2 //===-- VOP1Instructions.td - Vector Instruction Definitions --------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
14 class VOP1e <bits<8> op, VOPProfile P> : Enc32 {
18 let Inst{8-0} = !if(P.HasSrc0, src0{8-0}, ?);
20 let Inst{24-17} = !if(P.EmitDst, vdst{7-0}, 0);
21 let Inst{31-25} = 0x3f; //encoding
24 class VOP1_SDWAe <bits<8> op, VOPProfile P> : VOP_SDWAe <P> {
27 let Inst{8-0} = 0xf9; // sdwa
29 let Inst{24-17} = !if(P.EmitDst, vdst{7-0}, 0);
30 let Inst{31-25} = 0x3f; // encoding
33 class VOP1_SDWA9Ae <bits<8> op, VOPProfile P> : VOP_SDWA9Ae <P> {
36 let Inst{8-0} = 0xf9; // sdwa
38 let Inst{24-17} = !if(P.EmitDst, vdst{7-0}, 0);
39 let Inst{31-25} = 0x3f; // encoding
42 class VOP1_Pseudo <string opName, VOPProfile P, list<dag> pattern=[], bit VOP1Only = 0> :
43 VOP_Pseudo <opName, !if(VOP1Only, "", "_e32"), P, P.Outs32, P.Ins32, "", pattern> {
45 let AsmOperands = P.Asm32;
50 let hasSideEffects = 0;
52 let ReadsModeReg = !or(P.DstVT.isFP, P.Src0VT.isFP);
54 let mayRaiseFPException = ReadsModeReg;
58 let Uses = !if(ReadsModeReg, [MODE, EXEC], [EXEC]);
60 let AsmVariantName = AMDGPUAsmVariants.Default;
63 class VOP1_Real <VOP1_Pseudo ps, int EncodingFamily, string real_name = ps.Mnemonic > :
65 InstSI <ps.OutOperandList, ps.InOperandList, real_name # ps.AsmOperands, []>,
66 SIMCInstr <ps.PseudoInstr, EncodingFamily> {
71 let isCodeGenOnly = 0;
73 let Constraints = ps.Constraints;
74 let DisableEncoding = ps.DisableEncoding;
76 // copy relevant pseudo op flags
77 let SubtargetPredicate = ps.SubtargetPredicate;
78 let OtherPredicates = ps.OtherPredicates;
79 let AsmMatchConverter = ps.AsmMatchConverter;
80 let AsmVariantName = ps.AsmVariantName;
81 let Constraints = ps.Constraints;
82 let DisableEncoding = ps.DisableEncoding;
83 let TSFlags = ps.TSFlags;
84 let UseNamedOperandTable = ps.UseNamedOperandTable;
87 let SchedRW = ps.SchedRW;
88 let mayLoad = ps.mayLoad;
89 let mayStore = ps.mayStore;
93 class VOP1_Real_Gen <VOP1_Pseudo ps, GFXGen Gen, string real_name = ps.Mnemonic> :
94 VOP1_Real <ps, Gen.Subtarget, real_name> {
95 let AssemblerPredicate = Gen.AssemblerPredicate;
96 let DecoderNamespace = Gen.DecoderNamespace;
99 class VOP1_SDWA_Pseudo <string OpName, VOPProfile P, list<dag> pattern=[]> :
100 VOP_SDWA_Pseudo <OpName, P, pattern> {
101 let AsmMatchConverter = "cvtSdwaVOP1";
104 class VOP1_DPP_Pseudo <string OpName, VOPProfile P, list<dag> pattern=[]> :
105 VOP_DPP_Pseudo <OpName, P, pattern> {
108 class getVOP1Pat <SDPatternOperator node, VOPProfile P> : LetDummies {
111 [(set P.DstVT:$vdst, (node (P.Src0VT (VOP3Mods P.Src0VT:$src0, i32:$src0_modifiers))))],
113 [(set P.DstVT:$vdst, (node (P.Src0VT (VOP3OMods P.Src0VT:$src0,
114 i1:$clamp, i32:$omod))))],
115 [(set P.DstVT:$vdst, (node (P.Src0VT P.Src0RC32:$src0)))]
120 multiclass VOP1Inst <string opName, VOPProfile P,
121 SDPatternOperator node = null_frag, int VOPDOp = -1> {
122 // We only want to set this on the basic, non-SDWA or DPP forms.
123 defvar should_mov_imm = !or(!eq(opName, "v_mov_b32"),
124 !eq(opName, "v_mov_b64"));
126 let isMoveImm = should_mov_imm in {
127 if !eq(VOPDOp, -1) then
128 def _e32 : VOP1_Pseudo <opName, P>;
130 // Only for V_MOV_B32
131 def _e32 : VOP1_Pseudo <opName, P>, VOPD_Component<VOPDOp, opName>;
132 def _e64 : VOP3InstBase <opName, P, node>;
136 def _sdwa : VOP1_SDWA_Pseudo <opName, P>;
139 def _dpp : VOP1_DPP_Pseudo <opName, P>;
141 let SubtargetPredicate = isGFX11Plus in {
142 if P.HasExtVOP3DPP then
143 def _e64_dpp : VOP3_DPP_Pseudo <opName, P>;
144 } // End SubtargetPredicate = isGFX11Plus
146 def : LetDummies, AMDGPUMnemonicAlias<opName#"_e32", opName>;
147 def : LetDummies, AMDGPUMnemonicAlias<opName#"_e64", opName>;
150 def : LetDummies, AMDGPUMnemonicAlias<opName#"_sdwa", opName>;
153 def : LetDummies, AMDGPUMnemonicAlias<opName#"_dpp", opName, AMDGPUAsmVariants.DPP>;
156 multiclass VOP1Inst_t16_with_profiles<string opName,
160 SDPatternOperator node = null_frag> {
161 let OtherPredicates = [NotHasTrue16BitInsts, Has16BitInsts] in {
162 defm NAME : VOP1Inst<opName, P, node>;
164 let OtherPredicates = [UseRealTrue16Insts] in {
165 defm _t16 : VOP1Inst<opName#"_t16", P_t16, node>;
167 let OtherPredicates = [UseFakeTrue16Insts] in {
168 defm _fake16 : VOP1Inst<opName#"_fake16", P_fake16, node>;
172 multiclass VOP1Inst_t16<string opName, VOPProfile P,
173 SDPatternOperator node = null_frag> :
174 VOP1Inst_t16_with_profiles<opName, P, VOPProfile_True16<P>, VOPProfile_Fake16<P>, node>;
176 // Special profile for instructions which have clamp
177 // and output modifiers (but have no input modifiers)
178 class VOPProfileI2F<ValueType dstVt, ValueType srcVt> :
179 VOPProfile<[dstVt, srcVt, untyped, untyped]> {
181 let Ins64 = (ins Src0RC64:$src0, Clamp:$clamp, omod:$omod);
182 let InsVOP3Base = (ins Src0VOP3DPP:$src0, Clamp:$clamp, omod:$omod);
183 let AsmVOP3Base = "$vdst, $src0$clamp$omod";
185 let HasModifiers = 0;
189 class VOPProfileI2F_True16<ValueType dstVt, ValueType srcVt> :
190 VOPProfile_Fake16<VOPProfile<[dstVt, srcVt, untyped, untyped]>> {
192 let Ins64 = (ins Src0RC64:$src0, Clamp:$clamp, omod:$omod);
193 let InsVOP3Base = (ins Src0VOP3DPP:$src0, Clamp:$clamp, omod:$omod);
194 let AsmVOP3Base = "$vdst, $src0$clamp$omod";
196 let HasModifiers = 0;
200 def VOP1_F64_I32 : VOPProfileI2F <f64, i32>;
201 def VOP1_F32_I32 : VOPProfileI2F <f32, i32>;
202 def VOP1_F16_I16 : VOPProfileI2F <f16, i16>;
203 def VOP1_F16_I16_t16 : VOPProfileI2F_True16 <f16, i16>;
205 def VOP_NOP_PROFILE : VOPProfile <[untyped, untyped, untyped, untyped]>{
206 let HasExtVOP3DPP = 0;
209 // OMod clears exceptions when set. OMod was always an operand, but its
210 // now explicitly set.
211 class VOP_SPECIAL_OMOD_PROF<ValueType dstVt, ValueType srcVt> :
212 VOPProfile<[dstVt, srcVt, untyped, untyped]> {
216 def VOP_I32_F32_SPECIAL_OMOD : VOP_SPECIAL_OMOD_PROF<i32, f32>;
217 def VOP_I32_F64_SPECIAL_OMOD : VOP_SPECIAL_OMOD_PROF<i32, f64>;
218 def VOP_I16_F16_SPECIAL_OMOD : VOP_SPECIAL_OMOD_PROF<i16, f16>;
219 def VOP_I16_F16_SPECIAL_OMOD_t16 : VOPProfile_Fake16<VOP_I16_F16> {
223 //===----------------------------------------------------------------------===//
225 //===----------------------------------------------------------------------===//
227 defm V_NOP : VOP1Inst <"v_nop", VOP_NOP_PROFILE>;
229 def VOPProfile_MOV : VOPProfile <[i32, i32, untyped, untyped]> {
230 let InsVOPDX = (ins Src0RC32:$src0X);
231 let InsVOPDXDeferred = (ins VSrc_f32_Deferred:$src0X);
232 let InsVOPDY = (ins Src0RC32:$src0Y);
233 let InsVOPDYDeferred = (ins VSrc_f32_Deferred:$src0Y);
236 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
237 defm V_MOV_B32 : VOP1Inst <"v_mov_b32", VOPProfile_MOV, null_frag, 0x8>;
239 let SubtargetPredicate = isGFX940Plus, SchedRW = [Write64Bit] in
240 defm V_MOV_B64 : VOP1Inst <"v_mov_b64", VOP_I64_I64>;
241 } // End isMoveImm = 1
243 def VOP_READFIRSTLANE : VOPProfile <[i32, i32, untyped, untyped]> {
244 let DstRC = RegisterOperand<SReg_32>;
245 let Src0RC32 = VRegOrLdsSrc_32;
246 let Asm32 = " $vdst, $src0";
249 // FIXME: Specify SchedRW for READFIRSTLANE_B32
250 // TODO: There is VOP3 encoding also
251 def V_READFIRSTLANE_B32 : VOP1_Pseudo <"v_readfirstlane_b32", VOP_READFIRSTLANE,
253 let isConvergent = 1;
254 let IsInvalidSingleUseConsumer = 1;
257 foreach vt = Reg32Types.types in {
258 def : GCNPat<(vt (int_amdgcn_readfirstlane (vt VRegOrLdsSrc_32:$src0))),
259 (V_READFIRSTLANE_B32 (vt VRegOrLdsSrc_32:$src0))
263 let isReMaterializable = 1 in {
264 let SchedRW = [WriteDoubleCvt] in {
265 // OMod clears exceptions when set in this instruction
266 defm V_CVT_I32_F64 : VOP1Inst <"v_cvt_i32_f64", VOP_I32_F64_SPECIAL_OMOD, fp_to_sint>;
268 let mayRaiseFPException = 0 in {
269 defm V_CVT_F64_I32 : VOP1Inst <"v_cvt_f64_i32", VOP1_F64_I32, sint_to_fp>;
272 defm V_CVT_F32_F64 : VOP1Inst <"v_cvt_f32_f64", VOP_F32_F64, fpround>;
273 defm V_CVT_F64_F32 : VOP1Inst <"v_cvt_f64_f32", VOP_F64_F32, any_fpextend>;
274 // OMod clears exceptions when set in this instruction
275 defm V_CVT_U32_F64 : VOP1Inst <"v_cvt_u32_f64", VOP_I32_F64_SPECIAL_OMOD, fp_to_uint>;
277 let mayRaiseFPException = 0 in {
278 defm V_CVT_F64_U32 : VOP1Inst <"v_cvt_f64_u32", VOP1_F64_I32, uint_to_fp>;
281 } // End SchedRW = [WriteDoubleCvt]
283 let SchedRW = [WriteFloatCvt] in {
285 // XXX: Does this really not raise exceptions? The manual claims the
287 let mayRaiseFPException = 0 in {
288 defm V_CVT_F32_I32 : VOP1Inst <"v_cvt_f32_i32", VOP1_F32_I32, sint_to_fp>;
289 defm V_CVT_F32_U32 : VOP1Inst <"v_cvt_f32_u32", VOP1_F32_I32, uint_to_fp>;
292 // OMod clears exceptions when set in these 2 instructions
293 defm V_CVT_U32_F32 : VOP1Inst <"v_cvt_u32_f32", VOP_I32_F32_SPECIAL_OMOD, fp_to_uint>;
294 defm V_CVT_I32_F32 : VOP1Inst <"v_cvt_i32_f32", VOP_I32_F32_SPECIAL_OMOD, fp_to_sint>;
295 let FPDPRounding = 1, isReMaterializable = 0 in {
296 let OtherPredicates = [NotHasTrue16BitInsts] in
297 defm V_CVT_F16_F32 : VOP1Inst <"v_cvt_f16_f32", VOP_F16_F32, any_fpround>;
298 let OtherPredicates = [HasTrue16BitInsts] in
299 defm V_CVT_F16_F32_t16 : VOP1Inst <"v_cvt_f16_f32_t16", VOPProfile_Fake16<VOP_F16_F32>, any_fpround>;
300 } // End FPDPRounding = 1, isReMaterializable = 0
302 let OtherPredicates = [NotHasTrue16BitInsts] in
303 defm V_CVT_F32_F16 : VOP1Inst <"v_cvt_f32_f16", VOP_F32_F16, any_fpextend>;
304 let OtherPredicates = [HasTrue16BitInsts] in
305 defm V_CVT_F32_F16_t16 : VOP1Inst <"v_cvt_f32_f16_t16", VOPProfile_Fake16<VOP_F32_F16>, any_fpextend>;
307 let ReadsModeReg = 0, mayRaiseFPException = 0 in {
308 defm V_CVT_RPI_I32_F32 : VOP1Inst <"v_cvt_rpi_i32_f32", VOP_I32_F32, cvt_rpi_i32_f32>;
309 defm V_CVT_FLR_I32_F32 : VOP1Inst <"v_cvt_flr_i32_f32", VOP_I32_F32, cvt_flr_i32_f32>;
310 defm V_CVT_OFF_F32_I4 : VOP1Inst <"v_cvt_off_f32_i4", VOP1_F32_I32>;
311 } // End ReadsModeReg = 0, mayRaiseFPException = 0
312 } // End SchedRW = [WriteFloatCvt]
314 let ReadsModeReg = 0, mayRaiseFPException = 0 in {
315 defm V_CVT_F32_UBYTE0 : VOP1Inst <"v_cvt_f32_ubyte0", VOP1_F32_I32, AMDGPUcvt_f32_ubyte0>;
316 defm V_CVT_F32_UBYTE1 : VOP1Inst <"v_cvt_f32_ubyte1", VOP1_F32_I32, AMDGPUcvt_f32_ubyte1>;
317 defm V_CVT_F32_UBYTE2 : VOP1Inst <"v_cvt_f32_ubyte2", VOP1_F32_I32, AMDGPUcvt_f32_ubyte2>;
318 defm V_CVT_F32_UBYTE3 : VOP1Inst <"v_cvt_f32_ubyte3", VOP1_F32_I32, AMDGPUcvt_f32_ubyte3>;
319 } // ReadsModeReg = 0, mayRaiseFPException = 0
321 defm V_FRACT_F32 : VOP1Inst <"v_fract_f32", VOP_F32_F32, AMDGPUfract>;
322 defm V_TRUNC_F32 : VOP1Inst <"v_trunc_f32", VOP_F32_F32, ftrunc>;
323 defm V_CEIL_F32 : VOP1Inst <"v_ceil_f32", VOP_F32_F32, fceil>;
324 defm V_RNDNE_F32 : VOP1Inst <"v_rndne_f32", VOP_F32_F32, froundeven>;
325 defm V_FLOOR_F32 : VOP1Inst <"v_floor_f32", VOP_F32_F32, ffloor>;
327 let TRANS = 1, SchedRW = [WriteTrans32] in {
328 defm V_EXP_F32 : VOP1Inst <"v_exp_f32", VOP_F32_F32, AMDGPUexp>;
329 defm V_LOG_F32 : VOP1Inst <"v_log_f32", VOP_F32_F32, AMDGPUlog>;
330 defm V_RCP_F32 : VOP1Inst <"v_rcp_f32", VOP_F32_F32, AMDGPUrcp>;
331 defm V_RCP_IFLAG_F32 : VOP1Inst <"v_rcp_iflag_f32", VOP_F32_F32, AMDGPUrcp_iflag>;
332 defm V_RSQ_F32 : VOP1Inst <"v_rsq_f32", VOP_F32_F32, AMDGPUrsq>;
333 defm V_SQRT_F32 : VOP1Inst <"v_sqrt_f32", VOP_F32_F32, int_amdgcn_sqrt>;
334 } // End TRANS = 1, SchedRW = [WriteTrans32]
336 let TRANS = 1, SchedRW = [WriteTrans64] in {
337 defm V_RCP_F64 : VOP1Inst <"v_rcp_f64", VOP_F64_F64, AMDGPUrcp>;
338 defm V_RSQ_F64 : VOP1Inst <"v_rsq_f64", VOP_F64_F64, AMDGPUrsq>;
339 defm V_SQRT_F64 : VOP1Inst <"v_sqrt_f64", VOP_F64_F64, int_amdgcn_sqrt>;
340 } // End TRANS = 1, SchedRW = [WriteTrans64]
342 let TRANS = 1, SchedRW = [WriteTrans32] in {
343 defm V_SIN_F32 : VOP1Inst <"v_sin_f32", VOP_F32_F32, AMDGPUsin>;
344 defm V_COS_F32 : VOP1Inst <"v_cos_f32", VOP_F32_F32, AMDGPUcos>;
345 } // End TRANS = 1, SchedRW = [WriteTrans32]
347 defm V_NOT_B32 : VOP1Inst <"v_not_b32", VOP_I32_I32>;
348 defm V_BFREV_B32 : VOP1Inst <"v_bfrev_b32", VOP_I32_I32, DivergentUnaryFrag<bitreverse>>;
349 defm V_FFBH_U32 : VOP1Inst <"v_ffbh_u32", VOP_I32_I32, AMDGPUffbh_u32>;
350 defm V_FFBL_B32 : VOP1Inst <"v_ffbl_b32", VOP_I32_I32, AMDGPUffbl_b32>;
351 defm V_FFBH_I32 : VOP1Inst <"v_ffbh_i32", VOP_I32_I32, AMDGPUffbh_i32>;
353 let SchedRW = [WriteDoubleAdd] in {
354 defm V_FREXP_EXP_I32_F64 : VOP1Inst <"v_frexp_exp_i32_f64", VOP_I32_F64_SPECIAL_OMOD, int_amdgcn_frexp_exp>;
355 defm V_FREXP_MANT_F64 : VOP1Inst <"v_frexp_mant_f64", VOP_F64_F64, int_amdgcn_frexp_mant>;
356 let FPDPRounding = 1 in {
357 defm V_FRACT_F64 : VOP1Inst <"v_fract_f64", VOP_F64_F64, AMDGPUfract>;
358 } // End FPDPRounding = 1
359 } // End SchedRW = [WriteDoubleAdd]
361 defm V_FREXP_EXP_I32_F32 : VOP1Inst <"v_frexp_exp_i32_f32", VOP_I32_F32, int_amdgcn_frexp_exp>;
362 defm V_FREXP_MANT_F32 : VOP1Inst <"v_frexp_mant_f32", VOP_F32_F32, int_amdgcn_frexp_mant>;
363 } // End isReMaterializable = 1
365 defm V_CLREXCP : VOP1Inst <"v_clrexcp", VOP_NO_EXT<VOP_NONE>>;
367 // Restrict src0 to be VGPR
368 def VOP_MOVRELS : VOPProfile<[i32, i32, untyped, untyped]> {
369 let Src0RC32 = VRegSrc_32;
370 let Src0RC64 = VRegSrc_32;
371 let IsInvalidSingleUseConsumer = 1;
374 // Special case because there are no true output operands. Hack vdst
375 // to be a src operand. The custom inserter must add a tied implicit
376 // def and use of the super register since there seems to be no way to
377 // add an implicit def of a virtual register in tablegen.
378 class VOP_MOVREL<RegisterOperand Src1RC> : VOPProfile<[untyped, i32, untyped, untyped]> {
379 let Src0RC32 = VOPDstOperand<VGPR_32>;
380 let Src0RC64 = VOPDstOperand<VGPR_32>;
383 let Ins32 = (ins Src0RC32:$vdst, Src1RC:$src0);
384 let Ins64 = (ins Src0RC64:$vdst, Src1RC:$src0);
385 let Asm32 = getAsm32<1, 1>.ret;
387 let OutsSDWA = (outs Src0RC32:$vdst);
388 let InsSDWA = (ins Src0ModSDWA:$src0_modifiers, Src0SDWA:$src0,
389 Clamp:$clamp, dst_sel:$dst_sel, dst_unused:$dst_unused,
391 let AsmSDWA9 = getAsmSDWA9<1, 0, 1>.ret;
393 let OutsDPP = (outs Src0RC32:$vdst);
394 let InsDPP16 = (ins Src0RC32:$old, Src0RC32:$src0,
395 dpp_ctrl:$dpp_ctrl, DppRowMask:$row_mask,
396 DppBankMask:$bank_mask, DppBoundCtrl:$bound_ctrl, Dpp16FI:$fi);
397 let AsmDPP16 = getAsmDPP16<1, 1, 0>.ret;
398 let InsDPP8 = (ins Src0RC32:$old, Src0RC32:$src0, dpp8:$dpp8, Dpp8FI:$fi);
399 let AsmDPP8 = getAsmDPP8<1, 1, 0>.ret;
401 let OutsVOP3DPP = (outs Src0RC64:$vdst);
402 let InsVOP3DPP = getInsVOP3DPP<InsVOP3Base, Src0RC64, NumSrcArgs>.ret;
403 let InsVOP3DPP16 = getInsVOP3DPP16<InsVOP3Base, Src0RC64, NumSrcArgs>.ret;
404 let InsVOP3DPP8 = getInsVOP3DPP8<InsVOP3Base, Src0RC64, NumSrcArgs>.ret;
407 getAsmVOP3Base<NumSrcArgs, 1 /* HasDst */, HasClamp,
408 HasOpSel, HasOMod, IsVOP3P, HasModifiers,
409 HasModifiers, HasModifiers, HasModifiers>.ret;
412 let EmitDst = 1; // force vdst emission
415 let IsInvalidSingleUseProducer = 1 in {
416 def VOP_MOVRELD : VOP_MOVREL<VSrc_b32>;
417 def VOP_MOVRELSD : VOP_MOVREL<VRegSrc_32> {
418 let IsInvalidSingleUseConsumer = 1;
422 let SubtargetPredicate = HasMovrel, Uses = [M0, EXEC] in {
423 // v_movreld_b32 is a special case because the destination output
424 // register is really a source. It isn't actually read (but may be
425 // written), and is only to provide the base register to start
426 // indexing from. Tablegen seems to not let you define an implicit
427 // virtual register output for the super register being written into,
428 // so this must have an implicit def of the register added to it.
429 defm V_MOVRELD_B32 : VOP1Inst <"v_movreld_b32", VOP_MOVRELD>;
430 defm V_MOVRELS_B32 : VOP1Inst <"v_movrels_b32", VOP_MOVRELS>;
431 defm V_MOVRELSD_B32 : VOP1Inst <"v_movrelsd_b32", VOP_MOVRELSD>;
432 } // End Uses = [M0, EXEC]
434 let isReMaterializable = 1 in {
435 let SubtargetPredicate = isGFX6GFX7 in {
436 let TRANS = 1, SchedRW = [WriteTrans32] in {
437 defm V_LOG_CLAMP_F32 :
438 VOP1Inst<"v_log_clamp_f32", VOP_F32_F32, int_amdgcn_log_clamp>;
439 defm V_RCP_CLAMP_F32 :
440 VOP1Inst<"v_rcp_clamp_f32", VOP_F32_F32>;
441 defm V_RCP_LEGACY_F32 :
442 VOP1Inst<"v_rcp_legacy_f32", VOP_F32_F32, AMDGPUrcp_legacy>;
443 defm V_RSQ_CLAMP_F32 :
444 VOP1Inst<"v_rsq_clamp_f32", VOP_F32_F32, AMDGPUrsq_clamp>;
445 defm V_RSQ_LEGACY_F32 :
446 VOP1Inst<"v_rsq_legacy_f32", VOP_F32_F32, int_amdgcn_rsq_legacy>;
447 } // End TRANS = 1, SchedRW = [WriteTrans32]
449 let SchedRW = [WriteTrans64] in {
450 defm V_RCP_CLAMP_F64 :
451 VOP1Inst<"v_rcp_clamp_f64", VOP_F64_F64>;
452 defm V_RSQ_CLAMP_F64 :
453 VOP1Inst<"v_rsq_clamp_f64", VOP_F64_F64, AMDGPUrsq_clamp>;
454 } // End SchedRW = [WriteTrans64]
455 } // End SubtargetPredicate = isGFX6GFX7
457 let SubtargetPredicate = isGFX7GFX8GFX9 in {
458 let TRANS = 1, SchedRW = [WriteTrans32] in {
459 defm V_LOG_LEGACY_F32 : VOP1Inst<"v_log_legacy_f32", VOP_F32_F32>;
460 defm V_EXP_LEGACY_F32 : VOP1Inst<"v_exp_legacy_f32", VOP_F32_F32>;
461 } // End TRANS = 1, SchedRW = [WriteTrans32]
462 } // End SubtargetPredicate = isGFX7GFX8GFX9
464 let SubtargetPredicate = isGFX7Plus in {
465 let SchedRW = [WriteDoubleAdd] in {
466 defm V_TRUNC_F64 : VOP1Inst<"v_trunc_f64", VOP_F64_F64, ftrunc>;
467 defm V_CEIL_F64 : VOP1Inst<"v_ceil_f64", VOP_F64_F64, fceil>;
468 defm V_RNDNE_F64 : VOP1Inst<"v_rndne_f64", VOP_F64_F64, froundeven>;
469 defm V_FLOOR_F64 : VOP1Inst<"v_floor_f64", VOP_F64_F64, ffloor>;
470 } // End SchedRW = [WriteDoubleAdd]
471 } // End SubtargetPredicate = isGFX7Plus
472 } // End isReMaterializable = 1
474 let FPDPRounding = 1 in {
475 let OtherPredicates = [Has16BitInsts, NotHasTrue16BitInsts] in {
476 defm V_CVT_F16_U16 : VOP1Inst <"v_cvt_f16_u16", VOP1_F16_I16, uint_to_fp>;
477 defm V_CVT_F16_I16 : VOP1Inst <"v_cvt_f16_i16", VOP1_F16_I16, sint_to_fp>;
479 let OtherPredicates = [HasTrue16BitInsts] in {
480 defm V_CVT_F16_U16_t16 : VOP1Inst <"v_cvt_f16_u16_t16", VOP1_F16_I16_t16, uint_to_fp>;
481 defm V_CVT_F16_I16_t16 : VOP1Inst <"v_cvt_f16_i16_t16", VOP1_F16_I16_t16, sint_to_fp>;
483 } // End FPDPRounding = 1
484 // OMod clears exceptions when set in these two instructions
485 let OtherPredicates = [Has16BitInsts, NotHasTrue16BitInsts] in {
486 defm V_CVT_U16_F16 : VOP1Inst <"v_cvt_u16_f16", VOP_I16_F16_SPECIAL_OMOD, fp_to_uint>;
487 defm V_CVT_I16_F16 : VOP1Inst <"v_cvt_i16_f16", VOP_I16_F16_SPECIAL_OMOD, fp_to_sint>;
489 let OtherPredicates = [HasTrue16BitInsts] in {
490 defm V_CVT_U16_F16_t16 : VOP1Inst <"v_cvt_u16_f16_t16", VOP_I16_F16_SPECIAL_OMOD_t16, fp_to_uint>;
491 defm V_CVT_I16_F16_t16 : VOP1Inst <"v_cvt_i16_f16_t16", VOP_I16_F16_SPECIAL_OMOD_t16, fp_to_sint>;
493 let TRANS = 1, SchedRW = [WriteTrans32] in {
494 defm V_RCP_F16 : VOP1Inst_t16 <"v_rcp_f16", VOP_F16_F16, AMDGPUrcp>;
495 defm V_SQRT_F16 : VOP1Inst_t16 <"v_sqrt_f16", VOP_F16_F16, any_amdgcn_sqrt>;
496 defm V_RSQ_F16 : VOP1Inst_t16 <"v_rsq_f16", VOP_F16_F16, AMDGPUrsq>;
497 defm V_LOG_F16 : VOP1Inst_t16 <"v_log_f16", VOP_F16_F16, AMDGPUlogf16>;
498 defm V_EXP_F16 : VOP1Inst_t16 <"v_exp_f16", VOP_F16_F16, AMDGPUexpf16>;
499 defm V_SIN_F16 : VOP1Inst_t16 <"v_sin_f16", VOP_F16_F16, AMDGPUsin>;
500 defm V_COS_F16 : VOP1Inst_t16 <"v_cos_f16", VOP_F16_F16, AMDGPUcos>;
501 } // End TRANS = 1, SchedRW = [WriteTrans32]
502 defm V_FREXP_MANT_F16 : VOP1Inst_t16 <"v_frexp_mant_f16", VOP_F16_F16, int_amdgcn_frexp_mant>;
503 let OtherPredicates = [Has16BitInsts, NotHasTrue16BitInsts] in {
504 defm V_FREXP_EXP_I16_F16 : VOP1Inst <"v_frexp_exp_i16_f16", VOP_I16_F16_SPECIAL_OMOD, int_amdgcn_frexp_exp>;
506 let OtherPredicates = [HasTrue16BitInsts] in {
507 defm V_FREXP_EXP_I16_F16_t16 : VOP1Inst <"v_frexp_exp_i16_f16_t16", VOP_I16_F16_SPECIAL_OMOD_t16, int_amdgcn_frexp_exp>;
509 defm V_FLOOR_F16 : VOP1Inst_t16 <"v_floor_f16", VOP_F16_F16, ffloor>;
510 defm V_CEIL_F16 : VOP1Inst_t16 <"v_ceil_f16", VOP_F16_F16, fceil>;
511 defm V_TRUNC_F16 : VOP1Inst_t16 <"v_trunc_f16", VOP_F16_F16, ftrunc>;
512 defm V_RNDNE_F16 : VOP1Inst_t16 <"v_rndne_f16", VOP_F16_F16, froundeven>;
513 let FPDPRounding = 1 in {
514 defm V_FRACT_F16 : VOP1Inst_t16 <"v_fract_f16", VOP_F16_F16, AMDGPUfract>;
515 } // End FPDPRounding = 1
517 let OtherPredicates = [Has16BitInsts, NotHasTrue16BitInsts] in {
519 (f32 (f16_to_fp i16:$src)),
520 (V_CVT_F32_F16_e32 $src)
523 (i16 (AMDGPUfp_to_f16 f32:$src)),
524 (V_CVT_F16_F32_e32 $src)
527 let OtherPredicates = [HasTrue16BitInsts] in {
529 (f32 (f16_to_fp i16:$src)),
530 (V_CVT_F32_F16_t16_e32 $src)
533 (i16 (AMDGPUfp_to_f16 f32:$src)),
534 (V_CVT_F16_F32_t16_e32 $src)
538 def VOP_SWAP_I32 : VOPProfile<[i32, i32, untyped, untyped]> {
539 let Outs32 = (outs VGPR_32:$vdst, VRegSrc_32:$vdst1);
540 let Ins32 = (ins VRegSrc_32:$src0, VGPR_32:$src1);
541 let Asm32 = " $vdst, $src0";
544 let SubtargetPredicate = isGFX9Plus in {
545 def V_SWAP_B32 : VOP1_Pseudo<"v_swap_b32", VOP_SWAP_I32, [], 1> {
546 let Constraints = "$vdst = $src1, $vdst1 = $src0";
547 let DisableEncoding = "$vdst1,$src1";
548 let SchedRW = [Write64Bit, Write64Bit];
549 let IsInvalidSingleUseConsumer = 1;
552 let isReMaterializable = 1 in
553 defm V_SAT_PK_U8_I16 : VOP1Inst_t16<"v_sat_pk_u8_i16", VOP_I16_I32>;
555 let mayRaiseFPException = 0 in {
556 let OtherPredicates = [Has16BitInsts, NotHasTrue16BitInsts] in {
557 defm V_CVT_NORM_I16_F16 : VOP1Inst<"v_cvt_norm_i16_f16", VOP_I16_F16_SPECIAL_OMOD>;
558 defm V_CVT_NORM_U16_F16 : VOP1Inst<"v_cvt_norm_u16_f16", VOP_I16_F16_SPECIAL_OMOD>;
560 let OtherPredicates = [HasTrue16BitInsts] in {
561 defm V_CVT_NORM_I16_F16_t16 : VOP1Inst<"v_cvt_norm_i16_f16_t16", VOP_I16_F16_SPECIAL_OMOD_t16>;
562 defm V_CVT_NORM_U16_F16_t16 : VOP1Inst<"v_cvt_norm_u16_f16_t16", VOP_I16_F16_SPECIAL_OMOD_t16>;
564 } // End mayRaiseFPException = 0
565 } // End SubtargetPredicate = isGFX9Plus
567 let SubtargetPredicate = isGFX9Only in {
568 defm V_SCREEN_PARTITION_4SE_B32 : VOP1Inst <"v_screen_partition_4se_b32", VOP_I32_I32>;
569 } // End SubtargetPredicate = isGFX9Only
571 class VOPProfile_Base_CVT_F32_F8<ValueType vt> : VOPProfileI2F <vt, i32> {
576 let DstRCSDWA = getVALUDstForVT<vt>.ret;
577 let InsSDWA = (ins Bin32SDWAInputMods:$src0_modifiers, Src0SDWA:$src0,
578 Clamp:$clamp, omod:$omod, src0_sel:$src0_sel);
579 let AsmSDWA = "$vdst, $src0_modifiers$clamp$omod $src0_sel"; // No dst_sel
580 let AsmSDWA9 = AsmSDWA;
584 def VOPProfileCVT_F32_F8 : VOPProfile_Base_CVT_F32_F8 <f32>;
585 def VOPProfileCVT_PK_F32_F8 : VOPProfile_Base_CVT_F32_F8 <v2f32>;
587 let OtherPredicates = [HasFP8ConversionInsts], mayRaiseFPException = 0,
588 SchedRW = [WriteFloatCvt] in {
589 defm V_CVT_F32_FP8 : VOP1Inst<"v_cvt_f32_fp8", VOPProfileCVT_F32_F8>;
590 defm V_CVT_F32_BF8 : VOP1Inst<"v_cvt_f32_bf8", VOPProfileCVT_F32_F8>;
591 defm V_CVT_PK_F32_FP8 : VOP1Inst<"v_cvt_pk_f32_fp8", VOPProfileCVT_PK_F32_F8>;
592 defm V_CVT_PK_F32_BF8 : VOP1Inst<"v_cvt_pk_f32_bf8", VOPProfileCVT_PK_F32_F8>;
595 class Cvt_F32_F8_Pat<SDPatternOperator node, int index,
596 VOP1_SDWA_Pseudo inst_sdwa> : GCNPat<
597 (f32 (node i32:$src, index)),
598 (inst_sdwa 0, $src, 0, 0, index)
601 let SubtargetPredicate = isGFX9Only in {
602 let OtherPredicates = [HasCvtFP8VOP1Bug] in {
603 def : GCNPat<(f32 (int_amdgcn_cvt_f32_fp8 i32:$src, 0)),
604 (V_CVT_F32_FP8_sdwa 0, $src, 0, 0, 0)>;
605 def : GCNPat<(f32 (int_amdgcn_cvt_f32_bf8 i32:$src, 0)),
606 (V_CVT_F32_BF8_sdwa 0, $src, 0, 0, 0)>;
609 let OtherPredicates = [HasNoCvtFP8VOP1Bug] in {
610 def : GCNPat<(f32 (int_amdgcn_cvt_f32_fp8 i32:$src, 0)),
611 (V_CVT_F32_FP8_e32 $src)>;
612 def : GCNPat<(f32 (int_amdgcn_cvt_f32_bf8 i32:$src, 0)),
613 (V_CVT_F32_BF8_e32 $src)>;
616 foreach Index = [1, 2, 3] in {
617 def : Cvt_F32_F8_Pat<int_amdgcn_cvt_f32_fp8, Index, V_CVT_F32_FP8_sdwa>;
618 def : Cvt_F32_F8_Pat<int_amdgcn_cvt_f32_bf8, Index, V_CVT_F32_BF8_sdwa>;
620 } // End SubtargetPredicate = isGFX9Only
622 class Cvt_PK_F32_F8_Pat<SDPatternOperator node, int index,
623 VOP1_Pseudo inst_e32, VOP1_SDWA_Pseudo inst_sdwa> : GCNPat<
624 (v2f32 (node i32:$src, index)),
626 (inst_sdwa 0, $src, 0, 0, SDWA.WORD_1),
630 let SubtargetPredicate = isGFX9Only in {
631 foreach Index = [0, -1] in {
632 def : Cvt_PK_F32_F8_Pat<int_amdgcn_cvt_pk_f32_fp8, Index,
633 V_CVT_PK_F32_FP8_e32, V_CVT_PK_F32_FP8_sdwa>;
634 def : Cvt_PK_F32_F8_Pat<int_amdgcn_cvt_pk_f32_bf8, Index,
635 V_CVT_PK_F32_BF8_e32, V_CVT_PK_F32_BF8_sdwa>;
640 // Similar to VOPProfile_Base_CVT_F32_F8, but for VOP3 instructions.
641 def VOPProfile_Base_CVT_PK_F32_F8_OpSel : VOPProfileI2F <v2f32, i32> {
643 let HasExtVOP3DPP = 0;
646 class VOPProfile_Base_CVT_F_F8_ByteSel<ValueType DstVT> : VOPProfile<[DstVT, i32, untyped, untyped]> {
647 let IsFP8SrcByteSel = 1;
650 let HasExtVOP3DPP = 1;
654 let HasModifiers = 0;
656 defvar bytesel = (ins ByteSel:$byte_sel);
657 let Ins64 = !con(getIns64<Src0RC64, Src1RC64, Src2RC64, NumSrcArgs,
658 HasClamp, HasModifiers, HasSrc2Mods,
659 HasOMod, Src0Mod, Src1Mod, Src2Mod>.ret,
661 let InsVOP3Base = !con(getInsVOP3Base<Src0VOP3DPP, Src1VOP3DPP, Src2VOP3DPP,
662 NumSrcArgs, HasClamp, HasModifiers, HasSrc2Mods,
663 HasOMod, Src0ModVOP3DPP, Src1ModVOP3DPP,
664 Src2ModVOP3DPP, HasOpSel>.ret,
668 let SubtargetPredicate = isGFX12Plus, OtherPredicates = [HasFP8ConversionInsts],
669 mayRaiseFPException = 0, SchedRW = [WriteFloatCvt] in {
670 defm V_CVT_F32_FP8_OP_SEL : VOP1Inst<"v_cvt_f32_fp8_op_sel", VOPProfile_Base_CVT_F_F8_ByteSel<f32>>;
671 defm V_CVT_F32_BF8_OP_SEL : VOP1Inst<"v_cvt_f32_bf8_op_sel", VOPProfile_Base_CVT_F_F8_ByteSel<f32>>;
672 defm V_CVT_PK_F32_FP8_OP_SEL : VOP1Inst<"v_cvt_pk_f32_fp8_op_sel", VOPProfile_Base_CVT_PK_F32_F8_OpSel>;
673 defm V_CVT_PK_F32_BF8_OP_SEL : VOP1Inst<"v_cvt_pk_f32_bf8_op_sel", VOPProfile_Base_CVT_PK_F32_F8_OpSel>;
676 class Cvt_F_F8_Pat_ByteSel<SDPatternOperator node, VOP3_Pseudo inst> : GCNPat<
677 (node i32:$src0, timm:$byte_sel),
678 (inst $src0, (as_i32timm $byte_sel))
681 let SubtargetPredicate = isGFX12Plus, OtherPredicates = [HasFP8ConversionInsts] in {
682 def : Cvt_F_F8_Pat_ByteSel<int_amdgcn_cvt_f32_fp8, V_CVT_F32_FP8_OP_SEL_e64>;
683 def : Cvt_F_F8_Pat_ByteSel<int_amdgcn_cvt_f32_bf8, V_CVT_F32_BF8_OP_SEL_e64>;
686 class Cvt_PK_F32_F8_Pat_OpSel<SDPatternOperator node, int index,
687 VOP1_Pseudo inst_e32, VOP3_Pseudo inst_e64> : GCNPat<
688 (v2f32 (node i32:$src, index)),
690 (inst_e64 SRCMODS.OP_SEL_0, $src, 0, 0, SRCMODS.NONE),
694 let SubtargetPredicate = isGFX12Plus, OtherPredicates = [HasFP8ConversionInsts] in {
695 foreach Index = [0, -1] in {
696 def : Cvt_PK_F32_F8_Pat_OpSel<int_amdgcn_cvt_pk_f32_fp8, Index,
697 V_CVT_PK_F32_FP8_e32, V_CVT_PK_F32_FP8_OP_SEL_e64>;
698 def : Cvt_PK_F32_F8_Pat_OpSel<int_amdgcn_cvt_pk_f32_bf8, Index,
699 V_CVT_PK_F32_BF8_e32, V_CVT_PK_F32_BF8_OP_SEL_e64>;
703 let SubtargetPredicate = isGFX10Plus in {
704 defm V_PIPEFLUSH : VOP1Inst<"v_pipeflush", VOP_NO_EXT<VOP_NONE>>;
707 defm V_MOVRELSD_2_B32 :
708 VOP1Inst<"v_movrelsd_2_b32", VOP_MOVRELSD>;
710 def V_SWAPREL_B32 : VOP1_Pseudo<"v_swaprel_b32", VOP_SWAP_I32, [], 1> {
711 let Constraints = "$vdst = $src1, $vdst1 = $src0";
712 let DisableEncoding = "$vdst1,$src1";
713 let SchedRW = [Write64Bit, Write64Bit];
714 let IsInvalidSingleUseConsumer = 1;
715 let IsInvalidSingleUseProducer = 1;
718 } // End SubtargetPredicate = isGFX10Plus
720 def VOPProfileAccMov : VOP_NO_EXT<VOP_I32_I32> {
721 let DstRC = RegisterOperand<AGPR_32>;
722 let Src0RC32 = ARegSrc_32;
723 let Asm32 = " $vdst, $src0";
726 def V_ACCVGPR_MOV_B32 : VOP1_Pseudo<"v_accvgpr_mov_b32", VOPProfileAccMov, [], 1> {
727 let SubtargetPredicate = isGFX90APlus;
728 let isReMaterializable = 1;
729 let isAsCheapAsAMove = 1;
732 let SubtargetPredicate = isGFX11Plus in {
733 // Restrict src0 to be VGPR
734 def V_PERMLANE64_B32 : VOP1_Pseudo<"v_permlane64_b32", VOP_MOVRELS,
735 [], /*VOP1Only=*/ 1> {
736 let IsInvalidSingleUseConsumer = 1;
737 let IsInvalidSingleUseProducer = 1;
739 defm V_MOV_B16_t16 : VOP1Inst<"v_mov_b16_t16", VOPProfile_True16<VOP_I16_I16>>;
740 defm V_NOT_B16 : VOP1Inst_t16<"v_not_b16", VOP_I16_I16>;
741 defm V_CVT_I32_I16 : VOP1Inst_t16<"v_cvt_i32_i16", VOP_I32_I16>;
742 defm V_CVT_U32_U16 : VOP1Inst_t16<"v_cvt_u32_u16", VOP_I32_I16>;
743 } // End SubtargetPredicate = isGFX11Plus
745 foreach vt = Reg32Types.types in {
746 def : GCNPat<(int_amdgcn_permlane64 (vt VRegSrc_32:$src0)),
747 (vt (V_PERMLANE64_B32 (vt VRegSrc_32:$src0)))
751 //===----------------------------------------------------------------------===//
752 // Target-specific instruction encodings.
753 //===----------------------------------------------------------------------===//
755 class VOP1_DPP<bits<8> op, VOP1_DPP_Pseudo ps, VOPProfile p = ps.Pfl, bit isDPP16 = 0> :
756 VOP_DPP<ps.OpName, p, isDPP16> {
757 let hasSideEffects = ps.hasSideEffects;
759 let SchedRW = ps.SchedRW;
761 let TRANS = ps.TRANS;
762 let SubtargetPredicate = ps.SubtargetPredicate;
763 let OtherPredicates = ps.OtherPredicates;
766 let Inst{8-0} = 0xfa;
768 let Inst{24-17} = !if(p.EmitDst, vdst{7-0}, 0);
769 let Inst{31-25} = 0x3f;
772 class VOP1_DPP16<bits<8> op, VOP1_DPP_Pseudo ps, int subtarget, VOPProfile p = ps.Pfl> :
773 VOP1_DPP<op, ps, p, 1>,
774 SIMCInstr <ps.PseudoInstr, subtarget> {
775 let AssemblerPredicate = HasDPP16;
778 class VOP1_DPP16_Gen<bits<8> op, VOP1_DPP_Pseudo ps, GFXGen Gen, VOPProfile p = ps.Pfl> :
779 VOP1_DPP16 <op, ps, Gen.Subtarget, p> {
780 let AssemblerPredicate = Gen.AssemblerPredicate;
781 let DecoderNamespace = Gen.DecoderNamespace;
784 class VOP1_DPP8<bits<8> op, VOP1_Pseudo ps, VOPProfile p = ps.Pfl> :
785 VOP_DPP8<ps.OpName, p> {
786 let hasSideEffects = ps.hasSideEffects;
788 let SchedRW = ps.SchedRW;
790 let SubtargetPredicate = ps.SubtargetPredicate;
791 let OtherPredicates = ps.OtherPredicates;
796 let Inst{24-17} = !if(p.EmitDst, vdst{7-0}, 0);
797 let Inst{31-25} = 0x3f;
800 class VOP1_DPP8_Gen<bits<8> op, VOP1_Pseudo ps, GFXGen Gen, VOPProfile p = ps.Pfl> :
801 VOP1_DPP8<op, ps, p> {
802 let AssemblerPredicate = Gen.AssemblerPredicate;
803 let DecoderNamespace = Gen.DecoderNamespace;
806 //===----------------------------------------------------------------------===//
808 //===----------------------------------------------------------------------===//
810 multiclass VOP1Only_Real<GFXGen Gen, bits<9> op> {
813 VOP1_Real_Gen<!cast<VOP1_Pseudo>(NAME), Gen>,
814 VOP1e<op{7-0}, !cast<VOP1_Pseudo>(NAME).Pfl>;
817 multiclass VOP1_Real_e32<GFXGen Gen, bits<9> op, string opName = NAME> {
818 defvar ps = !cast<VOP1_Pseudo>(opName#"_e32");
819 def _e32#Gen.Suffix :
820 VOP1_Real_Gen<ps, Gen>,
821 VOP1e<op{7-0}, ps.Pfl>;
824 multiclass VOP1_Real_e32_with_name<GFXGen Gen, bits<9> op, string opName,
826 defvar ps = !cast<VOP1_Pseudo>(opName#"_e32");
827 let AsmString = asmName # ps.AsmOperands,
828 DecoderNamespace = Gen.DecoderNamespace #
829 !if(ps.Pfl.IsRealTrue16, "", "_FAKE16") in {
830 defm NAME : VOP1_Real_e32<Gen, op, opName>;
834 multiclass VOP1_Real_e64<GFXGen Gen, bits<9> op> {
835 def _e64#Gen.Suffix :
836 VOP3_Real_Gen<!cast<VOP3_Pseudo>(NAME#"_e64"), Gen>,
837 VOP3e_gfx11_gfx12<{0, 1, 1, op{6-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
840 multiclass VOP1_Real_dpp<GFXGen Gen, bits<9> op, string opName = NAME> {
841 defvar ps = !cast<VOP1_Pseudo>(opName#"_e32");
842 def _dpp#Gen.Suffix : VOP1_DPP16_Gen<op{7-0}, !cast<VOP1_DPP_Pseudo>(opName#"_dpp"), Gen>;
845 multiclass VOP1_Real_dpp_with_name<GFXGen Gen, bits<9> op, string opName,
847 defvar ps = !cast<VOP1_Pseudo>(opName#"_e32");
848 let AsmString = asmName # ps.Pfl.AsmDPP16,
849 DecoderNamespace = Gen.DecoderNamespace #
850 !if(ps.Pfl.IsRealTrue16, "", "_FAKE16") in {
851 defm NAME : VOP1_Real_dpp<Gen, op, opName>;
855 multiclass VOP1_Real_dpp8<GFXGen Gen, bits<9> op, string opName = NAME> {
856 defvar ps = !cast<VOP1_Pseudo>(opName#"_e32");
857 def _dpp8#Gen.Suffix : VOP1_DPP8_Gen<op{7-0}, ps, Gen>;
860 multiclass VOP1_Real_dpp8_with_name<GFXGen Gen, bits<9> op, string opName,
862 defvar ps = !cast<VOP1_Pseudo>(opName#"_e32");
863 let AsmString = asmName # ps.Pfl.AsmDPP8,
864 DecoderNamespace = Gen.DecoderNamespace #
865 !if(ps.Pfl.IsRealTrue16, "", "_FAKE16") in {
866 defm NAME : VOP1_Real_dpp8<Gen, op, opName>;
870 multiclass VOP1_Realtriple_e64<GFXGen Gen, bits<9> op> {
871 defm NAME : VOP3_Realtriple<Gen, {0, 1, 1, op{6-0}}, /*isSingle=*/ 0, NAME>;
874 multiclass VOP1_Realtriple_e64_with_name<GFXGen Gen, bits<9> op, string opName,
876 defm NAME : VOP3_Realtriple_with_name<Gen, {0, 1, 1, op{6-0}}, opName,
880 multiclass VOP1_Real_FULL<GFXGen Gen, bits<9> op> :
881 VOP1_Real_e32<Gen, op>, VOP1_Realtriple_e64<Gen, op>,
882 VOP1_Real_dpp<Gen, op>, VOP1_Real_dpp8<Gen, op>;
884 multiclass VOP1_Real_NO_VOP3_with_name_gfx11<bits<9> op, string opName,
886 defm NAME : VOP1_Real_e32_with_name<GFX11Gen, op, opName, asmName>,
887 VOP1_Real_dpp_with_name<GFX11Gen, op, opName, asmName>,
888 VOP1_Real_dpp8_with_name<GFX11Gen, op, opName, asmName>;
889 defvar ps = !cast<VOP1_Pseudo>(opName#"_e32");
890 def gfx11_alias : AMDGPUMnemonicAlias<ps.Mnemonic, asmName> {
891 let AssemblerPredicate = isGFX11Plus;
895 multiclass VOP1_Real_NO_VOP3_with_name_gfx12<bits<9> op, string opName,
897 defm NAME : VOP1_Real_e32_with_name<GFX12Gen, op, opName, asmName>,
898 VOP1_Real_dpp_with_name<GFX12Gen, op, opName, asmName>,
899 VOP1_Real_dpp8_with_name<GFX12Gen, op, opName, asmName>;
902 multiclass VOP1_Real_FULL_with_name<GFXGen Gen, bits<9> op, string opName,
904 VOP1_Real_e32_with_name<Gen, op, opName, asmName>,
905 VOP1_Real_dpp_with_name<Gen, op, opName, asmName>,
906 VOP1_Real_dpp8_with_name<Gen, op, opName, asmName>,
907 VOP1_Realtriple_e64_with_name<Gen, op, opName, asmName>;
909 multiclass VOP1_Real_NO_DPP<GFXGen Gen, bits<9> op> :
910 VOP1_Real_e32<Gen, op>, VOP1_Real_e64<Gen, op>;
912 multiclass VOP1_Real_FULL_t16_gfx11_gfx12<bits<9> op, string asmName,
913 string opName = NAME> :
914 VOP1_Real_FULL_with_name<GFX11Gen, op, opName, asmName>,
915 VOP1_Real_FULL_with_name<GFX12Gen, op, opName, asmName>;
917 multiclass VOP1_Real_FULL_with_name_gfx11_gfx12<bits<9> op, string opName,
919 VOP1_Real_FULL_with_name<GFX11Gen, op, opName, asmName>,
920 VOP1_Real_FULL_with_name<GFX12Gen, op, opName, asmName>;
922 multiclass VOP1Only_Real_gfx11_gfx12<bits<9> op> :
923 VOP1Only_Real<GFX11Gen, op>, VOP1Only_Real<GFX12Gen, op>;
925 multiclass VOP1_Real_FULL_gfx11_gfx12<bits<9> op> :
926 VOP1_Real_FULL<GFX11Gen, op>, VOP1_Real_FULL<GFX12Gen, op>;
928 multiclass VOP1_Real_NO_DPP_OP_SEL_with_name<GFXGen Gen, bits<9> op,
929 string opName, string asmName> :
930 VOP1_Real_e32_with_name<Gen, op, opName, asmName>,
931 VOP3_Real_with_name<Gen, {0, 1, 1, op{6-0}}, opName, asmName>;
934 defm V_CVT_F32_FP8 : VOP1_Real_FULL_with_name<GFX12Gen, 0x06c, "V_CVT_F32_FP8_OP_SEL", "v_cvt_f32_fp8">;
935 defm V_CVT_F32_BF8 : VOP1_Real_FULL_with_name<GFX12Gen, 0x06d, "V_CVT_F32_BF8_OP_SEL", "v_cvt_f32_bf8">;
937 // Define VOP1 instructions using the pseudo instruction with its old profile and
938 // VOP3 using the OpSel profile for the pseudo instruction.
939 defm V_CVT_PK_F32_FP8 : VOP1_Real_e32_with_name<GFX12Gen, 0x06e, "V_CVT_PK_F32_FP8", "v_cvt_pk_f32_fp8">;
940 defm V_CVT_PK_F32_FP8 : VOP3_Real_with_name<GFX12Gen, 0x1ee, "V_CVT_PK_F32_FP8_OP_SEL", "v_cvt_pk_f32_fp8">;
942 defm V_CVT_PK_F32_BF8 : VOP1_Real_e32_with_name<GFX12Gen, 0x06f, "V_CVT_PK_F32_BF8", "v_cvt_pk_f32_bf8">;
943 defm V_CVT_PK_F32_BF8 : VOP3_Real_with_name<GFX12Gen, 0x1ef, "V_CVT_PK_F32_BF8_OP_SEL", "v_cvt_pk_f32_bf8">;
945 defm V_CVT_NEAREST_I32_F32 : VOP1_Real_FULL_with_name_gfx11_gfx12<0x00c,
946 "V_CVT_RPI_I32_F32", "v_cvt_nearest_i32_f32">;
947 defm V_CVT_FLOOR_I32_F32 : VOP1_Real_FULL_with_name_gfx11_gfx12<0x00d,
948 "V_CVT_FLR_I32_F32", "v_cvt_floor_i32_f32">;
949 defm V_CLZ_I32_U32 : VOP1_Real_FULL_with_name_gfx11_gfx12<0x039,
950 "V_FFBH_U32", "v_clz_i32_u32">;
951 defm V_CTZ_I32_B32 : VOP1_Real_FULL_with_name_gfx11_gfx12<0x03a,
952 "V_FFBL_B32", "v_ctz_i32_b32">;
953 defm V_CLS_I32 : VOP1_Real_FULL_with_name_gfx11_gfx12<0x03b,
954 "V_FFBH_I32", "v_cls_i32">;
955 defm V_PERMLANE64_B32 : VOP1Only_Real_gfx11_gfx12<0x067>;
956 defm V_MOV_B16_t16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x01c, "v_mov_b16">;
957 defm V_NOT_B16_fake16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x069, "v_not_b16">;
958 defm V_CVT_I32_I16_fake16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x06a, "v_cvt_i32_i16">;
959 defm V_CVT_U32_U16_fake16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x06b, "v_cvt_u32_u16">;
961 defm V_CVT_F16_U16_t16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x050, "v_cvt_f16_u16">;
962 defm V_CVT_F16_I16_t16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x051, "v_cvt_f16_i16">;
963 defm V_CVT_U16_F16_t16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x052, "v_cvt_u16_f16">;
964 defm V_CVT_I16_F16_t16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x053, "v_cvt_i16_f16">;
965 defm V_RCP_F16_t16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x054, "v_rcp_f16">;
966 defm V_RCP_F16_fake16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x054, "v_rcp_f16">;
967 defm V_SQRT_F16_t16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x055, "v_sqrt_f16">;
968 defm V_SQRT_F16_fake16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x055, "v_sqrt_f16">;
969 defm V_RSQ_F16_t16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x056, "v_rsq_f16">;
970 defm V_RSQ_F16_fake16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x056, "v_rsq_f16">;
971 defm V_LOG_F16_t16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x057, "v_log_f16">;
972 defm V_LOG_F16_fake16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x057, "v_log_f16">;
973 defm V_EXP_F16_t16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x058, "v_exp_f16">;
974 defm V_EXP_F16_fake16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x058, "v_exp_f16">;
975 defm V_FREXP_MANT_F16_fake16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x059, "v_frexp_mant_f16">;
976 defm V_FREXP_EXP_I16_F16_t16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x05a, "v_frexp_exp_i16_f16">;
977 defm V_FLOOR_F16_t16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x05b, "v_floor_f16">;
978 defm V_FLOOR_F16_fake16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x05b, "v_floor_f16">;
979 defm V_CEIL_F16_t16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x05c, "v_ceil_f16">;
980 defm V_CEIL_F16_fake16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x05c, "v_ceil_f16">;
981 defm V_TRUNC_F16_fake16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x05d, "v_trunc_f16">;
982 defm V_RNDNE_F16_fake16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x05e, "v_rndne_f16">;
983 defm V_FRACT_F16_fake16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x05f, "v_fract_f16">;
984 defm V_SIN_F16_fake16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x060, "v_sin_f16">;
985 defm V_COS_F16_fake16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x061, "v_cos_f16">;
986 defm V_SAT_PK_U8_I16_fake16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x062, "v_sat_pk_u8_i16">;
987 defm V_CVT_NORM_I16_F16_t16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x063, "v_cvt_norm_i16_f16">;
988 defm V_CVT_NORM_U16_F16_t16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x064, "v_cvt_norm_u16_f16">;
990 defm V_CVT_F16_F32_t16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x00a, "v_cvt_f16_f32">;
991 defm V_CVT_F32_F16_t16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x00b, "v_cvt_f32_f16">;
993 //===----------------------------------------------------------------------===//
995 //===----------------------------------------------------------------------===//
997 let AssemblerPredicate = isGFX10Only, DecoderNamespace = "GFX10" in {
998 multiclass VOP1Only_Real_gfx10<bits<9> op> {
1000 VOP1_Real<!cast<VOP1_Pseudo>(NAME), SIEncodingFamily.GFX10>,
1001 VOP1e<op{7-0}, !cast<VOP1_Pseudo>(NAME).Pfl>;
1003 multiclass VOP1_Real_e32_gfx10<bits<9> op> {
1005 VOP1_Real<!cast<VOP1_Pseudo>(NAME#"_e32"), SIEncodingFamily.GFX10>,
1006 VOP1e<op{7-0}, !cast<VOP1_Pseudo>(NAME#"_e32").Pfl>;
1008 multiclass VOP1_Real_e64_gfx10<bits<9> op> {
1010 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX10>,
1011 VOP3e_gfx10<{0, 1, 1, op{6-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1013 multiclass VOP1_Real_sdwa_gfx10<bits<9> op> {
1014 if !cast<VOP1_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA9 then
1016 VOP_SDWA10_Real<!cast<VOP1_SDWA_Pseudo>(NAME#"_sdwa")>,
1017 VOP1_SDWA9Ae<op{7-0}, !cast<VOP1_SDWA_Pseudo>(NAME#"_sdwa").Pfl>;
1019 multiclass VOP1_Real_dpp_gfx10<bits<9> op> {
1020 if !cast<VOP1_Pseudo>(NAME#"_e32").Pfl.HasExt32BitDPP then
1021 def _dpp_gfx10 : VOP1_DPP16<op{7-0}, !cast<VOP1_DPP_Pseudo>(NAME#"_dpp"), SIEncodingFamily.GFX10>;
1023 multiclass VOP1_Real_dpp8_gfx10<bits<9> op> {
1024 if !cast<VOP1_Pseudo>(NAME#"_e32").Pfl.HasExt32BitDPP then
1025 def _dpp8_gfx10 : VOP1_DPP8<op{7-0}, !cast<VOP1_Pseudo>(NAME#"_e32")>;
1027 } // End AssemblerPredicate = isGFX10Only, DecoderNamespace = "GFX10"
1029 multiclass VOP1_Real_gfx10<bits<9> op> :
1030 VOP1_Real_e32_gfx10<op>, VOP1_Real_e64_gfx10<op>,
1031 VOP1_Real_sdwa_gfx10<op>, VOP1_Real_dpp_gfx10<op>,
1032 VOP1_Real_dpp8_gfx10<op>;
1034 multiclass VOP1_Real_gfx10_FULL_gfx11_gfx12<bits<9> op> :
1035 VOP1_Real_gfx10<op>,
1036 VOP1_Real_FULL<GFX11Gen, op>,
1037 VOP1_Real_FULL<GFX12Gen, op>;
1039 multiclass VOP1_Real_gfx10_NO_DPP_gfx11_gfx12<bits<9> op> :
1040 VOP1_Real_gfx10<op>,
1041 VOP1_Real_NO_DPP<GFX11Gen, op>,
1042 VOP1_Real_NO_DPP<GFX12Gen, op>;
1044 multiclass VOP1Only_Real_gfx10_gfx11_gfx12<bits<9> op> :
1045 VOP1Only_Real_gfx10<op>,
1046 VOP1Only_Real<GFX11Gen, op>,
1047 VOP1Only_Real<GFX12Gen, op>;
1049 defm V_PIPEFLUSH : VOP1_Real_gfx10_NO_DPP_gfx11_gfx12<0x01b>;
1050 defm V_MOVRELSD_2_B32 : VOP1_Real_gfx10_FULL_gfx11_gfx12<0x048>;
1051 defm V_CVT_F16_U16 : VOP1_Real_gfx10<0x050>;
1052 defm V_CVT_F16_I16 : VOP1_Real_gfx10<0x051>;
1053 defm V_CVT_U16_F16 : VOP1_Real_gfx10<0x052>;
1054 defm V_CVT_I16_F16 : VOP1_Real_gfx10<0x053>;
1055 defm V_RCP_F16 : VOP1_Real_gfx10<0x054>;
1056 defm V_SQRT_F16 : VOP1_Real_gfx10<0x055>;
1057 defm V_RSQ_F16 : VOP1_Real_gfx10<0x056>;
1058 defm V_LOG_F16 : VOP1_Real_gfx10<0x057>;
1059 defm V_EXP_F16 : VOP1_Real_gfx10<0x058>;
1060 defm V_FREXP_MANT_F16 : VOP1_Real_gfx10<0x059>;
1061 defm V_FREXP_EXP_I16_F16 : VOP1_Real_gfx10<0x05a>;
1062 defm V_FLOOR_F16 : VOP1_Real_gfx10<0x05b>;
1063 defm V_CEIL_F16 : VOP1_Real_gfx10<0x05c>;
1064 defm V_TRUNC_F16 : VOP1_Real_gfx10<0x05d>;
1065 defm V_RNDNE_F16 : VOP1_Real_gfx10<0x05e>;
1066 defm V_FRACT_F16 : VOP1_Real_gfx10<0x05f>;
1067 defm V_SIN_F16 : VOP1_Real_gfx10<0x060>;
1068 defm V_COS_F16 : VOP1_Real_gfx10<0x061>;
1069 defm V_SAT_PK_U8_I16 : VOP1_Real_gfx10<0x062>;
1070 defm V_CVT_NORM_I16_F16 : VOP1_Real_gfx10<0x063>;
1071 defm V_CVT_NORM_U16_F16 : VOP1_Real_gfx10<0x064>;
1073 defm V_SWAP_B32 : VOP1Only_Real_gfx10_gfx11_gfx12<0x065>;
1074 defm V_SWAPREL_B32 : VOP1Only_Real_gfx10_gfx11_gfx12<0x068>;
1076 //===----------------------------------------------------------------------===//
1077 // GFX7, GFX10, GFX11, GFX12
1078 //===----------------------------------------------------------------------===//
1080 let AssemblerPredicate = isGFX7Only, DecoderNamespace = "GFX7" in {
1081 multiclass VOP1_Real_e32_gfx7<bits<9> op> {
1083 VOP1_Real<!cast<VOP1_Pseudo>(NAME#"_e32"), SIEncodingFamily.SI>,
1084 VOP1e<op{7-0}, !cast<VOP1_Pseudo>(NAME#"_e32").Pfl>;
1086 multiclass VOP1_Real_e64_gfx7<bits<9> op> {
1088 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.SI>,
1089 VOP3e_gfx6_gfx7<{1, 1, op{6-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1091 } // End AssemblerPredicate = isGFX7Only, DecoderNamespace = "GFX7"
1093 multiclass VOP1_Real_gfx7<bits<9> op> :
1094 VOP1_Real_e32_gfx7<op>, VOP1_Real_e64_gfx7<op>;
1096 multiclass VOP1_Real_gfx7_gfx10_NO_DPP_gfx11_gfx12<bits<9> op> :
1097 VOP1_Real_gfx7<op>, VOP1_Real_gfx10<op>, VOP1_Real_NO_DPP<GFX11Gen, op>,
1098 VOP1_Real_NO_DPP<GFX12Gen, op>;
1100 defm V_LOG_LEGACY_F32 : VOP1_Real_gfx7<0x045>;
1101 defm V_EXP_LEGACY_F32 : VOP1_Real_gfx7<0x046>;
1103 defm V_TRUNC_F64 : VOP1_Real_gfx7_gfx10_NO_DPP_gfx11_gfx12<0x017>;
1104 defm V_CEIL_F64 : VOP1_Real_gfx7_gfx10_NO_DPP_gfx11_gfx12<0x018>;
1105 defm V_RNDNE_F64 : VOP1_Real_gfx7_gfx10_NO_DPP_gfx11_gfx12<0x019>;
1106 defm V_FLOOR_F64 : VOP1_Real_gfx7_gfx10_NO_DPP_gfx11_gfx12<0x01a>;
1108 //===----------------------------------------------------------------------===//
1109 // GFX6, GFX7, GFX10, GFX11, GFX12
1110 //===----------------------------------------------------------------------===//
1112 let AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" in {
1113 multiclass VOP1_Real_e32_gfx6_gfx7<bits<9> op> {
1114 def _e32_gfx6_gfx7 :
1115 VOP1_Real<!cast<VOP1_Pseudo>(NAME#"_e32"), SIEncodingFamily.SI>,
1116 VOP1e<op{7-0}, !cast<VOP1_Pseudo>(NAME#"_e32").Pfl>;
1118 multiclass VOP1_Real_e64_gfx6_gfx7<bits<9> op> {
1119 def _e64_gfx6_gfx7 :
1120 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.SI>,
1121 VOP3e_gfx6_gfx7<{1, 1, op{6-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1123 multiclass VOP1Only_Real_gfx6_gfx7<bits<9> op> {
1125 VOP1_Real<!cast<VOP1_Pseudo>(NAME), SIEncodingFamily.SI>,
1126 VOP1e<op{7-0}, !cast<VOP1_Pseudo>(NAME).Pfl>;
1128 } // End AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7"
1130 multiclass VOP1_Real_gfx6_gfx7<bits<9> op> :
1131 VOP1_Real_e32_gfx6_gfx7<op>, VOP1_Real_e64_gfx6_gfx7<op>;
1133 multiclass VOP1_Real_gfx6_gfx7_gfx10<bits<9> op> :
1134 VOP1_Real_gfx6_gfx7<op>, VOP1_Real_gfx10<op>;
1136 multiclass VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<bits<9> op> :
1137 VOP1_Real_gfx6_gfx7_gfx10<op>, VOP1_Real_FULL<GFX11Gen, op>,
1138 VOP1_Real_FULL<GFX12Gen, op>;
1140 multiclass VOP1_Real_gfx6_gfx7_gfx10_NO_DPP_gfx11_gfx12<bits<9> op> :
1141 VOP1_Real_gfx6_gfx7_gfx10<op>, VOP1_Real_NO_DPP<GFX11Gen, op>,
1142 VOP1_Real_NO_DPP<GFX12Gen, op>;
1144 multiclass VOP1Only_Real_gfx6_gfx7_gfx10_gfx11_gfx12<bits<9> op> :
1145 VOP1Only_Real_gfx6_gfx7<op>, VOP1Only_Real_gfx10_gfx11_gfx12<op>;
1147 defm V_LOG_CLAMP_F32 : VOP1_Real_gfx6_gfx7<0x026>;
1148 defm V_RCP_CLAMP_F32 : VOP1_Real_gfx6_gfx7<0x028>;
1149 defm V_RCP_LEGACY_F32 : VOP1_Real_gfx6_gfx7<0x029>;
1150 defm V_RSQ_CLAMP_F32 : VOP1_Real_gfx6_gfx7<0x02c>;
1151 defm V_RSQ_LEGACY_F32 : VOP1_Real_gfx6_gfx7<0x02d>;
1152 defm V_RCP_CLAMP_F64 : VOP1_Real_gfx6_gfx7<0x030>;
1153 defm V_RSQ_CLAMP_F64 : VOP1_Real_gfx6_gfx7<0x032>;
1155 defm V_NOP : VOP1_Real_gfx6_gfx7_gfx10_NO_DPP_gfx11_gfx12<0x000>;
1156 defm V_MOV_B32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x001>;
1157 defm V_READFIRSTLANE_B32 : VOP1Only_Real_gfx6_gfx7_gfx10_gfx11_gfx12<0x002>;
1158 defm V_CVT_I32_F64 : VOP1_Real_gfx6_gfx7_gfx10_NO_DPP_gfx11_gfx12<0x003>;
1159 defm V_CVT_F64_I32 : VOP1_Real_gfx6_gfx7_gfx10_NO_DPP_gfx11_gfx12<0x004>;
1160 defm V_CVT_F32_I32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x005>;
1161 defm V_CVT_F32_U32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x006>;
1162 defm V_CVT_U32_F32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x007>;
1163 defm V_CVT_I32_F32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x008>;
1164 defm V_CVT_F16_F32 : VOP1_Real_gfx6_gfx7_gfx10<0x00a>;
1165 defm V_CVT_F32_F16 : VOP1_Real_gfx6_gfx7_gfx10<0x00b>;
1166 defm V_CVT_RPI_I32_F32 : VOP1_Real_gfx6_gfx7_gfx10<0x00c>;
1167 defm V_CVT_FLR_I32_F32 : VOP1_Real_gfx6_gfx7_gfx10<0x00d>;
1168 defm V_CVT_OFF_F32_I4 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x00e>;
1169 defm V_CVT_F32_F64 : VOP1_Real_gfx6_gfx7_gfx10_NO_DPP_gfx11_gfx12<0x00f>;
1170 defm V_CVT_F64_F32 : VOP1_Real_gfx6_gfx7_gfx10_NO_DPP_gfx11_gfx12<0x010>;
1171 defm V_CVT_F32_UBYTE0 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x011>;
1172 defm V_CVT_F32_UBYTE1 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x012>;
1173 defm V_CVT_F32_UBYTE2 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x013>;
1174 defm V_CVT_F32_UBYTE3 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x014>;
1175 defm V_CVT_U32_F64 : VOP1_Real_gfx6_gfx7_gfx10_NO_DPP_gfx11_gfx12<0x015>;
1176 defm V_CVT_F64_U32 : VOP1_Real_gfx6_gfx7_gfx10_NO_DPP_gfx11_gfx12<0x016>;
1177 defm V_FRACT_F32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x020>;
1178 defm V_TRUNC_F32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x021>;
1179 defm V_CEIL_F32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x022>;
1180 defm V_RNDNE_F32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x023>;
1181 defm V_FLOOR_F32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x024>;
1182 defm V_EXP_F32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x025>;
1183 defm V_LOG_F32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x027>;
1184 defm V_RCP_F32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x02a>;
1185 defm V_RCP_IFLAG_F32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x02b>;
1186 defm V_RSQ_F32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x02e>;
1187 defm V_RCP_F64 : VOP1_Real_gfx6_gfx7_gfx10_NO_DPP_gfx11_gfx12<0x02f>;
1188 defm V_RSQ_F64 : VOP1_Real_gfx6_gfx7_gfx10_NO_DPP_gfx11_gfx12<0x031>;
1189 defm V_SQRT_F32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x033>;
1190 defm V_SQRT_F64 : VOP1_Real_gfx6_gfx7_gfx10_NO_DPP_gfx11_gfx12<0x034>;
1191 defm V_SIN_F32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x035>;
1192 defm V_COS_F32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x036>;
1193 defm V_NOT_B32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x037>;
1194 defm V_BFREV_B32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x038>;
1195 defm V_FFBH_U32 : VOP1_Real_gfx6_gfx7_gfx10<0x039>;
1196 defm V_FFBL_B32 : VOP1_Real_gfx6_gfx7_gfx10<0x03a>;
1197 defm V_FFBH_I32 : VOP1_Real_gfx6_gfx7_gfx10<0x03b>;
1198 defm V_FREXP_EXP_I32_F64 : VOP1_Real_gfx6_gfx7_gfx10_NO_DPP_gfx11_gfx12<0x03c>;
1199 defm V_FREXP_MANT_F64 : VOP1_Real_gfx6_gfx7_gfx10_NO_DPP_gfx11_gfx12<0x03d>;
1200 defm V_FRACT_F64 : VOP1_Real_gfx6_gfx7_gfx10_NO_DPP_gfx11_gfx12<0x03e>;
1201 defm V_FREXP_EXP_I32_F32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x03f>;
1202 defm V_FREXP_MANT_F32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x040>;
1203 defm V_CLREXCP : VOP1_Real_gfx6_gfx7_gfx10<0x041>;
1204 defm V_MOVRELD_B32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x042>;
1205 defm V_MOVRELS_B32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x043>;
1206 defm V_MOVRELSD_B32 : VOP1_Real_gfx6_gfx7_gfx10_FULL_gfx11_gfx12<0x044>;
1208 //===----------------------------------------------------------------------===//
1210 //===----------------------------------------------------------------------===//
1212 class VOP1_DPPe <bits<8> op, VOP1_DPP_Pseudo ps, VOPProfile P = ps.Pfl> :
1215 let Inst{8-0} = 0xfa; // dpp
1216 let Inst{16-9} = op;
1217 let Inst{24-17} = !if(P.EmitDst, vdst{7-0}, 0);
1218 let Inst{31-25} = 0x3f; //encoding
1221 let AssemblerPredicate = isGFX8GFX9, DecoderNamespace = "GFX8" in {
1222 multiclass VOP1Only_Real_vi <bits<10> op> {
1224 VOP1_Real<!cast<VOP1_Pseudo>(NAME), SIEncodingFamily.VI>,
1225 VOP1e<op{7-0}, !cast<VOP1_Pseudo>(NAME).Pfl>;
1228 multiclass VOP1_Real_e32e64_vi <bits<10> op> {
1230 VOP1_Real<!cast<VOP1_Pseudo>(NAME#"_e32"), SIEncodingFamily.VI>,
1231 VOP1e<op{7-0}, !cast<VOP1_Pseudo>(NAME#"_e32").Pfl>;
1233 VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.VI>,
1234 VOP3e_vi <!add(0x140, op), !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
1238 multiclass VOP1_Real_vi <bits<10> op> {
1239 defm NAME : VOP1_Real_e32e64_vi <op>;
1241 if !cast<VOP1_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA then
1243 VOP_SDWA_Real <!cast<VOP1_SDWA_Pseudo>(NAME#"_sdwa")>,
1244 VOP1_SDWAe <op{7-0}, !cast<VOP1_SDWA_Pseudo>(NAME#"_sdwa").Pfl>;
1246 if !cast<VOP1_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA9 then
1248 VOP_SDWA9_Real <!cast<VOP1_SDWA_Pseudo>(NAME#"_sdwa")>,
1249 VOP1_SDWA9Ae <op{7-0}, !cast<VOP1_SDWA_Pseudo>(NAME#"_sdwa").Pfl>;
1251 if !cast<VOP1_Pseudo>(NAME#"_e32").Pfl.HasExtDPP then
1253 VOP_DPP_Real<!cast<VOP1_DPP_Pseudo>(NAME#"_dpp"), SIEncodingFamily.VI>,
1254 VOP1_DPPe<op{7-0}, !cast<VOP1_DPP_Pseudo>(NAME#"_dpp")>;
1257 defm V_NOP : VOP1_Real_vi <0x0>;
1258 defm V_MOV_B32 : VOP1_Real_vi <0x1>;
1259 defm V_READFIRSTLANE_B32 : VOP1Only_Real_vi <0x2>;
1260 defm V_CVT_I32_F64 : VOP1_Real_vi <0x3>;
1261 defm V_CVT_F64_I32 : VOP1_Real_vi <0x4>;
1262 defm V_CVT_F32_I32 : VOP1_Real_vi <0x5>;
1263 defm V_CVT_F32_U32 : VOP1_Real_vi <0x6>;
1264 defm V_CVT_U32_F32 : VOP1_Real_vi <0x7>;
1265 defm V_CVT_I32_F32 : VOP1_Real_vi <0x8>;
1266 defm V_CVT_F16_F32 : VOP1_Real_vi <0xa>;
1267 defm V_CVT_F32_F16 : VOP1_Real_vi <0xb>;
1268 defm V_CVT_RPI_I32_F32 : VOP1_Real_vi <0xc>;
1269 defm V_CVT_FLR_I32_F32 : VOP1_Real_vi <0xd>;
1270 defm V_CVT_OFF_F32_I4 : VOP1_Real_vi <0xe>;
1271 defm V_CVT_F32_F64 : VOP1_Real_vi <0xf>;
1272 defm V_CVT_F64_F32 : VOP1_Real_vi <0x10>;
1273 defm V_CVT_F32_UBYTE0 : VOP1_Real_vi <0x11>;
1274 defm V_CVT_F32_UBYTE1 : VOP1_Real_vi <0x12>;
1275 defm V_CVT_F32_UBYTE2 : VOP1_Real_vi <0x13>;
1276 defm V_CVT_F32_UBYTE3 : VOP1_Real_vi <0x14>;
1277 defm V_CVT_U32_F64 : VOP1_Real_vi <0x15>;
1278 defm V_CVT_F64_U32 : VOP1_Real_vi <0x16>;
1279 defm V_FRACT_F32 : VOP1_Real_vi <0x1b>;
1280 defm V_TRUNC_F32 : VOP1_Real_vi <0x1c>;
1281 defm V_CEIL_F32 : VOP1_Real_vi <0x1d>;
1282 defm V_RNDNE_F32 : VOP1_Real_vi <0x1e>;
1283 defm V_FLOOR_F32 : VOP1_Real_vi <0x1f>;
1284 defm V_EXP_F32 : VOP1_Real_vi <0x20>;
1285 defm V_LOG_F32 : VOP1_Real_vi <0x21>;
1286 defm V_RCP_F32 : VOP1_Real_vi <0x22>;
1287 defm V_RCP_IFLAG_F32 : VOP1_Real_vi <0x23>;
1288 defm V_RSQ_F32 : VOP1_Real_vi <0x24>;
1289 defm V_RCP_F64 : VOP1_Real_vi <0x25>;
1290 defm V_RSQ_F64 : VOP1_Real_vi <0x26>;
1291 defm V_SQRT_F32 : VOP1_Real_vi <0x27>;
1292 defm V_SQRT_F64 : VOP1_Real_vi <0x28>;
1293 defm V_SIN_F32 : VOP1_Real_vi <0x29>;
1294 defm V_COS_F32 : VOP1_Real_vi <0x2a>;
1295 defm V_NOT_B32 : VOP1_Real_vi <0x2b>;
1296 defm V_BFREV_B32 : VOP1_Real_vi <0x2c>;
1297 defm V_FFBH_U32 : VOP1_Real_vi <0x2d>;
1298 defm V_FFBL_B32 : VOP1_Real_vi <0x2e>;
1299 defm V_FFBH_I32 : VOP1_Real_vi <0x2f>;
1300 defm V_FREXP_EXP_I32_F64 : VOP1_Real_vi <0x30>;
1301 defm V_FREXP_MANT_F64 : VOP1_Real_vi <0x31>;
1302 defm V_FRACT_F64 : VOP1_Real_vi <0x32>;
1303 defm V_FREXP_EXP_I32_F32 : VOP1_Real_vi <0x33>;
1304 defm V_FREXP_MANT_F32 : VOP1_Real_vi <0x34>;
1305 defm V_CLREXCP : VOP1_Real_vi <0x35>;
1306 defm V_MOVRELD_B32 : VOP1_Real_e32e64_vi <0x36>;
1307 defm V_MOVRELS_B32 : VOP1_Real_e32e64_vi <0x37>;
1308 defm V_MOVRELSD_B32 : VOP1_Real_e32e64_vi <0x38>;
1309 defm V_TRUNC_F64 : VOP1_Real_vi <0x17>;
1310 defm V_CEIL_F64 : VOP1_Real_vi <0x18>;
1311 defm V_FLOOR_F64 : VOP1_Real_vi <0x1A>;
1312 defm V_RNDNE_F64 : VOP1_Real_vi <0x19>;
1313 defm V_LOG_LEGACY_F32 : VOP1_Real_vi <0x4c>;
1314 defm V_EXP_LEGACY_F32 : VOP1_Real_vi <0x4b>;
1315 defm V_CVT_F16_U16 : VOP1_Real_vi <0x39>;
1316 defm V_CVT_F16_I16 : VOP1_Real_vi <0x3a>;
1317 defm V_CVT_U16_F16 : VOP1_Real_vi <0x3b>;
1318 defm V_CVT_I16_F16 : VOP1_Real_vi <0x3c>;
1319 defm V_RCP_F16 : VOP1_Real_vi <0x3d>;
1320 defm V_SQRT_F16 : VOP1_Real_vi <0x3e>;
1321 defm V_RSQ_F16 : VOP1_Real_vi <0x3f>;
1322 defm V_LOG_F16 : VOP1_Real_vi <0x40>;
1323 defm V_EXP_F16 : VOP1_Real_vi <0x41>;
1324 defm V_FREXP_MANT_F16 : VOP1_Real_vi <0x42>;
1325 defm V_FREXP_EXP_I16_F16 : VOP1_Real_vi <0x43>;
1326 defm V_FLOOR_F16 : VOP1_Real_vi <0x44>;
1327 defm V_CEIL_F16 : VOP1_Real_vi <0x45>;
1328 defm V_TRUNC_F16 : VOP1_Real_vi <0x46>;
1329 defm V_RNDNE_F16 : VOP1_Real_vi <0x47>;
1330 defm V_FRACT_F16 : VOP1_Real_vi <0x48>;
1331 defm V_SIN_F16 : VOP1_Real_vi <0x49>;
1332 defm V_COS_F16 : VOP1_Real_vi <0x4a>;
1333 defm V_SWAP_B32 : VOP1Only_Real_vi <0x51>;
1335 defm V_SAT_PK_U8_I16 : VOP1_Real_vi<0x4f>;
1336 defm V_CVT_NORM_I16_F16 : VOP1_Real_vi<0x4d>;
1337 defm V_CVT_NORM_U16_F16 : VOP1_Real_vi<0x4e>;
1339 defm V_ACCVGPR_MOV_B32 : VOP1Only_Real_vi<0x52>;
1341 let VOP1 = 1, SubtargetPredicate = isGFX8GFX9, Uses = [EXEC, M0], Size = V_MOV_B32_e32.Size in {
1343 // Copy of v_mov_b32 with $vdst as a use operand for use with VGPR
1344 // indexing mode. vdst can't be treated as a def for codegen purposes,
1345 // and an implicit use and def of the super register should be added.
1346 def V_MOV_B32_indirect_write : VPseudoInstSI<(outs),
1347 (ins getVALUDstForVT<i32>.ret:$vdst, getVOPSrc0ForVT<i32, 0>.ret:$src0)>,
1348 PseudoInstExpansion<(V_MOV_B32_e32_vi getVALUDstForVT<i32>.ret:$vdst,
1349 getVOPSrc0ForVT<i32, 0>.ret:$src0)>;
1351 // Copy of v_mov_b32 for use with VGPR indexing mode. An implicit use of the
1352 // super register should be added.
1353 def V_MOV_B32_indirect_read : VPseudoInstSI<
1354 (outs getVALUDstForVT<i32>.ret:$vdst),
1355 (ins getVOPSrc0ForVT<i32, 0>.ret:$src0)>,
1356 PseudoInstExpansion<(V_MOV_B32_e32_vi getVALUDstForVT<i32>.ret:$vdst,
1357 getVOPSrc0ForVT<i32, 0>.ret:$src0)>;
1359 } // End VOP1 = 1, SubtargetPredicate = isGFX8GFX9, Uses = [M0]
1361 let OtherPredicates = [isGFX8Plus] in {
1364 (i32 (int_amdgcn_mov_dpp i32:$src, timm:$dpp_ctrl, timm:$row_mask,
1365 timm:$bank_mask, timm:$bound_ctrl)),
1366 (V_MOV_B32_dpp VGPR_32:$src, VGPR_32:$src, (as_i32timm $dpp_ctrl),
1367 (as_i32timm $row_mask), (as_i32timm $bank_mask),
1368 (as_i1timm $bound_ctrl))
1371 foreach vt = Reg32Types.types in {
1373 (vt (int_amdgcn_update_dpp vt:$old, vt:$src, timm:$dpp_ctrl,
1374 timm:$row_mask, timm:$bank_mask,
1376 (V_MOV_B32_dpp VGPR_32:$old, VGPR_32:$src, (as_i32timm $dpp_ctrl),
1377 (as_i32timm $row_mask), (as_i32timm $bank_mask),
1378 (as_i1timm $bound_ctrl))
1382 } // End OtherPredicates = [isGFX8Plus]
1384 let OtherPredicates = [isGFX8Plus] in {
1386 (i32 (anyext i16:$src)),
1391 (i64 (anyext i16:$src)),
1392 (REG_SEQUENCE VReg_64,
1393 (i32 (COPY $src)), sub0,
1394 (V_MOV_B32_e32 (i32 0)), sub1)
1398 (i16 (trunc i32:$src)),
1403 (i16 (trunc i64:$src)),
1404 (EXTRACT_SUBREG $src, sub0)
1407 } // End OtherPredicates = [isGFX8Plus]
1409 //===----------------------------------------------------------------------===//
1411 //===----------------------------------------------------------------------===//
1413 let AssemblerPredicate = isGFX9Only, DecoderNamespace = "GFX9" in {
1414 multiclass VOP1_Real_gfx9 <bits<10> op> {
1415 defm NAME : VOP1_Real_e32e64_vi <op>;
1417 if !cast<VOP1_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA9 then
1419 VOP_SDWA9_Real <!cast<VOP1_SDWA_Pseudo>(NAME#"_sdwa")>,
1420 VOP1_SDWA9Ae <op{7-0}, !cast<VOP1_SDWA_Pseudo>(NAME#"_sdwa").Pfl>;
1422 if !cast<VOP1_Pseudo>(NAME#"_e32").Pfl.HasExtDPP then
1424 VOP_DPP_Real<!cast<VOP1_DPP_Pseudo>(NAME#"_dpp"), SIEncodingFamily.GFX9>,
1425 VOP1_DPPe<op{7-0}, !cast<VOP1_DPP_Pseudo>(NAME#"_dpp")>;
1428 multiclass VOP1_Real_NoDstSel_SDWA_gfx9 <bits<10> op> {
1429 defm NAME : VOP1_Real_e32e64_vi <op>;
1431 if !cast<VOP1_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA9 then
1433 VOP_SDWA9_Real <!cast<VOP1_SDWA_Pseudo>(NAME#"_sdwa")>,
1434 VOP1_SDWA9Ae <op{7-0}, !cast<VOP1_SDWA_Pseudo>(NAME#"_sdwa").Pfl> {
1435 let Inst{42-40} = 6;
1438 if !cast<VOP1_Pseudo>(NAME#"_e32").Pfl.HasExtDPP then
1440 VOP_DPP_Real<!cast<VOP1_DPP_Pseudo>(NAME#"_dpp"), SIEncodingFamily.GFX9>,
1441 VOP1_DPPe<op{7-0}, !cast<VOP1_DPP_Pseudo>(NAME#"_dpp")>;
1445 defm V_SCREEN_PARTITION_4SE_B32 : VOP1_Real_gfx9 <0x37>;
1447 let AssemblerPredicate = isGFX940Plus in
1448 defm V_MOV_B64 : VOP1_Real_gfx9 <0x38>;
1450 defm V_CVT_F32_FP8 : VOP1_Real_NoDstSel_SDWA_gfx9<0x54>;
1451 defm V_CVT_F32_BF8 : VOP1_Real_NoDstSel_SDWA_gfx9<0x55>;
1452 defm V_CVT_PK_F32_FP8 : VOP1_Real_NoDstSel_SDWA_gfx9<0x56>;
1453 defm V_CVT_PK_F32_BF8 : VOP1_Real_NoDstSel_SDWA_gfx9<0x57>;
1455 class MovDPP8Pattern<Predicate Pred, Instruction Inst> : GCNPat <
1456 (i32 (int_amdgcn_mov_dpp8 i32:$src, timm:$dpp8)),
1457 (Inst VGPR_32:$src, VGPR_32:$src, (as_i32timm $dpp8), (i32 DPP8Mode.FI_0))> {
1458 let OtherPredicates = [Pred];
1461 def : MovDPP8Pattern<isGFX10Only, V_MOV_B32_dpp8_gfx10>;
1462 def : MovDPP8Pattern<isGFX11Only, V_MOV_B32_dpp8_gfx11>;
1463 def : MovDPP8Pattern<isGFX12Only, V_MOV_B32_dpp8_gfx12>;