| 1 |
//===-- ARMRegisterInfo.td - ARM Register defs -------------*- tablegen -*-===// |
| 2 |
// |
| 3 |
// The LLVM Compiler Infrastructure |
| 4 |
// |
| 5 |
// This file is distributed under the University of Illinois Open Source |
| 6 |
// License. See LICENSE.TXT for details. |
| 7 |
// |
| 8 |
//===----------------------------------------------------------------------===// |
| 9 |
|
| 10 |
include "ARMSystemRegister.td" |
| 11 |
|
| 12 |
//===----------------------------------------------------------------------===// |
| 13 |
// Declarations that describe the ARM register file |
| 14 |
//===----------------------------------------------------------------------===// |
| 15 |
|
| 16 |
// Registers are identified with 4-bit ID numbers. |
| 17 |
class ARMReg<bits<16> Enc, string n, list<Register> subregs = []> : Register<n> { |
| 18 |
let HWEncoding = Enc; |
| 19 |
let Namespace = "ARM"; |
| 20 |
let SubRegs = subregs; |
| 21 |
// All bits of ARM registers with sub-registers are covered by sub-registers. |
| 22 |
let CoveredBySubRegs = 1; |
| 23 |
} |
| 24 |
|
| 25 |
class ARMFReg<bits<16> Enc, string n> : Register<n> { |
| 26 |
let HWEncoding = Enc; |
| 27 |
let Namespace = "ARM"; |
| 28 |
} |
| 29 |
|
| 30 |
// Subregister indices. |
| 31 |
let Namespace = "ARM" in { |
| 32 |
def qqsub_0 : SubRegIndex<256>; |
| 33 |
def qqsub_1 : SubRegIndex<256, 256>; |
| 34 |
|
| 35 |
// Note: Code depends on these having consecutive numbers. |
| 36 |
def qsub_0 : SubRegIndex<128>; |
| 37 |
def qsub_1 : SubRegIndex<128, 128>; |
| 38 |
def qsub_2 : ComposedSubRegIndex<qqsub_1, qsub_0>; |
| 39 |
def qsub_3 : ComposedSubRegIndex<qqsub_1, qsub_1>; |
| 40 |
|
| 41 |
def dsub_0 : SubRegIndex<64>; |
| 42 |
def dsub_1 : SubRegIndex<64, 64>; |
| 43 |
def dsub_2 : ComposedSubRegIndex<qsub_1, dsub_0>; |
| 44 |
def dsub_3 : ComposedSubRegIndex<qsub_1, dsub_1>; |
| 45 |
def dsub_4 : ComposedSubRegIndex<qsub_2, dsub_0>; |
| 46 |
def dsub_5 : ComposedSubRegIndex<qsub_2, dsub_1>; |
| 47 |
def dsub_6 : ComposedSubRegIndex<qsub_3, dsub_0>; |
| 48 |
def dsub_7 : ComposedSubRegIndex<qsub_3, dsub_1>; |
| 49 |
|
| 50 |
def ssub_0 : SubRegIndex<32>; |
| 51 |
def ssub_1 : SubRegIndex<32, 32>; |
| 52 |
def ssub_2 : ComposedSubRegIndex<dsub_1, ssub_0>; |
| 53 |
def ssub_3 : ComposedSubRegIndex<dsub_1, ssub_1>; |
| 54 |
def ssub_4 : ComposedSubRegIndex<dsub_2, ssub_0>; |
| 55 |
def ssub_5 : ComposedSubRegIndex<dsub_2, ssub_1>; |
| 56 |
def ssub_6 : ComposedSubRegIndex<dsub_3, ssub_0>; |
| 57 |
def ssub_7 : ComposedSubRegIndex<dsub_3, ssub_1>; |
| 58 |
def ssub_8 : ComposedSubRegIndex<dsub_4, ssub_0>; |
| 59 |
def ssub_9 : ComposedSubRegIndex<dsub_4, ssub_1>; |
| 60 |
def ssub_10 : ComposedSubRegIndex<dsub_5, ssub_0>; |
| 61 |
def ssub_11 : ComposedSubRegIndex<dsub_5, ssub_1>; |
| 62 |
def ssub_12 : ComposedSubRegIndex<dsub_6, ssub_0>; |
| 63 |
def ssub_13 : ComposedSubRegIndex<dsub_6, ssub_1>; |
| 64 |
|
| 65 |
def gsub_0 : SubRegIndex<32>; |
| 66 |
def gsub_1 : SubRegIndex<32, 32>; |
| 67 |
// Let TableGen synthesize the remaining 12 ssub_* indices. |
| 68 |
// We don't need to name them. |
| 69 |
} |
| 70 |
|
| 71 |
// Integer registers |
| 72 |
def R0 : ARMReg< 0, "r0">, DwarfRegNum<[0]>; |
| 73 |
def R1 : ARMReg< 1, "r1">, DwarfRegNum<[1]>; |
| 74 |
def R2 : ARMReg< 2, "r2">, DwarfRegNum<[2]>; |
| 75 |
def R3 : ARMReg< 3, "r3">, DwarfRegNum<[3]>; |
| 76 |
def R4 : ARMReg< 4, "r4">, DwarfRegNum<[4]>; |
| 77 |
def R5 : ARMReg< 5, "r5">, DwarfRegNum<[5]>; |
| 78 |
def R6 : ARMReg< 6, "r6">, DwarfRegNum<[6]>; |
| 79 |
def R7 : ARMReg< 7, "r7">, DwarfRegNum<[7]>; |
| 80 |
// These require 32-bit instructions. |
| 81 |
let CostPerUse = 1 in { |
| 82 |
def R8 : ARMReg< 8, "r8">, DwarfRegNum<[8]>; |
| 83 |
def R9 : ARMReg< 9, "r9">, DwarfRegNum<[9]>; |
| 84 |
def R10 : ARMReg<10, "r10">, DwarfRegNum<[10]>; |
| 85 |
def R11 : ARMReg<11, "r11">, DwarfRegNum<[11]>; |
| 86 |
def R12 : ARMReg<12, "r12">, DwarfRegNum<[12]>; |
| 87 |
// R13 and R14 were given names in Capstone 4, even when the CS_OPT_SYNTAX_NOREGNAME option was specified, |
| 88 |
// so here they are given these names as well. See https://github.com/capstone-engine/capstone/issues/2078 |
| 89 |
def SP : ARMReg<13, "sp">, DwarfRegNum<[13]>; |
| 90 |
def LR : ARMReg<14, "lr">, DwarfRegNum<[14]>; |
| 91 |
def PC : ARMReg<15, "pc">, DwarfRegNum<[15]>; |
| 92 |
} |
| 93 |
|
| 94 |
// Float registers |
| 95 |
def S0 : ARMFReg< 0, "s0">; def S1 : ARMFReg< 1, "s1">; |
| 96 |
def S2 : ARMFReg< 2, "s2">; def S3 : ARMFReg< 3, "s3">; |
| 97 |
def S4 : ARMFReg< 4, "s4">; def S5 : ARMFReg< 5, "s5">; |
| 98 |
def S6 : ARMFReg< 6, "s6">; def S7 : ARMFReg< 7, "s7">; |
| 99 |
def S8 : ARMFReg< 8, "s8">; def S9 : ARMFReg< 9, "s9">; |
| 100 |
def S10 : ARMFReg<10, "s10">; def S11 : ARMFReg<11, "s11">; |
| 101 |
def S12 : ARMFReg<12, "s12">; def S13 : ARMFReg<13, "s13">; |
| 102 |
def S14 : ARMFReg<14, "s14">; def S15 : ARMFReg<15, "s15">; |
| 103 |
def S16 : ARMFReg<16, "s16">; def S17 : ARMFReg<17, "s17">; |
| 104 |
def S18 : ARMFReg<18, "s18">; def S19 : ARMFReg<19, "s19">; |
| 105 |
def S20 : ARMFReg<20, "s20">; def S21 : ARMFReg<21, "s21">; |
| 106 |
def S22 : ARMFReg<22, "s22">; def S23 : ARMFReg<23, "s23">; |
| 107 |
def S24 : ARMFReg<24, "s24">; def S25 : ARMFReg<25, "s25">; |
| 108 |
def S26 : ARMFReg<26, "s26">; def S27 : ARMFReg<27, "s27">; |
| 109 |
def S28 : ARMFReg<28, "s28">; def S29 : ARMFReg<29, "s29">; |
| 110 |
def S30 : ARMFReg<30, "s30">; def S31 : ARMFReg<31, "s31">; |
| 111 |
|
| 112 |
// Aliases of the F* registers used to hold 64-bit fp values (doubles) |
| 113 |
let SubRegIndices = [ssub_0, ssub_1] in { |
| 114 |
def D0 : ARMReg< 0, "d0", [S0, S1]>, DwarfRegNum<[256]>; |
| 115 |
def D1 : ARMReg< 1, "d1", [S2, S3]>, DwarfRegNum<[257]>; |
| 116 |
def D2 : ARMReg< 2, "d2", [S4, S5]>, DwarfRegNum<[258]>; |
| 117 |
def D3 : ARMReg< 3, "d3", [S6, S7]>, DwarfRegNum<[259]>; |
| 118 |
def D4 : ARMReg< 4, "d4", [S8, S9]>, DwarfRegNum<[260]>; |
| 119 |
def D5 : ARMReg< 5, "d5", [S10, S11]>, DwarfRegNum<[261]>; |
| 120 |
def D6 : ARMReg< 6, "d6", [S12, S13]>, DwarfRegNum<[262]>; |
| 121 |
def D7 : ARMReg< 7, "d7", [S14, S15]>, DwarfRegNum<[263]>; |
| 122 |
def D8 : ARMReg< 8, "d8", [S16, S17]>, DwarfRegNum<[264]>; |
| 123 |
def D9 : ARMReg< 9, "d9", [S18, S19]>, DwarfRegNum<[265]>; |
| 124 |
def D10 : ARMReg<10, "d10", [S20, S21]>, DwarfRegNum<[266]>; |
| 125 |
def D11 : ARMReg<11, "d11", [S22, S23]>, DwarfRegNum<[267]>; |
| 126 |
def D12 : ARMReg<12, "d12", [S24, S25]>, DwarfRegNum<[268]>; |
| 127 |
def D13 : ARMReg<13, "d13", [S26, S27]>, DwarfRegNum<[269]>; |
| 128 |
def D14 : ARMReg<14, "d14", [S28, S29]>, DwarfRegNum<[270]>; |
| 129 |
def D15 : ARMReg<15, "d15", [S30, S31]>, DwarfRegNum<[271]>; |
| 130 |
} |
| 131 |
|
| 132 |
// VFP3 defines 16 additional double registers |
| 133 |
def D16 : ARMFReg<16, "d16">, DwarfRegNum<[272]>; |
| 134 |
def D17 : ARMFReg<17, "d17">, DwarfRegNum<[273]>; |
| 135 |
def D18 : ARMFReg<18, "d18">, DwarfRegNum<[274]>; |
| 136 |
def D19 : ARMFReg<19, "d19">, DwarfRegNum<[275]>; |
| 137 |
def D20 : ARMFReg<20, "d20">, DwarfRegNum<[276]>; |
| 138 |
def D21 : ARMFReg<21, "d21">, DwarfRegNum<[277]>; |
| 139 |
def D22 : ARMFReg<22, "d22">, DwarfRegNum<[278]>; |
| 140 |
def D23 : ARMFReg<23, "d23">, DwarfRegNum<[279]>; |
| 141 |
def D24 : ARMFReg<24, "d24">, DwarfRegNum<[280]>; |
| 142 |
def D25 : ARMFReg<25, "d25">, DwarfRegNum<[281]>; |
| 143 |
def D26 : ARMFReg<26, "d26">, DwarfRegNum<[282]>; |
| 144 |
def D27 : ARMFReg<27, "d27">, DwarfRegNum<[283]>; |
| 145 |
def D28 : ARMFReg<28, "d28">, DwarfRegNum<[284]>; |
| 146 |
def D29 : ARMFReg<29, "d29">, DwarfRegNum<[285]>; |
| 147 |
def D30 : ARMFReg<30, "d30">, DwarfRegNum<[286]>; |
| 148 |
def D31 : ARMFReg<31, "d31">, DwarfRegNum<[287]>; |
| 149 |
|
| 150 |
// Advanced SIMD (NEON) defines 16 quad-word aliases |
| 151 |
let SubRegIndices = [dsub_0, dsub_1] in { |
| 152 |
def Q0 : ARMReg< 0, "q0", [D0, D1]>; |
| 153 |
def Q1 : ARMReg< 1, "q1", [D2, D3]>; |
| 154 |
def Q2 : ARMReg< 2, "q2", [D4, D5]>; |
| 155 |
def Q3 : ARMReg< 3, "q3", [D6, D7]>; |
| 156 |
def Q4 : ARMReg< 4, "q4", [D8, D9]>; |
| 157 |
def Q5 : ARMReg< 5, "q5", [D10, D11]>; |
| 158 |
def Q6 : ARMReg< 6, "q6", [D12, D13]>; |
| 159 |
def Q7 : ARMReg< 7, "q7", [D14, D15]>; |
| 160 |
} |
| 161 |
let SubRegIndices = [dsub_0, dsub_1] in { |
| 162 |
def Q8 : ARMReg< 8, "q8", [D16, D17]>; |
| 163 |
def Q9 : ARMReg< 9, "q9", [D18, D19]>; |
| 164 |
def Q10 : ARMReg<10, "q10", [D20, D21]>; |
| 165 |
def Q11 : ARMReg<11, "q11", [D22, D23]>; |
| 166 |
def Q12 : ARMReg<12, "q12", [D24, D25]>; |
| 167 |
def Q13 : ARMReg<13, "q13", [D26, D27]>; |
| 168 |
def Q14 : ARMReg<14, "q14", [D28, D29]>; |
| 169 |
def Q15 : ARMReg<15, "q15", [D30, D31]>; |
| 170 |
} |
| 171 |
|
| 172 |
// Current Program Status Register. |
| 173 |
// We model fpscr with two registers: FPSCR models the control bits and will be |
| 174 |
// reserved. FPSCR_NZCV models the flag bits and will be unreserved. APSR_NZCV |
| 175 |
// models the APSR when it's accessed by some special instructions. In such cases |
| 176 |
// it has the same encoding as PC. |
| 177 |
def CPSR : ARMReg<0, "cpsr">; |
| 178 |
def APSR : ARMReg<1, "apsr">; |
| 179 |
def APSR_NZCV : ARMReg<15, "apsr_nzcv">; |
| 180 |
def SPSR : ARMReg<2, "spsr">; |
| 181 |
def FPSCR : ARMReg<3, "fpscr">; |
| 182 |
def FPSCR_NZCV : ARMReg<3, "fpscr_nzcv"> { |
| 183 |
let Aliases = [FPSCR]; |
| 184 |
} |
| 185 |
def ITSTATE : ARMReg<4, "itstate">; |
| 186 |
|
| 187 |
// Special Registers - only available in privileged mode. |
| 188 |
def FPSID : ARMReg<0, "fpsid">; |
| 189 |
def MVFR2 : ARMReg<5, "mvfr2">; |
| 190 |
def MVFR1 : ARMReg<6, "mvfr1">; |
| 191 |
def MVFR0 : ARMReg<7, "mvfr0">; |
| 192 |
def FPEXC : ARMReg<8, "fpexc">; |
| 193 |
def FPINST : ARMReg<9, "fpinst">; |
| 194 |
def FPINST2 : ARMReg<10, "fpinst2">; |
| 195 |
|
| 196 |
// Register classes. |
| 197 |
// |
| 198 |
// pc == Program Counter |
| 199 |
// lr == Link Register |
| 200 |
// sp == Stack Pointer |
| 201 |
// r12 == ip (scratch) |
| 202 |
// r7 == Frame Pointer (thumb-style backtraces) |
| 203 |
// r9 == May be reserved as Thread Register |
| 204 |
// r11 == Frame Pointer (arm-style backtraces) |
| 205 |
// r10 == Stack Limit |
| 206 |
// |
| 207 |
def GPR : RegisterClass<"ARM", [i32], 32, (add (sequence "R%u", 0, 12), |
| 208 |
SP, LR, PC)> { |
| 209 |
// Allocate LR as the first CSR since it is always saved anyway. |
| 210 |
// For Thumb1 mode, we don't want to allocate hi regs at all, as we don't |
| 211 |
// know how to spill them. If we make our prologue/epilogue code smarter at |
| 212 |
// some point, we can go back to using the above allocation orders for the |
| 213 |
// Thumb1 instructions that know how to use hi regs. |
| 214 |
let AltOrders = [(add LR, GPR), (trunc GPR, 8)]; |
| 215 |
let AltOrderSelect = [{ |
| 216 |
return 1 + MF.getSubtarget<ARMSubtarget>().isThumb1Only(); |
| 217 |
}]; |
| 218 |
let DiagnosticString = "operand must be a register in range [r0, r15]"; |
| 219 |
} |
| 220 |
|
| 221 |
// GPRs without the PC. Some ARM instructions do not allow the PC in |
| 222 |
// certain operand slots, particularly as the destination. Primarily |
| 223 |
// useful for disassembly. |
| 224 |
def GPRnopc : RegisterClass<"ARM", [i32], 32, (sub GPR, PC)> { |
| 225 |
let AltOrders = [(add LR, GPRnopc), (trunc GPRnopc, 8)]; |
| 226 |
let AltOrderSelect = [{ |
| 227 |
return 1 + MF.getSubtarget<ARMSubtarget>().isThumb1Only(); |
| 228 |
}]; |
| 229 |
let DiagnosticString = "operand must be a register in range [r0, r14]"; |
| 230 |
} |
| 231 |
|
| 232 |
// GPRs without the PC but with APSR. Some instructions allow accessing the |
| 233 |
// APSR, while actually encoding PC in the register field. This is useful |
| 234 |
// for assembly and disassembly only. |
| 235 |
def GPRwithAPSR : RegisterClass<"ARM", [i32], 32, (add (sub GPR, PC), APSR_NZCV)> { |
| 236 |
let AltOrders = [(add LR, GPRnopc), (trunc GPRnopc, 8)]; |
| 237 |
let AltOrderSelect = [{ |
| 238 |
return 1 + MF.getSubtarget<ARMSubtarget>().isThumb1Only(); |
| 239 |
}]; |
| 240 |
let DiagnosticString = "operand must be a register in range [r0, r14] or apsr_nzcv"; |
| 241 |
} |
| 242 |
|
| 243 |
// GPRsp - Only the SP is legal. Used by Thumb1 instructions that want the |
| 244 |
// implied SP argument list. |
| 245 |
// FIXME: It would be better to not use this at all and refactor the |
| 246 |
// instructions to not have SP an an explicit argument. That makes |
| 247 |
// frame index resolution a bit trickier, though. |
| 248 |
def GPRsp : RegisterClass<"ARM", [i32], 32, (add SP)> { |
| 249 |
let DiagnosticString = "operand must be a register sp"; |
| 250 |
} |
| 251 |
|
| 252 |
// restricted GPR register class. Many Thumb2 instructions allow the full |
| 253 |
// register range for operands, but have undefined behaviours when PC |
| 254 |
// or SP (R13 or R15) are used. The ARM ISA refers to these operands |
| 255 |
// via the BadReg() pseudo-code description. |
| 256 |
def rGPR : RegisterClass<"ARM", [i32], 32, (sub GPR, SP, PC)> { |
| 257 |
let AltOrders = [(add LR, rGPR), (trunc rGPR, 8)]; |
| 258 |
let AltOrderSelect = [{ |
| 259 |
return 1 + MF.getSubtarget<ARMSubtarget>().isThumb1Only(); |
| 260 |
}]; |
| 261 |
let DiagnosticType = "rGPR"; |
| 262 |
} |
| 263 |
|
| 264 |
// Thumb registers are R0-R7 normally. Some instructions can still use |
| 265 |
// the general GPR register class above (MOV, e.g.) |
| 266 |
def tGPR : RegisterClass<"ARM", [i32], 32, (trunc GPR, 8)> { |
| 267 |
let DiagnosticString = "operand must be a register in range [r0, r7]"; |
| 268 |
} |
| 269 |
|
| 270 |
// Thumb registers R0-R7 and the PC. Some instructions like TBB or THH allow |
| 271 |
// the PC to be used as a destination operand as well. |
| 272 |
def tGPRwithpc : RegisterClass<"ARM", [i32], 32, (add tGPR, PC)>; |
| 273 |
|
| 274 |
// The high registers in thumb mode, R8-R15. |
| 275 |
def hGPR : RegisterClass<"ARM", [i32], 32, (sub GPR, tGPR)> { |
| 276 |
let DiagnosticString = "operand must be a register in range [r8, r15]"; |
| 277 |
} |
| 278 |
|
| 279 |
// For tail calls, we can't use callee-saved registers, as they are restored |
| 280 |
// to the saved value before the tail call, which would clobber a call address. |
| 281 |
// Note, getMinimalPhysRegClass(R0) returns tGPR because of the names of |
| 282 |
// this class and the preceding one(!) This is what we want. |
| 283 |
def tcGPR : RegisterClass<"ARM", [i32], 32, (add R0, R1, R2, R3, R12)> { |
| 284 |
let AltOrders = [(and tcGPR, tGPR)]; |
| 285 |
let AltOrderSelect = [{ |
| 286 |
return MF.getSubtarget<ARMSubtarget>().isThumb1Only(); |
| 287 |
}]; |
| 288 |
} |
| 289 |
|
| 290 |
// Condition code registers. |
| 291 |
def CCR : RegisterClass<"ARM", [i32], 32, (add CPSR)> { |
| 292 |
let CopyCost = -1; // Don't allow copying of status registers. |
| 293 |
let isAllocatable = 0; |
| 294 |
} |
| 295 |
|
| 296 |
// Scalar single precision floating point register class.. |
| 297 |
// FIXME: Allocation order changed to s0, s2, ... or s0, s4, ... as a quick hack |
| 298 |
// to avoid partial-write dependencies on D or Q (depending on platform) |
| 299 |
// registers (S registers are renamed as portions of D/Q registers). |
| 300 |
def SPR : RegisterClass<"ARM", [f32], 32, (sequence "S%u", 0, 31)> { |
| 301 |
let AltOrders = [(add (decimate SPR, 2), SPR), |
| 302 |
(add (decimate SPR, 4), |
| 303 |
(decimate SPR, 2), |
| 304 |
(decimate (rotl SPR, 1), 4), |
| 305 |
(decimate (rotl SPR, 1), 2))]; |
| 306 |
let AltOrderSelect = [{ |
| 307 |
return 1 + MF.getSubtarget<ARMSubtarget>().useStride4VFPs(MF); |
| 308 |
}]; |
| 309 |
let DiagnosticString = "operand must be a register in range [s0, s31]"; |
| 310 |
} |
| 311 |
|
| 312 |
def HPR : RegisterClass<"ARM", [f16], 32, (sequence "S%u", 0, 31)> { |
| 313 |
let AltOrders = [(add (decimate HPR, 2), SPR), |
| 314 |
(add (decimate HPR, 4), |
| 315 |
(decimate HPR, 2), |
| 316 |
(decimate (rotl HPR, 1), 4), |
| 317 |
(decimate (rotl HPR, 1), 2))]; |
| 318 |
let AltOrderSelect = [{ |
| 319 |
return 1 + MF.getSubtarget<ARMSubtarget>().useStride4VFPs(MF); |
| 320 |
}]; |
| 321 |
let DiagnosticString = "operand must be a register in range [s0, s31]"; |
| 322 |
} |
| 323 |
|
| 324 |
// Subset of SPR which can be used as a source of NEON scalars for 16-bit |
| 325 |
// operations |
| 326 |
def SPR_8 : RegisterClass<"ARM", [f32], 32, (sequence "S%u", 0, 15)> { |
| 327 |
let DiagnosticString = "operand must be a register in range [s0, s15]"; |
| 328 |
} |
| 329 |
|
| 330 |
// Scalar double precision floating point / generic 64-bit vector register |
| 331 |
// class. |
| 332 |
// ARM requires only word alignment for double. It's more performant if it |
| 333 |
// is double-word alignment though. |
| 334 |
def DPR : RegisterClass<"ARM", [f64, v8i8, v4i16, v2i32, v1i64, v2f32, v4f16], 64, |
| 335 |
(sequence "D%u", 0, 31)> { |
| 336 |
// Allocate non-VFP2 registers D16-D31 first, and prefer even registers on |
| 337 |
// Darwin platforms. |
| 338 |
let AltOrders = [(rotl DPR, 16), |
| 339 |
(add (decimate (rotl DPR, 16), 2), (rotl DPR, 16))]; |
| 340 |
let AltOrderSelect = [{ |
| 341 |
return 1 + MF.getSubtarget<ARMSubtarget>().useStride4VFPs(MF); |
| 342 |
}]; |
| 343 |
let DiagnosticType = "DPR"; |
| 344 |
} |
| 345 |
|
| 346 |
// Subset of DPR that are accessible with VFP2 (and so that also have |
| 347 |
// 32-bit SPR subregs). |
| 348 |
def DPR_VFP2 : RegisterClass<"ARM", [f64, v8i8, v4i16, v2i32, v1i64, v2f32, v4f16], 64, |
| 349 |
(trunc DPR, 16)> { |
| 350 |
let DiagnosticString = "operand must be a register in range [d0, d15]"; |
| 351 |
} |
| 352 |
|
| 353 |
// Subset of DPR which can be used as a source of NEON scalars for 16-bit |
| 354 |
// operations |
| 355 |
def DPR_8 : RegisterClass<"ARM", [f64, v8i8, v4i16, v2i32, v1i64, v2f32, v4f16], 64, |
| 356 |
(trunc DPR, 8)> { |
| 357 |
let DiagnosticString = "operand must be a register in range [d0, d7]"; |
| 358 |
} |
| 359 |
|
| 360 |
// Generic 128-bit vector register class. |
| 361 |
def QPR : RegisterClass<"ARM", [v16i8, v8i16, v4i32, v2i64, v4f32, v2f64, v8f16], 128, |
| 362 |
(sequence "Q%u", 0, 15)> { |
| 363 |
// Allocate non-VFP2 aliases Q8-Q15 first. |
| 364 |
let AltOrders = [(rotl QPR, 8)]; |
| 365 |
let AltOrderSelect = [{ return 1; }]; |
| 366 |
let DiagnosticString = "operand must be a register in range [q0, q15]"; |
| 367 |
} |
| 368 |
|
| 369 |
// Subset of QPR that have 32-bit SPR subregs. |
| 370 |
def QPR_VFP2 : RegisterClass<"ARM", [v16i8, v8i16, v4i32, v2i64, v4f32, v2f64], |
| 371 |
128, (trunc QPR, 8)> { |
| 372 |
let DiagnosticString = "operand must be a register in range [q0, q7]"; |
| 373 |
} |
| 374 |
|
| 375 |
// Subset of QPR that have DPR_8 and SPR_8 subregs. |
| 376 |
def QPR_8 : RegisterClass<"ARM", [v16i8, v8i16, v4i32, v2i64, v4f32, v2f64], |
| 377 |
128, (trunc QPR, 4)> { |
| 378 |
let DiagnosticString = "operand must be a register in range [q0, q3]"; |
| 379 |
} |
| 380 |
|
| 381 |
// Pseudo-registers representing odd-even pairs of D registers. The even-odd |
| 382 |
// pairs are already represented by the Q registers. |
| 383 |
// These are needed by NEON instructions requiring two consecutive D registers. |
| 384 |
// There is no D31_D0 register as that is always an UNPREDICTABLE encoding. |
| 385 |
def TuplesOE2D : RegisterTuples<[dsub_0, dsub_1], |
| 386 |
[(decimate (shl DPR, 1), 2), |
| 387 |
(decimate (shl DPR, 2), 2)]>; |
| 388 |
|
| 389 |
// Register class representing a pair of consecutive D registers. |
| 390 |
// Use the Q registers for the even-odd pairs. |
| 391 |
def DPair : RegisterClass<"ARM", [v16i8, v8i16, v4i32, v2i64, v4f32, v2f64], |
| 392 |
128, (interleave QPR, TuplesOE2D)> { |
| 393 |
// Allocate starting at non-VFP2 registers D16-D31 first. |
| 394 |
// Prefer even-odd pairs as they are easier to copy. |
| 395 |
let AltOrders = [(add (rotl QPR, 8), (rotl DPair, 16))]; |
| 396 |
let AltOrderSelect = [{ return 1; }]; |
| 397 |
} |
| 398 |
|
| 399 |
// Pseudo-registers representing even-odd pairs of GPRs from R1 to R13/SP. |
| 400 |
// These are needed by instructions (e.g. ldrexd/strexd) requiring even-odd GPRs. |
| 401 |
def Tuples2R : RegisterTuples<[gsub_0, gsub_1], |
| 402 |
[(add R0, R2, R4, R6, R8, R10, R12), |
| 403 |
(add R1, R3, R5, R7, R9, R11, SP)]>; |
| 404 |
|
| 405 |
// Register class representing a pair of even-odd GPRs. |
| 406 |
def GPRPair : RegisterClass<"ARM", [untyped], 64, (add Tuples2R)> { |
| 407 |
let Size = 64; // 2 x 32 bits, we have no predefined type of that size. |
| 408 |
} |
| 409 |
|
| 410 |
// Pseudo-registers representing 3 consecutive D registers. |
| 411 |
def Tuples3D : RegisterTuples<[dsub_0, dsub_1, dsub_2], |
| 412 |
[(shl DPR, 0), |
| 413 |
(shl DPR, 1), |
| 414 |
(shl DPR, 2)]>; |
| 415 |
|
| 416 |
// 3 consecutive D registers. |
| 417 |
def DTriple : RegisterClass<"ARM", [untyped], 64, (add Tuples3D)> { |
| 418 |
let Size = 192; // 3 x 64 bits, we have no predefined type of that size. |
| 419 |
} |
| 420 |
|
| 421 |
// Pseudo 256-bit registers to represent pairs of Q registers. These should |
| 422 |
// never be present in the emitted code. |
| 423 |
// These are used for NEON load / store instructions, e.g., vld4, vst3. |
| 424 |
def Tuples2Q : RegisterTuples<[qsub_0, qsub_1], [(shl QPR, 0), (shl QPR, 1)]>; |
| 425 |
|
| 426 |
// Pseudo 256-bit vector register class to model pairs of Q registers |
| 427 |
// (4 consecutive D registers). |
| 428 |
def QQPR : RegisterClass<"ARM", [v4i64], 256, (add Tuples2Q)> { |
| 429 |
// Allocate non-VFP2 aliases first. |
| 430 |
let AltOrders = [(rotl QQPR, 8)]; |
| 431 |
let AltOrderSelect = [{ return 1; }]; |
| 432 |
} |
| 433 |
|
| 434 |
// Tuples of 4 D regs that isn't also a pair of Q regs. |
| 435 |
def TuplesOE4D : RegisterTuples<[dsub_0, dsub_1, dsub_2, dsub_3], |
| 436 |
[(decimate (shl DPR, 1), 2), |
| 437 |
(decimate (shl DPR, 2), 2), |
| 438 |
(decimate (shl DPR, 3), 2), |
| 439 |
(decimate (shl DPR, 4), 2)]>; |
| 440 |
|
| 441 |
// 4 consecutive D registers. |
| 442 |
def DQuad : RegisterClass<"ARM", [v4i64], 256, |
| 443 |
(interleave Tuples2Q, TuplesOE4D)>; |
| 444 |
|
| 445 |
// Pseudo 512-bit registers to represent four consecutive Q registers. |
| 446 |
def Tuples2QQ : RegisterTuples<[qqsub_0, qqsub_1], |
| 447 |
[(shl QQPR, 0), (shl QQPR, 2)]>; |
| 448 |
|
| 449 |
// Pseudo 512-bit vector register class to model 4 consecutive Q registers |
| 450 |
// (8 consecutive D registers). |
| 451 |
def QQQQPR : RegisterClass<"ARM", [v8i64], 256, (add Tuples2QQ)> { |
| 452 |
// Allocate non-VFP2 aliases first. |
| 453 |
let AltOrders = [(rotl QQQQPR, 8)]; |
| 454 |
let AltOrderSelect = [{ return 1; }]; |
| 455 |
} |
| 456 |
|
| 457 |
|
| 458 |
// Pseudo-registers representing 2-spaced consecutive D registers. |
| 459 |
def Tuples2DSpc : RegisterTuples<[dsub_0, dsub_2], |
| 460 |
[(shl DPR, 0), |
| 461 |
(shl DPR, 2)]>; |
| 462 |
|
| 463 |
// Spaced pairs of D registers. |
| 464 |
def DPairSpc : RegisterClass<"ARM", [v2i64], 64, (add Tuples2DSpc)>; |
| 465 |
|
| 466 |
def Tuples3DSpc : RegisterTuples<[dsub_0, dsub_2, dsub_4], |
| 467 |
[(shl DPR, 0), |
| 468 |
(shl DPR, 2), |
| 469 |
(shl DPR, 4)]>; |
| 470 |
|
| 471 |
// Spaced triples of D registers. |
| 472 |
def DTripleSpc : RegisterClass<"ARM", [untyped], 64, (add Tuples3DSpc)> { |
| 473 |
let Size = 192; // 3 x 64 bits, we have no predefined type of that size. |
| 474 |
} |
| 475 |
|
| 476 |
def Tuples4DSpc : RegisterTuples<[dsub_0, dsub_2, dsub_4, dsub_6], |
| 477 |
[(shl DPR, 0), |
| 478 |
(shl DPR, 2), |
| 479 |
(shl DPR, 4), |
| 480 |
(shl DPR, 6)]>; |
| 481 |
|
| 482 |
// Spaced quads of D registers. |
| 483 |
def DQuadSpc : RegisterClass<"ARM", [v4i64], 64, (add Tuples3DSpc)>; |