psub.pas 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl, Daniel Mantione
  4. Does the parsing and codegeneration at subroutine level
  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 psub;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. symdef;
  23. procedure printnode_reset;
  24. procedure compile_proc_body(pd:tprocdef;make_global,parent_has_class:boolean);
  25. { reads the declaration blocks }
  26. procedure read_declarations(islibrary : boolean);
  27. { reads declarations in the interface part of a unit }
  28. procedure read_interface_declarations;
  29. implementation
  30. uses
  31. { common }
  32. cutils,cclasses,
  33. { global }
  34. globtype,globals,tokens,verbose,comphook,
  35. systems,
  36. { aasm }
  37. cpubase,cpuinfo,aasmbase,aasmtai,
  38. { symtable }
  39. symconst,symbase,symsym,symtype,symtable,defutil,
  40. paramgr,
  41. ppu,fmodule,
  42. { pass 1 }
  43. node,
  44. nbas,nld,ncal,ncon,nflw,nadd,ncnv,nmem,
  45. pass_1,
  46. {$ifdef state_tracking}
  47. nstate,
  48. {$endif state_tracking}
  49. { pass 2 }
  50. {$ifndef NOPASS2}
  51. pass_2,
  52. {$endif}
  53. { parser }
  54. scanner,
  55. pbase,pstatmnt,pdecl,pdecsub,pexports,
  56. { codegen }
  57. tgobj,cgbase,rgobj,rgcpu,
  58. ncgutil
  59. {$ifndef NOOPT}
  60. {$ifdef i386}
  61. ,aopt386
  62. {$else i386}
  63. ,aoptcpu
  64. {$endif i386}
  65. {$endif}
  66. ;
  67. {****************************************************************************
  68. PROCEDURE/FUNCTION BODY PARSING
  69. ****************************************************************************}
  70. procedure initializevars(p:tnamedindexitem;arg:pointer);
  71. var
  72. b : tblocknode;
  73. begin
  74. if tsym(p).typ<>varsym then
  75. exit;
  76. with tvarsym(p) do
  77. begin
  78. if assigned(defaultconstsym) then
  79. begin
  80. b:=tblocknode(arg);
  81. b.left:=cstatementnode.create(
  82. cassignmentnode.create(
  83. cloadnode.create(tsym(p),tsym(p).owner),
  84. cloadnode.create(defaultconstsym,defaultconstsym.owner)),
  85. b.left);
  86. end;
  87. end;
  88. end;
  89. function block(islibrary : boolean) : tnode;
  90. begin
  91. { parse const,types and vars }
  92. read_declarations(islibrary);
  93. current_procinfo.handle_body_start;
  94. { do we have an assembler block without the po_assembler?
  95. we should allow this for Delphi compatibility (PFV) }
  96. if (token=_ASM) and (m_delphi in aktmodeswitches) then
  97. include(current_procdef.procoptions,po_assembler);
  98. { Handle assembler block different }
  99. if (po_assembler in current_procdef.procoptions) then
  100. begin
  101. block:=assembler_block;
  102. exit;
  103. end;
  104. {Unit initialization?.}
  105. if (
  106. assigned(current_procdef.localst) and
  107. (current_procdef.localst.symtablelevel=main_program_level) and
  108. (current_module.is_unit)
  109. ) or
  110. islibrary then
  111. begin
  112. if (token=_END) then
  113. begin
  114. consume(_END);
  115. { We need at least a node, else the entry/exit code is not
  116. generated and thus no PASCALMAIN symbol which we need (PFV) }
  117. if islibrary then
  118. block:=cnothingnode.create
  119. else
  120. block:=nil;
  121. end
  122. else
  123. begin
  124. if token=_INITIALIZATION then
  125. begin
  126. { The library init code is already called and does not
  127. need to be in the initfinal table (PFV) }
  128. if not islibrary then
  129. current_module.flags:=current_module.flags or uf_init;
  130. block:=statement_block(_INITIALIZATION);
  131. end
  132. else if (token=_FINALIZATION) then
  133. begin
  134. if (current_module.flags and uf_finalize)<>0 then
  135. block:=statement_block(_FINALIZATION)
  136. else
  137. begin
  138. { can we allow no INITIALIZATION for DLL ??
  139. I think it should work PM }
  140. block:=nil;
  141. exit;
  142. end;
  143. end
  144. else
  145. begin
  146. { The library init code is already called and does not
  147. need to be in the initfinal table (PFV) }
  148. if not islibrary then
  149. current_module.flags:=current_module.flags or uf_init;
  150. block:=statement_block(_BEGIN);
  151. end;
  152. end;
  153. end
  154. else
  155. begin
  156. block:=statement_block(_BEGIN);
  157. if symtablestack.symtabletype=localsymtable then
  158. symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}initializevars,block);
  159. end;
  160. end;
  161. {****************************************************************************
  162. PROCEDURE/FUNCTION COMPILING
  163. ****************************************************************************}
  164. procedure printnode_reset;
  165. begin
  166. assign(printnodefile,treelogfilename);
  167. {$I-}
  168. rewrite(printnodefile);
  169. {$I+}
  170. if ioresult<>0 then
  171. begin
  172. Comment(V_Error,'Error creating '+treelogfilename);
  173. exit;
  174. end;
  175. close(printnodefile);
  176. end;
  177. procedure printnode_procdef(pd:tprocdef);
  178. begin
  179. assign(printnodefile,treelogfilename);
  180. {$I-}
  181. append(printnodefile);
  182. if ioresult<>0 then
  183. rewrite(printnodefile);
  184. {$I+}
  185. if ioresult<>0 then
  186. begin
  187. Comment(V_Error,'Error creating '+treelogfilename);
  188. exit;
  189. end;
  190. writeln(printnodefile);
  191. writeln(printnodefile,'*******************************************************************************');
  192. writeln(printnodefile,current_procdef.fullprocname(false));
  193. writeln(printnodefile,'*******************************************************************************');
  194. printnode(printnodefile,pd.code);
  195. close(printnodefile);
  196. end;
  197. function generate_entry_block:tblocknode;
  198. var
  199. srsym : tsym;
  200. para : tcallparanode;
  201. newstatement : tstatementnode;
  202. htype : ttype;
  203. begin
  204. generate_entry_block:=internalstatements(newstatement,true);
  205. if assigned(current_procdef._class) then
  206. begin
  207. { a constructor needs a help procedure }
  208. if (current_procdef.proctypeoption=potype_constructor) then
  209. begin
  210. if is_class(current_procdef._class) then
  211. begin
  212. if (cs_implicit_exceptions in aktmoduleswitches) then
  213. include(current_procinfo.flags,pi_needs_implicit_finally);
  214. srsym:=search_class_member(current_procdef._class,'NEWINSTANCE');
  215. if assigned(srsym) and
  216. (srsym.typ=procsym) then
  217. begin
  218. { if vmt<>0 then newinstance }
  219. addstatement(newstatement,cifnode.create(
  220. caddnode.create(unequaln,
  221. load_vmt_pointer_node,
  222. cnilnode.create),
  223. cassignmentnode.create(
  224. ctypeconvnode.create_explicit(
  225. load_self_pointer_node,
  226. voidpointertype),
  227. ccallnode.create(nil,tprocsym(srsym),srsym.owner,load_vmt_pointer_node)),
  228. nil));
  229. end
  230. else
  231. internalerror(200305108);
  232. end
  233. else
  234. if is_object(current_procdef._class) then
  235. begin
  236. htype.setdef(current_procdef._class);
  237. htype.setdef(tpointerdef.create(htype));
  238. { parameter 3 : vmt_offset }
  239. { parameter 2 : address of pointer to vmt,
  240. this is required to allow setting the vmt to -1 to indicate
  241. that memory was allocated }
  242. { parameter 1 : self pointer }
  243. para:=ccallparanode.create(
  244. cordconstnode.create(current_procdef._class.vmt_offset,s32bittype,false),
  245. ccallparanode.create(
  246. ctypeconvnode.create_explicit(
  247. load_vmt_pointer_node,
  248. voidpointertype),
  249. ccallparanode.create(
  250. ctypeconvnode.create_explicit(
  251. load_self_pointer_node,
  252. voidpointertype),
  253. nil)));
  254. addstatement(newstatement,cassignmentnode.create(
  255. ctypeconvnode.create_explicit(
  256. load_self_pointer_node,
  257. voidpointertype),
  258. ccallnode.createintern('fpc_help_constructor',para)));
  259. end
  260. else
  261. internalerror(200305103);
  262. { if self=nil then fail }
  263. addstatement(newstatement,cifnode.create(
  264. caddnode.create(equaln,
  265. load_self_pointer_node,
  266. cnilnode.create),
  267. cfailnode.create,
  268. nil));
  269. end;
  270. { maybe call BeforeDestruction for classes }
  271. if (current_procdef.proctypeoption=potype_destructor) and
  272. is_class(current_procdef._class) then
  273. begin
  274. srsym:=search_class_member(current_procdef._class,'BEFOREDESTRUCTION');
  275. if assigned(srsym) and
  276. (srsym.typ=procsym) then
  277. begin
  278. { if vmt<>0 then beforedestruction }
  279. addstatement(newstatement,cifnode.create(
  280. caddnode.create(unequaln,
  281. load_vmt_pointer_node,
  282. cnilnode.create),
  283. ccallnode.create(nil,tprocsym(srsym),srsym.owner,load_self_node),
  284. nil));
  285. end
  286. else
  287. internalerror(200305104);
  288. end;
  289. end;
  290. end;
  291. function generate_exit_block:tblocknode;
  292. var
  293. srsym : tsym;
  294. para : tcallparanode;
  295. newstatement : tstatementnode;
  296. begin
  297. generate_exit_block:=internalstatements(newstatement,true);
  298. if assigned(current_procdef._class) then
  299. begin
  300. { maybe call AfterConstruction for classes }
  301. if (current_procdef.proctypeoption=potype_constructor) and
  302. is_class(current_procdef._class) then
  303. begin
  304. srsym:=search_class_member(current_procdef._class,'AFTERCONSTRUCTION');
  305. if assigned(srsym) and
  306. (srsym.typ=procsym) then
  307. begin
  308. { if vmt<>0 then afterconstruction }
  309. addstatement(newstatement,cifnode.create(
  310. caddnode.create(unequaln,
  311. load_vmt_pointer_node,
  312. cnilnode.create),
  313. ccallnode.create(nil,tprocsym(srsym),srsym.owner,load_self_node),
  314. nil));
  315. end
  316. else
  317. internalerror(200305106);
  318. end;
  319. { a destructor needs a help procedure }
  320. if (current_procdef.proctypeoption=potype_destructor) then
  321. begin
  322. if is_class(current_procdef._class) then
  323. begin
  324. srsym:=search_class_member(current_procdef._class,'FREEINSTANCE');
  325. if assigned(srsym) and
  326. (srsym.typ=procsym) then
  327. begin
  328. { if self<>0 and vmt=1 then freeinstance }
  329. addstatement(newstatement,cifnode.create(
  330. caddnode.create(andn,
  331. caddnode.create(unequaln,
  332. load_self_pointer_node,
  333. cnilnode.create),
  334. caddnode.create(equaln,
  335. ctypeconvnode.create(
  336. load_vmt_pointer_node,
  337. voidpointertype),
  338. cpointerconstnode.create(1,voidpointertype))),
  339. ccallnode.create(nil,tprocsym(srsym),srsym.owner,load_self_node),
  340. nil));
  341. end
  342. else
  343. internalerror(200305108);
  344. end
  345. else
  346. if is_object(current_procdef._class) then
  347. begin
  348. { parameter 3 : vmt_offset }
  349. { parameter 2 : pointer to vmt }
  350. { parameter 1 : self pointer }
  351. para:=ccallparanode.create(
  352. cordconstnode.create(current_procdef._class.vmt_offset,s32bittype,false),
  353. ccallparanode.create(
  354. ctypeconvnode.create_explicit(
  355. load_vmt_pointer_node,
  356. voidpointertype),
  357. ccallparanode.create(
  358. ctypeconvnode.create_explicit(
  359. load_self_pointer_node,
  360. voidpointertype),
  361. nil)));
  362. addstatement(newstatement,
  363. ccallnode.createintern('fpc_help_destructor',para));
  364. end
  365. else
  366. internalerror(200305105);
  367. end;
  368. end;
  369. end;
  370. function generate_except_block:tblocknode;
  371. var
  372. pd : tprocdef;
  373. newstatement : tstatementnode;
  374. begin
  375. generate_except_block:=internalstatements(newstatement,true);
  376. { a constructor needs call destroy when it is not inherited }
  377. if (current_procdef.proctypeoption=potype_constructor) then
  378. begin
  379. pd:=current_procdef._class.searchdestructor;
  380. if assigned(pd) then
  381. begin
  382. { if vmt<>0 then call destructor }
  383. addstatement(newstatement,cifnode.create(
  384. caddnode.create(unequaln,
  385. load_vmt_pointer_node,
  386. cnilnode.create),
  387. ccallnode.create(nil,tprocsym(pd.procsym),pd.procsym.owner,load_self_node),
  388. nil));
  389. end
  390. else
  391. internalerror(200305107);
  392. end
  393. else
  394. begin
  395. { no constructor }
  396. { must be the return value finalized before reraising the exception? }
  397. if (not is_void(current_procdef.rettype.def)) and
  398. (current_procdef.rettype.def.needs_inittable) and
  399. (not is_class(current_procdef.rettype.def)) then
  400. finalize_data_node(caddrnode.create(load_result_node));
  401. end;
  402. end;
  403. procedure add_entry_exit_block(var code:tnode;const entrypos,exitpos:tfileposinfo);
  404. var
  405. entryblock,
  406. exitblock,
  407. newblock : tblocknode;
  408. newstatement : tstatementnode;
  409. oldfilepos : tfileposinfo;
  410. begin
  411. oldfilepos:=aktfilepos;
  412. { Generate entry and exit }
  413. aktfilepos:=entrypos;
  414. entryblock:=generate_entry_block;
  415. aktfilepos:=exitpos;
  416. exitblock:=generate_exit_block;
  417. { Generate procedure by combining entry+body+exit,
  418. depending on the implicit finally we need to add
  419. an try...finally...end wrapper }
  420. newblock:=internalstatements(newstatement,true);
  421. if (pi_needs_implicit_finally in current_procinfo.flags) and
  422. { but it's useless in init/final code of units }
  423. not(current_procdef.proctypeoption in [potype_unitfinalize,potype_unitinit]) then
  424. begin
  425. addstatement(newstatement,entryblock);
  426. aktfilepos:=exitpos;
  427. addstatement(newstatement,ctryexceptnode.createintern(
  428. code,
  429. generate_except_block));
  430. addstatement(newstatement,exitblock);
  431. end
  432. else
  433. begin
  434. addstatement(newstatement,entryblock);
  435. addstatement(newstatement,code);
  436. addstatement(newstatement,exitblock);
  437. end;
  438. resulttypepass(newblock);
  439. code:=newblock;
  440. aktfilepos:=oldfilepos;
  441. end;
  442. procedure compile_proc_body(pd:tprocdef;make_global,parent_has_class:boolean);
  443. {
  444. Compile the body of a procedure
  445. }
  446. var
  447. oldexitlabel,oldexit2label : tasmlabel;
  448. oldfaillabel,oldquickexitlabel:tasmlabel;
  449. _class,hp:tobjectdef;
  450. { switches can change inside the procedure }
  451. entryswitches, exitswitches : tlocalswitches;
  452. oldaktmaxfpuregisters,localmaxfpuregisters : longint;
  453. { code for the subroutine as tree }
  454. code:tnode;
  455. { true when no stackframe is required }
  456. nostackframe:boolean;
  457. { number of bytes which have to be cleared by RET }
  458. parasize:longint;
  459. { filepositions }
  460. entrypos,
  461. savepos,
  462. exitpos : tfileposinfo;
  463. oldprocdef : tprocdef;
  464. begin
  465. oldprocdef:=current_procdef;
  466. current_procdef:=pd;
  467. { calculate the lexical level }
  468. if current_procdef.parast.symtablelevel>maxnesting then
  469. Message(parser_e_too_much_lexlevel);
  470. { static is also important for local procedures !! }
  471. if (po_staticmethod in current_procdef.procoptions) then
  472. allow_only_static:=true
  473. else if (current_procdef.parast.symtablelevel=normal_function_level) then
  474. allow_only_static:=false;
  475. { save old labels }
  476. oldexitlabel:=aktexitlabel;
  477. oldexit2label:=aktexit2label;
  478. oldquickexitlabel:=quickexitlabel;
  479. oldfaillabel:=faillabel;
  480. { get new labels }
  481. objectlibrary.getlabel(aktexitlabel);
  482. objectlibrary.getlabel(aktexit2label);
  483. { exit for fail in constructors }
  484. if (current_procdef.proctypeoption=potype_constructor) then
  485. begin
  486. objectlibrary.getlabel(faillabel);
  487. objectlibrary.getlabel(quickexitlabel);
  488. end;
  489. { reset break and continue labels }
  490. block_type:=bt_general;
  491. aktbreaklabel:=nil;
  492. aktcontinuelabel:=nil;
  493. {$ifdef state_tracking}
  494. { aktstate:=Tstate_storage.create;}
  495. {$endif state_tracking}
  496. { insert symtables for the class, but only if it is no nested function }
  497. if assigned(current_procdef._class) and not(parent_has_class) then
  498. begin
  499. { insert them in the reverse order }
  500. hp:=nil;
  501. repeat
  502. _class:=current_procdef._class;
  503. while _class.childof<>hp do
  504. _class:=_class.childof;
  505. hp:=_class;
  506. _class.symtable.next:=symtablestack;
  507. symtablestack:=_class.symtable;
  508. until hp=current_procdef._class;
  509. end;
  510. { insert parasymtable in symtablestack when parsing
  511. a function }
  512. if current_procdef.parast.symtablelevel>=normal_function_level then
  513. begin
  514. current_procdef.parast.next:=symtablestack;
  515. symtablestack:=current_procdef.parast;
  516. end;
  517. { create a local symbol table for this routine }
  518. if not assigned(current_procdef.localst) then
  519. current_procdef.insert_localst;
  520. { insert localsymtable in symtablestack}
  521. current_procdef.localst.next:=symtablestack;
  522. symtablestack:=current_procdef.localst;
  523. { constant symbols are inserted in this symboltable }
  524. constsymtable:=symtablestack;
  525. { reset the temporary memory }
  526. rg.cleartempgen;
  527. rg.usedinproc:=[];
  528. rg.usedbyproc:=[];
  529. { save entry info }
  530. entrypos:=aktfilepos;
  531. entryswitches:=aktlocalswitches;
  532. localmaxfpuregisters:=aktmaxfpuregisters;
  533. { parse the code ... }
  534. code:=block(current_module.islibrary);
  535. { get a better entry point }
  536. if assigned(code) then
  537. entrypos:=code.fileinfo;
  538. { save exit info }
  539. exitswitches:=aktlocalswitches;
  540. exitpos:=last_endtoken_filepos;
  541. { save current filepos }
  542. savepos:=aktfilepos;
  543. { add implicit entry and exit code }
  544. if assigned(code) then
  545. add_entry_exit_block(code,entrypos,exitpos);
  546. { store a copy of the original tree for inline, for
  547. normal procedures only store a reference to the
  548. current tree }
  549. if (current_procdef.proccalloption=pocall_inline) then
  550. current_procdef.code:=code.getcopy
  551. else
  552. current_procdef.code:=code;
  553. {When we are called to compile the body of a unit, aktprocsym should
  554. point to the unit initialization. If the unit has no initialization,
  555. aktprocsym=nil. But in that case code=nil. Thus we should check for
  556. code=nil, when we use aktprocsym.}
  557. { set the start offset to the start of the temp area in the stack }
  558. tg.setfirsttemp(current_procinfo.firsttemp_offset);
  559. { ... and generate assembler }
  560. { but set the right switches for entry !! }
  561. aktlocalswitches:=entryswitches;
  562. oldaktmaxfpuregisters:=aktmaxfpuregisters;
  563. aktmaxfpuregisters:=localmaxfpuregisters;
  564. if assigned(code) then
  565. begin
  566. { the procedure is now defined }
  567. current_procdef.forwarddef:=false;
  568. if paraprintnodetree=1 then
  569. printnode_procdef(current_procdef);
  570. { only generate the code if no type errors are found, else
  571. finish at least the type checking pass }
  572. {$ifndef NOPASS2}
  573. if (status.errorcount=0) then
  574. begin
  575. generatecode(code);
  576. { first generate entry code with the correct position and switches }
  577. aktfilepos:=entrypos;
  578. aktlocalswitches:=entryswitches;
  579. genentrycode(current_procinfo.aktentrycode,make_global,0,parasize,nostackframe,false);
  580. { FPC_POPADDRSTACK destroys all registers (JM) }
  581. if (pi_needs_implicit_finally in current_procinfo.flags) or
  582. (pi_uses_exceptions in current_procinfo.flags) then
  583. begin
  584. rg.usedinproc := ALL_REGISTERS;
  585. end;
  586. { now generate exit code with the correct position and switches }
  587. aktfilepos:=exitpos;
  588. aktlocalswitches:=exitswitches;
  589. genexitcode(current_procinfo.aktexitcode,parasize,nostackframe,false);
  590. { now all the registers used are known }
  591. current_procdef.usedintregisters:=rg.usedintinproc;
  592. current_procdef.usedotherregisters:=rg.usedinproc;
  593. current_procinfo.aktproccode.insertlist(current_procinfo.aktentrycode);
  594. current_procinfo.aktproccode.concatlist(current_procinfo.aktexitcode);
  595. {$ifdef newra}
  596. { rg.writegraph;}
  597. {$endif}
  598. if not(cs_no_regalloc in aktglobalswitches) then
  599. begin
  600. {$ifdef newra}
  601. {Do register allocation.}
  602. repeat
  603. rg.prepare_colouring;
  604. rg.colour_registers;
  605. rg.epilogue_colouring;
  606. {Are there spilled registers? We cannot do that yet.}
  607. if rg.spillednodes<>'' then
  608. internalerror(200304221);
  609. {if not try_fast_spill(rg) then
  610. slow_spill(rg);
  611. }
  612. until rg.spillednodes='';
  613. current_procinfo.aktproccode.translate_registers(rg.colour);
  614. current_procinfo.aktproccode.convert_registers;
  615. {$else newra}
  616. current_procinfo.aktproccode.convert_registers;
  617. {$ifndef NoOpt}
  618. if (cs_optimize in aktglobalswitches) and
  619. { do not optimize pure assembler procedures }
  620. not(pi_is_assembler in current_procinfo.flags) then
  621. optimize(current_procinfo.aktproccode);
  622. {$endif NoOpt}
  623. {$endif newra}
  624. end;
  625. { save local data (casetable) also in the same file }
  626. if assigned(current_procinfo.aktlocaldata) and
  627. (not current_procinfo.aktlocaldata.empty) then
  628. begin
  629. current_procinfo.aktproccode.concat(Tai_section.Create(sec_data));
  630. current_procinfo.aktproccode.concatlist(current_procinfo.aktlocaldata);
  631. current_procinfo.aktproccode.concat(Tai_section.Create(sec_code));
  632. end;
  633. { add the procedure to the codesegment }
  634. if (cs_create_smart in aktmoduleswitches) then
  635. codeSegment.concat(Tai_cut.Create);
  636. codeSegment.concatlist(current_procinfo.aktproccode);
  637. end
  638. else
  639. do_resulttypepass(code);
  640. {$else NOPASS2}
  641. do_resulttypepass(code);
  642. {$endif NOPASS2}
  643. end;
  644. { ... remove symbol tables }
  645. if current_procdef.parast.symtablelevel>=normal_function_level then
  646. symtablestack:=symtablestack.next.next
  647. else
  648. symtablestack:=symtablestack.next;
  649. { ... check for unused symbols }
  650. { but only if there is no asm block }
  651. if assigned(code) then
  652. begin
  653. if (Errorcount=0) then
  654. begin
  655. { check if forwards are resolved }
  656. tstoredsymtable(current_procdef.localst).check_forwards;
  657. { check if all labels are used }
  658. tstoredsymtable(current_procdef.localst).checklabels;
  659. { remove cross unit overloads }
  660. tstoredsymtable(current_procdef.localst).unchain_overloaded;
  661. end;
  662. if not(pi_uses_asm in current_procinfo.flags) then
  663. begin
  664. { not for unit init, becuase the var can be used in finalize,
  665. it will be done in proc_unit }
  666. if not(current_procdef.proctypeoption
  667. in [potype_proginit,potype_unitinit,potype_unitfinalize]) then
  668. tstoredsymtable(current_procdef.localst).allsymbolsused;
  669. tstoredsymtable(current_procdef.parast).allsymbolsused;
  670. end;
  671. end;
  672. { the local symtables can be deleted, but the parast }
  673. { doesn't, (checking definitons when calling a }
  674. { function }
  675. { not for a inline procedure !! (PM) }
  676. { at lexlevel = 1 localst is the staticsymtable itself }
  677. { so no dispose here !! }
  678. if assigned(code) and
  679. not(cs_browser in aktmoduleswitches) and
  680. (current_procdef.proccalloption<>pocall_inline) then
  681. begin
  682. if current_procdef.parast.symtablelevel>=normal_function_level then
  683. current_procdef.localst.free;
  684. current_procdef.localst:=nil;
  685. end;
  686. { all registers can be used again }
  687. rg.resetusableregisters;
  688. { only now we can remove the temps }
  689. tg.resettempgen;
  690. { remove code tree, if not inline procedure }
  691. if assigned(code) then
  692. begin
  693. { the inline procedure has already got a copy of the tree
  694. stored in current_procdef.code }
  695. code.free;
  696. if (current_procdef.proccalloption<>pocall_inline) then
  697. current_procdef.code:=nil;
  698. end;
  699. { remove class member symbol tables }
  700. while symtablestack.symtabletype=objectsymtable do
  701. symtablestack:=symtablestack.next;
  702. aktmaxfpuregisters:=oldaktmaxfpuregisters;
  703. {$ifdef state_tracking}
  704. { aktstate.destroy;}
  705. {$endif state_tracking}
  706. { restore filepos, the switches are already set }
  707. aktfilepos:=savepos;
  708. { restore labels }
  709. aktexitlabel:=oldexitlabel;
  710. aktexit2label:=oldexit2label;
  711. quickexitlabel:=oldquickexitlabel;
  712. faillabel:=oldfaillabel;
  713. { reset to normal non static function }
  714. if (current_procdef.parast.symtablelevel=normal_function_level) then
  715. allow_only_static:=false;
  716. current_procdef:=oldprocdef;
  717. end;
  718. {****************************************************************************
  719. PROCEDURE/FUNCTION PARSING
  720. ****************************************************************************}
  721. procedure insert_local_value_para(p:tnamedindexitem;arg:pointer);
  722. var
  723. vs : tvarsym;
  724. pd : tprocdef;
  725. begin
  726. if tsym(p).typ<>varsym then
  727. exit;
  728. with tvarsym(p) do
  729. begin
  730. if copy(name,1,3)='val' then
  731. begin
  732. pd:=tprocdef(owner.defowner);
  733. vs:=tvarsym.create(Copy(name,4,255),varspez,vartype);
  734. vs.fileinfo:=fileinfo;
  735. if not assigned(pd.localst) then
  736. pd.insert_localst;
  737. pd.localst.insert(vs);
  738. pd.localst.insertvardata(vs);
  739. include(vs.varoptions,vo_is_local_copy);
  740. vs.varstate:=vs_assigned;
  741. localvarsym:=vs;
  742. inc(refs); { the para was used to set the local copy ! }
  743. { warnings only on local copy ! }
  744. varstate:=vs_used;
  745. end;
  746. end;
  747. end;
  748. procedure read_proc;
  749. {
  750. Parses the procedure directives, then parses the procedure body, then
  751. generates the code for it
  752. }
  753. var
  754. oldprocdef : tprocdef;
  755. old_current_procinfo : tprocinfo;
  756. oldconstsymtable : tsymtable;
  757. oldselftokenmode,
  758. oldfailtokenmode : tmodeswitch;
  759. pdflags : word;
  760. pd : tprocdef;
  761. begin
  762. { save old state }
  763. oldprocdef:=current_procdef;
  764. oldconstsymtable:=constsymtable;
  765. old_current_procinfo:=current_procinfo;
  766. { reset current_procdef to nil to be sure that nothing is writing
  767. to an other procdef }
  768. current_procdef:=nil;
  769. { create a new procedure }
  770. current_procinfo:=cprocinfo.create(old_current_procinfo);
  771. current_module.procinfo:=current_procinfo;
  772. { parse procedure declaration }
  773. if assigned(current_procinfo.parent) and
  774. assigned(current_procinfo.parent.procdef) then
  775. pd:=parse_proc_dec(current_procinfo.parent.procdef._class)
  776. else
  777. pd:=parse_proc_dec(nil);
  778. current_procinfo.procdef:=pd;
  779. { set the default function options }
  780. if parse_only then
  781. begin
  782. pd.forwarddef:=true;
  783. { set also the interface flag, for better error message when the
  784. implementation doesn't much this header }
  785. pd.interfacedef:=true;
  786. pdflags:=pd_interface;
  787. end
  788. else
  789. begin
  790. pdflags:=pd_body;
  791. if (not current_module.in_interface) then
  792. pdflags:=pdflags or pd_implemen;
  793. if (not current_module.is_unit) or (cs_create_smart in aktmoduleswitches) then
  794. pdflags:=pdflags or pd_global;
  795. pd.forwarddef:=false;
  796. end;
  797. { parse the directives that may follow }
  798. parse_proc_directives(pd,pdflags);
  799. { hint directives, these can be separated by semicolons here,
  800. that needs to be handled here with a loop (PFV) }
  801. while try_consume_hintdirective(pd.symoptions) do
  802. Consume(_SEMICOLON);
  803. { everything of the proc definition is known, we can now
  804. calculate the parameters }
  805. calc_parast(pd);
  806. { search for forward declarations }
  807. if not proc_add_definition(pd) then
  808. begin
  809. { A method must be forward defined (in the object declaration) }
  810. if assigned(pd._class) and
  811. (not assigned(current_procinfo.parent.procdef._class)) then
  812. begin
  813. Message1(parser_e_header_dont_match_any_member,pd.fullprocname(false));
  814. tprocsym(pd.procsym).write_parameter_lists(pd);
  815. end
  816. else
  817. begin
  818. { Give a better error if there is a forward def in the interface and only
  819. a single implementation }
  820. if (not pd.forwarddef) and
  821. (not pd.interfacedef) and
  822. (tprocsym(pd.procsym).procdef_count>1) and
  823. tprocsym(pd.procsym).first_procdef.forwarddef and
  824. tprocsym(pd.procsym).first_procdef.interfacedef and
  825. not(tprocsym(pd.procsym).procdef_count>2) then
  826. begin
  827. Message1(parser_e_header_dont_match_forward,pd.fullprocname(false));
  828. tprocsym(pd.procsym).write_parameter_lists(pd);
  829. end
  830. else
  831. begin
  832. { check the global flag, for delphi this is not
  833. required }
  834. if not(m_delphi in aktmodeswitches) and
  835. (pi_is_global in current_procinfo.flags) then
  836. Message(parser_e_overloaded_must_be_all_global);
  837. end;
  838. end;
  839. end;
  840. { update procinfo, because the procdef can be
  841. changed by check_identical_proc (PFV) }
  842. current_procinfo.procdef:=pd;
  843. { compile procedure when a body is needed }
  844. if (pdflags and pd_body)<>0 then
  845. begin
  846. Message1(parser_d_procedure_start,pd.fullprocname(false));
  847. pd.aliasnames.insert(pd.mangledname);
  848. { Insert result variables in the localst }
  849. insert_funcret_local(pd);
  850. { Insert local copies for value para }
  851. pd.parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}insert_local_value_para,nil);
  852. { Update parameter information }
  853. current_procinfo.allocate_implicit_parameter;
  854. {$ifdef i386}
  855. { add implicit pushes for interrupt routines }
  856. if (po_interrupt in pd.procoptions) then
  857. current_procinfo.allocate_interrupt_stackframe;
  858. {$endif i386}
  859. { Calculate offsets }
  860. current_procinfo.after_header;
  861. { set _FAIL as keyword if constructor }
  862. if (pd.proctypeoption=potype_constructor) then
  863. begin
  864. oldfailtokenmode:=tokeninfo^[_FAIL].keyword;
  865. tokeninfo^[_FAIL].keyword:=m_all;
  866. end;
  867. { set _SELF as keyword if methods }
  868. if assigned(pd._class) then
  869. begin
  870. oldselftokenmode:=tokeninfo^[_SELF].keyword;
  871. tokeninfo^[_SELF].keyword:=m_all;
  872. end;
  873. compile_proc_body(pd,((pdflags and pd_global)<>0),assigned(current_procinfo.parent.procdef._class));
  874. { reset _FAIL as _SELF normal }
  875. if (pd.proctypeoption=potype_constructor) then
  876. tokeninfo^[_FAIL].keyword:=oldfailtokenmode;
  877. if assigned(pd._class) then
  878. tokeninfo^[_SELF].keyword:=oldselftokenmode;
  879. consume(_SEMICOLON);
  880. end;
  881. { release procinfo }
  882. if tprocinfo(current_module.procinfo)<>current_procinfo then
  883. internalerror(200304274);
  884. current_module.procinfo:=current_procinfo.parent;
  885. current_procinfo.free;
  886. { Restore old state }
  887. constsymtable:=oldconstsymtable;
  888. current_procdef:=oldprocdef;
  889. current_procinfo:=old_current_procinfo;
  890. end;
  891. {****************************************************************************
  892. DECLARATION PARSING
  893. ****************************************************************************}
  894. { search in symtablestack for not complete classes }
  895. procedure check_forward_class(p : tnamedindexitem;arg:pointer);
  896. begin
  897. if (tsym(p).typ=typesym) and
  898. (ttypesym(p).restype.def.deftype=objectdef) and
  899. (oo_is_forward in tobjectdef(ttypesym(p).restype.def).objectoptions) then
  900. MessagePos1(tsym(p).fileinfo,sym_e_forward_type_not_resolved,tsym(p).realname);
  901. end;
  902. procedure read_declarations(islibrary : boolean);
  903. procedure Not_supported_for_inline(t : ttoken);
  904. begin
  905. if (current_procdef.proccalloption=pocall_inline) then
  906. Begin
  907. Message1(parser_w_not_supported_for_inline,tokenstring(t));
  908. Message(parser_w_inlining_disabled);
  909. current_procdef.proccalloption:=pocall_fpccall;
  910. End;
  911. end;
  912. begin
  913. repeat
  914. if not assigned(current_procdef) then
  915. internalerror(200304251);
  916. case token of
  917. _LABEL:
  918. begin
  919. Not_supported_for_inline(token);
  920. label_dec;
  921. end;
  922. _CONST:
  923. begin
  924. Not_supported_for_inline(token);
  925. const_dec;
  926. end;
  927. _TYPE:
  928. begin
  929. Not_supported_for_inline(token);
  930. type_dec;
  931. end;
  932. _VAR:
  933. var_dec;
  934. _THREADVAR:
  935. threadvar_dec;
  936. _CONSTRUCTOR,_DESTRUCTOR,
  937. _FUNCTION,_PROCEDURE,_OPERATOR,_CLASS:
  938. begin
  939. Not_supported_for_inline(token);
  940. read_proc;
  941. end;
  942. _RESOURCESTRING:
  943. resourcestring_dec;
  944. _EXPORTS:
  945. begin
  946. Not_supported_for_inline(token);
  947. if not(assigned(current_procdef.localst)) or
  948. (current_procdef.localst.symtablelevel>main_program_level) or
  949. (current_module.is_unit) then
  950. begin
  951. Message(parser_e_syntax_error);
  952. consume_all_until(_SEMICOLON);
  953. end
  954. else if islibrary or
  955. (target_info.system in [system_i386_WIN32,system_i386_wdosx,system_i386_Netware]) then
  956. read_exports
  957. else
  958. begin
  959. Message(parser_w_unsupported_feature);
  960. consume(_BEGIN);
  961. end;
  962. end
  963. else break;
  964. end;
  965. until false;
  966. { check for incomplete class definitions, this is only required
  967. for fpc modes }
  968. if (m_fpc in aktmodeswitches) then
  969. symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}check_forward_class,nil);
  970. end;
  971. procedure read_interface_declarations;
  972. begin
  973. repeat
  974. case token of
  975. _CONST :
  976. const_dec;
  977. _TYPE :
  978. type_dec;
  979. _VAR :
  980. var_dec;
  981. _THREADVAR :
  982. threadvar_dec;
  983. _RESOURCESTRING:
  984. resourcestring_dec;
  985. _FUNCTION,
  986. _PROCEDURE,
  987. _OPERATOR :
  988. read_proc;
  989. else
  990. break;
  991. end;
  992. until false;
  993. { check for incomplete class definitions, this is only required
  994. for fpc modes }
  995. if (m_fpc in aktmodeswitches) then
  996. symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}check_forward_class,nil);
  997. end;
  998. end.
  999. {
  1000. $Log$
  1001. Revision 1.110 2003-05-13 15:18:49 peter
  1002. * fixed various crashes
  1003. Revision 1.109 2003/05/11 21:37:03 peter
  1004. * moved implicit exception frame from ncgutil to psub
  1005. * constructor/destructor helpers moved from cobj/ncgutil to psub
  1006. Revision 1.108 2003/05/09 17:47:03 peter
  1007. * self moved to hidden parameter
  1008. * removed hdisposen,hnewn,selfn
  1009. Revision 1.107 2003/04/27 11:21:34 peter
  1010. * aktprocdef renamed to current_procdef
  1011. * procinfo renamed to current_procinfo
  1012. * procinfo will now be stored in current_module so it can be
  1013. cleaned up properly
  1014. * gen_main_procsym changed to create_main_proc and release_main_proc
  1015. to also generate a tprocinfo structure
  1016. * fixed unit implicit initfinal
  1017. Revision 1.106 2003/04/27 07:29:50 peter
  1018. * current_procdef cleanup, current_procdef is now always nil when parsing
  1019. a new procdef declaration
  1020. * aktprocsym removed
  1021. * lexlevel removed, use symtable.symtablelevel instead
  1022. * implicit init/final code uses the normal genentry/genexit
  1023. * funcret state checking updated for new funcret handling
  1024. Revision 1.105 2003/04/26 00:31:42 peter
  1025. * set return_offset moved to after_header
  1026. Revision 1.104 2003/04/25 20:59:34 peter
  1027. * removed funcretn,funcretsym, function result is now in varsym
  1028. and aliases for result and function name are added using absolutesym
  1029. * vs_hidden parameter for funcret passed in parameter
  1030. * vs_hidden fixes
  1031. * writenode changed to printnode and released from extdebug
  1032. * -vp option added to generate a tree.log with the nodetree
  1033. * nicer printnode for statements, callnode
  1034. Revision 1.103 2003/04/24 13:03:01 florian
  1035. * comp is now written with its bit pattern to the ppu instead as an extended
  1036. Revision 1.102 2003/04/23 12:35:34 florian
  1037. * fixed several issues with powerpc
  1038. + applied a patch from Jonas for nested function calls (PowerPC only)
  1039. * ...
  1040. Revision 1.101 2003/04/22 14:33:38 peter
  1041. * removed some notes/hints
  1042. Revision 1.100 2003/04/22 13:47:08 peter
  1043. * fixed C style array of const
  1044. * fixed C array passing
  1045. * fixed left to right with high parameters
  1046. Revision 1.99 2003/04/22 10:09:35 daniel
  1047. + Implemented the actual register allocator
  1048. + Scratch registers unavailable when new register allocator used
  1049. + maybe_save/maybe_restore unavailable when new register allocator used
  1050. Revision 1.98 2003/04/17 07:50:24 daniel
  1051. * Some work on interference graph construction
  1052. Revision 1.97 2003/04/16 09:26:55 jonas
  1053. * assembler procedures now again get a stackframe if they have local
  1054. variables. No space is reserved for a function result however.
  1055. Also, the register parameters aren't automatically saved on the stack
  1056. anymore in assembler procedures.
  1057. Revision 1.96 2003/04/05 21:09:31 jonas
  1058. * several ppc/generic result offset related fixes. The "normal" result
  1059. offset seems now to be calculated correctly and a lot of duplicate
  1060. calculations have been removed. Nested functions accessing the parent's
  1061. function result don't work at all though :(
  1062. Revision 1.95 2003/04/02 16:11:34 peter
  1063. * give error when exports is not supported
  1064. Revision 1.94 2003/03/12 22:43:38 jonas
  1065. * more powerpc and generic fixes related to the new register allocator
  1066. Revision 1.93 2003/03/08 08:59:07 daniel
  1067. + $define newra will enable new register allocator
  1068. + getregisterint will return imaginary registers with $newra
  1069. + -sr switch added, will skip register allocation so you can see
  1070. the direct output of the code generator before register allocation
  1071. Revision 1.92 2003/02/19 22:00:14 daniel
  1072. * Code generator converted to new register notation
  1073. - Horribily outdated todo.txt removed
  1074. Revision 1.91 2003/01/09 21:52:37 peter
  1075. * merged some verbosity options.
  1076. * V_LineInfo is a verbosity flag to include line info
  1077. Revision 1.90 2003/01/09 20:40:59 daniel
  1078. * Converted some code in cgx86.pas to new register numbering
  1079. Revision 1.89 2003/01/09 15:49:56 daniel
  1080. * Added register conversion
  1081. Revision 1.88 2003/01/08 18:43:56 daniel
  1082. * Tregister changed into a record
  1083. Revision 1.87 2003/01/03 20:35:08 peter
  1084. * check also interfacedef when checking for matching forwarddef
  1085. Revision 1.86 2003/01/02 11:14:02 michael
  1086. + Patch from peter to support initial values for local variables
  1087. Revision 1.85 2002/12/29 18:59:34 peter
  1088. * fixed parsing of declarations before asm statement
  1089. Revision 1.84 2002/12/29 18:25:18 peter
  1090. * parse declarations before check _ASM token
  1091. Revision 1.83 2002/12/29 14:57:50 peter
  1092. * unit loading changed to first register units and load them
  1093. afterwards. This is needed to support uses xxx in yyy correctly
  1094. * unit dependency check fixed
  1095. Revision 1.82 2002/12/25 01:26:56 peter
  1096. * duplicate procsym-unitsym fix
  1097. Revision 1.81 2002/12/15 13:37:15 peter
  1098. * don't include uf_init for library. The code is already called and
  1099. does not need to be in the initfinal table
  1100. Revision 1.80 2002/12/07 14:27:09 carl
  1101. * 3% memory optimization
  1102. * changed some types
  1103. + added type checking with different size for call node and for
  1104. parameters
  1105. Revision 1.79 2002/11/25 18:43:32 carl
  1106. - removed the invalid if <> checking (Delphi is strange on this)
  1107. + implemented abstract warning on instance creation of class with
  1108. abstract methods.
  1109. * some error message cleanups
  1110. Revision 1.78 2002/11/25 17:43:23 peter
  1111. * splitted defbase in defutil,symutil,defcmp
  1112. * merged isconvertable and is_equal into compare_defs(_ext)
  1113. * made operator search faster by walking the list only once
  1114. Revision 1.77 2002/11/23 22:50:06 carl
  1115. * some small speed optimizations
  1116. + added several new warnings/hints
  1117. Revision 1.76 2002/11/18 17:31:58 peter
  1118. * pass proccalloption to ret_in_xxx and push_xxx functions
  1119. Revision 1.75 2002/11/17 16:31:57 carl
  1120. * memory optimization (3-4%) : cleanup of tai fields,
  1121. cleanup of tdef and tsym fields.
  1122. * make it work for m68k
  1123. Revision 1.74 2002/11/15 01:58:53 peter
  1124. * merged changes from 1.0.7 up to 04-11
  1125. - -V option for generating bug report tracing
  1126. - more tracing for option parsing
  1127. - errors for cdecl and high()
  1128. - win32 import stabs
  1129. - win32 records<=8 are returned in eax:edx (turned off by default)
  1130. - heaptrc update
  1131. - more info for temp management in .s file with EXTDEBUG
  1132. Revision 1.73 2002/11/09 15:32:30 carl
  1133. * noopt for non-i386 targets
  1134. Revision 1.72 2002/09/10 20:31:48 florian
  1135. * call to current_procinfo.after_header added
  1136. Revision 1.71 2002/09/07 15:25:07 peter
  1137. * old logs removed and tabs fixed
  1138. Revision 1.70 2002/09/03 16:26:27 daniel
  1139. * Make Tprocdef.defs protected
  1140. Revision 1.69 2002/08/25 19:25:20 peter
  1141. * sym.insert_in_data removed
  1142. * symtable.insertvardata/insertconstdata added
  1143. * removed insert_in_data call from symtable.insert, it needs to be
  1144. called separatly. This allows to deref the address calculation
  1145. * procedures now calculate the parast addresses after the procedure
  1146. directives are parsed. This fixes the cdecl parast problem
  1147. * push_addr_param has an extra argument that specifies if cdecl is used
  1148. or not
  1149. Revision 1.68 2002/08/17 09:23:41 florian
  1150. * first part of procinfo rewrite
  1151. Revision 1.67 2002/08/16 14:24:59 carl
  1152. * issameref() to test if two references are the same (then emit no opcodes)
  1153. + ret_in_reg to replace ret_in_acc
  1154. (fix some register allocation bugs at the same time)
  1155. + save_std_register now has an extra parameter which is the
  1156. usedinproc registers
  1157. Revision 1.66 2002/08/11 14:32:27 peter
  1158. * renamed current_library to objectlibrary
  1159. Revision 1.65 2002/08/11 13:24:13 peter
  1160. * saving of asmsymbols in ppu supported
  1161. * asmsymbollist global is removed and moved into a new class
  1162. tasmlibrarydata that will hold the info of a .a file which
  1163. corresponds with a single module. Added librarydata to tmodule
  1164. to keep the library info stored for the module. In the future the
  1165. objectfiles will also be stored to the tasmlibrarydata class
  1166. * all getlabel/newasmsymbol and friends are moved to the new class
  1167. Revision 1.64 2002/08/09 19:14:28 carl
  1168. * fixed stackframe parameter (should only contain local size),
  1169. set to zero currently
  1170. Revision 1.63 2002/08/06 20:55:22 florian
  1171. * first part of ppc calling conventions fix
  1172. Revision 1.62 2002/07/26 21:15:41 florian
  1173. * rewrote the system handling
  1174. Revision 1.61 2002/07/20 11:57:56 florian
  1175. * types.pas renamed to defbase.pas because D6 contains a types
  1176. unit so this would conflicts if D6 programms are compiled
  1177. + Willamette/SSE2 instructions to assembler added
  1178. Revision 1.60 2002/07/19 11:41:36 daniel
  1179. * State tracker work
  1180. * The whilen and repeatn are now completely unified into whilerepeatn. This
  1181. allows the state tracker to change while nodes automatically into
  1182. repeat nodes.
  1183. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  1184. 'not(a>b)' is optimized into 'a<=b'.
  1185. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  1186. by removing the notn and later switchting the true and falselabels. The
  1187. same is done with 'repeat until not a'.
  1188. Revision 1.59 2002/07/15 18:03:15 florian
  1189. * readded removed changes
  1190. Revision 1.57 2002/07/11 14:41:28 florian
  1191. * start of the new generic parameter handling
  1192. Revision 1.58 2002/07/14 18:00:44 daniel
  1193. + Added the beginning of a state tracker. This will track the values of
  1194. variables through procedures and optimize things away.
  1195. Revision 1.56 2002/07/07 09:52:32 florian
  1196. * powerpc target fixed, very simple units can be compiled
  1197. * some basic stuff for better callparanode handling, far from being finished
  1198. Revision 1.55 2002/07/04 20:43:01 florian
  1199. * first x86-64 patches
  1200. Revision 1.54 2002/07/01 18:46:25 peter
  1201. * internal linker
  1202. * reorganized aasm layer
  1203. Revision 1.53 2002/05/18 13:34:14 peter
  1204. * readded missing revisions
  1205. Revision 1.52 2002/05/16 19:46:44 carl
  1206. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1207. + try to fix temp allocation (still in ifdef)
  1208. + generic constructor calls
  1209. + start of tassembler / tmodulebase class cleanup
  1210. Revision 1.51 2002/05/14 19:34:49 peter
  1211. * removed old logs and updated copyright year
  1212. }