1//===- X86RegisterInfo.td - Describe the X86 Register File --*- 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// This file describes the X86 Register file, defining the registers themselves, 11// aliases between the registers, and the register classes built out of the 12// registers. 13// 14//===----------------------------------------------------------------------===// 15 16class X86Reg<string n, bits<16> Enc, list<Register> subregs = []> : Register<n> { 17 let Namespace = "X86"; 18 let HWEncoding = Enc; 19 let SubRegs = subregs; 20} 21 22// Subregister indices. 23let Namespace = "X86" in { 24 def sub_8bit : SubRegIndex<8>; 25 def sub_8bit_hi : SubRegIndex<8, 8>; 26 def sub_8bit_hi_phony : SubRegIndex<8, 8>; 27 def sub_16bit : SubRegIndex<16>; 28 def sub_16bit_hi : SubRegIndex<16, 16>; 29 def sub_32bit : SubRegIndex<32>; 30 def sub_xmm : SubRegIndex<128>; 31 def sub_ymm : SubRegIndex<256>; 32} 33 34//===----------------------------------------------------------------------===// 35// Register definitions... 36// 37 38// In the register alias definitions below, we define which registers alias 39// which others. We only specify which registers the small registers alias, 40// because the register file generator is smart enough to figure out that 41// AL aliases AX if we tell it that AX aliased AL (for example). 42 43// Dwarf numbering is different for 32-bit and 64-bit, and there are 44// variations by target as well. Currently the first entry is for X86-64, 45// second - for EH on X86-32/Darwin and third is 'generic' one (X86-32/Linux 46// and debug information on X86-32/Darwin) 47 48// 8-bit registers 49// Low registers 50def AL : X86Reg<"al", 0>; 51def DL : X86Reg<"dl", 2>; 52def CL : X86Reg<"cl", 1>; 53def BL : X86Reg<"bl", 3>; 54 55// High registers. On x86-64, these cannot be used in any instruction 56// with a REX prefix. 57def AH : X86Reg<"ah", 4>; 58def DH : X86Reg<"dh", 6>; 59def CH : X86Reg<"ch", 5>; 60def BH : X86Reg<"bh", 7>; 61 62// X86-64 only, requires REX. 63let CostPerUse = 1 in { 64def SIL : X86Reg<"sil", 6>; 65def DIL : X86Reg<"dil", 7>; 66def BPL : X86Reg<"bpl", 5>; 67def SPL : X86Reg<"spl", 4>; 68def R8B : X86Reg<"r8b", 8>; 69def R9B : X86Reg<"r9b", 9>; 70def R10B : X86Reg<"r10b", 10>; 71def R11B : X86Reg<"r11b", 11>; 72def R12B : X86Reg<"r12b", 12>; 73def R13B : X86Reg<"r13b", 13>; 74def R14B : X86Reg<"r14b", 14>; 75def R15B : X86Reg<"r15b", 15>; 76} 77 78let isArtificial = 1 in { 79// High byte of the low 16 bits of the super-register: 80def SIH : X86Reg<"", -1>; 81def DIH : X86Reg<"", -1>; 82def BPH : X86Reg<"", -1>; 83def SPH : X86Reg<"", -1>; 84def R8BH : X86Reg<"", -1>; 85def R9BH : X86Reg<"", -1>; 86def R10BH : X86Reg<"", -1>; 87def R11BH : X86Reg<"", -1>; 88def R12BH : X86Reg<"", -1>; 89def R13BH : X86Reg<"", -1>; 90def R14BH : X86Reg<"", -1>; 91def R15BH : X86Reg<"", -1>; 92// High word of the low 32 bits of the super-register: 93def HAX : X86Reg<"", -1>; 94def HDX : X86Reg<"", -1>; 95def HCX : X86Reg<"", -1>; 96def HBX : X86Reg<"", -1>; 97def HSI : X86Reg<"", -1>; 98def HDI : X86Reg<"", -1>; 99def HBP : X86Reg<"", -1>; 100def HSP : X86Reg<"", -1>; 101def HIP : X86Reg<"", -1>; 102def R8WH : X86Reg<"", -1>; 103def R9WH : X86Reg<"", -1>; 104def R10WH : X86Reg<"", -1>; 105def R11WH : X86Reg<"", -1>; 106def R12WH : X86Reg<"", -1>; 107def R13WH : X86Reg<"", -1>; 108def R14WH : X86Reg<"", -1>; 109def R15WH : X86Reg<"", -1>; 110} 111 112// 16-bit registers 113let SubRegIndices = [sub_8bit, sub_8bit_hi], CoveredBySubRegs = 1 in { 114def AX : X86Reg<"ax", 0, [AL,AH]>; 115def DX : X86Reg<"dx", 2, [DL,DH]>; 116def CX : X86Reg<"cx", 1, [CL,CH]>; 117def BX : X86Reg<"bx", 3, [BL,BH]>; 118} 119let SubRegIndices = [sub_8bit, sub_8bit_hi_phony], CoveredBySubRegs = 1 in { 120def SI : X86Reg<"si", 6, [SIL,SIH]>; 121def DI : X86Reg<"di", 7, [DIL,DIH]>; 122def BP : X86Reg<"bp", 5, [BPL,BPH]>; 123def SP : X86Reg<"sp", 4, [SPL,SPH]>; 124} 125def IP : X86Reg<"ip", 0>; 126 127// X86-64 only, requires REX. 128let SubRegIndices = [sub_8bit, sub_8bit_hi_phony], CostPerUse = 1, 129 CoveredBySubRegs = 1 in { 130def R8W : X86Reg<"r8w", 8, [R8B,R8BH]>; 131def R9W : X86Reg<"r9w", 9, [R9B,R9BH]>; 132def R10W : X86Reg<"r10w", 10, [R10B,R10BH]>; 133def R11W : X86Reg<"r11w", 11, [R11B,R11BH]>; 134def R12W : X86Reg<"r12w", 12, [R12B,R12BH]>; 135def R13W : X86Reg<"r13w", 13, [R13B,R13BH]>; 136def R14W : X86Reg<"r14w", 14, [R14B,R14BH]>; 137def R15W : X86Reg<"r15w", 15, [R15B,R15BH]>; 138} 139 140// 32-bit registers 141let SubRegIndices = [sub_16bit, sub_16bit_hi], CoveredBySubRegs = 1 in { 142def EAX : X86Reg<"eax", 0, [AX, HAX]>, DwarfRegNum<[-2, 0, 0]>; 143def EDX : X86Reg<"edx", 2, [DX, HDX]>, DwarfRegNum<[-2, 2, 2]>; 144def ECX : X86Reg<"ecx", 1, [CX, HCX]>, DwarfRegNum<[-2, 1, 1]>; 145def EBX : X86Reg<"ebx", 3, [BX, HBX]>, DwarfRegNum<[-2, 3, 3]>; 146def ESI : X86Reg<"esi", 6, [SI, HSI]>, DwarfRegNum<[-2, 6, 6]>; 147def EDI : X86Reg<"edi", 7, [DI, HDI]>, DwarfRegNum<[-2, 7, 7]>; 148def EBP : X86Reg<"ebp", 5, [BP, HBP]>, DwarfRegNum<[-2, 4, 5]>; 149def ESP : X86Reg<"esp", 4, [SP, HSP]>, DwarfRegNum<[-2, 5, 4]>; 150def EIP : X86Reg<"eip", 0, [IP, HIP]>, DwarfRegNum<[-2, 8, 8]>; 151} 152 153// X86-64 only, requires REX 154let SubRegIndices = [sub_16bit, sub_16bit_hi], CostPerUse = 1, 155 CoveredBySubRegs = 1 in { 156def R8D : X86Reg<"r8d", 8, [R8W,R8WH]>; 157def R9D : X86Reg<"r9d", 9, [R9W,R9WH]>; 158def R10D : X86Reg<"r10d", 10, [R10W,R10WH]>; 159def R11D : X86Reg<"r11d", 11, [R11W,R11WH]>; 160def R12D : X86Reg<"r12d", 12, [R12W,R12WH]>; 161def R13D : X86Reg<"r13d", 13, [R13W,R13WH]>; 162def R14D : X86Reg<"r14d", 14, [R14W,R14WH]>; 163def R15D : X86Reg<"r15d", 15, [R15W,R15WH]>; 164} 165 166// 64-bit registers, X86-64 only 167let SubRegIndices = [sub_32bit] in { 168def RAX : X86Reg<"rax", 0, [EAX]>, DwarfRegNum<[0, -2, -2]>; 169def RDX : X86Reg<"rdx", 2, [EDX]>, DwarfRegNum<[1, -2, -2]>; 170def RCX : X86Reg<"rcx", 1, [ECX]>, DwarfRegNum<[2, -2, -2]>; 171def RBX : X86Reg<"rbx", 3, [EBX]>, DwarfRegNum<[3, -2, -2]>; 172def RSI : X86Reg<"rsi", 6, [ESI]>, DwarfRegNum<[4, -2, -2]>; 173def RDI : X86Reg<"rdi", 7, [EDI]>, DwarfRegNum<[5, -2, -2]>; 174def RBP : X86Reg<"rbp", 5, [EBP]>, DwarfRegNum<[6, -2, -2]>; 175def RSP : X86Reg<"rsp", 4, [ESP]>, DwarfRegNum<[7, -2, -2]>; 176 177// These also require REX. 178let CostPerUse = 1 in { 179def R8 : X86Reg<"r8", 8, [R8D]>, DwarfRegNum<[ 8, -2, -2]>; 180def R9 : X86Reg<"r9", 9, [R9D]>, DwarfRegNum<[ 9, -2, -2]>; 181def R10 : X86Reg<"r10", 10, [R10D]>, DwarfRegNum<[10, -2, -2]>; 182def R11 : X86Reg<"r11", 11, [R11D]>, DwarfRegNum<[11, -2, -2]>; 183def R12 : X86Reg<"r12", 12, [R12D]>, DwarfRegNum<[12, -2, -2]>; 184def R13 : X86Reg<"r13", 13, [R13D]>, DwarfRegNum<[13, -2, -2]>; 185def R14 : X86Reg<"r14", 14, [R14D]>, DwarfRegNum<[14, -2, -2]>; 186def R15 : X86Reg<"r15", 15, [R15D]>, DwarfRegNum<[15, -2, -2]>; 187def RIP : X86Reg<"rip", 0, [EIP]>, DwarfRegNum<[16, -2, -2]>; 188}} 189 190// MMX Registers. These are actually aliased to ST0 .. ST7 191def MM0 : X86Reg<"mm0", 0>, DwarfRegNum<[41, 29, 29]>; 192def MM1 : X86Reg<"mm1", 1>, DwarfRegNum<[42, 30, 30]>; 193def MM2 : X86Reg<"mm2", 2>, DwarfRegNum<[43, 31, 31]>; 194def MM3 : X86Reg<"mm3", 3>, DwarfRegNum<[44, 32, 32]>; 195def MM4 : X86Reg<"mm4", 4>, DwarfRegNum<[45, 33, 33]>; 196def MM5 : X86Reg<"mm5", 5>, DwarfRegNum<[46, 34, 34]>; 197def MM6 : X86Reg<"mm6", 6>, DwarfRegNum<[47, 35, 35]>; 198def MM7 : X86Reg<"mm7", 7>, DwarfRegNum<[48, 36, 36]>; 199 200// Pseudo Floating Point registers 201def FP0 : X86Reg<"fp0", 0>; 202def FP1 : X86Reg<"fp1", 0>; 203def FP2 : X86Reg<"fp2", 0>; 204def FP3 : X86Reg<"fp3", 0>; 205def FP4 : X86Reg<"fp4", 0>; 206def FP5 : X86Reg<"fp5", 0>; 207def FP6 : X86Reg<"fp6", 0>; 208def FP7 : X86Reg<"fp7", 0>; 209 210// XMM Registers, used by the various SSE instruction set extensions. 211def XMM0: X86Reg<"xmm0", 0>, DwarfRegNum<[17, 21, 21]>; 212def XMM1: X86Reg<"xmm1", 1>, DwarfRegNum<[18, 22, 22]>; 213def XMM2: X86Reg<"xmm2", 2>, DwarfRegNum<[19, 23, 23]>; 214def XMM3: X86Reg<"xmm3", 3>, DwarfRegNum<[20, 24, 24]>; 215def XMM4: X86Reg<"xmm4", 4>, DwarfRegNum<[21, 25, 25]>; 216def XMM5: X86Reg<"xmm5", 5>, DwarfRegNum<[22, 26, 26]>; 217def XMM6: X86Reg<"xmm6", 6>, DwarfRegNum<[23, 27, 27]>; 218def XMM7: X86Reg<"xmm7", 7>, DwarfRegNum<[24, 28, 28]>; 219 220// X86-64 only 221let CostPerUse = 1 in { 222def XMM8: X86Reg<"xmm8", 8>, DwarfRegNum<[25, -2, -2]>; 223def XMM9: X86Reg<"xmm9", 9>, DwarfRegNum<[26, -2, -2]>; 224def XMM10: X86Reg<"xmm10", 10>, DwarfRegNum<[27, -2, -2]>; 225def XMM11: X86Reg<"xmm11", 11>, DwarfRegNum<[28, -2, -2]>; 226def XMM12: X86Reg<"xmm12", 12>, DwarfRegNum<[29, -2, -2]>; 227def XMM13: X86Reg<"xmm13", 13>, DwarfRegNum<[30, -2, -2]>; 228def XMM14: X86Reg<"xmm14", 14>, DwarfRegNum<[31, -2, -2]>; 229def XMM15: X86Reg<"xmm15", 15>, DwarfRegNum<[32, -2, -2]>; 230 231def XMM16: X86Reg<"xmm16", 16>, DwarfRegNum<[67, -2, -2]>; 232def XMM17: X86Reg<"xmm17", 17>, DwarfRegNum<[68, -2, -2]>; 233def XMM18: X86Reg<"xmm18", 18>, DwarfRegNum<[69, -2, -2]>; 234def XMM19: X86Reg<"xmm19", 19>, DwarfRegNum<[70, -2, -2]>; 235def XMM20: X86Reg<"xmm20", 20>, DwarfRegNum<[71, -2, -2]>; 236def XMM21: X86Reg<"xmm21", 21>, DwarfRegNum<[72, -2, -2]>; 237def XMM22: X86Reg<"xmm22", 22>, DwarfRegNum<[73, -2, -2]>; 238def XMM23: X86Reg<"xmm23", 23>, DwarfRegNum<[74, -2, -2]>; 239def XMM24: X86Reg<"xmm24", 24>, DwarfRegNum<[75, -2, -2]>; 240def XMM25: X86Reg<"xmm25", 25>, DwarfRegNum<[76, -2, -2]>; 241def XMM26: X86Reg<"xmm26", 26>, DwarfRegNum<[77, -2, -2]>; 242def XMM27: X86Reg<"xmm27", 27>, DwarfRegNum<[78, -2, -2]>; 243def XMM28: X86Reg<"xmm28", 28>, DwarfRegNum<[79, -2, -2]>; 244def XMM29: X86Reg<"xmm29", 29>, DwarfRegNum<[80, -2, -2]>; 245def XMM30: X86Reg<"xmm30", 30>, DwarfRegNum<[81, -2, -2]>; 246def XMM31: X86Reg<"xmm31", 31>, DwarfRegNum<[82, -2, -2]>; 247 248} // CostPerUse 249 250// YMM0-15 registers, used by AVX instructions and 251// YMM16-31 registers, used by AVX-512 instructions. 252let SubRegIndices = [sub_xmm] in { 253 foreach Index = 0-31 in { 254 def YMM#Index : X86Reg<"ymm"#Index, Index, [!cast<X86Reg>("XMM"#Index)]>, 255 DwarfRegAlias<!cast<X86Reg>("XMM"#Index)>; 256 } 257} 258 259// ZMM Registers, used by AVX-512 instructions. 260let SubRegIndices = [sub_ymm] in { 261 foreach Index = 0-31 in { 262 def ZMM#Index : X86Reg<"zmm"#Index, Index, [!cast<X86Reg>("YMM"#Index)]>, 263 DwarfRegAlias<!cast<X86Reg>("XMM"#Index)>; 264 } 265} 266 267// Mask Registers, used by AVX-512 instructions. 268def K0 : X86Reg<"k0", 0>, DwarfRegNum<[118, 93, 93]>; 269def K1 : X86Reg<"k1", 1>, DwarfRegNum<[119, 94, 94]>; 270def K2 : X86Reg<"k2", 2>, DwarfRegNum<[120, 95, 95]>; 271def K3 : X86Reg<"k3", 3>, DwarfRegNum<[121, 96, 96]>; 272def K4 : X86Reg<"k4", 4>, DwarfRegNum<[122, 97, 97]>; 273def K5 : X86Reg<"k5", 5>, DwarfRegNum<[123, 98, 98]>; 274def K6 : X86Reg<"k6", 6>, DwarfRegNum<[124, 99, 99]>; 275def K7 : X86Reg<"k7", 7>, DwarfRegNum<[125, 100, 100]>; 276 277// Floating point stack registers. These don't map one-to-one to the FP 278// pseudo registers, but we still mark them as aliasing FP registers. That 279// way both kinds can be live without exceeding the stack depth. ST registers 280// are only live around inline assembly. 281def ST0 : X86Reg<"st(0)", 0>, DwarfRegNum<[33, 12, 11]>; 282def ST1 : X86Reg<"st(1)", 1>, DwarfRegNum<[34, 13, 12]>; 283def ST2 : X86Reg<"st(2)", 2>, DwarfRegNum<[35, 14, 13]>; 284def ST3 : X86Reg<"st(3)", 3>, DwarfRegNum<[36, 15, 14]>; 285def ST4 : X86Reg<"st(4)", 4>, DwarfRegNum<[37, 16, 15]>; 286def ST5 : X86Reg<"st(5)", 5>, DwarfRegNum<[38, 17, 16]>; 287def ST6 : X86Reg<"st(6)", 6>, DwarfRegNum<[39, 18, 17]>; 288def ST7 : X86Reg<"st(7)", 7>, DwarfRegNum<[40, 19, 18]>; 289 290// Floating-point status word 291def FPSW : X86Reg<"fpsw", 0>; 292 293// Status flags register. 294// 295// Note that some flags that are commonly thought of as part of the status 296// flags register are modeled separately. Typically this is due to instructions 297// reading and updating those flags independently of all the others. We don't 298// want to create false dependencies between these instructions and so we use 299// a separate register to model them. 300def EFLAGS : X86Reg<"flags", 0>; 301 302// The direction flag. 303def DF : X86Reg<"dirflag", 0>; 304 305 306// Segment registers 307def CS : X86Reg<"cs", 1>; 308def DS : X86Reg<"ds", 3>; 309def SS : X86Reg<"ss", 2>; 310def ES : X86Reg<"es", 0>; 311def FS : X86Reg<"fs", 4>; 312def GS : X86Reg<"gs", 5>; 313 314// Debug registers 315def DR0 : X86Reg<"dr0", 0>; 316def DR1 : X86Reg<"dr1", 1>; 317def DR2 : X86Reg<"dr2", 2>; 318def DR3 : X86Reg<"dr3", 3>; 319def DR4 : X86Reg<"dr4", 4>; 320def DR5 : X86Reg<"dr5", 5>; 321def DR6 : X86Reg<"dr6", 6>; 322def DR7 : X86Reg<"dr7", 7>; 323def DR8 : X86Reg<"dr8", 8>; 324def DR9 : X86Reg<"dr9", 9>; 325def DR10 : X86Reg<"dr10", 10>; 326def DR11 : X86Reg<"dr11", 11>; 327def DR12 : X86Reg<"dr12", 12>; 328def DR13 : X86Reg<"dr13", 13>; 329def DR14 : X86Reg<"dr14", 14>; 330def DR15 : X86Reg<"dr15", 15>; 331 332// Control registers 333def CR0 : X86Reg<"cr0", 0>; 334def CR1 : X86Reg<"cr1", 1>; 335def CR2 : X86Reg<"cr2", 2>; 336def CR3 : X86Reg<"cr3", 3>; 337def CR4 : X86Reg<"cr4", 4>; 338def CR5 : X86Reg<"cr5", 5>; 339def CR6 : X86Reg<"cr6", 6>; 340def CR7 : X86Reg<"cr7", 7>; 341def CR8 : X86Reg<"cr8", 8>; 342def CR9 : X86Reg<"cr9", 9>; 343def CR10 : X86Reg<"cr10", 10>; 344def CR11 : X86Reg<"cr11", 11>; 345def CR12 : X86Reg<"cr12", 12>; 346def CR13 : X86Reg<"cr13", 13>; 347def CR14 : X86Reg<"cr14", 14>; 348def CR15 : X86Reg<"cr15", 15>; 349 350// Pseudo index registers 351def EIZ : X86Reg<"eiz", 4>; 352def RIZ : X86Reg<"riz", 4>; 353 354// Bound registers, used in MPX instructions 355def BND0 : X86Reg<"bnd0", 0>; 356def BND1 : X86Reg<"bnd1", 1>; 357def BND2 : X86Reg<"bnd2", 2>; 358def BND3 : X86Reg<"bnd3", 3>; 359 360// CET registers - Shadow Stack Pointer 361def SSP : X86Reg<"ssp", 0>; 362 363//===----------------------------------------------------------------------===// 364// Register Class Definitions... now that we have all of the pieces, define the 365// top-level register classes. The order specified in the register list is 366// implicitly defined to be the register allocation order. 367// 368 369// List call-clobbered registers before callee-save registers. RBX, RBP, (and 370// R12, R13, R14, and R15 for X86-64) are callee-save registers. 371// In 64-mode, there are 12 additional i8 registers, SIL, DIL, BPL, SPL, and 372// R8B, ... R15B. 373// Allocate R12 and R13 last, as these require an extra byte when 374// encoded in x86_64 instructions. 375// FIXME: Allow AH, CH, DH, BH to be used as general-purpose registers in 376// 64-bit mode. The main complication is that they cannot be encoded in an 377// instruction requiring a REX prefix, while SIL, DIL, BPL, R8D, etc. 378// require a REX prefix. For example, "addb %ah, %dil" and "movzbl %ah, %r8d" 379// cannot be encoded. 380def GR8 : RegisterClass<"X86", [i8], 8, 381 (add AL, CL, DL, AH, CH, DH, BL, BH, SIL, DIL, BPL, SPL, 382 R8B, R9B, R10B, R11B, R14B, R15B, R12B, R13B)> { 383 let AltOrders = [(sub GR8, AH, BH, CH, DH)]; 384 let AltOrderSelect = [{ 385 return MF.getSubtarget<X86Subtarget>().is64Bit(); 386 }]; 387} 388 389let isAllocatable = 0 in 390def GRH8 : RegisterClass<"X86", [i8], 8, 391 (add SIH, DIH, BPH, SPH, R8BH, R9BH, R10BH, R11BH, 392 R12BH, R13BH, R14BH, R15BH)>; 393 394def GR16 : RegisterClass<"X86", [i16], 16, 395 (add AX, CX, DX, SI, DI, BX, BP, SP, 396 R8W, R9W, R10W, R11W, R14W, R15W, R12W, R13W)>; 397 398let isAllocatable = 0 in 399def GRH16 : RegisterClass<"X86", [i16], 16, 400 (add HAX, HCX, HDX, HSI, HDI, HBX, HBP, HSP, HIP, 401 R8WH, R9WH, R10WH, R11WH, R12WH, R13WH, R14WH, 402 R15WH)>; 403 404def GR32 : RegisterClass<"X86", [i32], 32, 405 (add EAX, ECX, EDX, ESI, EDI, EBX, EBP, ESP, 406 R8D, R9D, R10D, R11D, R14D, R15D, R12D, R13D)>; 407 408// GR64 - 64-bit GPRs. This oddly includes RIP, which isn't accurate, since 409// RIP isn't really a register and it can't be used anywhere except in an 410// address, but it doesn't cause trouble. 411// FIXME: it *does* cause trouble - CheckBaseRegAndIndexReg() has extra 412// tests because of the inclusion of RIP in this register class. 413def GR64 : RegisterClass<"X86", [i64], 64, 414 (add RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11, 415 RBX, R14, R15, R12, R13, RBP, RSP, RIP)>; 416 417// Segment registers for use by MOV instructions (and others) that have a 418// segment register as one operand. Always contain a 16-bit segment 419// descriptor. 420def SEGMENT_REG : RegisterClass<"X86", [i16], 16, (add CS, DS, SS, ES, FS, GS)>; 421 422// Debug registers. 423def DEBUG_REG : RegisterClass<"X86", [i32], 32, (sequence "DR%u", 0, 15)>; 424 425// Control registers. 426def CONTROL_REG : RegisterClass<"X86", [i64], 64, (sequence "CR%u", 0, 15)>; 427 428// GR8_ABCD_L, GR8_ABCD_H, GR16_ABCD, GR32_ABCD, GR64_ABCD - Subclasses of 429// GR8, GR16, GR32, and GR64 which contain just the "a" "b", "c", and "d" 430// registers. On x86-32, GR16_ABCD and GR32_ABCD are classes for registers 431// that support 8-bit subreg operations. On x86-64, GR16_ABCD, GR32_ABCD, 432// and GR64_ABCD are classes for registers that support 8-bit h-register 433// operations. 434def GR8_ABCD_L : RegisterClass<"X86", [i8], 8, (add AL, CL, DL, BL)>; 435def GR8_ABCD_H : RegisterClass<"X86", [i8], 8, (add AH, CH, DH, BH)>; 436def GR16_ABCD : RegisterClass<"X86", [i16], 16, (add AX, CX, DX, BX)>; 437def GR32_ABCD : RegisterClass<"X86", [i32], 32, (add EAX, ECX, EDX, EBX)>; 438def GR64_ABCD : RegisterClass<"X86", [i64], 64, (add RAX, RCX, RDX, RBX)>; 439def GR32_TC : RegisterClass<"X86", [i32], 32, (add EAX, ECX, EDX)>; 440def GR64_TC : RegisterClass<"X86", [i64], 64, (add RAX, RCX, RDX, RSI, RDI, 441 R8, R9, R11, RIP)>; 442def GR64_TCW64 : RegisterClass<"X86", [i64], 64, (add RAX, RCX, RDX, 443 R8, R9, R10, R11, RIP)>; 444 445// GR8_NOREX - GR8 registers which do not require a REX prefix. 446def GR8_NOREX : RegisterClass<"X86", [i8], 8, 447 (add AL, CL, DL, AH, CH, DH, BL, BH)> { 448 let AltOrders = [(sub GR8_NOREX, AH, BH, CH, DH)]; 449 let AltOrderSelect = [{ 450 return MF.getSubtarget<X86Subtarget>().is64Bit(); 451 }]; 452} 453// GR16_NOREX - GR16 registers which do not require a REX prefix. 454def GR16_NOREX : RegisterClass<"X86", [i16], 16, 455 (add AX, CX, DX, SI, DI, BX, BP, SP)>; 456// GR32_NOREX - GR32 registers which do not require a REX prefix. 457def GR32_NOREX : RegisterClass<"X86", [i32], 32, 458 (add EAX, ECX, EDX, ESI, EDI, EBX, EBP, ESP)>; 459// GR64_NOREX - GR64 registers which do not require a REX prefix. 460def GR64_NOREX : RegisterClass<"X86", [i64], 64, 461 (add RAX, RCX, RDX, RSI, RDI, RBX, RBP, RSP, RIP)>; 462 463// GR32_NOSP - GR32 registers except ESP. 464def GR32_NOSP : RegisterClass<"X86", [i32], 32, (sub GR32, ESP)>; 465 466// GR64_NOSP - GR64 registers except RSP (and RIP). 467def GR64_NOSP : RegisterClass<"X86", [i64], 64, (sub GR64, RSP, RIP)>; 468 469// GR32_NOREX_NOSP - GR32 registers which do not require a REX prefix except 470// ESP. 471def GR32_NOREX_NOSP : RegisterClass<"X86", [i32], 32, 472 (and GR32_NOREX, GR32_NOSP)>; 473 474// GR64_NOREX_NOSP - GR64_NOREX registers except RSP. 475def GR64_NOREX_NOSP : RegisterClass<"X86", [i64], 64, 476 (and GR64_NOREX, GR64_NOSP)>; 477 478// Register classes used for ABIs that use 32-bit address accesses, 479// while using the whole x84_64 ISA. 480 481// In such cases, it is fine to use RIP as we are sure the 32 high 482// bits are not set. We do not need variants for NOSP as RIP is not 483// allowed there. 484// RIP is not spilled anywhere for now, so stick to 32-bit alignment 485// to save on memory space. 486// FIXME: We could allow all 64bit registers, but we would need 487// something to check that the 32 high bits are not set, 488// which we do not have right now. 489def LOW32_ADDR_ACCESS : RegisterClass<"X86", [i32], 32, (add GR32, RIP)>; 490 491// When RBP is used as a base pointer in a 32-bit addresses environement, 492// this is also safe to use the full register to access addresses. 493// Since RBP will never be spilled, stick to a 32 alignment to save 494// on memory consumption. 495def LOW32_ADDR_ACCESS_RBP : RegisterClass<"X86", [i32], 32, 496 (add LOW32_ADDR_ACCESS, RBP)>; 497 498// A class to support the 'A' assembler constraint: [ER]AX then [ER]DX. 499def GR32_AD : RegisterClass<"X86", [i32], 32, (add EAX, EDX)>; 500def GR64_AD : RegisterClass<"X86", [i64], 64, (add RAX, RDX)>; 501 502// Scalar SSE2 floating point registers. 503def FR32 : RegisterClass<"X86", [f32], 32, (sequence "XMM%u", 0, 15)>; 504 505def FR64 : RegisterClass<"X86", [f64], 64, (add FR32)>; 506 507 508// FIXME: This sets up the floating point register files as though they are f64 509// values, though they really are f80 values. This will cause us to spill 510// values as 64-bit quantities instead of 80-bit quantities, which is much much 511// faster on common hardware. In reality, this should be controlled by a 512// command line option or something. 513 514def RFP32 : RegisterClass<"X86",[f32], 32, (sequence "FP%u", 0, 6)>; 515def RFP64 : RegisterClass<"X86",[f64], 32, (add RFP32)>; 516def RFP80 : RegisterClass<"X86",[f80], 32, (add RFP32)>; 517 518// Floating point stack registers (these are not allocatable by the 519// register allocator - the floating point stackifier is responsible 520// for transforming FPn allocations to STn registers) 521def RST : RegisterClass<"X86", [f80, f64, f32], 32, (sequence "ST%u", 0, 7)> { 522 let isAllocatable = 0; 523} 524 525// Generic vector registers: VR64 and VR128. 526// Ensure that float types are declared first - only float is legal on SSE1. 527def VR64: RegisterClass<"X86", [x86mmx], 64, (sequence "MM%u", 0, 7)>; 528def VR128 : RegisterClass<"X86", [v4f32, v2f64, v16i8, v8i16, v4i32, v2i64, f128], 529 128, (add FR32)>; 530def VR256 : RegisterClass<"X86", [v8f32, v4f64, v32i8, v16i16, v8i32, v4i64], 531 256, (sequence "YMM%u", 0, 15)>; 532 533// Special classes that help the assembly parser choose some alternate 534// instructions to favor 2-byte VEX encodings. 535def VR128L : RegisterClass<"X86", [v4f32, v2f64, v16i8, v8i16, v4i32, v2i64, f128], 536 128, (sequence "XMM%u", 0, 7)>; 537def VR128H : RegisterClass<"X86", [v4f32, v2f64, v16i8, v8i16, v4i32, v2i64, f128], 538 128, (sequence "XMM%u", 8, 15)>; 539def VR256L : RegisterClass<"X86", [v8f32, v4f64, v32i8, v16i16, v8i32, v4i64], 540 256, (sequence "YMM%u", 0, 7)>; 541def VR256H : RegisterClass<"X86", [v8f32, v4f64, v32i8, v16i16, v8i32, v4i64], 542 256, (sequence "YMM%u", 8, 15)>; 543 544// Status flags registers. 545def CCR : RegisterClass<"X86", [i32], 32, (add EFLAGS)> { 546 let CopyCost = -1; // Don't allow copying of status registers. 547 let isAllocatable = 0; 548} 549def FPCCR : RegisterClass<"X86", [i16], 16, (add FPSW)> { 550 let CopyCost = -1; // Don't allow copying of status registers. 551 let isAllocatable = 0; 552} 553def DFCCR : RegisterClass<"X86", [i32], 32, (add DF)> { 554 let CopyCost = -1; // Don't allow copying of status registers. 555 let isAllocatable = 0; 556} 557 558// AVX-512 vector/mask registers. 559def VR512 : RegisterClass<"X86", [v16f32, v8f64, v64i8, v32i16, v16i32, v8i64], 560 512, (sequence "ZMM%u", 0, 31)>; 561 562// Scalar AVX-512 floating point registers. 563def FR32X : RegisterClass<"X86", [f32], 32, (sequence "XMM%u", 0, 31)>; 564 565def FR64X : RegisterClass<"X86", [f64], 64, (add FR32X)>; 566 567// Extended VR128 and VR256 for AVX-512 instructions 568def VR128X : RegisterClass<"X86", [v4f32, v2f64, v16i8, v8i16, v4i32, v2i64, f128], 569 128, (add FR32X)>; 570def VR256X : RegisterClass<"X86", [v8f32, v4f64, v32i8, v16i16, v8i32, v4i64], 571 256, (sequence "YMM%u", 0, 31)>; 572 573// Mask registers 574def VK1 : RegisterClass<"X86", [v1i1], 16, (sequence "K%u", 0, 7)> {let Size = 16;} 575def VK2 : RegisterClass<"X86", [v2i1], 16, (add VK1)> {let Size = 16;} 576def VK4 : RegisterClass<"X86", [v4i1], 16, (add VK2)> {let Size = 16;} 577def VK8 : RegisterClass<"X86", [v8i1], 16, (add VK4)> {let Size = 16;} 578def VK16 : RegisterClass<"X86", [v16i1], 16, (add VK8)> {let Size = 16;} 579def VK32 : RegisterClass<"X86", [v32i1], 32, (add VK16)> {let Size = 32;} 580def VK64 : RegisterClass<"X86", [v64i1], 64, (add VK32)> {let Size = 64;} 581 582def VK1WM : RegisterClass<"X86", [v1i1], 16, (sub VK1, K0)> {let Size = 16;} 583def VK2WM : RegisterClass<"X86", [v2i1], 16, (sub VK2, K0)> {let Size = 16;} 584def VK4WM : RegisterClass<"X86", [v4i1], 16, (sub VK4, K0)> {let Size = 16;} 585def VK8WM : RegisterClass<"X86", [v8i1], 16, (sub VK8, K0)> {let Size = 16;} 586def VK16WM : RegisterClass<"X86", [v16i1], 16, (add VK8WM)> {let Size = 16;} 587def VK32WM : RegisterClass<"X86", [v32i1], 32, (add VK16WM)> {let Size = 32;} 588def VK64WM : RegisterClass<"X86", [v64i1], 64, (add VK32WM)> {let Size = 64;} 589 590// Bound registers 591def BNDR : RegisterClass<"X86", [v2i64], 128, (sequence "BND%u", 0, 3)>; 592