nflw.pas 45 KB

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