cgobj.pas 105 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Member of the Free Pascal development team
  5. This unit implements the basic code generator object
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. {# @abstract(Abstract code generator unit)
  20. Abstreact code generator unit. This contains the base class
  21. to implement for all new supported processors.
  22. WARNING: None of the routines implemented in these modules,
  23. or their descendants, should use the temp. allocator, as
  24. these routines may be called inside genentrycode, and the
  25. stack frame is already setup!
  26. }
  27. unit cgobj;
  28. {$i fpcdefs.inc}
  29. interface
  30. uses
  31. {$ifdef delphi}
  32. dmisc,
  33. {$endif}
  34. cclasses,
  35. cpubase,cpuinfo,cgbase,
  36. aasmbase,aasmtai,aasmcpu,
  37. symconst,symbase,symtype,symdef,symtable,rgobj
  38. ;
  39. type
  40. talignment = (AM_NATURAL,AM_NONE,AM_2BYTE,AM_4BYTE,AM_8BYTE);
  41. {# @abstract(Abstract code generator)
  42. This class implements an abstract instruction generator. Some of
  43. the methods of this class are generic, while others must
  44. be overriden for all new processors which will be supported
  45. by Free Pascal. For 32-bit processors, the base class
  46. sould be @link(tcg64f32) and not @var(tcg).
  47. }
  48. tcg = class
  49. public
  50. alignment : talignment;
  51. rg : array[tregistertype] of trgobj;
  52. t_times:cardinal;
  53. {$ifdef flowgraph}
  54. aktflownode:word;
  55. {$endif}
  56. {************************************************}
  57. { basic routines }
  58. constructor create;
  59. {# Initialize the register allocators needed for the codegenerator.}
  60. procedure init_register_allocators;virtual;
  61. {# Clean up the register allocators needed for the codegenerator.}
  62. procedure done_register_allocators;virtual;
  63. {$ifdef flowgraph}
  64. procedure init_flowgraph;
  65. procedure done_flowgraph;
  66. {$endif}
  67. {# Gets a register suitable to do integer operations on.}
  68. function getintregister(list:Taasmoutput;size:Tcgsize):Tregister;virtual;
  69. {# Gets a register suitable to do integer operations on.}
  70. function getaddressregister(list:Taasmoutput):Tregister;virtual;
  71. function getfpuregister(list:Taasmoutput;size:Tcgsize):Tregister;virtual;
  72. function getmmregister(list:Taasmoutput;size:Tcgsize):Tregister;virtual;
  73. function getflagregister(list:Taasmoutput;size:Tcgsize):Tregister;virtual;abstract;
  74. {Does the generic cg need SIMD registers, like getmmxregister? Or should
  75. the cpu specific child cg object have such a method?}
  76. procedure ungetregister(list:Taasmoutput;r:Tregister);virtual;
  77. procedure ungetreference(list:Taasmoutput;const r:Treference);virtual;
  78. procedure add_reg_instruction(instr:Tai;r:tregister);virtual;
  79. procedure add_move_instruction(instr:Taicpu);virtual;
  80. function uses_registers(rt:Tregistertype):boolean;virtual;
  81. {# Get a specific register.}
  82. procedure getexplicitregister(list:Taasmoutput;r:Tregister);virtual;
  83. {# Get multiple registers specified.}
  84. procedure allocexplicitregisters(list:Taasmoutput;rt:Tregistertype;r:Tcpuregisterset);virtual;
  85. {# Free multiple registers specified.}
  86. procedure deallocexplicitregisters(list:Taasmoutput;rt:Tregistertype;r:Tcpuregisterset);virtual;
  87. procedure do_register_allocation(list:Taasmoutput;headertai:tai);virtual;
  88. function makeregsize(list:Taasmoutput;reg:Tregister;size:Tcgsize):Tregister;
  89. {# Returns the tcgsize corresponding with the size of reg.}
  90. class function reg_cgsize(const reg: tregister) : tcgsize; virtual;
  91. {# Emit a label to the instruction stream. }
  92. procedure a_label(list : taasmoutput;l : tasmlabel);virtual;
  93. {# Allocates register r by inserting a pai_realloc record }
  94. procedure a_reg_alloc(list : taasmoutput;r : tregister);
  95. {# Deallocates register r by inserting a pa_regdealloc record}
  96. procedure a_reg_dealloc(list : taasmoutput;r : tregister);
  97. {# Pass a parameter, which is located in a register, to a routine.
  98. This routine should push/send the parameter to the routine, as
  99. required by the specific processor ABI and routine modifiers.
  100. This must be overriden for each CPU target.
  101. @param(size size of the operand in the register)
  102. @param(r register source of the operand)
  103. @param(locpara where the parameter will be stored)
  104. }
  105. procedure a_param_reg(list : taasmoutput;size : tcgsize;r : tregister;const locpara : tparalocation);virtual;
  106. {# Pass a parameter, which is a constant, to a routine.
  107. A generic version is provided. This routine should
  108. be overriden for optimization purposes if the cpu
  109. permits directly sending this type of parameter.
  110. @param(size size of the operand in constant)
  111. @param(a value of constant to send)
  112. @param(locpara where the parameter will be stored)
  113. }
  114. procedure a_param_const(list : taasmoutput;size : tcgsize;a : aword;const locpara : tparalocation);virtual;
  115. {# Pass the value of a parameter, which is located in memory, to a routine.
  116. A generic version is provided. This routine should
  117. be overriden for optimization purposes if the cpu
  118. permits directly sending this type of parameter.
  119. @param(size size of the operand in constant)
  120. @param(r Memory reference of value to send)
  121. @param(locpara where the parameter will be stored)
  122. }
  123. procedure a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;const locpara : tparalocation);virtual;
  124. {# Pass the value of a parameter, which can be located either in a register or memory location,
  125. to a routine.
  126. A generic version is provided.
  127. @param(l location of the operand to send)
  128. @param(nr parameter number (starting from one) of routine (from left to right))
  129. @param(locpara where the parameter will be stored)
  130. }
  131. procedure a_param_loc(list : taasmoutput;const l : tlocation;const locpara : tparalocation);
  132. {# Pass the address of a reference to a routine. This routine
  133. will calculate the address of the reference, and pass this
  134. calculated address as a parameter.
  135. A generic version is provided. This routine should
  136. be overriden for optimization purposes if the cpu
  137. permits directly sending this type of parameter.
  138. @param(r reference to get address from)
  139. @param(nr parameter number (starting from one) of routine (from left to right))
  140. }
  141. procedure a_paramaddr_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);virtual;
  142. { Copies a whole memory block to the stack, the locpara must be a memory location }
  143. procedure a_param_copy_ref(list : taasmoutput;size : qword;const r : treference;const locpara : tparalocation);
  144. { Remarks:
  145. * If a method specifies a size you have only to take care
  146. of that number of bits, i.e. load_const_reg with OP_8 must
  147. only load the lower 8 bit of the specified register
  148. the rest of the register can be undefined
  149. if necessary the compiler will call a method
  150. to zero or sign extend the register
  151. * The a_load_XX_XX with OP_64 needn't to be
  152. implemented for 32 bit
  153. processors, the code generator takes care of that
  154. * the addr size is for work with the natural pointer
  155. size
  156. * the procedures without fpu/mm are only for integer usage
  157. * normally the first location is the source and the
  158. second the destination
  159. }
  160. { Copy a parameter to a (temporary) reference }
  161. procedure a_loadany_param_ref(list : taasmoutput;const locpara : tparalocation;const ref:treference;shuffle : pmmshuffle);virtual;
  162. { Copy a parameter to a register }
  163. procedure a_loadany_param_reg(list : taasmoutput;const locpara : tparalocation;const reg:tregister;shuffle : pmmshuffle);virtual;
  164. {# Emits instruction to call the method specified by symbol name.
  165. This routine must be overriden for each new target cpu.
  166. There is no a_call_ref because loading the reference will use
  167. a temp register on most cpu's resulting in conflicts with the
  168. registers used for the parameters (PFV)
  169. }
  170. procedure a_call_name(list : taasmoutput;const s : string);virtual; abstract;
  171. procedure a_call_reg(list : taasmoutput;reg : tregister);virtual;abstract;
  172. { move instructions }
  173. procedure a_load_const_reg(list : taasmoutput;size : tcgsize;a : aword;register : tregister);virtual; abstract;
  174. procedure a_load_const_ref(list : taasmoutput;size : tcgsize;a : aword;const ref : treference);virtual;
  175. procedure a_load_const_loc(list : taasmoutput;a : aword;const loc : tlocation);
  176. procedure a_load_reg_ref(list : taasmoutput;fromsize,tosize : tcgsize;register : tregister;const ref : treference);virtual; abstract;
  177. procedure a_load_reg_reg(list : taasmoutput;fromsize,tosize : tcgsize;reg1,reg2 : tregister);virtual; abstract;
  178. procedure a_load_reg_loc(list : taasmoutput;fromsize : tcgsize;reg : tregister;const loc: tlocation);
  179. procedure a_load_ref_reg(list : taasmoutput;fromsize,tosize : tcgsize;const ref : treference;register : tregister);virtual; abstract;
  180. procedure a_load_ref_ref(list : taasmoutput;fromsize,tosize : tcgsize;const sref : treference;const dref : treference);virtual;
  181. procedure a_load_loc_reg(list : taasmoutput;tosize: tcgsize; const loc: tlocation; reg : tregister);
  182. procedure a_load_loc_ref(list : taasmoutput;tosize: tcgsize; const loc: tlocation; const ref : treference);
  183. procedure a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);virtual; abstract;
  184. { fpu move instructions }
  185. procedure a_loadfpu_reg_reg(list: taasmoutput; size:tcgsize; reg1, reg2: tregister); virtual; abstract;
  186. procedure a_loadfpu_ref_reg(list: taasmoutput; size: tcgsize; const ref: treference; reg: tregister); virtual; abstract;
  187. procedure a_loadfpu_reg_ref(list: taasmoutput; size: tcgsize; reg: tregister; const ref: treference); virtual; abstract;
  188. procedure a_loadfpu_loc_reg(list: taasmoutput; const loc: tlocation; const reg: tregister);
  189. procedure a_loadfpu_reg_loc(list: taasmoutput; size: tcgsize; const reg: tregister; const loc: tlocation);
  190. procedure a_paramfpu_reg(list : taasmoutput;size : tcgsize;const r : tregister;const locpara : tparalocation);virtual;
  191. procedure a_paramfpu_ref(list : taasmoutput;size : tcgsize;const ref : treference;const locpara : tparalocation);virtual;
  192. { vector register move instructions }
  193. procedure a_loadmm_reg_reg(list: taasmoutput; fromsize, tosize : tcgsize;reg1, reg2: tregister;shuffle : pmmshuffle); virtual; abstract;
  194. procedure a_loadmm_ref_reg(list: taasmoutput; fromsize, tosize : tcgsize;const ref: treference; reg: tregister;shuffle : pmmshuffle); virtual; abstract;
  195. procedure a_loadmm_reg_ref(list: taasmoutput; fromsize, tosize : tcgsize;reg: tregister; const ref: treference;shuffle : pmmshuffle); virtual; abstract;
  196. procedure a_loadmm_loc_reg(list: taasmoutput; size: tcgsize; const loc: tlocation; const reg: tregister;shuffle : pmmshuffle);
  197. procedure a_loadmm_reg_loc(list: taasmoutput; size: tcgsize; const reg: tregister; const loc: tlocation;shuffle : pmmshuffle);
  198. procedure a_parammm_reg(list: taasmoutput; size: tcgsize; reg: tregister;const locpara : tparalocation;shuffle : pmmshuffle); virtual;
  199. procedure a_parammm_ref(list: taasmoutput; size: tcgsize; const ref: treference;const locpara : tparalocation;shuffle : pmmshuffle); virtual;
  200. procedure a_parammm_loc(list: taasmoutput; const loc: tlocation; const locpara : tparalocation;shuffle : pmmshuffle); virtual;
  201. procedure a_opmm_reg_reg(list: taasmoutput; Op: TOpCG; size : tcgsize;src,dst: tregister;shuffle : pmmshuffle); virtual;abstract;
  202. procedure a_opmm_ref_reg(list: taasmoutput; Op: TOpCG; size : tcgsize;const ref: treference; reg: tregister;shuffle : pmmshuffle); virtual;
  203. procedure a_opmm_loc_reg(list: taasmoutput; Op: TOpCG; size : tcgsize;const loc: tlocation; reg: tregister;shuffle : pmmshuffle); virtual;
  204. procedure a_opmm_reg_ref(list: taasmoutput; Op: TOpCG; size : tcgsize;reg: tregister;const ref: treference; shuffle : pmmshuffle); virtual;
  205. { basic arithmetic operations }
  206. { note: for operators which require only one argument (not, neg), use }
  207. { the op_reg_reg, op_reg_ref or op_reg_loc methods and keep in mind }
  208. { that in this case the *second* operand is used as both source and }
  209. { destination (JM) }
  210. procedure a_op_const_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; a: AWord; reg: TRegister); virtual; abstract;
  211. procedure a_op_const_ref(list : taasmoutput; Op: TOpCG; size: TCGSize; a: AWord; const ref: TReference); virtual;
  212. procedure a_op_const_loc(list : taasmoutput; Op: TOpCG; a: AWord; const loc: tlocation);
  213. procedure a_op_reg_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; reg1, reg2: TRegister); virtual; abstract;
  214. procedure a_op_reg_ref(list : taasmoutput; Op: TOpCG; size: TCGSize; reg: TRegister; const ref: TReference); virtual;
  215. procedure a_op_ref_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; const ref: TReference; reg: TRegister); virtual;
  216. procedure a_op_reg_loc(list : taasmoutput; Op: TOpCG; reg: tregister; const loc: tlocation);
  217. procedure a_op_ref_loc(list : taasmoutput; Op: TOpCG; const ref: TReference; const loc: tlocation);
  218. { trinary operations for processors that support them, 'emulated' }
  219. { on others. None with "ref" arguments since I don't think there }
  220. { are any processors that support it (JM) }
  221. procedure a_op_const_reg_reg(list: taasmoutput; op: TOpCg;
  222. size: tcgsize; a: aword; src, dst: tregister); virtual;
  223. procedure a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
  224. size: tcgsize; src1, src2, dst: tregister); virtual;
  225. { comparison operations }
  226. procedure a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;reg : tregister;
  227. l : tasmlabel);virtual; abstract;
  228. procedure a_cmp_const_ref_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;const ref : treference;
  229. l : tasmlabel); virtual;
  230. procedure a_cmp_const_loc_label(list: taasmoutput; size: tcgsize;cmp_op: topcmp; a: aword; const loc: tlocation;
  231. l : tasmlabel);
  232. procedure a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel); virtual; abstract;
  233. procedure a_cmp_ref_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const ref: treference; reg : tregister; l : tasmlabel); virtual;
  234. procedure a_cmp_loc_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const loc: tlocation; reg : tregister; l : tasmlabel);
  235. procedure a_cmp_ref_loc_label(list: taasmoutput; size: tcgsize;cmp_op: topcmp; const ref: treference; const loc: tlocation;
  236. l : tasmlabel);
  237. procedure a_jmp_name(list : taasmoutput;const s : string); virtual; abstract;
  238. procedure a_jmp_always(list : taasmoutput;l: tasmlabel); virtual; abstract;
  239. procedure a_jmp_flags(list : taasmoutput;const f : TResFlags;l: tasmlabel); virtual; abstract;
  240. {# Depending on the value to check in the flags, either sets the register reg to one (if the flag is set)
  241. or zero (if the flag is cleared). The size parameter indicates the destination size register.
  242. }
  243. procedure g_flags2reg(list: taasmoutput; size: TCgSize; const f: tresflags; reg: TRegister); virtual; abstract;
  244. procedure g_flags2ref(list: taasmoutput; size: TCgSize; const f: tresflags; const ref:TReference); virtual;
  245. {
  246. This routine tries to optimize the const_reg opcode, and should be
  247. called at the start of a_op_const_reg. It returns the actual opcode
  248. to emit, and the constant value to emit. If this routine returns
  249. TRUE, @var(no) instruction should be emitted (.eg : imul reg by 1 )
  250. @param(op The opcode to emit, returns the opcode which must be emitted)
  251. @param(a The constant which should be emitted, returns the constant which must
  252. be emitted)
  253. @param(reg The register to emit the opcode with, returns the register with
  254. which the opcode will be emitted)
  255. }
  256. function optimize_op_const_reg(list: taasmoutput; var op: topcg; var a : aword; var reg: tregister): boolean;virtual;
  257. {#
  258. This routine is used in exception management nodes. It should
  259. save the exception reason currently in the FUNCTION_RETURN_REG. The
  260. save should be done either to a temp (pointed to by href).
  261. or on the stack (pushing the value on the stack).
  262. The size of the value to save is OS_S32. The default version
  263. saves the exception reason to a temp. memory area.
  264. }
  265. procedure g_exception_reason_save(list : taasmoutput; const href : treference);virtual;
  266. {#
  267. This routine is used in exception management nodes. It should
  268. save the exception reason constant. The
  269. save should be done either to a temp (pointed to by href).
  270. or on the stack (pushing the value on the stack).
  271. The size of the value to save is OS_S32. The default version
  272. saves the exception reason to a temp. memory area.
  273. }
  274. procedure g_exception_reason_save_const(list : taasmoutput; const href : treference; a: aword);virtual;
  275. {#
  276. This routine is used in exception management nodes. It should
  277. load the exception reason to the FUNCTION_RETURN_REG. The saved value
  278. should either be in the temp. area (pointed to by href , href should
  279. *NOT* be freed) or on the stack (the value should be popped).
  280. The size of the value to save is OS_S32. The default version
  281. saves the exception reason to a temp. memory area.
  282. }
  283. procedure g_exception_reason_load(list : taasmoutput; const href : treference);virtual;
  284. procedure g_maybe_testself(list : taasmoutput;reg:tregister);
  285. procedure g_maybe_testvmt(list : taasmoutput;reg:tregister;objdef:tobjectdef);
  286. {# This should emit the opcode to copy len bytes from the source
  287. to destination, if loadref is true, it assumes that it first must load
  288. the source address from the memory location where
  289. source points to.
  290. It must be overriden for each new target processor.
  291. @param(source Source reference of copy)
  292. @param(dest Destination reference of copy)
  293. @param(delsource Indicates if the source reference's resources should be freed)
  294. @param(loadref Is the source reference a pointer to the actual source (TRUE), is it the actual source address (FALSE))
  295. }
  296. procedure g_concatcopy(list : taasmoutput;const source,dest : treference;len : aword;delsource,loadref : boolean);virtual; abstract;
  297. {# This should emit the opcode to a shortrstring from the source
  298. to destination, if loadref is true, it assumes that it first must load
  299. the source address from the memory location where
  300. source points to.
  301. @param(source Source reference of copy)
  302. @param(dest Destination reference of copy)
  303. @param(delsource Indicates if the source reference's resources should be freed)
  304. @param(loadref Is the source reference a pointer to the actual source (TRUE), is it the actual source address (FALSE))
  305. }
  306. procedure g_copyshortstring(list : taasmoutput;const source,dest : treference;len:byte;delsource,loadref : boolean);
  307. procedure g_incrrefcount(list : taasmoutput;t: tdef; const ref: treference;loadref : boolean);
  308. procedure g_decrrefcount(list : taasmoutput;t: tdef; const ref: treference;loadref : boolean);
  309. procedure g_initialize(list : taasmoutput;t : tdef;const ref : treference;loadref : boolean);
  310. procedure g_finalize(list : taasmoutput;t : tdef;const ref : treference;loadref : boolean);
  311. {# Generates range checking code. It is to note
  312. that this routine does not need to be overriden,
  313. as it takes care of everything.
  314. @param(p Node which contains the value to check)
  315. @param(todef Type definition of node to range check)
  316. }
  317. procedure g_rangecheck(list: taasmoutput; const l:tlocation; fromdef,todef: tdef); virtual;
  318. {# Generates overflow checking code for a node }
  319. procedure g_overflowcheck(list: taasmoutput; const l:tlocation; def:tdef); virtual; abstract;
  320. procedure g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:aword);virtual;
  321. procedure g_releasevaluepara_openarray(list : taasmoutput;const ref:treference);virtual;
  322. {# Emits instructions which should be emitted when entering
  323. a routine declared as @var(interrupt). The default
  324. behavior does nothing, should be overriden as required.
  325. }
  326. procedure g_interrupt_stackframe_entry(list : taasmoutput);virtual;
  327. {# Emits instructions which should be emitted when exiting
  328. a routine declared as @var(interrupt). The default
  329. behavior does nothing, should be overriden as required.
  330. }
  331. procedure g_interrupt_stackframe_exit(list : taasmoutput;accused,acchiused:boolean);virtual;
  332. {# Emits instructions when compilation is done in profile
  333. mode (this is set as a command line option). The default
  334. behavior does nothing, should be overriden as required.
  335. }
  336. procedure g_profilecode(list : taasmoutput);virtual;
  337. {# Emits instruction for allocating @var(size) bytes at the stackpointer
  338. @param(size Number of bytes to allocate)
  339. }
  340. procedure g_stackpointer_alloc(list : taasmoutput;size : longint);virtual; abstract;
  341. {# Emits instruction for allocating the locals in entry
  342. code of a routine. This is one of the first
  343. routine called in @var(genentrycode).
  344. @param(localsize Number of bytes to allocate as locals)
  345. }
  346. procedure g_stackframe_entry(list : taasmoutput;localsize : longint);virtual; abstract;
  347. {# Emits instructiona for restoring the frame pointer
  348. at routine exit. For some processors, this routine
  349. may do nothing at all.
  350. }
  351. procedure g_restore_frame_pointer(list : taasmoutput);virtual; abstract;
  352. {# Emits instructions for returning from a subroutine.
  353. Should also restore the stack.
  354. @param(parasize Number of bytes of parameters to deallocate from stack)
  355. }
  356. procedure g_return_from_proc(list : taasmoutput;parasize : aword);virtual; abstract;
  357. {# This routine is called when generating the code for the entry point
  358. of a routine. It should save all registers which are not used in this
  359. routine, and which should be declared as saved in the std_saved_registers
  360. set.
  361. This routine is mainly used when linking to code which is generated
  362. by ABI-compliant compilers (like GCC), to make sure that the reserved
  363. registers of that ABI are not clobbered.
  364. @param(usedinproc Registers which are used in the code of this routine)
  365. }
  366. procedure g_save_standard_registers(list:Taasmoutput);virtual;abstract;
  367. {# This routine is called when generating the code for the exit point
  368. of a routine. It should restore all registers which were previously
  369. saved in @var(g_save_standard_registers).
  370. @param(usedinproc Registers which are used in the code of this routine)
  371. }
  372. procedure g_restore_standard_registers(list:Taasmoutput);virtual;abstract;
  373. procedure g_save_all_registers(list : taasmoutput);virtual;abstract;
  374. procedure g_restore_all_registers(list : taasmoutput;const funcretparaloc:tparalocation);virtual;abstract;
  375. end;
  376. {# @abstract(Abstract code generator for 64 Bit operations)
  377. This class implements an abstract code generator class
  378. for 64 Bit operations.
  379. }
  380. tcg64 = class
  381. { Allocates 64 Bit register r by inserting a pai_realloc record }
  382. procedure a_reg_alloc(list : taasmoutput;r : tregister64);virtual;abstract;
  383. { Deallocates 64 Bit register r by inserting a pa_regdealloc record}
  384. procedure a_reg_dealloc(list : taasmoutput;r : tregister64);virtual;abstract;
  385. procedure a_load64_const_ref(list : taasmoutput;value : qword;const ref : treference);virtual;abstract;
  386. procedure a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);virtual;abstract;
  387. procedure a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64);virtual;abstract;
  388. procedure a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64);virtual;abstract;
  389. procedure a_load64_const_reg(list : taasmoutput;value : qword;reg : tregister64);virtual;abstract;
  390. procedure a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64);virtual;abstract;
  391. procedure a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);virtual;abstract;
  392. procedure a_load64_const_loc(list : taasmoutput;value : qword;const l : tlocation);virtual;abstract;
  393. procedure a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);virtual;abstract;
  394. procedure a_load64high_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);virtual;abstract;
  395. procedure a_load64low_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);virtual;abstract;
  396. procedure a_load64high_ref_reg(list : taasmoutput;const ref : treference;reg : tregister);virtual;abstract;
  397. procedure a_load64low_ref_reg(list : taasmoutput;const ref : treference;reg : tregister);virtual;abstract;
  398. procedure a_load64high_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister);virtual;abstract;
  399. procedure a_load64low_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister);virtual;abstract;
  400. procedure a_op64_ref_reg(list : taasmoutput;op:TOpCG;const ref : treference;reg : tregister64);virtual;abstract;
  401. procedure a_op64_reg_reg(list : taasmoutput;op:TOpCG;regsrc,regdst : tregister64);virtual;abstract;
  402. procedure a_op64_reg_ref(list : taasmoutput;op:TOpCG;regsrc : tregister64;const ref : treference);virtual;abstract;
  403. procedure a_op64_const_reg(list : taasmoutput;op:TOpCG;value : qword;regdst : tregister64);virtual;abstract;
  404. procedure a_op64_const_ref(list : taasmoutput;op:TOpCG;value : qword;const ref : treference);virtual;abstract;
  405. procedure a_op64_const_loc(list : taasmoutput;op:TOpCG;value : qword;const l: tlocation);virtual;abstract;
  406. procedure a_op64_reg_loc(list : taasmoutput;op:TOpCG;reg : tregister64;const l : tlocation);virtual;abstract;
  407. procedure a_op64_loc_reg(list : taasmoutput;op:TOpCG;const l : tlocation;reg64 : tregister64);virtual;abstract;
  408. procedure a_op64_const_reg_reg(list: taasmoutput;op:TOpCG;value : qword;regsrc,regdst : tregister64);virtual;
  409. procedure a_op64_reg_reg_reg(list: taasmoutput;op:TOpCG;regsrc1,regsrc2,regdst : tregister64);virtual;
  410. procedure a_param64_reg(list : taasmoutput;reg64 : tregister64;const loc : tparalocation);virtual;abstract;
  411. procedure a_param64_const(list : taasmoutput;value : qword;const loc : tparalocation);virtual;abstract;
  412. procedure a_param64_ref(list : taasmoutput;const r : treference;const loc : tparalocation);virtual;abstract;
  413. procedure a_param64_loc(list : taasmoutput;const l : tlocation;const loc : tparalocation);virtual;abstract;
  414. {
  415. This routine tries to optimize the const_reg opcode, and should be
  416. called at the start of a_op64_const_reg. It returns the actual opcode
  417. to emit, and the constant value to emit. If this routine returns
  418. TRUE, @var(no) instruction should be emitted (.eg : imul reg by 1 )
  419. @param(op The opcode to emit, returns the opcode which must be emitted)
  420. @param(a The constant which should be emitted, returns the constant which must
  421. be emitted)
  422. @param(reg The register to emit the opcode with, returns the register with
  423. which the opcode will be emitted)
  424. }
  425. function optimize64_op_const_reg(list: taasmoutput; var op: topcg; var a : qword; var reg: tregister64): boolean;virtual;abstract;
  426. { override to catch 64bit rangechecks }
  427. procedure g_rangecheck64(list: taasmoutput; const l:tlocation; fromdef,todef: tdef);virtual;abstract;
  428. end;
  429. procedure reference_release(list: taasmoutput; const ref : treference);
  430. { tlocation handling }
  431. procedure location_reset(var l : tlocation;lt:TCGLoc;lsize:TCGSize);
  432. procedure location_release(list: taasmoutput; const l : tlocation);
  433. procedure location_freetemp(list: taasmoutput; const l : tlocation);
  434. procedure location_copy(var destloc:tlocation; const sourceloc : tlocation);
  435. procedure location_swap(var destloc,sourceloc : tlocation);
  436. var
  437. {# Main code generator class }
  438. cg : tcg;
  439. {# Code generator class for all operations working with 64-Bit operands }
  440. cg64 : tcg64;
  441. implementation
  442. uses
  443. globals,globtype,options,systems,
  444. verbose,defutil,paramgr,
  445. tgobj,cutils,
  446. cgutils;
  447. const
  448. { Please leave this here, this module should NOT use
  449. exprasmlist, the lists are always passed as arguments.
  450. Declaring it as string here results in an error when compiling (PFV) }
  451. exprasmlist = 'error';
  452. {*****************************************************************************
  453. basic functionallity
  454. ******************************************************************************}
  455. constructor tcg.create;
  456. begin
  457. end;
  458. {*****************************************************************************
  459. register allocation
  460. ******************************************************************************}
  461. procedure tcg.init_register_allocators;
  462. begin
  463. fillchar(rg,sizeof(rg),0);
  464. add_reg_instruction_hook:={$ifdef FPCPROCVAR}@{$endif}add_reg_instruction;
  465. end;
  466. procedure tcg.done_register_allocators;
  467. begin
  468. { Safety }
  469. fillchar(rg,sizeof(rg),0);
  470. add_reg_instruction_hook:=nil;
  471. end;
  472. {$ifdef flowgraph}
  473. procedure Tcg.init_flowgraph;
  474. begin
  475. aktflownode:=0;
  476. end;
  477. procedure Tcg.done_flowgraph;
  478. begin
  479. end;
  480. {$endif}
  481. function tcg.getintregister(list:Taasmoutput;size:Tcgsize):Tregister;
  482. begin
  483. if not assigned(rg[R_INTREGISTER]) then
  484. internalerror(200312122);
  485. result:=rg[R_INTREGISTER].getregister(list,cgsize2subreg(size));
  486. end;
  487. function tcg.getfpuregister(list:Taasmoutput;size:Tcgsize):Tregister;
  488. begin
  489. if not assigned(rg[R_FPUREGISTER]) then
  490. internalerror(200312123);
  491. result:=rg[R_FPUREGISTER].getregister(list,cgsize2subreg(size));
  492. end;
  493. function tcg.getmmregister(list:Taasmoutput;size:Tcgsize):Tregister;
  494. begin
  495. if not assigned(rg[R_MMREGISTER]) then
  496. internalerror(200312124);
  497. result:=rg[R_MMREGISTER].getregister(list,cgsize2subreg(size));
  498. end;
  499. function tcg.getaddressregister(list:Taasmoutput):Tregister;
  500. begin
  501. if assigned(rg[R_ADDRESSREGISTER]) then
  502. result:=rg[R_ADDRESSREGISTER].getregister(list,R_SUBWHOLE)
  503. else
  504. begin
  505. if not assigned(rg[R_INTREGISTER]) then
  506. internalerror(200312121);
  507. result:=rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
  508. end;
  509. end;
  510. function Tcg.makeregsize(list:Taasmoutput;reg:Tregister;size:Tcgsize):Tregister;
  511. var
  512. subreg:Tsubregister;
  513. begin
  514. subreg:=cgsize2subreg(size);
  515. result:=reg;
  516. setsubreg(result,subreg);
  517. { notify RA }
  518. if result<>reg then
  519. list.concat(tai_regalloc.resize(result));
  520. end;
  521. procedure tcg.getexplicitregister(list:Taasmoutput;r:Tregister);
  522. begin
  523. if not assigned(rg[getregtype(r)]) then
  524. internalerror(200312125);
  525. rg[getregtype(r)].getexplicitregister(list,r);
  526. end;
  527. procedure tcg.ungetregister(list:Taasmoutput;r:Tregister);
  528. begin
  529. if not assigned(rg[getregtype(r)]) then
  530. internalerror(200312126);
  531. rg[getregtype(r)].ungetregister(list,r);
  532. end;
  533. procedure tcg.ungetreference(list:Taasmoutput;const r:Treference);
  534. begin
  535. if r.base<>NR_NO then
  536. ungetregister(list,r.base);
  537. if r.index<>NR_NO then
  538. ungetregister(list,r.index);
  539. end;
  540. procedure tcg.allocexplicitregisters(list:Taasmoutput;rt:Tregistertype;r:Tcpuregisterset);
  541. begin
  542. if assigned(rg[rt]) then
  543. rg[rt].allocexplicitregisters(list,r)
  544. else
  545. internalerror(200310092);
  546. end;
  547. procedure tcg.deallocexplicitregisters(list:Taasmoutput;rt:Tregistertype;r:Tcpuregisterset);
  548. begin
  549. if assigned(rg[rt]) then
  550. rg[rt].deallocexplicitregisters(list,r)
  551. else
  552. internalerror(200310093);
  553. end;
  554. function tcg.uses_registers(rt:Tregistertype):boolean;
  555. begin
  556. if assigned(rg[rt]) then
  557. result:=rg[rt].uses_registers
  558. else
  559. result:=false;
  560. end;
  561. procedure tcg.add_reg_instruction(instr:Tai;r:tregister);
  562. var
  563. rt : tregistertype;
  564. begin
  565. rt:=getregtype(r);
  566. { Only add it when a register allocator is configured.
  567. No IE can be generated, because the VMT is written
  568. without a valid rg[] }
  569. if assigned(rg[rt]) then
  570. rg[rt].add_reg_instruction(instr,r);
  571. end;
  572. procedure tcg.add_move_instruction(instr:Taicpu);
  573. var
  574. rt : tregistertype;
  575. begin
  576. rt:=getregtype(instr.oper[O_MOV_SOURCE]^.reg);
  577. if assigned(rg[rt]) then
  578. rg[rt].add_move_instruction(instr)
  579. else
  580. internalerror(200310095);
  581. end;
  582. procedure tcg.do_register_allocation(list:Taasmoutput;headertai:tai);
  583. var
  584. rt : tregistertype;
  585. begin
  586. for rt:=low(tregistertype) to high(tregistertype) do
  587. begin
  588. if assigned(rg[rt]) then
  589. rg[rt].do_register_allocation(list,headertai);
  590. end;
  591. end;
  592. procedure tcg.a_reg_alloc(list : taasmoutput;r : tregister);
  593. begin
  594. list.concat(tai_regalloc.alloc(r));
  595. end;
  596. procedure tcg.a_reg_dealloc(list : taasmoutput;r : tregister);
  597. begin
  598. list.concat(tai_regalloc.dealloc(r));
  599. end;
  600. procedure tcg.a_label(list : taasmoutput;l : tasmlabel);
  601. begin
  602. list.concat(tai_label.create(l));
  603. end;
  604. {*****************************************************************************
  605. for better code generation these methods should be overridden
  606. ******************************************************************************}
  607. procedure tcg.a_param_reg(list : taasmoutput;size : tcgsize;r : tregister;const locpara : tparalocation);
  608. var
  609. ref : treference;
  610. begin
  611. case locpara.loc of
  612. LOC_REGISTER,LOC_CREGISTER:
  613. a_load_reg_reg(list,size,locpara.size,r,locpara.register);
  614. LOC_REFERENCE,LOC_CREFERENCE:
  615. begin
  616. reference_reset(ref);
  617. ref.base:=locpara.reference.index;
  618. ref.offset:=locpara.reference.offset;
  619. a_load_reg_ref(list,size,locpara.size,r,ref);
  620. end
  621. else
  622. internalerror(2002071004);
  623. end;
  624. end;
  625. procedure tcg.a_param_const(list : taasmoutput;size : tcgsize;a : aword;const locpara : tparalocation);
  626. var
  627. ref : treference;
  628. begin
  629. case locpara.loc of
  630. LOC_REGISTER,LOC_CREGISTER:
  631. a_load_const_reg(list,locpara.size,a,locpara.register);
  632. LOC_REFERENCE,LOC_CREFERENCE:
  633. begin
  634. reference_reset(ref);
  635. ref.base:=locpara.reference.index;
  636. ref.offset:=locpara.reference.offset;
  637. a_load_const_ref(list,locpara.size,a,ref);
  638. end
  639. else
  640. internalerror(2002071004);
  641. end;
  642. end;
  643. procedure tcg.a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;const locpara : tparalocation);
  644. var
  645. ref : treference;
  646. begin
  647. case locpara.loc of
  648. LOC_REGISTER,LOC_CREGISTER:
  649. a_load_ref_reg(list,size,locpara.size,r,locpara.register);
  650. LOC_REFERENCE,LOC_CREFERENCE:
  651. begin
  652. reference_reset(ref);
  653. ref.base:=locpara.reference.index;
  654. ref.offset:=locpara.reference.offset;
  655. a_load_ref_ref(list,size,locpara.size,r,ref);
  656. end
  657. else
  658. internalerror(2002071004);
  659. end;
  660. end;
  661. procedure tcg.a_param_loc(list : taasmoutput;const l:tlocation;const locpara : tparalocation);
  662. begin
  663. case l.loc of
  664. LOC_REGISTER,
  665. LOC_CREGISTER :
  666. a_param_reg(list,l.size,l.register,locpara);
  667. LOC_CONSTANT :
  668. a_param_const(list,l.size,l.value,locpara);
  669. LOC_CREFERENCE,
  670. LOC_REFERENCE :
  671. a_param_ref(list,l.size,l.reference,locpara);
  672. else
  673. internalerror(2002032211);
  674. end;
  675. end;
  676. procedure tcg.a_paramaddr_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);
  677. var
  678. hr : tregister;
  679. begin
  680. hr:=getaddressregister(list);
  681. a_loadaddr_ref_reg(list,r,hr);
  682. ungetregister(list,hr);
  683. a_param_reg(list,OS_ADDR,hr,locpara);
  684. end;
  685. procedure tcg.a_param_copy_ref(list : taasmoutput;size : qword;const r : treference;const locpara : tparalocation);
  686. var
  687. ref : treference;
  688. begin
  689. if not(locpara.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
  690. internalerror(2003010901);
  691. reference_reset_base(ref,locpara.reference.index,locpara.reference.offset);
  692. g_concatcopy(list,r,ref,size,false,false);
  693. end;
  694. procedure tcg.a_loadany_param_ref(list : taasmoutput;const locpara : tparalocation;const ref:treference;shuffle : pmmshuffle);
  695. begin
  696. case locpara.loc of
  697. LOC_CREGISTER,
  698. LOC_REGISTER:
  699. begin
  700. {$ifndef cpu64bit}
  701. if (locpara.size in [OS_S64,OS_64]) then
  702. begin
  703. getexplicitregister(list,locpara.registerlow);
  704. getexplicitregister(list,locpara.registerhigh);
  705. ungetregister(list,locpara.registerlow);
  706. ungetregister(list,locpara.registerhigh);
  707. cg64.a_load64_reg_ref(list,locpara.register64,ref)
  708. end
  709. else
  710. {$endif cpu64bit}
  711. begin
  712. getexplicitregister(list,locpara.register);
  713. ungetregister(list,locpara.register);
  714. a_load_reg_ref(list,locpara.size,locpara.size,locpara.register,ref);
  715. end;
  716. end;
  717. LOC_MMREGISTER,
  718. LOC_CMMREGISTER:
  719. begin
  720. getexplicitregister(list,locpara.register);
  721. ungetregister(list,locpara.register);
  722. a_loadmm_reg_ref(list,locpara.size,locpara.size,locpara.register,ref,shuffle);
  723. end;
  724. LOC_FPUREGISTER,
  725. LOC_CFPUREGISTER:
  726. begin
  727. getexplicitregister(list,locpara.register);
  728. ungetregister(list,locpara.register);
  729. a_loadfpu_reg_ref(list,locpara.size,locpara.register,ref);
  730. end;
  731. else
  732. internalerror(2002081302);
  733. end;
  734. end;
  735. procedure tcg.a_loadany_param_reg(list : taasmoutput;const locpara : tparalocation;const reg:tregister;shuffle : pmmshuffle);
  736. var
  737. href : treference;
  738. begin
  739. case locpara.loc of
  740. LOC_CREGISTER,
  741. LOC_REGISTER:
  742. begin
  743. if not(locpara.size in [OS_S64,OS_64]) then
  744. begin
  745. getexplicitregister(list,locpara.register);
  746. ungetregister(list,locpara.register);
  747. {
  748. This is now a normal imaginary register, allocated the usual way (JM)
  749. getexplicitregister(list,reg);
  750. }
  751. a_load_reg_reg(list,locpara.size,locpara.size,locpara.register,reg)
  752. end
  753. else
  754. internalerror(2003053011);
  755. end;
  756. LOC_CFPUREGISTER,
  757. LOC_FPUREGISTER:
  758. begin
  759. getexplicitregister(list,locpara.register);
  760. ungetregister(list,locpara.register);
  761. {
  762. This is now a normal imaginary register, allocated the usual way (JM)
  763. getexplicitregister(list,reg);
  764. }
  765. a_loadfpu_reg_reg(list,locpara.size,locpara.register,reg);
  766. end;
  767. LOC_MMREGISTER,
  768. LOC_CMMREGISTER:
  769. begin
  770. getexplicitregister(list,locpara.register);
  771. ungetregister(list,locpara.register);
  772. {
  773. This is now a normal imaginary register, allocated the usual way (JM)
  774. getexplicitregister(list,reg);
  775. }
  776. a_loadmm_reg_reg(list,locpara.size,locpara.size,locpara.register,reg,shuffle);
  777. end;
  778. LOC_REFERENCE,
  779. LOC_CREFERENCE:
  780. begin
  781. reference_reset_base(href,locpara.reference.index,locpara.reference.offset);
  782. {
  783. This is now a normal imaginary register, allocated the usual way (JM)
  784. getexplicitregister(list,reg);
  785. }
  786. a_load_ref_reg(list,locpara.size,locpara.size,href,reg);
  787. end;
  788. else
  789. internalerror(2003053010);
  790. end
  791. end;
  792. {****************************************************************************
  793. some generic implementations
  794. ****************************************************************************}
  795. procedure tcg.a_load_ref_ref(list : taasmoutput;fromsize,tosize : tcgsize;const sref : treference;const dref : treference);
  796. var
  797. tmpreg: tregister;
  798. begin
  799. { verify if we have the same reference }
  800. if references_equal(sref,dref) then
  801. exit;
  802. tmpreg:=getintregister(list,tosize);
  803. a_load_ref_reg(list,fromsize,tosize,sref,tmpreg);
  804. a_load_reg_ref(list,tosize,tosize,tmpreg,dref);
  805. ungetregister(list,tmpreg);
  806. end;
  807. procedure tcg.a_load_const_ref(list : taasmoutput;size : tcgsize;a : aword;const ref : treference);
  808. var
  809. tmpreg: tregister;
  810. begin
  811. tmpreg:=getintregister(list,size);
  812. a_load_const_reg(list,size,a,tmpreg);
  813. a_load_reg_ref(list,size,size,tmpreg,ref);
  814. ungetregister(list,tmpreg);
  815. end;
  816. procedure tcg.a_load_const_loc(list : taasmoutput;a : aword;const loc: tlocation);
  817. begin
  818. case loc.loc of
  819. LOC_REFERENCE,LOC_CREFERENCE:
  820. a_load_const_ref(list,loc.size,a,loc.reference);
  821. LOC_REGISTER,LOC_CREGISTER:
  822. a_load_const_reg(list,loc.size,a,loc.register);
  823. else
  824. internalerror(200203272);
  825. end;
  826. end;
  827. procedure tcg.a_load_reg_loc(list : taasmoutput;fromsize : tcgsize;reg : tregister;const loc: tlocation);
  828. begin
  829. case loc.loc of
  830. LOC_REFERENCE,LOC_CREFERENCE:
  831. a_load_reg_ref(list,fromsize,loc.size,reg,loc.reference);
  832. LOC_REGISTER,LOC_CREGISTER:
  833. a_load_reg_reg(list,fromsize,loc.size,reg,loc.register);
  834. else
  835. internalerror(200203271);
  836. end;
  837. end;
  838. procedure tcg.a_load_loc_reg(list : taasmoutput; tosize: tcgsize; const loc: tlocation; reg : tregister);
  839. begin
  840. case loc.loc of
  841. LOC_REFERENCE,LOC_CREFERENCE:
  842. a_load_ref_reg(list,loc.size,tosize,loc.reference,reg);
  843. LOC_REGISTER,LOC_CREGISTER:
  844. a_load_reg_reg(list,loc.size,tosize,loc.register,reg);
  845. LOC_CONSTANT:
  846. a_load_const_reg(list,tosize,loc.value,reg);
  847. else
  848. internalerror(200109092);
  849. end;
  850. end;
  851. procedure tcg.a_load_loc_ref(list : taasmoutput;tosize: tcgsize; const loc: tlocation; const ref : treference);
  852. begin
  853. case loc.loc of
  854. LOC_REFERENCE,LOC_CREFERENCE:
  855. a_load_ref_ref(list,loc.size,tosize,loc.reference,ref);
  856. LOC_REGISTER,LOC_CREGISTER:
  857. a_load_reg_ref(list,loc.size,tosize,loc.register,ref);
  858. LOC_CONSTANT:
  859. a_load_const_ref(list,tosize,loc.value,ref);
  860. else
  861. internalerror(200109302);
  862. end;
  863. end;
  864. function tcg.optimize_op_const_reg(list: taasmoutput; var op: topcg; var a : aword; var reg:tregister): boolean;
  865. var
  866. powerval : longint;
  867. begin
  868. optimize_op_const_reg := false;
  869. case op of
  870. { or with zero returns same result }
  871. OP_OR : if a = 0 then optimize_op_const_reg := true;
  872. { and with max returns same result }
  873. OP_AND : if (a = high(a)) then optimize_op_const_reg := true;
  874. { division by 1 returns result }
  875. OP_DIV :
  876. begin
  877. if a = 1 then
  878. optimize_op_const_reg := true
  879. else if ispowerof2(int64(a), powerval) then
  880. begin
  881. a := powerval;
  882. op:= OP_SHR;
  883. end;
  884. exit;
  885. end;
  886. OP_IDIV:
  887. begin
  888. if a = 1 then
  889. optimize_op_const_reg := true
  890. else if ispowerof2(int64(a), powerval) then
  891. begin
  892. a := powerval;
  893. op:= OP_SAR;
  894. end;
  895. exit;
  896. end;
  897. OP_MUL,OP_IMUL:
  898. begin
  899. if a = 1 then
  900. optimize_op_const_reg := true
  901. else if ispowerof2(int64(a), powerval) then
  902. begin
  903. a := powerval;
  904. op:= OP_SHL;
  905. end;
  906. exit;
  907. end;
  908. OP_SAR,OP_SHL,OP_SHR:
  909. begin
  910. if a = 0 then
  911. optimize_op_const_reg := true;
  912. exit;
  913. end;
  914. end;
  915. end;
  916. procedure tcg.a_loadfpu_loc_reg(list: taasmoutput; const loc: tlocation; const reg: tregister);
  917. begin
  918. case loc.loc of
  919. LOC_REFERENCE, LOC_CREFERENCE:
  920. a_loadfpu_ref_reg(list,loc.size,loc.reference,reg);
  921. LOC_FPUREGISTER, LOC_CFPUREGISTER:
  922. a_loadfpu_reg_reg(list,loc.size,loc.register,reg);
  923. else
  924. internalerror(200203301);
  925. end;
  926. end;
  927. procedure tcg.a_loadfpu_reg_loc(list: taasmoutput; size: tcgsize; const reg: tregister; const loc: tlocation);
  928. begin
  929. case loc.loc of
  930. LOC_REFERENCE, LOC_CREFERENCE:
  931. a_loadfpu_reg_ref(list,size,reg,loc.reference);
  932. LOC_FPUREGISTER, LOC_CFPUREGISTER:
  933. a_loadfpu_reg_reg(list,size,reg,loc.register);
  934. else
  935. internalerror(48991);
  936. end;
  937. end;
  938. procedure tcg.a_paramfpu_reg(list : taasmoutput;size : tcgsize;const r : tregister;const locpara : tparalocation);
  939. var
  940. ref : treference;
  941. begin
  942. case locpara.loc of
  943. LOC_FPUREGISTER,LOC_CFPUREGISTER:
  944. a_loadfpu_reg_reg(list,size,r,locpara.register);
  945. LOC_REFERENCE,LOC_CREFERENCE:
  946. begin
  947. reference_reset(ref);
  948. ref.base:=locpara.reference.index;
  949. ref.offset:=locpara.reference.offset;
  950. a_loadfpu_reg_ref(list,size,r,ref);
  951. end
  952. else
  953. internalerror(2002071004);
  954. end;
  955. end;
  956. procedure tcg.a_paramfpu_ref(list : taasmoutput;size : tcgsize;const ref : treference;const locpara : tparalocation);
  957. var
  958. href : treference;
  959. begin
  960. case locpara.loc of
  961. LOC_FPUREGISTER,LOC_CFPUREGISTER:
  962. a_loadfpu_ref_reg(list,size,ref,locpara.register);
  963. LOC_REFERENCE,LOC_CREFERENCE:
  964. begin
  965. reference_reset(href);
  966. href.base:=locpara.reference.index;
  967. href.offset:=locpara.reference.offset;
  968. { concatcopy should choose the best way to copy the data }
  969. g_concatcopy(list,ref,href,tcgsize2size[size],false,false);
  970. end
  971. else
  972. internalerror(200402201);
  973. end;
  974. end;
  975. procedure tcg.a_op_const_ref(list : taasmoutput; Op: TOpCG; size: TCGSize; a: AWord; const ref: TReference);
  976. var
  977. tmpreg: tregister;
  978. begin
  979. tmpreg:=getintregister(list,size);
  980. a_load_ref_reg(list,size,size,ref,tmpreg);
  981. a_op_const_reg(list,op,size,a,tmpreg);
  982. a_load_reg_ref(list,size,size,tmpreg,ref);
  983. ungetregister(list,tmpreg);
  984. end;
  985. procedure tcg.a_op_const_loc(list : taasmoutput; Op: TOpCG; a: AWord; const loc: tlocation);
  986. begin
  987. case loc.loc of
  988. LOC_REGISTER, LOC_CREGISTER:
  989. a_op_const_reg(list,op,loc.size,a,loc.register);
  990. LOC_REFERENCE, LOC_CREFERENCE:
  991. a_op_const_ref(list,op,loc.size,a,loc.reference);
  992. else
  993. internalerror(200109061);
  994. end;
  995. end;
  996. procedure tcg.a_op_reg_ref(list : taasmoutput; Op: TOpCG; size: TCGSize;reg: TRegister; const ref: TReference);
  997. var
  998. tmpreg: tregister;
  999. begin
  1000. tmpreg:=getintregister(list,size);
  1001. a_load_ref_reg(list,size,size,ref,tmpreg);
  1002. a_op_reg_reg(list,op,size,reg,tmpreg);
  1003. a_load_reg_ref(list,size,size,tmpreg,ref);
  1004. ungetregister(list,tmpreg);
  1005. end;
  1006. procedure tcg.a_op_ref_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; const ref: TReference; reg: TRegister);
  1007. var
  1008. tmpreg: tregister;
  1009. begin
  1010. case op of
  1011. OP_NOT,OP_NEG:
  1012. { handle it as "load ref,reg; op reg" }
  1013. begin
  1014. a_load_ref_reg(list,size,size,ref,reg);
  1015. a_op_reg_reg(list,op,size,reg,reg);
  1016. end;
  1017. else
  1018. begin
  1019. tmpreg:=getintregister(list,size);
  1020. a_load_ref_reg(list,size,size,ref,tmpreg);
  1021. a_op_reg_reg(list,op,size,tmpreg,reg);
  1022. ungetregister(list,tmpreg);
  1023. end;
  1024. end;
  1025. end;
  1026. procedure tcg.a_op_reg_loc(list : taasmoutput; Op: TOpCG; reg: tregister; const loc: tlocation);
  1027. begin
  1028. case loc.loc of
  1029. LOC_REGISTER, LOC_CREGISTER:
  1030. a_op_reg_reg(list,op,loc.size,reg,loc.register);
  1031. LOC_REFERENCE, LOC_CREFERENCE:
  1032. a_op_reg_ref(list,op,loc.size,reg,loc.reference);
  1033. else
  1034. internalerror(200109061);
  1035. end;
  1036. end;
  1037. procedure tcg.a_op_ref_loc(list : taasmoutput; Op: TOpCG; const ref: TReference; const loc: tlocation);
  1038. var
  1039. tmpreg: tregister;
  1040. begin
  1041. case loc.loc of
  1042. LOC_REGISTER,LOC_CREGISTER:
  1043. a_op_ref_reg(list,op,loc.size,ref,loc.register);
  1044. LOC_REFERENCE,LOC_CREFERENCE:
  1045. begin
  1046. tmpreg:=getintregister(list,loc.size);
  1047. a_load_ref_reg(list,loc.size,loc.size,ref,tmpreg);
  1048. a_op_reg_ref(list,op,loc.size,tmpreg,loc.reference);
  1049. ungetregister(list,tmpreg);
  1050. end;
  1051. else
  1052. internalerror(200109061);
  1053. end;
  1054. end;
  1055. procedure Tcg.a_op_const_reg_reg(list:Taasmoutput;op:Topcg;size:Tcgsize;
  1056. a:aword;src,dst:Tregister);
  1057. begin
  1058. a_load_reg_reg(list,size,size,src,dst);
  1059. a_op_const_reg(list,op,size,a,dst);
  1060. end;
  1061. procedure tcg.a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
  1062. size: tcgsize; src1, src2, dst: tregister);
  1063. var
  1064. tmpreg: tregister;
  1065. begin
  1066. if (dst<>src1) then
  1067. begin
  1068. a_load_reg_reg(list,size,size,src2,dst);
  1069. a_op_reg_reg(list,op,size,src1,dst);
  1070. end
  1071. else
  1072. begin
  1073. tmpreg:=getintregister(list,size);
  1074. a_load_reg_reg(list,size,size,src2,tmpreg);
  1075. a_op_reg_reg(list,op,size,src1,tmpreg);
  1076. a_load_reg_reg(list,size,size,tmpreg,dst);
  1077. ungetregister(list,tmpreg);
  1078. end;
  1079. end;
  1080. procedure tcg.a_cmp_const_ref_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;const ref : treference;
  1081. l : tasmlabel);
  1082. var
  1083. tmpreg: tregister;
  1084. begin
  1085. tmpreg:=getintregister(list,size);
  1086. a_load_ref_reg(list,size,size,ref,tmpreg);
  1087. a_cmp_const_reg_label(list,size,cmp_op,a,tmpreg,l);
  1088. ungetregister(list,tmpreg);
  1089. end;
  1090. procedure tcg.a_cmp_const_loc_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;const loc : tlocation;
  1091. l : tasmlabel);
  1092. begin
  1093. case loc.loc of
  1094. LOC_REGISTER,LOC_CREGISTER:
  1095. a_cmp_const_reg_label(list,size,cmp_op,a,loc.register,l);
  1096. LOC_REFERENCE,LOC_CREFERENCE:
  1097. a_cmp_const_ref_label(list,size,cmp_op,a,loc.reference,l);
  1098. else
  1099. internalerror(200109061);
  1100. end;
  1101. end;
  1102. procedure tcg.a_cmp_ref_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const ref: treference; reg : tregister; l : tasmlabel);
  1103. var
  1104. tmpreg: tregister;
  1105. begin
  1106. tmpreg:=getintregister(list,size);
  1107. a_load_ref_reg(list,size,size,ref,tmpreg);
  1108. a_cmp_reg_reg_label(list,size,cmp_op,tmpreg,reg,l);
  1109. ungetregister(list,tmpreg);
  1110. end;
  1111. procedure tcg.a_cmp_loc_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const loc: tlocation; reg : tregister; l : tasmlabel);
  1112. begin
  1113. case loc.loc of
  1114. LOC_REGISTER,
  1115. LOC_CREGISTER:
  1116. a_cmp_reg_reg_label(list,size,cmp_op,loc.register,reg,l);
  1117. LOC_REFERENCE,
  1118. LOC_CREFERENCE :
  1119. a_cmp_ref_reg_label(list,size,cmp_op,loc.reference,reg,l);
  1120. LOC_CONSTANT:
  1121. a_cmp_const_reg_label(list,size,cmp_op,loc.value,reg,l);
  1122. else
  1123. internalerror(200203231);
  1124. end;
  1125. end;
  1126. procedure tcg.a_cmp_ref_loc_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;const ref: treference;const loc : tlocation;
  1127. l : tasmlabel);
  1128. var
  1129. tmpreg: tregister;
  1130. begin
  1131. case loc.loc of
  1132. LOC_REGISTER,LOC_CREGISTER:
  1133. a_cmp_ref_reg_label(list,size,cmp_op,ref,loc.register,l);
  1134. LOC_REFERENCE,LOC_CREFERENCE:
  1135. begin
  1136. tmpreg:=getintregister(list,size);
  1137. a_load_ref_reg(list,size,size,loc.reference,tmpreg);
  1138. a_cmp_ref_reg_label(list,size,cmp_op,ref,tmpreg,l);
  1139. ungetregister(list,tmpreg);
  1140. end
  1141. else
  1142. internalerror(200109061);
  1143. end;
  1144. end;
  1145. procedure tcg.a_loadmm_loc_reg(list: taasmoutput; size: tcgsize; const loc: tlocation; const reg: tregister;shuffle : pmmshuffle);
  1146. begin
  1147. case loc.loc of
  1148. LOC_MMREGISTER,LOC_CMMREGISTER:
  1149. a_loadmm_reg_reg(list,loc.size,size,loc.register,reg,shuffle);
  1150. LOC_REFERENCE,LOC_CREFERENCE:
  1151. a_loadmm_ref_reg(list,loc.size,size,loc.reference,reg,shuffle);
  1152. else
  1153. internalerror(200310121);
  1154. end;
  1155. end;
  1156. procedure tcg.a_loadmm_reg_loc(list: taasmoutput; size: tcgsize; const reg: tregister; const loc: tlocation;shuffle : pmmshuffle);
  1157. begin
  1158. case loc.loc of
  1159. LOC_MMREGISTER,LOC_CMMREGISTER:
  1160. a_loadmm_reg_reg(list,size,loc.size,reg,loc.register,shuffle);
  1161. LOC_REFERENCE,LOC_CREFERENCE:
  1162. a_loadmm_reg_ref(list,size,loc.size,reg,loc.reference,shuffle);
  1163. else
  1164. internalerror(200310122);
  1165. end;
  1166. end;
  1167. procedure tcg.a_parammm_reg(list: taasmoutput; size: tcgsize; reg: tregister;const locpara : tparalocation;shuffle : pmmshuffle);
  1168. var
  1169. ref : treference;
  1170. begin
  1171. case locpara.loc of
  1172. LOC_MMREGISTER,LOC_CMMREGISTER:
  1173. a_loadmm_reg_reg(list,size,locpara.size,reg,locpara.register,shuffle);
  1174. LOC_REFERENCE,LOC_CREFERENCE:
  1175. begin
  1176. reference_reset(ref);
  1177. ref.base:=locpara.reference.index;
  1178. ref.offset:=locpara.reference.offset;
  1179. a_loadmm_reg_ref(list,size,locpara.size,reg,ref,shuffle);
  1180. end
  1181. else
  1182. internalerror(200310123);
  1183. end;
  1184. end;
  1185. procedure tcg.a_parammm_ref(list: taasmoutput; size: tcgsize;const ref: treference;const locpara : tparalocation;shuffle : pmmshuffle);
  1186. var
  1187. hr : tregister;
  1188. hs : tmmshuffle;
  1189. begin
  1190. hr:=getmmregister(list,locpara.size);
  1191. a_loadmm_ref_reg(list,size,locpara.size,ref,hr,shuffle);
  1192. if realshuffle(shuffle) then
  1193. begin
  1194. hs:=shuffle^;
  1195. removeshuffles(hs);
  1196. a_parammm_reg(list,locpara.size,hr,locpara,@hs);
  1197. end
  1198. else
  1199. a_parammm_reg(list,locpara.size,hr,locpara,shuffle);
  1200. ungetregister(list,hr);
  1201. end;
  1202. procedure tcg.a_parammm_loc(list: taasmoutput;const loc: tlocation; const locpara : tparalocation;shuffle : pmmshuffle);
  1203. begin
  1204. case loc.loc of
  1205. LOC_MMREGISTER,LOC_CMMREGISTER:
  1206. a_parammm_reg(list,loc.size,loc.register,locpara,shuffle);
  1207. LOC_REFERENCE,LOC_CREFERENCE:
  1208. a_parammm_ref(list,loc.size,loc.reference,locpara,shuffle);
  1209. else
  1210. internalerror(200310123);
  1211. end;
  1212. end;
  1213. procedure tcg.a_opmm_ref_reg(list: taasmoutput; Op: TOpCG; size : tcgsize;const ref: treference; reg: tregister;shuffle : pmmshuffle);
  1214. var
  1215. hr : tregister;
  1216. hs : tmmshuffle;
  1217. begin
  1218. hr:=getmmregister(list,size);
  1219. a_loadmm_ref_reg(list,size,size,ref,hr,shuffle);
  1220. if realshuffle(shuffle) then
  1221. begin
  1222. hs:=shuffle^;
  1223. removeshuffles(hs);
  1224. a_opmm_reg_reg(list,op,size,hr,reg,@hs);
  1225. end
  1226. else
  1227. a_opmm_reg_reg(list,op,size,hr,reg,shuffle);
  1228. ungetregister(list,hr);
  1229. end;
  1230. procedure tcg.a_opmm_reg_ref(list: taasmoutput; Op: TOpCG; size : tcgsize;reg: tregister; const ref: treference; shuffle : pmmshuffle);
  1231. var
  1232. hr : tregister;
  1233. hs : tmmshuffle;
  1234. begin
  1235. hr:=getmmregister(list,size);
  1236. a_loadmm_ref_reg(list,size,size,ref,hr,shuffle);
  1237. if realshuffle(shuffle) then
  1238. begin
  1239. hs:=shuffle^;
  1240. removeshuffles(hs);
  1241. a_opmm_reg_reg(list,op,size,reg,hr,@hs);
  1242. a_loadmm_reg_ref(list,size,size,hr,ref,@hs);
  1243. end
  1244. else
  1245. begin
  1246. a_opmm_reg_reg(list,op,size,reg,hr,shuffle);
  1247. a_loadmm_reg_ref(list,size,size,hr,ref,shuffle);
  1248. end;
  1249. ungetregister(list,hr);
  1250. end;
  1251. procedure tcg.a_opmm_loc_reg(list: taasmoutput; Op: TOpCG; size : tcgsize;const loc: tlocation; reg: tregister;shuffle : pmmshuffle);
  1252. begin
  1253. case loc.loc of
  1254. LOC_CMMREGISTER,LOC_MMREGISTER:
  1255. a_opmm_reg_reg(list,op,size,loc.register,reg,shuffle);
  1256. LOC_CREFERENCE,LOC_REFERENCE:
  1257. a_opmm_ref_reg(list,op,size,loc.reference,reg,shuffle);
  1258. else
  1259. internalerror(200312232);
  1260. end;
  1261. end;
  1262. class function tcg.reg_cgsize(const reg: tregister) : tcgsize;
  1263. begin
  1264. reg_cgsize := OS_INT;
  1265. end;
  1266. procedure tcg.g_copyshortstring(list : taasmoutput;const source,dest : treference;len:byte;delsource,loadref : boolean);
  1267. var
  1268. paraloc1,paraloc2,paraloc3 : tparalocation;
  1269. begin
  1270. {$ifdef FPC}
  1271. {$warning FIX ME!}
  1272. {$endif}
  1273. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  1274. paraloc2:=paramanager.getintparaloc(pocall_default,2);
  1275. paraloc3:=paramanager.getintparaloc(pocall_default,3);
  1276. paramanager.allocparaloc(list,paraloc3);
  1277. a_paramaddr_ref(list,dest,paraloc3);
  1278. paramanager.allocparaloc(list,paraloc2);
  1279. if loadref then
  1280. a_param_ref(list,OS_ADDR,source,paraloc2)
  1281. else
  1282. a_paramaddr_ref(list,source,paraloc2);
  1283. if delsource then
  1284. reference_release(list,source);
  1285. paramanager.allocparaloc(list,paraloc1);
  1286. a_param_const(list,OS_INT,len,paraloc1);
  1287. paramanager.freeparaloc(list,paraloc3);
  1288. paramanager.freeparaloc(list,paraloc2);
  1289. paramanager.freeparaloc(list,paraloc1);
  1290. allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1291. a_call_name(list,'FPC_SHORTSTR_ASSIGN');
  1292. deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1293. end;
  1294. procedure tcg.g_incrrefcount(list : taasmoutput;t: tdef; const ref: treference;loadref : boolean);
  1295. var
  1296. href : treference;
  1297. incrfunc : string;
  1298. paraloc1,paraloc2 : tparalocation;
  1299. begin
  1300. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  1301. paraloc2:=paramanager.getintparaloc(pocall_default,2);
  1302. { These functions should not change the registers (they use
  1303. the saveregister proc directive }
  1304. if is_interfacecom(t) then
  1305. incrfunc:='FPC_INTF_INCR_REF'
  1306. else if is_ansistring(t) then
  1307. {$ifdef ansistring_bits}
  1308. begin
  1309. case Tstringdef(t).string_typ of
  1310. st_ansistring16:
  1311. incrfunc:='FPC_ANSISTR16_INCR_REF';
  1312. st_ansistring32:
  1313. incrfunc:='FPC_ANSISTR32_INCR_REF';
  1314. st_ansistring64:
  1315. incrfunc:='FPC_ANSISTR64_INCR_REF';
  1316. end;
  1317. end
  1318. {$else}
  1319. incrfunc:='FPC_ANSISTR_INCR_REF'
  1320. {$endif}
  1321. else if is_widestring(t) then
  1322. incrfunc:='FPC_WIDESTR_INCR_REF'
  1323. else if is_dynamic_array(t) then
  1324. incrfunc:='FPC_DYNARRAY_INCR_REF'
  1325. else
  1326. incrfunc:='';
  1327. { call the special incr function or the generic addref }
  1328. if incrfunc<>'' then
  1329. begin
  1330. { these functions get the pointer by value }
  1331. paramanager.allocparaloc(list,paraloc1);
  1332. a_param_ref(list,OS_ADDR,ref,paraloc1);
  1333. paramanager.freeparaloc(list,paraloc1);
  1334. allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1335. a_call_name(list,incrfunc);
  1336. deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1337. end
  1338. else
  1339. begin
  1340. reference_reset_symbol(href,tstoreddef(t).get_rtti_label(initrtti),0);
  1341. paramanager.allocparaloc(list,paraloc2);
  1342. a_paramaddr_ref(list,href,paraloc2);
  1343. paramanager.allocparaloc(list,paraloc1);
  1344. if loadref then
  1345. a_param_ref(list,OS_ADDR,ref,paraloc1)
  1346. else
  1347. a_paramaddr_ref(list,ref,paraloc1);
  1348. paramanager.freeparaloc(list,paraloc1);
  1349. paramanager.freeparaloc(list,paraloc2);
  1350. allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1351. a_call_name(list,'FPC_ADDREF');
  1352. deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1353. end;
  1354. end;
  1355. procedure tcg.g_decrrefcount(list : taasmoutput;t: tdef; const ref: treference; loadref:boolean);
  1356. var
  1357. hreg : tregister;
  1358. href : treference;
  1359. decrfunc : string;
  1360. needrtti : boolean;
  1361. paraloc1,paraloc2 : tparalocation;
  1362. begin
  1363. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  1364. paraloc2:=paramanager.getintparaloc(pocall_default,2);
  1365. needrtti:=false;
  1366. if is_interfacecom(t) then
  1367. decrfunc:='FPC_INTF_DECR_REF'
  1368. else if is_ansistring(t) then
  1369. {$ifdef ansistring_bits}
  1370. begin
  1371. case Tstringdef(t).string_typ of
  1372. st_ansistring16:
  1373. decrfunc:='FPC_ANSISTR16_DECR_REF';
  1374. st_ansistring32:
  1375. decrfunc:='FPC_ANSISTR32_DECR_REF';
  1376. st_ansistring64:
  1377. decrfunc:='FPC_ANSISTR64_DECR_REF';
  1378. end;
  1379. end
  1380. {$else}
  1381. decrfunc:='FPC_ANSISTR_DECR_REF'
  1382. {$endif}
  1383. else if is_widestring(t) then
  1384. decrfunc:='FPC_WIDESTR_DECR_REF'
  1385. else if is_dynamic_array(t) then
  1386. begin
  1387. decrfunc:='FPC_DYNARRAY_DECR_REF';
  1388. needrtti:=true;
  1389. end
  1390. else
  1391. decrfunc:='';
  1392. { call the special decr function or the generic decref }
  1393. if decrfunc<>'' then
  1394. begin
  1395. if needrtti then
  1396. begin
  1397. reference_reset_symbol(href,tstoreddef(t).get_rtti_label(initrtti),0);
  1398. paramanager.allocparaloc(list,paraloc2);
  1399. a_paramaddr_ref(list,href,paraloc2);
  1400. end;
  1401. paramanager.allocparaloc(list,paraloc1);
  1402. if loadref then
  1403. a_param_ref(list,OS_ADDR,ref,paraloc1)
  1404. else
  1405. a_paramaddr_ref(list,ref,paraloc1);
  1406. paramanager.freeparaloc(list,paraloc1);
  1407. if needrtti then
  1408. paramanager.freeparaloc(list,paraloc2);
  1409. allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1410. a_call_name(list,decrfunc);
  1411. deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1412. end
  1413. else
  1414. begin
  1415. reference_reset_symbol(href,tstoreddef(t).get_rtti_label(initrtti),0);
  1416. paramanager.allocparaloc(list,paraloc2);
  1417. a_paramaddr_ref(list,href,paraloc2);
  1418. paramanager.allocparaloc(list,paraloc1);
  1419. if loadref then
  1420. a_param_ref(list,OS_ADDR,ref,paraloc1)
  1421. else
  1422. a_paramaddr_ref(list,ref,paraloc1);
  1423. paramanager.freeparaloc(list,paraloc1);
  1424. paramanager.freeparaloc(list,paraloc2);
  1425. allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1426. a_call_name(list,'FPC_DECREF');
  1427. deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1428. end;
  1429. { Temp locations need always to be reset to 0 }
  1430. if tg.istemp(ref) then
  1431. begin
  1432. if loadref then
  1433. begin
  1434. hreg:=getaddressregister(list);
  1435. a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,hreg);
  1436. reference_reset_base(href,hreg,0);
  1437. a_load_const_ref(list,OS_ADDR,0,href);
  1438. ungetregister(list,hreg);
  1439. end
  1440. else
  1441. a_load_const_ref(list,OS_ADDR,0,ref);
  1442. end;
  1443. end;
  1444. procedure tcg.g_initialize(list : taasmoutput;t : tdef;const ref : treference;loadref : boolean);
  1445. var
  1446. href : treference;
  1447. paraloc1,paraloc2 : tparalocation;
  1448. begin
  1449. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  1450. paraloc2:=paramanager.getintparaloc(pocall_default,2);
  1451. if is_ansistring(t) or
  1452. is_widestring(t) or
  1453. is_interfacecom(t) or
  1454. is_dynamic_array(t) then
  1455. a_load_const_ref(list,OS_ADDR,0,ref)
  1456. else
  1457. begin
  1458. reference_reset_symbol(href,tstoreddef(t).get_rtti_label(initrtti),0);
  1459. paramanager.allocparaloc(list,paraloc2);
  1460. a_paramaddr_ref(list,href,paraloc2);
  1461. paramanager.allocparaloc(list,paraloc1);
  1462. if loadref then
  1463. a_param_ref(list,OS_ADDR,ref,paraloc1)
  1464. else
  1465. a_paramaddr_ref(list,ref,paraloc1);
  1466. paramanager.freeparaloc(list,paraloc1);
  1467. paramanager.freeparaloc(list,paraloc2);
  1468. allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1469. a_call_name(list,'FPC_INITIALIZE');
  1470. deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1471. end;
  1472. end;
  1473. procedure tcg.g_finalize(list : taasmoutput;t : tdef;const ref : treference;loadref : boolean);
  1474. var
  1475. hreg : tregister;
  1476. href : treference;
  1477. paraloc1,paraloc2 : tparalocation;
  1478. begin
  1479. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  1480. paraloc2:=paramanager.getintparaloc(pocall_default,2);
  1481. if is_ansistring(t) or
  1482. is_widestring(t) or
  1483. is_interfacecom(t) then
  1484. begin
  1485. g_decrrefcount(list,t,ref,loadref);
  1486. { Temp locations are already reset to 0 }
  1487. if not tg.istemp(ref) then
  1488. begin
  1489. if loadref then
  1490. begin
  1491. hreg:=getaddressregister(list);
  1492. a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,hreg);
  1493. reference_reset_base(href,hreg,0);
  1494. a_load_const_ref(list,OS_ADDR,0,href);
  1495. ungetregister(list,hreg);
  1496. end
  1497. else
  1498. a_load_const_ref(list,OS_ADDR,0,ref);
  1499. end;
  1500. end
  1501. else
  1502. begin
  1503. reference_reset_symbol(href,tstoreddef(t).get_rtti_label(initrtti),0);
  1504. paramanager.allocparaloc(list,paraloc2);
  1505. a_paramaddr_ref(list,href,paraloc2);
  1506. paramanager.allocparaloc(list,paraloc1);
  1507. if loadref then
  1508. a_param_ref(list,OS_ADDR,ref,paraloc1)
  1509. else
  1510. a_paramaddr_ref(list,ref,paraloc1);
  1511. paramanager.freeparaloc(list,paraloc1);
  1512. paramanager.freeparaloc(list,paraloc2);
  1513. allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1514. a_call_name(list,'FPC_FINALIZE');
  1515. deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1516. end;
  1517. end;
  1518. procedure tcg.g_rangecheck(list: taasmoutput; const l:tlocation;fromdef,todef: tdef);
  1519. { generate range checking code for the value at location p. The type }
  1520. { type used is checked against todefs ranges. fromdef (p.resulttype.def) }
  1521. { is the original type used at that location. When both defs are equal }
  1522. { the check is also insert (needed for succ,pref,inc,dec) }
  1523. const
  1524. {$ifdef ver1_0}
  1525. awordsignedmax=high(longint);
  1526. {$else}
  1527. awordsignedmax=high(aword) div 2;
  1528. {$endif}
  1529. var
  1530. neglabel : tasmlabel;
  1531. hreg : tregister;
  1532. lto,hto,
  1533. lfrom,hfrom : TConstExprInt;
  1534. from_signed: boolean;
  1535. begin
  1536. { range checking on and range checkable value? }
  1537. if not(cs_check_range in aktlocalswitches) or
  1538. not(fromdef.deftype in [orddef,enumdef,arraydef]) then
  1539. exit;
  1540. if is_64bit(fromdef) or is_64bit(todef) then
  1541. begin
  1542. cg64.g_rangecheck64(list,l,fromdef,todef);
  1543. exit;
  1544. end;
  1545. { only check when assigning to scalar, subranges are different, }
  1546. { when todef=fromdef then the check is always generated }
  1547. getrange(fromdef,lfrom,hfrom);
  1548. getrange(todef,lto,hto);
  1549. { no range check if from and to are equal and are both longint/dword }
  1550. { (if we have a 32bit processor) or int64/qword, since such }
  1551. { operations can at most cause overflows (JM) }
  1552. { Note that these checks are mostly processor independent, they only }
  1553. { have to be changed once we introduce 64bit subrange types }
  1554. {$warning range check still s32bit}
  1555. if (fromdef = todef) and
  1556. (fromdef.deftype=orddef) and
  1557. (((sizeof(aword) = 4) and
  1558. (((torddef(fromdef).typ = s32bit) and
  1559. (lfrom = low(longint)) and
  1560. (hfrom = high(longint))) or
  1561. ((torddef(fromdef).typ = u32bit) and
  1562. (lfrom = low(cardinal)) and
  1563. (hfrom = high(cardinal)))))) then
  1564. exit;
  1565. if todef<>fromdef then
  1566. begin
  1567. { if the from-range falls completely in the to-range, no check }
  1568. { is necessary }
  1569. if (lto<=lfrom) and (hto>=hfrom) then
  1570. exit;
  1571. end;
  1572. { generate the rangecheck code for the def where we are going to }
  1573. { store the result }
  1574. { use the trick that }
  1575. { a <= x <= b <=> 0 <= x-a <= b-a <=> unsigned(x-a) <= unsigned(b-a) }
  1576. { To be able to do that, we have to make sure however that either }
  1577. { fromdef and todef are both signed or unsigned, or that we leave }
  1578. { the parts < 0 and > maxlongint out }
  1579. { is_signed now also works for arrays (it checks the rangetype) (JM) }
  1580. from_signed := is_signed(fromdef);
  1581. if from_signed xor is_signed(todef) then
  1582. if from_signed then
  1583. { from is signed, to is unsigned }
  1584. begin
  1585. { if high(from) < 0 -> always range error }
  1586. if (hfrom < 0) or
  1587. { if low(to) > maxlongint also range error }
  1588. (lto > awordsignedmax) then
  1589. begin
  1590. a_call_name(list,'FPC_RANGEERROR');
  1591. exit
  1592. end;
  1593. { from is signed and to is unsigned -> when looking at from }
  1594. { as an unsigned value, it must be < maxlongint (otherwise }
  1595. { it's negative, which is invalid since "to" is unsigned) }
  1596. if hto > awordsignedmax then
  1597. hto := awordsignedmax;
  1598. end
  1599. else
  1600. { from is unsigned, to is signed }
  1601. begin
  1602. if (lfrom > awordsignedmax) or
  1603. (hto < 0) then
  1604. begin
  1605. a_call_name(list,'FPC_RANGEERROR');
  1606. exit
  1607. end;
  1608. { from is unsigned and to is signed -> when looking at to }
  1609. { as an unsigned value, it must be >= 0 (since negative }
  1610. { values are the same as values > maxlongint) }
  1611. if lto < 0 then
  1612. lto := 0;
  1613. end;
  1614. hreg:=getintregister(list,OS_INT);
  1615. a_load_loc_reg(list,OS_INT,l,hreg);
  1616. a_op_const_reg(list,OP_SUB,OS_INT,aword(lto),hreg);
  1617. objectlibrary.getlabel(neglabel);
  1618. a_cmp_const_reg_label(list,OS_INT,OC_BE,aword(hto-lto),hreg,neglabel);
  1619. { !!! should happen right after the compare (JM) }
  1620. ungetregister(list,hreg);
  1621. a_call_name(list,'FPC_RANGEERROR');
  1622. a_label(list,neglabel);
  1623. end;
  1624. procedure tcg.g_flags2ref(list: taasmoutput; size: TCgSize; const f: tresflags; const ref:TReference);
  1625. var
  1626. tmpreg : tregister;
  1627. begin
  1628. tmpreg:=getintregister(list,size);
  1629. g_flags2reg(list,size,f,tmpreg);
  1630. a_load_reg_ref(list,size,size,tmpreg,ref);
  1631. ungetregister(list,tmpreg);
  1632. end;
  1633. procedure tcg.g_maybe_testself(list : taasmoutput;reg:tregister);
  1634. var
  1635. OKLabel : tasmlabel;
  1636. paraloc1 : tparalocation;
  1637. begin
  1638. if (cs_check_object in aktlocalswitches) or
  1639. (cs_check_range in aktlocalswitches) then
  1640. begin
  1641. objectlibrary.getlabel(oklabel);
  1642. a_cmp_const_reg_label(list,OS_ADDR,OC_NE,0,reg,oklabel);
  1643. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  1644. paramanager.allocparaloc(list,paraloc1);
  1645. a_param_const(list,OS_INT,210,paraloc1);
  1646. paramanager.freeparaloc(list,paraloc1);
  1647. a_call_name(list,'FPC_HANDLEERROR');
  1648. a_label(list,oklabel);
  1649. end;
  1650. end;
  1651. procedure tcg.g_maybe_testvmt(list : taasmoutput;reg:tregister;objdef:tobjectdef);
  1652. var
  1653. hrefvmt : treference;
  1654. paraloc1,paraloc2 : tparalocation;
  1655. begin
  1656. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  1657. paraloc2:=paramanager.getintparaloc(pocall_default,2);
  1658. if (cs_check_object in aktlocalswitches) then
  1659. begin
  1660. reference_reset_symbol(hrefvmt,objectlibrary.newasmsymbol(objdef.vmt_mangledname,AB_EXTERNAL,AT_DATA),0);
  1661. paramanager.allocparaloc(list,paraloc2);
  1662. a_paramaddr_ref(list,hrefvmt,paraloc2);
  1663. paramanager.allocparaloc(list,paraloc1);
  1664. a_param_reg(list,OS_ADDR,reg,paraloc1);
  1665. paramanager.freeparaloc(list,paraloc1);
  1666. paramanager.freeparaloc(list,paraloc2);
  1667. { No register saving needed, saveregisters is used }
  1668. allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1669. a_call_name(list,'FPC_CHECK_OBJECT_EXT');
  1670. deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1671. end
  1672. else
  1673. if (cs_check_range in aktlocalswitches) then
  1674. begin
  1675. paramanager.allocparaloc(list,paraloc1);
  1676. a_param_reg(list,OS_ADDR,reg,paraloc1);
  1677. paramanager.freeparaloc(list,paraloc1);
  1678. { No register saving needed, saveregisters is used }
  1679. allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1680. a_call_name(list,'FPC_CHECK_OBJECT');
  1681. deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1682. end;
  1683. end;
  1684. {*****************************************************************************
  1685. Entry/Exit Code Functions
  1686. *****************************************************************************}
  1687. procedure tcg.g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:aword);
  1688. var
  1689. sizereg,sourcereg,destreg : tregister;
  1690. paraloc1,paraloc2,paraloc3 : tparalocation;
  1691. begin
  1692. { because ppc abi doesn't support dynamic stack allocation properly
  1693. open array value parameters are copied onto the heap
  1694. }
  1695. { allocate two registers for len and source }
  1696. sizereg:=getintregister(list,OS_INT);
  1697. sourcereg:=getintregister(list,OS_ADDR);
  1698. destreg:=getintregister(list,OS_ADDR);
  1699. { calculate necessary memory }
  1700. a_load_ref_reg(list,OS_INT,OS_INT,lenref,sizereg);
  1701. a_op_const_reg(list,OP_ADD,OS_INT,1,sizereg);
  1702. a_op_const_reg(list,OP_MUL,OS_INT,elesize,sizereg);
  1703. { load source }
  1704. a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,sourcereg);
  1705. { do getmem call }
  1706. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  1707. paramanager.allocparaloc(list,paraloc1);
  1708. a_param_reg(list,OS_INT,sizereg,paraloc1);
  1709. paramanager.freeparaloc(list,paraloc1);
  1710. allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1711. a_call_name(list,'FPC_GETMEM');
  1712. deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1713. a_load_reg_reg(list,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,destreg);
  1714. a_load_reg_ref(list,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,ref);
  1715. { do move call }
  1716. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  1717. paraloc2:=paramanager.getintparaloc(pocall_default,2);
  1718. paraloc3:=paramanager.getintparaloc(pocall_default,3);
  1719. { load size }
  1720. paramanager.allocparaloc(list,paraloc3);
  1721. a_param_reg(list,OS_INT,sizereg,paraloc3);
  1722. { load destination }
  1723. paramanager.allocparaloc(list,paraloc2);
  1724. a_param_reg(list,OS_ADDR,destreg,paraloc2);
  1725. { load source }
  1726. paramanager.allocparaloc(list,paraloc1);
  1727. a_param_reg(list,OS_ADDR,sourcereg,paraloc1);
  1728. paramanager.freeparaloc(list,paraloc3);
  1729. paramanager.freeparaloc(list,paraloc2);
  1730. paramanager.freeparaloc(list,paraloc1);
  1731. allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1732. a_call_name(list,'FPC_MOVE');
  1733. deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1734. { release used registers }
  1735. ungetregister(list,sizereg);
  1736. ungetregister(list,sourcereg);
  1737. ungetregister(list,destreg);
  1738. end;
  1739. procedure tcg.g_releasevaluepara_openarray(list : taasmoutput;const ref:treference);
  1740. var
  1741. paraloc : tparalocation;
  1742. begin
  1743. { do move call }
  1744. paraloc:=paramanager.getintparaloc(pocall_default,1);
  1745. { load source }
  1746. paramanager.allocparaloc(list,paraloc);
  1747. a_param_ref(list,OS_ADDR,ref,paraloc);
  1748. paramanager.freeparaloc(list,paraloc);
  1749. allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1750. a_call_name(list,'FPC_FREEMEM');
  1751. deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1752. end;
  1753. procedure tcg.g_interrupt_stackframe_entry(list : taasmoutput);
  1754. begin
  1755. end;
  1756. procedure tcg.g_interrupt_stackframe_exit(list : taasmoutput;accused,acchiused:boolean);
  1757. begin
  1758. end;
  1759. procedure tcg.g_profilecode(list : taasmoutput);
  1760. begin
  1761. end;
  1762. procedure tcg.g_exception_reason_save(list : taasmoutput; const href : treference);
  1763. begin
  1764. a_load_reg_ref(list, OS_S32, OS_32, NR_FUNCTION_RETURN_REG, href);
  1765. end;
  1766. procedure tcg.g_exception_reason_save_const(list : taasmoutput; const href : treference; a: aword);
  1767. begin
  1768. a_load_const_ref(list, OS_S32, a, href);
  1769. end;
  1770. procedure tcg.g_exception_reason_load(list : taasmoutput; const href : treference);
  1771. begin
  1772. a_load_ref_reg(list, OS_S32, OS_S32, href, NR_FUNCTION_RETURN_REG);
  1773. end;
  1774. {*****************************************************************************
  1775. TCG64
  1776. *****************************************************************************}
  1777. procedure tcg64.a_op64_const_reg_reg(list: taasmoutput;op:TOpCG;value : qword; regsrc,regdst : tregister64);
  1778. begin
  1779. a_load64_reg_reg(list,regsrc,regdst);
  1780. a_op64_const_reg(list,op,value,regdst);
  1781. end;
  1782. procedure tcg64.a_op64_reg_reg_reg(list: taasmoutput;op:TOpCG;regsrc1,regsrc2,regdst : tregister64);
  1783. begin
  1784. a_load64_reg_reg(list,regsrc2,regdst);
  1785. a_op64_reg_reg(list,op,regsrc1,regdst);
  1786. end;
  1787. {****************************************************************************
  1788. TReference
  1789. ****************************************************************************}
  1790. procedure reference_release(list: taasmoutput; const ref : treference);
  1791. begin
  1792. cg.ungetreference(list,ref);
  1793. end;
  1794. {****************************************************************************
  1795. TLocation
  1796. ****************************************************************************}
  1797. procedure location_reset(var l : tlocation;lt:TCGLoc;lsize:TCGSize);
  1798. begin
  1799. FillChar(l,sizeof(tlocation),0);
  1800. l.loc:=lt;
  1801. l.size:=lsize;
  1802. {$ifdef arm}
  1803. if l.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
  1804. l.reference.signindex:=1;
  1805. {$endif arm}
  1806. end;
  1807. procedure location_release(list: taasmoutput; const l : tlocation);
  1808. begin
  1809. case l.loc of
  1810. LOC_REGISTER,LOC_CREGISTER :
  1811. begin
  1812. cg.ungetregister(list,l.register);
  1813. {$ifndef cpu64bit}
  1814. if l.size in [OS_64,OS_S64] then
  1815. cg.ungetregister(list,l.registerhigh);
  1816. {$endif cpu64bit}
  1817. end;
  1818. LOC_FPUREGISTER,LOC_CFPUREGISTER :
  1819. cg.ungetregister(list,l.register);
  1820. LOC_CREFERENCE,LOC_REFERENCE :
  1821. cg.ungetreference(list, l.reference);
  1822. end;
  1823. end;
  1824. procedure location_freetemp(list:taasmoutput; const l : tlocation);
  1825. begin
  1826. if (l.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
  1827. tg.ungetiftemp(list,l.reference);
  1828. end;
  1829. procedure location_copy(var destloc:tlocation; const sourceloc : tlocation);
  1830. begin
  1831. destloc:=sourceloc;
  1832. end;
  1833. procedure location_swap(var destloc,sourceloc : tlocation);
  1834. var
  1835. swapl : tlocation;
  1836. begin
  1837. swapl := destloc;
  1838. destloc := sourceloc;
  1839. sourceloc := swapl;
  1840. end;
  1841. initialization
  1842. ;
  1843. finalization
  1844. cg.free;
  1845. cg64.free;
  1846. end.
  1847. {
  1848. $Log$
  1849. Revision 1.164 2004-05-22 23:34:27 peter
  1850. tai_regalloc.allocation changed to ratype to notify rgobj of register size changes
  1851. Revision 1.163 2004/04/29 19:56:36 daniel
  1852. * Prepare compiler infrastructure for multiple ansistring types
  1853. Revision 1.162 2004/04/18 07:52:43 florian
  1854. * fixed web bug 3048: comparision of dyn. arrays
  1855. Revision 1.161 2004/03/06 20:35:19 florian
  1856. * fixed arm compilation
  1857. * cleaned up code generation for exported linux procedures
  1858. Revision 1.160 2004/03/02 00:36:33 olle
  1859. * big transformation of Tai_[const_]Symbol.Create[data]name*
  1860. Revision 1.159 2004/02/27 10:21:05 florian
  1861. * top_symbol killed
  1862. + refaddr to treference added
  1863. + refsymbol to treference added
  1864. * top_local stuff moved to an extra record to save memory
  1865. + aint introduced
  1866. * tppufile.get/putint64/aint implemented
  1867. Revision 1.158 2004/02/20 22:16:34 florian
  1868. * handling of float parameters passed in mm registers fixed
  1869. Revision 1.157 2004/02/12 15:54:03 peter
  1870. * make extcycle is working again
  1871. Revision 1.156 2004/02/08 18:08:59 jonas
  1872. * fixed regvars support. Needs -doldregvars to activate. Only tested with
  1873. ppc, other processors should however only require maxregvars and
  1874. maxfpuregvars constants in cpubase.pas. Remember to take scratch-
  1875. registers into account when defining that value.
  1876. Revision 1.155 2004/02/04 22:01:13 peter
  1877. * first try to get cpupara working for x86_64
  1878. Revision 1.154 2004/02/03 22:32:53 peter
  1879. * renamed xNNbittype to xNNinttype
  1880. * renamed registers32 to registersint
  1881. * replace some s32bit,u32bit with torddef([su]inttype).def.typ
  1882. Revision 1.153 2004/01/31 17:45:17 peter
  1883. * Change several $ifdef i386 to x86
  1884. * Change several OS_32 to OS_INT/OS_ADDR
  1885. Revision 1.152 2004/01/22 22:12:21 peter
  1886. * g_finalize needs to reset to nil after decr_ref
  1887. * support loadref in decr_ref reset to nil
  1888. Revision 1.151 2004/01/21 22:13:20 peter
  1889. * decrrefcount resets temps to nil
  1890. Revision 1.150 2004/01/21 21:01:34 peter
  1891. * fixed stackchecking for register calling
  1892. Revision 1.149 2004/01/20 12:59:36 florian
  1893. * common addnode code for x86-64 and i386
  1894. Revision 1.148 2004/01/12 22:11:38 peter
  1895. * use localalign info for alignment for locals and temps
  1896. * sparc fpu flags branching added
  1897. * moved powerpc copy_valye_openarray to generic
  1898. Revision 1.147 2004/01/11 23:56:19 daniel
  1899. * Experiment: Compress strings to save memory
  1900. Did not save a single byte of mem; clearly the core size is boosted by
  1901. temporary memory usage...
  1902. Revision 1.146 2003/12/26 14:02:30 peter
  1903. * sparc updates
  1904. * use registertype in spill_register
  1905. Revision 1.145 2003/12/26 13:19:16 florian
  1906. * rtl and compiler compile with -Cfsse2
  1907. Revision 1.144 2003/12/24 00:10:02 florian
  1908. - delete parameter in cg64 methods removed
  1909. Revision 1.143 2003/12/23 14:38:07 florian
  1910. + second_floataddsse implemented
  1911. Revision 1.142 2003/12/22 19:00:17 florian
  1912. * fixed some x86-64 issues
  1913. Revision 1.141 2003/12/21 19:42:42 florian
  1914. * fixed ppc inlining stuff
  1915. * fixed wrong unit writing
  1916. + added some sse stuff
  1917. Revision 1.140 2003/12/15 21:39:39 florian
  1918. * improved register allocation of generic a_param_const and a_param_ref
  1919. Revision 1.139 2003/12/15 21:25:48 peter
  1920. * reg allocations for imaginary register are now inserted just
  1921. before reg allocation
  1922. * tregister changed to enum to allow compile time check
  1923. * fixed several tregister-tsuperregister errors
  1924. Revision 1.138 2003/12/12 17:16:17 peter
  1925. * rg[tregistertype] added in tcg
  1926. Revision 1.137 2003/12/06 22:11:47 jonas
  1927. + allocate volatile registers around calls to procedures declared with
  1928. "saveregisters" on non-x86 processors
  1929. Revision 1.136 2003/12/06 01:15:22 florian
  1930. * reverted Peter's alloctemp patch; hopefully properly
  1931. Revision 1.135 2003/12/03 23:13:19 peter
  1932. * delayed paraloc allocation, a_param_*() gets extra parameter
  1933. if it needs to allocate temp or real paralocation
  1934. * optimized/simplified int-real loading
  1935. Revision 1.134 2003/11/05 23:05:13 florian
  1936. * elesize of g_copyvaluepara_openarray changed
  1937. + g_releaesvaluepara_openarray added
  1938. Revision 1.133 2003/10/19 01:34:30 florian
  1939. * some ppc stuff fixed
  1940. * memory leak fixed
  1941. Revision 1.132 2003/10/17 15:25:18 florian
  1942. * fixed more ppc stuff
  1943. Revision 1.131 2003/10/17 14:38:32 peter
  1944. * 64k registers supported
  1945. * fixed some memory leaks
  1946. Revision 1.130 2003/10/13 01:23:13 florian
  1947. * some ideas for mm support implemented
  1948. Revision 1.129 2003/10/11 16:06:42 florian
  1949. * fixed some MMX<->SSE
  1950. * started to fix ppc, needs an overhaul
  1951. + stabs info improve for spilling, not sure if it works correctly/completly
  1952. - MMX_SUPPORT removed from Makefile.fpc
  1953. Revision 1.128 2003/10/10 17:48:13 peter
  1954. * old trgobj moved to x86/rgcpu and renamed to trgx86fpu
  1955. * tregisteralloctor renamed to trgobj
  1956. * removed rgobj from a lot of units
  1957. * moved location_* and reference_* to cgobj
  1958. * first things for mmx register allocation
  1959. Revision 1.127 2003/10/09 21:31:37 daniel
  1960. * Register allocator splitted, ans abstract now
  1961. Revision 1.126 2003/10/01 20:34:48 peter
  1962. * procinfo unit contains tprocinfo
  1963. * cginfo renamed to cgbase
  1964. * moved cgmessage to verbose
  1965. * fixed ppc and sparc compiles
  1966. Revision 1.125 2003/09/28 17:55:03 peter
  1967. * parent framepointer changed to hidden parameter
  1968. * tloadparentfpnode added
  1969. Revision 1.124 2003/09/28 13:40:13 peter
  1970. * a_call_ref removed
  1971. Revision 1.123 2003/09/25 21:26:24 peter
  1972. * remove obsolete tparalocation.sp_fixup
  1973. Revision 1.122 2003/09/23 20:37:16 peter
  1974. * fpc_check_object(_ext) has saveregisters and doesn't need
  1975. saving of registers
  1976. Revision 1.121 2003/09/10 08:31:47 marco
  1977. * Patch from Peter for paraloc
  1978. Revision 1.120 2003/09/09 20:59:27 daniel
  1979. * Adding register allocation order
  1980. Revision 1.119 2003/09/07 22:09:34 peter
  1981. * preparations for different default calling conventions
  1982. * various RA fixes
  1983. Revision 1.118 2003/09/03 15:55:00 peter
  1984. * NEWRA branch merged
  1985. Revision 1.117 2003/09/03 11:18:36 florian
  1986. * fixed arm concatcopy
  1987. + arm support in the common compiler sources added
  1988. * moved some generic cg code around
  1989. + tfputype added
  1990. * ...
  1991. Revision 1.116.2.4 2003/08/29 17:28:59 peter
  1992. * next batch of updates
  1993. Revision 1.116.2.3 2003/08/28 18:35:07 peter
  1994. * tregister changed to cardinal
  1995. Revision 1.116.2.2 2003/08/27 20:23:55 peter
  1996. * remove old ra code
  1997. Revision 1.116.2.1 2003/08/27 19:55:54 peter
  1998. * first tregister patch
  1999. Revision 1.116 2003/08/17 16:59:20 jonas
  2000. * fixed regvars so they work with newra (at least for ppc)
  2001. * fixed some volatile register bugs
  2002. + -dnotranslation option for -dnewra, which causes the registers not to
  2003. be translated from virtual to normal registers. Requires support in
  2004. the assembler writer as well, which is only implemented in aggas/
  2005. agppcgas currently
  2006. Revision 1.115 2003/07/23 11:01:14 jonas
  2007. * several rg.allocexplicitregistersint/rg.deallocexplicitregistersint
  2008. pairs round calls to helpers
  2009. Revision 1.114 2003/07/06 17:58:22 peter
  2010. * framepointer fixes for sparc
  2011. * parent framepointer code more generic
  2012. Revision 1.113 2003/07/02 22:18:04 peter
  2013. * paraloc splitted in callerparaloc,calleeparaloc
  2014. * sparc calling convention updates
  2015. Revision 1.112 2003/06/13 21:19:30 peter
  2016. * current_procdef removed, use current_procinfo.procdef instead
  2017. Revision 1.111 2003/06/12 21:11:10 peter
  2018. * ungetregisterfpu gets size parameter
  2019. Revision 1.110 2003/06/12 16:43:07 peter
  2020. * newra compiles for sparc
  2021. Revision 1.109 2003/06/07 18:57:04 jonas
  2022. + added freeintparaloc
  2023. * ppc get/freeintparaloc now check whether the parameter regs are
  2024. properly allocated/deallocated (and get an extra list para)
  2025. * ppc a_call_* now internalerrors if pi_do_call is not yet set
  2026. * fixed lot of missing pi_do_call's
  2027. Revision 1.108 2003/06/06 14:43:02 peter
  2028. * g_copyopenarrayvalue gets length reference
  2029. * don't copy open arrays for cdecl
  2030. Revision 1.107 2003/06/03 21:11:09 peter
  2031. * cg.a_load_* get a from and to size specifier
  2032. * makeregsize only accepts newregister
  2033. * i386 uses generic tcgnotnode,tcgunaryminus
  2034. Revision 1.106 2003/06/03 13:01:59 daniel
  2035. * Register allocator finished
  2036. Revision 1.105 2003/06/01 21:38:06 peter
  2037. * getregisterfpu size parameter added
  2038. * op_const_reg size parameter added
  2039. * sparc updates
  2040. Revision 1.104 2003/06/01 01:02:39 peter
  2041. * generic a_call_ref
  2042. Revision 1.103 2003/05/30 23:57:08 peter
  2043. * more sparc cleanup
  2044. * accumulator removed, splitted in function_return_reg (called) and
  2045. function_result_reg (caller)
  2046. Revision 1.102 2003/05/30 23:49:18 jonas
  2047. * a_load_loc_reg now has an extra size parameter for the destination
  2048. register (properly fixes what I worked around in revision 1.106 of
  2049. ncgutil.pas)
  2050. Revision 1.101 2003/05/30 21:40:00 jonas
  2051. * fixed bug in a_load_loc_ref (the source instead of dest size was passed
  2052. to a_load_reg_ref in case of a register)
  2053. Revision 1.100 2003/05/30 12:36:13 jonas
  2054. * use as little different registers on the ppc until newra is released,
  2055. since every used register must be saved
  2056. Revision 1.99 2003/05/23 14:27:35 peter
  2057. * remove some unit dependencies
  2058. * current_procinfo changes to store more info
  2059. Revision 1.98 2003/05/15 18:58:53 peter
  2060. * removed selfpointer_offset, vmtpointer_offset
  2061. * tvarsym.adjusted_address
  2062. * address in localsymtable is now in the real direction
  2063. * removed some obsolete globals
  2064. Revision 1.97 2003/05/13 19:14:41 peter
  2065. * failn removed
  2066. * inherited result code check moven to pexpr
  2067. Revision 1.96 2003/05/11 21:37:03 peter
  2068. * moved implicit exception frame from ncgutil to psub
  2069. * constructor/destructor helpers moved from cobj/ncgutil to psub
  2070. Revision 1.95 2003/05/09 17:47:02 peter
  2071. * self moved to hidden parameter
  2072. * removed hdisposen,hnewn,selfn
  2073. Revision 1.94 2003/05/01 12:23:46 jonas
  2074. * fix for op_reg_reg_reg in case the destination is the same as the first
  2075. source register
  2076. Revision 1.93 2003/04/29 07:28:52 michael
  2077. + Patch from peter to fix wrong pushing of ansistring function results in open array
  2078. Revision 1.92 2003/04/27 11:21:32 peter
  2079. * aktprocdef renamed to current_procinfo.procdef
  2080. * procinfo renamed to current_procinfo
  2081. * procinfo will now be stored in current_module so it can be
  2082. cleaned up properly
  2083. * gen_main_procsym changed to create_main_proc and release_main_proc
  2084. to also generate a tprocinfo structure
  2085. * fixed unit implicit initfinal
  2086. Revision 1.91 2003/04/27 07:29:50 peter
  2087. * current_procinfo.procdef cleanup, current_procdef is now always nil when parsing
  2088. a new procdef declaration
  2089. * aktprocsym removed
  2090. * lexlevel removed, use symtable.symtablelevel instead
  2091. * implicit init/final code uses the normal genentry/genexit
  2092. * funcret state checking updated for new funcret handling
  2093. Revision 1.90 2003/04/26 20:57:17 florian
  2094. * fixed para locations of fpc_class_new helper call
  2095. Revision 1.89 2003/04/26 17:21:08 florian
  2096. * fixed passing of fpu values by fpu register
  2097. Revision 1.88 2003/04/23 20:16:03 peter
  2098. + added currency support based on int64
  2099. + is_64bit for use in cg units instead of is_64bitint
  2100. * removed cgmessage from n386add, replace with internalerrors
  2101. Revision 1.87 2003/04/23 14:42:07 daniel
  2102. * Further register allocator work. Compiler now smaller with new
  2103. allocator than without.
  2104. * Somebody forgot to adjust ppu version number
  2105. Revision 1.86 2003/04/23 13:20:34 peter
  2106. * fix self passing to fpc_help_fail
  2107. Revision 1.85 2003/04/23 12:35:34 florian
  2108. * fixed several issues with powerpc
  2109. + applied a patch from Jonas for nested function calls (PowerPC only)
  2110. * ...
  2111. Revision 1.84 2003/04/22 14:33:38 peter
  2112. * removed some notes/hints
  2113. Revision 1.83 2003/04/22 13:47:08 peter
  2114. * fixed C style array of const
  2115. * fixed C array passing
  2116. * fixed left to right with high parameters
  2117. Revision 1.82 2003/04/22 10:09:34 daniel
  2118. + Implemented the actual register allocator
  2119. + Scratch registers unavailable when new register allocator used
  2120. + maybe_save/maybe_restore unavailable when new register allocator used
  2121. Revision 1.81 2003/04/06 21:11:23 olle
  2122. * changed newasmsymbol to newasmsymboldata for data symbols
  2123. Revision 1.80 2003/03/28 19:16:56 peter
  2124. * generic constructor working for i386
  2125. * remove fixed self register
  2126. * esi added as address register for i386
  2127. Revision 1.79 2003/03/22 18:07:18 jonas
  2128. + add used scratch registers to usedintbyproc for non-i386
  2129. Revision 1.78 2003/03/11 21:46:24 jonas
  2130. * lots of new regallocator fixes, both in generic and ppc-specific code
  2131. (ppc compiler still can't compile the linux system unit though)
  2132. Revision 1.77 2003/02/19 22:00:14 daniel
  2133. * Code generator converted to new register notation
  2134. - Horribily outdated todo.txt removed
  2135. Revision 1.76 2003/01/31 22:47:48 peter
  2136. * maybe_testself now really uses the passed register
  2137. Revision 1.75 2003/01/30 21:46:35 peter
  2138. * maybe_testvmt added
  2139. Revision 1.74 2003/01/17 12:45:40 daniel
  2140. * Fixed internalerror 200301081 problem
  2141. Revision 1.73 2003/01/13 14:54:34 daniel
  2142. * Further work to convert codegenerator register convention;
  2143. internalerror bug fixed.
  2144. Revision 1.72 2003/01/09 22:00:53 florian
  2145. * fixed some PowerPC issues
  2146. Revision 1.71 2003/01/09 20:41:10 florian
  2147. * fixed broken PowerPC compiler
  2148. Revision 1.70 2003/01/08 18:43:56 daniel
  2149. * Tregister changed into a record
  2150. Revision 1.69 2002/12/24 15:56:50 peter
  2151. * stackpointer_alloc added for adjusting ESP. Win32 needs
  2152. this for the pageprotection
  2153. Revision 1.68 2002/12/20 18:14:04 peter
  2154. * removed some runerror and writeln
  2155. Revision 1.67 2002/12/14 15:02:03 carl
  2156. * maxoperands -> max_operands (for portability in rautils.pas)
  2157. * fix some range-check errors with loadconst
  2158. + add ncgadd unit to m68k
  2159. * some bugfix of a_param_reg with LOC_CREFERENCE
  2160. Revision 1.66 2002/11/25 17:43:16 peter
  2161. * splitted defbase in defutil,symutil,defcmp
  2162. * merged isconvertable and is_equal into compare_defs(_ext)
  2163. * made operator search faster by walking the list only once
  2164. Revision 1.65 2002/11/17 16:27:31 carl
  2165. * document flags2reg
  2166. Revision 1.64 2002/11/16 17:06:28 peter
  2167. * return error 210 for failed self test
  2168. Revision 1.63 2002/11/15 01:58:46 peter
  2169. * merged changes from 1.0.7 up to 04-11
  2170. - -V option for generating bug report tracing
  2171. - more tracing for option parsing
  2172. - errors for cdecl and high()
  2173. - win32 import stabs
  2174. - win32 records<=8 are returned in eax:edx (turned off by default)
  2175. - heaptrc update
  2176. - more info for temp management in .s file with EXTDEBUG
  2177. Revision 1.62 2002/10/16 19:01:43 peter
  2178. + $IMPLICITEXCEPTIONS switch to turn on/off generation of the
  2179. implicit exception frames for procedures with initialized variables
  2180. and for constructors. The default is on for compatibility
  2181. Revision 1.61 2002/10/05 12:43:23 carl
  2182. * fixes for Delphi 6 compilation
  2183. (warning : Some features do not work under Delphi)
  2184. Revision 1.60 2002/10/02 18:20:52 peter
  2185. * Copy() is now internal syssym that calls compilerprocs
  2186. Revision 1.59 2002/09/17 18:54:02 jonas
  2187. * a_load_reg_reg() now has two size parameters: source and dest. This
  2188. allows some optimizations on architectures that don't encode the
  2189. register size in the register name.
  2190. Revision 1.58 2002/09/09 19:29:29 peter
  2191. * fixed dynarr_decr_ref call
  2192. Revision 1.57 2002/09/07 15:25:01 peter
  2193. * old logs removed and tabs fixed
  2194. Revision 1.56 2002/09/01 21:04:47 florian
  2195. * several powerpc related stuff fixed
  2196. Revision 1.55 2002/09/01 17:05:43 florian
  2197. + added abstract tcg.g_removevaluepara_openarray
  2198. Revision 1.54 2002/09/01 12:09:27 peter
  2199. + a_call_reg, a_call_loc added
  2200. * removed exprasmlist references
  2201. Revision 1.53 2002/08/19 18:17:48 carl
  2202. + optimize64_op_const_reg implemented (optimizes 64-bit constant opcodes)
  2203. * more fixes to m68k for 64-bit operations
  2204. Revision 1.52 2002/08/17 22:09:43 florian
  2205. * result type handling in tcgcal.pass_2 overhauled
  2206. * better tnode.dowrite
  2207. * some ppc stuff fixed
  2208. Revision 1.51 2002/08/17 09:23:33 florian
  2209. * first part of procinfo rewrite
  2210. Revision 1.50 2002/08/16 14:24:57 carl
  2211. * issameref() to test if two references are the same (then emit no opcodes)
  2212. + ret_in_reg to replace ret_in_acc
  2213. (fix some register allocation bugs at the same time)
  2214. + save_std_register now has an extra parameter which is the
  2215. usedinproc registers
  2216. Revision 1.49 2002/08/15 08:13:54 carl
  2217. - a_load_sym_ofs_reg removed
  2218. * loadvmt now calls loadaddr_ref_reg instead
  2219. Revision 1.48 2002/08/14 19:26:02 carl
  2220. + routine to optimize opcodes with constants
  2221. Revision 1.47 2002/08/11 14:32:26 peter
  2222. * renamed current_library to objectlibrary
  2223. Revision 1.46 2002/08/11 13:24:11 peter
  2224. * saving of asmsymbols in ppu supported
  2225. * asmsymbollist global is removed and moved into a new class
  2226. tasmlibrarydata that will hold the info of a .a file which
  2227. corresponds with a single module. Added librarydata to tmodule
  2228. to keep the library info stored for the module. In the future the
  2229. objectfiles will also be stored to the tasmlibrarydata class
  2230. * all getlabel/newasmsymbol and friends are moved to the new class
  2231. Revision 1.45 2002/08/10 17:15:20 jonas
  2232. * register parameters are now LOC_CREGISTER instead of LOC_REGISTER
  2233. Revision 1.44 2002/08/09 19:10:05 carl
  2234. - moved new_exception and free_exception to ncgutils
  2235. Revision 1.43 2002/08/05 18:27:48 carl
  2236. + more more more documentation
  2237. + first version include/exclude (can't test though, not enough scratch for i386 :()...
  2238. Revision 1.42 2002/08/04 19:08:21 carl
  2239. + added generic exception support (still does not work!)
  2240. + more documentation
  2241. Revision 1.41 2002/07/30 20:50:43 florian
  2242. * the code generator knows now if parameters are in registers
  2243. Revision 1.40 2002/07/29 21:16:02 florian
  2244. * some more ppc fixes
  2245. Revision 1.39 2002/07/28 15:56:00 jonas
  2246. + tcg64.a_op64_const_reg_reg() and tcg64.a_op64_reg_reg_reg() methods +
  2247. generic implementation
  2248. Revision 1.38 2002/07/27 19:53:51 jonas
  2249. + generic implementation of tcg.g_flags2ref()
  2250. * tcg.flags2xxx() now also needs a size parameter
  2251. Revision 1.37 2002/07/20 11:57:53 florian
  2252. * types.pas renamed to defbase.pas because D6 contains a types
  2253. unit so this would conflicts if D6 programms are compiled
  2254. + Willamette/SSE2 instructions to assembler added
  2255. }