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 fpcdefs.inc}
  25. interface
  26. uses
  27. cclasses,
  28. globals,globtype,
  29. symtype,
  30. cpubase,cpuinfo,cgbase,
  31. aasmbase,aasmtai;
  32. type
  33. ttemptypeset = set of ttemptype;
  34. ptemprecord = ^ttemprecord;
  35. ttemprecord = record
  36. temptype : ttemptype;
  37. pos : longint;
  38. size : longint;
  39. def : tdef;
  40. next : ptemprecord;
  41. nextfree : ptemprecord; { for faster freeblock checking }
  42. {$ifdef EXTDEBUG}
  43. posinfo,
  44. releaseposinfo : tfileposinfo;
  45. {$endif}
  46. end;
  47. {# Generates temporary variables }
  48. ttgobj = class
  49. private
  50. { contains all free temps using nextfree links }
  51. tempfreelist : ptemprecord;
  52. function alloctemp(list: taasmoutput; size : longint; temptype : ttemptype; def:tdef) : longint;
  53. procedure freetemp(list: taasmoutput; pos:longint;temptypes:ttemptypeset);
  54. public
  55. { contains all temps }
  56. templist : ptemprecord;
  57. { Offsets of the first/last temp }
  58. firsttemp,
  59. lasttemp : longint;
  60. direction : shortint;
  61. constructor create;
  62. {# Clear and free the complete linked list of temporary memory
  63. locations. The list is set to nil.}
  64. procedure resettempgen;
  65. {# Sets the first offset from the frame pointer or stack pointer where
  66. the temporary references will be allocated. It is to note that this
  67. value should always be negative.
  68. @param(l start offset where temps will start in stack)
  69. }
  70. procedure setfirsttemp(l : longint);
  71. procedure gettemp(list: taasmoutput; size : longint;temptype:ttemptype;var ref : treference);
  72. procedure gettemptyped(list: taasmoutput; def:tdef;temptype:ttemptype;var ref : treference);
  73. procedure ungettemp(list: taasmoutput; const ref : treference);
  74. function sizeoftemp(list: taasmoutput; const ref: treference): longint;
  75. function changetemptype(list: taasmoutput; const ref:treference;temptype:ttemptype):boolean;
  76. {# Returns TRUE if the reference ref is allocated in temporary volatile memory space,
  77. otherwise returns FALSE.
  78. @param(ref reference to verify)
  79. }
  80. function istemp(const ref : treference) : boolean;
  81. {# Frees a reference @var(ref) which was allocated in the volatile temporary memory space.
  82. The freed space can later be reallocated and reused. If this reference
  83. is not in the temporary memory, it is simply not freed.
  84. }
  85. procedure ungetiftemp(list: taasmoutput; const ref : treference);
  86. { Allocate space for a local }
  87. procedure getlocal(list: taasmoutput; size : longint;var ref : tparareference);
  88. procedure UnGetLocal(list: taasmoutput; const ref : tparareference);
  89. end;
  90. var
  91. tg: ttgobj;
  92. implementation
  93. uses
  94. cutils,
  95. systems,verbose,
  96. procinfo
  97. ;
  98. const
  99. FreeTempTypes = [tt_free,tt_freenoreuse];
  100. {$ifdef EXTDEBUG}
  101. TempTypeStr : array[ttemptype] of string[18] = (
  102. '<none>',
  103. 'free','normal','persistant',
  104. 'noreuse','freenoreuse'
  105. );
  106. {$endif EXTDEBUG}
  107. Used2Free : array[ttemptype] of ttemptype = (
  108. tt_none,
  109. tt_none,tt_free,tt_free,
  110. tt_freenoreuse,tt_none
  111. );
  112. {*****************************************************************************
  113. TTGOBJ
  114. *****************************************************************************}
  115. constructor ttgobj.create;
  116. begin
  117. tempfreelist:=nil;
  118. templist:=nil;
  119. { we could create a new child class for this but I don't if it is worth the effort (FK) }
  120. {$ifdef powerpc}
  121. direction:=1;
  122. {$else powerpc}
  123. direction:=-1;
  124. {$endif powerpc}
  125. end;
  126. procedure ttgobj.resettempgen;
  127. var
  128. hp : ptemprecord;
  129. begin
  130. { Clear the old templist }
  131. while assigned(templist) do
  132. begin
  133. {$ifdef EXTDEBUG}
  134. if not(templist^.temptype in FreeTempTypes) then
  135. begin
  136. Comment(V_Warning,'tgobj: (ResetTempgen) temp at pos '+tostr(templist^.pos)+
  137. ' with size '+tostr(templist^.size)+' and type '+TempTypeStr[templist^.temptype]+
  138. ' from pos '+tostr(templist^.posinfo.line)+':'+tostr(templist^.posinfo.column)+
  139. ' not freed at the end of the procedure');
  140. end;
  141. {$endif}
  142. hp:=templist;
  143. templist:=hp^.next;
  144. dispose(hp);
  145. end;
  146. templist:=nil;
  147. tempfreelist:=nil;
  148. firsttemp:=0;
  149. lasttemp:=0;
  150. end;
  151. procedure ttgobj.setfirsttemp(l : longint);
  152. begin
  153. { this is a negative value normally }
  154. if l*direction>=0 then
  155. begin
  156. if odd(l) then
  157. inc(l,direction);
  158. end
  159. else
  160. internalerror(200204221);
  161. firsttemp:=l;
  162. lasttemp:=l;
  163. end;
  164. function ttgobj.AllocTemp(list: taasmoutput; size : longint; temptype : ttemptype;def : tdef) : longint;
  165. var
  166. tl,
  167. bestslot,bestprev,
  168. hprev,hp : ptemprecord;
  169. bestsize : longint;
  170. freetype : ttemptype;
  171. begin
  172. AllocTemp:=0;
  173. bestprev:=nil;
  174. bestslot:=nil;
  175. tl:=nil;
  176. bestsize:=0;
  177. if size=0 then
  178. begin
  179. {$ifdef EXTDEBUG}
  180. Comment(V_Warning,'tgobj: (AllocTemp) temp of size 0 requested, allocating 4 bytes');
  181. {$endif}
  182. size:=4;
  183. end;
  184. freetype:=Used2Free[temptype];
  185. if freetype=tt_none then
  186. internalerror(200208201);
  187. { Align needed size on 4 bytes }
  188. size:=align(size,4);
  189. { First check the tmpfreelist, but not when
  190. we don't want to reuse an already allocated block }
  191. if assigned(tempfreelist) and
  192. (temptype<>tt_noreuse) then
  193. begin
  194. { Check for a slot with the same size first }
  195. hprev:=nil;
  196. hp:=tempfreelist;
  197. while assigned(hp) do
  198. begin
  199. {$ifdef EXTDEBUG}
  200. if not(hp^.temptype in FreeTempTypes) then
  201. Comment(V_Warning,'tgobj: (AllocTemp) temp at pos '+tostr(hp^.pos)+ ' in freelist is not set to tt_free !');
  202. {$endif}
  203. if (hp^.temptype=freetype) and
  204. (hp^.def=def) and
  205. (hp^.size>=size) then
  206. begin
  207. { Slot is the same size, then leave immediatly }
  208. if hp^.size=size then
  209. begin
  210. bestprev:=hprev;
  211. bestslot:=hp;
  212. bestsize:=size;
  213. break;
  214. end
  215. else
  216. begin
  217. if (bestsize=0) or (hp^.size<bestsize) then
  218. begin
  219. bestprev:=hprev;
  220. bestslot:=hp;
  221. bestsize:=hp^.size;
  222. end;
  223. end;
  224. end;
  225. hprev:=hp;
  226. hp:=hp^.nextfree;
  227. end;
  228. end;
  229. { Reuse an old temp ? }
  230. if assigned(bestslot) then
  231. begin
  232. if bestsize=size then
  233. begin
  234. tl:=bestslot;
  235. tl^.temptype:=temptype;
  236. tl^.def:=def;
  237. { Remove from the tempfreelist }
  238. if assigned(bestprev) then
  239. bestprev^.nextfree:=tl^.nextfree
  240. else
  241. tempfreelist:=tl^.nextfree;
  242. tl^.nextfree:=nil;
  243. end
  244. else
  245. begin
  246. { Resize the old block }
  247. dec(bestslot^.size,size);
  248. { Create new block and link after bestslot }
  249. new(tl);
  250. tl^.temptype:=temptype;
  251. tl^.def:=def;
  252. if direction=1 then
  253. begin
  254. tl^.pos:=bestslot^.pos;
  255. inc(bestslot^.pos,size);
  256. end
  257. else
  258. tl^.pos:=bestslot^.pos+bestslot^.size;
  259. tl^.size:=size;
  260. tl^.nextfree:=nil;
  261. { link the new block }
  262. tl^.next:=bestslot^.next;
  263. bestslot^.next:=tl;
  264. end;
  265. end
  266. else
  267. begin
  268. { create a new temp, we need to allocate at least a minimum of
  269. 4 bytes, else we get two temps at the same position resulting
  270. in problems when finding the corresponding temprecord }
  271. if size<4 then
  272. size:=4;
  273. { now we can create the templist entry }
  274. new(tl);
  275. tl^.temptype:=temptype;
  276. tl^.def:=def;
  277. if direction=-1 then
  278. begin
  279. { Extend the temp }
  280. dec(lasttemp,size);
  281. tl^.pos:=lasttemp;
  282. end
  283. else
  284. begin
  285. tl^.pos:=lasttemp;
  286. { Extend the temp }
  287. inc(lasttemp,size);
  288. end;
  289. tl^.size:=size;
  290. tl^.next:=templist;
  291. tl^.nextfree:=nil;
  292. templist:=tl;
  293. end;
  294. {$ifdef EXTDEBUG}
  295. tl^.posinfo:=aktfilepos;
  296. if assigned(tl^.def) then
  297. list.concat(tai_tempalloc.allocinfo(tl^.pos,tl^.size,'allocated with type '+TempTypeStr[tl^.temptype]+' for def '+tl^.def.typename))
  298. else
  299. list.concat(tai_tempalloc.allocinfo(tl^.pos,tl^.size,'allocated with type '+TempTypeStr[tl^.temptype]));
  300. {$else}
  301. list.concat(tai_tempalloc.alloc(tl^.pos,tl^.size));
  302. {$endif}
  303. AllocTemp:=tl^.pos;
  304. end;
  305. procedure ttgobj.FreeTemp(list: taasmoutput; pos:longint;temptypes:ttemptypeset);
  306. var
  307. hp,hnext,hprev,hprevfree : ptemprecord;
  308. begin
  309. hp:=templist;
  310. hprev:=nil;
  311. hprevfree:=nil;
  312. while assigned(hp) do
  313. begin
  314. if (hp^.pos=pos) then
  315. begin
  316. { check if already freed }
  317. if hp^.temptype in FreeTempTypes then
  318. begin
  319. {$ifdef EXTDEBUG}
  320. Comment(V_Warning,'tgobj: (FreeTemp) temp at pos '+tostr(pos)+ ' is already free !');
  321. list.concat(tai_tempalloc.allocinfo(hp^.pos,hp^.size,'temp is already freed'));
  322. {$endif}
  323. exit;
  324. end;
  325. { check type that are allowed to be released }
  326. if not(hp^.temptype in temptypes) then
  327. begin
  328. {$ifdef EXTDEBUG}
  329. Comment(V_Debug,'tgobj: (Freetemp) temp at pos '+tostr(pos)+ ' has different type ('+TempTypeStr[hp^.temptype]+'), not releasing');
  330. list.concat(tai_tempalloc.allocinfo(hp^.pos,hp^.size,'temp has wrong type ('+TempTypeStr[hp^.temptype]+') not releasing'));
  331. {$endif}
  332. exit;
  333. end;
  334. list.concat(tai_tempalloc.dealloc(hp^.pos,hp^.size));
  335. { set this block to free }
  336. hp^.temptype:=Used2Free[hp^.temptype];
  337. { Update tempfreelist }
  338. if assigned(hprevfree) then
  339. begin
  340. { Concat blocks when the previous block is free and
  341. there is no block assigned for a tdef }
  342. if assigned(hprev) and
  343. (hp^.temptype=tt_free) and
  344. not assigned(hp^.def) and
  345. (hprev^.temptype=tt_free) and
  346. not assigned(hprev^.def) then
  347. begin
  348. inc(hprev^.size,hp^.size);
  349. if direction=1 then
  350. hprev^.pos:=hp^.pos;
  351. hprev^.next:=hp^.next;
  352. dispose(hp);
  353. hp:=hprev;
  354. end
  355. else
  356. hprevfree^.nextfree:=hp;
  357. end
  358. else
  359. begin
  360. hp^.nextfree:=tempfreelist;
  361. tempfreelist:=hp;
  362. end;
  363. { Concat blocks when the next block is free and
  364. there is no block assigned for a tdef }
  365. hnext:=hp^.next;
  366. if assigned(hnext) and
  367. (hp^.temptype=tt_free) and
  368. not assigned(hp^.def) and
  369. (hnext^.temptype=tt_free) and
  370. not assigned(hnext^.def) then
  371. begin
  372. inc(hp^.size,hnext^.size);
  373. if direction=1 then
  374. hp^.pos:=hnext^.pos;
  375. hp^.nextfree:=hnext^.nextfree;
  376. hp^.next:=hnext^.next;
  377. dispose(hnext);
  378. end;
  379. { Stop }
  380. exit;
  381. end;
  382. if (hp^.temptype=tt_free) then
  383. hprevfree:=hp;
  384. hprev:=hp;
  385. hp:=hp^.next;
  386. end;
  387. end;
  388. procedure ttgobj.gettemp(list: taasmoutput; size : longint;temptype:ttemptype;var ref : treference);
  389. begin
  390. { can't use reference_reset_base, because that will let tgobj depend
  391. on cgobj (PFV) }
  392. fillchar(ref,sizeof(ref),0);
  393. ref.base:=current_procinfo.framepointer;
  394. ref.offset:=alloctemp(list,size,temptype,nil);
  395. end;
  396. procedure ttgobj.gettemptyped(list: taasmoutput; def:tdef;temptype:ttemptype;var ref : treference);
  397. begin
  398. { can't use reference_reset_base, because that will let tgobj depend
  399. on cgobj (PFV) }
  400. fillchar(ref,sizeof(ref),0);
  401. ref.base:=current_procinfo.framepointer;
  402. ref.offset:=alloctemp(list,def.size,temptype,def);
  403. end;
  404. function ttgobj.istemp(const ref : treference) : boolean;
  405. begin
  406. { ref.index = R_NO was missing
  407. led to problems with local arrays
  408. with lower bound > 0 (PM) }
  409. if direction = 1 then
  410. begin
  411. istemp:=(ref.base=current_procinfo.framepointer) and
  412. (ref.index=NR_NO) and
  413. (ref.offset>=firsttemp);
  414. end
  415. else
  416. begin
  417. istemp:=(ref.base=current_procinfo.framepointer) and
  418. (ref.index=NR_NO) and
  419. (ref.offset<firsttemp);
  420. end;
  421. end;
  422. function ttgobj.sizeoftemp(list: taasmoutput; const ref: treference): longint;
  423. var
  424. hp : ptemprecord;
  425. begin
  426. SizeOfTemp := -1;
  427. hp:=templist;
  428. while assigned(hp) do
  429. begin
  430. if (hp^.pos=ref.offset) then
  431. begin
  432. sizeoftemp := hp^.size;
  433. exit;
  434. end;
  435. hp := hp^.next;
  436. end;
  437. {$ifdef EXTDEBUG}
  438. comment(v_debug,'tgobj: (SizeOfTemp) temp at pos '+tostr(ref.offset)+' not found !');
  439. list.concat(tai_tempalloc.allocinfo(ref.offset,0,'temp not found'));
  440. {$endif}
  441. end;
  442. function ttgobj.ChangeTempType(list: taasmoutput; const ref:treference;temptype:ttemptype):boolean;
  443. var
  444. hp : ptemprecord;
  445. begin
  446. ChangeTempType:=false;
  447. hp:=templist;
  448. while assigned(hp) do
  449. begin
  450. if (hp^.pos=ref.offset) then
  451. begin
  452. if hp^.temptype<>tt_free then
  453. begin
  454. {$ifdef EXTDEBUG}
  455. if hp^.temptype=temptype then
  456. Comment(V_Warning,'tgobj: (ChangeTempType) temp'+
  457. ' at pos '+tostr(ref.offset)+ ' is already of the correct type !');
  458. list.concat(tai_tempalloc.allocinfo(hp^.pos,hp^.size,'type changed to '+TempTypeStr[temptype]));
  459. {$endif}
  460. ChangeTempType:=true;
  461. hp^.temptype:=temptype;
  462. end
  463. else
  464. begin
  465. {$ifdef EXTDEBUG}
  466. Comment(V_Warning,'tgobj: (ChangeTempType) temp'+
  467. ' at pos '+tostr(ref.offset)+ ' is already freed !');
  468. list.concat(tai_tempalloc.allocinfo(hp^.pos,hp^.size,'temp is already freed'));
  469. {$endif}
  470. end;
  471. exit;
  472. end;
  473. hp:=hp^.next;
  474. end;
  475. {$ifdef EXTDEBUG}
  476. Comment(V_Warning,'tgobj: (ChangeTempType) temp'+
  477. ' at pos '+tostr(ref.offset)+ ' not found !');
  478. list.concat(tai_tempalloc.allocinfo(ref.offset,0,'temp not found'));
  479. {$endif}
  480. end;
  481. procedure ttgobj.UnGetTemp(list: taasmoutput; const ref : treference);
  482. begin
  483. FreeTemp(list,ref.offset,[tt_normal,tt_noreuse,tt_persistent]);
  484. end;
  485. procedure ttgobj.UnGetIfTemp(list: taasmoutput; const ref : treference);
  486. begin
  487. if istemp(ref) then
  488. FreeTemp(list,ref.offset,[tt_normal]);
  489. end;
  490. procedure ttgobj.getlocal(list: taasmoutput; size : longint;var ref : tparareference);
  491. begin
  492. ref.index:=current_procinfo.framepointer;
  493. ref.offset:=alloctemp(list,size,tt_persistent,nil);
  494. end;
  495. procedure ttgobj.UnGetLocal(list: taasmoutput; const ref : tparareference);
  496. begin
  497. FreeTemp(list,ref.offset,[tt_persistent]);
  498. end;
  499. end.
  500. {
  501. $Log$
  502. Revision 1.42 2003-11-04 19:03:54 peter
  503. * fixes for temp type patch
  504. Revision 1.41 2003/11/04 15:35:13 peter
  505. * fix for referencecounted temps
  506. Revision 1.40 2003/10/01 20:34:49 peter
  507. * procinfo unit contains tprocinfo
  508. * cginfo renamed to cgbase
  509. * moved cgmessage to verbose
  510. * fixed ppc and sparc compiles
  511. Revision 1.39 2003/09/23 17:56:06 peter
  512. * locals and paras are allocated in the code generation
  513. * tvarsym.localloc contains the location of para/local when
  514. generating code for the current procedure
  515. Revision 1.38 2003/09/03 15:55:01 peter
  516. * NEWRA branch merged
  517. Revision 1.37.2.2 2003/08/31 15:46:26 peter
  518. * more updates for tregister
  519. Revision 1.37.2.1 2003/08/29 17:28:59 peter
  520. * next batch of updates
  521. Revision 1.37 2003/08/20 17:48:49 peter
  522. * fixed stackalloc to not allocate localst.datasize twice
  523. * order of stackalloc code fixed for implicit init/final
  524. Revision 1.36 2003/07/06 17:58:22 peter
  525. * framepointer fixes for sparc
  526. * parent framepointer code more generic
  527. Revision 1.35 2003/06/03 13:01:59 daniel
  528. * Register allocator finished
  529. Revision 1.34 2003/05/17 13:30:08 jonas
  530. * changed tt_persistant to tt_persistent :)
  531. * tempcreatenode now doesn't accept a boolean anymore for persistent
  532. temps, but a ttemptype, so you can also create ansistring temps etc
  533. Revision 1.33 2003/05/13 20:13:41 florian
  534. * fixed temp. management for CPUs were the temp. space grows upwards
  535. Revision 1.32 2003/05/12 21:29:59 peter
  536. * extdebug info temp alloc type was wrong
  537. Revision 1.31 2003/04/27 11:21:35 peter
  538. * aktprocdef renamed to current_procdef
  539. * procinfo renamed to current_procinfo
  540. * procinfo will now be stored in current_module so it can be
  541. cleaned up properly
  542. * gen_main_procsym changed to create_main_proc and release_main_proc
  543. to also generate a tprocinfo structure
  544. * fixed unit implicit initfinal
  545. Revision 1.30 2003/04/25 20:59:35 peter
  546. * removed funcretn,funcretsym, function result is now in varsym
  547. and aliases for result and function name are added using absolutesym
  548. * vs_hidden parameter for funcret passed in parameter
  549. * vs_hidden fixes
  550. * writenode changed to printnode and released from extdebug
  551. * -vp option added to generate a tree.log with the nodetree
  552. * nicer printnode for statements, callnode
  553. Revision 1.29 2003/04/23 08:40:39 jonas
  554. * fixed istemp() when tg.direction = 1
  555. Revision 1.28 2003/04/22 09:46:17 peter
  556. * always allocate 4 bytes when 0 bytes are asked
  557. Revision 1.27 2003/03/11 21:46:24 jonas
  558. * lots of new regallocator fixes, both in generic and ppc-specific code
  559. (ppc compiler still can't compile the linux system unit though)
  560. Revision 1.26 2003/02/19 22:00:15 daniel
  561. * Code generator converted to new register notation
  562. - Horribily outdated todo.txt removed
  563. Revision 1.25 2003/02/03 23:10:39 daniel
  564. * Fixed last commit
  565. Revision 1.24 2003/02/03 23:07:39 daniel
  566. * Made gettemp use intended procedure for setting reference
  567. Revision 1.23 2003/01/08 18:43:57 daniel
  568. * Tregister changed into a record
  569. Revision 1.22 2002/12/01 18:58:26 carl
  570. * fix bugs with istemp() was wrong, and every reference was a temp
  571. Revision 1.21 2002/11/24 18:18:04 carl
  572. - remove some unused defines
  573. Revision 1.20 2002/11/17 17:49:08 mazen
  574. + return_result_reg and function_result_reg are now used, in all plateforms, to pass functions result between called function and its caller. See the explanation of each one
  575. Revision 1.19 2002/11/15 01:58:54 peter
  576. * merged changes from 1.0.7 up to 04-11
  577. - -V option for generating bug report tracing
  578. - more tracing for option parsing
  579. - errors for cdecl and high()
  580. - win32 import stabs
  581. - win32 records<=8 are returned in eax:edx (turned off by default)
  582. - heaptrc update
  583. - more info for temp management in .s file with EXTDEBUG
  584. Revision 1.18 2002/10/11 11:57:43 florian
  585. *** empty log message ***
  586. Revision 1.16 2002/09/07 18:25:00 florian
  587. + added tcg.direction to allow upwards growing temp areas
  588. i.e. temps with positive index
  589. Revision 1.15 2002/09/01 18:42:50 peter
  590. * reduced level of comment that type is wrong for release
  591. Revision 1.14 2002/09/01 12:14:53 peter
  592. * fixed some wrong levels in extdebug comments
  593. Revision 1.13 2002/08/24 18:35:04 peter
  594. * when reusing a block also update the temptype instead of forcing it
  595. to tt_normal
  596. Revision 1.12 2002/08/23 16:14:49 peter
  597. * tempgen cleanup
  598. * tt_noreuse temp type added that will be used in genentrycode
  599. Revision 1.11 2002/08/17 09:23:44 florian
  600. * first part of procinfo rewrite
  601. Revision 1.10 2002/07/01 18:46:29 peter
  602. * internal linker
  603. * reorganized aasm layer
  604. Revision 1.9 2002/05/18 13:34:21 peter
  605. * readded missing revisions
  606. Revision 1.8 2002/05/16 19:46:45 carl
  607. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  608. + try to fix temp allocation (still in ifdef)
  609. + generic constructor calls
  610. + start of tassembler / tmodulebase class cleanup
  611. Revision 1.7 2002/05/14 19:34:52 peter
  612. * removed old logs and updated copyright year
  613. Revision 1.6 2002/04/15 19:08:22 carl
  614. + target_info.size_of_pointer -> pointer_size
  615. + some cleanup of unused types/variables
  616. Revision 1.5 2002/04/07 13:38:48 carl
  617. + update documentation
  618. Revision 1.4 2002/04/07 09:17:17 carl
  619. + documentation
  620. - clean-up
  621. Revision 1.3 2002/04/04 19:06:06 peter
  622. * removed unused units
  623. * use tlocation.size in cg.a_*loc*() routines
  624. Revision 1.2 2002/04/02 17:11:32 peter
  625. * tlocation,treference update
  626. * LOC_CONSTANT added for better constant handling
  627. * secondadd splitted in multiple routines
  628. * location_force_reg added for loading a location to a register
  629. of a specified size
  630. * secondassignment parses now first the right and then the left node
  631. (this is compatible with Kylix). This saves a lot of push/pop especially
  632. with string operations
  633. * adapted some routines to use the new cg methods
  634. Revision 1.1 2002/03/31 20:26:37 jonas
  635. + a_loadfpu_* and a_loadmm_* methods in tcg
  636. * register allocation is now handled by a class and is mostly processor
  637. independent (+rgobj.pas and i386/rgcpu.pas)
  638. * temp allocation is now handled by a class (+tgobj.pas, -i386\tgcpu.pas)
  639. * some small improvements and fixes to the optimizer
  640. * some register allocation fixes
  641. * some fpuvaroffset fixes in the unary minus node
  642. * push/popusedregisters is now called rg.save/restoreusedregisters and
  643. (for i386) uses temps instead of push/pop's when using -Op3 (that code is
  644. also better optimizable)
  645. * fixed and optimized register saving/restoring for new/dispose nodes
  646. * LOC_FPU locations now also require their "register" field to be set to
  647. R_ST, not R_ST0 (the latter is used for LOC_CFPUREGISTER locations only)
  648. - list field removed of the tnode class because it's not used currently
  649. and can cause hard-to-find bugs
  650. }