cpubase.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl and Peter Vreman
  3. Contains the base types for the ARM
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. {# Base unit for processor information. This unit contains
  18. enumerations of registers, opcodes, sizes, and other
  19. such things which are processor specific.
  20. }
  21. unit cpubase;
  22. {$define USEINLINE}
  23. {$i fpcdefs.inc}
  24. interface
  25. uses
  26. cutils,cclasses,
  27. globtype,globals,
  28. cpuinfo,
  29. aasmbase,
  30. cgbase
  31. ;
  32. {*****************************************************************************
  33. Assembler Opcodes
  34. *****************************************************************************}
  35. type
  36. TAsmOp= {$i armop.inc}
  37. {This is a bit of a hack, because there are more than 256 ARM Assembly Ops
  38. But FPC currently can't handle more than 256 elements in a set.}
  39. TCommonAsmOps = Set of A_None .. A_UQASX;
  40. { This should define the array of instructions as string }
  41. op2strtable=array[tasmop] of string[11];
  42. const
  43. { First value of opcode enumeration }
  44. firstop = low(tasmop);
  45. { Last value of opcode enumeration }
  46. lastop = high(tasmop);
  47. {*****************************************************************************
  48. Registers
  49. *****************************************************************************}
  50. type
  51. { Number of registers used for indexing in tables }
  52. tregisterindex=0..{$i rarmnor.inc}-1;
  53. const
  54. { Available Superregisters }
  55. {$i rarmsup.inc}
  56. RS_PC = RS_R15;
  57. { No Subregisters }
  58. R_SUBWHOLE = R_SUBNONE;
  59. { Available Registers }
  60. {$i rarmcon.inc}
  61. { aliases }
  62. NR_PC = NR_R15;
  63. { Integer Super registers first and last }
  64. first_int_supreg = RS_R0;
  65. first_int_imreg = $10;
  66. { Float Super register first and last }
  67. first_fpu_supreg = RS_F0;
  68. first_fpu_imreg = $08;
  69. { MM Super register first and last }
  70. first_mm_supreg = RS_S0;
  71. first_mm_imreg = $30;
  72. { TODO: Calculate bsstart}
  73. regnumber_count_bsstart = 64;
  74. regnumber_table : array[tregisterindex] of tregister = (
  75. {$i rarmnum.inc}
  76. );
  77. regstabs_table : array[tregisterindex] of shortint = (
  78. {$i rarmsta.inc}
  79. );
  80. regdwarf_table : array[tregisterindex] of shortint = (
  81. {$i rarmdwa.inc}
  82. );
  83. { registers which may be destroyed by calls }
  84. VOLATILE_INTREGISTERS = [RS_R0..RS_R3,RS_R12..RS_R14];
  85. VOLATILE_FPUREGISTERS = [RS_F0..RS_F3];
  86. VOLATILE_MMREGISTERS = [RS_D0..RS_D7,RS_D16..RS_D31,RS_S1..RS_S15];
  87. VOLATILE_INTREGISTERS_DARWIN = [RS_R0..RS_R3,RS_R9,RS_R12..RS_R14];
  88. type
  89. totherregisterset = set of tregisterindex;
  90. {*****************************************************************************
  91. Instruction post fixes
  92. *****************************************************************************}
  93. type
  94. { ARM instructions load/store and arithmetic instructions
  95. can have several instruction post fixes which are collected
  96. in this enumeration
  97. }
  98. TOpPostfix = (PF_None,
  99. { update condition flags
  100. or floating point single }
  101. PF_S,
  102. { floating point size }
  103. PF_D,PF_E,PF_P,PF_EP,
  104. { load/store }
  105. PF_B,PF_SB,PF_BT,PF_H,PF_SH,PF_T,
  106. { multiple load/store address modes }
  107. PF_IA,PF_IB,PF_DA,PF_DB,PF_FD,PF_FA,PF_ED,PF_EA,
  108. { multiple load/store vfp address modes }
  109. PF_IAD,PF_DBD,PF_FDD,PF_EAD,
  110. PF_IAS,PF_DBS,PF_FDS,PF_EAS,
  111. PF_IAX,PF_DBX,PF_FDX,PF_EAX,
  112. { FPv4 postfixes }
  113. PF_32,PF_64,PF_F32,PF_F64,
  114. PF_F32S32,PF_F32U32,
  115. PF_S32F32,PF_U32F32
  116. );
  117. TOpPostfixes = set of TOpPostfix;
  118. TRoundingMode = (RM_None,RM_P,RM_M,RM_Z);
  119. const
  120. cgsize2fpuoppostfix : array[OS_NO..OS_F128] of toppostfix = (
  121. PF_None,
  122. PF_None,PF_None,PF_None,PF_None,PF_None,PF_None,PF_None,PF_None,PF_None,PF_None,
  123. PF_S,PF_D,PF_E,PF_None,PF_None);
  124. oppostfix2str : array[TOpPostfix] of string[8] = ('',
  125. 's',
  126. 'd','e','p','ep',
  127. 'b','sb','bt','h','sh','t',
  128. 'ia','ib','da','db','fd','fa','ed','ea',
  129. 'iad','dbd','fdd','ead',
  130. 'ias','dbs','fds','eas',
  131. 'iax','dbx','fdx','eax',
  132. '.32','.64','.f32','.f64',
  133. '.f32.s32','.f32.u32',
  134. '.s32.f32','.u32.f32');
  135. roundingmode2str : array[TRoundingMode] of string[1] = ('',
  136. 'p','m','z');
  137. {*****************************************************************************
  138. Conditions
  139. *****************************************************************************}
  140. type
  141. TAsmCond=(C_None,
  142. C_EQ,C_NE,C_CS,C_CC,C_MI,C_PL,C_VS,C_VC,C_HI,C_LS,
  143. C_GE,C_LT,C_GT,C_LE,C_AL,C_NV
  144. );
  145. TAsmConds = set of TAsmCond;
  146. const
  147. cond2str : array[TAsmCond] of string[2]=('',
  148. 'eq','ne','cs','cc','mi','pl','vs','vc','hi','ls',
  149. 'ge','lt','gt','le','al','nv'
  150. );
  151. uppercond2str : array[TAsmCond] of string[2]=('',
  152. 'EQ','NE','CS','CC','MI','PL','VS','VC','HI','LS',
  153. 'GE','LT','GT','LE','AL','NV'
  154. );
  155. {*****************************************************************************
  156. Flags
  157. *****************************************************************************}
  158. type
  159. TResFlags = (F_EQ,F_NE,F_CS,F_CC,F_MI,F_PL,F_VS,F_VC,F_HI,F_LS,
  160. F_GE,F_LT,F_GT,F_LE);
  161. {*****************************************************************************
  162. Operands
  163. *****************************************************************************}
  164. taddressmode = (AM_OFFSET,AM_PREINDEXED,AM_POSTINDEXED);
  165. tshiftmode = (SM_None,SM_LSL,SM_LSR,SM_ASR,SM_ROR,SM_RRX);
  166. tupdatereg = (UR_None,UR_Update);
  167. pshifterop = ^tshifterop;
  168. tshifterop = record
  169. shiftmode : tshiftmode;
  170. rs : tregister;
  171. shiftimm : byte;
  172. end;
  173. tcpumodeflag = (mfA, mfI, mfF);
  174. tcpumodeflags = set of tcpumodeflag;
  175. tspecialregflag = (srC, srX, srS, srF);
  176. tspecialregflags = set of tspecialregflag;
  177. {*****************************************************************************
  178. Constants
  179. *****************************************************************************}
  180. const
  181. max_operands = 6;
  182. maxintregs = 15;
  183. maxfpuregs = 8;
  184. maxaddrregs = 0;
  185. {*****************************************************************************
  186. Operand Sizes
  187. *****************************************************************************}
  188. type
  189. topsize = (S_NO,
  190. S_B,S_W,S_L,S_BW,S_BL,S_WL,
  191. S_IS,S_IL,S_IQ,
  192. S_FS,S_FL,S_FX,S_D,S_Q,S_FV,S_FXX
  193. );
  194. {*****************************************************************************
  195. Constants
  196. *****************************************************************************}
  197. const
  198. maxvarregs = 7;
  199. varregs : Array [1..maxvarregs] of tsuperregister =
  200. (RS_R4,RS_R5,RS_R6,RS_R7,RS_R8,RS_R9,RS_R10);
  201. maxfpuvarregs = 4;
  202. fpuvarregs : Array [1..maxfpuvarregs] of tsuperregister =
  203. (RS_F4,RS_F5,RS_F6,RS_F7);
  204. {*****************************************************************************
  205. Default generic sizes
  206. *****************************************************************************}
  207. { Defines the default address size for a processor, }
  208. OS_ADDR = OS_32;
  209. { the natural int size for a processor,
  210. has to match osuinttype/ossinttype as initialized in psystem }
  211. OS_INT = OS_32;
  212. OS_SINT = OS_S32;
  213. { the maximum float size for a processor, }
  214. OS_FLOAT = OS_F64;
  215. { the size of a vector register for a processor }
  216. OS_VECTOR = OS_M32;
  217. {*****************************************************************************
  218. Generic Register names
  219. *****************************************************************************}
  220. { Stack pointer register }
  221. NR_STACK_POINTER_REG = NR_R13;
  222. RS_STACK_POINTER_REG = RS_R13;
  223. { Frame pointer register (initialized in tarmprocinfo.init_framepointer) }
  224. RS_FRAME_POINTER_REG: tsuperregister = RS_NO;
  225. NR_FRAME_POINTER_REG: tregister = NR_NO;
  226. { Register for addressing absolute data in a position independant way,
  227. such as in PIC code. The exact meaning is ABI specific. For
  228. further information look at GCC source : PIC_OFFSET_TABLE_REGNUM
  229. }
  230. NR_PIC_OFFSET_REG = NR_R9;
  231. { Results are returned in this register (32-bit values) }
  232. NR_FUNCTION_RETURN_REG = NR_R0;
  233. RS_FUNCTION_RETURN_REG = RS_R0;
  234. { The value returned from a function is available in this register }
  235. NR_FUNCTION_RESULT_REG = NR_FUNCTION_RETURN_REG;
  236. RS_FUNCTION_RESULT_REG = RS_FUNCTION_RETURN_REG;
  237. NR_FPU_RESULT_REG = NR_F0;
  238. NR_MM_RESULT_REG = NR_D0;
  239. NR_RETURN_ADDRESS_REG = NR_FUNCTION_RETURN_REG;
  240. { Offset where the parent framepointer is pushed }
  241. PARENT_FRAMEPOINTER_OFFSET = 0;
  242. NR_DEFAULTFLAGS = NR_CPSR;
  243. RS_DEFAULTFLAGS = RS_CPSR;
  244. { Low part of 64bit return value }
  245. function NR_FUNCTION_RESULT64_LOW_REG: tregister;{$ifdef USEINLINE}inline;{$endif USEINLINE}
  246. function RS_FUNCTION_RESULT64_LOW_REG: shortint;{$ifdef USEINLINE}inline;{$endif USEINLINE}
  247. { High part of 64bit return value }
  248. function NR_FUNCTION_RESULT64_HIGH_REG: tregister;{$ifdef USEINLINE}inline;{$endif USEINLINE}
  249. function RS_FUNCTION_RESULT64_HIGH_REG: shortint;{$ifdef USEINLINE}inline;{$endif USEINLINE}
  250. {*****************************************************************************
  251. GCC /ABI linking information
  252. *****************************************************************************}
  253. const
  254. { Registers which must be saved when calling a routine declared as
  255. cppdecl, cdecl, stdcall, safecall, palmossyscall. The registers
  256. saved should be the ones as defined in the target ABI and / or GCC.
  257. This value can be deduced from the CALLED_USED_REGISTERS array in the
  258. GCC source.
  259. }
  260. saved_standard_registers : array[0..6] of tsuperregister =
  261. (RS_R4,RS_R5,RS_R6,RS_R7,RS_R8,RS_R9,RS_R10);
  262. { this is only for the generic code which is not used for this architecture }
  263. saved_mm_registers : array[0..0] of tsuperregister = (RS_INVALID);
  264. { Required parameter alignment when calling a routine declared as
  265. stdcall and cdecl. The alignment value should be the one defined
  266. by GCC or the target ABI.
  267. The value of this constant is equal to the constant
  268. PARM_BOUNDARY / BITS_PER_UNIT in the GCC source.
  269. }
  270. std_param_align = 4;
  271. {*****************************************************************************
  272. Helpers
  273. *****************************************************************************}
  274. { Returns the tcgsize corresponding with the size of reg.}
  275. function reg_cgsize(const reg: tregister) : tcgsize;
  276. function cgsize2subreg(regtype: tregistertype; s:Tcgsize):Tsubregister;
  277. function is_calljmp(o:tasmop):boolean;{$ifdef USEINLINE}inline;{$endif USEINLINE}
  278. procedure inverse_flags(var f: TResFlags);
  279. function flags_to_cond(const f: TResFlags) : TAsmCond;
  280. function findreg_by_number(r:Tregister):tregisterindex;
  281. function std_regnum_search(const s:string):Tregister;
  282. function std_regname(r:Tregister):string;
  283. function inverse_cond(const c: TAsmCond): TAsmCond; {$ifdef USEINLINE}inline;{$endif USEINLINE}
  284. function conditions_equal(const c1, c2: TAsmCond): boolean; {$ifdef USEINLINE}inline;{$endif USEINLINE}
  285. procedure shifterop_reset(var so : tshifterop); {$ifdef USEINLINE}inline;{$endif USEINLINE}
  286. function is_pc(const r : tregister) : boolean; {$ifdef USEINLINE}inline;{$endif USEINLINE}
  287. function is_shifter_const(d : aint;var imm_shift : byte) : boolean;
  288. function is_thumb_imm(d : aint) : boolean; { Doesn't handle ROR_C detection }
  289. function split_into_shifter_const(value : aint;var imm1: dword; var imm2: dword):boolean;
  290. function dwarf_reg(r:tregister):shortint;
  291. function IsIT(op: TAsmOp) : boolean;
  292. function GetITLevels(op: TAsmOp) : longint;
  293. implementation
  294. uses
  295. systems,rgBase,verbose;
  296. const
  297. std_regname_table : TRegNameTable = (
  298. {$i rarmstd.inc}
  299. );
  300. regnumber_index : array[tregisterindex] of tregisterindex = (
  301. {$i rarmrni.inc}
  302. );
  303. std_regname_index : array[tregisterindex] of tregisterindex = (
  304. {$i rarmsri.inc}
  305. );
  306. function cgsize2subreg(regtype: tregistertype; s:Tcgsize):Tsubregister;
  307. begin
  308. case regtype of
  309. R_MMREGISTER:
  310. begin
  311. case s of
  312. OS_F32:
  313. cgsize2subreg:=R_SUBFS;
  314. OS_F64:
  315. cgsize2subreg:=R_SUBFD;
  316. else
  317. internalerror(2009112701);
  318. end;
  319. end;
  320. else
  321. cgsize2subreg:=R_SUBWHOLE;
  322. end;
  323. end;
  324. function reg_cgsize(const reg: tregister): tcgsize;
  325. begin
  326. case getregtype(reg) of
  327. R_INTREGISTER :
  328. reg_cgsize:=OS_32;
  329. R_FPUREGISTER :
  330. reg_cgsize:=OS_F80;
  331. R_MMREGISTER :
  332. begin
  333. case getsubreg(reg) of
  334. R_SUBFD,
  335. R_SUBWHOLE:
  336. result:=OS_F64;
  337. R_SUBFS:
  338. result:=OS_F32;
  339. else
  340. internalerror(2009112903);
  341. end;
  342. end;
  343. else
  344. internalerror(200303181);
  345. end;
  346. end;
  347. function is_calljmp(o:tasmop):boolean;{$ifdef USEINLINE}inline;{$endif USEINLINE}
  348. begin
  349. { This isn't 100% perfect because the arm allows jumps also by writing to PC=R15.
  350. To overcome this problem we simply forbid that FPC generates jumps by loading R15 }
  351. is_calljmp:= o in [A_B,A_BL,A_BX,A_BLX];
  352. end;
  353. procedure inverse_flags(var f: TResFlags);
  354. const
  355. inv_flags: array[TResFlags] of TResFlags =
  356. (F_NE,F_EQ,F_CC,F_CS,F_PL,F_MI,F_VC,F_VS,F_LS,F_HI,
  357. F_LT,F_GE,F_LE,F_GT);
  358. begin
  359. f:=inv_flags[f];
  360. end;
  361. function flags_to_cond(const f: TResFlags) : TAsmCond;
  362. const
  363. flag_2_cond: array[F_EQ..F_LE] of TAsmCond =
  364. (C_EQ,C_NE,C_CS,C_CC,C_MI,C_PL,C_VS,C_VC,C_HI,C_LS,
  365. C_GE,C_LT,C_GT,C_LE);
  366. begin
  367. if f>high(flag_2_cond) then
  368. internalerror(200112301);
  369. result:=flag_2_cond[f];
  370. end;
  371. function findreg_by_number(r:Tregister):tregisterindex;
  372. begin
  373. result:=rgBase.findreg_by_number_table(r,regnumber_index);
  374. end;
  375. function std_regnum_search(const s:string):Tregister;
  376. begin
  377. result:=regnumber_table[findreg_by_name_table(s,std_regname_table,std_regname_index)];
  378. end;
  379. function std_regname(r:Tregister):string;
  380. var
  381. p : tregisterindex;
  382. begin
  383. p:=findreg_by_number_table(r,regnumber_index);
  384. if p<>0 then
  385. result:=std_regname_table[p]
  386. else
  387. result:=generic_regname(r);
  388. end;
  389. procedure shifterop_reset(var so : tshifterop);{$ifdef USEINLINE}inline;{$endif USEINLINE}
  390. begin
  391. FillChar(so,sizeof(so),0);
  392. end;
  393. function is_pc(const r : tregister) : boolean; {$ifdef USEINLINE}inline;{$endif USEINLINE}
  394. begin
  395. is_pc:=(r=NR_R15);
  396. end;
  397. function inverse_cond(const c: TAsmCond): TAsmCond; {$ifdef USEINLINE}inline;{$endif USEINLINE}
  398. const
  399. inverse: array[TAsmCond] of TAsmCond=(C_None,
  400. C_NE,C_EQ,C_CC,C_CS,C_PL,C_MI,C_VC,C_VS,C_LS,C_HI,
  401. C_LT,C_GE,C_LE,C_GT,C_None,C_None
  402. );
  403. begin
  404. result := inverse[c];
  405. end;
  406. function conditions_equal(const c1, c2: TAsmCond): boolean; {$ifdef USEINLINE}inline;{$endif USEINLINE}
  407. begin
  408. result := c1 = c2;
  409. end;
  410. function is_shifter_const(d : aint;var imm_shift : byte) : boolean;
  411. var
  412. i : longint;
  413. begin
  414. if current_settings.cputype in cpu_thumb2 then
  415. begin
  416. for i:=0 to 24 do
  417. begin
  418. if (dword(d) and not($ff shl i))=0 then
  419. begin
  420. imm_shift:=i;
  421. result:=true;
  422. exit;
  423. end;
  424. end;
  425. end
  426. else
  427. begin
  428. for i:=0 to 15 do
  429. begin
  430. if (dword(d) and not(roldword($ff,i*2)))=0 then
  431. begin
  432. imm_shift:=i*2;
  433. result:=true;
  434. exit;
  435. end;
  436. end;
  437. end;
  438. result:=false;
  439. end;
  440. function is_thumb_imm(d: aint): boolean;
  441. var
  442. t : aint;
  443. i : longint;
  444. imm : byte;
  445. begin
  446. result:=false;
  447. if (d and $FF) = d then
  448. begin
  449. result:=true;
  450. exit;
  451. end;
  452. if ((d and $FF00FF00) = 0) and
  453. ((d shr 16)=(d and $FFFF)) then
  454. begin
  455. result:=true;
  456. exit;
  457. end;
  458. if ((d and $00FF00FF) = 0) and
  459. ((d shr 16)=(d and $FFFF)) then
  460. begin
  461. result:=true;
  462. exit;
  463. end;
  464. if ((d shr 16)=(d and $FFFF)) and
  465. ((d shr 8)=(d and $FF)) then
  466. begin
  467. result:=true;
  468. exit;
  469. end;
  470. if is_shifter_const(d,imm) then
  471. begin
  472. result:=true;
  473. exit;
  474. end;
  475. end;
  476. function split_into_shifter_const(value : aint;var imm1: dword; var imm2: dword) : boolean;
  477. var
  478. d, i, i2: Dword;
  479. begin
  480. Result:=false;
  481. {Thumb2 is not supported (YET?)}
  482. if current_settings.cputype in cpu_thumb2 then exit;
  483. d:=DWord(value);
  484. for i:=0 to 15 do
  485. begin
  486. imm1:=d and rordword($FF, I*2);
  487. imm2:=d and not (imm1); {remove already found bits}
  488. {is the remainder a shifterconst? YAY! we've done it!}
  489. {Could we start from i instead of 0?}
  490. for i2:=0 to 15 do
  491. begin
  492. if (imm2 and not(rordword($FF,i2*2)))=0 then
  493. begin
  494. result:=true;
  495. exit;
  496. end;
  497. end;
  498. end;
  499. end;
  500. function dwarf_reg(r:tregister):shortint;
  501. begin
  502. result:=regdwarf_table[findreg_by_number(r)];
  503. if result=-1 then
  504. internalerror(200603251);
  505. end;
  506. { Low part of 64bit return value }
  507. function NR_FUNCTION_RESULT64_LOW_REG: tregister; {$ifdef USEINLINE}inline;{$endif USEINLINE}
  508. begin
  509. if target_info.endian=endian_little then
  510. result:=NR_R0
  511. else
  512. result:=NR_R1;
  513. end;
  514. function RS_FUNCTION_RESULT64_LOW_REG: shortint; {$ifdef USEINLINE}inline;{$endif USEINLINE}
  515. begin
  516. if target_info.endian=endian_little then
  517. result:=RS_R0
  518. else
  519. result:=RS_R1;
  520. end;
  521. { High part of 64bit return value }
  522. function NR_FUNCTION_RESULT64_HIGH_REG: tregister; {$ifdef USEINLINE}inline;{$endif USEINLINE}
  523. begin
  524. if target_info.endian=endian_little then
  525. result:=NR_R1
  526. else
  527. result:=NR_R0;
  528. end;
  529. function RS_FUNCTION_RESULT64_HIGH_REG: shortint; {$ifdef USEINLINE}inline;{$endif USEINLINE}
  530. begin
  531. if target_info.endian=endian_little then
  532. result:=RS_R1
  533. else
  534. result:=RS_R0;
  535. end;
  536. function IsIT(op: TAsmOp) : boolean;
  537. begin
  538. case op of
  539. A_IT,
  540. A_ITE, A_ITT,
  541. A_ITEE, A_ITTE, A_ITET, A_ITTT,
  542. A_ITEEE, A_ITTEE, A_ITETE, A_ITTTE,
  543. A_ITEET, A_ITTET, A_ITETT, A_ITTTT:
  544. result:=true;
  545. else
  546. result:=false;
  547. end;
  548. end;
  549. function GetITLevels(op: TAsmOp) : longint;
  550. begin
  551. case op of
  552. A_IT:
  553. result:=1;
  554. A_ITE, A_ITT:
  555. result:=2;
  556. A_ITEE, A_ITTE, A_ITET, A_ITTT:
  557. result:=3;
  558. A_ITEEE, A_ITTEE, A_ITETE, A_ITTTE,
  559. A_ITEET, A_ITTET, A_ITETT, A_ITTTT:
  560. result:=4;
  561. else
  562. result:=0;
  563. end;
  564. end;
  565. end.