1 //===- ARMRegisterInfo.td - ARM Register defs -------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
11 // Declarations that describe the ARM register file
12 //===----------------------------------------------------------------------===//
14 // Registers are identified with 4-bit ID numbers.
15 class ARMReg<bits<4> num, string n, list<Register> subregs = []> : Register<n> {
17 let Namespace = "ARM";
18 let SubRegs = subregs;
21 class ARMFReg<bits<5> num, string n> : Register<n> {
23 let Namespace = "ARM";
27 def R0 : ARMReg< 0, "r0">, DwarfRegNum<[0]>;
28 def R1 : ARMReg< 1, "r1">, DwarfRegNum<[1]>;
29 def R2 : ARMReg< 2, "r2">, DwarfRegNum<[2]>;
30 def R3 : ARMReg< 3, "r3">, DwarfRegNum<[3]>;
31 def R4 : ARMReg< 4, "r4">, DwarfRegNum<[4]>;
32 def R5 : ARMReg< 5, "r5">, DwarfRegNum<[5]>;
33 def R6 : ARMReg< 6, "r6">, DwarfRegNum<[6]>;
34 def R7 : ARMReg< 7, "r7">, DwarfRegNum<[7]>;
35 def R8 : ARMReg< 8, "r8">, DwarfRegNum<[8]>;
36 def R9 : ARMReg< 9, "r9">, DwarfRegNum<[9]>;
37 def R10 : ARMReg<10, "r10">, DwarfRegNum<[10]>;
38 def R11 : ARMReg<11, "r11">, DwarfRegNum<[11]>;
39 def R12 : ARMReg<12, "r12">, DwarfRegNum<[12]>;
40 def SP : ARMReg<13, "sp">, DwarfRegNum<[13]>;
41 def LR : ARMReg<14, "lr">, DwarfRegNum<[14]>;
42 def PC : ARMReg<15, "pc">, DwarfRegNum<[15]>;
45 def S0 : ARMFReg< 0, "s0">; def S1 : ARMFReg< 1, "s1">;
46 def S2 : ARMFReg< 2, "s2">; def S3 : ARMFReg< 3, "s3">;
47 def S4 : ARMFReg< 4, "s4">; def S5 : ARMFReg< 5, "s5">;
48 def S6 : ARMFReg< 6, "s6">; def S7 : ARMFReg< 7, "s7">;
49 def S8 : ARMFReg< 8, "s8">; def S9 : ARMFReg< 9, "s9">;
50 def S10 : ARMFReg<10, "s10">; def S11 : ARMFReg<11, "s11">;
51 def S12 : ARMFReg<12, "s12">; def S13 : ARMFReg<13, "s13">;
52 def S14 : ARMFReg<14, "s14">; def S15 : ARMFReg<15, "s15">;
53 def S16 : ARMFReg<16, "s16">; def S17 : ARMFReg<17, "s17">;
54 def S18 : ARMFReg<18, "s18">; def S19 : ARMFReg<19, "s19">;
55 def S20 : ARMFReg<20, "s20">; def S21 : ARMFReg<21, "s21">;
56 def S22 : ARMFReg<22, "s22">; def S23 : ARMFReg<23, "s23">;
57 def S24 : ARMFReg<24, "s24">; def S25 : ARMFReg<25, "s25">;
58 def S26 : ARMFReg<26, "s26">; def S27 : ARMFReg<27, "s27">;
59 def S28 : ARMFReg<28, "s28">; def S29 : ARMFReg<29, "s29">;
60 def S30 : ARMFReg<30, "s30">; def S31 : ARMFReg<31, "s31">;
62 // Aliases of the F* registers used to hold 64-bit fp values (doubles)
63 def D0 : ARMReg< 0, "d0", [S0, S1]>;
64 def D1 : ARMReg< 1, "d1", [S2, S3]>;
65 def D2 : ARMReg< 2, "d2", [S4, S5]>;
66 def D3 : ARMReg< 3, "d3", [S6, S7]>;
67 def D4 : ARMReg< 4, "d4", [S8, S9]>;
68 def D5 : ARMReg< 5, "d5", [S10, S11]>;
69 def D6 : ARMReg< 6, "d6", [S12, S13]>;
70 def D7 : ARMReg< 7, "d7", [S14, S15]>;
71 def D8 : ARMReg< 8, "d8", [S16, S17]>;
72 def D9 : ARMReg< 9, "d9", [S18, S19]>;
73 def D10 : ARMReg<10, "d10", [S20, S21]>;
74 def D11 : ARMReg<11, "d11", [S22, S23]>;
75 def D12 : ARMReg<12, "d12", [S24, S25]>;
76 def D13 : ARMReg<13, "d13", [S26, S27]>;
77 def D14 : ARMReg<14, "d14", [S28, S29]>;
78 def D15 : ARMReg<15, "d15", [S30, S31]>;
80 // Current Program Status Register.
81 def CPSR : ARMReg<0, "cpsr">;
85 // pc == Program Counter
86 // lr == Link Register
87 // sp == Stack Pointer
88 // r12 == ip (scratch)
89 // r7 == Frame Pointer (thumb-style backtraces)
90 // r11 == Frame Pointer (arm-style backtraces)
93 def GPR : RegisterClass<"ARM", [i32], 32, [R0, R1, R2, R3, R4, R5, R6,
94 R7, R8, R9, R10, R12, R11,
97 iterator allocation_order_begin(const MachineFunction &MF) const;
98 iterator allocation_order_end(const MachineFunction &MF) const;
100 // FIXME: We are reserving r12 in case the PEI needs to use it to
101 // generate large stack offset. Make it available once we have register
102 // scavenging. Similarly r3 is reserved in Thumb mode for now.
103 let MethodBodies = [{
104 // FP is R11, R9 is available.
105 static const unsigned ARM_GPR_AO_1[] = {
106 ARM::R3, ARM::R2, ARM::R1, ARM::R0,
108 ARM::R4, ARM::R5, ARM::R6, ARM::R7,
109 ARM::R8, ARM::R9, ARM::R10,
111 // FP is R11, R9 is not available.
112 static const unsigned ARM_GPR_AO_2[] = {
113 ARM::R3, ARM::R2, ARM::R1, ARM::R0,
115 ARM::R4, ARM::R5, ARM::R6, ARM::R7,
118 // FP is R7, R9 is available.
119 static const unsigned ARM_GPR_AO_3[] = {
120 ARM::R3, ARM::R2, ARM::R1, ARM::R0,
122 ARM::R4, ARM::R5, ARM::R6,
123 ARM::R8, ARM::R9, ARM::R10,ARM::R11,
125 // FP is R7, R9 is not available.
126 static const unsigned ARM_GPR_AO_4[] = {
127 ARM::R3, ARM::R2, ARM::R1, ARM::R0,
129 ARM::R4, ARM::R5, ARM::R6,
130 ARM::R8, ARM::R10,ARM::R11,
133 // FP is R7, only low registers available.
134 static const unsigned THUMB_GPR_AO[] = {
135 ARM::R2, ARM::R1, ARM::R0,
136 ARM::R4, ARM::R5, ARM::R6, ARM::R7 };
139 GPRClass::allocation_order_begin(const MachineFunction &MF) const {
140 const TargetMachine &TM = MF.getTarget();
141 const ARMSubtarget &Subtarget = TM.getSubtarget<ARMSubtarget>();
142 if (Subtarget.isThumb())
144 if (Subtarget.useThumbBacktraces()) {
145 if (Subtarget.isR9Reserved())
150 if (Subtarget.isR9Reserved())
158 GPRClass::allocation_order_end(const MachineFunction &MF) const {
159 const TargetMachine &TM = MF.getTarget();
160 const TargetRegisterInfo *RI = TM.getRegisterInfo();
161 const ARMSubtarget &Subtarget = TM.getSubtarget<ARMSubtarget>();
162 GPRClass::iterator I;
163 if (Subtarget.isThumb())
164 I = THUMB_GPR_AO + (sizeof(THUMB_GPR_AO)/sizeof(unsigned));
165 else if (Subtarget.useThumbBacktraces()) {
166 if (Subtarget.isR9Reserved()) {
167 I = ARM_GPR_AO_4 + (sizeof(ARM_GPR_AO_4)/sizeof(unsigned));
169 I = ARM_GPR_AO_3 + (sizeof(ARM_GPR_AO_3)/sizeof(unsigned));
172 if (Subtarget.isR9Reserved()) {
173 I = ARM_GPR_AO_2 + (sizeof(ARM_GPR_AO_2)/sizeof(unsigned));
175 I = ARM_GPR_AO_1 + (sizeof(ARM_GPR_AO_1)/sizeof(unsigned));
179 // Mac OS X requires FP not to be clobbered for backtracing purpose.
180 return (Subtarget.isTargetDarwin() || RI->hasFP(MF)) ? I-1 : I;
185 def SPR : RegisterClass<"ARM", [f32], 32, [S0, S1, S2, S3, S4, S5, S6, S7, S8,
186 S9, S10, S11, S12, S13, S14, S15, S16, S17, S18, S19, S20, S21, S22,
187 S23, S24, S25, S26, S27, S28, S29, S30, S31]>;
189 // ARM requires only word alignment for double. It's more performant if it
190 // is double-word alignment though.
191 def DPR : RegisterClass<"ARM", [f64], 64, [D0, D1, D2, D3, D4, D5, D6, D7, D8,
192 D9, D10, D11, D12, D13, D14, D15]>;
194 // Condition code registers.
195 def CCR : RegisterClass<"ARM", [i32], 32, [CPSR]>;