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 // VGPR 32-bit registers
354 // i16/f16 only on VI+
355 def VGPR_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
356 (add (sequence "VGPR%u", 0, 255))> {
357 let AllocationPriority = 1;
361 // VGPR 64-bit registers
362 def VGPR_64 : SIRegisterTuples<getSubRegs<2>.ret, VGPR_32, 255, 1, 2, "v">;
364 // VGPR 96-bit registers
365 def VGPR_96 : SIRegisterTuples<getSubRegs<3>.ret, VGPR_32, 255, 1, 3, "v">;
367 // VGPR 128-bit registers
368 def VGPR_128 : SIRegisterTuples<getSubRegs<4>.ret, VGPR_32, 255, 1, 4, "v">;
370 // VGPR 160-bit registers
371 def VGPR_160 : SIRegisterTuples<getSubRegs<5>.ret, VGPR_32, 255, 1, 5, "v">;
373 // VGPR 256-bit registers
374 def VGPR_256 : SIRegisterTuples<getSubRegs<8>.ret, VGPR_32, 255, 1, 8, "v">;
376 // VGPR 512-bit registers
377 def VGPR_512 : SIRegisterTuples<getSubRegs<16>.ret, VGPR_32, 255, 1, 16, "v">;
379 // VGPR 1024-bit registers
380 def VGPR_1024 : SIRegisterTuples<getSubRegs<32>.ret, VGPR_32, 255, 1, 32, "v">;
382 // AccVGPR 32-bit registers
383 def AGPR_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
384 (add (sequence "AGPR%u", 0, 255))> {
385 let AllocationPriority = 1;
389 // AGPR 64-bit registers
390 def AGPR_64 : SIRegisterTuples<getSubRegs<2>.ret, AGPR_32, 255, 1, 2, "a">;
392 // AGPR 128-bit registers
393 def AGPR_128 : SIRegisterTuples<getSubRegs<4>.ret, AGPR_32, 255, 1, 4, "a">;
395 // AGPR 512-bit registers
396 def AGPR_512 : SIRegisterTuples<getSubRegs<16>.ret, AGPR_32, 255, 1, 16, "a">;
398 // AGPR 1024-bit registers
399 def AGPR_1024 : SIRegisterTuples<getSubRegs<32>.ret, AGPR_32, 255, 1, 32, "a">;
401 //===----------------------------------------------------------------------===//
402 // Register classes used as source and destination
403 //===----------------------------------------------------------------------===//
405 def Pseudo_SReg_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
406 (add FP_REG, SP_REG, SCRATCH_WAVE_OFFSET_REG)> {
407 let isAllocatable = 0;
411 def Pseudo_SReg_128 : RegisterClass<"AMDGPU", [v4i32, v2i64, v2f64], 32,
412 (add PRIVATE_RSRC_REG)> {
413 let isAllocatable = 0;
417 def LDS_DIRECT_CLASS : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
419 let isAllocatable = 0;
423 // Subset of SReg_32 without M0 for SMRD instructions and alike.
424 // See comments in SIInstructions.td for more info.
425 def SReg_32_XM0_XEXEC : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16, i1], 32,
426 (add SGPR_32, VCC_LO, VCC_HI, FLAT_SCR_LO, FLAT_SCR_HI, XNACK_MASK_LO, XNACK_MASK_HI,
427 SGPR_NULL, TTMP_32, TMA_LO, TMA_HI, TBA_LO, TBA_HI, SRC_SHARED_BASE, SRC_SHARED_LIMIT,
428 SRC_PRIVATE_BASE, SRC_PRIVATE_LIMIT, SRC_POPS_EXITING_WAVE_ID,
429 SRC_VCCZ, SRC_EXECZ, SRC_SCC)> {
430 let AllocationPriority = 10;
433 def SReg_32_XEXEC_HI : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16, i1], 32,
434 (add SReg_32_XM0_XEXEC, EXEC_LO, M0_CLASS)> {
435 let AllocationPriority = 10;
438 def SReg_32_XM0 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16, i1], 32,
439 (add SReg_32_XM0_XEXEC, EXEC_LO, EXEC_HI)> {
440 let AllocationPriority = 10;
443 // Register class for all scalar registers (SGPRs + Special Registers)
444 def SReg_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16, i1], 32,
445 (add SReg_32_XM0, M0_CLASS, EXEC_LO, EXEC_HI, SReg_32_XEXEC_HI)> {
446 let AllocationPriority = 10;
449 def SRegOrLds_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16, i1], 32,
450 (add SReg_32_XM0, M0_CLASS, EXEC_LO, EXEC_HI, SReg_32_XEXEC_HI, LDS_DIRECT_CLASS)> {
451 let isAllocatable = 0;
454 def SGPR_64 : RegisterClass<"AMDGPU", [v2i32, i64, v2f32, f64, v4i16, v4f16], 32,
457 let AllocationPriority = 11;
460 // CCR (call clobbered registers) SGPR 64-bit registers
461 def CCR_SGPR_64 : RegisterClass<"AMDGPU", SGPR_64.RegTypes, 32,
462 (add (trunc SGPR_64, 16))> {
463 let CopyCost = SGPR_64.CopyCost;
464 let AllocationPriority = SGPR_64.AllocationPriority;
467 def TTMP_64 : RegisterClass<"AMDGPU", [v2i32, i64, f64, v4i16, v4f16], 32,
469 let isAllocatable = 0;
472 def SReg_64_XEXEC : RegisterClass<"AMDGPU", [v2i32, i64, v2f32, f64, i1, v4i16, v4f16], 32,
473 (add SGPR_64, VCC, FLAT_SCR, XNACK_MASK, TTMP_64, TBA, TMA)> {
475 let AllocationPriority = 13;
478 def SReg_64 : RegisterClass<"AMDGPU", [v2i32, i64, v2f32, f64, i1, v4i16, v4f16], 32,
479 (add SReg_64_XEXEC, EXEC)> {
481 let AllocationPriority = 13;
484 def SReg_1_XEXEC : RegisterClass<"AMDGPU", [i1], 32,
485 (add SReg_64_XEXEC, SReg_32_XM0_XEXEC)> {
487 let isAllocatable = 0;
490 def SReg_1 : RegisterClass<"AMDGPU", [i1], 32,
491 (add SReg_1_XEXEC, EXEC, EXEC_LO)> {
493 let isAllocatable = 0;
496 // Requires 2 s_mov_b64 to copy
497 let CopyCost = 2 in {
499 // There are no 3-component scalar instructions, but this is needed
500 // for symmetry with VGPRs.
501 def SGPR_96 : RegisterClass<"AMDGPU", [v3i32, v3f32], 32,
503 let AllocationPriority = 14;
506 def SReg_96 : RegisterClass<"AMDGPU", [v3i32, v3f32], 32,
508 let AllocationPriority = 14;
511 def SGPR_128 : RegisterClass<"AMDGPU", [v4i32, v4f32, v2i64], 32,
512 (add SGPR_128Regs)> {
513 let AllocationPriority = 15;
516 def TTMP_128 : RegisterClass<"AMDGPU", [v4i32, v4f32, v2i64], 32,
517 (add TTMP_128Regs)> {
518 let isAllocatable = 0;
521 def SReg_128 : RegisterClass<"AMDGPU", [v4i32, v4f32, v2i64, v2f64], 32,
522 (add SGPR_128, TTMP_128)> {
523 let AllocationPriority = 15;
526 } // End CopyCost = 2
528 // There are no 5-component scalar instructions, but this is needed
529 // for symmetry with VGPRs.
530 def SGPR_160 : RegisterClass<"AMDGPU", [v5i32, v5f32], 32,
531 (add SGPR_160Regs)> {
532 let AllocationPriority = 16;
535 def SReg_160 : RegisterClass<"AMDGPU", [v5i32, v5f32], 32,
537 let AllocationPriority = 16;
540 def SGPR_256 : RegisterClass<"AMDGPU", [v8i32, v8f32], 32, (add SGPR_256Regs)> {
541 let AllocationPriority = 17;
544 def TTMP_256 : RegisterClass<"AMDGPU", [v8i32, v8f32], 32, (add TTMP_256Regs)> {
545 let isAllocatable = 0;
548 def SReg_256 : RegisterClass<"AMDGPU", [v8i32, v8f32], 32,
549 (add SGPR_256, TTMP_256)> {
550 // Requires 4 s_mov_b64 to copy
552 let AllocationPriority = 17;
555 def SGPR_512 : RegisterClass<"AMDGPU", [v16i32, v16f32], 32,
556 (add SGPR_512Regs)> {
557 let AllocationPriority = 18;
560 def TTMP_512 : RegisterClass<"AMDGPU", [v16i32, v16f32], 32,
561 (add TTMP_512Regs)> {
562 let isAllocatable = 0;
565 def SReg_512 : RegisterClass<"AMDGPU", [v16i32, v16f32], 32,
566 (add SGPR_512, TTMP_512)> {
567 // Requires 8 s_mov_b64 to copy
569 let AllocationPriority = 18;
572 def VRegOrLds_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
573 (add VGPR_32, LDS_DIRECT_CLASS)> {
574 let isAllocatable = 0;
577 def SGPR_1024 : RegisterClass<"AMDGPU", [v32i32, v32f32], 32,
578 (add SGPR_1024Regs)> {
579 let AllocationPriority = 19;
582 def SReg_1024 : RegisterClass<"AMDGPU", [v32i32, v32f32], 32,
585 let AllocationPriority = 19;
588 // Register class for all vector registers (VGPRs + Interploation Registers)
589 def VReg_64 : RegisterClass<"AMDGPU", [i64, f64, v2i32, v2f32, v4f16, v4i16], 32,
593 // Requires 2 v_mov_b32 to copy
595 let AllocationPriority = 2;
598 def VReg_96 : RegisterClass<"AMDGPU", [v3i32, v3f32], 32, (add VGPR_96)> {
601 // Requires 3 v_mov_b32 to copy
603 let AllocationPriority = 3;
606 def VReg_128 : RegisterClass<"AMDGPU", [v4i32, v4f32, v2i64, v2f64], 32,
610 // Requires 4 v_mov_b32 to copy
612 let AllocationPriority = 4;
615 def VReg_160 : RegisterClass<"AMDGPU", [v5i32, v5f32], 32,
619 // Requires 5 v_mov_b32 to copy
621 let AllocationPriority = 5;
624 def VReg_256 : RegisterClass<"AMDGPU", [v8i32, v8f32], 32,
628 let AllocationPriority = 6;
631 def VReg_512 : RegisterClass<"AMDGPU", [v16i32, v16f32], 32,
635 let AllocationPriority = 7;
638 def VReg_1024 : RegisterClass<"AMDGPU", [v32i32, v32f32], 32,
642 let AllocationPriority = 8;
645 def AReg_64 : RegisterClass<"AMDGPU", [i64, f64, v2i32, v2f32, v4f16, v4i16], 32,
650 let AllocationPriority = 2;
653 def AReg_128 : RegisterClass<"AMDGPU", [v4i32, v4f32, v2i64, v2f64], 32,
657 // Requires 4 v_accvgpr_write and 4 v_accvgpr_read to copy + burn 1 vgpr
659 let AllocationPriority = 4;
662 def AReg_512 : RegisterClass<"AMDGPU", [v16i32, v16f32], 32,
666 let AllocationPriority = 7;
669 def AReg_1024 : RegisterClass<"AMDGPU", [v32i32, v32f32], 32,
673 let AllocationPriority = 8;
676 def VReg_1 : RegisterClass<"AMDGPU", [i1], 32, (add VGPR_32)> {
680 def VS_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
681 (add VGPR_32, SReg_32, LDS_DIRECT_CLASS)> {
682 let isAllocatable = 0;
685 def VS_64 : RegisterClass<"AMDGPU", [i64, f64], 32, (add VReg_64, SReg_64)> {
686 let isAllocatable = 0;
689 def AV_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
690 (add AGPR_32, VGPR_32)> {
691 let isAllocatable = 0;
694 def AV_64 : RegisterClass<"AMDGPU", [i64, f64, v4f16], 32,
695 (add AReg_64, VReg_64)> {
696 let isAllocatable = 0;
699 //===----------------------------------------------------------------------===//
701 //===----------------------------------------------------------------------===//
703 class RegImmMatcher<string name> : AsmOperandClass {
705 let RenderMethod = "addRegOrImmOperands";
708 multiclass SIRegOperand32 <string rc, string MatchName, string opType,
709 string rc_suffix = "_32"> {
710 let OperandNamespace = "AMDGPU" in {
711 def _b16 : RegisterOperand<!cast<RegisterClass>(rc#rc_suffix)> {
712 let OperandType = opType#"_INT16";
713 let ParserMatchClass = RegImmMatcher<MatchName#"B16">;
714 let DecoderMethod = "decodeOperand_VSrc16";
717 def _f16 : RegisterOperand<!cast<RegisterClass>(rc#rc_suffix)> {
718 let OperandType = opType#"_FP16";
719 let ParserMatchClass = RegImmMatcher<MatchName#"F16">;
720 let DecoderMethod = "decodeOperand_" # rc # "_16";
723 def _b32 : RegisterOperand<!cast<RegisterClass>(rc#rc_suffix)> {
724 let OperandType = opType#"_INT32";
725 let ParserMatchClass = RegImmMatcher<MatchName#"B32">;
726 let DecoderMethod = "decodeOperand_" # rc # rc_suffix;
729 def _f32 : RegisterOperand<!cast<RegisterClass>(rc#rc_suffix)> {
730 let OperandType = opType#"_FP32";
731 let ParserMatchClass = RegImmMatcher<MatchName#"F32">;
732 let DecoderMethod = "decodeOperand_" # rc # rc_suffix;
735 def _v2b16 : RegisterOperand<!cast<RegisterClass>(rc#rc_suffix)> {
736 let OperandType = opType#"_V2INT16";
737 let ParserMatchClass = RegImmMatcher<MatchName#"V2B16">;
738 let DecoderMethod = "decodeOperand_VSrcV216";
741 def _v2f16 : RegisterOperand<!cast<RegisterClass>(rc#rc_suffix)> {
742 let OperandType = opType#"_V2FP16";
743 let ParserMatchClass = RegImmMatcher<MatchName#"V2F16">;
744 let DecoderMethod = "decodeOperand_VSrcV216";
749 multiclass SIRegOperand <string rc, string MatchName, string opType> :
750 SIRegOperand32<rc, MatchName, opType> {
751 let OperandNamespace = "AMDGPU" in {
752 def _b64 : RegisterOperand<!cast<RegisterClass>(rc#"_64")> {
753 let OperandType = opType#"_INT64";
754 let ParserMatchClass = RegImmMatcher<MatchName#"B64">;
757 def _f64 : RegisterOperand<!cast<RegisterClass>(rc#"_64")> {
758 let OperandType = opType#"_FP64";
759 let ParserMatchClass = RegImmMatcher<MatchName#"F64">;
764 // FIXME: 64-bit sources can sometimes use 32-bit constants.
765 multiclass RegImmOperand <string rc, string MatchName>
766 : SIRegOperand<rc, MatchName, "OPERAND_REG_IMM">;
768 multiclass RegInlineOperand <string rc, string MatchName>
769 : SIRegOperand<rc, MatchName, "OPERAND_REG_INLINE_C">;
771 multiclass RegInlineOperand32 <string rc, string MatchName,
772 string rc_suffix = "_32">
773 : SIRegOperand32<rc, MatchName, "OPERAND_REG_INLINE_C", rc_suffix>;
775 multiclass RegInlineOperandAC <string rc, string MatchName,
776 string rc_suffix = "_32">
777 : SIRegOperand32<rc, MatchName, "OPERAND_REG_INLINE_AC", rc_suffix>;
779 //===----------------------------------------------------------------------===//
780 // SSrc_* Operands with an SGPR or a 32-bit immediate
781 //===----------------------------------------------------------------------===//
783 defm SSrc : RegImmOperand<"SReg", "SSrc">;
785 def SSrcOrLds_b32 : RegisterOperand<SRegOrLds_32> {
786 let OperandNamespace = "AMDGPU";
787 let OperandType = "OPERAND_REG_IMM_INT32";
788 let ParserMatchClass = RegImmMatcher<"SSrcOrLdsB32">;
791 //===----------------------------------------------------------------------===//
792 // SCSrc_* Operands with an SGPR or a inline constant
793 //===----------------------------------------------------------------------===//
795 defm SCSrc : RegInlineOperand<"SReg", "SCSrc"> ;
797 //===----------------------------------------------------------------------===//
798 // VSrc_* Operands with an SGPR, VGPR or a 32-bit immediate
799 //===----------------------------------------------------------------------===//
801 defm VSrc : RegImmOperand<"VS", "VSrc">;
803 def VSrc_128 : RegisterOperand<VReg_128> {
804 let DecoderMethod = "DecodeVS_128RegisterClass";
807 //===----------------------------------------------------------------------===//
808 // VSrc_* Operands with an VGPR
809 //===----------------------------------------------------------------------===//
811 // This is for operands with the enum(9), VSrc encoding restriction,
812 // but only allows VGPRs.
813 def VRegSrc_32 : RegisterOperand<VGPR_32> {
814 //let ParserMatchClass = RegImmMatcher<"VRegSrc32">;
815 let DecoderMethod = "DecodeVS_32RegisterClass";
818 //===----------------------------------------------------------------------===//
819 // ASrc_* Operands with an AccVGPR
820 //===----------------------------------------------------------------------===//
822 def ARegSrc_32 : RegisterOperand<AGPR_32> {
823 let DecoderMethod = "DecodeAGPR_32RegisterClass";
824 let EncoderMethod = "getAVOperandEncoding";
827 //===----------------------------------------------------------------------===//
828 // VCSrc_* Operands with an SGPR, VGPR or an inline constant
829 //===----------------------------------------------------------------------===//
831 defm VCSrc : RegInlineOperand<"VS", "VCSrc">;
833 //===----------------------------------------------------------------------===//
834 // VISrc_* Operands with a VGPR or an inline constant
835 //===----------------------------------------------------------------------===//
837 defm VISrc : RegInlineOperand32<"VGPR", "VISrc">;
839 //===----------------------------------------------------------------------===//
840 // AVSrc_* Operands with an AGPR or VGPR
841 //===----------------------------------------------------------------------===//
843 def AVSrc_32 : RegisterOperand<AV_32> {
844 let DecoderMethod = "DecodeAV_32RegisterClass";
845 let EncoderMethod = "getAVOperandEncoding";
848 def AVSrc_64 : RegisterOperand<AV_64> {
849 let DecoderMethod = "DecodeAV_64RegisterClass";
850 let EncoderMethod = "getAVOperandEncoding";
853 //===----------------------------------------------------------------------===//
854 // ACSrc_* Operands with an AGPR or an inline constant
855 //===----------------------------------------------------------------------===//
857 defm AISrc : RegInlineOperandAC<"AGPR", "AISrc">;
858 defm AISrc_128 : RegInlineOperandAC<"AReg", "AISrc_128", "_128">;
859 defm AISrc_512 : RegInlineOperandAC<"AReg", "AISrc_512", "_512">;
860 defm AISrc_1024 : RegInlineOperandAC<"AReg", "AISrc_1024", "_1024">;