cpubase.pas 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. {*****************************************************************************}
  2. { File : cpubase.pas }
  3. { Author : Mazen NEIFER }
  4. { Project : Free Pascal Compiler (FPC) }
  5. { Creation date : 2002\04\26 }
  6. { Licence : GPL }
  7. { Bug report : [email protected] }
  8. {*****************************************************************************}
  9. { $Id$
  10. Copyright (c) 1998-2000 by Florian Klaempfl and Peter Vreman
  11. Contains the base types for the Scalable Processor ARChitecture (SPARC)
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. GNU General Public License for more details.
  20. You should have received a copy of the GNU General Public License
  21. along with this program; if not, write to the Free Software
  22. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23. ****************************************************************************}
  24. UNIT cpuBase;
  25. {$INCLUDE fpcdefs.inc}
  26. INTERFACE
  27. USES globals,cutils,cclasses,aasmbase,cpuinfo,cginfo;
  28. CONST
  29. {Size of the instruction table converted by nasmconv.pas}
  30. maxinfolen=8;
  31. {Defines the default address size for a processor}
  32. OS_ADDR=OS_32;
  33. {the natural int size for a processor}
  34. OS_INT=OS_32;
  35. {the maximum float size for a processor}
  36. OS_FLOAT=OS_F80;{$WARNING "OS_FLOAT" was set to "OS_F80" but not verified!}
  37. {the size of a vector register for a processor}
  38. OS_VECTOR=OS_M64;{$WARNING "OS_VECTOR" was set to "OS_M64" but not verified!}
  39. CONST
  40. {Operand types}
  41. OT_NONE = $00000000;
  42. OT_BITS8 = $00000001; { size, and other attributes, of the operand }
  43. OT_BITS16 = $00000002;
  44. OT_BITS32 = $00000004;
  45. OT_BITS64 = $00000008; { FPU only }
  46. OT_BITS80 = $00000010;
  47. OT_FAR = $00000020; { this means 16:16 or 16:32, like in CALL/JMP }
  48. OT_NEAR = $00000040;
  49. OT_SHORT = $00000080;
  50. OT_SIZE_MASK = $000000FF; { all the size attributes }
  51. OT_NON_SIZE = LongInt(not OT_SIZE_MASK);
  52. OT_SIGNED = $00000100; { the operand need to be signed -128-127 }
  53. OT_TO = $00000200; { operand is followed by a colon }
  54. { reverse effect in FADD, FSUB &c }
  55. OT_COLON = $00000400;
  56. OT_REGISTER = $00001000;
  57. OT_IMMEDIATE = $00002000;
  58. OT_IMM8 = $00002001;
  59. OT_IMM16 = $00002002;
  60. OT_IMM32 = $00002004;
  61. OT_IMM64 = $00002008;
  62. OT_IMM80 = $00002010;
  63. OT_REGMEM = $00200000; { for r/m, ie EA, operands }
  64. OT_REGNORM = $00201000; { 'normal' reg, qualifies as EA }
  65. OT_REG8 = $00201001;
  66. OT_REG16 = $00201002;
  67. OT_REG32 = $00201004;
  68. OT_MMXREG = $00201008; { MMX registers }
  69. OT_XMMREG = $00201010; { Katmai registers }
  70. OT_MEMORY = $00204000; { register number in 'basereg' }
  71. OT_MEM8 = $00204001;
  72. OT_MEM16 = $00204002;
  73. OT_MEM32 = $00204004;
  74. OT_MEM64 = $00204008;
  75. OT_MEM80 = $00204010;
  76. OT_FPUREG = $01000000; { floating point stack registers }
  77. OT_FPU0 = $01000800; { FPU stack register zero }
  78. OT_REG_SMASK = $00070000; { special register operands: these may be treated differently }
  79. { a mask for the following }
  80. OT_REG_ACCUM = $00211000; { accumulator: AL, AX or EAX }
  81. OT_REG_AL = $00211001; { REG_ACCUM | BITSxx }
  82. OT_REG_AX = $00211002; { ditto }
  83. OT_REG_EAX = $00211004; { and again }
  84. OT_REG_COUNT = $00221000; { counter: CL, CX or ECX }
  85. OT_REG_CL = $00221001; { REG_COUNT | BITSxx }
  86. OT_REG_CX = $00221002; { ditto }
  87. OT_REG_ECX = $00221004; { another one }
  88. OT_REG_DX = $00241002;
  89. OT_REG_SREG = $00081002; { any segment register }
  90. OT_REG_CS = $01081002; { CS }
  91. OT_REG_DESS = $02081002; { DS, ES, SS (non-CS 86 registers) }
  92. OT_REG_FSGS = $04081002; { FS, GS (386 extENDed registers) }
  93. OT_REG_CDT = $00101004; { CRn, DRn and TRn }
  94. OT_REG_CREG = $08101004; { CRn }
  95. OT_REG_CR4 = $08101404; { CR4 (Pentium only) }
  96. OT_REG_DREG = $10101004; { DRn }
  97. OT_REG_TREG = $20101004; { TRn }
  98. OT_MEM_OFFS = $00604000; { special type of EA }
  99. { simple [address] offset }
  100. OT_ONENESS = $00800000; { special type of immediate operand }
  101. { so UNITY == IMMEDIATE | ONENESS }
  102. OT_UNITY = $00802000; { for shift/rotate instructions }
  103. {Instruction flags }
  104. IF_NONE = $00000000;
  105. IF_SM = $00000001; { size match first two operands }
  106. IF_SM2 = $00000002;
  107. IF_SB = $00000004; { unsized operands can't be non-byte }
  108. IF_SW = $00000008; { unsized operands can't be non-word }
  109. IF_SD = $00000010; { unsized operands can't be nondword }
  110. IF_AR0 = $00000020; { SB, SW, SD applies to argument 0 }
  111. IF_AR1 = $00000040; { SB, SW, SD applies to argument 1 }
  112. IF_AR2 = $00000060; { SB, SW, SD applies to argument 2 }
  113. IF_ARMASK = $00000060; { mask for unsized argument spec }
  114. IF_PRIV = $00000100; { it's a privileged instruction }
  115. IF_SMM = $00000200; { it's only valid in SMM }
  116. IF_PROT = $00000400; { it's protected mode only }
  117. IF_UNDOC = $00001000; { it's an undocumented instruction }
  118. IF_FPU = $00002000; { it's an FPU instruction }
  119. IF_MMX = $00004000; { it's an MMX instruction }
  120. IF_3DNOW = $00008000; { it's a 3DNow! instruction }
  121. IF_SSE = $00010000; { it's a SSE (KNI, MMX2) instruction }
  122. IF_PMASK = LongInt($FF000000); { the mask for processor types }
  123. IF_PFMASK = LongInt($F001FF00); { the mask for disassembly "prefer" }
  124. IF_V7 = $00000000; { SPARC V7 instruction only (not supported)}
  125. IF_V8 = $01000000; { SPARC V8 instruction (the default)}
  126. IF_V9 = $02000000; { SPARC V9 instruction (not yet supported)}
  127. { added flags }
  128. IF_PRE = $40000000; { it's a prefix instruction }
  129. IF_PASS2 = LongInt($80000000);{instruction can change in a second pass?}
  130. TYPE
  131. {$WARNING CPU32 opcodes do not fully include the Ultra SPRAC instruction set.}
  132. TAsmOp=({$INCLUDE opcode.inc});
  133. op2strtable=ARRAY[TAsmOp]OF STRING[11];
  134. CONST
  135. FirstOp=Low(TAsmOp);
  136. LastOp=High(TAsmOp);
  137. std_op2str:op2strtable=({$INCLUDE attinstr.inc});
  138. {*****************************************************************************
  139. Operand Sizes
  140. *****************************************************************************}
  141. TYPE
  142. { S_NO = No Size of operand }
  143. { S_B = Byte size operand }
  144. { S_W = Word size operand }
  145. { S_L = DWord size operand }
  146. { USED FOR conversions in x86}
  147. { S_BW = Byte to word }
  148. { S_BL = Byte to long }
  149. { S_WL = Word to long }
  150. { Floating point types }
  151. { S_FS = single type (32 bit) }
  152. { S_FL = double/64bit integer }
  153. { S_FX = ExtENDed type }
  154. { S_IS = integer on 16 bits }
  155. { S_IL = integer on 32 bits }
  156. { S_IQ = integer on 64 bits }
  157. TOpSize=(S_NO,
  158. S_B,
  159. S_W,
  160. S_L,
  161. S_BW,
  162. S_BL,
  163. S_WL,
  164. S_IS,
  165. S_IL,
  166. S_IQ,
  167. S_FS,
  168. S_FL,
  169. S_FX,
  170. S_D,
  171. S_Q,
  172. S_FV,
  173. S_NEAR,
  174. S_FAR,
  175. S_SHORT);
  176. CONST
  177. { Intel style operands ! }
  178. opsize_2_type:ARRAY[0..2,topsize] of LongInt=(
  179. (OT_NONE,
  180. OT_BITS8,OT_BITS16,OT_BITS32,OT_BITS16,OT_BITS32,OT_BITS32,
  181. OT_BITS16,OT_BITS32,OT_BITS64,
  182. OT_BITS32,OT_BITS64,OT_BITS80,OT_BITS64,OT_BITS64,OT_BITS64,
  183. OT_NEAR,OT_FAR,OT_SHORT
  184. ),
  185. (OT_NONE,
  186. OT_BITS8,OT_BITS16,OT_BITS32,OT_BITS8,OT_BITS8,OT_BITS16,
  187. OT_BITS16,OT_BITS32,OT_BITS64,
  188. OT_BITS32,OT_BITS64,OT_BITS80,OT_BITS64,OT_BITS64,OT_BITS64,
  189. OT_NEAR,OT_FAR,OT_SHORT
  190. ),
  191. (OT_NONE,
  192. OT_BITS8,OT_BITS16,OT_BITS32,OT_NONE,OT_NONE,OT_NONE,
  193. OT_BITS16,OT_BITS32,OT_BITS64,
  194. OT_BITS32,OT_BITS64,OT_BITS80,OT_BITS64,OT_BITS64,OT_BITS64,
  195. OT_NEAR,OT_FAR,OT_SHORT
  196. )
  197. );
  198. {$IFDEF ATTOP}
  199. att_opsize2str : ARRAY[topsize] of string[2] = ('',
  200. 'b','w','l','bw','bl','wl',
  201. 's','l','q',
  202. 's','l','t','d','q','v',
  203. '','',''
  204. );
  205. {$ENDIF}
  206. {*****************************************************************************
  207. Conditions
  208. *****************************************************************************}
  209. TYPE
  210. TAsmCond=(C_None,
  211. C_A,C_AE,C_B,C_BE,C_C,C_E,C_G,C_GE,C_L,C_LE,C_NA,C_NAE,
  212. C_NB,C_NBE,C_NC,C_NE,C_NG,C_NGE,C_NL,C_NLE,C_NO,C_NP,
  213. C_NS,C_NZ,C_O,C_P,C_PE,C_PO,C_S,C_Z
  214. );
  215. CONST
  216. cond2str:ARRAY[TAsmCond] of string[3]=('',
  217. 'a','ae','b','be','c','e','g','ge','l','le','na','nae',
  218. 'nb','nbe','nc','ne','ng','nge','nl','nle','no','np',
  219. 'ns','nz','o','p','pe','po','s','z'
  220. );
  221. inverse_cond:ARRAY[TAsmCond] of TAsmCond=(C_None,
  222. C_NA,C_NAE,C_NB,C_NBE,C_NC,C_NE,C_NG,C_NGE,C_NL,C_NLE,C_A,C_AE,
  223. C_B,C_BE,C_C,C_E,C_G,C_GE,C_L,C_LE,C_O,C_P,
  224. C_S,C_Z,C_NO,C_NP,C_NP,C_P,C_NS,C_NZ
  225. );
  226. CONST
  227. CondAsmOps=3;
  228. CondAsmOp:ARRAY[0..CondAsmOps-1] of TAsmOp=(A_FCMPd, A_JMPL, A_FCMPs);
  229. CondAsmOpStr:ARRAY[0..CondAsmOps-1] of string[4]=('FCMPd','JMPL','FCMPs');
  230. {*****************************************************************************
  231. Registers
  232. *****************************************************************************}
  233. TYPE
  234. { enumeration for registers, don't change the order }
  235. { it's used by the register size conversions }
  236. TRegister=({$INCLUDE registers.inc});
  237. TRegister64=PACKED RECORD
  238. {A type to store register locations for 64 Bit values.}
  239. RegLo,RegHi:TRegister;
  240. END;
  241. treg64=tregister64;{alias for compact code}
  242. TRegisterSet=SET OF TRegister;
  243. reg2strtable=ARRAY[tregister] OF STRING[6];
  244. CONST
  245. firstreg = low(tregister);
  246. lastreg = high(tregister);
  247. std_reg2str:reg2strtable=({$INCLUDE strregs.inc});
  248. {*****************************************************************************
  249. Flags
  250. *****************************************************************************}
  251. TYPE
  252. TResFlags=(
  253. F_E, {Equal}
  254. F_NE, {Not Equal}
  255. F_G, {Greater}
  256. F_L, {Less}
  257. F_GE, {Greater or Equal}
  258. F_LE, {Less or Equal}
  259. F_C, {Carry}
  260. F_NC, {Not Carry}
  261. F_A, {Above}
  262. F_AE, {Above or Equal}
  263. F_B, {Below}
  264. F_BE {Below or Equal}
  265. );
  266. {*****************************************************************************
  267. Reference
  268. *****************************************************************************}
  269. TYPE
  270. trefoptions=(ref_none,ref_parafixup,ref_localfixup,ref_selffixup);
  271. { immediate/reference record }
  272. poperreference = ^treference;
  273. treference = packed record
  274. segment,
  275. base,
  276. index : tregister;
  277. scalefactor : byte;
  278. offset : LongInt;
  279. symbol : tasmsymbol;
  280. offsetfixup : LongInt;
  281. options : trefoptions;
  282. {$ifdef newcg}
  283. alignment : byte;
  284. {$ENDif newcg}
  285. END;
  286. { reference record }
  287. PParaReference=^TParaReference;
  288. TParaReference=PACKED RECORD
  289. Index:TRegister;
  290. Offset:longint;
  291. END;
  292. {*****************************************************************************
  293. Operands
  294. *****************************************************************************}
  295. { Types of operand }
  296. toptype=(top_none,top_reg,top_ref,top_CONST,top_symbol);
  297. toper=record
  298. ot : LongInt;
  299. case typ : toptype of
  300. top_none : ();
  301. top_reg : (reg:tregister);
  302. top_ref : (ref:poperreference);
  303. top_CONST : (val:aword);
  304. top_symbol : (sym:tasmsymbol;symofs:LongInt);
  305. END;
  306. {*****************************************************************************
  307. Argument Classification
  308. *****************************************************************************}
  309. TYPE
  310. TArgClass = (
  311. { the following classes should be defined by all processor implemnations }
  312. AC_NOCLASS,
  313. AC_MEMORY,
  314. AC_INTEGER,
  315. AC_FPU,
  316. { the following argument classes are i386 specific }
  317. AC_FPUUP,
  318. AC_SSE,
  319. AC_SSEUP);
  320. {*****************************************************************************
  321. Generic Location
  322. *****************************************************************************}
  323. TYPE
  324. TLoc=( {information about the location of an operand}
  325. LOC_INVALID, { added for tracking problems}
  326. LOC_CONSTANT, { CONSTant value }
  327. LOC_JUMP, { boolean results only, jump to false or true label }
  328. LOC_FLAGS, { boolean results only, flags are set }
  329. LOC_CREFERENCE, { in memory CONSTant value }
  330. LOC_REFERENCE, { in memory value }
  331. LOC_REGISTER, { in a processor register }
  332. LOC_CREGISTER, { Constant register which shouldn't be modified }
  333. LOC_FPUREGISTER, { FPU stack }
  334. LOC_CFPUREGISTER, { if it is a FPU register variable on the fpu stack }
  335. LOC_MMXREGISTER, { MMX register }
  336. LOC_CMMXREGISTER, { MMX register variable }
  337. LOC_MMREGISTER,
  338. LOC_CMMREGISTER
  339. );
  340. {tparamlocation describes where a parameter for a procedure is stored.
  341. References are given from the caller's point of view. The usual TLocation isn't
  342. used, because contains a lot of unnessary fields.}
  343. TParaLocation=PACKED RECORD
  344. Size:TCGSize;
  345. Loc:TLoc;
  346. sp_fixup:LongInt;
  347. CASE TLoc OF
  348. LOC_REFERENCE:(reference:tparareference);
  349. { segment in reference at the same place as in loc_register }
  350. LOC_REGISTER,LOC_CREGISTER : (
  351. CASE LongInt OF
  352. 1 : (register,registerhigh : tregister);
  353. { overlay a registerlow }
  354. 2 : (registerlow : tregister);
  355. { overlay a 64 Bit register type }
  356. 3 : (reg64 : tregister64);
  357. 4 : (register64 : tregister64);
  358. );
  359. { it's only for better handling }
  360. LOC_MMXREGISTER,LOC_CMMXREGISTER : (mmxreg : tregister);
  361. END;
  362. TLocation=PACKED RECORD
  363. loc : TLoc;
  364. size : TCGSize;
  365. case TLoc of
  366. LOC_FLAGS : (resflags : tresflags);
  367. LOC_CONSTANT : (
  368. case longint of
  369. 1 : (value : AWord);
  370. 2 : (valuelow, valuehigh:AWord);
  371. { overlay a complete 64 Bit value }
  372. 3 : (valueqword : qword);
  373. );
  374. LOC_CREFERENCE,
  375. LOC_REFERENCE : (reference : treference);
  376. { segment in reference at the same place as in loc_register }
  377. LOC_REGISTER,LOC_CREGISTER : (
  378. case longint of
  379. 1 : (register,registerhigh,segment : tregister);
  380. { overlay a registerlow }
  381. 2 : (registerlow : tregister);
  382. { overlay a 64 Bit register type }
  383. 3 : (reg64 : tregister64);
  384. 4 : (register64 : tregister64);
  385. );
  386. { it's only for better handling }
  387. LOC_MMXREGISTER,LOC_CMMXREGISTER : (mmxreg : tregister);
  388. end;
  389. {*****************************************************************************
  390. Constants
  391. *****************************************************************************}
  392. CONST
  393. general_registers = [R_G0..R_I7];
  394. { legEND: }
  395. { xxxregs = set of all possibly used registers of that type in the code }
  396. { generator }
  397. { usableregsxxx = set of all 32bit components of registers that can be }
  398. { possible allocated to a regvar or using getregisterxxx (this }
  399. { excludes registers which can be only used for parameter }
  400. { passing on ABI's that define this) }
  401. { c_countusableregsxxx = amount of registers in the usableregsxxx set }
  402. intregs = [R_G0..R_I7];
  403. usableregsint = general_registers;
  404. c_countusableregsint = 4;
  405. fpuregs = [R_F0..R_F31];
  406. usableregsfpu = [];
  407. c_countusableregsfpu = 0;
  408. mmregs = [R_G0..R_G7];
  409. usableregsmm = [R_G0..R_G7];
  410. c_countusableregsmm = 8;
  411. firstsaveintreg = R_G0;
  412. lastsaveintreg = R_I7;
  413. firstsavefpureg = R_F0;
  414. lastsavefpureg = R_F31;
  415. firstsavemmreg = R_G0;
  416. lastsavemmreg = R_I7;
  417. lowsavereg = R_G0;
  418. highsavereg = R_I7;
  419. ALL_REGISTERS = [lowsavereg..highsavereg];
  420. lvaluelocations = [LOC_REFERENCE,LOC_CFPUREGISTER,
  421. LOC_CREGISTER,LOC_MMXREGISTER,LOC_CMMXREGISTER];
  422. {
  423. registers_saved_on_cdecl = [R_ESI,R_EDI,R_EBX];}
  424. {*****************************************************************************
  425. GDB Information
  426. *****************************************************************************}
  427. {# Register indexes for stabs information, when some
  428. parameters or variables are stored in registers.
  429. Taken from rs6000.h (DBX_REGISTER_NUMBER)
  430. from GCC 3.x source code. PowerPC has 1:1 mapping
  431. according to the order of the registers defined
  432. in GCC
  433. }
  434. stab_regindex:ARRAY[tregister]OF ShortInt=({$INCLUDE stabregi.inc});
  435. { generic register names }
  436. stack_pointer_reg =R_O6;
  437. frame_pointer_reg =R_I6;
  438. self_pointer_reg =R_G5;
  439. {There is no accumulator in the SPARC architecture. There are just families of
  440. registers. All registers belonging to the same family are identical except in
  441. the "global registers" family where GO is different from the others : G0 gives
  442. always 0 when it is red and thows away any value written to it}
  443. accumulator = R_L0;
  444. accumulatorhigh = R_L7;
  445. fpu_result_reg =R_F0;
  446. mmresultreg =R_G0;
  447. {*****************************************************************************}
  448. { GCC /ABI linking information }
  449. {*****************************************************************************}
  450. {# Registers which must be saved when calling a routine declared as cppdecl,
  451. cdecl, stdcall, safecall, palmossyscall. The registers saved should be the ones
  452. as defined in the target ABI and / or GCC.
  453. This value can be deduced from the CALLED_USED_REGISTERS array in the GCC
  454. source.}
  455. std_saved_registers=[R_O6];
  456. {# Required parameter alignment when calling a routine declared as stdcall and
  457. cdecl. The alignment value should be the one defined by GCC or the target ABI.
  458. The value of this constant is equal to the constant
  459. PARM_BOUNDARY / BITS_PER_UNIT in the GCC source.}
  460. std_param_align=4;
  461. {# Registers which are defined as scratch and no need to save across routine
  462. calls or in assembler blocks.}
  463. ScratchRegsCount=3;
  464. scratch_regs:ARRAY[1..ScratchRegsCount]OF TRegister=(R_O4,R_O5,R_I7);
  465. {$WARNING FIXME : Scratch registers list has to be verified}
  466. { low and high of the available maximum width integer general purpose }
  467. { registers }
  468. LoGPReg = R_G0;
  469. HiGPReg = R_I7;
  470. { low and high of every possible width general purpose register (same as }
  471. { above on most architctures apart from the 80x86) }
  472. LoReg = R_G0;
  473. HiReg = R_I7;
  474. cpuflags = [];
  475. { sizes }
  476. pointersize = 4;
  477. extENDed_size = 8;{SPARC architecture uses IEEE floating point numbers}
  478. mmreg_size = 8;
  479. sizepostfix_pointer = S_L;
  480. {*****************************************************************************
  481. Instruction table
  482. *****************************************************************************}
  483. {$ifndef NOAG386BIN}
  484. TYPE
  485. tinsentry=packed record
  486. opcode : tasmop;
  487. ops : byte;
  488. optypes : ARRAY[0..2] of LongInt;
  489. code : ARRAY[0..maxinfolen] of char;
  490. flags : LongInt;
  491. END;
  492. pinsentry=^tinsentry;
  493. TInsTabCache=ARRAY[TasmOp] of LongInt;
  494. PInsTabCache=^TInsTabCache;
  495. VAR
  496. InsTabCache : PInsTabCache;
  497. {$ENDif NOAG386BIN}
  498. {*****************************************************************************
  499. Helpers
  500. *****************************************************************************}
  501. CONST
  502. maxvarregs=30;
  503. VarRegs:ARRAY[1..maxvarregs]OF TRegister=(
  504. R_G0,R_G1,R_G2,R_G3,R_G4,R_G5,R_G6,R_G7,
  505. R_O0,R_O1,R_O2,R_O3,R_O4,R_O5,{R_R14=R_SP}R_O7,
  506. R_L0,R_L1,R_L2,R_L3,R_L4,R_L5,R_L6,R_L7,
  507. R_I0,R_I1,R_I2,R_I3,R_I4,R_I5,{R_R30=R_FP}R_I7
  508. );
  509. maxfpuvarregs = 8;
  510. max_operands = 3;
  511. maxintregs = maxvarregs;
  512. maxfpuregs = maxfpuvarregs;
  513. FUNCTION reg2str(r:tregister):string;
  514. FUNCTION is_calljmp(o:tasmop):boolean;
  515. FUNCTION flags_to_cond(CONST f:TResFlags):TAsmCond;
  516. IMPLEMENTATION
  517. FUNCTION reg2str(r:tregister):string;
  518. TYPE
  519. TStrReg=ARRAY[TRegister]OF STRING[5];
  520. CONST
  521. StrReg:TStrReg=({$INCLUDE strregs.inc});
  522. BEGIN
  523. reg2str:=StrReg[r];
  524. END;
  525. FUNCTION is_calljmp(o:tasmop):boolean;
  526. BEGIN
  527. CASE o OF
  528. A_CALL,A_JMPL:
  529. is_calljmp:=true;
  530. ELSE
  531. is_calljmp:=false;
  532. END;
  533. END;
  534. FUNCTION flags_to_cond(CONST f:TResFlags):TAsmCond;
  535. CONST
  536. flags_2_cond:ARRAY[TResFlags]OF TAsmCond=(C_E,C_NE,C_G,C_L,C_GE,C_LE,C_C,C_NC,C_A,C_AE,C_B,C_BE);
  537. BEGIN
  538. result:=flags_2_cond[f];
  539. END;
  540. END.
  541. {
  542. $Log$
  543. Revision 1.6 2002-09-24 03:57:53 mazen
  544. * some cleanup was made
  545. }