nflw.pas 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497
  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. 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;reintroduce;
  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;reintroduce;
  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;reintroduce;
  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. begin
  947. p:=tgotonode(inherited dogetcopy);
  948. p.exceptionblock:=exceptionblock;
  949. { force a valid labelnode }
  950. if not(assigned(labelnode)) then
  951. begin
  952. if assigned(labelsym) and assigned(labelsym.code) then
  953. labelnode:=tlabelnode(labelsym.code)
  954. else
  955. internalerror(200610291);
  956. end;
  957. p.labelnode:=tlabelnode(labelnode.dogetcopy);
  958. result:=p;
  959. end;
  960. function tgotonode.docompare(p: tnode): boolean;
  961. begin
  962. docompare := false;
  963. end;
  964. {*****************************************************************************
  965. TLABELNODE
  966. *****************************************************************************}
  967. constructor tlabelnode.create(l:tnode);
  968. begin
  969. inherited create(labeln,l);
  970. exceptionblock:=aktexceptblock;
  971. end;
  972. constructor tlabelnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  973. begin
  974. inherited ppuload(t,ppufile);
  975. exceptionblock:=ppufile.getbyte;
  976. end;
  977. procedure tlabelnode.ppuwrite(ppufile:tcompilerppufile);
  978. begin
  979. inherited ppuwrite(ppufile);
  980. ppufile.putbyte(exceptionblock);
  981. end;
  982. procedure tlabelnode.buildderefimpl;
  983. begin
  984. inherited buildderefimpl;
  985. end;
  986. procedure tlabelnode.derefimpl;
  987. begin
  988. inherited derefimpl;
  989. end;
  990. function tlabelnode.pass_typecheck:tnode;
  991. begin
  992. result:=nil;
  993. { left could still be unassigned }
  994. if assigned(left) then
  995. typecheckpass(left);
  996. resultdef:=voidtype;
  997. end;
  998. function tlabelnode.pass_1 : tnode;
  999. begin
  1000. result:=nil;
  1001. expectloc:=LOC_VOID;
  1002. if assigned(left) then
  1003. begin
  1004. firstpass(left);
  1005. registersint:=left.registersint;
  1006. registersfpu:=left.registersfpu;
  1007. {$ifdef SUPPORT_MMX}
  1008. registersmmx:=left.registersmmx;
  1009. {$endif SUPPORT_MMX}
  1010. end;
  1011. end;
  1012. function tlabelnode.dogetcopy : tnode;
  1013. begin
  1014. if not(assigned(copiedto)) then
  1015. copiedto:=tlabelnode(inherited dogetcopy);
  1016. copiedto.exceptionblock:=exceptionblock;
  1017. result:=copiedto;
  1018. end;
  1019. function tlabelnode.docompare(p: tnode): boolean;
  1020. begin
  1021. docompare := false;
  1022. end;
  1023. {*****************************************************************************
  1024. TRAISENODE
  1025. *****************************************************************************}
  1026. constructor traisenode.create(l,taddr,tframe:tnode);
  1027. begin
  1028. inherited create(raisen,l,taddr,tframe);
  1029. end;
  1030. function traisenode.pass_typecheck:tnode;
  1031. begin
  1032. result:=nil;
  1033. resultdef:=voidtype;
  1034. if assigned(left) then
  1035. begin
  1036. { first para must be a _class_ }
  1037. typecheckpass(left);
  1038. set_varstate(left,vs_read,[vsf_must_be_valid]);
  1039. if codegenerror then
  1040. exit;
  1041. if not(is_class(left.resultdef)) then
  1042. CGMessage1(type_e_class_type_expected,left.resultdef.typename);
  1043. { insert needed typeconvs for addr,frame }
  1044. if assigned(right) then
  1045. begin
  1046. { addr }
  1047. typecheckpass(right);
  1048. inserttypeconv(right,voidpointertype);
  1049. { frame }
  1050. if assigned(frametree) then
  1051. begin
  1052. typecheckpass(frametree);
  1053. inserttypeconv(frametree,voidpointertype);
  1054. end;
  1055. end;
  1056. end;
  1057. end;
  1058. function traisenode.pass_1 : tnode;
  1059. begin
  1060. result:=nil;
  1061. include(current_procinfo.flags,pi_do_call);
  1062. expectloc:=LOC_VOID;
  1063. if assigned(left) then
  1064. begin
  1065. { first para must be a _class_ }
  1066. firstpass(left);
  1067. { insert needed typeconvs for addr,frame }
  1068. if assigned(right) then
  1069. begin
  1070. { addr }
  1071. firstpass(right);
  1072. { frame }
  1073. if assigned(frametree) then
  1074. firstpass(frametree);
  1075. end;
  1076. left_right_max;
  1077. end;
  1078. end;
  1079. {*****************************************************************************
  1080. TTRYEXCEPTNODE
  1081. *****************************************************************************}
  1082. constructor ttryexceptnode.create(l,r,_t1 : tnode);
  1083. begin
  1084. inherited create(tryexceptn,l,r,_t1,nil);
  1085. end;
  1086. function ttryexceptnode.pass_typecheck:tnode;
  1087. begin
  1088. result:=nil;
  1089. typecheckpass(left);
  1090. { on statements }
  1091. if assigned(right) then
  1092. typecheckpass(right);
  1093. { else block }
  1094. if assigned(t1) then
  1095. typecheckpass(t1);
  1096. resultdef:=voidtype;
  1097. end;
  1098. function ttryexceptnode.pass_1 : tnode;
  1099. begin
  1100. result:=nil;
  1101. include(current_procinfo.flags,pi_do_call);
  1102. expectloc:=LOC_VOID;
  1103. firstpass(left);
  1104. { on statements }
  1105. if assigned(right) then
  1106. begin
  1107. firstpass(right);
  1108. registersint:=max(registersint,right.registersint);
  1109. registersfpu:=max(registersfpu,right.registersfpu);
  1110. {$ifdef SUPPORT_MMX}
  1111. registersmmx:=max(registersmmx,right.registersmmx);
  1112. {$endif SUPPORT_MMX}
  1113. end;
  1114. { else block }
  1115. if assigned(t1) then
  1116. begin
  1117. firstpass(t1);
  1118. registersint:=max(registersint,t1.registersint);
  1119. registersfpu:=max(registersfpu,t1.registersfpu);
  1120. {$ifdef SUPPORT_MMX}
  1121. registersmmx:=max(registersmmx,t1.registersmmx);
  1122. {$endif SUPPORT_MMX}
  1123. end;
  1124. end;
  1125. {*****************************************************************************
  1126. TTRYFINALLYNODE
  1127. *****************************************************************************}
  1128. constructor ttryfinallynode.create(l,r:tnode);
  1129. begin
  1130. inherited create(tryfinallyn,l,r,nil,nil);
  1131. implicitframe:=false;
  1132. end;
  1133. constructor ttryfinallynode.create_implicit(l,r,_t1:tnode);
  1134. begin
  1135. inherited create(tryfinallyn,l,r,_t1,nil);
  1136. implicitframe:=true;
  1137. end;
  1138. function ttryfinallynode.pass_typecheck:tnode;
  1139. begin
  1140. result:=nil;
  1141. include(current_procinfo.flags,pi_do_call);
  1142. resultdef:=voidtype;
  1143. typecheckpass(left);
  1144. // "try block" is "used"? (JM)
  1145. set_varstate(left,vs_readwritten,[vsf_must_be_valid]);
  1146. typecheckpass(right);
  1147. // "except block" is "used"? (JM)
  1148. set_varstate(right,vs_readwritten,[vsf_must_be_valid]);
  1149. { special finally block only executed when there was an exception }
  1150. if assigned(t1) then
  1151. begin
  1152. typecheckpass(t1);
  1153. // "finally block" is "used"? (JM)
  1154. set_varstate(t1,vs_readwritten,[vsf_must_be_valid]);
  1155. end;
  1156. end;
  1157. function ttryfinallynode.pass_1 : tnode;
  1158. begin
  1159. result:=nil;
  1160. expectloc:=LOC_VOID;
  1161. firstpass(left);
  1162. firstpass(right);
  1163. left_right_max;
  1164. if assigned(t1) then
  1165. begin
  1166. firstpass(t1);
  1167. registersint:=max(registersint,t1.registersint);
  1168. registersfpu:=max(registersfpu,t1.registersfpu);
  1169. {$ifdef SUPPORT_MMX}
  1170. registersmmx:=max(registersmmx,t1.registersmmx);
  1171. {$endif SUPPORT_MMX}
  1172. end;
  1173. end;
  1174. {*****************************************************************************
  1175. TONNODE
  1176. *****************************************************************************}
  1177. constructor tonnode.create(l,r:tnode);
  1178. begin
  1179. inherited create(onn,l,r);
  1180. excepTSymtable:=nil;
  1181. excepttype:=nil;
  1182. end;
  1183. destructor tonnode.destroy;
  1184. begin
  1185. { copied nodes don't need to release the symtable }
  1186. if assigned(excepTSymtable) then
  1187. excepTSymtable.free;
  1188. inherited destroy;
  1189. end;
  1190. constructor tonnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  1191. begin
  1192. inherited ppuload(t,ppufile);
  1193. excepTSymtable:=nil;
  1194. excepttype:=nil;
  1195. end;
  1196. function tonnode.dogetcopy : tnode;
  1197. var
  1198. n : tonnode;
  1199. begin
  1200. n:=tonnode(inherited dogetcopy);
  1201. n.excepTSymtable:=excepTSymtable.getcopy;
  1202. n.excepttype:=excepttype;
  1203. result:=n;
  1204. end;
  1205. function tonnode.pass_typecheck:tnode;
  1206. begin
  1207. result:=nil;
  1208. resultdef:=voidtype;
  1209. if not(is_class(excepttype)) then
  1210. CGMessage1(type_e_class_type_expected,excepttype.typename);
  1211. if assigned(left) then
  1212. typecheckpass(left);
  1213. if assigned(right) then
  1214. typecheckpass(right);
  1215. end;
  1216. function tonnode.pass_1 : tnode;
  1217. begin
  1218. result:=nil;
  1219. include(current_procinfo.flags,pi_do_call);
  1220. expectloc:=LOC_VOID;
  1221. registersint:=0;
  1222. registersfpu:=0;
  1223. {$ifdef SUPPORT_MMX}
  1224. registersmmx:=0;
  1225. {$endif SUPPORT_MMX}
  1226. if assigned(left) then
  1227. begin
  1228. firstpass(left);
  1229. registersint:=left.registersint;
  1230. registersfpu:=left.registersfpu;
  1231. {$ifdef SUPPORT_MMX}
  1232. registersmmx:=left.registersmmx;
  1233. {$endif SUPPORT_MMX}
  1234. end;
  1235. if assigned(right) then
  1236. begin
  1237. firstpass(right);
  1238. registersint:=max(registersint,right.registersint);
  1239. registersfpu:=max(registersfpu,right.registersfpu);
  1240. {$ifdef SUPPORT_MMX}
  1241. registersmmx:=max(registersmmx,right.registersmmx);
  1242. {$endif SUPPORT_MMX}
  1243. end;
  1244. end;
  1245. function tonnode.docompare(p: tnode): boolean;
  1246. begin
  1247. docompare := false;
  1248. end;
  1249. begin
  1250. cwhilerepeatnode:=twhilerepeatnode;
  1251. cifnode:=tifnode;
  1252. cfornode:=tfornode;
  1253. cexitnode:=texitnode;
  1254. cgotonode:=tgotonode;
  1255. clabelnode:=tlabelnode;
  1256. craisenode:=traisenode;
  1257. ctryexceptnode:=ttryexceptnode;
  1258. ctryfinallynode:=ttryfinallynode;
  1259. connode:=tonnode;
  1260. end.