cgobj.pas 104 KB

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