xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/SIRegisterInfo.td (revision 5ffd83dbcc34f10e07f6d3e968ae6365869615f4)
10b57cec5SDimitry Andric//===-- SIRegisterInfo.td - SI Register defs ---------------*- tablegen -*-===//
20b57cec5SDimitry Andric//
30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric//
70b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric
90b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
10*5ffd83dbSDimitry Andric//  Subregister declarations
11*5ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
12*5ffd83dbSDimitry Andric
13*5ffd83dbSDimitry Andricclass Indexes<int N> {
14*5ffd83dbSDimitry Andric  list<int> all = [0,   1,  2,  3,  4,  5,  6 , 7,
15*5ffd83dbSDimitry Andric                   8,   9, 10, 11, 12, 13, 14, 15,
16*5ffd83dbSDimitry Andric                   16, 17, 18, 19, 20, 21, 22, 23,
17*5ffd83dbSDimitry Andric                   24, 25, 26, 27, 28, 29, 30, 31];
18*5ffd83dbSDimitry Andric
19*5ffd83dbSDimitry Andric  // Returns list of indexes [0..N)
20*5ffd83dbSDimitry Andric  list<int> slice =
21*5ffd83dbSDimitry Andric    !foldl([]<int>, all, acc, cur,
22*5ffd83dbSDimitry Andric           !listconcat(acc, !if(!lt(cur, N), [cur], [])));
23*5ffd83dbSDimitry Andric}
24*5ffd83dbSDimitry Andric
25*5ffd83dbSDimitry Andriclet Namespace = "AMDGPU" in {
26*5ffd83dbSDimitry Andric
27*5ffd83dbSDimitry Andricdef lo16 : SubRegIndex<16, 0>;
28*5ffd83dbSDimitry Andricdef hi16 : SubRegIndex<16, 16>;
29*5ffd83dbSDimitry Andric
30*5ffd83dbSDimitry Andricforeach Index = 0-31 in {
31*5ffd83dbSDimitry Andric  def sub#Index : SubRegIndex<32, !shl(Index, 5)>;
32*5ffd83dbSDimitry Andric}
33*5ffd83dbSDimitry Andric
34*5ffd83dbSDimitry Andricforeach Index = 1-31 in {
35*5ffd83dbSDimitry Andric  def sub#Index#_lo16 : ComposedSubRegIndex<!cast<SubRegIndex>(sub#Index), lo16>;
36*5ffd83dbSDimitry Andric  def sub#Index#_hi16 : ComposedSubRegIndex<!cast<SubRegIndex>(sub#Index), hi16>;
37*5ffd83dbSDimitry Andric}
38*5ffd83dbSDimitry Andric
39*5ffd83dbSDimitry Andricforeach Size = {2-6,8,16} in {
40*5ffd83dbSDimitry Andric  foreach Index = Indexes<!add(33, !mul(Size, -1))>.slice in {
41*5ffd83dbSDimitry Andric    def !foldl("", Indexes<Size>.slice, acc, cur,
42*5ffd83dbSDimitry Andric               !strconcat(acc#!if(!eq(acc,""),"","_"), "sub"#!add(cur, Index))) :
43*5ffd83dbSDimitry Andric      SubRegIndex<!mul(Size, 32), !shl(Index, 5)> {
44*5ffd83dbSDimitry Andric      let CoveringSubRegIndices =
45*5ffd83dbSDimitry Andric        !foldl([]<SubRegIndex>, Indexes<Size>.slice, acc, cur,
46*5ffd83dbSDimitry Andric               !listconcat(acc, [!cast<SubRegIndex>(sub#!add(cur, Index))]));
47*5ffd83dbSDimitry Andric    }
48*5ffd83dbSDimitry Andric  }
49*5ffd83dbSDimitry Andric}
50*5ffd83dbSDimitry Andric
51*5ffd83dbSDimitry Andric}
52*5ffd83dbSDimitry Andric
53*5ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
540b57cec5SDimitry Andric//  Helpers
550b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
560b57cec5SDimitry Andric
570b57cec5SDimitry Andricclass getSubRegs<int size> {
580b57cec5SDimitry Andric  list<SubRegIndex> ret2 = [sub0, sub1];
590b57cec5SDimitry Andric  list<SubRegIndex> ret3 = [sub0, sub1, sub2];
600b57cec5SDimitry Andric  list<SubRegIndex> ret4 = [sub0, sub1, sub2, sub3];
610b57cec5SDimitry Andric  list<SubRegIndex> ret5 = [sub0, sub1, sub2, sub3, sub4];
62*5ffd83dbSDimitry Andric  list<SubRegIndex> ret6 = [sub0, sub1, sub2, sub3, sub4, sub5];
630b57cec5SDimitry Andric  list<SubRegIndex> ret8 = [sub0, sub1, sub2, sub3, sub4, sub5, sub6, sub7];
640b57cec5SDimitry Andric  list<SubRegIndex> ret16 = [sub0, sub1, sub2, sub3,
650b57cec5SDimitry Andric                             sub4, sub5, sub6, sub7,
660b57cec5SDimitry Andric                             sub8, sub9, sub10, sub11,
670b57cec5SDimitry Andric                             sub12, sub13, sub14, sub15];
680b57cec5SDimitry Andric  list<SubRegIndex> ret32 = [sub0, sub1, sub2, sub3,
690b57cec5SDimitry Andric                             sub4, sub5, sub6, sub7,
700b57cec5SDimitry Andric                             sub8, sub9, sub10, sub11,
710b57cec5SDimitry Andric                             sub12, sub13, sub14, sub15,
720b57cec5SDimitry Andric                             sub16, sub17, sub18, sub19,
730b57cec5SDimitry Andric                             sub20, sub21, sub22, sub23,
740b57cec5SDimitry Andric                             sub24, sub25, sub26, sub27,
750b57cec5SDimitry Andric                             sub28, sub29, sub30, sub31];
760b57cec5SDimitry Andric
770b57cec5SDimitry Andric  list<SubRegIndex> ret = !if(!eq(size, 2), ret2,
780b57cec5SDimitry Andric                              !if(!eq(size, 3), ret3,
790b57cec5SDimitry Andric                                  !if(!eq(size, 4), ret4,
800b57cec5SDimitry Andric                                      !if(!eq(size, 5), ret5,
81*5ffd83dbSDimitry Andric                                          !if(!eq(size, 6), ret6,
820b57cec5SDimitry Andric                                              !if(!eq(size, 8), ret8,
83*5ffd83dbSDimitry Andric                                                  !if(!eq(size, 16), ret16,
84*5ffd83dbSDimitry Andric                                                      ret32)))))));
850b57cec5SDimitry Andric}
860b57cec5SDimitry Andric
878bcb0991SDimitry Andric// Generates list of sequential register tuple names.
888bcb0991SDimitry Andric// E.g. RegSeq<3,2,2,"s">.ret -> [ "s[0:1]", "s[2:3]" ]
898bcb0991SDimitry Andricclass RegSeqNames<int last_reg, int stride, int size, string prefix,
908bcb0991SDimitry Andric                  int start = 0> {
918bcb0991SDimitry Andric  int next = !add(start, stride);
928bcb0991SDimitry Andric  int end_reg = !add(!add(start, size), -1);
938bcb0991SDimitry Andric  list<string> ret =
948bcb0991SDimitry Andric    !if(!le(end_reg, last_reg),
958bcb0991SDimitry Andric        !listconcat([prefix # "[" # start # ":" # end_reg # "]"],
968bcb0991SDimitry Andric                    RegSeqNames<last_reg, stride, size, prefix, next>.ret),
978bcb0991SDimitry Andric                    []);
980b57cec5SDimitry Andric}
998bcb0991SDimitry Andric
1008bcb0991SDimitry Andric// Generates list of dags for register tupless.
1018bcb0991SDimitry Andricclass RegSeqDags<RegisterClass RC, int last_reg, int stride, int size,
1028bcb0991SDimitry Andric                int start = 0> {
1038bcb0991SDimitry Andric  dag trunc_rc = (trunc RC,
1048bcb0991SDimitry Andric                  !if(!and(!eq(stride, 1), !eq(start, 0)),
1058bcb0991SDimitry Andric                      !add(!add(last_reg, 2), !mul(size, -1)),
1068bcb0991SDimitry Andric                      !add(last_reg, 1)));
1078bcb0991SDimitry Andric  list<dag> ret =
1088bcb0991SDimitry Andric    !if(!lt(start, size),
1098bcb0991SDimitry Andric        !listconcat([(add (decimate (shl trunc_rc, start), stride))],
1108bcb0991SDimitry Andric                    RegSeqDags<RC, last_reg, stride, size, !add(start, 1)>.ret),
1118bcb0991SDimitry Andric        []);
1120b57cec5SDimitry Andric}
1130b57cec5SDimitry Andric
1148bcb0991SDimitry Andricclass SIRegisterTuples<list<SubRegIndex> Indices, RegisterClass RC,
1158bcb0991SDimitry Andric                       int last_reg, int stride, int size, string prefix> :
1168bcb0991SDimitry Andric  RegisterTuples<Indices,
1178bcb0991SDimitry Andric                 RegSeqDags<RC, last_reg, stride, size>.ret,
1188bcb0991SDimitry Andric                 RegSeqNames<last_reg, stride, size, prefix>.ret>;
1198bcb0991SDimitry Andric
1200b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1210b57cec5SDimitry Andric//  Declarations that describe the SI registers
1220b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1238bcb0991SDimitry Andricclass SIReg <string n, bits<16> regIdx = 0> :
124*5ffd83dbSDimitry Andric  Register<n> {
1250b57cec5SDimitry Andric  let Namespace = "AMDGPU";
1260b57cec5SDimitry Andric  let HWEncoding = regIdx;
1270b57cec5SDimitry Andric}
1280b57cec5SDimitry Andric
129*5ffd83dbSDimitry Andricclass SIRegWithSubRegs <string n, list<Register> subregs, bits<16> regIdx> :
130*5ffd83dbSDimitry Andric  RegisterWithSubRegs<n, subregs> {
131*5ffd83dbSDimitry Andric}
132*5ffd83dbSDimitry Andric
133*5ffd83dbSDimitry Andricmulticlass SIRegLoHi16 <string n, bits<16> regIdx, bit ArtificialHigh = 1,
134*5ffd83dbSDimitry Andric                        bit HWEncodingHigh = 0> {
135*5ffd83dbSDimitry Andric  // There is no special encoding for 16 bit subregs, these are not real
136*5ffd83dbSDimitry Andric  // registers but rather operands for instructions preserving other 16 bits
137*5ffd83dbSDimitry Andric  // of the result or reading just 16 bits of a 32 bit VGPR.
138*5ffd83dbSDimitry Andric  // It is encoded as a corresponding 32 bit register.
139*5ffd83dbSDimitry Andric  // Non-VGPR register classes use it as we need to have matching subregisters
140*5ffd83dbSDimitry Andric  // to move instructions and data between ALUs.
141*5ffd83dbSDimitry Andric  def _LO16 : SIReg<n#".l", regIdx> {
142*5ffd83dbSDimitry Andric    let HWEncoding{8} = HWEncodingHigh;
143*5ffd83dbSDimitry Andric  }
144*5ffd83dbSDimitry Andric  def _HI16 : SIReg<!if(ArtificialHigh, "", n#".h"), regIdx> {
145*5ffd83dbSDimitry Andric    let isArtificial = ArtificialHigh;
146*5ffd83dbSDimitry Andric    let HWEncoding{8} = HWEncodingHigh;
147*5ffd83dbSDimitry Andric  }
148*5ffd83dbSDimitry Andric  def "" : RegisterWithSubRegs<n, [!cast<Register>(NAME#"_LO16"),
149*5ffd83dbSDimitry Andric                                   !cast<Register>(NAME#"_HI16")]> {
150*5ffd83dbSDimitry Andric    let Namespace = "AMDGPU";
151*5ffd83dbSDimitry Andric    let SubRegIndices = [lo16, hi16];
152*5ffd83dbSDimitry Andric    let CoveredBySubRegs = !if(ArtificialHigh,0,1);
153*5ffd83dbSDimitry Andric    let HWEncoding = regIdx;
154*5ffd83dbSDimitry Andric    let HWEncoding{8} = HWEncodingHigh;
155*5ffd83dbSDimitry Andric  }
156*5ffd83dbSDimitry Andric}
157*5ffd83dbSDimitry Andric
1580b57cec5SDimitry Andric// Special Registers
159*5ffd83dbSDimitry Andricdefm VCC_LO : SIRegLoHi16<"vcc_lo", 106>;
160*5ffd83dbSDimitry Andricdefm VCC_HI : SIRegLoHi16<"vcc_hi", 107>;
1610b57cec5SDimitry Andric
1620b57cec5SDimitry Andric// Pseudo-registers: Used as placeholders during isel and immediately
1630b57cec5SDimitry Andric// replaced, never seeing the verifier.
1640b57cec5SDimitry Andricdef PRIVATE_RSRC_REG : SIReg<"private_rsrc", 0>;
1650b57cec5SDimitry Andricdef FP_REG : SIReg<"fp", 0>;
1660b57cec5SDimitry Andricdef SP_REG : SIReg<"sp", 0>;
167*5ffd83dbSDimitry Andric
168*5ffd83dbSDimitry Andric// Pseudo-register to represent the program-counter DWARF register.
169*5ffd83dbSDimitry Andricdef PC_REG : SIReg<"pc", 0>, DwarfRegNum<[16, 16]> {
170*5ffd83dbSDimitry Andric  // There is no physical register corresponding to a "program counter", but
171*5ffd83dbSDimitry Andric  // we need to encode the concept in debug information in order to represent
172*5ffd83dbSDimitry Andric  // things like the return value in unwind information.
173*5ffd83dbSDimitry Andric  let isArtificial = 1;
174*5ffd83dbSDimitry Andric}
1750b57cec5SDimitry Andric
1760b57cec5SDimitry Andric// VCC for 64-bit instructions
177*5ffd83dbSDimitry Andricdef VCC : RegisterWithSubRegs<"vcc", [VCC_LO, VCC_HI]> {
1780b57cec5SDimitry Andric  let Namespace = "AMDGPU";
1790b57cec5SDimitry Andric  let SubRegIndices = [sub0, sub1];
1800b57cec5SDimitry Andric  let HWEncoding = 106;
1810b57cec5SDimitry Andric}
1820b57cec5SDimitry Andric
183*5ffd83dbSDimitry Andricdefm EXEC_LO : SIRegLoHi16<"exec_lo", 126>, DwarfRegNum<[1, 1]>;
184*5ffd83dbSDimitry Andricdefm EXEC_HI : SIRegLoHi16<"exec_hi", 127>;
1850b57cec5SDimitry Andric
186*5ffd83dbSDimitry Andricdef EXEC : RegisterWithSubRegs<"exec", [EXEC_LO, EXEC_HI]>, DwarfRegNum<[17, 1]> {
1870b57cec5SDimitry Andric  let Namespace = "AMDGPU";
1880b57cec5SDimitry Andric  let SubRegIndices = [sub0, sub1];
1890b57cec5SDimitry Andric  let HWEncoding = 126;
1900b57cec5SDimitry Andric}
1910b57cec5SDimitry Andric
1920b57cec5SDimitry Andric// 32-bit real registers, for MC only.
1930b57cec5SDimitry Andric// May be used with both 32-bit and 64-bit operands.
194*5ffd83dbSDimitry Andricdefm SRC_VCCZ : SIRegLoHi16<"src_vccz", 251>;
195*5ffd83dbSDimitry Andricdefm SRC_EXECZ : SIRegLoHi16<"src_execz", 252>;
196*5ffd83dbSDimitry Andricdefm SRC_SCC : SIRegLoHi16<"src_scc", 253>;
1970b57cec5SDimitry Andric
1980b57cec5SDimitry Andric// 1-bit pseudo register, for codegen only.
1990b57cec5SDimitry Andric// Should never be emitted.
2000b57cec5SDimitry Andricdef SCC : SIReg<"scc">;
2010b57cec5SDimitry Andric
202*5ffd83dbSDimitry Andricdefm M0 : SIRegLoHi16 <"m0", 124>;
203*5ffd83dbSDimitry Andricdefm SGPR_NULL : SIRegLoHi16 <"null", 125>;
2040b57cec5SDimitry Andric
205*5ffd83dbSDimitry Andricdefm SRC_SHARED_BASE : SIRegLoHi16<"src_shared_base", 235>;
206*5ffd83dbSDimitry Andricdefm SRC_SHARED_LIMIT : SIRegLoHi16<"src_shared_limit", 236>;
207*5ffd83dbSDimitry Andricdefm SRC_PRIVATE_BASE : SIRegLoHi16<"src_private_base", 237>;
208*5ffd83dbSDimitry Andricdefm SRC_PRIVATE_LIMIT : SIRegLoHi16<"src_private_limit", 238>;
209*5ffd83dbSDimitry Andricdefm SRC_POPS_EXITING_WAVE_ID : SIRegLoHi16<"src_pops_exiting_wave_id", 239>;
2100b57cec5SDimitry Andric
211*5ffd83dbSDimitry Andric// Not addressable
212*5ffd83dbSDimitry Andricdef MODE : SIReg <"mode", 0>;
2130b57cec5SDimitry Andric
214*5ffd83dbSDimitry Andricdef LDS_DIRECT : SIReg <"src_lds_direct", 254> {
215*5ffd83dbSDimitry Andric  // There is no physical register corresponding to this. This is an
216*5ffd83dbSDimitry Andric  // encoding value in a source field, which will ultimately trigger a
217*5ffd83dbSDimitry Andric  // read from m0.
218*5ffd83dbSDimitry Andric  let isArtificial = 1;
219*5ffd83dbSDimitry Andric}
2200b57cec5SDimitry Andric
221*5ffd83dbSDimitry Andricdefm XNACK_MASK_LO : SIRegLoHi16<"xnack_mask_lo", 104>;
222*5ffd83dbSDimitry Andricdefm XNACK_MASK_HI : SIRegLoHi16<"xnack_mask_hi", 105>;
223*5ffd83dbSDimitry Andric
224*5ffd83dbSDimitry Andricdef XNACK_MASK :
225*5ffd83dbSDimitry Andric    RegisterWithSubRegs<"xnack_mask", [XNACK_MASK_LO, XNACK_MASK_HI]> {
2260b57cec5SDimitry Andric  let Namespace = "AMDGPU";
2270b57cec5SDimitry Andric  let SubRegIndices = [sub0, sub1];
2280b57cec5SDimitry Andric  let HWEncoding = 104;
2290b57cec5SDimitry Andric}
2300b57cec5SDimitry Andric
2310b57cec5SDimitry Andric// Trap handler registers
232*5ffd83dbSDimitry Andricdefm TBA_LO : SIRegLoHi16<"tba_lo", 108>;
233*5ffd83dbSDimitry Andricdefm TBA_HI : SIRegLoHi16<"tba_hi", 109>;
2340b57cec5SDimitry Andric
235*5ffd83dbSDimitry Andricdef TBA : RegisterWithSubRegs<"tba", [TBA_LO, TBA_HI]> {
2360b57cec5SDimitry Andric  let Namespace = "AMDGPU";
2370b57cec5SDimitry Andric  let SubRegIndices = [sub0, sub1];
2380b57cec5SDimitry Andric  let HWEncoding = 108;
2390b57cec5SDimitry Andric}
2400b57cec5SDimitry Andric
241*5ffd83dbSDimitry Andricdefm TMA_LO : SIRegLoHi16<"tma_lo", 110>;
242*5ffd83dbSDimitry Andricdefm TMA_HI : SIRegLoHi16<"tma_hi", 111>;
2430b57cec5SDimitry Andric
244*5ffd83dbSDimitry Andricdef TMA : RegisterWithSubRegs<"tma", [TMA_LO, TMA_HI]> {
2450b57cec5SDimitry Andric  let Namespace = "AMDGPU";
2460b57cec5SDimitry Andric  let SubRegIndices = [sub0, sub1];
2470b57cec5SDimitry Andric  let HWEncoding = 110;
2480b57cec5SDimitry Andric}
2490b57cec5SDimitry Andric
2500b57cec5SDimitry Andricforeach Index = 0-15 in {
251*5ffd83dbSDimitry Andric  defm TTMP#Index#_vi         : SIRegLoHi16<"ttmp"#Index, !add(112, Index)>;
252*5ffd83dbSDimitry Andric  defm TTMP#Index#_gfx9_gfx10 : SIRegLoHi16<"ttmp"#Index, !add(108, Index)>;
253*5ffd83dbSDimitry Andric  defm TTMP#Index             : SIRegLoHi16<"ttmp"#Index, 0>;
2540b57cec5SDimitry Andric}
2550b57cec5SDimitry Andric
2560b57cec5SDimitry Andricmulticlass FLAT_SCR_LOHI_m <string n, bits<16> ci_e, bits<16> vi_e> {
257*5ffd83dbSDimitry Andric  defm _ci : SIRegLoHi16<n, ci_e>;
258*5ffd83dbSDimitry Andric  defm _vi : SIRegLoHi16<n, vi_e>;
259*5ffd83dbSDimitry Andric  defm "" : SIRegLoHi16<n, 0>;
2600b57cec5SDimitry Andric}
2610b57cec5SDimitry Andric
2620b57cec5SDimitry Andricclass FlatReg <Register lo, Register hi, bits<16> encoding> :
263*5ffd83dbSDimitry Andric    RegisterWithSubRegs<"flat_scratch", [lo, hi]> {
2640b57cec5SDimitry Andric  let Namespace = "AMDGPU";
2650b57cec5SDimitry Andric  let SubRegIndices = [sub0, sub1];
2660b57cec5SDimitry Andric  let HWEncoding = encoding;
2670b57cec5SDimitry Andric}
2680b57cec5SDimitry Andric
2690b57cec5SDimitry Andricdefm FLAT_SCR_LO : FLAT_SCR_LOHI_m<"flat_scratch_lo", 104, 102>; // Offset in units of 256-bytes.
2700b57cec5SDimitry Andricdefm FLAT_SCR_HI : FLAT_SCR_LOHI_m<"flat_scratch_hi", 105, 103>; // Size is the per-thread scratch size, in bytes.
2710b57cec5SDimitry Andric
2720b57cec5SDimitry Andricdef FLAT_SCR_ci : FlatReg<FLAT_SCR_LO_ci, FLAT_SCR_HI_ci, 104>;
2730b57cec5SDimitry Andricdef FLAT_SCR_vi : FlatReg<FLAT_SCR_LO_vi, FLAT_SCR_HI_vi, 102>;
2740b57cec5SDimitry Andricdef FLAT_SCR : FlatReg<FLAT_SCR_LO, FLAT_SCR_HI, 0>;
2750b57cec5SDimitry Andric
2760b57cec5SDimitry Andric// SGPR registers
2770b57cec5SDimitry Andricforeach Index = 0-105 in {
278*5ffd83dbSDimitry Andric  defm SGPR#Index :
279*5ffd83dbSDimitry Andric     SIRegLoHi16 <"s"#Index, Index>,
280*5ffd83dbSDimitry Andric     DwarfRegNum<[!if(!le(Index, 63), !add(Index, 32), !add(Index, 1024)),
281*5ffd83dbSDimitry Andric                  !if(!le(Index, 63), !add(Index, 32), !add(Index, 1024))]>;
2820b57cec5SDimitry Andric}
2830b57cec5SDimitry Andric
2840b57cec5SDimitry Andric// VGPR registers
2850b57cec5SDimitry Andricforeach Index = 0-255 in {
286*5ffd83dbSDimitry Andric  defm VGPR#Index :
287*5ffd83dbSDimitry Andric    SIRegLoHi16 <"v"#Index, Index, 0, 1>,
288*5ffd83dbSDimitry Andric    DwarfRegNum<[!add(Index, 2560), !add(Index, 1536)]>;
2890b57cec5SDimitry Andric}
2900b57cec5SDimitry Andric
2910b57cec5SDimitry Andric// AccVGPR registers
2920b57cec5SDimitry Andricforeach Index = 0-255 in {
293*5ffd83dbSDimitry Andric  defm AGPR#Index :
294*5ffd83dbSDimitry Andric      SIRegLoHi16 <"a"#Index, Index, 1, 1>,
295*5ffd83dbSDimitry Andric      DwarfRegNum<[!add(Index, 3072), !add(Index, 2048)]>;
2960b57cec5SDimitry Andric}
2970b57cec5SDimitry Andric
2980b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
2990b57cec5SDimitry Andric//  Groupings using register classes and tuples
3000b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
3010b57cec5SDimitry Andric
3020b57cec5SDimitry Andricdef SCC_CLASS : RegisterClass<"AMDGPU", [i1], 1, (add SCC)> {
3030b57cec5SDimitry Andric  let CopyCost = -1;
3040b57cec5SDimitry Andric  let isAllocatable = 0;
3050b57cec5SDimitry Andric}
3060b57cec5SDimitry Andric
3070b57cec5SDimitry Andricdef M0_CLASS : RegisterClass<"AMDGPU", [i32], 32, (add M0)> {
3080b57cec5SDimitry Andric  let CopyCost = 1;
3090b57cec5SDimitry Andric  let isAllocatable = 0;
3100b57cec5SDimitry Andric}
3110b57cec5SDimitry Andric
312*5ffd83dbSDimitry Andricdef M0_CLASS_LO16 : RegisterClass<"AMDGPU", [i16, f16], 16, (add M0_LO16)> {
313*5ffd83dbSDimitry Andric  let CopyCost = 1;
314*5ffd83dbSDimitry Andric  let Size = 16;
315*5ffd83dbSDimitry Andric  let isAllocatable = 0;
316*5ffd83dbSDimitry Andric}
317*5ffd83dbSDimitry Andric
3180b57cec5SDimitry Andric// TODO: Do we need to set DwarfRegAlias on register tuples?
3190b57cec5SDimitry Andric
320*5ffd83dbSDimitry Andricdef SGPR_LO16 : RegisterClass<"AMDGPU", [i16, f16], 16,
321*5ffd83dbSDimitry Andric                              (add (sequence "SGPR%u_LO16", 0, 105))> {
322*5ffd83dbSDimitry Andric  let AllocationPriority = 9;
323*5ffd83dbSDimitry Andric  let Size = 16;
324*5ffd83dbSDimitry Andric  let GeneratePressureSet = 0;
325*5ffd83dbSDimitry Andric}
326*5ffd83dbSDimitry Andric
327*5ffd83dbSDimitry Andricdef SGPR_HI16 : RegisterClass<"AMDGPU", [i16, f16], 16,
328*5ffd83dbSDimitry Andric                              (add (sequence "SGPR%u_HI16", 0, 105))> {
329*5ffd83dbSDimitry Andric  let isAllocatable = 0;
330*5ffd83dbSDimitry Andric  let Size = 16;
331*5ffd83dbSDimitry Andric  let GeneratePressureSet = 0;
332*5ffd83dbSDimitry Andric}
333*5ffd83dbSDimitry Andric
3340b57cec5SDimitry Andric// SGPR 32-bit registers
3350b57cec5SDimitry Andricdef SGPR_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
3368bcb0991SDimitry Andric                            (add (sequence "SGPR%u", 0, 105))> {
3370b57cec5SDimitry Andric  // Give all SGPR classes higher priority than VGPR classes, because
3380b57cec5SDimitry Andric  // we want to spill SGPRs to VGPRs.
3390b57cec5SDimitry Andric  let AllocationPriority = 9;
340*5ffd83dbSDimitry Andric  let GeneratePressureSet = 0;
3410b57cec5SDimitry Andric}
3420b57cec5SDimitry Andric
3430b57cec5SDimitry Andric// SGPR 64-bit registers
3448bcb0991SDimitry Andricdef SGPR_64Regs : SIRegisterTuples<getSubRegs<2>.ret, SGPR_32, 105, 2, 2, "s">;
3450b57cec5SDimitry Andric
3460b57cec5SDimitry Andric// SGPR 96-bit registers. No operations use these, but for symmetry with 96-bit VGPRs.
3478bcb0991SDimitry Andricdef SGPR_96Regs : SIRegisterTuples<getSubRegs<3>.ret, SGPR_32, 105, 3, 3, "s">;
3480b57cec5SDimitry Andric
3490b57cec5SDimitry Andric// SGPR 128-bit registers
3508bcb0991SDimitry Andricdef SGPR_128Regs : SIRegisterTuples<getSubRegs<4>.ret, SGPR_32, 105, 4, 4, "s">;
3510b57cec5SDimitry Andric
3520b57cec5SDimitry Andric// SGPR 160-bit registers. No operations use these, but for symmetry with 160-bit VGPRs.
3538bcb0991SDimitry Andricdef SGPR_160Regs : SIRegisterTuples<getSubRegs<5>.ret, SGPR_32, 105, 4, 5, "s">;
3540b57cec5SDimitry Andric
355*5ffd83dbSDimitry Andric// SGPR 192-bit registers
356*5ffd83dbSDimitry Andricdef SGPR_192Regs : SIRegisterTuples<getSubRegs<6>.ret, SGPR_32, 105, 4, 6, "s">;
357*5ffd83dbSDimitry Andric
3580b57cec5SDimitry Andric// SGPR 256-bit registers
3598bcb0991SDimitry Andricdef SGPR_256Regs : SIRegisterTuples<getSubRegs<8>.ret, SGPR_32, 105, 4, 8, "s">;
3600b57cec5SDimitry Andric
3610b57cec5SDimitry Andric// SGPR 512-bit registers
3628bcb0991SDimitry Andricdef SGPR_512Regs : SIRegisterTuples<getSubRegs<16>.ret, SGPR_32, 105, 4, 16, "s">;
3630b57cec5SDimitry Andric
3640b57cec5SDimitry Andric// SGPR 1024-bit registers
3658bcb0991SDimitry Andricdef SGPR_1024Regs : SIRegisterTuples<getSubRegs<32>.ret, SGPR_32, 105, 4, 32, "s">;
3660b57cec5SDimitry Andric
3670b57cec5SDimitry Andric// Trap handler TMP 32-bit registers
3680b57cec5SDimitry Andricdef TTMP_32 : RegisterClass<"AMDGPU", [i32, f32, v2i16, v2f16], 32,
3690b57cec5SDimitry Andric                            (add (sequence "TTMP%u", 0, 15))> {
3700b57cec5SDimitry Andric  let isAllocatable = 0;
3710b57cec5SDimitry Andric}
3720b57cec5SDimitry Andric
373*5ffd83dbSDimitry Andricdef TTMP_LO16 : RegisterClass<"AMDGPU", [i16, f16], 16,
374*5ffd83dbSDimitry Andric                              (add (sequence "TTMP%u_LO16", 0, 15))> {
375*5ffd83dbSDimitry Andric  let Size = 16;
376*5ffd83dbSDimitry Andric  let isAllocatable = 0;
377*5ffd83dbSDimitry Andric}
378*5ffd83dbSDimitry Andric
3790b57cec5SDimitry Andric// Trap handler TMP 64-bit registers
3808bcb0991SDimitry Andricdef TTMP_64Regs : SIRegisterTuples<getSubRegs<2>.ret, TTMP_32, 15, 2, 2, "ttmp">;
3810b57cec5SDimitry Andric
3820b57cec5SDimitry Andric// Trap handler TMP 128-bit registers
3838bcb0991SDimitry Andricdef TTMP_128Regs : SIRegisterTuples<getSubRegs<4>.ret, TTMP_32, 15, 4, 4, "ttmp">;
3840b57cec5SDimitry Andric
3858bcb0991SDimitry Andricdef TTMP_256Regs : SIRegisterTuples<getSubRegs<8>.ret, TTMP_32, 15, 4, 8, "ttmp">;
3860b57cec5SDimitry Andric
3878bcb0991SDimitry Andricdef TTMP_512Regs : SIRegisterTuples<getSubRegs<16>.ret, TTMP_32, 15, 4, 16, "ttmp">;
3880b57cec5SDimitry Andric
3890b57cec5SDimitry Andricclass TmpRegTuplesBase<int index, int size,
3900b57cec5SDimitry Andric                       list<Register> subRegs,
3910b57cec5SDimitry Andric                       list<SubRegIndex> indices = getSubRegs<size>.ret,
3920b57cec5SDimitry Andric                       int index1 = !add(index, !add(size, -1)),
3930b57cec5SDimitry Andric                       string name = "ttmp["#index#":"#index1#"]"> :
3948bcb0991SDimitry Andric  RegisterWithSubRegs<name, subRegs> {
3950b57cec5SDimitry Andric  let HWEncoding = subRegs[0].HWEncoding;
3960b57cec5SDimitry Andric  let SubRegIndices = indices;
3970b57cec5SDimitry Andric}
3980b57cec5SDimitry Andric
3990b57cec5SDimitry Andricclass TmpRegTuples<string tgt,
4000b57cec5SDimitry Andric                   int size,
4010b57cec5SDimitry Andric                   int index0,
4020b57cec5SDimitry Andric                   int index1 = !add(index0, 1),
4030b57cec5SDimitry Andric                   int index2 = !add(index0, !if(!eq(size, 2), 1, 2)),
4040b57cec5SDimitry Andric                   int index3 = !add(index0, !if(!eq(size, 2), 1, 3)),
4050b57cec5SDimitry Andric                   int index4 = !add(index0, !if(!eq(size, 8), 4, 1)),
4060b57cec5SDimitry Andric                   int index5 = !add(index0, !if(!eq(size, 8), 5, 1)),
4070b57cec5SDimitry Andric                   int index6 = !add(index0, !if(!eq(size, 8), 6, 1)),
4080b57cec5SDimitry Andric                   int index7 = !add(index0, !if(!eq(size, 8), 7, 1)),
4090b57cec5SDimitry Andric                   Register r0 = !cast<Register>("TTMP"#index0#tgt),
4100b57cec5SDimitry Andric                   Register r1 = !cast<Register>("TTMP"#index1#tgt),
4110b57cec5SDimitry Andric                   Register r2 = !cast<Register>("TTMP"#index2#tgt),
4120b57cec5SDimitry Andric                   Register r3 = !cast<Register>("TTMP"#index3#tgt),
4130b57cec5SDimitry Andric                   Register r4 = !cast<Register>("TTMP"#index4#tgt),
4140b57cec5SDimitry Andric                   Register r5 = !cast<Register>("TTMP"#index5#tgt),
4150b57cec5SDimitry Andric                   Register r6 = !cast<Register>("TTMP"#index6#tgt),
4160b57cec5SDimitry Andric                   Register r7 = !cast<Register>("TTMP"#index7#tgt)> :
4170b57cec5SDimitry Andric  TmpRegTuplesBase<index0, size,
4180b57cec5SDimitry Andric                   !if(!eq(size, 2), [r0, r1],
4190b57cec5SDimitry Andric                       !if(!eq(size, 4), [r0, r1, r2, r3],
4200b57cec5SDimitry Andric                                         [r0, r1, r2, r3, r4, r5, r6, r7])),
4210b57cec5SDimitry Andric                   getSubRegs<size>.ret>;
4220b57cec5SDimitry Andric
4230b57cec5SDimitry Andricforeach Index = {0, 2, 4, 6, 8, 10, 12, 14} in {
4240b57cec5SDimitry Andric  def TTMP#Index#_TTMP#!add(Index,1)#_vi         : TmpRegTuples<"_vi",   2, Index>;
4250b57cec5SDimitry Andric  def TTMP#Index#_TTMP#!add(Index,1)#_gfx9_gfx10 : TmpRegTuples<"_gfx9_gfx10", 2, Index>;
4260b57cec5SDimitry Andric}
4270b57cec5SDimitry Andric
4280b57cec5SDimitry Andricforeach Index = {0, 4, 8, 12} in {
4290b57cec5SDimitry Andric  def TTMP#Index#_TTMP#!add(Index,1)#
4300b57cec5SDimitry Andric                 _TTMP#!add(Index,2)#
4310b57cec5SDimitry Andric                 _TTMP#!add(Index,3)#_vi : TmpRegTuples<"_vi",   4, Index>;
4320b57cec5SDimitry Andric  def TTMP#Index#_TTMP#!add(Index,1)#
4330b57cec5SDimitry Andric                 _TTMP#!add(Index,2)#
4340b57cec5SDimitry Andric                 _TTMP#!add(Index,3)#_gfx9_gfx10 : TmpRegTuples<"_gfx9_gfx10", 4, Index>;
4350b57cec5SDimitry Andric}
4360b57cec5SDimitry Andric
4370b57cec5SDimitry Andricforeach Index = {0, 4, 8} in {
4380b57cec5SDimitry Andric  def TTMP#Index#_TTMP#!add(Index,1)#
4390b57cec5SDimitry Andric                 _TTMP#!add(Index,2)#
4400b57cec5SDimitry Andric                 _TTMP#!add(Index,3)#
4410b57cec5SDimitry Andric                 _TTMP#!add(Index,4)#
4420b57cec5SDimitry Andric                 _TTMP#!add(Index,5)#
4430b57cec5SDimitry Andric                 _TTMP#!add(Index,6)#
4440b57cec5SDimitry Andric                 _TTMP#!add(Index,7)#_vi : TmpRegTuples<"_vi",   8, Index>;
4450b57cec5SDimitry Andric  def TTMP#Index#_TTMP#!add(Index,1)#
4460b57cec5SDimitry Andric                 _TTMP#!add(Index,2)#
4470b57cec5SDimitry Andric                 _TTMP#!add(Index,3)#
4480b57cec5SDimitry Andric                 _TTMP#!add(Index,4)#
4490b57cec5SDimitry Andric                 _TTMP#!add(Index,5)#
4500b57cec5SDimitry Andric                 _TTMP#!add(Index,6)#
4510b57cec5SDimitry Andric                 _TTMP#!add(Index,7)#_gfx9_gfx10 : TmpRegTuples<"_gfx9_gfx10", 8, Index>;
4520b57cec5SDimitry Andric}
4530b57cec5SDimitry Andric
4540b57cec5SDimitry Andricdef TTMP0_TTMP1_TTMP2_TTMP3_TTMP4_TTMP5_TTMP6_TTMP7_TTMP8_TTMP9_TTMP10_TTMP11_TTMP12_TTMP13_TTMP14_TTMP15_vi :
4550b57cec5SDimitry Andric  TmpRegTuplesBase<0, 16,
4560b57cec5SDimitry Andric                   [TTMP0_vi, TTMP1_vi, TTMP2_vi, TTMP3_vi,
4570b57cec5SDimitry Andric                    TTMP4_vi, TTMP5_vi, TTMP6_vi, TTMP7_vi,
4580b57cec5SDimitry Andric                    TTMP8_vi, TTMP9_vi, TTMP10_vi, TTMP11_vi,
4590b57cec5SDimitry Andric                    TTMP12_vi, TTMP13_vi, TTMP14_vi, TTMP15_vi]>;
4600b57cec5SDimitry Andric
4610b57cec5SDimitry Andricdef TTMP0_TTMP1_TTMP2_TTMP3_TTMP4_TTMP5_TTMP6_TTMP7_TTMP8_TTMP9_TTMP10_TTMP11_TTMP12_TTMP13_TTMP14_TTMP15_gfx9_gfx10 :
4620b57cec5SDimitry Andric  TmpRegTuplesBase<0, 16,
4630b57cec5SDimitry Andric                   [TTMP0_gfx9_gfx10, TTMP1_gfx9_gfx10, TTMP2_gfx9_gfx10, TTMP3_gfx9_gfx10,
4640b57cec5SDimitry Andric                    TTMP4_gfx9_gfx10, TTMP5_gfx9_gfx10, TTMP6_gfx9_gfx10, TTMP7_gfx9_gfx10,
4650b57cec5SDimitry Andric                    TTMP8_gfx9_gfx10, TTMP9_gfx9_gfx10, TTMP10_gfx9_gfx10, TTMP11_gfx9_gfx10,
4660b57cec5SDimitry Andric                    TTMP12_gfx9_gfx10, TTMP13_gfx9_gfx10, TTMP14_gfx9_gfx10, TTMP15_gfx9_gfx10]>;
4670b57cec5SDimitry Andric
4688bcb0991SDimitry Andricclass RegisterTypes<list<ValueType> reg_types> {
4698bcb0991SDimitry Andric  list<ValueType> types = reg_types;
4708bcb0991SDimitry Andric}
4718bcb0991SDimitry Andric
4728bcb0991SDimitry Andricdef Reg16Types : RegisterTypes<[i16, f16]>;
4738bcb0991SDimitry Andricdef Reg32Types : RegisterTypes<[i32, f32, v2i16, v2f16, p2, p3, p5, p6]>;
4748bcb0991SDimitry Andric
475*5ffd83dbSDimitry Andricdef VGPR_LO16 : RegisterClass<"AMDGPU", Reg16Types.types, 16,
476*5ffd83dbSDimitry Andric                              (add (sequence "VGPR%u_LO16", 0, 255))> {
477*5ffd83dbSDimitry Andric  let AllocationPriority = 1;
478*5ffd83dbSDimitry Andric  let Size = 16;
479*5ffd83dbSDimitry Andric  let GeneratePressureSet = 0;
480*5ffd83dbSDimitry Andric}
481*5ffd83dbSDimitry Andric
482*5ffd83dbSDimitry Andricdef VGPR_HI16 : RegisterClass<"AMDGPU", Reg16Types.types, 16,
483*5ffd83dbSDimitry Andric                              (add (sequence "VGPR%u_HI16", 0, 255))> {
484*5ffd83dbSDimitry Andric  let AllocationPriority = 1;
485*5ffd83dbSDimitry Andric  let Size = 16;
486*5ffd83dbSDimitry Andric  let GeneratePressureSet = 0;
487*5ffd83dbSDimitry Andric}
4888bcb0991SDimitry Andric
4890b57cec5SDimitry Andric// VGPR 32-bit registers
4900b57cec5SDimitry Andric// i16/f16 only on VI+
4918bcb0991SDimitry Andricdef VGPR_32 : RegisterClass<"AMDGPU", !listconcat(Reg32Types.types, Reg16Types.types), 32,
4928bcb0991SDimitry Andric                            (add (sequence "VGPR%u", 0, 255))> {
4930b57cec5SDimitry Andric  let AllocationPriority = 1;
4940b57cec5SDimitry Andric  let Size = 32;
495*5ffd83dbSDimitry Andric  let Weight = 1;
4960b57cec5SDimitry Andric}
4970b57cec5SDimitry Andric
4980b57cec5SDimitry Andric// VGPR 64-bit registers
4998bcb0991SDimitry Andricdef VGPR_64 : SIRegisterTuples<getSubRegs<2>.ret, VGPR_32, 255, 1, 2, "v">;
5000b57cec5SDimitry Andric
5010b57cec5SDimitry Andric// VGPR 96-bit registers
5028bcb0991SDimitry Andricdef VGPR_96 : SIRegisterTuples<getSubRegs<3>.ret, VGPR_32, 255, 1, 3, "v">;
5030b57cec5SDimitry Andric
5040b57cec5SDimitry Andric// VGPR 128-bit registers
5058bcb0991SDimitry Andricdef VGPR_128 : SIRegisterTuples<getSubRegs<4>.ret, VGPR_32, 255, 1, 4, "v">;
5060b57cec5SDimitry Andric
5070b57cec5SDimitry Andric// VGPR 160-bit registers
5088bcb0991SDimitry Andricdef VGPR_160 : SIRegisterTuples<getSubRegs<5>.ret, VGPR_32, 255, 1, 5, "v">;
5090b57cec5SDimitry Andric
510*5ffd83dbSDimitry Andric// VGPR 192-bit registers
511*5ffd83dbSDimitry Andricdef VGPR_192 : SIRegisterTuples<getSubRegs<6>.ret, VGPR_32, 255, 1, 6, "v">;
512*5ffd83dbSDimitry Andric
5130b57cec5SDimitry Andric// VGPR 256-bit registers
5148bcb0991SDimitry Andricdef VGPR_256 : SIRegisterTuples<getSubRegs<8>.ret, VGPR_32, 255, 1, 8, "v">;
5150b57cec5SDimitry Andric
5160b57cec5SDimitry Andric// VGPR 512-bit registers
5178bcb0991SDimitry Andricdef VGPR_512 : SIRegisterTuples<getSubRegs<16>.ret, VGPR_32, 255, 1, 16, "v">;
5180b57cec5SDimitry Andric
5190b57cec5SDimitry Andric// VGPR 1024-bit registers
5208bcb0991SDimitry Andricdef VGPR_1024 : SIRegisterTuples<getSubRegs<32>.ret, VGPR_32, 255, 1, 32, "v">;
5210b57cec5SDimitry Andric
522*5ffd83dbSDimitry Andricdef AGPR_LO16 : RegisterClass<"AMDGPU", Reg16Types.types, 16,
523*5ffd83dbSDimitry Andric                              (add (sequence "AGPR%u_LO16", 0, 255))> {
524*5ffd83dbSDimitry Andric  let isAllocatable = 0;
525*5ffd83dbSDimitry Andric  let Size = 16;
526*5ffd83dbSDimitry Andric  let GeneratePressureSet = 0;
527*5ffd83dbSDimitry Andric}
528*5ffd83dbSDimitry Andric
5290b57cec5SDimitry Andric// AccVGPR 32-bit registers
5300b57cec5SDimitry Andricdef AGPR_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
5318bcb0991SDimitry Andric                            (add (sequence "AGPR%u", 0, 255))> {
5320b57cec5SDimitry Andric  let AllocationPriority = 1;
5330b57cec5SDimitry Andric  let Size = 32;
534*5ffd83dbSDimitry Andric  let Weight = 1;
5350b57cec5SDimitry Andric}
5360b57cec5SDimitry Andric
5370b57cec5SDimitry Andric// AGPR 64-bit registers
5388bcb0991SDimitry Andricdef AGPR_64 : SIRegisterTuples<getSubRegs<2>.ret, AGPR_32, 255, 1, 2, "a">;
5390b57cec5SDimitry Andric
540*5ffd83dbSDimitry Andric// AGPR 96-bit registers
541*5ffd83dbSDimitry Andricdef AGPR_96 : SIRegisterTuples<getSubRegs<3>.ret, AGPR_32, 255, 1, 3, "a">;
542*5ffd83dbSDimitry Andric
5430b57cec5SDimitry Andric// AGPR 128-bit registers
5448bcb0991SDimitry Andricdef AGPR_128 : SIRegisterTuples<getSubRegs<4>.ret, AGPR_32, 255, 1, 4, "a">;
5450b57cec5SDimitry Andric
546*5ffd83dbSDimitry Andric// AGPR 160-bit registers
547*5ffd83dbSDimitry Andricdef AGPR_160 : SIRegisterTuples<getSubRegs<5>.ret, AGPR_32, 255, 1, 5, "a">;
548*5ffd83dbSDimitry Andric
549*5ffd83dbSDimitry Andric// AGPR 192-bit registers
550*5ffd83dbSDimitry Andricdef AGPR_192 : SIRegisterTuples<getSubRegs<6>.ret, AGPR_32, 255, 1, 6, "a">;
551*5ffd83dbSDimitry Andric
552*5ffd83dbSDimitry Andric// AGPR 256-bit registers
553*5ffd83dbSDimitry Andricdef AGPR_256 : SIRegisterTuples<getSubRegs<8>.ret, AGPR_32, 255, 1, 8, "a">;
554*5ffd83dbSDimitry Andric
5550b57cec5SDimitry Andric// AGPR 512-bit registers
5568bcb0991SDimitry Andricdef AGPR_512 : SIRegisterTuples<getSubRegs<16>.ret, AGPR_32, 255, 1, 16, "a">;
5570b57cec5SDimitry Andric
5580b57cec5SDimitry Andric// AGPR 1024-bit registers
5598bcb0991SDimitry Andricdef AGPR_1024 : SIRegisterTuples<getSubRegs<32>.ret, AGPR_32, 255, 1, 32, "a">;
5600b57cec5SDimitry Andric
5610b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
5620b57cec5SDimitry Andric//  Register classes used as source and destination
5630b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
5640b57cec5SDimitry Andric
5650b57cec5SDimitry Andricdef Pseudo_SReg_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
566*5ffd83dbSDimitry Andric  (add FP_REG, SP_REG)> {
5670b57cec5SDimitry Andric  let isAllocatable = 0;
5680b57cec5SDimitry Andric  let CopyCost = -1;
5690b57cec5SDimitry Andric}
5700b57cec5SDimitry Andric
5710b57cec5SDimitry Andricdef Pseudo_SReg_128 : RegisterClass<"AMDGPU", [v4i32, v2i64, v2f64], 32,
5728bcb0991SDimitry Andric  (add PRIVATE_RSRC_REG)> {
5730b57cec5SDimitry Andric  let isAllocatable = 0;
5740b57cec5SDimitry Andric  let CopyCost = -1;
5750b57cec5SDimitry Andric}
5760b57cec5SDimitry Andric
577*5ffd83dbSDimitry Andricdef LDS_DIRECT_CLASS : RegisterClass<"AMDGPU", [i32], 32,
5788bcb0991SDimitry Andric  (add LDS_DIRECT)> {
5790b57cec5SDimitry Andric  let isAllocatable = 0;
5800b57cec5SDimitry Andric  let CopyCost = -1;
5810b57cec5SDimitry Andric}
5820b57cec5SDimitry Andric
583*5ffd83dbSDimitry Andriclet GeneratePressureSet = 0 in {
5840b57cec5SDimitry Andric// Subset of SReg_32 without M0 for SMRD instructions and alike.
5850b57cec5SDimitry Andric// See comments in SIInstructions.td for more info.
5860b57cec5SDimitry Andricdef SReg_32_XM0_XEXEC : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16, i1], 32,
5870b57cec5SDimitry Andric  (add SGPR_32, VCC_LO, VCC_HI, FLAT_SCR_LO, FLAT_SCR_HI, XNACK_MASK_LO, XNACK_MASK_HI,
5880b57cec5SDimitry Andric   SGPR_NULL, TTMP_32, TMA_LO, TMA_HI, TBA_LO, TBA_HI, SRC_SHARED_BASE, SRC_SHARED_LIMIT,
5890b57cec5SDimitry Andric   SRC_PRIVATE_BASE, SRC_PRIVATE_LIMIT, SRC_POPS_EXITING_WAVE_ID,
5908bcb0991SDimitry Andric   SRC_VCCZ, SRC_EXECZ, SRC_SCC)> {
5910b57cec5SDimitry Andric  let AllocationPriority = 10;
5920b57cec5SDimitry Andric}
5930b57cec5SDimitry Andric
594*5ffd83dbSDimitry Andricdef SReg_LO16_XM0_XEXEC : RegisterClass<"AMDGPU", [i16, f16], 16,
595*5ffd83dbSDimitry Andric  (add SGPR_LO16, VCC_LO_LO16, VCC_HI_LO16, FLAT_SCR_LO_LO16, FLAT_SCR_HI_LO16,
596*5ffd83dbSDimitry Andric   XNACK_MASK_LO_LO16, XNACK_MASK_HI_LO16, SGPR_NULL_LO16, TTMP_LO16, TMA_LO_LO16,
597*5ffd83dbSDimitry Andric   TMA_HI_LO16, TBA_LO_LO16, TBA_HI_LO16, SRC_SHARED_BASE_LO16,
598*5ffd83dbSDimitry Andric   SRC_SHARED_LIMIT_LO16, SRC_PRIVATE_BASE_LO16, SRC_PRIVATE_LIMIT_LO16,
599*5ffd83dbSDimitry Andric   SRC_POPS_EXITING_WAVE_ID_LO16, SRC_VCCZ_LO16, SRC_EXECZ_LO16, SRC_SCC_LO16)> {
600*5ffd83dbSDimitry Andric  let Size = 16;
601*5ffd83dbSDimitry Andric  let AllocationPriority = 10;
602*5ffd83dbSDimitry Andric}
603*5ffd83dbSDimitry Andric
6040b57cec5SDimitry Andricdef SReg_32_XEXEC_HI : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16, i1], 32,
6058bcb0991SDimitry Andric  (add SReg_32_XM0_XEXEC, EXEC_LO, M0_CLASS)> {
6060b57cec5SDimitry Andric  let AllocationPriority = 10;
6070b57cec5SDimitry Andric}
6080b57cec5SDimitry Andric
609*5ffd83dbSDimitry Andricdef SReg_LO16_XEXEC_HI : RegisterClass<"AMDGPU", [i16, f16], 16,
610*5ffd83dbSDimitry Andric  (add SReg_LO16_XM0_XEXEC, EXEC_LO_LO16, M0_CLASS_LO16)> {
611*5ffd83dbSDimitry Andric  let Size = 16;
612*5ffd83dbSDimitry Andric  let AllocationPriority = 10;
613*5ffd83dbSDimitry Andric}
614*5ffd83dbSDimitry Andric
6150b57cec5SDimitry Andricdef SReg_32_XM0 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16, i1], 32,
6168bcb0991SDimitry Andric  (add SReg_32_XM0_XEXEC, EXEC_LO, EXEC_HI)> {
6170b57cec5SDimitry Andric  let AllocationPriority = 10;
6180b57cec5SDimitry Andric}
6190b57cec5SDimitry Andric
620*5ffd83dbSDimitry Andricdef SReg_LO16_XM0 : RegisterClass<"AMDGPU", [i16, f16], 16,
621*5ffd83dbSDimitry Andric  (add SReg_LO16_XM0_XEXEC, EXEC_LO_LO16, EXEC_HI_LO16)> {
622*5ffd83dbSDimitry Andric  let Size = 16;
623*5ffd83dbSDimitry Andric  let AllocationPriority = 10;
624*5ffd83dbSDimitry Andric}
625*5ffd83dbSDimitry Andric
626*5ffd83dbSDimitry Andricdef SReg_LO16 : RegisterClass<"AMDGPU", [i16, f16], 16,
627*5ffd83dbSDimitry Andric  (add SGPR_LO16, SReg_LO16_XM0, M0_CLASS_LO16, EXEC_LO_LO16, EXEC_HI_LO16, SReg_LO16_XEXEC_HI)> {
628*5ffd83dbSDimitry Andric  let Size = 16;
629*5ffd83dbSDimitry Andric  let AllocationPriority = 10;
630*5ffd83dbSDimitry Andric}
631*5ffd83dbSDimitry Andric} // End GeneratePressureSet = 0
632*5ffd83dbSDimitry Andric
6330b57cec5SDimitry Andric// Register class for all scalar registers (SGPRs + Special Registers)
6340b57cec5SDimitry Andricdef SReg_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16, i1], 32,
6358bcb0991SDimitry Andric  (add SReg_32_XM0, M0_CLASS, EXEC_LO, EXEC_HI, SReg_32_XEXEC_HI)> {
6360b57cec5SDimitry Andric  let AllocationPriority = 10;
6370b57cec5SDimitry Andric}
6380b57cec5SDimitry Andric
639*5ffd83dbSDimitry Andriclet GeneratePressureSet = 0 in {
640*5ffd83dbSDimitry Andricdef SRegOrLds_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
641*5ffd83dbSDimitry Andric  (add SReg_32, LDS_DIRECT_CLASS)> {
6420b57cec5SDimitry Andric  let isAllocatable = 0;
6430b57cec5SDimitry Andric}
6440b57cec5SDimitry Andric
6450b57cec5SDimitry Andricdef SGPR_64 : RegisterClass<"AMDGPU", [v2i32, i64, v2f32, f64, v4i16, v4f16], 32,
6468bcb0991SDimitry Andric                            (add SGPR_64Regs)> {
6470b57cec5SDimitry Andric  let CopyCost = 1;
6480b57cec5SDimitry Andric  let AllocationPriority = 11;
6490b57cec5SDimitry Andric}
6500b57cec5SDimitry Andric
6510b57cec5SDimitry Andric// CCR (call clobbered registers) SGPR 64-bit registers
6520b57cec5SDimitry Andricdef CCR_SGPR_64 : RegisterClass<"AMDGPU", SGPR_64.RegTypes, 32,
6538bcb0991SDimitry Andric                                (add (trunc SGPR_64, 16))> {
6540b57cec5SDimitry Andric  let CopyCost = SGPR_64.CopyCost;
6550b57cec5SDimitry Andric  let AllocationPriority = SGPR_64.AllocationPriority;
6560b57cec5SDimitry Andric}
6570b57cec5SDimitry Andric
6580b57cec5SDimitry Andricdef TTMP_64 : RegisterClass<"AMDGPU", [v2i32, i64, f64, v4i16, v4f16], 32,
6590b57cec5SDimitry Andric                            (add TTMP_64Regs)> {
6600b57cec5SDimitry Andric  let isAllocatable = 0;
6610b57cec5SDimitry Andric}
6620b57cec5SDimitry Andric
6630b57cec5SDimitry Andricdef SReg_64_XEXEC : RegisterClass<"AMDGPU", [v2i32, i64, v2f32, f64, i1, v4i16, v4f16], 32,
6648bcb0991SDimitry Andric  (add SGPR_64, VCC, FLAT_SCR, XNACK_MASK, TTMP_64, TBA, TMA)> {
6650b57cec5SDimitry Andric  let CopyCost = 1;
6660b57cec5SDimitry Andric  let AllocationPriority = 13;
6670b57cec5SDimitry Andric}
6680b57cec5SDimitry Andric
6690b57cec5SDimitry Andricdef SReg_64 : RegisterClass<"AMDGPU", [v2i32, i64, v2f32, f64, i1, v4i16, v4f16], 32,
6708bcb0991SDimitry Andric  (add SReg_64_XEXEC, EXEC)> {
6710b57cec5SDimitry Andric  let CopyCost = 1;
6720b57cec5SDimitry Andric  let AllocationPriority = 13;
6730b57cec5SDimitry Andric}
6740b57cec5SDimitry Andric
6750b57cec5SDimitry Andricdef SReg_1_XEXEC : RegisterClass<"AMDGPU", [i1], 32,
6760b57cec5SDimitry Andric  (add SReg_64_XEXEC, SReg_32_XM0_XEXEC)> {
6770b57cec5SDimitry Andric  let CopyCost = 1;
6780b57cec5SDimitry Andric  let isAllocatable = 0;
6790b57cec5SDimitry Andric}
6800b57cec5SDimitry Andric
6810b57cec5SDimitry Andricdef SReg_1 : RegisterClass<"AMDGPU", [i1], 32,
6820b57cec5SDimitry Andric  (add SReg_1_XEXEC, EXEC, EXEC_LO)> {
6830b57cec5SDimitry Andric  let CopyCost = 1;
6840b57cec5SDimitry Andric  let isAllocatable = 0;
6850b57cec5SDimitry Andric}
6860b57cec5SDimitry Andric
6870b57cec5SDimitry Andric// Requires 2 s_mov_b64 to copy
6880b57cec5SDimitry Andriclet CopyCost = 2 in {
6890b57cec5SDimitry Andric
6900b57cec5SDimitry Andric// There are no 3-component scalar instructions, but this is needed
6910b57cec5SDimitry Andric// for symmetry with VGPRs.
6920b57cec5SDimitry Andricdef SGPR_96 : RegisterClass<"AMDGPU", [v3i32, v3f32], 32,
6938bcb0991SDimitry Andric  (add SGPR_96Regs)> {
6940b57cec5SDimitry Andric  let AllocationPriority = 14;
6950b57cec5SDimitry Andric}
6960b57cec5SDimitry Andric
6970b57cec5SDimitry Andricdef SReg_96 : RegisterClass<"AMDGPU", [v3i32, v3f32], 32,
6988bcb0991SDimitry Andric  (add SGPR_96)> {
6990b57cec5SDimitry Andric  let AllocationPriority = 14;
7000b57cec5SDimitry Andric}
7010b57cec5SDimitry Andric
7020b57cec5SDimitry Andricdef SGPR_128 : RegisterClass<"AMDGPU", [v4i32, v4f32, v2i64], 32,
7038bcb0991SDimitry Andric                             (add SGPR_128Regs)> {
7040b57cec5SDimitry Andric  let AllocationPriority = 15;
7050b57cec5SDimitry Andric}
7060b57cec5SDimitry Andric
7070b57cec5SDimitry Andricdef TTMP_128 : RegisterClass<"AMDGPU", [v4i32, v4f32, v2i64], 32,
7080b57cec5SDimitry Andric                             (add TTMP_128Regs)> {
7090b57cec5SDimitry Andric  let isAllocatable = 0;
7100b57cec5SDimitry Andric}
7110b57cec5SDimitry Andric
7120b57cec5SDimitry Andricdef SReg_128 : RegisterClass<"AMDGPU", [v4i32, v4f32, v2i64, v2f64], 32,
7138bcb0991SDimitry Andric                             (add SGPR_128, TTMP_128)> {
7148bcb0991SDimitry Andric  let isAllocatable = 0;
7150b57cec5SDimitry Andric}
7160b57cec5SDimitry Andric
7170b57cec5SDimitry Andric} // End CopyCost = 2
7180b57cec5SDimitry Andric
7190b57cec5SDimitry Andric// There are no 5-component scalar instructions, but this is needed
7200b57cec5SDimitry Andric// for symmetry with VGPRs.
7210b57cec5SDimitry Andricdef SGPR_160 : RegisterClass<"AMDGPU", [v5i32, v5f32], 32,
7228bcb0991SDimitry Andric                             (add SGPR_160Regs)> {
7230b57cec5SDimitry Andric  let AllocationPriority = 16;
7240b57cec5SDimitry Andric}
7250b57cec5SDimitry Andric
7260b57cec5SDimitry Andricdef SReg_160 : RegisterClass<"AMDGPU", [v5i32, v5f32], 32,
7278bcb0991SDimitry Andric                             (add SGPR_160)> {
728*5ffd83dbSDimitry Andric  // FIXME: Should be isAllocatable = 0, but that causes all TableGen-generated
729*5ffd83dbSDimitry Andric  // subclasses of SGPR_160 to be marked unallocatable too.
7300b57cec5SDimitry Andric}
7310b57cec5SDimitry Andric
732*5ffd83dbSDimitry Andricdef SGPR_192 : RegisterClass<"AMDGPU", [untyped], 32, (add SGPR_192Regs)> {
733*5ffd83dbSDimitry Andric  let Size = 192;
7340b57cec5SDimitry Andric  let AllocationPriority = 17;
7350b57cec5SDimitry Andric}
7360b57cec5SDimitry Andric
737*5ffd83dbSDimitry Andricdef SReg_192 : RegisterClass<"AMDGPU", [untyped], 32, (add SGPR_192)> {
738*5ffd83dbSDimitry Andric  let Size = 192;
7390b57cec5SDimitry Andric  let isAllocatable = 0;
7400b57cec5SDimitry Andric}
7410b57cec5SDimitry Andric
742*5ffd83dbSDimitry Andricdef SGPR_256 : RegisterClass<"AMDGPU", [v8i32, v8f32, v4i64, v4f64], 32, (add SGPR_256Regs)> {
7430b57cec5SDimitry Andric  let AllocationPriority = 18;
7440b57cec5SDimitry Andric}
7450b57cec5SDimitry Andric
746*5ffd83dbSDimitry Andricdef TTMP_256 : RegisterClass<"AMDGPU", [v8i32, v8f32, v4i64, v4f64], 32, (add TTMP_256Regs)> {
747*5ffd83dbSDimitry Andric  let isAllocatable = 0;
748*5ffd83dbSDimitry Andric}
749*5ffd83dbSDimitry Andric
750*5ffd83dbSDimitry Andricdef SReg_256 : RegisterClass<"AMDGPU", [v8i32, v8f32, v4i64, v4f64], 32,
751*5ffd83dbSDimitry Andric                             (add SGPR_256, TTMP_256)> {
752*5ffd83dbSDimitry Andric  // Requires 4 s_mov_b64 to copy
753*5ffd83dbSDimitry Andric  let CopyCost = 4;
754*5ffd83dbSDimitry Andric  let isAllocatable = 0;
755*5ffd83dbSDimitry Andric}
756*5ffd83dbSDimitry Andric
757*5ffd83dbSDimitry Andricdef SGPR_512 : RegisterClass<"AMDGPU", [v16i32, v16f32, v8i64, v8f64], 32,
758*5ffd83dbSDimitry Andric                             (add SGPR_512Regs)> {
759*5ffd83dbSDimitry Andric  let AllocationPriority = 19;
760*5ffd83dbSDimitry Andric}
761*5ffd83dbSDimitry Andric
762*5ffd83dbSDimitry Andricdef TTMP_512 : RegisterClass<"AMDGPU", [v16i32, v16f32, v8i64, v8f64], 32,
7630b57cec5SDimitry Andric                             (add TTMP_512Regs)> {
7640b57cec5SDimitry Andric  let isAllocatable = 0;
7650b57cec5SDimitry Andric}
7660b57cec5SDimitry Andric
767*5ffd83dbSDimitry Andricdef SReg_512 : RegisterClass<"AMDGPU", [v16i32, v16f32, v8i64, v8f64], 32,
7688bcb0991SDimitry Andric                             (add SGPR_512, TTMP_512)> {
7690b57cec5SDimitry Andric  // Requires 8 s_mov_b64 to copy
7700b57cec5SDimitry Andric  let CopyCost = 8;
771*5ffd83dbSDimitry Andric  let isAllocatable = 0;
7720b57cec5SDimitry Andric}
7730b57cec5SDimitry Andric
7740b57cec5SDimitry Andricdef VRegOrLds_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
7758bcb0991SDimitry Andric                                 (add VGPR_32, LDS_DIRECT_CLASS)> {
7760b57cec5SDimitry Andric  let isAllocatable = 0;
7770b57cec5SDimitry Andric}
7780b57cec5SDimitry Andric
779*5ffd83dbSDimitry Andricdef SGPR_1024 : RegisterClass<"AMDGPU", [v32i32, v32f32, v16i64, v16f64], 32,
7808bcb0991SDimitry Andric                              (add SGPR_1024Regs)> {
781*5ffd83dbSDimitry Andric  let AllocationPriority = 20;
7820b57cec5SDimitry Andric}
7830b57cec5SDimitry Andric
784*5ffd83dbSDimitry Andricdef SReg_1024 : RegisterClass<"AMDGPU", [v32i32, v32f32, v16i64, v16f64], 32,
7858bcb0991SDimitry Andric                              (add SGPR_1024)> {
7860b57cec5SDimitry Andric  let CopyCost = 16;
787*5ffd83dbSDimitry Andric  let isAllocatable = 0;
7880b57cec5SDimitry Andric}
7890b57cec5SDimitry Andric
790*5ffd83dbSDimitry Andric// Register class for all vector registers (VGPRs + Interpolation Registers)
791*5ffd83dbSDimitry Andricclass VRegClass<int numRegs, list<ValueType> regTypes, dag regList> :
792*5ffd83dbSDimitry Andric    RegisterClass<"AMDGPU", regTypes, 32, regList> {
793*5ffd83dbSDimitry Andric  let Size = !mul(numRegs, 32);
7940b57cec5SDimitry Andric
795*5ffd83dbSDimitry Andric  // Requires n v_mov_b32 to copy
796*5ffd83dbSDimitry Andric  let CopyCost = numRegs;
797*5ffd83dbSDimitry Andric  let AllocationPriority = numRegs;
798*5ffd83dbSDimitry Andric  let Weight = numRegs;
7990b57cec5SDimitry Andric}
8000b57cec5SDimitry Andric
801*5ffd83dbSDimitry Andricdef VReg_64 : VRegClass<2, [i64, f64, v2i32, v2f32, v4f16, v4i16, p0, p1, p4],
802*5ffd83dbSDimitry Andric                        (add VGPR_64)>;
803*5ffd83dbSDimitry Andricdef VReg_96 : VRegClass<3, [v3i32, v3f32], (add VGPR_96)>;
804*5ffd83dbSDimitry Andricdef VReg_128 : VRegClass<4, [v4i32, v4f32, v2i64, v2f64, i128], (add VGPR_128)>;
805*5ffd83dbSDimitry Andricdef VReg_160 : VRegClass<5, [v5i32, v5f32], (add VGPR_160)>;
806*5ffd83dbSDimitry Andricdef VReg_192 : VRegClass<6, [untyped], (add VGPR_192)>;
807*5ffd83dbSDimitry Andricdef VReg_256 : VRegClass<8, [v8i32, v8f32, v4i64, v4f64], (add VGPR_256)>;
808*5ffd83dbSDimitry Andricdef VReg_512 : VRegClass<16, [v16i32, v16f32, v8i64, v8f64], (add VGPR_512)>;
809*5ffd83dbSDimitry Andricdef VReg_1024 : VRegClass<32, [v32i32, v32f32, v16i64, v16f64], (add VGPR_1024)>;
8100b57cec5SDimitry Andric
811*5ffd83dbSDimitry Andricclass ARegClass<int numRegs, list<ValueType> regTypes, dag regList> :
812*5ffd83dbSDimitry Andric    VRegClass<numRegs, regTypes, regList> {
813*5ffd83dbSDimitry Andric  // Requires n v_accvgpr_write and n v_accvgpr_read to copy + burn 1 vgpr
814*5ffd83dbSDimitry Andric  let CopyCost = !add(numRegs, numRegs, 1);
8150b57cec5SDimitry Andric}
8160b57cec5SDimitry Andric
817*5ffd83dbSDimitry Andricdef AReg_64 : ARegClass<2, [i64, f64, v2i32, v2f32, v4f16, v4i16],
818*5ffd83dbSDimitry Andric                        (add AGPR_64)>;
819*5ffd83dbSDimitry Andricdef AReg_96 : ARegClass<3, [v3i32, v3f32], (add AGPR_96)>;
820*5ffd83dbSDimitry Andricdef AReg_128 : ARegClass<4, [v4i32, v4f32, v2i64, v2f64], (add AGPR_128)>;
821*5ffd83dbSDimitry Andricdef AReg_160 : ARegClass<5, [v5i32, v5f32], (add AGPR_160)>;
822*5ffd83dbSDimitry Andricdef AReg_192 : ARegClass<6, [untyped], (add AGPR_192)>;
823*5ffd83dbSDimitry Andricdef AReg_256 : ARegClass<8, [v8i32, v8f32, v4i64, v4f64], (add AGPR_256)>;
824*5ffd83dbSDimitry Andricdef AReg_512 : ARegClass<16, [v16i32, v16f32, v8i64, v8f64], (add AGPR_512)>;
825*5ffd83dbSDimitry Andricdef AReg_1024 : ARegClass<32, [v32i32, v32f32, v16i64, v16f64], (add AGPR_1024)>;
8260b57cec5SDimitry Andric
827*5ffd83dbSDimitry Andric} // End GeneratePressureSet = 0
828480093f4SDimitry Andric
829480093f4SDimitry Andric// This is not a real register. This is just to have a register to add
830480093f4SDimitry Andric// to VReg_1 that does not alias any real register that would
831480093f4SDimitry Andric// introduce inferred register classess.
832480093f4SDimitry Andricdef ARTIFICIAL_VGPR : SIReg <"invalid vgpr", 0> {
833480093f4SDimitry Andric  let isArtificial = 1;
834480093f4SDimitry Andric}
835480093f4SDimitry Andric
836*5ffd83dbSDimitry Andriclet GeneratePressureSet = 0 in {
837480093f4SDimitry Andric// FIXME: Should specify an empty set for this. No register should
838480093f4SDimitry Andric// ever be allocated using VReg_1. This is a hack for SelectionDAG
839480093f4SDimitry Andric// that should always be lowered by SILowerI1Copies. TableGen crashes
840480093f4SDimitry Andric// on an empty register set, but also sorts register classes based on
841480093f4SDimitry Andric// the number of registerss in them. Add only one register so this is
842480093f4SDimitry Andric// sorted to the end and not preferred over VGPR_32.
843480093f4SDimitry Andricdef VReg_1 : RegisterClass<"AMDGPU", [i1], 32, (add ARTIFICIAL_VGPR)> {
8448bcb0991SDimitry Andric  let Size = 1;
8450b57cec5SDimitry Andric}
8460b57cec5SDimitry Andric
8470b57cec5SDimitry Andricdef VS_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
8488bcb0991SDimitry Andric                          (add VGPR_32, SReg_32, LDS_DIRECT_CLASS)> {
8490b57cec5SDimitry Andric  let isAllocatable = 0;
8500b57cec5SDimitry Andric}
8510b57cec5SDimitry Andric
8528bcb0991SDimitry Andricdef VS_64 : RegisterClass<"AMDGPU", [i64, f64], 32, (add VReg_64, SReg_64)> {
8530b57cec5SDimitry Andric  let isAllocatable = 0;
8540b57cec5SDimitry Andric}
8550b57cec5SDimitry Andric
8560b57cec5SDimitry Andricdef AV_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
8578bcb0991SDimitry Andric                          (add AGPR_32, VGPR_32)> {
8580b57cec5SDimitry Andric  let isAllocatable = 0;
8590b57cec5SDimitry Andric}
8600b57cec5SDimitry Andric
8610b57cec5SDimitry Andricdef AV_64 : RegisterClass<"AMDGPU", [i64, f64, v4f16], 32,
8628bcb0991SDimitry Andric                          (add AReg_64, VReg_64)> {
8630b57cec5SDimitry Andric  let isAllocatable = 0;
8640b57cec5SDimitry Andric}
865*5ffd83dbSDimitry Andric} // End GeneratePressureSet = 0
8660b57cec5SDimitry Andric
8670b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
8680b57cec5SDimitry Andric//  Register operands
8690b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
8700b57cec5SDimitry Andric
8710b57cec5SDimitry Andricclass RegImmMatcher<string name> : AsmOperandClass {
8720b57cec5SDimitry Andric  let Name = name;
8730b57cec5SDimitry Andric  let RenderMethod = "addRegOrImmOperands";
8740b57cec5SDimitry Andric}
8750b57cec5SDimitry Andric
8760b57cec5SDimitry Andricmulticlass SIRegOperand32 <string rc, string MatchName, string opType,
8770b57cec5SDimitry Andric                           string rc_suffix = "_32"> {
8780b57cec5SDimitry Andric  let OperandNamespace = "AMDGPU" in {
8790b57cec5SDimitry Andric    def _b16 : RegisterOperand<!cast<RegisterClass>(rc#rc_suffix)> {
8800b57cec5SDimitry Andric      let OperandType = opType#"_INT16";
8810b57cec5SDimitry Andric      let ParserMatchClass = RegImmMatcher<MatchName#"B16">;
8820b57cec5SDimitry Andric      let DecoderMethod = "decodeOperand_VSrc16";
8830b57cec5SDimitry Andric    }
8840b57cec5SDimitry Andric
8850b57cec5SDimitry Andric    def _f16 : RegisterOperand<!cast<RegisterClass>(rc#rc_suffix)> {
8860b57cec5SDimitry Andric      let OperandType = opType#"_FP16";
8870b57cec5SDimitry Andric      let ParserMatchClass = RegImmMatcher<MatchName#"F16">;
8880b57cec5SDimitry Andric      let DecoderMethod = "decodeOperand_" # rc # "_16";
8890b57cec5SDimitry Andric    }
8900b57cec5SDimitry Andric
8910b57cec5SDimitry Andric    def _b32 : RegisterOperand<!cast<RegisterClass>(rc#rc_suffix)> {
8920b57cec5SDimitry Andric      let OperandType = opType#"_INT32";
8930b57cec5SDimitry Andric      let ParserMatchClass = RegImmMatcher<MatchName#"B32">;
8940b57cec5SDimitry Andric      let DecoderMethod = "decodeOperand_" # rc # rc_suffix;
8950b57cec5SDimitry Andric    }
8960b57cec5SDimitry Andric
8970b57cec5SDimitry Andric    def _f32 : RegisterOperand<!cast<RegisterClass>(rc#rc_suffix)> {
8980b57cec5SDimitry Andric      let OperandType = opType#"_FP32";
8990b57cec5SDimitry Andric      let ParserMatchClass = RegImmMatcher<MatchName#"F32">;
9000b57cec5SDimitry Andric      let DecoderMethod = "decodeOperand_" # rc # rc_suffix;
9010b57cec5SDimitry Andric    }
9020b57cec5SDimitry Andric
9030b57cec5SDimitry Andric    def _v2b16 : RegisterOperand<!cast<RegisterClass>(rc#rc_suffix)> {
9040b57cec5SDimitry Andric      let OperandType = opType#"_V2INT16";
9050b57cec5SDimitry Andric      let ParserMatchClass = RegImmMatcher<MatchName#"V2B16">;
9060b57cec5SDimitry Andric      let DecoderMethod = "decodeOperand_VSrcV216";
9070b57cec5SDimitry Andric    }
9080b57cec5SDimitry Andric
9090b57cec5SDimitry Andric    def _v2f16 : RegisterOperand<!cast<RegisterClass>(rc#rc_suffix)> {
9100b57cec5SDimitry Andric      let OperandType = opType#"_V2FP16";
9110b57cec5SDimitry Andric      let ParserMatchClass = RegImmMatcher<MatchName#"V2F16">;
9120b57cec5SDimitry Andric      let DecoderMethod = "decodeOperand_VSrcV216";
9130b57cec5SDimitry Andric    }
9140b57cec5SDimitry Andric  }
9150b57cec5SDimitry Andric}
9160b57cec5SDimitry Andric
9170b57cec5SDimitry Andricmulticlass SIRegOperand <string rc, string MatchName, string opType> :
9180b57cec5SDimitry Andric  SIRegOperand32<rc, MatchName, opType> {
9190b57cec5SDimitry Andric  let OperandNamespace = "AMDGPU" in {
9200b57cec5SDimitry Andric    def _b64 : RegisterOperand<!cast<RegisterClass>(rc#"_64")> {
9210b57cec5SDimitry Andric      let OperandType = opType#"_INT64";
9220b57cec5SDimitry Andric      let ParserMatchClass = RegImmMatcher<MatchName#"B64">;
9230b57cec5SDimitry Andric    }
9240b57cec5SDimitry Andric
9250b57cec5SDimitry Andric    def _f64 : RegisterOperand<!cast<RegisterClass>(rc#"_64")> {
9260b57cec5SDimitry Andric      let OperandType = opType#"_FP64";
9270b57cec5SDimitry Andric      let ParserMatchClass = RegImmMatcher<MatchName#"F64">;
9280b57cec5SDimitry Andric    }
9290b57cec5SDimitry Andric  }
9300b57cec5SDimitry Andric}
9310b57cec5SDimitry Andric
9320b57cec5SDimitry Andric// FIXME: 64-bit sources can sometimes use 32-bit constants.
9330b57cec5SDimitry Andricmulticlass RegImmOperand <string rc, string MatchName>
9340b57cec5SDimitry Andric  : SIRegOperand<rc, MatchName, "OPERAND_REG_IMM">;
9350b57cec5SDimitry Andric
9360b57cec5SDimitry Andricmulticlass RegInlineOperand <string rc, string MatchName>
9370b57cec5SDimitry Andric  : SIRegOperand<rc, MatchName, "OPERAND_REG_INLINE_C">;
9380b57cec5SDimitry Andric
9390b57cec5SDimitry Andricmulticlass RegInlineOperand32 <string rc, string MatchName,
9400b57cec5SDimitry Andric                               string rc_suffix = "_32">
9410b57cec5SDimitry Andric  : SIRegOperand32<rc, MatchName, "OPERAND_REG_INLINE_C", rc_suffix>;
9420b57cec5SDimitry Andric
9430b57cec5SDimitry Andricmulticlass RegInlineOperandAC <string rc, string MatchName,
9440b57cec5SDimitry Andric                               string rc_suffix = "_32">
9450b57cec5SDimitry Andric  : SIRegOperand32<rc, MatchName, "OPERAND_REG_INLINE_AC", rc_suffix>;
9460b57cec5SDimitry Andric
9470b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
9480b57cec5SDimitry Andric//  SSrc_* Operands with an SGPR or a 32-bit immediate
9490b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
9500b57cec5SDimitry Andric
9510b57cec5SDimitry Andricdefm SSrc : RegImmOperand<"SReg", "SSrc">;
9520b57cec5SDimitry Andric
9530b57cec5SDimitry Andricdef SSrcOrLds_b32 : RegisterOperand<SRegOrLds_32> {
9540b57cec5SDimitry Andric  let OperandNamespace = "AMDGPU";
9550b57cec5SDimitry Andric  let OperandType = "OPERAND_REG_IMM_INT32";
9560b57cec5SDimitry Andric  let ParserMatchClass = RegImmMatcher<"SSrcOrLdsB32">;
9570b57cec5SDimitry Andric}
9580b57cec5SDimitry Andric
9590b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
9600b57cec5SDimitry Andric//  SCSrc_* Operands with an SGPR or a inline constant
9610b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
9620b57cec5SDimitry Andric
9630b57cec5SDimitry Andricdefm SCSrc : RegInlineOperand<"SReg", "SCSrc"> ;
9640b57cec5SDimitry Andric
9650b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
9660b57cec5SDimitry Andric//  VSrc_* Operands with an SGPR, VGPR or a 32-bit immediate
9670b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
9680b57cec5SDimitry Andric
9690b57cec5SDimitry Andricdefm VSrc : RegImmOperand<"VS", "VSrc">;
9700b57cec5SDimitry Andric
9710b57cec5SDimitry Andricdef VSrc_128 : RegisterOperand<VReg_128> {
9720b57cec5SDimitry Andric  let DecoderMethod = "DecodeVS_128RegisterClass";
9730b57cec5SDimitry Andric}
9740b57cec5SDimitry Andric
9750b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
9760b57cec5SDimitry Andric//  VSrc_* Operands with an VGPR
9770b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
9780b57cec5SDimitry Andric
9790b57cec5SDimitry Andric// This is for operands with the enum(9), VSrc encoding restriction,
9800b57cec5SDimitry Andric// but only allows VGPRs.
9810b57cec5SDimitry Andricdef VRegSrc_32 : RegisterOperand<VGPR_32> {
9820b57cec5SDimitry Andric  //let ParserMatchClass = RegImmMatcher<"VRegSrc32">;
9830b57cec5SDimitry Andric  let DecoderMethod = "DecodeVS_32RegisterClass";
9840b57cec5SDimitry Andric}
9850b57cec5SDimitry Andric
9860b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
9870b57cec5SDimitry Andric//  ASrc_* Operands with an AccVGPR
9880b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
9890b57cec5SDimitry Andric
9900b57cec5SDimitry Andricdef ARegSrc_32 : RegisterOperand<AGPR_32> {
9910b57cec5SDimitry Andric  let DecoderMethod = "DecodeAGPR_32RegisterClass";
9920b57cec5SDimitry Andric  let EncoderMethod = "getAVOperandEncoding";
9930b57cec5SDimitry Andric}
9940b57cec5SDimitry Andric
9950b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
9960b57cec5SDimitry Andric//  VCSrc_* Operands with an SGPR, VGPR or an inline constant
9970b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
9980b57cec5SDimitry Andric
9990b57cec5SDimitry Andricdefm VCSrc : RegInlineOperand<"VS", "VCSrc">;
10000b57cec5SDimitry Andric
10010b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
10020b57cec5SDimitry Andric//  VISrc_* Operands with a VGPR or an inline constant
10030b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
10040b57cec5SDimitry Andric
10050b57cec5SDimitry Andricdefm VISrc : RegInlineOperand32<"VGPR", "VISrc">;
10060b57cec5SDimitry Andric
10070b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
10080b57cec5SDimitry Andric//  AVSrc_* Operands with an AGPR or VGPR
10090b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
10100b57cec5SDimitry Andric
10110b57cec5SDimitry Andricdef AVSrc_32 : RegisterOperand<AV_32> {
10120b57cec5SDimitry Andric  let DecoderMethod = "DecodeAV_32RegisterClass";
10130b57cec5SDimitry Andric  let EncoderMethod = "getAVOperandEncoding";
10140b57cec5SDimitry Andric}
10150b57cec5SDimitry Andric
10160b57cec5SDimitry Andricdef AVSrc_64 : RegisterOperand<AV_64> {
10170b57cec5SDimitry Andric  let DecoderMethod = "DecodeAV_64RegisterClass";
10180b57cec5SDimitry Andric  let EncoderMethod = "getAVOperandEncoding";
10190b57cec5SDimitry Andric}
10200b57cec5SDimitry Andric
10210b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
10220b57cec5SDimitry Andric//  ACSrc_* Operands with an AGPR or an inline constant
10230b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
10240b57cec5SDimitry Andric
10250b57cec5SDimitry Andricdefm AISrc      : RegInlineOperandAC<"AGPR", "AISrc">;
10260b57cec5SDimitry Andricdefm AISrc_128  : RegInlineOperandAC<"AReg", "AISrc_128",  "_128">;
10270b57cec5SDimitry Andricdefm AISrc_512  : RegInlineOperandAC<"AReg", "AISrc_512",  "_512">;
10280b57cec5SDimitry Andricdefm AISrc_1024 : RegInlineOperandAC<"AReg", "AISrc_1024", "_1024">;
1029