tgobj.pas 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit implements the base object for temp. generator
  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. {#@abstract(Temporary reference allocator unit)
  19. Temporary reference allocator unit. This unit contains
  20. all which is related to allocating temporary memory
  21. space on the stack, as required, by the code generator.
  22. }
  23. unit tgobj;
  24. {$i defines.inc}
  25. interface
  26. uses
  27. globals,
  28. cpubase,
  29. cpuinfo,
  30. cpuasm,
  31. tainst,
  32. cclasses,globtype,cgbase,aasm;
  33. type
  34. ttemptype = (tt_none,tt_free,tt_normal,tt_persistant,
  35. tt_ansistring,tt_freeansistring,tt_widestring,tt_freewidestring,
  36. tt_interfacecom,tt_freeinterfacecom);
  37. ttemptypeset = set of ttemptype;
  38. ptemprecord = ^ttemprecord;
  39. ttemprecord = record
  40. temptype : ttemptype;
  41. pos : longint;
  42. size : longint;
  43. next : ptemprecord;
  44. nextfree : ptemprecord; { for faster freeblock checking }
  45. {$ifdef EXTDEBUG}
  46. posinfo,
  47. releaseposinfo : tfileposinfo;
  48. {$endif}
  49. end;
  50. {# Generates temporary variables }
  51. ttgobj = class
  52. { contains all temps }
  53. templist : ptemprecord;
  54. { contains all free temps using nextfree links }
  55. tempfreelist : ptemprecord;
  56. { Offsets of the first/last temp }
  57. firsttemp,
  58. lasttemp : longint;
  59. lasttempofsize : ptemprecord;
  60. { tries to hold the amount of times which the current tree is processed }
  61. t_times: longint;
  62. constructor create;
  63. {# Clear and free the complete linked list of temporary memory
  64. locations. The list is set to nil.}
  65. procedure resettempgen;
  66. {# Sets the first offset from the frame pointer or stack pointer where
  67. the temporary references will be allocated. It is to note that this
  68. value should always be negative.
  69. @param(l start offset where temps will start in stack)
  70. }
  71. procedure setfirsttemp(l : longint);
  72. function gettempsize : longint;
  73. { special call for inlined procedures }
  74. function gettempofsizepersistant(list: taasmoutput; size : longint) : longint;
  75. procedure gettempofsizereferencepersistant(list: taasmoutput; l : longint;var ref : treference);
  76. procedure gettemppointerreferencefortype(list: taasmoutput; var ref : treference; const usedtype, freetype: ttemptype);
  77. function ungettemppointeriftype(list: taasmoutput; const ref : treference; const usedtype, freetype: ttemptype) : boolean;
  78. { for parameter func returns }
  79. procedure normaltemptopersistant(pos : longint);
  80. {# Searches the list of currently allocated persistent memory space
  81. as the specified address @var(pos) , and if found, converts this memory
  82. space to normal volatile memory space which can be freed and reused.
  83. @param(pos offset from current frame pointer to memory area to convert)
  84. }
  85. procedure persistanttemptonormal(pos : longint);
  86. {procedure ungettemp(pos : longint;size : longint);}
  87. procedure ungetpersistanttemp(list: taasmoutput; pos : longint);
  88. procedure ungetpersistanttempreference(list: taasmoutput; const ref : treference);
  89. {# This routine is used to assign and allocate extra temporary volatile memory space
  90. on the stack from a reference. @var(l) is the size of the persistent memory space to
  91. allocate, while @var(ref) is a reference entry which will be set to the correct offset
  92. and correct base register (which is the current @var(procinfo^.framepointer)) register.
  93. The offset and base fields of ref will be set appropriately in this routine, and can be
  94. considered valid on exit of this routine.
  95. @param(l size of the area to allocate)
  96. @param(ref allocated reference)
  97. }
  98. procedure gettempofsizereference(list: taasmoutput; l : longint;var ref : treference);
  99. {# Returns TRUE if the reference ref is allocated in temporary volatile memory space,
  100. otherwise returns FALSE.
  101. @param(ref reference to verify)
  102. }
  103. function istemp(const ref : treference) : boolean;
  104. {# Frees a reference @var(ref) which was allocated in the volatile temporary memory space.
  105. The freed space can later be reallocated and reused. If this reference
  106. is not in the temporary memory, it is simply not freed.
  107. }
  108. procedure ungetiftemp(list: taasmoutput; const ref : treference);
  109. function getsizeoftemp(const ref: treference): longint;
  110. function ungetiftempansi(list: taasmoutput; const ref : treference) : boolean;
  111. procedure gettempansistringreference(list: taasmoutput; var ref : treference);
  112. function ungetiftempwidestr(list: taasmoutput; const ref : treference) : boolean;
  113. procedure gettempwidestringreference(list: taasmoutput; var ref : treference);
  114. function ungetiftempintfcom(list: taasmoutput; const ref : treference) : boolean;
  115. procedure gettempintfcomreference(list: taasmoutput; var ref : treference);
  116. private
  117. function ungettemp(list: taasmoutput; pos:longint;allowtype:ttemptype):ttemptype;
  118. function newtempofsize(size : longint) : longint;
  119. function gettempofsize(list: taasmoutput; size : longint) : longint;
  120. end;
  121. var
  122. tg: ttgobj;
  123. implementation
  124. uses
  125. systems,
  126. verbose,cutils;
  127. constructor ttgobj.create;
  128. begin
  129. tempfreelist:=nil;
  130. templist:=nil;
  131. lasttempofsize := nil;
  132. end;
  133. procedure ttgobj.resettempgen;
  134. var
  135. hp : ptemprecord;
  136. begin
  137. { Clear the old templist }
  138. while assigned(templist) do
  139. begin
  140. {$ifdef EXTDEBUG}
  141. case templist^.temptype of
  142. tt_normal,
  143. tt_persistant :
  144. Comment(V_Warning,'temporary assignment of size '+
  145. tostr(templist^.size)+' from pos '+tostr(templist^.posinfo.line)+
  146. ':'+tostr(templist^.posinfo.column)+
  147. ' at pos '+tostr(templist^.pos)+
  148. ' not freed at the end of the procedure');
  149. tt_ansistring :
  150. Comment(V_Warning,'temporary ANSI assignment of size '+
  151. tostr(templist^.size)+' from pos '+tostr(templist^.posinfo.line)+
  152. ':'+tostr(templist^.posinfo.column)+
  153. ' at pos '+tostr(templist^.pos)+
  154. ' not freed at the end of the procedure');
  155. tt_widestring :
  156. Comment(V_Warning,'temporary WIDE assignment of size '+
  157. tostr(templist^.size)+' from pos '+tostr(templist^.posinfo.line)+
  158. ':'+tostr(templist^.posinfo.column)+
  159. ' at pos '+tostr(templist^.pos)+
  160. ' not freed at the end of the procedure');
  161. end;
  162. {$endif}
  163. hp:=templist;
  164. templist:=hp^.next;
  165. dispose(hp);
  166. end;
  167. templist:=nil;
  168. tempfreelist:=nil;
  169. firsttemp:=0;
  170. lasttemp:=0;
  171. end;
  172. procedure ttgobj.setfirsttemp(l : longint);
  173. begin
  174. { this is a negative value normally }
  175. if l < 0 then
  176. Begin
  177. if odd(l) then
  178. Dec(l);
  179. end
  180. else
  181. Begin
  182. if odd(l) then
  183. Inc(l);
  184. end;
  185. firsttemp:=l;
  186. lasttemp:=l;
  187. end;
  188. function ttgobj.newtempofsize(size : longint) : longint;
  189. var
  190. tl : ptemprecord;
  191. begin
  192. { we need to allocate at least a minimum of 4 bytes, else
  193. we get two temps at the same position resulting in problems
  194. when finding the corresponding temprecord }
  195. if size=0 then
  196. size:=4;
  197. { Just extend the temp, everything below has been use
  198. already }
  199. dec(lasttemp,size);
  200. { now we can create the templist entry }
  201. new(tl);
  202. tl^.temptype:=tt_normal;
  203. tl^.pos:=lasttemp;
  204. tl^.size:=size;
  205. tl^.next:=templist;
  206. tl^.nextfree:=nil;
  207. templist:=tl;
  208. newtempofsize:=tl^.pos;
  209. end;
  210. function ttgobj.gettempofsize(list: taasmoutput; size : longint) : longint;
  211. var
  212. tl,
  213. bestslot,bestprev,
  214. hprev,hp : ptemprecord;
  215. bestsize,ofs : longint;
  216. begin
  217. bestprev:=nil;
  218. bestslot:=nil;
  219. tl:=nil;
  220. bestsize:=0;
  221. {$ifdef EXTDEBUG}
  222. if size=0 then
  223. Comment(V_Warning,'Temp of size 0 requested');
  224. {$endif}
  225. { Align needed size on 4 bytes }
  226. if (size mod 4)<>0 then
  227. size:=size+(4-(size mod 4));
  228. { First check the tmpfreelist }
  229. if assigned(tempfreelist) then
  230. begin
  231. { Check for a slot with the same size first }
  232. hprev:=nil;
  233. hp:=tempfreelist;
  234. while assigned(hp) do
  235. begin
  236. {$ifdef EXTDEBUG}
  237. if hp^.temptype<>tt_free then
  238. Comment(V_Warning,'Temp in freelist is not set to tt_free');
  239. {$endif}
  240. if hp^.size>=size then
  241. begin
  242. { Slot is the same size, then leave immediatly }
  243. if hp^.size=size then
  244. begin
  245. bestprev:=hprev;
  246. bestslot:=hp;
  247. bestsize:=size;
  248. break;
  249. end
  250. else
  251. begin
  252. if (bestsize=0) or (hp^.size<bestsize) then
  253. begin
  254. bestprev:=hprev;
  255. bestslot:=hp;
  256. bestsize:=hp^.size;
  257. end;
  258. end;
  259. end;
  260. hprev:=hp;
  261. hp:=hp^.nextfree;
  262. end;
  263. end;
  264. { Reuse an old temp ? }
  265. if assigned(bestslot) then
  266. begin
  267. if bestsize=size then
  268. begin
  269. bestslot^.temptype:=tt_normal;
  270. ofs:=bestslot^.pos;
  271. tl:=bestslot;
  272. { Remove from the tempfreelist }
  273. if assigned(bestprev) then
  274. bestprev^.nextfree:=bestslot^.nextfree
  275. else
  276. tempfreelist:=bestslot^.nextfree;
  277. end
  278. else
  279. begin
  280. { Resize the old block }
  281. dec(bestslot^.size,size);
  282. { Create new block and link after bestslot }
  283. new(tl);
  284. tl^.temptype:=tt_normal;
  285. tl^.pos:=bestslot^.pos+bestslot^.size;
  286. ofs:=tl^.pos;
  287. tl^.size:=size;
  288. tl^.nextfree:=nil;
  289. { link the new block }
  290. tl^.next:=bestslot^.next;
  291. bestslot^.next:=tl;
  292. end;
  293. end
  294. else
  295. begin
  296. ofs:=newtempofsize(size);
  297. tl:=templist;
  298. end;
  299. lasttempofsize:=tl;
  300. {$ifdef EXTDEBUG}
  301. tl^.posinfo:=aktfilepos;
  302. {$endif}
  303. list.concat(Taitempalloc.alloc(ofs,size));
  304. gettempofsize:=ofs;
  305. end;
  306. function ttgobj.gettempofsizepersistant(list: taasmoutput; size : longint) : longint;
  307. var
  308. l : longint;
  309. begin
  310. l:=gettempofsize(list, size);
  311. lasttempofsize^.temptype:=tt_persistant;
  312. {$ifdef EXTDEBUG}
  313. Comment(V_Debug,'temp managment : call to gettempofsizepersistant()'+
  314. ' with size '+tostr(size)+' returned '+tostr(l));
  315. {$endif}
  316. gettempofsizepersistant:=l;
  317. end;
  318. function ttgobj.gettempsize : longint;
  319. var
  320. _align : longint;
  321. begin
  322. { align to 4 bytes at least
  323. otherwise all those subl $2,%esp are meaningless PM }
  324. _align:=target_info.alignment.localalignmin;
  325. if _align<4 then
  326. _align:=4;
  327. gettempsize:=Align(-lasttemp,_align);
  328. end;
  329. procedure ttgobj.gettempofsizereference(list: taasmoutput; l : longint;var ref : treference);
  330. begin
  331. { do a reset, because the reference isn't used }
  332. FillChar(ref,sizeof(treference),0);
  333. ref.offset:=gettempofsize(list,l);
  334. ref.base:=procinfo^.framepointer;
  335. end;
  336. procedure ttgobj.gettempofsizereferencepersistant(list: taasmoutput; l : longint;var ref : treference);
  337. begin
  338. { do a reset, because the reference isn't used }
  339. FillChar(ref,sizeof(treference),0);
  340. ref.offset:=gettempofsizepersistant(list,l);
  341. ref.base:=procinfo^.framepointer;
  342. end;
  343. procedure ttgobj.gettemppointerreferencefortype(list: taasmoutput; var ref : treference; const usedtype, freetype: ttemptype);
  344. var
  345. foundslot,tl : ptemprecord;
  346. begin
  347. { do a reset, because the reference isn't used }
  348. FillChar(ref,sizeof(treference),0);
  349. ref.base:=procinfo^.framepointer;
  350. { Reuse old slot ? }
  351. foundslot:=nil;
  352. tl:=templist;
  353. while assigned(tl) do
  354. begin
  355. if tl^.temptype=freetype then
  356. begin
  357. foundslot:=tl;
  358. {$ifdef EXTDEBUG}
  359. tl^.posinfo:=aktfilepos;
  360. {$endif}
  361. break;
  362. end;
  363. tl:=tl^.next;
  364. end;
  365. if assigned(foundslot) then
  366. begin
  367. foundslot^.temptype:=usedtype;
  368. ref.offset:=foundslot^.pos;
  369. end
  370. else
  371. begin
  372. ref.offset:=newtempofsize(pointer_size);
  373. {$ifdef EXTDEBUG}
  374. templist^.posinfo:=aktfilepos;
  375. {$endif}
  376. templist^.temptype:=usedtype;
  377. end;
  378. list.concat(Taitempalloc.alloc(ref.offset,pointer_size));
  379. end;
  380. function ttgobj.ungettemppointeriftype(list: taasmoutput; const ref : treference; const usedtype, freetype: ttemptype) : boolean;
  381. var
  382. tl : ptemprecord;
  383. begin
  384. ungettemppointeriftype:=false;
  385. tl:=templist;
  386. while assigned(tl) do
  387. begin
  388. if tl^.pos=ref.offset then
  389. begin
  390. if tl^.temptype=usedtype then
  391. begin
  392. tl^.temptype:=freetype;
  393. ungettemppointeriftype:=true;
  394. list.concat(Taitempalloc.dealloc(tl^.pos,tl^.size));
  395. exit;
  396. {$ifdef EXTDEBUG}
  397. end
  398. else if (tl^.temptype=freetype) then
  399. begin
  400. Comment(V_Debug,'temp managment problem : ungettemppointeriftype()'+
  401. ' at pos '+tostr(ref.offset)+ ' already free !');
  402. {$endif}
  403. end;
  404. end;
  405. tl:=tl^.next;
  406. end;
  407. end;
  408. procedure ttgobj.gettempansistringreference(list: taasmoutput; var ref : treference);
  409. begin
  410. gettemppointerreferencefortype(list,ref,tt_ansistring,tt_freeansistring);
  411. end;
  412. procedure ttgobj.gettempwidestringreference(list: taasmoutput; var ref : treference);
  413. begin
  414. gettemppointerreferencefortype(list,ref,tt_widestring,tt_freewidestring);
  415. end;
  416. function ttgobj.ungetiftempansi(list: taasmoutput; const ref : treference) : boolean;
  417. begin
  418. ungetiftempansi:=ungettemppointeriftype(list,ref,tt_ansistring,tt_freeansistring);
  419. end;
  420. function ttgobj.ungetiftempwidestr(list: taasmoutput; const ref : treference) : boolean;
  421. begin
  422. ungetiftempwidestr:=ungettemppointeriftype(list,ref,tt_widestring,tt_freewidestring);
  423. end;
  424. procedure ttgobj.gettempintfcomreference(list: taasmoutput; var ref : treference);
  425. begin
  426. gettemppointerreferencefortype(list,ref,tt_interfacecom,tt_freeinterfacecom);
  427. end;
  428. function ttgobj.ungetiftempintfcom(list: taasmoutput; const ref : treference) : boolean;
  429. begin
  430. ungetiftempintfcom:=ungettemppointeriftype(list,ref,tt_ansistring,tt_freeansistring);
  431. end;
  432. function ttgobj.istemp(const ref : treference) : boolean;
  433. begin
  434. { ref.index = R_NO was missing
  435. led to problems with local arrays
  436. with lower bound > 0 (PM) }
  437. istemp:=((ref.base=procinfo^.framepointer) and
  438. (ref.index=R_NO) and
  439. (ref.offset<firsttemp));
  440. end;
  441. procedure ttgobj.persistanttemptonormal(pos : longint);
  442. var
  443. hp : ptemprecord;
  444. begin
  445. hp:=templist;
  446. while assigned(hp) do
  447. if (hp^.pos=pos) and (hp^.temptype=tt_persistant) then
  448. begin
  449. {$ifdef EXTDEBUG}
  450. Comment(V_Debug,'temp managment : persistanttemptonormal()'+
  451. ' at pos '+tostr(pos)+ ' found !');
  452. {$endif}
  453. hp^.temptype:=tt_normal;
  454. exit;
  455. end
  456. else
  457. hp:=hp^.next;
  458. {$ifdef EXTDEBUG}
  459. Comment(V_Debug,'temp managment problem : persistanttemptonormal()'+
  460. ' at pos '+tostr(pos)+ ' not found !');
  461. {$endif}
  462. end;
  463. procedure ttgobj.normaltemptopersistant(pos : longint);
  464. var
  465. hp : ptemprecord;
  466. begin
  467. hp:=templist;
  468. while assigned(hp) do
  469. if (hp^.pos=pos) and (hp^.temptype=tt_normal) then
  470. begin
  471. {$ifdef EXTDEBUG}
  472. Comment(V_Debug,'temp managment : normaltemptopersistant()'+
  473. ' at pos '+tostr(pos)+ ' found !');
  474. {$endif}
  475. hp^.temptype:=tt_persistant;
  476. exit;
  477. end
  478. else
  479. hp:=hp^.next;
  480. {$ifdef EXTDEBUG}
  481. Comment(V_Debug,'temp managment problem : normaltemptopersistant()'+
  482. ' at pos '+tostr(pos)+ ' not found !');
  483. {$endif}
  484. end;
  485. function ttgobj.ungettemp(list: taasmoutput; pos:longint;allowtype:ttemptype):ttemptype;
  486. var
  487. hp,hnext,hprev,hprevfree : ptemprecord;
  488. begin
  489. ungettemp:=tt_none;
  490. hp:=templist;
  491. hprev:=nil;
  492. hprevfree:=nil;
  493. while assigned(hp) do
  494. begin
  495. if (hp^.pos=pos) then
  496. begin
  497. { check type }
  498. ungettemp:=hp^.temptype;
  499. if hp^.temptype<>allowtype then
  500. begin
  501. exit;
  502. end;
  503. list.concat(Taitempalloc.dealloc(hp^.pos,hp^.size));
  504. { set this block to free }
  505. hp^.temptype:=tt_free;
  506. { Update tempfreelist }
  507. if assigned(hprevfree) then
  508. begin
  509. { Connect with previous? }
  510. if assigned(hprev) and (hprev^.temptype=tt_free) then
  511. begin
  512. inc(hprev^.size,hp^.size);
  513. hprev^.next:=hp^.next;
  514. dispose(hp);
  515. hp:=hprev;
  516. end
  517. else
  518. hprevfree^.nextfree:=hp;
  519. end
  520. else
  521. begin
  522. hp^.nextfree:=tempfreelist;
  523. tempfreelist:=hp;
  524. end;
  525. { Next block free ? Yes, then concat }
  526. hnext:=hp^.next;
  527. if assigned(hnext) and (hnext^.temptype=tt_free) then
  528. begin
  529. inc(hp^.size,hnext^.size);
  530. hp^.nextfree:=hnext^.nextfree;
  531. hp^.next:=hnext^.next;
  532. dispose(hnext);
  533. end;
  534. exit;
  535. end;
  536. if (hp^.temptype=tt_free) then
  537. hprevfree:=hp;
  538. hprev:=hp;
  539. hp:=hp^.next;
  540. end;
  541. ungettemp:=tt_none;
  542. end;
  543. function ttgobj.getsizeoftemp(const ref: treference): longint;
  544. var
  545. hp : ptemprecord;
  546. begin
  547. hp:=templist;
  548. while assigned(hp) do
  549. begin
  550. if (hp^.pos=ref.offset) then
  551. begin
  552. getsizeoftemp := hp^.size;
  553. exit;
  554. end;
  555. hp := hp^.next;
  556. end;
  557. getsizeoftemp := -1;
  558. end;
  559. procedure ttgobj.ungetpersistanttemp(list: taasmoutput; pos : longint);
  560. begin
  561. {$ifdef EXTDEBUG}
  562. if ungettemp(list,pos,tt_persistant)<>tt_persistant then
  563. Comment(V_Warning,'temp managment problem : ungetpersistanttemp()'+
  564. ' at pos '+tostr(pos)+ ' not found !');
  565. {$else}
  566. ungettemp(list,pos,tt_persistant);
  567. {$endif}
  568. end;
  569. procedure ttgobj.ungetpersistanttempreference(list: taasmoutput; const ref : treference);
  570. begin
  571. ungetpersistanttemp(list, ref.offset);
  572. end;
  573. procedure ttgobj.ungetiftemp(list: taasmoutput; const ref : treference);
  574. {$ifdef EXTDEBUG}
  575. var
  576. tt : ttemptype;
  577. {$endif}
  578. begin
  579. if istemp(ref) then
  580. begin
  581. { first check if ansistring }
  582. if ungetiftempansi(list,ref) or
  583. ungetiftempwidestr(list,ref) or
  584. ungetiftempintfcom(list,ref) then
  585. exit;
  586. {$ifndef EXTDEBUG}
  587. ungettemp(list,ref.offset,tt_normal);
  588. {$else}
  589. tt:=ungettemp(list,ref.offset,tt_normal);
  590. if tt=tt_persistant then
  591. Comment(V_Debug,'temp at pos '+tostr(ref.offset)+ ' not released because persistant!');
  592. if tt=tt_none then
  593. Comment(V_Warning,'temp not found for release at offset '+tostr(ref.offset));
  594. {$endif}
  595. end;
  596. end;
  597. initialization
  598. tg := ttgobj.create;
  599. finalization
  600. tg.free;
  601. end.
  602. {
  603. $Log$
  604. Revision 1.6 2002-04-15 19:08:22 carl
  605. + target_info.size_of_pointer -> pointer_size
  606. + some cleanup of unused types/variables
  607. Revision 1.5 2002/04/07 13:38:48 carl
  608. + update documentation
  609. Revision 1.4 2002/04/07 09:17:17 carl
  610. + documentation
  611. - clean-up
  612. Revision 1.3 2002/04/04 19:06:06 peter
  613. * removed unused units
  614. * use tlocation.size in cg.a_*loc*() routines
  615. Revision 1.2 2002/04/02 17:11:32 peter
  616. * tlocation,treference update
  617. * LOC_CONSTANT added for better constant handling
  618. * secondadd splitted in multiple routines
  619. * location_force_reg added for loading a location to a register
  620. of a specified size
  621. * secondassignment parses now first the right and then the left node
  622. (this is compatible with Kylix). This saves a lot of push/pop especially
  623. with string operations
  624. * adapted some routines to use the new cg methods
  625. Revision 1.1 2002/03/31 20:26:37 jonas
  626. + a_loadfpu_* and a_loadmm_* methods in tcg
  627. * register allocation is now handled by a class and is mostly processor
  628. independent (+rgobj.pas and i386/rgcpu.pas)
  629. * temp allocation is now handled by a class (+tgobj.pas, -i386\tgcpu.pas)
  630. * some small improvements and fixes to the optimizer
  631. * some register allocation fixes
  632. * some fpuvaroffset fixes in the unary minus node
  633. * push/popusedregisters is now called rg.save/restoreusedregisters and
  634. (for i386) uses temps instead of push/pop's when using -Op3 (that code is
  635. also better optimizable)
  636. * fixed and optimized register saving/restoring for new/dispose nodes
  637. * LOC_FPU locations now also require their "register" field to be set to
  638. R_ST, not R_ST0 (the latter is used for LOC_CFPUREGISTER locations only)
  639. - list field removed of the tnode class because it's not used currently
  640. and can cause hard-to-find bugs
  641. Revision 1.1 2000/07/13 06:30:09 michael
  642. + Initial import
  643. Revision 1.10 2000/02/17 14:48:36 florian
  644. * updated to use old firstpass
  645. Revision 1.9 2000/01/07 01:14:55 peter
  646. * updated copyright to 2000
  647. Revision 1.8 1999/10/14 14:57:54 florian
  648. - removed the hcodegen use in the new cg, use cgbase instead
  649. Revision 1.7 1999/10/12 21:20:47 florian
  650. * new codegenerator compiles again
  651. Revision 1.6 1999/09/10 18:48:11 florian
  652. * some bug fixes (e.g. must_be_valid and procinfo.funcret_is_valid)
  653. * most things for stored properties fixed
  654. Revision 1.5 1999/08/06 16:04:06 michael
  655. + introduced tainstruction
  656. Revision 1.4 1999/08/03 00:33:23 michael
  657. + Added cpuasm for alpha
  658. Revision 1.3 1999/08/03 00:32:13 florian
  659. * reg_vars and reg_pushes is now in tgobj
  660. Revision 1.2 1999/08/02 23:13:22 florian
  661. * more changes to compile for the Alpha
  662. Revision 1.1 1999/08/02 17:14:12 florian
  663. + changed the temp. generator to an object
  664. }