xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/VOP1Instructions.td (revision 349cc55c9796c4596a5b9904cd3281af295f878f)
15ffd83dbSDimitry Andric//===-- VOP1Instructions.td - Vector Instruction Definitions --------------===//
20b57cec5SDimitry Andric//
30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric//
70b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric
90b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
100b57cec5SDimitry Andric// VOP1 Classes
110b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric
130b57cec5SDimitry Andricclass VOP1e <bits<8> op, VOPProfile P> : Enc32 {
140b57cec5SDimitry Andric  bits<8> vdst;
150b57cec5SDimitry Andric  bits<9> src0;
160b57cec5SDimitry Andric
170b57cec5SDimitry Andric  let Inst{8-0}   = !if(P.HasSrc0, src0{8-0}, ?);
180b57cec5SDimitry Andric  let Inst{16-9}  = op;
190b57cec5SDimitry Andric  let Inst{24-17} = !if(P.EmitDst, vdst{7-0}, 0);
200b57cec5SDimitry Andric  let Inst{31-25} = 0x3f; //encoding
210b57cec5SDimitry Andric}
220b57cec5SDimitry Andric
230b57cec5SDimitry Andricclass VOP1_SDWAe <bits<8> op, VOPProfile P> : VOP_SDWAe <P> {
240b57cec5SDimitry Andric  bits<8> vdst;
250b57cec5SDimitry Andric
260b57cec5SDimitry Andric  let Inst{8-0}   = 0xf9; // sdwa
270b57cec5SDimitry Andric  let Inst{16-9}  = op;
280b57cec5SDimitry Andric  let Inst{24-17} = !if(P.EmitDst, vdst{7-0}, 0);
290b57cec5SDimitry Andric  let Inst{31-25} = 0x3f; // encoding
300b57cec5SDimitry Andric}
310b57cec5SDimitry Andric
320b57cec5SDimitry Andricclass VOP1_SDWA9Ae <bits<8> op, VOPProfile P> : VOP_SDWA9Ae <P> {
330b57cec5SDimitry Andric  bits<8> vdst;
340b57cec5SDimitry Andric
350b57cec5SDimitry Andric  let Inst{8-0}   = 0xf9; // sdwa
360b57cec5SDimitry Andric  let Inst{16-9}  = op;
370b57cec5SDimitry Andric  let Inst{24-17} = !if(P.EmitDst, vdst{7-0}, 0);
380b57cec5SDimitry Andric  let Inst{31-25} = 0x3f; // encoding
390b57cec5SDimitry Andric}
400b57cec5SDimitry Andric
410b57cec5SDimitry Andricclass VOP1_Pseudo <string opName, VOPProfile P, list<dag> pattern=[], bit VOP1Only = 0> :
420b57cec5SDimitry Andric  VOP_Pseudo <opName, !if(VOP1Only, "", "_e32"), P, P.Outs32, P.Ins32, "", pattern> {
430b57cec5SDimitry Andric
440b57cec5SDimitry Andric  let AsmOperands = P.Asm32;
450b57cec5SDimitry Andric
460b57cec5SDimitry Andric  let Size = 4;
470b57cec5SDimitry Andric  let mayLoad = 0;
480b57cec5SDimitry Andric  let mayStore = 0;
490b57cec5SDimitry Andric  let hasSideEffects = 0;
500b57cec5SDimitry Andric
515ffd83dbSDimitry Andric  let ReadsModeReg = !or(isFloatType<P.DstVT>.ret, isFloatType<P.Src0VT>.ret);
525ffd83dbSDimitry Andric
535ffd83dbSDimitry Andric  let mayRaiseFPException = ReadsModeReg;
545ffd83dbSDimitry Andric
550b57cec5SDimitry Andric  let VOP1 = 1;
560b57cec5SDimitry Andric  let VALU = 1;
575ffd83dbSDimitry Andric  let Uses = !if(ReadsModeReg, [MODE, EXEC], [EXEC]);
580b57cec5SDimitry Andric
590b57cec5SDimitry Andric  let AsmVariantName = AMDGPUAsmVariants.Default;
600b57cec5SDimitry Andric}
610b57cec5SDimitry Andric
620b57cec5SDimitry Andricclass VOP1_Real <VOP1_Pseudo ps, int EncodingFamily> :
63fe6060f1SDimitry Andric  VOP_Real <ps>,
640b57cec5SDimitry Andric  InstSI <ps.OutOperandList, ps.InOperandList, ps.Mnemonic # ps.AsmOperands, []>,
650b57cec5SDimitry Andric  SIMCInstr <ps.PseudoInstr, EncodingFamily> {
660b57cec5SDimitry Andric
67fe6060f1SDimitry Andric  let VALU = 1;
68fe6060f1SDimitry Andric  let VOP1 = 1;
690b57cec5SDimitry Andric  let isPseudo = 0;
700b57cec5SDimitry Andric  let isCodeGenOnly = 0;
710b57cec5SDimitry Andric
720b57cec5SDimitry Andric  let Constraints     = ps.Constraints;
730b57cec5SDimitry Andric  let DisableEncoding = ps.DisableEncoding;
740b57cec5SDimitry Andric
750b57cec5SDimitry Andric  // copy relevant pseudo op flags
760b57cec5SDimitry Andric  let SubtargetPredicate = ps.SubtargetPredicate;
770b57cec5SDimitry Andric  let AsmMatchConverter  = ps.AsmMatchConverter;
780b57cec5SDimitry Andric  let AsmVariantName     = ps.AsmVariantName;
790b57cec5SDimitry Andric  let Constraints        = ps.Constraints;
800b57cec5SDimitry Andric  let DisableEncoding    = ps.DisableEncoding;
810b57cec5SDimitry Andric  let TSFlags            = ps.TSFlags;
820b57cec5SDimitry Andric  let UseNamedOperandTable = ps.UseNamedOperandTable;
830b57cec5SDimitry Andric  let Uses                 = ps.Uses;
840b57cec5SDimitry Andric  let Defs                 = ps.Defs;
85fe6060f1SDimitry Andric  let SchedRW              = ps.SchedRW;
86fe6060f1SDimitry Andric  let mayLoad              = ps.mayLoad;
87fe6060f1SDimitry Andric  let mayStore             = ps.mayStore;
88fe6060f1SDimitry Andric  let TRANS                = ps.TRANS;
890b57cec5SDimitry Andric}
900b57cec5SDimitry Andric
910b57cec5SDimitry Andricclass VOP1_SDWA_Pseudo <string OpName, VOPProfile P, list<dag> pattern=[]> :
920b57cec5SDimitry Andric  VOP_SDWA_Pseudo <OpName, P, pattern> {
930b57cec5SDimitry Andric  let AsmMatchConverter = "cvtSdwaVOP1";
940b57cec5SDimitry Andric}
950b57cec5SDimitry Andric
960b57cec5SDimitry Andricclass VOP1_DPP_Pseudo <string OpName, VOPProfile P, list<dag> pattern=[]> :
970b57cec5SDimitry Andric  VOP_DPP_Pseudo <OpName, P, pattern> {
980b57cec5SDimitry Andric}
990b57cec5SDimitry Andric
1000b57cec5SDimitry Andricclass getVOP1Pat64 <SDPatternOperator node, VOPProfile P> : LetDummies {
1010b57cec5SDimitry Andric  list<dag> ret =
1020b57cec5SDimitry Andric    !if(P.HasModifiers,
1035ffd83dbSDimitry Andric        [(set P.DstVT:$vdst, (node (P.Src0VT (VOP3Mods P.Src0VT:$src0, i32:$src0_modifiers))))],
1040b57cec5SDimitry Andric        !if(P.HasOMod,
1050b57cec5SDimitry Andric            [(set P.DstVT:$vdst, (node (P.Src0VT (VOP3OMods P.Src0VT:$src0,
1060b57cec5SDimitry Andric                                                  i1:$clamp, i32:$omod))))],
1070b57cec5SDimitry Andric            [(set P.DstVT:$vdst, (node P.Src0VT:$src0))]
1080b57cec5SDimitry Andric        )
1090b57cec5SDimitry Andric    );
1100b57cec5SDimitry Andric}
1110b57cec5SDimitry Andric
1120b57cec5SDimitry Andricmulticlass VOP1Inst <string opName, VOPProfile P,
1130b57cec5SDimitry Andric                     SDPatternOperator node = null_frag> {
1145ffd83dbSDimitry Andric  // We only want to set this on the basic, non-SDWA or DPP forms.
1155ffd83dbSDimitry Andric  defvar should_mov_imm = !eq(opName, "v_mov_b32");
1165ffd83dbSDimitry Andric
1175ffd83dbSDimitry Andric  let isMoveImm = should_mov_imm in {
1180b57cec5SDimitry Andric    def _e32 : VOP1_Pseudo <opName, P>;
1190b57cec5SDimitry Andric    def _e64 : VOP3_Pseudo <opName, P, getVOP1Pat64<node, P>.ret>;
1205ffd83dbSDimitry Andric  }
1218bcb0991SDimitry Andric
1228bcb0991SDimitry Andric  foreach _ = BoolToList<P.HasExtSDWA>.ret in
1230b57cec5SDimitry Andric    def _sdwa : VOP1_SDWA_Pseudo <opName, P>;
1248bcb0991SDimitry Andric
1250b57cec5SDimitry Andric  foreach _ = BoolToList<P.HasExtDPP>.ret in
1260b57cec5SDimitry Andric    def _dpp : VOP1_DPP_Pseudo <opName, P>;
1278bcb0991SDimitry Andric
1288bcb0991SDimitry Andric  def : MnemonicAlias<opName#"_e32", opName>, LetDummies;
1298bcb0991SDimitry Andric  def : MnemonicAlias<opName#"_e64", opName>, LetDummies;
1308bcb0991SDimitry Andric
1318bcb0991SDimitry Andric  foreach _ = BoolToList<P.HasExtSDWA>.ret in
1328bcb0991SDimitry Andric    def : MnemonicAlias<opName#"_sdwa", opName>, LetDummies;
1338bcb0991SDimitry Andric
1348bcb0991SDimitry Andric  foreach _ = BoolToList<P.HasExtDPP>.ret in
1358bcb0991SDimitry Andric    def : MnemonicAlias<opName#"_dpp", opName>, LetDummies;
1360b57cec5SDimitry Andric}
1370b57cec5SDimitry Andric
1380b57cec5SDimitry Andric// Special profile for instructions which have clamp
1390b57cec5SDimitry Andric// and output modifiers (but have no input modifiers)
1400b57cec5SDimitry Andricclass VOPProfileI2F<ValueType dstVt, ValueType srcVt> :
1410b57cec5SDimitry Andric  VOPProfile<[dstVt, srcVt, untyped, untyped]> {
1420b57cec5SDimitry Andric
1430b57cec5SDimitry Andric  let Ins64 = (ins Src0RC64:$src0, clampmod:$clamp, omod:$omod);
1440b57cec5SDimitry Andric  let Asm64 = "$vdst, $src0$clamp$omod";
1450b57cec5SDimitry Andric
1460b57cec5SDimitry Andric  let HasModifiers = 0;
1470b57cec5SDimitry Andric  let HasClamp = 1;
1480b57cec5SDimitry Andric}
1490b57cec5SDimitry Andric
1500b57cec5SDimitry Andricdef VOP1_F64_I32 : VOPProfileI2F <f64, i32>;
1510b57cec5SDimitry Andricdef VOP1_F32_I32 : VOPProfileI2F <f32, i32>;
1520b57cec5SDimitry Andricdef VOP1_F16_I16 : VOPProfileI2F <f16, i16>;
1530b57cec5SDimitry Andric
154fe6060f1SDimitry Andricclass VOP_SPECIAL_OMOD_PROF<ValueType dstVt, ValueType srcVt> :
155fe6060f1SDimitry Andric  VOPProfile<[dstVt, srcVt, untyped, untyped]> {
156fe6060f1SDimitry Andric
157fe6060f1SDimitry Andric  let HasOMod = 1;
158fe6060f1SDimitry Andric}
159fe6060f1SDimitry Andricdef VOP_I32_F32_SPECIAL_OMOD : VOP_SPECIAL_OMOD_PROF<i32, f32>;
160fe6060f1SDimitry Andricdef VOP_I32_F64_SPECIAL_OMOD : VOP_SPECIAL_OMOD_PROF<i32, f64>;
161fe6060f1SDimitry Andricdef VOP_I16_F16_SPECIAL_OMOD : VOP_SPECIAL_OMOD_PROF<i16, f16>;
162fe6060f1SDimitry Andric
1630b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1640b57cec5SDimitry Andric// VOP1 Instructions
1650b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1660b57cec5SDimitry Andric
1670b57cec5SDimitry Andriclet VOPAsmPrefer32Bit = 1 in {
1680b57cec5SDimitry Andricdefm V_NOP : VOP1Inst <"v_nop", VOP_NONE>;
1690b57cec5SDimitry Andric}
1700b57cec5SDimitry Andric
1715ffd83dbSDimitry Andriclet isReMaterializable = 1, isAsCheapAsAMove = 1 in {
1720b57cec5SDimitry Andricdefm V_MOV_B32 : VOP1Inst <"v_mov_b32", VOP_I32_I32>;
1730b57cec5SDimitry Andric} // End isMoveImm = 1
1740b57cec5SDimitry Andric
1750b57cec5SDimitry Andric// FIXME: Specify SchedRW for READFIRSTLANE_B32
1760b57cec5SDimitry Andric// TODO: Make profile for this, there is VOP3 encoding also
1770b57cec5SDimitry Andricdef V_READFIRSTLANE_B32 :
1780b57cec5SDimitry Andric  InstSI <(outs SReg_32:$vdst),
1790b57cec5SDimitry Andric    (ins VRegOrLds_32:$src0),
1800b57cec5SDimitry Andric    "v_readfirstlane_b32 $vdst, $src0",
181480093f4SDimitry Andric    [(set i32:$vdst, (int_amdgcn_readfirstlane (i32 VRegOrLds_32:$src0)))]>,
1820b57cec5SDimitry Andric  Enc32 {
1830b57cec5SDimitry Andric
1840b57cec5SDimitry Andric  let isCodeGenOnly = 0;
1850b57cec5SDimitry Andric  let UseNamedOperandTable = 1;
1860b57cec5SDimitry Andric
1870b57cec5SDimitry Andric  let Size = 4;
1880b57cec5SDimitry Andric  let mayLoad = 0;
1890b57cec5SDimitry Andric  let mayStore = 0;
1900b57cec5SDimitry Andric  let hasSideEffects = 0;
1910b57cec5SDimitry Andric
1920b57cec5SDimitry Andric  let VOP1 = 1;
1930b57cec5SDimitry Andric  let VALU = 1;
1940b57cec5SDimitry Andric  let Uses = [EXEC];
1950b57cec5SDimitry Andric  let isConvergent = 1;
1960b57cec5SDimitry Andric
1970b57cec5SDimitry Andric  bits<8> vdst;
1980b57cec5SDimitry Andric  bits<9> src0;
1990b57cec5SDimitry Andric
2000b57cec5SDimitry Andric  let Inst{8-0}   = src0;
2010b57cec5SDimitry Andric  let Inst{16-9}  = 0x2;
2020b57cec5SDimitry Andric  let Inst{24-17} = vdst;
2030b57cec5SDimitry Andric  let Inst{31-25} = 0x3f; //encoding
2040b57cec5SDimitry Andric}
2050b57cec5SDimitry Andric
206fe6060f1SDimitry Andriclet isReMaterializable = 1 in {
2070b57cec5SDimitry Andriclet SchedRW = [WriteDoubleCvt] in {
208fe6060f1SDimitry Andric// OMod clears exceptions when set in this instruction
209fe6060f1SDimitry Andricdefm V_CVT_I32_F64 : VOP1Inst <"v_cvt_i32_f64", VOP_I32_F64_SPECIAL_OMOD,  fp_to_sint>;
2105ffd83dbSDimitry Andric
2115ffd83dbSDimitry Andriclet mayRaiseFPException = 0 in {
2120b57cec5SDimitry Andricdefm V_CVT_F64_I32 : VOP1Inst <"v_cvt_f64_i32", VOP1_F64_I32, sint_to_fp>;
2135ffd83dbSDimitry Andric}
2145ffd83dbSDimitry Andric
2150b57cec5SDimitry Andricdefm V_CVT_F32_F64 : VOP1Inst <"v_cvt_f32_f64", VOP_F32_F64,  fpround>;
2160b57cec5SDimitry Andricdefm V_CVT_F64_F32 : VOP1Inst <"v_cvt_f64_f32", VOP_F64_F32,  fpextend>;
217fe6060f1SDimitry Andric// OMod clears exceptions when set in this instruction
218fe6060f1SDimitry Andricdefm V_CVT_U32_F64 : VOP1Inst <"v_cvt_u32_f64", VOP_I32_F64_SPECIAL_OMOD,  fp_to_uint>;
2195ffd83dbSDimitry Andric
2205ffd83dbSDimitry Andriclet mayRaiseFPException = 0 in {
2210b57cec5SDimitry Andricdefm V_CVT_F64_U32 : VOP1Inst <"v_cvt_f64_u32", VOP1_F64_I32, uint_to_fp>;
2225ffd83dbSDimitry Andric}
2235ffd83dbSDimitry Andric
2240b57cec5SDimitry Andric} // End SchedRW = [WriteDoubleCvt]
2250b57cec5SDimitry Andric
2265ffd83dbSDimitry Andriclet SchedRW = [WriteFloatCvt] in {
2275ffd83dbSDimitry Andric
2285ffd83dbSDimitry Andric// XXX: Does this really not raise exceptions? The manual claims the
2295ffd83dbSDimitry Andric// 16-bit ones can.
2305ffd83dbSDimitry Andriclet mayRaiseFPException = 0 in {
2310b57cec5SDimitry Andricdefm V_CVT_F32_I32 : VOP1Inst <"v_cvt_f32_i32", VOP1_F32_I32, sint_to_fp>;
2320b57cec5SDimitry Andricdefm V_CVT_F32_U32 : VOP1Inst <"v_cvt_f32_u32", VOP1_F32_I32, uint_to_fp>;
2335ffd83dbSDimitry Andric}
2345ffd83dbSDimitry Andric
235fe6060f1SDimitry Andric// OMod clears exceptions when set in these 2 instructions
236fe6060f1SDimitry Andricdefm V_CVT_U32_F32 : VOP1Inst <"v_cvt_u32_f32", VOP_I32_F32_SPECIAL_OMOD, fp_to_uint>;
237fe6060f1SDimitry Andricdefm V_CVT_I32_F32 : VOP1Inst <"v_cvt_i32_f32", VOP_I32_F32_SPECIAL_OMOD, fp_to_sint>;
238fe6060f1SDimitry Andriclet FPDPRounding = 1, isReMaterializable = 0 in {
2390b57cec5SDimitry Andricdefm V_CVT_F16_F32 : VOP1Inst <"v_cvt_f16_f32", VOP_F16_F32, fpround>;
240fe6060f1SDimitry Andric} // End FPDPRounding = 1, isReMaterializable = 0
2415ffd83dbSDimitry Andric
2420b57cec5SDimitry Andricdefm V_CVT_F32_F16 : VOP1Inst <"v_cvt_f32_f16", VOP_F32_F16, fpextend>;
2435ffd83dbSDimitry Andric
2445ffd83dbSDimitry Andriclet ReadsModeReg = 0, mayRaiseFPException = 0 in {
2450b57cec5SDimitry Andricdefm V_CVT_RPI_I32_F32 : VOP1Inst <"v_cvt_rpi_i32_f32", VOP_I32_F32, cvt_rpi_i32_f32>;
2460b57cec5SDimitry Andricdefm V_CVT_FLR_I32_F32 : VOP1Inst <"v_cvt_flr_i32_f32", VOP_I32_F32, cvt_flr_i32_f32>;
2470b57cec5SDimitry Andricdefm V_CVT_OFF_F32_I4 : VOP1Inst  <"v_cvt_off_f32_i4", VOP1_F32_I32>;
2485ffd83dbSDimitry Andric} // End ReadsModeReg = 0, mayRaiseFPException = 0
2495ffd83dbSDimitry Andric} // End SchedRW = [WriteFloatCvt]
2500b57cec5SDimitry Andric
2515ffd83dbSDimitry Andriclet ReadsModeReg = 0, mayRaiseFPException = 0 in {
2520b57cec5SDimitry Andricdefm V_CVT_F32_UBYTE0 : VOP1Inst <"v_cvt_f32_ubyte0", VOP1_F32_I32, AMDGPUcvt_f32_ubyte0>;
2530b57cec5SDimitry Andricdefm V_CVT_F32_UBYTE1 : VOP1Inst <"v_cvt_f32_ubyte1", VOP1_F32_I32, AMDGPUcvt_f32_ubyte1>;
2540b57cec5SDimitry Andricdefm V_CVT_F32_UBYTE2 : VOP1Inst <"v_cvt_f32_ubyte2", VOP1_F32_I32, AMDGPUcvt_f32_ubyte2>;
2550b57cec5SDimitry Andricdefm V_CVT_F32_UBYTE3 : VOP1Inst <"v_cvt_f32_ubyte3", VOP1_F32_I32, AMDGPUcvt_f32_ubyte3>;
2565ffd83dbSDimitry Andric} // ReadsModeReg = 0, mayRaiseFPException = 0
2570b57cec5SDimitry Andric
2580b57cec5SDimitry Andricdefm V_FRACT_F32 : VOP1Inst <"v_fract_f32", VOP_F32_F32, AMDGPUfract>;
2590b57cec5SDimitry Andricdefm V_TRUNC_F32 : VOP1Inst <"v_trunc_f32", VOP_F32_F32, ftrunc>;
2600b57cec5SDimitry Andricdefm V_CEIL_F32 : VOP1Inst <"v_ceil_f32", VOP_F32_F32, fceil>;
2610b57cec5SDimitry Andricdefm V_RNDNE_F32 : VOP1Inst <"v_rndne_f32", VOP_F32_F32, frint>;
2620b57cec5SDimitry Andricdefm V_FLOOR_F32 : VOP1Inst <"v_floor_f32", VOP_F32_F32, ffloor>;
2630b57cec5SDimitry Andric
264e8d8bef9SDimitry Andriclet TRANS = 1, SchedRW = [WriteTrans32] in {
2650b57cec5SDimitry Andricdefm V_EXP_F32 : VOP1Inst <"v_exp_f32", VOP_F32_F32, fexp2>;
2660b57cec5SDimitry Andricdefm V_LOG_F32 : VOP1Inst <"v_log_f32", VOP_F32_F32, flog2>;
2670b57cec5SDimitry Andricdefm V_RCP_F32 : VOP1Inst <"v_rcp_f32", VOP_F32_F32, AMDGPUrcp>;
2680b57cec5SDimitry Andricdefm V_RCP_IFLAG_F32 : VOP1Inst <"v_rcp_iflag_f32", VOP_F32_F32, AMDGPUrcp_iflag>;
2690b57cec5SDimitry Andricdefm V_RSQ_F32 : VOP1Inst <"v_rsq_f32", VOP_F32_F32, AMDGPUrsq>;
2705ffd83dbSDimitry Andricdefm V_SQRT_F32 : VOP1Inst <"v_sqrt_f32", VOP_F32_F32, any_amdgcn_sqrt>;
271e8d8bef9SDimitry Andric} // End TRANS = 1, SchedRW = [WriteTrans32]
2720b57cec5SDimitry Andric
273e8d8bef9SDimitry Andriclet TRANS = 1, SchedRW = [WriteTrans64] in {
2740b57cec5SDimitry Andricdefm V_RCP_F64 : VOP1Inst <"v_rcp_f64", VOP_F64_F64, AMDGPUrcp>;
2750b57cec5SDimitry Andricdefm V_RSQ_F64 : VOP1Inst <"v_rsq_f64", VOP_F64_F64, AMDGPUrsq>;
2765ffd83dbSDimitry Andricdefm V_SQRT_F64 : VOP1Inst <"v_sqrt_f64", VOP_F64_F64, any_amdgcn_sqrt>;
277e8d8bef9SDimitry Andric} // End TRANS = 1, SchedRW = [WriteTrans64]
2780b57cec5SDimitry Andric
279e8d8bef9SDimitry Andriclet TRANS = 1, SchedRW = [WriteTrans32] in {
2800b57cec5SDimitry Andricdefm V_SIN_F32 : VOP1Inst <"v_sin_f32", VOP_F32_F32, AMDGPUsin>;
2810b57cec5SDimitry Andricdefm V_COS_F32 : VOP1Inst <"v_cos_f32", VOP_F32_F32, AMDGPUcos>;
282e8d8bef9SDimitry Andric} // End TRANS = 1, SchedRW = [WriteTrans32]
2830b57cec5SDimitry Andric
2840b57cec5SDimitry Andricdefm V_NOT_B32 : VOP1Inst <"v_not_b32", VOP_I32_I32>;
2858bcb0991SDimitry Andricdefm V_BFREV_B32 : VOP1Inst <"v_bfrev_b32", VOP_I32_I32, bitreverse>;
2868bcb0991SDimitry Andricdefm V_FFBH_U32 : VOP1Inst <"v_ffbh_u32", VOP_I32_I32, AMDGPUffbh_u32>;
2875ffd83dbSDimitry Andricdefm V_FFBL_B32 : VOP1Inst <"v_ffbl_b32", VOP_I32_I32, AMDGPUffbl_b32>;
2888bcb0991SDimitry Andricdefm V_FFBH_I32 : VOP1Inst <"v_ffbh_i32", VOP_I32_I32, AMDGPUffbh_i32>;
2890b57cec5SDimitry Andric
2900b57cec5SDimitry Andriclet SchedRW = [WriteDoubleAdd] in {
291fe6060f1SDimitry Andricdefm V_FREXP_EXP_I32_F64 : VOP1Inst <"v_frexp_exp_i32_f64", VOP_I32_F64_SPECIAL_OMOD, int_amdgcn_frexp_exp>;
2920b57cec5SDimitry Andricdefm V_FREXP_MANT_F64 : VOP1Inst <"v_frexp_mant_f64", VOP_F64_F64, int_amdgcn_frexp_mant>;
2930b57cec5SDimitry Andriclet FPDPRounding = 1 in {
2940b57cec5SDimitry Andricdefm V_FRACT_F64 : VOP1Inst <"v_fract_f64", VOP_F64_F64, AMDGPUfract>;
2950b57cec5SDimitry Andric} // End FPDPRounding = 1
2960b57cec5SDimitry Andric} // End SchedRW = [WriteDoubleAdd]
2970b57cec5SDimitry Andric
2980b57cec5SDimitry Andricdefm V_FREXP_EXP_I32_F32 : VOP1Inst <"v_frexp_exp_i32_f32", VOP_I32_F32, int_amdgcn_frexp_exp>;
2990b57cec5SDimitry Andricdefm V_FREXP_MANT_F32 : VOP1Inst <"v_frexp_mant_f32", VOP_F32_F32, int_amdgcn_frexp_mant>;
300fe6060f1SDimitry Andric} // End isReMaterializable = 1
3010b57cec5SDimitry Andric
3020b57cec5SDimitry Andriclet VOPAsmPrefer32Bit = 1 in {
3030b57cec5SDimitry Andricdefm V_CLREXCP : VOP1Inst <"v_clrexcp", VOP_NO_EXT<VOP_NONE>>;
3040b57cec5SDimitry Andric}
3050b57cec5SDimitry Andric
3060b57cec5SDimitry Andric// Restrict src0 to be VGPR
307480093f4SDimitry Andricdef VOP_MOVRELS : VOPProfile<[i32, i32, untyped, untyped]> {
3080b57cec5SDimitry Andric  let Src0RC32 = VRegSrc_32;
3090b57cec5SDimitry Andric  let Src0RC64 = VRegSrc_32;
3100b57cec5SDimitry Andric}
3110b57cec5SDimitry Andric
3120b57cec5SDimitry Andric// Special case because there are no true output operands.  Hack vdst
3130b57cec5SDimitry Andric// to be a src operand. The custom inserter must add a tied implicit
3140b57cec5SDimitry Andric// def and use of the super register since there seems to be no way to
3150b57cec5SDimitry Andric// add an implicit def of a virtual register in tablegen.
316480093f4SDimitry Andricclass VOP_MOVREL<RegisterOperand Src1RC> : VOPProfile<[untyped, i32, untyped, untyped]> {
3170b57cec5SDimitry Andric  let Src0RC32 = VOPDstOperand<VGPR_32>;
3180b57cec5SDimitry Andric  let Src0RC64 = VOPDstOperand<VGPR_32>;
3190b57cec5SDimitry Andric
3200b57cec5SDimitry Andric  let Outs = (outs);
321480093f4SDimitry Andric  let Ins32 = (ins Src0RC32:$vdst, Src1RC:$src0);
322480093f4SDimitry Andric  let Ins64 = (ins Src0RC64:$vdst, Src1RC:$src0);
3230b57cec5SDimitry Andric  let Asm32 = getAsm32<1, 1>.ret;
3240b57cec5SDimitry Andric  let Asm64 = getAsm64<1, 1, 0, 0, 1>.ret;
325480093f4SDimitry Andric
326480093f4SDimitry Andric  let OutsSDWA = (outs Src0RC32:$vdst);
327480093f4SDimitry Andric  let InsSDWA = (ins Src0ModSDWA:$src0_modifiers, Src0SDWA:$src0,
328480093f4SDimitry Andric                     clampmod:$clamp, dst_sel:$dst_sel, dst_unused:$dst_unused,
329480093f4SDimitry Andric                     src0_sel:$src0_sel);
3300b57cec5SDimitry Andric  let AsmSDWA9 = getAsmSDWA9<1, 0, 1>.ret;
3310b57cec5SDimitry Andric
332480093f4SDimitry Andric  let OutsDPP = (outs Src0RC32:$vdst);
333480093f4SDimitry Andric  let InsDPP16 = (ins Src0RC32:$old, Src0RC32:$src0,
334480093f4SDimitry Andric                      dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
335480093f4SDimitry Andric                      bank_mask:$bank_mask, bound_ctrl:$bound_ctrl, FI:$fi);
336480093f4SDimitry Andric  let AsmDPP16 = getAsmDPP16<1, 1, 0>.ret;
337480093f4SDimitry Andric
338480093f4SDimitry Andric  let OutsDPP8 = (outs Src0RC32:$vdst);
339480093f4SDimitry Andric  let InsDPP8 = (ins Src0RC32:$old, Src0RC32:$src0, dpp8:$dpp8, FI:$fi);
340480093f4SDimitry Andric  let AsmDPP8 = getAsmDPP8<1, 1, 0>.ret;
3410b57cec5SDimitry Andric
3420b57cec5SDimitry Andric  let HasDst = 0;
3430b57cec5SDimitry Andric  let EmitDst = 1; // force vdst emission
3440b57cec5SDimitry Andric}
3450b57cec5SDimitry Andric
346480093f4SDimitry Andricdef VOP_MOVRELD : VOP_MOVREL<VSrc_b32>;
347480093f4SDimitry Andricdef VOP_MOVRELSD : VOP_MOVREL<VRegSrc_32>;
348480093f4SDimitry Andric
3490b57cec5SDimitry Andriclet SubtargetPredicate = HasMovrel, Uses = [M0, EXEC] in {
3500b57cec5SDimitry Andric // v_movreld_b32 is a special case because the destination output
3510b57cec5SDimitry Andric // register is really a source. It isn't actually read (but may be
3520b57cec5SDimitry Andric // written), and is only to provide the base register to start
3530b57cec5SDimitry Andric // indexing from. Tablegen seems to not let you define an implicit
3540b57cec5SDimitry Andric // virtual register output for the super register being written into,
3550b57cec5SDimitry Andric // so this must have an implicit def of the register added to it.
3560b57cec5SDimitry Andricdefm V_MOVRELD_B32 : VOP1Inst <"v_movreld_b32", VOP_MOVRELD>;
357480093f4SDimitry Andricdefm V_MOVRELS_B32 : VOP1Inst <"v_movrels_b32", VOP_MOVRELS>;
358480093f4SDimitry Andricdefm V_MOVRELSD_B32 : VOP1Inst <"v_movrelsd_b32", VOP_MOVRELSD>;
3590b57cec5SDimitry Andric} // End Uses = [M0, EXEC]
3600b57cec5SDimitry Andric
361fe6060f1SDimitry Andriclet isReMaterializable = 1 in {
3620b57cec5SDimitry Andriclet SubtargetPredicate = isGFX6GFX7 in {
363e8d8bef9SDimitry Andric  let TRANS = 1, SchedRW = [WriteTrans32] in {
3640b57cec5SDimitry Andric    defm V_LOG_CLAMP_F32 :
3650b57cec5SDimitry Andric      VOP1Inst<"v_log_clamp_f32", VOP_F32_F32, int_amdgcn_log_clamp>;
3660b57cec5SDimitry Andric    defm V_RCP_CLAMP_F32 :
3670b57cec5SDimitry Andric      VOP1Inst<"v_rcp_clamp_f32", VOP_F32_F32>;
3680b57cec5SDimitry Andric    defm V_RCP_LEGACY_F32 :
3690b57cec5SDimitry Andric      VOP1Inst<"v_rcp_legacy_f32", VOP_F32_F32, AMDGPUrcp_legacy>;
3700b57cec5SDimitry Andric    defm V_RSQ_CLAMP_F32 :
3710b57cec5SDimitry Andric      VOP1Inst<"v_rsq_clamp_f32", VOP_F32_F32, AMDGPUrsq_clamp>;
3720b57cec5SDimitry Andric    defm V_RSQ_LEGACY_F32 :
3735ffd83dbSDimitry Andric      VOP1Inst<"v_rsq_legacy_f32", VOP_F32_F32, int_amdgcn_rsq_legacy>;
374e8d8bef9SDimitry Andric  } // End TRANS = 1, SchedRW = [WriteTrans32]
3750b57cec5SDimitry Andric
376fe6060f1SDimitry Andric  let SchedRW = [WriteTrans64] in {
3770b57cec5SDimitry Andric    defm V_RCP_CLAMP_F64 :
3780b57cec5SDimitry Andric      VOP1Inst<"v_rcp_clamp_f64", VOP_F64_F64>;
3790b57cec5SDimitry Andric    defm V_RSQ_CLAMP_F64 :
3800b57cec5SDimitry Andric      VOP1Inst<"v_rsq_clamp_f64", VOP_F64_F64, AMDGPUrsq_clamp>;
381fe6060f1SDimitry Andric  } // End SchedRW = [WriteTrans64]
3820b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX6GFX7
3830b57cec5SDimitry Andric
3840b57cec5SDimitry Andriclet SubtargetPredicate = isGFX7GFX8GFX9 in {
385e8d8bef9SDimitry Andric  let TRANS = 1, SchedRW = [WriteTrans32] in {
3860b57cec5SDimitry Andric    defm V_LOG_LEGACY_F32 : VOP1Inst<"v_log_legacy_f32", VOP_F32_F32>;
3870b57cec5SDimitry Andric    defm V_EXP_LEGACY_F32 : VOP1Inst<"v_exp_legacy_f32", VOP_F32_F32>;
388e8d8bef9SDimitry Andric  } // End TRANS = 1, SchedRW = [WriteTrans32]
3890b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX7GFX8GFX9
3900b57cec5SDimitry Andric
3910b57cec5SDimitry Andriclet SubtargetPredicate = isGFX7Plus in {
3920b57cec5SDimitry Andric  let SchedRW = [WriteDoubleAdd] in {
3930b57cec5SDimitry Andric    defm V_TRUNC_F64 : VOP1Inst<"v_trunc_f64", VOP_F64_F64, ftrunc>;
3940b57cec5SDimitry Andric    defm V_CEIL_F64  : VOP1Inst<"v_ceil_f64", VOP_F64_F64, fceil>;
3950b57cec5SDimitry Andric    defm V_RNDNE_F64 : VOP1Inst<"v_rndne_f64", VOP_F64_F64, frint>;
3960b57cec5SDimitry Andric    defm V_FLOOR_F64 : VOP1Inst<"v_floor_f64", VOP_F64_F64, ffloor>;
3970b57cec5SDimitry Andric  } // End SchedRW = [WriteDoubleAdd]
3980b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX7Plus
399fe6060f1SDimitry Andric} // End isReMaterializable = 1
4000b57cec5SDimitry Andric
4010b57cec5SDimitry Andriclet SubtargetPredicate = Has16BitInsts in {
4020b57cec5SDimitry Andric
4030b57cec5SDimitry Andriclet FPDPRounding = 1 in {
4040b57cec5SDimitry Andricdefm V_CVT_F16_U16 : VOP1Inst <"v_cvt_f16_u16", VOP1_F16_I16, uint_to_fp>;
4050b57cec5SDimitry Andricdefm V_CVT_F16_I16 : VOP1Inst <"v_cvt_f16_i16", VOP1_F16_I16, sint_to_fp>;
4060b57cec5SDimitry Andric} // End FPDPRounding = 1
407fe6060f1SDimitry Andric// OMod clears exceptions when set in these two instructions
408fe6060f1SDimitry Andricdefm V_CVT_U16_F16 : VOP1Inst <"v_cvt_u16_f16", VOP_I16_F16_SPECIAL_OMOD, fp_to_uint>;
409fe6060f1SDimitry Andricdefm V_CVT_I16_F16 : VOP1Inst <"v_cvt_i16_f16", VOP_I16_F16_SPECIAL_OMOD, fp_to_sint>;
410e8d8bef9SDimitry Andriclet TRANS = 1, SchedRW = [WriteTrans32] in {
4110b57cec5SDimitry Andricdefm V_RCP_F16 : VOP1Inst <"v_rcp_f16", VOP_F16_F16, AMDGPUrcp>;
4125ffd83dbSDimitry Andricdefm V_SQRT_F16 : VOP1Inst <"v_sqrt_f16", VOP_F16_F16, any_amdgcn_sqrt>;
4130b57cec5SDimitry Andricdefm V_RSQ_F16 : VOP1Inst <"v_rsq_f16", VOP_F16_F16, AMDGPUrsq>;
4140b57cec5SDimitry Andricdefm V_LOG_F16 : VOP1Inst <"v_log_f16", VOP_F16_F16, flog2>;
4150b57cec5SDimitry Andricdefm V_EXP_F16 : VOP1Inst <"v_exp_f16", VOP_F16_F16, fexp2>;
4160b57cec5SDimitry Andricdefm V_SIN_F16 : VOP1Inst <"v_sin_f16", VOP_F16_F16, AMDGPUsin>;
4170b57cec5SDimitry Andricdefm V_COS_F16 : VOP1Inst <"v_cos_f16", VOP_F16_F16, AMDGPUcos>;
418e8d8bef9SDimitry Andric} // End TRANS = 1, SchedRW = [WriteTrans32]
4190b57cec5SDimitry Andricdefm V_FREXP_MANT_F16 : VOP1Inst <"v_frexp_mant_f16", VOP_F16_F16, int_amdgcn_frexp_mant>;
420fe6060f1SDimitry Andricdefm V_FREXP_EXP_I16_F16 : VOP1Inst <"v_frexp_exp_i16_f16", VOP_I16_F16_SPECIAL_OMOD, int_amdgcn_frexp_exp>;
4210b57cec5SDimitry Andricdefm V_FLOOR_F16 : VOP1Inst <"v_floor_f16", VOP_F16_F16, ffloor>;
4220b57cec5SDimitry Andricdefm V_CEIL_F16 : VOP1Inst <"v_ceil_f16", VOP_F16_F16, fceil>;
4230b57cec5SDimitry Andricdefm V_TRUNC_F16 : VOP1Inst <"v_trunc_f16", VOP_F16_F16, ftrunc>;
4240b57cec5SDimitry Andricdefm V_RNDNE_F16 : VOP1Inst <"v_rndne_f16", VOP_F16_F16, frint>;
4250b57cec5SDimitry Andriclet FPDPRounding = 1 in {
4260b57cec5SDimitry Andricdefm V_FRACT_F16 : VOP1Inst <"v_fract_f16", VOP_F16_F16, AMDGPUfract>;
4270b57cec5SDimitry Andric} // End FPDPRounding = 1
4280b57cec5SDimitry Andric
4290b57cec5SDimitry Andric}
4300b57cec5SDimitry Andric
4310b57cec5SDimitry Andriclet OtherPredicates = [Has16BitInsts] in {
4320b57cec5SDimitry Andric
4330b57cec5SDimitry Andricdef : GCNPat<
4340b57cec5SDimitry Andric    (f32 (f16_to_fp i16:$src)),
4350b57cec5SDimitry Andric    (V_CVT_F32_F16_e32 $src)
4360b57cec5SDimitry Andric>;
4370b57cec5SDimitry Andric
4380b57cec5SDimitry Andricdef : GCNPat<
4390b57cec5SDimitry Andric    (i16 (AMDGPUfp_to_f16 f32:$src)),
4400b57cec5SDimitry Andric    (V_CVT_F16_F32_e32 $src)
4410b57cec5SDimitry Andric>;
4420b57cec5SDimitry Andric
4430b57cec5SDimitry Andric}
4440b57cec5SDimitry Andric
4450b57cec5SDimitry Andricdef VOP_SWAP_I32 : VOPProfile<[i32, i32, i32, untyped]> {
4460b57cec5SDimitry Andric  let Outs32 = (outs VGPR_32:$vdst, VGPR_32:$vdst1);
4470b57cec5SDimitry Andric  let Ins32 = (ins VGPR_32:$src0, VGPR_32:$src1);
4480b57cec5SDimitry Andric  let Outs64 = Outs32;
4490b57cec5SDimitry Andric  let Asm32 = " $vdst, $src0";
4500b57cec5SDimitry Andric  let Asm64 = "";
4510b57cec5SDimitry Andric  let Ins64 = (ins);
4520b57cec5SDimitry Andric}
4530b57cec5SDimitry Andric
4540b57cec5SDimitry Andriclet SubtargetPredicate = isGFX9Plus in {
4550b57cec5SDimitry Andric  def V_SWAP_B32 : VOP1_Pseudo<"v_swap_b32", VOP_SWAP_I32, [], 1> {
4560b57cec5SDimitry Andric    let Constraints = "$vdst = $src1, $vdst1 = $src0";
4570b57cec5SDimitry Andric    let DisableEncoding = "$vdst1,$src1";
4580b57cec5SDimitry Andric    let SchedRW = [Write64Bit, Write64Bit];
4590b57cec5SDimitry Andric  }
4600b57cec5SDimitry Andric
461fe6060f1SDimitry Andric  let isReMaterializable = 1 in
4620b57cec5SDimitry Andric  defm V_SAT_PK_U8_I16    : VOP1Inst<"v_sat_pk_u8_i16", VOP_I32_I32>;
4635ffd83dbSDimitry Andric
4645ffd83dbSDimitry Andric  let mayRaiseFPException = 0 in {
465fe6060f1SDimitry Andric    defm V_CVT_NORM_I16_F16 : VOP1Inst<"v_cvt_norm_i16_f16", VOP_I16_F16_SPECIAL_OMOD>;
466fe6060f1SDimitry Andric    defm V_CVT_NORM_U16_F16 : VOP1Inst<"v_cvt_norm_u16_f16", VOP_I16_F16_SPECIAL_OMOD>;
4675ffd83dbSDimitry Andric  } // End mayRaiseFPException = 0
4680b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX9Plus
4690b57cec5SDimitry Andric
4700b57cec5SDimitry Andriclet SubtargetPredicate = isGFX9Only in {
4710b57cec5SDimitry Andric  defm V_SCREEN_PARTITION_4SE_B32 : VOP1Inst <"v_screen_partition_4se_b32", VOP_I32_I32>;
4720b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX9Only
4730b57cec5SDimitry Andric
4740b57cec5SDimitry Andriclet SubtargetPredicate = isGFX10Plus in {
4750b57cec5SDimitry Andric  defm V_PIPEFLUSH        : VOP1Inst<"v_pipeflush", VOP_NONE>;
4760b57cec5SDimitry Andric
4770b57cec5SDimitry Andric  let Uses = [M0] in {
4780b57cec5SDimitry Andric    defm V_MOVRELSD_2_B32 :
479480093f4SDimitry Andric      VOP1Inst<"v_movrelsd_2_b32", VOP_MOVRELSD>;
4800b57cec5SDimitry Andric
4810b57cec5SDimitry Andric    def V_SWAPREL_B32 : VOP1_Pseudo<"v_swaprel_b32", VOP_SWAP_I32, [], 1> {
4820b57cec5SDimitry Andric      let Constraints = "$vdst = $src1, $vdst1 = $src0";
4830b57cec5SDimitry Andric      let DisableEncoding = "$vdst1,$src1";
4840b57cec5SDimitry Andric      let SchedRW = [Write64Bit, Write64Bit];
4850b57cec5SDimitry Andric    }
4860b57cec5SDimitry Andric  } // End Uses = [M0]
4870b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX10Plus
4880b57cec5SDimitry Andric
489fe6060f1SDimitry Andricdef VOPProfileAccMov : VOP_NO_EXT<VOP_I32_I32> {
490fe6060f1SDimitry Andric  let DstRC = RegisterOperand<AGPR_32>;
491fe6060f1SDimitry Andric  let Src0RC32 = RegisterOperand<AGPR_32>;
492fe6060f1SDimitry Andric  let Asm32 = " $vdst, $src0";
493fe6060f1SDimitry Andric}
494fe6060f1SDimitry Andric
495fe6060f1SDimitry Andricdef V_ACCVGPR_MOV_B32 : VOP1_Pseudo<"v_accvgpr_mov_b32", VOPProfileAccMov, [], 1> {
496fe6060f1SDimitry Andric  let SubtargetPredicate = isGFX90APlus;
497fe6060f1SDimitry Andric  let isReMaterializable = 1;
498fe6060f1SDimitry Andric  let isAsCheapAsAMove = 1;
499fe6060f1SDimitry Andric}
500fe6060f1SDimitry Andric
5010b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
5020b57cec5SDimitry Andric// Target-specific instruction encodings.
5030b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
5040b57cec5SDimitry Andric
5058bcb0991SDimitry Andricclass VOP1_DPP<bits<8> op, VOP1_DPP_Pseudo ps, VOPProfile p = ps.Pfl, bit isDPP16 = 0> :
5060b57cec5SDimitry Andric    VOP_DPP<ps.OpName, p, isDPP16> {
5070b57cec5SDimitry Andric  let hasSideEffects = ps.hasSideEffects;
5080b57cec5SDimitry Andric  let Defs = ps.Defs;
5090b57cec5SDimitry Andric  let SchedRW = ps.SchedRW;
5100b57cec5SDimitry Andric  let Uses = ps.Uses;
511fe6060f1SDimitry Andric  let TRANS = ps.TRANS;
5120b57cec5SDimitry Andric
5130b57cec5SDimitry Andric  bits<8> vdst;
5140b57cec5SDimitry Andric  let Inst{8-0}   = 0xfa;
5150b57cec5SDimitry Andric  let Inst{16-9}  = op;
5160b57cec5SDimitry Andric  let Inst{24-17} = !if(p.EmitDst, vdst{7-0}, 0);
5170b57cec5SDimitry Andric  let Inst{31-25} = 0x3f;
5180b57cec5SDimitry Andric}
5190b57cec5SDimitry Andric
5208bcb0991SDimitry Andricclass VOP1_DPP16<bits<8> op, VOP1_DPP_Pseudo ps, VOPProfile p = ps.Pfl> :
5218bcb0991SDimitry Andric    VOP1_DPP<op, ps, p, 1>,
5228bcb0991SDimitry Andric    SIMCInstr <ps.PseudoInstr, SIEncodingFamily.GFX10> {
5235ffd83dbSDimitry Andric  let AssemblerPredicate = HasDPP16;
5240b57cec5SDimitry Andric  let SubtargetPredicate = HasDPP16;
5250b57cec5SDimitry Andric}
5260b57cec5SDimitry Andric
5270b57cec5SDimitry Andricclass VOP1_DPP8<bits<8> op, VOP1_Pseudo ps, VOPProfile p = ps.Pfl> :
5280b57cec5SDimitry Andric    VOP_DPP8<ps.OpName, p> {
5290b57cec5SDimitry Andric  let hasSideEffects = ps.hasSideEffects;
5300b57cec5SDimitry Andric  let Defs = ps.Defs;
5310b57cec5SDimitry Andric  let SchedRW = ps.SchedRW;
5320b57cec5SDimitry Andric  let Uses = ps.Uses;
5330b57cec5SDimitry Andric
5340b57cec5SDimitry Andric  bits<8> vdst;
5350b57cec5SDimitry Andric  let Inst{8-0}   = fi;
5360b57cec5SDimitry Andric  let Inst{16-9}  = op;
5370b57cec5SDimitry Andric  let Inst{24-17} = !if(p.EmitDst, vdst{7-0}, 0);
5380b57cec5SDimitry Andric  let Inst{31-25} = 0x3f;
5390b57cec5SDimitry Andric}
5400b57cec5SDimitry Andric
5410b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
5420b57cec5SDimitry Andric// GFX10.
5430b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
5440b57cec5SDimitry Andric
5450b57cec5SDimitry Andriclet AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10" in {
5460b57cec5SDimitry Andric  multiclass VOP1Only_Real_gfx10<bits<9> op> {
5470b57cec5SDimitry Andric    def _gfx10 :
5480b57cec5SDimitry Andric      VOP1_Real<!cast<VOP1_Pseudo>(NAME), SIEncodingFamily.GFX10>,
5490b57cec5SDimitry Andric      VOP1e<op{7-0}, !cast<VOP1_Pseudo>(NAME).Pfl>;
5500b57cec5SDimitry Andric  }
5510b57cec5SDimitry Andric  multiclass VOP1_Real_e32_gfx10<bits<9> op> {
5520b57cec5SDimitry Andric    def _e32_gfx10 :
5530b57cec5SDimitry Andric      VOP1_Real<!cast<VOP1_Pseudo>(NAME#"_e32"), SIEncodingFamily.GFX10>,
5540b57cec5SDimitry Andric      VOP1e<op{7-0}, !cast<VOP1_Pseudo>(NAME#"_e32").Pfl>;
5550b57cec5SDimitry Andric  }
5560b57cec5SDimitry Andric  multiclass VOP1_Real_e64_gfx10<bits<9> op> {
5570b57cec5SDimitry Andric    def _e64_gfx10 :
5580b57cec5SDimitry Andric      VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX10>,
5590b57cec5SDimitry Andric      VOP3e_gfx10<{0, 1, 1, op{6-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
5600b57cec5SDimitry Andric  }
5610b57cec5SDimitry Andric  multiclass VOP1_Real_sdwa_gfx10<bits<9> op> {
5628bcb0991SDimitry Andric    foreach _ = BoolToList<!cast<VOP1_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA9>.ret in
5630b57cec5SDimitry Andric    def _sdwa_gfx10 :
5640b57cec5SDimitry Andric      VOP_SDWA10_Real<!cast<VOP1_SDWA_Pseudo>(NAME#"_sdwa")>,
5650b57cec5SDimitry Andric      VOP1_SDWA9Ae<op{7-0}, !cast<VOP1_SDWA_Pseudo>(NAME#"_sdwa").Pfl> {
5660b57cec5SDimitry Andric      let DecoderNamespace = "SDWA10";
5670b57cec5SDimitry Andric    }
5680b57cec5SDimitry Andric  }
5690b57cec5SDimitry Andric  multiclass VOP1_Real_dpp_gfx10<bits<9> op> {
5708bcb0991SDimitry Andric    foreach _ = BoolToList<!cast<VOP1_Pseudo>(NAME#"_e32").Pfl.HasExtDPP>.ret in
5718bcb0991SDimitry Andric    def _dpp_gfx10 : VOP1_DPP16<op{7-0}, !cast<VOP1_DPP_Pseudo>(NAME#"_dpp")> {
5720b57cec5SDimitry Andric      let DecoderNamespace = "SDWA10";
5730b57cec5SDimitry Andric    }
5740b57cec5SDimitry Andric  }
5750b57cec5SDimitry Andric  multiclass VOP1_Real_dpp8_gfx10<bits<9> op> {
5768bcb0991SDimitry Andric    foreach _ = BoolToList<!cast<VOP1_Pseudo>(NAME#"_e32").Pfl.HasExtDPP>.ret in
5770b57cec5SDimitry Andric    def _dpp8_gfx10 : VOP1_DPP8<op{7-0}, !cast<VOP1_Pseudo>(NAME#"_e32")> {
5780b57cec5SDimitry Andric      let DecoderNamespace = "DPP8";
5790b57cec5SDimitry Andric    }
5800b57cec5SDimitry Andric  }
5810b57cec5SDimitry Andric} // End AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10"
5820b57cec5SDimitry Andric
5830b57cec5SDimitry Andricmulticlass VOP1_Real_gfx10<bits<9> op> :
584480093f4SDimitry Andric  VOP1_Real_e32_gfx10<op>, VOP1_Real_e64_gfx10<op>,
585480093f4SDimitry Andric  VOP1_Real_sdwa_gfx10<op>, VOP1_Real_dpp_gfx10<op>,
586480093f4SDimitry Andric  VOP1_Real_dpp8_gfx10<op>;
5870b57cec5SDimitry Andric
5880b57cec5SDimitry Andricdefm V_PIPEFLUSH         : VOP1_Real_gfx10<0x01b>;
5890b57cec5SDimitry Andricdefm V_MOVRELSD_2_B32    : VOP1_Real_gfx10<0x048>;
5900b57cec5SDimitry Andricdefm V_CVT_F16_U16       : VOP1_Real_gfx10<0x050>;
5910b57cec5SDimitry Andricdefm V_CVT_F16_I16       : VOP1_Real_gfx10<0x051>;
5920b57cec5SDimitry Andricdefm V_CVT_U16_F16       : VOP1_Real_gfx10<0x052>;
5930b57cec5SDimitry Andricdefm V_CVT_I16_F16       : VOP1_Real_gfx10<0x053>;
5940b57cec5SDimitry Andricdefm V_RCP_F16           : VOP1_Real_gfx10<0x054>;
5950b57cec5SDimitry Andricdefm V_SQRT_F16          : VOP1_Real_gfx10<0x055>;
5960b57cec5SDimitry Andricdefm V_RSQ_F16           : VOP1_Real_gfx10<0x056>;
5970b57cec5SDimitry Andricdefm V_LOG_F16           : VOP1_Real_gfx10<0x057>;
5980b57cec5SDimitry Andricdefm V_EXP_F16           : VOP1_Real_gfx10<0x058>;
5990b57cec5SDimitry Andricdefm V_FREXP_MANT_F16    : VOP1_Real_gfx10<0x059>;
6000b57cec5SDimitry Andricdefm V_FREXP_EXP_I16_F16 : VOP1_Real_gfx10<0x05a>;
6010b57cec5SDimitry Andricdefm V_FLOOR_F16         : VOP1_Real_gfx10<0x05b>;
6020b57cec5SDimitry Andricdefm V_CEIL_F16          : VOP1_Real_gfx10<0x05c>;
6030b57cec5SDimitry Andricdefm V_TRUNC_F16         : VOP1_Real_gfx10<0x05d>;
6040b57cec5SDimitry Andricdefm V_RNDNE_F16         : VOP1_Real_gfx10<0x05e>;
6050b57cec5SDimitry Andricdefm V_FRACT_F16         : VOP1_Real_gfx10<0x05f>;
6060b57cec5SDimitry Andricdefm V_SIN_F16           : VOP1_Real_gfx10<0x060>;
6070b57cec5SDimitry Andricdefm V_COS_F16           : VOP1_Real_gfx10<0x061>;
6080b57cec5SDimitry Andricdefm V_SAT_PK_U8_I16     : VOP1_Real_gfx10<0x062>;
6090b57cec5SDimitry Andricdefm V_CVT_NORM_I16_F16  : VOP1_Real_gfx10<0x063>;
6100b57cec5SDimitry Andricdefm V_CVT_NORM_U16_F16  : VOP1_Real_gfx10<0x064>;
6110b57cec5SDimitry Andric
6120b57cec5SDimitry Andricdefm V_SWAP_B32    : VOP1Only_Real_gfx10<0x065>;
6130b57cec5SDimitry Andricdefm V_SWAPREL_B32 : VOP1Only_Real_gfx10<0x068>;
6140b57cec5SDimitry Andric
6150b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
6160b57cec5SDimitry Andric// GFX7, GFX10.
6170b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
6180b57cec5SDimitry Andric
6190b57cec5SDimitry Andriclet AssemblerPredicate = isGFX7Only, DecoderNamespace = "GFX7" in {
6200b57cec5SDimitry Andric  multiclass VOP1_Real_e32_gfx7<bits<9> op> {
6210b57cec5SDimitry Andric    def _e32_gfx7 :
6220b57cec5SDimitry Andric      VOP1_Real<!cast<VOP1_Pseudo>(NAME#"_e32"), SIEncodingFamily.SI>,
6230b57cec5SDimitry Andric      VOP1e<op{7-0}, !cast<VOP1_Pseudo>(NAME#"_e32").Pfl>;
6240b57cec5SDimitry Andric  }
6250b57cec5SDimitry Andric  multiclass VOP1_Real_e64_gfx7<bits<9> op> {
6260b57cec5SDimitry Andric    def _e64_gfx7 :
6270b57cec5SDimitry Andric      VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.SI>,
6280b57cec5SDimitry Andric      VOP3e_gfx6_gfx7<{1, 1, op{6-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
6290b57cec5SDimitry Andric  }
6300b57cec5SDimitry Andric} // End AssemblerPredicate = isGFX7Only, DecoderNamespace = "GFX7"
6310b57cec5SDimitry Andric
6320b57cec5SDimitry Andricmulticlass VOP1_Real_gfx7<bits<9> op> :
6330b57cec5SDimitry Andric  VOP1_Real_e32_gfx7<op>, VOP1_Real_e64_gfx7<op>;
6340b57cec5SDimitry Andric
6350b57cec5SDimitry Andricmulticlass VOP1_Real_gfx7_gfx10<bits<9> op> :
6360b57cec5SDimitry Andric  VOP1_Real_gfx7<op>, VOP1_Real_gfx10<op>;
6370b57cec5SDimitry Andric
6380b57cec5SDimitry Andricdefm V_LOG_LEGACY_F32 : VOP1_Real_gfx7<0x045>;
6390b57cec5SDimitry Andricdefm V_EXP_LEGACY_F32 : VOP1_Real_gfx7<0x046>;
6400b57cec5SDimitry Andric
6410b57cec5SDimitry Andricdefm V_TRUNC_F64 : VOP1_Real_gfx7_gfx10<0x017>;
6420b57cec5SDimitry Andricdefm V_CEIL_F64  : VOP1_Real_gfx7_gfx10<0x018>;
6430b57cec5SDimitry Andricdefm V_RNDNE_F64 : VOP1_Real_gfx7_gfx10<0x019>;
6440b57cec5SDimitry Andricdefm V_FLOOR_F64 : VOP1_Real_gfx7_gfx10<0x01a>;
6450b57cec5SDimitry Andric
6460b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
6470b57cec5SDimitry Andric// GFX6, GFX7, GFX10.
6480b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
6490b57cec5SDimitry Andric
6500b57cec5SDimitry Andriclet AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" in {
6510b57cec5SDimitry Andric  multiclass VOP1_Real_e32_gfx6_gfx7<bits<9> op> {
6520b57cec5SDimitry Andric    def _e32_gfx6_gfx7 :
6530b57cec5SDimitry Andric      VOP1_Real<!cast<VOP1_Pseudo>(NAME#"_e32"), SIEncodingFamily.SI>,
6540b57cec5SDimitry Andric      VOP1e<op{7-0}, !cast<VOP1_Pseudo>(NAME#"_e32").Pfl>;
6550b57cec5SDimitry Andric  }
6560b57cec5SDimitry Andric  multiclass VOP1_Real_e64_gfx6_gfx7<bits<9> op> {
6570b57cec5SDimitry Andric    def _e64_gfx6_gfx7 :
6580b57cec5SDimitry Andric      VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.SI>,
6590b57cec5SDimitry Andric      VOP3e_gfx6_gfx7<{1, 1, op{6-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
6600b57cec5SDimitry Andric  }
6610b57cec5SDimitry Andric} // End AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7"
6620b57cec5SDimitry Andric
6630b57cec5SDimitry Andricmulticlass VOP1_Real_gfx6_gfx7<bits<9> op> :
6640b57cec5SDimitry Andric  VOP1_Real_e32_gfx6_gfx7<op>, VOP1_Real_e64_gfx6_gfx7<op>;
6650b57cec5SDimitry Andric
6660b57cec5SDimitry Andricmulticlass VOP1_Real_gfx6_gfx7_gfx10<bits<9> op> :
6670b57cec5SDimitry Andric  VOP1_Real_gfx6_gfx7<op>, VOP1_Real_gfx10<op>;
6680b57cec5SDimitry Andric
6690b57cec5SDimitry Andricdefm V_LOG_CLAMP_F32  : VOP1_Real_gfx6_gfx7<0x026>;
6700b57cec5SDimitry Andricdefm V_RCP_CLAMP_F32  : VOP1_Real_gfx6_gfx7<0x028>;
6710b57cec5SDimitry Andricdefm V_RCP_LEGACY_F32 : VOP1_Real_gfx6_gfx7<0x029>;
6720b57cec5SDimitry Andricdefm V_RSQ_CLAMP_F32  : VOP1_Real_gfx6_gfx7<0x02c>;
6730b57cec5SDimitry Andricdefm V_RSQ_LEGACY_F32 : VOP1_Real_gfx6_gfx7<0x02d>;
6740b57cec5SDimitry Andricdefm V_RCP_CLAMP_F64  : VOP1_Real_gfx6_gfx7<0x030>;
6750b57cec5SDimitry Andricdefm V_RSQ_CLAMP_F64  : VOP1_Real_gfx6_gfx7<0x032>;
6760b57cec5SDimitry Andric
6770b57cec5SDimitry Andricdefm V_NOP               : VOP1_Real_gfx6_gfx7_gfx10<0x000>;
6780b57cec5SDimitry Andricdefm V_MOV_B32           : VOP1_Real_gfx6_gfx7_gfx10<0x001>;
6790b57cec5SDimitry Andricdefm V_CVT_I32_F64       : VOP1_Real_gfx6_gfx7_gfx10<0x003>;
6800b57cec5SDimitry Andricdefm V_CVT_F64_I32       : VOP1_Real_gfx6_gfx7_gfx10<0x004>;
6810b57cec5SDimitry Andricdefm V_CVT_F32_I32       : VOP1_Real_gfx6_gfx7_gfx10<0x005>;
6820b57cec5SDimitry Andricdefm V_CVT_F32_U32       : VOP1_Real_gfx6_gfx7_gfx10<0x006>;
6830b57cec5SDimitry Andricdefm V_CVT_U32_F32       : VOP1_Real_gfx6_gfx7_gfx10<0x007>;
6840b57cec5SDimitry Andricdefm V_CVT_I32_F32       : VOP1_Real_gfx6_gfx7_gfx10<0x008>;
6850b57cec5SDimitry Andricdefm V_CVT_F16_F32       : VOP1_Real_gfx6_gfx7_gfx10<0x00a>;
6860b57cec5SDimitry Andricdefm V_CVT_F32_F16       : VOP1_Real_gfx6_gfx7_gfx10<0x00b>;
6870b57cec5SDimitry Andricdefm V_CVT_RPI_I32_F32   : VOP1_Real_gfx6_gfx7_gfx10<0x00c>;
6880b57cec5SDimitry Andricdefm V_CVT_FLR_I32_F32   : VOP1_Real_gfx6_gfx7_gfx10<0x00d>;
6890b57cec5SDimitry Andricdefm V_CVT_OFF_F32_I4    : VOP1_Real_gfx6_gfx7_gfx10<0x00e>;
6900b57cec5SDimitry Andricdefm V_CVT_F32_F64       : VOP1_Real_gfx6_gfx7_gfx10<0x00f>;
6910b57cec5SDimitry Andricdefm V_CVT_F64_F32       : VOP1_Real_gfx6_gfx7_gfx10<0x010>;
6920b57cec5SDimitry Andricdefm V_CVT_F32_UBYTE0    : VOP1_Real_gfx6_gfx7_gfx10<0x011>;
6930b57cec5SDimitry Andricdefm V_CVT_F32_UBYTE1    : VOP1_Real_gfx6_gfx7_gfx10<0x012>;
6940b57cec5SDimitry Andricdefm V_CVT_F32_UBYTE2    : VOP1_Real_gfx6_gfx7_gfx10<0x013>;
6950b57cec5SDimitry Andricdefm V_CVT_F32_UBYTE3    : VOP1_Real_gfx6_gfx7_gfx10<0x014>;
6960b57cec5SDimitry Andricdefm V_CVT_U32_F64       : VOP1_Real_gfx6_gfx7_gfx10<0x015>;
6970b57cec5SDimitry Andricdefm V_CVT_F64_U32       : VOP1_Real_gfx6_gfx7_gfx10<0x016>;
6980b57cec5SDimitry Andricdefm V_FRACT_F32         : VOP1_Real_gfx6_gfx7_gfx10<0x020>;
6990b57cec5SDimitry Andricdefm V_TRUNC_F32         : VOP1_Real_gfx6_gfx7_gfx10<0x021>;
7000b57cec5SDimitry Andricdefm V_CEIL_F32          : VOP1_Real_gfx6_gfx7_gfx10<0x022>;
7010b57cec5SDimitry Andricdefm V_RNDNE_F32         : VOP1_Real_gfx6_gfx7_gfx10<0x023>;
7020b57cec5SDimitry Andricdefm V_FLOOR_F32         : VOP1_Real_gfx6_gfx7_gfx10<0x024>;
7030b57cec5SDimitry Andricdefm V_EXP_F32           : VOP1_Real_gfx6_gfx7_gfx10<0x025>;
7040b57cec5SDimitry Andricdefm V_LOG_F32           : VOP1_Real_gfx6_gfx7_gfx10<0x027>;
7050b57cec5SDimitry Andricdefm V_RCP_F32           : VOP1_Real_gfx6_gfx7_gfx10<0x02a>;
7060b57cec5SDimitry Andricdefm V_RCP_IFLAG_F32     : VOP1_Real_gfx6_gfx7_gfx10<0x02b>;
7070b57cec5SDimitry Andricdefm V_RSQ_F32           : VOP1_Real_gfx6_gfx7_gfx10<0x02e>;
7080b57cec5SDimitry Andricdefm V_RCP_F64           : VOP1_Real_gfx6_gfx7_gfx10<0x02f>;
7090b57cec5SDimitry Andricdefm V_RSQ_F64           : VOP1_Real_gfx6_gfx7_gfx10<0x031>;
7100b57cec5SDimitry Andricdefm V_SQRT_F32          : VOP1_Real_gfx6_gfx7_gfx10<0x033>;
7110b57cec5SDimitry Andricdefm V_SQRT_F64          : VOP1_Real_gfx6_gfx7_gfx10<0x034>;
7120b57cec5SDimitry Andricdefm V_SIN_F32           : VOP1_Real_gfx6_gfx7_gfx10<0x035>;
7130b57cec5SDimitry Andricdefm V_COS_F32           : VOP1_Real_gfx6_gfx7_gfx10<0x036>;
7140b57cec5SDimitry Andricdefm V_NOT_B32           : VOP1_Real_gfx6_gfx7_gfx10<0x037>;
7150b57cec5SDimitry Andricdefm V_BFREV_B32         : VOP1_Real_gfx6_gfx7_gfx10<0x038>;
7160b57cec5SDimitry Andricdefm V_FFBH_U32          : VOP1_Real_gfx6_gfx7_gfx10<0x039>;
7170b57cec5SDimitry Andricdefm V_FFBL_B32          : VOP1_Real_gfx6_gfx7_gfx10<0x03a>;
7180b57cec5SDimitry Andricdefm V_FFBH_I32          : VOP1_Real_gfx6_gfx7_gfx10<0x03b>;
7190b57cec5SDimitry Andricdefm V_FREXP_EXP_I32_F64 : VOP1_Real_gfx6_gfx7_gfx10<0x03c>;
7200b57cec5SDimitry Andricdefm V_FREXP_MANT_F64    : VOP1_Real_gfx6_gfx7_gfx10<0x03d>;
7210b57cec5SDimitry Andricdefm V_FRACT_F64         : VOP1_Real_gfx6_gfx7_gfx10<0x03e>;
7220b57cec5SDimitry Andricdefm V_FREXP_EXP_I32_F32 : VOP1_Real_gfx6_gfx7_gfx10<0x03f>;
7230b57cec5SDimitry Andricdefm V_FREXP_MANT_F32    : VOP1_Real_gfx6_gfx7_gfx10<0x040>;
7240b57cec5SDimitry Andricdefm V_CLREXCP           : VOP1_Real_gfx6_gfx7_gfx10<0x041>;
725480093f4SDimitry Andricdefm V_MOVRELD_B32       : VOP1_Real_gfx6_gfx7_gfx10<0x042>;
726480093f4SDimitry Andricdefm V_MOVRELS_B32       : VOP1_Real_gfx6_gfx7_gfx10<0x043>;
727480093f4SDimitry Andricdefm V_MOVRELSD_B32      : VOP1_Real_gfx6_gfx7_gfx10<0x044>;
7280b57cec5SDimitry Andric
7290b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
7300b57cec5SDimitry Andric// GFX8, GFX9 (VI).
7310b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
7320b57cec5SDimitry Andric
7330b57cec5SDimitry Andricclass VOP1_DPPe <bits<8> op, VOP1_DPP_Pseudo ps, VOPProfile P = ps.Pfl> :
7340b57cec5SDimitry Andric  VOP_DPPe <P> {
7350b57cec5SDimitry Andric  bits<8> vdst;
7360b57cec5SDimitry Andric  let Inst{8-0}   = 0xfa; // dpp
7370b57cec5SDimitry Andric  let Inst{16-9}  = op;
7380b57cec5SDimitry Andric  let Inst{24-17} = !if(P.EmitDst, vdst{7-0}, 0);
7390b57cec5SDimitry Andric  let Inst{31-25} = 0x3f; //encoding
7400b57cec5SDimitry Andric}
7410b57cec5SDimitry Andric
7420b57cec5SDimitry Andricmulticlass VOP1Only_Real_vi <bits<10> op> {
743480093f4SDimitry Andric  let AssemblerPredicate = isGFX8GFX9, DecoderNamespace = "GFX8" in {
7440b57cec5SDimitry Andric    def _vi :
7450b57cec5SDimitry Andric      VOP1_Real<!cast<VOP1_Pseudo>(NAME), SIEncodingFamily.VI>,
7460b57cec5SDimitry Andric      VOP1e<op{7-0}, !cast<VOP1_Pseudo>(NAME).Pfl>;
7470b57cec5SDimitry Andric  }
7480b57cec5SDimitry Andric}
7490b57cec5SDimitry Andric
7500b57cec5SDimitry Andricmulticlass VOP1_Real_e32e64_vi <bits<10> op> {
751480093f4SDimitry Andric  let AssemblerPredicate = isGFX8GFX9, DecoderNamespace = "GFX8" in {
7520b57cec5SDimitry Andric    def _e32_vi :
7530b57cec5SDimitry Andric      VOP1_Real<!cast<VOP1_Pseudo>(NAME#"_e32"), SIEncodingFamily.VI>,
7540b57cec5SDimitry Andric      VOP1e<op{7-0}, !cast<VOP1_Pseudo>(NAME#"_e32").Pfl>;
7550b57cec5SDimitry Andric    def _e64_vi :
7560b57cec5SDimitry Andric      VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.VI>,
7570b57cec5SDimitry Andric      VOP3e_vi <!add(0x140, op), !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
7580b57cec5SDimitry Andric  }
7590b57cec5SDimitry Andric}
7600b57cec5SDimitry Andric
7610b57cec5SDimitry Andricmulticlass VOP1_Real_vi <bits<10> op> {
7620b57cec5SDimitry Andric  defm NAME : VOP1_Real_e32e64_vi <op>;
7630b57cec5SDimitry Andric
7648bcb0991SDimitry Andric  foreach _ = BoolToList<!cast<VOP1_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA>.ret in
7650b57cec5SDimitry Andric  def _sdwa_vi :
7660b57cec5SDimitry Andric    VOP_SDWA_Real <!cast<VOP1_SDWA_Pseudo>(NAME#"_sdwa")>,
7670b57cec5SDimitry Andric    VOP1_SDWAe <op{7-0}, !cast<VOP1_SDWA_Pseudo>(NAME#"_sdwa").Pfl>;
7680b57cec5SDimitry Andric
7698bcb0991SDimitry Andric  foreach _ = BoolToList<!cast<VOP1_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA9>.ret in
7700b57cec5SDimitry Andric  def _sdwa_gfx9 :
7710b57cec5SDimitry Andric    VOP_SDWA9_Real <!cast<VOP1_SDWA_Pseudo>(NAME#"_sdwa")>,
7720b57cec5SDimitry Andric    VOP1_SDWA9Ae <op{7-0}, !cast<VOP1_SDWA_Pseudo>(NAME#"_sdwa").Pfl>;
7730b57cec5SDimitry Andric
7740b57cec5SDimitry Andric  foreach _ = BoolToList<!cast<VOP1_Pseudo>(NAME#"_e32").Pfl.HasExtDPP>.ret in
7750b57cec5SDimitry Andric    def _dpp_vi :
7760b57cec5SDimitry Andric      VOP_DPP_Real<!cast<VOP1_DPP_Pseudo>(NAME#"_dpp"), SIEncodingFamily.VI>,
7770b57cec5SDimitry Andric      VOP1_DPPe<op{7-0}, !cast<VOP1_DPP_Pseudo>(NAME#"_dpp")>;
7780b57cec5SDimitry Andric}
7790b57cec5SDimitry Andric
7800b57cec5SDimitry Andricdefm V_NOP               : VOP1_Real_vi <0x0>;
7810b57cec5SDimitry Andricdefm V_MOV_B32           : VOP1_Real_vi <0x1>;
7820b57cec5SDimitry Andricdefm V_CVT_I32_F64       : VOP1_Real_vi <0x3>;
7830b57cec5SDimitry Andricdefm V_CVT_F64_I32       : VOP1_Real_vi <0x4>;
7840b57cec5SDimitry Andricdefm V_CVT_F32_I32       : VOP1_Real_vi <0x5>;
7850b57cec5SDimitry Andricdefm V_CVT_F32_U32       : VOP1_Real_vi <0x6>;
7860b57cec5SDimitry Andricdefm V_CVT_U32_F32       : VOP1_Real_vi <0x7>;
7870b57cec5SDimitry Andricdefm V_CVT_I32_F32       : VOP1_Real_vi <0x8>;
7880b57cec5SDimitry Andricdefm V_CVT_F16_F32       : VOP1_Real_vi <0xa>;
7890b57cec5SDimitry Andricdefm V_CVT_F32_F16       : VOP1_Real_vi <0xb>;
7900b57cec5SDimitry Andricdefm V_CVT_RPI_I32_F32   : VOP1_Real_vi <0xc>;
7910b57cec5SDimitry Andricdefm V_CVT_FLR_I32_F32   : VOP1_Real_vi <0xd>;
7920b57cec5SDimitry Andricdefm V_CVT_OFF_F32_I4    : VOP1_Real_vi <0xe>;
7930b57cec5SDimitry Andricdefm V_CVT_F32_F64       : VOP1_Real_vi <0xf>;
7940b57cec5SDimitry Andricdefm V_CVT_F64_F32       : VOP1_Real_vi <0x10>;
7950b57cec5SDimitry Andricdefm V_CVT_F32_UBYTE0    : VOP1_Real_vi <0x11>;
7960b57cec5SDimitry Andricdefm V_CVT_F32_UBYTE1    : VOP1_Real_vi <0x12>;
7970b57cec5SDimitry Andricdefm V_CVT_F32_UBYTE2    : VOP1_Real_vi <0x13>;
7980b57cec5SDimitry Andricdefm V_CVT_F32_UBYTE3    : VOP1_Real_vi <0x14>;
7990b57cec5SDimitry Andricdefm V_CVT_U32_F64       : VOP1_Real_vi <0x15>;
8000b57cec5SDimitry Andricdefm V_CVT_F64_U32       : VOP1_Real_vi <0x16>;
8010b57cec5SDimitry Andricdefm V_FRACT_F32         : VOP1_Real_vi <0x1b>;
8020b57cec5SDimitry Andricdefm V_TRUNC_F32         : VOP1_Real_vi <0x1c>;
8030b57cec5SDimitry Andricdefm V_CEIL_F32          : VOP1_Real_vi <0x1d>;
8040b57cec5SDimitry Andricdefm V_RNDNE_F32         : VOP1_Real_vi <0x1e>;
8050b57cec5SDimitry Andricdefm V_FLOOR_F32         : VOP1_Real_vi <0x1f>;
8060b57cec5SDimitry Andricdefm V_EXP_F32           : VOP1_Real_vi <0x20>;
8070b57cec5SDimitry Andricdefm V_LOG_F32           : VOP1_Real_vi <0x21>;
8080b57cec5SDimitry Andricdefm V_RCP_F32           : VOP1_Real_vi <0x22>;
8090b57cec5SDimitry Andricdefm V_RCP_IFLAG_F32     : VOP1_Real_vi <0x23>;
8100b57cec5SDimitry Andricdefm V_RSQ_F32           : VOP1_Real_vi <0x24>;
8110b57cec5SDimitry Andricdefm V_RCP_F64           : VOP1_Real_vi <0x25>;
8120b57cec5SDimitry Andricdefm V_RSQ_F64           : VOP1_Real_vi <0x26>;
8130b57cec5SDimitry Andricdefm V_SQRT_F32          : VOP1_Real_vi <0x27>;
8140b57cec5SDimitry Andricdefm V_SQRT_F64          : VOP1_Real_vi <0x28>;
8150b57cec5SDimitry Andricdefm V_SIN_F32           : VOP1_Real_vi <0x29>;
8160b57cec5SDimitry Andricdefm V_COS_F32           : VOP1_Real_vi <0x2a>;
8170b57cec5SDimitry Andricdefm V_NOT_B32           : VOP1_Real_vi <0x2b>;
8180b57cec5SDimitry Andricdefm V_BFREV_B32         : VOP1_Real_vi <0x2c>;
8190b57cec5SDimitry Andricdefm V_FFBH_U32          : VOP1_Real_vi <0x2d>;
8200b57cec5SDimitry Andricdefm V_FFBL_B32          : VOP1_Real_vi <0x2e>;
8210b57cec5SDimitry Andricdefm V_FFBH_I32          : VOP1_Real_vi <0x2f>;
8220b57cec5SDimitry Andricdefm V_FREXP_EXP_I32_F64 : VOP1_Real_vi <0x30>;
8230b57cec5SDimitry Andricdefm V_FREXP_MANT_F64    : VOP1_Real_vi <0x31>;
8240b57cec5SDimitry Andricdefm V_FRACT_F64         : VOP1_Real_vi <0x32>;
8250b57cec5SDimitry Andricdefm V_FREXP_EXP_I32_F32 : VOP1_Real_vi <0x33>;
8260b57cec5SDimitry Andricdefm V_FREXP_MANT_F32    : VOP1_Real_vi <0x34>;
8270b57cec5SDimitry Andricdefm V_CLREXCP           : VOP1_Real_vi <0x35>;
8280b57cec5SDimitry Andricdefm V_MOVRELD_B32       : VOP1_Real_e32e64_vi <0x36>;
8290b57cec5SDimitry Andricdefm V_MOVRELS_B32       : VOP1_Real_e32e64_vi <0x37>;
8300b57cec5SDimitry Andricdefm V_MOVRELSD_B32      : VOP1_Real_e32e64_vi <0x38>;
8310b57cec5SDimitry Andricdefm V_TRUNC_F64         : VOP1_Real_vi <0x17>;
8320b57cec5SDimitry Andricdefm V_CEIL_F64          : VOP1_Real_vi <0x18>;
8330b57cec5SDimitry Andricdefm V_FLOOR_F64         : VOP1_Real_vi <0x1A>;
8340b57cec5SDimitry Andricdefm V_RNDNE_F64         : VOP1_Real_vi <0x19>;
8350b57cec5SDimitry Andricdefm V_LOG_LEGACY_F32    : VOP1_Real_vi <0x4c>;
8360b57cec5SDimitry Andricdefm V_EXP_LEGACY_F32    : VOP1_Real_vi <0x4b>;
8370b57cec5SDimitry Andricdefm V_CVT_F16_U16       : VOP1_Real_vi <0x39>;
8380b57cec5SDimitry Andricdefm V_CVT_F16_I16       : VOP1_Real_vi <0x3a>;
8390b57cec5SDimitry Andricdefm V_CVT_U16_F16       : VOP1_Real_vi <0x3b>;
8400b57cec5SDimitry Andricdefm V_CVT_I16_F16       : VOP1_Real_vi <0x3c>;
8410b57cec5SDimitry Andricdefm V_RCP_F16           : VOP1_Real_vi <0x3d>;
8420b57cec5SDimitry Andricdefm V_SQRT_F16          : VOP1_Real_vi <0x3e>;
8430b57cec5SDimitry Andricdefm V_RSQ_F16           : VOP1_Real_vi <0x3f>;
8440b57cec5SDimitry Andricdefm V_LOG_F16           : VOP1_Real_vi <0x40>;
8450b57cec5SDimitry Andricdefm V_EXP_F16           : VOP1_Real_vi <0x41>;
8460b57cec5SDimitry Andricdefm V_FREXP_MANT_F16    : VOP1_Real_vi <0x42>;
8470b57cec5SDimitry Andricdefm V_FREXP_EXP_I16_F16 : VOP1_Real_vi <0x43>;
8480b57cec5SDimitry Andricdefm V_FLOOR_F16         : VOP1_Real_vi <0x44>;
8490b57cec5SDimitry Andricdefm V_CEIL_F16          : VOP1_Real_vi <0x45>;
8500b57cec5SDimitry Andricdefm V_TRUNC_F16         : VOP1_Real_vi <0x46>;
8510b57cec5SDimitry Andricdefm V_RNDNE_F16         : VOP1_Real_vi <0x47>;
8520b57cec5SDimitry Andricdefm V_FRACT_F16         : VOP1_Real_vi <0x48>;
8530b57cec5SDimitry Andricdefm V_SIN_F16           : VOP1_Real_vi <0x49>;
8540b57cec5SDimitry Andricdefm V_COS_F16           : VOP1_Real_vi <0x4a>;
8550b57cec5SDimitry Andricdefm V_SWAP_B32          : VOP1Only_Real_vi <0x51>;
8560b57cec5SDimitry Andric
8570b57cec5SDimitry Andricdefm V_SAT_PK_U8_I16     : VOP1_Real_vi<0x4f>;
8580b57cec5SDimitry Andricdefm V_CVT_NORM_I16_F16  : VOP1_Real_vi<0x4d>;
8590b57cec5SDimitry Andricdefm V_CVT_NORM_U16_F16  : VOP1_Real_vi<0x4e>;
8600b57cec5SDimitry Andric
861fe6060f1SDimitry Andricdefm V_ACCVGPR_MOV_B32   : VOP1Only_Real_vi<0x52>;
862fe6060f1SDimitry Andric
863*349cc55cSDimitry Andriclet VOP1 = 1, SubtargetPredicate = isGFX8GFX9, Uses = [EXEC, M0] in {
864*349cc55cSDimitry Andric
8650b57cec5SDimitry Andric// Copy of v_mov_b32 with $vdst as a use operand for use with VGPR
8660b57cec5SDimitry Andric// indexing mode. vdst can't be treated as a def for codegen purposes,
8670b57cec5SDimitry Andric// and an implicit use and def of the super register should be added.
868*349cc55cSDimitry Andricdef V_MOV_B32_indirect_write : VPseudoInstSI<(outs),
8690b57cec5SDimitry Andric  (ins getVALUDstForVT<i32>.ret:$vdst, getVOPSrc0ForVT<i32>.ret:$src0)>,
8700b57cec5SDimitry Andric  PseudoInstExpansion<(V_MOV_B32_e32_vi getVALUDstForVT<i32>.ret:$vdst,
871*349cc55cSDimitry Andric                                        getVOPSrc0ForVT<i32>.ret:$src0)>;
872*349cc55cSDimitry Andric
873*349cc55cSDimitry Andric// Copy of v_mov_b32 for use with VGPR indexing mode. An implicit use of the
874*349cc55cSDimitry Andric// super register should be added.
875*349cc55cSDimitry Andricdef V_MOV_B32_indirect_read : VPseudoInstSI<
876*349cc55cSDimitry Andric  (outs getVALUDstForVT<i32>.ret:$vdst),
877*349cc55cSDimitry Andric  (ins getVOPSrc0ForVT<i32>.ret:$src0)>,
878*349cc55cSDimitry Andric  PseudoInstExpansion<(V_MOV_B32_e32_vi getVALUDstForVT<i32>.ret:$vdst,
879*349cc55cSDimitry Andric                                        getVOPSrc0ForVT<i32>.ret:$src0)>;
880*349cc55cSDimitry Andric
881*349cc55cSDimitry Andric} // End VOP1 = 1, SubtargetPredicate = isGFX8GFX9, Uses = [M0]
8820b57cec5SDimitry Andric
8838bcb0991SDimitry Andriclet OtherPredicates = [isGFX8Plus] in {
8840b57cec5SDimitry Andric
8850b57cec5SDimitry Andricdef : GCNPat <
8865ffd83dbSDimitry Andric  (i32 (int_amdgcn_mov_dpp i32:$src, timm:$dpp_ctrl, timm:$row_mask,
8875ffd83dbSDimitry Andric                           timm:$bank_mask, timm:$bound_ctrl)),
8885ffd83dbSDimitry Andric  (V_MOV_B32_dpp VGPR_32:$src, VGPR_32:$src, (as_i32timm $dpp_ctrl),
8895ffd83dbSDimitry Andric                       (as_i32timm $row_mask), (as_i32timm $bank_mask),
8905ffd83dbSDimitry Andric                       (as_i1timm $bound_ctrl))
8910b57cec5SDimitry Andric>;
8920b57cec5SDimitry Andric
8930b57cec5SDimitry Andricdef : GCNPat <
8945ffd83dbSDimitry Andric  (i32 (int_amdgcn_update_dpp i32:$old, i32:$src, timm:$dpp_ctrl,
8955ffd83dbSDimitry Andric                              timm:$row_mask, timm:$bank_mask,
8965ffd83dbSDimitry Andric                              timm:$bound_ctrl)),
8975ffd83dbSDimitry Andric  (V_MOV_B32_dpp VGPR_32:$old, VGPR_32:$src, (as_i32timm $dpp_ctrl),
8985ffd83dbSDimitry Andric                 (as_i32timm $row_mask), (as_i32timm $bank_mask),
8995ffd83dbSDimitry Andric                 (as_i1timm $bound_ctrl))
9000b57cec5SDimitry Andric>;
9010b57cec5SDimitry Andric
9028bcb0991SDimitry Andric} // End OtherPredicates = [isGFX8Plus]
9030b57cec5SDimitry Andric
9040b57cec5SDimitry Andriclet OtherPredicates = [isGFX8Plus] in {
9050b57cec5SDimitry Andricdef : GCNPat<
9060b57cec5SDimitry Andric  (i32 (anyext i16:$src)),
9070b57cec5SDimitry Andric  (COPY $src)
9080b57cec5SDimitry Andric>;
9090b57cec5SDimitry Andric
9100b57cec5SDimitry Andricdef : GCNPat<
9110b57cec5SDimitry Andric   (i64 (anyext i16:$src)),
9120b57cec5SDimitry Andric   (REG_SEQUENCE VReg_64,
9130b57cec5SDimitry Andric     (i32 (COPY $src)), sub0,
9140b57cec5SDimitry Andric     (V_MOV_B32_e32 (i32 0)), sub1)
9150b57cec5SDimitry Andric>;
9160b57cec5SDimitry Andric
9170b57cec5SDimitry Andricdef : GCNPat<
9180b57cec5SDimitry Andric  (i16 (trunc i32:$src)),
9190b57cec5SDimitry Andric  (COPY $src)
9200b57cec5SDimitry Andric>;
9210b57cec5SDimitry Andric
9220b57cec5SDimitry Andricdef : GCNPat <
9230b57cec5SDimitry Andric  (i16 (trunc i64:$src)),
9240b57cec5SDimitry Andric  (EXTRACT_SUBREG $src, sub0)
9250b57cec5SDimitry Andric>;
9260b57cec5SDimitry Andric
9270b57cec5SDimitry Andric} // End OtherPredicates = [isGFX8Plus]
9280b57cec5SDimitry Andric
9290b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
9300b57cec5SDimitry Andric// GFX9
9310b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
9320b57cec5SDimitry Andric
9330b57cec5SDimitry Andricmulticlass VOP1_Real_gfx9 <bits<10> op> {
934480093f4SDimitry Andric  let AssemblerPredicate = isGFX9Only, DecoderNamespace = "GFX9" in {
9350b57cec5SDimitry Andric    defm NAME : VOP1_Real_e32e64_vi <op>;
9360b57cec5SDimitry Andric  }
9370b57cec5SDimitry Andric
9388bcb0991SDimitry Andric  foreach _ = BoolToList<!cast<VOP1_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA9>.ret in
9390b57cec5SDimitry Andric  def _sdwa_gfx9 :
9400b57cec5SDimitry Andric    VOP_SDWA9_Real <!cast<VOP1_SDWA_Pseudo>(NAME#"_sdwa")>,
9410b57cec5SDimitry Andric    VOP1_SDWA9Ae <op{7-0}, !cast<VOP1_SDWA_Pseudo>(NAME#"_sdwa").Pfl>;
9420b57cec5SDimitry Andric
9430b57cec5SDimitry Andric  foreach _ = BoolToList<!cast<VOP1_Pseudo>(NAME#"_e32").Pfl.HasExtDPP>.ret in
9440b57cec5SDimitry Andric    def _dpp_gfx9 :
9450b57cec5SDimitry Andric      VOP_DPP_Real<!cast<VOP1_DPP_Pseudo>(NAME#"_dpp"), SIEncodingFamily.GFX9>,
9460b57cec5SDimitry Andric      VOP1_DPPe<op{7-0}, !cast<VOP1_DPP_Pseudo>(NAME#"_dpp")>;
9470b57cec5SDimitry Andric
9480b57cec5SDimitry Andric}
9490b57cec5SDimitry Andric
9500b57cec5SDimitry Andricdefm V_SCREEN_PARTITION_4SE_B32 : VOP1_Real_gfx9 <0x37>;
9510b57cec5SDimitry Andric
9520b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
9530b57cec5SDimitry Andric// GFX10
9540b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
9550b57cec5SDimitry Andric
9560b57cec5SDimitry Andriclet OtherPredicates = [isGFX10Plus] in {
9570b57cec5SDimitry Andricdef : GCNPat <
9588bcb0991SDimitry Andric  (i32 (int_amdgcn_mov_dpp8 i32:$src, timm:$dpp8)),
9595ffd83dbSDimitry Andric  (V_MOV_B32_dpp8_gfx10 VGPR_32:$src, VGPR_32:$src,
9605ffd83dbSDimitry Andric                        (as_i32timm $dpp8), (i32 DPP8Mode.FI_0))
9610b57cec5SDimitry Andric>;
9620b57cec5SDimitry Andric} // End OtherPredicates = [isGFX10Plus]
963