1 //===-- VOP3Instructions.td - Vector Instruction Definitions --------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
13 class getVOP3ModPat<VOPProfile P, SDPatternOperator node> {
14 dag src0 = !if(P.HasOMod,
15 (VOP3Mods0 P.Src0VT:$src0, i32:$src0_modifiers, i1:$clamp, i32:$omod),
16 (VOP3Mods0 P.Src0VT:$src0, i32:$src0_modifiers, i1:$clamp));
18 list<dag> ret3 = [(set P.DstVT:$vdst,
19 (DivergentFragOrOp<node, P>.ret (P.Src0VT src0),
20 (P.Src1VT (VOP3Mods P.Src1VT:$src1, i32:$src1_modifiers)),
21 (P.Src2VT (VOP3Mods P.Src2VT:$src2, i32:$src2_modifiers))))];
23 list<dag> ret2 = [(set P.DstVT:$vdst,
24 (DivergentFragOrOp<node, P>.ret (P.Src0VT src0),
25 (P.Src1VT (VOP3Mods P.Src1VT:$src1, i32:$src1_modifiers))))];
27 list<dag> ret1 = [(set P.DstVT:$vdst,
28 (DivergentFragOrOp<node, P>.ret (P.Src0VT src0)))];
30 list<dag> ret = !if(!eq(P.NumSrcArgs, 3), ret3,
31 !if(!eq(P.NumSrcArgs, 2), ret2,
35 class getVOP3PModPat<VOPProfile P, SDPatternOperator node, bit HasExplicitClamp> {
36 dag src0_dag = (P.Src0VT (VOP3PMods P.Src0VT:$src0, i32:$src0_modifiers));
37 dag src1_dag = (P.Src1VT (VOP3PMods P.Src1VT:$src1, i32:$src1_modifiers));
38 dag src2_dag = (P.Src2VT (VOP3PMods P.Src2VT:$src2, i32:$src2_modifiers));
39 dag clamp_dag = (i1 timm:$clamp);
41 list<dag> ret3 = [(set P.DstVT:$vdst,
43 (DivergentFragOrOp<node, P>.ret src0_dag, src1_dag, src2_dag, clamp_dag),
44 (DivergentFragOrOp<node, P>.ret src0_dag, src1_dag, src2_dag)))];
46 list<dag> ret2 = [(set P.DstVT:$vdst,
48 (DivergentFragOrOp<node, P>.ret src0_dag, src1_dag, clamp_dag),
49 (DivergentFragOrOp<node, P>.ret src0_dag, src1_dag)))];
51 list<dag> ret1 = [(set P.DstVT:$vdst,
53 (DivergentFragOrOp<node, P>.ret src0_dag, clamp_dag),
54 (DivergentFragOrOp<node, P>.ret src0_dag)))];
56 list<dag> ret = !if(!eq(P.NumSrcArgs, 3), ret3,
57 !if(!eq(P.NumSrcArgs, 2), ret2,
61 class getVOP3OpSelPat<VOPProfile P, SDPatternOperator node> {
62 list<dag> ret3 = [(set P.DstVT:$vdst,
63 (DivergentFragOrOp<node, P>.ret (P.Src0VT (VOP3OpSel P.Src0VT:$src0, i32:$src0_modifiers)),
64 (P.Src1VT (VOP3OpSel P.Src1VT:$src1, i32:$src1_modifiers)),
65 (P.Src2VT (VOP3OpSel P.Src2VT:$src2, i32:$src2_modifiers))))];
67 list<dag> ret2 = [(set P.DstVT:$vdst,
68 (DivergentFragOrOp<node, P>.ret (P.Src0VT (VOP3OpSel P.Src0VT:$src0, i32:$src0_modifiers)),
69 (P.Src1VT (VOP3OpSel P.Src1VT:$src1, i32:$src1_modifiers))))];
71 list<dag> ret1 = [(set P.DstVT:$vdst,
72 (DivergentFragOrOp<node, P>.ret (P.Src0VT (VOP3OpSel P.Src0VT:$src0, i32:$src0_modifiers))))];
74 list<dag> ret = !if(!eq(P.NumSrcArgs, 3), ret3,
75 !if(!eq(P.NumSrcArgs, 2), ret2,
79 class getVOP3OpSelModPat<VOPProfile P, SDPatternOperator node> {
80 list<dag> ret3 = [(set P.DstVT:$vdst,
81 (DivergentFragOrOp<node, P>.ret (P.Src0VT !if(P.HasClamp, (VOP3OpSelMods P.Src0VT:$src0, i32:$src0_modifiers),
82 (VOP3OpSelMods P.Src0VT:$src0, i32:$src0_modifiers))),
83 (P.Src1VT (VOP3OpSelMods P.Src1VT:$src1, i32:$src1_modifiers)),
84 (P.Src2VT (VOP3OpSelMods P.Src2VT:$src2, i32:$src2_modifiers))))];
86 list<dag> ret2 = [(set P.DstVT:$vdst,
87 (DivergentFragOrOp<node, P>.ret !if(P.HasClamp, (P.Src0VT (VOP3OpSelMods P.Src0VT:$src0, i32:$src0_modifiers)),
88 (P.Src0VT (VOP3OpSelMods P.Src0VT:$src0, i32:$src0_modifiers))),
89 (P.Src1VT (VOP3OpSelMods P.Src1VT:$src1, i32:$src1_modifiers))))];
91 list<dag> ret1 = [(set P.DstVT:$vdst,
92 (DivergentFragOrOp<node, P>.ret (P.Src0VT (VOP3OpSelMods P.Src0VT:$src0, i32:$src0_modifiers))))];
94 list<dag> ret = !if(!eq(P.NumSrcArgs, 3), ret3,
95 !if(!eq(P.NumSrcArgs, 2), ret2,
99 class getVOP3Pat<VOPProfile P, SDPatternOperator node> {
100 list<dag> ret3 = [(set P.DstVT:$vdst, (DivergentFragOrOp<node, P>.ret P.Src0VT:$src0, P.Src1VT:$src1, P.Src2VT:$src2))];
101 list<dag> ret2 = [(set P.DstVT:$vdst, (DivergentFragOrOp<node, P>.ret P.Src0VT:$src0, P.Src1VT:$src1))];
102 list<dag> ret1 = [(set P.DstVT:$vdst, (DivergentFragOrOp<node, P>.ret P.Src0VT:$src0))];
103 list<dag> ret = !if(!eq(P.NumSrcArgs, 3), ret3,
104 !if(!eq(P.NumSrcArgs, 2), ret2,
108 class getVOP3ClampPat<VOPProfile P, SDPatternOperator node> {
109 list<dag> ret3 = [(set P.DstVT:$vdst, (node P.Src0VT:$src0, P.Src1VT:$src1, P.Src2VT:$src2, i1:$clamp))];
110 list<dag> ret2 = [(set P.DstVT:$vdst, (node P.Src0VT:$src0, P.Src1VT:$src1, i1:$clamp))];
111 list<dag> ret1 = [(set P.DstVT:$vdst, (node P.Src0VT:$src0, i1:$clamp))];
112 list<dag> ret = !if(!eq(P.NumSrcArgs, 3), ret3,
113 !if(!eq(P.NumSrcArgs, 2), ret2,
117 class getVOP3MAIPat<VOPProfile P, SDPatternOperator node> {
118 list<dag> ret = [(set P.DstVT:$vdst, (node P.Src0VT:$src0, P.Src1VT:$src1, P.Src2VT:$src2,
119 timm:$cbsz, timm:$abid, timm:$blgp))];
122 // Consistently gives instructions a _e64 suffix.
123 multiclass VOP3Inst_Pseudo_Wrapper<string opName, VOPProfile P, list<dag> pattern = [], bit VOP3Only = 0> {
124 def _e64 : VOP3_Pseudo<opName, P, pattern, VOP3Only>;
127 class VOP3InstBase<string OpName, VOPProfile P, SDPatternOperator node = null_frag, bit VOP3Only = 0> :
128 VOP3_Pseudo<OpName, P,
131 getVOP3OpSelModPat<P, node>.ret,
132 getVOP3OpSelPat<P, node>.ret),
134 getVOP3ModPat<P, node>.ret,
136 getVOP3ClampPat<P, node>.ret,
138 getVOP3MAIPat<P, node>.ret,
139 getVOP3Pat<P, node>.ret)))),
140 VOP3Only, 0, P.HasOpSel> {
142 let IntClamp = P.HasIntClamp;
143 let AsmMatchConverter =
146 !if(!or(P.HasModifiers, P.HasOMod, P.HasIntClamp),
151 multiclass VOP3Inst<string OpName, VOPProfile P, SDPatternOperator node = null_frag, bit VOP3Only = 0> {
152 def _e64 : VOP3InstBase<OpName, P, node, VOP3Only>;
155 // Special case for v_div_fmas_{f32|f64}, since it seems to be the
156 // only VOP instruction that implicitly reads VCC.
157 let Asm64 = " $vdst, $src0_modifiers, $src1_modifiers, $src2_modifiers$clamp$omod" in {
158 def VOP_F32_F32_F32_F32_VCC : VOPProfile<[f32, f32, f32, f32]> {
159 let Outs64 = (outs DstRC.RegClass:$vdst);
161 def VOP_F64_F64_F64_F64_VCC : VOPProfile<[f64, f64, f64, f64]> {
162 let Outs64 = (outs DstRC.RegClass:$vdst);
166 class VOP3Features<bit Clamp, bit OpSel, bit Packed, bit MAI> {
167 bit HasClamp = Clamp;
168 bit HasOpSel = OpSel;
169 bit IsPacked = Packed;
173 def VOP3_REGULAR : VOP3Features<0, 0, 0, 0>;
174 def VOP3_CLAMP : VOP3Features<1, 0, 0, 0>;
175 def VOP3_OPSEL : VOP3Features<1, 1, 0, 0>;
176 def VOP3_PACKED : VOP3Features<1, 1, 1, 0>;
177 def VOP3_MAI : VOP3Features<0, 0, 0, 1>;
179 class VOP3_Profile<VOPProfile P, VOP3Features Features = VOP3_REGULAR> : VOPProfile<P.ArgVT> {
181 let HasClamp = !if(Features.HasClamp, 1, P.HasClamp);
182 let HasOpSel = !if(Features.HasOpSel, 1, P.HasOpSel);
183 let IsMAI = !if(Features.IsMAI, 1, P.IsMAI);
184 let IsPacked = !if(Features.IsPacked, 1, P.IsPacked);
186 let HasModifiers = !if(Features.IsMAI, 0, !or(Features.IsPacked, P.HasModifiers));
190 class VOP3b_Profile<ValueType vt> : VOPProfile<[vt, vt, vt, vt]> {
191 let Outs64 = (outs DstRC:$vdst, VOPDstS64orS32:$sdst);
192 let Asm64 = "$vdst, $sdst, $src0_modifiers, $src1_modifiers, $src2_modifiers$clamp$omod";
196 def VOP3b_F32_I1_F32_F32_F32 : VOP3b_Profile<f32>;
197 def VOP3b_F64_I1_F64_F64_F64 : VOP3b_Profile<f64>;
199 def VOP3b_I64_I1_I32_I32_I64 : VOPProfile<[i64, i32, i32, i64]> {
203 let Outs64 = (outs DstRC:$vdst, VOPDstS64orS32:$sdst);
204 let Asm64 = "$vdst, $sdst, $src0, $src1, $src2$clamp";
207 //===----------------------------------------------------------------------===//
209 //===----------------------------------------------------------------------===//
211 class VOP3Interp<string OpName, VOPProfile P, list<dag> pattern = []> :
212 VOP3_Pseudo<OpName, P, pattern> {
213 let AsmMatchConverter = "cvtVOP3Interp";
214 let mayRaiseFPException = 0;
217 def VOP3_INTERP : VOPProfile<[f32, f32, i32, untyped]> {
218 let Ins64 = (ins Src0Mod:$src0_modifiers, VRegSrc_32:$src0,
219 Attr:$attr, AttrChan:$attrchan,
220 clampmod0:$clamp, omod0:$omod);
222 let Asm64 = "$vdst, $src0_modifiers, $attr$attrchan$clamp$omod";
225 def VOP3_INTERP_MOV : VOPProfile<[f32, i32, i32, untyped]> {
226 let Ins64 = (ins InterpSlot:$src0,
227 Attr:$attr, AttrChan:$attrchan,
228 clampmod0:$clamp, omod0:$omod);
230 let Asm64 = "$vdst, $src0, $attr$attrchan$clamp$omod";
236 class getInterp16Asm <bit HasSrc2, bit HasOMod> {
237 string src2 = !if(HasSrc2, ", $src2_modifiers", "");
238 string omod = !if(HasOMod, "$omod", "");
240 " $vdst, $src0_modifiers, $attr$attrchan"#src2#"$high$clamp"#omod;
243 class getInterp16Ins <bit HasSrc2, bit HasOMod,
244 Operand Src0Mod, Operand Src2Mod> {
245 dag ret = !if(HasSrc2,
247 (ins Src0Mod:$src0_modifiers, VRegSrc_32:$src0,
248 Attr:$attr, AttrChan:$attrchan,
249 Src2Mod:$src2_modifiers, VRegSrc_32:$src2,
250 highmod:$high, clampmod0:$clamp, omod0:$omod),
251 (ins Src0Mod:$src0_modifiers, VRegSrc_32:$src0,
252 Attr:$attr, AttrChan:$attrchan,
253 Src2Mod:$src2_modifiers, VRegSrc_32:$src2,
254 highmod:$high, clampmod0:$clamp)
256 (ins Src0Mod:$src0_modifiers, VRegSrc_32:$src0,
257 Attr:$attr, AttrChan:$attrchan,
258 highmod:$high, clampmod0:$clamp, omod0:$omod)
262 class VOP3_INTERP16 <list<ValueType> ArgVT> : VOPProfile<ArgVT> {
264 let HasOMod = !ne(DstVT.Value, f16.Value);
267 let Outs64 = (outs DstRC.RegClass:$vdst);
268 let Ins64 = getInterp16Ins<HasSrc2, HasOMod, Src0Mod, Src2Mod>.ret;
269 let Asm64 = getInterp16Asm<HasSrc2, HasOMod>.ret;
272 //===----------------------------------------------------------------------===//
274 //===----------------------------------------------------------------------===//
276 let isCommutable = 1 in {
278 let isReMaterializable = 1 in {
279 let mayRaiseFPException = 0 in {
280 let SubtargetPredicate = HasMadMacF32Insts in {
281 defm V_MAD_LEGACY_F32 : VOP3Inst <"v_mad_legacy_f32", VOP3_Profile<VOP_F32_F32_F32_F32>>;
282 defm V_MAD_F32 : VOP3Inst <"v_mad_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, fmad>;
283 } // End SubtargetPredicate = HasMadMacInsts
285 let SubtargetPredicate = HasFmaLegacy32 in
286 defm V_FMA_LEGACY_F32 : VOP3Inst <"v_fma_legacy_f32",
287 VOP3_Profile<VOP_F32_F32_F32_F32>,
288 int_amdgcn_fma_legacy>;
291 defm V_MAD_I32_I24 : VOP3Inst <"v_mad_i32_i24", VOP3_Profile<VOP_I32_I32_I32_I32, VOP3_CLAMP>>;
292 defm V_MAD_U32_U24 : VOP3Inst <"v_mad_u32_u24", VOP3_Profile<VOP_I32_I32_I32_I32, VOP3_CLAMP>>;
293 defm V_FMA_F32 : VOP3Inst <"v_fma_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, any_fma>;
294 defm V_LERP_U8 : VOP3Inst <"v_lerp_u8", VOP3_Profile<VOP_I32_I32_I32_I32>, int_amdgcn_lerp>;
296 let SchedRW = [WriteDoubleAdd] in {
297 let FPDPRounding = 1 in {
298 defm V_FMA_F64 : VOP3Inst <"v_fma_f64", VOP3_Profile<VOP_F64_F64_F64_F64>, any_fma>;
299 defm V_ADD_F64 : VOP3Inst <"v_add_f64", VOP3_Profile<VOP_F64_F64_F64>, any_fadd, 1>;
300 defm V_MUL_F64 : VOP3Inst <"v_mul_f64", VOP3_Profile<VOP_F64_F64_F64>, fmul, 1>;
301 } // End FPDPRounding = 1
302 defm V_MIN_F64 : VOP3Inst <"v_min_f64", VOP3_Profile<VOP_F64_F64_F64>, fminnum_like, 1>;
303 defm V_MAX_F64 : VOP3Inst <"v_max_f64", VOP3_Profile<VOP_F64_F64_F64>, fmaxnum_like, 1>;
304 } // End SchedRW = [WriteDoubleAdd]
306 let SchedRW = [WriteIntMul] in {
307 defm V_MUL_LO_U32 : VOP3Inst <"v_mul_lo_u32", VOP3_Profile<VOP_I32_I32_I32>, mul>;
308 defm V_MUL_HI_U32 : VOP3Inst <"v_mul_hi_u32", VOP3_Profile<VOP_I32_I32_I32>, mulhu>;
309 defm V_MUL_LO_I32 : VOP3Inst <"v_mul_lo_i32", VOP3_Profile<VOP_I32_I32_I32>>;
310 defm V_MUL_HI_I32 : VOP3Inst <"v_mul_hi_i32", VOP3_Profile<VOP_I32_I32_I32>, mulhs>;
311 } // End SchedRW = [WriteIntMul]
312 } // End isReMaterializable = 1
314 let Uses = [MODE, VCC, EXEC] in {
316 // result = src0 * src1 + src2
320 let SchedRW = [WriteFloatFMA] in
321 defm V_DIV_FMAS_F32 : VOP3Inst_Pseudo_Wrapper <"v_div_fmas_f32", VOP_F32_F32_F32_F32_VCC, []>;
323 // result = src0 * src1 + src2
327 let SchedRW = [WriteDouble], FPDPRounding = 1 in
328 defm V_DIV_FMAS_F64 : VOP3Inst_Pseudo_Wrapper <"v_div_fmas_f64", VOP_F64_F64_F64_F64_VCC, []>;
329 } // End Uses = [MODE, VCC, EXEC]
331 } // End isCommutable = 1
333 let isReMaterializable = 1 in {
334 let mayRaiseFPException = 0 in {
335 defm V_CUBEID_F32 : VOP3Inst <"v_cubeid_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, int_amdgcn_cubeid>;
336 defm V_CUBESC_F32 : VOP3Inst <"v_cubesc_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, int_amdgcn_cubesc>;
337 defm V_CUBETC_F32 : VOP3Inst <"v_cubetc_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, int_amdgcn_cubetc>;
338 defm V_CUBEMA_F32 : VOP3Inst <"v_cubema_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, int_amdgcn_cubema>;
339 } // End mayRaiseFPException
341 defm V_BFE_U32 : VOP3Inst <"v_bfe_u32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUbfe_u32>;
342 defm V_BFE_I32 : VOP3Inst <"v_bfe_i32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUbfe_i32>;
343 defm V_BFI_B32 : VOP3Inst <"v_bfi_b32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUbfi>;
344 defm V_ALIGNBIT_B32 : VOP3Inst <"v_alignbit_b32", VOP3_Profile<VOP_I32_I32_I32_I32>, fshr>;
345 defm V_ALIGNBYTE_B32 : VOP3Inst <"v_alignbyte_b32", VOP3_Profile<VOP_I32_I32_I32_I32>, int_amdgcn_alignbyte>;
347 // XXX - No FPException seems suspect but manual doesn't say it does
348 let mayRaiseFPException = 0 in {
349 let isCommutable = 1 in {
350 defm V_MIN3_I32 : VOP3Inst <"v_min3_i32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUsmin3>;
351 defm V_MIN3_U32 : VOP3Inst <"v_min3_u32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUumin3>;
352 defm V_MAX3_I32 : VOP3Inst <"v_max3_i32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUsmax3>;
353 defm V_MAX3_U32 : VOP3Inst <"v_max3_u32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUumax3>;
354 defm V_MED3_I32 : VOP3Inst <"v_med3_i32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUsmed3>;
355 defm V_MED3_U32 : VOP3Inst <"v_med3_u32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUumed3>;
356 } // End isCommutable = 1
357 defm V_MIN3_F32 : VOP3Inst <"v_min3_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, AMDGPUfmin3>;
358 defm V_MAX3_F32 : VOP3Inst <"v_max3_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, AMDGPUfmax3>;
359 defm V_MED3_F32 : VOP3Inst <"v_med3_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, AMDGPUfmed3>;
360 } // End mayRaiseFPException = 0
362 let isCommutable = 1 in {
363 defm V_SAD_U8 : VOP3Inst <"v_sad_u8", VOP3_Profile<VOP_I32_I32_I32_I32, VOP3_CLAMP>>;
364 defm V_SAD_HI_U8 : VOP3Inst <"v_sad_hi_u8", VOP3_Profile<VOP_I32_I32_I32_I32, VOP3_CLAMP>>;
365 defm V_SAD_U16 : VOP3Inst <"v_sad_u16", VOP3_Profile<VOP_I32_I32_I32_I32, VOP3_CLAMP>>;
366 defm V_SAD_U32 : VOP3Inst <"v_sad_u32", VOP3_Profile<VOP_I32_I32_I32_I32, VOP3_CLAMP>>;
367 } // End isCommutable = 1
368 defm V_CVT_PK_U8_F32 : VOP3Inst<"v_cvt_pk_u8_f32", VOP3_Profile<VOP_I32_F32_I32_I32>, int_amdgcn_cvt_pk_u8_f32>;
370 defm V_DIV_FIXUP_F32 : VOP3Inst <"v_div_fixup_f32", VOP3_Profile<VOP_F32_F32_F32_F32>, AMDGPUdiv_fixup>;
372 let SchedRW = [WriteDoubleAdd], FPDPRounding = 1 in {
373 defm V_DIV_FIXUP_F64 : VOP3Inst <"v_div_fixup_f64", VOP3_Profile<VOP_F64_F64_F64_F64>, AMDGPUdiv_fixup>;
374 defm V_LDEXP_F64 : VOP3Inst <"v_ldexp_f64", VOP3_Profile<VOP_F64_F64_I32>, AMDGPUldexp, 1>;
375 } // End SchedRW = [WriteDoubleAdd], FPDPRounding = 1
376 } // End isReMaterializable = 1
379 let mayRaiseFPException = 0 in { // Seems suspicious but manual doesn't say it does.
380 let SchedRW = [WriteFloatFMA, WriteSALU] in
381 defm V_DIV_SCALE_F32 : VOP3Inst_Pseudo_Wrapper <"v_div_scale_f32", VOP3b_F32_I1_F32_F32_F32, [], 1> ;
383 // Double precision division pre-scale.
384 let SchedRW = [WriteDouble, WriteSALU], FPDPRounding = 1 in
385 defm V_DIV_SCALE_F64 : VOP3Inst_Pseudo_Wrapper <"v_div_scale_f64", VOP3b_F64_I1_F64_F64_F64, [], 1>;
386 } // End mayRaiseFPException = 0
388 let isReMaterializable = 1 in
389 defm V_MSAD_U8 : VOP3Inst <"v_msad_u8", VOP3_Profile<VOP_I32_I32_I32_I32, VOP3_CLAMP>>;
391 let Constraints = "@earlyclobber $vdst" in {
392 defm V_MQSAD_PK_U16_U8 : VOP3Inst <"v_mqsad_pk_u16_u8", VOP3_Profile<VOP_I64_I64_I32_I64, VOP3_CLAMP>>;
393 } // End Constraints = "@earlyclobber $vdst"
396 let isReMaterializable = 1 in {
397 let SchedRW = [WriteDouble] in {
398 defm V_TRIG_PREOP_F64 : VOP3Inst <"v_trig_preop_f64", VOP3_Profile<VOP_F64_F64_I32>, int_amdgcn_trig_preop>;
399 } // End SchedRW = [WriteDouble]
401 let SchedRW = [Write64Bit] in {
402 let SubtargetPredicate = isGFX6GFX7 in {
403 defm V_LSHL_B64 : VOP3Inst <"v_lshl_b64", VOP3_Profile<VOP_I64_I64_I32>, shl>;
404 defm V_LSHR_B64 : VOP3Inst <"v_lshr_b64", VOP3_Profile<VOP_I64_I64_I32>, srl>;
405 defm V_ASHR_I64 : VOP3Inst <"v_ashr_i64", VOP3_Profile<VOP_I64_I64_I32>, sra>;
406 } // End SubtargetPredicate = isGFX6GFX7
408 let SubtargetPredicate = isGFX8Plus in {
409 defm V_LSHLREV_B64 : VOP3Inst <"v_lshlrev_b64", VOP3_Profile<VOP_I64_I32_I64>, lshl_rev>;
410 defm V_LSHRREV_B64 : VOP3Inst <"v_lshrrev_b64", VOP3_Profile<VOP_I64_I32_I64>, lshr_rev>;
411 defm V_ASHRREV_I64 : VOP3Inst <"v_ashrrev_i64", VOP3_Profile<VOP_I64_I32_I64>, ashr_rev>;
412 } // End SubtargetPredicate = isGFX8Plus
413 } // End SchedRW = [Write64Bit]
414 } // End isReMaterializable = 1
417 (i32 (getDivergentFrag<sext>.ret i16:$src)),
418 (i32 (V_BFE_I32_e64 $src, (S_MOV_B32 (i32 0)), (S_MOV_B32 (i32 0x10))))
421 let isReMaterializable = 1 in {
422 let SubtargetPredicate = isGFX6GFX7GFX10 in {
423 defm V_MULLIT_F32 : VOP3Inst <"v_mullit_f32", VOP3_Profile<VOP_F32_F32_F32_F32>>;
424 } // End SubtargetPredicate = isGFX6GFX7GFX10
426 let SchedRW = [Write32Bit] in {
427 let SubtargetPredicate = isGFX8Plus in {
428 defm V_PERM_B32 : VOP3Inst <"v_perm_b32", VOP3_Profile<VOP_I32_I32_I32_I32>, AMDGPUperm>;
429 } // End SubtargetPredicate = isGFX8Plus
430 } // End SchedRW = [Write32Bit]
431 } // End isReMaterializable = 1
433 let SubtargetPredicate = isGFX7Plus in {
435 let Constraints = "@earlyclobber $vdst", SchedRW = [WriteQuarterRate32] in {
436 defm V_QSAD_PK_U16_U8 : VOP3Inst <"v_qsad_pk_u16_u8", VOP3_Profile<VOP_I64_I64_I32_I64, VOP3_CLAMP>>;
437 defm V_MQSAD_U32_U8 : VOP3Inst <"v_mqsad_u32_u8", VOP3_Profile<VOP_V4I32_I64_I32_V4I32, VOP3_CLAMP>>;
438 } // End Constraints = "@earlyclobber $vdst", SchedRW = [WriteQuarterRate32]
440 let isCommutable = 1 in {
441 let SchedRW = [WriteIntMul, WriteSALU] in {
442 defm V_MAD_U64_U32 : VOP3Inst <"v_mad_u64_u32", VOP3b_I64_I1_I32_I32_I64>;
443 defm V_MAD_I64_I32 : VOP3Inst <"v_mad_i64_i32", VOP3b_I64_I1_I32_I32_I64>;
444 } // End SchedRW = [WriteIntMul, WriteSALU]
445 } // End isCommutable = 1
447 } // End SubtargetPredicate = isGFX7Plus
449 let FPDPRounding = 1 in {
450 let Predicates = [Has16BitInsts, isGFX8Only] in {
451 defm V_DIV_FIXUP_F16 : VOP3Inst <"v_div_fixup_f16", VOP3_Profile<VOP_F16_F16_F16_F16>, AMDGPUdiv_fixup>;
452 defm V_FMA_F16 : VOP3Inst <"v_fma_f16", VOP3_Profile<VOP_F16_F16_F16_F16>, any_fma>;
453 } // End Predicates = [Has16BitInsts, isGFX8Only]
455 let renamedInGFX9 = 1, Predicates = [Has16BitInsts, isGFX9Plus] in {
456 defm V_DIV_FIXUP_F16_gfx9 : VOP3Inst <"v_div_fixup_f16_gfx9",
457 VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>, AMDGPUdiv_fixup>;
458 defm V_FMA_F16_gfx9 : VOP3Inst <"v_fma_f16_gfx9", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>, any_fma>;
459 } // End renamedInGFX9 = 1, Predicates = [Has16BitInsts, isGFX9Plus]
460 } // End FPDPRounding = 1
462 let SubtargetPredicate = Has16BitInsts, isCommutable = 1 in {
464 let renamedInGFX9 = 1 in {
465 defm V_MAD_U16 : VOP3Inst <"v_mad_u16", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_CLAMP>>;
466 defm V_MAD_I16 : VOP3Inst <"v_mad_i16", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_CLAMP>>;
467 let FPDPRounding = 1 in {
468 defm V_MAD_F16 : VOP3Inst <"v_mad_f16", VOP3_Profile<VOP_F16_F16_F16_F16>, fmad>;
469 let Uses = [MODE, M0, EXEC] in {
470 let OtherPredicates = [isNotGFX90APlus] in
471 // For some reason the intrinsic operands are in a different order
472 // from the instruction operands.
473 def V_INTERP_P2_F16 : VOP3Interp <"v_interp_p2_f16", VOP3_INTERP16<[f16, f32, i32, f32]>,
475 (int_amdgcn_interp_p2_f16 (VOP3Mods f32:$src2, i32:$src2_modifiers),
476 (VOP3Mods f32:$src0, i32:$src0_modifiers),
477 (i32 timm:$attrchan),
481 } // End Uses = [M0, MODE, EXEC]
482 } // End FPDPRounding = 1
483 } // End renamedInGFX9 = 1
485 let SubtargetPredicate = isGFX9Only, FPDPRounding = 1 in {
486 defm V_MAD_F16_gfx9 : VOP3Inst <"v_mad_f16_gfx9", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>> ;
487 } // End SubtargetPredicate = isGFX9Only, FPDPRounding = 1
489 let SubtargetPredicate = isGFX9Plus in {
490 defm V_MAD_U16_gfx9 : VOP3Inst <"v_mad_u16_gfx9", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_OPSEL>>;
491 defm V_MAD_I16_gfx9 : VOP3Inst <"v_mad_i16_gfx9", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_OPSEL>>;
492 let OtherPredicates = [isNotGFX90APlus] in
493 def V_INTERP_P2_F16_gfx9 : VOP3Interp <"v_interp_p2_f16_gfx9", VOP3_INTERP16<[f16, f32, i32, f32]>>;
494 } // End SubtargetPredicate = isGFX9Plus
496 // This predicate should only apply to the selection pattern. The
497 // instruction still exists and should decode on subtargets with
498 // other bank counts.
499 let OtherPredicates = [isNotGFX90APlus, has32BankLDS], Uses = [MODE, M0, EXEC], FPDPRounding = 1 in {
500 def V_INTERP_P1LL_F16 : VOP3Interp <"v_interp_p1ll_f16", VOP3_INTERP16<[f32, f32, i32, untyped]>,
501 [(set f32:$vdst, (int_amdgcn_interp_p1_f16 (VOP3Mods f32:$src0, i32:$src0_modifiers),
502 (i32 timm:$attrchan),
504 (i1 timm:$high), M0))]>;
505 } // End OtherPredicates = [isNotGFX90APlus, has32BankLDS], Uses = [MODE, M0, EXEC], FPDPRounding = 1
507 let OtherPredicates = [isNotGFX90APlus], Uses = [MODE, M0, EXEC], FPDPRounding = 1 in {
508 def V_INTERP_P1LV_F16 : VOP3Interp <"v_interp_p1lv_f16", VOP3_INTERP16<[f32, f32, i32, f16]>>;
509 } // End OtherPredicates = [isNotGFX90APlus], Uses = [MODE, M0, EXEC], FPDPRounding = 1
511 } // End SubtargetPredicate = Has16BitInsts, isCommutable = 1
514 (i64 (getDivergentFrag<sext>.ret i16:$src)),
515 (REG_SEQUENCE VReg_64,
516 (i32 (V_BFE_I32_e64 $src, (S_MOV_B32 (i32 0)), (S_MOV_B32 (i32 0x10)))), sub0,
517 (i32 (COPY_TO_REGCLASS
518 (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))))
522 let SubtargetPredicate = isGFX8Plus, Uses = [MODE, M0, EXEC], OtherPredicates = [isNotGFX90APlus] in {
523 def V_INTERP_P1_F32_e64 : VOP3Interp <"v_interp_p1_f32", VOP3_INTERP>;
524 def V_INTERP_P2_F32_e64 : VOP3Interp <"v_interp_p2_f32", VOP3_INTERP>;
525 def V_INTERP_MOV_F32_e64 : VOP3Interp <"v_interp_mov_f32", VOP3_INTERP_MOV>;
526 } // End SubtargetPredicate = isGFX8Plus, Uses = [MODE, M0, EXEC], OtherPredicates = [isNotGFX90APlus]
528 let Predicates = [Has16BitInsts, isGFX6GFX7GFX8GFX9] in {
530 multiclass Ternary_i16_Pats <SDPatternOperator op1, SDPatternOperator op2,
531 Instruction inst, SDPatternOperator op3> {
533 (op2 (op1 i16:$src0, i16:$src1), i16:$src2),
534 (inst i16:$src0, i16:$src1, i16:$src2, (i1 0))
539 defm: Ternary_i16_Pats<mul, add, V_MAD_U16_e64, zext>;
540 defm: Ternary_i16_Pats<mul, add, V_MAD_I16_e64, sext>;
542 } // End Predicates = [Has16BitInsts, isGFX6GFX7GFX8GFX9]
544 let Predicates = [Has16BitInsts, isGFX10Plus] in {
546 multiclass Ternary_i16_Pats_gfx9<SDPatternOperator op1, SDPatternOperator op2,
547 Instruction inst, SDPatternOperator op3> {
549 (op2 (op1 i16:$src0, i16:$src1), i16:$src2),
550 (inst SRCMODS.NONE, $src0, SRCMODS.NONE, $src1, SRCMODS.NONE, $src2, DSTCLAMP.NONE)
555 defm: Ternary_i16_Pats_gfx9<mul, add, V_MAD_U16_gfx9_e64, zext>;
556 defm: Ternary_i16_Pats_gfx9<mul, add, V_MAD_I16_gfx9_e64, sext>;
558 } // End Predicates = [Has16BitInsts, isGFX10Plus]
560 class ThreeOpFrag<SDPatternOperator op1, SDPatternOperator op2> : PatFrag<
561 (ops node:$x, node:$y, node:$z),
562 // When the inner operation is used multiple times, selecting 3-op
563 // instructions may still be beneficial -- if the other users can be
564 // combined similarly. Let's be conservative for now.
565 (op2 (HasOneUseBinOp<op1> node:$x, node:$y), node:$z),
567 // Only use VALU ops when the result is divergent.
568 if (!N->isDivergent())
571 // Check constant bus limitations.
573 // Note: Use !isDivergent as a conservative proxy for whether the value
574 // is in an SGPR (uniform values can end up in VGPRs as well).
575 unsigned ConstantBusUses = 0;
576 for (unsigned i = 0; i < 3; ++i) {
577 if (!Operands[i]->isDivergent() &&
578 !isInlineImmediate(Operands[i].getNode())) {
580 // This uses AMDGPU::V_ADD3_U32_e64, but all three operand instructions
581 // have the same constant bus limit.
582 if (ConstantBusUses > Subtarget->getConstantBusLimit(AMDGPU::V_ADD3_U32_e64))
589 let PredicateCodeUsesOperands = 1;
591 // The divergence predicate is irrelevant in GlobalISel, as we have
592 // proper register bank checks. We just need to verify the constant
593 // bus restriction when all the sources are considered.
595 // FIXME: With unlucky SGPR operands, we could penalize code by
596 // blocking folding SGPR->VGPR copies later.
597 // FIXME: There's no register bank verifier
598 let GISelPredicateCode = [{
599 const int ConstantBusLimit = Subtarget->getConstantBusLimit(AMDGPU::V_ADD3_U32_e64);
600 int ConstantBusUses = 0;
601 for (unsigned i = 0; i < 3; ++i) {
602 const RegisterBank *RegBank = RBI.getRegBank(Operands[i]->getReg(), MRI, TRI);
603 if (RegBank->getID() == AMDGPU::SGPRRegBankID) {
604 if (++ConstantBusUses > ConstantBusLimit)
612 let SubtargetPredicate = isGFX9Plus in {
613 let isCommutable = 1, isReMaterializable = 1 in {
614 defm V_ADD3_U32 : VOP3Inst <"v_add3_u32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
615 defm V_AND_OR_B32 : VOP3Inst <"v_and_or_b32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
616 defm V_OR3_B32 : VOP3Inst <"v_or3_b32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
617 defm V_XAD_U32 : VOP3Inst <"v_xad_u32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
618 defm V_ADD_I32 : VOP3Inst <"v_add_i32", VOP3_Profile<VOP_I32_I32_I32_ARITH>>;
619 defm V_ADD_LSHL_U32 : VOP3Inst <"v_add_lshl_u32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
620 } // End isCommutable = 1, isReMaterializable = 1
621 // TODO src0 contains the opsel bit for dst, so if we commute, need to mask and swap this
623 defm V_MED3_F16 : VOP3Inst <"v_med3_f16", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>, AMDGPUfmed3>;
624 defm V_MED3_I16 : VOP3Inst <"v_med3_i16", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_OPSEL>, AMDGPUsmed3>;
625 defm V_MED3_U16 : VOP3Inst <"v_med3_u16", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_OPSEL>, AMDGPUumed3>;
627 defm V_MIN3_F16 : VOP3Inst <"v_min3_f16", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>, AMDGPUfmin3>;
628 defm V_MIN3_I16 : VOP3Inst <"v_min3_i16", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_OPSEL>, AMDGPUsmin3>;
629 defm V_MIN3_U16 : VOP3Inst <"v_min3_u16", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_OPSEL>, AMDGPUumin3>;
631 defm V_MAX3_F16 : VOP3Inst <"v_max3_f16", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>, AMDGPUfmax3>;
632 defm V_MAX3_I16 : VOP3Inst <"v_max3_i16", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_OPSEL>, AMDGPUsmax3>;
633 defm V_MAX3_U16 : VOP3Inst <"v_max3_u16", VOP3_Profile<VOP_I16_I16_I16_I16, VOP3_OPSEL>, AMDGPUumax3>;
635 defm V_ADD_I16 : VOP3Inst <"v_add_i16", VOP3_Profile<VOP_I16_I16_I16, VOP3_OPSEL>>;
636 defm V_SUB_I16 : VOP3Inst <"v_sub_i16", VOP3_Profile<VOP_I16_I16_I16, VOP3_OPSEL>>;
638 defm V_MAD_U32_U16 : VOP3Inst <"v_mad_u32_u16", VOP3_Profile<VOP_I32_I16_I16_I32, VOP3_OPSEL>>;
639 defm V_MAD_I32_I16 : VOP3Inst <"v_mad_i32_i16", VOP3_Profile<VOP_I32_I16_I16_I32, VOP3_OPSEL>>;
641 defm V_CVT_PKNORM_I16_F16 : VOP3Inst <"v_cvt_pknorm_i16_f16", VOP3_Profile<VOP_B32_F16_F16, VOP3_OPSEL>>;
642 defm V_CVT_PKNORM_U16_F16 : VOP3Inst <"v_cvt_pknorm_u16_f16", VOP3_Profile<VOP_B32_F16_F16, VOP3_OPSEL>>;
644 defm V_PACK_B32_F16 : VOP3Inst <"v_pack_b32_f16", VOP3_Profile<VOP_B32_F16_F16, VOP3_OPSEL>>;
646 let isReMaterializable = 1 in {
647 defm V_SUB_I32 : VOP3Inst <"v_sub_i32", VOP3_Profile<VOP_I32_I32_I32_ARITH>>;
648 defm V_LSHL_ADD_U32 : VOP3Inst <"v_lshl_add_u32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
649 defm V_LSHL_OR_B32 : VOP3Inst <"v_lshl_or_b32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
650 } // End isReMaterializable = 1
653 class ThreeOp_i32_Pats <SDPatternOperator op1, SDPatternOperator op2, Instruction inst> : GCNPat <
654 // This matches (op2 (op1 i32:$src0, i32:$src1), i32:$src2) with conditions.
655 (ThreeOpFrag<op1, op2> i32:$src0, i32:$src1, i32:$src2),
656 (inst VSrc_b32:$src0, VSrc_b32:$src1, VSrc_b32:$src2)
659 def : ThreeOp_i32_Pats<shl, add, V_LSHL_ADD_U32_e64>;
660 def : ThreeOp_i32_Pats<add, shl, V_ADD_LSHL_U32_e64>;
661 def : ThreeOp_i32_Pats<add, add, V_ADD3_U32_e64>;
662 def : ThreeOp_i32_Pats<shl, or, V_LSHL_OR_B32_e64>;
663 def : ThreeOp_i32_Pats<and, or, V_AND_OR_B32_e64>;
664 def : ThreeOp_i32_Pats<or, or, V_OR3_B32_e64>;
665 def : ThreeOp_i32_Pats<xor, add, V_XAD_U32_e64>;
667 def : VOPBinOpClampPat<saddsat, V_ADD_I32_e64, i32>;
668 def : VOPBinOpClampPat<ssubsat, V_SUB_I32_e64, i32>;
671 // FIXME: Probably should hardcode clamp bit in pseudo and avoid this.
672 class OpSelBinOpClampPat<SDPatternOperator node,
673 Instruction inst> : GCNPat<
674 (node (i16 (VOP3OpSel i16:$src0, i32:$src0_modifiers)),
675 (i16 (VOP3OpSel i16:$src1, i32:$src1_modifiers))),
676 (inst $src0_modifiers, $src0, $src1_modifiers, $src1, DSTCLAMP.ENABLE, 0)
679 def : OpSelBinOpClampPat<saddsat, V_ADD_I16_e64>;
680 def : OpSelBinOpClampPat<ssubsat, V_SUB_I16_e64>;
681 } // End SubtargetPredicate = isGFX9Plus
683 def VOP3_PERMLANE_Profile : VOP3_Profile<VOPProfile <[i32, i32, i32, i32]>, VOP3_OPSEL> {
684 let Src0RC64 = VRegSrc_32;
685 let Src1RC64 = SCSrc_b32;
686 let Src2RC64 = SCSrc_b32;
687 let InsVOP3OpSel = (ins IntOpSelMods:$src0_modifiers, VRegSrc_32:$src0,
688 IntOpSelMods:$src1_modifiers, SCSrc_b32:$src1,
689 IntOpSelMods:$src2_modifiers, SCSrc_b32:$src2,
690 VGPR_32:$vdst_in, op_sel0:$op_sel);
694 class PermlanePat<SDPatternOperator permlane,
695 Instruction inst> : GCNPat<
696 (permlane i32:$vdst_in, i32:$src0, i32:$src1, i32:$src2,
698 (inst (as_i1timm $fi), VGPR_32:$src0, (as_i1timm $bc),
699 SCSrc_b32:$src1, 0, SCSrc_b32:$src2, VGPR_32:$vdst_in)
702 // Permlane intrinsic that has either fetch invalid or bound control
704 class BoundControlOrFetchInvalidPermlane<SDPatternOperator permlane> :
705 PatFrag<(ops node:$vdst_in, node:$src0, node:$src1, node:$src2,
707 (permlane node:$vdst_in, node:$src0, node:
708 $src1, node:$src2, node:$fi, node:$bc)> {
709 let PredicateCode = [{ return N->getConstantOperandVal(5) != 0 ||
710 N->getConstantOperandVal(6) != 0; }];
711 let GISelPredicateCode = [{
712 return MI.getOperand(6).getImm() != 0 ||
713 MI.getOperand(7).getImm() != 0;
717 // Drop the input value if it won't be read.
718 class PermlaneDiscardVDstIn<SDPatternOperator permlane,
719 Instruction inst> : GCNPat<
720 (permlane srcvalue, i32:$src0, i32:$src1, i32:$src2,
722 (inst (as_i1timm $fi), VGPR_32:$src0, (as_i1timm $bc),
723 SCSrc_b32:$src1, 0, SCSrc_b32:$src2,
728 let SubtargetPredicate = isGFX10Plus in {
729 let isCommutable = 1, isReMaterializable = 1 in {
730 defm V_XOR3_B32 : VOP3Inst <"v_xor3_b32", VOP3_Profile<VOP_I32_I32_I32_I32>>;
731 } // End isCommutable = 1, isReMaterializable = 1
732 def : ThreeOp_i32_Pats<xor, xor, V_XOR3_B32_e64>;
734 let Constraints = "$vdst = $vdst_in", DisableEncoding="$vdst_in" in {
735 defm V_PERMLANE16_B32 : VOP3Inst<"v_permlane16_b32", VOP3_PERMLANE_Profile>;
736 defm V_PERMLANEX16_B32 : VOP3Inst<"v_permlanex16_b32", VOP3_PERMLANE_Profile>;
737 } // End $vdst = $vdst_in, DisableEncoding $vdst_in
739 def : PermlanePat<int_amdgcn_permlane16, V_PERMLANE16_B32_e64>;
740 def : PermlanePat<int_amdgcn_permlanex16, V_PERMLANEX16_B32_e64>;
742 def : PermlaneDiscardVDstIn<
743 BoundControlOrFetchInvalidPermlane<int_amdgcn_permlane16>,
744 V_PERMLANE16_B32_e64>;
745 def : PermlaneDiscardVDstIn<
746 BoundControlOrFetchInvalidPermlane<int_amdgcn_permlanex16>,
747 V_PERMLANEX16_B32_e64>;
748 } // End SubtargetPredicate = isGFX10Plus
750 class DivFmasPat<ValueType vt, Instruction inst, Register CondReg> : GCNPat<
751 (AMDGPUdiv_fmas (vt (VOP3Mods vt:$src0, i32:$src0_modifiers)),
752 (vt (VOP3Mods vt:$src1, i32:$src1_modifiers)),
753 (vt (VOP3Mods vt:$src2, i32:$src2_modifiers)),
755 (inst $src0_modifiers, $src0, $src1_modifiers, $src1, $src2_modifiers, $src2)
758 let WaveSizePredicate = isWave64 in {
759 def : DivFmasPat<f32, V_DIV_FMAS_F32_e64, VCC>;
760 def : DivFmasPat<f64, V_DIV_FMAS_F64_e64, VCC>;
763 let WaveSizePredicate = isWave32 in {
764 def : DivFmasPat<f32, V_DIV_FMAS_F32_e64, VCC_LO>;
765 def : DivFmasPat<f64, V_DIV_FMAS_F64_e64, VCC_LO>;
768 //===----------------------------------------------------------------------===//
769 // Integer Clamp Patterns
770 //===----------------------------------------------------------------------===//
772 class getClampPat<VOPProfile P, SDPatternOperator node> {
773 dag ret3 = (P.DstVT (node P.Src0VT:$src0, P.Src1VT:$src1, P.Src2VT:$src2));
774 dag ret2 = (P.DstVT (node P.Src0VT:$src0, P.Src1VT:$src1));
775 dag ret1 = (P.DstVT (node P.Src0VT:$src0));
776 dag ret = !if(!eq(P.NumSrcArgs, 3), ret3,
777 !if(!eq(P.NumSrcArgs, 2), ret2,
781 class getClampRes<VOPProfile P, Instruction inst> {
782 dag ret3 = (inst P.Src0VT:$src0, P.Src1VT:$src1, P.Src2VT:$src2, (i1 0));
783 dag ret2 = (inst P.Src0VT:$src0, P.Src1VT:$src1, (i1 0));
784 dag ret1 = (inst P.Src0VT:$src0, (i1 0));
785 dag ret = !if(!eq(P.NumSrcArgs, 3), ret3,
786 !if(!eq(P.NumSrcArgs, 2), ret2,
790 class IntClampPat<VOP3InstBase inst, SDPatternOperator node> : GCNPat<
791 getClampPat<inst.Pfl, node>.ret,
792 getClampRes<inst.Pfl, inst>.ret
795 def : IntClampPat<V_MAD_I32_I24_e64, AMDGPUmad_i24>;
796 def : IntClampPat<V_MAD_U32_U24_e64, AMDGPUmad_u24>;
798 def : IntClampPat<V_SAD_U8_e64, int_amdgcn_sad_u8>;
799 def : IntClampPat<V_SAD_HI_U8_e64, int_amdgcn_sad_hi_u8>;
800 def : IntClampPat<V_SAD_U16_e64, int_amdgcn_sad_u16>;
802 def : IntClampPat<V_MSAD_U8_e64, int_amdgcn_msad_u8>;
803 def : IntClampPat<V_MQSAD_PK_U16_U8_e64, int_amdgcn_mqsad_pk_u16_u8>;
805 def : IntClampPat<V_QSAD_PK_U16_U8_e64, int_amdgcn_qsad_pk_u16_u8>;
806 def : IntClampPat<V_MQSAD_U32_U8_e64, int_amdgcn_mqsad_u32_u8>;
809 //===----------------------------------------------------------------------===//
810 // Target-specific instruction encodings.
811 //===----------------------------------------------------------------------===//
813 //===----------------------------------------------------------------------===//
815 //===----------------------------------------------------------------------===//
817 let AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10" in {
818 multiclass VOP3_Real_gfx10<bits<10> op> {
820 VOP3_Real<!cast<VOP_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX10>,
821 VOP3e_gfx10<op, !cast<VOP_Pseudo>(NAME#"_e64").Pfl>;
823 multiclass VOP3_Real_No_Suffix_gfx10<bits<10> op> {
825 VOP3_Real<!cast<VOP_Pseudo>(NAME), SIEncodingFamily.GFX10>,
826 VOP3e_gfx10<op, !cast<VOP_Pseudo>(NAME).Pfl>;
828 multiclass VOP3_Real_gfx10_with_name<bits<10> op, string opName,
831 VOP3_Real<!cast<VOP3_Pseudo>(opName#"_e64"), SIEncodingFamily.GFX10>,
832 VOP3e_gfx10<op, !cast<VOP3_Pseudo>(opName#"_e64").Pfl> {
833 VOP3_Pseudo ps = !cast<VOP3_Pseudo>(opName#"_e64");
834 let AsmString = asmName # ps.AsmOperands;
838 multiclass VOP3be_Real_gfx10<bits<10> op> {
840 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX10>,
841 VOP3be_gfx10<op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
843 multiclass VOP3Interp_Real_gfx10<bits<10> op> {
845 VOP3_Real<!cast<VOP3_Pseudo>(NAME), SIEncodingFamily.GFX10>,
846 VOP3Interp_gfx10<op, !cast<VOP3_Pseudo>(NAME).Pfl>;
848 multiclass VOP3OpSel_Real_gfx10<bits<10> op> {
850 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX10>,
851 VOP3OpSel_gfx10<op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
853 multiclass VOP3OpSel_Real_gfx10_with_name<bits<10> op, string opName,
856 VOP3_Real<!cast<VOP3_Pseudo>(opName#"_e64"), SIEncodingFamily.GFX10>,
857 VOP3OpSel_gfx10<op, !cast<VOP3_Pseudo>(opName#"_e64").Pfl> {
858 VOP3_Pseudo ps = !cast<VOP3_Pseudo>(opName#"_e64");
859 let AsmString = asmName # ps.AsmOperands;
862 } // End AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10"
864 defm V_READLANE_B32 : VOP3_Real_No_Suffix_gfx10<0x360>;
866 let InOperandList = (ins SSrcOrLds_b32:$src0, SCSrc_b32:$src1, VGPR_32:$vdst_in) in {
867 defm V_WRITELANE_B32 : VOP3_Real_No_Suffix_gfx10<0x361>;
868 } // End InOperandList = (ins SSrcOrLds_b32:$src0, SCSrc_b32:$src1, VGPR_32:$vdst_in)
870 let SubtargetPredicate = isGFX10Before1030 in {
871 defm V_MUL_LO_I32 : VOP3_Real_gfx10<0x16b>;
874 defm V_XOR3_B32 : VOP3_Real_gfx10<0x178>;
875 defm V_LSHLREV_B64 : VOP3_Real_gfx10<0x2ff>;
876 defm V_LSHRREV_B64 : VOP3_Real_gfx10<0x300>;
877 defm V_ASHRREV_I64 : VOP3_Real_gfx10<0x301>;
878 defm V_PERM_B32 : VOP3_Real_gfx10<0x344>;
879 defm V_XAD_U32 : VOP3_Real_gfx10<0x345>;
880 defm V_LSHL_ADD_U32 : VOP3_Real_gfx10<0x346>;
881 defm V_ADD_LSHL_U32 : VOP3_Real_gfx10<0x347>;
882 defm V_ADD3_U32 : VOP3_Real_gfx10<0x36d>;
883 defm V_LSHL_OR_B32 : VOP3_Real_gfx10<0x36f>;
884 defm V_AND_OR_B32 : VOP3_Real_gfx10<0x371>;
885 defm V_OR3_B32 : VOP3_Real_gfx10<0x372>;
887 // TODO-GFX10: add MC tests for v_add/sub_nc_i16
889 VOP3OpSel_Real_gfx10_with_name<0x30d, "V_ADD_I16", "v_add_nc_i16">;
891 VOP3OpSel_Real_gfx10_with_name<0x30e, "V_SUB_I16", "v_sub_nc_i16">;
893 VOP3_Real_gfx10_with_name<0x376, "V_SUB_I32", "v_sub_nc_i32">;
895 VOP3_Real_gfx10_with_name<0x37f, "V_ADD_I32", "v_add_nc_i32">;
897 defm V_INTERP_P1_F32_e64 : VOP3Interp_Real_gfx10<0x200>;
898 defm V_INTERP_P2_F32_e64 : VOP3Interp_Real_gfx10<0x201>;
899 defm V_INTERP_MOV_F32_e64 : VOP3Interp_Real_gfx10<0x202>;
901 defm V_INTERP_P1LL_F16 : VOP3Interp_Real_gfx10<0x342>;
902 defm V_INTERP_P1LV_F16 : VOP3Interp_Real_gfx10<0x343>;
903 defm V_INTERP_P2_F16 : VOP3Interp_Real_gfx10<0x35a>;
905 defm V_PACK_B32_F16 : VOP3OpSel_Real_gfx10<0x311>;
906 defm V_CVT_PKNORM_I16_F16 : VOP3OpSel_Real_gfx10<0x312>;
907 defm V_CVT_PKNORM_U16_F16 : VOP3OpSel_Real_gfx10<0x313>;
909 defm V_MIN3_F16 : VOP3OpSel_Real_gfx10<0x351>;
910 defm V_MIN3_I16 : VOP3OpSel_Real_gfx10<0x352>;
911 defm V_MIN3_U16 : VOP3OpSel_Real_gfx10<0x353>;
912 defm V_MAX3_F16 : VOP3OpSel_Real_gfx10<0x354>;
913 defm V_MAX3_I16 : VOP3OpSel_Real_gfx10<0x355>;
914 defm V_MAX3_U16 : VOP3OpSel_Real_gfx10<0x356>;
915 defm V_MED3_F16 : VOP3OpSel_Real_gfx10<0x357>;
916 defm V_MED3_I16 : VOP3OpSel_Real_gfx10<0x358>;
917 defm V_MED3_U16 : VOP3OpSel_Real_gfx10<0x359>;
918 defm V_MAD_U32_U16 : VOP3OpSel_Real_gfx10<0x373>;
919 defm V_MAD_I32_I16 : VOP3OpSel_Real_gfx10<0x375>;
922 VOP3OpSel_Real_gfx10_with_name<0x340, "V_MAD_U16_gfx9", "v_mad_u16">;
924 VOP3OpSel_Real_gfx10_with_name<0x34b, "V_FMA_F16_gfx9", "v_fma_f16">;
926 VOP3OpSel_Real_gfx10_with_name<0x35e, "V_MAD_I16_gfx9", "v_mad_i16">;
927 defm V_DIV_FIXUP_F16 :
928 VOP3OpSel_Real_gfx10_with_name<0x35f, "V_DIV_FIXUP_F16_gfx9", "v_div_fixup_f16">;
930 // FIXME-GFX10-OPSEL: Need to add "selective" opsel support to some of these
931 // (they do not support SDWA or DPP).
932 defm V_ADD_NC_U16 : VOP3_Real_gfx10_with_name<0x303, "V_ADD_U16", "v_add_nc_u16">;
933 defm V_SUB_NC_U16 : VOP3_Real_gfx10_with_name<0x304, "V_SUB_U16", "v_sub_nc_u16">;
934 defm V_MUL_LO_U16 : VOP3_Real_gfx10_with_name<0x305, "V_MUL_LO_U16", "v_mul_lo_u16">;
935 defm V_LSHRREV_B16 : VOP3_Real_gfx10_with_name<0x307, "V_LSHRREV_B16", "v_lshrrev_b16">;
936 defm V_ASHRREV_I16 : VOP3_Real_gfx10_with_name<0x308, "V_ASHRREV_I16", "v_ashrrev_i16">;
937 defm V_MAX_U16 : VOP3_Real_gfx10_with_name<0x309, "V_MAX_U16", "v_max_u16">;
938 defm V_MAX_I16 : VOP3_Real_gfx10_with_name<0x30a, "V_MAX_I16", "v_max_i16">;
939 defm V_MIN_U16 : VOP3_Real_gfx10_with_name<0x30b, "V_MIN_U16", "v_min_u16">;
940 defm V_MIN_I16 : VOP3_Real_gfx10_with_name<0x30c, "V_MIN_I16", "v_min_i16">;
941 defm V_LSHLREV_B16 : VOP3_Real_gfx10_with_name<0x314, "V_LSHLREV_B16", "v_lshlrev_b16">;
942 defm V_PERMLANE16_B32 : VOP3OpSel_Real_gfx10<0x377>;
943 defm V_PERMLANEX16_B32 : VOP3OpSel_Real_gfx10<0x378>;
945 //===----------------------------------------------------------------------===//
947 //===----------------------------------------------------------------------===//
949 let AssemblerPredicate = isGFX7Only, DecoderNamespace = "GFX7" in {
950 multiclass VOP3_Real_gfx7<bits<10> op> {
952 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.SI>,
953 VOP3e_gfx6_gfx7<op{8-0}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
955 multiclass VOP3be_Real_gfx7<bits<10> op> {
957 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.SI>,
958 VOP3be_gfx6_gfx7<op{8-0}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
960 } // End AssemblerPredicate = isGFX7Only, DecoderNamespace = "GFX7"
962 multiclass VOP3_Real_gfx7_gfx10<bits<10> op> :
963 VOP3_Real_gfx7<op>, VOP3_Real_gfx10<op>;
965 multiclass VOP3be_Real_gfx7_gfx10<bits<10> op> :
966 VOP3be_Real_gfx7<op>, VOP3be_Real_gfx10<op>;
968 defm V_QSAD_PK_U16_U8 : VOP3_Real_gfx7_gfx10<0x172>;
969 defm V_MQSAD_U32_U8 : VOP3_Real_gfx7_gfx10<0x175>;
970 defm V_MAD_U64_U32 : VOP3be_Real_gfx7_gfx10<0x176>;
971 defm V_MAD_I64_I32 : VOP3be_Real_gfx7_gfx10<0x177>;
973 //===----------------------------------------------------------------------===//
974 // GFX6, GFX7, GFX10.
975 //===----------------------------------------------------------------------===//
977 let AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" in {
978 multiclass VOP3_Real_gfx6_gfx7<bits<10> op> {
980 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.SI>,
981 VOP3e_gfx6_gfx7<op{8-0}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
983 multiclass VOP3be_Real_gfx6_gfx7<bits<10> op> {
985 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.SI>,
986 VOP3be_gfx6_gfx7<op{8-0}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
988 } // End AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7"
990 multiclass VOP3_Real_gfx6_gfx7_gfx10<bits<10> op> :
991 VOP3_Real_gfx6_gfx7<op>, VOP3_Real_gfx10<op>;
993 multiclass VOP3be_Real_gfx6_gfx7_gfx10<bits<10> op> :
994 VOP3be_Real_gfx6_gfx7<op>, VOP3be_Real_gfx10<op>;
996 defm V_LSHL_B64 : VOP3_Real_gfx6_gfx7<0x161>;
997 defm V_LSHR_B64 : VOP3_Real_gfx6_gfx7<0x162>;
998 defm V_ASHR_I64 : VOP3_Real_gfx6_gfx7<0x163>;
999 defm V_MUL_LO_I32 : VOP3_Real_gfx6_gfx7<0x16b>;
1001 defm V_MAD_LEGACY_F32 : VOP3_Real_gfx6_gfx7_gfx10<0x140>;
1002 defm V_MAD_F32 : VOP3_Real_gfx6_gfx7_gfx10<0x141>;
1003 defm V_MAD_I32_I24 : VOP3_Real_gfx6_gfx7_gfx10<0x142>;
1004 defm V_MAD_U32_U24 : VOP3_Real_gfx6_gfx7_gfx10<0x143>;
1005 defm V_CUBEID_F32 : VOP3_Real_gfx6_gfx7_gfx10<0x144>;
1006 defm V_CUBESC_F32 : VOP3_Real_gfx6_gfx7_gfx10<0x145>;
1007 defm V_CUBETC_F32 : VOP3_Real_gfx6_gfx7_gfx10<0x146>;
1008 defm V_CUBEMA_F32 : VOP3_Real_gfx6_gfx7_gfx10<0x147>;
1009 defm V_BFE_U32 : VOP3_Real_gfx6_gfx7_gfx10<0x148>;
1010 defm V_BFE_I32 : VOP3_Real_gfx6_gfx7_gfx10<0x149>;
1011 defm V_BFI_B32 : VOP3_Real_gfx6_gfx7_gfx10<0x14a>;
1012 defm V_FMA_F32 : VOP3_Real_gfx6_gfx7_gfx10<0x14b>;
1013 defm V_FMA_F64 : VOP3_Real_gfx6_gfx7_gfx10<0x14c>;
1014 defm V_LERP_U8 : VOP3_Real_gfx6_gfx7_gfx10<0x14d>;
1015 defm V_ALIGNBIT_B32 : VOP3_Real_gfx6_gfx7_gfx10<0x14e>;
1016 defm V_ALIGNBYTE_B32 : VOP3_Real_gfx6_gfx7_gfx10<0x14f>;
1017 defm V_MULLIT_F32 : VOP3_Real_gfx6_gfx7_gfx10<0x150>;
1018 defm V_MIN3_F32 : VOP3_Real_gfx6_gfx7_gfx10<0x151>;
1019 defm V_MIN3_I32 : VOP3_Real_gfx6_gfx7_gfx10<0x152>;
1020 defm V_MIN3_U32 : VOP3_Real_gfx6_gfx7_gfx10<0x153>;
1021 defm V_MAX3_F32 : VOP3_Real_gfx6_gfx7_gfx10<0x154>;
1022 defm V_MAX3_I32 : VOP3_Real_gfx6_gfx7_gfx10<0x155>;
1023 defm V_MAX3_U32 : VOP3_Real_gfx6_gfx7_gfx10<0x156>;
1024 defm V_MED3_F32 : VOP3_Real_gfx6_gfx7_gfx10<0x157>;
1025 defm V_MED3_I32 : VOP3_Real_gfx6_gfx7_gfx10<0x158>;
1026 defm V_MED3_U32 : VOP3_Real_gfx6_gfx7_gfx10<0x159>;
1027 defm V_SAD_U8 : VOP3_Real_gfx6_gfx7_gfx10<0x15a>;
1028 defm V_SAD_HI_U8 : VOP3_Real_gfx6_gfx7_gfx10<0x15b>;
1029 defm V_SAD_U16 : VOP3_Real_gfx6_gfx7_gfx10<0x15c>;
1030 defm V_SAD_U32 : VOP3_Real_gfx6_gfx7_gfx10<0x15d>;
1031 defm V_CVT_PK_U8_F32 : VOP3_Real_gfx6_gfx7_gfx10<0x15e>;
1032 defm V_DIV_FIXUP_F32 : VOP3_Real_gfx6_gfx7_gfx10<0x15f>;
1033 defm V_DIV_FIXUP_F64 : VOP3_Real_gfx6_gfx7_gfx10<0x160>;
1034 defm V_ADD_F64 : VOP3_Real_gfx6_gfx7_gfx10<0x164>;
1035 defm V_MUL_F64 : VOP3_Real_gfx6_gfx7_gfx10<0x165>;
1036 defm V_MIN_F64 : VOP3_Real_gfx6_gfx7_gfx10<0x166>;
1037 defm V_MAX_F64 : VOP3_Real_gfx6_gfx7_gfx10<0x167>;
1038 defm V_LDEXP_F64 : VOP3_Real_gfx6_gfx7_gfx10<0x168>;
1039 defm V_MUL_LO_U32 : VOP3_Real_gfx6_gfx7_gfx10<0x169>;
1040 defm V_MUL_HI_U32 : VOP3_Real_gfx6_gfx7_gfx10<0x16a>;
1041 defm V_MUL_HI_I32 : VOP3_Real_gfx6_gfx7_gfx10<0x16c>;
1042 defm V_DIV_FMAS_F32 : VOP3_Real_gfx6_gfx7_gfx10<0x16f>;
1043 defm V_DIV_FMAS_F64 : VOP3_Real_gfx6_gfx7_gfx10<0x170>;
1044 defm V_MSAD_U8 : VOP3_Real_gfx6_gfx7_gfx10<0x171>;
1045 defm V_MQSAD_PK_U16_U8 : VOP3_Real_gfx6_gfx7_gfx10<0x173>;
1046 defm V_TRIG_PREOP_F64 : VOP3_Real_gfx6_gfx7_gfx10<0x174>;
1047 defm V_DIV_SCALE_F32 : VOP3be_Real_gfx6_gfx7_gfx10<0x16d>;
1048 defm V_DIV_SCALE_F64 : VOP3be_Real_gfx6_gfx7_gfx10<0x16e>;
1050 // NB: Same opcode as v_mad_legacy_f32
1051 let DecoderNamespace = "GFX10_B" in
1052 defm V_FMA_LEGACY_F32 : VOP3_Real_gfx10<0x140>;
1054 //===----------------------------------------------------------------------===//
1056 //===----------------------------------------------------------------------===//
1058 let AssemblerPredicate = isGFX8GFX9, DecoderNamespace = "GFX8" in {
1060 multiclass VOP3_Real_vi<bits<10> op> {
1061 def _vi : VOP3_Real<!cast<VOP_Pseudo>(NAME#"_e64"), SIEncodingFamily.VI>,
1062 VOP3e_vi <op, !cast<VOP_Pseudo>(NAME#"_e64").Pfl>;
1064 multiclass VOP3_Real_No_Suffix_vi<bits<10> op> {
1065 def _vi : VOP3_Real<!cast<VOP_Pseudo>(NAME), SIEncodingFamily.VI>,
1066 VOP3e_vi <op, !cast<VOP_Pseudo>(NAME).Pfl>;
1069 multiclass VOP3be_Real_vi<bits<10> op> {
1070 def _vi : VOP3_Real<!cast<VOP_Pseudo>(NAME#"_e64"), SIEncodingFamily.VI>,
1071 VOP3be_vi <op, !cast<VOP_Pseudo>(NAME#"_e64").Pfl>;
1074 multiclass VOP3OpSel_Real_gfx9<bits<10> op> {
1075 def _vi : VOP3_Real<!cast<VOP_Pseudo>(NAME#"_e64"), SIEncodingFamily.VI>,
1076 VOP3OpSel_gfx9 <op, !cast<VOP_Pseudo>(NAME#"_e64").Pfl>;
1079 multiclass VOP3Interp_Real_vi<bits<10> op> {
1080 def _vi : VOP3_Real<!cast<VOP_Pseudo>(NAME), SIEncodingFamily.VI>,
1081 VOP3Interp_vi <op, !cast<VOP_Pseudo>(NAME).Pfl>;
1084 } // End AssemblerPredicate = isGFX8GFX9, DecoderNamespace = "GFX8"
1086 let AssemblerPredicate = isGFX8Only, DecoderNamespace = "GFX8" in {
1088 multiclass VOP3_F16_Real_vi<bits<10> op> {
1089 def _vi : VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.VI>,
1090 VOP3e_vi <op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1093 multiclass VOP3Interp_F16_Real_vi<bits<10> op> {
1094 def _vi : VOP3_Real<!cast<VOP3_Pseudo>(NAME), SIEncodingFamily.VI>,
1095 VOP3Interp_vi <op, !cast<VOP3_Pseudo>(NAME).Pfl>;
1098 } // End AssemblerPredicate = isGFX8Only, DecoderNamespace = "GFX8"
1100 let AssemblerPredicate = isGFX9Only, DecoderNamespace = "GFX9" in {
1102 multiclass VOP3_F16_Real_gfx9<bits<10> op, string OpName, string AsmName> {
1103 def _gfx9 : VOP3_Real<!cast<VOP3_Pseudo>(OpName#"_e64"), SIEncodingFamily.GFX9>,
1104 VOP3e_vi <op, !cast<VOP3_Pseudo>(OpName#"_e64").Pfl> {
1105 VOP3_Pseudo ps = !cast<VOP3_Pseudo>(OpName#"_e64");
1106 let AsmString = AsmName # ps.AsmOperands;
1110 multiclass VOP3OpSel_F16_Real_gfx9<bits<10> op, string AsmName> {
1111 def _gfx9 : VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX9>,
1112 VOP3OpSel_gfx9 <op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl> {
1113 VOP3_Pseudo ps = !cast<VOP3_Pseudo>(NAME#"_e64");
1114 let AsmString = AsmName # ps.AsmOperands;
1118 multiclass VOP3Interp_F16_Real_gfx9<bits<10> op, string OpName, string AsmName> {
1119 def _gfx9 : VOP3_Real<!cast<VOP3_Pseudo>(OpName), SIEncodingFamily.GFX9>,
1120 VOP3Interp_vi <op, !cast<VOP3_Pseudo>(OpName).Pfl> {
1121 VOP3_Pseudo ps = !cast<VOP3_Pseudo>(OpName);
1122 let AsmString = AsmName # ps.AsmOperands;
1126 multiclass VOP3_Real_gfx9<bits<10> op, string AsmName> {
1127 def _gfx9 : VOP3_Real<!cast<VOP_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX9>,
1128 VOP3e_vi <op, !cast<VOP_Pseudo>(NAME#"_e64").Pfl> {
1129 VOP_Pseudo ps = !cast<VOP_Pseudo>(NAME#"_e64");
1130 let AsmString = AsmName # ps.AsmOperands;
1134 } // End AssemblerPredicate = isGFX9Only, DecoderNamespace = "GFX9"
1136 defm V_MAD_U64_U32 : VOP3be_Real_vi <0x1E8>;
1137 defm V_MAD_I64_I32 : VOP3be_Real_vi <0x1E9>;
1139 defm V_MAD_LEGACY_F32 : VOP3_Real_vi <0x1c0>;
1140 defm V_MAD_F32 : VOP3_Real_vi <0x1c1>;
1141 defm V_MAD_I32_I24 : VOP3_Real_vi <0x1c2>;
1142 defm V_MAD_U32_U24 : VOP3_Real_vi <0x1c3>;
1143 defm V_CUBEID_F32 : VOP3_Real_vi <0x1c4>;
1144 defm V_CUBESC_F32 : VOP3_Real_vi <0x1c5>;
1145 defm V_CUBETC_F32 : VOP3_Real_vi <0x1c6>;
1146 defm V_CUBEMA_F32 : VOP3_Real_vi <0x1c7>;
1147 defm V_BFE_U32 : VOP3_Real_vi <0x1c8>;
1148 defm V_BFE_I32 : VOP3_Real_vi <0x1c9>;
1149 defm V_BFI_B32 : VOP3_Real_vi <0x1ca>;
1150 defm V_FMA_F32 : VOP3_Real_vi <0x1cb>;
1151 defm V_FMA_F64 : VOP3_Real_vi <0x1cc>;
1152 defm V_LERP_U8 : VOP3_Real_vi <0x1cd>;
1153 defm V_ALIGNBIT_B32 : VOP3_Real_vi <0x1ce>;
1154 defm V_ALIGNBYTE_B32 : VOP3_Real_vi <0x1cf>;
1155 defm V_MIN3_F32 : VOP3_Real_vi <0x1d0>;
1156 defm V_MIN3_I32 : VOP3_Real_vi <0x1d1>;
1157 defm V_MIN3_U32 : VOP3_Real_vi <0x1d2>;
1158 defm V_MAX3_F32 : VOP3_Real_vi <0x1d3>;
1159 defm V_MAX3_I32 : VOP3_Real_vi <0x1d4>;
1160 defm V_MAX3_U32 : VOP3_Real_vi <0x1d5>;
1161 defm V_MED3_F32 : VOP3_Real_vi <0x1d6>;
1162 defm V_MED3_I32 : VOP3_Real_vi <0x1d7>;
1163 defm V_MED3_U32 : VOP3_Real_vi <0x1d8>;
1164 defm V_SAD_U8 : VOP3_Real_vi <0x1d9>;
1165 defm V_SAD_HI_U8 : VOP3_Real_vi <0x1da>;
1166 defm V_SAD_U16 : VOP3_Real_vi <0x1db>;
1167 defm V_SAD_U32 : VOP3_Real_vi <0x1dc>;
1168 defm V_CVT_PK_U8_F32 : VOP3_Real_vi <0x1dd>;
1169 defm V_DIV_FIXUP_F32 : VOP3_Real_vi <0x1de>;
1170 defm V_DIV_FIXUP_F64 : VOP3_Real_vi <0x1df>;
1171 defm V_DIV_SCALE_F32 : VOP3be_Real_vi <0x1e0>;
1172 defm V_DIV_SCALE_F64 : VOP3be_Real_vi <0x1e1>;
1173 defm V_DIV_FMAS_F32 : VOP3_Real_vi <0x1e2>;
1174 defm V_DIV_FMAS_F64 : VOP3_Real_vi <0x1e3>;
1175 defm V_MSAD_U8 : VOP3_Real_vi <0x1e4>;
1176 defm V_QSAD_PK_U16_U8 : VOP3_Real_vi <0x1e5>;
1177 defm V_MQSAD_PK_U16_U8 : VOP3_Real_vi <0x1e6>;
1178 defm V_MQSAD_U32_U8 : VOP3_Real_vi <0x1e7>;
1180 defm V_PERM_B32 : VOP3_Real_vi <0x1ed>;
1182 defm V_MAD_F16 : VOP3_F16_Real_vi <0x1ea>;
1183 defm V_MAD_U16 : VOP3_F16_Real_vi <0x1eb>;
1184 defm V_MAD_I16 : VOP3_F16_Real_vi <0x1ec>;
1185 defm V_FMA_F16 : VOP3_F16_Real_vi <0x1ee>;
1186 defm V_DIV_FIXUP_F16 : VOP3_F16_Real_vi <0x1ef>;
1187 defm V_INTERP_P2_F16 : VOP3Interp_F16_Real_vi <0x276>;
1189 let FPDPRounding = 1 in {
1190 defm V_MAD_LEGACY_F16 : VOP3_F16_Real_gfx9 <0x1ea, "V_MAD_F16", "v_mad_legacy_f16">;
1191 defm V_FMA_LEGACY_F16 : VOP3_F16_Real_gfx9 <0x1ee, "V_FMA_F16", "v_fma_legacy_f16">;
1192 defm V_DIV_FIXUP_LEGACY_F16 : VOP3_F16_Real_gfx9 <0x1ef, "V_DIV_FIXUP_F16", "v_div_fixup_legacy_f16">;
1193 defm V_INTERP_P2_LEGACY_F16 : VOP3Interp_F16_Real_gfx9 <0x276, "V_INTERP_P2_F16", "v_interp_p2_legacy_f16">;
1194 } // End FPDPRounding = 1
1196 defm V_MAD_LEGACY_U16 : VOP3_F16_Real_gfx9 <0x1eb, "V_MAD_U16", "v_mad_legacy_u16">;
1197 defm V_MAD_LEGACY_I16 : VOP3_F16_Real_gfx9 <0x1ec, "V_MAD_I16", "v_mad_legacy_i16">;
1199 defm V_MAD_F16_gfx9 : VOP3OpSel_F16_Real_gfx9 <0x203, "v_mad_f16">;
1200 defm V_MAD_U16_gfx9 : VOP3OpSel_F16_Real_gfx9 <0x204, "v_mad_u16">;
1201 defm V_MAD_I16_gfx9 : VOP3OpSel_F16_Real_gfx9 <0x205, "v_mad_i16">;
1202 defm V_FMA_F16_gfx9 : VOP3OpSel_F16_Real_gfx9 <0x206, "v_fma_f16">;
1203 defm V_DIV_FIXUP_F16_gfx9 : VOP3OpSel_F16_Real_gfx9 <0x207, "v_div_fixup_f16">;
1204 defm V_INTERP_P2_F16_gfx9 : VOP3Interp_F16_Real_gfx9 <0x277, "V_INTERP_P2_F16_gfx9", "v_interp_p2_f16">;
1206 defm V_ADD_I32 : VOP3_Real_vi <0x29c>;
1207 defm V_SUB_I32 : VOP3_Real_vi <0x29d>;
1209 defm V_INTERP_P1_F32_e64 : VOP3Interp_Real_vi <0x270>;
1210 defm V_INTERP_P2_F32_e64 : VOP3Interp_Real_vi <0x271>;
1211 defm V_INTERP_MOV_F32_e64 : VOP3Interp_Real_vi <0x272>;
1213 defm V_INTERP_P1LL_F16 : VOP3Interp_Real_vi <0x274>;
1214 defm V_INTERP_P1LV_F16 : VOP3Interp_Real_vi <0x275>;
1215 defm V_ADD_F64 : VOP3_Real_vi <0x280>;
1216 defm V_MUL_F64 : VOP3_Real_vi <0x281>;
1217 defm V_MIN_F64 : VOP3_Real_vi <0x282>;
1218 defm V_MAX_F64 : VOP3_Real_vi <0x283>;
1219 defm V_LDEXP_F64 : VOP3_Real_vi <0x284>;
1220 defm V_MUL_LO_U32 : VOP3_Real_vi <0x285>;
1222 // removed from VI as identical to V_MUL_LO_U32
1223 let isAsmParserOnly = 1 in {
1224 defm V_MUL_LO_I32 : VOP3_Real_vi <0x285>;
1227 defm V_MUL_HI_U32 : VOP3_Real_vi <0x286>;
1228 defm V_MUL_HI_I32 : VOP3_Real_vi <0x287>;
1230 defm V_READLANE_B32 : VOP3_Real_No_Suffix_vi <0x289>;
1231 defm V_WRITELANE_B32 : VOP3_Real_No_Suffix_vi <0x28a>;
1233 defm V_LSHLREV_B64 : VOP3_Real_vi <0x28f>;
1234 defm V_LSHRREV_B64 : VOP3_Real_vi <0x290>;
1235 defm V_ASHRREV_I64 : VOP3_Real_vi <0x291>;
1236 defm V_TRIG_PREOP_F64 : VOP3_Real_vi <0x292>;
1238 defm V_LSHL_ADD_U32 : VOP3_Real_vi <0x1fd>;
1239 defm V_ADD_LSHL_U32 : VOP3_Real_vi <0x1fe>;
1240 defm V_ADD3_U32 : VOP3_Real_vi <0x1ff>;
1241 defm V_LSHL_OR_B32 : VOP3_Real_vi <0x200>;
1242 defm V_AND_OR_B32 : VOP3_Real_vi <0x201>;
1243 defm V_OR3_B32 : VOP3_Real_vi <0x202>;
1244 defm V_PACK_B32_F16 : VOP3OpSel_Real_gfx9 <0x2a0>;
1246 defm V_XAD_U32 : VOP3_Real_vi <0x1f3>;
1248 defm V_MIN3_F16 : VOP3OpSel_Real_gfx9 <0x1f4>;
1249 defm V_MIN3_I16 : VOP3OpSel_Real_gfx9 <0x1f5>;
1250 defm V_MIN3_U16 : VOP3OpSel_Real_gfx9 <0x1f6>;
1252 defm V_MAX3_F16 : VOP3OpSel_Real_gfx9 <0x1f7>;
1253 defm V_MAX3_I16 : VOP3OpSel_Real_gfx9 <0x1f8>;
1254 defm V_MAX3_U16 : VOP3OpSel_Real_gfx9 <0x1f9>;
1256 defm V_MED3_F16 : VOP3OpSel_Real_gfx9 <0x1fa>;
1257 defm V_MED3_I16 : VOP3OpSel_Real_gfx9 <0x1fb>;
1258 defm V_MED3_U16 : VOP3OpSel_Real_gfx9 <0x1fc>;
1260 defm V_ADD_I16 : VOP3OpSel_Real_gfx9 <0x29e>;
1261 defm V_SUB_I16 : VOP3OpSel_Real_gfx9 <0x29f>;
1263 defm V_MAD_U32_U16 : VOP3OpSel_Real_gfx9 <0x1f1>;
1264 defm V_MAD_I32_I16 : VOP3OpSel_Real_gfx9 <0x1f2>;
1266 defm V_CVT_PKNORM_I16_F16 : VOP3OpSel_Real_gfx9 <0x299>;
1267 defm V_CVT_PKNORM_U16_F16 : VOP3OpSel_Real_gfx9 <0x29a>;