1 //===-- BUFInstructions.td - Buffer Instruction Defintions ----------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 def MUBUFAddr32 : ComplexPattern<i64, 9, "SelectMUBUFAddr32">;
10 def MUBUFAddr64 : ComplexPattern<i64, 7, "SelectMUBUFAddr64">;
11 def MUBUFAddr64Atomic : ComplexPattern<i64, 5, "SelectMUBUFAddr64">;
13 def MUBUFScratchOffen : ComplexPattern<i64, 4, "SelectMUBUFScratchOffen", [], [SDNPWantParent]>;
14 def MUBUFScratchOffset : ComplexPattern<i64, 3, "SelectMUBUFScratchOffset", [], [SDNPWantParent], 20>;
16 def MUBUFOffset : ComplexPattern<i64, 6, "SelectMUBUFOffset">;
17 def MUBUFOffsetNoGLC : ComplexPattern<i64, 3, "SelectMUBUFOffset">;
18 def MUBUFOffsetAtomic : ComplexPattern<i64, 4, "SelectMUBUFOffset">;
20 class MubufLoad <SDPatternOperator op> : PatFrag <
21 (ops node:$ptr), (op node:$ptr), [{
22 auto const AS = cast<MemSDNode>(N)->getAddressSpace();
23 return AS == AMDGPUAS::GLOBAL_ADDRESS ||
24 AS == AMDGPUAS::CONSTANT_ADDRESS;
27 def mubuf_load : MubufLoad <load>;
28 def mubuf_az_extloadi8 : MubufLoad <az_extloadi8>;
29 def mubuf_sextloadi8 : MubufLoad <sextloadi8>;
30 def mubuf_az_extloadi16 : MubufLoad <az_extloadi16>;
31 def mubuf_sextloadi16 : MubufLoad <sextloadi16>;
32 def mubuf_load_atomic : MubufLoad <atomic_load>;
42 class getAddrName<int addrKind> {
44 !if(!eq(addrKind, BUFAddrKind.Offset), "offset",
45 !if(!eq(addrKind, BUFAddrKind.OffEn), "offen",
46 !if(!eq(addrKind, BUFAddrKind.IdxEn), "idxen",
47 !if(!eq(addrKind, BUFAddrKind.BothEn), "bothen",
48 !if(!eq(addrKind, BUFAddrKind.Addr64), "addr64",
52 class MUBUFAddr64Table <bit is_addr64, string Name> {
53 bit IsAddr64 = is_addr64;
57 class MUBUFLdsTable <bit is_lds, string Name> {
62 class MTBUFAddr64Table <bit is_addr64, string Name> {
63 bit IsAddr64 = is_addr64;
67 //===----------------------------------------------------------------------===//
69 //===----------------------------------------------------------------------===//
71 class MTBUF_Pseudo <string opName, dag outs, dag ins,
72 string asmOps, list<dag> pattern=[]> :
73 InstSI<outs, ins, "", pattern>,
74 SIMCInstr<opName, SIEncodingFamily.NONE> {
77 let isCodeGenOnly = 1;
79 let UseNamedOperandTable = 1;
81 string Mnemonic = opName;
82 string AsmOperands = asmOps;
88 let hasSideEffects = 0;
89 let SchedRW = [WriteVMEM];
91 let AsmMatchConverter = "cvtMtbuf";
96 bits<1> has_vdata = 1;
97 bits<1> has_vaddr = 1;
99 bits<1> glc_value = 0; // the value for glc if no such operand
100 bits<1> has_srsrc = 1;
101 bits<1> has_soffset = 1;
102 bits<1> has_offset = 1;
107 class MTBUF_Real <MTBUF_Pseudo ps> :
108 InstSI <ps.OutOperandList, ps.InOperandList, ps.Mnemonic # ps.AsmOperands, []> {
111 let isCodeGenOnly = 0;
113 // copy relevant pseudo op flags
114 let SubtargetPredicate = ps.SubtargetPredicate;
115 let AsmMatchConverter = ps.AsmMatchConverter;
116 let Constraints = ps.Constraints;
117 let DisableEncoding = ps.DisableEncoding;
118 let TSFlags = ps.TSFlags;
130 bits<4> dfmt = format{3-0};
131 bits<3> nfmt = format{6-4};
134 class getMTBUFInsDA<list<RegisterClass> vdataList,
135 list<RegisterClass> vaddrList=[]> {
136 RegisterClass vdataClass = !if(!empty(vdataList), ?, !head(vdataList));
137 RegisterClass vaddrClass = !if(!empty(vaddrList), ?, !head(vaddrList));
138 dag InsNoData = !if(!empty(vaddrList),
139 (ins SReg_128:$srsrc, SCSrc_b32:$soffset,
140 offset:$offset, FORMAT:$format, GLC:$glc, SLC:$slc, TFE:$tfe),
141 (ins vaddrClass:$vaddr, SReg_128:$srsrc, SCSrc_b32:$soffset,
142 offset:$offset, FORMAT:$format, GLC:$glc, SLC:$slc, TFE:$tfe)
144 dag InsData = !if(!empty(vaddrList),
145 (ins vdataClass:$vdata, SReg_128:$srsrc,
146 SCSrc_b32:$soffset, offset:$offset, FORMAT:$format, GLC:$glc,
148 (ins vdataClass:$vdata, vaddrClass:$vaddr, SReg_128:$srsrc,
149 SCSrc_b32:$soffset, offset:$offset, FORMAT:$format, GLC:$glc,
152 dag ret = !if(!empty(vdataList), InsNoData, InsData);
155 class getMTBUFIns<int addrKind, list<RegisterClass> vdataList=[]> {
157 !if(!eq(addrKind, BUFAddrKind.Offset), getMTBUFInsDA<vdataList>.ret,
158 !if(!eq(addrKind, BUFAddrKind.OffEn), getMTBUFInsDA<vdataList, [VGPR_32]>.ret,
159 !if(!eq(addrKind, BUFAddrKind.IdxEn), getMTBUFInsDA<vdataList, [VGPR_32]>.ret,
160 !if(!eq(addrKind, BUFAddrKind.BothEn), getMTBUFInsDA<vdataList, [VReg_64]>.ret,
161 !if(!eq(addrKind, BUFAddrKind.Addr64), getMTBUFInsDA<vdataList, [VReg_64]>.ret,
165 class getMTBUFAsmOps<int addrKind> {
167 !if(!eq(addrKind, BUFAddrKind.Offset), "off, $srsrc, $format, $soffset",
168 !if(!eq(addrKind, BUFAddrKind.OffEn),
169 "$vaddr, $srsrc, $format, $soffset offen",
170 !if(!eq(addrKind, BUFAddrKind.IdxEn),
171 "$vaddr, $srsrc, $format, $soffset idxen",
172 !if(!eq(addrKind, BUFAddrKind.BothEn),
173 "$vaddr, $srsrc, $format, $soffset idxen offen",
174 !if(!eq(addrKind, BUFAddrKind.Addr64),
175 "$vaddr, $srsrc, $format, $soffset addr64",
177 string ret = Pfx # "$offset";
180 class MTBUF_SetupAddr<int addrKind> {
181 bits<1> offen = !if(!eq(addrKind, BUFAddrKind.OffEn), 1,
182 !if(!eq(addrKind, BUFAddrKind.BothEn), 1 , 0));
184 bits<1> idxen = !if(!eq(addrKind, BUFAddrKind.IdxEn), 1,
185 !if(!eq(addrKind, BUFAddrKind.BothEn), 1 , 0));
187 bits<1> addr64 = !if(!eq(addrKind, BUFAddrKind.Addr64), 1, 0);
189 bits<1> has_vaddr = !if(!eq(addrKind, BUFAddrKind.Offset), 0, 1);
192 class MTBUF_Load_Pseudo <string opName,
194 RegisterClass vdataClass,
195 list<dag> pattern=[],
196 // Workaround bug bz30254
197 int addrKindCopy = addrKind>
198 : MTBUF_Pseudo<opName,
199 (outs vdataClass:$vdata),
200 getMTBUFIns<addrKindCopy>.ret,
201 " $vdata, " # getMTBUFAsmOps<addrKindCopy>.ret # "$glc$slc$tfe",
203 MTBUF_SetupAddr<addrKindCopy> {
204 let PseudoInstr = opName # "_" # getAddrName<addrKindCopy>.ret;
209 multiclass MTBUF_Pseudo_Loads<string opName, RegisterClass vdataClass,
210 ValueType load_vt = i32,
211 SDPatternOperator ld = null_frag> {
213 def _OFFSET : MTBUF_Load_Pseudo <opName, BUFAddrKind.Offset, vdataClass,
214 [(set load_vt:$vdata,
215 (ld (MUBUFOffset v4i32:$srsrc, i32:$soffset, i16:$offset, i8:$format,
216 i1:$glc, i1:$slc, i1:$tfe)))]>,
217 MTBUFAddr64Table<0, NAME>;
219 def _ADDR64 : MTBUF_Load_Pseudo <opName, BUFAddrKind.Addr64, vdataClass,
220 [(set load_vt:$vdata,
221 (ld (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset, i16:$offset,
222 i8:$format, i1:$glc, i1:$slc, i1:$tfe)))]>,
223 MTBUFAddr64Table<1, NAME>;
225 def _OFFEN : MTBUF_Load_Pseudo <opName, BUFAddrKind.OffEn, vdataClass>;
226 def _IDXEN : MTBUF_Load_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass>;
227 def _BOTHEN : MTBUF_Load_Pseudo <opName, BUFAddrKind.BothEn, vdataClass>;
229 let DisableWQM = 1 in {
230 def _OFFSET_exact : MTBUF_Load_Pseudo <opName, BUFAddrKind.Offset, vdataClass>;
231 def _OFFEN_exact : MTBUF_Load_Pseudo <opName, BUFAddrKind.OffEn, vdataClass>;
232 def _IDXEN_exact : MTBUF_Load_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass>;
233 def _BOTHEN_exact : MTBUF_Load_Pseudo <opName, BUFAddrKind.BothEn, vdataClass>;
237 class MTBUF_Store_Pseudo <string opName,
239 RegisterClass vdataClass,
240 list<dag> pattern=[],
241 // Workaround bug bz30254
242 int addrKindCopy = addrKind,
243 RegisterClass vdataClassCopy = vdataClass>
244 : MTBUF_Pseudo<opName,
246 getMTBUFIns<addrKindCopy, [vdataClassCopy]>.ret,
247 " $vdata, " # getMTBUFAsmOps<addrKindCopy>.ret # "$glc$slc$tfe",
249 MTBUF_SetupAddr<addrKindCopy> {
250 let PseudoInstr = opName # "_" # getAddrName<addrKindCopy>.ret;
255 multiclass MTBUF_Pseudo_Stores<string opName, RegisterClass vdataClass,
256 ValueType store_vt = i32,
257 SDPatternOperator st = null_frag> {
259 def _OFFSET : MTBUF_Store_Pseudo <opName, BUFAddrKind.Offset, vdataClass,
260 [(st store_vt:$vdata, (MUBUFOffset v4i32:$srsrc, i32:$soffset,
261 i16:$offset, i8:$format, i1:$glc,
262 i1:$slc, i1:$tfe))]>,
263 MTBUFAddr64Table<0, NAME>;
265 def _ADDR64 : MTBUF_Store_Pseudo <opName, BUFAddrKind.Addr64, vdataClass,
266 [(st store_vt:$vdata, (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset,
267 i16:$offset, i8:$format, i1:$glc,
268 i1:$slc, i1:$tfe))]>,
269 MTBUFAddr64Table<1, NAME>;
271 def _OFFEN : MTBUF_Store_Pseudo <opName, BUFAddrKind.OffEn, vdataClass>;
272 def _IDXEN : MTBUF_Store_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass>;
273 def _BOTHEN : MTBUF_Store_Pseudo <opName, BUFAddrKind.BothEn, vdataClass>;
275 let DisableWQM = 1 in {
276 def _OFFSET_exact : MTBUF_Store_Pseudo <opName, BUFAddrKind.Offset, vdataClass>;
277 def _OFFEN_exact : MTBUF_Store_Pseudo <opName, BUFAddrKind.OffEn, vdataClass>;
278 def _IDXEN_exact : MTBUF_Store_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass>;
279 def _BOTHEN_exact : MTBUF_Store_Pseudo <opName, BUFAddrKind.BothEn, vdataClass>;
284 //===----------------------------------------------------------------------===//
286 //===----------------------------------------------------------------------===//
288 class MUBUFGetBaseOpcode<string Op> {
289 string ret = !subst("DWORDX2", "DWORD",
290 !subst("DWORDX3", "DWORD",
291 !subst("DWORDX4", "DWORD", Op)));
294 class MUBUF_Pseudo <string opName, dag outs, dag ins,
295 string asmOps, list<dag> pattern=[]> :
296 InstSI<outs, ins, "", pattern>,
297 SIMCInstr<opName, SIEncodingFamily.NONE> {
300 let isCodeGenOnly = 1;
302 let UseNamedOperandTable = 1;
304 string Mnemonic = opName;
305 string AsmOperands = asmOps;
307 Instruction Opcode = !cast<Instruction>(NAME);
308 Instruction BaseOpcode = !cast<Instruction>(MUBUFGetBaseOpcode<NAME>.ret);
314 let hasSideEffects = 0;
315 let SchedRW = [WriteVMEM];
317 let AsmMatchConverter = "cvtMubuf";
323 bits<1> has_vdata = 1;
324 bits<1> has_vaddr = 1;
326 bits<1> glc_value = 0; // the value for glc if no such operand
327 bits<1> has_srsrc = 1;
328 bits<1> has_soffset = 1;
329 bits<1> has_offset = 1;
335 class MUBUF_Real <bits<7> op, MUBUF_Pseudo ps> :
336 InstSI <ps.OutOperandList, ps.InOperandList, ps.Mnemonic # ps.AsmOperands, []> {
339 let isCodeGenOnly = 0;
341 // copy relevant pseudo op flags
342 let SubtargetPredicate = ps.SubtargetPredicate;
343 let AsmMatchConverter = ps.AsmMatchConverter;
344 let Constraints = ps.Constraints;
345 let DisableEncoding = ps.DisableEncoding;
346 let TSFlags = ps.TSFlags;
359 // For cache invalidation instructions.
360 class MUBUF_Invalidate <string opName, SDPatternOperator node> :
361 MUBUF_Pseudo<opName, (outs), (ins), "", [(node)]> {
363 let AsmMatchConverter = "";
365 let hasSideEffects = 1;
368 // Set everything to 0.
383 class getMUBUFInsDA<list<RegisterClass> vdataList,
384 list<RegisterClass> vaddrList=[],
386 RegisterClass vdataClass = !if(!empty(vdataList), ?, !head(vdataList));
387 RegisterClass vaddrClass = !if(!empty(vaddrList), ?, !head(vaddrList));
388 dag InsNoData = !if(!empty(vaddrList),
389 (ins SReg_128:$srsrc, SCSrc_b32:$soffset,
390 offset:$offset, GLC:$glc, SLC:$slc),
391 (ins vaddrClass:$vaddr, SReg_128:$srsrc, SCSrc_b32:$soffset,
392 offset:$offset, GLC:$glc, SLC:$slc)
394 dag InsData = !if(!empty(vaddrList),
395 (ins vdataClass:$vdata, SReg_128:$srsrc,
396 SCSrc_b32:$soffset, offset:$offset, GLC:$glc, SLC:$slc),
397 (ins vdataClass:$vdata, vaddrClass:$vaddr, SReg_128:$srsrc,
398 SCSrc_b32:$soffset, offset:$offset, GLC:$glc, SLC:$slc)
401 !if(!empty(vdataList), InsNoData, InsData),
402 !if(isLds, (ins), (ins TFE:$tfe))
406 class getMUBUFDwords<RegisterClass regClass> {
407 string regClassAsInt = !cast<string>(regClass);
409 !if(!eq(regClassAsInt, !cast<string>(VGPR_32)), 1,
410 !if(!eq(regClassAsInt, !cast<string>(VReg_64)), 2,
411 !if(!eq(regClassAsInt, !cast<string>(VReg_96)), 3,
412 !if(!eq(regClassAsInt, !cast<string>(VReg_128)), 4,
416 class getMUBUFIns<int addrKind, list<RegisterClass> vdataList=[], bit isLds = 0> {
418 !if(!eq(addrKind, BUFAddrKind.Offset), getMUBUFInsDA<vdataList, [], isLds>.ret,
419 !if(!eq(addrKind, BUFAddrKind.OffEn), getMUBUFInsDA<vdataList, [VGPR_32], isLds>.ret,
420 !if(!eq(addrKind, BUFAddrKind.IdxEn), getMUBUFInsDA<vdataList, [VGPR_32], isLds>.ret,
421 !if(!eq(addrKind, BUFAddrKind.BothEn), getMUBUFInsDA<vdataList, [VReg_64], isLds>.ret,
422 !if(!eq(addrKind, BUFAddrKind.Addr64), getMUBUFInsDA<vdataList, [VReg_64], isLds>.ret,
426 class getMUBUFAsmOps<int addrKind> {
428 !if(!eq(addrKind, BUFAddrKind.Offset), "off, $srsrc, $soffset",
429 !if(!eq(addrKind, BUFAddrKind.OffEn), "$vaddr, $srsrc, $soffset offen",
430 !if(!eq(addrKind, BUFAddrKind.IdxEn), "$vaddr, $srsrc, $soffset idxen",
431 !if(!eq(addrKind, BUFAddrKind.BothEn), "$vaddr, $srsrc, $soffset idxen offen",
432 !if(!eq(addrKind, BUFAddrKind.Addr64), "$vaddr, $srsrc, $soffset addr64",
434 string ret = Pfx # "$offset";
437 class MUBUF_SetupAddr<int addrKind> {
438 bits<1> offen = !if(!eq(addrKind, BUFAddrKind.OffEn), 1,
439 !if(!eq(addrKind, BUFAddrKind.BothEn), 1 , 0));
441 bits<1> idxen = !if(!eq(addrKind, BUFAddrKind.IdxEn), 1,
442 !if(!eq(addrKind, BUFAddrKind.BothEn), 1 , 0));
444 bits<1> addr64 = !if(!eq(addrKind, BUFAddrKind.Addr64), 1, 0);
446 bits<1> has_vaddr = !if(!eq(addrKind, BUFAddrKind.Offset), 0, 1);
449 class MUBUF_Load_Pseudo <string opName,
451 RegisterClass vdataClass,
454 list<dag> pattern=[],
455 // Workaround bug bz30254
456 int addrKindCopy = addrKind>
457 : MUBUF_Pseudo<opName,
458 (outs vdataClass:$vdata),
459 !con(getMUBUFIns<addrKindCopy, [], isLds>.ret,
460 !if(HasTiedDest, (ins vdataClass:$vdata_in), (ins))),
461 " $vdata, " # getMUBUFAsmOps<addrKindCopy>.ret # "$glc$slc" #
462 !if(isLds, " lds", "$tfe"),
464 MUBUF_SetupAddr<addrKindCopy> {
465 let PseudoInstr = opName # !if(isLds, "_lds", "") #
466 "_" # getAddrName<addrKindCopy>.ret;
467 let AsmMatchConverter = !if(isLds, "cvtMubufLds", "cvtMubuf");
469 let Constraints = !if(HasTiedDest, "$vdata = $vdata_in", "");
473 let Uses = !if(isLds, [EXEC, M0], [EXEC]);
474 let has_tfe = !if(isLds, 0, 1);
476 let dwords = getMUBUFDwords<vdataClass>.ret;
479 // FIXME: tfe can't be an operand because it requires a separate
480 // opcode because it needs an N+1 register class dest register.
481 multiclass MUBUF_Pseudo_Loads<string opName, RegisterClass vdataClass,
482 ValueType load_vt = i32,
483 SDPatternOperator ld = null_frag,
487 def _OFFSET : MUBUF_Load_Pseudo <opName, BUFAddrKind.Offset, vdataClass,
491 [(set load_vt:$vdata,
492 (ld (MUBUFOffset v4i32:$srsrc, i32:$soffset, i16:$offset, i1:$glc, i1:$slc, i1:$tfe)))])>,
493 MUBUFAddr64Table<0, NAME # !if(isLds, "_LDS", "")>;
495 def _ADDR64 : MUBUF_Load_Pseudo <opName, BUFAddrKind.Addr64, vdataClass,
499 [(set load_vt:$vdata,
500 (ld (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset, i16:$offset, i1:$glc, i1:$slc, i1:$tfe)))])>,
501 MUBUFAddr64Table<1, NAME # !if(isLds, "_LDS", "")>;
503 def _OFFEN : MUBUF_Load_Pseudo <opName, BUFAddrKind.OffEn, vdataClass, TiedDest, isLds>;
504 def _IDXEN : MUBUF_Load_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass, TiedDest, isLds>;
505 def _BOTHEN : MUBUF_Load_Pseudo <opName, BUFAddrKind.BothEn, vdataClass, TiedDest, isLds>;
507 let DisableWQM = 1 in {
508 def _OFFSET_exact : MUBUF_Load_Pseudo <opName, BUFAddrKind.Offset, vdataClass, TiedDest, isLds>;
509 def _OFFEN_exact : MUBUF_Load_Pseudo <opName, BUFAddrKind.OffEn, vdataClass, TiedDest, isLds>;
510 def _IDXEN_exact : MUBUF_Load_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass, TiedDest, isLds>;
511 def _BOTHEN_exact : MUBUF_Load_Pseudo <opName, BUFAddrKind.BothEn, vdataClass, TiedDest, isLds>;
515 multiclass MUBUF_Pseudo_Loads_Lds<string opName, RegisterClass vdataClass,
516 ValueType load_vt = i32,
517 SDPatternOperator ld_nolds = null_frag,
518 SDPatternOperator ld_lds = null_frag> {
519 defm NAME : MUBUF_Pseudo_Loads<opName, vdataClass, load_vt, ld_nolds>;
520 defm _LDS : MUBUF_Pseudo_Loads<opName, vdataClass, load_vt, ld_lds, 0, 1>;
523 class MUBUF_Store_Pseudo <string opName,
525 RegisterClass vdataClass,
526 list<dag> pattern=[],
527 // Workaround bug bz30254
528 int addrKindCopy = addrKind,
529 RegisterClass vdataClassCopy = vdataClass>
530 : MUBUF_Pseudo<opName,
532 getMUBUFIns<addrKindCopy, [vdataClassCopy]>.ret,
533 " $vdata, " # getMUBUFAsmOps<addrKindCopy>.ret # "$glc$slc$tfe",
535 MUBUF_SetupAddr<addrKindCopy> {
536 let PseudoInstr = opName # "_" # getAddrName<addrKindCopy>.ret;
540 let dwords = getMUBUFDwords<vdataClass>.ret;
543 multiclass MUBUF_Pseudo_Stores<string opName, RegisterClass vdataClass,
544 ValueType store_vt = i32,
545 SDPatternOperator st = null_frag> {
547 def _OFFSET : MUBUF_Store_Pseudo <opName, BUFAddrKind.Offset, vdataClass,
548 [(st store_vt:$vdata, (MUBUFOffset v4i32:$srsrc, i32:$soffset,
549 i16:$offset, i1:$glc, i1:$slc, i1:$tfe))]>,
550 MUBUFAddr64Table<0, NAME>;
552 def _ADDR64 : MUBUF_Store_Pseudo <opName, BUFAddrKind.Addr64, vdataClass,
553 [(st store_vt:$vdata, (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset,
554 i16:$offset, i1:$glc, i1:$slc, i1:$tfe))]>,
555 MUBUFAddr64Table<1, NAME>;
557 def _OFFEN : MUBUF_Store_Pseudo <opName, BUFAddrKind.OffEn, vdataClass>;
558 def _IDXEN : MUBUF_Store_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass>;
559 def _BOTHEN : MUBUF_Store_Pseudo <opName, BUFAddrKind.BothEn, vdataClass>;
561 let DisableWQM = 1 in {
562 def _OFFSET_exact : MUBUF_Store_Pseudo <opName, BUFAddrKind.Offset, vdataClass>;
563 def _OFFEN_exact : MUBUF_Store_Pseudo <opName, BUFAddrKind.OffEn, vdataClass>;
564 def _IDXEN_exact : MUBUF_Store_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass>;
565 def _BOTHEN_exact : MUBUF_Store_Pseudo <opName, BUFAddrKind.BothEn, vdataClass>;
569 class MUBUF_Pseudo_Store_Lds<string opName>
570 : MUBUF_Pseudo<opName,
572 (ins SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset, GLC:$glc, SLC:$slc),
573 " $srsrc, $soffset$offset lds$glc$slc"> {
583 let Uses = [EXEC, M0];
584 let AsmMatchConverter = "cvtMubufLds";
587 class getMUBUFAtomicInsDA<RegisterClass vdataClass, bit vdata_in,
588 list<RegisterClass> vaddrList=[]> {
589 RegisterClass vaddrClass = !if(!empty(vaddrList), ?, !head(vaddrList));
590 dag ret = !if(vdata_in,
591 !if(!empty(vaddrList),
592 (ins vdataClass:$vdata_in,
593 SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset, SLC:$slc),
594 (ins vdataClass:$vdata_in, vaddrClass:$vaddr,
595 SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset, SLC:$slc)
597 !if(!empty(vaddrList),
598 (ins vdataClass:$vdata,
599 SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset, SLC:$slc),
600 (ins vdataClass:$vdata, vaddrClass:$vaddr,
601 SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset, SLC:$slc)
605 class getMUBUFAtomicIns<int addrKind,
606 RegisterClass vdataClass,
608 // Workaround bug bz30254
609 RegisterClass vdataClassCopy=vdataClass> {
611 !if(!eq(addrKind, BUFAddrKind.Offset),
612 getMUBUFAtomicInsDA<vdataClassCopy, vdata_in>.ret,
613 !if(!eq(addrKind, BUFAddrKind.OffEn),
614 getMUBUFAtomicInsDA<vdataClassCopy, vdata_in, [VGPR_32]>.ret,
615 !if(!eq(addrKind, BUFAddrKind.IdxEn),
616 getMUBUFAtomicInsDA<vdataClassCopy, vdata_in, [VGPR_32]>.ret,
617 !if(!eq(addrKind, BUFAddrKind.BothEn),
618 getMUBUFAtomicInsDA<vdataClassCopy, vdata_in, [VReg_64]>.ret,
619 !if(!eq(addrKind, BUFAddrKind.Addr64),
620 getMUBUFAtomicInsDA<vdataClassCopy, vdata_in, [VReg_64]>.ret,
624 class MUBUF_Atomic_Pseudo<string opName,
629 list<dag> pattern=[],
630 // Workaround bug bz30254
631 int addrKindCopy = addrKind>
632 : MUBUF_Pseudo<opName, outs, ins, asmOps, pattern>,
633 MUBUF_SetupAddr<addrKindCopy> {
636 let hasPostISelHook = 1;
637 let hasSideEffects = 1;
644 class MUBUF_AtomicNoRet_Pseudo<string opName, int addrKind,
645 RegisterClass vdataClass,
646 list<dag> pattern=[],
647 // Workaround bug bz30254
648 int addrKindCopy = addrKind,
649 RegisterClass vdataClassCopy = vdataClass>
650 : MUBUF_Atomic_Pseudo<opName, addrKindCopy,
652 getMUBUFAtomicIns<addrKindCopy, vdataClassCopy, 0>.ret,
653 " $vdata, " # getMUBUFAsmOps<addrKindCopy>.ret # "$slc",
655 AtomicNoRet<opName # "_" # getAddrName<addrKindCopy>.ret, 0> {
656 let PseudoInstr = opName # "_" # getAddrName<addrKindCopy>.ret;
658 let AsmMatchConverter = "cvtMubufAtomic";
661 class MUBUF_AtomicRet_Pseudo<string opName, int addrKind,
662 RegisterClass vdataClass,
663 list<dag> pattern=[],
664 // Workaround bug bz30254
665 int addrKindCopy = addrKind,
666 RegisterClass vdataClassCopy = vdataClass>
667 : MUBUF_Atomic_Pseudo<opName, addrKindCopy,
668 (outs vdataClassCopy:$vdata),
669 getMUBUFAtomicIns<addrKindCopy, vdataClassCopy, 1>.ret,
670 " $vdata, " # getMUBUFAsmOps<addrKindCopy>.ret # " glc$slc",
672 AtomicNoRet<opName # "_" # getAddrName<addrKindCopy>.ret, 1> {
673 let PseudoInstr = opName # "_rtn_" # getAddrName<addrKindCopy>.ret;
675 let Constraints = "$vdata = $vdata_in";
676 let DisableEncoding = "$vdata_in";
677 let AsmMatchConverter = "cvtMubufAtomicReturn";
680 multiclass MUBUF_Pseudo_Atomics_NO_RTN <string opName,
681 RegisterClass vdataClass,
683 SDPatternOperator atomic> {
684 def _OFFSET : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.Offset, vdataClass>,
685 MUBUFAddr64Table <0, NAME>;
686 def _ADDR64 : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.Addr64, vdataClass>,
687 MUBUFAddr64Table <1, NAME>;
688 def _OFFEN : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.OffEn, vdataClass>;
689 def _IDXEN : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass>;
690 def _BOTHEN : MUBUF_AtomicNoRet_Pseudo <opName, BUFAddrKind.BothEn, vdataClass>;
693 multiclass MUBUF_Pseudo_Atomics_RTN <string opName,
694 RegisterClass vdataClass,
696 SDPatternOperator atomic> {
697 def _OFFSET_RTN : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.Offset, vdataClass,
698 [(set vdataType:$vdata,
699 (atomic (MUBUFOffsetAtomic v4i32:$srsrc, i32:$soffset, i16:$offset, i1:$slc),
700 vdataType:$vdata_in))]>,
701 MUBUFAddr64Table <0, NAME # "_RTN">;
703 def _ADDR64_RTN : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.Addr64, vdataClass,
704 [(set vdataType:$vdata,
705 (atomic (MUBUFAddr64Atomic v4i32:$srsrc, i64:$vaddr, i32:$soffset, i16:$offset, i1:$slc),
706 vdataType:$vdata_in))]>,
707 MUBUFAddr64Table <1, NAME # "_RTN">;
709 def _OFFEN_RTN : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.OffEn, vdataClass>;
710 def _IDXEN_RTN : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.IdxEn, vdataClass>;
711 def _BOTHEN_RTN : MUBUF_AtomicRet_Pseudo <opName, BUFAddrKind.BothEn, vdataClass>;
714 multiclass MUBUF_Pseudo_Atomics <string opName,
715 RegisterClass vdataClass,
717 SDPatternOperator atomic> :
718 MUBUF_Pseudo_Atomics_NO_RTN<opName, vdataClass, vdataType, atomic>,
719 MUBUF_Pseudo_Atomics_RTN<opName, vdataClass, vdataType, atomic>;
722 //===----------------------------------------------------------------------===//
723 // MUBUF Instructions
724 //===----------------------------------------------------------------------===//
726 defm BUFFER_LOAD_FORMAT_X : MUBUF_Pseudo_Loads_Lds <
727 "buffer_load_format_x", VGPR_32
729 defm BUFFER_LOAD_FORMAT_XY : MUBUF_Pseudo_Loads <
730 "buffer_load_format_xy", VReg_64
732 defm BUFFER_LOAD_FORMAT_XYZ : MUBUF_Pseudo_Loads <
733 "buffer_load_format_xyz", VReg_96
735 defm BUFFER_LOAD_FORMAT_XYZW : MUBUF_Pseudo_Loads <
736 "buffer_load_format_xyzw", VReg_128
738 defm BUFFER_STORE_FORMAT_X : MUBUF_Pseudo_Stores <
739 "buffer_store_format_x", VGPR_32
741 defm BUFFER_STORE_FORMAT_XY : MUBUF_Pseudo_Stores <
742 "buffer_store_format_xy", VReg_64
744 defm BUFFER_STORE_FORMAT_XYZ : MUBUF_Pseudo_Stores <
745 "buffer_store_format_xyz", VReg_96
747 defm BUFFER_STORE_FORMAT_XYZW : MUBUF_Pseudo_Stores <
748 "buffer_store_format_xyzw", VReg_128
751 let SubtargetPredicate = HasUnpackedD16VMem, D16Buf = 1 in {
752 defm BUFFER_LOAD_FORMAT_D16_X_gfx80 : MUBUF_Pseudo_Loads <
753 "buffer_load_format_d16_x", VGPR_32
755 defm BUFFER_LOAD_FORMAT_D16_XY_gfx80 : MUBUF_Pseudo_Loads <
756 "buffer_load_format_d16_xy", VReg_64
758 defm BUFFER_LOAD_FORMAT_D16_XYZ_gfx80 : MUBUF_Pseudo_Loads <
759 "buffer_load_format_d16_xyz", VReg_96
761 defm BUFFER_LOAD_FORMAT_D16_XYZW_gfx80 : MUBUF_Pseudo_Loads <
762 "buffer_load_format_d16_xyzw", VReg_128
764 defm BUFFER_STORE_FORMAT_D16_X_gfx80 : MUBUF_Pseudo_Stores <
765 "buffer_store_format_d16_x", VGPR_32
767 defm BUFFER_STORE_FORMAT_D16_XY_gfx80 : MUBUF_Pseudo_Stores <
768 "buffer_store_format_d16_xy", VReg_64
770 defm BUFFER_STORE_FORMAT_D16_XYZ_gfx80 : MUBUF_Pseudo_Stores <
771 "buffer_store_format_d16_xyz", VReg_96
773 defm BUFFER_STORE_FORMAT_D16_XYZW_gfx80 : MUBUF_Pseudo_Stores <
774 "buffer_store_format_d16_xyzw", VReg_128
776 } // End HasUnpackedD16VMem.
778 let SubtargetPredicate = HasPackedD16VMem, D16Buf = 1 in {
779 defm BUFFER_LOAD_FORMAT_D16_X : MUBUF_Pseudo_Loads <
780 "buffer_load_format_d16_x", VGPR_32
782 defm BUFFER_LOAD_FORMAT_D16_XY : MUBUF_Pseudo_Loads <
783 "buffer_load_format_d16_xy", VGPR_32
785 defm BUFFER_LOAD_FORMAT_D16_XYZ : MUBUF_Pseudo_Loads <
786 "buffer_load_format_d16_xyz", VReg_64
788 defm BUFFER_LOAD_FORMAT_D16_XYZW : MUBUF_Pseudo_Loads <
789 "buffer_load_format_d16_xyzw", VReg_64
791 defm BUFFER_STORE_FORMAT_D16_X : MUBUF_Pseudo_Stores <
792 "buffer_store_format_d16_x", VGPR_32
794 defm BUFFER_STORE_FORMAT_D16_XY : MUBUF_Pseudo_Stores <
795 "buffer_store_format_d16_xy", VGPR_32
797 defm BUFFER_STORE_FORMAT_D16_XYZ : MUBUF_Pseudo_Stores <
798 "buffer_store_format_d16_xyz", VReg_64
800 defm BUFFER_STORE_FORMAT_D16_XYZW : MUBUF_Pseudo_Stores <
801 "buffer_store_format_d16_xyzw", VReg_64
803 } // End HasPackedD16VMem.
805 defm BUFFER_LOAD_UBYTE : MUBUF_Pseudo_Loads_Lds <
806 "buffer_load_ubyte", VGPR_32, i32, mubuf_az_extloadi8
808 defm BUFFER_LOAD_SBYTE : MUBUF_Pseudo_Loads_Lds <
809 "buffer_load_sbyte", VGPR_32, i32, mubuf_sextloadi8
811 defm BUFFER_LOAD_USHORT : MUBUF_Pseudo_Loads_Lds <
812 "buffer_load_ushort", VGPR_32, i32, mubuf_az_extloadi16
814 defm BUFFER_LOAD_SSHORT : MUBUF_Pseudo_Loads_Lds <
815 "buffer_load_sshort", VGPR_32, i32, mubuf_sextloadi16
817 defm BUFFER_LOAD_DWORD : MUBUF_Pseudo_Loads_Lds <
818 "buffer_load_dword", VGPR_32, i32, mubuf_load
820 defm BUFFER_LOAD_DWORDX2 : MUBUF_Pseudo_Loads <
821 "buffer_load_dwordx2", VReg_64, v2i32, mubuf_load
823 defm BUFFER_LOAD_DWORDX3 : MUBUF_Pseudo_Loads <
824 "buffer_load_dwordx3", VReg_96, untyped, mubuf_load
826 defm BUFFER_LOAD_DWORDX4 : MUBUF_Pseudo_Loads <
827 "buffer_load_dwordx4", VReg_128, v4i32, mubuf_load
830 // This is not described in AMD documentation,
831 // but 'lds' versions of these opcodes are available
832 // in at least GFX8+ chips. See Bug 37653.
833 let SubtargetPredicate = isVI in {
834 defm BUFFER_LOAD_DWORDX2_LDS : MUBUF_Pseudo_Loads <
835 "buffer_load_dwordx2", VReg_64, v2i32, null_frag, 0, 1
837 defm BUFFER_LOAD_DWORDX3_LDS : MUBUF_Pseudo_Loads <
838 "buffer_load_dwordx3", VReg_96, untyped, null_frag, 0, 1
840 defm BUFFER_LOAD_DWORDX4_LDS : MUBUF_Pseudo_Loads <
841 "buffer_load_dwordx4", VReg_128, v4i32, null_frag, 0, 1
845 defm BUFFER_STORE_BYTE : MUBUF_Pseudo_Stores <
846 "buffer_store_byte", VGPR_32, i32, truncstorei8_global
848 defm BUFFER_STORE_SHORT : MUBUF_Pseudo_Stores <
849 "buffer_store_short", VGPR_32, i32, truncstorei16_global
851 defm BUFFER_STORE_DWORD : MUBUF_Pseudo_Stores <
852 "buffer_store_dword", VGPR_32, i32, store_global
854 defm BUFFER_STORE_DWORDX2 : MUBUF_Pseudo_Stores <
855 "buffer_store_dwordx2", VReg_64, v2i32, store_global
857 defm BUFFER_STORE_DWORDX3 : MUBUF_Pseudo_Stores <
858 "buffer_store_dwordx3", VReg_96, untyped, store_global
860 defm BUFFER_STORE_DWORDX4 : MUBUF_Pseudo_Stores <
861 "buffer_store_dwordx4", VReg_128, v4i32, store_global
863 defm BUFFER_ATOMIC_SWAP : MUBUF_Pseudo_Atomics <
864 "buffer_atomic_swap", VGPR_32, i32, atomic_swap_global
866 defm BUFFER_ATOMIC_CMPSWAP : MUBUF_Pseudo_Atomics <
867 "buffer_atomic_cmpswap", VReg_64, v2i32, null_frag
869 defm BUFFER_ATOMIC_ADD : MUBUF_Pseudo_Atomics <
870 "buffer_atomic_add", VGPR_32, i32, atomic_add_global
872 defm BUFFER_ATOMIC_SUB : MUBUF_Pseudo_Atomics <
873 "buffer_atomic_sub", VGPR_32, i32, atomic_sub_global
875 defm BUFFER_ATOMIC_SMIN : MUBUF_Pseudo_Atomics <
876 "buffer_atomic_smin", VGPR_32, i32, atomic_min_global
878 defm BUFFER_ATOMIC_UMIN : MUBUF_Pseudo_Atomics <
879 "buffer_atomic_umin", VGPR_32, i32, atomic_umin_global
881 defm BUFFER_ATOMIC_SMAX : MUBUF_Pseudo_Atomics <
882 "buffer_atomic_smax", VGPR_32, i32, atomic_max_global
884 defm BUFFER_ATOMIC_UMAX : MUBUF_Pseudo_Atomics <
885 "buffer_atomic_umax", VGPR_32, i32, atomic_umax_global
887 defm BUFFER_ATOMIC_AND : MUBUF_Pseudo_Atomics <
888 "buffer_atomic_and", VGPR_32, i32, atomic_and_global
890 defm BUFFER_ATOMIC_OR : MUBUF_Pseudo_Atomics <
891 "buffer_atomic_or", VGPR_32, i32, atomic_or_global
893 defm BUFFER_ATOMIC_XOR : MUBUF_Pseudo_Atomics <
894 "buffer_atomic_xor", VGPR_32, i32, atomic_xor_global
896 defm BUFFER_ATOMIC_INC : MUBUF_Pseudo_Atomics <
897 "buffer_atomic_inc", VGPR_32, i32, atomic_inc_global
899 defm BUFFER_ATOMIC_DEC : MUBUF_Pseudo_Atomics <
900 "buffer_atomic_dec", VGPR_32, i32, atomic_dec_global
902 defm BUFFER_ATOMIC_SWAP_X2 : MUBUF_Pseudo_Atomics <
903 "buffer_atomic_swap_x2", VReg_64, i64, atomic_swap_global
905 defm BUFFER_ATOMIC_CMPSWAP_X2 : MUBUF_Pseudo_Atomics <
906 "buffer_atomic_cmpswap_x2", VReg_128, v2i64, null_frag
908 defm BUFFER_ATOMIC_ADD_X2 : MUBUF_Pseudo_Atomics <
909 "buffer_atomic_add_x2", VReg_64, i64, atomic_add_global
911 defm BUFFER_ATOMIC_SUB_X2 : MUBUF_Pseudo_Atomics <
912 "buffer_atomic_sub_x2", VReg_64, i64, atomic_sub_global
914 defm BUFFER_ATOMIC_SMIN_X2 : MUBUF_Pseudo_Atomics <
915 "buffer_atomic_smin_x2", VReg_64, i64, atomic_min_global
917 defm BUFFER_ATOMIC_UMIN_X2 : MUBUF_Pseudo_Atomics <
918 "buffer_atomic_umin_x2", VReg_64, i64, atomic_umin_global
920 defm BUFFER_ATOMIC_SMAX_X2 : MUBUF_Pseudo_Atomics <
921 "buffer_atomic_smax_x2", VReg_64, i64, atomic_max_global
923 defm BUFFER_ATOMIC_UMAX_X2 : MUBUF_Pseudo_Atomics <
924 "buffer_atomic_umax_x2", VReg_64, i64, atomic_umax_global
926 defm BUFFER_ATOMIC_AND_X2 : MUBUF_Pseudo_Atomics <
927 "buffer_atomic_and_x2", VReg_64, i64, atomic_and_global
929 defm BUFFER_ATOMIC_OR_X2 : MUBUF_Pseudo_Atomics <
930 "buffer_atomic_or_x2", VReg_64, i64, atomic_or_global
932 defm BUFFER_ATOMIC_XOR_X2 : MUBUF_Pseudo_Atomics <
933 "buffer_atomic_xor_x2", VReg_64, i64, atomic_xor_global
935 defm BUFFER_ATOMIC_INC_X2 : MUBUF_Pseudo_Atomics <
936 "buffer_atomic_inc_x2", VReg_64, i64, atomic_inc_global
938 defm BUFFER_ATOMIC_DEC_X2 : MUBUF_Pseudo_Atomics <
939 "buffer_atomic_dec_x2", VReg_64, i64, atomic_dec_global
942 let SubtargetPredicate = isVI in {
943 def BUFFER_STORE_LDS_DWORD : MUBUF_Pseudo_Store_Lds <"buffer_store_lds_dword">;
946 let SubtargetPredicate = isSI in { // isn't on CI & VI
948 defm BUFFER_ATOMIC_RSUB : MUBUF_Pseudo_Atomics <"buffer_atomic_rsub">;
949 defm BUFFER_ATOMIC_FCMPSWAP : MUBUF_Pseudo_Atomics <"buffer_atomic_fcmpswap">;
950 defm BUFFER_ATOMIC_FMIN : MUBUF_Pseudo_Atomics <"buffer_atomic_fmin">;
951 defm BUFFER_ATOMIC_FMAX : MUBUF_Pseudo_Atomics <"buffer_atomic_fmax">;
952 defm BUFFER_ATOMIC_RSUB_X2 : MUBUF_Pseudo_Atomics <"buffer_atomic_rsub_x2">;
953 defm BUFFER_ATOMIC_FCMPSWAP_X2 : MUBUF_Pseudo_Atomics <"buffer_atomic_fcmpswap_x2">;
954 defm BUFFER_ATOMIC_FMIN_X2 : MUBUF_Pseudo_Atomics <"buffer_atomic_fmin_x2">;
955 defm BUFFER_ATOMIC_FMAX_X2 : MUBUF_Pseudo_Atomics <"buffer_atomic_fmax_x2">;
958 def BUFFER_WBINVL1_SC : MUBUF_Invalidate <"buffer_wbinvl1_sc",
959 int_amdgcn_buffer_wbinvl1_sc>;
962 let SubtargetPredicate = HasD16LoadStore in {
964 defm BUFFER_LOAD_UBYTE_D16 : MUBUF_Pseudo_Loads <
965 "buffer_load_ubyte_d16", VGPR_32, i32, null_frag, 1
968 defm BUFFER_LOAD_UBYTE_D16_HI : MUBUF_Pseudo_Loads <
969 "buffer_load_ubyte_d16_hi", VGPR_32, i32, null_frag, 1
972 defm BUFFER_LOAD_SBYTE_D16 : MUBUF_Pseudo_Loads <
973 "buffer_load_sbyte_d16", VGPR_32, i32, null_frag, 1
976 defm BUFFER_LOAD_SBYTE_D16_HI : MUBUF_Pseudo_Loads <
977 "buffer_load_sbyte_d16_hi", VGPR_32, i32, null_frag, 1
980 defm BUFFER_LOAD_SHORT_D16 : MUBUF_Pseudo_Loads <
981 "buffer_load_short_d16", VGPR_32, i32, null_frag, 1
984 defm BUFFER_LOAD_SHORT_D16_HI : MUBUF_Pseudo_Loads <
985 "buffer_load_short_d16_hi", VGPR_32, i32, null_frag, 1
988 defm BUFFER_STORE_BYTE_D16_HI : MUBUF_Pseudo_Stores <
989 "buffer_store_byte_d16_hi", VGPR_32, i32
992 defm BUFFER_STORE_SHORT_D16_HI : MUBUF_Pseudo_Stores <
993 "buffer_store_short_d16_hi", VGPR_32, i32
996 defm BUFFER_LOAD_FORMAT_D16_HI_X : MUBUF_Pseudo_Loads <
997 "buffer_load_format_d16_hi_x", VGPR_32
999 defm BUFFER_STORE_FORMAT_D16_HI_X : MUBUF_Pseudo_Stores <
1000 "buffer_store_format_d16_hi_x", VGPR_32
1003 } // End HasD16LoadStore
1005 def BUFFER_WBINVL1 : MUBUF_Invalidate <"buffer_wbinvl1",
1006 int_amdgcn_buffer_wbinvl1>;
1008 //===----------------------------------------------------------------------===//
1009 // MTBUF Instructions
1010 //===----------------------------------------------------------------------===//
1012 defm TBUFFER_LOAD_FORMAT_X : MTBUF_Pseudo_Loads <"tbuffer_load_format_x", VGPR_32>;
1013 defm TBUFFER_LOAD_FORMAT_XY : MTBUF_Pseudo_Loads <"tbuffer_load_format_xy", VReg_64>;
1014 defm TBUFFER_LOAD_FORMAT_XYZ : MTBUF_Pseudo_Loads <"tbuffer_load_format_xyz", VReg_128>;
1015 defm TBUFFER_LOAD_FORMAT_XYZW : MTBUF_Pseudo_Loads <"tbuffer_load_format_xyzw", VReg_128>;
1016 defm TBUFFER_STORE_FORMAT_X : MTBUF_Pseudo_Stores <"tbuffer_store_format_x", VGPR_32>;
1017 defm TBUFFER_STORE_FORMAT_XY : MTBUF_Pseudo_Stores <"tbuffer_store_format_xy", VReg_64>;
1018 defm TBUFFER_STORE_FORMAT_XYZ : MTBUF_Pseudo_Stores <"tbuffer_store_format_xyz", VReg_128>;
1019 defm TBUFFER_STORE_FORMAT_XYZW : MTBUF_Pseudo_Stores <"tbuffer_store_format_xyzw", VReg_128>;
1021 let SubtargetPredicate = HasUnpackedD16VMem, D16Buf = 1 in {
1022 defm TBUFFER_LOAD_FORMAT_D16_X_gfx80 : MTBUF_Pseudo_Loads <"tbuffer_load_format_d16_x", VGPR_32>;
1023 defm TBUFFER_LOAD_FORMAT_D16_XY_gfx80 : MTBUF_Pseudo_Loads <"tbuffer_load_format_d16_xy", VReg_64>;
1024 defm TBUFFER_LOAD_FORMAT_D16_XYZ_gfx80 : MTBUF_Pseudo_Loads <"tbuffer_load_format_d16_xyz", VReg_96>;
1025 defm TBUFFER_LOAD_FORMAT_D16_XYZW_gfx80 : MTBUF_Pseudo_Loads <"tbuffer_load_format_d16_xyzw", VReg_128>;
1026 defm TBUFFER_STORE_FORMAT_D16_X_gfx80 : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_x", VGPR_32>;
1027 defm TBUFFER_STORE_FORMAT_D16_XY_gfx80 : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xy", VReg_64>;
1028 defm TBUFFER_STORE_FORMAT_D16_XYZ_gfx80 : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xyz", VReg_96>;
1029 defm TBUFFER_STORE_FORMAT_D16_XYZW_gfx80 : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xyzw", VReg_128>;
1030 } // End HasUnpackedD16VMem.
1032 let SubtargetPredicate = HasPackedD16VMem, D16Buf = 1 in {
1033 defm TBUFFER_LOAD_FORMAT_D16_X : MTBUF_Pseudo_Loads <"tbuffer_load_format_d16_x", VGPR_32>;
1034 defm TBUFFER_LOAD_FORMAT_D16_XY : MTBUF_Pseudo_Loads <"tbuffer_load_format_d16_xy", VGPR_32>;
1035 defm TBUFFER_LOAD_FORMAT_D16_XYZ : MTBUF_Pseudo_Loads <"tbuffer_load_format_d16_xyz", VReg_64>;
1036 defm TBUFFER_LOAD_FORMAT_D16_XYZW : MTBUF_Pseudo_Loads <"tbuffer_load_format_d16_xyzw", VReg_64>;
1037 defm TBUFFER_STORE_FORMAT_D16_X : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_x", VGPR_32>;
1038 defm TBUFFER_STORE_FORMAT_D16_XY : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xy", VGPR_32>;
1039 defm TBUFFER_STORE_FORMAT_D16_XYZ : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xyz", VReg_64>;
1040 defm TBUFFER_STORE_FORMAT_D16_XYZW : MTBUF_Pseudo_Stores <"tbuffer_store_format_d16_xyzw", VReg_64>;
1041 } // End HasPackedD16VMem.
1043 let SubtargetPredicate = isCIVI in {
1045 //===----------------------------------------------------------------------===//
1046 // Instruction definitions for CI and newer.
1047 //===----------------------------------------------------------------------===//
1048 // Remaining instructions:
1049 // BUFFER_LOAD_DWORDX3
1050 // BUFFER_STORE_DWORDX3
1052 def BUFFER_WBINVL1_VOL : MUBUF_Invalidate <"buffer_wbinvl1_vol",
1053 int_amdgcn_buffer_wbinvl1_vol>;
1055 } // End let SubtargetPredicate = isCIVI
1057 //===----------------------------------------------------------------------===//
1059 //===----------------------------------------------------------------------===//
1061 def extract_glc : SDNodeXForm<imm, [{
1062 return CurDAG->getTargetConstant(N->getZExtValue() & 1, SDLoc(N), MVT::i8);
1065 def extract_slc : SDNodeXForm<imm, [{
1066 return CurDAG->getTargetConstant((N->getZExtValue() >> 1) & 1, SDLoc(N), MVT::i8);
1069 //===----------------------------------------------------------------------===//
1070 // buffer_load/store_format patterns
1071 //===----------------------------------------------------------------------===//
1073 multiclass MUBUF_LoadIntrinsicPat<SDPatternOperator name, ValueType vt,
1076 (vt (name v4i32:$rsrc, 0, 0, i32:$soffset, imm:$offset,
1077 imm:$cachepolicy, 0)),
1078 (!cast<MUBUF_Pseudo>(opcode # _OFFSET) $rsrc, $soffset, (as_i16imm $offset),
1079 (extract_glc $cachepolicy), (extract_slc $cachepolicy), 0)
1083 (vt (name v4i32:$rsrc, 0, i32:$voffset, i32:$soffset, imm:$offset,
1084 imm:$cachepolicy, 0)),
1085 (!cast<MUBUF_Pseudo>(opcode # _OFFEN) $voffset, $rsrc, $soffset, (as_i16imm $offset),
1086 (extract_glc $cachepolicy), (extract_slc $cachepolicy), 0)
1090 (vt (name v4i32:$rsrc, i32:$vindex, 0, i32:$soffset, imm:$offset,
1091 imm:$cachepolicy, imm)),
1092 (!cast<MUBUF_Pseudo>(opcode # _IDXEN) $vindex, $rsrc, $soffset, (as_i16imm $offset),
1093 (extract_glc $cachepolicy), (extract_slc $cachepolicy), 0)
1097 (vt (name v4i32:$rsrc, i32:$vindex, i32:$voffset, i32:$soffset, imm:$offset,
1098 imm:$cachepolicy, imm)),
1099 (!cast<MUBUF_Pseudo>(opcode # _BOTHEN)
1100 (REG_SEQUENCE VReg_64, $vindex, sub0, $voffset, sub1),
1101 $rsrc, $soffset, (as_i16imm $offset),
1102 (extract_glc $cachepolicy), (extract_slc $cachepolicy), 0)
1106 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, f32, "BUFFER_LOAD_FORMAT_X">;
1107 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, i32, "BUFFER_LOAD_FORMAT_X">;
1108 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v2f32, "BUFFER_LOAD_FORMAT_XY">;
1109 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v2i32, "BUFFER_LOAD_FORMAT_XY">;
1110 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v4f32, "BUFFER_LOAD_FORMAT_XYZW">;
1111 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format, v4i32, "BUFFER_LOAD_FORMAT_XYZW">;
1113 let SubtargetPredicate = HasUnpackedD16VMem in {
1114 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, f16, "BUFFER_LOAD_FORMAT_D16_X_gfx80">;
1115 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, i16, "BUFFER_LOAD_FORMAT_D16_X_gfx80">;
1116 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v2i32, "BUFFER_LOAD_FORMAT_D16_XY_gfx80">;
1117 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v4i32, "BUFFER_LOAD_FORMAT_D16_XYZW_gfx80">;
1118 } // End HasUnpackedD16VMem.
1120 let SubtargetPredicate = HasPackedD16VMem in {
1121 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, f16, "BUFFER_LOAD_FORMAT_D16_X">;
1122 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, i16, "BUFFER_LOAD_FORMAT_D16_X">;
1123 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v2f16, "BUFFER_LOAD_FORMAT_D16_XY">;
1124 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v2i16, "BUFFER_LOAD_FORMAT_D16_XY">;
1125 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v4f16, "BUFFER_LOAD_FORMAT_D16_XYZW">;
1126 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load_format_d16, v4i16, "BUFFER_LOAD_FORMAT_D16_XYZW">;
1127 } // End HasPackedD16VMem.
1129 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load, f32, "BUFFER_LOAD_DWORD">;
1130 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load, i32, "BUFFER_LOAD_DWORD">;
1131 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v2f32, "BUFFER_LOAD_DWORDX2">;
1132 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v2i32, "BUFFER_LOAD_DWORDX2">;
1133 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v4f32, "BUFFER_LOAD_DWORDX4">;
1134 defm : MUBUF_LoadIntrinsicPat<SIbuffer_load, v4i32, "BUFFER_LOAD_DWORDX4">;
1136 multiclass MUBUF_StoreIntrinsicPat<SDPatternOperator name, ValueType vt,
1139 (name vt:$vdata, v4i32:$rsrc, 0, 0, i32:$soffset, imm:$offset,
1140 imm:$cachepolicy, 0),
1141 (!cast<MUBUF_Pseudo>(opcode # _OFFSET_exact) $vdata, $rsrc, $soffset, (as_i16imm $offset),
1142 (extract_glc $cachepolicy), (extract_slc $cachepolicy), 0)
1146 (name vt:$vdata, v4i32:$rsrc, 0, i32:$voffset, i32:$soffset, imm:$offset,
1147 imm:$cachepolicy, 0),
1148 (!cast<MUBUF_Pseudo>(opcode # _OFFEN_exact) $vdata, $voffset, $rsrc, $soffset,
1149 (as_i16imm $offset), (extract_glc $cachepolicy), (extract_slc $cachepolicy), 0)
1153 (name vt:$vdata, v4i32:$rsrc, i32:$vindex, 0, i32:$soffset, imm:$offset,
1154 imm:$cachepolicy, imm),
1155 (!cast<MUBUF_Pseudo>(opcode # _IDXEN_exact) $vdata, $vindex, $rsrc, $soffset,
1156 (as_i16imm $offset), (extract_glc $cachepolicy), (extract_slc $cachepolicy), 0)
1160 (name vt:$vdata, v4i32:$rsrc, i32:$vindex, i32:$voffset, i32:$soffset, imm:$offset,
1161 imm:$cachepolicy, imm),
1162 (!cast<MUBUF_Pseudo>(opcode # _BOTHEN_exact)
1164 (REG_SEQUENCE VReg_64, $vindex, sub0, $voffset, sub1),
1165 $rsrc, $soffset, (as_i16imm $offset),
1166 (extract_glc $cachepolicy), (extract_slc $cachepolicy), 0)
1170 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, f32, "BUFFER_STORE_FORMAT_X">;
1171 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, i32, "BUFFER_STORE_FORMAT_X">;
1172 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v2f32, "BUFFER_STORE_FORMAT_XY">;
1173 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v2i32, "BUFFER_STORE_FORMAT_XY">;
1174 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v4f32, "BUFFER_STORE_FORMAT_XYZW">;
1175 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format, v4i32, "BUFFER_STORE_FORMAT_XYZW">;
1177 let SubtargetPredicate = HasUnpackedD16VMem in {
1178 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, f16, "BUFFER_STORE_FORMAT_D16_X_gfx80">;
1179 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, i16, "BUFFER_STORE_FORMAT_D16_X_gfx80">;
1180 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v2i32, "BUFFER_STORE_FORMAT_D16_XY_gfx80">;
1181 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v4i32, "BUFFER_STORE_FORMAT_D16_XYZW_gfx80">;
1182 } // End HasUnpackedD16VMem.
1184 let SubtargetPredicate = HasPackedD16VMem in {
1185 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, f16, "BUFFER_STORE_FORMAT_D16_X">;
1186 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, i16, "BUFFER_STORE_FORMAT_D16_X">;
1187 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v2f16, "BUFFER_STORE_FORMAT_D16_XY">;
1188 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v2i16, "BUFFER_STORE_FORMAT_D16_XY">;
1189 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v4f16, "BUFFER_STORE_FORMAT_D16_XYZW">;
1190 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store_format_d16, v4i16, "BUFFER_STORE_FORMAT_D16_XYZW">;
1191 } // End HasPackedD16VMem.
1193 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store, f32, "BUFFER_STORE_DWORD">;
1194 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store, i32, "BUFFER_STORE_DWORD">;
1195 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v2f32, "BUFFER_STORE_DWORDX2">;
1196 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v2i32, "BUFFER_STORE_DWORDX2">;
1197 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v4f32, "BUFFER_STORE_DWORDX4">;
1198 defm : MUBUF_StoreIntrinsicPat<SIbuffer_store, v4i32, "BUFFER_STORE_DWORDX4">;
1200 //===----------------------------------------------------------------------===//
1201 // buffer_atomic patterns
1202 //===----------------------------------------------------------------------===//
1204 multiclass BufferAtomicPatterns<SDPatternOperator name, string opcode> {
1206 (name i32:$vdata_in, v4i32:$rsrc, 0,
1207 0, i32:$soffset, imm:$offset,
1208 imm:$cachepolicy, 0),
1209 (!cast<MUBUF_Pseudo>(opcode # _OFFSET_RTN) $vdata_in, $rsrc, $soffset,
1210 (as_i16imm $offset), (extract_slc $cachepolicy))
1214 (name i32:$vdata_in, v4i32:$rsrc, i32:$vindex,
1215 0, i32:$soffset, imm:$offset,
1216 imm:$cachepolicy, imm),
1217 (!cast<MUBUF_Pseudo>(opcode # _IDXEN_RTN) $vdata_in, $vindex, $rsrc, $soffset,
1218 (as_i16imm $offset), (extract_slc $cachepolicy))
1222 (name i32:$vdata_in, v4i32:$rsrc, 0,
1223 i32:$voffset, i32:$soffset, imm:$offset,
1224 imm:$cachepolicy, 0),
1225 (!cast<MUBUF_Pseudo>(opcode # _OFFEN_RTN) $vdata_in, $voffset, $rsrc, $soffset,
1226 (as_i16imm $offset), (extract_slc $cachepolicy))
1230 (name i32:$vdata_in, v4i32:$rsrc, i32:$vindex,
1231 i32:$voffset, i32:$soffset, imm:$offset,
1232 imm:$cachepolicy, imm),
1233 (!cast<MUBUF_Pseudo>(opcode # _BOTHEN_RTN)
1235 (REG_SEQUENCE VReg_64, $vindex, sub0, $voffset, sub1),
1236 $rsrc, $soffset, (as_i16imm $offset), (extract_slc $cachepolicy))
1240 defm : BufferAtomicPatterns<SIbuffer_atomic_swap, "BUFFER_ATOMIC_SWAP">;
1241 defm : BufferAtomicPatterns<SIbuffer_atomic_add, "BUFFER_ATOMIC_ADD">;
1242 defm : BufferAtomicPatterns<SIbuffer_atomic_sub, "BUFFER_ATOMIC_SUB">;
1243 defm : BufferAtomicPatterns<SIbuffer_atomic_smin, "BUFFER_ATOMIC_SMIN">;
1244 defm : BufferAtomicPatterns<SIbuffer_atomic_umin, "BUFFER_ATOMIC_UMIN">;
1245 defm : BufferAtomicPatterns<SIbuffer_atomic_smax, "BUFFER_ATOMIC_SMAX">;
1246 defm : BufferAtomicPatterns<SIbuffer_atomic_umax, "BUFFER_ATOMIC_UMAX">;
1247 defm : BufferAtomicPatterns<SIbuffer_atomic_and, "BUFFER_ATOMIC_AND">;
1248 defm : BufferAtomicPatterns<SIbuffer_atomic_or, "BUFFER_ATOMIC_OR">;
1249 defm : BufferAtomicPatterns<SIbuffer_atomic_xor, "BUFFER_ATOMIC_XOR">;
1252 (SIbuffer_atomic_cmpswap
1253 i32:$data, i32:$cmp, v4i32:$rsrc, 0,
1254 0, i32:$soffset, imm:$offset,
1255 imm:$cachepolicy, 0),
1257 (BUFFER_ATOMIC_CMPSWAP_OFFSET_RTN
1258 (REG_SEQUENCE VReg_64, $data, sub0, $cmp, sub1),
1259 $rsrc, $soffset, (as_i16imm $offset), (extract_slc $cachepolicy)),
1264 (SIbuffer_atomic_cmpswap
1265 i32:$data, i32:$cmp, v4i32:$rsrc, i32:$vindex,
1266 0, i32:$soffset, imm:$offset,
1267 imm:$cachepolicy, imm),
1269 (BUFFER_ATOMIC_CMPSWAP_IDXEN_RTN
1270 (REG_SEQUENCE VReg_64, $data, sub0, $cmp, sub1),
1271 $vindex, $rsrc, $soffset, (as_i16imm $offset), (extract_slc $cachepolicy)),
1276 (SIbuffer_atomic_cmpswap
1277 i32:$data, i32:$cmp, v4i32:$rsrc, 0,
1278 i32:$voffset, i32:$soffset, imm:$offset,
1279 imm:$cachepolicy, 0),
1281 (BUFFER_ATOMIC_CMPSWAP_OFFEN_RTN
1282 (REG_SEQUENCE VReg_64, $data, sub0, $cmp, sub1),
1283 $voffset, $rsrc, $soffset, (as_i16imm $offset), (extract_slc $cachepolicy)),
1288 (SIbuffer_atomic_cmpswap
1289 i32:$data, i32:$cmp, v4i32:$rsrc, i32:$vindex,
1290 i32:$voffset, i32:$soffset, imm:$offset,
1291 imm:$cachepolicy, imm),
1293 (BUFFER_ATOMIC_CMPSWAP_BOTHEN_RTN
1294 (REG_SEQUENCE VReg_64, $data, sub0, $cmp, sub1),
1295 (REG_SEQUENCE VReg_64, $vindex, sub0, $voffset, sub1),
1296 $rsrc, $soffset, (as_i16imm $offset), (extract_slc $cachepolicy)),
1301 class MUBUFLoad_PatternADDR64 <MUBUF_Pseudo Instr_ADDR64, ValueType vt,
1302 PatFrag constant_ld> : GCNPat <
1303 (vt (constant_ld (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset,
1304 i16:$offset, i1:$glc, i1:$slc, i1:$tfe))),
1305 (Instr_ADDR64 $vaddr, $srsrc, $soffset, $offset, $glc, $slc, $tfe)
1308 multiclass MUBUFLoad_Atomic_Pattern <MUBUF_Pseudo Instr_ADDR64, MUBUF_Pseudo Instr_OFFSET,
1309 ValueType vt, PatFrag atomic_ld> {
1311 (vt (atomic_ld (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset,
1312 i16:$offset, i1:$slc))),
1313 (Instr_ADDR64 $vaddr, $srsrc, $soffset, $offset, 0, $slc, 0)
1317 (vt (atomic_ld (MUBUFOffsetNoGLC v4i32:$rsrc, i32:$soffset, i16:$offset))),
1318 (Instr_OFFSET $rsrc, $soffset, (as_i16imm $offset), 0, 0, 0)
1322 let SubtargetPredicate = isSICI in {
1323 def : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_SBYTE_ADDR64, i32, sextloadi8_constant>;
1324 def : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_UBYTE_ADDR64, i32, az_extloadi8_constant>;
1325 def : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_SSHORT_ADDR64, i32, sextloadi16_constant>;
1326 def : MUBUFLoad_PatternADDR64 <BUFFER_LOAD_USHORT_ADDR64, i32, az_extloadi16_constant>;
1328 defm : MUBUFLoad_Atomic_Pattern <BUFFER_LOAD_DWORD_ADDR64, BUFFER_LOAD_DWORD_OFFSET, i32, mubuf_load_atomic>;
1329 defm : MUBUFLoad_Atomic_Pattern <BUFFER_LOAD_DWORDX2_ADDR64, BUFFER_LOAD_DWORDX2_OFFSET, i64, mubuf_load_atomic>;
1330 } // End SubtargetPredicate = isSICI
1332 multiclass MUBUFLoad_Pattern <MUBUF_Pseudo Instr_OFFSET, ValueType vt,
1336 (vt (ld (MUBUFOffset v4i32:$srsrc, i32:$soffset,
1337 i16:$offset, i1:$glc, i1:$slc, i1:$tfe))),
1338 (Instr_OFFSET $srsrc, $soffset, $offset, $glc, $slc, $tfe)
1342 let OtherPredicates = [Has16BitInsts] in {
1344 defm : MUBUFLoad_Pattern <BUFFER_LOAD_SBYTE_OFFSET, i16, sextloadi8_constant>;
1345 defm : MUBUFLoad_Pattern <BUFFER_LOAD_UBYTE_OFFSET, i16, az_extloadi8_constant>;
1346 defm : MUBUFLoad_Pattern <BUFFER_LOAD_SBYTE_OFFSET, i16, mubuf_sextloadi8>;
1347 defm : MUBUFLoad_Pattern <BUFFER_LOAD_UBYTE_OFFSET, i16, mubuf_az_extloadi8>;
1349 defm : MUBUFLoad_Pattern <BUFFER_LOAD_USHORT_OFFSET, i16, mubuf_load>;
1351 } // End OtherPredicates = [Has16BitInsts]
1353 multiclass MUBUFScratchLoadPat <MUBUF_Pseudo InstrOffen,
1354 MUBUF_Pseudo InstrOffset,
1355 ValueType vt, PatFrag ld> {
1357 (vt (ld (MUBUFScratchOffen v4i32:$srsrc, i32:$vaddr,
1358 i32:$soffset, u16imm:$offset))),
1359 (InstrOffen $vaddr, $srsrc, $soffset, $offset, 0, 0, 0)
1363 (vt (ld (MUBUFScratchOffset v4i32:$srsrc, i32:$soffset, u16imm:$offset))),
1364 (InstrOffset $srsrc, $soffset, $offset, 0, 0, 0)
1368 // XXX - Is it possible to have a complex pattern in a PatFrag?
1369 multiclass MUBUFScratchLoadPat_Hi16 <MUBUF_Pseudo InstrOffen,
1370 MUBUF_Pseudo InstrOffset,
1371 ValueType vt, PatFrag ld> {
1373 (build_vector vt:$lo, (vt (ld (MUBUFScratchOffen v4i32:$srsrc, i32:$vaddr,
1374 i32:$soffset, u16imm:$offset)))),
1375 (v2i16 (InstrOffen $vaddr, $srsrc, $soffset, $offset, 0, 0, 0, $lo))
1379 (build_vector f16:$lo, (f16 (bitconvert (vt (ld (MUBUFScratchOffen v4i32:$srsrc, i32:$vaddr,
1380 i32:$soffset, u16imm:$offset)))))),
1381 (v2f16 (InstrOffen $vaddr, $srsrc, $soffset, $offset, 0, 0, 0, $lo))
1386 (build_vector vt:$lo, (vt (ld (MUBUFScratchOffset v4i32:$srsrc, i32:$soffset, u16imm:$offset)))),
1387 (v2i16 (InstrOffset $srsrc, $soffset, $offset, 0, 0, 0, $lo))
1391 (build_vector f16:$lo, (f16 (bitconvert (vt (ld (MUBUFScratchOffset v4i32:$srsrc, i32:$soffset, u16imm:$offset)))))),
1392 (v2f16 (InstrOffset $srsrc, $soffset, $offset, 0, 0, 0, $lo))
1396 multiclass MUBUFScratchLoadPat_Lo16 <MUBUF_Pseudo InstrOffen,
1397 MUBUF_Pseudo InstrOffset,
1398 ValueType vt, PatFrag ld> {
1400 (build_vector (vt (ld (MUBUFScratchOffen v4i32:$srsrc, i32:$vaddr,
1401 i32:$soffset, u16imm:$offset))),
1402 (vt (Hi16Elt vt:$hi))),
1403 (v2i16 (InstrOffen $vaddr, $srsrc, $soffset, $offset, 0, 0, 0, $hi))
1407 (build_vector (f16 (bitconvert (vt (ld (MUBUFScratchOffen v4i32:$srsrc, i32:$vaddr,
1408 i32:$soffset, u16imm:$offset))))),
1409 (f16 (Hi16Elt f16:$hi))),
1410 (v2f16 (InstrOffen $vaddr, $srsrc, $soffset, $offset, 0, 0, 0, $hi))
1414 (build_vector (vt (ld (MUBUFScratchOffset v4i32:$srsrc, i32:$soffset, u16imm:$offset))),
1415 (vt (Hi16Elt vt:$hi))),
1416 (v2i16 (InstrOffset $srsrc, $soffset, $offset, 0, 0, 0, $hi))
1420 (build_vector (f16 (bitconvert (vt (ld (MUBUFScratchOffset v4i32:$srsrc, i32:$soffset, u16imm:$offset))))),
1421 (f16 (Hi16Elt f16:$hi))),
1422 (v2f16 (InstrOffset $srsrc, $soffset, $offset, 0, 0, 0, $hi))
1426 defm : MUBUFScratchLoadPat <BUFFER_LOAD_SBYTE_OFFEN, BUFFER_LOAD_SBYTE_OFFSET, i32, sextloadi8_private>;
1427 defm : MUBUFScratchLoadPat <BUFFER_LOAD_UBYTE_OFFEN, BUFFER_LOAD_UBYTE_OFFSET, i32, az_extloadi8_private>;
1428 defm : MUBUFScratchLoadPat <BUFFER_LOAD_SBYTE_OFFEN, BUFFER_LOAD_SBYTE_OFFSET, i16, sextloadi8_private>;
1429 defm : MUBUFScratchLoadPat <BUFFER_LOAD_UBYTE_OFFEN, BUFFER_LOAD_UBYTE_OFFSET, i16, az_extloadi8_private>;
1430 defm : MUBUFScratchLoadPat <BUFFER_LOAD_SSHORT_OFFEN, BUFFER_LOAD_SSHORT_OFFSET, i32, sextloadi16_private>;
1431 defm : MUBUFScratchLoadPat <BUFFER_LOAD_USHORT_OFFEN, BUFFER_LOAD_USHORT_OFFSET, i32, az_extloadi16_private>;
1432 defm : MUBUFScratchLoadPat <BUFFER_LOAD_USHORT_OFFEN, BUFFER_LOAD_USHORT_OFFSET, i16, load_private>;
1433 defm : MUBUFScratchLoadPat <BUFFER_LOAD_DWORD_OFFEN, BUFFER_LOAD_DWORD_OFFSET, i32, load_private>;
1434 defm : MUBUFScratchLoadPat <BUFFER_LOAD_DWORDX2_OFFEN, BUFFER_LOAD_DWORDX2_OFFSET, v2i32, load_private>;
1435 defm : MUBUFScratchLoadPat <BUFFER_LOAD_DWORDX4_OFFEN, BUFFER_LOAD_DWORDX4_OFFSET, v4i32, load_private>;
1437 let OtherPredicates = [D16PreservesUnusedBits] in {
1438 defm : MUBUFScratchLoadPat_Hi16<BUFFER_LOAD_SHORT_D16_HI_OFFEN, BUFFER_LOAD_SHORT_D16_HI_OFFSET, i16, load_private>;
1439 defm : MUBUFScratchLoadPat_Hi16<BUFFER_LOAD_UBYTE_D16_HI_OFFEN, BUFFER_LOAD_UBYTE_D16_HI_OFFSET, i16, az_extloadi8_private>;
1440 defm : MUBUFScratchLoadPat_Hi16<BUFFER_LOAD_SBYTE_D16_HI_OFFEN, BUFFER_LOAD_SBYTE_D16_HI_OFFSET, i16, sextloadi8_private>;
1442 defm : MUBUFScratchLoadPat_Lo16<BUFFER_LOAD_SHORT_D16_OFFEN, BUFFER_LOAD_SHORT_D16_OFFSET, i16, load_private>;
1443 defm : MUBUFScratchLoadPat_Lo16<BUFFER_LOAD_UBYTE_D16_OFFEN, BUFFER_LOAD_UBYTE_D16_OFFSET, i16, az_extloadi8_private>;
1444 defm : MUBUFScratchLoadPat_Lo16<BUFFER_LOAD_SBYTE_D16_OFFEN, BUFFER_LOAD_SBYTE_D16_OFFSET, i16, sextloadi8_private>;
1446 multiclass MUBUFStore_Atomic_Pattern <MUBUF_Pseudo Instr_ADDR64, MUBUF_Pseudo Instr_OFFSET,
1447 ValueType vt, PatFrag atomic_st> {
1448 // Store follows atomic op convention so address is forst
1450 (atomic_st (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i32:$soffset,
1451 i16:$offset, i1:$slc), vt:$val),
1452 (Instr_ADDR64 $val, $vaddr, $srsrc, $soffset, $offset, 0, $slc, 0)
1456 (atomic_st (MUBUFOffsetNoGLC v4i32:$rsrc, i32:$soffset, i16:$offset), vt:$val),
1457 (Instr_OFFSET $val, $rsrc, $soffset, (as_i16imm $offset), 0, 0, 0)
1460 let SubtargetPredicate = isSICI in {
1461 defm : MUBUFStore_Atomic_Pattern <BUFFER_STORE_DWORD_ADDR64, BUFFER_STORE_DWORD_OFFSET, i32, store_atomic_global>;
1462 defm : MUBUFStore_Atomic_Pattern <BUFFER_STORE_DWORDX2_ADDR64, BUFFER_STORE_DWORDX2_OFFSET, i64, store_atomic_global>;
1463 } // End Predicates = isSICI
1466 multiclass MUBUFStore_Pattern <MUBUF_Pseudo Instr_OFFSET, ValueType vt,
1470 (st vt:$vdata, (MUBUFOffset v4i32:$srsrc, i32:$soffset,
1471 i16:$offset, i1:$glc, i1:$slc, i1:$tfe)),
1472 (Instr_OFFSET $vdata, $srsrc, $soffset, $offset, $glc, $slc, $tfe)
1476 defm : MUBUFStore_Pattern <BUFFER_STORE_BYTE_OFFSET, i16, truncstorei8_global>;
1477 defm : MUBUFStore_Pattern <BUFFER_STORE_SHORT_OFFSET, i16, store_global>;
1479 multiclass MUBUFScratchStorePat <MUBUF_Pseudo InstrOffen,
1480 MUBUF_Pseudo InstrOffset,
1481 ValueType vt, PatFrag st> {
1483 (st vt:$value, (MUBUFScratchOffen v4i32:$srsrc, i32:$vaddr,
1484 i32:$soffset, u16imm:$offset)),
1485 (InstrOffen $value, $vaddr, $srsrc, $soffset, $offset, 0, 0, 0)
1489 (st vt:$value, (MUBUFScratchOffset v4i32:$srsrc, i32:$soffset,
1491 (InstrOffset $value, $srsrc, $soffset, $offset, 0, 0, 0)
1495 defm : MUBUFScratchStorePat <BUFFER_STORE_BYTE_OFFEN, BUFFER_STORE_BYTE_OFFSET, i32, truncstorei8_private>;
1496 defm : MUBUFScratchStorePat <BUFFER_STORE_SHORT_OFFEN, BUFFER_STORE_SHORT_OFFSET, i32, truncstorei16_private>;
1497 defm : MUBUFScratchStorePat <BUFFER_STORE_BYTE_OFFEN, BUFFER_STORE_BYTE_OFFSET, i16, truncstorei8_private>;
1498 defm : MUBUFScratchStorePat <BUFFER_STORE_SHORT_OFFEN, BUFFER_STORE_SHORT_OFFSET, i16, store_private>;
1499 defm : MUBUFScratchStorePat <BUFFER_STORE_DWORD_OFFEN, BUFFER_STORE_DWORD_OFFSET, i32, store_private>;
1500 defm : MUBUFScratchStorePat <BUFFER_STORE_DWORDX2_OFFEN, BUFFER_STORE_DWORDX2_OFFSET, v2i32, store_private>;
1501 defm : MUBUFScratchStorePat <BUFFER_STORE_DWORDX4_OFFEN, BUFFER_STORE_DWORDX4_OFFSET, v4i32, store_private>;
1504 let OtherPredicates = [D16PreservesUnusedBits] in {
1505 // Hiding the extract high pattern in the PatFrag seems to not
1506 // automatically increase the complexity.
1507 let AddedComplexity = 1 in {
1508 defm : MUBUFScratchStorePat <BUFFER_STORE_SHORT_D16_HI_OFFEN, BUFFER_STORE_SHORT_D16_HI_OFFSET, i32, store_hi16_private>;
1509 defm : MUBUFScratchStorePat <BUFFER_STORE_BYTE_D16_HI_OFFEN, BUFFER_STORE_BYTE_D16_HI_OFFSET, i32, truncstorei8_hi16_private>;
1513 //===----------------------------------------------------------------------===//
1515 //===----------------------------------------------------------------------===//
1517 //===----------------------------------------------------------------------===//
1518 // tbuffer_load/store_format patterns
1519 //===----------------------------------------------------------------------===//
1521 multiclass MTBUF_LoadIntrinsicPat<SDPatternOperator name, ValueType vt,
1524 (vt (name v4i32:$rsrc, 0, 0, i32:$soffset, imm:$offset,
1525 imm:$format, imm:$cachepolicy, 0)),
1526 (!cast<MTBUF_Pseudo>(opcode # _OFFSET) $rsrc, $soffset, (as_i16imm $offset),
1528 (extract_glc $cachepolicy), (extract_slc $cachepolicy), 0)
1532 (vt (name v4i32:$rsrc, i32:$vindex, 0, i32:$soffset, imm:$offset,
1533 imm:$format, imm:$cachepolicy, imm)),
1534 (!cast<MTBUF_Pseudo>(opcode # _IDXEN) $vindex, $rsrc, $soffset, (as_i16imm $offset),
1536 (extract_glc $cachepolicy), (extract_slc $cachepolicy), 0)
1540 (vt (name v4i32:$rsrc, 0, i32:$voffset, i32:$soffset, imm:$offset,
1541 imm:$format, imm:$cachepolicy, 0)),
1542 (!cast<MTBUF_Pseudo>(opcode # _OFFEN) $voffset, $rsrc, $soffset, (as_i16imm $offset),
1544 (extract_glc $cachepolicy), (extract_slc $cachepolicy), 0)
1548 (vt (name v4i32:$rsrc, i32:$vindex, i32:$voffset, i32:$soffset, imm:$offset,
1549 imm:$format, imm:$cachepolicy, imm)),
1550 (!cast<MTBUF_Pseudo>(opcode # _BOTHEN)
1551 (REG_SEQUENCE VReg_64, $vindex, sub0, $voffset, sub1),
1552 $rsrc, $soffset, (as_i16imm $offset),
1554 (extract_glc $cachepolicy), (extract_slc $cachepolicy), 0)
1558 defm : MTBUF_LoadIntrinsicPat<SItbuffer_load, i32, "TBUFFER_LOAD_FORMAT_X">;
1559 defm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v2i32, "TBUFFER_LOAD_FORMAT_XY">;
1560 defm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v4i32, "TBUFFER_LOAD_FORMAT_XYZW">;
1561 defm : MTBUF_LoadIntrinsicPat<SItbuffer_load, f32, "TBUFFER_LOAD_FORMAT_X">;
1562 defm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v2f32, "TBUFFER_LOAD_FORMAT_XY">;
1563 defm : MTBUF_LoadIntrinsicPat<SItbuffer_load, v4f32, "TBUFFER_LOAD_FORMAT_XYZW">;
1565 let SubtargetPredicate = HasUnpackedD16VMem in {
1566 defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, f16, "TBUFFER_LOAD_FORMAT_D16_X_gfx80">;
1567 defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, v2i32, "TBUFFER_LOAD_FORMAT_D16_XY_gfx80">;
1568 defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, v4i32, "TBUFFER_LOAD_FORMAT_D16_XYZW_gfx80">;
1569 } // End HasUnpackedD16VMem.
1571 let SubtargetPredicate = HasPackedD16VMem in {
1572 defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, f16, "TBUFFER_LOAD_FORMAT_D16_X">;
1573 defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, v2f16, "TBUFFER_LOAD_FORMAT_D16_XY">;
1574 defm : MTBUF_LoadIntrinsicPat<SItbuffer_load_d16, v4f16, "TBUFFER_LOAD_FORMAT_D16_XYZW">;
1575 } // End HasPackedD16VMem.
1577 multiclass MTBUF_StoreIntrinsicPat<SDPatternOperator name, ValueType vt,
1580 (name vt:$vdata, v4i32:$rsrc, 0, 0, i32:$soffset, imm:$offset,
1581 imm:$format, imm:$cachepolicy, 0),
1582 (!cast<MTBUF_Pseudo>(opcode # _OFFSET_exact) $vdata, $rsrc, $soffset,
1583 (as_i16imm $offset), (as_i8imm $format),
1584 (extract_glc $cachepolicy), (extract_slc $cachepolicy), 0)
1588 (name vt:$vdata, v4i32:$rsrc, i32:$vindex, 0, i32:$soffset, imm:$offset,
1589 imm:$format, imm:$cachepolicy, imm),
1590 (!cast<MTBUF_Pseudo>(opcode # _IDXEN_exact) $vdata, $vindex, $rsrc, $soffset,
1591 (as_i16imm $offset), (as_i8imm $format),
1592 (extract_glc $cachepolicy), (extract_slc $cachepolicy), 0)
1596 (name vt:$vdata, v4i32:$rsrc, 0, i32:$voffset, i32:$soffset, imm:$offset,
1597 imm:$format, imm:$cachepolicy, 0),
1598 (!cast<MTBUF_Pseudo>(opcode # _OFFEN_exact) $vdata, $voffset, $rsrc, $soffset,
1599 (as_i16imm $offset), (as_i8imm $format),
1600 (extract_glc $cachepolicy), (extract_slc $cachepolicy), 0)
1604 (name vt:$vdata, v4i32:$rsrc, i32:$vindex, i32:$voffset, i32:$soffset,
1605 imm:$offset, imm:$format, imm:$cachepolicy, imm),
1606 (!cast<MTBUF_Pseudo>(opcode # _BOTHEN_exact)
1608 (REG_SEQUENCE VReg_64, $vindex, sub0, $voffset, sub1),
1609 $rsrc, $soffset, (as_i16imm $offset), (as_i8imm $format),
1610 (extract_glc $cachepolicy), (extract_slc $cachepolicy), 0)
1614 defm : MTBUF_StoreIntrinsicPat<SItbuffer_store, i32, "TBUFFER_STORE_FORMAT_X">;
1615 defm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v2i32, "TBUFFER_STORE_FORMAT_XY">;
1616 defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_x3, v4i32, "TBUFFER_STORE_FORMAT_XYZ">;
1617 defm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v4i32, "TBUFFER_STORE_FORMAT_XYZW">;
1618 defm : MTBUF_StoreIntrinsicPat<SItbuffer_store, f32, "TBUFFER_STORE_FORMAT_X">;
1619 defm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v2f32, "TBUFFER_STORE_FORMAT_XY">;
1620 defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_x3, v4f32, "TBUFFER_STORE_FORMAT_XYZ">;
1621 defm : MTBUF_StoreIntrinsicPat<SItbuffer_store, v4f32, "TBUFFER_STORE_FORMAT_XYZW">;
1623 let SubtargetPredicate = HasUnpackedD16VMem in {
1624 defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, f16, "TBUFFER_STORE_FORMAT_D16_X_gfx80">;
1625 defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, v2i32, "TBUFFER_STORE_FORMAT_D16_XY_gfx80">;
1626 defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, v4i32, "TBUFFER_STORE_FORMAT_D16_XYZW_gfx80">;
1627 } // End HasUnpackedD16VMem.
1629 let SubtargetPredicate = HasPackedD16VMem in {
1630 defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, f16, "TBUFFER_STORE_FORMAT_D16_X">;
1631 defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, v2f16, "TBUFFER_STORE_FORMAT_D16_XY">;
1632 defm : MTBUF_StoreIntrinsicPat<SItbuffer_store_d16, v4f16, "TBUFFER_STORE_FORMAT_D16_XYZW">;
1633 } // End HasPackedD16VMem.
1635 //===----------------------------------------------------------------------===//
1636 // Target instructions, move to the appropriate target TD file
1637 //===----------------------------------------------------------------------===//
1639 //===----------------------------------------------------------------------===//
1641 //===----------------------------------------------------------------------===//
1643 class MUBUF_Real_si <bits<7> op, MUBUF_Pseudo ps> :
1646 SIMCInstr<ps.PseudoInstr, SIEncodingFamily.SI> {
1647 let AssemblerPredicate=isSICI;
1648 let DecoderNamespace="SICI";
1650 let Inst{11-0} = !if(ps.has_offset, offset, ?);
1651 let Inst{12} = ps.offen;
1652 let Inst{13} = ps.idxen;
1653 let Inst{14} = !if(ps.has_glc, glc, ps.glc_value);
1654 let Inst{15} = ps.addr64;
1655 let Inst{16} = !if(ps.lds, 1, 0);
1656 let Inst{24-18} = op;
1657 let Inst{31-26} = 0x38; //encoding
1658 let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?);
1659 let Inst{47-40} = !if(ps.has_vdata, vdata, ?);
1660 let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?);
1661 let Inst{54} = !if(ps.has_slc, slc, ?);
1662 let Inst{55} = !if(ps.has_tfe, tfe, ?);
1663 let Inst{63-56} = !if(ps.has_soffset, soffset, ?);
1666 multiclass MUBUF_Real_AllAddr_si<bits<7> op> {
1667 def _OFFSET_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>;
1668 def _ADDR64_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_ADDR64")>;
1669 def _OFFEN_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>;
1670 def _IDXEN_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>;
1671 def _BOTHEN_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>;
1674 multiclass MUBUF_Real_AllAddr_Lds_si<bits<7> op> {
1676 def _OFFSET_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>,
1677 MUBUFLdsTable<0, NAME # "_OFFSET_si">;
1678 def _ADDR64_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_ADDR64")>,
1679 MUBUFLdsTable<0, NAME # "_ADDR64_si">;
1680 def _OFFEN_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>,
1681 MUBUFLdsTable<0, NAME # "_OFFEN_si">;
1682 def _IDXEN_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>,
1683 MUBUFLdsTable<0, NAME # "_IDXEN_si">;
1684 def _BOTHEN_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>,
1685 MUBUFLdsTable<0, NAME # "_BOTHEN_si">;
1687 def _LDS_OFFSET_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_OFFSET")>,
1688 MUBUFLdsTable<1, NAME # "_OFFSET_si">;
1689 def _LDS_ADDR64_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_ADDR64")>,
1690 MUBUFLdsTable<1, NAME # "_ADDR64_si">;
1691 def _LDS_OFFEN_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_OFFEN")>,
1692 MUBUFLdsTable<1, NAME # "_OFFEN_si">;
1693 def _LDS_IDXEN_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_IDXEN")>,
1694 MUBUFLdsTable<1, NAME # "_IDXEN_si">;
1695 def _LDS_BOTHEN_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_BOTHEN")>,
1696 MUBUFLdsTable<1, NAME # "_BOTHEN_si">;
1699 multiclass MUBUF_Real_Atomic_si<bits<7> op> : MUBUF_Real_AllAddr_si<op> {
1700 def _OFFSET_RTN_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET_RTN")>;
1701 def _ADDR64_RTN_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_ADDR64_RTN")>;
1702 def _OFFEN_RTN_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN_RTN")>;
1703 def _IDXEN_RTN_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN_RTN")>;
1704 def _BOTHEN_RTN_si : MUBUF_Real_si <op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN_RTN")>;
1707 defm BUFFER_LOAD_FORMAT_X : MUBUF_Real_AllAddr_Lds_si <0x00>;
1708 defm BUFFER_LOAD_FORMAT_XY : MUBUF_Real_AllAddr_si <0x01>;
1709 defm BUFFER_LOAD_FORMAT_XYZ : MUBUF_Real_AllAddr_si <0x02>;
1710 defm BUFFER_LOAD_FORMAT_XYZW : MUBUF_Real_AllAddr_si <0x03>;
1711 defm BUFFER_STORE_FORMAT_X : MUBUF_Real_AllAddr_si <0x04>;
1712 defm BUFFER_STORE_FORMAT_XY : MUBUF_Real_AllAddr_si <0x05>;
1713 defm BUFFER_STORE_FORMAT_XYZ : MUBUF_Real_AllAddr_si <0x06>;
1714 defm BUFFER_STORE_FORMAT_XYZW : MUBUF_Real_AllAddr_si <0x07>;
1715 defm BUFFER_LOAD_UBYTE : MUBUF_Real_AllAddr_Lds_si <0x08>;
1716 defm BUFFER_LOAD_SBYTE : MUBUF_Real_AllAddr_Lds_si <0x09>;
1717 defm BUFFER_LOAD_USHORT : MUBUF_Real_AllAddr_Lds_si <0x0a>;
1718 defm BUFFER_LOAD_SSHORT : MUBUF_Real_AllAddr_Lds_si <0x0b>;
1719 defm BUFFER_LOAD_DWORD : MUBUF_Real_AllAddr_Lds_si <0x0c>;
1720 defm BUFFER_LOAD_DWORDX2 : MUBUF_Real_AllAddr_si <0x0d>;
1721 defm BUFFER_LOAD_DWORDX4 : MUBUF_Real_AllAddr_si <0x0e>;
1722 defm BUFFER_LOAD_DWORDX3 : MUBUF_Real_AllAddr_si <0x0f>;
1723 defm BUFFER_STORE_BYTE : MUBUF_Real_AllAddr_si <0x18>;
1724 defm BUFFER_STORE_SHORT : MUBUF_Real_AllAddr_si <0x1a>;
1725 defm BUFFER_STORE_DWORD : MUBUF_Real_AllAddr_si <0x1c>;
1726 defm BUFFER_STORE_DWORDX2 : MUBUF_Real_AllAddr_si <0x1d>;
1727 defm BUFFER_STORE_DWORDX4 : MUBUF_Real_AllAddr_si <0x1e>;
1728 defm BUFFER_STORE_DWORDX3 : MUBUF_Real_AllAddr_si <0x1f>;
1730 defm BUFFER_ATOMIC_SWAP : MUBUF_Real_Atomic_si <0x30>;
1731 defm BUFFER_ATOMIC_CMPSWAP : MUBUF_Real_Atomic_si <0x31>;
1732 defm BUFFER_ATOMIC_ADD : MUBUF_Real_Atomic_si <0x32>;
1733 defm BUFFER_ATOMIC_SUB : MUBUF_Real_Atomic_si <0x33>;
1734 //defm BUFFER_ATOMIC_RSUB : MUBUF_Real_Atomic_si <0x34>; // isn't on CI & VI
1735 defm BUFFER_ATOMIC_SMIN : MUBUF_Real_Atomic_si <0x35>;
1736 defm BUFFER_ATOMIC_UMIN : MUBUF_Real_Atomic_si <0x36>;
1737 defm BUFFER_ATOMIC_SMAX : MUBUF_Real_Atomic_si <0x37>;
1738 defm BUFFER_ATOMIC_UMAX : MUBUF_Real_Atomic_si <0x38>;
1739 defm BUFFER_ATOMIC_AND : MUBUF_Real_Atomic_si <0x39>;
1740 defm BUFFER_ATOMIC_OR : MUBUF_Real_Atomic_si <0x3a>;
1741 defm BUFFER_ATOMIC_XOR : MUBUF_Real_Atomic_si <0x3b>;
1742 defm BUFFER_ATOMIC_INC : MUBUF_Real_Atomic_si <0x3c>;
1743 defm BUFFER_ATOMIC_DEC : MUBUF_Real_Atomic_si <0x3d>;
1745 //defm BUFFER_ATOMIC_FCMPSWAP : MUBUF_Real_Atomic_si <0x3e>; // isn't on VI
1746 //defm BUFFER_ATOMIC_FMIN : MUBUF_Real_Atomic_si <0x3f>; // isn't on VI
1747 //defm BUFFER_ATOMIC_FMAX : MUBUF_Real_Atomic_si <0x40>; // isn't on VI
1748 defm BUFFER_ATOMIC_SWAP_X2 : MUBUF_Real_Atomic_si <0x50>;
1749 defm BUFFER_ATOMIC_CMPSWAP_X2 : MUBUF_Real_Atomic_si <0x51>;
1750 defm BUFFER_ATOMIC_ADD_X2 : MUBUF_Real_Atomic_si <0x52>;
1751 defm BUFFER_ATOMIC_SUB_X2 : MUBUF_Real_Atomic_si <0x53>;
1752 //defm BUFFER_ATOMIC_RSUB_X2 : MUBUF_Real_Atomic_si <0x54>; // isn't on CI & VI
1753 defm BUFFER_ATOMIC_SMIN_X2 : MUBUF_Real_Atomic_si <0x55>;
1754 defm BUFFER_ATOMIC_UMIN_X2 : MUBUF_Real_Atomic_si <0x56>;
1755 defm BUFFER_ATOMIC_SMAX_X2 : MUBUF_Real_Atomic_si <0x57>;
1756 defm BUFFER_ATOMIC_UMAX_X2 : MUBUF_Real_Atomic_si <0x58>;
1757 defm BUFFER_ATOMIC_AND_X2 : MUBUF_Real_Atomic_si <0x59>;
1758 defm BUFFER_ATOMIC_OR_X2 : MUBUF_Real_Atomic_si <0x5a>;
1759 defm BUFFER_ATOMIC_XOR_X2 : MUBUF_Real_Atomic_si <0x5b>;
1760 defm BUFFER_ATOMIC_INC_X2 : MUBUF_Real_Atomic_si <0x5c>;
1761 defm BUFFER_ATOMIC_DEC_X2 : MUBUF_Real_Atomic_si <0x5d>;
1762 // FIXME: Need to handle hazard for BUFFER_ATOMIC_FCMPSWAP_X2 on CI.
1763 //defm BUFFER_ATOMIC_FCMPSWAP_X2 : MUBUF_Real_Atomic_si <0x5e">; // isn't on VI
1764 //defm BUFFER_ATOMIC_FMIN_X2 : MUBUF_Real_Atomic_si <0x5f>; // isn't on VI
1765 //defm BUFFER_ATOMIC_FMAX_X2 : MUBUF_Real_Atomic_si <0x60>; // isn't on VI
1767 def BUFFER_WBINVL1_SC_si : MUBUF_Real_si <0x70, BUFFER_WBINVL1_SC>;
1768 def BUFFER_WBINVL1_si : MUBUF_Real_si <0x71, BUFFER_WBINVL1>;
1770 class MTBUF_Real_si <bits<3> op, MTBUF_Pseudo ps> :
1773 SIMCInstr<ps.PseudoInstr, SIEncodingFamily.SI> {
1774 let AssemblerPredicate=isSICI;
1775 let DecoderNamespace="SICI";
1777 let Inst{11-0} = !if(ps.has_offset, offset, ?);
1778 let Inst{12} = ps.offen;
1779 let Inst{13} = ps.idxen;
1780 let Inst{14} = !if(ps.has_glc, glc, ps.glc_value);
1781 let Inst{15} = ps.addr64;
1782 let Inst{18-16} = op;
1783 let Inst{22-19} = dfmt;
1784 let Inst{25-23} = nfmt;
1785 let Inst{31-26} = 0x3a; //encoding
1786 let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?);
1787 let Inst{47-40} = !if(ps.has_vdata, vdata, ?);
1788 let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?);
1789 let Inst{54} = !if(ps.has_slc, slc, ?);
1790 let Inst{55} = !if(ps.has_tfe, tfe, ?);
1791 let Inst{63-56} = !if(ps.has_soffset, soffset, ?);
1794 multiclass MTBUF_Real_AllAddr_si<bits<3> op> {
1795 def _OFFSET_si : MTBUF_Real_si <op, !cast<MTBUF_Pseudo>(NAME#"_OFFSET")>;
1796 def _ADDR64_si : MTBUF_Real_si <op, !cast<MTBUF_Pseudo>(NAME#"_ADDR64")>;
1797 def _OFFEN_si : MTBUF_Real_si <op, !cast<MTBUF_Pseudo>(NAME#"_OFFEN")>;
1798 def _IDXEN_si : MTBUF_Real_si <op, !cast<MTBUF_Pseudo>(NAME#"_IDXEN")>;
1799 def _BOTHEN_si : MTBUF_Real_si <op, !cast<MTBUF_Pseudo>(NAME#"_BOTHEN")>;
1802 defm TBUFFER_LOAD_FORMAT_X : MTBUF_Real_AllAddr_si <0>;
1803 defm TBUFFER_LOAD_FORMAT_XY : MTBUF_Real_AllAddr_si <1>;
1804 defm TBUFFER_LOAD_FORMAT_XYZ : MTBUF_Real_AllAddr_si <2>;
1805 defm TBUFFER_LOAD_FORMAT_XYZW : MTBUF_Real_AllAddr_si <3>;
1806 defm TBUFFER_STORE_FORMAT_X : MTBUF_Real_AllAddr_si <4>;
1807 defm TBUFFER_STORE_FORMAT_XY : MTBUF_Real_AllAddr_si <5>;
1808 defm TBUFFER_STORE_FORMAT_XYZ : MTBUF_Real_AllAddr_si <6>;
1809 defm TBUFFER_STORE_FORMAT_XYZW : MTBUF_Real_AllAddr_si <7>;
1811 //===----------------------------------------------------------------------===//
1813 // MTBUF - GFX6, GFX7.
1814 //===----------------------------------------------------------------------===//
1816 class MUBUF_Real_ci <bits<7> op, MUBUF_Pseudo ps> :
1817 MUBUF_Real_si<op, ps> {
1818 let AssemblerPredicate=isCIOnly;
1819 let DecoderNamespace="CI";
1822 def BUFFER_WBINVL1_VOL_ci : MUBUF_Real_ci <0x70, BUFFER_WBINVL1_VOL>;
1825 //===----------------------------------------------------------------------===//
1827 //===----------------------------------------------------------------------===//
1829 class MUBUF_Real_vi <bits<7> op, MUBUF_Pseudo ps> :
1832 SIMCInstr<ps.PseudoInstr, SIEncodingFamily.VI> {
1833 let AssemblerPredicate=isVI;
1834 let DecoderNamespace="VI";
1836 let Inst{11-0} = !if(ps.has_offset, offset, ?);
1837 let Inst{12} = ps.offen;
1838 let Inst{13} = ps.idxen;
1839 let Inst{14} = !if(ps.has_glc, glc, ps.glc_value);
1840 let Inst{16} = !if(ps.lds, 1, 0);
1841 let Inst{17} = !if(ps.has_slc, slc, ?);
1842 let Inst{24-18} = op;
1843 let Inst{31-26} = 0x38; //encoding
1844 let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?);
1845 let Inst{47-40} = !if(ps.has_vdata, vdata, ?);
1846 let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?);
1847 let Inst{55} = !if(ps.has_tfe, tfe, ?);
1848 let Inst{63-56} = !if(ps.has_soffset, soffset, ?);
1851 multiclass MUBUF_Real_AllAddr_vi<bits<7> op> {
1852 def _OFFSET_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>;
1853 def _OFFEN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>;
1854 def _IDXEN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>;
1855 def _BOTHEN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>;
1858 multiclass MUBUF_Real_AllAddr_Lds_vi<bits<7> op> {
1860 def _OFFSET_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>,
1861 MUBUFLdsTable<0, NAME # "_OFFSET_vi">;
1862 def _OFFEN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>,
1863 MUBUFLdsTable<0, NAME # "_OFFEN_vi">;
1864 def _IDXEN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>,
1865 MUBUFLdsTable<0, NAME # "_IDXEN_vi">;
1866 def _BOTHEN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>,
1867 MUBUFLdsTable<0, NAME # "_BOTHEN_vi">;
1869 def _LDS_OFFSET_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_OFFSET")>,
1870 MUBUFLdsTable<1, NAME # "_OFFSET_vi">;
1871 def _LDS_OFFEN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_OFFEN")>,
1872 MUBUFLdsTable<1, NAME # "_OFFEN_vi">;
1873 def _LDS_IDXEN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_IDXEN")>,
1874 MUBUFLdsTable<1, NAME # "_IDXEN_vi">;
1875 def _LDS_BOTHEN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_LDS_BOTHEN")>,
1876 MUBUFLdsTable<1, NAME # "_BOTHEN_vi">;
1879 class MUBUF_Real_gfx80 <bits<7> op, MUBUF_Pseudo ps> :
1882 SIMCInstr<ps.PseudoInstr, SIEncodingFamily.GFX80> {
1883 let AssemblerPredicate=HasUnpackedD16VMem;
1884 let DecoderNamespace="GFX80_UNPACKED";
1886 let Inst{11-0} = !if(ps.has_offset, offset, ?);
1887 let Inst{12} = ps.offen;
1888 let Inst{13} = ps.idxen;
1889 let Inst{14} = !if(ps.has_glc, glc, ps.glc_value);
1890 let Inst{16} = !if(ps.lds, 1, 0);
1891 let Inst{17} = !if(ps.has_slc, slc, ?);
1892 let Inst{24-18} = op;
1893 let Inst{31-26} = 0x38; //encoding
1894 let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?);
1895 let Inst{47-40} = !if(ps.has_vdata, vdata, ?);
1896 let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?);
1897 let Inst{55} = !if(ps.has_tfe, tfe, ?);
1898 let Inst{63-56} = !if(ps.has_soffset, soffset, ?);
1901 multiclass MUBUF_Real_AllAddr_gfx80<bits<7> op> {
1902 def _OFFSET_gfx80 : MUBUF_Real_gfx80 <op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET")>;
1903 def _OFFEN_gfx80 : MUBUF_Real_gfx80 <op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN")>;
1904 def _IDXEN_gfx80 : MUBUF_Real_gfx80 <op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN")>;
1905 def _BOTHEN_gfx80 : MUBUF_Real_gfx80 <op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN")>;
1908 multiclass MUBUF_Real_Atomic_vi<bits<7> op> :
1909 MUBUF_Real_AllAddr_vi<op> {
1910 def _OFFSET_RTN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_OFFSET_RTN")>;
1911 def _OFFEN_RTN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_OFFEN_RTN")>;
1912 def _IDXEN_RTN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_IDXEN_RTN")>;
1913 def _BOTHEN_RTN_vi : MUBUF_Real_vi <op, !cast<MUBUF_Pseudo>(NAME#"_BOTHEN_RTN")>;
1916 defm BUFFER_LOAD_FORMAT_X : MUBUF_Real_AllAddr_Lds_vi <0x00>;
1917 defm BUFFER_LOAD_FORMAT_XY : MUBUF_Real_AllAddr_vi <0x01>;
1918 defm BUFFER_LOAD_FORMAT_XYZ : MUBUF_Real_AllAddr_vi <0x02>;
1919 defm BUFFER_LOAD_FORMAT_XYZW : MUBUF_Real_AllAddr_vi <0x03>;
1920 defm BUFFER_STORE_FORMAT_X : MUBUF_Real_AllAddr_vi <0x04>;
1921 defm BUFFER_STORE_FORMAT_XY : MUBUF_Real_AllAddr_vi <0x05>;
1922 defm BUFFER_STORE_FORMAT_XYZ : MUBUF_Real_AllAddr_vi <0x06>;
1923 defm BUFFER_STORE_FORMAT_XYZW : MUBUF_Real_AllAddr_vi <0x07>;
1924 let SubtargetPredicate = HasUnpackedD16VMem in {
1925 defm BUFFER_LOAD_FORMAT_D16_X_gfx80 : MUBUF_Real_AllAddr_gfx80 <0x08>;
1926 defm BUFFER_LOAD_FORMAT_D16_XY_gfx80 : MUBUF_Real_AllAddr_gfx80 <0x09>;
1927 defm BUFFER_LOAD_FORMAT_D16_XYZ_gfx80 : MUBUF_Real_AllAddr_gfx80 <0x0a>;
1928 defm BUFFER_LOAD_FORMAT_D16_XYZW_gfx80 : MUBUF_Real_AllAddr_gfx80 <0x0b>;
1929 defm BUFFER_STORE_FORMAT_D16_X_gfx80 : MUBUF_Real_AllAddr_gfx80 <0x0c>;
1930 defm BUFFER_STORE_FORMAT_D16_XY_gfx80 : MUBUF_Real_AllAddr_gfx80 <0x0d>;
1931 defm BUFFER_STORE_FORMAT_D16_XYZ_gfx80 : MUBUF_Real_AllAddr_gfx80 <0x0e>;
1932 defm BUFFER_STORE_FORMAT_D16_XYZW_gfx80 : MUBUF_Real_AllAddr_gfx80 <0x0f>;
1933 } // End HasUnpackedD16VMem.
1934 let SubtargetPredicate = HasPackedD16VMem in {
1935 defm BUFFER_LOAD_FORMAT_D16_X : MUBUF_Real_AllAddr_vi <0x08>;
1936 defm BUFFER_LOAD_FORMAT_D16_XY : MUBUF_Real_AllAddr_vi <0x09>;
1937 defm BUFFER_LOAD_FORMAT_D16_XYZ : MUBUF_Real_AllAddr_vi <0x0a>;
1938 defm BUFFER_LOAD_FORMAT_D16_XYZW : MUBUF_Real_AllAddr_vi <0x0b>;
1939 defm BUFFER_STORE_FORMAT_D16_X : MUBUF_Real_AllAddr_vi <0x0c>;
1940 defm BUFFER_STORE_FORMAT_D16_XY : MUBUF_Real_AllAddr_vi <0x0d>;
1941 defm BUFFER_STORE_FORMAT_D16_XYZ : MUBUF_Real_AllAddr_vi <0x0e>;
1942 defm BUFFER_STORE_FORMAT_D16_XYZW : MUBUF_Real_AllAddr_vi <0x0f>;
1943 } // End HasPackedD16VMem.
1944 defm BUFFER_LOAD_UBYTE : MUBUF_Real_AllAddr_Lds_vi <0x10>;
1945 defm BUFFER_LOAD_SBYTE : MUBUF_Real_AllAddr_Lds_vi <0x11>;
1946 defm BUFFER_LOAD_USHORT : MUBUF_Real_AllAddr_Lds_vi <0x12>;
1947 defm BUFFER_LOAD_SSHORT : MUBUF_Real_AllAddr_Lds_vi <0x13>;
1948 defm BUFFER_LOAD_DWORD : MUBUF_Real_AllAddr_Lds_vi <0x14>;
1949 defm BUFFER_LOAD_DWORDX2 : MUBUF_Real_AllAddr_Lds_vi <0x15>;
1950 defm BUFFER_LOAD_DWORDX3 : MUBUF_Real_AllAddr_Lds_vi <0x16>;
1951 defm BUFFER_LOAD_DWORDX4 : MUBUF_Real_AllAddr_Lds_vi <0x17>;
1952 defm BUFFER_STORE_BYTE : MUBUF_Real_AllAddr_vi <0x18>;
1953 defm BUFFER_STORE_BYTE_D16_HI : MUBUF_Real_AllAddr_vi <0x19>;
1954 defm BUFFER_STORE_SHORT : MUBUF_Real_AllAddr_vi <0x1a>;
1955 defm BUFFER_STORE_SHORT_D16_HI : MUBUF_Real_AllAddr_vi <0x1b>;
1956 defm BUFFER_STORE_DWORD : MUBUF_Real_AllAddr_vi <0x1c>;
1957 defm BUFFER_STORE_DWORDX2 : MUBUF_Real_AllAddr_vi <0x1d>;
1958 defm BUFFER_STORE_DWORDX3 : MUBUF_Real_AllAddr_vi <0x1e>;
1959 defm BUFFER_STORE_DWORDX4 : MUBUF_Real_AllAddr_vi <0x1f>;
1961 defm BUFFER_LOAD_UBYTE_D16 : MUBUF_Real_AllAddr_vi <0x20>;
1962 defm BUFFER_LOAD_UBYTE_D16_HI : MUBUF_Real_AllAddr_vi <0x21>;
1963 defm BUFFER_LOAD_SBYTE_D16 : MUBUF_Real_AllAddr_vi <0x22>;
1964 defm BUFFER_LOAD_SBYTE_D16_HI : MUBUF_Real_AllAddr_vi <0x23>;
1965 defm BUFFER_LOAD_SHORT_D16 : MUBUF_Real_AllAddr_vi <0x24>;
1966 defm BUFFER_LOAD_SHORT_D16_HI : MUBUF_Real_AllAddr_vi <0x25>;
1968 defm BUFFER_LOAD_FORMAT_D16_HI_X : MUBUF_Real_AllAddr_vi <0x26>;
1969 defm BUFFER_STORE_FORMAT_D16_HI_X : MUBUF_Real_AllAddr_vi <0x27>;
1971 defm BUFFER_ATOMIC_SWAP : MUBUF_Real_Atomic_vi <0x40>;
1972 defm BUFFER_ATOMIC_CMPSWAP : MUBUF_Real_Atomic_vi <0x41>;
1973 defm BUFFER_ATOMIC_ADD : MUBUF_Real_Atomic_vi <0x42>;
1974 defm BUFFER_ATOMIC_SUB : MUBUF_Real_Atomic_vi <0x43>;
1975 defm BUFFER_ATOMIC_SMIN : MUBUF_Real_Atomic_vi <0x44>;
1976 defm BUFFER_ATOMIC_UMIN : MUBUF_Real_Atomic_vi <0x45>;
1977 defm BUFFER_ATOMIC_SMAX : MUBUF_Real_Atomic_vi <0x46>;
1978 defm BUFFER_ATOMIC_UMAX : MUBUF_Real_Atomic_vi <0x47>;
1979 defm BUFFER_ATOMIC_AND : MUBUF_Real_Atomic_vi <0x48>;
1980 defm BUFFER_ATOMIC_OR : MUBUF_Real_Atomic_vi <0x49>;
1981 defm BUFFER_ATOMIC_XOR : MUBUF_Real_Atomic_vi <0x4a>;
1982 defm BUFFER_ATOMIC_INC : MUBUF_Real_Atomic_vi <0x4b>;
1983 defm BUFFER_ATOMIC_DEC : MUBUF_Real_Atomic_vi <0x4c>;
1985 defm BUFFER_ATOMIC_SWAP_X2 : MUBUF_Real_Atomic_vi <0x60>;
1986 defm BUFFER_ATOMIC_CMPSWAP_X2 : MUBUF_Real_Atomic_vi <0x61>;
1987 defm BUFFER_ATOMIC_ADD_X2 : MUBUF_Real_Atomic_vi <0x62>;
1988 defm BUFFER_ATOMIC_SUB_X2 : MUBUF_Real_Atomic_vi <0x63>;
1989 defm BUFFER_ATOMIC_SMIN_X2 : MUBUF_Real_Atomic_vi <0x64>;
1990 defm BUFFER_ATOMIC_UMIN_X2 : MUBUF_Real_Atomic_vi <0x65>;
1991 defm BUFFER_ATOMIC_SMAX_X2 : MUBUF_Real_Atomic_vi <0x66>;
1992 defm BUFFER_ATOMIC_UMAX_X2 : MUBUF_Real_Atomic_vi <0x67>;
1993 defm BUFFER_ATOMIC_AND_X2 : MUBUF_Real_Atomic_vi <0x68>;
1994 defm BUFFER_ATOMIC_OR_X2 : MUBUF_Real_Atomic_vi <0x69>;
1995 defm BUFFER_ATOMIC_XOR_X2 : MUBUF_Real_Atomic_vi <0x6a>;
1996 defm BUFFER_ATOMIC_INC_X2 : MUBUF_Real_Atomic_vi <0x6b>;
1997 defm BUFFER_ATOMIC_DEC_X2 : MUBUF_Real_Atomic_vi <0x6c>;
1999 def BUFFER_STORE_LDS_DWORD_vi : MUBUF_Real_vi <0x3d, BUFFER_STORE_LDS_DWORD>;
2001 def BUFFER_WBINVL1_vi : MUBUF_Real_vi <0x3e, BUFFER_WBINVL1>;
2002 def BUFFER_WBINVL1_VOL_vi : MUBUF_Real_vi <0x3f, BUFFER_WBINVL1_VOL>;
2004 class MTBUF_Real_vi <bits<4> op, MTBUF_Pseudo ps> :
2007 SIMCInstr<ps.PseudoInstr, SIEncodingFamily.VI> {
2008 let AssemblerPredicate=isVI;
2009 let DecoderNamespace="VI";
2011 let Inst{11-0} = !if(ps.has_offset, offset, ?);
2012 let Inst{12} = ps.offen;
2013 let Inst{13} = ps.idxen;
2014 let Inst{14} = !if(ps.has_glc, glc, ps.glc_value);
2015 let Inst{18-15} = op;
2016 let Inst{22-19} = dfmt;
2017 let Inst{25-23} = nfmt;
2018 let Inst{31-26} = 0x3a; //encoding
2019 let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?);
2020 let Inst{47-40} = !if(ps.has_vdata, vdata, ?);
2021 let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?);
2022 let Inst{54} = !if(ps.has_slc, slc, ?);
2023 let Inst{55} = !if(ps.has_tfe, tfe, ?);
2024 let Inst{63-56} = !if(ps.has_soffset, soffset, ?);
2027 multiclass MTBUF_Real_AllAddr_vi<bits<4> op> {
2028 def _OFFSET_vi : MTBUF_Real_vi <op, !cast<MTBUF_Pseudo>(NAME#"_OFFSET")>;
2029 def _OFFEN_vi : MTBUF_Real_vi <op, !cast<MTBUF_Pseudo>(NAME#"_OFFEN")>;
2030 def _IDXEN_vi : MTBUF_Real_vi <op, !cast<MTBUF_Pseudo>(NAME#"_IDXEN")>;
2031 def _BOTHEN_vi : MTBUF_Real_vi <op, !cast<MTBUF_Pseudo>(NAME#"_BOTHEN")>;
2034 class MTBUF_Real_gfx80 <bits<4> op, MTBUF_Pseudo ps> :
2037 SIMCInstr<ps.PseudoInstr, SIEncodingFamily.GFX80> {
2038 let AssemblerPredicate=HasUnpackedD16VMem;
2039 let DecoderNamespace="GFX80_UNPACKED";
2041 let Inst{11-0} = !if(ps.has_offset, offset, ?);
2042 let Inst{12} = ps.offen;
2043 let Inst{13} = ps.idxen;
2044 let Inst{14} = !if(ps.has_glc, glc, ps.glc_value);
2045 let Inst{18-15} = op;
2046 let Inst{22-19} = dfmt;
2047 let Inst{25-23} = nfmt;
2048 let Inst{31-26} = 0x3a; //encoding
2049 let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?);
2050 let Inst{47-40} = !if(ps.has_vdata, vdata, ?);
2051 let Inst{52-48} = !if(ps.has_srsrc, srsrc{6-2}, ?);
2052 let Inst{54} = !if(ps.has_slc, slc, ?);
2053 let Inst{55} = !if(ps.has_tfe, tfe, ?);
2054 let Inst{63-56} = !if(ps.has_soffset, soffset, ?);
2057 multiclass MTBUF_Real_AllAddr_gfx80<bits<4> op> {
2058 def _OFFSET_gfx80 : MTBUF_Real_gfx80 <op, !cast<MTBUF_Pseudo>(NAME#"_OFFSET")>;
2059 def _OFFEN_gfx80 : MTBUF_Real_gfx80 <op, !cast<MTBUF_Pseudo>(NAME#"_OFFEN")>;
2060 def _IDXEN_gfx80 : MTBUF_Real_gfx80 <op, !cast<MTBUF_Pseudo>(NAME#"_IDXEN")>;
2061 def _BOTHEN_gfx80 : MTBUF_Real_gfx80 <op, !cast<MTBUF_Pseudo>(NAME#"_BOTHEN")>;
2064 defm TBUFFER_LOAD_FORMAT_X : MTBUF_Real_AllAddr_vi <0x00>;
2065 defm TBUFFER_LOAD_FORMAT_XY : MTBUF_Real_AllAddr_vi <0x01>;
2066 defm TBUFFER_LOAD_FORMAT_XYZ : MTBUF_Real_AllAddr_vi <0x02>;
2067 defm TBUFFER_LOAD_FORMAT_XYZW : MTBUF_Real_AllAddr_vi <0x03>;
2068 defm TBUFFER_STORE_FORMAT_X : MTBUF_Real_AllAddr_vi <0x04>;
2069 defm TBUFFER_STORE_FORMAT_XY : MTBUF_Real_AllAddr_vi <0x05>;
2070 defm TBUFFER_STORE_FORMAT_XYZ : MTBUF_Real_AllAddr_vi <0x06>;
2071 defm TBUFFER_STORE_FORMAT_XYZW : MTBUF_Real_AllAddr_vi <0x07>;
2072 let SubtargetPredicate = HasUnpackedD16VMem in {
2073 defm TBUFFER_LOAD_FORMAT_D16_X_gfx80 : MTBUF_Real_AllAddr_gfx80 <0x08>;
2074 defm TBUFFER_LOAD_FORMAT_D16_XY_gfx80 : MTBUF_Real_AllAddr_gfx80 <0x09>;
2075 defm TBUFFER_LOAD_FORMAT_D16_XYZ_gfx80 : MTBUF_Real_AllAddr_gfx80 <0x0a>;
2076 defm TBUFFER_LOAD_FORMAT_D16_XYZW_gfx80 : MTBUF_Real_AllAddr_gfx80 <0x0b>;
2077 defm TBUFFER_STORE_FORMAT_D16_X_gfx80 : MTBUF_Real_AllAddr_gfx80 <0x0c>;
2078 defm TBUFFER_STORE_FORMAT_D16_XY_gfx80 : MTBUF_Real_AllAddr_gfx80 <0x0d>;
2079 defm TBUFFER_STORE_FORMAT_D16_XYZ_gfx80 : MTBUF_Real_AllAddr_gfx80 <0x0e>;
2080 defm TBUFFER_STORE_FORMAT_D16_XYZW_gfx80 : MTBUF_Real_AllAddr_gfx80 <0x0f>;
2081 } // End HasUnpackedD16VMem.
2082 let SubtargetPredicate = HasPackedD16VMem in {
2083 defm TBUFFER_LOAD_FORMAT_D16_X : MTBUF_Real_AllAddr_vi <0x08>;
2084 defm TBUFFER_LOAD_FORMAT_D16_XY : MTBUF_Real_AllAddr_vi <0x09>;
2085 defm TBUFFER_LOAD_FORMAT_D16_XYZ : MTBUF_Real_AllAddr_vi <0x0a>;
2086 defm TBUFFER_LOAD_FORMAT_D16_XYZW : MTBUF_Real_AllAddr_vi <0x0b>;
2087 defm TBUFFER_STORE_FORMAT_D16_X : MTBUF_Real_AllAddr_vi <0x0c>;
2088 defm TBUFFER_STORE_FORMAT_D16_XY : MTBUF_Real_AllAddr_vi <0x0d>;
2089 defm TBUFFER_STORE_FORMAT_D16_XYZ : MTBUF_Real_AllAddr_vi <0x0e>;
2090 defm TBUFFER_STORE_FORMAT_D16_XYZW : MTBUF_Real_AllAddr_vi <0x0f>;
2091 } // End HasUnpackedD16VMem.
2093 def MUBUFInfoTable : GenericTable {
2094 let FilterClass = "MUBUF_Pseudo";
2095 let CppTypeName = "MUBUFInfo";
2096 let Fields = ["Opcode", "BaseOpcode", "dwords", "has_vaddr", "has_srsrc", "has_soffset"];
2098 let PrimaryKey = ["Opcode"];
2099 let PrimaryKeyName = "getMUBUFOpcodeHelper";
2102 def getMUBUFInfoFromOpcode : SearchIndex {
2103 let Table = MUBUFInfoTable;
2104 let Key = ["Opcode"];
2107 def getMUBUFInfoFromBaseOpcodeAndDwords : SearchIndex {
2108 let Table = MUBUFInfoTable;
2109 let Key = ["BaseOpcode", "dwords"];