ncgcal.pas 78 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779
  1. {
  2. Id: ncgcal.pas,v 1.10 2002/08/17 09:23:35 florian Exp $
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Generate i386 assembler for in call nodes
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published bymethodpointer
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit ncgcal;
  19. {$i fpcdefs.inc}
  20. interface
  21. { $define AnsiStrRef}
  22. uses
  23. cpubase,
  24. globtype,
  25. symdef,node,ncal;
  26. type
  27. tcgcallparanode = class(tcallparanode)
  28. procedure secondcallparan(push_from_left_to_right:boolean;calloption:tproccalloption;
  29. para_alignment,para_offset : longint);override;
  30. end;
  31. tcgcallnode = class(tcallnode)
  32. protected
  33. funcretref : treference;
  34. refcountedtemp : treference;
  35. procedure handle_return_value(inlined,extended_new:boolean);
  36. {# This routine is used to push the current frame pointer
  37. on the stack. This is used in nested routines where the
  38. value of the frame pointer is always pushed as an extra
  39. parameter.
  40. The default handling is the standard handling used on
  41. most stack based machines, where the frame pointer is
  42. the first invisible parameter.
  43. }
  44. procedure load_framepointer;virtual;
  45. procedure extra_interrupt_code;virtual;
  46. public
  47. procedure pass_2;override;
  48. end;
  49. tcgprocinlinenode = class(tprocinlinenode)
  50. procedure pass_2;override;
  51. end;
  52. implementation
  53. uses
  54. systems,
  55. cutils,verbose,globals,
  56. symconst,symbase,symsym,symtable,defutil,paramgr,
  57. {$ifdef GDB}
  58. {$ifdef delphi}
  59. sysutils,
  60. {$else}
  61. strings,
  62. {$endif}
  63. gdb,
  64. {$endif GDB}
  65. cginfo,cgbase,pass_2,
  66. cpuinfo,cpupi,aasmbase,aasmtai,aasmcpu,
  67. nmem,nld,ncnv,
  68. {$ifdef i386}
  69. cga,
  70. {$endif i386}
  71. cg64f32,ncgutil,cgobj,tgobj,regvars,rgobj,rgcpu,cgcpu;
  72. {*****************************************************************************
  73. TCGCALLPARANODE
  74. *****************************************************************************}
  75. procedure tcgcallparanode.secondcallparan(push_from_left_to_right:boolean;calloption:tproccalloption;para_alignment,para_offset : longint);
  76. {$ifndef VS_HIDDEN}
  77. { goes to pass 1 }
  78. procedure maybe_push_high;
  79. begin
  80. { open array ? }
  81. { defcoll.data can be nil for read/write }
  82. if assigned(paraitem.paratype.def) and
  83. assigned(hightree) then
  84. begin
  85. secondpass(hightree);
  86. { this is a longint anyway ! }
  87. push_value_para(hightree,calloption,para_offset,4,paraitem.paraloc);
  88. end;
  89. end;
  90. {$endif VS_HIDDEN}
  91. var
  92. otlabel,oflabel : tasmlabel;
  93. { temporary variables: }
  94. tempdeftype : tdeftype;
  95. tmpreg : tregister;
  96. href : treference;
  97. begin
  98. { push from left to right if specified }
  99. if push_from_left_to_right and assigned(right) then
  100. begin
  101. if (nf_varargs_para in flags) then
  102. tcallparanode(right).secondcallparan(push_from_left_to_right,
  103. calloption,para_alignment,para_offset)
  104. else
  105. tcallparanode(right).secondcallparan(push_from_left_to_right,
  106. calloption,para_alignment,para_offset);
  107. end;
  108. otlabel:=truelabel;
  109. oflabel:=falselabel;
  110. objectlibrary.getlabel(truelabel);
  111. objectlibrary.getlabel(falselabel);
  112. secondpass(left);
  113. { handle varargs first, because defcoll is not valid }
  114. if (nf_varargs_para in flags) then
  115. begin
  116. if paramanager.push_addr_param(left.resulttype.def,calloption) then
  117. begin
  118. inc(pushedparasize,4);
  119. cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.paraloc);
  120. location_release(exprasmlist,left.location);
  121. end
  122. else
  123. push_value_para(left,calloption,para_offset,para_alignment,paraitem.paraloc);
  124. end
  125. { filter array constructor with c styled args }
  126. else if is_array_constructor(left.resulttype.def) and (nf_cargs in left.flags) then
  127. begin
  128. { nothing, everything is already pushed }
  129. end
  130. { in codegen.handleread.. paraitem.data is set to nil }
  131. else if assigned(paraitem.paratype.def) and
  132. (paraitem.paratype.def.deftype=formaldef) then
  133. begin
  134. { allow passing of a constant to a const formaldef }
  135. if (paraitem.paratyp=vs_const) and
  136. (left.location.loc=LOC_CONSTANT) then
  137. location_force_mem(exprasmlist,left.location);
  138. { allow @var }
  139. inc(pushedparasize,4);
  140. if (left.nodetype=addrn) and
  141. (not(nf_procvarload in left.flags)) then
  142. begin
  143. if calloption=pocall_inline then
  144. begin
  145. reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
  146. cg.a_load_loc_ref(exprasmlist,left.location,href);
  147. end
  148. else
  149. cg.a_param_loc(exprasmlist,left.location,paraitem.paraloc);
  150. location_release(exprasmlist,left.location);
  151. end
  152. else
  153. begin
  154. if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
  155. begin
  156. CGMessage(type_e_mismatch)
  157. end
  158. else
  159. begin
  160. if calloption=pocall_inline then
  161. begin
  162. tmpreg:=cg.get_scratch_reg_address(exprasmlist);
  163. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  164. reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
  165. cg.a_load_reg_ref(exprasmlist,OS_ADDR,tmpreg,href);
  166. cg.free_scratch_reg(exprasmlist,tmpreg);
  167. end
  168. else
  169. cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.paraloc);
  170. location_release(exprasmlist,left.location);
  171. end;
  172. end;
  173. end
  174. { handle call by reference parameter }
  175. else if (paraitem.paratyp in [vs_var,vs_out]) then
  176. begin
  177. if (left.location.loc<>LOC_REFERENCE) then
  178. begin
  179. { passing self to a var parameter is allowed in
  180. TP and delphi }
  181. if not((left.location.loc=LOC_CREFERENCE) and
  182. (left.nodetype=selfn)) then
  183. internalerror(200106041);
  184. end;
  185. {$ifdef unused}
  186. if not push_from_left_to_right then
  187. {$endif unused}
  188. {$ifndef VS_HIDDEN}
  189. maybe_push_high;
  190. {$endif VS_HIDDEN}
  191. if (paraitem.paratyp=vs_out) and
  192. assigned(paraitem.paratype.def) and
  193. not is_class(paraitem.paratype.def) and
  194. paraitem.paratype.def.needs_inittable then
  195. cg.g_finalize(exprasmlist,paraitem.paratype.def,left.location.reference,false);
  196. inc(pushedparasize,4);
  197. if calloption=pocall_inline then
  198. begin
  199. tmpreg:=cg.get_scratch_reg_address(exprasmlist);
  200. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  201. reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
  202. cg.a_load_reg_ref(exprasmlist,OS_ADDR,tmpreg,href);
  203. cg.free_scratch_reg(exprasmlist,tmpreg);
  204. end
  205. else
  206. cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.paraloc);
  207. location_release(exprasmlist,left.location);
  208. {$ifdef unused}
  209. if push_from_left_to_right then
  210. maybe_push_high;
  211. {$endif unused}
  212. end
  213. else
  214. begin
  215. tempdeftype:=resulttype.def.deftype;
  216. if tempdeftype=filedef then
  217. CGMessage(cg_e_file_must_call_by_reference);
  218. { open array must always push the address, this is needed to
  219. also push addr of small open arrays and with cdecl functions (PFV) }
  220. if (
  221. assigned(paraitem.paratype.def) and
  222. (is_open_array(paraitem.paratype.def) or
  223. is_array_of_const(paraitem.paratype.def))
  224. ) or
  225. (
  226. paramanager.push_addr_param(resulttype.def,calloption)
  227. ) then
  228. begin
  229. if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
  230. begin
  231. { allow passing nil to a procvardef (methodpointer) }
  232. (* if (left.nodetype=typeconvn) and
  233. (left.resulttype.def.deftype=procvardef) and
  234. (ttypeconvnode(left).left.nodetype=niln) then
  235. *)
  236. if (left.location.size <> OS_NO) then
  237. begin
  238. tg.GetTemp(exprasmlist,tcgsize2size[left.location.size],tt_normal,href);
  239. if not (left.location.size in [OS_64,OS_S64]) then
  240. cg.a_load_loc_ref(exprasmlist,left.location,href)
  241. else
  242. cg64.a_load64_loc_ref(exprasmlist,left.location,href);
  243. location_reset(left.location,LOC_REFERENCE,left.location.size);
  244. left.location.reference:=href;
  245. end
  246. else
  247. internalerror(200204011);
  248. end;
  249. {$ifdef unused}
  250. if not push_from_left_to_right then
  251. {$endif unused}
  252. {$ifndef VS_HIDDEN}
  253. maybe_push_high;
  254. {$endif VS_HIDDEN}
  255. inc(pushedparasize,4);
  256. if calloption=pocall_inline then
  257. begin
  258. tmpreg:=cg.get_scratch_reg_address(exprasmlist);
  259. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  260. reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
  261. cg.a_load_reg_ref(exprasmlist,OS_ADDR,tmpreg,href);
  262. cg.free_scratch_reg(exprasmlist,tmpreg);
  263. end
  264. else
  265. cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.paraloc);
  266. location_release(exprasmlist,left.location);
  267. {$ifdef unused}
  268. if push_from_left_to_right then
  269. maybe_push_high;
  270. {$endif unused}
  271. end
  272. else
  273. begin
  274. push_value_para(left,calloption,
  275. para_offset,para_alignment,paraitem.paraloc);
  276. end;
  277. end;
  278. truelabel:=otlabel;
  279. falselabel:=oflabel;
  280. { push from right to left }
  281. if not push_from_left_to_right and assigned(right) then
  282. begin
  283. if (nf_varargs_para in flags) then
  284. tcallparanode(right).secondcallparan(push_from_left_to_right,
  285. calloption,para_alignment,para_offset)
  286. else
  287. tcallparanode(right).secondcallparan(push_from_left_to_right,
  288. calloption,para_alignment,para_offset);
  289. end;
  290. end;
  291. {*****************************************************************************
  292. TCGCALLNODE
  293. *****************************************************************************}
  294. procedure tcgcallnode.extra_interrupt_code;
  295. var r:Tregister;
  296. begin
  297. {$ifdef i386}
  298. { if the i386 ever uses tcgcal, we've to move this into an overriden method }
  299. emit_none(A_PUSHF,S_L);
  300. r.enum:=R_CS;
  301. emit_reg(A_PUSH,S_L,r);
  302. {$endif i386}
  303. end;
  304. procedure tcgcallnode.load_framepointer;
  305. var href : treference;
  306. hregister : tregister;
  307. i: integer;
  308. begin
  309. { this routine is itself not nested }
  310. if lexlevel=(tprocdef(procdefinition).parast.symtablelevel) then
  311. begin
  312. reference_reset_base(href,procinfo.framepointer,procinfo.framepointer_offset);
  313. cg.a_param_ref(exprasmlist,OS_ADDR,href,paramanager.getintparaloc(1));
  314. end
  315. { one nesting level }
  316. else if (lexlevel=(tprocdef(procdefinition).parast.symtablelevel)-1) then
  317. begin
  318. cg.a_param_reg(exprasmlist,OS_ADDR,procinfo.framepointer,paramanager.getintparaloc(1));
  319. end
  320. { very complex nesting level ... }
  321. else if (lexlevel>(tprocdef(procdefinition).parast.symtablelevel)) then
  322. begin
  323. hregister:=rg.getaddressregister(exprasmlist);
  324. reference_reset_base(href,procinfo.framepointer,procinfo.framepointer_offset);
  325. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister);
  326. for i:=(tprocdef(procdefinition).parast.symtablelevel) to lexlevel-1 do
  327. begin
  328. reference_reset_base(href,hregister,procinfo.framepointer_offset);
  329. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister);
  330. end;
  331. cg.a_param_reg(exprasmlist,OS_ADDR,hregister,paramanager.getintparaloc(1));
  332. rg.ungetaddressregister(exprasmlist,hregister);
  333. end;
  334. end;
  335. procedure tcgcallnode.handle_return_value(inlined,extended_new:boolean);
  336. var
  337. cgsize : tcgsize;
  338. r,hregister : tregister;
  339. begin
  340. { structured results are easy to handle.... }
  341. { needed also when result_no_used !! }
  342. if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  343. begin
  344. location_reset(location,LOC_CREFERENCE,def_cgsize(resulttype.def));
  345. location.reference.symbol:=nil;
  346. location.reference:=funcretref;
  347. end
  348. else
  349. { ansi/widestrings must be registered, so we can dispose them }
  350. if is_ansistring(resulttype.def) or
  351. is_widestring(resulttype.def) then
  352. begin
  353. location_reset(location,LOC_CREFERENCE,OS_ADDR);
  354. location.reference:=refcountedtemp;
  355. r.enum:=accumulator;
  356. cg.a_reg_alloc(exprasmlist,r);
  357. cg.a_load_reg_ref(exprasmlist,OS_ADDR,r,location.reference);
  358. cg.a_reg_dealloc(exprasmlist,r);
  359. end
  360. else
  361. { we have only to handle the result if it is used }
  362. if (nf_return_value_used in flags) then
  363. begin
  364. case resulttype.def.deftype of
  365. enumdef,
  366. orddef :
  367. begin
  368. cgsize:=def_cgsize(resulttype.def);
  369. { an object constructor is a function with boolean result }
  370. if (inlined or (right=nil)) and
  371. (procdefinition.proctypeoption=potype_constructor) then
  372. begin
  373. {$ifdef x86}
  374. if extended_new then
  375. cgsize:=OS_INT
  376. else
  377. begin
  378. cgsize:=OS_NO;
  379. { this fails if popsize > 0 PM }
  380. location_reset(location,LOC_FLAGS,OS_NO);
  381. location.resflags:=F_NE;
  382. end;
  383. {$else x86}
  384. cgsize:=OS_INT
  385. {$endif x86}
  386. end;
  387. if cgsize<>OS_NO then
  388. begin
  389. location_reset(location,LOC_REGISTER,cgsize);
  390. r.enum:=accumulator;
  391. hregister.enum:=accumulatorhigh;
  392. cg.a_reg_alloc(exprasmlist,r);
  393. {$ifndef cpu64bit}
  394. if cgsize in [OS_64,OS_S64] then
  395. begin
  396. cg.a_reg_alloc(exprasmlist,hregister);
  397. location.registerhigh:=rg.getexplicitregisterint(exprasmlist,hregister.enum);
  398. location.registerlow:=rg.getexplicitregisterint(exprasmlist,r.enum);
  399. cg64.a_load64_reg_reg(exprasmlist,joinreg64(r,hregister),
  400. location.register64);
  401. end
  402. else
  403. {$endif cpu64bit}
  404. begin
  405. location.register:=rg.getexplicitregisterint(exprasmlist,r.enum);
  406. hregister:=rg.makeregsize(r,cgsize);
  407. location.register:=rg.makeregsize(location.register,cgsize);
  408. cg.a_load_reg_reg(exprasmlist,cgsize,cgsize,hregister,location.register);
  409. end;
  410. end;
  411. end;
  412. floatdef :
  413. begin
  414. location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
  415. location.register.enum:=fpu_result_reg;
  416. {$ifdef x86}
  417. inc(trgcpu(rg).fpuvaroffset);
  418. {$endif x86}
  419. end;
  420. {$ifdef TEST_WIN32_RECORDS}
  421. recorddef :
  422. begin
  423. if (target_info.system=system_i386_win32) then
  424. begin
  425. location_reset(location,LOC_REFERENCE,def_cgsize(resulttype.def));
  426. tg.GetTemp(exprasmlist,resulttype.size,tt_normal,location);
  427. {$ifndef cpu64bit}
  428. if cgsize in [OS_64,OS_S64] then
  429. cg64.a_load64_reg_loc(exprasmlist,joinreg64(accumulator,accumulatorhigh),location)
  430. else
  431. {$endif cpu64bit}
  432. cg.a_load_reg_loc(exprasmlist,accumulator,location);
  433. end
  434. else
  435. internalerror(200211141);
  436. end;
  437. {$endif TEST_WIN32_RECORDS}
  438. else
  439. begin
  440. location_reset(location,LOC_REGISTER,OS_INT);
  441. location.register:=rg.getexplicitregisterint(exprasmlist,accumulator);
  442. r.enum:=accumulator;
  443. cg.a_load_reg_reg(exprasmlist,OS_INT,OS_INT,r,location.register);
  444. end;
  445. end;
  446. end;
  447. end;
  448. procedure tcgcallnode.pass_2;
  449. var
  450. regs_to_push : tregisterset;
  451. unusedstate: pointer;
  452. pushed : tpushedsaved;
  453. tmpreg : tregister;
  454. hregister : tregister;
  455. hregister64 : tregister64;
  456. oldpushedparasize : longint;
  457. { true if ESI must be loaded again after the subroutine }
  458. loadesi : boolean;
  459. { true if a virtual method must be called directly }
  460. no_virtual_call : boolean;
  461. { true if we produce a con- or destrutor in a call }
  462. is_con_or_destructor : boolean;
  463. { true if a constructor is called again }
  464. extended_new : boolean;
  465. { adress returned from an I/O-error }
  466. iolabel : tasmlabel;
  467. { lexlevel count }
  468. i : longint;
  469. { help reference pointer }
  470. href : treference;
  471. hrefvmt : treference;
  472. hp : tnode;
  473. pp : tbinarynode;
  474. params : tnode;
  475. inlined : boolean;
  476. inlinecode : tprocinlinenode;
  477. store_parast_fixup,
  478. para_alignment,
  479. para_offset : longint;
  480. cgsize : tcgsize;
  481. { instruction for alignement correction }
  482. { corr : paicpu;}
  483. { we must pop this size also after !! }
  484. { must_pop : boolean; }
  485. pop_size : longint;
  486. {$ifdef OPTALIGN}
  487. pop_esp : boolean;
  488. push_size : longint;
  489. {$endif OPTALIGN}
  490. pop_allowed : boolean;
  491. release_tmpreg : boolean;
  492. constructorfailed : tasmlabel;
  493. resultloc : tparalocation;
  494. returnref,
  495. pararef : treference;
  496. r,r2:Tregister;
  497. label
  498. dont_call;
  499. begin
  500. extended_new:=false;
  501. iolabel:=nil;
  502. inlinecode:=nil;
  503. inlined:=false;
  504. loadesi:=true;
  505. no_virtual_call:=false;
  506. rg.saveunusedstate(unusedstate);
  507. { if we allocate the temp. location for ansi- or widestrings }
  508. { already here, we avoid later a push/pop }
  509. if is_widestring(resulttype.def) then
  510. begin
  511. tg.GetTemp(exprasmlist,pointer_size,tt_widestring,refcountedtemp);
  512. cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp);
  513. end
  514. else if is_ansistring(resulttype.def) then
  515. begin
  516. tg.GetTemp(exprasmlist,pointer_size,tt_ansistring,refcountedtemp);
  517. cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp);
  518. end;
  519. if (procdefinition.proccalloption in [pocall_cdecl,pocall_cppdecl,pocall_stdcall]) then
  520. para_alignment:=4
  521. else
  522. para_alignment:=aktalignment.paraalign;
  523. if not assigned(procdefinition) then
  524. exit;
  525. { Deciding whether we may still need the parameters happens next (JM) }
  526. if assigned(left) then
  527. params:=left.getcopy
  528. else
  529. params := nil;
  530. if (procdefinition.proccalloption=pocall_inline) then
  531. begin
  532. inlined:=true;
  533. inlinecode:=tprocinlinenode(right);
  534. right:=nil;
  535. { set it to the same lexical level as the local symtable, becuase
  536. the para's are stored there }
  537. tprocdef(procdefinition).parast.symtablelevel:=aktprocdef.localst.symtablelevel;
  538. if assigned(params) then
  539. begin
  540. inlinecode.para_size:=tprocdef(procdefinition).para_size(para_alignment);
  541. tg.GetTemp(exprasmlist,inlinecode.para_size,tt_persistant,pararef);
  542. inlinecode.para_offset:=pararef.offset;
  543. end;
  544. store_parast_fixup:=tprocdef(procdefinition).parast.address_fixup;
  545. tprocdef(procdefinition).parast.address_fixup:=inlinecode.para_offset;
  546. {$ifdef extdebug}
  547. Comment(V_debug,
  548. 'inlined parasymtable is at offset '
  549. +tostr(tprocdef(procdefinition).parast.address_fixup));
  550. exprasmList.concat(tai_comment.Create(
  551. strpnew('inlined parasymtable is at offset '
  552. +tostr(tprocdef(procdefinition).parast.address_fixup))));
  553. {$endif extdebug}
  554. end;
  555. { only if no proc var }
  556. if inlined or
  557. not(assigned(right)) then
  558. is_con_or_destructor:=(procdefinition.proctypeoption in [potype_constructor,potype_destructor]);
  559. { proc variables destroy all registers }
  560. if (inlined or
  561. (right=nil)) and
  562. { virtual methods too }
  563. not(po_virtualmethod in procdefinition.procoptions) then
  564. begin
  565. if (cs_check_io in aktlocalswitches) and
  566. (po_iocheck in procdefinition.procoptions) and
  567. not(po_iocheck in aktprocdef.procoptions) then
  568. begin
  569. objectlibrary.getaddrlabel(iolabel);
  570. cg.a_label(exprasmlist,iolabel);
  571. end
  572. else
  573. iolabel:=nil;
  574. { save all used registers and possible registers
  575. used for the return value }
  576. regs_to_push := tprocdef(procdefinition).usedregisters;
  577. if (not is_void(resulttype.def)) and
  578. (not paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption)) then
  579. begin
  580. include(regs_to_push,accumulator);
  581. {$ifndef cpu64bit}
  582. if resulttype.def.size>sizeof(aword) then
  583. include(regs_to_push,accumulatorhigh);
  584. {$endif cpu64bit}
  585. end;
  586. rg.saveusedregisters(exprasmlist,pushed,regs_to_push);
  587. { give used registers through }
  588. rg.usedinproc:=rg.usedinproc + tprocdef(procdefinition).usedregisters;
  589. end
  590. else
  591. begin
  592. regs_to_push := all_registers;
  593. rg.saveusedregisters(exprasmlist,pushed,regs_to_push);
  594. rg.usedinproc:=all_registers;
  595. { no IO check for methods and procedure variables }
  596. iolabel:=nil;
  597. end;
  598. { generate the code for the parameter and push them }
  599. oldpushedparasize:=pushedparasize;
  600. pushedparasize:=0;
  601. pop_size:=0;
  602. {$ifdef dummy}
  603. { no inc esp for inlined procedure
  604. and for objects constructors PM }
  605. if inlined or
  606. ((procdefinition.proctypeoption=potype_constructor) and
  607. { quick'n'dirty check if it is a class or an object }
  608. (resulttype.def.deftype=orddef)) then
  609. pop_allowed:=false
  610. else
  611. pop_allowed:=true;
  612. if pop_allowed then
  613. begin
  614. { Old pushedsize aligned on 4 ? }
  615. i:=oldpushedparasize and 3;
  616. if i>0 then
  617. inc(pop_size,4-i);
  618. { This parasize aligned on 4 ? }
  619. i:=procdefinition.para_size(para_alignment) and 3;
  620. if i>0 then
  621. inc(pop_size,4-i);
  622. { insert the opcode and update pushedparasize }
  623. { never push 4 or more !! }
  624. pop_size:=pop_size mod 4;
  625. if pop_size>0 then
  626. begin
  627. inc(pushedparasize,pop_size);
  628. cg.a_const_reg(A_SUB,S_L,pop_size,R_ESP);
  629. {$ifdef GDB}
  630. if (cs_debuginfo in aktmoduleswitches) and
  631. (exprasmList.first=exprasmList.last) then
  632. exprasmList.concat(Tai_force_line.Create);
  633. {$endif GDB}
  634. end;
  635. end;
  636. {$endif dummy}
  637. {$ifdef OPTALIGN}
  638. if pop_allowed and (cs_align in aktglobalswitches) then
  639. begin
  640. pop_esp:=true;
  641. push_size:=procdefinition.para_size(para_alignment);
  642. { !!!! here we have to take care of return type, self
  643. and nested procedures
  644. }
  645. inc(push_size,12);
  646. r.enum:=R_ESP:
  647. r2.enum:=R_EDI;
  648. emit_reg_reg(A_MOV,S_L,r,r2);
  649. if (push_size mod 8)=0 then
  650. emit_const_reg(A_AND,S_L,$fffffff8,r)
  651. else
  652. begin
  653. emit_const_reg(A_SUB,S_L,push_size,r);
  654. emit_const_reg(A_AND,S_L,$fffffff8,r);
  655. emit_const_reg(A_SUB,S_L,push_size,r);
  656. end;
  657. emit_reg(A_PUSH,S_L,r2);
  658. end
  659. else
  660. pop_esp:=false;
  661. {$endif OPTALIGN}
  662. { Push parameters }
  663. if assigned(params) then
  664. begin
  665. { be found elsewhere }
  666. if inlined then
  667. para_offset:=tprocdef(procdefinition).parast.address_fixup+
  668. tprocdef(procdefinition).parast.datasize
  669. else
  670. para_offset:=0;
  671. if not(inlined) and
  672. assigned(right) then
  673. tcallparanode(params).secondcallparan(
  674. { TParaItem(tabstractprocdef(right.resulttype.def).Para.first), }
  675. (po_leftright in procdefinition.procoptions),procdefinition.proccalloption,
  676. para_alignment,para_offset)
  677. else
  678. tcallparanode(params).secondcallparan(
  679. { TParaItem(procdefinition.Para.first), }
  680. (po_leftright in procdefinition.procoptions),procdefinition.proccalloption,
  681. para_alignment,para_offset);
  682. end;
  683. { Allocate return value for inlined routines }
  684. if inlined and
  685. (resulttype.def.size>0) then
  686. begin
  687. tg.GetTemp(exprasmlist,Align(resulttype.def.size,aktalignment.paraalign),tt_persistant,returnref);
  688. inlinecode.retoffset:=returnref.offset;
  689. end;
  690. { Allocate return value when returned in argument }
  691. if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  692. begin
  693. if assigned(funcretrefnode) then
  694. begin
  695. secondpass(funcretrefnode);
  696. if codegenerror then
  697. exit;
  698. if (funcretrefnode.location.loc<>LOC_REFERENCE) then
  699. internalerror(200204246);
  700. funcretref:=funcretrefnode.location.reference;
  701. end
  702. else
  703. begin
  704. if inlined then
  705. begin
  706. tg.GetTemp(exprasmlist,resulttype.def.size,tt_persistant,funcretref);
  707. {$ifdef extdebug}
  708. Comment(V_debug,'function return value is at offset '
  709. +tostr(funcretref.offset));
  710. exprasmlist.concat(tai_comment.create(
  711. strpnew('function return value is at offset '
  712. +tostr(funcretref.offset))));
  713. {$endif extdebug}
  714. end
  715. else
  716. tg.GetTemp(exprasmlist,resulttype.def.size,tt_normal,funcretref);
  717. end;
  718. { This must not be counted for C code
  719. complex return address is removed from stack
  720. by function itself ! }
  721. {$ifdef OLD_C_STACK}
  722. inc(pushedparasize,4); { lets try without it PM }
  723. {$endif not OLD_C_STACK}
  724. if inlined then
  725. begin
  726. hregister:=cg.get_scratch_reg_address(exprasmlist);
  727. cg.a_loadaddr_ref_reg(exprasmlist,funcretref,hregister);
  728. reference_reset_base(href,procinfo.framepointer,inlinecode.retoffset);
  729. cg.a_load_reg_ref(exprasmlist,OS_ADDR,hregister,href);
  730. cg.free_scratch_reg(exprasmlist,hregister);
  731. end
  732. else
  733. cg.a_paramaddr_ref(exprasmlist,funcretref,
  734. paramanager.getfuncretparaloc(procdefinition));
  735. end;
  736. { procedure variable or normal function call ? }
  737. if inlined or
  738. (right=nil) then
  739. begin
  740. { Normal function call }
  741. {$ifdef dummy}
  742. { overloaded operator has no symtable }
  743. { push self }
  744. if assigned(symtableproc) and
  745. (symtableproc.symtabletype=withsymtable) then
  746. begin
  747. { dirty trick to avoid the secondcall below }
  748. methodpointer:=ccallparanode.create(nil,nil);
  749. location_reset(methodpointer.location,LOC_REGISTER,OS_ADDR);
  750. rg.getexplicitregisterint(exprasmlist,R_ESI);
  751. methodpointer.location.register:=R_ESI;
  752. { ARGHHH this is wrong !!!
  753. if we can init from base class for a child
  754. class that the wrong VMT will be
  755. transfered to constructor !! }
  756. methodpointer.resulttype:=
  757. twithnode(twithsymtable(symtableproc).withnode).left.resulttype;
  758. { make a reference }
  759. href:=twithnode(twithsymtable(symtableproc).withnode).withreference;
  760. if ((not(nf_islocal in twithnode(twithsymtable(symtableproc).withnode).flags)) and
  761. (not twithsymtable(symtableproc).direct_with)) or
  762. is_class_or_interface(methodpointer.resulttype.def) then
  763. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,self_pointer_reg)
  764. else
  765. cg.a_loadaddr_ref_reg(exprasmlist,href,self_pointer_reg);
  766. end;
  767. { push self }
  768. if assigned(symtableproc) and
  769. ((symtableproc.symtabletype=objectsymtable) or
  770. (symtableproc.symtabletype=withsymtable)) then
  771. begin
  772. if assigned(methodpointer) then
  773. begin
  774. {
  775. if methodpointer^.resulttype.def=classrefdef then
  776. begin
  777. two possibilities:
  778. 1. constructor
  779. 2. class method
  780. end
  781. else }
  782. begin
  783. case methodpointer.nodetype of
  784. typen:
  785. begin
  786. { direct call to inherited method }
  787. if (po_abstractmethod in procdefinition.procoptions) then
  788. begin
  789. CGMessage(cg_e_cant_call_abstract_method);
  790. goto dont_call;
  791. end;
  792. { generate no virtual call }
  793. no_virtual_call:=true;
  794. if (sp_static in symtableprocentry.symoptions) then
  795. begin
  796. { well lets put the VMT address directly into ESI }
  797. { it is kind of dirty but that is the simplest }
  798. { way to accept virtual static functions (PM) }
  799. loadesi:=true;
  800. { if no VMT just use $0 bug0214 PM }
  801. rg.getexplicitregisterint(exprasmlist,R_ESI);
  802. if not(oo_has_vmt in tobjectdef(methodpointer.resulttype.def).objectoptions) then
  803. cg.a_load_const_reg(exprasmlist,OS_ADDR,0,self_pointer_reg)
  804. else
  805. begin
  806. reference_reset_symbol(href,objectlibrary.newasmsymbol(tobjectdef(methodpointer.resulttype.def).vmt_mangledname),0);
  807. cg.a_loadaddr_ref_reg(exprasmlist,href,self_pointer_reg);
  808. end;
  809. { emit_reg(A_PUSH,S_L,R_ESI);
  810. this is done below !! }
  811. end
  812. else
  813. { this is a member call, so ESI isn't modfied }
  814. loadesi:=false;
  815. { a class destructor needs a flag }
  816. if is_class(tobjectdef(methodpointer.resulttype.def)) and
  817. (procdefinition.proctypeoption=potype_destructor) then
  818. begin
  819. cg.a_param_const(exprasmlist,OS_ADDR,0,2);
  820. cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,1);
  821. end;
  822. if not(is_con_or_destructor and
  823. is_class(methodpointer.resulttype.def) and
  824. (procdefinition.proctypeoption in [potype_constructor,potype_destructor])
  825. ) then
  826. cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,1);
  827. { if an inherited con- or destructor should be }
  828. { called in a con- or destructor then a warning }
  829. { will be made }
  830. { con- and destructors need a pointer to the vmt }
  831. if is_con_or_destructor and
  832. is_object(methodpointer.resulttype.def) and
  833. assigned(aktprocdef) then
  834. begin
  835. if not(aktprocdef.proctypeoption in
  836. [potype_constructor,potype_destructor]) then
  837. CGMessage(cg_w_member_cd_call_from_method);
  838. end;
  839. { class destructors get there flag above }
  840. { constructor flags ? }
  841. if is_con_or_destructor and
  842. not(
  843. is_class(methodpointer.resulttype.def) and
  844. assigned(aktprocdef) and
  845. (aktprocdef.proctypeoption=potype_destructor)) then
  846. begin
  847. { a constructor needs also a flag }
  848. if is_class(methodpointer.resulttype.def) then
  849. cg.a_param_const(exprasmlist,OS_ADDR,0,2);
  850. cg.a_param_const(exprasmlist,OS_ADDR,0,1);
  851. end;
  852. end;
  853. hnewn:
  854. begin
  855. { extended syntax of new }
  856. { ESI must be zero }
  857. rg.getexplicitregisterint(exprasmlist,R_ESI);
  858. cg.a_load_const_reg(exprasmlist,OS_ADDR,0,self_pointer_reg);
  859. cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,2);
  860. { insert the vmt }
  861. reference_reset_symbol(href,objectlibrary.newasmsymbol(tobjectdef(methodpointer.resulttype.def).vmt_mangledname),0);
  862. cg.a_paramaddr_ref(exprasmlist,href,1);
  863. extended_new:=true;
  864. end;
  865. hdisposen:
  866. begin
  867. secondpass(methodpointer);
  868. { destructor with extended syntax called from dispose }
  869. { hdisposen always deliver LOC_REFERENCE }
  870. rg.getexplicitregisterint(exprasmlist,R_ESI);
  871. emit_ref_reg(A_LEA,S_L,methodpointer.location.reference,R_ESI);
  872. reference_release(exprasmlist,methodpointer.location.reference);
  873. cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,2);
  874. reference_reset_symbol(href,objectlibrary.newasmsymbol(tobjectdef(methodpointer.resulttype.def).vmt_mangledname),0);
  875. cg.a_paramaddr_ref(exprasmlist,href,1);
  876. end;
  877. else
  878. begin
  879. { call to an instance member }
  880. if (symtableproc.symtabletype<>withsymtable) then
  881. begin
  882. secondpass(methodpointer);
  883. rg.getexplicitregisterint(exprasmlist,R_ESI);
  884. case methodpointer.location.loc of
  885. LOC_CREGISTER,
  886. LOC_REGISTER:
  887. begin
  888. cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,methodpointer.location.register,R_ESI);
  889. rg.ungetregisterint(exprasmlist,methodpointer.location.register);
  890. end;
  891. else
  892. begin
  893. if (methodpointer.resulttype.def.deftype=classrefdef) or
  894. is_class_or_interface(methodpointer.resulttype.def) then
  895. cg.a_load_ref_reg(exprasmlist,OS_ADDR,methodpointer.location.reference,R_ESI)
  896. else
  897. cg.a_loadaddr_ref_reg(exprasmlist,methodpointer.location.reference,R_ESI);
  898. reference_release(exprasmlist,methodpointer.location.reference);
  899. end;
  900. end;
  901. end;
  902. { when calling a class method, we have to load ESI with the VMT !
  903. But, not for a class method via self }
  904. if not(po_containsself in procdefinition.procoptions) then
  905. begin
  906. if (po_staticmethod in procdefinition.procoptions) or
  907. ((po_classmethod in procdefinition.procoptions) and
  908. not(methodpointer.resulttype.def.deftype=classrefdef)) then
  909. begin
  910. r.enum:=self_pointer_reg;
  911. rg.getexplicitregisterint(exprasmlist,r.enum);
  912. if not(oo_has_vmt in tprocdef(procdefinition)._class.objectoptions) then
  913. cg.a_load_const_reg(exprasmlist,OS_ADDR,0,r)
  914. else
  915. begin
  916. { class method and static methods needs current VMT }
  917. cg.g_maybe_testself(exprasmlist,r);
  918. reference_reset_base(href,r,tprocdef(procdefinition)._class.vmt_offset);
  919. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,r);
  920. cg.g_maybe_testvmt(exprasmlist,r,tprocdef(procdefinition)._class);
  921. end;
  922. end;
  923. { direct call to destructor: remove data }
  924. if (procdefinition.proctypeoption=potype_destructor) and
  925. is_class(methodpointer.resulttype.def) then
  926. cg.a_param_const(exprasmlist,OS_INT,1,1);
  927. { direct call to class constructor, don't allocate memory }
  928. if (procdefinition.proctypeoption=potype_constructor) and
  929. is_class(methodpointer.resulttype.def) then
  930. begin
  931. cg.a_param_const(exprasmlist,OS_INT,0,2);
  932. cg.a_param_const(exprasmlist,OS_INT,0,1);
  933. end
  934. else
  935. begin
  936. { constructor call via classreference => allocate memory }
  937. if (procdefinition.proctypeoption=potype_constructor) and
  938. (methodpointer.resulttype.def.deftype=classrefdef) and
  939. is_class(tclassrefdef(methodpointer.resulttype.def).pointertype.def) then
  940. cg.a_param_const(exprasmlist,OS_INT,1,1);
  941. cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,1);
  942. end;
  943. end;
  944. if is_con_or_destructor then
  945. begin
  946. { classes don't get a VMT pointer pushed }
  947. if is_object(methodpointer.resulttype.def) then
  948. begin
  949. if (procdefinition.proctypeoption=potype_constructor) then
  950. begin
  951. { it's no bad idea, to insert the VMT }
  952. reference_reset_symbol(href,objectlibrary.newasmsymbol(
  953. tobjectdef(methodpointer.resulttype.def).vmt_mangledname),0);
  954. cg.a_paramaddr_ref(exprasmlist,href,1);
  955. end
  956. { destructors haven't to dispose the instance, if this is }
  957. { a direct call }
  958. else
  959. cg.a_param_const(exprasmlist,OS_INT,0,1);
  960. end;
  961. end;
  962. end;
  963. end;
  964. end;
  965. end
  966. else
  967. begin
  968. if (
  969. (po_classmethod in procdefinition.procoptions) and
  970. not(assigned(aktprocdef) and
  971. (po_classmethod in aktprocdef.procoptions))
  972. ) or
  973. (
  974. (po_staticmethod in procdefinition.procoptions) and
  975. not(assigned(aktprocdef) and
  976. (po_staticmethod in aktprocdef.procoptions))
  977. ) then
  978. begin
  979. r.enum:=self_pointer_reg;
  980. rg.getexplicitregisterint(exprasmlist,r.enum);
  981. if not(oo_has_vmt in tprocdef(procdefinition)._class.objectoptions) then
  982. cg.a_load_const_reg(exprasmlist,OS_ADDR,0,r)
  983. else
  984. begin
  985. { class method and static methods needs current VMT }
  986. cg.g_maybe_testself(exprasmlist,r);
  987. reference_reset_base(href,r,tprocdef(procdefinition)._class.vmt_offset);
  988. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,r);
  989. cg.g_maybe_testvmt(exprasmlist,r,tprocdef(procdefinition)._class);
  990. end;
  991. end
  992. else
  993. begin
  994. { member call, ESI isn't modified }
  995. loadesi:=false;
  996. end;
  997. { direct call to destructor: don't remove data! }
  998. if is_class(procinfo._class) then
  999. begin
  1000. if (procdefinition.proctypeoption=potype_destructor) then
  1001. begin
  1002. cg.a_param_const(exprasmlist,OS_INT,0,2);
  1003. cg.a_param_reg(exprasmlist,OS_ADDR,R_ESI,1);
  1004. end
  1005. else if (procdefinition.proctypeoption=potype_constructor) then
  1006. begin
  1007. cg.a_param_const(exprasmlist,OS_INT,0,2);
  1008. cg.a_param_const(exprasmlist,OS_INT,0,1);
  1009. end
  1010. else
  1011. cg.a_param_reg(exprasmlist,OS_ADDR,R_ESI,1);
  1012. end
  1013. else if is_object(procinfo._class) then
  1014. begin
  1015. cg.a_param_reg(exprasmlist,OS_ADDR,R_ESI,1);
  1016. if is_con_or_destructor then
  1017. begin
  1018. if (procdefinition.proctypeoption=potype_constructor) then
  1019. begin
  1020. { it's no bad idea, to insert the VMT }
  1021. reference_reset_symbol(href,objectlibrary.newasmsymbol(procinfo._class.vmt_mangledname),0);
  1022. cg.a_paramaddr_ref(exprasmlist,href,1);
  1023. end
  1024. { destructors haven't to dispose the instance, if this is }
  1025. { a direct call }
  1026. else
  1027. cg.a_param_const(exprasmlist,OS_INT,0,1);
  1028. end;
  1029. end
  1030. else
  1031. Internalerror(200006165);
  1032. end;
  1033. end;
  1034. {$endif dummy}
  1035. { call to BeforeDestruction? }
  1036. if (procdefinition.proctypeoption=potype_destructor) and
  1037. assigned(methodpointer) and
  1038. (methodpointer.nodetype<>typen) and
  1039. is_class(tobjectdef(methodpointer.resulttype.def)) and
  1040. (inlined or
  1041. (right=nil)) then
  1042. begin
  1043. r.enum:=self_pointer_reg;
  1044. cg.a_param_reg(exprasmlist,OS_ADDR,r,paramanager.getintparaloc(1));
  1045. reference_reset_base(href,r,0);
  1046. tmpreg:=cg.get_scratch_reg_address(exprasmlist);
  1047. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,tmpreg);
  1048. reference_reset_base(href,tmpreg,72);
  1049. cg.a_call_ref(exprasmlist,href);
  1050. cg.free_scratch_reg(exprasmlist,tmpreg);
  1051. end;
  1052. {$ifndef SPARC}{We don't need that on SPARC arch!}
  1053. { push base pointer ?}
  1054. { never when inlining, since if necessary, the base pointer }
  1055. { can/will be gottten from the current procedure's symtable }
  1056. { (JM)}
  1057. if not inlined then
  1058. if (lexlevel>=normal_function_level) and assigned(tprocdef(procdefinition).parast) and
  1059. ((tprocdef(procdefinition).parast.symtablelevel)>normal_function_level) then
  1060. load_framepointer;
  1061. {$endif SPARC}
  1062. rg.saveregvars(exprasmlist,regs_to_push);
  1063. {$ifdef dummy}
  1064. if (po_virtualmethod in procdefinition.procoptions) and
  1065. not(no_virtual_call) then
  1066. begin
  1067. { static functions contain the vmt_address in ESI }
  1068. { also class methods }
  1069. { Here it is quite tricky because it also depends }
  1070. { on the methodpointer PM }
  1071. release_tmpreg:=false;
  1072. rg.getexplicitregisterint(exprasmlist,R_ESI);
  1073. if assigned(aktprocdef) then
  1074. begin
  1075. if (((sp_static in aktprocdef.procsym.symoptions) or
  1076. (po_classmethod in aktprocdef.procoptions)) and
  1077. ((methodpointer=nil) or (methodpointer.nodetype=typen)))
  1078. or
  1079. (po_staticmethod in procdefinition.procoptions) or
  1080. ((procdefinition.proctypeoption=potype_constructor) and
  1081. { esi contains the vmt if we call a constructor via a class ref }
  1082. assigned(methodpointer) and
  1083. (methodpointer.resulttype.def.deftype=classrefdef)
  1084. ) or
  1085. { is_interface(tprocdef(procdefinition)._class) or }
  1086. { ESI is loaded earlier }
  1087. (po_classmethod in procdefinition.procoptions) then
  1088. begin
  1089. reference_reset_base(href,R_ESI,0);
  1090. end
  1091. else
  1092. begin
  1093. { this is one point where we need vmt_offset (PM) }
  1094. reference_reset_base(href,R_ESI,tprocdef(procdefinition)._class.vmt_offset);
  1095. cg.a_maybe_testself(exprasmlist);
  1096. tmpreg:=cg.get_scratch_reg_address(exprasmlist);
  1097. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,tmpreg);
  1098. reference_reset_base(href,tmpreg,0);
  1099. release_tmpreg:=true;
  1100. end;
  1101. end
  1102. else
  1103. { aktprocdef should be assigned, also in main program }
  1104. internalerror(12345);
  1105. if tprocdef(procdefinition).extnumber=-1 then
  1106. internalerror(44584);
  1107. href.offset:=tprocdef(procdefinition)._class.vmtmethodoffset(tprocdef(procdefinition).extnumber);
  1108. if not(is_interface(tprocdef(procdefinition)._class)) and
  1109. not(is_cppclass(tprocdef(procdefinition)._class)) then
  1110. cg.g_maybe_testvmt(exprasmlist,href.base,tprocdef(procdefinition)._class);
  1111. cg.a_call_ref(exprasmlist,href);
  1112. if release_tmpreg then
  1113. cg.free_scratch_reg(exprasmlist,tmpreg);
  1114. end
  1115. else
  1116. {$endif dummy}
  1117. if not inlined then
  1118. begin
  1119. { We can call interrupts from within the smae code
  1120. by just pushing the flags and CS PM }
  1121. if (po_interrupt in procdefinition.procoptions) then
  1122. extra_interrupt_code;
  1123. cg.a_call_name(exprasmlist,tprocdef(procdefinition).mangledname);
  1124. end
  1125. else { inlined proc }
  1126. { inlined code is in inlinecode }
  1127. begin
  1128. { process the inlinecode }
  1129. secondpass(tnode(inlinecode));
  1130. { free the args }
  1131. if tprocdef(procdefinition).parast.datasize>0 then
  1132. tg.UnGetTemp(exprasmlist,pararef);
  1133. end;
  1134. end
  1135. else
  1136. { now procedure variable case }
  1137. begin
  1138. secondpass(right);
  1139. if (po_interrupt in procdefinition.procoptions) then
  1140. extra_interrupt_code;
  1141. { procedure of object? }
  1142. if (po_methodpointer in procdefinition.procoptions) then
  1143. begin
  1144. {$ifdef dummy}
  1145. { method pointer can't be in a register }
  1146. hregister:=R_NO;
  1147. { do some hacking if we call a method pointer }
  1148. { which is a class member }
  1149. { else ESI is overwritten ! }
  1150. if (right.location.reference.base=R_ESI) or
  1151. (right.location.reference.index=R_ESI) then
  1152. begin
  1153. reference_release(exprasmlist,right.location.reference);
  1154. hregister:=cg.get_scratch_reg_address(exprasmlist);
  1155. cg.a_load_ref_reg(exprasmlist,OS_ADDR,right.location.reference,hregister);
  1156. end;
  1157. { load self, but not if it's already explicitly pushed }
  1158. if not(po_containsself in procdefinition.procoptions) then
  1159. begin
  1160. { load ESI }
  1161. href:=right.location.reference;
  1162. inc(href.offset,4);
  1163. rg.getexplicitregisterint(exprasmlist,R_ESI);
  1164. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,self_pointer_reg);
  1165. { push self pointer }
  1166. cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,-1);
  1167. end;
  1168. rg.saveregvars(exprasmlist,ALL_REGISTERS);
  1169. if hregister<>R_NO then
  1170. cg.a_call_reg(exprasmlist,hregister)
  1171. else
  1172. cg.a_call_ref(exprasmlist,right.location.reference);
  1173. if hregister<>R_NO then
  1174. cg.free_scratch_reg(exprasmlist,hregister);
  1175. reference_release(exprasmlist,right.location.reference);
  1176. tg.Ungetiftemp(exprasmlist,right.location.reference);
  1177. {$endif dummy}
  1178. end
  1179. else
  1180. begin
  1181. rg.saveregvars(exprasmlist,ALL_REGISTERS);
  1182. cg.a_call_loc(exprasmlist,right.location);
  1183. location_release(exprasmlist,right.location);
  1184. location_freetemp(exprasmlist,right.location);
  1185. end;
  1186. end;
  1187. {$ifdef dummy}
  1188. { this was only for normal functions
  1189. displaced here so we also get
  1190. it to work for procvars PM }
  1191. if (not inlined) and (po_clearstack in procdefinition.procoptions) then
  1192. begin
  1193. { we also add the pop_size which is included in pushedparasize }
  1194. pop_size:=0;
  1195. { better than an add on all processors }
  1196. if pushedparasize=4 then
  1197. begin
  1198. rg.getexplicitregisterint(exprasmlist,R_EDI);
  1199. emit_reg(A_POP,S_L,R_EDI);
  1200. rg.ungetregisterint(exprasmlist,R_EDI);
  1201. end
  1202. { the pentium has two pipes and pop reg is pairable }
  1203. { but the registers must be different! }
  1204. else if (pushedparasize=8) and
  1205. not(cs_littlesize in aktglobalswitches) and
  1206. {$ifdef i386}
  1207. (aktoptprocessor=ClassP5) and
  1208. {$endif}
  1209. (procinfo._class=nil) then
  1210. begin
  1211. rg.getexplicitregisterint(exprasmlist,R_EDI);
  1212. emit_reg(A_POP,S_L,R_EDI);
  1213. rg.ungetregisterint(exprasmlist,R_EDI);
  1214. exprasmList.concat(tai_regalloc.Alloc(R_ESI));
  1215. emit_reg(A_POP,S_L,R_ESI);
  1216. exprasmList.concat(tai_regalloc.DeAlloc(R_ESI));
  1217. end
  1218. else if pushedparasize<>0 then
  1219. emit_const_reg(A_ADD,S_L,pushedparasize,R_ESP);
  1220. end;
  1221. {$endif dummy}
  1222. {$ifdef powerpc}
  1223. { this calculation must be done in pass_1 anyway, so don't worry }
  1224. if tppcprocinfo(procinfo).maxpushedparasize<pushedparasize then
  1225. tppcprocinfo(procinfo).maxpushedparasize:=pushedparasize;
  1226. {$endif powerpc}
  1227. {$ifdef OPTALIGN}
  1228. r.enum:=R_ESP;
  1229. if pop_esp then
  1230. emit_reg(A_POP,S_L,r);
  1231. {$endif OPTALIGN}
  1232. dont_call:
  1233. pushedparasize:=oldpushedparasize;
  1234. rg.restoreunusedstate(unusedstate);
  1235. {$ifdef TEMPREGDEBUG}
  1236. testregisters32;
  1237. {$endif TEMPREGDEBUG}
  1238. { a constructor could be a function with boolean result }
  1239. { if calling constructor called fail we
  1240. must jump directly to quickexitlabel PM
  1241. but only if it is a call of an inherited constructor }
  1242. if (inlined or
  1243. (right=nil)) and
  1244. (procdefinition.proctypeoption=potype_constructor) and
  1245. assigned(methodpointer) and
  1246. (methodpointer.nodetype=typen) and
  1247. (aktprocdef.proctypeoption=potype_constructor) then
  1248. begin
  1249. r.enum:=accumulator;
  1250. cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,r,faillabel);
  1251. end;
  1252. { call to AfterConstruction? }
  1253. if is_class(resulttype.def) and
  1254. (inlined or
  1255. (right=nil)) and
  1256. (procdefinition.proctypeoption=potype_constructor) and
  1257. assigned(methodpointer) and
  1258. (methodpointer.nodetype<>typen) then
  1259. begin
  1260. objectlibrary.getlabel(constructorfailed);
  1261. r.enum:=self_pointer_reg;
  1262. r2.enum:=accumulator;
  1263. cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,r,constructorfailed);
  1264. cg.a_param_reg(exprasmlist,OS_ADDR,r2,paramanager.getintparaloc(1));
  1265. reference_reset_base(href,r,0);
  1266. tmpreg:=cg.get_scratch_reg_address(exprasmlist);
  1267. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,tmpreg);
  1268. reference_reset_base(href,tmpreg,17*pointer_size);
  1269. cg.a_call_ref(exprasmlist,href);
  1270. cg.free_scratch_reg(exprasmlist,tmpreg);
  1271. exprasmList.concat(tai_regalloc.Alloc(r2));
  1272. cg.a_label(exprasmlist,constructorfailed);
  1273. cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,r,r2);
  1274. end;
  1275. { handle function results }
  1276. if (not is_void(resulttype.def)) then
  1277. handle_return_value(inlined,extended_new);
  1278. { perhaps i/o check ? }
  1279. if iolabel<>nil then
  1280. begin
  1281. reference_reset_symbol(href,iolabel,0);
  1282. cg.a_paramaddr_ref(exprasmlist,href,paramanager.getintparaloc(1));
  1283. cg.a_call_name(exprasmlist,'FPC_IOCHECK');
  1284. end;
  1285. {$ifdef i386}
  1286. r.enum:=R_ESP;
  1287. if pop_size>0 then
  1288. emit_const_reg(A_ADD,S_L,pop_size,r);
  1289. {$endif i386}
  1290. { restore registers }
  1291. rg.restoreusedregisters(exprasmlist,pushed);
  1292. { at last, restore instance pointer (SELF) }
  1293. if loadesi then
  1294. cg.g_maybe_loadself(exprasmlist);
  1295. pp:=tbinarynode(params);
  1296. while assigned(pp) do
  1297. begin
  1298. if assigned(pp.left) then
  1299. begin
  1300. location_freetemp(exprasmlist,pp.left.location);
  1301. { process also all nodes of an array of const }
  1302. if pp.left.nodetype=arrayconstructorn then
  1303. begin
  1304. if assigned(tarrayconstructornode(pp.left).left) then
  1305. begin
  1306. hp:=pp.left;
  1307. while assigned(hp) do
  1308. begin
  1309. location_freetemp(exprasmlist,tarrayconstructornode(hp).left.location);
  1310. hp:=tarrayconstructornode(hp).right;
  1311. end;
  1312. end;
  1313. end;
  1314. end;
  1315. pp:=tbinarynode(pp.right);
  1316. end;
  1317. if inlined then
  1318. begin
  1319. if (resulttype.def.size>0) then
  1320. tg.UnGetTemp(exprasmlist,returnref);
  1321. tprocdef(procdefinition).parast.address_fixup:=store_parast_fixup;
  1322. right:=inlinecode;
  1323. end;
  1324. if assigned(params) then
  1325. params.free;
  1326. { from now on the result can be freed normally }
  1327. if inlined and paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  1328. tg.ChangeTempType(exprasmlist,funcretref,tt_normal);
  1329. { if return value is not used }
  1330. if (not(nf_return_value_used in flags)) and (not is_void(resulttype.def)) then
  1331. begin
  1332. if location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
  1333. begin
  1334. { data which must be finalized ? }
  1335. if (resulttype.def.needs_inittable) then
  1336. cg.g_finalize(exprasmlist,resulttype.def,location.reference,false);
  1337. { release unused temp }
  1338. tg.ungetiftemp(exprasmlist,location.reference)
  1339. end
  1340. else if location.loc=LOC_FPUREGISTER then
  1341. begin
  1342. {$ifdef i386}
  1343. { release FPU stack }
  1344. r.enum:=R_ST;
  1345. emit_reg(A_FSTP,S_NO,r);
  1346. {
  1347. dec(trgcpu(rg).fpuvaroffset);
  1348. do NOT decrement as the increment before
  1349. is not called for unused results PM }
  1350. {$endif i386}
  1351. end;
  1352. end;
  1353. end;
  1354. {*****************************************************************************
  1355. TCGPROCINLINENODE
  1356. *****************************************************************************}
  1357. procedure tcgprocinlinenode.pass_2;
  1358. var st : tsymtable;
  1359. oldprocdef : tprocdef;
  1360. ps, i : longint;
  1361. tmpreg: tregister;
  1362. oldprocinfo : tprocinfo;
  1363. oldinlining_procedure,
  1364. nostackframe,make_global : boolean;
  1365. inlineentrycode,inlineexitcode : TAAsmoutput;
  1366. oldexitlabel,oldexit2label,oldquickexitlabel:tasmlabel;
  1367. oldregstate: pointer;
  1368. localsref : treference;
  1369. {$ifdef GDB}
  1370. startlabel,endlabel : tasmlabel;
  1371. pp : pchar;
  1372. mangled_length : longint;
  1373. {$endif GDB}
  1374. begin
  1375. { deallocate the registers used for the current procedure's regvars }
  1376. if assigned(aktprocdef.regvarinfo) then
  1377. begin
  1378. with pregvarinfo(aktprocdef.regvarinfo)^ do
  1379. for i := 1 to maxvarregs do
  1380. if assigned(regvars[i]) then
  1381. store_regvar(exprasmlist,regvars[i].reg);
  1382. rg.saveStateForInline(oldregstate);
  1383. { make sure the register allocator knows what the regvars in the }
  1384. { inlined code block are (JM) }
  1385. rg.resetusableregisters;
  1386. rg.clearregistercount;
  1387. rg.cleartempgen;
  1388. if assigned(inlineprocdef.regvarinfo) then
  1389. with pregvarinfo(inlineprocdef.regvarinfo)^ do
  1390. for i := 1 to maxvarregs do
  1391. if assigned(regvars[i]) then
  1392. begin
  1393. tmpreg:=rg.makeregsize(regvars[i].reg,OS_INT);
  1394. rg.makeregvar(tmpreg);
  1395. end;
  1396. end;
  1397. oldinlining_procedure:=inlining_procedure;
  1398. oldexitlabel:=aktexitlabel;
  1399. oldexit2label:=aktexit2label;
  1400. oldquickexitlabel:=quickexitlabel;
  1401. oldprocdef:=aktprocdef;
  1402. oldprocinfo:=procinfo;
  1403. objectlibrary.getlabel(aktexitlabel);
  1404. objectlibrary.getlabel(aktexit2label);
  1405. { we're inlining a procedure }
  1406. inlining_procedure:=true;
  1407. aktprocdef:=inlineprocdef;
  1408. { clone procinfo, but not the asmlists }
  1409. procinfo:=tprocinfo(cprocinfo.newinstance);
  1410. move(pointer(oldprocinfo)^,pointer(procinfo)^,cprocinfo.InstanceSize);
  1411. procinfo.aktentrycode:=nil;
  1412. procinfo.aktexitcode:=nil;
  1413. procinfo.aktproccode:=nil;
  1414. procinfo.aktlocaldata:=nil;
  1415. { set new procinfo }
  1416. procinfo.return_offset:=retoffset;
  1417. procinfo.para_offset:=para_offset;
  1418. procinfo.no_fast_exit:=false;
  1419. { arg space has been filled by the parent secondcall }
  1420. st:=aktprocdef.localst;
  1421. { set it to the same lexical level }
  1422. st.symtablelevel:=oldprocdef.localst.symtablelevel;
  1423. if st.datasize>0 then
  1424. begin
  1425. tg.GetTemp(exprasmlist,st.datasize,tt_persistant,localsref);
  1426. st.address_fixup:=localsref.offset+st.datasize;
  1427. {$ifdef extdebug}
  1428. Comment(V_debug,'local symtable is at offset '+tostr(st.address_fixup));
  1429. exprasmList.concat(tai_comment.Create(strpnew(
  1430. 'local symtable is at offset '+tostr(st.address_fixup))));
  1431. {$endif extdebug}
  1432. end;
  1433. exprasmList.concat(Tai_Marker.Create(InlineStart));
  1434. {$ifdef extdebug}
  1435. exprasmList.concat(tai_comment.Create(strpnew('Start of inlined proc')));
  1436. {$endif extdebug}
  1437. {$ifdef GDB}
  1438. if (cs_debuginfo in aktmoduleswitches) then
  1439. begin
  1440. objectlibrary.getaddrlabel(startlabel);
  1441. objectlibrary.getaddrlabel(endlabel);
  1442. cg.a_label(exprasmlist,startlabel);
  1443. inlineprocdef.localst.symtabletype:=inlinelocalsymtable;
  1444. inlineprocdef.parast.symtabletype:=inlineparasymtable;
  1445. { Here we must include the para and local symtable info }
  1446. inlineprocdef.concatstabto(withdebuglist);
  1447. { set it back for safety }
  1448. inlineprocdef.localst.symtabletype:=localsymtable;
  1449. inlineprocdef.parast.symtabletype:=parasymtable;
  1450. mangled_length:=length(oldprocdef.mangledname);
  1451. getmem(pp,mangled_length+50);
  1452. strpcopy(pp,'192,0,0,'+startlabel.name);
  1453. if (target_info.use_function_relative_addresses) then
  1454. begin
  1455. strpcopy(strend(pp),'-');
  1456. strpcopy(strend(pp),oldprocdef.mangledname);
  1457. end;
  1458. withdebugList.concat(Tai_stabn.Create(strnew(pp)));
  1459. end;
  1460. {$endif GDB}
  1461. { takes care of local data initialization }
  1462. inlineentrycode:=TAAsmoutput.Create;
  1463. inlineexitcode:=TAAsmoutput.Create;
  1464. ps:=para_size;
  1465. make_global:=false; { to avoid warning }
  1466. genentrycode(inlineentrycode,make_global,0,ps,nostackframe,true);
  1467. if po_assembler in aktprocdef.procoptions then
  1468. inlineentrycode.insert(Tai_marker.Create(asmblockstart));
  1469. exprasmList.concatlist(inlineentrycode);
  1470. secondpass(inlinetree);
  1471. genexitcode(inlineexitcode,0,false,true);
  1472. if po_assembler in aktprocdef.procoptions then
  1473. inlineexitcode.concat(Tai_marker.Create(asmblockend));
  1474. exprasmList.concatlist(inlineexitcode);
  1475. inlineentrycode.free;
  1476. inlineexitcode.free;
  1477. {$ifdef extdebug}
  1478. exprasmList.concat(tai_comment.Create(strpnew('End of inlined proc')));
  1479. {$endif extdebug}
  1480. exprasmList.concat(Tai_Marker.Create(InlineEnd));
  1481. {we can free the local data now, reset also the fixup address }
  1482. if st.datasize>0 then
  1483. begin
  1484. tg.UnGetTemp(exprasmlist,localsref);
  1485. st.address_fixup:=0;
  1486. end;
  1487. { restore procinfo }
  1488. procinfo.free;
  1489. procinfo:=oldprocinfo;
  1490. {$ifdef GDB}
  1491. if (cs_debuginfo in aktmoduleswitches) then
  1492. begin
  1493. cg.a_label(exprasmlist,endlabel);
  1494. strpcopy(pp,'224,0,0,'+endlabel.name);
  1495. if (target_info.use_function_relative_addresses) then
  1496. begin
  1497. strpcopy(strend(pp),'-');
  1498. strpcopy(strend(pp),oldprocdef.mangledname);
  1499. end;
  1500. withdebugList.concat(Tai_stabn.Create(strnew(pp)));
  1501. freemem(pp,mangled_length+50);
  1502. end;
  1503. {$endif GDB}
  1504. { restore }
  1505. aktprocdef:=oldprocdef;
  1506. aktexitlabel:=oldexitlabel;
  1507. aktexit2label:=oldexit2label;
  1508. quickexitlabel:=oldquickexitlabel;
  1509. inlining_procedure:=oldinlining_procedure;
  1510. { reallocate the registers used for the current procedure's regvars, }
  1511. { since they may have been used and then deallocated in the inlined }
  1512. { procedure (JM) }
  1513. if assigned(aktprocdef.regvarinfo) then
  1514. begin
  1515. rg.restoreStateAfterInline(oldregstate);
  1516. end;
  1517. end;
  1518. begin
  1519. ccallparanode:=tcgcallparanode;
  1520. ccallnode:=tcgcallnode;
  1521. cprocinlinenode:=tcgprocinlinenode;
  1522. end.
  1523. {
  1524. $Log$
  1525. Revision 1.37 2003-02-12 22:10:07 carl
  1526. * load_frame_pointer is now generic
  1527. * change fpu emulation routine names
  1528. Revision 1.36 2003/01/30 21:46:57 peter
  1529. * self fixes for static methods (merged)
  1530. Revision 1.35 2003/01/22 20:45:15 mazen
  1531. * making math code in RTL compiling.
  1532. *NB : This does NOT mean necessary that it will generate correct code!
  1533. Revision 1.34 2003/01/17 12:03:45 daniel
  1534. * Optalign conditional code adapted to record Tregister
  1535. Revision 1.33 2003/01/08 18:43:56 daniel
  1536. * Tregister changed into a record
  1537. Revision 1.32 2002/12/15 22:50:00 florian
  1538. + some stuff for the new hidden parameter handling added
  1539. Revision 1.31 2002/12/15 21:30:12 florian
  1540. * tcallnode.paraitem introduced, all references to defcoll removed
  1541. Revision 1.30 2002/11/27 20:04:39 peter
  1542. * cdecl array of const fixes
  1543. Revision 1.29 2002/11/25 17:43:17 peter
  1544. * splitted defbase in defutil,symutil,defcmp
  1545. * merged isconvertable and is_equal into compare_defs(_ext)
  1546. * made operator search faster by walking the list only once
  1547. Revision 1.28 2002/11/18 17:31:54 peter
  1548. * pass proccalloption to ret_in_xxx and push_xxx functions
  1549. Revision 1.27 2002/11/16 15:34:30 florian
  1550. * generic location for float results
  1551. Revision 1.26 2002/11/15 01:58:51 peter
  1552. * merged changes from 1.0.7 up to 04-11
  1553. - -V option for generating bug report tracing
  1554. - more tracing for option parsing
  1555. - errors for cdecl and high()
  1556. - win32 import stabs
  1557. - win32 records<=8 are returned in eax:edx (turned off by default)
  1558. - heaptrc update
  1559. - more info for temp management in .s file with EXTDEBUG
  1560. Revision 1.25 2002/10/05 12:43:25 carl
  1561. * fixes for Delphi 6 compilation
  1562. (warning : Some features do not work under Delphi)
  1563. Revision 1.24 2002/09/30 07:00:45 florian
  1564. * fixes to common code to get the alpha compiler compiled applied
  1565. Revision 1.23 2002/09/17 18:54:02 jonas
  1566. * a_load_reg_reg() now has two size parameters: source and dest. This
  1567. allows some optimizations on architectures that don't encode the
  1568. register size in the register name.
  1569. Revision 1.22 2002/09/07 15:25:02 peter
  1570. * old logs removed and tabs fixed
  1571. Revision 1.21 2002/09/07 11:50:02 jonas
  1572. * fixed small regalloction info bug
  1573. Revision 1.20 2002/09/02 11:25:20 florian
  1574. * fixed generic procedure variable calling
  1575. Revision 1.19 2002/09/01 21:04:48 florian
  1576. * several powerpc related stuff fixed
  1577. Revision 1.18 2002/09/01 18:43:27 peter
  1578. * include accumulator in regs_to_push list
  1579. Revision 1.17 2002/09/01 12:13:00 peter
  1580. * use a_call_reg
  1581. * ungetiftemp for procvar of object temp
  1582. Revision 1.16 2002/08/25 19:25:18 peter
  1583. * sym.insert_in_data removed
  1584. * symtable.insertvardata/insertconstdata added
  1585. * removed insert_in_data call from symtable.insert, it needs to be
  1586. called separatly. This allows to deref the address calculation
  1587. * procedures now calculate the parast addresses after the procedure
  1588. directives are parsed. This fixes the cdecl parast problem
  1589. * push_addr_param has an extra argument that specifies if cdecl is used
  1590. or not
  1591. Revision 1.15 2002/08/23 16:14:48 peter
  1592. * tempgen cleanup
  1593. * tt_noreuse temp type added that will be used in genentrycode
  1594. Revision 1.14 2002/08/20 16:55:38 peter
  1595. * don't write (stabs)line info when inlining a procedure
  1596. Revision 1.13 2002/08/19 19:36:42 peter
  1597. * More fixes for cross unit inlining, all tnodes are now implemented
  1598. * Moved pocall_internconst to po_internconst because it is not a
  1599. calling type at all and it conflicted when inlining of these small
  1600. functions was requested
  1601. Revision 1.12 2002/08/18 20:06:23 peter
  1602. * inlining is now also allowed in interface
  1603. * renamed write/load to ppuwrite/ppuload
  1604. * tnode storing in ppu
  1605. * nld,ncon,nbas are already updated for storing in ppu
  1606. Revision 1.11 2002/08/17 22:09:44 florian
  1607. * result type handling in tcgcal.pass_2 overhauled
  1608. * better tnode.dowrite
  1609. * some ppc stuff fixed
  1610. Revision 1.10 2002/08/17 09:23:35 florian
  1611. * first part of procinfo rewrite
  1612. Revision 1.9 2002/08/13 21:40:55 florian
  1613. * more fixes for ppc calling conventions
  1614. Revision 1.8 2002/08/13 18:01:51 carl
  1615. * rename swatoperands to swapoperands
  1616. + m68k first compilable version (still needs a lot of testing):
  1617. assembler generator, system information , inline
  1618. assembler reader.
  1619. Revision 1.7 2002/08/12 15:08:39 carl
  1620. + stab register indexes for powerpc (moved from gdb to cpubase)
  1621. + tprocessor enumeration moved to cpuinfo
  1622. + linker in target_info is now a class
  1623. * many many updates for m68k (will soon start to compile)
  1624. - removed some ifdef or correct them for correct cpu
  1625. Revision 1.6 2002/08/11 14:32:26 peter
  1626. * renamed current_library to objectlibrary
  1627. Revision 1.5 2002/08/11 13:24:11 peter
  1628. * saving of asmsymbols in ppu supported
  1629. * asmsymbollist global is removed and moved into a new class
  1630. tasmlibrarydata that will hold the info of a .a file which
  1631. corresponds with a single module. Added librarydata to tmodule
  1632. to keep the library info stored for the module. In the future the
  1633. objectfiles will also be stored to the tasmlibrarydata class
  1634. * all getlabel/newasmsymbol and friends are moved to the new class
  1635. Revision 1.4 2002/08/06 20:55:20 florian
  1636. * first part of ppc calling conventions fix
  1637. Revision 1.3 2002/07/20 11:57:53 florian
  1638. * types.pas renamed to defbase.pas because D6 contains a types
  1639. unit so this would conflicts if D6 programms are compiled
  1640. + Willamette/SSE2 instructions to assembler added
  1641. Revision 1.2 2002/07/13 19:38:43 florian
  1642. * some more generic calling stuff fixed
  1643. }