node.pas 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917
  1. {
  2. $Id$
  3. Copyright (c) 2000 by Florian Klaempfl
  4. Basic node handling
  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 node;
  19. {$i defines.inc}
  20. interface
  21. uses
  22. cclasses,
  23. globtype,globals,
  24. cpubase,
  25. aasm,
  26. symtype;
  27. type
  28. pconstset = ^tconstset;
  29. tconstset = array[0..31] of byte;
  30. pconst32bitset = ^tconst32bitset;
  31. tconst32bitset = array[0..7] of longint;
  32. tnodetype = (
  33. addn, {Represents the + operator.}
  34. muln, {Represents the * operator.}
  35. subn, {Represents the - operator.}
  36. divn, {Represents the div operator.}
  37. symdifn, {Represents the >< operator.}
  38. modn, {Represents the mod operator.}
  39. assignn, {Represents an assignment.}
  40. loadn, {Represents the use of a variabele.}
  41. rangen, {Represents a range (i.e. 0..9).}
  42. ltn, {Represents the < operator.}
  43. lten, {Represents the <= operator.}
  44. gtn, {Represents the > operator.}
  45. gten, {Represents the >= operator.}
  46. equaln, {Represents the = operator.}
  47. unequaln, {Represents the <> operator.}
  48. inn, {Represents the in operator.}
  49. orn, {Represents the or operator.}
  50. xorn, {Represents the xor operator.}
  51. shrn, {Represents the shr operator.}
  52. shln, {Represents the shl operator.}
  53. slashn, {Represents the / operator.}
  54. andn, {Represents the and operator.}
  55. subscriptn, {??? Field in a record/object?}
  56. derefn, {Dereferences a pointer.}
  57. addrn, {Represents the @ operator.}
  58. doubleaddrn, {Represents the @@ operator.}
  59. ordconstn, {Represents an ordinal value.}
  60. typeconvn, {Represents type-conversion/typecast.}
  61. calln, {Represents a call node.}
  62. callparan, {Represents a parameter.}
  63. realconstn, {Represents a real value.}
  64. unaryminusn, {Represents a sign change (i.e. -2).}
  65. asmn, {Represents an assembler node }
  66. vecn, {Represents array indexing.}
  67. pointerconstn,
  68. stringconstn, {Represents a string constant.}
  69. funcretn, {Represents the function result var.}
  70. selfn, {Represents the self parameter.}
  71. notn, {Represents the not operator.}
  72. inlinen, {Internal procedures (i.e. writeln).}
  73. niln, {Represents the nil pointer.}
  74. errorn, {This part of the tree could not be
  75. parsed because of a compiler error.}
  76. typen, {A type name. Used for i.e. typeof(obj).}
  77. hnewn, {The new operation, constructor call.}
  78. hdisposen, {The dispose operation with destructor call.}
  79. newn, {The new operation, constructor call.}
  80. simpledisposen, {The dispose operation.}
  81. setelementn, {A set element(s) (i.e. [a,b] and also [a..b]).}
  82. setconstn, {A set constant (i.e. [1,2]).}
  83. blockn, {A block of statements.}
  84. statementn, {One statement in a block of nodes.}
  85. loopn, { used in genloopnode, must be converted }
  86. ifn, {An if statement.}
  87. breakn, {A break statement.}
  88. continuen, {A continue statement.}
  89. repeatn, {A repeat until block.}
  90. whilen, {A while do statement.}
  91. forn, {A for loop.}
  92. exitn, {An exit statement.}
  93. withn, {A with statement.}
  94. casen, {A case statement.}
  95. labeln, {A label.}
  96. goton, {A goto statement.}
  97. simplenewn, {The new operation.}
  98. tryexceptn, {A try except block.}
  99. raisen, {A raise statement.}
  100. switchesn, {??? Currently unused...}
  101. tryfinallyn, {A try finally statement.}
  102. onn, { for an on statement in exception code }
  103. isn, {Represents the is operator.}
  104. asn, {Represents the as typecast.}
  105. caretn, {Represents the ^ operator.}
  106. failn, {Represents the fail statement.}
  107. starstarn, {Represents the ** operator exponentiation }
  108. procinlinen, {Procedures that can be inlined }
  109. arrayconstructorn, {Construction node for [...] parsing}
  110. arrayconstructorrangen, {Range element to allow sets in array construction tree}
  111. tempn, { for temps in the result/firstpass }
  112. temprefn, { references to temps }
  113. { added for optimizations where we cannot suppress }
  114. addoptn,
  115. nothingn,
  116. loadvmtn,
  117. guidconstn,
  118. rttin { rtti information so they can be accessed in result/firstpass }
  119. );
  120. const
  121. nodetype2str : array[tnodetype] of string[20] = (
  122. 'addn',
  123. 'muln',
  124. 'subn',
  125. 'divn',
  126. 'symdifn',
  127. 'modn',
  128. 'assignn',
  129. 'loadn',
  130. 'rangen',
  131. 'ltn',
  132. 'lten',
  133. 'gtn',
  134. 'gten',
  135. 'equaln',
  136. 'unequaln',
  137. 'inn',
  138. 'orn',
  139. 'xorn',
  140. 'shrn',
  141. 'shln',
  142. 'slashn',
  143. 'andn',
  144. 'subscriptn',
  145. 'derefn',
  146. 'addrn',
  147. 'doubleaddrn',
  148. 'ordconstn',
  149. 'typeconvn',
  150. 'calln',
  151. 'callparan',
  152. 'realconstn',
  153. 'umminusn',
  154. 'asmn',
  155. 'vecn',
  156. 'pointerconstn',
  157. 'stringconstn',
  158. 'funcretn',
  159. 'selfn',
  160. 'notn',
  161. 'inlinen',
  162. 'niln',
  163. 'errorn',
  164. 'typen',
  165. 'hnewn',
  166. 'hdisposen',
  167. 'newn',
  168. 'simpledisposen',
  169. 'setelementn',
  170. 'setconstn',
  171. 'blockn',
  172. 'statementn',
  173. 'loopn',
  174. 'ifn',
  175. 'breakn',
  176. 'continuen',
  177. 'repeatn',
  178. 'whilen',
  179. 'forn',
  180. 'exitn',
  181. 'withn',
  182. 'casen',
  183. 'labeln',
  184. 'goton',
  185. 'simplenewn',
  186. 'tryexceptn',
  187. 'raisen',
  188. 'switchesn',
  189. 'tryfinallyn',
  190. 'onn',
  191. 'isn',
  192. 'asn',
  193. 'caretn',
  194. 'failn',
  195. 'starstarn',
  196. 'procinlinen',
  197. 'arrayconstructn',
  198. 'arrayconstructrangen',
  199. 'tempn',
  200. 'temprefn',
  201. 'addoptn',
  202. 'nothingn',
  203. 'loadvmtn',
  204. 'guidconstn',
  205. 'rttin');
  206. type
  207. { all boolean field of ttree are now collected in flags }
  208. tnodeflags = (
  209. nf_needs_truefalselabel,
  210. nf_swapable, { tbinop operands can be swaped }
  211. nf_swaped, { tbinop operands are swaped }
  212. nf_error,
  213. { flags used by tcallnode }
  214. nf_return_value_used,
  215. nf_static_call,
  216. { flags used by tcallparanode }
  217. nf_varargs_para, { belongs this para to varargs }
  218. { flags used by loop nodes }
  219. nf_backward, { set if it is a for ... downto ... do loop }
  220. nf_varstate, { do we need to parse childs to set var state }
  221. { taddrnode }
  222. nf_procvarload,
  223. { tvecnode }
  224. nf_memindex,
  225. nf_memseg,
  226. nf_callunique,
  227. { twithnode }
  228. nf_islocal,
  229. { tloadnode }
  230. nf_absolute,
  231. nf_first,
  232. { tassignmentnode }
  233. nf_concat_string,
  234. { tfuncretnode }
  235. nf_is_first_funcret, { 20th }
  236. { tarrayconstructnode }
  237. nf_cargs,
  238. nf_cargswap,
  239. nf_forcevaria,
  240. nf_novariaallowed,
  241. { ttypeconvnode }
  242. nf_explizit,
  243. { tinlinenode }
  244. nf_inlineconst,
  245. { general }
  246. nf_isproperty,
  247. nf_varstateset,
  248. { tasmnode }
  249. nf_object_preserved,
  250. { taddnode }
  251. nf_use_strconcat
  252. );
  253. tnodeflagset = set of tnodeflags;
  254. const
  255. { contains the flags which must be equal for the equality }
  256. { of nodes }
  257. flagsequal : tnodeflagset = [nf_error,nf_static_call,nf_backward];
  258. type
  259. tnodelist = class
  260. end;
  261. { later (for the newcg) tnode will inherit from tlinkedlist_item }
  262. tnode = class
  263. public
  264. { type of this node }
  265. nodetype : tnodetype;
  266. { type of the current code block, general/const/type }
  267. blocktype : tblock_type;
  268. { the location of the result of this node }
  269. location : tlocation;
  270. { the parent node of this is node }
  271. { this field is set by concattolist }
  272. parent : tnode;
  273. { there are some properties about the node stored }
  274. flags : tnodeflagset;
  275. { the number of registers needed to evalute the node }
  276. registers32,registersfpu : longint; { must be longint !!!! }
  277. {$ifdef SUPPORT_MMX}
  278. registersmmx,registerskni : longint;
  279. {$endif SUPPORT_MMX}
  280. resulttype : ttype;
  281. fileinfo : tfileposinfo;
  282. localswitches : tlocalswitches;
  283. {$ifdef extdebug}
  284. maxfirstpasscount,
  285. firstpasscount : longint;
  286. {$endif extdebug}
  287. {$ifdef TEMPS_NOT_PUSH}
  288. temp_offset: longint;
  289. {$endif TEMPS_NOT_PUSH}
  290. { list : taasmoutput; }
  291. constructor create(tt : tnodetype);
  292. { this constructor is only for creating copies of class }
  293. { the fields are copied by getcopy }
  294. constructor createforcopy;
  295. destructor destroy;override;
  296. { toggles the flag }
  297. procedure toggleflag(f : tnodeflags);
  298. { the 1.1 code generator may override pass_1 }
  299. { and it need not to implement det_* then }
  300. { 1.1: pass_1 returns a value<>0 if the node has been transformed }
  301. { 2.0: runs det_resulttype and det_temp }
  302. function pass_1 : tnode;virtual;abstract;
  303. { dermines the resulttype of the node }
  304. function det_resulttype : tnode;virtual;abstract;
  305. { dermines the number of necessary temp. locations to evaluate
  306. the node }
  307. procedure det_temp;virtual;abstract;
  308. procedure pass_2;virtual;abstract;
  309. { comparing of nodes }
  310. function isequal(p : tnode) : boolean;
  311. { to implement comparisation, override this method }
  312. function docompare(p : tnode) : boolean;virtual;
  313. { gets a copy of the node }
  314. function getcopy : tnode;virtual;
  315. procedure insertintolist(l : tnodelist);virtual;
  316. {$ifdef EXTDEBUG}
  317. { writes a node for debugging purpose, shouldn't be called }
  318. { direct, because there is no test for nil, use writenode }
  319. { to write a complete tree }
  320. procedure dowrite;virtual;
  321. procedure dowritenodetype;virtual;
  322. {$endif EXTDEBUG}
  323. procedure concattolist(l : tlinkedlist);virtual;
  324. function ischild(p : tnode) : boolean;virtual;
  325. procedure set_file_line(from : tnode);
  326. procedure set_tree_filepos(const filepos : tfileposinfo);
  327. end;
  328. { this node is the anchestor for all nodes with at least }
  329. { one child, you have to use it if you want to use }
  330. { true- and falselabel }
  331. tparentnode = class(tnode)
  332. {$ifdef newcg}
  333. falselabel,truelabel : tasmlabel;
  334. {$endif newcg}
  335. end;
  336. tnodeclass = class of tnode;
  337. punarynode = ^tunarynode;
  338. tunarynode = class(tparentnode)
  339. left : tnode;
  340. constructor create(tt : tnodetype;l : tnode);
  341. destructor destroy;override;
  342. procedure concattolist(l : tlinkedlist);override;
  343. function ischild(p : tnode) : boolean;override;
  344. function docompare(p : tnode) : boolean;override;
  345. function getcopy : tnode;override;
  346. procedure insertintolist(l : tnodelist);override;
  347. procedure left_max;
  348. {$ifdef extdebug}
  349. procedure dowrite;override;
  350. {$endif extdebug}
  351. end;
  352. pbinarynode = ^tbinarynode;
  353. tbinarynode = class(tunarynode)
  354. right : tnode;
  355. constructor create(tt : tnodetype;l,r : tnode);
  356. destructor destroy;override;
  357. procedure concattolist(l : tlinkedlist);override;
  358. function ischild(p : tnode) : boolean;override;
  359. function docompare(p : tnode) : boolean;override;
  360. procedure swapleftright;
  361. function getcopy : tnode;override;
  362. procedure insertintolist(l : tnodelist);override;
  363. procedure left_right_max;
  364. {$ifdef extdebug}
  365. procedure dowrite;override;
  366. {$endif extdebug}
  367. end;
  368. pbinopnode = ^tbinopnode;
  369. tbinopnode = class(tbinarynode)
  370. constructor create(tt : tnodetype;l,r : tnode);virtual;
  371. function docompare(p : tnode) : boolean;override;
  372. end;
  373. {$ifdef EXTDEBUG}
  374. var
  375. writenodeindention : string;
  376. procedure writenode(t:tnode);
  377. {$endif EXTDEBUG}
  378. {$ifdef tempregdebug}
  379. type
  380. pptree = ^tnode;
  381. var
  382. curptree: pptree;
  383. {$endif tempregdebug}
  384. implementation
  385. uses
  386. cutils;
  387. {****************************************************************************
  388. TNODE
  389. ****************************************************************************}
  390. constructor tnode.create(tt : tnodetype);
  391. begin
  392. inherited create;
  393. nodetype:=tt;
  394. blocktype:=block_type;
  395. { this allows easier error tracing }
  396. location.loc:=LOC_INVALID;
  397. { save local info }
  398. fileinfo:=aktfilepos;
  399. localswitches:=aktlocalswitches;
  400. resulttype.reset;
  401. registers32:=0;
  402. registersfpu:=0;
  403. {$ifdef SUPPORT_MMX}
  404. registersmmx:=0;
  405. {$endif SUPPORT_MMX}
  406. {$ifdef EXTDEBUG}
  407. maxfirstpasscount:=0;
  408. firstpasscount:=0;
  409. {$endif EXTDEBUG}
  410. flags:=[];
  411. end;
  412. constructor tnode.createforcopy;
  413. begin
  414. end;
  415. procedure tnode.toggleflag(f : tnodeflags);
  416. begin
  417. if f in flags then
  418. exclude(flags,f)
  419. else
  420. include(flags,f);
  421. end;
  422. destructor tnode.destroy;
  423. begin
  424. {$ifdef EXTDEBUG}
  425. if firstpasscount>maxfirstpasscount then
  426. maxfirstpasscount:=firstpasscount;
  427. {$endif EXTDEBUG}
  428. end;
  429. procedure tnode.concattolist(l : tlinkedlist);
  430. begin
  431. {$ifdef newcg}
  432. //!!!!!!! l^.concat(self);
  433. {$warning fixme}
  434. {$endif newcg}
  435. end;
  436. function tnode.ischild(p : tnode) : boolean;
  437. begin
  438. ischild:=false;
  439. end;
  440. {$ifdef EXTDEBUG}
  441. procedure tnode.dowrite;
  442. begin
  443. dowritenodetype;
  444. end;
  445. procedure tnode.dowritenodetype;
  446. begin
  447. write(writenodeindention,'(',nodetype2str[nodetype]);
  448. end;
  449. {$endif EXTDEBUG}
  450. function tnode.isequal(p : tnode) : boolean;
  451. begin
  452. isequal:=
  453. (not assigned(self) and not assigned(p)) or
  454. (assigned(self) and assigned(p) and
  455. { optimized subclasses have the same nodetype as their }
  456. { superclass (for compatibility), so also check the classtype (JM) }
  457. (p.classtype=classtype) and
  458. (p.nodetype=nodetype) and
  459. (flags*flagsequal=p.flags*flagsequal) and
  460. docompare(p));
  461. end;
  462. function tnode.docompare(p : tnode) : boolean;
  463. begin
  464. docompare:=true;
  465. end;
  466. function tnode.getcopy : tnode;
  467. var
  468. p : tnode;
  469. begin
  470. { this is quite tricky because we need a node of the current }
  471. { node type and not one of tnode! }
  472. p:=tnodeclass(classtype).createforcopy;
  473. p.nodetype:=nodetype;
  474. p.location:=location;
  475. p.parent:=parent;
  476. p.flags:=flags;
  477. p.registers32:=registers32;
  478. p.registersfpu:=registersfpu;
  479. {$ifdef SUPPORT_MMX}
  480. p.registersmmx:=registersmmx;
  481. p.registerskni:=registerskni;
  482. {$endif SUPPORT_MMX}
  483. p.resulttype:=resulttype;
  484. p.fileinfo:=fileinfo;
  485. p.localswitches:=localswitches;
  486. {$ifdef extdebug}
  487. p.firstpasscount:=firstpasscount;
  488. {$endif extdebug}
  489. { p.list:=list; }
  490. getcopy:=p;
  491. end;
  492. procedure tnode.insertintolist(l : tnodelist);
  493. begin
  494. end;
  495. procedure tnode.set_file_line(from : tnode);
  496. begin
  497. if assigned(from) then
  498. fileinfo:=from.fileinfo;
  499. end;
  500. procedure tnode.set_tree_filepos(const filepos : tfileposinfo);
  501. begin
  502. fileinfo:=filepos;
  503. end;
  504. {****************************************************************************
  505. TUNARYNODE
  506. ****************************************************************************}
  507. constructor tunarynode.create(tt : tnodetype;l : tnode);
  508. begin
  509. inherited create(tt);
  510. left:=l;
  511. end;
  512. destructor tunarynode.destroy;
  513. begin
  514. left.free;
  515. inherited destroy;
  516. end;
  517. function tunarynode.docompare(p : tnode) : boolean;
  518. begin
  519. docompare:=(inherited docompare(p) and
  520. ((left=nil) or left.isequal(tunarynode(p).left))
  521. );
  522. end;
  523. function tunarynode.getcopy : tnode;
  524. var
  525. p : tunarynode;
  526. begin
  527. p:=tunarynode(inherited getcopy);
  528. if assigned(left) then
  529. p.left:=left.getcopy
  530. else
  531. p.left:=nil;
  532. getcopy:=p;
  533. end;
  534. procedure tunarynode.insertintolist(l : tnodelist);
  535. begin
  536. end;
  537. {$ifdef extdebug}
  538. procedure tunarynode.dowrite;
  539. begin
  540. inherited dowrite;
  541. writeln(',');
  542. writenodeindention:=writenodeindention+' ';
  543. writenode(left);
  544. write(')');
  545. delete(writenodeindention,1,4);
  546. end;
  547. {$endif}
  548. procedure tunarynode.left_max;
  549. begin
  550. registers32:=left.registers32;
  551. registersfpu:=left.registersfpu;
  552. {$ifdef SUPPORT_MMX}
  553. registersmmx:=left.registersmmx;
  554. {$endif SUPPORT_MMX}
  555. end;
  556. procedure tunarynode.concattolist(l : tlinkedlist);
  557. begin
  558. left.parent:=self;
  559. left.concattolist(l);
  560. inherited concattolist(l);
  561. end;
  562. function tunarynode.ischild(p : tnode) : boolean;
  563. begin
  564. ischild:=p=left;
  565. end;
  566. {****************************************************************************
  567. TBINARYNODE
  568. ****************************************************************************}
  569. constructor tbinarynode.create(tt : tnodetype;l,r : tnode);
  570. begin
  571. inherited create(tt,l);
  572. right:=r
  573. end;
  574. destructor tbinarynode.destroy;
  575. begin
  576. right.free;
  577. inherited destroy;
  578. end;
  579. procedure tbinarynode.concattolist(l : tlinkedlist);
  580. begin
  581. { we could change that depending on the number of }
  582. { required registers }
  583. left.parent:=self;
  584. left.concattolist(l);
  585. left.parent:=self;
  586. left.concattolist(l);
  587. inherited concattolist(l);
  588. end;
  589. function tbinarynode.ischild(p : tnode) : boolean;
  590. begin
  591. ischild:=(p=right);
  592. end;
  593. function tbinarynode.docompare(p : tnode) : boolean;
  594. begin
  595. docompare:=(inherited docompare(p) and
  596. ((right=nil) or right.isequal(tbinarynode(p).right))
  597. );
  598. end;
  599. function tbinarynode.getcopy : tnode;
  600. var
  601. p : tbinarynode;
  602. begin
  603. p:=tbinarynode(inherited getcopy);
  604. if assigned(right) then
  605. p.right:=right.getcopy
  606. else
  607. p.right:=nil;
  608. getcopy:=p;
  609. end;
  610. procedure tbinarynode.insertintolist(l : tnodelist);
  611. begin
  612. end;
  613. procedure tbinarynode.swapleftright;
  614. var
  615. swapp : tnode;
  616. begin
  617. swapp:=right;
  618. right:=left;
  619. left:=swapp;
  620. if nf_swaped in flags then
  621. exclude(flags,nf_swaped)
  622. else
  623. include(flags,nf_swaped);
  624. end;
  625. procedure tbinarynode.left_right_max;
  626. begin
  627. if assigned(left) then
  628. begin
  629. if assigned(right) then
  630. begin
  631. registers32:=max(left.registers32,right.registers32);
  632. registersfpu:=max(left.registersfpu,right.registersfpu);
  633. {$ifdef SUPPORT_MMX}
  634. registersmmx:=max(left.registersmmx,right.registersmmx);
  635. {$endif SUPPORT_MMX}
  636. end
  637. else
  638. begin
  639. registers32:=left.registers32;
  640. registersfpu:=left.registersfpu;
  641. {$ifdef SUPPORT_MMX}
  642. registersmmx:=left.registersmmx;
  643. {$endif SUPPORT_MMX}
  644. end;
  645. end;
  646. end;
  647. {$ifdef extdebug}
  648. procedure tbinarynode.dowrite;
  649. begin
  650. inherited dowrite;
  651. writeln(',');
  652. writenodeindention:=writenodeindention+' ';
  653. writenode(right);
  654. write(')');
  655. delete(writenodeindention,1,4);
  656. end;
  657. {$endif}
  658. {****************************************************************************
  659. TBINOPYNODE
  660. ****************************************************************************}
  661. constructor tbinopnode.create(tt : tnodetype;l,r : tnode);
  662. begin
  663. inherited create(tt,l,r);
  664. end;
  665. function tbinopnode.docompare(p : tnode) : boolean;
  666. begin
  667. docompare:=(inherited docompare(p)) or
  668. { if that's in the flags, is p then always a tbinopnode (?) (JM) }
  669. ((nf_swapable in flags) and
  670. left.isequal(tbinopnode(p).right) and
  671. right.isequal(tbinopnode(p).left));
  672. end;
  673. {****************************************************************************
  674. WRITENODE
  675. ****************************************************************************}
  676. {$ifdef EXTDEBUG}
  677. procedure writenode(t:tnode);
  678. begin
  679. if assigned(t) then
  680. t.dowrite
  681. else
  682. write(writenodeindention,'nil');
  683. if writenodeindention='' then
  684. writeln;
  685. end;
  686. {$endif EXTDEBUG}
  687. end.
  688. {
  689. $Log$
  690. Revision 1.23 2002-04-06 18:13:01 jonas
  691. * several powerpc-related additions and fixes
  692. Revision 1.22 2002/03/31 20:26:35 jonas
  693. + a_loadfpu_* and a_loadmm_* methods in tcg
  694. * register allocation is now handled by a class and is mostly processor
  695. independent (+rgobj.pas and i386/rgcpu.pas)
  696. * temp allocation is now handled by a class (+tgobj.pas, -i386\tgcpu.pas)
  697. * some small improvements and fixes to the optimizer
  698. * some register allocation fixes
  699. * some fpuvaroffset fixes in the unary minus node
  700. * push/popusedregisters is now called rg.save/restoreusedregisters and
  701. (for i386) uses temps instead of push/pop's when using -Op3 (that code is
  702. also better optimizable)
  703. * fixed and optimized register saving/restoring for new/dispose nodes
  704. * LOC_FPU locations now also require their "register" field to be set to
  705. R_ST, not R_ST0 (the latter is used for LOC_CFPUREGISTER locations only)
  706. - list field removed of the tnode class because it's not used currently
  707. and can cause hard-to-find bugs
  708. Revision 1.21 2002/01/19 11:52:32 peter
  709. * dynarr:=nil support added
  710. Revision 1.20 2001/10/20 19:28:38 peter
  711. * interface 2 guid support
  712. * guid constants support
  713. Revision 1.19 2001/08/23 14:28:36 jonas
  714. + tempcreate/ref/delete nodes (allows the use of temps in the
  715. resulttype and first pass)
  716. * made handling of read(ln)/write(ln) processor independent
  717. * moved processor independent handling for str and reset/rewrite-typed
  718. from firstpass to resulttype pass
  719. * changed names of helpers in text.inc to be generic for use as
  720. compilerprocs + added "iocheck" directive for most of them
  721. * reading of ordinals is done by procedures instead of functions
  722. because otherwise FPC_IOCHECK overwrote the result before it could
  723. be stored elsewhere (range checking still works)
  724. * compilerprocs can now be used in the system unit before they are
  725. implemented
  726. * added note to errore.msg that booleans can't be read using read/readln
  727. Revision 1.18 2001/07/30 20:59:27 peter
  728. * m68k updates from v10 merged
  729. Revision 1.17 2001/06/04 18:14:16 peter
  730. * store blocktype info in tnode
  731. Revision 1.16 2001/06/04 11:53:13 peter
  732. + varargs directive
  733. Revision 1.15 2001/04/13 01:22:10 peter
  734. * symtable change to classes
  735. * range check generation and errors fixed, make cycle DEBUG=1 works
  736. * memory leaks fixed
  737. Revision 1.14 2001/04/02 21:20:31 peter
  738. * resulttype rewrite
  739. Revision 1.13 2001/01/13 00:08:09 peter
  740. * added missing addoptn
  741. Revision 1.12 2001/01/01 11:38:45 peter
  742. * forgot to remove node.inc and nodeh.inc that were merged into node.pas
  743. already.
  744. Revision 1.11 2000/12/25 00:07:26 peter
  745. + new tlinkedlist class (merge of old tstringqueue,tcontainer and
  746. tlinkedlist objects)
  747. Revision 1.10 2000/11/29 00:30:34 florian
  748. * unused units removed from uses clause
  749. * some changes for widestrings
  750. Revision 1.9 2000/10/31 22:02:49 peter
  751. * symtable splitted, no real code changes
  752. Revision 1.8 2000/10/01 19:48:24 peter
  753. * lot of compile updates for cg11
  754. Revision 1.7 2000/09/30 16:08:45 peter
  755. * more cg11 updates
  756. Revision 1.6 2000/09/28 19:49:52 florian
  757. *** empty log message ***
  758. Revision 1.5 2000/09/27 18:14:31 florian
  759. * fixed a lot of syntax errors in the n*.pas stuff
  760. Revision 1.4 2000/09/24 15:06:19 peter
  761. * use defines.inc
  762. Revision 1.3 2000/09/22 21:45:35 florian
  763. * some updates e.g. getcopy added
  764. Revision 1.2 2000/09/20 21:52:38 florian
  765. * removed a lot of errors
  766. Revision 1.1 2000/08/26 12:27:35 florian
  767. * initial release
  768. }