1 //===-- FLATInstructions.td - FLAT Instruction Definitions ----------------===//
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 FlatOffset : ComplexPattern<iPTR, 2, "SelectFlatOffset", [], [SDNPWantRoot], -10>;
10 def GlobalOffset : ComplexPattern<iPTR, 2, "SelectGlobalOffset", [], [SDNPWantRoot], -10>;
11 def ScratchOffset : ComplexPattern<iPTR, 2, "SelectScratchOffset", [], [SDNPWantRoot], -10>;
13 def GlobalSAddr : ComplexPattern<iPTR, 3, "SelectGlobalSAddr", [], [SDNPWantRoot], -10>;
14 def ScratchSAddr : ComplexPattern<iPTR, 2, "SelectScratchSAddr", [], [SDNPWantRoot], -10>;
15 def ScratchSVAddr : ComplexPattern<iPTR, 3, "SelectScratchSVAddr", [], [SDNPWantRoot], -10>;
17 //===----------------------------------------------------------------------===//
19 //===----------------------------------------------------------------------===//
21 class FLAT_Pseudo<string opName, dag outs, dag ins,
22 string asmOps, list<dag> pattern=[]> :
23 InstSI<outs, ins, "", pattern>,
24 SIMCInstr<NAME, SIEncodingFamily.NONE> {
27 let isCodeGenOnly = 1;
31 let UseNamedOperandTable = 1;
32 let hasSideEffects = 0;
33 let SchedRW = [WriteVMEM];
35 string Mnemonic = opName;
36 string AsmOperands = asmOps;
38 bits<1> is_flat_global = 0;
39 bits<1> is_flat_scratch = 0;
43 // We need to distinguish having saddr and enabling saddr because
44 // saddr is only valid for scratch and global instructions. Pre-gfx9
45 // these bits were reserved, so we also don't necessarily want to
46 // set these bits to the disabled value for the original flat
47 // segment instructions.
48 bits<1> has_saddr = 0;
49 bits<1> enabled_saddr = 0;
50 bits<7> saddr_value = 0;
51 bits<1> has_vaddr = 1;
59 bits<1> sccbValue = 0;
60 bits<1> has_sve = 0; // Scratch VGPR Enable
63 bits<1> has_offset = 1;
65 let SubtargetPredicate = !if(is_flat_global, HasFlatGlobalInsts,
66 !if(is_flat_scratch, HasFlatScratchInsts, HasFlatAddressSpace));
68 // TODO: M0 if it could possibly access LDS (before gfx9? only)?
69 let Uses = !if(is_flat_global, [EXEC], [EXEC, FLAT_SCR]);
71 // Internally, FLAT instruction are executed as both an LDS and a
72 // Buffer instruction; so, they increment both VM_CNT and LGKM_CNT
73 // and are not considered done until both have been decremented.
75 let LGKM_CNT = !not(!or(is_flat_global, is_flat_scratch));
77 let FlatGlobal = is_flat_global;
79 let FlatScratch = is_flat_scratch;
82 class FLAT_Real <bits<7> op, FLAT_Pseudo ps, string opName = ps.Mnemonic> :
83 InstSI <ps.OutOperandList, ps.InOperandList, opName # ps.AsmOperands, []>,
87 let isCodeGenOnly = 0;
91 // copy relevant pseudo op flags
92 let SubtargetPredicate = ps.SubtargetPredicate;
93 let AsmMatchConverter = ps.AsmMatchConverter;
94 let OtherPredicates = ps.OtherPredicates;
95 let TSFlags = ps.TSFlags;
96 let UseNamedOperandTable = ps.UseNamedOperandTable;
97 let SchedRW = ps.SchedRW;
98 let mayLoad = ps.mayLoad;
99 let mayStore = ps.mayStore;
100 let IsAtomicRet = ps.IsAtomicRet;
101 let IsAtomicNoRet = ps.IsAtomicNoRet;
102 let VM_CNT = ps.VM_CNT;
103 let LGKM_CNT = ps.LGKM_CNT;
116 // Only valid on gfx9
117 bits<1> lds = ps.lds; // LDS DMA for global and scratch
119 // Segment, 00=flat, 01=scratch, 10=global, 11=reserved
120 bits<2> seg = {ps.is_flat_global, ps.is_flat_scratch};
122 // Signed offset. Highest bit ignored for flat and treated as 12-bit
123 // unsigned for flat accesses.
125 // GFX90A+ only: instruction uses AccVGPR for data
126 bits<1> acc = !if(ps.has_vdst, vdst{9}, !if(ps.has_data, vdata{9}, 0));
128 // We don't use tfe right now, and it was removed in gfx9.
131 // Only valid on GFX9+
132 let Inst{12-0} = offset;
133 let Inst{13} = !if(ps.has_sve, ps.sve, lds);
134 let Inst{15-14} = seg;
136 let Inst{16} = !if(ps.has_glc, cpol{CPolBit.GLC}, ps.glcValue);
137 let Inst{17} = cpol{CPolBit.SLC};
138 let Inst{24-18} = op;
139 let Inst{31-26} = 0x37; // Encoding.
140 let Inst{39-32} = !if(ps.has_vaddr, vaddr, ?);
141 let Inst{47-40} = !if(ps.has_data, vdata{7-0}, ?);
142 let Inst{54-48} = !if(ps.has_saddr, !if(ps.enabled_saddr, saddr, 0x7f), 0);
144 // 54-48 is reserved.
145 let Inst{55} = acc; // nv on GFX9+, TFE before. AccVGPR for data on GFX90A.
146 let Inst{63-56} = !if(ps.has_vdst, vdst{7-0}, ?);
149 class VFLAT_Real <bits<8> op, FLAT_Pseudo ps, string opName = ps.Mnemonic> :
150 InstSI <ps.OutOperandList, ps.InOperandList, opName # ps.AsmOperands, []>,
155 // copy relevant pseudo op flags
156 let SubtargetPredicate = ps.SubtargetPredicate;
157 let WaveSizePredicate = ps.WaveSizePredicate;
158 let AsmMatchConverter = ps.AsmMatchConverter;
159 let OtherPredicates = ps.OtherPredicates;
160 let TSFlags = ps.TSFlags;
161 let UseNamedOperandTable = ps.UseNamedOperandTable;
162 let SchedRW = ps.SchedRW;
163 let mayLoad = ps.mayLoad;
164 let mayStore = ps.mayStore;
165 let IsAtomicRet = ps.IsAtomicRet;
166 let IsAtomicNoRet = ps.IsAtomicNoRet;
167 let VM_CNT = ps.VM_CNT;
168 let LGKM_CNT = ps.LGKM_CNT;
176 bits<8> vdata; // vsrc
180 let Inst{6-0} = !if(ps.enabled_saddr, saddr, SGPR_NULL_gfx11plus.Index);
181 let Inst{21-14} = op;
182 let Inst{31-26} = 0x3b;
183 let Inst{39-32} = !if(ps.has_vdst, vdst, ?);
184 let Inst{49} = ps.sve;
185 let Inst{54-53} = cpol{2-1}; // th{2-1}
186 let Inst{52} = !if(ps.IsAtomicRet, 1, cpol{0}); // th{0}
187 let Inst{51-50} = cpol{4-3}; // scope
188 let Inst{62-55} = !if(ps.has_data, vdata{7-0}, ?);
189 let Inst{71-64} = !if(ps.has_vaddr, vaddr, ?);
190 let Inst{95-72} = !if(ps.has_offset, offset, ?);
193 class GlobalSaddrTable <bit is_saddr, string Name = ""> {
194 bit IsSaddr = is_saddr;
195 string SaddrOp = Name;
198 // TODO: Is exec allowed for saddr? The disabled value 0x7f is the
199 // same encoding value as exec_hi, so it isn't possible to use that if
200 // saddr is 32-bit (which isn't handled here yet).
201 class FLAT_Load_Pseudo <string opName, RegisterClass regClass,
202 bit HasTiedOutput = 0,
203 bit HasSaddr = 0, bit EnableSaddr = 0,
204 RegisterOperand vdata_op = getLdStRegisterOperand<regClass>.ret> : FLAT_Pseudo<
206 (outs vdata_op:$vdst),
210 (ins SReg_64:$saddr, VGPR_32:$vaddr),
211 (ins VReg_64:$vaddr)),
212 (ins flat_offset:$offset)),
213 // FIXME: Operands with default values do not work with following non-optional operands.
214 !if(HasTiedOutput, (ins CPol:$cpol, vdata_op:$vdst_in),
215 (ins CPol_0:$cpol))),
216 " $vdst, $vaddr"#!if(HasSaddr, !if(EnableSaddr, ", $saddr", ", off"), "")#"$offset$cpol"> {
219 let has_saddr = HasSaddr;
220 let enabled_saddr = EnableSaddr;
222 let Constraints = !if(HasTiedOutput, "$vdst = $vdst_in", "");
223 let DisableEncoding = !if(HasTiedOutput, "$vdst_in", "");
226 class FLAT_Store_Pseudo <string opName, RegisterClass vdataClass,
227 bit HasSaddr = 0, bit EnableSaddr = 0> : FLAT_Pseudo<
232 (ins VGPR_32:$vaddr, getLdStRegisterOperand<vdataClass>.ret:$vdata, SReg_64:$saddr),
233 (ins VReg_64:$vaddr, getLdStRegisterOperand<vdataClass>.ret:$vdata)),
234 (ins flat_offset:$offset, CPol_0:$cpol)),
235 " $vaddr, $vdata"#!if(HasSaddr, !if(EnableSaddr, ", $saddr", ", off"), "")#"$offset$cpol"> {
239 let has_saddr = HasSaddr;
240 let enabled_saddr = EnableSaddr;
243 multiclass FLAT_Global_Load_Pseudo<string opName, RegisterClass regClass, bit HasTiedInput = 0> {
244 let is_flat_global = 1 in {
245 def "" : FLAT_Load_Pseudo<opName, regClass, HasTiedInput, 1>,
246 GlobalSaddrTable<0, opName>;
247 def _SADDR : FLAT_Load_Pseudo<opName, regClass, HasTiedInput, 1, 1>,
248 GlobalSaddrTable<1, opName>;
252 class FLAT_Global_Load_AddTid_Pseudo <string opName, RegisterClass regClass,
253 bit HasTiedOutput = 0, bit EnableSaddr = 0> : FLAT_Pseudo<
255 (outs regClass:$vdst),
256 !con(!if(EnableSaddr, (ins SReg_64:$saddr), (ins)),
257 (ins flat_offset:$offset, CPol_0:$cpol),
258 !if(HasTiedOutput, (ins regClass:$vdst_in), (ins))),
259 " $vdst, "#!if(EnableSaddr, "$saddr", "off")#"$offset$cpol"> {
260 let is_flat_global = 1;
265 let enabled_saddr = EnableSaddr;
267 let Constraints = !if(HasTiedOutput, "$vdst = $vdst_in", "");
268 let DisableEncoding = !if(HasTiedOutput, "$vdst_in", "");
271 multiclass FLAT_Global_Load_AddTid_Pseudo<string opName, RegisterClass regClass,
272 bit HasTiedOutput = 0> {
273 def "" : FLAT_Global_Load_AddTid_Pseudo<opName, regClass, HasTiedOutput>,
274 GlobalSaddrTable<0, opName>;
275 def _SADDR : FLAT_Global_Load_AddTid_Pseudo<opName, regClass, HasTiedOutput, 1>,
276 GlobalSaddrTable<1, opName>;
279 multiclass FLAT_Global_Store_Pseudo<string opName, RegisterClass regClass> {
280 let is_flat_global = 1 in {
281 def "" : FLAT_Store_Pseudo<opName, regClass, 1>,
282 GlobalSaddrTable<0, opName>;
283 def _SADDR : FLAT_Store_Pseudo<opName, regClass, 1, 1>,
284 GlobalSaddrTable<1, opName>;
288 class FLAT_Global_Load_LDS_Pseudo <string opName, bit EnableSaddr = 0> : FLAT_Pseudo<
292 !if(EnableSaddr, (ins SReg_64:$saddr, VGPR_32:$vaddr), (ins VReg_64:$vaddr)),
293 (ins flat_offset:$offset, CPol_0:$cpol)),
294 " $vaddr"#!if(EnableSaddr, ", $saddr", ", off")#"$offset$cpol"> {
296 let is_flat_global = 1;
303 let enabled_saddr = EnableSaddr;
305 let Uses = [M0, EXEC];
306 let SchedRW = [WriteVMEM, WriteLDS];
309 multiclass FLAT_Global_Load_LDS_Pseudo<string opName> {
310 def "" : FLAT_Global_Load_LDS_Pseudo<opName>,
311 GlobalSaddrTable<0, opName>;
312 def _SADDR : FLAT_Global_Load_LDS_Pseudo<opName, 1>,
313 GlobalSaddrTable<1, opName>;
316 class FLAT_Global_Store_AddTid_Pseudo <string opName, RegisterClass vdataClass,
317 bit EnableSaddr = 0> : FLAT_Pseudo<
320 !con(!if(EnableSaddr, (ins vdataClass:$vdata, SReg_64:$saddr), (ins vdataClass:$vdata)),
321 (ins flat_offset:$offset, CPol:$cpol)),
322 " $vdata, "#!if(EnableSaddr, "$saddr", "off")#"$offset$cpol"> {
323 let is_flat_global = 1;
329 let enabled_saddr = EnableSaddr;
332 multiclass FLAT_Global_Store_AddTid_Pseudo<string opName, RegisterClass regClass> {
333 def "" : FLAT_Global_Store_AddTid_Pseudo<opName, regClass>,
334 GlobalSaddrTable<0, opName>;
335 def _SADDR : FLAT_Global_Store_AddTid_Pseudo<opName, regClass, 1>,
336 GlobalSaddrTable<1, opName>;
339 class FLAT_Global_Invalidate_Writeback<string opName, SDPatternOperator node = null_frag> :
340 FLAT_Pseudo<opName, (outs), (ins CPol:$cpol), "$cpol", [(node)]> {
342 let AsmMatchConverter = "";
344 let hasSideEffects = 1;
347 let is_flat_global = 1;
351 let enabled_saddr = 0;
367 class FlatScratchInst <string sv_op, string mode> {
372 class FLAT_Scratch_Load_Pseudo <string opName, RegisterClass regClass,
373 bit HasTiedOutput = 0,
376 bit EnableVaddr = !or(EnableSVE, !not(EnableSaddr))>
379 (outs getLdStRegisterOperand<regClass>.ret:$vdst),
382 (ins VGPR_32:$vaddr, SReg_32_XEXEC_HI:$saddr, flat_offset:$offset),
384 (ins SReg_32_XEXEC_HI:$saddr, flat_offset:$offset),
386 (ins VGPR_32:$vaddr, flat_offset:$offset),
387 (ins flat_offset:$offset)))),
388 !if(HasTiedOutput, (ins CPol:$cpol, getLdStRegisterOperand<regClass>.ret:$vdst_in),
389 (ins CPol_0:$cpol))),
390 " $vdst, "#!if(EnableVaddr, "$vaddr, ", "off, ")#!if(EnableSaddr, "$saddr", "off")#"$offset$cpol"> {
391 let is_flat_scratch = 1;
395 let enabled_saddr = EnableSaddr;
396 let has_vaddr = EnableVaddr;
397 let has_sve = EnableSVE;
398 let sve = EnableVaddr;
400 let Constraints = !if(HasTiedOutput, "$vdst = $vdst_in", "");
401 let DisableEncoding = !if(HasTiedOutput, "$vdst_in", "");
404 class FLAT_Scratch_Store_Pseudo <string opName, RegisterClass vdataClass, bit EnableSaddr = 0,
406 bit EnableVaddr = !or(EnableSVE, !not(EnableSaddr)),
407 RegisterOperand vdata_op = getLdStRegisterOperand<vdataClass>.ret> : FLAT_Pseudo<
411 (ins vdata_op:$vdata, VGPR_32:$vaddr, SReg_32_XEXEC_HI:$saddr, flat_offset:$offset, CPol_0:$cpol),
413 (ins vdata_op:$vdata, SReg_32_XEXEC_HI:$saddr, flat_offset:$offset, CPol_0:$cpol),
415 (ins vdata_op:$vdata, VGPR_32:$vaddr, flat_offset:$offset, CPol_0:$cpol),
416 (ins vdata_op:$vdata, flat_offset:$offset, CPol_0:$cpol)))),
417 " "#!if(EnableVaddr, "$vaddr", "off")#", $vdata, "#!if(EnableSaddr, "$saddr", "off")#"$offset$cpol"> {
418 let is_flat_scratch = 1;
423 let enabled_saddr = EnableSaddr;
424 let has_vaddr = EnableVaddr;
425 let has_sve = EnableSVE;
426 let sve = EnableVaddr;
429 multiclass FLAT_Scratch_Load_Pseudo<string opName, RegisterClass regClass, bit HasTiedOutput = 0> {
430 def "" : FLAT_Scratch_Load_Pseudo<opName, regClass, HasTiedOutput>,
431 FlatScratchInst<opName, "SV">;
432 def _SADDR : FLAT_Scratch_Load_Pseudo<opName, regClass, HasTiedOutput, 1>,
433 FlatScratchInst<opName, "SS">;
435 let SubtargetPredicate = HasFlatScratchSVSMode in
436 def _SVS : FLAT_Scratch_Load_Pseudo<opName, regClass, HasTiedOutput, 1, 1>,
437 FlatScratchInst<opName, "SVS">;
439 let SubtargetPredicate = HasFlatScratchSTMode in
440 def _ST : FLAT_Scratch_Load_Pseudo<opName, regClass, HasTiedOutput, 0, 0, 0>,
441 FlatScratchInst<opName, "ST">;
444 multiclass FLAT_Scratch_Store_Pseudo<string opName, RegisterClass regClass> {
445 def "" : FLAT_Scratch_Store_Pseudo<opName, regClass>,
446 FlatScratchInst<opName, "SV">;
447 def _SADDR : FLAT_Scratch_Store_Pseudo<opName, regClass, 1>,
448 FlatScratchInst<opName, "SS">;
450 let SubtargetPredicate = HasFlatScratchSVSMode in
451 def _SVS : FLAT_Scratch_Store_Pseudo<opName, regClass, 1, 1>,
452 FlatScratchInst<opName, "SVS">;
454 let SubtargetPredicate = HasFlatScratchSTMode in
455 def _ST : FLAT_Scratch_Store_Pseudo<opName, regClass, 0, 0, 0>,
456 FlatScratchInst<opName, "ST">;
459 class FLAT_Scratch_Load_LDS_Pseudo <string opName, bit EnableSaddr = 0,
461 bit EnableVaddr = !or(EnableSVE, !not(EnableSaddr))> : FLAT_Pseudo<
465 (ins VGPR_32:$vaddr, SReg_32_XEXEC_HI:$saddr, flat_offset:$offset, CPol:$cpol),
467 (ins SReg_32_XEXEC_HI:$saddr, flat_offset:$offset, CPol:$cpol),
469 (ins VGPR_32:$vaddr, flat_offset:$offset, CPol:$cpol),
470 (ins flat_offset:$offset, CPol:$cpol)))),
471 " "#!if(EnableVaddr, "$vaddr, ", "off, ")#!if(EnableSaddr, "$saddr", "off")#"$offset$cpol"> {
474 let is_flat_scratch = 1;
481 let enabled_saddr = EnableSaddr;
482 let has_vaddr = EnableVaddr;
483 let has_sve = EnableSVE;
484 let sve = EnableVaddr;
486 let Uses = [M0, EXEC];
487 let SchedRW = [WriteVMEM, WriteLDS];
490 multiclass FLAT_Scratch_Load_LDS_Pseudo<string opName> {
491 def "" : FLAT_Scratch_Load_LDS_Pseudo<opName>,
492 FlatScratchInst<opName, "SV">;
493 def _SADDR : FLAT_Scratch_Load_LDS_Pseudo<opName, 1>,
494 FlatScratchInst<opName, "SS">;
495 def _SVS : FLAT_Scratch_Load_LDS_Pseudo<opName, 1, 1>,
496 FlatScratchInst<opName, "SVS">;
497 def _ST : FLAT_Scratch_Load_LDS_Pseudo<opName, 0, 0, 0>,
498 FlatScratchInst<opName, "ST">;
501 class FLAT_AtomicNoRet_Pseudo<string opName, dag outs, dag ins,
502 string asm, list<dag> pattern = []> :
503 FLAT_Pseudo<opName, outs, ins, asm, pattern> {
511 let IsAtomicNoRet = 1;
514 class FLAT_AtomicRet_Pseudo<string opName, dag outs, dag ins,
515 string asm, list<dag> pattern = []>
516 : FLAT_AtomicNoRet_Pseudo<opName, outs, ins, asm, pattern> {
517 let hasPostISelHook = 1;
521 let IsAtomicNoRet = 0;
525 multiclass FLAT_Atomic_Pseudo_NO_RTN<
527 RegisterClass vdst_rc,
529 ValueType data_vt = vt,
530 RegisterClass data_rc = vdst_rc,
531 RegisterOperand data_op = getLdStRegisterOperand<data_rc>.ret> {
532 def "" : FLAT_AtomicNoRet_Pseudo <opName,
534 (ins VReg_64:$vaddr, data_op:$vdata, flat_offset:$offset, CPol_0:$cpol),
535 " $vaddr, $vdata$offset$cpol">,
536 GlobalSaddrTable<0, opName> {
537 let FPAtomic = data_vt.isFP;
538 let AddedComplexity = -1; // Prefer global atomics if available
542 multiclass FLAT_Atomic_Pseudo_RTN<
544 RegisterClass vdst_rc,
546 ValueType data_vt = vt,
547 RegisterClass data_rc = vdst_rc,
548 RegisterOperand data_op = getLdStRegisterOperand<data_rc>.ret> {
549 def _RTN : FLAT_AtomicRet_Pseudo <opName,
550 (outs getLdStRegisterOperand<vdst_rc>.ret:$vdst),
551 (ins VReg_64:$vaddr, data_op:$vdata, flat_offset:$offset, CPol_GLC1:$cpol),
552 " $vdst, $vaddr, $vdata$offset$cpol">,
553 GlobalSaddrTable<0, opName#"_rtn"> {
554 let FPAtomic = data_vt.isFP;
555 let AddedComplexity = -1; // Prefer global atomics if available
559 multiclass FLAT_Atomic_Pseudo<
561 RegisterClass vdst_rc,
563 ValueType data_vt = vt,
564 RegisterClass data_rc = vdst_rc,
565 RegisterOperand data_op = getLdStRegisterOperand<data_rc>.ret> {
566 defm "" : FLAT_Atomic_Pseudo_NO_RTN<opName, vdst_rc, vt, data_vt, data_rc, data_op>;
567 defm "" : FLAT_Atomic_Pseudo_RTN<opName, vdst_rc, vt, data_vt, data_rc, data_op>;
570 multiclass FLAT_Global_Atomic_Pseudo_NO_RTN<
572 RegisterClass vdst_rc,
574 ValueType data_vt = vt,
575 RegisterClass data_rc = vdst_rc,
576 RegisterOperand data_op = getLdStRegisterOperand<data_rc>.ret> {
578 let is_flat_global = 1 in {
579 def "" : FLAT_AtomicNoRet_Pseudo <opName,
581 (ins VReg_64:$vaddr, data_op:$vdata, flat_offset:$offset, CPol_0:$cpol),
582 " $vaddr, $vdata, off$offset$cpol">,
583 GlobalSaddrTable<0, opName> {
585 let FPAtomic = data_vt.isFP;
588 def _SADDR : FLAT_AtomicNoRet_Pseudo <opName,
590 (ins VGPR_32:$vaddr, data_op:$vdata, SReg_64:$saddr, flat_offset:$offset, CPol_0:$cpol),
591 " $vaddr, $vdata, $saddr$offset$cpol">,
592 GlobalSaddrTable<1, opName> {
594 let enabled_saddr = 1;
595 let FPAtomic = data_vt.isFP;
600 multiclass FLAT_Global_Atomic_Pseudo_RTN<
602 RegisterClass vdst_rc,
604 ValueType data_vt = vt,
605 RegisterClass data_rc = vdst_rc,
606 RegisterOperand data_op = getLdStRegisterOperand<data_rc>.ret,
607 RegisterOperand vdst_op = getLdStRegisterOperand<vdst_rc>.ret> {
609 let is_flat_global = 1 in {
610 def _RTN : FLAT_AtomicRet_Pseudo <opName,
611 (outs vdst_op:$vdst),
612 (ins VReg_64:$vaddr, data_op:$vdata, flat_offset:$offset, CPol_GLC1:$cpol),
613 " $vdst, $vaddr, $vdata, off$offset$cpol">,
614 GlobalSaddrTable<0, opName#"_rtn"> {
616 let FPAtomic = data_vt.isFP;
619 def _SADDR_RTN : FLAT_AtomicRet_Pseudo <opName,
620 (outs vdst_op:$vdst),
621 (ins VGPR_32:$vaddr, data_op:$vdata, SReg_64:$saddr, flat_offset:$offset, CPol_GLC1:$cpol),
622 " $vdst, $vaddr, $vdata, $saddr$offset$cpol">,
623 GlobalSaddrTable<1, opName#"_rtn"> {
625 let enabled_saddr = 1;
626 let FPAtomic = data_vt.isFP;
631 multiclass FLAT_Global_Atomic_Pseudo<
633 RegisterClass vdst_rc,
635 ValueType data_vt = vt,
636 RegisterClass data_rc = vdst_rc> {
637 defm "" : FLAT_Global_Atomic_Pseudo_NO_RTN<opName, vdst_rc, vt, data_vt, data_rc>;
638 defm "" : FLAT_Global_Atomic_Pseudo_RTN<opName, vdst_rc, vt, data_vt, data_rc>;
641 //===----------------------------------------------------------------------===//
643 //===----------------------------------------------------------------------===//
645 def FLAT_LOAD_UBYTE : FLAT_Load_Pseudo <"flat_load_ubyte", VGPR_32>;
646 def FLAT_LOAD_SBYTE : FLAT_Load_Pseudo <"flat_load_sbyte", VGPR_32>;
647 def FLAT_LOAD_USHORT : FLAT_Load_Pseudo <"flat_load_ushort", VGPR_32>;
648 def FLAT_LOAD_SSHORT : FLAT_Load_Pseudo <"flat_load_sshort", VGPR_32>;
649 def FLAT_LOAD_DWORD : FLAT_Load_Pseudo <"flat_load_dword", VGPR_32>;
650 def FLAT_LOAD_DWORDX2 : FLAT_Load_Pseudo <"flat_load_dwordx2", VReg_64>;
651 def FLAT_LOAD_DWORDX4 : FLAT_Load_Pseudo <"flat_load_dwordx4", VReg_128>;
652 def FLAT_LOAD_DWORDX3 : FLAT_Load_Pseudo <"flat_load_dwordx3", VReg_96>;
654 def FLAT_STORE_BYTE : FLAT_Store_Pseudo <"flat_store_byte", VGPR_32>;
655 def FLAT_STORE_SHORT : FLAT_Store_Pseudo <"flat_store_short", VGPR_32>;
656 def FLAT_STORE_DWORD : FLAT_Store_Pseudo <"flat_store_dword", VGPR_32>;
657 def FLAT_STORE_DWORDX2 : FLAT_Store_Pseudo <"flat_store_dwordx2", VReg_64>;
658 def FLAT_STORE_DWORDX4 : FLAT_Store_Pseudo <"flat_store_dwordx4", VReg_128>;
659 def FLAT_STORE_DWORDX3 : FLAT_Store_Pseudo <"flat_store_dwordx3", VReg_96>;
661 let SubtargetPredicate = HasD16LoadStore in {
662 let TiedSourceNotRead = 1 in {
663 def FLAT_LOAD_UBYTE_D16 : FLAT_Load_Pseudo <"flat_load_ubyte_d16", VGPR_32, 1>;
664 def FLAT_LOAD_UBYTE_D16_HI : FLAT_Load_Pseudo <"flat_load_ubyte_d16_hi", VGPR_32, 1>;
665 def FLAT_LOAD_SBYTE_D16 : FLAT_Load_Pseudo <"flat_load_sbyte_d16", VGPR_32, 1>;
666 def FLAT_LOAD_SBYTE_D16_HI : FLAT_Load_Pseudo <"flat_load_sbyte_d16_hi", VGPR_32, 1>;
667 def FLAT_LOAD_SHORT_D16 : FLAT_Load_Pseudo <"flat_load_short_d16", VGPR_32, 1>;
668 def FLAT_LOAD_SHORT_D16_HI : FLAT_Load_Pseudo <"flat_load_short_d16_hi", VGPR_32, 1>;
671 def FLAT_STORE_BYTE_D16_HI : FLAT_Store_Pseudo <"flat_store_byte_d16_hi", VGPR_32>;
672 def FLAT_STORE_SHORT_D16_HI : FLAT_Store_Pseudo <"flat_store_short_d16_hi", VGPR_32>;
675 defm FLAT_ATOMIC_CMPSWAP : FLAT_Atomic_Pseudo <"flat_atomic_cmpswap",
676 VGPR_32, i32, v2i32, VReg_64>;
678 defm FLAT_ATOMIC_CMPSWAP_X2 : FLAT_Atomic_Pseudo <"flat_atomic_cmpswap_x2",
679 VReg_64, i64, v2i64, VReg_128>;
681 defm FLAT_ATOMIC_SWAP : FLAT_Atomic_Pseudo <"flat_atomic_swap",
684 defm FLAT_ATOMIC_SWAP_X2 : FLAT_Atomic_Pseudo <"flat_atomic_swap_x2",
687 defm FLAT_ATOMIC_ADD : FLAT_Atomic_Pseudo <"flat_atomic_add",
690 defm FLAT_ATOMIC_SUB : FLAT_Atomic_Pseudo <"flat_atomic_sub",
693 defm FLAT_ATOMIC_SMIN : FLAT_Atomic_Pseudo <"flat_atomic_smin",
696 defm FLAT_ATOMIC_UMIN : FLAT_Atomic_Pseudo <"flat_atomic_umin",
699 defm FLAT_ATOMIC_SMAX : FLAT_Atomic_Pseudo <"flat_atomic_smax",
702 defm FLAT_ATOMIC_UMAX : FLAT_Atomic_Pseudo <"flat_atomic_umax",
705 defm FLAT_ATOMIC_AND : FLAT_Atomic_Pseudo <"flat_atomic_and",
708 defm FLAT_ATOMIC_OR : FLAT_Atomic_Pseudo <"flat_atomic_or",
711 defm FLAT_ATOMIC_XOR : FLAT_Atomic_Pseudo <"flat_atomic_xor",
714 defm FLAT_ATOMIC_INC : FLAT_Atomic_Pseudo <"flat_atomic_inc",
717 defm FLAT_ATOMIC_DEC : FLAT_Atomic_Pseudo <"flat_atomic_dec",
720 defm FLAT_ATOMIC_ADD_X2 : FLAT_Atomic_Pseudo <"flat_atomic_add_x2",
723 defm FLAT_ATOMIC_SUB_X2 : FLAT_Atomic_Pseudo <"flat_atomic_sub_x2",
726 defm FLAT_ATOMIC_SMIN_X2 : FLAT_Atomic_Pseudo <"flat_atomic_smin_x2",
729 defm FLAT_ATOMIC_UMIN_X2 : FLAT_Atomic_Pseudo <"flat_atomic_umin_x2",
732 defm FLAT_ATOMIC_SMAX_X2 : FLAT_Atomic_Pseudo <"flat_atomic_smax_x2",
735 defm FLAT_ATOMIC_UMAX_X2 : FLAT_Atomic_Pseudo <"flat_atomic_umax_x2",
738 defm FLAT_ATOMIC_AND_X2 : FLAT_Atomic_Pseudo <"flat_atomic_and_x2",
741 defm FLAT_ATOMIC_OR_X2 : FLAT_Atomic_Pseudo <"flat_atomic_or_x2",
744 defm FLAT_ATOMIC_XOR_X2 : FLAT_Atomic_Pseudo <"flat_atomic_xor_x2",
747 defm FLAT_ATOMIC_INC_X2 : FLAT_Atomic_Pseudo <"flat_atomic_inc_x2",
750 defm FLAT_ATOMIC_DEC_X2 : FLAT_Atomic_Pseudo <"flat_atomic_dec_x2",
753 // GFX7-, GFX10-only flat instructions.
754 let SubtargetPredicate = isGFX7GFX10 in {
755 defm FLAT_ATOMIC_FCMPSWAP_X2 : FLAT_Atomic_Pseudo <"flat_atomic_fcmpswap_x2",
756 VReg_64, f64, v2f64, VReg_128>;
757 } // End SubtargetPredicate = isGFX7GFX10
760 // The names may be flat_atomic_fmin_x2 on some subtargets, but we
761 // choose this as the canonical name.
762 let SubtargetPredicate = HasAtomicFMinFMaxF64FlatInsts in {
763 defm FLAT_ATOMIC_MIN_F64 : FLAT_Atomic_Pseudo <"flat_atomic_min_f64",
766 defm FLAT_ATOMIC_MAX_F64 : FLAT_Atomic_Pseudo <"flat_atomic_max_f64",
770 let SubtargetPredicate = HasAtomicFMinFMaxF64GlobalInsts in {
771 defm GLOBAL_ATOMIC_MIN_F64 : FLAT_Global_Atomic_Pseudo<"global_atomic_min_f64", VReg_64, f64>;
772 defm GLOBAL_ATOMIC_MAX_F64 : FLAT_Global_Atomic_Pseudo<"global_atomic_max_f64", VReg_64, f64>;
775 let SubtargetPredicate = HasFlatBufferGlobalAtomicFaddF64Inst in {
776 defm FLAT_ATOMIC_ADD_F64 : FLAT_Atomic_Pseudo<"flat_atomic_add_f64", VReg_64, f64>;
777 defm GLOBAL_ATOMIC_ADD_F64 : FLAT_Global_Atomic_Pseudo<"global_atomic_add_f64", VReg_64, f64>;
778 } // End SubtargetPredicate = HasFlatBufferGlobalAtomicFaddF64Inst
780 let SubtargetPredicate = HasAtomicFlatPkAdd16Insts in {
781 defm FLAT_ATOMIC_PK_ADD_F16 : FLAT_Atomic_Pseudo<"flat_atomic_pk_add_f16", VGPR_32, v2f16>;
783 defm FLAT_ATOMIC_PK_ADD_BF16 : FLAT_Atomic_Pseudo<"flat_atomic_pk_add_bf16", VGPR_32, v2i16>;
784 } // End SubtargetPredicate = HasAtomicFlatPkAdd16Insts
786 let SubtargetPredicate = HasAtomicGlobalPkAddBF16Inst, FPAtomic = 1 in
787 defm GLOBAL_ATOMIC_PK_ADD_BF16 : FLAT_Global_Atomic_Pseudo<"global_atomic_pk_add_bf16", VGPR_32, v2i16>;
789 // GFX7-, GFX10-, GFX11-only flat instructions.
790 let SubtargetPredicate = isGFX7GFX10GFX11 in {
792 defm FLAT_ATOMIC_FCMPSWAP : FLAT_Atomic_Pseudo <"flat_atomic_fcmpswap",
793 VGPR_32, f32, v2f32, VReg_64>;
795 defm FLAT_ATOMIC_FMIN : FLAT_Atomic_Pseudo <"flat_atomic_fmin",
798 defm FLAT_ATOMIC_FMAX : FLAT_Atomic_Pseudo <"flat_atomic_fmax",
801 } // End SubtargetPredicate = isGFX7GFX10GFX11
803 // GFX940-, GFX11-only flat instructions.
804 let SubtargetPredicate = HasFlatAtomicFaddF32Inst in {
805 defm FLAT_ATOMIC_ADD_F32 : FLAT_Atomic_Pseudo<"flat_atomic_add_f32", VGPR_32, f32>;
806 } // End SubtargetPredicate = HasFlatAtomicFaddF32Inst
808 let SubtargetPredicate = isGFX12Plus in {
809 defm FLAT_ATOMIC_CSUB_U32 : FLAT_Atomic_Pseudo <"flat_atomic_csub_u32", VGPR_32, i32>;
810 defm FLAT_ATOMIC_COND_SUB_U32 : FLAT_Atomic_Pseudo <"flat_atomic_cond_sub_u32", VGPR_32, i32>;
811 } // End SubtargetPredicate = isGFX12Plus
813 defm GLOBAL_LOAD_UBYTE : FLAT_Global_Load_Pseudo <"global_load_ubyte", VGPR_32>;
814 defm GLOBAL_LOAD_SBYTE : FLAT_Global_Load_Pseudo <"global_load_sbyte", VGPR_32>;
815 defm GLOBAL_LOAD_USHORT : FLAT_Global_Load_Pseudo <"global_load_ushort", VGPR_32>;
816 defm GLOBAL_LOAD_SSHORT : FLAT_Global_Load_Pseudo <"global_load_sshort", VGPR_32>;
817 defm GLOBAL_LOAD_DWORD : FLAT_Global_Load_Pseudo <"global_load_dword", VGPR_32>;
818 defm GLOBAL_LOAD_DWORDX2 : FLAT_Global_Load_Pseudo <"global_load_dwordx2", VReg_64>;
819 defm GLOBAL_LOAD_DWORDX3 : FLAT_Global_Load_Pseudo <"global_load_dwordx3", VReg_96>;
820 defm GLOBAL_LOAD_DWORDX4 : FLAT_Global_Load_Pseudo <"global_load_dwordx4", VReg_128>;
822 let TiedSourceNotRead = 1 in {
823 defm GLOBAL_LOAD_UBYTE_D16 : FLAT_Global_Load_Pseudo <"global_load_ubyte_d16", VGPR_32, 1>;
824 defm GLOBAL_LOAD_UBYTE_D16_HI : FLAT_Global_Load_Pseudo <"global_load_ubyte_d16_hi", VGPR_32, 1>;
825 defm GLOBAL_LOAD_SBYTE_D16 : FLAT_Global_Load_Pseudo <"global_load_sbyte_d16", VGPR_32, 1>;
826 defm GLOBAL_LOAD_SBYTE_D16_HI : FLAT_Global_Load_Pseudo <"global_load_sbyte_d16_hi", VGPR_32, 1>;
827 defm GLOBAL_LOAD_SHORT_D16 : FLAT_Global_Load_Pseudo <"global_load_short_d16", VGPR_32, 1>;
828 defm GLOBAL_LOAD_SHORT_D16_HI : FLAT_Global_Load_Pseudo <"global_load_short_d16_hi", VGPR_32, 1>;
831 let OtherPredicates = [HasGFX10_BEncoding] in
832 defm GLOBAL_LOAD_DWORD_ADDTID : FLAT_Global_Load_AddTid_Pseudo <"global_load_dword_addtid", VGPR_32>;
834 defm GLOBAL_STORE_BYTE : FLAT_Global_Store_Pseudo <"global_store_byte", VGPR_32>;
835 defm GLOBAL_STORE_SHORT : FLAT_Global_Store_Pseudo <"global_store_short", VGPR_32>;
836 defm GLOBAL_STORE_DWORD : FLAT_Global_Store_Pseudo <"global_store_dword", VGPR_32>;
837 defm GLOBAL_STORE_DWORDX2 : FLAT_Global_Store_Pseudo <"global_store_dwordx2", VReg_64>;
838 defm GLOBAL_STORE_DWORDX3 : FLAT_Global_Store_Pseudo <"global_store_dwordx3", VReg_96>;
839 defm GLOBAL_STORE_DWORDX4 : FLAT_Global_Store_Pseudo <"global_store_dwordx4", VReg_128>;
840 let OtherPredicates = [HasGFX10_BEncoding] in
841 defm GLOBAL_STORE_DWORD_ADDTID : FLAT_Global_Store_AddTid_Pseudo <"global_store_dword_addtid", VGPR_32>;
843 defm GLOBAL_STORE_BYTE_D16_HI : FLAT_Global_Store_Pseudo <"global_store_byte_d16_hi", VGPR_32>;
844 defm GLOBAL_STORE_SHORT_D16_HI : FLAT_Global_Store_Pseudo <"global_store_short_d16_hi", VGPR_32>;
846 defm GLOBAL_ATOMIC_CMPSWAP : FLAT_Global_Atomic_Pseudo <"global_atomic_cmpswap",
847 VGPR_32, i32, v2i32, VReg_64>;
849 defm GLOBAL_ATOMIC_CMPSWAP_X2 : FLAT_Global_Atomic_Pseudo <"global_atomic_cmpswap_x2",
850 VReg_64, i64, v2i64, VReg_128>;
852 defm GLOBAL_ATOMIC_SWAP : FLAT_Global_Atomic_Pseudo <"global_atomic_swap",
855 defm GLOBAL_ATOMIC_SWAP_X2 : FLAT_Global_Atomic_Pseudo <"global_atomic_swap_x2",
858 defm GLOBAL_ATOMIC_ADD : FLAT_Global_Atomic_Pseudo <"global_atomic_add",
861 defm GLOBAL_ATOMIC_SUB : FLAT_Global_Atomic_Pseudo <"global_atomic_sub",
864 defm GLOBAL_ATOMIC_SMIN : FLAT_Global_Atomic_Pseudo <"global_atomic_smin",
867 defm GLOBAL_ATOMIC_UMIN : FLAT_Global_Atomic_Pseudo <"global_atomic_umin",
870 defm GLOBAL_ATOMIC_SMAX : FLAT_Global_Atomic_Pseudo <"global_atomic_smax",
873 defm GLOBAL_ATOMIC_UMAX : FLAT_Global_Atomic_Pseudo <"global_atomic_umax",
876 defm GLOBAL_ATOMIC_AND : FLAT_Global_Atomic_Pseudo <"global_atomic_and",
879 defm GLOBAL_ATOMIC_OR : FLAT_Global_Atomic_Pseudo <"global_atomic_or",
882 defm GLOBAL_ATOMIC_XOR : FLAT_Global_Atomic_Pseudo <"global_atomic_xor",
885 defm GLOBAL_ATOMIC_INC : FLAT_Global_Atomic_Pseudo <"global_atomic_inc",
888 defm GLOBAL_ATOMIC_DEC : FLAT_Global_Atomic_Pseudo <"global_atomic_dec",
891 defm GLOBAL_ATOMIC_ADD_X2 : FLAT_Global_Atomic_Pseudo <"global_atomic_add_x2",
894 defm GLOBAL_ATOMIC_SUB_X2 : FLAT_Global_Atomic_Pseudo <"global_atomic_sub_x2",
897 defm GLOBAL_ATOMIC_SMIN_X2 : FLAT_Global_Atomic_Pseudo <"global_atomic_smin_x2",
900 defm GLOBAL_ATOMIC_UMIN_X2 : FLAT_Global_Atomic_Pseudo <"global_atomic_umin_x2",
903 defm GLOBAL_ATOMIC_SMAX_X2 : FLAT_Global_Atomic_Pseudo <"global_atomic_smax_x2",
906 defm GLOBAL_ATOMIC_UMAX_X2 : FLAT_Global_Atomic_Pseudo <"global_atomic_umax_x2",
909 defm GLOBAL_ATOMIC_AND_X2 : FLAT_Global_Atomic_Pseudo <"global_atomic_and_x2",
912 defm GLOBAL_ATOMIC_OR_X2 : FLAT_Global_Atomic_Pseudo <"global_atomic_or_x2",
915 defm GLOBAL_ATOMIC_XOR_X2 : FLAT_Global_Atomic_Pseudo <"global_atomic_xor_x2",
918 defm GLOBAL_ATOMIC_INC_X2 : FLAT_Global_Atomic_Pseudo <"global_atomic_inc_x2",
921 defm GLOBAL_ATOMIC_DEC_X2 : FLAT_Global_Atomic_Pseudo <"global_atomic_dec_x2",
924 let SubtargetPredicate = HasGFX10_BEncoding in {
925 defm GLOBAL_ATOMIC_CSUB : FLAT_Global_Atomic_Pseudo <"global_atomic_csub",
929 defm GLOBAL_LOAD_LDS_UBYTE : FLAT_Global_Load_LDS_Pseudo <"global_load_lds_ubyte">;
930 defm GLOBAL_LOAD_LDS_SBYTE : FLAT_Global_Load_LDS_Pseudo <"global_load_lds_sbyte">;
931 defm GLOBAL_LOAD_LDS_USHORT : FLAT_Global_Load_LDS_Pseudo <"global_load_lds_ushort">;
932 defm GLOBAL_LOAD_LDS_SSHORT : FLAT_Global_Load_LDS_Pseudo <"global_load_lds_sshort">;
933 defm GLOBAL_LOAD_LDS_DWORD : FLAT_Global_Load_LDS_Pseudo <"global_load_lds_dword">;
935 let SubtargetPredicate = isGFX12Plus in {
936 defm GLOBAL_ATOMIC_COND_SUB_U32 : FLAT_Global_Atomic_Pseudo <"global_atomic_cond_sub_u32", VGPR_32, i32>;
937 defm GLOBAL_ATOMIC_ORDERED_ADD_B64 : FLAT_Global_Atomic_Pseudo <"global_atomic_ordered_add_b64", VReg_64, i64>;
939 def GLOBAL_INV : FLAT_Global_Invalidate_Writeback<"global_inv">;
940 def GLOBAL_WB : FLAT_Global_Invalidate_Writeback<"global_wb">;
941 def GLOBAL_WBINV : FLAT_Global_Invalidate_Writeback<"global_wbinv">;
942 } // End SubtargetPredicate = isGFX12Plus
944 defm SCRATCH_LOAD_UBYTE : FLAT_Scratch_Load_Pseudo <"scratch_load_ubyte", VGPR_32>;
945 defm SCRATCH_LOAD_SBYTE : FLAT_Scratch_Load_Pseudo <"scratch_load_sbyte", VGPR_32>;
946 defm SCRATCH_LOAD_USHORT : FLAT_Scratch_Load_Pseudo <"scratch_load_ushort", VGPR_32>;
947 defm SCRATCH_LOAD_SSHORT : FLAT_Scratch_Load_Pseudo <"scratch_load_sshort", VGPR_32>;
948 defm SCRATCH_LOAD_DWORD : FLAT_Scratch_Load_Pseudo <"scratch_load_dword", VGPR_32>;
949 defm SCRATCH_LOAD_DWORDX2 : FLAT_Scratch_Load_Pseudo <"scratch_load_dwordx2", VReg_64>;
950 defm SCRATCH_LOAD_DWORDX3 : FLAT_Scratch_Load_Pseudo <"scratch_load_dwordx3", VReg_96>;
951 defm SCRATCH_LOAD_DWORDX4 : FLAT_Scratch_Load_Pseudo <"scratch_load_dwordx4", VReg_128>;
953 let TiedSourceNotRead = 1 in {
954 defm SCRATCH_LOAD_UBYTE_D16 : FLAT_Scratch_Load_Pseudo <"scratch_load_ubyte_d16", VGPR_32, 1>;
955 defm SCRATCH_LOAD_UBYTE_D16_HI : FLAT_Scratch_Load_Pseudo <"scratch_load_ubyte_d16_hi", VGPR_32, 1>;
956 defm SCRATCH_LOAD_SBYTE_D16 : FLAT_Scratch_Load_Pseudo <"scratch_load_sbyte_d16", VGPR_32, 1>;
957 defm SCRATCH_LOAD_SBYTE_D16_HI : FLAT_Scratch_Load_Pseudo <"scratch_load_sbyte_d16_hi", VGPR_32, 1>;
958 defm SCRATCH_LOAD_SHORT_D16 : FLAT_Scratch_Load_Pseudo <"scratch_load_short_d16", VGPR_32, 1>;
959 defm SCRATCH_LOAD_SHORT_D16_HI : FLAT_Scratch_Load_Pseudo <"scratch_load_short_d16_hi", VGPR_32, 1>;
962 defm SCRATCH_STORE_BYTE : FLAT_Scratch_Store_Pseudo <"scratch_store_byte", VGPR_32>;
963 defm SCRATCH_STORE_SHORT : FLAT_Scratch_Store_Pseudo <"scratch_store_short", VGPR_32>;
964 defm SCRATCH_STORE_DWORD : FLAT_Scratch_Store_Pseudo <"scratch_store_dword", VGPR_32>;
965 defm SCRATCH_STORE_DWORDX2 : FLAT_Scratch_Store_Pseudo <"scratch_store_dwordx2", VReg_64>;
966 defm SCRATCH_STORE_DWORDX3 : FLAT_Scratch_Store_Pseudo <"scratch_store_dwordx3", VReg_96>;
967 defm SCRATCH_STORE_DWORDX4 : FLAT_Scratch_Store_Pseudo <"scratch_store_dwordx4", VReg_128>;
969 defm SCRATCH_STORE_BYTE_D16_HI : FLAT_Scratch_Store_Pseudo <"scratch_store_byte_d16_hi", VGPR_32>;
970 defm SCRATCH_STORE_SHORT_D16_HI : FLAT_Scratch_Store_Pseudo <"scratch_store_short_d16_hi", VGPR_32>;
972 defm SCRATCH_LOAD_LDS_UBYTE : FLAT_Scratch_Load_LDS_Pseudo <"scratch_load_lds_ubyte">;
973 defm SCRATCH_LOAD_LDS_SBYTE : FLAT_Scratch_Load_LDS_Pseudo <"scratch_load_lds_sbyte">;
974 defm SCRATCH_LOAD_LDS_USHORT : FLAT_Scratch_Load_LDS_Pseudo <"scratch_load_lds_ushort">;
975 defm SCRATCH_LOAD_LDS_SSHORT : FLAT_Scratch_Load_LDS_Pseudo <"scratch_load_lds_sshort">;
976 defm SCRATCH_LOAD_LDS_DWORD : FLAT_Scratch_Load_LDS_Pseudo <"scratch_load_lds_dword">;
978 let SubtargetPredicate = isGFX12Plus in {
979 let Uses = [EXEC, M0] in {
980 defm GLOBAL_LOAD_BLOCK : FLAT_Global_Load_Pseudo <"global_load_block", VReg_1024>;
981 defm GLOBAL_STORE_BLOCK : FLAT_Global_Store_Pseudo <"global_store_block", VReg_1024>;
983 let Uses = [EXEC, FLAT_SCR, M0] in {
984 defm SCRATCH_LOAD_BLOCK : FLAT_Scratch_Load_Pseudo <"scratch_load_block", VReg_1024>;
985 defm SCRATCH_STORE_BLOCK : FLAT_Scratch_Store_Pseudo <"scratch_store_block", VReg_1024>;
988 let WaveSizePredicate = isWave32 in {
989 let Mnemonic = "global_load_tr_b128" in
990 defm GLOBAL_LOAD_TR_B128_w32 : FLAT_Global_Load_Pseudo <"global_load_tr_b128_w32", VReg_128>;
991 let Mnemonic = "global_load_tr_b64" in
992 defm GLOBAL_LOAD_TR_B64_w32 : FLAT_Global_Load_Pseudo <"global_load_tr_b64_w32", VReg_64>;
994 let WaveSizePredicate = isWave64 in {
995 let Mnemonic = "global_load_tr_b128" in
996 defm GLOBAL_LOAD_TR_B128_w64 : FLAT_Global_Load_Pseudo <"global_load_tr_b128_w64", VReg_64>;
997 let Mnemonic = "global_load_tr_b64" in
998 defm GLOBAL_LOAD_TR_B64_w64 : FLAT_Global_Load_Pseudo <"global_load_tr_b64_w64", VGPR_32>;
1000 } // End SubtargetPredicate = isGFX12Plus
1002 let SubtargetPredicate = isGFX10Plus in {
1003 defm GLOBAL_ATOMIC_FCMPSWAP :
1004 FLAT_Global_Atomic_Pseudo<"global_atomic_fcmpswap", VGPR_32, f32, v2f32, VReg_64>;
1005 defm GLOBAL_ATOMIC_FMIN :
1006 FLAT_Global_Atomic_Pseudo<"global_atomic_fmin", VGPR_32, f32>;
1007 defm GLOBAL_ATOMIC_FMAX :
1008 FLAT_Global_Atomic_Pseudo<"global_atomic_fmax", VGPR_32, f32>;
1009 defm GLOBAL_ATOMIC_FCMPSWAP_X2 :
1010 FLAT_Global_Atomic_Pseudo<"global_atomic_fcmpswap_x2", VReg_64, f64, v2f64, VReg_128>;
1011 } // End SubtargetPredicate = isGFX10Plus
1013 let OtherPredicates = [HasAtomicFaddNoRtnInsts] in
1014 defm GLOBAL_ATOMIC_ADD_F32 : FLAT_Global_Atomic_Pseudo_NO_RTN <
1015 "global_atomic_add_f32", VGPR_32, f32
1017 let OtherPredicates = [HasAtomicBufferGlobalPkAddF16NoRtnInsts] in
1018 defm GLOBAL_ATOMIC_PK_ADD_F16 : FLAT_Global_Atomic_Pseudo_NO_RTN <
1019 "global_atomic_pk_add_f16", VGPR_32, v2f16
1021 let OtherPredicates = [HasAtomicFaddRtnInsts] in
1022 defm GLOBAL_ATOMIC_ADD_F32 : FLAT_Global_Atomic_Pseudo_RTN <
1023 "global_atomic_add_f32", VGPR_32, f32
1025 let OtherPredicates = [HasAtomicBufferGlobalPkAddF16Insts] in
1026 defm GLOBAL_ATOMIC_PK_ADD_F16 : FLAT_Global_Atomic_Pseudo_RTN <
1027 "global_atomic_pk_add_f16", VGPR_32, v2f16
1030 //===----------------------------------------------------------------------===//
1032 //===----------------------------------------------------------------------===//
1034 // Patterns for global loads with no offset.
1035 class FlatLoadPat <FLAT_Pseudo inst, SDPatternOperator node, ValueType vt> : GCNPat <
1036 (vt (node (FlatOffset i64:$vaddr, i32:$offset))),
1037 (inst $vaddr, $offset)
1040 class FlatLoadPat_D16 <FLAT_Pseudo inst, SDPatternOperator node, ValueType vt> : GCNPat <
1041 (node (FlatOffset (i64 VReg_64:$vaddr), i32:$offset), vt:$in),
1042 (inst $vaddr, $offset, 0, $in)
1045 class FlatSignedLoadPat_D16 <FLAT_Pseudo inst, SDPatternOperator node, ValueType vt> : GCNPat <
1046 (node (GlobalOffset (i64 VReg_64:$vaddr), i32:$offset), vt:$in),
1047 (inst $vaddr, $offset, 0, $in)
1050 class GlobalLoadSaddrPat_D16 <FLAT_Pseudo inst, SDPatternOperator node, ValueType vt> : GCNPat <
1051 (vt (node (GlobalSAddr (i64 SReg_64:$saddr), (i32 VGPR_32:$voffset), i32:$offset), vt:$in)),
1052 (inst $saddr, $voffset, $offset, 0, $in)
1055 class FlatLoadSignedPat <FLAT_Pseudo inst, SDPatternOperator node, ValueType vt> : GCNPat <
1056 (vt (node (GlobalOffset (i64 VReg_64:$vaddr), i32:$offset))),
1057 (inst $vaddr, $offset)
1060 class GlobalLoadSaddrPat <FLAT_Pseudo inst, SDPatternOperator node, ValueType vt> : GCNPat <
1061 (vt (node (GlobalSAddr (i64 SReg_64:$saddr), (i32 VGPR_32:$voffset), i32:$offset))),
1062 (inst $saddr, $voffset, $offset, 0)
1065 class GlobalStoreSaddrPat <FLAT_Pseudo inst, SDPatternOperator node,
1066 ValueType vt> : GCNPat <
1067 (node vt:$data, (GlobalSAddr (i64 SReg_64:$saddr), (i32 VGPR_32:$voffset), i32:$offset)),
1068 (inst $voffset, getVregSrcForVT<vt>.ret:$data, $saddr, $offset)
1071 class GlobalAtomicSaddrPat <FLAT_Pseudo inst, SDPatternOperator node,
1072 ValueType vt, ValueType data_vt = vt> : GCNPat <
1073 (vt (node (GlobalSAddr (i64 SReg_64:$saddr), (i32 VGPR_32:$voffset), i32:$offset), data_vt:$data)),
1074 (inst $voffset, getVregSrcForVT<data_vt>.ret:$data, $saddr, $offset)
1077 class GlobalAtomicNoRtnSaddrPat <FLAT_Pseudo inst, SDPatternOperator node,
1078 ValueType vt> : GCNPat <
1079 (node (GlobalSAddr (i64 SReg_64:$saddr), (i32 VGPR_32:$voffset), i32:$offset), vt:$data),
1080 (inst $voffset, getVregSrcForVT<vt>.ret:$data, $saddr, $offset)
1083 class FlatStorePat <FLAT_Pseudo inst, SDPatternOperator node, ValueType vt> : GCNPat <
1084 (node vt:$data, (FlatOffset i64:$vaddr, i32:$offset)),
1085 (inst $vaddr, getVregSrcForVT<vt>.ret:$data, $offset)
1088 class FlatStoreSignedPat <FLAT_Pseudo inst, SDPatternOperator node, ValueType vt> : GCNPat <
1089 (node vt:$data, (GlobalOffset i64:$vaddr, i32:$offset)),
1090 (inst $vaddr, getVregSrcForVT<vt>.ret:$data, $offset)
1093 class FlatStoreSignedAtomicPat <FLAT_Pseudo inst, SDPatternOperator node,
1094 ValueType vt, ValueType data_vt = vt> : GCNPat <
1095 // atomic store follows atomic binop convention so the address comes
1097 (node (GlobalOffset i64:$vaddr, i32:$offset), data_vt:$data),
1098 (inst $vaddr, getVregSrcForVT<data_vt>.ret:$data, $offset)
1101 multiclass FlatAtomicNoRtnPatBase <string inst, string node, ValueType vt,
1102 ValueType data_vt = vt> {
1104 defvar noRtnNode = !cast<PatFrags>(node);
1106 let AddedComplexity = 1 in
1107 def : GCNPat <(vt (noRtnNode (FlatOffset i64:$vaddr, i32:$offset), data_vt:$data)),
1108 (!cast<FLAT_Pseudo>(inst) VReg_64:$vaddr, getVregSrcForVT<data_vt>.ret:$data, $offset)>;
1111 multiclass FlatAtomicNoRtnPatWithAddrSpace<string inst, string node, string addrSpaceSuffix,
1113 FlatAtomicNoRtnPatBase<inst, node # "_noret_" # addrSpaceSuffix, vt, vt>;
1115 multiclass FlatAtomicNoRtnPat <string inst, string node, ValueType vt,
1116 ValueType data_vt = vt, bit isIntr = 0> :
1117 FlatAtomicNoRtnPatBase<inst, node # "_noret" # !if(isIntr, "", "_"#vt), vt, data_vt>;
1120 multiclass FlatAtomicRtnPatBase <string inst, string node, ValueType vt,
1121 ValueType data_vt = vt> {
1123 defvar rtnNode = !cast<SDPatternOperator>(node);
1125 def : GCNPat <(vt (rtnNode (FlatOffset i64:$vaddr, i32:$offset), data_vt:$data)),
1126 (!cast<FLAT_Pseudo>(inst#"_RTN") VReg_64:$vaddr, getVregSrcForVT<data_vt>.ret:$data, $offset)>;
1129 multiclass FlatAtomicRtnPatWithAddrSpace<string inst, string intr, string addrSpaceSuffix,
1131 FlatAtomicRtnPatBase<inst, intr # "_" # addrSpaceSuffix, vt, vt>;
1133 multiclass FlatAtomicRtnPat <string inst, string node, ValueType vt,
1134 ValueType data_vt = vt, bit isIntr = 0> :
1135 FlatAtomicRtnPatBase<inst, node # !if(isIntr, "", "_"#vt), vt, data_vt>;
1138 multiclass FlatAtomicPat <string inst, string node, ValueType vt,
1139 ValueType data_vt = vt, bit isIntr = 0> :
1140 FlatAtomicRtnPat<inst, node, vt, data_vt, isIntr>,
1141 FlatAtomicNoRtnPat<inst, node, vt, data_vt, isIntr>;
1143 multiclass FlatAtomicIntrNoRtnPat <string inst, string node, ValueType vt,
1144 ValueType data_vt = vt> {
1145 defm : FlatAtomicNoRtnPat<inst, node, vt, data_vt, /* isIntr */ 1>;
1148 multiclass FlatAtomicIntrRtnPat <string inst, string node, ValueType vt,
1149 ValueType data_vt = vt> {
1150 defm : FlatAtomicRtnPat<inst, node, vt, data_vt, /* isIntr */ 1>;
1153 multiclass FlatAtomicIntrPat <string inst, string node, ValueType vt,
1154 ValueType data_vt = vt> :
1155 FlatAtomicRtnPat<inst, node, vt, data_vt, /* isIntr */ 1>,
1156 FlatAtomicNoRtnPat<inst, node, vt, data_vt, /* isIntr */ 1>;
1158 class FlatSignedAtomicPatBase <FLAT_Pseudo inst, SDPatternOperator node,
1159 ValueType vt, ValueType data_vt = vt> : GCNPat <
1160 (vt (node (GlobalOffset i64:$vaddr, i32:$offset), data_vt:$data)),
1161 (inst VReg_64:$vaddr, getVregSrcForVT<data_vt>.ret:$data, $offset)
1164 multiclass FlatSignedAtomicPat <string inst, string node, ValueType vt,
1165 ValueType data_vt = vt, int complexity = 0,
1167 defvar rtnNode = !cast<SDPatternOperator>(node # !if(isIntr, "", "_" # vt));
1168 defvar noRtnNode = !cast<PatFrags>(node # "_noret" # !if(isIntr, "", "_" # vt));
1170 let AddedComplexity = complexity in
1171 def : FlatSignedAtomicPatBase<!cast<FLAT_Pseudo>(inst#"_RTN"), rtnNode, vt, data_vt>;
1173 let AddedComplexity = !add(complexity, 1) in
1174 def : FlatSignedAtomicPatBase<!cast<FLAT_Pseudo>(inst), noRtnNode, vt, data_vt>;
1177 class ScratchLoadSignedPat <FLAT_Pseudo inst, SDPatternOperator node, ValueType vt> : GCNPat <
1178 (vt (node (ScratchOffset (i32 VGPR_32:$vaddr), i32:$offset))),
1179 (inst $vaddr, $offset)
1182 class ScratchLoadSignedPat_D16 <FLAT_Pseudo inst, SDPatternOperator node, ValueType vt> : GCNPat <
1183 (node (ScratchOffset (i32 VGPR_32:$vaddr), i32:$offset), vt:$in),
1184 (inst $vaddr, $offset, 0, $in)
1187 class ScratchStoreSignedPat <FLAT_Pseudo inst, SDPatternOperator node, ValueType vt> : GCNPat <
1188 (node vt:$data, (ScratchOffset (i32 VGPR_32:$vaddr), i32:$offset)),
1189 (inst getVregSrcForVT<vt>.ret:$data, $vaddr, $offset)
1192 class ScratchLoadSaddrPat <FLAT_Pseudo inst, SDPatternOperator node, ValueType vt> : GCNPat <
1193 (vt (node (ScratchSAddr (i32 SGPR_32:$saddr), i32:$offset))),
1194 (inst $saddr, $offset)
1197 class ScratchLoadSaddrPat_D16 <FLAT_Pseudo inst, SDPatternOperator node, ValueType vt> : GCNPat <
1198 (vt (node (ScratchSAddr (i32 SGPR_32:$saddr), i32:$offset), vt:$in)),
1199 (inst $saddr, $offset, 0, $in)
1202 class ScratchStoreSaddrPat <FLAT_Pseudo inst, SDPatternOperator node,
1203 ValueType vt> : GCNPat <
1204 (node vt:$data, (ScratchSAddr (i32 SGPR_32:$saddr), i32:$offset)),
1205 (inst getVregSrcForVT<vt>.ret:$data, $saddr, $offset)
1208 class ScratchLoadSVaddrPat <FLAT_Pseudo inst, SDPatternOperator node, ValueType vt> : GCNPat <
1209 (vt (node (ScratchSVAddr (i32 VGPR_32:$vaddr), (i32 SGPR_32:$saddr), i32:$offset))),
1210 (inst $vaddr, $saddr, $offset, 0)
1213 class ScratchStoreSVaddrPat <FLAT_Pseudo inst, SDPatternOperator node,
1214 ValueType vt> : GCNPat <
1215 (node vt:$data, (ScratchSVAddr (i32 VGPR_32:$vaddr), (i32 SGPR_32:$saddr), i32:$offset)),
1216 (inst getVregSrcForVT<vt>.ret:$data, $vaddr, $saddr, $offset)
1219 class ScratchLoadSVaddrPat_D16 <FLAT_Pseudo inst, SDPatternOperator node, ValueType vt> : GCNPat <
1220 (vt (node (ScratchSVAddr (i32 VGPR_32:$vaddr), (i32 SGPR_32:$saddr), i32:$offset), vt:$in)),
1221 (inst $vaddr, $saddr, $offset, 0, $in)
1224 multiclass GlobalFLATLoadPats<FLAT_Pseudo inst, SDPatternOperator node, ValueType vt> {
1225 def : FlatLoadSignedPat <inst, node, vt> {
1226 let AddedComplexity = 10;
1229 def : GlobalLoadSaddrPat<!cast<FLAT_Pseudo>(!cast<string>(inst)#"_SADDR"), node, vt> {
1230 let AddedComplexity = 11;
1234 multiclass GlobalFLATLoadPats_D16<FLAT_Pseudo inst, SDPatternOperator node, ValueType vt> {
1235 def : FlatSignedLoadPat_D16 <inst, node, vt> {
1236 let AddedComplexity = 10;
1239 def : GlobalLoadSaddrPat_D16<!cast<FLAT_Pseudo>(!cast<string>(inst)#"_SADDR"), node, vt> {
1240 let AddedComplexity = 11;
1244 multiclass GlobalFLATStorePats<FLAT_Pseudo inst, SDPatternOperator node,
1246 def : FlatStoreSignedPat <inst, node, vt> {
1247 let AddedComplexity = 10;
1250 def : GlobalStoreSaddrPat<!cast<FLAT_Pseudo>(!cast<string>(inst)#"_SADDR"), node, vt> {
1251 let AddedComplexity = 11;
1255 multiclass GlobalFLATAtomicPatsNoRtnBase<string inst, string node, ValueType vt,
1256 ValueType data_vt = vt> {
1257 let AddedComplexity = 11 in
1258 def : FlatSignedAtomicPatBase<!cast<FLAT_Pseudo>(inst), !cast<SDPatternOperator>(node), vt, data_vt>;
1260 let AddedComplexity = 13 in
1261 def : GlobalAtomicSaddrPat<!cast<FLAT_Pseudo>(inst#"_SADDR"), !cast<SDPatternOperator>(node), vt, data_vt>;
1264 multiclass GlobalFLATAtomicPatsRtnBase<string inst, string node, ValueType vt,
1265 ValueType data_vt = vt, bit isPatFrags = 0> {
1266 defvar rtnNode = !if(isPatFrags, !cast<PatFrags>(node), !cast<SDPatternOperator>(node));
1268 let AddedComplexity = 10 in
1269 def : FlatSignedAtomicPatBase<!cast<FLAT_Pseudo>(inst#"_RTN"), rtnNode, vt, data_vt>;
1271 let AddedComplexity = 12 in
1272 def : GlobalAtomicSaddrPat<!cast<FLAT_Pseudo>(inst#"_SADDR_RTN"), rtnNode, vt, data_vt>;
1275 multiclass GlobalFLATAtomicPatsNoRtn<string inst, string node, ValueType vt,
1276 ValueType data_vt = vt, bit isIntr = 0> :
1277 GlobalFLATAtomicPatsNoRtnBase<inst, node # "_noret" # !if(isIntr, "", "_" # vt), vt, data_vt>;
1279 multiclass GlobalFLATAtomicPatsRtn<string inst, string node, ValueType vt,
1280 ValueType data_vt = vt, bit isIntr = 0> :
1281 GlobalFLATAtomicPatsRtnBase<inst, node # !if(isIntr, "", "_" # vt), vt, data_vt>;
1283 multiclass GlobalFLATAtomicPats<string inst, string node, ValueType vt,
1284 ValueType data_vt = vt, bit isIntr = 0> :
1285 GlobalFLATAtomicPatsNoRtn<inst, node, vt, data_vt, isIntr>,
1286 GlobalFLATAtomicPatsRtn<inst, node, vt, data_vt, isIntr>;
1288 multiclass GlobalFLATAtomicPatsNoRtnWithAddrSpace<string inst, string intr, string addrSpaceSuffix,
1289 ValueType vt, ValueType data_vt = vt> :
1290 GlobalFLATAtomicPatsNoRtnBase<inst, intr # "_noret_" # addrSpaceSuffix, vt, data_vt>;
1292 multiclass GlobalFLATAtomicPatsRtnWithAddrSpace<string inst, string intr, string addrSpaceSuffix,
1293 ValueType vt, ValueType data_vt = vt> :
1294 GlobalFLATAtomicPatsRtnBase<inst, intr # "_" # addrSpaceSuffix, vt, data_vt, /*isPatFrags*/ 1>;
1296 multiclass GlobalFLATAtomicPatsWithAddrSpace<string inst, string intr, string addrSpaceSuffix,
1297 ValueType vt, ValueType data_vt = vt> :
1298 GlobalFLATAtomicPatsNoRtnWithAddrSpace<inst, intr, addrSpaceSuffix, vt, data_vt>,
1299 GlobalFLATAtomicPatsRtnWithAddrSpace<inst, intr, addrSpaceSuffix, vt, data_vt>;
1301 multiclass GlobalFLATAtomicIntrPats<string inst, string node, ValueType vt,
1302 ValueType data_vt = vt> {
1303 defm : GlobalFLATAtomicPats<inst, node, vt, data_vt, /* isIntr */ 1>;
1306 multiclass ScratchFLATLoadPats<FLAT_Pseudo inst, SDPatternOperator node, ValueType vt> {
1307 def : ScratchLoadSignedPat <inst, node, vt> {
1308 let AddedComplexity = 25;
1311 def : ScratchLoadSaddrPat<!cast<FLAT_Pseudo>(!cast<string>(inst)#"_SADDR"), node, vt> {
1312 let AddedComplexity = 26;
1315 def : ScratchLoadSVaddrPat<!cast<FLAT_Pseudo>(!cast<string>(inst)#"_SVS"), node, vt> {
1316 let SubtargetPredicate = HasFlatScratchSVSMode;
1317 let AddedComplexity = 27;
1321 multiclass ScratchFLATStorePats<FLAT_Pseudo inst, SDPatternOperator node,
1323 def : ScratchStoreSignedPat <inst, node, vt> {
1324 let AddedComplexity = 25;
1327 def : ScratchStoreSaddrPat<!cast<FLAT_Pseudo>(!cast<string>(inst)#"_SADDR"), node, vt> {
1328 let AddedComplexity = 26;
1331 def : ScratchStoreSVaddrPat<!cast<FLAT_Pseudo>(!cast<string>(inst)#"_SVS"), node, vt> {
1332 let SubtargetPredicate = HasFlatScratchSVSMode;
1333 let AddedComplexity = 27;
1337 multiclass ScratchFLATLoadPats_D16<FLAT_Pseudo inst, SDPatternOperator node, ValueType vt> {
1338 def : ScratchLoadSignedPat_D16 <inst, node, vt> {
1339 let AddedComplexity = 25;
1342 def : ScratchLoadSaddrPat_D16<!cast<FLAT_Pseudo>(!cast<string>(inst)#"_SADDR"), node, vt> {
1343 let AddedComplexity = 26;
1346 def : ScratchLoadSVaddrPat_D16 <!cast<FLAT_Pseudo>(!cast<string>(inst)#"_SVS"), node, vt> {
1347 let SubtargetPredicate = HasFlatScratchSVSMode;
1348 let AddedComplexity = 27;
1352 let OtherPredicates = [HasFlatAddressSpace] in {
1354 def : FlatLoadPat <FLAT_LOAD_UBYTE, atomic_load_8_flat, i32>;
1355 def : FlatLoadPat <FLAT_LOAD_UBYTE, atomic_load_8_flat, i16>;
1356 def : FlatLoadPat <FLAT_LOAD_USHORT, atomic_load_16_flat, i32>;
1357 def : FlatLoadPat <FLAT_LOAD_USHORT, atomic_load_16_flat, i16>;
1358 def : FlatLoadPat <FLAT_LOAD_UBYTE, extloadi8_flat, i32>;
1359 def : FlatLoadPat <FLAT_LOAD_UBYTE, zextloadi8_flat, i32>;
1360 def : FlatLoadPat <FLAT_LOAD_SBYTE, sextloadi8_flat, i32>;
1361 def : FlatLoadPat <FLAT_LOAD_UBYTE, extloadi8_flat, i16>;
1362 def : FlatLoadPat <FLAT_LOAD_UBYTE, zextloadi8_flat, i16>;
1363 def : FlatLoadPat <FLAT_LOAD_SBYTE, sextloadi8_flat, i16>;
1364 def : FlatLoadPat <FLAT_LOAD_USHORT, extloadi16_flat, i32>;
1365 def : FlatLoadPat <FLAT_LOAD_USHORT, zextloadi16_flat, i32>;
1366 def : FlatLoadPat <FLAT_LOAD_USHORT, load_flat, i16>;
1367 def : FlatLoadPat <FLAT_LOAD_SSHORT, sextloadi16_flat, i32>;
1368 def : FlatLoadPat <FLAT_LOAD_DWORDX3, load_flat, v3i32>;
1370 def : FlatLoadPat <FLAT_LOAD_DWORD, atomic_load_32_flat, i32>;
1371 def : FlatLoadPat <FLAT_LOAD_DWORDX2, atomic_load_64_flat, i64>;
1373 def : FlatStorePat <FLAT_STORE_BYTE, truncstorei8_flat, i32>;
1374 def : FlatStorePat <FLAT_STORE_SHORT, truncstorei16_flat, i32>;
1376 foreach vt = Reg32Types.types in {
1377 def : FlatLoadPat <FLAT_LOAD_DWORD, load_flat, vt>;
1378 def : FlatStorePat <FLAT_STORE_DWORD, store_flat, vt>;
1381 foreach vt = VReg_64.RegTypes in {
1382 def : FlatStorePat <FLAT_STORE_DWORDX2, store_flat, vt>;
1383 def : FlatLoadPat <FLAT_LOAD_DWORDX2, load_flat, vt>;
1386 def : FlatStorePat <FLAT_STORE_DWORDX3, store_flat, v3i32>;
1388 foreach vt = VReg_128.RegTypes in {
1389 def : FlatLoadPat <FLAT_LOAD_DWORDX4, load_flat, vt>;
1390 def : FlatStorePat <FLAT_STORE_DWORDX4, store_flat, vt>;
1393 def : FlatStorePat <FLAT_STORE_DWORD, atomic_store_32_flat, i32>;
1394 def : FlatStorePat <FLAT_STORE_DWORDX2, atomic_store_64_flat, i64>;
1395 def : FlatStorePat <FLAT_STORE_BYTE, atomic_store_8_flat, i32>;
1396 def : FlatStorePat <FLAT_STORE_BYTE, atomic_store_8_flat, i16>;
1397 def : FlatStorePat <FLAT_STORE_SHORT, atomic_store_16_flat, i32>;
1398 def : FlatStorePat <FLAT_STORE_SHORT, atomic_store_16_flat, i16>;
1400 foreach as = [ "flat", "global" ] in {
1401 defm : FlatAtomicPat <"FLAT_ATOMIC_ADD", "atomic_load_add_"#as, i32>;
1402 defm : FlatAtomicPat <"FLAT_ATOMIC_SUB", "atomic_load_sub_"#as, i32>;
1403 defm : FlatAtomicPat <"FLAT_ATOMIC_INC", "atomic_load_uinc_wrap_"#as, i32>;
1404 defm : FlatAtomicPat <"FLAT_ATOMIC_DEC", "atomic_load_udec_wrap_"#as, i32>;
1405 defm : FlatAtomicPat <"FLAT_ATOMIC_AND", "atomic_load_and_"#as, i32>;
1406 defm : FlatAtomicPat <"FLAT_ATOMIC_SMAX", "atomic_load_max_"#as, i32>;
1407 defm : FlatAtomicPat <"FLAT_ATOMIC_UMAX", "atomic_load_umax_"#as, i32>;
1408 defm : FlatAtomicPat <"FLAT_ATOMIC_SMIN", "atomic_load_min_"#as, i32>;
1409 defm : FlatAtomicPat <"FLAT_ATOMIC_UMIN", "atomic_load_umin_"#as, i32>;
1410 defm : FlatAtomicPat <"FLAT_ATOMIC_OR", "atomic_load_or_"#as, i32>;
1411 defm : FlatAtomicPat <"FLAT_ATOMIC_SWAP", "atomic_swap_"#as, i32>;
1412 defm : FlatAtomicPat <"FLAT_ATOMIC_CMPSWAP", "AMDGPUatomic_cmp_swap_"#as, i32, v2i32>;
1413 defm : FlatAtomicPat <"FLAT_ATOMIC_XOR", "atomic_load_xor_"#as, i32>;
1415 defm : FlatAtomicPat <"FLAT_ATOMIC_ADD_X2", "atomic_load_add_"#as, i64>;
1416 defm : FlatAtomicPat <"FLAT_ATOMIC_SUB_X2", "atomic_load_sub_"#as, i64>;
1417 defm : FlatAtomicPat <"FLAT_ATOMIC_INC_X2", "atomic_load_uinc_wrap_"#as, i64>;
1418 defm : FlatAtomicPat <"FLAT_ATOMIC_DEC_X2", "atomic_load_udec_wrap_"#as, i64>;
1419 defm : FlatAtomicPat <"FLAT_ATOMIC_AND_X2", "atomic_load_and_"#as, i64>;
1420 defm : FlatAtomicPat <"FLAT_ATOMIC_SMAX_X2", "atomic_load_max_"#as, i64>;
1421 defm : FlatAtomicPat <"FLAT_ATOMIC_UMAX_X2", "atomic_load_umax_"#as, i64>;
1422 defm : FlatAtomicPat <"FLAT_ATOMIC_SMIN_X2", "atomic_load_min_"#as, i64>;
1423 defm : FlatAtomicPat <"FLAT_ATOMIC_UMIN_X2", "atomic_load_umin_"#as, i64>;
1424 defm : FlatAtomicPat <"FLAT_ATOMIC_OR_X2", "atomic_load_or_"#as, i64>;
1425 defm : FlatAtomicPat <"FLAT_ATOMIC_SWAP_X2", "atomic_swap_"#as, i64>;
1426 defm : FlatAtomicPat <"FLAT_ATOMIC_CMPSWAP_X2", "AMDGPUatomic_cmp_swap_"#as, i64, v2i64>;
1427 defm : FlatAtomicPat <"FLAT_ATOMIC_XOR_X2", "atomic_load_xor_"#as, i64>;
1429 let SubtargetPredicate = HasAtomicFMinFMaxF32FlatInsts in {
1430 defm : FlatAtomicPat <"FLAT_ATOMIC_FMIN", "atomic_load_fmin_"#as, f32>;
1431 defm : FlatAtomicPat <"FLAT_ATOMIC_FMAX", "atomic_load_fmax_"#as, f32>;
1434 let SubtargetPredicate = HasAtomicFMinFMaxF64FlatInsts in {
1435 defm : FlatAtomicPat <"FLAT_ATOMIC_MIN_F64", "atomic_load_fmin_"#as, f64>;
1436 defm : FlatAtomicPat <"FLAT_ATOMIC_MAX_F64", "atomic_load_fmax_"#as, f64>;
1441 let SubtargetPredicate = isGFX12Plus in {
1442 defm : FlatAtomicRtnPatWithAddrSpace<"FLAT_ATOMIC_COND_SUB_U32", "int_amdgcn_atomic_cond_sub_u32", "flat_addrspace", i32 >;
1444 let OtherPredicates = [HasAtomicCSubNoRtnInsts] in
1445 defm : FlatAtomicNoRtnPatWithAddrSpace<"FLAT_ATOMIC_COND_SUB_U32", "int_amdgcn_atomic_cond_sub_u32", "flat_addrspace", i32>;
1448 def : FlatStorePat <FLAT_STORE_BYTE, truncstorei8_flat, i16>;
1449 def : FlatStorePat <FLAT_STORE_SHORT, store_flat, i16>;
1451 let OtherPredicates = [HasD16LoadStore] in {
1452 def : FlatStorePat <FLAT_STORE_SHORT_D16_HI, truncstorei16_hi16_flat, i32>;
1453 def : FlatStorePat <FLAT_STORE_BYTE_D16_HI, truncstorei8_hi16_flat, i32>;
1456 let OtherPredicates = [D16PreservesUnusedBits] in {
1457 def : FlatLoadPat_D16 <FLAT_LOAD_UBYTE_D16_HI, az_extloadi8_d16_hi_flat, v2i16>;
1458 def : FlatLoadPat_D16 <FLAT_LOAD_UBYTE_D16_HI, az_extloadi8_d16_hi_flat, v2f16>;
1459 def : FlatLoadPat_D16 <FLAT_LOAD_SBYTE_D16_HI, sextloadi8_d16_hi_flat, v2i16>;
1460 def : FlatLoadPat_D16 <FLAT_LOAD_SBYTE_D16_HI, sextloadi8_d16_hi_flat, v2f16>;
1461 def : FlatLoadPat_D16 <FLAT_LOAD_SHORT_D16_HI, load_d16_hi_flat, v2i16>;
1462 def : FlatLoadPat_D16 <FLAT_LOAD_SHORT_D16_HI, load_d16_hi_flat, v2f16>;
1464 def : FlatLoadPat_D16 <FLAT_LOAD_UBYTE_D16, az_extloadi8_d16_lo_flat, v2i16>;
1465 def : FlatLoadPat_D16 <FLAT_LOAD_UBYTE_D16, az_extloadi8_d16_lo_flat, v2f16>;
1466 def : FlatLoadPat_D16 <FLAT_LOAD_SBYTE_D16, sextloadi8_d16_lo_flat, v2i16>;
1467 def : FlatLoadPat_D16 <FLAT_LOAD_SBYTE_D16, sextloadi8_d16_lo_flat, v2f16>;
1468 def : FlatLoadPat_D16 <FLAT_LOAD_SHORT_D16, load_d16_lo_flat, v2i16>;
1469 def : FlatLoadPat_D16 <FLAT_LOAD_SHORT_D16, load_d16_lo_flat, v2f16>;
1472 } // End OtherPredicates = [HasFlatAddressSpace]
1474 let OtherPredicates = [HasFlatGlobalInsts] in {
1476 defm : GlobalFLATLoadPats <GLOBAL_LOAD_UBYTE, atomic_load_8_global, i32>;
1477 defm : GlobalFLATLoadPats <GLOBAL_LOAD_UBYTE, atomic_load_8_global, i16>;
1478 defm : GlobalFLATLoadPats <GLOBAL_LOAD_USHORT, atomic_load_16_global, i32>;
1479 defm : GlobalFLATLoadPats <GLOBAL_LOAD_USHORT, atomic_load_16_global, i16>;
1480 defm : GlobalFLATLoadPats <GLOBAL_LOAD_UBYTE, extloadi8_global, i32>;
1481 defm : GlobalFLATLoadPats <GLOBAL_LOAD_UBYTE, zextloadi8_global, i32>;
1482 defm : GlobalFLATLoadPats <GLOBAL_LOAD_SBYTE, sextloadi8_global, i32>;
1483 defm : GlobalFLATLoadPats <GLOBAL_LOAD_UBYTE, extloadi8_global, i16>;
1484 defm : GlobalFLATLoadPats <GLOBAL_LOAD_UBYTE, zextloadi8_global, i16>;
1485 defm : GlobalFLATLoadPats <GLOBAL_LOAD_SBYTE, sextloadi8_global, i16>;
1486 defm : GlobalFLATLoadPats <GLOBAL_LOAD_USHORT, extloadi16_global, i32>;
1487 defm : GlobalFLATLoadPats <GLOBAL_LOAD_USHORT, zextloadi16_global, i32>;
1488 defm : GlobalFLATLoadPats <GLOBAL_LOAD_SSHORT, sextloadi16_global, i32>;
1489 defm : GlobalFLATLoadPats <GLOBAL_LOAD_USHORT, load_global, i16>;
1491 foreach vt = Reg32Types.types in {
1492 defm : GlobalFLATLoadPats <GLOBAL_LOAD_DWORD, load_global, vt>;
1493 defm : GlobalFLATStorePats <GLOBAL_STORE_DWORD, store_global, vt>;
1496 foreach vt = VReg_64.RegTypes in {
1497 defm : GlobalFLATLoadPats <GLOBAL_LOAD_DWORDX2, load_global, vt>;
1498 defm : GlobalFLATStorePats <GLOBAL_STORE_DWORDX2, store_global, vt>;
1501 defm : GlobalFLATLoadPats <GLOBAL_LOAD_DWORDX3, load_global, v3i32>;
1503 foreach vt = VReg_128.RegTypes in {
1504 defm : GlobalFLATLoadPats <GLOBAL_LOAD_DWORDX4, load_global, vt>;
1505 defm : GlobalFLATStorePats <GLOBAL_STORE_DWORDX4, store_global, vt>;
1508 // There is no distinction for atomic load lowering during selection;
1509 // the memory legalizer will set the cache bits and insert the
1510 // appropriate waits.
1511 defm : GlobalFLATLoadPats <GLOBAL_LOAD_DWORD, atomic_load_32_global, i32>;
1512 defm : GlobalFLATLoadPats <GLOBAL_LOAD_DWORDX2, atomic_load_64_global, i64>;
1514 defm : GlobalFLATStorePats <GLOBAL_STORE_BYTE, truncstorei8_global, i32>;
1515 defm : GlobalFLATStorePats <GLOBAL_STORE_BYTE, truncstorei8_global, i16>;
1516 defm : GlobalFLATStorePats <GLOBAL_STORE_SHORT, truncstorei16_global, i32>;
1517 defm : GlobalFLATStorePats <GLOBAL_STORE_SHORT, store_global, i16>;
1518 defm : GlobalFLATStorePats <GLOBAL_STORE_DWORDX3, store_global, v3i32>;
1520 let OtherPredicates = [HasD16LoadStore] in {
1521 defm : GlobalFLATStorePats <GLOBAL_STORE_SHORT_D16_HI, truncstorei16_hi16_global, i32>;
1522 defm : GlobalFLATStorePats <GLOBAL_STORE_BYTE_D16_HI, truncstorei8_hi16_global, i32>;
1525 let OtherPredicates = [D16PreservesUnusedBits] in {
1526 defm : GlobalFLATLoadPats_D16 <GLOBAL_LOAD_UBYTE_D16_HI, az_extloadi8_d16_hi_global, v2i16>;
1527 defm : GlobalFLATLoadPats_D16 <GLOBAL_LOAD_UBYTE_D16_HI, az_extloadi8_d16_hi_global, v2f16>;
1528 defm : GlobalFLATLoadPats_D16 <GLOBAL_LOAD_SBYTE_D16_HI, sextloadi8_d16_hi_global, v2i16>;
1529 defm : GlobalFLATLoadPats_D16 <GLOBAL_LOAD_SBYTE_D16_HI, sextloadi8_d16_hi_global, v2f16>;
1530 defm : GlobalFLATLoadPats_D16 <GLOBAL_LOAD_SHORT_D16_HI, load_d16_hi_global, v2i16>;
1531 defm : GlobalFLATLoadPats_D16 <GLOBAL_LOAD_SHORT_D16_HI, load_d16_hi_global, v2f16>;
1533 defm : GlobalFLATLoadPats_D16 <GLOBAL_LOAD_UBYTE_D16, az_extloadi8_d16_lo_global, v2i16>;
1534 defm : GlobalFLATLoadPats_D16 <GLOBAL_LOAD_UBYTE_D16, az_extloadi8_d16_lo_global, v2f16>;
1535 defm : GlobalFLATLoadPats_D16 <GLOBAL_LOAD_SBYTE_D16, sextloadi8_d16_lo_global, v2i16>;
1536 defm : GlobalFLATLoadPats_D16 <GLOBAL_LOAD_SBYTE_D16, sextloadi8_d16_lo_global, v2f16>;
1537 defm : GlobalFLATLoadPats_D16 <GLOBAL_LOAD_SHORT_D16, load_d16_lo_global, v2i16>;
1538 defm : GlobalFLATLoadPats_D16 <GLOBAL_LOAD_SHORT_D16, load_d16_lo_global, v2f16>;
1541 defm : GlobalFLATStorePats <GLOBAL_STORE_BYTE, atomic_store_8_global, i32>;
1542 defm : GlobalFLATStorePats <GLOBAL_STORE_BYTE, atomic_store_8_global, i16>;
1543 defm : GlobalFLATStorePats <GLOBAL_STORE_SHORT, atomic_store_16_global, i32>;
1544 defm : GlobalFLATStorePats <GLOBAL_STORE_SHORT, atomic_store_16_global, i16>;
1545 defm : GlobalFLATStorePats <GLOBAL_STORE_DWORD, atomic_store_32_global, i32>;
1546 defm : GlobalFLATStorePats <GLOBAL_STORE_DWORDX2, atomic_store_64_global, i64>;
1548 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_ADD", "atomic_load_add_global", i32>;
1549 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_SUB", "atomic_load_sub_global", i32>;
1550 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_INC", "atomic_load_uinc_wrap_global", i32>;
1551 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_DEC", "atomic_load_udec_wrap_global", i32>;
1552 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_AND", "atomic_load_and_global", i32>;
1553 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_SMAX", "atomic_load_max_global", i32>;
1554 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_UMAX", "atomic_load_umax_global", i32>;
1555 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_SMIN", "atomic_load_min_global", i32>;
1556 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_UMIN", "atomic_load_umin_global", i32>;
1557 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_OR", "atomic_load_or_global", i32>;
1558 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_SWAP", "atomic_swap_global", i32>;
1559 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_CMPSWAP", "AMDGPUatomic_cmp_swap_global", i32, v2i32>;
1560 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_XOR", "atomic_load_xor_global", i32>;
1561 defm : GlobalFLATAtomicPatsRtn <"GLOBAL_ATOMIC_CSUB", "int_amdgcn_global_atomic_csub", i32, i32, /* isIntr */ 1>;
1563 let OtherPredicates = [HasAtomicCSubNoRtnInsts] in
1564 defm : GlobalFLATAtomicPatsNoRtn <"GLOBAL_ATOMIC_CSUB", "int_amdgcn_global_atomic_csub", i32, i32, /* isIntr */ 1>;
1566 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_ADD_X2", "atomic_load_add_global", i64>;
1567 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_SUB_X2", "atomic_load_sub_global", i64>;
1568 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_INC_X2", "atomic_load_uinc_wrap_global", i64>;
1569 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_DEC_X2", "atomic_load_udec_wrap_global", i64>;
1570 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_AND_X2", "atomic_load_and_global", i64>;
1571 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_SMAX_X2", "atomic_load_max_global", i64>;
1572 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_UMAX_X2", "atomic_load_umax_global", i64>;
1573 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_SMIN_X2", "atomic_load_min_global", i64>;
1574 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_UMIN_X2", "atomic_load_umin_global", i64>;
1575 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_OR_X2", "atomic_load_or_global", i64>;
1576 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_SWAP_X2", "atomic_swap_global", i64>;
1577 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_CMPSWAP_X2", "AMDGPUatomic_cmp_swap_global", i64, v2i64>;
1578 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_XOR_X2", "atomic_load_xor_global", i64>;
1580 let SubtargetPredicate = isGFX12Plus in {
1581 defm : GlobalFLATAtomicPatsRtnWithAddrSpace <"GLOBAL_ATOMIC_COND_SUB_U32", "int_amdgcn_atomic_cond_sub_u32", "global_addrspace", i32>;
1583 let OtherPredicates = [HasAtomicCSubNoRtnInsts] in
1584 defm : GlobalFLATAtomicPatsNoRtnWithAddrSpace <"GLOBAL_ATOMIC_COND_SUB_U32", "int_amdgcn_atomic_cond_sub_u32", "global_addrspace", i32>;
1587 let OtherPredicates = [isGFX12Plus] in {
1588 defm : GlobalFLATAtomicPatsRtn <"GLOBAL_ATOMIC_ORDERED_ADD_B64", "int_amdgcn_global_atomic_ordered_add_b64", i64, i64, /* isIntr */ 1>;
1590 let WaveSizePredicate = isWave32 in {
1591 defm : GlobalFLATLoadPats <GLOBAL_LOAD_TR_B64_w32, int_amdgcn_global_load_tr_b64, v2i32>;
1592 foreach vt = [v8i16, v8f16, v8bf16] in
1593 defm : GlobalFLATLoadPats <GLOBAL_LOAD_TR_B128_w32, int_amdgcn_global_load_tr_b128, vt>;
1595 let WaveSizePredicate = isWave64 in {
1596 defm : GlobalFLATLoadPats <GLOBAL_LOAD_TR_B64_w64, int_amdgcn_global_load_tr_b64, i32>;
1597 foreach vt = [v4i16, v4f16, v4bf16] in
1598 defm : GlobalFLATLoadPats <GLOBAL_LOAD_TR_B128_w64, int_amdgcn_global_load_tr_b128, vt>;
1602 let SubtargetPredicate = HasAtomicFMinFMaxF32GlobalInsts, OtherPredicates = [HasFlatGlobalInsts] in {
1603 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_FMIN", "atomic_load_fmin_global", f32>;
1604 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_FMAX", "atomic_load_fmax_global", f32>;
1605 defm : GlobalFLATAtomicIntrPats <"GLOBAL_ATOMIC_FMIN", "int_amdgcn_global_atomic_fmin", f32>;
1606 defm : GlobalFLATAtomicIntrPats <"GLOBAL_ATOMIC_FMAX", "int_amdgcn_global_atomic_fmax", f32>;
1609 let SubtargetPredicate = HasAtomicFMinFMaxF32FlatInsts in {
1610 defm : FlatAtomicPat <"FLAT_ATOMIC_FMIN", "atomic_load_fmin_flat", f32>;
1611 defm : FlatAtomicPat <"FLAT_ATOMIC_FMAX", "atomic_load_fmax_flat", f32>;
1612 defm : FlatAtomicIntrPat <"FLAT_ATOMIC_FMIN", "int_amdgcn_flat_atomic_fmin", f32>;
1613 defm : FlatAtomicIntrPat <"FLAT_ATOMIC_FMAX", "int_amdgcn_flat_atomic_fmax", f32>;
1616 let OtherPredicates = [isGFX12Only] in {
1617 // FIXME: Remove these intrinsics
1618 defm : GlobalFLATAtomicIntrPats <"GLOBAL_ATOMIC_FMIN", "int_amdgcn_global_atomic_fmin_num", f32>;
1619 defm : GlobalFLATAtomicIntrPats <"GLOBAL_ATOMIC_FMAX", "int_amdgcn_global_atomic_fmax_num", f32>;
1620 defm : FlatAtomicIntrPat <"FLAT_ATOMIC_FMIN", "int_amdgcn_flat_atomic_fmin_num", f32>;
1621 defm : FlatAtomicIntrPat <"FLAT_ATOMIC_FMAX", "int_amdgcn_flat_atomic_fmax_num", f32>;
1624 let OtherPredicates = [HasAtomicFaddNoRtnInsts] in {
1625 defm : GlobalFLATAtomicPatsNoRtn <"GLOBAL_ATOMIC_ADD_F32", "atomic_load_fadd_global", f32>;
1626 defm : GlobalFLATAtomicPatsNoRtnWithAddrSpace <"GLOBAL_ATOMIC_ADD_F32", "int_amdgcn_flat_atomic_fadd", "global_addrspace", f32>;
1627 defm : GlobalFLATAtomicPatsNoRtnWithAddrSpace <"GLOBAL_ATOMIC_ADD_F32", "int_amdgcn_global_atomic_fadd", "global_addrspace", f32>;
1630 let OtherPredicates = [HasAtomicBufferGlobalPkAddF16NoRtnInsts] in {
1631 defm : GlobalFLATAtomicPatsNoRtn <"GLOBAL_ATOMIC_PK_ADD_F16", "atomic_load_fadd_global", v2f16>;
1632 defm : GlobalFLATAtomicPatsNoRtnWithAddrSpace <"GLOBAL_ATOMIC_PK_ADD_F16", "int_amdgcn_flat_atomic_fadd", "global_addrspace", v2f16>;
1633 defm : GlobalFLATAtomicPatsNoRtnWithAddrSpace <"GLOBAL_ATOMIC_PK_ADD_F16", "int_amdgcn_global_atomic_fadd", "global_addrspace", v2f16>;
1636 let OtherPredicates = [HasAtomicFaddRtnInsts] in {
1637 defm : GlobalFLATAtomicPatsRtn <"GLOBAL_ATOMIC_ADD_F32", "atomic_load_fadd_global", f32>;
1638 defm : GlobalFLATAtomicPatsRtnWithAddrSpace <"GLOBAL_ATOMIC_ADD_F32", "int_amdgcn_flat_atomic_fadd", "global_addrspace", f32>;
1639 defm : GlobalFLATAtomicPatsRtnWithAddrSpace <"GLOBAL_ATOMIC_ADD_F32", "int_amdgcn_global_atomic_fadd", "global_addrspace", f32>;
1642 let OtherPredicates = [HasAtomicBufferGlobalPkAddF16Insts] in {
1643 defm : GlobalFLATAtomicPatsRtnWithAddrSpace <"GLOBAL_ATOMIC_PK_ADD_F16", "int_amdgcn_flat_atomic_fadd", "global_addrspace", v2f16>;
1644 defm : GlobalFLATAtomicPatsRtnWithAddrSpace <"GLOBAL_ATOMIC_PK_ADD_F16", "int_amdgcn_global_atomic_fadd", "global_addrspace", v2f16>;
1645 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_PK_ADD_F16", "atomic_load_fadd_global", v2f16>;
1648 let SubtargetPredicate = HasAtomicFMinFMaxF64GlobalInsts, OtherPredicates = [HasFlatGlobalInsts] in {
1649 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_MIN_F64", "atomic_load_fmin_global", f64>;
1650 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_MAX_F64", "atomic_load_fmax_global", f64>;
1651 defm : GlobalFLATAtomicIntrPats <"GLOBAL_ATOMIC_MIN_F64", "int_amdgcn_global_atomic_fmin", f64>;
1652 defm : GlobalFLATAtomicIntrPats <"GLOBAL_ATOMIC_MAX_F64", "int_amdgcn_global_atomic_fmax", f64>;
1655 let SubtargetPredicate = HasAtomicFMinFMaxF64FlatInsts in {
1656 defm : FlatAtomicIntrPat <"FLAT_ATOMIC_MIN_F64", "int_amdgcn_flat_atomic_fmin", f64>;
1657 defm : FlatAtomicIntrPat <"FLAT_ATOMIC_MAX_F64", "int_amdgcn_flat_atomic_fmax", f64>;
1660 let OtherPredicates = [HasFlatBufferGlobalAtomicFaddF64Inst] in {
1661 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_ADD_F64", "atomic_load_fadd_global", f64>;
1662 defm : GlobalFLATAtomicPatsWithAddrSpace<"GLOBAL_ATOMIC_ADD_F64", "int_amdgcn_flat_atomic_fadd", "global_addrspace", f64>;
1663 defm : GlobalFLATAtomicPatsWithAddrSpace<"GLOBAL_ATOMIC_ADD_F64", "int_amdgcn_global_atomic_fadd", "global_addrspace", f64>;
1664 defm : FlatAtomicPat <"FLAT_ATOMIC_ADD_F64", "atomic_load_fadd_flat", f64>;
1665 defm : FlatAtomicIntrPat <"FLAT_ATOMIC_ADD_F64", "int_amdgcn_flat_atomic_fadd", f64>;
1668 let OtherPredicates = [HasFlatAtomicFaddF32Inst] in {
1669 defm : FlatAtomicPat <"FLAT_ATOMIC_ADD_F32", "atomic_load_fadd_flat", f32>;
1670 defm : FlatAtomicIntrPat <"FLAT_ATOMIC_ADD_F32", "int_amdgcn_flat_atomic_fadd", f32>;
1673 let OtherPredicates = [HasAtomicFlatPkAdd16Insts] in {
1674 defm : FlatAtomicIntrPat <"FLAT_ATOMIC_PK_ADD_F16", "int_amdgcn_flat_atomic_fadd", v2f16>;
1675 defm : FlatAtomicIntrPat <"FLAT_ATOMIC_PK_ADD_BF16", "int_amdgcn_flat_atomic_fadd_v2bf16", v2i16>;
1676 defm : FlatAtomicPat <"FLAT_ATOMIC_PK_ADD_F16", "atomic_load_fadd_flat", v2f16>;
1677 defm : FlatAtomicPat <"FLAT_ATOMIC_PK_ADD_BF16", "atomic_load_fadd_flat", v2bf16>;
1680 let OtherPredicates = [HasAtomicGlobalPkAddBF16Inst] in
1681 defm : GlobalFLATAtomicIntrPats <"GLOBAL_ATOMIC_PK_ADD_BF16", "int_amdgcn_global_atomic_fadd_v2bf16", v2i16>;
1682 defm : GlobalFLATAtomicPats <"GLOBAL_ATOMIC_PK_ADD_BF16", "atomic_load_fadd_global", v2bf16>;
1683 } // End OtherPredicates = [HasFlatGlobalInsts], AddedComplexity = 10
1685 let OtherPredicates = [HasFlatScratchInsts, EnableFlatScratch] in {
1687 defm : ScratchFLATLoadPats <SCRATCH_LOAD_UBYTE, extloadi8_private, i32>;
1688 defm : ScratchFLATLoadPats <SCRATCH_LOAD_UBYTE, zextloadi8_private, i32>;
1689 defm : ScratchFLATLoadPats <SCRATCH_LOAD_SBYTE, sextloadi8_private, i32>;
1690 defm : ScratchFLATLoadPats <SCRATCH_LOAD_UBYTE, extloadi8_private, i16>;
1691 defm : ScratchFLATLoadPats <SCRATCH_LOAD_UBYTE, zextloadi8_private, i16>;
1692 defm : ScratchFLATLoadPats <SCRATCH_LOAD_SBYTE, sextloadi8_private, i16>;
1693 defm : ScratchFLATLoadPats <SCRATCH_LOAD_USHORT, extloadi16_private, i32>;
1694 defm : ScratchFLATLoadPats <SCRATCH_LOAD_USHORT, zextloadi16_private, i32>;
1695 defm : ScratchFLATLoadPats <SCRATCH_LOAD_SSHORT, sextloadi16_private, i32>;
1696 defm : ScratchFLATLoadPats <SCRATCH_LOAD_USHORT, load_private, i16>;
1698 foreach vt = Reg32Types.types in {
1699 defm : ScratchFLATLoadPats <SCRATCH_LOAD_DWORD, load_private, vt>;
1700 defm : ScratchFLATStorePats <SCRATCH_STORE_DWORD, store_private, vt>;
1703 foreach vt = VReg_64.RegTypes in {
1704 defm : ScratchFLATLoadPats <SCRATCH_LOAD_DWORDX2, load_private, vt>;
1705 defm : ScratchFLATStorePats <SCRATCH_STORE_DWORDX2, store_private, vt>;
1708 defm : ScratchFLATLoadPats <SCRATCH_LOAD_DWORDX3, load_private, v3i32>;
1710 foreach vt = VReg_128.RegTypes in {
1711 defm : ScratchFLATLoadPats <SCRATCH_LOAD_DWORDX4, load_private, vt>;
1712 defm : ScratchFLATStorePats <SCRATCH_STORE_DWORDX4, store_private, vt>;
1715 defm : ScratchFLATStorePats <SCRATCH_STORE_BYTE, truncstorei8_private, i32>;
1716 defm : ScratchFLATStorePats <SCRATCH_STORE_BYTE, truncstorei8_private, i16>;
1717 defm : ScratchFLATStorePats <SCRATCH_STORE_SHORT, truncstorei16_private, i32>;
1718 defm : ScratchFLATStorePats <SCRATCH_STORE_SHORT, store_private, i16>;
1719 defm : ScratchFLATStorePats <SCRATCH_STORE_DWORDX3, store_private, v3i32>;
1721 let OtherPredicates = [HasD16LoadStore, HasFlatScratchInsts, EnableFlatScratch] in {
1722 defm : ScratchFLATStorePats <SCRATCH_STORE_SHORT_D16_HI, truncstorei16_hi16_private, i32>;
1723 defm : ScratchFLATStorePats <SCRATCH_STORE_BYTE_D16_HI, truncstorei8_hi16_private, i32>;
1726 let OtherPredicates = [D16PreservesUnusedBits, HasFlatScratchInsts, EnableFlatScratch] in {
1727 defm : ScratchFLATLoadPats_D16 <SCRATCH_LOAD_UBYTE_D16_HI, az_extloadi8_d16_hi_private, v2i16>;
1728 defm : ScratchFLATLoadPats_D16 <SCRATCH_LOAD_UBYTE_D16_HI, az_extloadi8_d16_hi_private, v2f16>;
1729 defm : ScratchFLATLoadPats_D16 <SCRATCH_LOAD_SBYTE_D16_HI, sextloadi8_d16_hi_private, v2i16>;
1730 defm : ScratchFLATLoadPats_D16 <SCRATCH_LOAD_SBYTE_D16_HI, sextloadi8_d16_hi_private, v2f16>;
1731 defm : ScratchFLATLoadPats_D16 <SCRATCH_LOAD_SHORT_D16_HI, load_d16_hi_private, v2i16>;
1732 defm : ScratchFLATLoadPats_D16 <SCRATCH_LOAD_SHORT_D16_HI, load_d16_hi_private, v2f16>;
1734 defm : ScratchFLATLoadPats_D16 <SCRATCH_LOAD_UBYTE_D16, az_extloadi8_d16_lo_private, v2i16>;
1735 defm : ScratchFLATLoadPats_D16 <SCRATCH_LOAD_UBYTE_D16, az_extloadi8_d16_lo_private, v2f16>;
1736 defm : ScratchFLATLoadPats_D16 <SCRATCH_LOAD_SBYTE_D16, sextloadi8_d16_lo_private, v2i16>;
1737 defm : ScratchFLATLoadPats_D16 <SCRATCH_LOAD_SBYTE_D16, sextloadi8_d16_lo_private, v2f16>;
1738 defm : ScratchFLATLoadPats_D16 <SCRATCH_LOAD_SHORT_D16, load_d16_lo_private, v2i16>;
1739 defm : ScratchFLATLoadPats_D16 <SCRATCH_LOAD_SHORT_D16, load_d16_lo_private, v2f16>;
1742 } // End OtherPredicates = [HasFlatScratchInsts,EnableFlatScratch]
1744 //===----------------------------------------------------------------------===//
1746 //===----------------------------------------------------------------------===//
1748 //===----------------------------------------------------------------------===//
1750 //===----------------------------------------------------------------------===//
1752 class FLAT_Real_ci <bits<7> op, FLAT_Pseudo ps, string asmName = ps.Mnemonic> :
1753 FLAT_Real <op, ps, asmName>,
1754 SIMCInstr <ps.PseudoInstr, SIEncodingFamily.SI> {
1755 let AssemblerPredicate = isGFX7Only;
1756 let DecoderNamespace="GFX7";
1759 def FLAT_LOAD_UBYTE_ci : FLAT_Real_ci <0x8, FLAT_LOAD_UBYTE>;
1760 def FLAT_LOAD_SBYTE_ci : FLAT_Real_ci <0x9, FLAT_LOAD_SBYTE>;
1761 def FLAT_LOAD_USHORT_ci : FLAT_Real_ci <0xa, FLAT_LOAD_USHORT>;
1762 def FLAT_LOAD_SSHORT_ci : FLAT_Real_ci <0xb, FLAT_LOAD_SSHORT>;
1763 def FLAT_LOAD_DWORD_ci : FLAT_Real_ci <0xc, FLAT_LOAD_DWORD>;
1764 def FLAT_LOAD_DWORDX2_ci : FLAT_Real_ci <0xd, FLAT_LOAD_DWORDX2>;
1765 def FLAT_LOAD_DWORDX4_ci : FLAT_Real_ci <0xe, FLAT_LOAD_DWORDX4>;
1766 def FLAT_LOAD_DWORDX3_ci : FLAT_Real_ci <0xf, FLAT_LOAD_DWORDX3>;
1768 def FLAT_STORE_BYTE_ci : FLAT_Real_ci <0x18, FLAT_STORE_BYTE>;
1769 def FLAT_STORE_SHORT_ci : FLAT_Real_ci <0x1a, FLAT_STORE_SHORT>;
1770 def FLAT_STORE_DWORD_ci : FLAT_Real_ci <0x1c, FLAT_STORE_DWORD>;
1771 def FLAT_STORE_DWORDX2_ci : FLAT_Real_ci <0x1d, FLAT_STORE_DWORDX2>;
1772 def FLAT_STORE_DWORDX4_ci : FLAT_Real_ci <0x1e, FLAT_STORE_DWORDX4>;
1773 def FLAT_STORE_DWORDX3_ci : FLAT_Real_ci <0x1f, FLAT_STORE_DWORDX3>;
1775 multiclass FLAT_Real_Atomics_ci <bits<7> op, string opName = NAME,
1776 string asmName = !cast<FLAT_Pseudo>(opName).Mnemonic> {
1777 defvar ps = !cast<FLAT_Pseudo>(opName);
1778 defvar ps_rtn = !cast<FLAT_Pseudo>(opName#"_RTN");
1780 def _ci : FLAT_Real_ci<op, ps, asmName>;
1781 def _RTN_ci : FLAT_Real_ci<op, ps_rtn, asmName>;
1784 defm FLAT_ATOMIC_SWAP : FLAT_Real_Atomics_ci <0x30>;
1785 defm FLAT_ATOMIC_CMPSWAP : FLAT_Real_Atomics_ci <0x31>;
1786 defm FLAT_ATOMIC_ADD : FLAT_Real_Atomics_ci <0x32>;
1787 defm FLAT_ATOMIC_SUB : FLAT_Real_Atomics_ci <0x33>;
1788 defm FLAT_ATOMIC_SMIN : FLAT_Real_Atomics_ci <0x35>;
1789 defm FLAT_ATOMIC_UMIN : FLAT_Real_Atomics_ci <0x36>;
1790 defm FLAT_ATOMIC_SMAX : FLAT_Real_Atomics_ci <0x37>;
1791 defm FLAT_ATOMIC_UMAX : FLAT_Real_Atomics_ci <0x38>;
1792 defm FLAT_ATOMIC_AND : FLAT_Real_Atomics_ci <0x39>;
1793 defm FLAT_ATOMIC_OR : FLAT_Real_Atomics_ci <0x3a>;
1794 defm FLAT_ATOMIC_XOR : FLAT_Real_Atomics_ci <0x3b>;
1795 defm FLAT_ATOMIC_INC : FLAT_Real_Atomics_ci <0x3c>;
1796 defm FLAT_ATOMIC_DEC : FLAT_Real_Atomics_ci <0x3d>;
1797 defm FLAT_ATOMIC_SWAP_X2 : FLAT_Real_Atomics_ci <0x50>;
1798 defm FLAT_ATOMIC_CMPSWAP_X2 : FLAT_Real_Atomics_ci <0x51>;
1799 defm FLAT_ATOMIC_ADD_X2 : FLAT_Real_Atomics_ci <0x52>;
1800 defm FLAT_ATOMIC_SUB_X2 : FLAT_Real_Atomics_ci <0x53>;
1801 defm FLAT_ATOMIC_SMIN_X2 : FLAT_Real_Atomics_ci <0x55>;
1802 defm FLAT_ATOMIC_UMIN_X2 : FLAT_Real_Atomics_ci <0x56>;
1803 defm FLAT_ATOMIC_SMAX_X2 : FLAT_Real_Atomics_ci <0x57>;
1804 defm FLAT_ATOMIC_UMAX_X2 : FLAT_Real_Atomics_ci <0x58>;
1805 defm FLAT_ATOMIC_AND_X2 : FLAT_Real_Atomics_ci <0x59>;
1806 defm FLAT_ATOMIC_OR_X2 : FLAT_Real_Atomics_ci <0x5a>;
1807 defm FLAT_ATOMIC_XOR_X2 : FLAT_Real_Atomics_ci <0x5b>;
1808 defm FLAT_ATOMIC_INC_X2 : FLAT_Real_Atomics_ci <0x5c>;
1809 defm FLAT_ATOMIC_DEC_X2 : FLAT_Real_Atomics_ci <0x5d>;
1811 // CI Only flat instructions
1812 defm FLAT_ATOMIC_FCMPSWAP : FLAT_Real_Atomics_ci <0x3e>;
1813 defm FLAT_ATOMIC_FMIN : FLAT_Real_Atomics_ci <0x3f>;
1814 defm FLAT_ATOMIC_FMAX : FLAT_Real_Atomics_ci <0x40>;
1815 defm FLAT_ATOMIC_FCMPSWAP_X2 : FLAT_Real_Atomics_ci <0x5e>;
1816 defm FLAT_ATOMIC_FMIN_X2 : FLAT_Real_Atomics_ci <0x5f, "FLAT_ATOMIC_MIN_F64", "flat_atomic_fmin_x2">;
1817 defm FLAT_ATOMIC_FMAX_X2 : FLAT_Real_Atomics_ci <0x60, "FLAT_ATOMIC_MAX_F64", "flat_atomic_fmax_x2">;
1820 //===----------------------------------------------------------------------===//
1822 //===----------------------------------------------------------------------===//
1824 class FLAT_Real_vi <bits<7> op, FLAT_Pseudo ps, bit has_sccb = ps.has_sccb> :
1826 SIMCInstr <ps.PseudoInstr, SIEncodingFamily.VI> {
1827 let AssemblerPredicate = isGFX8GFX9;
1828 let DecoderNamespace = "GFX8";
1830 let Inst{25} = !if(has_sccb, cpol{CPolBit.SCC}, ps.sccbValue);
1831 let AsmString = ps.Mnemonic #
1832 !subst("$sccb", !if(has_sccb, "$sccb",""), ps.AsmOperands);
1835 multiclass FLAT_Real_AllAddr_vi<bits<7> op,
1836 bit has_sccb = !cast<FLAT_Pseudo>(NAME).has_sccb> {
1837 def _vi : FLAT_Real_vi<op, !cast<FLAT_Pseudo>(NAME), has_sccb>;
1838 def _SADDR_vi : FLAT_Real_vi<op, !cast<FLAT_Pseudo>(NAME#"_SADDR"), has_sccb>;
1841 class FLAT_Real_gfx940 <bits<7> op, FLAT_Pseudo ps> :
1843 SIMCInstr <ps.PseudoInstr, SIEncodingFamily.GFX940> {
1844 let AssemblerPredicate = isGFX940Plus;
1845 let DecoderNamespace = "GFX9";
1846 let Inst{13} = ps.sve;
1847 let Inst{25} = !if(ps.has_sccb, cpol{CPolBit.SCC}, ps.sccbValue);
1850 multiclass FLAT_Real_AllAddr_SVE_vi<bits<7> op> {
1851 def _vi : FLAT_Real_vi<op, !cast<FLAT_Pseudo>(NAME)> {
1852 let AssemblerPredicate = isGFX8GFX9NotGFX940;
1853 let OtherPredicates = [isGFX8GFX9NotGFX940];
1855 def _SADDR_vi : FLAT_Real_vi<op, !cast<FLAT_Pseudo>(NAME#"_SADDR")> {
1856 let DecoderNamespace = "GFX9";
1858 let AssemblerPredicate = isGFX940Plus, SubtargetPredicate = isGFX940Plus in {
1859 def _VE_gfx940 : FLAT_Real_gfx940<op, !cast<FLAT_Pseudo>(NAME)>;
1860 def _SVS_gfx940 : FLAT_Real_gfx940<op, !cast<FLAT_Pseudo>(NAME#"_SVS")>;
1861 def _ST_gfx940 : FLAT_Real_gfx940<op, !cast<FLAT_Pseudo>(NAME#"_ST")>;
1865 multiclass FLAT_Real_AllAddr_LDS<bits<7> op, bits<7> pre_gfx940_op,
1866 string pre_gfx940_name = !subst("_lds", "", !cast<FLAT_Pseudo>(NAME).Mnemonic),
1867 bit has_sccb = !cast<FLAT_Pseudo>(NAME).has_sccb> {
1869 let OtherPredicates = [isGFX8GFX9NotGFX940] in {
1870 def _vi : FLAT_Real_vi<pre_gfx940_op, !cast<FLAT_Pseudo>(NAME), has_sccb> {
1871 let AsmString = pre_gfx940_name # !cast<FLAT_Pseudo>(NAME).AsmOperands # " lds";
1873 def _SADDR_vi : FLAT_Real_vi<pre_gfx940_op, !cast<FLAT_Pseudo>(NAME#"_SADDR"), has_sccb> {
1874 let AsmString = pre_gfx940_name # !cast<FLAT_Pseudo>(NAME#"_SADDR").AsmOperands # " lds";
1878 let SubtargetPredicate = isGFX940Plus in {
1879 def _gfx940 : FLAT_Real_gfx940<op, !cast<FLAT_Pseudo>(NAME)>;
1880 def _SADDR_gfx940 : FLAT_Real_gfx940<op, !cast<FLAT_Pseudo>(NAME#"_SADDR")>;
1884 multiclass FLAT_Real_AllAddr_SVE_LDS<bits<7> op, bits<7> pre_gfx940_op> {
1885 defm "" : FLAT_Real_AllAddr_LDS<op, pre_gfx940_op>;
1886 let SubtargetPredicate = isGFX940Plus in {
1887 def _SVS_gfx940 : FLAT_Real_gfx940<op, !cast<FLAT_Pseudo>(NAME#"_SVS")>;
1888 def _ST_gfx940 : FLAT_Real_gfx940<op, !cast<FLAT_Pseudo>(NAME#"_ST")>;
1892 def FLAT_LOAD_UBYTE_vi : FLAT_Real_vi <0x10, FLAT_LOAD_UBYTE>;
1893 def FLAT_LOAD_SBYTE_vi : FLAT_Real_vi <0x11, FLAT_LOAD_SBYTE>;
1894 def FLAT_LOAD_USHORT_vi : FLAT_Real_vi <0x12, FLAT_LOAD_USHORT>;
1895 def FLAT_LOAD_SSHORT_vi : FLAT_Real_vi <0x13, FLAT_LOAD_SSHORT>;
1896 def FLAT_LOAD_DWORD_vi : FLAT_Real_vi <0x14, FLAT_LOAD_DWORD>;
1897 def FLAT_LOAD_DWORDX2_vi : FLAT_Real_vi <0x15, FLAT_LOAD_DWORDX2>;
1898 def FLAT_LOAD_DWORDX4_vi : FLAT_Real_vi <0x17, FLAT_LOAD_DWORDX4>;
1899 def FLAT_LOAD_DWORDX3_vi : FLAT_Real_vi <0x16, FLAT_LOAD_DWORDX3>;
1901 def FLAT_STORE_BYTE_vi : FLAT_Real_vi <0x18, FLAT_STORE_BYTE>;
1902 def FLAT_STORE_BYTE_D16_HI_vi : FLAT_Real_vi <0x19, FLAT_STORE_BYTE_D16_HI>;
1903 def FLAT_STORE_SHORT_vi : FLAT_Real_vi <0x1a, FLAT_STORE_SHORT>;
1904 def FLAT_STORE_SHORT_D16_HI_vi : FLAT_Real_vi <0x1b, FLAT_STORE_SHORT_D16_HI>;
1905 def FLAT_STORE_DWORD_vi : FLAT_Real_vi <0x1c, FLAT_STORE_DWORD>;
1906 def FLAT_STORE_DWORDX2_vi : FLAT_Real_vi <0x1d, FLAT_STORE_DWORDX2>;
1907 def FLAT_STORE_DWORDX4_vi : FLAT_Real_vi <0x1f, FLAT_STORE_DWORDX4>;
1908 def FLAT_STORE_DWORDX3_vi : FLAT_Real_vi <0x1e, FLAT_STORE_DWORDX3>;
1910 def FLAT_LOAD_UBYTE_D16_vi : FLAT_Real_vi <0x20, FLAT_LOAD_UBYTE_D16>;
1911 def FLAT_LOAD_UBYTE_D16_HI_vi : FLAT_Real_vi <0x21, FLAT_LOAD_UBYTE_D16_HI>;
1912 def FLAT_LOAD_SBYTE_D16_vi : FLAT_Real_vi <0x22, FLAT_LOAD_SBYTE_D16>;
1913 def FLAT_LOAD_SBYTE_D16_HI_vi : FLAT_Real_vi <0x23, FLAT_LOAD_SBYTE_D16_HI>;
1914 def FLAT_LOAD_SHORT_D16_vi : FLAT_Real_vi <0x24, FLAT_LOAD_SHORT_D16>;
1915 def FLAT_LOAD_SHORT_D16_HI_vi : FLAT_Real_vi <0x25, FLAT_LOAD_SHORT_D16_HI>;
1917 multiclass FLAT_Real_Atomics_vi <bits<7> op,
1918 bit has_sccb = !cast<FLAT_Pseudo>(NAME).has_sccb> {
1919 defvar ps = !cast<FLAT_Pseudo>(NAME);
1920 def _vi : FLAT_Real_vi<op, !cast<FLAT_Pseudo>(ps.PseudoInstr), has_sccb>;
1921 def _RTN_vi : FLAT_Real_vi<op, !cast<FLAT_Pseudo>(ps.PseudoInstr # "_RTN"), has_sccb>;
1924 multiclass FLAT_Global_Real_Atomics_vi<bits<7> op,
1925 bit has_sccb = !cast<FLAT_Pseudo>(NAME).has_sccb> :
1926 FLAT_Real_AllAddr_vi<op, has_sccb> {
1927 def _RTN_vi : FLAT_Real_vi <op, !cast<FLAT_Pseudo>(NAME#"_RTN"), has_sccb>;
1928 def _SADDR_RTN_vi : FLAT_Real_vi <op, !cast<FLAT_Pseudo>(NAME#"_SADDR_RTN"), has_sccb>;
1932 defm FLAT_ATOMIC_SWAP : FLAT_Real_Atomics_vi <0x40>;
1933 defm FLAT_ATOMIC_CMPSWAP : FLAT_Real_Atomics_vi <0x41>;
1934 defm FLAT_ATOMIC_ADD : FLAT_Real_Atomics_vi <0x42>;
1935 defm FLAT_ATOMIC_SUB : FLAT_Real_Atomics_vi <0x43>;
1936 defm FLAT_ATOMIC_SMIN : FLAT_Real_Atomics_vi <0x44>;
1937 defm FLAT_ATOMIC_UMIN : FLAT_Real_Atomics_vi <0x45>;
1938 defm FLAT_ATOMIC_SMAX : FLAT_Real_Atomics_vi <0x46>;
1939 defm FLAT_ATOMIC_UMAX : FLAT_Real_Atomics_vi <0x47>;
1940 defm FLAT_ATOMIC_AND : FLAT_Real_Atomics_vi <0x48>;
1941 defm FLAT_ATOMIC_OR : FLAT_Real_Atomics_vi <0x49>;
1942 defm FLAT_ATOMIC_XOR : FLAT_Real_Atomics_vi <0x4a>;
1943 defm FLAT_ATOMIC_INC : FLAT_Real_Atomics_vi <0x4b>;
1944 defm FLAT_ATOMIC_DEC : FLAT_Real_Atomics_vi <0x4c>;
1945 defm FLAT_ATOMIC_SWAP_X2 : FLAT_Real_Atomics_vi <0x60>;
1946 defm FLAT_ATOMIC_CMPSWAP_X2 : FLAT_Real_Atomics_vi <0x61>;
1947 defm FLAT_ATOMIC_ADD_X2 : FLAT_Real_Atomics_vi <0x62>;
1948 defm FLAT_ATOMIC_SUB_X2 : FLAT_Real_Atomics_vi <0x63>;
1949 defm FLAT_ATOMIC_SMIN_X2 : FLAT_Real_Atomics_vi <0x64>;
1950 defm FLAT_ATOMIC_UMIN_X2 : FLAT_Real_Atomics_vi <0x65>;
1951 defm FLAT_ATOMIC_SMAX_X2 : FLAT_Real_Atomics_vi <0x66>;
1952 defm FLAT_ATOMIC_UMAX_X2 : FLAT_Real_Atomics_vi <0x67>;
1953 defm FLAT_ATOMIC_AND_X2 : FLAT_Real_Atomics_vi <0x68>;
1954 defm FLAT_ATOMIC_OR_X2 : FLAT_Real_Atomics_vi <0x69>;
1955 defm FLAT_ATOMIC_XOR_X2 : FLAT_Real_Atomics_vi <0x6a>;
1956 defm FLAT_ATOMIC_INC_X2 : FLAT_Real_Atomics_vi <0x6b>;
1957 defm FLAT_ATOMIC_DEC_X2 : FLAT_Real_Atomics_vi <0x6c>;
1959 defm GLOBAL_LOAD_UBYTE : FLAT_Real_AllAddr_vi <0x10>;
1960 defm GLOBAL_LOAD_SBYTE : FLAT_Real_AllAddr_vi <0x11>;
1961 defm GLOBAL_LOAD_USHORT : FLAT_Real_AllAddr_vi <0x12>;
1962 defm GLOBAL_LOAD_SSHORT : FLAT_Real_AllAddr_vi <0x13>;
1963 defm GLOBAL_LOAD_DWORD : FLAT_Real_AllAddr_vi <0x14>;
1964 defm GLOBAL_LOAD_DWORDX2 : FLAT_Real_AllAddr_vi <0x15>;
1965 defm GLOBAL_LOAD_DWORDX3 : FLAT_Real_AllAddr_vi <0x16>;
1966 defm GLOBAL_LOAD_DWORDX4 : FLAT_Real_AllAddr_vi <0x17>;
1968 defm GLOBAL_LOAD_UBYTE_D16 : FLAT_Real_AllAddr_vi <0x20>;
1969 defm GLOBAL_LOAD_UBYTE_D16_HI : FLAT_Real_AllAddr_vi <0x21>;
1970 defm GLOBAL_LOAD_SBYTE_D16 : FLAT_Real_AllAddr_vi <0x22>;
1971 defm GLOBAL_LOAD_SBYTE_D16_HI : FLAT_Real_AllAddr_vi <0x23>;
1972 defm GLOBAL_LOAD_SHORT_D16 : FLAT_Real_AllAddr_vi <0x24>;
1973 defm GLOBAL_LOAD_SHORT_D16_HI : FLAT_Real_AllAddr_vi <0x25>;
1975 defm GLOBAL_STORE_BYTE : FLAT_Real_AllAddr_vi <0x18>;
1976 defm GLOBAL_STORE_BYTE_D16_HI : FLAT_Real_AllAddr_vi <0x19>;
1977 defm GLOBAL_STORE_SHORT : FLAT_Real_AllAddr_vi <0x1a>;
1978 defm GLOBAL_STORE_SHORT_D16_HI : FLAT_Real_AllAddr_vi <0x1b>;
1979 defm GLOBAL_STORE_DWORD : FLAT_Real_AllAddr_vi <0x1c>;
1980 defm GLOBAL_STORE_DWORDX2 : FLAT_Real_AllAddr_vi <0x1d>;
1981 defm GLOBAL_STORE_DWORDX3 : FLAT_Real_AllAddr_vi <0x1e>;
1982 defm GLOBAL_STORE_DWORDX4 : FLAT_Real_AllAddr_vi <0x1f>;
1984 defm GLOBAL_LOAD_LDS_UBYTE : FLAT_Real_AllAddr_LDS <0x026, 0x10>;
1985 defm GLOBAL_LOAD_LDS_SBYTE : FLAT_Real_AllAddr_LDS <0x027, 0x11>;
1986 defm GLOBAL_LOAD_LDS_USHORT : FLAT_Real_AllAddr_LDS <0x028, 0x12>;
1987 defm GLOBAL_LOAD_LDS_SSHORT : FLAT_Real_AllAddr_LDS <0x029, 0x13>;
1988 defm GLOBAL_LOAD_LDS_DWORD : FLAT_Real_AllAddr_LDS <0x02a, 0x14>;
1990 defm GLOBAL_ATOMIC_SWAP : FLAT_Global_Real_Atomics_vi <0x40>;
1991 defm GLOBAL_ATOMIC_CMPSWAP : FLAT_Global_Real_Atomics_vi <0x41>;
1992 defm GLOBAL_ATOMIC_ADD : FLAT_Global_Real_Atomics_vi <0x42>;
1993 defm GLOBAL_ATOMIC_SUB : FLAT_Global_Real_Atomics_vi <0x43>;
1994 defm GLOBAL_ATOMIC_SMIN : FLAT_Global_Real_Atomics_vi <0x44>;
1995 defm GLOBAL_ATOMIC_UMIN : FLAT_Global_Real_Atomics_vi <0x45>;
1996 defm GLOBAL_ATOMIC_SMAX : FLAT_Global_Real_Atomics_vi <0x46>;
1997 defm GLOBAL_ATOMIC_UMAX : FLAT_Global_Real_Atomics_vi <0x47>;
1998 defm GLOBAL_ATOMIC_AND : FLAT_Global_Real_Atomics_vi <0x48>;
1999 defm GLOBAL_ATOMIC_OR : FLAT_Global_Real_Atomics_vi <0x49>;
2000 defm GLOBAL_ATOMIC_XOR : FLAT_Global_Real_Atomics_vi <0x4a>;
2001 defm GLOBAL_ATOMIC_INC : FLAT_Global_Real_Atomics_vi <0x4b>;
2002 defm GLOBAL_ATOMIC_DEC : FLAT_Global_Real_Atomics_vi <0x4c>;
2003 defm GLOBAL_ATOMIC_SWAP_X2 : FLAT_Global_Real_Atomics_vi <0x60>;
2004 defm GLOBAL_ATOMIC_CMPSWAP_X2 : FLAT_Global_Real_Atomics_vi <0x61>;
2005 defm GLOBAL_ATOMIC_ADD_X2 : FLAT_Global_Real_Atomics_vi <0x62>;
2006 defm GLOBAL_ATOMIC_SUB_X2 : FLAT_Global_Real_Atomics_vi <0x63>;
2007 defm GLOBAL_ATOMIC_SMIN_X2 : FLAT_Global_Real_Atomics_vi <0x64>;
2008 defm GLOBAL_ATOMIC_UMIN_X2 : FLAT_Global_Real_Atomics_vi <0x65>;
2009 defm GLOBAL_ATOMIC_SMAX_X2 : FLAT_Global_Real_Atomics_vi <0x66>;
2010 defm GLOBAL_ATOMIC_UMAX_X2 : FLAT_Global_Real_Atomics_vi <0x67>;
2011 defm GLOBAL_ATOMIC_AND_X2 : FLAT_Global_Real_Atomics_vi <0x68>;
2012 defm GLOBAL_ATOMIC_OR_X2 : FLAT_Global_Real_Atomics_vi <0x69>;
2013 defm GLOBAL_ATOMIC_XOR_X2 : FLAT_Global_Real_Atomics_vi <0x6a>;
2014 defm GLOBAL_ATOMIC_INC_X2 : FLAT_Global_Real_Atomics_vi <0x6b>;
2015 defm GLOBAL_ATOMIC_DEC_X2 : FLAT_Global_Real_Atomics_vi <0x6c>;
2017 defm SCRATCH_LOAD_LDS_UBYTE : FLAT_Real_AllAddr_SVE_LDS <0x026, 0x10>;
2018 defm SCRATCH_LOAD_LDS_SBYTE : FLAT_Real_AllAddr_SVE_LDS <0x027, 0x11>;
2019 defm SCRATCH_LOAD_LDS_USHORT : FLAT_Real_AllAddr_SVE_LDS <0x028, 0x12>;
2020 defm SCRATCH_LOAD_LDS_SSHORT : FLAT_Real_AllAddr_SVE_LDS <0x029, 0x13>;
2021 defm SCRATCH_LOAD_LDS_DWORD : FLAT_Real_AllAddr_SVE_LDS <0x02a, 0x14>;
2023 defm SCRATCH_LOAD_UBYTE : FLAT_Real_AllAddr_SVE_vi <0x10>;
2024 defm SCRATCH_LOAD_SBYTE : FLAT_Real_AllAddr_SVE_vi <0x11>;
2025 defm SCRATCH_LOAD_USHORT : FLAT_Real_AllAddr_SVE_vi <0x12>;
2026 defm SCRATCH_LOAD_SSHORT : FLAT_Real_AllAddr_SVE_vi <0x13>;
2027 defm SCRATCH_LOAD_DWORD : FLAT_Real_AllAddr_SVE_vi <0x14>;
2028 defm SCRATCH_LOAD_DWORDX2 : FLAT_Real_AllAddr_SVE_vi <0x15>;
2029 defm SCRATCH_LOAD_DWORDX3 : FLAT_Real_AllAddr_SVE_vi <0x16>;
2030 defm SCRATCH_LOAD_DWORDX4 : FLAT_Real_AllAddr_SVE_vi <0x17>;
2031 defm SCRATCH_STORE_BYTE : FLAT_Real_AllAddr_SVE_vi <0x18>;
2032 defm SCRATCH_STORE_BYTE_D16_HI : FLAT_Real_AllAddr_SVE_vi <0x19>;
2033 defm SCRATCH_LOAD_UBYTE_D16 : FLAT_Real_AllAddr_SVE_vi <0x20>;
2034 defm SCRATCH_LOAD_UBYTE_D16_HI : FLAT_Real_AllAddr_SVE_vi <0x21>;
2035 defm SCRATCH_LOAD_SBYTE_D16 : FLAT_Real_AllAddr_SVE_vi <0x22>;
2036 defm SCRATCH_LOAD_SBYTE_D16_HI : FLAT_Real_AllAddr_SVE_vi <0x23>;
2037 defm SCRATCH_LOAD_SHORT_D16 : FLAT_Real_AllAddr_SVE_vi <0x24>;
2038 defm SCRATCH_LOAD_SHORT_D16_HI : FLAT_Real_AllAddr_SVE_vi <0x25>;
2039 defm SCRATCH_STORE_SHORT : FLAT_Real_AllAddr_SVE_vi <0x1a>;
2040 defm SCRATCH_STORE_SHORT_D16_HI : FLAT_Real_AllAddr_SVE_vi <0x1b>;
2041 defm SCRATCH_STORE_DWORD : FLAT_Real_AllAddr_SVE_vi <0x1c>;
2042 defm SCRATCH_STORE_DWORDX2 : FLAT_Real_AllAddr_SVE_vi <0x1d>;
2043 defm SCRATCH_STORE_DWORDX3 : FLAT_Real_AllAddr_SVE_vi <0x1e>;
2044 defm SCRATCH_STORE_DWORDX4 : FLAT_Real_AllAddr_SVE_vi <0x1f>;
2046 let SubtargetPredicate = isGFX8GFX9NotGFX940 in {
2047 // These instructions are encoded differently on gfx90* and gfx940.
2048 defm GLOBAL_ATOMIC_ADD_F32 : FLAT_Global_Real_Atomics_vi <0x04d, 0>;
2049 defm GLOBAL_ATOMIC_PK_ADD_F16 : FLAT_Global_Real_Atomics_vi <0x04e, 0>;
2052 let SubtargetPredicate = isGFX90AOnly in {
2053 defm FLAT_ATOMIC_ADD_F64 : FLAT_Real_Atomics_vi<0x4f, 0>;
2054 defm FLAT_ATOMIC_MIN_F64 : FLAT_Real_Atomics_vi<0x50, 0>;
2055 defm FLAT_ATOMIC_MAX_F64 : FLAT_Real_Atomics_vi<0x51, 0>;
2056 defm GLOBAL_ATOMIC_ADD_F64 : FLAT_Global_Real_Atomics_vi<0x4f, 0>;
2057 defm GLOBAL_ATOMIC_MIN_F64 : FLAT_Global_Real_Atomics_vi<0x50, 0>;
2058 defm GLOBAL_ATOMIC_MAX_F64 : FLAT_Global_Real_Atomics_vi<0x51, 0>;
2059 } // End SubtargetPredicate = isGFX90AOnly
2061 multiclass FLAT_Real_AllAddr_gfx940<bits<7> op> {
2062 def _gfx940 : FLAT_Real_gfx940<op, !cast<FLAT_Pseudo>(NAME)>;
2063 def _SADDR_gfx940 : FLAT_Real_gfx940<op, !cast<FLAT_Pseudo>(NAME#"_SADDR")>;
2066 multiclass FLAT_Real_Atomics_gfx940 <bits<7> op> {
2067 defvar ps = !cast<FLAT_Pseudo>(NAME);
2068 def _gfx940 : FLAT_Real_gfx940<op, !cast<FLAT_Pseudo>(ps.PseudoInstr)>;
2069 def _RTN_gfx940 : FLAT_Real_gfx940<op, !cast<FLAT_Pseudo>(ps.PseudoInstr # "_RTN")>;
2072 multiclass FLAT_Global_Real_Atomics_gfx940<bits<7> op> :
2073 FLAT_Real_AllAddr_gfx940<op> {
2074 def _RTN_gfx940 : FLAT_Real_gfx940 <op, !cast<FLAT_Pseudo>(NAME#"_RTN")>;
2075 def _SADDR_RTN_gfx940 : FLAT_Real_gfx940 <op, !cast<FLAT_Pseudo>(NAME#"_SADDR_RTN")>;
2078 let SubtargetPredicate = isGFX940Plus in {
2079 // These instructions are encoded differently on gfx90* and gfx940.
2080 defm GLOBAL_ATOMIC_ADD_F32 : FLAT_Global_Real_Atomics_gfx940 <0x04d>;
2081 defm GLOBAL_ATOMIC_PK_ADD_F16 : FLAT_Global_Real_Atomics_gfx940 <0x04e>;
2083 defm FLAT_ATOMIC_ADD_F64 : FLAT_Real_Atomics_gfx940<0x4f>;
2084 defm FLAT_ATOMIC_MIN_F64 : FLAT_Real_Atomics_gfx940<0x50>;
2085 defm FLAT_ATOMIC_MAX_F64 : FLAT_Real_Atomics_gfx940<0x51>;
2086 defm GLOBAL_ATOMIC_ADD_F64 : FLAT_Global_Real_Atomics_gfx940<0x4f>;
2087 defm GLOBAL_ATOMIC_MIN_F64 : FLAT_Global_Real_Atomics_gfx940<0x50>;
2088 defm GLOBAL_ATOMIC_MAX_F64 : FLAT_Global_Real_Atomics_gfx940<0x51>;
2089 defm FLAT_ATOMIC_ADD_F32 : FLAT_Real_Atomics_vi<0x4d>;
2090 defm FLAT_ATOMIC_PK_ADD_F16 : FLAT_Real_Atomics_vi<0x4e>;
2091 defm FLAT_ATOMIC_PK_ADD_BF16 : FLAT_Real_Atomics_vi<0x52>;
2092 defm GLOBAL_ATOMIC_PK_ADD_BF16 : FLAT_Global_Real_Atomics_vi<0x52>;
2093 } // End SubtargetPredicate = isGFX940Plus
2095 //===----------------------------------------------------------------------===//
2097 //===----------------------------------------------------------------------===//
2099 class FLAT_Real_gfx10<bits<7> op, FLAT_Pseudo ps, string opName = ps.Mnemonic> :
2100 FLAT_Real<op, ps, opName>, SIMCInstr<ps.PseudoInstr, SIEncodingFamily.GFX10> {
2101 let AssemblerPredicate = isGFX10Only;
2102 let DecoderNamespace = "GFX10";
2104 let Inst{11-0} = offset{11-0};
2105 let Inst{12} = !if(ps.has_dlc, cpol{CPolBit.DLC}, ps.dlcValue);
2106 let Inst{54-48} = !cond(ps.enabled_saddr : saddr,
2107 !and(ps.is_flat_scratch, !not(ps.has_vaddr)) : EXEC_HI.Index{6-0}, // ST mode
2108 true : SGPR_NULL_gfxpre11.Index{6-0});
2112 multiclass FLAT_Real_Base_gfx10<bits<7> op, string psName = NAME,
2113 string asmName = !cast<FLAT_Pseudo>(psName).Mnemonic> {
2115 FLAT_Real_gfx10<op, !cast<FLAT_Pseudo>(psName), asmName>;
2118 multiclass FLAT_Real_RTN_gfx10<bits<7> op, string psName = NAME,
2119 string asmName = !cast<FLAT_Pseudo>(psName).Mnemonic> {
2121 FLAT_Real_gfx10<op, !cast<FLAT_Pseudo>(psName#"_RTN"), asmName>;
2124 multiclass FLAT_Real_SADDR_gfx10<bits<7> op, string psName = NAME,
2125 string asmName = !cast<FLAT_Pseudo>(psName#"_SADDR").Mnemonic> {
2127 FLAT_Real_gfx10<op, !cast<FLAT_Pseudo>(psName#"_SADDR"), asmName>;
2130 multiclass FLAT_Real_SADDR_RTN_gfx10<bits<7> op, string psName = NAME,
2131 string asmName = !cast<FLAT_Pseudo>(psName#"_SADDR_RTN").Mnemonic> {
2132 def _SADDR_RTN_gfx10 :
2133 FLAT_Real_gfx10<op, !cast<FLAT_Pseudo>(psName#"_SADDR_RTN"), asmName>;
2136 multiclass FLAT_Real_ST_gfx10<bits<7> op> {
2138 FLAT_Real_gfx10<op, !cast<FLAT_Pseudo>(NAME#"_ST")>;
2141 multiclass FLAT_Real_AllAddr_gfx10<bits<7> op, string OpName = NAME,
2142 string asmName = !cast<FLAT_Pseudo>(OpName).Mnemonic> :
2143 FLAT_Real_Base_gfx10<op, OpName, asmName>,
2144 FLAT_Real_SADDR_gfx10<op, OpName, asmName>;
2146 multiclass FLAT_Real_Atomics_gfx10<bits<7> op, string OpName = NAME,
2147 string asmName = !cast<FLAT_Pseudo>(OpName).Mnemonic> :
2148 FLAT_Real_Base_gfx10<op, OpName, asmName>,
2149 FLAT_Real_RTN_gfx10<op, OpName, asmName>;
2151 multiclass FLAT_Real_GlblAtomics_gfx10<bits<7> op, string OpName = NAME,
2152 string asmName = !cast<FLAT_Pseudo>(OpName).Mnemonic> :
2153 FLAT_Real_AllAddr_gfx10<op, OpName, asmName>,
2154 FLAT_Real_RTN_gfx10<op, OpName, asmName>,
2155 FLAT_Real_SADDR_RTN_gfx10<op, OpName, asmName>;
2157 multiclass FLAT_Real_GlblAtomics_RTN_gfx10<bits<7> op, string OpName = NAME> :
2158 FLAT_Real_RTN_gfx10<op, OpName>,
2159 FLAT_Real_SADDR_RTN_gfx10<op, OpName>;
2161 multiclass FLAT_Real_ScratchAllAddr_gfx10<bits<7> op> :
2162 FLAT_Real_Base_gfx10<op>,
2163 FLAT_Real_SADDR_gfx10<op>,
2164 FLAT_Real_ST_gfx10<op>;
2166 multiclass FLAT_Real_AllAddr_LDS_gfx10<bits<7> op,
2167 string opname = !subst("_lds", "", !cast<FLAT_Pseudo>(NAME).Mnemonic)> {
2168 let AsmString = opname # !cast<FLAT_Pseudo>(NAME).AsmOperands # " lds" in
2169 defm "" : FLAT_Real_Base_gfx10<op>;
2171 let AsmString = opname # !cast<FLAT_Pseudo>(NAME#"_SADDR").AsmOperands # " lds" in
2172 defm "" : FLAT_Real_SADDR_gfx10<op>;
2175 multiclass FLAT_Real_ScratchAllAddr_LDS_gfx10<bits<7> op,
2176 string opname = !subst("_lds", "", !cast<FLAT_Pseudo>(NAME).Mnemonic)> {
2177 defm "" : FLAT_Real_AllAddr_LDS_gfx10<op>;
2179 let AsmString = opname # !cast<FLAT_Pseudo>(NAME#"_ST").AsmOperands # " lds" in
2180 defm "" : FLAT_Real_ST_gfx10<op>;
2184 defm FLAT_LOAD_UBYTE : FLAT_Real_Base_gfx10<0x008>;
2185 defm FLAT_LOAD_SBYTE : FLAT_Real_Base_gfx10<0x009>;
2186 defm FLAT_LOAD_USHORT : FLAT_Real_Base_gfx10<0x00a>;
2187 defm FLAT_LOAD_SSHORT : FLAT_Real_Base_gfx10<0x00b>;
2188 defm FLAT_LOAD_DWORD : FLAT_Real_Base_gfx10<0x00c>;
2189 defm FLAT_LOAD_DWORDX2 : FLAT_Real_Base_gfx10<0x00d>;
2190 defm FLAT_LOAD_DWORDX4 : FLAT_Real_Base_gfx10<0x00e>;
2191 defm FLAT_LOAD_DWORDX3 : FLAT_Real_Base_gfx10<0x00f>;
2192 defm FLAT_STORE_BYTE : FLAT_Real_Base_gfx10<0x018>;
2193 defm FLAT_STORE_BYTE_D16_HI : FLAT_Real_Base_gfx10<0x019>;
2194 defm FLAT_STORE_SHORT : FLAT_Real_Base_gfx10<0x01a>;
2195 defm FLAT_STORE_SHORT_D16_HI : FLAT_Real_Base_gfx10<0x01b>;
2196 defm FLAT_STORE_DWORD : FLAT_Real_Base_gfx10<0x01c>;
2197 defm FLAT_STORE_DWORDX2 : FLAT_Real_Base_gfx10<0x01d>;
2198 defm FLAT_STORE_DWORDX4 : FLAT_Real_Base_gfx10<0x01e>;
2199 defm FLAT_STORE_DWORDX3 : FLAT_Real_Base_gfx10<0x01f>;
2200 defm FLAT_LOAD_UBYTE_D16 : FLAT_Real_Base_gfx10<0x020>;
2201 defm FLAT_LOAD_UBYTE_D16_HI : FLAT_Real_Base_gfx10<0x021>;
2202 defm FLAT_LOAD_SBYTE_D16 : FLAT_Real_Base_gfx10<0x022>;
2203 defm FLAT_LOAD_SBYTE_D16_HI : FLAT_Real_Base_gfx10<0x023>;
2204 defm FLAT_LOAD_SHORT_D16 : FLAT_Real_Base_gfx10<0x024>;
2205 defm FLAT_LOAD_SHORT_D16_HI : FLAT_Real_Base_gfx10<0x025>;
2206 defm FLAT_ATOMIC_SWAP : FLAT_Real_Atomics_gfx10<0x030>;
2207 defm FLAT_ATOMIC_CMPSWAP : FLAT_Real_Atomics_gfx10<0x031>;
2208 defm FLAT_ATOMIC_ADD : FLAT_Real_Atomics_gfx10<0x032>;
2209 defm FLAT_ATOMIC_SUB : FLAT_Real_Atomics_gfx10<0x033>;
2210 defm FLAT_ATOMIC_SMIN : FLAT_Real_Atomics_gfx10<0x035>;
2211 defm FLAT_ATOMIC_UMIN : FLAT_Real_Atomics_gfx10<0x036>;
2212 defm FLAT_ATOMIC_SMAX : FLAT_Real_Atomics_gfx10<0x037>;
2213 defm FLAT_ATOMIC_UMAX : FLAT_Real_Atomics_gfx10<0x038>;
2214 defm FLAT_ATOMIC_AND : FLAT_Real_Atomics_gfx10<0x039>;
2215 defm FLAT_ATOMIC_OR : FLAT_Real_Atomics_gfx10<0x03a>;
2216 defm FLAT_ATOMIC_XOR : FLAT_Real_Atomics_gfx10<0x03b>;
2217 defm FLAT_ATOMIC_INC : FLAT_Real_Atomics_gfx10<0x03c>;
2218 defm FLAT_ATOMIC_DEC : FLAT_Real_Atomics_gfx10<0x03d>;
2219 defm FLAT_ATOMIC_FCMPSWAP : FLAT_Real_Atomics_gfx10<0x03e>;
2220 defm FLAT_ATOMIC_FMIN : FLAT_Real_Atomics_gfx10<0x03f>;
2221 defm FLAT_ATOMIC_FMAX : FLAT_Real_Atomics_gfx10<0x040>;
2222 defm FLAT_ATOMIC_SWAP_X2 : FLAT_Real_Atomics_gfx10<0x050>;
2223 defm FLAT_ATOMIC_CMPSWAP_X2 : FLAT_Real_Atomics_gfx10<0x051>;
2224 defm FLAT_ATOMIC_ADD_X2 : FLAT_Real_Atomics_gfx10<0x052>;
2225 defm FLAT_ATOMIC_SUB_X2 : FLAT_Real_Atomics_gfx10<0x053>;
2226 defm FLAT_ATOMIC_SMIN_X2 : FLAT_Real_Atomics_gfx10<0x055>;
2227 defm FLAT_ATOMIC_UMIN_X2 : FLAT_Real_Atomics_gfx10<0x056>;
2228 defm FLAT_ATOMIC_SMAX_X2 : FLAT_Real_Atomics_gfx10<0x057>;
2229 defm FLAT_ATOMIC_UMAX_X2 : FLAT_Real_Atomics_gfx10<0x058>;
2230 defm FLAT_ATOMIC_AND_X2 : FLAT_Real_Atomics_gfx10<0x059>;
2231 defm FLAT_ATOMIC_OR_X2 : FLAT_Real_Atomics_gfx10<0x05a>;
2232 defm FLAT_ATOMIC_XOR_X2 : FLAT_Real_Atomics_gfx10<0x05b>;
2233 defm FLAT_ATOMIC_INC_X2 : FLAT_Real_Atomics_gfx10<0x05c>;
2234 defm FLAT_ATOMIC_DEC_X2 : FLAT_Real_Atomics_gfx10<0x05d>;
2235 defm FLAT_ATOMIC_FCMPSWAP_X2 : FLAT_Real_Atomics_gfx10<0x05e>;
2236 defm FLAT_ATOMIC_FMIN_X2 : FLAT_Real_Atomics_gfx10<0x05f, "FLAT_ATOMIC_MIN_F64", "flat_atomic_fmin_x2">;
2237 defm FLAT_ATOMIC_FMAX_X2 : FLAT_Real_Atomics_gfx10<0x060, "FLAT_ATOMIC_MAX_F64", "flat_atomic_fmax_x2">;
2241 defm GLOBAL_LOAD_UBYTE : FLAT_Real_AllAddr_gfx10<0x008>;
2242 defm GLOBAL_LOAD_SBYTE : FLAT_Real_AllAddr_gfx10<0x009>;
2243 defm GLOBAL_LOAD_USHORT : FLAT_Real_AllAddr_gfx10<0x00a>;
2244 defm GLOBAL_LOAD_SSHORT : FLAT_Real_AllAddr_gfx10<0x00b>;
2245 defm GLOBAL_LOAD_DWORD : FLAT_Real_AllAddr_gfx10<0x00c>;
2246 defm GLOBAL_LOAD_DWORDX2 : FLAT_Real_AllAddr_gfx10<0x00d>;
2247 defm GLOBAL_LOAD_DWORDX4 : FLAT_Real_AllAddr_gfx10<0x00e>;
2248 defm GLOBAL_LOAD_DWORDX3 : FLAT_Real_AllAddr_gfx10<0x00f>;
2249 defm GLOBAL_STORE_BYTE : FLAT_Real_AllAddr_gfx10<0x018>;
2250 defm GLOBAL_STORE_BYTE_D16_HI : FLAT_Real_AllAddr_gfx10<0x019>;
2251 defm GLOBAL_STORE_SHORT : FLAT_Real_AllAddr_gfx10<0x01a>;
2252 defm GLOBAL_STORE_SHORT_D16_HI : FLAT_Real_AllAddr_gfx10<0x01b>;
2253 defm GLOBAL_STORE_DWORD : FLAT_Real_AllAddr_gfx10<0x01c>;
2254 defm GLOBAL_STORE_DWORDX2 : FLAT_Real_AllAddr_gfx10<0x01d>;
2255 defm GLOBAL_STORE_DWORDX4 : FLAT_Real_AllAddr_gfx10<0x01e>;
2256 defm GLOBAL_STORE_DWORDX3 : FLAT_Real_AllAddr_gfx10<0x01f>;
2257 defm GLOBAL_LOAD_UBYTE_D16 : FLAT_Real_AllAddr_gfx10<0x020>;
2258 defm GLOBAL_LOAD_UBYTE_D16_HI : FLAT_Real_AllAddr_gfx10<0x021>;
2259 defm GLOBAL_LOAD_SBYTE_D16 : FLAT_Real_AllAddr_gfx10<0x022>;
2260 defm GLOBAL_LOAD_SBYTE_D16_HI : FLAT_Real_AllAddr_gfx10<0x023>;
2261 defm GLOBAL_LOAD_SHORT_D16 : FLAT_Real_AllAddr_gfx10<0x024>;
2262 defm GLOBAL_LOAD_SHORT_D16_HI : FLAT_Real_AllAddr_gfx10<0x025>;
2263 defm GLOBAL_ATOMIC_SWAP : FLAT_Real_GlblAtomics_gfx10<0x030>;
2264 defm GLOBAL_ATOMIC_CMPSWAP : FLAT_Real_GlblAtomics_gfx10<0x031>;
2265 defm GLOBAL_ATOMIC_ADD : FLAT_Real_GlblAtomics_gfx10<0x032>;
2266 defm GLOBAL_ATOMIC_SUB : FLAT_Real_GlblAtomics_gfx10<0x033>;
2267 defm GLOBAL_ATOMIC_CSUB : FLAT_Real_GlblAtomics_gfx10<0x034>;
2268 defm GLOBAL_ATOMIC_SMIN : FLAT_Real_GlblAtomics_gfx10<0x035>;
2269 defm GLOBAL_ATOMIC_UMIN : FLAT_Real_GlblAtomics_gfx10<0x036>;
2270 defm GLOBAL_ATOMIC_SMAX : FLAT_Real_GlblAtomics_gfx10<0x037>;
2271 defm GLOBAL_ATOMIC_UMAX : FLAT_Real_GlblAtomics_gfx10<0x038>;
2272 defm GLOBAL_ATOMIC_AND : FLAT_Real_GlblAtomics_gfx10<0x039>;
2273 defm GLOBAL_ATOMIC_OR : FLAT_Real_GlblAtomics_gfx10<0x03a>;
2274 defm GLOBAL_ATOMIC_XOR : FLAT_Real_GlblAtomics_gfx10<0x03b>;
2275 defm GLOBAL_ATOMIC_INC : FLAT_Real_GlblAtomics_gfx10<0x03c>;
2276 defm GLOBAL_ATOMIC_DEC : FLAT_Real_GlblAtomics_gfx10<0x03d>;
2277 defm GLOBAL_ATOMIC_FCMPSWAP : FLAT_Real_GlblAtomics_gfx10<0x03e>;
2278 defm GLOBAL_ATOMIC_FMIN : FLAT_Real_GlblAtomics_gfx10<0x03f>;
2279 defm GLOBAL_ATOMIC_FMAX : FLAT_Real_GlblAtomics_gfx10<0x040>;
2280 defm GLOBAL_ATOMIC_SWAP_X2 : FLAT_Real_GlblAtomics_gfx10<0x050>;
2281 defm GLOBAL_ATOMIC_CMPSWAP_X2 : FLAT_Real_GlblAtomics_gfx10<0x051>;
2282 defm GLOBAL_ATOMIC_ADD_X2 : FLAT_Real_GlblAtomics_gfx10<0x052>;
2283 defm GLOBAL_ATOMIC_SUB_X2 : FLAT_Real_GlblAtomics_gfx10<0x053>;
2284 defm GLOBAL_ATOMIC_SMIN_X2 : FLAT_Real_GlblAtomics_gfx10<0x055>;
2285 defm GLOBAL_ATOMIC_UMIN_X2 : FLAT_Real_GlblAtomics_gfx10<0x056>;
2286 defm GLOBAL_ATOMIC_SMAX_X2 : FLAT_Real_GlblAtomics_gfx10<0x057>;
2287 defm GLOBAL_ATOMIC_UMAX_X2 : FLAT_Real_GlblAtomics_gfx10<0x058>;
2288 defm GLOBAL_ATOMIC_AND_X2 : FLAT_Real_GlblAtomics_gfx10<0x059>;
2289 defm GLOBAL_ATOMIC_OR_X2 : FLAT_Real_GlblAtomics_gfx10<0x05a>;
2290 defm GLOBAL_ATOMIC_XOR_X2 : FLAT_Real_GlblAtomics_gfx10<0x05b>;
2291 defm GLOBAL_ATOMIC_INC_X2 : FLAT_Real_GlblAtomics_gfx10<0x05c>;
2292 defm GLOBAL_ATOMIC_DEC_X2 : FLAT_Real_GlblAtomics_gfx10<0x05d>;
2293 defm GLOBAL_ATOMIC_FCMPSWAP_X2 : FLAT_Real_GlblAtomics_gfx10<0x05e>;
2294 defm GLOBAL_ATOMIC_FMIN_X2 : FLAT_Real_GlblAtomics_gfx10<0x05f, "GLOBAL_ATOMIC_MIN_F64", "global_atomic_fmin_x2">;
2295 defm GLOBAL_ATOMIC_FMAX_X2 : FLAT_Real_GlblAtomics_gfx10<0x060, "GLOBAL_ATOMIC_MAX_F64", "global_atomic_fmax_x2">;
2296 defm GLOBAL_LOAD_DWORD_ADDTID : FLAT_Real_AllAddr_gfx10<0x016>;
2297 defm GLOBAL_STORE_DWORD_ADDTID : FLAT_Real_AllAddr_gfx10<0x017>;
2299 defm GLOBAL_LOAD_LDS_UBYTE : FLAT_Real_AllAddr_LDS_gfx10 <0x008>;
2300 defm GLOBAL_LOAD_LDS_SBYTE : FLAT_Real_AllAddr_LDS_gfx10 <0x009>;
2301 defm GLOBAL_LOAD_LDS_USHORT : FLAT_Real_AllAddr_LDS_gfx10 <0x00a>;
2302 defm GLOBAL_LOAD_LDS_SSHORT : FLAT_Real_AllAddr_LDS_gfx10 <0x00b>;
2303 defm GLOBAL_LOAD_LDS_DWORD : FLAT_Real_AllAddr_LDS_gfx10 <0x00c>;
2305 // ENC_FLAT_SCRATCH.
2306 defm SCRATCH_LOAD_UBYTE : FLAT_Real_ScratchAllAddr_gfx10<0x008>;
2307 defm SCRATCH_LOAD_SBYTE : FLAT_Real_ScratchAllAddr_gfx10<0x009>;
2308 defm SCRATCH_LOAD_USHORT : FLAT_Real_ScratchAllAddr_gfx10<0x00a>;
2309 defm SCRATCH_LOAD_SSHORT : FLAT_Real_ScratchAllAddr_gfx10<0x00b>;
2310 defm SCRATCH_LOAD_DWORD : FLAT_Real_ScratchAllAddr_gfx10<0x00c>;
2311 defm SCRATCH_LOAD_DWORDX2 : FLAT_Real_ScratchAllAddr_gfx10<0x00d>;
2312 defm SCRATCH_LOAD_DWORDX4 : FLAT_Real_ScratchAllAddr_gfx10<0x00e>;
2313 defm SCRATCH_LOAD_DWORDX3 : FLAT_Real_ScratchAllAddr_gfx10<0x00f>;
2314 defm SCRATCH_STORE_BYTE : FLAT_Real_ScratchAllAddr_gfx10<0x018>;
2315 defm SCRATCH_STORE_BYTE_D16_HI : FLAT_Real_ScratchAllAddr_gfx10<0x019>;
2316 defm SCRATCH_STORE_SHORT : FLAT_Real_ScratchAllAddr_gfx10<0x01a>;
2317 defm SCRATCH_STORE_SHORT_D16_HI : FLAT_Real_ScratchAllAddr_gfx10<0x01b>;
2318 defm SCRATCH_STORE_DWORD : FLAT_Real_ScratchAllAddr_gfx10<0x01c>;
2319 defm SCRATCH_STORE_DWORDX2 : FLAT_Real_ScratchAllAddr_gfx10<0x01d>;
2320 defm SCRATCH_STORE_DWORDX4 : FLAT_Real_ScratchAllAddr_gfx10<0x01e>;
2321 defm SCRATCH_STORE_DWORDX3 : FLAT_Real_ScratchAllAddr_gfx10<0x01f>;
2322 defm SCRATCH_LOAD_UBYTE_D16 : FLAT_Real_ScratchAllAddr_gfx10<0x020>;
2323 defm SCRATCH_LOAD_UBYTE_D16_HI : FLAT_Real_ScratchAllAddr_gfx10<0x021>;
2324 defm SCRATCH_LOAD_SBYTE_D16 : FLAT_Real_ScratchAllAddr_gfx10<0x022>;
2325 defm SCRATCH_LOAD_SBYTE_D16_HI : FLAT_Real_ScratchAllAddr_gfx10<0x023>;
2326 defm SCRATCH_LOAD_SHORT_D16 : FLAT_Real_ScratchAllAddr_gfx10<0x024>;
2327 defm SCRATCH_LOAD_SHORT_D16_HI : FLAT_Real_ScratchAllAddr_gfx10<0x025>;
2329 defm SCRATCH_LOAD_LDS_UBYTE : FLAT_Real_ScratchAllAddr_LDS_gfx10 <0x008>;
2330 defm SCRATCH_LOAD_LDS_SBYTE : FLAT_Real_ScratchAllAddr_LDS_gfx10 <0x009>;
2331 defm SCRATCH_LOAD_LDS_USHORT : FLAT_Real_ScratchAllAddr_LDS_gfx10 <0x00a>;
2332 defm SCRATCH_LOAD_LDS_SSHORT : FLAT_Real_ScratchAllAddr_LDS_gfx10 <0x00b>;
2333 defm SCRATCH_LOAD_LDS_DWORD : FLAT_Real_ScratchAllAddr_LDS_gfx10 <0x00c>;
2335 //===----------------------------------------------------------------------===//
2337 //===----------------------------------------------------------------------===//
2339 class get_FLAT_ps<string name> {
2340 string Mnemonic = !cast<FLAT_Pseudo>(name).Mnemonic;
2343 multiclass FLAT_Real_gfx11 <bits<7> op,
2344 string name = get_FLAT_ps<NAME>.Mnemonic> {
2345 defvar ps = !cast<FLAT_Pseudo>(NAME);
2346 def _gfx11 : FLAT_Real <op, ps, name>,
2347 SIMCInstr <ps.PseudoInstr, SIEncodingFamily.GFX11> {
2348 let AssemblerPredicate = isGFX11Only;
2349 let DecoderNamespace = "GFX11";
2351 let Inst{13} = !if(ps.has_dlc, cpol{CPolBit.DLC}, ps.dlcValue);
2352 let Inst{14} = !if(ps.has_glc, cpol{CPolBit.GLC}, ps.glcValue);
2353 let Inst{15} = cpol{CPolBit.SLC};
2354 let Inst{17-16} = seg;
2355 let Inst{54-48} = !if(ps.enabled_saddr, saddr, SGPR_NULL_gfx11plus.Index);
2356 let Inst{55} = ps.sve;
2360 multiclass FLAT_Aliases_gfx11<string name> {
2361 defvar ps = get_FLAT_ps<NAME>;
2362 if !ne(ps.Mnemonic, name) then
2363 def : AMDGPUMnemonicAlias<ps.Mnemonic, name> {
2364 let AssemblerPredicate = isGFX11Only;
2368 multiclass FLAT_Real_Base_gfx11<bits<7> op,
2369 string name = get_FLAT_ps<NAME>.Mnemonic> :
2370 FLAT_Aliases_gfx11<name>,
2371 FLAT_Real_gfx11<op, name>;
2373 multiclass FLAT_Real_Atomics_gfx11<bits<7> op,
2374 string name = get_FLAT_ps<NAME>.Mnemonic> :
2375 FLAT_Real_Base_gfx11<op, name> {
2376 defm _RTN : FLAT_Real_gfx11<op, name>;
2379 multiclass GLOBAL_Real_AllAddr_gfx11<bits<7> op,
2380 string name = get_FLAT_ps<NAME>.Mnemonic> :
2381 FLAT_Real_Base_gfx11<op, name> {
2382 defm _SADDR : FLAT_Real_gfx11<op, name>;
2385 multiclass GLOBAL_Real_Atomics_gfx11<bits<7> op,
2386 string name = get_FLAT_ps<NAME>.Mnemonic> :
2387 GLOBAL_Real_AllAddr_gfx11<op, name> {
2388 defm _RTN : FLAT_Real_gfx11<op, name>;
2389 defm _SADDR_RTN : FLAT_Real_gfx11<op, name>;
2392 multiclass SCRATCH_Real_AllAddr_gfx11<bits<7> op,
2393 string name = get_FLAT_ps<NAME>.Mnemonic> :
2394 FLAT_Real_Base_gfx11<op, name> {
2395 defm _SADDR : FLAT_Real_gfx11<op, name>;
2396 defm _ST : FLAT_Real_gfx11<op, name>;
2397 defm _SVS : FLAT_Real_gfx11<op, name>;
2401 defm FLAT_LOAD_UBYTE : FLAT_Real_Base_gfx11<0x010, "flat_load_u8">;
2402 defm FLAT_LOAD_SBYTE : FLAT_Real_Base_gfx11<0x011, "flat_load_i8">;
2403 defm FLAT_LOAD_USHORT : FLAT_Real_Base_gfx11<0x012, "flat_load_u16">;
2404 defm FLAT_LOAD_SSHORT : FLAT_Real_Base_gfx11<0x013, "flat_load_i16">;
2405 defm FLAT_LOAD_DWORD : FLAT_Real_Base_gfx11<0x014, "flat_load_b32">;
2406 defm FLAT_LOAD_DWORDX2 : FLAT_Real_Base_gfx11<0x015, "flat_load_b64">;
2407 defm FLAT_LOAD_DWORDX3 : FLAT_Real_Base_gfx11<0x016, "flat_load_b96">;
2408 defm FLAT_LOAD_DWORDX4 : FLAT_Real_Base_gfx11<0x017, "flat_load_b128">;
2409 defm FLAT_STORE_BYTE : FLAT_Real_Base_gfx11<0x018, "flat_store_b8">;
2410 defm FLAT_STORE_SHORT : FLAT_Real_Base_gfx11<0x019, "flat_store_b16">;
2411 defm FLAT_STORE_DWORD : FLAT_Real_Base_gfx11<0x01a, "flat_store_b32">;
2412 defm FLAT_STORE_DWORDX2 : FLAT_Real_Base_gfx11<0x01b, "flat_store_b64">;
2413 defm FLAT_STORE_DWORDX3 : FLAT_Real_Base_gfx11<0x01c, "flat_store_b96">;
2414 defm FLAT_STORE_DWORDX4 : FLAT_Real_Base_gfx11<0x01d, "flat_store_b128">;
2415 defm FLAT_LOAD_UBYTE_D16 : FLAT_Real_Base_gfx11<0x01e, "flat_load_d16_u8">;
2416 defm FLAT_LOAD_SBYTE_D16 : FLAT_Real_Base_gfx11<0x01f, "flat_load_d16_i8">;
2417 defm FLAT_LOAD_SHORT_D16 : FLAT_Real_Base_gfx11<0x020, "flat_load_d16_b16">;
2418 defm FLAT_LOAD_UBYTE_D16_HI : FLAT_Real_Base_gfx11<0x021, "flat_load_d16_hi_u8">;
2419 defm FLAT_LOAD_SBYTE_D16_HI : FLAT_Real_Base_gfx11<0x022, "flat_load_d16_hi_i8">;
2420 defm FLAT_LOAD_SHORT_D16_HI : FLAT_Real_Base_gfx11<0x023, "flat_load_d16_hi_b16">;
2421 defm FLAT_STORE_BYTE_D16_HI : FLAT_Real_Base_gfx11<0x024, "flat_store_d16_hi_b8">;
2422 defm FLAT_STORE_SHORT_D16_HI : FLAT_Real_Base_gfx11<0x025, "flat_store_d16_hi_b16">;
2423 defm FLAT_ATOMIC_SWAP : FLAT_Real_Atomics_gfx11<0x033, "flat_atomic_swap_b32">;
2424 defm FLAT_ATOMIC_CMPSWAP : FLAT_Real_Atomics_gfx11<0x034, "flat_atomic_cmpswap_b32">;
2425 defm FLAT_ATOMIC_ADD : FLAT_Real_Atomics_gfx11<0x035, "flat_atomic_add_u32">;
2426 defm FLAT_ATOMIC_SUB : FLAT_Real_Atomics_gfx11<0x036, "flat_atomic_sub_u32">;
2427 defm FLAT_ATOMIC_SMIN : FLAT_Real_Atomics_gfx11<0x038, "flat_atomic_min_i32">;
2428 defm FLAT_ATOMIC_UMIN : FLAT_Real_Atomics_gfx11<0x039, "flat_atomic_min_u32">;
2429 defm FLAT_ATOMIC_SMAX : FLAT_Real_Atomics_gfx11<0x03a, "flat_atomic_max_i32">;
2430 defm FLAT_ATOMIC_UMAX : FLAT_Real_Atomics_gfx11<0x03b, "flat_atomic_max_u32">;
2431 defm FLAT_ATOMIC_AND : FLAT_Real_Atomics_gfx11<0x03c, "flat_atomic_and_b32">;
2432 defm FLAT_ATOMIC_OR : FLAT_Real_Atomics_gfx11<0x03d, "flat_atomic_or_b32">;
2433 defm FLAT_ATOMIC_XOR : FLAT_Real_Atomics_gfx11<0x03e, "flat_atomic_xor_b32">;
2434 defm FLAT_ATOMIC_INC : FLAT_Real_Atomics_gfx11<0x03f, "flat_atomic_inc_u32">;
2435 defm FLAT_ATOMIC_DEC : FLAT_Real_Atomics_gfx11<0x040, "flat_atomic_dec_u32">;
2436 defm FLAT_ATOMIC_SWAP_X2 : FLAT_Real_Atomics_gfx11<0x041, "flat_atomic_swap_b64">;
2437 defm FLAT_ATOMIC_CMPSWAP_X2 : FLAT_Real_Atomics_gfx11<0x042, "flat_atomic_cmpswap_b64">;
2438 defm FLAT_ATOMIC_ADD_X2 : FLAT_Real_Atomics_gfx11<0x043, "flat_atomic_add_u64">;
2439 defm FLAT_ATOMIC_SUB_X2 : FLAT_Real_Atomics_gfx11<0x044, "flat_atomic_sub_u64">;
2440 defm FLAT_ATOMIC_SMIN_X2 : FLAT_Real_Atomics_gfx11<0x045, "flat_atomic_min_i64">;
2441 defm FLAT_ATOMIC_UMIN_X2 : FLAT_Real_Atomics_gfx11<0x046, "flat_atomic_min_u64">;
2442 defm FLAT_ATOMIC_SMAX_X2 : FLAT_Real_Atomics_gfx11<0x047, "flat_atomic_max_i64">;
2443 defm FLAT_ATOMIC_UMAX_X2 : FLAT_Real_Atomics_gfx11<0x048, "flat_atomic_max_u64">;
2444 defm FLAT_ATOMIC_AND_X2 : FLAT_Real_Atomics_gfx11<0x049, "flat_atomic_and_b64">;
2445 defm FLAT_ATOMIC_OR_X2 : FLAT_Real_Atomics_gfx11<0x04a, "flat_atomic_or_b64">;
2446 defm FLAT_ATOMIC_XOR_X2 : FLAT_Real_Atomics_gfx11<0x04b, "flat_atomic_xor_b64">;
2447 defm FLAT_ATOMIC_INC_X2 : FLAT_Real_Atomics_gfx11<0x04c, "flat_atomic_inc_u64">;
2448 defm FLAT_ATOMIC_DEC_X2 : FLAT_Real_Atomics_gfx11<0x04d, "flat_atomic_dec_u64">;
2449 defm FLAT_ATOMIC_FCMPSWAP : FLAT_Real_Atomics_gfx11<0x050, "flat_atomic_cmpswap_f32">;
2450 defm FLAT_ATOMIC_FMIN : FLAT_Real_Atomics_gfx11<0x051, "flat_atomic_min_f32">;
2451 defm FLAT_ATOMIC_FMAX : FLAT_Real_Atomics_gfx11<0x052, "flat_atomic_max_f32">;
2452 defm FLAT_ATOMIC_ADD_F32 : FLAT_Real_Atomics_gfx11<0x056>;
2455 defm GLOBAL_LOAD_UBYTE : GLOBAL_Real_AllAddr_gfx11<0x010, "global_load_u8">;
2456 defm GLOBAL_LOAD_SBYTE : GLOBAL_Real_AllAddr_gfx11<0x011, "global_load_i8">;
2457 defm GLOBAL_LOAD_USHORT : GLOBAL_Real_AllAddr_gfx11<0x012, "global_load_u16">;
2458 defm GLOBAL_LOAD_SSHORT : GLOBAL_Real_AllAddr_gfx11<0x013, "global_load_i16">;
2459 defm GLOBAL_LOAD_DWORD : GLOBAL_Real_AllAddr_gfx11<0x014, "global_load_b32">;
2460 defm GLOBAL_LOAD_DWORDX2 : GLOBAL_Real_AllAddr_gfx11<0x015, "global_load_b64">;
2461 defm GLOBAL_LOAD_DWORDX3 : GLOBAL_Real_AllAddr_gfx11<0x016, "global_load_b96">;
2462 defm GLOBAL_LOAD_DWORDX4 : GLOBAL_Real_AllAddr_gfx11<0x017, "global_load_b128">;
2463 defm GLOBAL_STORE_BYTE : GLOBAL_Real_AllAddr_gfx11<0x018, "global_store_b8">;
2464 defm GLOBAL_STORE_SHORT : GLOBAL_Real_AllAddr_gfx11<0x019, "global_store_b16">;
2465 defm GLOBAL_STORE_DWORD : GLOBAL_Real_AllAddr_gfx11<0x01a, "global_store_b32">;
2466 defm GLOBAL_STORE_DWORDX2 : GLOBAL_Real_AllAddr_gfx11<0x01b, "global_store_b64">;
2467 defm GLOBAL_STORE_DWORDX3 : GLOBAL_Real_AllAddr_gfx11<0x01c, "global_store_b96">;
2468 defm GLOBAL_STORE_DWORDX4 : GLOBAL_Real_AllAddr_gfx11<0x01d, "global_store_b128">;
2469 defm GLOBAL_LOAD_UBYTE_D16 : GLOBAL_Real_AllAddr_gfx11<0x01e, "global_load_d16_u8">;
2470 defm GLOBAL_LOAD_SBYTE_D16 : GLOBAL_Real_AllAddr_gfx11<0x01f, "global_load_d16_i8">;
2471 defm GLOBAL_LOAD_SHORT_D16 : GLOBAL_Real_AllAddr_gfx11<0x020, "global_load_d16_b16">;
2472 defm GLOBAL_LOAD_UBYTE_D16_HI : GLOBAL_Real_AllAddr_gfx11<0x021, "global_load_d16_hi_u8">;
2473 defm GLOBAL_LOAD_SBYTE_D16_HI : GLOBAL_Real_AllAddr_gfx11<0x022, "global_load_d16_hi_i8">;
2474 defm GLOBAL_LOAD_SHORT_D16_HI : GLOBAL_Real_AllAddr_gfx11<0x023, "global_load_d16_hi_b16">;
2475 defm GLOBAL_STORE_BYTE_D16_HI : GLOBAL_Real_AllAddr_gfx11<0x024, "global_store_d16_hi_b8">;
2476 defm GLOBAL_STORE_SHORT_D16_HI : GLOBAL_Real_AllAddr_gfx11<0x025, "global_store_d16_hi_b16">;
2477 defm GLOBAL_LOAD_DWORD_ADDTID : GLOBAL_Real_AllAddr_gfx11<0x028, "global_load_addtid_b32">;
2478 defm GLOBAL_STORE_DWORD_ADDTID : GLOBAL_Real_AllAddr_gfx11<0x029, "global_store_addtid_b32">;
2479 defm GLOBAL_ATOMIC_SWAP : GLOBAL_Real_Atomics_gfx11<0x033, "global_atomic_swap_b32">;
2480 defm GLOBAL_ATOMIC_CMPSWAP : GLOBAL_Real_Atomics_gfx11<0x034, "global_atomic_cmpswap_b32">;
2481 defm GLOBAL_ATOMIC_ADD : GLOBAL_Real_Atomics_gfx11<0x035, "global_atomic_add_u32">;
2482 defm GLOBAL_ATOMIC_SUB : GLOBAL_Real_Atomics_gfx11<0x036, "global_atomic_sub_u32">;
2483 defm GLOBAL_ATOMIC_CSUB : GLOBAL_Real_Atomics_gfx11<0x037, "global_atomic_csub_u32">;
2484 defm GLOBAL_ATOMIC_SMIN : GLOBAL_Real_Atomics_gfx11<0x038, "global_atomic_min_i32">;
2485 defm GLOBAL_ATOMIC_UMIN : GLOBAL_Real_Atomics_gfx11<0x039, "global_atomic_min_u32">;
2486 defm GLOBAL_ATOMIC_SMAX : GLOBAL_Real_Atomics_gfx11<0x03a, "global_atomic_max_i32">;
2487 defm GLOBAL_ATOMIC_UMAX : GLOBAL_Real_Atomics_gfx11<0x03b, "global_atomic_max_u32">;
2488 defm GLOBAL_ATOMIC_AND : GLOBAL_Real_Atomics_gfx11<0x03c, "global_atomic_and_b32">;
2489 defm GLOBAL_ATOMIC_OR : GLOBAL_Real_Atomics_gfx11<0x03d, "global_atomic_or_b32">;
2490 defm GLOBAL_ATOMIC_XOR : GLOBAL_Real_Atomics_gfx11<0x03e, "global_atomic_xor_b32">;
2491 defm GLOBAL_ATOMIC_INC : GLOBAL_Real_Atomics_gfx11<0x03f, "global_atomic_inc_u32">;
2492 defm GLOBAL_ATOMIC_DEC : GLOBAL_Real_Atomics_gfx11<0x040, "global_atomic_dec_u32">;
2493 defm GLOBAL_ATOMIC_SWAP_X2 : GLOBAL_Real_Atomics_gfx11<0x041, "global_atomic_swap_b64">;
2494 defm GLOBAL_ATOMIC_CMPSWAP_X2 : GLOBAL_Real_Atomics_gfx11<0x042, "global_atomic_cmpswap_b64">;
2495 defm GLOBAL_ATOMIC_ADD_X2 : GLOBAL_Real_Atomics_gfx11<0x043, "global_atomic_add_u64">;
2496 defm GLOBAL_ATOMIC_SUB_X2 : GLOBAL_Real_Atomics_gfx11<0x044, "global_atomic_sub_u64">;
2497 defm GLOBAL_ATOMIC_SMIN_X2 : GLOBAL_Real_Atomics_gfx11<0x045, "global_atomic_min_i64">;
2498 defm GLOBAL_ATOMIC_UMIN_X2 : GLOBAL_Real_Atomics_gfx11<0x046, "global_atomic_min_u64">;
2499 defm GLOBAL_ATOMIC_SMAX_X2 : GLOBAL_Real_Atomics_gfx11<0x047, "global_atomic_max_i64">;
2500 defm GLOBAL_ATOMIC_UMAX_X2 : GLOBAL_Real_Atomics_gfx11<0x048, "global_atomic_max_u64">;
2501 defm GLOBAL_ATOMIC_AND_X2 : GLOBAL_Real_Atomics_gfx11<0x049, "global_atomic_and_b64">;
2502 defm GLOBAL_ATOMIC_OR_X2 : GLOBAL_Real_Atomics_gfx11<0x04a, "global_atomic_or_b64">;
2503 defm GLOBAL_ATOMIC_XOR_X2 : GLOBAL_Real_Atomics_gfx11<0x04b, "global_atomic_xor_b64">;
2504 defm GLOBAL_ATOMIC_INC_X2 : GLOBAL_Real_Atomics_gfx11<0x04c, "global_atomic_inc_u64">;
2505 defm GLOBAL_ATOMIC_DEC_X2 : GLOBAL_Real_Atomics_gfx11<0x04d, "global_atomic_dec_u64">;
2506 defm GLOBAL_ATOMIC_FCMPSWAP : GLOBAL_Real_Atomics_gfx11<0x050, "global_atomic_cmpswap_f32">;
2507 defm GLOBAL_ATOMIC_FMIN : GLOBAL_Real_Atomics_gfx11<0x051, "global_atomic_min_f32">;
2508 defm GLOBAL_ATOMIC_FMAX : GLOBAL_Real_Atomics_gfx11<0x052, "global_atomic_max_f32">;
2509 defm GLOBAL_ATOMIC_ADD_F32 : GLOBAL_Real_Atomics_gfx11<0x056>;
2511 // ENC_FLAT_SCRATCH.
2512 defm SCRATCH_LOAD_UBYTE : SCRATCH_Real_AllAddr_gfx11<0x10, "scratch_load_u8">;
2513 defm SCRATCH_LOAD_SBYTE : SCRATCH_Real_AllAddr_gfx11<0x11, "scratch_load_i8">;
2514 defm SCRATCH_LOAD_USHORT : SCRATCH_Real_AllAddr_gfx11<0x12, "scratch_load_u16">;
2515 defm SCRATCH_LOAD_SSHORT : SCRATCH_Real_AllAddr_gfx11<0x13, "scratch_load_i16">;
2516 defm SCRATCH_LOAD_DWORD : SCRATCH_Real_AllAddr_gfx11<0x14, "scratch_load_b32">;
2517 defm SCRATCH_LOAD_DWORDX2 : SCRATCH_Real_AllAddr_gfx11<0x15, "scratch_load_b64">;
2518 defm SCRATCH_LOAD_DWORDX3 : SCRATCH_Real_AllAddr_gfx11<0x16, "scratch_load_b96">;
2519 defm SCRATCH_LOAD_DWORDX4 : SCRATCH_Real_AllAddr_gfx11<0x17, "scratch_load_b128">;
2520 defm SCRATCH_STORE_BYTE : SCRATCH_Real_AllAddr_gfx11<0x18, "scratch_store_b8">;
2521 defm SCRATCH_STORE_SHORT : SCRATCH_Real_AllAddr_gfx11<0x19, "scratch_store_b16">;
2522 defm SCRATCH_STORE_DWORD : SCRATCH_Real_AllAddr_gfx11<0x1a, "scratch_store_b32">;
2523 defm SCRATCH_STORE_DWORDX2 : SCRATCH_Real_AllAddr_gfx11<0x1b, "scratch_store_b64">;
2524 defm SCRATCH_STORE_DWORDX3 : SCRATCH_Real_AllAddr_gfx11<0x1c, "scratch_store_b96">;
2525 defm SCRATCH_STORE_DWORDX4 : SCRATCH_Real_AllAddr_gfx11<0x1d, "scratch_store_b128">;
2526 defm SCRATCH_LOAD_UBYTE_D16 : SCRATCH_Real_AllAddr_gfx11<0x1e, "scratch_load_d16_u8">;
2527 defm SCRATCH_LOAD_SBYTE_D16 : SCRATCH_Real_AllAddr_gfx11<0x1f, "scratch_load_d16_i8">;
2528 defm SCRATCH_LOAD_SHORT_D16 : SCRATCH_Real_AllAddr_gfx11<0x20, "scratch_load_d16_b16">;
2529 defm SCRATCH_LOAD_UBYTE_D16_HI : SCRATCH_Real_AllAddr_gfx11<0x21, "scratch_load_d16_hi_u8">;
2530 defm SCRATCH_LOAD_SBYTE_D16_HI : SCRATCH_Real_AllAddr_gfx11<0x22, "scratch_load_d16_hi_i8">;
2531 defm SCRATCH_LOAD_SHORT_D16_HI : SCRATCH_Real_AllAddr_gfx11<0x23, "scratch_load_d16_hi_b16">;
2532 defm SCRATCH_STORE_BYTE_D16_HI : SCRATCH_Real_AllAddr_gfx11<0x24, "scratch_store_d16_hi_b8">;
2533 defm SCRATCH_STORE_SHORT_D16_HI : SCRATCH_Real_AllAddr_gfx11<0x25, "scratch_store_d16_hi_b16">;
2535 //===----------------------------------------------------------------------===//
2537 //===----------------------------------------------------------------------===//
2539 multiclass VFLAT_Real_gfx12 <bits<8> op, string name = get_FLAT_ps<NAME>.Mnemonic> {
2540 defvar ps = !cast<FLAT_Pseudo>(NAME);
2541 def _gfx12 : VFLAT_Real <op, ps, name>,
2542 SIMCInstr <ps.PseudoInstr, SIEncodingFamily.GFX12> {
2543 let AssemblerPredicate = isGFX12Only;
2544 let DecoderNamespace = "GFX12";
2546 let Inst{25-24} = {ps.is_flat_global, ps.is_flat_scratch};
2550 multiclass VFLAT_Aliases_gfx12<string name, string alias = name> {
2551 defvar ps = get_FLAT_ps<NAME>;
2552 let AssemblerPredicate = isGFX12Only in {
2553 if !ne(ps.Mnemonic, name) then
2554 def : AMDGPUMnemonicAlias<ps.Mnemonic, name>;
2555 if !ne(alias, name) then
2556 def : AMDGPUMnemonicAlias<alias, name>;
2560 multiclass VFLAT_Real_Base_gfx12<bits<8> op,
2561 string name = get_FLAT_ps<NAME>.Mnemonic,
2562 string alias = name> :
2563 VFLAT_Aliases_gfx12<name, alias>,
2564 VFLAT_Real_gfx12<op, name>;
2566 multiclass VFLAT_Real_Atomics_gfx12<bits<8> op,
2567 string name = get_FLAT_ps<NAME>.Mnemonic,
2568 string alias = name> :
2569 VFLAT_Real_Base_gfx12<op, name, alias> {
2570 defm _RTN : VFLAT_Real_gfx12<op, name>;
2573 multiclass VGLOBAL_Real_AllAddr_gfx12<bits<8> op,
2574 string name = get_FLAT_ps<NAME>.Mnemonic,
2575 string alias = name> :
2576 VFLAT_Real_Base_gfx12<op, name, alias> {
2577 defm _SADDR : VFLAT_Real_gfx12<op, name>;
2580 multiclass VGLOBAL_Real_AllAddr_gfx12_w64<bits<8> op,
2581 string name = get_FLAT_ps<NAME>.Mnemonic> :
2582 VFLAT_Aliases_gfx12<name> {
2583 let DecoderNamespace = "GFX12W64" in {
2584 defm "" : VFLAT_Real_gfx12<op, name>;
2585 defm _SADDR : VFLAT_Real_gfx12<op, name>;
2589 multiclass VGLOBAL_Real_Atomics_gfx12<bits<8> op,
2590 string name = get_FLAT_ps<NAME>.Mnemonic,
2591 string alias = name> :
2592 VGLOBAL_Real_AllAddr_gfx12<op, name, alias> {
2593 defm _RTN : VFLAT_Real_gfx12<op, name>;
2594 defm _SADDR_RTN : VFLAT_Real_gfx12<op, name>;
2597 multiclass VSCRATCH_Real_AllAddr_gfx12<bits<8> op,
2598 string name = get_FLAT_ps<NAME>.Mnemonic> :
2599 VFLAT_Real_Base_gfx12<op, name> {
2600 defm _SADDR : VFLAT_Real_gfx12<op, name>;
2601 defm _ST : VFLAT_Real_gfx12<op, name>;
2602 defm _SVS : VFLAT_Real_gfx12<op, name>;
2606 defm FLAT_LOAD_UBYTE : VFLAT_Real_Base_gfx12<0x010, "flat_load_u8">;
2607 defm FLAT_LOAD_SBYTE : VFLAT_Real_Base_gfx12<0x011, "flat_load_i8">;
2608 defm FLAT_LOAD_USHORT : VFLAT_Real_Base_gfx12<0x012, "flat_load_u16">;
2609 defm FLAT_LOAD_SSHORT : VFLAT_Real_Base_gfx12<0x013, "flat_load_i16">;
2610 defm FLAT_LOAD_DWORD : VFLAT_Real_Base_gfx12<0x014, "flat_load_b32">;
2611 defm FLAT_LOAD_DWORDX2 : VFLAT_Real_Base_gfx12<0x015, "flat_load_b64">;
2612 defm FLAT_LOAD_DWORDX3 : VFLAT_Real_Base_gfx12<0x016, "flat_load_b96">;
2613 defm FLAT_LOAD_DWORDX4 : VFLAT_Real_Base_gfx12<0x017, "flat_load_b128">;
2614 defm FLAT_STORE_BYTE : VFLAT_Real_Base_gfx12<0x018, "flat_store_b8">;
2615 defm FLAT_STORE_SHORT : VFLAT_Real_Base_gfx12<0x019, "flat_store_b16">;
2616 defm FLAT_STORE_DWORD : VFLAT_Real_Base_gfx12<0x01a, "flat_store_b32">;
2617 defm FLAT_STORE_DWORDX2 : VFLAT_Real_Base_gfx12<0x01b, "flat_store_b64">;
2618 defm FLAT_STORE_DWORDX3 : VFLAT_Real_Base_gfx12<0x01c, "flat_store_b96">;
2619 defm FLAT_STORE_DWORDX4 : VFLAT_Real_Base_gfx12<0x01d, "flat_store_b128">;
2620 defm FLAT_LOAD_UBYTE_D16 : VFLAT_Real_Base_gfx12<0x01e, "flat_load_d16_u8">;
2621 defm FLAT_LOAD_SBYTE_D16 : VFLAT_Real_Base_gfx12<0x01f, "flat_load_d16_i8">;
2622 defm FLAT_LOAD_SHORT_D16 : VFLAT_Real_Base_gfx12<0x020, "flat_load_d16_b16">;
2623 defm FLAT_LOAD_UBYTE_D16_HI : VFLAT_Real_Base_gfx12<0x021, "flat_load_d16_hi_u8">;
2624 defm FLAT_LOAD_SBYTE_D16_HI : VFLAT_Real_Base_gfx12<0x022, "flat_load_d16_hi_i8">;
2625 defm FLAT_LOAD_SHORT_D16_HI : VFLAT_Real_Base_gfx12<0x023, "flat_load_d16_hi_b16">;
2626 defm FLAT_STORE_BYTE_D16_HI : VFLAT_Real_Base_gfx12<0x024, "flat_store_d16_hi_b8">;
2627 defm FLAT_STORE_SHORT_D16_HI : VFLAT_Real_Base_gfx12<0x025, "flat_store_d16_hi_b16">;
2628 defm FLAT_ATOMIC_SWAP : VFLAT_Real_Atomics_gfx12<0x033, "flat_atomic_swap_b32">;
2629 defm FLAT_ATOMIC_CMPSWAP : VFLAT_Real_Atomics_gfx12<0x034, "flat_atomic_cmpswap_b32">;
2630 defm FLAT_ATOMIC_ADD : VFLAT_Real_Atomics_gfx12<0x035, "flat_atomic_add_u32">;
2631 defm FLAT_ATOMIC_SUB : VFLAT_Real_Atomics_gfx12<0x036, "flat_atomic_sub_u32">;
2632 defm FLAT_ATOMIC_CSUB_U32 : VFLAT_Real_Atomics_gfx12<0x037, "flat_atomic_sub_clamp_u32">;
2633 defm FLAT_ATOMIC_SMIN : VFLAT_Real_Atomics_gfx12<0x038, "flat_atomic_min_i32">;
2634 defm FLAT_ATOMIC_UMIN : VFLAT_Real_Atomics_gfx12<0x039, "flat_atomic_min_u32">;
2635 defm FLAT_ATOMIC_SMAX : VFLAT_Real_Atomics_gfx12<0x03a, "flat_atomic_max_i32">;
2636 defm FLAT_ATOMIC_UMAX : VFLAT_Real_Atomics_gfx12<0x03b, "flat_atomic_max_u32">;
2637 defm FLAT_ATOMIC_AND : VFLAT_Real_Atomics_gfx12<0x03c, "flat_atomic_and_b32">;
2638 defm FLAT_ATOMIC_OR : VFLAT_Real_Atomics_gfx12<0x03d, "flat_atomic_or_b32">;
2639 defm FLAT_ATOMIC_XOR : VFLAT_Real_Atomics_gfx12<0x03e, "flat_atomic_xor_b32">;
2640 defm FLAT_ATOMIC_INC : VFLAT_Real_Atomics_gfx12<0x03f, "flat_atomic_inc_u32">;
2641 defm FLAT_ATOMIC_DEC : VFLAT_Real_Atomics_gfx12<0x040, "flat_atomic_dec_u32">;
2642 defm FLAT_ATOMIC_SWAP_X2 : VFLAT_Real_Atomics_gfx12<0x041, "flat_atomic_swap_b64">;
2643 defm FLAT_ATOMIC_CMPSWAP_X2 : VFLAT_Real_Atomics_gfx12<0x042, "flat_atomic_cmpswap_b64">;
2644 defm FLAT_ATOMIC_ADD_X2 : VFLAT_Real_Atomics_gfx12<0x043, "flat_atomic_add_u64">;
2645 defm FLAT_ATOMIC_SUB_X2 : VFLAT_Real_Atomics_gfx12<0x044, "flat_atomic_sub_u64">;
2646 defm FLAT_ATOMIC_SMIN_X2 : VFLAT_Real_Atomics_gfx12<0x045, "flat_atomic_min_i64">;
2647 defm FLAT_ATOMIC_UMIN_X2 : VFLAT_Real_Atomics_gfx12<0x046, "flat_atomic_min_u64">;
2648 defm FLAT_ATOMIC_SMAX_X2 : VFLAT_Real_Atomics_gfx12<0x047, "flat_atomic_max_i64">;
2649 defm FLAT_ATOMIC_UMAX_X2 : VFLAT_Real_Atomics_gfx12<0x048, "flat_atomic_max_u64">;
2650 defm FLAT_ATOMIC_AND_X2 : VFLAT_Real_Atomics_gfx12<0x049, "flat_atomic_and_b64">;
2651 defm FLAT_ATOMIC_OR_X2 : VFLAT_Real_Atomics_gfx12<0x04a, "flat_atomic_or_b64">;
2652 defm FLAT_ATOMIC_XOR_X2 : VFLAT_Real_Atomics_gfx12<0x04b, "flat_atomic_xor_b64">;
2653 defm FLAT_ATOMIC_INC_X2 : VFLAT_Real_Atomics_gfx12<0x04c, "flat_atomic_inc_u64">;
2654 defm FLAT_ATOMIC_DEC_X2 : VFLAT_Real_Atomics_gfx12<0x04d, "flat_atomic_dec_u64">;
2655 defm FLAT_ATOMIC_COND_SUB_U32 : VFLAT_Real_Atomics_gfx12<0x050>;
2656 defm FLAT_ATOMIC_FMIN : VFLAT_Real_Atomics_gfx12<0x051, "flat_atomic_min_num_f32", "flat_atomic_min_f32">;
2657 defm FLAT_ATOMIC_FMAX : VFLAT_Real_Atomics_gfx12<0x052, "flat_atomic_max_num_f32", "flat_atomic_max_f32">;
2658 defm FLAT_ATOMIC_ADD_F32 : VFLAT_Real_Atomics_gfx12<0x056>;
2659 defm FLAT_ATOMIC_PK_ADD_F16 : VFLAT_Real_Atomics_gfx12<0x059>;
2660 defm FLAT_ATOMIC_PK_ADD_BF16 : VFLAT_Real_Atomics_gfx12<0x05a>;
2663 defm GLOBAL_LOAD_UBYTE : VGLOBAL_Real_AllAddr_gfx12<0x010, "global_load_u8">;
2664 defm GLOBAL_LOAD_SBYTE : VGLOBAL_Real_AllAddr_gfx12<0x011, "global_load_i8">;
2665 defm GLOBAL_LOAD_USHORT : VGLOBAL_Real_AllAddr_gfx12<0x012, "global_load_u16">;
2666 defm GLOBAL_LOAD_SSHORT : VGLOBAL_Real_AllAddr_gfx12<0x013, "global_load_i16">;
2667 defm GLOBAL_LOAD_DWORD : VGLOBAL_Real_AllAddr_gfx12<0x014, "global_load_b32">;
2668 defm GLOBAL_LOAD_DWORDX2 : VGLOBAL_Real_AllAddr_gfx12<0x015, "global_load_b64">;
2669 defm GLOBAL_LOAD_DWORDX3 : VGLOBAL_Real_AllAddr_gfx12<0x016, "global_load_b96">;
2670 defm GLOBAL_LOAD_DWORDX4 : VGLOBAL_Real_AllAddr_gfx12<0x017, "global_load_b128">;
2671 defm GLOBAL_STORE_BYTE : VGLOBAL_Real_AllAddr_gfx12<0x018, "global_store_b8">;
2672 defm GLOBAL_STORE_SHORT : VGLOBAL_Real_AllAddr_gfx12<0x019, "global_store_b16">;
2673 defm GLOBAL_STORE_DWORD : VGLOBAL_Real_AllAddr_gfx12<0x01a, "global_store_b32">;
2674 defm GLOBAL_STORE_DWORDX2 : VGLOBAL_Real_AllAddr_gfx12<0x01b, "global_store_b64">;
2675 defm GLOBAL_STORE_DWORDX3 : VGLOBAL_Real_AllAddr_gfx12<0x01c, "global_store_b96">;
2676 defm GLOBAL_STORE_DWORDX4 : VGLOBAL_Real_AllAddr_gfx12<0x01d, "global_store_b128">;
2677 defm GLOBAL_LOAD_UBYTE_D16 : VGLOBAL_Real_AllAddr_gfx12<0x01e, "global_load_d16_u8">;
2678 defm GLOBAL_LOAD_SBYTE_D16 : VGLOBAL_Real_AllAddr_gfx12<0x01f, "global_load_d16_i8">;
2679 defm GLOBAL_LOAD_SHORT_D16 : VGLOBAL_Real_AllAddr_gfx12<0x020, "global_load_d16_b16">;
2680 defm GLOBAL_LOAD_UBYTE_D16_HI : VGLOBAL_Real_AllAddr_gfx12<0x021, "global_load_d16_hi_u8">;
2681 defm GLOBAL_LOAD_SBYTE_D16_HI : VGLOBAL_Real_AllAddr_gfx12<0x022, "global_load_d16_hi_i8">;
2682 defm GLOBAL_LOAD_SHORT_D16_HI : VGLOBAL_Real_AllAddr_gfx12<0x023, "global_load_d16_hi_b16">;
2683 defm GLOBAL_STORE_BYTE_D16_HI : VGLOBAL_Real_AllAddr_gfx12<0x024, "global_store_d16_hi_b8">;
2684 defm GLOBAL_STORE_SHORT_D16_HI : VGLOBAL_Real_AllAddr_gfx12<0x025, "global_store_d16_hi_b16">;
2685 defm GLOBAL_LOAD_DWORD_ADDTID : VGLOBAL_Real_AllAddr_gfx12<0x028, "global_load_addtid_b32">;
2686 defm GLOBAL_STORE_DWORD_ADDTID : VGLOBAL_Real_AllAddr_gfx12<0x029, "global_store_addtid_b32">;
2687 defm GLOBAL_LOAD_BLOCK : VGLOBAL_Real_AllAddr_gfx12<0x053>;
2688 defm GLOBAL_STORE_BLOCK : VGLOBAL_Real_AllAddr_gfx12<0x054>;
2690 defm GLOBAL_ATOMIC_SWAP : VGLOBAL_Real_Atomics_gfx12<0x033, "global_atomic_swap_b32">;
2691 defm GLOBAL_ATOMIC_CMPSWAP : VGLOBAL_Real_Atomics_gfx12<0x034, "global_atomic_cmpswap_b32">;
2692 defm GLOBAL_ATOMIC_ADD : VGLOBAL_Real_Atomics_gfx12<0x035, "global_atomic_add_u32">;
2693 defm GLOBAL_ATOMIC_SUB : VGLOBAL_Real_Atomics_gfx12<0x036, "global_atomic_sub_u32">;
2694 defm GLOBAL_ATOMIC_CSUB : VGLOBAL_Real_Atomics_gfx12<0x037, "global_atomic_sub_clamp_u32", "global_atomic_csub_u32">;
2695 defm GLOBAL_ATOMIC_SMIN : VGLOBAL_Real_Atomics_gfx12<0x038, "global_atomic_min_i32">;
2696 defm GLOBAL_ATOMIC_UMIN : VGLOBAL_Real_Atomics_gfx12<0x039, "global_atomic_min_u32">;
2697 defm GLOBAL_ATOMIC_SMAX : VGLOBAL_Real_Atomics_gfx12<0x03a, "global_atomic_max_i32">;
2698 defm GLOBAL_ATOMIC_UMAX : VGLOBAL_Real_Atomics_gfx12<0x03b, "global_atomic_max_u32">;
2699 defm GLOBAL_ATOMIC_AND : VGLOBAL_Real_Atomics_gfx12<0x03c, "global_atomic_and_b32">;
2700 defm GLOBAL_ATOMIC_OR : VGLOBAL_Real_Atomics_gfx12<0x03d, "global_atomic_or_b32">;
2701 defm GLOBAL_ATOMIC_XOR : VGLOBAL_Real_Atomics_gfx12<0x03e, "global_atomic_xor_b32">;
2702 defm GLOBAL_ATOMIC_INC : VGLOBAL_Real_Atomics_gfx12<0x03f, "global_atomic_inc_u32">;
2703 defm GLOBAL_ATOMIC_DEC : VGLOBAL_Real_Atomics_gfx12<0x040, "global_atomic_dec_u32">;
2704 defm GLOBAL_ATOMIC_SWAP_X2 : VGLOBAL_Real_Atomics_gfx12<0x041, "global_atomic_swap_b64">;
2705 defm GLOBAL_ATOMIC_CMPSWAP_X2 : VGLOBAL_Real_Atomics_gfx12<0x042, "global_atomic_cmpswap_b64">;
2706 defm GLOBAL_ATOMIC_ADD_X2 : VGLOBAL_Real_Atomics_gfx12<0x043, "global_atomic_add_u64">;
2707 defm GLOBAL_ATOMIC_SUB_X2 : VGLOBAL_Real_Atomics_gfx12<0x044, "global_atomic_sub_u64">;
2708 defm GLOBAL_ATOMIC_SMIN_X2 : VGLOBAL_Real_Atomics_gfx12<0x045, "global_atomic_min_i64">;
2709 defm GLOBAL_ATOMIC_UMIN_X2 : VGLOBAL_Real_Atomics_gfx12<0x046, "global_atomic_min_u64">;
2710 defm GLOBAL_ATOMIC_SMAX_X2 : VGLOBAL_Real_Atomics_gfx12<0x047, "global_atomic_max_i64">;
2711 defm GLOBAL_ATOMIC_UMAX_X2 : VGLOBAL_Real_Atomics_gfx12<0x048, "global_atomic_max_u64">;
2712 defm GLOBAL_ATOMIC_AND_X2 : VGLOBAL_Real_Atomics_gfx12<0x049, "global_atomic_and_b64">;
2713 defm GLOBAL_ATOMIC_OR_X2 : VGLOBAL_Real_Atomics_gfx12<0x04a, "global_atomic_or_b64">;
2714 defm GLOBAL_ATOMIC_XOR_X2 : VGLOBAL_Real_Atomics_gfx12<0x04b, "global_atomic_xor_b64">;
2715 defm GLOBAL_ATOMIC_INC_X2 : VGLOBAL_Real_Atomics_gfx12<0x04c, "global_atomic_inc_u64">;
2716 defm GLOBAL_ATOMIC_DEC_X2 : VGLOBAL_Real_Atomics_gfx12<0x04d, "global_atomic_dec_u64">;
2717 defm GLOBAL_ATOMIC_COND_SUB_U32 : VGLOBAL_Real_Atomics_gfx12<0x050>;
2718 defm GLOBAL_ATOMIC_FMIN : VGLOBAL_Real_Atomics_gfx12<0x051, "global_atomic_min_num_f32", "global_atomic_min_f32">;
2719 defm GLOBAL_ATOMIC_FMAX : VGLOBAL_Real_Atomics_gfx12<0x052, "global_atomic_max_num_f32", "global_atomic_max_f32">;
2720 defm GLOBAL_ATOMIC_ADD_F32 : VGLOBAL_Real_Atomics_gfx12<0x056>;
2722 defm GLOBAL_LOAD_TR_B128_w32 : VGLOBAL_Real_AllAddr_gfx12<0x057>;
2723 defm GLOBAL_LOAD_TR_B64_w32 : VGLOBAL_Real_AllAddr_gfx12<0x058>;
2725 defm GLOBAL_LOAD_TR_B128_w64 : VGLOBAL_Real_AllAddr_gfx12_w64<0x057>;
2726 defm GLOBAL_LOAD_TR_B64_w64 : VGLOBAL_Real_AllAddr_gfx12_w64<0x058>;
2728 defm GLOBAL_ATOMIC_ORDERED_ADD_B64 : VGLOBAL_Real_Atomics_gfx12<0x073>;
2729 defm GLOBAL_ATOMIC_PK_ADD_F16 : VGLOBAL_Real_Atomics_gfx12<0x059>;
2730 defm GLOBAL_ATOMIC_PK_ADD_BF16 : VGLOBAL_Real_Atomics_gfx12<0x05a>;
2732 defm GLOBAL_INV : VFLAT_Real_Base_gfx12<0x02b>;
2733 defm GLOBAL_WB : VFLAT_Real_Base_gfx12<0x02c>;
2734 defm GLOBAL_WBINV : VFLAT_Real_Base_gfx12<0x04f>;
2737 defm SCRATCH_LOAD_UBYTE : VSCRATCH_Real_AllAddr_gfx12<0x10, "scratch_load_u8">;
2738 defm SCRATCH_LOAD_SBYTE : VSCRATCH_Real_AllAddr_gfx12<0x11, "scratch_load_i8">;
2739 defm SCRATCH_LOAD_USHORT : VSCRATCH_Real_AllAddr_gfx12<0x12, "scratch_load_u16">;
2740 defm SCRATCH_LOAD_SSHORT : VSCRATCH_Real_AllAddr_gfx12<0x13, "scratch_load_i16">;
2741 defm SCRATCH_LOAD_DWORD : VSCRATCH_Real_AllAddr_gfx12<0x14, "scratch_load_b32">;
2742 defm SCRATCH_LOAD_DWORDX2 : VSCRATCH_Real_AllAddr_gfx12<0x15, "scratch_load_b64">;
2743 defm SCRATCH_LOAD_DWORDX3 : VSCRATCH_Real_AllAddr_gfx12<0x16, "scratch_load_b96">;
2744 defm SCRATCH_LOAD_DWORDX4 : VSCRATCH_Real_AllAddr_gfx12<0x17, "scratch_load_b128">;
2745 defm SCRATCH_STORE_BYTE : VSCRATCH_Real_AllAddr_gfx12<0x18, "scratch_store_b8">;
2746 defm SCRATCH_STORE_SHORT : VSCRATCH_Real_AllAddr_gfx12<0x19, "scratch_store_b16">;
2747 defm SCRATCH_STORE_DWORD : VSCRATCH_Real_AllAddr_gfx12<0x1a, "scratch_store_b32">;
2748 defm SCRATCH_STORE_DWORDX2 : VSCRATCH_Real_AllAddr_gfx12<0x1b, "scratch_store_b64">;
2749 defm SCRATCH_STORE_DWORDX3 : VSCRATCH_Real_AllAddr_gfx12<0x1c, "scratch_store_b96">;
2750 defm SCRATCH_STORE_DWORDX4 : VSCRATCH_Real_AllAddr_gfx12<0x1d, "scratch_store_b128">;
2751 defm SCRATCH_LOAD_UBYTE_D16 : VSCRATCH_Real_AllAddr_gfx12<0x1e, "scratch_load_d16_u8">;
2752 defm SCRATCH_LOAD_SBYTE_D16 : VSCRATCH_Real_AllAddr_gfx12<0x1f, "scratch_load_d16_i8">;
2753 defm SCRATCH_LOAD_SHORT_D16 : VSCRATCH_Real_AllAddr_gfx12<0x20, "scratch_load_d16_b16">;
2754 defm SCRATCH_LOAD_UBYTE_D16_HI : VSCRATCH_Real_AllAddr_gfx12<0x21, "scratch_load_d16_hi_u8">;
2755 defm SCRATCH_LOAD_SBYTE_D16_HI : VSCRATCH_Real_AllAddr_gfx12<0x22, "scratch_load_d16_hi_i8">;
2756 defm SCRATCH_LOAD_SHORT_D16_HI : VSCRATCH_Real_AllAddr_gfx12<0x23, "scratch_load_d16_hi_b16">;
2757 defm SCRATCH_STORE_BYTE_D16_HI : VSCRATCH_Real_AllAddr_gfx12<0x24, "scratch_store_d16_hi_b8">;
2758 defm SCRATCH_STORE_SHORT_D16_HI : VSCRATCH_Real_AllAddr_gfx12<0x25, "scratch_store_d16_hi_b16">;
2760 defm SCRATCH_LOAD_BLOCK : VSCRATCH_Real_AllAddr_gfx12<0x53>;
2761 defm SCRATCH_STORE_BLOCK : VSCRATCH_Real_AllAddr_gfx12<0x54>;