xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/BUFInstructions.td (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
15ffd83dbSDimitry Andric//===-- BUFInstructions.td - Buffer Instruction Definitions ---------------===//
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
90eae32dcSDimitry Andricdef MUBUFAddr64 : ComplexPattern<iPTR, 4, "SelectMUBUFAddr64">;
100eae32dcSDimitry Andricdef MUBUFOffset : ComplexPattern<iPTR, 3, "SelectMUBUFOffset">;
110b57cec5SDimitry Andric
120eae32dcSDimitry Andricdef MUBUFScratchOffen : ComplexPattern<iPTR, 4, "SelectMUBUFScratchOffen", [], [SDNPWantParent]>;
130eae32dcSDimitry Andricdef MUBUFScratchOffset : ComplexPattern<iPTR, 3, "SelectMUBUFScratchOffset", [], [SDNPWantParent], 20>;
140b57cec5SDimitry Andric
150b57cec5SDimitry Andricdef BUFAddrKind {
160b57cec5SDimitry Andric  int Offset = 0;
170b57cec5SDimitry Andric  int OffEn  = 1;
180b57cec5SDimitry Andric  int IdxEn  = 2;
190b57cec5SDimitry Andric  int BothEn = 3;
200b57cec5SDimitry Andric  int Addr64 = 4;
210b57cec5SDimitry Andric}
220b57cec5SDimitry Andric
230b57cec5SDimitry Andricclass getAddrName<int addrKind> {
240b57cec5SDimitry Andric  string ret =
250b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Offset), "offset",
260b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.OffEn),  "offen",
270b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.IdxEn),  "idxen",
280b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.BothEn), "bothen",
290b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Addr64), "addr64",
300b57cec5SDimitry Andric    "")))));
310b57cec5SDimitry Andric}
320b57cec5SDimitry Andric
330b57cec5SDimitry Andricclass MUBUFAddr64Table <bit is_addr64, string Name> {
340b57cec5SDimitry Andric  bit IsAddr64 = is_addr64;
350b57cec5SDimitry Andric  string OpName = Name;
360b57cec5SDimitry Andric}
370b57cec5SDimitry Andric
380b57cec5SDimitry Andricclass MTBUFAddr64Table <bit is_addr64, string Name> {
390b57cec5SDimitry Andric  bit IsAddr64 = is_addr64;
400b57cec5SDimitry Andric  string OpName = Name;
410b57cec5SDimitry Andric}
420b57cec5SDimitry Andric
43bdd1243dSDimitry Andric
440b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
45bdd1243dSDimitry Andric// BUF class (base class for MTBUF and MUBUF pseudos)
460b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
470b57cec5SDimitry Andric
48bdd1243dSDimitry Andricclass BUF_Pseudo <string opName, dag outs, dag ins,
490b57cec5SDimitry Andric                    string asmOps, list<dag> pattern=[]> :
500b57cec5SDimitry Andric  InstSI<outs, ins, "", pattern>,
510b57cec5SDimitry Andric  SIMCInstr<opName, SIEncodingFamily.NONE> {
520b57cec5SDimitry Andric
530b57cec5SDimitry Andric  let isPseudo = 1;
540b57cec5SDimitry Andric  let isCodeGenOnly = 1;
550b57cec5SDimitry Andric  let Size = 8;
560b57cec5SDimitry Andric  let UseNamedOperandTable = 1;
570b57cec5SDimitry Andric
580b57cec5SDimitry Andric  string Mnemonic = opName;
590b57cec5SDimitry Andric  string AsmOperands = asmOps;
600b57cec5SDimitry Andric
618bcb0991SDimitry Andric  Instruction Opcode = !cast<Instruction>(NAME);
62bdd1243dSDimitry Andric
638bcb0991SDimitry Andric
640b57cec5SDimitry Andric  let VM_CNT = 1;
650b57cec5SDimitry Andric  let EXP_CNT = 1;
66bdd1243dSDimitry Andric
670b57cec5SDimitry Andric  let Uses = [EXEC];
680b57cec5SDimitry Andric  let hasSideEffects = 0;
690b57cec5SDimitry Andric  let SchedRW = [WriteVMEM];
700b57cec5SDimitry Andric
71bdd1243dSDimitry Andric
720b57cec5SDimitry Andric
730b57cec5SDimitry Andric  bits<1> offen       = 0;
740b57cec5SDimitry Andric  bits<1> idxen       = 0;
750b57cec5SDimitry Andric  bits<1> addr64      = 0;
76bdd1243dSDimitry Andric  bits<1> lds         = 0;
77bdd1243dSDimitry Andric  bits<1> has_vdata   = !not(lds);
780b57cec5SDimitry Andric  bits<1> has_vaddr   = 1;
790b57cec5SDimitry Andric  bits<1> has_glc     = 1;
800b57cec5SDimitry Andric  bits<1> has_dlc     = 1;
810b57cec5SDimitry Andric  bits<1> glc_value   = 0; // the value for glc if no such operand
820b57cec5SDimitry Andric  bits<1> dlc_value   = 0; // the value for dlc if no such operand
830b57cec5SDimitry Andric  bits<1> has_srsrc   = 1;
840b57cec5SDimitry Andric  bits<1> has_soffset = 1;
850b57cec5SDimitry Andric  bits<1> has_offset  = 1;
860b57cec5SDimitry Andric  bits<1> has_slc     = 1;
87bdd1243dSDimitry Andric  bits<1> tfe         = ?;
888bcb0991SDimitry Andric  bits<4> elements    = 0;
89fe6060f1SDimitry Andric  bits<1> has_sccb    = 1;
90fe6060f1SDimitry Andric  bits<1> sccb_value  = 0;
91bdd1243dSDimitry Andric  bits<1> IsBufferInv = 0;
92bdd1243dSDimitry Andric}
93bdd1243dSDimitry Andric
94bdd1243dSDimitry Andric
95bdd1243dSDimitry Andric
96bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
97bdd1243dSDimitry Andric// MTBUF classes
98bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
99bdd1243dSDimitry Andric
100bdd1243dSDimitry Andricclass MTBUFGetBaseOpcode<string Op> {
101bdd1243dSDimitry Andric  string ret = !subst("FORMAT_XY", "FORMAT_X",
102bdd1243dSDimitry Andric    !subst("FORMAT_XYZ", "FORMAT_X",
103bdd1243dSDimitry Andric    !subst("FORMAT_XYZW", "FORMAT_X", Op)));
104bdd1243dSDimitry Andric}
105bdd1243dSDimitry Andric
106bdd1243dSDimitry Andric
107bdd1243dSDimitry Andricclass MTBUF_Pseudo <string opName, dag outs, dag ins,
108bdd1243dSDimitry Andric                    string asmOps, list<dag> pattern=[]> :
109bdd1243dSDimitry Andric  BUF_Pseudo <opName, outs, ins, asmOps, pattern> {
110bdd1243dSDimitry Andric
111bdd1243dSDimitry Andric  Instruction BaseOpcode = !cast<Instruction>(MTBUFGetBaseOpcode<NAME>.ret);
112bdd1243dSDimitry Andric  let MTBUF = 1;
1130b57cec5SDimitry Andric}
1140b57cec5SDimitry Andric
11581ad6265SDimitry Andricclass MTBUF_Real <MTBUF_Pseudo ps, string real_name = ps.Mnemonic> :
11681ad6265SDimitry Andric  InstSI <ps.OutOperandList, ps.InOperandList, real_name # ps.AsmOperands, []> {
1170b57cec5SDimitry Andric
1180b57cec5SDimitry Andric  let isPseudo = 0;
1190b57cec5SDimitry Andric  let isCodeGenOnly = 0;
1200b57cec5SDimitry Andric
121fe6060f1SDimitry Andric  let VM_CNT = 1;
122fe6060f1SDimitry Andric  let EXP_CNT = 1;
123fe6060f1SDimitry Andric  let MTBUF = 1;
124fe6060f1SDimitry Andric
1250b57cec5SDimitry Andric  // copy relevant pseudo op flags
126e8d8bef9SDimitry Andric  let UseNamedOperandTable = ps.UseNamedOperandTable;
1270b57cec5SDimitry Andric  let SubtargetPredicate = ps.SubtargetPredicate;
1280b57cec5SDimitry Andric  let AsmMatchConverter  = ps.AsmMatchConverter;
1290b57cec5SDimitry Andric  let Constraints        = ps.Constraints;
1300b57cec5SDimitry Andric  let DisableEncoding    = ps.DisableEncoding;
1310b57cec5SDimitry Andric  let TSFlags            = ps.TSFlags;
132fe6060f1SDimitry Andric  let SchedRW            = ps.SchedRW;
133fe6060f1SDimitry Andric  let mayLoad            = ps.mayLoad;
134fe6060f1SDimitry Andric  let mayStore           = ps.mayStore;
135fe6060f1SDimitry Andric  let IsAtomicRet        = ps.IsAtomicRet;
136fe6060f1SDimitry Andric  let IsAtomicNoRet      = ps.IsAtomicNoRet;
1370b57cec5SDimitry Andric
1380b57cec5SDimitry Andric  bits<12> offset;
139fe6060f1SDimitry Andric  bits<5>  cpol;
1400b57cec5SDimitry Andric  bits<7>  format;
1410b57cec5SDimitry Andric  bits<8>  vaddr;
142fe6060f1SDimitry Andric  bits<10> vdata;
1430b57cec5SDimitry Andric  bits<7>  srsrc;
1440b57cec5SDimitry Andric  bits<8>  soffset;
1450b57cec5SDimitry Andric
1460b57cec5SDimitry Andric  bits<4> dfmt = format{3-0};
1470b57cec5SDimitry Andric  bits<3> nfmt = format{6-4};
148fe6060f1SDimitry Andric
149fe6060f1SDimitry Andric  // GFX90A+ only: instruction uses AccVGPR for data
15081ad6265SDimitry Andric  // Bit supersedes tfe.
151fe6060f1SDimitry Andric  bits<1> acc = !if(ps.has_vdata, vdata{9}, 0);
1520b57cec5SDimitry Andric}
1530b57cec5SDimitry Andric
1540b57cec5SDimitry Andricclass getMTBUFInsDA<list<RegisterClass> vdataList,
1550b57cec5SDimitry Andric                    list<RegisterClass> vaddrList=[]> {
1560b57cec5SDimitry Andric  RegisterClass vdataClass = !if(!empty(vdataList), ?, !head(vdataList));
1570b57cec5SDimitry Andric  RegisterClass vaddrClass = !if(!empty(vaddrList), ?, !head(vaddrList));
158fe6060f1SDimitry Andric  RegisterOperand vdata_op = getLdStRegisterOperand<vdataClass>.ret;
159bdd1243dSDimitry Andric
160*06c3fb27SDimitry Andric  dag NonVaddrInputs = (ins SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset, FORMAT:$format, CPol:$cpol, i1imm:$swz);
161bdd1243dSDimitry Andric  dag Inputs = !if(!empty(vaddrList), NonVaddrInputs, !con((ins vaddrClass:$vaddr), NonVaddrInputs));
162bdd1243dSDimitry Andric  dag ret = !if(!empty(vdataList), Inputs, !con((ins vdata_op:$vdata), Inputs));
1630b57cec5SDimitry Andric}
1640b57cec5SDimitry Andric
165bdd1243dSDimitry Andric
1660b57cec5SDimitry Andricclass getMTBUFIns<int addrKind, list<RegisterClass> vdataList=[]> {
1670b57cec5SDimitry Andric  dag ret =
1680b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Offset), getMTBUFInsDA<vdataList>.ret,
1690b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.OffEn),  getMTBUFInsDA<vdataList, [VGPR_32]>.ret,
1700b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.IdxEn),  getMTBUFInsDA<vdataList, [VGPR_32]>.ret,
1710b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.BothEn), getMTBUFInsDA<vdataList, [VReg_64]>.ret,
1720b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Addr64), getMTBUFInsDA<vdataList, [VReg_64]>.ret,
1730b57cec5SDimitry Andric    (ins))))));
1740b57cec5SDimitry Andric}
1750b57cec5SDimitry Andric
1760b57cec5SDimitry Andricclass getMTBUFAsmOps<int addrKind> {
1770b57cec5SDimitry Andric  string Pfx =
178e8d8bef9SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Offset), "off, $srsrc,$format $soffset",
1790b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.OffEn),
180e8d8bef9SDimitry Andric            "$vaddr, $srsrc,$format $soffset offen",
1810b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.IdxEn),
182e8d8bef9SDimitry Andric            "$vaddr, $srsrc,$format $soffset idxen",
1830b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.BothEn),
184e8d8bef9SDimitry Andric            "$vaddr, $srsrc,$format $soffset idxen offen",
1850b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Addr64),
186e8d8bef9SDimitry Andric            "$vaddr, $srsrc,$format $soffset addr64",
1870b57cec5SDimitry Andric    "")))));
188*06c3fb27SDimitry Andric  string ret = " $vdata, " # Pfx # "$offset$cpol";
1890b57cec5SDimitry Andric}
1900b57cec5SDimitry Andric
1910b57cec5SDimitry Andricclass MTBUF_SetupAddr<int addrKind> {
192e8d8bef9SDimitry Andric  bits<1> offen  = !or(!eq(addrKind, BUFAddrKind.OffEn),
193e8d8bef9SDimitry Andric                       !eq(addrKind, BUFAddrKind.BothEn));
1940b57cec5SDimitry Andric
195e8d8bef9SDimitry Andric  bits<1> idxen  = !or(!eq(addrKind, BUFAddrKind.IdxEn),
196e8d8bef9SDimitry Andric                       !eq(addrKind, BUFAddrKind.BothEn));
1970b57cec5SDimitry Andric
198e8d8bef9SDimitry Andric  bits<1> addr64 = !eq(addrKind, BUFAddrKind.Addr64);
1990b57cec5SDimitry Andric
200e8d8bef9SDimitry Andric  bits<1> has_vaddr = !ne(addrKind, BUFAddrKind.Offset);
2010b57cec5SDimitry Andric}
2020b57cec5SDimitry Andric
2030b57cec5SDimitry Andricclass MTBUF_Load_Pseudo <string opName,
2040b57cec5SDimitry Andric                         int addrKind,
2050b57cec5SDimitry Andric                         RegisterClass vdataClass,
2068bcb0991SDimitry Andric                         int elems,
2070b57cec5SDimitry Andric                         list<dag> pattern=[],
2080b57cec5SDimitry Andric                         // Workaround bug bz30254
2090b57cec5SDimitry Andric                         int addrKindCopy = addrKind>
2100b57cec5SDimitry Andric  : MTBUF_Pseudo<opName,
211fe6060f1SDimitry Andric                 (outs getLdStRegisterOperand<vdataClass>.ret:$vdata),
2120b57cec5SDimitry Andric                 getMTBUFIns<addrKindCopy>.ret,
213bdd1243dSDimitry Andric                 getMTBUFAsmOps<addrKindCopy>.ret,
2140b57cec5SDimitry Andric                 pattern>,
2150b57cec5SDimitry Andric    MTBUF_SetupAddr<addrKindCopy> {
2160b57cec5SDimitry Andric  let PseudoInstr = opName # "_" # getAddrName<addrKindCopy>.ret;
2170b57cec5SDimitry Andric  let mayLoad = 1;
2180b57cec5SDimitry Andric  let mayStore = 0;
2198bcb0991SDimitry Andric  let elements = elems;
2200b57cec5SDimitry Andric}
2210b57cec5SDimitry Andric
2220b57cec5SDimitry Andricmulticlass MTBUF_Pseudo_Loads<string opName, RegisterClass vdataClass,
223349cc55cSDimitry Andric                              int elems> {
2240b57cec5SDimitry Andric
225fe6060f1SDimitry Andric  def _OFFSET : MTBUF_Load_Pseudo <opName, BUFAddrKind.Offset, vdataClass, elems>,
2260b57cec5SDimitry Andric                MTBUFAddr64Table<0, NAME>;
2270b57cec5SDimitry Andric
228fe6060f1SDimitry Andric  def _ADDR64 : MTBUF_Load_Pseudo <opName, BUFAddrKind.Addr64, vdataClass, elems>,
2290b57cec5SDimitry Andric                MTBUFAddr64Table<1, NAME>;
2300b57cec5SDimitry Andric
2318bcb0991SDimitry Andric  def _OFFEN  : MTBUF_Load_Pseudo <opName, BUFAddrKind.OffEn, vdataClass, elems>;
2328bcb0991SDimitry Andric  def _IDXEN  : MTBUF_Load_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass, elems>;
2338bcb0991SDimitry Andric  def _BOTHEN : MTBUF_Load_Pseudo <opName, BUFAddrKind.BothEn, vdataClass, elems>;
2340b57cec5SDimitry Andric
2350b57cec5SDimitry Andric  let DisableWQM = 1 in {
2368bcb0991SDimitry Andric    def _OFFSET_exact : MTBUF_Load_Pseudo <opName, BUFAddrKind.Offset, vdataClass, elems>;
2378bcb0991SDimitry Andric    def _OFFEN_exact  : MTBUF_Load_Pseudo <opName, BUFAddrKind.OffEn, vdataClass, elems>;
2388bcb0991SDimitry Andric    def _IDXEN_exact  : MTBUF_Load_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass, elems>;
2398bcb0991SDimitry Andric    def _BOTHEN_exact : MTBUF_Load_Pseudo <opName, BUFAddrKind.BothEn, vdataClass, elems>;
2400b57cec5SDimitry Andric  }
2410b57cec5SDimitry Andric}
2420b57cec5SDimitry Andric
2430b57cec5SDimitry Andricclass MTBUF_Store_Pseudo <string opName,
2440b57cec5SDimitry Andric                          int addrKind,
2450b57cec5SDimitry Andric                          RegisterClass vdataClass,
2468bcb0991SDimitry Andric                          int elems,
2470b57cec5SDimitry Andric                          list<dag> pattern=[],
2480b57cec5SDimitry Andric                          // Workaround bug bz30254
2490b57cec5SDimitry Andric                          int addrKindCopy = addrKind,
2500b57cec5SDimitry Andric                          RegisterClass vdataClassCopy = vdataClass>
2510b57cec5SDimitry Andric  : MTBUF_Pseudo<opName,
2520b57cec5SDimitry Andric                 (outs),
2530b57cec5SDimitry Andric                 getMTBUFIns<addrKindCopy, [vdataClassCopy]>.ret,
254bdd1243dSDimitry Andric                 getMTBUFAsmOps<addrKindCopy>.ret,
2550b57cec5SDimitry Andric                 pattern>,
2560b57cec5SDimitry Andric    MTBUF_SetupAddr<addrKindCopy> {
2570b57cec5SDimitry Andric  let PseudoInstr = opName # "_" # getAddrName<addrKindCopy>.ret;
2580b57cec5SDimitry Andric  let mayLoad = 0;
2590b57cec5SDimitry Andric  let mayStore = 1;
2608bcb0991SDimitry Andric  let elements = elems;
2610b57cec5SDimitry Andric}
2620b57cec5SDimitry Andric
2630b57cec5SDimitry Andricmulticlass MTBUF_Pseudo_Stores<string opName, RegisterClass vdataClass,
264349cc55cSDimitry Andric                               int elems> {
2650b57cec5SDimitry Andric
266fe6060f1SDimitry Andric  def _OFFSET : MTBUF_Store_Pseudo <opName, BUFAddrKind.Offset, vdataClass, elems>,
2670b57cec5SDimitry Andric    MTBUFAddr64Table<0, NAME>;
2680b57cec5SDimitry Andric
269fe6060f1SDimitry Andric  def _ADDR64 : MTBUF_Store_Pseudo <opName, BUFAddrKind.Addr64, vdataClass, elems>,
2700b57cec5SDimitry Andric    MTBUFAddr64Table<1, NAME>;
2710b57cec5SDimitry Andric
2728bcb0991SDimitry Andric  def _OFFEN  : MTBUF_Store_Pseudo <opName, BUFAddrKind.OffEn, vdataClass, elems>;
2738bcb0991SDimitry Andric  def _IDXEN  : MTBUF_Store_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass, elems>;
2748bcb0991SDimitry Andric  def _BOTHEN : MTBUF_Store_Pseudo <opName, BUFAddrKind.BothEn, vdataClass, elems>;
2750b57cec5SDimitry Andric
2760b57cec5SDimitry Andric  let DisableWQM = 1 in {
2778bcb0991SDimitry Andric    def _OFFSET_exact : MTBUF_Store_Pseudo <opName, BUFAddrKind.Offset, vdataClass, elems>;
2788bcb0991SDimitry Andric    def _OFFEN_exact  : MTBUF_Store_Pseudo <opName, BUFAddrKind.OffEn, vdataClass, elems>;
2798bcb0991SDimitry Andric    def _IDXEN_exact  : MTBUF_Store_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass, elems>;
2808bcb0991SDimitry Andric    def _BOTHEN_exact : MTBUF_Store_Pseudo <opName, BUFAddrKind.BothEn, vdataClass, elems>;
2810b57cec5SDimitry Andric  }
2820b57cec5SDimitry Andric}
2830b57cec5SDimitry Andric
2840b57cec5SDimitry Andric
2850b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
2860b57cec5SDimitry Andric// MUBUF classes
2870b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
2880b57cec5SDimitry Andric
2890b57cec5SDimitry Andricclass MUBUFGetBaseOpcode<string Op> {
2900b57cec5SDimitry Andric  string ret = !subst("DWORDX2", "DWORD",
2910b57cec5SDimitry Andric    !subst("DWORDX3", "DWORD",
2920b57cec5SDimitry Andric    !subst("DWORDX4", "DWORD", Op)));
2930b57cec5SDimitry Andric}
2940b57cec5SDimitry Andric
2950b57cec5SDimitry Andricclass MUBUF_Pseudo <string opName, dag outs, dag ins,
2960b57cec5SDimitry Andric                    string asmOps, list<dag> pattern=[]> :
297bdd1243dSDimitry Andric  BUF_Pseudo <opName, outs, ins, asmOps, pattern> {
2980b57cec5SDimitry Andric
2990b57cec5SDimitry Andric  Instruction BaseOpcode = !cast<Instruction>(MUBUFGetBaseOpcode<NAME>.ret);
3000b57cec5SDimitry Andric  let MUBUF = 1;
3010b57cec5SDimitry Andric  let AsmMatchConverter = "cvtMubuf";
3020b57cec5SDimitry Andric}
3030b57cec5SDimitry Andric
30481ad6265SDimitry Andricclass MUBUF_Real <MUBUF_Pseudo ps, string real_name = ps.Mnemonic> :
30581ad6265SDimitry Andric  InstSI <ps.OutOperandList, ps.InOperandList, real_name # ps.AsmOperands, []> {
3060b57cec5SDimitry Andric
3070b57cec5SDimitry Andric  let isPseudo = 0;
3080b57cec5SDimitry Andric  let isCodeGenOnly = 0;
3090b57cec5SDimitry Andric
310fe6060f1SDimitry Andric  let VM_CNT = 1;
311fe6060f1SDimitry Andric  let EXP_CNT = 1;
312fe6060f1SDimitry Andric  let MUBUF = 1;
313fe6060f1SDimitry Andric
3140b57cec5SDimitry Andric  // copy relevant pseudo op flags
3150b57cec5SDimitry Andric  let SubtargetPredicate   = ps.SubtargetPredicate;
3160b57cec5SDimitry Andric  let AsmMatchConverter    = ps.AsmMatchConverter;
317e8d8bef9SDimitry Andric  let OtherPredicates      = ps.OtherPredicates;
3180b57cec5SDimitry Andric  let Constraints          = ps.Constraints;
3190b57cec5SDimitry Andric  let DisableEncoding      = ps.DisableEncoding;
3200b57cec5SDimitry Andric  let TSFlags              = ps.TSFlags;
321e8d8bef9SDimitry Andric  let UseNamedOperandTable = ps.UseNamedOperandTable;
322fe6060f1SDimitry Andric  let SchedRW              = ps.SchedRW;
323fe6060f1SDimitry Andric  let mayLoad              = ps.mayLoad;
324fe6060f1SDimitry Andric  let mayStore             = ps.mayStore;
325fe6060f1SDimitry Andric  let IsAtomicRet          = ps.IsAtomicRet;
326fe6060f1SDimitry Andric  let IsAtomicNoRet        = ps.IsAtomicNoRet;
32781ad6265SDimitry Andric  let VALU                 = ps.VALU;
32881ad6265SDimitry Andric  let LGKM_CNT             = ps.LGKM_CNT;
3290b57cec5SDimitry Andric
3300b57cec5SDimitry Andric  bits<12> offset;
331fe6060f1SDimitry Andric  bits<5>  cpol;
3320b57cec5SDimitry Andric  bits<8>  vaddr;
333fe6060f1SDimitry Andric  bits<10> vdata;
3340b57cec5SDimitry Andric  bits<7>  srsrc;
3350b57cec5SDimitry Andric  bits<8>  soffset;
336fe6060f1SDimitry Andric
337fe6060f1SDimitry Andric  // GFX90A+ only: instruction uses AccVGPR for data
33881ad6265SDimitry Andric  // Bit supersedes tfe.
339bdd1243dSDimitry Andric  bits<1> acc = !if(ps.has_vdata, vdata{9}, 0);
3400b57cec5SDimitry Andric}
3410b57cec5SDimitry Andric
3420b57cec5SDimitry Andric// For cache invalidation instructions.
3430b57cec5SDimitry Andricclass MUBUF_Invalidate <string opName, SDPatternOperator node = null_frag> :
3440b57cec5SDimitry Andric  MUBUF_Pseudo<opName, (outs), (ins), "", [(node)]> {
3450b57cec5SDimitry Andric
3460b57cec5SDimitry Andric  let AsmMatchConverter = "";
3470b57cec5SDimitry Andric
3480b57cec5SDimitry Andric  let hasSideEffects = 1;
3495ffd83dbSDimitry Andric  let mayLoad = 0;
3505ffd83dbSDimitry Andric  let mayStore = 0;
3510b57cec5SDimitry Andric
352fe6060f1SDimitry Andric  let IsBufferInv = 1;
353fe6060f1SDimitry Andric  // Set everything else to 0.
3540b57cec5SDimitry Andric  let offen       = 0;
3550b57cec5SDimitry Andric  let idxen       = 0;
3560b57cec5SDimitry Andric  let addr64      = 0;
3570b57cec5SDimitry Andric  let has_vdata   = 0;
3580b57cec5SDimitry Andric  let has_vaddr   = 0;
3590b57cec5SDimitry Andric  let has_glc     = 0;
3600b57cec5SDimitry Andric  let has_dlc     = 0;
3610b57cec5SDimitry Andric  let glc_value   = 0;
3620b57cec5SDimitry Andric  let dlc_value   = 0;
3630b57cec5SDimitry Andric  let has_srsrc   = 0;
3640b57cec5SDimitry Andric  let has_soffset = 0;
3650b57cec5SDimitry Andric  let has_offset  = 0;
3660b57cec5SDimitry Andric  let has_slc     = 0;
367fe6060f1SDimitry Andric  let has_sccb    = 0;
368fe6060f1SDimitry Andric  let sccb_value  = 0;
3690b57cec5SDimitry Andric}
3700b57cec5SDimitry Andric
371bdd1243dSDimitry Andricclass getLdStVDataRegisterOperand<RegisterClass RC, bit isTFE> {
372bdd1243dSDimitry Andric  RegisterOperand tfeVDataOp =
373bdd1243dSDimitry Andric    !if(!eq(RC.Size, 32), AVLdSt_64,
374bdd1243dSDimitry Andric    !if(!eq(RC.Size, 64), AVLdSt_96,
375bdd1243dSDimitry Andric    !if(!eq(RC.Size, 96), AVLdSt_128,
376bdd1243dSDimitry Andric    !if(!eq(RC.Size, 128), AVLdSt_160,
377bdd1243dSDimitry Andric    RegisterOperand<VReg_1>  // Invalid register.
378bdd1243dSDimitry Andric    ))));
379bdd1243dSDimitry Andric
380bdd1243dSDimitry Andric  RegisterOperand ret = !if(isTFE, tfeVDataOp, getLdStRegisterOperand<RC>.ret);
381bdd1243dSDimitry Andric}
382bdd1243dSDimitry Andric
3830b57cec5SDimitry Andricclass getMUBUFInsDA<list<RegisterClass> vdataList,
384bdd1243dSDimitry Andric                    list<RegisterClass> vaddrList, bit isTFE> {
3850b57cec5SDimitry Andric  RegisterClass vdataClass = !if(!empty(vdataList), ?, !head(vdataList));
3860b57cec5SDimitry Andric  RegisterClass vaddrClass = !if(!empty(vaddrList), ?, !head(vaddrList));
387bdd1243dSDimitry Andric  RegisterOperand vdata_op = getLdStVDataRegisterOperand<vdataClass, isTFE>.ret;
388bdd1243dSDimitry Andric
389*06c3fb27SDimitry Andric  dag NonVaddrInputs = (ins SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset, CPol_0:$cpol, i1imm_0:$swz);
390bdd1243dSDimitry Andric  dag Inputs = !if(!empty(vaddrList), NonVaddrInputs, !con((ins vaddrClass:$vaddr), NonVaddrInputs));
391bdd1243dSDimitry Andric  dag ret = !if(!empty(vdataList), Inputs, !con((ins vdata_op:$vdata), Inputs));
3920b57cec5SDimitry Andric}
3930b57cec5SDimitry Andric
3948bcb0991SDimitry Andricclass getMUBUFElements<ValueType vt> {
3950b57cec5SDimitry Andric  int ret =
396fe6060f1SDimitry Andric    !if(!eq(vt, f16), 1,
397fe6060f1SDimitry Andric      !if(!eq(vt, v2f16), 2,
398fe6060f1SDimitry Andric        !if(!eq(vt, v3f16), 3,
399fe6060f1SDimitry Andric          !if(!eq(vt, v4f16), 4,
4008bcb0991SDimitry Andric            !if(!eq(vt.Size, 32), 1,
4018bcb0991SDimitry Andric              !if(!eq(vt.Size, 64), 2,
4028bcb0991SDimitry Andric                !if(!eq(vt.Size, 96), 3,
4038bcb0991SDimitry Andric                  !if(!eq(vt.Size, 128), 4, 0)
4048bcb0991SDimitry Andric                )
4058bcb0991SDimitry Andric              )
4068bcb0991SDimitry Andric            )
4078bcb0991SDimitry Andric          )
4088bcb0991SDimitry Andric        )
4098bcb0991SDimitry Andric      )
4108bcb0991SDimitry Andric    );
4110b57cec5SDimitry Andric}
4120b57cec5SDimitry Andric
413bdd1243dSDimitry Andricclass getMUBUFIns<int addrKind, list<RegisterClass> vdataList, bit isTFE> {
4140b57cec5SDimitry Andric  dag ret =
415bdd1243dSDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Offset), getMUBUFInsDA<vdataList, [], isTFE>.ret,
416bdd1243dSDimitry Andric    !if(!eq(addrKind, BUFAddrKind.OffEn),  getMUBUFInsDA<vdataList, [VGPR_32], isTFE>.ret,
417bdd1243dSDimitry Andric    !if(!eq(addrKind, BUFAddrKind.IdxEn),  getMUBUFInsDA<vdataList, [VGPR_32], isTFE>.ret,
418bdd1243dSDimitry Andric    !if(!eq(addrKind, BUFAddrKind.BothEn), getMUBUFInsDA<vdataList, [VReg_64], isTFE>.ret,
419bdd1243dSDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Addr64), getMUBUFInsDA<vdataList, [VReg_64], isTFE>.ret,
4200b57cec5SDimitry Andric    (ins))))));
4210b57cec5SDimitry Andric}
4220b57cec5SDimitry Andric
423*06c3fb27SDimitry Andricclass getMUBUFAsmOps<int addrKind, bit noVdata = 0, bit isLds = 0, bit isTFE = 0> {
424bdd1243dSDimitry Andric  string Vdata = !if(noVdata, " ", " $vdata, ");
425bdd1243dSDimitry Andric  string Lds = !if(isLds, " lds", "");
426bdd1243dSDimitry Andric  string TFE = !if(isTFE, " tfe", "");
427bdd1243dSDimitry Andric  string MainArgs =
4280b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Offset), "off, $srsrc, $soffset",
4290b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.OffEn),  "$vaddr, $srsrc, $soffset offen",
4300b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.IdxEn),  "$vaddr, $srsrc, $soffset idxen",
4310b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.BothEn), "$vaddr, $srsrc, $soffset idxen offen",
4320b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Addr64), "$vaddr, $srsrc, $soffset addr64",
4330b57cec5SDimitry Andric    "")))));
434bdd1243dSDimitry Andric  string Offset = "$offset";
435bdd1243dSDimitry Andric  string OtherArgs = "$cpol";
436bdd1243dSDimitry Andric
437*06c3fb27SDimitry Andric  string ret = Vdata # MainArgs # Offset # OtherArgs # Lds # TFE;
4380b57cec5SDimitry Andric}
4390b57cec5SDimitry Andric
4400b57cec5SDimitry Andricclass MUBUF_SetupAddr<int addrKind> {
441e8d8bef9SDimitry Andric  bits<1> offen  = !or(!eq(addrKind, BUFAddrKind.OffEn),
442e8d8bef9SDimitry Andric                       !eq(addrKind, BUFAddrKind.BothEn));
4430b57cec5SDimitry Andric
444e8d8bef9SDimitry Andric  bits<1> idxen  = !or(!eq(addrKind, BUFAddrKind.IdxEn),
445e8d8bef9SDimitry Andric                       !eq(addrKind, BUFAddrKind.BothEn));
4460b57cec5SDimitry Andric
447e8d8bef9SDimitry Andric  bits<1> addr64 = !eq(addrKind, BUFAddrKind.Addr64);
4480b57cec5SDimitry Andric
449e8d8bef9SDimitry Andric  bits<1> has_vaddr = !ne(addrKind, BUFAddrKind.Offset);
4500b57cec5SDimitry Andric}
4510b57cec5SDimitry Andric
4520b57cec5SDimitry Andricclass MUBUF_Load_Pseudo <string opName,
4530b57cec5SDimitry Andric                         int addrKind,
4548bcb0991SDimitry Andric                         ValueType vdata_vt,
4550b57cec5SDimitry Andric                         bit HasTiedDest = 0,
4560b57cec5SDimitry Andric                         bit isLds = 0,
45781ad6265SDimitry Andric                         bit isLdsOpc = 0,
458bdd1243dSDimitry Andric                         bit isTFE = 0,
4590b57cec5SDimitry Andric                         list<dag> pattern=[],
4600b57cec5SDimitry Andric                         // Workaround bug bz30254
461fe6060f1SDimitry Andric                         int addrKindCopy = addrKind,
462fe6060f1SDimitry Andric                         RegisterClass vdata_rc = getVregSrcForVT<vdata_vt>.ret,
463bdd1243dSDimitry Andric                         RegisterOperand vdata_op = getLdStVDataRegisterOperand<vdata_rc, isTFE>.ret>
4640b57cec5SDimitry Andric  : MUBUF_Pseudo<opName,
46581ad6265SDimitry Andric                 !if(!or(isLds, isLdsOpc), (outs), (outs vdata_op:$vdata)),
466bdd1243dSDimitry Andric                 !con(getMUBUFIns<addrKindCopy, [], isTFE>.ret,
467fe6060f1SDimitry Andric                      !if(HasTiedDest, (ins vdata_op:$vdata_in), (ins))),
468*06c3fb27SDimitry Andric                 getMUBUFAsmOps<addrKindCopy, !or(isLds, isLdsOpc), isLds, isTFE>.ret,
4690b57cec5SDimitry Andric                 pattern>,
4700b57cec5SDimitry Andric    MUBUF_SetupAddr<addrKindCopy> {
471bdd1243dSDimitry Andric  let PseudoInstr = opName # !if(isLds, "_lds", "") # !if(isTFE, "_tfe", "") #
4720b57cec5SDimitry Andric                    "_" # getAddrName<addrKindCopy>.ret;
473bdd1243dSDimitry Andric  let AsmMatchConverter = "cvtMubuf";
4740b57cec5SDimitry Andric
4750b57cec5SDimitry Andric  let Constraints = !if(HasTiedDest, "$vdata = $vdata_in", "");
47681ad6265SDimitry Andric  let LGKM_CNT = isLds;
477bdd1243dSDimitry Andric  let has_vdata = !not(!or(isLds, isLdsOpc));
4780b57cec5SDimitry Andric  let mayLoad = 1;
47981ad6265SDimitry Andric  let mayStore = isLds;
4800b57cec5SDimitry Andric  let maybeAtomic = 1;
48181ad6265SDimitry Andric  let Uses = !if(!or(isLds, isLdsOpc) , [EXEC, M0], [EXEC]);
482bdd1243dSDimitry Andric  let tfe = isTFE;
4830b57cec5SDimitry Andric  let lds = isLds;
4848bcb0991SDimitry Andric  let elements = getMUBUFElements<vdata_vt>.ret;
48581ad6265SDimitry Andric  let VALU = isLds;
4860b57cec5SDimitry Andric}
4870b57cec5SDimitry Andric
4880b57cec5SDimitry Andricclass MUBUF_Offset_Load_Pat <Instruction inst, ValueType load_vt = i32, SDPatternOperator ld = null_frag> : Pat <
489*06c3fb27SDimitry Andric  (load_vt (ld (MUBUFOffset v4i32:$srsrc, i32:$soffset, i32:$offset))),
490*06c3fb27SDimitry Andric  (load_vt (inst v4i32:$srsrc, i32:$soffset, i32:$offset))
4910b57cec5SDimitry Andric>;
4920b57cec5SDimitry Andric
4930b57cec5SDimitry Andricclass MUBUF_Addr64_Load_Pat <Instruction inst,
4940b57cec5SDimitry Andric                            ValueType load_vt = i32,
4950b57cec5SDimitry Andric                            SDPatternOperator ld = null_frag> : Pat <
496*06c3fb27SDimitry Andric  (load_vt (ld (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset, i32:$offset))),
497*06c3fb27SDimitry Andric  (load_vt (inst i64:$vaddr, v4i32:$srsrc, i32:$soffset, i32:$offset))
4980b57cec5SDimitry Andric>;
4990b57cec5SDimitry Andric
5000b57cec5SDimitry Andricmulticlass MUBUF_Pseudo_Load_Pats<string BaseInst, ValueType load_vt = i32, SDPatternOperator ld = null_frag> {
5010b57cec5SDimitry Andric  def : MUBUF_Offset_Load_Pat<!cast<Instruction>(BaseInst#"_OFFSET"), load_vt, ld>;
5020b57cec5SDimitry Andric  def : MUBUF_Addr64_Load_Pat<!cast<Instruction>(BaseInst#"_ADDR64"), load_vt, ld>;
5030b57cec5SDimitry Andric}
5040b57cec5SDimitry Andric
505bdd1243dSDimitry Andricmulticlass MUBUF_Pseudo_Loads_Helper<string opName, ValueType load_vt,
506bdd1243dSDimitry Andric                                     bit TiedDest, bit isLds, bit isTFE> {
507fe6060f1SDimitry Andric  defvar legal_load_vt = !if(!eq(load_vt, v3f16), v4f16, load_vt);
508e8d8bef9SDimitry Andric
509bdd1243dSDimitry Andric  def _OFFSET : MUBUF_Load_Pseudo <opName, BUFAddrKind.Offset, legal_load_vt, TiedDest, isLds, 0, isTFE>,
5100b57cec5SDimitry Andric    MUBUFAddr64Table<0, NAME # !if(isLds, "_LDS", "")>;
5110b57cec5SDimitry Andric
512bdd1243dSDimitry Andric  def _ADDR64 : MUBUF_Load_Pseudo <opName, BUFAddrKind.Addr64, legal_load_vt, TiedDest, isLds, 0, isTFE>,
5130b57cec5SDimitry Andric    MUBUFAddr64Table<1, NAME # !if(isLds, "_LDS", "")>;
5140b57cec5SDimitry Andric
515bdd1243dSDimitry Andric  def _OFFEN  : MUBUF_Load_Pseudo <opName, BUFAddrKind.OffEn, legal_load_vt, TiedDest, isLds, 0, isTFE>;
516bdd1243dSDimitry Andric  def _IDXEN  : MUBUF_Load_Pseudo <opName, BUFAddrKind.IdxEn, legal_load_vt, TiedDest, isLds, 0, isTFE>;
517bdd1243dSDimitry Andric  def _BOTHEN : MUBUF_Load_Pseudo <opName, BUFAddrKind.BothEn, legal_load_vt, TiedDest, isLds, 0, isTFE>;
5180b57cec5SDimitry Andric
5190b57cec5SDimitry Andric  let DisableWQM = 1 in {
520bdd1243dSDimitry Andric    def _OFFSET_exact : MUBUF_Load_Pseudo <opName, BUFAddrKind.Offset, legal_load_vt, TiedDest, isLds, 0, isTFE>;
521bdd1243dSDimitry Andric    def _OFFEN_exact  : MUBUF_Load_Pseudo <opName, BUFAddrKind.OffEn, legal_load_vt, TiedDest, isLds, 0, isTFE>;
522bdd1243dSDimitry Andric    def _IDXEN_exact  : MUBUF_Load_Pseudo <opName, BUFAddrKind.IdxEn, legal_load_vt, TiedDest, isLds, 0, isTFE>;
523bdd1243dSDimitry Andric    def _BOTHEN_exact : MUBUF_Load_Pseudo <opName, BUFAddrKind.BothEn, legal_load_vt, TiedDest, isLds, 0, isTFE>;
5240b57cec5SDimitry Andric  }
5250b57cec5SDimitry Andric}
5260b57cec5SDimitry Andric
527bdd1243dSDimitry Andricmulticlass MUBUF_Pseudo_Loads<string opName, ValueType load_vt = i32,
528bdd1243dSDimitry Andric                              bit TiedDest = 0, bit isLds = 0> {
529bdd1243dSDimitry Andric  defm NAME : MUBUF_Pseudo_Loads_Helper<opName, load_vt, TiedDest, isLds, 0>;
530bdd1243dSDimitry Andric  if !not(isLds) then
531bdd1243dSDimitry Andric    defm _TFE : MUBUF_Pseudo_Loads_Helper<opName, load_vt, TiedDest, isLds, 1>;
532bdd1243dSDimitry Andric}
533bdd1243dSDimitry Andric
534349cc55cSDimitry Andricmulticlass MUBUF_Pseudo_Loads_Lds<string opName, ValueType load_vt = i32> {
535349cc55cSDimitry Andric  defm NAME : MUBUF_Pseudo_Loads<opName, load_vt>;
536349cc55cSDimitry Andric  defm _LDS : MUBUF_Pseudo_Loads<opName, load_vt, 0, 1>;
5370b57cec5SDimitry Andric}
5380b57cec5SDimitry Andric
53981ad6265SDimitry Andricmulticlass MUBUF_Pseudo_Loads_LDSOpc<string opName,
54081ad6265SDimitry Andric                                     ValueType load_vt = i32,
54181ad6265SDimitry Andric                                     bit TiedDest = 0,
54281ad6265SDimitry Andric                                     bit isLds = 0,
54381ad6265SDimitry Andric                                     bit isLdsOpc = 1> {
54481ad6265SDimitry Andric
54581ad6265SDimitry Andric  defvar legal_load_vt = !if(!eq(!cast<string>(load_vt), !cast<string>(v3f16)), v4f16, load_vt);
54681ad6265SDimitry Andric
54781ad6265SDimitry Andric  def _OFFSET : MUBUF_Load_Pseudo <opName, BUFAddrKind.Offset, legal_load_vt, TiedDest, isLds, isLdsOpc>;
54881ad6265SDimitry Andric  def _OFFEN  : MUBUF_Load_Pseudo <opName, BUFAddrKind.OffEn, legal_load_vt, TiedDest, isLds, isLdsOpc>;
54981ad6265SDimitry Andric  def _IDXEN  : MUBUF_Load_Pseudo <opName, BUFAddrKind.IdxEn, legal_load_vt, TiedDest, isLds, isLdsOpc>;
55081ad6265SDimitry Andric  def _BOTHEN : MUBUF_Load_Pseudo <opName, BUFAddrKind.BothEn, legal_load_vt, TiedDest, isLds, isLdsOpc>;
55181ad6265SDimitry Andric}
55281ad6265SDimitry Andric
5530b57cec5SDimitry Andricclass MUBUF_Store_Pseudo <string opName,
5540b57cec5SDimitry Andric                          int addrKind,
5558bcb0991SDimitry Andric                          ValueType store_vt,
556bdd1243dSDimitry Andric                          bit isTFE = 0,
5570b57cec5SDimitry Andric                          list<dag> pattern=[],
5580b57cec5SDimitry Andric                          // Workaround bug bz30254
5598bcb0991SDimitry Andric                          int addrKindCopy = addrKind>
5600b57cec5SDimitry Andric  : MUBUF_Pseudo<opName,
5610b57cec5SDimitry Andric                 (outs),
562bdd1243dSDimitry Andric                 getMUBUFIns<addrKindCopy, [getVregSrcForVT<store_vt>.ret], isTFE>.ret,
563*06c3fb27SDimitry Andric                 getMUBUFAsmOps<addrKindCopy, 0, 0, isTFE>.ret,
5640b57cec5SDimitry Andric                 pattern>,
5650b57cec5SDimitry Andric    MUBUF_SetupAddr<addrKindCopy> {
566bdd1243dSDimitry Andric  let PseudoInstr = opName # "_" # !if(isTFE, "_tfe", "") #
567bdd1243dSDimitry Andric                    getAddrName<addrKindCopy>.ret;
5680b57cec5SDimitry Andric  let mayLoad = 0;
5690b57cec5SDimitry Andric  let mayStore = 1;
5700b57cec5SDimitry Andric  let maybeAtomic = 1;
5718bcb0991SDimitry Andric  let elements = getMUBUFElements<store_vt>.ret;
572bdd1243dSDimitry Andric  let tfe = isTFE;
5730b57cec5SDimitry Andric}
5740b57cec5SDimitry Andric
575bdd1243dSDimitry Andricmulticlass MUBUF_Pseudo_Stores_Helper<string opName, ValueType store_vt,
576bdd1243dSDimitry Andric                                      SDPatternOperator st, bit isTFE> {
577fe6060f1SDimitry Andric  defvar legal_store_vt = !if(!eq(store_vt, v3f16), v4f16, store_vt);
578e8d8bef9SDimitry Andric
579bdd1243dSDimitry Andric  def _OFFSET : MUBUF_Store_Pseudo <opName, BUFAddrKind.Offset, legal_store_vt, isTFE,
580e8d8bef9SDimitry Andric    [(st legal_store_vt:$vdata, (MUBUFOffset v4i32:$srsrc, i32:$soffset,
581*06c3fb27SDimitry Andric                                             i32:$offset))]>,
5820b57cec5SDimitry Andric    MUBUFAddr64Table<0, NAME>;
5830b57cec5SDimitry Andric
584bdd1243dSDimitry Andric  def _ADDR64 : MUBUF_Store_Pseudo <opName, BUFAddrKind.Addr64, legal_store_vt, isTFE,
585e8d8bef9SDimitry Andric    [(st legal_store_vt:$vdata, (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset,
586*06c3fb27SDimitry Andric                                             i32:$offset))]>,
5870b57cec5SDimitry Andric    MUBUFAddr64Table<1, NAME>;
5880b57cec5SDimitry Andric
589bdd1243dSDimitry Andric  def _OFFEN  : MUBUF_Store_Pseudo <opName, BUFAddrKind.OffEn, legal_store_vt, isTFE>;
590bdd1243dSDimitry Andric  def _IDXEN  : MUBUF_Store_Pseudo <opName, BUFAddrKind.IdxEn, legal_store_vt, isTFE>;
591bdd1243dSDimitry Andric  def _BOTHEN : MUBUF_Store_Pseudo <opName, BUFAddrKind.BothEn, legal_store_vt, isTFE>;
5920b57cec5SDimitry Andric
5930b57cec5SDimitry Andric  let DisableWQM = 1 in {
594bdd1243dSDimitry Andric    def _OFFSET_exact : MUBUF_Store_Pseudo <opName, BUFAddrKind.Offset, legal_store_vt, isTFE>;
595bdd1243dSDimitry Andric    def _OFFEN_exact  : MUBUF_Store_Pseudo <opName, BUFAddrKind.OffEn, legal_store_vt, isTFE>;
596bdd1243dSDimitry Andric    def _IDXEN_exact  : MUBUF_Store_Pseudo <opName, BUFAddrKind.IdxEn, legal_store_vt, isTFE>;
597bdd1243dSDimitry Andric    def _BOTHEN_exact : MUBUF_Store_Pseudo <opName, BUFAddrKind.BothEn, legal_store_vt, isTFE>;
5980b57cec5SDimitry Andric  }
5990b57cec5SDimitry Andric}
6000b57cec5SDimitry Andric
601bdd1243dSDimitry Andricmulticlass MUBUF_Pseudo_Stores<string opName, ValueType store_vt = i32,
602bdd1243dSDimitry Andric                               SDPatternOperator st = null_frag> {
603bdd1243dSDimitry Andric  defm NAME : MUBUF_Pseudo_Stores_Helper<opName, store_vt, st, 0>;
604bdd1243dSDimitry Andric  defm _TFE : MUBUF_Pseudo_Stores_Helper<opName, store_vt, null_frag, 1>;
605bdd1243dSDimitry Andric}
606bdd1243dSDimitry Andric
6070b57cec5SDimitry Andricclass MUBUF_Pseudo_Store_Lds<string opName>
6080b57cec5SDimitry Andric  : MUBUF_Pseudo<opName,
6090b57cec5SDimitry Andric                 (outs),
610*06c3fb27SDimitry Andric                 (ins SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset, CPol:$cpol, i1imm:$swz),
611*06c3fb27SDimitry Andric                 " $srsrc, $soffset$offset lds$cpol"> {
61281ad6265SDimitry Andric  let LGKM_CNT = 1;
61381ad6265SDimitry Andric  let mayLoad = 1;
6140b57cec5SDimitry Andric  let mayStore = 1;
6150b57cec5SDimitry Andric  let maybeAtomic = 1;
6160b57cec5SDimitry Andric
6170b57cec5SDimitry Andric  let has_vdata = 0;
6180b57cec5SDimitry Andric  let has_vaddr = 0;
6190b57cec5SDimitry Andric  let lds = 1;
62081ad6265SDimitry Andric  let VALU = 1;
6210b57cec5SDimitry Andric
6220b57cec5SDimitry Andric  let Uses = [EXEC, M0];
623bdd1243dSDimitry Andric  let AsmMatchConverter = "cvtMubuf";
6240b57cec5SDimitry Andric}
6250b57cec5SDimitry Andric
6260b57cec5SDimitry Andricclass getMUBUFAtomicInsDA<RegisterClass vdataClass, bit vdata_in,
6270b57cec5SDimitry Andric                          list<RegisterClass> vaddrList=[]> {
6280b57cec5SDimitry Andric  RegisterClass vaddrClass = !if(!empty(vaddrList), ?, !head(vaddrList));
629fe6060f1SDimitry Andric  RegisterOperand vdata_op = getLdStRegisterOperand<vdataClass>.ret;
630bdd1243dSDimitry Andric
631bdd1243dSDimitry Andric  dag VData = !if(vdata_in, (ins vdata_op:$vdata_in), (ins vdata_op:$vdata));
632bdd1243dSDimitry Andric  dag Data = !if(!empty(vaddrList), VData, !con(VData, (ins vaddrClass:$vaddr)));
633bdd1243dSDimitry Andric  dag MainInputs = (ins SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset);
634bdd1243dSDimitry Andric  dag CPol = !if(vdata_in, (ins CPol_GLC1:$cpol), (ins CPol_0:$cpol));
635bdd1243dSDimitry Andric
636*06c3fb27SDimitry Andric  dag ret = !con(Data, MainInputs, CPol);
6370b57cec5SDimitry Andric}
6380b57cec5SDimitry Andric
6390b57cec5SDimitry Andricclass getMUBUFAtomicIns<int addrKind,
6400b57cec5SDimitry Andric                        RegisterClass vdataClass,
6410b57cec5SDimitry Andric                        bit vdata_in,
6420b57cec5SDimitry Andric                        // Workaround bug bz30254
6430b57cec5SDimitry Andric                        RegisterClass vdataClassCopy=vdataClass> {
6440b57cec5SDimitry Andric  dag ret =
6450b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Offset),
6460b57cec5SDimitry Andric            getMUBUFAtomicInsDA<vdataClassCopy, vdata_in>.ret,
6470b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.OffEn),
6480b57cec5SDimitry Andric            getMUBUFAtomicInsDA<vdataClassCopy, vdata_in, [VGPR_32]>.ret,
6490b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.IdxEn),
6500b57cec5SDimitry Andric            getMUBUFAtomicInsDA<vdataClassCopy, vdata_in, [VGPR_32]>.ret,
6510b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.BothEn),
6520b57cec5SDimitry Andric            getMUBUFAtomicInsDA<vdataClassCopy, vdata_in, [VReg_64]>.ret,
6530b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Addr64),
6540b57cec5SDimitry Andric            getMUBUFAtomicInsDA<vdataClassCopy, vdata_in, [VReg_64]>.ret,
6550b57cec5SDimitry Andric    (ins))))));
6560b57cec5SDimitry Andric}
6570b57cec5SDimitry Andric
6580b57cec5SDimitry Andricclass MUBUF_Atomic_Pseudo<string opName,
6590b57cec5SDimitry Andric                          int addrKind,
6600b57cec5SDimitry Andric                          dag outs,
6610b57cec5SDimitry Andric                          dag ins,
6620b57cec5SDimitry Andric                          string asmOps,
6630b57cec5SDimitry Andric                          list<dag> pattern=[],
6640b57cec5SDimitry Andric                          // Workaround bug bz30254
6650b57cec5SDimitry Andric                          int addrKindCopy = addrKind>
6660b57cec5SDimitry Andric  : MUBUF_Pseudo<opName, outs, ins, asmOps, pattern>,
6670b57cec5SDimitry Andric    MUBUF_SetupAddr<addrKindCopy> {
6680b57cec5SDimitry Andric  let mayStore = 1;
6690b57cec5SDimitry Andric  let mayLoad = 1;
6700b57cec5SDimitry Andric  let hasPostISelHook = 1;
6710b57cec5SDimitry Andric  let hasSideEffects = 1;
6720b57cec5SDimitry Andric  let DisableWQM = 1;
6730b57cec5SDimitry Andric  let has_glc = 0;
6740b57cec5SDimitry Andric  let has_dlc = 0;
675fe6060f1SDimitry Andric  let has_sccb = 1;
6760b57cec5SDimitry Andric  let maybeAtomic = 1;
677fe6060f1SDimitry Andric  let AsmMatchConverter = "cvtMubufAtomic";
6780b57cec5SDimitry Andric}
6790b57cec5SDimitry Andric
6800b57cec5SDimitry Andricclass MUBUF_AtomicNoRet_Pseudo<string opName, int addrKind,
6810b57cec5SDimitry Andric                               RegisterClass vdataClass,
6820b57cec5SDimitry Andric                               list<dag> pattern=[],
6830b57cec5SDimitry Andric                               // Workaround bug bz30254
6840b57cec5SDimitry Andric                               int addrKindCopy = addrKind,
6850b57cec5SDimitry Andric                               RegisterClass vdataClassCopy = vdataClass>
6860b57cec5SDimitry Andric  : MUBUF_Atomic_Pseudo<opName, addrKindCopy,
6870b57cec5SDimitry Andric                        (outs),
6880b57cec5SDimitry Andric                        getMUBUFAtomicIns<addrKindCopy, vdataClassCopy, 0>.ret,
689bdd1243dSDimitry Andric                        getMUBUFAsmOps<addrKindCopy>.ret,
6900b57cec5SDimitry Andric                        pattern>,
6910b57cec5SDimitry Andric    AtomicNoRet<opName # "_" # getAddrName<addrKindCopy>.ret, 0> {
6920b57cec5SDimitry Andric  let PseudoInstr = opName # "_" # getAddrName<addrKindCopy>.ret;
6930b57cec5SDimitry Andric  let glc_value = 0;
6940b57cec5SDimitry Andric  let dlc_value = 0;
695fe6060f1SDimitry Andric  let sccb_value = 0;
696fe6060f1SDimitry Andric  let IsAtomicNoRet = 1;
6970b57cec5SDimitry Andric}
6980b57cec5SDimitry Andric
6990b57cec5SDimitry Andricclass MUBUF_AtomicRet_Pseudo<string opName, int addrKind,
7000b57cec5SDimitry Andric                             RegisterClass vdataClass,
7010b57cec5SDimitry Andric                             list<dag> pattern=[],
7020b57cec5SDimitry Andric                             // Workaround bug bz30254
7030b57cec5SDimitry Andric                             int addrKindCopy = addrKind,
704fe6060f1SDimitry Andric                             RegisterClass vdataClassCopy = vdataClass,
705fe6060f1SDimitry Andric                             RegisterOperand vdata_op = getLdStRegisterOperand<vdataClass>.ret>
7060b57cec5SDimitry Andric  : MUBUF_Atomic_Pseudo<opName, addrKindCopy,
707fe6060f1SDimitry Andric                        (outs vdata_op:$vdata),
7080b57cec5SDimitry Andric                        getMUBUFAtomicIns<addrKindCopy, vdataClassCopy, 1>.ret,
709bdd1243dSDimitry Andric                        getMUBUFAsmOps<addrKindCopy>.ret,
7100b57cec5SDimitry Andric                        pattern>,
7110b57cec5SDimitry Andric    AtomicNoRet<opName # "_" # getAddrName<addrKindCopy>.ret, 1> {
7120b57cec5SDimitry Andric  let PseudoInstr = opName # "_rtn_" # getAddrName<addrKindCopy>.ret;
7130b57cec5SDimitry Andric  let glc_value = 1;
7140b57cec5SDimitry Andric  let dlc_value = 0;
715fe6060f1SDimitry Andric  let sccb_value = 0;
716fe6060f1SDimitry Andric  let IsAtomicRet = 1;
7170b57cec5SDimitry Andric  let Constraints = "$vdata = $vdata_in";
7180b57cec5SDimitry Andric  let DisableEncoding = "$vdata_in";
7190b57cec5SDimitry Andric}
7200b57cec5SDimitry Andric
7210b57cec5SDimitry Andricmulticlass MUBUF_Pseudo_Atomics_NO_RTN <string opName,
7220b57cec5SDimitry Andric                                        RegisterClass vdataClass,
7230b57cec5SDimitry Andric                                        ValueType vdataType,
7248bcb0991SDimitry Andric                                        bit isFP = isFloatType<vdataType>.ret> {
725*06c3fb27SDimitry Andric  let FPAtomic = isFP in {
7260b57cec5SDimitry Andric    def _OFFSET : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.Offset, vdataClass>,
7270b57cec5SDimitry Andric                  MUBUFAddr64Table <0, NAME>;
7280b57cec5SDimitry Andric    def _ADDR64 : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.Addr64, vdataClass>,
7290b57cec5SDimitry Andric                  MUBUFAddr64Table <1, NAME>;
7300b57cec5SDimitry Andric    def _OFFEN  : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.OffEn,  vdataClass>;
7310b57cec5SDimitry Andric    def _IDXEN  : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.IdxEn,  vdataClass>;
7320b57cec5SDimitry Andric    def _BOTHEN : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.BothEn, vdataClass>;
7330b57cec5SDimitry Andric  }
734*06c3fb27SDimitry Andric}
7350b57cec5SDimitry Andric
7360b57cec5SDimitry Andricmulticlass MUBUF_Pseudo_Atomics_RTN <string opName,
7370b57cec5SDimitry Andric                                     RegisterClass vdataClass,
7380b57cec5SDimitry Andric                                     ValueType vdataType,
7390b57cec5SDimitry Andric                                     SDPatternOperator atomic,
7408bcb0991SDimitry Andric                                     bit isFP = isFloatType<vdataType>.ret> {
741*06c3fb27SDimitry Andric  let FPAtomic = isFP in {
7420b57cec5SDimitry Andric    def _OFFSET_RTN : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.Offset, vdataClass,
7430b57cec5SDimitry Andric      [(set vdataType:$vdata,
744*06c3fb27SDimitry Andric       (atomic (MUBUFOffset v4i32:$srsrc, i32:$soffset, i32:$offset),
7450b57cec5SDimitry Andric               vdataType:$vdata_in))]>,
7460b57cec5SDimitry Andric      MUBUFAddr64Table <0, NAME # "_RTN">;
7470b57cec5SDimitry Andric
7480b57cec5SDimitry Andric    def _ADDR64_RTN : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.Addr64, vdataClass,
7490b57cec5SDimitry Andric      [(set vdataType:$vdata,
750*06c3fb27SDimitry Andric       (atomic (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset, i32:$offset),
7510b57cec5SDimitry Andric                vdataType:$vdata_in))]>,
7520b57cec5SDimitry Andric      MUBUFAddr64Table <1, NAME # "_RTN">;
7530b57cec5SDimitry Andric
7540b57cec5SDimitry Andric    def _OFFEN_RTN  : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.OffEn,  vdataClass>;
7550b57cec5SDimitry Andric    def _IDXEN_RTN  : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.IdxEn,  vdataClass>;
7560b57cec5SDimitry Andric    def _BOTHEN_RTN : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.BothEn, vdataClass>;
7570b57cec5SDimitry Andric  }
758*06c3fb27SDimitry Andric}
7590b57cec5SDimitry Andric
7600b57cec5SDimitry Andricmulticlass MUBUF_Pseudo_Atomics <string opName,
7610b57cec5SDimitry Andric                                 RegisterClass vdataClass,
7620b57cec5SDimitry Andric                                 ValueType vdataType,
76381ad6265SDimitry Andric                                 SDPatternOperator atomic = null_frag> :
764349cc55cSDimitry Andric  MUBUF_Pseudo_Atomics_NO_RTN<opName, vdataClass, vdataType>,
7650b57cec5SDimitry Andric  MUBUF_Pseudo_Atomics_RTN<opName, vdataClass, vdataType, atomic>;
7660b57cec5SDimitry Andric
7670b57cec5SDimitry Andric
7680b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
7690b57cec5SDimitry Andric// MUBUF Instructions
7700b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
7710b57cec5SDimitry Andric
7720b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_X : MUBUF_Pseudo_Loads_Lds <
7738bcb0991SDimitry Andric  "buffer_load_format_x", f32
7740b57cec5SDimitry Andric>;
7750b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XY : MUBUF_Pseudo_Loads <
7768bcb0991SDimitry Andric  "buffer_load_format_xy", v2f32
7770b57cec5SDimitry Andric>;
7780b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZ : MUBUF_Pseudo_Loads <
7798bcb0991SDimitry Andric  "buffer_load_format_xyz", v3f32
7800b57cec5SDimitry Andric>;
7810b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZW : MUBUF_Pseudo_Loads <
7828bcb0991SDimitry Andric  "buffer_load_format_xyzw", v4f32
7830b57cec5SDimitry Andric>;
7840b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_X : MUBUF_Pseudo_Stores <
7858bcb0991SDimitry Andric  "buffer_store_format_x", f32
7860b57cec5SDimitry Andric>;
7870b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XY : MUBUF_Pseudo_Stores <
7888bcb0991SDimitry Andric  "buffer_store_format_xy", v2f32
7890b57cec5SDimitry Andric>;
7900b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZ : MUBUF_Pseudo_Stores <
7918bcb0991SDimitry Andric  "buffer_store_format_xyz", v3f32
7920b57cec5SDimitry Andric>;
7930b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZW : MUBUF_Pseudo_Stores <
7948bcb0991SDimitry Andric  "buffer_store_format_xyzw", v4f32
7950b57cec5SDimitry Andric>;
7960b57cec5SDimitry Andric
7970b57cec5SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem, D16Buf = 1 in {
798bdd1243dSDimitry Andriclet TiedSourceNotRead = 1 in {
7990b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_X_gfx80 : MUBUF_Pseudo_Loads <
8008bcb0991SDimitry Andric    "buffer_load_format_d16_x", i32
8010b57cec5SDimitry Andric  >;
8020b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XY_gfx80 : MUBUF_Pseudo_Loads <
8038bcb0991SDimitry Andric    "buffer_load_format_d16_xy", v2i32
8040b57cec5SDimitry Andric  >;
8050b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XYZ_gfx80 : MUBUF_Pseudo_Loads <
8068bcb0991SDimitry Andric    "buffer_load_format_d16_xyz", v3i32
8070b57cec5SDimitry Andric  >;
8080b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XYZW_gfx80 : MUBUF_Pseudo_Loads <
8098bcb0991SDimitry Andric   "buffer_load_format_d16_xyzw", v4i32
8100b57cec5SDimitry Andric  >;
811bdd1243dSDimitry Andric}
8120b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_X_gfx80 : MUBUF_Pseudo_Stores <
8138bcb0991SDimitry Andric    "buffer_store_format_d16_x", i32
8140b57cec5SDimitry Andric  >;
8150b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XY_gfx80 : MUBUF_Pseudo_Stores <
8168bcb0991SDimitry Andric    "buffer_store_format_d16_xy", v2i32
8170b57cec5SDimitry Andric  >;
8180b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XYZ_gfx80 : MUBUF_Pseudo_Stores <
8198bcb0991SDimitry Andric    "buffer_store_format_d16_xyz", v3i32
8200b57cec5SDimitry Andric  >;
8210b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XYZW_gfx80 : MUBUF_Pseudo_Stores <
8228bcb0991SDimitry Andric    "buffer_store_format_d16_xyzw", v4i32
8230b57cec5SDimitry Andric  >;
8240b57cec5SDimitry Andric} // End HasUnpackedD16VMem.
8250b57cec5SDimitry Andric
8260b57cec5SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem, D16Buf = 1 in {
827bdd1243dSDimitry Andriclet TiedSourceNotRead = 1 in {
8280b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_X : MUBUF_Pseudo_Loads <
8298bcb0991SDimitry Andric    "buffer_load_format_d16_x", f16
8300b57cec5SDimitry Andric  >;
8310b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XY : MUBUF_Pseudo_Loads <
8328bcb0991SDimitry Andric    "buffer_load_format_d16_xy", v2f16
8330b57cec5SDimitry Andric  >;
8340b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XYZ : MUBUF_Pseudo_Loads <
8358bcb0991SDimitry Andric    "buffer_load_format_d16_xyz", v3f16
8360b57cec5SDimitry Andric  >;
8370b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XYZW : MUBUF_Pseudo_Loads <
8388bcb0991SDimitry Andric    "buffer_load_format_d16_xyzw", v4f16
8390b57cec5SDimitry Andric  >;
840bdd1243dSDimitry Andric}
8410b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_X : MUBUF_Pseudo_Stores <
8428bcb0991SDimitry Andric    "buffer_store_format_d16_x", f16
8430b57cec5SDimitry Andric  >;
8440b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XY : MUBUF_Pseudo_Stores <
8458bcb0991SDimitry Andric    "buffer_store_format_d16_xy", v2f16
8460b57cec5SDimitry Andric  >;
8470b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XYZ : MUBUF_Pseudo_Stores <
8488bcb0991SDimitry Andric    "buffer_store_format_d16_xyz", v3f16
8490b57cec5SDimitry Andric  >;
8500b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XYZW : MUBUF_Pseudo_Stores <
8518bcb0991SDimitry Andric    "buffer_store_format_d16_xyzw", v4f16
8520b57cec5SDimitry Andric  >;
8530b57cec5SDimitry Andric} // End HasPackedD16VMem.
8540b57cec5SDimitry Andric
8550b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE : MUBUF_Pseudo_Loads_Lds <
8568bcb0991SDimitry Andric  "buffer_load_ubyte", i32
8570b57cec5SDimitry Andric>;
8580b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE : MUBUF_Pseudo_Loads_Lds <
8598bcb0991SDimitry Andric  "buffer_load_sbyte", i32
8600b57cec5SDimitry Andric>;
8610b57cec5SDimitry Andricdefm BUFFER_LOAD_USHORT : MUBUF_Pseudo_Loads_Lds <
8628bcb0991SDimitry Andric  "buffer_load_ushort", i32
8630b57cec5SDimitry Andric>;
8640b57cec5SDimitry Andricdefm BUFFER_LOAD_SSHORT : MUBUF_Pseudo_Loads_Lds <
8658bcb0991SDimitry Andric  "buffer_load_sshort", i32
8660b57cec5SDimitry Andric>;
8670b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORD : MUBUF_Pseudo_Loads_Lds <
8688bcb0991SDimitry Andric  "buffer_load_dword", i32
8690b57cec5SDimitry Andric>;
8700b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX2 : MUBUF_Pseudo_Loads <
8718bcb0991SDimitry Andric  "buffer_load_dwordx2", v2i32
8720b57cec5SDimitry Andric>;
8730b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX3 : MUBUF_Pseudo_Loads <
8748bcb0991SDimitry Andric  "buffer_load_dwordx3", v3i32
8750b57cec5SDimitry Andric>;
8760b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX4 : MUBUF_Pseudo_Loads <
8778bcb0991SDimitry Andric  "buffer_load_dwordx4", v4i32
8780b57cec5SDimitry Andric>;
8790b57cec5SDimitry Andric
88081ad6265SDimitry Andricdefm BUFFER_LOAD_LDS_B32 : MUBUF_Pseudo_Loads_LDSOpc <
88181ad6265SDimitry Andric  "buffer_load_lds_b32", i32
88281ad6265SDimitry Andric>;
88381ad6265SDimitry Andricdefm BUFFER_LOAD_LDS_FORMAT_X : MUBUF_Pseudo_Loads_LDSOpc <
88481ad6265SDimitry Andric  "buffer_load_lds_format_x", f32
88581ad6265SDimitry Andric>;
88681ad6265SDimitry Andricdefm BUFFER_LOAD_LDS_I8 : MUBUF_Pseudo_Loads_LDSOpc <
88781ad6265SDimitry Andric  "buffer_load_lds_i8", i32
88881ad6265SDimitry Andric>;
88981ad6265SDimitry Andricdefm BUFFER_LOAD_LDS_I16 : MUBUF_Pseudo_Loads_LDSOpc <
89081ad6265SDimitry Andric  "buffer_load_lds_i16", i32
89181ad6265SDimitry Andric>;
89281ad6265SDimitry Andricdefm BUFFER_LOAD_LDS_U8 : MUBUF_Pseudo_Loads_LDSOpc <
89381ad6265SDimitry Andric  "buffer_load_lds_u8", i32
89481ad6265SDimitry Andric>;
89581ad6265SDimitry Andricdefm BUFFER_LOAD_LDS_U16 : MUBUF_Pseudo_Loads_LDSOpc <
89681ad6265SDimitry Andric  "buffer_load_lds_u16", i32
89781ad6265SDimitry Andric>;
89881ad6265SDimitry Andric
89981ad6265SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_UBYTE", i32, atomic_load_8_global>;
90081ad6265SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_USHORT", i32, atomic_load_16_global>;
90181ad6265SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_UBYTE", i16, atomic_load_8_global>;
90281ad6265SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_USHORT", i16, atomic_load_16_global>;
9030b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_UBYTE", i32, extloadi8_global>;
9040b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_UBYTE", i32, zextloadi8_global>;
9050b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_SBYTE", i32, sextloadi8_global>;
9060b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_USHORT", i32, extloadi16_global>;
9070b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_USHORT", i32, zextloadi16_global>;
9080b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_SSHORT", i32, sextloadi16_global>;
9090b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_DWORD", i32, load_global>;
9100b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_DWORDX2", v2i32, load_global>;
9110b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_DWORDX3", v3i32, load_global>;
9120b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_DWORDX4", v4i32, load_global>;
9130b57cec5SDimitry Andric
9140b57cec5SDimitry Andricdefm BUFFER_STORE_BYTE : MUBUF_Pseudo_Stores <
9158bcb0991SDimitry Andric  "buffer_store_byte", i32, truncstorei8_global
9160b57cec5SDimitry Andric>;
9170b57cec5SDimitry Andricdefm BUFFER_STORE_SHORT : MUBUF_Pseudo_Stores <
9188bcb0991SDimitry Andric  "buffer_store_short", i32, truncstorei16_global
9190b57cec5SDimitry Andric>;
9200b57cec5SDimitry Andricdefm BUFFER_STORE_DWORD : MUBUF_Pseudo_Stores <
9218bcb0991SDimitry Andric  "buffer_store_dword", i32, store_global
9220b57cec5SDimitry Andric>;
9230b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX2 : MUBUF_Pseudo_Stores <
9248bcb0991SDimitry Andric  "buffer_store_dwordx2", v2i32, store_global
9250b57cec5SDimitry Andric>;
9260b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX3 : MUBUF_Pseudo_Stores <
9278bcb0991SDimitry Andric  "buffer_store_dwordx3", v3i32, store_global
9280b57cec5SDimitry Andric>;
9290b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX4 : MUBUF_Pseudo_Stores <
9308bcb0991SDimitry Andric  "buffer_store_dwordx4", v4i32, store_global
9310b57cec5SDimitry Andric>;
9320b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SWAP : MUBUF_Pseudo_Atomics <
93381ad6265SDimitry Andric  "buffer_atomic_swap", VGPR_32, i32
9340b57cec5SDimitry Andric>;
9350b57cec5SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP : MUBUF_Pseudo_Atomics <
93681ad6265SDimitry Andric  "buffer_atomic_cmpswap", VReg_64, v2i32
9370b57cec5SDimitry Andric>;
9380b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD : MUBUF_Pseudo_Atomics <
93981ad6265SDimitry Andric  "buffer_atomic_add", VGPR_32, i32
9400b57cec5SDimitry Andric>;
9410b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SUB : MUBUF_Pseudo_Atomics <
94281ad6265SDimitry Andric  "buffer_atomic_sub", VGPR_32, i32
9430b57cec5SDimitry Andric>;
9440b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMIN : MUBUF_Pseudo_Atomics <
94581ad6265SDimitry Andric  "buffer_atomic_smin", VGPR_32, i32
9460b57cec5SDimitry Andric>;
9470b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMIN : MUBUF_Pseudo_Atomics <
94881ad6265SDimitry Andric  "buffer_atomic_umin", VGPR_32, i32
9490b57cec5SDimitry Andric>;
9500b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMAX : MUBUF_Pseudo_Atomics <
95181ad6265SDimitry Andric  "buffer_atomic_smax", VGPR_32, i32
9520b57cec5SDimitry Andric>;
9530b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMAX : MUBUF_Pseudo_Atomics <
95481ad6265SDimitry Andric  "buffer_atomic_umax", VGPR_32, i32
9550b57cec5SDimitry Andric>;
9560b57cec5SDimitry Andricdefm BUFFER_ATOMIC_AND : MUBUF_Pseudo_Atomics <
95781ad6265SDimitry Andric  "buffer_atomic_and", VGPR_32, i32
9580b57cec5SDimitry Andric>;
9590b57cec5SDimitry Andricdefm BUFFER_ATOMIC_OR : MUBUF_Pseudo_Atomics <
96081ad6265SDimitry Andric  "buffer_atomic_or", VGPR_32, i32
9610b57cec5SDimitry Andric>;
9620b57cec5SDimitry Andricdefm BUFFER_ATOMIC_XOR : MUBUF_Pseudo_Atomics <
96381ad6265SDimitry Andric  "buffer_atomic_xor", VGPR_32, i32
9640b57cec5SDimitry Andric>;
9650b57cec5SDimitry Andricdefm BUFFER_ATOMIC_INC : MUBUF_Pseudo_Atomics <
96681ad6265SDimitry Andric  "buffer_atomic_inc", VGPR_32, i32
9670b57cec5SDimitry Andric>;
9680b57cec5SDimitry Andricdefm BUFFER_ATOMIC_DEC : MUBUF_Pseudo_Atomics <
96981ad6265SDimitry Andric  "buffer_atomic_dec", VGPR_32, i32
9700b57cec5SDimitry Andric>;
9710b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SWAP_X2 : MUBUF_Pseudo_Atomics <
97281ad6265SDimitry Andric  "buffer_atomic_swap_x2", VReg_64, i64
9730b57cec5SDimitry Andric>;
9740b57cec5SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP_X2 : MUBUF_Pseudo_Atomics <
97581ad6265SDimitry Andric  "buffer_atomic_cmpswap_x2", VReg_128, v2i64
9760b57cec5SDimitry Andric>;
9770b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD_X2 : MUBUF_Pseudo_Atomics <
97881ad6265SDimitry Andric  "buffer_atomic_add_x2", VReg_64, i64
9790b57cec5SDimitry Andric>;
9800b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SUB_X2 : MUBUF_Pseudo_Atomics <
98181ad6265SDimitry Andric  "buffer_atomic_sub_x2", VReg_64, i64
9820b57cec5SDimitry Andric>;
9830b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMIN_X2 : MUBUF_Pseudo_Atomics <
98481ad6265SDimitry Andric  "buffer_atomic_smin_x2", VReg_64, i64
9850b57cec5SDimitry Andric>;
9860b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMIN_X2 : MUBUF_Pseudo_Atomics <
98781ad6265SDimitry Andric  "buffer_atomic_umin_x2", VReg_64, i64
9880b57cec5SDimitry Andric>;
9890b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMAX_X2 : MUBUF_Pseudo_Atomics <
99081ad6265SDimitry Andric  "buffer_atomic_smax_x2", VReg_64, i64
9910b57cec5SDimitry Andric>;
9920b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMAX_X2 : MUBUF_Pseudo_Atomics <
99381ad6265SDimitry Andric  "buffer_atomic_umax_x2", VReg_64, i64
9940b57cec5SDimitry Andric>;
9950b57cec5SDimitry Andricdefm BUFFER_ATOMIC_AND_X2 : MUBUF_Pseudo_Atomics <
99681ad6265SDimitry Andric  "buffer_atomic_and_x2", VReg_64, i64
9970b57cec5SDimitry Andric>;
9980b57cec5SDimitry Andricdefm BUFFER_ATOMIC_OR_X2 : MUBUF_Pseudo_Atomics <
99981ad6265SDimitry Andric  "buffer_atomic_or_x2", VReg_64, i64
10000b57cec5SDimitry Andric>;
10010b57cec5SDimitry Andricdefm BUFFER_ATOMIC_XOR_X2 : MUBUF_Pseudo_Atomics <
100281ad6265SDimitry Andric  "buffer_atomic_xor_x2", VReg_64, i64
10030b57cec5SDimitry Andric>;
10040b57cec5SDimitry Andricdefm BUFFER_ATOMIC_INC_X2 : MUBUF_Pseudo_Atomics <
100581ad6265SDimitry Andric  "buffer_atomic_inc_x2", VReg_64, i64
10060b57cec5SDimitry Andric>;
10070b57cec5SDimitry Andricdefm BUFFER_ATOMIC_DEC_X2 : MUBUF_Pseudo_Atomics <
100881ad6265SDimitry Andric  "buffer_atomic_dec_x2", VReg_64, i64
10090b57cec5SDimitry Andric>;
10100b57cec5SDimitry Andric
10115ffd83dbSDimitry Andriclet SubtargetPredicate = HasGFX10_BEncoding in
10125ffd83dbSDimitry Andricdefm BUFFER_ATOMIC_CSUB : MUBUF_Pseudo_Atomics_RTN <
1013e8d8bef9SDimitry Andric  "buffer_atomic_csub", VGPR_32, i32, int_amdgcn_global_atomic_csub
10145ffd83dbSDimitry Andric>;
10155ffd83dbSDimitry Andric
10160b57cec5SDimitry Andriclet SubtargetPredicate = isGFX8GFX9 in {
10170b57cec5SDimitry Andricdef BUFFER_STORE_LDS_DWORD : MUBUF_Pseudo_Store_Lds <"buffer_store_lds_dword">;
10180b57cec5SDimitry Andric}
10190b57cec5SDimitry Andric
10200b57cec5SDimitry Andriclet SubtargetPredicate = isGFX6 in { // isn't on CI & VI
10210b57cec5SDimitry Andric/*
10220b57cec5SDimitry Andricdefm BUFFER_ATOMIC_RSUB        : MUBUF_Pseudo_Atomics <"buffer_atomic_rsub">;
10230b57cec5SDimitry Andricdefm BUFFER_ATOMIC_RSUB_X2     : MUBUF_Pseudo_Atomics <"buffer_atomic_rsub_x2">;
10240b57cec5SDimitry Andric*/
10250b57cec5SDimitry Andric
10260b57cec5SDimitry Andricdef BUFFER_WBINVL1_SC : MUBUF_Invalidate <"buffer_wbinvl1_sc",
10270b57cec5SDimitry Andric                                          int_amdgcn_buffer_wbinvl1_sc>;
10280b57cec5SDimitry Andric}
10290b57cec5SDimitry Andric
103081ad6265SDimitry Andriclet SubtargetPredicate = isGFX6GFX7GFX10Plus in {
10318bcb0991SDimitry Andric
10328bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FCMPSWAP : MUBUF_Pseudo_Atomics <
10338bcb0991SDimitry Andric  "buffer_atomic_fcmpswap", VReg_64, v2f32, null_frag
10348bcb0991SDimitry Andric>;
10358bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMIN : MUBUF_Pseudo_Atomics <
10368bcb0991SDimitry Andric  "buffer_atomic_fmin", VGPR_32, f32, null_frag
10378bcb0991SDimitry Andric>;
10388bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMAX : MUBUF_Pseudo_Atomics <
10398bcb0991SDimitry Andric  "buffer_atomic_fmax", VGPR_32, f32, null_frag
10408bcb0991SDimitry Andric>;
104181ad6265SDimitry Andric
104281ad6265SDimitry Andric}
104381ad6265SDimitry Andric
104481ad6265SDimitry Andriclet SubtargetPredicate = isGFX6GFX7GFX10 in {
104581ad6265SDimitry Andric
10468bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FCMPSWAP_X2 : MUBUF_Pseudo_Atomics <
10478bcb0991SDimitry Andric  "buffer_atomic_fcmpswap_x2", VReg_128, v2f64, null_frag
10488bcb0991SDimitry Andric>;
10498bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMIN_X2 : MUBUF_Pseudo_Atomics <
10508bcb0991SDimitry Andric  "buffer_atomic_fmin_x2", VReg_64, f64, null_frag
10518bcb0991SDimitry Andric>;
10528bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMAX_X2 : MUBUF_Pseudo_Atomics <
10538bcb0991SDimitry Andric  "buffer_atomic_fmax_x2", VReg_64, f64, null_frag
10548bcb0991SDimitry Andric>;
10558bcb0991SDimitry Andric
10568bcb0991SDimitry Andric}
10578bcb0991SDimitry Andric
10580b57cec5SDimitry Andriclet SubtargetPredicate = HasD16LoadStore in {
1059bdd1243dSDimitry Andriclet TiedSourceNotRead = 1 in {
10600b57cec5SDimitry Andric
10610b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16 : MUBUF_Pseudo_Loads <
1062349cc55cSDimitry Andric  "buffer_load_ubyte_d16", i32, 1
10630b57cec5SDimitry Andric>;
10640b57cec5SDimitry Andric
10650b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16_HI : MUBUF_Pseudo_Loads <
1066349cc55cSDimitry Andric  "buffer_load_ubyte_d16_hi", i32, 1
10670b57cec5SDimitry Andric>;
10680b57cec5SDimitry Andric
10690b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16 : MUBUF_Pseudo_Loads <
1070349cc55cSDimitry Andric  "buffer_load_sbyte_d16", i32, 1
10710b57cec5SDimitry Andric>;
10720b57cec5SDimitry Andric
10730b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16_HI : MUBUF_Pseudo_Loads <
1074349cc55cSDimitry Andric  "buffer_load_sbyte_d16_hi", i32, 1
10750b57cec5SDimitry Andric>;
10760b57cec5SDimitry Andric
10770b57cec5SDimitry Andricdefm BUFFER_LOAD_SHORT_D16 : MUBUF_Pseudo_Loads <
1078349cc55cSDimitry Andric  "buffer_load_short_d16", i32, 1
10790b57cec5SDimitry Andric>;
10800b57cec5SDimitry Andric
10810b57cec5SDimitry Andricdefm BUFFER_LOAD_SHORT_D16_HI : MUBUF_Pseudo_Loads <
1082349cc55cSDimitry Andric  "buffer_load_short_d16_hi", i32, 1
10830b57cec5SDimitry Andric>;
10840b57cec5SDimitry Andric
1085bdd1243dSDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_HI_X : MUBUF_Pseudo_Loads <
1086bdd1243dSDimitry Andric  "buffer_load_format_d16_hi_x", i32
1087bdd1243dSDimitry Andric>;
1088bdd1243dSDimitry Andric} // End TiedSourceNotRead
1089bdd1243dSDimitry Andric
10900b57cec5SDimitry Andricdefm BUFFER_STORE_BYTE_D16_HI : MUBUF_Pseudo_Stores <
10918bcb0991SDimitry Andric  "buffer_store_byte_d16_hi", i32
10920b57cec5SDimitry Andric>;
10930b57cec5SDimitry Andric
10940b57cec5SDimitry Andricdefm BUFFER_STORE_SHORT_D16_HI : MUBUF_Pseudo_Stores <
10958bcb0991SDimitry Andric  "buffer_store_short_d16_hi", i32
10960b57cec5SDimitry Andric>;
10970b57cec5SDimitry Andric
10980b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_HI_X : MUBUF_Pseudo_Stores <
10998bcb0991SDimitry Andric  "buffer_store_format_d16_hi_x", i32
11000b57cec5SDimitry Andric>;
11010b57cec5SDimitry Andric
11020b57cec5SDimitry Andric} // End HasD16LoadStore
11030b57cec5SDimitry Andric
11040b57cec5SDimitry Andricdef BUFFER_WBINVL1 : MUBUF_Invalidate <"buffer_wbinvl1",
11050b57cec5SDimitry Andric                                       int_amdgcn_buffer_wbinvl1>;
11060b57cec5SDimitry Andric
110781ad6265SDimitry Andriclet SubtargetPredicate = HasAtomicFaddNoRtnInsts in
11080b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD_F32 : MUBUF_Pseudo_Atomics_NO_RTN<
1109349cc55cSDimitry Andric  "buffer_atomic_add_f32", VGPR_32, f32
11100b57cec5SDimitry Andric>;
111181ad6265SDimitry Andric
1112*06c3fb27SDimitry Andriclet SubtargetPredicate = HasAtomicBufferGlobalPkAddF16NoRtnInsts in
11130b57cec5SDimitry Andricdefm BUFFER_ATOMIC_PK_ADD_F16 : MUBUF_Pseudo_Atomics_NO_RTN <
1114349cc55cSDimitry Andric  "buffer_atomic_pk_add_f16", VGPR_32, v2f16
11150b57cec5SDimitry Andric>;
1116fe6060f1SDimitry Andric
111781ad6265SDimitry Andriclet OtherPredicates = [HasAtomicFaddRtnInsts] in
1118fe6060f1SDimitry Andricdefm BUFFER_ATOMIC_ADD_F32 : MUBUF_Pseudo_Atomics_RTN<
1119bdd1243dSDimitry Andric  "buffer_atomic_add_f32", VGPR_32, f32, null_frag
1120fe6060f1SDimitry Andric>;
112181ad6265SDimitry Andric
1122*06c3fb27SDimitry Andriclet OtherPredicates = [HasAtomicBufferGlobalPkAddF16Insts] in
1123fe6060f1SDimitry Andricdefm BUFFER_ATOMIC_PK_ADD_F16 : MUBUF_Pseudo_Atomics_RTN <
1124bdd1243dSDimitry Andric  "buffer_atomic_pk_add_f16", VGPR_32, v2f16, null_frag
1125fe6060f1SDimitry Andric>;
11260b57cec5SDimitry Andric
11270b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
11280b57cec5SDimitry Andric// MTBUF Instructions
11290b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
11300b57cec5SDimitry Andric
11318bcb0991SDimitry Andricdefm TBUFFER_LOAD_FORMAT_X     : MTBUF_Pseudo_Loads  <"tbuffer_load_format_x",     VGPR_32,  1>;
11328bcb0991SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XY    : MTBUF_Pseudo_Loads  <"tbuffer_load_format_xy",    VReg_64,  2>;
11338bcb0991SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZ   : MTBUF_Pseudo_Loads  <"tbuffer_load_format_xyz",   VReg_96,  3>;
11348bcb0991SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZW  : MTBUF_Pseudo_Loads  <"tbuffer_load_format_xyzw",  VReg_128, 4>;
11358bcb0991SDimitry Andricdefm TBUFFER_STORE_FORMAT_X    : MTBUF_Pseudo_Stores <"tbuffer_store_format_x",    VGPR_32,  1>;
11368bcb0991SDimitry Andricdefm TBUFFER_STORE_FORMAT_XY   : MTBUF_Pseudo_Stores <"tbuffer_store_format_xy",   VReg_64,  2>;
11378bcb0991SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZ  : MTBUF_Pseudo_Stores <"tbuffer_store_format_xyz",  VReg_96,  3>;
11388bcb0991SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZW : MTBUF_Pseudo_Stores <"tbuffer_store_format_xyzw", VReg_128, 4>;
11390b57cec5SDimitry Andric
11400b57cec5SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem, D16Buf = 1 in {
1141bdd1243dSDimitry Andriclet TiedSourceNotRead = 1 in {
11428bcb0991SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_X_gfx80     : MTBUF_Pseudo_Loads  <"tbuffer_load_format_d16_x",     VGPR_32,  1>;
11438bcb0991SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XY_gfx80    : MTBUF_Pseudo_Loads  <"tbuffer_load_format_d16_xy",    VReg_64,  2>;
11448bcb0991SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XYZ_gfx80   : MTBUF_Pseudo_Loads  <"tbuffer_load_format_d16_xyz",   VReg_96,  3>;
11458bcb0991SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XYZW_gfx80  : MTBUF_Pseudo_Loads  <"tbuffer_load_format_d16_xyzw",  VReg_128, 4>;
1146bdd1243dSDimitry Andric}
11478bcb0991SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_X_gfx80    : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_x",    VGPR_32,  1>;
11488bcb0991SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XY_gfx80   : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xy",   VReg_64,  2>;
11498bcb0991SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XYZ_gfx80  : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xyz",  VReg_96,  3>;
11508bcb0991SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XYZW_gfx80 : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xyzw", VReg_128, 4>;
11510b57cec5SDimitry Andric} // End HasUnpackedD16VMem.
11520b57cec5SDimitry Andric
11530b57cec5SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem, D16Buf = 1 in {
1154bdd1243dSDimitry Andriclet TiedSourceNotRead = 1 in {
11558bcb0991SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_X     : MTBUF_Pseudo_Loads  <"tbuffer_load_format_d16_x",     VGPR_32, 1>;
11568bcb0991SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XY    : MTBUF_Pseudo_Loads  <"tbuffer_load_format_d16_xy",    VGPR_32, 2>;
11578bcb0991SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XYZ   : MTBUF_Pseudo_Loads  <"tbuffer_load_format_d16_xyz",   VReg_64, 3>;
11588bcb0991SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XYZW  : MTBUF_Pseudo_Loads  <"tbuffer_load_format_d16_xyzw",  VReg_64, 4>;
1159bdd1243dSDimitry Andric}
11608bcb0991SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_X    : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_x",    VGPR_32, 1>;
11618bcb0991SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XY   : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xy",   VGPR_32, 2>;
11628bcb0991SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XYZ  : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xyz",  VReg_64, 3>;
11638bcb0991SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XYZW : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xyzw", VReg_64, 4>;
11640b57cec5SDimitry Andric} // End HasPackedD16VMem.
11650b57cec5SDimitry Andric
11660b57cec5SDimitry Andriclet SubtargetPredicate = isGFX7Plus in {
11670b57cec5SDimitry Andric
11680b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
11690b57cec5SDimitry Andric// Instruction definitions for CI and newer.
11700b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
11710b57cec5SDimitry Andric
11720b57cec5SDimitry Andricdef BUFFER_WBINVL1_VOL : MUBUF_Invalidate <"buffer_wbinvl1_vol",
11730b57cec5SDimitry Andric                                           int_amdgcn_buffer_wbinvl1_vol>;
11740b57cec5SDimitry Andric
11750b57cec5SDimitry Andric} // End let SubtargetPredicate = isGFX7Plus
11760b57cec5SDimitry Andric
1177fe6060f1SDimitry Andriclet SubtargetPredicate = isGFX90APlus in {
1178fe6060f1SDimitry Andric  def BUFFER_WBL2  : MUBUF_Invalidate<"buffer_wbl2"> {
117981ad6265SDimitry Andric    let has_glc = 1;
118081ad6265SDimitry Andric    let has_sccb = 1;
118181ad6265SDimitry Andric    let InOperandList = (ins CPol_0:$cpol);
118281ad6265SDimitry Andric    let AsmOperands = "$cpol";
1183fe6060f1SDimitry Andric  }
1184fe6060f1SDimitry Andric  def BUFFER_INVL2 : MUBUF_Invalidate<"buffer_invl2"> {
118581ad6265SDimitry Andric    let SubtargetPredicate = isGFX90AOnly;
1186fe6060f1SDimitry Andric  }
1187fe6060f1SDimitry Andric
118881ad6265SDimitry Andric  defm BUFFER_ATOMIC_ADD_F64 : MUBUF_Pseudo_Atomics<"buffer_atomic_add_f64", VReg_64, f64>;
118981ad6265SDimitry Andric  defm BUFFER_ATOMIC_MIN_F64 : MUBUF_Pseudo_Atomics<"buffer_atomic_min_f64", VReg_64, f64>;
119081ad6265SDimitry Andric  defm BUFFER_ATOMIC_MAX_F64 : MUBUF_Pseudo_Atomics<"buffer_atomic_max_f64", VReg_64, f64>;
1191fe6060f1SDimitry Andric} // End SubtargetPredicate = isGFX90APlus
1192fe6060f1SDimitry Andric
119381ad6265SDimitry Andricdef BUFFER_INV : MUBUF_Invalidate<"buffer_inv"> {
119481ad6265SDimitry Andric  let SubtargetPredicate = isGFX940Plus;
119581ad6265SDimitry Andric  let has_glc = 1;
119681ad6265SDimitry Andric  let has_sccb = 1;
119781ad6265SDimitry Andric  let InOperandList = (ins CPol_0:$cpol);
119881ad6265SDimitry Andric  let AsmOperands = "$cpol";
119981ad6265SDimitry Andric}
120081ad6265SDimitry Andric
12010b57cec5SDimitry Andriclet SubtargetPredicate = isGFX10Plus in {
12020b57cec5SDimitry Andric  def BUFFER_GL0_INV : MUBUF_Invalidate<"buffer_gl0_inv">;
12030b57cec5SDimitry Andric  def BUFFER_GL1_INV : MUBUF_Invalidate<"buffer_gl1_inv">;
12040b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX10Plus
12050b57cec5SDimitry Andric
12060b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
12070b57cec5SDimitry Andric// MUBUF Patterns
12080b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
12090b57cec5SDimitry Andric
12100b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
12110b57cec5SDimitry Andric// buffer_load/store_format patterns
12120b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
12130b57cec5SDimitry Andric
12140b57cec5SDimitry Andricmulticlass MUBUF_LoadIntrinsicPat<SDPatternOperator name, ValueType vt,
1215e8d8bef9SDimitry Andric                                  string opcode, ValueType memoryVt = vt> {
1216fe6060f1SDimitry Andric  defvar st = !if(!eq(memoryVt, vt), name, mubuf_intrinsic_load<name, memoryVt>);
1217e8d8bef9SDimitry Andric
12180b57cec5SDimitry Andric  def : GCNPat<
1219e8d8bef9SDimitry Andric    (vt (st v4i32:$rsrc, 0, 0, i32:$soffset, timm:$offset,
12208bcb0991SDimitry Andric              timm:$auxiliary, 0)),
1221*06c3fb27SDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _OFFSET) SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset,
1222bdd1243dSDimitry Andric      (extract_cpol $auxiliary), (extract_swz $auxiliary))
12230b57cec5SDimitry Andric  >;
12240b57cec5SDimitry Andric
12250b57cec5SDimitry Andric  def : GCNPat<
1226e8d8bef9SDimitry Andric    (vt (st v4i32:$rsrc, 0, i32:$voffset, i32:$soffset, timm:$offset,
12278bcb0991SDimitry Andric              timm:$auxiliary, 0)),
1228*06c3fb27SDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _OFFEN) VGPR_32:$voffset, SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset,
1229bdd1243dSDimitry Andric      (extract_cpol $auxiliary), (extract_swz $auxiliary))
12300b57cec5SDimitry Andric  >;
12310b57cec5SDimitry Andric
12320b57cec5SDimitry Andric  def : GCNPat<
1233e8d8bef9SDimitry Andric    (vt (st v4i32:$rsrc, i32:$vindex, 0, i32:$soffset, timm:$offset,
12348bcb0991SDimitry Andric              timm:$auxiliary, timm)),
1235*06c3fb27SDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _IDXEN) VGPR_32:$vindex, SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset,
1236bdd1243dSDimitry Andric      (extract_cpol $auxiliary), (extract_swz $auxiliary))
12370b57cec5SDimitry Andric  >;
12380b57cec5SDimitry Andric
12390b57cec5SDimitry Andric  def : GCNPat<
1240e8d8bef9SDimitry Andric    (vt (st v4i32:$rsrc, i32:$vindex, i32:$voffset, i32:$soffset, timm:$offset,
12418bcb0991SDimitry Andric              timm:$auxiliary, timm)),
12420b57cec5SDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _BOTHEN)
12435ffd83dbSDimitry Andric      (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1),
1244*06c3fb27SDimitry Andric      SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset,
1245bdd1243dSDimitry Andric      (extract_cpol $auxiliary), (extract_swz $auxiliary))
12460b57cec5SDimitry Andric  >;
12470b57cec5SDimitry Andric}
12480b57cec5SDimitry Andric
12490b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, f32, "BUFFER_LOAD_FORMAT_X">;
12500b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, i32, "BUFFER_LOAD_FORMAT_X">;
12510b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v2f32, "BUFFER_LOAD_FORMAT_XY">;
12520b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v2i32, "BUFFER_LOAD_FORMAT_XY">;
12530b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v3f32, "BUFFER_LOAD_FORMAT_XYZ">;
12540b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v3i32, "BUFFER_LOAD_FORMAT_XYZ">;
12550b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v4f32, "BUFFER_LOAD_FORMAT_XYZW">;
12560b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v4i32, "BUFFER_LOAD_FORMAT_XYZW">;
12570b57cec5SDimitry Andric
1258bdd1243dSDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_tfe, v2i32, "BUFFER_LOAD_FORMAT_X_TFE">;
1259bdd1243dSDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_tfe, v3i32, "BUFFER_LOAD_FORMAT_XY_TFE">;
1260bdd1243dSDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_tfe, v4i32, "BUFFER_LOAD_FORMAT_XYZ_TFE">;
1261bdd1243dSDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_tfe, v5i32, "BUFFER_LOAD_FORMAT_XYZW_TFE">;
1262bdd1243dSDimitry Andric
12630b57cec5SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem in {
12640b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, f16, "BUFFER_LOAD_FORMAT_D16_X_gfx80">;
12650b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, i16, "BUFFER_LOAD_FORMAT_D16_X_gfx80">;
12665ffd83dbSDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, i32, "BUFFER_LOAD_FORMAT_D16_X_gfx80">;
12670b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v2i32, "BUFFER_LOAD_FORMAT_D16_XY_gfx80">;
1268e8d8bef9SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v3i32, "BUFFER_LOAD_FORMAT_D16_XYZ_gfx80">;
12690b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v4i32, "BUFFER_LOAD_FORMAT_D16_XYZW_gfx80">;
12700b57cec5SDimitry Andric} // End HasUnpackedD16VMem.
12710b57cec5SDimitry Andric
12720b57cec5SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem in {
12730b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, f16, "BUFFER_LOAD_FORMAT_D16_X">;
12740b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, i16, "BUFFER_LOAD_FORMAT_D16_X">;
12755ffd83dbSDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, i32, "BUFFER_LOAD_FORMAT_D16_X">;
12760b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v2f16, "BUFFER_LOAD_FORMAT_D16_XY">;
12770b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v2i16, "BUFFER_LOAD_FORMAT_D16_XY">;
1278e8d8bef9SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v4f16, "BUFFER_LOAD_FORMAT_D16_XYZ", v3f16>;
1279e8d8bef9SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v4i16, "BUFFER_LOAD_FORMAT_D16_XYZ", v3i16>;
12800b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v4f16, "BUFFER_LOAD_FORMAT_D16_XYZW">;
12810b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v4i16, "BUFFER_LOAD_FORMAT_D16_XYZW">;
12820b57cec5SDimitry Andric} // End HasPackedD16VMem.
12830b57cec5SDimitry Andric
12840b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, f32, "BUFFER_LOAD_DWORD">;
12850b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, i32, "BUFFER_LOAD_DWORD">;
12868bcb0991SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v2i16, "BUFFER_LOAD_DWORD">;
12878bcb0991SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v2f16, "BUFFER_LOAD_DWORD">;
12880b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v2f32, "BUFFER_LOAD_DWORDX2">;
12890b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v2i32, "BUFFER_LOAD_DWORDX2">;
12908bcb0991SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v4i16, "BUFFER_LOAD_DWORDX2">;
12918bcb0991SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v4f16, "BUFFER_LOAD_DWORDX2">;
12920b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v3f32, "BUFFER_LOAD_DWORDX3">;
12930b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v3i32, "BUFFER_LOAD_DWORDX3">;
12940b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v4f32, "BUFFER_LOAD_DWORDX4">;
12950b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v4i32, "BUFFER_LOAD_DWORDX4">;
12960b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_byte, i32, "BUFFER_LOAD_SBYTE">;
12970b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_short, i32, "BUFFER_LOAD_SSHORT">;
12980b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_ubyte, i32, "BUFFER_LOAD_UBYTE">;
12990b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_ushort,  i32, "BUFFER_LOAD_USHORT">;
13000b57cec5SDimitry Andric
13010b57cec5SDimitry Andricmulticlass MUBUF_StoreIntrinsicPat<SDPatternOperator name, ValueType vt,
1302e8d8bef9SDimitry Andric                                   string opcode, ValueType memoryVt = vt> {
1303fe6060f1SDimitry Andric  defvar st = !if(!eq(memoryVt, vt), name, mubuf_intrinsic_store<name, memoryVt>);
1304e8d8bef9SDimitry Andric
13050b57cec5SDimitry Andric  def : GCNPat<
1306e8d8bef9SDimitry Andric    (st vt:$vdata, v4i32:$rsrc, 0, 0, i32:$soffset, timm:$offset,
13078bcb0991SDimitry Andric              timm:$auxiliary, 0),
1308*06c3fb27SDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _OFFSET_exact) getVregSrcForVT<vt>.ret:$vdata, SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset,
1309bdd1243dSDimitry Andric      (extract_cpol $auxiliary), (extract_swz $auxiliary))
13100b57cec5SDimitry Andric  >;
13110b57cec5SDimitry Andric
13120b57cec5SDimitry Andric  def : GCNPat<
1313e8d8bef9SDimitry Andric    (st vt:$vdata, v4i32:$rsrc, 0, i32:$voffset, i32:$soffset, timm:$offset,
13148bcb0991SDimitry Andric              timm:$auxiliary, 0),
13155ffd83dbSDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _OFFEN_exact) getVregSrcForVT<vt>.ret:$vdata, VGPR_32:$voffset, SReg_128:$rsrc, SCSrc_b32:$soffset,
1316*06c3fb27SDimitry Andric      timm:$offset, (extract_cpol $auxiliary), (extract_swz $auxiliary))
13170b57cec5SDimitry Andric  >;
13180b57cec5SDimitry Andric
13190b57cec5SDimitry Andric  def : GCNPat<
1320e8d8bef9SDimitry Andric    (st vt:$vdata, v4i32:$rsrc, i32:$vindex, 0, i32:$soffset, timm:$offset,
13218bcb0991SDimitry Andric              timm:$auxiliary, timm),
13225ffd83dbSDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _IDXEN_exact) getVregSrcForVT<vt>.ret:$vdata, VGPR_32:$vindex, SReg_128:$rsrc, SCSrc_b32:$soffset,
1323*06c3fb27SDimitry Andric      timm:$offset, (extract_cpol $auxiliary), (extract_swz $auxiliary))
13240b57cec5SDimitry Andric  >;
13250b57cec5SDimitry Andric
13260b57cec5SDimitry Andric  def : GCNPat<
1327e8d8bef9SDimitry Andric    (st vt:$vdata, v4i32:$rsrc, i32:$vindex, i32:$voffset, i32:$soffset, timm:$offset,
13288bcb0991SDimitry Andric              timm:$auxiliary, timm),
13290b57cec5SDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _BOTHEN_exact)
13305ffd83dbSDimitry Andric      getVregSrcForVT<vt>.ret:$vdata,
13315ffd83dbSDimitry Andric      (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1),
1332*06c3fb27SDimitry Andric      SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, (extract_cpol $auxiliary),
1333bdd1243dSDimitry Andric      (extract_swz $auxiliary))
13340b57cec5SDimitry Andric  >;
13350b57cec5SDimitry Andric}
13360b57cec5SDimitry Andric
13370b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, f32, "BUFFER_STORE_FORMAT_X">;
13380b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, i32, "BUFFER_STORE_FORMAT_X">;
13390b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v2f32, "BUFFER_STORE_FORMAT_XY">;
13400b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v2i32, "BUFFER_STORE_FORMAT_XY">;
13410b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v3f32, "BUFFER_STORE_FORMAT_XYZ">;
13420b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v3i32, "BUFFER_STORE_FORMAT_XYZ">;
13430b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v4f32, "BUFFER_STORE_FORMAT_XYZW">;
13440b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v4i32, "BUFFER_STORE_FORMAT_XYZW">;
13450b57cec5SDimitry Andric
13460b57cec5SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem in {
13470b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, f16, "BUFFER_STORE_FORMAT_D16_X_gfx80">;
13480b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, i16, "BUFFER_STORE_FORMAT_D16_X_gfx80">;
13495ffd83dbSDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, i32, "BUFFER_STORE_FORMAT_D16_X_gfx80">;
13500b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v2i32, "BUFFER_STORE_FORMAT_D16_XY_gfx80">;
1351e8d8bef9SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v3i32, "BUFFER_STORE_FORMAT_D16_XYZ_gfx80">;
13520b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v4i32, "BUFFER_STORE_FORMAT_D16_XYZW_gfx80">;
13530b57cec5SDimitry Andric} // End HasUnpackedD16VMem.
13540b57cec5SDimitry Andric
13550b57cec5SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem in {
13560b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, f16, "BUFFER_STORE_FORMAT_D16_X">;
13570b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, i16, "BUFFER_STORE_FORMAT_D16_X">;
13585ffd83dbSDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, i32, "BUFFER_STORE_FORMAT_D16_X">;
13590b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v2f16, "BUFFER_STORE_FORMAT_D16_XY">;
13600b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v2i16, "BUFFER_STORE_FORMAT_D16_XY">;
1361e8d8bef9SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v4f16, "BUFFER_STORE_FORMAT_D16_XYZ", v3f16>;
1362e8d8bef9SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v4i16, "BUFFER_STORE_FORMAT_D16_XYZ", v3i16>;
13630b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v4f16, "BUFFER_STORE_FORMAT_D16_XYZW">;
13640b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v4i16, "BUFFER_STORE_FORMAT_D16_XYZW">;
13650b57cec5SDimitry Andric} // End HasPackedD16VMem.
13660b57cec5SDimitry Andric
13670b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, f32, "BUFFER_STORE_DWORD">;
13680b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, i32, "BUFFER_STORE_DWORD">;
13698bcb0991SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v2i16, "BUFFER_STORE_DWORD">;
13708bcb0991SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v2f16, "BUFFER_STORE_DWORD">;
13710b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v2f32, "BUFFER_STORE_DWORDX2">;
13720b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v2i32, "BUFFER_STORE_DWORDX2">;
13738bcb0991SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v4i16, "BUFFER_STORE_DWORDX2">;
13748bcb0991SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v4f16, "BUFFER_STORE_DWORDX2">;
13750b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v3f32, "BUFFER_STORE_DWORDX3">;
13760b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v3i32, "BUFFER_STORE_DWORDX3">;
13770b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v4f32, "BUFFER_STORE_DWORDX4">;
13780b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v4i32, "BUFFER_STORE_DWORDX4">;
13790b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_byte, i32, "BUFFER_STORE_BYTE">;
13800b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_short, i32, "BUFFER_STORE_SHORT">;
13810b57cec5SDimitry Andric
13820b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
13830b57cec5SDimitry Andric// buffer_atomic patterns
13840b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
13850b57cec5SDimitry Andric
138681ad6265SDimitry Andricmulticlass BufferAtomicPat<string OpPrefix, ValueType vt, string Inst, bit isIntr = 0> {
138781ad6265SDimitry Andric  foreach RtnMode = ["ret", "noret"] in {
138881ad6265SDimitry Andric
1389753f127fSDimitry Andric  defvar Op = !cast<SDPatternOperator>(OpPrefix
1390753f127fSDimitry Andric                                       # !if(!eq(RtnMode, "ret"), "", "_noret")
139181ad6265SDimitry Andric                                       # !if(isIntr, "", "_" # vt.Size));
139281ad6265SDimitry Andric  defvar InstSuffix = !if(!eq(RtnMode, "ret"), "_RTN", "");
139381ad6265SDimitry Andric
1394753f127fSDimitry Andric  let AddedComplexity = !if(!eq(RtnMode, "ret"), 0, 1) in {
13950b57cec5SDimitry Andric  def : GCNPat<
1396*06c3fb27SDimitry Andric    (vt (Op (MUBUFOffset v4i32:$srsrc, i32:$soffset, i32:$offset), vt:$vdata_in)),
139781ad6265SDimitry Andric    (!cast<MUBUF_Pseudo>(Inst # "_OFFSET" # InstSuffix) getVregSrcForVT<vt>.ret:$vdata_in,
139881ad6265SDimitry Andric      SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset)
13990b57cec5SDimitry Andric  >;
14000b57cec5SDimitry Andric
14010b57cec5SDimitry Andric  def : GCNPat<
1402*06c3fb27SDimitry Andric    (vt (Op (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset, i32:$offset),
140381ad6265SDimitry Andric      vt:$vdata_in)),
140481ad6265SDimitry Andric    (!cast<MUBUF_Pseudo>(Inst # "_ADDR64" # InstSuffix) getVregSrcForVT<vt>.ret:$vdata_in,
140581ad6265SDimitry Andric      VReg_64:$vaddr, SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset)
14060b57cec5SDimitry Andric  >;
1407753f127fSDimitry Andric  } // end let AddedComplexity
14080b57cec5SDimitry Andric
140981ad6265SDimitry Andric  } // end foreach RtnMode
14100b57cec5SDimitry Andric}
14110b57cec5SDimitry Andric
141281ad6265SDimitry Andricmulticlass BufferAtomicIntrPat<string OpPrefix, ValueType vt, string Inst> {
141381ad6265SDimitry Andric  defm : BufferAtomicPat<OpPrefix, vt, Inst, /* isIntr */ 1>;
141481ad6265SDimitry Andric}
14150b57cec5SDimitry Andric
141681ad6265SDimitry Andricmulticlass BufferAtomicCmpSwapPat<ValueType vt, ValueType data_vt, string Inst> {
141781ad6265SDimitry Andric  foreach RtnMode = ["ret", "noret"] in {
141881ad6265SDimitry Andric
1419753f127fSDimitry Andric  defvar Op = !cast<SDPatternOperator>("AMDGPUatomic_cmp_swap_global"
1420753f127fSDimitry Andric                                       # !if(!eq(RtnMode, "ret"), "", "_noret")
142181ad6265SDimitry Andric                                       # "_" # vt.Size);
142281ad6265SDimitry Andric  defvar InstSuffix = !if(!eq(RtnMode, "ret"), "_RTN", "");
142381ad6265SDimitry Andric
1424753f127fSDimitry Andric  let AddedComplexity = !if(!eq(RtnMode, "ret"), 0, 1) in {
142581ad6265SDimitry Andric  defvar OffsetResDag = (!cast<MUBUF_Pseudo>(Inst # "_OFFSET" # InstSuffix)
142681ad6265SDimitry Andric    getVregSrcForVT<data_vt>.ret:$vdata_in, SReg_128:$srsrc, SCSrc_b32:$soffset,
142781ad6265SDimitry Andric    offset:$offset);
142881ad6265SDimitry Andric  def : GCNPat<
1429*06c3fb27SDimitry Andric    (vt (Op (MUBUFOffset v4i32:$srsrc, i32:$soffset, i32:$offset), data_vt:$vdata_in)),
143081ad6265SDimitry Andric    !if(!eq(RtnMode, "ret"),
143181ad6265SDimitry Andric      (EXTRACT_SUBREG (vt (COPY_TO_REGCLASS OffsetResDag, getVregSrcForVT<data_vt>.ret)),
143281ad6265SDimitry Andric        !if(!eq(vt, i32), sub0, sub0_sub1)),
143381ad6265SDimitry Andric      OffsetResDag)
143481ad6265SDimitry Andric  >;
143581ad6265SDimitry Andric
143681ad6265SDimitry Andric  defvar Addr64ResDag = (!cast<MUBUF_Pseudo>(Inst # "_ADDR64" # InstSuffix)
143781ad6265SDimitry Andric    getVregSrcForVT<data_vt>.ret:$vdata_in, VReg_64:$vaddr, SReg_128:$srsrc,
143881ad6265SDimitry Andric    SCSrc_b32:$soffset, offset:$offset);
143981ad6265SDimitry Andric  def : GCNPat<
1440*06c3fb27SDimitry Andric    (vt (Op (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset, i32:$offset),
144181ad6265SDimitry Andric      data_vt:$vdata_in)),
144281ad6265SDimitry Andric    !if(!eq(RtnMode, "ret"),
144381ad6265SDimitry Andric      (EXTRACT_SUBREG (vt (COPY_TO_REGCLASS Addr64ResDag, getVregSrcForVT<data_vt>.ret)),
144481ad6265SDimitry Andric        !if(!eq(vt, i32), sub0, sub0_sub1)),
144581ad6265SDimitry Andric      Addr64ResDag)
144681ad6265SDimitry Andric  >;
1447753f127fSDimitry Andric  } // end let AddedComplexity
144881ad6265SDimitry Andric
144981ad6265SDimitry Andric  } // end foreach RtnMode
145081ad6265SDimitry Andric}
145181ad6265SDimitry Andric
145281ad6265SDimitry Andricforeach Ty = [i32, i64] in {
145381ad6265SDimitry Andric
145481ad6265SDimitry Andricdefvar Suffix = !if(!eq(Ty, i64), "_X2", "");
145581ad6265SDimitry Andric
145681ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_swap_global", Ty, "BUFFER_ATOMIC_SWAP" # Suffix>;
145781ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_load_add_global", Ty, "BUFFER_ATOMIC_ADD" # Suffix>;
145881ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_load_sub_global", Ty, "BUFFER_ATOMIC_SUB" # Suffix>;
145981ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_load_min_global", Ty, "BUFFER_ATOMIC_SMIN" # Suffix>;
146081ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_load_umin_global", Ty, "BUFFER_ATOMIC_UMIN" # Suffix>;
146181ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_load_max_global", Ty, "BUFFER_ATOMIC_SMAX" # Suffix>;
146281ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_load_umax_global", Ty, "BUFFER_ATOMIC_UMAX" # Suffix>;
146381ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_load_and_global", Ty, "BUFFER_ATOMIC_AND" # Suffix>;
146481ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_load_or_global", Ty, "BUFFER_ATOMIC_OR" # Suffix>;
146581ad6265SDimitry Andricdefm : BufferAtomicPat<"atomic_load_xor_global", Ty, "BUFFER_ATOMIC_XOR" # Suffix>;
1466*06c3fb27SDimitry Andricdefm : BufferAtomicPat<"atomic_load_uinc_wrap_global", Ty, "BUFFER_ATOMIC_INC" # Suffix>;
1467*06c3fb27SDimitry Andricdefm : BufferAtomicPat<"atomic_load_udec_wrap_global", Ty, "BUFFER_ATOMIC_DEC" # Suffix>;
146881ad6265SDimitry Andric
146981ad6265SDimitry Andric} // end foreach Ty
147081ad6265SDimitry Andric
147181ad6265SDimitry Andricdefm : BufferAtomicCmpSwapPat<i32, v2i32, "BUFFER_ATOMIC_CMPSWAP">;
147281ad6265SDimitry Andricdefm : BufferAtomicCmpSwapPat<i64, v2i64, "BUFFER_ATOMIC_CMPSWAP_X2">;
147381ad6265SDimitry Andric
147481ad6265SDimitry Andricmulticlass SIBufferAtomicPat<string OpPrefix, ValueType vt, string Inst,
147581ad6265SDimitry Andric                             list<string> RtnModes = ["ret", "noret"]> {
147681ad6265SDimitry Andric  foreach RtnMode = RtnModes in {
147781ad6265SDimitry Andric
1478753f127fSDimitry Andric  defvar Op = !cast<SDPatternOperator>(OpPrefix
1479753f127fSDimitry Andric                                       # !if(!eq(RtnMode, "ret"), "", "_noret"));
1480753f127fSDimitry Andric
1481753f127fSDimitry Andric  defvar InstSuffix = !if(!eq(RtnMode, "ret"), "_RTN", "");
1482753f127fSDimitry Andric  defvar CachePolicy = !if(!eq(RtnMode, "ret"),
148381ad6265SDimitry Andric    (set_glc $cachepolicy), (timm:$cachepolicy));
148481ad6265SDimitry Andric
1485753f127fSDimitry Andric  let AddedComplexity = !if(!eq(RtnMode, "ret"), 0, 1) in {
148681ad6265SDimitry Andric  def : GCNPat<
148781ad6265SDimitry Andric    (vt (Op vt:$vdata_in, v4i32:$rsrc, 0, 0, i32:$soffset,
148881ad6265SDimitry Andric              timm:$offset, timm:$cachepolicy, 0)),
148981ad6265SDimitry Andric    (!cast<MUBUF_Pseudo>(Inst # "_OFFSET" # InstSuffix)
149081ad6265SDimitry Andric      getVregSrcForVT<vt>.ret:$vdata_in, SReg_128:$rsrc, SCSrc_b32:$soffset,
1491*06c3fb27SDimitry Andric      timm:$offset, CachePolicy)
149281ad6265SDimitry Andric  >;
149381ad6265SDimitry Andric
149481ad6265SDimitry Andric  def : GCNPat<
149581ad6265SDimitry Andric    (vt (Op vt:$vdata_in, v4i32:$rsrc, i32:$vindex, 0, i32:$soffset,
149681ad6265SDimitry Andric              timm:$offset, timm:$cachepolicy, timm)),
149781ad6265SDimitry Andric    (!cast<MUBUF_Pseudo>(Inst # "_IDXEN" # InstSuffix)
149881ad6265SDimitry Andric      getVregSrcForVT<vt>.ret:$vdata_in, VGPR_32:$vindex, SReg_128:$rsrc,
1499*06c3fb27SDimitry Andric      SCSrc_b32:$soffset, timm:$offset, CachePolicy)
150081ad6265SDimitry Andric  >;
150181ad6265SDimitry Andric
150281ad6265SDimitry Andric  def : GCNPat<
150381ad6265SDimitry Andric    (vt (Op vt:$vdata_in, v4i32:$rsrc, 0, i32:$voffset,
150481ad6265SDimitry Andric              i32:$soffset, timm:$offset, timm:$cachepolicy, 0)),
150581ad6265SDimitry Andric    (!cast<MUBUF_Pseudo>(Inst # "_OFFEN" # InstSuffix)
150681ad6265SDimitry Andric      getVregSrcForVT<vt>.ret:$vdata_in, VGPR_32:$voffset, SReg_128:$rsrc,
1507*06c3fb27SDimitry Andric      SCSrc_b32:$soffset, timm:$offset, CachePolicy)
150881ad6265SDimitry Andric  >;
150981ad6265SDimitry Andric
151081ad6265SDimitry Andric  def : GCNPat<
151181ad6265SDimitry Andric    (vt (Op vt:$vdata_in, v4i32:$rsrc, i32:$vindex, i32:$voffset,
151281ad6265SDimitry Andric              i32:$soffset, timm:$offset, timm:$cachepolicy, timm)),
151381ad6265SDimitry Andric    (!cast<MUBUF_Pseudo>(Inst # "_BOTHEN" # InstSuffix)
151481ad6265SDimitry Andric      getVregSrcForVT<vt>.ret:$vdata_in,
151581ad6265SDimitry Andric      (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1),
1516*06c3fb27SDimitry Andric        SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, CachePolicy)
151781ad6265SDimitry Andric  >;
1518753f127fSDimitry Andric  } // end let AddedComplexity
151981ad6265SDimitry Andric
152081ad6265SDimitry Andric  } // end foreach RtnMode
152181ad6265SDimitry Andric}
152281ad6265SDimitry Andric
152381ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_swap", i32, "BUFFER_ATOMIC_SWAP">;
152481ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_swap", f32, "BUFFER_ATOMIC_SWAP">;
152581ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_add", i32, "BUFFER_ATOMIC_ADD">;
152681ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_sub", i32, "BUFFER_ATOMIC_SUB">;
152781ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_smin", i32, "BUFFER_ATOMIC_SMIN">;
152881ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_umin", i32, "BUFFER_ATOMIC_UMIN">;
152981ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_smax", i32, "BUFFER_ATOMIC_SMAX">;
153081ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_umax", i32, "BUFFER_ATOMIC_UMAX">;
153181ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_and", i32, "BUFFER_ATOMIC_AND">;
153281ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_or", i32, "BUFFER_ATOMIC_OR">;
153381ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_xor", i32, "BUFFER_ATOMIC_XOR">;
153481ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_inc", i32, "BUFFER_ATOMIC_INC">;
153581ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_dec", i32, "BUFFER_ATOMIC_DEC">;
1536753f127fSDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_csub", i32, "BUFFER_ATOMIC_CSUB", ["ret"]>;
153781ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_swap", i64, "BUFFER_ATOMIC_SWAP_X2">;
153881ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_add", i64,  "BUFFER_ATOMIC_ADD_X2">;
153981ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_sub", i64, "BUFFER_ATOMIC_SUB_X2">;
154081ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_smin", i64, "BUFFER_ATOMIC_SMIN_X2">;
154181ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_umin", i64, "BUFFER_ATOMIC_UMIN_X2">;
154281ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_smax", i64, "BUFFER_ATOMIC_SMAX_X2">;
154381ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_umax", i64, "BUFFER_ATOMIC_UMAX_X2">;
154481ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_and", i64, "BUFFER_ATOMIC_AND_X2">;
154581ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_or", i64, "BUFFER_ATOMIC_OR_X2">;
154681ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_xor", i64, "BUFFER_ATOMIC_XOR_X2">;
154781ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_inc", i64, "BUFFER_ATOMIC_INC_X2">;
154881ad6265SDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_dec", i64, "BUFFER_ATOMIC_DEC_X2">;
154981ad6265SDimitry Andric
155081ad6265SDimitry Andriclet SubtargetPredicate = isGFX6GFX7GFX10Plus in {
155181ad6265SDimitry Andric  defm : SIBufferAtomicPat<"SIbuffer_atomic_fmin", f32, "BUFFER_ATOMIC_FMIN">;
155281ad6265SDimitry Andric  defm : SIBufferAtomicPat<"SIbuffer_atomic_fmax", f32, "BUFFER_ATOMIC_FMAX">;
155381ad6265SDimitry Andric}
1554349cc55cSDimitry Andriclet SubtargetPredicate = isGFX6GFX7GFX10 in {
155581ad6265SDimitry Andric  defm : SIBufferAtomicPat<"SIbuffer_atomic_fmin", f64, "BUFFER_ATOMIC_FMIN_X2">;
155681ad6265SDimitry Andric  defm : SIBufferAtomicPat<"SIbuffer_atomic_fmax", f64, "BUFFER_ATOMIC_FMAX_X2">;
1557349cc55cSDimitry Andric}
1558349cc55cSDimitry Andric
1559e8d8bef9SDimitry Andricclass NoUseBufferAtomic<SDPatternOperator Op, ValueType vt> : PatFrag <
1560e8d8bef9SDimitry Andric  (ops node:$src0, node:$src1, node:$src2, node:$src3, node:$src4, node:$src5, node:$src6, node:$src7),
1561bdd1243dSDimitry Andric  (vt (Op $src0, $src1, $src2, $src3, $src4, $src5, $src6, $src7))> {
1562bdd1243dSDimitry Andric  let HasNoUse = true;
1563e8d8bef9SDimitry Andric}
1564e8d8bef9SDimitry Andric
15650b57cec5SDimitry Andricmulticlass BufferAtomicPatterns_NO_RTN<SDPatternOperator name, ValueType vt,
15660b57cec5SDimitry Andric                                       string opcode> {
15670b57cec5SDimitry Andric  def : GCNPat<
1568e8d8bef9SDimitry Andric    (NoUseBufferAtomic<name, vt> vt:$vdata_in, v4i32:$rsrc, 0,
15698bcb0991SDimitry Andric                                 0, i32:$soffset, timm:$offset,
15708bcb0991SDimitry Andric                                 timm:$cachepolicy, 0),
1571e8d8bef9SDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _OFFSET) getVregSrcForVT<vt>.ret:$vdata_in, SReg_128:$rsrc, SCSrc_b32:$soffset,
1572*06c3fb27SDimitry Andric                                          timm:$offset, timm:$cachepolicy)
15730b57cec5SDimitry Andric  >;
15740b57cec5SDimitry Andric
15750b57cec5SDimitry Andric  def : GCNPat<
1576e8d8bef9SDimitry Andric    (NoUseBufferAtomic<name, vt> vt:$vdata_in, v4i32:$rsrc, i32:$vindex,
15778bcb0991SDimitry Andric                                 0, i32:$soffset, timm:$offset,
15788bcb0991SDimitry Andric                                 timm:$cachepolicy, timm),
1579e8d8bef9SDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _IDXEN) getVregSrcForVT<vt>.ret:$vdata_in, VGPR_32:$vindex, SReg_128:$rsrc, SCSrc_b32:$soffset,
1580*06c3fb27SDimitry Andric                                          timm:$offset, timm:$cachepolicy)
15810b57cec5SDimitry Andric  >;
15820b57cec5SDimitry Andric
15830b57cec5SDimitry Andric  def : GCNPat<
1584e8d8bef9SDimitry Andric    (NoUseBufferAtomic<name, vt> vt:$vdata_in, v4i32:$rsrc, 0,
15858bcb0991SDimitry Andric                                 i32:$voffset, i32:$soffset, timm:$offset,
15868bcb0991SDimitry Andric                                 timm:$cachepolicy, 0),
1587e8d8bef9SDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _OFFEN) getVregSrcForVT<vt>.ret:$vdata_in, VGPR_32:$voffset, SReg_128:$rsrc, SCSrc_b32:$soffset,
1588*06c3fb27SDimitry Andric                                          timm:$offset, timm:$cachepolicy)
15890b57cec5SDimitry Andric  >;
15900b57cec5SDimitry Andric
15910b57cec5SDimitry Andric  def : GCNPat<
1592e8d8bef9SDimitry Andric    (NoUseBufferAtomic<name, vt> vt:$vdata_in, v4i32:$rsrc, i32:$vindex,
15938bcb0991SDimitry Andric                                 i32:$voffset, i32:$soffset, timm:$offset,
15948bcb0991SDimitry Andric                                 timm:$cachepolicy, timm),
15950b57cec5SDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _BOTHEN)
1596e8d8bef9SDimitry Andric      getVregSrcForVT<vt>.ret:$vdata_in,
1597e8d8bef9SDimitry Andric      (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1),
1598*06c3fb27SDimitry Andric      SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, timm:$cachepolicy)
15990b57cec5SDimitry Andric  >;
16000b57cec5SDimitry Andric}
16010b57cec5SDimitry Andric
160281ad6265SDimitry Andriclet SubtargetPredicate = HasAtomicFaddNoRtnInsts in
1603bdd1243dSDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_fadd", f32, "BUFFER_ATOMIC_ADD_F32", ["noret"]>;
160481ad6265SDimitry Andric
1605*06c3fb27SDimitry Andriclet SubtargetPredicate = HasAtomicBufferGlobalPkAddF16NoRtnInsts in
1606bdd1243dSDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_fadd", v2f16, "BUFFER_ATOMIC_PK_ADD_F16", ["noret"]>;
160781ad6265SDimitry Andric
160881ad6265SDimitry Andriclet SubtargetPredicate = HasAtomicFaddRtnInsts in
1609bdd1243dSDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_fadd", f32, "BUFFER_ATOMIC_ADD_F32", ["ret"]>;
16100b57cec5SDimitry Andric
1611*06c3fb27SDimitry Andriclet SubtargetPredicate = HasAtomicBufferGlobalPkAddF16Insts in
1612bdd1243dSDimitry Andricdefm : SIBufferAtomicPat<"SIbuffer_atomic_fadd", v2f16, "BUFFER_ATOMIC_PK_ADD_F16", ["ret"]>;
1613fe6060f1SDimitry Andric
1614*06c3fb27SDimitry Andriclet SubtargetPredicate = isGFX90APlus in {
161581ad6265SDimitry Andric  defm : SIBufferAtomicPat<"SIbuffer_atomic_fadd", f64, "BUFFER_ATOMIC_ADD_F64">;
161681ad6265SDimitry Andric  defm : SIBufferAtomicPat<"SIbuffer_atomic_fmin", f64, "BUFFER_ATOMIC_MIN_F64">;
161781ad6265SDimitry Andric  defm : SIBufferAtomicPat<"SIbuffer_atomic_fmax", f64, "BUFFER_ATOMIC_MAX_F64">;
1618fe6060f1SDimitry Andric} // End SubtargetPredicate = isGFX90APlus
1619fe6060f1SDimitry Andric
162081ad6265SDimitry Andricforeach RtnMode = ["ret", "noret"] in {
162181ad6265SDimitry Andric
1622753f127fSDimitry Andricdefvar Op = !cast<SDPatternOperator>(SIbuffer_atomic_cmpswap
1623753f127fSDimitry Andric                                     # !if(!eq(RtnMode, "ret"), "", "_noret"));
162481ad6265SDimitry Andricdefvar InstSuffix = !if(!eq(RtnMode, "ret"), "_RTN", "");
162581ad6265SDimitry Andricdefvar CachePolicy = !if(!eq(RtnMode, "ret"), (set_glc $cachepolicy),
162681ad6265SDimitry Andric  (timm:$cachepolicy));
162781ad6265SDimitry Andric
162881ad6265SDimitry Andricdefvar OffsetResDag = (!cast<MUBUF_Pseudo>("BUFFER_ATOMIC_CMPSWAP_OFFSET" # InstSuffix)
162981ad6265SDimitry Andric  (REG_SEQUENCE VReg_64, VGPR_32:$data, sub0, VGPR_32:$cmp, sub1),
1630*06c3fb27SDimitry Andric  SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, CachePolicy);
16310b57cec5SDimitry Andricdef : GCNPat<
163281ad6265SDimitry Andric  (Op
16335ffd83dbSDimitry Andric      i32:$data, i32:$cmp, v4i32:$rsrc, 0, 0, i32:$soffset,
16345ffd83dbSDimitry Andric      timm:$offset, timm:$cachepolicy, 0),
163581ad6265SDimitry Andric  !if(!eq(RtnMode, "ret"),
163681ad6265SDimitry Andric    (EXTRACT_SUBREG (i64 (COPY_TO_REGCLASS OffsetResDag, VReg_64)), sub0),
163781ad6265SDimitry Andric    OffsetResDag)
16380b57cec5SDimitry Andric>;
16390b57cec5SDimitry Andric
164081ad6265SDimitry Andricdefvar IdxenResDag = (!cast<MUBUF_Pseudo>("BUFFER_ATOMIC_CMPSWAP_IDXEN" # InstSuffix)
164181ad6265SDimitry Andric  (REG_SEQUENCE VReg_64, VGPR_32:$data, sub0, VGPR_32:$cmp, sub1),
1642*06c3fb27SDimitry Andric  VGPR_32:$vindex, SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset,
164381ad6265SDimitry Andric  CachePolicy);
16440b57cec5SDimitry Andricdef : GCNPat<
164581ad6265SDimitry Andric  (Op
16460b57cec5SDimitry Andric      i32:$data, i32:$cmp, v4i32:$rsrc, i32:$vindex,
16478bcb0991SDimitry Andric      0, i32:$soffset, timm:$offset,
16488bcb0991SDimitry Andric      timm:$cachepolicy, timm),
164981ad6265SDimitry Andric  !if(!eq(RtnMode, "ret"),
165081ad6265SDimitry Andric    (EXTRACT_SUBREG (i64 (COPY_TO_REGCLASS IdxenResDag, VReg_64)), sub0),
165181ad6265SDimitry Andric    IdxenResDag)
16520b57cec5SDimitry Andric>;
16530b57cec5SDimitry Andric
165481ad6265SDimitry Andricdefvar OffenResDag = (!cast<MUBUF_Pseudo>("BUFFER_ATOMIC_CMPSWAP_OFFEN" # InstSuffix)
165581ad6265SDimitry Andric  (REG_SEQUENCE VReg_64, VGPR_32:$data, sub0, VGPR_32:$cmp, sub1),
1656*06c3fb27SDimitry Andric  VGPR_32:$voffset, SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset,
165781ad6265SDimitry Andric  CachePolicy);
16580b57cec5SDimitry Andricdef : GCNPat<
165981ad6265SDimitry Andric  (Op
16600b57cec5SDimitry Andric      i32:$data, i32:$cmp, v4i32:$rsrc, 0,
16618bcb0991SDimitry Andric      i32:$voffset, i32:$soffset, timm:$offset,
16628bcb0991SDimitry Andric      timm:$cachepolicy, 0),
166381ad6265SDimitry Andric  !if(!eq(RtnMode, "ret"),
166481ad6265SDimitry Andric    (EXTRACT_SUBREG (i64 (COPY_TO_REGCLASS OffenResDag, VReg_64)), sub0),
166581ad6265SDimitry Andric    OffenResDag)
16660b57cec5SDimitry Andric>;
16670b57cec5SDimitry Andric
166881ad6265SDimitry Andricdefvar BothenResDag = (!cast<MUBUF_Pseudo>("BUFFER_ATOMIC_CMPSWAP_BOTHEN" # InstSuffix)
166981ad6265SDimitry Andric  (REG_SEQUENCE VReg_64, VGPR_32:$data, sub0, VGPR_32:$cmp, sub1),
167081ad6265SDimitry Andric  (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1),
1671*06c3fb27SDimitry Andric  SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, CachePolicy);
16720b57cec5SDimitry Andricdef : GCNPat<
167381ad6265SDimitry Andric  (Op
16740b57cec5SDimitry Andric      i32:$data, i32:$cmp, v4i32:$rsrc, i32:$vindex,
16758bcb0991SDimitry Andric      i32:$voffset, i32:$soffset, timm:$offset,
16768bcb0991SDimitry Andric      timm:$cachepolicy, timm),
167781ad6265SDimitry Andric  !if(!eq(RtnMode, "ret"),
167881ad6265SDimitry Andric    (EXTRACT_SUBREG (i64 (COPY_TO_REGCLASS BothenResDag, VReg_64)), sub0),
167981ad6265SDimitry Andric    BothenResDag)
16800b57cec5SDimitry Andric>;
16810b57cec5SDimitry Andric
168281ad6265SDimitry Andric} // end foreach RtnMode
168381ad6265SDimitry Andric
16840b57cec5SDimitry Andricclass MUBUFLoad_PatternADDR64 <MUBUF_Pseudo Instr_ADDR64, ValueType vt,
16850b57cec5SDimitry Andric                              PatFrag constant_ld> : GCNPat <
16860b57cec5SDimitry Andric     (vt (constant_ld (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset,
1687*06c3fb27SDimitry Andric                                   i32:$offset))),
1688fe6060f1SDimitry Andric     (Instr_ADDR64 $vaddr, $srsrc, $soffset, $offset)
16890b57cec5SDimitry Andric  >;
16900b57cec5SDimitry Andric
16910b57cec5SDimitry Andricmulticlass MUBUFLoad_Atomic_Pattern <MUBUF_Pseudo Instr_ADDR64, MUBUF_Pseudo Instr_OFFSET,
16920b57cec5SDimitry Andric                                     ValueType vt, PatFrag atomic_ld> {
16930b57cec5SDimitry Andric  def : GCNPat <
1694*06c3fb27SDimitry Andric     (vt (atomic_ld (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset, i32:$offset))),
1695fe6060f1SDimitry Andric     (Instr_ADDR64 $vaddr, $srsrc, $soffset, $offset)
16960b57cec5SDimitry Andric  >;
16970b57cec5SDimitry Andric
16980b57cec5SDimitry Andric  def : GCNPat <
1699*06c3fb27SDimitry Andric    (vt (atomic_ld (MUBUFOffset v4i32:$rsrc, i32:$soffset, i32:$offset))),
1700fe6060f1SDimitry Andric    (Instr_OFFSET $rsrc, $soffset, (as_i16imm $offset))
17010b57cec5SDimitry Andric  >;
17020b57cec5SDimitry Andric}
17030b57cec5SDimitry Andric
17040b57cec5SDimitry Andriclet SubtargetPredicate = isGFX6GFX7 in {
17050b57cec5SDimitry Andricdef : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_SBYTE_ADDR64, i32, sextloadi8_constant>;
17060b57cec5SDimitry Andricdef : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_UBYTE_ADDR64, i32, extloadi8_constant>;
17070b57cec5SDimitry Andricdef : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_UBYTE_ADDR64, i32, zextloadi8_constant>;
17080b57cec5SDimitry Andricdef : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_SSHORT_ADDR64, i32, sextloadi16_constant>;
17090b57cec5SDimitry Andricdef : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_USHORT_ADDR64, i32, extloadi16_constant>;
17100b57cec5SDimitry Andricdef : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_USHORT_ADDR64, i32, zextloadi16_constant>;
17110b57cec5SDimitry Andric
17120b57cec5SDimitry Andricdefm : MUBUFLoad_Atomic_Pattern <BUFFER_LOAD_DWORD_ADDR64, BUFFER_LOAD_DWORD_OFFSET, i32, atomic_load_32_global>;
17130b57cec5SDimitry Andricdefm : MUBUFLoad_Atomic_Pattern <BUFFER_LOAD_DWORDX2_ADDR64, BUFFER_LOAD_DWORDX2_OFFSET, i64, atomic_load_64_global>;
17140b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX6GFX7
17150b57cec5SDimitry Andric
17160b57cec5SDimitry Andricmulticlass MUBUFLoad_Pattern <MUBUF_Pseudo Instr_OFFSET, ValueType vt,
17170b57cec5SDimitry Andric                               PatFrag ld> {
17180b57cec5SDimitry Andric
17190b57cec5SDimitry Andric  def : GCNPat <
1720*06c3fb27SDimitry Andric    (vt (ld (MUBUFOffset v4i32:$srsrc, i32:$soffset, i32:$offset))),
1721fe6060f1SDimitry Andric    (Instr_OFFSET $srsrc, $soffset, $offset)
17220b57cec5SDimitry Andric  >;
17230b57cec5SDimitry Andric}
17240b57cec5SDimitry Andric
17250b57cec5SDimitry Andriclet OtherPredicates = [Has16BitInsts] in {
17260b57cec5SDimitry Andric
17270b57cec5SDimitry Andricdefm : MUBUFLoad_Pattern <BUFFER_LOAD_SBYTE_OFFSET, i16, sextloadi8_constant>;
17280b57cec5SDimitry Andricdefm : MUBUFLoad_Pattern <BUFFER_LOAD_UBYTE_OFFSET, i16, extloadi8_constant>;
17290b57cec5SDimitry Andricdefm : MUBUFLoad_Pattern <BUFFER_LOAD_UBYTE_OFFSET, i16, zextloadi8_constant>;
17300b57cec5SDimitry Andricdefm : MUBUFLoad_Pattern <BUFFER_LOAD_SBYTE_OFFSET, i16, sextloadi8_global>;
17310b57cec5SDimitry Andricdefm : MUBUFLoad_Pattern <BUFFER_LOAD_UBYTE_OFFSET, i16, extloadi8_global>;
17320b57cec5SDimitry Andricdefm : MUBUFLoad_Pattern <BUFFER_LOAD_UBYTE_OFFSET, i16, zextloadi8_global>;
17330b57cec5SDimitry Andric
17340b57cec5SDimitry Andricdefm : MUBUFLoad_Pattern <BUFFER_LOAD_USHORT_OFFSET, i16, load_global>;
17350b57cec5SDimitry Andric
17360b57cec5SDimitry Andric} // End OtherPredicates = [Has16BitInsts]
17370b57cec5SDimitry Andric
17380b57cec5SDimitry Andricmulticlass MUBUFScratchLoadPat <MUBUF_Pseudo InstrOffen,
17390b57cec5SDimitry Andric                                MUBUF_Pseudo InstrOffset,
17400b57cec5SDimitry Andric                                ValueType vt, PatFrag ld> {
17410b57cec5SDimitry Andric  def : GCNPat <
17420b57cec5SDimitry Andric    (vt (ld (MUBUFScratchOffen v4i32:$srsrc, i32:$vaddr,
1743*06c3fb27SDimitry Andric                               i32:$soffset, i32:$offset))),
1744bdd1243dSDimitry Andric    (InstrOffen $vaddr, $srsrc, $soffset, $offset, 0, 0)
17450b57cec5SDimitry Andric  >;
17460b57cec5SDimitry Andric
17470b57cec5SDimitry Andric  def : GCNPat <
1748*06c3fb27SDimitry Andric    (vt (ld (MUBUFScratchOffset v4i32:$srsrc, i32:$soffset, i32:$offset))),
1749bdd1243dSDimitry Andric    (InstrOffset $srsrc, $soffset, $offset, 0, 0)
17500b57cec5SDimitry Andric  >;
17510b57cec5SDimitry Andric}
17520b57cec5SDimitry Andric
17530b57cec5SDimitry Andric// XXX - Is it possible to have a complex pattern in a PatFrag?
17540b57cec5SDimitry Andricmulticlass MUBUFScratchLoadPat_D16 <MUBUF_Pseudo InstrOffen,
17550b57cec5SDimitry Andric                                MUBUF_Pseudo InstrOffset,
17560b57cec5SDimitry Andric                                ValueType vt, PatFrag ld_frag> {
17570b57cec5SDimitry Andric  def : GCNPat <
1758*06c3fb27SDimitry Andric    (ld_frag (MUBUFScratchOffen v4i32:$srsrc, i32:$vaddr, i32:$soffset, i32:$offset), vt:$in),
1759fe6060f1SDimitry Andric    (InstrOffen $vaddr, $srsrc, $soffset, $offset, $in)
17600b57cec5SDimitry Andric  >;
17610b57cec5SDimitry Andric
17620b57cec5SDimitry Andric  def : GCNPat <
1763*06c3fb27SDimitry Andric    (ld_frag (MUBUFScratchOffset v4i32:$srsrc, i32:$soffset, i32:$offset), vt:$in),
1764fe6060f1SDimitry Andric    (InstrOffset $srsrc, $soffset, $offset, $in)
17650b57cec5SDimitry Andric  >;
17660b57cec5SDimitry Andric}
17670b57cec5SDimitry Andric
1768e8d8bef9SDimitry Andriclet OtherPredicates = [DisableFlatScratch] in {
17690b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_SBYTE_OFFEN, BUFFER_LOAD_SBYTE_OFFSET, i32, sextloadi8_private>;
17700b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_UBYTE_OFFEN, BUFFER_LOAD_UBYTE_OFFSET, i32, extloadi8_private>;
17710b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_UBYTE_OFFEN, BUFFER_LOAD_UBYTE_OFFSET, i32, zextloadi8_private>;
17720b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_SBYTE_OFFEN, BUFFER_LOAD_SBYTE_OFFSET, i16, sextloadi8_private>;
17730b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_UBYTE_OFFEN, BUFFER_LOAD_UBYTE_OFFSET, i16, extloadi8_private>;
17740b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_UBYTE_OFFEN, BUFFER_LOAD_UBYTE_OFFSET, i16, zextloadi8_private>;
17750b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_SSHORT_OFFEN, BUFFER_LOAD_SSHORT_OFFSET, i32, sextloadi16_private>;
17760b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_USHORT_OFFEN, BUFFER_LOAD_USHORT_OFFSET, i32, extloadi16_private>;
17770b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_USHORT_OFFEN, BUFFER_LOAD_USHORT_OFFSET, i32, zextloadi16_private>;
17780b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_USHORT_OFFEN, BUFFER_LOAD_USHORT_OFFSET, i16, load_private>;
17798bcb0991SDimitry Andric
17808bcb0991SDimitry Andricforeach vt = Reg32Types.types in {
17815ffd83dbSDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_DWORD_OFFEN, BUFFER_LOAD_DWORD_OFFSET, vt, load_private>;
17828bcb0991SDimitry Andric}
17830b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_DWORDX2_OFFEN, BUFFER_LOAD_DWORDX2_OFFSET, v2i32, load_private>;
17840b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_DWORDX3_OFFEN, BUFFER_LOAD_DWORDX3_OFFSET, v3i32, load_private>;
17850b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_DWORDX4_OFFEN, BUFFER_LOAD_DWORDX4_OFFSET, v4i32, load_private>;
17860b57cec5SDimitry Andric
1787e8d8bef9SDimitry Andriclet OtherPredicates = [D16PreservesUnusedBits, DisableFlatScratch] in {
17880b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_SHORT_D16_HI_OFFEN, BUFFER_LOAD_SHORT_D16_HI_OFFSET, v2i16, load_d16_hi_private>;
17890b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_UBYTE_D16_HI_OFFEN, BUFFER_LOAD_UBYTE_D16_HI_OFFSET, v2i16, az_extloadi8_d16_hi_private>;
17900b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_SBYTE_D16_HI_OFFEN, BUFFER_LOAD_SBYTE_D16_HI_OFFSET, v2i16, sextloadi8_d16_hi_private>;
17910b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_SHORT_D16_HI_OFFEN, BUFFER_LOAD_SHORT_D16_HI_OFFSET, v2f16, load_d16_hi_private>;
17920b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_UBYTE_D16_HI_OFFEN, BUFFER_LOAD_UBYTE_D16_HI_OFFSET, v2f16, az_extloadi8_d16_hi_private>;
17930b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_SBYTE_D16_HI_OFFEN, BUFFER_LOAD_SBYTE_D16_HI_OFFSET, v2f16, sextloadi8_d16_hi_private>;
17940b57cec5SDimitry Andric
17950b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_SHORT_D16_OFFEN, BUFFER_LOAD_SHORT_D16_OFFSET, v2i16, load_d16_lo_private>;
17960b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_UBYTE_D16_OFFEN, BUFFER_LOAD_UBYTE_D16_OFFSET, v2i16, az_extloadi8_d16_lo_private>;
17970b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_SBYTE_D16_OFFEN, BUFFER_LOAD_SBYTE_D16_OFFSET, v2i16, sextloadi8_d16_lo_private>;
17980b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_SHORT_D16_OFFEN, BUFFER_LOAD_SHORT_D16_OFFSET, v2f16, load_d16_lo_private>;
17990b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_UBYTE_D16_OFFEN, BUFFER_LOAD_UBYTE_D16_OFFSET, v2f16, az_extloadi8_d16_lo_private>;
18000b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_SBYTE_D16_OFFEN, BUFFER_LOAD_SBYTE_D16_OFFSET, v2f16, sextloadi8_d16_lo_private>;
18010b57cec5SDimitry Andric}
18020b57cec5SDimitry Andric
1803e8d8bef9SDimitry Andric} // End OtherPredicates = [DisableFlatScratch]
1804e8d8bef9SDimitry Andric
18050b57cec5SDimitry Andricmulticlass MUBUFStore_Atomic_Pattern <MUBUF_Pseudo Instr_ADDR64, MUBUF_Pseudo Instr_OFFSET,
18060b57cec5SDimitry Andric                                      ValueType vt, PatFrag atomic_st> {
18078bcb0991SDimitry Andric  // Store follows atomic op convention so address is first
18080b57cec5SDimitry Andric  def : GCNPat <
1809*06c3fb27SDimitry Andric     (atomic_st (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset, i32:$offset), vt:$val),
1810fe6060f1SDimitry Andric     (Instr_ADDR64 $val, $vaddr, $srsrc, $soffset, $offset)
18110b57cec5SDimitry Andric  >;
18120b57cec5SDimitry Andric
18130b57cec5SDimitry Andric  def : GCNPat <
1814*06c3fb27SDimitry Andric    (atomic_st (MUBUFOffset v4i32:$rsrc, i32:$soffset, i32:$offset), vt:$val),
1815fe6060f1SDimitry Andric    (Instr_OFFSET $val, $rsrc, $soffset, (as_i16imm $offset))
18160b57cec5SDimitry Andric  >;
18170b57cec5SDimitry Andric}
18180b57cec5SDimitry Andriclet SubtargetPredicate = isGFX6GFX7 in {
181981ad6265SDimitry Andricdefm : MUBUFStore_Atomic_Pattern <BUFFER_STORE_BYTE_ADDR64, BUFFER_STORE_BYTE_OFFSET, i32, atomic_store_8_global>;
182081ad6265SDimitry Andricdefm : MUBUFStore_Atomic_Pattern <BUFFER_STORE_BYTE_ADDR64, BUFFER_STORE_BYTE_OFFSET, i16, atomic_store_8_global>;
182181ad6265SDimitry Andricdefm : MUBUFStore_Atomic_Pattern <BUFFER_STORE_SHORT_ADDR64, BUFFER_STORE_SHORT_OFFSET, i32, atomic_store_16_global>;
182281ad6265SDimitry Andricdefm : MUBUFStore_Atomic_Pattern <BUFFER_STORE_SHORT_ADDR64, BUFFER_STORE_SHORT_OFFSET, i16, atomic_store_16_global>;
182381ad6265SDimitry Andricdefm : MUBUFStore_Atomic_Pattern <BUFFER_STORE_DWORD_ADDR64, BUFFER_STORE_DWORD_OFFSET, i32, atomic_store_32_global>;
182481ad6265SDimitry Andricdefm : MUBUFStore_Atomic_Pattern <BUFFER_STORE_DWORDX2_ADDR64, BUFFER_STORE_DWORDX2_OFFSET, i64, atomic_store_64_global>;
18250b57cec5SDimitry Andric} // End Predicates = isGFX6GFX7
18260b57cec5SDimitry Andric
18270b57cec5SDimitry Andric
18280b57cec5SDimitry Andricmulticlass MUBUFStore_Pattern <MUBUF_Pseudo Instr_OFFSET, ValueType vt,
18290b57cec5SDimitry Andric                               PatFrag st> {
18300b57cec5SDimitry Andric
18310b57cec5SDimitry Andric  def : GCNPat <
1832*06c3fb27SDimitry Andric    (st vt:$vdata, (MUBUFOffset v4i32:$srsrc, i32:$soffset, i32:$offset)),
1833fe6060f1SDimitry Andric    (Instr_OFFSET $vdata, $srsrc, $soffset, $offset)
18340b57cec5SDimitry Andric  >;
18350b57cec5SDimitry Andric}
18360b57cec5SDimitry Andric
18370b57cec5SDimitry Andricdefm : MUBUFStore_Pattern <BUFFER_STORE_BYTE_OFFSET, i16, truncstorei8_global>;
18380b57cec5SDimitry Andricdefm : MUBUFStore_Pattern <BUFFER_STORE_SHORT_OFFSET, i16, store_global>;
18390b57cec5SDimitry Andric
18400b57cec5SDimitry Andricmulticlass MUBUFScratchStorePat <MUBUF_Pseudo InstrOffen,
18410b57cec5SDimitry Andric                                 MUBUF_Pseudo InstrOffset,
18420b57cec5SDimitry Andric                                 ValueType vt, PatFrag st,
18430b57cec5SDimitry Andric                                 RegisterClass rc = VGPR_32> {
18440b57cec5SDimitry Andric  def : GCNPat <
18450b57cec5SDimitry Andric    (st vt:$value, (MUBUFScratchOffen v4i32:$srsrc, i32:$vaddr,
1846*06c3fb27SDimitry Andric                                      i32:$soffset, i32:$offset)),
1847bdd1243dSDimitry Andric    (InstrOffen rc:$value, $vaddr, $srsrc, $soffset, $offset, 0, 0)
18480b57cec5SDimitry Andric  >;
18490b57cec5SDimitry Andric
18500b57cec5SDimitry Andric  def : GCNPat <
18510b57cec5SDimitry Andric    (st vt:$value, (MUBUFScratchOffset v4i32:$srsrc, i32:$soffset,
1852*06c3fb27SDimitry Andric                                       i32:$offset)),
1853bdd1243dSDimitry Andric    (InstrOffset rc:$value, $srsrc, $soffset, $offset, 0, 0)
18540b57cec5SDimitry Andric  >;
18550b57cec5SDimitry Andric}
18560b57cec5SDimitry Andric
1857e8d8bef9SDimitry Andriclet OtherPredicates = [DisableFlatScratch] in {
18580b57cec5SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_BYTE_OFFEN, BUFFER_STORE_BYTE_OFFSET, i32, truncstorei8_private>;
18590b57cec5SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_SHORT_OFFEN, BUFFER_STORE_SHORT_OFFSET, i32, truncstorei16_private>;
18600b57cec5SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_BYTE_OFFEN, BUFFER_STORE_BYTE_OFFSET, i16, truncstorei8_private>;
18610b57cec5SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_SHORT_OFFEN, BUFFER_STORE_SHORT_OFFSET, i16, store_private>;
18628bcb0991SDimitry Andric
18638bcb0991SDimitry Andricforeach vt = Reg32Types.types in {
18648bcb0991SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_DWORD_OFFEN, BUFFER_STORE_DWORD_OFFSET, vt, store_private>;
18658bcb0991SDimitry Andric}
18668bcb0991SDimitry Andric
18670b57cec5SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_DWORDX2_OFFEN, BUFFER_STORE_DWORDX2_OFFSET, v2i32, store_private, VReg_64>;
18680b57cec5SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_DWORDX3_OFFEN, BUFFER_STORE_DWORDX3_OFFSET, v3i32, store_private, VReg_96>;
18690b57cec5SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_DWORDX4_OFFEN, BUFFER_STORE_DWORDX4_OFFSET, v4i32, store_private, VReg_128>;
18700b57cec5SDimitry Andric
18710b57cec5SDimitry Andric
187281ad6265SDimitry Andriclet OtherPredicates = [HasD16LoadStore, DisableFlatScratch] in {
18730b57cec5SDimitry Andric // Hiding the extract high pattern in the PatFrag seems to not
18740b57cec5SDimitry Andric // automatically increase the complexity.
18750b57cec5SDimitry Andriclet AddedComplexity = 1 in {
18760b57cec5SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_SHORT_D16_HI_OFFEN, BUFFER_STORE_SHORT_D16_HI_OFFSET, i32, store_hi16_private>;
18770b57cec5SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_BYTE_D16_HI_OFFEN, BUFFER_STORE_BYTE_D16_HI_OFFSET, i32, truncstorei8_hi16_private>;
18780b57cec5SDimitry Andric}
18790b57cec5SDimitry Andric}
1880e8d8bef9SDimitry Andric} // End OtherPredicates = [DisableFlatScratch]
18810b57cec5SDimitry Andric
18820b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
18830b57cec5SDimitry Andric// MTBUF Patterns
18840b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
18850b57cec5SDimitry Andric
18860b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
18870b57cec5SDimitry Andric// tbuffer_load/store_format patterns
18880b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
18890b57cec5SDimitry Andric
18900b57cec5SDimitry Andricmulticlass MTBUF_LoadIntrinsicPat<SDPatternOperator name, ValueType vt,
1891e8d8bef9SDimitry Andric                                  string opcode, ValueType memoryVt = vt> {
1892fe6060f1SDimitry Andric  defvar st = !if(!eq(memoryVt, vt), name, mtbuf_intrinsic_load<name, memoryVt>);
1893e8d8bef9SDimitry Andric
18940b57cec5SDimitry Andric  def : GCNPat<
1895e8d8bef9SDimitry Andric    (vt (st v4i32:$rsrc, 0, 0, i32:$soffset, timm:$offset,
18968bcb0991SDimitry Andric              timm:$format, timm:$auxiliary, 0)),
1897*06c3fb27SDimitry Andric    (!cast<MTBUF_Pseudo>(opcode # _OFFSET) SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset,
18985ffd83dbSDimitry Andric      (as_i8timm $format),
1899bdd1243dSDimitry Andric      (extract_cpol $auxiliary), (extract_swz $auxiliary))
19000b57cec5SDimitry Andric  >;
19010b57cec5SDimitry Andric
19020b57cec5SDimitry Andric  def : GCNPat<
1903e8d8bef9SDimitry Andric    (vt (st v4i32:$rsrc, i32:$vindex, 0, i32:$soffset, timm:$offset,
19048bcb0991SDimitry Andric              timm:$format, timm:$auxiliary, timm)),
1905*06c3fb27SDimitry Andric    (!cast<MTBUF_Pseudo>(opcode # _IDXEN) VGPR_32:$vindex, SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset,
19065ffd83dbSDimitry Andric      (as_i8timm $format),
1907bdd1243dSDimitry Andric      (extract_cpol $auxiliary), (extract_swz $auxiliary))
19080b57cec5SDimitry Andric  >;
19090b57cec5SDimitry Andric
19100b57cec5SDimitry Andric  def : GCNPat<
1911e8d8bef9SDimitry Andric    (vt (st v4i32:$rsrc, 0, i32:$voffset, i32:$soffset, timm:$offset,
19128bcb0991SDimitry Andric              timm:$format, timm:$auxiliary, 0)),
1913*06c3fb27SDimitry Andric    (!cast<MTBUF_Pseudo>(opcode # _OFFEN) VGPR_32:$voffset, SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset,
19145ffd83dbSDimitry Andric      (as_i8timm $format),
1915bdd1243dSDimitry Andric      (extract_cpol $auxiliary), (extract_swz $auxiliary))
19160b57cec5SDimitry Andric  >;
19170b57cec5SDimitry Andric
19180b57cec5SDimitry Andric  def : GCNPat<
1919e8d8bef9SDimitry Andric    (vt (st v4i32:$rsrc, i32:$vindex, i32:$voffset, i32:$soffset, timm:$offset,
19208bcb0991SDimitry Andric              timm:$format, timm:$auxiliary, timm)),
19210b57cec5SDimitry Andric    (!cast<MTBUF_Pseudo>(opcode # _BOTHEN)
19225ffd83dbSDimitry Andric      (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1),
1923*06c3fb27SDimitry Andric      SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset,
19245ffd83dbSDimitry Andric      (as_i8timm $format),
1925bdd1243dSDimitry Andric      (extract_cpol $auxiliary), (extract_swz $auxiliary))
19260b57cec5SDimitry Andric  >;
19270b57cec5SDimitry Andric}
19280b57cec5SDimitry Andric
19290b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, i32,   "TBUFFER_LOAD_FORMAT_X">;
19300b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v2i32, "TBUFFER_LOAD_FORMAT_XY">;
19310b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v3i32, "TBUFFER_LOAD_FORMAT_XYZ">;
19320b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v4i32, "TBUFFER_LOAD_FORMAT_XYZW">;
19330b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, f32,   "TBUFFER_LOAD_FORMAT_X">;
19340b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v2f32, "TBUFFER_LOAD_FORMAT_XY">;
19350b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v3f32, "TBUFFER_LOAD_FORMAT_XYZ">;
19360b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v4f32, "TBUFFER_LOAD_FORMAT_XYZW">;
19370b57cec5SDimitry Andric
19380b57cec5SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem in {
19390b57cec5SDimitry Andric  defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, f16,   "TBUFFER_LOAD_FORMAT_D16_X_gfx80">;
19405ffd83dbSDimitry Andric  defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, i32,   "TBUFFER_LOAD_FORMAT_D16_X_gfx80">;
19410b57cec5SDimitry Andric  defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, v2i32, "TBUFFER_LOAD_FORMAT_D16_XY_gfx80">;
1942e8d8bef9SDimitry Andric  defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, v3i32, "TBUFFER_LOAD_FORMAT_D16_XYZ_gfx80">;
19430b57cec5SDimitry Andric  defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, v4i32, "TBUFFER_LOAD_FORMAT_D16_XYZW_gfx80">;
19440b57cec5SDimitry Andric} // End HasUnpackedD16VMem.
19450b57cec5SDimitry Andric
19460b57cec5SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem in {
19470b57cec5SDimitry Andric  defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, f16,   "TBUFFER_LOAD_FORMAT_D16_X">;
19485ffd83dbSDimitry Andric  defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, i32,   "TBUFFER_LOAD_FORMAT_D16_X">;
19490b57cec5SDimitry Andric  defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, v2f16, "TBUFFER_LOAD_FORMAT_D16_XY">;
1950e8d8bef9SDimitry Andric  defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, v4f16, "TBUFFER_LOAD_FORMAT_D16_XYZ", v3f16>;
19510b57cec5SDimitry Andric  defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, v4f16, "TBUFFER_LOAD_FORMAT_D16_XYZW">;
19520b57cec5SDimitry Andric} // End HasPackedD16VMem.
19530b57cec5SDimitry Andric
19540b57cec5SDimitry Andricmulticlass MTBUF_StoreIntrinsicPat<SDPatternOperator name, ValueType vt,
1955e8d8bef9SDimitry Andric                                        string opcode, ValueType memoryVt = vt> {
1956fe6060f1SDimitry Andric  defvar st = !if(!eq(memoryVt, vt), name, mtbuf_intrinsic_store<name, memoryVt>);
1957e8d8bef9SDimitry Andric
19580b57cec5SDimitry Andric  def : GCNPat<
1959e8d8bef9SDimitry Andric    (st vt:$vdata, v4i32:$rsrc, 0, 0, i32:$soffset, timm:$offset,
19608bcb0991SDimitry Andric          timm:$format, timm:$auxiliary, 0),
19615ffd83dbSDimitry Andric    (!cast<MTBUF_Pseudo>(opcode # _OFFSET_exact) getVregSrcForVT<vt>.ret:$vdata, SReg_128:$rsrc, SCSrc_b32:$soffset,
1962*06c3fb27SDimitry Andric      timm:$offset, (as_i8timm $format),
1963bdd1243dSDimitry Andric      (extract_cpol $auxiliary), (extract_swz $auxiliary))
19640b57cec5SDimitry Andric  >;
19650b57cec5SDimitry Andric
19660b57cec5SDimitry Andric  def : GCNPat<
1967e8d8bef9SDimitry Andric    (st vt:$vdata, v4i32:$rsrc, i32:$vindex, 0, i32:$soffset, timm:$offset,
19688bcb0991SDimitry Andric          timm:$format, timm:$auxiliary, timm),
19695ffd83dbSDimitry Andric    (!cast<MTBUF_Pseudo>(opcode # _IDXEN_exact) getVregSrcForVT<vt>.ret:$vdata, VGPR_32:$vindex, SReg_128:$rsrc, SCSrc_b32:$soffset,
1970*06c3fb27SDimitry Andric      timm:$offset, (as_i8timm $format),
1971bdd1243dSDimitry Andric      (extract_cpol $auxiliary), (extract_swz $auxiliary))
19720b57cec5SDimitry Andric  >;
19730b57cec5SDimitry Andric
19740b57cec5SDimitry Andric  def : GCNPat<
1975e8d8bef9SDimitry Andric    (st vt:$vdata, v4i32:$rsrc, 0, i32:$voffset, i32:$soffset, timm:$offset,
19768bcb0991SDimitry Andric          timm:$format, timm:$auxiliary, 0),
19775ffd83dbSDimitry Andric    (!cast<MTBUF_Pseudo>(opcode # _OFFEN_exact) getVregSrcForVT<vt>.ret:$vdata, VGPR_32:$voffset, SReg_128:$rsrc, SCSrc_b32:$soffset,
1978*06c3fb27SDimitry Andric      timm:$offset, (as_i8timm $format),
1979bdd1243dSDimitry Andric      (extract_cpol $auxiliary), (extract_swz $auxiliary))
19800b57cec5SDimitry Andric  >;
19810b57cec5SDimitry Andric
19820b57cec5SDimitry Andric  def : GCNPat<
1983e8d8bef9SDimitry Andric    (st vt:$vdata, v4i32:$rsrc, i32:$vindex, i32:$voffset, i32:$soffset,
19848bcb0991SDimitry Andric          timm:$offset, timm:$format, timm:$auxiliary, timm),
19850b57cec5SDimitry Andric    (!cast<MTBUF_Pseudo>(opcode # _BOTHEN_exact)
19865ffd83dbSDimitry Andric      getVregSrcForVT<vt>.ret:$vdata,
19875ffd83dbSDimitry Andric      (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1),
1988*06c3fb27SDimitry Andric      SReg_128:$rsrc, SCSrc_b32:$soffset, timm:$offset, (as_i8timm $format),
1989bdd1243dSDimitry Andric      (extract_cpol $auxiliary), (extract_swz $auxiliary))
19900b57cec5SDimitry Andric  >;
19910b57cec5SDimitry Andric}
19920b57cec5SDimitry Andric
19930b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, i32,   "TBUFFER_STORE_FORMAT_X">;
19940b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v2i32, "TBUFFER_STORE_FORMAT_XY">;
19950b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v3i32, "TBUFFER_STORE_FORMAT_XYZ">;
19960b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v4i32, "TBUFFER_STORE_FORMAT_XYZW">;
19970b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, f32,   "TBUFFER_STORE_FORMAT_X">;
19980b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v2f32, "TBUFFER_STORE_FORMAT_XY">;
19990b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v3f32, "TBUFFER_STORE_FORMAT_XYZ">;
20000b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v4f32, "TBUFFER_STORE_FORMAT_XYZW">;
20010b57cec5SDimitry Andric
20020b57cec5SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem in {
20030b57cec5SDimitry Andric  defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, f16,   "TBUFFER_STORE_FORMAT_D16_X_gfx80">;
20045ffd83dbSDimitry Andric  defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, i32,   "TBUFFER_STORE_FORMAT_D16_X_gfx80">;
20050b57cec5SDimitry Andric  defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, v2i32, "TBUFFER_STORE_FORMAT_D16_XY_gfx80">;
2006e8d8bef9SDimitry Andric  defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, v3i32, "TBUFFER_STORE_FORMAT_D16_XYZ_gfx80">;
20070b57cec5SDimitry Andric  defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, v4i32, "TBUFFER_STORE_FORMAT_D16_XYZW_gfx80">;
20080b57cec5SDimitry Andric} // End HasUnpackedD16VMem.
20090b57cec5SDimitry Andric
20100b57cec5SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem in {
20110b57cec5SDimitry Andric  defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, f16,   "TBUFFER_STORE_FORMAT_D16_X">;
20125ffd83dbSDimitry Andric  defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, i32,   "TBUFFER_STORE_FORMAT_D16_X">;
20130b57cec5SDimitry Andric  defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, v2f16, "TBUFFER_STORE_FORMAT_D16_XY">;
2014e8d8bef9SDimitry Andric  defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, v4f16, "TBUFFER_STORE_FORMAT_D16_XYZ", v3f16>;
20150b57cec5SDimitry Andric  defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, v4f16, "TBUFFER_STORE_FORMAT_D16_XYZW">;
20160b57cec5SDimitry Andric} // End HasPackedD16VMem.
20170b57cec5SDimitry Andric
20180b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
20190b57cec5SDimitry Andric// Target-specific instruction encodings.
20200b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
20210b57cec5SDimitry Andric
20220b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
202381ad6265SDimitry Andric// Base ENC_MUBUF for GFX6, GFX7, GFX10, GFX11.
20240b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
20250b57cec5SDimitry Andric
202681ad6265SDimitry Andricclass Base_MUBUF_Real_gfx6_gfx7_gfx10_gfx11 <MUBUF_Pseudo ps, int ef,
202781ad6265SDimitry Andric                                             string real_name = ps.Mnemonic> :
202881ad6265SDimitry Andric  MUBUF_Real<ps, real_name>, Enc64, SIMCInstr<ps.PseudoInstr, ef> {
20290b57cec5SDimitry Andric  let Inst{11-0}  = !if(ps.has_offset, offset, ?);
203081ad6265SDimitry Andric  let Inst{31-26} = 0x38;
203181ad6265SDimitry Andric  let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?);
203281ad6265SDimitry Andric  let Inst{47-40} = !if(ps.has_vdata, vdata{7-0}, ?);
203381ad6265SDimitry Andric  let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?);
203481ad6265SDimitry Andric  let Inst{63-56} = !if(ps.has_soffset, soffset, ?);
203581ad6265SDimitry Andric}
203681ad6265SDimitry Andric
203781ad6265SDimitry Andricclass MUBUF_Real_gfx11<bits<8> op, MUBUF_Pseudo ps,
203881ad6265SDimitry Andric                       string real_name = ps.Mnemonic> :
203981ad6265SDimitry Andric  Base_MUBUF_Real_gfx6_gfx7_gfx10_gfx11<ps, SIEncodingFamily.GFX11, real_name> {
204081ad6265SDimitry Andric  let Inst{12}    = !if(ps.has_slc, cpol{CPolBit.SLC}, ?);
204181ad6265SDimitry Andric  let Inst{13}    = !if(ps.has_dlc, cpol{CPolBit.DLC}, ps.dlc_value);
204281ad6265SDimitry Andric  let Inst{14}    = !if(ps.has_glc, cpol{CPolBit.GLC}, ps.glc_value);
204381ad6265SDimitry Andric  let Inst{25-18} = op;
2044bdd1243dSDimitry Andric  let Inst{53}    = ps.tfe;
204581ad6265SDimitry Andric  let Inst{54}    = ps.offen;
204681ad6265SDimitry Andric  let Inst{55}    = ps.idxen;
204781ad6265SDimitry Andric}
204881ad6265SDimitry Andric
2049bdd1243dSDimitry Andricclass Base_MUBUF_Real_Atomic_gfx11<bits<8> op, MUBUF_Pseudo ps,
2050bdd1243dSDimitry Andric                                   string real_name> :
2051bdd1243dSDimitry Andric  MUBUF_Real_gfx11<op, ps, real_name> {
2052bdd1243dSDimitry Andric  let Inst{13} = cpol{CPolBit.DLC};
2053bdd1243dSDimitry Andric}
2054bdd1243dSDimitry Andric
205581ad6265SDimitry Andricclass Base_MUBUF_Real_gfx6_gfx7_gfx10<bits<7> op, MUBUF_Pseudo ps, int ef> :
205681ad6265SDimitry Andric  Base_MUBUF_Real_gfx6_gfx7_gfx10_gfx11<ps, ef> {
20570b57cec5SDimitry Andric  let Inst{12}    = ps.offen;
20580b57cec5SDimitry Andric  let Inst{13}    = ps.idxen;
2059fe6060f1SDimitry Andric  let Inst{14}    = !if(ps.has_glc, cpol{CPolBit.GLC}, ps.glc_value);
2060e8d8bef9SDimitry Andric  let Inst{16}    = ps.lds;
20610b57cec5SDimitry Andric  let Inst{24-18} = op;
2062fe6060f1SDimitry Andric  let Inst{54}    = !if(ps.has_slc, cpol{CPolBit.SLC}, ?);
2063bdd1243dSDimitry Andric  let Inst{55}    = ps.tfe;
20640b57cec5SDimitry Andric}
20650b57cec5SDimitry Andric
20660b57cec5SDimitry Andricclass MUBUF_Real_gfx10<bits<8> op, MUBUF_Pseudo ps> :
20670b57cec5SDimitry Andric    Base_MUBUF_Real_gfx6_gfx7_gfx10<op{6-0}, ps, SIEncodingFamily.GFX10> {
2068fe6060f1SDimitry Andric  let Inst{15} = !if(ps.has_dlc, cpol{CPolBit.DLC}, ps.dlc_value);
20690b57cec5SDimitry Andric  let Inst{25} = op{7};
20700b57cec5SDimitry Andric}
20710b57cec5SDimitry Andric
20720b57cec5SDimitry Andricclass MUBUF_Real_gfx6_gfx7<bits<8> op, MUBUF_Pseudo ps> :
20730b57cec5SDimitry Andric    Base_MUBUF_Real_gfx6_gfx7_gfx10<op{6-0}, ps, SIEncodingFamily.SI> {
20740b57cec5SDimitry Andric  let Inst{15} = ps.addr64;
20750b57cec5SDimitry Andric}
20760b57cec5SDimitry Andric
20770b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
207881ad6265SDimitry Andric// MUBUF - GFX11.
207981ad6265SDimitry Andric//===----------------------------------------------------------------------===//
208081ad6265SDimitry Andric
2081bdd1243dSDimitry Andric// Shortcut to default Mnemonic from MUBUF_Pseudo. Hides the cast to the
2082bdd1243dSDimitry Andric// specific pseudo (bothen in this case) since any of them will work.
2083bdd1243dSDimitry Andricclass get_MUBUF_ps<string name> {
2084bdd1243dSDimitry Andric  string Mnemonic = !cast<MUBUF_Pseudo>(name # "_BOTHEN").Mnemonic;
208581ad6265SDimitry Andric}
208681ad6265SDimitry Andric
2087bdd1243dSDimitry Andric// gfx11 instruction that accept both old and new assembler name.
2088bdd1243dSDimitry Andricclass Pre_gfx11_MUBUF_Name <string mnemonic, string real_name> :
2089bdd1243dSDimitry Andric  MnemonicAlias<mnemonic, real_name>, Requires<[isGFX11Plus]>;
209081ad6265SDimitry Andric
2091bdd1243dSDimitry Andricclass MUBUF_Real_gfx11_impl<bits<8> op, string ps_name, string real_name> :
2092bdd1243dSDimitry Andric  MUBUF_Real_gfx11<op, !cast<MUBUF_Pseudo>(ps_name), real_name>;
2093bdd1243dSDimitry Andriclet AssemblerPredicate = isGFX11Only, DecoderNamespace = "GFX11" in
2094bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_gfx11_Renamed_Impl2<bits<8> op, string real_name> {
2095bdd1243dSDimitry Andric  def _BOTHEN_gfx11 : MUBUF_Real_gfx11_impl<op, NAME # "_BOTHEN", real_name>;
2096bdd1243dSDimitry Andric  def _IDXEN_gfx11 : MUBUF_Real_gfx11_impl<op, NAME # "_IDXEN", real_name>;
2097bdd1243dSDimitry Andric  def _OFFEN_gfx11 : MUBUF_Real_gfx11_impl<op, NAME # "_OFFEN", real_name>;
2098bdd1243dSDimitry Andric  def _OFFSET_gfx11 : MUBUF_Real_gfx11_impl<op, NAME # "_OFFSET", real_name>;
2099bdd1243dSDimitry Andric}
2100bdd1243dSDimitry Andric
2101bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_gfx11_Renamed_Impl<bits<8> op, string real_name,
2102bdd1243dSDimitry Andric                                                 bit hasTFE = 1> {
2103bdd1243dSDimitry Andric  defm NAME : MUBUF_Real_AllAddr_gfx11_Renamed_Impl2<op, real_name>;
2104bdd1243dSDimitry Andric  if hasTFE then
2105bdd1243dSDimitry Andric    defm _TFE : MUBUF_Real_AllAddr_gfx11_Renamed_Impl2<op, real_name>;
2106bdd1243dSDimitry Andric}
2107bdd1243dSDimitry Andric
2108bdd1243dSDimitry Andric// Non-renamed, non-atomic gfx11 mubuf instructions.
2109bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_gfx11<bits<8> op, bit hasTFE = 1> :
2110bdd1243dSDimitry Andric  MUBUF_Real_AllAddr_gfx11_Renamed_Impl<op, get_MUBUF_ps<NAME>.Mnemonic, hasTFE>;
2111bdd1243dSDimitry Andric
211281ad6265SDimitry Andricmulticlass MUBUF_Real_AllAddr_gfx11_Renamed<bits<8> op, string real_name> :
211381ad6265SDimitry Andric  MUBUF_Real_AllAddr_gfx11_Renamed_Impl<op, real_name> {
2114bdd1243dSDimitry Andric  def : Pre_gfx11_MUBUF_Name<get_MUBUF_ps<NAME>.Mnemonic, real_name>;
211581ad6265SDimitry Andric}
211681ad6265SDimitry Andric
2117bdd1243dSDimitry Andricclass MUBUF_Real_Atomic_gfx11_impl<bits<8> op, string ps_name,
2118bdd1243dSDimitry Andric                                   string real_name> :
2119bdd1243dSDimitry Andric  Base_MUBUF_Real_Atomic_gfx11<op, !cast<MUBUF_Pseudo>(ps_name), real_name>;
212081ad6265SDimitry Andriclet AssemblerPredicate = isGFX11Only, DecoderNamespace = "GFX11" in
2121bdd1243dSDimitry Andricmulticlass MUBUF_Real_Atomic_gfx11_Renamed_impl<bits<8> op, bit is_return,
2122bdd1243dSDimitry Andric                                                string real_name> {
2123bdd1243dSDimitry Andric  defvar Rtn = !if(!eq(is_return, 1), "_RTN", "");
2124bdd1243dSDimitry Andric  def _BOTHEN#Rtn#_gfx11 :
2125bdd1243dSDimitry Andric    MUBUF_Real_Atomic_gfx11_impl<op, NAME # "_BOTHEN" # Rtn, real_name>,
2126bdd1243dSDimitry Andric    AtomicNoRet<NAME # "_BOTHEN_gfx11", is_return>;
2127bdd1243dSDimitry Andric  def _IDXEN#Rtn#_gfx11 :
2128bdd1243dSDimitry Andric    MUBUF_Real_Atomic_gfx11_impl<op, NAME # "_IDXEN" # Rtn, real_name>,
2129bdd1243dSDimitry Andric    AtomicNoRet<NAME # "_IDXEN_gfx11", is_return>;
2130bdd1243dSDimitry Andric  def _OFFEN#Rtn#_gfx11 :
2131bdd1243dSDimitry Andric    MUBUF_Real_Atomic_gfx11_impl<op, NAME # "_OFFEN" # Rtn, real_name>,
2132bdd1243dSDimitry Andric    AtomicNoRet<NAME # "_OFFEN_gfx11", is_return>;
2133bdd1243dSDimitry Andric  def _OFFSET#Rtn#_gfx11 :
2134bdd1243dSDimitry Andric    MUBUF_Real_Atomic_gfx11_impl<op, NAME # "_OFFSET" # Rtn, real_name>,
2135bdd1243dSDimitry Andric    AtomicNoRet<NAME # "_OFFSET_gfx11", is_return>;
213681ad6265SDimitry Andric}
213781ad6265SDimitry Andric
2138bdd1243dSDimitry Andric// Non-renamed gfx11 mubuf atomic.
2139bdd1243dSDimitry Andricmulticlass MUBUF_Real_Atomic_gfx11<bits<8> op> :
2140bdd1243dSDimitry Andric  MUBUF_Real_Atomic_gfx11_Renamed_impl<op, 0, get_MUBUF_ps<NAME>.Mnemonic>,
2141bdd1243dSDimitry Andric  MUBUF_Real_Atomic_gfx11_Renamed_impl<op, 1, get_MUBUF_ps<NAME>.Mnemonic>;
214281ad6265SDimitry Andric
2143bdd1243dSDimitry Andricmulticlass MUBUF_Real_Atomic_gfx11_Renamed<bits<8> op, string real_name> :
2144bdd1243dSDimitry Andric  MUBUF_Real_Atomic_gfx11_Renamed_impl<op, 0, real_name>,
2145bdd1243dSDimitry Andric  MUBUF_Real_Atomic_gfx11_Renamed_impl<op, 1, real_name>  {
2146bdd1243dSDimitry Andric  def : Pre_gfx11_MUBUF_Name<get_MUBUF_ps<NAME>.Mnemonic, real_name>;
2147bdd1243dSDimitry Andric}
214881ad6265SDimitry Andric
214981ad6265SDimitry Andriclet AssemblerPredicate = isGFX11Only, DecoderNamespace = "GFX11" in {
215081ad6265SDimitry Andricdef BUFFER_GL0_INV_gfx11          : MUBUF_Real_gfx11<0x02B, BUFFER_GL0_INV>;
215181ad6265SDimitry Andricdef BUFFER_GL1_INV_gfx11          : MUBUF_Real_gfx11<0x02C, BUFFER_GL1_INV>;
215281ad6265SDimitry Andric}
215381ad6265SDimitry Andric
215481ad6265SDimitry Andricdefm BUFFER_LOAD_DWORD            : MUBUF_Real_AllAddr_gfx11_Renamed<0x014, "buffer_load_b32">;
215581ad6265SDimitry Andricdefm BUFFER_LOAD_DWORDX2          : MUBUF_Real_AllAddr_gfx11_Renamed<0x015, "buffer_load_b64">;
215681ad6265SDimitry Andricdefm BUFFER_LOAD_DWORDX3          : MUBUF_Real_AllAddr_gfx11_Renamed<0x016, "buffer_load_b96">;
215781ad6265SDimitry Andricdefm BUFFER_LOAD_DWORDX4          : MUBUF_Real_AllAddr_gfx11_Renamed<0x017, "buffer_load_b128">;
215881ad6265SDimitry Andricdefm BUFFER_LOAD_SHORT_D16        : MUBUF_Real_AllAddr_gfx11_Renamed<0x020, "buffer_load_d16_b16">;
215981ad6265SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_X     : MUBUF_Real_AllAddr_gfx11_Renamed<0x008, "buffer_load_d16_format_x">;
216081ad6265SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_XY    : MUBUF_Real_AllAddr_gfx11_Renamed<0x009, "buffer_load_d16_format_xy">;
216181ad6265SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_XYZ   : MUBUF_Real_AllAddr_gfx11_Renamed<0x00a, "buffer_load_d16_format_xyz">;
216281ad6265SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_XYZW  : MUBUF_Real_AllAddr_gfx11_Renamed<0x00b, "buffer_load_d16_format_xyzw">;
216381ad6265SDimitry Andricdefm BUFFER_LOAD_SHORT_D16_HI     : MUBUF_Real_AllAddr_gfx11_Renamed<0x023, "buffer_load_d16_hi_b16">;
216481ad6265SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_HI_X  : MUBUF_Real_AllAddr_gfx11_Renamed<0x026, "buffer_load_d16_hi_format_x">;
216581ad6265SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16_HI     : MUBUF_Real_AllAddr_gfx11_Renamed<0x022, "buffer_load_d16_hi_i8">;
216681ad6265SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16_HI     : MUBUF_Real_AllAddr_gfx11_Renamed<0x021, "buffer_load_d16_hi_u8">;
216781ad6265SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16        : MUBUF_Real_AllAddr_gfx11_Renamed<0x01f, "buffer_load_d16_i8">;
216881ad6265SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16        : MUBUF_Real_AllAddr_gfx11_Renamed<0x01e, "buffer_load_d16_u8">;
216981ad6265SDimitry Andricdefm BUFFER_LOAD_FORMAT_X         : MUBUF_Real_AllAddr_gfx11<0x000>;
217081ad6265SDimitry Andricdefm BUFFER_LOAD_FORMAT_XY        : MUBUF_Real_AllAddr_gfx11<0x001>;
217181ad6265SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZ       : MUBUF_Real_AllAddr_gfx11<0x002>;
217281ad6265SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZW      : MUBUF_Real_AllAddr_gfx11<0x003>;
217381ad6265SDimitry Andricdefm BUFFER_LOAD_SBYTE            : MUBUF_Real_AllAddr_gfx11_Renamed<0x011, "buffer_load_i8">;
217481ad6265SDimitry Andricdefm BUFFER_LOAD_SSHORT           : MUBUF_Real_AllAddr_gfx11_Renamed<0x013, "buffer_load_i16">;
217581ad6265SDimitry Andricdefm BUFFER_LOAD_UBYTE            : MUBUF_Real_AllAddr_gfx11_Renamed<0x010, "buffer_load_u8">;
217681ad6265SDimitry Andricdefm BUFFER_LOAD_USHORT           : MUBUF_Real_AllAddr_gfx11_Renamed<0x012, "buffer_load_u16">;
2177bdd1243dSDimitry Andricdefm BUFFER_LOAD_LDS_B32          : MUBUF_Real_AllAddr_gfx11<0x031, 0>;
2178bdd1243dSDimitry Andricdefm BUFFER_LOAD_LDS_FORMAT_X     : MUBUF_Real_AllAddr_gfx11<0x032, 0>;
2179bdd1243dSDimitry Andricdefm BUFFER_LOAD_LDS_I8           : MUBUF_Real_AllAddr_gfx11<0x02e, 0>;
2180bdd1243dSDimitry Andricdefm BUFFER_LOAD_LDS_I16          : MUBUF_Real_AllAddr_gfx11<0x030, 0>;
2181bdd1243dSDimitry Andricdefm BUFFER_LOAD_LDS_U8           : MUBUF_Real_AllAddr_gfx11<0x02d, 0>;
2182bdd1243dSDimitry Andricdefm BUFFER_LOAD_LDS_U16          : MUBUF_Real_AllAddr_gfx11<0x02f, 0>;
218381ad6265SDimitry Andricdefm BUFFER_STORE_BYTE            : MUBUF_Real_AllAddr_gfx11_Renamed<0x018, "buffer_store_b8">;
218481ad6265SDimitry Andricdefm BUFFER_STORE_SHORT           : MUBUF_Real_AllAddr_gfx11_Renamed<0x019, "buffer_store_b16">;
218581ad6265SDimitry Andricdefm BUFFER_STORE_DWORD           : MUBUF_Real_AllAddr_gfx11_Renamed<0x01A, "buffer_store_b32">;
218681ad6265SDimitry Andricdefm BUFFER_STORE_DWORDX2         : MUBUF_Real_AllAddr_gfx11_Renamed<0x01B, "buffer_store_b64">;
218781ad6265SDimitry Andricdefm BUFFER_STORE_DWORDX3         : MUBUF_Real_AllAddr_gfx11_Renamed<0x01C, "buffer_store_b96">;
218881ad6265SDimitry Andricdefm BUFFER_STORE_DWORDX4         : MUBUF_Real_AllAddr_gfx11_Renamed<0x01D, "buffer_store_b128">;
218981ad6265SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_X    : MUBUF_Real_AllAddr_gfx11_Renamed<0x00C, "buffer_store_d16_format_x">;
219081ad6265SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_XY   : MUBUF_Real_AllAddr_gfx11_Renamed<0x00D, "buffer_store_d16_format_xy">;
219181ad6265SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_XYZ  : MUBUF_Real_AllAddr_gfx11_Renamed<0x00E, "buffer_store_d16_format_xyz">;
219281ad6265SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_XYZW : MUBUF_Real_AllAddr_gfx11_Renamed<0x00F, "buffer_store_d16_format_xyzw">;
219381ad6265SDimitry Andricdefm BUFFER_STORE_BYTE_D16_HI     : MUBUF_Real_AllAddr_gfx11_Renamed<0x024, "buffer_store_d16_hi_b8">;
219481ad6265SDimitry Andricdefm BUFFER_STORE_SHORT_D16_HI    : MUBUF_Real_AllAddr_gfx11_Renamed<0x025, "buffer_store_d16_hi_b16">;
219581ad6265SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_HI_X : MUBUF_Real_AllAddr_gfx11_Renamed<0x027, "buffer_store_d16_hi_format_x">;
219681ad6265SDimitry Andricdefm BUFFER_STORE_FORMAT_X        : MUBUF_Real_AllAddr_gfx11<0x004>;
219781ad6265SDimitry Andricdefm BUFFER_STORE_FORMAT_XY       : MUBUF_Real_AllAddr_gfx11<0x005>;
219881ad6265SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZ      : MUBUF_Real_AllAddr_gfx11<0x006>;
219981ad6265SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZW     : MUBUF_Real_AllAddr_gfx11<0x007>;
2200bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_ADD_F32        : MUBUF_Real_Atomic_gfx11<0x056>;
2201bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_ADD            : MUBUF_Real_Atomic_gfx11_Renamed<0x035, "buffer_atomic_add_u32">;
2202bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_ADD_X2         : MUBUF_Real_Atomic_gfx11_Renamed<0x043, "buffer_atomic_add_u64">;
2203bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_AND            : MUBUF_Real_Atomic_gfx11_Renamed<0x03C, "buffer_atomic_and_b32">;
2204bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_AND_X2         : MUBUF_Real_Atomic_gfx11_Renamed<0x049, "buffer_atomic_and_b64">;
2205bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP        : MUBUF_Real_Atomic_gfx11_Renamed<0x034, "buffer_atomic_cmpswap_b32">;
2206bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP_X2     : MUBUF_Real_Atomic_gfx11_Renamed<0x042, "buffer_atomic_cmpswap_b64">;
2207bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_FCMPSWAP       : MUBUF_Real_Atomic_gfx11_Renamed<0x050, "buffer_atomic_cmpswap_f32">;
2208bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_CSUB           : MUBUF_Real_Atomic_gfx11_Renamed_impl<0x037, 1, "buffer_atomic_csub_u32">;
2209bdd1243dSDimitry Andricdef : Pre_gfx11_MUBUF_Name<"buffer_atomic_csub", "buffer_atomic_csub_u32">;
2210bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_DEC            : MUBUF_Real_Atomic_gfx11_Renamed<0x040, "buffer_atomic_dec_u32">;
2211bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_DEC_X2         : MUBUF_Real_Atomic_gfx11_Renamed<0x04D, "buffer_atomic_dec_u64">;
2212bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_INC            : MUBUF_Real_Atomic_gfx11_Renamed<0x03F, "buffer_atomic_inc_u32">;
2213bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_INC_X2         : MUBUF_Real_Atomic_gfx11_Renamed<0x04C, "buffer_atomic_inc_u64">;
2214bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_FMAX           : MUBUF_Real_Atomic_gfx11_Renamed<0x052, "buffer_atomic_max_f32">;
2215bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_SMAX           : MUBUF_Real_Atomic_gfx11_Renamed<0x03A, "buffer_atomic_max_i32">;
2216bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_SMAX_X2        : MUBUF_Real_Atomic_gfx11_Renamed<0x047, "buffer_atomic_max_i64">;
2217bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_UMAX           : MUBUF_Real_Atomic_gfx11_Renamed<0x03B, "buffer_atomic_max_u32">;
2218bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_UMAX_X2        : MUBUF_Real_Atomic_gfx11_Renamed<0x048, "buffer_atomic_max_u64">;
2219bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_FMIN           : MUBUF_Real_Atomic_gfx11_Renamed<0x051, "buffer_atomic_min_f32">;
2220bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_SMIN           : MUBUF_Real_Atomic_gfx11_Renamed<0x038, "buffer_atomic_min_i32">;
2221bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_SMIN_X2        : MUBUF_Real_Atomic_gfx11_Renamed<0x045, "buffer_atomic_min_i64">;
2222bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_UMIN           : MUBUF_Real_Atomic_gfx11_Renamed<0x039, "buffer_atomic_min_u32">;
2223bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_UMIN_X2        : MUBUF_Real_Atomic_gfx11_Renamed<0x046, "buffer_atomic_min_u64">;
2224bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_OR             : MUBUF_Real_Atomic_gfx11_Renamed<0x03D, "buffer_atomic_or_b32">;
2225bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_OR_X2          : MUBUF_Real_Atomic_gfx11_Renamed<0x04A, "buffer_atomic_or_b64">;
2226bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_SUB            : MUBUF_Real_Atomic_gfx11_Renamed<0x036, "buffer_atomic_sub_u32">;
2227bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_SUB_X2         : MUBUF_Real_Atomic_gfx11_Renamed<0x044, "buffer_atomic_sub_u64">;
2228bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_SWAP           : MUBUF_Real_Atomic_gfx11_Renamed<0x033, "buffer_atomic_swap_b32">;
2229bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_SWAP_X2        : MUBUF_Real_Atomic_gfx11_Renamed<0x041, "buffer_atomic_swap_b64">;
2230bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_XOR            : MUBUF_Real_Atomic_gfx11_Renamed<0x03E, "buffer_atomic_xor_b32">;
2231bdd1243dSDimitry Andricdefm BUFFER_ATOMIC_XOR_X2         : MUBUF_Real_Atomic_gfx11_Renamed<0x04B, "buffer_atomic_xor_b64">;
223281ad6265SDimitry Andric
223381ad6265SDimitry Andric//===----------------------------------------------------------------------===//
22340b57cec5SDimitry Andric// MUBUF - GFX10.
22350b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
22360b57cec5SDimitry Andric
223781ad6265SDimitry Andriclet AssemblerPredicate = isGFX10Only, DecoderNamespace = "GFX10" in {
2238bdd1243dSDimitry Andric  multiclass MUBUF_Real_AllAddr_Helper_gfx10<bits<8> op> {
22390b57cec5SDimitry Andric    def _BOTHEN_gfx10 :
22400b57cec5SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>;
22410b57cec5SDimitry Andric    def _IDXEN_gfx10 :
22420b57cec5SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>;
22430b57cec5SDimitry Andric    def _OFFEN_gfx10 :
22440b57cec5SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>;
22450b57cec5SDimitry Andric    def _OFFSET_gfx10 :
22460b57cec5SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>;
22470b57cec5SDimitry Andric  }
2248bdd1243dSDimitry Andric  multiclass MUBUF_Real_AllAddr_gfx10<bits<8> op> {
2249bdd1243dSDimitry Andric    defm NAME : MUBUF_Real_AllAddr_Helper_gfx10<op>;
2250bdd1243dSDimitry Andric    defm _TFE : MUBUF_Real_AllAddr_Helper_gfx10<op>;
2251bdd1243dSDimitry Andric  }
2252bdd1243dSDimitry Andric  multiclass MUBUF_Real_AllAddr_Lds_gfx10<bits<8> op, bit isTFE = 0> {
225381ad6265SDimitry Andric    def _OFFSET_gfx10 : MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>;
225481ad6265SDimitry Andric    def _OFFEN_gfx10  : MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>;
225581ad6265SDimitry Andric    def _IDXEN_gfx10  : MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>;
225681ad6265SDimitry Andric    def _BOTHEN_gfx10 : MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>;
22570b57cec5SDimitry Andric
2258bdd1243dSDimitry Andric    if !not(isTFE) then {
225981ad6265SDimitry Andric      def _LDS_OFFSET_gfx10 : MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_LDS_OFFSET")>;
226081ad6265SDimitry Andric      def _LDS_OFFEN_gfx10  : MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_LDS_OFFEN")>;
226181ad6265SDimitry Andric      def _LDS_IDXEN_gfx10  : MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_LDS_IDXEN")>;
226281ad6265SDimitry Andric      def _LDS_BOTHEN_gfx10 : MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_LDS_BOTHEN")>;
22630b57cec5SDimitry Andric    }
2264bdd1243dSDimitry Andric  }
22655ffd83dbSDimitry Andric  multiclass MUBUF_Real_Atomics_RTN_gfx10<bits<8> op> {
22660b57cec5SDimitry Andric    def _BOTHEN_RTN_gfx10 :
2267fe6060f1SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN_RTN")>,
2268fe6060f1SDimitry Andric      AtomicNoRet<NAME # "_BOTHEN_gfx10", 1>;
22690b57cec5SDimitry Andric    def _IDXEN_RTN_gfx10 :
2270fe6060f1SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN_RTN")>,
2271fe6060f1SDimitry Andric      AtomicNoRet<NAME # "_IDXEN_gfx10", 1>;
22720b57cec5SDimitry Andric    def _OFFEN_RTN_gfx10 :
2273fe6060f1SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN_RTN")>,
2274fe6060f1SDimitry Andric      AtomicNoRet<NAME # "_OFFEN_gfx10", 1>;
22750b57cec5SDimitry Andric    def _OFFSET_RTN_gfx10 :
2276fe6060f1SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET_RTN")>,
2277fe6060f1SDimitry Andric      AtomicNoRet<NAME # "_OFFSET_gfx10", 1>;
22780b57cec5SDimitry Andric  }
22795ffd83dbSDimitry Andric  multiclass MUBUF_Real_Atomics_gfx10<bits<8> op> :
2280fe6060f1SDimitry Andric      MUBUF_Real_Atomics_RTN_gfx10<op> {
2281fe6060f1SDimitry Andric    def _BOTHEN_gfx10 :
2282fe6060f1SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>,
2283fe6060f1SDimitry Andric      AtomicNoRet<NAME # "_BOTHEN_gfx10", 0>;
2284fe6060f1SDimitry Andric    def _IDXEN_gfx10 :
2285fe6060f1SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>,
2286fe6060f1SDimitry Andric      AtomicNoRet<NAME # "_IDXEN_gfx10", 0>;
2287fe6060f1SDimitry Andric    def _OFFEN_gfx10 :
2288fe6060f1SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>,
2289fe6060f1SDimitry Andric      AtomicNoRet<NAME # "_OFFEN_gfx10", 0>;
2290fe6060f1SDimitry Andric    def _OFFSET_gfx10 :
2291fe6060f1SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>,
2292fe6060f1SDimitry Andric      AtomicNoRet<NAME # "_OFFSET_gfx10", 0>;
2293fe6060f1SDimitry Andric  }
229481ad6265SDimitry Andric} // End AssemblerPredicate = isGFX10Only, DecoderNamespace = "GFX10"
22950b57cec5SDimitry Andric
22960b57cec5SDimitry Andricdefm BUFFER_STORE_BYTE_D16_HI     : MUBUF_Real_AllAddr_gfx10<0x019>;
22970b57cec5SDimitry Andricdefm BUFFER_STORE_SHORT_D16_HI    : MUBUF_Real_AllAddr_gfx10<0x01b>;
22980b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16        : MUBUF_Real_AllAddr_gfx10<0x020>;
22990b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16_HI     : MUBUF_Real_AllAddr_gfx10<0x021>;
23000b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16        : MUBUF_Real_AllAddr_gfx10<0x022>;
23010b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16_HI     : MUBUF_Real_AllAddr_gfx10<0x023>;
23020b57cec5SDimitry Andricdefm BUFFER_LOAD_SHORT_D16        : MUBUF_Real_AllAddr_gfx10<0x024>;
23030b57cec5SDimitry Andricdefm BUFFER_LOAD_SHORT_D16_HI     : MUBUF_Real_AllAddr_gfx10<0x025>;
23040b57cec5SDimitry Andric// FIXME-GFX10: Add following instructions:
23050b57cec5SDimitry Andric//defm BUFFER_LOAD_FORMAT_D16_HI_X  : MUBUF_Real_AllAddr_gfx10<0x026>;
23060b57cec5SDimitry Andric//defm BUFFER_STORE_FORMAT_D16_HI_X : MUBUF_Real_AllAddr_gfx10<0x027>;
23070b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_X     : MUBUF_Real_AllAddr_gfx10<0x080>;
23080b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_XY    : MUBUF_Real_AllAddr_gfx10<0x081>;
23090b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_XYZ   : MUBUF_Real_AllAddr_gfx10<0x082>;
23100b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_XYZW  : MUBUF_Real_AllAddr_gfx10<0x083>;
23110b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_X    : MUBUF_Real_AllAddr_gfx10<0x084>;
23120b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_XY   : MUBUF_Real_AllAddr_gfx10<0x085>;
23130b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_XYZ  : MUBUF_Real_AllAddr_gfx10<0x086>;
23140b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_XYZW : MUBUF_Real_AllAddr_gfx10<0x087>;
23150b57cec5SDimitry Andric
23160b57cec5SDimitry Andricdef BUFFER_GL0_INV_gfx10 :
23170b57cec5SDimitry Andric  MUBUF_Real_gfx10<0x071, BUFFER_GL0_INV>;
23180b57cec5SDimitry Andricdef BUFFER_GL1_INV_gfx10 :
23190b57cec5SDimitry Andric  MUBUF_Real_gfx10<0x072, BUFFER_GL1_INV>;
23200b57cec5SDimitry Andric
23210b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
23220b57cec5SDimitry Andric// MUBUF - GFX6, GFX7, GFX10.
23230b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
23240b57cec5SDimitry Andric
23250b57cec5SDimitry Andriclet AssemblerPredicate = isGFX6, DecoderNamespace = "GFX6" in {
23260b57cec5SDimitry Andric  multiclass MUBUF_Real_gfx6<bits<8> op> {
23270b57cec5SDimitry Andric    def _gfx6 : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME)>;
23280b57cec5SDimitry Andric  }
23290b57cec5SDimitry Andric} // End AssemblerPredicate = isGFX6, DecoderNamespace = "GFX6"
23300b57cec5SDimitry Andric
23310b57cec5SDimitry Andriclet AssemblerPredicate = isGFX7Only, DecoderNamespace = "GFX7" in {
23320b57cec5SDimitry Andric  multiclass MUBUF_Real_gfx7<bits<8> op> {
23330b57cec5SDimitry Andric    def _gfx7 : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME)>;
23340b57cec5SDimitry Andric  }
23350b57cec5SDimitry Andric} // End AssemblerPredicate = isGFX7Only, DecoderNamespace = "GFX7"
23360b57cec5SDimitry Andric
23370b57cec5SDimitry Andriclet AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" in {
2338bdd1243dSDimitry Andric  multiclass MUBUF_Real_AllAddr_Helper_gfx6_gfx7<bits<8> op> {
23390b57cec5SDimitry Andric    def _ADDR64_gfx6_gfx7 :
23400b57cec5SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_ADDR64")>;
23410b57cec5SDimitry Andric    def _BOTHEN_gfx6_gfx7 :
23420b57cec5SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>;
23430b57cec5SDimitry Andric    def _IDXEN_gfx6_gfx7 :
23440b57cec5SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>;
23450b57cec5SDimitry Andric    def _OFFEN_gfx6_gfx7 :
23460b57cec5SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>;
23470b57cec5SDimitry Andric    def _OFFSET_gfx6_gfx7 :
23480b57cec5SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>;
23490b57cec5SDimitry Andric  }
2350bdd1243dSDimitry Andric  multiclass MUBUF_Real_AllAddr_gfx6_gfx7<bits<8> op> {
2351bdd1243dSDimitry Andric    defm NAME : MUBUF_Real_AllAddr_Helper_gfx6_gfx7<op>;
2352bdd1243dSDimitry Andric    defm _TFE : MUBUF_Real_AllAddr_Helper_gfx6_gfx7<op>;
2353bdd1243dSDimitry Andric  }
2354bdd1243dSDimitry Andric  multiclass MUBUF_Real_AllAddr_Lds_gfx6_gfx7<bits<8> op, bit isTFE = 0> {
235581ad6265SDimitry Andric    def _OFFSET_gfx6_gfx7 : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>;
235681ad6265SDimitry Andric    def _ADDR64_gfx6_gfx7 : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_ADDR64")>;
235781ad6265SDimitry Andric    def _OFFEN_gfx6_gfx7  : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>;
235881ad6265SDimitry Andric    def _IDXEN_gfx6_gfx7  : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>;
235981ad6265SDimitry Andric    def _BOTHEN_gfx6_gfx7 : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>;
23600b57cec5SDimitry Andric
2361bdd1243dSDimitry Andric    if !not(isTFE) then {
236281ad6265SDimitry Andric      def _LDS_OFFSET_gfx6_gfx7 : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_LDS_OFFSET")>;
236381ad6265SDimitry Andric      def _LDS_ADDR64_gfx6_gfx7 : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_LDS_ADDR64")>;
236481ad6265SDimitry Andric      def _LDS_OFFEN_gfx6_gfx7  : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_LDS_OFFEN")>;
236581ad6265SDimitry Andric      def _LDS_IDXEN_gfx6_gfx7  : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_LDS_IDXEN")>;
236681ad6265SDimitry Andric      def _LDS_BOTHEN_gfx6_gfx7 : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_LDS_BOTHEN")>;
23670b57cec5SDimitry Andric    }
2368bdd1243dSDimitry Andric  }
2369fe6060f1SDimitry Andric  multiclass MUBUF_Real_Atomics_gfx6_gfx7<bits<8> op> {
2370fe6060f1SDimitry Andric    def _ADDR64_gfx6_gfx7 :
2371fe6060f1SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_ADDR64")>,
2372fe6060f1SDimitry Andric      AtomicNoRet<NAME # "_ADDR64_gfx6_gfx7", 0>;
2373fe6060f1SDimitry Andric    def _BOTHEN_gfx6_gfx7 :
2374fe6060f1SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>,
2375fe6060f1SDimitry Andric      AtomicNoRet<NAME # "_BOTHEN_gfx6_gfx7", 0>;
2376fe6060f1SDimitry Andric    def _IDXEN_gfx6_gfx7 :
2377fe6060f1SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>,
2378fe6060f1SDimitry Andric      AtomicNoRet<NAME # "_IDXEN_gfx6_gfx7", 0>;
2379fe6060f1SDimitry Andric    def _OFFEN_gfx6_gfx7 :
2380fe6060f1SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>,
2381fe6060f1SDimitry Andric      AtomicNoRet<NAME # "_OFFEN_gfx6_gfx7", 0>;
2382fe6060f1SDimitry Andric    def _OFFSET_gfx6_gfx7 :
2383fe6060f1SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>,
2384fe6060f1SDimitry Andric      AtomicNoRet<NAME # "_OFFSET_gfx6_gfx7", 0>;
2385fe6060f1SDimitry Andric
23860b57cec5SDimitry Andric    def _ADDR64_RTN_gfx6_gfx7 :
2387fe6060f1SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_ADDR64_RTN")>,
2388fe6060f1SDimitry Andric      AtomicNoRet<NAME # "_ADDR64_gfx6_gfx7", 1>;
23890b57cec5SDimitry Andric    def _BOTHEN_RTN_gfx6_gfx7 :
2390fe6060f1SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN_RTN")>,
2391fe6060f1SDimitry Andric      AtomicNoRet<NAME # "_BOTHEN_gfx6_gfx7", 1>;
23920b57cec5SDimitry Andric    def _IDXEN_RTN_gfx6_gfx7 :
2393fe6060f1SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN_RTN")>,
2394fe6060f1SDimitry Andric      AtomicNoRet<NAME # "_IDXEN_gfx6_gfx7", 1>;
23950b57cec5SDimitry Andric    def _OFFEN_RTN_gfx6_gfx7 :
2396fe6060f1SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN_RTN")>,
2397fe6060f1SDimitry Andric      AtomicNoRet<NAME # "_OFFEN_gfx6_gfx7", 1>;
23980b57cec5SDimitry Andric    def _OFFSET_RTN_gfx6_gfx7 :
2399fe6060f1SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET_RTN")>,
2400fe6060f1SDimitry Andric      AtomicNoRet<NAME # "_OFFSET_gfx6_gfx7", 1>;
24010b57cec5SDimitry Andric  }
24020b57cec5SDimitry Andric} // End AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7"
24030b57cec5SDimitry Andric
24040b57cec5SDimitry Andricmulticlass MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<bits<8> op> :
24050b57cec5SDimitry Andric  MUBUF_Real_AllAddr_gfx6_gfx7<op>, MUBUF_Real_AllAddr_gfx10<op>;
24060b57cec5SDimitry Andric
2407bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_Lds_Helper_gfx6_gfx7_gfx10<bits<8> op, bit isTFE = 0> :
2408bdd1243dSDimitry Andric  MUBUF_Real_AllAddr_Lds_gfx6_gfx7<op, isTFE>,
2409bdd1243dSDimitry Andric  MUBUF_Real_AllAddr_Lds_gfx10<op, isTFE>;
2410bdd1243dSDimitry Andric
2411bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<bits<8> op> {
2412bdd1243dSDimitry Andric  defm NAME : MUBUF_Real_AllAddr_Lds_Helper_gfx6_gfx7_gfx10<op>;
2413bdd1243dSDimitry Andric  defm _TFE : MUBUF_Real_AllAddr_Lds_Helper_gfx6_gfx7_gfx10<op, 1>;
2414bdd1243dSDimitry Andric}
24150b57cec5SDimitry Andric
24160b57cec5SDimitry Andricmulticlass MUBUF_Real_Atomics_gfx6_gfx7_gfx10<bits<8> op> :
24170b57cec5SDimitry Andric  MUBUF_Real_Atomics_gfx6_gfx7<op>, MUBUF_Real_Atomics_gfx10<op>;
24180b57cec5SDimitry Andric
24190b57cec5SDimitry Andric// FIXME-GFX6: Following instructions are available only on GFX6.
24200b57cec5SDimitry Andric//defm BUFFER_ATOMIC_RSUB         : MUBUF_Real_Atomics_gfx6 <0x034>;
24210b57cec5SDimitry Andric//defm BUFFER_ATOMIC_RSUB_X2      : MUBUF_Real_Atomics_gfx6 <0x054>;
24220b57cec5SDimitry Andric
24230b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_X     : MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<0x000>;
24240b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XY    : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x001>;
24250b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZ   : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x002>;
24260b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZW  : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x003>;
24270b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_X    : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x004>;
24280b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XY   : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x005>;
24290b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZ  : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x006>;
24300b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZW : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x007>;
24310b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE        : MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<0x008>;
24320b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE        : MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<0x009>;
24330b57cec5SDimitry Andricdefm BUFFER_LOAD_USHORT       : MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<0x00a>;
24340b57cec5SDimitry Andricdefm BUFFER_LOAD_SSHORT       : MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<0x00b>;
24350b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORD        : MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<0x00c>;
24360b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX2      : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x00d>;
24370b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX4      : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x00e>;
24380b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX3      : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x00f>;
24390b57cec5SDimitry Andricdefm BUFFER_STORE_BYTE        : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x018>;
24400b57cec5SDimitry Andricdefm BUFFER_STORE_SHORT       : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x01a>;
24410b57cec5SDimitry Andricdefm BUFFER_STORE_DWORD       : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x01c>;
24420b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX2     : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x01d>;
24430b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX4     : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x01e>;
24440b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX3     : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x01f>;
24450b57cec5SDimitry Andric
24460b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SWAP        : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x030>;
24470b57cec5SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP     : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x031>;
24480b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD         : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x032>;
24490b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SUB         : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x033>;
24500b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMIN        : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x035>;
24510b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMIN        : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x036>;
24520b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMAX        : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x037>;
24530b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMAX        : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x038>;
24540b57cec5SDimitry Andricdefm BUFFER_ATOMIC_AND         : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x039>;
24550b57cec5SDimitry Andricdefm BUFFER_ATOMIC_OR          : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x03a>;
24560b57cec5SDimitry Andricdefm BUFFER_ATOMIC_XOR         : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x03b>;
24570b57cec5SDimitry Andricdefm BUFFER_ATOMIC_INC         : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x03c>;
24580b57cec5SDimitry Andricdefm BUFFER_ATOMIC_DEC         : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x03d>;
24598bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FCMPSWAP    : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x03e>;
24608bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMIN        : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x03f>;
24618bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMAX        : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x040>;
24620b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SWAP_X2     : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x050>;
24630b57cec5SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP_X2  : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x051>;
24640b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD_X2      : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x052>;
24650b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SUB_X2      : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x053>;
24660b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMIN_X2     : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x055>;
24670b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMIN_X2     : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x056>;
24680b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMAX_X2     : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x057>;
24690b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMAX_X2     : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x058>;
24700b57cec5SDimitry Andricdefm BUFFER_ATOMIC_AND_X2      : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x059>;
24710b57cec5SDimitry Andricdefm BUFFER_ATOMIC_OR_X2       : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x05a>;
24720b57cec5SDimitry Andricdefm BUFFER_ATOMIC_XOR_X2      : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x05b>;
24730b57cec5SDimitry Andricdefm BUFFER_ATOMIC_INC_X2      : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x05c>;
24740b57cec5SDimitry Andricdefm BUFFER_ATOMIC_DEC_X2      : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x05d>;
24750b57cec5SDimitry Andric// FIXME-GFX7: Need to handle hazard for BUFFER_ATOMIC_FCMPSWAP_X2 on GFX7.
24768bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FCMPSWAP_X2 : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x05e>;
24778bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMIN_X2     : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x05f>;
24788bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMAX_X2     : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x060>;
24790b57cec5SDimitry Andric
24805ffd83dbSDimitry Andricdefm BUFFER_ATOMIC_CSUB       : MUBUF_Real_Atomics_RTN_gfx10<0x034>;
24815ffd83dbSDimitry Andric
24820b57cec5SDimitry Andricdefm BUFFER_WBINVL1_SC        : MUBUF_Real_gfx6<0x070>;
24830b57cec5SDimitry Andricdefm BUFFER_WBINVL1_VOL       : MUBUF_Real_gfx7<0x070>;
24840b57cec5SDimitry Andricdef  BUFFER_WBINVL1_gfx6_gfx7 : MUBUF_Real_gfx6_gfx7<0x071, BUFFER_WBINVL1>;
24850b57cec5SDimitry Andric
24860b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
248781ad6265SDimitry Andric// Base ENC_MTBUF for GFX6, GFX7, GFX10, GFX11.
24880b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
24890b57cec5SDimitry Andric
249081ad6265SDimitry Andricclass Base_MTBUF_Real_gfx6_gfx7_gfx10_gfx11<MTBUF_Pseudo ps, int ef,
249181ad6265SDimitry Andric                                            string real_name = ps.Mnemonic> :
249281ad6265SDimitry Andric  MTBUF_Real<ps, real_name>, Enc64, SIMCInstr<ps.PseudoInstr, ef> {
24930b57cec5SDimitry Andric  let Inst{11-0}  = !if(ps.has_offset, offset, ?);
2494fe6060f1SDimitry Andric  let Inst{14}    = !if(ps.has_glc, cpol{CPolBit.GLC}, ps.glc_value);
24950b57cec5SDimitry Andric  let Inst{31-26} = 0x3a; //encoding
24960b57cec5SDimitry Andric  let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?);
2497fe6060f1SDimitry Andric  let Inst{47-40} = !if(ps.has_vdata, vdata{7-0}, ?);
24980b57cec5SDimitry Andric  let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?);
24990b57cec5SDimitry Andric  let Inst{63-56} = !if(ps.has_soffset, soffset, ?);
25000b57cec5SDimitry Andric}
25010b57cec5SDimitry Andric
250281ad6265SDimitry Andricclass Base_MTBUF_Real_gfx11<bits<4> op, MTBUF_Pseudo ps,
250381ad6265SDimitry Andric                            string real_name = ps.Mnemonic> :
250481ad6265SDimitry Andric  Base_MTBUF_Real_gfx6_gfx7_gfx10_gfx11<ps, SIEncodingFamily.GFX11, real_name> {
250581ad6265SDimitry Andric  let Inst{12}    = !if(ps.has_slc, cpol{CPolBit.SLC}, ?);
250681ad6265SDimitry Andric  let Inst{13}    = !if(ps.has_dlc, cpol{CPolBit.DLC}, ps.dlc_value);
250781ad6265SDimitry Andric  let Inst{18-15} = op;
250881ad6265SDimitry Andric  let Inst{25-19} = format;
2509bdd1243dSDimitry Andric  let Inst{53}    = ps.tfe;
251081ad6265SDimitry Andric  let Inst{54}    = ps.offen;
251181ad6265SDimitry Andric  let Inst{55}    = ps.idxen;
251281ad6265SDimitry Andric}
251381ad6265SDimitry Andric
251481ad6265SDimitry Andricclass Base_MTBUF_Real_gfx6_gfx7_gfx10<bits<3> op, MTBUF_Pseudo ps, int ef> :
251581ad6265SDimitry Andric  Base_MTBUF_Real_gfx6_gfx7_gfx10_gfx11<ps, ef> {
251681ad6265SDimitry Andric  let Inst{12}    = ps.offen;
251781ad6265SDimitry Andric  let Inst{13}    = ps.idxen;
251881ad6265SDimitry Andric  let Inst{18-16} = op;
251981ad6265SDimitry Andric  let Inst{54}    = !if(ps.has_slc, cpol{CPolBit.SLC}, ?);
2520bdd1243dSDimitry Andric  let Inst{55}    = ps.tfe;
252181ad6265SDimitry Andric}
252281ad6265SDimitry Andric
252381ad6265SDimitry Andric//===----------------------------------------------------------------------===//
252481ad6265SDimitry Andric// MTBUF - GFX11.
252581ad6265SDimitry Andric//===----------------------------------------------------------------------===//
252681ad6265SDimitry Andric
252781ad6265SDimitry Andriclet AssemblerPredicate = isGFX11Only, DecoderNamespace = "GFX11" in
252881ad6265SDimitry Andricmulticlass MTBUF_Real_AllAddr_gfx11_Renamed_Impl<bits<4> op, string real_name> {
252981ad6265SDimitry Andric  def _BOTHEN_gfx11 :
253081ad6265SDimitry Andric    Base_MTBUF_Real_gfx11<op, !cast<MTBUF_Pseudo>(NAME#"_BOTHEN"), real_name>;
253181ad6265SDimitry Andric  def _IDXEN_gfx11 :
253281ad6265SDimitry Andric    Base_MTBUF_Real_gfx11<op, !cast<MTBUF_Pseudo>(NAME#"_IDXEN"), real_name>;
253381ad6265SDimitry Andric  def _OFFEN_gfx11 :
253481ad6265SDimitry Andric    Base_MTBUF_Real_gfx11<op, !cast<MTBUF_Pseudo>(NAME#"_OFFEN"), real_name>;
253581ad6265SDimitry Andric  def _OFFSET_gfx11 :
253681ad6265SDimitry Andric    Base_MTBUF_Real_gfx11<op, !cast<MTBUF_Pseudo>(NAME#"_OFFSET"), real_name>;
253781ad6265SDimitry Andric}
253881ad6265SDimitry Andric
253981ad6265SDimitry Andricmulticlass MTBUF_Real_AllAddr_gfx11_Impl<bits<4> op, MTBUF_Pseudo ps>
254081ad6265SDimitry Andric : MTBUF_Real_AllAddr_gfx11_Renamed_Impl<op, ps.Mnemonic>;
254181ad6265SDimitry Andricmulticlass MTBUF_Real_AllAddr_gfx11<bits<4> op>
254281ad6265SDimitry Andric : MTBUF_Real_AllAddr_gfx11_Impl<op, !cast<MTBUF_Pseudo>(NAME#"_BOTHEN")>;
254381ad6265SDimitry Andric
254481ad6265SDimitry Andric
254581ad6265SDimitry Andricclass Pre_gfx11_MTBUF_Name <MTBUF_Pseudo ps, string real_name>
254681ad6265SDimitry Andric  : MnemonicAlias<ps.Mnemonic, real_name>, Requires<[isGFX11Plus]>;
254781ad6265SDimitry Andricmulticlass MTBUF_Real_AllAddr_gfx11_Renamed<bits<4> op, string real_name>
254881ad6265SDimitry Andric  : MTBUF_Real_AllAddr_gfx11_Renamed_Impl<op, real_name> {
254981ad6265SDimitry Andric  def : Pre_gfx11_MTBUF_Name<!cast<MTBUF_Pseudo>(NAME#"_BOTHEN"), real_name>;
255081ad6265SDimitry Andric}
255181ad6265SDimitry Andric
255281ad6265SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_X     : MTBUF_Real_AllAddr_gfx11_Renamed<0x008, "tbuffer_load_d16_format_x">;
255381ad6265SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_XY    : MTBUF_Real_AllAddr_gfx11_Renamed<0x009, "tbuffer_load_d16_format_xy">;
255481ad6265SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_XYZ   : MTBUF_Real_AllAddr_gfx11_Renamed<0x00a, "tbuffer_load_d16_format_xyz">;
255581ad6265SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_XYZW  : MTBUF_Real_AllAddr_gfx11_Renamed<0x00b, "tbuffer_load_d16_format_xyzw">;
255681ad6265SDimitry Andricdefm TBUFFER_LOAD_FORMAT_X         : MTBUF_Real_AllAddr_gfx11<0x000>;
255781ad6265SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XY        : MTBUF_Real_AllAddr_gfx11<0x001>;
255881ad6265SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZ       : MTBUF_Real_AllAddr_gfx11<0x002>;
255981ad6265SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZW      : MTBUF_Real_AllAddr_gfx11<0x003>;
256081ad6265SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_X    : MTBUF_Real_AllAddr_gfx11_Renamed<0x00c, "tbuffer_store_d16_format_x">;
256181ad6265SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_XY   : MTBUF_Real_AllAddr_gfx11_Renamed<0x00d, "tbuffer_store_d16_format_xy">;
256281ad6265SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_XYZ  : MTBUF_Real_AllAddr_gfx11_Renamed<0x00e, "tbuffer_store_d16_format_xyz">;
256381ad6265SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_XYZW : MTBUF_Real_AllAddr_gfx11_Renamed<0x00f, "tbuffer_store_d16_format_xyzw">;
256481ad6265SDimitry Andricdefm TBUFFER_STORE_FORMAT_X        : MTBUF_Real_AllAddr_gfx11<0x004>;
256581ad6265SDimitry Andricdefm TBUFFER_STORE_FORMAT_XY       : MTBUF_Real_AllAddr_gfx11<0x005>;
256681ad6265SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZ      : MTBUF_Real_AllAddr_gfx11<0x006>;
256781ad6265SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZW     : MTBUF_Real_AllAddr_gfx11<0x007>;
256881ad6265SDimitry Andric
25690b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
25700b57cec5SDimitry Andric// MTBUF - GFX10.
25710b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
25720b57cec5SDimitry Andric
25730b57cec5SDimitry Andricclass MTBUF_Real_gfx10<bits<4> op, MTBUF_Pseudo ps> :
25740b57cec5SDimitry Andric    Base_MTBUF_Real_gfx6_gfx7_gfx10<op{2-0}, ps, SIEncodingFamily.GFX10> {
2575fe6060f1SDimitry Andric  let Inst{15} = !if(ps.has_dlc, cpol{CPolBit.DLC}, ps.dlc_value);
25760b57cec5SDimitry Andric  let Inst{25-19} = format;
25770b57cec5SDimitry Andric  let Inst{53} = op{3};
25780b57cec5SDimitry Andric}
25790b57cec5SDimitry Andric
258081ad6265SDimitry Andriclet AssemblerPredicate = isGFX10Only, DecoderNamespace = "GFX10" in {
25810b57cec5SDimitry Andric  multiclass MTBUF_Real_AllAddr_gfx10<bits<4> op> {
25820b57cec5SDimitry Andric    def _BOTHEN_gfx10 :
25830b57cec5SDimitry Andric      MTBUF_Real_gfx10<op, !cast<MTBUF_Pseudo>(NAME#"_BOTHEN")>;
25840b57cec5SDimitry Andric    def _IDXEN_gfx10 :
25850b57cec5SDimitry Andric      MTBUF_Real_gfx10<op, !cast<MTBUF_Pseudo>(NAME#"_IDXEN")>;
25860b57cec5SDimitry Andric    def _OFFEN_gfx10 :
25870b57cec5SDimitry Andric      MTBUF_Real_gfx10<op, !cast<MTBUF_Pseudo>(NAME#"_OFFEN")>;
25880b57cec5SDimitry Andric    def _OFFSET_gfx10 :
25890b57cec5SDimitry Andric      MTBUF_Real_gfx10<op, !cast<MTBUF_Pseudo>(NAME#"_OFFSET")>;
25900b57cec5SDimitry Andric  }
259181ad6265SDimitry Andric} // End AssemblerPredicate = isGFX10Only, DecoderNamespace = "GFX10"
25920b57cec5SDimitry Andric
25930b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_X     : MTBUF_Real_AllAddr_gfx10<0x008>;
25940b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_XY    : MTBUF_Real_AllAddr_gfx10<0x009>;
25950b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_XYZ   : MTBUF_Real_AllAddr_gfx10<0x00a>;
25960b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_XYZW  : MTBUF_Real_AllAddr_gfx10<0x00b>;
25970b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_X    : MTBUF_Real_AllAddr_gfx10<0x00c>;
25980b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_XY   : MTBUF_Real_AllAddr_gfx10<0x00d>;
25990b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_XYZ  : MTBUF_Real_AllAddr_gfx10<0x00e>;
26000b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_XYZW : MTBUF_Real_AllAddr_gfx10<0x00f>;
26010b57cec5SDimitry Andric
26020b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
26030b57cec5SDimitry Andric// MTBUF - GFX6, GFX7, GFX10.
26040b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
26050b57cec5SDimitry Andric
26060b57cec5SDimitry Andricclass MTBUF_Real_gfx6_gfx7<bits<4> op, MTBUF_Pseudo ps> :
26070b57cec5SDimitry Andric    Base_MTBUF_Real_gfx6_gfx7_gfx10<op{2-0}, ps, SIEncodingFamily.SI> {
26080b57cec5SDimitry Andric  let Inst{15} = ps.addr64;
26090b57cec5SDimitry Andric  let Inst{22-19} = dfmt;
26100b57cec5SDimitry Andric  let Inst{25-23} = nfmt;
26110b57cec5SDimitry Andric}
26120b57cec5SDimitry Andric
26130b57cec5SDimitry Andriclet AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" in {
26140b57cec5SDimitry Andric  multiclass MTBUF_Real_AllAddr_gfx6_gfx7<bits<4> op> {
26150b57cec5SDimitry Andric    def _ADDR64_gfx6_gfx7 :
26160b57cec5SDimitry Andric      MTBUF_Real_gfx6_gfx7<op, !cast<MTBUF_Pseudo>(NAME#"_ADDR64")>;
26170b57cec5SDimitry Andric    def _BOTHEN_gfx6_gfx7 :
26180b57cec5SDimitry Andric      MTBUF_Real_gfx6_gfx7<op, !cast<MTBUF_Pseudo>(NAME#"_BOTHEN")>;
26190b57cec5SDimitry Andric    def _IDXEN_gfx6_gfx7 :
26200b57cec5SDimitry Andric      MTBUF_Real_gfx6_gfx7<op, !cast<MTBUF_Pseudo>(NAME#"_IDXEN")>;
26210b57cec5SDimitry Andric    def _OFFEN_gfx6_gfx7 :
26220b57cec5SDimitry Andric      MTBUF_Real_gfx6_gfx7<op, !cast<MTBUF_Pseudo>(NAME#"_OFFEN")>;
26230b57cec5SDimitry Andric    def _OFFSET_gfx6_gfx7 :
26240b57cec5SDimitry Andric      MTBUF_Real_gfx6_gfx7<op, !cast<MTBUF_Pseudo>(NAME#"_OFFSET")>;
26250b57cec5SDimitry Andric  }
26260b57cec5SDimitry Andric} // End AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7"
26270b57cec5SDimitry Andric
26280b57cec5SDimitry Andricmulticlass MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<bits<4> op> :
26290b57cec5SDimitry Andric  MTBUF_Real_AllAddr_gfx6_gfx7<op>, MTBUF_Real_AllAddr_gfx10<op>;
26300b57cec5SDimitry Andric
26310b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_X     : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x000>;
26320b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XY    : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x001>;
26330b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZ   : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x002>;
26340b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZW  : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x003>;
26350b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_X    : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x004>;
26360b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_XY   : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x005>;
26370b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZ  : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x006>;
26380b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZW : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x007>;
26390b57cec5SDimitry Andric
26400b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
26410b57cec5SDimitry Andric// GFX8, GFX9 (VI).
26420b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
26430b57cec5SDimitry Andric
2644fe6060f1SDimitry Andricclass MUBUF_Real_Base_vi <bits<7> op, MUBUF_Pseudo ps, int Enc,
2645fe6060f1SDimitry Andric                          bit has_sccb = ps.has_sccb> :
26460b57cec5SDimitry Andric  MUBUF_Real<ps>,
26470b57cec5SDimitry Andric  Enc64,
2648fe6060f1SDimitry Andric  SIMCInstr<ps.PseudoInstr, Enc>,
2649fe6060f1SDimitry Andric  AtomicNoRet<!subst("_RTN","",NAME), !if(ps.IsAtomicNoRet, 0,
2650fe6060f1SDimitry Andric                                        !if(ps.IsAtomicRet, 1, ?))> {
26510b57cec5SDimitry Andric
26520b57cec5SDimitry Andric  let Inst{11-0}  = !if(ps.has_offset, offset, ?);
26530b57cec5SDimitry Andric  let Inst{12}    = ps.offen;
26540b57cec5SDimitry Andric  let Inst{13}    = ps.idxen;
2655fe6060f1SDimitry Andric  let Inst{14}    = !if(ps.has_glc, cpol{CPolBit.GLC}, ps.glc_value);
2656fe6060f1SDimitry Andric  let Inst{15}    = !if(has_sccb, cpol{CPolBit.SCC}, ps.sccb_value);
2657e8d8bef9SDimitry Andric  let Inst{16}    = ps.lds;
2658fe6060f1SDimitry Andric  let Inst{17}    = !if(ps.has_slc, cpol{CPolBit.SLC}, ?);
26590b57cec5SDimitry Andric  let Inst{24-18} = op;
26600b57cec5SDimitry Andric  let Inst{31-26} = 0x38; //encoding
26610b57cec5SDimitry Andric  let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?);
2662fe6060f1SDimitry Andric  let Inst{47-40} = !if(ps.has_vdata, vdata{7-0}, ?);
26630b57cec5SDimitry Andric  let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?);
26640b57cec5SDimitry Andric  let Inst{63-56} = !if(ps.has_soffset, soffset, ?);
26650b57cec5SDimitry Andric}
26660b57cec5SDimitry Andric
2667fe6060f1SDimitry Andricclass MUBUF_Real_vi <bits<7> op, MUBUF_Pseudo ps, bit has_sccb = ps.has_sccb> :
2668fe6060f1SDimitry Andric  MUBUF_Real_Base_vi<op, ps, SIEncodingFamily.VI, has_sccb> {
2669fe6060f1SDimitry Andric  let AssemblerPredicate = isGFX8GFX9NotGFX90A;
2670fe6060f1SDimitry Andric  let DecoderNamespace = "GFX8";
2671fe6060f1SDimitry Andric
2672bdd1243dSDimitry Andric  let Inst{55}    = ps.tfe;
2673fe6060f1SDimitry Andric}
2674fe6060f1SDimitry Andric
2675fe6060f1SDimitry Andricclass MUBUF_Real_gfx90a <bits<7> op, MUBUF_Pseudo ps,
2676fe6060f1SDimitry Andric                         bit has_sccb = ps.has_sccb> :
2677fe6060f1SDimitry Andric  MUBUF_Real_Base_vi<op, ps, SIEncodingFamily.GFX90A, has_sccb> {
2678fe6060f1SDimitry Andric  let AssemblerPredicate = isGFX90APlus;
2679fe6060f1SDimitry Andric  let DecoderNamespace = "GFX90A";
2680fe6060f1SDimitry Andric  let AsmString = ps.Mnemonic # !subst("$sccb", !if(has_sccb, "$sccb",""),
2681bdd1243dSDimitry Andric                                ps.AsmOperands);
2682fe6060f1SDimitry Andric
2683fe6060f1SDimitry Andric  let Inst{55}    = acc;
2684fe6060f1SDimitry Andric}
2685fe6060f1SDimitry Andric
268681ad6265SDimitry Andricclass MUBUF_Real_gfx940 <bits<7> op, MUBUF_Pseudo ps> :
268781ad6265SDimitry Andric  MUBUF_Real_Base_vi<op, ps, SIEncodingFamily.GFX940> {
268881ad6265SDimitry Andric  let AssemblerPredicate = isGFX940Plus;
268981ad6265SDimitry Andric  let DecoderNamespace = "GFX9";
2690bdd1243dSDimitry Andric  let AsmString = ps.Mnemonic # ps.AsmOperands;
269181ad6265SDimitry Andric
269281ad6265SDimitry Andric  let Inst{55} = acc;
269381ad6265SDimitry Andric}
269481ad6265SDimitry Andric
2695bdd1243dSDimitry Andricmulticlass MUBUF_Real_vi_gfx90a<bits<7> op, MUBUF_Pseudo ps, bit isTFE = 0> {
2696fe6060f1SDimitry Andric  def _vi :     MUBUF_Real_vi<op, ps>;
269781ad6265SDimitry Andric
2698bdd1243dSDimitry Andric  if !not(isTFE) then {
2699*06c3fb27SDimitry Andric    if !not(ps.FPAtomic) then
270081ad6265SDimitry Andric      def _gfx90a : MUBUF_Real_gfx90a<op, ps>;
2701bdd1243dSDimitry Andric  }
270281ad6265SDimitry Andric
2703*06c3fb27SDimitry Andric  if ps.FPAtomic then {
270481ad6265SDimitry Andric    def _gfx90a : MUBUF_Real_gfx90a<op, ps, 0> {
270581ad6265SDimitry Andric      let SubtargetPredicate = isGFX90AOnly;
270681ad6265SDimitry Andric      let AssemblerPredicate = isGFX90AOnly;
270781ad6265SDimitry Andric    }
270881ad6265SDimitry Andric    def _gfx940 : MUBUF_Real_gfx940<op, ps>;
270981ad6265SDimitry Andric  }
2710fe6060f1SDimitry Andric}
2711fe6060f1SDimitry Andric
2712bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_Helper_vi<bits<7> op, bit isTFE = 0> {
2713bdd1243dSDimitry Andric  defm _OFFSET : MUBUF_Real_vi_gfx90a <op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET"), isTFE>;
2714bdd1243dSDimitry Andric  defm _OFFEN  : MUBUF_Real_vi_gfx90a <op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN"), isTFE>;
2715bdd1243dSDimitry Andric  defm _IDXEN  : MUBUF_Real_vi_gfx90a <op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN"), isTFE>;
2716bdd1243dSDimitry Andric  defm _BOTHEN : MUBUF_Real_vi_gfx90a <op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN"), isTFE>;
27170b57cec5SDimitry Andric}
27180b57cec5SDimitry Andric
2719bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_vi<bits<7> op, bit hasTFE = 1> {
2720bdd1243dSDimitry Andric  defm NAME : MUBUF_Real_AllAddr_Helper_vi<op>;
2721bdd1243dSDimitry Andric  if hasTFE then
2722bdd1243dSDimitry Andric    defm _TFE : MUBUF_Real_AllAddr_Helper_vi<op, 1>;
2723bdd1243dSDimitry Andric}
27240b57cec5SDimitry Andric
2725bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_Lds_Helper_vi<bits<7> op, bit isTFE = 0> {
272681ad6265SDimitry Andric  def _OFFSET_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>;
272781ad6265SDimitry Andric  def _OFFEN_vi  : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>;
272881ad6265SDimitry Andric  def _IDXEN_vi  : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>;
272981ad6265SDimitry Andric  def _BOTHEN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>;
27300b57cec5SDimitry Andric
2731bdd1243dSDimitry Andric  if !not(isTFE) then {
273281ad6265SDimitry Andric    def _LDS_OFFSET_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_OFFSET")>;
273381ad6265SDimitry Andric    def _LDS_OFFEN_vi  : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_OFFEN")>;
273481ad6265SDimitry Andric    def _LDS_IDXEN_vi  : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_IDXEN")>;
273581ad6265SDimitry Andric    def _LDS_BOTHEN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_BOTHEN")>;
2736fe6060f1SDimitry Andric
273781ad6265SDimitry Andric    def _OFFSET_gfx90a : MUBUF_Real_gfx90a <op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>;
273881ad6265SDimitry Andric    def _OFFEN_gfx90a  : MUBUF_Real_gfx90a <op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>;
273981ad6265SDimitry Andric    def _IDXEN_gfx90a  : MUBUF_Real_gfx90a <op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>;
274081ad6265SDimitry Andric    def _BOTHEN_gfx90a : MUBUF_Real_gfx90a <op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>;
2741fe6060f1SDimitry Andric
274281ad6265SDimitry Andric    def _LDS_OFFSET_gfx90a : MUBUF_Real_gfx90a <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_OFFSET")>;
274381ad6265SDimitry Andric    def _LDS_OFFEN_gfx90a  : MUBUF_Real_gfx90a <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_OFFEN")>;
274481ad6265SDimitry Andric    def _LDS_IDXEN_gfx90a  : MUBUF_Real_gfx90a <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_IDXEN")>;
274581ad6265SDimitry Andric    def _LDS_BOTHEN_gfx90a : MUBUF_Real_gfx90a <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_BOTHEN")>;
27460b57cec5SDimitry Andric  }
2747bdd1243dSDimitry Andric}
2748bdd1243dSDimitry Andric
2749bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_Lds_vi<bits<7> op> {
2750bdd1243dSDimitry Andric  defm NAME : MUBUF_Real_AllAddr_Lds_Helper_vi<op>;
2751bdd1243dSDimitry Andric  defm _TFE : MUBUF_Real_AllAddr_Lds_Helper_vi<op, 1>;
2752bdd1243dSDimitry Andric}
27530b57cec5SDimitry Andric
27540b57cec5SDimitry Andricclass MUBUF_Real_gfx80 <bits<7> op, MUBUF_Pseudo ps> :
27550b57cec5SDimitry Andric  MUBUF_Real<ps>,
27560b57cec5SDimitry Andric  Enc64,
27570b57cec5SDimitry Andric  SIMCInstr<ps.PseudoInstr, SIEncodingFamily.GFX80> {
27580b57cec5SDimitry Andric  let AssemblerPredicate=HasUnpackedD16VMem;
27590b57cec5SDimitry Andric  let DecoderNamespace="GFX80_UNPACKED";
27600b57cec5SDimitry Andric
27610b57cec5SDimitry Andric  let Inst{11-0}  = !if(ps.has_offset, offset, ?);
27620b57cec5SDimitry Andric  let Inst{12}    = ps.offen;
27630b57cec5SDimitry Andric  let Inst{13}    = ps.idxen;
2764fe6060f1SDimitry Andric  let Inst{14}    = !if(ps.has_glc, cpol{CPolBit.GLC}, ps.glc_value);
2765e8d8bef9SDimitry Andric  let Inst{16}    = ps.lds;
2766fe6060f1SDimitry Andric  let Inst{17}    = !if(ps.has_slc, cpol{CPolBit.SLC}, ?);
27670b57cec5SDimitry Andric  let Inst{24-18} = op;
27680b57cec5SDimitry Andric  let Inst{31-26} = 0x38; //encoding
27690b57cec5SDimitry Andric  let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?);
2770fe6060f1SDimitry Andric  let Inst{47-40} = !if(ps.has_vdata, vdata{7-0}, ?);
27710b57cec5SDimitry Andric  let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?);
2772bdd1243dSDimitry Andric  let Inst{55}    = ps.tfe;
27730b57cec5SDimitry Andric  let Inst{63-56} = !if(ps.has_soffset, soffset, ?);
27740b57cec5SDimitry Andric}
27750b57cec5SDimitry Andric
2776bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_Helper_gfx80<bits<7> op> {
27770b57cec5SDimitry Andric  def _OFFSET_gfx80 : MUBUF_Real_gfx80 <op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>;
27780b57cec5SDimitry Andric  def _OFFEN_gfx80  : MUBUF_Real_gfx80 <op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>;
27790b57cec5SDimitry Andric  def _IDXEN_gfx80  : MUBUF_Real_gfx80 <op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>;
27800b57cec5SDimitry Andric  def _BOTHEN_gfx80 : MUBUF_Real_gfx80 <op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>;
27810b57cec5SDimitry Andric}
27820b57cec5SDimitry Andric
2783bdd1243dSDimitry Andricmulticlass MUBUF_Real_AllAddr_gfx80<bits<7> op> {
2784bdd1243dSDimitry Andric  defm NAME : MUBUF_Real_AllAddr_Helper_gfx80<op>;
2785bdd1243dSDimitry Andric  defm _TFE : MUBUF_Real_AllAddr_Helper_gfx80<op>;
2786bdd1243dSDimitry Andric}
2787bdd1243dSDimitry Andric
27880b57cec5SDimitry Andricmulticlass MUBUF_Real_Atomic_vi<bits<7> op> :
2789bdd1243dSDimitry Andric  MUBUF_Real_AllAddr_vi<op, 0> {
2790fe6060f1SDimitry Andric  defm _OFFSET_RTN : MUBUF_Real_vi_gfx90a <op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET_RTN")>;
2791fe6060f1SDimitry Andric  defm _OFFEN_RTN  : MUBUF_Real_vi_gfx90a <op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN_RTN")>;
2792fe6060f1SDimitry Andric  defm _IDXEN_RTN  : MUBUF_Real_vi_gfx90a <op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN_RTN")>;
2793fe6060f1SDimitry Andric  defm _BOTHEN_RTN : MUBUF_Real_vi_gfx90a <op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN_RTN")>;
27940b57cec5SDimitry Andric}
27950b57cec5SDimitry Andric
27960b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_X       : MUBUF_Real_AllAddr_Lds_vi <0x00>;
27970b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XY      : MUBUF_Real_AllAddr_vi <0x01>;
27980b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZ     : MUBUF_Real_AllAddr_vi <0x02>;
27990b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZW    : MUBUF_Real_AllAddr_vi <0x03>;
28000b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_X      : MUBUF_Real_AllAddr_vi <0x04>;
28010b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XY     : MUBUF_Real_AllAddr_vi <0x05>;
28020b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZ    : MUBUF_Real_AllAddr_vi <0x06>;
28030b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZW   : MUBUF_Real_AllAddr_vi <0x07>;
28040b57cec5SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem in {
28050b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_X_gfx80       : MUBUF_Real_AllAddr_gfx80 <0x08>;
28060b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XY_gfx80      : MUBUF_Real_AllAddr_gfx80 <0x09>;
28070b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XYZ_gfx80     : MUBUF_Real_AllAddr_gfx80 <0x0a>;
28080b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XYZW_gfx80    : MUBUF_Real_AllAddr_gfx80 <0x0b>;
28090b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_X_gfx80      : MUBUF_Real_AllAddr_gfx80 <0x0c>;
28100b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XY_gfx80     : MUBUF_Real_AllAddr_gfx80 <0x0d>;
28110b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XYZ_gfx80    : MUBUF_Real_AllAddr_gfx80 <0x0e>;
28120b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XYZW_gfx80   : MUBUF_Real_AllAddr_gfx80 <0x0f>;
28130b57cec5SDimitry Andric} // End HasUnpackedD16VMem.
28140b57cec5SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem in {
28150b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_X       : MUBUF_Real_AllAddr_vi <0x08>;
28160b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XY      : MUBUF_Real_AllAddr_vi <0x09>;
28170b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XYZ     : MUBUF_Real_AllAddr_vi <0x0a>;
28180b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XYZW    : MUBUF_Real_AllAddr_vi <0x0b>;
28190b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_X      : MUBUF_Real_AllAddr_vi <0x0c>;
28200b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XY     : MUBUF_Real_AllAddr_vi <0x0d>;
28210b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XYZ    : MUBUF_Real_AllAddr_vi <0x0e>;
28220b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XYZW   : MUBUF_Real_AllAddr_vi <0x0f>;
28230b57cec5SDimitry Andric} // End HasPackedD16VMem.
28240b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE          : MUBUF_Real_AllAddr_Lds_vi <0x10>;
28250b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE          : MUBUF_Real_AllAddr_Lds_vi <0x11>;
28260b57cec5SDimitry Andricdefm BUFFER_LOAD_USHORT         : MUBUF_Real_AllAddr_Lds_vi <0x12>;
28270b57cec5SDimitry Andricdefm BUFFER_LOAD_SSHORT         : MUBUF_Real_AllAddr_Lds_vi <0x13>;
28280b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORD          : MUBUF_Real_AllAddr_Lds_vi <0x14>;
282981ad6265SDimitry Andricdefm BUFFER_LOAD_DWORDX2        : MUBUF_Real_AllAddr_vi <0x15>;
283081ad6265SDimitry Andricdefm BUFFER_LOAD_DWORDX3        : MUBUF_Real_AllAddr_vi <0x16>;
283181ad6265SDimitry Andricdefm BUFFER_LOAD_DWORDX4        : MUBUF_Real_AllAddr_vi <0x17>;
28320b57cec5SDimitry Andricdefm BUFFER_STORE_BYTE          : MUBUF_Real_AllAddr_vi <0x18>;
28330b57cec5SDimitry Andricdefm BUFFER_STORE_BYTE_D16_HI   : MUBUF_Real_AllAddr_vi <0x19>;
28340b57cec5SDimitry Andricdefm BUFFER_STORE_SHORT         : MUBUF_Real_AllAddr_vi <0x1a>;
28350b57cec5SDimitry Andricdefm BUFFER_STORE_SHORT_D16_HI  : MUBUF_Real_AllAddr_vi <0x1b>;
28360b57cec5SDimitry Andricdefm BUFFER_STORE_DWORD         : MUBUF_Real_AllAddr_vi <0x1c>;
28370b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX2       : MUBUF_Real_AllAddr_vi <0x1d>;
28380b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX3       : MUBUF_Real_AllAddr_vi <0x1e>;
28390b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX4       : MUBUF_Real_AllAddr_vi <0x1f>;
28400b57cec5SDimitry Andric
28410b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16      : MUBUF_Real_AllAddr_vi <0x20>;
28420b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16_HI   : MUBUF_Real_AllAddr_vi <0x21>;
28430b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16      : MUBUF_Real_AllAddr_vi <0x22>;
28440b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16_HI   : MUBUF_Real_AllAddr_vi <0x23>;
28450b57cec5SDimitry Andricdefm BUFFER_LOAD_SHORT_D16      : MUBUF_Real_AllAddr_vi <0x24>;
28460b57cec5SDimitry Andricdefm BUFFER_LOAD_SHORT_D16_HI   : MUBUF_Real_AllAddr_vi <0x25>;
28470b57cec5SDimitry Andric
28480b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_HI_X  : MUBUF_Real_AllAddr_vi <0x26>;
28490b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_HI_X : MUBUF_Real_AllAddr_vi <0x27>;
28500b57cec5SDimitry Andric
28510b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SWAP         : MUBUF_Real_Atomic_vi <0x40>;
28520b57cec5SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP      : MUBUF_Real_Atomic_vi <0x41>;
28530b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD          : MUBUF_Real_Atomic_vi <0x42>;
28540b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SUB          : MUBUF_Real_Atomic_vi <0x43>;
28550b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMIN         : MUBUF_Real_Atomic_vi <0x44>;
28560b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMIN         : MUBUF_Real_Atomic_vi <0x45>;
28570b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMAX         : MUBUF_Real_Atomic_vi <0x46>;
28580b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMAX         : MUBUF_Real_Atomic_vi <0x47>;
28590b57cec5SDimitry Andricdefm BUFFER_ATOMIC_AND          : MUBUF_Real_Atomic_vi <0x48>;
28600b57cec5SDimitry Andricdefm BUFFER_ATOMIC_OR           : MUBUF_Real_Atomic_vi <0x49>;
28610b57cec5SDimitry Andricdefm BUFFER_ATOMIC_XOR          : MUBUF_Real_Atomic_vi <0x4a>;
28620b57cec5SDimitry Andricdefm BUFFER_ATOMIC_INC          : MUBUF_Real_Atomic_vi <0x4b>;
28630b57cec5SDimitry Andricdefm BUFFER_ATOMIC_DEC          : MUBUF_Real_Atomic_vi <0x4c>;
28640b57cec5SDimitry Andric
28650b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SWAP_X2      : MUBUF_Real_Atomic_vi <0x60>;
28660b57cec5SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP_X2   : MUBUF_Real_Atomic_vi <0x61>;
28670b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD_X2       : MUBUF_Real_Atomic_vi <0x62>;
28680b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SUB_X2       : MUBUF_Real_Atomic_vi <0x63>;
28690b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMIN_X2      : MUBUF_Real_Atomic_vi <0x64>;
28700b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMIN_X2      : MUBUF_Real_Atomic_vi <0x65>;
28710b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMAX_X2      : MUBUF_Real_Atomic_vi <0x66>;
28720b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMAX_X2      : MUBUF_Real_Atomic_vi <0x67>;
28730b57cec5SDimitry Andricdefm BUFFER_ATOMIC_AND_X2       : MUBUF_Real_Atomic_vi <0x68>;
28740b57cec5SDimitry Andricdefm BUFFER_ATOMIC_OR_X2        : MUBUF_Real_Atomic_vi <0x69>;
28750b57cec5SDimitry Andricdefm BUFFER_ATOMIC_XOR_X2       : MUBUF_Real_Atomic_vi <0x6a>;
28760b57cec5SDimitry Andricdefm BUFFER_ATOMIC_INC_X2       : MUBUF_Real_Atomic_vi <0x6b>;
28770b57cec5SDimitry Andricdefm BUFFER_ATOMIC_DEC_X2       : MUBUF_Real_Atomic_vi <0x6c>;
28780b57cec5SDimitry Andric
2879fe6060f1SDimitry Andricdefm BUFFER_STORE_LDS_DWORD     : MUBUF_Real_vi_gfx90a <0x3d, BUFFER_STORE_LDS_DWORD>;
28800b57cec5SDimitry Andric
2881fe6060f1SDimitry Andriclet AssemblerPredicate = isGFX8GFX9 in {
28820b57cec5SDimitry Andricdef BUFFER_WBINVL1_vi           : MUBUF_Real_vi <0x3e, BUFFER_WBINVL1>;
28830b57cec5SDimitry Andricdef BUFFER_WBINVL1_VOL_vi       : MUBUF_Real_vi <0x3f, BUFFER_WBINVL1_VOL>;
2884fe6060f1SDimitry Andric} // End AssemblerPredicate = isGFX8GFX9
28850b57cec5SDimitry Andric
28860b57cec5SDimitry Andric
2887fe6060f1SDimitry Andricdefm BUFFER_ATOMIC_PK_ADD_F16 : MUBUF_Real_Atomic_vi <0x4e>;
28880b57cec5SDimitry Andric
2889*06c3fb27SDimitry Andriclet SubtargetPredicate = HasAtomicFaddNoRtnInsts in {
2890*06c3fb27SDimitry Andricdefm BUFFER_ATOMIC_ADD_F32    : MUBUF_Real_Atomic_vi <0x4d>;
289181ad6265SDimitry Andric} // End SubtargetPredicate = HasAtomicFaddNoRtnInsts
28920b57cec5SDimitry Andric
2893fe6060f1SDimitry Andriclet SubtargetPredicate = isGFX90APlus in {
2894fe6060f1SDimitry Andric  defm BUFFER_ATOMIC_ADD_F64 : MUBUF_Real_Atomic_vi<0x4f>;
2895fe6060f1SDimitry Andric  defm BUFFER_ATOMIC_MIN_F64 : MUBUF_Real_Atomic_vi<0x50>;
2896fe6060f1SDimitry Andric  defm BUFFER_ATOMIC_MAX_F64 : MUBUF_Real_Atomic_vi<0x51>;
2897fe6060f1SDimitry Andric} // End SubtargetPredicate = isGFX90APlus, AssemblerPredicate = isGFX90APlus
2898fe6060f1SDimitry Andric
2899fe6060f1SDimitry Andricdef BUFFER_WBL2_gfx90a  : MUBUF_Real_gfx90a<0x28, BUFFER_WBL2> {
290081ad6265SDimitry Andric  let AsmString = BUFFER_WBL2.Mnemonic; // drop flags
290181ad6265SDimitry Andric  let AssemblerPredicate = isGFX90AOnly;
290281ad6265SDimitry Andric  let SubtargetPredicate = isGFX90AOnly;
2903fe6060f1SDimitry Andric}
2904fe6060f1SDimitry Andricdef BUFFER_INVL2_gfx90a : MUBUF_Real_gfx90a<0x29, BUFFER_INVL2>;
2905fe6060f1SDimitry Andric
290681ad6265SDimitry Andriclet SubtargetPredicate = isGFX940Plus in {
290781ad6265SDimitry Andricdef BUFFER_WBL2_gfx940  : MUBUF_Real_gfx940<0x28, BUFFER_WBL2>;
290881ad6265SDimitry Andricdef BUFFER_INV_gfx940   : MUBUF_Real_gfx940<0x29, BUFFER_INV>;
290981ad6265SDimitry Andric}
291081ad6265SDimitry Andric
2911fe6060f1SDimitry Andricclass MTBUF_Real_Base_vi <bits<4> op, MTBUF_Pseudo ps, int Enc> :
29120b57cec5SDimitry Andric  MTBUF_Real<ps>,
29130b57cec5SDimitry Andric  Enc64,
2914fe6060f1SDimitry Andric  SIMCInstr<ps.PseudoInstr, Enc> {
29150b57cec5SDimitry Andric
29160b57cec5SDimitry Andric  let Inst{11-0}  = !if(ps.has_offset, offset, ?);
29170b57cec5SDimitry Andric  let Inst{12}    = ps.offen;
29180b57cec5SDimitry Andric  let Inst{13}    = ps.idxen;
2919fe6060f1SDimitry Andric  let Inst{14}    = !if(ps.has_glc, cpol{CPolBit.GLC}, ps.glc_value);
29200b57cec5SDimitry Andric  let Inst{18-15} = op;
29210b57cec5SDimitry Andric  let Inst{22-19} = dfmt;
29220b57cec5SDimitry Andric  let Inst{25-23} = nfmt;
29230b57cec5SDimitry Andric  let Inst{31-26} = 0x3a; //encoding
29240b57cec5SDimitry Andric  let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?);
2925fe6060f1SDimitry Andric  let Inst{47-40} = !if(ps.has_vdata, vdata{7-0}, ?);
29260b57cec5SDimitry Andric  let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?);
2927fe6060f1SDimitry Andric  let Inst{53}    = !if(ps.has_sccb, cpol{CPolBit.SCC}, ps.sccb_value);
2928fe6060f1SDimitry Andric  let Inst{54}    = !if(ps.has_slc, cpol{CPolBit.SLC}, ?);
2929bdd1243dSDimitry Andric  let Inst{55}    = ps.tfe;
29300b57cec5SDimitry Andric  let Inst{63-56} = !if(ps.has_soffset, soffset, ?);
29310b57cec5SDimitry Andric}
29320b57cec5SDimitry Andric
2933fe6060f1SDimitry Andricclass MTBUF_Real_vi <bits<4> op, MTBUF_Pseudo ps> :
2934fe6060f1SDimitry Andric  MTBUF_Real_Base_vi <op, ps, SIEncodingFamily.VI> {
2935fe6060f1SDimitry Andric  let AssemblerPredicate = isGFX8GFX9NotGFX90A;
2936fe6060f1SDimitry Andric  let DecoderNamespace = "GFX8";
2937fe6060f1SDimitry Andric
2938bdd1243dSDimitry Andric  let Inst{55}    = ps.tfe;
2939fe6060f1SDimitry Andric}
2940fe6060f1SDimitry Andric
2941fe6060f1SDimitry Andricclass MTBUF_Real_gfx90a <bits<4> op, MTBUF_Pseudo ps> :
2942fe6060f1SDimitry Andric  MTBUF_Real_Base_vi <op, ps, SIEncodingFamily.GFX90A> {
2943fe6060f1SDimitry Andric  let AssemblerPredicate = isGFX90APlus;
2944fe6060f1SDimitry Andric  let DecoderNamespace = "GFX90A";
2945bdd1243dSDimitry Andric  let AsmString = ps.Mnemonic # ps.AsmOperands;
2946fe6060f1SDimitry Andric
2947fe6060f1SDimitry Andric  let Inst{55}    = acc;
2948fe6060f1SDimitry Andric}
2949fe6060f1SDimitry Andric
2950fe6060f1SDimitry Andricmulticlass MTBUF_Real_vi_gfx90a<bits<4> op, MTBUF_Pseudo ps> {
2951fe6060f1SDimitry Andric  def _vi :     MTBUF_Real_vi<op, ps>;
2952fe6060f1SDimitry Andric  def _gfx90a : MTBUF_Real_gfx90a<op, ps>;
2953fe6060f1SDimitry Andric}
2954fe6060f1SDimitry Andric
29550b57cec5SDimitry Andricmulticlass MTBUF_Real_AllAddr_vi<bits<4> op> {
2956fe6060f1SDimitry Andric  defm _OFFSET : MTBUF_Real_vi_gfx90a <op, !cast<MTBUF_Pseudo>(NAME#"_OFFSET")>;
2957fe6060f1SDimitry Andric  defm _OFFEN  : MTBUF_Real_vi_gfx90a <op, !cast<MTBUF_Pseudo>(NAME#"_OFFEN")>;
2958fe6060f1SDimitry Andric  defm _IDXEN  : MTBUF_Real_vi_gfx90a <op, !cast<MTBUF_Pseudo>(NAME#"_IDXEN")>;
2959fe6060f1SDimitry Andric  defm _BOTHEN : MTBUF_Real_vi_gfx90a <op, !cast<MTBUF_Pseudo>(NAME#"_BOTHEN")>;
29600b57cec5SDimitry Andric}
29610b57cec5SDimitry Andric
29620b57cec5SDimitry Andricclass MTBUF_Real_gfx80 <bits<4> op, MTBUF_Pseudo ps> :
29630b57cec5SDimitry Andric  MTBUF_Real<ps>,
29640b57cec5SDimitry Andric  Enc64,
29650b57cec5SDimitry Andric  SIMCInstr<ps.PseudoInstr, SIEncodingFamily.GFX80> {
29660b57cec5SDimitry Andric  let AssemblerPredicate=HasUnpackedD16VMem;
29670b57cec5SDimitry Andric  let DecoderNamespace="GFX80_UNPACKED";
29680b57cec5SDimitry Andric
29690b57cec5SDimitry Andric  let Inst{11-0}  = !if(ps.has_offset, offset, ?);
29700b57cec5SDimitry Andric  let Inst{12}    = ps.offen;
29710b57cec5SDimitry Andric  let Inst{13}    = ps.idxen;
2972fe6060f1SDimitry Andric  let Inst{14}    = !if(ps.has_glc, cpol{CPolBit.GLC}, ps.glc_value);
29730b57cec5SDimitry Andric  let Inst{18-15} = op;
29740b57cec5SDimitry Andric  let Inst{22-19} = dfmt;
29750b57cec5SDimitry Andric  let Inst{25-23} = nfmt;
29760b57cec5SDimitry Andric  let Inst{31-26} = 0x3a; //encoding
29770b57cec5SDimitry Andric  let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?);
2978fe6060f1SDimitry Andric  let Inst{47-40} = !if(ps.has_vdata, vdata{7-0}, ?);
29790b57cec5SDimitry Andric  let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?);
2980fe6060f1SDimitry Andric  let Inst{54}    = !if(ps.has_slc, cpol{CPolBit.SLC}, ?);
2981bdd1243dSDimitry Andric  let Inst{55}    = ps.tfe;
29820b57cec5SDimitry Andric  let Inst{63-56} = !if(ps.has_soffset, soffset, ?);
29830b57cec5SDimitry Andric}
29840b57cec5SDimitry Andric
29850b57cec5SDimitry Andricmulticlass MTBUF_Real_AllAddr_gfx80<bits<4> op> {
29860b57cec5SDimitry Andric  def _OFFSET_gfx80 : MTBUF_Real_gfx80 <op, !cast<MTBUF_Pseudo>(NAME#"_OFFSET")>;
29870b57cec5SDimitry Andric  def _OFFEN_gfx80  : MTBUF_Real_gfx80 <op, !cast<MTBUF_Pseudo>(NAME#"_OFFEN")>;
29880b57cec5SDimitry Andric  def _IDXEN_gfx80  : MTBUF_Real_gfx80 <op, !cast<MTBUF_Pseudo>(NAME#"_IDXEN")>;
29890b57cec5SDimitry Andric  def _BOTHEN_gfx80 : MTBUF_Real_gfx80 <op, !cast<MTBUF_Pseudo>(NAME#"_BOTHEN")>;
29900b57cec5SDimitry Andric}
29910b57cec5SDimitry Andric
29920b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_X     : MTBUF_Real_AllAddr_vi <0x00>;
29930b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XY    : MTBUF_Real_AllAddr_vi <0x01>;
29940b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZ   : MTBUF_Real_AllAddr_vi <0x02>;
29950b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZW  : MTBUF_Real_AllAddr_vi <0x03>;
29960b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_X    : MTBUF_Real_AllAddr_vi <0x04>;
29970b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_XY   : MTBUF_Real_AllAddr_vi <0x05>;
29980b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZ  : MTBUF_Real_AllAddr_vi <0x06>;
29990b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZW : MTBUF_Real_AllAddr_vi <0x07>;
30000b57cec5SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem in {
30010b57cec5SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_X_gfx80     : MTBUF_Real_AllAddr_gfx80 <0x08>;
30020b57cec5SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XY_gfx80    : MTBUF_Real_AllAddr_gfx80 <0x09>;
30030b57cec5SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XYZ_gfx80   : MTBUF_Real_AllAddr_gfx80 <0x0a>;
30040b57cec5SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XYZW_gfx80  : MTBUF_Real_AllAddr_gfx80 <0x0b>;
30050b57cec5SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_X_gfx80    : MTBUF_Real_AllAddr_gfx80 <0x0c>;
30060b57cec5SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XY_gfx80   : MTBUF_Real_AllAddr_gfx80 <0x0d>;
30070b57cec5SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XYZ_gfx80  : MTBUF_Real_AllAddr_gfx80 <0x0e>;
30080b57cec5SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XYZW_gfx80 : MTBUF_Real_AllAddr_gfx80 <0x0f>;
30090b57cec5SDimitry Andric} // End HasUnpackedD16VMem.
30100b57cec5SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem in {
30110b57cec5SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_X     : MTBUF_Real_AllAddr_vi <0x08>;
30120b57cec5SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XY    : MTBUF_Real_AllAddr_vi <0x09>;
30130b57cec5SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XYZ   : MTBUF_Real_AllAddr_vi <0x0a>;
30140b57cec5SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XYZW  : MTBUF_Real_AllAddr_vi <0x0b>;
30150b57cec5SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_X    : MTBUF_Real_AllAddr_vi <0x0c>;
30160b57cec5SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XY   : MTBUF_Real_AllAddr_vi <0x0d>;
30170b57cec5SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XYZ  : MTBUF_Real_AllAddr_vi <0x0e>;
30180b57cec5SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XYZW : MTBUF_Real_AllAddr_vi <0x0f>;
30190b57cec5SDimitry Andric} // End HasUnpackedD16VMem.
30200b57cec5SDimitry Andric
30210b57cec5SDimitry Andricdef MUBUFInfoTable : GenericTable {
30220b57cec5SDimitry Andric  let FilterClass = "MUBUF_Pseudo";
30230b57cec5SDimitry Andric  let CppTypeName = "MUBUFInfo";
3024fe6060f1SDimitry Andric  let Fields = [
3025fe6060f1SDimitry Andric    "Opcode", "BaseOpcode", "elements", "has_vaddr", "has_srsrc", "has_soffset",
3026fe6060f1SDimitry Andric    "IsBufferInv"
3027fe6060f1SDimitry Andric  ];
30280b57cec5SDimitry Andric
30290b57cec5SDimitry Andric  let PrimaryKey = ["Opcode"];
30300b57cec5SDimitry Andric  let PrimaryKeyName = "getMUBUFOpcodeHelper";
30310b57cec5SDimitry Andric}
30320b57cec5SDimitry Andric
30330b57cec5SDimitry Andricdef getMUBUFInfoFromOpcode : SearchIndex {
30340b57cec5SDimitry Andric  let Table = MUBUFInfoTable;
30350b57cec5SDimitry Andric  let Key = ["Opcode"];
30360b57cec5SDimitry Andric}
30370b57cec5SDimitry Andric
30388bcb0991SDimitry Andricdef getMUBUFInfoFromBaseOpcodeAndElements : SearchIndex {
30390b57cec5SDimitry Andric  let Table = MUBUFInfoTable;
30408bcb0991SDimitry Andric  let Key = ["BaseOpcode", "elements"];
30418bcb0991SDimitry Andric}
30428bcb0991SDimitry Andric
30438bcb0991SDimitry Andricdef MTBUFInfoTable : GenericTable {
30448bcb0991SDimitry Andric  let FilterClass = "MTBUF_Pseudo";
30458bcb0991SDimitry Andric  let CppTypeName = "MTBUFInfo";
30468bcb0991SDimitry Andric  let Fields = ["Opcode", "BaseOpcode", "elements", "has_vaddr", "has_srsrc", "has_soffset"];
30478bcb0991SDimitry Andric
30488bcb0991SDimitry Andric  let PrimaryKey = ["Opcode"];
30498bcb0991SDimitry Andric  let PrimaryKeyName = "getMTBUFOpcodeHelper";
30508bcb0991SDimitry Andric}
30518bcb0991SDimitry Andric
30528bcb0991SDimitry Andricdef getMTBUFInfoFromOpcode : SearchIndex {
30538bcb0991SDimitry Andric  let Table = MTBUFInfoTable;
30548bcb0991SDimitry Andric  let Key = ["Opcode"];
30558bcb0991SDimitry Andric}
30568bcb0991SDimitry Andric
30578bcb0991SDimitry Andricdef getMTBUFInfoFromBaseOpcodeAndElements : SearchIndex {
30588bcb0991SDimitry Andric  let Table = MTBUFInfoTable;
30598bcb0991SDimitry Andric  let Key = ["BaseOpcode", "elements"];
30600b57cec5SDimitry Andric}
3061