nflw.pas 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Type checking and register allocation for nodes that influence
  4. the flow
  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 nflw;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cclasses,
  23. node,cpubase,
  24. symnot,
  25. symtype,symbase,symdef,symsym,
  26. optunrol;
  27. type
  28. { flags used by loop nodes }
  29. tloopflag = (
  30. { set if it is a for ... downto ... do loop }
  31. lnf_backward,
  32. { Do we need to parse childs to set var state? }
  33. lnf_varstate,
  34. { Do a test at the begin of the loop?}
  35. lnf_testatbegin,
  36. { Negate the loop test? }
  37. lnf_checknegate,
  38. { Should the value of the loop variable on exit be correct. }
  39. lnf_dont_mind_loopvar_on_exit);
  40. tloopflags = set of tloopflag;
  41. const
  42. { loop flags which must match to consider loop nodes equal regarding the flags }
  43. loopflagsequal = [lnf_backward];
  44. type
  45. tlabelnode = class;
  46. tloopnode = class(tbinarynode)
  47. t1,t2 : tnode;
  48. loopflags : tloopflags;
  49. constructor create(tt : tnodetype;l,r,_t1,_t2 : tnode);virtual;
  50. destructor destroy;override;
  51. function dogetcopy : tnode;override;
  52. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  53. procedure ppuwrite(ppufile:tcompilerppufile);override;
  54. procedure buildderefimpl;override;
  55. procedure derefimpl;override;
  56. procedure insertintolist(l : tnodelist);override;
  57. procedure printnodetree(var t:text);override;
  58. function docompare(p: tnode): boolean; override;
  59. end;
  60. twhilerepeatnode = class(tloopnode)
  61. constructor create(l,r:Tnode;tab,cn:boolean);virtual;reintroduce;
  62. function pass_typecheck:tnode;override;
  63. function pass_1 : tnode;override;
  64. {$ifdef state_tracking}
  65. function track_state_pass(exec_known:boolean):boolean;override;
  66. {$endif}
  67. end;
  68. twhilerepeatnodeclass = class of twhilerepeatnode;
  69. tifnode = class(tloopnode)
  70. constructor create(l,r,_t1 : tnode);virtual;reintroduce;
  71. function pass_typecheck:tnode;override;
  72. function pass_1 : tnode;override;
  73. function simplify : tnode;override;
  74. private
  75. function internalsimplify(warn: boolean) : tnode;
  76. end;
  77. tifnodeclass = class of tifnode;
  78. tfornode = class(tloopnode)
  79. { if count isn divisable by unrolls then
  80. the for loop must jump to this label to get the correct
  81. number of executions }
  82. entrylabel : tnode;
  83. loopvar_notid:cardinal;
  84. constructor create(l,r,_t1,_t2 : tnode;back : boolean);virtual;reintroduce;
  85. procedure loop_var_access(not_type:Tnotification_flag;symbol:Tsym);
  86. function pass_typecheck:tnode;override;
  87. function pass_1 : tnode;override;
  88. end;
  89. tfornodeclass = class of tfornode;
  90. texitnode = class(tunarynode)
  91. constructor create(l:tnode);virtual;
  92. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  93. procedure ppuwrite(ppufile:tcompilerppufile);override;
  94. function pass_typecheck:tnode;override;
  95. function pass_1 : tnode;override;
  96. end;
  97. texitnodeclass = class of texitnode;
  98. tbreaknode = class(tnode)
  99. constructor create;virtual;
  100. function pass_typecheck:tnode;override;
  101. function pass_1 : tnode;override;
  102. end;
  103. tbreaknodeclass = class of tbreaknode;
  104. tcontinuenode = class(tnode)
  105. constructor create;virtual;
  106. function pass_typecheck:tnode;override;
  107. function pass_1 : tnode;override;
  108. end;
  109. tcontinuenodeclass = class of tcontinuenode;
  110. tgotonode = class(tnode)
  111. { we still need this for resolving forward gotos }
  112. labelsym : tlabelsym;
  113. labelnode : tlabelnode;
  114. exceptionblock : integer;
  115. { internlab : tinterngotolabel;}
  116. constructor create(p : tlabelnode);virtual;
  117. { as long as we don't know the label node we can't resolve it }
  118. constructor create_sym(p : tlabelsym);virtual;
  119. { constructor createintern(g:tinterngotolabel);}
  120. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  121. procedure ppuwrite(ppufile:tcompilerppufile);override;
  122. procedure buildderefimpl;override;
  123. procedure derefimpl;override;
  124. function dogetcopy : tnode;override;
  125. function pass_typecheck:tnode;override;
  126. function pass_1 : tnode;override;
  127. function docompare(p: tnode): boolean; override;
  128. end;
  129. tgotonodeclass = class of tgotonode;
  130. tlabelnode = class(tunarynode)
  131. exceptionblock : integer;
  132. { when copying trees, this points to the newly created copy of a label }
  133. copiedto : tlabelnode;
  134. { contains all goto nodesrefering to this label }
  135. referinggotonodes : TFPObjectList;
  136. constructor create(l:tnode);virtual;
  137. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  138. procedure ppuwrite(ppufile:tcompilerppufile);override;
  139. procedure buildderefimpl;override;
  140. procedure derefimpl;override;
  141. function dogetcopy : tnode;override;
  142. function pass_typecheck:tnode;override;
  143. function pass_1 : tnode;override;
  144. function docompare(p: tnode): boolean; override;
  145. end;
  146. tlabelnodeclass = class of tlabelnode;
  147. traisenode = class(ttertiarynode)
  148. constructor create(l,taddr,tframe:tnode);virtual;
  149. function pass_typecheck:tnode;override;
  150. function pass_1 : tnode;override;
  151. end;
  152. traisenodeclass = class of traisenode;
  153. ttryexceptnode = class(tloopnode)
  154. constructor create(l,r,_t1 : tnode);virtual;reintroduce;
  155. function pass_typecheck:tnode;override;
  156. function pass_1 : tnode;override;
  157. end;
  158. ttryexceptnodeclass = class of ttryexceptnode;
  159. ttryfinallynode = class(tloopnode)
  160. implicitframe : boolean;
  161. constructor create(l,r:tnode);virtual;reintroduce;
  162. constructor create_implicit(l,r,_t1:tnode);virtual;
  163. function pass_typecheck:tnode;override;
  164. function pass_1 : tnode;override;
  165. end;
  166. ttryfinallynodeclass = class of ttryfinallynode;
  167. tonnode = class(tbinarynode)
  168. excepTSymtable : TSymtable;
  169. excepttype : tobjectdef;
  170. constructor create(l,r:tnode);virtual;
  171. destructor destroy;override;
  172. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  173. function pass_typecheck:tnode;override;
  174. function pass_1 : tnode;override;
  175. function dogetcopy : tnode;override;
  176. function docompare(p: tnode): boolean; override;
  177. end;
  178. tonnodeclass = class of tonnode;
  179. var
  180. cwhilerepeatnode : twhilerepeatnodeclass;
  181. cifnode : tifnodeclass;
  182. cfornode : tfornodeclass;
  183. cexitnode : texitnodeclass;
  184. cbreaknode : tbreaknodeclass;
  185. ccontinuenode : tcontinuenodeclass;
  186. cgotonode : tgotonodeclass;
  187. clabelnode : tlabelnodeclass;
  188. craisenode : traisenodeclass;
  189. ctryexceptnode : ttryexceptnodeclass;
  190. ctryfinallynode : ttryfinallynodeclass;
  191. connode : tonnodeclass;
  192. implementation
  193. uses
  194. globtype,systems,constexp,
  195. cutils,verbose,globals,
  196. symconst,paramgr,defcmp,defutil,htypechk,pass_1,
  197. ncal,nadd,ncon,nmem,nld,ncnv,nbas,cgobj,nutils,
  198. {$ifdef prefetchnext}
  199. ninl,
  200. {$endif prefetchnext}
  201. {$ifdef state_tracking}
  202. nstate,
  203. {$endif}
  204. cgbase,procinfo
  205. ;
  206. {****************************************************************************
  207. TLOOPNODE
  208. *****************************************************************************}
  209. constructor tloopnode.create(tt : tnodetype;l,r,_t1,_t2 : tnode);
  210. begin
  211. inherited create(tt,l,r);
  212. t1:=_t1;
  213. t2:=_t2;
  214. fileinfo:=l.fileinfo;
  215. end;
  216. destructor tloopnode.destroy;
  217. begin
  218. t1.free;
  219. t2.free;
  220. inherited destroy;
  221. end;
  222. constructor tloopnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  223. begin
  224. inherited ppuload(t,ppufile);
  225. t1:=ppuloadnode(ppufile);
  226. t2:=ppuloadnode(ppufile);
  227. end;
  228. procedure tloopnode.ppuwrite(ppufile:tcompilerppufile);
  229. begin
  230. inherited ppuwrite(ppufile);
  231. ppuwritenode(ppufile,t1);
  232. ppuwritenode(ppufile,t2);
  233. end;
  234. procedure tloopnode.buildderefimpl;
  235. begin
  236. inherited buildderefimpl;
  237. if assigned(t1) then
  238. t1.buildderefimpl;
  239. if assigned(t2) then
  240. t2.buildderefimpl;
  241. end;
  242. procedure tloopnode.derefimpl;
  243. begin
  244. inherited derefimpl;
  245. if assigned(t1) then
  246. t1.derefimpl;
  247. if assigned(t2) then
  248. t2.derefimpl;
  249. end;
  250. function tloopnode.dogetcopy : tnode;
  251. var
  252. p : tloopnode;
  253. begin
  254. p:=tloopnode(inherited dogetcopy);
  255. if assigned(t1) then
  256. p.t1:=t1.dogetcopy
  257. else
  258. p.t1:=nil;
  259. if assigned(t2) then
  260. p.t2:=t2.dogetcopy
  261. else
  262. p.t2:=nil;
  263. p.loopflags:=loopflags;
  264. dogetcopy:=p;
  265. end;
  266. procedure tloopnode.insertintolist(l : tnodelist);
  267. begin
  268. end;
  269. procedure tloopnode.printnodetree(var t:text);
  270. begin
  271. write(t,printnodeindention,'(');
  272. printnodeindent;
  273. printnodeinfo(t);
  274. writeln(t);
  275. printnode(t,left);
  276. printnode(t,right);
  277. printnode(t,t1);
  278. printnode(t,t2);
  279. printnodeunindent;
  280. writeln(t,printnodeindention,')');
  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:Tnode;tab,cn:boolean);
  294. begin
  295. inherited create(whilerepeatn,l,r,nil,nil);
  296. if tab then
  297. include(loopflags, lnf_testatbegin);
  298. if cn then
  299. include(loopflags,lnf_checknegate);
  300. end;
  301. function twhilerepeatnode.pass_typecheck:tnode;
  302. var
  303. t:Tunarynode;
  304. begin
  305. result:=nil;
  306. resultdef:=voidtype;
  307. typecheckpass(left);
  308. { tp procvar support }
  309. maybe_call_procvar(left,true);
  310. {A not node can be removed.}
  311. if left.nodetype=notn then
  312. begin
  313. t:=Tunarynode(left);
  314. left:=Tunarynode(left).left;
  315. t.left:=nil;
  316. t.destroy;
  317. {Symdif operator, in case you are wondering:}
  318. loopflags:=loopflags >< [lnf_checknegate];
  319. end;
  320. { loop instruction }
  321. if assigned(right) then
  322. typecheckpass(right);
  323. set_varstate(left,vs_read,[vsf_must_be_valid]);
  324. if codegenerror then
  325. exit;
  326. if not is_boolean(left.resultdef) then
  327. begin
  328. if left.resultdef.typ=variantdef then
  329. inserttypeconv(left,booltype)
  330. else
  331. CGMessage1(type_e_boolean_expr_expected,left.resultdef.typename);
  332. end;
  333. { Give warnings for code that will never be executed for
  334. while false do }
  335. if (lnf_testatbegin in loopflags) and
  336. (left.nodetype=ordconstn) and
  337. (tordconstnode(left).value.uvalue=0) and
  338. assigned(right) then
  339. CGMessagePos(right.fileinfo,cg_w_unreachable_code);
  340. end;
  341. {$ifdef prefetchnext}
  342. type
  343. passignmentquery = ^tassignmentquery;
  344. tassignmentquery = record
  345. towhat: tnode;
  346. source: tassignmentnode;
  347. statementcount: cardinal;
  348. end;
  349. function checkassignment(var n: tnode; arg: pointer): foreachnoderesult;
  350. var
  351. query: passignmentquery absolute arg;
  352. temp, prederef: tnode;
  353. begin
  354. result := fen_norecurse_false;
  355. if (n.nodetype in [assignn,inlinen,forn,calln,whilerepeatn,casen,ifn]) then
  356. inc(query^.statementcount);
  357. { make sure there's something else in the loop besides going to the }
  358. { next item }
  359. if (query^.statementcount > 1) and
  360. (n.nodetype = assignn) then
  361. begin
  362. { skip type conversions of assignment target }
  363. temp := tassignmentnode(n).left;
  364. while (temp.nodetype = typeconvn) do
  365. temp := ttypeconvnode(temp).left;
  366. { assignment to x of the while assigned(x) check? }
  367. if not(temp.isequal(query^.towhat)) then
  368. exit;
  369. { right hand side of assignment dereferenced field of }
  370. { x? (no derefn in case of class) }
  371. temp := tassignmentnode(n).right;
  372. while (temp.nodetype = typeconvn) do
  373. temp := ttypeconvnode(temp).left;
  374. if (temp.nodetype <> subscriptn) then
  375. exit;
  376. prederef := tsubscriptnode(temp).left;
  377. temp := prederef;
  378. while (temp.nodetype = typeconvn) do
  379. temp := ttypeconvnode(temp).left;
  380. { see tests/test/prefetch1.pp }
  381. if (temp.nodetype = derefn) then
  382. temp := tderefnode(temp).left
  383. else
  384. temp := prederef;
  385. if temp.isequal(query^.towhat) then
  386. begin
  387. query^.source := tassignmentnode(n);
  388. result := fen_norecurse_true;
  389. end
  390. end
  391. { don't check nodes which can't contain an assignment or whose }
  392. { final assignment can vary a lot }
  393. else if not(n.nodetype in [calln,inlinen,casen,whilerepeatn,forn]) then
  394. result := fen_false;
  395. end;
  396. function findassignment(where: tnode; towhat: tnode): tassignmentnode;
  397. var
  398. query: tassignmentquery;
  399. begin
  400. query.towhat := towhat;
  401. query.source := nil;
  402. query.statementcount := 0;
  403. if foreachnodestatic(where,@checkassignment,@query) then
  404. result := query.source
  405. else
  406. result := nil;
  407. end;
  408. {$endif prefetchnext}
  409. function twhilerepeatnode.pass_1 : tnode;
  410. var
  411. {$ifdef prefetchnext}
  412. runnernode, prefetchcode: tnode;
  413. assignmentnode: tassignmentnode;
  414. prefetchstatements: tstatementnode;
  415. {$endif prefetchnext}
  416. old_t_times : longint;
  417. begin
  418. result:=nil;
  419. expectloc:=LOC_VOID;
  420. old_t_times:=cg.t_times;
  421. { calc register weight }
  422. if not(cs_opt_size in current_settings.optimizerswitches) then
  423. cg.t_times:=cg.t_times*8;
  424. firstpass(left);
  425. if codegenerror then
  426. exit;
  427. registersint:=left.registersint;
  428. registersfpu:=left.registersfpu;
  429. {$ifdef SUPPORT_MMX}
  430. registersmmx:=left.registersmmx;
  431. {$endif SUPPORT_MMX}
  432. { loop instruction }
  433. if assigned(right) then
  434. begin
  435. firstpass(right);
  436. if codegenerror then
  437. exit;
  438. if registersint<right.registersint then
  439. registersint:=right.registersint;
  440. if registersfpu<right.registersfpu then
  441. registersfpu:=right.registersfpu;
  442. {$ifdef SUPPORT_MMX}
  443. if registersmmx<right.registersmmx then
  444. registersmmx:=right.registersmmx;
  445. {$endif SUPPORT_MMX}
  446. end;
  447. cg.t_times:=old_t_times;
  448. {$ifdef prefetchnext}
  449. { do at the end so all complex typeconversions are already }
  450. { converted to calln's }
  451. if (cs_opt_level1 in current_settings.optimizerswitches) and
  452. (lnf_testatbegin in loopflags) then
  453. begin
  454. { get first component of the while check }
  455. runnernode := left;
  456. while (runnernode.nodetype in [andn,orn,notn,xorn,typeconvn]) do
  457. runnernode := tunarynode(runnernode).left;
  458. { is it an assigned(x) check? }
  459. if ((runnernode.nodetype = inlinen) and
  460. (tinlinenode(runnernode).inlinenumber = in_assigned_x)) or
  461. ((runnernode.nodetype = unequaln) and
  462. (taddnode(runnernode).right.nodetype = niln)) then
  463. begin
  464. runnernode := tunarynode(runnernode).left;
  465. { in case of in_assigned_x, there's a callparan in between }
  466. if (runnernode.nodetype = callparan) then
  467. runnernode := tcallparanode(runnernode).left;
  468. while (runnernode.nodetype = typeconvn) do
  469. runnernode := ttypeconvnode(runnernode).left;
  470. { is there an "x := x(^).somefield"? }
  471. assignmentnode := findassignment(right,runnernode);
  472. if assigned(assignmentnode) then
  473. begin
  474. prefetchcode := internalstatements(prefetchstatements);
  475. addstatement(prefetchstatements,geninlinenode(in_prefetch_var,false,
  476. cderefnode.create(ctypeconvnode.create(assignmentnode.right.getcopy,voidpointertype))));
  477. addstatement(prefetchstatements,right);
  478. right := prefetchcode;
  479. typecheckpass(right);
  480. end;
  481. end;
  482. end;
  483. {$endif prefetchnext}
  484. end;
  485. {$ifdef state_tracking}
  486. function Twhilerepeatnode.track_state_pass(exec_known:boolean):boolean;
  487. var condition:Tnode;
  488. code:Tnode;
  489. done:boolean;
  490. value:boolean;
  491. change:boolean;
  492. firsttest:boolean;
  493. factval:Tnode;
  494. begin
  495. track_state_pass:=false;
  496. done:=false;
  497. firsttest:=true;
  498. {For repeat until statements, first do a pass through the code.}
  499. if not(lnf_testatbegin in flags) then
  500. begin
  501. code:=right.getcopy;
  502. if code.track_state_pass(exec_known) then
  503. track_state_pass:=true;
  504. code.destroy;
  505. end;
  506. repeat
  507. condition:=left.getcopy;
  508. code:=right.getcopy;
  509. change:=condition.track_state_pass(exec_known);
  510. factval:=aktstate.find_fact(left);
  511. if factval<>nil then
  512. begin
  513. condition.destroy;
  514. condition:=factval.getcopy;
  515. change:=true;
  516. end;
  517. if change then
  518. begin
  519. track_state_pass:=true;
  520. {Force new resultdef pass.}
  521. condition.resultdef:=nil;
  522. do_typecheckpass(condition);
  523. end;
  524. if is_constboolnode(condition) then
  525. begin
  526. {Try to turn a while loop into a repeat loop.}
  527. if firsttest then
  528. exclude(flags,testatbegin);
  529. value:=(Tordconstnode(condition).value<>0) xor checknegate;
  530. if value then
  531. begin
  532. if code.track_state_pass(exec_known) then
  533. track_state_pass:=true;
  534. end
  535. else
  536. done:=true;
  537. end
  538. else
  539. begin
  540. {Remove any modified variables from the state.}
  541. code.track_state_pass(false);
  542. done:=true;
  543. end;
  544. code.destroy;
  545. condition.destroy;
  546. firsttest:=false;
  547. until done;
  548. {The loop condition is also known, for example:
  549. while i<10 do
  550. begin
  551. ...
  552. end;
  553. When the loop is done, we do know that i<10 = false.
  554. }
  555. condition:=left.getcopy;
  556. if condition.track_state_pass(exec_known) then
  557. begin
  558. track_state_pass:=true;
  559. {Force new resultdef pass.}
  560. condition.resultdef:=nil;
  561. do_typecheckpass(condition);
  562. end;
  563. if not is_constboolnode(condition) then
  564. aktstate.store_fact(condition,
  565. cordconstnode.create(byte(checknegate),booltype,true))
  566. else
  567. condition.destroy;
  568. end;
  569. {$endif}
  570. {*****************************************************************************
  571. TIFNODE
  572. *****************************************************************************}
  573. constructor tifnode.create(l,r,_t1 : tnode);
  574. begin
  575. inherited create(ifn,l,r,_t1,nil);
  576. end;
  577. function tifnode.internalsimplify(warn: boolean) : tnode;
  578. begin
  579. result:=nil;
  580. { optimize constant expressions }
  581. if left.nodetype=ordconstn then
  582. begin
  583. if tordconstnode(left).value.uvalue=1 then
  584. begin
  585. if assigned(right) then
  586. result:=right
  587. else
  588. result:=cnothingnode.create;
  589. right:=nil;
  590. if warn and assigned(t1) then
  591. CGMessagePos(t1.fileinfo,cg_w_unreachable_code);
  592. end
  593. else
  594. begin
  595. if assigned(t1) then
  596. result:=t1
  597. else
  598. result:=cnothingnode.create;
  599. t1:=nil;
  600. if warn and assigned(right) then
  601. CGMessagePos(right.fileinfo,cg_w_unreachable_code);
  602. end;
  603. end;
  604. end;
  605. function tifnode.simplify : tnode;
  606. begin
  607. result:=internalsimplify(false);
  608. end;
  609. function tifnode.pass_typecheck:tnode;
  610. begin
  611. result:=nil;
  612. resultdef:=voidtype;
  613. typecheckpass(left);
  614. { tp procvar support }
  615. maybe_call_procvar(left,true);
  616. { if path }
  617. if assigned(right) then
  618. typecheckpass(right);
  619. { else path }
  620. if assigned(t1) then
  621. typecheckpass(t1);
  622. set_varstate(left,vs_read,[vsf_must_be_valid]);
  623. if codegenerror then
  624. exit;
  625. if not is_boolean(left.resultdef) then
  626. begin
  627. if left.resultdef.typ=variantdef then
  628. inserttypeconv(left,booltype)
  629. else
  630. Message1(type_e_boolean_expr_expected,left.resultdef.typename);
  631. end;
  632. result:=internalsimplify(true);
  633. end;
  634. function tifnode.pass_1 : tnode;
  635. var
  636. old_t_times : longint;
  637. begin
  638. result:=nil;
  639. expectloc:=LOC_VOID;
  640. old_t_times:=cg.t_times;
  641. firstpass(left);
  642. registersint:=left.registersint;
  643. registersfpu:=left.registersfpu;
  644. {$ifdef SUPPORT_MMX}
  645. registersmmx:=left.registersmmx;
  646. {$endif SUPPORT_MMX}
  647. { determines registers weigths }
  648. if not(cs_opt_size in current_settings.optimizerswitches) then
  649. cg.t_times:=cg.t_times div 2;
  650. if cg.t_times=0 then
  651. cg.t_times:=1;
  652. { if path }
  653. if assigned(right) then
  654. begin
  655. firstpass(right);
  656. if registersint<right.registersint then
  657. registersint:=right.registersint;
  658. if registersfpu<right.registersfpu then
  659. registersfpu:=right.registersfpu;
  660. {$ifdef SUPPORT_MMX}
  661. if registersmmx<right.registersmmx then
  662. registersmmx:=right.registersmmx;
  663. {$endif SUPPORT_MMX}
  664. end;
  665. { else path }
  666. if assigned(t1) then
  667. begin
  668. firstpass(t1);
  669. if registersint<t1.registersint then
  670. registersint:=t1.registersint;
  671. if registersfpu<t1.registersfpu then
  672. registersfpu:=t1.registersfpu;
  673. {$ifdef SUPPORT_MMX}
  674. if registersmmx<t1.registersmmx then
  675. registersmmx:=t1.registersmmx;
  676. {$endif SUPPORT_MMX}
  677. end;
  678. { leave if we've got an error in one of the paths }
  679. if codegenerror then
  680. exit;
  681. cg.t_times:=old_t_times;
  682. end;
  683. {*****************************************************************************
  684. TFORNODE
  685. *****************************************************************************}
  686. constructor tfornode.create(l,r,_t1,_t2 : tnode;back : boolean);
  687. begin
  688. inherited create(forn,l,r,_t1,_t2);
  689. if back then
  690. include(loopflags,lnf_backward);
  691. include(loopflags,lnf_testatbegin);
  692. end;
  693. procedure Tfornode.loop_var_access(not_type:Tnotification_flag;
  694. symbol:Tsym);
  695. begin
  696. {If there is a read access, the value of the loop counter is important;
  697. at the end of the loop the loop variable should contain the value it
  698. had in the last iteration.}
  699. if not_type=vn_onwrite then
  700. begin
  701. writeln('Loopvar does not matter on exit');
  702. end
  703. else
  704. begin
  705. exclude(loopflags,lnf_dont_mind_loopvar_on_exit);
  706. writeln('Loopvar does matter on exit');
  707. end;
  708. Tabstractvarsym(symbol).unregister_notification(loopvar_notid);
  709. end;
  710. function tfornode.pass_typecheck:tnode;
  711. var
  712. unrollres : tnode;
  713. begin
  714. result:=nil;
  715. resultdef:=voidtype;
  716. { loop unrolling }
  717. if cs_opt_loopunroll in current_settings.optimizerswitches then
  718. begin
  719. unrollres:=unroll_loop(self);
  720. if assigned(unrollres) then
  721. begin
  722. typecheckpass(unrollres);
  723. result:=unrollres;
  724. exit;
  725. end;
  726. end;
  727. { process the loopvar, from and to, varstates are already set }
  728. typecheckpass(left);
  729. typecheckpass(right);
  730. typecheckpass(t1);
  731. {Can we spare the first comparision?}
  732. if (t1.nodetype=ordconstn) and
  733. (right.nodetype=ordconstn) and
  734. (
  735. (
  736. (lnf_backward in loopflags) and
  737. (Tordconstnode(right).value>=Tordconstnode(t1).value)
  738. ) or
  739. (
  740. not(lnf_backward in loopflags) and
  741. (Tordconstnode(right).value<=Tordconstnode(t1).value)
  742. )
  743. ) then
  744. exclude(loopflags,lnf_testatbegin);
  745. { Make sure that the loop var and the
  746. from and to values are compatible types }
  747. check_ranges(right.fileinfo,right,left.resultdef);
  748. inserttypeconv(right,left.resultdef);
  749. check_ranges(t1.fileinfo,t1,left.resultdef);
  750. inserttypeconv(t1,left.resultdef);
  751. if assigned(t2) then
  752. typecheckpass(t2);
  753. end;
  754. function tfornode.pass_1 : tnode;
  755. var
  756. old_t_times : longint;
  757. begin
  758. result:=nil;
  759. expectloc:=LOC_VOID;
  760. firstpass(left);
  761. if left.registersint>registersint then
  762. registersint:=left.registersint;
  763. if left.registersfpu>registersfpu then
  764. registersfpu:=left.registersfpu;
  765. {$ifdef SUPPORT_MMX}
  766. if left.registersmmx>registersmmx then
  767. registersmmx:=left.registersmmx;
  768. {$endif SUPPORT_MMX}
  769. firstpass(right);
  770. if right.registersint>registersint then
  771. registersint:=right.registersint;
  772. if right.registersfpu>registersfpu then
  773. registersfpu:=right.registersfpu;
  774. {$ifdef SUPPORT_MMX}
  775. if right.registersmmx>registersmmx then
  776. registersmmx:=right.registersmmx;
  777. {$endif SUPPORT_MMX}
  778. firstpass(t1);
  779. if t1.registersint>registersint then
  780. registersint:=t1.registersint;
  781. if t1.registersfpu>registersfpu then
  782. registersfpu:=t1.registersfpu;
  783. {$ifdef SUPPORT_MMX}
  784. if t1.registersmmx>registersmmx then
  785. registersmmx:=t1.registersmmx;
  786. {$endif SUPPORT_MMX}
  787. if assigned(t2) then
  788. begin
  789. { Calc register weight }
  790. old_t_times:=cg.t_times;
  791. if not(cs_opt_size in current_settings.optimizerswitches) then
  792. cg.t_times:=cg.t_times*8;
  793. firstpass(t2);
  794. if codegenerror then
  795. exit;
  796. if t2.registersint>registersint then
  797. registersint:=t2.registersint;
  798. if t2.registersfpu>registersfpu then
  799. registersfpu:=t2.registersfpu;
  800. {$ifdef SUPPORT_MMX}
  801. if t2.registersmmx>registersmmx then
  802. registersmmx:=t2.registersmmx;
  803. {$endif SUPPORT_MMX}
  804. cg.t_times:=old_t_times;
  805. end;
  806. { we need at least one register for comparisons PM }
  807. if registersint=0 then
  808. inc(registersint);
  809. end;
  810. {*****************************************************************************
  811. TEXITNODE
  812. *****************************************************************************}
  813. constructor texitnode.create(l:tnode);
  814. begin
  815. inherited create(exitn,l);
  816. end;
  817. constructor texitnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  818. begin
  819. inherited ppuload(t,ppufile);
  820. end;
  821. procedure texitnode.ppuwrite(ppufile:tcompilerppufile);
  822. begin
  823. inherited ppuwrite(ppufile);
  824. end;
  825. function texitnode.pass_typecheck:tnode;
  826. begin
  827. result:=nil;
  828. if assigned(left) then
  829. begin
  830. { add assignment to funcretsym }
  831. inserttypeconv(left,current_procinfo.procdef.returndef);
  832. left:=cassignmentnode.create(
  833. cloadnode.create(current_procinfo.procdef.funcretsym,current_procinfo.procdef.funcretsym.owner),
  834. left);
  835. typecheckpass(left);
  836. set_varstate(left,vs_read,[vsf_must_be_valid]);
  837. end;
  838. resultdef:=voidtype;
  839. end;
  840. function texitnode.pass_1 : tnode;
  841. begin
  842. result:=nil;
  843. expectloc:=LOC_VOID;
  844. if assigned(left) then
  845. begin
  846. firstpass(left);
  847. if codegenerror then
  848. exit;
  849. registersint:=left.registersint;
  850. registersfpu:=left.registersfpu;
  851. {$ifdef SUPPORT_MMX}
  852. registersmmx:=left.registersmmx;
  853. {$endif SUPPORT_MMX}
  854. end;
  855. end;
  856. {*****************************************************************************
  857. TBREAKNODE
  858. *****************************************************************************}
  859. constructor tbreaknode.create;
  860. begin
  861. inherited create(breakn);
  862. end;
  863. function tbreaknode.pass_typecheck:tnode;
  864. begin
  865. result:=nil;
  866. resultdef:=voidtype;
  867. end;
  868. function tbreaknode.pass_1 : tnode;
  869. begin
  870. result:=nil;
  871. expectloc:=LOC_VOID;
  872. end;
  873. {*****************************************************************************
  874. TCONTINUENODE
  875. *****************************************************************************}
  876. constructor tcontinuenode.create;
  877. begin
  878. inherited create(continuen);
  879. end;
  880. function tcontinuenode.pass_typecheck:tnode;
  881. begin
  882. result:=nil;
  883. resultdef:=voidtype;
  884. end;
  885. function tcontinuenode.pass_1 : tnode;
  886. begin
  887. result:=nil;
  888. expectloc:=LOC_VOID;
  889. end;
  890. {*****************************************************************************
  891. TGOTONODE
  892. *****************************************************************************}
  893. constructor tgotonode.create(p : tlabelnode);
  894. begin
  895. inherited create(goton);
  896. exceptionblock:=aktexceptblock;
  897. labelnode:=p;
  898. labelsym:=nil;
  899. end;
  900. constructor tgotonode.create_sym(p : tlabelsym);
  901. begin
  902. inherited create(goton);
  903. exceptionblock:=aktexceptblock;
  904. if assigned(p.code) then
  905. labelnode:=tlabelnode(p.code)
  906. else
  907. labelnode:=nil;
  908. labelsym:=p;
  909. end;
  910. constructor tgotonode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  911. begin
  912. inherited ppuload(t,ppufile);
  913. labelnode:=tlabelnode(ppuloadnoderef(ppufile));
  914. exceptionblock:=ppufile.getbyte;
  915. end;
  916. procedure tgotonode.ppuwrite(ppufile:tcompilerppufile);
  917. begin
  918. inherited ppuwrite(ppufile);
  919. ppuwritenoderef(ppufile,labelnode);
  920. ppufile.putbyte(exceptionblock);
  921. end;
  922. procedure tgotonode.buildderefimpl;
  923. begin
  924. inherited buildderefimpl;
  925. //!!! deref(labelnode);
  926. end;
  927. procedure tgotonode.derefimpl;
  928. begin
  929. inherited derefimpl;
  930. //!!! deref(labelnode);
  931. end;
  932. function tgotonode.pass_typecheck:tnode;
  933. begin
  934. result:=nil;
  935. resultdef:=voidtype;
  936. end;
  937. function tgotonode.pass_1 : tnode;
  938. begin
  939. result:=nil;
  940. expectloc:=LOC_VOID;
  941. include(current_procinfo.flags,pi_has_goto);
  942. if not(assigned(labelnode)) then
  943. begin
  944. if assigned(labelsym) and assigned(labelsym.code) then
  945. labelnode:=tlabelnode(labelsym.code)
  946. else
  947. internalerror(200506183);
  948. end;
  949. { check if we don't mess with exception blocks }
  950. if assigned(labelnode) and
  951. (exceptionblock<>labelnode.exceptionblock) then
  952. CGMessage(cg_e_goto_inout_of_exception_block);
  953. end;
  954. function tgotonode.dogetcopy : tnode;
  955. var
  956. p : tgotonode;
  957. begin
  958. p:=tgotonode(inherited dogetcopy);
  959. p.exceptionblock:=exceptionblock;
  960. { force a valid labelnode }
  961. if not(assigned(labelnode)) then
  962. begin
  963. if assigned(labelsym) and assigned(labelsym.code) then
  964. labelnode:=tlabelnode(labelsym.code)
  965. else
  966. internalerror(200610291);
  967. end;
  968. p.labelnode:=tlabelnode(labelnode.dogetcopy);
  969. result:=p;
  970. end;
  971. function tgotonode.docompare(p: tnode): boolean;
  972. begin
  973. docompare := false;
  974. end;
  975. {*****************************************************************************
  976. TLABELNODE
  977. *****************************************************************************}
  978. constructor tlabelnode.create(l:tnode);
  979. begin
  980. inherited create(labeln,l);
  981. exceptionblock:=aktexceptblock;
  982. end;
  983. constructor tlabelnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  984. begin
  985. inherited ppuload(t,ppufile);
  986. exceptionblock:=ppufile.getbyte;
  987. end;
  988. procedure tlabelnode.ppuwrite(ppufile:tcompilerppufile);
  989. begin
  990. inherited ppuwrite(ppufile);
  991. ppufile.putbyte(exceptionblock);
  992. end;
  993. procedure tlabelnode.buildderefimpl;
  994. begin
  995. inherited buildderefimpl;
  996. end;
  997. procedure tlabelnode.derefimpl;
  998. begin
  999. inherited derefimpl;
  1000. end;
  1001. function tlabelnode.pass_typecheck:tnode;
  1002. begin
  1003. result:=nil;
  1004. { left could still be unassigned }
  1005. if assigned(left) then
  1006. typecheckpass(left);
  1007. resultdef:=voidtype;
  1008. end;
  1009. function tlabelnode.pass_1 : tnode;
  1010. begin
  1011. result:=nil;
  1012. expectloc:=LOC_VOID;
  1013. if assigned(left) then
  1014. begin
  1015. firstpass(left);
  1016. registersint:=left.registersint;
  1017. registersfpu:=left.registersfpu;
  1018. {$ifdef SUPPORT_MMX}
  1019. registersmmx:=left.registersmmx;
  1020. {$endif SUPPORT_MMX}
  1021. end;
  1022. end;
  1023. function tlabelnode.dogetcopy : tnode;
  1024. begin
  1025. if not(assigned(copiedto)) then
  1026. copiedto:=tlabelnode(inherited dogetcopy);
  1027. copiedto.exceptionblock:=exceptionblock;
  1028. result:=copiedto;
  1029. end;
  1030. function tlabelnode.docompare(p: tnode): boolean;
  1031. begin
  1032. docompare := false;
  1033. end;
  1034. {*****************************************************************************
  1035. TRAISENODE
  1036. *****************************************************************************}
  1037. constructor traisenode.create(l,taddr,tframe:tnode);
  1038. begin
  1039. inherited create(raisen,l,taddr,tframe);
  1040. end;
  1041. function traisenode.pass_typecheck:tnode;
  1042. begin
  1043. result:=nil;
  1044. resultdef:=voidtype;
  1045. if assigned(left) then
  1046. begin
  1047. { first para must be a _class_ }
  1048. typecheckpass(left);
  1049. set_varstate(left,vs_read,[vsf_must_be_valid]);
  1050. if codegenerror then
  1051. exit;
  1052. if not(is_class(left.resultdef)) then
  1053. CGMessage1(type_e_class_type_expected,left.resultdef.typename);
  1054. { insert needed typeconvs for addr,frame }
  1055. if assigned(right) then
  1056. begin
  1057. { addr }
  1058. typecheckpass(right);
  1059. inserttypeconv(right,voidpointertype);
  1060. { frame }
  1061. if assigned(third) then
  1062. begin
  1063. typecheckpass(third);
  1064. inserttypeconv(third,voidpointertype);
  1065. end;
  1066. end;
  1067. end;
  1068. end;
  1069. function traisenode.pass_1 : tnode;
  1070. begin
  1071. result:=nil;
  1072. include(current_procinfo.flags,pi_do_call);
  1073. expectloc:=LOC_VOID;
  1074. if assigned(left) then
  1075. begin
  1076. { first para must be a _class_ }
  1077. firstpass(left);
  1078. { insert needed typeconvs for addr,frame }
  1079. if assigned(right) then
  1080. begin
  1081. { addr }
  1082. firstpass(right);
  1083. { frame }
  1084. if assigned(third) then
  1085. firstpass(third);
  1086. end;
  1087. left_right_max;
  1088. end;
  1089. end;
  1090. {*****************************************************************************
  1091. TTRYEXCEPTNODE
  1092. *****************************************************************************}
  1093. constructor ttryexceptnode.create(l,r,_t1 : tnode);
  1094. begin
  1095. inherited create(tryexceptn,l,r,_t1,nil);
  1096. end;
  1097. function ttryexceptnode.pass_typecheck:tnode;
  1098. begin
  1099. result:=nil;
  1100. typecheckpass(left);
  1101. { on statements }
  1102. if assigned(right) then
  1103. typecheckpass(right);
  1104. { else block }
  1105. if assigned(t1) then
  1106. typecheckpass(t1);
  1107. resultdef:=voidtype;
  1108. end;
  1109. function ttryexceptnode.pass_1 : tnode;
  1110. begin
  1111. result:=nil;
  1112. include(current_procinfo.flags,pi_do_call);
  1113. expectloc:=LOC_VOID;
  1114. firstpass(left);
  1115. { on statements }
  1116. if assigned(right) then
  1117. begin
  1118. firstpass(right);
  1119. registersint:=max(registersint,right.registersint);
  1120. registersfpu:=max(registersfpu,right.registersfpu);
  1121. {$ifdef SUPPORT_MMX}
  1122. registersmmx:=max(registersmmx,right.registersmmx);
  1123. {$endif SUPPORT_MMX}
  1124. end;
  1125. { else block }
  1126. if assigned(t1) then
  1127. begin
  1128. firstpass(t1);
  1129. registersint:=max(registersint,t1.registersint);
  1130. registersfpu:=max(registersfpu,t1.registersfpu);
  1131. {$ifdef SUPPORT_MMX}
  1132. registersmmx:=max(registersmmx,t1.registersmmx);
  1133. {$endif SUPPORT_MMX}
  1134. end;
  1135. end;
  1136. {*****************************************************************************
  1137. TTRYFINALLYNODE
  1138. *****************************************************************************}
  1139. constructor ttryfinallynode.create(l,r:tnode);
  1140. begin
  1141. inherited create(tryfinallyn,l,r,nil,nil);
  1142. implicitframe:=false;
  1143. end;
  1144. constructor ttryfinallynode.create_implicit(l,r,_t1:tnode);
  1145. begin
  1146. inherited create(tryfinallyn,l,r,_t1,nil);
  1147. implicitframe:=true;
  1148. end;
  1149. function ttryfinallynode.pass_typecheck:tnode;
  1150. begin
  1151. result:=nil;
  1152. include(current_procinfo.flags,pi_do_call);
  1153. resultdef:=voidtype;
  1154. typecheckpass(left);
  1155. // "try block" is "used"? (JM)
  1156. set_varstate(left,vs_readwritten,[vsf_must_be_valid]);
  1157. typecheckpass(right);
  1158. // "except block" is "used"? (JM)
  1159. set_varstate(right,vs_readwritten,[vsf_must_be_valid]);
  1160. { special finally block only executed when there was an exception }
  1161. if assigned(t1) then
  1162. begin
  1163. typecheckpass(t1);
  1164. // "finally block" is "used"? (JM)
  1165. set_varstate(t1,vs_readwritten,[vsf_must_be_valid]);
  1166. end;
  1167. end;
  1168. function ttryfinallynode.pass_1 : tnode;
  1169. begin
  1170. result:=nil;
  1171. expectloc:=LOC_VOID;
  1172. firstpass(left);
  1173. firstpass(right);
  1174. left_right_max;
  1175. if assigned(t1) then
  1176. begin
  1177. firstpass(t1);
  1178. registersint:=max(registersint,t1.registersint);
  1179. registersfpu:=max(registersfpu,t1.registersfpu);
  1180. {$ifdef SUPPORT_MMX}
  1181. registersmmx:=max(registersmmx,t1.registersmmx);
  1182. {$endif SUPPORT_MMX}
  1183. end;
  1184. end;
  1185. {*****************************************************************************
  1186. TONNODE
  1187. *****************************************************************************}
  1188. constructor tonnode.create(l,r:tnode);
  1189. begin
  1190. inherited create(onn,l,r);
  1191. excepTSymtable:=nil;
  1192. excepttype:=nil;
  1193. end;
  1194. destructor tonnode.destroy;
  1195. begin
  1196. { copied nodes don't need to release the symtable }
  1197. if assigned(excepTSymtable) then
  1198. excepTSymtable.free;
  1199. inherited destroy;
  1200. end;
  1201. constructor tonnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  1202. begin
  1203. inherited ppuload(t,ppufile);
  1204. excepTSymtable:=nil;
  1205. excepttype:=nil;
  1206. end;
  1207. function tonnode.dogetcopy : tnode;
  1208. var
  1209. n : tonnode;
  1210. begin
  1211. n:=tonnode(inherited dogetcopy);
  1212. n.excepTSymtable:=excepTSymtable.getcopy;
  1213. n.excepttype:=excepttype;
  1214. result:=n;
  1215. end;
  1216. function tonnode.pass_typecheck:tnode;
  1217. begin
  1218. result:=nil;
  1219. resultdef:=voidtype;
  1220. if not(is_class(excepttype)) then
  1221. CGMessage1(type_e_class_type_expected,excepttype.typename);
  1222. if assigned(left) then
  1223. typecheckpass(left);
  1224. if assigned(right) then
  1225. typecheckpass(right);
  1226. end;
  1227. function tonnode.pass_1 : tnode;
  1228. begin
  1229. result:=nil;
  1230. include(current_procinfo.flags,pi_do_call);
  1231. expectloc:=LOC_VOID;
  1232. registersint:=0;
  1233. registersfpu:=0;
  1234. {$ifdef SUPPORT_MMX}
  1235. registersmmx:=0;
  1236. {$endif SUPPORT_MMX}
  1237. if assigned(left) then
  1238. begin
  1239. firstpass(left);
  1240. registersint:=left.registersint;
  1241. registersfpu:=left.registersfpu;
  1242. {$ifdef SUPPORT_MMX}
  1243. registersmmx:=left.registersmmx;
  1244. {$endif SUPPORT_MMX}
  1245. end;
  1246. if assigned(right) then
  1247. begin
  1248. firstpass(right);
  1249. registersint:=max(registersint,right.registersint);
  1250. registersfpu:=max(registersfpu,right.registersfpu);
  1251. {$ifdef SUPPORT_MMX}
  1252. registersmmx:=max(registersmmx,right.registersmmx);
  1253. {$endif SUPPORT_MMX}
  1254. end;
  1255. end;
  1256. function tonnode.docompare(p: tnode): boolean;
  1257. begin
  1258. docompare := false;
  1259. end;
  1260. begin
  1261. cwhilerepeatnode:=twhilerepeatnode;
  1262. cifnode:=tifnode;
  1263. cfornode:=tfornode;
  1264. cexitnode:=texitnode;
  1265. cgotonode:=tgotonode;
  1266. clabelnode:=tlabelnode;
  1267. craisenode:=traisenode;
  1268. ctryexceptnode:=ttryexceptnode;
  1269. ctryfinallynode:=ttryfinallynode;
  1270. connode:=tonnode;
  1271. end.