aasmtai.pas 98 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345
  1. {
  2. Copyright (c) 1998-2006 by Florian Klaempfl
  3. This unit implements an abstract asmoutput class for all processor types
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. { @abstract(This unit implements an abstract asm output class for all processor types)
  18. This unit implements an abstract assembler output class for all processors, these
  19. are then overridden for each assembler writer to actually write the data in these
  20. classes to an assembler file.
  21. }
  22. unit aasmtai;
  23. {$i fpcdefs.inc}
  24. interface
  25. uses
  26. cutils,cclasses,
  27. globtype,systems,
  28. cpuinfo,cpubase,
  29. {$ifdef llvm}
  30. { overrides max_operands }
  31. llvmbase,
  32. {$endif llvm}
  33. cgbase,cgutils,
  34. symtype,
  35. aasmbase,aasmdata,ogbase
  36. {$ifdef jvm}
  37. ,widestr
  38. {$endif jvm}
  39. ;
  40. type
  41. { keep the number of elements in this enumeration less or equal than 32 as long
  42. as FPC knows only 4 byte and 32 byte sets (FK) }
  43. taitype = (
  44. ait_none,
  45. ait_align,
  46. ait_section,
  47. ait_comment,
  48. ait_string,
  49. ait_instruction,
  50. ait_datablock,
  51. ait_symbol,
  52. { needed to calc the size of a symbol }
  53. ait_symbol_end,
  54. ait_directive,
  55. ait_label,
  56. ait_const,
  57. ait_realconst,
  58. ait_typedconst,
  59. ait_stab,
  60. ait_force_line,
  61. ait_function_name,
  62. ait_symbolpair,
  63. { used to split into tiny assembler files }
  64. ait_cutobject,
  65. ait_regalloc,
  66. ait_tempalloc,
  67. { used to mark assembler blocks and inlined functions }
  68. ait_marker,
  69. { used to describe a new location of a variable }
  70. ait_varloc,
  71. {$ifdef JVM}
  72. { JVM only }
  73. ait_jvar, { debug information for a local variable }
  74. ait_jcatch, { exception catch clause }
  75. {$endif JVM}
  76. {$ifdef llvm}
  77. ait_llvmins, { llvm instruction }
  78. ait_llvmalias, { alias for a symbol }
  79. ait_llvmdecl, { llvm symbol declaration (global/external variable, external procdef) }
  80. {$endif}
  81. { SEH directives used in ARM,MIPS and x86_64 COFF targets }
  82. ait_seh_directive
  83. );
  84. taiconst_type = (
  85. aitconst_128bit,
  86. aitconst_64bit,
  87. aitconst_32bit,
  88. aitconst_16bit,
  89. aitconst_8bit,
  90. aitconst_sleb128bit,
  91. aitconst_uleb128bit,
  92. { win32 only }
  93. aitconst_rva_symbol,
  94. aitconst_secrel32_symbol,
  95. { darwin only }
  96. { From gcc/config/darwin.c (darwin_asm_output_dwarf_delta):
  97. ***
  98. Output a difference of two labels that will be an assembly time
  99. constant if the two labels are local. (.long lab1-lab2 will be
  100. very different if lab1 is at the boundary between two sections; it
  101. will be relocated according to the second section, not the first,
  102. so one ends up with a difference between labels in different
  103. sections, which is bad in the dwarf2 eh context for instance.)
  104. ***
  105. We cannot use this everywhere, because older versions of the
  106. darwin assembler don't support the construct used for these
  107. relsyms (nor do they support dwarf, for that matter)
  108. }
  109. aitconst_darwin_dwarf_delta64,
  110. aitconst_darwin_dwarf_delta32,
  111. { ARM Thumb-2 only }
  112. aitconst_half16bit, { used for table jumps. The actual value is the 16bit value shifted left once }
  113. { AVR }
  114. aitconst_gs, { Upper 16-bit of 17-bit constant }
  115. { for use by dwarf debugger information }
  116. aitconst_16bit_unaligned,
  117. aitconst_32bit_unaligned,
  118. aitconst_64bit_unaligned,
  119. { i8086 far pointer; emits: 'DW symbol, SEG symbol' }
  120. aitconst_farptr,
  121. { i8086 segment of symbol; emits: 'DW SEG symbol' }
  122. aitconst_seg,
  123. { i8086 data segment group; emits: 'DW dgroup'
  124. generated by the this inline asm:
  125. DW SEG @DATA
  126. in all memory models, except huge }
  127. aitconst_dgroup,
  128. { i8086 far data segment of the current pascal module (unit or program);
  129. emits: 'DW CURRENTMODULENAME_DATA'
  130. generated by the this inline asm:
  131. DW SEG @DATA
  132. in the huge memory model }
  133. aitconst_fardataseg,
  134. { offset of symbol's GOT slot in GOT }
  135. aitconst_got,
  136. { offset of symbol itself from GOT }
  137. aitconst_gotoff_symbol
  138. );
  139. tairealconsttype = (
  140. aitrealconst_s32bit,
  141. aitrealconst_s64bit,
  142. aitrealconst_s80bit,
  143. aitrealconst_s128bit,
  144. aitrealconst_s64comp
  145. );
  146. const
  147. {$if defined(cpu64bitaddr)}
  148. aitconst_ptr = aitconst_64bit;
  149. aitconst_ptr_unaligned = aitconst_64bit_unaligned;
  150. aitconst_sizeint = aitconst_64bit;
  151. aitconst_sizeint_unaligned = aitconst_64bit_unaligned;
  152. {$elseif defined(cpu32bitaddr)}
  153. aitconst_ptr = aitconst_32bit;
  154. aitconst_ptr_unaligned = aitconst_32bit_unaligned;
  155. aitconst_sizeint = aitconst_32bit;
  156. aitconst_sizeint_unaligned = aitconst_32bit_unaligned;
  157. {$elseif defined(cpu16bitaddr)}
  158. aitconst_ptr = aitconst_16bit;
  159. aitconst_ptr_unaligned = aitconst_16bit_unaligned;
  160. aitconst_sizeint = aitconst_16bit;
  161. aitconst_sizeint_unaligned = aitconst_16bit_unaligned;
  162. {$endif}
  163. {$if defined(cpu64bitalu)}
  164. aitconst_aint = aitconst_64bit;
  165. {$elseif defined(cpu32bitalu)}
  166. aitconst_aint = aitconst_32bit;
  167. {$elseif defined(cpu16bitalu)}
  168. aitconst_aint = aitconst_16bit;
  169. {$elseif defined(cpu8bitalu)}
  170. aitconst_aint = aitconst_8bit;
  171. {$endif}
  172. taitypestr : array[taitype] of string[24] = (
  173. '<none>',
  174. 'align',
  175. 'section',
  176. 'comment',
  177. 'string',
  178. 'instruction',
  179. 'datablock',
  180. 'symbol',
  181. 'symbol_end',
  182. 'symbol_directive',
  183. 'label',
  184. 'const',
  185. 'realconst',
  186. 'typedconst',
  187. 'stab',
  188. 'force_line',
  189. 'function_name',
  190. 'symbolpair',
  191. 'cut',
  192. 'regalloc',
  193. 'tempalloc',
  194. 'marker',
  195. 'varloc',
  196. {$ifdef JVM}
  197. 'jvar',
  198. 'jcatch',
  199. {$endif JVM}
  200. {$ifdef llvm}
  201. 'llvmins',
  202. 'llvmalias',
  203. 'llvmdecl',
  204. {$endif}
  205. 'seh_directive'
  206. );
  207. type
  208. { Types of operand }
  209. toptype=(top_none,top_reg,top_ref,top_const,top_bool,top_local
  210. {$ifdef arm}
  211. { ARM only }
  212. ,top_regset
  213. ,top_modeflags
  214. ,top_specialreg
  215. {$endif arm}
  216. {$if defined(arm) or defined(aarch64)}
  217. ,top_conditioncode
  218. ,top_shifterop
  219. {$endif defined(arm) or defined(aarch64)}
  220. {$ifdef m68k}
  221. { m68k only }
  222. ,top_regset
  223. ,top_regpair
  224. ,top_realconst
  225. {$endif m68k}
  226. {$ifdef jvm}
  227. { jvm only}
  228. ,top_single
  229. ,top_double
  230. ,top_string
  231. ,top_wstring
  232. {$endif jvm}
  233. {$ifdef llvm}
  234. { llvm only }
  235. ,top_single
  236. ,top_double
  237. ,top_undef
  238. {$ifdef cpuextended}
  239. ,top_extended80
  240. {$endif cpuextended}
  241. ,top_tai
  242. ,top_def
  243. ,top_fpcond
  244. ,top_cond
  245. ,top_para
  246. ,top_asmlist
  247. {$endif llvm}
  248. );
  249. { kinds of operations that an instruction can perform on an operand }
  250. topertype = (operand_read,operand_write,operand_readwrite);
  251. tlocaloper = record
  252. localsym : pointer;
  253. localsymderef : tderef;
  254. localsymofs : longint;
  255. {$ifdef x86}
  256. localsegment,
  257. {$endif x86}
  258. localindexreg : tregister;
  259. localscale : byte;
  260. localgetoffset,
  261. localforceref : boolean
  262. end;
  263. plocaloper = ^tlocaloper;
  264. const
  265. { ait_* types which don't result in executable code or which don't influence
  266. the way the program runs/behaves, but which may be encountered by the
  267. optimizer (= if it's sometimes added to the exprasm list). Update if you add
  268. a new ait type! }
  269. SkipInstr = [ait_comment, ait_symbol,ait_section
  270. ,ait_stab, ait_function_name, ait_force_line
  271. ,ait_regalloc, ait_tempalloc, ait_symbol_end
  272. ,ait_directive
  273. ,ait_varloc,
  274. {$ifdef JVM}
  275. ait_jvar,
  276. {$endif JVM}
  277. ait_seh_directive];
  278. { ait_* types which do not have line information (and hence which are of type
  279. tai, otherwise, they are of type tailineinfo }
  280. SkipLineInfo =[ait_label,
  281. ait_regalloc,ait_tempalloc,
  282. ait_stab,ait_function_name,
  283. ait_cutobject,ait_marker,ait_varloc,ait_align,ait_section,ait_comment,
  284. ait_const,ait_directive,
  285. ait_symbolpair,
  286. ait_realconst,
  287. ait_symbol,
  288. {$ifdef JVM}
  289. ait_jvar, ait_jcatch,
  290. {$endif JVM}
  291. {$ifdef llvm}
  292. ait_llvmdecl,
  293. {$endif llvm}
  294. ait_seh_directive
  295. ];
  296. type
  297. { cut type, required for alphanumeric ordering of the assembler filenames }
  298. TCutPlace=(cut_normal,cut_begin,cut_end);
  299. TAsmMarker = (
  300. mark_NoPropInfoStart,mark_NoPropInfoEnd,
  301. mark_AsmBlockStart,mark_AsmBlockEnd,
  302. mark_NoLineInfoStart,mark_NoLineInfoEnd,mark_BlockStart,
  303. mark_Position
  304. );
  305. TRegAllocType = (ra_alloc,ra_dealloc,ra_sync,ra_resize,ra_markused);
  306. TStabType = (stab_stabs,stab_stabn,stab_stabd,
  307. { AIX/XCOFF stab types }
  308. stab_stabx,
  309. { begin/end include file }
  310. stabx_bi,stabx_ei,
  311. { begin/end function }
  312. stabx_bf, stabx_ef,
  313. { begin/end static data block }
  314. stabx_bs, stabx_es,
  315. { line spec, function start/end label }
  316. stabx_line, stabx_function);
  317. TAsmDirective=(
  318. asd_indirect_symbol,
  319. asd_extern,asd_nasm_import, asd_toc_entry,
  320. asd_reference,asd_no_dead_strip,asd_weak_reference,asd_lazy_reference,
  321. asd_weak_definition,
  322. { for Jasmin }
  323. asd_jclass,asd_jinterface,asd_jsuper,asd_jfield,asd_jlimit,asd_jline,
  324. { .ent/.end for MIPS }
  325. asd_ent,asd_ent_end,
  326. { supported by recent clang-based assemblers for data-in-code }
  327. asd_data_region, asd_end_data_region,
  328. { ARM }
  329. asd_thumb_func,asd_code,
  330. { restricts the assembler only to those instructions, which are
  331. available on the specified CPU; this represents directives such as
  332. NASM's 'CPU 686' or MASM/TASM's '.686p'. Might not be supported by
  333. all assemblers. }
  334. asd_cpu,
  335. { for the OMF object format }
  336. asd_omf_linnum_line
  337. );
  338. TAsmSehDirective=(
  339. ash_proc,ash_endproc,
  340. ash_endprologue,ash_handler,ash_handlerdata,
  341. ash_eh,ash_32,ash_no32,
  342. ash_setframe,ash_stackalloc,ash_pushreg,
  343. ash_savereg,ash_savexmm,ash_pushframe,
  344. ash_pushnv,ash_savenv
  345. );
  346. TSymbolPairKind = (spk_set, spk_thumb_set, spk_localentry);
  347. const
  348. regallocstr : array[tregalloctype] of string[10]=('allocated','released','sync','resized','used');
  349. tempallocstr : array[boolean] of string[10]=('released','allocated');
  350. stabtypestr : array[TStabType] of string[8]=(
  351. 'stabs','stabn','stabd',
  352. 'stabx',
  353. 'bi','ei',
  354. 'bf','ef',
  355. 'bs','es',
  356. 'line','function');
  357. directivestr : array[TAsmDirective] of string[23]=(
  358. 'indirect_symbol',
  359. 'extern','nasm_import', 'tc', 'reference',
  360. 'no_dead_strip','weak','lazy_reference','weak',
  361. { for Jasmin }
  362. 'class','interface','super','field','limit','line',
  363. { .ent/.end for MIPS }
  364. 'ent','end',
  365. { supported by recent clang-based assemblers for data-in-code }
  366. 'data_region','end_data_region',
  367. { ARM }
  368. 'thumb_func',
  369. 'code',
  370. 'cpu',
  371. { for the OMF object format }
  372. 'omf_line'
  373. );
  374. sehdirectivestr : array[TAsmSehDirective] of string[16]=(
  375. '.seh_proc','.seh_endproc',
  376. '.seh_endprologue','.seh_handler','.seh_handlerdata',
  377. '.seh_eh','.seh_32','seh_no32',
  378. '.seh_setframe','.seh_stackalloc','.seh_pushreg',
  379. '.seh_savereg','.seh_savexmm','.seh_pushframe',
  380. '.pushnv','.savenv'
  381. );
  382. symbolpairkindstr: array[TSymbolPairKind] of string[11]=(
  383. '.set', '.thumb_set', '.localentry'
  384. );
  385. type
  386. tai = class;
  387. { please keep the size of this record <=12 bytes and keep it properly aligned }
  388. toper = record
  389. ot : longint;
  390. case typ : toptype of
  391. top_none : ();
  392. top_reg : (reg:tregister);
  393. top_ref : (ref:preference);
  394. top_const : (val:tcgint);
  395. top_bool : (b:boolean);
  396. { local varsym that will be inserted in pass_generate_code }
  397. top_local : (localoper:plocaloper);
  398. {$ifdef arm}
  399. top_regset : (regset:^tcpuregisterset; regtyp: tregistertype; subreg: tsubregister; usermode: boolean);
  400. top_modeflags : (modeflags : tcpumodeflags);
  401. top_specialreg : (specialreg:tregister; specialflags:tspecialregflags);
  402. {$endif arm}
  403. {$if defined(arm) or defined(aarch64)}
  404. top_shifterop : (shifterop : pshifterop);
  405. top_conditioncode : (cc : TAsmCond);
  406. {$endif defined(arm) or defined(aarch64)}
  407. {$ifdef m68k}
  408. top_regset : (dataregset,addrregset,fpuregset: tcpuregisterset);
  409. top_regpair : (reghi,reglo: tregister);
  410. top_realconst : (val_real:bestreal);
  411. {$endif m68k}
  412. {$ifdef jvm}
  413. top_single : (sval:single);
  414. top_double : (dval:double);
  415. top_string : (pcvallen: aint; pcval: pchar);
  416. top_wstring : (pwstrval: pcompilerwidestring);
  417. {$endif jvm}
  418. {$ifdef llvm}
  419. top_single : (sval:single);
  420. top_double : (dval:double);
  421. top_undef : ();
  422. {$ifdef cpuextended}
  423. top_extended80 : (eval:extended);
  424. {$endif cpuextended}
  425. top_tai : (ai: tai);
  426. top_def : (def: tdef);
  427. top_cond : (cond: topcmp);
  428. top_fpcond : (fpcond: tllvmfpcmp);
  429. top_para : (paras: tfplist);
  430. top_asmlist : (asmlist: tasmlist);
  431. {$endif llvm}
  432. end;
  433. poper=^toper;
  434. { abstract assembler item }
  435. tai = class(TLinkedListItem)
  436. {$ifndef NOOPT}
  437. { pointer to record with optimizer info about this tai object }
  438. optinfo : pointer;
  439. {$endif NOOPT}
  440. typ : taitype;
  441. constructor Create;
  442. constructor ppuload(t:taitype;ppufile:tcompilerppufile);virtual;
  443. procedure ppuwrite(ppufile:tcompilerppufile);virtual;
  444. procedure buildderefimpl;virtual;
  445. procedure derefimpl;virtual;
  446. end;
  447. { abstract assembler item with line information }
  448. tailineinfo = class(tai)
  449. fileinfo : tfileposinfo;
  450. constructor Create;
  451. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  452. procedure ppuwrite(ppufile:tcompilerppufile);override;
  453. end;
  454. tai_simple = class(tai)
  455. constructor create(_typ : taitype);
  456. end;
  457. taiclass = class of tai;
  458. taiclassarray = array[taitype] of taiclass;
  459. { Generates an assembler string }
  460. tai_string = class(tailineinfo)
  461. str : pchar;
  462. { extra len so the string can contain an \0 }
  463. len : longint;
  464. constructor Create(const _str : string);
  465. constructor Create_pchar(_str : pchar;length : longint);
  466. destructor Destroy;override;
  467. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  468. procedure ppuwrite(ppufile:tcompilerppufile);override;
  469. function getcopy:tlinkedlistitem;override;
  470. end;
  471. { Generates a common label }
  472. tai_symbol = class(tai)
  473. sym : tasmsymbol;
  474. value : puint;
  475. size : longint;
  476. is_global,
  477. has_value : boolean;
  478. constructor Create(_sym:tasmsymbol;siz:longint);
  479. constructor Create_Global(_sym:tasmsymbol;siz:longint);
  480. constructor Createname(const _name : string;_symtyp:Tasmsymtype;siz:longint;def:tdef);
  481. constructor Createname_global(const _name : string;_symtyp:Tasmsymtype;siz:longint;def:tdef);
  482. constructor Createname_global_value(const _name : string;_symtyp:Tasmsymtype;siz:longint;val:ptruint;def:tdef);
  483. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  484. procedure ppuwrite(ppufile:tcompilerppufile);override;
  485. procedure derefimpl;override;
  486. end;
  487. tai_symbol_end = class(tailineinfo)
  488. sym : tasmsymbol;
  489. constructor Create(_sym:tasmsymbol);
  490. constructor Createname(const _name : string);
  491. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  492. procedure ppuwrite(ppufile:tcompilerppufile);override;
  493. procedure derefimpl;override;
  494. end;
  495. tai_directive = class(tailineinfo)
  496. name : ansistring;
  497. directive : TAsmDirective;
  498. constructor Create(_directive:TAsmDirective;const _name:ansistring);
  499. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  500. procedure ppuwrite(ppufile:tcompilerppufile);override;
  501. end;
  502. { Generates an assembler label }
  503. tai_label = class(tai)
  504. labsym : tasmlabel;
  505. {$ifdef arm}
  506. { set to true when the label has been moved by insertpcrelativedata to the correct location
  507. so one label can be used multiple times }
  508. moved : boolean;
  509. { true, if a label has been already inserted, this is important for arm thumb where no negative
  510. pc relative offsets are allowed }
  511. inserted : boolean;
  512. {$endif arm}
  513. constructor Create(_labsym : tasmlabel);
  514. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  515. procedure ppuwrite(ppufile:tcompilerppufile);override;
  516. procedure derefimpl;override;
  517. end;
  518. { Generates an assembler comment }
  519. tai_comment = class(tai)
  520. str : pchar;
  521. constructor Create(_str : pchar);
  522. destructor Destroy; override;
  523. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  524. procedure ppuwrite(ppufile:tcompilerppufile);override;
  525. function getcopy:tlinkedlistitem;override;
  526. end;
  527. { Generates a section / segment directive }
  528. tai_section = class(tai)
  529. sectype : TAsmSectiontype;
  530. secorder : TasmSectionorder;
  531. secalign : longint;
  532. name : pshortstring;
  533. sec : TObjSection; { used in binary writer }
  534. destructor Destroy;override;
  535. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  536. procedure ppuwrite(ppufile:tcompilerppufile);override;
  537. {$push}{$warnings off}
  538. private
  539. { this constructor is made private on purpose }
  540. { because sections should be created via new_section() }
  541. constructor Create(Asectype:TAsmSectiontype;const Aname:string;Aalign:longint;Asecorder:TasmSectionorder=secorder_default);
  542. {$pop}
  543. end;
  544. { Generates an uninitializised data block }
  545. tai_datablock = class(tailineinfo)
  546. is_global : boolean;
  547. sym : tasmsymbol;
  548. size : asizeint;
  549. constructor Create(const _name : string;_size : asizeint; def: tdef);
  550. constructor Create_global(const _name : string;_size : asizeint; def: tdef);
  551. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  552. procedure ppuwrite(ppufile:tcompilerppufile);override;
  553. procedure derefimpl;override;
  554. end;
  555. { Generates an integer const }
  556. { tai_const }
  557. tai_const = class(tai)
  558. sym,
  559. endsym : tasmsymbol;
  560. { if symbols and offset are provided the symofs is used,
  561. the value is calculated during assembling }
  562. symofs,
  563. value : int64;
  564. consttype : taiconst_type;
  565. { we use for the 128bit int64/qword for now because I can't imagine a
  566. case where we need 128 bit now (FK) }
  567. constructor Create(_typ:taiconst_type;_value : int64);
  568. constructor Create_128bit(_value : int64);
  569. constructor Create_64bit(_value : int64);
  570. constructor Create_32bit(_value : longint);
  571. constructor Create_16bit(_value : word);
  572. constructor Create_64bit_unaligned(_value : int64);
  573. constructor Create_32bit_unaligned(_value : longint);
  574. constructor Create_16bit_unaligned(_value : word);
  575. constructor Create_8bit(_value : byte);
  576. constructor Create_char(size: integer; _value: dword);
  577. constructor Create_sleb128bit(_value : int64);
  578. constructor Create_uleb128bit(_value : qword);
  579. constructor Create_aint(_value : aint);
  580. constructor Create_sizeint(_value : asizeint);
  581. constructor Create_sizeint_unaligned(_value : asizeint);
  582. constructor Create_sym(_sym:tasmsymbol);
  583. {$ifdef i8086}
  584. constructor Create_sym_near(_sym:tasmsymbol);
  585. constructor Create_sym_far(_sym:tasmsymbol);
  586. constructor Createname_near(const name:string;ofs:asizeint);
  587. constructor Createname_far(const name:string;ofs:asizeint);
  588. constructor Createname_near(const name:string;_symtyp:Tasmsymtype;ofs:asizeint);
  589. constructor Createname_far(const name:string;_symtyp:Tasmsymtype;ofs:asizeint);
  590. {$endif i8086}
  591. constructor Create_type_sym(_typ:taiconst_type;_sym:tasmsymbol);
  592. constructor Create_sym_offset(_sym:tasmsymbol;ofs:asizeint);
  593. constructor Create_type_sym_offset(_typ:taiconst_type;_sym:tasmsymbol;ofs:asizeint);
  594. constructor Create_rel_sym(_typ:taiconst_type;_sym,_endsym:tasmsymbol);
  595. constructor Create_rel_sym_offset(_typ : taiconst_type; _sym,_endsym : tasmsymbol; _ofs : int64);
  596. constructor Create_rva_sym(_sym:tasmsymbol);
  597. constructor Createname(const name:string;ofs:asizeint);
  598. constructor Createname(const name:string;_symtyp:Tasmsymtype;ofs:asizeint);
  599. constructor Create_type_name(_typ:taiconst_type;const name:string;ofs:asizeint);
  600. constructor Create_type_name(_typ:taiconst_type;const name:string;_symtyp:Tasmsymtype;ofs:asizeint);
  601. constructor Create_nil_codeptr;
  602. constructor Create_nil_codeptr_unaligned;
  603. constructor Create_nil_dataptr;
  604. constructor Create_nil_dataptr_unaligned;
  605. constructor Create_int_codeptr(_value: int64);
  606. constructor Create_int_codeptr_unaligned(_value: int64);
  607. constructor Create_int_dataptr(_value: int64);
  608. constructor Create_int_dataptr_unaligned(_value: int64);
  609. {$ifdef i8086}
  610. constructor Create_seg_name(const name:string);
  611. constructor Create_dgroup;
  612. constructor Create_fardataseg;
  613. {$endif i8086}
  614. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  615. procedure ppuwrite(ppufile:tcompilerppufile);override;
  616. procedure derefimpl;override;
  617. function getcopy:tlinkedlistitem;override;
  618. function size:longint;
  619. end;
  620. { floating point const }
  621. tformatoptions = (fo_none,fo_hiloswapped);
  622. tai_realconst = class(tai)
  623. realtyp: tairealconsttype;
  624. savesize: byte;
  625. value: record
  626. case tairealconsttype of
  627. aitrealconst_s32bit: (s32val: ts32real);
  628. aitrealconst_s64bit: (s64val: ts64real);
  629. aitrealconst_s80bit: (s80val: ts80real);
  630. aitrealconst_s128bit: (s128val: ts128real);
  631. aitrealconst_s64comp: (s64compval: ts64comp);
  632. end;
  633. {$ifdef ARM}
  634. formatoptions : tformatoptions;
  635. {$endif ARM}
  636. constructor create_s32real(val: ts32real);
  637. constructor create_s64real(val: ts64real);
  638. {$ifdef ARM}
  639. constructor create_s64real_hiloswapped(val : ts64real);
  640. {$endif ARM}
  641. constructor create_s80real(val: ts80real; _savesize: byte);
  642. constructor create_s128real(val: ts128real);
  643. constructor create_s64compreal(val: ts64comp);
  644. constructor ppuload(t: taitype;ppufile: tcompilerppufile); override;
  645. procedure ppuwrite(ppufile: tcompilerppufile); override;
  646. function getcopy:tlinkedlistitem;override;
  647. function datasize: word;
  648. end;
  649. { tai_stab }
  650. tai_stab = class(tai)
  651. str : pchar;
  652. stabtype : TStabType;
  653. constructor Create(_stabtype:TStabType;_str : pchar);
  654. constructor Create_str(_stabtype:TStabType;const s:string);
  655. constructor create_ansistr(_stabtype: TStabType; const s: ansistring);
  656. destructor Destroy;override;
  657. end;
  658. tai_force_line = class(tailineinfo)
  659. constructor Create;
  660. end;
  661. tai_function_name = class(tai)
  662. funcname : pshortstring;
  663. constructor create(const s:string);
  664. destructor destroy;override;
  665. end;
  666. { Insert a cut to split assembler into several smaller files }
  667. tai_cutobject = class(tai)
  668. place : tcutplace;
  669. constructor Create;
  670. constructor Create_begin;
  671. constructor Create_end;
  672. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  673. procedure ppuwrite(ppufile:tcompilerppufile);override;
  674. end;
  675. { Insert a marker for assembler and inline blocks }
  676. tai_marker = class(tai)
  677. Kind: TAsmMarker;
  678. Constructor Create(_Kind: TAsmMarker);
  679. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  680. procedure ppuwrite(ppufile:tcompilerppufile);override;
  681. end;
  682. tai_tempalloc = class(tai)
  683. allocation : boolean;
  684. {$ifdef EXTDEBUG}
  685. problem : pshortstring;
  686. {$endif EXTDEBUG}
  687. temppos,
  688. tempsize : longint;
  689. constructor alloc(pos,size:longint);
  690. constructor dealloc(pos,size:longint);
  691. {$ifdef EXTDEBUG}
  692. constructor allocinfo(pos,size:longint;const st:string);
  693. {$endif EXTDEBUG}
  694. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  695. destructor destroy;override;
  696. procedure ppuwrite(ppufile:tcompilerppufile);override;
  697. end;
  698. tai_regalloc = class(tai)
  699. reg : tregister;
  700. ratype : TRegAllocType;
  701. { tells BuildLabelTableAndFixRegAlloc that the deallocation should be kept }
  702. keep : boolean;
  703. { reg(de)alloc belongs to this instruction, this
  704. is only used for automatic inserted (de)alloc for
  705. imaginary register and required for spilling code }
  706. instr : tai;
  707. constructor alloc(r : tregister;ainstr:tai);
  708. constructor dealloc(r : tregister;ainstr:tai);
  709. constructor sync(r : tregister);
  710. constructor resize(r : tregister);
  711. constructor markused(r : tregister);
  712. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  713. procedure ppuwrite(ppufile:tcompilerppufile);override;
  714. end;
  715. tadd_reg_instruction_proc=procedure(instr:Tai;r:tregister) of object;
  716. { Class template for assembler instructions
  717. }
  718. tai_cpu_abstract = class(tailineinfo)
  719. protected
  720. procedure ppuloadoper(ppufile:tcompilerppufile;var o:toper);virtual;
  721. procedure ppuwriteoper(ppufile:tcompilerppufile;const o:toper);virtual;
  722. procedure ppubuildderefimploper(var o:toper);virtual;abstract;
  723. procedure ppuderefoper(var o:toper);virtual;abstract;
  724. public
  725. { Condition flags for instruction }
  726. condition : TAsmCond;
  727. { Number of operands to instruction }
  728. ops : byte;
  729. { Number of allocate oper structures }
  730. opercnt : byte;
  731. { Operands of instruction }
  732. oper : array[0..max_operands-1] of poper;
  733. { Actual opcode of instruction }
  734. opcode : tasmop;
  735. {$ifdef x86}
  736. segprefix : tregister;
  737. {$endif x86}
  738. { true if instruction is a jmp }
  739. is_jmp : boolean; { is this instruction a jump? (needed for optimizer) }
  740. Constructor Create(op : tasmop);virtual;
  741. Destructor Destroy;override;
  742. function getcopy:TLinkedListItem;override;
  743. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  744. procedure ppuwrite(ppufile:tcompilerppufile);override;
  745. procedure buildderefimpl;override;
  746. procedure derefimpl;override;
  747. procedure SetCondition(const c:TAsmCond);
  748. procedure allocate_oper(opers:longint);
  749. procedure loadconst(opidx:longint;l:tcgint);
  750. procedure loadsymbol(opidx:longint;s:tasmsymbol;sofs:longint);
  751. procedure loadlocal(opidx:longint;s:pointer;sofs:longint;indexreg:tregister;scale:byte;getoffset,forceref:boolean);
  752. procedure loadref(opidx:longint;const r:treference);
  753. procedure loadreg(opidx:longint;r:tregister);
  754. procedure loadoper(opidx:longint;o:toper); virtual;
  755. procedure clearop(opidx:longint); virtual;
  756. procedure freeop(opidx:longint);
  757. { register allocator }
  758. function is_same_reg_move(regtype: Tregistertype):boolean;virtual;
  759. function spilling_get_operation_type(opnr: longint): topertype;virtual;
  760. function spilling_get_operation_type_ref(opnr: longint; reg: tregister): topertype;virtual;
  761. function Pass1(objdata:TObjData):longint;virtual;
  762. procedure Pass2(objdata:TObjData);virtual;
  763. procedure resetpass1; virtual;
  764. procedure resetpass2; virtual;
  765. end;
  766. tai_cpu_class = class of tai_cpu_abstract;
  767. { Buffer type used for alignment }
  768. tfillbuffer = array[0..63] of char;
  769. { alignment for operator }
  770. tai_align_abstract = class(tai)
  771. aligntype : byte; { 1 = no align, 2 = word align, 4 = dword align }
  772. fillsize : byte; { real size to fill }
  773. fillop : byte; { value to fill with - optional }
  774. use_op : boolean;
  775. constructor Create(b:byte);virtual;
  776. constructor Create_op(b: byte; _op: byte);virtual;
  777. constructor Create_zeros(b:byte);
  778. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  779. procedure ppuwrite(ppufile:tcompilerppufile);override;
  780. function calculatefillbuf(var buf : tfillbuffer;executable : boolean):pchar;virtual;
  781. end;
  782. tai_align_class = class of tai_align_abstract;
  783. tai_varloc = class(tai)
  784. newlocation,
  785. newlocationhi : tregister;
  786. varsym : tsym;
  787. constructor create(sym : tsym;loc : tregister);
  788. constructor create64(sym : tsym;loc,lochi : tregister);
  789. {$ifdef cpu64bitalu}
  790. constructor create128(sym : tsym;loc,lochi : tregister);
  791. {$endif cpu64bitalu}
  792. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  793. procedure ppuwrite(ppufile:tcompilerppufile);override;
  794. procedure buildderefimpl;override;
  795. procedure derefimpl;override;
  796. end;
  797. TSehDirectiveDatatype=(sd_none,sd_string,sd_reg,sd_offset,sd_regoffset);
  798. TSehDirectiveData=record
  799. case typ: TSehDirectiveDatatype of
  800. sd_none: ();
  801. sd_string: (name:pshortstring;flags:byte);
  802. sd_reg,sd_offset,sd_regoffset: (reg:TRegister;offset:dword);
  803. end;
  804. tai_seh_directive = class(tai)
  805. kind: TAsmSehDirective;
  806. data: TSehDirectiveData;
  807. constructor create(_kind:TAsmSehDirective);
  808. constructor create_name(_kind:TAsmSehDirective;const _name: string);
  809. constructor create_reg(_kind:TAsmSehDirective;r:TRegister);
  810. constructor create_offset(_kind:TAsmSehDirective;ofs:dword);
  811. constructor create_reg_offset(_kind:TAsmSehDirective;r:TRegister;ofs:dword);
  812. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  813. destructor destroy;override;
  814. procedure ppuwrite(ppufile:tcompilerppufile);override;
  815. procedure generate_code(objdata:TObjData);virtual;
  816. property datatype: TSehDirectiveDatatype read data.typ;
  817. end;
  818. tai_seh_directive_class=class of tai_seh_directive;
  819. {$ifdef JVM}
  820. { JVM variable live range description }
  821. tai_jvar = class(tai)
  822. stackslot: longint;
  823. desc: pshortstring;
  824. startlab,stoplab: tasmsymbol;
  825. constructor Create(_stackslot: longint; const _desc: shortstring; _startlab, _stoplab: TAsmSymbol);
  826. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  827. procedure ppuwrite(ppufile:tcompilerppufile);override;
  828. destructor destroy;override;
  829. end;
  830. tai_jvar_class = class of tai_jvar;
  831. { JVM exception catch description }
  832. tai_jcatch = class(tai)
  833. name: pshortstring;
  834. startlab,stoplab,handlerlab: tasmsymbol;
  835. constructor Create(const _name: shortstring; _startlab, _stoplab, _handlerlab: TAsmSymbol);
  836. destructor destroy;override;
  837. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  838. procedure ppuwrite(ppufile:tcompilerppufile);override;
  839. end;
  840. tai_jcatch_class = class of tai_jcatch;
  841. {$endif JVM}
  842. tai_symbolpair = class(tai)
  843. kind: TSymbolPairKind;
  844. sym,
  845. value: pshortstring;
  846. constructor create(akind: TSymbolPairKind; const asym, avalue: string);
  847. destructor destroy;override;
  848. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  849. procedure ppuwrite(ppufile:tcompilerppufile);override;
  850. end;
  851. var
  852. { array with all class types for tais }
  853. aiclass : taiclassarray;
  854. { target specific tais, possibly overwritten in target specific aasmcpu }
  855. cai_align : tai_align_class = tai_align_abstract;
  856. cai_cpu : tai_cpu_class = tai_cpu_abstract;
  857. cai_seh_directive: tai_seh_directive_class = tai_seh_directive;
  858. { hook to notify uses of registers }
  859. add_reg_instruction_hook : tadd_reg_instruction_proc;
  860. procedure maybe_new_object_file(list:TAsmList);
  861. procedure new_section(list:TAsmList;Asectype:TAsmSectiontype;const Aname:string;Aalign:byte;Asecorder:TasmSectionorder=secorder_default);
  862. function ppuloadai(ppufile:tcompilerppufile):tai;
  863. procedure ppuwriteai(ppufile:tcompilerppufile;n:tai);
  864. implementation
  865. uses
  866. {$ifdef x86}
  867. aasmcpu,
  868. {$endif x86}
  869. SysUtils,
  870. verbose,
  871. globals;
  872. const
  873. pputaimarker = 254;
  874. {****************************************************************************
  875. Helpers
  876. ****************************************************************************}
  877. procedure maybe_new_object_file(list:TAsmList);
  878. begin
  879. if create_smartlink_library then
  880. list.concat(tai_cutobject.create);
  881. end;
  882. procedure new_section(list:TAsmList;Asectype:TAsmSectiontype;const Aname:string;Aalign:byte;Asecorder:TasmSectionorder=secorder_default);
  883. begin
  884. list.concat(tai_section.create(Asectype,Aname,Aalign,Asecorder));
  885. inc(list.section_count);
  886. list.concat(cai_align.create(Aalign));
  887. end;
  888. function ppuloadai(ppufile:tcompilerppufile):tai;
  889. var
  890. b : byte;
  891. t : taitype;
  892. begin
  893. { marker }
  894. b:=ppufile.getbyte;
  895. if b<>pputaimarker then
  896. internalerror(200208181);
  897. { load nodetype }
  898. t:=taitype(ppufile.getbyte);
  899. if t<>ait_none then
  900. begin
  901. if t>high(taitype) then
  902. internalerror(200208182);
  903. if not assigned(aiclass[t]) then
  904. internalerror(200208183);
  905. {writeln('taiload: ',taitypestr[t]);}
  906. { generate tai of the correct class }
  907. ppuloadai:=aiclass[t].ppuload(t,ppufile);
  908. end
  909. else
  910. ppuloadai:=nil;
  911. end;
  912. procedure ppuwriteai(ppufile:tcompilerppufile;n:tai);
  913. begin
  914. { marker, read by ppuloadnode }
  915. ppufile.putbyte(pputaimarker);
  916. if assigned(n) then
  917. begin
  918. { type, read by ppuloadnode }
  919. ppufile.putbyte(byte(n.typ));
  920. {writeln('taiwrite: ',taitypestr[n.typ]);}
  921. n.ppuwrite(ppufile);
  922. end
  923. else
  924. ppufile.putbyte(byte(ait_none));
  925. end;
  926. constructor tai_symbolpair.create(akind: TSymbolPairKind; const asym, avalue: string);
  927. begin
  928. inherited create;
  929. kind:=akind;
  930. typ:=ait_symbolpair;
  931. sym:=stringdup(asym);
  932. value:=stringdup(avalue);
  933. end;
  934. destructor tai_symbolpair.destroy;
  935. begin
  936. stringdispose(sym);
  937. stringdispose(value);
  938. inherited destroy;
  939. end;
  940. constructor tai_symbolpair.ppuload(t: taitype; ppufile: tcompilerppufile);
  941. begin
  942. inherited ppuload(t,ppufile);
  943. kind:=TSymbolPairKind(ppufile.getbyte);;
  944. sym:=ppufile.getpshortstring;
  945. value:=ppufile.getpshortstring;
  946. end;
  947. procedure tai_symbolpair.ppuwrite(ppufile: tcompilerppufile);
  948. begin
  949. inherited ppuwrite(ppufile);
  950. ppufile.putbyte(byte(kind));
  951. ppufile.putstring(sym^);
  952. ppufile.putstring(value^);
  953. end;
  954. constructor tai_varloc.create(sym: tsym; loc: tregister);
  955. begin
  956. inherited Create;
  957. typ:=ait_varloc;
  958. newlocation:=loc;
  959. newlocationhi:=NR_NO;
  960. varsym:=sym;
  961. end;
  962. constructor tai_varloc.create64(sym: tsym; loc, lochi: tregister);
  963. begin
  964. inherited Create;
  965. typ:=ait_varloc;
  966. newlocation:=loc;
  967. newlocationhi:=lochi;
  968. varsym:=sym;
  969. end;
  970. {$ifdef cpu64bitalu}
  971. constructor tai_varloc.create128(sym: tsym; loc, lochi: tregister);
  972. begin
  973. inherited Create;
  974. typ:=ait_varloc;
  975. newlocation:=loc;
  976. newlocationhi:=lochi;
  977. varsym:=sym;
  978. end;
  979. {$endif cpu64bitalu}
  980. constructor tai_varloc.ppuload(t: taitype; ppufile: tcompilerppufile);
  981. begin
  982. inherited ppuload(t, ppufile);
  983. end;
  984. procedure tai_varloc.ppuwrite(ppufile: tcompilerppufile);
  985. begin
  986. inherited ppuwrite(ppufile);
  987. end;
  988. procedure tai_varloc.buildderefimpl;
  989. begin
  990. inherited buildderefimpl;
  991. end;
  992. procedure tai_varloc.derefimpl;
  993. begin
  994. inherited derefimpl;
  995. end;
  996. {****************************************************************************
  997. TAI
  998. ****************************************************************************}
  999. constructor tai.Create;
  1000. begin
  1001. {$ifndef NOOPT}
  1002. optinfo:=nil;
  1003. {$endif NOOPT}
  1004. end;
  1005. constructor tai.ppuload(t:taitype;ppufile:tcompilerppufile);
  1006. begin
  1007. typ:=t;
  1008. {$ifndef NOOPT}
  1009. optinfo:=nil;
  1010. {$endif}
  1011. end;
  1012. procedure tai.ppuwrite(ppufile:tcompilerppufile);
  1013. begin
  1014. end;
  1015. procedure tai.buildderefimpl;
  1016. begin
  1017. end;
  1018. procedure tai.derefimpl;
  1019. begin
  1020. end;
  1021. {****************************************************************************
  1022. TAILINEINFO
  1023. ****************************************************************************}
  1024. constructor tailineinfo.create;
  1025. begin
  1026. inherited create;
  1027. fileinfo:=current_filepos;
  1028. end;
  1029. constructor tailineinfo.ppuload(t:taitype;ppufile:tcompilerppufile);
  1030. begin
  1031. inherited ppuload(t,ppufile);
  1032. ppufile.getposinfo(fileinfo);
  1033. end;
  1034. procedure tailineinfo.ppuwrite(ppufile:tcompilerppufile);
  1035. begin
  1036. inherited ppuwrite(ppufile);
  1037. ppufile.putposinfo(fileinfo);
  1038. end;
  1039. {****************************************************************************
  1040. TAI_SIMPLE
  1041. ****************************************************************************}
  1042. constructor tai_simple.create(_typ : taitype);
  1043. begin
  1044. inherited create;
  1045. typ:=_typ;
  1046. end;
  1047. {****************************************************************************
  1048. TAI_SECTION
  1049. ****************************************************************************}
  1050. constructor tai_section.Create(Asectype:TAsmSectiontype;const Aname:string;Aalign:longint;Asecorder:TasmSectionorder=secorder_default);
  1051. begin
  1052. inherited Create;
  1053. typ:=ait_section;
  1054. sectype:=asectype;
  1055. secalign:=Aalign;
  1056. secorder:=Asecorder;
  1057. name:=stringdup(Aname);
  1058. sec:=nil;
  1059. end;
  1060. constructor tai_section.ppuload(t:taitype;ppufile:tcompilerppufile);
  1061. begin
  1062. inherited ppuload(t,ppufile);
  1063. sectype:=TAsmSectiontype(ppufile.getbyte);
  1064. secalign:=ppufile.getlongint;
  1065. name:=ppufile.getpshortstring;
  1066. sec:=nil;
  1067. end;
  1068. destructor tai_section.Destroy;
  1069. begin
  1070. stringdispose(name);
  1071. end;
  1072. procedure tai_section.ppuwrite(ppufile:tcompilerppufile);
  1073. begin
  1074. inherited ppuwrite(ppufile);
  1075. ppufile.putbyte(byte(sectype));
  1076. ppufile.putlongint(secalign);
  1077. ppufile.putstring(name^);
  1078. end;
  1079. {****************************************************************************
  1080. TAI_DATABLOCK
  1081. ****************************************************************************}
  1082. constructor tai_datablock.Create(const _name : string;_size : asizeint; def: tdef);
  1083. begin
  1084. inherited Create;
  1085. typ:=ait_datablock;
  1086. sym:=current_asmdata.DefineAsmSymbol(_name,AB_LOCAL,AT_DATA,def);
  1087. { keep things aligned }
  1088. if _size<=0 then
  1089. _size:=sizeof(aint);
  1090. size:=_size;
  1091. is_global:=false;
  1092. end;
  1093. constructor tai_datablock.Create_global(const _name : string;_size : asizeint; def: tdef);
  1094. begin
  1095. inherited Create;
  1096. typ:=ait_datablock;
  1097. sym:=current_asmdata.DefineAsmSymbol(_name,AB_GLOBAL,AT_DATA,def);
  1098. { keep things aligned }
  1099. if _size<=0 then
  1100. _size:=sizeof(aint);
  1101. size:=_size;
  1102. is_global:=true;
  1103. end;
  1104. constructor tai_datablock.ppuload(t:taitype;ppufile:tcompilerppufile);
  1105. begin
  1106. inherited Create;
  1107. sym:=ppufile.getasmsymbol;
  1108. size:=ppufile.getaint;
  1109. is_global:=ppufile.getboolean;
  1110. end;
  1111. procedure tai_datablock.ppuwrite(ppufile:tcompilerppufile);
  1112. begin
  1113. inherited ppuwrite(ppufile);
  1114. ppufile.putasmsymbol(sym);
  1115. ppufile.putaint(size);
  1116. ppufile.putboolean(is_global);
  1117. end;
  1118. procedure tai_datablock.derefimpl;
  1119. begin
  1120. end;
  1121. {****************************************************************************
  1122. TAI_SYMBOL
  1123. ****************************************************************************}
  1124. constructor tai_symbol.Create(_sym:tasmsymbol;siz:longint);
  1125. begin
  1126. inherited Create;
  1127. typ:=ait_symbol;
  1128. sym:=_sym;
  1129. size:=siz;
  1130. { don't redefine global/external symbols as local, as code to access
  1131. such symbols is different on some platforms }
  1132. if not(sym.bind in [AB_NONE,AB_LOCAL]) then
  1133. internalerror(2013081601);
  1134. sym.bind:=AB_LOCAL;
  1135. is_global:=false;
  1136. end;
  1137. constructor tai_symbol.Create_global(_sym:tasmsymbol;siz:longint);
  1138. begin
  1139. inherited Create;
  1140. typ:=ait_symbol;
  1141. sym:=_sym;
  1142. size:=siz;
  1143. { don't override PRIVATE_EXTERN with GLOBAL }
  1144. if not(sym.bind in [AB_GLOBAL,AB_PRIVATE_EXTERN]) then
  1145. sym.bind:=AB_GLOBAL;
  1146. is_global:=true;
  1147. end;
  1148. constructor tai_symbol.Createname(const _name : string;_symtyp:Tasmsymtype;siz:longint;def:tdef);
  1149. begin
  1150. inherited Create;
  1151. typ:=ait_symbol;
  1152. sym:=current_asmdata.DefineAsmSymbol(_name,AB_LOCAL,_symtyp,def);
  1153. size:=siz;
  1154. is_global:=false;
  1155. end;
  1156. constructor tai_symbol.Createname_global(const _name : string;_symtyp:Tasmsymtype;siz:longint;def:tdef);
  1157. begin
  1158. inherited Create;
  1159. typ:=ait_symbol;
  1160. sym:=current_asmdata.DefineAsmSymbol(_name,AB_GLOBAL,_symtyp,def);
  1161. size:=siz;
  1162. is_global:=true;
  1163. end;
  1164. constructor tai_symbol.createname_global_value(const _name: string;_symtyp: tasmsymtype; siz: longint; val: ptruint;def:tdef);
  1165. begin
  1166. Createname_global(_name,_symtyp,siz,def);
  1167. value:=val;
  1168. has_value:=true;
  1169. end;
  1170. constructor tai_symbol.ppuload(t:taitype;ppufile:tcompilerppufile);
  1171. begin
  1172. inherited ppuload(t,ppufile);
  1173. sym:=ppufile.getasmsymbol;
  1174. size:=ppufile.getlongint;
  1175. is_global:=ppufile.getboolean;
  1176. end;
  1177. procedure tai_symbol.ppuwrite(ppufile:tcompilerppufile);
  1178. begin
  1179. inherited ppuwrite(ppufile);
  1180. ppufile.putasmsymbol(sym);
  1181. ppufile.putlongint(size);
  1182. ppufile.putboolean(is_global);
  1183. end;
  1184. procedure tai_symbol.derefimpl;
  1185. begin
  1186. end;
  1187. {****************************************************************************
  1188. TAI_SYMBOL_END
  1189. ****************************************************************************}
  1190. constructor tai_symbol_end.Create(_sym:tasmsymbol);
  1191. begin
  1192. inherited Create;
  1193. typ:=ait_symbol_end;
  1194. sym:=_sym;
  1195. end;
  1196. constructor tai_symbol_end.Createname(const _name : string);
  1197. begin
  1198. inherited Create;
  1199. typ:=ait_symbol_end;
  1200. sym:=current_asmdata.GetAsmSymbol(_name);
  1201. if not assigned(sym) then
  1202. internalerror(2013080301);
  1203. end;
  1204. constructor tai_symbol_end.ppuload(t:taitype;ppufile:tcompilerppufile);
  1205. begin
  1206. inherited ppuload(t,ppufile);
  1207. sym:=ppufile.getasmsymbol;
  1208. end;
  1209. procedure tai_symbol_end.ppuwrite(ppufile:tcompilerppufile);
  1210. begin
  1211. inherited ppuwrite(ppufile);
  1212. ppufile.putasmsymbol(sym);
  1213. end;
  1214. procedure tai_symbol_end.derefimpl;
  1215. begin
  1216. end;
  1217. {****************************************************************************
  1218. TAI_SYMBOL_END
  1219. ****************************************************************************}
  1220. constructor tai_directive.Create(_directive:TAsmDirective;const _name:ansistring);
  1221. begin
  1222. inherited Create;
  1223. typ:=ait_directive;
  1224. name:=_name;
  1225. directive:=_directive;
  1226. end;
  1227. constructor tai_directive.ppuload(t:taitype;ppufile:tcompilerppufile);
  1228. begin
  1229. inherited ppuload(t,ppufile);
  1230. name:=ppufile.getansistring;
  1231. directive:=TAsmDirective(ppufile.getbyte);
  1232. end;
  1233. procedure tai_directive.ppuwrite(ppufile:tcompilerppufile);
  1234. begin
  1235. inherited ppuwrite(ppufile);
  1236. ppufile.putansistring(name);
  1237. ppufile.putbyte(byte(directive));
  1238. end;
  1239. {****************************************************************************
  1240. TAI_CONST
  1241. ****************************************************************************}
  1242. constructor tai_const.Create(_typ:taiconst_type;_value : int64);
  1243. begin
  1244. inherited Create;
  1245. typ:=ait_const;
  1246. consttype:=_typ;
  1247. value:=_value;
  1248. sym:=nil;
  1249. endsym:=nil;
  1250. end;
  1251. constructor tai_const.Create_128bit(_value : int64);
  1252. begin
  1253. inherited Create;
  1254. typ:=ait_const;
  1255. consttype:=aitconst_128bit;
  1256. value:=_value;
  1257. sym:=nil;
  1258. endsym:=nil;
  1259. end;
  1260. constructor tai_const.Create_64bit(_value : int64);
  1261. begin
  1262. inherited Create;
  1263. typ:=ait_const;
  1264. consttype:=aitconst_64bit;
  1265. value:=_value;
  1266. sym:=nil;
  1267. endsym:=nil;
  1268. end;
  1269. constructor tai_const.Create_32bit(_value : longint);
  1270. begin
  1271. inherited Create;
  1272. typ:=ait_const;
  1273. consttype:=aitconst_32bit;
  1274. value:=_value;
  1275. sym:=nil;
  1276. endsym:=nil;
  1277. end;
  1278. constructor tai_const.Create_16bit(_value : word);
  1279. begin
  1280. inherited Create;
  1281. typ:=ait_const;
  1282. consttype:=aitconst_16bit;
  1283. value:=_value;
  1284. sym:=nil;
  1285. endsym:=nil;
  1286. end;
  1287. constructor tai_const.Create_64bit_unaligned(_value : int64);
  1288. begin
  1289. inherited Create;
  1290. typ:=ait_const;
  1291. consttype:=aitconst_64bit_unaligned;
  1292. value:=_value;
  1293. sym:=nil;
  1294. endsym:=nil;
  1295. end;
  1296. constructor tai_const.Create_32bit_unaligned(_value : longint);
  1297. begin
  1298. inherited Create;
  1299. typ:=ait_const;
  1300. consttype:=aitconst_32bit_unaligned;
  1301. value:=_value;
  1302. sym:=nil;
  1303. endsym:=nil;
  1304. end;
  1305. constructor tai_const.Create_16bit_unaligned(_value : word);
  1306. begin
  1307. inherited Create;
  1308. typ:=ait_const;
  1309. consttype:=aitconst_16bit_unaligned;
  1310. value:=_value;
  1311. sym:=nil;
  1312. endsym:=nil;
  1313. end;
  1314. constructor tai_const.Create_8bit(_value : byte);
  1315. begin
  1316. inherited Create;
  1317. typ:=ait_const;
  1318. consttype:=aitconst_8bit;
  1319. value:=_value;
  1320. sym:=nil;
  1321. endsym:=nil;
  1322. end;
  1323. constructor tai_const.Create_char(size: integer; _value: dword);
  1324. begin
  1325. inherited Create;
  1326. typ:=ait_const;
  1327. case size of
  1328. 1:
  1329. begin
  1330. consttype:=aitconst_8bit;
  1331. value:=byte(_value)
  1332. end;
  1333. 2:
  1334. begin
  1335. consttype:=aitconst_16bit;
  1336. value:=word(_value)
  1337. end
  1338. else
  1339. InternalError(2010030701)
  1340. end
  1341. end;
  1342. constructor tai_const.Create_sleb128bit(_value : int64);
  1343. begin
  1344. inherited Create;
  1345. typ:=ait_const;
  1346. consttype:=aitconst_sleb128bit;
  1347. value:=_value;
  1348. sym:=nil;
  1349. endsym:=nil;
  1350. end;
  1351. constructor tai_const.Create_uleb128bit(_value : qword);
  1352. begin
  1353. inherited Create;
  1354. typ:=ait_const;
  1355. consttype:=aitconst_uleb128bit;
  1356. value:=int64(_value);
  1357. sym:=nil;
  1358. endsym:=nil;
  1359. end;
  1360. constructor tai_const.Create_aint(_value : aint);
  1361. begin
  1362. inherited Create;
  1363. typ:=ait_const;
  1364. consttype:=aitconst_aint;
  1365. value:=_value;
  1366. sym:=nil;
  1367. endsym:=nil;
  1368. end;
  1369. constructor tai_const.Create_sizeint(_value : asizeint);
  1370. begin
  1371. inherited Create;
  1372. typ:=ait_const;
  1373. consttype:=aitconst_sizeint;
  1374. value:=_value;
  1375. sym:=nil;
  1376. endsym:=nil;
  1377. end;
  1378. constructor tai_const.Create_sizeint_unaligned(_value : asizeint);
  1379. begin
  1380. inherited Create;
  1381. typ:=ait_const;
  1382. consttype:=aitconst_sizeint_unaligned;
  1383. value:=_value;
  1384. sym:=nil;
  1385. endsym:=nil;
  1386. end;
  1387. constructor tai_const.Create_type_sym(_typ:taiconst_type;_sym:tasmsymbol);
  1388. begin
  1389. inherited Create;
  1390. typ:=ait_const;
  1391. consttype:=_typ;
  1392. sym:=_sym;
  1393. endsym:=nil;
  1394. value:=0;
  1395. { update sym info }
  1396. if assigned(sym) then
  1397. sym.increfs;
  1398. end;
  1399. constructor tai_const.Create_sym(_sym:tasmsymbol);
  1400. begin
  1401. self.create_sym_offset(_sym,0);
  1402. end;
  1403. {$ifdef i8086}
  1404. constructor tai_const.Create_sym_near(_sym: tasmsymbol);
  1405. begin
  1406. self.create_sym(_sym);
  1407. consttype:=aitconst_ptr;
  1408. end;
  1409. constructor tai_const.Create_sym_far(_sym: tasmsymbol);
  1410. begin
  1411. self.create_sym(_sym);
  1412. consttype:=aitconst_farptr;
  1413. end;
  1414. constructor tai_const.Createname_near(const name:string;ofs:asizeint);
  1415. begin
  1416. self.Createname(name,ofs);
  1417. consttype:=aitconst_ptr;
  1418. end;
  1419. constructor tai_const.Createname_far(const name:string;ofs:asizeint);
  1420. begin
  1421. self.Createname(name,ofs);
  1422. consttype:=aitconst_farptr;
  1423. end;
  1424. constructor tai_const.Createname_near(const name:string;_symtyp:Tasmsymtype;ofs:asizeint);
  1425. begin
  1426. self.Createname(name,_symtyp,ofs);
  1427. consttype:=aitconst_ptr;
  1428. end;
  1429. constructor tai_const.Createname_far(const name:string;_symtyp:Tasmsymtype;ofs:asizeint);
  1430. begin
  1431. self.Createname(name,_symtyp,ofs);
  1432. consttype:=aitconst_farptr;
  1433. end;
  1434. {$endif i8086}
  1435. constructor tai_const.Create_sym_offset(_sym:tasmsymbol;ofs:asizeint);
  1436. begin
  1437. inherited Create;
  1438. typ:=ait_const;
  1439. {$ifdef i8086}
  1440. if assigned(_sym) and (_sym.typ=AT_DATA) then
  1441. begin
  1442. if current_settings.x86memorymodel in x86_far_data_models then
  1443. consttype:=aitconst_farptr
  1444. else
  1445. consttype:=aitconst_ptr;
  1446. end
  1447. else
  1448. begin
  1449. if current_settings.x86memorymodel in x86_far_code_models then
  1450. consttype:=aitconst_farptr
  1451. else
  1452. consttype:=aitconst_ptr;
  1453. end;
  1454. {$else i8086}
  1455. {$ifdef avr}
  1456. if assigned(_sym) and (_sym.typ=AT_FUNCTION) then
  1457. consttype:=aitconst_gs
  1458. else
  1459. {$endif avr}
  1460. consttype:=aitconst_ptr;
  1461. {$endif i8086}
  1462. { sym is allowed to be nil, this is used to write nil pointers }
  1463. sym:=_sym;
  1464. endsym:=nil;
  1465. { store the original offset in symofs so that we can recalculate the
  1466. value field in the assembler }
  1467. symofs:=ofs;
  1468. value:=ofs;
  1469. { update sym info }
  1470. if assigned(sym) then
  1471. sym.increfs;
  1472. end;
  1473. constructor tai_const.Create_type_sym_offset(_typ : taiconst_type;_sym : tasmsymbol; ofs : asizeint);
  1474. begin
  1475. inherited Create;
  1476. typ:=ait_const;
  1477. consttype:=_typ;
  1478. { sym is allowed to be nil, this is used to write nil pointers }
  1479. sym:=_sym;
  1480. endsym:=nil;
  1481. { store the original offset in symofs so that we can recalculate the
  1482. value field in the assembler }
  1483. symofs:=ofs;
  1484. value:=ofs;
  1485. { update sym info }
  1486. if assigned(sym) then
  1487. sym.increfs;
  1488. end;
  1489. constructor tai_const.Create_rel_sym(_typ:taiconst_type;_sym,_endsym:tasmsymbol);
  1490. begin
  1491. self.create_sym_offset(_sym,0);
  1492. consttype:=_typ;
  1493. endsym:=_endsym;
  1494. endsym.increfs;
  1495. end;
  1496. constructor tai_const.Create_rel_sym_offset(_typ: taiconst_type; _sym,_endsym: tasmsymbol; _ofs: int64);
  1497. begin
  1498. self.create_sym_offset(_sym,_ofs);
  1499. consttype:=_typ;
  1500. endsym:=_endsym;
  1501. endsym.increfs;
  1502. end;
  1503. constructor tai_const.Create_rva_sym(_sym:tasmsymbol);
  1504. begin
  1505. self.create_sym_offset(_sym,0);
  1506. consttype:=aitconst_rva_symbol;
  1507. end;
  1508. constructor tai_const.Createname(const name:string;ofs:asizeint);
  1509. begin
  1510. self.Createname(name,AT_NONE,ofs);
  1511. end;
  1512. constructor tai_const.Createname(const name:string;_symtyp:Tasmsymtype;ofs:asizeint);
  1513. begin
  1514. self.create_sym_offset(current_asmdata.RefAsmSymbol(name,_symtyp),ofs);
  1515. end;
  1516. constructor tai_const.Create_type_name(_typ:taiconst_type;const name:string;ofs:asizeint);
  1517. begin
  1518. self.Create_type_name(_typ,name,AT_NONE,ofs);
  1519. end;
  1520. constructor tai_const.Create_type_name(_typ:taiconst_type;const name:string;_symtyp:Tasmsymtype;ofs:asizeint);
  1521. begin
  1522. self.create_sym_offset(current_asmdata.RefAsmSymbol(name,_symtyp),ofs);
  1523. consttype:=_typ;
  1524. end;
  1525. constructor tai_const.Create_nil_codeptr;
  1526. begin
  1527. self.Create_int_codeptr(0);
  1528. end;
  1529. constructor tai_const.Create_nil_codeptr_unaligned;
  1530. begin
  1531. self.Create_int_codeptr_unaligned(0);
  1532. end;
  1533. constructor tai_const.Create_nil_dataptr;
  1534. begin
  1535. self.Create_int_dataptr(0);
  1536. end;
  1537. constructor tai_const.Create_nil_dataptr_unaligned;
  1538. begin
  1539. self.Create_int_dataptr_unaligned(0);
  1540. end;
  1541. constructor tai_const.Create_int_codeptr(_value: int64);
  1542. begin
  1543. inherited Create;
  1544. typ:=ait_const;
  1545. {$ifdef i8086}
  1546. if current_settings.x86memorymodel in x86_far_code_models then
  1547. consttype:=aitconst_farptr
  1548. else
  1549. {$endif i8086}
  1550. {$ifdef avr}
  1551. consttype:=aitconst_gs;
  1552. {$else avr}
  1553. consttype:=aitconst_ptr;
  1554. {$endif avr}
  1555. sym:=nil;
  1556. endsym:=nil;
  1557. symofs:=0;
  1558. value:=_value;
  1559. end;
  1560. constructor tai_const.Create_int_codeptr_unaligned(_value: int64);
  1561. begin
  1562. inherited Create;
  1563. typ:=ait_const;
  1564. {$ifdef i8086}
  1565. if current_settings.x86memorymodel in x86_far_code_models then
  1566. consttype:=aitconst_farptr
  1567. else
  1568. {$endif i8086}
  1569. {$ifdef avr}
  1570. consttype:=aitconst_gs;
  1571. {$else avr}
  1572. consttype:=aitconst_ptr_unaligned;
  1573. {$endif avr}
  1574. sym:=nil;
  1575. endsym:=nil;
  1576. symofs:=0;
  1577. value:=_value;
  1578. end;
  1579. constructor tai_const.Create_int_dataptr(_value: int64);
  1580. begin
  1581. inherited Create;
  1582. typ:=ait_const;
  1583. {$ifdef i8086}
  1584. if current_settings.x86memorymodel in x86_far_data_models then
  1585. consttype:=aitconst_farptr
  1586. else
  1587. {$endif i8086}
  1588. consttype:=aitconst_ptr;
  1589. sym:=nil;
  1590. endsym:=nil;
  1591. symofs:=0;
  1592. value:=_value;
  1593. end;
  1594. constructor tai_const.Create_int_dataptr_unaligned(_value: int64);
  1595. begin
  1596. inherited Create;
  1597. typ:=ait_const;
  1598. {$ifdef i8086}
  1599. if current_settings.x86memorymodel in x86_far_data_models then
  1600. consttype:=aitconst_farptr
  1601. else
  1602. {$endif i8086}
  1603. consttype:=aitconst_ptr_unaligned;
  1604. sym:=nil;
  1605. endsym:=nil;
  1606. symofs:=0;
  1607. value:=_value;
  1608. end;
  1609. {$ifdef i8086}
  1610. constructor tai_const.Create_seg_name(const name:string);
  1611. begin
  1612. self.Createname(name,0);
  1613. self.consttype:=aitconst_seg;
  1614. end;
  1615. constructor tai_const.Create_dgroup;
  1616. begin
  1617. self.Create_16bit(0);
  1618. self.consttype:=aitconst_dgroup;
  1619. end;
  1620. constructor tai_const.Create_fardataseg;
  1621. begin
  1622. self.Create_16bit(0);
  1623. self.consttype:=aitconst_fardataseg;
  1624. end;
  1625. {$endif i8086}
  1626. constructor tai_const.ppuload(t:taitype;ppufile:tcompilerppufile);
  1627. begin
  1628. inherited ppuload(t,ppufile);
  1629. consttype:=taiconst_type(ppufile.getbyte);
  1630. sym:=ppufile.getasmsymbol;
  1631. endsym:=ppufile.getasmsymbol;
  1632. value:=ppufile.getint64;
  1633. end;
  1634. procedure tai_const.ppuwrite(ppufile:tcompilerppufile);
  1635. begin
  1636. inherited ppuwrite(ppufile);
  1637. ppufile.putbyte(byte(consttype));
  1638. ppufile.putasmsymbol(sym);
  1639. ppufile.putasmsymbol(endsym);
  1640. ppufile.putint64(value);
  1641. end;
  1642. procedure tai_const.derefimpl;
  1643. begin
  1644. end;
  1645. function tai_const.getcopy:tlinkedlistitem;
  1646. begin
  1647. getcopy:=inherited getcopy;
  1648. { we need to increase the reference number }
  1649. if assigned(sym) then
  1650. sym.increfs;
  1651. if assigned(endsym) then
  1652. endsym.increfs;
  1653. end;
  1654. function tai_const.size:longint;
  1655. begin
  1656. case consttype of
  1657. aitconst_8bit :
  1658. result:=1;
  1659. aitconst_16bit,aitconst_16bit_unaligned :
  1660. result:=2;
  1661. aitconst_32bit,aitconst_darwin_dwarf_delta32,
  1662. aitconst_32bit_unaligned:
  1663. result:=4;
  1664. aitconst_64bit,aitconst_darwin_dwarf_delta64,
  1665. aitconst_64bit_unaligned:
  1666. result:=8;
  1667. aitconst_secrel32_symbol,
  1668. aitconst_rva_symbol :
  1669. if target_info.system=system_x86_64_win64 then
  1670. result:=sizeof(longint)
  1671. else
  1672. result:=sizeof(pint);
  1673. aitconst_uleb128bit :
  1674. result:=LengthUleb128(qword(value));
  1675. aitconst_sleb128bit :
  1676. result:=LengthSleb128(value);
  1677. aitconst_half16bit,
  1678. aitconst_gs:
  1679. result:=2;
  1680. aitconst_farptr:
  1681. result:=4;
  1682. aitconst_dgroup,
  1683. aitconst_fardataseg,
  1684. aitconst_seg:
  1685. result:=2;
  1686. aitconst_got:
  1687. result:=sizeof(pint);
  1688. aitconst_gotoff_symbol:
  1689. result:=4;
  1690. else
  1691. internalerror(200603253);
  1692. end;
  1693. end;
  1694. {****************************************************************************
  1695. TAI_realconst
  1696. ****************************************************************************}
  1697. constructor tai_realconst.create_s32real(val: ts32real);
  1698. begin
  1699. inherited create;
  1700. typ:=ait_realconst;
  1701. realtyp:=aitrealconst_s32bit;
  1702. savesize:=4;
  1703. value.s32val:=val;
  1704. end;
  1705. constructor tai_realconst.create_s64real(val: ts64real);
  1706. begin
  1707. inherited create;
  1708. typ:=ait_realconst;
  1709. realtyp:=aitrealconst_s64bit;
  1710. savesize:=8;
  1711. value.s64val:=val;
  1712. end;
  1713. {$ifdef ARM}
  1714. constructor tai_realconst.create_s64real_hiloswapped(val : ts64real);
  1715. begin
  1716. inherited create;
  1717. typ:=ait_realconst;
  1718. realtyp:=aitrealconst_s64bit;
  1719. value.s64val:=val;
  1720. savesize:=8;
  1721. formatoptions:=fo_hiloswapped;
  1722. end;
  1723. {$endif ARM}
  1724. constructor tai_realconst.create_s80real(val: ts80real; _savesize: byte);
  1725. begin
  1726. inherited create;
  1727. typ:=ait_realconst;
  1728. realtyp:=aitrealconst_s80bit;
  1729. savesize:=_savesize;
  1730. value.s80val:=val;
  1731. end;
  1732. constructor tai_realconst.create_s128real(val: ts128real);
  1733. begin
  1734. inherited create;
  1735. typ:=ait_realconst;
  1736. realtyp:=aitrealconst_s128bit;
  1737. savesize:=16;
  1738. value.s128val:=val;
  1739. end;
  1740. constructor tai_realconst.create_s64compreal(val: ts64comp);
  1741. begin
  1742. inherited create;
  1743. typ:=ait_realconst;
  1744. realtyp:=aitrealconst_s64comp;
  1745. savesize:=8;
  1746. value.s64compval:=val;
  1747. end;
  1748. constructor tai_realconst.ppuload(t: taitype; ppufile: tcompilerppufile);
  1749. begin
  1750. inherited;
  1751. realtyp:=tairealconsttype(ppufile.getbyte);
  1752. {$ifdef ARM}
  1753. formatoptions:=tformatoptions(ppufile.getbyte);
  1754. {$endif ARM}
  1755. case realtyp of
  1756. aitrealconst_s32bit:
  1757. value.s32val:=ppufile.getreal;
  1758. aitrealconst_s64bit:
  1759. value.s64val:=ppufile.getreal;
  1760. aitrealconst_s80bit:
  1761. value.s80val:=ppufile.getreal;
  1762. aitrealconst_s128bit:
  1763. value.s128val:=ppufile.getreal;
  1764. aitrealconst_s64comp:
  1765. value.s64compval:=comp(ppufile.getint64);
  1766. else
  1767. internalerror(2014050602);
  1768. end;
  1769. end;
  1770. procedure tai_realconst.ppuwrite(ppufile: tcompilerppufile);
  1771. var
  1772. c: comp;
  1773. begin
  1774. inherited ppuwrite(ppufile);
  1775. ppufile.putbyte(byte(realtyp));
  1776. {$ifdef ARM}
  1777. ppufile.putbyte(byte(formatoptions));
  1778. {$endif ARM}
  1779. case realtyp of
  1780. aitrealconst_s32bit:
  1781. ppufile.putreal(value.s32val);
  1782. aitrealconst_s64bit:
  1783. ppufile.putreal(value.s64val);
  1784. aitrealconst_s80bit:
  1785. ppufile.putreal(value.s80val);
  1786. aitrealconst_s128bit:
  1787. ppufile.putreal(value.s128val);
  1788. aitrealconst_s64comp:
  1789. begin
  1790. c:=comp(value.s64compval);
  1791. ppufile.putint64(int64(c));
  1792. end
  1793. else
  1794. internalerror(2014050601);
  1795. end;
  1796. end;
  1797. function tai_realconst.getcopy: tlinkedlistitem;
  1798. begin
  1799. result:=inherited getcopy;
  1800. tai_realconst(result).value:=value;
  1801. tai_realconst(result).realtyp:=realtyp;
  1802. tai_realconst(result).savesize:=savesize;
  1803. {$ifdef ARM}
  1804. tai_realconst(result).formatoptions:=formatoptions;
  1805. {$endif ARM}
  1806. end;
  1807. function tai_realconst.datasize: word;
  1808. begin
  1809. case realtyp of
  1810. aitrealconst_s32bit:
  1811. result:=4;
  1812. aitrealconst_s64bit,
  1813. aitrealconst_s64comp:
  1814. result:=8;
  1815. aitrealconst_s80bit:
  1816. result:=10;
  1817. aitrealconst_s128bit:
  1818. result:=16;
  1819. else
  1820. internalerror(2014050603);
  1821. end;
  1822. end;
  1823. {****************************************************************************
  1824. TAI_STRING
  1825. ****************************************************************************}
  1826. constructor tai_string.Create(const _str : string);
  1827. begin
  1828. inherited Create;
  1829. typ:=ait_string;
  1830. len:=length(_str);
  1831. getmem(str,len+1);
  1832. move(_str[1],str^,len);
  1833. str[len]:=#0;
  1834. end;
  1835. constructor tai_string.Create_pchar(_str : pchar;length : longint);
  1836. begin
  1837. inherited Create;
  1838. typ:=ait_string;
  1839. str:=_str;
  1840. len:=length;
  1841. end;
  1842. destructor tai_string.destroy;
  1843. begin
  1844. if str<>nil then
  1845. freemem(str);
  1846. inherited Destroy;
  1847. end;
  1848. constructor tai_string.ppuload(t:taitype;ppufile:tcompilerppufile);
  1849. begin
  1850. inherited ppuload(t,ppufile);
  1851. len:=ppufile.getlongint;
  1852. getmem(str,len+1);
  1853. ppufile.getdata(str^,len);
  1854. str[len]:=#0
  1855. end;
  1856. procedure tai_string.ppuwrite(ppufile:tcompilerppufile);
  1857. begin
  1858. inherited ppuwrite(ppufile);
  1859. ppufile.putlongint(len);
  1860. ppufile.putdata(str^,len);
  1861. end;
  1862. function tai_string.getcopy : tlinkedlistitem;
  1863. var
  1864. p : tlinkedlistitem;
  1865. begin
  1866. p:=inherited getcopy;
  1867. getmem(tai_string(p).str,len);
  1868. move(str^,tai_string(p).str^,len);
  1869. getcopy:=p;
  1870. end;
  1871. {****************************************************************************
  1872. TAI_LABEL
  1873. ****************************************************************************}
  1874. constructor tai_label.Create(_labsym : tasmlabel);
  1875. begin
  1876. inherited Create;
  1877. typ:=ait_label;
  1878. labsym:=_labsym;
  1879. labsym.is_set:=true;
  1880. end;
  1881. constructor tai_label.ppuload(t:taitype;ppufile:tcompilerppufile);
  1882. begin
  1883. inherited ppuload(t,ppufile);
  1884. labsym:=tasmlabel(ppufile.getasmsymbol);
  1885. ppufile.getbyte; { was is_global flag, now unused }
  1886. end;
  1887. procedure tai_label.ppuwrite(ppufile:tcompilerppufile);
  1888. begin
  1889. inherited ppuwrite(ppufile);
  1890. ppufile.putasmsymbol(labsym);
  1891. ppufile.putbyte(0); { was is_global flag, now unused }
  1892. end;
  1893. procedure tai_label.derefimpl;
  1894. begin
  1895. labsym.is_set:=true;
  1896. end;
  1897. {****************************************************************************
  1898. tai_comment comment to be inserted in the assembler file
  1899. ****************************************************************************}
  1900. constructor tai_comment.Create(_str : pchar);
  1901. begin
  1902. inherited Create;
  1903. typ:=ait_comment;
  1904. str:=_str;
  1905. end;
  1906. destructor tai_comment.destroy;
  1907. begin
  1908. freemem(str);
  1909. inherited Destroy;
  1910. end;
  1911. constructor tai_comment.ppuload(t:taitype;ppufile:tcompilerppufile);
  1912. var
  1913. len : longint;
  1914. begin
  1915. inherited ppuload(t,ppufile);
  1916. len:=ppufile.getlongint;
  1917. getmem(str,len+1);
  1918. ppufile.getdata(str^,len);
  1919. str[len]:=#0;
  1920. end;
  1921. procedure tai_comment.ppuwrite(ppufile:tcompilerppufile);
  1922. var
  1923. len : longint;
  1924. begin
  1925. inherited ppuwrite(ppufile);
  1926. len:=strlen(str);
  1927. ppufile.putlongint(len);
  1928. ppufile.putdata(str^,len);
  1929. end;
  1930. function tai_comment.getcopy : tlinkedlistitem;
  1931. var
  1932. p : tlinkedlistitem;
  1933. begin
  1934. p:=inherited getcopy;
  1935. getmem(tai_comment(p).str,strlen(str)+1);
  1936. move(str^,tai_comment(p).str^,strlen(str)+1);
  1937. getcopy:=p;
  1938. end;
  1939. {****************************************************************************
  1940. TAI_STABS
  1941. ****************************************************************************}
  1942. constructor tai_stab.create(_stabtype:TStabType;_str : pchar);
  1943. begin
  1944. inherited create;
  1945. typ:=ait_stab;
  1946. str:=_str;
  1947. stabtype:=_stabtype;
  1948. end;
  1949. constructor tai_stab.create_str(_stabtype:TStabType;const s:string);
  1950. begin
  1951. self.create(_stabtype,strpnew(s));
  1952. end;
  1953. constructor tai_stab.create_ansistr(_stabtype:TStabType;const s:ansistring);
  1954. begin
  1955. inherited create;
  1956. typ:=ait_stab;
  1957. stabtype:=_stabtype;
  1958. getmem(str,length(s)+1);
  1959. if length(s)>0 then
  1960. move(s[1],str^,length(s)+1)
  1961. else
  1962. str^:=#0;
  1963. end;
  1964. destructor tai_stab.destroy;
  1965. begin
  1966. freemem(str);
  1967. inherited destroy;
  1968. end;
  1969. {****************************************************************************
  1970. TAI_FORCE_LINE
  1971. ****************************************************************************}
  1972. constructor tai_force_line.create;
  1973. begin
  1974. inherited create;
  1975. typ:=ait_force_line;
  1976. end;
  1977. {****************************************************************************
  1978. TAI_FUNCTION_NAME
  1979. ****************************************************************************}
  1980. constructor tai_function_name.create(const s:string);
  1981. begin
  1982. inherited create;
  1983. typ:=ait_function_name;
  1984. funcname:=stringdup(s);
  1985. end;
  1986. destructor tai_function_name.destroy;
  1987. begin
  1988. stringdispose(funcname);
  1989. inherited destroy;
  1990. end;
  1991. {****************************************************************************
  1992. TAI_CUTOBJECT
  1993. ****************************************************************************}
  1994. constructor tai_cutobject.Create;
  1995. begin
  1996. inherited Create;
  1997. typ:=ait_cutobject;
  1998. place:=cut_normal;
  1999. end;
  2000. constructor tai_cutobject.Create_begin;
  2001. begin
  2002. inherited Create;
  2003. typ:=ait_cutobject;
  2004. place:=cut_begin;
  2005. end;
  2006. constructor tai_cutobject.Create_end;
  2007. begin
  2008. inherited Create;
  2009. typ:=ait_cutobject;
  2010. place:=cut_end;
  2011. end;
  2012. constructor tai_cutobject.ppuload(t:taitype;ppufile:tcompilerppufile);
  2013. begin
  2014. inherited ppuload(t,ppufile);
  2015. place:=TCutPlace(ppufile.getbyte);
  2016. end;
  2017. procedure tai_cutobject.ppuwrite(ppufile:tcompilerppufile);
  2018. begin
  2019. inherited ppuwrite(ppufile);
  2020. ppufile.putbyte(byte(place));
  2021. end;
  2022. {****************************************************************************
  2023. Tai_Marker
  2024. ****************************************************************************}
  2025. constructor Tai_Marker.Create(_Kind: TAsmMarker);
  2026. begin
  2027. Inherited Create;
  2028. typ := ait_marker;
  2029. Kind := _Kind;
  2030. end;
  2031. constructor Tai_Marker.ppuload(t:taitype;ppufile:tcompilerppufile);
  2032. begin
  2033. inherited ppuload(t,ppufile);
  2034. kind:=TAsmMarker(ppufile.getbyte);
  2035. end;
  2036. procedure Tai_Marker.ppuwrite(ppufile:tcompilerppufile);
  2037. begin
  2038. inherited ppuwrite(ppufile);
  2039. ppufile.putbyte(byte(kind));
  2040. end;
  2041. {*****************************************************************************
  2042. tai_tempalloc
  2043. *****************************************************************************}
  2044. constructor tai_tempalloc.alloc(pos,size:longint);
  2045. begin
  2046. inherited Create;
  2047. typ:=ait_tempalloc;
  2048. allocation:=true;
  2049. temppos:=pos;
  2050. tempsize:=size;
  2051. {$ifdef EXTDEBUG}
  2052. problem:=nil;
  2053. {$endif EXTDEBUG}
  2054. end;
  2055. destructor tai_tempalloc.destroy;
  2056. begin
  2057. {$ifdef EXTDEBUG}
  2058. stringdispose(problem);
  2059. {$endif EXTDEBUG}
  2060. inherited destroy;
  2061. end;
  2062. constructor tai_tempalloc.dealloc(pos,size:longint);
  2063. begin
  2064. inherited Create;
  2065. typ:=ait_tempalloc;
  2066. allocation:=false;
  2067. temppos:=pos;
  2068. tempsize:=size;
  2069. {$ifdef EXTDEBUG}
  2070. problem:=nil;
  2071. {$endif EXTDEBUG}
  2072. end;
  2073. {$ifdef EXTDEBUG}
  2074. constructor tai_tempalloc.allocinfo(pos,size:longint;const st:string);
  2075. begin
  2076. inherited Create;
  2077. typ:=ait_tempalloc;
  2078. allocation:=false;
  2079. temppos:=pos;
  2080. tempsize:=size;
  2081. problem:=stringdup(st);
  2082. end;
  2083. {$endif EXTDEBUG}
  2084. constructor tai_tempalloc.ppuload(t:taitype;ppufile:tcompilerppufile);
  2085. begin
  2086. inherited ppuload(t,ppufile);
  2087. temppos:=ppufile.getlongint;
  2088. tempsize:=ppufile.getlongint;
  2089. allocation:=ppufile.getboolean;
  2090. {$ifdef EXTDEBUG}
  2091. problem:=nil;
  2092. {$endif EXTDEBUG}
  2093. end;
  2094. procedure tai_tempalloc.ppuwrite(ppufile:tcompilerppufile);
  2095. begin
  2096. inherited ppuwrite(ppufile);
  2097. ppufile.putlongint(temppos);
  2098. ppufile.putlongint(tempsize);
  2099. ppufile.putboolean(allocation);
  2100. end;
  2101. {*****************************************************************************
  2102. tai_regalloc
  2103. *****************************************************************************}
  2104. constructor tai_regalloc.alloc(r : tregister;ainstr:tai);
  2105. begin
  2106. inherited create;
  2107. typ:=ait_regalloc;
  2108. ratype:=ra_alloc;
  2109. reg:=r;
  2110. { ainstr must be an instruction }
  2111. if assigned(ainstr) and
  2112. (ainstr.typ<>ait_instruction) then
  2113. internalerror(200411011);
  2114. instr:=ainstr;
  2115. end;
  2116. constructor tai_regalloc.dealloc(r : tregister;ainstr:tai);
  2117. begin
  2118. inherited create;
  2119. typ:=ait_regalloc;
  2120. ratype:=ra_dealloc;
  2121. reg:=r;
  2122. { ainstr must be an instruction }
  2123. if assigned(ainstr) and
  2124. (ainstr.typ<>ait_instruction) then
  2125. internalerror(200411012);
  2126. instr:=ainstr;
  2127. end;
  2128. constructor tai_regalloc.sync(r : tregister);
  2129. begin
  2130. inherited create;
  2131. typ:=ait_regalloc;
  2132. ratype:=ra_sync;
  2133. reg:=r;
  2134. end;
  2135. constructor tai_regalloc.resize(r : tregister);
  2136. begin
  2137. inherited create;
  2138. typ:=ait_regalloc;
  2139. ratype:=ra_resize;
  2140. reg:=r;
  2141. end;
  2142. constructor tai_regalloc.markused(r : tregister);
  2143. begin
  2144. inherited create;
  2145. typ:=ait_regalloc;
  2146. ratype:=ra_markused;
  2147. reg:=r;
  2148. end;
  2149. constructor tai_regalloc.ppuload(t:taitype;ppufile:tcompilerppufile);
  2150. begin
  2151. inherited ppuload(t,ppufile);
  2152. ppufile.getdata(reg,sizeof(Tregister));
  2153. ratype:=tregalloctype(ppufile.getbyte);
  2154. keep:=ppufile.getboolean;
  2155. end;
  2156. procedure tai_regalloc.ppuwrite(ppufile:tcompilerppufile);
  2157. begin
  2158. inherited ppuwrite(ppufile);
  2159. ppufile.putdata(reg,sizeof(Tregister));
  2160. ppufile.putbyte(byte(ratype));
  2161. ppufile.putboolean(keep);
  2162. end;
  2163. {*****************************************************************************
  2164. TaiInstruction
  2165. *****************************************************************************}
  2166. constructor tai_cpu_abstract.Create(op : tasmop);
  2167. begin
  2168. inherited create;
  2169. typ:=ait_instruction;
  2170. is_jmp:=false;
  2171. opcode:=op;
  2172. ops:=0;
  2173. end;
  2174. destructor tai_cpu_abstract.Destroy;
  2175. var
  2176. i : integer;
  2177. begin
  2178. for i:=0 to opercnt-1 do
  2179. freeop(i);
  2180. inherited destroy;
  2181. end;
  2182. { ---------------------------------------------------------------------
  2183. Loading of operands.
  2184. ---------------------------------------------------------------------}
  2185. procedure tai_cpu_abstract.allocate_oper(opers:longint);
  2186. begin
  2187. while (opers>opercnt) do
  2188. begin
  2189. new(oper[opercnt]);
  2190. fillchar(oper[opercnt]^,sizeof(toper),0);
  2191. inc(opercnt);
  2192. end;
  2193. end;
  2194. procedure tai_cpu_abstract.loadconst(opidx:longint;l:tcgint);
  2195. begin
  2196. allocate_oper(opidx+1);
  2197. with oper[opidx]^ do
  2198. begin
  2199. if typ<>top_const then
  2200. clearop(opidx);
  2201. val:=l;
  2202. typ:=top_const;
  2203. end;
  2204. end;
  2205. procedure tai_cpu_abstract.loadsymbol(opidx:longint;s:tasmsymbol;sofs:longint);
  2206. var
  2207. r : treference;
  2208. begin
  2209. reference_reset_symbol(r,s,sofs,1,[]);
  2210. r.refaddr:=addr_full;
  2211. loadref(opidx,r);
  2212. end;
  2213. procedure tai_cpu_abstract.loadlocal(opidx:longint;s:pointer;sofs:longint;indexreg:tregister;scale:byte;getoffset,forceref:boolean);
  2214. begin
  2215. if not assigned(s) then
  2216. internalerror(200204251);
  2217. allocate_oper(opidx+1);
  2218. with oper[opidx]^ do
  2219. begin
  2220. if typ<>top_local then
  2221. begin
  2222. clearop(opidx);
  2223. new(localoper);
  2224. end;
  2225. with oper[opidx]^.localoper^ do
  2226. begin
  2227. localsym:=s;
  2228. localsymofs:=sofs;
  2229. localindexreg:=indexreg;
  2230. localscale:=scale;
  2231. localgetoffset:=getoffset;
  2232. localforceref:=forceref;
  2233. {$ifdef x86}
  2234. localsegment:=NR_NO;
  2235. {$endif x86}
  2236. end;
  2237. typ:=top_local;
  2238. end;
  2239. end;
  2240. procedure tai_cpu_abstract.loadref(opidx:longint;const r:treference);
  2241. {$ifdef x86}
  2242. var
  2243. si_param: ShortInt;
  2244. {$endif}
  2245. begin
  2246. allocate_oper(opidx+1);
  2247. with oper[opidx]^ do
  2248. begin
  2249. if typ<>top_ref then
  2250. begin
  2251. clearop(opidx);
  2252. new(ref);
  2253. end;
  2254. ref^:=r;
  2255. {$ifdef x86}
  2256. { We allow this exception for x86, since overloading this would be
  2257. too much of a a speed penalty}
  2258. if is_x86_parameterized_string_op(opcode) then
  2259. begin
  2260. si_param:=get_x86_string_op_si_param(opcode);
  2261. if (si_param<>-1) and (taicpu(self).OperandOrder=op_att) then
  2262. si_param:=x86_parameterized_string_op_param_count(opcode)-si_param-1;
  2263. if (si_param=opidx) and (ref^.segment<>NR_NO) and (ref^.segment<>NR_DS) then
  2264. segprefix:=ref^.segment;
  2265. end
  2266. else if (opcode=A_XLAT) and (ref^.segment<>NR_NO) and (ref^.segment<>NR_DS) then
  2267. segprefix:=ref^.segment
  2268. else if (ref^.segment<>NR_NO) and (ref^.segment<>get_default_segment_of_ref(ref^)) then
  2269. segprefix:=ref^.segment;
  2270. {$endif}
  2271. {$ifndef llvm}
  2272. if (cs_create_pic in current_settings.moduleswitches) and
  2273. assigned(r.symbol) and
  2274. not assigned(r.relsymbol) and
  2275. (r.refaddr=addr_no)
  2276. {$ifdef ARM}
  2277. and not(r.base=NR_R15)
  2278. {$endif ARM}
  2279. {$ifdef aarch64}
  2280. and not(r.refaddr in [addr_full,addr_gotpageoffset,addr_gotpage])
  2281. {$endif aarch64}
  2282. then
  2283. internalerror(200502052);
  2284. {$endif not llvm}
  2285. typ:=top_ref;
  2286. if assigned(add_reg_instruction_hook) then
  2287. begin
  2288. add_reg_instruction_hook(self,ref^.base);
  2289. add_reg_instruction_hook(self,ref^.index);
  2290. end;
  2291. { mark symbol as used }
  2292. if assigned(ref^.symbol) then
  2293. ref^.symbol.increfs;
  2294. if assigned(ref^.relsymbol) then
  2295. ref^.relsymbol.increfs;
  2296. end;
  2297. end;
  2298. procedure tai_cpu_abstract.loadreg(opidx:longint;r:tregister);
  2299. begin
  2300. allocate_oper(opidx+1);
  2301. with oper[opidx]^ do
  2302. begin
  2303. if typ<>top_reg then
  2304. clearop(opidx);
  2305. reg:=r;
  2306. typ:=top_reg;
  2307. end;
  2308. if assigned(add_reg_instruction_hook) then
  2309. add_reg_instruction_hook(self,r);
  2310. {$ifdef ARM}
  2311. { R15 is the PC on the ARM thus moves to R15 are jumps.
  2312. Due to speed considerations we don't use a virtual overridden method here.
  2313. Because the pc/r15 isn't handled by the reg. allocator this should never cause
  2314. problems with iregs getting r15.
  2315. }
  2316. is_jmp:=(opcode=A_MOV) and (opidx=0) and (r=NR_R15);
  2317. {$endif ARM}
  2318. end;
  2319. procedure tai_cpu_abstract.loadoper(opidx:longint;o:toper);
  2320. {$ifdef x86}
  2321. var
  2322. si_param: ShortInt;
  2323. {$endif x86}
  2324. begin
  2325. allocate_oper(opidx+1);
  2326. clearop(opidx);
  2327. oper[opidx]^:=o;
  2328. { copy also the reference }
  2329. with oper[opidx]^ do
  2330. begin
  2331. case typ of
  2332. top_reg:
  2333. begin
  2334. if assigned(add_reg_instruction_hook) then
  2335. add_reg_instruction_hook(self,reg);
  2336. end;
  2337. top_ref:
  2338. begin
  2339. new(ref);
  2340. ref^:=o.ref^;
  2341. {$ifdef x86}
  2342. { We allow this exception for x86, since overloading this would be
  2343. too much of a a speed penalty}
  2344. if is_x86_parameterized_string_op(opcode) then
  2345. begin
  2346. si_param:=get_x86_string_op_si_param(opcode);
  2347. if (si_param<>-1) and (taicpu(self).OperandOrder=op_att) then
  2348. si_param:=x86_parameterized_string_op_param_count(opcode)-si_param-1;
  2349. if (si_param=opidx) and (ref^.segment<>NR_NO) and (ref^.segment<>NR_DS) then
  2350. segprefix:=ref^.segment;
  2351. end
  2352. else if (opcode=A_XLAT) and (ref^.segment<>NR_NO) and (ref^.segment<>NR_DS) then
  2353. segprefix:=ref^.segment
  2354. else if (ref^.segment<>NR_NO) and (ref^.segment<>get_default_segment_of_ref(ref^)) then
  2355. segprefix:=ref^.segment;
  2356. {$endif x86}
  2357. if assigned(add_reg_instruction_hook) then
  2358. begin
  2359. add_reg_instruction_hook(self,ref^.base);
  2360. add_reg_instruction_hook(self,ref^.index);
  2361. end;
  2362. end;
  2363. {$ifdef ARM}
  2364. top_shifterop:
  2365. begin
  2366. new(shifterop);
  2367. shifterop^:=o.shifterop^;
  2368. if assigned(add_reg_instruction_hook) then
  2369. add_reg_instruction_hook(self,shifterop^.rs);
  2370. end;
  2371. {$endif ARM}
  2372. end;
  2373. end;
  2374. end;
  2375. procedure tai_cpu_abstract.clearop(opidx:longint);
  2376. begin
  2377. with oper[opidx]^ do
  2378. begin
  2379. case typ of
  2380. top_ref:
  2381. dispose(ref);
  2382. top_local:
  2383. dispose(localoper);
  2384. {$ifdef ARM}
  2385. top_shifterop:
  2386. dispose(shifterop);
  2387. top_regset:
  2388. dispose(regset);
  2389. {$endif ARM}
  2390. {$ifdef jvm}
  2391. top_string:
  2392. freemem(pcval);
  2393. top_wstring:
  2394. donewidestring(pwstrval);
  2395. {$endif jvm}
  2396. end;
  2397. typ:=top_none;
  2398. end;
  2399. end;
  2400. procedure tai_cpu_abstract.freeop(opidx:longint);
  2401. begin
  2402. clearop(opidx);
  2403. dispose(oper[opidx]);
  2404. end;
  2405. { ---------------------------------------------------------------------
  2406. Miscellaneous methods.
  2407. ---------------------------------------------------------------------}
  2408. procedure tai_cpu_abstract.SetCondition(const c:TAsmCond);
  2409. begin
  2410. condition:=c;
  2411. end;
  2412. Function tai_cpu_abstract.getcopy:TLinkedListItem;
  2413. var
  2414. i : longint;
  2415. p : tai_cpu_abstract;
  2416. begin
  2417. p:=tai_cpu_abstract(inherited getcopy);
  2418. { make a copy of the references }
  2419. p.opercnt:=0;
  2420. p.allocate_oper(ops);
  2421. for i:=0 to ops-1 do
  2422. begin
  2423. p.oper[i]^:=oper[i]^;
  2424. case oper[i]^.typ of
  2425. top_local :
  2426. begin
  2427. new(p.oper[i]^.localoper);
  2428. p.oper[i]^.localoper^:=oper[i]^.localoper^;
  2429. end;
  2430. top_ref :
  2431. begin
  2432. new(p.oper[i]^.ref);
  2433. p.oper[i]^.ref^:=oper[i]^.ref^;
  2434. end;
  2435. {$ifdef ARM}
  2436. top_shifterop:
  2437. begin
  2438. new(p.oper[i]^.shifterop);
  2439. p.oper[i]^.shifterop^:=oper[i]^.shifterop^;
  2440. end;
  2441. {$endif ARM}
  2442. end;
  2443. end;
  2444. getcopy:=p;
  2445. end;
  2446. function tai_cpu_abstract.is_same_reg_move(regtype: Tregistertype):boolean;
  2447. begin
  2448. { When the generic RA is used this needs to be overridden, we don't use
  2449. virtual;abstract; to prevent a lot of warnings of unimplemented abstract methods
  2450. when tai_cpu is created (PFV) }
  2451. internalerror(2004040901);
  2452. result:=false;
  2453. end;
  2454. function tai_cpu_abstract.spilling_get_operation_type(opnr: longint): topertype;
  2455. begin
  2456. internalerror(2004040902);
  2457. result:=operand_readwrite;
  2458. end;
  2459. function tai_cpu_abstract.spilling_get_operation_type_ref(opnr: longint; reg: tregister): topertype;
  2460. begin
  2461. result := operand_read;
  2462. end;
  2463. constructor tai_cpu_abstract.ppuload(t:taitype;ppufile:tcompilerppufile);
  2464. var
  2465. i : integer;
  2466. begin
  2467. inherited ppuload(t,ppufile);
  2468. { hopefully, we don't get problems with big/litte endian here when cross compiling :/ }
  2469. ppufile.getdata(condition,sizeof(tasmcond));
  2470. allocate_oper(ppufile.getbyte);
  2471. for i:=0 to ops-1 do
  2472. ppuloadoper(ppufile,oper[i]^);
  2473. opcode:=tasmop(ppufile.getword);
  2474. {$ifdef x86}
  2475. ppufile.getdata(segprefix,sizeof(Tregister));
  2476. {$endif x86}
  2477. is_jmp:=ppufile.getboolean;
  2478. end;
  2479. procedure tai_cpu_abstract.ppuwrite(ppufile:tcompilerppufile);
  2480. var
  2481. i : integer;
  2482. begin
  2483. inherited ppuwrite(ppufile);
  2484. ppufile.putdata(condition,sizeof(tasmcond));
  2485. ppufile.putbyte(ops);
  2486. for i:=0 to ops-1 do
  2487. ppuwriteoper(ppufile,oper[i]^);
  2488. ppufile.putword(word(opcode));
  2489. {$ifdef x86}
  2490. ppufile.putdata(segprefix,sizeof(Tregister));
  2491. {$endif x86}
  2492. ppufile.putboolean(is_jmp);
  2493. end;
  2494. procedure tai_cpu_abstract.buildderefimpl;
  2495. var
  2496. i : integer;
  2497. begin
  2498. for i:=0 to ops-1 do
  2499. ppubuildderefimploper(oper[i]^);
  2500. end;
  2501. procedure tai_cpu_abstract.derefimpl;
  2502. var
  2503. i : integer;
  2504. begin
  2505. for i:=0 to ops-1 do
  2506. ppuderefoper(oper[i]^);
  2507. end;
  2508. procedure tai_cpu_abstract.resetpass1;
  2509. begin
  2510. end;
  2511. procedure tai_cpu_abstract.resetpass2;
  2512. begin
  2513. end;
  2514. function tai_cpu_abstract.Pass1(objdata:TObjData):longint;
  2515. begin
  2516. result:=0;
  2517. end;
  2518. procedure tai_cpu_abstract.Pass2(objdata:TObjData);
  2519. begin
  2520. end;
  2521. procedure tai_cpu_abstract.ppuloadoper(ppufile:tcompilerppufile;var o:toper);
  2522. begin
  2523. o.typ:=toptype(ppufile.getbyte);
  2524. o.ot:=ppufile.getlongint;
  2525. case o.typ of
  2526. top_reg :
  2527. ppufile.getdata(o.reg,sizeof(Tregister));
  2528. top_ref :
  2529. begin
  2530. new(o.ref);
  2531. {$ifdef x86}
  2532. ppufile.getdata(o.ref^.segment,sizeof(Tregister));
  2533. {$endif x86}
  2534. ppufile.getdata(o.ref^.base,sizeof(Tregister));
  2535. ppufile.getdata(o.ref^.index,sizeof(Tregister));
  2536. ppufile.getdata(o.ref^.refaddr,sizeof(o.ref^.refaddr));
  2537. o.ref^.scalefactor:=ppufile.getbyte;
  2538. o.ref^.offset:=ppufile.getaint;
  2539. o.ref^.symbol:=ppufile.getasmsymbol;
  2540. o.ref^.relsymbol:=ppufile.getasmsymbol;
  2541. end;
  2542. top_const :
  2543. o.val:=ppufile.getaint;
  2544. top_local :
  2545. begin
  2546. new(o.localoper);
  2547. with o.localoper^ do
  2548. begin
  2549. ppufile.getderef(localsymderef);
  2550. localsymofs:=ppufile.getaint;
  2551. {$ifdef x86}
  2552. localsegment:=tregister(ppufile.getlongint);
  2553. {$endif x86}
  2554. localindexreg:=tregister(ppufile.getlongint);
  2555. localscale:=ppufile.getbyte;
  2556. localgetoffset:=(ppufile.getbyte<>0);
  2557. end;
  2558. end;
  2559. else
  2560. internalerror(2007010210);
  2561. end;
  2562. end;
  2563. procedure tai_cpu_abstract.ppuwriteoper(ppufile:tcompilerppufile;const o:toper);
  2564. begin
  2565. ppufile.putbyte(byte(o.typ));
  2566. ppufile.putlongint(o.ot);
  2567. case o.typ of
  2568. top_reg :
  2569. ppufile.putdata(o.reg,sizeof(Tregister));
  2570. top_ref :
  2571. begin
  2572. {$ifdef x86}
  2573. ppufile.putdata(o.ref^.segment,sizeof(Tregister));
  2574. {$endif x86}
  2575. ppufile.putdata(o.ref^.base,sizeof(Tregister));
  2576. ppufile.putdata(o.ref^.index,sizeof(Tregister));
  2577. ppufile.putdata(o.ref^.refaddr,sizeof(o.ref^.refaddr));
  2578. ppufile.putbyte(o.ref^.scalefactor);
  2579. ppufile.putaint(o.ref^.offset);
  2580. ppufile.putasmsymbol(o.ref^.symbol);
  2581. ppufile.putasmsymbol(o.ref^.relsymbol);
  2582. end;
  2583. top_const :
  2584. ppufile.putaint(o.val);
  2585. top_local :
  2586. begin
  2587. with o.localoper^ do
  2588. begin
  2589. ppufile.putderef(localsymderef);
  2590. ppufile.putaint(localsymofs);
  2591. {$ifdef x86}
  2592. ppufile.putlongint(longint(localsegment));
  2593. {$endif x86}
  2594. ppufile.putlongint(longint(localindexreg));
  2595. ppufile.putbyte(localscale);
  2596. ppufile.putbyte(byte(localgetoffset));
  2597. end;
  2598. end;
  2599. else
  2600. internalerror(2007010211);
  2601. end;
  2602. end;
  2603. {****************************************************************************
  2604. tai_align_abstract
  2605. ****************************************************************************}
  2606. constructor tai_align_abstract.Create(b: byte);
  2607. begin
  2608. inherited Create;
  2609. typ:=ait_align;
  2610. {$ifdef EXTDEBUG}
  2611. if upper(classname)='TAI_ALIGN_ABSTRACT' then
  2612. internalerror(200709191);
  2613. {$endif EXTDEBUG}
  2614. if b in [1,2,4,8,16,32,64] then
  2615. aligntype := b
  2616. else
  2617. aligntype := 1;
  2618. fillsize:=0;
  2619. fillop:=0;
  2620. use_op:=false;
  2621. end;
  2622. constructor tai_align_abstract.Create_op(b: byte; _op: byte);
  2623. begin
  2624. inherited Create;
  2625. typ:=ait_align;
  2626. if b in [1,2,4,8,16,32] then
  2627. aligntype := b
  2628. else
  2629. aligntype := 1;
  2630. fillsize:=0;
  2631. fillop:=_op;
  2632. use_op:=true;
  2633. end;
  2634. constructor tai_align_abstract.Create_zeros(b: byte);
  2635. begin
  2636. inherited Create;
  2637. typ:=ait_align;
  2638. if b in [1,2,4,8,16,32] then
  2639. aligntype := b
  2640. else
  2641. aligntype := 1;
  2642. use_op:=true;
  2643. fillsize:=0;
  2644. fillop:=0;
  2645. end;
  2646. function tai_align_abstract.calculatefillbuf(var buf : tfillbuffer;executable : boolean):pchar;
  2647. begin
  2648. if fillsize>sizeof(buf) then
  2649. internalerror(200404293);
  2650. fillchar(buf,high(buf),fillop);
  2651. calculatefillbuf:=pchar(@buf);
  2652. end;
  2653. constructor tai_align_abstract.ppuload(t:taitype;ppufile:tcompilerppufile);
  2654. begin
  2655. inherited ppuload(t,ppufile);
  2656. aligntype:=ppufile.getbyte;
  2657. fillsize:=0;
  2658. fillop:=ppufile.getbyte;
  2659. use_op:=ppufile.getboolean;
  2660. end;
  2661. procedure tai_align_abstract.ppuwrite(ppufile:tcompilerppufile);
  2662. begin
  2663. inherited ppuwrite(ppufile);
  2664. ppufile.putbyte(aligntype);
  2665. ppufile.putbyte(fillop);
  2666. ppufile.putboolean(use_op);
  2667. end;
  2668. {****************************************************************************
  2669. tai_seh_directive
  2670. ****************************************************************************}
  2671. const
  2672. datatypemap: array[TAsmSehDirective] of TSehDirectiveDatatype=(
  2673. sd_string, { proc }
  2674. sd_none, { endproc }
  2675. sd_none, { endprologue }
  2676. sd_string, { handler }
  2677. sd_none, { handlerdata }
  2678. sd_none,sd_none,sd_none, { eh, 32, no32 }
  2679. sd_regoffset, { setframe }
  2680. sd_offset, { stackalloc }
  2681. sd_reg, { pushreg }
  2682. sd_regoffset, { savereg }
  2683. sd_regoffset, { savexmm }
  2684. sd_none, { pushframe }
  2685. sd_reg, { pushnv }
  2686. sd_none { savenv }
  2687. );
  2688. constructor tai_seh_directive.create(_kind:TAsmSehDirective);
  2689. begin
  2690. inherited Create;
  2691. typ:=ait_seh_directive;
  2692. kind:=_kind;
  2693. data.typ:=datatypemap[_kind];
  2694. end;
  2695. constructor tai_seh_directive.create_name(_kind:TAsmSehDirective;const _name:string);
  2696. begin
  2697. create(_kind);
  2698. data.name:=stringdup(_name);
  2699. end;
  2700. constructor tai_seh_directive.create_reg(_kind:TAsmSehDirective;r:TRegister);
  2701. begin
  2702. create(_kind);
  2703. data.reg:=r;
  2704. end;
  2705. constructor tai_seh_directive.create_offset(_kind:TAsmSehDirective;ofs:dword);
  2706. begin
  2707. create(_kind);
  2708. data.offset:=ofs;
  2709. end;
  2710. constructor tai_seh_directive.create_reg_offset(_kind:TAsmSehDirective;
  2711. r:TRegister;ofs:dword);
  2712. begin
  2713. create(_kind);
  2714. data.offset:=ofs;
  2715. data.reg:=r;
  2716. end;
  2717. constructor tai_seh_directive.ppuload(t:taitype;ppufile:tcompilerppufile);
  2718. begin
  2719. inherited ppuload(t, ppufile);
  2720. kind:=TAsmSehDirective(ppufile.getbyte);
  2721. data.typ:=datatypemap[kind];
  2722. case data.typ of
  2723. sd_none: ;
  2724. sd_string:
  2725. begin
  2726. data.name:=ppufile.getpshortstring;
  2727. data.flags:=ppufile.getbyte;
  2728. end;
  2729. sd_reg,sd_offset,sd_regoffset:
  2730. begin
  2731. ppufile.getdata(data.reg,sizeof(TRegister));
  2732. data.offset:=ppufile.getdword;
  2733. end;
  2734. else
  2735. InternalError(2011091201);
  2736. end;
  2737. end;
  2738. destructor tai_seh_directive.destroy;
  2739. begin
  2740. if data.typ=sd_string then
  2741. stringdispose(data.name);
  2742. inherited destroy;
  2743. end;
  2744. procedure tai_seh_directive.ppuwrite(ppufile:tcompilerppufile);
  2745. begin
  2746. inherited ppuwrite(ppufile);
  2747. ppufile.putbyte(ord(kind));
  2748. case data.typ of
  2749. sd_none: ;
  2750. sd_string:
  2751. begin
  2752. ppufile.putstring(data.name^);
  2753. ppufile.putbyte(data.flags);
  2754. end;
  2755. sd_reg,sd_offset,sd_regoffset:
  2756. begin
  2757. ppufile.putdata(data.reg,sizeof(TRegister));
  2758. ppufile.putdword(data.offset);
  2759. end;
  2760. else
  2761. InternalError(2011091202);
  2762. end;
  2763. end;
  2764. procedure tai_seh_directive.generate_code(objdata:TObjData);
  2765. begin
  2766. end;
  2767. {$ifdef JVM}
  2768. {****************************************************************************
  2769. tai_jvar
  2770. ****************************************************************************}
  2771. constructor tai_jvar.Create(_stackslot: longint; const _desc: shortstring; _startlab, _stoplab: TAsmSymbol);
  2772. begin
  2773. Inherited create;
  2774. typ:=ait_jvar;
  2775. stackslot:=_stackslot;
  2776. desc:=stringdup(_desc);
  2777. startlab:=_startlab;
  2778. stoplab:=_stoplab;
  2779. end;
  2780. constructor tai_jvar.ppuload(t: taitype; ppufile: tcompilerppufile);
  2781. begin
  2782. inherited ppuload(t, ppufile);
  2783. stackslot:=ppufile.getlongint;
  2784. desc:=ppufile.getpshortstring;
  2785. startlab:=ppufile.getasmsymbol;
  2786. stoplab:=ppufile.getasmsymbol;
  2787. end;
  2788. procedure tai_jvar.ppuwrite(ppufile: tcompilerppufile);
  2789. begin
  2790. inherited ppuwrite(ppufile);
  2791. ppufile.putlongint(stackslot);
  2792. ppufile.putstring(desc^);
  2793. ppufile.putasmsymbol(startlab);
  2794. ppufile.putasmsymbol(stoplab);
  2795. end;
  2796. destructor tai_jvar.destroy;
  2797. begin
  2798. stringdispose(desc);
  2799. inherited destroy;
  2800. end;
  2801. {****************************************************************************
  2802. tai_jcatch
  2803. ****************************************************************************}
  2804. constructor tai_jcatch.Create(const _name: shortstring; _startlab, _stoplab, _handlerlab: TAsmSymbol);
  2805. begin
  2806. Inherited create;
  2807. typ:=ait_jcatch;
  2808. name:=stringdup(_name);
  2809. startlab:=_startlab;
  2810. startlab.increfs;
  2811. stoplab:=_stoplab;
  2812. stoplab.increfs;
  2813. handlerlab:=_handlerlab;
  2814. handlerlab.increfs;
  2815. end;
  2816. destructor tai_jcatch.destroy;
  2817. begin
  2818. stringdispose(name);
  2819. inherited destroy;
  2820. end;
  2821. constructor tai_jcatch.ppuload(t: taitype; ppufile: tcompilerppufile);
  2822. begin
  2823. inherited ppuload(t, ppufile);
  2824. name:=ppufile.getpshortstring;
  2825. startlab:=ppufile.getasmsymbol;
  2826. startlab.increfs;
  2827. stoplab:=ppufile.getasmsymbol;
  2828. stoplab.increfs;
  2829. handlerlab:=ppufile.getasmsymbol;
  2830. handlerlab.increfs;
  2831. end;
  2832. procedure tai_jcatch.ppuwrite(ppufile: tcompilerppufile);
  2833. begin
  2834. inherited ppuwrite(ppufile);
  2835. ppufile.putstring(name^);
  2836. ppufile.putasmsymbol(startlab);
  2837. ppufile.putasmsymbol(stoplab);
  2838. ppufile.putasmsymbol(handlerlab);
  2839. end;
  2840. {$endif JVM}
  2841. begin
  2842. {$push}{$warnings off}
  2843. { taitype should fit into a 4 byte set for speed reasons }
  2844. if ord(high(taitype))>31 then
  2845. internalerror(201108181);
  2846. {$pop}
  2847. end.