1//===-- SIRegisterInfo.td - SI 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//===----------------------------------------------------------------------===// 11// Declarations that describe the SI registers 12//===----------------------------------------------------------------------===// 13 14class SIReg <string n, bits<16> encoding = 0> : Register<n> { 15 let Namespace = "AMDGPU"; 16 let HWEncoding = encoding; 17} 18 19// Special Registers 20def VCC : SIReg<"VCC", 106>; 21def EXEC : SIReg<"EXEC", 126>; 22def SCC : SIReg<"SCC", 253>; 23def M0 : SIReg <"M0", 124>; 24 25// SGPR registers 26foreach Index = 0-101 in { 27 def SGPR#Index : SIReg <"SGPR"#Index, Index>; 28} 29 30// VGPR registers 31foreach Index = 0-255 in { 32 def VGPR#Index : SIReg <"VGPR"#Index, Index> { 33 let HWEncoding{8} = 1; 34 } 35} 36 37//===----------------------------------------------------------------------===// 38// Groupings using register classes and tuples 39//===----------------------------------------------------------------------===// 40 41// SGPR 32-bit registers 42def SGPR_32 : RegisterClass<"AMDGPU", [f32, i32], 32, 43 (add (sequence "SGPR%u", 0, 101))>; 44 45// SGPR 64-bit registers 46def SGPR_64 : RegisterTuples<[sub0, sub1], 47 [(add (decimate (trunc SGPR_32, 101), 2)), 48 (add (decimate (shl SGPR_32, 1), 2))]>; 49 50// SGPR 128-bit registers 51def SGPR_128 : RegisterTuples<[sub0, sub1, sub2, sub3], 52 [(add (decimate (trunc SGPR_32, 99), 4)), 53 (add (decimate (shl SGPR_32, 1), 4)), 54 (add (decimate (shl SGPR_32, 2), 4)), 55 (add (decimate (shl SGPR_32, 3), 4))]>; 56 57// SGPR 256-bit registers 58def SGPR_256 : RegisterTuples<[sub0, sub1, sub2, sub3, sub4, sub5, sub6, sub7], 59 [(add (decimate (trunc SGPR_32, 95), 4)), 60 (add (decimate (shl SGPR_32, 1), 4)), 61 (add (decimate (shl SGPR_32, 2), 4)), 62 (add (decimate (shl SGPR_32, 3), 4)), 63 (add (decimate (shl SGPR_32, 4), 4)), 64 (add (decimate (shl SGPR_32, 5), 4)), 65 (add (decimate (shl SGPR_32, 6), 4)), 66 (add (decimate (shl SGPR_32, 7), 4))]>; 67 68// SGPR 512-bit registers 69def SGPR_512 : RegisterTuples<[sub0, sub1, sub2, sub3, sub4, sub5, sub6, sub7, 70 sub8, sub9, sub10, sub11, sub12, sub13, sub14, sub15], 71 [(add (decimate (trunc SGPR_32, 87), 4)), 72 (add (decimate (shl SGPR_32, 1), 4)), 73 (add (decimate (shl SGPR_32, 2), 4)), 74 (add (decimate (shl SGPR_32, 3), 4)), 75 (add (decimate (shl SGPR_32, 4), 4)), 76 (add (decimate (shl SGPR_32, 5), 4)), 77 (add (decimate (shl SGPR_32, 6), 4)), 78 (add (decimate (shl SGPR_32, 7), 4)), 79 (add (decimate (shl SGPR_32, 8), 4)), 80 (add (decimate (shl SGPR_32, 9), 4)), 81 (add (decimate (shl SGPR_32, 10), 4)), 82 (add (decimate (shl SGPR_32, 11), 4)), 83 (add (decimate (shl SGPR_32, 12), 4)), 84 (add (decimate (shl SGPR_32, 13), 4)), 85 (add (decimate (shl SGPR_32, 14), 4)), 86 (add (decimate (shl SGPR_32, 15), 4))]>; 87 88// VGPR 32-bit registers 89def VGPR_32 : RegisterClass<"AMDGPU", [f32, i32], 32, 90 (add (sequence "VGPR%u", 0, 255))>; 91 92// VGPR 64-bit registers 93def VGPR_64 : RegisterTuples<[sub0, sub1], 94 [(add (trunc VGPR_32, 255)), 95 (add (shl VGPR_32, 1))]>; 96 97// VGPR 128-bit registers 98def VGPR_128 : RegisterTuples<[sub0, sub1, sub2, sub3], 99 [(add (trunc VGPR_32, 253)), 100 (add (shl VGPR_32, 1)), 101 (add (shl VGPR_32, 2)), 102 (add (shl VGPR_32, 3))]>; 103 104// VGPR 256-bit registers 105def VGPR_256 : RegisterTuples<[sub0, sub1, sub2, sub3, sub4, sub5, sub6, sub7], 106 [(add (trunc VGPR_32, 249)), 107 (add (shl VGPR_32, 1)), 108 (add (shl VGPR_32, 2)), 109 (add (shl VGPR_32, 3)), 110 (add (shl VGPR_32, 4)), 111 (add (shl VGPR_32, 5)), 112 (add (shl VGPR_32, 6)), 113 (add (shl VGPR_32, 7))]>; 114 115// VGPR 512-bit registers 116def VGPR_512 : RegisterTuples<[sub0, sub1, sub2, sub3, sub4, sub5, sub6, sub7, 117 sub8, sub9, sub10, sub11, sub12, sub13, sub14, sub15], 118 [(add (trunc VGPR_32, 241)), 119 (add (shl VGPR_32, 1)), 120 (add (shl VGPR_32, 2)), 121 (add (shl VGPR_32, 3)), 122 (add (shl VGPR_32, 4)), 123 (add (shl VGPR_32, 5)), 124 (add (shl VGPR_32, 6)), 125 (add (shl VGPR_32, 7)), 126 (add (shl VGPR_32, 8)), 127 (add (shl VGPR_32, 9)), 128 (add (shl VGPR_32, 10)), 129 (add (shl VGPR_32, 11)), 130 (add (shl VGPR_32, 12)), 131 (add (shl VGPR_32, 13)), 132 (add (shl VGPR_32, 14)), 133 (add (shl VGPR_32, 15))]>; 134 135//===----------------------------------------------------------------------===// 136// Register classes used as source and destination 137//===----------------------------------------------------------------------===// 138 139// Special register classes for predicates and the M0 register 140def SCCReg : RegisterClass<"AMDGPU", [i32, i1], 32, (add SCC)>; 141def VCCReg : RegisterClass<"AMDGPU", [i64, i1], 64, (add VCC)>; 142def EXECReg : RegisterClass<"AMDGPU", [i64, i1], 64, (add EXEC)>; 143def M0Reg : RegisterClass<"AMDGPU", [i32], 32, (add M0)>; 144 145// Register class for all scalar registers (SGPRs + Special Registers) 146def SReg_32 : RegisterClass<"AMDGPU", [f32, i32], 32, 147 (add SGPR_32, M0Reg) 148>; 149 150def SReg_64 : RegisterClass<"AMDGPU", [i64, i1], 64, 151 (add SGPR_64, VCCReg, EXECReg) 152>; 153 154def SReg_128 : RegisterClass<"AMDGPU", [v16i8], 128, (add SGPR_128)>; 155 156def SReg_256 : RegisterClass<"AMDGPU", [v32i8], 256, (add SGPR_256)>; 157 158def SReg_512 : RegisterClass<"AMDGPU", [v64i8], 512, (add SGPR_512)>; 159 160// Register class for all vector registers (VGPRs + Interploation Registers) 161def VReg_32 : RegisterClass<"AMDGPU", [i32, f32, v1i32], 32, (add VGPR_32)>; 162 163def VReg_64 : RegisterClass<"AMDGPU", [i64, f64, v2i32, v2f32], 64, (add VGPR_64)>; 164 165def VReg_128 : RegisterClass<"AMDGPU", [v4i32, v4f32], 128, (add VGPR_128)>; 166 167def VReg_256 : RegisterClass<"AMDGPU", [v8i32, v8f32], 256, (add VGPR_256)>; 168 169def VReg_512 : RegisterClass<"AMDGPU", [v16i32, v16f32], 512, (add VGPR_512)>; 170 171//===----------------------------------------------------------------------===// 172// [SV]Src_* register classes, can have either an immediate or an register 173//===----------------------------------------------------------------------===// 174 175def SSrc_32 : RegisterClass<"AMDGPU", [i32, f32], 32, (add SReg_32)>; 176 177def SSrc_64 : RegisterClass<"AMDGPU", [i64, f64, i1], 64, (add SReg_64)>; 178 179def VSrc_32 : RegisterClass<"AMDGPU", [i32, f32], 32, (add VReg_32, SReg_32)>; 180 181def VSrc_64 : RegisterClass<"AMDGPU", [i64, f64], 64, (add VReg_64, SReg_64)>; 182 183