xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/VOP2Instructions.td (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
15ffd83dbSDimitry 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
727a6dacacSDimitry Andric  let ReadsModeReg = !or(P.DstVT.isFP, P.Src0VT.isFP);
735ffd83dbSDimitry Andric
745ffd83dbSDimitry Andric  let mayRaiseFPException = ReadsModeReg;
755ffd83dbSDimitry Andric
760b57cec5SDimitry Andric  let VOP2 = 1;
770b57cec5SDimitry Andric  let VALU = 1;
785ffd83dbSDimitry Andric  let Uses = !if(ReadsModeReg, [MODE, EXEC], [EXEC]);
790b57cec5SDimitry Andric
800b57cec5SDimitry Andric  let AsmVariantName = AMDGPUAsmVariants.Default;
810b57cec5SDimitry Andric}
820b57cec5SDimitry Andric
8381ad6265SDimitry Andricclass VOP2_Real <VOP2_Pseudo ps, int EncodingFamily, string real_name = ps.Mnemonic> :
84fe6060f1SDimitry Andric  VOP_Real <ps>,
8581ad6265SDimitry Andric  InstSI <ps.OutOperandList, ps.InOperandList, real_name # ps.AsmOperands, []>,
860b57cec5SDimitry Andric  SIMCInstr <ps.PseudoInstr, EncodingFamily> {
870b57cec5SDimitry Andric
88fe6060f1SDimitry Andric  let VALU = 1;
89fe6060f1SDimitry Andric  let VOP2 = 1;
900b57cec5SDimitry Andric  let isPseudo = 0;
910b57cec5SDimitry Andric  let isCodeGenOnly = 0;
920b57cec5SDimitry Andric
930b57cec5SDimitry Andric  let Constraints     = ps.Constraints;
940b57cec5SDimitry Andric  let DisableEncoding = ps.DisableEncoding;
950b57cec5SDimitry Andric
960b57cec5SDimitry Andric  // copy relevant pseudo op flags
970b57cec5SDimitry Andric  let SubtargetPredicate = ps.SubtargetPredicate;
98e8d8bef9SDimitry Andric  let OtherPredicates    = ps.OtherPredicates;
990b57cec5SDimitry Andric  let AsmMatchConverter  = ps.AsmMatchConverter;
1000b57cec5SDimitry Andric  let AsmVariantName     = ps.AsmVariantName;
1010b57cec5SDimitry Andric  let Constraints        = ps.Constraints;
1020b57cec5SDimitry Andric  let DisableEncoding    = ps.DisableEncoding;
1030b57cec5SDimitry Andric  let TSFlags            = ps.TSFlags;
1040b57cec5SDimitry Andric  let UseNamedOperandTable = ps.UseNamedOperandTable;
1050b57cec5SDimitry Andric  let Uses                 = ps.Uses;
1060b57cec5SDimitry Andric  let Defs                 = ps.Defs;
107fe6060f1SDimitry Andric  let SchedRW              = ps.SchedRW;
108fe6060f1SDimitry Andric  let mayLoad              = ps.mayLoad;
109fe6060f1SDimitry Andric  let mayStore             = ps.mayStore;
1100b57cec5SDimitry Andric}
1110b57cec5SDimitry Andric
1125f757f3fSDimitry Andricclass VOP2_Real_Gen <VOP2_Pseudo ps, GFXGen Gen, string real_name = ps.Mnemonic> :
1135f757f3fSDimitry Andric  VOP2_Real <ps, Gen.Subtarget, real_name> {
114297eecfbSDimitry Andric  let AssemblerPredicate = Gen.AssemblerPredicate;
115*0fca6ea1SDimitry Andric  let True16Predicate = !if(ps.Pfl.IsRealTrue16, UseRealTrue16Insts, NoTrue16Predicate);
1165f757f3fSDimitry Andric  let DecoderNamespace = Gen.DecoderNamespace#
1175f757f3fSDimitry Andric                         !if(ps.Pfl.IsRealTrue16, "", "_FAKE16");
1185f757f3fSDimitry Andric}
1195f757f3fSDimitry Andric
1200b57cec5SDimitry Andricclass VOP2_SDWA_Pseudo <string OpName, VOPProfile P, list<dag> pattern=[]> :
1210b57cec5SDimitry Andric  VOP_SDWA_Pseudo <OpName, P, pattern> {
1220b57cec5SDimitry Andric  let AsmMatchConverter = "cvtSdwaVOP2";
1230b57cec5SDimitry Andric}
1240b57cec5SDimitry Andric
1250b57cec5SDimitry Andricclass VOP2_DPP_Pseudo <string OpName, VOPProfile P, list<dag> pattern=[]> :
1260b57cec5SDimitry Andric  VOP_DPP_Pseudo <OpName, P, pattern> {
1270b57cec5SDimitry Andric}
1280b57cec5SDimitry Andric
1290b57cec5SDimitry Andric
1300b57cec5SDimitry Andricclass getVOP2Pat64 <SDPatternOperator node, VOPProfile P> : LetDummies {
1310b57cec5SDimitry Andric  list<dag> ret = !if(P.HasModifiers,
1320b57cec5SDimitry Andric    [(set P.DstVT:$vdst,
1330b57cec5SDimitry Andric      (node (P.Src0VT
1340b57cec5SDimitry Andric              !if(P.HasOMod,
1350b57cec5SDimitry Andric                  (VOP3Mods0 P.Src0VT:$src0, i32:$src0_modifiers, i1:$clamp, i32:$omod),
1360b57cec5SDimitry Andric                  (VOP3Mods0 P.Src0VT:$src0, i32:$src0_modifiers, i1:$clamp))),
1370b57cec5SDimitry Andric            (P.Src1VT (VOP3Mods P.Src1VT:$src1, i32:$src1_modifiers))))],
1380b57cec5SDimitry Andric    [(set P.DstVT:$vdst, (node P.Src0VT:$src0, P.Src1VT:$src1))]);
1390b57cec5SDimitry Andric}
1400b57cec5SDimitry Andric
1410b57cec5SDimitry Andricmulticlass VOP2Inst_e32<string opName,
1420b57cec5SDimitry Andric                        VOPProfile P,
1430b57cec5SDimitry Andric                        SDPatternOperator node = null_frag,
1440b57cec5SDimitry Andric                        string revOp = opName,
1450b57cec5SDimitry Andric                        bit GFX9Renamed = 0> {
1460b57cec5SDimitry Andric  let renamedInGFX9 = GFX9Renamed in {
1470b57cec5SDimitry Andric    def _e32 : VOP2_Pseudo <opName, P, VOPPatOrNull<node,P>.ret>,
1480b57cec5SDimitry Andric               Commutable_REV<revOp#"_e32", !eq(revOp, opName)>;
1490b57cec5SDimitry Andric  } // End renamedInGFX9 = GFX9Renamed
1500b57cec5SDimitry Andric}
15181ad6265SDimitry Andricmulticlass
15281ad6265SDimitry Andric    VOP2Inst_e32_VOPD<string opName, VOPProfile P, bits<5> VOPDOp,
15381ad6265SDimitry Andric                      string VOPDName, SDPatternOperator node = null_frag,
15481ad6265SDimitry Andric                      string revOp = opName, bit GFX9Renamed = 0> {
15581ad6265SDimitry Andric  defm NAME : VOP2Inst_e32<opName, P, node, revOp, GFX9Renamed>,
15681ad6265SDimitry Andric              VOPD_Component<VOPDOp, VOPDName>;
15781ad6265SDimitry Andric}
1580b57cec5SDimitry Andricmulticlass VOP2Inst_e64<string opName,
1590b57cec5SDimitry Andric                        VOPProfile P,
1600b57cec5SDimitry Andric                        SDPatternOperator node = null_frag,
1610b57cec5SDimitry Andric                        string revOp = opName,
1620b57cec5SDimitry Andric                        bit GFX9Renamed = 0> {
1630b57cec5SDimitry Andric  let renamedInGFX9 = GFX9Renamed in {
16481ad6265SDimitry Andric    def _e64 : VOP3InstBase <opName, P, node, 1>,
1650b57cec5SDimitry Andric               Commutable_REV<revOp#"_e64", !eq(revOp, opName)>;
16681ad6265SDimitry Andric
16781ad6265SDimitry Andric    let SubtargetPredicate = isGFX11Plus in {
16806c3fb27SDimitry Andric      if P.HasExtVOP3DPP then
16981ad6265SDimitry Andric        def _e64_dpp  : VOP3_DPP_Pseudo <opName, P>;
17081ad6265SDimitry Andric    } // End SubtargetPredicate = isGFX11Plus
1710b57cec5SDimitry Andric  } // End renamedInGFX9 = GFX9Renamed
1720b57cec5SDimitry Andric}
1730b57cec5SDimitry Andric
1740b57cec5SDimitry Andricmulticlass VOP2Inst_sdwa<string opName,
1750b57cec5SDimitry Andric                         VOPProfile P,
1760b57cec5SDimitry Andric                         bit GFX9Renamed = 0> {
1770b57cec5SDimitry Andric  let renamedInGFX9 = GFX9Renamed in {
17806c3fb27SDimitry Andric    if P.HasExtSDWA then
1790b57cec5SDimitry Andric      def _sdwa : VOP2_SDWA_Pseudo <opName, P>;
1800b57cec5SDimitry Andric  } // End renamedInGFX9 = GFX9Renamed
1810b57cec5SDimitry Andric}
1820b57cec5SDimitry Andric
1830b57cec5SDimitry Andricmulticlass VOP2Inst<string opName,
1840b57cec5SDimitry Andric                    VOPProfile P,
1850b57cec5SDimitry Andric                    SDPatternOperator node = null_frag,
1860b57cec5SDimitry Andric                    string revOp = opName,
1870b57cec5SDimitry Andric                    bit GFX9Renamed = 0> :
1880b57cec5SDimitry Andric    VOP2Inst_e32<opName, P, node, revOp, GFX9Renamed>,
1890b57cec5SDimitry Andric    VOP2Inst_e64<opName, P, node, revOp, GFX9Renamed>,
190349cc55cSDimitry Andric    VOP2Inst_sdwa<opName, P, GFX9Renamed> {
1910b57cec5SDimitry Andric  let renamedInGFX9 = GFX9Renamed in {
19206c3fb27SDimitry Andric    if P.HasExtDPP then
1930b57cec5SDimitry Andric      def _dpp  : VOP2_DPP_Pseudo <opName, P>;
1940b57cec5SDimitry Andric  }
1950b57cec5SDimitry Andric}
1960b57cec5SDimitry Andric
197bdd1243dSDimitry Andricmulticlass VOP2Inst_t16<string opName,
198bdd1243dSDimitry Andric                        VOPProfile P,
199bdd1243dSDimitry Andric                        SDPatternOperator node = null_frag,
200bdd1243dSDimitry Andric                        string revOp = opName,
201bdd1243dSDimitry Andric                        bit GFX9Renamed = 0> {
202*0fca6ea1SDimitry Andric  let OtherPredicates = [Has16BitInsts], True16Predicate = NotHasTrue16BitInsts in {
203bdd1243dSDimitry Andric    defm NAME : VOP2Inst<opName, P, node, revOp, GFX9Renamed>;
204bdd1243dSDimitry Andric  }
2055f757f3fSDimitry Andric  let SubtargetPredicate = UseRealTrue16Insts in {
206bdd1243dSDimitry Andric    defm _t16 : VOP2Inst<opName#"_t16", VOPProfile_True16<P>, node, revOp#"_t16", GFX9Renamed>;
207bdd1243dSDimitry Andric  }
2085f757f3fSDimitry Andric  let SubtargetPredicate = UseFakeTrue16Insts in {
2095f757f3fSDimitry Andric    defm _fake16 : VOP2Inst<opName#"_fake16", VOPProfile_Fake16<P>, node, revOp#"_fake16", GFX9Renamed>;
2105f757f3fSDimitry Andric  }
211bdd1243dSDimitry Andric}
212bdd1243dSDimitry Andric
213bdd1243dSDimitry Andric// Creating a _t16_e32 pseudo when there is no corresponding real instruction on
214bdd1243dSDimitry Andric// any subtarget is a problem. It makes getMCOpcodeGen return -1, which we
215bdd1243dSDimitry Andric// assume means the instruction is already a real. The fix is to not create that
216bdd1243dSDimitry Andric// _t16_e32 pseudo
217bdd1243dSDimitry Andricmulticlass VOP2Inst_e64_t16<string opName,
218bdd1243dSDimitry Andric                        VOPProfile P,
219bdd1243dSDimitry Andric                        SDPatternOperator node = null_frag,
220bdd1243dSDimitry Andric                        string revOp = opName,
221bdd1243dSDimitry Andric                        bit GFX9Renamed = 0> {
222*0fca6ea1SDimitry Andric  let OtherPredicates = [Has16BitInsts], True16Predicate = NotHasTrue16BitInsts in {
223bdd1243dSDimitry Andric    defm NAME : VOP2Inst<opName, P, node, revOp, GFX9Renamed>;
224bdd1243dSDimitry Andric  }
225bdd1243dSDimitry Andric  let SubtargetPredicate = HasTrue16BitInsts in {
2265f757f3fSDimitry Andric    defm _t16 : VOP2Inst_e64<opName#"_t16", VOPProfile_Fake16<P>, node, revOp#"_t16", GFX9Renamed>;
227bdd1243dSDimitry Andric  }
228bdd1243dSDimitry Andric}
229bdd1243dSDimitry Andric
23081ad6265SDimitry Andricmulticlass VOP2Inst_VOPD<string opName,
23181ad6265SDimitry Andric                         VOPProfile P,
23281ad6265SDimitry Andric                         bits<5> VOPDOp,
23381ad6265SDimitry Andric                         string VOPDName,
23481ad6265SDimitry Andric                         SDPatternOperator node = null_frag,
23581ad6265SDimitry Andric                         string revOp = opName,
23681ad6265SDimitry Andric                         bit GFX9Renamed = 0> :
23781ad6265SDimitry Andric    VOP2Inst_e32_VOPD<opName, P, VOPDOp, VOPDName, node, revOp, GFX9Renamed>,
23881ad6265SDimitry Andric    VOP2Inst_e64<opName, P, node, revOp, GFX9Renamed>,
23981ad6265SDimitry Andric    VOP2Inst_sdwa<opName, P, GFX9Renamed> {
24081ad6265SDimitry Andric  let renamedInGFX9 = GFX9Renamed in {
24106c3fb27SDimitry Andric    if P.HasExtDPP then
24281ad6265SDimitry Andric      def _dpp  : VOP2_DPP_Pseudo <opName, P>;
24381ad6265SDimitry Andric  }
24481ad6265SDimitry Andric}
24581ad6265SDimitry Andric
2460b57cec5SDimitry Andricmulticlass VOP2bInst <string opName,
2470b57cec5SDimitry Andric                      VOPProfile P,
2480b57cec5SDimitry Andric                      SDPatternOperator node = null_frag,
2490b57cec5SDimitry Andric                      string revOp = opName,
2500b57cec5SDimitry Andric                      bit GFX9Renamed = 0,
2510b57cec5SDimitry Andric                      bit useSGPRInput = !eq(P.NumSrcArgs, 3)> {
2520b57cec5SDimitry Andric  let renamedInGFX9 = GFX9Renamed in {
2530b57cec5SDimitry Andric    let SchedRW = [Write32Bit, WriteSALU] in {
2540b57cec5SDimitry Andric      let Uses = !if(useSGPRInput, [VCC, EXEC], [EXEC]), Defs = [VCC] in {
2550b57cec5SDimitry Andric        def _e32 : VOP2_Pseudo <opName, P, VOPPatOrNull<node,P>.ret>,
2560b57cec5SDimitry Andric                   Commutable_REV<revOp#"_e32", !eq(revOp, opName)> {
257349cc55cSDimitry Andric          let usesCustomInserter = true;
2580b57cec5SDimitry Andric        }
2590b57cec5SDimitry Andric
26006c3fb27SDimitry Andric        if P.HasExtSDWA then
2610b57cec5SDimitry Andric          def _sdwa  : VOP2_SDWA_Pseudo <opName, P> {
2620b57cec5SDimitry Andric            let AsmMatchConverter = "cvtSdwaVOP2b";
2630b57cec5SDimitry Andric          }
26406c3fb27SDimitry Andric        if P.HasExtDPP then
2650b57cec5SDimitry Andric          def _dpp  : VOP2_DPP_Pseudo <opName, P>;
26681ad6265SDimitry Andric      } // End Uses = !if(useSGPRInput, [VCC, EXEC], [EXEC]), Defs = [VCC]
2670b57cec5SDimitry Andric
26881ad6265SDimitry Andric      def _e64 : VOP3InstBase <opName, P, node, 1>,
2690b57cec5SDimitry Andric                 Commutable_REV<revOp#"_e64", !eq(revOp, opName)>;
27081ad6265SDimitry Andric
27181ad6265SDimitry Andric      let SubtargetPredicate = isGFX11Plus in {
27206c3fb27SDimitry Andric        if P.HasExtVOP3DPP then
27381ad6265SDimitry Andric          def _e64_dpp  : VOP3_DPP_Pseudo <opName, P>;
27481ad6265SDimitry Andric      } // End SubtargetPredicate = isGFX11Plus
2750b57cec5SDimitry Andric    }
2760b57cec5SDimitry Andric  }
2770b57cec5SDimitry Andric}
2780b57cec5SDimitry Andric
2790b57cec5SDimitry Andricclass VOP2bInstAlias <VOP2_Pseudo ps, Instruction inst,
2800b57cec5SDimitry Andric                      string OpName, string opnd> :
2810b57cec5SDimitry Andric  InstAlias <OpName#" "#!subst("vcc", opnd, ps.Pfl.Asm32),
2820b57cec5SDimitry Andric             (inst ps.Pfl.DstRC:$vdst, ps.Pfl.Src0RC32:$src0,
283bdd1243dSDimitry Andric                   ps.Pfl.Src1RC32:$src1),
284bdd1243dSDimitry Andric             1, inst.AsmVariantName>,
2850b57cec5SDimitry Andric  PredicateControl {
2860b57cec5SDimitry Andric}
2870b57cec5SDimitry Andric
2880b57cec5SDimitry Andricmulticlass VOP2bInstAliases<VOP2_Pseudo ps, VOP2_Real inst, string OpName> {
2890b57cec5SDimitry Andric  let WaveSizePredicate = isWave32 in {
2900b57cec5SDimitry Andric    def : VOP2bInstAlias<ps, inst, OpName, "vcc_lo">;
2910b57cec5SDimitry Andric  }
2920b57cec5SDimitry Andric  let WaveSizePredicate = isWave64 in {
2930b57cec5SDimitry Andric    def : VOP2bInstAlias<ps, inst, OpName, "vcc">;
2940b57cec5SDimitry Andric  }
2950b57cec5SDimitry Andric}
2960b57cec5SDimitry Andric
29781ad6265SDimitry Andricmulticlass
29881ad6265SDimitry Andric    VOP2eInst_Base<string opName, VOPProfile P, bits<5> VOPDOp, string VOPDName,
29981ad6265SDimitry Andric                   SDPatternOperator node, string revOp, bit useSGPRInput> {
3000b57cec5SDimitry Andric
3010b57cec5SDimitry Andric  let SchedRW = [Write32Bit] in {
3020b57cec5SDimitry Andric    let Uses = !if(useSGPRInput, [VCC, EXEC], [EXEC]) in {
30381ad6265SDimitry Andric      if !eq(VOPDOp, -1) then
3040b57cec5SDimitry Andric        def _e32 : VOP2_Pseudo <opName, P>,
3050b57cec5SDimitry Andric                   Commutable_REV<revOp#"_e32", !eq(revOp, opName)>;
30681ad6265SDimitry Andric      else
30781ad6265SDimitry Andric        def _e32 : VOP2_Pseudo <opName, P>,
30881ad6265SDimitry Andric                   Commutable_REV<revOp#"_e32", !eq(revOp, opName)>,
30981ad6265SDimitry Andric                   VOPD_Component<VOPDOp, VOPDName>;
3100b57cec5SDimitry Andric
31106c3fb27SDimitry Andric      if P.HasExtSDWA then
3120b57cec5SDimitry Andric        def _sdwa : VOP2_SDWA_Pseudo <opName, P> {
3138bcb0991SDimitry Andric          let AsmMatchConverter = "cvtSdwaVOP2e";
3140b57cec5SDimitry Andric        }
3150b57cec5SDimitry Andric
31606c3fb27SDimitry Andric      if P.HasExtDPP then
3170b57cec5SDimitry Andric        def _dpp  : VOP2_DPP_Pseudo <opName, P>;
3180b57cec5SDimitry Andric    }
3190b57cec5SDimitry Andric
32081ad6265SDimitry Andric    def _e64 : VOP3InstBase <opName, P, node, 1>,
321fe6060f1SDimitry Andric               Commutable_REV<revOp#"_e64", !eq(revOp, opName)> {
322fe6060f1SDimitry Andric      let isReMaterializable = 1;
323fe6060f1SDimitry Andric    }
32481ad6265SDimitry Andric
32581ad6265SDimitry Andric    let SubtargetPredicate = isGFX11Plus in {
32606c3fb27SDimitry Andric      if P.HasExtVOP3DPP then
32781ad6265SDimitry Andric        def _e64_dpp  : VOP3_DPP_Pseudo <opName, P>;
32881ad6265SDimitry Andric    } // End SubtargetPredicate = isGFX11Plus
3290b57cec5SDimitry Andric  }
3300b57cec5SDimitry Andric}
3310b57cec5SDimitry Andric
33281ad6265SDimitry Andricmulticlass
33381ad6265SDimitry Andric    VOP2eInst<string opName, VOPProfile P, SDPatternOperator node = null_frag,
33481ad6265SDimitry Andric              string revOp = opName, bit useSGPRInput = !eq(P.NumSrcArgs, 3)>
33581ad6265SDimitry Andric    : VOP2eInst_Base<opName, P, -1, "", node, revOp, useSGPRInput>;
33681ad6265SDimitry Andric
33781ad6265SDimitry Andricmulticlass
33881ad6265SDimitry Andric    VOP2eInst_VOPD<string opName, VOPProfile P, bits<5> VOPDOp, string VOPDName,
33981ad6265SDimitry Andric                   SDPatternOperator node = null_frag, string revOp = opName,
34081ad6265SDimitry Andric                   bit useSGPRInput = !eq(P.NumSrcArgs, 3)>
34181ad6265SDimitry Andric    : VOP2eInst_Base<opName, P, VOPDOp, VOPDName, node, revOp, useSGPRInput>;
34281ad6265SDimitry Andric
343e8d8bef9SDimitry Andricclass VOP2eInstAlias <VOP2_Pseudo ps, Instruction inst, string opnd = ""> :
3440b57cec5SDimitry Andric  InstAlias <ps.OpName#" "#ps.Pfl.Asm32#", "#opnd,
3450b57cec5SDimitry Andric             (inst ps.Pfl.DstRC:$vdst, ps.Pfl.Src0RC32:$src0,
346bdd1243dSDimitry Andric                   ps.Pfl.Src1RC32:$src1),
347bdd1243dSDimitry Andric             1, inst.AsmVariantName>,
348bdd1243dSDimitry Andric  PredicateControl;
349e8d8bef9SDimitry Andric
350e8d8bef9SDimitry Andricclass VOP2e64InstAlias <VOP3_Pseudo ps, Instruction inst> :
351e8d8bef9SDimitry Andric  InstAlias <ps.OpName#" "#ps.Pfl.Asm64,
352e8d8bef9SDimitry Andric             (inst ps.Pfl.DstRC:$vdst, VOPDstS64orS32:$sdst,
353*0fca6ea1SDimitry Andric                   ps.Pfl.Src0RC32:$src0, ps.Pfl.Src1RC32:$src1, Clamp:$clamp),
354bdd1243dSDimitry Andric             1, inst.AsmVariantName>,
355e8d8bef9SDimitry Andric  PredicateControl;
3560b57cec5SDimitry Andric
3570b57cec5SDimitry Andricmulticlass VOP2eInstAliases<VOP2_Pseudo ps, VOP2_Real inst> {
3580b57cec5SDimitry Andric  let WaveSizePredicate = isWave32 in {
3590b57cec5SDimitry Andric    def : VOP2eInstAlias<ps, inst, "vcc_lo">;
3600b57cec5SDimitry Andric  }
3610b57cec5SDimitry Andric  let WaveSizePredicate = isWave64 in {
3620b57cec5SDimitry Andric    def : VOP2eInstAlias<ps, inst, "vcc">;
3630b57cec5SDimitry Andric  }
3640b57cec5SDimitry Andric}
3650b57cec5SDimitry Andric
36681ad6265SDimitry Andricclass VOP_MADK_Base<ValueType vt> : VOPProfile <[vt, vt, vt, vt]> {
36781ad6265SDimitry Andric  string AsmVOPDXDeferred = ?;
36881ad6265SDimitry Andric}
36981ad6265SDimitry Andric
37081ad6265SDimitry Andricclass VOP_MADAK <ValueType vt> : VOP_MADK_Base<vt> {
37106c3fb27SDimitry Andric  field Operand ImmOpType = !if(!eq(vt.Size, 32), KImmFP32, KImmFP16);
3728bcb0991SDimitry Andric  field dag Ins32 = !if(!eq(vt.Size, 32),
373349cc55cSDimitry Andric                        (ins VSrc_f32_Deferred:$src0, VGPR_32:$src1, ImmOpType:$imm),
374349cc55cSDimitry Andric                        (ins VSrc_f16_Deferred:$src0, VGPR_32:$src1, ImmOpType:$imm));
37581ad6265SDimitry Andric  field dag InsVOPDX = (ins VSrc_f32_Deferred:$src0X, VGPR_32:$vsrc1X, ImmOpType:$imm);
37681ad6265SDimitry Andric  // Note that both src0X and imm are deferred
37781ad6265SDimitry Andric  let InsVOPDXDeferred = (ins VSrc_f32_Deferred:$src0X, VGPR_32:$vsrc1X, ImmOpType:$immDeferred);
37881ad6265SDimitry Andric  field dag InsVOPDY = (ins VSrc_f32_Deferred:$src0Y, VGPR_32:$vsrc1Y, ImmOpType:$imm);
37981ad6265SDimitry Andric
380349cc55cSDimitry Andric  field string Asm32 = "$vdst, $src0, $src1, $imm";
38181ad6265SDimitry Andric  field string AsmVOPDX = "$vdstX, $src0X, $vsrc1X, $imm";
38281ad6265SDimitry Andric  let AsmVOPDXDeferred = "$vdstX, $src0X, $vsrc1X, $immDeferred";
38381ad6265SDimitry Andric  field string AsmVOPDY = "$vdstY, $src0Y, $vsrc1Y, $imm";
3840b57cec5SDimitry Andric  field bit HasExt = 0;
385fe6060f1SDimitry Andric  let IsSingle = 1;
3860b57cec5SDimitry Andric}
3870b57cec5SDimitry Andric
3880b57cec5SDimitry Andricdef VOP_MADAK_F16 : VOP_MADAK <f16>;
389bdd1243dSDimitry Andricdef VOP_MADAK_F16_t16 : VOP_MADAK <f16> {
390bdd1243dSDimitry Andric  let IsTrue16 = 1;
391bdd1243dSDimitry Andric  let DstRC = VOPDstOperand<VGPR_32_Lo128>;
3925f757f3fSDimitry Andric  let Ins32 = (ins VSrcFake16_f16_Lo128_Deferred:$src0, VGPR_32_Lo128:$src1, ImmOpType:$imm);
393bdd1243dSDimitry Andric}
3940b57cec5SDimitry Andricdef VOP_MADAK_F32 : VOP_MADAK <f32>;
3950b57cec5SDimitry Andric
39681ad6265SDimitry Andricclass VOP_MADMK <ValueType vt> : VOP_MADK_Base<vt> {
39706c3fb27SDimitry Andric  field Operand ImmOpType = !if(!eq(vt.Size, 32), KImmFP32, KImmFP16);
398bdd1243dSDimitry Andric  field dag Ins32 = !if(!eq(vt.Size, 32),
399bdd1243dSDimitry Andric                        (ins VSrc_f32_Deferred:$src0, ImmOpType:$imm, VGPR_32:$src1),
400bdd1243dSDimitry Andric                        (ins VSrc_f16_Deferred:$src0, ImmOpType:$imm, VGPR_32:$src1));
40181ad6265SDimitry Andric  field dag InsVOPDX = (ins VSrc_f32_Deferred:$src0X, ImmOpType:$imm, VGPR_32:$vsrc1X);
40281ad6265SDimitry Andric  let InsVOPDXDeferred = (ins VSrc_f32_Deferred:$src0X, ImmOpType:$immDeferred, VGPR_32:$vsrc1X);
40381ad6265SDimitry Andric  field dag InsVOPDY = (ins VSrc_f32_Deferred:$src0Y, ImmOpType:$imm, VGPR_32:$vsrc1Y);
40481ad6265SDimitry Andric
405349cc55cSDimitry Andric  field string Asm32 = "$vdst, $src0, $imm, $src1";
40681ad6265SDimitry Andric  field string AsmVOPDX = "$vdstX, $src0X, $imm, $vsrc1X";
40781ad6265SDimitry Andric  let AsmVOPDXDeferred = "$vdstX, $src0X, $immDeferred, $vsrc1X";
40881ad6265SDimitry Andric  field string AsmVOPDY = "$vdstY, $src0Y, $imm, $vsrc1Y";
4090b57cec5SDimitry Andric  field bit HasExt = 0;
410fe6060f1SDimitry Andric  let IsSingle = 1;
4110b57cec5SDimitry Andric}
4120b57cec5SDimitry Andric
4130b57cec5SDimitry Andricdef VOP_MADMK_F16 : VOP_MADMK <f16>;
414bdd1243dSDimitry Andricdef VOP_MADMK_F16_t16 : VOP_MADMK <f16> {
415bdd1243dSDimitry Andric  let IsTrue16 = 1;
416bdd1243dSDimitry Andric  let DstRC = VOPDstOperand<VGPR_32_Lo128>;
4175f757f3fSDimitry Andric  let Ins32 = (ins VSrcFake16_f16_Lo128_Deferred:$src0, ImmOpType:$imm, VGPR_32_Lo128:$src1);
418bdd1243dSDimitry Andric}
4190b57cec5SDimitry Andricdef VOP_MADMK_F32 : VOP_MADMK <f32>;
4200b57cec5SDimitry Andric
4210b57cec5SDimitry Andric// FIXME: Remove src2_modifiers. It isn't used, so is wasting memory
4220b57cec5SDimitry Andric// and processing time but it makes it easier to convert to mad.
4230b57cec5SDimitry Andricclass VOP_MAC <ValueType vt0, ValueType vt1=vt0> : VOPProfile <[vt0, vt1, vt1, vt0]> {
424fe6060f1SDimitry Andric  let Ins32 = (ins Src0RC32:$src0, Src1RC32:$src1, getVregSrcForVT<Src2VT>.ret:$src2);
4257a6dacacSDimitry Andric  let Ins64 = getIns64<Src0RC64, Src1RC64, getVregSrcForVT<Src2VT>.ret, 3,
4260b57cec5SDimitry Andric                       0, HasModifiers, HasModifiers, HasOMod,
4270b57cec5SDimitry Andric                       Src0Mod, Src1Mod, Src2Mod>.ret;
4280b57cec5SDimitry Andric  let InsDPP = (ins Src0ModDPP:$src0_modifiers, Src0DPP:$src0,
4290b57cec5SDimitry Andric                    Src1ModDPP:$src1_modifiers, Src1DPP:$src1,
430fe6060f1SDimitry Andric                    getVregSrcForVT<Src2VT>.ret:$src2, // stub argument
431*0fca6ea1SDimitry Andric                    dpp_ctrl:$dpp_ctrl, DppRowMask:$row_mask,
432*0fca6ea1SDimitry Andric                    DppBankMask:$bank_mask, DppBoundCtrl:$bound_ctrl);
433*0fca6ea1SDimitry Andric  let InsDPP16 = !con(InsDPP, (ins Dpp16FI:$fi));
434bdd1243dSDimitry Andric  let InsVOP3Base = getInsVOP3Base<Src0VOP3DPP, Src1VOP3DPP, RegisterOperand<VGPR_32>, 3,
43581ad6265SDimitry Andric                       0, HasModifiers, HasModifiers, HasOMod,
436297eecfbSDimitry Andric                       Src0ModVOP3DPP, Src1ModVOP3DPP, Src2Mod, HasOpSel>.ret;
437bdd1243dSDimitry Andric  // We need a dummy src2 tied to dst to track the use of that register for s_delay_alu
438bdd1243dSDimitry Andric  let InsVOPDX = (ins Src0RC32:$src0X, Src1RC32:$vsrc1X, VGPRSrc_32:$src2X);
439bdd1243dSDimitry Andric  let InsVOPDXDeferred =
440bdd1243dSDimitry Andric    (ins !if(!eq(Src0VT.Size, 32), VSrc_f32_Deferred, VSrc_f16_Deferred):$src0X,
441bdd1243dSDimitry Andric         VGPR_32:$vsrc1X, VGPRSrc_32:$src2X);
442bdd1243dSDimitry Andric  let InsVOPDY = (ins Src0RC32:$src0Y, Src1RC32:$vsrc1Y, VGPRSrc_32:$src2Y);
443bdd1243dSDimitry Andric  let InsVOPDYDeferred =
444bdd1243dSDimitry Andric    (ins !if(!eq(Src1VT.Size, 32), VSrc_f32_Deferred, VSrc_f16_Deferred):$src0Y,
445bdd1243dSDimitry Andric         VGPR_32:$vsrc1Y, VGPRSrc_32:$src2Y);
44681ad6265SDimitry Andric
4470b57cec5SDimitry Andric  let InsDPP8 = (ins Src0ModDPP:$src0_modifiers, Src0DPP:$src0,
4480b57cec5SDimitry Andric                     Src1ModDPP:$src1_modifiers, Src1DPP:$src1,
449fe6060f1SDimitry Andric                     getVregSrcForVT<Src2VT>.ret:$src2, // stub argument
450*0fca6ea1SDimitry Andric                     dpp8:$dpp8, Dpp8FI:$fi);
4510b57cec5SDimitry Andric  let InsSDWA = (ins Src0ModSDWA:$src0_modifiers, Src0SDWA:$src0,
4520b57cec5SDimitry Andric                     Src1ModSDWA:$src1_modifiers, Src1SDWA:$src1,
453fe6060f1SDimitry Andric                     getVregSrcForVT<Src2VT>.ret:$src2, // stub argument
454*0fca6ea1SDimitry Andric                     Clamp:$clamp, omod:$omod,
4550b57cec5SDimitry Andric                     dst_sel:$dst_sel, dst_unused:$dst_unused,
4560b57cec5SDimitry Andric                     src0_sel:$src0_sel, src1_sel:$src1_sel);
4570b57cec5SDimitry Andric  let Asm32 = getAsm32<1, 2, vt0>.ret;
4580b57cec5SDimitry Andric  let AsmDPP = getAsmDPP<1, 2, HasModifiers, vt0>.ret;
4590b57cec5SDimitry Andric  let AsmDPP16 = getAsmDPP16<1, 2, HasModifiers, vt0>.ret;
4600b57cec5SDimitry Andric  let AsmDPP8 = getAsmDPP8<1, 2, 0, vt0>.ret;
4610b57cec5SDimitry Andric  let AsmSDWA = getAsmSDWA<1, 2, vt0>.ret;
4620b57cec5SDimitry Andric  let AsmSDWA9 = getAsmSDWA9<1, 1, 2, vt0>.ret;
463bdd1243dSDimitry Andric  let AsmVOP3Base =
464bdd1243dSDimitry Andric      getAsmVOP3Base<2 /*NumSrcArgs*/, HasDst, HasClamp,
465bdd1243dSDimitry Andric                        HasOpSel, HasOMod, IsVOP3P, HasModifiers,
466bdd1243dSDimitry Andric                        HasModifiers, HasModifiers,
467bdd1243dSDimitry Andric                        0 /*Src2HasMods*/, DstVT>.ret;
4680b57cec5SDimitry Andric  let HasSrc2 = 0;
4690b57cec5SDimitry Andric  let HasSrc2Mods = 0;
4700b57cec5SDimitry Andric
4710b57cec5SDimitry Andric  let HasExt = 1;
4720b57cec5SDimitry Andric  let HasExtDPP = 1;
47381ad6265SDimitry Andric  let HasExt32BitDPP = 1;
4740b57cec5SDimitry Andric  let HasExtSDWA = 1;
4750b57cec5SDimitry Andric  let HasExtSDWA9 = 0;
4760b57cec5SDimitry Andric  let TieRegDPP = "$src2";
4770b57cec5SDimitry Andric}
4780b57cec5SDimitry Andric
4790b57cec5SDimitry Andricdef VOP_MAC_F16 : VOP_MAC <f16>;
480bdd1243dSDimitry Andricdef VOP_MAC_F16_t16 : VOP_MAC <f16> {
481bdd1243dSDimitry Andric  let IsTrue16 = 1;
482bdd1243dSDimitry Andric  let HasOpSel = 1;
483bdd1243dSDimitry Andric  let AsmVOP3OpSel = getAsmVOP3OpSel<2/*NumSrcArgs*/, HasClamp, HasOMod,
484bdd1243dSDimitry Andric                        HasSrc0FloatMods, HasSrc1FloatMods, HasSrc2FloatMods>.ret;
485bdd1243dSDimitry Andric  let DstRC = VOPDstOperand<VGPR_32_Lo128>;
486bdd1243dSDimitry Andric  let DstRC64 = VOPDstOperand<VGPR_32>;
487bdd1243dSDimitry Andric  let Src1RC32 = VGPRSrc_32_Lo128;
4887a6dacacSDimitry Andric  let Ins32 = (ins Src0RC32:$src0, Src1RC32:$src1, getVregSrcForVT<Src2VT, 1/*IsTrue16*/, 1/*IsFake16*/>.ret:$src2);
4897a6dacacSDimitry Andric  let Src0DPP = getVregSrcForVT<Src0VT, 1/*IsTrue16*/, 1/*IsFake16*/>.ret;
4907a6dacacSDimitry Andric  let Src1DPP = getVregSrcForVT<Src1VT, 1/*IsTrue16*/, 1/*IsFake16*/>.ret;
4917a6dacacSDimitry Andric  let Src2DPP = getVregSrcForVT<Src2VT, 1/*IsTrue16*/, 1/*IsFake16*/>.ret;
492bdd1243dSDimitry Andric  let Src0ModDPP = getSrcModDPP_t16<Src0VT>.ret;
493bdd1243dSDimitry Andric  let Src1ModDPP = getSrcModDPP_t16<Src1VT>.ret;
494bdd1243dSDimitry Andric  let Src2ModDPP = getSrcModDPP_t16<Src2VT>.ret;
495bdd1243dSDimitry Andric  let InsDPP = (ins Src0ModDPP:$src0_modifiers, Src0DPP:$src0,
496bdd1243dSDimitry Andric                    Src1ModDPP:$src1_modifiers, Src1DPP:$src1,
4977a6dacacSDimitry Andric                    getVregSrcForVT<Src2VT, 1/*IsTrue16*/, 1/*IsFake16*/>.ret:$src2, // stub argument
498*0fca6ea1SDimitry Andric                    dpp_ctrl:$dpp_ctrl, DppRowMask:$row_mask,
499*0fca6ea1SDimitry Andric                    DppBankMask:$bank_mask, DppBoundCtrl:$bound_ctrl);
500bdd1243dSDimitry Andric  let InsDPP8 = (ins Src0ModDPP:$src0_modifiers, Src0DPP:$src0,
501bdd1243dSDimitry Andric                     Src1ModDPP:$src1_modifiers, Src1DPP:$src1,
5027a6dacacSDimitry Andric                     getVregSrcForVT<Src2VT, 1/*IsTrue16*/, 1/*IsFake16*/>.ret:$src2, // stub argument
503*0fca6ea1SDimitry Andric                     dpp8:$dpp8, Dpp8FI:$fi);
504bdd1243dSDimitry Andric  let Src2Mod = FP32InputMods; // dummy unused modifiers
505bdd1243dSDimitry Andric  let Src2RC64 = VGPRSrc_32;   // stub argument
506*0fca6ea1SDimitry Andric  let Src1ModVOP3DPP = getSrcModVOP3DPP<Src1VT, 1/*IsFake16*/>.ret;
507bdd1243dSDimitry Andric}
5080b57cec5SDimitry Andricdef VOP_MAC_F32 : VOP_MAC <f32>;
50981ad6265SDimitry Andriclet HasExtDPP = 0, HasExt32BitDPP = 0 in
510e8d8bef9SDimitry Andricdef VOP_MAC_LEGACY_F32 : VOP_MAC <f32>;
51181ad6265SDimitry Andriclet HasExtSDWA = 0, HasExt32BitDPP = 0, HasExt64BitDPP = 1 in
512fe6060f1SDimitry Andricdef VOP_MAC_F64 : VOP_MAC <f64>;
5130b57cec5SDimitry Andric
5140b57cec5SDimitry Andricclass VOP_DOT_ACC<ValueType vt0, ValueType vt1> : VOP_MAC<vt0, vt1> {
5150b57cec5SDimitry Andric  let HasClamp = 0;
5160b57cec5SDimitry Andric  let HasExtSDWA = 0;
5170b57cec5SDimitry Andric  let HasOpSel = 0;
5180b57cec5SDimitry Andric  let IsPacked = 0;
5190b57cec5SDimitry Andric}
5200b57cec5SDimitry Andric
5210b57cec5SDimitry Andricdef VOP_DOT_ACC_F32_V2F16 : VOP_DOT_ACC<f32, v2f16> {
5220b57cec5SDimitry Andric  let Src0ModDPP = FPVRegInputMods;
5230b57cec5SDimitry Andric  let Src1ModDPP = FPVRegInputMods;
524bdd1243dSDimitry Andric  let HasClamp = 1;
5250b57cec5SDimitry Andric}
526e8d8bef9SDimitry Andric
527e8d8bef9SDimitry Andricdef VOP_DOT_ACC_I32_I32   : VOP_DOT_ACC<i32, i32> {
52881ad6265SDimitry Andric  let HasExtVOP3DPP = 0;
529e8d8bef9SDimitry Andric  let HasSrc0Mods = 1;
530e8d8bef9SDimitry Andric  let HasSrc1Mods = 1;
531bdd1243dSDimitry Andric  let HasClamp = 1;
532bdd1243dSDimitry Andric
533bdd1243dSDimitry Andric  let Src0Mod = Int32InputMods;
534bdd1243dSDimitry Andric  let Src1Mod = Int32InputMods;
5357a6dacacSDimitry Andric  let Ins64 = getIns64<Src0RC64, Src1RC64, getVregSrcForVT<Src2VT>.ret,
536bdd1243dSDimitry Andric                       3 /*NumSrcArgs*/, HasClamp, 1 /*HasModifiers*/,
537bdd1243dSDimitry Andric                       1 /*HasSrc2Mods*/, HasOMod,
538bdd1243dSDimitry Andric                       Src0Mod, Src1Mod, Src2Mod>.ret;
539bdd1243dSDimitry Andric  let Asm64 = "$vdst, $src0, $src1$clamp";
540e8d8bef9SDimitry Andric}
5410b57cec5SDimitry Andric
5420b57cec5SDimitry Andric// Write out to vcc or arbitrary SGPR.
543bdd1243dSDimitry Andricdef VOP2b_I32_I1_I32_I32 : VOPProfile<[i32, i32, i32, untyped], /*EnableClamp=*/1> {
5440b57cec5SDimitry Andric  let Asm32 = "$vdst, vcc, $src0, $src1";
545bdd1243dSDimitry Andric  let AsmVOP3Base = "$vdst, $sdst, $src0, $src1$clamp";
5460b57cec5SDimitry Andric  let AsmSDWA = "$vdst, vcc, $src0_modifiers, $src1_modifiers$clamp $dst_sel $dst_unused $src0_sel $src1_sel";
5470b57cec5SDimitry Andric  let AsmSDWA9 = "$vdst, vcc, $src0_modifiers, $src1_modifiers$clamp $dst_sel $dst_unused $src0_sel $src1_sel";
5480b57cec5SDimitry Andric  let AsmDPP = "$vdst, vcc, $src0, $src1 $dpp_ctrl$row_mask$bank_mask$bound_ctrl";
5490b57cec5SDimitry Andric  let AsmDPP8 = "$vdst, vcc, $src0, $src1 $dpp8$fi";
5500b57cec5SDimitry Andric  let AsmDPP16 = AsmDPP#"$fi";
55181ad6265SDimitry Andric  let InsDPP = (ins DstRCDPP:$old,
55281ad6265SDimitry Andric                    Src0DPP:$src0,
55381ad6265SDimitry Andric                    Src1DPP:$src1,
554*0fca6ea1SDimitry Andric                    dpp_ctrl:$dpp_ctrl, DppRowMask:$row_mask,
555*0fca6ea1SDimitry Andric                    DppBankMask:$bank_mask, DppBoundCtrl:$bound_ctrl);
556*0fca6ea1SDimitry Andric  let InsDPP16 = !con(InsDPP, (ins Dpp16FI:$fi));
55781ad6265SDimitry Andric  let InsDPP8 = (ins DstRCDPP:$old,
55881ad6265SDimitry Andric                    Src0DPP:$src0,
55981ad6265SDimitry Andric                    Src1DPP:$src1,
560*0fca6ea1SDimitry Andric                    dpp8:$dpp8, Dpp8FI:$fi);
5610b57cec5SDimitry Andric  let Outs32 = (outs DstRC:$vdst);
5620b57cec5SDimitry Andric  let Outs64 = (outs DstRC:$vdst, VOPDstS64orS32:$sdst);
56381ad6265SDimitry Andric  let OutsVOP3DPP = Outs64;
56481ad6265SDimitry Andric  let OutsVOP3DPP8 = Outs64;
5650b57cec5SDimitry Andric}
5660b57cec5SDimitry Andric
5670b57cec5SDimitry Andric// Write out to vcc or arbitrary SGPR and read in from vcc or
5680b57cec5SDimitry Andric// arbitrary SGPR.
569bdd1243dSDimitry Andricdef VOP2b_I32_I1_I32_I32_I1 : VOPProfile<[i32, i32, i32, i1], /*EnableClamp=*/1> {
57081ad6265SDimitry Andric  let HasSrc2Mods = 0;
5710b57cec5SDimitry Andric  let Asm32 = "$vdst, vcc, $src0, $src1, vcc";
5720b57cec5SDimitry Andric  let AsmSDWA = "$vdst, vcc, $src0_modifiers, $src1_modifiers, vcc$clamp $dst_sel $dst_unused $src0_sel $src1_sel";
5730b57cec5SDimitry Andric  let AsmSDWA9 = "$vdst, vcc, $src0_modifiers, $src1_modifiers, vcc$clamp $dst_sel $dst_unused $src0_sel $src1_sel";
5740b57cec5SDimitry Andric  let AsmDPP = "$vdst, vcc, $src0, $src1, vcc $dpp_ctrl$row_mask$bank_mask$bound_ctrl";
5750b57cec5SDimitry Andric  let AsmDPP8 = "$vdst, vcc, $src0, $src1, vcc $dpp8$fi";
5760b57cec5SDimitry Andric  let AsmDPP16 = AsmDPP#"$fi";
5770b57cec5SDimitry Andric  let Outs32 = (outs DstRC:$vdst);
5780b57cec5SDimitry Andric  let Outs64 = (outs DstRC:$vdst, VOPDstS64orS32:$sdst);
579bdd1243dSDimitry Andric  let AsmVOP3Base = "$vdst, $sdst, $src0, $src1, $src2$clamp";
58081ad6265SDimitry Andric  let OutsVOP3DPP = Outs64;
58181ad6265SDimitry Andric  let OutsVOP3DPP8 = Outs64;
5820b57cec5SDimitry Andric
5830b57cec5SDimitry Andric  // Suppress src2 implied by type since the 32-bit encoding uses an
5840b57cec5SDimitry Andric  // implicit VCC use.
5850b57cec5SDimitry Andric  let Ins32 = (ins Src0RC32:$src0, Src1RC32:$src1);
5860b57cec5SDimitry Andric
5870b57cec5SDimitry Andric  let InsSDWA = (ins Src0ModSDWA:$src0_modifiers, Src0SDWA:$src0,
5880b57cec5SDimitry Andric                     Src1ModSDWA:$src1_modifiers, Src1SDWA:$src1,
589*0fca6ea1SDimitry Andric                     Clamp:$clamp,
5900b57cec5SDimitry Andric                     dst_sel:$dst_sel, dst_unused:$dst_unused,
5910b57cec5SDimitry Andric                     src0_sel:$src0_sel, src1_sel:$src1_sel);
5920b57cec5SDimitry Andric
5930b57cec5SDimitry Andric  let InsDPP = (ins DstRCDPP:$old,
5940b57cec5SDimitry Andric                    Src0DPP:$src0,
5950b57cec5SDimitry Andric                    Src1DPP:$src1,
596*0fca6ea1SDimitry Andric                    dpp_ctrl:$dpp_ctrl, DppRowMask:$row_mask,
597*0fca6ea1SDimitry Andric                    DppBankMask:$bank_mask, DppBoundCtrl:$bound_ctrl);
598*0fca6ea1SDimitry Andric  let InsDPP16 = !con(InsDPP, (ins Dpp16FI:$fi));
59981ad6265SDimitry Andric  let InsDPP8 = (ins DstRCDPP:$old,
60081ad6265SDimitry Andric                     Src0DPP:$src0,
60181ad6265SDimitry Andric                     Src1DPP:$src1,
602*0fca6ea1SDimitry Andric                     dpp8:$dpp8, Dpp8FI:$fi);
6030b57cec5SDimitry Andric
6040b57cec5SDimitry Andric  let HasExt = 1;
6050b57cec5SDimitry Andric  let HasExtDPP = 1;
60681ad6265SDimitry Andric  let HasExt32BitDPP = 1;
6070b57cec5SDimitry Andric  let HasExtSDWA = 1;
6080b57cec5SDimitry Andric  let HasExtSDWA9 = 1;
6090b57cec5SDimitry Andric}
6100b57cec5SDimitry Andric
6110b57cec5SDimitry Andric// Read in from vcc or arbitrary SGPR.
612bdd1243dSDimitry Andricclass VOP2e_SGPR<list<ValueType> ArgVT> : VOPProfile<ArgVT> {
6130b57cec5SDimitry Andric  let Asm32 = "$vdst, $src0, $src1";
6140b57cec5SDimitry Andric  let AsmSDWA = "$vdst, $src0_modifiers, $src1_modifiers, vcc$clamp $dst_sel $dst_unused $src0_sel $src1_sel";
6150b57cec5SDimitry Andric  let AsmSDWA9 = "$vdst, $src0_modifiers, $src1_modifiers, vcc$clamp $dst_sel $dst_unused $src0_sel $src1_sel";
616bdd1243dSDimitry Andric  let AsmDPP = "$vdst, $src0_modifiers, $src1_modifiers, vcc $dpp_ctrl$row_mask$bank_mask$bound_ctrl";
6170b57cec5SDimitry Andric  let AsmDPP8 = "$vdst, $src0, $src1, vcc $dpp8$fi";
6180b57cec5SDimitry Andric  let AsmDPP16 = AsmDPP#"$fi";
619bdd1243dSDimitry Andric  let AsmVOP3Base = "$vdst, $src0_modifiers, $src1_modifiers, $src2";
6200b57cec5SDimitry Andric
6210b57cec5SDimitry Andric  let Outs32 = (outs DstRC:$vdst);
622*0fca6ea1SDimitry Andric  let Outs64 = (outs DstRC64:$vdst);
6230b57cec5SDimitry Andric
6240b57cec5SDimitry Andric  // Suppress src2 implied by type since the 32-bit encoding uses an
6250b57cec5SDimitry Andric  // implicit VCC use.
626bdd1243dSDimitry Andric  let Ins32 = (ins VSrc_f32:$src0, Src1RC32:$src1);
6270b57cec5SDimitry Andric
628bdd1243dSDimitry Andric  let HasModifiers = 1;
629bdd1243dSDimitry Andric
630bdd1243dSDimitry Andric  // Select FP modifiers for VOP3
631bdd1243dSDimitry Andric  let Src0Mod = !if(!eq(Src0VT.Size, 16), FP16InputMods, FP32InputMods);
632bdd1243dSDimitry Andric  let Src1Mod = Src0Mod;
633bdd1243dSDimitry Andric
634bdd1243dSDimitry Andric  let HasSrc0IntMods = 0;
635bdd1243dSDimitry Andric  let HasSrc1IntMods = 0;
636bdd1243dSDimitry Andric  let HasSrc0FloatMods = 1;
637bdd1243dSDimitry Andric  let HasSrc1FloatMods = 1;
638bdd1243dSDimitry Andric  let InsSDWA = (ins FP32SDWAInputMods:$src0_modifiers, SDWASrc_f32:$src0,
639bdd1243dSDimitry Andric                     FP32SDWAInputMods:$src1_modifiers, SDWASrc_f32:$src1,
640*0fca6ea1SDimitry Andric                     Clamp:$clamp,
6410b57cec5SDimitry Andric                     dst_sel:$dst_sel, dst_unused:$dst_unused,
6420b57cec5SDimitry Andric                     src0_sel:$src0_sel, src1_sel:$src1_sel);
6430b57cec5SDimitry Andric
6440b57cec5SDimitry Andric  let InsDPP = (ins DstRCDPP:$old,
645bdd1243dSDimitry Andric                    FPVRegInputMods:$src0_modifiers, Src0DPP:$src0,
646bdd1243dSDimitry Andric                    FPVRegInputMods:$src1_modifiers, Src1DPP:$src1,
647*0fca6ea1SDimitry Andric                    dpp_ctrl:$dpp_ctrl, DppRowMask:$row_mask,
648*0fca6ea1SDimitry Andric                    DppBankMask:$bank_mask, DppBoundCtrl:$bound_ctrl);
649*0fca6ea1SDimitry Andric  let InsDPP16 = !con(InsDPP, (ins Dpp16FI:$fi));
65081ad6265SDimitry Andric  let InsDPP8 = (ins DstRCDPP:$old,
651bdd1243dSDimitry Andric                     FPVRegInputMods:$src0_modifiers, Src0DPP:$src0,
652bdd1243dSDimitry Andric                     FPVRegInputMods:$src1_modifiers, Src1DPP:$src1,
653*0fca6ea1SDimitry Andric                     dpp8:$dpp8, Dpp8FI:$fi);
6540b57cec5SDimitry Andric
655bdd1243dSDimitry Andric  let Src0ModVOP3DPP = FPVRegInputMods;
656*0fca6ea1SDimitry Andric  let Src1ModVOP3DPP = FP32VCSrcInputMods;
657bdd1243dSDimitry Andric
6580b57cec5SDimitry Andric  let HasExt = 1;
6590b57cec5SDimitry Andric  let HasExtDPP = 1;
66081ad6265SDimitry Andric  let HasExt32BitDPP = 1;
6610b57cec5SDimitry Andric  let HasExtSDWA = 1;
6620b57cec5SDimitry Andric  let HasExtSDWA9 = 1;
6630b57cec5SDimitry Andric}
6640b57cec5SDimitry Andric
66581ad6265SDimitry Andricdef VOP2e_I32_I32_I32_I1 : VOP2e_SGPR<[i32, i32, i32, i1]>;
666*0fca6ea1SDimitry Andricdef VOP2e_I16_I16_I16_I1_fake16 : VOP2e_SGPR<[i16, i16, i16, i1]> {
667*0fca6ea1SDimitry Andric  let IsTrue16 = 1;
668*0fca6ea1SDimitry Andric  let DstRC64 = getVALUDstForVT<DstVT>.ret;
669*0fca6ea1SDimitry Andric
670*0fca6ea1SDimitry Andric  let Src0Mod = getSrcMod<f16>.ret;
671*0fca6ea1SDimitry Andric  let Src1Mod = getSrcMod<f16>.ret;
672*0fca6ea1SDimitry Andric
673*0fca6ea1SDimitry Andric  let Src0VOP3DPP = VGPRSrc_32;
674*0fca6ea1SDimitry Andric  let Src1VOP3DPP = getVOP3DPPSrcForVT<Src1VT>.ret;
675*0fca6ea1SDimitry Andric  let Src1ModVOP3DPP = getSrcModVOP3DPP<f16, 1/*IsFake16*/>.ret;
676*0fca6ea1SDimitry Andric}
67781ad6265SDimitry Andric
67881ad6265SDimitry Andricdef VOP_READLANE : VOPProfile<[i32, i32, i32, untyped]> {
6790b57cec5SDimitry Andric  let Outs32 = (outs SReg_32:$vdst);
6800b57cec5SDimitry Andric  let Outs64 = Outs32;
68106c3fb27SDimitry Andric  let Ins32 = (ins VRegOrLdsSrc_32:$src0, SCSrc_b32:$src1);
6820b57cec5SDimitry Andric  let Ins64 = Ins32;
6830b57cec5SDimitry Andric  let Asm32 = " $vdst, $src0, $src1";
6840b57cec5SDimitry Andric  let Asm64 = Asm32;
6850b57cec5SDimitry Andric
6860b57cec5SDimitry Andric  let HasExt = 0;
6870b57cec5SDimitry Andric  let HasExtDPP = 0;
68881ad6265SDimitry Andric  let HasExt32BitDPP = 0;
689fe6060f1SDimitry Andric  let HasExt64BitDPP = 0;
6900b57cec5SDimitry Andric  let HasExtSDWA = 0;
6910b57cec5SDimitry Andric  let HasExtSDWA9 = 0;
6920b57cec5SDimitry Andric}
6930b57cec5SDimitry Andric
6940b57cec5SDimitry Andricdef VOP_WRITELANE : VOPProfile<[i32, i32, i32, i32]> {
6950b57cec5SDimitry Andric  let Outs32 = (outs VGPR_32:$vdst);
6960b57cec5SDimitry Andric  let Outs64 = Outs32;
6970b57cec5SDimitry Andric  let Ins32 = (ins SCSrc_b32:$src0, SCSrc_b32:$src1, VGPR_32:$vdst_in);
6980b57cec5SDimitry Andric  let Ins64 = Ins32;
6990b57cec5SDimitry Andric  let Asm32 = " $vdst, $src0, $src1";
7000b57cec5SDimitry Andric  let Asm64 = Asm32;
7010b57cec5SDimitry Andric  let HasSrc2 = 0;
7020b57cec5SDimitry Andric  let HasSrc2Mods = 0;
7030b57cec5SDimitry Andric
7040b57cec5SDimitry Andric  let HasExt = 0;
7050b57cec5SDimitry Andric  let HasExtDPP = 0;
70681ad6265SDimitry Andric  let HasExt32BitDPP = 0;
707fe6060f1SDimitry Andric  let HasExt64BitDPP = 0;
7080b57cec5SDimitry Andric  let HasExtSDWA = 0;
7090b57cec5SDimitry Andric  let HasExtSDWA9 = 0;
7100b57cec5SDimitry Andric}
7110b57cec5SDimitry Andric
7120b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
7130b57cec5SDimitry Andric// VOP2 Instructions
7140b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
7150b57cec5SDimitry Andric
71681ad6265SDimitry Andriclet SubtargetPredicate = isGFX11Plus in
717*0fca6ea1SDimitry Andricdefm V_CNDMASK_B16 : VOP2eInst <"v_cndmask_b16", VOP2e_I16_I16_I16_I1_fake16>;
71881ad6265SDimitry Andricdefm V_CNDMASK_B32 : VOP2eInst_VOPD <"v_cndmask_b32", VOP2e_I32_I32_I32_I1, 0x9, "v_cndmask_b32">;
719fe6060f1SDimitry Andriclet SubtargetPredicate = HasMadMacF32Insts, isReMaterializable = 1 in
7200b57cec5SDimitry Andricdef V_MADMK_F32 : VOP2_Pseudo <"v_madmk_f32", VOP_MADMK_F32, []>;
7210b57cec5SDimitry Andric
7220b57cec5SDimitry Andriclet isCommutable = 1 in {
723fe6060f1SDimitry Andriclet isReMaterializable = 1 in {
72481ad6265SDimitry Andricdefm V_ADD_F32 : VOP2Inst_VOPD <"v_add_f32", VOP_F32_F32_F32, 0x4, "v_add_f32", any_fadd>;
72581ad6265SDimitry Andricdefm V_SUB_F32 : VOP2Inst_VOPD <"v_sub_f32", VOP_F32_F32_F32, 0x5, "v_sub_f32", any_fsub>;
72681ad6265SDimitry Andricdefm V_SUBREV_F32 : VOP2Inst_VOPD <"v_subrev_f32", VOP_F32_F32_F32, 0x6, "v_subrev_f32", null_frag, "v_sub_f32">;
72781ad6265SDimitry Andricdefm V_MUL_LEGACY_F32 : VOP2Inst_VOPD <"v_mul_legacy_f32", VOP_F32_F32_F32, 0x7, "v_mul_dx9_zero_f32", AMDGPUfmul_legacy>;
72881ad6265SDimitry Andricdefm V_MUL_F32 : VOP2Inst_VOPD <"v_mul_f32", VOP_F32_F32_F32, 0x3, "v_mul_f32", any_fmul>;
7295ffd83dbSDimitry Andricdefm V_MUL_I32_I24 : VOP2Inst <"v_mul_i32_i24", VOP_I32_I32_I32_ARITH, AMDGPUmul_i24>;
730349cc55cSDimitry Andricdefm V_MUL_HI_I32_I24 : VOP2Inst <"v_mul_hi_i32_i24", VOP_I32_I32_I32, AMDGPUmulhi_i24>;
7315ffd83dbSDimitry Andricdefm V_MUL_U32_U24 : VOP2Inst <"v_mul_u32_u24", VOP_I32_I32_I32_ARITH, AMDGPUmul_u24>;
732349cc55cSDimitry Andricdefm V_MUL_HI_U32_U24 : VOP2Inst <"v_mul_hi_u32_u24", VOP_I32_I32_I32, AMDGPUmulhi_u24>;
73381ad6265SDimitry Andricdefm V_MIN_F32 : VOP2Inst_VOPD <"v_min_f32", VOP_F32_F32_F32, 0xb, "v_min_f32", fminnum_like>;
73481ad6265SDimitry Andricdefm V_MAX_F32 : VOP2Inst_VOPD <"v_max_f32", VOP_F32_F32_F32, 0xa, "v_max_f32", fmaxnum_like>;
7350b57cec5SDimitry Andricdefm V_MIN_I32 : VOP2Inst <"v_min_i32", VOP_PAT_GEN<VOP_I32_I32_I32>, smin>;
7360b57cec5SDimitry Andricdefm V_MAX_I32 : VOP2Inst <"v_max_i32", VOP_PAT_GEN<VOP_I32_I32_I32>, smax>;
7370b57cec5SDimitry Andricdefm V_MIN_U32 : VOP2Inst <"v_min_u32", VOP_PAT_GEN<VOP_I32_I32_I32>, umin>;
7380b57cec5SDimitry Andricdefm V_MAX_U32 : VOP2Inst <"v_max_u32", VOP_PAT_GEN<VOP_I32_I32_I32>, umax>;
739349cc55cSDimitry Andricdefm V_LSHRREV_B32 : VOP2Inst <"v_lshrrev_b32", VOP_I32_I32_I32, clshr_rev_32, "v_lshr_b32">;
740349cc55cSDimitry Andricdefm V_ASHRREV_I32 : VOP2Inst <"v_ashrrev_i32", VOP_I32_I32_I32, cashr_rev_32, "v_ashr_i32">;
74181ad6265SDimitry Andricdefm V_LSHLREV_B32 : VOP2Inst_VOPD <"v_lshlrev_b32", VOP_I32_I32_I32, 0x11, "v_lshlrev_b32", clshl_rev_32, "v_lshl_b32">;
74281ad6265SDimitry Andricdefm V_AND_B32 : VOP2Inst_VOPD <"v_and_b32", VOP_PAT_GEN<VOP_I32_I32_I32>, 0x12, "v_and_b32", and>;
7430b57cec5SDimitry Andricdefm V_OR_B32 : VOP2Inst <"v_or_b32", VOP_PAT_GEN<VOP_I32_I32_I32>, or>;
7440b57cec5SDimitry Andricdefm V_XOR_B32 : VOP2Inst <"v_xor_b32", VOP_PAT_GEN<VOP_I32_I32_I32>, xor>;
745fe6060f1SDimitry Andric} // End isReMaterializable = 1
7460b57cec5SDimitry Andric
7475ffd83dbSDimitry Andriclet mayRaiseFPException = 0 in {
748e8d8bef9SDimitry Andriclet OtherPredicates = [HasMadMacF32Insts] in {
7490b57cec5SDimitry Andriclet Constraints = "$vdst = $src2", DisableEncoding="$src2",
7500b57cec5SDimitry Andric    isConvertibleToThreeAddress = 1 in {
7510b57cec5SDimitry Andricdefm V_MAC_F32 : VOP2Inst <"v_mac_f32", VOP_MAC_F32>;
752e8d8bef9SDimitry Andric
753e8d8bef9SDimitry Andriclet SubtargetPredicate = isGFX6GFX7GFX10 in
754e8d8bef9SDimitry Andricdefm V_MAC_LEGACY_F32 : VOP2Inst <"v_mac_legacy_f32", VOP_MAC_LEGACY_F32>;
755e8d8bef9SDimitry Andric} // End Constraints = "$vdst = $src2", DisableEncoding="$src2",
756e8d8bef9SDimitry Andric  //     isConvertibleToThreeAddress = 1
7570b57cec5SDimitry Andric
758fe6060f1SDimitry Andriclet isReMaterializable = 1 in
7590b57cec5SDimitry Andricdef V_MADAK_F32 : VOP2_Pseudo <"v_madak_f32", VOP_MADAK_F32, []>;
760e8d8bef9SDimitry Andric} // End OtherPredicates = [HasMadMacF32Insts]
761e8d8bef9SDimitry Andric} // End mayRaiseFPException = 0
7620b57cec5SDimitry Andric
7630b57cec5SDimitry Andric// No patterns so that the scalar instructions are always selected.
7640b57cec5SDimitry Andric// The scalar versions will be replaced with vector when needed later.
765e8d8bef9SDimitry Andricdefm V_ADD_CO_U32 : VOP2bInst <"v_add_co_u32", VOP2b_I32_I1_I32_I32, null_frag, "v_add_co_u32", 1>;
766e8d8bef9SDimitry Andricdefm V_SUB_CO_U32 : VOP2bInst <"v_sub_co_u32", VOP2b_I32_I1_I32_I32, null_frag, "v_sub_co_u32", 1>;
767e8d8bef9SDimitry Andricdefm V_SUBREV_CO_U32 : VOP2bInst <"v_subrev_co_u32", VOP2b_I32_I1_I32_I32, null_frag, "v_sub_co_u32", 1>;
7680b57cec5SDimitry Andricdefm V_ADDC_U32 : VOP2bInst <"v_addc_u32", VOP2b_I32_I1_I32_I32_I1, null_frag, "v_addc_u32", 1>;
7690b57cec5SDimitry Andricdefm V_SUBB_U32 : VOP2bInst <"v_subb_u32", VOP2b_I32_I1_I32_I32_I1, null_frag, "v_subb_u32", 1>;
7700b57cec5SDimitry Andricdefm V_SUBBREV_U32 : VOP2bInst <"v_subbrev_u32", VOP2b_I32_I1_I32_I32_I1, null_frag, "v_subb_u32", 1>;
7710b57cec5SDimitry Andric
7720b57cec5SDimitry Andric
773fe6060f1SDimitry Andriclet SubtargetPredicate = HasAddNoCarryInsts, isReMaterializable = 1 in {
77481ad6265SDimitry Andricdefm V_ADD_U32 : VOP2Inst_VOPD <"v_add_u32", VOP_I32_I32_I32_ARITH, 0x10, "v_add_nc_u32", null_frag, "v_add_u32", 1>;
7750b57cec5SDimitry Andricdefm V_SUB_U32 : VOP2Inst <"v_sub_u32", VOP_I32_I32_I32_ARITH, null_frag, "v_sub_u32", 1>;
7760b57cec5SDimitry Andricdefm V_SUBREV_U32 : VOP2Inst <"v_subrev_u32", VOP_I32_I32_I32_ARITH, null_frag, "v_sub_u32", 1>;
7770b57cec5SDimitry Andric}
7780b57cec5SDimitry Andric
7790b57cec5SDimitry Andric} // End isCommutable = 1
7800b57cec5SDimitry Andric
7810b57cec5SDimitry Andric// These are special and do not read the exec mask.
782*0fca6ea1SDimitry Andriclet isConvergent = 1, Uses = []<Register>, IsInvalidSingleUseConsumer = 1 in {
783*0fca6ea1SDimitry Andricdef V_READLANE_B32 : VOP2_Pseudo<"v_readlane_b32", VOP_READLANE, []>;
78406c3fb27SDimitry Andriclet IsNeverUniform = 1, Constraints = "$vdst = $vdst_in", DisableEncoding="$vdst_in" in {
785*0fca6ea1SDimitry Andricdef V_WRITELANE_B32 : VOP2_Pseudo<"v_writelane_b32", VOP_WRITELANE, []> {
786*0fca6ea1SDimitry Andric    let IsInvalidSingleUseProducer = 1;
787*0fca6ea1SDimitry Andric  }
78806c3fb27SDimitry Andric} // End IsNeverUniform, $vdst = $vdst_in, DisableEncoding $vdst_in
7890b57cec5SDimitry Andric} // End isConvergent = 1
7900b57cec5SDimitry Andric
791*0fca6ea1SDimitry Andricforeach vt = Reg32Types.types in {
792*0fca6ea1SDimitry Andric  def : GCNPat<(vt (int_amdgcn_readlane vt:$src0, i32:$src1)),
793*0fca6ea1SDimitry Andric        (V_READLANE_B32 VRegOrLdsSrc_32:$src0, SCSrc_b32:$src1)
794*0fca6ea1SDimitry Andric  >;
795*0fca6ea1SDimitry Andric
796*0fca6ea1SDimitry Andric  def : GCNPat<(vt (int_amdgcn_writelane vt:$src0, i32:$src1, vt:$src2)),
797*0fca6ea1SDimitry Andric        (V_WRITELANE_B32 SCSrc_b32:$src0, SCSrc_b32:$src1, VGPR_32:$src2)
798*0fca6ea1SDimitry Andric  >;
799*0fca6ea1SDimitry Andric}
800*0fca6ea1SDimitry Andric
801fe6060f1SDimitry Andriclet isReMaterializable = 1 in {
80281ad6265SDimitry Andricdefm V_BFM_B32 : VOP2Inst <"v_bfm_b32", VOP_I32_I32_I32>;
80381ad6265SDimitry Andricdefm V_BCNT_U32_B32 : VOP2Inst <"v_bcnt_u32_b32", VOP_I32_I32_I32, add_ctpop>;
80406c3fb27SDimitry Andriclet IsNeverUniform = 1 in {
80581ad6265SDimitry Andricdefm V_MBCNT_LO_U32_B32 : VOP2Inst <"v_mbcnt_lo_u32_b32", VOP_I32_I32_I32, int_amdgcn_mbcnt_lo>;
80681ad6265SDimitry Andricdefm V_MBCNT_HI_U32_B32 : VOP2Inst <"v_mbcnt_hi_u32_b32", VOP_I32_I32_I32, int_amdgcn_mbcnt_hi>;
80706c3fb27SDimitry Andric} // End IsNeverUniform = 1
80806c3fb27SDimitry Andricdefm V_LDEXP_F32 : VOP2Inst <"v_ldexp_f32", VOP_F32_F32_I32, any_fldexp>;
8095ffd83dbSDimitry Andric
8105ffd83dbSDimitry Andriclet ReadsModeReg = 0, mayRaiseFPException = 0 in {
81181ad6265SDimitry Andricdefm V_CVT_PKNORM_I16_F32 : VOP2Inst <"v_cvt_pknorm_i16_f32", VOP_V2I16_F32_F32, AMDGPUpknorm_i16_f32>;
81281ad6265SDimitry Andricdefm V_CVT_PKNORM_U16_F32 : VOP2Inst <"v_cvt_pknorm_u16_f32", VOP_V2I16_F32_F32, AMDGPUpknorm_u16_f32>;
8135ffd83dbSDimitry Andric}
8145ffd83dbSDimitry Andric
81581ad6265SDimitry Andricdefm V_CVT_PKRTZ_F16_F32 : VOP2Inst <"v_cvt_pkrtz_f16_f32", VOP_V2F16_F32_F32, AMDGPUpkrtz_f16_f32>;
81681ad6265SDimitry Andricdefm V_CVT_PK_U16_U32 : VOP2Inst <"v_cvt_pk_u16_u32", VOP_V2I16_I32_I32, AMDGPUpk_u16_u32>;
81781ad6265SDimitry Andricdefm V_CVT_PK_I16_I32 : VOP2Inst <"v_cvt_pk_i16_i32", VOP_V2I16_I32_I32, AMDGPUpk_i16_i32>;
8180b57cec5SDimitry Andric
8190b57cec5SDimitry Andric
8200b57cec5SDimitry Andriclet SubtargetPredicate = isGFX6GFX7 in {
8210b57cec5SDimitry Andricdefm V_MIN_LEGACY_F32 : VOP2Inst <"v_min_legacy_f32", VOP_F32_F32_F32, AMDGPUfmin_legacy>;
8220b57cec5SDimitry Andricdefm V_MAX_LEGACY_F32 : VOP2Inst <"v_max_legacy_f32", VOP_F32_F32_F32, AMDGPUfmax_legacy>;
8230b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX6GFX7
8240b57cec5SDimitry Andric
8250b57cec5SDimitry Andriclet isCommutable = 1 in {
8265ffd83dbSDimitry Andriclet SubtargetPredicate = isGFX6GFX7 in {
827349cc55cSDimitry Andricdefm V_LSHR_B32 : VOP2Inst <"v_lshr_b32", VOP_PAT_GEN<VOP_I32_I32_I32>, csrl_32>;
828349cc55cSDimitry Andricdefm V_ASHR_I32 : VOP2Inst <"v_ashr_i32", VOP_PAT_GEN<VOP_I32_I32_I32>, csra_32>;
829349cc55cSDimitry Andricdefm V_LSHL_B32 : VOP2Inst <"v_lshl_b32", VOP_PAT_GEN<VOP_I32_I32_I32>, cshl_32>;
8305ffd83dbSDimitry Andric} // End SubtargetPredicate = isGFX6GFX7
8315ffd83dbSDimitry Andric} // End isCommutable = 1
832fe6060f1SDimitry Andric} // End isReMaterializable = 1
8335ffd83dbSDimitry Andric
834fe6060f1SDimitry Andricdefm V_CVT_PKACCUM_U8_F32 : VOP2Inst <"v_cvt_pkaccum_u8_f32", VOP_NO_EXT<VOP_I32_F32_I32>>; // TODO: set "Uses = dst"
8350b57cec5SDimitry Andric
8360b57cec5SDimitry Andricclass DivergentBinOp<SDPatternOperator Op, VOP_Pseudo Inst> :
8370b57cec5SDimitry Andric  GCNPat<
838bdd1243dSDimitry Andric      (DivergentBinFrag<Op> Inst.Pfl.Src0VT:$src0, Inst.Pfl.Src1VT:$src1),
8390b57cec5SDimitry Andric      !if(!cast<Commutable_REV>(Inst).IsOrig,
8400b57cec5SDimitry Andric        (Inst $src0, $src1),
8410b57cec5SDimitry Andric        (Inst $src1, $src0)
8420b57cec5SDimitry Andric      )
8430b57cec5SDimitry Andric  >;
8440b57cec5SDimitry Andric
8450b57cec5SDimitry Andricclass DivergentClampingBinOp<SDPatternOperator Op, VOP_Pseudo Inst> :
8460b57cec5SDimitry Andric  GCNPat<
847bdd1243dSDimitry Andric      (DivergentBinFrag<Op> Inst.Pfl.Src0VT:$src0, Inst.Pfl.Src1VT:$src1),
8480b57cec5SDimitry Andric      !if(!cast<Commutable_REV>(Inst).IsOrig,
8490b57cec5SDimitry Andric        (Inst $src0, $src1, 0),
8500b57cec5SDimitry Andric        (Inst $src1, $src0, 0)
8510b57cec5SDimitry Andric      )
8520b57cec5SDimitry Andric  >;
8530b57cec5SDimitry Andric
854349cc55cSDimitry Andricdef : DivergentBinOp<csrl_32, V_LSHRREV_B32_e64>;
855349cc55cSDimitry Andricdef : DivergentBinOp<csra_32, V_ASHRREV_I32_e64>;
856349cc55cSDimitry Andricdef : DivergentBinOp<cshl_32, V_LSHLREV_B32_e64>;
8570b57cec5SDimitry Andric
8580b57cec5SDimitry Andriclet SubtargetPredicate = HasAddNoCarryInsts in {
8590b57cec5SDimitry Andric  def : DivergentClampingBinOp<add, V_ADD_U32_e64>;
8600b57cec5SDimitry Andric  def : DivergentClampingBinOp<sub, V_SUB_U32_e64>;
8610b57cec5SDimitry Andric}
8620b57cec5SDimitry Andric
8630b57cec5SDimitry Andriclet SubtargetPredicate = isGFX6GFX7GFX8GFX9, Predicates = [isGFX6GFX7GFX8GFX9] in {
864e8d8bef9SDimitry Andricdef : DivergentClampingBinOp<add, V_ADD_CO_U32_e64>;
865e8d8bef9SDimitry Andricdef : DivergentClampingBinOp<sub, V_SUB_CO_U32_e64>;
8660b57cec5SDimitry Andric}
8670b57cec5SDimitry Andric
8680b57cec5SDimitry Andricdef : DivergentBinOp<adde, V_ADDC_U32_e32>;
8690b57cec5SDimitry Andricdef : DivergentBinOp<sube, V_SUBB_U32_e32>;
8700b57cec5SDimitry Andric
8710b57cec5SDimitry Andricclass divergent_i64_BinOp <SDPatternOperator Op, Instruction Inst> :
8720b57cec5SDimitry Andric  GCNPat<
873bdd1243dSDimitry Andric      (DivergentBinFrag<Op> i64:$src0, i64:$src1),
8740b57cec5SDimitry Andric      (REG_SEQUENCE VReg_64,
8750b57cec5SDimitry Andric        (Inst
8760b57cec5SDimitry Andric          (i32 (EXTRACT_SUBREG $src0, sub0)),
8770b57cec5SDimitry Andric          (i32 (EXTRACT_SUBREG $src1, sub0))
8780b57cec5SDimitry Andric        ), sub0,
8790b57cec5SDimitry Andric        (Inst
8800b57cec5SDimitry Andric          (i32 (EXTRACT_SUBREG $src0, sub1)),
8810b57cec5SDimitry Andric          (i32 (EXTRACT_SUBREG $src1, sub1))
8820b57cec5SDimitry Andric        ), sub1
8830b57cec5SDimitry Andric      )
8840b57cec5SDimitry Andric  >;
8850b57cec5SDimitry Andric
88604eeddc0SDimitry Andricdef :  divergent_i64_BinOp <and, V_AND_B32_e64>;
88704eeddc0SDimitry Andricdef :  divergent_i64_BinOp <or,  V_OR_B32_e64>;
88804eeddc0SDimitry Andricdef :  divergent_i64_BinOp <xor, V_XOR_B32_e64>;
8890b57cec5SDimitry Andric
8905f757f3fSDimitry Andric// mul24 w/ 64 bit output.
8915f757f3fSDimitry Andricclass mul24_64_Pat<SDPatternOperator Op, Instruction InstLo, Instruction InstHi> : GCNPat<
8925f757f3fSDimitry Andric  (i64 (Op i32:$src0, i32:$src1)),
8935f757f3fSDimitry Andric  (REG_SEQUENCE VReg_64,
8945f757f3fSDimitry Andric    (InstLo $src0, $src1), sub0,
8955f757f3fSDimitry Andric    (InstHi $src0, $src1), sub1)
8965f757f3fSDimitry Andric>;
8975f757f3fSDimitry Andric
8985f757f3fSDimitry Andricdef : mul24_64_Pat<AMDGPUmul_i24, V_MUL_I32_I24_e64, V_MUL_HI_I32_I24_e64>;
8995f757f3fSDimitry Andricdef : mul24_64_Pat<AMDGPUmul_u24, V_MUL_U32_U24_e64, V_MUL_HI_U32_U24_e64>;
9005f757f3fSDimitry Andric
901bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
902bdd1243dSDimitry Andric// 16-Bit Operand Instructions
903bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
904bdd1243dSDimitry Andric
90506c3fb27SDimitry Andric// The ldexp.f16 intrinsic expects a integer src1 operand, though the hardware
906bdd1243dSDimitry Andric// encoding treats src1 as an f16
90706c3fb27SDimitry Andricdef LDEXP_F16_VOPProfile : VOPProfile <[f16, f16, f16, untyped]> {
90806c3fb27SDimitry Andric  let Src1Mod = Int32InputMods;
90906c3fb27SDimitry Andric  let Src1ModDPP = IntVRegInputMods;
91006c3fb27SDimitry Andric  let Src1ModVOP3DPP = IntVRegInputMods;
91106c3fb27SDimitry Andric  // SDWA sext is the only modifier allowed.
91206c3fb27SDimitry Andric  let HasSrc1IntMods = 1;
91306c3fb27SDimitry Andric  let HasSrc1FloatMods = 0;
91406c3fb27SDimitry Andric  let Src1ModSDWA = Int16SDWAInputMods;
91506c3fb27SDimitry Andric}
9165f757f3fSDimitry Andricdef LDEXP_F16_VOPProfile_True16 : VOPProfile_Fake16<VOP_F16_F16_F16> {
917bdd1243dSDimitry Andric  let Src1RC32 = RegisterOperand<VGPR_32_Lo128>;
9187a6dacacSDimitry Andric  let Src1DPP = RegisterOperand<VGPR_32_Lo128>;
9197a6dacacSDimitry Andric  let Src1ModDPP = IntT16VRegInputMods</* IsFake16= */ 1>;
920bdd1243dSDimitry Andric}
921bdd1243dSDimitry Andric
922bdd1243dSDimitry Andriclet isReMaterializable = 1 in {
923bdd1243dSDimitry Andriclet FPDPRounding = 1 in {
924*0fca6ea1SDimitry Andric  let OtherPredicates = [Has16BitInsts], True16Predicate = NotHasTrue16BitInsts in
92506c3fb27SDimitry Andric    defm V_LDEXP_F16 : VOP2Inst <"v_ldexp_f16", LDEXP_F16_VOPProfile>;
926bdd1243dSDimitry Andric  let SubtargetPredicate = HasTrue16BitInsts in
92706c3fb27SDimitry Andric    defm V_LDEXP_F16_t16 : VOP2Inst <"v_ldexp_f16_t16", LDEXP_F16_VOPProfile_True16>;
928bdd1243dSDimitry Andric} // End FPDPRounding = 1
929bdd1243dSDimitry Andric// FIXME VOP3 Only instructions. NFC using VOPProfile_True16 for these until a planned change to use a new register class for VOP3 encoded True16 instuctions
930bdd1243dSDimitry Andricdefm V_LSHLREV_B16 : VOP2Inst_e64_t16 <"v_lshlrev_b16", VOP_I16_I16_I16, clshl_rev_16>;
931bdd1243dSDimitry Andricdefm V_LSHRREV_B16 : VOP2Inst_e64_t16 <"v_lshrrev_b16", VOP_I16_I16_I16, clshr_rev_16>;
932bdd1243dSDimitry Andricdefm V_ASHRREV_I16 : VOP2Inst_e64_t16 <"v_ashrrev_i16", VOP_I16_I16_I16, cashr_rev_16>;
933bdd1243dSDimitry Andriclet isCommutable = 1 in {
934bdd1243dSDimitry Andriclet FPDPRounding = 1 in {
935bdd1243dSDimitry Andricdefm V_ADD_F16 : VOP2Inst_t16 <"v_add_f16", VOP_F16_F16_F16, any_fadd>;
936bdd1243dSDimitry Andricdefm V_SUB_F16 : VOP2Inst_t16 <"v_sub_f16", VOP_F16_F16_F16, any_fsub>;
937bdd1243dSDimitry Andricdefm V_SUBREV_F16 : VOP2Inst_t16 <"v_subrev_f16", VOP_F16_F16_F16, null_frag, "v_sub_f16">;
938bdd1243dSDimitry Andricdefm V_MUL_F16 : VOP2Inst_t16 <"v_mul_f16", VOP_F16_F16_F16, any_fmul>;
939bdd1243dSDimitry Andric} // End FPDPRounding = 1
940bdd1243dSDimitry Andricdefm V_MUL_LO_U16 : VOP2Inst_e64_t16 <"v_mul_lo_u16", VOP_I16_I16_I16, mul>;
941bdd1243dSDimitry Andricdefm V_MAX_F16 : VOP2Inst_t16 <"v_max_f16", VOP_F16_F16_F16, fmaxnum_like>;
942bdd1243dSDimitry Andricdefm V_MIN_F16 : VOP2Inst_t16 <"v_min_f16", VOP_F16_F16_F16, fminnum_like>;
943bdd1243dSDimitry Andricdefm V_MAX_U16 : VOP2Inst_e64_t16 <"v_max_u16", VOP_I16_I16_I16, umax>;
944bdd1243dSDimitry Andricdefm V_MAX_I16 : VOP2Inst_e64_t16 <"v_max_i16", VOP_I16_I16_I16, smax>;
945bdd1243dSDimitry Andricdefm V_MIN_U16 : VOP2Inst_e64_t16 <"v_min_u16", VOP_I16_I16_I16, umin>;
946bdd1243dSDimitry Andricdefm V_MIN_I16 : VOP2Inst_e64_t16 <"v_min_i16", VOP_I16_I16_I16, smin>;
947bdd1243dSDimitry Andric} // End isCommutable = 1
948bdd1243dSDimitry Andric} // End isReMaterializable = 1
949bdd1243dSDimitry Andric
95006c3fb27SDimitry Andricclass LDEXP_F16_Pat <SDPatternOperator op, VOP_Pseudo inst, VOPProfile P = inst.Pfl> : GCNPat <
95106c3fb27SDimitry Andric  (P.DstVT (op (P.Src0VT (VOP3Mods0 P.Src0VT:$src0, i32:$src0_modifiers, i1:$clamp, i32:$omod)),
95206c3fb27SDimitry Andric               (i16 (VOP3Mods0 P.Src1VT:$src1, i32:$src1_modifiers)))),
95306c3fb27SDimitry Andric  (inst $src0_modifiers, $src0,
95406c3fb27SDimitry Andric        $src1_modifiers, $src1,
95506c3fb27SDimitry Andric        $clamp, /* clamp */
95606c3fb27SDimitry Andric        $omod /* omod */)
95706c3fb27SDimitry Andric>;
95806c3fb27SDimitry Andric
95906c3fb27SDimitry Andriclet OtherPredicates = [NotHasTrue16BitInsts] in
96006c3fb27SDimitry Andricdef : LDEXP_F16_Pat<any_fldexp, V_LDEXP_F16_e64>;
96106c3fb27SDimitry Andric
96206c3fb27SDimitry Andriclet OtherPredicates = [HasTrue16BitInsts] in
96306c3fb27SDimitry Andricdef : LDEXP_F16_Pat<any_fldexp, V_LDEXP_F16_t16_e64>;
96406c3fb27SDimitry Andric
965bdd1243dSDimitry Andriclet SubtargetPredicate = isGFX11Plus in {
966bdd1243dSDimitry Andric  let isCommutable = 1 in {
9675f757f3fSDimitry Andric    defm V_AND_B16_t16 : VOP2Inst_e64 <"v_and_b16_t16", VOPProfile_Fake16<VOP_I16_I16_I16>, and>;
9685f757f3fSDimitry Andric    defm V_OR_B16_t16  : VOP2Inst_e64 <"v_or_b16_t16", VOPProfile_Fake16<VOP_I16_I16_I16>, or>;
9695f757f3fSDimitry Andric    defm V_XOR_B16_t16 : VOP2Inst_e64 <"v_xor_b16_t16", VOPProfile_Fake16<VOP_I16_I16_I16>, xor>;
970bdd1243dSDimitry Andric  } // End isCommutable = 1
971bdd1243dSDimitry Andric} // End SubtargetPredicate = isGFX11Plus
972bdd1243dSDimitry Andric
9735f757f3fSDimitry Andriclet FPDPRounding = 1, isReMaterializable = 1, FixedSize = 1 in {
974*0fca6ea1SDimitry Andriclet SubtargetPredicate = isGFX10Plus, True16Predicate = NotHasTrue16BitInsts in {
975bdd1243dSDimitry Andricdef V_FMAMK_F16 : VOP2_Pseudo <"v_fmamk_f16", VOP_MADMK_F16, [], "">;
976bdd1243dSDimitry Andric}
977bdd1243dSDimitry Andriclet SubtargetPredicate = HasTrue16BitInsts in {
978bdd1243dSDimitry Andricdef V_FMAMK_F16_t16 : VOP2_Pseudo <"v_fmamk_f16_t16", VOP_MADMK_F16_t16, [], "">;
979bdd1243dSDimitry Andric}
980bdd1243dSDimitry Andric
981bdd1243dSDimitry Andriclet isCommutable = 1 in {
982*0fca6ea1SDimitry Andriclet SubtargetPredicate = isGFX10Plus, True16Predicate = NotHasTrue16BitInsts in {
983bdd1243dSDimitry Andricdef V_FMAAK_F16 : VOP2_Pseudo <"v_fmaak_f16", VOP_MADAK_F16, [], "">;
984bdd1243dSDimitry Andric}
985bdd1243dSDimitry Andriclet SubtargetPredicate = HasTrue16BitInsts in {
986bdd1243dSDimitry Andricdef V_FMAAK_F16_t16 : VOP2_Pseudo <"v_fmaak_f16_t16", VOP_MADAK_F16_t16, [], "">;
987bdd1243dSDimitry Andric}
988bdd1243dSDimitry Andric} // End isCommutable = 1
9895f757f3fSDimitry Andric} // End FPDPRounding  = 1, isReMaterializable = 1, FixedSize = 1
990bdd1243dSDimitry Andric
991bdd1243dSDimitry Andriclet Constraints = "$vdst = $src2",
992bdd1243dSDimitry Andric    DisableEncoding="$src2",
993bdd1243dSDimitry Andric    isConvertibleToThreeAddress = 1,
994bdd1243dSDimitry Andric    isCommutable = 1 in {
995*0fca6ea1SDimitry Andriclet SubtargetPredicate = isGFX10Plus, True16Predicate = NotHasTrue16BitInsts in {
996bdd1243dSDimitry Andricdefm V_FMAC_F16 : VOP2Inst <"v_fmac_f16", VOP_MAC_F16>;
997bdd1243dSDimitry Andric}
998bdd1243dSDimitry Andriclet SubtargetPredicate = HasTrue16BitInsts in {
999bdd1243dSDimitry Andricdefm V_FMAC_F16_t16 : VOP2Inst <"v_fmac_f16_t16", VOP_MAC_F16_t16>;
1000bdd1243dSDimitry Andric}
1001bdd1243dSDimitry Andric} // End FMAC Constraints
10020b57cec5SDimitry Andric
100381ad6265SDimitry Andriclet SubtargetPredicate = Has16BitInsts in {
100481ad6265SDimitry Andriclet isReMaterializable = 1 in {
10050b57cec5SDimitry Andriclet FPDPRounding = 1 in {
10060b57cec5SDimitry Andricdef V_MADMK_F16 : VOP2_Pseudo <"v_madmk_f16", VOP_MADMK_F16, [], "">;
10070b57cec5SDimitry Andric} // End FPDPRounding = 1
10080b57cec5SDimitry Andriclet isCommutable = 1 in {
10095ffd83dbSDimitry Andriclet mayRaiseFPException = 0 in {
10100b57cec5SDimitry Andricdef V_MADAK_F16 : VOP2_Pseudo <"v_madak_f16", VOP_MADAK_F16, [], "">;
10115ffd83dbSDimitry Andric}
101281ad6265SDimitry Andriclet SubtargetPredicate = isGFX8GFX9 in {
101381ad6265SDimitry Andric  defm V_ADD_U16 : VOP2Inst <"v_add_u16", VOP_I16_I16_I16_ARITH, add>;
101481ad6265SDimitry Andric  defm V_SUB_U16 : VOP2Inst <"v_sub_u16" , VOP_I16_I16_I16_ARITH, sub>;
101581ad6265SDimitry Andric  defm V_SUBREV_U16 : VOP2Inst <"v_subrev_u16", VOP_I16_I16_I16_ARITH, null_frag, "v_sub_u16">;
10160b57cec5SDimitry Andric}
10170b57cec5SDimitry Andric} // End isCommutable = 1
101881ad6265SDimitry Andric} // End isReMaterializable = 1
10190b57cec5SDimitry Andric
102081ad6265SDimitry Andric// FIXME: Missing FPDPRounding
102181ad6265SDimitry Andriclet Constraints = "$vdst = $src2", DisableEncoding="$src2",
102281ad6265SDimitry Andric    isConvertibleToThreeAddress = 1, isCommutable = 1 in {
102381ad6265SDimitry Andricdefm V_MAC_F16 : VOP2Inst <"v_mac_f16", VOP_MAC_F16>;
102481ad6265SDimitry Andric}
10250b57cec5SDimitry Andric} // End SubtargetPredicate = Has16BitInsts
10260b57cec5SDimitry Andric
1027bdd1243dSDimitry Andric
10280b57cec5SDimitry Andriclet SubtargetPredicate = HasDLInsts in {
10290b57cec5SDimitry Andric
1030fe6060f1SDimitry Andriclet isReMaterializable = 1 in
1031fe6060f1SDimitry Andricdefm V_XNOR_B32 : VOP2Inst <"v_xnor_b32", VOP_I32_I32_I32, xnor>;
10320b57cec5SDimitry Andric
103304eeddc0SDimitry Andricdef : GCNPat<
103404eeddc0SDimitry Andric  (i32 (DivergentUnaryFrag<not> (xor_oneuse i32:$src0, i32:$src1))),
103504eeddc0SDimitry Andric  (i32 (V_XNOR_B32_e64 $src0, $src1))
103604eeddc0SDimitry Andric>;
103704eeddc0SDimitry Andric
103804eeddc0SDimitry Andricdef : GCNPat<
103904eeddc0SDimitry Andric  (i32 (DivergentBinFrag<xor_oneuse> (not i32:$src0), i32:$src1)),
104004eeddc0SDimitry Andric  (i32 (V_XNOR_B32_e64 $src0, $src1))
104104eeddc0SDimitry Andric>;
104204eeddc0SDimitry Andric
104304eeddc0SDimitry Andricdef : GCNPat<
104404eeddc0SDimitry Andric  (i64 (DivergentUnaryFrag<not> (xor_oneuse i64:$src0, i64:$src1))),
104504eeddc0SDimitry Andric  (REG_SEQUENCE VReg_64, (i32 (V_XNOR_B32_e64
104604eeddc0SDimitry Andric                            (i32 (EXTRACT_SUBREG $src0, sub0)),
104704eeddc0SDimitry Andric                            (i32 (EXTRACT_SUBREG $src1, sub0)))), sub0,
104804eeddc0SDimitry Andric                     (i32 (V_XNOR_B32_e64
104904eeddc0SDimitry Andric                            (i32 (EXTRACT_SUBREG $src0, sub1)),
105004eeddc0SDimitry Andric                            (i32 (EXTRACT_SUBREG $src1, sub1)))), sub1)
105104eeddc0SDimitry Andric>;
105204eeddc0SDimitry Andric
105304eeddc0SDimitry Andricdef : GCNPat<
105404eeddc0SDimitry Andric  (i64 (DivergentBinFrag<xor_oneuse> (not i64:$src0), i64:$src1)),
105504eeddc0SDimitry Andric  (REG_SEQUENCE VReg_64, (i32 (V_XNOR_B32_e64
105604eeddc0SDimitry Andric                            (i32 (EXTRACT_SUBREG $src0, sub0)),
105704eeddc0SDimitry Andric                            (i32 (EXTRACT_SUBREG $src1, sub0)))), sub0,
105804eeddc0SDimitry Andric                     (i32 (V_XNOR_B32_e64
105904eeddc0SDimitry Andric                            (i32 (EXTRACT_SUBREG $src0, sub1)),
106004eeddc0SDimitry Andric                            (i32 (EXTRACT_SUBREG $src1, sub1)))), sub1)
106104eeddc0SDimitry Andric>;
106204eeddc0SDimitry Andric
10630b57cec5SDimitry Andriclet Constraints = "$vdst = $src2",
10640b57cec5SDimitry Andric    DisableEncoding = "$src2",
10650b57cec5SDimitry Andric    isConvertibleToThreeAddress = 1,
1066e8d8bef9SDimitry Andric    isCommutable = 1 in
106781ad6265SDimitry Andricdefm V_FMAC_F32 : VOP2Inst_VOPD <"v_fmac_f32", VOP_MAC_F32, 0x0, "v_fmac_f32">;
10680b57cec5SDimitry Andric} // End SubtargetPredicate = HasDLInsts
10690b57cec5SDimitry Andric
1070e8d8bef9SDimitry Andriclet SubtargetPredicate = HasFmaLegacy32 in {
1071e8d8bef9SDimitry Andric
1072e8d8bef9SDimitry Andriclet Constraints = "$vdst = $src2",
1073e8d8bef9SDimitry Andric    DisableEncoding = "$src2",
1074e8d8bef9SDimitry Andric    isConvertibleToThreeAddress = 1,
1075e8d8bef9SDimitry Andric    isCommutable = 1 in
1076e8d8bef9SDimitry Andricdefm V_FMAC_LEGACY_F32 : VOP2Inst <"v_fmac_legacy_f32", VOP_MAC_LEGACY_F32>;
1077e8d8bef9SDimitry Andric
1078e8d8bef9SDimitry Andric} // End SubtargetPredicate = HasFmaLegacy32
1079e8d8bef9SDimitry Andric
1080bdd1243dSDimitry Andriclet SubtargetPredicate = HasFmacF64Inst,
1081fe6060f1SDimitry Andric    Constraints = "$vdst = $src2",
1082fe6060f1SDimitry Andric    DisableEncoding="$src2",
1083fe6060f1SDimitry Andric    isConvertibleToThreeAddress = 1,
1084fe6060f1SDimitry Andric    isCommutable = 1,
1085fe6060f1SDimitry Andric    SchedRW = [WriteDoubleAdd] in
1086fe6060f1SDimitry Andricdefm V_FMAC_F64 : VOP2Inst <"v_fmac_f64", VOP_MAC_F64>;
1087fe6060f1SDimitry Andric
10880b57cec5SDimitry Andriclet Constraints = "$vdst = $src2",
10890b57cec5SDimitry Andric      DisableEncoding="$src2",
10900b57cec5SDimitry Andric      isConvertibleToThreeAddress = 1,
10918bcb0991SDimitry Andric      isCommutable = 1,
10928bcb0991SDimitry Andric      IsDOT = 1 in {
10930b57cec5SDimitry Andric  let SubtargetPredicate = HasDot5Insts in
109481ad6265SDimitry Andric    defm V_DOT2C_F32_F16 : VOP2Inst_VOPD<"v_dot2c_f32_f16", VOP_DOT_ACC_F32_V2F16, 0xc, "v_dot2acc_f32_f16">;
10950b57cec5SDimitry Andric  let SubtargetPredicate = HasDot6Insts in
10968bcb0991SDimitry Andric    defm V_DOT4C_I32_I8  : VOP2Inst<"v_dot4c_i32_i8",  VOP_DOT_ACC_I32_I32>;
10970b57cec5SDimitry Andric
10980b57cec5SDimitry Andric  let SubtargetPredicate = HasDot4Insts in
10998bcb0991SDimitry Andric    defm V_DOT2C_I32_I16 : VOP2Inst<"v_dot2c_i32_i16", VOP_DOT_ACC_I32_I32>;
11000b57cec5SDimitry Andric  let SubtargetPredicate = HasDot3Insts in
11018bcb0991SDimitry Andric    defm V_DOT8C_I32_I4  : VOP2Inst<"v_dot8c_i32_i4",  VOP_DOT_ACC_I32_I32>;
11020b57cec5SDimitry Andric}
11030b57cec5SDimitry Andric
11040b57cec5SDimitry Andriclet AddedComplexity = 30 in {
11050b57cec5SDimitry Andric  def : GCNPat<
11060b57cec5SDimitry Andric    (f32 (AMDGPUfdot2 v2f16:$src0, v2f16:$src1, f32:$src2, (i1 DSTCLAMP.NONE))),
11070b57cec5SDimitry Andric    (f32 (V_DOT2C_F32_F16_e32 $src0, $src1, $src2))
11080b57cec5SDimitry Andric  > {
11090b57cec5SDimitry Andric    let SubtargetPredicate = HasDot5Insts;
11100b57cec5SDimitry Andric  }
11110b57cec5SDimitry Andric  def : GCNPat<
11120b57cec5SDimitry Andric    (i32 (int_amdgcn_sdot4 i32:$src0, i32:$src1, i32:$src2, (i1 DSTCLAMP.NONE))),
11130b57cec5SDimitry Andric    (i32 (V_DOT4C_I32_I8_e32 $src0, $src1, $src2))
11140b57cec5SDimitry Andric  > {
11150b57cec5SDimitry Andric    let SubtargetPredicate = HasDot6Insts;
11160b57cec5SDimitry Andric  }
11170b57cec5SDimitry Andric  def : GCNPat<
11180b57cec5SDimitry Andric    (i32 (int_amdgcn_sdot2 v2i16:$src0, v2i16:$src1, i32:$src2, (i1 DSTCLAMP.NONE))),
11190b57cec5SDimitry Andric    (i32 (V_DOT2C_I32_I16_e32 $src0, $src1, $src2))
11200b57cec5SDimitry Andric  > {
11210b57cec5SDimitry Andric    let SubtargetPredicate = HasDot4Insts;
11220b57cec5SDimitry Andric  }
11230b57cec5SDimitry Andric  def : GCNPat<
11240b57cec5SDimitry Andric    (i32 (int_amdgcn_sdot8 i32:$src0, i32:$src1, i32:$src2, (i1 DSTCLAMP.NONE))),
11250b57cec5SDimitry Andric    (i32 (V_DOT8C_I32_I4_e32 $src0, $src1, $src2))
11260b57cec5SDimitry Andric  > {
11270b57cec5SDimitry Andric    let SubtargetPredicate = HasDot3Insts;
11280b57cec5SDimitry Andric  }
11290b57cec5SDimitry Andric} // End AddedComplexity = 30
11300b57cec5SDimitry Andric
11315f757f3fSDimitry Andriclet SubtargetPredicate = HasFmaakFmamkF32Insts, isReMaterializable = 1, FixedSize = 1 in {
113281ad6265SDimitry Andricdef V_FMAMK_F32 : VOP2_Pseudo<"v_fmamk_f32", VOP_MADMK_F32, [], "">, VOPD_Component<0x2, "v_fmamk_f32">;
1133fe6060f1SDimitry Andric
1134fe6060f1SDimitry Andriclet isCommutable = 1 in
113581ad6265SDimitry Andricdef V_FMAAK_F32 : VOP2_Pseudo<"v_fmaak_f32", VOP_MADAK_F32, [], "">, VOPD_Component<0x1, "v_fmaak_f32">;
11365f757f3fSDimitry Andric} // End SubtargetPredicate = HasFmaakFmamkF32Insts, isReMaterializable = 1, FixedSize = 1
1137fe6060f1SDimitry Andric
11380b57cec5SDimitry Andriclet SubtargetPredicate = HasPkFmacF16Inst in {
11390b57cec5SDimitry Andricdefm V_PK_FMAC_F16 : VOP2Inst<"v_pk_fmac_f16", VOP_V2F16_V2F16_V2F16>;
11400b57cec5SDimitry Andric} // End SubtargetPredicate = HasPkFmacF16Inst
11410b57cec5SDimitry Andric
11420b57cec5SDimitry Andric// Note: 16-bit instructions produce a 0 result in the high 16-bits
11430b57cec5SDimitry Andric// on GFX8 and GFX9 and preserve high 16 bits on GFX10+
11448bcb0991SDimitry Andricmulticlass Arithmetic_i16_0Hi_Pats <SDPatternOperator op, Instruction inst> {
11450b57cec5SDimitry Andric
11460b57cec5SDimitry Andricdef : GCNPat<
11470b57cec5SDimitry Andric  (i32 (zext (op i16:$src0, i16:$src1))),
1148480093f4SDimitry Andric  (inst VSrc_b16:$src0, VSrc_b16:$src1)
11490b57cec5SDimitry Andric>;
11500b57cec5SDimitry Andric
11510b57cec5SDimitry Andricdef : GCNPat<
11520b57cec5SDimitry Andric  (i64 (zext (op i16:$src0, i16:$src1))),
11530b57cec5SDimitry Andric   (REG_SEQUENCE VReg_64,
11548bcb0991SDimitry Andric     (inst $src0, $src1), sub0,
11550b57cec5SDimitry Andric     (V_MOV_B32_e32 (i32 0)), sub1)
11560b57cec5SDimitry Andric>;
11570b57cec5SDimitry Andric}
11580b57cec5SDimitry Andric
11590b57cec5SDimitry Andricclass ZExt_i16_i1_Pat <SDNode ext> : GCNPat <
11600b57cec5SDimitry Andric  (i16 (ext i1:$src)),
11610b57cec5SDimitry Andric  (V_CNDMASK_B32_e64 (i32 0/*src0mod*/), (i32 0/*src0*/),
11620b57cec5SDimitry Andric                     (i32 0/*src1mod*/), (i32 1/*src1*/),
11630b57cec5SDimitry Andric                     $src)
11640b57cec5SDimitry Andric>;
11650b57cec5SDimitry Andric
11668bcb0991SDimitry Andricforeach vt = [i16, v2i16] in {
11678bcb0991SDimitry Andricdef : GCNPat <
11688bcb0991SDimitry Andric  (and vt:$src0, vt:$src1),
11698bcb0991SDimitry Andric  (V_AND_B32_e64 VSrc_b32:$src0, VSrc_b32:$src1)
11708bcb0991SDimitry Andric>;
11718bcb0991SDimitry Andric
11728bcb0991SDimitry Andricdef : GCNPat <
11738bcb0991SDimitry Andric  (or vt:$src0, vt:$src1),
11748bcb0991SDimitry Andric  (V_OR_B32_e64 VSrc_b32:$src0, VSrc_b32:$src1)
11758bcb0991SDimitry Andric>;
11768bcb0991SDimitry Andric
11778bcb0991SDimitry Andricdef : GCNPat <
11788bcb0991SDimitry Andric  (xor vt:$src0, vt:$src1),
11798bcb0991SDimitry Andric  (V_XOR_B32_e64 VSrc_b32:$src0, VSrc_b32:$src1)
11808bcb0991SDimitry Andric>;
11818bcb0991SDimitry Andric}
11828bcb0991SDimitry Andric
118381ad6265SDimitry Andriclet Predicates = [Has16BitInsts, isGFX8GFX9] in {
11840b57cec5SDimitry Andric
1185480093f4SDimitry Andric// Undo sub x, c -> add x, -c canonicalization since c is more likely
1186480093f4SDimitry Andric// an inline immediate than -c.
1187480093f4SDimitry Andric// TODO: Also do for 64-bit.
1188480093f4SDimitry Andricdef : GCNPat<
11895ffd83dbSDimitry Andric  (add i16:$src0, (i16 NegSubInlineIntConst16:$src1)),
11905ffd83dbSDimitry Andric  (V_SUB_U16_e64 VSrc_b16:$src0, NegSubInlineIntConst16:$src1)
1191480093f4SDimitry Andric>;
1192480093f4SDimitry Andric
1193480093f4SDimitry Andricdef : GCNPat<
11945ffd83dbSDimitry Andric  (i32 (zext (add i16:$src0, (i16 NegSubInlineIntConst16:$src1)))),
11955ffd83dbSDimitry Andric  (V_SUB_U16_e64 VSrc_b16:$src0, NegSubInlineIntConst16:$src1)
1196480093f4SDimitry Andric>;
1197480093f4SDimitry Andric
11988bcb0991SDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<add, V_ADD_U16_e64>;
11998bcb0991SDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<mul, V_MUL_LO_U16_e64>;
12008bcb0991SDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<sub, V_SUB_U16_e64>;
12018bcb0991SDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<smin, V_MIN_I16_e64>;
12028bcb0991SDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<smax, V_MAX_I16_e64>;
12038bcb0991SDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<umin, V_MIN_U16_e64>;
12048bcb0991SDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<umax, V_MAX_U16_e64>;
1205349cc55cSDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<clshl_rev_16, V_LSHLREV_B16_e64>;
1206349cc55cSDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<clshr_rev_16, V_LSHRREV_B16_e64>;
1207349cc55cSDimitry Andricdefm : Arithmetic_i16_0Hi_Pats<cashr_rev_16, V_ASHRREV_I16_e64>;
120881ad6265SDimitry Andric
120981ad6265SDimitry Andric}  // End Predicates = [Has16BitInsts, isGFX8GFX9]
121081ad6265SDimitry Andric
121181ad6265SDimitry Andriclet Predicates = [Has16BitInsts] in {
12120b57cec5SDimitry Andric
12130b57cec5SDimitry Andricdef : ZExt_i16_i1_Pat<zext>;
12140b57cec5SDimitry Andricdef : ZExt_i16_i1_Pat<anyext>;
12150b57cec5SDimitry Andric
12160b57cec5SDimitry Andricdef : GCNPat <
12170b57cec5SDimitry Andric  (i16 (sext i1:$src)),
12180b57cec5SDimitry Andric  (V_CNDMASK_B32_e64 /*src0mod*/(i32 0), /*src0*/(i32 0),
12190b57cec5SDimitry Andric                     /*src1mod*/(i32 0), /*src1*/(i32 -1), $src)
12200b57cec5SDimitry Andric>;
12210b57cec5SDimitry Andric
1222480093f4SDimitry Andric} // End Predicates = [Has16BitInsts]
12230b57cec5SDimitry Andric
12240b57cec5SDimitry Andric
1225e8d8bef9SDimitry Andriclet SubtargetPredicate = HasIntClamp in {
1226e8d8bef9SDimitry Andric// Set clamp bit for saturation.
1227e8d8bef9SDimitry Andricdef : VOPBinOpClampPat<uaddsat, V_ADD_CO_U32_e64, i32>;
1228e8d8bef9SDimitry Andricdef : VOPBinOpClampPat<usubsat, V_SUB_CO_U32_e64, i32>;
1229e8d8bef9SDimitry Andric}
1230e8d8bef9SDimitry Andric
1231e8d8bef9SDimitry Andriclet SubtargetPredicate = HasAddNoCarryInsts, OtherPredicates = [HasIntClamp] in {
1232e8d8bef9SDimitry Andriclet AddedComplexity = 1 in { // Prefer over form with carry-out.
1233e8d8bef9SDimitry Andricdef : VOPBinOpClampPat<uaddsat, V_ADD_U32_e64, i32>;
1234e8d8bef9SDimitry Andricdef : VOPBinOpClampPat<usubsat, V_SUB_U32_e64, i32>;
1235e8d8bef9SDimitry Andric}
1236e8d8bef9SDimitry Andric}
1237e8d8bef9SDimitry Andric
1238e8d8bef9SDimitry Andriclet SubtargetPredicate = Has16BitInsts, OtherPredicates = [HasIntClamp] in {
1239e8d8bef9SDimitry Andricdef : VOPBinOpClampPat<uaddsat, V_ADD_U16_e64, i16>;
1240e8d8bef9SDimitry Andricdef : VOPBinOpClampPat<usubsat, V_SUB_U16_e64, i16>;
1241e8d8bef9SDimitry Andric}
1242e8d8bef9SDimitry Andric
12435f757f3fSDimitry Andriclet SubtargetPredicate = isGFX12Plus, isReMaterializable = 1 in {
12445f757f3fSDimitry Andric  let SchedRW = [WriteDoubleAdd], isCommutable = 1 in {
12455f757f3fSDimitry Andric    let FPDPRounding = 1 in {
12465f757f3fSDimitry Andric      defm V_ADD_F64_pseudo : VOP2Inst <"v_add_f64_pseudo", VOP_F64_F64_F64, any_fadd>;
12475f757f3fSDimitry Andric      defm V_MUL_F64_pseudo : VOP2Inst <"v_mul_f64_pseudo", VOP_F64_F64_F64, fmul>;
12485f757f3fSDimitry Andric    } // End FPDPRounding = 1
12495f757f3fSDimitry Andric    defm V_MIN_NUM_F64 : VOP2Inst <"v_min_num_f64", VOP_F64_F64_F64, fminnum_like>;
12505f757f3fSDimitry Andric    defm V_MAX_NUM_F64 : VOP2Inst <"v_max_num_f64", VOP_F64_F64_F64, fmaxnum_like>;
12515f757f3fSDimitry Andric  } // End SchedRW = [WriteDoubleAdd], isCommutable = 1
12525f757f3fSDimitry Andric  let SchedRW = [Write64Bit] in {
12535f757f3fSDimitry Andric    defm V_LSHLREV_B64_pseudo : VOP2Inst <"v_lshlrev_b64_pseudo", VOP_I64_I32_I64, clshl_rev_64>;
12545f757f3fSDimitry Andric  } // End SchedRW = [Write64Bit]
12555f757f3fSDimitry Andric} // End SubtargetPredicate = isGFX12Plus, isReMaterializable = 1
12565f757f3fSDimitry Andric
12570b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
125881ad6265SDimitry Andric// DPP Encodings
12590b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
12600b57cec5SDimitry Andric
12618bcb0991SDimitry Andricclass VOP2_DPP<bits<6> op, VOP2_DPP_Pseudo ps,
12620b57cec5SDimitry Andric               string opName = ps.OpName, VOPProfile p = ps.Pfl,
12630b57cec5SDimitry Andric               bit IsDPP16 = 0> :
12640b57cec5SDimitry Andric    VOP_DPP<opName, p, IsDPP16> {
12650b57cec5SDimitry Andric  let hasSideEffects = ps.hasSideEffects;
12660b57cec5SDimitry Andric  let Defs = ps.Defs;
12670b57cec5SDimitry Andric  let SchedRW = ps.SchedRW;
12680b57cec5SDimitry Andric  let Uses = ps.Uses;
12690b57cec5SDimitry Andric
12700b57cec5SDimitry Andric  bits<8> vdst;
12710b57cec5SDimitry Andric  bits<8> src1;
12720b57cec5SDimitry Andric  let Inst{8-0}   = 0xfa;
12730b57cec5SDimitry Andric  let Inst{16-9}  = !if(p.HasSrc1, src1{7-0}, 0);
12740b57cec5SDimitry Andric  let Inst{24-17} = !if(p.EmitDst, vdst{7-0}, 0);
12750b57cec5SDimitry Andric  let Inst{30-25} = op;
12760b57cec5SDimitry Andric  let Inst{31}    = 0x0;
12770b57cec5SDimitry Andric}
12780b57cec5SDimitry Andric
12798bcb0991SDimitry Andricclass Base_VOP2_DPP16<bits<6> op, VOP2_DPP_Pseudo ps,
12800b57cec5SDimitry Andric                 string opName = ps.OpName, VOPProfile p = ps.Pfl> :
12810b57cec5SDimitry Andric    VOP2_DPP<op, ps, opName, p, 1> {
12825ffd83dbSDimitry Andric  let AssemblerPredicate = HasDPP16;
1283*0fca6ea1SDimitry Andric  let SubtargetPredicate = ps.SubtargetPredicate;
1284e8d8bef9SDimitry Andric  let OtherPredicates = ps.OtherPredicates;
12850b57cec5SDimitry Andric}
12860b57cec5SDimitry Andric
128781ad6265SDimitry Andricclass VOP2_DPP16<bits<6> op, VOP2_DPP_Pseudo ps, int subtarget,
12888bcb0991SDimitry Andric                 string opName = ps.OpName, VOPProfile p = ps.Pfl> :
12898bcb0991SDimitry Andric    Base_VOP2_DPP16<op, ps, opName, p>,
129081ad6265SDimitry Andric    SIMCInstr <ps.PseudoInstr, subtarget>;
12918bcb0991SDimitry Andric
12925f757f3fSDimitry Andricclass VOP2_DPP16_Gen<bits<6> op, VOP2_DPP_Pseudo ps, GFXGen Gen,
12935f757f3fSDimitry Andric                 string opName = ps.OpName, VOPProfile p = ps.Pfl> :
12945f757f3fSDimitry Andric    VOP2_DPP16<op, ps, Gen.Subtarget, opName, p> {
1295297eecfbSDimitry Andric  let AssemblerPredicate = Gen.AssemblerPredicate;
1296*0fca6ea1SDimitry Andric  let True16Predicate = !if(ps.Pfl.IsRealTrue16, UseRealTrue16Insts, NoTrue16Predicate);
1297*0fca6ea1SDimitry Andric  let DecoderNamespace = Gen.DecoderNamespace#
12985f757f3fSDimitry Andric                         !if(ps.Pfl.IsRealTrue16, "", "_FAKE16");
12995f757f3fSDimitry Andric}
13005f757f3fSDimitry Andric
13010b57cec5SDimitry Andricclass VOP2_DPP8<bits<6> op, VOP2_Pseudo ps,
1302349cc55cSDimitry Andric                VOPProfile p = ps.Pfl> :
13030b57cec5SDimitry Andric    VOP_DPP8<ps.OpName, p> {
13040b57cec5SDimitry Andric  let hasSideEffects = ps.hasSideEffects;
13050b57cec5SDimitry Andric  let Defs = ps.Defs;
13060b57cec5SDimitry Andric  let SchedRW = ps.SchedRW;
13070b57cec5SDimitry Andric  let Uses = ps.Uses;
13080b57cec5SDimitry Andric
13090b57cec5SDimitry Andric  bits<8> vdst;
13100b57cec5SDimitry Andric  bits<8> src1;
13110b57cec5SDimitry Andric
13120b57cec5SDimitry Andric  let Inst{8-0}   = fi;
13130b57cec5SDimitry Andric  let Inst{16-9}  = !if(p.HasSrc1, src1{7-0}, 0);
13140b57cec5SDimitry Andric  let Inst{24-17} = !if(p.EmitDst, vdst{7-0}, 0);
13150b57cec5SDimitry Andric  let Inst{30-25} = op;
13160b57cec5SDimitry Andric  let Inst{31}    = 0x0;
13170b57cec5SDimitry Andric
1318*0fca6ea1SDimitry Andric  let SubtargetPredicate = ps.SubtargetPredicate;
1319e8d8bef9SDimitry Andric  let OtherPredicates = ps.OtherPredicates;
13200b57cec5SDimitry Andric}
13210b57cec5SDimitry Andric
13225f757f3fSDimitry Andricclass VOP2_DPP8_Gen<bits<6> op, VOP2_Pseudo ps, GFXGen Gen,
13235f757f3fSDimitry Andric                    VOPProfile p = ps.Pfl> :
13245f757f3fSDimitry Andric    VOP2_DPP8<op, ps, p> {
1325297eecfbSDimitry Andric  let AssemblerPredicate = Gen.AssemblerPredicate;
1326*0fca6ea1SDimitry Andric  let True16Predicate = !if(ps.Pfl.IsRealTrue16, UseRealTrue16Insts, NoTrue16Predicate);
1327*0fca6ea1SDimitry Andric  let DecoderNamespace = Gen.DecoderNamespace#
13285f757f3fSDimitry Andric                         !if(ps.Pfl.IsRealTrue16, "", "_FAKE16");
13295f757f3fSDimitry Andric}
13305f757f3fSDimitry Andric
13310b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
13325f757f3fSDimitry Andric// GFX11, GFX12
133381ad6265SDimitry Andric//===----------------------------------------------------------------------===//
133481ad6265SDimitry Andric
133581ad6265SDimitry Andric//===------------------------------- VOP2 -------------------------------===//
13365f757f3fSDimitry Andricmulticlass VOP2Only_Real_MADK<GFXGen Gen, bits<6> op> {
13375f757f3fSDimitry Andric  def Gen.Suffix :
13385f757f3fSDimitry Andric    VOP2_Real_Gen<!cast<VOP2_Pseudo>(NAME), Gen>,
133981ad6265SDimitry Andric    VOP2_MADKe<op{5-0}, !cast<VOP2_Pseudo>(NAME).Pfl>;
134081ad6265SDimitry Andric}
13415f757f3fSDimitry Andric
13425f757f3fSDimitry Andricmulticlass VOP2Only_Real_MADK_with_name<GFXGen Gen, bits<6> op, string asmName,
1343bdd1243dSDimitry Andric                                        string opName = NAME> {
13445f757f3fSDimitry Andric  def Gen.Suffix :
13455f757f3fSDimitry Andric      VOP2_Real_Gen<!cast<VOP2_Pseudo>(opName), Gen>,
1346bdd1243dSDimitry Andric      VOP2_MADKe<op{5-0}, !cast<VOP2_Pseudo>(opName).Pfl> {
1347bdd1243dSDimitry Andric    VOP2_Pseudo ps = !cast<VOP2_Pseudo>(opName);
1348bdd1243dSDimitry Andric    let AsmString = asmName # ps.AsmOperands;
1349bdd1243dSDimitry Andric  }
1350bdd1243dSDimitry Andric}
13515f757f3fSDimitry Andric
13525f757f3fSDimitry Andricmulticlass VOP2_Real_e32<GFXGen Gen, bits<6> op> {
13535f757f3fSDimitry Andric  def _e32#Gen.Suffix :
13545f757f3fSDimitry Andric    VOP2_Real_Gen<!cast<VOP2_Pseudo>(NAME#"_e32"), Gen>,
135581ad6265SDimitry Andric    VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME#"_e32").Pfl>;
135681ad6265SDimitry Andric}
13575f757f3fSDimitry Andric
13585f757f3fSDimitry Andricmulticlass VOP2Only_Real_e32<GFXGen Gen, bits<6> op> {
135981ad6265SDimitry Andric  let IsSingle = 1 in
13605f757f3fSDimitry Andric    defm NAME: VOP2_Real_e32<Gen, op>;
136181ad6265SDimitry Andric}
13625f757f3fSDimitry Andric
13635f757f3fSDimitry Andricmulticlass VOP2_Real_e64<GFXGen Gen, bits<6> op> {
13645f757f3fSDimitry Andric  def _e64#Gen.Suffix :
13655f757f3fSDimitry Andric    VOP3_Real_Gen<!cast<VOP3_Pseudo>(NAME#"_e64"), Gen>,
13665f757f3fSDimitry Andric    VOP3e_gfx11_gfx12<{0, 1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
136781ad6265SDimitry Andric}
13685f757f3fSDimitry Andric
13695f757f3fSDimitry Andricmulticlass VOP2_Real_dpp<GFXGen Gen, bits<6> op> {
137006c3fb27SDimitry Andric  if !cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtDPP then
13715f757f3fSDimitry Andric  def _dpp#Gen.Suffix : VOP2_DPP16_Gen<op, !cast<VOP2_DPP_Pseudo>(NAME#"_dpp"), Gen>;
137281ad6265SDimitry Andric}
13735f757f3fSDimitry Andric
13745f757f3fSDimitry Andricmulticlass VOP2_Real_dpp8<GFXGen Gen, bits<6> op> {
137506c3fb27SDimitry Andric  if !cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtDPP then
13765f757f3fSDimitry Andric  def _dpp8#Gen.Suffix : VOP2_DPP8_Gen<op, !cast<VOP2_Pseudo>(NAME#"_e32"), Gen>;
137781ad6265SDimitry Andric}
137881ad6265SDimitry Andric
137981ad6265SDimitry Andric//===------------------------- VOP2 (with name) -------------------------===//
13805f757f3fSDimitry Andricmulticlass VOP2_Real_e32_with_name<GFXGen Gen, bits<6> op, string opName,
138181ad6265SDimitry Andric                                   string asmName, bit single = 0> {
138281ad6265SDimitry Andric  defvar ps = !cast<VOP2_Pseudo>(opName#"_e32");
13835f757f3fSDimitry Andric  def _e32#Gen.Suffix :
13845f757f3fSDimitry Andric    VOP2_Real_Gen<ps, Gen, asmName>,
1385bdd1243dSDimitry Andric    VOP2e<op{5-0}, ps.Pfl> {
138681ad6265SDimitry Andric      let AsmString = asmName # ps.AsmOperands;
138781ad6265SDimitry Andric      let IsSingle = single;
138881ad6265SDimitry Andric    }
138981ad6265SDimitry Andric}
13905f757f3fSDimitry Andricmulticlass VOP2_Real_e64_with_name<GFXGen Gen, bits<6> op, string opName,
139181ad6265SDimitry Andric                                   string asmName> {
139281ad6265SDimitry Andric  defvar ps = !cast<VOP3_Pseudo>(opName#"_e64");
13935f757f3fSDimitry Andric  def _e64#Gen.Suffix :
13945f757f3fSDimitry Andric    VOP3_Real_Gen<ps, Gen>,
13955f757f3fSDimitry Andric    VOP3e_gfx11_gfx12<{0, 1, 0, 0, op{5-0}}, ps.Pfl> {
139681ad6265SDimitry Andric      let AsmString = asmName # ps.AsmOperands;
139781ad6265SDimitry Andric    }
139881ad6265SDimitry Andric}
139981ad6265SDimitry Andric
14005f757f3fSDimitry Andricmulticlass VOP2_Real_dpp_with_name<GFXGen Gen, bits<6> op, string opName,
140181ad6265SDimitry Andric                                   string asmName> {
140281ad6265SDimitry Andric  defvar ps = !cast<VOP2_Pseudo>(opName#"_e32");
140306c3fb27SDimitry Andric  if ps.Pfl.HasExtDPP then
14045f757f3fSDimitry Andric  def _dpp#Gen.Suffix : VOP2_DPP16_Gen<op, !cast<VOP2_DPP_Pseudo>(opName#"_dpp"), Gen> {
140581ad6265SDimitry Andric    let AsmString = asmName # ps.Pfl.AsmDPP16;
140681ad6265SDimitry Andric  }
140781ad6265SDimitry Andric}
14085f757f3fSDimitry Andricmulticlass VOP2_Real_dpp8_with_name<GFXGen Gen, bits<6> op, string opName,
140981ad6265SDimitry Andric                                    string asmName> {
141081ad6265SDimitry Andric  defvar ps = !cast<VOP2_Pseudo>(opName#"_e32");
141106c3fb27SDimitry Andric  if ps.Pfl.HasExtDPP then
14125f757f3fSDimitry Andric  def _dpp8#Gen.Suffix : VOP2_DPP8_Gen<op, ps, Gen> {
141381ad6265SDimitry Andric    let AsmString = asmName # ps.Pfl.AsmDPP8;
141481ad6265SDimitry Andric  }
141581ad6265SDimitry Andric}
141681ad6265SDimitry Andric
141781ad6265SDimitry Andric//===------------------------------ VOP2be ------------------------------===//
14185f757f3fSDimitry Andricmulticlass VOP2be_Real_e32<GFXGen Gen, bits<6> op, string opName, string asmName> {
141981ad6265SDimitry Andric  defvar ps = !cast<VOP2_Pseudo>(opName#"_e32");
14205f757f3fSDimitry Andric  def _e32#Gen.Suffix :
14215f757f3fSDimitry Andric    VOP2_Real_Gen<ps, Gen>,
142281ad6265SDimitry Andric    VOP2e<op{5-0}, ps.Pfl> {
142381ad6265SDimitry Andric      let AsmString = asmName # !subst(", vcc", "", ps.AsmOperands);
142481ad6265SDimitry Andric    }
142581ad6265SDimitry Andric}
14265f757f3fSDimitry Andricmulticlass VOP2be_Real_dpp<GFXGen Gen, bits<6> op, string opName, string asmName> {
142706c3fb27SDimitry Andric  if !cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP then
14285f757f3fSDimitry Andric  def _dpp#Gen.Suffix :
14295f757f3fSDimitry Andric    VOP2_DPP16_Gen<op, !cast<VOP2_DPP_Pseudo>(opName#"_dpp"), Gen, asmName> {
143081ad6265SDimitry Andric      string AsmDPP = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP16;
143181ad6265SDimitry Andric      let AsmString = asmName # !subst(", vcc", "", AsmDPP);
143281ad6265SDimitry Andric    }
143306c3fb27SDimitry Andric  if !cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP then
14345f757f3fSDimitry Andric  def _dpp_w32#Gen.Suffix :
143581ad6265SDimitry Andric    Base_VOP2_DPP16<op, !cast<VOP2_DPP_Pseudo>(opName#"_dpp"), asmName> {
143681ad6265SDimitry Andric      string AsmDPP = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP16;
143781ad6265SDimitry Andric      let AsmString = asmName # !subst("vcc", "vcc_lo", AsmDPP);
143881ad6265SDimitry Andric      let isAsmParserOnly = 1;
143981ad6265SDimitry Andric      let WaveSizePredicate = isWave32;
14405f757f3fSDimitry Andric      let AssemblerPredicate = Gen.AssemblerPredicate;
14415f757f3fSDimitry Andric      let DecoderNamespace = Gen.DecoderNamespace;
144281ad6265SDimitry Andric    }
144306c3fb27SDimitry Andric  if !cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP then
14445f757f3fSDimitry Andric  def _dpp_w64#Gen.Suffix :
144581ad6265SDimitry Andric    Base_VOP2_DPP16<op, !cast<VOP2_DPP_Pseudo>(opName#"_dpp"), asmName> {
144681ad6265SDimitry Andric      string AsmDPP = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP16;
144781ad6265SDimitry Andric      let AsmString = asmName # AsmDPP;
144881ad6265SDimitry Andric      let isAsmParserOnly = 1;
144981ad6265SDimitry Andric      let WaveSizePredicate = isWave64;
14505f757f3fSDimitry Andric      let AssemblerPredicate = Gen.AssemblerPredicate;
14515f757f3fSDimitry Andric      let DecoderNamespace = Gen.DecoderNamespace;
145281ad6265SDimitry Andric    }
145381ad6265SDimitry Andric}
14545f757f3fSDimitry Andricmulticlass VOP2be_Real_dpp8<GFXGen Gen, bits<6> op, string opName, string asmName> {
145506c3fb27SDimitry Andric  if !cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP then
14565f757f3fSDimitry Andric  def _dpp8#Gen.Suffix :
14575f757f3fSDimitry Andric    VOP2_DPP8_Gen<op, !cast<VOP2_Pseudo>(opName#"_e32"), Gen> {
145881ad6265SDimitry Andric      string AsmDPP8 = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP8;
145981ad6265SDimitry Andric      let AsmString = asmName # !subst(", vcc", "", AsmDPP8);
146081ad6265SDimitry Andric    }
146106c3fb27SDimitry Andric  if !cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP then
14625f757f3fSDimitry Andric  def _dpp8_w32#Gen.Suffix :
146381ad6265SDimitry Andric    VOP2_DPP8<op, !cast<VOP2_Pseudo>(opName#"_e32")> {
146481ad6265SDimitry Andric      string AsmDPP8 = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP8;
146581ad6265SDimitry Andric      let AsmString = asmName # !subst("vcc", "vcc_lo", AsmDPP8);
146681ad6265SDimitry Andric      let isAsmParserOnly = 1;
146781ad6265SDimitry Andric      let WaveSizePredicate = isWave32;
14685f757f3fSDimitry Andric      let AssemblerPredicate = Gen.AssemblerPredicate;
14695f757f3fSDimitry Andric      let DecoderNamespace = Gen.DecoderNamespace;
147081ad6265SDimitry Andric    }
147106c3fb27SDimitry Andric  if !cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtDPP then
14725f757f3fSDimitry Andric  def _dpp8_w64#Gen.Suffix :
147381ad6265SDimitry Andric    VOP2_DPP8<op, !cast<VOP2_Pseudo>(opName#"_e32")> {
147481ad6265SDimitry Andric      string AsmDPP8 = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP8;
147581ad6265SDimitry Andric      let AsmString = asmName # AsmDPP8;
147681ad6265SDimitry Andric      let isAsmParserOnly = 1;
147781ad6265SDimitry Andric      let WaveSizePredicate = isWave64;
14785f757f3fSDimitry Andric      let AssemblerPredicate = Gen.AssemblerPredicate;
14795f757f3fSDimitry Andric      let DecoderNamespace = Gen.DecoderNamespace;
148081ad6265SDimitry Andric    }
148181ad6265SDimitry Andric}
148281ad6265SDimitry Andric
148381ad6265SDimitry Andric// We don't want to override separate decoderNamespaces within these
14845f757f3fSDimitry Andricmulticlass VOP2_Realtriple_e64<GFXGen Gen, bits<6> op> {
14855f757f3fSDimitry Andric  defm NAME : VOP3_Realtriple<Gen, {0, 1, 0, 0, op{5-0}}, /*isSingle=*/ 0, NAME> ;
148681ad6265SDimitry Andric}
148781ad6265SDimitry Andric
14885f757f3fSDimitry Andricmulticlass VOP2_Realtriple_e64_with_name<GFXGen Gen, bits<6> op, string opName,
14895f757f3fSDimitry Andric                                               string asmName> {
14905f757f3fSDimitry Andric  defm NAME : VOP3_Realtriple_with_name<Gen, {0, 1, 0, 0, op{5-0}}, opName, asmName> ;
14915f757f3fSDimitry Andric}
14925f757f3fSDimitry Andric
14935f757f3fSDimitry Andricmulticlass VOP2be_Real<GFXGen Gen, bits<6> op, string opName, string asmName> :
14945f757f3fSDimitry Andric  VOP2be_Real_e32<Gen, op, opName, asmName>,
14955f757f3fSDimitry Andric  VOP3be_Realtriple<Gen, {0, 1, 0, 0, op{5-0}}, /*isSingle=*/ 0, opName, asmName>,
14965f757f3fSDimitry Andric  VOP2be_Real_dpp<Gen, op, opName, asmName>,
14975f757f3fSDimitry Andric  VOP2be_Real_dpp8<Gen, op, opName, asmName>;
14985f757f3fSDimitry Andric
14995f757f3fSDimitry Andric// Only for CNDMASK
15005f757f3fSDimitry Andricmulticlass VOP2e_Real<GFXGen Gen, bits<6> op, string opName, string asmName> :
15015f757f3fSDimitry Andric  VOP2_Real_e32<Gen, op>,
15025f757f3fSDimitry Andric  VOP2_Realtriple_e64<Gen, op>,
15035f757f3fSDimitry Andric  VOP2be_Real_dpp<Gen, op, opName, asmName>,
15045f757f3fSDimitry Andric  VOP2be_Real_dpp8<Gen, op, opName, asmName>;
15055f757f3fSDimitry Andric
15065f757f3fSDimitry Andricmulticlass VOP2Only_Real<GFXGen Gen, bits<6> op> :
15075f757f3fSDimitry Andric  VOP2Only_Real_e32<Gen, op>,
15085f757f3fSDimitry Andric  VOP2_Real_dpp<Gen, op>,
15095f757f3fSDimitry Andric  VOP2_Real_dpp8<Gen, op>;
15105f757f3fSDimitry Andric
15115f757f3fSDimitry Andricmulticlass VOP2_Real_FULL<GFXGen Gen, bits<6> op> :
15125f757f3fSDimitry Andric  VOP2_Realtriple_e64<Gen, op>,
15135f757f3fSDimitry Andric  VOP2_Real_e32<Gen, op>,
15145f757f3fSDimitry Andric  VOP2_Real_dpp<Gen, op>,
15155f757f3fSDimitry Andric  VOP2_Real_dpp8<Gen, op>;
15165f757f3fSDimitry Andric
15175f757f3fSDimitry Andricmulticlass VOP2_Real_NO_VOP3_with_name<GFXGen Gen, bits<6> op, string opName,
15185f757f3fSDimitry Andric                                       string asmName, bit isSingle = 0> {
15195f757f3fSDimitry Andric  defm NAME : VOP2_Real_e32_with_name<Gen, op, opName, asmName, isSingle>,
15205f757f3fSDimitry Andric              VOP2_Real_dpp_with_name<Gen, op, opName, asmName>,
15215f757f3fSDimitry Andric              VOP2_Real_dpp8_with_name<Gen, op, opName, asmName>;
15225f757f3fSDimitry Andric  defvar ps = !cast<VOP2_Pseudo>(opName#"_e32");
1523*0fca6ea1SDimitry Andric  def Gen.Suffix#"_alias" : AMDGPUMnemonicAlias<ps.Mnemonic, asmName> {
1524*0fca6ea1SDimitry Andric    let AssemblerPredicate = Gen.AssemblerPredicate;
1525*0fca6ea1SDimitry Andric  }
15265f757f3fSDimitry Andric}
15275f757f3fSDimitry Andric
15285f757f3fSDimitry Andricmulticlass VOP2_Real_FULL_with_name<GFXGen Gen, bits<6> op, string opName,
15295f757f3fSDimitry Andric                                    string asmName> :
15305f757f3fSDimitry Andric  VOP2_Realtriple_e64_with_name<Gen, op, opName, asmName>,
15315f757f3fSDimitry Andric  VOP2_Real_NO_VOP3_with_name<Gen, op, opName, asmName>;
15325f757f3fSDimitry Andric
15335f757f3fSDimitry Andricmulticlass VOP2_Real_NO_DPP_with_name<GFXGen Gen, bits<6> op, string opName,
15345f757f3fSDimitry Andric                                      string asmName> {
15355f757f3fSDimitry Andric  defm NAME : VOP2_Real_e32_with_name<Gen, op, opName, asmName>,
15365f757f3fSDimitry Andric              VOP2_Real_e64_with_name<Gen, op, opName, asmName>;
15375f757f3fSDimitry Andric  defvar ps = !cast<VOP2_Pseudo>(opName#"_e32");
1538*0fca6ea1SDimitry Andric  def Gen.Suffix#"_alias" : AMDGPUMnemonicAlias<ps.Mnemonic, asmName> {
1539*0fca6ea1SDimitry Andric    let AssemblerPredicate = Gen.AssemblerPredicate;
1540*0fca6ea1SDimitry Andric  }
15415f757f3fSDimitry Andric}
15425f757f3fSDimitry Andric
15435f757f3fSDimitry Andricmulticlass VOP2_Real_NO_DPP_with_alias<GFXGen Gen, bits<6> op, string alias> {
15445f757f3fSDimitry Andric  defm NAME : VOP2_Real_e32<Gen, op>,
15455f757f3fSDimitry Andric              VOP2_Real_e64<Gen, op>;
1546*0fca6ea1SDimitry Andric  def Gen.Suffix#"_alias" : AMDGPUMnemonicAlias<alias, NAME> {
1547*0fca6ea1SDimitry Andric    let AssemblerPredicate = Gen.AssemblerPredicate;
1548*0fca6ea1SDimitry Andric  }
15495f757f3fSDimitry Andric}
15505f757f3fSDimitry Andric
15515f757f3fSDimitry Andric//===----------------------------------------------------------------------===//
15525f757f3fSDimitry Andric// GFX12.
15535f757f3fSDimitry Andric//===----------------------------------------------------------------------===//
15545f757f3fSDimitry Andric
15555f757f3fSDimitry Andricmulticlass VOP2be_Real_gfx12<bits<6> op, string opName, string asmName> :
15565f757f3fSDimitry Andric  VOP2be_Real<GFX12Gen, op, opName, asmName>;
15575f757f3fSDimitry Andric
15585f757f3fSDimitry Andric// Only for CNDMASK
15595f757f3fSDimitry Andricmulticlass VOP2e_Real_gfx12<bits<6> op, string opName, string asmName> :
15605f757f3fSDimitry Andric  VOP2e_Real<GFX12Gen, op, opName, asmName>;
15615f757f3fSDimitry Andric
15625f757f3fSDimitry Andricmulticlass VOP2_Real_FULL_with_name_gfx12<bits<6> op, string opName,
15635f757f3fSDimitry Andric                                          string asmName> :
15645f757f3fSDimitry Andric  VOP2_Real_FULL_with_name<GFX12Gen, op, opName, asmName>;
15655f757f3fSDimitry Andric
15665f757f3fSDimitry Andricmulticlass VOP2_Real_FULL_t16_with_name_gfx12<bits<6> op, string opName,
15675f757f3fSDimitry Andric                                              string asmName, string alias> {
15685f757f3fSDimitry Andric  defm NAME : VOP2_Real_FULL_with_name<GFX12Gen, op, opName, asmName>;
1569*0fca6ea1SDimitry Andric  def _gfx12_2nd_alias : AMDGPUMnemonicAlias<alias, asmName> {
1570*0fca6ea1SDimitry Andric    let AssemblerPredicate = isGFX12Only;
1571*0fca6ea1SDimitry Andric  }
15725f757f3fSDimitry Andric}
15735f757f3fSDimitry Andric
15745f757f3fSDimitry Andricmulticlass VOP2_Real_NO_DPP_with_name_gfx12<bits<6> op, string opName,
15755f757f3fSDimitry Andric                                            string asmName> :
15765f757f3fSDimitry Andric  VOP2_Real_NO_DPP_with_name<GFX12Gen, op, opName, asmName>;
15775f757f3fSDimitry Andric
15785f757f3fSDimitry Andricmulticlass VOP2_Real_NO_DPP_with_alias_gfx12<bits<6> op, string alias> :
15795f757f3fSDimitry Andric  VOP2_Real_NO_DPP_with_alias<GFX12Gen, op, alias>;
15805f757f3fSDimitry Andric
15815f757f3fSDimitry Andricdefm V_ADD_F64     : VOP2_Real_NO_DPP_with_name_gfx12<0x002, "V_ADD_F64_pseudo", "v_add_f64">;
15825f757f3fSDimitry Andricdefm V_MUL_F64     : VOP2_Real_NO_DPP_with_name_gfx12<0x006, "V_MUL_F64_pseudo", "v_mul_f64">;
15835f757f3fSDimitry Andricdefm V_LSHLREV_B64 : VOP2_Real_NO_DPP_with_name_gfx12<0x01f, "V_LSHLREV_B64_pseudo", "v_lshlrev_b64">;
15845f757f3fSDimitry Andricdefm V_MIN_NUM_F64 : VOP2_Real_NO_DPP_with_alias_gfx12<0x00d, "v_min_f64">;
15855f757f3fSDimitry Andricdefm V_MAX_NUM_F64 : VOP2_Real_NO_DPP_with_alias_gfx12<0x00e, "v_max_f64">;
15865f757f3fSDimitry Andric
15875f757f3fSDimitry Andricdefm V_CNDMASK_B32 : VOP2e_Real_gfx12<0x001, "V_CNDMASK_B32", "v_cndmask_b32">;
15885f757f3fSDimitry Andricdefm V_ADD_CO_CI_U32 :
15895f757f3fSDimitry Andric  VOP2be_Real_gfx12<0x020, "V_ADDC_U32", "v_add_co_ci_u32">;
15905f757f3fSDimitry Andricdefm V_SUB_CO_CI_U32 :
15915f757f3fSDimitry Andric  VOP2be_Real_gfx12<0x021, "V_SUBB_U32", "v_sub_co_ci_u32">;
15925f757f3fSDimitry Andricdefm V_SUBREV_CO_CI_U32 :
15935f757f3fSDimitry Andric  VOP2be_Real_gfx12<0x022, "V_SUBBREV_U32", "v_subrev_co_ci_u32">;
15945f757f3fSDimitry Andric
15955f757f3fSDimitry Andricdefm V_MIN_NUM_F32 : VOP2_Real_FULL_with_name_gfx12<0x015, "V_MIN_F32", "v_min_num_f32">;
15965f757f3fSDimitry Andricdefm V_MAX_NUM_F32 : VOP2_Real_FULL_with_name_gfx12<0x016, "V_MAX_F32", "v_max_num_f32">;
15975f757f3fSDimitry Andricdefm V_MIN_NUM_F16 : VOP2_Real_FULL_t16_with_name_gfx12<0x030, "V_MIN_F16_t16", "v_min_num_f16", "v_min_f16">;
15985f757f3fSDimitry Andricdefm V_MIN_NUM_F16_fake16 : VOP2_Real_FULL_t16_with_name_gfx12<0x030, "V_MIN_F16_fake16", "v_min_num_f16", "v_min_f16">;
15995f757f3fSDimitry Andricdefm V_MAX_NUM_F16 : VOP2_Real_FULL_t16_with_name_gfx12<0x031, "V_MAX_F16_t16", "v_max_num_f16", "v_max_f16">;
16005f757f3fSDimitry Andricdefm V_MAX_NUM_F16_fake16 : VOP2_Real_FULL_t16_with_name_gfx12<0x031, "V_MAX_F16_fake16", "v_max_num_f16", "v_max_f16">;
16015f757f3fSDimitry Andric
16025f757f3fSDimitry Andriclet SubtargetPredicate = isGFX12Plus in {
16035f757f3fSDimitry Andric  defm : VOP2eInstAliases<V_CNDMASK_B32_e32, V_CNDMASK_B32_e32_gfx12>;
16045f757f3fSDimitry Andric
16055f757f3fSDimitry Andric  defm : VOP2bInstAliases<
16065f757f3fSDimitry Andric    V_ADDC_U32_e32, V_ADD_CO_CI_U32_e32_gfx12, "v_add_co_ci_u32">;
16075f757f3fSDimitry Andric  defm : VOP2bInstAliases<
16085f757f3fSDimitry Andric    V_SUBB_U32_e32, V_SUB_CO_CI_U32_e32_gfx12, "v_sub_co_ci_u32">;
16095f757f3fSDimitry Andric  defm : VOP2bInstAliases<
16105f757f3fSDimitry Andric    V_SUBBREV_U32_e32, V_SUBREV_CO_CI_U32_e32_gfx12, "v_subrev_co_ci_u32">;
16115f757f3fSDimitry Andric} // End SubtargetPredicate = isGFX12Plus
16125f757f3fSDimitry Andric
16135f757f3fSDimitry Andric//===----------------------------------------------------------------------===//
16145f757f3fSDimitry Andric// GFX11.
16155f757f3fSDimitry Andric//===----------------------------------------------------------------------===//
16165f757f3fSDimitry Andric
161781ad6265SDimitry Andricmulticlass VOP2be_Real_gfx11<bits<6> op, string opName, string asmName> :
16185f757f3fSDimitry Andric  VOP2be_Real<GFX11Gen, op, opName, asmName>;
161981ad6265SDimitry Andric
162081ad6265SDimitry Andric// Only for CNDMASK
162181ad6265SDimitry Andricmulticlass VOP2e_Real_gfx11<bits<6> op, string opName, string asmName> :
16225f757f3fSDimitry Andric  VOP2e_Real<GFX11Gen, op, opName, asmName>;
162381ad6265SDimitry Andric
162481ad6265SDimitry Andricmulticlass VOP2_Real_NO_VOP3_with_name_gfx11<bits<6> op, string opName,
1625bdd1243dSDimitry Andric                                           string asmName, bit isSingle = 0> {
16265f757f3fSDimitry Andric  defm NAME : VOP2_Real_e32_with_name<GFX11Gen, op, opName, asmName, isSingle>,
16275f757f3fSDimitry Andric              VOP2_Real_dpp_with_name<GFX11Gen, op, opName, asmName>,
16285f757f3fSDimitry Andric              VOP2_Real_dpp8_with_name<GFX11Gen, op, opName, asmName>;
1629bdd1243dSDimitry Andric  defvar ps = !cast<VOP2_Pseudo>(opName#"_e32");
1630*0fca6ea1SDimitry Andric  def _gfx11_alias : AMDGPUMnemonicAlias<ps.Mnemonic, asmName> {
1631*0fca6ea1SDimitry Andric    let AssemblerPredicate = isGFX11Only;
1632*0fca6ea1SDimitry Andric  }
1633bdd1243dSDimitry Andric}
163481ad6265SDimitry Andric
163581ad6265SDimitry Andricmulticlass VOP2_Real_NO_DPP_with_name_gfx11<bits<6> op, string opName,
16365f757f3fSDimitry Andric                                           string asmName> :
16375f757f3fSDimitry Andric  VOP2_Real_NO_DPP_with_name<GFX11Gen, op, opName, asmName>;
16385f757f3fSDimitry Andric
16395f757f3fSDimitry Andricmulticlass VOP2_Real_FULL_gfx11_gfx12<bits<6> op> :
16405f757f3fSDimitry Andric  VOP2_Real_FULL<GFX11Gen, op>, VOP2_Real_FULL<GFX12Gen, op>;
16415f757f3fSDimitry Andric
16425f757f3fSDimitry Andricmulticlass VOP2_Real_FULL_with_name_gfx11_gfx12<bits<6> op, string opName,
16435f757f3fSDimitry Andric                                                string asmName> :
16445f757f3fSDimitry Andric  VOP2_Real_FULL_with_name<GFX11Gen, op, opName, asmName>,
16455f757f3fSDimitry Andric  VOP2_Real_FULL_with_name<GFX12Gen, op, opName, asmName>;
16465f757f3fSDimitry Andric
16475f757f3fSDimitry Andricmulticlass VOP2_Real_e32_gfx11_gfx12<bits<6> op> :
16485f757f3fSDimitry Andric  VOP2Only_Real<GFX11Gen, op>, VOP2Only_Real<GFX12Gen, op>;
16495f757f3fSDimitry Andric
16505f757f3fSDimitry Andricmulticlass VOP3Only_Realtriple_gfx11_gfx12<bits<10> op> :
16515f757f3fSDimitry Andric  VOP3Only_Realtriple<GFX11Gen, op>, VOP3Only_Realtriple<GFX12Gen, op>;
16525f757f3fSDimitry Andric
16535f757f3fSDimitry Andricmulticlass VOP3Only_Realtriple_t16_gfx11_gfx12<bits<10> op, string asmName> :
16545f757f3fSDimitry Andric  VOP3Only_Realtriple_t16<GFX11Gen, op, asmName>,
16555f757f3fSDimitry Andric  VOP3Only_Realtriple_t16<GFX12Gen, op, asmName>;
16565f757f3fSDimitry Andric
16575f757f3fSDimitry Andricmulticlass VOP3beOnly_Realtriple_gfx11_gfx12<bits<10> op> :
16585f757f3fSDimitry Andric  VOP3beOnly_Realtriple<GFX11Gen, op>, VOP3beOnly_Realtriple<GFX12Gen, op>;
16595f757f3fSDimitry Andric
16605f757f3fSDimitry Andricmulticlass VOP2Only_Real_MADK_with_name_gfx11_gfx12<bits<6> op, string asmName,
16615f757f3fSDimitry Andric                                                    string opName = NAME> :
16625f757f3fSDimitry Andric  VOP2Only_Real_MADK_with_name<GFX11Gen, op, asmName, opName>,
16635f757f3fSDimitry Andric  VOP2Only_Real_MADK_with_name<GFX12Gen, op, asmName, opName>;
16645f757f3fSDimitry Andric
16655f757f3fSDimitry Andricmulticlass VOP2_Real_FULL_t16_gfx11<bits<6> op, string asmName,
16665f757f3fSDimitry Andric                                    string opName = NAME> :
16675f757f3fSDimitry Andric  VOP2_Real_FULL_with_name<GFX11Gen, op, opName, asmName>;
16685f757f3fSDimitry Andric
16695f757f3fSDimitry Andricmulticlass VOP2_Real_FULL_t16_gfx11_gfx12<bits<6> op, string asmName,
16705f757f3fSDimitry Andric                                          string opName = NAME> :
16715f757f3fSDimitry Andric  VOP2_Real_FULL_with_name_gfx11_gfx12<op, opName, asmName>;
16725f757f3fSDimitry Andric
16735f757f3fSDimitry Andricmulticlass VOP2_Real_FULL_gfx11<bits<6> op> :
16745f757f3fSDimitry Andric  VOP2_Real_FULL<GFX11Gen, op>;
167581ad6265SDimitry Andric
167681ad6265SDimitry Andricdefm V_CNDMASK_B32 : VOP2e_Real_gfx11<0x001, "V_CNDMASK_B32",
167781ad6265SDimitry Andric  "v_cndmask_b32">;
167881ad6265SDimitry Andricdefm V_DOT2ACC_F32_F16 : VOP2_Real_NO_VOP3_with_name_gfx11<0x002,
167981ad6265SDimitry Andric  "V_DOT2C_F32_F16", "v_dot2acc_f32_f16", 1>;
168081ad6265SDimitry Andricdefm V_FMAC_DX9_ZERO_F32 : VOP2_Real_NO_DPP_with_name_gfx11<0x006,
168181ad6265SDimitry Andric  "V_FMAC_LEGACY_F32", "v_fmac_dx9_zero_f32">;
16825f757f3fSDimitry Andricdefm V_MUL_DX9_ZERO_F32 : VOP2_Real_FULL_with_name_gfx11_gfx12<0x007,
168381ad6265SDimitry Andric  "V_MUL_LEGACY_F32", "v_mul_dx9_zero_f32">;
16845f757f3fSDimitry Andricdefm V_LSHLREV_B32        : VOP2_Real_FULL_gfx11_gfx12<0x018>;
16855f757f3fSDimitry Andricdefm V_LSHRREV_B32        : VOP2_Real_FULL_gfx11_gfx12<0x019>;
16865f757f3fSDimitry Andricdefm V_ASHRREV_I32        : VOP2_Real_FULL_gfx11_gfx12<0x01a>;
168781ad6265SDimitry Andricdefm V_ADD_CO_CI_U32 :
168881ad6265SDimitry Andric  VOP2be_Real_gfx11<0x020, "V_ADDC_U32", "v_add_co_ci_u32">;
168981ad6265SDimitry Andricdefm V_SUB_CO_CI_U32 :
169081ad6265SDimitry Andric  VOP2be_Real_gfx11<0x021, "V_SUBB_U32", "v_sub_co_ci_u32">;
169181ad6265SDimitry Andricdefm V_SUBREV_CO_CI_U32 :
169281ad6265SDimitry Andric  VOP2be_Real_gfx11<0x022, "V_SUBBREV_U32", "v_subrev_co_ci_u32">;
169381ad6265SDimitry Andric
16945f757f3fSDimitry Andricdefm V_CVT_PK_RTZ_F16_F32  : VOP2_Real_FULL_with_name_gfx11_gfx12<0x02f,
169581ad6265SDimitry Andric  "V_CVT_PKRTZ_F16_F32", "v_cvt_pk_rtz_f16_f32">;
16965f757f3fSDimitry Andricdefm V_PK_FMAC_F16     : VOP2_Real_e32_gfx11_gfx12<0x03c>;
169781ad6265SDimitry Andric
16985f757f3fSDimitry Andricdefm V_ADD_F16_t16         : VOP2_Real_FULL_t16_gfx11_gfx12<0x032, "v_add_f16">;
16995f757f3fSDimitry Andricdefm V_ADD_F16_fake16      : VOP2_Real_FULL_t16_gfx11_gfx12<0x032, "v_add_f16">;
17005f757f3fSDimitry Andricdefm V_SUB_F16_t16         : VOP2_Real_FULL_t16_gfx11_gfx12<0x033, "v_sub_f16">;
17015f757f3fSDimitry Andricdefm V_SUB_F16_fake16      : VOP2_Real_FULL_t16_gfx11_gfx12<0x033, "v_sub_f16">;
17025f757f3fSDimitry Andricdefm V_SUBREV_F16_t16      : VOP2_Real_FULL_t16_gfx11_gfx12<0x034, "v_subrev_f16">;
17035f757f3fSDimitry Andricdefm V_SUBREV_F16_fake16   : VOP2_Real_FULL_t16_gfx11_gfx12<0x034, "v_subrev_f16">;
17045f757f3fSDimitry Andricdefm V_MUL_F16_t16         : VOP2_Real_FULL_t16_gfx11_gfx12<0x035, "v_mul_f16">;
17055f757f3fSDimitry Andricdefm V_MUL_F16_fake16      : VOP2_Real_FULL_t16_gfx11_gfx12<0x035, "v_mul_f16">;
17065f757f3fSDimitry Andricdefm V_FMAC_F16_t16        : VOP2_Real_FULL_t16_gfx11_gfx12<0x036, "v_fmac_f16">;
17075f757f3fSDimitry Andricdefm V_LDEXP_F16_t16       : VOP2_Real_FULL_t16_gfx11_gfx12<0x03b, "v_ldexp_f16">;
1708bdd1243dSDimitry Andricdefm V_MAX_F16_t16         : VOP2_Real_FULL_t16_gfx11<0x039, "v_max_f16">;
17095f757f3fSDimitry Andricdefm V_MAX_F16_fake16      : VOP2_Real_FULL_t16_gfx11<0x039, "v_max_f16">;
1710bdd1243dSDimitry Andricdefm V_MIN_F16_t16         : VOP2_Real_FULL_t16_gfx11<0x03a, "v_min_f16">;
17115f757f3fSDimitry Andricdefm V_MIN_F16_fake16      : VOP2_Real_FULL_t16_gfx11<0x03a, "v_min_f16">;
17125f757f3fSDimitry Andricdefm V_FMAMK_F16_t16       : VOP2Only_Real_MADK_with_name_gfx11_gfx12<0x037, "v_fmamk_f16">;
17135f757f3fSDimitry Andricdefm V_FMAAK_F16_t16       : VOP2Only_Real_MADK_with_name_gfx11_gfx12<0x038, "v_fmaak_f16">;
1714bdd1243dSDimitry Andric
171581ad6265SDimitry Andric// VOP3 only.
17165f757f3fSDimitry Andricdefm V_CNDMASK_B16         : VOP3Only_Realtriple_gfx11_gfx12<0x25d>;
17175f757f3fSDimitry Andricdefm V_LDEXP_F32           : VOP3Only_Realtriple_gfx11_gfx12<0x31c>;
17185f757f3fSDimitry Andricdefm V_BFM_B32             : VOP3Only_Realtriple_gfx11_gfx12<0x31d>;
17195f757f3fSDimitry Andricdefm V_BCNT_U32_B32        : VOP3Only_Realtriple_gfx11_gfx12<0x31e>;
17205f757f3fSDimitry Andricdefm V_MBCNT_LO_U32_B32    : VOP3Only_Realtriple_gfx11_gfx12<0x31f>;
17215f757f3fSDimitry Andricdefm V_MBCNT_HI_U32_B32    : VOP3Only_Realtriple_gfx11_gfx12<0x320>;
17225f757f3fSDimitry Andricdefm V_CVT_PK_NORM_I16_F32 : VOP3Only_Realtriple_with_name_gfx11_gfx12<0x321, "V_CVT_PKNORM_I16_F32", "v_cvt_pk_norm_i16_f32">;
17235f757f3fSDimitry Andricdefm V_CVT_PK_NORM_U16_F32 : VOP3Only_Realtriple_with_name_gfx11_gfx12<0x322, "V_CVT_PKNORM_U16_F32", "v_cvt_pk_norm_u16_f32">;
17245f757f3fSDimitry Andricdefm V_CVT_PK_U16_U32      : VOP3Only_Realtriple_gfx11_gfx12<0x323>;
17255f757f3fSDimitry Andricdefm V_CVT_PK_I16_I32      : VOP3Only_Realtriple_gfx11_gfx12<0x324>;
17265f757f3fSDimitry Andricdefm V_ADD_CO_U32          : VOP3beOnly_Realtriple_gfx11_gfx12<0x300>;
17275f757f3fSDimitry Andricdefm V_SUB_CO_U32          : VOP3beOnly_Realtriple_gfx11_gfx12<0x301>;
17285f757f3fSDimitry Andricdefm V_SUBREV_CO_U32       : VOP3beOnly_Realtriple_gfx11_gfx12<0x302>;
172981ad6265SDimitry Andric
17305f757f3fSDimitry Andriclet SubtargetPredicate = isGFX11Only in {
173181ad6265SDimitry Andric  defm : VOP2eInstAliases<V_CNDMASK_B32_e32, V_CNDMASK_B32_e32_gfx11>;
173281ad6265SDimitry Andric
173381ad6265SDimitry Andric  defm : VOP2bInstAliases<
173481ad6265SDimitry Andric    V_ADDC_U32_e32, V_ADD_CO_CI_U32_e32_gfx11, "v_add_co_ci_u32">;
173581ad6265SDimitry Andric  defm : VOP2bInstAliases<
173681ad6265SDimitry Andric    V_SUBB_U32_e32, V_SUB_CO_CI_U32_e32_gfx11, "v_sub_co_ci_u32">;
173781ad6265SDimitry Andric  defm : VOP2bInstAliases<
173881ad6265SDimitry Andric    V_SUBBREV_U32_e32, V_SUBREV_CO_CI_U32_e32_gfx11, "v_subrev_co_ci_u32">;
17395f757f3fSDimitry Andric} // End SubtargetPredicate = isGFX11Only
174081ad6265SDimitry Andric
174181ad6265SDimitry Andric//===----------------------------------------------------------------------===//
17420b57cec5SDimitry Andric// GFX10.
17430b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
17440b57cec5SDimitry Andric
174581ad6265SDimitry Andriclet AssemblerPredicate = isGFX10Only, DecoderNamespace = "GFX10" in {
17460b57cec5SDimitry Andric  //===------------------------------- VOP2 -------------------------------===//
17470b57cec5SDimitry Andric  multiclass VOP2Only_Real_MADK_gfx10<bits<6> op> {
17480b57cec5SDimitry Andric    def _gfx10 :
17490b57cec5SDimitry Andric      VOP2_Real<!cast<VOP2_Pseudo>(NAME), SIEncodingFamily.GFX10>,
17500b57cec5SDimitry Andric      VOP2_MADKe<op{5-0}, !cast<VOP2_Pseudo>(NAME).Pfl>;
17510b57cec5SDimitry Andric  }
17520b57cec5SDimitry Andric  multiclass VOP2Only_Real_MADK_gfx10_with_name<bits<6> op, string opName,
17530b57cec5SDimitry Andric                                                string asmName> {
17540b57cec5SDimitry Andric    def _gfx10 :
17550b57cec5SDimitry Andric        VOP2_Real<!cast<VOP2_Pseudo>(opName), SIEncodingFamily.GFX10>,
17560b57cec5SDimitry Andric        VOP2_MADKe<op{5-0}, !cast<VOP2_Pseudo>(opName).Pfl> {
17570b57cec5SDimitry Andric      VOP2_Pseudo ps = !cast<VOP2_Pseudo>(opName);
17580b57cec5SDimitry Andric      let AsmString = asmName # ps.AsmOperands;
17590b57cec5SDimitry Andric    }
17600b57cec5SDimitry Andric  }
17610b57cec5SDimitry Andric  multiclass VOP2_Real_e32_gfx10<bits<6> op> {
17620b57cec5SDimitry Andric    def _e32_gfx10 :
17630b57cec5SDimitry Andric      VOP2_Real<!cast<VOP2_Pseudo>(NAME#"_e32"), SIEncodingFamily.GFX10>,
17640b57cec5SDimitry Andric      VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME#"_e32").Pfl>;
17650b57cec5SDimitry Andric  }
17660b57cec5SDimitry Andric  multiclass VOP2_Real_e64_gfx10<bits<6> op> {
17670b57cec5SDimitry Andric    def _e64_gfx10 :
17680b57cec5SDimitry Andric      VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX10>,
17690b57cec5SDimitry Andric      VOP3e_gfx10<{0, 1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
17700b57cec5SDimitry Andric  }
17710b57cec5SDimitry Andric  multiclass VOP2_Real_sdwa_gfx10<bits<6> op> {
177206c3fb27SDimitry Andric    if !cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA9 then
17730b57cec5SDimitry Andric    def _sdwa_gfx10 :
17740b57cec5SDimitry Andric      VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa")>,
1775*0fca6ea1SDimitry Andric      VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa").Pfl>;
17760b57cec5SDimitry Andric  }
17770b57cec5SDimitry Andric  multiclass VOP2_Real_dpp_gfx10<bits<6> op> {
177806c3fb27SDimitry Andric    if !cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExt32BitDPP then
1779*0fca6ea1SDimitry Andric    def _dpp_gfx10 : VOP2_DPP16<op, !cast<VOP2_DPP_Pseudo>(NAME#"_dpp"), SIEncodingFamily.GFX10>;
17800b57cec5SDimitry Andric  }
17810b57cec5SDimitry Andric  multiclass VOP2_Real_dpp8_gfx10<bits<6> op> {
178206c3fb27SDimitry Andric    if !cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExt32BitDPP then
1783*0fca6ea1SDimitry Andric    def _dpp8_gfx10 : VOP2_DPP8<op, !cast<VOP2_Pseudo>(NAME#"_e32")>;
17840b57cec5SDimitry Andric  }
17850b57cec5SDimitry Andric
17860b57cec5SDimitry Andric  //===------------------------- VOP2 (with name) -------------------------===//
17870b57cec5SDimitry Andric  multiclass VOP2_Real_e32_gfx10_with_name<bits<6> op, string opName,
17880b57cec5SDimitry Andric                                           string asmName> {
17890b57cec5SDimitry Andric    def _e32_gfx10 :
17900b57cec5SDimitry Andric      VOP2_Real<!cast<VOP2_Pseudo>(opName#"_e32"), SIEncodingFamily.GFX10>,
17910b57cec5SDimitry Andric      VOP2e<op{5-0}, !cast<VOP2_Pseudo>(opName#"_e32").Pfl> {
17920b57cec5SDimitry Andric        VOP2_Pseudo ps = !cast<VOP2_Pseudo>(opName#"_e32");
17930b57cec5SDimitry Andric        let AsmString = asmName # ps.AsmOperands;
17940b57cec5SDimitry Andric      }
17950b57cec5SDimitry Andric  }
17960b57cec5SDimitry Andric  multiclass VOP2_Real_e64_gfx10_with_name<bits<6> op, string opName,
17970b57cec5SDimitry Andric                                           string asmName> {
17980b57cec5SDimitry Andric    def _e64_gfx10 :
17990b57cec5SDimitry Andric      VOP3_Real<!cast<VOP3_Pseudo>(opName#"_e64"), SIEncodingFamily.GFX10>,
18000b57cec5SDimitry Andric      VOP3e_gfx10<{0, 1, 0, 0, op{5-0}},
18010b57cec5SDimitry Andric                  !cast<VOP3_Pseudo>(opName#"_e64").Pfl> {
18020b57cec5SDimitry Andric        VOP3_Pseudo ps = !cast<VOP3_Pseudo>(opName#"_e64");
18030b57cec5SDimitry Andric        let AsmString = asmName # ps.AsmOperands;
18040b57cec5SDimitry Andric      }
18050b57cec5SDimitry Andric  }
18060b57cec5SDimitry Andric  multiclass VOP2_Real_sdwa_gfx10_with_name<bits<6> op, string opName,
18070b57cec5SDimitry Andric                                            string asmName> {
180806c3fb27SDimitry Andric    if !cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtSDWA9 then
18090b57cec5SDimitry Andric    def _sdwa_gfx10 :
18100b57cec5SDimitry Andric      VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(opName#"_sdwa")>,
18110b57cec5SDimitry Andric      VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa").Pfl> {
18120b57cec5SDimitry Andric        VOP2_SDWA_Pseudo ps = !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa");
18130b57cec5SDimitry Andric        let AsmString = asmName # ps.AsmOperands;
18140b57cec5SDimitry Andric      }
18150b57cec5SDimitry Andric  }
18160b57cec5SDimitry Andric  multiclass VOP2_Real_dpp_gfx10_with_name<bits<6> op, string opName,
18170b57cec5SDimitry Andric                                           string asmName> {
181806c3fb27SDimitry Andric    if !cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExt32BitDPP then
181981ad6265SDimitry Andric    def _dpp_gfx10 : VOP2_DPP16<op, !cast<VOP2_DPP_Pseudo>(opName#"_dpp"), SIEncodingFamily.GFX10> {
18200b57cec5SDimitry Andric      VOP2_Pseudo ps = !cast<VOP2_Pseudo>(opName#"_e32");
18210b57cec5SDimitry Andric      let AsmString = asmName # ps.Pfl.AsmDPP16;
18220b57cec5SDimitry Andric    }
18230b57cec5SDimitry Andric  }
18240b57cec5SDimitry Andric  multiclass VOP2_Real_dpp8_gfx10_with_name<bits<6> op, string opName,
18250b57cec5SDimitry Andric                                            string asmName> {
182606c3fb27SDimitry Andric    if !cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExt32BitDPP then
18270b57cec5SDimitry Andric    def _dpp8_gfx10 : VOP2_DPP8<op, !cast<VOP2_Pseudo>(opName#"_e32")> {
18280b57cec5SDimitry Andric      VOP2_Pseudo ps = !cast<VOP2_Pseudo>(opName#"_e32");
18290b57cec5SDimitry Andric      let AsmString = asmName # ps.Pfl.AsmDPP8;
18300b57cec5SDimitry Andric    }
18310b57cec5SDimitry Andric  }
18320b57cec5SDimitry Andric
18330b57cec5SDimitry Andric  //===------------------------------ VOP2be ------------------------------===//
18348bcb0991SDimitry Andric  multiclass VOP2be_Real_e32_gfx10<bits<6> op, string opName, string asmName> {
18350b57cec5SDimitry Andric    def _e32_gfx10 :
18360b57cec5SDimitry Andric      VOP2_Real<!cast<VOP2_Pseudo>(opName#"_e32"), SIEncodingFamily.GFX10>,
18370b57cec5SDimitry Andric      VOP2e<op{5-0}, !cast<VOP2_Pseudo>(opName#"_e32").Pfl> {
18380b57cec5SDimitry Andric        VOP2_Pseudo Ps = !cast<VOP2_Pseudo>(opName#"_e32");
18390b57cec5SDimitry Andric        let AsmString = asmName # !subst(", vcc", "", Ps.AsmOperands);
18400b57cec5SDimitry Andric      }
18418bcb0991SDimitry Andric  }
18428bcb0991SDimitry Andric  multiclass VOP2be_Real_e64_gfx10<bits<6> op, string opName, string asmName> {
18430b57cec5SDimitry Andric    def _e64_gfx10 :
18440b57cec5SDimitry Andric      VOP3_Real<!cast<VOP3_Pseudo>(opName#"_e64"), SIEncodingFamily.GFX10>,
18450b57cec5SDimitry Andric      VOP3be_gfx10<{0, 1, 0, 0, op{5-0}},
18460b57cec5SDimitry Andric                   !cast<VOP3_Pseudo>(opName#"_e64").Pfl> {
18470b57cec5SDimitry Andric        VOP3_Pseudo Ps = !cast<VOP3_Pseudo>(opName#"_e64");
18480b57cec5SDimitry Andric        let AsmString = asmName # Ps.AsmOperands;
18490b57cec5SDimitry Andric      }
18508bcb0991SDimitry Andric  }
18518bcb0991SDimitry Andric  multiclass VOP2be_Real_sdwa_gfx10<bits<6> op, string opName, string asmName> {
185206c3fb27SDimitry Andric    if !cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtSDWA9 then
18530b57cec5SDimitry Andric    def _sdwa_gfx10 :
18540b57cec5SDimitry Andric      VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(opName#"_sdwa")>,
18550b57cec5SDimitry Andric      VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa").Pfl> {
18560b57cec5SDimitry Andric        VOP2_SDWA_Pseudo Ps = !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa");
18570b57cec5SDimitry Andric        let AsmString = asmName # !subst(", vcc", "", Ps.AsmOperands);
18580b57cec5SDimitry Andric      }
185906c3fb27SDimitry Andric    if !cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtSDWA9 then
18600b57cec5SDimitry Andric    def _sdwa_w32_gfx10 :
18610b57cec5SDimitry Andric      Base_VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(opName#"_sdwa")>,
18620b57cec5SDimitry Andric      VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa").Pfl> {
18630b57cec5SDimitry Andric        VOP2_SDWA_Pseudo Ps = !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa");
18640b57cec5SDimitry Andric        let AsmString = asmName # !subst("vcc", "vcc_lo", Ps.AsmOperands);
18650b57cec5SDimitry Andric        let isAsmParserOnly = 1;
18668bcb0991SDimitry Andric        let WaveSizePredicate = isWave32;
18670b57cec5SDimitry Andric     }
186806c3fb27SDimitry Andric    if !cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExtSDWA9 then
18690b57cec5SDimitry Andric    def _sdwa_w64_gfx10 :
18700b57cec5SDimitry Andric      Base_VOP_SDWA10_Real<!cast<VOP2_SDWA_Pseudo>(opName#"_sdwa")>,
18710b57cec5SDimitry Andric      VOP2_SDWA9Ae<op{5-0}, !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa").Pfl> {
18720b57cec5SDimitry Andric        VOP2_SDWA_Pseudo Ps = !cast<VOP2_SDWA_Pseudo>(opName#"_sdwa");
18730b57cec5SDimitry Andric        let AsmString = asmName # Ps.AsmOperands;
18740b57cec5SDimitry Andric        let isAsmParserOnly = 1;
18758bcb0991SDimitry Andric        let WaveSizePredicate = isWave64;
18760b57cec5SDimitry Andric      }
18778bcb0991SDimitry Andric  }
18788bcb0991SDimitry Andric  multiclass VOP2be_Real_dpp_gfx10<bits<6> op, string opName, string asmName> {
187906c3fb27SDimitry Andric    if !cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExt32BitDPP then
18808bcb0991SDimitry Andric    def _dpp_gfx10 :
188181ad6265SDimitry Andric      VOP2_DPP16<op, !cast<VOP2_DPP_Pseudo>(opName#"_dpp"), SIEncodingFamily.GFX10, asmName> {
18828bcb0991SDimitry Andric        string AsmDPP = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP16;
18838bcb0991SDimitry Andric        let AsmString = asmName # !subst(", vcc", "", AsmDPP);
18848bcb0991SDimitry Andric      }
188506c3fb27SDimitry Andric    if !cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExt32BitDPP then
18868bcb0991SDimitry Andric    def _dpp_w32_gfx10 :
18878bcb0991SDimitry Andric      Base_VOP2_DPP16<op, !cast<VOP2_DPP_Pseudo>(opName#"_dpp"), asmName> {
18888bcb0991SDimitry Andric        string AsmDPP = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP16;
18898bcb0991SDimitry Andric        let AsmString = asmName # !subst("vcc", "vcc_lo", AsmDPP);
18908bcb0991SDimitry Andric        let isAsmParserOnly = 1;
18918bcb0991SDimitry Andric        let WaveSizePredicate = isWave32;
18928bcb0991SDimitry Andric      }
189306c3fb27SDimitry Andric    if !cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExt32BitDPP then
18940b57cec5SDimitry Andric    def _dpp_w64_gfx10 :
18958bcb0991SDimitry Andric      Base_VOP2_DPP16<op, !cast<VOP2_DPP_Pseudo>(opName#"_dpp"), asmName> {
18960b57cec5SDimitry Andric        string AsmDPP = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP16;
18970b57cec5SDimitry Andric        let AsmString = asmName # AsmDPP;
18980b57cec5SDimitry Andric        let isAsmParserOnly = 1;
18998bcb0991SDimitry Andric        let WaveSizePredicate = isWave64;
19000b57cec5SDimitry Andric      }
19018bcb0991SDimitry Andric  }
19028bcb0991SDimitry Andric  multiclass VOP2be_Real_dpp8_gfx10<bits<6> op, string opName, string asmName> {
190306c3fb27SDimitry Andric    if !cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExt32BitDPP then
19048bcb0991SDimitry Andric    def _dpp8_gfx10 :
1905349cc55cSDimitry Andric      VOP2_DPP8<op, !cast<VOP2_Pseudo>(opName#"_e32")> {
19068bcb0991SDimitry Andric        string AsmDPP8 = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP8;
19078bcb0991SDimitry Andric        let AsmString = asmName # !subst(", vcc", "", AsmDPP8);
19088bcb0991SDimitry Andric      }
190906c3fb27SDimitry Andric    if !cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExt32BitDPP then
19108bcb0991SDimitry Andric    def _dpp8_w32_gfx10 :
1911349cc55cSDimitry Andric      VOP2_DPP8<op, !cast<VOP2_Pseudo>(opName#"_e32")> {
19128bcb0991SDimitry Andric        string AsmDPP8 = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP8;
19138bcb0991SDimitry Andric        let AsmString = asmName # !subst("vcc", "vcc_lo", AsmDPP8);
19148bcb0991SDimitry Andric        let isAsmParserOnly = 1;
19158bcb0991SDimitry Andric        let WaveSizePredicate = isWave32;
19168bcb0991SDimitry Andric      }
191706c3fb27SDimitry Andric    if !cast<VOP2_Pseudo>(opName#"_e32").Pfl.HasExt32BitDPP then
19180b57cec5SDimitry Andric    def _dpp8_w64_gfx10 :
1919349cc55cSDimitry Andric      VOP2_DPP8<op, !cast<VOP2_Pseudo>(opName#"_e32")> {
19200b57cec5SDimitry Andric        string AsmDPP8 = !cast<VOP2_Pseudo>(opName#"_e32").Pfl.AsmDPP8;
19210b57cec5SDimitry Andric        let AsmString = asmName # AsmDPP8;
19220b57cec5SDimitry Andric        let isAsmParserOnly = 1;
19238bcb0991SDimitry Andric        let WaveSizePredicate = isWave64;
19240b57cec5SDimitry Andric      }
19250b57cec5SDimitry Andric  }
19260b57cec5SDimitry Andric
19270b57cec5SDimitry Andric  //===----------------------------- VOP3Only -----------------------------===//
19280b57cec5SDimitry Andric  multiclass VOP3Only_Real_gfx10<bits<10> op> {
19290b57cec5SDimitry Andric    def _e64_gfx10 :
19300b57cec5SDimitry Andric      VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX10>,
1931fe6060f1SDimitry Andric      VOP3e_gfx10<op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl> {
1932fe6060f1SDimitry Andric        let IsSingle = 1;
1933fe6060f1SDimitry Andric      }
19340b57cec5SDimitry Andric  }
19350b57cec5SDimitry Andric
19360b57cec5SDimitry Andric  //===---------------------------- VOP3beOnly ----------------------------===//
1937e8d8bef9SDimitry Andric  multiclass VOP3beOnly_Real_gfx10<bits<10> op> {
19380b57cec5SDimitry Andric    def _e64_gfx10 :
1939e8d8bef9SDimitry Andric      VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX10>,
1940fe6060f1SDimitry Andric      VOP3be_gfx10<op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl> {
1941fe6060f1SDimitry Andric        let IsSingle = 1;
1942fe6060f1SDimitry Andric      }
19430b57cec5SDimitry Andric  }
194481ad6265SDimitry Andric} // End AssemblerPredicate = isGFX10Only, DecoderNamespace = "GFX10"
194581ad6265SDimitry Andric
194681ad6265SDimitry Andricmulticlass VOP2Only_Real_MADK_gfx10_gfx11<bits<6> op> :
19475f757f3fSDimitry Andric  VOP2Only_Real_MADK_gfx10<op>, VOP2Only_Real_MADK<GFX11Gen, op>;
19485f757f3fSDimitry Andric
19495f757f3fSDimitry Andricmulticlass VOP2Only_Real_MADK_gfx10_gfx11_gfx12<bits<6> op> :
19505f757f3fSDimitry Andric  VOP2Only_Real_MADK_gfx10_gfx11<op>, VOP2Only_Real_MADK<GFX12Gen, op>;
19510b57cec5SDimitry Andric
19528bcb0991SDimitry Andricmulticlass VOP2be_Real_gfx10<bits<6> op, string opName, string asmName> :
19538bcb0991SDimitry Andric  VOP2be_Real_e32_gfx10<op, opName, asmName>,
19548bcb0991SDimitry Andric  VOP2be_Real_e64_gfx10<op, opName, asmName>,
19558bcb0991SDimitry Andric  VOP2be_Real_sdwa_gfx10<op, opName, asmName>,
19568bcb0991SDimitry Andric  VOP2be_Real_dpp_gfx10<op, opName, asmName>,
19578bcb0991SDimitry Andric  VOP2be_Real_dpp8_gfx10<op, opName, asmName>;
19588bcb0991SDimitry Andric
19598bcb0991SDimitry Andricmulticlass VOP2e_Real_gfx10<bits<6> op, string opName, string asmName> :
19608bcb0991SDimitry Andric  VOP2_Real_e32_gfx10<op>,
19618bcb0991SDimitry Andric  VOP2_Real_e64_gfx10<op>,
19628bcb0991SDimitry Andric  VOP2be_Real_sdwa_gfx10<op, opName, asmName>,
19638bcb0991SDimitry Andric  VOP2be_Real_dpp_gfx10<op, opName, asmName>,
19648bcb0991SDimitry Andric  VOP2be_Real_dpp8_gfx10<op, opName, asmName>;
19650b57cec5SDimitry Andric
19660b57cec5SDimitry Andricmulticlass VOP2_Real_gfx10<bits<6> op> :
19670b57cec5SDimitry Andric  VOP2_Real_e32_gfx10<op>, VOP2_Real_e64_gfx10<op>,
19680b57cec5SDimitry Andric  VOP2_Real_sdwa_gfx10<op>, VOP2_Real_dpp_gfx10<op>, VOP2_Real_dpp8_gfx10<op>;
19690b57cec5SDimitry Andric
197081ad6265SDimitry Andricmulticlass VOP2_Real_gfx10_gfx11<bits<6> op> :
19715f757f3fSDimitry Andric  VOP2_Real_gfx10<op>, VOP2_Real_FULL<GFX11Gen, op>;
19725f757f3fSDimitry Andric
19735f757f3fSDimitry Andricmulticlass VOP2_Real_gfx10_gfx11_gfx12<bits<6> op> :
19745f757f3fSDimitry Andric  VOP2_Real_gfx10_gfx11<op>, VOP2_Real_FULL<GFX12Gen, op>;
197581ad6265SDimitry Andric
197681ad6265SDimitry Andricmulticlass VOP2_Real_with_name_gfx10<bits<6> op, string opName,
19770b57cec5SDimitry Andric                                     string asmName> :
19780b57cec5SDimitry Andric  VOP2_Real_e32_gfx10_with_name<op, opName, asmName>,
19790b57cec5SDimitry Andric  VOP2_Real_e64_gfx10_with_name<op, opName, asmName>,
19800b57cec5SDimitry Andric  VOP2_Real_sdwa_gfx10_with_name<op, opName, asmName>,
19810b57cec5SDimitry Andric  VOP2_Real_dpp_gfx10_with_name<op, opName, asmName>,
19820b57cec5SDimitry Andric  VOP2_Real_dpp8_gfx10_with_name<op, opName, asmName>;
19830b57cec5SDimitry Andric
19845f757f3fSDimitry Andricmulticlass VOP2_Real_with_name_gfx10_gfx11_gfx12<bits<6> op, string opName,
198581ad6265SDimitry Andric                                                 string asmName> :
198681ad6265SDimitry Andric  VOP2_Real_with_name_gfx10<op, opName, asmName>,
19875f757f3fSDimitry Andric  VOP2_Real_FULL_with_name<GFX11Gen, op, opName, asmName>,
19885f757f3fSDimitry Andric  VOP2_Real_FULL_with_name<GFX12Gen, op, opName, asmName>;
198981ad6265SDimitry Andric
1990e8d8bef9SDimitry Andric// NB: Same opcode as v_mac_legacy_f32
1991e8d8bef9SDimitry Andriclet DecoderNamespace = "GFX10_B" in
1992e8d8bef9SDimitry Andricdefm V_FMAC_LEGACY_F32 : VOP2_Real_gfx10<0x006>;
1993e8d8bef9SDimitry Andric
19945f757f3fSDimitry Andricdefm V_XNOR_B32        : VOP2_Real_gfx10_gfx11_gfx12<0x01e>;
19955f757f3fSDimitry Andricdefm V_FMAC_F32        : VOP2_Real_gfx10_gfx11_gfx12<0x02b>;
19965f757f3fSDimitry Andricdefm V_FMAMK_F32       : VOP2Only_Real_MADK_gfx10_gfx11_gfx12<0x02c>;
19975f757f3fSDimitry Andricdefm V_FMAAK_F32       : VOP2Only_Real_MADK_gfx10_gfx11_gfx12<0x02d>;
1998bdd1243dSDimitry Andricdefm V_ADD_F16         : VOP2_Real_gfx10<0x032>;
1999bdd1243dSDimitry Andricdefm V_SUB_F16         : VOP2_Real_gfx10<0x033>;
2000bdd1243dSDimitry Andricdefm V_SUBREV_F16      : VOP2_Real_gfx10<0x034>;
2001bdd1243dSDimitry Andricdefm V_MUL_F16         : VOP2_Real_gfx10<0x035>;
2002bdd1243dSDimitry Andricdefm V_FMAC_F16        : VOP2_Real_gfx10<0x036>;
2003bdd1243dSDimitry Andricdefm V_FMAMK_F16       : VOP2Only_Real_MADK_gfx10<0x037>;
2004bdd1243dSDimitry Andricdefm V_FMAAK_F16       : VOP2Only_Real_MADK_gfx10<0x038>;
2005bdd1243dSDimitry Andricdefm V_MAX_F16         : VOP2_Real_gfx10<0x039>;
2006bdd1243dSDimitry Andricdefm V_MIN_F16         : VOP2_Real_gfx10<0x03a>;
2007bdd1243dSDimitry Andricdefm V_LDEXP_F16       : VOP2_Real_gfx10<0x03b>;
2008fe6060f1SDimitry Andric
2009fe6060f1SDimitry Andriclet IsSingle = 1 in {
20100b57cec5SDimitry Andric  defm V_PK_FMAC_F16     : VOP2_Real_e32_gfx10<0x03c>;
2011fe6060f1SDimitry Andric}
20120b57cec5SDimitry Andric
20130b57cec5SDimitry Andric// VOP2 no carry-in, carry-out.
20140b57cec5SDimitry Andricdefm V_ADD_NC_U32 :
20155f757f3fSDimitry Andric  VOP2_Real_with_name_gfx10_gfx11_gfx12<0x025, "V_ADD_U32", "v_add_nc_u32">;
20160b57cec5SDimitry Andricdefm V_SUB_NC_U32 :
20175f757f3fSDimitry Andric  VOP2_Real_with_name_gfx10_gfx11_gfx12<0x026, "V_SUB_U32", "v_sub_nc_u32">;
20180b57cec5SDimitry Andricdefm V_SUBREV_NC_U32 :
20195f757f3fSDimitry Andric  VOP2_Real_with_name_gfx10_gfx11_gfx12<0x027, "V_SUBREV_U32", "v_subrev_nc_u32">;
20200b57cec5SDimitry Andric
20210b57cec5SDimitry Andric// VOP2 carry-in, carry-out.
20220b57cec5SDimitry Andricdefm V_ADD_CO_CI_U32 :
20230b57cec5SDimitry Andric  VOP2be_Real_gfx10<0x028, "V_ADDC_U32", "v_add_co_ci_u32">;
20240b57cec5SDimitry Andricdefm V_SUB_CO_CI_U32 :
20250b57cec5SDimitry Andric  VOP2be_Real_gfx10<0x029, "V_SUBB_U32", "v_sub_co_ci_u32">;
20260b57cec5SDimitry Andricdefm V_SUBREV_CO_CI_U32 :
20270b57cec5SDimitry Andric  VOP2be_Real_gfx10<0x02a, "V_SUBBREV_U32", "v_subrev_co_ci_u32">;
20280b57cec5SDimitry Andric
20298bcb0991SDimitry Andricdefm V_CNDMASK_B32 :
20308bcb0991SDimitry Andric  VOP2e_Real_gfx10<0x001, "V_CNDMASK_B32", "v_cndmask_b32">;
20318bcb0991SDimitry Andric
20320b57cec5SDimitry Andric// VOP3 only.
20330b57cec5SDimitry Andricdefm V_BFM_B32            : VOP3Only_Real_gfx10<0x363>;
20340b57cec5SDimitry Andricdefm V_BCNT_U32_B32       : VOP3Only_Real_gfx10<0x364>;
20350b57cec5SDimitry Andricdefm V_MBCNT_LO_U32_B32   : VOP3Only_Real_gfx10<0x365>;
20360b57cec5SDimitry Andricdefm V_MBCNT_HI_U32_B32   : VOP3Only_Real_gfx10<0x366>;
20370b57cec5SDimitry Andricdefm V_LDEXP_F32          : VOP3Only_Real_gfx10<0x362>;
20380b57cec5SDimitry Andricdefm V_CVT_PKNORM_I16_F32 : VOP3Only_Real_gfx10<0x368>;
20390b57cec5SDimitry Andricdefm V_CVT_PKNORM_U16_F32 : VOP3Only_Real_gfx10<0x369>;
20400b57cec5SDimitry Andricdefm V_CVT_PK_U16_U32     : VOP3Only_Real_gfx10<0x36a>;
20410b57cec5SDimitry Andricdefm V_CVT_PK_I16_I32     : VOP3Only_Real_gfx10<0x36b>;
20420b57cec5SDimitry Andric
2043e8d8bef9SDimitry Andric// VOP3 carry-out.
2044e8d8bef9SDimitry Andricdefm V_ADD_CO_U32 : VOP3beOnly_Real_gfx10<0x30f>;
2045e8d8bef9SDimitry Andricdefm V_SUB_CO_U32 : VOP3beOnly_Real_gfx10<0x310>;
2046e8d8bef9SDimitry Andricdefm V_SUBREV_CO_U32 : VOP3beOnly_Real_gfx10<0x319>;
20470b57cec5SDimitry Andric
204881ad6265SDimitry Andriclet SubtargetPredicate = isGFX10Only in {
20490b57cec5SDimitry Andric  defm : VOP2eInstAliases<V_CNDMASK_B32_e32, V_CNDMASK_B32_e32_gfx10>;
20500b57cec5SDimitry Andric
20510b57cec5SDimitry Andric  defm : VOP2bInstAliases<
20520b57cec5SDimitry Andric    V_ADDC_U32_e32, V_ADD_CO_CI_U32_e32_gfx10, "v_add_co_ci_u32">;
20530b57cec5SDimitry Andric  defm : VOP2bInstAliases<
20540b57cec5SDimitry Andric    V_SUBB_U32_e32, V_SUB_CO_CI_U32_e32_gfx10, "v_sub_co_ci_u32">;
20550b57cec5SDimitry Andric  defm : VOP2bInstAliases<
20560b57cec5SDimitry Andric    V_SUBBREV_U32_e32, V_SUBREV_CO_CI_U32_e32_gfx10, "v_subrev_co_ci_u32">;
205781ad6265SDimitry Andric} // End SubtargetPredicate = isGFX10Only
20580b57cec5SDimitry Andric
20590b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
206081ad6265SDimitry Andric// GFX6, GFX7, GFX10, GFX11
20610b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
20620b57cec5SDimitry Andric
20630b57cec5SDimitry Andricclass VOP2_DPPe <bits<6> op, VOP2_DPP_Pseudo ps, VOPProfile P = ps.Pfl> :
20640b57cec5SDimitry Andric  VOP_DPPe <P> {
20650b57cec5SDimitry Andric  bits<8> vdst;
20660b57cec5SDimitry Andric  bits<8> src1;
20670b57cec5SDimitry Andric  let Inst{8-0}   = 0xfa; //dpp
20680b57cec5SDimitry Andric  let Inst{16-9}  = !if(P.HasSrc1, src1{7-0}, 0);
20690b57cec5SDimitry Andric  let Inst{24-17} = !if(P.EmitDst, vdst{7-0}, 0);
20700b57cec5SDimitry Andric  let Inst{30-25} = op;
20710b57cec5SDimitry Andric  let Inst{31}    = 0x0; //encoding
20720b57cec5SDimitry Andric}
20730b57cec5SDimitry Andric
20740b57cec5SDimitry Andriclet AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" in {
2075e8d8bef9SDimitry Andric  multiclass VOP2_Lane_Real_gfx6_gfx7<bits<6> op> {
20760b57cec5SDimitry Andric    def _gfx6_gfx7 :
20770b57cec5SDimitry Andric      VOP2_Real<!cast<VOP2_Pseudo>(NAME), SIEncodingFamily.SI>,
20780b57cec5SDimitry Andric      VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME).Pfl>;
20790b57cec5SDimitry Andric  }
20800b57cec5SDimitry Andric  multiclass VOP2Only_Real_MADK_gfx6_gfx7<bits<6> op> {
20810b57cec5SDimitry Andric    def _gfx6_gfx7 :
20820b57cec5SDimitry Andric      VOP2_Real<!cast<VOP2_Pseudo>(NAME), SIEncodingFamily.SI>,
20830b57cec5SDimitry Andric      VOP2_MADKe<op{5-0}, !cast<VOP2_Pseudo>(NAME).Pfl>;
20840b57cec5SDimitry Andric  }
2085fe6060f1SDimitry Andric  multiclass VOP2_Real_e32_gfx6_gfx7<bits<6> op, string opName = NAME> {
20860b57cec5SDimitry Andric    def _e32_gfx6_gfx7 :
2087fe6060f1SDimitry Andric      VOP2_Real<!cast<VOP2_Pseudo>(opName#"_e32"), SIEncodingFamily.SI>,
2088fe6060f1SDimitry Andric      VOP2e<op{5-0}, !cast<VOP2_Pseudo>(opName#"_e32").Pfl>;
20890b57cec5SDimitry Andric  }
2090fe6060f1SDimitry Andric  multiclass VOP2_Real_e64_gfx6_gfx7<bits<6> op, string opName = NAME> {
20910b57cec5SDimitry Andric    def _e64_gfx6_gfx7 :
2092fe6060f1SDimitry Andric      VOP3_Real<!cast<VOP3_Pseudo>(opName#"_e64"), SIEncodingFamily.SI>,
2093fe6060f1SDimitry Andric      VOP3e_gfx6_gfx7<{1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(opName#"_e64").Pfl>;
20940b57cec5SDimitry Andric  }
2095fe6060f1SDimitry Andric  multiclass VOP2be_Real_e64_gfx6_gfx7<bits<6> op, string opName = NAME> {
20960b57cec5SDimitry Andric    def _e64_gfx6_gfx7 :
2097fe6060f1SDimitry Andric      VOP3_Real<!cast<VOP3_Pseudo>(opName#"_e64"), SIEncodingFamily.SI>,
2098fe6060f1SDimitry Andric      VOP3be_gfx6_gfx7<{1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(opName#"_e64").Pfl>;
20990b57cec5SDimitry Andric  }
21000b57cec5SDimitry Andric} // End AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7"
21010b57cec5SDimitry Andric
21020b57cec5SDimitry Andricmulticlass VOP2Only_Real_MADK_gfx6_gfx7_gfx10<bits<6> op> :
21030b57cec5SDimitry Andric  VOP2Only_Real_MADK_gfx6_gfx7<op>, VOP2Only_Real_MADK_gfx10<op>;
21040b57cec5SDimitry Andric
21050b57cec5SDimitry Andricmulticlass VOP2_Real_gfx6_gfx7<bits<6> op> :
21060b57cec5SDimitry Andric  VOP2_Real_e32_gfx6_gfx7<op>, VOP2_Real_e64_gfx6_gfx7<op>;
21070b57cec5SDimitry Andric
21080b57cec5SDimitry Andricmulticlass VOP2_Real_gfx6_gfx7_gfx10<bits<6> op> :
21090b57cec5SDimitry Andric  VOP2_Real_gfx6_gfx7<op>, VOP2_Real_gfx10<op>;
21100b57cec5SDimitry Andric
211181ad6265SDimitry Andricmulticlass VOP2_Real_gfx6_gfx7_gfx10_gfx11<bits<6> op> :
21125f757f3fSDimitry Andric  VOP2_Real_gfx6_gfx7_gfx10<op>, VOP2_Real_FULL<GFX11Gen, op>;
21135f757f3fSDimitry Andric
21145f757f3fSDimitry Andricmulticlass VOP2_Real_gfx6_gfx7_gfx10_gfx11_gfx12<bits<6> op> :
21155f757f3fSDimitry Andric  VOP2_Real_gfx6_gfx7_gfx10_gfx11<op>, VOP2_Real_FULL<GFX12Gen, op>;
211681ad6265SDimitry Andric
21170b57cec5SDimitry Andricmulticlass VOP2be_Real_gfx6_gfx7<bits<6> op> :
21180b57cec5SDimitry Andric  VOP2_Real_e32_gfx6_gfx7<op>, VOP2be_Real_e64_gfx6_gfx7<op>;
21190b57cec5SDimitry Andric
2120e8d8bef9SDimitry Andricmulticlass VOP2be_Real_gfx6_gfx7_with_name<bits<6> op,
2121fe6060f1SDimitry Andric  string opName, string asmName>  {
2122fe6060f1SDimitry Andric  defvar ps32 = !cast<VOP2_Pseudo>(opName#"_e32");
2123fe6060f1SDimitry Andric  defvar ps64 = !cast<VOP3_Pseudo>(opName#"_e64");
2124e8d8bef9SDimitry Andric
2125e8d8bef9SDimitry Andric  let AsmString = asmName # ps32.AsmOperands in {
2126fe6060f1SDimitry Andric    defm "" : VOP2_Real_e32_gfx6_gfx7<op, opName>;
2127e8d8bef9SDimitry Andric  }
2128e8d8bef9SDimitry Andric
2129e8d8bef9SDimitry Andric   let AsmString = asmName # ps64.AsmOperands in {
2130fe6060f1SDimitry Andric    defm "" : VOP2be_Real_e64_gfx6_gfx7<op, opName>;
2131e8d8bef9SDimitry Andric  }
2132e8d8bef9SDimitry Andric}
2133e8d8bef9SDimitry Andric
21340b57cec5SDimitry Andricdefm V_CNDMASK_B32        : VOP2_Real_gfx6_gfx7<0x000>;
21350b57cec5SDimitry Andricdefm V_MIN_LEGACY_F32     : VOP2_Real_gfx6_gfx7<0x00d>;
21360b57cec5SDimitry Andricdefm V_MAX_LEGACY_F32     : VOP2_Real_gfx6_gfx7<0x00e>;
21370b57cec5SDimitry Andricdefm V_LSHR_B32           : VOP2_Real_gfx6_gfx7<0x015>;
21380b57cec5SDimitry Andricdefm V_ASHR_I32           : VOP2_Real_gfx6_gfx7<0x017>;
21390b57cec5SDimitry Andricdefm V_LSHL_B32           : VOP2_Real_gfx6_gfx7<0x019>;
21400b57cec5SDimitry Andricdefm V_BFM_B32            : VOP2_Real_gfx6_gfx7<0x01e>;
21410b57cec5SDimitry Andricdefm V_BCNT_U32_B32       : VOP2_Real_gfx6_gfx7<0x022>;
21420b57cec5SDimitry Andricdefm V_MBCNT_LO_U32_B32   : VOP2_Real_gfx6_gfx7<0x023>;
21430b57cec5SDimitry Andricdefm V_MBCNT_HI_U32_B32   : VOP2_Real_gfx6_gfx7<0x024>;
21440b57cec5SDimitry Andricdefm V_LDEXP_F32          : VOP2_Real_gfx6_gfx7<0x02b>;
21450b57cec5SDimitry Andricdefm V_CVT_PKACCUM_U8_F32 : VOP2_Real_gfx6_gfx7<0x02c>;
21460b57cec5SDimitry Andricdefm V_CVT_PKNORM_I16_F32 : VOP2_Real_gfx6_gfx7<0x02d>;
21470b57cec5SDimitry Andricdefm V_CVT_PKNORM_U16_F32 : VOP2_Real_gfx6_gfx7<0x02e>;
21480b57cec5SDimitry Andricdefm V_CVT_PK_U16_U32     : VOP2_Real_gfx6_gfx7<0x030>;
21490b57cec5SDimitry Andricdefm V_CVT_PK_I16_I32     : VOP2_Real_gfx6_gfx7<0x031>;
2150e8d8bef9SDimitry Andric
2151e8d8bef9SDimitry Andric// V_ADD_I32, V_SUB_I32, and V_SUBREV_I32 where renamed to *_U32 in
2152e8d8bef9SDimitry Andric// VI, but the VI instructions behave the same as the SI versions.
2153e8d8bef9SDimitry Andricdefm V_ADD_I32            : VOP2be_Real_gfx6_gfx7_with_name<0x025, "V_ADD_CO_U32", "v_add_i32">;
2154e8d8bef9SDimitry Andricdefm V_SUB_I32            : VOP2be_Real_gfx6_gfx7_with_name<0x026, "V_SUB_CO_U32", "v_sub_i32">;
2155e8d8bef9SDimitry Andricdefm V_SUBREV_I32         : VOP2be_Real_gfx6_gfx7_with_name<0x027, "V_SUBREV_CO_U32", "v_subrev_i32">;
21560b57cec5SDimitry Andricdefm V_ADDC_U32           : VOP2be_Real_gfx6_gfx7<0x028>;
21570b57cec5SDimitry Andricdefm V_SUBB_U32           : VOP2be_Real_gfx6_gfx7<0x029>;
21580b57cec5SDimitry Andricdefm V_SUBBREV_U32        : VOP2be_Real_gfx6_gfx7<0x02a>;
21590b57cec5SDimitry Andric
2160e8d8bef9SDimitry Andricdefm V_READLANE_B32 : VOP2_Lane_Real_gfx6_gfx7<0x001>;
21610b57cec5SDimitry Andric
21625ffd83dbSDimitry Andriclet InOperandList = (ins SSrcOrLds_b32:$src0, SCSrc_b32:$src1, VGPR_32:$vdst_in) in {
2163e8d8bef9SDimitry Andric  defm V_WRITELANE_B32 : VOP2_Lane_Real_gfx6_gfx7<0x002>;
21645ffd83dbSDimitry Andric} // End InOperandList = (ins SSrcOrLds_b32:$src0, SCSrc_b32:$src1, VGPR_32:$vdst_in)
21650b57cec5SDimitry Andric
21660b57cec5SDimitry Andriclet SubtargetPredicate = isGFX6GFX7 in {
21670b57cec5SDimitry Andric  defm : VOP2eInstAliases<V_CNDMASK_B32_e32, V_CNDMASK_B32_e32_gfx6_gfx7>;
2168e8d8bef9SDimitry Andric  defm : VOP2eInstAliases<V_ADD_CO_U32_e32, V_ADD_I32_e32_gfx6_gfx7>;
2169e8d8bef9SDimitry Andric  defm : VOP2eInstAliases<V_SUB_CO_U32_e32, V_SUB_I32_e32_gfx6_gfx7>;
2170e8d8bef9SDimitry Andric  defm : VOP2eInstAliases<V_SUBREV_CO_U32_e32, V_SUBREV_I32_e32_gfx6_gfx7>;
2171e8d8bef9SDimitry Andric
2172e8d8bef9SDimitry Andric  def : VOP2e64InstAlias<V_ADD_CO_U32_e64, V_ADD_I32_e64_gfx6_gfx7>;
2173e8d8bef9SDimitry Andric  def : VOP2e64InstAlias<V_SUB_CO_U32_e64, V_SUB_I32_e64_gfx6_gfx7>;
2174e8d8bef9SDimitry Andric  def : VOP2e64InstAlias<V_SUBREV_CO_U32_e64, V_SUBREV_I32_e64_gfx6_gfx7>;
21750b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX6GFX7
21760b57cec5SDimitry Andric
21775f757f3fSDimitry Andricdefm V_ADD_F32            : VOP2_Real_gfx6_gfx7_gfx10_gfx11_gfx12<0x003>;
21785f757f3fSDimitry Andricdefm V_SUB_F32            : VOP2_Real_gfx6_gfx7_gfx10_gfx11_gfx12<0x004>;
21795f757f3fSDimitry Andricdefm V_SUBREV_F32         : VOP2_Real_gfx6_gfx7_gfx10_gfx11_gfx12<0x005>;
21800b57cec5SDimitry Andricdefm V_MAC_LEGACY_F32     : VOP2_Real_gfx6_gfx7_gfx10<0x006>;
21810b57cec5SDimitry Andricdefm V_MUL_LEGACY_F32     : VOP2_Real_gfx6_gfx7_gfx10<0x007>;
21825f757f3fSDimitry Andricdefm V_MUL_F32            : VOP2_Real_gfx6_gfx7_gfx10_gfx11_gfx12<0x008>;
21835f757f3fSDimitry Andricdefm V_MUL_I32_I24        : VOP2_Real_gfx6_gfx7_gfx10_gfx11_gfx12<0x009>;
21845f757f3fSDimitry Andricdefm V_MUL_HI_I32_I24     : VOP2_Real_gfx6_gfx7_gfx10_gfx11_gfx12<0x00a>;
21855f757f3fSDimitry Andricdefm V_MUL_U32_U24        : VOP2_Real_gfx6_gfx7_gfx10_gfx11_gfx12<0x00b>;
21865f757f3fSDimitry Andricdefm V_MUL_HI_U32_U24     : VOP2_Real_gfx6_gfx7_gfx10_gfx11_gfx12<0x00c>;
218781ad6265SDimitry Andricdefm V_MIN_F32            : VOP2_Real_gfx6_gfx7_gfx10_gfx11<0x00f>;
218881ad6265SDimitry Andricdefm V_MAX_F32            : VOP2_Real_gfx6_gfx7_gfx10_gfx11<0x010>;
21895f757f3fSDimitry Andricdefm V_MIN_I32            : VOP2_Real_gfx6_gfx7_gfx10_gfx11_gfx12<0x011>;
21905f757f3fSDimitry Andricdefm V_MAX_I32            : VOP2_Real_gfx6_gfx7_gfx10_gfx11_gfx12<0x012>;
21915f757f3fSDimitry Andricdefm V_MIN_U32            : VOP2_Real_gfx6_gfx7_gfx10_gfx11_gfx12<0x013>;
21925f757f3fSDimitry Andricdefm V_MAX_U32            : VOP2_Real_gfx6_gfx7_gfx10_gfx11_gfx12<0x014>;
21930b57cec5SDimitry Andricdefm V_LSHRREV_B32        : VOP2_Real_gfx6_gfx7_gfx10<0x016>;
21940b57cec5SDimitry Andricdefm V_ASHRREV_I32        : VOP2_Real_gfx6_gfx7_gfx10<0x018>;
21950b57cec5SDimitry Andricdefm V_LSHLREV_B32        : VOP2_Real_gfx6_gfx7_gfx10<0x01a>;
21965f757f3fSDimitry Andricdefm V_AND_B32            : VOP2_Real_gfx6_gfx7_gfx10_gfx11_gfx12<0x01b>;
21975f757f3fSDimitry Andricdefm V_OR_B32             : VOP2_Real_gfx6_gfx7_gfx10_gfx11_gfx12<0x01c>;
21985f757f3fSDimitry Andricdefm V_XOR_B32            : VOP2_Real_gfx6_gfx7_gfx10_gfx11_gfx12<0x01d>;
21990b57cec5SDimitry Andricdefm V_MAC_F32            : VOP2_Real_gfx6_gfx7_gfx10<0x01f>;
22000b57cec5SDimitry Andricdefm V_CVT_PKRTZ_F16_F32  : VOP2_Real_gfx6_gfx7_gfx10<0x02f>;
22010b57cec5SDimitry Andricdefm V_MADMK_F32          : VOP2Only_Real_MADK_gfx6_gfx7_gfx10<0x020>;
22020b57cec5SDimitry Andricdefm V_MADAK_F32          : VOP2Only_Real_MADK_gfx6_gfx7_gfx10<0x021>;
22030b57cec5SDimitry Andric
22040b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
22050b57cec5SDimitry Andric// GFX8, GFX9 (VI).
22060b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
22070b57cec5SDimitry Andric
2208480093f4SDimitry Andriclet AssemblerPredicate = isGFX8GFX9, DecoderNamespace = "GFX8" in {
22090b57cec5SDimitry Andric
22100b57cec5SDimitry Andricmulticlass VOP2_Real_MADK_vi <bits<6> op> {
22110b57cec5SDimitry Andric  def _vi : VOP2_Real<!cast<VOP2_Pseudo>(NAME), SIEncodingFamily.VI>,
22120b57cec5SDimitry Andric            VOP2_MADKe<op{5-0}, !cast<VOP2_Pseudo>(NAME).Pfl>;
22130b57cec5SDimitry Andric}
22140b57cec5SDimitry Andric
221581ad6265SDimitry Andricmulticlass VOP2_Real_MADK_gfx940 <bits<6> op> {
221681ad6265SDimitry Andric  def _gfx940 : VOP2_Real<!cast<VOP2_Pseudo>(NAME), SIEncodingFamily.GFX940>,
221781ad6265SDimitry Andric                VOP2_MADKe<op{5-0}, !cast<VOP2_Pseudo>(NAME).Pfl> {
221881ad6265SDimitry Andric    let DecoderNamespace = "GFX9";
221981ad6265SDimitry Andric  }
222081ad6265SDimitry Andric}
222181ad6265SDimitry Andric
22220b57cec5SDimitry Andricmulticlass VOP2_Real_e32_vi <bits<6> op> {
22230b57cec5SDimitry Andric  def _e32_vi :
22240b57cec5SDimitry Andric    VOP2_Real<!cast<VOP2_Pseudo>(NAME#"_e32"), SIEncodingFamily.VI>,
22250b57cec5SDimitry Andric    VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME#"_e32").Pfl>;
22260b57cec5SDimitry Andric}
22270b57cec5SDimitry Andric
22280b57cec5SDimitry Andricmulticlass VOP2_Real_e64_vi <bits<10> op> {
22290b57cec5SDimitry Andric  def _e64_vi :
22300b57cec5SDimitry Andric    VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.VI>,
22310b57cec5SDimitry Andric    VOP3e_vi <op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
22320b57cec5SDimitry Andric}
22330b57cec5SDimitry Andric
22340b57cec5SDimitry Andricmulticlass VOP2_Real_e64only_vi <bits<10> op> {
22350b57cec5SDimitry Andric  def _e64_vi :
22360b57cec5SDimitry Andric    VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.VI>,
22370b57cec5SDimitry Andric    VOP3e_vi <op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl> {
2238fe6060f1SDimitry Andric      let IsSingle = 1;
22390b57cec5SDimitry Andric    }
22400b57cec5SDimitry Andric}
22410b57cec5SDimitry Andric
22420b57cec5SDimitry Andricmulticlass Base_VOP2_Real_e32e64_vi <bits<6> op> :
22430b57cec5SDimitry Andric  VOP2_Real_e32_vi<op>,
22440b57cec5SDimitry Andric  VOP2_Real_e64_vi<{0, 1, 0, 0, op{5-0}}>;
22450b57cec5SDimitry Andric
2246480093f4SDimitry Andric} // End AssemblerPredicate = isGFX8GFX9, DecoderNamespace = "GFX8"
22470b57cec5SDimitry Andric
22480b57cec5SDimitry Andricmulticlass VOP2_SDWA_Real <bits<6> op> {
224906c3fb27SDimitry Andric  if !cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA then
22500b57cec5SDimitry Andric  def _sdwa_vi :
22510b57cec5SDimitry Andric    VOP_SDWA_Real <!cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa")>,
22520b57cec5SDimitry Andric    VOP2_SDWAe <op{5-0}, !cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa").Pfl>;
22530b57cec5SDimitry Andric}
22540b57cec5SDimitry Andric
22550b57cec5SDimitry Andricmulticlass VOP2_SDWA9_Real <bits<6> op> {
225606c3fb27SDimitry Andric  if !cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA9 then
22570b57cec5SDimitry Andric  def _sdwa_gfx9 :
22580b57cec5SDimitry Andric    VOP_SDWA9_Real <!cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa")>,
22590b57cec5SDimitry Andric    VOP2_SDWA9Ae <op{5-0}, !cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa").Pfl>;
22600b57cec5SDimitry Andric}
22610b57cec5SDimitry Andric
2262*0fca6ea1SDimitry Andriclet AssemblerPredicate = isGFX8Only, DecoderNamespace = "GFX8" in {
22630b57cec5SDimitry Andric
22640b57cec5SDimitry Andricmulticlass VOP2be_Real_e32e64_vi_only <bits<6> op, string OpName, string AsmName> {
22650b57cec5SDimitry Andric  def _e32_vi :
22660b57cec5SDimitry Andric    VOP2_Real<!cast<VOP2_Pseudo>(OpName#"_e32"), SIEncodingFamily.VI>,
22670b57cec5SDimitry Andric    VOP2e<op{5-0}, !cast<VOP2_Pseudo>(OpName#"_e32").Pfl> {
22680b57cec5SDimitry Andric      VOP2_Pseudo ps = !cast<VOP2_Pseudo>(OpName#"_e32");
22690b57cec5SDimitry Andric      let AsmString = AsmName # ps.AsmOperands;
22700b57cec5SDimitry Andric    }
22710b57cec5SDimitry Andric  def _e64_vi :
22720b57cec5SDimitry Andric    VOP3_Real<!cast<VOP3_Pseudo>(OpName#"_e64"), SIEncodingFamily.VI>,
22730b57cec5SDimitry Andric    VOP3be_vi <{0, 1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(OpName#"_e64").Pfl> {
22740b57cec5SDimitry Andric      VOP3_Pseudo ps = !cast<VOP3_Pseudo>(OpName#"_e64");
22750b57cec5SDimitry Andric      let AsmString = AsmName # ps.AsmOperands;
22760b57cec5SDimitry Andric    }
227706c3fb27SDimitry Andric  if !cast<VOP2_Pseudo>(OpName#"_e32").Pfl.HasExtSDWA then
22780b57cec5SDimitry Andric    def _sdwa_vi :
22790b57cec5SDimitry Andric      VOP_SDWA_Real <!cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa")>,
22800b57cec5SDimitry Andric      VOP2_SDWAe <op{5-0}, !cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa").Pfl> {
22810b57cec5SDimitry Andric        VOP2_SDWA_Pseudo ps = !cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa");
22820b57cec5SDimitry Andric        let AsmString = AsmName # ps.AsmOperands;
22830b57cec5SDimitry Andric      }
228406c3fb27SDimitry Andric  if !cast<VOP2_Pseudo>(OpName#"_e32").Pfl.HasExtDPP then
22850b57cec5SDimitry Andric    def _dpp_vi :
22860b57cec5SDimitry Andric      VOP_DPP_Real<!cast<VOP2_DPP_Pseudo>(OpName#"_dpp"), SIEncodingFamily.VI>,
22870b57cec5SDimitry Andric      VOP2_DPPe<op, !cast<VOP2_DPP_Pseudo>(OpName#"_dpp")> {
22880b57cec5SDimitry Andric        VOP2_DPP_Pseudo ps = !cast<VOP2_DPP_Pseudo>(OpName#"_dpp");
22890b57cec5SDimitry Andric        let AsmString = AsmName # ps.AsmOperands;
22900b57cec5SDimitry Andric      }
22910b57cec5SDimitry Andric}
22920b57cec5SDimitry Andric
2293*0fca6ea1SDimitry Andric} // End AssemblerPredicate = isGFX8Only, DecoderNamespace = "GFX8"
2294*0fca6ea1SDimitry Andric
2295*0fca6ea1SDimitry Andriclet AssemblerPredicate = isGFX9Only, DecoderNamespace = "GFX9" in {
22960b57cec5SDimitry Andric
22970b57cec5SDimitry Andricmulticlass VOP2be_Real_e32e64_gfx9 <bits<6> op, string OpName, string AsmName> {
22980b57cec5SDimitry Andric  def _e32_gfx9 :
22990b57cec5SDimitry Andric    VOP2_Real<!cast<VOP2_Pseudo>(OpName#"_e32"), SIEncodingFamily.GFX9>,
23000b57cec5SDimitry Andric    VOP2e<op{5-0}, !cast<VOP2_Pseudo>(OpName#"_e32").Pfl> {
23010b57cec5SDimitry Andric      VOP2_Pseudo ps = !cast<VOP2_Pseudo>(OpName#"_e32");
23020b57cec5SDimitry Andric      let AsmString = AsmName # ps.AsmOperands;
23030b57cec5SDimitry Andric    }
23040b57cec5SDimitry Andric  def _e64_gfx9 :
23050b57cec5SDimitry Andric    VOP3_Real<!cast<VOP3_Pseudo>(OpName#"_e64"), SIEncodingFamily.GFX9>,
23060b57cec5SDimitry Andric    VOP3be_vi <{0, 1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(OpName#"_e64").Pfl> {
23070b57cec5SDimitry Andric      VOP3_Pseudo ps = !cast<VOP3_Pseudo>(OpName#"_e64");
23080b57cec5SDimitry Andric      let AsmString = AsmName # ps.AsmOperands;
23090b57cec5SDimitry Andric    }
231006c3fb27SDimitry Andric  if !cast<VOP2_Pseudo>(OpName#"_e32").Pfl.HasExtSDWA9 then
23110b57cec5SDimitry Andric    def _sdwa_gfx9 :
23120b57cec5SDimitry Andric      VOP_SDWA9_Real <!cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa")>,
23130b57cec5SDimitry Andric      VOP2_SDWA9Ae <op{5-0}, !cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa").Pfl> {
23140b57cec5SDimitry Andric        VOP2_SDWA_Pseudo ps = !cast<VOP2_SDWA_Pseudo>(OpName#"_sdwa");
23150b57cec5SDimitry Andric        let AsmString = AsmName # ps.AsmOperands;
23160b57cec5SDimitry Andric      }
231706c3fb27SDimitry Andric  if !cast<VOP2_Pseudo>(OpName#"_e32").Pfl.HasExtDPP then
23180b57cec5SDimitry Andric    def _dpp_gfx9 :
23190b57cec5SDimitry Andric      VOP_DPP_Real<!cast<VOP2_DPP_Pseudo>(OpName#"_dpp"), SIEncodingFamily.GFX9>,
23200b57cec5SDimitry Andric      VOP2_DPPe<op, !cast<VOP2_DPP_Pseudo>(OpName#"_dpp")> {
23210b57cec5SDimitry Andric        VOP2_DPP_Pseudo ps = !cast<VOP2_DPP_Pseudo>(OpName#"_dpp");
23220b57cec5SDimitry Andric        let AsmString = AsmName # ps.AsmOperands;
23230b57cec5SDimitry Andric      }
23240b57cec5SDimitry Andric}
23250b57cec5SDimitry Andric
23260b57cec5SDimitry Andricmulticlass VOP2_Real_e32e64_gfx9 <bits<6> op> {
23270b57cec5SDimitry Andric  def _e32_gfx9 :
23280b57cec5SDimitry Andric    VOP2_Real<!cast<VOP2_Pseudo>(NAME#"_e32"), SIEncodingFamily.GFX9>,
2329*0fca6ea1SDimitry Andric    VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME#"_e32").Pfl>;
23300b57cec5SDimitry Andric  def _e64_gfx9 :
23310b57cec5SDimitry Andric    VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX9>,
2332*0fca6ea1SDimitry Andric    VOP3e_vi <{0, 1, 0, 0, op{5-0}}, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
233306c3fb27SDimitry Andric  if !cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtSDWA9 then
23340b57cec5SDimitry Andric    def _sdwa_gfx9 :
23350b57cec5SDimitry Andric      VOP_SDWA9_Real <!cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa")>,
23360b57cec5SDimitry Andric      VOP2_SDWA9Ae <op{5-0}, !cast<VOP2_SDWA_Pseudo>(NAME#"_sdwa").Pfl> {
23370b57cec5SDimitry Andric      }
233806c3fb27SDimitry Andric  if !cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtDPP then
23390b57cec5SDimitry Andric    def _dpp_gfx9 :
23400b57cec5SDimitry Andric      VOP_DPP_Real<!cast<VOP2_DPP_Pseudo>(NAME#"_dpp"), SIEncodingFamily.GFX9>,
2341*0fca6ea1SDimitry Andric      VOP2_DPPe<op, !cast<VOP2_DPP_Pseudo>(NAME#"_dpp")>;
23420b57cec5SDimitry Andric}
23430b57cec5SDimitry Andric
2344*0fca6ea1SDimitry Andric} // End AssemblerPredicate = isGFX9Only, DecoderNamespace = "GFX9"
23450b57cec5SDimitry Andric
23460b57cec5SDimitry Andricmulticlass VOP2_Real_e32e64_vi <bits<6> op> :
23470b57cec5SDimitry Andric  Base_VOP2_Real_e32e64_vi<op>, VOP2_SDWA_Real<op>, VOP2_SDWA9_Real<op> {
23480b57cec5SDimitry Andric
234906c3fb27SDimitry Andric  if !cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtDPP then
23500b57cec5SDimitry Andric    def _dpp_vi :
23510b57cec5SDimitry Andric      VOP_DPP_Real<!cast<VOP2_DPP_Pseudo>(NAME#"_dpp"), SIEncodingFamily.VI>,
23520b57cec5SDimitry Andric      VOP2_DPPe<op, !cast<VOP2_DPP_Pseudo>(NAME#"_dpp")>;
23530b57cec5SDimitry Andric}
23540b57cec5SDimitry Andric
23550b57cec5SDimitry Andricdefm V_CNDMASK_B32        : VOP2_Real_e32e64_vi <0x0>;
23560b57cec5SDimitry Andricdefm V_ADD_F32            : VOP2_Real_e32e64_vi <0x1>;
23570b57cec5SDimitry Andricdefm V_SUB_F32            : VOP2_Real_e32e64_vi <0x2>;
23580b57cec5SDimitry Andricdefm V_SUBREV_F32         : VOP2_Real_e32e64_vi <0x3>;
2359fe6060f1SDimitry Andriclet AssemblerPredicate = isGCN3ExcludingGFX90A in
23600b57cec5SDimitry Andricdefm V_MUL_LEGACY_F32     : VOP2_Real_e32e64_vi <0x4>;
23610b57cec5SDimitry Andricdefm V_MUL_F32            : VOP2_Real_e32e64_vi <0x5>;
23620b57cec5SDimitry Andricdefm V_MUL_I32_I24        : VOP2_Real_e32e64_vi <0x6>;
23630b57cec5SDimitry Andricdefm V_MUL_HI_I32_I24     : VOP2_Real_e32e64_vi <0x7>;
23640b57cec5SDimitry Andricdefm V_MUL_U32_U24        : VOP2_Real_e32e64_vi <0x8>;
23650b57cec5SDimitry Andricdefm V_MUL_HI_U32_U24     : VOP2_Real_e32e64_vi <0x9>;
23660b57cec5SDimitry Andricdefm V_MIN_F32            : VOP2_Real_e32e64_vi <0xa>;
23670b57cec5SDimitry Andricdefm V_MAX_F32            : VOP2_Real_e32e64_vi <0xb>;
23680b57cec5SDimitry Andricdefm V_MIN_I32            : VOP2_Real_e32e64_vi <0xc>;
23690b57cec5SDimitry Andricdefm V_MAX_I32            : VOP2_Real_e32e64_vi <0xd>;
23700b57cec5SDimitry Andricdefm V_MIN_U32            : VOP2_Real_e32e64_vi <0xe>;
23710b57cec5SDimitry Andricdefm V_MAX_U32            : VOP2_Real_e32e64_vi <0xf>;
23720b57cec5SDimitry Andricdefm V_LSHRREV_B32        : VOP2_Real_e32e64_vi <0x10>;
23730b57cec5SDimitry Andricdefm V_ASHRREV_I32        : VOP2_Real_e32e64_vi <0x11>;
23740b57cec5SDimitry Andricdefm V_LSHLREV_B32        : VOP2_Real_e32e64_vi <0x12>;
23750b57cec5SDimitry Andricdefm V_AND_B32            : VOP2_Real_e32e64_vi <0x13>;
23760b57cec5SDimitry Andricdefm V_OR_B32             : VOP2_Real_e32e64_vi <0x14>;
23770b57cec5SDimitry Andricdefm V_XOR_B32            : VOP2_Real_e32e64_vi <0x15>;
23780b57cec5SDimitry Andricdefm V_MAC_F32            : VOP2_Real_e32e64_vi <0x16>;
23790b57cec5SDimitry Andricdefm V_MADMK_F32          : VOP2_Real_MADK_vi <0x17>;
23800b57cec5SDimitry Andricdefm V_MADAK_F32          : VOP2_Real_MADK_vi <0x18>;
23810b57cec5SDimitry Andric
2382e8d8bef9SDimitry Andricdefm V_ADD_U32            : VOP2be_Real_e32e64_vi_only <0x19, "V_ADD_CO_U32",     "v_add_u32">;
2383e8d8bef9SDimitry Andricdefm V_SUB_U32            : VOP2be_Real_e32e64_vi_only <0x1a, "V_SUB_CO_U32",     "v_sub_u32">;
2384e8d8bef9SDimitry Andricdefm V_SUBREV_U32         : VOP2be_Real_e32e64_vi_only <0x1b, "V_SUBREV_CO_U32",  "v_subrev_u32">;
23850b57cec5SDimitry Andricdefm V_ADDC_U32           : VOP2be_Real_e32e64_vi_only <0x1c, "V_ADDC_U32",    "v_addc_u32">;
23860b57cec5SDimitry Andricdefm V_SUBB_U32           : VOP2be_Real_e32e64_vi_only <0x1d, "V_SUBB_U32",    "v_subb_u32">;
23870b57cec5SDimitry Andricdefm V_SUBBREV_U32        : VOP2be_Real_e32e64_vi_only <0x1e, "V_SUBBREV_U32", "v_subbrev_u32">;
23880b57cec5SDimitry Andric
2389e8d8bef9SDimitry Andricdefm V_ADD_CO_U32         : VOP2be_Real_e32e64_gfx9 <0x19, "V_ADD_CO_U32",     "v_add_co_u32">;
2390e8d8bef9SDimitry Andricdefm V_SUB_CO_U32         : VOP2be_Real_e32e64_gfx9 <0x1a, "V_SUB_CO_U32",     "v_sub_co_u32">;
2391e8d8bef9SDimitry Andricdefm V_SUBREV_CO_U32      : VOP2be_Real_e32e64_gfx9 <0x1b, "V_SUBREV_CO_U32",  "v_subrev_co_u32">;
23920b57cec5SDimitry Andricdefm V_ADDC_CO_U32        : VOP2be_Real_e32e64_gfx9 <0x1c, "V_ADDC_U32",    "v_addc_co_u32">;
23930b57cec5SDimitry Andricdefm V_SUBB_CO_U32        : VOP2be_Real_e32e64_gfx9 <0x1d, "V_SUBB_U32",    "v_subb_co_u32">;
23940b57cec5SDimitry Andricdefm V_SUBBREV_CO_U32     : VOP2be_Real_e32e64_gfx9 <0x1e, "V_SUBBREV_U32", "v_subbrev_co_u32">;
23950b57cec5SDimitry Andric
23960b57cec5SDimitry Andricdefm V_ADD_U32            : VOP2_Real_e32e64_gfx9 <0x34>;
23970b57cec5SDimitry Andricdefm V_SUB_U32            : VOP2_Real_e32e64_gfx9 <0x35>;
23980b57cec5SDimitry Andricdefm V_SUBREV_U32         : VOP2_Real_e32e64_gfx9 <0x36>;
23990b57cec5SDimitry Andric
24000b57cec5SDimitry Andricdefm V_BFM_B32            : VOP2_Real_e64only_vi <0x293>;
24010b57cec5SDimitry Andricdefm V_BCNT_U32_B32       : VOP2_Real_e64only_vi <0x28b>;
24020b57cec5SDimitry Andricdefm V_MBCNT_LO_U32_B32   : VOP2_Real_e64only_vi <0x28c>;
24030b57cec5SDimitry Andricdefm V_MBCNT_HI_U32_B32   : VOP2_Real_e64only_vi <0x28d>;
24040b57cec5SDimitry Andricdefm V_LDEXP_F32          : VOP2_Real_e64only_vi <0x288>;
24050b57cec5SDimitry Andricdefm V_CVT_PKACCUM_U8_F32 : VOP2_Real_e64only_vi <0x1f0>;
24060b57cec5SDimitry Andricdefm V_CVT_PKNORM_I16_F32 : VOP2_Real_e64only_vi <0x294>;
24070b57cec5SDimitry Andricdefm V_CVT_PKNORM_U16_F32 : VOP2_Real_e64only_vi <0x295>;
24080b57cec5SDimitry Andricdefm V_CVT_PKRTZ_F16_F32  : VOP2_Real_e64only_vi <0x296>;
24090b57cec5SDimitry Andricdefm V_CVT_PK_U16_U32     : VOP2_Real_e64only_vi <0x297>;
24100b57cec5SDimitry Andricdefm V_CVT_PK_I16_I32     : VOP2_Real_e64only_vi <0x298>;
24110b57cec5SDimitry Andric
24120b57cec5SDimitry Andricdefm V_ADD_F16            : VOP2_Real_e32e64_vi <0x1f>;
24130b57cec5SDimitry Andricdefm V_SUB_F16            : VOP2_Real_e32e64_vi <0x20>;
24140b57cec5SDimitry Andricdefm V_SUBREV_F16         : VOP2_Real_e32e64_vi <0x21>;
24150b57cec5SDimitry Andricdefm V_MUL_F16            : VOP2_Real_e32e64_vi <0x22>;
24160b57cec5SDimitry Andricdefm V_MAC_F16            : VOP2_Real_e32e64_vi <0x23>;
24170b57cec5SDimitry Andricdefm V_MADMK_F16          : VOP2_Real_MADK_vi <0x24>;
24180b57cec5SDimitry Andricdefm V_MADAK_F16          : VOP2_Real_MADK_vi <0x25>;
24190b57cec5SDimitry Andricdefm V_ADD_U16            : VOP2_Real_e32e64_vi <0x26>;
24200b57cec5SDimitry Andricdefm V_SUB_U16            : VOP2_Real_e32e64_vi <0x27>;
24210b57cec5SDimitry Andricdefm V_SUBREV_U16         : VOP2_Real_e32e64_vi <0x28>;
24220b57cec5SDimitry Andricdefm V_MUL_LO_U16         : VOP2_Real_e32e64_vi <0x29>;
24230b57cec5SDimitry Andricdefm V_LSHLREV_B16        : VOP2_Real_e32e64_vi <0x2a>;
24240b57cec5SDimitry Andricdefm V_LSHRREV_B16        : VOP2_Real_e32e64_vi <0x2b>;
24250b57cec5SDimitry Andricdefm V_ASHRREV_I16        : VOP2_Real_e32e64_vi <0x2c>;
24260b57cec5SDimitry Andricdefm V_MAX_F16            : VOP2_Real_e32e64_vi <0x2d>;
24270b57cec5SDimitry Andricdefm V_MIN_F16            : VOP2_Real_e32e64_vi <0x2e>;
24280b57cec5SDimitry Andricdefm V_MAX_U16            : VOP2_Real_e32e64_vi <0x2f>;
24290b57cec5SDimitry Andricdefm V_MAX_I16            : VOP2_Real_e32e64_vi <0x30>;
24300b57cec5SDimitry Andricdefm V_MIN_U16            : VOP2_Real_e32e64_vi <0x31>;
24310b57cec5SDimitry Andricdefm V_MIN_I16            : VOP2_Real_e32e64_vi <0x32>;
24320b57cec5SDimitry Andricdefm V_LDEXP_F16          : VOP2_Real_e32e64_vi <0x33>;
24330b57cec5SDimitry Andric
24340b57cec5SDimitry Andriclet SubtargetPredicate = isGFX8GFX9 in {
24350b57cec5SDimitry Andric
24360b57cec5SDimitry Andric// Aliases to simplify matching of floating-point instructions that
24370b57cec5SDimitry Andric// are VOP2 on SI and VOP3 on VI.
24380b57cec5SDimitry Andricclass SI2_VI3Alias <string name, VOP3_Real inst> : InstAlias <
24390b57cec5SDimitry Andric  name#" $dst, $src0, $src1",
24400b57cec5SDimitry Andric  !if(inst.Pfl.HasOMod,
24410b57cec5SDimitry Andric      (inst VGPR_32:$dst, 0, VCSrc_f32:$src0, 0, VCSrc_f32:$src1, 0, 0),
24420b57cec5SDimitry Andric      (inst VGPR_32:$dst, 0, VCSrc_f32:$src0, 0, VCSrc_f32:$src1, 0))
24430b57cec5SDimitry Andric>, PredicateControl {
24440b57cec5SDimitry Andric  let UseInstAsmMatchConverter = 0;
24450b57cec5SDimitry Andric  let AsmVariantName = AMDGPUAsmVariants.VOP3;
24460b57cec5SDimitry Andric}
24470b57cec5SDimitry Andric
24480b57cec5SDimitry Andricdef : SI2_VI3Alias <"v_ldexp_f32", V_LDEXP_F32_e64_vi>;
24490b57cec5SDimitry Andricdef : SI2_VI3Alias <"v_cvt_pkaccum_u8_f32", V_CVT_PKACCUM_U8_F32_e64_vi>;
24500b57cec5SDimitry Andricdef : SI2_VI3Alias <"v_cvt_pknorm_i16_f32", V_CVT_PKNORM_I16_F32_e64_vi>;
24510b57cec5SDimitry Andricdef : SI2_VI3Alias <"v_cvt_pknorm_u16_f32", V_CVT_PKNORM_U16_F32_e64_vi>;
24520b57cec5SDimitry Andricdef : SI2_VI3Alias <"v_cvt_pkrtz_f16_f32", V_CVT_PKRTZ_F16_F32_e64_vi>;
24530b57cec5SDimitry Andric
24540b57cec5SDimitry Andricdefm : VOP2eInstAliases<V_CNDMASK_B32_e32, V_CNDMASK_B32_e32_vi>;
24550b57cec5SDimitry Andric
24560b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX8GFX9
24570b57cec5SDimitry Andric
24580b57cec5SDimitry Andriclet SubtargetPredicate = isGFX9Only in {
24590b57cec5SDimitry Andric
2460e8d8bef9SDimitry Andricdefm : VOP2bInstAliases<V_ADD_U32_e32,     V_ADD_CO_U32_e32_gfx9,     "v_add_co_u32">;
24610b57cec5SDimitry Andricdefm : VOP2bInstAliases<V_ADDC_U32_e32,    V_ADDC_CO_U32_e32_gfx9,    "v_addc_co_u32">;
2462e8d8bef9SDimitry Andricdefm : VOP2bInstAliases<V_SUB_U32_e32,     V_SUB_CO_U32_e32_gfx9,     "v_sub_co_u32">;
24630b57cec5SDimitry Andricdefm : VOP2bInstAliases<V_SUBB_U32_e32,    V_SUBB_CO_U32_e32_gfx9,    "v_subb_co_u32">;
2464e8d8bef9SDimitry Andricdefm : VOP2bInstAliases<V_SUBREV_U32_e32,  V_SUBREV_CO_U32_e32_gfx9,  "v_subrev_co_u32">;
24650b57cec5SDimitry Andricdefm : VOP2bInstAliases<V_SUBBREV_U32_e32, V_SUBBREV_CO_U32_e32_gfx9, "v_subbrev_co_u32">;
24660b57cec5SDimitry Andric
24670b57cec5SDimitry Andric} // End SubtargetPredicate = isGFX9Only
24680b57cec5SDimitry Andric
24690b57cec5SDimitry Andriclet SubtargetPredicate = HasDLInsts in {
24700b57cec5SDimitry Andric
24710b57cec5SDimitry Andricdefm V_FMAC_F32 : VOP2_Real_e32e64_vi <0x3b>;
24720b57cec5SDimitry Andricdefm V_XNOR_B32 : VOP2_Real_e32e64_vi <0x3d>;
24730b57cec5SDimitry Andric
24740b57cec5SDimitry Andric} // End SubtargetPredicate = HasDLInsts
24750b57cec5SDimitry Andric
2476fe6060f1SDimitry Andriclet AssemblerPredicate = isGFX90APlus, DecoderNamespace = "GFX90A" in {
2477fe6060f1SDimitry Andric  multiclass VOP2_Real_e32_gfx90a <bits<6> op> {
2478fe6060f1SDimitry Andric    def _e32_gfx90a :
2479fe6060f1SDimitry Andric      VOP2_Real<!cast<VOP2_Pseudo>(NAME#"_e32"), SIEncodingFamily.GFX90A>,
2480fe6060f1SDimitry Andric      VOP2e<op{5-0}, !cast<VOP2_Pseudo>(NAME#"_e32").Pfl>;
2481fe6060f1SDimitry Andric  }
2482fe6060f1SDimitry Andric
2483fe6060f1SDimitry Andric  multiclass VOP2_Real_e64_gfx90a <bits<10> op> {
2484fe6060f1SDimitry Andric    def _e64_gfx90a :
2485fe6060f1SDimitry Andric      VOP3_Real<!cast<VOP3_Pseudo>(NAME#"_e64"), SIEncodingFamily.GFX90A>,
2486fe6060f1SDimitry Andric      VOP3e_vi <op, !cast<VOP3_Pseudo>(NAME#"_e64").Pfl>;
2487fe6060f1SDimitry Andric  }
2488fe6060f1SDimitry Andric
2489fe6060f1SDimitry Andric  multiclass Base_VOP2_Real_e32e64_gfx90a <bits<6> op> :
2490fe6060f1SDimitry Andric    VOP2_Real_e32_gfx90a<op>,
2491fe6060f1SDimitry Andric    VOP2_Real_e64_gfx90a<{0, 1, 0, 0, op{5-0}}>;
2492fe6060f1SDimitry Andric
2493fe6060f1SDimitry Andric  multiclass VOP2_Real_e32e64_gfx90a <bits<6> op> :
2494fe6060f1SDimitry Andric    Base_VOP2_Real_e32e64_gfx90a<op> {
2495fe6060f1SDimitry Andric
249606c3fb27SDimitry Andric    if !cast<VOP2_Pseudo>(NAME#"_e32").Pfl.HasExtDPP then
2497fe6060f1SDimitry Andric      def _dpp_gfx90a :
2498fe6060f1SDimitry Andric        VOP_DPP_Real<!cast<VOP2_DPP_Pseudo>(NAME#"_dpp"), SIEncodingFamily.GFX90A>,
2499fe6060f1SDimitry Andric        VOP2_DPPe<op, !cast<VOP2_DPP_Pseudo>(NAME#"_dpp")> {
2500*0fca6ea1SDimitry Andric          let DecoderNamespace = "GFX9";
2501fe6060f1SDimitry Andric        }
2502fe6060f1SDimitry Andric  }
2503fe6060f1SDimitry Andric} // End AssemblerPredicate = isGFX90APlus, DecoderNamespace = "GFX90A"
2504fe6060f1SDimitry Andric
2505bdd1243dSDimitry Andriclet SubtargetPredicate = HasFmacF64Inst in {
2506fe6060f1SDimitry Andric  defm V_FMAC_F64       : VOP2_Real_e32e64_gfx90a <0x4>;
2507bdd1243dSDimitry Andric} // End SubtargetPredicate = HasFmacF64Inst
2508bdd1243dSDimitry Andric
2509bdd1243dSDimitry Andriclet SubtargetPredicate = isGFX90APlus, IsSingle = 1 in {
2510fe6060f1SDimitry Andric  defm V_MUL_LEGACY_F32 : VOP2_Real_e64_gfx90a <0x2a1>;
2511fe6060f1SDimitry Andric}
2512fe6060f1SDimitry Andric
251381ad6265SDimitry Andriclet SubtargetPredicate = HasFmaakFmamkF32Insts in {
251481ad6265SDimitry Andricdefm V_FMAMK_F32        : VOP2_Real_MADK_gfx940 <0x17>;
251581ad6265SDimitry Andricdefm V_FMAAK_F32        : VOP2_Real_MADK_gfx940 <0x18>;
251681ad6265SDimitry Andric}
251781ad6265SDimitry Andric
2518bdd1243dSDimitry Andricmulticlass VOP2_Real_DOT_ACC_gfx9<bits<6> op> : Base_VOP2_Real_e32e64_vi<op> {
25197a6dacacSDimitry Andric  let SubtargetPredicate = isGFX9Only in
25208bcb0991SDimitry Andric  def _dpp_vi : VOP2_DPP<op, !cast<VOP2_DPP_Pseudo>(NAME#"_dpp")>;
25210b57cec5SDimitry Andric}
25220b57cec5SDimitry Andric
25230b57cec5SDimitry Andricmulticlass VOP2_Real_DOT_ACC_gfx10<bits<6> op> :
25240b57cec5SDimitry Andric  VOP2_Real_e32_gfx10<op>,
25250b57cec5SDimitry Andric  VOP2_Real_dpp_gfx10<op>,
25260b57cec5SDimitry Andric  VOP2_Real_dpp8_gfx10<op>;
25270b57cec5SDimitry Andric
25287a6dacacSDimitry Andricmulticlass VOP2Only_Real_DOT_ACC_gfx10<bits<6> op> : VOP2_Real_dpp_gfx10<op>,
25297a6dacacSDimitry Andric                                                     VOP2_Real_dpp8_gfx10<op> {
25307a6dacacSDimitry Andric  let IsSingle = 1 in
25317a6dacacSDimitry Andric    defm NAME : VOP2_Real_e32_gfx10<op>;
25327a6dacacSDimitry Andric}
25337a6dacacSDimitry Andric
25347a6dacacSDimitry Andriclet OtherPredicates = [HasDot5Insts] in {
25350b57cec5SDimitry Andric  defm V_DOT2C_F32_F16 : VOP2_Real_DOT_ACC_gfx9<0x37>;
25360b57cec5SDimitry Andric  // NB: Opcode conflicts with V_DOT8C_I32_I4
25370b57cec5SDimitry Andric  // This opcode exists in gfx 10.1* only
25387a6dacacSDimitry Andric  defm V_DOT2C_F32_F16 : VOP2Only_Real_DOT_ACC_gfx10<0x02>;
25390b57cec5SDimitry Andric}
25400b57cec5SDimitry Andric
25417a6dacacSDimitry Andriclet OtherPredicates = [HasDot6Insts] in {
25420b57cec5SDimitry Andric  defm V_DOT4C_I32_I8  : VOP2_Real_DOT_ACC_gfx9<0x39>;
25437a6dacacSDimitry Andric  defm V_DOT4C_I32_I8  : VOP2Only_Real_DOT_ACC_gfx10<0x0d>;
25440b57cec5SDimitry Andric}
25450b57cec5SDimitry Andric
25467a6dacacSDimitry Andriclet OtherPredicates = [HasDot4Insts] in {
25470b57cec5SDimitry Andric  defm V_DOT2C_I32_I16 : VOP2_Real_DOT_ACC_gfx9<0x38>;
25480b57cec5SDimitry Andric}
25497a6dacacSDimitry Andriclet OtherPredicates = [HasDot3Insts] in {
25500b57cec5SDimitry Andric  defm V_DOT8C_I32_I4  : VOP2_Real_DOT_ACC_gfx9<0x3a>;
25510b57cec5SDimitry Andric}
25520b57cec5SDimitry Andric
25530b57cec5SDimitry Andriclet SubtargetPredicate = HasPkFmacF16Inst in {
25540b57cec5SDimitry Andricdefm V_PK_FMAC_F16 : VOP2_Real_e32_vi<0x3c>;
25550b57cec5SDimitry Andric} // End SubtargetPredicate = HasPkFmacF16Inst
25565ffd83dbSDimitry Andric
25575ffd83dbSDimitry Andriclet SubtargetPredicate = HasDot3Insts in {
25585ffd83dbSDimitry Andric  // NB: Opcode conflicts with V_DOT2C_F32_F16
25595ffd83dbSDimitry Andric  let DecoderNamespace = "GFX10_B" in
25605ffd83dbSDimitry Andric  defm V_DOT8C_I32_I4 : VOP2_Real_DOT_ACC_gfx10<0x02>;
25615ffd83dbSDimitry Andric}
2562