1 //===-- SIRegisterInfo.td - SI Register defs ---------------*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
13 class getSubRegs<int size> {
14 list<SubRegIndex> ret2 = [sub0, sub1];
15 list<SubRegIndex> ret3 = [sub0, sub1, sub2];
16 list<SubRegIndex> ret4 = [sub0, sub1, sub2, sub3];
17 list<SubRegIndex> ret5 = [sub0, sub1, sub2, sub3, sub4];
18 list<SubRegIndex> ret8 = [sub0, sub1, sub2, sub3, sub4, sub5, sub6, sub7];
19 list<SubRegIndex> ret16 = [sub0, sub1, sub2, sub3,
20 sub4, sub5, sub6, sub7,
21 sub8, sub9, sub10, sub11,
22 sub12, sub13, sub14, sub15];
23 list<SubRegIndex> ret32 = [sub0, sub1, sub2, sub3,
24 sub4, sub5, sub6, sub7,
25 sub8, sub9, sub10, sub11,
26 sub12, sub13, sub14, sub15,
27 sub16, sub17, sub18, sub19,
28 sub20, sub21, sub22, sub23,
29 sub24, sub25, sub26, sub27,
30 sub28, sub29, sub30, sub31];
32 list<SubRegIndex> ret = !if(!eq(size, 2), ret2,
33 !if(!eq(size, 3), ret3,
34 !if(!eq(size, 4), ret4,
35 !if(!eq(size, 5), ret5,
36 !if(!eq(size, 8), ret8,
37 !if(!eq(size, 16), ret16, ret32))))));
40 // Generates list of sequential register tuple names.
41 // E.g. RegSeq<3,2,2,"s">.ret -> [ "s[0:1]", "s[2:3]" ]
42 class RegSeqNames<int last_reg, int stride, int size, string prefix,
44 int next = !add(start, stride);
45 int end_reg = !add(!add(start, size), -1);
47 !if(!le(end_reg, last_reg),
48 !listconcat([prefix # "[" # start # ":" # end_reg # "]"],
49 RegSeqNames<last_reg, stride, size, prefix, next>.ret),
53 // Generates list of dags for register tupless.
54 class RegSeqDags<RegisterClass RC, int last_reg, int stride, int size,
56 dag trunc_rc = (trunc RC,
57 !if(!and(!eq(stride, 1), !eq(start, 0)),
58 !add(!add(last_reg, 2), !mul(size, -1)),
62 !listconcat([(add (decimate (shl trunc_rc, start), stride))],
63 RegSeqDags<RC, last_reg, stride, size, !add(start, 1)>.ret),
67 class SIRegisterTuples<list<SubRegIndex> Indices, RegisterClass RC,
68 int last_reg, int stride, int size, string prefix> :
69 RegisterTuples<Indices,
70 RegSeqDags<RC, last_reg, stride, size>.ret,
71 RegSeqNames<last_reg, stride, size, prefix>.ret>;
73 //===----------------------------------------------------------------------===//
74 // Declarations that describe the SI registers
75 //===----------------------------------------------------------------------===//
76 class SIReg <string n, bits<16> regIdx = 0> :
78 DwarfRegNum<[!cast<int>(HWEncoding)]> {
79 let Namespace = "AMDGPU";
81 // This is the not yet the complete register encoding. An additional
82 // bit is set for VGPRs.
83 let HWEncoding = regIdx;
87 def VCC_LO : SIReg<"vcc_lo", 106>;
88 def VCC_HI : SIReg<"vcc_hi", 107>;
90 // Pseudo-registers: Used as placeholders during isel and immediately
91 // replaced, never seeing the verifier.
92 def PRIVATE_RSRC_REG : SIReg<"private_rsrc", 0>;
93 def FP_REG : SIReg<"fp", 0>;
94 def SP_REG : SIReg<"sp", 0>;
95 def SCRATCH_WAVE_OFFSET_REG : SIReg<"scratch_wave_offset", 0>;
97 // VCC for 64-bit instructions
98 def VCC : RegisterWithSubRegs<"vcc", [VCC_LO, VCC_HI]>,
99 DwarfRegAlias<VCC_LO> {
100 let Namespace = "AMDGPU";
101 let SubRegIndices = [sub0, sub1];
102 let HWEncoding = 106;
105 def EXEC_LO : SIReg<"exec_lo", 126>;
106 def EXEC_HI : SIReg<"exec_hi", 127>;
108 def EXEC : RegisterWithSubRegs<"exec", [EXEC_LO, EXEC_HI]>,
109 DwarfRegAlias<EXEC_LO> {
110 let Namespace = "AMDGPU";
111 let SubRegIndices = [sub0, sub1];
112 let HWEncoding = 126;
115 // 32-bit real registers, for MC only.
116 // May be used with both 32-bit and 64-bit operands.
117 def SRC_VCCZ : SIReg<"src_vccz", 251>;
118 def SRC_EXECZ : SIReg<"src_execz", 252>;
119 def SRC_SCC : SIReg<"src_scc", 253>;
121 // 1-bit pseudo register, for codegen only.
122 // Should never be emitted.
123 def SCC : SIReg<"scc">;
125 def M0 : SIReg <"m0", 124>;
126 def SGPR_NULL : SIReg<"null", 125>;
128 def SRC_SHARED_BASE : SIReg<"src_shared_base", 235>;
129 def SRC_SHARED_LIMIT : SIReg<"src_shared_limit", 236>;
130 def SRC_PRIVATE_BASE : SIReg<"src_private_base", 237>;
131 def SRC_PRIVATE_LIMIT : SIReg<"src_private_limit", 238>;
132 def SRC_POPS_EXITING_WAVE_ID : SIReg<"src_pops_exiting_wave_id", 239>;
134 def LDS_DIRECT : SIReg <"src_lds_direct", 254>;
136 def XNACK_MASK_LO : SIReg<"xnack_mask_lo", 104>;
137 def XNACK_MASK_HI : SIReg<"xnack_mask_hi", 105>;
139 def XNACK_MASK : RegisterWithSubRegs<"xnack_mask", [XNACK_MASK_LO, XNACK_MASK_HI]>,
140 DwarfRegAlias<XNACK_MASK_LO> {
141 let Namespace = "AMDGPU";
142 let SubRegIndices = [sub0, sub1];
143 let HWEncoding = 104;
146 // Trap handler registers
147 def TBA_LO : SIReg<"tba_lo", 108>;
148 def TBA_HI : SIReg<"tba_hi", 109>;
150 def TBA : RegisterWithSubRegs<"tba", [TBA_LO, TBA_HI]>,
151 DwarfRegAlias<TBA_LO> {
152 let Namespace = "AMDGPU";
153 let SubRegIndices = [sub0, sub1];
154 let HWEncoding = 108;
157 def TMA_LO : SIReg<"tma_lo", 110>;
158 def TMA_HI : SIReg<"tma_hi", 111>;
160 def TMA : RegisterWithSubRegs<"tma", [TMA_LO, TMA_HI]>,
161 DwarfRegAlias<TMA_LO> {
162 let Namespace = "AMDGPU";
163 let SubRegIndices = [sub0, sub1];
164 let HWEncoding = 110;
167 foreach Index = 0-15 in {
168 def TTMP#Index#_vi : SIReg<"ttmp"#Index, !add(112, Index)>;
169 def TTMP#Index#_gfx9_gfx10 : SIReg<"ttmp"#Index, !add(108, Index)>;
170 def TTMP#Index : SIReg<"ttmp"#Index, 0>;
173 multiclass FLAT_SCR_LOHI_m <string n, bits<16> ci_e, bits<16> vi_e> {
174 def _ci : SIReg<n, ci_e>;
175 def _vi : SIReg<n, vi_e>;
176 def "" : SIReg<n, 0>;
179 class FlatReg <Register lo, Register hi, bits<16> encoding> :
180 RegisterWithSubRegs<"flat_scratch", [lo, hi]>,
182 let Namespace = "AMDGPU";
183 let SubRegIndices = [sub0, sub1];
184 let HWEncoding = encoding;
187 defm FLAT_SCR_LO : FLAT_SCR_LOHI_m<"flat_scratch_lo", 104, 102>; // Offset in units of 256-bytes.
188 defm FLAT_SCR_HI : FLAT_SCR_LOHI_m<"flat_scratch_hi", 105, 103>; // Size is the per-thread scratch size, in bytes.
190 def FLAT_SCR_ci : FlatReg<FLAT_SCR_LO_ci, FLAT_SCR_HI_ci, 104>;
191 def FLAT_SCR_vi : FlatReg<FLAT_SCR_LO_vi, FLAT_SCR_HI_vi, 102>;
192 def FLAT_SCR : FlatReg<FLAT_SCR_LO, FLAT_SCR_HI, 0>;
195 foreach Index = 0-105 in {
196 def SGPR#Index : SIReg <"s"#Index, Index>;
200 foreach Index = 0-255 in {
201 def VGPR#Index : SIReg <"v"#Index, Index> {
202 let HWEncoding{8} = 1;
207 foreach Index = 0-255 in {
208 def AGPR#Index : SIReg <"a"#Index, Index> {
209 let HWEncoding{8} = 1;
213 //===----------------------------------------------------------------------===//
214 // Groupings using register classes and tuples
215 //===----------------------------------------------------------------------===//
217 def SCC_CLASS : RegisterClass<"AMDGPU", [i1], 1, (add SCC)> {
219 let isAllocatable = 0;
222 def M0_CLASS : RegisterClass<"AMDGPU", [i32], 32, (add M0)> {
224 let isAllocatable = 0;
227 // TODO: Do we need to set DwarfRegAlias on register tuples?
229 // SGPR 32-bit registers
230 def SGPR_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
231 (add (sequence "SGPR%u", 0, 105))> {
232 // Give all SGPR classes higher priority than VGPR classes, because
233 // we want to spill SGPRs to VGPRs.
234 let AllocationPriority = 9;
237 // SGPR 64-bit registers
238 def SGPR_64Regs : SIRegisterTuples<getSubRegs<2>.ret, SGPR_32, 105, 2, 2, "s">;
240 // SGPR 96-bit registers. No operations use these, but for symmetry with 96-bit VGPRs.
241 def SGPR_96Regs : SIRegisterTuples<getSubRegs<3>.ret, SGPR_32, 105, 3, 3, "s">;
243 // SGPR 128-bit registers
244 def SGPR_128Regs : SIRegisterTuples<getSubRegs<4>.ret, SGPR_32, 105, 4, 4, "s">;
246 // SGPR 160-bit registers. No operations use these, but for symmetry with 160-bit VGPRs.
247 def SGPR_160Regs : SIRegisterTuples<getSubRegs<5>.ret, SGPR_32, 105, 4, 5, "s">;
249 // SGPR 256-bit registers
250 def SGPR_256Regs : SIRegisterTuples<getSubRegs<8>.ret, SGPR_32, 105, 4, 8, "s">;
252 // SGPR 512-bit registers
253 def SGPR_512Regs : SIRegisterTuples<getSubRegs<16>.ret, SGPR_32, 105, 4, 16, "s">;
255 // SGPR 1024-bit registers
256 def SGPR_1024Regs : SIRegisterTuples<getSubRegs<32>.ret, SGPR_32, 105, 4, 32, "s">;
258 // Trap handler TMP 32-bit registers
259 def TTMP_32 : RegisterClass<"AMDGPU", [i32, f32, v2i16, v2f16], 32,
260 (add (sequence "TTMP%u", 0, 15))> {
261 let isAllocatable = 0;
264 // Trap handler TMP 64-bit registers
265 def TTMP_64Regs : SIRegisterTuples<getSubRegs<2>.ret, TTMP_32, 15, 2, 2, "ttmp">;
267 // Trap handler TMP 128-bit registers
268 def TTMP_128Regs : SIRegisterTuples<getSubRegs<4>.ret, TTMP_32, 15, 4, 4, "ttmp">;
270 def TTMP_256Regs : SIRegisterTuples<getSubRegs<8>.ret, TTMP_32, 15, 4, 8, "ttmp">;
272 def TTMP_512Regs : SIRegisterTuples<getSubRegs<16>.ret, TTMP_32, 15, 4, 16, "ttmp">;
274 class TmpRegTuplesBase<int index, int size,
275 list<Register> subRegs,
276 list<SubRegIndex> indices = getSubRegs<size>.ret,
277 int index1 = !add(index, !add(size, -1)),
278 string name = "ttmp["#index#":"#index1#"]"> :
279 RegisterWithSubRegs<name, subRegs> {
280 let HWEncoding = subRegs[0].HWEncoding;
281 let SubRegIndices = indices;
284 class TmpRegTuples<string tgt,
287 int index1 = !add(index0, 1),
288 int index2 = !add(index0, !if(!eq(size, 2), 1, 2)),
289 int index3 = !add(index0, !if(!eq(size, 2), 1, 3)),
290 int index4 = !add(index0, !if(!eq(size, 8), 4, 1)),
291 int index5 = !add(index0, !if(!eq(size, 8), 5, 1)),
292 int index6 = !add(index0, !if(!eq(size, 8), 6, 1)),
293 int index7 = !add(index0, !if(!eq(size, 8), 7, 1)),
294 Register r0 = !cast<Register>("TTMP"#index0#tgt),
295 Register r1 = !cast<Register>("TTMP"#index1#tgt),
296 Register r2 = !cast<Register>("TTMP"#index2#tgt),
297 Register r3 = !cast<Register>("TTMP"#index3#tgt),
298 Register r4 = !cast<Register>("TTMP"#index4#tgt),
299 Register r5 = !cast<Register>("TTMP"#index5#tgt),
300 Register r6 = !cast<Register>("TTMP"#index6#tgt),
301 Register r7 = !cast<Register>("TTMP"#index7#tgt)> :
302 TmpRegTuplesBase<index0, size,
303 !if(!eq(size, 2), [r0, r1],
304 !if(!eq(size, 4), [r0, r1, r2, r3],
305 [r0, r1, r2, r3, r4, r5, r6, r7])),
306 getSubRegs<size>.ret>;
308 foreach Index = {0, 2, 4, 6, 8, 10, 12, 14} in {
309 def TTMP#Index#_TTMP#!add(Index,1)#_vi : TmpRegTuples<"_vi", 2, Index>;
310 def TTMP#Index#_TTMP#!add(Index,1)#_gfx9_gfx10 : TmpRegTuples<"_gfx9_gfx10", 2, Index>;
313 foreach Index = {0, 4, 8, 12} in {
314 def TTMP#Index#_TTMP#!add(Index,1)#
316 _TTMP#!add(Index,3)#_vi : TmpRegTuples<"_vi", 4, Index>;
317 def TTMP#Index#_TTMP#!add(Index,1)#
319 _TTMP#!add(Index,3)#_gfx9_gfx10 : TmpRegTuples<"_gfx9_gfx10", 4, Index>;
322 foreach Index = {0, 4, 8} in {
323 def TTMP#Index#_TTMP#!add(Index,1)#
329 _TTMP#!add(Index,7)#_vi : TmpRegTuples<"_vi", 8, Index>;
330 def TTMP#Index#_TTMP#!add(Index,1)#
336 _TTMP#!add(Index,7)#_gfx9_gfx10 : TmpRegTuples<"_gfx9_gfx10", 8, Index>;
339 def TTMP0_TTMP1_TTMP2_TTMP3_TTMP4_TTMP5_TTMP6_TTMP7_TTMP8_TTMP9_TTMP10_TTMP11_TTMP12_TTMP13_TTMP14_TTMP15_vi :
340 TmpRegTuplesBase<0, 16,
341 [TTMP0_vi, TTMP1_vi, TTMP2_vi, TTMP3_vi,
342 TTMP4_vi, TTMP5_vi, TTMP6_vi, TTMP7_vi,
343 TTMP8_vi, TTMP9_vi, TTMP10_vi, TTMP11_vi,
344 TTMP12_vi, TTMP13_vi, TTMP14_vi, TTMP15_vi]>;
346 def TTMP0_TTMP1_TTMP2_TTMP3_TTMP4_TTMP5_TTMP6_TTMP7_TTMP8_TTMP9_TTMP10_TTMP11_TTMP12_TTMP13_TTMP14_TTMP15_gfx9_gfx10 :
347 TmpRegTuplesBase<0, 16,
348 [TTMP0_gfx9_gfx10, TTMP1_gfx9_gfx10, TTMP2_gfx9_gfx10, TTMP3_gfx9_gfx10,
349 TTMP4_gfx9_gfx10, TTMP5_gfx9_gfx10, TTMP6_gfx9_gfx10, TTMP7_gfx9_gfx10,
350 TTMP8_gfx9_gfx10, TTMP9_gfx9_gfx10, TTMP10_gfx9_gfx10, TTMP11_gfx9_gfx10,
351 TTMP12_gfx9_gfx10, TTMP13_gfx9_gfx10, TTMP14_gfx9_gfx10, TTMP15_gfx9_gfx10]>;
353 class RegisterTypes<list<ValueType> reg_types> {
354 list<ValueType> types = reg_types;
357 def Reg16Types : RegisterTypes<[i16, f16]>;
358 def Reg32Types : RegisterTypes<[i32, f32, v2i16, v2f16, p2, p3, p5, p6]>;
361 // VGPR 32-bit registers
362 // i16/f16 only on VI+
363 def VGPR_32 : RegisterClass<"AMDGPU", !listconcat(Reg32Types.types, Reg16Types.types), 32,
364 (add (sequence "VGPR%u", 0, 255))> {
365 let AllocationPriority = 1;
369 // VGPR 64-bit registers
370 def VGPR_64 : SIRegisterTuples<getSubRegs<2>.ret, VGPR_32, 255, 1, 2, "v">;
372 // VGPR 96-bit registers
373 def VGPR_96 : SIRegisterTuples<getSubRegs<3>.ret, VGPR_32, 255, 1, 3, "v">;
375 // VGPR 128-bit registers
376 def VGPR_128 : SIRegisterTuples<getSubRegs<4>.ret, VGPR_32, 255, 1, 4, "v">;
378 // VGPR 160-bit registers
379 def VGPR_160 : SIRegisterTuples<getSubRegs<5>.ret, VGPR_32, 255, 1, 5, "v">;
381 // VGPR 256-bit registers
382 def VGPR_256 : SIRegisterTuples<getSubRegs<8>.ret, VGPR_32, 255, 1, 8, "v">;
384 // VGPR 512-bit registers
385 def VGPR_512 : SIRegisterTuples<getSubRegs<16>.ret, VGPR_32, 255, 1, 16, "v">;
387 // VGPR 1024-bit registers
388 def VGPR_1024 : SIRegisterTuples<getSubRegs<32>.ret, VGPR_32, 255, 1, 32, "v">;
390 // AccVGPR 32-bit registers
391 def AGPR_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
392 (add (sequence "AGPR%u", 0, 255))> {
393 let AllocationPriority = 1;
397 // AGPR 64-bit registers
398 def AGPR_64 : SIRegisterTuples<getSubRegs<2>.ret, AGPR_32, 255, 1, 2, "a">;
400 // AGPR 128-bit registers
401 def AGPR_128 : SIRegisterTuples<getSubRegs<4>.ret, AGPR_32, 255, 1, 4, "a">;
403 // AGPR 512-bit registers
404 def AGPR_512 : SIRegisterTuples<getSubRegs<16>.ret, AGPR_32, 255, 1, 16, "a">;
406 // AGPR 1024-bit registers
407 def AGPR_1024 : SIRegisterTuples<getSubRegs<32>.ret, AGPR_32, 255, 1, 32, "a">;
409 //===----------------------------------------------------------------------===//
410 // Register classes used as source and destination
411 //===----------------------------------------------------------------------===//
413 def Pseudo_SReg_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
414 (add FP_REG, SP_REG, SCRATCH_WAVE_OFFSET_REG)> {
415 let isAllocatable = 0;
419 def Pseudo_SReg_128 : RegisterClass<"AMDGPU", [v4i32, v2i64, v2f64], 32,
420 (add PRIVATE_RSRC_REG)> {
421 let isAllocatable = 0;
425 def LDS_DIRECT_CLASS : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
427 let isAllocatable = 0;
431 // Subset of SReg_32 without M0 for SMRD instructions and alike.
432 // See comments in SIInstructions.td for more info.
433 def SReg_32_XM0_XEXEC : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16, i1], 32,
434 (add SGPR_32, VCC_LO, VCC_HI, FLAT_SCR_LO, FLAT_SCR_HI, XNACK_MASK_LO, XNACK_MASK_HI,
435 SGPR_NULL, TTMP_32, TMA_LO, TMA_HI, TBA_LO, TBA_HI, SRC_SHARED_BASE, SRC_SHARED_LIMIT,
436 SRC_PRIVATE_BASE, SRC_PRIVATE_LIMIT, SRC_POPS_EXITING_WAVE_ID,
437 SRC_VCCZ, SRC_EXECZ, SRC_SCC)> {
438 let AllocationPriority = 10;
441 def SReg_32_XEXEC_HI : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16, i1], 32,
442 (add SReg_32_XM0_XEXEC, EXEC_LO, M0_CLASS)> {
443 let AllocationPriority = 10;
446 def SReg_32_XM0 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16, i1], 32,
447 (add SReg_32_XM0_XEXEC, EXEC_LO, EXEC_HI)> {
448 let AllocationPriority = 10;
451 // Register class for all scalar registers (SGPRs + Special Registers)
452 def SReg_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16, i1], 32,
453 (add SReg_32_XM0, M0_CLASS, EXEC_LO, EXEC_HI, SReg_32_XEXEC_HI)> {
454 let AllocationPriority = 10;
457 def SRegOrLds_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16, i1], 32,
458 (add SReg_32_XM0, M0_CLASS, EXEC_LO, EXEC_HI, SReg_32_XEXEC_HI, LDS_DIRECT_CLASS)> {
459 let isAllocatable = 0;
462 def SGPR_64 : RegisterClass<"AMDGPU", [v2i32, i64, v2f32, f64, v4i16, v4f16], 32,
465 let AllocationPriority = 11;
468 // CCR (call clobbered registers) SGPR 64-bit registers
469 def CCR_SGPR_64 : RegisterClass<"AMDGPU", SGPR_64.RegTypes, 32,
470 (add (trunc SGPR_64, 16))> {
471 let CopyCost = SGPR_64.CopyCost;
472 let AllocationPriority = SGPR_64.AllocationPriority;
475 def TTMP_64 : RegisterClass<"AMDGPU", [v2i32, i64, f64, v4i16, v4f16], 32,
477 let isAllocatable = 0;
480 def SReg_64_XEXEC : RegisterClass<"AMDGPU", [v2i32, i64, v2f32, f64, i1, v4i16, v4f16], 32,
481 (add SGPR_64, VCC, FLAT_SCR, XNACK_MASK, TTMP_64, TBA, TMA)> {
483 let AllocationPriority = 13;
486 def SReg_64 : RegisterClass<"AMDGPU", [v2i32, i64, v2f32, f64, i1, v4i16, v4f16], 32,
487 (add SReg_64_XEXEC, EXEC)> {
489 let AllocationPriority = 13;
492 def SReg_1_XEXEC : RegisterClass<"AMDGPU", [i1], 32,
493 (add SReg_64_XEXEC, SReg_32_XM0_XEXEC)> {
495 let isAllocatable = 0;
498 def SReg_1 : RegisterClass<"AMDGPU", [i1], 32,
499 (add SReg_1_XEXEC, EXEC, EXEC_LO)> {
501 let isAllocatable = 0;
504 // Requires 2 s_mov_b64 to copy
505 let CopyCost = 2 in {
507 // There are no 3-component scalar instructions, but this is needed
508 // for symmetry with VGPRs.
509 def SGPR_96 : RegisterClass<"AMDGPU", [v3i32, v3f32], 32,
511 let AllocationPriority = 14;
514 def SReg_96 : RegisterClass<"AMDGPU", [v3i32, v3f32], 32,
516 let AllocationPriority = 14;
519 def SGPR_128 : RegisterClass<"AMDGPU", [v4i32, v4f32, v2i64], 32,
520 (add SGPR_128Regs)> {
521 let AllocationPriority = 15;
524 def TTMP_128 : RegisterClass<"AMDGPU", [v4i32, v4f32, v2i64], 32,
525 (add TTMP_128Regs)> {
526 let isAllocatable = 0;
529 def SReg_128 : RegisterClass<"AMDGPU", [v4i32, v4f32, v2i64, v2f64], 32,
530 (add SGPR_128, TTMP_128)> {
531 let AllocationPriority = 15;
534 } // End CopyCost = 2
536 // There are no 5-component scalar instructions, but this is needed
537 // for symmetry with VGPRs.
538 def SGPR_160 : RegisterClass<"AMDGPU", [v5i32, v5f32], 32,
539 (add SGPR_160Regs)> {
540 let AllocationPriority = 16;
543 def SReg_160 : RegisterClass<"AMDGPU", [v5i32, v5f32], 32,
545 let AllocationPriority = 16;
548 def SGPR_256 : RegisterClass<"AMDGPU", [v8i32, v8f32], 32, (add SGPR_256Regs)> {
549 let AllocationPriority = 17;
552 def TTMP_256 : RegisterClass<"AMDGPU", [v8i32, v8f32], 32, (add TTMP_256Regs)> {
553 let isAllocatable = 0;
556 def SReg_256 : RegisterClass<"AMDGPU", [v8i32, v8f32], 32,
557 (add SGPR_256, TTMP_256)> {
558 // Requires 4 s_mov_b64 to copy
560 let AllocationPriority = 17;
563 def SGPR_512 : RegisterClass<"AMDGPU", [v16i32, v16f32], 32,
564 (add SGPR_512Regs)> {
565 let AllocationPriority = 18;
568 def TTMP_512 : RegisterClass<"AMDGPU", [v16i32, v16f32], 32,
569 (add TTMP_512Regs)> {
570 let isAllocatable = 0;
573 def SReg_512 : RegisterClass<"AMDGPU", [v16i32, v16f32], 32,
574 (add SGPR_512, TTMP_512)> {
575 // Requires 8 s_mov_b64 to copy
577 let AllocationPriority = 18;
580 def VRegOrLds_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
581 (add VGPR_32, LDS_DIRECT_CLASS)> {
582 let isAllocatable = 0;
585 def SGPR_1024 : RegisterClass<"AMDGPU", [v32i32, v32f32], 32,
586 (add SGPR_1024Regs)> {
587 let AllocationPriority = 19;
590 def SReg_1024 : RegisterClass<"AMDGPU", [v32i32, v32f32], 32,
593 let AllocationPriority = 19;
596 // Register class for all vector registers (VGPRs + Interploation Registers)
597 def VReg_64 : RegisterClass<"AMDGPU", [i64, f64, v2i32, v2f32, v4f16, v4i16, p0, p1, p4], 32,
601 // Requires 2 v_mov_b32 to copy
603 let AllocationPriority = 2;
606 def VReg_96 : RegisterClass<"AMDGPU", [v3i32, v3f32], 32, (add VGPR_96)> {
609 // Requires 3 v_mov_b32 to copy
611 let AllocationPriority = 3;
614 def VReg_128 : RegisterClass<"AMDGPU", [v4i32, v4f32, v2i64, v2f64], 32,
618 // Requires 4 v_mov_b32 to copy
620 let AllocationPriority = 4;
623 def VReg_160 : RegisterClass<"AMDGPU", [v5i32, v5f32], 32,
627 // Requires 5 v_mov_b32 to copy
629 let AllocationPriority = 5;
632 def VReg_256 : RegisterClass<"AMDGPU", [v8i32, v8f32], 32,
636 let AllocationPriority = 6;
639 def VReg_512 : RegisterClass<"AMDGPU", [v16i32, v16f32], 32,
643 let AllocationPriority = 7;
646 def VReg_1024 : RegisterClass<"AMDGPU", [v32i32, v32f32], 32,
650 let AllocationPriority = 8;
653 def AReg_64 : RegisterClass<"AMDGPU", [i64, f64, v2i32, v2f32, v4f16, v4i16], 32,
658 let AllocationPriority = 2;
661 def AReg_128 : RegisterClass<"AMDGPU", [v4i32, v4f32, v2i64, v2f64], 32,
665 // Requires 4 v_accvgpr_write and 4 v_accvgpr_read to copy + burn 1 vgpr
667 let AllocationPriority = 4;
670 def AReg_512 : RegisterClass<"AMDGPU", [v16i32, v16f32], 32,
674 let AllocationPriority = 7;
677 def AReg_1024 : RegisterClass<"AMDGPU", [v32i32, v32f32], 32,
681 let AllocationPriority = 8;
684 def VReg_1 : RegisterClass<"AMDGPU", [i1], 32, (add VGPR_32)> {
688 def VS_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
689 (add VGPR_32, SReg_32, LDS_DIRECT_CLASS)> {
690 let isAllocatable = 0;
693 def VS_64 : RegisterClass<"AMDGPU", [i64, f64], 32, (add VReg_64, SReg_64)> {
694 let isAllocatable = 0;
697 def AV_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
698 (add AGPR_32, VGPR_32)> {
699 let isAllocatable = 0;
702 def AV_64 : RegisterClass<"AMDGPU", [i64, f64, v4f16], 32,
703 (add AReg_64, VReg_64)> {
704 let isAllocatable = 0;
707 //===----------------------------------------------------------------------===//
709 //===----------------------------------------------------------------------===//
711 class RegImmMatcher<string name> : AsmOperandClass {
713 let RenderMethod = "addRegOrImmOperands";
716 multiclass SIRegOperand32 <string rc, string MatchName, string opType,
717 string rc_suffix = "_32"> {
718 let OperandNamespace = "AMDGPU" in {
719 def _b16 : RegisterOperand<!cast<RegisterClass>(rc#rc_suffix)> {
720 let OperandType = opType#"_INT16";
721 let ParserMatchClass = RegImmMatcher<MatchName#"B16">;
722 let DecoderMethod = "decodeOperand_VSrc16";
725 def _f16 : RegisterOperand<!cast<RegisterClass>(rc#rc_suffix)> {
726 let OperandType = opType#"_FP16";
727 let ParserMatchClass = RegImmMatcher<MatchName#"F16">;
728 let DecoderMethod = "decodeOperand_" # rc # "_16";
731 def _b32 : RegisterOperand<!cast<RegisterClass>(rc#rc_suffix)> {
732 let OperandType = opType#"_INT32";
733 let ParserMatchClass = RegImmMatcher<MatchName#"B32">;
734 let DecoderMethod = "decodeOperand_" # rc # rc_suffix;
737 def _f32 : RegisterOperand<!cast<RegisterClass>(rc#rc_suffix)> {
738 let OperandType = opType#"_FP32";
739 let ParserMatchClass = RegImmMatcher<MatchName#"F32">;
740 let DecoderMethod = "decodeOperand_" # rc # rc_suffix;
743 def _v2b16 : RegisterOperand<!cast<RegisterClass>(rc#rc_suffix)> {
744 let OperandType = opType#"_V2INT16";
745 let ParserMatchClass = RegImmMatcher<MatchName#"V2B16">;
746 let DecoderMethod = "decodeOperand_VSrcV216";
749 def _v2f16 : RegisterOperand<!cast<RegisterClass>(rc#rc_suffix)> {
750 let OperandType = opType#"_V2FP16";
751 let ParserMatchClass = RegImmMatcher<MatchName#"V2F16">;
752 let DecoderMethod = "decodeOperand_VSrcV216";
757 multiclass SIRegOperand <string rc, string MatchName, string opType> :
758 SIRegOperand32<rc, MatchName, opType> {
759 let OperandNamespace = "AMDGPU" in {
760 def _b64 : RegisterOperand<!cast<RegisterClass>(rc#"_64")> {
761 let OperandType = opType#"_INT64";
762 let ParserMatchClass = RegImmMatcher<MatchName#"B64">;
765 def _f64 : RegisterOperand<!cast<RegisterClass>(rc#"_64")> {
766 let OperandType = opType#"_FP64";
767 let ParserMatchClass = RegImmMatcher<MatchName#"F64">;
772 // FIXME: 64-bit sources can sometimes use 32-bit constants.
773 multiclass RegImmOperand <string rc, string MatchName>
774 : SIRegOperand<rc, MatchName, "OPERAND_REG_IMM">;
776 multiclass RegInlineOperand <string rc, string MatchName>
777 : SIRegOperand<rc, MatchName, "OPERAND_REG_INLINE_C">;
779 multiclass RegInlineOperand32 <string rc, string MatchName,
780 string rc_suffix = "_32">
781 : SIRegOperand32<rc, MatchName, "OPERAND_REG_INLINE_C", rc_suffix>;
783 multiclass RegInlineOperandAC <string rc, string MatchName,
784 string rc_suffix = "_32">
785 : SIRegOperand32<rc, MatchName, "OPERAND_REG_INLINE_AC", rc_suffix>;
787 //===----------------------------------------------------------------------===//
788 // SSrc_* Operands with an SGPR or a 32-bit immediate
789 //===----------------------------------------------------------------------===//
791 defm SSrc : RegImmOperand<"SReg", "SSrc">;
793 def SSrcOrLds_b32 : RegisterOperand<SRegOrLds_32> {
794 let OperandNamespace = "AMDGPU";
795 let OperandType = "OPERAND_REG_IMM_INT32";
796 let ParserMatchClass = RegImmMatcher<"SSrcOrLdsB32">;
799 //===----------------------------------------------------------------------===//
800 // SCSrc_* Operands with an SGPR or a inline constant
801 //===----------------------------------------------------------------------===//
803 defm SCSrc : RegInlineOperand<"SReg", "SCSrc"> ;
805 //===----------------------------------------------------------------------===//
806 // VSrc_* Operands with an SGPR, VGPR or a 32-bit immediate
807 //===----------------------------------------------------------------------===//
809 defm VSrc : RegImmOperand<"VS", "VSrc">;
811 def VSrc_128 : RegisterOperand<VReg_128> {
812 let DecoderMethod = "DecodeVS_128RegisterClass";
815 //===----------------------------------------------------------------------===//
816 // VSrc_* Operands with an VGPR
817 //===----------------------------------------------------------------------===//
819 // This is for operands with the enum(9), VSrc encoding restriction,
820 // but only allows VGPRs.
821 def VRegSrc_32 : RegisterOperand<VGPR_32> {
822 //let ParserMatchClass = RegImmMatcher<"VRegSrc32">;
823 let DecoderMethod = "DecodeVS_32RegisterClass";
826 //===----------------------------------------------------------------------===//
827 // ASrc_* Operands with an AccVGPR
828 //===----------------------------------------------------------------------===//
830 def ARegSrc_32 : RegisterOperand<AGPR_32> {
831 let DecoderMethod = "DecodeAGPR_32RegisterClass";
832 let EncoderMethod = "getAVOperandEncoding";
835 //===----------------------------------------------------------------------===//
836 // VCSrc_* Operands with an SGPR, VGPR or an inline constant
837 //===----------------------------------------------------------------------===//
839 defm VCSrc : RegInlineOperand<"VS", "VCSrc">;
841 //===----------------------------------------------------------------------===//
842 // VISrc_* Operands with a VGPR or an inline constant
843 //===----------------------------------------------------------------------===//
845 defm VISrc : RegInlineOperand32<"VGPR", "VISrc">;
847 //===----------------------------------------------------------------------===//
848 // AVSrc_* Operands with an AGPR or VGPR
849 //===----------------------------------------------------------------------===//
851 def AVSrc_32 : RegisterOperand<AV_32> {
852 let DecoderMethod = "DecodeAV_32RegisterClass";
853 let EncoderMethod = "getAVOperandEncoding";
856 def AVSrc_64 : RegisterOperand<AV_64> {
857 let DecoderMethod = "DecodeAV_64RegisterClass";
858 let EncoderMethod = "getAVOperandEncoding";
861 //===----------------------------------------------------------------------===//
862 // ACSrc_* Operands with an AGPR or an inline constant
863 //===----------------------------------------------------------------------===//
865 defm AISrc : RegInlineOperandAC<"AGPR", "AISrc">;
866 defm AISrc_128 : RegInlineOperandAC<"AReg", "AISrc_128", "_128">;
867 defm AISrc_512 : RegInlineOperandAC<"AReg", "AISrc_512", "_512">;
868 defm AISrc_1024 : RegInlineOperandAC<"AReg", "AISrc_1024", "_1024">;