xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/VOP2Instructions.td (revision 5ffd83dbcc34f10e07f6d3e968ae6365869615f4)
1*5ffd83dbSDimitry Andric//===-- VOP2Instructions.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// VOP2 Classes
110b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric
130b57cec5SDimitry Andricclass VOP2e <bits<6> op, VOPProfile P> : Enc32 {
140b57cec5SDimitry Andric  bits<8> vdst;
150b57cec5SDimitry Andric  bits<9> src0;
160b57cec5SDimitry Andric  bits<8> src1;
170b57cec5SDimitry Andric
180b57cec5SDimitry Andric  let Inst{8-0}   = !if(P.HasSrc0, src0, 0);
190b57cec5SDimitry Andric  let Inst{16-9}  = !if(P.HasSrc1, src1, 0);
200b57cec5SDimitry Andric  let Inst{24-17} = !if(P.EmitDst, vdst, 0);
210b57cec5SDimitry Andric  let Inst{30-25} = op;
220b57cec5SDimitry Andric  let Inst{31}    = 0x0; //encoding
230b57cec5SDimitry Andric}
240b57cec5SDimitry Andric
250b57cec5SDimitry Andricclass VOP2_MADKe <bits<6> op, VOPProfile P> : Enc64 {
260b57cec5SDimitry Andric  bits<8>  vdst;
270b57cec5SDimitry Andric  bits<9>  src0;
280b57cec5SDimitry Andric  bits<8>  src1;
290b57cec5SDimitry Andric  bits<32> imm;
300b57cec5SDimitry Andric
310b57cec5SDimitry Andric  let Inst{8-0}   = !if(P.HasSrc0, src0, 0);
320b57cec5SDimitry Andric  let Inst{16-9}  = !if(P.HasSrc1, src1, 0);
330b57cec5SDimitry Andric  let Inst{24-17} = !if(P.EmitDst, vdst, 0);
340b57cec5SDimitry Andric  let Inst{30-25} = op;
350b57cec5SDimitry Andric  let Inst{31}    = 0x0; // encoding
360b57cec5SDimitry Andric  let Inst{63-32} = imm;
370b57cec5SDimitry Andric}
380b57cec5SDimitry Andric
390b57cec5SDimitry Andricclass VOP2_SDWAe <bits<6> op, VOPProfile P> : VOP_SDWAe <P> {
400b57cec5SDimitry Andric  bits<8> vdst;
410b57cec5SDimitry Andric  bits<8> src1;
420b57cec5SDimitry Andric
430b57cec5SDimitry Andric  let Inst{8-0}   = 0xf9; // sdwa
440b57cec5SDimitry Andric  let Inst{16-9}  = !if(P.HasSrc1, src1{7-0}, 0);
450b57cec5SDimitry Andric  let Inst{24-17} = !if(P.EmitDst, vdst{7-0}, 0);
460b57cec5SDimitry Andric  let Inst{30-25} = op;
470b57cec5SDimitry Andric  let Inst{31}    = 0x0; // encoding
480b57cec5SDimitry Andric}
490b57cec5SDimitry Andric
500b57cec5SDimitry Andricclass VOP2_SDWA9Ae <bits<6> op, VOPProfile P> : VOP_SDWA9Ae <P> {
510b57cec5SDimitry Andric  bits<8> vdst;
520b57cec5SDimitry Andric  bits<9> src1;
530b57cec5SDimitry Andric
540b57cec5SDimitry Andric  let Inst{8-0}   = 0xf9; // sdwa
550b57cec5SDimitry Andric  let Inst{16-9}  = !if(P.HasSrc1, src1{7-0}, 0);
560b57cec5SDimitry Andric  let Inst{24-17} = !if(P.EmitDst, vdst{7-0}, 0);
570b57cec5SDimitry Andric  let Inst{30-25} = op;
580b57cec5SDimitry Andric  let Inst{31}    = 0x0; // encoding
590b57cec5SDimitry Andric  let Inst{63}    = !if(P.HasSrc1, src1{8}, 0); // src1_sgpr
600b57cec5SDimitry Andric}
610b57cec5SDimitry Andric
620b57cec5SDimitry Andricclass VOP2_Pseudo <string opName, VOPProfile P, list<dag> pattern=[], string suffix = "_e32"> :
630b57cec5SDimitry Andric  VOP_Pseudo <opName, suffix, P, P.Outs32, P.Ins32, "", pattern> {
640b57cec5SDimitry Andric
650b57cec5SDimitry Andric  let AsmOperands = P.Asm32;
660b57cec5SDimitry Andric
670b57cec5SDimitry Andric  let Size = 4;
680b57cec5SDimitry Andric  let mayLoad = 0;
690b57cec5SDimitry Andric  let mayStore = 0;
700b57cec5SDimitry Andric  let hasSideEffects = 0;
710b57cec5SDimitry Andric
72*5ffd83dbSDimitry Andric  let ReadsModeReg = !or(isFloatType<P.DstVT>.ret, isFloatType<P.Src0VT>.ret);
73*5ffd83dbSDimitry Andric
74*5ffd83dbSDimitry Andric  let mayRaiseFPException = ReadsModeReg;
75*5ffd83dbSDimitry Andric
760b57cec5SDimitry Andric  let VOP2 = 1;
770b57cec5SDimitry Andric  let VALU = 1;
78*5ffd83dbSDimitry Andric  let Uses = !if(ReadsModeReg, [MODE, EXEC], [EXEC]);
790b57cec5SDimitry Andric
800b57cec5SDimitry Andric  let AsmVariantName = AMDGPUAsmVariants.Default;
810b57cec5SDimitry Andric}
820b57cec5SDimitry Andric
830b57cec5SDimitry Andricclass VOP2_Real <VOP2_Pseudo ps, int EncodingFamily> :
840b57cec5SDimitry Andric  InstSI <ps.OutOperandList, ps.InOperandList, ps.Mnemonic # ps.AsmOperands, []>,
850b57cec5SDimitry Andric  SIMCInstr <ps.PseudoInstr, EncodingFamily> {
860b57cec5SDimitry Andric
870b57cec5SDimitry Andric  let isPseudo = 0;
880b57cec5SDimitry Andric  let isCodeGenOnly = 0;
890b57cec5SDimitry Andric
900b57cec5SDimitry Andric  let Constraints     = ps.Constraints;
910b57cec5SDimitry Andric  let DisableEncoding = ps.DisableEncoding;
920b57cec5SDimitry Andric
930b57cec5SDimitry Andric  // copy relevant pseudo op flags
940b57cec5SDimitry Andric  let SubtargetPredicate = ps.SubtargetPredicate;
950b57cec5SDimitry Andric  let AsmMatchConverter  = ps.AsmMatchConverter;
960b57cec5SDimitry Andric  let AsmVariantName     = ps.AsmVariantName;
970b57cec5SDimitry Andric  let Constraints        = ps.Constraints;
980b57cec5SDimitry Andric  let DisableEncoding    = ps.DisableEncoding;
990b57cec5SDimitry Andric  let TSFlags            = ps.TSFlags;
1000b57cec5SDimitry Andric  let UseNamedOperandTable = ps.UseNamedOperandTable;
1010b57cec5SDimitry Andric  let Uses                 = ps.Uses;
1020b57cec5SDimitry Andric  let Defs                 = ps.Defs;
1030b57cec5SDimitry Andric}
1040b57cec5SDimitry Andric
1050b57cec5SDimitry Andricclass VOP2_SDWA_Pseudo <string OpName, VOPProfile P, list<dag> pattern=[]> :
1060b57cec5SDimitry Andric  VOP_SDWA_Pseudo <OpName, P, pattern> {
1070b57cec5SDimitry Andric  let AsmMatchConverter = "cvtSdwaVOP2";
1080b57cec5SDimitry Andric}
1090b57cec5SDimitry Andric
1100b57cec5SDimitry Andricclass VOP2_DPP_Pseudo <string OpName, VOPProfile P, list<dag> pattern=[]> :
1110b57cec5SDimitry Andric  VOP_DPP_Pseudo <OpName, P, pattern> {
1120b57cec5SDimitry Andric}
1130b57cec5SDimitry Andric
1140b57cec5SDimitry Andric
1150b57cec5SDimitry Andricclass getVOP2Pat64 <SDPatternOperator node, VOPProfile P> : LetDummies {
1160b57cec5SDimitry Andric  list<dag> ret = !if(P.HasModifiers,
1170b57cec5SDimitry Andric    [(set P.DstVT:$vdst,
1180b57cec5SDimitry Andric      (node (P.Src0VT
1190b57cec5SDimitry Andric              !if(P.HasOMod,
1200b57cec5SDimitry Andric                  (VOP3Mods0 P.Src0VT:$src0, i32:$src0_modifiers, i1:$clamp, i32:$omod),
1210b57cec5SDimitry Andric                  (VOP3Mods0 P.Src0VT:$src0, i32:$src0_modifiers, i1:$clamp))),
1220b57cec5SDimitry Andric            (P.Src1VT (VOP3Mods P.Src1VT:$src1, i32:$src1_modifiers))))],
1230b57cec5SDimitry Andric    [(set P.DstVT:$vdst, (node P.Src0VT:$src0, P.Src1VT:$src1))]);
1240b57cec5SDimitry Andric}
1250b57cec5SDimitry Andric
1260b57cec5SDimitry Andricmulticlass VOP2Inst_e32<string opName,
1270b57cec5SDimitry Andric                        VOPProfile P,
1280b57cec5SDimitry Andric                        SDPatternOperator node = null_frag,
1290b57cec5SDimitry Andric                        string revOp = opName,
1300b57cec5SDimitry Andric                        bit GFX9Renamed = 0> {
1310b57cec5SDimitry Andric  let renamedInGFX9 = GFX9Renamed in {
1320b57cec5SDimitry Andric    def _e32 : VOP2_Pseudo <opName, P, VOPPatOrNull<node,P>.ret>,
1330b57cec5SDimitry Andric               Commutable_REV<revOp#"_e32", !eq(revOp, opName)>;
1340b57cec5SDimitry Andric  } // End renamedInGFX9 = GFX9Renamed
1350b57cec5SDimitry Andric}
1360b57cec5SDimitry Andric
1370b57cec5SDimitry Andricmulticlass VOP2Inst_e64<string opName,
1380b57cec5SDimitry Andric                        VOPProfile P,
1390b57cec5SDimitry Andric                        SDPatternOperator node = null_frag,
1400b57cec5SDimitry Andric                        string revOp = opName,
1410b57cec5SDimitry Andric                        bit GFX9Renamed = 0> {
1420b57cec5SDimitry Andric  let renamedInGFX9 = GFX9Renamed in {
1430b57cec5SDimitry Andric    def _e64 : VOP3_Pseudo <opName, P, getVOP2Pat64<node, P>.ret>,
1440b57cec5SDimitry Andric               Commutable_REV<revOp#"_e64", !eq(revOp, opName)>;
1450b57cec5SDimitry Andric  } // End renamedInGFX9 = GFX9Renamed
1460b57cec5SDimitry Andric}
1470b57cec5SDimitry Andric
1480b57cec5SDimitry Andricmulticlass VOP2Inst_sdwa<string opName,
1490b57cec5SDimitry Andric                         VOPProfile P,
1500b57cec5SDimitry Andric                         SDPatternOperator node = null_frag,
1510b57cec5SDimitry Andric                         string revOp = opName,
1520b57cec5SDimitry Andric                         bit GFX9Renamed = 0> {
1530b57cec5SDimitry Andric  let renamedInGFX9 = GFX9Renamed in {
1548bcb0991SDimitry Andric    foreach _ = BoolToList<P.HasExtSDWA>.ret in
1550b57cec5SDimitry Andric      def _sdwa : VOP2_SDWA_Pseudo <opName, P>;
1560b57cec5SDimitry Andric  } // End renamedInGFX9 = GFX9Renamed
1570b57cec5SDimitry Andric}
1580b57cec5SDimitry Andric
1590b57cec5SDimitry Andricmulticlass VOP2Inst<string opName,
1600b57cec5SDimitry Andric                    VOPProfile P,
1610b57cec5SDimitry Andric                    SDPatternOperator node = null_frag,
1620b57cec5SDimitry Andric                    string revOp = opName,
1630b57cec5SDimitry Andric                    bit GFX9Renamed = 0> :
1640b57cec5SDimitry Andric    VOP2Inst_e32<opName, P, node, revOp, GFX9Renamed>,
1650b57cec5SDimitry Andric    VOP2Inst_e64<opName, P, node, revOp, GFX9Renamed>,
1660b57cec5SDimitry Andric    VOP2Inst_sdwa<opName, P, node, revOp, GFX9Renamed> {
1670b57cec5SDimitry Andric  let renamedInGFX9 = GFX9Renamed in {
1680b57cec5SDimitry Andric    foreach _ = BoolToList<P.HasExtDPP>.ret in
1690b57cec5SDimitry Andric      def _dpp  : VOP2_DPP_Pseudo <opName, P>;
1700b57cec5SDimitry Andric  }
1710b57cec5SDimitry Andric}
1720b57cec5SDimitry Andric
1730b57cec5SDimitry Andricmulticlass VOP2bInst <string opName,
1740b57cec5SDimitry Andric                      VOPProfile P,
1750b57cec5SDimitry Andric                      SDPatternOperator node = null_frag,
1760b57cec5SDimitry Andric                      string revOp = opName,
1770b57cec5SDimitry Andric                      bit GFX9Renamed = 0,
1780b57cec5SDimitry Andric                      bit useSGPRInput = !eq(P.NumSrcArgs, 3)> {
1790b57cec5SDimitry Andric  let renamedInGFX9 = GFX9Renamed in {
1800b57cec5SDimitry Andric    let SchedRW = [Write32Bit, WriteSALU] in {
1810b57cec5SDimitry Andric      let Uses = !if(useSGPRInput, [VCC, EXEC], [EXEC]), Defs = [VCC] in {
1820b57cec5SDimitry Andric        def _e32 : VOP2_Pseudo <opName, P, VOPPatOrNull<node,P>.ret>,
1830b57cec5SDimitry Andric                   Commutable_REV<revOp#"_e32", !eq(revOp, opName)> {
1840b57cec5SDimitry Andric          let usesCustomInserter = !eq(P.NumSrcArgs, 2);
1850b57cec5SDimitry Andric        }
1860b57cec5SDimitry Andric
1878bcb0991SDimitry Andric        foreach _ = BoolToList<P.HasExtSDWA>.ret in
1880b57cec5SDimitry Andric          def _sdwa  : VOP2_SDWA_Pseudo <opName, P> {
1890b57cec5SDimitry Andric            let AsmMatchConverter = "cvtSdwaVOP2b";
1900b57cec5SDimitry Andric          }
1910b57cec5SDimitry Andric        foreach _ = BoolToList<P.HasExtDPP>.ret in
1920b57cec5SDimitry Andric          def _dpp  : VOP2_DPP_Pseudo <opName, P>;
1930b57cec5SDimitry Andric      }
1940b57cec5SDimitry Andric
1950b57cec5SDimitry Andric      def _e64 : VOP3_Pseudo <opName, P, getVOP2Pat64<node, P>.ret>,
1960b57cec5SDimitry Andric                 Commutable_REV<revOp#"_e64", !eq(revOp, opName)>;
1970b57cec5SDimitry Andric    }
1980b57cec5SDimitry Andric  }
1990b57cec5SDimitry Andric}
2000b57cec5SDimitry Andric
2010b57cec5SDimitry Andricclass VOP2bInstAlias <VOP2_Pseudo ps, Instruction inst,
2020b57cec5SDimitry Andric                      string OpName, string opnd> :
2030b57cec5SDimitry Andric  InstAlias <OpName#" "#!subst("vcc", opnd, ps.Pfl.Asm32),
2040b57cec5SDimitry Andric             (inst ps.Pfl.DstRC:$vdst, ps.Pfl.Src0RC32:$src0,
2050b57cec5SDimitry Andric                   ps.Pfl.Src1RC32:$src1)>,
2060b57cec5SDimitry Andric  PredicateControl {
2070b57cec5SDimitry Andric}
2080b57cec5SDimitry Andric
2090b57cec5SDimitry Andricmulticlass VOP2bInstAliases<VOP2_Pseudo ps, VOP2_Real inst, string OpName> {
2100b57cec5SDimitry Andric  let WaveSizePredicate = isWave32 in {
2110b57cec5SDimitry Andric    def : VOP2bInstAlias<ps, inst, OpName, "vcc_lo">;
2120b57cec5SDimitry Andric  }
2130b57cec5SDimitry Andric  let WaveSizePredicate = isWave64 in {
2140b57cec5SDimitry Andric    def : VOP2bInstAlias<ps, inst, OpName, "vcc">;
2150b57cec5SDimitry Andric  }
2160b57cec5SDimitry Andric}
2170b57cec5SDimitry Andric
2180b57cec5SDimitry Andricmulticlass VOP2eInst <string opName,
2190b57cec5SDimitry Andric                      VOPProfile P,
2200b57cec5SDimitry Andric                      SDPatternOperator node = null_frag,
2210b57cec5SDimitry Andric                      string revOp = opName,
2220b57cec5SDimitry Andric                      bit useSGPRInput = !eq(P.NumSrcArgs, 3)> {
2230b57cec5SDimitry Andric
2240b57cec5SDimitry Andric  let SchedRW = [Write32Bit] in {
2250b57cec5SDimitry Andric    let Uses = !if(useSGPRInput, [VCC, EXEC], [EXEC]) in {
2260b57cec5SDimitry Andric      def _e32 : VOP2_Pseudo <opName, P>,
2270b57cec5SDimitry Andric                 Commutable_REV<revOp#"_e32", !eq(revOp, opName)>;
2280b57cec5SDimitry Andric
2298bcb0991SDimitry Andric      foreach _ = BoolToList<P.HasExtSDWA>.ret in
2300b57cec5SDimitry Andric        def _sdwa : VOP2_SDWA_Pseudo <opName, P> {
2318bcb0991SDimitry Andric          let AsmMatchConverter = "cvtSdwaVOP2e";
2320b57cec5SDimitry Andric        }
2330b57cec5SDimitry Andric
2340b57cec5SDimitry Andric      foreach _ = BoolToList<P.HasExtDPP>.ret in
2350b57cec5SDimitry Andric        def _dpp  : VOP2_DPP_Pseudo <opName, P>;
2360b57cec5SDimitry Andric    }
2370b57cec5SDimitry Andric
2380b57cec5SDimitry Andric    def _e64 : VOP3_Pseudo <opName, P, getVOP2Pat64<node, P>.ret>,
2390b57cec5SDimitry Andric               Commutable_REV<revOp#"_e64", !eq(revOp, opName)>;
2400b57cec5SDimitry Andric  }
2410b57cec5SDimitry Andric}
2420b57cec5SDimitry Andric
2430b57cec5SDimitry Andricclass VOP2eInstAlias <VOP2_Pseudo ps, Instruction inst, string opnd> :
2440b57cec5SDimitry Andric  InstAlias <ps.OpName#" "#ps.Pfl.Asm32#", "#opnd,
2450b57cec5SDimitry Andric             (inst ps.Pfl.DstRC:$vdst, ps.Pfl.Src0RC32:$src0,
2460b57cec5SDimitry Andric                   ps.Pfl.Src1RC32:$src1)>,
2470b57cec5SDimitry Andric  PredicateControl {
2480b57cec5SDimitry Andric}
2490b57cec5SDimitry Andric
2500b57cec5SDimitry Andricmulticlass VOP2eInstAliases<VOP2_Pseudo ps, VOP2_Real inst> {
2510b57cec5SDimitry Andric  let WaveSizePredicate = isWave32 in {
2520b57cec5SDimitry Andric    def : VOP2eInstAlias<ps, inst, "vcc_lo">;
2530b57cec5SDimitry Andric  }
2540b57cec5SDimitry Andric  let WaveSizePredicate = isWave64 in {
2550b57cec5SDimitry Andric    def : VOP2eInstAlias<ps, inst, "vcc">;
2560b57cec5SDimitry Andric  }
2570b57cec5SDimitry Andric}
2580b57cec5SDimitry Andric
2590b57cec5SDimitry Andricclass VOP_MADAK <ValueType vt> : VOPProfile <[vt, vt, vt, vt]> {
2600b57cec5SDimitry Andric  field Operand ImmOpType = !if(!eq(vt.Size, 32), f32kimm, f16kimm);
2618bcb0991SDimitry Andric  field dag Ins32 = !if(!eq(vt.Size, 32),
2628bcb0991SDimitry Andric                        (ins VCSrc_f32:$src0, VGPR_32:$src1, ImmOpType:$imm),
2638bcb0991SDimitry Andric                        (ins VCSrc_f16:$src0, VGPR_32:$src1, ImmOpType:$imm));
2640b57cec5SDimitry Andric  field bit HasExt = 0;
2650b57cec5SDimitry Andric
2660b57cec5SDimitry Andric  // Hack to stop printing _e64
2670b57cec5SDimitry Andric  let DstRC = RegisterOperand<VGPR_32>;
2680b57cec5SDimitry Andric  field string Asm32 = " $vdst, $src0, $src1, $imm";
2690b57cec5SDimitry Andric}
2700b57cec5SDimitry Andric
2710b57cec5SDimitry Andricdef VOP_MADAK_F16 : VOP_MADAK <f16>;
2720b57cec5SDimitry Andricdef VOP_MADAK_F32 : VOP_MADAK <f32>;
2730b57cec5SDimitry Andric
2740b57cec5SDimitry Andricclass VOP_MADMK <ValueType vt> : VOPProfile <[vt, vt, vt, vt]> {
2750b57cec5SDimitry Andric  field Operand ImmOpType = !if(!eq(vt.Size, 32), f32kimm, f16kimm);
2760b57cec5SDimitry Andric  field dag Ins32 = (ins VCSrc_f32:$src0, ImmOpType:$imm, VGPR_32:$src1);
2770b57cec5SDimitry Andric  field bit HasExt = 0;
2780b57cec5SDimitry Andric
2790b57cec5SDimitry Andric  // Hack to stop printing _e64
2800b57cec5SDimitry Andric  let DstRC = RegisterOperand<VGPR_32>;
2810b57cec5SDimitry Andric  field string Asm32 = " $vdst, $src0, $imm, $src1";
2820b57cec5SDimitry Andric}
2830b57cec5SDimitry Andric
2840b57cec5SDimitry Andricdef VOP_MADMK_F16 : VOP_MADMK <f16>;
2850b57cec5SDimitry Andricdef VOP_MADMK_F32 : VOP_MADMK <f32>;
2860b57cec5SDimitry Andric
2870b57cec5SDimitry Andric// FIXME: Remove src2_modifiers. It isn't used, so is wasting memory
2880b57cec5SDimitry Andric// and processing time but it makes it easier to convert to mad.
2890b57cec5SDimitry Andricclass VOP_MAC <ValueType vt0, ValueType vt1=vt0> : VOPProfile <[vt0, vt1, vt1, vt0]> {
2900b57cec5SDimitry Andric  let Ins32 = (ins Src0RC32:$src0, Src1RC32:$src1, VGPR_32:$src2);
2910b57cec5SDimitry Andric  let Ins64 = getIns64<Src0RC64, Src1RC64, RegisterOperand<VGPR_32>, 3,
2920b57cec5SDimitry Andric                       0, HasModifiers, HasModifiers, HasOMod,
2930b57cec5SDimitry Andric                       Src0Mod, Src1Mod, Src2Mod>.ret;
2940b57cec5SDimitry Andric  let InsDPP = (ins Src0ModDPP:$src0_modifiers, Src0DPP:$src0,
2950b57cec5SDimitry Andric                    Src1ModDPP:$src1_modifiers, Src1DPP:$src1,
2960b57cec5SDimitry Andric                    VGPR_32:$src2, // stub argument
2970b57cec5SDimitry Andric                    dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
2980b57cec5SDimitry Andric                    bank_mask:$bank_mask, bound_ctrl:$bound_ctrl);
2990b57cec5SDimitry Andric  let InsDPP16 = !con(InsDPP, (ins FI:$fi));
3000b57cec5SDimitry Andric
3010b57cec5SDimitry Andric  let InsDPP8 = (ins Src0ModDPP:$src0_modifiers, Src0DPP:$src0,
3020b57cec5SDimitry Andric                     Src1ModDPP:$src1_modifiers, Src1DPP:$src1,
3030b57cec5SDimitry Andric                     VGPR_32:$src2, // stub argument
3040b57cec5SDimitry Andric                     dpp8:$dpp8, FI:$fi);
3050b57cec5SDimitry Andric
3060b57cec5SDimitry Andric  let InsSDWA = (ins Src0ModSDWA:$src0_modifiers, Src0SDWA:$src0,
3070b57cec5SDimitry Andric                     Src1ModSDWA:$src1_modifiers, Src1SDWA:$src1,
3080b57cec5SDimitry Andric                     VGPR_32:$src2, // stub argument
3090b57cec5SDimitry Andric                     clampmod:$clamp, omod:$omod,
3100b57cec5SDimitry Andric                     dst_sel:$dst_sel, dst_unused:$dst_unused,
3110b57cec5SDimitry Andric                     src0_sel:$src0_sel, src1_sel:$src1_sel);
3120b57cec5SDimitry Andric  let Asm32 = getAsm32<1, 2, vt0>.ret;
3130b57cec5SDimitry Andric  let Asm64 = getAsm64<1, 2, 0, HasModifiers, HasOMod, vt0>.ret;
3140b57cec5SDimitry Andric  let AsmDPP = getAsmDPP<1, 2, HasModifiers, vt0>.ret;
3150b57cec5SDimitry Andric  let AsmDPP16 = getAsmDPP16<1, 2, HasModifiers, vt0>.ret;
3160b57cec5SDimitry Andric  let AsmDPP8 = getAsmDPP8<1, 2, 0, vt0>.ret;
3170b57cec5SDimitry Andric  let AsmSDWA = getAsmSDWA<1, 2, vt0>.ret;
3180b57cec5SDimitry Andric  let AsmSDWA9 = getAsmSDWA9<1, 1, 2, vt0>.ret;
3190b57cec5SDimitry Andric  let HasSrc2 = 0;
3200b57cec5SDimitry Andric  let HasSrc2Mods = 0;
3210b57cec5SDimitry Andric
3220b57cec5SDimitry Andric  let HasExt = 1;
3230b57cec5SDimitry Andric  let HasExtDPP = 1;
3240b57cec5SDimitry Andric  let HasExtSDWA = 1;
3250b57cec5SDimitry Andric  let HasExtSDWA9 = 0;
3260b57cec5SDimitry Andric  let TieRegDPP = "$src2";
3270b57cec5SDimitry Andric}
3280b57cec5SDimitry Andric
3290b57cec5SDimitry Andricdef VOP_MAC_F16 : VOP_MAC <f16>;
3300b57cec5SDimitry Andricdef VOP_MAC_F32 : VOP_MAC <f32>;
3310b57cec5SDimitry Andric
3320b57cec5SDimitry Andricclass VOP_DOT_ACC<ValueType vt0, ValueType vt1> : VOP_MAC<vt0, vt1> {
3330b57cec5SDimitry Andric  let HasClamp = 0;
3340b57cec5SDimitry Andric  let HasExtSDWA = 0;
3350b57cec5SDimitry Andric  let HasModifiers = 1;
3360b57cec5SDimitry Andric  let HasOpSel = 0;
3370b57cec5SDimitry Andric  let IsPacked = 0;
3380b57cec5SDimitry Andric}
3390b57cec5SDimitry Andric
3400b57cec5SDimitry Andricdef VOP_DOT_ACC_F32_V2F16 : VOP_DOT_ACC<f32, v2f16> {
3410b57cec5SDimitry Andric  let Src0ModDPP = FPVRegInputMods;
3420b57cec5SDimitry Andric  let Src1ModDPP = FPVRegInputMods;
3430b57cec5SDimitry Andric}
3440b57cec5SDimitry Andricdef VOP_DOT_ACC_I32_I32   : VOP_DOT_ACC<i32, i32>;
3450b57cec5SDimitry Andric
3460b57cec5SDimitry Andric// Write out to vcc or arbitrary SGPR.
3470b57cec5SDimitry Andricdef VOP2b_I32_I1_I32_I32 : VOPProfile<[i32, i32, i32, untyped], 0, /*EnableClamp=*/1> {
3480b57cec5SDimitry Andric  let Asm32 = "$vdst, vcc, $src0, $src1";
3490b57cec5SDimitry Andric  let Asm64 = "$vdst, $sdst, $src0, $src1$clamp";
3500b57cec5SDimitry Andric  let AsmSDWA = "$vdst, vcc, $src0_modifiers, $src1_modifiers$clamp $dst_sel $dst_unused $src0_sel $src1_sel";
3510b57cec5SDimitry Andric  let AsmSDWA9 = "$vdst, vcc, $src0_modifiers, $src1_modifiers$clamp $dst_sel $dst_unused $src0_sel $src1_sel";
3520b57cec5SDimitry Andric  let AsmDPP = "$vdst, vcc, $src0, $src1 $dpp_ctrl$row_mask$bank_mask$bound_ctrl";
3530b57cec5SDimitry Andric  let AsmDPP8 = "$vdst, vcc, $src0, $src1 $dpp8$fi";
3540b57cec5SDimitry Andric  let AsmDPP16 = AsmDPP#"$fi";
3550b57cec5SDimitry Andric  let Outs32 = (outs DstRC:$vdst);
3560b57cec5SDimitry Andric  let Outs64 = (outs DstRC:$vdst, VOPDstS64orS32:$sdst);
3570b57cec5SDimitry Andric}
3580b57cec5SDimitry Andric
3590b57cec5SDimitry Andric// Write out to vcc or arbitrary SGPR and read in from vcc or
3600b57cec5SDimitry Andric// arbitrary SGPR.
3610b57cec5SDimitry Andricdef VOP2b_I32_I1_I32_I32_I1 : VOPProfile<[i32, i32, i32, i1], 0, /*EnableClamp=*/1> {
3620b57cec5SDimitry Andric  let Asm32 = "$vdst, vcc, $src0, $src1, vcc";
3630b57cec5SDimitry Andric  let Asm64 = "$vdst, $sdst, $src0, $src1, $src2$clamp";
3640b57cec5SDimitry Andric  let AsmSDWA = "$vdst, vcc, $src0_modifiers, $src1_modifiers, vcc $clamp $dst_sel $dst_unused $src0_sel $src1_sel";
3650b57cec5SDimitry Andric  let AsmSDWA9 = "$vdst, vcc, $src0_modifiers, $src1_modifiers, vcc $clamp $dst_sel $dst_unused $src0_sel $src1_sel";
3660b57cec5SDimitry Andric  let AsmDPP = "$vdst, vcc, $src0, $src1, vcc $dpp_ctrl$row_mask$bank_mask$bound_ctrl";
3670b57cec5SDimitry Andric  let AsmDPP8 = "$vdst, vcc, $src0, $src1, vcc $dpp8$fi";
3680b57cec5SDimitry Andric  let AsmDPP16 = AsmDPP#"$fi";
3690b57cec5SDimitry Andric  let Outs32 = (outs DstRC:$vdst);
3700b57cec5SDimitry Andric  let Outs64 = (outs DstRC:$vdst, VOPDstS64orS32:$sdst);
3710b57cec5SDimitry Andric
3720b57cec5SDimitry Andric  // Suppress src2 implied by type since the 32-bit encoding uses an
3730b57cec5SDimitry Andric  // implicit VCC use.
3740b57cec5SDimitry Andric  let Ins32 = (ins Src0RC32:$src0, Src1RC32:$src1);
3750b57cec5SDimitry Andric
3760b57cec5SDimitry Andric  let InsSDWA = (ins Src0ModSDWA:$src0_modifiers, Src0SDWA:$src0,
3770b57cec5SDimitry Andric                     Src1ModSDWA:$src1_modifiers, Src1SDWA:$src1,
3780b57cec5SDimitry Andric                     clampmod:$clamp,
3790b57cec5SDimitry Andric                     dst_sel:$dst_sel, dst_unused:$dst_unused,
3800b57cec5SDimitry Andric                     src0_sel:$src0_sel, src1_sel:$src1_sel);
3810b57cec5SDimitry Andric
3820b57cec5SDimitry Andric  let InsDPP = (ins DstRCDPP:$old,
3830b57cec5SDimitry Andric                    Src0DPP:$src0,
3840b57cec5SDimitry Andric                    Src1DPP:$src1,
3850b57cec5SDimitry Andric                    dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
3860b57cec5SDimitry Andric                    bank_mask:$bank_mask, bound_ctrl:$bound_ctrl);
3870b57cec5SDimitry Andric  let InsDPP16 = !con(InsDPP, (ins FI:$fi));
3880b57cec5SDimitry Andric
3890b57cec5SDimitry Andric  let HasExt = 1;
3900b57cec5SDimitry Andric  let HasExtDPP = 1;
3910b57cec5SDimitry Andric  let HasExtSDWA = 1;
3920b57cec5SDimitry Andric  let HasExtSDWA9 = 1;
3930b57cec5SDimitry Andric}
3940b57cec5SDimitry Andric
3950b57cec5SDimitry Andric// Read in from vcc or arbitrary SGPR.
3960b57cec5SDimitry Andricdef VOP2e_I32_I32_I32_I1 : VOPProfile<[i32, i32, i32, i1], /*EnableF32SrcMods=*/1> {
3970b57cec5SDimitry Andric  let Asm32 = "$vdst, $src0, $src1";
3980b57cec5SDimitry Andric  let Asm64 = "$vdst, $src0_modifiers, $src1_modifiers, $src2";
3990b57cec5SDimitry Andric  let AsmSDWA = "$vdst, $src0_modifiers, $src1_modifiers, vcc $clamp $dst_sel $dst_unused $src0_sel $src1_sel";
4000b57cec5SDimitry Andric  let AsmSDWA9 = "$vdst, $src0_modifiers, $src1_modifiers, vcc $clamp $dst_sel $dst_unused $src0_sel $src1_sel";
4010b57cec5SDimitry Andric  let AsmDPP = "$vdst, $src0, $src1, vcc $dpp_ctrl$row_mask$bank_mask$bound_ctrl";
4020b57cec5SDimitry Andric  let AsmDPP8 = "$vdst, $src0, $src1, vcc $dpp8$fi";
4030b57cec5SDimitry Andric  let AsmDPP16 = AsmDPP#"$fi";
4040b57cec5SDimitry Andric
4050b57cec5SDimitry Andric  let Outs32 = (outs DstRC:$vdst);
4060b57cec5SDimitry Andric  let Outs64 = (outs DstRC:$vdst);
4070b57cec5SDimitry Andric
4080b57cec5SDimitry Andric  // Suppress src2 implied by type since the 32-bit encoding uses an
4090b57cec5SDimitry Andric  // implicit VCC use.
4100b57cec5SDimitry Andric  let Ins32 = (ins Src0RC32:$src0, Src1RC32:$src1);
4110b57cec5SDimitry Andric
4120b57cec5SDimitry Andric  let InsSDWA = (ins Src0ModSDWA:$src0_modifiers, Src0SDWA:$src0,
4130b57cec5SDimitry Andric                     Src1ModSDWA:$src1_modifiers, Src1SDWA:$src1,
4140b57cec5SDimitry Andric                     clampmod:$clamp,
4150b57cec5SDimitry Andric                     dst_sel:$dst_sel, dst_unused:$dst_unused,
4160b57cec5SDimitry Andric                     src0_sel:$src0_sel, src1_sel:$src1_sel);
4170b57cec5SDimitry Andric
4180b57cec5SDimitry Andric  let InsDPP = (ins DstRCDPP:$old,
4190b57cec5SDimitry Andric                    Src0ModDPP:$src0_modifiers, Src0DPP:$src0,
4200b57cec5SDimitry Andric                    Src1ModDPP:$src1_modifiers, Src1DPP:$src1,
4210b57cec5SDimitry Andric                    dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
4220b57cec5SDimitry Andric                    bank_mask:$bank_mask, bound_ctrl:$bound_ctrl);
4230b57cec5SDimitry Andric  let InsDPP16 = !con(InsDPP, (ins FI:$fi));
4240b57cec5SDimitry Andric
4250b57cec5SDimitry Andric  let HasExt = 1;
4260b57cec5SDimitry Andric  let HasExtDPP = 1;
4270b57cec5SDimitry Andric  let HasExtSDWA = 1;
4280b57cec5SDimitry Andric  let HasExtSDWA9 = 1;
4290b57cec5SDimitry Andric}
4300b57cec5SDimitry Andric
4310b57cec5SDimitry Andricdef VOP_READLANE : VOPProfile<[i32, i32, i32]> {
4320b57cec5SDimitry Andric  let Outs32 = (outs SReg_32:$vdst);
4330b57cec5SDimitry Andric  let Outs64 = Outs32;
4340b57cec5SDimitry Andric  let Ins32 = (ins VRegOrLds_32:$src0, SCSrc_b32:$src1);
4350b57cec5SDimitry Andric  let Ins64 = Ins32;
4360b57cec5SDimitry Andric  let Asm32 = " $vdst, $src0, $src1";
4370b57cec5SDimitry Andric  let Asm64 = Asm32;
4380b57cec5SDimitry Andric
4390b57cec5SDimitry Andric  let HasExt = 0;
4400b57cec5SDimitry Andric  let HasExtDPP = 0;
4410b57cec5SDimitry Andric  let HasExtSDWA = 0;
4420b57cec5SDimitry Andric  let HasExtSDWA9 = 0;
4430b57cec5SDimitry Andric}
4440b57cec5SDimitry Andric
4450b57cec5SDimitry Andricdef VOP_WRITELANE : VOPProfile<[i32, i32, i32, i32]> {
4460b57cec5SDimitry Andric  let Outs32 = (outs VGPR_32:$vdst);
4470b57cec5SDimitry Andric  let Outs64 = Outs32;
4480b57cec5SDimitry Andric  let Ins32 = (ins SCSrc_b32:$src0, SCSrc_b32:$src1, VGPR_32:$vdst_in);
4490b57cec5SDimitry Andric  let Ins64 = Ins32;
4500b57cec5SDimitry Andric  let Asm32 = " $vdst, $src0, $src1";
4510b57cec5SDimitry Andric  let Asm64 = Asm32;
4520b57cec5SDimitry Andric  let HasSrc2 = 0;
4530b57cec5SDimitry Andric  let HasSrc2Mods = 0;
4540b57cec5SDimitry Andric
4550b57cec5SDimitry Andric  let HasExt = 0;
4560b57cec5SDimitry Andric  let HasExtDPP = 0;
4570b57cec5SDimitry Andric  let HasExtSDWA = 0;
4580b57cec5SDimitry Andric  let HasExtSDWA9 = 0;
4590b57cec5SDimitry Andric}
4600b57cec5SDimitry Andric
4610b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
4620b57cec5SDimitry Andric// VOP2 Instructions
4630b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
4640b57cec5SDimitry Andric
4650b57cec5SDimitry Andricdefm V_CNDMASK_B32 : VOP2eInst <"v_cndmask_b32", VOP2e_I32_I32_I32_I1>;
466*5ffd83dbSDimitry Andriclet SubtargetPredicate = HasMadMacF32Insts in
4670b57cec5SDimitry Andricdef V_MADMK_F32 : VOP2_Pseudo <"v_madmk_f32", VOP_MADMK_F32, []>;
4680b57cec5SDimitry Andric
4690b57cec5SDimitry Andriclet isCommutable = 1 in {
470*5ffd83dbSDimitry Andricdefm V_ADD_F32 : VOP2Inst <"v_add_f32", VOP_F32_F32_F32, any_fadd>;
4710b57cec5SDimitry Andricdefm V_SUB_F32 : VOP2Inst <"v_sub_f32", VOP_F32_F32_F32, fsub>;
4720b57cec5SDimitry Andricdefm V_SUBREV_F32 : VOP2Inst <"v_subrev_f32", VOP_F32_F32_F32, null_frag, "v_sub_f32">;
4730b57cec5SDimitry Andricdefm V_MUL_LEGACY_F32 : VOP2Inst <"v_mul_legacy_f32", VOP_F32_F32_F32, AMDGPUfmul_legacy>;
474*5ffd83dbSDimitry Andricdefm V_MUL_F32 : VOP2Inst <"v_mul_f32", VOP_F32_F32_F32, any_fmul>;
475*5ffd83dbSDimitry Andricdefm V_MUL_I32_I24 : VOP2Inst <"v_mul_i32_i24", VOP_I32_I32_I32_ARITH, AMDGPUmul_i24>;
4760b57cec5SDimitry Andricdefm V_MUL_HI_I32_I24 : VOP2Inst <"v_mul_hi_i32_i24", VOP_PAT_GEN<VOP_I32_I32_I32, 2>, AMDGPUmulhi_i24>;
477*5ffd83dbSDimitry Andricdefm V_MUL_U32_U24 : VOP2Inst <"v_mul_u32_u24", VOP_I32_I32_I32_ARITH, AMDGPUmul_u24>;
4780b57cec5SDimitry Andricdefm V_MUL_HI_U32_U24 : VOP2Inst <"v_mul_hi_u32_u24", VOP_PAT_GEN<VOP_I32_I32_I32, 2>, AMDGPUmulhi_u24>;
4790b57cec5SDimitry Andricdefm V_MIN_F32 : VOP2Inst <"v_min_f32", VOP_F32_F32_F32, fminnum_like>;
4800b57cec5SDimitry Andricdefm V_MAX_F32 : VOP2Inst <"v_max_f32", VOP_F32_F32_F32, fmaxnum_like>;
4810b57cec5SDimitry Andricdefm V_MIN_I32 : VOP2Inst <"v_min_i32", VOP_PAT_GEN<VOP_I32_I32_I32>, smin>;
4820b57cec5SDimitry Andricdefm V_MAX_I32 : VOP2Inst <"v_max_i32", VOP_PAT_GEN<VOP_I32_I32_I32>, smax>;
4830b57cec5SDimitry Andricdefm V_MIN_U32 : VOP2Inst <"v_min_u32", VOP_PAT_GEN<VOP_I32_I32_I32>, umin>;
4840b57cec5SDimitry Andricdefm V_MAX_U32 : VOP2Inst <"v_max_u32", VOP_PAT_GEN<VOP_I32_I32_I32>, umax>;
4850b57cec5SDimitry Andricdefm V_LSHRREV_B32 : VOP2Inst <"v_lshrrev_b32", VOP_I32_I32_I32, lshr_rev, "v_lshr_b32">;
4860b57cec5SDimitry Andricdefm V_ASHRREV_I32 : VOP2Inst <"v_ashrrev_i32", VOP_I32_I32_I32, ashr_rev, "v_ashr_i32">;
4870b57cec5SDimitry Andricdefm V_LSHLREV_B32 : VOP2Inst <"v_lshlrev_b32", VOP_I32_I32_I32, lshl_rev, "v_lshl_b32">;
4880b57cec5SDimitry Andricdefm V_AND_B32 : VOP2Inst <"v_and_b32", VOP_PAT_GEN<VOP_I32_I32_I32>, and>;
4890b57cec5SDimitry Andricdefm V_OR_B32 : VOP2Inst <"v_or_b32", VOP_PAT_GEN<VOP_I32_I32_I32>, or>;
4900b57cec5SDimitry Andricdefm V_XOR_B32 : VOP2Inst <"v_xor_b32", VOP_PAT_GEN<VOP_I32_I32_I32>, xor>;
4910b57cec5SDimitry Andric
492*5ffd83dbSDimitry Andriclet mayRaiseFPException = 0 in {
493*5ffd83dbSDimitry Andriclet SubtargetPredicate = HasMadMacF32Insts in {
4940b57cec5SDimitry Andriclet Constraints = "$vdst = $src2", DisableEncoding="$src2",
4950b57cec5SDimitry Andric    isConvertibleToThreeAddress = 1 in {
4960b57cec5SDimitry Andricdefm V_MAC_F32 : VOP2Inst <"v_mac_f32", VOP_MAC_F32>;
4970b57cec5SDimitry Andric}
4980b57cec5SDimitry Andric
4990b57cec5SDimitry Andricdef V_MADAK_F32 : VOP2_Pseudo <"v_madak_f32", VOP_MADAK_F32, []>;
500*5ffd83dbSDimitry Andric} // End SubtargetPredicate = HasMadMacF32Insts
501*5ffd83dbSDimitry Andric}
5020b57cec5SDimitry Andric
5030b57cec5SDimitry Andric// No patterns so that the scalar instructions are always selected.
5040b57cec5SDimitry Andric// The scalar versions will be replaced with vector when needed later.
5050b57cec5SDimitry Andric
5060b57cec5SDimitry Andric// V_ADD_I32, V_SUB_I32, and V_SUBREV_I32 where renamed to *_U32 in VI,
5070b57cec5SDimitry Andric// but the VI instructions behave the same as the SI versions.
5080b57cec5SDimitry Andricdefm V_ADD_I32 : VOP2bInst <"v_add_i32", VOP2b_I32_I1_I32_I32, null_frag, "v_add_i32", 1>;
5090b57cec5SDimitry Andricdefm V_SUB_I32 : VOP2bInst <"v_sub_i32", VOP2b_I32_I1_I32_I32, null_frag, "v_sub_i32", 1>;
5100b57cec5SDimitry Andricdefm V_SUBREV_I32 : VOP2bInst <"v_subrev_i32", VOP2b_I32_I1_I32_I32, null_frag, "v_sub_i32", 1>;
5110b57cec5SDimitry Andricdefm V_ADDC_U32 : VOP2bInst <"v_addc_u32", VOP2b_I32_I1_I32_I32_I1, null_frag, "v_addc_u32", 1>;
5120b57cec5SDimitry Andricdefm V_SUBB_U32 : VOP2bInst <"v_subb_u32", VOP2b_I32_I1_I32_I32_I1, null_frag, "v_subb_u32", 1>;
5130b57cec5SDimitry Andricdefm V_SUBBREV_U32 : VOP2bInst <"v_subbrev_u32", VOP2b_I32_I1_I32_I32_I1, null_frag, "v_subb_u32", 1>;
5140b57cec5SDimitry Andric
5150b57cec5SDimitry Andric
5160b57cec5SDimitry Andriclet SubtargetPredicate = HasAddNoCarryInsts in {
5170b57cec5SDimitry Andricdefm V_ADD_U32 : VOP2Inst <"v_add_u32", VOP_I32_I32_I32_ARITH, null_frag, "v_add_u32", 1>;
5180b57cec5SDimitry Andricdefm V_SUB_U32 : VOP2Inst <"v_sub_u32", VOP_I32_I32_I32_ARITH, null_frag, "v_sub_u32", 1>;
5190b57cec5SDimitry Andricdefm V_SUBREV_U32 : VOP2Inst <"v_subrev_u32", VOP_I32_I32_I32_ARITH, null_frag, "v_sub_u32", 1>;
5200b57cec5SDimitry Andric}
5210b57cec5SDimitry Andric
5220b57cec5SDimitry Andric} // End isCommutable = 1
5230b57cec5SDimitry Andric
5240b57cec5SDimitry Andric// These are special and do not read the exec mask.
5250b57cec5SDimitry Andriclet isConvergent = 1, Uses = []<Register> in {
5260b57cec5SDimitry Andricdef V_READLANE_B32 : VOP2_Pseudo<"v_readlane_b32", VOP_READLANE,
5270b57cec5SDimitry Andric  [(set i32:$vdst, (int_amdgcn_readlane i32:$src0, i32:$src1))]>;
5280b57cec5SDimitry Andric
5290b57cec5SDimitry Andriclet Constraints = "$vdst = $vdst_in", DisableEncoding="$vdst_in" in {
5300b57cec5SDimitry Andricdef V_WRITELANE_B32 : VOP2_Pseudo<"v_writelane_b32", VOP_WRITELANE,
5310b57cec5SDimitry Andric  [(set i32:$vdst, (int_amdgcn_writelane i32:$src0, i32:$src1, i32:$vdst_in))]>;
5320b57cec5SDimitry Andric} // End $vdst = $vdst_in, DisableEncoding $vdst_in
5330b57cec5SDimitry Andric} // End isConvergent = 1
5340b57cec5SDimitry Andric
5350b57cec5SDimitry Andricdefm V_BFM_B32 : VOP2Inst <"v_bfm_b32", VOP_NO_EXT<VOP_I32_I32_I32>>;
5368bcb0991SDimitry Andricdefm V_BCNT_U32_B32 : VOP2Inst <"v_bcnt_u32_b32", VOP_NO_EXT<VOP_I32_I32_I32>, add_ctpop>;
5370b57cec5SDimitry Andricdefm V_MBCNT_LO_U32_B32 : VOP2Inst <"v_mbcnt_lo_u32_b32", VOP_NO_EXT<VOP_I32_I32_I32>, int_amdgcn_mbcnt_lo>;
5380b57cec5SDimitry Andricdefm V_MBCNT_HI_U32_B32 : VOP2Inst <"v_mbcnt_hi_u32_b32", VOP_NO_EXT<VOP_I32_I32_I32>, int_amdgcn_mbcnt_hi>;
5390b57cec5SDimitry Andricdefm V_LDEXP_F32 : VOP2Inst <"v_ldexp_f32", VOP_NO_EXT<VOP_F32_F32_I32>, AMDGPUldexp>;
5400b57cec5SDimitry Andricdefm V_CVT_PKACCUM_U8_F32 : VOP2Inst <"v_cvt_pkaccum_u8_f32", VOP_NO_EXT<VOP_I32_F32_I32>>; // TODO: set "Uses = dst"
541*5ffd83dbSDimitry Andric
542*5ffd83dbSDimitry Andriclet ReadsModeReg = 0, mayRaiseFPException = 0 in {
5430b57cec5SDimitry Andricdefm V_CVT_PKNORM_I16_F32 : VOP2Inst <"v_cvt_pknorm_i16_f32", VOP_NO_EXT<VOP_V2I16_F32_F32>, AMDGPUpknorm_i16_f32>;
5440b57cec5SDimitry Andricdefm V_CVT_PKNORM_U16_F32 : VOP2Inst <"v_cvt_pknorm_u16_f32", VOP_NO_EXT<VOP_V2I16_F32_F32>, AMDGPUpknorm_u16_f32>;
545*5ffd83dbSDimitry Andric}
546*5ffd83dbSDimitry Andric
5470b57cec5SDimitry Andricdefm V_CVT_PKRTZ_F16_F32 : VOP2Inst <"v_cvt_pkrtz_f16_f32", VOP_NO_EXT<VOP_V2F16_F32_F32>, AMDGPUpkrtz_f16_f32>;
5480b57cec5SDimitry Andricdefm V_CVT_PK_U16_U32 : VOP2Inst <"v_cvt_pk_u16_u32", VOP_NO_EXT<VOP_V2I16_I32_I32>, AMDGPUpk_u16_u32>;
5490b57cec5SDimitry Andricdefm V_CVT_PK_I16_I32 : VOP2Inst <"v_cvt_pk_i16_i32", VOP_NO_EXT<VOP_V2I16_I32_I32>, AMDGPUpk_i16_i32>;
5500b57cec5SDimitry Andric
5510b57cec5SDimitry Andric
5520b57cec5SDimitry Andriclet SubtargetPredicate = isGFX6GFX7 in {
5530b57cec5SDimitry Andricdefm V_MIN_LEGACY_F32 : VOP2Inst <"v_min_legacy_f32", VOP_F32_F32_F32, AMDGPUfmin_legacy>;
5540b57cec5SDimitry Andricdefm V_MAX_LEGACY_F32 : VOP2Inst <"v_max_legacy_f32", VOP_F32_F32_F32, AMDGPUfmax_legacy>;
5550b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX6GFX7
5560b57cec5SDimitry Andric
5570b57cec5SDimitry Andriclet isCommutable = 1 in {
558*5ffd83dbSDimitry Andriclet SubtargetPredicate = isGFX6GFX7GFX10 in {
559*5ffd83dbSDimitry Andriclet OtherPredicates = [HasMadMacF32Insts] in
5600b57cec5SDimitry Andricdefm V_MAC_LEGACY_F32 : VOP2Inst <"v_mac_legacy_f32", VOP_F32_F32_F32>;
5610b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX6GFX7GFX10
562*5ffd83dbSDimitry Andriclet SubtargetPredicate = isGFX6GFX7 in {
563*5ffd83dbSDimitry Andricdefm V_LSHR_B32 : VOP2Inst <"v_lshr_b32", VOP_PAT_GEN<VOP_I32_I32_I32>, srl>;
564*5ffd83dbSDimitry Andricdefm V_ASHR_I32 : VOP2Inst <"v_ashr_i32", VOP_PAT_GEN<VOP_I32_I32_I32>, sra>;
565*5ffd83dbSDimitry Andricdefm V_LSHL_B32 : VOP2Inst <"v_lshl_b32", VOP_PAT_GEN<VOP_I32_I32_I32>, shl>;
566*5ffd83dbSDimitry Andric} // End SubtargetPredicate = isGFX6GFX7
567*5ffd83dbSDimitry Andric} // End isCommutable = 1
568*5ffd83dbSDimitry Andric
5690b57cec5SDimitry Andric
5700b57cec5SDimitry Andricclass DivergentBinOp<SDPatternOperator Op, VOP_Pseudo Inst> :
5710b57cec5SDimitry Andric  GCNPat<
5720b57cec5SDimitry Andric      (getDivergentFrag<Op>.ret Inst.Pfl.Src0VT:$src0, Inst.Pfl.Src1VT:$src1),
5730b57cec5SDimitry Andric      !if(!cast<Commutable_REV>(Inst).IsOrig,
5740b57cec5SDimitry Andric        (Inst $src0, $src1),
5750b57cec5SDimitry Andric        (Inst $src1, $src0)
5760b57cec5SDimitry Andric      )
5770b57cec5SDimitry Andric  >;
5780b57cec5SDimitry Andric
5790b57cec5SDimitry Andricclass DivergentClampingBinOp<SDPatternOperator Op, VOP_Pseudo Inst> :
5800b57cec5SDimitry Andric  GCNPat<
5810b57cec5SDimitry Andric      (getDivergentFrag<Op>.ret Inst.Pfl.Src0VT:$src0, Inst.Pfl.Src1VT:$src1),
5820b57cec5SDimitry Andric      !if(!cast<Commutable_REV>(Inst).IsOrig,
5830b57cec5SDimitry Andric        (Inst $src0, $src1, 0),
5840b57cec5SDimitry Andric        (Inst $src1, $src0, 0)
5850b57cec5SDimitry Andric      )
5860b57cec5SDimitry Andric  >;
5870b57cec5SDimitry Andric
5880b57cec5SDimitry Andricdef : DivergentBinOp<srl, V_LSHRREV_B32_e64>;
5890b57cec5SDimitry Andricdef : DivergentBinOp<sra, V_ASHRREV_I32_e64>;
5900b57cec5SDimitry Andricdef : DivergentBinOp<shl, V_LSHLREV_B32_e64>;
5910b57cec5SDimitry Andric
5920b57cec5SDimitry Andriclet SubtargetPredicate = HasAddNoCarryInsts in {
5930b57cec5SDimitry Andric  def : DivergentClampingBinOp<add, V_ADD_U32_e64>;
5940b57cec5SDimitry Andric  def : DivergentClampingBinOp<sub, V_SUB_U32_e64>;
5950b57cec5SDimitry Andric}
5960b57cec5SDimitry Andric
5970b57cec5SDimitry Andriclet SubtargetPredicate = isGFX6GFX7GFX8GFX9, Predicates = [isGFX6GFX7GFX8GFX9] in {
5980b57cec5SDimitry Andricdef : DivergentClampingBinOp<add, V_ADD_I32_e64>;
5990b57cec5SDimitry Andricdef : DivergentClampingBinOp<sub, V_SUB_I32_e64>;
6000b57cec5SDimitry Andric}
6010b57cec5SDimitry Andric
6020b57cec5SDimitry Andricdef : DivergentBinOp<adde, V_ADDC_U32_e32>;
6030b57cec5SDimitry Andricdef : DivergentBinOp<sube, V_SUBB_U32_e32>;
6040b57cec5SDimitry Andric
6050b57cec5SDimitry Andricclass divergent_i64_BinOp <SDPatternOperator Op, Instruction Inst> :
6060b57cec5SDimitry Andric  GCNPat<
6070b57cec5SDimitry Andric      (getDivergentFrag<Op>.ret i64:$src0, i64:$src1),
6080b57cec5SDimitry Andric      (REG_SEQUENCE VReg_64,
6090b57cec5SDimitry Andric        (Inst
6100b57cec5SDimitry Andric          (i32 (EXTRACT_SUBREG $src0, sub0)),
6110b57cec5SDimitry Andric          (i32 (EXTRACT_SUBREG $src1, sub0))
6120b57cec5SDimitry Andric        ), sub0,
6130b57cec5SDimitry Andric        (Inst
6140b57cec5SDimitry Andric          (i32 (EXTRACT_SUBREG $src0, sub1)),
6150b57cec5SDimitry Andric          (i32 (EXTRACT_SUBREG $src1, sub1))
6160b57cec5SDimitry Andric        ), sub1
6170b57cec5SDimitry Andric      )
6180b57cec5SDimitry Andric  >;
6190b57cec5SDimitry Andric
6200b57cec5SDimitry Andricdef :  divergent_i64_BinOp <and, V_AND_B32_e32>;
6210b57cec5SDimitry Andricdef :  divergent_i64_BinOp <or,  V_OR_B32_e32>;
6220b57cec5SDimitry Andricdef :  divergent_i64_BinOp <xor, V_XOR_B32_e32>;
6230b57cec5SDimitry Andric
6240b57cec5SDimitry Andriclet SubtargetPredicate = Has16BitInsts in {
6250b57cec5SDimitry Andric
6260b57cec5SDimitry Andriclet FPDPRounding = 1 in {
6270b57cec5SDimitry Andricdef V_MADMK_F16 : VOP2_Pseudo <"v_madmk_f16", VOP_MADMK_F16, [], "">;
6280b57cec5SDimitry Andricdefm V_LDEXP_F16 : VOP2Inst <"v_ldexp_f16", VOP_F16_F16_I32, AMDGPUldexp>;
6290b57cec5SDimitry Andric} // End FPDPRounding = 1
6300b57cec5SDimitry Andric
6318bcb0991SDimitry Andricdefm V_LSHLREV_B16 : VOP2Inst <"v_lshlrev_b16", VOP_I16_I16_I16, lshl_rev>;
6328bcb0991SDimitry Andricdefm V_LSHRREV_B16 : VOP2Inst <"v_lshrrev_b16", VOP_I16_I16_I16, lshr_rev>;
6338bcb0991SDimitry Andricdefm V_ASHRREV_I16 : VOP2Inst <"v_ashrrev_i16", VOP_I16_I16_I16, ashr_rev>;
6340b57cec5SDimitry Andric
6350b57cec5SDimitry Andriclet isCommutable = 1 in {
6360b57cec5SDimitry Andriclet FPDPRounding = 1 in {
637*5ffd83dbSDimitry Andricdefm V_ADD_F16 : VOP2Inst <"v_add_f16", VOP_F16_F16_F16, any_fadd>;
6380b57cec5SDimitry Andricdefm V_SUB_F16 : VOP2Inst <"v_sub_f16", VOP_F16_F16_F16, fsub>;
6390b57cec5SDimitry Andricdefm V_SUBREV_F16 : VOP2Inst <"v_subrev_f16", VOP_F16_F16_F16, null_frag, "v_sub_f16">;
640*5ffd83dbSDimitry Andricdefm V_MUL_F16 : VOP2Inst <"v_mul_f16", VOP_F16_F16_F16, any_fmul>;
641*5ffd83dbSDimitry Andric
642*5ffd83dbSDimitry Andriclet mayRaiseFPException = 0 in {
6430b57cec5SDimitry Andricdef V_MADAK_F16 : VOP2_Pseudo <"v_madak_f16", VOP_MADAK_F16, [], "">;
644*5ffd83dbSDimitry Andric}
645*5ffd83dbSDimitry Andric
6460b57cec5SDimitry Andric} // End FPDPRounding = 1
647*5ffd83dbSDimitry Andricdefm V_ADD_U16 : VOP2Inst <"v_add_u16", VOP_I16_I16_I16_ARITH, add>;
648*5ffd83dbSDimitry Andricdefm V_SUB_U16 : VOP2Inst <"v_sub_u16" , VOP_I16_I16_I16_ARITH, sub>;
649*5ffd83dbSDimitry Andricdefm V_SUBREV_U16 : VOP2Inst <"v_subrev_u16", VOP_I16_I16_I16_ARITH, null_frag, "v_sub_u16">;
6508bcb0991SDimitry Andricdefm V_MUL_LO_U16 : VOP2Inst <"v_mul_lo_u16", VOP_I16_I16_I16, mul>;
6510b57cec5SDimitry Andricdefm V_MAX_F16 : VOP2Inst <"v_max_f16", VOP_F16_F16_F16, fmaxnum_like>;
6520b57cec5SDimitry Andricdefm V_MIN_F16 : VOP2Inst <"v_min_f16", VOP_F16_F16_F16, fminnum_like>;
6538bcb0991SDimitry Andricdefm V_MAX_U16 : VOP2Inst <"v_max_u16", VOP_I16_I16_I16, umax>;
6548bcb0991SDimitry Andricdefm V_MAX_I16 : VOP2Inst <"v_max_i16", VOP_I16_I16_I16, smax>;
6558bcb0991SDimitry Andricdefm V_MIN_U16 : VOP2Inst <"v_min_u16", VOP_I16_I16_I16, umin>;
6568bcb0991SDimitry Andricdefm V_MIN_I16 : VOP2Inst <"v_min_i16", VOP_I16_I16_I16, smin>;
6570b57cec5SDimitry Andric
6580b57cec5SDimitry Andriclet Constraints = "$vdst = $src2", DisableEncoding="$src2",
6590b57cec5SDimitry Andric    isConvertibleToThreeAddress = 1 in {
6600b57cec5SDimitry Andricdefm V_MAC_F16 : VOP2Inst <"v_mac_f16", VOP_MAC_F16>;
6610b57cec5SDimitry Andric}
6620b57cec5SDimitry Andric} // End isCommutable = 1
6630b57cec5SDimitry Andric
6640b57cec5SDimitry Andric} // End SubtargetPredicate = Has16BitInsts
6650b57cec5SDimitry Andric
6660b57cec5SDimitry Andriclet SubtargetPredicate = HasDLInsts in {
6670b57cec5SDimitry Andric
6680b57cec5SDimitry Andricdefm V_XNOR_B32 : VOP2Inst <"v_xnor_b32", VOP_I32_I32_I32>;
6690b57cec5SDimitry Andric
6700b57cec5SDimitry Andriclet Constraints = "$vdst = $src2",
6710b57cec5SDimitry Andric    DisableEncoding="$src2",
6720b57cec5SDimitry Andric    isConvertibleToThreeAddress = 1,
6730b57cec5SDimitry Andric    isCommutable = 1 in {
6740b57cec5SDimitry Andricdefm V_FMAC_F32 : VOP2Inst <"v_fmac_f32", VOP_MAC_F32>;
6750b57cec5SDimitry Andric}
6760b57cec5SDimitry Andric
6770b57cec5SDimitry Andric} // End SubtargetPredicate = HasDLInsts
6780b57cec5SDimitry Andric
6790b57cec5SDimitry Andriclet Constraints = "$vdst = $src2",
6800b57cec5SDimitry Andric      DisableEncoding="$src2",
6810b57cec5SDimitry Andric      isConvertibleToThreeAddress = 1,
6828bcb0991SDimitry Andric      isCommutable = 1,
6838bcb0991SDimitry Andric      IsDOT = 1 in {
6840b57cec5SDimitry Andric  let SubtargetPredicate = HasDot5Insts in
6858bcb0991SDimitry Andric    defm V_DOT2C_F32_F16 : VOP2Inst<"v_dot2c_f32_f16", VOP_DOT_ACC_F32_V2F16>;
6860b57cec5SDimitry Andric  let SubtargetPredicate = HasDot6Insts in
6878bcb0991SDimitry Andric    defm V_DOT4C_I32_I8  : VOP2Inst<"v_dot4c_i32_i8",  VOP_DOT_ACC_I32_I32>;
6880b57cec5SDimitry Andric
6890b57cec5SDimitry Andric  let SubtargetPredicate = HasDot4Insts in
6908bcb0991SDimitry Andric    defm V_DOT2C_I32_I16 : VOP2Inst<"v_dot2c_i32_i16", VOP_DOT_ACC_I32_I32>;
6910b57cec5SDimitry Andric  let SubtargetPredicate = HasDot3Insts in
6928bcb0991SDimitry Andric    defm V_DOT8C_I32_I4  : VOP2Inst<"v_dot8c_i32_i4",  VOP_DOT_ACC_I32_I32>;
6930b57cec5SDimitry Andric}
6940b57cec5SDimitry Andric
6950b57cec5SDimitry Andriclet AddedComplexity = 30 in {
6960b57cec5SDimitry Andric  def : GCNPat<
6970b57cec5SDimitry Andric    (f32 (AMDGPUfdot2 v2f16:$src0, v2f16:$src1, f32:$src2, (i1 DSTCLAMP.NONE))),
6980b57cec5SDimitry Andric    (f32 (V_DOT2C_F32_F16_e32 $src0, $src1, $src2))
6990b57cec5SDimitry Andric  > {
7000b57cec5SDimitry Andric    let SubtargetPredicate = HasDot5Insts;
7010b57cec5SDimitry Andric  }
7020b57cec5SDimitry Andric  def : GCNPat<
7030b57cec5SDimitry Andric    (i32 (int_amdgcn_sdot4 i32:$src0, i32:$src1, i32:$src2, (i1 DSTCLAMP.NONE))),
7040b57cec5SDimitry Andric    (i32 (V_DOT4C_I32_I8_e32 $src0, $src1, $src2))
7050b57cec5SDimitry Andric  > {
7060b57cec5SDimitry Andric    let SubtargetPredicate = HasDot6Insts;
7070b57cec5SDimitry Andric  }
7080b57cec5SDimitry Andric  def : GCNPat<
7090b57cec5SDimitry Andric    (i32 (int_amdgcn_sdot2 v2i16:$src0, v2i16:$src1, i32:$src2, (i1 DSTCLAMP.NONE))),
7100b57cec5SDimitry Andric    (i32 (V_DOT2C_I32_I16_e32 $src0, $src1, $src2))
7110b57cec5SDimitry Andric  > {
7120b57cec5SDimitry Andric    let SubtargetPredicate = HasDot4Insts;
7130b57cec5SDimitry Andric  }
7140b57cec5SDimitry Andric  def : GCNPat<
7150b57cec5SDimitry Andric    (i32 (int_amdgcn_sdot8 i32:$src0, i32:$src1, i32:$src2, (i1 DSTCLAMP.NONE))),
7160b57cec5SDimitry Andric    (i32 (V_DOT8C_I32_I4_e32 $src0, $src1, $src2))
7170b57cec5SDimitry Andric  > {
7180b57cec5SDimitry Andric    let SubtargetPredicate = HasDot3Insts;
7190b57cec5SDimitry Andric  }
7200b57cec5SDimitry Andric} // End AddedComplexity = 30
7210b57cec5SDimitry Andric
7220b57cec5SDimitry Andriclet SubtargetPredicate = isGFX10Plus in {
7230b57cec5SDimitry Andric
7240b57cec5SDimitry Andricdef V_FMAMK_F32 : VOP2_Pseudo<"v_fmamk_f32", VOP_MADMK_F32, [], "">;
7250b57cec5SDimitry Andriclet FPDPRounding = 1 in
7260b57cec5SDimitry Andricdef V_FMAMK_F16 : VOP2_Pseudo <"v_fmamk_f16", VOP_MADMK_F16, [], "">;
7270b57cec5SDimitry Andric
7280b57cec5SDimitry Andriclet isCommutable = 1 in {
7290b57cec5SDimitry Andricdef V_FMAAK_F32 : VOP2_Pseudo<"v_fmaak_f32", VOP_MADAK_F32, [], "">;
7300b57cec5SDimitry Andriclet FPDPRounding = 1 in
7310b57cec5SDimitry Andricdef V_FMAAK_F16 : VOP2_Pseudo <"v_fmaak_f16", VOP_MADAK_F16, [], "">;
7320b57cec5SDimitry Andric} // End isCommutable = 1
7330b57cec5SDimitry Andric
7340b57cec5SDimitry Andriclet Constraints = "$vdst = $src2",
7350b57cec5SDimitry Andric    DisableEncoding="$src2",
7360b57cec5SDimitry Andric    isConvertibleToThreeAddress = 1,
7370b57cec5SDimitry Andric    isCommutable = 1 in {
7380b57cec5SDimitry Andricdefm V_FMAC_F16 : VOP2Inst <"v_fmac_f16", VOP_MAC_F16>;
7390b57cec5SDimitry Andric}
7400b57cec5SDimitry Andric
7410b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX10Plus
7420b57cec5SDimitry Andric
7430b57cec5SDimitry Andriclet SubtargetPredicate = HasPkFmacF16Inst in {
7440b57cec5SDimitry Andricdefm V_PK_FMAC_F16 : VOP2Inst<"v_pk_fmac_f16", VOP_V2F16_V2F16_V2F16>;
7450b57cec5SDimitry Andric} // End SubtargetPredicate = HasPkFmacF16Inst
7460b57cec5SDimitry Andric
7470b57cec5SDimitry Andric// Note: 16-bit instructions produce a 0 result in the high 16-bits
7480b57cec5SDimitry Andric// on GFX8 and GFX9 and preserve high 16 bits on GFX10+
7498bcb0991SDimitry Andricmulticlass Arithmetic_i16_0Hi_Pats <SDPatternOperator op, Instruction inst> {
7500b57cec5SDimitry Andric
7510b57cec5SDimitry Andricdef : GCNPat<
7520b57cec5SDimitry Andric  (i32 (zext (op i16:$src0, i16:$src1))),
753480093f4SDimitry Andric  (inst VSrc_b16:$src0, VSrc_b16:$src1)
7540b57cec5SDimitry Andric>;
7550b57cec5SDimitry Andric
7560b57cec5SDimitry Andricdef : GCNPat<
7570b57cec5SDimitry Andric  (i64 (zext (op i16:$src0, i16:$src1))),
7580b57cec5SDimitry Andric   (REG_SEQUENCE VReg_64,
7598bcb0991SDimitry Andric     (inst $src0, $src1), sub0,
7600b57cec5SDimitry Andric     (V_MOV_B32_e32 (i32 0)), sub1)
7610b57cec5SDimitry Andric>;
7620b57cec5SDimitry Andric}
7630b57cec5SDimitry Andric
7640b57cec5SDimitry Andricclass ZExt_i16_i1_Pat <SDNode ext> : GCNPat <
7650b57cec5SDimitry Andric  (i16 (ext i1:$src)),
7660b57cec5SDimitry Andric  (V_CNDMASK_B32_e64 (i32 0/*src0mod*/), (i32 0/*src0*/),
7670b57cec5SDimitry Andric                     (i32 0/*src1mod*/), (i32 1/*src1*/),
7680b57cec5SDimitry Andric                     $src)
7690b57cec5SDimitry Andric>;
7700b57cec5SDimitry Andric
7718bcb0991SDimitry Andricforeach vt = [i16, v2i16] in {
7728bcb0991SDimitry Andricdef : GCNPat <
7738bcb0991SDimitry Andric  (and vt:$src0, vt:$src1),
7748bcb0991SDimitry Andric  (V_AND_B32_e64 VSrc_b32:$src0, VSrc_b32:$src1)
7758bcb0991SDimitry Andric>;
7768bcb0991SDimitry Andric
7778bcb0991SDimitry Andricdef : GCNPat <
7788bcb0991SDimitry Andric  (or vt:$src0, vt:$src1),
7798bcb0991SDimitry Andric  (V_OR_B32_e64 VSrc_b32:$src0, VSrc_b32:$src1)
7808bcb0991SDimitry Andric>;
7818bcb0991SDimitry Andric
7828bcb0991SDimitry Andricdef : GCNPat <
7838bcb0991SDimitry Andric  (xor vt:$src0, vt:$src1),
7848bcb0991SDimitry Andric  (V_XOR_B32_e64 VSrc_b32:$src0, VSrc_b32:$src1)
7858bcb0991SDimitry Andric>;
7868bcb0991SDimitry Andric}
7878bcb0991SDimitry Andric
7880b57cec5SDimitry Andriclet Predicates = [Has16BitInsts] in {
7890b57cec5SDimitry Andric
790480093f4SDimitry Andric// Undo sub x, c -> add x, -c canonicalization since c is more likely
791480093f4SDimitry Andric// an inline immediate than -c.
792480093f4SDimitry Andric// TODO: Also do for 64-bit.
793480093f4SDimitry Andricdef : GCNPat<
794*5ffd83dbSDimitry Andric  (add i16:$src0, (i16 NegSubInlineIntConst16:$src1)),
795*5ffd83dbSDimitry Andric  (V_SUB_U16_e64 VSrc_b16:$src0, NegSubInlineIntConst16:$src1)
796480093f4SDimitry Andric>;
797480093f4SDimitry Andric
798480093f4SDimitry Andric
7990b57cec5SDimitry Andriclet Predicates = [Has16BitInsts, isGFX7GFX8GFX9] in {
800480093f4SDimitry Andric
801480093f4SDimitry Andricdef : GCNPat<
802*5ffd83dbSDimitry Andric  (i32 (zext (add i16:$src0, (i16 NegSubInlineIntConst16:$src1)))),
803*5ffd83dbSDimitry Andric  (V_SUB_U16_e64 VSrc_b16:$src0, NegSubInlineIntConst16:$src1)
804480093f4SDimitry Andric>;
805480093f4SDimitry Andric
8068bcb0991SDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<add, V_ADD_U16_e64>;
8078bcb0991SDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<mul, V_MUL_LO_U16_e64>;
8088bcb0991SDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<sub, V_SUB_U16_e64>;
8098bcb0991SDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<smin, V_MIN_I16_e64>;
8108bcb0991SDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<smax, V_MAX_I16_e64>;
8118bcb0991SDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<umin, V_MIN_U16_e64>;
8128bcb0991SDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<umax, V_MAX_U16_e64>;
8138bcb0991SDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<lshl_rev, V_LSHLREV_B16_e64>;
8148bcb0991SDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<lshr_rev, V_LSHRREV_B16_e64>;
8158bcb0991SDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<ashr_rev, V_ASHRREV_I16_e64>;
816480093f4SDimitry Andric}  // End Predicates = [Has16BitInsts, isGFX7GFX8GFX9]
8170b57cec5SDimitry Andric
8180b57cec5SDimitry Andricdef : ZExt_i16_i1_Pat<zext>;
8190b57cec5SDimitry Andricdef : ZExt_i16_i1_Pat<anyext>;
8200b57cec5SDimitry Andric
8210b57cec5SDimitry Andricdef : GCNPat <
8220b57cec5SDimitry Andric  (i16 (sext i1:$src)),
8230b57cec5SDimitry Andric  (V_CNDMASK_B32_e64 /*src0mod*/(i32 0), /*src0*/(i32 0),
8240b57cec5SDimitry Andric                     /*src1mod*/(i32 0), /*src1*/(i32 -1), $src)
8250b57cec5SDimitry Andric>;
8260b57cec5SDimitry Andric
827480093f4SDimitry Andric} // End Predicates = [Has16BitInsts]
8280b57cec5SDimitry Andric
8290b57cec5SDimitry Andric
8300b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
8310b57cec5SDimitry Andric// Target-specific instruction encodings.
8320b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
8330b57cec5SDimitry Andric
8348bcb0991SDimitry Andricclass VOP2_DPP<bits<6> op, VOP2_DPP_Pseudo ps,
8350b57cec5SDimitry Andric               string opName = ps.OpName, VOPProfile p = ps.Pfl,
8360b57cec5SDimitry Andric               bit IsDPP16 = 0> :
8370b57cec5SDimitry Andric    VOP_DPP<opName, p, IsDPP16> {
8380b57cec5SDimitry Andric  let hasSideEffects = ps.hasSideEffects;
8390b57cec5SDimitry Andric  let Defs = ps.Defs;
8400b57cec5SDimitry Andric  let SchedRW = ps.SchedRW;
8410b57cec5SDimitry Andric  let Uses = ps.Uses;
8420b57cec5SDimitry Andric
8430b57cec5SDimitry Andric  bits<8> vdst;
8440b57cec5SDimitry Andric  bits<8> src1;
8450b57cec5SDimitry Andric  let Inst{8-0}   = 0xfa;
8460b57cec5SDimitry Andric  let Inst{16-9}  = !if(p.HasSrc1, src1{7-0}, 0);
8470b57cec5SDimitry Andric  let Inst{24-17} = !if(p.EmitDst, vdst{7-0}, 0);
8480b57cec5SDimitry Andric  let Inst{30-25} = op;
8490b57cec5SDimitry Andric  let Inst{31}    = 0x0;
8500b57cec5SDimitry Andric}
8510b57cec5SDimitry Andric
8528bcb0991SDimitry Andricclass Base_VOP2_DPP16<bits<6> op, VOP2_DPP_Pseudo ps,
8530b57cec5SDimitry Andric                 string opName = ps.OpName, VOPProfile p = ps.Pfl> :
8540b57cec5SDimitry Andric    VOP2_DPP<op, ps, opName, p, 1> {
855*5ffd83dbSDimitry Andric  let AssemblerPredicate = HasDPP16;
8560b57cec5SDimitry Andric  let SubtargetPredicate = HasDPP16;
8570b57cec5SDimitry Andric}
8580b57cec5SDimitry Andric
8598bcb0991SDimitry Andricclass VOP2_DPP16<bits<6> op, VOP2_DPP_Pseudo ps,
8608bcb0991SDimitry Andric                 string opName = ps.OpName, VOPProfile p = ps.Pfl> :
8618bcb0991SDimitry Andric    Base_VOP2_DPP16<op, ps, opName, p>,
8628bcb0991SDimitry Andric    SIMCInstr <ps.PseudoInstr, SIEncodingFamily.GFX10>;
8638bcb0991SDimitry Andric
8640b57cec5SDimitry Andricclass VOP2_DPP8<bits<6> op, VOP2_Pseudo ps,
8650b57cec5SDimitry Andric                string opName = ps.OpName, VOPProfile p = ps.Pfl> :
8660b57cec5SDimitry Andric    VOP_DPP8<ps.OpName, p> {
8670b57cec5SDimitry Andric  let hasSideEffects = ps.hasSideEffects;
8680b57cec5SDimitry Andric  let Defs = ps.Defs;
8690b57cec5SDimitry Andric  let SchedRW = ps.SchedRW;
8700b57cec5SDimitry Andric  let Uses = ps.Uses;
8710b57cec5SDimitry Andric
8720b57cec5SDimitry Andric  bits<8> vdst;
8730b57cec5SDimitry Andric  bits<8> src1;
8740b57cec5SDimitry Andric
8750b57cec5SDimitry Andric  let Inst{8-0}   = fi;
8760b57cec5SDimitry Andric  let Inst{16-9}  = !if(p.HasSrc1, src1{7-0}, 0);
8770b57cec5SDimitry Andric  let Inst{24-17} = !if(p.EmitDst, vdst{7-0}, 0);
8780b57cec5SDimitry Andric  let Inst{30-25} = op;
8790b57cec5SDimitry Andric  let Inst{31}    = 0x0;
8800b57cec5SDimitry Andric
881*5ffd83dbSDimitry Andric  let AssemblerPredicate = HasDPP8;
8820b57cec5SDimitry Andric  let SubtargetPredicate = HasDPP8;
8830b57cec5SDimitry Andric}
8840b57cec5SDimitry Andric
8850b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
8860b57cec5SDimitry Andric// GFX10.
8870b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
8880b57cec5SDimitry Andric
8890b57cec5SDimitry Andriclet AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10" in {
8900b57cec5SDimitry Andric  //===------------------------------- VOP2 -------------------------------===//
8910b57cec5SDimitry Andric  multiclass VOP2Only_Real_MADK_gfx10<bits<6> op> {
8920b57cec5SDimitry Andric    def _gfx10 :
8930b57cec5SDimitry Andric      VOP2_Real<!cast<VOP2_Pseudo>(NAME), SIEncodingFamily.GFX10>,
8940b57cec5SDimitry Andric      VOP2_MADKe<op{5-0}, !cast<VOP2_Pseudo>(NAME).Pfl>;
8950b57cec5SDimitry Andric  }
8960b57cec5SDimitry Andric  multiclass VOP2Only_Real_MADK_gfx10_with_name<bits<6> op, string opName,
8970b57cec5SDimitry Andric                                                string asmName> {
8980b57cec5SDimitry Andric    def _gfx10 :
8990b57cec5SDimitry Andric        VOP2_Real<!cast<VOP2_Pseudo>(opName), SIEncodingFamily.GFX10>,
9000b57cec5SDimitry Andric        VOP2_MADKe<op{5-0}, !cast<VOP2_Pseudo>(opName).Pfl> {
9010b57cec5SDimitry Andric      VOP2_Pseudo ps = !cast<VOP2_Pseudo>(opName);
9020b57cec5SDimitry Andric      let AsmString = asmName # ps.AsmOperands;
9030b57cec5SDimitry Andric    }
9040b57cec5SDimitry Andric  }
9050b57cec5SDimitry Andric  multiclass VOP2_Real_e32_gfx10<bits<6> op> {
9060b57cec5SDimitry Andric    def _e32_gfx10 :
9070b57cec5SDimitry Andric      VOP2_Real<!cast<VOP2_Pseudo>(NAME#"_e32"), SIEncodingFamily.GFX10>,
9080b57cec5SDimitry Andric      VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME#"_e32").Pfl>;
9090b57cec5SDimitry Andric  }
9100b57cec5SDimitry Andric  multiclass VOP2_Real_e64_gfx10<bits<6> op> {
9110b57cec5SDimitry Andric    def _e64_gfx10 :
9120b57cec5SDimitry Andric      VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX10>,
9130b57cec5SDimitry Andric      VOP3e_gfx10<{0, 1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
9140b57cec5SDimitry Andric  }
9150b57cec5SDimitry Andric  multiclass VOP2_Real_sdwa_gfx10<bits<6> op> {
9168bcb0991SDimitry Andric    foreach _ = BoolToList<!cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA9>.ret in
9170b57cec5SDimitry Andric    def _sdwa_gfx10 :
9180b57cec5SDimitry Andric      VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa")>,
9190b57cec5SDimitry Andric      VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa").Pfl> {
9200b57cec5SDimitry Andric      let DecoderNamespace = "SDWA10";
9210b57cec5SDimitry Andric    }
9220b57cec5SDimitry Andric  }
9230b57cec5SDimitry Andric  multiclass VOP2_Real_dpp_gfx10<bits<6> op> {
9248bcb0991SDimitry Andric    foreach _ = BoolToList<!cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtDPP>.ret in
9258bcb0991SDimitry Andric    def _dpp_gfx10 : VOP2_DPP16<op, !cast<VOP2_DPP_Pseudo>(NAME#"_dpp")> {
9260b57cec5SDimitry Andric      let DecoderNamespace = "SDWA10";
9270b57cec5SDimitry Andric    }
9280b57cec5SDimitry Andric  }
9290b57cec5SDimitry Andric  multiclass VOP2_Real_dpp8_gfx10<bits<6> op> {
9308bcb0991SDimitry Andric    foreach _ = BoolToList<!cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtDPP>.ret in
9310b57cec5SDimitry Andric    def _dpp8_gfx10 : VOP2_DPP8<op, !cast<VOP2_Pseudo>(NAME#"_e32")> {
9320b57cec5SDimitry Andric      let DecoderNamespace = "DPP8";
9330b57cec5SDimitry Andric    }
9340b57cec5SDimitry Andric  }
9350b57cec5SDimitry Andric
9360b57cec5SDimitry Andric  //===------------------------- VOP2 (with name) -------------------------===//
9370b57cec5SDimitry Andric  multiclass VOP2_Real_e32_gfx10_with_name<bits<6> op, string opName,
9380b57cec5SDimitry Andric                                           string asmName> {
9390b57cec5SDimitry Andric    def _e32_gfx10 :
9400b57cec5SDimitry Andric      VOP2_Real<!cast<VOP2_Pseudo>(opName#"_e32"), SIEncodingFamily.GFX10>,
9410b57cec5SDimitry Andric      VOP2e<op{5-0}, !cast<VOP2_Pseudo>(opName#"_e32").Pfl> {
9420b57cec5SDimitry Andric        VOP2_Pseudo ps = !cast<VOP2_Pseudo>(opName#"_e32");
9430b57cec5SDimitry Andric        let AsmString = asmName # ps.AsmOperands;
9440b57cec5SDimitry Andric      }
9450b57cec5SDimitry Andric  }
9460b57cec5SDimitry Andric  multiclass VOP2_Real_e64_gfx10_with_name<bits<6> op, string opName,
9470b57cec5SDimitry Andric                                           string asmName> {
9480b57cec5SDimitry Andric    def _e64_gfx10 :
9490b57cec5SDimitry Andric      VOP3_Real<!cast<VOP3_Pseudo>(opName#"_e64"), SIEncodingFamily.GFX10>,
9500b57cec5SDimitry Andric      VOP3e_gfx10<{0, 1, 0, 0, op{5-0}},
9510b57cec5SDimitry Andric                  !cast<VOP3_Pseudo>(opName#"_e64").Pfl> {
9520b57cec5SDimitry Andric        VOP3_Pseudo ps = !cast<VOP3_Pseudo>(opName#"_e64");
9530b57cec5SDimitry Andric        let AsmString = asmName # ps.AsmOperands;
9540b57cec5SDimitry Andric      }
9550b57cec5SDimitry Andric  }
9560b57cec5SDimitry Andric  let DecoderNamespace = "SDWA10" in {
9570b57cec5SDimitry Andric    multiclass VOP2_Real_sdwa_gfx10_with_name<bits<6> op, string opName,
9580b57cec5SDimitry Andric                                              string asmName> {
9598bcb0991SDimitry Andric      foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtSDWA9>.ret in
9600b57cec5SDimitry Andric      def _sdwa_gfx10 :
9610b57cec5SDimitry Andric        VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(opName#"_sdwa")>,
9620b57cec5SDimitry Andric        VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa").Pfl> {
9630b57cec5SDimitry Andric          VOP2_SDWA_Pseudo ps = !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa");
9640b57cec5SDimitry Andric          let AsmString = asmName # ps.AsmOperands;
9650b57cec5SDimitry Andric        }
9660b57cec5SDimitry Andric    }
9670b57cec5SDimitry Andric    multiclass VOP2_Real_dpp_gfx10_with_name<bits<6> op, string opName,
9680b57cec5SDimitry Andric                                             string asmName> {
9698bcb0991SDimitry Andric      foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP>.ret in
9708bcb0991SDimitry Andric      def _dpp_gfx10 : VOP2_DPP16<op, !cast<VOP2_DPP_Pseudo>(opName#"_dpp")> {
9710b57cec5SDimitry Andric        VOP2_Pseudo ps = !cast<VOP2_Pseudo>(opName#"_e32");
9720b57cec5SDimitry Andric        let AsmString = asmName # ps.Pfl.AsmDPP16;
9730b57cec5SDimitry Andric      }
9740b57cec5SDimitry Andric    }
9750b57cec5SDimitry Andric    multiclass VOP2_Real_dpp8_gfx10_with_name<bits<6> op, string opName,
9760b57cec5SDimitry Andric                                              string asmName> {
9778bcb0991SDimitry Andric      foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP>.ret in
9780b57cec5SDimitry Andric      def _dpp8_gfx10 : VOP2_DPP8<op, !cast<VOP2_Pseudo>(opName#"_e32")> {
9790b57cec5SDimitry Andric        VOP2_Pseudo ps = !cast<VOP2_Pseudo>(opName#"_e32");
9800b57cec5SDimitry Andric        let AsmString = asmName # ps.Pfl.AsmDPP8;
9810b57cec5SDimitry Andric        let DecoderNamespace = "DPP8";
9820b57cec5SDimitry Andric      }
9830b57cec5SDimitry Andric    }
9840b57cec5SDimitry Andric  } // End DecoderNamespace = "SDWA10"
9850b57cec5SDimitry Andric
9860b57cec5SDimitry Andric  //===------------------------------ VOP2be ------------------------------===//
9878bcb0991SDimitry Andric  multiclass VOP2be_Real_e32_gfx10<bits<6> op, string opName, string asmName> {
9880b57cec5SDimitry Andric    def _e32_gfx10 :
9890b57cec5SDimitry Andric      VOP2_Real<!cast<VOP2_Pseudo>(opName#"_e32"), SIEncodingFamily.GFX10>,
9900b57cec5SDimitry Andric      VOP2e<op{5-0}, !cast<VOP2_Pseudo>(opName#"_e32").Pfl> {
9910b57cec5SDimitry Andric        VOP2_Pseudo Ps = !cast<VOP2_Pseudo>(opName#"_e32");
9920b57cec5SDimitry Andric        let AsmString = asmName # !subst(", vcc", "", Ps.AsmOperands);
9930b57cec5SDimitry Andric      }
9948bcb0991SDimitry Andric  }
9958bcb0991SDimitry Andric  multiclass VOP2be_Real_e64_gfx10<bits<6> op, string opName, string asmName> {
9960b57cec5SDimitry Andric    def _e64_gfx10 :
9970b57cec5SDimitry Andric      VOP3_Real<!cast<VOP3_Pseudo>(opName#"_e64"), SIEncodingFamily.GFX10>,
9980b57cec5SDimitry Andric      VOP3be_gfx10<{0, 1, 0, 0, op{5-0}},
9990b57cec5SDimitry Andric                   !cast<VOP3_Pseudo>(opName#"_e64").Pfl> {
10000b57cec5SDimitry Andric        VOP3_Pseudo Ps = !cast<VOP3_Pseudo>(opName#"_e64");
10010b57cec5SDimitry Andric        let AsmString = asmName # Ps.AsmOperands;
10020b57cec5SDimitry Andric      }
10038bcb0991SDimitry Andric  }
10048bcb0991SDimitry Andric  multiclass VOP2be_Real_sdwa_gfx10<bits<6> op, string opName, string asmName> {
10058bcb0991SDimitry Andric    foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtSDWA9>.ret in
10060b57cec5SDimitry Andric    def _sdwa_gfx10 :
10070b57cec5SDimitry Andric      VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(opName#"_sdwa")>,
10080b57cec5SDimitry Andric      VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa").Pfl> {
10090b57cec5SDimitry Andric        VOP2_SDWA_Pseudo Ps = !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa");
10100b57cec5SDimitry Andric        let AsmString = asmName # !subst(", vcc", "", Ps.AsmOperands);
10110b57cec5SDimitry Andric        let DecoderNamespace = "SDWA10";
10120b57cec5SDimitry Andric      }
10138bcb0991SDimitry Andric    foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtSDWA9>.ret in
10140b57cec5SDimitry Andric    def _sdwa_w32_gfx10 :
10150b57cec5SDimitry Andric      Base_VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(opName#"_sdwa")>,
10160b57cec5SDimitry Andric      VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa").Pfl> {
10170b57cec5SDimitry Andric        VOP2_SDWA_Pseudo Ps = !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa");
10180b57cec5SDimitry Andric        let AsmString = asmName # !subst("vcc", "vcc_lo", Ps.AsmOperands);
10190b57cec5SDimitry Andric        let isAsmParserOnly = 1;
10200b57cec5SDimitry Andric        let DecoderNamespace = "SDWA10";
10218bcb0991SDimitry Andric        let WaveSizePredicate = isWave32;
10220b57cec5SDimitry Andric      }
10238bcb0991SDimitry Andric    foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtSDWA9>.ret in
10240b57cec5SDimitry Andric    def _sdwa_w64_gfx10 :
10250b57cec5SDimitry Andric      Base_VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(opName#"_sdwa")>,
10260b57cec5SDimitry Andric      VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa").Pfl> {
10270b57cec5SDimitry Andric        VOP2_SDWA_Pseudo Ps = !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa");
10280b57cec5SDimitry Andric        let AsmString = asmName # Ps.AsmOperands;
10290b57cec5SDimitry Andric        let isAsmParserOnly = 1;
10300b57cec5SDimitry Andric        let DecoderNamespace = "SDWA10";
10318bcb0991SDimitry Andric        let WaveSizePredicate = isWave64;
10320b57cec5SDimitry Andric      }
10338bcb0991SDimitry Andric  }
10348bcb0991SDimitry Andric  multiclass VOP2be_Real_dpp_gfx10<bits<6> op, string opName, string asmName> {
10358bcb0991SDimitry Andric    foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP>.ret in
10368bcb0991SDimitry Andric    def _dpp_gfx10 :
10378bcb0991SDimitry Andric      VOP2_DPP16<op, !cast<VOP2_DPP_Pseudo>(opName#"_dpp"), asmName> {
10388bcb0991SDimitry Andric        string AsmDPP = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP16;
10398bcb0991SDimitry Andric        let AsmString = asmName # !subst(", vcc", "", AsmDPP);
10408bcb0991SDimitry Andric        let DecoderNamespace = "SDWA10";
10418bcb0991SDimitry Andric      }
10428bcb0991SDimitry Andric    foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP>.ret in
10438bcb0991SDimitry Andric    def _dpp_w32_gfx10 :
10448bcb0991SDimitry Andric      Base_VOP2_DPP16<op, !cast<VOP2_DPP_Pseudo>(opName#"_dpp"), asmName> {
10458bcb0991SDimitry Andric        string AsmDPP = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP16;
10468bcb0991SDimitry Andric        let AsmString = asmName # !subst("vcc", "vcc_lo", AsmDPP);
10478bcb0991SDimitry Andric        let isAsmParserOnly = 1;
10488bcb0991SDimitry Andric        let WaveSizePredicate = isWave32;
10498bcb0991SDimitry Andric      }
10508bcb0991SDimitry Andric    foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP>.ret in
10510b57cec5SDimitry Andric    def _dpp_w64_gfx10 :
10528bcb0991SDimitry Andric      Base_VOP2_DPP16<op, !cast<VOP2_DPP_Pseudo>(opName#"_dpp"), asmName> {
10530b57cec5SDimitry Andric        string AsmDPP = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP16;
10540b57cec5SDimitry Andric        let AsmString = asmName # AsmDPP;
10550b57cec5SDimitry Andric        let isAsmParserOnly = 1;
10568bcb0991SDimitry Andric        let WaveSizePredicate = isWave64;
10570b57cec5SDimitry Andric      }
10588bcb0991SDimitry Andric  }
10598bcb0991SDimitry Andric  multiclass VOP2be_Real_dpp8_gfx10<bits<6> op, string opName, string asmName> {
10608bcb0991SDimitry Andric    foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP>.ret in
10618bcb0991SDimitry Andric    def _dpp8_gfx10 :
10628bcb0991SDimitry Andric      VOP2_DPP8<op, !cast<VOP2_Pseudo>(opName#"_e32"), asmName> {
10638bcb0991SDimitry Andric        string AsmDPP8 = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP8;
10648bcb0991SDimitry Andric        let AsmString = asmName # !subst(", vcc", "", AsmDPP8);
10658bcb0991SDimitry Andric        let DecoderNamespace = "DPP8";
10668bcb0991SDimitry Andric      }
10678bcb0991SDimitry Andric    foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP>.ret in
10688bcb0991SDimitry Andric    def _dpp8_w32_gfx10 :
10698bcb0991SDimitry Andric      VOP2_DPP8<op, !cast<VOP2_Pseudo>(opName#"_e32"), asmName> {
10708bcb0991SDimitry Andric        string AsmDPP8 = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP8;
10718bcb0991SDimitry Andric        let AsmString = asmName # !subst("vcc", "vcc_lo", AsmDPP8);
10728bcb0991SDimitry Andric        let isAsmParserOnly = 1;
10738bcb0991SDimitry Andric        let WaveSizePredicate = isWave32;
10748bcb0991SDimitry Andric      }
10758bcb0991SDimitry Andric    foreach _ = BoolToList<!cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP>.ret in
10760b57cec5SDimitry Andric    def _dpp8_w64_gfx10 :
10770b57cec5SDimitry Andric      VOP2_DPP8<op, !cast<VOP2_Pseudo>(opName#"_e32"), asmName> {
10780b57cec5SDimitry Andric        string AsmDPP8 = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP8;
10790b57cec5SDimitry Andric        let AsmString = asmName # AsmDPP8;
10800b57cec5SDimitry Andric        let isAsmParserOnly = 1;
10818bcb0991SDimitry Andric        let WaveSizePredicate = isWave64;
10820b57cec5SDimitry Andric      }
10830b57cec5SDimitry Andric  }
10840b57cec5SDimitry Andric
10850b57cec5SDimitry Andric  //===----------------------------- VOP3Only -----------------------------===//
10860b57cec5SDimitry Andric  multiclass VOP3Only_Real_gfx10<bits<10> op> {
10870b57cec5SDimitry Andric    def _e64_gfx10 :
10880b57cec5SDimitry Andric      VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX10>,
10890b57cec5SDimitry Andric      VOP3e_gfx10<op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
10900b57cec5SDimitry Andric  }
10910b57cec5SDimitry Andric
10920b57cec5SDimitry Andric  //===---------------------------- VOP3beOnly ----------------------------===//
10930b57cec5SDimitry Andric  multiclass VOP3beOnly_Real_gfx10<bits<10> op, string opName, string asmName> {
10940b57cec5SDimitry Andric    def _e64_gfx10 :
10950b57cec5SDimitry Andric      VOP3_Real<!cast<VOP3_Pseudo>(opName#"_e64"), SIEncodingFamily.GFX10>,
10960b57cec5SDimitry Andric      VOP3be_gfx10<op, !cast<VOP3_Pseudo>(opName#"_e64").Pfl> {
10970b57cec5SDimitry Andric        VOP3_Pseudo Ps = !cast<VOP3_Pseudo>(opName#"_e64");
10980b57cec5SDimitry Andric        let AsmString = asmName # Ps.AsmOperands;
10990b57cec5SDimitry Andric      }
11000b57cec5SDimitry Andric  }
11010b57cec5SDimitry Andric} // End AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10"
11020b57cec5SDimitry Andric
11038bcb0991SDimitry Andricmulticlass VOP2be_Real_gfx10<bits<6> op, string opName, string asmName> :
11048bcb0991SDimitry Andric  VOP2be_Real_e32_gfx10<op, opName, asmName>,
11058bcb0991SDimitry Andric  VOP2be_Real_e64_gfx10<op, opName, asmName>,
11068bcb0991SDimitry Andric  VOP2be_Real_sdwa_gfx10<op, opName, asmName>,
11078bcb0991SDimitry Andric  VOP2be_Real_dpp_gfx10<op, opName, asmName>,
11088bcb0991SDimitry Andric  VOP2be_Real_dpp8_gfx10<op, opName, asmName>;
11098bcb0991SDimitry Andric
11108bcb0991SDimitry Andricmulticlass VOP2e_Real_gfx10<bits<6> op, string opName, string asmName> :
11118bcb0991SDimitry Andric  VOP2_Real_e32_gfx10<op>,
11128bcb0991SDimitry Andric  VOP2_Real_e64_gfx10<op>,
11138bcb0991SDimitry Andric  VOP2be_Real_sdwa_gfx10<op, opName, asmName>,
11148bcb0991SDimitry Andric  VOP2be_Real_dpp_gfx10<op, opName, asmName>,
11158bcb0991SDimitry Andric  VOP2be_Real_dpp8_gfx10<op, opName, asmName>;
11160b57cec5SDimitry Andric
11170b57cec5SDimitry Andricmulticlass VOP2_Real_gfx10<bits<6> op> :
11180b57cec5SDimitry Andric  VOP2_Real_e32_gfx10<op>, VOP2_Real_e64_gfx10<op>,
11190b57cec5SDimitry Andric  VOP2_Real_sdwa_gfx10<op>, VOP2_Real_dpp_gfx10<op>, VOP2_Real_dpp8_gfx10<op>;
11200b57cec5SDimitry Andric
11210b57cec5SDimitry Andricmulticlass VOP2_Real_gfx10_with_name<bits<6> op, string opName,
11220b57cec5SDimitry Andric                                     string asmName> :
11230b57cec5SDimitry Andric  VOP2_Real_e32_gfx10_with_name<op, opName, asmName>,
11240b57cec5SDimitry Andric  VOP2_Real_e64_gfx10_with_name<op, opName, asmName>,
11250b57cec5SDimitry Andric  VOP2_Real_sdwa_gfx10_with_name<op, opName, asmName>,
11260b57cec5SDimitry Andric  VOP2_Real_dpp_gfx10_with_name<op, opName, asmName>,
11270b57cec5SDimitry Andric  VOP2_Real_dpp8_gfx10_with_name<op, opName, asmName>;
11280b57cec5SDimitry Andric
11290b57cec5SDimitry Andricdefm V_XNOR_B32      : VOP2_Real_gfx10<0x01e>;
11300b57cec5SDimitry Andricdefm V_FMAC_F32      : VOP2_Real_gfx10<0x02b>;
11310b57cec5SDimitry Andricdefm V_FMAMK_F32     : VOP2Only_Real_MADK_gfx10<0x02c>;
11320b57cec5SDimitry Andricdefm V_FMAAK_F32     : VOP2Only_Real_MADK_gfx10<0x02d>;
11330b57cec5SDimitry Andricdefm V_ADD_F16       : VOP2_Real_gfx10<0x032>;
11340b57cec5SDimitry Andricdefm V_SUB_F16       : VOP2_Real_gfx10<0x033>;
11350b57cec5SDimitry Andricdefm V_SUBREV_F16    : VOP2_Real_gfx10<0x034>;
11360b57cec5SDimitry Andricdefm V_MUL_F16       : VOP2_Real_gfx10<0x035>;
11370b57cec5SDimitry Andricdefm V_FMAC_F16      : VOP2_Real_gfx10<0x036>;
11380b57cec5SDimitry Andricdefm V_FMAMK_F16     : VOP2Only_Real_MADK_gfx10<0x037>;
11390b57cec5SDimitry Andricdefm V_FMAAK_F16     : VOP2Only_Real_MADK_gfx10<0x038>;
11400b57cec5SDimitry Andricdefm V_MAX_F16       : VOP2_Real_gfx10<0x039>;
11410b57cec5SDimitry Andricdefm V_MIN_F16       : VOP2_Real_gfx10<0x03a>;
11420b57cec5SDimitry Andricdefm V_LDEXP_F16     : VOP2_Real_gfx10<0x03b>;
11430b57cec5SDimitry Andricdefm V_PK_FMAC_F16   : VOP2_Real_e32_gfx10<0x03c>;
11440b57cec5SDimitry Andric
11450b57cec5SDimitry Andric// VOP2 no carry-in, carry-out.
11460b57cec5SDimitry Andricdefm V_ADD_NC_U32 :
11470b57cec5SDimitry Andric  VOP2_Real_gfx10_with_name<0x025, "V_ADD_U32", "v_add_nc_u32">;
11480b57cec5SDimitry Andricdefm V_SUB_NC_U32 :
11490b57cec5SDimitry Andric  VOP2_Real_gfx10_with_name<0x026, "V_SUB_U32", "v_sub_nc_u32">;
11500b57cec5SDimitry Andricdefm V_SUBREV_NC_U32 :
11510b57cec5SDimitry Andric  VOP2_Real_gfx10_with_name<0x027, "V_SUBREV_U32", "v_subrev_nc_u32">;
11520b57cec5SDimitry Andric
11530b57cec5SDimitry Andric// VOP2 carry-in, carry-out.
11540b57cec5SDimitry Andricdefm V_ADD_CO_CI_U32 :
11550b57cec5SDimitry Andric  VOP2be_Real_gfx10<0x028, "V_ADDC_U32", "v_add_co_ci_u32">;
11560b57cec5SDimitry Andricdefm V_SUB_CO_CI_U32 :
11570b57cec5SDimitry Andric  VOP2be_Real_gfx10<0x029, "V_SUBB_U32", "v_sub_co_ci_u32">;
11580b57cec5SDimitry Andricdefm V_SUBREV_CO_CI_U32 :
11590b57cec5SDimitry Andric  VOP2be_Real_gfx10<0x02a, "V_SUBBREV_U32", "v_subrev_co_ci_u32">;
11600b57cec5SDimitry Andric
11618bcb0991SDimitry Andricdefm V_CNDMASK_B32 :
11628bcb0991SDimitry Andric  VOP2e_Real_gfx10<0x001, "V_CNDMASK_B32", "v_cndmask_b32">;
11638bcb0991SDimitry Andric
11640b57cec5SDimitry Andric// VOP3 only.
11650b57cec5SDimitry Andricdefm V_BFM_B32            : VOP3Only_Real_gfx10<0x363>;
11660b57cec5SDimitry Andricdefm V_BCNT_U32_B32       : VOP3Only_Real_gfx10<0x364>;
11670b57cec5SDimitry Andricdefm V_MBCNT_LO_U32_B32   : VOP3Only_Real_gfx10<0x365>;
11680b57cec5SDimitry Andricdefm V_MBCNT_HI_U32_B32   : VOP3Only_Real_gfx10<0x366>;
11690b57cec5SDimitry Andricdefm V_LDEXP_F32          : VOP3Only_Real_gfx10<0x362>;
11700b57cec5SDimitry Andricdefm V_CVT_PKNORM_I16_F32 : VOP3Only_Real_gfx10<0x368>;
11710b57cec5SDimitry Andricdefm V_CVT_PKNORM_U16_F32 : VOP3Only_Real_gfx10<0x369>;
11720b57cec5SDimitry Andricdefm V_CVT_PK_U16_U32     : VOP3Only_Real_gfx10<0x36a>;
11730b57cec5SDimitry Andricdefm V_CVT_PK_I16_I32     : VOP3Only_Real_gfx10<0x36b>;
11740b57cec5SDimitry Andric
11750b57cec5SDimitry Andric// VOP3 carry-in, carry-out.
11760b57cec5SDimitry Andricdefm V_ADD_CO_U32 :
11770b57cec5SDimitry Andric  VOP3beOnly_Real_gfx10<0x30f, "V_ADD_I32", "v_add_co_u32">;
11780b57cec5SDimitry Andricdefm V_SUB_CO_U32 :
11790b57cec5SDimitry Andric  VOP3beOnly_Real_gfx10<0x310, "V_SUB_I32", "v_sub_co_u32">;
11800b57cec5SDimitry Andricdefm V_SUBREV_CO_U32 :
11810b57cec5SDimitry Andric  VOP3beOnly_Real_gfx10<0x319, "V_SUBREV_I32", "v_subrev_co_u32">;
11820b57cec5SDimitry Andric
11830b57cec5SDimitry Andriclet SubtargetPredicate = isGFX10Plus in {
11840b57cec5SDimitry Andric  defm : VOP2eInstAliases<V_CNDMASK_B32_e32, V_CNDMASK_B32_e32_gfx10>;
11850b57cec5SDimitry Andric
11860b57cec5SDimitry Andric  defm : VOP2bInstAliases<
11870b57cec5SDimitry Andric    V_ADDC_U32_e32, V_ADD_CO_CI_U32_e32_gfx10, "v_add_co_ci_u32">;
11880b57cec5SDimitry Andric  defm : VOP2bInstAliases<
11890b57cec5SDimitry Andric    V_SUBB_U32_e32, V_SUB_CO_CI_U32_e32_gfx10, "v_sub_co_ci_u32">;
11900b57cec5SDimitry Andric  defm : VOP2bInstAliases<
11910b57cec5SDimitry Andric    V_SUBBREV_U32_e32, V_SUBREV_CO_CI_U32_e32_gfx10, "v_subrev_co_ci_u32">;
11920b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX10Plus
11930b57cec5SDimitry Andric
11940b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
11950b57cec5SDimitry Andric// GFX6, GFX7, GFX10.
11960b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
11970b57cec5SDimitry Andric
11980b57cec5SDimitry Andricclass VOP2_DPPe <bits<6> op, VOP2_DPP_Pseudo ps, VOPProfile P = ps.Pfl> :
11990b57cec5SDimitry Andric  VOP_DPPe <P> {
12000b57cec5SDimitry Andric  bits<8> vdst;
12010b57cec5SDimitry Andric  bits<8> src1;
12020b57cec5SDimitry Andric  let Inst{8-0}   = 0xfa; //dpp
12030b57cec5SDimitry Andric  let Inst{16-9}  = !if(P.HasSrc1, src1{7-0}, 0);
12040b57cec5SDimitry Andric  let Inst{24-17} = !if(P.EmitDst, vdst{7-0}, 0);
12050b57cec5SDimitry Andric  let Inst{30-25} = op;
12060b57cec5SDimitry Andric  let Inst{31}    = 0x0; //encoding
12070b57cec5SDimitry Andric}
12080b57cec5SDimitry Andric
12090b57cec5SDimitry Andriclet AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" in {
12100b57cec5SDimitry Andric  multiclass VOP2Only_Real_gfx6_gfx7<bits<6> op> {
12110b57cec5SDimitry Andric    def _gfx6_gfx7 :
12120b57cec5SDimitry Andric      VOP2_Real<!cast<VOP2_Pseudo>(NAME), SIEncodingFamily.SI>,
12130b57cec5SDimitry Andric      VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME).Pfl>;
12140b57cec5SDimitry Andric  }
12150b57cec5SDimitry Andric  multiclass VOP2Only_Real_MADK_gfx6_gfx7<bits<6> op> {
12160b57cec5SDimitry Andric    def _gfx6_gfx7 :
12170b57cec5SDimitry Andric      VOP2_Real<!cast<VOP2_Pseudo>(NAME), SIEncodingFamily.SI>,
12180b57cec5SDimitry Andric      VOP2_MADKe<op{5-0}, !cast<VOP2_Pseudo>(NAME).Pfl>;
12190b57cec5SDimitry Andric  }
12200b57cec5SDimitry Andric  multiclass VOP2_Real_e32_gfx6_gfx7<bits<6> op> {
12210b57cec5SDimitry Andric    def _e32_gfx6_gfx7 :
12220b57cec5SDimitry Andric      VOP2_Real<!cast<VOP2_Pseudo>(NAME#"_e32"), SIEncodingFamily.SI>,
12230b57cec5SDimitry Andric      VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME#"_e32").Pfl>;
12240b57cec5SDimitry Andric  }
12250b57cec5SDimitry Andric  multiclass VOP2_Real_e64_gfx6_gfx7<bits<6> op> {
12260b57cec5SDimitry Andric    def _e64_gfx6_gfx7 :
12270b57cec5SDimitry Andric      VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.SI>,
12280b57cec5SDimitry Andric      VOP3e_gfx6_gfx7<{1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
12290b57cec5SDimitry Andric  }
12300b57cec5SDimitry Andric  multiclass VOP2be_Real_e64_gfx6_gfx7<bits<6> op> {
12310b57cec5SDimitry Andric    def _e64_gfx6_gfx7 :
12320b57cec5SDimitry Andric      VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.SI>,
12330b57cec5SDimitry Andric      VOP3be_gfx6_gfx7<{1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
12340b57cec5SDimitry Andric  }
12350b57cec5SDimitry Andric} // End AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7"
12360b57cec5SDimitry Andric
12370b57cec5SDimitry Andricmulticlass VOP2Only_Real_MADK_gfx6_gfx7_gfx10<bits<6> op> :
12380b57cec5SDimitry Andric  VOP2Only_Real_MADK_gfx6_gfx7<op>, VOP2Only_Real_MADK_gfx10<op>;
12390b57cec5SDimitry Andric
12400b57cec5SDimitry Andricmulticlass VOP2_Real_gfx6_gfx7<bits<6> op> :
12410b57cec5SDimitry Andric  VOP2_Real_e32_gfx6_gfx7<op>, VOP2_Real_e64_gfx6_gfx7<op>;
12420b57cec5SDimitry Andric
12430b57cec5SDimitry Andricmulticlass VOP2_Real_gfx6_gfx7_gfx10<bits<6> op> :
12440b57cec5SDimitry Andric  VOP2_Real_gfx6_gfx7<op>, VOP2_Real_gfx10<op>;
12450b57cec5SDimitry Andric
12460b57cec5SDimitry Andricmulticlass VOP2be_Real_gfx6_gfx7<bits<6> op> :
12470b57cec5SDimitry Andric  VOP2_Real_e32_gfx6_gfx7<op>, VOP2be_Real_e64_gfx6_gfx7<op>;
12480b57cec5SDimitry Andric
12490b57cec5SDimitry Andricdefm V_CNDMASK_B32        : VOP2_Real_gfx6_gfx7<0x000>;
12500b57cec5SDimitry Andricdefm V_MIN_LEGACY_F32     : VOP2_Real_gfx6_gfx7<0x00d>;
12510b57cec5SDimitry Andricdefm V_MAX_LEGACY_F32     : VOP2_Real_gfx6_gfx7<0x00e>;
12520b57cec5SDimitry Andricdefm V_LSHR_B32           : VOP2_Real_gfx6_gfx7<0x015>;
12530b57cec5SDimitry Andricdefm V_ASHR_I32           : VOP2_Real_gfx6_gfx7<0x017>;
12540b57cec5SDimitry Andricdefm V_LSHL_B32           : VOP2_Real_gfx6_gfx7<0x019>;
12550b57cec5SDimitry Andricdefm V_BFM_B32            : VOP2_Real_gfx6_gfx7<0x01e>;
12560b57cec5SDimitry Andricdefm V_BCNT_U32_B32       : VOP2_Real_gfx6_gfx7<0x022>;
12570b57cec5SDimitry Andricdefm V_MBCNT_LO_U32_B32   : VOP2_Real_gfx6_gfx7<0x023>;
12580b57cec5SDimitry Andricdefm V_MBCNT_HI_U32_B32   : VOP2_Real_gfx6_gfx7<0x024>;
12590b57cec5SDimitry Andricdefm V_LDEXP_F32          : VOP2_Real_gfx6_gfx7<0x02b>;
12600b57cec5SDimitry Andricdefm V_CVT_PKACCUM_U8_F32 : VOP2_Real_gfx6_gfx7<0x02c>;
12610b57cec5SDimitry Andricdefm V_CVT_PKNORM_I16_F32 : VOP2_Real_gfx6_gfx7<0x02d>;
12620b57cec5SDimitry Andricdefm V_CVT_PKNORM_U16_F32 : VOP2_Real_gfx6_gfx7<0x02e>;
12630b57cec5SDimitry Andricdefm V_CVT_PK_U16_U32     : VOP2_Real_gfx6_gfx7<0x030>;
12640b57cec5SDimitry Andricdefm V_CVT_PK_I16_I32     : VOP2_Real_gfx6_gfx7<0x031>;
12650b57cec5SDimitry Andricdefm V_ADD_I32            : VOP2be_Real_gfx6_gfx7<0x025>;
12660b57cec5SDimitry Andricdefm V_SUB_I32            : VOP2be_Real_gfx6_gfx7<0x026>;
12670b57cec5SDimitry Andricdefm V_SUBREV_I32         : VOP2be_Real_gfx6_gfx7<0x027>;
12680b57cec5SDimitry Andricdefm V_ADDC_U32           : VOP2be_Real_gfx6_gfx7<0x028>;
12690b57cec5SDimitry Andricdefm V_SUBB_U32           : VOP2be_Real_gfx6_gfx7<0x029>;
12700b57cec5SDimitry Andricdefm V_SUBBREV_U32        : VOP2be_Real_gfx6_gfx7<0x02a>;
12710b57cec5SDimitry Andric
12720b57cec5SDimitry Andricdefm V_READLANE_B32 : VOP2Only_Real_gfx6_gfx7<0x001>;
12730b57cec5SDimitry Andric
1274*5ffd83dbSDimitry Andriclet InOperandList = (ins SSrcOrLds_b32:$src0, SCSrc_b32:$src1, VGPR_32:$vdst_in) in {
12750b57cec5SDimitry Andric  defm V_WRITELANE_B32 : VOP2Only_Real_gfx6_gfx7<0x002>;
1276*5ffd83dbSDimitry Andric} // End InOperandList = (ins SSrcOrLds_b32:$src0, SCSrc_b32:$src1, VGPR_32:$vdst_in)
12770b57cec5SDimitry Andric
12780b57cec5SDimitry Andriclet SubtargetPredicate = isGFX6GFX7 in {
12790b57cec5SDimitry Andric  defm : VOP2eInstAliases<V_CNDMASK_B32_e32, V_CNDMASK_B32_e32_gfx6_gfx7>;
12800b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX6GFX7
12810b57cec5SDimitry Andric
12820b57cec5SDimitry Andricdefm V_ADD_F32            : VOP2_Real_gfx6_gfx7_gfx10<0x003>;
12830b57cec5SDimitry Andricdefm V_SUB_F32            : VOP2_Real_gfx6_gfx7_gfx10<0x004>;
12840b57cec5SDimitry Andricdefm V_SUBREV_F32         : VOP2_Real_gfx6_gfx7_gfx10<0x005>;
1285*5ffd83dbSDimitry Andriclet OtherPredicates = [HasMadMacF32Insts] in
12860b57cec5SDimitry Andricdefm V_MAC_LEGACY_F32     : VOP2_Real_gfx6_gfx7_gfx10<0x006>;
12870b57cec5SDimitry Andricdefm V_MUL_LEGACY_F32     : VOP2_Real_gfx6_gfx7_gfx10<0x007>;
12880b57cec5SDimitry Andricdefm V_MUL_F32            : VOP2_Real_gfx6_gfx7_gfx10<0x008>;
12890b57cec5SDimitry Andricdefm V_MUL_I32_I24        : VOP2_Real_gfx6_gfx7_gfx10<0x009>;
12900b57cec5SDimitry Andricdefm V_MUL_HI_I32_I24     : VOP2_Real_gfx6_gfx7_gfx10<0x00a>;
12910b57cec5SDimitry Andricdefm V_MUL_U32_U24        : VOP2_Real_gfx6_gfx7_gfx10<0x00b>;
12920b57cec5SDimitry Andricdefm V_MUL_HI_U32_U24     : VOP2_Real_gfx6_gfx7_gfx10<0x00c>;
12930b57cec5SDimitry Andricdefm V_MIN_F32            : VOP2_Real_gfx6_gfx7_gfx10<0x00f>;
12940b57cec5SDimitry Andricdefm V_MAX_F32            : VOP2_Real_gfx6_gfx7_gfx10<0x010>;
12950b57cec5SDimitry Andricdefm V_MIN_I32            : VOP2_Real_gfx6_gfx7_gfx10<0x011>;
12960b57cec5SDimitry Andricdefm V_MAX_I32            : VOP2_Real_gfx6_gfx7_gfx10<0x012>;
12970b57cec5SDimitry Andricdefm V_MIN_U32            : VOP2_Real_gfx6_gfx7_gfx10<0x013>;
12980b57cec5SDimitry Andricdefm V_MAX_U32            : VOP2_Real_gfx6_gfx7_gfx10<0x014>;
12990b57cec5SDimitry Andricdefm V_LSHRREV_B32        : VOP2_Real_gfx6_gfx7_gfx10<0x016>;
13000b57cec5SDimitry Andricdefm V_ASHRREV_I32        : VOP2_Real_gfx6_gfx7_gfx10<0x018>;
13010b57cec5SDimitry Andricdefm V_LSHLREV_B32        : VOP2_Real_gfx6_gfx7_gfx10<0x01a>;
13020b57cec5SDimitry Andricdefm V_AND_B32            : VOP2_Real_gfx6_gfx7_gfx10<0x01b>;
13030b57cec5SDimitry Andricdefm V_OR_B32             : VOP2_Real_gfx6_gfx7_gfx10<0x01c>;
13040b57cec5SDimitry Andricdefm V_XOR_B32            : VOP2_Real_gfx6_gfx7_gfx10<0x01d>;
13050b57cec5SDimitry Andricdefm V_MAC_F32            : VOP2_Real_gfx6_gfx7_gfx10<0x01f>;
13060b57cec5SDimitry Andricdefm V_CVT_PKRTZ_F16_F32  : VOP2_Real_gfx6_gfx7_gfx10<0x02f>;
13070b57cec5SDimitry Andricdefm V_MADMK_F32          : VOP2Only_Real_MADK_gfx6_gfx7_gfx10<0x020>;
13080b57cec5SDimitry Andricdefm V_MADAK_F32          : VOP2Only_Real_MADK_gfx6_gfx7_gfx10<0x021>;
13090b57cec5SDimitry Andric
13100b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
13110b57cec5SDimitry Andric// GFX8, GFX9 (VI).
13120b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
13130b57cec5SDimitry Andric
1314480093f4SDimitry Andriclet AssemblerPredicate = isGFX8GFX9, DecoderNamespace = "GFX8" in {
13150b57cec5SDimitry Andric
13160b57cec5SDimitry Andricmulticlass VOP2_Real_MADK_vi <bits<6> op> {
13170b57cec5SDimitry Andric  def _vi : VOP2_Real<!cast<VOP2_Pseudo>(NAME), SIEncodingFamily.VI>,
13180b57cec5SDimitry Andric            VOP2_MADKe<op{5-0}, !cast<VOP2_Pseudo>(NAME).Pfl>;
13190b57cec5SDimitry Andric}
13200b57cec5SDimitry Andric
13210b57cec5SDimitry Andricmulticlass VOP2_Real_e32_vi <bits<6> op> {
13220b57cec5SDimitry Andric  def _e32_vi :
13230b57cec5SDimitry Andric    VOP2_Real<!cast<VOP2_Pseudo>(NAME#"_e32"), SIEncodingFamily.VI>,
13240b57cec5SDimitry Andric    VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME#"_e32").Pfl>;
13250b57cec5SDimitry Andric}
13260b57cec5SDimitry Andric
13270b57cec5SDimitry Andricmulticlass VOP2_Real_e64_vi <bits<10> op> {
13280b57cec5SDimitry Andric  def _e64_vi :
13290b57cec5SDimitry Andric    VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.VI>,
13300b57cec5SDimitry Andric    VOP3e_vi <op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
13310b57cec5SDimitry Andric}
13320b57cec5SDimitry Andric
13330b57cec5SDimitry Andricmulticlass VOP2_Real_e64only_vi <bits<10> op> {
13340b57cec5SDimitry Andric  def _e64_vi :
13350b57cec5SDimitry Andric    VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.VI>,
13360b57cec5SDimitry Andric    VOP3e_vi <op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl> {
13370b57cec5SDimitry Andric      // Hack to stop printing _e64
13380b57cec5SDimitry Andric      VOP3_Pseudo ps = !cast<VOP3_Pseudo>(NAME#"_e64");
13390b57cec5SDimitry Andric      let OutOperandList = (outs VGPR_32:$vdst);
13400b57cec5SDimitry Andric      let AsmString = ps.Mnemonic # " " # ps.AsmOperands;
13410b57cec5SDimitry Andric    }
13420b57cec5SDimitry Andric}
13430b57cec5SDimitry Andric
13440b57cec5SDimitry Andricmulticlass Base_VOP2_Real_e32e64_vi <bits<6> op> :
13450b57cec5SDimitry Andric  VOP2_Real_e32_vi<op>,
13460b57cec5SDimitry Andric  VOP2_Real_e64_vi<{0, 1, 0, 0, op{5-0}}>;
13470b57cec5SDimitry Andric
1348480093f4SDimitry Andric} // End AssemblerPredicate = isGFX8GFX9, DecoderNamespace = "GFX8"
13490b57cec5SDimitry Andric
13500b57cec5SDimitry Andricmulticlass VOP2_SDWA_Real <bits<6> op> {
13518bcb0991SDimitry Andric  foreach _ = BoolToList<!cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA>.ret in
13520b57cec5SDimitry Andric  def _sdwa_vi :
13530b57cec5SDimitry Andric    VOP_SDWA_Real <!cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa")>,
13540b57cec5SDimitry Andric    VOP2_SDWAe <op{5-0}, !cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa").Pfl>;
13550b57cec5SDimitry Andric}
13560b57cec5SDimitry Andric
13570b57cec5SDimitry Andricmulticlass VOP2_SDWA9_Real <bits<6> op> {
13588bcb0991SDimitry Andric  foreach _ = BoolToList<!cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA9>.ret in
13590b57cec5SDimitry Andric  def _sdwa_gfx9 :
13600b57cec5SDimitry Andric    VOP_SDWA9_Real <!cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa")>,
13610b57cec5SDimitry Andric    VOP2_SDWA9Ae <op{5-0}, !cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa").Pfl>;
13620b57cec5SDimitry Andric}
13630b57cec5SDimitry Andric
1364480093f4SDimitry Andriclet AssemblerPredicate = isGFX8Only in {
13650b57cec5SDimitry Andric
13660b57cec5SDimitry Andricmulticlass VOP2be_Real_e32e64_vi_only <bits<6> op, string OpName, string AsmName> {
13670b57cec5SDimitry Andric  def _e32_vi :
13680b57cec5SDimitry Andric    VOP2_Real<!cast<VOP2_Pseudo>(OpName#"_e32"), SIEncodingFamily.VI>,
13690b57cec5SDimitry Andric    VOP2e<op{5-0}, !cast<VOP2_Pseudo>(OpName#"_e32").Pfl> {
13700b57cec5SDimitry Andric      VOP2_Pseudo ps = !cast<VOP2_Pseudo>(OpName#"_e32");
13710b57cec5SDimitry Andric      let AsmString = AsmName # ps.AsmOperands;
13720b57cec5SDimitry Andric      let DecoderNamespace = "GFX8";
13730b57cec5SDimitry Andric    }
13740b57cec5SDimitry Andric  def _e64_vi :
13750b57cec5SDimitry Andric    VOP3_Real<!cast<VOP3_Pseudo>(OpName#"_e64"), SIEncodingFamily.VI>,
13760b57cec5SDimitry Andric    VOP3be_vi <{0, 1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(OpName#"_e64").Pfl> {
13770b57cec5SDimitry Andric      VOP3_Pseudo ps = !cast<VOP3_Pseudo>(OpName#"_e64");
13780b57cec5SDimitry Andric      let AsmString = AsmName # ps.AsmOperands;
13790b57cec5SDimitry Andric      let DecoderNamespace = "GFX8";
13800b57cec5SDimitry Andric    }
13818bcb0991SDimitry Andric  foreach _ = BoolToList<!cast<VOP2_Pseudo>(OpName#"_e32").Pfl.HasExtSDWA>.ret in
13820b57cec5SDimitry Andric    def _sdwa_vi :
13830b57cec5SDimitry Andric      VOP_SDWA_Real <!cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa")>,
13840b57cec5SDimitry Andric      VOP2_SDWAe <op{5-0}, !cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa").Pfl> {
13850b57cec5SDimitry Andric        VOP2_SDWA_Pseudo ps = !cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa");
13860b57cec5SDimitry Andric        let AsmString = AsmName # ps.AsmOperands;
13870b57cec5SDimitry Andric      }
13880b57cec5SDimitry Andric  foreach _ = BoolToList<!cast<VOP2_Pseudo>(OpName#"_e32").Pfl.HasExtDPP>.ret in
13890b57cec5SDimitry Andric    def _dpp_vi :
13900b57cec5SDimitry Andric      VOP_DPP_Real<!cast<VOP2_DPP_Pseudo>(OpName#"_dpp"), SIEncodingFamily.VI>,
13910b57cec5SDimitry Andric      VOP2_DPPe<op, !cast<VOP2_DPP_Pseudo>(OpName#"_dpp")> {
13920b57cec5SDimitry Andric        VOP2_DPP_Pseudo ps = !cast<VOP2_DPP_Pseudo>(OpName#"_dpp");
13930b57cec5SDimitry Andric        let AsmString = AsmName # ps.AsmOperands;
13940b57cec5SDimitry Andric      }
13950b57cec5SDimitry Andric}
13960b57cec5SDimitry Andric}
13970b57cec5SDimitry Andric
1398480093f4SDimitry Andriclet AssemblerPredicate = isGFX9Only in {
13990b57cec5SDimitry Andric
14000b57cec5SDimitry Andricmulticlass VOP2be_Real_e32e64_gfx9 <bits<6> op, string OpName, string AsmName> {
14010b57cec5SDimitry Andric  def _e32_gfx9 :
14020b57cec5SDimitry Andric    VOP2_Real<!cast<VOP2_Pseudo>(OpName#"_e32"), SIEncodingFamily.GFX9>,
14030b57cec5SDimitry Andric    VOP2e<op{5-0}, !cast<VOP2_Pseudo>(OpName#"_e32").Pfl> {
14040b57cec5SDimitry Andric      VOP2_Pseudo ps = !cast<VOP2_Pseudo>(OpName#"_e32");
14050b57cec5SDimitry Andric      let AsmString = AsmName # ps.AsmOperands;
14060b57cec5SDimitry Andric      let DecoderNamespace = "GFX9";
14070b57cec5SDimitry Andric    }
14080b57cec5SDimitry Andric  def _e64_gfx9 :
14090b57cec5SDimitry Andric    VOP3_Real<!cast<VOP3_Pseudo>(OpName#"_e64"), SIEncodingFamily.GFX9>,
14100b57cec5SDimitry Andric    VOP3be_vi <{0, 1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(OpName#"_e64").Pfl> {
14110b57cec5SDimitry Andric      VOP3_Pseudo ps = !cast<VOP3_Pseudo>(OpName#"_e64");
14120b57cec5SDimitry Andric      let AsmString = AsmName # ps.AsmOperands;
14130b57cec5SDimitry Andric      let DecoderNamespace = "GFX9";
14140b57cec5SDimitry Andric    }
14158bcb0991SDimitry Andric  foreach _ = BoolToList<!cast<VOP2_Pseudo>(OpName#"_e32").Pfl.HasExtSDWA9>.ret in
14160b57cec5SDimitry Andric    def _sdwa_gfx9 :
14170b57cec5SDimitry Andric      VOP_SDWA9_Real <!cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa")>,
14180b57cec5SDimitry Andric      VOP2_SDWA9Ae <op{5-0}, !cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa").Pfl> {
14190b57cec5SDimitry Andric        VOP2_SDWA_Pseudo ps = !cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa");
14200b57cec5SDimitry Andric        let AsmString = AsmName # ps.AsmOperands;
14210b57cec5SDimitry Andric      }
14220b57cec5SDimitry Andric  foreach _ = BoolToList<!cast<VOP2_Pseudo>(OpName#"_e32").Pfl.HasExtDPP>.ret in
14230b57cec5SDimitry Andric    def _dpp_gfx9 :
14240b57cec5SDimitry Andric      VOP_DPP_Real<!cast<VOP2_DPP_Pseudo>(OpName#"_dpp"), SIEncodingFamily.GFX9>,
14250b57cec5SDimitry Andric      VOP2_DPPe<op, !cast<VOP2_DPP_Pseudo>(OpName#"_dpp")> {
14260b57cec5SDimitry Andric        VOP2_DPP_Pseudo ps = !cast<VOP2_DPP_Pseudo>(OpName#"_dpp");
14270b57cec5SDimitry Andric        let AsmString = AsmName # ps.AsmOperands;
14280b57cec5SDimitry Andric        let DecoderNamespace = "SDWA9";
14290b57cec5SDimitry Andric      }
14300b57cec5SDimitry Andric}
14310b57cec5SDimitry Andric
14320b57cec5SDimitry Andricmulticlass VOP2_Real_e32e64_gfx9 <bits<6> op> {
14330b57cec5SDimitry Andric  def _e32_gfx9 :
14340b57cec5SDimitry Andric    VOP2_Real<!cast<VOP2_Pseudo>(NAME#"_e32"), SIEncodingFamily.GFX9>,
14350b57cec5SDimitry Andric    VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME#"_e32").Pfl>{
14360b57cec5SDimitry Andric      let DecoderNamespace = "GFX9";
14370b57cec5SDimitry Andric    }
14380b57cec5SDimitry Andric  def _e64_gfx9 :
14390b57cec5SDimitry Andric    VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX9>,
14400b57cec5SDimitry Andric    VOP3e_vi <{0, 1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl> {
14410b57cec5SDimitry Andric      let DecoderNamespace = "GFX9";
14420b57cec5SDimitry Andric    }
14438bcb0991SDimitry Andric  foreach _ = BoolToList<!cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA9>.ret in
14440b57cec5SDimitry Andric    def _sdwa_gfx9 :
14450b57cec5SDimitry Andric      VOP_SDWA9_Real <!cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa")>,
14460b57cec5SDimitry Andric      VOP2_SDWA9Ae <op{5-0}, !cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa").Pfl> {
14470b57cec5SDimitry Andric      }
14480b57cec5SDimitry Andric  foreach _ = BoolToList<!cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtDPP>.ret in
14490b57cec5SDimitry Andric    def _dpp_gfx9 :
14500b57cec5SDimitry Andric      VOP_DPP_Real<!cast<VOP2_DPP_Pseudo>(NAME#"_dpp"), SIEncodingFamily.GFX9>,
14510b57cec5SDimitry Andric      VOP2_DPPe<op, !cast<VOP2_DPP_Pseudo>(NAME#"_dpp")> {
14520b57cec5SDimitry Andric        let DecoderNamespace = "SDWA9";
14530b57cec5SDimitry Andric      }
14540b57cec5SDimitry Andric}
14550b57cec5SDimitry Andric
1456480093f4SDimitry Andric} // AssemblerPredicate = isGFX9Only
14570b57cec5SDimitry Andric
14580b57cec5SDimitry Andricmulticlass VOP2_Real_e32e64_vi <bits<6> op> :
14590b57cec5SDimitry Andric  Base_VOP2_Real_e32e64_vi<op>, VOP2_SDWA_Real<op>, VOP2_SDWA9_Real<op> {
14600b57cec5SDimitry Andric
14610b57cec5SDimitry Andric  foreach _ = BoolToList<!cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtDPP>.ret in
14620b57cec5SDimitry Andric    def _dpp_vi :
14630b57cec5SDimitry Andric      VOP_DPP_Real<!cast<VOP2_DPP_Pseudo>(NAME#"_dpp"), SIEncodingFamily.VI>,
14640b57cec5SDimitry Andric      VOP2_DPPe<op, !cast<VOP2_DPP_Pseudo>(NAME#"_dpp")>;
14650b57cec5SDimitry Andric}
14660b57cec5SDimitry Andric
14670b57cec5SDimitry Andricdefm V_CNDMASK_B32        : VOP2_Real_e32e64_vi <0x0>;
14680b57cec5SDimitry Andricdefm V_ADD_F32            : VOP2_Real_e32e64_vi <0x1>;
14690b57cec5SDimitry Andricdefm V_SUB_F32            : VOP2_Real_e32e64_vi <0x2>;
14700b57cec5SDimitry Andricdefm V_SUBREV_F32         : VOP2_Real_e32e64_vi <0x3>;
14710b57cec5SDimitry Andricdefm V_MUL_LEGACY_F32     : VOP2_Real_e32e64_vi <0x4>;
14720b57cec5SDimitry Andricdefm V_MUL_F32            : VOP2_Real_e32e64_vi <0x5>;
14730b57cec5SDimitry Andricdefm V_MUL_I32_I24        : VOP2_Real_e32e64_vi <0x6>;
14740b57cec5SDimitry Andricdefm V_MUL_HI_I32_I24     : VOP2_Real_e32e64_vi <0x7>;
14750b57cec5SDimitry Andricdefm V_MUL_U32_U24        : VOP2_Real_e32e64_vi <0x8>;
14760b57cec5SDimitry Andricdefm V_MUL_HI_U32_U24     : VOP2_Real_e32e64_vi <0x9>;
14770b57cec5SDimitry Andricdefm V_MIN_F32            : VOP2_Real_e32e64_vi <0xa>;
14780b57cec5SDimitry Andricdefm V_MAX_F32            : VOP2_Real_e32e64_vi <0xb>;
14790b57cec5SDimitry Andricdefm V_MIN_I32            : VOP2_Real_e32e64_vi <0xc>;
14800b57cec5SDimitry Andricdefm V_MAX_I32            : VOP2_Real_e32e64_vi <0xd>;
14810b57cec5SDimitry Andricdefm V_MIN_U32            : VOP2_Real_e32e64_vi <0xe>;
14820b57cec5SDimitry Andricdefm V_MAX_U32            : VOP2_Real_e32e64_vi <0xf>;
14830b57cec5SDimitry Andricdefm V_LSHRREV_B32        : VOP2_Real_e32e64_vi <0x10>;
14840b57cec5SDimitry Andricdefm V_ASHRREV_I32        : VOP2_Real_e32e64_vi <0x11>;
14850b57cec5SDimitry Andricdefm V_LSHLREV_B32        : VOP2_Real_e32e64_vi <0x12>;
14860b57cec5SDimitry Andricdefm V_AND_B32            : VOP2_Real_e32e64_vi <0x13>;
14870b57cec5SDimitry Andricdefm V_OR_B32             : VOP2_Real_e32e64_vi <0x14>;
14880b57cec5SDimitry Andricdefm V_XOR_B32            : VOP2_Real_e32e64_vi <0x15>;
14890b57cec5SDimitry Andricdefm V_MAC_F32            : VOP2_Real_e32e64_vi <0x16>;
14900b57cec5SDimitry Andricdefm V_MADMK_F32          : VOP2_Real_MADK_vi <0x17>;
14910b57cec5SDimitry Andricdefm V_MADAK_F32          : VOP2_Real_MADK_vi <0x18>;
14920b57cec5SDimitry Andric
14930b57cec5SDimitry Andricdefm V_ADD_U32            : VOP2be_Real_e32e64_vi_only <0x19, "V_ADD_I32",     "v_add_u32">;
14940b57cec5SDimitry Andricdefm V_SUB_U32            : VOP2be_Real_e32e64_vi_only <0x1a, "V_SUB_I32",     "v_sub_u32">;
14950b57cec5SDimitry Andricdefm V_SUBREV_U32         : VOP2be_Real_e32e64_vi_only <0x1b, "V_SUBREV_I32",  "v_subrev_u32">;
14960b57cec5SDimitry Andricdefm V_ADDC_U32           : VOP2be_Real_e32e64_vi_only <0x1c, "V_ADDC_U32",    "v_addc_u32">;
14970b57cec5SDimitry Andricdefm V_SUBB_U32           : VOP2be_Real_e32e64_vi_only <0x1d, "V_SUBB_U32",    "v_subb_u32">;
14980b57cec5SDimitry Andricdefm V_SUBBREV_U32        : VOP2be_Real_e32e64_vi_only <0x1e, "V_SUBBREV_U32", "v_subbrev_u32">;
14990b57cec5SDimitry Andric
15000b57cec5SDimitry Andricdefm V_ADD_CO_U32         : VOP2be_Real_e32e64_gfx9 <0x19, "V_ADD_I32",     "v_add_co_u32">;
15010b57cec5SDimitry Andricdefm V_SUB_CO_U32         : VOP2be_Real_e32e64_gfx9 <0x1a, "V_SUB_I32",     "v_sub_co_u32">;
15020b57cec5SDimitry Andricdefm V_SUBREV_CO_U32      : VOP2be_Real_e32e64_gfx9 <0x1b, "V_SUBREV_I32",  "v_subrev_co_u32">;
15030b57cec5SDimitry Andricdefm V_ADDC_CO_U32        : VOP2be_Real_e32e64_gfx9 <0x1c, "V_ADDC_U32",    "v_addc_co_u32">;
15040b57cec5SDimitry Andricdefm V_SUBB_CO_U32        : VOP2be_Real_e32e64_gfx9 <0x1d, "V_SUBB_U32",    "v_subb_co_u32">;
15050b57cec5SDimitry Andricdefm V_SUBBREV_CO_U32     : VOP2be_Real_e32e64_gfx9 <0x1e, "V_SUBBREV_U32", "v_subbrev_co_u32">;
15060b57cec5SDimitry Andric
15070b57cec5SDimitry Andricdefm V_ADD_U32            : VOP2_Real_e32e64_gfx9 <0x34>;
15080b57cec5SDimitry Andricdefm V_SUB_U32            : VOP2_Real_e32e64_gfx9 <0x35>;
15090b57cec5SDimitry Andricdefm V_SUBREV_U32         : VOP2_Real_e32e64_gfx9 <0x36>;
15100b57cec5SDimitry Andric
15110b57cec5SDimitry Andricdefm V_BFM_B32            : VOP2_Real_e64only_vi <0x293>;
15120b57cec5SDimitry Andricdefm V_BCNT_U32_B32       : VOP2_Real_e64only_vi <0x28b>;
15130b57cec5SDimitry Andricdefm V_MBCNT_LO_U32_B32   : VOP2_Real_e64only_vi <0x28c>;
15140b57cec5SDimitry Andricdefm V_MBCNT_HI_U32_B32   : VOP2_Real_e64only_vi <0x28d>;
15150b57cec5SDimitry Andricdefm V_LDEXP_F32          : VOP2_Real_e64only_vi <0x288>;
15160b57cec5SDimitry Andricdefm V_CVT_PKACCUM_U8_F32 : VOP2_Real_e64only_vi <0x1f0>;
15170b57cec5SDimitry Andricdefm V_CVT_PKNORM_I16_F32 : VOP2_Real_e64only_vi <0x294>;
15180b57cec5SDimitry Andricdefm V_CVT_PKNORM_U16_F32 : VOP2_Real_e64only_vi <0x295>;
15190b57cec5SDimitry Andricdefm V_CVT_PKRTZ_F16_F32  : VOP2_Real_e64only_vi <0x296>;
15200b57cec5SDimitry Andricdefm V_CVT_PK_U16_U32     : VOP2_Real_e64only_vi <0x297>;
15210b57cec5SDimitry Andricdefm V_CVT_PK_I16_I32     : VOP2_Real_e64only_vi <0x298>;
15220b57cec5SDimitry Andric
15230b57cec5SDimitry Andricdefm V_ADD_F16            : VOP2_Real_e32e64_vi <0x1f>;
15240b57cec5SDimitry Andricdefm V_SUB_F16            : VOP2_Real_e32e64_vi <0x20>;
15250b57cec5SDimitry Andricdefm V_SUBREV_F16         : VOP2_Real_e32e64_vi <0x21>;
15260b57cec5SDimitry Andricdefm V_MUL_F16            : VOP2_Real_e32e64_vi <0x22>;
15270b57cec5SDimitry Andricdefm V_MAC_F16            : VOP2_Real_e32e64_vi <0x23>;
15280b57cec5SDimitry Andricdefm V_MADMK_F16          : VOP2_Real_MADK_vi <0x24>;
15290b57cec5SDimitry Andricdefm V_MADAK_F16          : VOP2_Real_MADK_vi <0x25>;
15300b57cec5SDimitry Andricdefm V_ADD_U16            : VOP2_Real_e32e64_vi <0x26>;
15310b57cec5SDimitry Andricdefm V_SUB_U16            : VOP2_Real_e32e64_vi <0x27>;
15320b57cec5SDimitry Andricdefm V_SUBREV_U16         : VOP2_Real_e32e64_vi <0x28>;
15330b57cec5SDimitry Andricdefm V_MUL_LO_U16         : VOP2_Real_e32e64_vi <0x29>;
15340b57cec5SDimitry Andricdefm V_LSHLREV_B16        : VOP2_Real_e32e64_vi <0x2a>;
15350b57cec5SDimitry Andricdefm V_LSHRREV_B16        : VOP2_Real_e32e64_vi <0x2b>;
15360b57cec5SDimitry Andricdefm V_ASHRREV_I16        : VOP2_Real_e32e64_vi <0x2c>;
15370b57cec5SDimitry Andricdefm V_MAX_F16            : VOP2_Real_e32e64_vi <0x2d>;
15380b57cec5SDimitry Andricdefm V_MIN_F16            : VOP2_Real_e32e64_vi <0x2e>;
15390b57cec5SDimitry Andricdefm V_MAX_U16            : VOP2_Real_e32e64_vi <0x2f>;
15400b57cec5SDimitry Andricdefm V_MAX_I16            : VOP2_Real_e32e64_vi <0x30>;
15410b57cec5SDimitry Andricdefm V_MIN_U16            : VOP2_Real_e32e64_vi <0x31>;
15420b57cec5SDimitry Andricdefm V_MIN_I16            : VOP2_Real_e32e64_vi <0x32>;
15430b57cec5SDimitry Andricdefm V_LDEXP_F16          : VOP2_Real_e32e64_vi <0x33>;
15440b57cec5SDimitry Andric
15450b57cec5SDimitry Andriclet SubtargetPredicate = isGFX8GFX9 in {
15460b57cec5SDimitry Andric
15470b57cec5SDimitry Andric// Aliases to simplify matching of floating-point instructions that
15480b57cec5SDimitry Andric// are VOP2 on SI and VOP3 on VI.
15490b57cec5SDimitry Andricclass SI2_VI3Alias <string name, VOP3_Real inst> : InstAlias <
15500b57cec5SDimitry Andric  name#" $dst, $src0, $src1",
15510b57cec5SDimitry Andric  !if(inst.Pfl.HasOMod,
15520b57cec5SDimitry Andric      (inst VGPR_32:$dst, 0, VCSrc_f32:$src0, 0, VCSrc_f32:$src1, 0, 0),
15530b57cec5SDimitry Andric      (inst VGPR_32:$dst, 0, VCSrc_f32:$src0, 0, VCSrc_f32:$src1, 0))
15540b57cec5SDimitry Andric>, PredicateControl {
15550b57cec5SDimitry Andric  let UseInstAsmMatchConverter = 0;
15560b57cec5SDimitry Andric  let AsmVariantName = AMDGPUAsmVariants.VOP3;
15570b57cec5SDimitry Andric}
15580b57cec5SDimitry Andric
15590b57cec5SDimitry Andricdef : SI2_VI3Alias <"v_ldexp_f32", V_LDEXP_F32_e64_vi>;
15600b57cec5SDimitry Andricdef : SI2_VI3Alias <"v_cvt_pkaccum_u8_f32", V_CVT_PKACCUM_U8_F32_e64_vi>;
15610b57cec5SDimitry Andricdef : SI2_VI3Alias <"v_cvt_pknorm_i16_f32", V_CVT_PKNORM_I16_F32_e64_vi>;
15620b57cec5SDimitry Andricdef : SI2_VI3Alias <"v_cvt_pknorm_u16_f32", V_CVT_PKNORM_U16_F32_e64_vi>;
15630b57cec5SDimitry Andricdef : SI2_VI3Alias <"v_cvt_pkrtz_f16_f32", V_CVT_PKRTZ_F16_F32_e64_vi>;
15640b57cec5SDimitry Andric
15650b57cec5SDimitry Andricdefm : VOP2eInstAliases<V_CNDMASK_B32_e32, V_CNDMASK_B32_e32_vi>;
15660b57cec5SDimitry Andric
15670b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX8GFX9
15680b57cec5SDimitry Andric
15690b57cec5SDimitry Andriclet SubtargetPredicate = isGFX9Only in {
15700b57cec5SDimitry Andric
15710b57cec5SDimitry Andricdefm : VOP2bInstAliases<V_ADD_I32_e32,     V_ADD_CO_U32_e32_gfx9,     "v_add_co_u32">;
15720b57cec5SDimitry Andricdefm : VOP2bInstAliases<V_ADDC_U32_e32,    V_ADDC_CO_U32_e32_gfx9,    "v_addc_co_u32">;
15730b57cec5SDimitry Andricdefm : VOP2bInstAliases<V_SUB_I32_e32,     V_SUB_CO_U32_e32_gfx9,     "v_sub_co_u32">;
15740b57cec5SDimitry Andricdefm : VOP2bInstAliases<V_SUBB_U32_e32,    V_SUBB_CO_U32_e32_gfx9,    "v_subb_co_u32">;
15750b57cec5SDimitry Andricdefm : VOP2bInstAliases<V_SUBREV_I32_e32,  V_SUBREV_CO_U32_e32_gfx9,  "v_subrev_co_u32">;
15760b57cec5SDimitry Andricdefm : VOP2bInstAliases<V_SUBBREV_U32_e32, V_SUBBREV_CO_U32_e32_gfx9, "v_subbrev_co_u32">;
15770b57cec5SDimitry Andric
15780b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX9Only
15790b57cec5SDimitry Andric
15800b57cec5SDimitry Andriclet SubtargetPredicate = HasDLInsts in {
15810b57cec5SDimitry Andric
15820b57cec5SDimitry Andricdefm V_FMAC_F32 : VOP2_Real_e32e64_vi <0x3b>;
15830b57cec5SDimitry Andricdefm V_XNOR_B32 : VOP2_Real_e32e64_vi <0x3d>;
15840b57cec5SDimitry Andric
15850b57cec5SDimitry Andric} // End SubtargetPredicate = HasDLInsts
15860b57cec5SDimitry Andric
15870b57cec5SDimitry Andricmulticlass VOP2_Real_DOT_ACC_gfx9<bits<6> op> : VOP2_Real_e32_vi<op> {
15888bcb0991SDimitry Andric  def _dpp_vi : VOP2_DPP<op, !cast<VOP2_DPP_Pseudo>(NAME#"_dpp")>;
15890b57cec5SDimitry Andric}
15900b57cec5SDimitry Andric
15910b57cec5SDimitry Andricmulticlass VOP2_Real_DOT_ACC_gfx10<bits<6> op> :
15920b57cec5SDimitry Andric  VOP2_Real_e32_gfx10<op>,
15930b57cec5SDimitry Andric  VOP2_Real_dpp_gfx10<op>,
15940b57cec5SDimitry Andric  VOP2_Real_dpp8_gfx10<op>;
15950b57cec5SDimitry Andric
15960b57cec5SDimitry Andriclet SubtargetPredicate = HasDot5Insts in {
15970b57cec5SDimitry Andric  defm V_DOT2C_F32_F16 : VOP2_Real_DOT_ACC_gfx9<0x37>;
15980b57cec5SDimitry Andric  // NB: Opcode conflicts with V_DOT8C_I32_I4
15990b57cec5SDimitry Andric  // This opcode exists in gfx 10.1* only
16000b57cec5SDimitry Andric  defm V_DOT2C_F32_F16 : VOP2_Real_DOT_ACC_gfx10<0x02>;
16010b57cec5SDimitry Andric}
16020b57cec5SDimitry Andric
16030b57cec5SDimitry Andriclet SubtargetPredicate = HasDot6Insts in {
16040b57cec5SDimitry Andric  defm V_DOT4C_I32_I8  : VOP2_Real_DOT_ACC_gfx9<0x39>;
16050b57cec5SDimitry Andric  defm V_DOT4C_I32_I8  : VOP2_Real_DOT_ACC_gfx10<0x0d>;
16060b57cec5SDimitry Andric}
16070b57cec5SDimitry Andric
16080b57cec5SDimitry Andriclet SubtargetPredicate = HasDot4Insts in {
16090b57cec5SDimitry Andric  defm V_DOT2C_I32_I16 : VOP2_Real_DOT_ACC_gfx9<0x38>;
16100b57cec5SDimitry Andric}
16110b57cec5SDimitry Andriclet SubtargetPredicate = HasDot3Insts in {
16120b57cec5SDimitry Andric  defm V_DOT8C_I32_I4  : VOP2_Real_DOT_ACC_gfx9<0x3a>;
16130b57cec5SDimitry Andric}
16140b57cec5SDimitry Andric
16150b57cec5SDimitry Andriclet SubtargetPredicate = HasPkFmacF16Inst in {
16160b57cec5SDimitry Andricdefm V_PK_FMAC_F16 : VOP2_Real_e32_vi<0x3c>;
16170b57cec5SDimitry Andric} // End SubtargetPredicate = HasPkFmacF16Inst
1618*5ffd83dbSDimitry Andric
1619*5ffd83dbSDimitry Andriclet SubtargetPredicate = HasDot3Insts in {
1620*5ffd83dbSDimitry Andric  // NB: Opcode conflicts with V_DOT2C_F32_F16
1621*5ffd83dbSDimitry Andric  let DecoderNamespace = "GFX10_B" in
1622*5ffd83dbSDimitry Andric  defm V_DOT8C_I32_I4 : VOP2_Real_DOT_ACC_gfx10<0x02>;
1623*5ffd83dbSDimitry Andric}
1624