ncgcal.pas 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Generate i386 assembler for in call nodes
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit ncgcal;
  19. {$i fpcdefs.inc}
  20. interface
  21. { $define AnsiStrRef}
  22. uses
  23. cpubase,
  24. globtype,
  25. symdef,node,ncal;
  26. type
  27. tcgcallparanode = class(tcallparanode)
  28. private
  29. tempparaloc : tparalocation;
  30. public
  31. procedure secondcallparan(push_from_left_to_right:boolean;calloption:tproccalloption;
  32. para_alignment,para_offset : longint);override;
  33. end;
  34. tcgcallnode = class(tcallnode)
  35. private
  36. procedure release_para_temps;
  37. procedure normal_pass_2;
  38. procedure inlined_pass_2;
  39. protected
  40. refcountedtemp : treference;
  41. procedure handle_return_value;
  42. {# This routine is used to push the current frame pointer
  43. on the stack. This is used in nested routines where the
  44. value of the frame pointer is always pushed as an extra
  45. parameter.
  46. The default handling is the standard handling used on
  47. most stack based machines, where the frame pointer is
  48. the first invisible parameter.
  49. }
  50. function align_parasize:longint;virtual;
  51. procedure pop_parasize(pop_size:longint);virtual;
  52. procedure push_framepointer;virtual;
  53. procedure free_pushed_framepointer;virtual;
  54. procedure extra_interrupt_code;virtual;
  55. public
  56. procedure pass_2;override;
  57. end;
  58. implementation
  59. uses
  60. systems,
  61. cutils,verbose,globals,
  62. symconst,symbase,symsym,symtable,defutil,paramgr,
  63. {$ifdef GDB}
  64. {$ifdef delphi}
  65. sysutils,
  66. {$else}
  67. strings,
  68. {$endif}
  69. gdb,
  70. {$endif GDB}
  71. cginfo,cgbase,pass_2,
  72. cpuinfo,aasmbase,aasmtai,aasmcpu,
  73. nbas,nmem,nld,ncnv,
  74. {$ifdef x86}
  75. cga,
  76. {$endif x86}
  77. {$ifdef cpu64bit}
  78. cg64f64,
  79. {$else cpu64bit}
  80. cg64f32,
  81. {$endif cpu64bit}
  82. ncgutil,cgobj,tgobj,regvars,rgobj,rgcpu;
  83. {*****************************************************************************
  84. TCGCALLPARANODE
  85. *****************************************************************************}
  86. procedure tcgcallparanode.secondcallparan(push_from_left_to_right:boolean;calloption:tproccalloption;para_alignment,para_offset : longint);
  87. var
  88. otlabel,
  89. oflabel : tasmlabel;
  90. tmpreg : tregister;
  91. href : treference;
  92. begin
  93. if not(assigned(paraitem.paratype.def) or
  94. assigned(paraitem.parasym)) then
  95. internalerror(200304242);
  96. { set default para_alignment to target_info.stackalignment }
  97. if para_alignment=0 then
  98. para_alignment:=aktalignment.paraalign;
  99. { push from left to right if specified }
  100. if push_from_left_to_right and assigned(right) then
  101. begin
  102. tcallparanode(right).secondcallparan(push_from_left_to_right,
  103. calloption,para_alignment,para_offset);
  104. end;
  105. otlabel:=truelabel;
  106. oflabel:=falselabel;
  107. objectlibrary.getlabel(truelabel);
  108. objectlibrary.getlabel(falselabel);
  109. secondpass(left);
  110. { Allocate (temporary) paralocation }
  111. {$ifdef usetempparaloc}
  112. tempparaloc:=paraitem.paraloc[callerside];
  113. if tempparaloc.loc=LOC_REGISTER then
  114. paramanager.alloctempregs(exprasmlist,tempparaloc)
  115. else
  116. paramanager.allocparaloc(exprasmlist,tempparaloc);
  117. {$else}
  118. tempparaloc:=paraitem.paraloc[callerside];
  119. paramanager.allocparaloc(exprasmlist,tempparaloc);
  120. {$endif usetempparaloc}
  121. { handle varargs first, because defcoll is not valid }
  122. if (nf_varargs_para in flags) then
  123. begin
  124. if paramanager.push_addr_param(left.resulttype.def,calloption) then
  125. begin
  126. inc(pushedparasize,POINTER_SIZE);
  127. cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
  128. location_release(exprasmlist,left.location);
  129. end
  130. else
  131. push_value_para(exprasmlist,left,calloption,para_offset,para_alignment,tempparaloc);
  132. end
  133. { hidden parameters }
  134. else if paraitem.is_hidden then
  135. begin
  136. { don't push a node that already generated a pointer type
  137. by address for implicit hidden parameters }
  138. if (vo_is_funcret in tvarsym(paraitem.parasym).varoptions) or
  139. (not(left.resulttype.def.deftype in [pointerdef,classrefdef]) and
  140. paramanager.push_addr_param(paraitem.paratype.def,calloption)) then
  141. begin
  142. if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
  143. internalerror(200305071);
  144. inc(pushedparasize,POINTER_SIZE);
  145. if calloption=pocall_inline then
  146. begin
  147. tmpreg:=rg.getaddressregister(exprasmlist);
  148. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  149. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  150. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
  151. rg.ungetregisterint(exprasmlist,tmpreg);
  152. end
  153. else
  154. cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
  155. location_release(exprasmlist,left.location);
  156. end
  157. else
  158. begin
  159. push_value_para(exprasmlist,left,calloption,
  160. para_offset,para_alignment,tempparaloc);
  161. end;
  162. end
  163. { filter array of const c styled args }
  164. else if is_array_of_const(left.resulttype.def) and (nf_cargs in left.flags) then
  165. begin
  166. { nothing, everything is already pushed }
  167. end
  168. { in codegen.handleread.. paraitem.data is set to nil }
  169. else if assigned(paraitem.paratype.def) and
  170. (paraitem.paratype.def.deftype=formaldef) then
  171. begin
  172. { allow passing of a constant to a const formaldef }
  173. if (tvarsym(paraitem.parasym).varspez=vs_const) and
  174. (left.location.loc=LOC_CONSTANT) then
  175. location_force_mem(exprasmlist,left.location);
  176. { allow @var }
  177. inc(pushedparasize,POINTER_SIZE);
  178. if (left.nodetype=addrn) and
  179. (not(nf_procvarload in left.flags)) then
  180. begin
  181. if calloption=pocall_inline then
  182. begin
  183. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  184. cg.a_load_loc_ref(exprasmlist,OS_ADDR,left.location,href);
  185. end
  186. else
  187. cg.a_param_loc(exprasmlist,left.location,tempparaloc);
  188. location_release(exprasmlist,left.location);
  189. end
  190. else
  191. begin
  192. if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
  193. internalerror(200304235);
  194. if calloption=pocall_inline then
  195. begin
  196. tmpreg:=rg.getaddressregister(exprasmlist);
  197. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  198. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  199. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
  200. rg.ungetregisterint(exprasmlist,tmpreg);
  201. end
  202. else
  203. cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
  204. location_release(exprasmlist,left.location);
  205. end;
  206. end
  207. { handle call by reference parameter }
  208. else if (paraitem.paratyp in [vs_var,vs_out]) then
  209. begin
  210. if (left.location.loc<>LOC_REFERENCE) then
  211. begin
  212. { passing self to a var parameter is allowed in
  213. TP and delphi }
  214. if not((left.location.loc=LOC_CREFERENCE) and
  215. is_self_node(left)) then
  216. internalerror(200106041);
  217. end;
  218. if (paraitem.paratyp=vs_out) and
  219. assigned(paraitem.paratype.def) and
  220. not is_class(paraitem.paratype.def) and
  221. paraitem.paratype.def.needs_inittable then
  222. cg.g_finalize(exprasmlist,paraitem.paratype.def,left.location.reference,false);
  223. inc(pushedparasize,POINTER_SIZE);
  224. if calloption=pocall_inline then
  225. begin
  226. tmpreg:=rg.getaddressregister(exprasmlist);
  227. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  228. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  229. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
  230. rg.ungetregisterint(exprasmlist,tmpreg);
  231. end
  232. else
  233. cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
  234. location_release(exprasmlist,left.location);
  235. end
  236. else
  237. begin
  238. { don't push a node that already generated a pointer type
  239. by address for implicit hidden parameters }
  240. if (not(
  241. paraitem.is_hidden and
  242. (left.resulttype.def.deftype in [pointerdef,classrefdef])
  243. ) and
  244. paramanager.push_addr_param(paraitem.paratype.def,calloption)) then
  245. begin
  246. if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
  247. begin
  248. { allow passing nil to a procvardef (methodpointer) }
  249. if (left.nodetype=typeconvn) and
  250. (left.resulttype.def.deftype=procvardef) and
  251. (ttypeconvnode(left).left.nodetype=niln) then
  252. begin
  253. tg.GetTemp(exprasmlist,tcgsize2size[left.location.size],tt_normal,href);
  254. if not (left.location.size in [OS_64,OS_S64]) then
  255. cg.a_load_loc_ref(exprasmlist,left.location.size,left.location,href)
  256. else
  257. cg64.a_load64_loc_ref(exprasmlist,left.location,href);
  258. location_reset(left.location,LOC_REFERENCE,left.location.size);
  259. left.location.reference:=href;
  260. end
  261. else
  262. internalerror(200204011);
  263. end;
  264. inc(pushedparasize,POINTER_SIZE);
  265. if calloption=pocall_inline then
  266. begin
  267. tmpreg:=rg.getaddressregister(exprasmlist);
  268. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  269. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  270. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
  271. rg.ungetregisterint(exprasmlist,tmpreg);
  272. end
  273. else
  274. cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
  275. location_release(exprasmlist,left.location);
  276. end
  277. else
  278. begin
  279. push_value_para(exprasmlist,left,calloption,
  280. para_offset,para_alignment,tempparaloc);
  281. end;
  282. end;
  283. truelabel:=otlabel;
  284. falselabel:=oflabel;
  285. { update return location in callnode when this is the function
  286. result }
  287. if (vo_is_funcret in tvarsym(paraitem.parasym).varoptions) then
  288. begin
  289. location_copy(aktcallnode.location,left.location);
  290. end;
  291. { push from right to left }
  292. if not push_from_left_to_right and assigned(right) then
  293. begin
  294. tcallparanode(right).secondcallparan(push_from_left_to_right,
  295. calloption,para_alignment,para_offset);
  296. end;
  297. end;
  298. {*****************************************************************************
  299. TCGCALLNODE
  300. *****************************************************************************}
  301. procedure tcgcallnode.extra_interrupt_code;
  302. begin
  303. end;
  304. function tcgcallnode.align_parasize:longint;
  305. begin
  306. result:=0;
  307. end;
  308. procedure tcgcallnode.pop_parasize(pop_size:longint);
  309. begin
  310. end;
  311. procedure tcgcallnode.push_framepointer;
  312. var
  313. href : treference;
  314. hregister : tregister;
  315. begin
  316. { this routine is itself not nested }
  317. if current_procinfo.procdef.parast.symtablelevel=(tprocdef(procdefinition).parast.symtablelevel) then
  318. begin
  319. reference_reset_base(href,current_procinfo.framepointer,current_procinfo.parent_framepointer_offset);
  320. cg.a_param_ref(exprasmlist,OS_ADDR,href,paramanager.getintparaloc(exprasmlist,1));
  321. end
  322. { one nesting level }
  323. else if (current_procinfo.procdef.parast.symtablelevel=(tprocdef(procdefinition).parast.symtablelevel)-1) then
  324. begin
  325. cg.a_param_reg(exprasmlist,OS_ADDR,current_procinfo.framepointer,paramanager.getintparaloc(exprasmlist,1));
  326. end
  327. { very complex nesting level ... }
  328. else if (current_procinfo.procdef.parast.symtablelevel>(tprocdef(procdefinition).parast.symtablelevel)) then
  329. begin
  330. hregister:=rg.getaddressregister(exprasmlist);
  331. cg.g_load_parent_framepointer(exprasmlist,tprocdef(procdefinition).parast,hregister);
  332. cg.a_param_reg(exprasmlist,OS_ADDR,hregister,paramanager.getintparaloc(exprasmlist,1));
  333. rg.ungetaddressregister(exprasmlist,hregister);
  334. end;
  335. end;
  336. procedure tcgcallnode.free_pushed_framepointer;
  337. begin
  338. paramanager.freeintparaloc(exprasmlist,1);
  339. end;
  340. procedure tcgcallnode.handle_return_value;
  341. var
  342. cgsize : tcgsize;
  343. hregister : tregister;
  344. tempnode: tnode;
  345. begin
  346. { structured results are easy to handle.... }
  347. { needed also when result_no_used !! }
  348. if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  349. begin
  350. { Location should be setup by the funcret para }
  351. if location.loc<>LOC_REFERENCE then
  352. internalerror(200304241);
  353. end
  354. else
  355. { ansi/widestrings must be registered, so we can dispose them }
  356. if is_ansistring(resulttype.def) or
  357. is_widestring(resulttype.def) then
  358. begin
  359. { the FUNCTION_RESULT_REG is already allocated }
  360. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT_REG);
  361. if not assigned(funcretnode) then
  362. begin
  363. location_reset(location,LOC_CREFERENCE,OS_ADDR);
  364. location.reference:=refcountedtemp;
  365. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,location.reference);
  366. end
  367. else
  368. begin
  369. hregister := rg.getaddressregister(exprasmlist);
  370. cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,hregister);
  371. { in case of a regular funcretnode with ret_in_param, the }
  372. { original funcretnode isn't touched -> make sure it's }
  373. { the same here (not sure if it's necessary) }
  374. tempnode := funcretnode.getcopy;
  375. tempnode.pass_2;
  376. location := tempnode.location;
  377. tempnode.free;
  378. cg.g_decrrefcount(exprasmlist,resulttype.def,location.reference, false);
  379. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,hregister,location.reference);
  380. rg.ungetregisterint(exprasmlist,hregister);
  381. end;
  382. end
  383. else
  384. { we have only to handle the result if it is used }
  385. if (nf_return_value_used in flags) then
  386. begin
  387. if (resulttype.def.deftype=floatdef) then
  388. begin
  389. location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
  390. {$ifdef cpufpemu}
  391. if cs_fp_emulation in aktmoduleswitches then
  392. location.register:=NR_FUNCTION_RESULT_REG
  393. else
  394. {$endif cpufpemu}
  395. location.register:=NR_FPU_RESULT_REG;
  396. {$ifdef x86}
  397. inc(trgcpu(rg).fpuvaroffset);
  398. {$else x86}
  399. hregister := rg.getregisterfpu(exprasmlist,location.size);
  400. cg.a_loadfpu_reg_reg(exprasmlist,location.size,location.register,hregister);
  401. location.register := hregister;
  402. {$endif x86}
  403. end
  404. else
  405. begin
  406. cgsize:=def_cgsize(resulttype.def);
  407. { an object constructor is a function with pointer result }
  408. if (procdefinition.proctypeoption=potype_constructor) then
  409. cgsize:=OS_ADDR;
  410. if cgsize<>OS_NO then
  411. begin
  412. location_reset(location,LOC_REGISTER,cgsize);
  413. {$ifndef cpu64bit}
  414. if cgsize in [OS_64,OS_S64] then
  415. begin
  416. { Move the function result to free registers, preferably the
  417. FUNCTION_RESULT_REG/FUNCTION_RESULTHIGH_REG, so no move is necessary.}
  418. { the FUNCTION_RESULT_LOW_REG/FUNCTION_RESULT_HIGH_REG
  419. are already allocated }
  420. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT64_LOW_REG);
  421. location.registerlow:=rg.getregisterint(exprasmlist,OS_INT);
  422. cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,NR_FUNCTION_RESULT64_LOW_REG,location.registerlow);
  423. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT64_HIGH_REG);
  424. location.registerhigh:=rg.getregisterint(exprasmlist,OS_INT);
  425. cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,NR_FUNCTION_RESULT64_HIGH_REG,location.registerhigh);
  426. end
  427. else
  428. {$endif cpu64bit}
  429. begin
  430. {Move the function result to a free register, preferably the
  431. FUNCTION_RESULT_REG, so no move is necessary.}
  432. { the FUNCTION_RESULT_REG is already allocated }
  433. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT_REG);
  434. { change register size after the unget because the
  435. getregister was done for the full register }
  436. location.register:=rg.getregisterint(exprasmlist,cgsize);
  437. cg.a_load_reg_reg(exprasmlist,cgsize,cgsize,rg.makeregsize(NR_FUNCTION_RESULT_REG,cgsize),location.register);
  438. end;
  439. end
  440. else
  441. begin
  442. if resulttype.def.size>0 then
  443. internalerror(200305131);
  444. end;
  445. end;
  446. end
  447. else
  448. begin
  449. cgsize:=def_cgsize(resulttype.def);
  450. { an object constructor is a function with pointer result }
  451. if (procdefinition.proctypeoption=potype_constructor) then
  452. cgsize:=OS_ADDR;
  453. if cgsize<>OS_NO then
  454. {$ifndef cpu64bit}
  455. if cgsize in [OS_64,OS_S64] then
  456. begin
  457. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT64_LOW_REG);
  458. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT64_HIGH_REG);
  459. end
  460. else
  461. {$endif cpu64bit}
  462. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT_REG);
  463. location_reset(location,LOC_VOID,OS_NO);
  464. end;
  465. end;
  466. procedure tcgcallnode.release_para_temps;
  467. var
  468. hp : tnode;
  469. ppn : tcallparanode;
  470. begin
  471. { Release temps from parameters }
  472. ppn:=tcallparanode(left);
  473. while assigned(ppn) do
  474. begin
  475. if assigned(ppn.left) then
  476. begin
  477. { don't release the funcret temp }
  478. if not(vo_is_funcret in tvarsym(ppn.paraitem.parasym).varoptions) then
  479. location_freetemp(exprasmlist,ppn.left.location);
  480. { process also all nodes of an array of const }
  481. if ppn.left.nodetype=arrayconstructorn then
  482. begin
  483. if assigned(tarrayconstructornode(ppn.left).left) then
  484. begin
  485. hp:=ppn.left;
  486. while assigned(hp) do
  487. begin
  488. location_freetemp(exprasmlist,tarrayconstructornode(hp).left.location);
  489. hp:=tarrayconstructornode(hp).right;
  490. end;
  491. end;
  492. end;
  493. end;
  494. ppn:=tcallparanode(ppn.right);
  495. end;
  496. end;
  497. procedure tcgcallnode.normal_pass_2;
  498. var
  499. regs_to_push_other : totherregisterset;
  500. unusedstate: pointer;
  501. regs_to_alloc,regs_to_free:Tsuperregisterset;
  502. pushedother : tpushedsavedother;
  503. oldpushedparasize : longint;
  504. { adress returned from an I/O-error }
  505. iolabel : tasmlabel;
  506. { help reference pointer }
  507. href,helpref : treference;
  508. para_alignment,
  509. pop_size : longint;
  510. vmtreg,vmtreg2 : tregister;
  511. oldaktcallnode : tcallnode;
  512. procedure pushparas;
  513. var
  514. ppn : tcgcallparanode;
  515. begin
  516. { copy all resources to the allocated registers }
  517. ppn:=tcgcallparanode(left);
  518. while assigned(ppn) do
  519. begin
  520. if ppn.tempparaloc.loc=LOC_REGISTER then
  521. begin
  522. paramanager.allocparaloc(exprasmlist,ppn.paraitem.paraloc[callerside]);
  523. {$ifdef sparc}
  524. case ppn.tempparaloc.size of
  525. OS_F32 :
  526. ppn.tempparaloc.size:=OS_32;
  527. OS_F64 :
  528. ppn.tempparaloc.size:=OS_64;
  529. end;
  530. {$endif sparc}
  531. {$ifndef cpu64bit}
  532. if ppn.tempparaloc.size in [OS_64,OS_S64] then
  533. begin
  534. cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,ppn.tempparaloc.registerlow,
  535. ppn.paraitem.paraloc[callerside].registerlow);
  536. cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,ppn.tempparaloc.registerhigh,
  537. ppn.paraitem.paraloc[callerside].registerhigh);
  538. end
  539. else
  540. {$endif cpu64bit}
  541. cg.a_load_reg_reg(exprasmlist,ppn.tempparaloc.size,ppn.tempparaloc.size,
  542. ppn.tempparaloc.register,ppn.paraitem.paraloc[callerside].register);
  543. end;
  544. ppn:=tcgcallparanode(ppn.right);
  545. end;
  546. end;
  547. procedure freeparas;
  548. var
  549. ppn : tcgcallparanode;
  550. begin
  551. { free the resources allocated for the parameters }
  552. ppn:=tcgcallparanode(left);
  553. while assigned(ppn) do
  554. begin
  555. {$ifdef usetempparaloc}
  556. if ppn.tempparaloc.loc=LOC_REGISTER then
  557. paramanager.freeparaloc(exprasmlist,ppn.tempparaloc);
  558. {$endif usetempparaloc}
  559. paramanager.freeparaloc(exprasmlist,ppn.paraitem.paraloc[callerside]);
  560. ppn:=tcgcallparanode(ppn.right);
  561. end;
  562. { free pushed base pointer }
  563. if (right=nil) and
  564. (current_procinfo.procdef.parast.symtablelevel>=normal_function_level) and
  565. assigned(tprocdef(procdefinition).parast) and
  566. ((tprocdef(procdefinition).parast.symtablelevel)>normal_function_level) then
  567. free_pushed_framepointer;
  568. end;
  569. begin
  570. if not assigned(procdefinition) then
  571. internalerror(200305264);
  572. { calculate the parameter info for the procdef }
  573. if not procdefinition.has_paraloc_info then
  574. begin
  575. paramanager.create_paraloc_info(procdefinition,callerside);
  576. procdefinition.has_paraloc_info:=true;
  577. end;
  578. iolabel:=nil;
  579. rg.saveunusedstate(unusedstate);
  580. if not assigned(funcretnode) then
  581. begin
  582. { if we allocate the temp. location for ansi- or widestrings }
  583. { already here, we avoid later a push/pop }
  584. if is_widestring(resulttype.def) then
  585. begin
  586. tg.gettemp(exprasmlist,pointer_size,tt_widestring,refcountedtemp);
  587. cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp,false);
  588. end
  589. else if is_ansistring(resulttype.def) then
  590. begin
  591. tg.GetTemp(exprasmlist,pointer_size,tt_ansistring,refcountedtemp);
  592. cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp,false);
  593. end;
  594. end;
  595. if (procdefinition.proccalloption in [pocall_cdecl,pocall_cppdecl,pocall_stdcall]) then
  596. para_alignment:=4
  597. else
  598. para_alignment:=aktalignment.paraalign;
  599. { proc variables destroy all registers }
  600. if (right=nil) and
  601. { virtual methods too }
  602. not(po_virtualmethod in procdefinition.procoptions) then
  603. begin
  604. if (cs_check_io in aktlocalswitches) and
  605. (po_iocheck in procdefinition.procoptions) and
  606. not(po_iocheck in current_procinfo.procdef.procoptions) then
  607. begin
  608. objectlibrary.getaddrlabel(iolabel);
  609. cg.a_label(exprasmlist,iolabel);
  610. end
  611. else
  612. iolabel:=nil;
  613. regs_to_alloc:=Tprocdef(procdefinition).usedintregisters;
  614. {$ifdef i386}
  615. regs_to_push_other := tprocdef(procdefinition).usedotherregisters;
  616. {$else i386}
  617. regs_to_push_other := VOLATILE_FPUREGISTERS;
  618. {$endif i386}
  619. { on the ppc, ever procedure saves the non-volatile registers it uses itself }
  620. { and must make sure it saves its volatile registers before doing a call }
  621. {$ifdef i386}
  622. { give used registers through }
  623. rg.used_in_proc_int:=rg.used_in_proc_int + tprocdef(procdefinition).usedintregisters;
  624. rg.used_in_proc_other:=rg.used_in_proc_other + tprocdef(procdefinition).usedotherregisters;
  625. {$endif i386}
  626. end
  627. else
  628. begin
  629. regs_to_alloc:=VOLATILE_INTREGISTERS;
  630. {$ifdef i386}
  631. regs_to_push_other := all_otherregisters;
  632. {$else i386}
  633. regs_to_push_other := VOLATILE_FPUREGISTERS;
  634. {$endif i386}
  635. {$ifdef i386}
  636. rg.used_in_proc_int:=VOLATILE_INTREGISTERS;
  637. rg.used_in_proc_other:=all_otherregisters;
  638. {$endif i386}
  639. { no IO check for methods and procedure variables }
  640. iolabel:=nil;
  641. end;
  642. { Include Function result registers }
  643. if (not is_void(resulttype.def)) then
  644. begin
  645. case procdefinition.funcret_paraloc[callerside].loc of
  646. LOC_REGISTER,LOC_CREGISTER:
  647. begin
  648. {$ifndef cpu64bit}
  649. if procdefinition.funcret_paraloc[callerside].size in [OS_S64,OS_64] then
  650. begin
  651. include(regs_to_alloc,getsupreg(procdefinition.funcret_paraloc[callerside].registerlow));
  652. include(regs_to_alloc,getsupreg(procdefinition.funcret_paraloc[callerside].registerhigh));
  653. end
  654. else
  655. {$endif cpu64bit}
  656. include(regs_to_alloc,getsupreg(procdefinition.funcret_paraloc[callerside].register));
  657. end;
  658. end;
  659. end;
  660. { Save registers destroyed by the call }
  661. rg.saveusedotherregisters(exprasmlist,pushedother,regs_to_push_other);
  662. { Initialize for pushing the parameters }
  663. oldpushedparasize:=pushedparasize;
  664. pushedparasize:=0;
  665. { Align stack if required }
  666. pop_size:=align_parasize;
  667. { Push parameters }
  668. oldaktcallnode:=aktcallnode;
  669. aktcallnode:=self;
  670. {$ifndef i386}
  671. { process procvar. Done here already, because otherwise it may }
  672. { destroy registers containing a parameter for the actual }
  673. { function call (e.g. if it's a function, its result will }
  674. { overwrite r3, which contains the first parameter) (JM) }
  675. if assigned(right) then
  676. secondpass(right);
  677. if (po_virtualmethod in procdefinition.procoptions) and
  678. assigned(methodpointer) then
  679. begin
  680. secondpass(methodpointer);
  681. location_force_reg(exprasmlist,methodpointer.location,OS_ADDR,false);
  682. { virtual methods require an index }
  683. if tprocdef(procdefinition).extnumber=-1 then
  684. internalerror(200304021);
  685. { VMT should already be loaded in a register }
  686. if methodpointer.location.register=NR_NO then
  687. internalerror(200304022);
  688. { test validity of VMT }
  689. if not(is_interface(tprocdef(procdefinition)._class)) and
  690. not(is_cppclass(tprocdef(procdefinition)._class)) then
  691. cg.g_maybe_testvmt(exprasmlist,methodpointer.location.register,tprocdef(procdefinition)._class);
  692. end;
  693. {$endif not i386}
  694. { Process parameters }
  695. if assigned(left) then
  696. begin
  697. tcallparanode(left).secondcallparan(
  698. (po_leftright in procdefinition.procoptions),procdefinition.proccalloption,
  699. para_alignment,0);
  700. {$ifdef usetempparaloc}
  701. pushparas;
  702. {$endif}
  703. end;
  704. aktcallnode:=oldaktcallnode;
  705. { procedure variable or normal function call ? }
  706. if (right=nil) then
  707. begin
  708. { push base pointer ?}
  709. if (current_procinfo.procdef.parast.symtablelevel>=normal_function_level) and
  710. assigned(tprocdef(procdefinition).parast) and
  711. ((tprocdef(procdefinition).parast.symtablelevel)>normal_function_level) then
  712. push_framepointer;
  713. rg.saveotherregvars(exprasmlist,regs_to_push_other);
  714. if (po_virtualmethod in procdefinition.procoptions) and
  715. assigned(methodpointer) then
  716. begin
  717. {$ifdef i386}
  718. secondpass(methodpointer);
  719. location_force_reg(exprasmlist,methodpointer.location,OS_ADDR,false);
  720. vmtreg:=methodpointer.location.register;
  721. { virtual methods require an index }
  722. if tprocdef(procdefinition).extnumber=-1 then
  723. internalerror(200304021);
  724. { VMT should already be loaded in a register }
  725. if vmtreg=NR_NO then
  726. internalerror(200304022);
  727. { test validity of VMT }
  728. if not(is_interface(tprocdef(procdefinition)._class)) and
  729. not(is_cppclass(tprocdef(procdefinition)._class)) then
  730. cg.g_maybe_testvmt(exprasmlist,vmtreg,tprocdef(procdefinition)._class);
  731. {$else}
  732. vmtreg:=methodpointer.location.register;
  733. {$endif}
  734. { release self }
  735. rg.ungetaddressregister(exprasmlist,vmtreg);
  736. vmtreg2:=rg.getabtregisterint(exprasmlist,OS_ADDR);
  737. rg.ungetregisterint(exprasmlist,vmtreg2);
  738. cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,vmtreg,vmtreg2);
  739. { free the resources allocated for the parameters }
  740. freeparas;
  741. rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
  742. { call method }
  743. reference_reset_base(href,vmtreg2,
  744. tprocdef(procdefinition)._class.vmtmethodoffset(tprocdef(procdefinition).extnumber));
  745. cg.a_call_ref(exprasmlist,href);
  746. end
  747. else
  748. begin
  749. { free the resources allocated for the parameters }
  750. freeparas;
  751. rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
  752. { Calling interrupt from the same code requires some
  753. extra code }
  754. if (po_interrupt in procdefinition.procoptions) then
  755. extra_interrupt_code;
  756. cg.a_call_name(exprasmlist,tprocdef(procdefinition).mangledname);
  757. end;
  758. end
  759. else
  760. { now procedure variable case }
  761. begin
  762. {$ifdef i386}
  763. secondpass(right);
  764. {$endif i386}
  765. if right.location.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
  766. begin
  767. helpref:=right.location.reference;
  768. if (helpref.index<>NR_NO) and (helpref.index<>NR_FRAME_POINTER_REG) then
  769. begin
  770. rg.ungetregisterint(exprasmlist,helpref.index);
  771. helpref.index:=rg.getabtregisterint(exprasmlist,OS_ADDR);
  772. cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,
  773. right.location.reference.index,helpref.index);
  774. end;
  775. if (helpref.base<>NR_NO) and (helpref.base<>NR_FRAME_POINTER_REG) then
  776. begin
  777. rg.ungetregisterint(exprasmlist,helpref.base);
  778. helpref.base:=rg.getabtregisterint(exprasmlist,OS_ADDR);
  779. cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,
  780. right.location.reference.base,helpref.base);
  781. end;
  782. reference_release(exprasmlist,helpref);
  783. end
  784. else
  785. rg.ungetregisterint(exprasmlist,right.location.register);
  786. location_freetemp(exprasmlist,right.location);
  787. { free the resources allocated for the parameters }
  788. freeparas;
  789. rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
  790. { Calling interrupt from the same code requires some
  791. extra code }
  792. if (po_interrupt in procdefinition.procoptions) then
  793. extra_interrupt_code;
  794. rg.saveotherregvars(exprasmlist,ALL_OTHERREGISTERS);
  795. if right.location.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
  796. cg.a_call_ref(exprasmlist,helpref)
  797. else
  798. cg.a_call_reg(exprasmlist,right.location.register);
  799. { cg.a_call_loc(exprasmlist,right.location);}
  800. location_release(exprasmlist,right.location);
  801. location_freetemp(exprasmlist,right.location);
  802. end;
  803. { Need to remove the parameters from the stack? }
  804. if (po_clearstack in procdefinition.procoptions) then
  805. begin
  806. { the old pop_size was already included in pushedparasize }
  807. pop_size:=pushedparasize;
  808. { for Cdecl functions we don't need to pop the funcret when it
  809. was pushed by para }
  810. if paramanager.ret_in_param(procdefinition.rettype.def,procdefinition.proccalloption) then
  811. dec(pop_size,POINTER_SIZE);
  812. end;
  813. { Remove parameters/alignment from the stack }
  814. if pop_size>0 then
  815. pop_parasize(pop_size);
  816. { Reserve space for storing parameters that will be pushed }
  817. current_procinfo.allocate_push_parasize(pushedparasize);
  818. { Restore }
  819. pushedparasize:=oldpushedparasize;
  820. rg.restoreunusedstate(unusedstate);
  821. {$ifdef TEMPREGDEBUG}
  822. testregisters32;
  823. {$endif TEMPREGDEBUG}
  824. { Release registers, but not the registers that contain the
  825. function result }
  826. regs_to_free:=regs_to_alloc;
  827. if (not is_void(resulttype.def)) then
  828. begin
  829. case procdefinition.funcret_paraloc[callerside].loc of
  830. LOC_REGISTER,LOC_CREGISTER:
  831. begin
  832. {$ifndef cpu64bit}
  833. if procdefinition.funcret_paraloc[callerside].size in [OS_S64,OS_64] then
  834. begin
  835. exclude(regs_to_free,getsupreg(procdefinition.funcret_paraloc[callerside].registerlow));
  836. exclude(regs_to_free,getsupreg(procdefinition.funcret_paraloc[callerside].registerhigh));
  837. end
  838. else
  839. {$endif cpu64bit}
  840. exclude(regs_to_free,getsupreg(procdefinition.funcret_paraloc[callerside].register));
  841. end;
  842. end;
  843. end;
  844. rg.deallocexplicitregistersint(exprasmlist,regs_to_free);
  845. { handle function results }
  846. if (not is_void(resulttype.def)) then
  847. handle_return_value
  848. else
  849. location_reset(location,LOC_VOID,OS_NO);
  850. { perhaps i/o check ? }
  851. if iolabel<>nil then
  852. begin
  853. //reference_reset_symbol(href,iolabel,0);
  854. //cg.a_paramaddr_ref(exprasmlist,href,paramanager.getintparaloc(exprasmlist,1));
  855. //paramanager.freeintparaloc(exprasmlist,1);
  856. rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
  857. cg.a_call_name(exprasmlist,'FPC_IOCHECK');
  858. rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
  859. end;
  860. { restore registers }
  861. rg.restoreusedotherregisters(exprasmlist,pushedother);
  862. { release temps of paras }
  863. release_para_temps;
  864. { if return value is not used }
  865. if (not(nf_return_value_used in flags)) and (not is_void(resulttype.def)) then
  866. begin
  867. if location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
  868. begin
  869. { data which must be finalized ? }
  870. if (resulttype.def.needs_inittable) then
  871. cg.g_finalize(exprasmlist,resulttype.def,location.reference,false);
  872. { release unused temp }
  873. tg.ungetiftemp(exprasmlist,location.reference)
  874. end
  875. else if location.loc=LOC_FPUREGISTER then
  876. begin
  877. {$ifdef x86}
  878. { release FPU stack }
  879. emit_reg(A_FSTP,S_NO,NR_FPU_RESULT_REG);
  880. {
  881. dec(trgcpu(rg).fpuvaroffset);
  882. do NOT decrement as the increment before
  883. is not called for unused results PM }
  884. {$endif x86}
  885. end;
  886. end;
  887. end;
  888. procedure tcgcallnode.inlined_pass_2;
  889. var
  890. regs_to_push_int : Tsuperregisterset;
  891. regs_to_push_other : totherregisterset;
  892. unusedstate: pointer;
  893. pushedother : tpushedsavedother;
  894. oldpushedparasize : longint;
  895. { adress returned from an I/O-error }
  896. iolabel : tasmlabel;
  897. oldaktcallnode : tcallnode;
  898. oldprocdef : tprocdef;
  899. i : longint;
  900. oldprocinfo : tprocinfo;
  901. oldinlining_procedure : boolean;
  902. inlineentrycode,inlineexitcode : TAAsmoutput;
  903. oldregstate: pointer;
  904. old_local_fixup,
  905. old_para_fixup : longint;
  906. usesacc,usesacchi,usesfpu : boolean;
  907. pararef,
  908. localsref : treference;
  909. {$ifdef GDB}
  910. startlabel,endlabel : tasmlabel;
  911. pp : pchar;
  912. mangled_length : longint;
  913. {$endif GDB}
  914. begin
  915. if not(assigned(procdefinition) and (procdefinition.deftype=procdef)) then
  916. internalerror(200305262);
  917. oldinlining_procedure:=inlining_procedure;
  918. oldprocdef:=current_procinfo.procdef;
  919. oldprocinfo:=current_procinfo;
  920. { we're inlining a procedure }
  921. inlining_procedure:=true;
  922. { calculate the parameter info for the procdef }
  923. if not procdefinition.has_paraloc_info then
  924. begin
  925. paramanager.create_paraloc_info(procdefinition,callerside);
  926. procdefinition.has_paraloc_info:=true;
  927. end;
  928. { deallocate the registers used for the current procedure's regvars }
  929. if assigned(current_procinfo.procdef.regvarinfo) then
  930. begin
  931. with pregvarinfo(current_procinfo.procdef.regvarinfo)^ do
  932. for i := 1 to maxvarregs do
  933. if assigned(regvars[i]) then
  934. store_regvar(exprasmlist,regvars[i].reg);
  935. rg.saveStateForInline(oldregstate);
  936. { make sure the register allocator knows what the regvars in the }
  937. { inlined code block are (JM) }
  938. rg.resetusableregisters;
  939. rg.clearregistercount;
  940. if assigned(tprocdef(procdefinition).regvarinfo) then
  941. with pregvarinfo(tprocdef(procdefinition).regvarinfo)^ do
  942. for i := 1 to maxvarregs do
  943. if assigned(regvars[i]) then
  944. begin
  945. {Fix me!!}
  946. {tmpreg:=rg.makeregsize(regvars[i].reg,OS_INT);
  947. rg.makeregvar(tmpreg);}
  948. internalerror(200301232);
  949. end;
  950. end;
  951. { create temp procinfo }
  952. current_procinfo:=cprocinfo.create(nil);
  953. current_procinfo.procdef:=tprocdef(procdefinition);
  954. { Localsymtable }
  955. current_procinfo.procdef.localst.symtablelevel:=oldprocdef.localst.symtablelevel;
  956. if current_procinfo.procdef.localst.datasize>0 then
  957. begin
  958. old_local_fixup:=current_procinfo.procdef.localst.address_fixup;
  959. tg.GetTemp(exprasmlist,current_procinfo.procdef.localst.datasize,tt_persistent,localsref);
  960. if tg.direction>0 then
  961. current_procinfo.procdef.localst.address_fixup:=localsref.offset
  962. else
  963. current_procinfo.procdef.localst.address_fixup:=localsref.offset+current_procinfo.procdef.localst.datasize;
  964. {$ifdef extdebug}
  965. Comment(V_debug,'inlined local symtable ('+tostr(current_procinfo.procdef.localst.datasize)+' bytes) is at offset '+tostr(current_procinfo.procdef.localst.address_fixup));
  966. exprasmList.concat(tai_comment.Create(strpnew(
  967. 'inlined local symtable ('+tostr(current_procinfo.procdef.localst.datasize)+' bytes) is at offset '+tostr(current_procinfo.procdef.localst.address_fixup))));
  968. {$endif extdebug}
  969. end;
  970. { Parasymtable }
  971. current_procinfo.procdef.parast.symtablelevel:=oldprocdef.localst.symtablelevel;
  972. if current_procinfo.procdef.parast.datasize>0 then
  973. begin
  974. old_para_fixup:=current_procinfo.procdef.parast.address_fixup;
  975. tg.GetTemp(exprasmlist,current_procinfo.procdef.parast.datasize,tt_persistent,pararef);
  976. current_procinfo.procdef.parast.address_fixup:=pararef.offset;
  977. {$ifdef extdebug}
  978. Comment(V_debug,'inlined para symtable ('+tostr(current_procinfo.procdef.parast.datasize)+' bytes) is at offset '+tostr(current_procinfo.procdef.parast.address_fixup));
  979. exprasmList.concat(tai_comment.Create(strpnew(
  980. 'inlined para symtable ('+tostr(current_procinfo.procdef.parast.datasize)+' bytes) is at offset '+tostr(current_procinfo.procdef.parast.address_fixup))));
  981. {$endif extdebug}
  982. end;
  983. exprasmList.concat(Tai_Marker.Create(InlineStart));
  984. {$ifdef extdebug}
  985. exprasmList.concat(tai_comment.Create(strpnew('Start of inlined proc')));
  986. {$endif extdebug}
  987. {$ifdef GDB}
  988. if (cs_debuginfo in aktmoduleswitches) then
  989. begin
  990. objectlibrary.getaddrlabel(startlabel);
  991. objectlibrary.getaddrlabel(endlabel);
  992. cg.a_label(exprasmlist,startlabel);
  993. tprocdef(procdefinition).localst.symtabletype:=inlinelocalsymtable;
  994. procdefinition.parast.symtabletype:=inlineparasymtable;
  995. { Here we must include the para and local symtable info }
  996. procdefinition.concatstabto(withdebuglist);
  997. { set it back for safety }
  998. tprocdef(procdefinition).localst.symtabletype:=localsymtable;
  999. procdefinition.parast.symtabletype:=parasymtable;
  1000. mangled_length:=length(oldprocdef.mangledname);
  1001. getmem(pp,mangled_length+50);
  1002. strpcopy(pp,'192,0,0,'+startlabel.name);
  1003. if (target_info.use_function_relative_addresses) then
  1004. begin
  1005. strpcopy(strend(pp),'-');
  1006. strpcopy(strend(pp),oldprocdef.mangledname);
  1007. end;
  1008. withdebugList.concat(Tai_stabn.Create(strnew(pp)));
  1009. end;
  1010. {$endif GDB}
  1011. iolabel:=nil;
  1012. rg.saveunusedstate(unusedstate);
  1013. { if we allocate the temp. location for ansi- or widestrings }
  1014. { already here, we avoid later a push/pop }
  1015. if is_widestring(resulttype.def) then
  1016. begin
  1017. tg.GetTemp(exprasmlist,pointer_size,tt_widestring,refcountedtemp);
  1018. cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp,false);
  1019. end
  1020. else if is_ansistring(resulttype.def) then
  1021. begin
  1022. tg.GetTemp(exprasmlist,pointer_size,tt_ansistring,refcountedtemp);
  1023. cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp,false);
  1024. end;
  1025. if (cs_check_io in aktlocalswitches) and
  1026. (po_iocheck in procdefinition.procoptions) and
  1027. not(po_iocheck in current_procinfo.procdef.procoptions) then
  1028. begin
  1029. objectlibrary.getaddrlabel(iolabel);
  1030. cg.a_label(exprasmlist,iolabel);
  1031. end
  1032. else
  1033. iolabel:=nil;
  1034. { save all used registers and possible registers
  1035. used for the return value }
  1036. regs_to_push_int := tprocdef(procdefinition).usedintregisters;
  1037. regs_to_push_other := tprocdef(procdefinition).usedotherregisters;
  1038. if (not is_void(resulttype.def)) then
  1039. begin
  1040. case procdefinition.funcret_paraloc[callerside].loc of
  1041. LOC_REGISTER,LOC_CREGISTER:
  1042. begin
  1043. {$ifndef cpu64bit}
  1044. if procdefinition.funcret_paraloc[callerside].size in [OS_S64,OS_64] then
  1045. begin
  1046. include(regs_to_push_int,getsupreg(procdefinition.funcret_paraloc[callerside].registerlow));
  1047. include(regs_to_push_int,getsupreg(procdefinition.funcret_paraloc[callerside].registerhigh));
  1048. end
  1049. else
  1050. {$endif cpu64bit}
  1051. include(regs_to_push_int,getsupreg(procdefinition.funcret_paraloc[callerside].register));
  1052. end;
  1053. end;
  1054. end;
  1055. rg.saveusedotherregisters(exprasmlist,pushedother,regs_to_push_other);
  1056. {$ifdef i386}
  1057. { give used registers through }
  1058. rg.used_in_proc_int:=rg.used_in_proc_int + tprocdef(procdefinition).usedintregisters;
  1059. rg.used_in_proc_other:=rg.used_in_proc_other + tprocdef(procdefinition).usedotherregisters;
  1060. {$endif i386}
  1061. { Initialize for pushing the parameters }
  1062. oldpushedparasize:=pushedparasize;
  1063. pushedparasize:=0;
  1064. { Push parameters }
  1065. oldaktcallnode:=aktcallnode;
  1066. aktcallnode:=self;
  1067. if assigned(left) then
  1068. begin
  1069. { we push from right to left, so start with parameters at the end of
  1070. the parameter block }
  1071. tcallparanode(left).secondcallparan(
  1072. (po_leftright in procdefinition.procoptions),procdefinition.proccalloption,
  1073. 0,procdefinition.parast.address_fixup+procdefinition.parast.datasize);
  1074. end;
  1075. aktcallnode:=oldaktcallnode;
  1076. rg.saveotherregvars(exprasmlist,regs_to_push_other);
  1077. { takes care of local data initialization }
  1078. inlineentrycode:=TAAsmoutput.Create;
  1079. inlineexitcode:=TAAsmoutput.Create;
  1080. gen_initialize_code(inlineentrycode,true);
  1081. if po_assembler in current_procinfo.procdef.procoptions then
  1082. inlineentrycode.insert(Tai_marker.Create(asmblockstart));
  1083. exprasmList.concatlist(inlineentrycode);
  1084. { process the inline code }
  1085. secondpass(inlinecode);
  1086. { Reserve space for storing parameters that will be pushed }
  1087. current_procinfo.allocate_push_parasize(pushedparasize);
  1088. { Restore }
  1089. pushedparasize:=oldpushedparasize;
  1090. rg.restoreunusedstate(unusedstate);
  1091. {$ifdef TEMPREGDEBUG}
  1092. testregisters32;
  1093. {$endif TEMPREGDEBUG}
  1094. gen_finalize_code(inlineexitcode,true);
  1095. gen_load_return_value(inlineexitcode,usesacc,usesacchi,usesfpu);
  1096. if po_assembler in current_procinfo.procdef.procoptions then
  1097. inlineexitcode.concat(Tai_marker.Create(asmblockend));
  1098. exprasmList.concatlist(inlineexitcode);
  1099. inlineentrycode.free;
  1100. inlineexitcode.free;
  1101. {$ifdef extdebug}
  1102. exprasmList.concat(tai_comment.Create(strpnew('End of inlined proc')));
  1103. {$endif extdebug}
  1104. exprasmList.concat(Tai_Marker.Create(InlineEnd));
  1105. {we can free the local data now, reset also the fixup address }
  1106. if current_procinfo.procdef.localst.datasize>0 then
  1107. begin
  1108. tg.UnGetTemp(exprasmlist,localsref);
  1109. current_procinfo.procdef.localst.address_fixup:=old_local_fixup;
  1110. end;
  1111. {we can free the para data now, reset also the fixup address }
  1112. if current_procinfo.procdef.parast.datasize>0 then
  1113. begin
  1114. tg.UnGetTemp(exprasmlist,pararef);
  1115. current_procinfo.procdef.parast.address_fixup:=old_para_fixup;
  1116. end;
  1117. { free return reference }
  1118. if (resulttype.def.size>0) then
  1119. begin
  1120. { from now on the result can be freed normally }
  1121. // if assigned(funcretnode) and
  1122. // paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  1123. // tg.ChangeTempType(exprasmlist,funcretnode.location.reference,tt_normal);
  1124. end;
  1125. { handle function results }
  1126. if (not is_void(resulttype.def)) then
  1127. handle_return_value
  1128. else
  1129. location_reset(location,LOC_VOID,OS_NO);
  1130. { perhaps i/o check ? }
  1131. if iolabel<>nil then
  1132. begin
  1133. //reference_reset_symbol(href,iolabel,0);
  1134. //cg.a_paramaddr_ref(exprasmlist,href,paramanager.getintparaloc(exprasmlist,1));
  1135. //paramanager.freeintparaloc(exprasmlist,1);
  1136. rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
  1137. cg.a_call_name(exprasmlist,'FPC_IOCHECK');
  1138. rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
  1139. end;
  1140. { restore registers }
  1141. rg.restoreusedotherregisters(exprasmlist,pushedother);
  1142. { release temps of paras }
  1143. release_para_temps;
  1144. { if return value is not used }
  1145. if (not is_void(resulttype.def)) and
  1146. (not(nf_return_value_used in flags)) then
  1147. begin
  1148. if location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
  1149. begin
  1150. { data which must be finalized ? }
  1151. if (resulttype.def.needs_inittable) then
  1152. cg.g_finalize(exprasmlist,resulttype.def,location.reference,false);
  1153. { release unused temp }
  1154. tg.ungetiftemp(exprasmlist,location.reference)
  1155. end
  1156. else if location.loc=LOC_FPUREGISTER then
  1157. begin
  1158. {$ifdef x86}
  1159. { release FPU stack }
  1160. emit_reg(A_FSTP,S_NO,NR_FPU_RESULT_REG);
  1161. {
  1162. dec(trgcpu(rg).fpuvaroffset);
  1163. do NOT decrement as the increment before
  1164. is not called for unused results PM }
  1165. {$endif x86}
  1166. end;
  1167. end;
  1168. { release procinfo }
  1169. current_procinfo.free;
  1170. current_procinfo:=oldprocinfo;
  1171. {$ifdef GDB}
  1172. if (cs_debuginfo in aktmoduleswitches) then
  1173. begin
  1174. cg.a_label(exprasmlist,endlabel);
  1175. strpcopy(pp,'224,0,0,'+endlabel.name);
  1176. if (target_info.use_function_relative_addresses) then
  1177. begin
  1178. strpcopy(strend(pp),'-');
  1179. strpcopy(strend(pp),oldprocdef.mangledname);
  1180. end;
  1181. withdebugList.concat(Tai_stabn.Create(strnew(pp)));
  1182. freemem(pp,mangled_length+50);
  1183. end;
  1184. {$endif GDB}
  1185. { restore }
  1186. current_procinfo.procdef:=oldprocdef;
  1187. inlining_procedure:=oldinlining_procedure;
  1188. { reallocate the registers used for the current procedure's regvars, }
  1189. { since they may have been used and then deallocated in the inlined }
  1190. { procedure (JM) }
  1191. if assigned(current_procinfo.procdef.regvarinfo) then
  1192. rg.restoreStateAfterInline(oldregstate);
  1193. end;
  1194. procedure tcgcallnode.pass_2;
  1195. begin
  1196. if assigned(inlinecode) then
  1197. inlined_pass_2
  1198. else
  1199. normal_pass_2;
  1200. end;
  1201. begin
  1202. ccallparanode:=tcgcallparanode;
  1203. ccallnode:=tcgcallnode;
  1204. end.
  1205. {
  1206. $Log$
  1207. Revision 1.109 2003-09-03 15:55:00 peter
  1208. * NEWRA branch merged
  1209. Revision 1.108.2.4 2003/09/01 21:02:55 peter
  1210. * sparc updates for new tregister
  1211. Revision 1.108.2.3 2003/08/31 21:07:44 daniel
  1212. * callparatemp ripped
  1213. Revision 1.108.2.2 2003/08/29 17:28:59 peter
  1214. * next batch of updates
  1215. Revision 1.108.2.1 2003/08/27 20:23:55 peter
  1216. * remove old ra code
  1217. Revision 1.108 2003/08/21 22:14:16 olle
  1218. - removed parameter from fpc_iocheck
  1219. Revision 1.107 2003/08/17 16:59:20 jonas
  1220. * fixed regvars so they work with newra (at least for ppc)
  1221. * fixed some volatile register bugs
  1222. + -dnotranslation option for -dnewra, which causes the registers not to
  1223. be translated from virtual to normal registers. Requires support in
  1224. the assembler writer as well, which is only implemented in aggas/
  1225. agppcgas currently
  1226. Revision 1.106 2003/08/16 18:56:40 marco
  1227. * fix from Jonas.
  1228. Revision 1.105 2003/08/11 21:18:20 peter
  1229. * start of sparc support for newra
  1230. Revision 1.104 2003/08/11 14:22:06 mazen
  1231. - dupplicated code removed
  1232. Revision 1.103 2003/07/23 11:01:14 jonas
  1233. * several rg.allocexplicitregistersint/rg.deallocexplicitregistersint
  1234. pairs round calls to helpers
  1235. Revision 1.102 2003/07/21 13:51:50 jonas
  1236. * fixed 64bit int results with -dnewra (you can't free both registers and
  1237. then allocate two new ones, because then the registers could be reversed
  1238. afterwards -> you get something like "movl %eax, %edx; movl %edx,%eax")
  1239. Revision 1.101 2003/07/08 21:24:59 peter
  1240. * sparc fixes
  1241. Revision 1.100 2003/07/06 21:50:33 jonas
  1242. * fixed ppc compilation problems and changed VOLATILE_REGISTERS for x86
  1243. so that it doesn't include ebp and esp anymore
  1244. Revision 1.99 2003/07/06 17:58:22 peter
  1245. * framepointer fixes for sparc
  1246. * parent framepointer code more generic
  1247. Revision 1.98 2003/07/06 15:31:20 daniel
  1248. * Fixed register allocator. *Lots* of fixes.
  1249. Revision 1.97 2003/07/05 20:21:26 jonas
  1250. * create_paraloc_info() is now called separately for the caller and
  1251. callee info
  1252. * fixed ppc cycle
  1253. Revision 1.96 2003/07/02 22:18:04 peter
  1254. * paraloc splitted in paraloc[callerside],calleeparaloc
  1255. * sparc calling convention updates
  1256. Revision 1.95 2003/06/17 16:34:44 jonas
  1257. * lots of newra fixes (need getfuncretparaloc implementation for i386)!
  1258. * renamed all_intregisters to volatile_intregisters and made it
  1259. processor dependent
  1260. Revision 1.94 2003/06/15 16:52:02 jonas
  1261. * release function result registers if the functino result isn't used
  1262. * don't allocate function result register with -dnewra if there is none
  1263. * some optimizations for non-x86 processor (don't save any registers
  1264. before a call)
  1265. Revision 1.93 2003/06/13 21:19:30 peter
  1266. * current_procdef removed, use current_procinfo.procdef instead
  1267. Revision 1.92 2003/06/12 21:10:50 peter
  1268. * newra fixes
  1269. Revision 1.91 2003/06/12 18:38:45 jonas
  1270. * deallocate parameter registers in time for newra
  1271. * for non-i386, procvars and methodpointers always have to be processed
  1272. in advance, whether or not newra is defined
  1273. Revision 1.90 2003/06/09 14:54:26 jonas
  1274. * (de)allocation of registers for parameters is now performed properly
  1275. (and checked on the ppc)
  1276. - removed obsolete allocation of all parameter registers at the start
  1277. of a procedure (and deallocation at the end)
  1278. Revision 1.89 2003/06/09 12:23:29 peter
  1279. * init/final of procedure data splitted from genentrycode
  1280. * use asmnode getposition to insert final at the correct position
  1281. als for the implicit try...finally
  1282. Revision 1.88 2003/06/08 20:01:53 jonas
  1283. * optimized assignments with on the right side a function that returns
  1284. an ansi- or widestring
  1285. Revision 1.87 2003/06/08 18:21:47 jonas
  1286. * fixed weird error in the copyleft statement :)
  1287. Revision 1.86 2003/06/07 18:57:04 jonas
  1288. + added freeintparaloc
  1289. * ppc get/freeintparaloc now check whether the parameter regs are
  1290. properly allocated/deallocated (and get an extra list para)
  1291. * ppc a_call_* now internalerrors if pi_do_call is not yet set
  1292. * fixed lot of missing pi_do_call's
  1293. Revision 1.85 2003/06/04 06:43:36 jonas
  1294. * fixed double secondpassing of procvar loads
  1295. Revision 1.84 2003/06/03 21:11:09 peter
  1296. * cg.a_load_* get a from and to size specifier
  1297. * makeregsize only accepts newregister
  1298. * i386 uses generic tcgnotnode,tcgunaryminus
  1299. Revision 1.83 2003/06/03 20:27:02 daniel
  1300. * Restored original methodpointer code for non newra case
  1301. Revision 1.82 2003/06/03 13:01:59 daniel
  1302. * Register allocator finished
  1303. Revision 1.81 2003/06/01 21:38:06 peter
  1304. * getregisterfpu size parameter added
  1305. * op_const_reg size parameter added
  1306. * sparc updates
  1307. Revision 1.80 2003/05/31 15:05:28 peter
  1308. * FUNCTION_RESULT64_LOW/HIGH_REG added for int64 results
  1309. Revision 1.79 2003/05/31 00:59:44 peter
  1310. * typo in FUNCTION_RESULT_REG
  1311. Revision 1.78 2003/05/30 23:57:08 peter
  1312. * more sparc cleanup
  1313. * accumulator removed, splitted in function_return_reg (called) and
  1314. function_result_reg (caller)
  1315. Revision 1.77 2003/05/29 10:05:40 jonas
  1316. * free callparatemps created for call-by-reference parameters
  1317. Revision 1.76 2003/05/28 23:58:18 jonas
  1318. * added missing initialization of rg.usedintin,byproc
  1319. * ppc now also saves/restores used fpu registers
  1320. * ncgcal doesn't add used registers to usedby/inproc anymore, except for
  1321. i386
  1322. Revision 1.75 2003/05/26 21:17:17 peter
  1323. * procinlinenode removed
  1324. * aktexit2label removed, fast exit removed
  1325. + tcallnode.inlined_pass_2 added
  1326. Revision 1.74 2003/05/25 11:34:17 peter
  1327. * methodpointer self pushing fixed
  1328. Revision 1.73 2003/05/25 08:59:16 peter
  1329. * inline fixes
  1330. Revision 1.72 2003/05/24 13:36:54 jonas
  1331. * save fpu results in a normal fpu register on non-x86 processors
  1332. Revision 1.71 2003/05/23 19:35:50 jonas
  1333. - undid previous commit, it was wrong
  1334. Revision 1.70 2003/05/23 19:11:58 jonas
  1335. * fixed tests for whether a certain int register is unused
  1336. Revision 1.69 2003/05/23 18:01:56 jonas
  1337. * fixed ppc compiler
  1338. Revision 1.68 2003/05/23 14:27:35 peter
  1339. * remove some unit dependencies
  1340. * current_procinfo changes to store more info
  1341. Revision 1.67 2003/05/17 13:30:08 jonas
  1342. * changed tt_persistant to tt_persistent :)
  1343. * tempcreatenode now doesn't accept a boolean anymore for persistent
  1344. temps, but a ttemptype, so you can also create ansistring temps etc
  1345. Revision 1.66 2003/05/16 14:33:31 peter
  1346. * regvar fixes
  1347. Revision 1.65 2003/05/15 18:58:53 peter
  1348. * removed selfpointer_offset, vmtpointer_offset
  1349. * tvarsym.adjusted_address
  1350. * address in localsymtable is now in the real direction
  1351. * removed some obsolete globals
  1352. Revision 1.64 2003/05/14 19:36:54 jonas
  1353. * patch from Peter for int64 function results
  1354. Revision 1.63 2003/05/13 19:14:41 peter
  1355. * failn removed
  1356. * inherited result code check moven to pexpr
  1357. Revision 1.62 2003/05/13 15:18:18 peter
  1358. * generate code for procvar first before pushing parameters. Made
  1359. the already existing code for powerpc available for all platforms
  1360. Revision 1.61 2003/05/12 18:17:55 jonas
  1361. * moved fpc_check_object call earlier for the ppc, so it can't destroy
  1362. already-loaded parameter registers
  1363. Revision 1.60 2003/05/11 21:48:38 jonas
  1364. * fixed procvar bug on the ppc (load procvar before loading para's,
  1365. because the procvar may otherwise destroy the already loaded paras)
  1366. Revision 1.59 2003/05/09 17:47:02 peter
  1367. * self moved to hidden parameter
  1368. * removed hdisposen,hnewn,selfn
  1369. Revision 1.58 2003/05/05 14:53:16 peter
  1370. * vs_hidden replaced by is_hidden boolean
  1371. Revision 1.57 2003/04/30 20:53:32 florian
  1372. * error when address of an abstract method is taken
  1373. * fixed some x86-64 problems
  1374. * merged some more x86-64 and i386 code
  1375. Revision 1.56 2003/04/29 07:28:52 michael
  1376. + Patch from peter to fix wrong pushing of ansistring function results in open array
  1377. Revision 1.55 2003/04/27 11:21:33 peter
  1378. * aktprocdef renamed to current_procinfo.procdef
  1379. * procinfo renamed to current_procinfo
  1380. * procinfo will now be stored in current_module so it can be
  1381. cleaned up properly
  1382. * gen_main_procsym changed to create_main_proc and release_main_proc
  1383. to also generate a tprocinfo structure
  1384. * fixed unit implicit initfinal
  1385. Revision 1.54 2003/04/27 07:29:50 peter
  1386. * current_procinfo.procdef cleanup, current_procinfo.procdef is now always nil when parsing
  1387. a new procdef declaration
  1388. * aktprocsym removed
  1389. * lexlevel removed, use symtable.symtablelevel instead
  1390. * implicit init/final code uses the normal genentry/genexit
  1391. * funcret state checking updated for new funcret handling
  1392. Revision 1.53 2003/04/25 20:59:33 peter
  1393. * removed funcretn,funcretsym, function result is now in varsym
  1394. and aliases for result and function name are added using absolutesym
  1395. * vs_hidden parameter for funcret passed in parameter
  1396. * vs_hidden fixes
  1397. * writenode changed to printnode and released from extdebug
  1398. * -vp option added to generate a tree.log with the nodetree
  1399. * nicer printnode for statements, callnode
  1400. Revision 1.52 2003/04/25 08:25:26 daniel
  1401. * Ifdefs around a lot of calls to cleartempgen
  1402. * Fixed registers that are allocated but not freed in several nodes
  1403. * Tweak to register allocator to cause less spills
  1404. * 8-bit registers now interfere with esi,edi and ebp
  1405. Compiler can now compile rtl successfully when using new register
  1406. allocator
  1407. Revision 1.51 2003/04/22 23:50:22 peter
  1408. * firstpass uses expectloc
  1409. * checks if there are differences between the expectloc and
  1410. location.loc from secondpass in EXTDEBUG
  1411. Revision 1.50 2003/04/22 14:33:38 peter
  1412. * removed some notes/hints
  1413. Revision 1.49 2003/04/22 13:47:08 peter
  1414. * fixed C style array of const
  1415. * fixed C array passing
  1416. * fixed left to right with high parameters
  1417. Revision 1.48 2003/04/22 10:09:34 daniel
  1418. + Implemented the actual register allocator
  1419. + Scratch registers unavailable when new register allocator used
  1420. + maybe_save/maybe_restore unavailable when new register allocator used
  1421. Revision 1.47 2003/04/22 09:49:44 peter
  1422. * do not load self when calling a non-inherited class constructor
  1423. Revision 1.46 2003/04/21 20:03:32 peter
  1424. * forgot to copy vmtrefaddr to selfrefaddr when self=vmt
  1425. Revision 1.45 2003/04/21 13:53:16 jonas
  1426. - removed copying of all paras when secondpassing a callnode (this used
  1427. to be necessary for inlinign support, but currently the whole inlined
  1428. procedure is already copied in advance). Note that the compiler crashes
  1429. when compiling ucomplex with -dTEST_INLINE (also after fixing the
  1430. syntax errors), but that was also the case before this change.
  1431. Revision 1.44 2003/04/10 17:57:52 peter
  1432. * vs_hidden released
  1433. Revision 1.43 2003/04/06 21:11:23 olle
  1434. * changed newasmsymbol to newasmsymboldata for data symbols
  1435. Revision 1.42 2003/04/04 15:38:56 peter
  1436. * moved generic code from n386cal to ncgcal, i386 now also
  1437. uses the generic ncgcal
  1438. Revision 1.41 2003/03/28 19:16:56 peter
  1439. * generic constructor working for i386
  1440. * remove fixed self register
  1441. * esi added as address register for i386
  1442. Revision 1.40 2003/03/06 11:35:50 daniel
  1443. * Fixed internalerror 7843 issue
  1444. Revision 1.39 2003/02/19 22:00:14 daniel
  1445. * Code generator converted to new register notation
  1446. - Horribily outdated todo.txt removed
  1447. Revision 1.38 2003/02/15 22:17:38 carl
  1448. * bugfix of FPU emulation code
  1449. Revision 1.37 2003/02/12 22:10:07 carl
  1450. * load_frame_pointer is now generic
  1451. * change fpu emulation routine names
  1452. Revision 1.36 2003/01/30 21:46:57 peter
  1453. * self fixes for static methods (merged)
  1454. Revision 1.35 2003/01/22 20:45:15 mazen
  1455. * making math code in RTL compiling.
  1456. *NB : This does NOT mean necessary that it will generate correct code!
  1457. Revision 1.34 2003/01/17 12:03:45 daniel
  1458. * Optalign conditional code adapted to record Tregister
  1459. Revision 1.33 2003/01/08 18:43:56 daniel
  1460. * Tregister changed into a record
  1461. Revision 1.32 2002/12/15 22:50:00 florian
  1462. + some stuff for the new hidden parameter handling added
  1463. Revision 1.31 2002/12/15 21:30:12 florian
  1464. * tcallnode.paraitem introduced, all references to defcoll removed
  1465. Revision 1.30 2002/11/27 20:04:39 peter
  1466. * cdecl array of const fixes
  1467. Revision 1.29 2002/11/25 17:43:17 peter
  1468. * splitted defbase in defutil,symutil,defcmp
  1469. * merged isconvertable and is_equal into compare_defs(_ext)
  1470. * made operator search faster by walking the list only once
  1471. Revision 1.28 2002/11/18 17:31:54 peter
  1472. * pass proccalloption to ret_in_xxx and push_xxx functions
  1473. Revision 1.27 2002/11/16 15:34:30 florian
  1474. * generic location for float results
  1475. Revision 1.26 2002/11/15 01:58:51 peter
  1476. * merged changes from 1.0.7 up to 04-11
  1477. - -V option for generating bug report tracing
  1478. - more tracing for option parsing
  1479. - errors for cdecl and high()
  1480. - win32 import stabs
  1481. - win32 records<=8 are returned in eax:edx (turned off by default)
  1482. - heaptrc update
  1483. - more info for temp management in .s file with EXTDEBUG
  1484. Revision 1.25 2002/10/05 12:43:25 carl
  1485. * fixes for Delphi 6 compilation
  1486. (warning : Some features do not work under Delphi)
  1487. Revision 1.24 2002/09/30 07:00:45 florian
  1488. * fixes to common code to get the alpha compiler compiled applied
  1489. Revision 1.23 2002/09/17 18:54:02 jonas
  1490. * a_load_reg_reg() now has two size parameters: source and dest. This
  1491. allows some optimizations on architectures that don't encode the
  1492. register size in the register name.
  1493. Revision 1.22 2002/09/07 15:25:02 peter
  1494. * old logs removed and tabs fixed
  1495. Revision 1.21 2002/09/07 11:50:02 jonas
  1496. * fixed small regalloction info bug
  1497. Revision 1.20 2002/09/02 11:25:20 florian
  1498. * fixed generic procedure variable calling
  1499. Revision 1.19 2002/09/01 21:04:48 florian
  1500. * several powerpc related stuff fixed
  1501. Revision 1.18 2002/09/01 18:43:27 peter
  1502. * include FUNCTION_RETURN_REG in regs_to_push list
  1503. Revision 1.17 2002/09/01 12:13:00 peter
  1504. * use a_call_reg
  1505. * ungetiftemp for procvar of object temp
  1506. Revision 1.16 2002/08/25 19:25:18 peter
  1507. * sym.insert_in_data removed
  1508. * symtable.insertvardata/insertconstdata added
  1509. * removed insert_in_data call from symtable.insert, it needs to be
  1510. called separatly. This allows to deref the address calculation
  1511. * procedures now calculate the parast addresses after the procedure
  1512. directives are parsed. This fixes the cdecl parast problem
  1513. * push_addr_param has an extra argument that specifies if cdecl is used
  1514. or not
  1515. Revision 1.15 2002/08/23 16:14:48 peter
  1516. * tempgen cleanup
  1517. * tt_noreuse temp type added that will be used in genentrycode
  1518. Revision 1.14 2002/08/20 16:55:38 peter
  1519. * don't write (stabs)line info when inlining a procedure
  1520. Revision 1.13 2002/08/19 19:36:42 peter
  1521. * More fixes for cross unit inlining, all tnodes are now implemented
  1522. * Moved pocall_internconst to po_internconst because it is not a
  1523. calling type at all and it conflicted when inlining of these small
  1524. functions was requested
  1525. Revision 1.12 2002/08/18 20:06:23 peter
  1526. * inlining is now also allowed in interface
  1527. * renamed write/load to ppuwrite/ppuload
  1528. * tnode storing in ppu
  1529. * nld,ncon,nbas are already updated for storing in ppu
  1530. Revision 1.11 2002/08/17 22:09:44 florian
  1531. * result type handling in tcgcal.pass_2 overhauled
  1532. * better tnode.dowrite
  1533. * some ppc stuff fixed
  1534. Revision 1.10 2002/08/17 09:23:35 florian
  1535. * first part of procinfo rewrite
  1536. Revision 1.9 2002/08/13 21:40:55 florian
  1537. * more fixes for ppc calling conventions
  1538. Revision 1.8 2002/08/13 18:01:51 carl
  1539. * rename swatoperands to swapoperands
  1540. + m68k first compilable version (still needs a lot of testing):
  1541. assembler generator, system information , inline
  1542. assembler reader.
  1543. Revision 1.7 2002/08/12 15:08:39 carl
  1544. + stab register indexes for powerpc (moved from gdb to cpubase)
  1545. + tprocessor enumeration moved to cpuinfo
  1546. + linker in target_info is now a class
  1547. * many many updates for m68k (will soon start to compile)
  1548. - removed some ifdef or correct them for correct cpu
  1549. Revision 1.6 2002/08/11 14:32:26 peter
  1550. * renamed current_library to objectlibrary
  1551. Revision 1.5 2002/08/11 13:24:11 peter
  1552. * saving of asmsymbols in ppu supported
  1553. * asmsymbollist global is removed and moved into a new class
  1554. tasmlibrarydata that will hold the info of a .a file which
  1555. corresponds with a single module. Added librarydata to tmodule
  1556. to keep the library info stored for the module. In the future the
  1557. objectfiles will also be stored to the tasmlibrarydata class
  1558. * all getlabel/newasmsymbol and friends are moved to the new class
  1559. Revision 1.4 2002/08/06 20:55:20 florian
  1560. * first part of ppc calling conventions fix
  1561. Revision 1.3 2002/07/20 11:57:53 florian
  1562. * types.pas renamed to defbase.pas because D6 contains a types
  1563. unit so this would conflicts if D6 programms are compiled
  1564. + Willamette/SSE2 instructions to assembler added
  1565. Revision 1.2 2002/07/13 19:38:43 florian
  1566. * some more generic calling stuff fixed
  1567. }