psub.pas 73 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991
  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. cclasses,globals,
  23. node,nbas,
  24. symdef,procinfo;
  25. type
  26. tcgprocinfo = class(tprocinfo)
  27. private
  28. procedure add_entry_exit_code;
  29. public
  30. { code for the subroutine as tree }
  31. code : tnode;
  32. { positions in the tree for init/final }
  33. entry_asmnode,
  34. loadpara_asmnode,
  35. exitlabel_asmnode,
  36. init_asmnode,
  37. final_asmnode : tasmnode;
  38. { list to store the procinfo's of the nested procedures }
  39. nestedprocs : tlinkedlist;
  40. constructor create(aparent:tprocinfo);override;
  41. destructor destroy;override;
  42. procedure generate_code;
  43. procedure resetprocdef;
  44. procedure add_to_symtablestack;
  45. procedure remove_from_symtablestack;
  46. procedure parse_body;
  47. end;
  48. procedure printnode_reset;
  49. { reads the declaration blocks }
  50. procedure read_declarations(islibrary : boolean);
  51. { reads declarations in the interface part of a unit }
  52. procedure read_interface_declarations;
  53. implementation
  54. uses
  55. { common }
  56. cutils,
  57. { global }
  58. globtype,tokens,verbose,comphook,
  59. systems,
  60. { aasm }
  61. cpubase,aasmtai,
  62. { symtable }
  63. symconst,symbase,symsym,symtype,symtable,defutil,
  64. paramgr,
  65. ppu,fmodule,
  66. { pass 1 }
  67. nutils,nld,ncal,ncon,nflw,nadd,ncnv,nmem,
  68. pass_1,
  69. {$ifdef state_tracking}
  70. nstate,
  71. {$endif state_tracking}
  72. { pass 2 }
  73. {$ifndef NOPASS2}
  74. pass_2,
  75. {$endif}
  76. { parser }
  77. scanner,
  78. pbase,pstatmnt,pdecl,pdecsub,pexports,
  79. { codegen }
  80. tgobj,cgobj,
  81. ncgutil,regvars
  82. {$ifdef arm}
  83. ,aasmcpu
  84. {$endif arm}
  85. {$ifndef NOOPT}
  86. {$ifdef i386}
  87. ,aopt386
  88. {$else i386}
  89. ,aoptcpu
  90. {$endif i386}
  91. {$endif}
  92. ;
  93. {****************************************************************************
  94. PROCEDURE/FUNCTION BODY PARSING
  95. ****************************************************************************}
  96. procedure initializevars(p:tnamedindexitem;arg:pointer);
  97. var
  98. b : tblocknode;
  99. begin
  100. if tsym(p).typ<>varsym then
  101. exit;
  102. with tvarsym(p) do
  103. begin
  104. if assigned(defaultconstsym) then
  105. begin
  106. b:=tblocknode(arg);
  107. b.left:=cstatementnode.create(
  108. cassignmentnode.create(
  109. cloadnode.create(tsym(p),tsym(p).owner),
  110. cloadnode.create(defaultconstsym,defaultconstsym.owner)),
  111. b.left);
  112. end;
  113. end;
  114. end;
  115. procedure check_finalize_paras(p : tnamedindexitem;arg:pointer);
  116. begin
  117. if (tsym(p).typ=varsym) and
  118. (tvarsym(p).varspez=vs_value) and
  119. not is_class(tvarsym(p).vartype.def) and
  120. tvarsym(p).vartype.def.needs_inittable then
  121. include(current_procinfo.flags,pi_needs_implicit_finally);
  122. end;
  123. procedure check_finalize_locals(p : tnamedindexitem;arg:pointer);
  124. begin
  125. if (tsym(p).typ=varsym) and
  126. (tvarsym(p).refs>0) and
  127. not(vo_is_funcret in tvarsym(p).varoptions) and
  128. not(is_class(tvarsym(p).vartype.def)) and
  129. tvarsym(p).vartype.def.needs_inittable then
  130. include(current_procinfo.flags,pi_needs_implicit_finally);
  131. end;
  132. function block(islibrary : boolean) : tnode;
  133. begin
  134. { parse const,types and vars }
  135. read_declarations(islibrary);
  136. { do we have an assembler block without the po_assembler?
  137. we should allow this for Delphi compatibility (PFV) }
  138. if (token=_ASM) and (m_delphi in aktmodeswitches) then
  139. include(current_procinfo.procdef.procoptions,po_assembler);
  140. { Handle assembler block different }
  141. if (po_assembler in current_procinfo.procdef.procoptions) then
  142. begin
  143. block:=assembler_block;
  144. exit;
  145. end;
  146. {Unit initialization?.}
  147. if (
  148. assigned(current_procinfo.procdef.localst) and
  149. (current_procinfo.procdef.localst.symtablelevel=main_program_level) and
  150. (current_module.is_unit)
  151. ) or
  152. islibrary then
  153. begin
  154. if (token=_END) then
  155. begin
  156. consume(_END);
  157. { We need at least a node, else the entry/exit code is not
  158. generated and thus no PASCALMAIN symbol which we need (PFV) }
  159. if islibrary then
  160. block:=cnothingnode.create
  161. else
  162. block:=nil;
  163. end
  164. else
  165. begin
  166. if token=_INITIALIZATION then
  167. begin
  168. { The library init code is already called and does not
  169. need to be in the initfinal table (PFV) }
  170. if not islibrary then
  171. current_module.flags:=current_module.flags or uf_init;
  172. block:=statement_block(_INITIALIZATION);
  173. end
  174. else if (token=_FINALIZATION) then
  175. begin
  176. if (current_module.flags and uf_finalize)<>0 then
  177. block:=statement_block(_FINALIZATION)
  178. else
  179. begin
  180. { can we allow no INITIALIZATION for DLL ??
  181. I think it should work PM }
  182. block:=nil;
  183. exit;
  184. end;
  185. end
  186. else
  187. begin
  188. { The library init code is already called and does not
  189. need to be in the initfinal table (PFV) }
  190. if not islibrary then
  191. current_module.flags:=current_module.flags or uf_init;
  192. block:=statement_block(_BEGIN);
  193. end;
  194. end;
  195. end
  196. else
  197. begin
  198. block:=statement_block(_BEGIN);
  199. if symtablestack.symtabletype=localsymtable then
  200. symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}initializevars,block);
  201. end;
  202. end;
  203. {****************************************************************************
  204. PROCEDURE/FUNCTION COMPILING
  205. ****************************************************************************}
  206. procedure printnode_reset;
  207. begin
  208. assign(printnodefile,treelogfilename);
  209. {$I-}
  210. rewrite(printnodefile);
  211. {$I+}
  212. if ioresult<>0 then
  213. begin
  214. Comment(V_Error,'Error creating '+treelogfilename);
  215. exit;
  216. end;
  217. close(printnodefile);
  218. end;
  219. procedure printnode_procdef(pd:tprocdef);
  220. begin
  221. assign(printnodefile,treelogfilename);
  222. {$I-}
  223. append(printnodefile);
  224. if ioresult<>0 then
  225. rewrite(printnodefile);
  226. {$I+}
  227. if ioresult<>0 then
  228. begin
  229. Comment(V_Error,'Error creating '+treelogfilename);
  230. exit;
  231. end;
  232. writeln(printnodefile);
  233. writeln(printnodefile,'*******************************************************************************');
  234. writeln(printnodefile,current_procinfo.procdef.fullprocname(false));
  235. writeln(printnodefile,'*******************************************************************************');
  236. printnode(printnodefile,pd.inlininginfo^.code);
  237. close(printnodefile);
  238. end;
  239. function generate_bodyentry_block:tnode;
  240. var
  241. srsym : tsym;
  242. para : tcallparanode;
  243. newstatement : tstatementnode;
  244. htype : ttype;
  245. begin
  246. result:=internalstatements(newstatement);
  247. if assigned(current_procinfo.procdef._class) then
  248. begin
  249. { a constructor needs a help procedure }
  250. if (current_procinfo.procdef.proctypeoption=potype_constructor) then
  251. begin
  252. if is_class(current_procinfo.procdef._class) then
  253. begin
  254. include(current_procinfo.flags,pi_needs_implicit_finally);
  255. srsym:=search_class_member(current_procinfo.procdef._class,'NEWINSTANCE');
  256. if assigned(srsym) and
  257. (srsym.typ=procsym) then
  258. begin
  259. { if vmt<>0 then newinstance }
  260. addstatement(newstatement,cifnode.create(
  261. caddnode.create(unequaln,
  262. load_vmt_pointer_node,
  263. cnilnode.create),
  264. cassignmentnode.create(
  265. ctypeconvnode.create_explicit(
  266. load_self_pointer_node,
  267. voidpointertype),
  268. ccallnode.create(nil,tprocsym(srsym),srsym.owner,load_vmt_pointer_node)),
  269. nil));
  270. end
  271. else
  272. internalerror(200305108);
  273. end
  274. else
  275. if is_object(current_procinfo.procdef._class) then
  276. begin
  277. htype.setdef(current_procinfo.procdef._class);
  278. htype.setdef(tpointerdef.create(htype));
  279. { parameter 3 : vmt_offset }
  280. { parameter 2 : address of pointer to vmt,
  281. this is required to allow setting the vmt to -1 to indicate
  282. that memory was allocated }
  283. { parameter 1 : self pointer }
  284. para:=ccallparanode.create(
  285. cordconstnode.create(current_procinfo.procdef._class.vmt_offset,s32inttype,false),
  286. ccallparanode.create(
  287. ctypeconvnode.create_explicit(
  288. load_vmt_pointer_node,
  289. voidpointertype),
  290. ccallparanode.create(
  291. ctypeconvnode.create_explicit(
  292. load_self_pointer_node,
  293. voidpointertype),
  294. nil)));
  295. addstatement(newstatement,cassignmentnode.create(
  296. ctypeconvnode.create_explicit(
  297. load_self_pointer_node,
  298. voidpointertype),
  299. ccallnode.createintern('fpc_help_constructor',para)));
  300. end
  301. else
  302. internalerror(200305103);
  303. { if self=nil then exit
  304. calling fail instead of exit is useless because
  305. there is nothing to dispose (PFV) }
  306. addstatement(newstatement,cifnode.create(
  307. caddnode.create(equaln,
  308. load_self_pointer_node,
  309. cnilnode.create),
  310. cexitnode.create(nil),
  311. nil));
  312. end;
  313. { maybe call BeforeDestruction for classes }
  314. if (current_procinfo.procdef.proctypeoption=potype_destructor) and
  315. is_class(current_procinfo.procdef._class) then
  316. begin
  317. srsym:=search_class_member(current_procinfo.procdef._class,'BEFOREDESTRUCTION');
  318. if assigned(srsym) and
  319. (srsym.typ=procsym) then
  320. begin
  321. { if vmt<>0 then beforedestruction }
  322. addstatement(newstatement,cifnode.create(
  323. caddnode.create(unequaln,
  324. load_vmt_pointer_node,
  325. cnilnode.create),
  326. ccallnode.create(nil,tprocsym(srsym),srsym.owner,load_self_node),
  327. nil));
  328. end
  329. else
  330. internalerror(200305104);
  331. end;
  332. end;
  333. end;
  334. function generate_bodyexit_block:tnode;
  335. var
  336. srsym : tsym;
  337. para : tcallparanode;
  338. newstatement : tstatementnode;
  339. begin
  340. result:=internalstatements(newstatement);
  341. if assigned(current_procinfo.procdef._class) then
  342. begin
  343. { maybe call AfterConstruction for classes }
  344. if (current_procinfo.procdef.proctypeoption=potype_constructor) and
  345. is_class(current_procinfo.procdef._class) then
  346. begin
  347. srsym:=search_class_member(current_procinfo.procdef._class,'AFTERCONSTRUCTION');
  348. if assigned(srsym) and
  349. (srsym.typ=procsym) then
  350. begin
  351. { Self can be nil when fail is called }
  352. { if self<>nil and vmt<>nil then afterconstruction }
  353. addstatement(newstatement,cifnode.create(
  354. caddnode.create(andn,
  355. caddnode.create(unequaln,
  356. load_self_pointer_node,
  357. cnilnode.create),
  358. caddnode.create(unequaln,
  359. load_vmt_pointer_node,
  360. cnilnode.create)),
  361. ccallnode.create(nil,tprocsym(srsym),srsym.owner,load_self_node),
  362. nil));
  363. end
  364. else
  365. internalerror(200305106);
  366. end;
  367. { a destructor needs a help procedure }
  368. if (current_procinfo.procdef.proctypeoption=potype_destructor) then
  369. begin
  370. if is_class(current_procinfo.procdef._class) then
  371. begin
  372. srsym:=search_class_member(current_procinfo.procdef._class,'FREEINSTANCE');
  373. if assigned(srsym) and
  374. (srsym.typ=procsym) then
  375. begin
  376. { if self<>0 and vmt=1 then freeinstance }
  377. addstatement(newstatement,cifnode.create(
  378. caddnode.create(andn,
  379. caddnode.create(unequaln,
  380. load_self_pointer_node,
  381. cnilnode.create),
  382. caddnode.create(equaln,
  383. ctypeconvnode.create(
  384. load_vmt_pointer_node,
  385. voidpointertype),
  386. cpointerconstnode.create(1,voidpointertype))),
  387. ccallnode.create(nil,tprocsym(srsym),srsym.owner,load_self_node),
  388. nil));
  389. end
  390. else
  391. internalerror(200305108);
  392. end
  393. else
  394. if is_object(current_procinfo.procdef._class) then
  395. begin
  396. { finalize object data }
  397. if current_procinfo.procdef._class.needs_inittable then
  398. addstatement(newstatement,finalize_data_node(load_self_node));
  399. { parameter 3 : vmt_offset }
  400. { parameter 2 : pointer to vmt }
  401. { parameter 1 : self pointer }
  402. para:=ccallparanode.create(
  403. cordconstnode.create(current_procinfo.procdef._class.vmt_offset,s32inttype,false),
  404. ccallparanode.create(
  405. ctypeconvnode.create_explicit(
  406. load_vmt_pointer_node,
  407. voidpointertype),
  408. ccallparanode.create(
  409. ctypeconvnode.create_explicit(
  410. load_self_pointer_node,
  411. voidpointertype),
  412. nil)));
  413. addstatement(newstatement,
  414. ccallnode.createintern('fpc_help_destructor',para));
  415. end
  416. else
  417. internalerror(200305105);
  418. end;
  419. end;
  420. end;
  421. function generate_except_block:tnode;
  422. var
  423. pd : tprocdef;
  424. newstatement : tstatementnode;
  425. begin
  426. generate_except_block:=internalstatements(newstatement);
  427. { a constructor needs call destructor (if available) when it
  428. is not inherited }
  429. if assigned(current_procinfo.procdef._class) and
  430. (current_procinfo.procdef.proctypeoption=potype_constructor) then
  431. begin
  432. pd:=current_procinfo.procdef._class.searchdestructor;
  433. if assigned(pd) then
  434. begin
  435. { if vmt<>0 then call destructor }
  436. addstatement(newstatement,cifnode.create(
  437. caddnode.create(unequaln,
  438. load_vmt_pointer_node,
  439. cnilnode.create),
  440. ccallnode.create(nil,tprocsym(pd.procsym),pd.procsym.owner,load_self_node),
  441. nil));
  442. end;
  443. end
  444. else
  445. begin
  446. { no constructor }
  447. { must be the return value finalized before reraising the exception? }
  448. if (not is_void(current_procinfo.procdef.rettype.def)) and
  449. (current_procinfo.procdef.rettype.def.needs_inittable) and
  450. (not is_class(current_procinfo.procdef.rettype.def)) then
  451. addstatement(newstatement,finalize_data_node(load_result_node));
  452. end;
  453. end;
  454. {****************************************************************************
  455. TCGProcInfo
  456. ****************************************************************************}
  457. constructor tcgprocinfo.create(aparent:tprocinfo);
  458. begin
  459. inherited Create(aparent);
  460. nestedprocs:=tlinkedlist.create;
  461. end;
  462. destructor tcgprocinfo.destroy;
  463. begin
  464. nestedprocs.free;
  465. if assigned(code) then
  466. code.free;
  467. inherited destroy;
  468. end;
  469. procedure tcgprocinfo.add_entry_exit_code;
  470. var
  471. finalcode,
  472. bodyentrycode,
  473. bodyexitcode,
  474. exceptcode : tnode;
  475. newblock : tblocknode;
  476. codestatement,
  477. newstatement : tstatementnode;
  478. oldfilepos : tfileposinfo;
  479. begin
  480. oldfilepos:=aktfilepos;
  481. { Generate code/locations used at start of proc }
  482. aktfilepos:=entrypos;
  483. entry_asmnode:=casmnode.create_get_position;
  484. loadpara_asmnode:=casmnode.create_get_position;
  485. init_asmnode:=casmnode.create_get_position;
  486. bodyentrycode:=generate_bodyentry_block;
  487. { Generate code/locations used at end of proc }
  488. aktfilepos:=exitpos;
  489. exitlabel_asmnode:=casmnode.create_get_position;
  490. final_asmnode:=casmnode.create_get_position;
  491. bodyexitcode:=generate_bodyexit_block;
  492. { Generate procedure by combining init+body+final,
  493. depending on the implicit finally we need to add
  494. an try...finally...end wrapper }
  495. newblock:=internalstatements(newstatement);
  496. if (cs_implicit_exceptions in aktmoduleswitches) and
  497. (pi_needs_implicit_finally in flags) and
  498. { but it's useless in init/final code of units }
  499. not(procdef.proctypeoption in [potype_unitfinalize,potype_unitinit]) then
  500. begin
  501. { Generate special exception block only needed when
  502. implicit finaly is used }
  503. aktfilepos:=exitpos;
  504. exceptcode:=generate_except_block;
  505. { Generate code that will be in the try...finally }
  506. finalcode:=internalstatements(codestatement);
  507. addstatement(codestatement,bodyexitcode);
  508. addstatement(codestatement,final_asmnode);
  509. { Initialize before try...finally...end frame }
  510. addstatement(newstatement,entry_asmnode);
  511. addstatement(newstatement,loadpara_asmnode);
  512. addstatement(newstatement,init_asmnode);
  513. addstatement(newstatement,bodyentrycode);
  514. aktfilepos:=entrypos;
  515. addstatement(newstatement,ctryfinallynode.create_implicit(
  516. code,
  517. finalcode,
  518. exceptcode));
  519. addstatement(newstatement,exitlabel_asmnode);
  520. { set flag the implicit finally has been generated }
  521. include(flags,pi_has_implicit_finally);
  522. end
  523. else
  524. begin
  525. addstatement(newstatement,entry_asmnode);
  526. addstatement(newstatement,loadpara_asmnode);
  527. addstatement(newstatement,init_asmnode);
  528. addstatement(newstatement,bodyentrycode);
  529. addstatement(newstatement,code);
  530. addstatement(newstatement,exitlabel_asmnode);
  531. addstatement(newstatement,bodyexitcode);
  532. addstatement(newstatement,final_asmnode);
  533. end;
  534. do_firstpass(newblock);
  535. code:=newblock;
  536. aktfilepos:=oldfilepos;
  537. end;
  538. procedure clearrefs(p : tnamedindexitem;arg:pointer);
  539. begin
  540. if (tsym(p).typ=varsym) then
  541. if tvarsym(p).refs>1 then
  542. tvarsym(p).refs:=1;
  543. end;
  544. procedure tcgprocinfo.generate_code;
  545. var
  546. oldprocinfo : tprocinfo;
  547. oldaktmaxfpuregisters : longint;
  548. oldfilepos : tfileposinfo;
  549. templist : Taasmoutput;
  550. headertai : tai;
  551. usesacc,
  552. usesfpu,
  553. usesacchi : boolean;
  554. begin
  555. { the initialization procedure can be empty, then we
  556. don't need to generate anything. When it was an empty
  557. procedure there would be at least a blocknode }
  558. if not assigned(code) then
  559. exit;
  560. { We need valid code }
  561. if Errorcount<>0 then
  562. exit;
  563. { The RA and Tempgen shall not be available yet }
  564. if assigned(tg) then
  565. internalerror(200309201);
  566. oldprocinfo:=current_procinfo;
  567. oldfilepos:=aktfilepos;
  568. oldaktmaxfpuregisters:=aktmaxfpuregisters;
  569. current_procinfo:=self;
  570. aktfilepos:=entrypos;
  571. { get new labels }
  572. aktbreaklabel:=nil;
  573. aktcontinuelabel:=nil;
  574. templist:=Taasmoutput.create;
  575. { add parast/localst to symtablestack }
  576. add_to_symtablestack;
  577. { when size optimization only count occurrence }
  578. if cs_littlesize in aktglobalswitches then
  579. cg.t_times:=1
  580. else
  581. { reference for repetition is 100 }
  582. cg.t_times:=100;
  583. { clear register count }
  584. symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}clearrefs,nil);
  585. symtablestack.next.foreach_static({$ifdef FPCPROCVAR}@{$endif}clearrefs,nil);
  586. { there's always a call to FPC_INITIALIZEUNITS/FPC_DO_EXIT in the main program }
  587. if (procdef.localst.symtablelevel=main_program_level) and
  588. (not current_module.is_unit) then
  589. include(flags,pi_do_call);
  590. { set implicit_finally flag when there are locals/paras to be finalized }
  591. current_procinfo.procdef.parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}check_finalize_paras,nil);
  592. current_procinfo.procdef.localst.foreach_static({$ifdef FPCPROCVAR}@{$endif}check_finalize_locals,nil);
  593. { firstpass everything }
  594. flowcontrol:=[];
  595. do_firstpass(code);
  596. if code.registersfpu>0 then
  597. include(current_procinfo.flags,pi_uses_fpu);
  598. { add implicit entry and exit code }
  599. add_entry_exit_code;
  600. { only do secondpass if there are no errors }
  601. if ErrorCount=0 then
  602. begin
  603. { set the start offset to the start of the temp area in the stack }
  604. tg:=ttgobj.create;
  605. { Create register allocator }
  606. cg.init_register_allocators;
  607. set_first_temp_offset;
  608. generate_parameter_info;
  609. { Allocate space in temp/registers for parast and localst }
  610. aktfilepos:=entrypos;
  611. gen_alloc_parast(aktproccode,tparasymtable(procdef.parast));
  612. if procdef.localst.symtabletype=localsymtable then
  613. gen_alloc_localst(aktproccode,tlocalsymtable(procdef.localst));
  614. { Store temp offset for information about 'real' temps }
  615. tempstart:=tg.lasttemp;
  616. { Generate code to load register parameters in temps and insert local
  617. copies for values parameters. This must be done before the code for the
  618. body is generated because the localloc is updated.
  619. Note: The generated code will be inserted after the code generation of
  620. the body is finished, because only then the position is known }
  621. {$ifdef oldregvars}
  622. assign_regvars(code);
  623. {$endif oldreg}
  624. aktfilepos:=entrypos;
  625. gen_load_para_value(templist);
  626. { caller paraloc info is also necessary in the stackframe_entry
  627. code of the ppc (and possibly other processors) }
  628. if not procdef.has_paraloc_info then
  629. begin
  630. procdef.requiredargarea:=paramanager.create_paraloc_info(procdef,callerside);
  631. procdef.has_paraloc_info:=true;
  632. end;
  633. { generate code for the node tree }
  634. do_secondpass(code);
  635. aktproccode.concatlist(exprasmlist);
  636. {$ifdef i386}
  637. procdef.fpu_used:=code.registersfpu;
  638. {$endif i386}
  639. { The position of the loadpara_asmnode is now known }
  640. aktproccode.insertlistafter(loadpara_asmnode.currenttai,templist);
  641. { first generate entry and initialize code with the correct
  642. position and switches }
  643. aktfilepos:=entrypos;
  644. aktlocalswitches:=entryswitches;
  645. gen_entry_code(templist);
  646. aktproccode.insertlistafter(entry_asmnode.currenttai,templist);
  647. gen_initialize_code(templist,false);
  648. aktproccode.insertlistafter(init_asmnode.currenttai,templist);
  649. { now generate finalize and exit code with the correct position
  650. and switches }
  651. aktfilepos:=exitpos;
  652. aktlocalswitches:=exitswitches;
  653. gen_finalize_code(templist,false);
  654. { the finalcode must be concated if there was no position available,
  655. using insertlistafter will result in an insert at the start
  656. when currentai=nil }
  657. if assigned(final_asmnode.currenttai) then
  658. aktproccode.insertlistafter(final_asmnode.currenttai,templist)
  659. else
  660. aktproccode.concatlist(templist);
  661. { insert exit label at the correct position }
  662. cg.a_label(templist,aktexitlabel);
  663. if assigned(exitlabel_asmnode.currenttai) then
  664. aktproccode.insertlistafter(exitlabel_asmnode.currenttai,templist)
  665. else
  666. aktproccode.concatlist(templist);
  667. { exit code }
  668. gen_exit_code(templist);
  669. aktproccode.concatlist(templist);
  670. {$ifdef OLDREGVARS}
  671. { note: this must be done only after as much code as possible has }
  672. { been generated. The result is that when you ungetregister() a }
  673. { regvar, it will actually free the regvar (and alse free the }
  674. { the regvars at the same time). Doing this too early will }
  675. { confuse the register allocator, as the regvars will still be }
  676. { used. It should be done before loading the result regs (so }
  677. { they don't conflict with the regvars) and before }
  678. { gen_entry_code (that one has to be able to allocate the }
  679. { regvars again) (JM) }
  680. free_regvars(aktproccode);
  681. {$endif OLDREGVARS}
  682. { add code that will load the return value, this is not done
  683. for assembler routines when they didn't reference the result
  684. variable }
  685. usesacc:=false;
  686. usesfpu:=false;
  687. usesacchi:=false;
  688. gen_load_return_value(templist,usesacc,usesacchi,usesfpu);
  689. aktproccode.concatlist(templist);
  690. { generate symbol and save end of header position }
  691. aktfilepos:=entrypos;
  692. gen_proc_symbol(templist);
  693. headertai:=tai(templist.last);
  694. { insert symbol }
  695. aktproccode.insertlist(templist);
  696. { Free space in temp/registers for parast and localst, must be
  697. done after gen_entry_code }
  698. aktfilepos:=exitpos;
  699. if procdef.localst.symtabletype=localsymtable then
  700. gen_free_localst(aktproccode,tlocalsymtable(procdef.localst));
  701. gen_free_parast(aktproccode,tparasymtable(procdef.parast));
  702. { The procedure body is finished, we can now
  703. allocate the registers }
  704. cg.do_register_allocation(aktproccode,headertai);
  705. { Add save and restore of used registers }
  706. aktfilepos:=entrypos;
  707. gen_save_used_regs(templist);
  708. aktproccode.insertlistafter(headertai,templist);
  709. aktfilepos:=exitpos;
  710. gen_restore_used_regs(aktproccode,procdef.funcret_paraloc[calleeside]);
  711. { Add stack allocation code after header }
  712. aktfilepos:=entrypos;
  713. gen_stackalloc_code(templist);
  714. aktproccode.insertlistafter(headertai,templist);
  715. { Add exit code at the end }
  716. aktfilepos:=exitpos;
  717. gen_stackfree_code(templist,usesacc,usesacchi);
  718. aktproccode.concatlist(templist);
  719. { check if the implicit finally has been generated. The flag
  720. should already be set in pass1 }
  721. if (cs_implicit_exceptions in aktmoduleswitches) and
  722. not(procdef.proctypeoption in [potype_unitfinalize,potype_unitinit]) and
  723. (pi_needs_implicit_finally in flags) and
  724. not(pi_has_implicit_finally in flags) then
  725. internalerror(200405231);
  726. {$ifndef NoOpt}
  727. if not(cs_no_regalloc in aktglobalswitches) then
  728. begin
  729. if (cs_optimize in aktglobalswitches) and
  730. { do not optimize pure assembler procedures }
  731. not(pi_is_assembler in flags) then
  732. optimize(aktproccode);
  733. end;
  734. {$endif NoOpt}
  735. { Add end symbol and debug info }
  736. aktfilepos:=exitpos;
  737. gen_proc_symbol_end(templist);
  738. aktproccode.concatlist(templist);
  739. {$ifdef ARM}
  740. insertpcrelativedata(aktproccode,aktlocaldata);
  741. {$endif ARM}
  742. { save local data (casetable) also in the same file }
  743. if assigned(aktlocaldata) and
  744. (not aktlocaldata.empty) then
  745. begin
  746. { because of the limited constant size of the arm, all data access is done pc relative }
  747. if target_info.cpu=cpu_arm then
  748. aktproccode.concatlist(aktlocaldata)
  749. else
  750. begin
  751. aktproccode.concat(Tai_section.Create(sec_data));
  752. aktproccode.concatlist(aktlocaldata);
  753. aktproccode.concat(Tai_section.Create(sec_code));
  754. end;
  755. end;
  756. { add the procedure to the codesegment }
  757. if (cs_create_smart in aktmoduleswitches) then
  758. codesegment.concat(Tai_cut.Create);
  759. codesegment.concatlist(aktproccode);
  760. { only now we can remove the temps }
  761. tg.resettempgen;
  762. { stop tempgen and ra }
  763. tg.free;
  764. cg.done_register_allocators;
  765. tg:=nil;
  766. end;
  767. { restore symtablestack }
  768. remove_from_symtablestack;
  769. { restore }
  770. templist.free;
  771. aktmaxfpuregisters:=oldaktmaxfpuregisters;
  772. aktfilepos:=oldfilepos;
  773. current_procinfo:=oldprocinfo;
  774. end;
  775. procedure tcgprocinfo.add_to_symtablestack;
  776. var
  777. _class,hp : tobjectdef;
  778. begin
  779. { insert symtables for the class, but only if it is no nested function }
  780. if assigned(procdef._class) and
  781. not(assigned(parent) and
  782. assigned(parent.procdef) and
  783. assigned(parent.procdef._class)) then
  784. begin
  785. { insert them in the reverse order }
  786. hp:=nil;
  787. repeat
  788. _class:=procdef._class;
  789. while _class.childof<>hp do
  790. _class:=_class.childof;
  791. hp:=_class;
  792. _class.symtable.next:=symtablestack;
  793. symtablestack:=_class.symtable;
  794. until hp=procdef._class;
  795. end;
  796. { insert parasymtable in symtablestack when parsing
  797. a function }
  798. if procdef.parast.symtablelevel>=normal_function_level then
  799. begin
  800. procdef.parast.next:=symtablestack;
  801. symtablestack:=procdef.parast;
  802. end;
  803. procdef.localst.next:=symtablestack;
  804. symtablestack:=procdef.localst;
  805. end;
  806. procedure tcgprocinfo.remove_from_symtablestack;
  807. begin
  808. { remove localst/parast }
  809. if procdef.parast.symtablelevel>=normal_function_level then
  810. symtablestack:=symtablestack.next.next
  811. else
  812. symtablestack:=symtablestack.next;
  813. { remove class member symbol tables }
  814. while symtablestack.symtabletype=objectsymtable do
  815. symtablestack:=symtablestack.next;
  816. end;
  817. procedure tcgprocinfo.resetprocdef;
  818. begin
  819. { the local symtables can be deleted, but the parast }
  820. { doesn't, (checking definitons when calling a }
  821. { function }
  822. { not for a inline procedure !! (PM) }
  823. { at lexlevel = 1 localst is the staticsymtable itself }
  824. { so no dispose here !! }
  825. if assigned(code) and
  826. not(cs_browser in aktmoduleswitches) and
  827. (procdef.proccalloption<>pocall_inline) then
  828. begin
  829. if procdef.parast.symtablelevel>=normal_function_level then
  830. procdef.localst.free;
  831. procdef.localst:=nil;
  832. end;
  833. { remove code tree, if not inline procedure }
  834. if assigned(code) then
  835. begin
  836. { the inline procedure has already got a copy of the tree
  837. stored in current_procinfo.procdef.code }
  838. code.free;
  839. code:=nil;
  840. if (procdef.proccalloption<>pocall_inline) then
  841. procdef.inlininginfo^.code:=nil;
  842. end;
  843. end;
  844. procedure tcgprocinfo.parse_body;
  845. var
  846. oldprocinfo : tprocinfo;
  847. oldblock_type : tblock_type;
  848. begin
  849. oldprocinfo:=current_procinfo;
  850. oldblock_type:=block_type;
  851. { reset break and continue labels }
  852. block_type:=bt_body;
  853. current_procinfo:=self;
  854. { calculate the lexical level }
  855. if procdef.parast.symtablelevel>maxnesting then
  856. Message(parser_e_too_much_lexlevel);
  857. { static is also important for local procedures !! }
  858. if (po_staticmethod in procdef.procoptions) then
  859. allow_only_static:=true
  860. else if (procdef.parast.symtablelevel=normal_function_level) then
  861. allow_only_static:=false;
  862. {$ifdef state_tracking}
  863. { aktstate:=Tstate_storage.create;}
  864. {$endif state_tracking}
  865. { create a local symbol table for this routine }
  866. if not assigned(procdef.localst) then
  867. procdef.insert_localst;
  868. { add parast/localst to symtablestack }
  869. add_to_symtablestack;
  870. { constant symbols are inserted in this symboltable }
  871. constsymtable:=symtablestack;
  872. { save entry info }
  873. entrypos:=aktfilepos;
  874. entryswitches:=aktlocalswitches;
  875. { parse the code ... }
  876. code:=block(current_module.islibrary);
  877. { save exit info }
  878. exitswitches:=aktlocalswitches;
  879. exitpos:=last_endtoken_filepos;
  880. { the procedure is now defined }
  881. procdef.forwarddef:=false;
  882. { Check for unused labels, forwards, symbols for procedures. Static
  883. symtable is checked in pmodules }
  884. if (Errorcount=0) and
  885. (tstoredsymtable(procdef.localst).symtabletype<>staticsymtable) then
  886. begin
  887. { check if forwards are resolved }
  888. tstoredsymtable(procdef.localst).check_forwards;
  889. { check if all labels are used }
  890. tstoredsymtable(procdef.localst).checklabels;
  891. { remove cross unit overloads }
  892. tstoredsymtable(procdef.localst).unchain_overloaded;
  893. { check for unused symbols, but only if there is no asm block }
  894. if not(pi_uses_asm in flags) then
  895. begin
  896. tstoredsymtable(procdef.localst).allsymbolsused;
  897. tstoredsymtable(procdef.parast).allsymbolsused;
  898. end;
  899. end;
  900. if assigned(code) then
  901. begin
  902. { get a better entry point }
  903. entrypos:=code.fileinfo;
  904. { Finish type checking pass }
  905. do_resulttypepass(code);
  906. end;
  907. { store a copy of the original tree for inline, for
  908. normal procedures only store a reference to the
  909. current tree }
  910. if (procdef.proccalloption=pocall_inline) then
  911. begin
  912. procdef.inlininginfo^.code:=code.getcopy;
  913. procdef.inlininginfo^.flags:=current_procinfo.flags;
  914. end
  915. else
  916. procdef.inlininginfo^.code:=code;
  917. { Print the node to tree.log }
  918. if paraprintnodetree=1 then
  919. printnode_procdef(procdef);
  920. { ... remove symbol tables }
  921. remove_from_symtablestack;
  922. {$ifdef state_tracking}
  923. { aktstate.destroy;}
  924. {$endif state_tracking}
  925. { reset to normal non static function }
  926. if (procdef.parast.symtablelevel=normal_function_level) then
  927. allow_only_static:=false;
  928. current_procinfo:=oldprocinfo;
  929. block_type:=oldblock_type;
  930. end;
  931. {****************************************************************************
  932. PROCEDURE/FUNCTION PARSING
  933. ****************************************************************************}
  934. procedure check_init_paras(p:tnamedindexitem;arg:pointer);
  935. begin
  936. if tsym(p).typ<>varsym then
  937. exit;
  938. with tvarsym(p) do
  939. if (not is_class(vartype.def) and
  940. vartype.def.needs_inittable and
  941. (varspez in [vs_value,vs_out])) then
  942. include(current_procinfo.flags,pi_do_call);
  943. end;
  944. procedure read_proc;
  945. {
  946. Parses the procedure directives, then parses the procedure body, then
  947. generates the code for it
  948. }
  949. procedure do_generate_code(pi:tcgprocinfo);
  950. var
  951. hpi : tcgprocinfo;
  952. begin
  953. { generate code for this procedure }
  954. pi.generate_code;
  955. { process nested procs }
  956. hpi:=tcgprocinfo(pi.nestedprocs.first);
  957. while assigned(hpi) do
  958. begin
  959. do_generate_code(hpi);
  960. hpi:=tcgprocinfo(hpi.next);
  961. end;
  962. pi.resetprocdef;
  963. end;
  964. var
  965. old_current_procinfo : tprocinfo;
  966. oldconstsymtable : tsymtable;
  967. oldfailtokenmode : tmodeswitch;
  968. pdflags : tpdflags;
  969. pd : tprocdef;
  970. isnestedproc : boolean;
  971. begin
  972. { save old state }
  973. oldconstsymtable:=constsymtable;
  974. old_current_procinfo:=current_procinfo;
  975. { reset current_procinfo.procdef to nil to be sure that nothing is writing
  976. to an other procdef }
  977. current_procinfo:=nil;
  978. { parse procedure declaration }
  979. if assigned(old_current_procinfo) and
  980. assigned(old_current_procinfo.procdef) then
  981. pd:=parse_proc_dec(old_current_procinfo.procdef._class)
  982. else
  983. pd:=parse_proc_dec(nil);
  984. { set the default function options }
  985. if parse_only then
  986. begin
  987. pd.forwarddef:=true;
  988. { set also the interface flag, for better error message when the
  989. implementation doesn't much this header }
  990. pd.interfacedef:=true;
  991. include(pd.procoptions,po_public);
  992. pdflags:=[pd_interface];
  993. end
  994. else
  995. begin
  996. pdflags:=[pd_body];
  997. if (not current_module.in_interface) then
  998. include(pdflags,pd_implemen);
  999. if (not current_module.is_unit) or
  1000. (cs_create_smart in aktmoduleswitches) then
  1001. include(pd.procoptions,po_public);
  1002. pd.forwarddef:=false;
  1003. end;
  1004. { parse the directives that may follow }
  1005. parse_proc_directives(pd,pdflags);
  1006. { hint directives, these can be separated by semicolons here,
  1007. that needs to be handled here with a loop (PFV) }
  1008. while try_consume_hintdirective(pd.symoptions) do
  1009. Consume(_SEMICOLON);
  1010. { Set calling convention }
  1011. handle_calling_convention(pd);
  1012. { everything of the proc definition is known, we can now
  1013. calculate the parameters }
  1014. calc_parast(pd);
  1015. { search for forward declarations }
  1016. if not proc_add_definition(pd) then
  1017. begin
  1018. { A method must be forward defined (in the object declaration) }
  1019. if assigned(pd._class) and
  1020. (not assigned(old_current_procinfo.procdef._class)) then
  1021. begin
  1022. MessagePos1(pd.fileinfo,parser_e_header_dont_match_any_member,pd.fullprocname(false));
  1023. tprocsym(pd.procsym).write_parameter_lists(pd);
  1024. end
  1025. else
  1026. begin
  1027. { Give a better error if there is a forward def in the interface and only
  1028. a single implementation }
  1029. if (not pd.forwarddef) and
  1030. (not pd.interfacedef) and
  1031. (tprocsym(pd.procsym).procdef_count>1) and
  1032. tprocsym(pd.procsym).first_procdef.forwarddef and
  1033. tprocsym(pd.procsym).first_procdef.interfacedef and
  1034. not(tprocsym(pd.procsym).procdef_count>2) then
  1035. begin
  1036. MessagePos1(pd.fileinfo,parser_e_header_dont_match_forward,pd.fullprocname(false));
  1037. tprocsym(pd.procsym).write_parameter_lists(pd);
  1038. end;
  1039. end;
  1040. end;
  1041. { compile procedure when a body is needed }
  1042. if (pd_body in pdflags) then
  1043. begin
  1044. Message1(parser_d_procedure_start,pd.fullprocname(false));
  1045. { create a new procedure }
  1046. current_procinfo:=cprocinfo.create(old_current_procinfo);
  1047. current_module.procinfo:=current_procinfo;
  1048. current_procinfo.procdef:=pd;
  1049. isnestedproc:=(current_procinfo.procdef.parast.symtablelevel>normal_function_level);
  1050. { Insert mangledname }
  1051. pd.aliasnames.insert(pd.mangledname);
  1052. { Insert result variables in the localst }
  1053. insert_funcret_local(pd);
  1054. { check if there are para's which require initing -> set }
  1055. { pi_do_call (if not yet set) }
  1056. if not(pi_do_call in current_procinfo.flags) then
  1057. pd.parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}check_init_paras,nil);
  1058. { set _FAIL as keyword if constructor }
  1059. if (pd.proctypeoption=potype_constructor) then
  1060. begin
  1061. oldfailtokenmode:=tokeninfo^[_FAIL].keyword;
  1062. tokeninfo^[_FAIL].keyword:=m_all;
  1063. end;
  1064. tcgprocinfo(current_procinfo).parse_body;
  1065. { When it's a nested procedure then defer the code generation,
  1066. when back at normal function level then generate the code
  1067. for all defered nested procedures and the current procedure }
  1068. if isnestedproc then
  1069. tcgprocinfo(current_procinfo.parent).nestedprocs.insert(current_procinfo)
  1070. else
  1071. begin
  1072. { We can't support inlining for procedures that have nested
  1073. procedures because the nested procedures use a fixed offset
  1074. for accessing locals in the parent procedure (PFV) }
  1075. if (current_procinfo.procdef.proccalloption=pocall_inline) and
  1076. (tcgprocinfo(current_procinfo).nestedprocs.count>0) then
  1077. begin
  1078. Message1(parser_w_not_supported_for_inline,'nested procedures');
  1079. Message(parser_w_inlining_disabled);
  1080. current_procinfo.procdef.proccalloption:=pocall_default;
  1081. end;
  1082. do_generate_code(tcgprocinfo(current_procinfo));
  1083. end;
  1084. { reset _FAIL as _SELF normal }
  1085. if (pd.proctypeoption=potype_constructor) then
  1086. tokeninfo^[_FAIL].keyword:=oldfailtokenmode;
  1087. { release procinfo }
  1088. if tprocinfo(current_module.procinfo)<>current_procinfo then
  1089. internalerror(200304274);
  1090. current_module.procinfo:=current_procinfo.parent;
  1091. if not isnestedproc then
  1092. current_procinfo.free;
  1093. consume(_SEMICOLON);
  1094. end;
  1095. { Restore old state }
  1096. constsymtable:=oldconstsymtable;
  1097. current_procinfo:=old_current_procinfo;
  1098. end;
  1099. {****************************************************************************
  1100. DECLARATION PARSING
  1101. ****************************************************************************}
  1102. { search in symtablestack for not complete classes }
  1103. procedure check_forward_class(p : tnamedindexitem;arg:pointer);
  1104. begin
  1105. if (tsym(p).typ=typesym) and
  1106. (ttypesym(p).restype.def.deftype=objectdef) and
  1107. (oo_is_forward in tobjectdef(ttypesym(p).restype.def).objectoptions) then
  1108. MessagePos1(tsym(p).fileinfo,sym_e_forward_type_not_resolved,tsym(p).realname);
  1109. end;
  1110. procedure read_declarations(islibrary : boolean);
  1111. begin
  1112. repeat
  1113. if not assigned(current_procinfo) then
  1114. internalerror(200304251);
  1115. case token of
  1116. _LABEL:
  1117. label_dec;
  1118. _CONST:
  1119. const_dec;
  1120. _TYPE:
  1121. type_dec;
  1122. _VAR:
  1123. var_dec;
  1124. _THREADVAR:
  1125. threadvar_dec;
  1126. _CONSTRUCTOR,
  1127. _DESTRUCTOR,
  1128. _FUNCTION,
  1129. _PROCEDURE,
  1130. _OPERATOR,
  1131. _CLASS:
  1132. read_proc;
  1133. _EXPORTS:
  1134. begin
  1135. if not(assigned(current_procinfo.procdef.localst)) or
  1136. (current_procinfo.procdef.localst.symtablelevel>main_program_level) or
  1137. (current_module.is_unit) then
  1138. begin
  1139. Message(parser_e_syntax_error);
  1140. consume_all_until(_SEMICOLON);
  1141. end
  1142. else if islibrary or
  1143. (target_info.system in [system_i386_WIN32,system_i386_wdosx,system_i386_Netware]) then
  1144. read_exports
  1145. else
  1146. begin
  1147. Message(parser_w_unsupported_feature);
  1148. consume(_BEGIN);
  1149. end;
  1150. end
  1151. else
  1152. begin
  1153. case idtoken of
  1154. _RESOURCESTRING :
  1155. resourcestring_dec;
  1156. _PROPERTY:
  1157. begin
  1158. if (m_fpc in aktmodeswitches) then
  1159. property_dec
  1160. else
  1161. break;
  1162. end;
  1163. else
  1164. break;
  1165. end;
  1166. end;
  1167. end;
  1168. until false;
  1169. { check for incomplete class definitions, this is only required
  1170. for fpc modes }
  1171. if (m_fpc in aktmodeswitches) then
  1172. symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}check_forward_class,nil);
  1173. end;
  1174. procedure read_interface_declarations;
  1175. begin
  1176. repeat
  1177. case token of
  1178. _CONST :
  1179. const_dec;
  1180. _TYPE :
  1181. type_dec;
  1182. _VAR :
  1183. var_dec;
  1184. _THREADVAR :
  1185. threadvar_dec;
  1186. _FUNCTION,
  1187. _PROCEDURE,
  1188. _OPERATOR :
  1189. read_proc;
  1190. else
  1191. begin
  1192. case idtoken of
  1193. _RESOURCESTRING :
  1194. resourcestring_dec;
  1195. _PROPERTY:
  1196. begin
  1197. if (m_fpc in aktmodeswitches) then
  1198. property_dec
  1199. else
  1200. break;
  1201. end;
  1202. else
  1203. break;
  1204. end;
  1205. end;
  1206. end;
  1207. until false;
  1208. { check for incomplete class definitions, this is only required
  1209. for fpc modes }
  1210. if (m_fpc in aktmodeswitches) then
  1211. symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}check_forward_class,nil);
  1212. end;
  1213. end.
  1214. {
  1215. $Log$
  1216. Revision 1.191 2004-05-23 15:06:21 peter
  1217. * implicit_finally flag must be set in pass1
  1218. * add check whether the implicit frame is generated when expected
  1219. Revision 1.190 2004/05/20 21:54:33 florian
  1220. + <pointer> - <pointer> result is divided by the pointer element size now
  1221. this is delphi compatible as well as resulting in the expected result for p1+(p2-p1)
  1222. Revision 1.189 2004/05/19 22:25:56 jonas
  1223. * fixed web bug 3104: if stack checking is on, procedures pi_do_call
  1224. must be set
  1225. Revision 1.188 2004/05/16 13:29:21 peter
  1226. * fix checking for forwards in static symtable
  1227. Revision 1.187 2004/04/11 12:37:30 peter
  1228. * fix tree printing
  1229. Revision 1.186 2004/02/19 17:07:42 florian
  1230. * fixed arg. area calculation
  1231. Revision 1.185 2004/02/08 18:08:59 jonas
  1232. * fixed regvars support. Needs -doldregvars to activate. Only tested with
  1233. ppc, other processors should however only require maxregvars and
  1234. maxfpuregvars constants in cpubase.pas. Remember to take scratch-
  1235. registers into account when defining that value.
  1236. Revision 1.184 2004/02/04 22:01:13 peter
  1237. * first try to get cpupara working for x86_64
  1238. Revision 1.183 2004/02/03 22:32:54 peter
  1239. * renamed xNNbittype to xNNinttype
  1240. * renamed registers32 to registersint
  1241. * replace some s32bit,u32bit with torddef([su]inttype).def.typ
  1242. Revision 1.182 2004/01/21 19:01:03 florian
  1243. * fixed handling of max. distance of pc relative symbols
  1244. Revision 1.181 2003/12/21 19:42:43 florian
  1245. * fixed ppc inlining stuff
  1246. * fixed wrong unit writing
  1247. + added some sse stuff
  1248. Revision 1.180 2003/12/19 22:08:44 daniel
  1249. * Some work to restore the MMX capabilities
  1250. Revision 1.179 2003/12/16 22:36:19 florian
  1251. * forgot a commit
  1252. Revision 1.178 2003/12/16 21:29:24 florian
  1253. + inlined procedures inherit procinfo flags
  1254. Revision 1.177 2003/12/15 21:25:48 peter
  1255. * reg allocations for imaginary register are now inserted just
  1256. before reg allocation
  1257. * tregister changed to enum to allow compile time check
  1258. * fixed several tregister-tsuperregister errors
  1259. Revision 1.176 2003/12/10 16:37:01 peter
  1260. * global property support for fpc modes
  1261. Revision 1.175 2003/12/03 23:13:20 peter
  1262. * delayed paraloc allocation, a_param_*() gets extra parameter
  1263. if it needs to allocate temp or real paralocation
  1264. * optimized/simplified int-real loading
  1265. Revision 1.174 2003/11/27 09:08:01 florian
  1266. * resourcestring is allowed in the interface
  1267. Revision 1.173 2003/11/23 17:05:16 peter
  1268. * register calling is left-right
  1269. * parameter ordering
  1270. * left-right calling inserts result parameter last
  1271. Revision 1.172 2003/11/22 00:40:19 jonas
  1272. * fixed optimiser so it compiles again
  1273. * fixed several bugs which were in there already for a long time, but
  1274. which only popped up now :) -O2/-O3 will now optimise less than in
  1275. the past (and correctly so), but -O2u/-O3u will optimise a bit more
  1276. * some more small improvements for -O3 are still possible
  1277. Revision 1.171 2003/11/10 22:02:52 peter
  1278. * cross unit inlining fixed
  1279. Revision 1.170 2003/11/07 15:58:32 florian
  1280. * Florian's culmutative nr. 1; contains:
  1281. - invalid calling conventions for a certain cpu are rejected
  1282. - arm softfloat calling conventions
  1283. - -Sp for cpu dependend code generation
  1284. - several arm fixes
  1285. - remaining code for value open array paras on heap
  1286. Revision 1.169 2003/10/31 15:52:18 peter
  1287. * fix crash with fail in constructor
  1288. Revision 1.168 2003/10/30 16:22:40 peter
  1289. * call firstpass before allocation and codegeneration is started
  1290. * move leftover code from pass_2.generatecode() to psub
  1291. Revision 1.167 2003/10/24 17:40:23 peter
  1292. * cleanup of the entry and exit code insertion
  1293. Revision 1.166 2003/10/21 15:14:33 peter
  1294. * fixed memleak for initfinalcode
  1295. * exit from generatecode when there are already errors
  1296. Revision 1.165 2003/10/20 19:28:51 peter
  1297. * disable inlining when nested procedures are found
  1298. Revision 1.164 2003/10/19 01:34:30 florian
  1299. * some ppc stuff fixed
  1300. * memory leak fixed
  1301. Revision 1.163 2003/10/17 14:38:32 peter
  1302. * 64k registers supported
  1303. * fixed some memory leaks
  1304. Revision 1.162 2003/10/10 17:48:13 peter
  1305. * old trgobj moved to x86/rgcpu and renamed to trgx86fpu
  1306. * tregisteralloctor renamed to trgobj
  1307. * removed rgobj from a lot of units
  1308. * moved location_* and reference_* to cgobj
  1309. * first things for mmx register allocation
  1310. Revision 1.161 2003/10/09 21:31:37 daniel
  1311. * Register allocator splitted, ans abstract now
  1312. Revision 1.160 2003/10/09 15:20:56 peter
  1313. * self is not a token anymore. It is handled special when found
  1314. in a code block and when parsing an method
  1315. Revision 1.159 2003/10/07 15:17:07 peter
  1316. * inline supported again, LOC_REFERENCEs are used to pass the
  1317. parameters
  1318. * inlineparasymtable,inlinelocalsymtable removed
  1319. * exitlabel inserting fixed
  1320. Revision 1.158 2003/10/06 22:23:41 florian
  1321. + added basic olevariant support
  1322. Revision 1.157 2003/10/03 14:45:09 peter
  1323. * more proc directive for procvar fixes
  1324. Revision 1.156 2003/10/02 21:20:32 peter
  1325. * handle_calling_convention removed from parse_proc_directive to
  1326. separate call
  1327. Revision 1.155 2003/10/01 20:34:49 peter
  1328. * procinfo unit contains tprocinfo
  1329. * cginfo renamed to cgbase
  1330. * moved cgmessage to verbose
  1331. * fixed ppc and sparc compiles
  1332. Revision 1.154 2003/09/29 20:58:56 peter
  1333. * optimized releasing of registers
  1334. Revision 1.153 2003/09/28 17:55:04 peter
  1335. * parent framepointer changed to hidden parameter
  1336. * tloadparentfpnode added
  1337. Revision 1.152 2003/09/27 13:29:43 peter
  1338. * fix reported file position for not matched forwards
  1339. Revision 1.151 2003/09/25 21:25:13 peter
  1340. * remove allocate_intterupt_parameter, allocation is platform
  1341. dependent and needs to be done in create_paraloc_info
  1342. Revision 1.150 2003/09/25 16:19:32 peter
  1343. * fix filepositions
  1344. * insert spill temp allocations at the start of the proc
  1345. Revision 1.149 2003/09/23 17:56:06 peter
  1346. * locals and paras are allocated in the code generation
  1347. * tvarsym.localloc contains the location of para/local when
  1348. generating code for the current procedure
  1349. Revision 1.148 2003/09/14 19:18:10 peter
  1350. * remove obsolete code already in comments
  1351. Revision 1.147 2003/09/14 12:58:00 peter
  1352. * support mulitple overloads in implementation, this is delphi
  1353. compatible
  1354. * procsym only stores the overloads available in the interface
  1355. Revision 1.146 2003/09/12 19:07:42 daniel
  1356. * Fixed fast spilling functionality by re-adding the code that initializes
  1357. precoloured nodes to degree 255. I would like to play hangman on the one
  1358. who removed that code.
  1359. Revision 1.145 2003/09/10 19:14:31 daniel
  1360. * Failed attempt to restore broken fastspill functionality
  1361. Revision 1.144 2003/09/09 20:59:27 daniel
  1362. * Adding register allocation order
  1363. Revision 1.143 2003/09/09 15:55:44 peter
  1364. * use register with least interferences in spillregister
  1365. Revision 1.142 2003/09/07 22:09:35 peter
  1366. * preparations for different default calling conventions
  1367. * various RA fixes
  1368. Revision 1.141 2003/09/04 14:46:12 peter
  1369. * abort with IE when spilling requires > 20 loops
  1370. Revision 1.140 2003/09/03 15:55:01 peter
  1371. * NEWRA branch merged
  1372. Revision 1.139 2003/09/03 11:18:37 florian
  1373. * fixed arm concatcopy
  1374. + arm support in the common compiler sources added
  1375. * moved some generic cg code around
  1376. + tfputype added
  1377. * ...
  1378. Revision 1.138.2.1 2003/08/31 13:50:16 daniel
  1379. * Remove sorting and use pregenerated indexes
  1380. * Some work on making things compile
  1381. Revision 1.138 2003/08/20 17:48:49 peter
  1382. * fixed stackalloc to not allocate localst.datasize twice
  1383. * order of stackalloc code fixed for implicit init/final
  1384. Revision 1.137 2003/08/20 15:50:35 peter
  1385. * define NOOPT until optimizer is fixed
  1386. Revision 1.136 2003/08/20 09:07:00 daniel
  1387. * New register coding now mandatory, some more convert_registers calls
  1388. removed.
  1389. Revision 1.135 2003/08/20 07:48:03 daniel
  1390. * Made internal assembler use new register coding
  1391. Revision 1.134 2003/08/17 16:59:20 jonas
  1392. * fixed regvars so they work with newra (at least for ppc)
  1393. * fixed some volatile register bugs
  1394. + -dnotranslation option for -dnewra, which causes the registers not to
  1395. be translated from virtual to normal registers. Requires support in
  1396. the assembler writer as well, which is only implemented in aggas/
  1397. agppcgas currently
  1398. Revision 1.133 2003/07/23 11:04:15 jonas
  1399. * split en_exit_code into a part that may allocate a register and a part
  1400. that doesn't, so the former can be done before the register colouring
  1401. has been performed
  1402. Revision 1.132 2003/07/06 17:58:22 peter
  1403. * framepointer fixes for sparc
  1404. * parent framepointer code more generic
  1405. Revision 1.131 2003/07/06 15:31:21 daniel
  1406. * Fixed register allocator. *Lots* of fixes.
  1407. Revision 1.130 2003/07/05 20:15:24 jonas
  1408. * set pi_do_call if range/overflow checking is on
  1409. Revision 1.129 2003/06/17 16:34:44 jonas
  1410. * lots of newra fixes (need getfuncretparaloc implementation for i386)!
  1411. * renamed all_intregisters to paramanager.get_volatile_registers_int(pocall_default) and made it
  1412. processor dependent
  1413. Revision 1.128 2003/06/14 14:53:50 jonas
  1414. * fixed newra cycle for x86
  1415. * added constants for indicating source and destination operands of the
  1416. "move reg,reg" instruction to aasmcpu (and use those in rgobj)
  1417. Revision 1.127 2003/06/13 21:19:31 peter
  1418. * current_procdef removed, use current_procinfo.procdef instead
  1419. Revision 1.126 2003/06/12 16:43:07 peter
  1420. * newra compiles for sparc
  1421. Revision 1.125 2003/06/09 12:23:30 peter
  1422. * init/final of procedure data splitted from genentrycode
  1423. * use asmnode getposition to insert final at the correct position
  1424. als for the implicit try...finally
  1425. Revision 1.124 2003/06/07 19:37:43 jonas
  1426. * pi_do_call must always be set for the main program, since it always
  1427. ends with a call to FPC_DO_EXIT
  1428. Revision 1.123 2003/06/07 18:57:04 jonas
  1429. + added freeintparaloc
  1430. * ppc get/freeintparaloc now check whether the parameter regs are
  1431. properly allocated/deallocated (and get an extra list para)
  1432. * ppc a_call_* now internalerrors if pi_do_call is not yet set
  1433. * fixed lot of missing pi_do_call's
  1434. Revision 1.122 2003/06/03 13:01:59 daniel
  1435. * Register allocator finished
  1436. Revision 1.121 2003/05/31 20:23:39 jonas
  1437. * added pi_do_call if a procedure has a value shortstring parameter
  1438. (it's copied to the local stackframe with a helper)
  1439. Revision 1.120 2003/05/30 23:57:08 peter
  1440. * more sparc cleanup
  1441. * accumulator removed, splitted in function_return_reg (called) and
  1442. function_result_reg (caller)
  1443. Revision 1.119 2003/05/28 23:58:18 jonas
  1444. * added missing initialization of rg.usedintin,byproc
  1445. * ppc now also saves/restores used fpu registers
  1446. * ncgcal doesn't add used registers to usedby/inproc anymore, except for
  1447. i386
  1448. Revision 1.118 2003/05/26 21:17:18 peter
  1449. * procinlinenode removed
  1450. * aktexit2label removed, fast exit removed
  1451. + tcallnode.inlined_pass_2 added
  1452. Revision 1.117 2003/05/25 08:59:47 peter
  1453. * do not generate code when there was an error
  1454. Revision 1.116 2003/05/23 18:49:55 jonas
  1455. * generate code for parent procedure before that of nested procedures as
  1456. well (I only need pass_1 to be done for the ppc, but pass_1 and pass_2
  1457. are grouped and it doesn't hurt that pass_2 is done as well)
  1458. Revision 1.115 2003/05/22 21:31:35 peter
  1459. * defer codegeneration for nested procedures
  1460. Revision 1.114 2003/05/16 20:00:39 jonas
  1461. * powerpc nested procedure fixes, should work completely now if all
  1462. local variables of the parent procedure are declared before the
  1463. nested procedures are declared
  1464. Revision 1.113 2003/05/16 14:33:31 peter
  1465. * regvar fixes
  1466. Revision 1.112 2003/05/13 21:26:38 peter
  1467. * only call destructor in except block when there is a destructor
  1468. available
  1469. Revision 1.111 2003/05/13 19:14:41 peter
  1470. * failn removed
  1471. * inherited result code check moven to pexpr
  1472. Revision 1.110 2003/05/13 15:18:49 peter
  1473. * fixed various crashes
  1474. Revision 1.109 2003/05/11 21:37:03 peter
  1475. * moved implicit exception frame from ncgutil to psub
  1476. * constructor/destructor helpers moved from cobj/ncgutil to psub
  1477. Revision 1.108 2003/05/09 17:47:03 peter
  1478. * self moved to hidden parameter
  1479. * removed hdisposen,hnewn,selfn
  1480. Revision 1.107 2003/04/27 11:21:34 peter
  1481. * aktprocdef renamed to current_procinfo.procdef
  1482. * procinfo renamed to current_procinfo
  1483. * procinfo will now be stored in current_module so it can be
  1484. cleaned up properly
  1485. * gen_main_procsym changed to create_main_proc and release_main_proc
  1486. to also generate a tprocinfo structure
  1487. * fixed unit implicit initfinal
  1488. Revision 1.106 2003/04/27 07:29:50 peter
  1489. * current_procinfo.procdef cleanup, current_procdef is now always nil when parsing
  1490. a new procdef declaration
  1491. * aktprocsym removed
  1492. * lexlevel removed, use symtable.symtablelevel instead
  1493. * implicit init/final code uses the normal genentry/genexit
  1494. * funcret state checking updated for new funcret handling
  1495. Revision 1.105 2003/04/26 00:31:42 peter
  1496. * set return_offset moved to after_header
  1497. Revision 1.104 2003/04/25 20:59:34 peter
  1498. * removed funcretn,funcretsym, function result is now in varsym
  1499. and aliases for result and function name are added using absolutesym
  1500. * vs_hidden parameter for funcret passed in parameter
  1501. * vs_hidden fixes
  1502. * writenode changed to printnode and released from extdebug
  1503. * -vp option added to generate a tree.log with the nodetree
  1504. * nicer printnode for statements, callnode
  1505. Revision 1.103 2003/04/24 13:03:01 florian
  1506. * comp is now written with its bit pattern to the ppu instead as an extended
  1507. Revision 1.102 2003/04/23 12:35:34 florian
  1508. * fixed several issues with powerpc
  1509. + applied a patch from Jonas for nested function calls (PowerPC only)
  1510. * ...
  1511. Revision 1.101 2003/04/22 14:33:38 peter
  1512. * removed some notes/hints
  1513. Revision 1.100 2003/04/22 13:47:08 peter
  1514. * fixed C style array of const
  1515. * fixed C array passing
  1516. * fixed left to right with high parameters
  1517. Revision 1.99 2003/04/22 10:09:35 daniel
  1518. + Implemented the actual register allocator
  1519. + Scratch registers unavailable when new register allocator used
  1520. + maybe_save/maybe_restore unavailable when new register allocator used
  1521. Revision 1.98 2003/04/17 07:50:24 daniel
  1522. * Some work on interference graph construction
  1523. Revision 1.97 2003/04/16 09:26:55 jonas
  1524. * assembler procedures now again get a stackframe if they have local
  1525. variables. No space is reserved for a function result however.
  1526. Also, the register parameters aren't automatically saved on the stack
  1527. anymore in assembler procedures.
  1528. Revision 1.96 2003/04/05 21:09:31 jonas
  1529. * several ppc/generic result offset related fixes. The "normal" result
  1530. offset seems now to be calculated correctly and a lot of duplicate
  1531. calculations have been removed. Nested functions accessing the parent's
  1532. function result don't work at all though :(
  1533. Revision 1.95 2003/04/02 16:11:34 peter
  1534. * give error when exports is not supported
  1535. Revision 1.94 2003/03/12 22:43:38 jonas
  1536. * more powerpc and generic fixes related to the new register allocator
  1537. Revision 1.93 2003/03/08 08:59:07 daniel
  1538. + $define newra will enable new register allocator
  1539. + getregisterint will return imaginary registers with $newra
  1540. + -sr switch added, will skip register allocation so you can see
  1541. the direct output of the code generator before register allocation
  1542. Revision 1.92 2003/02/19 22:00:14 daniel
  1543. * Code generator converted to new register notation
  1544. - Horribily outdated todo.txt removed
  1545. Revision 1.91 2003/01/09 21:52:37 peter
  1546. * merged some verbosity options.
  1547. * V_LineInfo is a verbosity flag to include line info
  1548. Revision 1.90 2003/01/09 20:40:59 daniel
  1549. * Converted some code in cgx86.pas to new register numbering
  1550. Revision 1.89 2003/01/09 15:49:56 daniel
  1551. * Added register conversion
  1552. Revision 1.88 2003/01/08 18:43:56 daniel
  1553. * Tregister changed into a record
  1554. Revision 1.87 2003/01/03 20:35:08 peter
  1555. * check also interfacedef when checking for matching forwarddef
  1556. Revision 1.86 2003/01/02 11:14:02 michael
  1557. + Patch from peter to support initial values for local variables
  1558. Revision 1.85 2002/12/29 18:59:34 peter
  1559. * fixed parsing of declarations before asm statement
  1560. Revision 1.84 2002/12/29 18:25:18 peter
  1561. * parse declarations before check _ASM token
  1562. Revision 1.83 2002/12/29 14:57:50 peter
  1563. * unit loading changed to first register units and load them
  1564. afterwards. This is needed to support uses xxx in yyy correctly
  1565. * unit dependency check fixed
  1566. Revision 1.82 2002/12/25 01:26:56 peter
  1567. * duplicate procsym-unitsym fix
  1568. Revision 1.81 2002/12/15 13:37:15 peter
  1569. * don't include uf_init for library. The code is already called and
  1570. does not need to be in the initfinal table
  1571. Revision 1.80 2002/12/07 14:27:09 carl
  1572. * 3% memory optimization
  1573. * changed some types
  1574. + added type checking with different size for call node and for
  1575. parameters
  1576. Revision 1.79 2002/11/25 18:43:32 carl
  1577. - removed the invalid if <> checking (Delphi is strange on this)
  1578. + implemented abstract warning on instance creation of class with
  1579. abstract methods.
  1580. * some error message cleanups
  1581. Revision 1.78 2002/11/25 17:43:23 peter
  1582. * splitted defbase in defutil,symutil,defcmp
  1583. * merged isconvertable and is_equal into compare_defs(_ext)
  1584. * made operator search faster by walking the list only once
  1585. Revision 1.77 2002/11/23 22:50:06 carl
  1586. * some small speed optimizations
  1587. + added several new warnings/hints
  1588. Revision 1.76 2002/11/18 17:31:58 peter
  1589. * pass proccalloption to ret_in_xxx and push_xxx functions
  1590. Revision 1.75 2002/11/17 16:31:57 carl
  1591. * memory optimization (3-4%) : cleanup of tai fields,
  1592. cleanup of tdef and tsym fields.
  1593. * make it work for m68k
  1594. Revision 1.74 2002/11/15 01:58:53 peter
  1595. * merged changes from 1.0.7 up to 04-11
  1596. - -V option for generating bug report tracing
  1597. - more tracing for option parsing
  1598. - errors for cdecl and high()
  1599. - win32 import stabs
  1600. - win32 records<=8 are returned in eax:edx (turned off by default)
  1601. - heaptrc update
  1602. - more info for temp management in .s file with EXTDEBUG
  1603. Revision 1.73 2002/11/09 15:32:30 carl
  1604. * noopt for non-i386 targets
  1605. Revision 1.72 2002/09/10 20:31:48 florian
  1606. * call to current_procinfo.after_header added
  1607. Revision 1.71 2002/09/07 15:25:07 peter
  1608. * old logs removed and tabs fixed
  1609. Revision 1.70 2002/09/03 16:26:27 daniel
  1610. * Make Tprocdef.defs protected
  1611. Revision 1.69 2002/08/25 19:25:20 peter
  1612. * sym.insert_in_data removed
  1613. * symtable.insertvardata/insertconstdata added
  1614. * removed insert_in_data call from symtable.insert, it needs to be
  1615. called separatly. This allows to deref the address calculation
  1616. * procedures now calculate the parast addresses after the procedure
  1617. directives are parsed. This fixes the cdecl parast problem
  1618. * push_addr_param has an extra argument that specifies if cdecl is used
  1619. or not
  1620. Revision 1.68 2002/08/17 09:23:41 florian
  1621. * first part of procinfo rewrite
  1622. Revision 1.67 2002/08/16 14:24:59 carl
  1623. * issameref() to test if two references are the same (then emit no opcodes)
  1624. + ret_in_reg to replace ret_in_acc
  1625. (fix some register allocation bugs at the same time)
  1626. + save_std_register now has an extra parameter which is the
  1627. usedinproc registers
  1628. Revision 1.66 2002/08/11 14:32:27 peter
  1629. * renamed current_library to objectlibrary
  1630. Revision 1.65 2002/08/11 13:24:13 peter
  1631. * saving of asmsymbols in ppu supported
  1632. * asmsymbollist global is removed and moved into a new class
  1633. tasmlibrarydata that will hold the info of a .a file which
  1634. corresponds with a single module. Added librarydata to tmodule
  1635. to keep the library info stored for the module. In the future the
  1636. objectfiles will also be stored to the tasmlibrarydata class
  1637. * all getlabel/newasmsymbol and friends are moved to the new class
  1638. Revision 1.64 2002/08/09 19:14:28 carl
  1639. * fixed stackframe parameter (should only contain local size),
  1640. set to zero currently
  1641. Revision 1.63 2002/08/06 20:55:22 florian
  1642. * first part of ppc calling conventions fix
  1643. Revision 1.62 2002/07/26 21:15:41 florian
  1644. * rewrote the system handling
  1645. Revision 1.61 2002/07/20 11:57:56 florian
  1646. * types.pas renamed to defbase.pas because D6 contains a types
  1647. unit so this would conflicts if D6 programms are compiled
  1648. + Willamette/SSE2 instructions to assembler added
  1649. Revision 1.60 2002/07/19 11:41:36 daniel
  1650. * State tracker work
  1651. * The whilen and repeatn are now completely unified into whilerepeatn. This
  1652. allows the state tracker to change while nodes automatically into
  1653. repeat nodes.
  1654. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  1655. 'not(a>b)' is optimized into 'a<=b'.
  1656. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  1657. by removing the notn and later switchting the true and falselabels. The
  1658. same is done with 'repeat until not a'.
  1659. Revision 1.59 2002/07/15 18:03:15 florian
  1660. * readded removed changes
  1661. Revision 1.57 2002/07/11 14:41:28 florian
  1662. * start of the new generic parameter handling
  1663. Revision 1.58 2002/07/14 18:00:44 daniel
  1664. + Added the beginning of a state tracker. This will track the values of
  1665. variables through procedures and optimize things away.
  1666. Revision 1.56 2002/07/07 09:52:32 florian
  1667. * powerpc target fixed, very simple units can be compiled
  1668. * some basic stuff for better callparanode handling, far from being finished
  1669. Revision 1.55 2002/07/04 20:43:01 florian
  1670. * first x86-64 patches
  1671. Revision 1.54 2002/07/01 18:46:25 peter
  1672. * internal linker
  1673. * reorganized aasm layer
  1674. Revision 1.53 2002/05/18 13:34:14 peter
  1675. * readded missing revisions
  1676. Revision 1.52 2002/05/16 19:46:44 carl
  1677. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1678. + try to fix temp allocation (still in ifdef)
  1679. + generic constructor calls
  1680. + start of tassembler / tmodulebase class cleanup
  1681. Revision 1.51 2002/05/14 19:34:49 peter
  1682. * removed old logs and updated copyright year
  1683. }