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