ncgcal.pas 71 KB

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