xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/VOP3Instructions.td (revision 9bc300465e48e19d794d88d0c158a2adb92c7197)
1//===-- VOP3Instructions.td - Vector Instruction Definitions --------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9// Special case for v_div_fmas_{f32|f64}, since it seems to be the
10// only VOP instruction that implicitly reads VCC.
11let Asm64 = " $vdst, $src0_modifiers, $src1_modifiers, $src2_modifiers$clamp$omod" in {
12def VOP_F32_F32_F32_F32_VCC : VOPProfile<[f32, f32, f32, f32]> {
13  let Outs64 = (outs DstRC.RegClass:$vdst);
14  let HasExtVOP3DPP = 0;
15  let HasExtDPP = 0;
16}
17def VOP_F64_F64_F64_F64_VCC : VOPProfile<[f64, f64, f64, f64]> {
18  let Outs64 = (outs DstRC.RegClass:$vdst);
19}
20}
21
22class VOP3b_Profile<ValueType vt> : VOPProfile<[vt, vt, vt, vt]> {
23  let Outs64 = (outs DstRC:$vdst, VOPDstS64orS32:$sdst);
24  let Asm64 = "$vdst, $sdst, $src0_modifiers, $src1_modifiers, $src2_modifiers$clamp$omod";
25  let IsSingle = 1;
26  let HasExtVOP3DPP = 0;
27  let HasExtDPP = 0;
28}
29
30def VOP3b_F32_I1_F32_F32_F32 : VOP3b_Profile<f32>;
31def VOP3b_F64_I1_F64_F64_F64 : VOP3b_Profile<f64>;
32
33def VOP3b_I64_I1_I32_I32_I64 : VOPProfile<[i64, i32, i32, i64]> {
34  let HasClamp = 1;
35
36  let IsSingle = 1;
37  let Outs64 = (outs DstRC:$vdst, VOPDstS64orS32:$sdst);
38  let Asm64 = "$vdst, $sdst, $src0, $src1, $src2$clamp";
39}
40
41class V_MUL_PROF<VOPProfile P> : VOP3_Profile<P> {
42  let HasExtVOP3DPP = 0;
43  let HasExtDPP = 0;
44}
45
46def DIV_FIXUP_F32_PROF : VOP3_Profile<VOP_F32_F32_F32_F32> {
47  let HasExtVOP3DPP = 0;
48  let HasExtDPP = 0;
49}
50
51//===----------------------------------------------------------------------===//
52// VOP3 INTERP
53//===----------------------------------------------------------------------===//
54
55class VOP3Interp<string OpName, VOPProfile P, list<dag> pattern = []> :
56                 VOP3_Pseudo<OpName, P, pattern> {
57  let AsmMatchConverter = "cvtVOP3Interp";
58  let mayRaiseFPException = 0;
59}
60
61def VOP3_INTERP : VOPProfile<[f32, f32, i32, untyped]> {
62  let Src0Mod = FPVRegInputMods;
63  let Ins64 = (ins Src0Mod:$src0_modifiers, VRegSrc_32:$src0,
64                   InterpAttr:$attr, InterpAttrChan:$attrchan,
65                   clampmod0:$clamp, omod0:$omod);
66
67  let Asm64 = "$vdst, $src0_modifiers, $attr$attrchan$clamp$omod";
68}
69
70def VOP3_INTERP_MOV : VOPProfile<[f32, i32, i32, untyped]> {
71  let Ins64 = (ins InterpSlot:$src0,
72                   InterpAttr:$attr, InterpAttrChan:$attrchan,
73                   clampmod0:$clamp, omod0:$omod);
74
75  let Asm64 = "$vdst, $src0, $attr$attrchan$clamp$omod";
76
77  let HasClamp = 1;
78  let HasSrc0Mods = 0;
79}
80
81class getInterp16Asm <bit HasSrc2, bit HasOMod> {
82  string src2 = !if(HasSrc2, ", $src2_modifiers", "");
83  string omod = !if(HasOMod, "$omod", "");
84  string ret =
85    " $vdst, $src0_modifiers, $attr$attrchan"#src2#"$high$clamp"#omod;
86}
87
88class getInterp16Ins <bit HasSrc2, bit HasOMod,
89                      Operand Src0Mod, Operand Src2Mod> {
90  dag ret = !if(HasSrc2,
91                !if(HasOMod,
92                    (ins Src0Mod:$src0_modifiers, VRegSrc_32:$src0,
93                         InterpAttr:$attr, InterpAttrChan:$attrchan,
94                         Src2Mod:$src2_modifiers, VRegSrc_32:$src2,
95                         highmod:$high, clampmod0:$clamp, omod0:$omod),
96                    (ins Src0Mod:$src0_modifiers, VRegSrc_32:$src0,
97                         InterpAttr:$attr, InterpAttrChan:$attrchan,
98                         Src2Mod:$src2_modifiers, VRegSrc_32:$src2,
99                         highmod:$high, clampmod0:$clamp)
100                ),
101                (ins Src0Mod:$src0_modifiers, VRegSrc_32:$src0,
102                     InterpAttr:$attr, InterpAttrChan:$attrchan,
103                     highmod:$high, clampmod0:$clamp, omod0:$omod)
104            );
105}
106
107class VOP3_INTERP16 <list<ValueType> ArgVT> : VOPProfile<ArgVT> {
108
109  let HasOMod = !ne(DstVT.Value, f16.Value);
110  let HasHigh = 1;
111
112  let Src0Mod = FPVRegInputMods;
113  let Src2Mod = FPVRegInputMods;
114
115  let Outs64 = (outs DstRC.RegClass:$vdst);
116  let Ins64 = getInterp16Ins<HasSrc2, HasOMod, Src0Mod, Src2Mod>.ret;
117  let Asm64 = getInterp16Asm<HasSrc2, HasOMod>.ret;
118}
119
120//===----------------------------------------------------------------------===//
121// VOP3 Instructions
122//===----------------------------------------------------------------------===//
123
124let isCommutable = 1 in {
125
126let isReMaterializable = 1 in {
127let mayRaiseFPException = 0 in {
128let SubtargetPredicate = HasMadMacF32Insts in {
129defm V_MAD_LEGACY_F32 : VOP3Inst <"v_mad_legacy_f32", VOP3_Profile<VOP_F32_F32_F32_F32>>;
130defm V_MAD_F32 : VOP3Inst <"v_mad_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, any_fmad>;
131} // End SubtargetPredicate = HasMadMacInsts
132
133let SubtargetPredicate = HasFmaLegacy32 in
134defm V_FMA_LEGACY_F32 : VOP3Inst <"v_fma_legacy_f32",
135                                 VOP3_Profile<VOP_F32_F32_F32_F32>,
136                                 int_amdgcn_fma_legacy>;
137}
138
139defm V_MAD_I32_I24 : VOP3Inst <"v_mad_i32_i24", VOP3_Profile<VOP_I32_I32_I32_I32, VOP3_CLAMP>>;
140defm V_MAD_U32_U24 : VOP3Inst <"v_mad_u32_u24", VOP3_Profile<VOP_I32_I32_I32_I32, VOP3_CLAMP>>;
141defm V_FMA_F32 : VOP3Inst <"v_fma_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, any_fma>;
142defm V_LERP_U8 : VOP3Inst <"v_lerp_u8", VOP3_Profile<VOP_I32_I32_I32_I32>, int_amdgcn_lerp>;
143
144let SchedRW = [WriteDoubleAdd] in {
145let FPDPRounding = 1 in {
146defm V_FMA_F64 : VOP3Inst <"v_fma_f64", VOP3_Profile<VOP_F64_F64_F64_F64>, any_fma>;
147let SubtargetPredicate = isNotGFX12Plus in {
148defm V_ADD_F64 : VOP3Inst <"v_add_f64", VOP3_Profile<VOP_F64_F64_F64>, any_fadd>;
149defm V_MUL_F64 : VOP3Inst <"v_mul_f64", VOP3_Profile<VOP_F64_F64_F64>, any_fmul>;
150} // End SubtargetPredicate = isNotGFX12Plus
151} // End FPDPRounding = 1
152let SubtargetPredicate = isNotGFX12Plus in {
153defm V_MIN_F64 : VOP3Inst <"v_min_f64", VOP3_Profile<VOP_F64_F64_F64>, fminnum_like>;
154defm V_MAX_F64 : VOP3Inst <"v_max_f64", VOP3_Profile<VOP_F64_F64_F64>, fmaxnum_like>;
155} // End SubtargetPredicate = isNotGFX12Plus
156} // End SchedRW = [WriteDoubleAdd]
157
158let SchedRW = [WriteIntMul] in {
159defm V_MUL_LO_U32 : VOP3Inst <"v_mul_lo_u32", V_MUL_PROF<VOP_I32_I32_I32>, DivergentBinFrag<mul>>;
160defm V_MUL_HI_U32 : VOP3Inst <"v_mul_hi_u32", V_MUL_PROF<VOP_I32_I32_I32>, mulhu>;
161defm V_MUL_LO_I32 : VOP3Inst <"v_mul_lo_i32", V_MUL_PROF<VOP_I32_I32_I32>>;
162defm V_MUL_HI_I32 : VOP3Inst <"v_mul_hi_i32", V_MUL_PROF<VOP_I32_I32_I32>, mulhs>;
163} // End SchedRW = [WriteIntMul]
164
165let SubtargetPredicate = isGFX12Plus, ReadsModeReg = 0 in {
166defm V_MINIMUM_F32 : VOP3Inst <"v_minimum_f32", VOP3_Profile<VOP_F32_F32_F32>, DivergentBinFrag<fminimum>>;
167defm V_MAXIMUM_F32 : VOP3Inst <"v_maximum_f32", VOP3_Profile<VOP_F32_F32_F32>, DivergentBinFrag<fmaximum>>;
168defm V_MINIMUM_F16 : VOP3Inst <"v_minimum_f16", VOP3_Profile<VOP_F16_F16_F16>, DivergentBinFrag<fminimum>>;
169defm V_MAXIMUM_F16 : VOP3Inst <"v_maximum_f16", VOP3_Profile<VOP_F16_F16_F16>, DivergentBinFrag<fmaximum>>;
170
171let SchedRW = [WriteDoubleAdd] in {
172defm V_MINIMUM_F64 : VOP3Inst <"v_minimum_f64", VOP3_Profile<VOP_F64_F64_F64>, fminimum>;
173defm V_MAXIMUM_F64 : VOP3Inst <"v_maximum_f64", VOP3_Profile<VOP_F64_F64_F64>, fmaximum>;
174} // End SchedRW = [WriteDoubleAdd]
175} // End SubtargetPredicate = isGFX12Plus, ReadsModeReg = 0
176
177} // End isReMaterializable = 1
178
179let Uses = [MODE, VCC, EXEC] in {
180// v_div_fmas_f32:
181//   result = src0 * src1 + src2
182//   if (vcc)
183//     result *= 2^32
184//
185let SchedRW = [WriteFloatFMA] in
186defm V_DIV_FMAS_F32 : VOP3Inst_Pseudo_Wrapper <"v_div_fmas_f32", VOP_F32_F32_F32_F32_VCC, []>;
187// v_div_fmas_f64:
188//   result = src0 * src1 + src2
189//   if (vcc)
190//     result *= 2^64
191//
192let SchedRW = [WriteDouble], FPDPRounding = 1 in
193defm V_DIV_FMAS_F64 : VOP3Inst_Pseudo_Wrapper  <"v_div_fmas_f64", VOP_F64_F64_F64_F64_VCC, []>;
194} // End Uses = [MODE, VCC, EXEC]
195
196} // End isCommutable = 1
197
198let isReMaterializable = 1 in {
199let mayRaiseFPException = 0 in {
200defm V_CUBEID_F32 : VOP3Inst <"v_cubeid_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, int_amdgcn_cubeid>;
201defm V_CUBESC_F32 : VOP3Inst <"v_cubesc_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, int_amdgcn_cubesc>;
202defm V_CUBETC_F32 : VOP3Inst <"v_cubetc_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, int_amdgcn_cubetc>;
203defm V_CUBEMA_F32 : VOP3Inst <"v_cubema_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, int_amdgcn_cubema>;
204} // End mayRaiseFPException
205
206defm V_BFE_U32 : VOP3Inst <"v_bfe_u32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUbfe_u32>;
207defm V_BFE_I32 : VOP3Inst <"v_bfe_i32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUbfe_i32>;
208defm V_BFI_B32 : VOP3Inst <"v_bfi_b32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUbfi>;
209defm V_ALIGNBIT_B32 : VOP3Inst <"v_alignbit_b32", VOP3_Profile<VOP_I32_I32_I32_I32>, fshr>;
210defm V_ALIGNBYTE_B32 : VOP3Inst <"v_alignbyte_b32", VOP3_Profile<VOP_I32_I32_I32_I32>, int_amdgcn_alignbyte>;
211
212// XXX - No FPException seems suspect but manual doesn't say it does
213let mayRaiseFPException = 0 in {
214  let isCommutable = 1 in {
215    defm V_MIN3_I32 : VOP3Inst <"v_min3_i32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUsmin3>;
216    defm V_MIN3_U32 : VOP3Inst <"v_min3_u32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUumin3>;
217    defm V_MAX3_I32 : VOP3Inst <"v_max3_i32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUsmax3>;
218    defm V_MAX3_U32 : VOP3Inst <"v_max3_u32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUumax3>;
219    defm V_MED3_I32 : VOP3Inst <"v_med3_i32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUsmed3>;
220    defm V_MED3_U32 : VOP3Inst <"v_med3_u32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUumed3>;
221  } // End isCommutable = 1
222  defm V_MIN3_F32 : VOP3Inst <"v_min3_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, AMDGPUfmin3>;
223  defm V_MAX3_F32 : VOP3Inst <"v_max3_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, AMDGPUfmax3>;
224  defm V_MED3_F32 : VOP3Inst <"v_med3_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, AMDGPUfmed3>;
225} // End mayRaiseFPException = 0
226
227let SubtargetPredicate = isGFX12Plus, ReadsModeReg = 0 in {
228  defm V_MINIMUM3_F32 : VOP3Inst <"v_minimum3_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, AMDGPUfminimum3>;
229  defm V_MAXIMUM3_F32 : VOP3Inst <"v_maximum3_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, AMDGPUfmaximum3>;
230} // End SubtargetPredicate = isGFX12Plus, ReadsModeReg = 0
231
232let isCommutable = 1 in {
233  defm V_SAD_U8 : VOP3Inst <"v_sad_u8", VOP3_Profile<VOP_I32_I32_I32_I32, VOP3_CLAMP>>;
234  defm V_SAD_HI_U8 : VOP3Inst <"v_sad_hi_u8", VOP3_Profile<VOP_I32_I32_I32_I32, VOP3_CLAMP>>;
235  defm V_SAD_U16 : VOP3Inst <"v_sad_u16", VOP3_Profile<VOP_I32_I32_I32_I32, VOP3_CLAMP>>;
236  defm V_SAD_U32 : VOP3Inst <"v_sad_u32", VOP3_Profile<VOP_I32_I32_I32_I32, VOP3_CLAMP>>;
237} // End isCommutable = 1
238defm V_CVT_PK_U8_F32 : VOP3Inst<"v_cvt_pk_u8_f32", VOP3_Profile<VOP_I32_F32_I32_I32>, int_amdgcn_cvt_pk_u8_f32>;
239
240defm V_DIV_FIXUP_F32 : VOP3Inst <"v_div_fixup_f32", DIV_FIXUP_F32_PROF, AMDGPUdiv_fixup>;
241
242let SchedRW = [WriteDoubleAdd], FPDPRounding = 1 in {
243  defm V_DIV_FIXUP_F64 : VOP3Inst <"v_div_fixup_f64", VOP3_Profile<VOP_F64_F64_F64_F64>, AMDGPUdiv_fixup>;
244  defm V_LDEXP_F64 : VOP3Inst <"v_ldexp_f64", VOP3_Profile<VOP_F64_F64_I32>, any_fldexp>;
245} // End SchedRW = [WriteDoubleAdd], FPDPRounding = 1
246} // End isReMaterializable = 1
247
248
249let mayRaiseFPException = 0 in { // Seems suspicious but manual doesn't say it does.
250  let SchedRW = [WriteFloatFMA, WriteSALU] in
251  defm V_DIV_SCALE_F32 : VOP3Inst_Pseudo_Wrapper <"v_div_scale_f32", VOP3b_F32_I1_F32_F32_F32> ;
252
253  // Double precision division pre-scale.
254  let SchedRW = [WriteDouble, WriteSALU], FPDPRounding = 1 in
255  defm V_DIV_SCALE_F64 : VOP3Inst_Pseudo_Wrapper <"v_div_scale_f64", VOP3b_F64_I1_F64_F64_F64>;
256} // End mayRaiseFPException = 0
257
258let isReMaterializable = 1 in
259defm V_MSAD_U8 : VOP3Inst <"v_msad_u8", VOP3_Profile<VOP_I32_I32_I32_I32, VOP3_CLAMP>>;
260
261let Constraints = "@earlyclobber $vdst" in {
262defm V_MQSAD_PK_U16_U8 : VOP3Inst <"v_mqsad_pk_u16_u8", VOP3_Profile<VOP_I64_I64_I32_I64, VOP3_CLAMP>>;
263} // End Constraints = "@earlyclobber $vdst"
264
265
266let isReMaterializable = 1 in {
267let SchedRW = [WriteDouble] in {
268defm V_TRIG_PREOP_F64 : VOP3Inst <"v_trig_preop_f64", VOP3_Profile<VOP_F64_F64_I32>, int_amdgcn_trig_preop>;
269} // End SchedRW = [WriteDouble]
270
271let SchedRW = [Write64Bit] in {
272  let SubtargetPredicate = isGFX6GFX7 in {
273  defm V_LSHL_B64 : VOP3Inst <"v_lshl_b64", VOP3_Profile<VOP_I64_I64_I32>, cshl_64>;
274  defm V_LSHR_B64 : VOP3Inst <"v_lshr_b64", VOP3_Profile<VOP_I64_I64_I32>, csrl_64>;
275  defm V_ASHR_I64 : VOP3Inst <"v_ashr_i64", VOP3_Profile<VOP_I64_I64_I32>, csra_64>;
276  } // End SubtargetPredicate = isGFX6GFX7
277
278  let SubtargetPredicate = isGFX8Plus in {
279  defm V_LSHRREV_B64 : VOP3Inst <"v_lshrrev_b64", VOP3_Profile<VOP_I64_I32_I64>, clshr_rev_64>;
280  defm V_ASHRREV_I64 : VOP3Inst <"v_ashrrev_i64", VOP3_Profile<VOP_I64_I32_I64>, cashr_rev_64>;
281  } // End SubtargetPredicate = isGFX8Plus
282
283  let SubtargetPredicate = isGFX8GFX9GFX10GFX11 in {
284  defm V_LSHLREV_B64 : VOP3Inst <"v_lshlrev_b64", VOP3_Profile<VOP_I64_I32_I64>, clshl_rev_64>;
285  } // End SubtargetPredicate = isGFX8GFX9GFX10GFX11
286} // End SchedRW = [Write64Bit]
287} // End isReMaterializable = 1
288
289def : GCNPat<
290  (i32 (DivergentUnaryFrag<sext> i16:$src)),
291  (i32 (V_BFE_I32_e64 i16:$src, (i32 0), (i32 0x10)))
292>;
293
294let isReMaterializable = 1 in {
295let SubtargetPredicate = isGFX6GFX7GFX10Plus in {
296defm V_MULLIT_F32 : VOP3Inst <"v_mullit_f32", VOP3_Profile<VOP_F32_F32_F32_F32>>;
297} // End SubtargetPredicate = isGFX6GFX7GFX10Plus
298
299let SchedRW = [Write32Bit] in {
300let SubtargetPredicate = isGFX8Plus in {
301defm V_PERM_B32 : VOP3Inst <"v_perm_b32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUperm>;
302} // End SubtargetPredicate = isGFX8Plus
303} // End SchedRW = [Write32Bit]
304} // End isReMaterializable = 1
305
306def VOPProfileMQSAD : VOP3_Profile<VOP_V4I32_I64_I32_V4I32, VOP3_CLAMP> {
307  let HasModifiers = 0;
308}
309
310let SubtargetPredicate = isGFX7Plus in {
311let Constraints = "@earlyclobber $vdst", SchedRW = [WriteQuarterRate32] in {
312defm V_QSAD_PK_U16_U8 : VOP3Inst <"v_qsad_pk_u16_u8", VOP3_Profile<VOP_I64_I64_I32_I64, VOP3_CLAMP>>;
313defm V_MQSAD_U32_U8 : VOP3Inst <"v_mqsad_u32_u8", VOPProfileMQSAD>;
314} // End Constraints = "@earlyclobber $vdst", SchedRW = [WriteQuarterRate32]
315} // End SubtargetPredicate = isGFX7Plus
316
317let isCommutable = 1, SchedRW = [WriteIntMul, WriteSALU] in {
318  let SubtargetPredicate = isGFX7Plus, OtherPredicates = [HasNotMADIntraFwdBug] in {
319    defm V_MAD_U64_U32 : VOP3Inst <"v_mad_u64_u32", VOP3b_I64_I1_I32_I32_I64>;
320    defm V_MAD_I64_I32 : VOP3Inst <"v_mad_i64_i32", VOP3b_I64_I1_I32_I32_I64>;
321  }
322  let SubtargetPredicate = isGFX11Only, OtherPredicates = [HasMADIntraFwdBug],
323      Constraints = "@earlyclobber $vdst" in {
324    defm V_MAD_U64_U32_gfx11 : VOP3Inst <"v_mad_u64_u32", VOP3b_I64_I1_I32_I32_I64>;
325    defm V_MAD_I64_I32_gfx11 : VOP3Inst <"v_mad_i64_i32", VOP3b_I64_I1_I32_I32_I64>;
326  }
327} // End isCommutable = 1, SchedRW = [WriteIntMul, WriteSALU]
328
329
330let FPDPRounding = 1 in {
331  let Predicates = [Has16BitInsts, isGFX8Only] in {
332    defm V_DIV_FIXUP_F16 : VOP3Inst <"v_div_fixup_f16", VOP3_Profile<VOP_F16_F16_F16_F16>, AMDGPUdiv_fixup>;
333    defm V_FMA_F16 : VOP3Inst <"v_fma_f16", VOP3_Profile<VOP_F16_F16_F16_F16>, any_fma>;
334  } // End Predicates = [Has16BitInsts, isGFX8Only]
335
336  let renamedInGFX9 = 1, SubtargetPredicate = isGFX9Plus in {
337    defm V_DIV_FIXUP_F16_gfx9 : VOP3Inst <"v_div_fixup_f16_gfx9",
338                                          VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>, AMDGPUdiv_fixup>;
339    defm V_FMA_F16_gfx9 : VOP3Inst <"v_fma_f16_gfx9", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>, any_fma>;
340  } // End renamedInGFX9 = 1, SubtargetPredicate = isGFX9Plus
341} // End FPDPRounding = 1
342
343let SubtargetPredicate = Has16BitInsts, isCommutable = 1 in {
344
345let renamedInGFX9 = 1 in {
346  defm V_MAD_U16 : VOP3Inst <"v_mad_u16", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_CLAMP>>;
347  defm V_MAD_I16 : VOP3Inst <"v_mad_i16", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_CLAMP>>;
348  let FPDPRounding = 1 in {
349    defm V_MAD_F16 : VOP3Inst <"v_mad_f16", VOP3_Profile<VOP_F16_F16_F16_F16>, any_fmad>;
350    let Uses = [MODE, M0, EXEC] in {
351    let OtherPredicates = [isNotGFX90APlus] in
352    // For some reason the intrinsic operands are in a different order
353    // from the instruction operands.
354    def V_INTERP_P2_F16 : VOP3Interp <"v_interp_p2_f16", VOP3_INTERP16<[f16, f32, i32, f32]>,
355           [(set f16:$vdst,
356             (int_amdgcn_interp_p2_f16 (VOP3Mods f32:$src2, i32:$src2_modifiers),
357                                       (VOP3Mods f32:$src0, i32:$src0_modifiers),
358                                       (i32 timm:$attrchan),
359                                       (i32 timm:$attr),
360                                       (i1 timm:$high),
361                                       M0))]>;
362    } // End Uses = [M0, MODE, EXEC]
363  } // End FPDPRounding = 1
364} // End renamedInGFX9 = 1
365
366let SubtargetPredicate = isGFX9Only, FPDPRounding = 1 in {
367  defm V_MAD_F16_gfx9   : VOP3Inst <"v_mad_f16_gfx9", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>> ;
368} // End SubtargetPredicate = isGFX9Only, FPDPRounding = 1
369
370let SubtargetPredicate = isGFX9Plus in {
371defm V_MAD_U16_gfx9   : VOP3Inst <"v_mad_u16_gfx9", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_OPSEL>>;
372defm V_MAD_I16_gfx9   : VOP3Inst <"v_mad_i16_gfx9", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_OPSEL>>;
373let OtherPredicates = [isNotGFX90APlus] in
374def V_INTERP_P2_F16_gfx9 : VOP3Interp <"v_interp_p2_f16_gfx9", VOP3_INTERP16<[f16, f32, i32, f32]>>;
375} // End SubtargetPredicate = isGFX9Plus
376
377// This predicate should only apply to the selection pattern. The
378// instruction still exists and should decode on subtargets with
379// other bank counts.
380let OtherPredicates = [isNotGFX90APlus, has32BankLDS], Uses = [MODE, M0, EXEC], FPDPRounding = 1 in {
381def V_INTERP_P1LL_F16 : VOP3Interp <"v_interp_p1ll_f16", VOP3_INTERP16<[f32, f32, i32, untyped]>,
382       [(set f32:$vdst, (int_amdgcn_interp_p1_f16 (VOP3Mods f32:$src0, i32:$src0_modifiers),
383                                                  (i32 timm:$attrchan),
384                                                  (i32 timm:$attr),
385                                                  (i1 timm:$high), M0))]>;
386} // End OtherPredicates = [isNotGFX90APlus, has32BankLDS], Uses = [MODE, M0, EXEC], FPDPRounding = 1
387
388let OtherPredicates = [isNotGFX90APlus], Uses = [MODE, M0, EXEC], FPDPRounding = 1 in {
389def V_INTERP_P1LV_F16 : VOP3Interp <"v_interp_p1lv_f16", VOP3_INTERP16<[f32, f32, i32, f16]>>;
390} // End OtherPredicates = [isNotGFX90APlus], Uses = [MODE, M0, EXEC], FPDPRounding = 1
391
392} // End SubtargetPredicate = Has16BitInsts, isCommutable = 1
393
394def : GCNPat<
395  (i64 (DivergentUnaryFrag<sext> i16:$src)),
396    (REG_SEQUENCE VReg_64,
397      (i32 (V_BFE_I32_e64 $src, (S_MOV_B32 (i32 0)), (S_MOV_B32 (i32 0x10)))), sub0,
398      (i32 (COPY_TO_REGCLASS
399         (V_ASHRREV_I32_e32 (S_MOV_B32 (i32 0x1f)), (i32 (V_BFE_I32_e64 $src, (S_MOV_B32 (i32 0)), (S_MOV_B32 (i32 0x10))))
400      ), VGPR_32)), sub1)
401>;
402
403let SubtargetPredicate = isGFX8Plus, Uses = [MODE, M0, EXEC], OtherPredicates = [isNotGFX90APlus] in {
404def V_INTERP_P1_F32_e64  : VOP3Interp <"v_interp_p1_f32", VOP3_INTERP>;
405def V_INTERP_P2_F32_e64  : VOP3Interp <"v_interp_p2_f32", VOP3_INTERP>;
406def V_INTERP_MOV_F32_e64 : VOP3Interp <"v_interp_mov_f32", VOP3_INTERP_MOV>;
407} // End SubtargetPredicate = isGFX8Plus, Uses = [MODE, M0, EXEC], OtherPredicates = [isNotGFX90APlus]
408
409// Note: 16-bit instructions produce a 0 result in the high 16-bits
410// on GFX8 and GFX9 and preserve high 16 bits on GFX10+
411multiclass Arithmetic_i16_0Hi_TernaryPats <SDPatternOperator op, Instruction inst> {
412  def : GCNPat<
413    (i32 (zext (op i16:$src0, i16:$src1, i16:$src2))),
414    (inst VSrc_b16:$src0, VSrc_b16:$src1, VSrc_b16:$src2)
415  >;
416}
417
418let Predicates = [Has16BitInsts, isGFX8GFX9] in {
419defm : Arithmetic_i16_0Hi_TernaryPats<imad, V_MAD_U16_e64>;
420}
421
422let Predicates = [Has16BitInsts, isGFX6GFX7GFX8GFX9] in {
423
424// FIXME: Should be able to just pass imad to the instruction
425// definition pattern, but the implied clamp input interferes.
426multiclass Ternary_i16_Pats <SDPatternOperator op, Instruction inst> {
427  def : GCNPat <
428    (op i16:$src0, i16:$src1, i16:$src2),
429    (inst i16:$src0, i16:$src1, i16:$src2, (i1 0))
430  >;
431}
432
433defm: Ternary_i16_Pats<imad, V_MAD_U16_e64>;
434
435} // End Predicates = [Has16BitInsts, isGFX6GFX7GFX8GFX9]
436
437
438class Ternary_i16_Pats_gfx9<SDPatternOperator op1, SDPatternOperator op2,
439                                 Instruction inst> : GCNPat <
440  (op2 (op1 i16:$src0, i16:$src1), i16:$src2),
441  (inst SRCMODS.NONE, $src0, SRCMODS.NONE, $src1, SRCMODS.NONE, $src2, DSTCLAMP.NONE)
442>;
443
444let Predicates = [Has16BitInsts, isGFX10Plus] in {
445def: Ternary_i16_Pats_gfx9<mul, add, V_MAD_U16_gfx9_e64>;
446} // End Predicates = [Has16BitInsts, isGFX10Plus]
447
448class ThreeOpFragSDAG<SDPatternOperator op1, SDPatternOperator op2> : PatFrag<
449  (ops node:$x, node:$y, node:$z),
450  // When the inner operation is used multiple times, selecting 3-op
451  // instructions may still be beneficial -- if the other users can be
452  // combined similarly. Let's be conservative for now.
453  (op2 (HasOneUseBinOp<op1> node:$x, node:$y), node:$z),
454  [{
455    // Only use VALU ops when the result is divergent.
456    if (!N->isDivergent())
457      return false;
458
459    // Check constant bus limitations.
460    //
461    // Note: Use !isDivergent as a conservative proxy for whether the value
462    //       is in an SGPR (uniform values can end up in VGPRs as well).
463    unsigned ConstantBusUses = 0;
464    for (unsigned i = 0; i < 3; ++i) {
465      if (!Operands[i]->isDivergent() &&
466          !isInlineImmediate(Operands[i].getNode())) {
467        ConstantBusUses++;
468        // This uses AMDGPU::V_ADD3_U32_e64, but all three operand instructions
469        // have the same constant bus limit.
470        if (ConstantBusUses > Subtarget->getConstantBusLimit(AMDGPU::V_ADD3_U32_e64))
471          return false;
472      }
473    }
474
475    return true;
476  }]> {
477  let PredicateCodeUsesOperands = 1;
478}
479
480class ThreeOpFrag<SDPatternOperator op1, SDPatternOperator op2> : ThreeOpFragSDAG<op1, op2> {
481  // The divergence predicate is irrelevant in GlobalISel, as we have
482  // proper register bank checks. We just need to verify the constant
483  // bus restriction when all the sources are considered.
484  //
485  // FIXME: With unlucky SGPR operands, we could penalize code by
486  // blocking folding SGPR->VGPR copies later.
487  // FIXME: There's no register bank verifier
488  let GISelPredicateCode = [{
489    const int ConstantBusLimit = Subtarget->getConstantBusLimit(AMDGPU::V_ADD3_U32_e64);
490    int ConstantBusUses = 0;
491    for (unsigned i = 0; i < 3; ++i) {
492      const RegisterBank *RegBank = RBI.getRegBank(Operands[i]->getReg(), MRI, TRI);
493      if (RegBank->getID() == AMDGPU::SGPRRegBankID) {
494        if (++ConstantBusUses > ConstantBusLimit)
495          return false;
496      }
497    }
498    return true;
499  }];
500}
501
502def shl_0_to_4 : PatFrag<
503  (ops node:$src0, node:$src1), (shl node:$src0, node:$src1),
504  [{
505     if (auto *C = dyn_cast<ConstantSDNode>(N->getOperand(1))) {
506       return C->getZExtValue() <= 4;
507     }
508     return false;
509   }]> {
510  let GISelPredicateCode = [{
511    int64_t Imm = 0;
512    if (!mi_match(MI.getOperand(2).getReg(), MRI, m_ICst(Imm)) &&
513        !mi_match(MI.getOperand(2).getReg(), MRI, m_Copy(m_ICst(Imm))))
514      return false;
515    return (uint64_t)Imm <= 4;
516  }];
517}
518
519def VOP3_CVT_PK_F8_F32_Profile : VOP3_Profile<VOP_I32_F32_F32, VOP3_OPSEL> {
520  let InsVOP3OpSel = (ins FP32InputMods:$src0_modifiers, Src0RC64:$src0,
521                          FP32InputMods:$src1_modifiers, Src1RC64:$src1,
522                          VGPR_32:$vdst_in, op_sel0:$op_sel);
523  let InsVOP3DPP = (ins VGPR_32:$old,
524                        FP32InputMods:$src0_modifiers, Src0VOP3DPP:$src0,
525                        FP32InputMods:$src1_modifiers, Src1VOP3DPP:$src1,
526                        VGPR_32:$vdst_in, op_sel0:$op_sel,
527                        dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
528                        bank_mask:$bank_mask, bound_ctrl:$bound_ctrl);
529
530  let InsVOP3DPP16 = (ins VGPR_32:$old,
531                          FP32InputMods:$src0_modifiers, Src0VOP3DPP:$src0,
532                          FP32InputMods:$src1_modifiers, Src1VOP3DPP:$src1,
533                          VGPR_32:$vdst_in, op_sel0:$op_sel,
534                          dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
535                          bank_mask:$bank_mask, bound_ctrl:$bound_ctrl, FI:$fi);
536  let InsVOP3DPP8 = (ins VGPR_32:$old,
537                         FP32InputMods:$src0_modifiers, Src0VOP3DPP:$src0,
538                         FP32InputMods:$src1_modifiers, Src1VOP3DPP:$src1,
539                         VGPR_32:$vdst_in, op_sel0:$op_sel, dpp8:$dpp8, FI:$fi);
540
541  let HasClamp = 0;
542  let HasExtVOP3DPP = 1;
543}
544
545def VOP3_CVT_SR_F8_F32_Profile : VOP3_Profile<VOPProfile<[i32, f32, i32, f32]>,
546                                              VOP3_OPSEL> {
547  let InsVOP3OpSel = (ins FP32InputMods:$src0_modifiers, Src0RC64:$src0,
548                          FP32InputMods:$src1_modifiers, Src1RC64:$src1,
549                          FP32InputMods:$src2_modifiers, VGPR_32:$src2,
550                          op_sel0:$op_sel);
551  let InsVOP3DPP16 = (ins VGPR_32:$old,
552                          FP32InputMods:$src0_modifiers, Src0VOP3DPP:$src0,
553                          FP32InputMods:$src1_modifiers, Src1VOP3DPP:$src1,
554                          FP32InputMods:$src2_modifiers, VGPR_32:$src2,
555                          op_sel0:$op_sel, dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
556                          bank_mask:$bank_mask, bound_ctrl:$bound_ctrl, FI:$fi);
557  let InsVOP3DPP8 = (ins VGPR_32:$old,
558                         FP32InputMods:$src0_modifiers, Src0VOP3DPP:$src0,
559                         FP32InputMods:$src1_modifiers, Src1VOP3DPP:$src1,
560                         FP32InputMods:$src2_modifiers, VGPR_32:$src2,
561                         op_sel0:$op_sel, dpp8:$dpp8, FI:$fi);
562  let HasClamp = 0;
563  let HasSrc2 = 0;
564  let HasSrc2Mods = 1;
565  let HasExtVOP3DPP = 1;
566  let HasOpSel = 1;
567  let AsmVOP3OpSel = !subst(", $src2_modifiers", "",
568                            getAsmVOP3OpSel<3, HasClamp, HasOMod,
569                                            HasSrc0FloatMods, HasSrc1FloatMods,
570                                            HasSrc2FloatMods>.ret);
571  let AsmVOP3DPP16 = !subst(", $src2_modifiers", "",
572                            getAsmVOP3DPP16<getAsmVOP3Base<3, 1, HasClamp, 1,
573                                            HasOMod, 0, 1, HasSrc0FloatMods,
574                                            HasSrc1FloatMods,
575                                            HasSrc2FloatMods>.ret>.ret);
576  let AsmVOP3DPP8 = !subst(", $src2_modifiers", "",
577                           getAsmVOP3DPP8<getAsmVOP3Base<3, 1, HasClamp, 1,
578                                          HasOMod, 0, 1, HasSrc0FloatMods,
579                                          HasSrc1FloatMods,
580                                          HasSrc2FloatMods>.ret>.ret);
581}
582
583def IsPow2Plus1: PatLeaf<(i32 imm), [{
584  uint32_t V = N->getZExtValue();
585  return isPowerOf2_32(V - 1);
586}]>;
587
588def Log2_32: SDNodeXForm<imm, [{
589  uint32_t V = N->getZExtValue();
590  return CurDAG->getTargetConstant(Log2_32(V - 1), SDLoc(N), MVT::i32);
591}]>;
592
593let SubtargetPredicate = isGFX9Plus in {
594let isCommutable = 1, isReMaterializable = 1 in {
595  defm V_ADD3_U32 : VOP3Inst <"v_add3_u32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
596  defm V_AND_OR_B32 : VOP3Inst <"v_and_or_b32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
597  defm V_OR3_B32 : VOP3Inst <"v_or3_b32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
598  defm V_XAD_U32 : VOP3Inst <"v_xad_u32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
599  defm V_ADD_I32 : VOP3Inst <"v_add_i32", VOP3_Profile<VOP_I32_I32_I32_ARITH>>;
600  defm V_ADD_LSHL_U32 : VOP3Inst <"v_add_lshl_u32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
601} // End isCommutable = 1, isReMaterializable = 1
602// TODO src0 contains the opsel bit for dst, so if we commute, need to mask and swap this
603// to the new src0.
604defm V_MED3_F16 : VOP3Inst <"v_med3_f16", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>, AMDGPUfmed3>;
605defm V_MED3_I16 : VOP3Inst <"v_med3_i16", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_OPSEL>, AMDGPUsmed3>;
606defm V_MED3_U16 : VOP3Inst <"v_med3_u16", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_OPSEL>, AMDGPUumed3>;
607
608defm V_MIN3_F16 : VOP3Inst <"v_min3_f16", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>, AMDGPUfmin3>;
609defm V_MIN3_I16 : VOP3Inst <"v_min3_i16", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_OPSEL>, AMDGPUsmin3>;
610defm V_MIN3_U16 : VOP3Inst <"v_min3_u16", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_OPSEL>, AMDGPUumin3>;
611
612defm V_MAX3_F16 : VOP3Inst <"v_max3_f16", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>, AMDGPUfmax3>;
613defm V_MAX3_I16 : VOP3Inst <"v_max3_i16", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_OPSEL>, AMDGPUsmax3>;
614defm V_MAX3_U16 : VOP3Inst <"v_max3_u16", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_OPSEL>, AMDGPUumax3>;
615
616let SubtargetPredicate = isGFX12Plus, ReadsModeReg = 0 in {
617  defm V_MINIMUM3_F16 : VOP3Inst <"v_minimum3_f16", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>, AMDGPUfminimum3>;
618  defm V_MAXIMUM3_F16 : VOP3Inst <"v_maximum3_f16", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>, AMDGPUfmaximum3>;
619} // End SubtargetPredicate = isGFX12Plus, ReadsModeReg = 0
620
621defm V_ADD_I16 : VOP3Inst <"v_add_i16", VOP3_Profile<VOP_I16_I16_I16, VOP3_OPSEL>>;
622defm V_SUB_I16 : VOP3Inst <"v_sub_i16", VOP3_Profile<VOP_I16_I16_I16, VOP3_OPSEL>>;
623
624defm V_MAD_U32_U16 : VOP3Inst <"v_mad_u32_u16", VOP3_Profile<VOP_I32_I16_I16_I32, VOP3_OPSEL>>;
625defm V_MAD_I32_I16 : VOP3Inst <"v_mad_i32_i16", VOP3_Profile<VOP_I32_I16_I16_I32, VOP3_OPSEL>>;
626
627defm V_CVT_PKNORM_I16_F16 : VOP3Inst <"v_cvt_pknorm_i16_f16", VOP3_Profile<VOP_B32_F16_F16, VOP3_OPSEL>>;
628defm V_CVT_PKNORM_U16_F16 : VOP3Inst <"v_cvt_pknorm_u16_f16", VOP3_Profile<VOP_B32_F16_F16, VOP3_OPSEL>>;
629
630defm V_PACK_B32_F16 : VOP3Inst <"v_pack_b32_f16", VOP3_Profile<VOP_B32_F16_F16, VOP3_OPSEL>>;
631
632let isReMaterializable = 1 in {
633defm V_SUB_I32 : VOP3Inst <"v_sub_i32", VOP3_Profile<VOP_I32_I32_I32_ARITH>>;
634defm V_LSHL_ADD_U32 : VOP3Inst <"v_lshl_add_u32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
635defm V_LSHL_OR_B32 : VOP3Inst <"v_lshl_or_b32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
636} // End isReMaterializable = 1
637
638// V_LSHL_ADD_U64: D0.u64 = (S0.u64 << S1.u[2:0]) + S2.u64
639// src0 is shifted left by 0-4 (use “0” to get ADD_U64).
640let SubtargetPredicate = isGFX940Plus in
641defm V_LSHL_ADD_U64 : VOP3Inst <"v_lshl_add_u64", VOP3_Profile<VOP_I64_I64_I32_I64>>;
642
643let SubtargetPredicate = HasFP8ConversionInsts, mayRaiseFPException = 0,
644    SchedRW = [WriteFloatCvt] in {
645  let Constraints = "$vdst = $vdst_in", DisableEncoding = "$vdst_in" in {
646    defm V_CVT_PK_FP8_F32 : VOP3Inst<"v_cvt_pk_fp8_f32", VOP3_CVT_PK_F8_F32_Profile>;
647    defm V_CVT_PK_BF8_F32 : VOP3Inst<"v_cvt_pk_bf8_f32", VOP3_CVT_PK_F8_F32_Profile>;
648  }
649
650  // These instructions have non-standard use of op_sel. In particular they are
651  // using op_sel bits 2 and 3 while only having two sources. Therefore dummy
652  // src2 is used to hold the op_sel value.
653  let Constraints = "$vdst = $src2", DisableEncoding = "$src2" in {
654    defm V_CVT_SR_FP8_F32 : VOP3Inst<"v_cvt_sr_fp8_f32", VOP3_CVT_SR_F8_F32_Profile>;
655    defm V_CVT_SR_BF8_F32 : VOP3Inst<"v_cvt_sr_bf8_f32", VOP3_CVT_SR_F8_F32_Profile>;
656  }
657}
658
659class Cvt_PK_F8_F32_Pat<SDPatternOperator node, int index, VOP3_Pseudo inst> : GCNPat<
660    (i32 (node f32:$src0, f32:$src1, i32:$old, index)),
661    (inst !if(index, SRCMODS.DST_OP_SEL, 0), $src0, 0, $src1, $old, 0)
662>;
663
664class Cvt_SR_F8_F32_Pat<SDPatternOperator node, bits<2> index, VOP3_Pseudo inst> : GCNPat<
665    (i32 (node f32:$src0, i32:$src1, i32:$old, index)),
666    (inst !if(index{1}, SRCMODS.DST_OP_SEL, 0), $src0, 0, $src1,
667          !if(index{0}, SRCMODS.OP_SEL_0, 0), $old, 0)
668>;
669
670foreach Index = [0, -1] in {
671  def : Cvt_PK_F8_F32_Pat<int_amdgcn_cvt_pk_fp8_f32, Index, V_CVT_PK_FP8_F32_e64>;
672  def : Cvt_PK_F8_F32_Pat<int_amdgcn_cvt_pk_bf8_f32, Index, V_CVT_PK_BF8_F32_e64>;
673}
674
675foreach Index = [0, 1, 2, 3] in {
676  def : Cvt_SR_F8_F32_Pat<int_amdgcn_cvt_sr_fp8_f32, Index, V_CVT_SR_FP8_F32_e64>;
677  def : Cvt_SR_F8_F32_Pat<int_amdgcn_cvt_sr_bf8_f32, Index, V_CVT_SR_BF8_F32_e64>;
678}
679
680class ThreeOp_i32_Pats <SDPatternOperator op1, SDPatternOperator op2, Instruction inst> : GCNPat <
681  // This matches (op2 (op1 i32:$src0, i32:$src1), i32:$src2) with conditions.
682  (ThreeOpFrag<op1, op2> i32:$src0, i32:$src1, i32:$src2),
683  (inst VSrc_b32:$src0, VSrc_b32:$src1, VSrc_b32:$src2)
684>;
685
686def : ThreeOp_i32_Pats<cshl_32, add, V_LSHL_ADD_U32_e64>;
687def : ThreeOp_i32_Pats<add, cshl_32, V_ADD_LSHL_U32_e64>;
688def : ThreeOp_i32_Pats<add, add, V_ADD3_U32_e64>;
689def : ThreeOp_i32_Pats<ptradd, ptradd, V_ADD3_U32_e64>;
690def : ThreeOp_i32_Pats<cshl_32, or, V_LSHL_OR_B32_e64>;
691def : ThreeOp_i32_Pats<and, or, V_AND_OR_B32_e64>;
692def : ThreeOp_i32_Pats<or, or, V_OR3_B32_e64>;
693def : ThreeOp_i32_Pats<xor, add, V_XAD_U32_e64>;
694
695def : GCNPat<
696 (DivergentBinFrag<mul> i32:$src0, IsPow2Plus1:$src1),
697 (V_LSHL_ADD_U32_e64 i32:$src0, (i32 (Log2_32 imm:$src1)), i32:$src0)>;
698
699let SubtargetPredicate = isGFX940Plus in
700def : GCNPat<
701  (ThreeOpFrag<shl_0_to_4, add> i64:$src0, i32:$src1, i64:$src2),
702  (V_LSHL_ADD_U64_e64 VSrc_b64:$src0, VSrc_b32:$src1, VSrc_b64:$src2)
703>;
704
705def : VOPBinOpClampPat<saddsat, V_ADD_I32_e64, i32>;
706def : VOPBinOpClampPat<ssubsat, V_SUB_I32_e64, i32>;
707
708def : GCNPat<(DivergentBinFrag<or> (or_oneuse i64:$src0, i64:$src1), i64:$src2),
709             (REG_SEQUENCE VReg_64,
710               (V_OR3_B32_e64 (i32 (EXTRACT_SUBREG $src0, sub0)),
711                              (i32 (EXTRACT_SUBREG $src1, sub0)),
712                              (i32 (EXTRACT_SUBREG $src2, sub0))), sub0,
713               (V_OR3_B32_e64 (i32 (EXTRACT_SUBREG $src0, sub1)),
714                              (i32 (EXTRACT_SUBREG $src1, sub1)),
715                              (i32 (EXTRACT_SUBREG $src2, sub1))), sub1)>;
716
717// FIXME: Probably should hardcode clamp bit in pseudo and avoid this.
718class OpSelBinOpClampPat<SDPatternOperator node,
719                         Instruction inst> : GCNPat<
720 (node (i16 (VOP3OpSel i16:$src0, i32:$src0_modifiers)),
721       (i16 (VOP3OpSel i16:$src1, i32:$src1_modifiers))),
722  (inst $src0_modifiers, $src0, $src1_modifiers, $src1, DSTCLAMP.ENABLE, 0)
723>;
724
725def : OpSelBinOpClampPat<saddsat, V_ADD_I16_e64>;
726def : OpSelBinOpClampPat<ssubsat, V_SUB_I16_e64>;
727} // End SubtargetPredicate = isGFX9Plus
728
729// FIXME: GlobalISel in general does not handle instructions with 2 results,
730// so it cannot use these patterns.
731multiclass IMAD32_Pats <VOP3_Pseudo inst> {
732  def : GCNPat <
733        (ThreeOpFrag<mul, add> i32:$src0, i32:$src1, i32:$src2),
734        (EXTRACT_SUBREG (inst $src0, $src1,
735                              (REG_SEQUENCE SReg_64, // Use scalar and let it be legalized
736                                            $src2, sub0,
737                                            (i32 (IMPLICIT_DEF)), sub1),
738                                            0 /* clamp */),
739                        sub0)
740        >;
741  // Immediate src2 in the pattern above will not fold because it would be partially
742  // undef. Hence define specialized pattern for this case.
743  // FIXME: GlobalISel pattern exporter fails to export a pattern like this and asserts,
744  // make it SDAG only.
745  def : GCNPat <
746        (ThreeOpFragSDAG<mul, add> i32:$src0, i32:$src1, (i32 imm:$src2)),
747        (EXTRACT_SUBREG (inst $src0, $src1, (i64 (as_i64imm $src2)), 0 /* clamp */), sub0)
748        >;
749}
750
751// Handle cases where amdgpu-codegenprepare-mul24 made a mul24 instead of a normal mul.
752// We need to separate this because otherwise OtherPredicates would be overriden.
753class IMAD32_Mul24_Pat<VOP3_Pseudo inst>: GCNPat <
754    (i64 (add (i64 (AMDGPUmul_u24 i32:$src0, i32:$src1)), i64:$src2)),
755    (inst $src0, $src1, $src2, 0 /* clamp */)
756    >;
757
758// exclude pre-GFX9 where it was slow
759let OtherPredicates = [HasNotMADIntraFwdBug], SubtargetPredicate = isGFX9Plus in {
760  defm : IMAD32_Pats<V_MAD_U64_U32_e64>;
761  def : IMAD32_Mul24_Pat<V_MAD_U64_U32_e64>;
762}
763let OtherPredicates = [HasMADIntraFwdBug], SubtargetPredicate = isGFX11Only in {
764  defm : IMAD32_Pats<V_MAD_U64_U32_gfx11_e64>;
765  def : IMAD32_Mul24_Pat<V_MAD_U64_U32_gfx11_e64>;
766}
767
768def VOP3_PERMLANE_Profile : VOP3_Profile<VOPProfile <[i32, i32, i32, i32]>, VOP3_OPSEL> {
769  let InsVOP3OpSel = (ins IntOpSelMods:$src0_modifiers, VRegSrc_32:$src0,
770                          IntOpSelMods:$src1_modifiers, SSrc_b32:$src1,
771                          IntOpSelMods:$src2_modifiers, SSrc_b32:$src2,
772                          VGPR_32:$vdst_in, op_sel0:$op_sel);
773  let HasClamp = 0;
774  let HasExtVOP3DPP = 0;
775  let HasExtDPP = 0;
776}
777
778def VOP3_PERMLANE_VAR_Profile : VOP3_Profile<VOPProfile <[i32, i32, i32, untyped]>, VOP3_OPSEL> {
779  let InsVOP3OpSel = (ins IntOpSelMods:$src0_modifiers, VRegSrc_32:$src0,
780                          IntOpSelMods:$src1_modifiers, VRegSrc_32:$src1,
781                          VGPR_32:$vdst_in, op_sel0:$op_sel);
782  let HasClamp = 0;
783  let HasExtVOP3DPP = 0;
784  let HasExtDPP = 0;
785}
786
787def opsel_i1timm : SDNodeXForm<timm, [{
788  return CurDAG->getTargetConstant(
789      N->getZExtValue() ? SISrcMods::OP_SEL_0 : SISrcMods::NONE,
790      SDLoc(N), MVT::i32);
791}]>;
792def gi_opsel_i1timm : GICustomOperandRenderer<"renderOpSelTImm">,
793  GISDNodeXFormEquiv<opsel_i1timm>;
794
795class PermlanePat<SDPatternOperator permlane,
796  Instruction inst> : GCNPat<
797  (permlane i32:$vdst_in, i32:$src0, i32:$src1, i32:$src2,
798            timm:$fi, timm:$bc),
799  (inst (opsel_i1timm $fi), VGPR_32:$src0, (opsel_i1timm $bc),
800        SCSrc_b32:$src1, 0, SCSrc_b32:$src2, VGPR_32:$vdst_in)
801>;
802
803class PermlaneVarPat<SDPatternOperator permlane,
804  Instruction inst> : GCNPat<
805  (permlane i32:$vdst_in, i32:$src0, i32:$src1,
806            timm:$fi, timm:$bc),
807  (inst (opsel_i1timm $fi), VGPR_32:$src0, (opsel_i1timm $bc),
808        VGPR_32:$src1, VGPR_32:$vdst_in)
809>;
810
811let SubtargetPredicate = isGFX10Plus in {
812  let isCommutable = 1, isReMaterializable = 1 in {
813    defm V_XOR3_B32 : VOP3Inst <"v_xor3_b32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
814  } // End isCommutable = 1, isReMaterializable = 1
815  def : ThreeOp_i32_Pats<xor, xor, V_XOR3_B32_e64>;
816
817  let Constraints = "$vdst = $vdst_in", DisableEncoding="$vdst_in" in {
818    defm V_PERMLANE16_B32 : VOP3Inst<"v_permlane16_b32", VOP3_PERMLANE_Profile>;
819    defm V_PERMLANEX16_B32 : VOP3Inst<"v_permlanex16_b32", VOP3_PERMLANE_Profile>;
820  } // End $vdst = $vdst_in, DisableEncoding $vdst_in
821
822  def : PermlanePat<int_amdgcn_permlane16, V_PERMLANE16_B32_e64>;
823  def : PermlanePat<int_amdgcn_permlanex16, V_PERMLANEX16_B32_e64>;
824
825  defm V_ADD_NC_U16 : VOP3Inst <"v_add_nc_u16", VOP3_Profile<VOP_I16_I16_I16, VOP3_OPSEL>, add>;
826  defm V_SUB_NC_U16 : VOP3Inst <"v_sub_nc_u16", VOP3_Profile<VOP_I16_I16_I16, VOP3_OPSEL>, sub>;
827
828  def : OpSelBinOpClampPat<uaddsat, V_ADD_NC_U16_e64>;
829  def : OpSelBinOpClampPat<usubsat, V_SUB_NC_U16_e64>;
830
831  // Undo sub x, c -> add x, -c canonicalization since c is more likely
832  // an inline immediate than -c.
833  def : GCNPat<
834    (add i16:$src0, (i16 NegSubInlineIntConst16:$src1)),
835    (V_SUB_NC_U16_e64 0, VSrc_b16:$src0, 0, NegSubInlineIntConst16:$src1, 0, 0)
836  >;
837
838} // End SubtargetPredicate = isGFX10Plus
839
840let SubtargetPredicate = isGFX12Plus in {
841  let Constraints = "$vdst = $vdst_in", DisableEncoding="$vdst_in" in {
842    defm V_PERMLANE16_VAR_B32  : VOP3Inst<"v_permlane16_var_b32",  VOP3_PERMLANE_VAR_Profile>;
843    defm V_PERMLANEX16_VAR_B32 : VOP3Inst<"v_permlanex16_var_b32", VOP3_PERMLANE_VAR_Profile>;
844  } // End $vdst = $vdst_in, DisableEncoding $vdst_in
845
846  def : PermlaneVarPat<int_amdgcn_permlane16_var,  V_PERMLANE16_VAR_B32_e64>;
847  def : PermlaneVarPat<int_amdgcn_permlanex16_var, V_PERMLANEX16_VAR_B32_e64>;
848
849} // End SubtargetPredicate = isGFX12Plus
850
851class DivFmasPat<ValueType vt, Instruction inst, Register CondReg> : GCNPat<
852  (AMDGPUdiv_fmas (vt (VOP3Mods vt:$src0, i32:$src0_modifiers)),
853                  (vt (VOP3Mods vt:$src1, i32:$src1_modifiers)),
854                  (vt (VOP3Mods vt:$src2, i32:$src2_modifiers)),
855                  (i1 CondReg)),
856  (inst $src0_modifiers, $src0, $src1_modifiers, $src1, $src2_modifiers, $src2)
857>;
858
859let WaveSizePredicate = isWave64 in {
860def : DivFmasPat<f32, V_DIV_FMAS_F32_e64, VCC>;
861def : DivFmasPat<f64, V_DIV_FMAS_F64_e64, VCC>;
862}
863
864let WaveSizePredicate = isWave32 in {
865def : DivFmasPat<f32, V_DIV_FMAS_F32_e64, VCC_LO>;
866def : DivFmasPat<f64, V_DIV_FMAS_F64_e64, VCC_LO>;
867}
868
869class VOP3_DOT_Profile<VOPProfile P, VOP3Features Features = VOP3_REGULAR> : VOP3_Profile<P, Features> {
870  let HasClamp = 0;
871  let HasOMod = 0;
872  // Override modifiers for bf16(i16) (same as float modifiers).
873  let HasSrc0Mods = 1;
874  let HasSrc1Mods = 1;
875  let HasSrc2Mods = 1;
876  let Src0ModVOP3DPP = FPVRegInputMods;
877  let Src1ModVOP3DPP = FPVRegInputMods;
878  let Src2ModVOP3DPP = FP16InputMods;
879  let InsVOP3OpSel = getInsVOP3OpSel<Src0RC64, Src1RC64, Src2RC64, NumSrcArgs,
880                                     HasClamp, HasOMod, FP16InputMods,
881                                     FP16InputMods, FP16InputMods>.ret;
882  let AsmVOP3OpSel = getAsmVOP3OpSel<NumSrcArgs, HasClamp, HasOMod, 1, 1, 1>.ret;
883}
884
885let SubtargetPredicate = isGFX11Plus in {
886  defm V_MAXMIN_F32     : VOP3Inst<"v_maxmin_f32", VOP3_Profile<VOP_F32_F32_F32_F32>>;
887  defm V_MINMAX_F32     : VOP3Inst<"v_minmax_f32", VOP3_Profile<VOP_F32_F32_F32_F32>>;
888  defm V_MAXMIN_F16     : VOP3Inst<"v_maxmin_f16", VOP3_Profile<VOP_F16_F16_F16_F16>>;
889  defm V_MINMAX_F16     : VOP3Inst<"v_minmax_f16", VOP3_Profile<VOP_F16_F16_F16_F16>>;
890  defm V_MAXMIN_U32     : VOP3Inst<"v_maxmin_u32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
891  defm V_MINMAX_U32     : VOP3Inst<"v_minmax_u32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
892  defm V_MAXMIN_I32     : VOP3Inst<"v_maxmin_i32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
893  defm V_MINMAX_I32     : VOP3Inst<"v_minmax_i32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
894  defm V_CVT_PK_I16_F32 : VOP3Inst<"v_cvt_pk_i16_f32", VOP3_Profile<VOP_V2I16_F32_F32>>;
895  defm V_CVT_PK_U16_F32 : VOP3Inst<"v_cvt_pk_u16_f32", VOP3_Profile<VOP_V2I16_F32_F32>>;
896} // End SubtargetPredicate = isGFX11Plus
897
898let SubtargetPredicate = isGFX12Plus, ReadsModeReg = 0 in {
899  defm V_MAXIMUMMINIMUM_F32 : VOP3Inst<"v_maximumminimum_f32", VOP3_Profile<VOP_F32_F32_F32_F32>>;
900  defm V_MINIMUMMAXIMUM_F32 : VOP3Inst<"v_minimummaximum_f32", VOP3_Profile<VOP_F32_F32_F32_F32>>;
901  defm V_MAXIMUMMINIMUM_F16 : VOP3Inst<"v_maximumminimum_f16", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>>;
902  defm V_MINIMUMMAXIMUM_F16 : VOP3Inst<"v_minimummaximum_f16", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>>;
903} // End SubtargetPredicate = isGFX12Plus, ReadsModeReg = 0
904
905let SubtargetPredicate = HasDot9Insts, IsDOT=1 in {
906  defm V_DOT2_F16_F16 :   VOP3Inst<"v_dot2_f16_f16",   VOP3_DOT_Profile<VOP_F16_V2F16_V2F16_F16>, int_amdgcn_fdot2_f16_f16>;
907  defm V_DOT2_BF16_BF16 : VOP3Inst<"v_dot2_bf16_bf16", VOP3_DOT_Profile<VOP_I16_V2I16_V2I16_I16>, int_amdgcn_fdot2_bf16_bf16>;
908}
909
910class VOP_Pseudo_Scalar<RegisterClass Dst, RegisterOperand SrcOp,
911                        ValueType dstVt, ValueType srcVt = dstVt>
912    : VOPProfile<[dstVt, srcVt, untyped, untyped]> {
913  let DstRC = VOPDstOperand<Dst>;
914  let Src0RC64 = SrcOp;
915
916  let HasOMod = 1;
917  let HasModifiers = 1;
918}
919
920def VOP_Pseudo_Scalar_F32 : VOP_Pseudo_Scalar<SReg_32_XEXEC, SSrc_f32, f32>;
921def VOP_Pseudo_Scalar_F16 : VOP_Pseudo_Scalar<SReg_32_XEXEC, SSrc_f16, f32, f16>;
922
923let SubtargetPredicate = HasPseudoScalarTrans, TRANS = 1,
924    isReMaterializable = 1, SchedRW = [WritePseudoScalarTrans] in {
925  defm V_S_EXP_F32  : VOP3PseudoScalarInst<"v_s_exp_f32", VOP_Pseudo_Scalar_F32, AMDGPUexp>;
926  defm V_S_EXP_F16  : VOP3PseudoScalarInst<"v_s_exp_f16", VOP_Pseudo_Scalar_F16>;
927  defm V_S_LOG_F32  : VOP3PseudoScalarInst<"v_s_log_f32", VOP_Pseudo_Scalar_F32, AMDGPUlog>;
928  defm V_S_LOG_F16  : VOP3PseudoScalarInst<"v_s_log_f16", VOP_Pseudo_Scalar_F16>;
929  defm V_S_RCP_F32  : VOP3PseudoScalarInst<"v_s_rcp_f32", VOP_Pseudo_Scalar_F32, AMDGPUrcp>;
930  defm V_S_RCP_F16  : VOP3PseudoScalarInst<"v_s_rcp_f16", VOP_Pseudo_Scalar_F16>;
931  defm V_S_RSQ_F32  : VOP3PseudoScalarInst<"v_s_rsq_f32", VOP_Pseudo_Scalar_F32, AMDGPUrsq>;
932  defm V_S_RSQ_F16  : VOP3PseudoScalarInst<"v_s_rsq_f16", VOP_Pseudo_Scalar_F16>;
933  defm V_S_SQRT_F32 : VOP3PseudoScalarInst<"v_s_sqrt_f32", VOP_Pseudo_Scalar_F32, any_amdgcn_sqrt>;
934  defm V_S_SQRT_F16 : VOP3PseudoScalarInst<"v_s_sqrt_f16", VOP_Pseudo_Scalar_F16>;
935}
936
937class PseudoScalarPatF16<SDPatternOperator node, VOP3_Pseudo inst> : GCNPat <
938  (f16 (UniformUnaryFrag<node> (f16 (VOP3Mods0 f16:$src0, i32:$src0_modifiers,
939                                               i1:$clamp, i32:$omod)))),
940  (f16 (COPY_TO_REGCLASS (f32 (inst i32:$src0_modifiers, f16:$src0, i1:$clamp,
941                                    i32:$omod)),
942                         SReg_32_XEXEC))
943>;
944
945let SubtargetPredicate = HasPseudoScalarTrans in {
946  def : PseudoScalarPatF16<AMDGPUexpf16, V_S_EXP_F16_e64>;
947  def : PseudoScalarPatF16<AMDGPUlogf16, V_S_LOG_F16_e64>;
948  def : PseudoScalarPatF16<AMDGPUrcp, V_S_RCP_F16_e64>;
949  def : PseudoScalarPatF16<AMDGPUrsq, V_S_RSQ_F16_e64>;
950  def : PseudoScalarPatF16<any_amdgcn_sqrt, V_S_SQRT_F16_e64>;
951}
952
953//===----------------------------------------------------------------------===//
954// Integer Clamp Patterns
955//===----------------------------------------------------------------------===//
956
957class getClampPat<VOPProfile P, SDPatternOperator node> {
958  dag ret3 = (P.DstVT (node P.Src0VT:$src0, P.Src1VT:$src1, P.Src2VT:$src2));
959  dag ret2 = (P.DstVT (node P.Src0VT:$src0, P.Src1VT:$src1));
960  dag ret1 = (P.DstVT (node P.Src0VT:$src0));
961  dag ret = !if(!eq(P.NumSrcArgs, 3), ret3,
962            !if(!eq(P.NumSrcArgs, 2), ret2,
963            ret1));
964}
965
966class getClampRes<VOPProfile P, Instruction inst> {
967  dag ret3 = (inst P.Src0VT:$src0, P.Src1VT:$src1, P.Src2VT:$src2, (i1 0));
968  dag ret2 = (inst P.Src0VT:$src0, P.Src1VT:$src1, (i1 0));
969  dag ret1 = (inst P.Src0VT:$src0, (i1 0));
970  dag ret = !if(!eq(P.NumSrcArgs, 3), ret3,
971            !if(!eq(P.NumSrcArgs, 2), ret2,
972            ret1));
973}
974
975class IntClampPat<VOP3InstBase inst, SDPatternOperator node> : GCNPat<
976  getClampPat<inst.Pfl, node>.ret,
977  getClampRes<inst.Pfl, inst>.ret
978>;
979
980def : IntClampPat<V_MAD_I32_I24_e64, AMDGPUmad_i24>;
981def : IntClampPat<V_MAD_U32_U24_e64, AMDGPUmad_u24>;
982
983def : IntClampPat<V_SAD_U8_e64, int_amdgcn_sad_u8>;
984def : IntClampPat<V_SAD_HI_U8_e64, int_amdgcn_sad_hi_u8>;
985def : IntClampPat<V_SAD_U16_e64, int_amdgcn_sad_u16>;
986
987def : IntClampPat<V_MSAD_U8_e64, int_amdgcn_msad_u8>;
988def : IntClampPat<V_MQSAD_PK_U16_U8_e64, int_amdgcn_mqsad_pk_u16_u8>;
989
990def : IntClampPat<V_QSAD_PK_U16_U8_e64, int_amdgcn_qsad_pk_u16_u8>;
991def : IntClampPat<V_MQSAD_U32_U8_e64, int_amdgcn_mqsad_u32_u8>;
992
993//===----------------------------------------------------------------------===//
994// Target-specific instruction encodings.
995//===----------------------------------------------------------------------===//
996
997//===----------------------------------------------------------------------===//
998// GFX12.
999//===----------------------------------------------------------------------===//
1000
1001defm V_MIN3_NUM_F32       : VOP3_Realtriple_with_name_gfx12<0x229, "V_MIN3_F32", "v_min3_num_f32">;
1002defm V_MAX3_NUM_F32       : VOP3_Realtriple_with_name_gfx12<0x22a, "V_MAX3_F32", "v_max3_num_f32">;
1003defm V_MIN3_NUM_F16       : VOP3_Realtriple_with_name_gfx12<0x22b, "V_MIN3_F16", "v_min3_num_f16">;
1004defm V_MAX3_NUM_F16       : VOP3_Realtriple_with_name_gfx12<0x22c, "V_MAX3_F16", "v_max3_num_f16">;
1005defm V_MINIMUM3_F32       : VOP3Only_Realtriple_gfx12<0x22d>;
1006defm V_MAXIMUM3_F32       : VOP3Only_Realtriple_gfx12<0x22e>;
1007defm V_MINIMUM3_F16       : VOP3Only_Realtriple_t16_gfx12<0x22f>;
1008defm V_MAXIMUM3_F16       : VOP3Only_Realtriple_t16_gfx12<0x230>;
1009defm V_MED3_NUM_F32       : VOP3_Realtriple_with_name_gfx12<0x231, "V_MED3_F32", "v_med3_num_f32">;
1010defm V_MED3_NUM_F16       : VOP3_Realtriple_with_name_gfx12<0x232, "V_MED3_F16", "v_med3_num_f16">;
1011defm V_MINMAX_NUM_F32     : VOP3_Realtriple_with_name_gfx12<0x268, "V_MINMAX_F32", "v_minmax_num_f32">;
1012defm V_MAXMIN_NUM_F32     : VOP3_Realtriple_with_name_gfx12<0x269, "V_MAXMIN_F32", "v_maxmin_num_f32">;
1013defm V_MINMAX_NUM_F16     : VOP3_Realtriple_with_name_gfx12<0x26a, "V_MINMAX_F16", "v_minmax_num_f16">;
1014defm V_MAXMIN_NUM_F16     : VOP3_Realtriple_with_name_gfx12<0x26b, "V_MAXMIN_F16", "v_maxmin_num_f16">;
1015defm V_MINIMUMMAXIMUM_F32 : VOP3Only_Realtriple_gfx12<0x26c>;
1016defm V_MAXIMUMMINIMUM_F32 : VOP3Only_Realtriple_gfx12<0x26d>;
1017defm V_MINIMUMMAXIMUM_F16 : VOP3Only_Realtriple_t16_gfx12<0x26e>;
1018defm V_MAXIMUMMINIMUM_F16 : VOP3Only_Realtriple_t16_gfx12<0x26f>;
1019defm V_S_EXP_F32          : VOP3Only_Real_Base_gfx12<0x280>;
1020defm V_S_EXP_F16          : VOP3Only_Real_Base_gfx12<0x281>;
1021defm V_S_LOG_F32          : VOP3Only_Real_Base_gfx12<0x282>;
1022defm V_S_LOG_F16          : VOP3Only_Real_Base_gfx12<0x283>;
1023defm V_S_RCP_F32          : VOP3Only_Real_Base_gfx12<0x284>;
1024defm V_S_RCP_F16          : VOP3Only_Real_Base_gfx12<0x285>;
1025defm V_S_RSQ_F32          : VOP3Only_Real_Base_gfx12<0x286>;
1026defm V_S_RSQ_F16          : VOP3Only_Real_Base_gfx12<0x287>;
1027defm V_S_SQRT_F32         : VOP3Only_Real_Base_gfx12<0x288>;
1028defm V_S_SQRT_F16         : VOP3Only_Real_Base_gfx12<0x289>;
1029defm V_MAD_CO_U64_U32     : VOP3be_Real_with_name_gfx12<0x2fe, "V_MAD_U64_U32", "v_mad_co_u64_u32">;
1030defm V_MAD_CO_I64_I32     : VOP3be_Real_with_name_gfx12<0x2ff, "V_MAD_I64_I32", "v_mad_co_i64_i32">;
1031defm V_MINIMUM_F64        : VOP3Only_Real_Base_gfx12<0x341>;
1032defm V_MAXIMUM_F64        : VOP3Only_Real_Base_gfx12<0x342>;
1033defm V_MINIMUM_F32        : VOP3Only_Realtriple_gfx12<0x365>;
1034defm V_MAXIMUM_F32        : VOP3Only_Realtriple_gfx12<0x366>;
1035defm V_MINIMUM_F16        : VOP3Only_Realtriple_t16_gfx12<0x367>;
1036defm V_MAXIMUM_F16        : VOP3Only_Realtriple_t16_gfx12<0x368>;
1037
1038defm V_PERMLANE16_VAR_B32  : VOP3Only_Real_Base_gfx12<0x30f>;
1039defm V_PERMLANEX16_VAR_B32 : VOP3Only_Real_Base_gfx12<0x310>;
1040
1041defm V_CVT_PK_FP8_F32  : VOP3Only_Realtriple_gfx12<0x369>;
1042defm V_CVT_PK_BF8_F32  : VOP3Only_Realtriple_gfx12<0x36a>;
1043defm V_CVT_SR_FP8_F32  : VOP3Only_Realtriple_gfx12<0x36b>;
1044defm V_CVT_SR_BF8_F32  : VOP3Only_Realtriple_gfx12<0x36c>;
1045
1046//===----------------------------------------------------------------------===//
1047// GFX11, GFX12
1048//===----------------------------------------------------------------------===//
1049
1050multiclass VOP3_Real_with_name_gfx11_gfx12<bits<10> op, string opName,
1051                                           string asmName> :
1052  VOP3_Real_with_name<GFX11Gen, op, opName, asmName>,
1053  VOP3_Real_with_name<GFX12Gen, op, opName, asmName>;
1054
1055multiclass VOP3_Realtriple_gfx11_gfx12<bits<10> op> :
1056  VOP3_Realtriple<GFX11Gen, op>, VOP3_Realtriple<GFX12Gen, op>;
1057
1058multiclass VOP3_Real_Base_gfx11_gfx12<bits<10> op> :
1059  VOP3_Real_Base<GFX11Gen, op>, VOP3_Real_Base<GFX12Gen, op>;
1060
1061multiclass VOP3_Realtriple_with_name_gfx11_gfx12<bits<10> op, string opName,
1062                                                 string asmName> :
1063  VOP3_Realtriple_with_name<GFX11Gen, op, opName, asmName>,
1064  VOP3_Realtriple_with_name<GFX12Gen, op, opName, asmName>;
1065
1066multiclass VOP3Dot_Realtriple_gfx11_gfx12<bits<10> op> :
1067  VOP3Dot_Realtriple<GFX11Gen, op>, VOP3Dot_Realtriple<GFX12Gen, op>;
1068
1069multiclass VOP3be_Real_gfx11_gfx12<bits<10> op, string opName, string asmName> :
1070  VOP3be_Real<GFX11Gen, op, opName, asmName>,
1071  VOP3be_Real<GFX12Gen, op, opName, asmName>;
1072
1073multiclass VOP3_Real_No_Suffix_gfx11_gfx12<bits<10> op> :
1074  VOP3_Real_No_Suffix<GFX11Gen, op>, VOP3_Real_No_Suffix<GFX12Gen, op>;
1075
1076defm V_FMA_DX9_ZERO_F32    : VOP3_Real_with_name_gfx11_gfx12<0x209, "V_FMA_LEGACY_F32", "v_fma_dx9_zero_f32">;
1077defm V_MAD_I32_I24         : VOP3_Realtriple_gfx11_gfx12<0x20a>;
1078defm V_MAD_U32_U24         : VOP3_Realtriple_gfx11_gfx12<0x20b>;
1079defm V_CUBEID_F32          : VOP3_Realtriple_gfx11_gfx12<0x20c>;
1080defm V_CUBESC_F32          : VOP3_Realtriple_gfx11_gfx12<0x20d>;
1081defm V_CUBETC_F32          : VOP3_Realtriple_gfx11_gfx12<0x20e>;
1082defm V_CUBEMA_F32          : VOP3_Realtriple_gfx11_gfx12<0x20f>;
1083defm V_BFE_U32             : VOP3_Realtriple_gfx11_gfx12<0x210>;
1084defm V_BFE_I32             : VOP3_Realtriple_gfx11_gfx12<0x211>;
1085defm V_BFI_B32             : VOP3_Realtriple_gfx11_gfx12<0x212>;
1086defm V_FMA_F32             : VOP3_Realtriple_gfx11_gfx12<0x213>;
1087defm V_FMA_F64             : VOP3_Real_Base_gfx11_gfx12<0x214>;
1088defm V_LERP_U8             : VOP3_Realtriple_gfx11_gfx12<0x215>;
1089defm V_ALIGNBIT_B32        : VOP3_Realtriple_gfx11_gfx12<0x216>;
1090defm V_ALIGNBYTE_B32       : VOP3_Realtriple_gfx11_gfx12<0x217>;
1091defm V_MULLIT_F32          : VOP3_Realtriple_gfx11_gfx12<0x218>;
1092defm V_MIN3_F32            : VOP3_Realtriple_gfx11<0x219>;
1093defm V_MIN3_I32            : VOP3_Realtriple_gfx11_gfx12<0x21a>;
1094defm V_MIN3_U32            : VOP3_Realtriple_gfx11_gfx12<0x21b>;
1095defm V_MAX3_F32            : VOP3_Realtriple_gfx11<0x21c>;
1096defm V_MAX3_I32            : VOP3_Realtriple_gfx11_gfx12<0x21d>;
1097defm V_MAX3_U32            : VOP3_Realtriple_gfx11_gfx12<0x21e>;
1098defm V_MED3_F32            : VOP3_Realtriple_gfx11<0x21f>;
1099defm V_MED3_I32            : VOP3_Realtriple_gfx11_gfx12<0x220>;
1100defm V_MED3_U32            : VOP3_Realtriple_gfx11_gfx12<0x221>;
1101defm V_SAD_U8              : VOP3_Realtriple_gfx11_gfx12<0x222>;
1102defm V_SAD_HI_U8           : VOP3_Realtriple_gfx11_gfx12<0x223>;
1103defm V_SAD_U16             : VOP3_Realtriple_gfx11_gfx12<0x224>;
1104defm V_SAD_U32             : VOP3_Realtriple_gfx11_gfx12<0x225>;
1105defm V_CVT_PK_U8_F32       : VOP3_Realtriple_gfx11_gfx12<0x226>;
1106defm V_DIV_FIXUP_F32       : VOP3_Real_Base_gfx11_gfx12<0x227>;
1107defm V_DIV_FIXUP_F64       : VOP3_Real_Base_gfx11_gfx12<0x228>;
1108defm V_DIV_FMAS_F32        : VOP3_Real_Base_gfx11_gfx12<0x237>;
1109defm V_DIV_FMAS_F64        : VOP3_Real_Base_gfx11_gfx12<0x238>;
1110defm V_MSAD_U8             : VOP3_Realtriple_gfx11_gfx12<0x239>;
1111defm V_QSAD_PK_U16_U8      : VOP3_Real_Base_gfx11_gfx12<0x23a>;
1112defm V_MQSAD_PK_U16_U8     : VOP3_Real_Base_gfx11_gfx12<0x23b>;
1113defm V_MQSAD_U32_U8        : VOP3_Real_Base_gfx11_gfx12<0x23d>;
1114defm V_XOR3_B32            : VOP3_Realtriple_gfx11_gfx12<0x240>;
1115defm V_MAD_U16             : VOP3_Realtriple_with_name_gfx11_gfx12<0x241, "V_MAD_U16_gfx9", "v_mad_u16">;
1116defm V_PERM_B32            : VOP3_Realtriple_gfx11_gfx12<0x244>;
1117defm V_XAD_U32             : VOP3_Realtriple_gfx11_gfx12<0x245>;
1118defm V_LSHL_ADD_U32        : VOP3_Realtriple_gfx11_gfx12<0x246>;
1119defm V_ADD_LSHL_U32        : VOP3_Realtriple_gfx11_gfx12<0x247>;
1120defm V_FMA_F16             : VOP3_Realtriple_with_name_gfx11_gfx12<0x248, "V_FMA_F16_gfx9", "v_fma_f16">;
1121defm V_MIN3_F16            : VOP3_Realtriple_gfx11<0x249>;
1122defm V_MIN3_I16            : VOP3_Realtriple_gfx11_gfx12<0x24a>;
1123defm V_MIN3_U16            : VOP3_Realtriple_gfx11_gfx12<0x24b>;
1124defm V_MAX3_F16            : VOP3_Realtriple_gfx11<0x24c>;
1125defm V_MAX3_I16            : VOP3_Realtriple_gfx11_gfx12<0x24d>;
1126defm V_MAX3_U16            : VOP3_Realtriple_gfx11_gfx12<0x24e>;
1127defm V_MED3_F16            : VOP3_Realtriple_gfx11<0x24f>;
1128defm V_MED3_I16            : VOP3_Realtriple_gfx11_gfx12<0x250>;
1129defm V_MED3_U16            : VOP3_Realtriple_gfx11_gfx12<0x251>;
1130defm V_MAD_I16             : VOP3_Realtriple_with_name_gfx11_gfx12<0x253, "V_MAD_I16_gfx9", "v_mad_i16">;
1131defm V_DIV_FIXUP_F16       : VOP3_Realtriple_with_name_gfx11_gfx12<0x254, "V_DIV_FIXUP_F16_gfx9", "v_div_fixup_f16">;
1132defm V_ADD3_U32            : VOP3_Realtriple_gfx11_gfx12<0x255>;
1133defm V_LSHL_OR_B32         : VOP3_Realtriple_gfx11_gfx12<0x256>;
1134defm V_AND_OR_B32          : VOP3_Realtriple_gfx11_gfx12<0x257>;
1135defm V_OR3_B32             : VOP3_Realtriple_gfx11_gfx12<0x258>;
1136defm V_MAD_U32_U16         : VOP3_Realtriple_gfx11_gfx12<0x259>;
1137defm V_MAD_I32_I16         : VOP3_Realtriple_gfx11_gfx12<0x25a>;
1138defm V_PERMLANE16_B32      : VOP3_Real_Base_gfx11_gfx12<0x25b>;
1139defm V_PERMLANEX16_B32     : VOP3_Real_Base_gfx11_gfx12<0x25c>;
1140defm V_MAXMIN_F32          : VOP3_Realtriple_gfx11<0x25e>;
1141defm V_MINMAX_F32          : VOP3_Realtriple_gfx11<0x25f>;
1142defm V_MAXMIN_F16          : VOP3_Realtriple_gfx11<0x260>;
1143defm V_MINMAX_F16          : VOP3_Realtriple_gfx11<0x261>;
1144defm V_MAXMIN_U32          : VOP3_Realtriple_gfx11_gfx12<0x262>;
1145defm V_MINMAX_U32          : VOP3_Realtriple_gfx11_gfx12<0x263>;
1146defm V_MAXMIN_I32          : VOP3_Realtriple_gfx11_gfx12<0x264>;
1147defm V_MINMAX_I32          : VOP3_Realtriple_gfx11_gfx12<0x265>;
1148defm V_DOT2_F16_F16        : VOP3Dot_Realtriple_gfx11_gfx12<0x266>;
1149defm V_DOT2_BF16_BF16      : VOP3Dot_Realtriple_gfx11_gfx12<0x267>;
1150defm V_DIV_SCALE_F32       : VOP3be_Real_gfx11_gfx12<0x2fc, "V_DIV_SCALE_F32", "v_div_scale_f32">;
1151defm V_DIV_SCALE_F64       : VOP3be_Real_gfx11_gfx12<0x2fd, "V_DIV_SCALE_F64", "v_div_scale_f64">;
1152defm V_MAD_U64_U32_gfx11   : VOP3be_Real_gfx11<0x2fe, "V_MAD_U64_U32_gfx11", "v_mad_u64_u32">;
1153defm V_MAD_I64_I32_gfx11   : VOP3be_Real_gfx11<0x2ff, "V_MAD_I64_I32_gfx11", "v_mad_i64_i32">;
1154defm V_ADD_NC_U16          : VOP3Only_Realtriple_gfx11_gfx12<0x303>;
1155defm V_SUB_NC_U16          : VOP3Only_Realtriple_gfx11_gfx12<0x304>;
1156defm V_MUL_LO_U16_t16      : VOP3Only_Realtriple_t16_gfx11_gfx12<0x305, "v_mul_lo_u16">;
1157defm V_CVT_PK_I16_F32      : VOP3_Realtriple_gfx11_gfx12<0x306>;
1158defm V_CVT_PK_U16_F32      : VOP3_Realtriple_gfx11_gfx12<0x307>;
1159defm V_MAX_U16_t16         : VOP3Only_Realtriple_t16_gfx11_gfx12<0x309, "v_max_u16">;
1160defm V_MAX_I16_t16         : VOP3Only_Realtriple_t16_gfx11_gfx12<0x30a, "v_max_i16">;
1161defm V_MIN_U16_t16         : VOP3Only_Realtriple_t16_gfx11_gfx12<0x30b, "v_min_u16">;
1162defm V_MIN_I16_t16         : VOP3Only_Realtriple_t16_gfx11_gfx12<0x30c, "v_min_i16">;
1163defm V_ADD_NC_I16          : VOP3_Realtriple_with_name_gfx11_gfx12<0x30d, "V_ADD_I16", "v_add_nc_i16">;
1164defm V_SUB_NC_I16          : VOP3_Realtriple_with_name_gfx11_gfx12<0x30e, "V_SUB_I16", "v_sub_nc_i16">;
1165defm V_PACK_B32_F16        : VOP3_Realtriple_gfx11_gfx12<0x311>;
1166defm V_CVT_PK_NORM_I16_F16 : VOP3_Realtriple_with_name_gfx11_gfx12<0x312, "V_CVT_PKNORM_I16_F16" , "v_cvt_pk_norm_i16_f16" >;
1167defm V_CVT_PK_NORM_U16_F16 : VOP3_Realtriple_with_name_gfx11_gfx12<0x313, "V_CVT_PKNORM_U16_F16" , "v_cvt_pk_norm_u16_f16" >;
1168defm V_SUB_NC_I32          : VOP3_Realtriple_with_name_gfx11_gfx12<0x325, "V_SUB_I32", "v_sub_nc_i32">;
1169defm V_ADD_NC_I32          : VOP3_Realtriple_with_name_gfx11_gfx12<0x326, "V_ADD_I32", "v_add_nc_i32">;
1170defm V_ADD_F64             : VOP3_Real_Base_gfx11<0x327>;
1171defm V_MUL_F64             : VOP3_Real_Base_gfx11<0x328>;
1172defm V_MIN_F64             : VOP3_Real_Base_gfx11<0x329>;
1173defm V_MAX_F64             : VOP3_Real_Base_gfx11<0x32a>;
1174defm V_LDEXP_F64           : VOP3_Real_Base_gfx11_gfx12<0x32b>;
1175defm V_MUL_LO_U32          : VOP3_Real_Base_gfx11_gfx12<0x32c>;
1176defm V_MUL_HI_U32          : VOP3_Real_Base_gfx11_gfx12<0x32d>;
1177defm V_MUL_HI_I32          : VOP3_Real_Base_gfx11_gfx12<0x32e>;
1178defm V_TRIG_PREOP_F64      : VOP3_Real_Base_gfx11_gfx12<0x32f>;
1179defm V_LSHLREV_B16_t16     : VOP3Only_Realtriple_t16_gfx11_gfx12<0x338, "v_lshlrev_b16">;
1180defm V_LSHRREV_B16_t16     : VOP3Only_Realtriple_t16_gfx11_gfx12<0x339, "v_lshrrev_b16">;
1181defm V_ASHRREV_I16_t16     : VOP3Only_Realtriple_t16_gfx11_gfx12<0x33a, "v_ashrrev_i16">;
1182defm V_LSHLREV_B64         : VOP3_Real_Base_gfx11<0x33c>;
1183defm V_LSHRREV_B64         : VOP3_Real_Base_gfx11_gfx12<0x33d>;
1184defm V_ASHRREV_I64         : VOP3_Real_Base_gfx11_gfx12<0x33e>;
1185defm V_READLANE_B32        : VOP3_Real_No_Suffix_gfx11_gfx12<0x360>; // Pseudo in VOP2
1186let InOperandList = (ins SSrcOrLds_b32:$src0, SCSrc_b32:$src1, VGPR_32:$vdst_in) in {
1187  defm V_WRITELANE_B32     : VOP3_Real_No_Suffix_gfx11_gfx12<0x361>; // Pseudo in VOP2
1188} // End InOperandList = (ins SSrcOrLds_b32:$src0, SCSrc_b32:$src1, VGPR_32:$vdst_in)
1189defm V_AND_B16_t16         : VOP3Only_Realtriple_t16_gfx11_gfx12<0x362, "v_and_b16">;
1190defm V_OR_B16_t16          : VOP3Only_Realtriple_t16_gfx11_gfx12<0x363, "v_or_b16">;
1191defm V_XOR_B16_t16         : VOP3Only_Realtriple_t16_gfx11_gfx12<0x364, "v_xor_b16">;
1192
1193//===----------------------------------------------------------------------===//
1194// GFX10.
1195//===----------------------------------------------------------------------===//
1196
1197let AssemblerPredicate = isGFX10Only, DecoderNamespace = "GFX10" in {
1198  multiclass VOP3_Real_gfx10<bits<10> op> {
1199    def _gfx10 :
1200      VOP3_Real<!cast<VOP_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX10>,
1201      VOP3e_gfx10<op, !cast<VOP_Pseudo>(NAME#"_e64").Pfl>;
1202  }
1203  multiclass VOP3_Real_No_Suffix_gfx10<bits<10> op> {
1204    def _gfx10 :
1205      VOP3_Real<!cast<VOP_Pseudo>(NAME), SIEncodingFamily.GFX10>,
1206      VOP3e_gfx10<op, !cast<VOP_Pseudo>(NAME).Pfl>;
1207  }
1208  multiclass VOP3_Real_gfx10_with_name<bits<10> op, string opName,
1209                                       string asmName> {
1210    def _gfx10 :
1211      VOP3_Real<!cast<VOP3_Pseudo>(opName#"_e64"), SIEncodingFamily.GFX10>,
1212      VOP3e_gfx10<op, !cast<VOP3_Pseudo>(opName#"_e64").Pfl> {
1213        VOP3_Pseudo ps = !cast<VOP3_Pseudo>(opName#"_e64");
1214        let AsmString = asmName # ps.AsmOperands;
1215        let IsSingle = 1;
1216      }
1217  }
1218  multiclass VOP3be_Real_gfx10<bits<10> op> {
1219    def _gfx10 :
1220      VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX10>,
1221      VOP3be_gfx10<op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1222  }
1223  multiclass VOP3Interp_Real_gfx10<bits<10> op> {
1224    def _gfx10 :
1225      VOP3_Real<!cast<VOP3_Pseudo>(NAME), SIEncodingFamily.GFX10>,
1226      VOP3Interp_gfx10<op, !cast<VOP3_Pseudo>(NAME).Pfl>;
1227  }
1228  multiclass VOP3OpSel_Real_gfx10<bits<10> op> {
1229    def _gfx10 :
1230      VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX10>,
1231      VOP3OpSel_gfx10<op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1232  }
1233  multiclass VOP3OpSel_Real_gfx10_with_name<bits<10> op, string opName,
1234                                            string asmName> {
1235    def _gfx10 :
1236      VOP3_Real<!cast<VOP3_Pseudo>(opName#"_e64"), SIEncodingFamily.GFX10>,
1237      VOP3OpSel_gfx10<op, !cast<VOP3_Pseudo>(opName#"_e64").Pfl> {
1238        VOP3_Pseudo ps = !cast<VOP3_Pseudo>(opName#"_e64");
1239        let AsmString = asmName # ps.AsmOperands;
1240      }
1241  }
1242} // End AssemblerPredicate = isGFX10Only, DecoderNamespace = "GFX10"
1243
1244defm V_READLANE_B32  : VOP3_Real_No_Suffix_gfx10<0x360>;
1245
1246let InOperandList = (ins SSrcOrLds_b32:$src0, SCSrc_b32:$src1, VGPR_32:$vdst_in) in {
1247  defm V_WRITELANE_B32 : VOP3_Real_No_Suffix_gfx10<0x361>;
1248} // End InOperandList = (ins SSrcOrLds_b32:$src0, SCSrc_b32:$src1, VGPR_32:$vdst_in)
1249
1250let SubtargetPredicate = isGFX10Before1030 in {
1251  defm V_MUL_LO_I32      : VOP3_Real_gfx10<0x16b>;
1252}
1253
1254defm V_XOR3_B32           : VOP3_Real_gfx10<0x178>;
1255defm V_LSHLREV_B64        : VOP3_Real_gfx10<0x2ff>;
1256defm V_LSHRREV_B64        : VOP3_Real_gfx10<0x300>;
1257defm V_ASHRREV_I64        : VOP3_Real_gfx10<0x301>;
1258defm V_PERM_B32           : VOP3_Real_gfx10<0x344>;
1259defm V_XAD_U32            : VOP3_Real_gfx10<0x345>;
1260defm V_LSHL_ADD_U32       : VOP3_Real_gfx10<0x346>;
1261defm V_ADD_LSHL_U32       : VOP3_Real_gfx10<0x347>;
1262defm V_ADD3_U32           : VOP3_Real_gfx10<0x36d>;
1263defm V_LSHL_OR_B32        : VOP3_Real_gfx10<0x36f>;
1264defm V_AND_OR_B32         : VOP3_Real_gfx10<0x371>;
1265defm V_OR3_B32            : VOP3_Real_gfx10<0x372>;
1266
1267// TODO-GFX10: add MC tests for v_add/sub_nc_i16
1268defm V_ADD_NC_I16 :
1269  VOP3OpSel_Real_gfx10_with_name<0x30d, "V_ADD_I16", "v_add_nc_i16">;
1270defm V_SUB_NC_I16 :
1271  VOP3OpSel_Real_gfx10_with_name<0x30e, "V_SUB_I16", "v_sub_nc_i16">;
1272defm V_SUB_NC_I32 :
1273  VOP3_Real_gfx10_with_name<0x376, "V_SUB_I32", "v_sub_nc_i32">;
1274defm V_ADD_NC_I32 :
1275  VOP3_Real_gfx10_with_name<0x37f, "V_ADD_I32", "v_add_nc_i32">;
1276
1277defm V_INTERP_P1_F32_e64  : VOP3Interp_Real_gfx10<0x200>;
1278defm V_INTERP_P2_F32_e64  : VOP3Interp_Real_gfx10<0x201>;
1279defm V_INTERP_MOV_F32_e64 : VOP3Interp_Real_gfx10<0x202>;
1280
1281defm V_INTERP_P1LL_F16    : VOP3Interp_Real_gfx10<0x342>;
1282defm V_INTERP_P1LV_F16    : VOP3Interp_Real_gfx10<0x343>;
1283defm V_INTERP_P2_F16      : VOP3Interp_Real_gfx10<0x35a>;
1284
1285defm V_PACK_B32_F16       : VOP3OpSel_Real_gfx10<0x311>;
1286defm V_CVT_PKNORM_I16_F16 : VOP3OpSel_Real_gfx10<0x312>;
1287defm V_CVT_PKNORM_U16_F16 : VOP3OpSel_Real_gfx10<0x313>;
1288
1289defm V_MIN3_F16           : VOP3OpSel_Real_gfx10<0x351>;
1290defm V_MIN3_I16           : VOP3OpSel_Real_gfx10<0x352>;
1291defm V_MIN3_U16           : VOP3OpSel_Real_gfx10<0x353>;
1292defm V_MAX3_F16           : VOP3OpSel_Real_gfx10<0x354>;
1293defm V_MAX3_I16           : VOP3OpSel_Real_gfx10<0x355>;
1294defm V_MAX3_U16           : VOP3OpSel_Real_gfx10<0x356>;
1295defm V_MED3_F16           : VOP3OpSel_Real_gfx10<0x357>;
1296defm V_MED3_I16           : VOP3OpSel_Real_gfx10<0x358>;
1297defm V_MED3_U16           : VOP3OpSel_Real_gfx10<0x359>;
1298defm V_MAD_U32_U16        : VOP3OpSel_Real_gfx10<0x373>;
1299defm V_MAD_I32_I16        : VOP3OpSel_Real_gfx10<0x375>;
1300
1301defm V_MAD_U16 :
1302  VOP3OpSel_Real_gfx10_with_name<0x340, "V_MAD_U16_gfx9", "v_mad_u16">;
1303defm V_FMA_F16 :
1304  VOP3OpSel_Real_gfx10_with_name<0x34b, "V_FMA_F16_gfx9", "v_fma_f16">;
1305defm V_MAD_I16 :
1306  VOP3OpSel_Real_gfx10_with_name<0x35e, "V_MAD_I16_gfx9", "v_mad_i16">;
1307defm V_DIV_FIXUP_F16 :
1308  VOP3OpSel_Real_gfx10_with_name<0x35f, "V_DIV_FIXUP_F16_gfx9", "v_div_fixup_f16">;
1309
1310defm V_ADD_NC_U16      : VOP3OpSel_Real_gfx10<0x303>;
1311defm V_SUB_NC_U16      : VOP3OpSel_Real_gfx10<0x304>;
1312
1313// FIXME-GFX10-OPSEL: Need to add "selective" opsel support to some of these
1314// (they do not support SDWA or DPP).
1315defm V_MUL_LO_U16      : VOP3_Real_gfx10_with_name<0x305, "V_MUL_LO_U16", "v_mul_lo_u16">;
1316defm V_LSHRREV_B16     : VOP3_Real_gfx10_with_name<0x307, "V_LSHRREV_B16", "v_lshrrev_b16">;
1317defm V_ASHRREV_I16     : VOP3_Real_gfx10_with_name<0x308, "V_ASHRREV_I16", "v_ashrrev_i16">;
1318defm V_MAX_U16         : VOP3_Real_gfx10_with_name<0x309, "V_MAX_U16", "v_max_u16">;
1319defm V_MAX_I16         : VOP3_Real_gfx10_with_name<0x30a, "V_MAX_I16", "v_max_i16">;
1320defm V_MIN_U16         : VOP3_Real_gfx10_with_name<0x30b, "V_MIN_U16", "v_min_u16">;
1321defm V_MIN_I16         : VOP3_Real_gfx10_with_name<0x30c, "V_MIN_I16", "v_min_i16">;
1322defm V_LSHLREV_B16     : VOP3_Real_gfx10_with_name<0x314, "V_LSHLREV_B16", "v_lshlrev_b16">;
1323defm V_PERMLANE16_B32  : VOP3OpSel_Real_gfx10<0x377>;
1324defm V_PERMLANEX16_B32 : VOP3OpSel_Real_gfx10<0x378>;
1325
1326//===----------------------------------------------------------------------===//
1327// GFX7, GFX10.
1328//===----------------------------------------------------------------------===//
1329
1330let AssemblerPredicate = isGFX7Only, DecoderNamespace = "GFX7" in {
1331  multiclass VOP3_Real_gfx7<bits<10> op> {
1332    def _gfx7 :
1333      VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.SI>,
1334      VOP3e_gfx6_gfx7<op{8-0}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1335  }
1336  multiclass VOP3be_Real_gfx7<bits<10> op> {
1337    def _gfx7 :
1338      VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.SI>,
1339      VOP3be_gfx6_gfx7<op{8-0}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1340  }
1341} // End AssemblerPredicate = isGFX7Only, DecoderNamespace = "GFX7"
1342
1343multiclass VOP3_Real_gfx7_gfx10<bits<10> op> :
1344  VOP3_Real_gfx7<op>, VOP3_Real_gfx10<op>;
1345
1346multiclass VOP3be_Real_gfx7_gfx10<bits<10> op> :
1347  VOP3be_Real_gfx7<op>, VOP3be_Real_gfx10<op>;
1348
1349defm V_QSAD_PK_U16_U8   : VOP3_Real_gfx7_gfx10<0x172>;
1350defm V_MQSAD_U32_U8     : VOP3_Real_gfx7_gfx10<0x175>;
1351defm V_MAD_U64_U32      : VOP3be_Real_gfx7_gfx10<0x176>;
1352defm V_MAD_I64_I32      : VOP3be_Real_gfx7_gfx10<0x177>;
1353
1354//===----------------------------------------------------------------------===//
1355// GFX6, GFX7, GFX10.
1356//===----------------------------------------------------------------------===//
1357
1358let AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" in {
1359  multiclass VOP3_Real_gfx6_gfx7<bits<10> op> {
1360    def _gfx6_gfx7 :
1361      VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.SI>,
1362      VOP3e_gfx6_gfx7<op{8-0}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1363  }
1364  multiclass VOP3be_Real_gfx6_gfx7<bits<10> op> {
1365    def _gfx6_gfx7 :
1366      VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.SI>,
1367      VOP3be_gfx6_gfx7<op{8-0}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1368  }
1369} // End AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7"
1370
1371multiclass VOP3_Real_gfx6_gfx7_gfx10<bits<10> op> :
1372  VOP3_Real_gfx6_gfx7<op>, VOP3_Real_gfx10<op>;
1373
1374multiclass VOP3be_Real_gfx6_gfx7_gfx10<bits<10> op> :
1375  VOP3be_Real_gfx6_gfx7<op>, VOP3be_Real_gfx10<op>;
1376
1377defm V_LSHL_B64        : VOP3_Real_gfx6_gfx7<0x161>;
1378defm V_LSHR_B64        : VOP3_Real_gfx6_gfx7<0x162>;
1379defm V_ASHR_I64        : VOP3_Real_gfx6_gfx7<0x163>;
1380defm V_MUL_LO_I32      : VOP3_Real_gfx6_gfx7<0x16b>;
1381
1382defm V_MAD_LEGACY_F32  : VOP3_Real_gfx6_gfx7_gfx10<0x140>;
1383defm V_MAD_F32         : VOP3_Real_gfx6_gfx7_gfx10<0x141>;
1384defm V_MAD_I32_I24     : VOP3_Real_gfx6_gfx7_gfx10<0x142>;
1385defm V_MAD_U32_U24     : VOP3_Real_gfx6_gfx7_gfx10<0x143>;
1386defm V_CUBEID_F32      : VOP3_Real_gfx6_gfx7_gfx10<0x144>;
1387defm V_CUBESC_F32      : VOP3_Real_gfx6_gfx7_gfx10<0x145>;
1388defm V_CUBETC_F32      : VOP3_Real_gfx6_gfx7_gfx10<0x146>;
1389defm V_CUBEMA_F32      : VOP3_Real_gfx6_gfx7_gfx10<0x147>;
1390defm V_BFE_U32         : VOP3_Real_gfx6_gfx7_gfx10<0x148>;
1391defm V_BFE_I32         : VOP3_Real_gfx6_gfx7_gfx10<0x149>;
1392defm V_BFI_B32         : VOP3_Real_gfx6_gfx7_gfx10<0x14a>;
1393defm V_FMA_F32         : VOP3_Real_gfx6_gfx7_gfx10<0x14b>;
1394defm V_FMA_F64         : VOP3_Real_gfx6_gfx7_gfx10<0x14c>;
1395defm V_LERP_U8         : VOP3_Real_gfx6_gfx7_gfx10<0x14d>;
1396defm V_ALIGNBIT_B32    : VOP3_Real_gfx6_gfx7_gfx10<0x14e>;
1397defm V_ALIGNBYTE_B32   : VOP3_Real_gfx6_gfx7_gfx10<0x14f>;
1398defm V_MULLIT_F32      : VOP3_Real_gfx6_gfx7_gfx10<0x150>;
1399defm V_MIN3_F32        : VOP3_Real_gfx6_gfx7_gfx10<0x151>;
1400defm V_MIN3_I32        : VOP3_Real_gfx6_gfx7_gfx10<0x152>;
1401defm V_MIN3_U32        : VOP3_Real_gfx6_gfx7_gfx10<0x153>;
1402defm V_MAX3_F32        : VOP3_Real_gfx6_gfx7_gfx10<0x154>;
1403defm V_MAX3_I32        : VOP3_Real_gfx6_gfx7_gfx10<0x155>;
1404defm V_MAX3_U32        : VOP3_Real_gfx6_gfx7_gfx10<0x156>;
1405defm V_MED3_F32        : VOP3_Real_gfx6_gfx7_gfx10<0x157>;
1406defm V_MED3_I32        : VOP3_Real_gfx6_gfx7_gfx10<0x158>;
1407defm V_MED3_U32        : VOP3_Real_gfx6_gfx7_gfx10<0x159>;
1408defm V_SAD_U8          : VOP3_Real_gfx6_gfx7_gfx10<0x15a>;
1409defm V_SAD_HI_U8       : VOP3_Real_gfx6_gfx7_gfx10<0x15b>;
1410defm V_SAD_U16         : VOP3_Real_gfx6_gfx7_gfx10<0x15c>;
1411defm V_SAD_U32         : VOP3_Real_gfx6_gfx7_gfx10<0x15d>;
1412defm V_CVT_PK_U8_F32   : VOP3_Real_gfx6_gfx7_gfx10<0x15e>;
1413defm V_DIV_FIXUP_F32   : VOP3_Real_gfx6_gfx7_gfx10<0x15f>;
1414defm V_DIV_FIXUP_F64   : VOP3_Real_gfx6_gfx7_gfx10<0x160>;
1415defm V_ADD_F64         : VOP3_Real_gfx6_gfx7_gfx10<0x164>;
1416defm V_MUL_F64         : VOP3_Real_gfx6_gfx7_gfx10<0x165>;
1417defm V_MIN_F64         : VOP3_Real_gfx6_gfx7_gfx10<0x166>;
1418defm V_MAX_F64         : VOP3_Real_gfx6_gfx7_gfx10<0x167>;
1419defm V_LDEXP_F64       : VOP3_Real_gfx6_gfx7_gfx10<0x168>;
1420defm V_MUL_LO_U32      : VOP3_Real_gfx6_gfx7_gfx10<0x169>;
1421defm V_MUL_HI_U32      : VOP3_Real_gfx6_gfx7_gfx10<0x16a>;
1422defm V_MUL_HI_I32      : VOP3_Real_gfx6_gfx7_gfx10<0x16c>;
1423defm V_DIV_FMAS_F32    : VOP3_Real_gfx6_gfx7_gfx10<0x16f>;
1424defm V_DIV_FMAS_F64    : VOP3_Real_gfx6_gfx7_gfx10<0x170>;
1425defm V_MSAD_U8         : VOP3_Real_gfx6_gfx7_gfx10<0x171>;
1426defm V_MQSAD_PK_U16_U8 : VOP3_Real_gfx6_gfx7_gfx10<0x173>;
1427defm V_TRIG_PREOP_F64  : VOP3_Real_gfx6_gfx7_gfx10<0x174>;
1428defm V_DIV_SCALE_F32   : VOP3be_Real_gfx6_gfx7_gfx10<0x16d>;
1429defm V_DIV_SCALE_F64   : VOP3be_Real_gfx6_gfx7_gfx10<0x16e>;
1430
1431// NB: Same opcode as v_mad_legacy_f32
1432let DecoderNamespace = "GFX10_B" in
1433defm V_FMA_LEGACY_F32  : VOP3_Real_gfx10<0x140>;
1434
1435//===----------------------------------------------------------------------===//
1436// GFX8, GFX9 (VI).
1437//===----------------------------------------------------------------------===//
1438
1439let AssemblerPredicate = isGFX8GFX9, DecoderNamespace = "GFX8" in {
1440
1441multiclass VOP3_Real_vi<bits<10> op> {
1442  def _vi : VOP3_Real<!cast<VOP_Pseudo>(NAME#"_e64"), SIEncodingFamily.VI>,
1443            VOP3e_vi <op, !cast<VOP_Pseudo>(NAME#"_e64").Pfl>;
1444}
1445multiclass VOP3_Real_No_Suffix_vi<bits<10> op> {
1446  def _vi : VOP3_Real<!cast<VOP_Pseudo>(NAME), SIEncodingFamily.VI>,
1447            VOP3e_vi <op, !cast<VOP_Pseudo>(NAME).Pfl>;
1448}
1449
1450multiclass VOP3be_Real_vi<bits<10> op> {
1451  def _vi : VOP3_Real<!cast<VOP_Pseudo>(NAME#"_e64"), SIEncodingFamily.VI>,
1452            VOP3be_vi <op, !cast<VOP_Pseudo>(NAME#"_e64").Pfl>;
1453}
1454
1455multiclass VOP3OpSel_Real_gfx9<bits<10> op> {
1456  def _vi : VOP3_Real<!cast<VOP_Pseudo>(NAME#"_e64"), SIEncodingFamily.VI>,
1457            VOP3OpSel_gfx9 <op, !cast<VOP_Pseudo>(NAME#"_e64").Pfl>;
1458}
1459
1460multiclass VOP3OpSel_Real_gfx9_forced_opsel2<bits<10> op> {
1461  def _vi : VOP3_Real<!cast<VOP_Pseudo>(NAME#"_e64"), SIEncodingFamily.VI>,
1462            VOP3OpSel_gfx9 <op, !cast<VOP_Pseudo>(NAME#"_e64").Pfl> {
1463    let Inst{13} = src2_modifiers{2}; // op_sel(2)
1464  }
1465}
1466
1467multiclass VOP3Interp_Real_vi<bits<10> op> {
1468  def _vi : VOP3_Real<!cast<VOP_Pseudo>(NAME), SIEncodingFamily.VI>,
1469            VOP3Interp_vi <op, !cast<VOP_Pseudo>(NAME).Pfl>;
1470}
1471
1472} // End AssemblerPredicate = isGFX8GFX9, DecoderNamespace = "GFX8"
1473
1474let AssemblerPredicate = isGFX8Only, DecoderNamespace = "GFX8" in {
1475
1476multiclass VOP3_F16_Real_vi<bits<10> op> {
1477  def _vi : VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.VI>,
1478            VOP3e_vi <op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1479}
1480
1481multiclass VOP3Interp_F16_Real_vi<bits<10> op> {
1482  def _vi : VOP3_Real<!cast<VOP3_Pseudo>(NAME), SIEncodingFamily.VI>,
1483            VOP3Interp_vi <op, !cast<VOP3_Pseudo>(NAME).Pfl>;
1484}
1485
1486} // End AssemblerPredicate = isGFX8Only, DecoderNamespace = "GFX8"
1487
1488let AssemblerPredicate = isGFX9Only, DecoderNamespace = "GFX9" in {
1489
1490multiclass VOP3_F16_Real_gfx9<bits<10> op, string OpName, string AsmName> {
1491  def _gfx9 : VOP3_Real<!cast<VOP3_Pseudo>(OpName#"_e64"), SIEncodingFamily.GFX9>,
1492            VOP3e_vi <op, !cast<VOP3_Pseudo>(OpName#"_e64").Pfl> {
1493              VOP3_Pseudo ps = !cast<VOP3_Pseudo>(OpName#"_e64");
1494              let AsmString = AsmName # ps.AsmOperands;
1495            }
1496}
1497
1498multiclass VOP3OpSel_F16_Real_gfx9<bits<10> op, string AsmName> {
1499  def _gfx9 : VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX9>,
1500            VOP3OpSel_gfx9 <op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl> {
1501              VOP3_Pseudo ps = !cast<VOP3_Pseudo>(NAME#"_e64");
1502              let AsmString = AsmName # ps.AsmOperands;
1503            }
1504}
1505
1506multiclass VOP3Interp_F16_Real_gfx9<bits<10> op, string OpName, string AsmName> {
1507  def _gfx9 : VOP3_Real<!cast<VOP3_Pseudo>(OpName), SIEncodingFamily.GFX9>,
1508            VOP3Interp_vi <op, !cast<VOP3_Pseudo>(OpName).Pfl> {
1509              VOP3_Pseudo ps = !cast<VOP3_Pseudo>(OpName);
1510              let AsmString = AsmName # ps.AsmOperands;
1511            }
1512}
1513
1514multiclass VOP3_Real_gfx9<bits<10> op, string AsmName> {
1515  def _gfx9 : VOP3_Real<!cast<VOP_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX9>,
1516              VOP3e_vi <op, !cast<VOP_Pseudo>(NAME#"_e64").Pfl> {
1517              VOP_Pseudo ps = !cast<VOP_Pseudo>(NAME#"_e64");
1518              let AsmString = AsmName # ps.AsmOperands;
1519            }
1520}
1521
1522} // End AssemblerPredicate = isGFX9Only, DecoderNamespace = "GFX9"
1523
1524defm V_MAD_U64_U32      : VOP3be_Real_vi <0x1E8>;
1525defm V_MAD_I64_I32      : VOP3be_Real_vi <0x1E9>;
1526
1527defm V_MAD_LEGACY_F32   : VOP3_Real_vi <0x1c0>;
1528defm V_MAD_F32          : VOP3_Real_vi <0x1c1>;
1529defm V_MAD_I32_I24      : VOP3_Real_vi <0x1c2>;
1530defm V_MAD_U32_U24      : VOP3_Real_vi <0x1c3>;
1531defm V_CUBEID_F32       : VOP3_Real_vi <0x1c4>;
1532defm V_CUBESC_F32       : VOP3_Real_vi <0x1c5>;
1533defm V_CUBETC_F32       : VOP3_Real_vi <0x1c6>;
1534defm V_CUBEMA_F32       : VOP3_Real_vi <0x1c7>;
1535defm V_BFE_U32          : VOP3_Real_vi <0x1c8>;
1536defm V_BFE_I32          : VOP3_Real_vi <0x1c9>;
1537defm V_BFI_B32          : VOP3_Real_vi <0x1ca>;
1538defm V_FMA_F32          : VOP3_Real_vi <0x1cb>;
1539defm V_FMA_F64          : VOP3_Real_vi <0x1cc>;
1540defm V_LERP_U8          : VOP3_Real_vi <0x1cd>;
1541defm V_ALIGNBIT_B32     : VOP3_Real_vi <0x1ce>;
1542defm V_ALIGNBYTE_B32    : VOP3_Real_vi <0x1cf>;
1543defm V_MIN3_F32         : VOP3_Real_vi <0x1d0>;
1544defm V_MIN3_I32         : VOP3_Real_vi <0x1d1>;
1545defm V_MIN3_U32         : VOP3_Real_vi <0x1d2>;
1546defm V_MAX3_F32         : VOP3_Real_vi <0x1d3>;
1547defm V_MAX3_I32         : VOP3_Real_vi <0x1d4>;
1548defm V_MAX3_U32         : VOP3_Real_vi <0x1d5>;
1549defm V_MED3_F32         : VOP3_Real_vi <0x1d6>;
1550defm V_MED3_I32         : VOP3_Real_vi <0x1d7>;
1551defm V_MED3_U32         : VOP3_Real_vi <0x1d8>;
1552defm V_SAD_U8           : VOP3_Real_vi <0x1d9>;
1553defm V_SAD_HI_U8        : VOP3_Real_vi <0x1da>;
1554defm V_SAD_U16          : VOP3_Real_vi <0x1db>;
1555defm V_SAD_U32          : VOP3_Real_vi <0x1dc>;
1556defm V_CVT_PK_U8_F32    : VOP3_Real_vi <0x1dd>;
1557defm V_DIV_FIXUP_F32    : VOP3_Real_vi <0x1de>;
1558defm V_DIV_FIXUP_F64    : VOP3_Real_vi <0x1df>;
1559defm V_DIV_SCALE_F32    : VOP3be_Real_vi <0x1e0>;
1560defm V_DIV_SCALE_F64    : VOP3be_Real_vi <0x1e1>;
1561defm V_DIV_FMAS_F32     : VOP3_Real_vi <0x1e2>;
1562defm V_DIV_FMAS_F64     : VOP3_Real_vi <0x1e3>;
1563defm V_MSAD_U8          : VOP3_Real_vi <0x1e4>;
1564defm V_QSAD_PK_U16_U8   : VOP3_Real_vi <0x1e5>;
1565defm V_MQSAD_PK_U16_U8  : VOP3_Real_vi <0x1e6>;
1566defm V_MQSAD_U32_U8     : VOP3_Real_vi <0x1e7>;
1567
1568defm V_PERM_B32         : VOP3_Real_vi <0x1ed>;
1569
1570defm V_MAD_F16          : VOP3_F16_Real_vi <0x1ea>;
1571defm V_MAD_U16          : VOP3_F16_Real_vi <0x1eb>;
1572defm V_MAD_I16          : VOP3_F16_Real_vi <0x1ec>;
1573defm V_FMA_F16          : VOP3_F16_Real_vi <0x1ee>;
1574defm V_DIV_FIXUP_F16    : VOP3_F16_Real_vi <0x1ef>;
1575defm V_INTERP_P2_F16    : VOP3Interp_F16_Real_vi <0x276>;
1576
1577let FPDPRounding = 1 in {
1578defm V_MAD_LEGACY_F16       : VOP3_F16_Real_gfx9 <0x1ea, "V_MAD_F16",       "v_mad_legacy_f16">;
1579defm V_FMA_LEGACY_F16       : VOP3_F16_Real_gfx9 <0x1ee, "V_FMA_F16",       "v_fma_legacy_f16">;
1580defm V_DIV_FIXUP_LEGACY_F16 : VOP3_F16_Real_gfx9 <0x1ef, "V_DIV_FIXUP_F16", "v_div_fixup_legacy_f16">;
1581defm V_INTERP_P2_LEGACY_F16 : VOP3Interp_F16_Real_gfx9 <0x276, "V_INTERP_P2_F16", "v_interp_p2_legacy_f16">;
1582} // End FPDPRounding = 1
1583
1584defm V_MAD_LEGACY_U16       : VOP3_F16_Real_gfx9 <0x1eb, "V_MAD_U16",       "v_mad_legacy_u16">;
1585defm V_MAD_LEGACY_I16       : VOP3_F16_Real_gfx9 <0x1ec, "V_MAD_I16",       "v_mad_legacy_i16">;
1586
1587defm V_MAD_F16_gfx9         : VOP3OpSel_F16_Real_gfx9 <0x203, "v_mad_f16">;
1588defm V_MAD_U16_gfx9         : VOP3OpSel_F16_Real_gfx9 <0x204, "v_mad_u16">;
1589defm V_MAD_I16_gfx9         : VOP3OpSel_F16_Real_gfx9 <0x205, "v_mad_i16">;
1590defm V_FMA_F16_gfx9         : VOP3OpSel_F16_Real_gfx9 <0x206, "v_fma_f16">;
1591defm V_DIV_FIXUP_F16_gfx9   : VOP3OpSel_F16_Real_gfx9 <0x207, "v_div_fixup_f16">;
1592defm V_INTERP_P2_F16_gfx9   : VOP3Interp_F16_Real_gfx9 <0x277, "V_INTERP_P2_F16_gfx9", "v_interp_p2_f16">;
1593
1594defm V_ADD_I32         : VOP3_Real_vi <0x29c>;
1595defm V_SUB_I32         : VOP3_Real_vi <0x29d>;
1596
1597defm V_INTERP_P1_F32_e64  : VOP3Interp_Real_vi <0x270>;
1598defm V_INTERP_P2_F32_e64  : VOP3Interp_Real_vi <0x271>;
1599defm V_INTERP_MOV_F32_e64 : VOP3Interp_Real_vi <0x272>;
1600
1601defm V_INTERP_P1LL_F16  : VOP3Interp_Real_vi <0x274>;
1602defm V_INTERP_P1LV_F16  : VOP3Interp_Real_vi <0x275>;
1603defm V_ADD_F64          : VOP3_Real_vi <0x280>;
1604defm V_MUL_F64          : VOP3_Real_vi <0x281>;
1605defm V_MIN_F64          : VOP3_Real_vi <0x282>;
1606defm V_MAX_F64          : VOP3_Real_vi <0x283>;
1607defm V_LDEXP_F64        : VOP3_Real_vi <0x284>;
1608defm V_MUL_LO_U32       : VOP3_Real_vi <0x285>;
1609
1610// removed from VI as identical to V_MUL_LO_U32
1611let isAsmParserOnly = 1 in {
1612defm V_MUL_LO_I32       : VOP3_Real_vi <0x285>;
1613}
1614
1615defm V_MUL_HI_U32       : VOP3_Real_vi <0x286>;
1616defm V_MUL_HI_I32       : VOP3_Real_vi <0x287>;
1617
1618defm V_READLANE_B32     : VOP3_Real_No_Suffix_vi <0x289>;
1619defm V_WRITELANE_B32    : VOP3_Real_No_Suffix_vi <0x28a>;
1620
1621defm V_LSHLREV_B64      : VOP3_Real_vi <0x28f>;
1622defm V_LSHRREV_B64      : VOP3_Real_vi <0x290>;
1623defm V_ASHRREV_I64      : VOP3_Real_vi <0x291>;
1624defm V_TRIG_PREOP_F64   : VOP3_Real_vi <0x292>;
1625
1626defm V_LSHL_ADD_U32 : VOP3_Real_vi <0x1fd>;
1627defm V_ADD_LSHL_U32 : VOP3_Real_vi <0x1fe>;
1628defm V_ADD3_U32 : VOP3_Real_vi <0x1ff>;
1629defm V_LSHL_OR_B32 : VOP3_Real_vi <0x200>;
1630defm V_AND_OR_B32 : VOP3_Real_vi <0x201>;
1631defm V_OR3_B32 : VOP3_Real_vi <0x202>;
1632defm V_PACK_B32_F16 : VOP3OpSel_Real_gfx9 <0x2a0>;
1633
1634defm V_XAD_U32 : VOP3_Real_vi <0x1f3>;
1635
1636defm V_MIN3_F16 : VOP3OpSel_Real_gfx9 <0x1f4>;
1637defm V_MIN3_I16 : VOP3OpSel_Real_gfx9 <0x1f5>;
1638defm V_MIN3_U16 : VOP3OpSel_Real_gfx9 <0x1f6>;
1639
1640defm V_MAX3_F16 : VOP3OpSel_Real_gfx9 <0x1f7>;
1641defm V_MAX3_I16 : VOP3OpSel_Real_gfx9 <0x1f8>;
1642defm V_MAX3_U16 : VOP3OpSel_Real_gfx9 <0x1f9>;
1643
1644defm V_MED3_F16 : VOP3OpSel_Real_gfx9 <0x1fa>;
1645defm V_MED3_I16 : VOP3OpSel_Real_gfx9 <0x1fb>;
1646defm V_MED3_U16 : VOP3OpSel_Real_gfx9 <0x1fc>;
1647
1648defm V_ADD_I16  : VOP3OpSel_Real_gfx9 <0x29e>;
1649defm V_SUB_I16  : VOP3OpSel_Real_gfx9 <0x29f>;
1650
1651defm V_MAD_U32_U16 : VOP3OpSel_Real_gfx9 <0x1f1>;
1652defm V_MAD_I32_I16 : VOP3OpSel_Real_gfx9 <0x1f2>;
1653
1654defm V_CVT_PKNORM_I16_F16 : VOP3OpSel_Real_gfx9 <0x299>;
1655defm V_CVT_PKNORM_U16_F16 : VOP3OpSel_Real_gfx9 <0x29a>;
1656
1657defm V_LSHL_ADD_U64 : VOP3_Real_vi <0x208>;
1658
1659let OtherPredicates = [HasFP8ConversionInsts] in {
1660defm V_CVT_PK_FP8_F32 : VOP3OpSel_Real_gfx9 <0x2a2>;
1661defm V_CVT_PK_BF8_F32 : VOP3OpSel_Real_gfx9 <0x2a3>;
1662defm V_CVT_SR_FP8_F32 : VOP3OpSel_Real_gfx9_forced_opsel2 <0x2a4>;
1663defm V_CVT_SR_BF8_F32 : VOP3OpSel_Real_gfx9_forced_opsel2 <0x2a5>;
1664}
1665