cpubase.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. {******************************************************************************
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl and Peter Vreman
  4. Contains the base types for the Scalable Processor ARChitecture (SPARC)
  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. unit cpuBase;
  18. {$INCLUDE fpcdefs.inc}
  19. interface
  20. uses globals,cutils,cclasses,aasmbase,cpuinfo,cginfo;
  21. const
  22. {Size of the instruction table converted by nasmconv.pas}
  23. maxinfolen=8;
  24. {Defines the default address size for a processor}
  25. OS_ADDR=OS_32;
  26. {the natural int size for a processor}
  27. OS_INT=OS_32;
  28. {the maximum float size for a processor}
  29. OS_FLOAT=OS_F64;
  30. {the size of a vector register for a processor}
  31. OS_VECTOR=OS_M64;
  32. type
  33. {$WARNING CPU32 opcodes do not fully include the Ultra SPRAC instruction set.}
  34. { don't change the order of these opcodes! }
  35. TAsmOp=({$INCLUDE opcode.inc});
  36. op2strtable=array[TAsmOp]OF STRING[11];
  37. CONST
  38. FirstOp=Low(TAsmOp);
  39. LastOp=High(TAsmOp);
  40. std_op2str:op2strtable=({$INCLUDE strinst.inc});
  41. {*****************************************************************************
  42. Operand Sizes
  43. *****************************************************************************}
  44. type
  45. TOpSize=(S_NO,
  46. S_B,{Byte}
  47. S_H,{Half word}
  48. S_W,{Word}
  49. S_L:=S_W,
  50. S_D,{Double Word}
  51. S_Q,{Quad word}
  52. S_IQ:=S_Q,
  53. S_SB,{Signed byte}
  54. S_SH,{Signed half word}
  55. S_SW,{Signed word}
  56. S_SD,{Signed double word}
  57. S_SQ,{Signed quad word}
  58. S_FS,{Float single word}
  59. S_FX:=S_FS,
  60. S_FD,{Float double word}
  61. S_FQ,{Float quad word}
  62. S_NEAR,
  63. S_FAR,
  64. S_SHORT);
  65. {*****************************************************************************}
  66. { Conditions }
  67. {*****************************************************************************}
  68. type
  69. TAsmCond=(C_None,
  70. C_A,C_AE,C_B,C_BE,C_C,C_E,C_G,C_GE,C_L,C_LE,C_NA,C_NAE,
  71. C_NB,C_NBE,C_NC,C_NE,C_NG,C_NGE,C_NL,C_NLE,C_NO,C_NP,
  72. C_NS,C_NZ,C_O,C_P,C_PE,C_PO,C_S,C_Z
  73. );
  74. CONST
  75. cond2str:array[TAsmCond] of string[3]=('',
  76. 'a','ae','b','be','c','e','g','ge','l','le','na','nae',
  77. 'nb','nbe','nc','ne','ng','nge','nl','nle','no','np',
  78. 'ns','nz','o','p','pe','po','s','z'
  79. );
  80. inverse_cond:array[TAsmCond] of TAsmCond=(C_None,
  81. C_NA,C_NAE,C_NB,C_NBE,C_NC,C_NE,C_NG,C_NGE,C_NL,C_NLE,C_A,C_AE,
  82. C_B,C_BE,C_C,C_E,C_G,C_GE,C_L,C_LE,C_O,C_P,
  83. C_S,C_Z,C_NO,C_NP,C_NP,C_P,C_NS,C_NZ
  84. );
  85. CONST
  86. CondAsmOps=3;
  87. CondAsmOp:array[0..CondAsmOps-1] of TAsmOp=(A_FCMPd, A_JMPL, A_FCMPs);
  88. CondAsmOpStr:array[0..CondAsmOps-1] of string[7]=('FCMPd','JMPL','FCMPs');
  89. {*****************************************************************************}
  90. { Registers }
  91. {*****************************************************************************}
  92. type
  93. { enumeration for registers, don't change the order }
  94. { it's used by the register size conversions }
  95. TCpuRegister=({$INCLUDE cpuregs.inc});
  96. TOldRegister=TCpuRegister;
  97. Tnewregister=word;
  98. Tsuperregister=byte;
  99. Tsubregister=byte;
  100. Tregister=record
  101. enum:TCpuRegister;
  102. number:Tnewregister;
  103. end;
  104. TRegister64=PACKED RECORD
  105. {A type to store register locations for 64 Bit values.}
  106. RegLo,RegHi:TRegister;
  107. END;
  108. treg64=tregister64;{alias for compact code}
  109. TRegisterSet=SET OF TCpuRegister;
  110. Tsupregset=set of Tsuperregister;
  111. const
  112. R_NO=R_NONE;
  113. firstreg = Succ(R_NONE);
  114. lastreg = Pred(R_INTREGISTER);
  115. {General registers.}
  116. const
  117. NR_NONE=$0000;
  118. NR_NO=NR_NONE;
  119. NR_G0=$0001;
  120. NR_G1=$0002;
  121. NR_G2=$0003;
  122. NR_G3=$0004;
  123. NR_G4=$0005;
  124. NR_G5=$0006;
  125. NR_G6=$0007;
  126. NR_G7=$0008;
  127. NR_O0=$0100;
  128. NR_O1=$0200;
  129. NR_O2=$0300;
  130. NR_O3=$0400;
  131. NR_O4=$0500;
  132. NR_O5=$0600;
  133. NR_O6=$0700;
  134. NR_O7=$0800;
  135. NR_L0=$0900;
  136. NR_L1=$0A00;
  137. NR_L2=$0B00;
  138. NR_L3=$0C00;
  139. NR_L4=$0D00;
  140. NR_L5=$0E00;
  141. NR_L6=$0F00;
  142. NR_L7=$1000;
  143. NR_I0=$1100;
  144. NR_I1=$1200;
  145. NR_I2=$1300;
  146. NR_I3=$1400;
  147. NR_I4=$1500;
  148. NR_I5=$1600;
  149. NR_I6=$1700;
  150. NR_I7=$1800;
  151. {Floating point}
  152. NR_F0=$2000;
  153. NR_F1=$2000;
  154. NR_F2=$2000;
  155. NR_F3=$2000;
  156. NR_F4=$2000;
  157. NR_F5=$2000;
  158. NR_F6=$2000;
  159. NR_F7=$2000;
  160. NR_F8=$2000;
  161. NR_F9=$2000;
  162. NR_F10=$2000;
  163. NR_F11=$2000;
  164. NR_F12=$2000;
  165. NR_F13=$2000;
  166. NR_F14=$2000;
  167. NR_F15=$2000;
  168. NR_F16=$2000;
  169. NR_F17=$2000;
  170. NR_F18=$2000;
  171. NR_F19=$2000;
  172. NR_F20=$2000;
  173. NR_F21=$2000;
  174. NR_F22=$2000;
  175. NR_F23=$2000;
  176. NR_F24=$2000;
  177. NR_F25=$2000;
  178. NR_F26=$2000;
  179. NR_F27=$2000;
  180. NR_F28=$2000;
  181. NR_F29=$2000;
  182. NR_F30=$2000;
  183. NR_F31=$2000;
  184. {Coprocessor point}
  185. NR_C0=$3000;
  186. NR_C1=$3000;
  187. NR_C2=$3000;
  188. NR_C3=$3000;
  189. NR_C4=$3000;
  190. NR_C5=$3000;
  191. NR_C6=$3000;
  192. NR_C7=$3000;
  193. NR_C8=$3000;
  194. NR_C9=$3000;
  195. NR_C10=$3000;
  196. NR_C11=$3000;
  197. NR_C12=$3000;
  198. NR_C13=$3000;
  199. NR_C14=$3000;
  200. NR_C15=$3000;
  201. NR_C16=$3000;
  202. NR_C17=$3000;
  203. NR_C18=$3000;
  204. NR_C19=$3000;
  205. NR_C20=$3000;
  206. NR_C21=$3000;
  207. NR_C22=$3000;
  208. NR_C23=$3000;
  209. NR_C24=$3000;
  210. NR_C25=$3000;
  211. NR_C26=$3000;
  212. NR_C27=$3000;
  213. NR_C28=$3000;
  214. NR_C29=$3000;
  215. NR_C30=$3000;
  216. NR_C31=$3000;
  217. {ASR}
  218. NR_ASR0=$4000;
  219. NR_ASR1=$4000;
  220. NR_ASR2=$4000;
  221. NR_ASR3=$4000;
  222. NR_ASR4=$4000;
  223. NR_ASR5=$4000;
  224. NR_ASR6=$4000;
  225. NR_ASR7=$4000;
  226. NR_ASR8=$4000;
  227. NR_ASR9=$4000;
  228. NR_ASR10=$4000;
  229. NR_ASR11=$4000;
  230. NR_ASR12=$4000;
  231. NR_ASR13=$4000;
  232. NR_ASR14=$4000;
  233. NR_ASR15=$4000;
  234. NR_ASR16=$4000;
  235. NR_ASR17=$4000;
  236. NR_ASR18=$4000;
  237. NR_ASR19=$4000;
  238. NR_ASR20=$4000;
  239. NR_ASR21=$4000;
  240. NR_ASR22=$4000;
  241. NR_ASR23=$4000;
  242. NR_ASR24=$4000;
  243. NR_ASR25=$4000;
  244. NR_ASR26=$4000;
  245. NR_ASR27=$4000;
  246. NR_ASR28=$4000;
  247. NR_ASR29=$4000;
  248. NR_ASR30=$4000;
  249. NR_ASR31=$4000;
  250. {Floating point status/"front of queue" registers}
  251. NR_FSR=$5000;
  252. NR_FQ=$5001; { was $50001, probably typo (FK) }
  253. NR_CSR=$5000;
  254. NR_CQ=$5000;
  255. NR_PSR=$5000;
  256. NR_TBR=$5000;
  257. NR_WIM=$5000;
  258. NR_Y=$5000;
  259. {Superregisters.}
  260. const
  261. RS_O0=$01;
  262. RS_O1=$02;
  263. RS_O2=$03;
  264. RS_O3=$04;
  265. RS_O4=$05;
  266. RS_O5=$06;
  267. RS_O6=$07;
  268. RS_O7=$08;
  269. RS_L0=$09;
  270. RS_L1=$0A;
  271. RS_L2=$0B;
  272. RS_L3=$0C;
  273. RS_L4=$0D;
  274. RS_L5=$0E;
  275. RS_L6=$0F;
  276. RS_L7=$10;
  277. RS_I0=$11;
  278. RS_I1=$12;
  279. RS_I2=$13;
  280. RS_I3=$14;
  281. RS_I4=$15;
  282. RS_I5=$16;
  283. RS_I6=$17;
  284. RS_I7=$18;
  285. RS_G0=$19;
  286. RS_G1=$1A;
  287. RS_G2=$1B;
  288. RS_G3=$1C;
  289. RS_G4=$1D;
  290. RS_G5=$1E;
  291. RS_G6=$1F;
  292. RS_G7=$20;
  293. first_supreg = $01;
  294. last_supreg = $20;
  295. first_imreg = $21;
  296. last_imreg = $ff;
  297. {Subregisters; nothing known about.}
  298. R_SUBWHOLE=$00;
  299. R_SUBL=$00;
  300. type
  301. reg2strtable=array[TCpuRegister] OF STRING[7];
  302. TCpuReg=array[TCpuRegister]of TRegister;
  303. const
  304. std_reg2str:reg2strtable=({$INCLUDE strregs.inc});
  305. CpuReg:TCpuReg=({$INCLUDE registers.inc});
  306. {*****************************************************************************
  307. Flags
  308. *****************************************************************************}
  309. type
  310. TResFlags=(
  311. F_E, {Equal}
  312. F_NE, {Not Equal}
  313. F_G, {Greater}
  314. F_L, {Less}
  315. F_GE, {Greater or Equal}
  316. F_LE, {Less or Equal}
  317. F_C, {Carry}
  318. F_NC, {Not Carry}
  319. F_A, {Above}
  320. F_AE, {Above or Equal}
  321. F_B, {Below}
  322. F_BE {Below or Equal}
  323. );
  324. {*****************************************************************************
  325. Reference
  326. *****************************************************************************}
  327. type
  328. trefoptions=(ref_none,ref_parafixup,ref_localfixup,ref_selffixup);
  329. { immediate/reference record }
  330. poperreference = ^treference;
  331. Preference=^Treference;
  332. treference = packed record
  333. segment,
  334. base,
  335. index : tregister;
  336. scalefactor : byte;
  337. offset : LongInt;
  338. symbol : tasmsymbol;
  339. offsetfixup : LongInt;
  340. options : trefoptions;
  341. alignment : byte;
  342. END;
  343. { reference record }
  344. PParaReference=^TParaReference;
  345. TParaReference=PACKED RECORD
  346. Index:TRegister;
  347. Offset:longint;
  348. END;
  349. {*****************************************************************************
  350. Operands
  351. *****************************************************************************}
  352. { Types of operand }
  353. toptype=(top_none,top_reg,top_ref,top_const,top_symbol,top_raddr,top_caddr);
  354. toper=record
  355. ot:LongInt;
  356. case typ:toptype of
  357. top_none:();
  358. top_reg:(reg:tregister);
  359. top_ref:(ref:poperreference);
  360. top_const:(val:aword);
  361. top_symbol:(sym:tasmsymbol;symofs:LongInt);
  362. top_raddr:(reg1,reg2:TRegister);
  363. top_caddr:(regb:TRegister;const13:Integer);
  364. end;
  365. {*****************************************************************************
  366. Argument Classification
  367. *****************************************************************************}
  368. type
  369. TArgClass = (
  370. { the following classes should be defined by all processor implemnations }
  371. AC_NOCLASS,
  372. AC_MEMORY,
  373. AC_INTEGER,
  374. AC_FPU,
  375. { the following argument classes are i386 specific }
  376. AC_FPUUP,
  377. AC_SSE,
  378. AC_SSEUP);
  379. {*****************************************************************************
  380. Generic Location
  381. *****************************************************************************}
  382. type
  383. {tparamlocation describes where a parameter for a procedure is stored.
  384. References are given from the caller's point of view. The usual TLocation isn't
  385. used, because contains a lot of unnessary fields.}
  386. TParaLocation=PACKED RECORD
  387. Size:TCGSize;
  388. Loc:TCGLoc;
  389. sp_fixup:LongInt;
  390. CASE TCGLoc OF
  391. LOC_REFERENCE:(reference:tparareference);
  392. { segment in reference at the same place as in loc_register }
  393. LOC_REGISTER,LOC_CREGISTER : (
  394. CASE LongInt OF
  395. 1 : (register,registerhigh : tregister);
  396. { overlay a registerlow }
  397. 2 : (registerlow : tregister);
  398. { overlay a 64 Bit register type }
  399. 3 : (reg64 : tregister64);
  400. 4 : (register64 : tregister64);
  401. );
  402. { it's only for better handling }
  403. LOC_MMXREGISTER,LOC_CMMXREGISTER : (mmxreg : tregister);
  404. END;
  405. TLocation=PACKED RECORD
  406. loc : TCGLoc;
  407. size : TCGSize;
  408. case TCGLoc of
  409. LOC_FLAGS : (resflags : tresflags);
  410. LOC_CONSTANT : (
  411. case longint of
  412. 1 : (value : AWord);
  413. 2 : (valuelow, valuehigh:AWord);
  414. { overlay a complete 64 Bit value }
  415. 3 : (valueqword : qword);
  416. );
  417. LOC_CREFERENCE,
  418. LOC_REFERENCE : (reference : treference);
  419. { segment in reference at the same place as in loc_register }
  420. LOC_REGISTER,LOC_CREGISTER : (
  421. case longint of
  422. 1 : (register,registerhigh,segment : tregister);
  423. { overlay a registerlow }
  424. 2 : (registerlow : tregister);
  425. { overlay a 64 Bit register type }
  426. 3 : (reg64 : tregister64);
  427. 4 : (register64 : tregister64);
  428. );
  429. { it's only for better handling }
  430. LOC_MMXREGISTER,LOC_CMMXREGISTER : (mmxreg : tregister);
  431. end;
  432. {*****************************************************************************
  433. Constants
  434. *****************************************************************************}
  435. const
  436. general_registers = [R_G0..R_I7];
  437. general_superregisters = [RS_O0..RS_I7];
  438. { legend: }
  439. { xxxregs = set of all possibly used registers of that type in the code }
  440. { generator }
  441. { usableregsxxx = set of all 32bit components of registers that can be }
  442. { possible allocated to a regvar or using getregisterxxx (this }
  443. { excludes registers which can be only used for parameter }
  444. { passing on ABI's that define this) }
  445. { c_countusableregsxxx = amount of registers in the usableregsxxx set }
  446. IntRegs=[R_G0..R_I7];
  447. usableregsint=[RS_O0..RS_I7];
  448. c_countusableregsint = 24;
  449. fpuregs=[R_F0..R_F31];
  450. usableregsfpu=[R_F0..R_F31];
  451. c_countusableregsfpu=32;
  452. mmregs=[];
  453. usableregsmm=[];
  454. c_countusableregsmm=0;
  455. { no distinction on this platform }
  456. maxaddrregs = 0;
  457. addrregs = [];
  458. usableregsaddr = [];
  459. c_countusableregsaddr = 0;
  460. firstsaveintreg = RS_O0;
  461. lastsaveintreg = RS_I7;
  462. firstsavefpureg = R_F0;
  463. lastsavefpureg = R_F31;
  464. firstsavemmreg = R_NONE;
  465. lastsavemmreg = R_NONE;
  466. lowsavereg = R_G0;
  467. highsavereg = R_I7;
  468. ALL_REGISTERS = [lowsavereg..highsavereg];
  469. ALL_INTREGISTERS = [1..255];
  470. lvaluelocations = [LOC_REFERENCE,LOC_CFPUREGISTER,
  471. LOC_CREGISTER,LOC_MMXREGISTER,LOC_CMMXREGISTER];
  472. {*****************************************************************************
  473. GDB Information
  474. *****************************************************************************}
  475. {# Register indexes for stabs information, when some parameters or variables
  476. are stored in registers.
  477. Taken from rs6000.h (DBX_REGISTER_NUMBER) from GCC 3.x source code.}
  478. stab_regindex:array[TCpuRegister]OF ShortInt=({$INCLUDE stabregi.inc});
  479. {*************************** generic register names **************************}
  480. stack_pointer_reg = R_O6;
  481. NR_STACK_POINTER_REG = NR_O6;
  482. RS_STACK_POINTER_REG = RS_O6;
  483. frame_pointer_reg = R_I6;
  484. NR_FRAME_POINTER_REG = NR_I6;
  485. RS_FRAME_POINTER_REG = RS_I6;
  486. {the return_result_reg, is used inside the called function to store its return
  487. value when that is a scalar value otherwise a pointer to the address of the
  488. result is placed inside it}
  489. return_result_reg = R_I0;
  490. NR_RETURN_RESULT_REG = NR_I0;
  491. RS_RETURN_RESULT_REG = RS_I0;
  492. {the function_result_reg contains the function result after a call to a scalar
  493. function othewise it contains a pointer to the returned result}
  494. function_result_reg = R_O0;
  495. NR_FUNCTION_RESULT_REG = NR_O0;
  496. RS_FUNCTION_RESULT_REG = RS_O0;
  497. self_pointer_reg =R_G5;
  498. NR_SELF_POINTER_REG = NR_G5;
  499. { RS_SELF_POINTER_REG = RS_G5;}
  500. {There is no accumulator in the SPARC architecture. There are just families
  501. of registers. All registers belonging to the same family are identical except
  502. in the "global registers" family where GO is different from the others :
  503. G0 gives always 0 when it is red and thows away any value written to it.
  504. Nevertheless, scalar routine results are returned onto R_O0.}
  505. accumulator = R_O0;
  506. NR_ACCUMULATOR = NR_O0;
  507. RS_ACCUMULATOR = RS_O1;
  508. accumulatorhigh = R_O1;
  509. NR_ACCUMULATORHIGH = NR_O1;
  510. RS_ACCUMULATORHIGH = RS_O1;
  511. fpu_result_reg =R_F0;
  512. mmresultreg =R_G0;
  513. {*****************************************************************************}
  514. { GCC /ABI linking information }
  515. {*****************************************************************************}
  516. {# Registers which must be saved when calling a routine declared as cppdecl,
  517. cdecl, stdcall, safecall, palmossyscall. The registers saved should be the ones
  518. as defined in the target ABI and / or GCC.
  519. This value can be deduced from the CALLED_USED_REGISTERS array in the GCC
  520. source.}
  521. std_saved_registers=[RS_O6];
  522. {# Required parameter alignment when calling a routine declared as stdcall and
  523. cdecl. The alignment value should be the one defined by GCC or the target ABI.
  524. The value of this constant is equal to the constant
  525. PARM_BOUNDARY / BITS_PER_UNIT in the GCC source.}
  526. std_param_align=4;
  527. {# Registers which are defined as scratch and no need to save across routine
  528. calls or in assembler blocks.}
  529. ScratchRegsCount=8;
  530. scratch_regs:array[1..ScratchRegsCount] OF Tsuperregister=(RS_L0,RS_L1,RS_L2,RS_L3,RS_L4,RS_L5,RS_L6,RS_L7);
  531. { low and high of the available maximum width integer general purpose }
  532. { registers }
  533. LoGPReg = R_G0;
  534. HiGPReg = R_I7;
  535. { low and high of every possible width general purpose register (same as }
  536. { above on most architctures apart from the 80x86) }
  537. LoReg = R_G0;
  538. HiReg = R_I7;
  539. cpuflags = [];
  540. { sizes }
  541. pointersize = 4;
  542. extENDed_size = 8;{SPARC architecture uses IEEE floating point numbers}
  543. mmreg_size = 8;
  544. SizePostfix_pointer = S_SW;
  545. {*****************************************************************************
  546. Instruction table
  547. *****************************************************************************}
  548. {$ifndef NOAG386BIN}
  549. type
  550. tinsentry=packed record
  551. opcode : tasmop;
  552. ops : byte;
  553. optypes : array[0..2] of LongInt;
  554. code : array[0..maxinfolen] of char;
  555. flags : LongInt;
  556. END;
  557. pinsentry=^tinsentry;
  558. TInsTabCache=array[TasmOp] of LongInt;
  559. PInsTabCache=^TInsTabCache;
  560. VAR
  561. InsTabCache : PInsTabCache;
  562. {$ENDif NOAG386BIN}
  563. {*****************************************************************************
  564. Helpers
  565. *****************************************************************************}
  566. const
  567. maxvarregs=30;
  568. VarRegs:array[1..maxvarregs] of tnewregister = (
  569. RS_G0,RS_G1,RS_G2,RS_G3,RS_G4,RS_G5,RS_G6,RS_G7,
  570. RS_O0,RS_O1,RS_O2,RS_O3,RS_O4,RS_O5,{RS_R14=RS_SP}RS_O7,
  571. RS_L0,RS_L1,RS_L2,RS_L3,RS_L4,RS_L5,RS_L6,RS_L7,
  572. RS_I0,RS_I1,RS_I2,RS_I3,RS_I4,RS_I5,{RS_R30=RS_FP}RS_I7
  573. );
  574. maxfpuvarregs = 8;
  575. max_operands = 3;
  576. maxintregs = maxvarregs;
  577. maxfpuregs = maxfpuvarregs;
  578. max_scratch_regs=8;
  579. function is_calljmp(o:tasmop):boolean;
  580. function flags_to_cond(CONST f:TResFlags):TAsmCond;
  581. procedure convert_register_to_enum(var r:Tregister);
  582. function cgsize2subreg(s:Tcgsize):Tsubregister;
  583. implementation
  584. uses
  585. verbose;
  586. const
  587. CallJmpOp=[A_JMPL..A_CBccc];
  588. function is_calljmp(o:tasmop):boolean;
  589. begin
  590. if o in CallJmpOp
  591. then
  592. is_calljmp:=true
  593. else
  594. is_calljmp:=false;
  595. end;
  596. function flags_to_cond(const f:TResFlags):TAsmCond;
  597. CONST
  598. flags_2_cond:array[TResFlags]OF TAsmCond=
  599. (C_E,C_NE,C_G,C_L,C_GE,C_LE,C_C,C_NC,C_A,C_AE,C_B,C_BE);
  600. BEGIN
  601. result:=flags_2_cond[f];
  602. END;
  603. procedure convert_register_to_enum(var r:Tregister);
  604. begin
  605. if r.enum=R_INTREGISTER
  606. then
  607. case r.number of
  608. NR_NO: r.enum:= R_NO;
  609. NR_G0: r.enum:= R_G0;
  610. NR_G1: r.enum:= R_G1;
  611. NR_G2: r.enum:= R_G2;
  612. NR_G3: r.enum:= R_G3;
  613. NR_G4: r.enum:= R_G4;
  614. NR_G5: r.enum:= R_G5;
  615. NR_G6: r.enum:= R_G6;
  616. NR_G7: r.enum:= R_G7;
  617. NR_O0: r.enum:= R_O0;
  618. NR_O1: r.enum:= R_O1;
  619. NR_O2: r.enum:= R_O2;
  620. NR_O3: r.enum:= R_O3;
  621. NR_O4: r.enum:= R_O4;
  622. NR_O5: r.enum:= R_O5;
  623. NR_O6: r.enum:= R_O6;
  624. NR_O7: r.enum:= R_O7;
  625. NR_L0: r.enum:= R_L0;
  626. NR_L1: r.enum:= R_L1;
  627. NR_L2: r.enum:= R_L2;
  628. NR_L3: r.enum:= R_L3;
  629. NR_L4: r.enum:= R_L4;
  630. NR_L5: r.enum:= R_L5;
  631. NR_L6: r.enum:= R_L6;
  632. NR_L7: r.enum:= R_L7;
  633. NR_I0: r.enum:= R_I0;
  634. NR_I1: r.enum:= R_I1;
  635. NR_I2: r.enum:= R_I2;
  636. NR_I3: r.enum:= R_I3;
  637. NR_I4: r.enum:= R_I4;
  638. NR_I5: r.enum:= R_I5;
  639. NR_I6: r.enum:= R_I6;
  640. NR_I7: r.enum:= R_I7;
  641. else
  642. internalerror(200301082);
  643. end;
  644. end;
  645. function cgsize2subreg(s:Tcgsize):Tsubregister;
  646. begin
  647. cgsize2subreg:=R_SUBWHOLE;
  648. end;
  649. end.
  650. {
  651. $Log$
  652. Revision 1.32 2003-05-23 21:10:50 florian
  653. * fixed sparc compiler compilation
  654. Revision 1.31 2003/05/22 16:11:22 florian
  655. * fixed sparc compilation partially
  656. Revision 1.30 2003/05/06 14:58:46 mazen
  657. - non used constants OT_* removed
  658. * some keywords moved lower case
  659. Revision 1.29 2003/04/29 12:03:52 mazen
  660. * TOldRegister isnow just an alias for TCpuRegister
  661. * TCpuRegister is used to define cpu register set physically available
  662. + CpuRegs array to easially create correspondence between TCpuRegister and TRegister
  663. Revision 1.28 2003/04/28 09:46:30 mazen
  664. + max_scratch_regs variable added because requested by common compiler code
  665. Revision 1.27 2003/04/23 13:35:39 peter
  666. * fix sparc compile
  667. Revision 1.26 2003/04/23 12:35:35 florian
  668. * fixed several issues with powerpc
  669. + applied a patch from Jonas for nested function calls (PowerPC only)
  670. * ...
  671. }