1 //===-- VOP2Instructions.td - Vector Instruction Defintions ---------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
13 class VOP2e <bits<6> op, VOPProfile P> : Enc32 {
18 let Inst{8-0} = !if(P.HasSrc0, src0, 0);
19 let Inst{16-9} = !if(P.HasSrc1, src1, 0);
20 let Inst{24-17} = !if(P.EmitDst, vdst, 0);
22 let Inst{31} = 0x0; //encoding
25 class VOP2_MADKe <bits<6> op, VOPProfile P> : Enc64 {
31 let Inst{8-0} = !if(P.HasSrc0, src0, 0);
32 let Inst{16-9} = !if(P.HasSrc1, src1, 0);
33 let Inst{24-17} = !if(P.EmitDst, vdst, 0);
35 let Inst{31} = 0x0; // encoding
36 let Inst{63-32} = imm;
39 class VOP2_SDWAe <bits<6> op, VOPProfile P> : VOP_SDWAe <P> {
43 let Inst{8-0} = 0xf9; // sdwa
44 let Inst{16-9} = !if(P.HasSrc1, src1{7-0}, 0);
45 let Inst{24-17} = !if(P.EmitDst, vdst{7-0}, 0);
47 let Inst{31} = 0x0; // encoding
50 class VOP2_SDWA9Ae <bits<6> op, VOPProfile P> : VOP_SDWA9Ae <P> {
54 let Inst{8-0} = 0xf9; // sdwa
55 let Inst{16-9} = !if(P.HasSrc1, src1{7-0}, 0);
56 let Inst{24-17} = !if(P.EmitDst, vdst{7-0}, 0);
58 let Inst{31} = 0x0; // encoding
59 let Inst{63} = !if(P.HasSrc1, src1{8}, 0); // src1_sgpr
62 class VOP2_Pseudo <string opName, VOPProfile P, list<dag> pattern=[], string suffix = "_e32"> :
63 VOP_Pseudo <opName, suffix, P, P.Outs32, P.Ins32, "", pattern> {
65 let AsmOperands = P.Asm32;
70 let hasSideEffects = 0;
76 let AsmVariantName = AMDGPUAsmVariants.Default;
79 class VOP2_Real <VOP2_Pseudo ps, int EncodingFamily> :
80 InstSI <ps.OutOperandList, ps.InOperandList, ps.Mnemonic # ps.AsmOperands, []>,
81 SIMCInstr <ps.PseudoInstr, EncodingFamily> {
84 let isCodeGenOnly = 0;
86 let Constraints = ps.Constraints;
87 let DisableEncoding = ps.DisableEncoding;
89 // copy relevant pseudo op flags
90 let SubtargetPredicate = ps.SubtargetPredicate;
91 let AsmMatchConverter = ps.AsmMatchConverter;
92 let AsmVariantName = ps.AsmVariantName;
93 let Constraints = ps.Constraints;
94 let DisableEncoding = ps.DisableEncoding;
95 let TSFlags = ps.TSFlags;
96 let UseNamedOperandTable = ps.UseNamedOperandTable;
101 class VOP2_SDWA_Pseudo <string OpName, VOPProfile P, list<dag> pattern=[]> :
102 VOP_SDWA_Pseudo <OpName, P, pattern> {
103 let AsmMatchConverter = "cvtSdwaVOP2";
106 class VOP2_DPP_Pseudo <string OpName, VOPProfile P, list<dag> pattern=[]> :
107 VOP_DPP_Pseudo <OpName, P, pattern> {
111 class getVOP2Pat64 <SDPatternOperator node, VOPProfile P> : LetDummies {
112 list<dag> ret = !if(P.HasModifiers,
116 (VOP3Mods0 P.Src0VT:$src0, i32:$src0_modifiers, i1:$clamp, i32:$omod),
117 (VOP3Mods0 P.Src0VT:$src0, i32:$src0_modifiers, i1:$clamp))),
118 (P.Src1VT (VOP3Mods P.Src1VT:$src1, i32:$src1_modifiers))))],
119 [(set P.DstVT:$vdst, (node P.Src0VT:$src0, P.Src1VT:$src1))]);
122 multiclass VOP2Inst_e32<string opName,
124 SDPatternOperator node = null_frag,
125 string revOp = opName,
126 bit GFX9Renamed = 0> {
127 let renamedInGFX9 = GFX9Renamed in {
128 def _e32 : VOP2_Pseudo <opName, P, VOPPatOrNull<node,P>.ret>,
129 Commutable_REV<revOp#"_e32", !eq(revOp, opName)>;
130 } // End renamedInGFX9 = GFX9Renamed
133 multiclass VOP2Inst_e64<string opName,
135 SDPatternOperator node = null_frag,
136 string revOp = opName,
137 bit GFX9Renamed = 0> {
138 let renamedInGFX9 = GFX9Renamed in {
139 def _e64 : VOP3_Pseudo <opName, P, getVOP2Pat64<node, P>.ret>,
140 Commutable_REV<revOp#"_e64", !eq(revOp, opName)>;
141 } // End renamedInGFX9 = GFX9Renamed
144 multiclass VOP2Inst_sdwa<string opName,
146 SDPatternOperator node = null_frag,
147 string revOp = opName,
148 bit GFX9Renamed = 0> {
149 let renamedInGFX9 = GFX9Renamed in {
150 def _sdwa : VOP2_SDWA_Pseudo <opName, P>;
151 } // End renamedInGFX9 = GFX9Renamed
154 multiclass VOP2Inst<string opName,
156 SDPatternOperator node = null_frag,
157 string revOp = opName,
158 bit GFX9Renamed = 0> :
159 VOP2Inst_e32<opName, P, node, revOp, GFX9Renamed>,
160 VOP2Inst_e64<opName, P, node, revOp, GFX9Renamed>,
161 VOP2Inst_sdwa<opName, P, node, revOp, GFX9Renamed> {
162 let renamedInGFX9 = GFX9Renamed in {
163 foreach _ = BoolToList<P.HasExtDPP>.ret in
164 def _dpp : VOP2_DPP_Pseudo <opName, P>;
168 multiclass VOP2bInst <string opName,
170 SDPatternOperator node = null_frag,
171 string revOp = opName,
173 bit useSGPRInput = !eq(P.NumSrcArgs, 3)> {
174 let renamedInGFX9 = GFX9Renamed in {
175 let SchedRW = [Write32Bit, WriteSALU] in {
176 let Uses = !if(useSGPRInput, [VCC, EXEC], [EXEC]), Defs = [VCC] in {
177 def _e32 : VOP2_Pseudo <opName, P, VOPPatOrNull<node,P>.ret>,
178 Commutable_REV<revOp#"_e32", !eq(revOp, opName)> {
179 let usesCustomInserter = !eq(P.NumSrcArgs, 2);
182 def _sdwa : VOP2_SDWA_Pseudo <opName, P> {
183 let AsmMatchConverter = "cvtSdwaVOP2b";
185 foreach _ = BoolToList<P.HasExtDPP>.ret in
186 def _dpp : VOP2_DPP_Pseudo <opName, P>;
189 def _e64 : VOP3_Pseudo <opName, P, getVOP2Pat64<node, P>.ret>,
190 Commutable_REV<revOp#"_e64", !eq(revOp, opName)>;
195 class VOP2bInstAlias <VOP2_Pseudo ps, Instruction inst,
196 string OpName, string opnd> :
197 InstAlias <OpName#" "#!subst("vcc", opnd, ps.Pfl.Asm32),
198 (inst ps.Pfl.DstRC:$vdst, ps.Pfl.Src0RC32:$src0,
199 ps.Pfl.Src1RC32:$src1)>,
203 multiclass VOP2bInstAliases<VOP2_Pseudo ps, VOP2_Real inst, string OpName> {
204 let WaveSizePredicate = isWave32 in {
205 def : VOP2bInstAlias<ps, inst, OpName, "vcc_lo">;
207 let WaveSizePredicate = isWave64 in {
208 def : VOP2bInstAlias<ps, inst, OpName, "vcc">;
212 multiclass VOP2eInst <string opName,
214 SDPatternOperator node = null_frag,
215 string revOp = opName,
216 bit useSGPRInput = !eq(P.NumSrcArgs, 3)> {
218 let SchedRW = [Write32Bit] in {
219 let Uses = !if(useSGPRInput, [VCC, EXEC], [EXEC]) in {
220 def _e32 : VOP2_Pseudo <opName, P>,
221 Commutable_REV<revOp#"_e32", !eq(revOp, opName)>;
223 def _sdwa : VOP2_SDWA_Pseudo <opName, P> {
224 let AsmMatchConverter = "cvtSdwaVOP2b";
227 foreach _ = BoolToList<P.HasExtDPP>.ret in
228 def _dpp : VOP2_DPP_Pseudo <opName, P>;
231 def _e64 : VOP3_Pseudo <opName, P, getVOP2Pat64<node, P>.ret>,
232 Commutable_REV<revOp#"_e64", !eq(revOp, opName)>;
236 class VOP2eInstAlias <VOP2_Pseudo ps, Instruction inst, string opnd> :
237 InstAlias <ps.OpName#" "#ps.Pfl.Asm32#", "#opnd,
238 (inst ps.Pfl.DstRC:$vdst, ps.Pfl.Src0RC32:$src0,
239 ps.Pfl.Src1RC32:$src1)>,
243 multiclass VOP2eInstAliases<VOP2_Pseudo ps, VOP2_Real inst> {
244 let WaveSizePredicate = isWave32 in {
245 def : VOP2eInstAlias<ps, inst, "vcc_lo">;
247 let WaveSizePredicate = isWave64 in {
248 def : VOP2eInstAlias<ps, inst, "vcc">;
252 class VOP_MADAK <ValueType vt> : VOPProfile <[vt, vt, vt, vt]> {
253 field Operand ImmOpType = !if(!eq(vt.Size, 32), f32kimm, f16kimm);
254 field dag Ins32 = !if(!eq(vt.Size, 32),
255 (ins VCSrc_f32:$src0, VGPR_32:$src1, ImmOpType:$imm),
256 (ins VCSrc_f16:$src0, VGPR_32:$src1, ImmOpType:$imm));
257 field bit HasExt = 0;
259 // Hack to stop printing _e64
260 let DstRC = RegisterOperand<VGPR_32>;
261 field string Asm32 = " $vdst, $src0, $src1, $imm";
264 def VOP_MADAK_F16 : VOP_MADAK <f16>;
265 def VOP_MADAK_F32 : VOP_MADAK <f32>;
267 class VOP_MADMK <ValueType vt> : VOPProfile <[vt, vt, vt, vt]> {
268 field Operand ImmOpType = !if(!eq(vt.Size, 32), f32kimm, f16kimm);
269 field dag Ins32 = (ins VCSrc_f32:$src0, ImmOpType:$imm, VGPR_32:$src1);
270 field bit HasExt = 0;
272 // Hack to stop printing _e64
273 let DstRC = RegisterOperand<VGPR_32>;
274 field string Asm32 = " $vdst, $src0, $imm, $src1";
277 def VOP_MADMK_F16 : VOP_MADMK <f16>;
278 def VOP_MADMK_F32 : VOP_MADMK <f32>;
280 // FIXME: Remove src2_modifiers. It isn't used, so is wasting memory
281 // and processing time but it makes it easier to convert to mad.
282 class VOP_MAC <ValueType vt0, ValueType vt1=vt0> : VOPProfile <[vt0, vt1, vt1, vt0]> {
283 let Ins32 = (ins Src0RC32:$src0, Src1RC32:$src1, VGPR_32:$src2);
284 let Ins64 = getIns64<Src0RC64, Src1RC64, RegisterOperand<VGPR_32>, 3,
285 0, HasModifiers, HasModifiers, HasOMod,
286 Src0Mod, Src1Mod, Src2Mod>.ret;
287 let InsDPP = (ins Src0ModDPP:$src0_modifiers, Src0DPP:$src0,
288 Src1ModDPP:$src1_modifiers, Src1DPP:$src1,
289 VGPR_32:$src2, // stub argument
290 dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
291 bank_mask:$bank_mask, bound_ctrl:$bound_ctrl);
292 let InsDPP16 = !con(InsDPP, (ins FI:$fi));
294 let InsDPP8 = (ins Src0ModDPP:$src0_modifiers, Src0DPP:$src0,
295 Src1ModDPP:$src1_modifiers, Src1DPP:$src1,
296 VGPR_32:$src2, // stub argument
299 let InsSDWA = (ins Src0ModSDWA:$src0_modifiers, Src0SDWA:$src0,
300 Src1ModSDWA:$src1_modifiers, Src1SDWA:$src1,
301 VGPR_32:$src2, // stub argument
302 clampmod:$clamp, omod:$omod,
303 dst_sel:$dst_sel, dst_unused:$dst_unused,
304 src0_sel:$src0_sel, src1_sel:$src1_sel);
305 let Asm32 = getAsm32<1, 2, vt0>.ret;
306 let Asm64 = getAsm64<1, 2, 0, HasModifiers, HasOMod, vt0>.ret;
307 let AsmDPP = getAsmDPP<1, 2, HasModifiers, vt0>.ret;
308 let AsmDPP16 = getAsmDPP16<1, 2, HasModifiers, vt0>.ret;
309 let AsmDPP8 = getAsmDPP8<1, 2, 0, vt0>.ret;
310 let AsmSDWA = getAsmSDWA<1, 2, vt0>.ret;
311 let AsmSDWA9 = getAsmSDWA9<1, 1, 2, vt0>.ret;
319 let TieRegDPP = "$src2";
322 def VOP_MAC_F16 : VOP_MAC <f16>;
323 def VOP_MAC_F32 : VOP_MAC <f32>;
325 class VOP_DOT_ACC<ValueType vt0, ValueType vt1> : VOP_MAC<vt0, vt1> {
328 let HasModifiers = 1;
333 def VOP_DOT_ACC_F32_V2F16 : VOP_DOT_ACC<f32, v2f16> {
334 let Src0ModDPP = FPVRegInputMods;
335 let Src1ModDPP = FPVRegInputMods;
337 def VOP_DOT_ACC_I32_I32 : VOP_DOT_ACC<i32, i32>;
339 // Write out to vcc or arbitrary SGPR.
340 def VOP2b_I32_I1_I32_I32 : VOPProfile<[i32, i32, i32, untyped], 0, /*EnableClamp=*/1> {
341 let Asm32 = "$vdst, vcc, $src0, $src1";
342 let Asm64 = "$vdst, $sdst, $src0, $src1$clamp";
343 let AsmSDWA = "$vdst, vcc, $src0_modifiers, $src1_modifiers$clamp $dst_sel $dst_unused $src0_sel $src1_sel";
344 let AsmSDWA9 = "$vdst, vcc, $src0_modifiers, $src1_modifiers$clamp $dst_sel $dst_unused $src0_sel $src1_sel";
345 let AsmDPP = "$vdst, vcc, $src0, $src1 $dpp_ctrl$row_mask$bank_mask$bound_ctrl";
346 let AsmDPP8 = "$vdst, vcc, $src0, $src1 $dpp8$fi";
347 let AsmDPP16 = AsmDPP#"$fi";
348 let Outs32 = (outs DstRC:$vdst);
349 let Outs64 = (outs DstRC:$vdst, VOPDstS64orS32:$sdst);
352 // Write out to vcc or arbitrary SGPR and read in from vcc or
354 def VOP2b_I32_I1_I32_I32_I1 : VOPProfile<[i32, i32, i32, i1], 0, /*EnableClamp=*/1> {
355 let Asm32 = "$vdst, vcc, $src0, $src1, vcc";
356 let Asm64 = "$vdst, $sdst, $src0, $src1, $src2$clamp";
357 let AsmSDWA = "$vdst, vcc, $src0_modifiers, $src1_modifiers, vcc $clamp $dst_sel $dst_unused $src0_sel $src1_sel";
358 let AsmSDWA9 = "$vdst, vcc, $src0_modifiers, $src1_modifiers, vcc $clamp $dst_sel $dst_unused $src0_sel $src1_sel";
359 let AsmDPP = "$vdst, vcc, $src0, $src1, vcc $dpp_ctrl$row_mask$bank_mask$bound_ctrl";
360 let AsmDPP8 = "$vdst, vcc, $src0, $src1, vcc $dpp8$fi";
361 let AsmDPP16 = AsmDPP#"$fi";
362 let Outs32 = (outs DstRC:$vdst);
363 let Outs64 = (outs DstRC:$vdst, VOPDstS64orS32:$sdst);
365 // Suppress src2 implied by type since the 32-bit encoding uses an
367 let Ins32 = (ins Src0RC32:$src0, Src1RC32:$src1);
369 let InsSDWA = (ins Src0ModSDWA:$src0_modifiers, Src0SDWA:$src0,
370 Src1ModSDWA:$src1_modifiers, Src1SDWA:$src1,
372 dst_sel:$dst_sel, dst_unused:$dst_unused,
373 src0_sel:$src0_sel, src1_sel:$src1_sel);
375 let InsDPP = (ins DstRCDPP:$old,
378 dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
379 bank_mask:$bank_mask, bound_ctrl:$bound_ctrl);
380 let InsDPP16 = !con(InsDPP, (ins FI:$fi));
388 // Read in from vcc or arbitrary SGPR.
389 def VOP2e_I32_I32_I32_I1 : VOPProfile<[i32, i32, i32, i1], /*EnableF32SrcMods=*/1> {
390 let Asm32 = "$vdst, $src0, $src1";
391 let Asm64 = "$vdst, $src0_modifiers, $src1_modifiers, $src2";
392 let AsmSDWA = "$vdst, $src0_modifiers, $src1_modifiers, vcc $clamp $dst_sel $dst_unused $src0_sel $src1_sel";
393 let AsmSDWA9 = "$vdst, $src0_modifiers, $src1_modifiers, vcc $clamp $dst_sel $dst_unused $src0_sel $src1_sel";
394 let AsmDPP = "$vdst, $src0, $src1, vcc $dpp_ctrl$row_mask$bank_mask$bound_ctrl";
395 let AsmDPP8 = "$vdst, $src0, $src1, vcc $dpp8$fi";
396 let AsmDPP16 = AsmDPP#"$fi";
398 let Outs32 = (outs DstRC:$vdst);
399 let Outs64 = (outs DstRC:$vdst);
401 // Suppress src2 implied by type since the 32-bit encoding uses an
403 let Ins32 = (ins Src0RC32:$src0, Src1RC32:$src1);
405 let InsSDWA = (ins Src0ModSDWA:$src0_modifiers, Src0SDWA:$src0,
406 Src1ModSDWA:$src1_modifiers, Src1SDWA:$src1,
408 dst_sel:$dst_sel, dst_unused:$dst_unused,
409 src0_sel:$src0_sel, src1_sel:$src1_sel);
411 let InsDPP = (ins DstRCDPP:$old,
412 Src0ModDPP:$src0_modifiers, Src0DPP:$src0,
413 Src1ModDPP:$src1_modifiers, Src1DPP:$src1,
414 dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
415 bank_mask:$bank_mask, bound_ctrl:$bound_ctrl);
416 let InsDPP16 = !con(InsDPP, (ins FI:$fi));
424 def VOP_READLANE : VOPProfile<[i32, i32, i32]> {
425 let Outs32 = (outs SReg_32:$vdst);
427 let Ins32 = (ins VRegOrLds_32:$src0, SCSrc_b32:$src1);
429 let Asm32 = " $vdst, $src0, $src1";
438 def VOP_WRITELANE : VOPProfile<[i32, i32, i32, i32]> {
439 let Outs32 = (outs VGPR_32:$vdst);
441 let Ins32 = (ins SCSrc_b32:$src0, SCSrc_b32:$src1, VGPR_32:$vdst_in);
443 let Asm32 = " $vdst, $src0, $src1";
454 //===----------------------------------------------------------------------===//
456 //===----------------------------------------------------------------------===//
458 defm V_CNDMASK_B32 : VOP2eInst <"v_cndmask_b32", VOP2e_I32_I32_I32_I1>;
459 def V_MADMK_F32 : VOP2_Pseudo <"v_madmk_f32", VOP_MADMK_F32, []>;
461 let isCommutable = 1 in {
462 defm V_ADD_F32 : VOP2Inst <"v_add_f32", VOP_F32_F32_F32, fadd>;
463 defm V_SUB_F32 : VOP2Inst <"v_sub_f32", VOP_F32_F32_F32, fsub>;
464 defm V_SUBREV_F32 : VOP2Inst <"v_subrev_f32", VOP_F32_F32_F32, null_frag, "v_sub_f32">;
465 defm V_MUL_LEGACY_F32 : VOP2Inst <"v_mul_legacy_f32", VOP_F32_F32_F32, AMDGPUfmul_legacy>;
466 defm V_MUL_F32 : VOP2Inst <"v_mul_f32", VOP_F32_F32_F32, fmul>;
467 defm V_MUL_I32_I24 : VOP2Inst <"v_mul_i32_i24", VOP_PAT_GEN<VOP_I32_I32_I32, 2>, AMDGPUmul_i24>;
468 defm V_MUL_HI_I32_I24 : VOP2Inst <"v_mul_hi_i32_i24", VOP_PAT_GEN<VOP_I32_I32_I32, 2>, AMDGPUmulhi_i24>;
469 defm V_MUL_U32_U24 : VOP2Inst <"v_mul_u32_u24", VOP_PAT_GEN<VOP_I32_I32_I32, 2>, AMDGPUmul_u24>;
470 defm V_MUL_HI_U32_U24 : VOP2Inst <"v_mul_hi_u32_u24", VOP_PAT_GEN<VOP_I32_I32_I32, 2>, AMDGPUmulhi_u24>;
471 defm V_MIN_F32 : VOP2Inst <"v_min_f32", VOP_F32_F32_F32, fminnum_like>;
472 defm V_MAX_F32 : VOP2Inst <"v_max_f32", VOP_F32_F32_F32, fmaxnum_like>;
473 defm V_MIN_I32 : VOP2Inst <"v_min_i32", VOP_PAT_GEN<VOP_I32_I32_I32>, smin>;
474 defm V_MAX_I32 : VOP2Inst <"v_max_i32", VOP_PAT_GEN<VOP_I32_I32_I32>, smax>;
475 defm V_MIN_U32 : VOP2Inst <"v_min_u32", VOP_PAT_GEN<VOP_I32_I32_I32>, umin>;
476 defm V_MAX_U32 : VOP2Inst <"v_max_u32", VOP_PAT_GEN<VOP_I32_I32_I32>, umax>;
477 defm V_LSHRREV_B32 : VOP2Inst <"v_lshrrev_b32", VOP_I32_I32_I32, lshr_rev, "v_lshr_b32">;
478 defm V_ASHRREV_I32 : VOP2Inst <"v_ashrrev_i32", VOP_I32_I32_I32, ashr_rev, "v_ashr_i32">;
479 defm V_LSHLREV_B32 : VOP2Inst <"v_lshlrev_b32", VOP_I32_I32_I32, lshl_rev, "v_lshl_b32">;
480 defm V_AND_B32 : VOP2Inst <"v_and_b32", VOP_PAT_GEN<VOP_I32_I32_I32>, and>;
481 defm V_OR_B32 : VOP2Inst <"v_or_b32", VOP_PAT_GEN<VOP_I32_I32_I32>, or>;
482 defm V_XOR_B32 : VOP2Inst <"v_xor_b32", VOP_PAT_GEN<VOP_I32_I32_I32>, xor>;
484 let Constraints = "$vdst = $src2", DisableEncoding="$src2",
485 isConvertibleToThreeAddress = 1 in {
486 defm V_MAC_F32 : VOP2Inst <"v_mac_f32", VOP_MAC_F32>;
489 def V_MADAK_F32 : VOP2_Pseudo <"v_madak_f32", VOP_MADAK_F32, []>;
491 // No patterns so that the scalar instructions are always selected.
492 // The scalar versions will be replaced with vector when needed later.
494 // V_ADD_I32, V_SUB_I32, and V_SUBREV_I32 where renamed to *_U32 in VI,
495 // but the VI instructions behave the same as the SI versions.
496 defm V_ADD_I32 : VOP2bInst <"v_add_i32", VOP2b_I32_I1_I32_I32, null_frag, "v_add_i32", 1>;
497 defm V_SUB_I32 : VOP2bInst <"v_sub_i32", VOP2b_I32_I1_I32_I32, null_frag, "v_sub_i32", 1>;
498 defm V_SUBREV_I32 : VOP2bInst <"v_subrev_i32", VOP2b_I32_I1_I32_I32, null_frag, "v_sub_i32", 1>;
499 defm V_ADDC_U32 : VOP2bInst <"v_addc_u32", VOP2b_I32_I1_I32_I32_I1, null_frag, "v_addc_u32", 1>;
500 defm V_SUBB_U32 : VOP2bInst <"v_subb_u32", VOP2b_I32_I1_I32_I32_I1, null_frag, "v_subb_u32", 1>;
501 defm V_SUBBREV_U32 : VOP2bInst <"v_subbrev_u32", VOP2b_I32_I1_I32_I32_I1, null_frag, "v_subb_u32", 1>;
504 let SubtargetPredicate = HasAddNoCarryInsts in {
505 defm V_ADD_U32 : VOP2Inst <"v_add_u32", VOP_I32_I32_I32_ARITH, null_frag, "v_add_u32", 1>;
506 defm V_SUB_U32 : VOP2Inst <"v_sub_u32", VOP_I32_I32_I32_ARITH, null_frag, "v_sub_u32", 1>;
507 defm V_SUBREV_U32 : VOP2Inst <"v_subrev_u32", VOP_I32_I32_I32_ARITH, null_frag, "v_sub_u32", 1>;
510 } // End isCommutable = 1
512 // These are special and do not read the exec mask.
513 let isConvergent = 1, Uses = []<Register> in {
514 def V_READLANE_B32 : VOP2_Pseudo<"v_readlane_b32", VOP_READLANE,
515 [(set i32:$vdst, (int_amdgcn_readlane i32:$src0, i32:$src1))]>;
517 let Constraints = "$vdst = $vdst_in", DisableEncoding="$vdst_in" in {
518 def V_WRITELANE_B32 : VOP2_Pseudo<"v_writelane_b32", VOP_WRITELANE,
519 [(set i32:$vdst, (int_amdgcn_writelane i32:$src0, i32:$src1, i32:$vdst_in))]>;
520 } // End $vdst = $vdst_in, DisableEncoding $vdst_in
521 } // End isConvergent = 1
523 defm V_BFM_B32 : VOP2Inst <"v_bfm_b32", VOP_NO_EXT<VOP_I32_I32_I32>>;
524 defm V_BCNT_U32_B32 : VOP2Inst <"v_bcnt_u32_b32", VOP_NO_EXT<VOP_I32_I32_I32>, add_ctpop>;
525 defm V_MBCNT_LO_U32_B32 : VOP2Inst <"v_mbcnt_lo_u32_b32", VOP_NO_EXT<VOP_I32_I32_I32>, int_amdgcn_mbcnt_lo>;
526 defm V_MBCNT_HI_U32_B32 : VOP2Inst <"v_mbcnt_hi_u32_b32", VOP_NO_EXT<VOP_I32_I32_I32>, int_amdgcn_mbcnt_hi>;
527 defm V_LDEXP_F32 : VOP2Inst <"v_ldexp_f32", VOP_NO_EXT<VOP_F32_F32_I32>, AMDGPUldexp>;
528 defm V_CVT_PKACCUM_U8_F32 : VOP2Inst <"v_cvt_pkaccum_u8_f32", VOP_NO_EXT<VOP_I32_F32_I32>>; // TODO: set "Uses = dst"
529 defm V_CVT_PKNORM_I16_F32 : VOP2Inst <"v_cvt_pknorm_i16_f32", VOP_NO_EXT<VOP_V2I16_F32_F32>, AMDGPUpknorm_i16_f32>;
530 defm V_CVT_PKNORM_U16_F32 : VOP2Inst <"v_cvt_pknorm_u16_f32", VOP_NO_EXT<VOP_V2I16_F32_F32>, AMDGPUpknorm_u16_f32>;
531 defm V_CVT_PKRTZ_F16_F32 : VOP2Inst <"v_cvt_pkrtz_f16_f32", VOP_NO_EXT<VOP_V2F16_F32_F32>, AMDGPUpkrtz_f16_f32>;
532 defm V_CVT_PK_U16_U32 : VOP2Inst <"v_cvt_pk_u16_u32", VOP_NO_EXT<VOP_V2I16_I32_I32>, AMDGPUpk_u16_u32>;
533 defm V_CVT_PK_I16_I32 : VOP2Inst <"v_cvt_pk_i16_i32", VOP_NO_EXT<VOP_V2I16_I32_I32>, AMDGPUpk_i16_i32>;
536 let SubtargetPredicate = isGFX6GFX7 in {
537 defm V_MIN_LEGACY_F32 : VOP2Inst <"v_min_legacy_f32", VOP_F32_F32_F32, AMDGPUfmin_legacy>;
538 defm V_MAX_LEGACY_F32 : VOP2Inst <"v_max_legacy_f32", VOP_F32_F32_F32, AMDGPUfmax_legacy>;
539 } // End SubtargetPredicate = isGFX6GFX7
541 let SubtargetPredicate = isGFX6GFX7GFX10 in {
542 let isCommutable = 1 in {
543 defm V_MAC_LEGACY_F32 : VOP2Inst <"v_mac_legacy_f32", VOP_F32_F32_F32>;
544 defm V_LSHR_B32 : VOP2Inst <"v_lshr_b32", VOP_I32_I32_I32, srl>;
545 defm V_ASHR_I32 : VOP2Inst <"v_ashr_i32", VOP_I32_I32_I32, sra>;
546 defm V_LSHL_B32 : VOP2Inst <"v_lshl_b32", VOP_I32_I32_I32, shl>;
547 } // End isCommutable = 1
548 } // End SubtargetPredicate = isGFX6GFX7GFX10
550 class DivergentBinOp<SDPatternOperator Op, VOP_Pseudo Inst> :
552 (getDivergentFrag<Op>.ret Inst.Pfl.Src0VT:$src0, Inst.Pfl.Src1VT:$src1),
553 !if(!cast<Commutable_REV>(Inst).IsOrig,
559 class DivergentClampingBinOp<SDPatternOperator Op, VOP_Pseudo Inst> :
561 (getDivergentFrag<Op>.ret Inst.Pfl.Src0VT:$src0, Inst.Pfl.Src1VT:$src1),
562 !if(!cast<Commutable_REV>(Inst).IsOrig,
563 (Inst $src0, $src1, 0),
564 (Inst $src1, $src0, 0)
568 def : DivergentBinOp<srl, V_LSHRREV_B32_e64>;
569 def : DivergentBinOp<sra, V_ASHRREV_I32_e64>;
570 def : DivergentBinOp<shl, V_LSHLREV_B32_e64>;
572 let SubtargetPredicate = HasAddNoCarryInsts in {
573 def : DivergentClampingBinOp<add, V_ADD_U32_e64>;
574 def : DivergentClampingBinOp<sub, V_SUB_U32_e64>;
577 let SubtargetPredicate = isGFX6GFX7GFX8GFX9, Predicates = [isGFX6GFX7GFX8GFX9] in {
578 def : DivergentClampingBinOp<add, V_ADD_I32_e64>;
579 def : DivergentClampingBinOp<sub, V_SUB_I32_e64>;
582 def : DivergentBinOp<adde, V_ADDC_U32_e32>;
583 def : DivergentBinOp<sube, V_SUBB_U32_e32>;
585 class divergent_i64_BinOp <SDPatternOperator Op, Instruction Inst> :
587 (getDivergentFrag<Op>.ret i64:$src0, i64:$src1),
588 (REG_SEQUENCE VReg_64,
590 (i32 (EXTRACT_SUBREG $src0, sub0)),
591 (i32 (EXTRACT_SUBREG $src1, sub0))
594 (i32 (EXTRACT_SUBREG $src0, sub1)),
595 (i32 (EXTRACT_SUBREG $src1, sub1))
600 def : divergent_i64_BinOp <and, V_AND_B32_e32>;
601 def : divergent_i64_BinOp <or, V_OR_B32_e32>;
602 def : divergent_i64_BinOp <xor, V_XOR_B32_e32>;
604 let SubtargetPredicate = Has16BitInsts in {
606 let FPDPRounding = 1 in {
607 def V_MADMK_F16 : VOP2_Pseudo <"v_madmk_f16", VOP_MADMK_F16, [], "">;
608 defm V_LDEXP_F16 : VOP2Inst <"v_ldexp_f16", VOP_F16_F16_I32, AMDGPUldexp>;
609 } // End FPDPRounding = 1
611 defm V_LSHLREV_B16 : VOP2Inst <"v_lshlrev_b16", VOP_I16_I16_I16>;
612 defm V_LSHRREV_B16 : VOP2Inst <"v_lshrrev_b16", VOP_I16_I16_I16>;
613 defm V_ASHRREV_I16 : VOP2Inst <"v_ashrrev_i16", VOP_I16_I16_I16>;
615 let isCommutable = 1 in {
616 let FPDPRounding = 1 in {
617 defm V_ADD_F16 : VOP2Inst <"v_add_f16", VOP_F16_F16_F16, fadd>;
618 defm V_SUB_F16 : VOP2Inst <"v_sub_f16", VOP_F16_F16_F16, fsub>;
619 defm V_SUBREV_F16 : VOP2Inst <"v_subrev_f16", VOP_F16_F16_F16, null_frag, "v_sub_f16">;
620 defm V_MUL_F16 : VOP2Inst <"v_mul_f16", VOP_F16_F16_F16, fmul>;
621 def V_MADAK_F16 : VOP2_Pseudo <"v_madak_f16", VOP_MADAK_F16, [], "">;
622 } // End FPDPRounding = 1
623 defm V_ADD_U16 : VOP2Inst <"v_add_u16", VOP_I16_I16_I16>;
624 defm V_SUB_U16 : VOP2Inst <"v_sub_u16" , VOP_I16_I16_I16>;
625 defm V_SUBREV_U16 : VOP2Inst <"v_subrev_u16", VOP_I16_I16_I16, null_frag, "v_sub_u16">;
626 defm V_MUL_LO_U16 : VOP2Inst <"v_mul_lo_u16", VOP_I16_I16_I16>;
627 defm V_MAX_F16 : VOP2Inst <"v_max_f16", VOP_F16_F16_F16, fmaxnum_like>;
628 defm V_MIN_F16 : VOP2Inst <"v_min_f16", VOP_F16_F16_F16, fminnum_like>;
629 defm V_MAX_U16 : VOP2Inst <"v_max_u16", VOP_I16_I16_I16>;
630 defm V_MAX_I16 : VOP2Inst <"v_max_i16", VOP_I16_I16_I16>;
631 defm V_MIN_U16 : VOP2Inst <"v_min_u16", VOP_I16_I16_I16>;
632 defm V_MIN_I16 : VOP2Inst <"v_min_i16", VOP_I16_I16_I16>;
634 let Constraints = "$vdst = $src2", DisableEncoding="$src2",
635 isConvertibleToThreeAddress = 1 in {
636 defm V_MAC_F16 : VOP2Inst <"v_mac_f16", VOP_MAC_F16>;
638 } // End isCommutable = 1
640 } // End SubtargetPredicate = Has16BitInsts
642 let SubtargetPredicate = HasDLInsts in {
644 defm V_XNOR_B32 : VOP2Inst <"v_xnor_b32", VOP_I32_I32_I32>;
646 let Constraints = "$vdst = $src2",
647 DisableEncoding="$src2",
648 isConvertibleToThreeAddress = 1,
649 isCommutable = 1 in {
650 defm V_FMAC_F32 : VOP2Inst <"v_fmac_f32", VOP_MAC_F32>;
653 } // End SubtargetPredicate = HasDLInsts
655 let Constraints = "$vdst = $src2",
656 DisableEncoding="$src2",
657 isConvertibleToThreeAddress = 1,
660 let SubtargetPredicate = HasDot5Insts in
661 defm V_DOT2C_F32_F16 : VOP2Inst_e32<"v_dot2c_f32_f16", VOP_DOT_ACC_F32_V2F16>;
662 let SubtargetPredicate = HasDot6Insts in
663 defm V_DOT4C_I32_I8 : VOP2Inst_e32<"v_dot4c_i32_i8", VOP_DOT_ACC_I32_I32>;
665 let SubtargetPredicate = HasDot4Insts in
666 defm V_DOT2C_I32_I16 : VOP2Inst_e32<"v_dot2c_i32_i16", VOP_DOT_ACC_I32_I32>;
667 let SubtargetPredicate = HasDot3Insts in
668 defm V_DOT8C_I32_I4 : VOP2Inst_e32<"v_dot8c_i32_i4", VOP_DOT_ACC_I32_I32>;
671 let AddedComplexity = 30 in {
673 (f32 (AMDGPUfdot2 v2f16:$src0, v2f16:$src1, f32:$src2, (i1 DSTCLAMP.NONE))),
674 (f32 (V_DOT2C_F32_F16_e32 $src0, $src1, $src2))
676 let SubtargetPredicate = HasDot5Insts;
679 (i32 (int_amdgcn_sdot4 i32:$src0, i32:$src1, i32:$src2, (i1 DSTCLAMP.NONE))),
680 (i32 (V_DOT4C_I32_I8_e32 $src0, $src1, $src2))
682 let SubtargetPredicate = HasDot6Insts;
685 (i32 (int_amdgcn_sdot2 v2i16:$src0, v2i16:$src1, i32:$src2, (i1 DSTCLAMP.NONE))),
686 (i32 (V_DOT2C_I32_I16_e32 $src0, $src1, $src2))
688 let SubtargetPredicate = HasDot4Insts;
691 (i32 (int_amdgcn_sdot8 i32:$src0, i32:$src1, i32:$src2, (i1 DSTCLAMP.NONE))),
692 (i32 (V_DOT8C_I32_I4_e32 $src0, $src1, $src2))
694 let SubtargetPredicate = HasDot3Insts;
696 } // End AddedComplexity = 30
698 let SubtargetPredicate = isGFX10Plus in {
700 def V_FMAMK_F32 : VOP2_Pseudo<"v_fmamk_f32", VOP_MADMK_F32, [], "">;
701 let FPDPRounding = 1 in
702 def V_FMAMK_F16 : VOP2_Pseudo <"v_fmamk_f16", VOP_MADMK_F16, [], "">;
704 let isCommutable = 1 in {
705 def V_FMAAK_F32 : VOP2_Pseudo<"v_fmaak_f32", VOP_MADAK_F32, [], "">;
706 let FPDPRounding = 1 in
707 def V_FMAAK_F16 : VOP2_Pseudo <"v_fmaak_f16", VOP_MADAK_F16, [], "">;
708 } // End isCommutable = 1
710 let Constraints = "$vdst = $src2",
711 DisableEncoding="$src2",
712 isConvertibleToThreeAddress = 1,
713 isCommutable = 1 in {
714 defm V_FMAC_F16 : VOP2Inst <"v_fmac_f16", VOP_MAC_F16>;
717 } // End SubtargetPredicate = isGFX10Plus
719 let SubtargetPredicate = HasPkFmacF16Inst in {
720 defm V_PK_FMAC_F16 : VOP2Inst<"v_pk_fmac_f16", VOP_V2F16_V2F16_V2F16>;
721 } // End SubtargetPredicate = HasPkFmacF16Inst
723 // Note: 16-bit instructions produce a 0 result in the high 16-bits
724 // on GFX8 and GFX9 and preserve high 16 bits on GFX10+
725 def ClearHI16 : OutPatFrag<(ops node:$op),
726 (V_AND_B32_e64 $op, (V_MOV_B32_e32 (i32 0xffff)))>;
728 multiclass Arithmetic_i16_Pats <SDPatternOperator op, Instruction inst,
729 bit PreservesHI16 = 0> {
732 (op i16:$src0, i16:$src1),
733 !if(!eq(PreservesHI16,1), (ClearHI16 (inst $src0, $src1)), (inst $src0, $src1))
737 (i32 (zext (op i16:$src0, i16:$src1))),
738 !if(!eq(PreservesHI16,1), (ClearHI16 (inst $src0, $src1)), (inst $src0, $src1))
742 (i64 (zext (op i16:$src0, i16:$src1))),
743 (REG_SEQUENCE VReg_64,
744 !if(!eq(PreservesHI16,1), (ClearHI16 (inst $src0, $src1)), (inst $src0, $src1)),
746 (V_MOV_B32_e32 (i32 0)), sub1)
750 multiclass Bits_OpsRev_i16_Pats <SDPatternOperator op, Instruction inst,
751 bit PreservesHI16 = 0> {
754 (op i16:$src0, i16:$src1),
755 !if(!eq(PreservesHI16,1), (ClearHI16 (inst $src1, $src0)), (inst $src1, $src0))
759 (i32 (zext (op i16:$src0, i16:$src1))),
760 !if(!eq(PreservesHI16,1), (ClearHI16 (inst $src1, $src0)), (inst $src1, $src0))
765 (i64 (zext (op i16:$src0, i16:$src1))),
766 (REG_SEQUENCE VReg_64,
767 !if(!eq(PreservesHI16,1), (ClearHI16 (inst $src1, $src0)), (inst $src1, $src0)),
769 (V_MOV_B32_e32 (i32 0)), sub1)
773 class ZExt_i16_i1_Pat <SDNode ext> : GCNPat <
775 (V_CNDMASK_B32_e64 (i32 0/*src0mod*/), (i32 0/*src0*/),
776 (i32 0/*src1mod*/), (i32 1/*src1*/),
780 let Predicates = [Has16BitInsts] in {
782 let Predicates = [Has16BitInsts, isGFX7GFX8GFX9] in {
783 defm : Arithmetic_i16_Pats<add, V_ADD_U16_e64>;
784 defm : Arithmetic_i16_Pats<mul, V_MUL_LO_U16_e64>;
785 defm : Arithmetic_i16_Pats<sub, V_SUB_U16_e64>;
786 defm : Arithmetic_i16_Pats<smin, V_MIN_I16_e64>;
787 defm : Arithmetic_i16_Pats<smax, V_MAX_I16_e64>;
788 defm : Arithmetic_i16_Pats<umin, V_MIN_U16_e64>;
789 defm : Arithmetic_i16_Pats<umax, V_MAX_U16_e64>;
792 let Predicates = [Has16BitInsts, isGFX10Plus] in {
793 defm : Arithmetic_i16_Pats<add, V_ADD_U16_e64, 1>;
794 defm : Arithmetic_i16_Pats<mul, V_MUL_LO_U16_e64, 1>;
795 defm : Arithmetic_i16_Pats<sub, V_SUB_U16_e64, 1>;
796 defm : Arithmetic_i16_Pats<smin, V_MIN_I16_e64, 1>;
797 defm : Arithmetic_i16_Pats<smax, V_MAX_I16_e64, 1>;
798 defm : Arithmetic_i16_Pats<umin, V_MIN_U16_e64, 1>;
799 defm : Arithmetic_i16_Pats<umax, V_MAX_U16_e64, 1>;
803 (and i16:$src0, i16:$src1),
804 (V_AND_B32_e64 VSrc_b32:$src0, VSrc_b32:$src1)
808 (or i16:$src0, i16:$src1),
809 (V_OR_B32_e64 VSrc_b32:$src0, VSrc_b32:$src1)
813 (xor i16:$src0, i16:$src1),
814 (V_XOR_B32_e64 VSrc_b32:$src0, VSrc_b32:$src1)
817 let Predicates = [Has16BitInsts, isGFX7GFX8GFX9] in {
818 defm : Bits_OpsRev_i16_Pats<shl, V_LSHLREV_B16_e64>;
819 defm : Bits_OpsRev_i16_Pats<srl, V_LSHRREV_B16_e64>;
820 defm : Bits_OpsRev_i16_Pats<sra, V_ASHRREV_I16_e64>;
823 let Predicates = [Has16BitInsts, isGFX10Plus] in {
824 defm : Bits_OpsRev_i16_Pats<shl, V_LSHLREV_B16_e64, 1>;
825 defm : Bits_OpsRev_i16_Pats<srl, V_LSHRREV_B16_e64, 1>;
826 defm : Bits_OpsRev_i16_Pats<sra, V_ASHRREV_I16_e64, 1>;
829 def : ZExt_i16_i1_Pat<zext>;
830 def : ZExt_i16_i1_Pat<anyext>;
833 (i16 (sext i1:$src)),
834 (V_CNDMASK_B32_e64 /*src0mod*/(i32 0), /*src0*/(i32 0),
835 /*src1mod*/(i32 0), /*src1*/(i32 -1), $src)
838 // Undo sub x, c -> add x, -c canonicalization since c is more likely
839 // an inline immediate than -c.
840 // TODO: Also do for 64-bit.
842 (add i16:$src0, (i16 NegSubInlineConst16:$src1)),
843 (V_SUB_U16_e64 $src0, NegSubInlineConst16:$src1)
846 } // End Predicates = [Has16BitInsts, isGFX7GFX8GFX9]
849 //===----------------------------------------------------------------------===//
850 // Target-specific instruction encodings.
851 //===----------------------------------------------------------------------===//
853 class VOP2_DPP<bits<6> op, VOP2_Pseudo ps,
854 string opName = ps.OpName, VOPProfile p = ps.Pfl,
856 VOP_DPP<opName, p, IsDPP16> {
857 let hasSideEffects = ps.hasSideEffects;
859 let SchedRW = ps.SchedRW;
864 let Inst{8-0} = 0xfa;
865 let Inst{16-9} = !if(p.HasSrc1, src1{7-0}, 0);
866 let Inst{24-17} = !if(p.EmitDst, vdst{7-0}, 0);
867 let Inst{30-25} = op;
871 class VOP2_DPP16<bits<6> op, VOP2_Pseudo ps,
872 string opName = ps.OpName, VOPProfile p = ps.Pfl> :
873 VOP2_DPP<op, ps, opName, p, 1> {
874 let AssemblerPredicate = !if(p.HasExt, HasDPP16, DisableInst);
875 let SubtargetPredicate = HasDPP16;
878 class VOP2_DPP8<bits<6> op, VOP2_Pseudo ps,
879 string opName = ps.OpName, VOPProfile p = ps.Pfl> :
880 VOP_DPP8<ps.OpName, p> {
881 let hasSideEffects = ps.hasSideEffects;
883 let SchedRW = ps.SchedRW;
890 let Inst{16-9} = !if(p.HasSrc1, src1{7-0}, 0);
891 let Inst{24-17} = !if(p.EmitDst, vdst{7-0}, 0);
892 let Inst{30-25} = op;
895 let AssemblerPredicate = !if(p.HasExt, HasDPP8, DisableInst);
896 let SubtargetPredicate = HasDPP8;
899 //===----------------------------------------------------------------------===//
901 //===----------------------------------------------------------------------===//
903 let AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10" in {
904 //===------------------------------- VOP2 -------------------------------===//
905 multiclass VOP2Only_Real_MADK_gfx10<bits<6> op> {
907 VOP2_Real<!cast<VOP2_Pseudo>(NAME), SIEncodingFamily.GFX10>,
908 VOP2_MADKe<op{5-0}, !cast<VOP2_Pseudo>(NAME).Pfl>;
910 multiclass VOP2Only_Real_MADK_gfx10_with_name<bits<6> op, string opName,
913 VOP2_Real<!cast<VOP2_Pseudo>(opName), SIEncodingFamily.GFX10>,
914 VOP2_MADKe<op{5-0}, !cast<VOP2_Pseudo>(opName).Pfl> {
915 VOP2_Pseudo ps = !cast<VOP2_Pseudo>(opName);
916 let AsmString = asmName # ps.AsmOperands;
919 multiclass VOP2_Real_e32_gfx10<bits<6> op> {
921 VOP2_Real<!cast<VOP2_Pseudo>(NAME#"_e32"), SIEncodingFamily.GFX10>,
922 VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME#"_e32").Pfl>;
924 multiclass VOP2_Real_e64_gfx10<bits<6> op> {
926 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX10>,
927 VOP3e_gfx10<{0, 1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
929 multiclass VOP2_Real_sdwa_gfx10<bits<6> op> {
931 VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa")>,
932 VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa").Pfl> {
933 let DecoderNamespace = "SDWA10";
936 multiclass VOP2_Real_dpp_gfx10<bits<6> op> {
937 def _dpp_gfx10 : VOP2_DPP16<op, !cast<VOP2_Pseudo>(NAME#"_e32")> {
938 let DecoderNamespace = "SDWA10";
941 multiclass VOP2_Real_dpp8_gfx10<bits<6> op> {
942 def _dpp8_gfx10 : VOP2_DPP8<op, !cast<VOP2_Pseudo>(NAME#"_e32")> {
943 let DecoderNamespace = "DPP8";
947 //===------------------------- VOP2 (with name) -------------------------===//
948 multiclass VOP2_Real_e32_gfx10_with_name<bits<6> op, string opName,
951 VOP2_Real<!cast<VOP2_Pseudo>(opName#"_e32"), SIEncodingFamily.GFX10>,
952 VOP2e<op{5-0}, !cast<VOP2_Pseudo>(opName#"_e32").Pfl> {
953 VOP2_Pseudo ps = !cast<VOP2_Pseudo>(opName#"_e32");
954 let AsmString = asmName # ps.AsmOperands;
957 multiclass VOP2_Real_e64_gfx10_with_name<bits<6> op, string opName,
960 VOP3_Real<!cast<VOP3_Pseudo>(opName#"_e64"), SIEncodingFamily.GFX10>,
961 VOP3e_gfx10<{0, 1, 0, 0, op{5-0}},
962 !cast<VOP3_Pseudo>(opName#"_e64").Pfl> {
963 VOP3_Pseudo ps = !cast<VOP3_Pseudo>(opName#"_e64");
964 let AsmString = asmName # ps.AsmOperands;
967 let DecoderNamespace = "SDWA10" in {
968 multiclass VOP2_Real_sdwa_gfx10_with_name<bits<6> op, string opName,
971 VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(opName#"_sdwa")>,
972 VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa").Pfl> {
973 VOP2_SDWA_Pseudo ps = !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa");
974 let AsmString = asmName # ps.AsmOperands;
977 multiclass VOP2_Real_dpp_gfx10_with_name<bits<6> op, string opName,
979 def _dpp_gfx10 : VOP2_DPP16<op, !cast<VOP2_Pseudo>(opName#"_e32")> {
980 VOP2_Pseudo ps = !cast<VOP2_Pseudo>(opName#"_e32");
981 let AsmString = asmName # ps.Pfl.AsmDPP16;
984 multiclass VOP2_Real_dpp8_gfx10_with_name<bits<6> op, string opName,
986 def _dpp8_gfx10 : VOP2_DPP8<op, !cast<VOP2_Pseudo>(opName#"_e32")> {
987 VOP2_Pseudo ps = !cast<VOP2_Pseudo>(opName#"_e32");
988 let AsmString = asmName # ps.Pfl.AsmDPP8;
989 let DecoderNamespace = "DPP8";
992 } // End DecoderNamespace = "SDWA10"
994 //===------------------------------ VOP2be ------------------------------===//
995 multiclass VOP2be_Real_gfx10<bits<6> op, string opName, string asmName> {
997 VOP2_Real<!cast<VOP2_Pseudo>(opName#"_e32"), SIEncodingFamily.GFX10>,
998 VOP2e<op{5-0}, !cast<VOP2_Pseudo>(opName#"_e32").Pfl> {
999 VOP2_Pseudo Ps = !cast<VOP2_Pseudo>(opName#"_e32");
1000 let AsmString = asmName # !subst(", vcc", "", Ps.AsmOperands);
1003 VOP3_Real<!cast<VOP3_Pseudo>(opName#"_e64"), SIEncodingFamily.GFX10>,
1004 VOP3be_gfx10<{0, 1, 0, 0, op{5-0}},
1005 !cast<VOP3_Pseudo>(opName#"_e64").Pfl> {
1006 VOP3_Pseudo Ps = !cast<VOP3_Pseudo>(opName#"_e64");
1007 let AsmString = asmName # Ps.AsmOperands;
1010 VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(opName#"_sdwa")>,
1011 VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa").Pfl> {
1012 VOP2_SDWA_Pseudo Ps = !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa");
1013 let AsmString = asmName # !subst(", vcc", "", Ps.AsmOperands);
1014 let DecoderNamespace = "SDWA10";
1017 VOP2_DPP16<op, !cast<VOP2_Pseudo>(opName#"_e32"), asmName> {
1018 string AsmDPP = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP16;
1019 let AsmString = asmName # !subst(", vcc", "", AsmDPP);
1020 let DecoderNamespace = "SDWA10";
1023 VOP2_DPP8<op, !cast<VOP2_Pseudo>(opName#"_e32"), asmName> {
1024 string AsmDPP8 = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP8;
1025 let AsmString = asmName # !subst(", vcc", "", AsmDPP8);
1026 let DecoderNamespace = "DPP8";
1029 let WaveSizePredicate = isWave32 in {
1030 def _sdwa_w32_gfx10 :
1031 Base_VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(opName#"_sdwa")>,
1032 VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa").Pfl> {
1033 VOP2_SDWA_Pseudo Ps = !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa");
1034 let AsmString = asmName # !subst("vcc", "vcc_lo", Ps.AsmOperands);
1035 let isAsmParserOnly = 1;
1036 let DecoderNamespace = "SDWA10";
1038 def _dpp_w32_gfx10 :
1039 VOP2_DPP16<op, !cast<VOP2_Pseudo>(opName#"_e32"), asmName> {
1040 string AsmDPP = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP16;
1041 let AsmString = asmName # !subst("vcc", "vcc_lo", AsmDPP);
1042 let isAsmParserOnly = 1;
1044 def _dpp8_w32_gfx10 :
1045 VOP2_DPP8<op, !cast<VOP2_Pseudo>(opName#"_e32"), asmName> {
1046 string AsmDPP8 = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP8;
1047 let AsmString = asmName # !subst("vcc", "vcc_lo", AsmDPP8);
1048 let isAsmParserOnly = 1;
1050 } // End WaveSizePredicate = isWave32
1052 let WaveSizePredicate = isWave64 in {
1053 def _sdwa_w64_gfx10 :
1054 Base_VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(opName#"_sdwa")>,
1055 VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa").Pfl> {
1056 VOP2_SDWA_Pseudo Ps = !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa");
1057 let AsmString = asmName # Ps.AsmOperands;
1058 let isAsmParserOnly = 1;
1059 let DecoderNamespace = "SDWA10";
1061 def _dpp_w64_gfx10 :
1062 VOP2_DPP16<op, !cast<VOP2_Pseudo>(opName#"_e32"), asmName> {
1063 string AsmDPP = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP16;
1064 let AsmString = asmName # AsmDPP;
1065 let isAsmParserOnly = 1;
1067 def _dpp8_w64_gfx10 :
1068 VOP2_DPP8<op, !cast<VOP2_Pseudo>(opName#"_e32"), asmName> {
1069 string AsmDPP8 = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP8;
1070 let AsmString = asmName # AsmDPP8;
1071 let isAsmParserOnly = 1;
1073 } // End WaveSizePredicate = isWave64
1076 //===----------------------------- VOP3Only -----------------------------===//
1077 multiclass VOP3Only_Real_gfx10<bits<10> op> {
1079 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX10>,
1080 VOP3e_gfx10<op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1083 //===---------------------------- VOP3beOnly ----------------------------===//
1084 multiclass VOP3beOnly_Real_gfx10<bits<10> op, string opName, string asmName> {
1086 VOP3_Real<!cast<VOP3_Pseudo>(opName#"_e64"), SIEncodingFamily.GFX10>,
1087 VOP3be_gfx10<op, !cast<VOP3_Pseudo>(opName#"_e64").Pfl> {
1088 VOP3_Pseudo Ps = !cast<VOP3_Pseudo>(opName#"_e64");
1089 let AsmString = asmName # Ps.AsmOperands;
1092 } // End AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10"
1094 multiclass Base_VOP2_Real_gfx10<bits<6> op> :
1095 VOP2_Real_e32_gfx10<op>, VOP2_Real_e64_gfx10<op>;
1097 multiclass VOP2_Real_gfx10<bits<6> op> :
1098 VOP2_Real_e32_gfx10<op>, VOP2_Real_e64_gfx10<op>,
1099 VOP2_Real_sdwa_gfx10<op>, VOP2_Real_dpp_gfx10<op>, VOP2_Real_dpp8_gfx10<op>;
1101 multiclass VOP2_Real_gfx10_with_name<bits<6> op, string opName,
1103 VOP2_Real_e32_gfx10_with_name<op, opName, asmName>,
1104 VOP2_Real_e64_gfx10_with_name<op, opName, asmName>,
1105 VOP2_Real_sdwa_gfx10_with_name<op, opName, asmName>,
1106 VOP2_Real_dpp_gfx10_with_name<op, opName, asmName>,
1107 VOP2_Real_dpp8_gfx10_with_name<op, opName, asmName>;
1109 defm V_CNDMASK_B32 : Base_VOP2_Real_gfx10<0x001>;
1110 defm V_XNOR_B32 : VOP2_Real_gfx10<0x01e>;
1111 defm V_FMAC_F32 : VOP2_Real_gfx10<0x02b>;
1112 defm V_FMAMK_F32 : VOP2Only_Real_MADK_gfx10<0x02c>;
1113 defm V_FMAAK_F32 : VOP2Only_Real_MADK_gfx10<0x02d>;
1114 defm V_ADD_F16 : VOP2_Real_gfx10<0x032>;
1115 defm V_SUB_F16 : VOP2_Real_gfx10<0x033>;
1116 defm V_SUBREV_F16 : VOP2_Real_gfx10<0x034>;
1117 defm V_MUL_F16 : VOP2_Real_gfx10<0x035>;
1118 defm V_FMAC_F16 : VOP2_Real_gfx10<0x036>;
1119 defm V_FMAMK_F16 : VOP2Only_Real_MADK_gfx10<0x037>;
1120 defm V_FMAAK_F16 : VOP2Only_Real_MADK_gfx10<0x038>;
1121 defm V_MAX_F16 : VOP2_Real_gfx10<0x039>;
1122 defm V_MIN_F16 : VOP2_Real_gfx10<0x03a>;
1123 defm V_LDEXP_F16 : VOP2_Real_gfx10<0x03b>;
1124 defm V_PK_FMAC_F16 : VOP2_Real_e32_gfx10<0x03c>;
1126 // VOP2 no carry-in, carry-out.
1128 VOP2_Real_gfx10_with_name<0x025, "V_ADD_U32", "v_add_nc_u32">;
1130 VOP2_Real_gfx10_with_name<0x026, "V_SUB_U32", "v_sub_nc_u32">;
1131 defm V_SUBREV_NC_U32 :
1132 VOP2_Real_gfx10_with_name<0x027, "V_SUBREV_U32", "v_subrev_nc_u32">;
1134 // VOP2 carry-in, carry-out.
1135 defm V_ADD_CO_CI_U32 :
1136 VOP2be_Real_gfx10<0x028, "V_ADDC_U32", "v_add_co_ci_u32">;
1137 defm V_SUB_CO_CI_U32 :
1138 VOP2be_Real_gfx10<0x029, "V_SUBB_U32", "v_sub_co_ci_u32">;
1139 defm V_SUBREV_CO_CI_U32 :
1140 VOP2be_Real_gfx10<0x02a, "V_SUBBREV_U32", "v_subrev_co_ci_u32">;
1143 defm V_BFM_B32 : VOP3Only_Real_gfx10<0x363>;
1144 defm V_BCNT_U32_B32 : VOP3Only_Real_gfx10<0x364>;
1145 defm V_MBCNT_LO_U32_B32 : VOP3Only_Real_gfx10<0x365>;
1146 defm V_MBCNT_HI_U32_B32 : VOP3Only_Real_gfx10<0x366>;
1147 defm V_LDEXP_F32 : VOP3Only_Real_gfx10<0x362>;
1148 defm V_CVT_PKNORM_I16_F32 : VOP3Only_Real_gfx10<0x368>;
1149 defm V_CVT_PKNORM_U16_F32 : VOP3Only_Real_gfx10<0x369>;
1150 defm V_CVT_PK_U16_U32 : VOP3Only_Real_gfx10<0x36a>;
1151 defm V_CVT_PK_I16_I32 : VOP3Only_Real_gfx10<0x36b>;
1153 // VOP3 carry-in, carry-out.
1155 VOP3beOnly_Real_gfx10<0x30f, "V_ADD_I32", "v_add_co_u32">;
1157 VOP3beOnly_Real_gfx10<0x310, "V_SUB_I32", "v_sub_co_u32">;
1158 defm V_SUBREV_CO_U32 :
1159 VOP3beOnly_Real_gfx10<0x319, "V_SUBREV_I32", "v_subrev_co_u32">;
1161 let SubtargetPredicate = isGFX10Plus in {
1162 defm : VOP2eInstAliases<V_CNDMASK_B32_e32, V_CNDMASK_B32_e32_gfx10>;
1164 defm : VOP2bInstAliases<
1165 V_ADDC_U32_e32, V_ADD_CO_CI_U32_e32_gfx10, "v_add_co_ci_u32">;
1166 defm : VOP2bInstAliases<
1167 V_SUBB_U32_e32, V_SUB_CO_CI_U32_e32_gfx10, "v_sub_co_ci_u32">;
1168 defm : VOP2bInstAliases<
1169 V_SUBBREV_U32_e32, V_SUBREV_CO_CI_U32_e32_gfx10, "v_subrev_co_ci_u32">;
1170 } // End SubtargetPredicate = isGFX10Plus
1172 //===----------------------------------------------------------------------===//
1173 // GFX6, GFX7, GFX10.
1174 //===----------------------------------------------------------------------===//
1176 class VOP2_DPPe <bits<6> op, VOP2_DPP_Pseudo ps, VOPProfile P = ps.Pfl> :
1180 let Inst{8-0} = 0xfa; //dpp
1181 let Inst{16-9} = !if(P.HasSrc1, src1{7-0}, 0);
1182 let Inst{24-17} = !if(P.EmitDst, vdst{7-0}, 0);
1183 let Inst{30-25} = op;
1184 let Inst{31} = 0x0; //encoding
1187 let AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" in {
1188 multiclass VOP2Only_Real_gfx6_gfx7<bits<6> op> {
1190 VOP2_Real<!cast<VOP2_Pseudo>(NAME), SIEncodingFamily.SI>,
1191 VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME).Pfl>;
1193 multiclass VOP2Only_Real_MADK_gfx6_gfx7<bits<6> op> {
1195 VOP2_Real<!cast<VOP2_Pseudo>(NAME), SIEncodingFamily.SI>,
1196 VOP2_MADKe<op{5-0}, !cast<VOP2_Pseudo>(NAME).Pfl>;
1198 multiclass VOP2_Real_e32_gfx6_gfx7<bits<6> op> {
1199 def _e32_gfx6_gfx7 :
1200 VOP2_Real<!cast<VOP2_Pseudo>(NAME#"_e32"), SIEncodingFamily.SI>,
1201 VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME#"_e32").Pfl>;
1203 multiclass VOP2_Real_e64_gfx6_gfx7<bits<6> op> {
1204 def _e64_gfx6_gfx7 :
1205 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.SI>,
1206 VOP3e_gfx6_gfx7<{1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1208 multiclass VOP2be_Real_e64_gfx6_gfx7<bits<6> op> {
1209 def _e64_gfx6_gfx7 :
1210 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.SI>,
1211 VOP3be_gfx6_gfx7<{1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1213 } // End AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7"
1215 multiclass VOP2Only_Real_MADK_gfx6_gfx7_gfx10<bits<6> op> :
1216 VOP2Only_Real_MADK_gfx6_gfx7<op>, VOP2Only_Real_MADK_gfx10<op>;
1218 multiclass VOP2_Real_gfx6_gfx7<bits<6> op> :
1219 VOP2_Real_e32_gfx6_gfx7<op>, VOP2_Real_e64_gfx6_gfx7<op>;
1221 multiclass VOP2_Real_gfx6_gfx7_gfx10<bits<6> op> :
1222 VOP2_Real_gfx6_gfx7<op>, VOP2_Real_gfx10<op>;
1224 multiclass VOP2be_Real_gfx6_gfx7<bits<6> op> :
1225 VOP2_Real_e32_gfx6_gfx7<op>, VOP2be_Real_e64_gfx6_gfx7<op>;
1227 defm V_CNDMASK_B32 : VOP2_Real_gfx6_gfx7<0x000>;
1228 defm V_MIN_LEGACY_F32 : VOP2_Real_gfx6_gfx7<0x00d>;
1229 defm V_MAX_LEGACY_F32 : VOP2_Real_gfx6_gfx7<0x00e>;
1230 defm V_LSHR_B32 : VOP2_Real_gfx6_gfx7<0x015>;
1231 defm V_ASHR_I32 : VOP2_Real_gfx6_gfx7<0x017>;
1232 defm V_LSHL_B32 : VOP2_Real_gfx6_gfx7<0x019>;
1233 defm V_BFM_B32 : VOP2_Real_gfx6_gfx7<0x01e>;
1234 defm V_BCNT_U32_B32 : VOP2_Real_gfx6_gfx7<0x022>;
1235 defm V_MBCNT_LO_U32_B32 : VOP2_Real_gfx6_gfx7<0x023>;
1236 defm V_MBCNT_HI_U32_B32 : VOP2_Real_gfx6_gfx7<0x024>;
1237 defm V_LDEXP_F32 : VOP2_Real_gfx6_gfx7<0x02b>;
1238 defm V_CVT_PKACCUM_U8_F32 : VOP2_Real_gfx6_gfx7<0x02c>;
1239 defm V_CVT_PKNORM_I16_F32 : VOP2_Real_gfx6_gfx7<0x02d>;
1240 defm V_CVT_PKNORM_U16_F32 : VOP2_Real_gfx6_gfx7<0x02e>;
1241 defm V_CVT_PK_U16_U32 : VOP2_Real_gfx6_gfx7<0x030>;
1242 defm V_CVT_PK_I16_I32 : VOP2_Real_gfx6_gfx7<0x031>;
1243 defm V_ADD_I32 : VOP2be_Real_gfx6_gfx7<0x025>;
1244 defm V_SUB_I32 : VOP2be_Real_gfx6_gfx7<0x026>;
1245 defm V_SUBREV_I32 : VOP2be_Real_gfx6_gfx7<0x027>;
1246 defm V_ADDC_U32 : VOP2be_Real_gfx6_gfx7<0x028>;
1247 defm V_SUBB_U32 : VOP2be_Real_gfx6_gfx7<0x029>;
1248 defm V_SUBBREV_U32 : VOP2be_Real_gfx6_gfx7<0x02a>;
1250 defm V_READLANE_B32 : VOP2Only_Real_gfx6_gfx7<0x001>;
1252 let InOperandList = (ins SSrcOrLds_b32:$src0, SCSrc_b32:$src1, VSrc_b32:$vdst_in) in {
1253 defm V_WRITELANE_B32 : VOP2Only_Real_gfx6_gfx7<0x002>;
1254 } // End InOperandList = (ins SSrcOrLds_b32:$src0, SCSrc_b32:$src1, VSrc_b32:$vdst_in)
1256 let SubtargetPredicate = isGFX6GFX7 in {
1257 defm : VOP2eInstAliases<V_CNDMASK_B32_e32, V_CNDMASK_B32_e32_gfx6_gfx7>;
1258 } // End SubtargetPredicate = isGFX6GFX7
1260 defm V_ADD_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x003>;
1261 defm V_SUB_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x004>;
1262 defm V_SUBREV_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x005>;
1263 defm V_MAC_LEGACY_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x006>;
1264 defm V_MUL_LEGACY_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x007>;
1265 defm V_MUL_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x008>;
1266 defm V_MUL_I32_I24 : VOP2_Real_gfx6_gfx7_gfx10<0x009>;
1267 defm V_MUL_HI_I32_I24 : VOP2_Real_gfx6_gfx7_gfx10<0x00a>;
1268 defm V_MUL_U32_U24 : VOP2_Real_gfx6_gfx7_gfx10<0x00b>;
1269 defm V_MUL_HI_U32_U24 : VOP2_Real_gfx6_gfx7_gfx10<0x00c>;
1270 defm V_MIN_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x00f>;
1271 defm V_MAX_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x010>;
1272 defm V_MIN_I32 : VOP2_Real_gfx6_gfx7_gfx10<0x011>;
1273 defm V_MAX_I32 : VOP2_Real_gfx6_gfx7_gfx10<0x012>;
1274 defm V_MIN_U32 : VOP2_Real_gfx6_gfx7_gfx10<0x013>;
1275 defm V_MAX_U32 : VOP2_Real_gfx6_gfx7_gfx10<0x014>;
1276 defm V_LSHRREV_B32 : VOP2_Real_gfx6_gfx7_gfx10<0x016>;
1277 defm V_ASHRREV_I32 : VOP2_Real_gfx6_gfx7_gfx10<0x018>;
1278 defm V_LSHLREV_B32 : VOP2_Real_gfx6_gfx7_gfx10<0x01a>;
1279 defm V_AND_B32 : VOP2_Real_gfx6_gfx7_gfx10<0x01b>;
1280 defm V_OR_B32 : VOP2_Real_gfx6_gfx7_gfx10<0x01c>;
1281 defm V_XOR_B32 : VOP2_Real_gfx6_gfx7_gfx10<0x01d>;
1282 defm V_MAC_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x01f>;
1283 defm V_CVT_PKRTZ_F16_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x02f>;
1284 defm V_MADMK_F32 : VOP2Only_Real_MADK_gfx6_gfx7_gfx10<0x020>;
1285 defm V_MADAK_F32 : VOP2Only_Real_MADK_gfx6_gfx7_gfx10<0x021>;
1287 //===----------------------------------------------------------------------===//
1289 //===----------------------------------------------------------------------===//
1291 let AssemblerPredicates = [isGFX8GFX9], DecoderNamespace = "GFX8" in {
1293 multiclass VOP2_Real_MADK_vi <bits<6> op> {
1294 def _vi : VOP2_Real<!cast<VOP2_Pseudo>(NAME), SIEncodingFamily.VI>,
1295 VOP2_MADKe<op{5-0}, !cast<VOP2_Pseudo>(NAME).Pfl>;
1298 multiclass VOP2_Real_e32_vi <bits<6> op> {
1300 VOP2_Real<!cast<VOP2_Pseudo>(NAME#"_e32"), SIEncodingFamily.VI>,
1301 VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME#"_e32").Pfl>;
1304 multiclass VOP2_Real_e64_vi <bits<10> op> {
1306 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.VI>,
1307 VOP3e_vi <op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1310 multiclass VOP2_Real_e64only_vi <bits<10> op> {
1312 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.VI>,
1313 VOP3e_vi <op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl> {
1314 // Hack to stop printing _e64
1315 VOP3_Pseudo ps = !cast<VOP3_Pseudo>(NAME#"_e64");
1316 let OutOperandList = (outs VGPR_32:$vdst);
1317 let AsmString = ps.Mnemonic # " " # ps.AsmOperands;
1321 multiclass Base_VOP2_Real_e32e64_vi <bits<6> op> :
1322 VOP2_Real_e32_vi<op>,
1323 VOP2_Real_e64_vi<{0, 1, 0, 0, op{5-0}}>;
1325 } // End AssemblerPredicates = [isGFX8GFX9], DecoderNamespace = "GFX8"
1327 multiclass VOP2_SDWA_Real <bits<6> op> {
1329 VOP_SDWA_Real <!cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa")>,
1330 VOP2_SDWAe <op{5-0}, !cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa").Pfl>;
1333 multiclass VOP2_SDWA9_Real <bits<6> op> {
1335 VOP_SDWA9_Real <!cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa")>,
1336 VOP2_SDWA9Ae <op{5-0}, !cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa").Pfl>;
1339 let AssemblerPredicates = [isGFX8Only] in {
1341 multiclass VOP2be_Real_e32e64_vi_only <bits<6> op, string OpName, string AsmName> {
1343 VOP2_Real<!cast<VOP2_Pseudo>(OpName#"_e32"), SIEncodingFamily.VI>,
1344 VOP2e<op{5-0}, !cast<VOP2_Pseudo>(OpName#"_e32").Pfl> {
1345 VOP2_Pseudo ps = !cast<VOP2_Pseudo>(OpName#"_e32");
1346 let AsmString = AsmName # ps.AsmOperands;
1347 let DecoderNamespace = "GFX8";
1350 VOP3_Real<!cast<VOP3_Pseudo>(OpName#"_e64"), SIEncodingFamily.VI>,
1351 VOP3be_vi <{0, 1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(OpName#"_e64").Pfl> {
1352 VOP3_Pseudo ps = !cast<VOP3_Pseudo>(OpName#"_e64");
1353 let AsmString = AsmName # ps.AsmOperands;
1354 let DecoderNamespace = "GFX8";
1357 VOP_SDWA_Real <!cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa")>,
1358 VOP2_SDWAe <op{5-0}, !cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa").Pfl> {
1359 VOP2_SDWA_Pseudo ps = !cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa");
1360 let AsmString = AsmName # ps.AsmOperands;
1362 foreach _ = BoolToList<!cast<VOP2_Pseudo>(OpName#"_e32").Pfl.HasExtDPP>.ret in
1364 VOP_DPP_Real<!cast<VOP2_DPP_Pseudo>(OpName#"_dpp"), SIEncodingFamily.VI>,
1365 VOP2_DPPe<op, !cast<VOP2_DPP_Pseudo>(OpName#"_dpp")> {
1366 VOP2_DPP_Pseudo ps = !cast<VOP2_DPP_Pseudo>(OpName#"_dpp");
1367 let AsmString = AsmName # ps.AsmOperands;
1372 let AssemblerPredicates = [isGFX9Only] in {
1374 multiclass VOP2be_Real_e32e64_gfx9 <bits<6> op, string OpName, string AsmName> {
1376 VOP2_Real<!cast<VOP2_Pseudo>(OpName#"_e32"), SIEncodingFamily.GFX9>,
1377 VOP2e<op{5-0}, !cast<VOP2_Pseudo>(OpName#"_e32").Pfl> {
1378 VOP2_Pseudo ps = !cast<VOP2_Pseudo>(OpName#"_e32");
1379 let AsmString = AsmName # ps.AsmOperands;
1380 let DecoderNamespace = "GFX9";
1383 VOP3_Real<!cast<VOP3_Pseudo>(OpName#"_e64"), SIEncodingFamily.GFX9>,
1384 VOP3be_vi <{0, 1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(OpName#"_e64").Pfl> {
1385 VOP3_Pseudo ps = !cast<VOP3_Pseudo>(OpName#"_e64");
1386 let AsmString = AsmName # ps.AsmOperands;
1387 let DecoderNamespace = "GFX9";
1390 VOP_SDWA9_Real <!cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa")>,
1391 VOP2_SDWA9Ae <op{5-0}, !cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa").Pfl> {
1392 VOP2_SDWA_Pseudo ps = !cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa");
1393 let AsmString = AsmName # ps.AsmOperands;
1395 foreach _ = BoolToList<!cast<VOP2_Pseudo>(OpName#"_e32").Pfl.HasExtDPP>.ret in
1397 VOP_DPP_Real<!cast<VOP2_DPP_Pseudo>(OpName#"_dpp"), SIEncodingFamily.GFX9>,
1398 VOP2_DPPe<op, !cast<VOP2_DPP_Pseudo>(OpName#"_dpp")> {
1399 VOP2_DPP_Pseudo ps = !cast<VOP2_DPP_Pseudo>(OpName#"_dpp");
1400 let AsmString = AsmName # ps.AsmOperands;
1401 let DecoderNamespace = "SDWA9";
1405 multiclass VOP2_Real_e32e64_gfx9 <bits<6> op> {
1407 VOP2_Real<!cast<VOP2_Pseudo>(NAME#"_e32"), SIEncodingFamily.GFX9>,
1408 VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME#"_e32").Pfl>{
1409 let DecoderNamespace = "GFX9";
1412 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX9>,
1413 VOP3e_vi <{0, 1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl> {
1414 let DecoderNamespace = "GFX9";
1417 VOP_SDWA9_Real <!cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa")>,
1418 VOP2_SDWA9Ae <op{5-0}, !cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa").Pfl> {
1420 foreach _ = BoolToList<!cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtDPP>.ret in
1422 VOP_DPP_Real<!cast<VOP2_DPP_Pseudo>(NAME#"_dpp"), SIEncodingFamily.GFX9>,
1423 VOP2_DPPe<op, !cast<VOP2_DPP_Pseudo>(NAME#"_dpp")> {
1424 let DecoderNamespace = "SDWA9";
1428 } // AssemblerPredicates = [isGFX9Only]
1430 multiclass VOP2_Real_e32e64_vi <bits<6> op> :
1431 Base_VOP2_Real_e32e64_vi<op>, VOP2_SDWA_Real<op>, VOP2_SDWA9_Real<op> {
1433 foreach _ = BoolToList<!cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtDPP>.ret in
1435 VOP_DPP_Real<!cast<VOP2_DPP_Pseudo>(NAME#"_dpp"), SIEncodingFamily.VI>,
1436 VOP2_DPPe<op, !cast<VOP2_DPP_Pseudo>(NAME#"_dpp")>;
1439 defm V_CNDMASK_B32 : VOP2_Real_e32e64_vi <0x0>;
1440 defm V_ADD_F32 : VOP2_Real_e32e64_vi <0x1>;
1441 defm V_SUB_F32 : VOP2_Real_e32e64_vi <0x2>;
1442 defm V_SUBREV_F32 : VOP2_Real_e32e64_vi <0x3>;
1443 defm V_MUL_LEGACY_F32 : VOP2_Real_e32e64_vi <0x4>;
1444 defm V_MUL_F32 : VOP2_Real_e32e64_vi <0x5>;
1445 defm V_MUL_I32_I24 : VOP2_Real_e32e64_vi <0x6>;
1446 defm V_MUL_HI_I32_I24 : VOP2_Real_e32e64_vi <0x7>;
1447 defm V_MUL_U32_U24 : VOP2_Real_e32e64_vi <0x8>;
1448 defm V_MUL_HI_U32_U24 : VOP2_Real_e32e64_vi <0x9>;
1449 defm V_MIN_F32 : VOP2_Real_e32e64_vi <0xa>;
1450 defm V_MAX_F32 : VOP2_Real_e32e64_vi <0xb>;
1451 defm V_MIN_I32 : VOP2_Real_e32e64_vi <0xc>;
1452 defm V_MAX_I32 : VOP2_Real_e32e64_vi <0xd>;
1453 defm V_MIN_U32 : VOP2_Real_e32e64_vi <0xe>;
1454 defm V_MAX_U32 : VOP2_Real_e32e64_vi <0xf>;
1455 defm V_LSHRREV_B32 : VOP2_Real_e32e64_vi <0x10>;
1456 defm V_ASHRREV_I32 : VOP2_Real_e32e64_vi <0x11>;
1457 defm V_LSHLREV_B32 : VOP2_Real_e32e64_vi <0x12>;
1458 defm V_AND_B32 : VOP2_Real_e32e64_vi <0x13>;
1459 defm V_OR_B32 : VOP2_Real_e32e64_vi <0x14>;
1460 defm V_XOR_B32 : VOP2_Real_e32e64_vi <0x15>;
1461 defm V_MAC_F32 : VOP2_Real_e32e64_vi <0x16>;
1462 defm V_MADMK_F32 : VOP2_Real_MADK_vi <0x17>;
1463 defm V_MADAK_F32 : VOP2_Real_MADK_vi <0x18>;
1465 defm V_ADD_U32 : VOP2be_Real_e32e64_vi_only <0x19, "V_ADD_I32", "v_add_u32">;
1466 defm V_SUB_U32 : VOP2be_Real_e32e64_vi_only <0x1a, "V_SUB_I32", "v_sub_u32">;
1467 defm V_SUBREV_U32 : VOP2be_Real_e32e64_vi_only <0x1b, "V_SUBREV_I32", "v_subrev_u32">;
1468 defm V_ADDC_U32 : VOP2be_Real_e32e64_vi_only <0x1c, "V_ADDC_U32", "v_addc_u32">;
1469 defm V_SUBB_U32 : VOP2be_Real_e32e64_vi_only <0x1d, "V_SUBB_U32", "v_subb_u32">;
1470 defm V_SUBBREV_U32 : VOP2be_Real_e32e64_vi_only <0x1e, "V_SUBBREV_U32", "v_subbrev_u32">;
1472 defm V_ADD_CO_U32 : VOP2be_Real_e32e64_gfx9 <0x19, "V_ADD_I32", "v_add_co_u32">;
1473 defm V_SUB_CO_U32 : VOP2be_Real_e32e64_gfx9 <0x1a, "V_SUB_I32", "v_sub_co_u32">;
1474 defm V_SUBREV_CO_U32 : VOP2be_Real_e32e64_gfx9 <0x1b, "V_SUBREV_I32", "v_subrev_co_u32">;
1475 defm V_ADDC_CO_U32 : VOP2be_Real_e32e64_gfx9 <0x1c, "V_ADDC_U32", "v_addc_co_u32">;
1476 defm V_SUBB_CO_U32 : VOP2be_Real_e32e64_gfx9 <0x1d, "V_SUBB_U32", "v_subb_co_u32">;
1477 defm V_SUBBREV_CO_U32 : VOP2be_Real_e32e64_gfx9 <0x1e, "V_SUBBREV_U32", "v_subbrev_co_u32">;
1479 defm V_ADD_U32 : VOP2_Real_e32e64_gfx9 <0x34>;
1480 defm V_SUB_U32 : VOP2_Real_e32e64_gfx9 <0x35>;
1481 defm V_SUBREV_U32 : VOP2_Real_e32e64_gfx9 <0x36>;
1483 defm V_BFM_B32 : VOP2_Real_e64only_vi <0x293>;
1484 defm V_BCNT_U32_B32 : VOP2_Real_e64only_vi <0x28b>;
1485 defm V_MBCNT_LO_U32_B32 : VOP2_Real_e64only_vi <0x28c>;
1486 defm V_MBCNT_HI_U32_B32 : VOP2_Real_e64only_vi <0x28d>;
1487 defm V_LDEXP_F32 : VOP2_Real_e64only_vi <0x288>;
1488 defm V_CVT_PKACCUM_U8_F32 : VOP2_Real_e64only_vi <0x1f0>;
1489 defm V_CVT_PKNORM_I16_F32 : VOP2_Real_e64only_vi <0x294>;
1490 defm V_CVT_PKNORM_U16_F32 : VOP2_Real_e64only_vi <0x295>;
1491 defm V_CVT_PKRTZ_F16_F32 : VOP2_Real_e64only_vi <0x296>;
1492 defm V_CVT_PK_U16_U32 : VOP2_Real_e64only_vi <0x297>;
1493 defm V_CVT_PK_I16_I32 : VOP2_Real_e64only_vi <0x298>;
1495 defm V_ADD_F16 : VOP2_Real_e32e64_vi <0x1f>;
1496 defm V_SUB_F16 : VOP2_Real_e32e64_vi <0x20>;
1497 defm V_SUBREV_F16 : VOP2_Real_e32e64_vi <0x21>;
1498 defm V_MUL_F16 : VOP2_Real_e32e64_vi <0x22>;
1499 defm V_MAC_F16 : VOP2_Real_e32e64_vi <0x23>;
1500 defm V_MADMK_F16 : VOP2_Real_MADK_vi <0x24>;
1501 defm V_MADAK_F16 : VOP2_Real_MADK_vi <0x25>;
1502 defm V_ADD_U16 : VOP2_Real_e32e64_vi <0x26>;
1503 defm V_SUB_U16 : VOP2_Real_e32e64_vi <0x27>;
1504 defm V_SUBREV_U16 : VOP2_Real_e32e64_vi <0x28>;
1505 defm V_MUL_LO_U16 : VOP2_Real_e32e64_vi <0x29>;
1506 defm V_LSHLREV_B16 : VOP2_Real_e32e64_vi <0x2a>;
1507 defm V_LSHRREV_B16 : VOP2_Real_e32e64_vi <0x2b>;
1508 defm V_ASHRREV_I16 : VOP2_Real_e32e64_vi <0x2c>;
1509 defm V_MAX_F16 : VOP2_Real_e32e64_vi <0x2d>;
1510 defm V_MIN_F16 : VOP2_Real_e32e64_vi <0x2e>;
1511 defm V_MAX_U16 : VOP2_Real_e32e64_vi <0x2f>;
1512 defm V_MAX_I16 : VOP2_Real_e32e64_vi <0x30>;
1513 defm V_MIN_U16 : VOP2_Real_e32e64_vi <0x31>;
1514 defm V_MIN_I16 : VOP2_Real_e32e64_vi <0x32>;
1515 defm V_LDEXP_F16 : VOP2_Real_e32e64_vi <0x33>;
1517 let SubtargetPredicate = isGFX8GFX9 in {
1519 // Aliases to simplify matching of floating-point instructions that
1520 // are VOP2 on SI and VOP3 on VI.
1521 class SI2_VI3Alias <string name, VOP3_Real inst> : InstAlias <
1522 name#" $dst, $src0, $src1",
1523 !if(inst.Pfl.HasOMod,
1524 (inst VGPR_32:$dst, 0, VCSrc_f32:$src0, 0, VCSrc_f32:$src1, 0, 0),
1525 (inst VGPR_32:$dst, 0, VCSrc_f32:$src0, 0, VCSrc_f32:$src1, 0))
1526 >, PredicateControl {
1527 let UseInstAsmMatchConverter = 0;
1528 let AsmVariantName = AMDGPUAsmVariants.VOP3;
1531 def : SI2_VI3Alias <"v_ldexp_f32", V_LDEXP_F32_e64_vi>;
1532 def : SI2_VI3Alias <"v_cvt_pkaccum_u8_f32", V_CVT_PKACCUM_U8_F32_e64_vi>;
1533 def : SI2_VI3Alias <"v_cvt_pknorm_i16_f32", V_CVT_PKNORM_I16_F32_e64_vi>;
1534 def : SI2_VI3Alias <"v_cvt_pknorm_u16_f32", V_CVT_PKNORM_U16_F32_e64_vi>;
1535 def : SI2_VI3Alias <"v_cvt_pkrtz_f16_f32", V_CVT_PKRTZ_F16_F32_e64_vi>;
1537 defm : VOP2eInstAliases<V_CNDMASK_B32_e32, V_CNDMASK_B32_e32_vi>;
1539 } // End SubtargetPredicate = isGFX8GFX9
1541 let SubtargetPredicate = isGFX9Only in {
1543 defm : VOP2bInstAliases<V_ADD_I32_e32, V_ADD_CO_U32_e32_gfx9, "v_add_co_u32">;
1544 defm : VOP2bInstAliases<V_ADDC_U32_e32, V_ADDC_CO_U32_e32_gfx9, "v_addc_co_u32">;
1545 defm : VOP2bInstAliases<V_SUB_I32_e32, V_SUB_CO_U32_e32_gfx9, "v_sub_co_u32">;
1546 defm : VOP2bInstAliases<V_SUBB_U32_e32, V_SUBB_CO_U32_e32_gfx9, "v_subb_co_u32">;
1547 defm : VOP2bInstAliases<V_SUBREV_I32_e32, V_SUBREV_CO_U32_e32_gfx9, "v_subrev_co_u32">;
1548 defm : VOP2bInstAliases<V_SUBBREV_U32_e32, V_SUBBREV_CO_U32_e32_gfx9, "v_subbrev_co_u32">;
1550 } // End SubtargetPredicate = isGFX9Only
1552 let SubtargetPredicate = HasDLInsts in {
1554 defm V_FMAC_F32 : VOP2_Real_e32e64_vi <0x3b>;
1555 defm V_XNOR_B32 : VOP2_Real_e32e64_vi <0x3d>;
1557 } // End SubtargetPredicate = HasDLInsts
1559 multiclass VOP2_Real_DOT_ACC_gfx9<bits<6> op> : VOP2_Real_e32_vi<op> {
1560 def _dpp : VOP2_DPP<op, !cast<VOP2_Pseudo>(NAME#"_e32")>;
1563 multiclass VOP2_Real_DOT_ACC_gfx10<bits<6> op> :
1564 VOP2_Real_e32_gfx10<op>,
1565 VOP2_Real_dpp_gfx10<op>,
1566 VOP2_Real_dpp8_gfx10<op>;
1568 let SubtargetPredicate = HasDot5Insts in {
1569 defm V_DOT2C_F32_F16 : VOP2_Real_DOT_ACC_gfx9<0x37>;
1570 // NB: Opcode conflicts with V_DOT8C_I32_I4
1571 // This opcode exists in gfx 10.1* only
1572 defm V_DOT2C_F32_F16 : VOP2_Real_DOT_ACC_gfx10<0x02>;
1575 let SubtargetPredicate = HasDot6Insts in {
1576 defm V_DOT4C_I32_I8 : VOP2_Real_DOT_ACC_gfx9<0x39>;
1577 defm V_DOT4C_I32_I8 : VOP2_Real_DOT_ACC_gfx10<0x0d>;
1580 let SubtargetPredicate = HasDot4Insts in {
1581 defm V_DOT2C_I32_I16 : VOP2_Real_DOT_ACC_gfx9<0x38>;
1583 let SubtargetPredicate = HasDot3Insts in {
1584 defm V_DOT8C_I32_I4 : VOP2_Real_DOT_ACC_gfx9<0x3a>;
1587 let SubtargetPredicate = HasPkFmacF16Inst in {
1588 defm V_PK_FMAC_F16 : VOP2_Real_e32_vi<0x3c>;
1589 } // End SubtargetPredicate = HasPkFmacF16Inst