rgcpu.pas 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit implements the i386 specific class for the register
  5. allocator
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit rgcpu;
  20. {$i fpcdefs.inc}
  21. interface
  22. uses
  23. cpubase,
  24. cpuinfo,
  25. aasmbase,aasmtai,aasmcpu,
  26. cclasses,globtype,cgbase,cginfo,rgobj;
  27. type
  28. trgcpu = class(trgobj)
  29. fpuvaroffset : byte;
  30. { to keep the same allocation order as with the old routines }
  31. function getregisterint(list:Taasmoutput;size:Tcgsize):Tregister;override;
  32. {$ifndef newra}
  33. function getaddressregister(list:Taasmoutput):Tregister;override;
  34. procedure ungetregisterint(list:Taasmoutput;r:Tregister); override;
  35. function getexplicitregisterint(list:Taasmoutput;r:Tnewregister):Tregister;override;
  36. {$endif newra}
  37. function getregisterfpu(list: taasmoutput) : tregister; override;
  38. procedure ungetregisterfpu(list: taasmoutput; r : tregister); override;
  39. procedure ungetreference(list: taasmoutput; const ref : treference); override;
  40. {# Returns a subset register of the register r with the specified size.
  41. WARNING: There is no clearing of the upper parts of the register,
  42. if a 8-bit / 16-bit register is converted to a 32-bit register.
  43. It is up to the code generator to correctly zero fill the register
  44. }
  45. function makeregsize(reg: tregister; size: tcgsize): tregister; override;
  46. { pushes and restores registers }
  47. procedure pushusedintregisters(list:Taasmoutput;
  48. var pushed:Tpushedsavedint;
  49. const s:Tsupregset);
  50. {$ifdef SUPPORT_MMX}
  51. procedure pushusedotherregisters(list:Taasmoutput;
  52. var pushed:Tpushedsaved;
  53. const s:Tregisterset);
  54. {$endif SUPPORT_MMX}
  55. procedure popusedintregisters(list:Taasmoutput;
  56. const pushed:Tpushedsavedint);
  57. {$ifdef SUPPORT_MMX}
  58. procedure popusedotherregisters(list:Taasmoutput;
  59. const pushed:Tpushedsaved);
  60. {$endif SUPPORT_MMX}
  61. procedure saveusedintregisters(list:Taasmoutput;
  62. var saved:Tpushedsavedint;
  63. const s:Tsupregset);override;
  64. procedure saveusedotherregisters(list:Taasmoutput;
  65. var saved:Tpushedsaved;
  66. const s:Tregisterset);override;
  67. procedure restoreusedintregisters(list:Taasmoutput;
  68. const saved:Tpushedsavedint);override;
  69. procedure restoreusedotherregisters(list:Taasmoutput;
  70. const saved:Tpushedsaved);override;
  71. procedure resetusableregisters;override;
  72. { corrects the fpu stack register by ofs }
  73. function correct_fpuregister(r : tregister;ofs : byte) : tregister;
  74. end;
  75. implementation
  76. uses
  77. systems,
  78. globals,verbose,
  79. tgobj;
  80. {************************************************************************}
  81. { routine helpers }
  82. {************************************************************************}
  83. const
  84. reg2reg32 : array[firstreg..lastreg] of Toldregister = (R_NO,
  85. R_EAX,R_ECX,R_EDX,R_EBX,R_ESP,R_EBP,R_ESI,R_EDI,
  86. R_EAX,R_ECX,R_EDX,R_EBX,R_ESP,R_EBP,R_ESI,R_EDI,
  87. R_EAX,R_ECX,R_EDX,R_EBX,R_NO,R_NO,R_NO,R_NO,
  88. R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,
  89. R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,
  90. R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,
  91. R_NO,R_NO,R_NO,R_NO,
  92. R_NO,R_NO,R_NO,R_NO,R_NO,
  93. R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,
  94. R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO
  95. );
  96. reg2reg16 : array[firstreg..lastreg] of Toldregister = (R_NO,
  97. R_AX,R_CX,R_DX,R_BX,R_SP,R_BP,R_SI,R_DI,
  98. R_AX,R_CX,R_DX,R_BX,R_SP,R_BP,R_SI,R_DI,
  99. R_AX,R_CX,R_DX,R_BX,R_NO,R_NO,R_NO,R_NO,
  100. R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,
  101. R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,
  102. R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,
  103. R_NO,R_NO,R_NO,R_NO,
  104. R_NO,R_NO,R_NO,R_NO,R_NO,
  105. R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,
  106. R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO
  107. );
  108. reg2reg8 : array[firstreg..lastreg] of Toldregister = (R_NO,
  109. R_AL,R_CL,R_DL,R_BL,R_NO,R_NO,R_NO,R_NO,
  110. R_AL,R_CL,R_DL,R_BL,R_NO,R_NO,R_NO,R_NO,
  111. R_AL,R_CL,R_DL,R_BL,R_NO,R_NO,R_NO,R_NO,
  112. R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,
  113. R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,
  114. R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,
  115. R_NO,R_NO,R_NO,R_NO,
  116. R_NO,R_NO,R_NO,R_NO,R_NO,
  117. R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,
  118. R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO
  119. );
  120. { convert a register to a specfied register size }
  121. function changeregsize(r:tregister;size:topsize):tregister;
  122. var
  123. reg : tregister;
  124. begin
  125. case size of
  126. S_B :
  127. reg.enum:=reg2reg8[r.enum];
  128. S_W :
  129. reg.enum:=reg2reg16[r.enum];
  130. S_L :
  131. reg.enum:=reg2reg32[r.enum];
  132. else
  133. internalerror(200204101);
  134. end;
  135. if reg.enum=R_NO then
  136. internalerror(200204102);
  137. changeregsize:=reg;
  138. end;
  139. {************************************************************************}
  140. { trgcpu }
  141. {************************************************************************}
  142. {$ifdef newra}
  143. function Trgcpu.getregisterint(list:Taasmoutput;size:Tcgsize):Tregister;
  144. begin
  145. getregisterint:=inherited getregisterint(list,size);
  146. if size in [OS_8,OS_S8] then
  147. begin
  148. {These registers have no 8-bit subregister, so add interferences.}
  149. add_edge(getregisterint.number shr 8,RS_ESI);
  150. add_edge(getregisterint.number shr 8,RS_EDI);
  151. add_edge(getregisterint.number shr 8,RS_EBP);
  152. end;
  153. end;
  154. {$endif}
  155. {$ifndef newra}
  156. function trgcpu.getregisterint(list:Taasmoutput;size:Tcgsize):Tregister;
  157. var subreg:Tsubregister;
  158. begin
  159. subreg:=cgsize2subreg(size);
  160. if countunusedregsint=0 then
  161. internalerror(10);
  162. result.enum:=R_INTREGISTER;
  163. {$ifdef TEMPREGDEBUG}
  164. if curptree^.usableregsint-countunusedregsint>curptree^.registers32 then
  165. internalerror(10);
  166. {$endif TEMPREGDEBUG}
  167. {$ifdef EXTTEMPREGDEBUG}
  168. if curptree^.usableregs-countunusedregistersint>curptree^^.reallyusedregs then
  169. curptree^.reallyusedregs:=curptree^^.usableregs-countunusedregistersint;
  170. {$endif EXTTEMPREGDEBUG}
  171. if RS_EAX in unusedregsint then
  172. begin
  173. dec(countunusedregsint);
  174. exclude(unusedregsint,RS_EAX);
  175. include(usedintinproc,RS_EAX);
  176. result.number:=RS_EAX shl 8 or subreg;
  177. {$ifdef TEMPREGDEBUG}
  178. reg_user[R_EAX]:=curptree^;
  179. {$endif TEMPREGDEBUG}
  180. exprasmlist.concat(tai_regalloc.alloc(result));
  181. end
  182. else if RS_EDX in unusedregsint then
  183. begin
  184. dec(countunusedregsint);
  185. exclude(unusedregsint,RS_EDX);
  186. include(usedintinproc,RS_EDX);
  187. result.number:=RS_EDX shl 8 or subreg;
  188. {$ifdef TEMPREGDEBUG}
  189. reg_user[R_EDX]:=curptree^;
  190. {$endif TEMPREGDEBUG}
  191. exprasmlist.concat(tai_regalloc.alloc(result));
  192. end
  193. else if RS_EBX in unusedregsint then
  194. begin
  195. dec(countunusedregsint);
  196. exclude(unusedregsint,RS_EBX);
  197. include(usedintinproc,RS_EBX);
  198. result.number:=RS_EBX shl 8 or subreg;
  199. {$ifdef TEMPREGDEBUG}
  200. reg_user[R_EBX]:=curptree^;
  201. {$endif TEMPREGDEBUG}
  202. exprasmlist.concat(tai_regalloc.alloc(result));
  203. end
  204. else if RS_ECX in unusedregsint then
  205. begin
  206. dec(countunusedregsint);
  207. exclude(unusedregsint,RS_ECX);
  208. include(usedintinproc,RS_ECX);
  209. result.number:=RS_ECX shl 8 or subreg;
  210. {$ifdef TEMPREGDEBUG}
  211. reg_user[R_ECX]:=curptree^;
  212. {$endif TEMPREGDEBUG}
  213. exprasmlist.concat(tai_regalloc.alloc(result));
  214. end
  215. else
  216. internalerror(10);
  217. {$ifdef TEMPREGDEBUG}
  218. testregisters;
  219. {$endif TEMPREGDEBUG}
  220. end;
  221. function trgcpu.getaddressregister(list:Taasmoutput):Tregister;
  222. begin
  223. if countunusedregsaddr>0 then
  224. begin
  225. result.enum:=R_INTREGISTER;
  226. {$ifdef TEMPREGDEBUG}
  227. if curptree^.usableregsaddr-countunusedregsaddr>curptree^.registers32 then
  228. internalerror(10);
  229. {$endif TEMPREGDEBUG}
  230. {$ifdef EXTTEMPREGDEBUG}
  231. if curptree^.usableregs-countunusedregistersaddr>curptree^^.reallyusedregs then
  232. curptree^.reallyusedregs:=curptree^^.usableregs-countunusedregistersaddr;
  233. {$endif EXTTEMPREGDEBUG}
  234. if RS_ESI in unusedregsaddr then
  235. begin
  236. dec(countunusedregsaddr);
  237. exclude(unusedregsaddr,RS_ESI);
  238. include(usedaddrinproc,RS_ESI);
  239. result.number:=NR_ESI;
  240. {$ifdef TEMPREGDEBUG}
  241. reg_user[R_ESI]:=curptree^;
  242. {$endif TEMPREGDEBUG}
  243. exprasmlist.concat(tai_regalloc.alloc(result));
  244. end
  245. else
  246. internalerror(10);
  247. end
  248. else
  249. result:=getregisterint(list,OS_ADDR);
  250. end;
  251. procedure trgcpu.ungetregisterint(list: taasmoutput; r : tregister);
  252. var supreg:Tsuperregister;
  253. begin
  254. if r.enum=R_NO then
  255. exit;
  256. if r.enum<>R_INTREGISTER then
  257. internalerror(200301234);
  258. supreg:=r.number shr 8;
  259. if (supreg in [RS_EDI]) then
  260. begin
  261. list.concat(tai_regalloc.DeAlloc(r));
  262. exit;
  263. end;
  264. if not(supreg in [RS_EAX,RS_EBX,RS_ECX,RS_EDX,RS_ESI]) then
  265. exit;
  266. inherited ungetregisterint(list,r);
  267. end;
  268. function trgcpu.getexplicitregisterint(list:Taasmoutput;r:Tnewregister):Tregister;
  269. var r2:Tregister;
  270. begin
  271. if (r shr 8) in [RS_EDI] then
  272. begin
  273. r2.enum:=R_INTREGISTER;
  274. r2.number:=r;
  275. list.concat(Tai_regalloc.alloc(r2));
  276. getexplicitregisterint:=r2;
  277. exit;
  278. end;
  279. result:=inherited getexplicitregisterint(list,r);
  280. end;
  281. {$endif newra}
  282. function trgcpu.getregisterfpu(list: taasmoutput) : tregister;
  283. begin
  284. { note: don't return R_ST0, see comments above implementation of }
  285. { a_loadfpu_* methods in cgcpu (JM) }
  286. result.enum := R_ST;
  287. end;
  288. procedure trgcpu.ungetregisterfpu(list : taasmoutput; r : tregister);
  289. begin
  290. { nothing to do, fpu stack management is handled by the load/ }
  291. { store operations in cgcpu (JM) }
  292. end;
  293. procedure trgcpu.ungetreference(list: taasmoutput; const ref : treference);
  294. begin
  295. if (ref.base.number<>NR_NO) and (ref.base.number<>NR_FRAME_POINTER_REG) then
  296. ungetregisterint(list,ref.base);
  297. if (ref.index.number<>NR_NO) and (ref.index.number<>NR_FRAME_POINTER_REG) then
  298. ungetregisterint(list,ref.index);
  299. end;
  300. procedure trgcpu.pushusedintregisters(list:Taasmoutput;
  301. var pushed:Tpushedsavedint;
  302. const s:Tsupregset);
  303. var r:Tsuperregister;
  304. r2:Tregister;
  305. begin
  306. usedintinproc:=usedintinproc+s;
  307. for r:=firstsaveintreg to lastsaveintreg do
  308. begin
  309. r2.enum:=R_INTREGISTER;
  310. r2.number:=r shl 8 or R_SUBWHOLE;
  311. pushed[r].pushed:=false;
  312. { if the register is used by the calling subroutine }
  313. if not(r in is_reg_var_int) and (r in s) and
  314. { and is present in use }
  315. not(r in unusedregsint) then
  316. begin
  317. { then save it }
  318. list.concat(Taicpu.Op_reg(A_PUSH,S_L,r2));
  319. include(unusedregsint,r);
  320. {$ifndef newra}
  321. inc(countunusedregsint);
  322. {$endif}
  323. pushed[r].pushed:=true;
  324. end;
  325. end;
  326. {$ifdef TEMPREGDEBUG}
  327. testregisters;
  328. {$endif TEMPREGDEBUG}
  329. end;
  330. {$ifdef SUPPORT_MMX}
  331. procedure trgcpu.pushusedotherregisters(list:Taasmoutput;
  332. var pushed:Tpushedsaved;
  333. const s:Tregisterset);
  334. var r:Toldregister;
  335. r2:Tregister;
  336. hr:Treference;
  337. begin
  338. usedinproc:=usedinproc+s;
  339. for r:=R_MM0 to R_MM6 do
  340. begin
  341. pushed[r].pushed:=false;
  342. { if the register is used by the calling subroutine }
  343. if not is_reg_var[r] and
  344. (r in s) and
  345. { and is present in use }
  346. not(r in unusedregsmm) then
  347. begin
  348. r2.enum:=R_ESP;
  349. list.concat(Taicpu.Op_const_reg(A_SUB,S_L,8,r2));
  350. reference_reset_base(hr,r2,0);
  351. r2.enum:=r;
  352. list.concat(Taicpu.Op_reg_ref(A_MOVQ,S_NO,r2,hr));
  353. include(unusedregsmm,r);
  354. {$ifndef newra}
  355. inc(countunusedregsmm);
  356. {$endif}
  357. pushed[r].pushed:=true;
  358. end;
  359. end;
  360. {$ifdef TEMPREGDEBUG}
  361. testregisters;
  362. {$endif TEMPREGDEBUG}
  363. end;
  364. {$endif SUPPORT_MMX}
  365. procedure trgcpu.popusedintregisters(list:Taasmoutput;
  366. const pushed:Tpushedsavedint);
  367. var r:Tsuperregister;
  368. r2:Tregister;
  369. begin
  370. { restore in reverse order: }
  371. for r:=lastsaveintreg downto firstsaveintreg do
  372. if pushed[r].pushed then
  373. begin
  374. r2.enum:=R_INTREGISTER;
  375. r2.number:=r shl 8 or R_SUBWHOLE;
  376. list.concat(Taicpu.op_reg(A_POP,S_L,r2));
  377. if not (r in unusedregsint) then
  378. { internalerror(10)
  379. in cg386cal we always restore regs
  380. that appear as used
  381. due to a unused tmep storage PM }
  382. else
  383. {$ifndef newra}dec(countunusedregsint){$endif};
  384. exclude(unusedregsint,r);
  385. end;
  386. {$ifdef TEMPREGDEBUG}
  387. testregisters;
  388. {$endif TEMPREGDEBUG}
  389. end;
  390. {$ifdef SUPPORT_MMX}
  391. procedure trgcpu.popusedotherregisters(list:Taasmoutput;
  392. const pushed:Tpushedsaved);
  393. var r:Toldregister;
  394. r2,r3:Tregister;
  395. hr:Treference;
  396. begin
  397. { restore in reverse order: }
  398. for r:=R_MM6 downto R_MM0 do
  399. if pushed[r].pushed then
  400. begin
  401. r2.enum:=R_ESP;
  402. reference_reset_base(hr,r2,0);
  403. r3.enum:=r;
  404. list.concat(Taicpu.op_ref_reg(A_MOVQ,S_NO,hr,r3));
  405. list.concat(Taicpu.op_const_reg(A_ADD,S_L,8,r2));
  406. if not (r in unusedregsmm) then
  407. { internalerror(10)
  408. in cg386cal we always restore regs
  409. that appear as used
  410. due to a unused tmep storage PM }
  411. else
  412. {$ifndef newra}dec(countunusedregsmm){$endif};
  413. exclude(unusedregsmm,r);
  414. end;
  415. {$ifdef TEMPREGDEBUG}
  416. testregisters;
  417. {$endif TEMPREGDEBUG}
  418. end;
  419. {$endif SUPPORT_MMX}
  420. procedure trgcpu.saveusedintregisters(list:Taasmoutput;
  421. var saved:Tpushedsavedint;
  422. const s:Tsupregset);
  423. begin
  424. if (aktoptprocessor in [class386,classP5]) or
  425. (CS_LittleSize in aktglobalswitches) then
  426. pushusedintregisters(list,saved,s)
  427. else
  428. inherited saveusedintregisters(list,saved,s);
  429. end;
  430. procedure trgcpu.saveusedotherregisters(list:Taasmoutput;var saved:Tpushedsaved;
  431. const s:tregisterset);
  432. begin
  433. {$ifdef SUPPORT_MMX}
  434. if (aktoptprocessor in [class386,classP5]) or
  435. (CS_LittleSize in aktglobalswitches) then
  436. pushusedotherregisters(list,saved,s)
  437. else
  438. {$endif SUPPORT_MMX}
  439. inherited saveusedotherregisters(list,saved,s);
  440. end;
  441. procedure trgcpu.restoreusedintregisters(list:Taasmoutput;
  442. const saved:tpushedsavedint);
  443. begin
  444. if (aktoptprocessor in [class386,classP5]) or
  445. (CS_LittleSize in aktglobalswitches) then
  446. popusedintregisters(list,saved)
  447. else
  448. inherited restoreusedintregisters(list,saved);
  449. end;
  450. procedure trgcpu.restoreusedotherregisters(list:Taasmoutput;
  451. const saved:tpushedsaved);
  452. begin
  453. {$ifdef SUPPORT_MMX}
  454. if (aktoptprocessor in [class386,classP5]) or
  455. (CS_LittleSize in aktglobalswitches) then
  456. popusedotherregisters(list,saved)
  457. else
  458. {$endif SUPPORT_MMX}
  459. inherited restoreusedotherregisters(list,saved);
  460. end;
  461. procedure trgcpu.resetusableregisters;
  462. begin
  463. inherited resetusableregisters;
  464. fpuvaroffset := 0;
  465. end;
  466. function trgcpu.correct_fpuregister(r : tregister;ofs : byte) : tregister;
  467. begin
  468. correct_fpuregister.enum:=Toldregister(longint(r.enum)+ofs);
  469. end;
  470. function trgcpu.makeregsize(reg: tregister; size: tcgsize): tregister;
  471. var
  472. _result : topsize;
  473. begin
  474. case size of
  475. OS_32,OS_S32:
  476. begin
  477. _result := S_L;
  478. end;
  479. OS_8,OS_S8:
  480. begin
  481. _result := S_B;
  482. end;
  483. OS_16,OS_S16:
  484. begin
  485. _result := S_W;
  486. end;
  487. else
  488. internalerror(2001092312);
  489. end;
  490. makeregsize := changeregsize(reg,_result);
  491. end;
  492. initialization
  493. rg := trgcpu.create(7); {We use 7 int registers on i386.}
  494. end.
  495. {
  496. $Log$
  497. Revision 1.21 2003-04-25 08:25:26 daniel
  498. * Ifdefs around a lot of calls to cleartempgen
  499. * Fixed registers that are allocated but not freed in several nodes
  500. * Tweak to register allocator to cause less spills
  501. * 8-bit registers now interfere with esi,edi and ebp
  502. Compiler can now compile rtl successfully when using new register
  503. allocator
  504. Revision 1.20 2003/04/23 14:42:08 daniel
  505. * Further register allocator work. Compiler now smaller with new
  506. allocator than without.
  507. * Somebody forgot to adjust ppu version number
  508. Revision 1.19 2003/04/22 10:09:35 daniel
  509. + Implemented the actual register allocator
  510. + Scratch registers unavailable when new register allocator used
  511. + maybe_save/maybe_restore unavailable when new register allocator used
  512. Revision 1.18 2003/04/21 19:16:50 peter
  513. * count address regs separate
  514. Revision 1.17 2003/03/28 19:16:57 peter
  515. * generic constructor working for i386
  516. * remove fixed self register
  517. * esi added as address register for i386
  518. Revision 1.16 2003/03/17 15:52:57 peter
  519. * SUPPORT_MMX define compile fix
  520. Revision 1.15 2003/03/08 13:59:17 daniel
  521. * Work to handle new register notation in ag386nsm
  522. + Added newra version of Ti386moddivnode
  523. Revision 1.14 2003/03/08 08:59:07 daniel
  524. + $define newra will enable new register allocator
  525. + getregisterint will return imaginary registers with $newra
  526. + -sr switch added, will skip register allocation so you can see
  527. the direct output of the code generator before register allocation
  528. Revision 1.13 2003/03/07 21:57:53 daniel
  529. * Improved getregisterint
  530. Revision 1.12 2003/02/19 22:00:16 daniel
  531. * Code generator converted to new register notation
  532. - Horribily outdated todo.txt removed
  533. Revision 1.11 2003/01/08 18:43:57 daniel
  534. * Tregister changed into a record
  535. Revision 1.10 2002/10/05 12:43:29 carl
  536. * fixes for Delphi 6 compilation
  537. (warning : Some features do not work under Delphi)
  538. Revision 1.9 2002/08/17 09:23:48 florian
  539. * first part of procinfo rewrite
  540. Revision 1.8 2002/07/01 18:46:34 peter
  541. * internal linker
  542. * reorganized aasm layer
  543. Revision 1.7 2002/05/16 19:46:52 carl
  544. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  545. + try to fix temp allocation (still in ifdef)
  546. + generic constructor calls
  547. + start of tassembler / tmodulebase class cleanup
  548. Revision 1.6 2002/05/12 16:53:18 peter
  549. * moved entry and exitcode to ncgutil and cgobj
  550. * foreach gets extra argument for passing local data to the
  551. iterator function
  552. * -CR checks also class typecasts at runtime by changing them
  553. into as
  554. * fixed compiler to cycle with the -CR option
  555. * fixed stabs with elf writer, finally the global variables can
  556. be watched
  557. * removed a lot of routines from cga unit and replaced them by
  558. calls to cgobj
  559. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  560. u32bit then the other is typecasted also to u32bit without giving
  561. a rangecheck warning/error.
  562. * fixed pascal calling method with reversing also the high tree in
  563. the parast, detected by tcalcst3 test
  564. Revision 1.5 2002/04/21 15:43:32 carl
  565. * changeregsize -> rg.makeregsize
  566. * changeregsize moved from cpubase to here
  567. Revision 1.4 2002/04/15 19:44:22 peter
  568. * fixed stackcheck that would be called recursively when a stack
  569. error was found
  570. * generic changeregsize(reg,size) for i386 register resizing
  571. * removed some more routines from cga unit
  572. * fixed returnvalue handling
  573. * fixed default stacksize of linux and go32v2, 8kb was a bit small :-)
  574. Revision 1.3 2002/04/04 19:06:13 peter
  575. * removed unused units
  576. * use tlocation.size in cg.a_*loc*() routines
  577. Revision 1.2 2002/04/02 17:11:39 peter
  578. * tlocation,treference update
  579. * LOC_CONSTANT added for better constant handling
  580. * secondadd splitted in multiple routines
  581. * location_force_reg added for loading a location to a register
  582. of a specified size
  583. * secondassignment parses now first the right and then the left node
  584. (this is compatible with Kylix). This saves a lot of push/pop especially
  585. with string operations
  586. * adapted some routines to use the new cg methods
  587. Revision 1.1 2002/03/31 20:26:40 jonas
  588. + a_loadfpu_* and a_loadmm_* methods in tcg
  589. * register allocation is now handled by a class and is mostly processor
  590. independent (+rgobj.pas and i386/rgcpu.pas)
  591. * temp allocation is now handled by a class (+tgobj.pas, -i386\tgcpu.pas)
  592. * some small improvements and fixes to the optimizer
  593. * some register allocation fixes
  594. * some fpuvaroffset fixes in the unary minus node
  595. * push/popusedregisters is now called rg.save/restoreusedregisters and
  596. (for i386) uses temps instead of push/pop's when using -Op3 (that code is
  597. also better optimizable)
  598. * fixed and optimized register saving/restoring for new/dispose nodes
  599. * LOC_FPU locations now also require their "register" field to be set to
  600. R_ST, not R_ST0 (the latter is used for LOC_CFPUREGISTER locations only)
  601. - list field removed of the tnode class because it's not used currently
  602. and can cause hard-to-find bugs
  603. }