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 foreach _ = BoolToList<P.HasExtSDWA>.ret in
151 def _sdwa : VOP2_SDWA_Pseudo <opName, P>;
152 } // End renamedInGFX9 = GFX9Renamed
155 multiclass VOP2Inst<string opName,
157 SDPatternOperator node = null_frag,
158 string revOp = opName,
159 bit GFX9Renamed = 0> :
160 VOP2Inst_e32<opName, P, node, revOp, GFX9Renamed>,
161 VOP2Inst_e64<opName, P, node, revOp, GFX9Renamed>,
162 VOP2Inst_sdwa<opName, P, node, revOp, GFX9Renamed> {
163 let renamedInGFX9 = GFX9Renamed in {
164 foreach _ = BoolToList<P.HasExtDPP>.ret in
165 def _dpp : VOP2_DPP_Pseudo <opName, P>;
169 multiclass VOP2bInst <string opName,
171 SDPatternOperator node = null_frag,
172 string revOp = opName,
174 bit useSGPRInput = !eq(P.NumSrcArgs, 3)> {
175 let renamedInGFX9 = GFX9Renamed in {
176 let SchedRW = [Write32Bit, WriteSALU] in {
177 let Uses = !if(useSGPRInput, [VCC, EXEC], [EXEC]), Defs = [VCC] in {
178 def _e32 : VOP2_Pseudo <opName, P, VOPPatOrNull<node,P>.ret>,
179 Commutable_REV<revOp#"_e32", !eq(revOp, opName)> {
180 let usesCustomInserter = !eq(P.NumSrcArgs, 2);
183 foreach _ = BoolToList<P.HasExtSDWA>.ret in
184 def _sdwa : VOP2_SDWA_Pseudo <opName, P> {
185 let AsmMatchConverter = "cvtSdwaVOP2b";
187 foreach _ = BoolToList<P.HasExtDPP>.ret in
188 def _dpp : VOP2_DPP_Pseudo <opName, P>;
191 def _e64 : VOP3_Pseudo <opName, P, getVOP2Pat64<node, P>.ret>,
192 Commutable_REV<revOp#"_e64", !eq(revOp, opName)>;
197 class VOP2bInstAlias <VOP2_Pseudo ps, Instruction inst,
198 string OpName, string opnd> :
199 InstAlias <OpName#" "#!subst("vcc", opnd, ps.Pfl.Asm32),
200 (inst ps.Pfl.DstRC:$vdst, ps.Pfl.Src0RC32:$src0,
201 ps.Pfl.Src1RC32:$src1)>,
205 multiclass VOP2bInstAliases<VOP2_Pseudo ps, VOP2_Real inst, string OpName> {
206 let WaveSizePredicate = isWave32 in {
207 def : VOP2bInstAlias<ps, inst, OpName, "vcc_lo">;
209 let WaveSizePredicate = isWave64 in {
210 def : VOP2bInstAlias<ps, inst, OpName, "vcc">;
214 multiclass VOP2eInst <string opName,
216 SDPatternOperator node = null_frag,
217 string revOp = opName,
218 bit useSGPRInput = !eq(P.NumSrcArgs, 3)> {
220 let SchedRW = [Write32Bit] in {
221 let Uses = !if(useSGPRInput, [VCC, EXEC], [EXEC]) in {
222 def _e32 : VOP2_Pseudo <opName, P>,
223 Commutable_REV<revOp#"_e32", !eq(revOp, opName)>;
225 foreach _ = BoolToList<P.HasExtSDWA>.ret in
226 def _sdwa : VOP2_SDWA_Pseudo <opName, P> {
227 let AsmMatchConverter = "cvtSdwaVOP2e";
230 foreach _ = BoolToList<P.HasExtDPP>.ret in
231 def _dpp : VOP2_DPP_Pseudo <opName, P>;
234 def _e64 : VOP3_Pseudo <opName, P, getVOP2Pat64<node, P>.ret>,
235 Commutable_REV<revOp#"_e64", !eq(revOp, opName)>;
239 class VOP2eInstAlias <VOP2_Pseudo ps, Instruction inst, string opnd> :
240 InstAlias <ps.OpName#" "#ps.Pfl.Asm32#", "#opnd,
241 (inst ps.Pfl.DstRC:$vdst, ps.Pfl.Src0RC32:$src0,
242 ps.Pfl.Src1RC32:$src1)>,
246 multiclass VOP2eInstAliases<VOP2_Pseudo ps, VOP2_Real inst> {
247 let WaveSizePredicate = isWave32 in {
248 def : VOP2eInstAlias<ps, inst, "vcc_lo">;
250 let WaveSizePredicate = isWave64 in {
251 def : VOP2eInstAlias<ps, inst, "vcc">;
255 class VOP_MADAK <ValueType vt> : VOPProfile <[vt, vt, vt, vt]> {
256 field Operand ImmOpType = !if(!eq(vt.Size, 32), f32kimm, f16kimm);
257 field dag Ins32 = !if(!eq(vt.Size, 32),
258 (ins VCSrc_f32:$src0, VGPR_32:$src1, ImmOpType:$imm),
259 (ins VCSrc_f16:$src0, VGPR_32:$src1, ImmOpType:$imm));
260 field bit HasExt = 0;
262 // Hack to stop printing _e64
263 let DstRC = RegisterOperand<VGPR_32>;
264 field string Asm32 = " $vdst, $src0, $src1, $imm";
267 def VOP_MADAK_F16 : VOP_MADAK <f16>;
268 def VOP_MADAK_F32 : VOP_MADAK <f32>;
270 class VOP_MADMK <ValueType vt> : VOPProfile <[vt, vt, vt, vt]> {
271 field Operand ImmOpType = !if(!eq(vt.Size, 32), f32kimm, f16kimm);
272 field dag Ins32 = (ins VCSrc_f32:$src0, ImmOpType:$imm, VGPR_32:$src1);
273 field bit HasExt = 0;
275 // Hack to stop printing _e64
276 let DstRC = RegisterOperand<VGPR_32>;
277 field string Asm32 = " $vdst, $src0, $imm, $src1";
280 def VOP_MADMK_F16 : VOP_MADMK <f16>;
281 def VOP_MADMK_F32 : VOP_MADMK <f32>;
283 // FIXME: Remove src2_modifiers. It isn't used, so is wasting memory
284 // and processing time but it makes it easier to convert to mad.
285 class VOP_MAC <ValueType vt0, ValueType vt1=vt0> : VOPProfile <[vt0, vt1, vt1, vt0]> {
286 let Ins32 = (ins Src0RC32:$src0, Src1RC32:$src1, VGPR_32:$src2);
287 let Ins64 = getIns64<Src0RC64, Src1RC64, RegisterOperand<VGPR_32>, 3,
288 0, HasModifiers, HasModifiers, HasOMod,
289 Src0Mod, Src1Mod, Src2Mod>.ret;
290 let InsDPP = (ins Src0ModDPP:$src0_modifiers, Src0DPP:$src0,
291 Src1ModDPP:$src1_modifiers, Src1DPP:$src1,
292 VGPR_32:$src2, // stub argument
293 dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
294 bank_mask:$bank_mask, bound_ctrl:$bound_ctrl);
295 let InsDPP16 = !con(InsDPP, (ins FI:$fi));
297 let InsDPP8 = (ins Src0ModDPP:$src0_modifiers, Src0DPP:$src0,
298 Src1ModDPP:$src1_modifiers, Src1DPP:$src1,
299 VGPR_32:$src2, // stub argument
302 let InsSDWA = (ins Src0ModSDWA:$src0_modifiers, Src0SDWA:$src0,
303 Src1ModSDWA:$src1_modifiers, Src1SDWA:$src1,
304 VGPR_32:$src2, // stub argument
305 clampmod:$clamp, omod:$omod,
306 dst_sel:$dst_sel, dst_unused:$dst_unused,
307 src0_sel:$src0_sel, src1_sel:$src1_sel);
308 let Asm32 = getAsm32<1, 2, vt0>.ret;
309 let Asm64 = getAsm64<1, 2, 0, HasModifiers, HasOMod, vt0>.ret;
310 let AsmDPP = getAsmDPP<1, 2, HasModifiers, vt0>.ret;
311 let AsmDPP16 = getAsmDPP16<1, 2, HasModifiers, vt0>.ret;
312 let AsmDPP8 = getAsmDPP8<1, 2, 0, vt0>.ret;
313 let AsmSDWA = getAsmSDWA<1, 2, vt0>.ret;
314 let AsmSDWA9 = getAsmSDWA9<1, 1, 2, vt0>.ret;
322 let TieRegDPP = "$src2";
325 def VOP_MAC_F16 : VOP_MAC <f16>;
326 def VOP_MAC_F32 : VOP_MAC <f32>;
328 class VOP_DOT_ACC<ValueType vt0, ValueType vt1> : VOP_MAC<vt0, vt1> {
331 let HasModifiers = 1;
336 def VOP_DOT_ACC_F32_V2F16 : VOP_DOT_ACC<f32, v2f16> {
337 let Src0ModDPP = FPVRegInputMods;
338 let Src1ModDPP = FPVRegInputMods;
340 def VOP_DOT_ACC_I32_I32 : VOP_DOT_ACC<i32, i32>;
342 // Write out to vcc or arbitrary SGPR.
343 def VOP2b_I32_I1_I32_I32 : VOPProfile<[i32, i32, i32, untyped], 0, /*EnableClamp=*/1> {
344 let Asm32 = "$vdst, vcc, $src0, $src1";
345 let Asm64 = "$vdst, $sdst, $src0, $src1$clamp";
346 let AsmSDWA = "$vdst, vcc, $src0_modifiers, $src1_modifiers$clamp $dst_sel $dst_unused $src0_sel $src1_sel";
347 let AsmSDWA9 = "$vdst, vcc, $src0_modifiers, $src1_modifiers$clamp $dst_sel $dst_unused $src0_sel $src1_sel";
348 let AsmDPP = "$vdst, vcc, $src0, $src1 $dpp_ctrl$row_mask$bank_mask$bound_ctrl";
349 let AsmDPP8 = "$vdst, vcc, $src0, $src1 $dpp8$fi";
350 let AsmDPP16 = AsmDPP#"$fi";
351 let Outs32 = (outs DstRC:$vdst);
352 let Outs64 = (outs DstRC:$vdst, VOPDstS64orS32:$sdst);
355 // Write out to vcc or arbitrary SGPR and read in from vcc or
357 def VOP2b_I32_I1_I32_I32_I1 : VOPProfile<[i32, i32, i32, i1], 0, /*EnableClamp=*/1> {
358 let Asm32 = "$vdst, vcc, $src0, $src1, vcc";
359 let Asm64 = "$vdst, $sdst, $src0, $src1, $src2$clamp";
360 let AsmSDWA = "$vdst, vcc, $src0_modifiers, $src1_modifiers, vcc $clamp $dst_sel $dst_unused $src0_sel $src1_sel";
361 let AsmSDWA9 = "$vdst, vcc, $src0_modifiers, $src1_modifiers, vcc $clamp $dst_sel $dst_unused $src0_sel $src1_sel";
362 let AsmDPP = "$vdst, vcc, $src0, $src1, vcc $dpp_ctrl$row_mask$bank_mask$bound_ctrl";
363 let AsmDPP8 = "$vdst, vcc, $src0, $src1, vcc $dpp8$fi";
364 let AsmDPP16 = AsmDPP#"$fi";
365 let Outs32 = (outs DstRC:$vdst);
366 let Outs64 = (outs DstRC:$vdst, VOPDstS64orS32:$sdst);
368 // Suppress src2 implied by type since the 32-bit encoding uses an
370 let Ins32 = (ins Src0RC32:$src0, Src1RC32:$src1);
372 let InsSDWA = (ins Src0ModSDWA:$src0_modifiers, Src0SDWA:$src0,
373 Src1ModSDWA:$src1_modifiers, Src1SDWA:$src1,
375 dst_sel:$dst_sel, dst_unused:$dst_unused,
376 src0_sel:$src0_sel, src1_sel:$src1_sel);
378 let InsDPP = (ins DstRCDPP:$old,
381 dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
382 bank_mask:$bank_mask, bound_ctrl:$bound_ctrl);
383 let InsDPP16 = !con(InsDPP, (ins FI:$fi));
391 // Read in from vcc or arbitrary SGPR.
392 def VOP2e_I32_I32_I32_I1 : VOPProfile<[i32, i32, i32, i1], /*EnableF32SrcMods=*/1> {
393 let Asm32 = "$vdst, $src0, $src1";
394 let Asm64 = "$vdst, $src0_modifiers, $src1_modifiers, $src2";
395 let AsmSDWA = "$vdst, $src0_modifiers, $src1_modifiers, vcc $clamp $dst_sel $dst_unused $src0_sel $src1_sel";
396 let AsmSDWA9 = "$vdst, $src0_modifiers, $src1_modifiers, vcc $clamp $dst_sel $dst_unused $src0_sel $src1_sel";
397 let AsmDPP = "$vdst, $src0, $src1, vcc $dpp_ctrl$row_mask$bank_mask$bound_ctrl";
398 let AsmDPP8 = "$vdst, $src0, $src1, vcc $dpp8$fi";
399 let AsmDPP16 = AsmDPP#"$fi";
401 let Outs32 = (outs DstRC:$vdst);
402 let Outs64 = (outs DstRC:$vdst);
404 // Suppress src2 implied by type since the 32-bit encoding uses an
406 let Ins32 = (ins Src0RC32:$src0, Src1RC32:$src1);
408 let InsSDWA = (ins Src0ModSDWA:$src0_modifiers, Src0SDWA:$src0,
409 Src1ModSDWA:$src1_modifiers, Src1SDWA:$src1,
411 dst_sel:$dst_sel, dst_unused:$dst_unused,
412 src0_sel:$src0_sel, src1_sel:$src1_sel);
414 let InsDPP = (ins DstRCDPP:$old,
415 Src0ModDPP:$src0_modifiers, Src0DPP:$src0,
416 Src1ModDPP:$src1_modifiers, Src1DPP:$src1,
417 dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
418 bank_mask:$bank_mask, bound_ctrl:$bound_ctrl);
419 let InsDPP16 = !con(InsDPP, (ins FI:$fi));
427 def VOP_READLANE : VOPProfile<[i32, i32, i32]> {
428 let Outs32 = (outs SReg_32:$vdst);
430 let Ins32 = (ins VRegOrLds_32:$src0, SCSrc_b32:$src1);
432 let Asm32 = " $vdst, $src0, $src1";
441 def VOP_WRITELANE : VOPProfile<[i32, i32, i32, i32]> {
442 let Outs32 = (outs VGPR_32:$vdst);
444 let Ins32 = (ins SCSrc_b32:$src0, SCSrc_b32:$src1, VGPR_32:$vdst_in);
446 let Asm32 = " $vdst, $src0, $src1";
457 //===----------------------------------------------------------------------===//
459 //===----------------------------------------------------------------------===//
461 defm V_CNDMASK_B32 : VOP2eInst <"v_cndmask_b32", VOP2e_I32_I32_I32_I1>;
462 def V_MADMK_F32 : VOP2_Pseudo <"v_madmk_f32", VOP_MADMK_F32, []>;
464 let isCommutable = 1 in {
465 defm V_ADD_F32 : VOP2Inst <"v_add_f32", VOP_F32_F32_F32, fadd>;
466 defm V_SUB_F32 : VOP2Inst <"v_sub_f32", VOP_F32_F32_F32, fsub>;
467 defm V_SUBREV_F32 : VOP2Inst <"v_subrev_f32", VOP_F32_F32_F32, null_frag, "v_sub_f32">;
468 defm V_MUL_LEGACY_F32 : VOP2Inst <"v_mul_legacy_f32", VOP_F32_F32_F32, AMDGPUfmul_legacy>;
469 defm V_MUL_F32 : VOP2Inst <"v_mul_f32", VOP_F32_F32_F32, fmul>;
470 defm V_MUL_I32_I24 : VOP2Inst <"v_mul_i32_i24", VOP_PAT_GEN<VOP_I32_I32_I32, 2>, AMDGPUmul_i24>;
471 defm V_MUL_HI_I32_I24 : VOP2Inst <"v_mul_hi_i32_i24", VOP_PAT_GEN<VOP_I32_I32_I32, 2>, AMDGPUmulhi_i24>;
472 defm V_MUL_U32_U24 : VOP2Inst <"v_mul_u32_u24", VOP_PAT_GEN<VOP_I32_I32_I32, 2>, AMDGPUmul_u24>;
473 defm V_MUL_HI_U32_U24 : VOP2Inst <"v_mul_hi_u32_u24", VOP_PAT_GEN<VOP_I32_I32_I32, 2>, AMDGPUmulhi_u24>;
474 defm V_MIN_F32 : VOP2Inst <"v_min_f32", VOP_F32_F32_F32, fminnum_like>;
475 defm V_MAX_F32 : VOP2Inst <"v_max_f32", VOP_F32_F32_F32, fmaxnum_like>;
476 defm V_MIN_I32 : VOP2Inst <"v_min_i32", VOP_PAT_GEN<VOP_I32_I32_I32>, smin>;
477 defm V_MAX_I32 : VOP2Inst <"v_max_i32", VOP_PAT_GEN<VOP_I32_I32_I32>, smax>;
478 defm V_MIN_U32 : VOP2Inst <"v_min_u32", VOP_PAT_GEN<VOP_I32_I32_I32>, umin>;
479 defm V_MAX_U32 : VOP2Inst <"v_max_u32", VOP_PAT_GEN<VOP_I32_I32_I32>, umax>;
480 defm V_LSHRREV_B32 : VOP2Inst <"v_lshrrev_b32", VOP_I32_I32_I32, lshr_rev, "v_lshr_b32">;
481 defm V_ASHRREV_I32 : VOP2Inst <"v_ashrrev_i32", VOP_I32_I32_I32, ashr_rev, "v_ashr_i32">;
482 defm V_LSHLREV_B32 : VOP2Inst <"v_lshlrev_b32", VOP_I32_I32_I32, lshl_rev, "v_lshl_b32">;
483 defm V_AND_B32 : VOP2Inst <"v_and_b32", VOP_PAT_GEN<VOP_I32_I32_I32>, and>;
484 defm V_OR_B32 : VOP2Inst <"v_or_b32", VOP_PAT_GEN<VOP_I32_I32_I32>, or>;
485 defm V_XOR_B32 : VOP2Inst <"v_xor_b32", VOP_PAT_GEN<VOP_I32_I32_I32>, xor>;
487 let Constraints = "$vdst = $src2", DisableEncoding="$src2",
488 isConvertibleToThreeAddress = 1 in {
489 defm V_MAC_F32 : VOP2Inst <"v_mac_f32", VOP_MAC_F32>;
492 def V_MADAK_F32 : VOP2_Pseudo <"v_madak_f32", VOP_MADAK_F32, []>;
494 // No patterns so that the scalar instructions are always selected.
495 // The scalar versions will be replaced with vector when needed later.
497 // V_ADD_I32, V_SUB_I32, and V_SUBREV_I32 where renamed to *_U32 in VI,
498 // but the VI instructions behave the same as the SI versions.
499 defm V_ADD_I32 : VOP2bInst <"v_add_i32", VOP2b_I32_I1_I32_I32, null_frag, "v_add_i32", 1>;
500 defm V_SUB_I32 : VOP2bInst <"v_sub_i32", VOP2b_I32_I1_I32_I32, null_frag, "v_sub_i32", 1>;
501 defm V_SUBREV_I32 : VOP2bInst <"v_subrev_i32", VOP2b_I32_I1_I32_I32, null_frag, "v_sub_i32", 1>;
502 defm V_ADDC_U32 : VOP2bInst <"v_addc_u32", VOP2b_I32_I1_I32_I32_I1, null_frag, "v_addc_u32", 1>;
503 defm V_SUBB_U32 : VOP2bInst <"v_subb_u32", VOP2b_I32_I1_I32_I32_I1, null_frag, "v_subb_u32", 1>;
504 defm V_SUBBREV_U32 : VOP2bInst <"v_subbrev_u32", VOP2b_I32_I1_I32_I32_I1, null_frag, "v_subb_u32", 1>;
507 let SubtargetPredicate = HasAddNoCarryInsts in {
508 defm V_ADD_U32 : VOP2Inst <"v_add_u32", VOP_I32_I32_I32_ARITH, null_frag, "v_add_u32", 1>;
509 defm V_SUB_U32 : VOP2Inst <"v_sub_u32", VOP_I32_I32_I32_ARITH, null_frag, "v_sub_u32", 1>;
510 defm V_SUBREV_U32 : VOP2Inst <"v_subrev_u32", VOP_I32_I32_I32_ARITH, null_frag, "v_sub_u32", 1>;
513 } // End isCommutable = 1
515 // These are special and do not read the exec mask.
516 let isConvergent = 1, Uses = []<Register> in {
517 def V_READLANE_B32 : VOP2_Pseudo<"v_readlane_b32", VOP_READLANE,
518 [(set i32:$vdst, (int_amdgcn_readlane i32:$src0, i32:$src1))]>;
520 let Constraints = "$vdst = $vdst_in", DisableEncoding="$vdst_in" in {
521 def V_WRITELANE_B32 : VOP2_Pseudo<"v_writelane_b32", VOP_WRITELANE,
522 [(set i32:$vdst, (int_amdgcn_writelane i32:$src0, i32:$src1, i32:$vdst_in))]>;
523 } // End $vdst = $vdst_in, DisableEncoding $vdst_in
524 } // End isConvergent = 1
526 defm V_BFM_B32 : VOP2Inst <"v_bfm_b32", VOP_NO_EXT<VOP_I32_I32_I32>>;
527 defm V_BCNT_U32_B32 : VOP2Inst <"v_bcnt_u32_b32", VOP_NO_EXT<VOP_I32_I32_I32>, add_ctpop>;
528 defm V_MBCNT_LO_U32_B32 : VOP2Inst <"v_mbcnt_lo_u32_b32", VOP_NO_EXT<VOP_I32_I32_I32>, int_amdgcn_mbcnt_lo>;
529 defm V_MBCNT_HI_U32_B32 : VOP2Inst <"v_mbcnt_hi_u32_b32", VOP_NO_EXT<VOP_I32_I32_I32>, int_amdgcn_mbcnt_hi>;
530 defm V_LDEXP_F32 : VOP2Inst <"v_ldexp_f32", VOP_NO_EXT<VOP_F32_F32_I32>, AMDGPUldexp>;
531 defm V_CVT_PKACCUM_U8_F32 : VOP2Inst <"v_cvt_pkaccum_u8_f32", VOP_NO_EXT<VOP_I32_F32_I32>>; // TODO: set "Uses = dst"
532 defm V_CVT_PKNORM_I16_F32 : VOP2Inst <"v_cvt_pknorm_i16_f32", VOP_NO_EXT<VOP_V2I16_F32_F32>, AMDGPUpknorm_i16_f32>;
533 defm V_CVT_PKNORM_U16_F32 : VOP2Inst <"v_cvt_pknorm_u16_f32", VOP_NO_EXT<VOP_V2I16_F32_F32>, AMDGPUpknorm_u16_f32>;
534 defm V_CVT_PKRTZ_F16_F32 : VOP2Inst <"v_cvt_pkrtz_f16_f32", VOP_NO_EXT<VOP_V2F16_F32_F32>, AMDGPUpkrtz_f16_f32>;
535 defm V_CVT_PK_U16_U32 : VOP2Inst <"v_cvt_pk_u16_u32", VOP_NO_EXT<VOP_V2I16_I32_I32>, AMDGPUpk_u16_u32>;
536 defm V_CVT_PK_I16_I32 : VOP2Inst <"v_cvt_pk_i16_i32", VOP_NO_EXT<VOP_V2I16_I32_I32>, AMDGPUpk_i16_i32>;
539 let SubtargetPredicate = isGFX6GFX7 in {
540 defm V_MIN_LEGACY_F32 : VOP2Inst <"v_min_legacy_f32", VOP_F32_F32_F32, AMDGPUfmin_legacy>;
541 defm V_MAX_LEGACY_F32 : VOP2Inst <"v_max_legacy_f32", VOP_F32_F32_F32, AMDGPUfmax_legacy>;
542 } // End SubtargetPredicate = isGFX6GFX7
544 let SubtargetPredicate = isGFX6GFX7GFX10 in {
545 let isCommutable = 1 in {
546 defm V_MAC_LEGACY_F32 : VOP2Inst <"v_mac_legacy_f32", VOP_F32_F32_F32>;
547 defm V_LSHR_B32 : VOP2Inst <"v_lshr_b32", VOP_I32_I32_I32, srl>;
548 defm V_ASHR_I32 : VOP2Inst <"v_ashr_i32", VOP_I32_I32_I32, sra>;
549 defm V_LSHL_B32 : VOP2Inst <"v_lshl_b32", VOP_I32_I32_I32, shl>;
550 } // End isCommutable = 1
551 } // End SubtargetPredicate = isGFX6GFX7GFX10
553 class DivergentBinOp<SDPatternOperator Op, VOP_Pseudo Inst> :
555 (getDivergentFrag<Op>.ret Inst.Pfl.Src0VT:$src0, Inst.Pfl.Src1VT:$src1),
556 !if(!cast<Commutable_REV>(Inst).IsOrig,
562 class DivergentClampingBinOp<SDPatternOperator Op, VOP_Pseudo Inst> :
564 (getDivergentFrag<Op>.ret Inst.Pfl.Src0VT:$src0, Inst.Pfl.Src1VT:$src1),
565 !if(!cast<Commutable_REV>(Inst).IsOrig,
566 (Inst $src0, $src1, 0),
567 (Inst $src1, $src0, 0)
571 def : DivergentBinOp<srl, V_LSHRREV_B32_e64>;
572 def : DivergentBinOp<sra, V_ASHRREV_I32_e64>;
573 def : DivergentBinOp<shl, V_LSHLREV_B32_e64>;
575 let SubtargetPredicate = HasAddNoCarryInsts in {
576 def : DivergentClampingBinOp<add, V_ADD_U32_e64>;
577 def : DivergentClampingBinOp<sub, V_SUB_U32_e64>;
580 let SubtargetPredicate = isGFX6GFX7GFX8GFX9, Predicates = [isGFX6GFX7GFX8GFX9] in {
581 def : DivergentClampingBinOp<add, V_ADD_I32_e64>;
582 def : DivergentClampingBinOp<sub, V_SUB_I32_e64>;
585 def : DivergentBinOp<adde, V_ADDC_U32_e32>;
586 def : DivergentBinOp<sube, V_SUBB_U32_e32>;
588 class divergent_i64_BinOp <SDPatternOperator Op, Instruction Inst> :
590 (getDivergentFrag<Op>.ret i64:$src0, i64:$src1),
591 (REG_SEQUENCE VReg_64,
593 (i32 (EXTRACT_SUBREG $src0, sub0)),
594 (i32 (EXTRACT_SUBREG $src1, sub0))
597 (i32 (EXTRACT_SUBREG $src0, sub1)),
598 (i32 (EXTRACT_SUBREG $src1, sub1))
603 def : divergent_i64_BinOp <and, V_AND_B32_e32>;
604 def : divergent_i64_BinOp <or, V_OR_B32_e32>;
605 def : divergent_i64_BinOp <xor, V_XOR_B32_e32>;
607 let SubtargetPredicate = Has16BitInsts in {
609 let FPDPRounding = 1 in {
610 def V_MADMK_F16 : VOP2_Pseudo <"v_madmk_f16", VOP_MADMK_F16, [], "">;
611 defm V_LDEXP_F16 : VOP2Inst <"v_ldexp_f16", VOP_F16_F16_I32, AMDGPUldexp>;
612 } // End FPDPRounding = 1
614 defm V_LSHLREV_B16 : VOP2Inst <"v_lshlrev_b16", VOP_I16_I16_I16, lshl_rev>;
615 defm V_LSHRREV_B16 : VOP2Inst <"v_lshrrev_b16", VOP_I16_I16_I16, lshr_rev>;
616 defm V_ASHRREV_I16 : VOP2Inst <"v_ashrrev_i16", VOP_I16_I16_I16, ashr_rev>;
618 let isCommutable = 1 in {
619 let FPDPRounding = 1 in {
620 defm V_ADD_F16 : VOP2Inst <"v_add_f16", VOP_F16_F16_F16, fadd>;
621 defm V_SUB_F16 : VOP2Inst <"v_sub_f16", VOP_F16_F16_F16, fsub>;
622 defm V_SUBREV_F16 : VOP2Inst <"v_subrev_f16", VOP_F16_F16_F16, null_frag, "v_sub_f16">;
623 defm V_MUL_F16 : VOP2Inst <"v_mul_f16", VOP_F16_F16_F16, fmul>;
624 def V_MADAK_F16 : VOP2_Pseudo <"v_madak_f16", VOP_MADAK_F16, [], "">;
625 } // End FPDPRounding = 1
626 defm V_ADD_U16 : VOP2Inst <"v_add_u16", VOP_I16_I16_I16, add>;
627 defm V_SUB_U16 : VOP2Inst <"v_sub_u16" , VOP_I16_I16_I16, sub>;
628 defm V_SUBREV_U16 : VOP2Inst <"v_subrev_u16", VOP_I16_I16_I16, null_frag, "v_sub_u16">;
629 defm V_MUL_LO_U16 : VOP2Inst <"v_mul_lo_u16", VOP_I16_I16_I16, mul>;
630 defm V_MAX_F16 : VOP2Inst <"v_max_f16", VOP_F16_F16_F16, fmaxnum_like>;
631 defm V_MIN_F16 : VOP2Inst <"v_min_f16", VOP_F16_F16_F16, fminnum_like>;
632 defm V_MAX_U16 : VOP2Inst <"v_max_u16", VOP_I16_I16_I16, umax>;
633 defm V_MAX_I16 : VOP2Inst <"v_max_i16", VOP_I16_I16_I16, smax>;
634 defm V_MIN_U16 : VOP2Inst <"v_min_u16", VOP_I16_I16_I16, umin>;
635 defm V_MIN_I16 : VOP2Inst <"v_min_i16", VOP_I16_I16_I16, smin>;
637 let Constraints = "$vdst = $src2", DisableEncoding="$src2",
638 isConvertibleToThreeAddress = 1 in {
639 defm V_MAC_F16 : VOP2Inst <"v_mac_f16", VOP_MAC_F16>;
641 } // End isCommutable = 1
643 } // End SubtargetPredicate = Has16BitInsts
645 let SubtargetPredicate = HasDLInsts in {
647 defm V_XNOR_B32 : VOP2Inst <"v_xnor_b32", VOP_I32_I32_I32>;
649 let Constraints = "$vdst = $src2",
650 DisableEncoding="$src2",
651 isConvertibleToThreeAddress = 1,
652 isCommutable = 1 in {
653 defm V_FMAC_F32 : VOP2Inst <"v_fmac_f32", VOP_MAC_F32>;
656 } // End SubtargetPredicate = HasDLInsts
658 let Constraints = "$vdst = $src2",
659 DisableEncoding="$src2",
660 isConvertibleToThreeAddress = 1,
663 let SubtargetPredicate = HasDot5Insts in
664 defm V_DOT2C_F32_F16 : VOP2Inst<"v_dot2c_f32_f16", VOP_DOT_ACC_F32_V2F16>;
665 let SubtargetPredicate = HasDot6Insts in
666 defm V_DOT4C_I32_I8 : VOP2Inst<"v_dot4c_i32_i8", VOP_DOT_ACC_I32_I32>;
668 let SubtargetPredicate = HasDot4Insts in
669 defm V_DOT2C_I32_I16 : VOP2Inst<"v_dot2c_i32_i16", VOP_DOT_ACC_I32_I32>;
670 let SubtargetPredicate = HasDot3Insts in
671 defm V_DOT8C_I32_I4 : VOP2Inst<"v_dot8c_i32_i4", VOP_DOT_ACC_I32_I32>;
674 let AddedComplexity = 30 in {
676 (f32 (AMDGPUfdot2 v2f16:$src0, v2f16:$src1, f32:$src2, (i1 DSTCLAMP.NONE))),
677 (f32 (V_DOT2C_F32_F16_e32 $src0, $src1, $src2))
679 let SubtargetPredicate = HasDot5Insts;
682 (i32 (int_amdgcn_sdot4 i32:$src0, i32:$src1, i32:$src2, (i1 DSTCLAMP.NONE))),
683 (i32 (V_DOT4C_I32_I8_e32 $src0, $src1, $src2))
685 let SubtargetPredicate = HasDot6Insts;
688 (i32 (int_amdgcn_sdot2 v2i16:$src0, v2i16:$src1, i32:$src2, (i1 DSTCLAMP.NONE))),
689 (i32 (V_DOT2C_I32_I16_e32 $src0, $src1, $src2))
691 let SubtargetPredicate = HasDot4Insts;
694 (i32 (int_amdgcn_sdot8 i32:$src0, i32:$src1, i32:$src2, (i1 DSTCLAMP.NONE))),
695 (i32 (V_DOT8C_I32_I4_e32 $src0, $src1, $src2))
697 let SubtargetPredicate = HasDot3Insts;
699 } // End AddedComplexity = 30
701 let SubtargetPredicate = isGFX10Plus in {
703 def V_FMAMK_F32 : VOP2_Pseudo<"v_fmamk_f32", VOP_MADMK_F32, [], "">;
704 let FPDPRounding = 1 in
705 def V_FMAMK_F16 : VOP2_Pseudo <"v_fmamk_f16", VOP_MADMK_F16, [], "">;
707 let isCommutable = 1 in {
708 def V_FMAAK_F32 : VOP2_Pseudo<"v_fmaak_f32", VOP_MADAK_F32, [], "">;
709 let FPDPRounding = 1 in
710 def V_FMAAK_F16 : VOP2_Pseudo <"v_fmaak_f16", VOP_MADAK_F16, [], "">;
711 } // End isCommutable = 1
713 let Constraints = "$vdst = $src2",
714 DisableEncoding="$src2",
715 isConvertibleToThreeAddress = 1,
716 isCommutable = 1 in {
717 defm V_FMAC_F16 : VOP2Inst <"v_fmac_f16", VOP_MAC_F16>;
720 } // End SubtargetPredicate = isGFX10Plus
722 let SubtargetPredicate = HasPkFmacF16Inst in {
723 defm V_PK_FMAC_F16 : VOP2Inst<"v_pk_fmac_f16", VOP_V2F16_V2F16_V2F16>;
724 } // End SubtargetPredicate = HasPkFmacF16Inst
726 // Note: 16-bit instructions produce a 0 result in the high 16-bits
727 // on GFX8 and GFX9 and preserve high 16 bits on GFX10+
728 multiclass Arithmetic_i16_0Hi_Pats <SDPatternOperator op, Instruction inst> {
731 (i32 (zext (op i16:$src0, i16:$src1))),
736 (i64 (zext (op i16:$src0, i16:$src1))),
737 (REG_SEQUENCE VReg_64,
738 (inst $src0, $src1), sub0,
739 (V_MOV_B32_e32 (i32 0)), sub1)
743 class ZExt_i16_i1_Pat <SDNode ext> : GCNPat <
745 (V_CNDMASK_B32_e64 (i32 0/*src0mod*/), (i32 0/*src0*/),
746 (i32 0/*src1mod*/), (i32 1/*src1*/),
750 foreach vt = [i16, v2i16] in {
752 (and vt:$src0, vt:$src1),
753 (V_AND_B32_e64 VSrc_b32:$src0, VSrc_b32:$src1)
757 (or vt:$src0, vt:$src1),
758 (V_OR_B32_e64 VSrc_b32:$src0, VSrc_b32:$src1)
762 (xor vt:$src0, vt:$src1),
763 (V_XOR_B32_e64 VSrc_b32:$src0, VSrc_b32:$src1)
767 let Predicates = [Has16BitInsts] in {
769 let Predicates = [Has16BitInsts, isGFX7GFX8GFX9] in {
770 defm : Arithmetic_i16_0Hi_Pats<add, V_ADD_U16_e64>;
771 defm : Arithmetic_i16_0Hi_Pats<mul, V_MUL_LO_U16_e64>;
772 defm : Arithmetic_i16_0Hi_Pats<sub, V_SUB_U16_e64>;
773 defm : Arithmetic_i16_0Hi_Pats<smin, V_MIN_I16_e64>;
774 defm : Arithmetic_i16_0Hi_Pats<smax, V_MAX_I16_e64>;
775 defm : Arithmetic_i16_0Hi_Pats<umin, V_MIN_U16_e64>;
776 defm : Arithmetic_i16_0Hi_Pats<umax, V_MAX_U16_e64>;
777 defm : Arithmetic_i16_0Hi_Pats<lshl_rev, V_LSHLREV_B16_e64>;
778 defm : Arithmetic_i16_0Hi_Pats<lshr_rev, V_LSHRREV_B16_e64>;
779 defm : Arithmetic_i16_0Hi_Pats<ashr_rev, V_ASHRREV_I16_e64>;
782 def : ZExt_i16_i1_Pat<zext>;
783 def : ZExt_i16_i1_Pat<anyext>;
786 (i16 (sext i1:$src)),
787 (V_CNDMASK_B32_e64 /*src0mod*/(i32 0), /*src0*/(i32 0),
788 /*src1mod*/(i32 0), /*src1*/(i32 -1), $src)
791 // Undo sub x, c -> add x, -c canonicalization since c is more likely
792 // an inline immediate than -c.
793 // TODO: Also do for 64-bit.
795 (add i16:$src0, (i16 NegSubInlineConst16:$src1)),
796 (V_SUB_U16_e64 $src0, NegSubInlineConst16:$src1)
799 } // End Predicates = [Has16BitInsts, isGFX7GFX8GFX9]
802 //===----------------------------------------------------------------------===//
803 // Target-specific instruction encodings.
804 //===----------------------------------------------------------------------===//
806 class VOP2_DPP<bits<6> op, VOP2_DPP_Pseudo ps,
807 string opName = ps.OpName, VOPProfile p = ps.Pfl,
809 VOP_DPP<opName, p, IsDPP16> {
810 let hasSideEffects = ps.hasSideEffects;
812 let SchedRW = ps.SchedRW;
817 let Inst{8-0} = 0xfa;
818 let Inst{16-9} = !if(p.HasSrc1, src1{7-0}, 0);
819 let Inst{24-17} = !if(p.EmitDst, vdst{7-0}, 0);
820 let Inst{30-25} = op;
824 class Base_VOP2_DPP16<bits<6> op, VOP2_DPP_Pseudo ps,
825 string opName = ps.OpName, VOPProfile p = ps.Pfl> :
826 VOP2_DPP<op, ps, opName, p, 1> {
827 let AssemblerPredicate = !if(p.HasExt, HasDPP16, DisableInst);
828 let SubtargetPredicate = HasDPP16;
831 class VOP2_DPP16<bits<6> op, VOP2_DPP_Pseudo ps,
832 string opName = ps.OpName, VOPProfile p = ps.Pfl> :
833 Base_VOP2_DPP16<op, ps, opName, p>,
834 SIMCInstr <ps.PseudoInstr, SIEncodingFamily.GFX10>;
836 class VOP2_DPP8<bits<6> op, VOP2_Pseudo ps,
837 string opName = ps.OpName, VOPProfile p = ps.Pfl> :
838 VOP_DPP8<ps.OpName, p> {
839 let hasSideEffects = ps.hasSideEffects;
841 let SchedRW = ps.SchedRW;
848 let Inst{16-9} = !if(p.HasSrc1, src1{7-0}, 0);
849 let Inst{24-17} = !if(p.EmitDst, vdst{7-0}, 0);
850 let Inst{30-25} = op;
853 let AssemblerPredicate = !if(p.HasExt, HasDPP8, DisableInst);
854 let SubtargetPredicate = HasDPP8;
857 //===----------------------------------------------------------------------===//
859 //===----------------------------------------------------------------------===//
861 let AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10" in {
862 //===------------------------------- VOP2 -------------------------------===//
863 multiclass VOP2Only_Real_MADK_gfx10<bits<6> op> {
865 VOP2_Real<!cast<VOP2_Pseudo>(NAME), SIEncodingFamily.GFX10>,
866 VOP2_MADKe<op{5-0}, !cast<VOP2_Pseudo>(NAME).Pfl>;
868 multiclass VOP2Only_Real_MADK_gfx10_with_name<bits<6> op, string opName,
871 VOP2_Real<!cast<VOP2_Pseudo>(opName), SIEncodingFamily.GFX10>,
872 VOP2_MADKe<op{5-0}, !cast<VOP2_Pseudo>(opName).Pfl> {
873 VOP2_Pseudo ps = !cast<VOP2_Pseudo>(opName);
874 let AsmString = asmName # ps.AsmOperands;
877 multiclass VOP2_Real_e32_gfx10<bits<6> op> {
879 VOP2_Real<!cast<VOP2_Pseudo>(NAME#"_e32"), SIEncodingFamily.GFX10>,
880 VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME#"_e32").Pfl>;
882 multiclass VOP2_Real_e64_gfx10<bits<6> op> {
884 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX10>,
885 VOP3e_gfx10<{0, 1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
887 multiclass VOP2_Real_sdwa_gfx10<bits<6> op> {
888 foreach _ = BoolToList<!cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA9>.ret in
890 VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa")>,
891 VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa").Pfl> {
892 let DecoderNamespace = "SDWA10";
895 multiclass VOP2_Real_dpp_gfx10<bits<6> op> {
896 foreach _ = BoolToList<!cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtDPP>.ret in
897 def _dpp_gfx10 : VOP2_DPP16<op, !cast<VOP2_DPP_Pseudo>(NAME#"_dpp")> {
898 let DecoderNamespace = "SDWA10";
901 multiclass VOP2_Real_dpp8_gfx10<bits<6> op> {
902 foreach _ = BoolToList<!cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtDPP>.ret in
903 def _dpp8_gfx10 : VOP2_DPP8<op, !cast<VOP2_Pseudo>(NAME#"_e32")> {
904 let DecoderNamespace = "DPP8";
908 //===------------------------- VOP2 (with name) -------------------------===//
909 multiclass VOP2_Real_e32_gfx10_with_name<bits<6> op, string opName,
912 VOP2_Real<!cast<VOP2_Pseudo>(opName#"_e32"), SIEncodingFamily.GFX10>,
913 VOP2e<op{5-0}, !cast<VOP2_Pseudo>(opName#"_e32").Pfl> {
914 VOP2_Pseudo ps = !cast<VOP2_Pseudo>(opName#"_e32");
915 let AsmString = asmName # ps.AsmOperands;
918 multiclass VOP2_Real_e64_gfx10_with_name<bits<6> op, string opName,
921 VOP3_Real<!cast<VOP3_Pseudo>(opName#"_e64"), SIEncodingFamily.GFX10>,
922 VOP3e_gfx10<{0, 1, 0, 0, op{5-0}},
923 !cast<VOP3_Pseudo>(opName#"_e64").Pfl> {
924 VOP3_Pseudo ps = !cast<VOP3_Pseudo>(opName#"_e64");
925 let AsmString = asmName # ps.AsmOperands;
928 let DecoderNamespace = "SDWA10" in {
929 multiclass VOP2_Real_sdwa_gfx10_with_name<bits<6> op, string opName,
931 foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtSDWA9>.ret in
933 VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(opName#"_sdwa")>,
934 VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa").Pfl> {
935 VOP2_SDWA_Pseudo ps = !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa");
936 let AsmString = asmName # ps.AsmOperands;
939 multiclass VOP2_Real_dpp_gfx10_with_name<bits<6> op, string opName,
941 foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP>.ret in
942 def _dpp_gfx10 : VOP2_DPP16<op, !cast<VOP2_DPP_Pseudo>(opName#"_dpp")> {
943 VOP2_Pseudo ps = !cast<VOP2_Pseudo>(opName#"_e32");
944 let AsmString = asmName # ps.Pfl.AsmDPP16;
947 multiclass VOP2_Real_dpp8_gfx10_with_name<bits<6> op, string opName,
949 foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP>.ret in
950 def _dpp8_gfx10 : VOP2_DPP8<op, !cast<VOP2_Pseudo>(opName#"_e32")> {
951 VOP2_Pseudo ps = !cast<VOP2_Pseudo>(opName#"_e32");
952 let AsmString = asmName # ps.Pfl.AsmDPP8;
953 let DecoderNamespace = "DPP8";
956 } // End DecoderNamespace = "SDWA10"
958 //===------------------------------ VOP2be ------------------------------===//
959 multiclass VOP2be_Real_e32_gfx10<bits<6> op, string opName, string asmName> {
961 VOP2_Real<!cast<VOP2_Pseudo>(opName#"_e32"), SIEncodingFamily.GFX10>,
962 VOP2e<op{5-0}, !cast<VOP2_Pseudo>(opName#"_e32").Pfl> {
963 VOP2_Pseudo Ps = !cast<VOP2_Pseudo>(opName#"_e32");
964 let AsmString = asmName # !subst(", vcc", "", Ps.AsmOperands);
967 multiclass VOP2be_Real_e64_gfx10<bits<6> op, string opName, string asmName> {
969 VOP3_Real<!cast<VOP3_Pseudo>(opName#"_e64"), SIEncodingFamily.GFX10>,
970 VOP3be_gfx10<{0, 1, 0, 0, op{5-0}},
971 !cast<VOP3_Pseudo>(opName#"_e64").Pfl> {
972 VOP3_Pseudo Ps = !cast<VOP3_Pseudo>(opName#"_e64");
973 let AsmString = asmName # Ps.AsmOperands;
976 multiclass VOP2be_Real_sdwa_gfx10<bits<6> op, string opName, string asmName> {
977 foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtSDWA9>.ret in
979 VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(opName#"_sdwa")>,
980 VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa").Pfl> {
981 VOP2_SDWA_Pseudo Ps = !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa");
982 let AsmString = asmName # !subst(", vcc", "", Ps.AsmOperands);
983 let DecoderNamespace = "SDWA10";
985 foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtSDWA9>.ret in
986 def _sdwa_w32_gfx10 :
987 Base_VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(opName#"_sdwa")>,
988 VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa").Pfl> {
989 VOP2_SDWA_Pseudo Ps = !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa");
990 let AsmString = asmName # !subst("vcc", "vcc_lo", Ps.AsmOperands);
991 let isAsmParserOnly = 1;
992 let DecoderNamespace = "SDWA10";
993 let WaveSizePredicate = isWave32;
995 foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtSDWA9>.ret in
996 def _sdwa_w64_gfx10 :
997 Base_VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(opName#"_sdwa")>,
998 VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa").Pfl> {
999 VOP2_SDWA_Pseudo Ps = !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa");
1000 let AsmString = asmName # Ps.AsmOperands;
1001 let isAsmParserOnly = 1;
1002 let DecoderNamespace = "SDWA10";
1003 let WaveSizePredicate = isWave64;
1006 multiclass VOP2be_Real_dpp_gfx10<bits<6> op, string opName, string asmName> {
1007 foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP>.ret in
1009 VOP2_DPP16<op, !cast<VOP2_DPP_Pseudo>(opName#"_dpp"), asmName> {
1010 string AsmDPP = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP16;
1011 let AsmString = asmName # !subst(", vcc", "", AsmDPP);
1012 let DecoderNamespace = "SDWA10";
1014 foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP>.ret in
1015 def _dpp_w32_gfx10 :
1016 Base_VOP2_DPP16<op, !cast<VOP2_DPP_Pseudo>(opName#"_dpp"), asmName> {
1017 string AsmDPP = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP16;
1018 let AsmString = asmName # !subst("vcc", "vcc_lo", AsmDPP);
1019 let isAsmParserOnly = 1;
1020 let WaveSizePredicate = isWave32;
1022 foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP>.ret in
1023 def _dpp_w64_gfx10 :
1024 Base_VOP2_DPP16<op, !cast<VOP2_DPP_Pseudo>(opName#"_dpp"), asmName> {
1025 string AsmDPP = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP16;
1026 let AsmString = asmName # AsmDPP;
1027 let isAsmParserOnly = 1;
1028 let WaveSizePredicate = isWave64;
1031 multiclass VOP2be_Real_dpp8_gfx10<bits<6> op, string opName, string asmName> {
1032 foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP>.ret in
1034 VOP2_DPP8<op, !cast<VOP2_Pseudo>(opName#"_e32"), asmName> {
1035 string AsmDPP8 = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP8;
1036 let AsmString = asmName # !subst(", vcc", "", AsmDPP8);
1037 let DecoderNamespace = "DPP8";
1039 foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP>.ret in
1040 def _dpp8_w32_gfx10 :
1041 VOP2_DPP8<op, !cast<VOP2_Pseudo>(opName#"_e32"), asmName> {
1042 string AsmDPP8 = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP8;
1043 let AsmString = asmName # !subst("vcc", "vcc_lo", AsmDPP8);
1044 let isAsmParserOnly = 1;
1045 let WaveSizePredicate = isWave32;
1047 foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP>.ret in
1048 def _dpp8_w64_gfx10 :
1049 VOP2_DPP8<op, !cast<VOP2_Pseudo>(opName#"_e32"), asmName> {
1050 string AsmDPP8 = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP8;
1051 let AsmString = asmName # AsmDPP8;
1052 let isAsmParserOnly = 1;
1053 let WaveSizePredicate = isWave64;
1057 //===----------------------------- VOP3Only -----------------------------===//
1058 multiclass VOP3Only_Real_gfx10<bits<10> op> {
1060 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX10>,
1061 VOP3e_gfx10<op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1064 //===---------------------------- VOP3beOnly ----------------------------===//
1065 multiclass VOP3beOnly_Real_gfx10<bits<10> op, string opName, string asmName> {
1067 VOP3_Real<!cast<VOP3_Pseudo>(opName#"_e64"), SIEncodingFamily.GFX10>,
1068 VOP3be_gfx10<op, !cast<VOP3_Pseudo>(opName#"_e64").Pfl> {
1069 VOP3_Pseudo Ps = !cast<VOP3_Pseudo>(opName#"_e64");
1070 let AsmString = asmName # Ps.AsmOperands;
1073 } // End AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10"
1075 multiclass VOP2be_Real_gfx10<bits<6> op, string opName, string asmName> :
1076 VOP2be_Real_e32_gfx10<op, opName, asmName>,
1077 VOP2be_Real_e64_gfx10<op, opName, asmName>,
1078 VOP2be_Real_sdwa_gfx10<op, opName, asmName>,
1079 VOP2be_Real_dpp_gfx10<op, opName, asmName>,
1080 VOP2be_Real_dpp8_gfx10<op, opName, asmName>;
1082 multiclass VOP2e_Real_gfx10<bits<6> op, string opName, string asmName> :
1083 VOP2_Real_e32_gfx10<op>,
1084 VOP2_Real_e64_gfx10<op>,
1085 VOP2be_Real_sdwa_gfx10<op, opName, asmName>,
1086 VOP2be_Real_dpp_gfx10<op, opName, asmName>,
1087 VOP2be_Real_dpp8_gfx10<op, opName, asmName>;
1089 multiclass VOP2_Real_gfx10<bits<6> op> :
1090 VOP2_Real_e32_gfx10<op>, VOP2_Real_e64_gfx10<op>,
1091 VOP2_Real_sdwa_gfx10<op>, VOP2_Real_dpp_gfx10<op>, VOP2_Real_dpp8_gfx10<op>;
1093 multiclass VOP2_Real_gfx10_with_name<bits<6> op, string opName,
1095 VOP2_Real_e32_gfx10_with_name<op, opName, asmName>,
1096 VOP2_Real_e64_gfx10_with_name<op, opName, asmName>,
1097 VOP2_Real_sdwa_gfx10_with_name<op, opName, asmName>,
1098 VOP2_Real_dpp_gfx10_with_name<op, opName, asmName>,
1099 VOP2_Real_dpp8_gfx10_with_name<op, opName, asmName>;
1101 defm V_XNOR_B32 : VOP2_Real_gfx10<0x01e>;
1102 defm V_FMAC_F32 : VOP2_Real_gfx10<0x02b>;
1103 defm V_FMAMK_F32 : VOP2Only_Real_MADK_gfx10<0x02c>;
1104 defm V_FMAAK_F32 : VOP2Only_Real_MADK_gfx10<0x02d>;
1105 defm V_ADD_F16 : VOP2_Real_gfx10<0x032>;
1106 defm V_SUB_F16 : VOP2_Real_gfx10<0x033>;
1107 defm V_SUBREV_F16 : VOP2_Real_gfx10<0x034>;
1108 defm V_MUL_F16 : VOP2_Real_gfx10<0x035>;
1109 defm V_FMAC_F16 : VOP2_Real_gfx10<0x036>;
1110 defm V_FMAMK_F16 : VOP2Only_Real_MADK_gfx10<0x037>;
1111 defm V_FMAAK_F16 : VOP2Only_Real_MADK_gfx10<0x038>;
1112 defm V_MAX_F16 : VOP2_Real_gfx10<0x039>;
1113 defm V_MIN_F16 : VOP2_Real_gfx10<0x03a>;
1114 defm V_LDEXP_F16 : VOP2_Real_gfx10<0x03b>;
1115 defm V_PK_FMAC_F16 : VOP2_Real_e32_gfx10<0x03c>;
1117 // VOP2 no carry-in, carry-out.
1119 VOP2_Real_gfx10_with_name<0x025, "V_ADD_U32", "v_add_nc_u32">;
1121 VOP2_Real_gfx10_with_name<0x026, "V_SUB_U32", "v_sub_nc_u32">;
1122 defm V_SUBREV_NC_U32 :
1123 VOP2_Real_gfx10_with_name<0x027, "V_SUBREV_U32", "v_subrev_nc_u32">;
1125 // VOP2 carry-in, carry-out.
1126 defm V_ADD_CO_CI_U32 :
1127 VOP2be_Real_gfx10<0x028, "V_ADDC_U32", "v_add_co_ci_u32">;
1128 defm V_SUB_CO_CI_U32 :
1129 VOP2be_Real_gfx10<0x029, "V_SUBB_U32", "v_sub_co_ci_u32">;
1130 defm V_SUBREV_CO_CI_U32 :
1131 VOP2be_Real_gfx10<0x02a, "V_SUBBREV_U32", "v_subrev_co_ci_u32">;
1133 defm V_CNDMASK_B32 :
1134 VOP2e_Real_gfx10<0x001, "V_CNDMASK_B32", "v_cndmask_b32">;
1137 defm V_BFM_B32 : VOP3Only_Real_gfx10<0x363>;
1138 defm V_BCNT_U32_B32 : VOP3Only_Real_gfx10<0x364>;
1139 defm V_MBCNT_LO_U32_B32 : VOP3Only_Real_gfx10<0x365>;
1140 defm V_MBCNT_HI_U32_B32 : VOP3Only_Real_gfx10<0x366>;
1141 defm V_LDEXP_F32 : VOP3Only_Real_gfx10<0x362>;
1142 defm V_CVT_PKNORM_I16_F32 : VOP3Only_Real_gfx10<0x368>;
1143 defm V_CVT_PKNORM_U16_F32 : VOP3Only_Real_gfx10<0x369>;
1144 defm V_CVT_PK_U16_U32 : VOP3Only_Real_gfx10<0x36a>;
1145 defm V_CVT_PK_I16_I32 : VOP3Only_Real_gfx10<0x36b>;
1147 // VOP3 carry-in, carry-out.
1149 VOP3beOnly_Real_gfx10<0x30f, "V_ADD_I32", "v_add_co_u32">;
1151 VOP3beOnly_Real_gfx10<0x310, "V_SUB_I32", "v_sub_co_u32">;
1152 defm V_SUBREV_CO_U32 :
1153 VOP3beOnly_Real_gfx10<0x319, "V_SUBREV_I32", "v_subrev_co_u32">;
1155 let SubtargetPredicate = isGFX10Plus in {
1156 defm : VOP2eInstAliases<V_CNDMASK_B32_e32, V_CNDMASK_B32_e32_gfx10>;
1158 defm : VOP2bInstAliases<
1159 V_ADDC_U32_e32, V_ADD_CO_CI_U32_e32_gfx10, "v_add_co_ci_u32">;
1160 defm : VOP2bInstAliases<
1161 V_SUBB_U32_e32, V_SUB_CO_CI_U32_e32_gfx10, "v_sub_co_ci_u32">;
1162 defm : VOP2bInstAliases<
1163 V_SUBBREV_U32_e32, V_SUBREV_CO_CI_U32_e32_gfx10, "v_subrev_co_ci_u32">;
1164 } // End SubtargetPredicate = isGFX10Plus
1166 //===----------------------------------------------------------------------===//
1167 // GFX6, GFX7, GFX10.
1168 //===----------------------------------------------------------------------===//
1170 class VOP2_DPPe <bits<6> op, VOP2_DPP_Pseudo ps, VOPProfile P = ps.Pfl> :
1174 let Inst{8-0} = 0xfa; //dpp
1175 let Inst{16-9} = !if(P.HasSrc1, src1{7-0}, 0);
1176 let Inst{24-17} = !if(P.EmitDst, vdst{7-0}, 0);
1177 let Inst{30-25} = op;
1178 let Inst{31} = 0x0; //encoding
1181 let AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" in {
1182 multiclass VOP2Only_Real_gfx6_gfx7<bits<6> op> {
1184 VOP2_Real<!cast<VOP2_Pseudo>(NAME), SIEncodingFamily.SI>,
1185 VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME).Pfl>;
1187 multiclass VOP2Only_Real_MADK_gfx6_gfx7<bits<6> op> {
1189 VOP2_Real<!cast<VOP2_Pseudo>(NAME), SIEncodingFamily.SI>,
1190 VOP2_MADKe<op{5-0}, !cast<VOP2_Pseudo>(NAME).Pfl>;
1192 multiclass VOP2_Real_e32_gfx6_gfx7<bits<6> op> {
1193 def _e32_gfx6_gfx7 :
1194 VOP2_Real<!cast<VOP2_Pseudo>(NAME#"_e32"), SIEncodingFamily.SI>,
1195 VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME#"_e32").Pfl>;
1197 multiclass VOP2_Real_e64_gfx6_gfx7<bits<6> op> {
1198 def _e64_gfx6_gfx7 :
1199 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.SI>,
1200 VOP3e_gfx6_gfx7<{1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1202 multiclass VOP2be_Real_e64_gfx6_gfx7<bits<6> op> {
1203 def _e64_gfx6_gfx7 :
1204 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.SI>,
1205 VOP3be_gfx6_gfx7<{1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1207 } // End AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7"
1209 multiclass VOP2Only_Real_MADK_gfx6_gfx7_gfx10<bits<6> op> :
1210 VOP2Only_Real_MADK_gfx6_gfx7<op>, VOP2Only_Real_MADK_gfx10<op>;
1212 multiclass VOP2_Real_gfx6_gfx7<bits<6> op> :
1213 VOP2_Real_e32_gfx6_gfx7<op>, VOP2_Real_e64_gfx6_gfx7<op>;
1215 multiclass VOP2_Real_gfx6_gfx7_gfx10<bits<6> op> :
1216 VOP2_Real_gfx6_gfx7<op>, VOP2_Real_gfx10<op>;
1218 multiclass VOP2be_Real_gfx6_gfx7<bits<6> op> :
1219 VOP2_Real_e32_gfx6_gfx7<op>, VOP2be_Real_e64_gfx6_gfx7<op>;
1221 defm V_CNDMASK_B32 : VOP2_Real_gfx6_gfx7<0x000>;
1222 defm V_MIN_LEGACY_F32 : VOP2_Real_gfx6_gfx7<0x00d>;
1223 defm V_MAX_LEGACY_F32 : VOP2_Real_gfx6_gfx7<0x00e>;
1224 defm V_LSHR_B32 : VOP2_Real_gfx6_gfx7<0x015>;
1225 defm V_ASHR_I32 : VOP2_Real_gfx6_gfx7<0x017>;
1226 defm V_LSHL_B32 : VOP2_Real_gfx6_gfx7<0x019>;
1227 defm V_BFM_B32 : VOP2_Real_gfx6_gfx7<0x01e>;
1228 defm V_BCNT_U32_B32 : VOP2_Real_gfx6_gfx7<0x022>;
1229 defm V_MBCNT_LO_U32_B32 : VOP2_Real_gfx6_gfx7<0x023>;
1230 defm V_MBCNT_HI_U32_B32 : VOP2_Real_gfx6_gfx7<0x024>;
1231 defm V_LDEXP_F32 : VOP2_Real_gfx6_gfx7<0x02b>;
1232 defm V_CVT_PKACCUM_U8_F32 : VOP2_Real_gfx6_gfx7<0x02c>;
1233 defm V_CVT_PKNORM_I16_F32 : VOP2_Real_gfx6_gfx7<0x02d>;
1234 defm V_CVT_PKNORM_U16_F32 : VOP2_Real_gfx6_gfx7<0x02e>;
1235 defm V_CVT_PK_U16_U32 : VOP2_Real_gfx6_gfx7<0x030>;
1236 defm V_CVT_PK_I16_I32 : VOP2_Real_gfx6_gfx7<0x031>;
1237 defm V_ADD_I32 : VOP2be_Real_gfx6_gfx7<0x025>;
1238 defm V_SUB_I32 : VOP2be_Real_gfx6_gfx7<0x026>;
1239 defm V_SUBREV_I32 : VOP2be_Real_gfx6_gfx7<0x027>;
1240 defm V_ADDC_U32 : VOP2be_Real_gfx6_gfx7<0x028>;
1241 defm V_SUBB_U32 : VOP2be_Real_gfx6_gfx7<0x029>;
1242 defm V_SUBBREV_U32 : VOP2be_Real_gfx6_gfx7<0x02a>;
1244 defm V_READLANE_B32 : VOP2Only_Real_gfx6_gfx7<0x001>;
1246 let InOperandList = (ins SSrcOrLds_b32:$src0, SCSrc_b32:$src1, VSrc_b32:$vdst_in) in {
1247 defm V_WRITELANE_B32 : VOP2Only_Real_gfx6_gfx7<0x002>;
1248 } // End InOperandList = (ins SSrcOrLds_b32:$src0, SCSrc_b32:$src1, VSrc_b32:$vdst_in)
1250 let SubtargetPredicate = isGFX6GFX7 in {
1251 defm : VOP2eInstAliases<V_CNDMASK_B32_e32, V_CNDMASK_B32_e32_gfx6_gfx7>;
1252 } // End SubtargetPredicate = isGFX6GFX7
1254 defm V_ADD_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x003>;
1255 defm V_SUB_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x004>;
1256 defm V_SUBREV_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x005>;
1257 defm V_MAC_LEGACY_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x006>;
1258 defm V_MUL_LEGACY_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x007>;
1259 defm V_MUL_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x008>;
1260 defm V_MUL_I32_I24 : VOP2_Real_gfx6_gfx7_gfx10<0x009>;
1261 defm V_MUL_HI_I32_I24 : VOP2_Real_gfx6_gfx7_gfx10<0x00a>;
1262 defm V_MUL_U32_U24 : VOP2_Real_gfx6_gfx7_gfx10<0x00b>;
1263 defm V_MUL_HI_U32_U24 : VOP2_Real_gfx6_gfx7_gfx10<0x00c>;
1264 defm V_MIN_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x00f>;
1265 defm V_MAX_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x010>;
1266 defm V_MIN_I32 : VOP2_Real_gfx6_gfx7_gfx10<0x011>;
1267 defm V_MAX_I32 : VOP2_Real_gfx6_gfx7_gfx10<0x012>;
1268 defm V_MIN_U32 : VOP2_Real_gfx6_gfx7_gfx10<0x013>;
1269 defm V_MAX_U32 : VOP2_Real_gfx6_gfx7_gfx10<0x014>;
1270 defm V_LSHRREV_B32 : VOP2_Real_gfx6_gfx7_gfx10<0x016>;
1271 defm V_ASHRREV_I32 : VOP2_Real_gfx6_gfx7_gfx10<0x018>;
1272 defm V_LSHLREV_B32 : VOP2_Real_gfx6_gfx7_gfx10<0x01a>;
1273 defm V_AND_B32 : VOP2_Real_gfx6_gfx7_gfx10<0x01b>;
1274 defm V_OR_B32 : VOP2_Real_gfx6_gfx7_gfx10<0x01c>;
1275 defm V_XOR_B32 : VOP2_Real_gfx6_gfx7_gfx10<0x01d>;
1276 defm V_MAC_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x01f>;
1277 defm V_CVT_PKRTZ_F16_F32 : VOP2_Real_gfx6_gfx7_gfx10<0x02f>;
1278 defm V_MADMK_F32 : VOP2Only_Real_MADK_gfx6_gfx7_gfx10<0x020>;
1279 defm V_MADAK_F32 : VOP2Only_Real_MADK_gfx6_gfx7_gfx10<0x021>;
1281 //===----------------------------------------------------------------------===//
1283 //===----------------------------------------------------------------------===//
1285 let AssemblerPredicates = [isGFX8GFX9], DecoderNamespace = "GFX8" in {
1287 multiclass VOP2_Real_MADK_vi <bits<6> op> {
1288 def _vi : VOP2_Real<!cast<VOP2_Pseudo>(NAME), SIEncodingFamily.VI>,
1289 VOP2_MADKe<op{5-0}, !cast<VOP2_Pseudo>(NAME).Pfl>;
1292 multiclass VOP2_Real_e32_vi <bits<6> op> {
1294 VOP2_Real<!cast<VOP2_Pseudo>(NAME#"_e32"), SIEncodingFamily.VI>,
1295 VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME#"_e32").Pfl>;
1298 multiclass VOP2_Real_e64_vi <bits<10> op> {
1300 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.VI>,
1301 VOP3e_vi <op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1304 multiclass VOP2_Real_e64only_vi <bits<10> op> {
1306 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.VI>,
1307 VOP3e_vi <op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl> {
1308 // Hack to stop printing _e64
1309 VOP3_Pseudo ps = !cast<VOP3_Pseudo>(NAME#"_e64");
1310 let OutOperandList = (outs VGPR_32:$vdst);
1311 let AsmString = ps.Mnemonic # " " # ps.AsmOperands;
1315 multiclass Base_VOP2_Real_e32e64_vi <bits<6> op> :
1316 VOP2_Real_e32_vi<op>,
1317 VOP2_Real_e64_vi<{0, 1, 0, 0, op{5-0}}>;
1319 } // End AssemblerPredicates = [isGFX8GFX9], DecoderNamespace = "GFX8"
1321 multiclass VOP2_SDWA_Real <bits<6> op> {
1322 foreach _ = BoolToList<!cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA>.ret in
1324 VOP_SDWA_Real <!cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa")>,
1325 VOP2_SDWAe <op{5-0}, !cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa").Pfl>;
1328 multiclass VOP2_SDWA9_Real <bits<6> op> {
1329 foreach _ = BoolToList<!cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA9>.ret in
1331 VOP_SDWA9_Real <!cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa")>,
1332 VOP2_SDWA9Ae <op{5-0}, !cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa").Pfl>;
1335 let AssemblerPredicates = [isGFX8Only] in {
1337 multiclass VOP2be_Real_e32e64_vi_only <bits<6> op, string OpName, string AsmName> {
1339 VOP2_Real<!cast<VOP2_Pseudo>(OpName#"_e32"), SIEncodingFamily.VI>,
1340 VOP2e<op{5-0}, !cast<VOP2_Pseudo>(OpName#"_e32").Pfl> {
1341 VOP2_Pseudo ps = !cast<VOP2_Pseudo>(OpName#"_e32");
1342 let AsmString = AsmName # ps.AsmOperands;
1343 let DecoderNamespace = "GFX8";
1346 VOP3_Real<!cast<VOP3_Pseudo>(OpName#"_e64"), SIEncodingFamily.VI>,
1347 VOP3be_vi <{0, 1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(OpName#"_e64").Pfl> {
1348 VOP3_Pseudo ps = !cast<VOP3_Pseudo>(OpName#"_e64");
1349 let AsmString = AsmName # ps.AsmOperands;
1350 let DecoderNamespace = "GFX8";
1352 foreach _ = BoolToList<!cast<VOP2_Pseudo>(OpName#"_e32").Pfl.HasExtSDWA>.ret in
1354 VOP_SDWA_Real <!cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa")>,
1355 VOP2_SDWAe <op{5-0}, !cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa").Pfl> {
1356 VOP2_SDWA_Pseudo ps = !cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa");
1357 let AsmString = AsmName # ps.AsmOperands;
1359 foreach _ = BoolToList<!cast<VOP2_Pseudo>(OpName#"_e32").Pfl.HasExtDPP>.ret in
1361 VOP_DPP_Real<!cast<VOP2_DPP_Pseudo>(OpName#"_dpp"), SIEncodingFamily.VI>,
1362 VOP2_DPPe<op, !cast<VOP2_DPP_Pseudo>(OpName#"_dpp")> {
1363 VOP2_DPP_Pseudo ps = !cast<VOP2_DPP_Pseudo>(OpName#"_dpp");
1364 let AsmString = AsmName # ps.AsmOperands;
1369 let AssemblerPredicates = [isGFX9Only] in {
1371 multiclass VOP2be_Real_e32e64_gfx9 <bits<6> op, string OpName, string AsmName> {
1373 VOP2_Real<!cast<VOP2_Pseudo>(OpName#"_e32"), SIEncodingFamily.GFX9>,
1374 VOP2e<op{5-0}, !cast<VOP2_Pseudo>(OpName#"_e32").Pfl> {
1375 VOP2_Pseudo ps = !cast<VOP2_Pseudo>(OpName#"_e32");
1376 let AsmString = AsmName # ps.AsmOperands;
1377 let DecoderNamespace = "GFX9";
1380 VOP3_Real<!cast<VOP3_Pseudo>(OpName#"_e64"), SIEncodingFamily.GFX9>,
1381 VOP3be_vi <{0, 1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(OpName#"_e64").Pfl> {
1382 VOP3_Pseudo ps = !cast<VOP3_Pseudo>(OpName#"_e64");
1383 let AsmString = AsmName # ps.AsmOperands;
1384 let DecoderNamespace = "GFX9";
1386 foreach _ = BoolToList<!cast<VOP2_Pseudo>(OpName#"_e32").Pfl.HasExtSDWA9>.ret in
1388 VOP_SDWA9_Real <!cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa")>,
1389 VOP2_SDWA9Ae <op{5-0}, !cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa").Pfl> {
1390 VOP2_SDWA_Pseudo ps = !cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa");
1391 let AsmString = AsmName # ps.AsmOperands;
1393 foreach _ = BoolToList<!cast<VOP2_Pseudo>(OpName#"_e32").Pfl.HasExtDPP>.ret in
1395 VOP_DPP_Real<!cast<VOP2_DPP_Pseudo>(OpName#"_dpp"), SIEncodingFamily.GFX9>,
1396 VOP2_DPPe<op, !cast<VOP2_DPP_Pseudo>(OpName#"_dpp")> {
1397 VOP2_DPP_Pseudo ps = !cast<VOP2_DPP_Pseudo>(OpName#"_dpp");
1398 let AsmString = AsmName # ps.AsmOperands;
1399 let DecoderNamespace = "SDWA9";
1403 multiclass VOP2_Real_e32e64_gfx9 <bits<6> op> {
1405 VOP2_Real<!cast<VOP2_Pseudo>(NAME#"_e32"), SIEncodingFamily.GFX9>,
1406 VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME#"_e32").Pfl>{
1407 let DecoderNamespace = "GFX9";
1410 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX9>,
1411 VOP3e_vi <{0, 1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl> {
1412 let DecoderNamespace = "GFX9";
1414 foreach _ = BoolToList<!cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA9>.ret in
1416 VOP_SDWA9_Real <!cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa")>,
1417 VOP2_SDWA9Ae <op{5-0}, !cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa").Pfl> {
1419 foreach _ = BoolToList<!cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtDPP>.ret in
1421 VOP_DPP_Real<!cast<VOP2_DPP_Pseudo>(NAME#"_dpp"), SIEncodingFamily.GFX9>,
1422 VOP2_DPPe<op, !cast<VOP2_DPP_Pseudo>(NAME#"_dpp")> {
1423 let DecoderNamespace = "SDWA9";
1427 } // AssemblerPredicates = [isGFX9Only]
1429 multiclass VOP2_Real_e32e64_vi <bits<6> op> :
1430 Base_VOP2_Real_e32e64_vi<op>, VOP2_SDWA_Real<op>, VOP2_SDWA9_Real<op> {
1432 foreach _ = BoolToList<!cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtDPP>.ret in
1434 VOP_DPP_Real<!cast<VOP2_DPP_Pseudo>(NAME#"_dpp"), SIEncodingFamily.VI>,
1435 VOP2_DPPe<op, !cast<VOP2_DPP_Pseudo>(NAME#"_dpp")>;
1438 defm V_CNDMASK_B32 : VOP2_Real_e32e64_vi <0x0>;
1439 defm V_ADD_F32 : VOP2_Real_e32e64_vi <0x1>;
1440 defm V_SUB_F32 : VOP2_Real_e32e64_vi <0x2>;
1441 defm V_SUBREV_F32 : VOP2_Real_e32e64_vi <0x3>;
1442 defm V_MUL_LEGACY_F32 : VOP2_Real_e32e64_vi <0x4>;
1443 defm V_MUL_F32 : VOP2_Real_e32e64_vi <0x5>;
1444 defm V_MUL_I32_I24 : VOP2_Real_e32e64_vi <0x6>;
1445 defm V_MUL_HI_I32_I24 : VOP2_Real_e32e64_vi <0x7>;
1446 defm V_MUL_U32_U24 : VOP2_Real_e32e64_vi <0x8>;
1447 defm V_MUL_HI_U32_U24 : VOP2_Real_e32e64_vi <0x9>;
1448 defm V_MIN_F32 : VOP2_Real_e32e64_vi <0xa>;
1449 defm V_MAX_F32 : VOP2_Real_e32e64_vi <0xb>;
1450 defm V_MIN_I32 : VOP2_Real_e32e64_vi <0xc>;
1451 defm V_MAX_I32 : VOP2_Real_e32e64_vi <0xd>;
1452 defm V_MIN_U32 : VOP2_Real_e32e64_vi <0xe>;
1453 defm V_MAX_U32 : VOP2_Real_e32e64_vi <0xf>;
1454 defm V_LSHRREV_B32 : VOP2_Real_e32e64_vi <0x10>;
1455 defm V_ASHRREV_I32 : VOP2_Real_e32e64_vi <0x11>;
1456 defm V_LSHLREV_B32 : VOP2_Real_e32e64_vi <0x12>;
1457 defm V_AND_B32 : VOP2_Real_e32e64_vi <0x13>;
1458 defm V_OR_B32 : VOP2_Real_e32e64_vi <0x14>;
1459 defm V_XOR_B32 : VOP2_Real_e32e64_vi <0x15>;
1460 defm V_MAC_F32 : VOP2_Real_e32e64_vi <0x16>;
1461 defm V_MADMK_F32 : VOP2_Real_MADK_vi <0x17>;
1462 defm V_MADAK_F32 : VOP2_Real_MADK_vi <0x18>;
1464 defm V_ADD_U32 : VOP2be_Real_e32e64_vi_only <0x19, "V_ADD_I32", "v_add_u32">;
1465 defm V_SUB_U32 : VOP2be_Real_e32e64_vi_only <0x1a, "V_SUB_I32", "v_sub_u32">;
1466 defm V_SUBREV_U32 : VOP2be_Real_e32e64_vi_only <0x1b, "V_SUBREV_I32", "v_subrev_u32">;
1467 defm V_ADDC_U32 : VOP2be_Real_e32e64_vi_only <0x1c, "V_ADDC_U32", "v_addc_u32">;
1468 defm V_SUBB_U32 : VOP2be_Real_e32e64_vi_only <0x1d, "V_SUBB_U32", "v_subb_u32">;
1469 defm V_SUBBREV_U32 : VOP2be_Real_e32e64_vi_only <0x1e, "V_SUBBREV_U32", "v_subbrev_u32">;
1471 defm V_ADD_CO_U32 : VOP2be_Real_e32e64_gfx9 <0x19, "V_ADD_I32", "v_add_co_u32">;
1472 defm V_SUB_CO_U32 : VOP2be_Real_e32e64_gfx9 <0x1a, "V_SUB_I32", "v_sub_co_u32">;
1473 defm V_SUBREV_CO_U32 : VOP2be_Real_e32e64_gfx9 <0x1b, "V_SUBREV_I32", "v_subrev_co_u32">;
1474 defm V_ADDC_CO_U32 : VOP2be_Real_e32e64_gfx9 <0x1c, "V_ADDC_U32", "v_addc_co_u32">;
1475 defm V_SUBB_CO_U32 : VOP2be_Real_e32e64_gfx9 <0x1d, "V_SUBB_U32", "v_subb_co_u32">;
1476 defm V_SUBBREV_CO_U32 : VOP2be_Real_e32e64_gfx9 <0x1e, "V_SUBBREV_U32", "v_subbrev_co_u32">;
1478 defm V_ADD_U32 : VOP2_Real_e32e64_gfx9 <0x34>;
1479 defm V_SUB_U32 : VOP2_Real_e32e64_gfx9 <0x35>;
1480 defm V_SUBREV_U32 : VOP2_Real_e32e64_gfx9 <0x36>;
1482 defm V_BFM_B32 : VOP2_Real_e64only_vi <0x293>;
1483 defm V_BCNT_U32_B32 : VOP2_Real_e64only_vi <0x28b>;
1484 defm V_MBCNT_LO_U32_B32 : VOP2_Real_e64only_vi <0x28c>;
1485 defm V_MBCNT_HI_U32_B32 : VOP2_Real_e64only_vi <0x28d>;
1486 defm V_LDEXP_F32 : VOP2_Real_e64only_vi <0x288>;
1487 defm V_CVT_PKACCUM_U8_F32 : VOP2_Real_e64only_vi <0x1f0>;
1488 defm V_CVT_PKNORM_I16_F32 : VOP2_Real_e64only_vi <0x294>;
1489 defm V_CVT_PKNORM_U16_F32 : VOP2_Real_e64only_vi <0x295>;
1490 defm V_CVT_PKRTZ_F16_F32 : VOP2_Real_e64only_vi <0x296>;
1491 defm V_CVT_PK_U16_U32 : VOP2_Real_e64only_vi <0x297>;
1492 defm V_CVT_PK_I16_I32 : VOP2_Real_e64only_vi <0x298>;
1494 defm V_ADD_F16 : VOP2_Real_e32e64_vi <0x1f>;
1495 defm V_SUB_F16 : VOP2_Real_e32e64_vi <0x20>;
1496 defm V_SUBREV_F16 : VOP2_Real_e32e64_vi <0x21>;
1497 defm V_MUL_F16 : VOP2_Real_e32e64_vi <0x22>;
1498 defm V_MAC_F16 : VOP2_Real_e32e64_vi <0x23>;
1499 defm V_MADMK_F16 : VOP2_Real_MADK_vi <0x24>;
1500 defm V_MADAK_F16 : VOP2_Real_MADK_vi <0x25>;
1501 defm V_ADD_U16 : VOP2_Real_e32e64_vi <0x26>;
1502 defm V_SUB_U16 : VOP2_Real_e32e64_vi <0x27>;
1503 defm V_SUBREV_U16 : VOP2_Real_e32e64_vi <0x28>;
1504 defm V_MUL_LO_U16 : VOP2_Real_e32e64_vi <0x29>;
1505 defm V_LSHLREV_B16 : VOP2_Real_e32e64_vi <0x2a>;
1506 defm V_LSHRREV_B16 : VOP2_Real_e32e64_vi <0x2b>;
1507 defm V_ASHRREV_I16 : VOP2_Real_e32e64_vi <0x2c>;
1508 defm V_MAX_F16 : VOP2_Real_e32e64_vi <0x2d>;
1509 defm V_MIN_F16 : VOP2_Real_e32e64_vi <0x2e>;
1510 defm V_MAX_U16 : VOP2_Real_e32e64_vi <0x2f>;
1511 defm V_MAX_I16 : VOP2_Real_e32e64_vi <0x30>;
1512 defm V_MIN_U16 : VOP2_Real_e32e64_vi <0x31>;
1513 defm V_MIN_I16 : VOP2_Real_e32e64_vi <0x32>;
1514 defm V_LDEXP_F16 : VOP2_Real_e32e64_vi <0x33>;
1516 let SubtargetPredicate = isGFX8GFX9 in {
1518 // Aliases to simplify matching of floating-point instructions that
1519 // are VOP2 on SI and VOP3 on VI.
1520 class SI2_VI3Alias <string name, VOP3_Real inst> : InstAlias <
1521 name#" $dst, $src0, $src1",
1522 !if(inst.Pfl.HasOMod,
1523 (inst VGPR_32:$dst, 0, VCSrc_f32:$src0, 0, VCSrc_f32:$src1, 0, 0),
1524 (inst VGPR_32:$dst, 0, VCSrc_f32:$src0, 0, VCSrc_f32:$src1, 0))
1525 >, PredicateControl {
1526 let UseInstAsmMatchConverter = 0;
1527 let AsmVariantName = AMDGPUAsmVariants.VOP3;
1530 def : SI2_VI3Alias <"v_ldexp_f32", V_LDEXP_F32_e64_vi>;
1531 def : SI2_VI3Alias <"v_cvt_pkaccum_u8_f32", V_CVT_PKACCUM_U8_F32_e64_vi>;
1532 def : SI2_VI3Alias <"v_cvt_pknorm_i16_f32", V_CVT_PKNORM_I16_F32_e64_vi>;
1533 def : SI2_VI3Alias <"v_cvt_pknorm_u16_f32", V_CVT_PKNORM_U16_F32_e64_vi>;
1534 def : SI2_VI3Alias <"v_cvt_pkrtz_f16_f32", V_CVT_PKRTZ_F16_F32_e64_vi>;
1536 defm : VOP2eInstAliases<V_CNDMASK_B32_e32, V_CNDMASK_B32_e32_vi>;
1538 } // End SubtargetPredicate = isGFX8GFX9
1540 let SubtargetPredicate = isGFX9Only in {
1542 defm : VOP2bInstAliases<V_ADD_I32_e32, V_ADD_CO_U32_e32_gfx9, "v_add_co_u32">;
1543 defm : VOP2bInstAliases<V_ADDC_U32_e32, V_ADDC_CO_U32_e32_gfx9, "v_addc_co_u32">;
1544 defm : VOP2bInstAliases<V_SUB_I32_e32, V_SUB_CO_U32_e32_gfx9, "v_sub_co_u32">;
1545 defm : VOP2bInstAliases<V_SUBB_U32_e32, V_SUBB_CO_U32_e32_gfx9, "v_subb_co_u32">;
1546 defm : VOP2bInstAliases<V_SUBREV_I32_e32, V_SUBREV_CO_U32_e32_gfx9, "v_subrev_co_u32">;
1547 defm : VOP2bInstAliases<V_SUBBREV_U32_e32, V_SUBBREV_CO_U32_e32_gfx9, "v_subbrev_co_u32">;
1549 } // End SubtargetPredicate = isGFX9Only
1551 let SubtargetPredicate = HasDLInsts in {
1553 defm V_FMAC_F32 : VOP2_Real_e32e64_vi <0x3b>;
1554 defm V_XNOR_B32 : VOP2_Real_e32e64_vi <0x3d>;
1556 } // End SubtargetPredicate = HasDLInsts
1558 multiclass VOP2_Real_DOT_ACC_gfx9<bits<6> op> : VOP2_Real_e32_vi<op> {
1559 def _dpp_vi : VOP2_DPP<op, !cast<VOP2_DPP_Pseudo>(NAME#"_dpp")>;
1562 multiclass VOP2_Real_DOT_ACC_gfx10<bits<6> op> :
1563 VOP2_Real_e32_gfx10<op>,
1564 VOP2_Real_dpp_gfx10<op>,
1565 VOP2_Real_dpp8_gfx10<op>;
1567 let SubtargetPredicate = HasDot5Insts in {
1568 defm V_DOT2C_F32_F16 : VOP2_Real_DOT_ACC_gfx9<0x37>;
1569 // NB: Opcode conflicts with V_DOT8C_I32_I4
1570 // This opcode exists in gfx 10.1* only
1571 defm V_DOT2C_F32_F16 : VOP2_Real_DOT_ACC_gfx10<0x02>;
1574 let SubtargetPredicate = HasDot6Insts in {
1575 defm V_DOT4C_I32_I8 : VOP2_Real_DOT_ACC_gfx9<0x39>;
1576 defm V_DOT4C_I32_I8 : VOP2_Real_DOT_ACC_gfx10<0x0d>;
1579 let SubtargetPredicate = HasDot4Insts in {
1580 defm V_DOT2C_I32_I16 : VOP2_Real_DOT_ACC_gfx9<0x38>;
1582 let SubtargetPredicate = HasDot3Insts in {
1583 defm V_DOT8C_I32_I4 : VOP2_Real_DOT_ACC_gfx9<0x3a>;
1586 let SubtargetPredicate = HasPkFmacF16Inst in {
1587 defm V_PK_FMAC_F16 : VOP2_Real_e32_vi<0x3c>;
1588 } // End SubtargetPredicate = HasPkFmacF16Inst