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> ret8 = [sub0, sub1, sub2, sub3, sub4, sub5, sub6, sub7];
18 list<SubRegIndex> ret16 = [sub0, sub1, sub2, sub3,
19 sub4, sub5, sub6, sub7,
20 sub8, sub9, sub10, sub11,
21 sub12, sub13, sub14, sub15];
23 list<SubRegIndex> ret = !if(!eq(size, 2), ret2,
24 !if(!eq(size, 3), ret3,
25 !if(!eq(size, 4), ret4,
26 !if(!eq(size, 8), ret8, ret16))));
29 //===----------------------------------------------------------------------===//
30 // Declarations that describe the SI registers
31 //===----------------------------------------------------------------------===//
32 class SIReg <string n, bits<16> regIdx = 0> : Register<n>,
33 DwarfRegNum<[!cast<int>(HWEncoding)]> {
34 let Namespace = "AMDGPU";
36 // This is the not yet the complete register encoding. An additional
37 // bit is set for VGPRs.
38 let HWEncoding = regIdx;
42 def VCC_LO : SIReg<"vcc_lo", 106>;
43 def VCC_HI : SIReg<"vcc_hi", 107>;
45 // Pseudo-registers: Used as placeholders during isel and immediately
46 // replaced, never seeing the verifier.
47 def PRIVATE_RSRC_REG : SIReg<"", 0>;
48 def FP_REG : SIReg<"", 0>;
49 def SP_REG : SIReg<"", 0>;
50 def SCRATCH_WAVE_OFFSET_REG : SIReg<"", 0>;
52 // VCC for 64-bit instructions
53 def VCC : RegisterWithSubRegs<"vcc", [VCC_LO, VCC_HI]>,
54 DwarfRegAlias<VCC_LO> {
55 let Namespace = "AMDGPU";
56 let SubRegIndices = [sub0, sub1];
60 def EXEC_LO : SIReg<"exec_lo", 126>;
61 def EXEC_HI : SIReg<"exec_hi", 127>;
63 def EXEC : RegisterWithSubRegs<"EXEC", [EXEC_LO, EXEC_HI]>,
64 DwarfRegAlias<EXEC_LO> {
65 let Namespace = "AMDGPU";
66 let SubRegIndices = [sub0, sub1];
70 def SCC : SIReg<"scc", 253>;
71 def M0 : SIReg <"m0", 124>;
73 def SRC_SHARED_BASE : SIReg<"src_shared_base", 235>;
74 def SRC_SHARED_LIMIT : SIReg<"src_shared_limit", 236>;
75 def SRC_PRIVATE_BASE : SIReg<"src_private_base", 237>;
76 def SRC_PRIVATE_LIMIT : SIReg<"src_private_limit", 238>;
78 def LDS_DIRECT : SIReg <"lds_direct", 254>;
80 def XNACK_MASK_LO : SIReg<"xnack_mask_lo", 104>;
81 def XNACK_MASK_HI : SIReg<"xnack_mask_hi", 105>;
83 def XNACK_MASK : RegisterWithSubRegs<"xnack_mask", [XNACK_MASK_LO, XNACK_MASK_HI]>,
84 DwarfRegAlias<XNACK_MASK_LO> {
85 let Namespace = "AMDGPU";
86 let SubRegIndices = [sub0, sub1];
90 // Trap handler registers
91 def TBA_LO : SIReg<"tba_lo", 108>;
92 def TBA_HI : SIReg<"tba_hi", 109>;
94 def TBA : RegisterWithSubRegs<"tba", [TBA_LO, TBA_HI]>,
95 DwarfRegAlias<TBA_LO> {
96 let Namespace = "AMDGPU";
97 let SubRegIndices = [sub0, sub1];
101 def TMA_LO : SIReg<"tma_lo", 110>;
102 def TMA_HI : SIReg<"tma_hi", 111>;
104 def TMA : RegisterWithSubRegs<"tma", [TMA_LO, TMA_HI]>,
105 DwarfRegAlias<TMA_LO> {
106 let Namespace = "AMDGPU";
107 let SubRegIndices = [sub0, sub1];
108 let HWEncoding = 110;
111 foreach Index = 0-15 in {
112 def TTMP#Index#_vi : SIReg<"ttmp"#Index, !add(112, Index)>;
113 def TTMP#Index#_gfx9 : SIReg<"ttmp"#Index, !add(108, Index)>;
114 def TTMP#Index : SIReg<"", 0>;
117 multiclass FLAT_SCR_LOHI_m <string n, bits<16> ci_e, bits<16> vi_e> {
118 def _ci : SIReg<n, ci_e>;
119 def _vi : SIReg<n, vi_e>;
120 def "" : SIReg<"", 0>;
123 class FlatReg <Register lo, Register hi, bits<16> encoding> :
124 RegisterWithSubRegs<"flat_scratch", [lo, hi]>,
126 let Namespace = "AMDGPU";
127 let SubRegIndices = [sub0, sub1];
128 let HWEncoding = encoding;
131 defm FLAT_SCR_LO : FLAT_SCR_LOHI_m<"flat_scratch_lo", 104, 102>; // Offset in units of 256-bytes.
132 defm FLAT_SCR_HI : FLAT_SCR_LOHI_m<"flat_scratch_hi", 105, 103>; // Size is the per-thread scratch size, in bytes.
134 def FLAT_SCR_ci : FlatReg<FLAT_SCR_LO_ci, FLAT_SCR_HI_ci, 104>;
135 def FLAT_SCR_vi : FlatReg<FLAT_SCR_LO_vi, FLAT_SCR_HI_vi, 102>;
136 def FLAT_SCR : FlatReg<FLAT_SCR_LO, FLAT_SCR_HI, 0>;
139 foreach Index = 0-103 in {
140 def SGPR#Index : SIReg <"SGPR"#Index, Index>;
144 foreach Index = 0-255 in {
145 def VGPR#Index : SIReg <"VGPR"#Index, Index> {
146 let HWEncoding{8} = 1;
150 //===----------------------------------------------------------------------===//
151 // Groupings using register classes and tuples
152 //===----------------------------------------------------------------------===//
154 def SCC_CLASS : RegisterClass<"AMDGPU", [i1], 1, (add SCC)> {
156 let isAllocatable = 0;
159 def M0_CLASS : RegisterClass<"AMDGPU", [i32], 32, (add M0)> {
161 let isAllocatable = 0;
164 // TODO: Do we need to set DwarfRegAlias on register tuples?
166 // SGPR 32-bit registers
167 def SGPR_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
168 (add (sequence "SGPR%u", 0, 103))> {
169 // Give all SGPR classes higher priority than VGPR classes, because
170 // we want to spill SGPRs to VGPRs.
171 let AllocationPriority = 7;
174 // SGPR 64-bit registers
175 def SGPR_64Regs : RegisterTuples<getSubRegs<2>.ret,
176 [(add (decimate SGPR_32, 2)),
177 (add (decimate (shl SGPR_32, 1), 2))]>;
179 // SGPR 128-bit registers
180 def SGPR_128Regs : RegisterTuples<getSubRegs<4>.ret,
181 [(add (decimate SGPR_32, 4)),
182 (add (decimate (shl SGPR_32, 1), 4)),
183 (add (decimate (shl SGPR_32, 2), 4)),
184 (add (decimate (shl SGPR_32, 3), 4))]>;
186 // SGPR 256-bit registers
187 def SGPR_256Regs : RegisterTuples<getSubRegs<8>.ret,
188 [(add (decimate SGPR_32, 4)),
189 (add (decimate (shl SGPR_32, 1), 4)),
190 (add (decimate (shl SGPR_32, 2), 4)),
191 (add (decimate (shl SGPR_32, 3), 4)),
192 (add (decimate (shl SGPR_32, 4), 4)),
193 (add (decimate (shl SGPR_32, 5), 4)),
194 (add (decimate (shl SGPR_32, 6), 4)),
195 (add (decimate (shl SGPR_32, 7), 4))]>;
197 // SGPR 512-bit registers
198 def SGPR_512Regs : RegisterTuples<getSubRegs<16>.ret,
199 [(add (decimate SGPR_32, 4)),
200 (add (decimate (shl SGPR_32, 1), 4)),
201 (add (decimate (shl SGPR_32, 2), 4)),
202 (add (decimate (shl SGPR_32, 3), 4)),
203 (add (decimate (shl SGPR_32, 4), 4)),
204 (add (decimate (shl SGPR_32, 5), 4)),
205 (add (decimate (shl SGPR_32, 6), 4)),
206 (add (decimate (shl SGPR_32, 7), 4)),
207 (add (decimate (shl SGPR_32, 8), 4)),
208 (add (decimate (shl SGPR_32, 9), 4)),
209 (add (decimate (shl SGPR_32, 10), 4)),
210 (add (decimate (shl SGPR_32, 11), 4)),
211 (add (decimate (shl SGPR_32, 12), 4)),
212 (add (decimate (shl SGPR_32, 13), 4)),
213 (add (decimate (shl SGPR_32, 14), 4)),
214 (add (decimate (shl SGPR_32, 15), 4))]>;
216 // Trap handler TMP 32-bit registers
217 def TTMP_32 : RegisterClass<"AMDGPU", [i32, f32, v2i16, v2f16], 32,
218 (add (sequence "TTMP%u", 0, 15))> {
219 let isAllocatable = 0;
222 // Trap handler TMP 64-bit registers
223 def TTMP_64Regs : RegisterTuples<getSubRegs<2>.ret,
224 [(add (decimate TTMP_32, 2)),
225 (add (decimate (shl TTMP_32, 1), 2))]>;
227 // Trap handler TMP 128-bit registers
228 def TTMP_128Regs : RegisterTuples<getSubRegs<4>.ret,
229 [(add (decimate TTMP_32, 4)),
230 (add (decimate (shl TTMP_32, 1), 4)),
231 (add (decimate (shl TTMP_32, 2), 4)),
232 (add (decimate (shl TTMP_32, 3), 4))]>;
234 def TTMP_256Regs : RegisterTuples<getSubRegs<8>.ret,
235 [(add (decimate TTMP_32, 4)),
236 (add (decimate (shl TTMP_32, 1), 4)),
237 (add (decimate (shl TTMP_32, 2), 4)),
238 (add (decimate (shl TTMP_32, 3), 4)),
239 (add (decimate (shl TTMP_32, 4), 4)),
240 (add (decimate (shl TTMP_32, 5), 4)),
241 (add (decimate (shl TTMP_32, 6), 4)),
242 (add (decimate (shl TTMP_32, 7), 4))]>;
244 def TTMP_512Regs : RegisterTuples<getSubRegs<16>.ret,
245 [(add (decimate TTMP_32, 4)),
246 (add (decimate (shl TTMP_32, 1), 4)),
247 (add (decimate (shl TTMP_32, 2), 4)),
248 (add (decimate (shl TTMP_32, 3), 4)),
249 (add (decimate (shl TTMP_32, 4), 4)),
250 (add (decimate (shl TTMP_32, 5), 4)),
251 (add (decimate (shl TTMP_32, 6), 4)),
252 (add (decimate (shl TTMP_32, 7), 4)),
253 (add (decimate (shl TTMP_32, 8), 4)),
254 (add (decimate (shl TTMP_32, 9), 4)),
255 (add (decimate (shl TTMP_32, 10), 4)),
256 (add (decimate (shl TTMP_32, 11), 4)),
257 (add (decimate (shl TTMP_32, 12), 4)),
258 (add (decimate (shl TTMP_32, 13), 4)),
259 (add (decimate (shl TTMP_32, 14), 4)),
260 (add (decimate (shl TTMP_32, 15), 4))]>;
262 class TmpRegTuplesBase<int index, int size,
263 list<Register> subRegs,
264 list<SubRegIndex> indices = getSubRegs<size>.ret,
265 int index1 = !add(index, !add(size, -1)),
266 string name = "ttmp["#index#":"#index1#"]"> :
267 RegisterWithSubRegs<name, subRegs> {
268 let HWEncoding = subRegs[0].HWEncoding;
269 let SubRegIndices = indices;
272 class TmpRegTuples<string tgt,
275 int index1 = !add(index0, 1),
276 int index2 = !add(index0, !if(!eq(size, 2), 1, 2)),
277 int index3 = !add(index0, !if(!eq(size, 2), 1, 3)),
278 int index4 = !add(index0, !if(!eq(size, 8), 4, 1)),
279 int index5 = !add(index0, !if(!eq(size, 8), 5, 1)),
280 int index6 = !add(index0, !if(!eq(size, 8), 6, 1)),
281 int index7 = !add(index0, !if(!eq(size, 8), 7, 1)),
282 Register r0 = !cast<Register>("TTMP"#index0#tgt),
283 Register r1 = !cast<Register>("TTMP"#index1#tgt),
284 Register r2 = !cast<Register>("TTMP"#index2#tgt),
285 Register r3 = !cast<Register>("TTMP"#index3#tgt),
286 Register r4 = !cast<Register>("TTMP"#index4#tgt),
287 Register r5 = !cast<Register>("TTMP"#index5#tgt),
288 Register r6 = !cast<Register>("TTMP"#index6#tgt),
289 Register r7 = !cast<Register>("TTMP"#index7#tgt)> :
290 TmpRegTuplesBase<index0, size,
291 !if(!eq(size, 2), [r0, r1],
292 !if(!eq(size, 4), [r0, r1, r2, r3],
293 [r0, r1, r2, r3, r4, r5, r6, r7])),
294 getSubRegs<size>.ret>;
296 foreach Index = {0, 2, 4, 6, 8, 10, 12, 14} in {
297 def TTMP#Index#_TTMP#!add(Index,1)#_vi : TmpRegTuples<"_vi", 2, Index>;
298 def TTMP#Index#_TTMP#!add(Index,1)#_gfx9 : TmpRegTuples<"_gfx9", 2, Index>;
301 foreach Index = {0, 4, 8, 12} in {
302 def TTMP#Index#_TTMP#!add(Index,1)#
304 _TTMP#!add(Index,3)#_vi : TmpRegTuples<"_vi", 4, Index>;
305 def TTMP#Index#_TTMP#!add(Index,1)#
307 _TTMP#!add(Index,3)#_gfx9 : TmpRegTuples<"_gfx9", 4, Index>;
310 foreach Index = {0, 4, 8} in {
311 def TTMP#Index#_TTMP#!add(Index,1)#
317 _TTMP#!add(Index,7)#_vi : TmpRegTuples<"_vi", 8, Index>;
318 def TTMP#Index#_TTMP#!add(Index,1)#
324 _TTMP#!add(Index,7)#_gfx9 : TmpRegTuples<"_gfx9", 8, Index>;
327 def TTMP0_TTMP1_TTMP2_TTMP3_TTMP4_TTMP5_TTMP6_TTMP7_TTMP8_TTMP9_TTMP10_TTMP11_TTMP12_TTMP13_TTMP14_TTMP15_vi :
328 TmpRegTuplesBase<0, 16,
329 [TTMP0_vi, TTMP1_vi, TTMP2_vi, TTMP3_vi,
330 TTMP4_vi, TTMP5_vi, TTMP6_vi, TTMP7_vi,
331 TTMP8_vi, TTMP9_vi, TTMP10_vi, TTMP11_vi,
332 TTMP12_vi, TTMP13_vi, TTMP14_vi, TTMP15_vi]>;
334 def TTMP0_TTMP1_TTMP2_TTMP3_TTMP4_TTMP5_TTMP6_TTMP7_TTMP8_TTMP9_TTMP10_TTMP11_TTMP12_TTMP13_TTMP14_TTMP15_gfx9 :
335 TmpRegTuplesBase<0, 16,
336 [TTMP0_gfx9, TTMP1_gfx9, TTMP2_gfx9, TTMP3_gfx9,
337 TTMP4_gfx9, TTMP5_gfx9, TTMP6_gfx9, TTMP7_gfx9,
338 TTMP8_gfx9, TTMP9_gfx9, TTMP10_gfx9, TTMP11_gfx9,
339 TTMP12_gfx9, TTMP13_gfx9, TTMP14_gfx9, TTMP15_gfx9]>;
342 // VGPR 32-bit registers
343 // i16/f16 only on VI+
344 def VGPR_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
345 (add (sequence "VGPR%u", 0, 255))> {
346 let AllocationPriority = 1;
350 // VGPR 64-bit registers
351 def VGPR_64 : RegisterTuples<getSubRegs<2>.ret,
352 [(add (trunc VGPR_32, 255)),
353 (add (shl VGPR_32, 1))]>;
355 // VGPR 96-bit registers
356 def VGPR_96 : RegisterTuples<getSubRegs<3>.ret,
357 [(add (trunc VGPR_32, 254)),
358 (add (shl VGPR_32, 1)),
359 (add (shl VGPR_32, 2))]>;
361 // VGPR 128-bit registers
362 def VGPR_128 : RegisterTuples<getSubRegs<4>.ret,
363 [(add (trunc VGPR_32, 253)),
364 (add (shl VGPR_32, 1)),
365 (add (shl VGPR_32, 2)),
366 (add (shl VGPR_32, 3))]>;
368 // VGPR 256-bit registers
369 def VGPR_256 : RegisterTuples<getSubRegs<8>.ret,
370 [(add (trunc VGPR_32, 249)),
371 (add (shl VGPR_32, 1)),
372 (add (shl VGPR_32, 2)),
373 (add (shl VGPR_32, 3)),
374 (add (shl VGPR_32, 4)),
375 (add (shl VGPR_32, 5)),
376 (add (shl VGPR_32, 6)),
377 (add (shl VGPR_32, 7))]>;
379 // VGPR 512-bit registers
380 def VGPR_512 : RegisterTuples<getSubRegs<16>.ret,
381 [(add (trunc VGPR_32, 241)),
382 (add (shl VGPR_32, 1)),
383 (add (shl VGPR_32, 2)),
384 (add (shl VGPR_32, 3)),
385 (add (shl VGPR_32, 4)),
386 (add (shl VGPR_32, 5)),
387 (add (shl VGPR_32, 6)),
388 (add (shl VGPR_32, 7)),
389 (add (shl VGPR_32, 8)),
390 (add (shl VGPR_32, 9)),
391 (add (shl VGPR_32, 10)),
392 (add (shl VGPR_32, 11)),
393 (add (shl VGPR_32, 12)),
394 (add (shl VGPR_32, 13)),
395 (add (shl VGPR_32, 14)),
396 (add (shl VGPR_32, 15))]>;
398 //===----------------------------------------------------------------------===//
399 // Register classes used as source and destination
400 //===----------------------------------------------------------------------===//
402 def Pseudo_SReg_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
403 (add FP_REG, SP_REG, SCRATCH_WAVE_OFFSET_REG)> {
404 let isAllocatable = 0;
408 def Pseudo_SReg_128 : RegisterClass<"AMDGPU", [v4i32, v2i64, v2f64], 32,
409 (add PRIVATE_RSRC_REG)> {
410 let isAllocatable = 0;
414 def LDS_DIRECT_CLASS : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
416 let isAllocatable = 0;
420 // Subset of SReg_32 without M0 for SMRD instructions and alike.
421 // See comments in SIInstructions.td for more info.
422 def SReg_32_XM0_XEXEC : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
423 (add SGPR_32, VCC_LO, VCC_HI, FLAT_SCR_LO, FLAT_SCR_HI, XNACK_MASK_LO, XNACK_MASK_HI,
424 TTMP_32, TMA_LO, TMA_HI, TBA_LO, TBA_HI, SRC_SHARED_BASE, SRC_SHARED_LIMIT,
425 SRC_PRIVATE_BASE, SRC_PRIVATE_LIMIT)> {
426 let AllocationPriority = 7;
429 def SReg_32_XEXEC_HI : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
430 (add SReg_32_XM0_XEXEC, EXEC_LO, M0_CLASS)> {
431 let AllocationPriority = 7;
434 def SReg_32_XM0 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
435 (add SReg_32_XM0_XEXEC, EXEC_LO, EXEC_HI)> {
436 let AllocationPriority = 7;
439 // Register class for all scalar registers (SGPRs + Special Registers)
440 def SReg_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
441 (add SReg_32_XM0, M0_CLASS, EXEC_LO, EXEC_HI, SReg_32_XEXEC_HI)> {
442 let AllocationPriority = 7;
445 def SGPR_64 : RegisterClass<"AMDGPU", [v2i32, i64, v2f32, f64, v4i16, v4f16], 32, (add SGPR_64Regs)> {
447 let AllocationPriority = 8;
450 def TTMP_64 : RegisterClass<"AMDGPU", [v2i32, i64, f64, v4i16, v4f16], 32, (add TTMP_64Regs)> {
451 let isAllocatable = 0;
454 def SReg_64_XEXEC : RegisterClass<"AMDGPU", [v2i32, i64, v2f32, f64, i1, v4i16, v4f16], 32,
455 (add SGPR_64, VCC, FLAT_SCR, XNACK_MASK, TTMP_64, TBA, TMA)> {
457 let AllocationPriority = 8;
460 def SReg_64 : RegisterClass<"AMDGPU", [v2i32, i64, v2f32, f64, i1, v4i16, v4f16], 32,
461 (add SReg_64_XEXEC, EXEC)> {
463 let AllocationPriority = 8;
466 // Requires 2 s_mov_b64 to copy
467 let CopyCost = 2 in {
469 def SGPR_128 : RegisterClass<"AMDGPU", [v4i32, v4f32, v2i64], 32, (add SGPR_128Regs)> {
470 let AllocationPriority = 10;
473 def TTMP_128 : RegisterClass<"AMDGPU", [v4i32, v4f32, v2i64], 32, (add TTMP_128Regs)> {
474 let isAllocatable = 0;
477 def SReg_128 : RegisterClass<"AMDGPU", [v4i32, v4f32, v2i64, v2f64], 32,
478 (add SGPR_128, TTMP_128)> {
479 let AllocationPriority = 10;
482 } // End CopyCost = 2
484 def SGPR_256 : RegisterClass<"AMDGPU", [v8i32, v8f32], 32, (add SGPR_256Regs)> {
485 let AllocationPriority = 11;
488 def TTMP_256 : RegisterClass<"AMDGPU", [v8i32, v8f32], 32, (add TTMP_256Regs)> {
489 let isAllocatable = 0;
492 def SReg_256 : RegisterClass<"AMDGPU", [v8i32, v8f32], 32,
493 (add SGPR_256, TTMP_256)> {
494 // Requires 4 s_mov_b64 to copy
496 let AllocationPriority = 11;
499 def SGPR_512 : RegisterClass<"AMDGPU", [v16i32, v16f32], 32, (add SGPR_512Regs)> {
500 let AllocationPriority = 12;
503 def TTMP_512 : RegisterClass<"AMDGPU", [v16i32, v16f32], 32, (add TTMP_512Regs)> {
504 let isAllocatable = 0;
507 def SReg_512 : RegisterClass<"AMDGPU", [v16i32, v16f32], 32,
508 (add SGPR_512, TTMP_512)> {
509 // Requires 8 s_mov_b64 to copy
511 let AllocationPriority = 12;
514 // Register class for all vector registers (VGPRs + Interploation Registers)
515 def VReg_64 : RegisterClass<"AMDGPU", [i64, f64, v2i32, v2f32, v4f16, v4i16], 32, (add VGPR_64)> {
518 // Requires 2 v_mov_b32 to copy
520 let AllocationPriority = 2;
523 def VReg_96 : RegisterClass<"AMDGPU", [untyped], 32, (add VGPR_96)> {
526 // Requires 3 v_mov_b32 to copy
528 let AllocationPriority = 3;
531 def VReg_128 : RegisterClass<"AMDGPU", [v4i32, v4f32, v2i64, v2f64], 32, (add VGPR_128)> {
534 // Requires 4 v_mov_b32 to copy
536 let AllocationPriority = 4;
539 def VReg_256 : RegisterClass<"AMDGPU", [v8i32, v8f32], 32, (add VGPR_256)> {
542 let AllocationPriority = 5;
545 def VReg_512 : RegisterClass<"AMDGPU", [v16i32, v16f32], 32, (add VGPR_512)> {
548 let AllocationPriority = 6;
551 def VReg_1 : RegisterClass<"AMDGPU", [i1], 32, (add VGPR_32)> {
555 def VS_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
556 (add VGPR_32, SReg_32, LDS_DIRECT_CLASS)> {
557 let isAllocatable = 0;
560 def VS_64 : RegisterClass<"AMDGPU", [i64, f64], 32, (add VReg_64, SReg_64)> {
561 let isAllocatable = 0;
564 //===----------------------------------------------------------------------===//
566 //===----------------------------------------------------------------------===//
568 class RegImmMatcher<string name> : AsmOperandClass {
570 let RenderMethod = "addRegOrImmOperands";
573 multiclass SIRegOperand <string rc, string MatchName, string opType> {
574 let OperandNamespace = "AMDGPU" in {
575 def _b16 : RegisterOperand<!cast<RegisterClass>(rc#"_32")> {
576 let OperandType = opType#"_INT16";
577 let ParserMatchClass = RegImmMatcher<MatchName#"B16">;
578 let DecoderMethod = "decodeOperand_VSrc16";
581 def _f16 : RegisterOperand<!cast<RegisterClass>(rc#"_32")> {
582 let OperandType = opType#"_FP16";
583 let ParserMatchClass = RegImmMatcher<MatchName#"F16">;
584 let DecoderMethod = "decodeOperand_VSrc16";
587 def _b32 : RegisterOperand<!cast<RegisterClass>(rc#"_32")> {
588 let OperandType = opType#"_INT32";
589 let ParserMatchClass = RegImmMatcher<MatchName#"B32">;
592 def _f32 : RegisterOperand<!cast<RegisterClass>(rc#"_32")> {
593 let OperandType = opType#"_FP32";
594 let ParserMatchClass = RegImmMatcher<MatchName#"F32">;
597 def _b64 : RegisterOperand<!cast<RegisterClass>(rc#"_64")> {
598 let OperandType = opType#"_INT64";
599 let ParserMatchClass = RegImmMatcher<MatchName#"B64">;
602 def _f64 : RegisterOperand<!cast<RegisterClass>(rc#"_64")> {
603 let OperandType = opType#"_FP64";
604 let ParserMatchClass = RegImmMatcher<MatchName#"F64">;
607 def _v2b16 : RegisterOperand<!cast<RegisterClass>(rc#"_32")> {
608 let OperandType = opType#"_V2INT16";
609 let ParserMatchClass = RegImmMatcher<MatchName#"V2B16">;
610 let DecoderMethod = "decodeOperand_VSrcV216";
613 def _v2f16 : RegisterOperand<!cast<RegisterClass>(rc#"_32")> {
614 let OperandType = opType#"_V2FP16";
615 let ParserMatchClass = RegImmMatcher<MatchName#"V2F16">;
616 let DecoderMethod = "decodeOperand_VSrcV216";
621 // FIXME: 64-bit sources can sometimes use 32-bit constants.
622 multiclass RegImmOperand <string rc, string MatchName>
623 : SIRegOperand<rc, MatchName, "OPERAND_REG_IMM">;
625 multiclass RegInlineOperand <string rc, string MatchName>
626 : SIRegOperand<rc, MatchName, "OPERAND_REG_INLINE_C">;
628 //===----------------------------------------------------------------------===//
629 // SSrc_* Operands with an SGPR or a 32-bit immediate
630 //===----------------------------------------------------------------------===//
632 defm SSrc : RegImmOperand<"SReg", "SSrc">;
634 //===----------------------------------------------------------------------===//
635 // SCSrc_* Operands with an SGPR or a inline constant
636 //===----------------------------------------------------------------------===//
638 defm SCSrc : RegInlineOperand<"SReg", "SCSrc"> ;
640 def SCSrc_i1 : RegisterOperand<SReg_64_XEXEC>;
642 //===----------------------------------------------------------------------===//
643 // VSrc_* Operands with an SGPR, VGPR or a 32-bit immediate
644 //===----------------------------------------------------------------------===//
646 defm VSrc : RegImmOperand<"VS", "VSrc">;
648 def VSrc_128 : RegisterOperand<VReg_128> {
649 let DecoderMethod = "DecodeVS_128RegisterClass";
652 //===----------------------------------------------------------------------===//
653 // VSrc_* Operands with an VGPR
654 //===----------------------------------------------------------------------===//
656 // This is for operands with the enum(9), VSrc encoding restriction,
657 // but only allows VGPRs.
658 def VRegSrc_32 : RegisterOperand<VGPR_32> {
659 //let ParserMatchClass = RegImmMatcher<"VRegSrc32">;
660 let DecoderMethod = "DecodeVS_32RegisterClass";
663 //===----------------------------------------------------------------------===//
664 // VCSrc_* Operands with an SGPR, VGPR or an inline constant
665 //===----------------------------------------------------------------------===//
667 defm VCSrc : RegInlineOperand<"VS", "VCSrc">;