aasmtai.pas 98 KB

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