cgobj.pas 67 KB

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