nbas.pas 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859
  1. {
  2. $Id$
  3. Copyright (c) 2000-2002 by Florian Klaempfl
  4. This unit implements some basic nodes
  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 nbas;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cpubase,
  23. aasmbase,aasmtai,aasmcpu,
  24. node,
  25. symtype,symppu;
  26. type
  27. tnothingnode = class(tnode)
  28. constructor create;virtual;
  29. function pass_1 : tnode;override;
  30. function det_resulttype:tnode;override;
  31. end;
  32. tnothingnodeclass = class of tnothingnode;
  33. terrornode = class(tnode)
  34. constructor create;virtual;
  35. function pass_1 : tnode;override;
  36. function det_resulttype:tnode;override;
  37. end;
  38. terrornodeclass = class of terrornode;
  39. tasmnode = class(tnode)
  40. p_asm : taasmoutput;
  41. constructor create(p : taasmoutput);virtual;
  42. destructor destroy;override;
  43. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  44. procedure ppuwrite(ppufile:tcompilerppufile);override;
  45. procedure derefimpl;override;
  46. function getcopy : tnode;override;
  47. function pass_1 : tnode;override;
  48. function det_resulttype:tnode;override;
  49. function docompare(p: tnode): boolean; override;
  50. end;
  51. tasmnodeclass = class of tasmnode;
  52. tstatementnode = class(tbinarynode)
  53. constructor create(l,r : tnode);virtual;
  54. function pass_1 : tnode;override;
  55. function det_resulttype:tnode;override;
  56. {$ifdef extdebug}
  57. procedure _dowrite;override;
  58. {$endif extdebug}
  59. end;
  60. tstatementnodeclass = class of tstatementnode;
  61. tblocknode = class(tunarynode)
  62. constructor create(l : tnode);virtual;
  63. function pass_1 : tnode;override;
  64. function det_resulttype:tnode;override;
  65. {$ifdef state_tracking}
  66. function track_state_pass(exec_known:boolean):boolean;override;
  67. {$endif state_tracking}
  68. end;
  69. tblocknodeclass = class of tblocknode;
  70. { to allow access to the location by temp references even after the temp has }
  71. { already been disposed and to make sure the coherency between temps and }
  72. { temp references is kept after a getcopy }
  73. ptempinfo = ^ttempinfo;
  74. ttempinfo = record
  75. { set to the copy of a tempcreate pnode (if it gets copied) so that the }
  76. { refs and deletenode can hook to this copy once they get copied too }
  77. hookoncopy : ptempinfo;
  78. ref : treference;
  79. restype : ttype;
  80. valid : boolean;
  81. end;
  82. { a node which will create a (non)persistent temp of a given type with a given }
  83. { size (the size is separate to allow creating "void" temps with a custom size) }
  84. ttempcreatenode = class(tnode)
  85. size: longint;
  86. tempinfo: ptempinfo;
  87. persistent: boolean;
  88. { * persistent temps are used in manually written code where the temp }
  89. { be usable among different statements and where you can manually say }
  90. { when the temp has to be freed (using a ttempdeletenode) }
  91. { * non-persistent temps are mostly used in typeconversion helpers, }
  92. { where the node that receives the temp becomes responsible for }
  93. { freeing it. In this last case, you should use only one reference }
  94. { to it and *not* generate a ttempdeletenode }
  95. constructor create(const _restype: ttype; _size: longint; _persistent: boolean); virtual;
  96. function getcopy: tnode; override;
  97. function pass_1 : tnode; override;
  98. function det_resulttype: tnode; override;
  99. function docompare(p: tnode): boolean; override;
  100. end;
  101. ttempcreatenodeclass = class of ttempcreatenode;
  102. { a node which is a reference to a certain temp }
  103. ttemprefnode = class(tnode)
  104. {$ifdef var_notification}
  105. writeaccess:boolean;
  106. {$endif}
  107. constructor create(const temp: ttempcreatenode); virtual;
  108. constructor create_offset(const temp: ttempcreatenode;aoffset:longint);
  109. function getcopy: tnode; override;
  110. function pass_1 : tnode; override;
  111. function det_resulttype : tnode; override;
  112. {$ifdef var_notification}
  113. procedure mark_write;override;
  114. {$endif}
  115. function docompare(p: tnode): boolean; override;
  116. protected
  117. tempinfo: ptempinfo;
  118. offset : longint;
  119. end;
  120. ttemprefnodeclass = class of ttemprefnode;
  121. { a node which removes a temp }
  122. ttempdeletenode = class(tnode)
  123. constructor create(const temp: ttempcreatenode);
  124. { this will convert the persistant temp to a normal temp
  125. for returning to the other nodes }
  126. constructor create_normal_temp(const temp: ttempcreatenode);
  127. function getcopy: tnode; override;
  128. function pass_1: tnode; override;
  129. function det_resulttype: tnode; override;
  130. function docompare(p: tnode): boolean; override;
  131. destructor destroy; override;
  132. protected
  133. tempinfo: ptempinfo;
  134. release_to_normal : boolean;
  135. end;
  136. ttempdeletenodeclass = class of ttempdeletenode;
  137. var
  138. cnothingnode : tnothingnodeclass;
  139. cerrornode : terrornodeclass;
  140. casmnode : tasmnodeclass;
  141. cstatementnode : tstatementnodeclass;
  142. cblocknode : tblocknodeclass;
  143. ctempcreatenode : ttempcreatenodeclass;
  144. ctemprefnode : ttemprefnodeclass;
  145. ctempdeletenode : ttempdeletenodeclass;
  146. { Create a blocknode and statement node for multiple statements
  147. generated internally by the parser }
  148. function internalstatements(var laststatement:tstatementnode):tblocknode;
  149. procedure addstatement(var laststatement:tstatementnode;n:tnode);
  150. implementation
  151. uses
  152. cutils,
  153. verbose,globals,globtype,systems,
  154. symconst,symdef,symsym,defbase,
  155. pass_1,
  156. nld,ncal,nflw,rgobj,cgbase
  157. ;
  158. {*****************************************************************************
  159. Helpers
  160. *****************************************************************************}
  161. function internalstatements(var laststatement:tstatementnode):tblocknode;
  162. begin
  163. { create dummy initial statement }
  164. laststatement := cstatementnode.create(nil,cnothingnode.create);
  165. internalstatements := cblocknode.create(laststatement);
  166. end;
  167. procedure addstatement(var laststatement:tstatementnode;n:tnode);
  168. begin
  169. if assigned(laststatement.left) then
  170. internalerror(200204201);
  171. laststatement.left:=cstatementnode.create(nil,n);
  172. laststatement:=tstatementnode(laststatement.left);
  173. end;
  174. {*****************************************************************************
  175. TFIRSTNOTHING
  176. *****************************************************************************}
  177. constructor tnothingnode.create;
  178. begin
  179. inherited create(nothingn);
  180. end;
  181. function tnothingnode.det_resulttype:tnode;
  182. begin
  183. result:=nil;
  184. resulttype:=voidtype;
  185. end;
  186. function tnothingnode.pass_1 : tnode;
  187. begin
  188. result:=nil;
  189. end;
  190. {*****************************************************************************
  191. TFIRSTERROR
  192. *****************************************************************************}
  193. constructor terrornode.create;
  194. begin
  195. inherited create(errorn);
  196. end;
  197. function terrornode.det_resulttype:tnode;
  198. begin
  199. result:=nil;
  200. include(flags,nf_error);
  201. codegenerror:=true;
  202. resulttype:=generrortype;
  203. end;
  204. function terrornode.pass_1 : tnode;
  205. begin
  206. result:=nil;
  207. codegenerror:=true;
  208. end;
  209. {*****************************************************************************
  210. TSTATEMENTNODE
  211. *****************************************************************************}
  212. constructor tstatementnode.create(l,r : tnode);
  213. begin
  214. inherited create(statementn,l,r);
  215. end;
  216. function tstatementnode.det_resulttype:tnode;
  217. begin
  218. result:=nil;
  219. resulttype:=voidtype;
  220. { right is the statement itself calln assignn or a complex one }
  221. resulttypepass(right);
  222. if (not (cs_extsyntax in aktmoduleswitches)) and
  223. assigned(right.resulttype.def) and
  224. not((right.nodetype=calln) and
  225. (tcallnode(right).procdefinition.proctypeoption=potype_constructor)) and
  226. not(is_void(right.resulttype.def)) then
  227. CGMessage(cg_e_illegal_expression);
  228. if codegenerror then
  229. exit;
  230. { left is the next in the list }
  231. resulttypepass(left);
  232. if codegenerror then
  233. exit;
  234. end;
  235. function tstatementnode.pass_1 : tnode;
  236. begin
  237. result:=nil;
  238. { no temps over several statements }
  239. rg.cleartempgen;
  240. { right is the statement itself calln assignn or a complex one }
  241. firstpass(right);
  242. if codegenerror then
  243. exit;
  244. location.loc:=right.location.loc;
  245. registers32:=right.registers32;
  246. registersfpu:=right.registersfpu;
  247. {$ifdef SUPPORT_MMX}
  248. registersmmx:=right.registersmmx;
  249. {$endif SUPPORT_MMX}
  250. { left is the next in the list }
  251. firstpass(left);
  252. if codegenerror then
  253. exit;
  254. if right.registers32>registers32 then
  255. registers32:=right.registers32;
  256. if right.registersfpu>registersfpu then
  257. registersfpu:=right.registersfpu;
  258. {$ifdef SUPPORT_MMX}
  259. if right.registersmmx>registersmmx then
  260. registersmmx:=right.registersmmx;
  261. {$endif}
  262. end;
  263. {$ifdef extdebug}
  264. procedure tstatementnode._dowrite;
  265. begin
  266. { can't use inherited dowrite, because that will use the
  267. binary which we don't want for statements }
  268. dowritenodetype;
  269. writeln(',');
  270. { write the statement }
  271. writenodeindention:=writenodeindention+' ';
  272. writenode(right);
  273. writeln(')');
  274. delete(writenodeindention,1,4);
  275. { go on with the next statement }
  276. writenode(left);
  277. end;
  278. {$endif}
  279. {*****************************************************************************
  280. TBLOCKNODE
  281. *****************************************************************************}
  282. constructor tblocknode.create(l : tnode);
  283. begin
  284. inherited create(blockn,l);
  285. end;
  286. function tblocknode.det_resulttype:tnode;
  287. var
  288. hp : tstatementnode;
  289. begin
  290. result:=nil;
  291. resulttype:=voidtype;
  292. hp:=tstatementnode(left);
  293. while assigned(hp) do
  294. begin
  295. if assigned(hp.right) then
  296. begin
  297. codegenerror:=false;
  298. resulttypepass(hp.right);
  299. if (not (cs_extsyntax in aktmoduleswitches)) and
  300. assigned(hp.right.resulttype.def) and
  301. not((hp.right.nodetype=calln) and
  302. (tcallnode(hp.right).procdefinition.proctypeoption=potype_constructor)) and
  303. not(is_void(hp.right.resulttype.def)) then
  304. CGMessage(cg_e_illegal_expression);
  305. { the resulttype of the block is the last type that is
  306. returned. Normally this is a voidtype. But when the
  307. compiler inserts a block of multiple statements then the
  308. last entry can return a value }
  309. resulttype:=hp.right.resulttype;
  310. end;
  311. hp:=tstatementnode(hp.left);
  312. end;
  313. end;
  314. function tblocknode.pass_1 : tnode;
  315. var
  316. hp : tstatementnode;
  317. count : longint;
  318. begin
  319. result:=nil;
  320. count:=0;
  321. hp:=tstatementnode(left);
  322. while assigned(hp) do
  323. begin
  324. if cs_regalloc in aktglobalswitches then
  325. begin
  326. { node transformations }
  327. { concat function result to exit }
  328. { this is wrong for string or other complex
  329. result types !!! }
  330. if {ret_in_acc(aktprocdef.rettype.def) and }
  331. (is_ordinal(aktprocdef.rettype.def) or
  332. is_smallset(aktprocdef.rettype.def)) and
  333. assigned(hp.left) and
  334. assigned(tstatementnode(hp.left).right) and
  335. (tstatementnode(hp.left).right.nodetype=exitn) and
  336. (hp.right.nodetype=assignn) and
  337. { !!!! this tbinarynode should be tassignmentnode }
  338. (tbinarynode(hp.right).left.nodetype=funcretn) then
  339. begin
  340. if assigned(texitnode(tstatementnode(hp.left).right).left) then
  341. CGMessage(cg_n_inefficient_code)
  342. else
  343. begin
  344. texitnode(tstatementnode(hp.left).right).left:=tassignmentnode(hp.right).right;
  345. tassignmentnode(hp.right).right:=nil;
  346. hp.right.free;
  347. hp.right:=nil;
  348. end;
  349. end
  350. { warning if unreachable code occurs and elimate this }
  351. else if (hp.right.nodetype in
  352. [exitn,breakn,continuen,goton]) and
  353. { statement node (JM) }
  354. assigned(hp.left) and
  355. { kind of statement! (JM) }
  356. assigned(tstatementnode(hp.left).right) and
  357. (tstatementnode(hp.left).right.nodetype<>labeln) then
  358. begin
  359. { use correct line number }
  360. aktfilepos:=hp.left.fileinfo;
  361. hp.left.free;
  362. hp.left:=nil;
  363. CGMessage(cg_w_unreachable_code);
  364. { old lines }
  365. aktfilepos:=hp.right.fileinfo;
  366. end;
  367. end;
  368. if assigned(hp.right) then
  369. begin
  370. rg.cleartempgen;
  371. codegenerror:=false;
  372. firstpass(hp.right);
  373. hp.registers32:=hp.right.registers32;
  374. hp.registersfpu:=hp.right.registersfpu;
  375. {$ifdef SUPPORT_MMX}
  376. hp.registersmmx:=hp.right.registersmmx;
  377. {$endif SUPPORT_MMX}
  378. end
  379. else
  380. hp.registers32:=0;
  381. if hp.registers32>registers32 then
  382. registers32:=hp.registers32;
  383. if hp.registersfpu>registersfpu then
  384. registersfpu:=hp.registersfpu;
  385. {$ifdef SUPPORT_MMX}
  386. if hp.registersmmx>registersmmx then
  387. registersmmx:=hp.registersmmx;
  388. {$endif}
  389. location.loc:=hp.location.loc;
  390. inc(count);
  391. hp:=tstatementnode(hp.left);
  392. end;
  393. end;
  394. {$ifdef state_tracking}
  395. function Tblocknode.track_state_pass(exec_known:boolean):boolean;
  396. var hp:Tstatementnode;
  397. begin
  398. track_state_pass:=false;
  399. hp:=Tstatementnode(left);
  400. while assigned(hp) do
  401. begin
  402. if hp.right.track_state_pass(exec_known) then
  403. track_state_pass:=true;
  404. hp:=Tstatementnode(hp.left);
  405. end;
  406. end;
  407. {$endif state_tracking}
  408. {*****************************************************************************
  409. TASMNODE
  410. *****************************************************************************}
  411. constructor tasmnode.create(p : taasmoutput);
  412. begin
  413. inherited create(asmn);
  414. p_asm:=p;
  415. end;
  416. destructor tasmnode.destroy;
  417. begin
  418. if assigned(p_asm) then
  419. p_asm.free;
  420. inherited destroy;
  421. end;
  422. constructor tasmnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  423. var
  424. hp : tai;
  425. begin
  426. inherited ppuload(t,ppufile);
  427. p_asm:=taasmoutput.create;
  428. repeat
  429. hp:=ppuloadai(ppufile);
  430. if hp=nil then
  431. break;
  432. p_asm.concat(hp);
  433. until false;
  434. end;
  435. procedure tasmnode.ppuwrite(ppufile:tcompilerppufile);
  436. var
  437. hp : tai;
  438. begin
  439. inherited ppuwrite(ppufile);
  440. hp:=tai(p_asm.first);
  441. while assigned(hp) do
  442. begin
  443. ppuwriteai(ppufile,hp);
  444. hp:=tai(hp.next);
  445. end;
  446. { end is marked by a nil }
  447. ppuwriteai(ppufile,nil);
  448. end;
  449. procedure tasmnode.derefimpl;
  450. var
  451. hp : tai;
  452. begin
  453. inherited derefimpl;
  454. hp:=tai(p_asm.first);
  455. while assigned(hp) do
  456. begin
  457. hp.derefimpl;
  458. hp:=tai(hp.next);
  459. end;
  460. end;
  461. function tasmnode.getcopy: tnode;
  462. var
  463. n: tasmnode;
  464. begin
  465. n := tasmnode(inherited getcopy);
  466. if assigned(p_asm) then
  467. begin
  468. n.p_asm:=taasmoutput.create;
  469. n.p_asm.concatlistcopy(p_asm);
  470. end
  471. else n.p_asm := nil;
  472. getcopy := n;
  473. end;
  474. function tasmnode.det_resulttype:tnode;
  475. begin
  476. result:=nil;
  477. resulttype:=voidtype;
  478. end;
  479. function tasmnode.pass_1 : tnode;
  480. begin
  481. result:=nil;
  482. procinfo.flags:=procinfo.flags or pi_uses_asm;
  483. end;
  484. function tasmnode.docompare(p: tnode): boolean;
  485. begin
  486. { comparing of asmlists is not implemented (JM) }
  487. docompare := false;
  488. end;
  489. {*****************************************************************************
  490. TEMPCREATENODE
  491. *****************************************************************************}
  492. constructor ttempcreatenode.create(const _restype: ttype; _size: longint; _persistent: boolean);
  493. begin
  494. inherited create(tempcreaten);
  495. size := _size;
  496. new(tempinfo);
  497. fillchar(tempinfo^,sizeof(tempinfo^),0);
  498. tempinfo^.restype := _restype;
  499. persistent := _persistent;
  500. end;
  501. function ttempcreatenode.getcopy: tnode;
  502. var
  503. n: ttempcreatenode;
  504. begin
  505. n := ttempcreatenode(inherited getcopy);
  506. n.size := size;
  507. new(n.tempinfo);
  508. fillchar(n.tempinfo^,sizeof(n.tempinfo^),0);
  509. n.tempinfo^.restype := tempinfo^.restype;
  510. { signal the temprefs that the temp they point to has been copied, }
  511. { so that if the refs get copied as well, they can hook themselves }
  512. { to the copy of the temp }
  513. tempinfo^.hookoncopy := n.tempinfo;
  514. result := n;
  515. end;
  516. function ttempcreatenode.pass_1 : tnode;
  517. begin
  518. result := nil;
  519. end;
  520. function ttempcreatenode.det_resulttype: tnode;
  521. begin
  522. result := nil;
  523. { a tempcreatenode doesn't have a resulttype, only temprefnodes do }
  524. resulttype := voidtype;
  525. end;
  526. function ttempcreatenode.docompare(p: tnode): boolean;
  527. begin
  528. result :=
  529. inherited docompare(p) and
  530. (ttempcreatenode(p).size = size) and
  531. is_equal(ttempcreatenode(p).tempinfo^.restype.def,tempinfo^.restype.def);
  532. end;
  533. {*****************************************************************************
  534. TEMPREFNODE
  535. *****************************************************************************}
  536. constructor ttemprefnode.create(const temp: ttempcreatenode);
  537. begin
  538. inherited create(temprefn);
  539. tempinfo := temp.tempinfo;
  540. offset:=0;
  541. end;
  542. constructor ttemprefnode.create_offset(const temp: ttempcreatenode;aoffset:longint);
  543. begin
  544. self.create(temp);
  545. offset := aoffset;
  546. end;
  547. function ttemprefnode.getcopy: tnode;
  548. var
  549. n: ttemprefnode;
  550. begin
  551. n := ttemprefnode(inherited getcopy);
  552. if assigned(tempinfo^.hookoncopy) then
  553. { if the temp has been copied, assume it becomes a new }
  554. { temp which has to be hooked by the copied reference }
  555. begin
  556. { hook the ref to the copied temp }
  557. n.tempinfo := tempinfo^.hookoncopy;
  558. end
  559. else
  560. { if the temp we refer to hasn't been copied, assume }
  561. { we're just a new reference to that temp }
  562. begin
  563. n.tempinfo := tempinfo;
  564. end;
  565. result := n;
  566. end;
  567. function ttemprefnode.pass_1 : tnode;
  568. begin
  569. location.loc:=LOC_REFERENCE;
  570. result := nil;
  571. end;
  572. function ttemprefnode.det_resulttype: tnode;
  573. begin
  574. { check if the temp is already resulttype passed }
  575. if not assigned(tempinfo^.restype.def) then
  576. internalerror(200108233);
  577. result := nil;
  578. resulttype := tempinfo^.restype;
  579. end;
  580. function ttemprefnode.docompare(p: tnode): boolean;
  581. begin
  582. result :=
  583. inherited docompare(p) and
  584. (ttemprefnode(p).tempinfo = tempinfo);
  585. end;
  586. {$ifdef var_notification}
  587. procedure Ttemprefnode.mark_write;
  588. begin
  589. writeaccess:=true;
  590. end;
  591. {$endif}
  592. {*****************************************************************************
  593. TEMPDELETENODE
  594. *****************************************************************************}
  595. constructor ttempdeletenode.create(const temp: ttempcreatenode);
  596. begin
  597. inherited create(temprefn);
  598. tempinfo := temp.tempinfo;
  599. release_to_normal := false;
  600. if not temp.persistent then
  601. internalerror(200204211);
  602. end;
  603. constructor ttempdeletenode.create_normal_temp(const temp: ttempcreatenode);
  604. begin
  605. inherited create(tempdeleten);
  606. tempinfo := temp.tempinfo;
  607. release_to_normal := true;
  608. end;
  609. function ttempdeletenode.getcopy: tnode;
  610. var
  611. n: ttempdeletenode;
  612. begin
  613. n := ttempdeletenode(inherited getcopy);
  614. if assigned(tempinfo^.hookoncopy) then
  615. { if the temp has been copied, assume it becomes a new }
  616. { temp which has to be hooked by the copied deletenode }
  617. begin
  618. { hook the tempdeletenode to the copied temp }
  619. n.tempinfo := tempinfo^.hookoncopy;
  620. end
  621. else
  622. { if the temp we refer to hasn't been copied, we have a }
  623. { problem since that means we now have two delete nodes }
  624. { for one temp }
  625. internalerror(200108234);
  626. result := n;
  627. end;
  628. function ttempdeletenode.pass_1 : tnode;
  629. begin
  630. result := nil;
  631. end;
  632. function ttempdeletenode.det_resulttype: tnode;
  633. begin
  634. result := nil;
  635. resulttype := voidtype;
  636. end;
  637. function ttempdeletenode.docompare(p: tnode): boolean;
  638. begin
  639. result :=
  640. inherited docompare(p) and
  641. (ttemprefnode(p).tempinfo = tempinfo);
  642. end;
  643. destructor ttempdeletenode.destroy;
  644. begin
  645. dispose(tempinfo);
  646. end;
  647. begin
  648. cnothingnode:=tnothingnode;
  649. cerrornode:=terrornode;
  650. casmnode:=tasmnode;
  651. cstatementnode:=tstatementnode;
  652. cblocknode:=tblocknode;
  653. ctempcreatenode:=ttempcreatenode;
  654. ctemprefnode:=ttemprefnode;
  655. ctempdeletenode:=ttempdeletenode;
  656. end.
  657. {
  658. $Log$
  659. Revision 1.35 2002-09-01 08:01:16 daniel
  660. * Removed sets from Tcallnode.det_resulttype
  661. + Added read/write notifications of variables. These will be usefull
  662. for providing information for several optimizations. For example
  663. the value of the loop variable of a for loop does matter is the
  664. variable is read after the for loop, but if it's no longer used
  665. or written, it doesn't matter and this can be used to optimize
  666. the loop code generation.
  667. Revision 1.34 2002/08/18 20:06:23 peter
  668. * inlining is now also allowed in interface
  669. * renamed write/load to ppuwrite/ppuload
  670. * tnode storing in ppu
  671. * nld,ncon,nbas are already updated for storing in ppu
  672. Revision 1.33 2002/08/17 22:09:44 florian
  673. * result type handling in tcgcal.pass_2 overhauled
  674. * better tnode.dowrite
  675. * some ppc stuff fixed
  676. Revision 1.32 2002/08/17 09:23:34 florian
  677. * first part of procinfo rewrite
  678. Revision 1.31 2002/08/15 19:10:35 peter
  679. * first things tai,tnode storing in ppu
  680. Revision 1.30 2002/07/20 11:57:53 florian
  681. * types.pas renamed to defbase.pas because D6 contains a types
  682. unit so this would conflicts if D6 programms are compiled
  683. + Willamette/SSE2 instructions to assembler added
  684. Revision 1.29 2002/07/19 11:41:35 daniel
  685. * State tracker work
  686. * The whilen and repeatn are now completely unified into whilerepeatn. This
  687. allows the state tracker to change while nodes automatically into
  688. repeat nodes.
  689. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  690. 'not(a>b)' is optimized into 'a<=b'.
  691. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  692. by removing the notn and later switchting the true and falselabels. The
  693. same is done with 'repeat until not a'.
  694. Revision 1.28 2002/07/14 18:00:43 daniel
  695. + Added the beginning of a state tracker. This will track the values of
  696. variables through procedures and optimize things away.
  697. Revision 1.27 2002/07/01 18:46:22 peter
  698. * internal linker
  699. * reorganized aasm layer
  700. Revision 1.26 2002/06/24 12:43:00 jonas
  701. * fixed errors found with new -CR code from Peter when cycling with -O2p3r
  702. Revision 1.25 2002/05/18 13:34:09 peter
  703. * readded missing revisions
  704. Revision 1.24 2002/05/16 19:46:37 carl
  705. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  706. + try to fix temp allocation (still in ifdef)
  707. + generic constructor calls
  708. + start of tassembler / tmodulebase class cleanup
  709. Revision 1.22 2002/04/23 19:16:34 peter
  710. * add pinline unit that inserts compiler supported functions using
  711. one or more statements
  712. * moved finalize and setlength from ninl to pinline
  713. Revision 1.21 2002/04/21 19:02:03 peter
  714. * removed newn and disposen nodes, the code is now directly
  715. inlined from pexpr
  716. * -an option that will write the secondpass nodes to the .s file, this
  717. requires EXTDEBUG define to actually write the info
  718. * fixed various internal errors and crashes due recent code changes
  719. Revision 1.20 2002/04/04 19:05:57 peter
  720. * removed unused units
  721. * use tlocation.size in cg.a_*loc*() routines
  722. Revision 1.19 2002/03/31 20:26:33 jonas
  723. + a_loadfpu_* and a_loadmm_* methods in tcg
  724. * register allocation is now handled by a class and is mostly processor
  725. independent (+rgobj.pas and i386/rgcpu.pas)
  726. * temp allocation is now handled by a class (+tgobj.pas, -i386\tgcpu.pas)
  727. * some small improvements and fixes to the optimizer
  728. * some register allocation fixes
  729. * some fpuvaroffset fixes in the unary minus node
  730. * push/popusedregisters is now called rg.save/restoreusedregisters and
  731. (for i386) uses temps instead of push/pop's when using -Op3 (that code is
  732. also better optimizable)
  733. * fixed and optimized register saving/restoring for new/dispose nodes
  734. * LOC_FPU locations now also require their "register" field to be set to
  735. R_ST, not R_ST0 (the latter is used for LOC_CFPUREGISTER locations only)
  736. - list field removed of the tnode class because it's not used currently
  737. and can cause hard-to-find bugs
  738. }