nflw.pas 45 KB

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