ncgcal.pas 70 KB

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