nflw.pas 45 KB

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