nflw.pas 44 KB

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