nutils.pas 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Type checking and register allocation for inline nodes
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit nutils;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype,
  22. symtype,symsym,node;
  23. const
  24. NODE_COMPLEXITY_INF = 255;
  25. type
  26. { resultdef of functions that process on all nodes in a (sub)tree }
  27. foreachnoderesult = (
  28. { false, continue recursion }
  29. fen_false,
  30. { false, stop recursion }
  31. fen_norecurse_false,
  32. { true, continue recursion }
  33. fen_true,
  34. { true, stop recursion }
  35. fen_norecurse_true
  36. );
  37. tforeachprocmethod = (pm_preprocess,pm_postprocess);
  38. foreachnodefunction = function(var n: tnode; arg: pointer): foreachnoderesult of object;
  39. staticforeachnodefunction = function(var n: tnode; arg: pointer): foreachnoderesult;
  40. function foreachnode(var n: tnode; f: foreachnodefunction; arg: pointer): boolean;
  41. function foreachnodestatic(var n: tnode; f: staticforeachnodefunction; arg: pointer): boolean;
  42. function foreachnodestatic(procmethod : tforeachprocmethod;var n: tnode; f: staticforeachnodefunction; arg: pointer): boolean;
  43. { checks if the given node tree contains only nodes of the given type,
  44. if this isn't the case, an ie is thrown
  45. }
  46. procedure checktreenodetypes(n : tnode;typeset : tnodetypeset);
  47. procedure load_procvar_from_calln(var p1:tnode);
  48. function maybe_call_procvar(var p1:tnode;tponly:boolean):boolean;
  49. function get_high_value_sym(vs: tparavarsym):tsym; { marking it as inline causes IE 200311075 during loading from ppu file }
  50. function load_high_value_node(vs:tparavarsym):tnode;
  51. function load_self_node:tnode;
  52. function load_result_node:tnode;
  53. function load_self_pointer_node:tnode;
  54. function load_vmt_pointer_node:tnode;
  55. function is_self_node(p:tnode):boolean;
  56. function call_fail_node:tnode;
  57. function initialize_data_node(p:tnode):tnode;
  58. function finalize_data_node(p:tnode):tnode;
  59. function node_complexity(p: tnode): cardinal;
  60. procedure node_tree_set_filepos(var n:tnode;const filepos:tfileposinfo);
  61. { tries to simplify the given node }
  62. procedure dosimplify(var n : tnode);
  63. implementation
  64. uses
  65. verbose,constexp,globals,
  66. symconst,symbase,symdef,symtable,
  67. defutil,defcmp,
  68. nbas,ncon,ncnv,nld,nflw,nset,ncal,nadd,nmem,
  69. cgbase,procinfo,
  70. pass_1;
  71. function foreachnode(var n: tnode; f: foreachnodefunction; arg: pointer): boolean;
  72. var
  73. i: longint;
  74. begin
  75. result := false;
  76. if not assigned(n) then
  77. exit;
  78. case f(n,arg) of
  79. fen_norecurse_false:
  80. exit;
  81. fen_norecurse_true:
  82. begin
  83. result := true;
  84. exit;
  85. end;
  86. fen_true:
  87. result := true;
  88. { result is already false
  89. fen_false:
  90. result := false; }
  91. end;
  92. case n.nodetype of
  93. asn:
  94. if assigned(tasnode(n).call) then
  95. begin
  96. result := foreachnode(tasnode(n).call,f,arg);
  97. exit
  98. end;
  99. calln:
  100. begin
  101. { not in one statement, won't work because of b- }
  102. result := foreachnode(tcallnode(n).methodpointerinit,f,arg) or result;
  103. result := foreachnode(tcallnode(n).methodpointer,f,arg) or result;
  104. result := foreachnode(tcallnode(n).methodpointerdone,f,arg) or result;
  105. end;
  106. ifn, whilerepeatn, forn:
  107. begin
  108. { not in one statement, won't work because of b- }
  109. result := foreachnode(tloopnode(n).t1,f,arg) or result;
  110. result := foreachnode(tloopnode(n).t2,f,arg) or result;
  111. end;
  112. raisen:
  113. { frame tree }
  114. result := foreachnode(traisenode(n).third,f,arg) or result;
  115. casen:
  116. begin
  117. for i := 0 to tcasenode(n).blocks.count-1 do
  118. if assigned(tcasenode(n).blocks[i]) then
  119. result := foreachnode(pcaseblock(tcasenode(n).blocks[i])^.statement,f,arg) or result;
  120. result := foreachnode(tcasenode(n).elseblock,f,arg) or result;
  121. end;
  122. end;
  123. if n.inheritsfrom(tbinarynode) then
  124. begin
  125. { first process the "payload" of statementnodes }
  126. result := foreachnode(tbinarynode(n).left,f,arg) or result;
  127. result := foreachnode(tbinarynode(n).right,f,arg) or result;
  128. end
  129. else if n.inheritsfrom(tunarynode) then
  130. result := foreachnode(tunarynode(n).left,f,arg) or result;
  131. end;
  132. function foreachnodestatic(procmethod : tforeachprocmethod;var n: tnode; f: staticforeachnodefunction; arg: pointer): boolean;
  133. function process_children(res : boolean) : boolean;
  134. var
  135. i: longint;
  136. begin
  137. result:=res;
  138. case n.nodetype of
  139. asn:
  140. if assigned(tasnode(n).call) then
  141. begin
  142. result := foreachnodestatic(procmethod,tasnode(n).call,f,arg);
  143. exit
  144. end;
  145. calln:
  146. begin
  147. result := foreachnodestatic(procmethod,tcallnode(n).methodpointerinit,f,arg) or result;
  148. result := foreachnodestatic(procmethod,tcallnode(n).methodpointer,f,arg) or result;
  149. result := foreachnodestatic(procmethod,tcallnode(n).methodpointerdone,f,arg) or result;
  150. end;
  151. ifn, whilerepeatn, forn:
  152. begin
  153. { not in one statement, won't work because of b- }
  154. result := foreachnodestatic(procmethod,tloopnode(n).t1,f,arg) or result;
  155. result := foreachnodestatic(procmethod,tloopnode(n).t2,f,arg) or result;
  156. end;
  157. raisen:
  158. { frame tree }
  159. result := foreachnodestatic(traisenode(n).third,f,arg) or result;
  160. casen:
  161. begin
  162. for i := 0 to tcasenode(n).blocks.count-1 do
  163. if assigned(tcasenode(n).blocks[i]) then
  164. result := foreachnodestatic(procmethod,pcaseblock(tcasenode(n).blocks[i])^.statement,f,arg) or result;
  165. result := foreachnodestatic(procmethod,tcasenode(n).elseblock,f,arg) or result;
  166. end;
  167. end;
  168. if n.inheritsfrom(tbinarynode) then
  169. begin
  170. { first process the "payload" of statementnodes }
  171. result := foreachnodestatic(procmethod,tbinarynode(n).left,f,arg) or result;
  172. result := foreachnodestatic(procmethod,tbinarynode(n).right,f,arg) or result;
  173. end
  174. else if n.inheritsfrom(tunarynode) then
  175. result := foreachnodestatic(procmethod,tunarynode(n).left,f,arg) or result;
  176. end;
  177. begin
  178. result := false;
  179. if not assigned(n) then
  180. exit;
  181. if procmethod=pm_preprocess then
  182. result:=process_children(result);
  183. case f(n,arg) of
  184. fen_norecurse_false:
  185. exit;
  186. fen_norecurse_true:
  187. begin
  188. result := true;
  189. exit;
  190. end;
  191. fen_true:
  192. result := true;
  193. { result is already false
  194. fen_false:
  195. result := false; }
  196. end;
  197. if procmethod=pm_postprocess then
  198. result:=process_children(result);
  199. end;
  200. function foreachnodestatic(var n: tnode; f: staticforeachnodefunction; arg: pointer): boolean;
  201. begin
  202. result:=foreachnodestatic(pm_postprocess,n,f,arg);
  203. end;
  204. function do_check(var n: tnode; arg: pointer): foreachnoderesult;
  205. begin
  206. if not(n.nodetype in pnodetypeset(arg)^) then
  207. internalerror(200610141);
  208. result:=fen_true;
  209. end;
  210. procedure checktreenodetypes(n : tnode;typeset : tnodetypeset);
  211. begin
  212. foreachnodestatic(n,@do_check,@typeset);
  213. end;
  214. procedure load_procvar_from_calln(var p1:tnode);
  215. var
  216. p2 : tnode;
  217. begin
  218. if p1.nodetype<>calln then
  219. internalerror(200212251);
  220. { was it a procvar, then we simply remove the calln and
  221. reuse the right }
  222. if assigned(tcallnode(p1).right) then
  223. begin
  224. p2:=tcallnode(p1).right;
  225. tcallnode(p1).right:=nil;
  226. end
  227. else
  228. begin
  229. p2:=cloadnode.create_procvar(tcallnode(p1).symtableprocentry,
  230. tprocdef(tcallnode(p1).procdefinition),tcallnode(p1).symtableproc);
  231. { when the methodpointer is typen we've something like:
  232. tobject.create. Then only the address is needed of the
  233. method without a self pointer }
  234. if assigned(tcallnode(p1).methodpointer) and
  235. (tcallnode(p1).methodpointer.nodetype<>typen) then
  236. tloadnode(p2).set_mp(tcallnode(p1).get_load_methodpointer);
  237. end;
  238. typecheckpass(p2);
  239. p1.free;
  240. p1:=p2;
  241. end;
  242. function maybe_call_procvar(var p1:tnode;tponly:boolean):boolean;
  243. var
  244. hp : tnode;
  245. begin
  246. result:=false;
  247. if (p1.resultdef.typ<>procvardef) or
  248. (tponly and
  249. not(m_tp_procvar in current_settings.modeswitches)) then
  250. exit;
  251. { ignore vecn,subscriptn }
  252. hp:=p1;
  253. repeat
  254. case hp.nodetype of
  255. vecn,
  256. derefn,
  257. typeconvn,
  258. subscriptn :
  259. hp:=tunarynode(hp).left;
  260. else
  261. break;
  262. end;
  263. until false;
  264. { a tempref is used when it is loaded from a withsymtable }
  265. if (hp.nodetype in [calln,loadn,temprefn]) then
  266. begin
  267. hp:=ccallnode.create_procvar(nil,p1);
  268. typecheckpass(hp);
  269. p1:=hp;
  270. result:=true;
  271. end;
  272. end;
  273. function get_high_value_sym(vs: tparavarsym):tsym;
  274. begin
  275. result := tsym(vs.owner.Find('high'+vs.name));
  276. end;
  277. function load_high_value_node(vs:tparavarsym):tnode;
  278. var
  279. srsym : tsym;
  280. begin
  281. result:=nil;
  282. srsym:=get_high_value_sym(vs);
  283. if assigned(srsym) then
  284. begin
  285. result:=cloadnode.create(srsym,vs.owner);
  286. typecheckpass(result);
  287. end
  288. else
  289. CGMessage(parser_e_illegal_expression);
  290. end;
  291. function load_self_node:tnode;
  292. var
  293. srsym : tsym;
  294. srsymtable : TSymtable;
  295. begin
  296. result:=nil;
  297. searchsym('self',srsym,srsymtable);
  298. if assigned(srsym) then
  299. begin
  300. result:=cloadnode.create(srsym,srsymtable);
  301. include(result.flags,nf_is_self);
  302. end
  303. else
  304. begin
  305. result:=cerrornode.create;
  306. CGMessage(parser_e_illegal_expression);
  307. end;
  308. typecheckpass(result);
  309. end;
  310. function load_result_node:tnode;
  311. var
  312. srsym : tsym;
  313. srsymtable : TSymtable;
  314. begin
  315. result:=nil;
  316. searchsym('result',srsym,srsymtable);
  317. if assigned(srsym) then
  318. result:=cloadnode.create(srsym,srsymtable)
  319. else
  320. begin
  321. result:=cerrornode.create;
  322. CGMessage(parser_e_illegal_expression);
  323. end;
  324. typecheckpass(result);
  325. end;
  326. function load_self_pointer_node:tnode;
  327. var
  328. srsym : tsym;
  329. srsymtable : TSymtable;
  330. begin
  331. result:=nil;
  332. searchsym('self',srsym,srsymtable);
  333. if assigned(srsym) then
  334. begin
  335. result:=cloadnode.create(srsym,srsymtable);
  336. include(result.flags,nf_load_self_pointer);
  337. end
  338. else
  339. begin
  340. result:=cerrornode.create;
  341. CGMessage(parser_e_illegal_expression);
  342. end;
  343. typecheckpass(result);
  344. end;
  345. function load_vmt_pointer_node:tnode;
  346. var
  347. srsym : tsym;
  348. srsymtable : TSymtable;
  349. begin
  350. result:=nil;
  351. searchsym('vmt',srsym,srsymtable);
  352. if assigned(srsym) then
  353. result:=cloadnode.create(srsym,srsymtable)
  354. else
  355. begin
  356. result:=cerrornode.create;
  357. CGMessage(parser_e_illegal_expression);
  358. end;
  359. typecheckpass(result);
  360. end;
  361. function is_self_node(p:tnode):boolean;
  362. begin
  363. is_self_node:=(p.nodetype=loadn) and
  364. (tloadnode(p).symtableentry.typ=paravarsym) and
  365. (vo_is_self in tparavarsym(tloadnode(p).symtableentry).varoptions);
  366. end;
  367. function call_fail_node:tnode;
  368. var
  369. para : tcallparanode;
  370. newstatement : tstatementnode;
  371. srsym : tsym;
  372. begin
  373. result:=internalstatements(newstatement);
  374. { call fail helper and exit normal }
  375. if is_class(current_procinfo.procdef._class) then
  376. begin
  377. srsym:=search_class_member(current_procinfo.procdef._class,'FREEINSTANCE');
  378. if assigned(srsym) and
  379. (srsym.typ=procsym) then
  380. begin
  381. { if self<>0 and vmt=1 then freeinstance }
  382. addstatement(newstatement,cifnode.create(
  383. caddnode.create(andn,
  384. caddnode.create(unequaln,
  385. load_self_pointer_node,
  386. cnilnode.create),
  387. caddnode.create(equaln,
  388. ctypeconvnode.create(
  389. load_vmt_pointer_node,
  390. voidpointertype),
  391. cpointerconstnode.create(1,voidpointertype))),
  392. ccallnode.create(nil,tprocsym(srsym),srsym.owner,load_self_node,[]),
  393. nil));
  394. end
  395. else
  396. internalerror(200305108);
  397. end
  398. else
  399. if is_object(current_procinfo.procdef._class) then
  400. begin
  401. { parameter 3 : vmt_offset }
  402. { parameter 2 : pointer to vmt }
  403. { parameter 1 : self pointer }
  404. para:=ccallparanode.create(
  405. cordconstnode.create(current_procinfo.procdef._class.vmt_offset,s32inttype,false),
  406. ccallparanode.create(
  407. ctypeconvnode.create_internal(
  408. load_vmt_pointer_node,
  409. voidpointertype),
  410. ccallparanode.create(
  411. ctypeconvnode.create_internal(
  412. load_self_pointer_node,
  413. voidpointertype),
  414. nil)));
  415. addstatement(newstatement,
  416. ccallnode.createintern('fpc_help_fail',para));
  417. end
  418. else
  419. internalerror(200305132);
  420. { self:=nil }
  421. addstatement(newstatement,cassignmentnode.create(
  422. load_self_pointer_node,
  423. cnilnode.create));
  424. { exit }
  425. addstatement(newstatement,cexitnode.create(nil));
  426. end;
  427. function initialize_data_node(p:tnode):tnode;
  428. begin
  429. if not assigned(p.resultdef) then
  430. typecheckpass(p);
  431. if is_ansistring(p.resultdef) or
  432. is_widestring(p.resultdef) or
  433. is_interfacecom(p.resultdef) or
  434. is_dynamic_array(p.resultdef) then
  435. begin
  436. result:=cassignmentnode.create(
  437. ctypeconvnode.create_internal(p,voidpointertype),
  438. cnilnode.create
  439. );
  440. end
  441. else
  442. begin
  443. result:=ccallnode.createintern('fpc_initialize',
  444. ccallparanode.create(
  445. caddrnode.create_internal(
  446. crttinode.create(
  447. tstoreddef(p.resultdef),initrtti,rdt_normal)),
  448. ccallparanode.create(
  449. caddrnode.create_internal(p),
  450. nil)));
  451. end;
  452. end;
  453. function finalize_data_node(p:tnode):tnode;
  454. var
  455. newstatement : tstatementnode;
  456. begin
  457. if not assigned(p.resultdef) then
  458. typecheckpass(p);
  459. if is_ansistring(p.resultdef) then
  460. begin
  461. result:=internalstatements(newstatement);
  462. addstatement(newstatement,ccallnode.createintern('fpc_ansistr_decr_ref',
  463. ccallparanode.create(
  464. ctypeconvnode.create_internal(p,voidpointertype),
  465. nil)));
  466. addstatement(newstatement,cassignmentnode.create(
  467. ctypeconvnode.create_internal(p.getcopy,voidpointertype),
  468. cnilnode.create
  469. ));
  470. end
  471. else if is_widestring(p.resultdef) then
  472. begin
  473. result:=internalstatements(newstatement);
  474. addstatement(newstatement,ccallnode.createintern('fpc_widestr_decr_ref',
  475. ccallparanode.create(
  476. ctypeconvnode.create_internal(p,voidpointertype),
  477. nil)));
  478. addstatement(newstatement,cassignmentnode.create(
  479. ctypeconvnode.create_internal(p.getcopy,voidpointertype),
  480. cnilnode.create
  481. ));
  482. end
  483. else
  484. result:=ccallnode.createintern('fpc_finalize',
  485. ccallparanode.create(
  486. caddrnode.create_internal(
  487. crttinode.create(
  488. tstoreddef(p.resultdef),initrtti,rdt_normal)),
  489. ccallparanode.create(
  490. caddrnode.create_internal(p),
  491. nil)));
  492. end;
  493. { this function must return a very high value ("infinity") for }
  494. { trees containing a call, the rest can be balanced more or less }
  495. { at will, probably best mainly in terms of required memory }
  496. { accesses }
  497. function node_complexity(p: tnode): cardinal;
  498. begin
  499. result := 0;
  500. while assigned(p) do
  501. begin
  502. case p.nodetype of
  503. temprefn,
  504. loadvmtaddrn,
  505. { main reason for the next one: we can't take the address of }
  506. { loadparentfpnode, so replacing it by a temp which is the }
  507. { address of this node's location and then dereferencing }
  508. { doesn't work. If changed, check whether webtbs/tw0935 }
  509. { still works with nodeinlining (JM) }
  510. loadparentfpn:
  511. begin
  512. result := 1;
  513. exit;
  514. end;
  515. loadn:
  516. begin
  517. { threadvars need a helper call }
  518. if (tloadnode(p).symtableentry.typ=staticvarsym) and
  519. (vo_is_thread_var in tstaticvarsym(tloadnode(p).symtableentry).varoptions) then
  520. inc(result,5)
  521. else
  522. inc(result);
  523. if (result >= NODE_COMPLEXITY_INF) then
  524. result := NODE_COMPLEXITY_INF;
  525. exit;
  526. end;
  527. subscriptn:
  528. begin
  529. if is_class_or_interface(tunarynode(p).left.resultdef) then
  530. inc(result);
  531. if (result = NODE_COMPLEXITY_INF) then
  532. exit;
  533. p := tunarynode(p).left;
  534. end;
  535. blockn:
  536. p := tunarynode(p).left;
  537. notn,
  538. derefn :
  539. begin
  540. inc(result);
  541. if (result = NODE_COMPLEXITY_INF) then
  542. exit;
  543. p := tunarynode(p).left;
  544. end;
  545. typeconvn:
  546. begin
  547. { may be more complex in some cases }
  548. if not(ttypeconvnode(p).convtype in [tc_equal,tc_int_2_int,tc_bool_2_bool,tc_real_2_real,tc_cord_2_pointer]) then
  549. inc(result);
  550. if (result = NODE_COMPLEXITY_INF) then
  551. exit;
  552. p := tunarynode(p).left;
  553. end;
  554. vecn,
  555. statementn:
  556. begin
  557. inc(result,node_complexity(tbinarynode(p).left));
  558. if (result >= NODE_COMPLEXITY_INF) then
  559. begin
  560. result := NODE_COMPLEXITY_INF;
  561. exit;
  562. end;
  563. p := tbinarynode(p).right;
  564. end;
  565. addn,subn,orn,andn,xorn,muln,divn,modn,symdifn,
  566. shln,shrn,
  567. equaln,unequaln,gtn,gten,ltn,lten,
  568. assignn:
  569. begin
  570. inc(result,node_complexity(tbinarynode(p).left)+1);
  571. if (p.nodetype in [muln,divn,modn]) then
  572. inc(result,5);
  573. if (result >= NODE_COMPLEXITY_INF) then
  574. begin
  575. result := NODE_COMPLEXITY_INF;
  576. exit;
  577. end;
  578. p := tbinarynode(p).right;
  579. end;
  580. tempcreaten,
  581. tempdeleten,
  582. ordconstn,
  583. pointerconstn,
  584. nothingn,
  585. niln:
  586. exit;
  587. else
  588. begin
  589. result := NODE_COMPLEXITY_INF;
  590. exit;
  591. end;
  592. end;
  593. end;
  594. end;
  595. function setnodefilepos(var n: tnode; arg: pointer): foreachnoderesult;
  596. begin
  597. result:=fen_true;
  598. n.fileinfo:=pfileposinfo(arg)^;
  599. end;
  600. procedure node_tree_set_filepos(var n:tnode;const filepos:tfileposinfo);
  601. begin
  602. foreachnodestatic(n,@setnodefilepos,@filepos);
  603. end;
  604. {$ifdef FPCMT}
  605. threadvar
  606. {$else FPCMT}
  607. var
  608. {$endif FPCMT}
  609. treechanged : boolean;
  610. function callsimplify(var n: tnode; arg: pointer): foreachnoderesult;
  611. var
  612. hn : tnode;
  613. begin
  614. result:=fen_false;
  615. // do_typecheckpass(n);
  616. hn:=n.simplify;
  617. if assigned(hn) then
  618. begin
  619. treechanged:=true;
  620. n.free;
  621. n:=hn;
  622. typecheckpass(n);
  623. end;
  624. end;
  625. { tries to simplify the given node calling the simplify method recursively }
  626. procedure dosimplify(var n : tnode);
  627. begin
  628. repeat
  629. treechanged:=false;
  630. foreachnodestatic(pm_preprocess,n,@callsimplify,nil);
  631. until not(treechanged);
  632. end;
  633. end.