1//==- SystemZRegisterInfo.td - SystemZ register definitions -*- 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//===----------------------------------------------------------------------===// 11// Class definitions. 12//===----------------------------------------------------------------------===// 13 14class SystemZReg<string n> : Register<n> { 15 let Namespace = "SystemZ"; 16} 17 18class SystemZRegWithSubregs<string n, list<Register> subregs> 19 : RegisterWithSubRegs<n, subregs> { 20 let Namespace = "SystemZ"; 21} 22 23let Namespace = "SystemZ" in { 24def subreg_l32 : SubRegIndex<32, 0>; // Also acts as subreg_ll32. 25def subreg_h32 : SubRegIndex<32, 32>; // Also acts as subreg_lh32. 26def subreg_l64 : SubRegIndex<64, 0>; 27def subreg_h64 : SubRegIndex<64, 64>; 28def subreg_r32 : SubRegIndex<32, 32>; // Reinterpret a wider reg as 32 bits. 29def subreg_r64 : SubRegIndex<64, 64>; // Reinterpret a wider reg as 64 bits. 30def subreg_hh32 : ComposedSubRegIndex<subreg_h64, subreg_h32>; 31def subreg_hl32 : ComposedSubRegIndex<subreg_h64, subreg_l32>; 32def subreg_hr32 : ComposedSubRegIndex<subreg_h64, subreg_r32>; 33} 34 35// Define a register class that contains values of types TYPES and an 36// associated operand called NAME. SIZE is the size and alignment 37// of the registers and REGLIST is the list of individual registers. 38multiclass SystemZRegClass<string name, list<ValueType> types, int size, 39 dag regList, bit allocatable = 1> { 40 def AsmOperand : AsmOperandClass { 41 let Name = name; 42 let ParserMethod = "parse"##name; 43 let RenderMethod = "addRegOperands"; 44 } 45 let isAllocatable = allocatable in 46 def Bit : RegisterClass<"SystemZ", types, size, regList> { 47 let Size = size; 48 } 49 def "" : RegisterOperand<!cast<RegisterClass>(name##"Bit")> { 50 let ParserMatchClass = !cast<AsmOperandClass>(name##"AsmOperand"); 51 } 52} 53 54//===----------------------------------------------------------------------===// 55// General-purpose registers 56//===----------------------------------------------------------------------===// 57 58// Lower 32 bits of one of the 16 64-bit general-purpose registers 59class GPR32<bits<16> num, string n> : SystemZReg<n> { 60 let HWEncoding = num; 61} 62 63// One of the 16 64-bit general-purpose registers. 64class GPR64<bits<16> num, string n, GPR32 low, GPR32 high> 65 : SystemZRegWithSubregs<n, [low, high]> { 66 let HWEncoding = num; 67 let SubRegIndices = [subreg_l32, subreg_h32]; 68 let CoveredBySubRegs = 1; 69} 70 71// 8 even-odd pairs of GPR64s. 72class GPR128<bits<16> num, string n, GPR64 low, GPR64 high> 73 : SystemZRegWithSubregs<n, [low, high]> { 74 let HWEncoding = num; 75 let SubRegIndices = [subreg_l64, subreg_h64]; 76 let CoveredBySubRegs = 1; 77} 78 79// General-purpose registers 80foreach I = 0-15 in { 81 def R#I#L : GPR32<I, "r"#I>; 82 def R#I#H : GPR32<I, "r"#I>; 83 def R#I#D : GPR64<I, "r"#I, !cast<GPR32>("R"#I#"L"), !cast<GPR32>("R"#I#"H")>, 84 DwarfRegNum<[I]>; 85} 86 87foreach I = [0, 2, 4, 6, 8, 10, 12, 14] in { 88 def R#I#Q : GPR128<I, "r"#I, !cast<GPR64>("R"#!add(I, 1)#"D"), 89 !cast<GPR64>("R"#I#"D")>; 90} 91 92/// Allocate the callee-saved R6-R13 backwards. That way they can be saved 93/// together with R14 and R15 in one prolog instruction. 94defm GR32 : SystemZRegClass<"GR32", [i32], 32, 95 (add (sequence "R%uL", 0, 5), 96 (sequence "R%uL", 15, 6))>; 97defm GRH32 : SystemZRegClass<"GRH32", [i32], 32, 98 (add (sequence "R%uH", 0, 5), 99 (sequence "R%uH", 15, 6))>; 100defm GR64 : SystemZRegClass<"GR64", [i64], 64, 101 (add (sequence "R%uD", 0, 5), 102 (sequence "R%uD", 15, 6))>; 103 104// Combine the low and high GR32s into a single class. This can only be 105// used for virtual registers if the high-word facility is available. 106defm GRX32 : SystemZRegClass<"GRX32", [i32], 32, 107 (add (sequence "R%uL", 0, 5), 108 (sequence "R%uH", 0, 5), 109 R15L, R15H, R14L, R14H, R13L, R13H, 110 R12L, R12H, R11L, R11H, R10L, R10H, 111 R9L, R9H, R8L, R8H, R7L, R7H, R6L, R6H)>; 112 113// The architecture doesn't really have any i128 support, so model the 114// register pairs as untyped instead. 115defm GR128 : SystemZRegClass<"GR128", [untyped], 128, 116 (add R0Q, R2Q, R4Q, R12Q, R10Q, R8Q, R6Q, R14Q)>; 117 118// Base and index registers. Everything except R0, which in an address 119// context evaluates as 0. 120defm ADDR32 : SystemZRegClass<"ADDR32", [i32], 32, (sub GR32Bit, R0L)>; 121defm ADDR64 : SystemZRegClass<"ADDR64", [i64], 64, (sub GR64Bit, R0D)>; 122 123// Not used directly, but needs to exist for ADDR32 and ADDR64 subregs 124// of a GR128. 125defm ADDR128 : SystemZRegClass<"ADDR128", [untyped], 128, (sub GR128Bit, R0Q)>; 126 127// Any type register. Used for .insn directives when we don't know what the 128// register types could be. 129defm AnyReg : SystemZRegClass<"AnyReg", 130 [i64, f64, v8i8, v4i16, v2i32, v2f32], 64, 131 (add (sequence "R%uD", 0, 15), 132 (sequence "F%uD", 0, 15), 133 (sequence "V%u", 0, 15)), 0/*allocatable*/>; 134 135//===----------------------------------------------------------------------===// 136// Floating-point registers 137//===----------------------------------------------------------------------===// 138 139// Maps FPR register numbers to their DWARF encoding. 140class DwarfMapping<int id> { int Id = id; } 141 142def F0Dwarf : DwarfMapping<16>; 143def F2Dwarf : DwarfMapping<17>; 144def F4Dwarf : DwarfMapping<18>; 145def F6Dwarf : DwarfMapping<19>; 146 147def F1Dwarf : DwarfMapping<20>; 148def F3Dwarf : DwarfMapping<21>; 149def F5Dwarf : DwarfMapping<22>; 150def F7Dwarf : DwarfMapping<23>; 151 152def F8Dwarf : DwarfMapping<24>; 153def F10Dwarf : DwarfMapping<25>; 154def F12Dwarf : DwarfMapping<26>; 155def F14Dwarf : DwarfMapping<27>; 156 157def F9Dwarf : DwarfMapping<28>; 158def F11Dwarf : DwarfMapping<29>; 159def F13Dwarf : DwarfMapping<30>; 160def F15Dwarf : DwarfMapping<31>; 161 162def F16Dwarf : DwarfMapping<68>; 163def F18Dwarf : DwarfMapping<69>; 164def F20Dwarf : DwarfMapping<70>; 165def F22Dwarf : DwarfMapping<71>; 166 167def F17Dwarf : DwarfMapping<72>; 168def F19Dwarf : DwarfMapping<73>; 169def F21Dwarf : DwarfMapping<74>; 170def F23Dwarf : DwarfMapping<75>; 171 172def F24Dwarf : DwarfMapping<76>; 173def F26Dwarf : DwarfMapping<77>; 174def F28Dwarf : DwarfMapping<78>; 175def F30Dwarf : DwarfMapping<79>; 176 177def F25Dwarf : DwarfMapping<80>; 178def F27Dwarf : DwarfMapping<81>; 179def F29Dwarf : DwarfMapping<82>; 180def F31Dwarf : DwarfMapping<83>; 181 182// Upper 32 bits of one of the floating-point registers 183class FPR32<bits<16> num, string n> : SystemZReg<n> { 184 let HWEncoding = num; 185} 186 187// One of the floating-point registers. 188class FPR64<bits<16> num, string n, FPR32 high> 189 : SystemZRegWithSubregs<n, [high]> { 190 let HWEncoding = num; 191 let SubRegIndices = [subreg_r32]; 192} 193 194// 8 pairs of FPR64s, with a one-register gap inbetween. 195class FPR128<bits<16> num, string n, FPR64 low, FPR64 high> 196 : SystemZRegWithSubregs<n, [low, high]> { 197 let HWEncoding = num; 198 let SubRegIndices = [subreg_l64, subreg_h64]; 199 let CoveredBySubRegs = 1; 200} 201 202// Floating-point registers. Registers 16-31 require the vector facility. 203foreach I = 0-15 in { 204 def F#I#S : FPR32<I, "f"#I>; 205 def F#I#D : FPR64<I, "f"#I, !cast<FPR32>("F"#I#"S")>, 206 DwarfRegNum<[!cast<DwarfMapping>("F"#I#"Dwarf").Id]>; 207} 208foreach I = 16-31 in { 209 def F#I#S : FPR32<I, "v"#I>; 210 def F#I#D : FPR64<I, "v"#I, !cast<FPR32>("F"#I#"S")>, 211 DwarfRegNum<[!cast<DwarfMapping>("F"#I#"Dwarf").Id]>; 212} 213 214foreach I = [0, 1, 4, 5, 8, 9, 12, 13] in { 215 def F#I#Q : FPR128<I, "f"#I, !cast<FPR64>("F"#!add(I, 2)#"D"), 216 !cast<FPR64>("F"#I#"D")>; 217} 218 219// There's no store-multiple instruction for FPRs, so we're not fussy 220// about the order in which call-saved registers are allocated. 221defm FP32 : SystemZRegClass<"FP32", [f32], 32, (sequence "F%uS", 0, 15)>; 222defm FP64 : SystemZRegClass<"FP64", [f64], 64, (sequence "F%uD", 0, 15)>; 223defm FP128 : SystemZRegClass<"FP128", [f128], 128, 224 (add F0Q, F1Q, F4Q, F5Q, F8Q, F9Q, F12Q, F13Q)>; 225 226//===----------------------------------------------------------------------===// 227// Vector registers 228//===----------------------------------------------------------------------===// 229 230// A full 128-bit vector register, with an FPR64 as its high part. 231class VR128<bits<16> num, string n, FPR64 high> 232 : SystemZRegWithSubregs<n, [high]> { 233 let HWEncoding = num; 234 let SubRegIndices = [subreg_r64]; 235} 236 237// Full vector registers. 238foreach I = 0-31 in { 239 def V#I : VR128<I, "v"#I, !cast<FPR64>("F"#I#"D")>, 240 DwarfRegNum<[!cast<DwarfMapping>("F"#I#"Dwarf").Id]>; 241} 242 243// Class used to store 32-bit values in the first element of a vector 244// register. f32 scalars are used for the WLEDB and WLDEB instructions. 245defm VR32 : SystemZRegClass<"VR32", [f32, v4i8, v2i16], 32, 246 (add (sequence "F%uS", 0, 7), 247 (sequence "F%uS", 16, 31), 248 (sequence "F%uS", 8, 15))>; 249 250// Class used to store 64-bit values in the upper half of a vector register. 251// The vector facility also includes scalar f64 instructions that operate 252// on the full vector register set. 253defm VR64 : SystemZRegClass<"VR64", [f64, v8i8, v4i16, v2i32, v2f32], 64, 254 (add (sequence "F%uD", 0, 7), 255 (sequence "F%uD", 16, 31), 256 (sequence "F%uD", 8, 15))>; 257 258// The subset of vector registers that can be used for floating-point 259// operations too. 260defm VF128 : SystemZRegClass<"VF128", 261 [v16i8, v8i16, v4i32, v2i64, v4f32, v2f64], 128, 262 (sequence "V%u", 0, 15)>; 263 264// All vector registers. 265defm VR128 : SystemZRegClass<"VR128", 266 [v16i8, v8i16, v4i32, v2i64, v4f32, v2f64, f128], 267 128, (add (sequence "V%u", 0, 7), 268 (sequence "V%u", 16, 31), 269 (sequence "V%u", 8, 15))>; 270 271// Attaches a ValueType to a register operand, to make the instruction 272// definitions easier. 273class TypedReg<ValueType vtin, RegisterOperand opin> { 274 ValueType vt = vtin; 275 RegisterOperand op = opin; 276} 277 278def v32f : TypedReg<i32, VR32>; 279def v32sb : TypedReg<f32, VR32>; 280def v64g : TypedReg<i64, VR64>; 281def v64db : TypedReg<f64, VR64>; 282def v128b : TypedReg<v16i8, VR128>; 283def v128h : TypedReg<v8i16, VR128>; 284def v128f : TypedReg<v4i32, VR128>; 285def v128g : TypedReg<v2i64, VR128>; 286def v128q : TypedReg<v16i8, VR128>; 287def v128sb : TypedReg<v4f32, VR128>; 288def v128db : TypedReg<v2f64, VR128>; 289def v128xb : TypedReg<f128, VR128>; 290def v128any : TypedReg<untyped, VR128>; 291 292//===----------------------------------------------------------------------===// 293// Other registers 294//===----------------------------------------------------------------------===// 295 296// The 2-bit condition code field of the PSW. Every register named in an 297// inline asm needs a class associated with it. 298def CC : SystemZReg<"cc">; 299let isAllocatable = 0, CopyCost = -1 in 300 def CCR : RegisterClass<"SystemZ", [i32], 32, (add CC)>; 301 302// Access registers. 303class ACR32<bits<16> num, string n> : SystemZReg<n> { 304 let HWEncoding = num; 305} 306foreach I = 0-15 in { 307 def A#I : ACR32<I, "a"#I>, DwarfRegNum<[!add(I, 48)]>; 308} 309defm AR32 : SystemZRegClass<"AR32", [i32], 32, 310 (add (sequence "A%u", 0, 15)), 0>; 311 312// Control registers. 313class CREG64<bits<16> num, string n> : SystemZReg<n> { 314 let HWEncoding = num; 315} 316foreach I = 0-15 in { 317 def C#I : CREG64<I, "c"#I>, DwarfRegNum<[!add(I, 32)]>; 318} 319defm CR64 : SystemZRegClass<"CR64", [i64], 64, 320 (add (sequence "C%u", 0, 15)), 0>; 321 322