nflw.pas 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Type checking and register allocation for nodes that influence
  5. the flow
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit nflw;
  20. {$i fpcdefs.inc}
  21. interface
  22. uses
  23. node,cpubase,
  24. aasmbase,aasmtai,aasmcpu,symnot,
  25. symppu,symtype,symbase,symdef,symsym;
  26. type
  27. { flags used by loop nodes }
  28. tloopflags = (
  29. { set if it is a for ... downto ... do loop }
  30. lnf_backward,
  31. { Do we need to parse childs to set var state? }
  32. lnf_varstate,
  33. { Do a test at the begin of the loop?}
  34. lnf_testatbegin,
  35. { Negate the loop test? }
  36. lnf_checknegate,
  37. { Should the value of the loop variable on exit be correct. }
  38. lnf_dont_mind_loopvar_on_exit);
  39. const
  40. { loop flags which must match to consider loop nodes equal regarding the flags }
  41. loopflagsequal = [lnf_backward];
  42. type
  43. tloopnode = class(tbinarynode)
  44. t1,t2 : tnode;
  45. loopflags : set of tloopflags;
  46. constructor create(tt : tnodetype;l,r,_t1,_t2 : tnode);virtual;
  47. destructor destroy;override;
  48. function getcopy : tnode;override;
  49. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  50. procedure ppuwrite(ppufile:tcompilerppufile);override;
  51. procedure derefimpl;override;
  52. procedure insertintolist(l : tnodelist);override;
  53. procedure printnodetree(var t:text);override;
  54. function docompare(p: tnode): boolean; override;
  55. end;
  56. twhilerepeatnode = class(tloopnode)
  57. constructor create(l,r,_t1:Tnode;tab,cn:boolean);virtual;
  58. function det_resulttype:tnode;override;
  59. function pass_1 : tnode;override;
  60. {$ifdef state_tracking}
  61. function track_state_pass(exec_known:boolean):boolean;override;
  62. {$endif}
  63. end;
  64. twhilerepeatnodeclass = class of twhilerepeatnode;
  65. tifnode = class(tloopnode)
  66. constructor create(l,r,_t1 : tnode);virtual;
  67. function det_resulttype:tnode;override;
  68. function pass_1 : tnode;override;
  69. end;
  70. tifnodeclass = class of tifnode;
  71. tfornode = class(tloopnode)
  72. loopvar_notid:cardinal;
  73. constructor create(l,r,_t1,_t2 : tnode;back : boolean);virtual;
  74. procedure loop_var_access(not_type:Tnotification_flag;symbol:Tsym);
  75. function det_resulttype:tnode;override;
  76. function pass_1 : tnode;override;
  77. end;
  78. tfornodeclass = class of tfornode;
  79. texitnode = class(tunarynode)
  80. onlyassign : boolean;
  81. constructor create(l:tnode);virtual;
  82. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  83. procedure ppuwrite(ppufile:tcompilerppufile);override;
  84. function det_resulttype:tnode;override;
  85. function pass_1 : tnode;override;
  86. end;
  87. texitnodeclass = class of texitnode;
  88. tbreaknode = class(tnode)
  89. constructor create;virtual;
  90. function det_resulttype:tnode;override;
  91. function pass_1 : tnode;override;
  92. end;
  93. tbreaknodeclass = class of tbreaknode;
  94. tcontinuenode = class(tnode)
  95. constructor create;virtual;
  96. function det_resulttype:tnode;override;
  97. function pass_1 : tnode;override;
  98. end;
  99. tcontinuenodeclass = class of tcontinuenode;
  100. tgotonode = class(tnode)
  101. labsym : tlabelsym;
  102. exceptionblock : integer;
  103. constructor create(p : tlabelsym);virtual;
  104. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  105. procedure ppuwrite(ppufile:tcompilerppufile);override;
  106. procedure derefimpl;override;
  107. function getcopy : tnode;override;
  108. function det_resulttype:tnode;override;
  109. function pass_1 : tnode;override;
  110. function docompare(p: tnode): boolean; override;
  111. end;
  112. tgotonodeclass = class of tgotonode;
  113. tlabelnode = class(tunarynode)
  114. labelnr : tasmlabel;
  115. labsym : tlabelsym;
  116. exceptionblock : integer;
  117. constructor createcase(p : tasmlabel;l:tnode);virtual;
  118. constructor create(p : tlabelsym;l:tnode);virtual;
  119. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  120. procedure ppuwrite(ppufile:tcompilerppufile);override;
  121. procedure derefimpl;override;
  122. function getcopy : tnode;override;
  123. function det_resulttype:tnode;override;
  124. function pass_1 : tnode;override;
  125. function docompare(p: tnode): boolean; override;
  126. end;
  127. tlabelnodeclass = class of tlabelnode;
  128. traisenode = class(tbinarynode)
  129. frametree : tnode;
  130. constructor create(l,taddr,tframe:tnode);virtual;
  131. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  132. procedure ppuwrite(ppufile:tcompilerppufile);override;
  133. procedure derefimpl;override;
  134. function getcopy : tnode;override;
  135. procedure insertintolist(l : tnodelist);override;
  136. function det_resulttype:tnode;override;
  137. function pass_1 : tnode;override;
  138. function docompare(p: tnode): boolean; override;
  139. end;
  140. traisenodeclass = class of traisenode;
  141. ttryexceptnode = class(tloopnode)
  142. constructor create(l,r,_t1 : tnode);virtual;
  143. function det_resulttype:tnode;override;
  144. function pass_1 : tnode;override;
  145. end;
  146. ttryexceptnodeclass = class of ttryexceptnode;
  147. ttryfinallynode = class(tbinarynode)
  148. constructor create(l,r:tnode);virtual;
  149. function det_resulttype:tnode;override;
  150. function pass_1 : tnode;override;
  151. end;
  152. ttryfinallynodeclass = class of ttryfinallynode;
  153. tonnode = class(tbinarynode)
  154. exceptsymtable : tsymtable;
  155. excepttype : tobjectdef;
  156. constructor create(l,r:tnode);virtual;
  157. destructor destroy;override;
  158. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  159. function det_resulttype:tnode;override;
  160. function pass_1 : tnode;override;
  161. function getcopy : tnode;override;
  162. function docompare(p: tnode): boolean; override;
  163. end;
  164. tonnodeclass = class of tonnode;
  165. tfailnode = class(tnode)
  166. constructor create;virtual;
  167. function det_resulttype:tnode;override;
  168. function pass_1: tnode;override;
  169. function docompare(p: tnode): boolean; override;
  170. end;
  171. tfailnodeclass = class of tfailnode;
  172. { for compatibilty }
  173. function genloopnode(t : tnodetype;l,r,n1 : tnode;back : boolean) : tnode;
  174. var
  175. cwhilerepeatnode : twhilerepeatnodeclass;
  176. cifnode : tifnodeclass;
  177. cfornode : tfornodeclass;
  178. cexitnode : texitnodeclass;
  179. cbreaknode : tbreaknodeclass;
  180. ccontinuenode : tcontinuenodeclass;
  181. cgotonode : tgotonodeclass;
  182. clabelnode : tlabelnodeclass;
  183. craisenode : traisenodeclass;
  184. ctryexceptnode : ttryexceptnodeclass;
  185. ctryfinallynode : ttryfinallynodeclass;
  186. connode : tonnodeclass;
  187. cfailnode : tfailnodeclass;
  188. implementation
  189. uses
  190. globtype,systems,
  191. cutils,verbose,globals,
  192. symconst,symtable,paramgr,defutil,htypechk,pass_1,
  193. ncon,nmem,nld,ncnv,nbas,rgobj,
  194. {$ifdef state_tracking}
  195. nstate,
  196. {$endif}
  197. cginfo,cgbase
  198. ;
  199. function genloopnode(t : tnodetype;l,r,n1 : tnode;back : boolean) : tnode;
  200. var
  201. p : tnode;
  202. begin
  203. case t of
  204. ifn:
  205. p:=cifnode.create(l,r,n1);
  206. whilerepeatn:
  207. if back then
  208. {Repeat until.}
  209. p:=cwhilerepeatnode.create(l,r,n1,false,true)
  210. else
  211. {While do.}
  212. p:=cwhilerepeatnode.create(l,r,n1,true,false);
  213. forn:
  214. p:=cfornode.create(l,r,n1,nil,back);
  215. end;
  216. genloopnode:=p;
  217. end;
  218. {****************************************************************************
  219. TLOOPNODE
  220. *****************************************************************************}
  221. constructor tloopnode.create(tt : tnodetype;l,r,_t1,_t2 : tnode);
  222. begin
  223. inherited create(tt,l,r);
  224. t1:=_t1;
  225. t2:=_t2;
  226. set_file_line(l);
  227. end;
  228. destructor tloopnode.destroy;
  229. begin
  230. t1.free;
  231. t2.free;
  232. inherited destroy;
  233. end;
  234. constructor tloopnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  235. begin
  236. inherited ppuload(t,ppufile);
  237. t1:=ppuloadnode(ppufile);
  238. t2:=ppuloadnode(ppufile);
  239. end;
  240. procedure tloopnode.ppuwrite(ppufile:tcompilerppufile);
  241. begin
  242. inherited ppuwrite(ppufile);
  243. ppuwritenode(ppufile,t1);
  244. ppuwritenode(ppufile,t2);
  245. end;
  246. procedure tloopnode.derefimpl;
  247. begin
  248. inherited derefimpl;
  249. if assigned(t1) then
  250. t1.derefimpl;
  251. if assigned(t2) then
  252. t2.derefimpl;
  253. end;
  254. function tloopnode.getcopy : tnode;
  255. var
  256. p : tloopnode;
  257. begin
  258. p:=tloopnode(inherited getcopy);
  259. if assigned(t1) then
  260. p.t1:=t1.getcopy
  261. else
  262. p.t1:=nil;
  263. if assigned(t2) then
  264. p.t2:=t2.getcopy
  265. else
  266. p.t2:=nil;
  267. getcopy:=p;
  268. end;
  269. procedure tloopnode.insertintolist(l : tnodelist);
  270. begin
  271. end;
  272. procedure tloopnode.printnodetree(var t:text);
  273. begin
  274. printnodeinfo(t);
  275. printnodeindent;
  276. printnode(t,left);
  277. printnode(t,right);
  278. printnode(t,t1);
  279. printnode(t,t2);
  280. printnodeunindent;
  281. end;
  282. function tloopnode.docompare(p: tnode): boolean;
  283. begin
  284. docompare :=
  285. inherited docompare(p) and
  286. (loopflags*loopflagsequal=tloopnode(p).loopflags*loopflagsequal) and
  287. t1.isequal(tloopnode(p).t1) and
  288. t2.isequal(tloopnode(p).t2);
  289. end;
  290. {****************************************************************************
  291. TWHILEREPEATNODE
  292. *****************************************************************************}
  293. constructor Twhilerepeatnode.create(l,r,_t1:Tnode;tab,cn:boolean);
  294. begin
  295. inherited create(whilerepeatn,l,r,_t1,nil);
  296. if tab then
  297. include(loopflags, lnf_testatbegin);
  298. if cn then
  299. include(loopflags,lnf_checknegate);
  300. end;
  301. function twhilerepeatnode.det_resulttype:tnode;
  302. var
  303. t:Tunarynode;
  304. begin
  305. result:=nil;
  306. resulttype:=voidtype;
  307. resulttypepass(left);
  308. {A not node can be removed.}
  309. if left.nodetype=notn then
  310. begin
  311. t:=Tunarynode(left);
  312. left:=Tunarynode(left).left;
  313. t.left:=nil;
  314. t.destroy;
  315. {$ifdef Delphi}
  316. { How can this be handled in Delphi ? }
  317. RunError(255);
  318. {$else}
  319. {Symdif operator, in case you are wondering:}
  320. loopflags:=loopflags >< [lnf_checknegate];
  321. {$endif}
  322. end;
  323. { loop instruction }
  324. if assigned(right) then
  325. resulttypepass(right);
  326. set_varstate(left,true);
  327. if codegenerror then
  328. exit;
  329. if not is_boolean(left.resulttype.def) then
  330. begin
  331. CGMessage(type_e_mismatch);
  332. exit;
  333. end;
  334. end;
  335. function twhilerepeatnode.pass_1 : tnode;
  336. var
  337. old_t_times : longint;
  338. begin
  339. result:=nil;
  340. expectloc:=LOC_VOID;
  341. old_t_times:=rg.t_times;
  342. { calc register weight }
  343. if not(cs_littlesize in aktglobalswitches ) then
  344. rg.t_times:=rg.t_times*8;
  345. {$ifndef newra}
  346. rg.cleartempgen;
  347. {$endif}
  348. firstpass(left);
  349. if codegenerror then
  350. exit;
  351. registers32:=left.registers32;
  352. registersfpu:=left.registersfpu;
  353. {$ifdef SUPPORT_MMX}
  354. registersmmx:=left.registersmmx;
  355. {$endif SUPPORT_MMX}
  356. { loop instruction }
  357. if assigned(right) then
  358. begin
  359. {$ifndef newra}
  360. rg.cleartempgen;
  361. {$endif}
  362. firstpass(right);
  363. if codegenerror then
  364. exit;
  365. if registers32<right.registers32 then
  366. registers32:=right.registers32;
  367. if registersfpu<right.registersfpu then
  368. registersfpu:=right.registersfpu;
  369. {$ifdef SUPPORT_MMX}
  370. if registersmmx<right.registersmmx then
  371. registersmmx:=right.registersmmx;
  372. {$endif SUPPORT_MMX}
  373. end;
  374. rg.t_times:=old_t_times;
  375. end;
  376. {$ifdef state_tracking}
  377. function Twhilerepeatnode.track_state_pass(exec_known:boolean):boolean;
  378. var condition:Tnode;
  379. code:Tnode;
  380. done:boolean;
  381. value:boolean;
  382. change:boolean;
  383. firsttest:boolean;
  384. factval:Tnode;
  385. begin
  386. track_state_pass:=false;
  387. done:=false;
  388. firsttest:=true;
  389. {For repeat until statements, first do a pass through the code.}
  390. if not(lnf_testatbegin in flags) then
  391. begin
  392. code:=right.getcopy;
  393. if code.track_state_pass(exec_known) then
  394. track_state_pass:=true;
  395. code.destroy;
  396. end;
  397. repeat
  398. condition:=left.getcopy;
  399. code:=right.getcopy;
  400. change:=condition.track_state_pass(exec_known);
  401. factval:=aktstate.find_fact(left);
  402. if factval<>nil then
  403. begin
  404. condition.destroy;
  405. condition:=factval.getcopy;
  406. change:=true;
  407. end;
  408. if change then
  409. begin
  410. track_state_pass:=true;
  411. {Force new resulttype pass.}
  412. condition.resulttype.def:=nil;
  413. do_resulttypepass(condition);
  414. end;
  415. if is_constboolnode(condition) then
  416. begin
  417. {Try to turn a while loop into a repeat loop.}
  418. if firsttest then
  419. exclude(flags,testatbegin);
  420. value:=(Tordconstnode(condition).value<>0) xor checknegate;
  421. if value then
  422. begin
  423. if code.track_state_pass(exec_known) then
  424. track_state_pass:=true;
  425. end
  426. else
  427. done:=true;
  428. end
  429. else
  430. begin
  431. {Remove any modified variables from the state.}
  432. code.track_state_pass(false);
  433. done:=true;
  434. end;
  435. code.destroy;
  436. condition.destroy;
  437. firsttest:=false;
  438. until done;
  439. {The loop condition is also known, for example:
  440. while i<10 do
  441. begin
  442. ...
  443. end;
  444. When the loop is done, we do know that i<10 = false.
  445. }
  446. condition:=left.getcopy;
  447. if condition.track_state_pass(exec_known) then
  448. begin
  449. track_state_pass:=true;
  450. {Force new resulttype pass.}
  451. condition.resulttype.def:=nil;
  452. do_resulttypepass(condition);
  453. end;
  454. if not is_constboolnode(condition) then
  455. aktstate.store_fact(condition,
  456. cordconstnode.create(byte(checknegate),booltype,true))
  457. else
  458. condition.destroy;
  459. end;
  460. {$endif}
  461. {*****************************************************************************
  462. TIFNODE
  463. *****************************************************************************}
  464. constructor tifnode.create(l,r,_t1 : tnode);
  465. begin
  466. inherited create(ifn,l,r,_t1,nil);
  467. end;
  468. function tifnode.det_resulttype:tnode;
  469. begin
  470. result:=nil;
  471. resulttype:=voidtype;
  472. resulttypepass(left);
  473. { if path }
  474. if assigned(right) then
  475. resulttypepass(right);
  476. { else path }
  477. if assigned(t1) then
  478. resulttypepass(t1);
  479. set_varstate(left,true);
  480. if codegenerror then
  481. exit;
  482. if not is_boolean(left.resulttype.def) then
  483. Message1(type_e_boolean_expr_expected,left.resulttype.def.typename);
  484. end;
  485. function tifnode.pass_1 : tnode;
  486. var
  487. old_t_times : longint;
  488. hp : tnode;
  489. begin
  490. result:=nil;
  491. expectloc:=LOC_VOID;
  492. old_t_times:=rg.t_times;
  493. {$ifndef newra}
  494. rg.cleartempgen;
  495. {$endif}
  496. firstpass(left);
  497. registers32:=left.registers32;
  498. registersfpu:=left.registersfpu;
  499. {$ifdef SUPPORT_MMX}
  500. registersmmx:=left.registersmmx;
  501. {$endif SUPPORT_MMX}
  502. { determines registers weigths }
  503. if not(cs_littlesize in aktglobalswitches) then
  504. rg.t_times:=rg.t_times div 2;
  505. if rg.t_times=0 then
  506. rg.t_times:=1;
  507. { if path }
  508. if assigned(right) then
  509. begin
  510. {$ifndef newra}
  511. rg.cleartempgen;
  512. {$endif}
  513. firstpass(right);
  514. if registers32<right.registers32 then
  515. registers32:=right.registers32;
  516. if registersfpu<right.registersfpu then
  517. registersfpu:=right.registersfpu;
  518. {$ifdef SUPPORT_MMX}
  519. if registersmmx<right.registersmmx then
  520. registersmmx:=right.registersmmx;
  521. {$endif SUPPORT_MMX}
  522. end;
  523. { else path }
  524. if assigned(t1) then
  525. begin
  526. {$ifndef newra}
  527. rg.cleartempgen;
  528. {$endif}
  529. firstpass(t1);
  530. if registers32<t1.registers32 then
  531. registers32:=t1.registers32;
  532. if registersfpu<t1.registersfpu then
  533. registersfpu:=t1.registersfpu;
  534. {$ifdef SUPPORT_MMX}
  535. if registersmmx<t1.registersmmx then
  536. registersmmx:=t1.registersmmx;
  537. {$endif SUPPORT_MMX}
  538. end;
  539. { leave if we've got an error in one of the paths }
  540. if codegenerror then
  541. exit;
  542. if left.nodetype=ordconstn then
  543. begin
  544. { optimize }
  545. if tordconstnode(left).value=1 then
  546. begin
  547. hp:=right;
  548. right:=nil;
  549. { we cannot set p to nil !!! }
  550. if assigned(hp) then
  551. result:=hp
  552. else
  553. result:=cnothingnode.create;
  554. end
  555. else
  556. begin
  557. hp:=t1;
  558. t1:=nil;
  559. { we cannot set p to nil !!! }
  560. if assigned(hp) then
  561. result:=hp
  562. else
  563. result:=cnothingnode.create;
  564. end;
  565. end;
  566. rg.t_times:=old_t_times;
  567. end;
  568. {*****************************************************************************
  569. TFORNODE
  570. *****************************************************************************}
  571. constructor tfornode.create(l,r,_t1,_t2 : tnode;back : boolean);
  572. begin
  573. inherited create(forn,l,r,_t1,_t2);
  574. if back then
  575. include(loopflags,lnf_backward);
  576. include(loopflags,lnf_testatbegin);
  577. end;
  578. procedure Tfornode.loop_var_access(not_type:Tnotification_flag;
  579. symbol:Tsym);
  580. begin
  581. {If there is a read access, the value of the loop counter is important;
  582. at the end of the loop the loop variable should contain the value it
  583. had in the last iteration.}
  584. if not_type=vn_onwrite then
  585. begin
  586. writeln('Loopvar does not matter on exit');
  587. end
  588. else
  589. begin
  590. exclude(loopflags,lnf_dont_mind_loopvar_on_exit);
  591. writeln('Loopvar does matter on exit');
  592. end;
  593. Tvarsym(symbol).unregister_notification(loopvar_notid);
  594. end;
  595. function tfornode.det_resulttype:tnode;
  596. var
  597. hp : tnode;
  598. begin
  599. result:=nil;
  600. resulttype:=voidtype;
  601. if left.nodetype<>assignn then
  602. begin
  603. CGMessage(cg_e_illegal_expression);
  604. exit;
  605. end;
  606. {Can we spare the first comparision?}
  607. if (right.nodetype=ordconstn) and (Tassignmentnode(left).right.nodetype=ordconstn) then
  608. if (
  609. (lnf_backward in loopflags) and
  610. (Tordconstnode(Tassignmentnode(left).right).value>=Tordconstnode(right).value)
  611. )
  612. or not(
  613. (lnf_backward in loopflags) and
  614. (Tordconstnode(Tassignmentnode(left).right).value<=Tordconstnode(right).value)
  615. ) then
  616. exclude(loopflags,lnf_testatbegin);
  617. { save counter var }
  618. t2:=tassignmentnode(left).left.getcopy;
  619. resulttypepass(left);
  620. set_varstate(left,false);
  621. if assigned(t1) then
  622. begin
  623. resulttypepass(t1);
  624. if codegenerror then
  625. exit;
  626. end;
  627. { process count var }
  628. resulttypepass(t2);
  629. set_varstate(t2,true);
  630. if codegenerror then
  631. exit;
  632. { Check count var, record fields are also allowed in tp7 }
  633. hp:=t2;
  634. while (hp.nodetype=subscriptn) or
  635. ((hp.nodetype=vecn) and
  636. is_constintnode(tvecnode(hp).right)) do
  637. hp:=tunarynode(hp).left;
  638. { we need a simple loadn, but the load must be in a global symtable or
  639. in the same lexlevel }
  640. if (
  641. (hp.nodetype=loadn) and
  642. (
  643. (tloadnode(hp).symtable.symtablelevel<=1) or
  644. (tloadnode(hp).symtable.symtablelevel=lexlevel)
  645. ) and
  646. not(
  647. (tloadnode(hp).symtableentry.typ=varsym) and
  648. ((tvarsym(tloadnode(hp).symtableentry).varspez in [vs_var,vs_out]) or
  649. (vo_is_thread_var in tvarsym(tloadnode(hp).symtableentry).varoptions))
  650. )
  651. ) then
  652. begin
  653. if (hp.nodetype=loadn) and
  654. (tloadnode(hp).symtableentry.typ=varsym) then
  655. tvarsym(tloadnode(hp).symtableentry).varstate:=vs_used;
  656. if (not(is_ordinal(t2.resulttype.def)) or is_64bitint(t2.resulttype.def)) then
  657. CGMessagePos(hp.fileinfo,type_e_ordinal_expr_expected);
  658. end
  659. else
  660. CGMessagePos(hp.fileinfo,cg_e_illegal_count_var);
  661. resulttypepass(right);
  662. set_varstate(right,true);
  663. inserttypeconv(right,t2.resulttype);
  664. end;
  665. function tfornode.pass_1 : tnode;
  666. var
  667. old_t_times : longint;
  668. {$ifdef loopvar_dont_mind}
  669. hp : Tnode;
  670. {$endif loopvar_dont_mind}
  671. begin
  672. result:=nil;
  673. expectloc:=LOC_VOID;
  674. { Calc register weight }
  675. old_t_times:=rg.t_times;
  676. if not(cs_littlesize in aktglobalswitches) then
  677. rg.t_times:=rg.t_times*8;
  678. {$ifndef newra}
  679. rg.cleartempgen;
  680. {$endif}
  681. firstpass(left);
  682. {$ifndef newra}
  683. rg.cleartempgen;
  684. {$endif}
  685. if assigned(t1) then
  686. begin
  687. firstpass(t1);
  688. if codegenerror then
  689. exit;
  690. end;
  691. registers32:=t1.registers32;
  692. registersfpu:=t1.registersfpu;
  693. {$ifdef SUPPORT_MMX}
  694. registersmmx:=left.registersmmx;
  695. {$endif SUPPORT_MMX}
  696. if left.registers32>registers32 then
  697. registers32:=left.registers32;
  698. if left.registersfpu>registersfpu then
  699. registersfpu:=left.registersfpu;
  700. {$ifdef SUPPORT_MMX}
  701. if left.registersmmx>registersmmx then
  702. registersmmx:=left.registersmmx;
  703. {$endif SUPPORT_MMX}
  704. { process count var }
  705. {$ifndef newra}
  706. rg.cleartempgen;
  707. {$endif}
  708. firstpass(t2);
  709. if codegenerror then
  710. exit;
  711. if t2.registers32>registers32 then
  712. registers32:=t2.registers32;
  713. if t2.registersfpu>registersfpu then
  714. registersfpu:=t2.registersfpu;
  715. {$ifdef SUPPORT_MMX}
  716. if t2.registersmmx>registersmmx then
  717. registersmmx:=t2.registersmmx;
  718. {$endif SUPPORT_MMX}
  719. {$ifndef newra}
  720. rg.cleartempgen;
  721. {$endif}
  722. firstpass(right);
  723. {$ifdef loopvar_dont_mind}
  724. { Check count var, record fields are also allowed in tp7 }
  725. include(loopflags,lnf_dont_mind_loopvar_on_exit);
  726. hp:=t2;
  727. while (hp.nodetype=subscriptn) or
  728. ((hp.nodetype=vecn) and
  729. is_constintnode(tvecnode(hp).right)) do
  730. hp:=tunarynode(hp).left;
  731. if (hp.nodetype=loadn) and (Tloadnode(hp).symtableentry.typ=varsym) then
  732. loopvar_notid:=Tvarsym(Tloadnode(hp).symtableentry).
  733. register_notification([vn_onread,vn_onwrite],@loop_var_access);
  734. {$endif}
  735. if right.registers32>registers32 then
  736. registers32:=right.registers32;
  737. if right.registersfpu>registersfpu then
  738. registersfpu:=right.registersfpu;
  739. {$ifdef SUPPORT_MMX}
  740. if right.registersmmx>registersmmx then
  741. registersmmx:=right.registersmmx;
  742. {$endif SUPPORT_MMX}
  743. { we need at least one register for comparisons PM }
  744. if registers32=0 then
  745. inc(registers32);
  746. rg.t_times:=old_t_times;
  747. end;
  748. {*****************************************************************************
  749. TEXITNODE
  750. *****************************************************************************}
  751. constructor texitnode.create(l:tnode);
  752. begin
  753. inherited create(exitn,l);
  754. onlyassign:=false;
  755. end;
  756. constructor texitnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  757. begin
  758. inherited ppuload(t,ppufile);
  759. onlyassign:=boolean(ppufile.getbyte);
  760. end;
  761. procedure texitnode.ppuwrite(ppufile:tcompilerppufile);
  762. begin
  763. inherited ppuwrite(ppufile);
  764. ppufile.putbyte(byte(onlyassign));
  765. end;
  766. function texitnode.det_resulttype:tnode;
  767. var
  768. pt : tnode;
  769. begin
  770. result:=nil;
  771. { Check the 2 types }
  772. if not inlining_procedure then
  773. begin
  774. if assigned(left) then
  775. begin
  776. inserttypeconv(left,aktprocdef.rettype);
  777. if paramanager.ret_in_param(aktprocdef.rettype.def,aktprocdef.proccalloption) or
  778. (procinfo.no_fast_exit) or
  779. ((procinfo.flags and pi_uses_exceptions)<>0) then
  780. begin
  781. left:=cassignmentnode.create(
  782. cloadnode.create(aktprocdef.funcretsym,aktprocdef.funcretsym.owner),
  783. left);
  784. onlyassign:=true;
  785. end;
  786. tvarsym(aktprocdef.funcretsym).varstate:=vs_assigned;
  787. end;
  788. end;
  789. if assigned(left) then
  790. begin
  791. resulttypepass(left);
  792. set_varstate(left,true);
  793. end;
  794. resulttype:=voidtype;
  795. end;
  796. function texitnode.pass_1 : tnode;
  797. begin
  798. result:=nil;
  799. expectloc:=LOC_VOID;
  800. if assigned(left) then
  801. begin
  802. firstpass(left);
  803. if codegenerror then
  804. exit;
  805. registers32:=left.registers32;
  806. registersfpu:=left.registersfpu;
  807. {$ifdef SUPPORT_MMX}
  808. registersmmx:=left.registersmmx;
  809. {$endif SUPPORT_MMX}
  810. end;
  811. end;
  812. {*****************************************************************************
  813. TBREAKNODE
  814. *****************************************************************************}
  815. constructor tbreaknode.create;
  816. begin
  817. inherited create(breakn);
  818. end;
  819. function tbreaknode.det_resulttype:tnode;
  820. begin
  821. result:=nil;
  822. resulttype:=voidtype;
  823. end;
  824. function tbreaknode.pass_1 : tnode;
  825. begin
  826. result:=nil;
  827. expectloc:=LOC_VOID;
  828. end;
  829. {*****************************************************************************
  830. TCONTINUENODE
  831. *****************************************************************************}
  832. constructor tcontinuenode.create;
  833. begin
  834. inherited create(continuen);
  835. end;
  836. function tcontinuenode.det_resulttype:tnode;
  837. begin
  838. result:=nil;
  839. resulttype:=voidtype;
  840. end;
  841. function tcontinuenode.pass_1 : tnode;
  842. begin
  843. result:=nil;
  844. expectloc:=LOC_VOID;
  845. end;
  846. {*****************************************************************************
  847. TGOTONODE
  848. *****************************************************************************}
  849. constructor tgotonode.create(p : tlabelsym);
  850. begin
  851. inherited create(goton);
  852. exceptionblock:=aktexceptblock;
  853. labsym:=p;
  854. end;
  855. constructor tgotonode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  856. begin
  857. inherited ppuload(t,ppufile);
  858. labsym:=tlabelsym(ppufile.getderef);
  859. exceptionblock:=ppufile.getbyte;
  860. end;
  861. procedure tgotonode.ppuwrite(ppufile:tcompilerppufile);
  862. begin
  863. inherited ppuwrite(ppufile);
  864. ppufile.putderef(labsym);
  865. ppufile.putbyte(exceptionblock);
  866. end;
  867. procedure tgotonode.derefimpl;
  868. begin
  869. inherited derefimpl;
  870. resolvesym(pointer(labsym));
  871. end;
  872. function tgotonode.det_resulttype:tnode;
  873. begin
  874. result:=nil;
  875. resulttype:=voidtype;
  876. end;
  877. function tgotonode.pass_1 : tnode;
  878. begin
  879. result:=nil;
  880. expectloc:=LOC_VOID;
  881. { check if }
  882. if assigned(labsym) and
  883. assigned(labsym.code) and
  884. (exceptionblock<>tlabelnode(labsym.code).exceptionblock) then
  885. begin
  886. writeln('goto exceptblock: ',exceptionblock);
  887. writeln('label exceptblock: ',tlabelnode(labsym.code).exceptionblock);
  888. CGMessage(cg_e_goto_inout_of_exception_block);
  889. end;
  890. end;
  891. function tgotonode.getcopy : tnode;
  892. var
  893. p : tgotonode;
  894. begin
  895. p:=tgotonode(inherited getcopy);
  896. p.labsym:=labsym;
  897. p.exceptionblock:=exceptionblock;
  898. result:=p;
  899. end;
  900. function tgotonode.docompare(p: tnode): boolean;
  901. begin
  902. docompare := false;
  903. end;
  904. {*****************************************************************************
  905. TLABELNODE
  906. *****************************************************************************}
  907. constructor tlabelnode.createcase(p : tasmlabel;l:tnode);
  908. begin
  909. inherited create(labeln,l);
  910. { it shouldn't be possible to jump to case labels using goto }
  911. exceptionblock:=-1;
  912. labsym:=nil;
  913. labelnr:=p;
  914. end;
  915. constructor tlabelnode.create(p : tlabelsym;l:tnode);
  916. begin
  917. inherited create(labeln,l);
  918. exceptionblock:=aktexceptblock;
  919. labsym:=p;
  920. labelnr:=p.lab;
  921. { save the current labelnode in the labelsym }
  922. p.code:=self;
  923. end;
  924. constructor tlabelnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  925. begin
  926. inherited ppuload(t,ppufile);
  927. labsym:=tlabelsym(ppufile.getderef);
  928. labelnr:=tasmlabel(ppufile.getasmsymbol);
  929. exceptionblock:=ppufile.getbyte;
  930. end;
  931. procedure tlabelnode.ppuwrite(ppufile:tcompilerppufile);
  932. begin
  933. inherited ppuwrite(ppufile);
  934. ppufile.putderef(labsym);
  935. ppufile.putasmsymbol(labelnr);
  936. ppufile.putbyte(exceptionblock);
  937. end;
  938. procedure tlabelnode.derefimpl;
  939. begin
  940. inherited derefimpl;
  941. resolvesym(pointer(labsym));
  942. objectlibrary.derefasmsymbol(tasmsymbol(labelnr));
  943. end;
  944. function tlabelnode.det_resulttype:tnode;
  945. begin
  946. result:=nil;
  947. { left could still be unassigned }
  948. if assigned(left) then
  949. resulttypepass(left);
  950. resulttype:=voidtype;
  951. end;
  952. function tlabelnode.pass_1 : tnode;
  953. begin
  954. result:=nil;
  955. expectloc:=LOC_VOID;
  956. if assigned(left) then
  957. begin
  958. {$ifndef newra}
  959. rg.cleartempgen;
  960. {$endif}
  961. firstpass(left);
  962. registers32:=left.registers32;
  963. registersfpu:=left.registersfpu;
  964. {$ifdef SUPPORT_MMX}
  965. registersmmx:=left.registersmmx;
  966. {$endif SUPPORT_MMX}
  967. end;
  968. end;
  969. function tlabelnode.getcopy : tnode;
  970. var
  971. p : tlabelnode;
  972. begin
  973. p:=tlabelnode(inherited getcopy);
  974. p.labelnr:=labelnr;
  975. p.exceptionblock:=exceptionblock;
  976. p.labsym:=labsym;
  977. result:=p;
  978. end;
  979. function tlabelnode.docompare(p: tnode): boolean;
  980. begin
  981. docompare := false;
  982. end;
  983. {*****************************************************************************
  984. TRAISENODE
  985. *****************************************************************************}
  986. constructor traisenode.create(l,taddr,tframe:tnode);
  987. begin
  988. inherited create(raisen,l,taddr);
  989. frametree:=tframe;
  990. end;
  991. constructor traisenode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  992. begin
  993. inherited ppuload(t,ppufile);
  994. frametree:=ppuloadnode(ppufile);
  995. end;
  996. procedure traisenode.ppuwrite(ppufile:tcompilerppufile);
  997. begin
  998. inherited ppuwrite(ppufile);
  999. ppuwritenode(ppufile,frametree);
  1000. end;
  1001. procedure traisenode.derefimpl;
  1002. begin
  1003. inherited derefimpl;
  1004. if assigned(frametree) then
  1005. frametree.derefimpl;
  1006. end;
  1007. function traisenode.getcopy : tnode;
  1008. var
  1009. n : traisenode;
  1010. begin
  1011. n:=traisenode(inherited getcopy);
  1012. if assigned(frametree) then
  1013. n.frametree:=frametree.getcopy
  1014. else
  1015. n.frametree:=nil;
  1016. getcopy:=n;
  1017. end;
  1018. procedure traisenode.insertintolist(l : tnodelist);
  1019. begin
  1020. end;
  1021. function traisenode.det_resulttype:tnode;
  1022. begin
  1023. result:=nil;
  1024. resulttype:=voidtype;
  1025. if assigned(left) then
  1026. begin
  1027. { first para must be a _class_ }
  1028. resulttypepass(left);
  1029. set_varstate(left,true);
  1030. if codegenerror then
  1031. exit;
  1032. if not(is_class(left.resulttype.def)) then
  1033. CGMessage(type_e_mismatch);
  1034. { insert needed typeconvs for addr,frame }
  1035. if assigned(right) then
  1036. begin
  1037. { addr }
  1038. resulttypepass(right);
  1039. inserttypeconv(right,voidpointertype);
  1040. { frame }
  1041. if assigned(frametree) then
  1042. begin
  1043. resulttypepass(frametree);
  1044. inserttypeconv(frametree,voidpointertype);
  1045. end;
  1046. end;
  1047. end;
  1048. end;
  1049. function traisenode.pass_1 : tnode;
  1050. begin
  1051. result:=nil;
  1052. expectloc:=LOC_VOID;
  1053. if assigned(left) then
  1054. begin
  1055. { first para must be a _class_ }
  1056. firstpass(left);
  1057. { insert needed typeconvs for addr,frame }
  1058. if assigned(right) then
  1059. begin
  1060. { addr }
  1061. firstpass(right);
  1062. { frame }
  1063. if assigned(frametree) then
  1064. firstpass(frametree);
  1065. end;
  1066. left_right_max;
  1067. end;
  1068. end;
  1069. function traisenode.docompare(p: tnode): boolean;
  1070. begin
  1071. docompare := false;
  1072. end;
  1073. {*****************************************************************************
  1074. TTRYEXCEPTNODE
  1075. *****************************************************************************}
  1076. constructor ttryexceptnode.create(l,r,_t1 : tnode);
  1077. begin
  1078. inherited create(tryexceptn,l,r,_t1,nil);
  1079. end;
  1080. function ttryexceptnode.det_resulttype:tnode;
  1081. begin
  1082. result:=nil;
  1083. resulttypepass(left);
  1084. { on statements }
  1085. if assigned(right) then
  1086. resulttypepass(right);
  1087. { else block }
  1088. if assigned(t1) then
  1089. resulttypepass(t1);
  1090. resulttype:=voidtype;
  1091. end;
  1092. function ttryexceptnode.pass_1 : tnode;
  1093. begin
  1094. result:=nil;
  1095. expectloc:=LOC_VOID;
  1096. {$ifndef newra}
  1097. rg.cleartempgen;
  1098. {$endif}
  1099. firstpass(left);
  1100. { on statements }
  1101. if assigned(right) then
  1102. begin
  1103. {$ifndef newra}
  1104. rg.cleartempgen;
  1105. {$endif}
  1106. firstpass(right);
  1107. registers32:=max(registers32,right.registers32);
  1108. registersfpu:=max(registersfpu,right.registersfpu);
  1109. {$ifdef SUPPORT_MMX}
  1110. registersmmx:=max(registersmmx,right.registersmmx);
  1111. {$endif SUPPORT_MMX}
  1112. end;
  1113. { else block }
  1114. if assigned(t1) then
  1115. begin
  1116. firstpass(t1);
  1117. registers32:=max(registers32,t1.registers32);
  1118. registersfpu:=max(registersfpu,t1.registersfpu);
  1119. {$ifdef SUPPORT_MMX}
  1120. registersmmx:=max(registersmmx,t1.registersmmx);
  1121. {$endif SUPPORT_MMX}
  1122. end;
  1123. end;
  1124. {*****************************************************************************
  1125. TTRYFINALLYNODE
  1126. *****************************************************************************}
  1127. constructor ttryfinallynode.create(l,r:tnode);
  1128. begin
  1129. inherited create(tryfinallyn,l,r);
  1130. end;
  1131. function ttryfinallynode.det_resulttype:tnode;
  1132. begin
  1133. result:=nil;
  1134. resulttype:=voidtype;
  1135. resulttypepass(left);
  1136. set_varstate(left,true);
  1137. resulttypepass(right);
  1138. set_varstate(right,true);
  1139. end;
  1140. function ttryfinallynode.pass_1 : tnode;
  1141. begin
  1142. result:=nil;
  1143. expectloc:=LOC_VOID;
  1144. {$ifndef newra}
  1145. rg.cleartempgen;
  1146. {$endif}
  1147. firstpass(left);
  1148. {$ifndef newra}
  1149. rg.cleartempgen;
  1150. {$endif}
  1151. firstpass(right);
  1152. left_right_max;
  1153. end;
  1154. {*****************************************************************************
  1155. TONNODE
  1156. *****************************************************************************}
  1157. constructor tonnode.create(l,r:tnode);
  1158. begin
  1159. inherited create(onn,l,r);
  1160. exceptsymtable:=nil;
  1161. excepttype:=nil;
  1162. end;
  1163. destructor tonnode.destroy;
  1164. begin
  1165. if assigned(exceptsymtable) then
  1166. exceptsymtable.free;
  1167. inherited destroy;
  1168. end;
  1169. constructor tonnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  1170. begin
  1171. inherited ppuload(t,ppufile);
  1172. exceptsymtable:=nil;
  1173. excepttype:=nil;
  1174. end;
  1175. function tonnode.getcopy : tnode;
  1176. var
  1177. n : tonnode;
  1178. begin
  1179. n:=tonnode(inherited getcopy);
  1180. n.exceptsymtable:=exceptsymtable;
  1181. n.excepttype:=excepttype;
  1182. result:=n;
  1183. end;
  1184. function tonnode.det_resulttype:tnode;
  1185. begin
  1186. result:=nil;
  1187. resulttype:=voidtype;
  1188. if not(is_class(excepttype)) then
  1189. CGMessage(type_e_mismatch);
  1190. if assigned(left) then
  1191. resulttypepass(left);
  1192. if assigned(right) then
  1193. resulttypepass(right);
  1194. end;
  1195. function tonnode.pass_1 : tnode;
  1196. begin
  1197. result:=nil;
  1198. expectloc:=LOC_VOID;
  1199. rg.cleartempgen;
  1200. registers32:=0;
  1201. registersfpu:=0;
  1202. {$ifdef SUPPORT_MMX}
  1203. registersmmx:=0;
  1204. {$endif SUPPORT_MMX}
  1205. if assigned(left) then
  1206. begin
  1207. firstpass(left);
  1208. registers32:=left.registers32;
  1209. registersfpu:=left.registersfpu;
  1210. {$ifdef SUPPORT_MMX}
  1211. registersmmx:=left.registersmmx;
  1212. {$endif SUPPORT_MMX}
  1213. end;
  1214. rg.cleartempgen;
  1215. if assigned(right) then
  1216. begin
  1217. firstpass(right);
  1218. registers32:=max(registers32,right.registers32);
  1219. registersfpu:=max(registersfpu,right.registersfpu);
  1220. {$ifdef SUPPORT_MMX}
  1221. registersmmx:=max(registersmmx,right.registersmmx);
  1222. {$endif SUPPORT_MMX}
  1223. end;
  1224. end;
  1225. function tonnode.docompare(p: tnode): boolean;
  1226. begin
  1227. docompare := false;
  1228. end;
  1229. {*****************************************************************************
  1230. TFAILNODE
  1231. *****************************************************************************}
  1232. constructor tfailnode.create;
  1233. begin
  1234. inherited create(failn);
  1235. end;
  1236. function tfailnode.det_resulttype:tnode;
  1237. begin
  1238. result:=nil;
  1239. resulttype:=voidtype;
  1240. end;
  1241. function tfailnode.pass_1 : tnode;
  1242. begin
  1243. result:=nil;
  1244. expectloc:=LOC_VOID;
  1245. end;
  1246. function tfailnode.docompare(p: tnode): boolean;
  1247. begin
  1248. docompare := false;
  1249. end;
  1250. begin
  1251. cwhilerepeatnode:=twhilerepeatnode;
  1252. cifnode:=tifnode;
  1253. cfornode:=tfornode;
  1254. cexitnode:=texitnode;
  1255. cgotonode:=tgotonode;
  1256. clabelnode:=tlabelnode;
  1257. craisenode:=traisenode;
  1258. ctryexceptnode:=ttryexceptnode;
  1259. ctryfinallynode:=ttryfinallynode;
  1260. connode:=tonnode;
  1261. cfailnode:=tfailnode;
  1262. end.
  1263. {
  1264. $Log$
  1265. Revision 1.69 2003-04-26 00:28:41 peter
  1266. * removed load_funcret
  1267. Revision 1.68 2003/04/25 20:59:33 peter
  1268. * removed funcretn,funcretsym, function result is now in varsym
  1269. and aliases for result and function name are added using absolutesym
  1270. * vs_hidden parameter for funcret passed in parameter
  1271. * vs_hidden fixes
  1272. * writenode changed to printnode and released from extdebug
  1273. * -vp option added to generate a tree.log with the nodetree
  1274. * nicer printnode for statements, callnode
  1275. Revision 1.67 2003/04/25 08:25:26 daniel
  1276. * Ifdefs around a lot of calls to cleartempgen
  1277. * Fixed registers that are allocated but not freed in several nodes
  1278. * Tweak to register allocator to cause less spills
  1279. * 8-bit registers now interfere with esi,edi and ebp
  1280. Compiler can now compile rtl successfully when using new register
  1281. allocator
  1282. Revision 1.66 2003/04/22 23:50:23 peter
  1283. * firstpass uses expectloc
  1284. * checks if there are differences between the expectloc and
  1285. location.loc from secondpass in EXTDEBUG
  1286. Revision 1.65 2003/03/20 15:54:46 peter
  1287. * don't allow var and out parameters as for loop counter
  1288. Revision 1.64 2003/01/09 21:52:37 peter
  1289. * merged some verbosity options.
  1290. * V_LineInfo is a verbosity flag to include line info
  1291. Revision 1.63 2003/01/04 08:08:47 daniel
  1292. * Readded missing variable
  1293. Revision 1.62 2003/01/03 17:16:57 peter
  1294. * fixed warning about unset funcret
  1295. Revision 1.61 2003/01/03 12:15:56 daniel
  1296. * Removed ifdefs around notifications
  1297. ifdefs around for loop optimizations remain
  1298. Revision 1.60 2002/12/31 09:55:58 daniel
  1299. + Notification implementation complete
  1300. + Add for loop code optimization using notifications
  1301. results in 1.5-1.9% speed improvement in nestloop benchmark
  1302. Optimization incomplete, compiler does not cycle yet with
  1303. notifications enabled.
  1304. Revision 1.59 2002/12/30 22:44:53 daniel
  1305. * Some work on notifications
  1306. Revision 1.58 2002/12/27 15:25:40 peter
  1307. * do not allow threadvar as loop counter
  1308. Revision 1.57 2002/11/28 11:17:02 florian
  1309. * loop node flags from node flags splitted
  1310. Revision 1.56 2002/11/25 17:43:18 peter
  1311. * splitted defbase in defutil,symutil,defcmp
  1312. * merged isconvertable and is_equal into compare_defs(_ext)
  1313. * made operator search faster by walking the list only once
  1314. Revision 1.55 2002/11/18 17:31:56 peter
  1315. * pass proccalloption to ret_in_xxx and push_xxx functions
  1316. Revision 1.54 2002/10/20 15:31:49 peter
  1317. * set funcret state for exit(0)
  1318. Revision 1.53 2002/10/05 12:43:25 carl
  1319. * fixes for Delphi 6 compilation
  1320. (warning : Some features do not work under Delphi)
  1321. Revision 1.52 2002/09/07 15:25:03 peter
  1322. * old logs removed and tabs fixed
  1323. Revision 1.51 2002/09/07 12:16:04 carl
  1324. * second part bug report 1996 fix, testrange in cordconstnode
  1325. only called if option is set (also make parsing a tiny faster)
  1326. Revision 1.50 2002/09/01 18:47:00 peter
  1327. * assignn check in exitnode changed to use a separate boolean as the
  1328. assignn can be changed to a calln
  1329. Revision 1.49 2002/09/01 08:01:16 daniel
  1330. * Removed sets from Tcallnode.det_resulttype
  1331. + Added read/write notifications of variables. These will be usefull
  1332. for providing information for several optimizations. For example
  1333. the value of the loop variable of a for loop does matter is the
  1334. variable is read after the for loop, but if it's no longer used
  1335. or written, it doesn't matter and this can be used to optimize
  1336. the loop code generation.
  1337. Revision 1.48 2002/08/22 15:15:20 daniel
  1338. * Fixed the detection wether the first check of a for loop can be skipped
  1339. Revision 1.47 2002/08/19 19:36:43 peter
  1340. * More fixes for cross unit inlining, all tnodes are now implemented
  1341. * Moved pocall_internconst to po_internconst because it is not a
  1342. calling type at all and it conflicted when inlining of these small
  1343. functions was requested
  1344. Revision 1.46 2002/08/17 22:09:46 florian
  1345. * result type handling in tcgcal.pass_2 overhauled
  1346. * better tnode.dowrite
  1347. * some ppc stuff fixed
  1348. Revision 1.45 2002/08/17 09:23:37 florian
  1349. * first part of procinfo rewrite
  1350. Revision 1.44 2002/07/21 06:58:49 daniel
  1351. * Changed booleans into flags
  1352. Revision 1.43 2002/07/20 11:57:54 florian
  1353. * types.pas renamed to defbase.pas because D6 contains a types
  1354. unit so this would conflicts if D6 programms are compiled
  1355. + Willamette/SSE2 instructions to assembler added
  1356. Revision 1.42 2002/07/20 11:18:18 daniel
  1357. * Small mistake fixed; the skip test was done before we know the for node
  1358. is correct.
  1359. Revision 1.40 2002/07/20 08:19:31 daniel
  1360. * State tracker automatically changes while loops into repeat loops
  1361. Revision 1.39 2002/07/19 12:55:27 daniel
  1362. * Further developed state tracking in whilerepeatn
  1363. Revision 1.38 2002/07/19 11:41:35 daniel
  1364. * State tracker work
  1365. * The whilen and repeatn are now completely unified into whilerepeatn. This
  1366. allows the state tracker to change while nodes automatically into
  1367. repeat nodes.
  1368. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  1369. 'not(a>b)' is optimized into 'a<=b'.
  1370. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  1371. by removing the notn and later switchting the true and falselabels. The
  1372. same is done with 'repeat until not a'.
  1373. Revision 1.37 2002/07/16 13:57:02 florian
  1374. * raise takes now a void pointer as at and frame address
  1375. instead of a longint
  1376. Revision 1.36 2002/07/15 18:03:15 florian
  1377. * readded removed changes
  1378. Revision 1.35 2002/07/14 18:00:44 daniel
  1379. + Added the beginning of a state tracker. This will track the values of
  1380. variables through procedures and optimize things away.
  1381. Revision 1.34 2002/07/11 14:41:28 florian
  1382. * start of the new generic parameter handling
  1383. Revision 1.33 2002/07/01 18:46:23 peter
  1384. * internal linker
  1385. * reorganized aasm layer
  1386. Revision 1.32 2002/05/18 13:34:10 peter
  1387. * readded missing revisions
  1388. Revision 1.31 2002/05/16 19:46:38 carl
  1389. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1390. + try to fix temp allocation (still in ifdef)
  1391. + generic constructor calls
  1392. + start of tassembler / tmodulebase class cleanup
  1393. }