xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/BUFInstructions.td (revision 5ffd83dbcc34f10e07f6d3e968ae6365869615f4)
1*5ffd83dbSDimitry 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
90b57cec5SDimitry Andricdef MUBUFAddr32 : ComplexPattern<i64, 9, "SelectMUBUFAddr32">;
108bcb0991SDimitry Andricdef MUBUFAddr64 : ComplexPattern<i64, 9, "SelectMUBUFAddr64">;
110b57cec5SDimitry Andricdef MUBUFAddr64Atomic : ComplexPattern<i64, 5, "SelectMUBUFAddr64">;
120b57cec5SDimitry Andric
130b57cec5SDimitry Andricdef MUBUFScratchOffen : ComplexPattern<i64, 4, "SelectMUBUFScratchOffen", [], [SDNPWantParent]>;
140b57cec5SDimitry Andricdef MUBUFScratchOffset : ComplexPattern<i64, 3, "SelectMUBUFScratchOffset", [], [SDNPWantParent], 20>;
150b57cec5SDimitry Andric
168bcb0991SDimitry Andricdef MUBUFOffset : ComplexPattern<i64, 8, "SelectMUBUFOffset">;
170b57cec5SDimitry Andricdef MUBUFOffsetNoGLC : ComplexPattern<i64, 3, "SelectMUBUFOffset">;
180b57cec5SDimitry Andricdef MUBUFOffsetAtomic : ComplexPattern<i64, 4, "SelectMUBUFOffset">;
190b57cec5SDimitry Andric
200b57cec5SDimitry Andricdef BUFAddrKind {
210b57cec5SDimitry Andric  int Offset = 0;
220b57cec5SDimitry Andric  int OffEn  = 1;
230b57cec5SDimitry Andric  int IdxEn  = 2;
240b57cec5SDimitry Andric  int BothEn = 3;
250b57cec5SDimitry Andric  int Addr64 = 4;
260b57cec5SDimitry Andric}
270b57cec5SDimitry Andric
280b57cec5SDimitry Andricclass getAddrName<int addrKind> {
290b57cec5SDimitry Andric  string ret =
300b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Offset), "offset",
310b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.OffEn),  "offen",
320b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.IdxEn),  "idxen",
330b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.BothEn), "bothen",
340b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Addr64), "addr64",
350b57cec5SDimitry Andric    "")))));
360b57cec5SDimitry Andric}
370b57cec5SDimitry Andric
380b57cec5SDimitry Andricclass MUBUFAddr64Table <bit is_addr64, string Name> {
390b57cec5SDimitry Andric  bit IsAddr64 = is_addr64;
400b57cec5SDimitry Andric  string OpName = Name;
410b57cec5SDimitry Andric}
420b57cec5SDimitry Andric
430b57cec5SDimitry Andricclass MUBUFLdsTable <bit is_lds, string Name> {
440b57cec5SDimitry Andric  bit IsLds = is_lds;
450b57cec5SDimitry Andric  string OpName = Name;
460b57cec5SDimitry Andric}
470b57cec5SDimitry Andric
480b57cec5SDimitry Andricclass MTBUFAddr64Table <bit is_addr64, string Name> {
490b57cec5SDimitry Andric  bit IsAddr64 = is_addr64;
500b57cec5SDimitry Andric  string OpName = Name;
510b57cec5SDimitry Andric}
520b57cec5SDimitry Andric
530b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
540b57cec5SDimitry Andric// MTBUF classes
550b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
560b57cec5SDimitry Andric
578bcb0991SDimitry Andricclass MTBUFGetBaseOpcode<string Op> {
588bcb0991SDimitry Andric  string ret = !subst("FORMAT_XY", "FORMAT_X",
598bcb0991SDimitry Andric    !subst("FORMAT_XYZ", "FORMAT_X",
608bcb0991SDimitry Andric    !subst("FORMAT_XYZW", "FORMAT_X", Op)));
618bcb0991SDimitry Andric}
628bcb0991SDimitry Andric
638bcb0991SDimitry Andricclass getMTBUFElements<string Op> {
648bcb0991SDimitry Andric  int ret = 1;
658bcb0991SDimitry Andric}
668bcb0991SDimitry Andric
678bcb0991SDimitry Andric
680b57cec5SDimitry Andricclass MTBUF_Pseudo <string opName, dag outs, dag ins,
690b57cec5SDimitry Andric                    string asmOps, list<dag> pattern=[]> :
700b57cec5SDimitry Andric  InstSI<outs, ins, "", pattern>,
710b57cec5SDimitry Andric  SIMCInstr<opName, SIEncodingFamily.NONE> {
720b57cec5SDimitry Andric
730b57cec5SDimitry Andric  let isPseudo = 1;
740b57cec5SDimitry Andric  let isCodeGenOnly = 1;
750b57cec5SDimitry Andric  let Size = 8;
760b57cec5SDimitry Andric  let UseNamedOperandTable = 1;
770b57cec5SDimitry Andric
780b57cec5SDimitry Andric  string Mnemonic = opName;
790b57cec5SDimitry Andric  string AsmOperands = asmOps;
800b57cec5SDimitry Andric
818bcb0991SDimitry Andric  Instruction Opcode = !cast<Instruction>(NAME);
828bcb0991SDimitry Andric  Instruction BaseOpcode = !cast<Instruction>(MTBUFGetBaseOpcode<NAME>.ret);
838bcb0991SDimitry Andric
840b57cec5SDimitry Andric  let VM_CNT = 1;
850b57cec5SDimitry Andric  let EXP_CNT = 1;
860b57cec5SDimitry Andric  let MTBUF = 1;
870b57cec5SDimitry Andric  let Uses = [EXEC];
880b57cec5SDimitry Andric  let hasSideEffects = 0;
890b57cec5SDimitry Andric  let SchedRW = [WriteVMEM];
900b57cec5SDimitry Andric
910b57cec5SDimitry Andric  let AsmMatchConverter = "cvtMtbuf";
920b57cec5SDimitry Andric
930b57cec5SDimitry Andric  bits<1> offen       = 0;
940b57cec5SDimitry Andric  bits<1> idxen       = 0;
950b57cec5SDimitry Andric  bits<1> addr64      = 0;
960b57cec5SDimitry Andric  bits<1> has_vdata   = 1;
970b57cec5SDimitry Andric  bits<1> has_vaddr   = 1;
980b57cec5SDimitry Andric  bits<1> has_glc     = 1;
990b57cec5SDimitry Andric  bits<1> has_dlc     = 1;
1000b57cec5SDimitry Andric  bits<1> glc_value   = 0; // the value for glc if no such operand
1010b57cec5SDimitry Andric  bits<1> dlc_value   = 0; // the value for dlc if no such operand
1020b57cec5SDimitry Andric  bits<1> has_srsrc   = 1;
1030b57cec5SDimitry Andric  bits<1> has_soffset = 1;
1040b57cec5SDimitry Andric  bits<1> has_offset  = 1;
1050b57cec5SDimitry Andric  bits<1> has_slc     = 1;
1060b57cec5SDimitry Andric  bits<1> has_tfe     = 1;
1078bcb0991SDimitry Andric  bits<4> elements    = 0;
1080b57cec5SDimitry Andric}
1090b57cec5SDimitry Andric
1100b57cec5SDimitry Andricclass MTBUF_Real <MTBUF_Pseudo ps> :
1110b57cec5SDimitry Andric  InstSI <ps.OutOperandList, ps.InOperandList, ps.Mnemonic # ps.AsmOperands, []> {
1120b57cec5SDimitry Andric
1130b57cec5SDimitry Andric  let isPseudo = 0;
1140b57cec5SDimitry Andric  let isCodeGenOnly = 0;
1150b57cec5SDimitry Andric
1160b57cec5SDimitry Andric  // copy relevant pseudo op flags
1170b57cec5SDimitry Andric  let SubtargetPredicate = ps.SubtargetPredicate;
1180b57cec5SDimitry Andric  let AsmMatchConverter  = ps.AsmMatchConverter;
1190b57cec5SDimitry Andric  let Constraints        = ps.Constraints;
1200b57cec5SDimitry Andric  let DisableEncoding    = ps.DisableEncoding;
1210b57cec5SDimitry Andric  let TSFlags            = ps.TSFlags;
1220b57cec5SDimitry Andric
1230b57cec5SDimitry Andric  bits<12> offset;
1240b57cec5SDimitry Andric  bits<1>  glc;
1250b57cec5SDimitry Andric  bits<1>  dlc;
1260b57cec5SDimitry Andric  bits<7>  format;
1270b57cec5SDimitry Andric  bits<8>  vaddr;
1280b57cec5SDimitry Andric  bits<8>  vdata;
1290b57cec5SDimitry Andric  bits<7>  srsrc;
1300b57cec5SDimitry Andric  bits<1>  slc;
1310b57cec5SDimitry Andric  bits<1>  tfe;
1320b57cec5SDimitry Andric  bits<8>  soffset;
1330b57cec5SDimitry Andric
1340b57cec5SDimitry Andric  bits<4> dfmt = format{3-0};
1350b57cec5SDimitry Andric  bits<3> nfmt = format{6-4};
1360b57cec5SDimitry Andric}
1370b57cec5SDimitry Andric
1380b57cec5SDimitry Andricclass getMTBUFInsDA<list<RegisterClass> vdataList,
1390b57cec5SDimitry Andric                    list<RegisterClass> vaddrList=[]> {
1400b57cec5SDimitry Andric  RegisterClass vdataClass = !if(!empty(vdataList), ?, !head(vdataList));
1410b57cec5SDimitry Andric  RegisterClass vaddrClass = !if(!empty(vaddrList), ?, !head(vaddrList));
1420b57cec5SDimitry Andric  dag InsNoData = !if(!empty(vaddrList),
1430b57cec5SDimitry Andric    (ins                    SReg_128:$srsrc, SCSrc_b32:$soffset,
1448bcb0991SDimitry Andric         offset:$offset, FORMAT:$format, GLC:$glc, SLC:$slc, TFE:$tfe, DLC:$dlc, SWZ:$swz),
1450b57cec5SDimitry Andric    (ins vaddrClass:$vaddr, SReg_128:$srsrc, SCSrc_b32:$soffset,
1468bcb0991SDimitry Andric         offset:$offset, FORMAT:$format, GLC:$glc, SLC:$slc, TFE:$tfe, DLC:$dlc, SWZ:$swz)
1470b57cec5SDimitry Andric  );
1480b57cec5SDimitry Andric  dag InsData = !if(!empty(vaddrList),
1490b57cec5SDimitry Andric    (ins vdataClass:$vdata,                    SReg_128:$srsrc,
1500b57cec5SDimitry Andric         SCSrc_b32:$soffset, offset:$offset, FORMAT:$format, GLC:$glc,
1518bcb0991SDimitry Andric         SLC:$slc, TFE:$tfe, DLC:$dlc, SWZ:$swz),
1520b57cec5SDimitry Andric    (ins vdataClass:$vdata, vaddrClass:$vaddr, SReg_128:$srsrc,
1530b57cec5SDimitry Andric         SCSrc_b32:$soffset, offset:$offset, FORMAT:$format, GLC:$glc,
1548bcb0991SDimitry Andric         SLC:$slc, TFE:$tfe, DLC:$dlc, SWZ:$swz)
1550b57cec5SDimitry Andric  );
1560b57cec5SDimitry Andric  dag ret = !if(!empty(vdataList), InsNoData, InsData);
1570b57cec5SDimitry Andric}
1580b57cec5SDimitry Andric
1590b57cec5SDimitry Andricclass getMTBUFIns<int addrKind, list<RegisterClass> vdataList=[]> {
1600b57cec5SDimitry Andric  dag ret =
1610b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Offset), getMTBUFInsDA<vdataList>.ret,
1620b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.OffEn),  getMTBUFInsDA<vdataList, [VGPR_32]>.ret,
1630b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.IdxEn),  getMTBUFInsDA<vdataList, [VGPR_32]>.ret,
1640b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.BothEn), getMTBUFInsDA<vdataList, [VReg_64]>.ret,
1650b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Addr64), getMTBUFInsDA<vdataList, [VReg_64]>.ret,
1660b57cec5SDimitry Andric    (ins))))));
1670b57cec5SDimitry Andric}
1680b57cec5SDimitry Andric
1690b57cec5SDimitry Andricclass getMTBUFAsmOps<int addrKind> {
1700b57cec5SDimitry Andric  string Pfx =
1710b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Offset), "off, $srsrc, $format, $soffset",
1720b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.OffEn),
1730b57cec5SDimitry Andric            "$vaddr, $srsrc, $format, $soffset offen",
1740b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.IdxEn),
1750b57cec5SDimitry Andric            "$vaddr, $srsrc, $format, $soffset idxen",
1760b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.BothEn),
1770b57cec5SDimitry Andric            "$vaddr, $srsrc, $format, $soffset idxen offen",
1780b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Addr64),
1790b57cec5SDimitry Andric            "$vaddr, $srsrc, $format, $soffset addr64",
1800b57cec5SDimitry Andric    "")))));
1810b57cec5SDimitry Andric  string ret = Pfx # "$offset";
1820b57cec5SDimitry Andric}
1830b57cec5SDimitry Andric
1840b57cec5SDimitry Andricclass MTBUF_SetupAddr<int addrKind> {
1850b57cec5SDimitry Andric  bits<1> offen  = !if(!eq(addrKind, BUFAddrKind.OffEn), 1,
1860b57cec5SDimitry Andric                   !if(!eq(addrKind, BUFAddrKind.BothEn), 1 , 0));
1870b57cec5SDimitry Andric
1880b57cec5SDimitry Andric  bits<1> idxen  = !if(!eq(addrKind, BUFAddrKind.IdxEn), 1,
1890b57cec5SDimitry Andric                   !if(!eq(addrKind, BUFAddrKind.BothEn), 1 , 0));
1900b57cec5SDimitry Andric
1910b57cec5SDimitry Andric  bits<1> addr64 = !if(!eq(addrKind, BUFAddrKind.Addr64), 1, 0);
1920b57cec5SDimitry Andric
1930b57cec5SDimitry Andric  bits<1> has_vaddr = !if(!eq(addrKind, BUFAddrKind.Offset), 0, 1);
1940b57cec5SDimitry Andric}
1950b57cec5SDimitry Andric
1960b57cec5SDimitry Andricclass MTBUF_Load_Pseudo <string opName,
1970b57cec5SDimitry Andric                         int addrKind,
1980b57cec5SDimitry Andric                         RegisterClass vdataClass,
1998bcb0991SDimitry Andric                         int elems,
2000b57cec5SDimitry Andric                         list<dag> pattern=[],
2010b57cec5SDimitry Andric                         // Workaround bug bz30254
2020b57cec5SDimitry Andric                         int addrKindCopy = addrKind>
2030b57cec5SDimitry Andric  : MTBUF_Pseudo<opName,
2040b57cec5SDimitry Andric                 (outs vdataClass:$vdata),
2050b57cec5SDimitry Andric                 getMTBUFIns<addrKindCopy>.ret,
2068bcb0991SDimitry Andric                 " $vdata, " # getMTBUFAsmOps<addrKindCopy>.ret # "$glc$slc$tfe$dlc$swz",
2070b57cec5SDimitry Andric                 pattern>,
2080b57cec5SDimitry Andric    MTBUF_SetupAddr<addrKindCopy> {
2090b57cec5SDimitry Andric  let PseudoInstr = opName # "_" # getAddrName<addrKindCopy>.ret;
2100b57cec5SDimitry Andric  let mayLoad = 1;
2110b57cec5SDimitry Andric  let mayStore = 0;
2128bcb0991SDimitry Andric  let elements = elems;
2130b57cec5SDimitry Andric}
2140b57cec5SDimitry Andric
2150b57cec5SDimitry Andricmulticlass MTBUF_Pseudo_Loads<string opName, RegisterClass vdataClass,
2168bcb0991SDimitry Andric                              int elems, ValueType load_vt = i32,
2170b57cec5SDimitry Andric                              SDPatternOperator ld = null_frag> {
2180b57cec5SDimitry Andric
2198bcb0991SDimitry Andric  def _OFFSET : MTBUF_Load_Pseudo <opName, BUFAddrKind.Offset, vdataClass, elems,
2200b57cec5SDimitry Andric    [(set load_vt:$vdata,
2210b57cec5SDimitry Andric     (ld (MUBUFOffset v4i32:$srsrc, i32:$soffset, i16:$offset, i8:$format,
2228bcb0991SDimitry Andric                      i1:$glc, i1:$slc, i1:$tfe, i1:$dlc, i1:$swz)))]>,
2230b57cec5SDimitry Andric    MTBUFAddr64Table<0, NAME>;
2240b57cec5SDimitry Andric
2258bcb0991SDimitry Andric  def _ADDR64 : MTBUF_Load_Pseudo <opName, BUFAddrKind.Addr64, vdataClass, elems,
2260b57cec5SDimitry Andric    [(set load_vt:$vdata,
2270b57cec5SDimitry Andric     (ld (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset, i16:$offset,
2288bcb0991SDimitry Andric                      i8:$format, i1:$glc, i1:$slc, i1:$tfe, i1:$dlc, i1:$swz)))]>,
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,
2548bcb0991SDimitry Andric                 " $vdata, " # getMTBUFAsmOps<addrKindCopy>.ret # "$glc$slc$tfe$dlc$swz",
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,
2648bcb0991SDimitry Andric                               int elems, ValueType store_vt = i32,
2650b57cec5SDimitry Andric                               SDPatternOperator st = null_frag> {
2660b57cec5SDimitry Andric
2678bcb0991SDimitry Andric  def _OFFSET : MTBUF_Store_Pseudo <opName, BUFAddrKind.Offset, vdataClass, elems,
2680b57cec5SDimitry Andric    [(st store_vt:$vdata, (MUBUFOffset v4i32:$srsrc, i32:$soffset,
2690b57cec5SDimitry Andric                                       i16:$offset, i8:$format, i1:$glc,
2708bcb0991SDimitry Andric                                       i1:$slc, i1:$tfe, i1:$dlc, i1:$swz))]>,
2710b57cec5SDimitry Andric    MTBUFAddr64Table<0, NAME>;
2720b57cec5SDimitry Andric
2738bcb0991SDimitry Andric  def _ADDR64 : MTBUF_Store_Pseudo <opName, BUFAddrKind.Addr64, vdataClass, elems,
2740b57cec5SDimitry Andric    [(st store_vt:$vdata, (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset,
2750b57cec5SDimitry Andric                                       i16:$offset, i8:$format, i1:$glc,
2768bcb0991SDimitry Andric                                       i1:$slc, i1:$tfe, i1:$dlc, i1:$swz))]>,
2770b57cec5SDimitry Andric    MTBUFAddr64Table<1, NAME>;
2780b57cec5SDimitry Andric
2798bcb0991SDimitry Andric  def _OFFEN  : MTBUF_Store_Pseudo <opName, BUFAddrKind.OffEn, vdataClass, elems>;
2808bcb0991SDimitry Andric  def _IDXEN  : MTBUF_Store_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass, elems>;
2818bcb0991SDimitry Andric  def _BOTHEN : MTBUF_Store_Pseudo <opName, BUFAddrKind.BothEn, vdataClass, elems>;
2820b57cec5SDimitry Andric
2830b57cec5SDimitry Andric  let DisableWQM = 1 in {
2848bcb0991SDimitry Andric    def _OFFSET_exact : MTBUF_Store_Pseudo <opName, BUFAddrKind.Offset, vdataClass, elems>;
2858bcb0991SDimitry Andric    def _OFFEN_exact  : MTBUF_Store_Pseudo <opName, BUFAddrKind.OffEn, vdataClass, elems>;
2868bcb0991SDimitry Andric    def _IDXEN_exact  : MTBUF_Store_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass, elems>;
2878bcb0991SDimitry Andric    def _BOTHEN_exact : MTBUF_Store_Pseudo <opName, BUFAddrKind.BothEn, vdataClass, elems>;
2880b57cec5SDimitry Andric  }
2890b57cec5SDimitry Andric}
2900b57cec5SDimitry Andric
2910b57cec5SDimitry Andric
2920b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
2930b57cec5SDimitry Andric// MUBUF classes
2940b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
2950b57cec5SDimitry Andric
2960b57cec5SDimitry Andricclass MUBUFGetBaseOpcode<string Op> {
2970b57cec5SDimitry Andric  string ret = !subst("DWORDX2", "DWORD",
2980b57cec5SDimitry Andric    !subst("DWORDX3", "DWORD",
2990b57cec5SDimitry Andric    !subst("DWORDX4", "DWORD", Op)));
3000b57cec5SDimitry Andric}
3010b57cec5SDimitry Andric
3020b57cec5SDimitry Andricclass MUBUF_Pseudo <string opName, dag outs, dag ins,
3030b57cec5SDimitry Andric                    string asmOps, list<dag> pattern=[]> :
3040b57cec5SDimitry Andric  InstSI<outs, ins, "", pattern>,
3050b57cec5SDimitry Andric  SIMCInstr<opName, SIEncodingFamily.NONE> {
3060b57cec5SDimitry Andric
3070b57cec5SDimitry Andric  let isPseudo = 1;
3080b57cec5SDimitry Andric  let isCodeGenOnly = 1;
3090b57cec5SDimitry Andric  let Size = 8;
3100b57cec5SDimitry Andric  let UseNamedOperandTable = 1;
3110b57cec5SDimitry Andric
3120b57cec5SDimitry Andric  string Mnemonic = opName;
3130b57cec5SDimitry Andric  string AsmOperands = asmOps;
3140b57cec5SDimitry Andric
3150b57cec5SDimitry Andric  Instruction Opcode = !cast<Instruction>(NAME);
3160b57cec5SDimitry Andric  Instruction BaseOpcode = !cast<Instruction>(MUBUFGetBaseOpcode<NAME>.ret);
3170b57cec5SDimitry Andric
3180b57cec5SDimitry Andric  let VM_CNT = 1;
3190b57cec5SDimitry Andric  let EXP_CNT = 1;
3200b57cec5SDimitry Andric  let MUBUF = 1;
3210b57cec5SDimitry Andric  let Uses = [EXEC];
3220b57cec5SDimitry Andric  let hasSideEffects = 0;
3230b57cec5SDimitry Andric  let SchedRW = [WriteVMEM];
3240b57cec5SDimitry Andric
3250b57cec5SDimitry Andric  let AsmMatchConverter = "cvtMubuf";
3260b57cec5SDimitry Andric
3270b57cec5SDimitry Andric  bits<1> offen       = 0;
3280b57cec5SDimitry Andric  bits<1> idxen       = 0;
3290b57cec5SDimitry Andric  bits<1> addr64      = 0;
3300b57cec5SDimitry Andric  bits<1> lds         = 0;
3310b57cec5SDimitry Andric  bits<1> has_vdata   = 1;
3320b57cec5SDimitry Andric  bits<1> has_vaddr   = 1;
3330b57cec5SDimitry Andric  bits<1> has_glc     = 1;
3340b57cec5SDimitry Andric  bits<1> has_dlc     = 1;
3350b57cec5SDimitry Andric  bits<1> glc_value   = 0; // the value for glc if no such operand
3360b57cec5SDimitry Andric  bits<1> dlc_value   = 0; // the value for dlc if no such operand
3370b57cec5SDimitry Andric  bits<1> has_srsrc   = 1;
3380b57cec5SDimitry Andric  bits<1> has_soffset = 1;
3390b57cec5SDimitry Andric  bits<1> has_offset  = 1;
3400b57cec5SDimitry Andric  bits<1> has_slc     = 1;
3410b57cec5SDimitry Andric  bits<1> has_tfe     = 1;
3428bcb0991SDimitry Andric  bits<4> elements    = 0;
3430b57cec5SDimitry Andric}
3440b57cec5SDimitry Andric
3450b57cec5SDimitry Andricclass MUBUF_Real <MUBUF_Pseudo ps> :
3460b57cec5SDimitry Andric  InstSI <ps.OutOperandList, ps.InOperandList, ps.Mnemonic # ps.AsmOperands, []> {
3470b57cec5SDimitry Andric
3480b57cec5SDimitry Andric  let isPseudo = 0;
3490b57cec5SDimitry Andric  let isCodeGenOnly = 0;
3500b57cec5SDimitry Andric
3510b57cec5SDimitry Andric  // copy relevant pseudo op flags
3520b57cec5SDimitry Andric  let SubtargetPredicate = ps.SubtargetPredicate;
3530b57cec5SDimitry Andric  let AsmMatchConverter  = ps.AsmMatchConverter;
3540b57cec5SDimitry Andric  let Constraints        = ps.Constraints;
3550b57cec5SDimitry Andric  let DisableEncoding    = ps.DisableEncoding;
3560b57cec5SDimitry Andric  let TSFlags            = ps.TSFlags;
3570b57cec5SDimitry Andric
3580b57cec5SDimitry Andric  bits<12> offset;
3590b57cec5SDimitry Andric  bits<1>  glc;
3600b57cec5SDimitry Andric  bits<1>  dlc;
3610b57cec5SDimitry Andric  bits<8>  vaddr;
3620b57cec5SDimitry Andric  bits<8>  vdata;
3630b57cec5SDimitry Andric  bits<7>  srsrc;
3640b57cec5SDimitry Andric  bits<1>  slc;
3650b57cec5SDimitry Andric  bits<1>  tfe;
3660b57cec5SDimitry Andric  bits<8>  soffset;
3670b57cec5SDimitry Andric}
3680b57cec5SDimitry Andric
3690b57cec5SDimitry Andric
3700b57cec5SDimitry Andric// For cache invalidation instructions.
3710b57cec5SDimitry Andricclass MUBUF_Invalidate <string opName, SDPatternOperator node = null_frag> :
3720b57cec5SDimitry Andric  MUBUF_Pseudo<opName, (outs), (ins), "", [(node)]> {
3730b57cec5SDimitry Andric
3740b57cec5SDimitry Andric  let AsmMatchConverter = "";
3750b57cec5SDimitry Andric
3760b57cec5SDimitry Andric  let hasSideEffects = 1;
377*5ffd83dbSDimitry Andric  let mayLoad = 0;
378*5ffd83dbSDimitry Andric  let mayStore = 0;
3790b57cec5SDimitry Andric
3800b57cec5SDimitry Andric  // Set everything to 0.
3810b57cec5SDimitry Andric  let offen       = 0;
3820b57cec5SDimitry Andric  let idxen       = 0;
3830b57cec5SDimitry Andric  let addr64      = 0;
3840b57cec5SDimitry Andric  let has_vdata   = 0;
3850b57cec5SDimitry Andric  let has_vaddr   = 0;
3860b57cec5SDimitry Andric  let has_glc     = 0;
3870b57cec5SDimitry Andric  let has_dlc     = 0;
3880b57cec5SDimitry Andric  let glc_value   = 0;
3890b57cec5SDimitry Andric  let dlc_value   = 0;
3900b57cec5SDimitry Andric  let has_srsrc   = 0;
3910b57cec5SDimitry Andric  let has_soffset = 0;
3920b57cec5SDimitry Andric  let has_offset  = 0;
3930b57cec5SDimitry Andric  let has_slc     = 0;
3940b57cec5SDimitry Andric  let has_tfe     = 0;
3950b57cec5SDimitry Andric}
3960b57cec5SDimitry Andric
3970b57cec5SDimitry Andricclass getMUBUFInsDA<list<RegisterClass> vdataList,
3980b57cec5SDimitry Andric                    list<RegisterClass> vaddrList=[],
3990b57cec5SDimitry Andric                    bit isLds = 0> {
4000b57cec5SDimitry Andric  RegisterClass vdataClass = !if(!empty(vdataList), ?, !head(vdataList));
4010b57cec5SDimitry Andric  RegisterClass vaddrClass = !if(!empty(vaddrList), ?, !head(vaddrList));
4020b57cec5SDimitry Andric  dag InsNoData = !if(!empty(vaddrList),
4030b57cec5SDimitry Andric    (ins                    SReg_128:$srsrc, SCSrc_b32:$soffset,
4040b57cec5SDimitry Andric         offset:$offset, GLC:$glc, SLC:$slc),
4050b57cec5SDimitry Andric    (ins vaddrClass:$vaddr, SReg_128:$srsrc, SCSrc_b32:$soffset,
4060b57cec5SDimitry Andric         offset:$offset, GLC:$glc, SLC:$slc)
4070b57cec5SDimitry Andric  );
4080b57cec5SDimitry Andric  dag InsData = !if(!empty(vaddrList),
4090b57cec5SDimitry Andric    (ins vdataClass:$vdata,                    SReg_128:$srsrc,
4100b57cec5SDimitry Andric         SCSrc_b32:$soffset, offset:$offset, GLC:$glc, SLC:$slc),
4110b57cec5SDimitry Andric    (ins vdataClass:$vdata, vaddrClass:$vaddr, SReg_128:$srsrc,
4120b57cec5SDimitry Andric         SCSrc_b32:$soffset, offset:$offset, GLC:$glc, SLC:$slc)
4130b57cec5SDimitry Andric  );
4140b57cec5SDimitry Andric  dag ret = !con(
4150b57cec5SDimitry Andric              !if(!empty(vdataList), InsNoData, InsData),
4168bcb0991SDimitry Andric              !if(isLds, (ins DLC:$dlc, SWZ:$swz), (ins TFE:$tfe, DLC:$dlc,SWZ:$swz))
4170b57cec5SDimitry Andric             );
4180b57cec5SDimitry Andric}
4190b57cec5SDimitry Andric
4208bcb0991SDimitry Andricclass getMUBUFElements<ValueType vt> {
4218bcb0991SDimitry Andric  // eq does not support ValueType for some reason.
4228bcb0991SDimitry Andric  string vtAsStr = !cast<string>(vt);
4238bcb0991SDimitry Andric
4240b57cec5SDimitry Andric  int ret =
4258bcb0991SDimitry Andric    !if(!eq(vtAsStr, "f16"), 1,
4268bcb0991SDimitry Andric      !if(!eq(vtAsStr, "v2f16"), 2,
4278bcb0991SDimitry Andric        !if(!eq(vtAsStr, "v3f16"), 3,
4288bcb0991SDimitry Andric          !if(!eq(vtAsStr, "v4f16"), 4,
4298bcb0991SDimitry Andric            !if(!eq(vt.Size, 32), 1,
4308bcb0991SDimitry Andric              !if(!eq(vt.Size, 64), 2,
4318bcb0991SDimitry Andric                !if(!eq(vt.Size, 96), 3,
4328bcb0991SDimitry Andric                  !if(!eq(vt.Size, 128), 4, 0)
4338bcb0991SDimitry Andric                )
4348bcb0991SDimitry Andric              )
4358bcb0991SDimitry Andric            )
4368bcb0991SDimitry Andric          )
4378bcb0991SDimitry Andric        )
4388bcb0991SDimitry Andric      )
4398bcb0991SDimitry Andric    );
4400b57cec5SDimitry Andric}
4410b57cec5SDimitry Andric
4420b57cec5SDimitry Andricclass getMUBUFIns<int addrKind, list<RegisterClass> vdataList=[], bit isLds = 0> {
4430b57cec5SDimitry Andric  dag ret =
4440b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Offset), getMUBUFInsDA<vdataList, [], isLds>.ret,
4450b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.OffEn),  getMUBUFInsDA<vdataList, [VGPR_32], isLds>.ret,
4460b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.IdxEn),  getMUBUFInsDA<vdataList, [VGPR_32], isLds>.ret,
4470b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.BothEn), getMUBUFInsDA<vdataList, [VReg_64], isLds>.ret,
4480b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Addr64), getMUBUFInsDA<vdataList, [VReg_64], isLds>.ret,
4490b57cec5SDimitry Andric    (ins))))));
4500b57cec5SDimitry Andric}
4510b57cec5SDimitry Andric
4520b57cec5SDimitry Andricclass getMUBUFAsmOps<int addrKind> {
4530b57cec5SDimitry Andric  string Pfx =
4540b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Offset), "off, $srsrc, $soffset",
4550b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.OffEn),  "$vaddr, $srsrc, $soffset offen",
4560b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.IdxEn),  "$vaddr, $srsrc, $soffset idxen",
4570b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.BothEn), "$vaddr, $srsrc, $soffset idxen offen",
4580b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Addr64), "$vaddr, $srsrc, $soffset addr64",
4590b57cec5SDimitry Andric    "")))));
4600b57cec5SDimitry Andric  string ret = Pfx # "$offset";
4610b57cec5SDimitry Andric}
4620b57cec5SDimitry Andric
4630b57cec5SDimitry Andricclass MUBUF_SetupAddr<int addrKind> {
4640b57cec5SDimitry Andric  bits<1> offen  = !if(!eq(addrKind, BUFAddrKind.OffEn), 1,
4650b57cec5SDimitry Andric                   !if(!eq(addrKind, BUFAddrKind.BothEn), 1 , 0));
4660b57cec5SDimitry Andric
4670b57cec5SDimitry Andric  bits<1> idxen  = !if(!eq(addrKind, BUFAddrKind.IdxEn), 1,
4680b57cec5SDimitry Andric                   !if(!eq(addrKind, BUFAddrKind.BothEn), 1 , 0));
4690b57cec5SDimitry Andric
4700b57cec5SDimitry Andric  bits<1> addr64 = !if(!eq(addrKind, BUFAddrKind.Addr64), 1, 0);
4710b57cec5SDimitry Andric
4720b57cec5SDimitry Andric  bits<1> has_vaddr = !if(!eq(addrKind, BUFAddrKind.Offset), 0, 1);
4730b57cec5SDimitry Andric}
4740b57cec5SDimitry Andric
4750b57cec5SDimitry Andricclass MUBUF_Load_Pseudo <string opName,
4760b57cec5SDimitry Andric                         int addrKind,
4778bcb0991SDimitry Andric                         ValueType vdata_vt,
4780b57cec5SDimitry Andric                         bit HasTiedDest = 0,
4790b57cec5SDimitry Andric                         bit isLds = 0,
4800b57cec5SDimitry Andric                         list<dag> pattern=[],
4810b57cec5SDimitry Andric                         // Workaround bug bz30254
4820b57cec5SDimitry Andric                         int addrKindCopy = addrKind>
4830b57cec5SDimitry Andric  : MUBUF_Pseudo<opName,
4848bcb0991SDimitry Andric                 (outs getVregSrcForVT<vdata_vt>.ret:$vdata),
4850b57cec5SDimitry Andric                 !con(getMUBUFIns<addrKindCopy, [], isLds>.ret,
4868bcb0991SDimitry Andric                      !if(HasTiedDest, (ins getVregSrcForVT<vdata_vt>.ret:$vdata_in), (ins))),
4870b57cec5SDimitry Andric                 " $vdata, " # getMUBUFAsmOps<addrKindCopy>.ret # "$glc$slc" #
4888bcb0991SDimitry Andric                   !if(isLds, " lds", "$tfe") # "$dlc" # "$swz",
4890b57cec5SDimitry Andric                 pattern>,
4900b57cec5SDimitry Andric    MUBUF_SetupAddr<addrKindCopy> {
4910b57cec5SDimitry Andric  let PseudoInstr = opName # !if(isLds, "_lds", "") #
4920b57cec5SDimitry Andric                    "_" # getAddrName<addrKindCopy>.ret;
4930b57cec5SDimitry Andric  let AsmMatchConverter = !if(isLds, "cvtMubufLds", "cvtMubuf");
4940b57cec5SDimitry Andric
4950b57cec5SDimitry Andric  let Constraints = !if(HasTiedDest, "$vdata = $vdata_in", "");
4960b57cec5SDimitry Andric  let mayLoad = 1;
4970b57cec5SDimitry Andric  let mayStore = 0;
4980b57cec5SDimitry Andric  let maybeAtomic = 1;
4990b57cec5SDimitry Andric  let Uses = !if(isLds, [EXEC, M0], [EXEC]);
5000b57cec5SDimitry Andric  let has_tfe = !if(isLds, 0, 1);
5010b57cec5SDimitry Andric  let lds = isLds;
5028bcb0991SDimitry Andric  let elements = getMUBUFElements<vdata_vt>.ret;
5030b57cec5SDimitry Andric}
5040b57cec5SDimitry Andric
5050b57cec5SDimitry Andricclass MUBUF_Offset_Load_Pat <Instruction inst, ValueType load_vt = i32, SDPatternOperator ld = null_frag> : Pat <
5068bcb0991SDimitry Andric  (load_vt (ld (MUBUFOffset v4i32:$srsrc, i32:$soffset, i16:$offset, i1:$glc, i1:$slc, i1:$tfe, i1:$dlc, i1:$swz))),
5078bcb0991SDimitry Andric  (load_vt (inst v4i32:$srsrc, i32:$soffset, i16:$offset, i1:$glc, i1:$slc, i1:$tfe, i1:$dlc, i1:$swz))
5080b57cec5SDimitry Andric>;
5090b57cec5SDimitry Andric
5100b57cec5SDimitry Andricclass MUBUF_Addr64_Load_Pat <Instruction inst,
5110b57cec5SDimitry Andric                            ValueType load_vt = i32,
5120b57cec5SDimitry Andric                            SDPatternOperator ld = null_frag> : Pat <
5138bcb0991SDimitry Andric  (load_vt (ld (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset, i16:$offset, i1:$glc, i1:$slc, i1:$tfe, i1:$dlc, i1:$swz))),
5148bcb0991SDimitry Andric  (load_vt (inst i64:$vaddr, v4i32:$srsrc, i32:$soffset, i16:$offset, i1:$glc, i1:$slc, i1:$tfe, i1:$dlc, i1:$swz))
5150b57cec5SDimitry Andric>;
5160b57cec5SDimitry Andric
5170b57cec5SDimitry Andricmulticlass MUBUF_Pseudo_Load_Pats<string BaseInst, ValueType load_vt = i32, SDPatternOperator ld = null_frag> {
5180b57cec5SDimitry Andric  def : MUBUF_Offset_Load_Pat<!cast<Instruction>(BaseInst#"_OFFSET"), load_vt, ld>;
5190b57cec5SDimitry Andric  def : MUBUF_Addr64_Load_Pat<!cast<Instruction>(BaseInst#"_ADDR64"), load_vt, ld>;
5200b57cec5SDimitry Andric}
5210b57cec5SDimitry Andric
5220b57cec5SDimitry Andric
5230b57cec5SDimitry Andric// FIXME: tfe can't be an operand because it requires a separate
5240b57cec5SDimitry Andric// opcode because it needs an N+1 register class dest register.
5258bcb0991SDimitry Andricmulticlass MUBUF_Pseudo_Loads<string opName,
5260b57cec5SDimitry Andric                              ValueType load_vt = i32,
5270b57cec5SDimitry Andric                              SDPatternOperator ld = null_frag,
5280b57cec5SDimitry Andric                              bit TiedDest = 0,
5290b57cec5SDimitry Andric                              bit isLds = 0> {
5300b57cec5SDimitry Andric
5318bcb0991SDimitry Andric  def _OFFSET : MUBUF_Load_Pseudo <opName, BUFAddrKind.Offset, load_vt, TiedDest, isLds>,
5320b57cec5SDimitry Andric    MUBUFAddr64Table<0, NAME # !if(isLds, "_LDS", "")>;
5330b57cec5SDimitry Andric
5348bcb0991SDimitry Andric  def _ADDR64 : MUBUF_Load_Pseudo <opName, BUFAddrKind.Addr64, load_vt, TiedDest, isLds>,
5350b57cec5SDimitry Andric    MUBUFAddr64Table<1, NAME # !if(isLds, "_LDS", "")>;
5360b57cec5SDimitry Andric
5378bcb0991SDimitry Andric  def _OFFEN  : MUBUF_Load_Pseudo <opName, BUFAddrKind.OffEn, load_vt, TiedDest, isLds>;
5388bcb0991SDimitry Andric  def _IDXEN  : MUBUF_Load_Pseudo <opName, BUFAddrKind.IdxEn, load_vt, TiedDest, isLds>;
5398bcb0991SDimitry Andric  def _BOTHEN : MUBUF_Load_Pseudo <opName, BUFAddrKind.BothEn, load_vt, TiedDest, isLds>;
5400b57cec5SDimitry Andric
5410b57cec5SDimitry Andric  let DisableWQM = 1 in {
5428bcb0991SDimitry Andric    def _OFFSET_exact : MUBUF_Load_Pseudo <opName, BUFAddrKind.Offset, load_vt, TiedDest, isLds>;
5438bcb0991SDimitry Andric    def _OFFEN_exact  : MUBUF_Load_Pseudo <opName, BUFAddrKind.OffEn, load_vt, TiedDest, isLds>;
5448bcb0991SDimitry Andric    def _IDXEN_exact  : MUBUF_Load_Pseudo <opName, BUFAddrKind.IdxEn, load_vt, TiedDest, isLds>;
5458bcb0991SDimitry Andric    def _BOTHEN_exact : MUBUF_Load_Pseudo <opName, BUFAddrKind.BothEn, load_vt, TiedDest, isLds>;
5460b57cec5SDimitry Andric  }
5470b57cec5SDimitry Andric}
5480b57cec5SDimitry Andric
5498bcb0991SDimitry Andricmulticlass MUBUF_Pseudo_Loads_Lds<string opName, ValueType load_vt = i32,
5500b57cec5SDimitry Andric                                  SDPatternOperator ld_nolds = null_frag,
5510b57cec5SDimitry Andric                                  SDPatternOperator ld_lds = null_frag> {
5528bcb0991SDimitry Andric  defm NAME : MUBUF_Pseudo_Loads<opName, load_vt, ld_nolds>;
5538bcb0991SDimitry Andric  defm _LDS : MUBUF_Pseudo_Loads<opName, load_vt, ld_lds, 0, 1>;
5540b57cec5SDimitry Andric}
5550b57cec5SDimitry Andric
5560b57cec5SDimitry Andricclass MUBUF_Store_Pseudo <string opName,
5570b57cec5SDimitry Andric                          int addrKind,
5588bcb0991SDimitry Andric                          ValueType store_vt,
5590b57cec5SDimitry Andric                          list<dag> pattern=[],
5600b57cec5SDimitry Andric                          // Workaround bug bz30254
5618bcb0991SDimitry Andric                          int addrKindCopy = addrKind>
5620b57cec5SDimitry Andric  : MUBUF_Pseudo<opName,
5630b57cec5SDimitry Andric                 (outs),
5648bcb0991SDimitry Andric                 getMUBUFIns<addrKindCopy, [getVregSrcForVT<store_vt>.ret]>.ret,
5658bcb0991SDimitry Andric                 " $vdata, " # getMUBUFAsmOps<addrKindCopy>.ret # "$glc$slc$tfe$dlc$swz",
5660b57cec5SDimitry Andric                 pattern>,
5670b57cec5SDimitry Andric    MUBUF_SetupAddr<addrKindCopy> {
5680b57cec5SDimitry Andric  let PseudoInstr = opName # "_" # getAddrName<addrKindCopy>.ret;
5690b57cec5SDimitry Andric  let mayLoad = 0;
5700b57cec5SDimitry Andric  let mayStore = 1;
5710b57cec5SDimitry Andric  let maybeAtomic = 1;
5728bcb0991SDimitry Andric  let elements = getMUBUFElements<store_vt>.ret;
5730b57cec5SDimitry Andric}
5740b57cec5SDimitry Andric
5758bcb0991SDimitry Andricmulticlass MUBUF_Pseudo_Stores<string opName,
5760b57cec5SDimitry Andric                               ValueType store_vt = i32,
5770b57cec5SDimitry Andric                               SDPatternOperator st = null_frag> {
5780b57cec5SDimitry Andric
5798bcb0991SDimitry Andric  def _OFFSET : MUBUF_Store_Pseudo <opName, BUFAddrKind.Offset, store_vt,
5800b57cec5SDimitry Andric    [(st store_vt:$vdata, (MUBUFOffset v4i32:$srsrc, i32:$soffset,
5818bcb0991SDimitry Andric                                       i16:$offset, i1:$glc, i1:$slc, i1:$tfe, i1:$dlc, i1:$swz))]>,
5820b57cec5SDimitry Andric    MUBUFAddr64Table<0, NAME>;
5830b57cec5SDimitry Andric
5848bcb0991SDimitry Andric  def _ADDR64 : MUBUF_Store_Pseudo <opName, BUFAddrKind.Addr64, store_vt,
5850b57cec5SDimitry Andric    [(st store_vt:$vdata, (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset,
5868bcb0991SDimitry Andric                                       i16:$offset, i1:$glc, i1:$slc, i1:$tfe, i1:$dlc, i1:$swz))]>,
5870b57cec5SDimitry Andric    MUBUFAddr64Table<1, NAME>;
5880b57cec5SDimitry Andric
5898bcb0991SDimitry Andric  def _OFFEN  : MUBUF_Store_Pseudo <opName, BUFAddrKind.OffEn, store_vt>;
5908bcb0991SDimitry Andric  def _IDXEN  : MUBUF_Store_Pseudo <opName, BUFAddrKind.IdxEn, store_vt>;
5918bcb0991SDimitry Andric  def _BOTHEN : MUBUF_Store_Pseudo <opName, BUFAddrKind.BothEn, store_vt>;
5920b57cec5SDimitry Andric
5930b57cec5SDimitry Andric  let DisableWQM = 1 in {
5948bcb0991SDimitry Andric    def _OFFSET_exact : MUBUF_Store_Pseudo <opName, BUFAddrKind.Offset, store_vt>;
5958bcb0991SDimitry Andric    def _OFFEN_exact  : MUBUF_Store_Pseudo <opName, BUFAddrKind.OffEn, store_vt>;
5968bcb0991SDimitry Andric    def _IDXEN_exact  : MUBUF_Store_Pseudo <opName, BUFAddrKind.IdxEn, store_vt>;
5978bcb0991SDimitry Andric    def _BOTHEN_exact : MUBUF_Store_Pseudo <opName, BUFAddrKind.BothEn, store_vt>;
5980b57cec5SDimitry Andric  }
5990b57cec5SDimitry Andric}
6000b57cec5SDimitry Andric
6010b57cec5SDimitry Andricclass MUBUF_Pseudo_Store_Lds<string opName>
6020b57cec5SDimitry Andric  : MUBUF_Pseudo<opName,
6030b57cec5SDimitry Andric                 (outs),
6048bcb0991SDimitry Andric                 (ins SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset, GLC:$glc, SLC:$slc, SWZ:$swz),
6058bcb0991SDimitry Andric                 " $srsrc, $soffset$offset lds$glc$slc$swz"> {
6060b57cec5SDimitry Andric  let mayLoad = 0;
6070b57cec5SDimitry Andric  let mayStore = 1;
6080b57cec5SDimitry Andric  let maybeAtomic = 1;
6090b57cec5SDimitry Andric
6100b57cec5SDimitry Andric  let has_vdata = 0;
6110b57cec5SDimitry Andric  let has_vaddr = 0;
6120b57cec5SDimitry Andric  let has_tfe = 0;
6130b57cec5SDimitry Andric  let lds = 1;
6140b57cec5SDimitry Andric
6150b57cec5SDimitry Andric  let Uses = [EXEC, M0];
6160b57cec5SDimitry Andric  let AsmMatchConverter = "cvtMubufLds";
6170b57cec5SDimitry Andric}
6180b57cec5SDimitry Andric
6190b57cec5SDimitry Andricclass getMUBUFAtomicInsDA<RegisterClass vdataClass, bit vdata_in,
6200b57cec5SDimitry Andric                          list<RegisterClass> vaddrList=[]> {
6210b57cec5SDimitry Andric  RegisterClass vaddrClass = !if(!empty(vaddrList), ?, !head(vaddrList));
6220b57cec5SDimitry Andric  dag ret = !if(vdata_in,
6230b57cec5SDimitry Andric    !if(!empty(vaddrList),
6240b57cec5SDimitry Andric      (ins vdataClass:$vdata_in,
6250b57cec5SDimitry Andric           SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset, SLC:$slc),
6260b57cec5SDimitry Andric      (ins vdataClass:$vdata_in, vaddrClass:$vaddr,
6270b57cec5SDimitry Andric           SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset, SLC:$slc)
6280b57cec5SDimitry Andric    ),
6290b57cec5SDimitry Andric    !if(!empty(vaddrList),
6300b57cec5SDimitry Andric      (ins vdataClass:$vdata,
6310b57cec5SDimitry Andric           SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset, SLC:$slc),
6320b57cec5SDimitry Andric      (ins vdataClass:$vdata, vaddrClass:$vaddr,
6330b57cec5SDimitry Andric           SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset, SLC:$slc)
6340b57cec5SDimitry Andric  ));
6350b57cec5SDimitry Andric}
6360b57cec5SDimitry Andric
6370b57cec5SDimitry Andricclass getMUBUFAtomicIns<int addrKind,
6380b57cec5SDimitry Andric                        RegisterClass vdataClass,
6390b57cec5SDimitry Andric                        bit vdata_in,
6400b57cec5SDimitry Andric                        // Workaround bug bz30254
6410b57cec5SDimitry Andric                        RegisterClass vdataClassCopy=vdataClass> {
6420b57cec5SDimitry Andric  dag ret =
6430b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Offset),
6440b57cec5SDimitry Andric            getMUBUFAtomicInsDA<vdataClassCopy, vdata_in>.ret,
6450b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.OffEn),
6460b57cec5SDimitry Andric            getMUBUFAtomicInsDA<vdataClassCopy, vdata_in, [VGPR_32]>.ret,
6470b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.IdxEn),
6480b57cec5SDimitry Andric            getMUBUFAtomicInsDA<vdataClassCopy, vdata_in, [VGPR_32]>.ret,
6490b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.BothEn),
6500b57cec5SDimitry Andric            getMUBUFAtomicInsDA<vdataClassCopy, vdata_in, [VReg_64]>.ret,
6510b57cec5SDimitry Andric    !if(!eq(addrKind, BUFAddrKind.Addr64),
6520b57cec5SDimitry Andric            getMUBUFAtomicInsDA<vdataClassCopy, vdata_in, [VReg_64]>.ret,
6530b57cec5SDimitry Andric    (ins))))));
6540b57cec5SDimitry Andric}
6550b57cec5SDimitry Andric
6560b57cec5SDimitry Andricclass MUBUF_Atomic_Pseudo<string opName,
6570b57cec5SDimitry Andric                          int addrKind,
6580b57cec5SDimitry Andric                          dag outs,
6590b57cec5SDimitry Andric                          dag ins,
6600b57cec5SDimitry Andric                          string asmOps,
6610b57cec5SDimitry Andric                          list<dag> pattern=[],
6620b57cec5SDimitry Andric                          // Workaround bug bz30254
6630b57cec5SDimitry Andric                          int addrKindCopy = addrKind>
6640b57cec5SDimitry Andric  : MUBUF_Pseudo<opName, outs, ins, asmOps, pattern>,
6650b57cec5SDimitry Andric    MUBUF_SetupAddr<addrKindCopy> {
6660b57cec5SDimitry Andric  let mayStore = 1;
6670b57cec5SDimitry Andric  let mayLoad = 1;
6680b57cec5SDimitry Andric  let hasPostISelHook = 1;
6690b57cec5SDimitry Andric  let hasSideEffects = 1;
6700b57cec5SDimitry Andric  let DisableWQM = 1;
6710b57cec5SDimitry Andric  let has_glc = 0;
6720b57cec5SDimitry Andric  let has_dlc = 0;
6730b57cec5SDimitry Andric  let has_tfe = 0;
6740b57cec5SDimitry Andric  let maybeAtomic = 1;
6750b57cec5SDimitry Andric}
6760b57cec5SDimitry Andric
6770b57cec5SDimitry Andricclass MUBUF_AtomicNoRet_Pseudo<string opName, int addrKind,
6780b57cec5SDimitry Andric                               RegisterClass vdataClass,
6790b57cec5SDimitry Andric                               list<dag> pattern=[],
6800b57cec5SDimitry Andric                               // Workaround bug bz30254
6810b57cec5SDimitry Andric                               int addrKindCopy = addrKind,
6820b57cec5SDimitry Andric                               RegisterClass vdataClassCopy = vdataClass>
6830b57cec5SDimitry Andric  : MUBUF_Atomic_Pseudo<opName, addrKindCopy,
6840b57cec5SDimitry Andric                        (outs),
6850b57cec5SDimitry Andric                        getMUBUFAtomicIns<addrKindCopy, vdataClassCopy, 0>.ret,
6860b57cec5SDimitry Andric                        " $vdata, " # getMUBUFAsmOps<addrKindCopy>.ret # "$slc",
6870b57cec5SDimitry Andric                        pattern>,
6880b57cec5SDimitry Andric    AtomicNoRet<opName # "_" # getAddrName<addrKindCopy>.ret, 0> {
6890b57cec5SDimitry Andric  let PseudoInstr = opName # "_" # getAddrName<addrKindCopy>.ret;
6900b57cec5SDimitry Andric  let glc_value = 0;
6910b57cec5SDimitry Andric  let dlc_value = 0;
6920b57cec5SDimitry Andric  let AsmMatchConverter = "cvtMubufAtomic";
6930b57cec5SDimitry Andric}
6940b57cec5SDimitry Andric
6950b57cec5SDimitry Andricclass MUBUF_AtomicRet_Pseudo<string opName, int addrKind,
6960b57cec5SDimitry Andric                             RegisterClass vdataClass,
6970b57cec5SDimitry Andric                             list<dag> pattern=[],
6980b57cec5SDimitry Andric                             // Workaround bug bz30254
6990b57cec5SDimitry Andric                             int addrKindCopy = addrKind,
7000b57cec5SDimitry Andric                             RegisterClass vdataClassCopy = vdataClass>
7010b57cec5SDimitry Andric  : MUBUF_Atomic_Pseudo<opName, addrKindCopy,
7020b57cec5SDimitry Andric                        (outs vdataClassCopy:$vdata),
7030b57cec5SDimitry Andric                        getMUBUFAtomicIns<addrKindCopy, vdataClassCopy, 1>.ret,
7040b57cec5SDimitry Andric                        " $vdata, " # getMUBUFAsmOps<addrKindCopy>.ret # " glc$slc",
7050b57cec5SDimitry Andric                        pattern>,
7060b57cec5SDimitry Andric    AtomicNoRet<opName # "_" # getAddrName<addrKindCopy>.ret, 1> {
7070b57cec5SDimitry Andric  let PseudoInstr = opName # "_rtn_" # getAddrName<addrKindCopy>.ret;
7080b57cec5SDimitry Andric  let glc_value = 1;
7090b57cec5SDimitry Andric  let dlc_value = 0;
7100b57cec5SDimitry Andric  let Constraints = "$vdata = $vdata_in";
7110b57cec5SDimitry Andric  let DisableEncoding = "$vdata_in";
7120b57cec5SDimitry Andric  let AsmMatchConverter = "cvtMubufAtomicReturn";
7130b57cec5SDimitry Andric}
7140b57cec5SDimitry Andric
7150b57cec5SDimitry Andricmulticlass MUBUF_Pseudo_Atomics_NO_RTN <string opName,
7160b57cec5SDimitry Andric                                        RegisterClass vdataClass,
7170b57cec5SDimitry Andric                                        ValueType vdataType,
7180b57cec5SDimitry Andric                                        SDPatternOperator atomic,
7198bcb0991SDimitry Andric                                        bit isFP = isFloatType<vdataType>.ret> {
7200b57cec5SDimitry Andric  let FPAtomic = isFP in
7210b57cec5SDimitry Andric  def _OFFSET : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.Offset, vdataClass>,
7220b57cec5SDimitry Andric                MUBUFAddr64Table <0, NAME>;
7230b57cec5SDimitry Andric
7240b57cec5SDimitry Andric  let FPAtomic = isFP in
7250b57cec5SDimitry Andric  def _ADDR64 : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.Addr64, vdataClass>,
7260b57cec5SDimitry Andric                MUBUFAddr64Table <1, NAME>;
7270b57cec5SDimitry Andric
7280b57cec5SDimitry Andric  let FPAtomic = isFP in
7290b57cec5SDimitry Andric  def _OFFEN  : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.OffEn,  vdataClass>;
7300b57cec5SDimitry Andric
7310b57cec5SDimitry Andric  let FPAtomic = isFP in
7320b57cec5SDimitry Andric
7330b57cec5SDimitry Andric  def _IDXEN  : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.IdxEn,  vdataClass>;
7340b57cec5SDimitry Andric
7350b57cec5SDimitry Andric  let FPAtomic = isFP in
7360b57cec5SDimitry Andric  def _BOTHEN : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.BothEn, vdataClass>;
7370b57cec5SDimitry Andric}
7380b57cec5SDimitry Andric
7390b57cec5SDimitry Andricmulticlass MUBUF_Pseudo_Atomics_RTN <string opName,
7400b57cec5SDimitry Andric                                     RegisterClass vdataClass,
7410b57cec5SDimitry Andric                                     ValueType vdataType,
7420b57cec5SDimitry Andric                                     SDPatternOperator atomic,
7438bcb0991SDimitry Andric                                     bit isFP = isFloatType<vdataType>.ret> {
7440b57cec5SDimitry Andric  let FPAtomic = isFP in
7450b57cec5SDimitry Andric  def _OFFSET_RTN : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.Offset, vdataClass,
7460b57cec5SDimitry Andric    [(set vdataType:$vdata,
7470b57cec5SDimitry Andric     (atomic (MUBUFOffsetAtomic v4i32:$srsrc, i32:$soffset, i16:$offset, i1:$slc),
7480b57cec5SDimitry Andric             vdataType:$vdata_in))]>,
7490b57cec5SDimitry Andric    MUBUFAddr64Table <0, NAME # "_RTN">;
7500b57cec5SDimitry Andric
7510b57cec5SDimitry Andric  let FPAtomic = isFP in
7520b57cec5SDimitry Andric  def _ADDR64_RTN : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.Addr64, vdataClass,
7530b57cec5SDimitry Andric    [(set vdataType:$vdata,
7540b57cec5SDimitry Andric     (atomic (MUBUFAddr64Atomic v4i32:$srsrc, i64:$vaddr, i32:$soffset, i16:$offset, i1:$slc),
7550b57cec5SDimitry Andric             vdataType:$vdata_in))]>,
7560b57cec5SDimitry Andric    MUBUFAddr64Table <1, NAME # "_RTN">;
7570b57cec5SDimitry Andric
7580b57cec5SDimitry Andric  let FPAtomic = isFP in
7590b57cec5SDimitry Andric  def _OFFEN_RTN  : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.OffEn,  vdataClass>;
7600b57cec5SDimitry Andric
7610b57cec5SDimitry Andric  let FPAtomic = isFP in
7620b57cec5SDimitry Andric  def _IDXEN_RTN  : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.IdxEn,  vdataClass>;
7630b57cec5SDimitry Andric
7640b57cec5SDimitry Andric  let FPAtomic = isFP in
7650b57cec5SDimitry Andric  def _BOTHEN_RTN : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.BothEn, vdataClass>;
7660b57cec5SDimitry Andric}
7670b57cec5SDimitry Andric
7680b57cec5SDimitry Andricmulticlass MUBUF_Pseudo_Atomics <string opName,
7690b57cec5SDimitry Andric                                 RegisterClass vdataClass,
7700b57cec5SDimitry Andric                                 ValueType vdataType,
7710b57cec5SDimitry Andric                                 SDPatternOperator atomic> :
7720b57cec5SDimitry Andric  MUBUF_Pseudo_Atomics_NO_RTN<opName, vdataClass, vdataType, atomic>,
7730b57cec5SDimitry Andric  MUBUF_Pseudo_Atomics_RTN<opName, vdataClass, vdataType, atomic>;
7740b57cec5SDimitry Andric
7750b57cec5SDimitry Andric
7760b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
7770b57cec5SDimitry Andric// MUBUF Instructions
7780b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
7790b57cec5SDimitry Andric
7800b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_X : MUBUF_Pseudo_Loads_Lds <
7818bcb0991SDimitry Andric  "buffer_load_format_x", f32
7820b57cec5SDimitry Andric>;
7830b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XY : MUBUF_Pseudo_Loads <
7848bcb0991SDimitry Andric  "buffer_load_format_xy", v2f32
7850b57cec5SDimitry Andric>;
7860b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZ : MUBUF_Pseudo_Loads <
7878bcb0991SDimitry Andric  "buffer_load_format_xyz", v3f32
7880b57cec5SDimitry Andric>;
7890b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZW : MUBUF_Pseudo_Loads <
7908bcb0991SDimitry Andric  "buffer_load_format_xyzw", v4f32
7910b57cec5SDimitry Andric>;
7920b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_X : MUBUF_Pseudo_Stores <
7938bcb0991SDimitry Andric  "buffer_store_format_x", f32
7940b57cec5SDimitry Andric>;
7950b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XY : MUBUF_Pseudo_Stores <
7968bcb0991SDimitry Andric  "buffer_store_format_xy", v2f32
7970b57cec5SDimitry Andric>;
7980b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZ : MUBUF_Pseudo_Stores <
7998bcb0991SDimitry Andric  "buffer_store_format_xyz", v3f32
8000b57cec5SDimitry Andric>;
8010b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZW : MUBUF_Pseudo_Stores <
8028bcb0991SDimitry Andric  "buffer_store_format_xyzw", v4f32
8030b57cec5SDimitry Andric>;
8040b57cec5SDimitry Andric
8050b57cec5SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem, D16Buf = 1 in {
8060b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_X_gfx80 : MUBUF_Pseudo_Loads <
8078bcb0991SDimitry Andric    "buffer_load_format_d16_x", i32
8080b57cec5SDimitry Andric  >;
8090b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XY_gfx80 : MUBUF_Pseudo_Loads <
8108bcb0991SDimitry Andric    "buffer_load_format_d16_xy", v2i32
8110b57cec5SDimitry Andric  >;
8120b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XYZ_gfx80 : MUBUF_Pseudo_Loads <
8138bcb0991SDimitry Andric    "buffer_load_format_d16_xyz", v3i32
8140b57cec5SDimitry Andric  >;
8150b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XYZW_gfx80 : MUBUF_Pseudo_Loads <
8168bcb0991SDimitry Andric   "buffer_load_format_d16_xyzw", v4i32
8170b57cec5SDimitry Andric  >;
8180b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_X_gfx80 : MUBUF_Pseudo_Stores <
8198bcb0991SDimitry Andric    "buffer_store_format_d16_x", i32
8200b57cec5SDimitry Andric  >;
8210b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XY_gfx80 : MUBUF_Pseudo_Stores <
8228bcb0991SDimitry Andric    "buffer_store_format_d16_xy", v2i32
8230b57cec5SDimitry Andric  >;
8240b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XYZ_gfx80 : MUBUF_Pseudo_Stores <
8258bcb0991SDimitry Andric    "buffer_store_format_d16_xyz", v3i32
8260b57cec5SDimitry Andric  >;
8270b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XYZW_gfx80 : MUBUF_Pseudo_Stores <
8288bcb0991SDimitry Andric    "buffer_store_format_d16_xyzw", v4i32
8290b57cec5SDimitry Andric  >;
8300b57cec5SDimitry Andric} // End HasUnpackedD16VMem.
8310b57cec5SDimitry Andric
8320b57cec5SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem, D16Buf = 1 in {
8330b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_X : MUBUF_Pseudo_Loads <
8348bcb0991SDimitry Andric    "buffer_load_format_d16_x", f16
8350b57cec5SDimitry Andric  >;
8360b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XY : MUBUF_Pseudo_Loads <
8378bcb0991SDimitry Andric    "buffer_load_format_d16_xy", v2f16
8380b57cec5SDimitry Andric  >;
8390b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XYZ : MUBUF_Pseudo_Loads <
8408bcb0991SDimitry Andric    "buffer_load_format_d16_xyz", v3f16
8410b57cec5SDimitry Andric  >;
8420b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XYZW : MUBUF_Pseudo_Loads <
8438bcb0991SDimitry Andric    "buffer_load_format_d16_xyzw", v4f16
8440b57cec5SDimitry Andric  >;
8450b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_X : MUBUF_Pseudo_Stores <
8468bcb0991SDimitry Andric    "buffer_store_format_d16_x", f16
8470b57cec5SDimitry Andric  >;
8480b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XY : MUBUF_Pseudo_Stores <
8498bcb0991SDimitry Andric    "buffer_store_format_d16_xy", v2f16
8500b57cec5SDimitry Andric  >;
8510b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XYZ : MUBUF_Pseudo_Stores <
8528bcb0991SDimitry Andric    "buffer_store_format_d16_xyz", v3f16
8530b57cec5SDimitry Andric  >;
8540b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XYZW : MUBUF_Pseudo_Stores <
8558bcb0991SDimitry Andric    "buffer_store_format_d16_xyzw", v4f16
8560b57cec5SDimitry Andric  >;
8570b57cec5SDimitry Andric} // End HasPackedD16VMem.
8580b57cec5SDimitry Andric
8590b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE : MUBUF_Pseudo_Loads_Lds <
8608bcb0991SDimitry Andric  "buffer_load_ubyte", i32
8610b57cec5SDimitry Andric>;
8620b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE : MUBUF_Pseudo_Loads_Lds <
8638bcb0991SDimitry Andric  "buffer_load_sbyte", i32
8640b57cec5SDimitry Andric>;
8650b57cec5SDimitry Andricdefm BUFFER_LOAD_USHORT : MUBUF_Pseudo_Loads_Lds <
8668bcb0991SDimitry Andric  "buffer_load_ushort", i32
8670b57cec5SDimitry Andric>;
8680b57cec5SDimitry Andricdefm BUFFER_LOAD_SSHORT : MUBUF_Pseudo_Loads_Lds <
8698bcb0991SDimitry Andric  "buffer_load_sshort", i32
8700b57cec5SDimitry Andric>;
8710b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORD : MUBUF_Pseudo_Loads_Lds <
8728bcb0991SDimitry Andric  "buffer_load_dword", i32
8730b57cec5SDimitry Andric>;
8740b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX2 : MUBUF_Pseudo_Loads <
8758bcb0991SDimitry Andric  "buffer_load_dwordx2", v2i32
8760b57cec5SDimitry Andric>;
8770b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX3 : MUBUF_Pseudo_Loads <
8788bcb0991SDimitry Andric  "buffer_load_dwordx3", v3i32
8790b57cec5SDimitry Andric>;
8800b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX4 : MUBUF_Pseudo_Loads <
8818bcb0991SDimitry Andric  "buffer_load_dwordx4", v4i32
8820b57cec5SDimitry Andric>;
8830b57cec5SDimitry Andric
8840b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_UBYTE", i32, extloadi8_global>;
8850b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_UBYTE", i32, zextloadi8_global>;
8860b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_SBYTE", i32, sextloadi8_global>;
8870b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_USHORT", i32, extloadi16_global>;
8880b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_USHORT", i32, zextloadi16_global>;
8890b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_SSHORT", i32, sextloadi16_global>;
8900b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_DWORD", i32, load_global>;
8910b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_DWORDX2", v2i32, load_global>;
8920b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_DWORDX3", v3i32, load_global>;
8930b57cec5SDimitry Andricdefm : MUBUF_Pseudo_Load_Pats<"BUFFER_LOAD_DWORDX4", v4i32, load_global>;
8940b57cec5SDimitry Andric
8950b57cec5SDimitry Andric// This is not described in AMD documentation,
8960b57cec5SDimitry Andric// but 'lds' versions of these opcodes are available
8970b57cec5SDimitry Andric// in at least GFX8+ chips. See Bug 37653.
8980b57cec5SDimitry Andriclet SubtargetPredicate = isGFX8GFX9 in {
8990b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX2_LDS : MUBUF_Pseudo_Loads <
9008bcb0991SDimitry Andric  "buffer_load_dwordx2", v2i32, null_frag, 0, 1
9010b57cec5SDimitry Andric>;
9020b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX3_LDS : MUBUF_Pseudo_Loads <
9038bcb0991SDimitry Andric  "buffer_load_dwordx3", v3i32, null_frag, 0, 1
9040b57cec5SDimitry Andric>;
9050b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX4_LDS : MUBUF_Pseudo_Loads <
9068bcb0991SDimitry Andric  "buffer_load_dwordx4", v4i32, null_frag, 0, 1
9070b57cec5SDimitry Andric>;
9080b57cec5SDimitry Andric}
9090b57cec5SDimitry Andric
9100b57cec5SDimitry Andricdefm BUFFER_STORE_BYTE : MUBUF_Pseudo_Stores <
9118bcb0991SDimitry Andric  "buffer_store_byte", i32, truncstorei8_global
9120b57cec5SDimitry Andric>;
9130b57cec5SDimitry Andricdefm BUFFER_STORE_SHORT : MUBUF_Pseudo_Stores <
9148bcb0991SDimitry Andric  "buffer_store_short", i32, truncstorei16_global
9150b57cec5SDimitry Andric>;
9160b57cec5SDimitry Andricdefm BUFFER_STORE_DWORD : MUBUF_Pseudo_Stores <
9178bcb0991SDimitry Andric  "buffer_store_dword", i32, store_global
9180b57cec5SDimitry Andric>;
9190b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX2 : MUBUF_Pseudo_Stores <
9208bcb0991SDimitry Andric  "buffer_store_dwordx2", v2i32, store_global
9210b57cec5SDimitry Andric>;
9220b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX3 : MUBUF_Pseudo_Stores <
9238bcb0991SDimitry Andric  "buffer_store_dwordx3", v3i32, store_global
9240b57cec5SDimitry Andric>;
9250b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX4 : MUBUF_Pseudo_Stores <
9268bcb0991SDimitry Andric  "buffer_store_dwordx4", v4i32, store_global
9270b57cec5SDimitry Andric>;
9280b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SWAP : MUBUF_Pseudo_Atomics <
9298bcb0991SDimitry Andric  "buffer_atomic_swap", VGPR_32, i32, atomic_swap_global_32
9300b57cec5SDimitry Andric>;
9310b57cec5SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP : MUBUF_Pseudo_Atomics <
9320b57cec5SDimitry Andric  "buffer_atomic_cmpswap", VReg_64, v2i32, null_frag
9330b57cec5SDimitry Andric>;
9340b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD : MUBUF_Pseudo_Atomics <
9358bcb0991SDimitry Andric  "buffer_atomic_add", VGPR_32, i32, atomic_load_add_global_32
9360b57cec5SDimitry Andric>;
9370b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SUB : MUBUF_Pseudo_Atomics <
9388bcb0991SDimitry Andric  "buffer_atomic_sub", VGPR_32, i32, atomic_load_sub_global_32
9390b57cec5SDimitry Andric>;
9400b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMIN : MUBUF_Pseudo_Atomics <
9418bcb0991SDimitry Andric  "buffer_atomic_smin", VGPR_32, i32, atomic_load_min_global_32
9420b57cec5SDimitry Andric>;
9430b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMIN : MUBUF_Pseudo_Atomics <
9448bcb0991SDimitry Andric  "buffer_atomic_umin", VGPR_32, i32, atomic_load_umin_global_32
9450b57cec5SDimitry Andric>;
9460b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMAX : MUBUF_Pseudo_Atomics <
9478bcb0991SDimitry Andric  "buffer_atomic_smax", VGPR_32, i32, atomic_load_max_global_32
9480b57cec5SDimitry Andric>;
9490b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMAX : MUBUF_Pseudo_Atomics <
9508bcb0991SDimitry Andric  "buffer_atomic_umax", VGPR_32, i32, atomic_load_umax_global_32
9510b57cec5SDimitry Andric>;
9520b57cec5SDimitry Andricdefm BUFFER_ATOMIC_AND : MUBUF_Pseudo_Atomics <
9538bcb0991SDimitry Andric  "buffer_atomic_and", VGPR_32, i32, atomic_load_and_global_32
9540b57cec5SDimitry Andric>;
9550b57cec5SDimitry Andricdefm BUFFER_ATOMIC_OR : MUBUF_Pseudo_Atomics <
9568bcb0991SDimitry Andric  "buffer_atomic_or", VGPR_32, i32, atomic_load_or_global_32
9570b57cec5SDimitry Andric>;
9580b57cec5SDimitry Andricdefm BUFFER_ATOMIC_XOR : MUBUF_Pseudo_Atomics <
9598bcb0991SDimitry Andric  "buffer_atomic_xor", VGPR_32, i32, atomic_load_xor_global_32
9600b57cec5SDimitry Andric>;
9610b57cec5SDimitry Andricdefm BUFFER_ATOMIC_INC : MUBUF_Pseudo_Atomics <
9628bcb0991SDimitry Andric  "buffer_atomic_inc", VGPR_32, i32, atomic_inc_global_32
9630b57cec5SDimitry Andric>;
9640b57cec5SDimitry Andricdefm BUFFER_ATOMIC_DEC : MUBUF_Pseudo_Atomics <
9658bcb0991SDimitry Andric  "buffer_atomic_dec", VGPR_32, i32, atomic_dec_global_32
9660b57cec5SDimitry Andric>;
9670b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SWAP_X2 : MUBUF_Pseudo_Atomics <
9688bcb0991SDimitry Andric  "buffer_atomic_swap_x2", VReg_64, i64, atomic_swap_global_64
9690b57cec5SDimitry Andric>;
9700b57cec5SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP_X2 : MUBUF_Pseudo_Atomics <
9710b57cec5SDimitry Andric  "buffer_atomic_cmpswap_x2", VReg_128, v2i64, null_frag
9720b57cec5SDimitry Andric>;
9730b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD_X2 : MUBUF_Pseudo_Atomics <
9748bcb0991SDimitry Andric  "buffer_atomic_add_x2", VReg_64, i64, atomic_load_add_global_64
9750b57cec5SDimitry Andric>;
9760b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SUB_X2 : MUBUF_Pseudo_Atomics <
9778bcb0991SDimitry Andric  "buffer_atomic_sub_x2", VReg_64, i64, atomic_load_sub_global_64
9780b57cec5SDimitry Andric>;
9790b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMIN_X2 : MUBUF_Pseudo_Atomics <
9808bcb0991SDimitry Andric  "buffer_atomic_smin_x2", VReg_64, i64, atomic_load_min_global_64
9810b57cec5SDimitry Andric>;
9820b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMIN_X2 : MUBUF_Pseudo_Atomics <
9838bcb0991SDimitry Andric  "buffer_atomic_umin_x2", VReg_64, i64, atomic_load_umin_global_64
9840b57cec5SDimitry Andric>;
9850b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMAX_X2 : MUBUF_Pseudo_Atomics <
9868bcb0991SDimitry Andric  "buffer_atomic_smax_x2", VReg_64, i64, atomic_load_max_global_64
9870b57cec5SDimitry Andric>;
9880b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMAX_X2 : MUBUF_Pseudo_Atomics <
9898bcb0991SDimitry Andric  "buffer_atomic_umax_x2", VReg_64, i64, atomic_load_umax_global_64
9900b57cec5SDimitry Andric>;
9910b57cec5SDimitry Andricdefm BUFFER_ATOMIC_AND_X2 : MUBUF_Pseudo_Atomics <
9928bcb0991SDimitry Andric  "buffer_atomic_and_x2", VReg_64, i64, atomic_load_and_global_64
9930b57cec5SDimitry Andric>;
9940b57cec5SDimitry Andricdefm BUFFER_ATOMIC_OR_X2 : MUBUF_Pseudo_Atomics <
9958bcb0991SDimitry Andric  "buffer_atomic_or_x2", VReg_64, i64, atomic_load_or_global_64
9960b57cec5SDimitry Andric>;
9970b57cec5SDimitry Andricdefm BUFFER_ATOMIC_XOR_X2 : MUBUF_Pseudo_Atomics <
9988bcb0991SDimitry Andric  "buffer_atomic_xor_x2", VReg_64, i64, atomic_load_xor_global_64
9990b57cec5SDimitry Andric>;
10000b57cec5SDimitry Andricdefm BUFFER_ATOMIC_INC_X2 : MUBUF_Pseudo_Atomics <
10018bcb0991SDimitry Andric  "buffer_atomic_inc_x2", VReg_64, i64, atomic_inc_global_64
10020b57cec5SDimitry Andric>;
10030b57cec5SDimitry Andricdefm BUFFER_ATOMIC_DEC_X2 : MUBUF_Pseudo_Atomics <
10048bcb0991SDimitry Andric  "buffer_atomic_dec_x2", VReg_64, i64, atomic_dec_global_64
10050b57cec5SDimitry Andric>;
10060b57cec5SDimitry Andric
1007*5ffd83dbSDimitry Andriclet SubtargetPredicate = HasGFX10_BEncoding in
1008*5ffd83dbSDimitry Andricdefm BUFFER_ATOMIC_CSUB : MUBUF_Pseudo_Atomics_RTN <
1009*5ffd83dbSDimitry Andric  "buffer_atomic_csub", VGPR_32, i32, atomic_csub_global_32
1010*5ffd83dbSDimitry Andric>;
1011*5ffd83dbSDimitry Andric
10120b57cec5SDimitry Andriclet SubtargetPredicate = isGFX8GFX9 in {
10130b57cec5SDimitry Andricdef BUFFER_STORE_LDS_DWORD : MUBUF_Pseudo_Store_Lds <"buffer_store_lds_dword">;
10140b57cec5SDimitry Andric}
10150b57cec5SDimitry Andric
10160b57cec5SDimitry Andriclet SubtargetPredicate = isGFX6 in { // isn't on CI & VI
10170b57cec5SDimitry Andric/*
10180b57cec5SDimitry Andricdefm BUFFER_ATOMIC_RSUB        : MUBUF_Pseudo_Atomics <"buffer_atomic_rsub">;
10190b57cec5SDimitry Andricdefm BUFFER_ATOMIC_RSUB_X2     : MUBUF_Pseudo_Atomics <"buffer_atomic_rsub_x2">;
10200b57cec5SDimitry Andric*/
10210b57cec5SDimitry Andric
10220b57cec5SDimitry Andricdef BUFFER_WBINVL1_SC : MUBUF_Invalidate <"buffer_wbinvl1_sc",
10230b57cec5SDimitry Andric                                          int_amdgcn_buffer_wbinvl1_sc>;
10240b57cec5SDimitry Andric}
10250b57cec5SDimitry Andric
10268bcb0991SDimitry Andriclet SubtargetPredicate = isGFX6GFX7GFX10 in {
10278bcb0991SDimitry Andric
10288bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FCMPSWAP : MUBUF_Pseudo_Atomics <
10298bcb0991SDimitry Andric  "buffer_atomic_fcmpswap", VReg_64, v2f32, null_frag
10308bcb0991SDimitry Andric>;
10318bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMIN : MUBUF_Pseudo_Atomics <
10328bcb0991SDimitry Andric  "buffer_atomic_fmin", VGPR_32, f32, null_frag
10338bcb0991SDimitry Andric>;
10348bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMAX : MUBUF_Pseudo_Atomics <
10358bcb0991SDimitry Andric  "buffer_atomic_fmax", VGPR_32, f32, null_frag
10368bcb0991SDimitry Andric>;
10378bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FCMPSWAP_X2 : MUBUF_Pseudo_Atomics <
10388bcb0991SDimitry Andric  "buffer_atomic_fcmpswap_x2", VReg_128, v2f64, null_frag
10398bcb0991SDimitry Andric>;
10408bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMIN_X2 : MUBUF_Pseudo_Atomics <
10418bcb0991SDimitry Andric  "buffer_atomic_fmin_x2", VReg_64, f64, null_frag
10428bcb0991SDimitry Andric>;
10438bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMAX_X2 : MUBUF_Pseudo_Atomics <
10448bcb0991SDimitry Andric  "buffer_atomic_fmax_x2", VReg_64, f64, null_frag
10458bcb0991SDimitry Andric>;
10468bcb0991SDimitry Andric
10478bcb0991SDimitry Andric}
10488bcb0991SDimitry Andric
10490b57cec5SDimitry Andriclet SubtargetPredicate = HasD16LoadStore in {
10500b57cec5SDimitry Andric
10510b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16 : MUBUF_Pseudo_Loads <
10528bcb0991SDimitry Andric  "buffer_load_ubyte_d16", i32, null_frag, 1
10530b57cec5SDimitry Andric>;
10540b57cec5SDimitry Andric
10550b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16_HI : MUBUF_Pseudo_Loads <
10568bcb0991SDimitry Andric  "buffer_load_ubyte_d16_hi", i32, null_frag, 1
10570b57cec5SDimitry Andric>;
10580b57cec5SDimitry Andric
10590b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16 : MUBUF_Pseudo_Loads <
10608bcb0991SDimitry Andric  "buffer_load_sbyte_d16", i32, null_frag, 1
10610b57cec5SDimitry Andric>;
10620b57cec5SDimitry Andric
10630b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16_HI : MUBUF_Pseudo_Loads <
10648bcb0991SDimitry Andric  "buffer_load_sbyte_d16_hi", i32, null_frag, 1
10650b57cec5SDimitry Andric>;
10660b57cec5SDimitry Andric
10670b57cec5SDimitry Andricdefm BUFFER_LOAD_SHORT_D16 : MUBUF_Pseudo_Loads <
10688bcb0991SDimitry Andric  "buffer_load_short_d16", i32, null_frag, 1
10690b57cec5SDimitry Andric>;
10700b57cec5SDimitry Andric
10710b57cec5SDimitry Andricdefm BUFFER_LOAD_SHORT_D16_HI : MUBUF_Pseudo_Loads <
10728bcb0991SDimitry Andric  "buffer_load_short_d16_hi", i32, null_frag, 1
10730b57cec5SDimitry Andric>;
10740b57cec5SDimitry Andric
10750b57cec5SDimitry Andricdefm BUFFER_STORE_BYTE_D16_HI : MUBUF_Pseudo_Stores <
10768bcb0991SDimitry Andric  "buffer_store_byte_d16_hi", i32
10770b57cec5SDimitry Andric>;
10780b57cec5SDimitry Andric
10790b57cec5SDimitry Andricdefm BUFFER_STORE_SHORT_D16_HI : MUBUF_Pseudo_Stores <
10808bcb0991SDimitry Andric  "buffer_store_short_d16_hi", i32
10810b57cec5SDimitry Andric>;
10820b57cec5SDimitry Andric
10830b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_HI_X : MUBUF_Pseudo_Loads <
10848bcb0991SDimitry Andric  "buffer_load_format_d16_hi_x", i32
10850b57cec5SDimitry Andric>;
10860b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_HI_X : MUBUF_Pseudo_Stores <
10878bcb0991SDimitry Andric  "buffer_store_format_d16_hi_x", i32
10880b57cec5SDimitry Andric>;
10890b57cec5SDimitry Andric
10900b57cec5SDimitry Andric} // End HasD16LoadStore
10910b57cec5SDimitry Andric
10920b57cec5SDimitry Andricdef BUFFER_WBINVL1 : MUBUF_Invalidate <"buffer_wbinvl1",
10930b57cec5SDimitry Andric                                       int_amdgcn_buffer_wbinvl1>;
10940b57cec5SDimitry Andric
10950b57cec5SDimitry Andriclet SubtargetPredicate = HasAtomicFaddInsts in {
10960b57cec5SDimitry Andric
10970b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD_F32 : MUBUF_Pseudo_Atomics_NO_RTN <
10988bcb0991SDimitry Andric  "buffer_atomic_add_f32", VGPR_32, f32, atomic_fadd_global_noret
10990b57cec5SDimitry Andric>;
11000b57cec5SDimitry Andricdefm BUFFER_ATOMIC_PK_ADD_F16 : MUBUF_Pseudo_Atomics_NO_RTN <
11018bcb0991SDimitry Andric  "buffer_atomic_pk_add_f16", VGPR_32, v2f16, atomic_pk_fadd_global_noret
11020b57cec5SDimitry Andric>;
11030b57cec5SDimitry Andric
11040b57cec5SDimitry Andric} // End SubtargetPredicate = HasAtomicFaddInsts
11050b57cec5SDimitry Andric
11060b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
11070b57cec5SDimitry Andric// MTBUF Instructions
11080b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
11090b57cec5SDimitry Andric
11108bcb0991SDimitry Andricdefm TBUFFER_LOAD_FORMAT_X     : MTBUF_Pseudo_Loads  <"tbuffer_load_format_x",     VGPR_32,  1>;
11118bcb0991SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XY    : MTBUF_Pseudo_Loads  <"tbuffer_load_format_xy",    VReg_64,  2>;
11128bcb0991SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZ   : MTBUF_Pseudo_Loads  <"tbuffer_load_format_xyz",   VReg_96,  3>;
11138bcb0991SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZW  : MTBUF_Pseudo_Loads  <"tbuffer_load_format_xyzw",  VReg_128, 4>;
11148bcb0991SDimitry Andricdefm TBUFFER_STORE_FORMAT_X    : MTBUF_Pseudo_Stores <"tbuffer_store_format_x",    VGPR_32,  1>;
11158bcb0991SDimitry Andricdefm TBUFFER_STORE_FORMAT_XY   : MTBUF_Pseudo_Stores <"tbuffer_store_format_xy",   VReg_64,  2>;
11168bcb0991SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZ  : MTBUF_Pseudo_Stores <"tbuffer_store_format_xyz",  VReg_96,  3>;
11178bcb0991SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZW : MTBUF_Pseudo_Stores <"tbuffer_store_format_xyzw", VReg_128, 4>;
11180b57cec5SDimitry Andric
11190b57cec5SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem, D16Buf = 1 in {
11208bcb0991SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_X_gfx80     : MTBUF_Pseudo_Loads  <"tbuffer_load_format_d16_x",     VGPR_32,  1>;
11218bcb0991SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XY_gfx80    : MTBUF_Pseudo_Loads  <"tbuffer_load_format_d16_xy",    VReg_64,  2>;
11228bcb0991SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XYZ_gfx80   : MTBUF_Pseudo_Loads  <"tbuffer_load_format_d16_xyz",   VReg_96,  3>;
11238bcb0991SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XYZW_gfx80  : MTBUF_Pseudo_Loads  <"tbuffer_load_format_d16_xyzw",  VReg_128, 4>;
11248bcb0991SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_X_gfx80    : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_x",    VGPR_32,  1>;
11258bcb0991SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XY_gfx80   : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xy",   VReg_64,  2>;
11268bcb0991SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XYZ_gfx80  : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xyz",  VReg_96,  3>;
11278bcb0991SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XYZW_gfx80 : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xyzw", VReg_128, 4>;
11280b57cec5SDimitry Andric} // End HasUnpackedD16VMem.
11290b57cec5SDimitry Andric
11300b57cec5SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem, D16Buf = 1 in {
11318bcb0991SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_X     : MTBUF_Pseudo_Loads  <"tbuffer_load_format_d16_x",     VGPR_32, 1>;
11328bcb0991SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XY    : MTBUF_Pseudo_Loads  <"tbuffer_load_format_d16_xy",    VGPR_32, 2>;
11338bcb0991SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XYZ   : MTBUF_Pseudo_Loads  <"tbuffer_load_format_d16_xyz",   VReg_64, 3>;
11348bcb0991SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XYZW  : MTBUF_Pseudo_Loads  <"tbuffer_load_format_d16_xyzw",  VReg_64, 4>;
11358bcb0991SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_X    : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_x",    VGPR_32, 1>;
11368bcb0991SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XY   : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xy",   VGPR_32, 2>;
11378bcb0991SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XYZ  : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xyz",  VReg_64, 3>;
11388bcb0991SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XYZW : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xyzw", VReg_64, 4>;
11390b57cec5SDimitry Andric} // End HasPackedD16VMem.
11400b57cec5SDimitry Andric
11410b57cec5SDimitry Andriclet SubtargetPredicate = isGFX7Plus in {
11420b57cec5SDimitry Andric
11430b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
11440b57cec5SDimitry Andric// Instruction definitions for CI and newer.
11450b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
11460b57cec5SDimitry Andric
11470b57cec5SDimitry Andricdef BUFFER_WBINVL1_VOL : MUBUF_Invalidate <"buffer_wbinvl1_vol",
11480b57cec5SDimitry Andric                                           int_amdgcn_buffer_wbinvl1_vol>;
11490b57cec5SDimitry Andric
11500b57cec5SDimitry Andric} // End let SubtargetPredicate = isGFX7Plus
11510b57cec5SDimitry Andric
11520b57cec5SDimitry Andriclet SubtargetPredicate = isGFX10Plus in {
11530b57cec5SDimitry Andric  def BUFFER_GL0_INV : MUBUF_Invalidate<"buffer_gl0_inv">;
11540b57cec5SDimitry Andric  def BUFFER_GL1_INV : MUBUF_Invalidate<"buffer_gl1_inv">;
11550b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX10Plus
11560b57cec5SDimitry Andric
11570b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
11580b57cec5SDimitry Andric// MUBUF Patterns
11590b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
11600b57cec5SDimitry Andric
11610b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
11620b57cec5SDimitry Andric// buffer_load/store_format patterns
11630b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
11640b57cec5SDimitry Andric
11650b57cec5SDimitry Andricmulticlass MUBUF_LoadIntrinsicPat<SDPatternOperator name, ValueType vt,
11660b57cec5SDimitry Andric                                  string opcode> {
11670b57cec5SDimitry Andric  def : GCNPat<
11688bcb0991SDimitry Andric    (vt (name v4i32:$rsrc, 0, 0, i32:$soffset, timm:$offset,
11698bcb0991SDimitry Andric              timm:$auxiliary, 0)),
1170*5ffd83dbSDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _OFFSET) SReg_128:$rsrc, SCSrc_b32:$soffset, (as_i16timm $offset),
11718bcb0991SDimitry Andric      (extract_glc $auxiliary), (extract_slc $auxiliary), 0, (extract_dlc $auxiliary),
11728bcb0991SDimitry Andric      (extract_swz $auxiliary))
11730b57cec5SDimitry Andric  >;
11740b57cec5SDimitry Andric
11750b57cec5SDimitry Andric  def : GCNPat<
11768bcb0991SDimitry Andric    (vt (name v4i32:$rsrc, 0, i32:$voffset, i32:$soffset, timm:$offset,
11778bcb0991SDimitry Andric              timm:$auxiliary, 0)),
1178*5ffd83dbSDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _OFFEN) VGPR_32:$voffset, SReg_128:$rsrc, SCSrc_b32:$soffset, (as_i16timm $offset),
11798bcb0991SDimitry Andric      (extract_glc $auxiliary), (extract_slc $auxiliary), 0, (extract_dlc $auxiliary),
11808bcb0991SDimitry Andric      (extract_swz $auxiliary))
11810b57cec5SDimitry Andric  >;
11820b57cec5SDimitry Andric
11830b57cec5SDimitry Andric  def : GCNPat<
11848bcb0991SDimitry Andric    (vt (name v4i32:$rsrc, i32:$vindex, 0, i32:$soffset, timm:$offset,
11858bcb0991SDimitry Andric              timm:$auxiliary, timm)),
1186*5ffd83dbSDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _IDXEN) VGPR_32:$vindex, SReg_128:$rsrc, SCSrc_b32:$soffset, (as_i16timm $offset),
11878bcb0991SDimitry Andric      (extract_glc $auxiliary), (extract_slc $auxiliary), 0, (extract_dlc $auxiliary),
11888bcb0991SDimitry Andric      (extract_swz $auxiliary))
11890b57cec5SDimitry Andric  >;
11900b57cec5SDimitry Andric
11910b57cec5SDimitry Andric  def : GCNPat<
11928bcb0991SDimitry Andric    (vt (name v4i32:$rsrc, i32:$vindex, i32:$voffset, i32:$soffset, timm:$offset,
11938bcb0991SDimitry Andric              timm:$auxiliary, timm)),
11940b57cec5SDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _BOTHEN)
1195*5ffd83dbSDimitry Andric      (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1),
1196*5ffd83dbSDimitry Andric      SReg_128:$rsrc, SCSrc_b32:$soffset, (as_i16timm $offset),
11978bcb0991SDimitry Andric      (extract_glc $auxiliary), (extract_slc $auxiliary), 0, (extract_dlc $auxiliary),
11988bcb0991SDimitry Andric      (extract_swz $auxiliary))
11990b57cec5SDimitry Andric  >;
12000b57cec5SDimitry Andric}
12010b57cec5SDimitry Andric
12020b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, f32, "BUFFER_LOAD_FORMAT_X">;
12030b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, i32, "BUFFER_LOAD_FORMAT_X">;
12040b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v2f32, "BUFFER_LOAD_FORMAT_XY">;
12050b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v2i32, "BUFFER_LOAD_FORMAT_XY">;
12060b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v3f32, "BUFFER_LOAD_FORMAT_XYZ">;
12070b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v3i32, "BUFFER_LOAD_FORMAT_XYZ">;
12080b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v4f32, "BUFFER_LOAD_FORMAT_XYZW">;
12090b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v4i32, "BUFFER_LOAD_FORMAT_XYZW">;
12100b57cec5SDimitry Andric
12110b57cec5SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem in {
12120b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, f16, "BUFFER_LOAD_FORMAT_D16_X_gfx80">;
12130b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, i16, "BUFFER_LOAD_FORMAT_D16_X_gfx80">;
1214*5ffd83dbSDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, i32, "BUFFER_LOAD_FORMAT_D16_X_gfx80">;
12150b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v2i32, "BUFFER_LOAD_FORMAT_D16_XY_gfx80">;
12160b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v4i32, "BUFFER_LOAD_FORMAT_D16_XYZW_gfx80">;
12170b57cec5SDimitry Andric} // End HasUnpackedD16VMem.
12180b57cec5SDimitry Andric
12190b57cec5SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem in {
12200b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, f16, "BUFFER_LOAD_FORMAT_D16_X">;
12210b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, i16, "BUFFER_LOAD_FORMAT_D16_X">;
1222*5ffd83dbSDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, i32, "BUFFER_LOAD_FORMAT_D16_X">;
12230b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v2f16, "BUFFER_LOAD_FORMAT_D16_XY">;
12240b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v2i16, "BUFFER_LOAD_FORMAT_D16_XY">;
12250b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v4f16, "BUFFER_LOAD_FORMAT_D16_XYZW">;
12260b57cec5SDimitry Andric  defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v4i16, "BUFFER_LOAD_FORMAT_D16_XYZW">;
12270b57cec5SDimitry Andric} // End HasPackedD16VMem.
12280b57cec5SDimitry Andric
12290b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, f32, "BUFFER_LOAD_DWORD">;
12300b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, i32, "BUFFER_LOAD_DWORD">;
12318bcb0991SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v2i16, "BUFFER_LOAD_DWORD">;
12328bcb0991SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v2f16, "BUFFER_LOAD_DWORD">;
12330b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v2f32, "BUFFER_LOAD_DWORDX2">;
12340b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v2i32, "BUFFER_LOAD_DWORDX2">;
12358bcb0991SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v4i16, "BUFFER_LOAD_DWORDX2">;
12368bcb0991SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v4f16, "BUFFER_LOAD_DWORDX2">;
12370b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v3f32, "BUFFER_LOAD_DWORDX3">;
12380b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v3i32, "BUFFER_LOAD_DWORDX3">;
12390b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v4f32, "BUFFER_LOAD_DWORDX4">;
12400b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v4i32, "BUFFER_LOAD_DWORDX4">;
12410b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_byte, i32, "BUFFER_LOAD_SBYTE">;
12420b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_short, i32, "BUFFER_LOAD_SSHORT">;
12430b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_ubyte, i32, "BUFFER_LOAD_UBYTE">;
12440b57cec5SDimitry Andricdefm : MUBUF_LoadIntrinsicPat<SIbuffer_load_ushort,  i32, "BUFFER_LOAD_USHORT">;
12450b57cec5SDimitry Andric
12460b57cec5SDimitry Andricmulticlass MUBUF_StoreIntrinsicPat<SDPatternOperator name, ValueType vt,
12470b57cec5SDimitry Andric                                   string opcode> {
12480b57cec5SDimitry Andric  def : GCNPat<
12498bcb0991SDimitry Andric    (name vt:$vdata, v4i32:$rsrc, 0, 0, i32:$soffset, timm:$offset,
12508bcb0991SDimitry Andric              timm:$auxiliary, 0),
1251*5ffd83dbSDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _OFFSET_exact) getVregSrcForVT<vt>.ret:$vdata, SReg_128:$rsrc, SCSrc_b32:$soffset, (as_i16timm $offset),
12528bcb0991SDimitry Andric      (extract_glc $auxiliary), (extract_slc $auxiliary), 0,  (extract_dlc $auxiliary),
12538bcb0991SDimitry Andric      (extract_swz $auxiliary))
12540b57cec5SDimitry Andric  >;
12550b57cec5SDimitry Andric
12560b57cec5SDimitry Andric  def : GCNPat<
12578bcb0991SDimitry Andric    (name vt:$vdata, v4i32:$rsrc, 0, i32:$voffset, i32:$soffset, timm:$offset,
12588bcb0991SDimitry Andric              timm:$auxiliary, 0),
1259*5ffd83dbSDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _OFFEN_exact) getVregSrcForVT<vt>.ret:$vdata, VGPR_32:$voffset, SReg_128:$rsrc, SCSrc_b32:$soffset,
1260*5ffd83dbSDimitry Andric      (as_i16timm $offset), (extract_glc $auxiliary),
12618bcb0991SDimitry Andric      (extract_slc $auxiliary), 0,  (extract_dlc $auxiliary),
12628bcb0991SDimitry Andric      (extract_swz $auxiliary))
12630b57cec5SDimitry Andric  >;
12640b57cec5SDimitry Andric
12650b57cec5SDimitry Andric  def : GCNPat<
12668bcb0991SDimitry Andric    (name vt:$vdata, v4i32:$rsrc, i32:$vindex, 0, i32:$soffset, timm:$offset,
12678bcb0991SDimitry Andric              timm:$auxiliary, timm),
1268*5ffd83dbSDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _IDXEN_exact) getVregSrcForVT<vt>.ret:$vdata, VGPR_32:$vindex, SReg_128:$rsrc, SCSrc_b32:$soffset,
1269*5ffd83dbSDimitry Andric      (as_i16timm $offset), (extract_glc $auxiliary),
12708bcb0991SDimitry Andric      (extract_slc $auxiliary), 0,  (extract_dlc $auxiliary),
12718bcb0991SDimitry Andric      (extract_swz $auxiliary))
12720b57cec5SDimitry Andric  >;
12730b57cec5SDimitry Andric
12740b57cec5SDimitry Andric  def : GCNPat<
12758bcb0991SDimitry Andric    (name vt:$vdata, v4i32:$rsrc, i32:$vindex, i32:$voffset, i32:$soffset, timm:$offset,
12768bcb0991SDimitry Andric              timm:$auxiliary, timm),
12770b57cec5SDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _BOTHEN_exact)
1278*5ffd83dbSDimitry Andric      getVregSrcForVT<vt>.ret:$vdata,
1279*5ffd83dbSDimitry Andric      (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1),
1280*5ffd83dbSDimitry Andric      SReg_128:$rsrc, SCSrc_b32:$soffset, (as_i16timm $offset), (extract_glc $auxiliary),
12818bcb0991SDimitry Andric      (extract_slc $auxiliary), 0,  (extract_dlc $auxiliary),
12828bcb0991SDimitry Andric      (extract_swz $auxiliary))
12830b57cec5SDimitry Andric  >;
12840b57cec5SDimitry Andric}
12850b57cec5SDimitry Andric
12860b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, f32, "BUFFER_STORE_FORMAT_X">;
12870b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, i32, "BUFFER_STORE_FORMAT_X">;
12880b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v2f32, "BUFFER_STORE_FORMAT_XY">;
12890b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v2i32, "BUFFER_STORE_FORMAT_XY">;
12900b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v3f32, "BUFFER_STORE_FORMAT_XYZ">;
12910b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v3i32, "BUFFER_STORE_FORMAT_XYZ">;
12920b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v4f32, "BUFFER_STORE_FORMAT_XYZW">;
12930b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v4i32, "BUFFER_STORE_FORMAT_XYZW">;
12940b57cec5SDimitry Andric
12950b57cec5SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem in {
12960b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, f16, "BUFFER_STORE_FORMAT_D16_X_gfx80">;
12970b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, i16, "BUFFER_STORE_FORMAT_D16_X_gfx80">;
1298*5ffd83dbSDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, i32, "BUFFER_STORE_FORMAT_D16_X_gfx80">;
12990b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v2i32, "BUFFER_STORE_FORMAT_D16_XY_gfx80">;
13000b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v4i32, "BUFFER_STORE_FORMAT_D16_XYZW_gfx80">;
13010b57cec5SDimitry Andric} // End HasUnpackedD16VMem.
13020b57cec5SDimitry Andric
13030b57cec5SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem in {
13040b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, f16, "BUFFER_STORE_FORMAT_D16_X">;
13050b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, i16, "BUFFER_STORE_FORMAT_D16_X">;
1306*5ffd83dbSDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, i32, "BUFFER_STORE_FORMAT_D16_X">;
13070b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v2f16, "BUFFER_STORE_FORMAT_D16_XY">;
13080b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v2i16, "BUFFER_STORE_FORMAT_D16_XY">;
13090b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v4f16, "BUFFER_STORE_FORMAT_D16_XYZW">;
13100b57cec5SDimitry Andric  defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v4i16, "BUFFER_STORE_FORMAT_D16_XYZW">;
13110b57cec5SDimitry Andric} // End HasPackedD16VMem.
13120b57cec5SDimitry Andric
13130b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, f32, "BUFFER_STORE_DWORD">;
13140b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, i32, "BUFFER_STORE_DWORD">;
13158bcb0991SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v2i16, "BUFFER_STORE_DWORD">;
13168bcb0991SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v2f16, "BUFFER_STORE_DWORD">;
13170b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v2f32, "BUFFER_STORE_DWORDX2">;
13180b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v2i32, "BUFFER_STORE_DWORDX2">;
13198bcb0991SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v4i16, "BUFFER_STORE_DWORDX2">;
13208bcb0991SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v4f16, "BUFFER_STORE_DWORDX2">;
13210b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v3f32, "BUFFER_STORE_DWORDX3">;
13220b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v3i32, "BUFFER_STORE_DWORDX3">;
13230b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v4f32, "BUFFER_STORE_DWORDX4">;
13240b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v4i32, "BUFFER_STORE_DWORDX4">;
13250b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_byte, i32, "BUFFER_STORE_BYTE">;
13260b57cec5SDimitry Andricdefm : MUBUF_StoreIntrinsicPat<SIbuffer_store_short, i32, "BUFFER_STORE_SHORT">;
13270b57cec5SDimitry Andric
13280b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
13290b57cec5SDimitry Andric// buffer_atomic patterns
13300b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
13310b57cec5SDimitry Andric
13320b57cec5SDimitry Andricmulticlass BufferAtomicPatterns<SDPatternOperator name, ValueType vt,
13330b57cec5SDimitry Andric                                string opcode> {
13340b57cec5SDimitry Andric  def : GCNPat<
1335*5ffd83dbSDimitry Andric    (vt (name vt:$vdata_in, v4i32:$rsrc, 0, 0, i32:$soffset,
1336*5ffd83dbSDimitry Andric              timm:$offset, timm:$cachepolicy, 0)),
1337*5ffd83dbSDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _OFFSET_RTN)
1338*5ffd83dbSDimitry Andric      getVregSrcForVT<vt>.ret:$vdata_in, SReg_128:$rsrc, SCSrc_b32:$soffset,
1339*5ffd83dbSDimitry Andric      (as_i16timm $offset), (extract_slc $cachepolicy))
13400b57cec5SDimitry Andric  >;
13410b57cec5SDimitry Andric
13420b57cec5SDimitry Andric  def : GCNPat<
1343*5ffd83dbSDimitry Andric    (vt (name vt:$vdata_in, v4i32:$rsrc, i32:$vindex, 0, i32:$soffset,
1344*5ffd83dbSDimitry Andric              timm:$offset, timm:$cachepolicy, timm)),
1345*5ffd83dbSDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _IDXEN_RTN) getVregSrcForVT<vt>.ret:$vdata_in,
1346*5ffd83dbSDimitry Andric      VGPR_32:$vindex, SReg_128:$rsrc, SCSrc_b32:$soffset,
1347*5ffd83dbSDimitry Andric      (as_i16timm $offset), (extract_slc $cachepolicy))
13480b57cec5SDimitry Andric  >;
13490b57cec5SDimitry Andric
13500b57cec5SDimitry Andric  def : GCNPat<
1351*5ffd83dbSDimitry Andric    (vt (name vt:$vdata_in, v4i32:$rsrc, 0, i32:$voffset,
1352*5ffd83dbSDimitry Andric              i32:$soffset, timm:$offset, timm:$cachepolicy, 0)),
1353*5ffd83dbSDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _OFFEN_RTN) getVregSrcForVT<vt>.ret:$vdata_in,
1354*5ffd83dbSDimitry Andric      VGPR_32:$voffset, SReg_128:$rsrc, SCSrc_b32:$soffset,
1355*5ffd83dbSDimitry Andric      (as_i16timm $offset), (extract_slc $cachepolicy))
13560b57cec5SDimitry Andric  >;
13570b57cec5SDimitry Andric
13580b57cec5SDimitry Andric  def : GCNPat<
1359*5ffd83dbSDimitry Andric    (vt (name vt:$vdata_in, v4i32:$rsrc, i32:$vindex, i32:$voffset,
1360*5ffd83dbSDimitry Andric              i32:$soffset, timm:$offset, timm:$cachepolicy, timm)),
13610b57cec5SDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _BOTHEN_RTN)
1362*5ffd83dbSDimitry Andric      getVregSrcForVT<vt>.ret:$vdata_in,
1363*5ffd83dbSDimitry Andric      (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1),
1364*5ffd83dbSDimitry Andric        SReg_128:$rsrc, SCSrc_b32:$soffset, (as_i16timm $offset),
1365*5ffd83dbSDimitry Andric        (extract_slc $cachepolicy))
13660b57cec5SDimitry Andric  >;
13670b57cec5SDimitry Andric}
13680b57cec5SDimitry Andric
13690b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_swap, i32, "BUFFER_ATOMIC_SWAP">;
13700b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_add, i32, "BUFFER_ATOMIC_ADD">;
13710b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_sub, i32, "BUFFER_ATOMIC_SUB">;
13720b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_smin, i32, "BUFFER_ATOMIC_SMIN">;
13730b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_umin, i32, "BUFFER_ATOMIC_UMIN">;
13740b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_smax, i32, "BUFFER_ATOMIC_SMAX">;
13750b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_umax, i32, "BUFFER_ATOMIC_UMAX">;
13760b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_and, i32, "BUFFER_ATOMIC_AND">;
13770b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_or, i32, "BUFFER_ATOMIC_OR">;
13780b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_xor, i32, "BUFFER_ATOMIC_XOR">;
13798bcb0991SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_inc, i32, "BUFFER_ATOMIC_INC">;
13808bcb0991SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_dec, i32, "BUFFER_ATOMIC_DEC">;
1381*5ffd83dbSDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_csub, i32, "BUFFER_ATOMIC_CSUB">;
13820b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_swap, i64, "BUFFER_ATOMIC_SWAP_X2">;
13830b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_add, i64,  "BUFFER_ATOMIC_ADD_X2">;
13840b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_sub, i64, "BUFFER_ATOMIC_SUB_X2">;
13850b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_smin, i64, "BUFFER_ATOMIC_SMIN_X2">;
13860b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_umin, i64, "BUFFER_ATOMIC_UMIN_X2">;
13870b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_smax, i64, "BUFFER_ATOMIC_SMAX_X2">;
13880b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_umax, i64, "BUFFER_ATOMIC_UMAX_X2">;
13890b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_and, i64, "BUFFER_ATOMIC_AND_X2">;
13900b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_or, i64, "BUFFER_ATOMIC_OR_X2">;
13910b57cec5SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_xor, i64, "BUFFER_ATOMIC_XOR_X2">;
13928bcb0991SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_inc, i64, "BUFFER_ATOMIC_INC_X2">;
13938bcb0991SDimitry Andricdefm : BufferAtomicPatterns<SIbuffer_atomic_dec, i64, "BUFFER_ATOMIC_DEC_X2">;
13940b57cec5SDimitry Andric
13950b57cec5SDimitry Andricmulticlass BufferAtomicPatterns_NO_RTN<SDPatternOperator name, ValueType vt,
13960b57cec5SDimitry Andric                                       string opcode> {
13970b57cec5SDimitry Andric  def : GCNPat<
13980b57cec5SDimitry Andric    (name vt:$vdata_in, v4i32:$rsrc, 0,
13998bcb0991SDimitry Andric          0, i32:$soffset, timm:$offset,
14008bcb0991SDimitry Andric          timm:$cachepolicy, 0),
14010b57cec5SDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _OFFSET) $vdata_in, $rsrc, $soffset,
14020b57cec5SDimitry Andric                                        (as_i16imm $offset), (extract_slc $cachepolicy))
14030b57cec5SDimitry Andric  >;
14040b57cec5SDimitry Andric
14050b57cec5SDimitry Andric  def : GCNPat<
14060b57cec5SDimitry Andric    (name vt:$vdata_in, v4i32:$rsrc, i32:$vindex,
14078bcb0991SDimitry Andric          0, i32:$soffset, timm:$offset,
14088bcb0991SDimitry Andric          timm:$cachepolicy, timm),
14090b57cec5SDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _IDXEN) $vdata_in, $vindex, $rsrc, $soffset,
14100b57cec5SDimitry Andric                                       (as_i16imm $offset), (extract_slc $cachepolicy))
14110b57cec5SDimitry Andric  >;
14120b57cec5SDimitry Andric
14130b57cec5SDimitry Andric  def : GCNPat<
14140b57cec5SDimitry Andric    (name vt:$vdata_in, v4i32:$rsrc, 0,
14158bcb0991SDimitry Andric          i32:$voffset, i32:$soffset, timm:$offset,
14168bcb0991SDimitry Andric          timm:$cachepolicy, 0),
14170b57cec5SDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _OFFEN) $vdata_in, $voffset, $rsrc, $soffset,
14180b57cec5SDimitry Andric                                       (as_i16imm $offset), (extract_slc $cachepolicy))
14190b57cec5SDimitry Andric  >;
14200b57cec5SDimitry Andric
14210b57cec5SDimitry Andric  def : GCNPat<
14220b57cec5SDimitry Andric    (name vt:$vdata_in, v4i32:$rsrc, i32:$vindex,
14238bcb0991SDimitry Andric          i32:$voffset, i32:$soffset, timm:$offset,
14248bcb0991SDimitry Andric          timm:$cachepolicy, timm),
14250b57cec5SDimitry Andric    (!cast<MUBUF_Pseudo>(opcode # _BOTHEN)
14260b57cec5SDimitry Andric      $vdata_in,
14270b57cec5SDimitry Andric      (REG_SEQUENCE VReg_64, $vindex, sub0, $voffset, sub1),
14280b57cec5SDimitry Andric      $rsrc, $soffset, (as_i16imm $offset), (extract_slc $cachepolicy))
14290b57cec5SDimitry Andric  >;
14300b57cec5SDimitry Andric}
14310b57cec5SDimitry Andric
1432*5ffd83dbSDimitry Andriclet SubtargetPredicate = HasAtomicFaddInsts in {
14330b57cec5SDimitry Andricdefm : BufferAtomicPatterns_NO_RTN<SIbuffer_atomic_fadd, f32, "BUFFER_ATOMIC_ADD_F32">;
14340b57cec5SDimitry Andricdefm : BufferAtomicPatterns_NO_RTN<SIbuffer_atomic_pk_fadd, v2f16, "BUFFER_ATOMIC_PK_ADD_F16">;
1435*5ffd83dbSDimitry Andric}
14360b57cec5SDimitry Andric
14370b57cec5SDimitry Andricdef : GCNPat<
14380b57cec5SDimitry Andric  (SIbuffer_atomic_cmpswap
1439*5ffd83dbSDimitry Andric      i32:$data, i32:$cmp, v4i32:$rsrc, 0, 0, i32:$soffset,
1440*5ffd83dbSDimitry Andric      timm:$offset, timm:$cachepolicy, 0),
14410b57cec5SDimitry Andric  (EXTRACT_SUBREG
14420b57cec5SDimitry Andric    (BUFFER_ATOMIC_CMPSWAP_OFFSET_RTN
1443*5ffd83dbSDimitry Andric      (REG_SEQUENCE VReg_64, VGPR_32:$data, sub0, VGPR_32:$cmp, sub1),
1444*5ffd83dbSDimitry Andric        SReg_128:$rsrc, SCSrc_b32:$soffset, (as_i16timm $offset),
1445*5ffd83dbSDimitry Andric        (extract_slc $cachepolicy)), sub0)
14460b57cec5SDimitry Andric>;
14470b57cec5SDimitry Andric
14480b57cec5SDimitry Andricdef : GCNPat<
14490b57cec5SDimitry Andric  (SIbuffer_atomic_cmpswap
14500b57cec5SDimitry Andric      i32:$data, i32:$cmp, v4i32:$rsrc, i32:$vindex,
14518bcb0991SDimitry Andric      0, i32:$soffset, timm:$offset,
14528bcb0991SDimitry Andric      timm:$cachepolicy, timm),
14530b57cec5SDimitry Andric  (EXTRACT_SUBREG
14540b57cec5SDimitry Andric    (BUFFER_ATOMIC_CMPSWAP_IDXEN_RTN
1455*5ffd83dbSDimitry Andric      (REG_SEQUENCE VReg_64, VGPR_32:$data, sub0, VGPR_32:$cmp, sub1),
1456*5ffd83dbSDimitry Andric      VGPR_32:$vindex, SReg_128:$rsrc, SCSrc_b32:$soffset, (as_i16timm $offset), (extract_slc $cachepolicy)),
14570b57cec5SDimitry Andric    sub0)
14580b57cec5SDimitry Andric>;
14590b57cec5SDimitry Andric
14600b57cec5SDimitry Andricdef : GCNPat<
14610b57cec5SDimitry Andric  (SIbuffer_atomic_cmpswap
14620b57cec5SDimitry Andric      i32:$data, i32:$cmp, v4i32:$rsrc, 0,
14638bcb0991SDimitry Andric      i32:$voffset, i32:$soffset, timm:$offset,
14648bcb0991SDimitry Andric      timm:$cachepolicy, 0),
14650b57cec5SDimitry Andric  (EXTRACT_SUBREG
14660b57cec5SDimitry Andric    (BUFFER_ATOMIC_CMPSWAP_OFFEN_RTN
1467*5ffd83dbSDimitry Andric      (REG_SEQUENCE VReg_64, VGPR_32:$data, sub0, VGPR_32:$cmp, sub1),
1468*5ffd83dbSDimitry Andric      VGPR_32:$voffset, SReg_128:$rsrc, SCSrc_b32:$soffset, (as_i16timm $offset), (extract_slc $cachepolicy)),
14690b57cec5SDimitry Andric    sub0)
14700b57cec5SDimitry Andric>;
14710b57cec5SDimitry Andric
14720b57cec5SDimitry Andricdef : GCNPat<
14730b57cec5SDimitry Andric  (SIbuffer_atomic_cmpswap
14740b57cec5SDimitry Andric      i32:$data, i32:$cmp, v4i32:$rsrc, i32:$vindex,
14758bcb0991SDimitry Andric      i32:$voffset, i32:$soffset, timm:$offset,
14768bcb0991SDimitry Andric      timm:$cachepolicy, timm),
14770b57cec5SDimitry Andric  (EXTRACT_SUBREG
14780b57cec5SDimitry Andric    (BUFFER_ATOMIC_CMPSWAP_BOTHEN_RTN
1479*5ffd83dbSDimitry Andric      (REG_SEQUENCE VReg_64, VGPR_32:$data, sub0, VGPR_32:$cmp, sub1),
1480*5ffd83dbSDimitry Andric      (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1),
1481*5ffd83dbSDimitry Andric      SReg_128:$rsrc, SCSrc_b32:$soffset, (as_i16timm $offset), (extract_slc $cachepolicy)),
14820b57cec5SDimitry Andric    sub0)
14830b57cec5SDimitry Andric>;
14840b57cec5SDimitry Andric
14850b57cec5SDimitry Andricclass MUBUFLoad_PatternADDR64 <MUBUF_Pseudo Instr_ADDR64, ValueType vt,
14860b57cec5SDimitry Andric                              PatFrag constant_ld> : GCNPat <
14870b57cec5SDimitry Andric     (vt (constant_ld (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset,
14888bcb0991SDimitry Andric                                   i16:$offset, i1:$glc, i1:$slc, i1:$tfe, i1:$dlc, i1:$swz))),
14898bcb0991SDimitry Andric     (Instr_ADDR64 $vaddr, $srsrc, $soffset, $offset, $glc, $slc, $tfe, $dlc, $swz)
14900b57cec5SDimitry Andric  >;
14910b57cec5SDimitry Andric
14920b57cec5SDimitry Andricmulticlass MUBUFLoad_Atomic_Pattern <MUBUF_Pseudo Instr_ADDR64, MUBUF_Pseudo Instr_OFFSET,
14930b57cec5SDimitry Andric                                     ValueType vt, PatFrag atomic_ld> {
14940b57cec5SDimitry Andric  def : GCNPat <
14950b57cec5SDimitry Andric     (vt (atomic_ld (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset,
14960b57cec5SDimitry Andric                                   i16:$offset, i1:$slc))),
14978bcb0991SDimitry Andric     (Instr_ADDR64 $vaddr, $srsrc, $soffset, $offset, 0, $slc, 0, 0, 0)
14980b57cec5SDimitry Andric  >;
14990b57cec5SDimitry Andric
15000b57cec5SDimitry Andric  def : GCNPat <
15010b57cec5SDimitry Andric    (vt (atomic_ld (MUBUFOffsetNoGLC v4i32:$rsrc, i32:$soffset, i16:$offset))),
15028bcb0991SDimitry Andric    (Instr_OFFSET $rsrc, $soffset, (as_i16imm $offset), 0, 0, 0, 0, 0)
15030b57cec5SDimitry Andric  >;
15040b57cec5SDimitry Andric}
15050b57cec5SDimitry Andric
15060b57cec5SDimitry Andriclet SubtargetPredicate = isGFX6GFX7 in {
15070b57cec5SDimitry Andricdef : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_SBYTE_ADDR64, i32, sextloadi8_constant>;
15080b57cec5SDimitry Andricdef : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_UBYTE_ADDR64, i32, extloadi8_constant>;
15090b57cec5SDimitry Andricdef : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_UBYTE_ADDR64, i32, zextloadi8_constant>;
15100b57cec5SDimitry Andricdef : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_SSHORT_ADDR64, i32, sextloadi16_constant>;
15110b57cec5SDimitry Andricdef : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_USHORT_ADDR64, i32, extloadi16_constant>;
15120b57cec5SDimitry Andricdef : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_USHORT_ADDR64, i32, zextloadi16_constant>;
15130b57cec5SDimitry Andric
15140b57cec5SDimitry Andricdefm : MUBUFLoad_Atomic_Pattern <BUFFER_LOAD_DWORD_ADDR64, BUFFER_LOAD_DWORD_OFFSET, i32, atomic_load_32_global>;
15150b57cec5SDimitry Andricdefm : MUBUFLoad_Atomic_Pattern <BUFFER_LOAD_DWORDX2_ADDR64, BUFFER_LOAD_DWORDX2_OFFSET, i64, atomic_load_64_global>;
15160b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX6GFX7
15170b57cec5SDimitry Andric
15180b57cec5SDimitry Andricmulticlass MUBUFLoad_Pattern <MUBUF_Pseudo Instr_OFFSET, ValueType vt,
15190b57cec5SDimitry Andric                               PatFrag ld> {
15200b57cec5SDimitry Andric
15210b57cec5SDimitry Andric  def : GCNPat <
15220b57cec5SDimitry Andric    (vt (ld (MUBUFOffset v4i32:$srsrc, i32:$soffset,
15238bcb0991SDimitry Andric                          i16:$offset, i1:$glc, i1:$slc, i1:$tfe, i1:$dlc, i1:$swz))),
15248bcb0991SDimitry Andric    (Instr_OFFSET $srsrc, $soffset, $offset, $glc, $slc, $tfe, $dlc, $swz)
15250b57cec5SDimitry Andric  >;
15260b57cec5SDimitry Andric}
15270b57cec5SDimitry Andric
15280b57cec5SDimitry Andriclet OtherPredicates = [Has16BitInsts] in {
15290b57cec5SDimitry Andric
15300b57cec5SDimitry Andricdefm : MUBUFLoad_Pattern <BUFFER_LOAD_SBYTE_OFFSET, i16, sextloadi8_constant>;
15310b57cec5SDimitry Andricdefm : MUBUFLoad_Pattern <BUFFER_LOAD_UBYTE_OFFSET, i16, extloadi8_constant>;
15320b57cec5SDimitry Andricdefm : MUBUFLoad_Pattern <BUFFER_LOAD_UBYTE_OFFSET, i16, zextloadi8_constant>;
15330b57cec5SDimitry Andricdefm : MUBUFLoad_Pattern <BUFFER_LOAD_SBYTE_OFFSET, i16, sextloadi8_global>;
15340b57cec5SDimitry Andricdefm : MUBUFLoad_Pattern <BUFFER_LOAD_UBYTE_OFFSET, i16, extloadi8_global>;
15350b57cec5SDimitry Andricdefm : MUBUFLoad_Pattern <BUFFER_LOAD_UBYTE_OFFSET, i16, zextloadi8_global>;
15360b57cec5SDimitry Andric
15370b57cec5SDimitry Andricdefm : MUBUFLoad_Pattern <BUFFER_LOAD_USHORT_OFFSET, i16, load_global>;
15380b57cec5SDimitry Andric
15390b57cec5SDimitry Andric} // End OtherPredicates = [Has16BitInsts]
15400b57cec5SDimitry Andric
15410b57cec5SDimitry Andricmulticlass MUBUFScratchLoadPat <MUBUF_Pseudo InstrOffen,
15420b57cec5SDimitry Andric                                MUBUF_Pseudo InstrOffset,
15430b57cec5SDimitry Andric                                ValueType vt, PatFrag ld> {
15440b57cec5SDimitry Andric  def : GCNPat <
15450b57cec5SDimitry Andric    (vt (ld (MUBUFScratchOffen v4i32:$srsrc, i32:$vaddr,
15460b57cec5SDimitry Andric                               i32:$soffset, u16imm:$offset))),
15478bcb0991SDimitry Andric    (InstrOffen $vaddr, $srsrc, $soffset, $offset, 0, 0, 0, 0, 0)
15480b57cec5SDimitry Andric  >;
15490b57cec5SDimitry Andric
15500b57cec5SDimitry Andric  def : GCNPat <
15510b57cec5SDimitry Andric    (vt (ld (MUBUFScratchOffset v4i32:$srsrc, i32:$soffset, u16imm:$offset))),
15528bcb0991SDimitry Andric    (InstrOffset $srsrc, $soffset, $offset, 0, 0, 0, 0, 0)
15530b57cec5SDimitry Andric  >;
15540b57cec5SDimitry Andric}
15550b57cec5SDimitry Andric
15560b57cec5SDimitry Andric// XXX - Is it possible to have a complex pattern in a PatFrag?
15570b57cec5SDimitry Andricmulticlass MUBUFScratchLoadPat_D16 <MUBUF_Pseudo InstrOffen,
15580b57cec5SDimitry Andric                                MUBUF_Pseudo InstrOffset,
15590b57cec5SDimitry Andric                                ValueType vt, PatFrag ld_frag> {
15600b57cec5SDimitry Andric  def : GCNPat <
15610b57cec5SDimitry Andric    (ld_frag (MUBUFScratchOffen v4i32:$srsrc, i32:$vaddr, i32:$soffset, u16imm:$offset), vt:$in),
15628bcb0991SDimitry Andric    (InstrOffen $vaddr, $srsrc, $soffset, $offset, 0, 0, 0, 0, 0, $in)
15630b57cec5SDimitry Andric  >;
15640b57cec5SDimitry Andric
15650b57cec5SDimitry Andric  def : GCNPat <
15660b57cec5SDimitry Andric    (ld_frag (MUBUFScratchOffset v4i32:$srsrc, i32:$soffset, u16imm:$offset), vt:$in),
15678bcb0991SDimitry Andric    (InstrOffset $srsrc, $soffset, $offset, 0, 0, 0, 0, 0, $in)
15680b57cec5SDimitry Andric  >;
15690b57cec5SDimitry Andric}
15700b57cec5SDimitry Andric
15710b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_SBYTE_OFFEN, BUFFER_LOAD_SBYTE_OFFSET, i32, sextloadi8_private>;
15720b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_UBYTE_OFFEN, BUFFER_LOAD_UBYTE_OFFSET, i32, extloadi8_private>;
15730b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_UBYTE_OFFEN, BUFFER_LOAD_UBYTE_OFFSET, i32, zextloadi8_private>;
15740b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_SBYTE_OFFEN, BUFFER_LOAD_SBYTE_OFFSET, i16, sextloadi8_private>;
15750b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_UBYTE_OFFEN, BUFFER_LOAD_UBYTE_OFFSET, i16, extloadi8_private>;
15760b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_UBYTE_OFFEN, BUFFER_LOAD_UBYTE_OFFSET, i16, zextloadi8_private>;
15770b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_SSHORT_OFFEN, BUFFER_LOAD_SSHORT_OFFSET, i32, sextloadi16_private>;
15780b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_USHORT_OFFEN, BUFFER_LOAD_USHORT_OFFSET, i32, extloadi16_private>;
15790b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_USHORT_OFFEN, BUFFER_LOAD_USHORT_OFFSET, i32, zextloadi16_private>;
15800b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_USHORT_OFFEN, BUFFER_LOAD_USHORT_OFFSET, i16, load_private>;
15818bcb0991SDimitry Andric
15828bcb0991SDimitry Andricforeach vt = Reg32Types.types in {
1583*5ffd83dbSDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_DWORD_OFFEN, BUFFER_LOAD_DWORD_OFFSET, vt, load_private>;
15848bcb0991SDimitry Andric}
15850b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_DWORDX2_OFFEN, BUFFER_LOAD_DWORDX2_OFFSET, v2i32, load_private>;
15860b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_DWORDX3_OFFEN, BUFFER_LOAD_DWORDX3_OFFSET, v3i32, load_private>;
15870b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat <BUFFER_LOAD_DWORDX4_OFFEN, BUFFER_LOAD_DWORDX4_OFFSET, v4i32, load_private>;
15880b57cec5SDimitry Andric
15890b57cec5SDimitry Andriclet OtherPredicates = [D16PreservesUnusedBits] in {
15900b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_SHORT_D16_HI_OFFEN, BUFFER_LOAD_SHORT_D16_HI_OFFSET, v2i16, load_d16_hi_private>;
15910b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_UBYTE_D16_HI_OFFEN, BUFFER_LOAD_UBYTE_D16_HI_OFFSET, v2i16, az_extloadi8_d16_hi_private>;
15920b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_SBYTE_D16_HI_OFFEN, BUFFER_LOAD_SBYTE_D16_HI_OFFSET, v2i16, sextloadi8_d16_hi_private>;
15930b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_SHORT_D16_HI_OFFEN, BUFFER_LOAD_SHORT_D16_HI_OFFSET, v2f16, load_d16_hi_private>;
15940b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_UBYTE_D16_HI_OFFEN, BUFFER_LOAD_UBYTE_D16_HI_OFFSET, v2f16, az_extloadi8_d16_hi_private>;
15950b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_SBYTE_D16_HI_OFFEN, BUFFER_LOAD_SBYTE_D16_HI_OFFSET, v2f16, sextloadi8_d16_hi_private>;
15960b57cec5SDimitry Andric
15970b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_SHORT_D16_OFFEN, BUFFER_LOAD_SHORT_D16_OFFSET, v2i16, load_d16_lo_private>;
15980b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_UBYTE_D16_OFFEN, BUFFER_LOAD_UBYTE_D16_OFFSET, v2i16, az_extloadi8_d16_lo_private>;
15990b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_SBYTE_D16_OFFEN, BUFFER_LOAD_SBYTE_D16_OFFSET, v2i16, sextloadi8_d16_lo_private>;
16000b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_SHORT_D16_OFFEN, BUFFER_LOAD_SHORT_D16_OFFSET, v2f16, load_d16_lo_private>;
16010b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_UBYTE_D16_OFFEN, BUFFER_LOAD_UBYTE_D16_OFFSET, v2f16, az_extloadi8_d16_lo_private>;
16020b57cec5SDimitry Andricdefm : MUBUFScratchLoadPat_D16<BUFFER_LOAD_SBYTE_D16_OFFEN, BUFFER_LOAD_SBYTE_D16_OFFSET, v2f16, sextloadi8_d16_lo_private>;
16030b57cec5SDimitry Andric}
16040b57cec5SDimitry Andric
16050b57cec5SDimitry Andricmulticlass MUBUFStore_Atomic_Pattern <MUBUF_Pseudo Instr_ADDR64, MUBUF_Pseudo Instr_OFFSET,
16060b57cec5SDimitry Andric                                      ValueType vt, PatFrag atomic_st> {
16078bcb0991SDimitry Andric  // Store follows atomic op convention so address is first
16080b57cec5SDimitry Andric  def : GCNPat <
16090b57cec5SDimitry Andric     (atomic_st (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset,
16100b57cec5SDimitry Andric                                   i16:$offset, i1:$slc), vt:$val),
16118bcb0991SDimitry Andric     (Instr_ADDR64 $val, $vaddr, $srsrc, $soffset, $offset, 0, $slc, 0, 0, 0)
16120b57cec5SDimitry Andric  >;
16130b57cec5SDimitry Andric
16140b57cec5SDimitry Andric  def : GCNPat <
16150b57cec5SDimitry Andric    (atomic_st (MUBUFOffsetNoGLC v4i32:$rsrc, i32:$soffset, i16:$offset), vt:$val),
16168bcb0991SDimitry Andric    (Instr_OFFSET $val, $rsrc, $soffset, (as_i16imm $offset), 0, 0, 0, 0, 0)
16170b57cec5SDimitry Andric  >;
16180b57cec5SDimitry Andric}
16190b57cec5SDimitry Andriclet SubtargetPredicate = isGFX6GFX7 in {
1620480093f4SDimitry Andricdefm : MUBUFStore_Atomic_Pattern <BUFFER_STORE_DWORD_ADDR64, BUFFER_STORE_DWORD_OFFSET, i32, atomic_store_global_32>;
1621480093f4SDimitry Andricdefm : MUBUFStore_Atomic_Pattern <BUFFER_STORE_DWORDX2_ADDR64, BUFFER_STORE_DWORDX2_OFFSET, i64, atomic_store_global_64>;
16220b57cec5SDimitry Andric} // End Predicates = isGFX6GFX7
16230b57cec5SDimitry Andric
16240b57cec5SDimitry Andric
16250b57cec5SDimitry Andricmulticlass MUBUFStore_Pattern <MUBUF_Pseudo Instr_OFFSET, ValueType vt,
16260b57cec5SDimitry Andric                               PatFrag st> {
16270b57cec5SDimitry Andric
16280b57cec5SDimitry Andric  def : GCNPat <
16290b57cec5SDimitry Andric    (st vt:$vdata, (MUBUFOffset v4i32:$srsrc, i32:$soffset,
16308bcb0991SDimitry Andric                                      i16:$offset, i1:$glc, i1:$slc, i1:$tfe, i1:$dlc, i1:$swz)),
16318bcb0991SDimitry Andric    (Instr_OFFSET $vdata, $srsrc, $soffset, $offset, $glc, $slc, $tfe, $dlc, $swz)
16320b57cec5SDimitry Andric  >;
16330b57cec5SDimitry Andric}
16340b57cec5SDimitry Andric
16350b57cec5SDimitry Andricdefm : MUBUFStore_Pattern <BUFFER_STORE_BYTE_OFFSET, i16, truncstorei8_global>;
16360b57cec5SDimitry Andricdefm : MUBUFStore_Pattern <BUFFER_STORE_SHORT_OFFSET, i16, store_global>;
16370b57cec5SDimitry Andric
16380b57cec5SDimitry Andricmulticlass MUBUFScratchStorePat <MUBUF_Pseudo InstrOffen,
16390b57cec5SDimitry Andric                                 MUBUF_Pseudo InstrOffset,
16400b57cec5SDimitry Andric                                 ValueType vt, PatFrag st,
16410b57cec5SDimitry Andric                                 RegisterClass rc = VGPR_32> {
16420b57cec5SDimitry Andric  def : GCNPat <
16430b57cec5SDimitry Andric    (st vt:$value, (MUBUFScratchOffen v4i32:$srsrc, i32:$vaddr,
16440b57cec5SDimitry Andric                                      i32:$soffset, u16imm:$offset)),
16458bcb0991SDimitry Andric    (InstrOffen rc:$value, $vaddr, $srsrc, $soffset, $offset, 0, 0, 0, 0, 0)
16460b57cec5SDimitry Andric  >;
16470b57cec5SDimitry Andric
16480b57cec5SDimitry Andric  def : GCNPat <
16490b57cec5SDimitry Andric    (st vt:$value, (MUBUFScratchOffset v4i32:$srsrc, i32:$soffset,
16500b57cec5SDimitry Andric                                       u16imm:$offset)),
16518bcb0991SDimitry Andric    (InstrOffset rc:$value, $srsrc, $soffset, $offset, 0, 0, 0, 0, 0)
16520b57cec5SDimitry Andric  >;
16530b57cec5SDimitry Andric}
16540b57cec5SDimitry Andric
16550b57cec5SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_BYTE_OFFEN, BUFFER_STORE_BYTE_OFFSET, i32, truncstorei8_private>;
16560b57cec5SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_SHORT_OFFEN, BUFFER_STORE_SHORT_OFFSET, i32, truncstorei16_private>;
16570b57cec5SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_BYTE_OFFEN, BUFFER_STORE_BYTE_OFFSET, i16, truncstorei8_private>;
16580b57cec5SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_SHORT_OFFEN, BUFFER_STORE_SHORT_OFFSET, i16, store_private>;
16598bcb0991SDimitry Andric
16608bcb0991SDimitry Andricforeach vt = Reg32Types.types in {
16618bcb0991SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_DWORD_OFFEN, BUFFER_STORE_DWORD_OFFSET, vt, store_private>;
16628bcb0991SDimitry Andric}
16638bcb0991SDimitry Andric
16640b57cec5SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_DWORDX2_OFFEN, BUFFER_STORE_DWORDX2_OFFSET, v2i32, store_private, VReg_64>;
16650b57cec5SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_DWORDX3_OFFEN, BUFFER_STORE_DWORDX3_OFFSET, v3i32, store_private, VReg_96>;
16660b57cec5SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_DWORDX4_OFFEN, BUFFER_STORE_DWORDX4_OFFSET, v4i32, store_private, VReg_128>;
16670b57cec5SDimitry Andric
16680b57cec5SDimitry Andric
16690b57cec5SDimitry Andriclet OtherPredicates = [D16PreservesUnusedBits] in {
16700b57cec5SDimitry Andric // Hiding the extract high pattern in the PatFrag seems to not
16710b57cec5SDimitry Andric // automatically increase the complexity.
16720b57cec5SDimitry Andriclet AddedComplexity = 1 in {
16730b57cec5SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_SHORT_D16_HI_OFFEN, BUFFER_STORE_SHORT_D16_HI_OFFSET, i32, store_hi16_private>;
16740b57cec5SDimitry Andricdefm : MUBUFScratchStorePat <BUFFER_STORE_BYTE_D16_HI_OFFEN, BUFFER_STORE_BYTE_D16_HI_OFFSET, i32, truncstorei8_hi16_private>;
16750b57cec5SDimitry Andric}
16760b57cec5SDimitry Andric}
16770b57cec5SDimitry Andric
16780b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
16790b57cec5SDimitry Andric// MTBUF Patterns
16800b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
16810b57cec5SDimitry Andric
16820b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
16830b57cec5SDimitry Andric// tbuffer_load/store_format patterns
16840b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
16850b57cec5SDimitry Andric
16860b57cec5SDimitry Andricmulticlass MTBUF_LoadIntrinsicPat<SDPatternOperator name, ValueType vt,
16870b57cec5SDimitry Andric                                  string opcode> {
16880b57cec5SDimitry Andric  def : GCNPat<
16898bcb0991SDimitry Andric    (vt (name v4i32:$rsrc, 0, 0, i32:$soffset, timm:$offset,
16908bcb0991SDimitry Andric              timm:$format, timm:$auxiliary, 0)),
1691*5ffd83dbSDimitry Andric    (!cast<MTBUF_Pseudo>(opcode # _OFFSET) SReg_128:$rsrc, SCSrc_b32:$soffset, (as_i16timm $offset),
1692*5ffd83dbSDimitry Andric      (as_i8timm $format),
16938bcb0991SDimitry Andric      (extract_glc $auxiliary), (extract_slc $auxiliary), 0, (extract_dlc $auxiliary),
16948bcb0991SDimitry Andric      (extract_swz $auxiliary))
16950b57cec5SDimitry Andric  >;
16960b57cec5SDimitry Andric
16970b57cec5SDimitry Andric  def : GCNPat<
16988bcb0991SDimitry Andric    (vt (name v4i32:$rsrc, i32:$vindex, 0, i32:$soffset, timm:$offset,
16998bcb0991SDimitry Andric              timm:$format, timm:$auxiliary, timm)),
1700*5ffd83dbSDimitry Andric    (!cast<MTBUF_Pseudo>(opcode # _IDXEN) VGPR_32:$vindex, SReg_128:$rsrc, SCSrc_b32:$soffset, (as_i16timm $offset),
1701*5ffd83dbSDimitry Andric      (as_i8timm $format),
17028bcb0991SDimitry Andric      (extract_glc $auxiliary), (extract_slc $auxiliary), 0, (extract_dlc $auxiliary),
17038bcb0991SDimitry Andric      (extract_swz $auxiliary))
17040b57cec5SDimitry Andric  >;
17050b57cec5SDimitry Andric
17060b57cec5SDimitry Andric  def : GCNPat<
17078bcb0991SDimitry Andric    (vt (name v4i32:$rsrc, 0, i32:$voffset, i32:$soffset, timm:$offset,
17088bcb0991SDimitry Andric              timm:$format, timm:$auxiliary, 0)),
1709*5ffd83dbSDimitry Andric    (!cast<MTBUF_Pseudo>(opcode # _OFFEN) VGPR_32:$voffset, SReg_128:$rsrc, SCSrc_b32:$soffset, (as_i16timm $offset),
1710*5ffd83dbSDimitry Andric      (as_i8timm $format),
17118bcb0991SDimitry Andric      (extract_glc $auxiliary), (extract_slc $auxiliary), 0, (extract_dlc $auxiliary),
17128bcb0991SDimitry Andric      (extract_swz $auxiliary))
17130b57cec5SDimitry Andric  >;
17140b57cec5SDimitry Andric
17150b57cec5SDimitry Andric  def : GCNPat<
17168bcb0991SDimitry Andric    (vt (name v4i32:$rsrc, i32:$vindex, i32:$voffset, i32:$soffset, timm:$offset,
17178bcb0991SDimitry Andric              timm:$format, timm:$auxiliary, timm)),
17180b57cec5SDimitry Andric    (!cast<MTBUF_Pseudo>(opcode # _BOTHEN)
1719*5ffd83dbSDimitry Andric      (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1),
1720*5ffd83dbSDimitry Andric      SReg_128:$rsrc, SCSrc_b32:$soffset, (as_i16timm $offset),
1721*5ffd83dbSDimitry Andric      (as_i8timm $format),
17228bcb0991SDimitry Andric      (extract_glc $auxiliary), (extract_slc $auxiliary), 0, (extract_dlc $auxiliary),
17238bcb0991SDimitry Andric      (extract_swz $auxiliary))
17240b57cec5SDimitry Andric  >;
17250b57cec5SDimitry Andric}
17260b57cec5SDimitry Andric
17270b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, i32,   "TBUFFER_LOAD_FORMAT_X">;
17280b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v2i32, "TBUFFER_LOAD_FORMAT_XY">;
17290b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v3i32, "TBUFFER_LOAD_FORMAT_XYZ">;
17300b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v4i32, "TBUFFER_LOAD_FORMAT_XYZW">;
17310b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, f32,   "TBUFFER_LOAD_FORMAT_X">;
17320b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v2f32, "TBUFFER_LOAD_FORMAT_XY">;
17330b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v3f32, "TBUFFER_LOAD_FORMAT_XYZ">;
17340b57cec5SDimitry Andricdefm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v4f32, "TBUFFER_LOAD_FORMAT_XYZW">;
17350b57cec5SDimitry Andric
17360b57cec5SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem in {
17370b57cec5SDimitry Andric  defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, f16,   "TBUFFER_LOAD_FORMAT_D16_X_gfx80">;
1738*5ffd83dbSDimitry Andric  defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, i32,   "TBUFFER_LOAD_FORMAT_D16_X_gfx80">;
17390b57cec5SDimitry Andric  defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, v2i32, "TBUFFER_LOAD_FORMAT_D16_XY_gfx80">;
17400b57cec5SDimitry Andric  defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, v4i32, "TBUFFER_LOAD_FORMAT_D16_XYZW_gfx80">;
17410b57cec5SDimitry Andric} // End HasUnpackedD16VMem.
17420b57cec5SDimitry Andric
17430b57cec5SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem in {
17440b57cec5SDimitry Andric  defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, f16,   "TBUFFER_LOAD_FORMAT_D16_X">;
1745*5ffd83dbSDimitry Andric  defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, i32,   "TBUFFER_LOAD_FORMAT_D16_X">;
17460b57cec5SDimitry Andric  defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, v2f16, "TBUFFER_LOAD_FORMAT_D16_XY">;
17470b57cec5SDimitry Andric  defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, v4f16, "TBUFFER_LOAD_FORMAT_D16_XYZW">;
17480b57cec5SDimitry Andric} // End HasPackedD16VMem.
17490b57cec5SDimitry Andric
17500b57cec5SDimitry Andricmulticlass MTBUF_StoreIntrinsicPat<SDPatternOperator name, ValueType vt,
17510b57cec5SDimitry Andric                                   string opcode> {
17520b57cec5SDimitry Andric  def : GCNPat<
17538bcb0991SDimitry Andric    (name vt:$vdata, v4i32:$rsrc, 0, 0, i32:$soffset, timm:$offset,
17548bcb0991SDimitry Andric          timm:$format, timm:$auxiliary, 0),
1755*5ffd83dbSDimitry Andric    (!cast<MTBUF_Pseudo>(opcode # _OFFSET_exact) getVregSrcForVT<vt>.ret:$vdata, SReg_128:$rsrc, SCSrc_b32:$soffset,
1756*5ffd83dbSDimitry Andric      (as_i16timm $offset), (as_i8timm $format),
17578bcb0991SDimitry Andric      (extract_glc $auxiliary), (extract_slc $auxiliary), 0, (extract_dlc $auxiliary),
17588bcb0991SDimitry Andric      (extract_swz $auxiliary))
17590b57cec5SDimitry Andric  >;
17600b57cec5SDimitry Andric
17610b57cec5SDimitry Andric  def : GCNPat<
17628bcb0991SDimitry Andric    (name vt:$vdata, v4i32:$rsrc, i32:$vindex, 0, i32:$soffset, timm:$offset,
17638bcb0991SDimitry Andric          timm:$format, timm:$auxiliary, timm),
1764*5ffd83dbSDimitry Andric    (!cast<MTBUF_Pseudo>(opcode # _IDXEN_exact) getVregSrcForVT<vt>.ret:$vdata, VGPR_32:$vindex, SReg_128:$rsrc, SCSrc_b32:$soffset,
1765*5ffd83dbSDimitry Andric      (as_i16timm $offset), (as_i8timm $format),
17668bcb0991SDimitry Andric      (extract_glc $auxiliary), (extract_slc $auxiliary), 0, (extract_dlc $auxiliary),
17678bcb0991SDimitry Andric      (extract_swz $auxiliary))
17680b57cec5SDimitry Andric  >;
17690b57cec5SDimitry Andric
17700b57cec5SDimitry Andric  def : GCNPat<
17718bcb0991SDimitry Andric    (name vt:$vdata, v4i32:$rsrc, 0, i32:$voffset, i32:$soffset, timm:$offset,
17728bcb0991SDimitry Andric          timm:$format, timm:$auxiliary, 0),
1773*5ffd83dbSDimitry Andric    (!cast<MTBUF_Pseudo>(opcode # _OFFEN_exact) getVregSrcForVT<vt>.ret:$vdata, VGPR_32:$voffset, SReg_128:$rsrc, SCSrc_b32:$soffset,
1774*5ffd83dbSDimitry Andric      (as_i16timm $offset), (as_i8timm $format),
17758bcb0991SDimitry Andric      (extract_glc $auxiliary), (extract_slc $auxiliary), 0, (extract_dlc $auxiliary),
17768bcb0991SDimitry Andric      (extract_swz $auxiliary))
17770b57cec5SDimitry Andric  >;
17780b57cec5SDimitry Andric
17790b57cec5SDimitry Andric  def : GCNPat<
17800b57cec5SDimitry Andric    (name vt:$vdata, v4i32:$rsrc, i32:$vindex, i32:$voffset, i32:$soffset,
17818bcb0991SDimitry Andric          timm:$offset, timm:$format, timm:$auxiliary, timm),
17820b57cec5SDimitry Andric    (!cast<MTBUF_Pseudo>(opcode # _BOTHEN_exact)
1783*5ffd83dbSDimitry Andric      getVregSrcForVT<vt>.ret:$vdata,
1784*5ffd83dbSDimitry Andric      (REG_SEQUENCE VReg_64, VGPR_32:$vindex, sub0, VGPR_32:$voffset, sub1),
1785*5ffd83dbSDimitry Andric      SReg_128:$rsrc, SCSrc_b32:$soffset, (as_i16timm $offset), (as_i8timm $format),
17868bcb0991SDimitry Andric      (extract_glc $auxiliary), (extract_slc $auxiliary), 0, (extract_dlc $auxiliary),
17878bcb0991SDimitry Andric      (extract_swz $auxiliary))
17880b57cec5SDimitry Andric  >;
17890b57cec5SDimitry Andric}
17900b57cec5SDimitry Andric
17910b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, i32,   "TBUFFER_STORE_FORMAT_X">;
17920b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v2i32, "TBUFFER_STORE_FORMAT_XY">;
17930b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v3i32, "TBUFFER_STORE_FORMAT_XYZ">;
17940b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v4i32, "TBUFFER_STORE_FORMAT_XYZW">;
17950b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, f32,   "TBUFFER_STORE_FORMAT_X">;
17960b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v2f32, "TBUFFER_STORE_FORMAT_XY">;
17970b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v3f32, "TBUFFER_STORE_FORMAT_XYZ">;
17980b57cec5SDimitry Andricdefm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v4f32, "TBUFFER_STORE_FORMAT_XYZW">;
17990b57cec5SDimitry Andric
18000b57cec5SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem in {
18010b57cec5SDimitry Andric  defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, f16,   "TBUFFER_STORE_FORMAT_D16_X_gfx80">;
1802*5ffd83dbSDimitry Andric  defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, i32,   "TBUFFER_STORE_FORMAT_D16_X_gfx80">;
18030b57cec5SDimitry Andric  defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, v2i32, "TBUFFER_STORE_FORMAT_D16_XY_gfx80">;
18040b57cec5SDimitry Andric  defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, v4i32, "TBUFFER_STORE_FORMAT_D16_XYZW_gfx80">;
18050b57cec5SDimitry Andric} // End HasUnpackedD16VMem.
18060b57cec5SDimitry Andric
18070b57cec5SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem in {
18080b57cec5SDimitry Andric  defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, f16,   "TBUFFER_STORE_FORMAT_D16_X">;
1809*5ffd83dbSDimitry Andric  defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, i32,   "TBUFFER_STORE_FORMAT_D16_X">;
18100b57cec5SDimitry Andric  defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, v2f16, "TBUFFER_STORE_FORMAT_D16_XY">;
18110b57cec5SDimitry Andric  defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, v4f16, "TBUFFER_STORE_FORMAT_D16_XYZW">;
18120b57cec5SDimitry Andric} // End HasPackedD16VMem.
18130b57cec5SDimitry Andric
18140b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
18150b57cec5SDimitry Andric// Target-specific instruction encodings.
18160b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
18170b57cec5SDimitry Andric
18180b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
18190b57cec5SDimitry Andric// Base ENC_MUBUF for GFX6, GFX7, GFX10.
18200b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
18210b57cec5SDimitry Andric
18220b57cec5SDimitry Andricclass Base_MUBUF_Real_gfx6_gfx7_gfx10<bits<7> op, MUBUF_Pseudo ps, int ef> :
18230b57cec5SDimitry Andric    MUBUF_Real<ps>, Enc64, SIMCInstr<ps.PseudoInstr, ef> {
18240b57cec5SDimitry Andric  let Inst{11-0}  = !if(ps.has_offset, offset, ?);
18250b57cec5SDimitry Andric  let Inst{12}    = ps.offen;
18260b57cec5SDimitry Andric  let Inst{13}    = ps.idxen;
18270b57cec5SDimitry Andric  let Inst{14}    = !if(ps.has_glc, glc, ps.glc_value);
18280b57cec5SDimitry Andric  let Inst{16}    = !if(ps.lds, 1, 0);
18290b57cec5SDimitry Andric  let Inst{24-18} = op;
18300b57cec5SDimitry Andric  let Inst{31-26} = 0x38;
18310b57cec5SDimitry Andric  let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?);
18320b57cec5SDimitry Andric  let Inst{47-40} = !if(ps.has_vdata, vdata, ?);
18330b57cec5SDimitry Andric  let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?);
18340b57cec5SDimitry Andric  let Inst{54}    = !if(ps.has_slc, slc, ?);
18350b57cec5SDimitry Andric  let Inst{55}    = !if(ps.has_tfe, tfe, ?);
18360b57cec5SDimitry Andric  let Inst{63-56} = !if(ps.has_soffset, soffset, ?);
18370b57cec5SDimitry Andric}
18380b57cec5SDimitry Andric
18390b57cec5SDimitry Andricclass MUBUF_Real_gfx10<bits<8> op, MUBUF_Pseudo ps> :
18400b57cec5SDimitry Andric    Base_MUBUF_Real_gfx6_gfx7_gfx10<op{6-0}, ps, SIEncodingFamily.GFX10> {
18410b57cec5SDimitry Andric  let Inst{15} = !if(ps.has_dlc, dlc, ps.dlc_value);
18420b57cec5SDimitry Andric  let Inst{25} = op{7};
18430b57cec5SDimitry Andric}
18440b57cec5SDimitry Andric
18450b57cec5SDimitry Andricclass MUBUF_Real_gfx6_gfx7<bits<8> op, MUBUF_Pseudo ps> :
18460b57cec5SDimitry Andric    Base_MUBUF_Real_gfx6_gfx7_gfx10<op{6-0}, ps, SIEncodingFamily.SI> {
18470b57cec5SDimitry Andric  let Inst{15} = ps.addr64;
18480b57cec5SDimitry Andric}
18490b57cec5SDimitry Andric
18500b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
18510b57cec5SDimitry Andric// MUBUF - GFX10.
18520b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
18530b57cec5SDimitry Andric
18540b57cec5SDimitry Andriclet AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10" in {
18550b57cec5SDimitry Andric  multiclass MUBUF_Real_gfx10_with_name<bits<8> op, string opName,
18560b57cec5SDimitry Andric                                        string asmName> {
18570b57cec5SDimitry Andric    def _gfx10 : MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(opName)> {
18580b57cec5SDimitry Andric      MUBUF_Pseudo ps = !cast<MUBUF_Pseudo>(opName);
18590b57cec5SDimitry Andric      let AsmString = asmName # ps.AsmOperands;
18600b57cec5SDimitry Andric    }
18610b57cec5SDimitry Andric  }
18620b57cec5SDimitry Andric  multiclass MUBUF_Real_AllAddr_gfx10<bits<8> op> {
18630b57cec5SDimitry Andric    def _BOTHEN_gfx10 :
18640b57cec5SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>;
18650b57cec5SDimitry Andric    def _IDXEN_gfx10 :
18660b57cec5SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>;
18670b57cec5SDimitry Andric    def _OFFEN_gfx10 :
18680b57cec5SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>;
18690b57cec5SDimitry Andric    def _OFFSET_gfx10 :
18700b57cec5SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>;
18710b57cec5SDimitry Andric  }
18720b57cec5SDimitry Andric  multiclass MUBUF_Real_AllAddr_Lds_gfx10<bits<8> op> {
18730b57cec5SDimitry Andric    def _OFFSET_gfx10 : MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>,
18740b57cec5SDimitry Andric                        MUBUFLdsTable<0, NAME # "_OFFSET_gfx10">;
18750b57cec5SDimitry Andric    def _OFFEN_gfx10  : MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>,
18760b57cec5SDimitry Andric                        MUBUFLdsTable<0, NAME # "_OFFEN_gfx10">;
18770b57cec5SDimitry Andric    def _IDXEN_gfx10  : MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>,
18780b57cec5SDimitry Andric                        MUBUFLdsTable<0, NAME # "_IDXEN_gfx10">;
18790b57cec5SDimitry Andric    def _BOTHEN_gfx10 : MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>,
18800b57cec5SDimitry Andric                        MUBUFLdsTable<0, NAME # "_BOTHEN_gfx10">;
18810b57cec5SDimitry Andric
18820b57cec5SDimitry Andric    def _LDS_OFFSET_gfx10 : MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_LDS_OFFSET")>,
18830b57cec5SDimitry Andric                            MUBUFLdsTable<1, NAME # "_OFFSET_gfx10">;
18840b57cec5SDimitry Andric    def _LDS_OFFEN_gfx10  : MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_LDS_OFFEN")>,
18850b57cec5SDimitry Andric                            MUBUFLdsTable<1, NAME # "_OFFEN_gfx10">;
18860b57cec5SDimitry Andric    def _LDS_IDXEN_gfx10  : MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_LDS_IDXEN")>,
18870b57cec5SDimitry Andric                            MUBUFLdsTable<1, NAME # "_IDXEN_gfx10">;
18880b57cec5SDimitry Andric    def _LDS_BOTHEN_gfx10 : MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_LDS_BOTHEN")>,
18890b57cec5SDimitry Andric                            MUBUFLdsTable<1, NAME # "_BOTHEN_gfx10">;
18900b57cec5SDimitry Andric  }
1891*5ffd83dbSDimitry Andric  multiclass MUBUF_Real_Atomics_RTN_gfx10<bits<8> op> {
18920b57cec5SDimitry Andric    def _BOTHEN_RTN_gfx10 :
18930b57cec5SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN_RTN")>;
18940b57cec5SDimitry Andric    def _IDXEN_RTN_gfx10 :
18950b57cec5SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN_RTN")>;
18960b57cec5SDimitry Andric    def _OFFEN_RTN_gfx10 :
18970b57cec5SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN_RTN")>;
18980b57cec5SDimitry Andric    def _OFFSET_RTN_gfx10 :
18990b57cec5SDimitry Andric      MUBUF_Real_gfx10<op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET_RTN")>;
19000b57cec5SDimitry Andric  }
1901*5ffd83dbSDimitry Andric  multiclass MUBUF_Real_Atomics_gfx10<bits<8> op> :
1902*5ffd83dbSDimitry Andric      MUBUF_Real_AllAddr_gfx10<op>, MUBUF_Real_Atomics_RTN_gfx10<op>;
19030b57cec5SDimitry Andric} // End AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10"
19040b57cec5SDimitry Andric
19050b57cec5SDimitry Andricdefm BUFFER_STORE_BYTE_D16_HI     : MUBUF_Real_AllAddr_gfx10<0x019>;
19060b57cec5SDimitry Andricdefm BUFFER_STORE_SHORT_D16_HI    : MUBUF_Real_AllAddr_gfx10<0x01b>;
19070b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16        : MUBUF_Real_AllAddr_gfx10<0x020>;
19080b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16_HI     : MUBUF_Real_AllAddr_gfx10<0x021>;
19090b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16        : MUBUF_Real_AllAddr_gfx10<0x022>;
19100b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16_HI     : MUBUF_Real_AllAddr_gfx10<0x023>;
19110b57cec5SDimitry Andricdefm BUFFER_LOAD_SHORT_D16        : MUBUF_Real_AllAddr_gfx10<0x024>;
19120b57cec5SDimitry Andricdefm BUFFER_LOAD_SHORT_D16_HI     : MUBUF_Real_AllAddr_gfx10<0x025>;
19130b57cec5SDimitry Andric// FIXME-GFX10: Add following instructions:
19140b57cec5SDimitry Andric//defm BUFFER_LOAD_FORMAT_D16_HI_X  : MUBUF_Real_AllAddr_gfx10<0x026>;
19150b57cec5SDimitry Andric//defm BUFFER_STORE_FORMAT_D16_HI_X : MUBUF_Real_AllAddr_gfx10<0x027>;
19160b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_X     : MUBUF_Real_AllAddr_gfx10<0x080>;
19170b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_XY    : MUBUF_Real_AllAddr_gfx10<0x081>;
19180b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_XYZ   : MUBUF_Real_AllAddr_gfx10<0x082>;
19190b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_XYZW  : MUBUF_Real_AllAddr_gfx10<0x083>;
19200b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_X    : MUBUF_Real_AllAddr_gfx10<0x084>;
19210b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_XY   : MUBUF_Real_AllAddr_gfx10<0x085>;
19220b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_XYZ  : MUBUF_Real_AllAddr_gfx10<0x086>;
19230b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_XYZW : MUBUF_Real_AllAddr_gfx10<0x087>;
19240b57cec5SDimitry Andric
19250b57cec5SDimitry Andricdef BUFFER_GL0_INV_gfx10 :
19260b57cec5SDimitry Andric  MUBUF_Real_gfx10<0x071, BUFFER_GL0_INV>;
19270b57cec5SDimitry Andricdef BUFFER_GL1_INV_gfx10 :
19280b57cec5SDimitry Andric  MUBUF_Real_gfx10<0x072, BUFFER_GL1_INV>;
19290b57cec5SDimitry Andric
19300b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
19310b57cec5SDimitry Andric// MUBUF - GFX6, GFX7, GFX10.
19320b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
19330b57cec5SDimitry Andric
19340b57cec5SDimitry Andriclet AssemblerPredicate = isGFX6, DecoderNamespace = "GFX6" in {
19350b57cec5SDimitry Andric  multiclass MUBUF_Real_gfx6<bits<8> op> {
19360b57cec5SDimitry Andric    def _gfx6 : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME)>;
19370b57cec5SDimitry Andric  }
19380b57cec5SDimitry Andric} // End AssemblerPredicate = isGFX6, DecoderNamespace = "GFX6"
19390b57cec5SDimitry Andric
19400b57cec5SDimitry Andriclet AssemblerPredicate = isGFX7Only, DecoderNamespace = "GFX7" in {
19410b57cec5SDimitry Andric  multiclass MUBUF_Real_gfx7<bits<8> op> {
19420b57cec5SDimitry Andric    def _gfx7 : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME)>;
19430b57cec5SDimitry Andric  }
19440b57cec5SDimitry Andric} // End AssemblerPredicate = isGFX7Only, DecoderNamespace = "GFX7"
19450b57cec5SDimitry Andric
19460b57cec5SDimitry Andriclet AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" in {
19470b57cec5SDimitry Andric  multiclass MUBUF_Real_AllAddr_gfx6_gfx7<bits<8> op> {
19480b57cec5SDimitry Andric    def _ADDR64_gfx6_gfx7 :
19490b57cec5SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_ADDR64")>;
19500b57cec5SDimitry Andric    def _BOTHEN_gfx6_gfx7 :
19510b57cec5SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>;
19520b57cec5SDimitry Andric    def _IDXEN_gfx6_gfx7 :
19530b57cec5SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>;
19540b57cec5SDimitry Andric    def _OFFEN_gfx6_gfx7 :
19550b57cec5SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>;
19560b57cec5SDimitry Andric    def _OFFSET_gfx6_gfx7 :
19570b57cec5SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>;
19580b57cec5SDimitry Andric  }
19590b57cec5SDimitry Andric  multiclass MUBUF_Real_AllAddr_Lds_gfx6_gfx7<bits<8> op> {
19600b57cec5SDimitry Andric    def _OFFSET_gfx6_gfx7 : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>,
19610b57cec5SDimitry Andric                            MUBUFLdsTable<0, NAME # "_OFFSET_gfx6_gfx7">;
19620b57cec5SDimitry Andric    def _ADDR64_gfx6_gfx7 : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_ADDR64")>,
19630b57cec5SDimitry Andric                            MUBUFLdsTable<0, NAME # "_ADDR64_gfx6_gfx7">;
19640b57cec5SDimitry Andric    def _OFFEN_gfx6_gfx7  : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>,
19650b57cec5SDimitry Andric                            MUBUFLdsTable<0, NAME # "_OFFEN_gfx6_gfx7">;
19660b57cec5SDimitry Andric    def _IDXEN_gfx6_gfx7  : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>,
19670b57cec5SDimitry Andric                            MUBUFLdsTable<0, NAME # "_IDXEN_gfx6_gfx7">;
19680b57cec5SDimitry Andric    def _BOTHEN_gfx6_gfx7 : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>,
19690b57cec5SDimitry Andric                            MUBUFLdsTable<0, NAME # "_BOTHEN_gfx6_gfx7">;
19700b57cec5SDimitry Andric
19710b57cec5SDimitry Andric    def _LDS_OFFSET_gfx6_gfx7 : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_LDS_OFFSET")>,
19720b57cec5SDimitry Andric                                MUBUFLdsTable<1, NAME # "_OFFSET_gfx6_gfx7">;
19730b57cec5SDimitry Andric    def _LDS_ADDR64_gfx6_gfx7 : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_LDS_ADDR64")>,
19740b57cec5SDimitry Andric                                MUBUFLdsTable<1, NAME # "_ADDR64_gfx6_gfx7">;
19750b57cec5SDimitry Andric    def _LDS_OFFEN_gfx6_gfx7  : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_LDS_OFFEN")>,
19760b57cec5SDimitry Andric                                MUBUFLdsTable<1, NAME # "_OFFEN_gfx6_gfx7">;
19770b57cec5SDimitry Andric    def _LDS_IDXEN_gfx6_gfx7  : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_LDS_IDXEN")>,
19780b57cec5SDimitry Andric                                MUBUFLdsTable<1, NAME # "_IDXEN_gfx6_gfx7">;
19790b57cec5SDimitry Andric    def _LDS_BOTHEN_gfx6_gfx7 : MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_LDS_BOTHEN")>,
19800b57cec5SDimitry Andric                                MUBUFLdsTable<1, NAME # "_BOTHEN_gfx6_gfx7">;
19810b57cec5SDimitry Andric  }
19820b57cec5SDimitry Andric  multiclass MUBUF_Real_Atomics_gfx6_gfx7<bits<8> op> :
19830b57cec5SDimitry Andric      MUBUF_Real_AllAddr_gfx6_gfx7<op> {
19840b57cec5SDimitry Andric    def _ADDR64_RTN_gfx6_gfx7 :
19850b57cec5SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_ADDR64_RTN")>;
19860b57cec5SDimitry Andric    def _BOTHEN_RTN_gfx6_gfx7 :
19870b57cec5SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN_RTN")>;
19880b57cec5SDimitry Andric    def _IDXEN_RTN_gfx6_gfx7 :
19890b57cec5SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN_RTN")>;
19900b57cec5SDimitry Andric    def _OFFEN_RTN_gfx6_gfx7 :
19910b57cec5SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN_RTN")>;
19920b57cec5SDimitry Andric    def _OFFSET_RTN_gfx6_gfx7 :
19930b57cec5SDimitry Andric      MUBUF_Real_gfx6_gfx7<op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET_RTN")>;
19940b57cec5SDimitry Andric  }
19950b57cec5SDimitry Andric} // End AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7"
19960b57cec5SDimitry Andric
19970b57cec5SDimitry Andricmulticlass MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<bits<8> op> :
19980b57cec5SDimitry Andric  MUBUF_Real_AllAddr_gfx6_gfx7<op>, MUBUF_Real_AllAddr_gfx10<op>;
19990b57cec5SDimitry Andric
20000b57cec5SDimitry Andricmulticlass MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<bits<8> op> :
20010b57cec5SDimitry Andric  MUBUF_Real_AllAddr_Lds_gfx6_gfx7<op>, MUBUF_Real_AllAddr_Lds_gfx10<op>;
20020b57cec5SDimitry Andric
20030b57cec5SDimitry Andricmulticlass MUBUF_Real_Atomics_gfx6_gfx7_gfx10<bits<8> op> :
20040b57cec5SDimitry Andric  MUBUF_Real_Atomics_gfx6_gfx7<op>, MUBUF_Real_Atomics_gfx10<op>;
20050b57cec5SDimitry Andric
20060b57cec5SDimitry Andric// FIXME-GFX6: Following instructions are available only on GFX6.
20070b57cec5SDimitry Andric//defm BUFFER_ATOMIC_RSUB         : MUBUF_Real_Atomics_gfx6 <0x034>;
20080b57cec5SDimitry Andric//defm BUFFER_ATOMIC_RSUB_X2      : MUBUF_Real_Atomics_gfx6 <0x054>;
20090b57cec5SDimitry Andric
20100b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_X     : MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<0x000>;
20110b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XY    : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x001>;
20120b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZ   : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x002>;
20130b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZW  : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x003>;
20140b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_X    : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x004>;
20150b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XY   : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x005>;
20160b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZ  : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x006>;
20170b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZW : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x007>;
20180b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE        : MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<0x008>;
20190b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE        : MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<0x009>;
20200b57cec5SDimitry Andricdefm BUFFER_LOAD_USHORT       : MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<0x00a>;
20210b57cec5SDimitry Andricdefm BUFFER_LOAD_SSHORT       : MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<0x00b>;
20220b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORD        : MUBUF_Real_AllAddr_Lds_gfx6_gfx7_gfx10<0x00c>;
20230b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX2      : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x00d>;
20240b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX4      : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x00e>;
20250b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX3      : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x00f>;
20260b57cec5SDimitry Andricdefm BUFFER_STORE_BYTE        : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x018>;
20270b57cec5SDimitry Andricdefm BUFFER_STORE_SHORT       : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x01a>;
20280b57cec5SDimitry Andricdefm BUFFER_STORE_DWORD       : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x01c>;
20290b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX2     : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x01d>;
20300b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX4     : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x01e>;
20310b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX3     : MUBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x01f>;
20320b57cec5SDimitry Andric
20330b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SWAP        : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x030>;
20340b57cec5SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP     : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x031>;
20350b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD         : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x032>;
20360b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SUB         : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x033>;
20370b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMIN        : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x035>;
20380b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMIN        : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x036>;
20390b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMAX        : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x037>;
20400b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMAX        : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x038>;
20410b57cec5SDimitry Andricdefm BUFFER_ATOMIC_AND         : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x039>;
20420b57cec5SDimitry Andricdefm BUFFER_ATOMIC_OR          : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x03a>;
20430b57cec5SDimitry Andricdefm BUFFER_ATOMIC_XOR         : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x03b>;
20440b57cec5SDimitry Andricdefm BUFFER_ATOMIC_INC         : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x03c>;
20450b57cec5SDimitry Andricdefm BUFFER_ATOMIC_DEC         : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x03d>;
20468bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FCMPSWAP    : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x03e>;
20478bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMIN        : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x03f>;
20488bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMAX        : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x040>;
20490b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SWAP_X2     : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x050>;
20500b57cec5SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP_X2  : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x051>;
20510b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD_X2      : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x052>;
20520b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SUB_X2      : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x053>;
20530b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMIN_X2     : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x055>;
20540b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMIN_X2     : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x056>;
20550b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMAX_X2     : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x057>;
20560b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMAX_X2     : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x058>;
20570b57cec5SDimitry Andricdefm BUFFER_ATOMIC_AND_X2      : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x059>;
20580b57cec5SDimitry Andricdefm BUFFER_ATOMIC_OR_X2       : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x05a>;
20590b57cec5SDimitry Andricdefm BUFFER_ATOMIC_XOR_X2      : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x05b>;
20600b57cec5SDimitry Andricdefm BUFFER_ATOMIC_INC_X2      : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x05c>;
20610b57cec5SDimitry Andricdefm BUFFER_ATOMIC_DEC_X2      : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x05d>;
20620b57cec5SDimitry Andric// FIXME-GFX7: Need to handle hazard for BUFFER_ATOMIC_FCMPSWAP_X2 on GFX7.
20638bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FCMPSWAP_X2 : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x05e>;
20648bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMIN_X2     : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x05f>;
20658bcb0991SDimitry Andricdefm BUFFER_ATOMIC_FMAX_X2     : MUBUF_Real_Atomics_gfx6_gfx7_gfx10<0x060>;
20660b57cec5SDimitry Andric
2067*5ffd83dbSDimitry Andricdefm BUFFER_ATOMIC_CSUB       : MUBUF_Real_Atomics_RTN_gfx10<0x034>;
2068*5ffd83dbSDimitry Andric
20690b57cec5SDimitry Andricdefm BUFFER_WBINVL1_SC        : MUBUF_Real_gfx6<0x070>;
20700b57cec5SDimitry Andricdefm BUFFER_WBINVL1_VOL       : MUBUF_Real_gfx7<0x070>;
20710b57cec5SDimitry Andricdef  BUFFER_WBINVL1_gfx6_gfx7 : MUBUF_Real_gfx6_gfx7<0x071, BUFFER_WBINVL1>;
20720b57cec5SDimitry Andric
20730b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
20740b57cec5SDimitry Andric// Base ENC_MTBUF for GFX6, GFX7, GFX10.
20750b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
20760b57cec5SDimitry Andric
20770b57cec5SDimitry Andricclass Base_MTBUF_Real_gfx6_gfx7_gfx10<bits<3> op, MTBUF_Pseudo ps, int ef> :
20780b57cec5SDimitry Andric    MTBUF_Real<ps>, Enc64, SIMCInstr<ps.PseudoInstr, ef> {
20790b57cec5SDimitry Andric  let Inst{11-0}  = !if(ps.has_offset, offset, ?);
20800b57cec5SDimitry Andric  let Inst{12}    = ps.offen;
20810b57cec5SDimitry Andric  let Inst{13}    = ps.idxen;
20820b57cec5SDimitry Andric  let Inst{14}    = !if(ps.has_glc, glc, ps.glc_value);
20830b57cec5SDimitry Andric  let Inst{18-16} = op;
20840b57cec5SDimitry Andric  let Inst{31-26} = 0x3a; //encoding
20850b57cec5SDimitry Andric  let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?);
20860b57cec5SDimitry Andric  let Inst{47-40} = !if(ps.has_vdata, vdata, ?);
20870b57cec5SDimitry Andric  let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?);
20880b57cec5SDimitry Andric  let Inst{54}    = !if(ps.has_slc, slc, ?);
20890b57cec5SDimitry Andric  let Inst{55}    = !if(ps.has_tfe, tfe, ?);
20900b57cec5SDimitry Andric  let Inst{63-56} = !if(ps.has_soffset, soffset, ?);
20910b57cec5SDimitry Andric}
20920b57cec5SDimitry Andric
20930b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
20940b57cec5SDimitry Andric// MTBUF - GFX10.
20950b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
20960b57cec5SDimitry Andric
20970b57cec5SDimitry Andricclass MTBUF_Real_gfx10<bits<4> op, MTBUF_Pseudo ps> :
20980b57cec5SDimitry Andric    Base_MTBUF_Real_gfx6_gfx7_gfx10<op{2-0}, ps, SIEncodingFamily.GFX10> {
20990b57cec5SDimitry Andric  let Inst{15} = !if(ps.has_dlc, dlc, ps.dlc_value);
21000b57cec5SDimitry Andric  let Inst{25-19} = format;
21010b57cec5SDimitry Andric  let Inst{53} = op{3};
21020b57cec5SDimitry Andric}
21030b57cec5SDimitry Andric
21040b57cec5SDimitry Andriclet AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10" in {
21050b57cec5SDimitry Andric  multiclass MTBUF_Real_AllAddr_gfx10<bits<4> op> {
21060b57cec5SDimitry Andric    def _BOTHEN_gfx10 :
21070b57cec5SDimitry Andric      MTBUF_Real_gfx10<op, !cast<MTBUF_Pseudo>(NAME#"_BOTHEN")>;
21080b57cec5SDimitry Andric    def _IDXEN_gfx10 :
21090b57cec5SDimitry Andric      MTBUF_Real_gfx10<op, !cast<MTBUF_Pseudo>(NAME#"_IDXEN")>;
21100b57cec5SDimitry Andric    def _OFFEN_gfx10 :
21110b57cec5SDimitry Andric      MTBUF_Real_gfx10<op, !cast<MTBUF_Pseudo>(NAME#"_OFFEN")>;
21120b57cec5SDimitry Andric    def _OFFSET_gfx10 :
21130b57cec5SDimitry Andric      MTBUF_Real_gfx10<op, !cast<MTBUF_Pseudo>(NAME#"_OFFSET")>;
21140b57cec5SDimitry Andric  }
21150b57cec5SDimitry Andric} // End AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10"
21160b57cec5SDimitry Andric
21170b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_X     : MTBUF_Real_AllAddr_gfx10<0x008>;
21180b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_XY    : MTBUF_Real_AllAddr_gfx10<0x009>;
21190b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_XYZ   : MTBUF_Real_AllAddr_gfx10<0x00a>;
21200b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_D16_XYZW  : MTBUF_Real_AllAddr_gfx10<0x00b>;
21210b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_X    : MTBUF_Real_AllAddr_gfx10<0x00c>;
21220b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_XY   : MTBUF_Real_AllAddr_gfx10<0x00d>;
21230b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_XYZ  : MTBUF_Real_AllAddr_gfx10<0x00e>;
21240b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_D16_XYZW : MTBUF_Real_AllAddr_gfx10<0x00f>;
21250b57cec5SDimitry Andric
21260b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
21270b57cec5SDimitry Andric// MTBUF - GFX6, GFX7, GFX10.
21280b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
21290b57cec5SDimitry Andric
21300b57cec5SDimitry Andricclass MTBUF_Real_gfx6_gfx7<bits<4> op, MTBUF_Pseudo ps> :
21310b57cec5SDimitry Andric    Base_MTBUF_Real_gfx6_gfx7_gfx10<op{2-0}, ps, SIEncodingFamily.SI> {
21320b57cec5SDimitry Andric  let Inst{15} = ps.addr64;
21330b57cec5SDimitry Andric  let Inst{22-19} = dfmt;
21340b57cec5SDimitry Andric  let Inst{25-23} = nfmt;
21350b57cec5SDimitry Andric}
21360b57cec5SDimitry Andric
21370b57cec5SDimitry Andriclet AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" in {
21380b57cec5SDimitry Andric  multiclass MTBUF_Real_AllAddr_gfx6_gfx7<bits<4> op> {
21390b57cec5SDimitry Andric    def _ADDR64_gfx6_gfx7 :
21400b57cec5SDimitry Andric      MTBUF_Real_gfx6_gfx7<op, !cast<MTBUF_Pseudo>(NAME#"_ADDR64")>;
21410b57cec5SDimitry Andric    def _BOTHEN_gfx6_gfx7 :
21420b57cec5SDimitry Andric      MTBUF_Real_gfx6_gfx7<op, !cast<MTBUF_Pseudo>(NAME#"_BOTHEN")>;
21430b57cec5SDimitry Andric    def _IDXEN_gfx6_gfx7 :
21440b57cec5SDimitry Andric      MTBUF_Real_gfx6_gfx7<op, !cast<MTBUF_Pseudo>(NAME#"_IDXEN")>;
21450b57cec5SDimitry Andric    def _OFFEN_gfx6_gfx7 :
21460b57cec5SDimitry Andric      MTBUF_Real_gfx6_gfx7<op, !cast<MTBUF_Pseudo>(NAME#"_OFFEN")>;
21470b57cec5SDimitry Andric    def _OFFSET_gfx6_gfx7 :
21480b57cec5SDimitry Andric      MTBUF_Real_gfx6_gfx7<op, !cast<MTBUF_Pseudo>(NAME#"_OFFSET")>;
21490b57cec5SDimitry Andric  }
21500b57cec5SDimitry Andric} // End AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7"
21510b57cec5SDimitry Andric
21520b57cec5SDimitry Andricmulticlass MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<bits<4> op> :
21530b57cec5SDimitry Andric  MTBUF_Real_AllAddr_gfx6_gfx7<op>, MTBUF_Real_AllAddr_gfx10<op>;
21540b57cec5SDimitry Andric
21550b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_X     : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x000>;
21560b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XY    : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x001>;
21570b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZ   : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x002>;
21580b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZW  : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x003>;
21590b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_X    : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x004>;
21600b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_XY   : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x005>;
21610b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZ  : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x006>;
21620b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZW : MTBUF_Real_AllAddr_gfx6_gfx7_gfx10<0x007>;
21630b57cec5SDimitry Andric
21640b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
21650b57cec5SDimitry Andric// GFX8, GFX9 (VI).
21660b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
21670b57cec5SDimitry Andric
21680b57cec5SDimitry Andricclass MUBUF_Real_vi <bits<7> op, MUBUF_Pseudo ps> :
21690b57cec5SDimitry Andric  MUBUF_Real<ps>,
21700b57cec5SDimitry Andric  Enc64,
21710b57cec5SDimitry Andric  SIMCInstr<ps.PseudoInstr, SIEncodingFamily.VI> {
21720b57cec5SDimitry Andric  let AssemblerPredicate = isGFX8GFX9;
21730b57cec5SDimitry Andric  let DecoderNamespace = "GFX8";
21740b57cec5SDimitry Andric
21750b57cec5SDimitry Andric  let Inst{11-0}  = !if(ps.has_offset, offset, ?);
21760b57cec5SDimitry Andric  let Inst{12}    = ps.offen;
21770b57cec5SDimitry Andric  let Inst{13}    = ps.idxen;
21780b57cec5SDimitry Andric  let Inst{14}    = !if(ps.has_glc, glc, ps.glc_value);
21790b57cec5SDimitry Andric  let Inst{16}    = !if(ps.lds, 1, 0);
21800b57cec5SDimitry Andric  let Inst{17}    = !if(ps.has_slc, slc, ?);
21810b57cec5SDimitry Andric  let Inst{24-18} = op;
21820b57cec5SDimitry Andric  let Inst{31-26} = 0x38; //encoding
21830b57cec5SDimitry Andric  let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?);
21840b57cec5SDimitry Andric  let Inst{47-40} = !if(ps.has_vdata, vdata, ?);
21850b57cec5SDimitry Andric  let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?);
21860b57cec5SDimitry Andric  let Inst{55}    = !if(ps.has_tfe, tfe, ?);
21870b57cec5SDimitry Andric  let Inst{63-56} = !if(ps.has_soffset, soffset, ?);
21880b57cec5SDimitry Andric}
21890b57cec5SDimitry Andric
21900b57cec5SDimitry Andricmulticlass MUBUF_Real_AllAddr_vi<bits<7> op> {
21910b57cec5SDimitry Andric  def _OFFSET_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>;
21920b57cec5SDimitry Andric  def _OFFEN_vi  : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>;
21930b57cec5SDimitry Andric  def _IDXEN_vi  : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>;
21940b57cec5SDimitry Andric  def _BOTHEN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>;
21950b57cec5SDimitry Andric}
21960b57cec5SDimitry Andric
21970b57cec5SDimitry Andricmulticlass MUBUF_Real_AllAddr_Lds_vi<bits<7> op> {
21980b57cec5SDimitry Andric
21990b57cec5SDimitry Andric  def _OFFSET_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>,
22000b57cec5SDimitry Andric                   MUBUFLdsTable<0, NAME # "_OFFSET_vi">;
22010b57cec5SDimitry Andric  def _OFFEN_vi  : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>,
22020b57cec5SDimitry Andric                   MUBUFLdsTable<0, NAME # "_OFFEN_vi">;
22030b57cec5SDimitry Andric  def _IDXEN_vi  : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>,
22040b57cec5SDimitry Andric                   MUBUFLdsTable<0, NAME # "_IDXEN_vi">;
22050b57cec5SDimitry Andric  def _BOTHEN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>,
22060b57cec5SDimitry Andric                   MUBUFLdsTable<0, NAME # "_BOTHEN_vi">;
22070b57cec5SDimitry Andric
22080b57cec5SDimitry Andric  def _LDS_OFFSET_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_OFFSET")>,
22090b57cec5SDimitry Andric                       MUBUFLdsTable<1, NAME # "_OFFSET_vi">;
22100b57cec5SDimitry Andric  def _LDS_OFFEN_vi  : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_OFFEN")>,
22110b57cec5SDimitry Andric                       MUBUFLdsTable<1, NAME # "_OFFEN_vi">;
22120b57cec5SDimitry Andric  def _LDS_IDXEN_vi  : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_IDXEN")>,
22130b57cec5SDimitry Andric                       MUBUFLdsTable<1, NAME # "_IDXEN_vi">;
22140b57cec5SDimitry Andric  def _LDS_BOTHEN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_BOTHEN")>,
22150b57cec5SDimitry Andric                       MUBUFLdsTable<1, NAME # "_BOTHEN_vi">;
22160b57cec5SDimitry Andric}
22170b57cec5SDimitry Andric
22180b57cec5SDimitry Andricclass MUBUF_Real_gfx80 <bits<7> op, MUBUF_Pseudo ps> :
22190b57cec5SDimitry Andric  MUBUF_Real<ps>,
22200b57cec5SDimitry Andric  Enc64,
22210b57cec5SDimitry Andric  SIMCInstr<ps.PseudoInstr, SIEncodingFamily.GFX80> {
22220b57cec5SDimitry Andric  let AssemblerPredicate=HasUnpackedD16VMem;
22230b57cec5SDimitry Andric  let DecoderNamespace="GFX80_UNPACKED";
22240b57cec5SDimitry Andric
22250b57cec5SDimitry Andric  let Inst{11-0}  = !if(ps.has_offset, offset, ?);
22260b57cec5SDimitry Andric  let Inst{12}    = ps.offen;
22270b57cec5SDimitry Andric  let Inst{13}    = ps.idxen;
22280b57cec5SDimitry Andric  let Inst{14}    = !if(ps.has_glc, glc, ps.glc_value);
22290b57cec5SDimitry Andric  let Inst{16}    = !if(ps.lds, 1, 0);
22300b57cec5SDimitry Andric  let Inst{17}    = !if(ps.has_slc, slc, ?);
22310b57cec5SDimitry Andric  let Inst{24-18} = op;
22320b57cec5SDimitry Andric  let Inst{31-26} = 0x38; //encoding
22330b57cec5SDimitry Andric  let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?);
22340b57cec5SDimitry Andric  let Inst{47-40} = !if(ps.has_vdata, vdata, ?);
22350b57cec5SDimitry Andric  let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?);
22360b57cec5SDimitry Andric  let Inst{55}    = !if(ps.has_tfe, tfe, ?);
22370b57cec5SDimitry Andric  let Inst{63-56} = !if(ps.has_soffset, soffset, ?);
22380b57cec5SDimitry Andric}
22390b57cec5SDimitry Andric
22400b57cec5SDimitry Andricmulticlass MUBUF_Real_AllAddr_gfx80<bits<7> op> {
22410b57cec5SDimitry Andric  def _OFFSET_gfx80 : MUBUF_Real_gfx80 <op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>;
22420b57cec5SDimitry Andric  def _OFFEN_gfx80  : MUBUF_Real_gfx80 <op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>;
22430b57cec5SDimitry Andric  def _IDXEN_gfx80  : MUBUF_Real_gfx80 <op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>;
22440b57cec5SDimitry Andric  def _BOTHEN_gfx80 : MUBUF_Real_gfx80 <op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>;
22450b57cec5SDimitry Andric}
22460b57cec5SDimitry Andric
22470b57cec5SDimitry Andricmulticlass MUBUF_Real_Atomic_vi<bits<7> op> :
22480b57cec5SDimitry Andric  MUBUF_Real_AllAddr_vi<op> {
22490b57cec5SDimitry Andric  def _OFFSET_RTN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET_RTN")>;
22500b57cec5SDimitry Andric  def _OFFEN_RTN_vi  : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN_RTN")>;
22510b57cec5SDimitry Andric  def _IDXEN_RTN_vi  : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN_RTN")>;
22520b57cec5SDimitry Andric  def _BOTHEN_RTN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN_RTN")>;
22530b57cec5SDimitry Andric}
22540b57cec5SDimitry Andric
22550b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_X       : MUBUF_Real_AllAddr_Lds_vi <0x00>;
22560b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XY      : MUBUF_Real_AllAddr_vi <0x01>;
22570b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZ     : MUBUF_Real_AllAddr_vi <0x02>;
22580b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_XYZW    : MUBUF_Real_AllAddr_vi <0x03>;
22590b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_X      : MUBUF_Real_AllAddr_vi <0x04>;
22600b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XY     : MUBUF_Real_AllAddr_vi <0x05>;
22610b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZ    : MUBUF_Real_AllAddr_vi <0x06>;
22620b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_XYZW   : MUBUF_Real_AllAddr_vi <0x07>;
22630b57cec5SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem in {
22640b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_X_gfx80       : MUBUF_Real_AllAddr_gfx80 <0x08>;
22650b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XY_gfx80      : MUBUF_Real_AllAddr_gfx80 <0x09>;
22660b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XYZ_gfx80     : MUBUF_Real_AllAddr_gfx80 <0x0a>;
22670b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XYZW_gfx80    : MUBUF_Real_AllAddr_gfx80 <0x0b>;
22680b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_X_gfx80      : MUBUF_Real_AllAddr_gfx80 <0x0c>;
22690b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XY_gfx80     : MUBUF_Real_AllAddr_gfx80 <0x0d>;
22700b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XYZ_gfx80    : MUBUF_Real_AllAddr_gfx80 <0x0e>;
22710b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XYZW_gfx80   : MUBUF_Real_AllAddr_gfx80 <0x0f>;
22720b57cec5SDimitry Andric} // End HasUnpackedD16VMem.
22730b57cec5SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem in {
22740b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_X       : MUBUF_Real_AllAddr_vi <0x08>;
22750b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XY      : MUBUF_Real_AllAddr_vi <0x09>;
22760b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XYZ     : MUBUF_Real_AllAddr_vi <0x0a>;
22770b57cec5SDimitry Andric  defm BUFFER_LOAD_FORMAT_D16_XYZW    : MUBUF_Real_AllAddr_vi <0x0b>;
22780b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_X      : MUBUF_Real_AllAddr_vi <0x0c>;
22790b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XY     : MUBUF_Real_AllAddr_vi <0x0d>;
22800b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XYZ    : MUBUF_Real_AllAddr_vi <0x0e>;
22810b57cec5SDimitry Andric  defm BUFFER_STORE_FORMAT_D16_XYZW   : MUBUF_Real_AllAddr_vi <0x0f>;
22820b57cec5SDimitry Andric} // End HasPackedD16VMem.
22830b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE          : MUBUF_Real_AllAddr_Lds_vi <0x10>;
22840b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE          : MUBUF_Real_AllAddr_Lds_vi <0x11>;
22850b57cec5SDimitry Andricdefm BUFFER_LOAD_USHORT         : MUBUF_Real_AllAddr_Lds_vi <0x12>;
22860b57cec5SDimitry Andricdefm BUFFER_LOAD_SSHORT         : MUBUF_Real_AllAddr_Lds_vi <0x13>;
22870b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORD          : MUBUF_Real_AllAddr_Lds_vi <0x14>;
22880b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX2        : MUBUF_Real_AllAddr_Lds_vi <0x15>;
22890b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX3        : MUBUF_Real_AllAddr_Lds_vi <0x16>;
22900b57cec5SDimitry Andricdefm BUFFER_LOAD_DWORDX4        : MUBUF_Real_AllAddr_Lds_vi <0x17>;
22910b57cec5SDimitry Andricdefm BUFFER_STORE_BYTE          : MUBUF_Real_AllAddr_vi <0x18>;
22920b57cec5SDimitry Andricdefm BUFFER_STORE_BYTE_D16_HI   : MUBUF_Real_AllAddr_vi <0x19>;
22930b57cec5SDimitry Andricdefm BUFFER_STORE_SHORT         : MUBUF_Real_AllAddr_vi <0x1a>;
22940b57cec5SDimitry Andricdefm BUFFER_STORE_SHORT_D16_HI  : MUBUF_Real_AllAddr_vi <0x1b>;
22950b57cec5SDimitry Andricdefm BUFFER_STORE_DWORD         : MUBUF_Real_AllAddr_vi <0x1c>;
22960b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX2       : MUBUF_Real_AllAddr_vi <0x1d>;
22970b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX3       : MUBUF_Real_AllAddr_vi <0x1e>;
22980b57cec5SDimitry Andricdefm BUFFER_STORE_DWORDX4       : MUBUF_Real_AllAddr_vi <0x1f>;
22990b57cec5SDimitry Andric
23000b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16      : MUBUF_Real_AllAddr_vi <0x20>;
23010b57cec5SDimitry Andricdefm BUFFER_LOAD_UBYTE_D16_HI   : MUBUF_Real_AllAddr_vi <0x21>;
23020b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16      : MUBUF_Real_AllAddr_vi <0x22>;
23030b57cec5SDimitry Andricdefm BUFFER_LOAD_SBYTE_D16_HI   : MUBUF_Real_AllAddr_vi <0x23>;
23040b57cec5SDimitry Andricdefm BUFFER_LOAD_SHORT_D16      : MUBUF_Real_AllAddr_vi <0x24>;
23050b57cec5SDimitry Andricdefm BUFFER_LOAD_SHORT_D16_HI   : MUBUF_Real_AllAddr_vi <0x25>;
23060b57cec5SDimitry Andric
23070b57cec5SDimitry Andricdefm BUFFER_LOAD_FORMAT_D16_HI_X  : MUBUF_Real_AllAddr_vi <0x26>;
23080b57cec5SDimitry Andricdefm BUFFER_STORE_FORMAT_D16_HI_X : MUBUF_Real_AllAddr_vi <0x27>;
23090b57cec5SDimitry Andric
23100b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SWAP         : MUBUF_Real_Atomic_vi <0x40>;
23110b57cec5SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP      : MUBUF_Real_Atomic_vi <0x41>;
23120b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD          : MUBUF_Real_Atomic_vi <0x42>;
23130b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SUB          : MUBUF_Real_Atomic_vi <0x43>;
23140b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMIN         : MUBUF_Real_Atomic_vi <0x44>;
23150b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMIN         : MUBUF_Real_Atomic_vi <0x45>;
23160b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMAX         : MUBUF_Real_Atomic_vi <0x46>;
23170b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMAX         : MUBUF_Real_Atomic_vi <0x47>;
23180b57cec5SDimitry Andricdefm BUFFER_ATOMIC_AND          : MUBUF_Real_Atomic_vi <0x48>;
23190b57cec5SDimitry Andricdefm BUFFER_ATOMIC_OR           : MUBUF_Real_Atomic_vi <0x49>;
23200b57cec5SDimitry Andricdefm BUFFER_ATOMIC_XOR          : MUBUF_Real_Atomic_vi <0x4a>;
23210b57cec5SDimitry Andricdefm BUFFER_ATOMIC_INC          : MUBUF_Real_Atomic_vi <0x4b>;
23220b57cec5SDimitry Andricdefm BUFFER_ATOMIC_DEC          : MUBUF_Real_Atomic_vi <0x4c>;
23230b57cec5SDimitry Andric
23240b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SWAP_X2      : MUBUF_Real_Atomic_vi <0x60>;
23250b57cec5SDimitry Andricdefm BUFFER_ATOMIC_CMPSWAP_X2   : MUBUF_Real_Atomic_vi <0x61>;
23260b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD_X2       : MUBUF_Real_Atomic_vi <0x62>;
23270b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SUB_X2       : MUBUF_Real_Atomic_vi <0x63>;
23280b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMIN_X2      : MUBUF_Real_Atomic_vi <0x64>;
23290b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMIN_X2      : MUBUF_Real_Atomic_vi <0x65>;
23300b57cec5SDimitry Andricdefm BUFFER_ATOMIC_SMAX_X2      : MUBUF_Real_Atomic_vi <0x66>;
23310b57cec5SDimitry Andricdefm BUFFER_ATOMIC_UMAX_X2      : MUBUF_Real_Atomic_vi <0x67>;
23320b57cec5SDimitry Andricdefm BUFFER_ATOMIC_AND_X2       : MUBUF_Real_Atomic_vi <0x68>;
23330b57cec5SDimitry Andricdefm BUFFER_ATOMIC_OR_X2        : MUBUF_Real_Atomic_vi <0x69>;
23340b57cec5SDimitry Andricdefm BUFFER_ATOMIC_XOR_X2       : MUBUF_Real_Atomic_vi <0x6a>;
23350b57cec5SDimitry Andricdefm BUFFER_ATOMIC_INC_X2       : MUBUF_Real_Atomic_vi <0x6b>;
23360b57cec5SDimitry Andricdefm BUFFER_ATOMIC_DEC_X2       : MUBUF_Real_Atomic_vi <0x6c>;
23370b57cec5SDimitry Andric
23380b57cec5SDimitry Andricdef BUFFER_STORE_LDS_DWORD_vi   : MUBUF_Real_vi <0x3d, BUFFER_STORE_LDS_DWORD>;
23390b57cec5SDimitry Andric
23400b57cec5SDimitry Andricdef BUFFER_WBINVL1_vi           : MUBUF_Real_vi <0x3e, BUFFER_WBINVL1>;
23410b57cec5SDimitry Andricdef BUFFER_WBINVL1_VOL_vi       : MUBUF_Real_vi <0x3f, BUFFER_WBINVL1_VOL>;
23420b57cec5SDimitry Andric
23430b57cec5SDimitry Andriclet SubtargetPredicate = HasAtomicFaddInsts in {
23440b57cec5SDimitry Andric
23450b57cec5SDimitry Andricdefm BUFFER_ATOMIC_ADD_F32    : MUBUF_Real_AllAddr_vi <0x4d>;
23460b57cec5SDimitry Andricdefm BUFFER_ATOMIC_PK_ADD_F16 : MUBUF_Real_AllAddr_vi <0x4e>;
23470b57cec5SDimitry Andric
23480b57cec5SDimitry Andric} // End SubtargetPredicate = HasAtomicFaddInsts
23490b57cec5SDimitry Andric
23500b57cec5SDimitry Andricclass MTBUF_Real_vi <bits<4> op, MTBUF_Pseudo ps> :
23510b57cec5SDimitry Andric  MTBUF_Real<ps>,
23520b57cec5SDimitry Andric  Enc64,
23530b57cec5SDimitry Andric  SIMCInstr<ps.PseudoInstr, SIEncodingFamily.VI> {
23540b57cec5SDimitry Andric  let AssemblerPredicate = isGFX8GFX9;
23550b57cec5SDimitry Andric  let DecoderNamespace = "GFX8";
23560b57cec5SDimitry Andric
23570b57cec5SDimitry Andric  let Inst{11-0}  = !if(ps.has_offset, offset, ?);
23580b57cec5SDimitry Andric  let Inst{12}    = ps.offen;
23590b57cec5SDimitry Andric  let Inst{13}    = ps.idxen;
23600b57cec5SDimitry Andric  let Inst{14}    = !if(ps.has_glc, glc, ps.glc_value);
23610b57cec5SDimitry Andric  let Inst{18-15} = op;
23620b57cec5SDimitry Andric  let Inst{22-19} = dfmt;
23630b57cec5SDimitry Andric  let Inst{25-23} = nfmt;
23640b57cec5SDimitry Andric  let Inst{31-26} = 0x3a; //encoding
23650b57cec5SDimitry Andric  let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?);
23660b57cec5SDimitry Andric  let Inst{47-40} = !if(ps.has_vdata, vdata, ?);
23670b57cec5SDimitry Andric  let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?);
23680b57cec5SDimitry Andric  let Inst{54}    = !if(ps.has_slc, slc, ?);
23690b57cec5SDimitry Andric  let Inst{55}    = !if(ps.has_tfe, tfe, ?);
23700b57cec5SDimitry Andric  let Inst{63-56} = !if(ps.has_soffset, soffset, ?);
23710b57cec5SDimitry Andric}
23720b57cec5SDimitry Andric
23730b57cec5SDimitry Andricmulticlass MTBUF_Real_AllAddr_vi<bits<4> op> {
23740b57cec5SDimitry Andric  def _OFFSET_vi : MTBUF_Real_vi <op, !cast<MTBUF_Pseudo>(NAME#"_OFFSET")>;
23750b57cec5SDimitry Andric  def _OFFEN_vi  : MTBUF_Real_vi <op, !cast<MTBUF_Pseudo>(NAME#"_OFFEN")>;
23760b57cec5SDimitry Andric  def _IDXEN_vi  : MTBUF_Real_vi <op, !cast<MTBUF_Pseudo>(NAME#"_IDXEN")>;
23770b57cec5SDimitry Andric  def _BOTHEN_vi : MTBUF_Real_vi <op, !cast<MTBUF_Pseudo>(NAME#"_BOTHEN")>;
23780b57cec5SDimitry Andric}
23790b57cec5SDimitry Andric
23800b57cec5SDimitry Andricclass MTBUF_Real_gfx80 <bits<4> op, MTBUF_Pseudo ps> :
23810b57cec5SDimitry Andric  MTBUF_Real<ps>,
23820b57cec5SDimitry Andric  Enc64,
23830b57cec5SDimitry Andric  SIMCInstr<ps.PseudoInstr, SIEncodingFamily.GFX80> {
23840b57cec5SDimitry Andric  let AssemblerPredicate=HasUnpackedD16VMem;
23850b57cec5SDimitry Andric  let DecoderNamespace="GFX80_UNPACKED";
23860b57cec5SDimitry Andric
23870b57cec5SDimitry Andric  let Inst{11-0}  = !if(ps.has_offset, offset, ?);
23880b57cec5SDimitry Andric  let Inst{12}    = ps.offen;
23890b57cec5SDimitry Andric  let Inst{13}    = ps.idxen;
23900b57cec5SDimitry Andric  let Inst{14}    = !if(ps.has_glc, glc, ps.glc_value);
23910b57cec5SDimitry Andric  let Inst{18-15} = op;
23920b57cec5SDimitry Andric  let Inst{22-19} = dfmt;
23930b57cec5SDimitry Andric  let Inst{25-23} = nfmt;
23940b57cec5SDimitry Andric  let Inst{31-26} = 0x3a; //encoding
23950b57cec5SDimitry Andric  let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?);
23960b57cec5SDimitry Andric  let Inst{47-40} = !if(ps.has_vdata, vdata, ?);
23970b57cec5SDimitry Andric  let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?);
23980b57cec5SDimitry Andric  let Inst{54}    = !if(ps.has_slc, slc, ?);
23990b57cec5SDimitry Andric  let Inst{55}    = !if(ps.has_tfe, tfe, ?);
24000b57cec5SDimitry Andric  let Inst{63-56} = !if(ps.has_soffset, soffset, ?);
24010b57cec5SDimitry Andric}
24020b57cec5SDimitry Andric
24030b57cec5SDimitry Andricmulticlass MTBUF_Real_AllAddr_gfx80<bits<4> op> {
24040b57cec5SDimitry Andric  def _OFFSET_gfx80 : MTBUF_Real_gfx80 <op, !cast<MTBUF_Pseudo>(NAME#"_OFFSET")>;
24050b57cec5SDimitry Andric  def _OFFEN_gfx80  : MTBUF_Real_gfx80 <op, !cast<MTBUF_Pseudo>(NAME#"_OFFEN")>;
24060b57cec5SDimitry Andric  def _IDXEN_gfx80  : MTBUF_Real_gfx80 <op, !cast<MTBUF_Pseudo>(NAME#"_IDXEN")>;
24070b57cec5SDimitry Andric  def _BOTHEN_gfx80 : MTBUF_Real_gfx80 <op, !cast<MTBUF_Pseudo>(NAME#"_BOTHEN")>;
24080b57cec5SDimitry Andric}
24090b57cec5SDimitry Andric
24100b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_X     : MTBUF_Real_AllAddr_vi <0x00>;
24110b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XY    : MTBUF_Real_AllAddr_vi <0x01>;
24120b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZ   : MTBUF_Real_AllAddr_vi <0x02>;
24130b57cec5SDimitry Andricdefm TBUFFER_LOAD_FORMAT_XYZW  : MTBUF_Real_AllAddr_vi <0x03>;
24140b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_X    : MTBUF_Real_AllAddr_vi <0x04>;
24150b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_XY   : MTBUF_Real_AllAddr_vi <0x05>;
24160b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZ  : MTBUF_Real_AllAddr_vi <0x06>;
24170b57cec5SDimitry Andricdefm TBUFFER_STORE_FORMAT_XYZW : MTBUF_Real_AllAddr_vi <0x07>;
24180b57cec5SDimitry Andriclet SubtargetPredicate = HasUnpackedD16VMem in {
24190b57cec5SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_X_gfx80     : MTBUF_Real_AllAddr_gfx80 <0x08>;
24200b57cec5SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XY_gfx80    : MTBUF_Real_AllAddr_gfx80 <0x09>;
24210b57cec5SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XYZ_gfx80   : MTBUF_Real_AllAddr_gfx80 <0x0a>;
24220b57cec5SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XYZW_gfx80  : MTBUF_Real_AllAddr_gfx80 <0x0b>;
24230b57cec5SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_X_gfx80    : MTBUF_Real_AllAddr_gfx80 <0x0c>;
24240b57cec5SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XY_gfx80   : MTBUF_Real_AllAddr_gfx80 <0x0d>;
24250b57cec5SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XYZ_gfx80  : MTBUF_Real_AllAddr_gfx80 <0x0e>;
24260b57cec5SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XYZW_gfx80 : MTBUF_Real_AllAddr_gfx80 <0x0f>;
24270b57cec5SDimitry Andric} // End HasUnpackedD16VMem.
24280b57cec5SDimitry Andriclet SubtargetPredicate = HasPackedD16VMem in {
24290b57cec5SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_X     : MTBUF_Real_AllAddr_vi <0x08>;
24300b57cec5SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XY    : MTBUF_Real_AllAddr_vi <0x09>;
24310b57cec5SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XYZ   : MTBUF_Real_AllAddr_vi <0x0a>;
24320b57cec5SDimitry Andric  defm TBUFFER_LOAD_FORMAT_D16_XYZW  : MTBUF_Real_AllAddr_vi <0x0b>;
24330b57cec5SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_X    : MTBUF_Real_AllAddr_vi <0x0c>;
24340b57cec5SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XY   : MTBUF_Real_AllAddr_vi <0x0d>;
24350b57cec5SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XYZ  : MTBUF_Real_AllAddr_vi <0x0e>;
24360b57cec5SDimitry Andric  defm TBUFFER_STORE_FORMAT_D16_XYZW : MTBUF_Real_AllAddr_vi <0x0f>;
24370b57cec5SDimitry Andric} // End HasUnpackedD16VMem.
24380b57cec5SDimitry Andric
24390b57cec5SDimitry Andricdef MUBUFInfoTable : GenericTable {
24400b57cec5SDimitry Andric  let FilterClass = "MUBUF_Pseudo";
24410b57cec5SDimitry Andric  let CppTypeName = "MUBUFInfo";
24428bcb0991SDimitry Andric  let Fields = ["Opcode", "BaseOpcode", "elements", "has_vaddr", "has_srsrc", "has_soffset"];
24430b57cec5SDimitry Andric
24440b57cec5SDimitry Andric  let PrimaryKey = ["Opcode"];
24450b57cec5SDimitry Andric  let PrimaryKeyName = "getMUBUFOpcodeHelper";
24460b57cec5SDimitry Andric}
24470b57cec5SDimitry Andric
24480b57cec5SDimitry Andricdef getMUBUFInfoFromOpcode : SearchIndex {
24490b57cec5SDimitry Andric  let Table = MUBUFInfoTable;
24500b57cec5SDimitry Andric  let Key = ["Opcode"];
24510b57cec5SDimitry Andric}
24520b57cec5SDimitry Andric
24538bcb0991SDimitry Andricdef getMUBUFInfoFromBaseOpcodeAndElements : SearchIndex {
24540b57cec5SDimitry Andric  let Table = MUBUFInfoTable;
24558bcb0991SDimitry Andric  let Key = ["BaseOpcode", "elements"];
24568bcb0991SDimitry Andric}
24578bcb0991SDimitry Andric
24588bcb0991SDimitry Andricdef MTBUFInfoTable : GenericTable {
24598bcb0991SDimitry Andric  let FilterClass = "MTBUF_Pseudo";
24608bcb0991SDimitry Andric  let CppTypeName = "MTBUFInfo";
24618bcb0991SDimitry Andric  let Fields = ["Opcode", "BaseOpcode", "elements", "has_vaddr", "has_srsrc", "has_soffset"];
24628bcb0991SDimitry Andric
24638bcb0991SDimitry Andric  let PrimaryKey = ["Opcode"];
24648bcb0991SDimitry Andric  let PrimaryKeyName = "getMTBUFOpcodeHelper";
24658bcb0991SDimitry Andric}
24668bcb0991SDimitry Andric
24678bcb0991SDimitry Andricdef getMTBUFInfoFromOpcode : SearchIndex {
24688bcb0991SDimitry Andric  let Table = MTBUFInfoTable;
24698bcb0991SDimitry Andric  let Key = ["Opcode"];
24708bcb0991SDimitry Andric}
24718bcb0991SDimitry Andric
24728bcb0991SDimitry Andricdef getMTBUFInfoFromBaseOpcodeAndElements : SearchIndex {
24738bcb0991SDimitry Andric  let Table = MTBUFInfoTable;
24748bcb0991SDimitry Andric  let Key = ["BaseOpcode", "elements"];
24750b57cec5SDimitry Andric}
2476