ncgcal.pas 70 KB

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