cpubase.pas 22 KB

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