cpubase.pas 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl and Peter Vreman
  4. Contains the base types for the i386 and x86-64 architecture
  5. * This code was inspired by the NASM sources
  6. The Netwide Assembler is Copyright (c) 1996 Simon Tatham and
  7. Julian Hall. All rights reserved.
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. ****************************************************************************
  20. }
  21. {# Base unit for processor information. This unit contains
  22. enumerations of registers, opcodes, sizes, and other
  23. such things which are processor specific.
  24. }
  25. unit cpubase;
  26. {$i fpcdefs.inc}
  27. interface
  28. uses
  29. cutils,cclasses,
  30. globtype,globals,
  31. cpuinfo,
  32. aasmbase,
  33. cgbase
  34. {$ifdef delphi}
  35. ,dmisc
  36. {$endif}
  37. ;
  38. {*****************************************************************************
  39. Assembler Opcodes
  40. *****************************************************************************}
  41. type
  42. {$ifdef x86_64}
  43. TAsmOp={$i x8664op.inc}
  44. {$else x86_64}
  45. TAsmOp={$i i386op.inc}
  46. {$endif x86_64}
  47. { This should define the array of instructions as string }
  48. op2strtable=array[tasmop] of string[11];
  49. const
  50. { First value of opcode enumeration }
  51. firstop = low(tasmop);
  52. { Last value of opcode enumeration }
  53. lastop = high(tasmop);
  54. {*****************************************************************************
  55. Registers
  56. *****************************************************************************}
  57. const
  58. { Invalid register number }
  59. RS_INVALID = $ff;
  60. { Integer Super registers }
  61. RS_RAX = $00; {EAX}
  62. RS_RCX = $01; {ECX}
  63. RS_RDX = $02; {EDX}
  64. RS_RBX = $03; {EBX}
  65. RS_RSI = $04; {ESI}
  66. RS_RDI = $05; {EDI}
  67. RS_RBP = $06; {EBP}
  68. RS_RSP = $07; {ESP}
  69. RS_R8 = $08; {R8}
  70. RS_R9 = $09; {R9}
  71. RS_R10 = $0a; {R10}
  72. RS_R11 = $0b; {R11}
  73. RS_R12 = $0c; {R12}
  74. RS_R13 = $0d; {R13}
  75. RS_R14 = $0e; {R14}
  76. RS_R15 = $0f; {R15}
  77. { create aliases to allow code sharing between x86-64 and i386 }
  78. RS_EAX = RS_RAX;
  79. RS_EBX = RS_RBX;
  80. RS_ECX = RS_RCX;
  81. RS_EDX = RS_RDX;
  82. RS_ESI = RS_RSI;
  83. RS_EDI = RS_RDI;
  84. RS_EBP = RS_RBP;
  85. RS_ESP = RS_RSP;
  86. { Number of first imaginary register }
  87. first_int_imreg = $10;
  88. { Float Super registers }
  89. RS_ST0 = $00;
  90. RS_ST1 = $01;
  91. RS_ST2 = $02;
  92. RS_ST3 = $03;
  93. RS_ST4 = $04;
  94. RS_ST5 = $05;
  95. RS_ST6 = $06;
  96. RS_ST7 = $07;
  97. { Number of first imaginary register }
  98. first_fpu_imreg = $08;
  99. { MM Super registers }
  100. RS_XMM0 = $00;
  101. RS_XMM1 = $01;
  102. RS_XMM2 = $02;
  103. RS_XMM3 = $03;
  104. RS_XMM4 = $04;
  105. RS_XMM5 = $05;
  106. RS_XMM6 = $06;
  107. RS_XMM7 = $07;
  108. RS_XMM8 = $08;
  109. RS_XMM9 = $09;
  110. RS_XMM10 = $0a;
  111. RS_XMM11 = $0b;
  112. RS_XMM12 = $0c;
  113. RS_XMM13 = $0d;
  114. RS_XMM14 = $0e;
  115. RS_XMM15 = $0f;
  116. { Number of first imaginary register }
  117. {$ifdef x86_64}
  118. first_sse_imreg = $10;
  119. {$else x86_64}
  120. first_sse_imreg = $08;
  121. {$endif x86_64}
  122. { The subregister that specifies the entire register }
  123. {$ifdef x86_64}
  124. R_SUBWHOLE = R_SUBQ; {Hammer}
  125. {$else x86_64}
  126. R_SUBWHOLE = R_SUBD; {i386}
  127. {$endif x86_64}
  128. { Available Registers }
  129. {$ifdef x86_64}
  130. {$i r8664con.inc}
  131. {$else x86_64}
  132. {$i r386con.inc}
  133. {$endif x86_64}
  134. type
  135. { Number of registers used for indexing in tables }
  136. {$ifdef x86_64}
  137. tregisterindex=0..{$i r8664nor.inc}-1;
  138. {$else x86_64}
  139. tregisterindex=0..{$i r386nor.inc}-1;
  140. {$endif x86_64}
  141. const
  142. {$warning TODO Calculate bsstart}
  143. regnumber_count_bsstart = 64;
  144. regnumber_table : array[tregisterindex] of tregister = (
  145. {$ifdef x86_64}
  146. {$i r8664num.inc}
  147. {$else x86_64}
  148. {$i r386num.inc}
  149. {$endif x86_64}
  150. );
  151. regstabs_table : array[tregisterindex] of shortint = (
  152. {$ifdef x86_64}
  153. {$i r8664stab.inc}
  154. {$else x86_64}
  155. {$i r386stab.inc}
  156. {$endif x86_64}
  157. );
  158. type
  159. totherregisterset = set of tregisterindex;
  160. {*****************************************************************************
  161. Conditions
  162. *****************************************************************************}
  163. type
  164. TAsmCond=(C_None,
  165. C_A,C_AE,C_B,C_BE,C_C,C_E,C_G,C_GE,C_L,C_LE,C_NA,C_NAE,
  166. C_NB,C_NBE,C_NC,C_NE,C_NG,C_NGE,C_NL,C_NLE,C_NO,C_NP,
  167. C_NS,C_NZ,C_O,C_P,C_PE,C_PO,C_S,C_Z
  168. );
  169. const
  170. cond2str:array[TAsmCond] of string[3]=('',
  171. 'a','ae','b','be','c','e','g','ge','l','le','na','nae',
  172. 'nb','nbe','nc','ne','ng','nge','nl','nle','no','np',
  173. 'ns','nz','o','p','pe','po','s','z'
  174. );
  175. inverse_cond:array[TAsmCond] of TAsmCond=(C_None,
  176. C_NA,C_NAE,C_NB,C_NBE,C_NC,C_NE,C_NG,C_NGE,C_NL,C_NLE,C_A,C_AE,
  177. C_B,C_BE,C_C,C_E,C_G,C_GE,C_L,C_LE,C_O,C_P,
  178. C_S,C_Z,C_NO,C_NP,C_NP,C_P,C_NS,C_NZ
  179. );
  180. {*****************************************************************************
  181. Flags
  182. *****************************************************************************}
  183. type
  184. TResFlags = (F_E,F_NE,F_G,F_L,F_GE,F_LE,F_C,F_NC,
  185. F_A,F_AE,F_B,F_BE,
  186. F_S,F_NS,F_O,F_NO);
  187. {*****************************************************************************
  188. Reference
  189. *****************************************************************************}
  190. type
  191. { reference record }
  192. preference = ^treference;
  193. treference = record
  194. segment,
  195. base,
  196. index : tregister;
  197. scalefactor : byte;
  198. offset : longint;
  199. symbol : tasmsymbol;
  200. end;
  201. { reference record }
  202. pparareference = ^tparareference;
  203. tparareference = packed record
  204. index : tregister;
  205. offset : longint;
  206. end;
  207. {*****************************************************************************
  208. Generic Location
  209. *****************************************************************************}
  210. type
  211. { tparamlocation describes where a parameter for a procedure is stored.
  212. References are given from the caller's point of view. The usual
  213. TLocation isn't used, because contains a lot of unnessary fields.
  214. }
  215. tparalocation = record
  216. size : TCGSize;
  217. loc : TCGLoc;
  218. { Location type of registerhigh, for x86_64 this can
  219. be different from loc when pushing structures of 16 bytes }
  220. lochigh : TCGLoc;
  221. alignment : byte;
  222. case TCGLoc of
  223. LOC_REFERENCE : (reference : tparareference);
  224. { segment in reference at the same place as in loc_register }
  225. LOC_REGISTER,LOC_CREGISTER : (
  226. case longint of
  227. 1 : (register,registerhigh : tregister);
  228. { overlay a registerlow }
  229. 2 : (registerlow : tregister);
  230. {$ifndef cpu64bit}
  231. { overlay a 64 Bit register type }
  232. 3 : (register64 : tregister64);
  233. {$endif cpu64bit}
  234. );
  235. { it's only for better handling }
  236. LOC_MMXREGISTER,LOC_CMMXREGISTER : (
  237. case longint of
  238. 0: (mmxreg : tregister);
  239. 1: (mmxregset : Tregistermmxset);
  240. );
  241. end;
  242. tlocation = packed record
  243. loc : TCGLoc;
  244. size : TCGSize;
  245. case TCGLoc of
  246. LOC_FLAGS : (resflags : tresflags);
  247. LOC_CONSTANT : (
  248. case longint of
  249. 1 : (value : AWord);
  250. { can't do this, this layout depends on the host cpu. Use }
  251. { lo(valueqword)/hi(valueqword) instead (JM) }
  252. { 2 : (valuelow, valuehigh:AWord); }
  253. { overlay a complete 64 Bit value }
  254. 3 : (valueqword : qword);
  255. );
  256. LOC_CREFERENCE,
  257. LOC_REFERENCE : (reference : treference);
  258. { segment in reference at the same place as in loc_register }
  259. LOC_REGISTER,LOC_CREGISTER : (
  260. case longint of
  261. 1 : (register,registerhigh,segment : tregister);
  262. { overlay a registerlow }
  263. 2 : (registerlow : tregister);
  264. { overlay a 64 Bit register type }
  265. 3 : (reg64 : tregister64);
  266. 4 : (register64 : tregister64);
  267. );
  268. { it's only for better handling }
  269. LOC_MMXREGISTER,LOC_CMMXREGISTER : (mmxreg : tregister);
  270. end;
  271. {*****************************************************************************
  272. Constants
  273. *****************************************************************************}
  274. const
  275. { declare aliases }
  276. LOC_SSEREGISTER = LOC_MMREGISTER;
  277. LOC_CSSEREGISTER = LOC_CMMREGISTER;
  278. max_operands = 3;
  279. maxfpuregs = 8;
  280. {*****************************************************************************
  281. CPU Dependent Constants
  282. *****************************************************************************}
  283. {$i cpubase.inc}
  284. {*****************************************************************************
  285. Helpers
  286. *****************************************************************************}
  287. function cgsize2subreg(s:Tcgsize):Tsubregister;
  288. function reg2opsize(r:Tregister):topsize;
  289. function is_calljmp(o:tasmop):boolean;
  290. procedure inverse_flags(var f: TResFlags);
  291. function flags_to_cond(const f: TResFlags) : TAsmCond;
  292. function is_segment_reg(r:tregister):boolean;
  293. function findreg_by_number(r:Tregister):tregisterindex;
  294. function std_regnum_search(const s:string):Tregister;
  295. function std_regname(r:Tregister):string;
  296. implementation
  297. uses
  298. rgbase,verbose;
  299. const
  300. {$ifdef x86_64}
  301. std_regname_table : array[tregisterindex] of string[7] = (
  302. {$i r8664std.inc}
  303. );
  304. regnumber_index : array[tregisterindex] of tregisterindex = (
  305. {$i r8664rni.inc}
  306. );
  307. std_regname_index : array[tregisterindex] of tregisterindex = (
  308. {$i r8664sri.inc}
  309. );
  310. {$else x86_64}
  311. std_regname_table : array[tregisterindex] of string[7] = (
  312. {$i r386std.inc}
  313. );
  314. regnumber_index : array[tregisterindex] of tregisterindex = (
  315. {$i r386rni.inc}
  316. );
  317. std_regname_index : array[tregisterindex] of tregisterindex = (
  318. {$i r386sri.inc}
  319. );
  320. {$endif x86_64}
  321. {*****************************************************************************
  322. Helpers
  323. *****************************************************************************}
  324. function cgsize2subreg(s:Tcgsize):Tsubregister;
  325. begin
  326. case s of
  327. OS_8,OS_S8:
  328. cgsize2subreg:=R_SUBL;
  329. OS_16,OS_S16:
  330. cgsize2subreg:=R_SUBW;
  331. OS_32,OS_S32:
  332. cgsize2subreg:=R_SUBD;
  333. OS_64,OS_S64:
  334. cgsize2subreg:=R_SUBQ;
  335. OS_M64:
  336. cgsize2subreg:=R_SUBNONE;
  337. OS_F32,OS_F64,
  338. OS_M128,OS_MS128:
  339. cgsize2subreg:=R_SUBWHOLE;
  340. else
  341. internalerror(200301231);
  342. end;
  343. end;
  344. function reg2opsize(r:Tregister):topsize;
  345. const
  346. subreg2opsize : array[tsubregister] of topsize =
  347. (S_NO,S_B,S_B,S_W,S_L,S_Q,S_NO,S_NO);
  348. begin
  349. reg2opsize:=S_L;
  350. case getregtype(r) of
  351. R_INTREGISTER :
  352. reg2opsize:=subreg2opsize[getsubreg(r)];
  353. R_FPUREGISTER :
  354. reg2opsize:=S_FL;
  355. R_MMXREGISTER,
  356. R_MMREGISTER :
  357. reg2opsize:=S_MD;
  358. R_SPECIALREGISTER :
  359. begin
  360. case r of
  361. NR_CS,NR_DS,NR_ES,
  362. NR_SS,NR_FS,NR_GS :
  363. reg2opsize:=S_W;
  364. end;
  365. end;
  366. else
  367. internalerror(200303181);
  368. end;
  369. end;
  370. function is_calljmp(o:tasmop):boolean;
  371. begin
  372. case o of
  373. A_CALL,
  374. A_JCXZ,
  375. A_JECXZ,
  376. A_JMP,
  377. A_LOOP,
  378. A_LOOPE,
  379. A_LOOPNE,
  380. A_LOOPNZ,
  381. A_LOOPZ,
  382. A_Jcc :
  383. is_calljmp:=true;
  384. else
  385. is_calljmp:=false;
  386. end;
  387. end;
  388. procedure inverse_flags(var f: TResFlags);
  389. const
  390. inv_flags: array[TResFlags] of TResFlags =
  391. (F_NE,F_E,F_LE,F_GE,F_L,F_G,F_NC,F_C,
  392. F_BE,F_B,F_AE,F_A,
  393. F_NS,F_S,F_NO,F_O);
  394. begin
  395. f:=inv_flags[f];
  396. end;
  397. function flags_to_cond(const f: TResFlags) : TAsmCond;
  398. const
  399. flags_2_cond : array[TResFlags] of TAsmCond =
  400. (C_E,C_NE,C_G,C_L,C_GE,C_LE,C_C,C_NC,C_A,C_AE,C_B,C_BE,C_S,C_NS,C_O,C_NO);
  401. begin
  402. result := flags_2_cond[f];
  403. end;
  404. function is_segment_reg(r:tregister):boolean;
  405. begin
  406. result:=false;
  407. case r of
  408. NR_CS,NR_DS,NR_ES,
  409. NR_SS,NR_FS,NR_GS :
  410. result:=true;
  411. end;
  412. end;
  413. function findreg_by_number(r:Tregister):tregisterindex;
  414. begin
  415. result:=findreg_by_number_table(r,regnumber_index);
  416. end;
  417. function std_regnum_search(const s:string):Tregister;
  418. begin
  419. result:=regnumber_table[findreg_by_name_table(s,std_regname_table,std_regname_index)];
  420. end;
  421. function std_regname(r:Tregister):string;
  422. var
  423. p : tregisterindex;
  424. begin
  425. p:=findreg_by_number_table(r,regnumber_index);
  426. if p<>0 then
  427. result:=std_regname_table[p]
  428. else
  429. result:=generic_regname(r);
  430. end;
  431. end.
  432. {
  433. $Log$
  434. Revision 1.41 2004-02-22 18:27:21 florian
  435. * fixed exception reason size for 64 bit systems
  436. Revision 1.40 2004/02/05 18:28:37 peter
  437. * x86_64 fixes for opsize
  438. Revision 1.39 2004/02/04 22:01:13 peter
  439. * first try to get cpupara working for x86_64
  440. Revision 1.38 2004/01/30 13:42:03 florian
  441. * fixed more alignment issues
  442. Revision 1.37 2004/01/15 14:01:32 florian
  443. + x86 instruction tables for x86-64 extended
  444. Revision 1.36 2004/01/14 23:39:05 florian
  445. * another bunch of x86-64 fixes mainly calling convention and
  446. assembler reader related
  447. Revision 1.35 2004/01/12 16:37:59 peter
  448. * moved spilling code from taicpu to rg
  449. Revision 1.34 2003/12/26 13:19:16 florian
  450. * rtl and compiler compile with -Cfsse2
  451. Revision 1.33 2003/12/25 01:07:09 florian
  452. + $fputype directive support
  453. + single data type operations with sse unit
  454. * fixed more x86-64 stuff
  455. Revision 1.32 2003/12/19 22:08:44 daniel
  456. * Some work to restore the MMX capabilities
  457. Revision 1.31 2003/12/15 21:25:49 peter
  458. * reg allocations for imaginary register are now inserted just
  459. before reg allocation
  460. * tregister changed to enum to allow compile time check
  461. * fixed several tregister-tsuperregister errors
  462. Revision 1.30 2003/10/31 09:22:55 mazen
  463. * using findreg_by_<name|number>_table directly to decrease heap overheading
  464. Revision 1.29 2003/10/30 17:13:18 peter
  465. * fixed findreg_by_number
  466. * renamed rghelper to rgbase
  467. Revision 1.28 2003/10/30 15:03:18 mazen
  468. * now uses standard routines in rgHelper unit to search registers by number and by name
  469. Revision 1.27 2003/10/17 15:08:34 peter
  470. * commented out more obsolete constants
  471. Revision 1.26 2003/10/17 14:38:32 peter
  472. * 64k registers supported
  473. * fixed some memory leaks
  474. Revision 1.25 2003/10/11 16:06:42 florian
  475. * fixed some MMX<->SSE
  476. * started to fix ppc, needs an overhaul
  477. + stabs info improve for spilling, not sure if it works correctly/completly
  478. - MMX_SUPPORT removed from Makefile.fpc
  479. Revision 1.24 2003/10/09 21:31:37 daniel
  480. * Register allocator splitted, ans abstract now
  481. Revision 1.23 2003/10/03 22:00:33 peter
  482. * parameter alignment fixes
  483. Revision 1.22 2003/10/01 20:34:51 peter
  484. * procinfo unit contains tprocinfo
  485. * cginfo renamed to cgbase
  486. * moved cgmessage to verbose
  487. * fixed ppc and sparc compiles
  488. Revision 1.21 2003/09/28 21:49:39 peter
  489. * removed emitjmp
  490. Revision 1.20 2003/09/25 21:29:23 peter
  491. * remove sp_fixup
  492. Revision 1.19 2003/09/24 17:12:36 florian
  493. * x86-64 adaptions
  494. Revision 1.18 2003/09/23 17:56:06 peter
  495. * locals and paras are allocated in the code generation
  496. * tvarsym.localloc contains the location of para/local when
  497. generating code for the current procedure
  498. Revision 1.17 2003/09/07 22:09:35 peter
  499. * preparations for different default calling conventions
  500. * various RA fixes
  501. Revision 1.16 2003/09/04 21:07:03 florian
  502. * ARM compiler compiles again
  503. Revision 1.15 2003/09/03 15:55:02 peter
  504. * NEWRA branch merged
  505. Revision 1.14 2003/09/03 11:18:37 florian
  506. * fixed arm concatcopy
  507. + arm support in the common compiler sources added
  508. * moved some generic cg code around
  509. + tfputype added
  510. * ...
  511. Revision 1.13.2.8 2003/08/31 19:31:51 daniel
  512. * FIxed superregister constants
  513. Revision 1.13.2.7 2003/08/31 16:18:05 peter
  514. * more fixes
  515. Revision 1.13.2.6 2003/08/31 15:46:26 peter
  516. * more updates for tregister
  517. Revision 1.13.2.5 2003/08/31 13:50:16 daniel
  518. * Remove sorting and use pregenerated indexes
  519. * Some work on making things compile
  520. Revision 1.13.2.4 2003/08/29 17:29:00 peter
  521. * next batch of updates
  522. Revision 1.13.2.3 2003/08/28 18:35:08 peter
  523. * tregister changed to cardinal
  524. Revision 1.13.2.2 2003/08/27 21:06:34 peter
  525. * more updates
  526. Revision 1.13.2.1 2003/08/27 19:55:54 peter
  527. * first tregister patch
  528. Revision 1.13 2003/08/20 07:48:04 daniel
  529. * Made internal assembler use new register coding
  530. Revision 1.12 2003/08/17 16:59:20 jonas
  531. * fixed regvars so they work with newra (at least for ppc)
  532. * fixed some volatile register bugs
  533. + -dnotranslation option for -dnewra, which causes the registers not to
  534. be translated from virtual to normal registers. Requires support in
  535. the assembler writer as well, which is only implemented in aggas/
  536. agppcgas currently
  537. Revision 1.11 2003/07/06 21:50:33 jonas
  538. * fixed ppc compilation problems and changed VOLATILE_REGISTERS for x86
  539. so that it doesn't include ebp and esp anymore
  540. Revision 1.10 2003/06/17 16:34:45 jonas
  541. * lots of newra fixes (need getfuncretparaloc implementation for i386)!
  542. * renamed all_intregisters to volatile_intregisters and made it
  543. processor dependent
  544. Revision 1.9 2003/06/13 21:19:33 peter
  545. * current_procdef removed, use current_procinfo.procdef instead
  546. Revision 1.8 2003/06/12 19:11:34 jonas
  547. - removed ALL_INTREGISTERS (only the one in rgobj is valid)
  548. Revision 1.7 2003/06/03 21:11:09 peter
  549. * cg.a_load_* get a from and to size specifier
  550. * makeregsize only accepts newregister
  551. * i386 uses generic tcgnotnode,tcgunaryminus
  552. Revision 1.6 2003/06/03 13:01:59 daniel
  553. * Register allocator finished
  554. Revision 1.5 2003/05/30 23:57:08 peter
  555. * more sparc cleanup
  556. * accumulator removed, splitted in function_return_reg (called) and
  557. function_result_reg (caller)
  558. Revision 1.4 2003/04/30 20:53:32 florian
  559. * error when address of an abstract method is taken
  560. * fixed some x86-64 problems
  561. * merged some more x86-64 and i386 code
  562. Revision 1.3 2002/04/25 20:15:40 florian
  563. * block nodes within expressions shouldn't release the used registers,
  564. fixed using a flag till the new rg is ready
  565. Revision 1.2 2002/04/25 16:12:09 florian
  566. * fixed more problems with cpubase and x86-64
  567. Revision 1.1 2003/04/25 11:12:09 florian
  568. * merged i386/cpubase and x86_64/cpubase to x86/cpubase;
  569. different stuff went to cpubase.inc
  570. Revision 1.50 2003/04/25 08:25:26 daniel
  571. * Ifdefs around a lot of calls to cleartempgen
  572. * Fixed registers that are allocated but not freed in several nodes
  573. * Tweak to register allocator to cause less spills
  574. * 8-bit registers now interfere with esi,edi and ebp
  575. Compiler can now compile rtl successfully when using new register
  576. allocator
  577. Revision 1.49 2003/04/22 23:50:23 peter
  578. * firstpass uses expectloc
  579. * checks if there are differences between the expectloc and
  580. location.loc from secondpass in EXTDEBUG
  581. Revision 1.48 2003/04/22 14:33:38 peter
  582. * removed some notes/hints
  583. Revision 1.47 2003/04/22 10:09:35 daniel
  584. + Implemented the actual register allocator
  585. + Scratch registers unavailable when new register allocator used
  586. + maybe_save/maybe_restore unavailable when new register allocator used
  587. Revision 1.46 2003/04/21 19:16:50 peter
  588. * count address regs separate
  589. Revision 1.45 2003/03/28 19:16:57 peter
  590. * generic constructor working for i386
  591. * remove fixed self register
  592. * esi added as address register for i386
  593. Revision 1.44 2003/03/18 18:15:53 peter
  594. * changed reg2opsize to function
  595. Revision 1.43 2003/03/08 08:59:07 daniel
  596. + $define newra will enable new register allocator
  597. + getregisterint will return imaginary registers with $newra
  598. + -sr switch added, will skip register allocation so you can see
  599. the direct output of the code generator before register allocation
  600. Revision 1.42 2003/02/19 22:00:15 daniel
  601. * Code generator converted to new register notation
  602. - Horribily outdated todo.txt removed
  603. Revision 1.41 2003/02/02 19:25:54 carl
  604. * Several bugfixes for m68k target (register alloc., opcode emission)
  605. + VIS target
  606. + Generic add more complete (still not verified)
  607. Revision 1.40 2003/01/13 18:37:44 daniel
  608. * Work on register conversion
  609. Revision 1.39 2003/01/09 20:41:00 daniel
  610. * Converted some code in cgx86.pas to new register numbering
  611. Revision 1.38 2003/01/09 15:49:56 daniel
  612. * Added register conversion
  613. Revision 1.37 2003/01/08 22:32:36 daniel
  614. * Added register convesrion procedure
  615. Revision 1.36 2003/01/08 18:43:57 daniel
  616. * Tregister changed into a record
  617. Revision 1.35 2003/01/05 13:36:53 florian
  618. * x86-64 compiles
  619. + very basic support for float128 type (x86-64 only)
  620. Revision 1.34 2002/11/17 18:26:16 mazen
  621. * fixed a compilation bug accmulator-->FUNCTION_RETURN_REG, in definition of return_result_reg
  622. Revision 1.33 2002/11/17 17:49:08 mazen
  623. + 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
  624. Revision 1.32 2002/10/05 12:43:29 carl
  625. * fixes for Delphi 6 compilation
  626. (warning : Some features do not work under Delphi)
  627. Revision 1.31 2002/08/14 18:41:48 jonas
  628. - remove valuelow/valuehigh fields from tlocation, because they depend
  629. on the endianess of the host operating system -> difficult to get
  630. right. Use lo/hi(location.valueqword) instead (remember to use
  631. valueqword and not value!!)
  632. Revision 1.30 2002/08/13 21:40:58 florian
  633. * more fixes for ppc calling conventions
  634. Revision 1.29 2002/08/12 15:08:41 carl
  635. + stab register indexes for powerpc (moved from gdb to cpubase)
  636. + tprocessor enumeration moved to cpuinfo
  637. + linker in target_info is now a class
  638. * many many updates for m68k (will soon start to compile)
  639. - removed some ifdef or correct them for correct cpu
  640. Revision 1.28 2002/08/06 20:55:23 florian
  641. * first part of ppc calling conventions fix
  642. Revision 1.27 2002/07/25 18:01:29 carl
  643. + FPURESULTREG -> FPU_RESULT_REG
  644. Revision 1.26 2002/07/07 09:52:33 florian
  645. * powerpc target fixed, very simple units can be compiled
  646. * some basic stuff for better callparanode handling, far from being finished
  647. Revision 1.25 2002/07/01 18:46:30 peter
  648. * internal linker
  649. * reorganized aasm layer
  650. Revision 1.24 2002/07/01 16:23:55 peter
  651. * cg64 patch
  652. * basics for currency
  653. * asnode updates for class and interface (not finished)
  654. Revision 1.23 2002/05/18 13:34:22 peter
  655. * readded missing revisions
  656. Revision 1.22 2002/05/16 19:46:50 carl
  657. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  658. + try to fix temp allocation (still in ifdef)
  659. + generic constructor calls
  660. + start of tassembler / tmodulebase class cleanup
  661. Revision 1.19 2002/05/12 16:53:16 peter
  662. * moved entry and exitcode to ncgutil and cgobj
  663. * foreach gets extra argument for passing local data to the
  664. iterator function
  665. * -CR checks also class typecasts at runtime by changing them
  666. into as
  667. * fixed compiler to cycle with the -CR option
  668. * fixed stabs with elf writer, finally the global variables can
  669. be watched
  670. * removed a lot of routines from cga unit and replaced them by
  671. calls to cgobj
  672. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  673. u32bit then the other is typecasted also to u32bit without giving
  674. a rangecheck warning/error.
  675. * fixed pascal calling method with reversing also the high tree in
  676. the parast, detected by tcalcst3 test
  677. Revision 1.18 2002/04/21 15:31:40 carl
  678. - removed some other stuff to their units
  679. Revision 1.17 2002/04/20 21:37:07 carl
  680. + generic FPC_CHECKPOINTER
  681. + first parameter offset in stack now portable
  682. * rename some constants
  683. + move some cpu stuff to other units
  684. - remove unused constents
  685. * fix stacksize for some targets
  686. * fix generic size problems which depend now on EXTEND_SIZE constant
  687. * removing frame pointer in routines is only available for : i386,m68k and vis targets
  688. Revision 1.16 2002/04/15 19:53:54 peter
  689. * fixed conflicts between the last 2 commits
  690. Revision 1.15 2002/04/15 19:44:20 peter
  691. * fixed stackcheck that would be called recursively when a stack
  692. error was found
  693. * generic changeregsize(reg,size) for i386 register resizing
  694. * removed some more routines from cga unit
  695. * fixed returnvalue handling
  696. * fixed default stacksize of linux and go32v2, 8kb was a bit small :-)
  697. Revision 1.14 2002/04/15 19:12:09 carl
  698. + target_info.size_of_pointer -> pointer_size
  699. + some cleanup of unused types/variables
  700. * move several constants from cpubase to their specific units
  701. (where they are used)
  702. + att_Reg2str -> gas_reg2str
  703. + int_reg2str -> std_reg2str
  704. Revision 1.13 2002/04/14 16:59:41 carl
  705. + att_reg2str -> gas_reg2str
  706. Revision 1.12 2002/04/02 17:11:34 peter
  707. * tlocation,treference update
  708. * LOC_CONSTANT added for better constant handling
  709. * secondadd splitted in multiple routines
  710. * location_force_reg added for loading a location to a register
  711. of a specified size
  712. * secondassignment parses now first the right and then the left node
  713. (this is compatible with Kylix). This saves a lot of push/pop especially
  714. with string operations
  715. * adapted some routines to use the new cg methods
  716. Revision 1.11 2002/03/31 20:26:37 jonas
  717. + a_loadfpu_* and a_loadmm_* methods in tcg
  718. * register allocation is now handled by a class and is mostly processor
  719. independent (+rgobj.pas and i386/rgcpu.pas)
  720. * temp allocation is now handled by a class (+tgobj.pas, -i386\tgcpu.pas)
  721. * some small improvements and fixes to the optimizer
  722. * some register allocation fixes
  723. * some fpuvaroffset fixes in the unary minus node
  724. * push/popusedregisters is now called rg.save/restoreusedregisters and
  725. (for i386) uses temps instead of push/pop's when using -Op3 (that code is
  726. also better optimizable)
  727. * fixed and optimized register saving/restoring for new/dispose nodes
  728. * LOC_FPU locations now also require their "register" field to be set to
  729. R_ST, not R_ST0 (the latter is used for LOC_CFPUREGISTER locations only)
  730. - list field removed of the tnode class because it's not used currently
  731. and can cause hard-to-find bugs
  732. Revision 1.10 2002/03/04 19:10:12 peter
  733. * removed compiler warnings
  734. }