cpubase.pas 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  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=$50001;
  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. first_supreg = $01;
  286. last_supreg = $18;
  287. first_imreg = $19;
  288. last_imreg = $ff;
  289. {Subregisters; nothing known about.}
  290. R_SUBWHOLE=$00;
  291. R_SUBL=$00;
  292. type
  293. reg2strtable=array[TCpuRegister] OF STRING[7];
  294. TCpuReg=array[TCpuRegister]of TRegister;
  295. const
  296. std_reg2str:reg2strtable=({$INCLUDE strregs.inc});
  297. CpuReg:TCpuReg=({$INCLUDE registers.inc});
  298. {*****************************************************************************
  299. Flags
  300. *****************************************************************************}
  301. type
  302. TResFlags=(
  303. F_E, {Equal}
  304. F_NE, {Not Equal}
  305. F_G, {Greater}
  306. F_L, {Less}
  307. F_GE, {Greater or Equal}
  308. F_LE, {Less or Equal}
  309. F_C, {Carry}
  310. F_NC, {Not Carry}
  311. F_A, {Above}
  312. F_AE, {Above or Equal}
  313. F_B, {Below}
  314. F_BE {Below or Equal}
  315. );
  316. {*****************************************************************************
  317. Reference
  318. *****************************************************************************}
  319. type
  320. trefoptions=(ref_none,ref_parafixup,ref_localfixup,ref_selffixup);
  321. { immediate/reference record }
  322. poperreference = ^treference;
  323. Preference=^Treference;
  324. treference = packed record
  325. segment,
  326. base,
  327. index : tregister;
  328. scalefactor : byte;
  329. offset : LongInt;
  330. symbol : tasmsymbol;
  331. offsetfixup : LongInt;
  332. options : trefoptions;
  333. alignment : byte;
  334. END;
  335. { reference record }
  336. PParaReference=^TParaReference;
  337. TParaReference=PACKED RECORD
  338. Index:TRegister;
  339. Offset:longint;
  340. END;
  341. {*****************************************************************************
  342. Operands
  343. *****************************************************************************}
  344. { Types of operand }
  345. toptype=(top_none,top_reg,top_ref,top_const,top_symbol,top_raddr,top_caddr);
  346. toper=record
  347. ot:LongInt;
  348. case typ:toptype of
  349. top_none:();
  350. top_reg:(reg:tregister);
  351. top_ref:(ref:poperreference);
  352. top_const:(val:aword);
  353. top_symbol:(sym:tasmsymbol;symofs:LongInt);
  354. top_raddr:(reg1,reg2:TRegister);
  355. top_caddr:(regb:TRegister;const13:Integer);
  356. end;
  357. {*****************************************************************************
  358. Argument Classification
  359. *****************************************************************************}
  360. type
  361. TArgClass = (
  362. { the following classes should be defined by all processor implemnations }
  363. AC_NOCLASS,
  364. AC_MEMORY,
  365. AC_INTEGER,
  366. AC_FPU,
  367. { the following argument classes are i386 specific }
  368. AC_FPUUP,
  369. AC_SSE,
  370. AC_SSEUP);
  371. {*****************************************************************************
  372. Generic Location
  373. *****************************************************************************}
  374. type
  375. {tparamlocation describes where a parameter for a procedure is stored.
  376. References are given from the caller's point of view. The usual TLocation isn't
  377. used, because contains a lot of unnessary fields.}
  378. TParaLocation=PACKED RECORD
  379. Size:TCGSize;
  380. Loc:TCGLoc;
  381. sp_fixup:LongInt;
  382. CASE TCGLoc OF
  383. LOC_REFERENCE:(reference:tparareference);
  384. { segment in reference at the same place as in loc_register }
  385. LOC_REGISTER,LOC_CREGISTER : (
  386. CASE LongInt OF
  387. 1 : (register,registerhigh : tregister);
  388. { overlay a registerlow }
  389. 2 : (registerlow : tregister);
  390. { overlay a 64 Bit register type }
  391. 3 : (reg64 : tregister64);
  392. 4 : (register64 : tregister64);
  393. );
  394. { it's only for better handling }
  395. LOC_MMXREGISTER,LOC_CMMXREGISTER : (mmxreg : tregister);
  396. END;
  397. TLocation=PACKED RECORD
  398. loc : TCGLoc;
  399. size : TCGSize;
  400. case TCGLoc of
  401. LOC_FLAGS : (resflags : tresflags);
  402. LOC_CONSTANT : (
  403. case longint of
  404. 1 : (value : AWord);
  405. 2 : (valuelow, valuehigh:AWord);
  406. { overlay a complete 64 Bit value }
  407. 3 : (valueqword : qword);
  408. );
  409. LOC_CREFERENCE,
  410. LOC_REFERENCE : (reference : treference);
  411. { segment in reference at the same place as in loc_register }
  412. LOC_REGISTER,LOC_CREGISTER : (
  413. case longint of
  414. 1 : (register,registerhigh,segment : tregister);
  415. { overlay a registerlow }
  416. 2 : (registerlow : tregister);
  417. { overlay a 64 Bit register type }
  418. 3 : (reg64 : tregister64);
  419. 4 : (register64 : tregister64);
  420. );
  421. { it's only for better handling }
  422. LOC_MMXREGISTER,LOC_CMMXREGISTER : (mmxreg : tregister);
  423. end;
  424. {*****************************************************************************
  425. Constants
  426. *****************************************************************************}
  427. const
  428. general_registers = [R_G0..R_I7];
  429. general_superregisters = [RS_O0..RS_I7];
  430. { legend: }
  431. { xxxregs = set of all possibly used registers of that type in the code }
  432. { generator }
  433. { usableregsxxx = set of all 32bit components of registers that can be }
  434. { possible allocated to a regvar or using getregisterxxx (this }
  435. { excludes registers which can be only used for parameter }
  436. { passing on ABI's that define this) }
  437. { c_countusableregsxxx = amount of registers in the usableregsxxx set }
  438. IntRegs=[R_G0..R_I7];
  439. usableregsint=[RS_O0..RS_I7];
  440. c_countusableregsint = 24;
  441. fpuregs=[R_F0..R_F31];
  442. usableregsfpu=[R_F0..R_F31];
  443. c_countusableregsfpu=32;
  444. mmregs=[];
  445. usableregsmm=[];
  446. c_countusableregsmm=0;
  447. { no distinction on this platform }
  448. maxaddrregs = 0;
  449. addrregs = [];
  450. usableregsaddr = [];
  451. c_countusableregsaddr = 0;
  452. firstsaveintreg = RS_O0;
  453. lastsaveintreg = RS_I7;
  454. firstsavefpureg = R_F0;
  455. lastsavefpureg = R_F31;
  456. firstsavemmreg = R_NONE;
  457. lastsavemmreg = R_NONE;
  458. lowsavereg = R_G0;
  459. highsavereg = R_I7;
  460. ALL_REGISTERS = [lowsavereg..highsavereg];
  461. ALL_INTREGISTERS = [1..255];
  462. lvaluelocations = [LOC_REFERENCE,LOC_CFPUREGISTER,
  463. LOC_CREGISTER,LOC_MMXREGISTER,LOC_CMMXREGISTER];
  464. {*****************************************************************************
  465. GDB Information
  466. *****************************************************************************}
  467. {# Register indexes for stabs information, when some parameters or variables
  468. are stored in registers.
  469. Taken from rs6000.h (DBX_REGISTER_NUMBER) from GCC 3.x source code.}
  470. stab_regindex:array[TCpuRegister]OF ShortInt=({$INCLUDE stabregi.inc});
  471. {*************************** generic register names **************************}
  472. stack_pointer_reg = R_O6;
  473. NR_STACK_POINTER_REG = NR_O6;
  474. RS_STACK_POINTER_REG = RS_O6;
  475. frame_pointer_reg = R_I6;
  476. NR_FRAME_POINTER_REG = NR_I6;
  477. RS_FRAME_POINTER_REG = RS_I6;
  478. {the return_result_reg, is used inside the called function to store its return
  479. value when that is a scalar value otherwise a pointer to the address of the
  480. result is placed inside it}
  481. return_result_reg = R_I0;
  482. NR_RETURN_RESULT_REG = NR_I0;
  483. RS_RETURN_RESULT_REG = RS_I0;
  484. {the function_result_reg contains the function result after a call to a scalar
  485. function othewise it contains a pointer to the returned result}
  486. function_result_reg = R_O0;
  487. NR_FUNCTION_RESULT_REG = NR_O0;
  488. RS_FUNCTION_RESULT_REG = RS_O0;
  489. self_pointer_reg =R_G5;
  490. NR_SELF_POINTER_REG = NR_G5;
  491. { RS_SELF_POINTER_REG = RS_G5;}
  492. {There is no accumulator in the SPARC architecture. There are just families
  493. of registers. All registers belonging to the same family are identical except
  494. in the "global registers" family where GO is different from the others :
  495. G0 gives always 0 when it is red and thows away any value written to it.
  496. Nevertheless, scalar routine results are returned onto R_O0.}
  497. accumulator = R_O0;
  498. NR_ACCUMULATOR = NR_O0;
  499. RS_ACCUMULATOR = RS_O1;
  500. accumulatorhigh = R_O1;
  501. NR_ACCUMULATORHIGH = NR_O1;
  502. RS_ACCUMULATORHIGH = RS_O1;
  503. fpu_result_reg =R_F0;
  504. mmresultreg =R_G0;
  505. {*****************************************************************************}
  506. { GCC /ABI linking information }
  507. {*****************************************************************************}
  508. {# Registers which must be saved when calling a routine declared as cppdecl,
  509. cdecl, stdcall, safecall, palmossyscall. The registers saved should be the ones
  510. as defined in the target ABI and / or GCC.
  511. This value can be deduced from the CALLED_USED_REGISTERS array in the GCC
  512. source.}
  513. std_saved_registers=[RS_O6];
  514. {# Required parameter alignment when calling a routine declared as stdcall and
  515. cdecl. The alignment value should be the one defined by GCC or the target ABI.
  516. The value of this constant is equal to the constant
  517. PARM_BOUNDARY / BITS_PER_UNIT in the GCC source.}
  518. std_param_align=4;
  519. {# Registers which are defined as scratch and no need to save across routine
  520. calls or in assembler blocks.}
  521. ScratchRegsCount=8;
  522. scratch_regs:array[1..ScratchRegsCount] OF Tsuperregister=(RS_L0,RS_L1,RS_L2,RS_L3,RS_L4,RS_L5,RS_L6,RS_L7);
  523. { low and high of the available maximum width integer general purpose }
  524. { registers }
  525. LoGPReg = R_G0;
  526. HiGPReg = R_I7;
  527. { low and high of every possible width general purpose register (same as }
  528. { above on most architctures apart from the 80x86) }
  529. LoReg = R_G0;
  530. HiReg = R_I7;
  531. cpuflags = [];
  532. { sizes }
  533. pointersize = 4;
  534. extENDed_size = 8;{SPARC architecture uses IEEE floating point numbers}
  535. mmreg_size = 8;
  536. SizePostfix_pointer = S_SW;
  537. {*****************************************************************************
  538. Instruction table
  539. *****************************************************************************}
  540. {$ifndef NOAG386BIN}
  541. type
  542. tinsentry=packed record
  543. opcode : tasmop;
  544. ops : byte;
  545. optypes : array[0..2] of LongInt;
  546. code : array[0..maxinfolen] of char;
  547. flags : LongInt;
  548. END;
  549. pinsentry=^tinsentry;
  550. TInsTabCache=array[TasmOp] of LongInt;
  551. PInsTabCache=^TInsTabCache;
  552. VAR
  553. InsTabCache : PInsTabCache;
  554. {$ENDif NOAG386BIN}
  555. {*****************************************************************************
  556. Helpers
  557. *****************************************************************************}
  558. const
  559. maxvarregs=30;
  560. VarRegs:array[1..maxvarregs]OF TCpuRegister=(
  561. R_G0,R_G1,R_G2,R_G3,R_G4,R_G5,R_G6,R_G7,
  562. R_O0,R_O1,R_O2,R_O3,R_O4,R_O5,{R_R14=R_SP}R_O7,
  563. R_L0,R_L1,R_L2,R_L3,R_L4,R_L5,R_L6,R_L7,
  564. R_I0,R_I1,R_I2,R_I3,R_I4,R_I5,{R_R30=R_FP}R_I7
  565. );
  566. maxfpuvarregs = 8;
  567. max_operands = 3;
  568. maxintregs = maxvarregs;
  569. maxfpuregs = maxfpuvarregs;
  570. max_scratch_regs=8;
  571. function is_calljmp(o:tasmop):boolean;
  572. function flags_to_cond(CONST f:TResFlags):TAsmCond;
  573. procedure convert_register_to_enum(var r:Tregister);
  574. function cgsize2subreg(s:Tcgsize):Tsubregister;
  575. implementation
  576. uses
  577. verbose;
  578. const
  579. CallJmpOp=[A_JMPL..A_CBccc];
  580. function is_calljmp(o:tasmop):boolean;
  581. begin
  582. if o in CallJmpOp
  583. then
  584. is_calljmp:=true
  585. else
  586. is_calljmp:=false;
  587. end;
  588. function flags_to_cond(const f:TResFlags):TAsmCond;
  589. CONST
  590. flags_2_cond:array[TResFlags]OF TAsmCond=
  591. (C_E,C_NE,C_G,C_L,C_GE,C_LE,C_C,C_NC,C_A,C_AE,C_B,C_BE);
  592. BEGIN
  593. result:=flags_2_cond[f];
  594. END;
  595. procedure convert_register_to_enum(var r:Tregister);
  596. begin
  597. if r.enum=R_INTREGISTER
  598. then
  599. case r.number of
  600. NR_NO: r.enum:= R_NO;
  601. NR_G0: r.enum:= R_G0;
  602. NR_G1: r.enum:= R_G1;
  603. NR_G2: r.enum:= R_G2;
  604. NR_G3: r.enum:= R_G3;
  605. NR_G4: r.enum:= R_G4;
  606. NR_G5: r.enum:= R_G5;
  607. NR_G6: r.enum:= R_G6;
  608. NR_G7: r.enum:= R_G7;
  609. NR_O0: r.enum:= R_O0;
  610. NR_O1: r.enum:= R_O1;
  611. NR_O2: r.enum:= R_O2;
  612. NR_O3: r.enum:= R_O3;
  613. NR_O4: r.enum:= R_O4;
  614. NR_O5: r.enum:= R_O5;
  615. NR_O6: r.enum:= R_O6;
  616. NR_O7: r.enum:= R_O7;
  617. NR_L0: r.enum:= R_L0;
  618. NR_L1: r.enum:= R_L1;
  619. NR_L2: r.enum:= R_L2;
  620. NR_L3: r.enum:= R_L3;
  621. NR_L4: r.enum:= R_L4;
  622. NR_L5: r.enum:= R_L5;
  623. NR_L6: r.enum:= R_L6;
  624. NR_L7: r.enum:= R_L7;
  625. NR_I0: r.enum:= R_I0;
  626. NR_I1: r.enum:= R_I1;
  627. NR_I2: r.enum:= R_I2;
  628. NR_I3: r.enum:= R_I3;
  629. NR_I4: r.enum:= R_I4;
  630. NR_I5: r.enum:= R_I5;
  631. NR_I6: r.enum:= R_I6;
  632. NR_I7: r.enum:= R_I7;
  633. else
  634. internalerror(200301082);
  635. end;
  636. end;
  637. function cgsize2subreg(s:Tcgsize):Tsubregister;
  638. begin
  639. cgsize2subreg:=R_SUBWHOLE;
  640. end;
  641. end.
  642. {
  643. $Log$
  644. Revision 1.30 2003-05-06 14:58:46 mazen
  645. - non used constants OT_* removed
  646. * some keywords moved lower case
  647. Revision 1.29 2003/04/29 12:03:52 mazen
  648. * TOldRegister isnow just an alias for TCpuRegister
  649. * TCpuRegister is used to define cpu register set physically available
  650. + CpuRegs array to easially create correspondence between TCpuRegister and TRegister
  651. Revision 1.28 2003/04/28 09:46:30 mazen
  652. + max_scratch_regs variable added because requested by common compiler code
  653. Revision 1.27 2003/04/23 13:35:39 peter
  654. * fix sparc compile
  655. Revision 1.26 2003/04/23 12:35:35 florian
  656. * fixed several issues with powerpc
  657. + applied a patch from Jonas for nested function calls (PowerPC only)
  658. * ...
  659. }