cgobj.pas 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 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. }
  23. unit cgobj;
  24. {$i defines.inc}
  25. interface
  26. uses
  27. cclasses,aasm,symtable,
  28. cpuasm,cpubase,cpuinfo,
  29. cginfo,
  30. symconst,symbase,symtype,node;
  31. type
  32. talignment = (AM_NATURAL,AM_NONE,AM_2BYTE,AM_4BYTE,AM_8BYTE);
  33. {# @abstract(Abstract code generator)
  34. This class implements an abstract instruction generator. Some of
  35. the methods of this class are generic, while others must
  36. be overriden for all new processors which will be supported
  37. by Free Pascal. For 32-bit processors, the base class
  38. sould be @link(tcg64f32) and not @var(tcg).
  39. }
  40. tcg = class
  41. scratch_register_array_pointer : aword;
  42. {# List of currently unused scratch registers }
  43. unusedscratchregisters : tregisterset;
  44. alignment : talignment;
  45. {************************************************}
  46. { basic routines }
  47. constructor create;
  48. {# Emit a label to the instruction stream. }
  49. procedure a_label(list : taasmoutput;l : tasmlabel);virtual;
  50. {# Allocates register r by inserting a pai_realloc record }
  51. procedure a_reg_alloc(list : taasmoutput;r : tregister);
  52. {# Deallocates register r by inserting a pa_regdealloc record}
  53. procedure a_reg_dealloc(list : taasmoutput;r : tregister);
  54. {# @abstract(Returns a register for use as scratch register)
  55. This routine returns a register which can be used by
  56. the code generator as a scratch register. Since
  57. scratch_registers are scarce resources, the register
  58. should be freed by calling @link(get_scratch_reg) as
  59. soon as it is no longer required.
  60. }
  61. function get_scratch_reg(list : taasmoutput) : tregister;
  62. {# @abstract(Releases a scratch register)
  63. Releases a scratch register.
  64. This routine is used to free a register which
  65. was previously allocated using @link(get_scratch_reg).
  66. }
  67. procedure free_scratch_reg(list : taasmoutput;r : tregister);
  68. {************************************************}
  69. { code generation for subroutine entry/exit code }
  70. { initilizes data of type t }
  71. { if is_already_ref is true then the routines assumes }
  72. { that r points to the data to initialize }
  73. procedure g_initialize(list : taasmoutput;t : tdef;const ref : treference;is_already_ref : boolean);
  74. { finalizes data of type t }
  75. { if is_already_ref is true then the routines assumes }
  76. { that r points to the data to finalizes }
  77. procedure g_finalize(list : taasmoutput;t : tdef;const ref : treference;is_already_ref : boolean);
  78. { helper routines }
  79. procedure g_initialize_data(list : taasmoutput;p : tsym);
  80. procedure g_incr_data(list : taasmoutput;p : tsym);
  81. procedure g_finalize_data(list : taasmoutput;p : tnamedindexitem);
  82. procedure g_copyvalueparas(list : taasmoutput;p : tnamedindexitem);
  83. procedure g_finalizetempansistrings(list : taasmoutput);
  84. procedure g_entrycode(alist : TAAsmoutput;make_global:boolean;
  85. stackframe:longint;
  86. var parasize:longint;var nostackframe:boolean;
  87. inlined : boolean);
  88. procedure g_exitcode(list : taasmoutput;parasize : longint;
  89. nostackframe,inlined : boolean);
  90. { string helper routines }
  91. procedure g_decrstrref(list : taasmoutput;const ref : treference;t : tdef);
  92. procedure g_removetemps(list : taasmoutput;p : tlinkedlist);
  93. { passing parameters, per default the parameter is pushed }
  94. { nr gives the number of the parameter (enumerated from }
  95. { left to right), this allows to move the parameter to }
  96. { register, if the cpu supports register calling }
  97. { conventions }
  98. {# Pass a parameter, which is located in a register, to a routine.
  99. This routine should push/send the parameter to the routine, as
  100. required by the specific processor ABI. This must be overriden for
  101. each CPU target.
  102. @param(size size of the operand in the register)
  103. @param(r register source of the operand)
  104. @param(nr parameter number (starting from one) of routine (from left to right))
  105. }
  106. procedure a_param_reg(list : taasmoutput;size : tcgsize;r : tregister;nr : longint);virtual; abstract;
  107. {# Pass a parameter, which is a constant, to a routine.
  108. A generic version is provided.
  109. @param(size size of the operand in constant)
  110. @param(a value of constant to send)
  111. @param(nr parameter number (starting from one) of routine (from left to right))
  112. }
  113. procedure a_param_const(list : taasmoutput;size : tcgsize;a : aword;nr : longint);virtual;
  114. {# Pass the value of a parameter, which is located in memory, to a routine.
  115. A generic version is provided.
  116. @param(size size of the operand in constant)
  117. @param(r Memory reference of value to send)
  118. @param(nr parameter number (starting from one) of routine (from left to right))
  119. }
  120. procedure a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;nr : longint);virtual;
  121. {# Pass the value of a parameter, which can be located either in a register or memory location,
  122. to a routine.
  123. A generic version is provided.
  124. @param(l location of the operand to send)
  125. @param(nr parameter number (starting from one) of routine (from left to right))
  126. }
  127. procedure a_param_loc(list : taasmoutput;const l : tlocation;nr : longint);
  128. {# Pass the address of a reference to a routine.
  129. A generic version is provided.
  130. @param(r reference to get address from)
  131. @param(nr parameter number (starting from one) of routine (from left to right))
  132. }
  133. procedure a_paramaddr_ref(list : taasmoutput;const r : treference;nr : longint);virtual;
  134. {**********************************}
  135. { these methods must be overriden: }
  136. { Remarks:
  137. * If a method specifies a size you have only to take care
  138. of that number of bits, i.e. load_const_reg with OP_8 must
  139. only load the lower 8 bit of the specified register
  140. the rest of the register can be undefined
  141. if necessary the compiler will call a method
  142. to zero or sign extend the register
  143. * The a_load_XX_XX with OP_64 needn't to be
  144. implemented for 32 bit
  145. processors, the code generator takes care of that
  146. * the addr size is for work with the natural pointer
  147. size
  148. * the procedures without fpu/mm are only for integer usage
  149. * normally the first location is the source and the
  150. second the destination
  151. }
  152. {# Emits instruction to call the method specified by symbol name @var(s) with offset
  153. to symbol in @var(offset). This routine must be overriden for each new target cpu.
  154. }
  155. procedure a_call_name(list : taasmoutput;const s : string;
  156. offset : longint);virtual; abstract;
  157. { move instructions }
  158. procedure a_load_const_reg(list : taasmoutput;size : tcgsize;a : aword;register : tregister);virtual; abstract;
  159. procedure a_load_const_ref(list : taasmoutput;size : tcgsize;a : aword;const ref : treference);virtual;
  160. procedure a_load_const_loc(list : taasmoutput;a : aword;const loc : tlocation);
  161. procedure a_load_reg_ref(list : taasmoutput;size : tcgsize;register : tregister;const ref : treference);virtual; abstract;
  162. procedure a_load_reg_reg(list : taasmoutput;size : tcgsize;reg1,reg2 : tregister);virtual; abstract;
  163. procedure a_load_reg_loc(list : taasmoutput;reg : tregister;const loc: tlocation);
  164. procedure a_load_ref_reg(list : taasmoutput;size : tcgsize;const ref : treference;register : tregister);virtual; abstract;
  165. procedure a_load_loc_reg(list : taasmoutput;const loc: tlocation; reg : tregister);
  166. procedure a_load_loc_ref(list : taasmoutput;const loc: tlocation; const ref : treference);
  167. procedure a_load_sym_ofs_reg(list: taasmoutput; const sym: tasmsymbol; ofs: longint; reg: tregister);virtual; abstract;
  168. { fpu move instructions }
  169. procedure a_loadfpu_reg_reg(list: taasmoutput; reg1, reg2: tregister); virtual; abstract;
  170. procedure a_loadfpu_ref_reg(list: taasmoutput; size: tcgsize; const ref: treference; reg: tregister); virtual; abstract;
  171. procedure a_loadfpu_reg_ref(list: taasmoutput; size: tcgsize; reg: tregister; const ref: treference); virtual; abstract;
  172. procedure a_loadfpu_loc_reg(list: taasmoutput; const loc: tlocation; const reg: tregister);
  173. procedure a_loadfpu_reg_loc(list: taasmoutput; size: tcgsize; const reg: tregister; const loc: tlocation);
  174. { vector register move instructions }
  175. procedure a_loadmm_reg_reg(list: taasmoutput; reg1, reg2: tregister); virtual; abstract;
  176. procedure a_loadmm_ref_reg(list: taasmoutput; const ref: treference; reg: tregister); virtual; abstract;
  177. procedure a_loadmm_reg_ref(list: taasmoutput; reg: tregister; const ref: treference); virtual; abstract;
  178. { basic arithmetic operations }
  179. { note: for operators which require only one argument (not, neg), use }
  180. { the op_reg_reg, op_reg_ref or op_reg_loc methods and keep in mind }
  181. { that in this case the *second* operand is used as both source and }
  182. { destination (JM) }
  183. procedure a_op_const_reg(list : taasmoutput; Op: TOpCG; a: AWord; reg: TRegister); virtual; abstract;
  184. procedure a_op_const_ref(list : taasmoutput; Op: TOpCG; size: TCGSize; a: AWord; const ref: TReference); virtual;
  185. procedure a_op_const_loc(list : taasmoutput; Op: TOpCG; a: AWord; const loc: tlocation);
  186. procedure a_op_reg_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; reg1, reg2: TRegister); virtual; abstract;
  187. procedure a_op_reg_ref(list : taasmoutput; Op: TOpCG; size: TCGSize; reg: TRegister; const ref: TReference); virtual;
  188. procedure a_op_ref_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; const ref: TReference; reg: TRegister); virtual;
  189. procedure a_op_reg_loc(list : taasmoutput; Op: TOpCG; reg: tregister; const loc: tlocation);
  190. procedure a_op_ref_loc(list : taasmoutput; Op: TOpCG; const ref: TReference; const loc: tlocation);
  191. { trinary operations for processors that support them, 'emulated' }
  192. { on others. None with "ref" arguments since I don't think there }
  193. { are any processors that support it (JM) }
  194. procedure a_op_const_reg_reg(list: taasmoutput; op: TOpCg;
  195. size: tcgsize; a: aword; src, dst: tregister); virtual;
  196. procedure a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
  197. size: tcgsize; src1, src2, dst: tregister); virtual;
  198. { comparison operations }
  199. procedure a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;reg : tregister;
  200. l : tasmlabel);virtual; abstract;
  201. procedure a_cmp_const_ref_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;const ref : treference;
  202. l : tasmlabel); virtual;
  203. procedure a_cmp_const_loc_label(list: taasmoutput; size: tcgsize;cmp_op: topcmp; a: aword; const loc: tlocation;
  204. l : tasmlabel);
  205. procedure a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel); virtual; abstract;
  206. procedure a_cmp_ref_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const ref: treference; reg : tregister; l : tasmlabel); virtual;
  207. procedure a_cmp_loc_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const loc: tlocation; reg : tregister; l : tasmlabel);
  208. procedure a_cmp_ref_loc_label(list: taasmoutput; size: tcgsize;cmp_op: topcmp; const ref: treference; const loc: tlocation;
  209. l : tasmlabel);
  210. procedure a_jmp_cond(list : taasmoutput;cond : TOpCmp;l: tasmlabel); virtual; abstract;
  211. procedure a_jmp_flags(list : taasmoutput;const f : TResFlags;l: tasmlabel); virtual; abstract;
  212. procedure g_flags2reg(list: taasmoutput; const f: tresflags; reg: TRegister); virtual; abstract;
  213. procedure a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);virtual; abstract;
  214. procedure g_stackframe_entry(list : taasmoutput;localsize : longint);virtual; abstract;
  215. { restores the frame pointer at procedure exit, for the }
  216. { i386 it generates a simple leave }
  217. procedure g_restore_frame_pointer(list : taasmoutput);virtual; abstract;
  218. { some processors like the PPC doesn't allow to change the stack in }
  219. { a procedure, so we need to maintain an extra stack for the }
  220. { result values of setjmp in exception code }
  221. { this two procedures are for pushing an exception value, }
  222. { they can use the scratch registers }
  223. procedure g_push_exception_value_reg(list : taasmoutput;reg : tregister);virtual; abstract;
  224. procedure g_push_exception_value_const(list : taasmoutput;reg : tregister);virtual; abstract;
  225. { that procedure pops a exception value }
  226. procedure g_pop_exception_value_reg(list : taasmoutput;reg : tregister);virtual; abstract;
  227. procedure g_return_from_proc(list : taasmoutput;parasize : aword);virtual; abstract;
  228. {********************************************************}
  229. { these methods can be overriden for extra functionality }
  230. {# Emits instructions which should be emitted when entering
  231. a routine declared as @var(interrupt). The default
  232. behavior does nothing, should be overriden as required.
  233. }
  234. procedure g_interrupt_stackframe_entry(list : taasmoutput);virtual;
  235. {# Emits instructions which should be emitted when exiting
  236. a routine declared as @var(interrupt). The default
  237. behavior does nothing, should be overriden as required.
  238. }
  239. procedure g_interrupt_stackframe_exit(list : taasmoutput);virtual;
  240. {# Emits instructions when compilation is done in profile
  241. mode (this is set as a command line option). The default
  242. behavior does nothing, should be overriden as required.
  243. }
  244. procedure g_profilecode(list : taasmoutput);virtual;
  245. {# Emits the call to the stack checking routine of
  246. the runtime library. The default behavior
  247. does not need to be modified, as it is generic
  248. for all platforms.
  249. }
  250. procedure g_stackcheck(list : taasmoutput;stackframesize : longint);virtual;
  251. procedure g_maybe_loadself(list : taasmoutput);virtual; abstract;
  252. {# This should emit the opcode to copy len bytes from the source
  253. to destination, if loadref is true, it assumes that it first must load
  254. the source address from the memory location where
  255. source points to.
  256. It must be overriden for each new target processor.
  257. @param(source Source reference of copy)
  258. @param(dest Destination reference of copy)
  259. @param(delsource Indicates if the source reference's resources should be freed)
  260. @param(loadref Is the source reference a pointer to the actual source (TRUE), is it the actual source address (FALSE))
  261. }
  262. procedure g_concatcopy(list : taasmoutput;const source,dest : treference;len : aword;delsource,loadref : boolean);virtual; abstract;
  263. {# Generates range checking code. It is to note
  264. that this routine does not need to be overriden,
  265. as it takes care of everything.
  266. @param(p Node which contains the value to check)
  267. @param(todef Type definition of node to range check)
  268. }
  269. procedure g_rangecheck(list: taasmoutput; const p: tnode;
  270. const todef: tdef); virtual;
  271. { generates overflow checking code for a node }
  272. procedure g_overflowcheck(list: taasmoutput; const p: tnode); virtual; abstract;
  273. { returns the tcgsize corresponding with the size of reg }
  274. class function reg_cgsize(const reg: tregister) : tcgsize; virtual;
  275. {$ifdef i386}
  276. { this one is only necessary due the the restrictions of the 80x86, }
  277. { so make it a special case (JM) }
  278. function makeregsize(var reg: tregister; size: tcgsize): topsize; virtual; abstract;
  279. {$endif i386}
  280. end;
  281. var
  282. cg : tcg; { this is the main code generator class }
  283. implementation
  284. uses
  285. globals,globtype,options,systems,cgbase,
  286. verbose,types,tgobj,symdef,cga,tainst,rgobj;
  287. const
  288. max_scratch_regs = high(scratch_regs) - low(scratch_regs) + 1;
  289. {*****************************************************************************
  290. basic functionallity
  291. ******************************************************************************}
  292. constructor tcg.create;
  293. var
  294. i : longint;
  295. begin
  296. scratch_register_array_pointer:=1;
  297. for i:=low(scratch_regs) to high(scratch_regs) do
  298. include(unusedscratchregisters,scratch_regs[i]);
  299. end;
  300. procedure tcg.a_reg_alloc(list : taasmoutput;r : tregister);
  301. begin
  302. list.concat(tairegalloc.alloc(r));
  303. end;
  304. procedure tcg.a_reg_dealloc(list : taasmoutput;r : tregister);
  305. begin
  306. list.concat(tairegalloc.dealloc(r));
  307. end;
  308. procedure tcg.a_label(list : taasmoutput;l : tasmlabel);
  309. begin
  310. list.concat(tai_label.create(l));
  311. end;
  312. function tcg.get_scratch_reg(list : taasmoutput) : tregister;
  313. var
  314. r : tregister;
  315. i : longint;
  316. begin
  317. if unusedscratchregisters=[] then
  318. internalerror(68996);
  319. for i:=scratch_register_array_pointer to
  320. (scratch_register_array_pointer+max_scratch_regs-1) do
  321. if scratch_regs[(i mod max_scratch_regs)+1] in unusedscratchregisters then
  322. begin
  323. r:=scratch_regs[(i mod max_scratch_regs)+1];
  324. break;
  325. end;
  326. exclude(unusedscratchregisters,r);
  327. inc(scratch_register_array_pointer);
  328. if scratch_register_array_pointer>max_scratch_regs then
  329. scratch_register_array_pointer:=1;
  330. a_reg_alloc(list,r);
  331. get_scratch_reg:=r;
  332. end;
  333. procedure tcg.free_scratch_reg(list : taasmoutput;r : tregister);
  334. begin
  335. {$ifdef i386}
  336. include(unusedscratchregisters,makereg32(r));
  337. {$else i386}
  338. include(unusedscratchregisters,r);
  339. {$endif i386}
  340. a_reg_dealloc(list,r);
  341. end;
  342. {*****************************************************************************
  343. this methods must be overridden for extra functionality
  344. ******************************************************************************}
  345. procedure tcg.g_interrupt_stackframe_entry(list : taasmoutput);
  346. begin
  347. end;
  348. procedure tcg.g_interrupt_stackframe_exit(list : taasmoutput);
  349. begin
  350. end;
  351. procedure tcg.g_profilecode(list : taasmoutput);
  352. begin
  353. end;
  354. {*****************************************************************************
  355. for better code generation these methods should be overridden
  356. ******************************************************************************}
  357. procedure tcg.a_param_const(list : taasmoutput;size : tcgsize;a : aword;nr : longint);
  358. var
  359. hr : tregister;
  360. begin
  361. hr:=get_scratch_reg(list);
  362. a_load_const_reg(list,size,a,hr);
  363. a_param_reg(list,size,hr,nr);
  364. free_scratch_reg(list,hr);
  365. end;
  366. procedure tcg.a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;nr : longint);
  367. var
  368. hr : tregister;
  369. begin
  370. hr:=get_scratch_reg(list);
  371. a_load_ref_reg(list,size,r,hr);
  372. a_param_reg(list,size,hr,nr);
  373. free_scratch_reg(list,hr);
  374. end;
  375. procedure tcg.a_param_loc(list : taasmoutput;const l:tlocation;nr : longint);
  376. begin
  377. case l.loc of
  378. LOC_REGISTER,
  379. LOC_CREGISTER :
  380. a_param_reg(list,l.size,l.register,nr);
  381. LOC_CONSTANT :
  382. a_param_const(list,l.size,l.value,nr);
  383. LOC_CREFERENCE,
  384. LOC_REFERENCE :
  385. a_param_ref(list,l.size,l.reference,nr);
  386. else
  387. internalerror(2002032211);
  388. end;
  389. end;
  390. procedure tcg.a_paramaddr_ref(list : taasmoutput;const r : treference;nr : longint);
  391. var
  392. hr : tregister;
  393. begin
  394. hr:=get_scratch_reg(list);
  395. a_loadaddr_ref_reg(list,r,hr);
  396. a_param_reg(list,OS_ADDR,hr,nr);
  397. free_scratch_reg(list,hr);
  398. end;
  399. procedure tcg.g_stackcheck(list : taasmoutput;stackframesize : longint);
  400. begin
  401. a_param_const(list,OS_32,stackframesize,1);
  402. a_call_name(list,'FPC_STACKCHECK',0);
  403. end;
  404. {*****************************************************************************
  405. String helper routines
  406. *****************************************************************************}
  407. procedure tcg.g_removetemps(list : taasmoutput;p : tlinkedlist);
  408. (*
  409. var
  410. hp : ptemptodestroy;
  411. pushedregs : tpushed;
  412. *)
  413. begin
  414. (*
  415. hp:=ptemptodestroy(p^.first);
  416. if not(assigned(hp)) then
  417. exit;
  418. tg.pushusedregisters(pushedregs,$ff);
  419. while assigned(hp) do
  420. begin
  421. if is_ansistring(hp^.typ) then
  422. begin
  423. g_decrstrref(list,hp^.address,hp^.typ);
  424. tg.ungetiftemp(hp^.address);
  425. end;
  426. hp:=ptemptodestroy(hp^.next);
  427. end;
  428. tg.popusedregisters(pushedregs);
  429. *)
  430. runerror(211);
  431. end;
  432. procedure tcg.g_decrstrref(list : taasmoutput;const ref : treference;t : tdef);
  433. { var
  434. pushedregs : tpushedsaved; }
  435. begin
  436. (*
  437. tg.pushusedregisters(pushedregs,$ff);
  438. a_param_ref_addr(list,ref,1);
  439. if is_ansistring(t) then
  440. a_call_name(list,'FPC_ANSISTR_DECR_REF',0)
  441. else if is_widestring(t) then
  442. a_call_name(list,'FPC_WIDESTR_DECR_REF',0)
  443. else internalerror(58993);
  444. tg.popusedregisters(pushedregs);
  445. *)
  446. runerror(211);
  447. end;
  448. {*****************************************************************************
  449. Code generation for subroutine entry- and exit code
  450. *****************************************************************************}
  451. { initilizes data of type t }
  452. { if is_already_ref is true then the routines assumes }
  453. { that r points to the data to initialize }
  454. procedure tcg.g_initialize(list : taasmoutput;t : tdef;const ref : treference;is_already_ref : boolean);
  455. { var
  456. hr : treference; }
  457. begin
  458. (*
  459. if is_ansistring(t) or
  460. is_widestring(t) then
  461. a_load_const_ref(list,OS_8,0,ref)
  462. else
  463. begin
  464. reset_reference(hr);
  465. hr.symbol:=t^.get_inittable_label;
  466. a_param_ref_addr(list,hr,2);
  467. if is_already_ref then
  468. a_param_ref(list,OS_ADDR,ref,1)
  469. else
  470. a_param_ref_addr(list,ref,1);
  471. a_call_name(list,'FPC_INITIALIZE',0);
  472. end;
  473. *)
  474. runerror(211);
  475. end;
  476. procedure tcg.g_finalize(list : taasmoutput;t : tdef;const ref : treference;is_already_ref : boolean);
  477. { var
  478. r : treference; }
  479. begin
  480. (*
  481. if is_ansistring(t) or
  482. is_widestring(t) then
  483. begin
  484. g_decrstrref(list,ref,t);
  485. end
  486. else
  487. begin
  488. reset_reference(r);
  489. r.symbol:=t^.get_inittable_label;
  490. a_param_ref_addr(list,r,2);
  491. if is_already_ref then
  492. a_paramaddr_ref(list,ref,1)
  493. else
  494. a_param_ref_addr(list,ref,1);
  495. a_call_name(list,'FPC_FINALIZE',0);
  496. end;
  497. *)
  498. runerror(211);
  499. end;
  500. { generates the code for initialisation of local data }
  501. procedure tcg.g_initialize_data(list : taasmoutput;p : tsym);
  502. { var
  503. hr : treference; }
  504. begin
  505. (*
  506. if (tsym(p)^.typ=varsym) and
  507. assigned(pvarsym(p)^.vartype.def) and
  508. not((pvarsym(p)^.vartype.def^.deftype=objectdef) and
  509. pobjectdef(pvarsym(p)^.vartype.def)^.is_class) and
  510. pvarsym(p)^.vartype.def^.needs_inittable then
  511. begin
  512. procinfo^.flags:=procinfo^.flags or pi_needs_implicit_finally;
  513. reset_reference(hr);
  514. if tsym(p)^.owner^.symtabletype=localsymtable then
  515. begin
  516. hr.base:=procinfo^.framepointer;
  517. hr.offset:=-pvarsym(p)^.address;
  518. end
  519. else
  520. begin
  521. hr.symbol:=newasmsymbol(pvarsym(p)^.mangledname);
  522. end;
  523. g_initialize(list,pvarsym(p)^.vartype.def,hr,false);
  524. end;
  525. *)
  526. runerror(211);
  527. end;
  528. { generates the code for incrementing the reference count of parameters }
  529. procedure tcg.g_incr_data(list : taasmoutput;p : tsym);
  530. { var
  531. hr : treference; }
  532. begin
  533. (*
  534. if (tsym(p)^.typ=varsym) and
  535. not((pvarsym(p)^.vartype.def^.deftype=objectdef) and
  536. pobjectdef(pvarsym(p)^.vartype.def)^.is_class) and
  537. pvarsym(p)^.vartype.def^.needs_inittable and
  538. ((pvarsym(p)^.varspez=vs_value)) then
  539. begin
  540. procinfo^.flags:=procinfo^.flags or pi_needs_implicit_finally;
  541. reset_reference(hr);
  542. hr.symbol:=pvarsym(p)^.vartype.def^.get_inittable_label;
  543. a_param_ref_addr(list,hr,2);
  544. reset_reference(hr);
  545. hr.base:=procinfo^.framepointer;
  546. hr.offset:=pvarsym(p)^.address+procinfo^.para_offset;
  547. a_param_ref_addr(list,hr,1);
  548. reset_reference(hr);
  549. a_call_name(list,'FPC_ADDREF',0);
  550. end;
  551. *)
  552. runerror(211);
  553. end;
  554. { generates the code for finalisation of local data }
  555. procedure tcg.g_finalize_data(list : taasmoutput;p : tnamedindexitem);
  556. { var
  557. hr : treference; }
  558. begin
  559. (*
  560. if (tsym(p)^.typ=varsym) and
  561. assigned(pvarsym(p)^.vartype.def) and
  562. not((pvarsym(p)^.vartype.def^.deftype=objectdef) and
  563. pobjectdef(pvarsym(p)^.vartype.def)^.is_class) and
  564. pvarsym(p)^.vartype.def^.needs_inittable then
  565. begin
  566. { not all kind of parameters need to be finalized }
  567. if (tsym(p)^.owner^.symtabletype=parasymtable) and
  568. ((pvarsym(p)^.varspez=vs_var) or
  569. (pvarsym(p)^.varspez=vs_const) { and
  570. (dont_copy_const_param(pvarsym(p)^.definition)) } ) then
  571. exit;
  572. procinfo^.flags:=procinfo^.flags or pi_needs_implicit_finally;
  573. reset_reference(hr);
  574. case tsym(p)^.owner^.symtabletype of
  575. localsymtable:
  576. begin
  577. hr.base:=procinfo^.framepointer;
  578. hr.offset:=-pvarsym(p)^.address;
  579. end;
  580. parasymtable:
  581. begin
  582. hr.base:=procinfo^.framepointer;
  583. hr.offset:=pvarsym(p)^.address+procinfo^.para_offset;
  584. end;
  585. else
  586. hr.symbol:=newasmsymbol(pvarsym(p)^.mangledname);
  587. end;
  588. g_finalize(list,pvarsym(p)^.vartype.def,hr,false);
  589. end;
  590. *)
  591. runerror(211);
  592. end;
  593. { generates the code to make local copies of the value parameters }
  594. procedure tcg.g_copyvalueparas(list : taasmoutput;p : tnamedindexitem);
  595. begin
  596. runerror(255);
  597. end;
  598. (*
  599. var
  600. _list : taasmoutput;
  601. { wrappers for the methods, because TP doesn't know procedures }
  602. { of objects }
  603. procedure _copyvalueparas(s : tnamedindexitem);{$ifndef FPC}far;{$endif}
  604. begin
  605. cg^.g_copyvalueparas(_list,s);
  606. end;
  607. *)
  608. procedure tcg.g_finalizetempansistrings(list : taasmoutput);
  609. (*
  610. var
  611. hp : ptemprecord;
  612. hr : treference;
  613. *)
  614. begin
  615. (*
  616. hp:=tg.templist;
  617. while assigned(hp) do
  618. begin
  619. if hp^.temptype in [tt_ansistring,tt_freeansistring] then
  620. begin
  621. procinfo^.flags:=procinfo^.flags or pi_needs_implicit_finally;
  622. reset_reference(hr);
  623. hr.base:=procinfo^.framepointer;
  624. hr.offset:=hp^.pos;
  625. a_param_ref_addr(list,hr,1);
  626. a_call_name(list,'FPC_ANSISTR_DECR_REF',0);
  627. end;
  628. hp:=hp^.next;
  629. end;
  630. *)
  631. runerror(211);
  632. end;
  633. (*
  634. procedure _finalize_data(s : tnamedindexitem);{$ifndef FPC}far;{$endif}
  635. begin
  636. cg^.g_finalize_data(_list,s);
  637. end;
  638. procedure _incr_data(s : tnamedindexitem);{$ifndef FPC}far;{$endif}
  639. begin
  640. cg^.g_incr_data(_list,tsym(s));
  641. end;
  642. procedure _initialize_data(s : tnamedindexitem);{$ifndef FPC}far;{$endif}
  643. begin
  644. cg^.g_initialize_data(_list,tsym(s));
  645. end;
  646. *)
  647. { generates the entry code for a procedure }
  648. procedure tcg.g_entrycode(alist : TAAsmoutput;make_global:boolean;
  649. stackframe:longint;
  650. var parasize:longint;var nostackframe:boolean;
  651. inlined : boolean);
  652. (*
  653. var
  654. hs : string;
  655. hp : pused_unit;
  656. initcode : taasmoutput;
  657. {$ifdef GDB}
  658. stab_function_name : Pai_stab_function_name;
  659. {$endif GDB}
  660. hr : treference;
  661. r : tregister;
  662. *)
  663. begin
  664. (*
  665. { Align }
  666. if (not inlined) then
  667. begin
  668. { gprof uses 16 byte granularity !! }
  669. if (cs_profile in aktmoduleswitches) then
  670. list^.insert(new(pai_align,init(16)))
  671. else
  672. if not(cs_littlesize in aktglobalswitches) then
  673. list^.insert(new(pai_align,init(4)));
  674. end;
  675. { save registers on cdecl }
  676. if (po_savestdregs in aktprocsym^.definition^.procoptions) then
  677. begin
  678. for r:=firstreg to lastreg do
  679. begin
  680. if (r in registers_saved_on_cdecl) then
  681. if (r in (tg.availabletempregsint+
  682. tg.availabletempregsfpu+
  683. tg.availabletempregsmm)) then
  684. begin
  685. if not(r in tg.usedinproc) then
  686. {!!!!!!!!!!!! a_push_reg(list,r) }
  687. end
  688. else
  689. {!!!!!!!! a_push_reg(list,r) };
  690. end;
  691. end;
  692. { omit stack frame ? }
  693. if not inlined then
  694. if procinfo^.framepointer=stack_pointer then
  695. begin
  696. CGMessage(cg_d_stackframe_omited);
  697. nostackframe:=true;
  698. if (aktprocsym^.definition^.proctypeoption in [potype_unitinit,potype_proginit,potype_unitfinalize]) then
  699. parasize:=0
  700. else
  701. parasize:=aktprocsym^.definition^.parast^.datasize+procinfo^.para_offset-pointersize;
  702. end
  703. else
  704. begin
  705. if (aktprocsym^.definition^.proctypeoption in [potype_unitinit,potype_proginit,potype_unitfinalize]) then
  706. parasize:=0
  707. else
  708. parasize:=aktprocsym^.definition^.parast^.datasize+procinfo^.para_offset-pointersize*2;
  709. nostackframe:=false;
  710. if (po_interrupt in aktprocsym^.definition^.procoptions) then
  711. g_interrupt_stackframe_entry(list);
  712. g_stackframe_entry(list,stackframe);
  713. if (cs_check_stack in aktlocalswitches) and
  714. (tf_supports_stack_checking in target_info.flags) then
  715. g_stackcheck(@initcode,stackframe);
  716. end;
  717. if cs_profile in aktmoduleswitches then
  718. g_profilecode(@initcode);
  719. if (not inlined) and (aktprocsym^.definition^.proctypeoption in [potype_unitinit]) then
  720. begin
  721. { needs the target a console flags ? }
  722. if tf_needs_isconsole in target_info.flags then
  723. begin
  724. hr.symbol:=newasmsymbol('U_'+target_info.system_unit+'_ISCONSOLE');
  725. if apptype=at_cui then
  726. a_load_const_ref(list,OS_8,1,hr)
  727. else
  728. a_load_const_ref(list,OS_8,0,hr);
  729. dispose(hr.symbol,done);
  730. end;
  731. hp:=pused_unit(usedunits.first);
  732. while assigned(hp) do
  733. begin
  734. { call the unit init code and make it external }
  735. if (hp^.u^.flags and uf_init)<>0 then
  736. a_call_name(list,
  737. 'INIT$$'+hp^.u^.modulename^,0);
  738. hp:=Pused_unit(hp^.next);
  739. end;
  740. end;
  741. {$ifdef dummy}
  742. { a constructor needs a help procedure }
  743. if (aktprocsym^.definition^.options and poconstructor)<>0 then
  744. begin
  745. if procinfo^._class^.isclass then
  746. begin
  747. list^.concat(new(paicpu,op_sym(A_CALL,S_NO,newasmsymbol('FPC_NEW_CLASS'))));
  748. list^.concat(new(paicpu,op_cond_sym(A_Jcc,C_Z,S_NO,quickexitlabel)));
  749. end
  750. else
  751. begin
  752. {
  753. list^.insert(new(pai_labeled,init(A_JZ,quickexitlabel)));
  754. list^.insert(new(paicpu,op_csymbol(A_CALL,S_NO,
  755. newcsymbol('FPC_HELP_CONSTRUCTOR',0))));
  756. list^.insert(new(paicpu,op_const_reg(A_MOV,S_L,procinfo^._class^.vmt_offset,R_EDI)));
  757. concat_external('FPC_HELP_CONSTRUCTOR',EXT_NEAR);
  758. }
  759. end;
  760. end;
  761. {$endif dummy}
  762. {$ifdef GDB}
  763. if (cs_debuginfo in aktmoduleswitches) then
  764. list^.insert(new(pai_force_line,init));
  765. {$endif GDB}
  766. { initialize return value }
  767. if assigned(procinfo^.returntype.def) and
  768. is_ansistring(procinfo^.returntype.def) or
  769. is_widestring(procinfo^.returntype.def) then
  770. begin
  771. reset_reference(hr);
  772. hr.offset:=procinfo^.return_offset;
  773. hr.base:=procinfo^.framepointer;
  774. a_load_const_ref(list,OS_32,0,hr);
  775. end;
  776. _list:=list;
  777. { generate copies of call by value parameters }
  778. if (po_assembler in aktprocsym^.definition^.procoptions) then
  779. aktprocsym^.definition^.parast^.foreach({$ifdef FPCPROCVAR}@{$endif}_copyvalueparas);
  780. { initialisizes local data }
  781. aktprocsym^.definition^.localst^.foreach({$ifdef FPCPROCVAR}@{$endif}_initialize_data);
  782. { add a reference to all call by value/const parameters }
  783. aktprocsym^.definition^.parast^.foreach({$ifdef FPCPROCVAR}@{$endif}_incr_data);
  784. if (cs_profile in aktmoduleswitches) or
  785. (aktprocsym^.definition^.owner^.symtabletype=globalsymtable) or
  786. (assigned(procinfo^._class) and (procinfo^._class^.owner^.symtabletype=globalsymtable)) then
  787. make_global:=true;
  788. if not inlined then
  789. begin
  790. hs:=proc_names.get;
  791. {$ifdef GDB}
  792. if (cs_debuginfo in aktmoduleswitches) and target_os.use_function_relative_addresses then
  793. stab_function_name := new(pai_stab_function_name,init(strpnew(hs)));
  794. {$endif GDB}
  795. { insert the names for the procedure }
  796. while hs<>'' do
  797. begin
  798. if make_global then
  799. exprasmlist^.insert(new(pai_symbol,initname_global(hs,0)))
  800. else
  801. exprasmlist^.insert(new(pai_symbol,initname(hs,0)));
  802. {$ifdef GDB}
  803. if (cs_debuginfo in aktmoduleswitches) then
  804. begin
  805. if target_os.use_function_relative_addresses then
  806. list^.insert(new(pai_stab_function_name,init(strpnew(hs))));
  807. end;
  808. {$endif GDB}
  809. hs:=proc_names.get;
  810. end;
  811. end;
  812. {$ifdef GDB}
  813. if (not inlined) and (cs_debuginfo in aktmoduleswitches) then
  814. begin
  815. if target_os.use_function_relative_addresses then
  816. list^.insert(stab_function_name);
  817. if make_global or ((procinfo^.flags and pi_is_global) <> 0) then
  818. aktprocsym^.is_global := True;
  819. list^.insert(new(pai_stabs,init(aktprocsym^.stabstring)));
  820. aktprocsym^.isstabwritten:=true;
  821. end;
  822. {$endif GDB}
  823. *)
  824. runerror(211);
  825. end;
  826. procedure tcg.g_exitcode(list : taasmoutput;parasize:longint;nostackframe,inlined:boolean);
  827. (*
  828. var
  829. {$ifdef GDB}
  830. mangled_length : longint;
  831. p : pchar;
  832. {$endif GDB}
  833. nofinal,noreraiselabel : tasmlabel;
  834. hr : treference;
  835. r : tregister;
  836. *)
  837. begin
  838. (*
  839. if aktexitlabel^.is_used then
  840. list^.insert(new(pai_label,init(aktexitlabel)));
  841. { call the destructor help procedure }
  842. if (aktprocsym^.definition^.proctypeoption=potype_destructor) then
  843. begin
  844. if procinfo^._class^.is_class then
  845. a_call_name(list,'FPC_DISPOSE_CLASS',0)
  846. else
  847. begin
  848. if procinfo^._class^.needs_inittable then
  849. begin
  850. getlabel(nofinal);
  851. {!!!!!!!!!!
  852. reset_reference(hr);
  853. hr.base:=R_EBP;
  854. hr.offset:=8;
  855. a_cmp_reg_const_label(list,OS_ADDR,OZ_EQ,
  856. }
  857. reset_reference(hr);
  858. hr.symbol:=procinfo^._class^.get_inittable_label;
  859. a_paramaddr_ref(list,hr,2);
  860. a_param_reg(list,OS_ADDR,self_pointer,1);
  861. a_call_name(list,'FPC_FINALIZE',0);
  862. a_label(list,nofinal);
  863. end;
  864. { vmt_offset_reg can be a scratch register, }
  865. { but it must be always the same }
  866. a_reg_alloc(list,vmt_offset_reg);
  867. a_load_const_reg(list,OS_32,procinfo^._class^.vmt_offset,vmt_offset_reg);
  868. a_call_name(list,'FPC_HELP_DESTRUCTOR',0);
  869. a_reg_dealloc(list,vmt_offset_reg);
  870. end;
  871. end;
  872. { finalize temporary data }
  873. g_finalizetempansistrings(list);
  874. _list:=list;
  875. { finalize local data }
  876. aktprocsym^.definition^.localst^.foreach({$ifdef FPCPROCVAR}@{$endif}_finalize_data);
  877. { finalize paras data }
  878. if assigned(aktprocsym^.definition^.parast) then
  879. aktprocsym^.definition^.parast^.foreach({$ifdef FPCPROCVAR}@{$endif}_finalize_data);
  880. { do we need to handle exceptions because of ansi/widestrings ? }
  881. if (procinfo^.flags and pi_needs_implicit_finally)<>0 then
  882. begin
  883. getlabel(noreraiselabel);
  884. a_call_name(list,'FPC_POPADDRSTACK',0);
  885. a_reg_alloc(list,accumulator);
  886. g_pop_exception_value_reg(list,accumulator);
  887. a_cmp_const_reg_label(list,OS_32,OC_EQ,0,accumulator,noreraiselabel);
  888. a_reg_dealloc(list,accumulator);
  889. { must be the return value finalized before reraising the exception? }
  890. if (procinfo^.returntype.def<>tdef(voiddef)) and
  891. (procinfo^.returntype.def^.needs_inittable) and
  892. ((procinfo^.returntype.def^.deftype<>objectdef) or
  893. not(pobjectdef(procinfo^.returntype.def)^.is_class)) then
  894. begin
  895. reset_reference(hr);
  896. hr.offset:=procinfo^.return_offset;
  897. hr.base:=procinfo^.framepointer;
  898. g_finalize(list,procinfo^.returntype.def,hr,ret_in_param(procinfo^.returntype.def));
  899. end;
  900. a_call_name(list,'FPC_RERAISE',0);
  901. a_label(list,noreraiselabel);
  902. end;
  903. { call __EXIT for main program }
  904. if (not DLLsource) and (not inlined) and (aktprocsym^.definition^.proctypeoption=potype_proginit) then
  905. a_call_name(list,'FPC_DO_EXIT',0);
  906. { handle return value }
  907. if not(po_assembler in aktprocsym^.definition^.procoptions) then
  908. if (aktprocsym^.definition^.proctypeoption<>potype_constructor) then
  909. { handle_return_value(inlined) }
  910. else
  911. begin
  912. { return self in EAX }
  913. a_label(list,quickexitlabel);
  914. a_reg_alloc(list,accumulator);
  915. a_load_reg_reg(list,OS_ADDR,self_pointer,accumulator);
  916. a_reg_dealloc(list,self_pointer);
  917. a_label(list,quickexitlabel);
  918. { we can't clear the zero flag because the Alpha }
  919. { for example doesn't have flags, we have to compare }
  920. { the accu. in the caller }
  921. end;
  922. { stabs uses the label also ! }
  923. if aktexit2label^.is_used or
  924. ((cs_debuginfo in aktmoduleswitches) and not inlined) then
  925. a_label(list,aktexit2label);
  926. {$ifdef dummy}
  927. { should we restore edi ? }
  928. { for all i386 gcc implementations }
  929. {!!!!!!!!!!! I don't know how to handle register saving yet }
  930. if (po_savestdregs in aktprocsym^.definition^.procoptions) then
  931. begin
  932. if (aktprocsym^.definition^.usedregisters and ($80 shr byte(R_EBX)))<>0 then
  933. exprasmlist^.concat(new(paicpu,op_reg(A_POP,S_L,R_EBX)));
  934. exprasmlist^.concat(new(paicpu,op_reg(A_POP,S_L,R_ESI)));
  935. exprasmlist^.concat(new(paicpu,op_reg(A_POP,S_L,R_EDI)));
  936. { here we could reset R_EBX
  937. but that is risky because it only works
  938. if genexitcode is called after genentrycode
  939. so lets skip this for the moment PM
  940. aktprocsym^.definition^.usedregisters:=
  941. aktprocsym^.definition^.usedregisters or not ($80 shr byte(R_EBX));
  942. }
  943. end;
  944. {$endif dummy}
  945. if not(nostackframe) and not inlined then
  946. g_restore_frame_pointer(list);
  947. { at last, the return is generated }
  948. if not inlined then
  949. if po_interrupt in aktprocsym^.definition^.procoptions then
  950. g_interrupt_stackframe_exit(list)
  951. else
  952. g_return_from_proc(list,parasize);
  953. list^.concat(new(pai_symbol_end,initname(aktprocsym^.definition^.mangledname)));
  954. {$ifdef GDB}
  955. if (cs_debuginfo in aktmoduleswitches) and not inlined then
  956. begin
  957. aktprocsym^.concatstabto(list);
  958. if assigned(procinfo^._class) then
  959. if (not assigned(procinfo^.parent) or
  960. not assigned(procinfo^.parent^._class)) then
  961. list^.concat(new(pai_stabs,init(strpnew(
  962. '"$t:v'+procinfo^._class^.numberstring+'",'+
  963. tostr(N_PSYM)+',0,0,'+tostr(procinfo^.selfpointer_offset)))));
  964. {!!!!!!!!!!!!
  965. else
  966. list^.concat(new(pai_stabs,init(strpnew(
  967. '"$t:r'+procinfo^._class^.numberstring+'",'+
  968. tostr(N_RSYM)+',0,0,'+tostr(GDB_i386index[R_ESI])))));
  969. }
  970. if (tdef(aktprocsym^.definition^.rettype.def) <> tdef(voiddef)) then
  971. begin
  972. if ret_in_param(aktprocsym^.definition^.rettype.def) then
  973. list^.concat(new(pai_stabs,init(strpnew(
  974. '"'+aktprocsym^.name+':X*'+aktprocsym^.definition^.rettype.def^.numberstring+'",'+
  975. tostr(N_PSYM)+',0,0,'+tostr(procinfo^.return_offset)))))
  976. else
  977. list^.concat(new(pai_stabs,init(strpnew(
  978. '"'+aktprocsym^.name+':X'+aktprocsym^.definition^.rettype.def^.numberstring+'",'+
  979. tostr(N_PSYM)+',0,0,'+tostr(procinfo^.return_offset)))));
  980. if (m_result in aktmodeswitches) then
  981. if ret_in_param(aktprocsym^.definition^.rettype.def) then
  982. list^.concat(new(pai_stabs,init(strpnew(
  983. '"RESULT:X*'+aktprocsym^.definition^.rettype.def^.numberstring+'",'+
  984. tostr(N_PSYM)+',0,0,'+tostr(procinfo^.return_offset)))))
  985. else
  986. list^.concat(new(pai_stabs,init(strpnew(
  987. '"RESULT:X'+aktprocsym^.definition^.rettype.def^.numberstring+'",'+
  988. tostr(N_PSYM)+',0,0,'+tostr(procinfo^.return_offset)))));
  989. end;
  990. mangled_length:=length(aktprocsym^.definition^.mangledname);
  991. getmem(p,mangled_length+50);
  992. strpcopy(p,'192,0,0,');
  993. strpcopy(strend(p),aktprocsym^.definition^.mangledname);
  994. list^.concat(new(pai_stabn,init(strnew(p))));
  995. {list^.concat(new(pai_stabn,init(strpnew('192,0,0,'
  996. +aktprocsym^.definition^.mangledname))));
  997. p[0]:='2';p[1]:='2';p[2]:='4';
  998. strpcopy(strend(p),'_end');}
  999. freemem(p,mangled_length+50);
  1000. list^.concat(new(pai_stabn,init(
  1001. strpnew('224,0,0,'+aktexit2label^.name))));
  1002. { strpnew('224,0,0,'
  1003. +aktprocsym^.definition^.mangledname+'_end'))));}
  1004. end;
  1005. {$endif GDB}
  1006. *)
  1007. runerror(211);
  1008. end;
  1009. {*****************************************************************************
  1010. some generic implementations
  1011. ****************************************************************************}
  1012. procedure tcg.a_load_const_ref(list : taasmoutput;size : tcgsize;a : aword;const ref : treference);
  1013. var
  1014. tmpreg: tregister;
  1015. begin
  1016. tmpreg := get_scratch_reg(list);
  1017. a_load_const_reg(list,size,a,tmpreg);
  1018. a_load_reg_ref(list,size,tmpreg,ref);
  1019. free_scratch_reg(list,tmpreg);
  1020. end;
  1021. procedure tcg.a_load_loc_reg(list : taasmoutput;const loc: tlocation; reg : tregister);
  1022. begin
  1023. case loc.loc of
  1024. LOC_REFERENCE,LOC_CREFERENCE:
  1025. a_load_ref_reg(list,loc.size,loc.reference,reg);
  1026. LOC_REGISTER,LOC_CREGISTER:
  1027. a_load_reg_reg(list,loc.size,loc.register,reg);
  1028. LOC_CONSTANT:
  1029. a_load_const_reg(list,loc.size,loc.value,reg);
  1030. else
  1031. internalerror(200109092);
  1032. end;
  1033. end;
  1034. procedure tcg.a_load_const_loc(list : taasmoutput;a : aword;const loc: tlocation);
  1035. begin
  1036. case loc.loc of
  1037. LOC_REFERENCE,LOC_CREFERENCE:
  1038. a_load_const_ref(list,loc.size,a,loc.reference);
  1039. LOC_REGISTER,LOC_CREGISTER:
  1040. a_load_const_reg(list,loc.size,a,loc.register);
  1041. else
  1042. internalerror(200203272);
  1043. end;
  1044. end;
  1045. procedure tcg.a_load_reg_loc(list : taasmoutput;reg : tregister;const loc: tlocation);
  1046. begin
  1047. case loc.loc of
  1048. LOC_REFERENCE,LOC_CREFERENCE:
  1049. a_load_reg_ref(list,loc.size,reg,loc.reference);
  1050. LOC_REGISTER,LOC_CREGISTER:
  1051. a_load_reg_reg(list,loc.size,reg,loc.register);
  1052. else
  1053. internalerror(200203271);
  1054. end;
  1055. end;
  1056. procedure tcg.a_load_loc_ref(list : taasmoutput;const loc: tlocation; const ref : treference);
  1057. var
  1058. tmpreg: tregister;
  1059. begin
  1060. case loc.loc of
  1061. LOC_REFERENCE,LOC_CREFERENCE:
  1062. begin
  1063. {$ifdef i386}
  1064. case loc.size of
  1065. OS_8,OS_S8:
  1066. tmpreg := reg32toreg8(rg.getregisterint(exprasmlist));
  1067. OS_16,OS_S16:
  1068. tmpreg := reg32toreg16(get_scratch_reg(list));
  1069. else
  1070. tmpreg := get_scratch_reg(list);
  1071. end;
  1072. {$else i386}
  1073. tmpreg := get_scratch_reg(list);
  1074. {$endif i386}
  1075. a_load_ref_reg(list,loc.size,loc.reference,tmpreg);
  1076. a_load_reg_ref(list,loc.size,tmpreg,ref);
  1077. {$ifdef i386}
  1078. if not (loc.size in [OS_32,OS_S32]) then
  1079. rg.ungetregister(exprasmlist,tmpreg)
  1080. else
  1081. {$endif i386}
  1082. free_scratch_reg(list,tmpreg);
  1083. end;
  1084. LOC_REGISTER,LOC_CREGISTER:
  1085. a_load_reg_ref(list,loc.size,loc.register,ref);
  1086. LOC_CONSTANT:
  1087. a_load_const_ref(list,loc.size,loc.value,ref);
  1088. else
  1089. internalerror(200109302);
  1090. end;
  1091. end;
  1092. procedure tcg.a_loadfpu_loc_reg(list: taasmoutput; const loc: tlocation; const reg: tregister);
  1093. begin
  1094. case loc.loc of
  1095. LOC_REFERENCE, LOC_CREFERENCE:
  1096. a_loadfpu_ref_reg(list,loc.size,loc.reference,reg);
  1097. LOC_FPUREGISTER, LOC_CFPUREGISTER:
  1098. a_loadfpu_reg_reg(list,loc.register,reg);
  1099. else
  1100. internalerror(200203301);
  1101. end;
  1102. end;
  1103. procedure tcg.a_loadfpu_reg_loc(list: taasmoutput; size: tcgsize; const reg: tregister; const loc: tlocation);
  1104. begin
  1105. case loc.loc of
  1106. LOC_REFERENCE, LOC_CREFERENCE:
  1107. a_loadfpu_reg_ref(list,size,reg,loc.reference);
  1108. LOC_FPUREGISTER, LOC_CFPUREGISTER:
  1109. a_loadfpu_reg_reg(list,reg,loc.register);
  1110. else
  1111. internalerror(48991);
  1112. end;
  1113. end;
  1114. procedure tcg.a_op_const_ref(list : taasmoutput; Op: TOpCG; size: TCGSize; a: AWord; const ref: TReference);
  1115. var
  1116. tmpreg: tregister;
  1117. begin
  1118. tmpreg := get_scratch_reg(list);
  1119. a_load_ref_reg(list,size,ref,tmpreg);
  1120. a_op_const_reg(list,op,a,tmpreg);
  1121. a_load_reg_ref(list,size,tmpreg,ref);
  1122. free_scratch_reg(list,tmpreg);
  1123. end;
  1124. procedure tcg.a_op_const_loc(list : taasmoutput; Op: TOpCG; a: AWord; const loc: tlocation);
  1125. begin
  1126. case loc.loc of
  1127. LOC_REGISTER, LOC_CREGISTER:
  1128. a_op_const_reg(list,op,a,loc.register);
  1129. LOC_REFERENCE, LOC_CREFERENCE:
  1130. a_op_const_ref(list,op,loc.size,a,loc.reference);
  1131. else
  1132. internalerror(200109061);
  1133. end;
  1134. end;
  1135. procedure tcg.a_op_reg_ref(list : taasmoutput; Op: TOpCG; size: TCGSize;reg: TRegister; const ref: TReference);
  1136. var
  1137. tmpreg: tregister;
  1138. begin
  1139. tmpreg := get_scratch_reg(list);
  1140. a_load_ref_reg(list,size,ref,tmpreg);
  1141. a_op_reg_reg(list,op,size,reg,tmpreg);
  1142. a_load_reg_ref(list,size,tmpreg,ref);
  1143. free_scratch_reg(list,tmpreg);
  1144. end;
  1145. procedure tcg.a_op_ref_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; const ref: TReference; reg: TRegister);
  1146. var
  1147. tmpreg: tregister;
  1148. begin
  1149. case op of
  1150. OP_NOT,OP_NEG:
  1151. { handle it as "load ref,reg; op reg" }
  1152. begin
  1153. a_load_ref_reg(list,size,ref,reg);
  1154. a_op_reg_reg(list,op,size,reg,reg);
  1155. end;
  1156. else
  1157. begin
  1158. tmpreg := get_scratch_reg(list);
  1159. a_load_ref_reg(list,size,ref,tmpreg);
  1160. a_op_reg_reg(list,op,size,tmpreg,reg);
  1161. free_scratch_reg(list,tmpreg);
  1162. end;
  1163. end;
  1164. end;
  1165. procedure tcg.a_op_reg_loc(list : taasmoutput; Op: TOpCG; reg: tregister; const loc: tlocation);
  1166. begin
  1167. case loc.loc of
  1168. LOC_REGISTER, LOC_CREGISTER:
  1169. a_op_reg_reg(list,op,loc.size,reg,loc.register);
  1170. LOC_REFERENCE, LOC_CREFERENCE:
  1171. a_op_reg_ref(list,op,loc.size,reg,loc.reference);
  1172. else
  1173. internalerror(200109061);
  1174. end;
  1175. end;
  1176. procedure tcg.a_op_ref_loc(list : taasmoutput; Op: TOpCG; const ref: TReference; const loc: tlocation);
  1177. var
  1178. tmpreg: tregister;
  1179. begin
  1180. case loc.loc of
  1181. LOC_REGISTER,LOC_CREGISTER:
  1182. a_op_ref_reg(list,op,loc.size,ref,loc.register);
  1183. LOC_REFERENCE,LOC_CREFERENCE:
  1184. begin
  1185. tmpreg := get_scratch_reg(list);
  1186. {$ifdef i386}
  1187. makeregsize(tmpreg,loc.size);
  1188. {$endif i386}
  1189. a_load_ref_reg(list,loc.size,ref,tmpreg);
  1190. a_op_reg_ref(list,op,loc.size,tmpreg,loc.reference);
  1191. free_scratch_reg(list,tmpreg);
  1192. end;
  1193. else
  1194. internalerror(200109061);
  1195. end;
  1196. end;
  1197. procedure tcg.a_op_const_reg_reg(list: taasmoutput; op: TOpCg;
  1198. size: tcgsize; a: aword; src, dst: tregister);
  1199. begin
  1200. a_load_reg_reg(list,size,src,dst);
  1201. a_op_const_reg(list,op,a,dst);
  1202. end;
  1203. procedure tcg.a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
  1204. size: tcgsize; src1, src2, dst: tregister);
  1205. begin
  1206. a_load_reg_reg(list,size,src2,dst);
  1207. a_op_reg_reg(list,op,size,src1,dst);
  1208. end;
  1209. procedure tcg.a_cmp_const_ref_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;const ref : treference;
  1210. l : tasmlabel);
  1211. var
  1212. tmpreg: tregister;
  1213. begin
  1214. tmpreg := get_scratch_reg(list);
  1215. a_load_ref_reg(list,size,ref,tmpreg);
  1216. a_cmp_const_reg_label(list,size,cmp_op,a,tmpreg,l);
  1217. free_scratch_reg(list,tmpreg);
  1218. end;
  1219. procedure tcg.a_cmp_const_loc_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;const loc : tlocation;
  1220. l : tasmlabel);
  1221. begin
  1222. case loc.loc of
  1223. LOC_REGISTER,LOC_CREGISTER:
  1224. a_cmp_const_reg_label(list,size,cmp_op,a,loc.register,l);
  1225. LOC_REFERENCE,LOC_CREFERENCE:
  1226. a_cmp_const_ref_label(list,size,cmp_op,a,loc.reference,l);
  1227. else
  1228. internalerror(200109061);
  1229. end;
  1230. end;
  1231. procedure tcg.a_cmp_ref_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const ref: treference; reg : tregister; l : tasmlabel);
  1232. var
  1233. tmpreg: tregister;
  1234. begin
  1235. tmpreg := get_scratch_reg(list);
  1236. a_load_ref_reg(list,size,ref,tmpreg);
  1237. a_cmp_reg_reg_label(list,size,cmp_op,tmpreg,reg,l);
  1238. free_scratch_reg(list,tmpreg);
  1239. end;
  1240. procedure tcg.a_cmp_loc_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const loc: tlocation; reg : tregister; l : tasmlabel);
  1241. begin
  1242. case loc.loc of
  1243. LOC_REGISTER,
  1244. LOC_CREGISTER:
  1245. a_cmp_reg_reg_label(list,size,cmp_op,loc.register,reg,l);
  1246. LOC_REFERENCE,
  1247. LOC_CREFERENCE :
  1248. a_cmp_ref_reg_label(list,size,cmp_op,loc.reference,reg,l);
  1249. LOC_CONSTANT:
  1250. a_cmp_const_reg_label(list,size,cmp_op,loc.value,reg,l);
  1251. else
  1252. internalerror(200203231);
  1253. end;
  1254. end;
  1255. procedure tcg.a_cmp_ref_loc_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;const ref: treference;const loc : tlocation;
  1256. l : tasmlabel);
  1257. var
  1258. tmpreg: tregister;
  1259. begin
  1260. case loc.loc of
  1261. LOC_REGISTER,LOC_CREGISTER:
  1262. a_cmp_ref_reg_label(list,size,cmp_op,ref,loc.register,l);
  1263. LOC_REFERENCE,LOC_CREFERENCE:
  1264. begin
  1265. {$ifdef i386}
  1266. { the following is done with defines to avoid a speed penalty, }
  1267. { since all this is only necessary for the 80x86 (because EDI }
  1268. { doesn't have an 8bit component which is directly addressable) }
  1269. if size in [OS_8,OS_S8] then
  1270. tmpreg := rg.getregisterint(exprasmlist)
  1271. else
  1272. {$endif i386}
  1273. tmpreg := get_scratch_reg(list);
  1274. {$ifdef i386}
  1275. makeregsize(tmpreg,size);
  1276. {$endif i386}
  1277. a_load_ref_reg(list,size,loc.reference,tmpreg);
  1278. a_cmp_ref_reg_label(list,size,cmp_op,ref,tmpreg,l);
  1279. {$ifdef i386}
  1280. if makereg32(tmpreg) <> R_EDI then
  1281. rg.ungetregister(exprasmlist,tmpreg)
  1282. else
  1283. {$endif i386}
  1284. free_scratch_reg(list,tmpreg);
  1285. end
  1286. else
  1287. internalerror(200109061);
  1288. end;
  1289. end;
  1290. procedure tcg.g_rangecheck(list: taasmoutput; const p: tnode;
  1291. const todef: tdef);
  1292. { generate range checking code for the value at location p. The type }
  1293. { type used is checked against todefs ranges. fromdef (p.resulttype.def) }
  1294. { is the original type used at that location. When both defs are equal }
  1295. { the check is also insert (needed for succ,pref,inc,dec) }
  1296. const
  1297. {$ifdef ver1_0}
  1298. awordsignedmax=high(longint);
  1299. {$else}
  1300. awordsignedmax=high(aword) div 2;
  1301. {$endif}
  1302. var
  1303. neglabel : tasmlabel;
  1304. hreg : tregister;
  1305. fromdef : tdef;
  1306. lto,hto,
  1307. lfrom,hfrom : TConstExprInt;
  1308. from_signed: boolean;
  1309. begin
  1310. { range checking on and range checkable value? }
  1311. if not(cs_check_range in aktlocalswitches) or
  1312. not(todef.deftype in [orddef,enumdef,arraydef]) then
  1313. exit;
  1314. { only check when assigning to scalar, subranges are different, }
  1315. { when todef=fromdef then the check is always generated }
  1316. fromdef:=p.resulttype.def;
  1317. getrange(p.resulttype.def,lfrom,hfrom);
  1318. getrange(todef,lto,hto);
  1319. { no range check if from and to are equal and are both longint/dword }
  1320. { (if we have a 32bit processor) or int64/qword, since such }
  1321. { operations can at most cause overflows (JM) }
  1322. { Note that these checks are mostly processor independent, they only }
  1323. { have to be changed once we introduce 64bit subrange types }
  1324. if (fromdef = todef) and
  1325. { then fromdef and todef can only be orddefs }
  1326. (((sizeof(aword) = 4) and
  1327. (((torddef(fromdef).typ = s32bit) and
  1328. (lfrom = low(longint)) and
  1329. (hfrom = high(longint))) or
  1330. ((torddef(fromdef).typ = u32bit) and
  1331. (lfrom = low(cardinal)) and
  1332. (hfrom = high(cardinal))))) or
  1333. is_64bitint(fromdef)) then
  1334. exit;
  1335. if todef<>fromdef then
  1336. begin
  1337. { if the from-range falls completely in the to-range, no check }
  1338. { is necessary }
  1339. if (lto<=lfrom) and (hto>=hfrom) then
  1340. exit;
  1341. end;
  1342. { generate the rangecheck code for the def where we are going to }
  1343. { store the result }
  1344. { use the trick that }
  1345. { a <= x <= b <=> 0 <= x-a <= b-a <=> cardinal(x-a) <= cardinal(b-a) }
  1346. { To be able to do that, we have to make sure however that either }
  1347. { fromdef and todef are both signed or unsigned, or that we leave }
  1348. { the parts < 0 and > maxlongint out }
  1349. { is_signed now also works for arrays (it checks the rangetype) (JM) }
  1350. from_signed := is_signed(fromdef);
  1351. if from_signed xor is_signed(todef) then
  1352. if from_signed then
  1353. { from is signed, to is unsigned }
  1354. begin
  1355. { if high(from) < 0 -> always range error }
  1356. if (hfrom < 0) or
  1357. { if low(to) > maxlongint also range error }
  1358. (lto > awordsignedmax) then
  1359. begin
  1360. a_call_name(list,'FPC_RANGEERROR',0);
  1361. exit
  1362. end;
  1363. { from is signed and to is unsigned -> when looking at from }
  1364. { as an unsigned value, it must be < maxlongint (otherwise }
  1365. { it's negative, which is invalid since "to" is unsigned) }
  1366. if hto > awordsignedmax then
  1367. hto := awordsignedmax;
  1368. end
  1369. else
  1370. { from is unsigned, to is signed }
  1371. begin
  1372. if (lfrom > awordsignedmax) or
  1373. (hto < 0) then
  1374. begin
  1375. a_call_name(list,'FPC_RANGEERROR',0);
  1376. exit
  1377. end;
  1378. { from is unsigned and to is signed -> when looking at to }
  1379. { as an unsigned value, it must be >= 0 (since negative }
  1380. { values are the same as values > maxlongint) }
  1381. if lto < 0 then
  1382. lto := 0;
  1383. end;
  1384. hreg := get_scratch_reg(list);
  1385. if (p.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
  1386. a_op_const_reg_reg(list,OP_SUB,def_cgsize(p.resulttype.def),
  1387. aword(longint(lto and $ffffffff)),p.location.register,hreg)
  1388. else
  1389. begin
  1390. a_load_ref_reg(list,def_cgsize(p.resulttype.def),
  1391. p.location.reference,hreg);
  1392. a_op_const_reg(list,OP_SUB,aword(longint(lto and $ffffffff)),hreg);
  1393. end;
  1394. getlabel(neglabel);
  1395. a_cmp_const_reg_label(list,OS_INT,OC_BE,aword(longint((hto-lto) and $ffffffff)),hreg,neglabel);
  1396. { !!! should happen right after the compare (JM) }
  1397. free_scratch_reg(list,hreg);
  1398. a_call_name(list,'FPC_RANGEERROR',0);
  1399. a_label(list,neglabel);
  1400. end;
  1401. function tcg.reg_cgsize(const reg: tregister) : tcgsize;
  1402. begin
  1403. reg_cgsize := OS_INT;
  1404. end;
  1405. finalization
  1406. cg.free;
  1407. end.
  1408. {
  1409. $Log$
  1410. Revision 1.13 2002-04-07 13:22:11 carl
  1411. + more documentation
  1412. Revision 1.12 2002/04/07 09:12:46 carl
  1413. + documentation
  1414. Revision 1.11 2002/04/06 18:10:42 jonas
  1415. * several powerpc-related additions and fixes
  1416. Revision 1.10 2002/04/04 19:05:54 peter
  1417. * removed unused units
  1418. * use tlocation.size in cg.a_*loc*() routines
  1419. Revision 1.9 2002/04/02 17:11:27 peter
  1420. * tlocation,treference update
  1421. * LOC_CONSTANT added for better constant handling
  1422. * secondadd splitted in multiple routines
  1423. * location_force_reg added for loading a location to a register
  1424. of a specified size
  1425. * secondassignment parses now first the right and then the left node
  1426. (this is compatible with Kylix). This saves a lot of push/pop especially
  1427. with string operations
  1428. * adapted some routines to use the new cg methods
  1429. Revision 1.8 2002/03/31 20:26:33 jonas
  1430. + a_loadfpu_* and a_loadmm_* methods in tcg
  1431. * register allocation is now handled by a class and is mostly processor
  1432. independent (+rgobj.pas and i386/rgcpu.pas)
  1433. * temp allocation is now handled by a class (+tgobj.pas, -i386\tgcpu.pas)
  1434. * some small improvements and fixes to the optimizer
  1435. * some register allocation fixes
  1436. * some fpuvaroffset fixes in the unary minus node
  1437. * push/popusedregisters is now called rg.save/restoreusedregisters and
  1438. (for i386) uses temps instead of push/pop's when using -Op3 (that code is
  1439. also better optimizable)
  1440. * fixed and optimized register saving/restoring for new/dispose nodes
  1441. * LOC_FPU locations now also require their "register" field to be set to
  1442. R_ST, not R_ST0 (the latter is used for LOC_CFPUREGISTER locations only)
  1443. - list field removed of the tnode class because it's not used currently
  1444. and can cause hard-to-find bugs
  1445. Revision 1.7 2002/03/04 19:10:11 peter
  1446. * removed compiler warnings
  1447. Revision 1.6 2001/12/30 17:24:48 jonas
  1448. * range checking is now processor independent (part in cgobj,
  1449. part in cg64f32) and should work correctly again (it needed
  1450. some changes after the changes of the low and high of
  1451. tordef's to int64)
  1452. * maketojumpbool() is now processor independent (in ncgutil)
  1453. * getregister32 is now called getregisterint
  1454. Revision 1.5 2001/12/29 15:28:58 jonas
  1455. * powerpc/cgcpu.pas compiles :)
  1456. * several powerpc-related fixes
  1457. * cpuasm unit is now based on common tainst unit
  1458. + nppcmat unit for powerpc (almost complete)
  1459. Revision 1.4 2001/09/30 21:26:42 peter
  1460. * removed obsolete newst defines
  1461. Revision 1.3 2001/09/30 16:17:17 jonas
  1462. * made most constant and mem handling processor independent
  1463. Revision 1.2 2001/09/28 20:39:32 jonas
  1464. * changed all flow control structures (except for exception handling
  1465. related things) to processor independent code (in new ncgflw unit)
  1466. + generic cgobj unit which contains lots of code generator helpers with
  1467. global "cg" class instance variable
  1468. + cgcpu unit for i386 (implements processor specific routines of the above
  1469. unit)
  1470. * updated cgbase and cpubase for the new code generator units
  1471. * include ncgflw unit in cpunode unit
  1472. Revision 1.5 2001/09/09 17:10:26 jonas
  1473. * some more things implemented
  1474. Revision 1.4 2001/09/06 15:25:55 jonas
  1475. * changed type of tcg from object to class -> abstract methods are now
  1476. a lot cleaner :)
  1477. + more updates: load_*_loc methods, op_*_* methods, g_flags2reg method
  1478. (if possible with geenric implementation and necessary ppc
  1479. implementations)
  1480. * worked a bit further on cgflw, now working on exitnode
  1481. Revision 1.3 2001/09/05 20:21:03 jonas
  1482. * new cgflow based on n386flw with all nodes until forn "translated"
  1483. + a_cmp_loc_*_label methods for tcg
  1484. + base implementatino for a_cmp_ref_*_label methods
  1485. * small bugfixes to powerpc cg
  1486. Revision 1.2 2001/08/26 13:37:04 florian
  1487. * some cg reorganisation
  1488. * some PPC updates
  1489. Revision 1.1 2000/07/13 06:30:07 michael
  1490. + Initial import
  1491. }