psub.pas 53 KB

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