xref: /freebsd/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVInstrInfoV.td (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
15ffd83dbSDimitry Andric//===-- RISCVInstrInfoV.td - RISC-V 'V' instructions -------*- tablegen -*-===//
25ffd83dbSDimitry Andric//
35ffd83dbSDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45ffd83dbSDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
55ffd83dbSDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65ffd83dbSDimitry Andric//
75ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
85ffd83dbSDimitry Andric///
95ffd83dbSDimitry Andric/// This file describes the RISC-V instructions from the standard 'V' Vector
1081ad6265SDimitry Andric/// extension, version 1.0.
115ffd83dbSDimitry Andric///
125ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
135ffd83dbSDimitry Andric
145ffd83dbSDimitry Andricinclude "RISCVInstrFormatsV.td"
155ffd83dbSDimitry Andric
165ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
175ffd83dbSDimitry Andric// Operand and SDNode transformation definitions.
185ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
195ffd83dbSDimitry Andric
2004eeddc0SDimitry Andricclass VTypeIAsmOperand<int VTypeINum> : AsmOperandClass {
2104eeddc0SDimitry Andric  let Name = "VTypeI" # VTypeINum;
225ffd83dbSDimitry Andric  let ParserMethod = "parseVTypeI";
235ffd83dbSDimitry Andric  let DiagnosticType = "InvalidVTypeI";
2404eeddc0SDimitry Andric  let RenderMethod = "addVTypeIOperands";
255ffd83dbSDimitry Andric}
265ffd83dbSDimitry Andric
275f757f3fSDimitry Andricclass VTypeIOp<int VTypeINum> : RISCVOp {
2804eeddc0SDimitry Andric  let ParserMatchClass = VTypeIAsmOperand<VTypeINum>;
295ffd83dbSDimitry Andric  let PrintMethod = "printVTypeI";
3004eeddc0SDimitry Andric  let DecoderMethod = "decodeUImmOperand<"#VTypeINum#">";
31bdd1243dSDimitry Andric  let OperandType = "OPERAND_VTYPEI" # VTypeINum;
32bdd1243dSDimitry Andric  let MCOperandPredicate = [{
33bdd1243dSDimitry Andric    int64_t Imm;
34bdd1243dSDimitry Andric    if (MCOp.evaluateAsConstantImm(Imm))
35bdd1243dSDimitry Andric      return isUInt<VTypeINum>(Imm);
36bdd1243dSDimitry Andric    return MCOp.isBareSymbolRef();
37bdd1243dSDimitry Andric  }];
385ffd83dbSDimitry Andric}
395ffd83dbSDimitry Andric
4004eeddc0SDimitry Andricdef VTypeIOp10 : VTypeIOp<10>;
4104eeddc0SDimitry Andricdef VTypeIOp11 : VTypeIOp<11>;
4204eeddc0SDimitry Andric
435ffd83dbSDimitry Andricdef VMaskAsmOperand : AsmOperandClass {
445ffd83dbSDimitry Andric  let Name = "RVVMaskRegOpOperand";
455ffd83dbSDimitry Andric  let RenderMethod = "addRegOperands";
465ffd83dbSDimitry Andric  let PredicateMethod = "isV0Reg";
475ffd83dbSDimitry Andric  let ParserMethod = "parseMaskReg";
485ffd83dbSDimitry Andric  let IsOptional = 1;
495ffd83dbSDimitry Andric  let DefaultMethod = "defaultMaskRegOp";
505ffd83dbSDimitry Andric  let DiagnosticType = "InvalidVMaskRegister";
515ffd83dbSDimitry Andric}
525ffd83dbSDimitry Andric
535ffd83dbSDimitry Andricdef VMaskOp : RegisterOperand<VMV0> {
545ffd83dbSDimitry Andric  let ParserMatchClass = VMaskAsmOperand;
555ffd83dbSDimitry Andric  let PrintMethod = "printVMaskReg";
565ffd83dbSDimitry Andric  let EncoderMethod = "getVMaskReg";
575ffd83dbSDimitry Andric  let DecoderMethod = "decodeVMaskReg";
585ffd83dbSDimitry Andric}
595ffd83dbSDimitry Andric
605f757f3fSDimitry Andricdef simm5 : RISCVSImmLeafOp<5> {
615ffd83dbSDimitry Andric  let MCOperandPredicate = [{
625ffd83dbSDimitry Andric    int64_t Imm;
635ffd83dbSDimitry Andric    if (MCOp.evaluateAsConstantImm(Imm))
645ffd83dbSDimitry Andric      return isInt<5>(Imm);
655ffd83dbSDimitry Andric    return MCOp.isBareSymbolRef();
665ffd83dbSDimitry Andric  }];
675ffd83dbSDimitry Andric}
685ffd83dbSDimitry Andric
695ffd83dbSDimitry Andricdef SImm5Plus1AsmOperand : AsmOperandClass {
705ffd83dbSDimitry Andric  let Name = "SImm5Plus1";
71e8d8bef9SDimitry Andric  let RenderMethod = "addImmOperands";
725ffd83dbSDimitry Andric  let DiagnosticType = "InvalidSImm5Plus1";
735ffd83dbSDimitry Andric}
745ffd83dbSDimitry Andric
755f757f3fSDimitry Andricdef simm5_plus1 : RISCVOp, ImmLeaf<XLenVT,
76fe6060f1SDimitry Andric  [{return (isInt<5>(Imm) && Imm != -16) || Imm == 16;}]> {
775ffd83dbSDimitry Andric  let ParserMatchClass = SImm5Plus1AsmOperand;
78bdd1243dSDimitry Andric  let OperandType = "OPERAND_SIMM5_PLUS1";
795ffd83dbSDimitry Andric  let MCOperandPredicate = [{
805ffd83dbSDimitry Andric    int64_t Imm;
815ffd83dbSDimitry Andric    if (MCOp.evaluateAsConstantImm(Imm))
82fe6060f1SDimitry Andric      return (isInt<5>(Imm) && Imm != -16) || Imm == 16;
835ffd83dbSDimitry Andric    return MCOp.isBareSymbolRef();
845ffd83dbSDimitry Andric  }];
855ffd83dbSDimitry Andric}
865ffd83dbSDimitry Andric
8704eeddc0SDimitry Andricdef simm5_plus1_nonzero : ImmLeaf<XLenVT,
8804eeddc0SDimitry Andric  [{return Imm != 0 && ((isInt<5>(Imm) && Imm != -16) || Imm == 16);}]>;
8904eeddc0SDimitry Andric
905ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
916e75b2fbSDimitry Andric// Scheduling definitions.
926e75b2fbSDimitry Andric//===----------------------------------------------------------------------===//
936e75b2fbSDimitry Andric
945f757f3fSDimitry Andric// Common class of scheduling definitions.
955f757f3fSDimitry Andric// `ReadVMergeOp` will be prepended to reads if instruction is masked.
965f757f3fSDimitry Andric// `ReadVMask` will be appended to reads if instruction is masked.
975f757f3fSDimitry Andric// Operands:
985f757f3fSDimitry Andric//   `writes`       SchedWrites that are listed for each explicit def operand
995f757f3fSDimitry Andric//                  in order.
1005f757f3fSDimitry Andric//   `reads`        SchedReads that are listed for each explicit use operand.
1015f757f3fSDimitry Andric//   `forceMasked`  Forced to be masked (e.g. Add-with-Carry Instructions).
1025f757f3fSDimitry Andric//   `forceMergeOpRead` Force to have read for merge operand.
1035f757f3fSDimitry Andricclass SchedCommon<list<SchedWrite> writes, list<SchedRead> reads,
1045f757f3fSDimitry Andric                  string mx = "WorstCase", int sew = 0, bit forceMasked = 0,
1055f757f3fSDimitry Andric                  bit forceMergeOpRead = 0> : Sched<[]> {
1065f757f3fSDimitry Andric  defvar isMasked = !ne(!find(NAME, "_MASK"), -1);
1075f757f3fSDimitry Andric  defvar isMaskedOrForceMasked = !or(forceMasked, isMasked);
1085f757f3fSDimitry Andric  defvar mergeRead = !if(!or(!eq(mx, "WorstCase"), !eq(sew, 0)),
1095f757f3fSDimitry Andric                            !cast<SchedRead>("ReadVMergeOp_" # mx),
1105f757f3fSDimitry Andric                            !cast<SchedRead>("ReadVMergeOp_" # mx # "_E" #sew));
1115f757f3fSDimitry Andric  defvar needsMergeRead = !or(isMaskedOrForceMasked, forceMergeOpRead);
1125f757f3fSDimitry Andric  defvar readsWithMask =
1135f757f3fSDimitry Andric      !if(isMaskedOrForceMasked, !listconcat(reads, [ReadVMask]), reads);
1145f757f3fSDimitry Andric  defvar allReads =
1155f757f3fSDimitry Andric      !if(needsMergeRead, !listconcat([mergeRead], readsWithMask), reads);
1165f757f3fSDimitry Andric  let SchedRW = !listconcat(writes, allReads);
1175f757f3fSDimitry Andric}
1186e75b2fbSDimitry Andric
1195f757f3fSDimitry Andric// Common class of scheduling definitions for n-ary instructions.
1205f757f3fSDimitry Andric// The scheudling resources are relevant to LMUL and may be relevant to SEW.
1215f757f3fSDimitry Andricclass SchedNary<string write, list<string> reads, string mx, int sew = 0,
1225f757f3fSDimitry Andric                bit forceMasked = 0, bit forceMergeOpRead = 0>
1235f757f3fSDimitry Andric    : SchedCommon<[!cast<SchedWrite>(
1245f757f3fSDimitry Andric                      !if(sew,
1255f757f3fSDimitry Andric                          write # "_" # mx # "_E" # sew,
1265f757f3fSDimitry Andric                          write # "_" # mx))],
1275f757f3fSDimitry Andric                  !foreach(read, reads,
1285f757f3fSDimitry Andric                           !cast<SchedRead>(!if(sew, read #"_" #mx #"_E" #sew,
1295f757f3fSDimitry Andric                                                 read #"_" #mx))),
1305f757f3fSDimitry Andric                  mx, sew, forceMasked, forceMergeOpRead>;
1316e75b2fbSDimitry Andric
1325f757f3fSDimitry Andric// Classes with postfix "MC" are only used in MC layer.
1335f757f3fSDimitry Andric// For these classes, we assume that they are with the worst case costs and
1345f757f3fSDimitry Andric// `ReadVMask` is always needed (with some exceptions).
1356e75b2fbSDimitry Andric
1365f757f3fSDimitry Andric// For instructions with no operand.
1375f757f3fSDimitry Andricclass SchedNullary<string write, string mx, int sew = 0, bit forceMasked = 0,
1385f757f3fSDimitry Andric                   bit forceMergeOpRead = 0>:
1395f757f3fSDimitry Andric  SchedNary<write, [], mx, sew, forceMasked, forceMergeOpRead>;
1405f757f3fSDimitry Andricclass SchedNullaryMC<string write, bit forceMasked = 1>:
1415f757f3fSDimitry Andric  SchedNullary<write, "WorstCase", forceMasked=forceMasked>;
1426e75b2fbSDimitry Andric
1435f757f3fSDimitry Andric// For instructions with one operand.
1445f757f3fSDimitry Andricclass SchedUnary<string write, string read0, string mx, int sew = 0,
1455f757f3fSDimitry Andric                 bit forceMasked = 0, bit forceMergeOpRead = 0>:
1465f757f3fSDimitry Andric  SchedNary<write, [read0], mx, sew, forceMasked, forceMergeOpRead>;
1475f757f3fSDimitry Andricclass SchedUnaryMC<string write, string read0, bit forceMasked = 1>:
1485f757f3fSDimitry Andric  SchedUnary<write, read0, "WorstCase", forceMasked=forceMasked>;
1496e75b2fbSDimitry Andric
1505f757f3fSDimitry Andric// For instructions with two operands.
1515f757f3fSDimitry Andricclass SchedBinary<string write, string read0, string read1, string mx,
1525f757f3fSDimitry Andric                  int sew = 0, bit forceMasked = 0, bit forceMergeOpRead = 0>
1535f757f3fSDimitry Andric    : SchedNary<write, [read0, read1], mx, sew, forceMasked, forceMergeOpRead>;
1545f757f3fSDimitry Andricclass SchedBinaryMC<string write, string read0, string read1,
1555f757f3fSDimitry Andric                    bit forceMasked = 1>:
1565f757f3fSDimitry Andric  SchedBinary<write, read0, read1, "WorstCase", forceMasked=forceMasked>;
1576e75b2fbSDimitry Andric
1585f757f3fSDimitry Andric// For instructions with three operands.
1595f757f3fSDimitry Andricclass SchedTernary<string write, string read0, string read1, string read2,
160*0fca6ea1SDimitry Andric                   string mx, int sew = 0, bit forceMasked = 0>
161*0fca6ea1SDimitry Andric    : SchedNary<write, [read0, read1, read2], mx, sew, forceMasked>;
1625f757f3fSDimitry Andricclass SchedTernaryMC<string write, string read0, string read1, string read2,
1635f757f3fSDimitry Andric                     int sew = 0, bit forceMasked = 1>:
1645f757f3fSDimitry Andric  SchedNary<write, [read0, read1, read2], "WorstCase", sew, forceMasked>;
1656e75b2fbSDimitry Andric
1665f757f3fSDimitry Andric// For reduction instructions.
1675f757f3fSDimitry Andricclass SchedReduction<string write, string read, string mx, int sew,
1685f757f3fSDimitry Andric                     bit forceMergeOpRead = 0>
1695f757f3fSDimitry Andric    : SchedCommon<[!cast<SchedWrite>(write #"_" #mx #"_E" #sew)],
1705f757f3fSDimitry Andric                  !listsplat(!cast<SchedRead>(read), 3), mx, sew, forceMergeOpRead>;
1715f757f3fSDimitry Andricclass SchedReductionMC<string write, string readV, string readV0>:
1725f757f3fSDimitry Andric  SchedCommon<[!cast<SchedWrite>(write # "_WorstCase")],
1735f757f3fSDimitry Andric              [!cast<SchedRead>(readV), !cast<SchedRead>(readV0)],
1745f757f3fSDimitry Andric              forceMasked=1>;
1755f757f3fSDimitry Andric
1765f757f3fSDimitry Andric// Whole Vector Register Move
1775f757f3fSDimitry Andricclass VMVRSched<int n> : SchedCommon<
1785f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVMov" # n # "V")],
1795f757f3fSDimitry Andric  [!cast<SchedRead>("ReadVMov" # n # "V")]
1805f757f3fSDimitry Andric>;
1815f757f3fSDimitry Andric
1825f757f3fSDimitry Andric// Vector Unit-Stride Loads and Stores
1835f757f3fSDimitry Andricclass VLESched<string lmul, bit forceMasked = 0> : SchedCommon<
1845f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVLDE_" # lmul)],
1855f757f3fSDimitry Andric  [ReadVLDX], mx=lmul, forceMasked=forceMasked
1865f757f3fSDimitry Andric>;
1875f757f3fSDimitry Andricclass VLESchedMC : VLESched<"WorstCase", forceMasked=1>;
1885f757f3fSDimitry Andric
1895f757f3fSDimitry Andricclass VSESched<string lmul, bit forceMasked = 0> : SchedCommon<
1905f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVSTE_" # lmul)],
1915f757f3fSDimitry Andric  [!cast<SchedRead>("ReadVSTEV_" # lmul), ReadVSTX], mx=lmul,
1925f757f3fSDimitry Andric  forceMasked=forceMasked
1935f757f3fSDimitry Andric>;
1945f757f3fSDimitry Andricclass VSESchedMC : VSESched<"WorstCase", forceMasked=1>;
1955f757f3fSDimitry Andric
1965f757f3fSDimitry Andric// Vector Strided Loads and Stores
1975f757f3fSDimitry Andricclass VLSSched<int eew, string emul, bit forceMasked = 0> : SchedCommon<
1985f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVLDS" # eew # "_" # emul)],
1995f757f3fSDimitry Andric  [ReadVLDX, ReadVLDSX], emul, eew, forceMasked
2005f757f3fSDimitry Andric>;
2015f757f3fSDimitry Andricclass VLSSchedMC<int eew> : VLSSched<eew, "WorstCase", forceMasked=1>;
2025f757f3fSDimitry Andric
2035f757f3fSDimitry Andricclass VSSSched<int eew, string emul, bit forceMasked = 0> : SchedCommon<
2045f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVSTS" # eew # "_" # emul)],
2055f757f3fSDimitry Andric  [!cast<SchedRead>("ReadVSTS" # eew # "V_" # emul), ReadVSTX, ReadVSTSX],
2065f757f3fSDimitry Andric  emul, eew, forceMasked
2075f757f3fSDimitry Andric>;
2085f757f3fSDimitry Andricclass VSSSchedMC<int eew> : VSSSched<eew, "WorstCase", forceMasked=1>;
2095f757f3fSDimitry Andric
2105f757f3fSDimitry Andric// Vector Indexed Loads and Stores
2115f757f3fSDimitry Andricclass VLXSched<int dataEEW, bit isOrdered, string dataEMUL, string idxEMUL,
2125f757f3fSDimitry Andric               bit forceMasked = 0> : SchedCommon<
2135f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVLD" # !if(isOrdered, "O", "U") # "X" # dataEEW # "_" # dataEMUL)],
2145f757f3fSDimitry Andric  [ReadVLDX, !cast<SchedRead>("ReadVLD" # !if(isOrdered, "O", "U") # "XV_" # idxEMUL)],
2155f757f3fSDimitry Andric  dataEMUL, dataEEW, forceMasked
2165f757f3fSDimitry Andric>;
2175f757f3fSDimitry Andricclass VLXSchedMC<int dataEEW, bit isOrdered>:
2185f757f3fSDimitry Andric  VLXSched<dataEEW, isOrdered, "WorstCase", "WorstCase", forceMasked=1>;
2195f757f3fSDimitry Andric
2205f757f3fSDimitry Andricclass VSXSched<int dataEEW, bit isOrdered, string dataEMUL, string idxEMUL,
2215f757f3fSDimitry Andric               bit forceMasked = 0> : SchedCommon<
2225f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVST" # !if(isOrdered, "O", "U") # "X" # dataEEW # "_" # dataEMUL)],
2235f757f3fSDimitry Andric  [!cast<SchedRead>("ReadVST" # !if(isOrdered, "O", "U") #"X" # dataEEW # "_" # dataEMUL),
2245f757f3fSDimitry Andric   ReadVSTX, !cast<SchedRead>("ReadVST" # !if(isOrdered, "O", "U") # "XV_" # idxEMUL)],
2255f757f3fSDimitry Andric  dataEMUL, dataEEW, forceMasked
2265f757f3fSDimitry Andric>;
2275f757f3fSDimitry Andricclass VSXSchedMC<int dataEEW, bit isOrdered>:
2285f757f3fSDimitry Andric  VSXSched<dataEEW, isOrdered, "WorstCase", "WorstCase", forceMasked=1>;
2295f757f3fSDimitry Andric
2305f757f3fSDimitry Andric// Unit-stride Fault-Only-First Loads
2315f757f3fSDimitry Andricclass VLFSched<string lmul, bit forceMasked = 0> : SchedCommon<
2325f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVLDFF_" # lmul)],
2335f757f3fSDimitry Andric  [ReadVLDX], mx=lmul, forceMasked=forceMasked
2345f757f3fSDimitry Andric>;
2355f757f3fSDimitry Andricclass VLFSchedMC: VLFSched<"WorstCase", forceMasked=1>;
2366e75b2fbSDimitry Andric
237753f127fSDimitry Andric// Unit-Stride Segment Loads and Stores
2385f757f3fSDimitry Andricclass VLSEGSched<int nf, int eew, string emul, bit forceMasked = 0> : SchedCommon<
2395f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVLSEG" #nf #"e" #eew #"_" #emul)],
2405f757f3fSDimitry Andric  [ReadVLDX], emul, eew, forceMasked
2415f757f3fSDimitry Andric>;
2425f757f3fSDimitry Andricclass VLSEGSchedMC<int nf, int eew> : VLSEGSched<nf, eew, "WorstCase",
2435f757f3fSDimitry Andric                                                 forceMasked=1>;
2445f757f3fSDimitry Andric
2455f757f3fSDimitry Andricclass VSSEGSched<int nf, int eew, string emul, bit forceMasked = 0> : SchedCommon<
2465f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVSSEG" # nf # "e" # eew # "_" # emul)],
2475f757f3fSDimitry Andric  [!cast<SchedRead>("ReadVSTEV_" #emul), ReadVSTX], emul, eew, forceMasked
2485f757f3fSDimitry Andric>;
2495f757f3fSDimitry Andricclass VSSEGSchedMC<int nf, int eew> : VSSEGSched<nf, eew, "WorstCase",
2505f757f3fSDimitry Andric                                                 forceMasked=1>;
2515f757f3fSDimitry Andric
2525f757f3fSDimitry Andricclass VLSEGFFSched<int nf, int eew, string emul, bit forceMasked = 0> : SchedCommon<
2535f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVLSEGFF" # nf # "e" # eew # "_" # emul)],
2545f757f3fSDimitry Andric  [ReadVLDX], emul, eew, forceMasked
2555f757f3fSDimitry Andric>;
2565f757f3fSDimitry Andricclass VLSEGFFSchedMC<int nf, int eew> : VLSEGFFSched<nf, eew, "WorstCase",
2575f757f3fSDimitry Andric                                                     forceMasked=1>;
2585f757f3fSDimitry Andric
259753f127fSDimitry Andric// Strided Segment Loads and Stores
2605f757f3fSDimitry Andricclass VLSSEGSched<int nf, int eew, string emul, bit forceMasked = 0> : SchedCommon<
2615f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVLSSEG" #nf #"e" #eew #"_" #emul)],
2625f757f3fSDimitry Andric  [ReadVLDX, ReadVLDSX], emul, eew, forceMasked
2635f757f3fSDimitry Andric>;
2645f757f3fSDimitry Andricclass VLSSEGSchedMC<int nf, int eew> : VLSSEGSched<nf, eew, "WorstCase",
2655f757f3fSDimitry Andric                                                   forceMasked=1>;
2665f757f3fSDimitry Andric
2675f757f3fSDimitry Andricclass VSSSEGSched<int nf, int eew, string emul, bit forceMasked = 0> : SchedCommon<
2685f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVSSSEG" #nf #"e" #eew #"_" #emul)],
2695f757f3fSDimitry Andric  [!cast<SchedRead>("ReadVSTS" #eew #"V_" #emul),
2705f757f3fSDimitry Andric   ReadVSTX, ReadVSTSX], emul, eew, forceMasked
2715f757f3fSDimitry Andric>;
2725f757f3fSDimitry Andricclass VSSSEGSchedMC<int nf, int eew> : VSSSEGSched<nf, eew, "WorstCase",
2735f757f3fSDimitry Andric                                                   forceMasked=1>;
2745f757f3fSDimitry Andric
275753f127fSDimitry Andric// Indexed Segment Loads and Stores
2765f757f3fSDimitry Andricclass VLXSEGSched<int nf, int eew, bit isOrdered, string emul,
2775f757f3fSDimitry Andric                  bit forceMasked = 0> : SchedCommon<
2785f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVL" #!if(isOrdered, "O", "U") #"XSEG" #nf #"e" #eew #"_" #emul)],
2795f757f3fSDimitry Andric  [ReadVLDX, !cast<SchedRead>("ReadVLD" #!if(isOrdered, "O", "U") #"XV_" #emul)],
2805f757f3fSDimitry Andric  emul, eew, forceMasked
2815f757f3fSDimitry Andric>;
2825f757f3fSDimitry Andricclass VLXSEGSchedMC<int nf, int eew, bit isOrdered>:
2835f757f3fSDimitry Andric  VLXSEGSched<nf, eew, isOrdered, "WorstCase", forceMasked=1>;
2845f757f3fSDimitry Andric
2855f757f3fSDimitry Andric// Passes sew=0 instead of eew=0 since this pseudo does not follow MX_E form.
2865f757f3fSDimitry Andricclass VSXSEGSched<int nf, int eew, bit isOrdered, string emul,
2875f757f3fSDimitry Andric                  bit forceMasked = 0> : SchedCommon<
2885f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVS" #!if(isOrdered, "O", "U") #"XSEG" #nf #"e" #eew #"_" #emul)],
2895f757f3fSDimitry Andric  [!cast<SchedRead>("ReadVST" #!if(isOrdered, "O", "U") #"X" #eew #"_" #emul),
2905f757f3fSDimitry Andric   ReadVSTX, !cast<SchedRead>("ReadVST" #!if(isOrdered, "O", "U") #"XV_" #emul)],
2915f757f3fSDimitry Andric  emul, sew=0, forceMasked=forceMasked
2925f757f3fSDimitry Andric>;
2935f757f3fSDimitry Andricclass VSXSEGSchedMC<int nf, int eew, bit isOrdered>:
2945f757f3fSDimitry Andric  VSXSEGSched<nf, eew, isOrdered, "WorstCase", forceMasked=1>;
295753f127fSDimitry Andric
2966e75b2fbSDimitry Andric//===----------------------------------------------------------------------===//
2975ffd83dbSDimitry Andric// Instruction class templates
2985ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
2995ffd83dbSDimitry Andric
3005ffd83dbSDimitry Andriclet hasSideEffects = 0, mayLoad = 1, mayStore = 0 in {
301349cc55cSDimitry Andric// unit-stride load vd, (rs1), vm
302349cc55cSDimitry Andricclass VUnitStrideLoad<RISCVWidth width, string opcodestr>
303349cc55cSDimitry Andric    : RVInstVLU<0b000, width.Value{3}, LUMOPUnitStride, width.Value{2-0},
304e8d8bef9SDimitry Andric                (outs VR:$vd),
30506c3fb27SDimitry Andric                (ins GPRMemZeroOffset:$rs1, VMaskOp:$vm), opcodestr, "$vd, ${rs1}$vm">;
3065ffd83dbSDimitry Andric
307349cc55cSDimitry Andriclet vm = 1, RVVConstraint = NoConstraint in {
308349cc55cSDimitry Andric// unit-stride whole register load vl<nf>r.v vd, (rs1)
309349cc55cSDimitry Andricclass VWholeLoad<bits<3> nf, RISCVWidth width, string opcodestr, RegisterClass VRC>
310349cc55cSDimitry Andric    : RVInstVLU<nf, width.Value{3}, LUMOPUnitStrideWholeReg,
31106c3fb27SDimitry Andric                width.Value{2-0}, (outs VRC:$vd), (ins GPRMemZeroOffset:$rs1),
31206c3fb27SDimitry Andric                opcodestr, "$vd, $rs1"> {
313349cc55cSDimitry Andric  let Uses = [];
314349cc55cSDimitry Andric}
315349cc55cSDimitry Andric
316349cc55cSDimitry Andric// unit-stride mask load vd, (rs1)
317349cc55cSDimitry Andricclass VUnitStrideLoadMask<string opcodestr>
318349cc55cSDimitry Andric    : RVInstVLU<0b000, LSWidth8.Value{3}, LUMOPUnitStrideMask, LSWidth8.Value{2-0},
319349cc55cSDimitry Andric                (outs VR:$vd),
32006c3fb27SDimitry Andric                (ins GPRMemZeroOffset:$rs1), opcodestr, "$vd, $rs1">;
321349cc55cSDimitry Andric} // vm = 1, RVVConstraint = NoConstraint
322349cc55cSDimitry Andric
323349cc55cSDimitry Andric// unit-stride fault-only-first load vd, (rs1), vm
324349cc55cSDimitry Andricclass VUnitStrideLoadFF<RISCVWidth width, string opcodestr>
325349cc55cSDimitry Andric    : RVInstVLU<0b000, width.Value{3}, LUMOPUnitStrideFF, width.Value{2-0},
326349cc55cSDimitry Andric                (outs VR:$vd),
32706c3fb27SDimitry Andric                (ins GPRMemZeroOffset:$rs1, VMaskOp:$vm), opcodestr, "$vd, ${rs1}$vm">;
328349cc55cSDimitry Andric
329349cc55cSDimitry Andric// strided load vd, (rs1), rs2, vm
330e8d8bef9SDimitry Andricclass VStridedLoad<RISCVWidth width, string opcodestr>
331e8d8bef9SDimitry Andric    : RVInstVLS<0b000, width.Value{3}, width.Value{2-0},
332e8d8bef9SDimitry Andric                (outs VR:$vd),
33306c3fb27SDimitry Andric                (ins GPRMemZeroOffset:$rs1, GPR:$rs2, VMaskOp:$vm), opcodestr,
33406c3fb27SDimitry Andric                "$vd, $rs1, $rs2$vm">;
3355ffd83dbSDimitry Andric
336349cc55cSDimitry Andric// indexed load vd, (rs1), vs2, vm
3375ffd83dbSDimitry Andricclass VIndexedLoad<RISCVMOP mop, RISCVWidth width, string opcodestr>
338e8d8bef9SDimitry Andric    : RVInstVLX<0b000, width.Value{3}, mop, width.Value{2-0},
339e8d8bef9SDimitry Andric                (outs VR:$vd),
34006c3fb27SDimitry Andric                (ins GPRMemZeroOffset:$rs1, VR:$vs2, VMaskOp:$vm), opcodestr,
34106c3fb27SDimitry Andric                "$vd, $rs1, $vs2$vm">;
3425ffd83dbSDimitry Andric
343349cc55cSDimitry Andric// unit-stride segment load vd, (rs1), vm
344349cc55cSDimitry Andricclass VUnitStrideSegmentLoad<bits<3> nf, RISCVWidth width, string opcodestr>
345349cc55cSDimitry Andric    : RVInstVLU<nf, width.Value{3}, LUMOPUnitStride, width.Value{2-0},
346e8d8bef9SDimitry Andric                (outs VR:$vd),
34706c3fb27SDimitry Andric                (ins GPRMemZeroOffset:$rs1, VMaskOp:$vm), opcodestr, "$vd, ${rs1}$vm">;
348e8d8bef9SDimitry Andric
349349cc55cSDimitry Andric// segment fault-only-first load vd, (rs1), vm
350349cc55cSDimitry Andricclass VUnitStrideSegmentLoadFF<bits<3> nf, RISCVWidth width, string opcodestr>
351349cc55cSDimitry Andric    : RVInstVLU<nf, width.Value{3}, LUMOPUnitStrideFF, width.Value{2-0},
352349cc55cSDimitry Andric                (outs VR:$vd),
35306c3fb27SDimitry Andric                (ins GPRMemZeroOffset:$rs1, VMaskOp:$vm), opcodestr, "$vd, ${rs1}$vm">;
354349cc55cSDimitry Andric
355349cc55cSDimitry Andric// strided segment load vd, (rs1), rs2, vm
356e8d8bef9SDimitry Andricclass VStridedSegmentLoad<bits<3> nf, RISCVWidth width, string opcodestr>
357e8d8bef9SDimitry Andric    : RVInstVLS<nf, width.Value{3}, width.Value{2-0},
358e8d8bef9SDimitry Andric                (outs VR:$vd),
35906c3fb27SDimitry Andric                (ins GPRMemZeroOffset:$rs1, GPR:$rs2, VMaskOp:$vm), opcodestr,
36006c3fb27SDimitry Andric                "$vd, $rs1, $rs2$vm">;
361e8d8bef9SDimitry Andric
362349cc55cSDimitry Andric// indexed segment load vd, (rs1), vs2, vm
363e8d8bef9SDimitry Andricclass VIndexedSegmentLoad<bits<3> nf, RISCVMOP mop, RISCVWidth width,
364e8d8bef9SDimitry Andric                          string opcodestr>
365e8d8bef9SDimitry Andric    : RVInstVLX<nf, width.Value{3}, mop, width.Value{2-0},
366e8d8bef9SDimitry Andric                (outs VR:$vd),
36706c3fb27SDimitry Andric                (ins GPRMemZeroOffset:$rs1, VR:$vs2, VMaskOp:$vm), opcodestr,
36806c3fb27SDimitry Andric                "$vd, $rs1, $vs2$vm">;
3695ffd83dbSDimitry Andric} // hasSideEffects = 0, mayLoad = 1, mayStore = 0
3705ffd83dbSDimitry Andric
3715ffd83dbSDimitry Andriclet hasSideEffects = 0, mayLoad = 0, mayStore = 1 in {
372349cc55cSDimitry Andric// unit-stride store vd, vs3, (rs1), vm
373349cc55cSDimitry Andricclass VUnitStrideStore<RISCVWidth width, string opcodestr>
374349cc55cSDimitry Andric    : RVInstVSU<0b000, width.Value{3}, SUMOPUnitStride, width.Value{2-0},
37506c3fb27SDimitry Andric                (outs), (ins VR:$vs3, GPRMemZeroOffset:$rs1, VMaskOp:$vm), opcodestr,
37606c3fb27SDimitry Andric                "$vs3, ${rs1}$vm">;
3775ffd83dbSDimitry Andric
378349cc55cSDimitry Andriclet vm = 1 in {
3795ffd83dbSDimitry Andric// vs<nf>r.v vd, (rs1)
380fe6060f1SDimitry Andricclass VWholeStore<bits<3> nf, string opcodestr, RegisterClass VRC>
381e8d8bef9SDimitry Andric    : RVInstVSU<nf, 0, SUMOPUnitStrideWholeReg,
38206c3fb27SDimitry Andric                0b000, (outs), (ins VRC:$vs3, GPRMemZeroOffset:$rs1),
38306c3fb27SDimitry Andric                opcodestr, "$vs3, $rs1"> {
3845ffd83dbSDimitry Andric  let Uses = [];
3855ffd83dbSDimitry Andric}
386e8d8bef9SDimitry Andric
387349cc55cSDimitry Andric// unit-stride mask store vd, vs3, (rs1)
388349cc55cSDimitry Andricclass VUnitStrideStoreMask<string opcodestr>
389349cc55cSDimitry Andric    : RVInstVSU<0b000, LSWidth8.Value{3}, SUMOPUnitStrideMask, LSWidth8.Value{2-0},
39006c3fb27SDimitry Andric                (outs), (ins VR:$vs3, GPRMemZeroOffset:$rs1), opcodestr,
39106c3fb27SDimitry Andric                "$vs3, $rs1">;
392349cc55cSDimitry Andric} // vm = 1
393349cc55cSDimitry Andric
394349cc55cSDimitry Andric// strided store vd, vs3, (rs1), rs2, vm
395349cc55cSDimitry Andricclass VStridedStore<RISCVWidth width, string opcodestr>
396349cc55cSDimitry Andric    : RVInstVSS<0b000, width.Value{3}, width.Value{2-0}, (outs),
39706c3fb27SDimitry Andric                (ins VR:$vs3, GPRMemZeroOffset:$rs1, GPR:$rs2, VMaskOp:$vm),
39806c3fb27SDimitry Andric                opcodestr, "$vs3, $rs1, $rs2$vm">;
399349cc55cSDimitry Andric
400349cc55cSDimitry Andric// indexed store vd, vs3, (rs1), vs2, vm
401349cc55cSDimitry Andricclass VIndexedStore<RISCVMOP mop, RISCVWidth width, string opcodestr>
402349cc55cSDimitry Andric    : RVInstVSX<0b000, width.Value{3}, mop, width.Value{2-0}, (outs),
40306c3fb27SDimitry Andric                (ins VR:$vs3, GPRMemZeroOffset:$rs1, VR:$vs2, VMaskOp:$vm),
40406c3fb27SDimitry Andric                opcodestr, "$vs3, $rs1, $vs2$vm">;
405349cc55cSDimitry Andric
406e8d8bef9SDimitry Andric// segment store vd, vs3, (rs1), vm
407e8d8bef9SDimitry Andricclass VUnitStrideSegmentStore<bits<3> nf, RISCVWidth width, string opcodestr>
408e8d8bef9SDimitry Andric    : RVInstVSU<nf, width.Value{3}, SUMOPUnitStride, width.Value{2-0},
40906c3fb27SDimitry Andric                (outs), (ins VR:$vs3, GPRMemZeroOffset:$rs1, VMaskOp:$vm), opcodestr,
41006c3fb27SDimitry Andric                "$vs3, ${rs1}$vm">;
411e8d8bef9SDimitry Andric
412e8d8bef9SDimitry Andric// segment store vd, vs3, (rs1), rs2, vm
413e8d8bef9SDimitry Andricclass VStridedSegmentStore<bits<3> nf, RISCVWidth width, string opcodestr>
414e8d8bef9SDimitry Andric    : RVInstVSS<nf, width.Value{3}, width.Value{2-0}, (outs),
41506c3fb27SDimitry Andric                (ins VR:$vs3, GPRMemZeroOffset:$rs1, GPR:$rs2, VMaskOp:$vm),
41606c3fb27SDimitry Andric                opcodestr, "$vs3, $rs1, $rs2$vm">;
417e8d8bef9SDimitry Andric
418e8d8bef9SDimitry Andric// segment store vd, vs3, (rs1), vs2, vm
419e8d8bef9SDimitry Andricclass VIndexedSegmentStore<bits<3> nf, RISCVMOP mop, RISCVWidth width,
420e8d8bef9SDimitry Andric                           string opcodestr>
421e8d8bef9SDimitry Andric    : RVInstVSX<nf, width.Value{3}, mop, width.Value{2-0}, (outs),
42206c3fb27SDimitry Andric                (ins VR:$vs3, GPRMemZeroOffset:$rs1, VR:$vs2, VMaskOp:$vm),
42306c3fb27SDimitry Andric                opcodestr, "$vs3, $rs1, $vs2$vm">;
4245ffd83dbSDimitry Andric} // hasSideEffects = 0, mayLoad = 0, mayStore = 1
4255ffd83dbSDimitry Andric
4265ffd83dbSDimitry Andriclet hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
4275ffd83dbSDimitry Andric// op vd, vs2, vs1, vm
4285ffd83dbSDimitry Andricclass VALUVV<bits<6> funct6, RISCVVFormat opv, string opcodestr>
429e8d8bef9SDimitry Andric    : RVInstVV<funct6, opv, (outs VR:$vd),
430e8d8bef9SDimitry Andric                (ins VR:$vs2, VR:$vs1, VMaskOp:$vm),
4315ffd83dbSDimitry Andric                opcodestr, "$vd, $vs2, $vs1$vm">;
4325ffd83dbSDimitry Andric
4335ffd83dbSDimitry Andric// op vd, vs2, vs1, v0 (without mask, use v0 as carry input)
4345ffd83dbSDimitry Andricclass VALUmVV<bits<6> funct6, RISCVVFormat opv, string opcodestr>
435e8d8bef9SDimitry Andric    : RVInstVV<funct6, opv, (outs VR:$vd),
436e8d8bef9SDimitry Andric                (ins VR:$vs2, VR:$vs1, VMV0:$v0),
4375ffd83dbSDimitry Andric                opcodestr, "$vd, $vs2, $vs1, v0"> {
4385ffd83dbSDimitry Andric  let vm = 0;
4395ffd83dbSDimitry Andric}
4405ffd83dbSDimitry Andric
4415ffd83dbSDimitry Andric// op vd, vs1, vs2, vm (reverse the order of vs1 and vs2)
4425f757f3fSDimitry Andricclass VALUrVV<bits<6> funct6, RISCVVFormat opv, string opcodestr,
4435f757f3fSDimitry Andric              bit EarlyClobber = 0>
4445f757f3fSDimitry Andric    : RVInstVV<funct6, opv, (outs VR:$vd_wb),
4455f757f3fSDimitry Andric                (ins VR:$vd, VR:$vs1, VR:$vs2, VMaskOp:$vm),
4465f757f3fSDimitry Andric                opcodestr, "$vd, $vs1, $vs2$vm"> {
4475f757f3fSDimitry Andric  let Constraints = !if(EarlyClobber, "@earlyclobber $vd_wb, $vd = $vd_wb",
4485f757f3fSDimitry Andric                                      "$vd = $vd_wb");
4495f757f3fSDimitry Andric}
4505ffd83dbSDimitry Andric
451e8d8bef9SDimitry Andric// op vd, vs2, vs1
4525ffd83dbSDimitry Andricclass VALUVVNoVm<bits<6> funct6, RISCVVFormat opv, string opcodestr>
453e8d8bef9SDimitry Andric    : RVInstVV<funct6, opv, (outs VR:$vd),
454e8d8bef9SDimitry Andric               (ins VR:$vs2, VR:$vs1),
4555ffd83dbSDimitry Andric               opcodestr, "$vd, $vs2, $vs1"> {
4565ffd83dbSDimitry Andric  let vm = 1;
4575ffd83dbSDimitry Andric}
4585ffd83dbSDimitry Andric
4595ffd83dbSDimitry Andric// op vd, vs2, rs1, vm
4605ffd83dbSDimitry Andricclass VALUVX<bits<6> funct6, RISCVVFormat opv, string opcodestr>
461e8d8bef9SDimitry Andric    : RVInstVX<funct6, opv, (outs VR:$vd),
462e8d8bef9SDimitry Andric                (ins VR:$vs2, GPR:$rs1, VMaskOp:$vm),
4635ffd83dbSDimitry Andric                opcodestr, "$vd, $vs2, $rs1$vm">;
4645ffd83dbSDimitry Andric
4655ffd83dbSDimitry Andric// op vd, vs2, rs1, v0 (without mask, use v0 as carry input)
4665ffd83dbSDimitry Andricclass VALUmVX<bits<6> funct6, RISCVVFormat opv, string opcodestr>
467e8d8bef9SDimitry Andric    : RVInstVX<funct6, opv, (outs VR:$vd),
468e8d8bef9SDimitry Andric                (ins VR:$vs2, GPR:$rs1, VMV0:$v0),
4695ffd83dbSDimitry Andric                opcodestr, "$vd, $vs2, $rs1, v0"> {
4705ffd83dbSDimitry Andric  let vm = 0;
4715ffd83dbSDimitry Andric}
4725ffd83dbSDimitry Andric
4735ffd83dbSDimitry Andric// op vd, rs1, vs2, vm (reverse the order of rs1 and vs2)
4745f757f3fSDimitry Andricclass VALUrVX<bits<6> funct6, RISCVVFormat opv, string opcodestr,
4755f757f3fSDimitry Andric              bit EarlyClobber = 0>
4765f757f3fSDimitry Andric    : RVInstVX<funct6, opv, (outs VR:$vd_wb),
4775f757f3fSDimitry Andric                (ins VR:$vd, GPR:$rs1, VR:$vs2, VMaskOp:$vm),
4785f757f3fSDimitry Andric                opcodestr, "$vd, $rs1, $vs2$vm"> {
4795f757f3fSDimitry Andric  let Constraints = !if(EarlyClobber, "@earlyclobber $vd_wb, $vd = $vd_wb",
4805f757f3fSDimitry Andric                                      "$vd = $vd_wb");
4815f757f3fSDimitry Andric}
4825ffd83dbSDimitry Andric
4835ffd83dbSDimitry Andric// op vd, vs1, vs2
4845ffd83dbSDimitry Andricclass VALUVXNoVm<bits<6> funct6, RISCVVFormat opv, string opcodestr>
485e8d8bef9SDimitry Andric    : RVInstVX<funct6, opv, (outs VR:$vd),
486e8d8bef9SDimitry Andric               (ins VR:$vs2, GPR:$rs1),
4875ffd83dbSDimitry Andric               opcodestr, "$vd, $vs2, $rs1"> {
4885ffd83dbSDimitry Andric  let vm = 1;
4895ffd83dbSDimitry Andric}
4905ffd83dbSDimitry Andric
4915ffd83dbSDimitry Andric// op vd, vs2, imm, vm
4925ffd83dbSDimitry Andricclass VALUVI<bits<6> funct6, string opcodestr, Operand optype = simm5>
493e8d8bef9SDimitry Andric    : RVInstIVI<funct6, (outs VR:$vd),
494e8d8bef9SDimitry Andric                (ins VR:$vs2, optype:$imm, VMaskOp:$vm),
4955ffd83dbSDimitry Andric                opcodestr, "$vd, $vs2, $imm$vm">;
4965ffd83dbSDimitry Andric
4975ffd83dbSDimitry Andric// op vd, vs2, imm, v0 (without mask, use v0 as carry input)
4985ffd83dbSDimitry Andricclass VALUmVI<bits<6> funct6, string opcodestr, Operand optype = simm5>
499e8d8bef9SDimitry Andric    : RVInstIVI<funct6, (outs VR:$vd),
500e8d8bef9SDimitry Andric                (ins VR:$vs2, optype:$imm, VMV0:$v0),
5015ffd83dbSDimitry Andric                opcodestr, "$vd, $vs2, $imm, v0"> {
5025ffd83dbSDimitry Andric  let vm = 0;
5035ffd83dbSDimitry Andric}
5045ffd83dbSDimitry Andric
5055ffd83dbSDimitry Andric// op vd, vs2, imm, vm
5065ffd83dbSDimitry Andricclass VALUVINoVm<bits<6> funct6, string opcodestr, Operand optype = simm5>
507e8d8bef9SDimitry Andric    : RVInstIVI<funct6, (outs VR:$vd),
508e8d8bef9SDimitry Andric                (ins VR:$vs2, optype:$imm),
5095ffd83dbSDimitry Andric                opcodestr, "$vd, $vs2, $imm"> {
5105ffd83dbSDimitry Andric  let vm = 1;
5115ffd83dbSDimitry Andric}
5125ffd83dbSDimitry Andric
5135ffd83dbSDimitry Andric// op vd, vs2, rs1, vm (Float)
5145ffd83dbSDimitry Andricclass VALUVF<bits<6> funct6, RISCVVFormat opv, string opcodestr>
515e8d8bef9SDimitry Andric    : RVInstVX<funct6, opv, (outs VR:$vd),
516e8d8bef9SDimitry Andric                (ins VR:$vs2, FPR32:$rs1, VMaskOp:$vm),
5175ffd83dbSDimitry Andric                opcodestr, "$vd, $vs2, $rs1$vm">;
5185ffd83dbSDimitry Andric
5195ffd83dbSDimitry Andric// op vd, rs1, vs2, vm (Float) (with mask, reverse the order of rs1 and vs2)
5205f757f3fSDimitry Andricclass VALUrVF<bits<6> funct6, RISCVVFormat opv, string opcodestr,
5215f757f3fSDimitry Andric              bit EarlyClobber = 0>
5225f757f3fSDimitry Andric    : RVInstVX<funct6, opv, (outs VR:$vd_wb),
5235f757f3fSDimitry Andric                (ins VR:$vd, FPR32:$rs1, VR:$vs2, VMaskOp:$vm),
5245f757f3fSDimitry Andric                opcodestr, "$vd, $rs1, $vs2$vm"> {
5255f757f3fSDimitry Andric  let Constraints = !if(EarlyClobber, "@earlyclobber $vd_wb, $vd = $vd_wb",
5265f757f3fSDimitry Andric                                      "$vd = $vd_wb");
5275f757f3fSDimitry Andric}
5285ffd83dbSDimitry Andric
5295ffd83dbSDimitry Andric// op vd, vs2, vm (use vs1 as instruction encoding)
5305ffd83dbSDimitry Andricclass VALUVs2<bits<6> funct6, bits<5> vs1, RISCVVFormat opv, string opcodestr>
531e8d8bef9SDimitry Andric    : RVInstV<funct6, vs1, opv, (outs VR:$vd),
532e8d8bef9SDimitry Andric               (ins VR:$vs2, VMaskOp:$vm),
5335ffd83dbSDimitry Andric               opcodestr, "$vd, $vs2$vm">;
5345ffd83dbSDimitry Andric} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
5355ffd83dbSDimitry Andric
5365ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
5375ffd83dbSDimitry Andric// Combination of instruction classes.
5385ffd83dbSDimitry Andric// Use these multiclasses to define instructions more easily.
5395ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
54004eeddc0SDimitry Andric
5415f757f3fSDimitry Andricmulticlass VIndexLoadStore<int eew> {
5425f757f3fSDimitry Andric  defvar w = !cast<RISCVWidth>("LSWidth" # eew);
54304eeddc0SDimitry Andric
5445f757f3fSDimitry Andric  def VLUXEI # eew # _V :
5455f757f3fSDimitry Andric    VIndexedLoad<MOPLDIndexedUnord, w, "vluxei" # eew # ".v">,
5465f757f3fSDimitry Andric    VLXSchedMC<eew, isOrdered=0>;
5475f757f3fSDimitry Andric  def VLOXEI # eew # _V :
5485f757f3fSDimitry Andric    VIndexedLoad<MOPLDIndexedOrder, w, "vloxei" # eew # ".v">,
5495f757f3fSDimitry Andric    VLXSchedMC<eew, isOrdered=1>;
55004eeddc0SDimitry Andric
5515f757f3fSDimitry Andric  def VSUXEI # eew # _V :
5525f757f3fSDimitry Andric    VIndexedStore<MOPSTIndexedUnord, w, "vsuxei" # eew # ".v">,
5535f757f3fSDimitry Andric    VSXSchedMC<eew, isOrdered=0>;
5545f757f3fSDimitry Andric  def VSOXEI # eew # _V :
5555f757f3fSDimitry Andric    VIndexedStore<MOPSTIndexedOrder, w, "vsoxei" # eew # ".v">,
5565f757f3fSDimitry Andric    VSXSchedMC<eew, isOrdered=1>;
55704eeddc0SDimitry Andric}
55804eeddc0SDimitry Andric
55906c3fb27SDimitry Andricmulticlass VALU_IV_V<string opcodestr, bits<6> funct6> {
56006c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".vv">,
5615f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIALUV", "ReadVIALUV", "ReadVIALUV">;
56206c3fb27SDimitry Andric}
56306c3fb27SDimitry Andric
56406c3fb27SDimitry Andricmulticlass VALU_IV_X<string opcodestr, bits<6> funct6> {
56506c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".vx">,
5665f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIALUX", "ReadVIALUV", "ReadVIALUX">;
56706c3fb27SDimitry Andric}
56806c3fb27SDimitry Andric
56906c3fb27SDimitry Andricmulticlass VALU_IV_I<string opcodestr, bits<6> funct6> {
570*0fca6ea1SDimitry Andric  def I  : VALUVI<funct6, opcodestr # ".vi">,
5715f757f3fSDimitry Andric           SchedUnaryMC<"WriteVIALUI", "ReadVIALUV">;
5725ffd83dbSDimitry Andric}
5735ffd83dbSDimitry Andric
57406c3fb27SDimitry Andricmulticlass VALU_IV_V_X_I<string opcodestr, bits<6> funct6>
57506c3fb27SDimitry Andric    : VALU_IV_V<opcodestr, funct6>,
57606c3fb27SDimitry Andric      VALU_IV_X<opcodestr, funct6>,
57706c3fb27SDimitry Andric      VALU_IV_I<opcodestr, funct6>;
5785ffd83dbSDimitry Andric
57906c3fb27SDimitry Andricmulticlass VALU_IV_V_X<string opcodestr, bits<6> funct6>
58006c3fb27SDimitry Andric    : VALU_IV_V<opcodestr, funct6>,
58106c3fb27SDimitry Andric      VALU_IV_X<opcodestr, funct6>;
5825ffd83dbSDimitry Andric
58306c3fb27SDimitry Andricmulticlass VALU_IV_X_I<string opcodestr, bits<6> funct6>
58406c3fb27SDimitry Andric    : VALU_IV_X<opcodestr, funct6>,
58506c3fb27SDimitry Andric      VALU_IV_I<opcodestr, funct6>;
58606c3fb27SDimitry Andric
58706c3fb27SDimitry Andricmulticlass VALU_MV_V_X<string opcodestr, bits<6> funct6, string vw> {
5886e75b2fbSDimitry Andric  def V  : VALUVV<funct6, OPMVV, opcodestr # "." # vw # "v">,
5895f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIWALUV", "ReadVIWALUV", "ReadVIWALUV">;
5906e75b2fbSDimitry Andric  def X  : VALUVX<funct6, OPMVX, opcodestr # "." # vw # "x">,
5915f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIWALUX", "ReadVIWALUV", "ReadVIWALUX">;
5925ffd83dbSDimitry Andric}
5935ffd83dbSDimitry Andric
59406c3fb27SDimitry Andricmulticlass VMAC_MV_V_X<string opcodestr, bits<6> funct6> {
59506c3fb27SDimitry Andric  def V : VALUrVV<funct6, OPMVV, opcodestr # ".vv">,
5965f757f3fSDimitry Andric          SchedTernaryMC<"WriteVIMulAddV", "ReadVIMulAddV", "ReadVIMulAddV",
5975f757f3fSDimitry Andric                         "ReadVIMulAddV">;
59806c3fb27SDimitry Andric  def X : VALUrVX<funct6, OPMVX, opcodestr # ".vx">,
5995f757f3fSDimitry Andric          SchedTernaryMC<"WriteVIMulAddX", "ReadVIMulAddV", "ReadVIMulAddX",
6005f757f3fSDimitry Andric                         "ReadVIMulAddV">;
6015ffd83dbSDimitry Andric}
6025ffd83dbSDimitry Andric
60306c3fb27SDimitry Andricmulticlass VWMAC_MV_X<string opcodestr, bits<6> funct6> {
6045f757f3fSDimitry Andric  let RVVConstraint = WidenV in
60506c3fb27SDimitry Andric  def X : VALUrVX<funct6, OPMVX, opcodestr # ".vx">,
6065f757f3fSDimitry Andric          SchedTernaryMC<"WriteVIWMulAddX", "ReadVIWMulAddV", "ReadVIWMulAddX",
6075f757f3fSDimitry Andric                         "ReadVIWMulAddV">;
6085ffd83dbSDimitry Andric}
6095ffd83dbSDimitry Andric
61006c3fb27SDimitry Andricmulticlass VWMAC_MV_V_X<string opcodestr, bits<6> funct6>
61106c3fb27SDimitry Andric   : VWMAC_MV_X<opcodestr, funct6> {
6125f757f3fSDimitry Andric  let RVVConstraint = WidenV in
6135f757f3fSDimitry Andric  def V : VALUrVV<funct6, OPMVV, opcodestr # ".vv", EarlyClobber=1>,
6145f757f3fSDimitry Andric          SchedTernaryMC<"WriteVIWMulAddV", "ReadVIWMulAddV", "ReadVIWMulAddV",
6155f757f3fSDimitry Andric                         "ReadVIWMulAddV">;
6165ffd83dbSDimitry Andric}
6175ffd83dbSDimitry Andric
6185ffd83dbSDimitry Andricmulticlass VALU_MV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
6196e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPMVV, opcodestr>,
6205f757f3fSDimitry Andric           SchedUnaryMC<"WriteVExtV", "ReadVExtV">;
6216e75b2fbSDimitry Andric}
6226e75b2fbSDimitry Andric
6236e75b2fbSDimitry Andricmulticlass VMRG_IV_V_X_I<string opcodestr, bits<6> funct6> {
6246e75b2fbSDimitry Andric  def VM : VALUmVV<funct6, OPIVV, opcodestr # ".vvm">,
6255f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIMergeV", "ReadVIMergeV", "ReadVIMergeV">;
6266e75b2fbSDimitry Andric  def XM : VALUmVX<funct6, OPIVX, opcodestr # ".vxm">,
6275f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIMergeX", "ReadVIMergeV", "ReadVIMergeX">;
6286e75b2fbSDimitry Andric  def IM : VALUmVI<funct6, opcodestr # ".vim">,
6295f757f3fSDimitry Andric           SchedUnaryMC<"WriteVIMergeI", "ReadVIMergeV">;
6305ffd83dbSDimitry Andric}
6315ffd83dbSDimitry Andric
6325ffd83dbSDimitry Andricmulticlass VALUm_IV_V_X<string opcodestr, bits<6> funct6> {
6336e75b2fbSDimitry Andric  def VM : VALUmVV<funct6, OPIVV, opcodestr # ".vvm">,
6345f757f3fSDimitry Andric           SchedBinaryMC<"WriteVICALUV", "ReadVICALUV", "ReadVICALUV">;
6356e75b2fbSDimitry Andric  def XM : VALUmVX<funct6, OPIVX, opcodestr # ".vxm">,
6365f757f3fSDimitry Andric           SchedBinaryMC<"WriteVICALUX", "ReadVICALUV", "ReadVICALUX">;
6375ffd83dbSDimitry Andric}
6385ffd83dbSDimitry Andric
63906c3fb27SDimitry Andricmulticlass VALUm_IV_V_X_I<string opcodestr, bits<6> funct6>
64006c3fb27SDimitry Andric    : VALUm_IV_V_X<opcodestr, funct6> {
64106c3fb27SDimitry Andric  def IM : VALUmVI<funct6, opcodestr # ".vim">,
6425f757f3fSDimitry Andric           SchedUnaryMC<"WriteVICALUI", "ReadVICALUV">;
6435ffd83dbSDimitry Andric}
6445ffd83dbSDimitry Andric
6455ffd83dbSDimitry Andricmulticlass VALUNoVm_IV_V_X<string opcodestr, bits<6> funct6> {
6466e75b2fbSDimitry Andric  def V : VALUVVNoVm<funct6, OPIVV, opcodestr # ".vv">,
6475f757f3fSDimitry Andric          SchedBinaryMC<"WriteVICALUV", "ReadVICALUV", "ReadVICALUV",
6485f757f3fSDimitry Andric                        forceMasked=0>;
6496e75b2fbSDimitry Andric  def X : VALUVXNoVm<funct6, OPIVX, opcodestr # ".vx">,
6505f757f3fSDimitry Andric          SchedBinaryMC<"WriteVICALUX", "ReadVICALUV", "ReadVICALUX",
6515f757f3fSDimitry Andric                        forceMasked=0>;
6525ffd83dbSDimitry Andric}
6535ffd83dbSDimitry Andric
65406c3fb27SDimitry Andricmulticlass VALUNoVm_IV_V_X_I<string opcodestr, bits<6> funct6>
65506c3fb27SDimitry Andric   : VALUNoVm_IV_V_X<opcodestr, funct6> {
656*0fca6ea1SDimitry Andric  def I : VALUVINoVm<funct6, opcodestr # ".vi">,
6575f757f3fSDimitry Andric          SchedUnaryMC<"WriteVICALUI", "ReadVICALUV", forceMasked=0>;
65806c3fb27SDimitry Andric}
65906c3fb27SDimitry Andric
66006c3fb27SDimitry Andricmulticlass VALU_FV_F<string opcodestr, bits<6> funct6> {
66106c3fb27SDimitry Andric  def F : VALUVF<funct6, OPFVF, opcodestr # ".vf">,
6625f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFALUF", "ReadVFALUV", "ReadVFALUF">;
66306c3fb27SDimitry Andric}
66406c3fb27SDimitry Andric
66506c3fb27SDimitry Andricmulticlass VALU_FV_V_F<string opcodestr, bits<6> funct6>
66606c3fb27SDimitry Andric    : VALU_FV_F<opcodestr, funct6> {
66706c3fb27SDimitry Andric  def V : VALUVV<funct6, OPFVV, opcodestr # ".vv">,
6685f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFALUV", "ReadVFALUV", "ReadVFALUV">;
66906c3fb27SDimitry Andric}
67006c3fb27SDimitry Andric
67106c3fb27SDimitry Andricmulticlass VWALU_FV_V_F<string opcodestr, bits<6> funct6, string vw> {
6726e75b2fbSDimitry Andric  def V : VALUVV<funct6, OPFVV, opcodestr # "." # vw # "v">,
6735f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFWALUV", "ReadVFWALUV", "ReadVFWALUV">;
6746e75b2fbSDimitry Andric  def F : VALUVF<funct6, OPFVF, opcodestr # "." # vw # "f">,
6755f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFWALUF", "ReadVFWALUV", "ReadVFWALUF">;
6765ffd83dbSDimitry Andric}
6775ffd83dbSDimitry Andric
67806c3fb27SDimitry Andricmulticlass VMUL_FV_V_F<string opcodestr, bits<6> funct6> {
67906c3fb27SDimitry Andric  def V : VALUVV<funct6, OPFVV, opcodestr # ".vv">,
6805f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFMulV", "ReadVFMulV", "ReadVFMulV">;
68106c3fb27SDimitry Andric  def F : VALUVF<funct6, OPFVF, opcodestr # ".vf">,
6825f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFMulF", "ReadVFMulV", "ReadVFMulF">;
6835ffd83dbSDimitry Andric}
6845ffd83dbSDimitry Andric
68506c3fb27SDimitry Andricmulticlass VDIV_FV_F<string opcodestr, bits<6> funct6> {
68606c3fb27SDimitry Andric  def F : VALUVF<funct6, OPFVF, opcodestr # ".vf">,
6875f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFDivF", "ReadVFDivV", "ReadVFDivF">;
6885ffd83dbSDimitry Andric}
6895ffd83dbSDimitry Andric
69006c3fb27SDimitry Andricmulticlass VDIV_FV_V_F<string opcodestr, bits<6> funct6>
69106c3fb27SDimitry Andric    : VDIV_FV_F<opcodestr, funct6> {
69206c3fb27SDimitry Andric  def V : VALUVV<funct6, OPFVV, opcodestr # ".vv">,
6935f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFDivV", "ReadVFDivV", "ReadVFDivV">;
6945ffd83dbSDimitry Andric}
6955ffd83dbSDimitry Andric
69606c3fb27SDimitry Andricmulticlass VWMUL_FV_V_F<string opcodestr, bits<6> funct6> {
69706c3fb27SDimitry Andric  def V : VALUVV<funct6, OPFVV, opcodestr # ".vv">,
6985f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFWMulV", "ReadVFWMulV", "ReadVFWMulV">;
69906c3fb27SDimitry Andric  def F : VALUVF<funct6, OPFVF, opcodestr # ".vf">,
7005f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFWMulF", "ReadVFWMulV", "ReadVFWMulF">;
7016e75b2fbSDimitry Andric}
7026e75b2fbSDimitry Andric
70306c3fb27SDimitry Andricmulticlass VMAC_FV_V_F<string opcodestr, bits<6> funct6> {
70406c3fb27SDimitry Andric  def V : VALUrVV<funct6, OPFVV, opcodestr # ".vv">,
7055f757f3fSDimitry Andric          SchedTernaryMC<"WriteVFMulAddV", "ReadVFMulAddV", "ReadVFMulAddV",
7065f757f3fSDimitry Andric                         "ReadVFMulAddV">;
70706c3fb27SDimitry Andric  def F : VALUrVF<funct6, OPFVF, opcodestr # ".vf">,
7085f757f3fSDimitry Andric          SchedTernaryMC<"WriteVFMulAddF", "ReadVFMulAddV", "ReadVFMulAddF",
7095f757f3fSDimitry Andric                         "ReadVFMulAddV">;
7106e75b2fbSDimitry Andric}
7116e75b2fbSDimitry Andric
71206c3fb27SDimitry Andricmulticlass VWMAC_FV_V_F<string opcodestr, bits<6> funct6> {
7135f757f3fSDimitry Andric  let RVVConstraint = WidenV in {
7145f757f3fSDimitry Andric  def V : VALUrVV<funct6, OPFVV, opcodestr # ".vv", EarlyClobber=1>,
7155f757f3fSDimitry Andric          SchedTernaryMC<"WriteVFWMulAddV", "ReadVFWMulAddV", "ReadVFWMulAddV",
7165f757f3fSDimitry Andric                         "ReadVFWMulAddV">;
7175f757f3fSDimitry Andric  def F : VALUrVF<funct6, OPFVF, opcodestr # ".vf", EarlyClobber=1>,
7185f757f3fSDimitry Andric          SchedTernaryMC<"WriteVFWMulAddF", "ReadVFWMulAddV", "ReadVFWMulAddF",
7195f757f3fSDimitry Andric                         "ReadVFWMulAddV">;
7205f757f3fSDimitry Andric  }
7216e75b2fbSDimitry Andric}
7226e75b2fbSDimitry Andric
7236e75b2fbSDimitry Andricmulticlass VSQR_FV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7246e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
7255f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFSqrtV", "ReadVFSqrtV">;
7266e75b2fbSDimitry Andric}
7276e75b2fbSDimitry Andric
7286e75b2fbSDimitry Andricmulticlass VRCP_FV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7296e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
7305f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFRecpV", "ReadVFRecpV">;
7316e75b2fbSDimitry Andric}
7326e75b2fbSDimitry Andric
73306c3fb27SDimitry Andricmulticlass VMINMAX_FV_V_F<string opcodestr, bits<6> funct6> {
73406c3fb27SDimitry Andric  def V : VALUVV<funct6, OPFVV, opcodestr # ".vv">,
7355f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFMinMaxV", "ReadVFMinMaxV", "ReadVFMinMaxV">;
73606c3fb27SDimitry Andric  def F : VALUVF<funct6, OPFVF, opcodestr # ".vf">,
7375f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFMinMaxF", "ReadVFMinMaxV", "ReadVFMinMaxF">;
7386e75b2fbSDimitry Andric}
7396e75b2fbSDimitry Andric
74006c3fb27SDimitry Andricmulticlass VCMP_FV_F<string opcodestr, bits<6> funct6> {
74106c3fb27SDimitry Andric  def F : VALUVF<funct6, OPFVF, opcodestr # ".vf">,
7425f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFCmpF", "ReadVFCmpV", "ReadVFCmpF">;
7436e75b2fbSDimitry Andric}
7446e75b2fbSDimitry Andric
74506c3fb27SDimitry Andricmulticlass VCMP_FV_V_F<string opcodestr, bits<6> funct6>
74606c3fb27SDimitry Andric    : VCMP_FV_F<opcodestr, funct6> {
74706c3fb27SDimitry Andric  def V : VALUVV<funct6, OPFVV, opcodestr # ".vv">,
7485f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFCmpV", "ReadVFCmpV", "ReadVFCmpV">;
74906c3fb27SDimitry Andric}
75006c3fb27SDimitry Andric
75106c3fb27SDimitry Andricmulticlass VSGNJ_FV_V_F<string opcodestr, bits<6> funct6> {
75206c3fb27SDimitry Andric  def V : VALUVV<funct6, OPFVV, opcodestr # ".vv">,
7535f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFSgnjV", "ReadVFSgnjV", "ReadVFSgnjV">;
75406c3fb27SDimitry Andric  def F : VALUVF<funct6, OPFVF, opcodestr # ".vf">,
7555f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFSgnjF", "ReadVFSgnjV", "ReadVFSgnjF">;
7566e75b2fbSDimitry Andric}
7576e75b2fbSDimitry Andric
7586e75b2fbSDimitry Andricmulticlass VCLS_FV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7596e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
7605f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFClassV", "ReadVFClassV">;
7616e75b2fbSDimitry Andric}
7626e75b2fbSDimitry Andric
7636e75b2fbSDimitry Andricmulticlass VCVTF_IV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7646e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
7655f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFCvtIToFV", "ReadVFCvtIToFV">;
7666e75b2fbSDimitry Andric}
7676e75b2fbSDimitry Andric
7686e75b2fbSDimitry Andricmulticlass VCVTI_FV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7696e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
7705f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFCvtFToIV", "ReadVFCvtFToIV">;
7716e75b2fbSDimitry Andric}
7726e75b2fbSDimitry Andric
7736e75b2fbSDimitry Andricmulticlass VWCVTF_IV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7746e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
7755f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFWCvtIToFV", "ReadVFWCvtIToFV">;
7766e75b2fbSDimitry Andric}
7776e75b2fbSDimitry Andric
7786e75b2fbSDimitry Andricmulticlass VWCVTI_FV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7796e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
7805f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFWCvtFToIV", "ReadVFWCvtFToIV">;
7816e75b2fbSDimitry Andric}
7826e75b2fbSDimitry Andric
7836e75b2fbSDimitry Andricmulticlass VWCVTF_FV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7846e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
7855f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFWCvtFToFV", "ReadVFWCvtFToFV">;
7866e75b2fbSDimitry Andric}
7876e75b2fbSDimitry Andric
7886e75b2fbSDimitry Andricmulticlass VNCVTF_IV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7896e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
7905f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFNCvtIToFV", "ReadVFNCvtIToFV">;
7916e75b2fbSDimitry Andric}
7926e75b2fbSDimitry Andric
7936e75b2fbSDimitry Andricmulticlass VNCVTI_FV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7946e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
7955f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFNCvtFToIV", "ReadVFNCvtFToIV">;
7966e75b2fbSDimitry Andric}
7976e75b2fbSDimitry Andric
7986e75b2fbSDimitry Andricmulticlass VNCVTF_FV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7996e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
8005f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFNCvtFToFV", "ReadVFNCvtFToFV">;
8016e75b2fbSDimitry Andric}
8026e75b2fbSDimitry Andric
8036e75b2fbSDimitry Andricmulticlass VRED_MV_V<string opcodestr, bits<6> funct6> {
8046e75b2fbSDimitry Andric  def _VS : VALUVV<funct6, OPMVV, opcodestr # ".vs">,
8055f757f3fSDimitry Andric            SchedReductionMC<"WriteVIRedV_From", "ReadVIRedV", "ReadVIRedV0">;
80606c3fb27SDimitry Andric}
80706c3fb27SDimitry Andric
80806c3fb27SDimitry Andricmulticlass VREDMINMAX_MV_V<string opcodestr, bits<6> funct6> {
80906c3fb27SDimitry Andric  def _VS : VALUVV<funct6, OPMVV, opcodestr # ".vs">,
8105f757f3fSDimitry Andric            SchedReductionMC<"WriteVIRedMinMaxV_From", "ReadVIRedV", "ReadVIRedV0">;
8116e75b2fbSDimitry Andric}
8126e75b2fbSDimitry Andric
8136e75b2fbSDimitry Andricmulticlass VWRED_IV_V<string opcodestr, bits<6> funct6> {
8146e75b2fbSDimitry Andric  def _VS : VALUVV<funct6, OPIVV, opcodestr # ".vs">,
8155f757f3fSDimitry Andric            SchedReductionMC<"WriteVIWRedV_From", "ReadVIWRedV", "ReadVIWRedV0">;
8166e75b2fbSDimitry Andric}
8176e75b2fbSDimitry Andric
8186e75b2fbSDimitry Andricmulticlass VRED_FV_V<string opcodestr, bits<6> funct6> {
8196e75b2fbSDimitry Andric  def _VS : VALUVV<funct6, OPFVV, opcodestr # ".vs">,
8205f757f3fSDimitry Andric            SchedReductionMC<"WriteVFRedV_From", "ReadVFRedV", "ReadVFRedV0">;
82106c3fb27SDimitry Andric}
82206c3fb27SDimitry Andric
82306c3fb27SDimitry Andricmulticlass VREDMINMAX_FV_V<string opcodestr, bits<6> funct6> {
82406c3fb27SDimitry Andric  def _VS : VALUVV<funct6, OPFVV, opcodestr # ".vs">,
8255f757f3fSDimitry Andric            SchedReductionMC<"WriteVFRedMinMaxV_From", "ReadVFRedV", "ReadVFRedV0">;
8266e75b2fbSDimitry Andric}
8276e75b2fbSDimitry Andric
8286e75b2fbSDimitry Andricmulticlass VREDO_FV_V<string opcodestr, bits<6> funct6> {
8296e75b2fbSDimitry Andric  def _VS : VALUVV<funct6, OPFVV, opcodestr # ".vs">,
8305f757f3fSDimitry Andric            SchedReductionMC<"WriteVFRedOV_From", "ReadVFRedOV", "ReadVFRedOV0">;
8316e75b2fbSDimitry Andric}
8326e75b2fbSDimitry Andric
8336e75b2fbSDimitry Andricmulticlass VWRED_FV_V<string opcodestr, bits<6> funct6> {
8346e75b2fbSDimitry Andric  def _VS : VALUVV<funct6, OPFVV, opcodestr # ".vs">,
8355f757f3fSDimitry Andric            SchedReductionMC<"WriteVFWRedV_From", "ReadVFWRedV", "ReadVFWRedV0">;
8366e75b2fbSDimitry Andric}
8376e75b2fbSDimitry Andric
8386e75b2fbSDimitry Andricmulticlass VWREDO_FV_V<string opcodestr, bits<6> funct6> {
8396e75b2fbSDimitry Andric  def _VS : VALUVV<funct6, OPFVV, opcodestr # ".vs">,
8405f757f3fSDimitry Andric            SchedReductionMC<"WriteVFWRedOV_From", "ReadVFWRedOV", "ReadVFWRedOV0">;
8416e75b2fbSDimitry Andric}
8426e75b2fbSDimitry Andric
8436e75b2fbSDimitry Andricmulticlass VMALU_MV_Mask<string opcodestr, bits<6> funct6, string vm = "v"> {
8446e75b2fbSDimitry Andric  def M : VALUVVNoVm<funct6, OPMVV, opcodestr #"." #vm #"m">,
8455f757f3fSDimitry Andric          SchedBinaryMC<"WriteVMALUV", "ReadVMALUV", "ReadVMALUV",
8465f757f3fSDimitry Andric                        forceMasked=0>;
8476e75b2fbSDimitry Andric}
8486e75b2fbSDimitry Andric
8496e75b2fbSDimitry Andricmulticlass VMSFS_MV_V<string opcodestr, bits<6> funct6, bits<5> vs1> {
8506e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPMVV, opcodestr>,
8515f757f3fSDimitry Andric           SchedUnaryMC<"WriteVMSFSV", "ReadVMSFSV">;
8526e75b2fbSDimitry Andric}
8536e75b2fbSDimitry Andric
854*0fca6ea1SDimitry Andricmulticlass VIOTA_MV_V<string opcodestr, bits<6> funct6, bits<5> vs1> {
8556e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPMVV, opcodestr>,
856*0fca6ea1SDimitry Andric           SchedUnaryMC<"WriteVIotaV", "ReadVIotaV">;
8576e75b2fbSDimitry Andric}
8586e75b2fbSDimitry Andric
85906c3fb27SDimitry Andricmulticlass VSHT_IV_V_X_I<string opcodestr, bits<6> funct6> {
86006c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".vv">,
8615f757f3fSDimitry Andric           SchedBinaryMC<"WriteVShiftV", "ReadVShiftV", "ReadVShiftV">;
86206c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".vx">,
8635f757f3fSDimitry Andric           SchedBinaryMC<"WriteVShiftX", "ReadVShiftV", "ReadVShiftX">;
86406c3fb27SDimitry Andric  def I  : VALUVI<funct6, opcodestr # ".vi", uimm5>,
8655f757f3fSDimitry Andric           SchedUnaryMC<"WriteVShiftI", "ReadVShiftV">;
8666e75b2fbSDimitry Andric}
8676e75b2fbSDimitry Andric
86806c3fb27SDimitry Andricmulticlass VNSHT_IV_V_X_I<string opcodestr, bits<6> funct6> {
86906c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".wv">,
8705f757f3fSDimitry Andric           SchedBinaryMC<"WriteVNShiftV", "ReadVNShiftV", "ReadVNShiftV">;
87106c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".wx">,
8725f757f3fSDimitry Andric           SchedBinaryMC<"WriteVNShiftX", "ReadVNShiftV", "ReadVNShiftX">;
87306c3fb27SDimitry Andric  def I  : VALUVI<funct6, opcodestr # ".wi", uimm5>,
8745f757f3fSDimitry Andric           SchedUnaryMC<"WriteVNShiftI", "ReadVNShiftV">;
8756e75b2fbSDimitry Andric}
8766e75b2fbSDimitry Andric
87706c3fb27SDimitry Andricmulticlass VMINMAX_IV_V_X<string opcodestr, bits<6> funct6> {
87806c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".vv">,
8795f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIMinMaxV", "ReadVIMinMaxV", "ReadVIMinMaxV">;
88006c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".vx">,
8815f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIMinMaxX", "ReadVIMinMaxV", "ReadVIMinMaxX">;
88206c3fb27SDimitry Andric}
88306c3fb27SDimitry Andric
88406c3fb27SDimitry Andricmulticlass VCMP_IV_V<string opcodestr, bits<6> funct6> {
88506c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".vv">,
8865f757f3fSDimitry Andric           SchedBinaryMC<"WriteVICmpV", "ReadVICmpV", "ReadVICmpV">;
88706c3fb27SDimitry Andric}
88806c3fb27SDimitry Andric
88906c3fb27SDimitry Andricmulticlass VCMP_IV_X<string opcodestr, bits<6> funct6> {
89006c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".vx">,
8915f757f3fSDimitry Andric           SchedBinaryMC<"WriteVICmpX", "ReadVICmpV", "ReadVICmpX">;
89206c3fb27SDimitry Andric}
89306c3fb27SDimitry Andric
89406c3fb27SDimitry Andricmulticlass VCMP_IV_I<string opcodestr, bits<6> funct6> {
895*0fca6ea1SDimitry Andric  def I  : VALUVI<funct6, opcodestr # ".vi">,
8965f757f3fSDimitry Andric           SchedUnaryMC<"WriteVICmpI", "ReadVICmpV">;
8976e75b2fbSDimitry Andric}
8986e75b2fbSDimitry Andric
89906c3fb27SDimitry Andricmulticlass VCMP_IV_V_X_I<string opcodestr, bits<6> funct6>
90006c3fb27SDimitry Andric    : VCMP_IV_V<opcodestr, funct6>,
90106c3fb27SDimitry Andric      VCMP_IV_X<opcodestr, funct6>,
90206c3fb27SDimitry Andric      VCMP_IV_I<opcodestr, funct6>;
90306c3fb27SDimitry Andric
90406c3fb27SDimitry Andricmulticlass VCMP_IV_X_I<string opcodestr, bits<6> funct6>
90506c3fb27SDimitry Andric    : VCMP_IV_X<opcodestr, funct6>,
90606c3fb27SDimitry Andric      VCMP_IV_I<opcodestr, funct6>;
90706c3fb27SDimitry Andric
90806c3fb27SDimitry Andricmulticlass VCMP_IV_V_X<string opcodestr, bits<6> funct6>
90906c3fb27SDimitry Andric    : VCMP_IV_V<opcodestr, funct6>,
91006c3fb27SDimitry Andric      VCMP_IV_X<opcodestr, funct6>;
91106c3fb27SDimitry Andric
91206c3fb27SDimitry Andricmulticlass VMUL_MV_V_X<string opcodestr, bits<6> funct6> {
91306c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPMVV, opcodestr # ".vv">,
9145f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIMulV", "ReadVIMulV", "ReadVIMulV">;
91506c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPMVX, opcodestr # ".vx">,
9165f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIMulX", "ReadVIMulV", "ReadVIMulX">;
91706c3fb27SDimitry Andric}
91806c3fb27SDimitry Andric
91906c3fb27SDimitry Andricmulticlass VWMUL_MV_V_X<string opcodestr, bits<6> funct6> {
92006c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPMVV, opcodestr # ".vv">,
9215f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIWMulV", "ReadVIWMulV", "ReadVIWMulV">;
92206c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPMVX, opcodestr # ".vx">,
9235f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIWMulX", "ReadVIWMulV", "ReadVIWMulX">;
92406c3fb27SDimitry Andric}
92506c3fb27SDimitry Andric
92606c3fb27SDimitry Andricmulticlass VDIV_MV_V_X<string opcodestr, bits<6> funct6> {
92706c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPMVV, opcodestr # ".vv">,
9285f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIDivV", "ReadVIDivV", "ReadVIDivV">;
92906c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPMVX, opcodestr # ".vx">,
9305f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIDivX", "ReadVIDivV", "ReadVIDivX">;
93106c3fb27SDimitry Andric}
93206c3fb27SDimitry Andric
93306c3fb27SDimitry Andricmulticlass VSALU_IV_V_X<string opcodestr, bits<6> funct6> {
93406c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".vv">,
9355f757f3fSDimitry Andric           SchedBinaryMC<"WriteVSALUV", "ReadVSALUV", "ReadVSALUV">;
93606c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".vx">,
9375f757f3fSDimitry Andric           SchedBinaryMC<"WriteVSALUX", "ReadVSALUV", "ReadVSALUX">;
93806c3fb27SDimitry Andric}
93906c3fb27SDimitry Andric
94006c3fb27SDimitry Andricmulticlass VSALU_IV_V_X_I<string opcodestr, bits<6> funct6>
94106c3fb27SDimitry Andric    : VSALU_IV_V_X<opcodestr, funct6> {
942*0fca6ea1SDimitry Andric  def I  : VALUVI<funct6, opcodestr # ".vi">,
9435f757f3fSDimitry Andric           SchedUnaryMC<"WriteVSALUI", "ReadVSALUV">;
9446e75b2fbSDimitry Andric}
9456e75b2fbSDimitry Andric
94606c3fb27SDimitry Andricmulticlass VAALU_MV_V_X<string opcodestr, bits<6> funct6> {
94706c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPMVV, opcodestr # ".vv">,
9485f757f3fSDimitry Andric           SchedBinaryMC<"WriteVAALUV", "ReadVAALUV", "ReadVAALUV">;
94906c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPMVX, opcodestr # ".vx">,
9505f757f3fSDimitry Andric           SchedBinaryMC<"WriteVAALUX", "ReadVAALUV", "ReadVAALUX">;
9516e75b2fbSDimitry Andric}
9526e75b2fbSDimitry Andric
95306c3fb27SDimitry Andricmulticlass VSMUL_IV_V_X<string opcodestr, bits<6> funct6> {
95406c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".vv">,
9555f757f3fSDimitry Andric           SchedBinaryMC<"WriteVSMulV", "ReadVSMulV", "ReadVSMulV">;
95606c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".vx">,
9575f757f3fSDimitry Andric           SchedBinaryMC<"WriteVSMulX", "ReadVSMulV", "ReadVSMulX">;
9586e75b2fbSDimitry Andric}
9596e75b2fbSDimitry Andric
96006c3fb27SDimitry Andricmulticlass VSSHF_IV_V_X_I<string opcodestr, bits<6> funct6> {
96106c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".vv">,
9625f757f3fSDimitry Andric           SchedBinaryMC<"WriteVSShiftV", "ReadVSShiftV", "ReadVSShiftV">;
96306c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".vx">,
9645f757f3fSDimitry Andric           SchedBinaryMC<"WriteVSShiftX", "ReadVSShiftV", "ReadVSShiftX">;
96506c3fb27SDimitry Andric  def I  : VALUVI<funct6, opcodestr # ".vi", uimm5>,
9665f757f3fSDimitry Andric           SchedUnaryMC<"WriteVSShiftI", "ReadVSShiftV">;
9676e75b2fbSDimitry Andric}
9686e75b2fbSDimitry Andric
96906c3fb27SDimitry Andricmulticlass VNCLP_IV_V_X_I<string opcodestr, bits<6> funct6> {
97006c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".wv">,
9715f757f3fSDimitry Andric           SchedBinaryMC<"WriteVNClipV", "ReadVNClipV", "ReadVNClipV">;
97206c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".wx">,
9735f757f3fSDimitry Andric           SchedBinaryMC<"WriteVNClipX", "ReadVNClipV", "ReadVNClipX">;
97406c3fb27SDimitry Andric  def I  : VALUVI<funct6, opcodestr # ".wi", uimm5>,
9755f757f3fSDimitry Andric           SchedUnaryMC<"WriteVNClipI", "ReadVNClipV">;
9766e75b2fbSDimitry Andric}
9776e75b2fbSDimitry Andric
978*0fca6ea1SDimitry Andricmulticlass VSLD_IV_X_I<string opcodestr, bits<6> funct6, bit slidesUp> {
979*0fca6ea1SDimitry Andric  // Note: In the future, if VISlideI is also split into VSlideUpI and
980*0fca6ea1SDimitry Andric  // VSlideDownI, it'll probably better to use two separate multiclasses.
981*0fca6ea1SDimitry Andric  defvar WriteSlideX = !if(slidesUp, "WriteVSlideUpX", "WriteVSlideDownX");
98206c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".vx">,
983*0fca6ea1SDimitry Andric           SchedBinaryMC<WriteSlideX, "ReadVISlideV", "ReadVISlideX">;
98406c3fb27SDimitry Andric  def I  : VALUVI<funct6, opcodestr # ".vi", uimm5>,
985*0fca6ea1SDimitry Andric           SchedUnaryMC<"WriteVSlideI", "ReadVISlideV">;
9866e75b2fbSDimitry Andric}
9876e75b2fbSDimitry Andric
98806c3fb27SDimitry Andricmulticlass VSLD1_MV_X<string opcodestr, bits<6> funct6> {
98906c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPMVX, opcodestr # ".vx">,
9905f757f3fSDimitry Andric           SchedBinaryMC<"WriteVISlide1X", "ReadVISlideV", "ReadVISlideX">;
9916e75b2fbSDimitry Andric}
9926e75b2fbSDimitry Andric
99306c3fb27SDimitry Andricmulticlass VSLD1_FV_F<string opcodestr, bits<6> funct6> {
99406c3fb27SDimitry Andric  def F : VALUVF<funct6, OPFVF, opcodestr # ".vf">,
9955f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFSlide1F", "ReadVFSlideV", "ReadVFSlideF">;
9966e75b2fbSDimitry Andric}
9976e75b2fbSDimitry Andric
99806c3fb27SDimitry Andricmulticlass VGTR_IV_V_X_I<string opcodestr, bits<6> funct6> {
99906c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".vv">,
10005f757f3fSDimitry Andric           SchedBinaryMC<"WriteVRGatherVV", "ReadVRGatherVV_data",
10015f757f3fSDimitry Andric                         "ReadVRGatherVV_index">;
100206c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".vx">,
10035f757f3fSDimitry Andric           SchedBinaryMC<"WriteVRGatherVX", "ReadVRGatherVX_data",
10045f757f3fSDimitry Andric                         "ReadVRGatherVX_index">;
100506c3fb27SDimitry Andric  def I  : VALUVI<funct6, opcodestr # ".vi", uimm5>,
10065f757f3fSDimitry Andric           SchedUnaryMC<"WriteVRGatherVI", "ReadVRGatherVI_data">;
10076e75b2fbSDimitry Andric}
10086e75b2fbSDimitry Andric
10096e75b2fbSDimitry Andricmulticlass VCPR_MV_Mask<string opcodestr, bits<6> funct6, string vm = "v"> {
10106e75b2fbSDimitry Andric  def M  : VALUVVNoVm<funct6, OPMVV, opcodestr # "." # vm # "m">,
10115f757f3fSDimitry Andric           SchedBinaryMC<"WriteVCompressV", "ReadVCompressV", "ReadVCompressV">;
10125ffd83dbSDimitry Andric}
10135ffd83dbSDimitry Andric
10145f757f3fSDimitry Andricmulticlass VWholeLoadN<int l, bits<3> nf, string opcodestr, RegisterClass VRC> {
1015349cc55cSDimitry Andric  defvar w = !cast<RISCVWidth>("LSWidth" # l);
1016bdd1243dSDimitry Andric  defvar s = !cast<SchedWrite>("WriteVLD" # !add(nf, 1) # "R");
10176e75b2fbSDimitry Andric
1018349cc55cSDimitry Andric  def E # l # _V : VWholeLoad<nf, w, opcodestr # "e" # l # ".v", VRC>,
101906c3fb27SDimitry Andric                   Sched<[s, ReadVLDX]>;
10206e75b2fbSDimitry Andric}
1021e8d8bef9SDimitry Andric
10225ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
10235ffd83dbSDimitry Andric// Instructions
10245ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
10255ffd83dbSDimitry Andric
102604eeddc0SDimitry Andriclet Predicates = [HasVInstructions] in {
10275ffd83dbSDimitry Andriclet hasSideEffects = 1, mayLoad = 0, mayStore = 0 in {
102804eeddc0SDimitry Andricdef VSETVLI : RVInstSetVLi<(outs GPR:$rd), (ins GPR:$rs1, VTypeIOp11:$vtypei),
1029bdd1243dSDimitry Andric                           "vsetvli", "$rd, $rs1, $vtypei">,
1030bdd1243dSDimitry Andric                           Sched<[WriteVSETVLI, ReadVSETVLI]>;
103104eeddc0SDimitry Andricdef VSETIVLI : RVInstSetiVLi<(outs GPR:$rd), (ins uimm5:$uimm, VTypeIOp10:$vtypei),
1032bdd1243dSDimitry Andric                             "vsetivli", "$rd, $uimm, $vtypei">,
1033bdd1243dSDimitry Andric                             Sched<[WriteVSETIVLI]>;
1034d409305fSDimitry Andric
10355ffd83dbSDimitry Andricdef VSETVL : RVInstSetVL<(outs GPR:$rd), (ins GPR:$rs1, GPR:$rs2),
1036bdd1243dSDimitry Andric                         "vsetvl", "$rd, $rs1, $rs2">,
1037bdd1243dSDimitry Andric                          Sched<[WriteVSETVL, ReadVSETVL, ReadVSETVL]>;
10385ffd83dbSDimitry Andric} // hasSideEffects = 1, mayLoad = 0, mayStore = 0
10395f757f3fSDimitry Andric} // Predicates = [HasVInstructions]
10405f757f3fSDimitry Andric
10415f757f3fSDimitry Andricforeach eew = [8, 16, 32, 64] in {
1042349cc55cSDimitry Andric  defvar w = !cast<RISCVWidth>("LSWidth" # eew);
10435ffd83dbSDimitry Andric
10445f757f3fSDimitry Andric  let Predicates = !if(!eq(eew, 64), [HasVInstructionsI64],
10455f757f3fSDimitry Andric                                     [HasVInstructions]) in {
10465ffd83dbSDimitry Andric    // Vector Unit-Stride Instructions
10475f757f3fSDimitry Andric    def VLE#eew#_V : VUnitStrideLoad<w, "vle"#eew#".v">, VLESchedMC;
10485f757f3fSDimitry Andric    def VSE#eew#_V  : VUnitStrideStore<w,  "vse"#eew#".v">, VSESchedMC;
10495ffd83dbSDimitry Andric
1050349cc55cSDimitry Andric    // Vector Unit-Stride Fault-only-First Loads
10515f757f3fSDimitry Andric    def VLE#eew#FF_V : VUnitStrideLoadFF<w,  "vle"#eew#"ff.v">, VLFSchedMC;
10525ffd83dbSDimitry Andric
10535ffd83dbSDimitry Andric    // Vector Strided Instructions
10545f757f3fSDimitry Andric    def VLSE#eew#_V  : VStridedLoad<w,  "vlse"#eew#".v">, VLSSchedMC<eew>;
10555f757f3fSDimitry Andric    def VSSE#eew#_V  : VStridedStore<w,  "vsse"#eew#".v">, VSSSchedMC<eew>;
10565f757f3fSDimitry Andric
10575f757f3fSDimitry Andric    defm VL1R : VWholeLoadN<eew, 0, "vl1r", VR>;
10585f757f3fSDimitry Andric    defm VL2R : VWholeLoadN<eew, 1, "vl2r", VRM2>;
10595f757f3fSDimitry Andric    defm VL4R : VWholeLoadN<eew, 3, "vl4r", VRM4>;
10605f757f3fSDimitry Andric    defm VL8R : VWholeLoadN<eew, 7, "vl8r", VRM8>;
10616e75b2fbSDimitry Andric  }
10625ffd83dbSDimitry Andric
10635f757f3fSDimitry Andric  let Predicates = !if(!eq(eew, 64), [IsRV64, HasVInstructionsI64],
10645f757f3fSDimitry Andric                                     [HasVInstructions]) in
10655f757f3fSDimitry Andric  defm "" : VIndexLoadStore<eew>;
10665f757f3fSDimitry Andric}
106704eeddc0SDimitry Andric
106804eeddc0SDimitry Andriclet Predicates = [HasVInstructions] in {
1069349cc55cSDimitry Andricdef VLM_V : VUnitStrideLoadMask<"vlm.v">,
107006c3fb27SDimitry Andric             Sched<[WriteVLDM_WorstCase, ReadVLDX]>;
1071349cc55cSDimitry Andricdef VSM_V : VUnitStrideStoreMask<"vsm.v">,
107206c3fb27SDimitry Andric             Sched<[WriteVSTM_WorstCase, ReadVSTM_WorstCase, ReadVSTX]>;
1073349cc55cSDimitry Andricdef : InstAlias<"vle1.v $vd, (${rs1})",
1074349cc55cSDimitry Andric                (VLM_V VR:$vd, GPR:$rs1), 0>;
1075349cc55cSDimitry Andricdef : InstAlias<"vse1.v $vs3, (${rs1})",
1076349cc55cSDimitry Andric                (VSM_V VR:$vs3, GPR:$rs1), 0>;
1077349cc55cSDimitry Andric
10786e75b2fbSDimitry Andricdef VS1R_V : VWholeStore<0, "vs1r.v", VR>,
107906c3fb27SDimitry Andric             Sched<[WriteVST1R, ReadVST1R, ReadVSTX]>;
10806e75b2fbSDimitry Andricdef VS2R_V : VWholeStore<1, "vs2r.v", VRM2>,
108106c3fb27SDimitry Andric             Sched<[WriteVST2R, ReadVST2R, ReadVSTX]>;
10826e75b2fbSDimitry Andricdef VS4R_V : VWholeStore<3, "vs4r.v", VRM4>,
108306c3fb27SDimitry Andric             Sched<[WriteVST4R, ReadVST4R, ReadVSTX]>;
10846e75b2fbSDimitry Andricdef VS8R_V : VWholeStore<7, "vs8r.v", VRM8>,
108506c3fb27SDimitry Andric             Sched<[WriteVST8R, ReadVST8R, ReadVSTX]>;
10865ffd83dbSDimitry Andric
108704eeddc0SDimitry Andricdef : InstAlias<"vl1r.v $vd, (${rs1})", (VL1RE8_V VR:$vd, GPR:$rs1)>;
108804eeddc0SDimitry Andricdef : InstAlias<"vl2r.v $vd, (${rs1})", (VL2RE8_V VRM2:$vd, GPR:$rs1)>;
108904eeddc0SDimitry Andricdef : InstAlias<"vl4r.v $vd, (${rs1})", (VL4RE8_V VRM4:$vd, GPR:$rs1)>;
109004eeddc0SDimitry Andricdef : InstAlias<"vl8r.v $vd, (${rs1})", (VL8RE8_V VRM8:$vd, GPR:$rs1)>;
109104eeddc0SDimitry Andric} // Predicates = [HasVInstructions]
109204eeddc0SDimitry Andric
109304eeddc0SDimitry Andriclet Predicates = [HasVInstructions] in {
10945ffd83dbSDimitry Andric// Vector Single-Width Integer Add and Subtract
10955ffd83dbSDimitry Andricdefm VADD_V : VALU_IV_V_X_I<"vadd", 0b000000>;
10965ffd83dbSDimitry Andricdefm VSUB_V : VALU_IV_V_X<"vsub", 0b000010>;
10975ffd83dbSDimitry Andricdefm VRSUB_V : VALU_IV_X_I<"vrsub", 0b000011>;
10985ffd83dbSDimitry Andric
1099e8d8bef9SDimitry Andricdef : InstAlias<"vneg.v $vd, $vs$vm", (VRSUB_VX VR:$vd, VR:$vs, X0, VMaskOp:$vm)>;
110081ad6265SDimitry Andricdef : InstAlias<"vneg.v $vd, $vs", (VRSUB_VX VR:$vd, VR:$vs, X0, zero_reg)>;
1101e8d8bef9SDimitry Andric
11025ffd83dbSDimitry Andric// Vector Widening Integer Add/Subtract
11035ffd83dbSDimitry Andric// Refer to 11.2 Widening Vector Arithmetic Instructions
11045ffd83dbSDimitry Andric// The destination vector register group cannot overlap a source vector
11055ffd83dbSDimitry Andric// register group of a different element width (including the mask register
11065ffd83dbSDimitry Andric// if masked), otherwise an illegal instruction exception is raised.
11075ffd83dbSDimitry Andriclet Constraints = "@earlyclobber $vd" in {
11085ffd83dbSDimitry Andriclet RVVConstraint = WidenV in {
110906c3fb27SDimitry Andricdefm VWADDU_V : VALU_MV_V_X<"vwaddu", 0b110000, "v">;
111006c3fb27SDimitry Andricdefm VWSUBU_V : VALU_MV_V_X<"vwsubu", 0b110010, "v">;
111106c3fb27SDimitry Andricdefm VWADD_V : VALU_MV_V_X<"vwadd", 0b110001, "v">;
111206c3fb27SDimitry Andricdefm VWSUB_V : VALU_MV_V_X<"vwsub", 0b110011, "v">;
11135ffd83dbSDimitry Andric} // RVVConstraint = WidenV
11145ffd83dbSDimitry Andric// Set earlyclobber for following instructions for second and mask operands.
11155ffd83dbSDimitry Andric// This has the downside that the earlyclobber constraint is too coarse and
11165ffd83dbSDimitry Andric// will impose unnecessary restrictions by not allowing the destination to
11175ffd83dbSDimitry Andric// overlap with the first (wide) operand.
11185ffd83dbSDimitry Andriclet RVVConstraint = WidenW in {
11195ffd83dbSDimitry Andricdefm VWADDU_W : VALU_MV_V_X<"vwaddu", 0b110100, "w">;
11205ffd83dbSDimitry Andricdefm VWSUBU_W : VALU_MV_V_X<"vwsubu", 0b110110, "w">;
11215ffd83dbSDimitry Andricdefm VWADD_W : VALU_MV_V_X<"vwadd", 0b110101, "w">;
11225ffd83dbSDimitry Andricdefm VWSUB_W : VALU_MV_V_X<"vwsub", 0b110111, "w">;
11235ffd83dbSDimitry Andric} // RVVConstraint = WidenW
11245ffd83dbSDimitry Andric} // Constraints = "@earlyclobber $vd"
11255ffd83dbSDimitry Andric
11265ffd83dbSDimitry Andricdef : InstAlias<"vwcvt.x.x.v $vd, $vs$vm",
1127e8d8bef9SDimitry Andric                (VWADD_VX VR:$vd, VR:$vs, X0, VMaskOp:$vm)>;
112881ad6265SDimitry Andricdef : InstAlias<"vwcvt.x.x.v $vd, $vs",
112981ad6265SDimitry Andric                (VWADD_VX VR:$vd, VR:$vs, X0, zero_reg)>;
11305ffd83dbSDimitry Andricdef : InstAlias<"vwcvtu.x.x.v $vd, $vs$vm",
1131e8d8bef9SDimitry Andric                (VWADDU_VX VR:$vd, VR:$vs, X0, VMaskOp:$vm)>;
113281ad6265SDimitry Andricdef : InstAlias<"vwcvtu.x.x.v $vd, $vs",
113381ad6265SDimitry Andric                (VWADDU_VX VR:$vd, VR:$vs, X0, zero_reg)>;
1134e8d8bef9SDimitry Andric
1135e8d8bef9SDimitry Andric// Vector Integer Extension
1136e8d8bef9SDimitry Andricdefm VZEXT_VF8 : VALU_MV_VS2<"vzext.vf8", 0b010010, 0b00010>;
1137e8d8bef9SDimitry Andricdefm VSEXT_VF8 : VALU_MV_VS2<"vsext.vf8", 0b010010, 0b00011>;
1138e8d8bef9SDimitry Andricdefm VZEXT_VF4 : VALU_MV_VS2<"vzext.vf4", 0b010010, 0b00100>;
1139e8d8bef9SDimitry Andricdefm VSEXT_VF4 : VALU_MV_VS2<"vsext.vf4", 0b010010, 0b00101>;
1140e8d8bef9SDimitry Andricdefm VZEXT_VF2 : VALU_MV_VS2<"vzext.vf2", 0b010010, 0b00110>;
1141e8d8bef9SDimitry Andricdefm VSEXT_VF2 : VALU_MV_VS2<"vsext.vf2", 0b010010, 0b00111>;
11425ffd83dbSDimitry Andric
11435ffd83dbSDimitry Andric// Vector Integer Add-with-Carry / Subtract-with-Borrow Instructions
11445ffd83dbSDimitry Andricdefm VADC_V : VALUm_IV_V_X_I<"vadc", 0b010000>;
1145e8d8bef9SDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = NoConstraint in {
11465ffd83dbSDimitry Andricdefm VMADC_V : VALUm_IV_V_X_I<"vmadc", 0b010001>;
11475ffd83dbSDimitry Andricdefm VMADC_V : VALUNoVm_IV_V_X_I<"vmadc", 0b010001>;
1148e8d8bef9SDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = NoConstraint
11495ffd83dbSDimitry Andricdefm VSBC_V : VALUm_IV_V_X<"vsbc", 0b010010>;
1150e8d8bef9SDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = NoConstraint in {
11515ffd83dbSDimitry Andricdefm VMSBC_V : VALUm_IV_V_X<"vmsbc", 0b010011>;
11525ffd83dbSDimitry Andricdefm VMSBC_V : VALUNoVm_IV_V_X<"vmsbc", 0b010011>;
1153e8d8bef9SDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = NoConstraint
11545ffd83dbSDimitry Andric
11555ffd83dbSDimitry Andric// Vector Bitwise Logical Instructions
11565ffd83dbSDimitry Andricdefm VAND_V : VALU_IV_V_X_I<"vand", 0b001001>;
11575ffd83dbSDimitry Andricdefm VOR_V : VALU_IV_V_X_I<"vor", 0b001010>;
11585ffd83dbSDimitry Andricdefm VXOR_V : VALU_IV_V_X_I<"vxor", 0b001011>;
11595ffd83dbSDimitry Andric
11605ffd83dbSDimitry Andricdef : InstAlias<"vnot.v $vd, $vs$vm",
1161e8d8bef9SDimitry Andric                (VXOR_VI VR:$vd, VR:$vs, -1, VMaskOp:$vm)>;
116281ad6265SDimitry Andricdef : InstAlias<"vnot.v $vd, $vs",
116381ad6265SDimitry Andric                (VXOR_VI VR:$vd, VR:$vs, -1, zero_reg)>;
11645ffd83dbSDimitry Andric
11655ffd83dbSDimitry Andric// Vector Single-Width Bit Shift Instructions
116606c3fb27SDimitry Andricdefm VSLL_V : VSHT_IV_V_X_I<"vsll", 0b100101>;
116706c3fb27SDimitry Andricdefm VSRL_V : VSHT_IV_V_X_I<"vsrl", 0b101000>;
116806c3fb27SDimitry Andricdefm VSRA_V : VSHT_IV_V_X_I<"vsra", 0b101001>;
11695ffd83dbSDimitry Andric
11705ffd83dbSDimitry Andric// Vector Narrowing Integer Right Shift Instructions
11715ffd83dbSDimitry Andric// Refer to 11.3. Narrowing Vector Arithmetic Instructions
11725ffd83dbSDimitry Andric// The destination vector register group cannot overlap the first source
11735ffd83dbSDimitry Andric// vector register group (specified by vs2). The destination vector register
11745ffd83dbSDimitry Andric// group cannot overlap the mask register if used, unless LMUL=1.
1175e8d8bef9SDimitry Andriclet Constraints = "@earlyclobber $vd" in {
117606c3fb27SDimitry Andricdefm VNSRL_W : VNSHT_IV_V_X_I<"vnsrl", 0b101100>;
117706c3fb27SDimitry Andricdefm VNSRA_W : VNSHT_IV_V_X_I<"vnsra", 0b101101>;
1178e8d8bef9SDimitry Andric} // Constraints = "@earlyclobber $vd"
1179e8d8bef9SDimitry Andric
1180e8d8bef9SDimitry Andricdef : InstAlias<"vncvt.x.x.w $vd, $vs$vm",
1181e8d8bef9SDimitry Andric                (VNSRL_WX VR:$vd, VR:$vs, X0, VMaskOp:$vm)>;
118281ad6265SDimitry Andricdef : InstAlias<"vncvt.x.x.w $vd, $vs",
118381ad6265SDimitry Andric                (VNSRL_WX VR:$vd, VR:$vs, X0, zero_reg)>;
11845ffd83dbSDimitry Andric
11855ffd83dbSDimitry Andric// Vector Integer Comparison Instructions
1186e8d8bef9SDimitry Andriclet RVVConstraint = NoConstraint in {
11876e75b2fbSDimitry Andricdefm VMSEQ_V : VCMP_IV_V_X_I<"vmseq", 0b011000>;
11886e75b2fbSDimitry Andricdefm VMSNE_V : VCMP_IV_V_X_I<"vmsne", 0b011001>;
11896e75b2fbSDimitry Andricdefm VMSLTU_V : VCMP_IV_V_X<"vmsltu", 0b011010>;
11906e75b2fbSDimitry Andricdefm VMSLT_V : VCMP_IV_V_X<"vmslt", 0b011011>;
11916e75b2fbSDimitry Andricdefm VMSLEU_V : VCMP_IV_V_X_I<"vmsleu", 0b011100>;
11926e75b2fbSDimitry Andricdefm VMSLE_V : VCMP_IV_V_X_I<"vmsle", 0b011101>;
11936e75b2fbSDimitry Andricdefm VMSGTU_V : VCMP_IV_X_I<"vmsgtu", 0b011110>;
11946e75b2fbSDimitry Andricdefm VMSGT_V : VCMP_IV_X_I<"vmsgt", 0b011111>;
1195e8d8bef9SDimitry Andric} // RVVConstraint = NoConstraint
11965ffd83dbSDimitry Andric
11975ffd83dbSDimitry Andricdef : InstAlias<"vmsgtu.vv $vd, $va, $vb$vm",
1198e8d8bef9SDimitry Andric                (VMSLTU_VV VR:$vd, VR:$vb, VR:$va, VMaskOp:$vm), 0>;
11995ffd83dbSDimitry Andricdef : InstAlias<"vmsgt.vv $vd, $va, $vb$vm",
1200e8d8bef9SDimitry Andric                (VMSLT_VV VR:$vd, VR:$vb, VR:$va, VMaskOp:$vm), 0>;
12015ffd83dbSDimitry Andricdef : InstAlias<"vmsgeu.vv $vd, $va, $vb$vm",
1202e8d8bef9SDimitry Andric                (VMSLEU_VV VR:$vd, VR:$vb, VR:$va, VMaskOp:$vm), 0>;
12035ffd83dbSDimitry Andricdef : InstAlias<"vmsge.vv $vd, $va, $vb$vm",
1204e8d8bef9SDimitry Andric                (VMSLE_VV VR:$vd, VR:$vb, VR:$va, VMaskOp:$vm), 0>;
1205e8d8bef9SDimitry Andric
1206e8d8bef9SDimitry Andriclet isCodeGenOnly = 0, isAsmParserOnly = 1, hasSideEffects = 0, mayLoad = 0,
1207e8d8bef9SDimitry Andric    mayStore = 0 in {
1208e8d8bef9SDimitry Andric// For unsigned comparisons we need to special case 0 immediate to maintain
1209e8d8bef9SDimitry Andric// the always true/false semantics we would invert if we just decremented the
1210e8d8bef9SDimitry Andric// immediate like we do for signed. To match the GNU assembler we will use
1211e8d8bef9SDimitry Andric// vmseq/vmsne.vv with the same register for both operands which we can't do
1212e8d8bef9SDimitry Andric// from an InstAlias.
1213e8d8bef9SDimitry Andricdef PseudoVMSGEU_VI : Pseudo<(outs VR:$vd),
1214e8d8bef9SDimitry Andric                             (ins VR:$vs2, simm5_plus1:$imm, VMaskOp:$vm),
1215e8d8bef9SDimitry Andric                             [], "vmsgeu.vi", "$vd, $vs2, $imm$vm">;
1216e8d8bef9SDimitry Andricdef PseudoVMSLTU_VI : Pseudo<(outs VR:$vd),
1217e8d8bef9SDimitry Andric                             (ins VR:$vs2, simm5_plus1:$imm, VMaskOp:$vm),
1218e8d8bef9SDimitry Andric                             [], "vmsltu.vi", "$vd, $vs2, $imm$vm">;
1219e8d8bef9SDimitry Andric// Handle signed with pseudos as well for more consistency in the
1220e8d8bef9SDimitry Andric// implementation.
1221e8d8bef9SDimitry Andricdef PseudoVMSGE_VI : Pseudo<(outs VR:$vd),
1222e8d8bef9SDimitry Andric                            (ins VR:$vs2, simm5_plus1:$imm, VMaskOp:$vm),
1223e8d8bef9SDimitry Andric                            [], "vmsge.vi", "$vd, $vs2, $imm$vm">;
1224e8d8bef9SDimitry Andricdef PseudoVMSLT_VI : Pseudo<(outs VR:$vd),
1225e8d8bef9SDimitry Andric                            (ins VR:$vs2, simm5_plus1:$imm, VMaskOp:$vm),
1226e8d8bef9SDimitry Andric                            [], "vmslt.vi", "$vd, $vs2, $imm$vm">;
1227e8d8bef9SDimitry Andric}
1228e8d8bef9SDimitry Andric
1229e8d8bef9SDimitry Andriclet isCodeGenOnly = 0, isAsmParserOnly = 1, hasSideEffects = 0, mayLoad = 0,
1230e8d8bef9SDimitry Andric    mayStore = 0 in {
1231e8d8bef9SDimitry Andricdef PseudoVMSGEU_VX : Pseudo<(outs VR:$vd),
1232e8d8bef9SDimitry Andric                             (ins VR:$vs2, GPR:$rs1),
1233e8d8bef9SDimitry Andric                             [], "vmsgeu.vx", "$vd, $vs2, $rs1">;
1234e8d8bef9SDimitry Andricdef PseudoVMSGE_VX : Pseudo<(outs VR:$vd),
1235e8d8bef9SDimitry Andric                            (ins VR:$vs2, GPR:$rs1),
1236e8d8bef9SDimitry Andric                            [], "vmsge.vx", "$vd, $vs2, $rs1">;
1237e8d8bef9SDimitry Andricdef PseudoVMSGEU_VX_M : Pseudo<(outs VRNoV0:$vd),
1238e8d8bef9SDimitry Andric                               (ins VR:$vs2, GPR:$rs1, VMaskOp:$vm),
1239e8d8bef9SDimitry Andric                               [], "vmsgeu.vx", "$vd, $vs2, $rs1$vm">;
1240e8d8bef9SDimitry Andricdef PseudoVMSGE_VX_M : Pseudo<(outs VRNoV0:$vd),
1241e8d8bef9SDimitry Andric                              (ins VR:$vs2, GPR:$rs1, VMaskOp:$vm),
1242e8d8bef9SDimitry Andric                              [], "vmsge.vx", "$vd, $vs2, $rs1$vm">;
1243fe6060f1SDimitry Andricdef PseudoVMSGEU_VX_M_T : Pseudo<(outs VR:$vd, VRNoV0:$scratch),
1244e8d8bef9SDimitry Andric                                 (ins VR:$vs2, GPR:$rs1, VMaskOp:$vm),
1245e8d8bef9SDimitry Andric                                 [], "vmsgeu.vx", "$vd, $vs2, $rs1$vm, $scratch">;
1246fe6060f1SDimitry Andricdef PseudoVMSGE_VX_M_T : Pseudo<(outs VR:$vd, VRNoV0:$scratch),
1247e8d8bef9SDimitry Andric                                (ins VR:$vs2, GPR:$rs1, VMaskOp:$vm),
1248e8d8bef9SDimitry Andric                                [], "vmsge.vx", "$vd, $vs2, $rs1$vm, $scratch">;
1249e8d8bef9SDimitry Andric}
12505ffd83dbSDimitry Andric
12515ffd83dbSDimitry Andric// Vector Integer Min/Max Instructions
125206c3fb27SDimitry Andricdefm VMINU_V : VMINMAX_IV_V_X<"vminu", 0b000100>;
125306c3fb27SDimitry Andricdefm VMIN_V : VMINMAX_IV_V_X<"vmin", 0b000101>;
125406c3fb27SDimitry Andricdefm VMAXU_V : VMINMAX_IV_V_X<"vmaxu", 0b000110>;
125506c3fb27SDimitry Andricdefm VMAX_V : VMINMAX_IV_V_X<"vmax", 0b000111>;
12565ffd83dbSDimitry Andric
12575ffd83dbSDimitry Andric// Vector Single-Width Integer Multiply Instructions
12586e75b2fbSDimitry Andricdefm VMUL_V : VMUL_MV_V_X<"vmul", 0b100101>;
12596e75b2fbSDimitry Andricdefm VMULH_V : VMUL_MV_V_X<"vmulh", 0b100111>;
12606e75b2fbSDimitry Andricdefm VMULHU_V : VMUL_MV_V_X<"vmulhu", 0b100100>;
12616e75b2fbSDimitry Andricdefm VMULHSU_V : VMUL_MV_V_X<"vmulhsu", 0b100110>;
12625ffd83dbSDimitry Andric
12635ffd83dbSDimitry Andric// Vector Integer Divide Instructions
12646e75b2fbSDimitry Andricdefm VDIVU_V : VDIV_MV_V_X<"vdivu", 0b100000>;
12656e75b2fbSDimitry Andricdefm VDIV_V : VDIV_MV_V_X<"vdiv", 0b100001>;
12666e75b2fbSDimitry Andricdefm VREMU_V : VDIV_MV_V_X<"vremu", 0b100010>;
12676e75b2fbSDimitry Andricdefm VREM_V : VDIV_MV_V_X<"vrem", 0b100011>;
12685ffd83dbSDimitry Andric
12695ffd83dbSDimitry Andric// Vector Widening Integer Multiply Instructions
12705ffd83dbSDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = WidenV in {
12716e75b2fbSDimitry Andricdefm VWMUL_V : VWMUL_MV_V_X<"vwmul", 0b111011>;
12726e75b2fbSDimitry Andricdefm VWMULU_V : VWMUL_MV_V_X<"vwmulu", 0b111000>;
12736e75b2fbSDimitry Andricdefm VWMULSU_V : VWMUL_MV_V_X<"vwmulsu", 0b111010>;
12745ffd83dbSDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = WidenV
12755ffd83dbSDimitry Andric
12765ffd83dbSDimitry Andric// Vector Single-Width Integer Multiply-Add Instructions
12776e75b2fbSDimitry Andricdefm VMACC_V : VMAC_MV_V_X<"vmacc", 0b101101>;
12786e75b2fbSDimitry Andricdefm VNMSAC_V : VMAC_MV_V_X<"vnmsac", 0b101111>;
12796e75b2fbSDimitry Andricdefm VMADD_V : VMAC_MV_V_X<"vmadd", 0b101001>;
12806e75b2fbSDimitry Andricdefm VNMSUB_V : VMAC_MV_V_X<"vnmsub", 0b101011>;
12815ffd83dbSDimitry Andric
12825ffd83dbSDimitry Andric// Vector Widening Integer Multiply-Add Instructions
12836e75b2fbSDimitry Andricdefm VWMACCU_V : VWMAC_MV_V_X<"vwmaccu", 0b111100>;
12846e75b2fbSDimitry Andricdefm VWMACC_V : VWMAC_MV_V_X<"vwmacc", 0b111101>;
12856e75b2fbSDimitry Andricdefm VWMACCSU_V : VWMAC_MV_V_X<"vwmaccsu", 0b111111>;
12866e75b2fbSDimitry Andricdefm VWMACCUS_V : VWMAC_MV_X<"vwmaccus", 0b111110>;
12875ffd83dbSDimitry Andric
12885ffd83dbSDimitry Andric// Vector Integer Merge Instructions
12896e75b2fbSDimitry Andricdefm VMERGE_V : VMRG_IV_V_X_I<"vmerge", 0b010111>;
12905ffd83dbSDimitry Andric
12915ffd83dbSDimitry Andric// Vector Integer Move Instructions
1292e8d8bef9SDimitry Andriclet hasSideEffects = 0, mayLoad = 0, mayStore = 0, vs2 = 0, vm = 1,
1293e8d8bef9SDimitry Andric    RVVConstraint = NoConstraint  in {
12945ffd83dbSDimitry Andric// op vd, vs1
1295e8d8bef9SDimitry Andricdef VMV_V_V : RVInstVV<0b010111, OPIVV, (outs VR:$vd),
12966e75b2fbSDimitry Andric                       (ins VR:$vs1), "vmv.v.v", "$vd, $vs1">,
12975f757f3fSDimitry Andric              SchedUnaryMC<"WriteVIMovV", "ReadVIMovV", forceMasked=0>;
12985ffd83dbSDimitry Andric// op vd, rs1
1299e8d8bef9SDimitry Andricdef VMV_V_X : RVInstVX<0b010111, OPIVX, (outs VR:$vd),
13006e75b2fbSDimitry Andric                       (ins GPR:$rs1), "vmv.v.x", "$vd, $rs1">,
13015f757f3fSDimitry Andric              SchedUnaryMC<"WriteVIMovX", "ReadVIMovX", forceMasked=0>;
13025ffd83dbSDimitry Andric// op vd, imm
1303e8d8bef9SDimitry Andricdef VMV_V_I : RVInstIVI<0b010111, (outs VR:$vd),
13046e75b2fbSDimitry Andric                       (ins simm5:$imm), "vmv.v.i", "$vd, $imm">,
13055f757f3fSDimitry Andric              SchedNullaryMC<"WriteVIMovI", forceMasked=0>;
13065ffd83dbSDimitry Andric} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
13075ffd83dbSDimitry Andric
13085ffd83dbSDimitry Andric// Vector Fixed-Point Arithmetic Instructions
13096e75b2fbSDimitry Andricdefm VSADDU_V : VSALU_IV_V_X_I<"vsaddu", 0b100000>;
13106e75b2fbSDimitry Andricdefm VSADD_V : VSALU_IV_V_X_I<"vsadd", 0b100001>;
13116e75b2fbSDimitry Andricdefm VSSUBU_V : VSALU_IV_V_X<"vssubu", 0b100010>;
13126e75b2fbSDimitry Andricdefm VSSUB_V : VSALU_IV_V_X<"vssub", 0b100011>;
13135ffd83dbSDimitry Andric
13145ffd83dbSDimitry Andric// Vector Single-Width Averaging Add and Subtract
13156e75b2fbSDimitry Andricdefm VAADDU_V : VAALU_MV_V_X<"vaaddu", 0b001000>;
13166e75b2fbSDimitry Andricdefm VAADD_V : VAALU_MV_V_X<"vaadd", 0b001001>;
13176e75b2fbSDimitry Andricdefm VASUBU_V : VAALU_MV_V_X<"vasubu", 0b001010>;
13186e75b2fbSDimitry Andricdefm VASUB_V : VAALU_MV_V_X<"vasub", 0b001011>;
13195ffd83dbSDimitry Andric
13205ffd83dbSDimitry Andric// Vector Single-Width Fractional Multiply with Rounding and Saturation
13216e75b2fbSDimitry Andricdefm VSMUL_V : VSMUL_IV_V_X<"vsmul", 0b100111>;
13225ffd83dbSDimitry Andric
13235ffd83dbSDimitry Andric// Vector Single-Width Scaling Shift Instructions
132406c3fb27SDimitry Andricdefm VSSRL_V : VSSHF_IV_V_X_I<"vssrl", 0b101010>;
132506c3fb27SDimitry Andricdefm VSSRA_V : VSSHF_IV_V_X_I<"vssra", 0b101011>;
13265ffd83dbSDimitry Andric
13275ffd83dbSDimitry Andric// Vector Narrowing Fixed-Point Clip Instructions
1328e8d8bef9SDimitry Andriclet Constraints = "@earlyclobber $vd" in {
132906c3fb27SDimitry Andricdefm VNCLIPU_W : VNCLP_IV_V_X_I<"vnclipu", 0b101110>;
133006c3fb27SDimitry Andricdefm VNCLIP_W : VNCLP_IV_V_X_I<"vnclip", 0b101111>;
1331e8d8bef9SDimitry Andric} // Constraints = "@earlyclobber $vd"
133204eeddc0SDimitry Andric} // Predicates = [HasVInstructions]
13335ffd83dbSDimitry Andric
133404eeddc0SDimitry Andriclet Predicates = [HasVInstructionsAnyF] in {
13355ffd83dbSDimitry Andric// Vector Single-Width Floating-Point Add/Subtract Instructions
133681ad6265SDimitry Andriclet Uses = [FRM], mayRaiseFPException = true in {
13375ffd83dbSDimitry Andricdefm VFADD_V : VALU_FV_V_F<"vfadd", 0b000000>;
13385ffd83dbSDimitry Andricdefm VFSUB_V : VALU_FV_V_F<"vfsub", 0b000010>;
13395ffd83dbSDimitry Andricdefm VFRSUB_V : VALU_FV_F<"vfrsub", 0b100111>;
134081ad6265SDimitry Andric}
13415ffd83dbSDimitry Andric
13425ffd83dbSDimitry Andric// Vector Widening Floating-Point Add/Subtract Instructions
134381ad6265SDimitry Andriclet Constraints = "@earlyclobber $vd",
134481ad6265SDimitry Andric    Uses = [FRM],
134581ad6265SDimitry Andric    mayRaiseFPException = true in {
13465ffd83dbSDimitry Andriclet RVVConstraint = WidenV in {
134706c3fb27SDimitry Andricdefm VFWADD_V : VWALU_FV_V_F<"vfwadd", 0b110000, "v">;
134806c3fb27SDimitry Andricdefm VFWSUB_V : VWALU_FV_V_F<"vfwsub", 0b110010, "v">;
13495ffd83dbSDimitry Andric} // RVVConstraint = WidenV
13505ffd83dbSDimitry Andric// Set earlyclobber for following instructions for second and mask operands.
13515ffd83dbSDimitry Andric// This has the downside that the earlyclobber constraint is too coarse and
13525ffd83dbSDimitry Andric// will impose unnecessary restrictions by not allowing the destination to
13535ffd83dbSDimitry Andric// overlap with the first (wide) operand.
13545ffd83dbSDimitry Andriclet RVVConstraint = WidenW in {
13556e75b2fbSDimitry Andricdefm VFWADD_W : VWALU_FV_V_F<"vfwadd", 0b110100, "w">;
13566e75b2fbSDimitry Andricdefm VFWSUB_W : VWALU_FV_V_F<"vfwsub", 0b110110, "w">;
13575ffd83dbSDimitry Andric} // RVVConstraint = WidenW
135881ad6265SDimitry Andric} // Constraints = "@earlyclobber $vd", Uses = [FRM], mayRaiseFPException = true
13595ffd83dbSDimitry Andric
13605ffd83dbSDimitry Andric// Vector Single-Width Floating-Point Multiply/Divide Instructions
136181ad6265SDimitry Andriclet Uses = [FRM], mayRaiseFPException = true in {
13626e75b2fbSDimitry Andricdefm VFMUL_V : VMUL_FV_V_F<"vfmul", 0b100100>;
13636e75b2fbSDimitry Andricdefm VFDIV_V : VDIV_FV_V_F<"vfdiv", 0b100000>;
136406c3fb27SDimitry Andricdefm VFRDIV_V : VDIV_FV_F<"vfrdiv", 0b100001>;
136581ad6265SDimitry Andric}
13665ffd83dbSDimitry Andric
13675ffd83dbSDimitry Andric// Vector Widening Floating-Point Multiply
136881ad6265SDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = WidenV,
136981ad6265SDimitry Andric    Uses = [FRM], mayRaiseFPException = true in {
13706e75b2fbSDimitry Andricdefm VFWMUL_V : VWMUL_FV_V_F<"vfwmul", 0b111000>;
137181ad6265SDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = WidenV, Uses = [FRM], mayRaiseFPException = true
13725ffd83dbSDimitry Andric
13735ffd83dbSDimitry Andric// Vector Single-Width Floating-Point Fused Multiply-Add Instructions
137481ad6265SDimitry Andriclet Uses = [FRM], mayRaiseFPException = true in {
13756e75b2fbSDimitry Andricdefm VFMACC_V : VMAC_FV_V_F<"vfmacc", 0b101100>;
13766e75b2fbSDimitry Andricdefm VFNMACC_V : VMAC_FV_V_F<"vfnmacc", 0b101101>;
13776e75b2fbSDimitry Andricdefm VFMSAC_V : VMAC_FV_V_F<"vfmsac", 0b101110>;
13786e75b2fbSDimitry Andricdefm VFNMSAC_V : VMAC_FV_V_F<"vfnmsac", 0b101111>;
13796e75b2fbSDimitry Andricdefm VFMADD_V : VMAC_FV_V_F<"vfmadd", 0b101000>;
13806e75b2fbSDimitry Andricdefm VFNMADD_V : VMAC_FV_V_F<"vfnmadd", 0b101001>;
13816e75b2fbSDimitry Andricdefm VFMSUB_V : VMAC_FV_V_F<"vfmsub", 0b101010>;
13826e75b2fbSDimitry Andricdefm VFNMSUB_V : VMAC_FV_V_F<"vfnmsub", 0b101011>;
138381ad6265SDimitry Andric}
13845ffd83dbSDimitry Andric
13855ffd83dbSDimitry Andric// Vector Widening Floating-Point Fused Multiply-Add Instructions
13865f757f3fSDimitry Andriclet Uses = [FRM], mayRaiseFPException = true in {
13876e75b2fbSDimitry Andricdefm VFWMACC_V : VWMAC_FV_V_F<"vfwmacc", 0b111100>;
13886e75b2fbSDimitry Andricdefm VFWNMACC_V : VWMAC_FV_V_F<"vfwnmacc", 0b111101>;
13896e75b2fbSDimitry Andricdefm VFWMSAC_V : VWMAC_FV_V_F<"vfwmsac", 0b111110>;
13906e75b2fbSDimitry Andricdefm VFWNMSAC_V : VWMAC_FV_V_F<"vfwnmsac", 0b111111>;
139181ad6265SDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = WidenV, Uses = [FRM], mayRaiseFPException = true
13925ffd83dbSDimitry Andric
13935ffd83dbSDimitry Andric// Vector Floating-Point Square-Root Instruction
139481ad6265SDimitry Andriclet Uses = [FRM], mayRaiseFPException = true in {
13956e75b2fbSDimitry Andricdefm VFSQRT_V : VSQR_FV_VS2<"vfsqrt.v", 0b010011, 0b00000>;
13966e75b2fbSDimitry Andricdefm VFREC7_V : VRCP_FV_VS2<"vfrec7.v", 0b010011, 0b00101>;
139781ad6265SDimitry Andric}
139881ad6265SDimitry Andric
139981ad6265SDimitry Andriclet mayRaiseFPException = true in
140081ad6265SDimitry Andricdefm VFRSQRT7_V : VRCP_FV_VS2<"vfrsqrt7.v", 0b010011, 0b00100>;
14015ffd83dbSDimitry Andric
14025ffd83dbSDimitry Andric// Vector Floating-Point MIN/MAX Instructions
140381ad6265SDimitry Andriclet mayRaiseFPException = true in {
140406c3fb27SDimitry Andricdefm VFMIN_V : VMINMAX_FV_V_F<"vfmin", 0b000100>;
140506c3fb27SDimitry Andricdefm VFMAX_V : VMINMAX_FV_V_F<"vfmax", 0b000110>;
140681ad6265SDimitry Andric}
14075ffd83dbSDimitry Andric
14085ffd83dbSDimitry Andric// Vector Floating-Point Sign-Injection Instructions
14096e75b2fbSDimitry Andricdefm VFSGNJ_V : VSGNJ_FV_V_F<"vfsgnj", 0b001000>;
14106e75b2fbSDimitry Andricdefm VFSGNJN_V : VSGNJ_FV_V_F<"vfsgnjn", 0b001001>;
14116e75b2fbSDimitry Andricdefm VFSGNJX_V : VSGNJ_FV_V_F<"vfsgnjx", 0b001010>;
14125ffd83dbSDimitry Andric
1413e8d8bef9SDimitry Andricdef : InstAlias<"vfneg.v $vd, $vs$vm",
1414e8d8bef9SDimitry Andric                (VFSGNJN_VV VR:$vd, VR:$vs, VR:$vs, VMaskOp:$vm)>;
141581ad6265SDimitry Andricdef : InstAlias<"vfneg.v $vd, $vs",
141681ad6265SDimitry Andric                (VFSGNJN_VV VR:$vd, VR:$vs, VR:$vs, zero_reg)>;
1417fe6060f1SDimitry Andricdef : InstAlias<"vfabs.v $vd, $vs$vm",
1418fe6060f1SDimitry Andric                (VFSGNJX_VV VR:$vd, VR:$vs, VR:$vs, VMaskOp:$vm)>;
141981ad6265SDimitry Andricdef : InstAlias<"vfabs.v $vd, $vs",
142081ad6265SDimitry Andric                (VFSGNJX_VV VR:$vd, VR:$vs, VR:$vs, zero_reg)>;
1421e8d8bef9SDimitry Andric
14225ffd83dbSDimitry Andric// Vector Floating-Point Compare Instructions
142381ad6265SDimitry Andriclet RVVConstraint = NoConstraint, mayRaiseFPException = true in {
14246e75b2fbSDimitry Andricdefm VMFEQ_V : VCMP_FV_V_F<"vmfeq", 0b011000>;
14256e75b2fbSDimitry Andricdefm VMFNE_V : VCMP_FV_V_F<"vmfne", 0b011100>;
14266e75b2fbSDimitry Andricdefm VMFLT_V : VCMP_FV_V_F<"vmflt", 0b011011>;
14276e75b2fbSDimitry Andricdefm VMFLE_V : VCMP_FV_V_F<"vmfle", 0b011001>;
14286e75b2fbSDimitry Andricdefm VMFGT_V : VCMP_FV_F<"vmfgt", 0b011101>;
14296e75b2fbSDimitry Andricdefm VMFGE_V : VCMP_FV_F<"vmfge", 0b011111>;
143081ad6265SDimitry Andric} // RVVConstraint = NoConstraint, mayRaiseFPException = true
14315ffd83dbSDimitry Andric
14325ffd83dbSDimitry Andricdef : InstAlias<"vmfgt.vv $vd, $va, $vb$vm",
1433e8d8bef9SDimitry Andric                (VMFLT_VV VR:$vd, VR:$vb, VR:$va, VMaskOp:$vm), 0>;
14345ffd83dbSDimitry Andricdef : InstAlias<"vmfge.vv $vd, $va, $vb$vm",
1435e8d8bef9SDimitry Andric                (VMFLE_VV VR:$vd, VR:$vb, VR:$va, VMaskOp:$vm), 0>;
14365ffd83dbSDimitry Andric
14375ffd83dbSDimitry Andric// Vector Floating-Point Classify Instruction
14386e75b2fbSDimitry Andricdefm VFCLASS_V : VCLS_FV_VS2<"vfclass.v", 0b010011, 0b10000>;
14395ffd83dbSDimitry Andric
14405ffd83dbSDimitry Andriclet hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
14416e75b2fbSDimitry Andric
14425ffd83dbSDimitry Andric// Vector Floating-Point Merge Instruction
14436e75b2fbSDimitry Andriclet vm = 0 in
1444e8d8bef9SDimitry Andricdef VFMERGE_VFM : RVInstVX<0b010111, OPFVF, (outs VR:$vd),
1445e8d8bef9SDimitry Andric                           (ins VR:$vs2, FPR32:$rs1, VMV0:$v0),
14466e75b2fbSDimitry Andric                           "vfmerge.vfm", "$vd, $vs2, $rs1, v0">,
14475f757f3fSDimitry Andric                  SchedBinaryMC<"WriteVFMergeV", "ReadVFMergeV", "ReadVFMergeF">;
14485ffd83dbSDimitry Andric
14495ffd83dbSDimitry Andric// Vector Floating-Point Move Instruction
1450e8d8bef9SDimitry Andriclet RVVConstraint = NoConstraint in
14516e75b2fbSDimitry Andriclet vm = 1, vs2 = 0 in
1452e8d8bef9SDimitry Andricdef VFMV_V_F : RVInstVX<0b010111, OPFVF, (outs VR:$vd),
14536e75b2fbSDimitry Andric                       (ins FPR32:$rs1), "vfmv.v.f", "$vd, $rs1">,
14545f757f3fSDimitry Andric               SchedUnaryMC<"WriteVFMovV", "ReadVFMovF", forceMasked=0>;
14556e75b2fbSDimitry Andric
14565ffd83dbSDimitry Andric} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
14575ffd83dbSDimitry Andric
14585ffd83dbSDimitry Andric// Single-Width Floating-Point/Integer Type-Convert Instructions
1459bdd1243dSDimitry Andriclet mayRaiseFPException = true in {
1460bdd1243dSDimitry Andriclet Uses = [FRM] in {
14616e75b2fbSDimitry Andricdefm VFCVT_XU_F_V : VCVTI_FV_VS2<"vfcvt.xu.f.v", 0b010010, 0b00000>;
14626e75b2fbSDimitry Andricdefm VFCVT_X_F_V : VCVTI_FV_VS2<"vfcvt.x.f.v", 0b010010, 0b00001>;
1463bdd1243dSDimitry Andric}
14646e75b2fbSDimitry Andricdefm VFCVT_RTZ_XU_F_V : VCVTI_FV_VS2<"vfcvt.rtz.xu.f.v", 0b010010, 0b00110>;
14656e75b2fbSDimitry Andricdefm VFCVT_RTZ_X_F_V : VCVTI_FV_VS2<"vfcvt.rtz.x.f.v", 0b010010, 0b00111>;
1466bdd1243dSDimitry Andriclet Uses = [FRM] in {
14676e75b2fbSDimitry Andricdefm VFCVT_F_XU_V : VCVTF_IV_VS2<"vfcvt.f.xu.v", 0b010010, 0b00010>;
14686e75b2fbSDimitry Andricdefm VFCVT_F_X_V : VCVTF_IV_VS2<"vfcvt.f.x.v", 0b010010, 0b00011>;
1469bdd1243dSDimitry Andric}
1470bdd1243dSDimitry Andric} // mayRaiseFPException = true
14715ffd83dbSDimitry Andric
14725ffd83dbSDimitry Andric// Widening Floating-Point/Integer Type-Convert Instructions
1473bdd1243dSDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = WidenCvt,
1474bdd1243dSDimitry Andric    mayRaiseFPException = true in {
1475bdd1243dSDimitry Andriclet Uses = [FRM] in {
14766e75b2fbSDimitry Andricdefm VFWCVT_XU_F_V : VWCVTI_FV_VS2<"vfwcvt.xu.f.v", 0b010010, 0b01000>;
14776e75b2fbSDimitry Andricdefm VFWCVT_X_F_V : VWCVTI_FV_VS2<"vfwcvt.x.f.v", 0b010010, 0b01001>;
1478bdd1243dSDimitry Andric}
14796e75b2fbSDimitry Andricdefm VFWCVT_RTZ_XU_F_V : VWCVTI_FV_VS2<"vfwcvt.rtz.xu.f.v", 0b010010, 0b01110>;
14806e75b2fbSDimitry Andricdefm VFWCVT_RTZ_X_F_V : VWCVTI_FV_VS2<"vfwcvt.rtz.x.f.v", 0b010010, 0b01111>;
14816e75b2fbSDimitry Andricdefm VFWCVT_F_XU_V : VWCVTF_IV_VS2<"vfwcvt.f.xu.v", 0b010010, 0b01010>;
14826e75b2fbSDimitry Andricdefm VFWCVT_F_X_V : VWCVTF_IV_VS2<"vfwcvt.f.x.v", 0b010010, 0b01011>;
14836e75b2fbSDimitry Andricdefm VFWCVT_F_F_V : VWCVTF_FV_VS2<"vfwcvt.f.f.v", 0b010010, 0b01100>;
14845ffd83dbSDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = WidenCvt
14855ffd83dbSDimitry Andric
14865ffd83dbSDimitry Andric// Narrowing Floating-Point/Integer Type-Convert Instructions
1487bdd1243dSDimitry Andriclet Constraints = "@earlyclobber $vd", mayRaiseFPException = true in {
1488bdd1243dSDimitry Andriclet Uses = [FRM] in {
14896e75b2fbSDimitry Andricdefm VFNCVT_XU_F_W : VNCVTI_FV_VS2<"vfncvt.xu.f.w", 0b010010, 0b10000>;
14906e75b2fbSDimitry Andricdefm VFNCVT_X_F_W : VNCVTI_FV_VS2<"vfncvt.x.f.w", 0b010010, 0b10001>;
1491bdd1243dSDimitry Andric}
14926e75b2fbSDimitry Andricdefm VFNCVT_RTZ_XU_F_W : VNCVTI_FV_VS2<"vfncvt.rtz.xu.f.w", 0b010010, 0b10110>;
14936e75b2fbSDimitry Andricdefm VFNCVT_RTZ_X_F_W : VNCVTI_FV_VS2<"vfncvt.rtz.x.f.w", 0b010010, 0b10111>;
1494bdd1243dSDimitry Andriclet Uses = [FRM] in {
14956e75b2fbSDimitry Andricdefm VFNCVT_F_XU_W : VNCVTF_IV_VS2<"vfncvt.f.xu.w", 0b010010, 0b10010>;
14966e75b2fbSDimitry Andricdefm VFNCVT_F_X_W : VNCVTF_IV_VS2<"vfncvt.f.x.w", 0b010010, 0b10011>;
14976e75b2fbSDimitry Andricdefm VFNCVT_F_F_W : VNCVTF_FV_VS2<"vfncvt.f.f.w", 0b010010, 0b10100>;
1498bdd1243dSDimitry Andric}
14996e75b2fbSDimitry Andricdefm VFNCVT_ROD_F_F_W : VNCVTF_FV_VS2<"vfncvt.rod.f.f.w", 0b010010, 0b10101>;
1500bdd1243dSDimitry Andric} // Constraints = "@earlyclobber $vd", mayRaiseFPException = true
150104eeddc0SDimitry Andric} // Predicates = HasVInstructionsAnyF]
15025ffd83dbSDimitry Andric
150304eeddc0SDimitry Andriclet Predicates = [HasVInstructions] in {
15046e75b2fbSDimitry Andric
15055ffd83dbSDimitry Andric// Vector Single-Width Integer Reduction Instructions
1506e8d8bef9SDimitry Andriclet RVVConstraint = NoConstraint in {
15076e75b2fbSDimitry Andricdefm VREDSUM  : VRED_MV_V<"vredsum", 0b000000>;
150806c3fb27SDimitry Andricdefm VREDMAXU : VREDMINMAX_MV_V<"vredmaxu", 0b000110>;
150906c3fb27SDimitry Andricdefm VREDMAX  : VREDMINMAX_MV_V<"vredmax", 0b000111>;
151006c3fb27SDimitry Andricdefm VREDMINU : VREDMINMAX_MV_V<"vredminu", 0b000100>;
151106c3fb27SDimitry Andricdefm VREDMIN  : VREDMINMAX_MV_V<"vredmin", 0b000101>;
15126e75b2fbSDimitry Andricdefm VREDAND  : VRED_MV_V<"vredand", 0b000001>;
15136e75b2fbSDimitry Andricdefm VREDOR   : VRED_MV_V<"vredor", 0b000010>;
15146e75b2fbSDimitry Andricdefm VREDXOR  : VRED_MV_V<"vredxor", 0b000011>;
1515e8d8bef9SDimitry Andric} // RVVConstraint = NoConstraint
15165ffd83dbSDimitry Andric
15175ffd83dbSDimitry Andric// Vector Widening Integer Reduction Instructions
1518e8d8bef9SDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = NoConstraint in {
15195ffd83dbSDimitry Andric// Set earlyclobber for following instructions for second and mask operands.
15205ffd83dbSDimitry Andric// This has the downside that the earlyclobber constraint is too coarse and
15215ffd83dbSDimitry Andric// will impose unnecessary restrictions by not allowing the destination to
15225ffd83dbSDimitry Andric// overlap with the first (wide) operand.
15236e75b2fbSDimitry Andricdefm VWREDSUMU : VWRED_IV_V<"vwredsumu", 0b110000>;
15246e75b2fbSDimitry Andricdefm VWREDSUM : VWRED_IV_V<"vwredsum", 0b110001>;
1525e8d8bef9SDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = NoConstraint
15266e75b2fbSDimitry Andric
152704eeddc0SDimitry Andric} // Predicates = [HasVInstructions]
15285ffd83dbSDimitry Andric
152904eeddc0SDimitry Andriclet Predicates = [HasVInstructionsAnyF] in {
15305ffd83dbSDimitry Andric// Vector Single-Width Floating-Point Reduction Instructions
1531e8d8bef9SDimitry Andriclet RVVConstraint = NoConstraint in {
153281ad6265SDimitry Andriclet Uses = [FRM], mayRaiseFPException = true in {
15336e75b2fbSDimitry Andricdefm VFREDOSUM : VREDO_FV_V<"vfredosum", 0b000011>;
1534349cc55cSDimitry Andricdefm VFREDUSUM : VRED_FV_V<"vfredusum", 0b000001>;
153581ad6265SDimitry Andric}
153681ad6265SDimitry Andriclet mayRaiseFPException = true in {
153706c3fb27SDimitry Andricdefm VFREDMAX : VREDMINMAX_FV_V<"vfredmax", 0b000111>;
153806c3fb27SDimitry Andricdefm VFREDMIN : VREDMINMAX_FV_V<"vfredmin", 0b000101>;
153981ad6265SDimitry Andric}
1540e8d8bef9SDimitry Andric} // RVVConstraint = NoConstraint
15415ffd83dbSDimitry Andric
1542349cc55cSDimitry Andricdef : InstAlias<"vfredsum.vs $vd, $vs2, $vs1$vm",
1543349cc55cSDimitry Andric                (VFREDUSUM_VS VR:$vd, VR:$vs2, VR:$vs1, VMaskOp:$vm), 0>;
1544349cc55cSDimitry Andric
15455ffd83dbSDimitry Andric// Vector Widening Floating-Point Reduction Instructions
1546e8d8bef9SDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = NoConstraint in {
15475ffd83dbSDimitry Andric// Set earlyclobber for following instructions for second and mask operands.
15485ffd83dbSDimitry Andric// This has the downside that the earlyclobber constraint is too coarse and
15495ffd83dbSDimitry Andric// will impose unnecessary restrictions by not allowing the destination to
15505ffd83dbSDimitry Andric// overlap with the first (wide) operand.
155181ad6265SDimitry Andriclet Uses = [FRM], mayRaiseFPException = true in {
15526e75b2fbSDimitry Andricdefm VFWREDOSUM : VWREDO_FV_V<"vfwredosum", 0b110011>;
1553349cc55cSDimitry Andricdefm VFWREDUSUM : VWRED_FV_V<"vfwredusum", 0b110001>;
155481ad6265SDimitry Andric}
1555e8d8bef9SDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = NoConstraint
1556349cc55cSDimitry Andric
1557349cc55cSDimitry Andricdef : InstAlias<"vfwredsum.vs $vd, $vs2, $vs1$vm",
1558349cc55cSDimitry Andric                (VFWREDUSUM_VS VR:$vd, VR:$vs2, VR:$vs1, VMaskOp:$vm), 0>;
155904eeddc0SDimitry Andric} // Predicates = [HasVInstructionsAnyF]
15605ffd83dbSDimitry Andric
156104eeddc0SDimitry Andriclet Predicates = [HasVInstructions] in {
15625ffd83dbSDimitry Andric// Vector Mask-Register Logical Instructions
1563e8d8bef9SDimitry Andriclet RVVConstraint = NoConstraint in {
15646e75b2fbSDimitry Andricdefm VMAND_M : VMALU_MV_Mask<"vmand", 0b011001, "m">;
15656e75b2fbSDimitry Andricdefm VMNAND_M : VMALU_MV_Mask<"vmnand", 0b011101, "m">;
1566349cc55cSDimitry Andricdefm VMANDN_M : VMALU_MV_Mask<"vmandn", 0b011000, "m">;
15676e75b2fbSDimitry Andricdefm VMXOR_M : VMALU_MV_Mask<"vmxor", 0b011011, "m">;
15686e75b2fbSDimitry Andricdefm VMOR_M : VMALU_MV_Mask<"vmor", 0b011010, "m">;
15696e75b2fbSDimitry Andricdefm VMNOR_M : VMALU_MV_Mask<"vmnor", 0b011110, "m">;
1570349cc55cSDimitry Andricdefm VMORN_M : VMALU_MV_Mask<"vmorn", 0b011100, "m">;
15716e75b2fbSDimitry Andricdefm VMXNOR_M : VMALU_MV_Mask<"vmxnor", 0b011111, "m">;
1572e8d8bef9SDimitry Andric}
15735ffd83dbSDimitry Andric
1574e8d8bef9SDimitry Andricdef : InstAlias<"vmmv.m $vd, $vs",
1575e8d8bef9SDimitry Andric                (VMAND_MM VR:$vd, VR:$vs, VR:$vs)>;
15765ffd83dbSDimitry Andricdef : InstAlias<"vmclr.m $vd",
1577e8d8bef9SDimitry Andric                (VMXOR_MM VR:$vd, VR:$vd, VR:$vd)>;
15785ffd83dbSDimitry Andricdef : InstAlias<"vmset.m $vd",
1579e8d8bef9SDimitry Andric                (VMXNOR_MM VR:$vd, VR:$vd, VR:$vd)>;
15805ffd83dbSDimitry Andricdef : InstAlias<"vmnot.m $vd, $vs",
1581e8d8bef9SDimitry Andric                (VMNAND_MM VR:$vd, VR:$vs, VR:$vs)>;
15825ffd83dbSDimitry Andric
1583349cc55cSDimitry Andricdef : InstAlias<"vmandnot.mm $vd, $vs2, $vs1",
1584349cc55cSDimitry Andric                (VMANDN_MM VR:$vd, VR:$vs2, VR:$vs1), 0>;
1585349cc55cSDimitry Andricdef : InstAlias<"vmornot.mm $vd, $vs2, $vs1",
1586349cc55cSDimitry Andric                (VMORN_MM VR:$vd, VR:$vs2, VR:$vs1), 0>;
1587349cc55cSDimitry Andric
1588e8d8bef9SDimitry Andriclet hasSideEffects = 0, mayLoad = 0, mayStore = 0,
1589e8d8bef9SDimitry Andric    RVVConstraint = NoConstraint  in {
15906e75b2fbSDimitry Andric
1591349cc55cSDimitry Andric// Vector mask population count vcpop
1592349cc55cSDimitry Andricdef VCPOP_M : RVInstV<0b010000, 0b10000, OPMVV, (outs GPR:$vd),
1593e8d8bef9SDimitry Andric                      (ins VR:$vs2, VMaskOp:$vm),
1594349cc55cSDimitry Andric                      "vcpop.m", "$vd, $vs2$vm">,
15955f757f3fSDimitry Andric              SchedUnaryMC<"WriteVMPopV", "ReadVMPopV">;
15965ffd83dbSDimitry Andric
15975ffd83dbSDimitry Andric// vfirst find-first-set mask bit
15985ffd83dbSDimitry Andricdef VFIRST_M : RVInstV<0b010000, 0b10001, OPMVV, (outs GPR:$vd),
1599e8d8bef9SDimitry Andric                       (ins VR:$vs2, VMaskOp:$vm),
16006e75b2fbSDimitry Andric                       "vfirst.m", "$vd, $vs2$vm">,
16015f757f3fSDimitry Andric              SchedUnaryMC<"WriteVMFFSV", "ReadVMFFSV">;
16026e75b2fbSDimitry Andric
16035ffd83dbSDimitry Andric} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
16045ffd83dbSDimitry Andric
1605349cc55cSDimitry Andricdef : InstAlias<"vpopc.m $vd, $vs2$vm",
1606349cc55cSDimitry Andric                (VCPOP_M GPR:$vd, VR:$vs2, VMaskOp:$vm), 0>;
1607349cc55cSDimitry Andric
1608e8d8bef9SDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = Iota in {
16096e75b2fbSDimitry Andric
16105ffd83dbSDimitry Andric// vmsbf.m set-before-first mask bit
16116e75b2fbSDimitry Andricdefm VMSBF_M : VMSFS_MV_V<"vmsbf.m", 0b010100, 0b00001>;
16125ffd83dbSDimitry Andric// vmsif.m set-including-first mask bit
16136e75b2fbSDimitry Andricdefm VMSIF_M : VMSFS_MV_V<"vmsif.m", 0b010100, 0b00011>;
16145ffd83dbSDimitry Andric// vmsof.m set-only-first mask bit
16156e75b2fbSDimitry Andricdefm VMSOF_M : VMSFS_MV_V<"vmsof.m", 0b010100, 0b00010>;
16165ffd83dbSDimitry Andric// Vector Iota Instruction
1617*0fca6ea1SDimitry Andricdefm VIOTA_M : VIOTA_MV_V<"viota.m", 0b010100, 0b10000>;
16186e75b2fbSDimitry Andric
16195ffd83dbSDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = Iota
16205ffd83dbSDimitry Andric
16215ffd83dbSDimitry Andric// Vector Element Index Instruction
16225ffd83dbSDimitry Andriclet hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
16236e75b2fbSDimitry Andric
16246e75b2fbSDimitry Andriclet vs2 = 0 in
1625e8d8bef9SDimitry Andricdef VID_V : RVInstV<0b010100, 0b10001, OPMVV, (outs VR:$vd),
16266e75b2fbSDimitry Andric                    (ins VMaskOp:$vm), "vid.v", "$vd$vm">,
1627*0fca6ea1SDimitry Andric            SchedNullaryMC<"WriteVIdxV">;
16285ffd83dbSDimitry Andric
16295ffd83dbSDimitry Andric// Integer Scalar Move Instructions
1630e8d8bef9SDimitry Andriclet vm = 1, RVVConstraint = NoConstraint in {
16315ffd83dbSDimitry Andricdef VMV_X_S : RVInstV<0b010000, 0b00000, OPMVV, (outs GPR:$vd),
16326e75b2fbSDimitry Andric                      (ins VR:$vs2), "vmv.x.s", "$vd, $vs2">,
1633*0fca6ea1SDimitry Andric              Sched<[WriteVMovXS, ReadVMovXS]>;
1634e8d8bef9SDimitry Andriclet Constraints = "$vd = $vd_wb" in
1635e8d8bef9SDimitry Andricdef VMV_S_X : RVInstV2<0b010000, 0b00000, OPMVX, (outs VR:$vd_wb),
16366e75b2fbSDimitry Andric                      (ins VR:$vd, GPR:$rs1), "vmv.s.x", "$vd, $rs1">,
1637*0fca6ea1SDimitry Andric              Sched<[WriteVMovSX, ReadVMovSX_V, ReadVMovSX_X]>;
16385ffd83dbSDimitry Andric}
16396e75b2fbSDimitry Andric
16405ffd83dbSDimitry Andric} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
16416e75b2fbSDimitry Andric
164204eeddc0SDimitry Andric} // Predicates = [HasVInstructions]
16435ffd83dbSDimitry Andric
164404eeddc0SDimitry Andriclet Predicates = [HasVInstructionsAnyF] in {
16456e75b2fbSDimitry Andric
1646e8d8bef9SDimitry Andriclet hasSideEffects = 0, mayLoad = 0, mayStore = 0, vm = 1,
1647e8d8bef9SDimitry Andric    RVVConstraint = NoConstraint  in {
16485ffd83dbSDimitry Andric// Floating-Point Scalar Move Instructions
16495ffd83dbSDimitry Andricdef VFMV_F_S : RVInstV<0b010000, 0b00000, OPFVV, (outs FPR32:$vd),
16506e75b2fbSDimitry Andric                      (ins VR:$vs2), "vfmv.f.s", "$vd, $vs2">,
1651*0fca6ea1SDimitry Andric               Sched<[WriteVMovFS, ReadVMovFS]>;
1652e8d8bef9SDimitry Andriclet Constraints = "$vd = $vd_wb" in
1653e8d8bef9SDimitry Andricdef VFMV_S_F : RVInstV2<0b010000, 0b00000, OPFVF, (outs VR:$vd_wb),
16546e75b2fbSDimitry Andric                       (ins VR:$vd, FPR32:$rs1), "vfmv.s.f", "$vd, $rs1">,
1655*0fca6ea1SDimitry Andric               Sched<[WriteVMovSF, ReadVMovSF_V, ReadVMovSF_F]>;
16565ffd83dbSDimitry Andric
16575ffd83dbSDimitry Andric} // hasSideEffects = 0, mayLoad = 0, mayStore = 0, vm = 1
16586e75b2fbSDimitry Andric
165904eeddc0SDimitry Andric} // Predicates = [HasVInstructionsAnyF]
16605ffd83dbSDimitry Andric
166104eeddc0SDimitry Andriclet Predicates = [HasVInstructions] in {
16625ffd83dbSDimitry Andric// Vector Slide Instructions
16635ffd83dbSDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = SlideUp in {
1664*0fca6ea1SDimitry Andricdefm VSLIDEUP_V : VSLD_IV_X_I<"vslideup", 0b001110, /*slidesUp=*/true>;
16656e75b2fbSDimitry Andricdefm VSLIDE1UP_V : VSLD1_MV_X<"vslide1up", 0b001110>;
16665ffd83dbSDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = SlideUp
1667*0fca6ea1SDimitry Andricdefm VSLIDEDOWN_V : VSLD_IV_X_I<"vslidedown", 0b001111, /*slidesUp=*/false>;
16686e75b2fbSDimitry Andricdefm VSLIDE1DOWN_V : VSLD1_MV_X<"vslide1down", 0b001111>;
166904eeddc0SDimitry Andric} // Predicates = [HasVInstructions]
16705ffd83dbSDimitry Andric
167104eeddc0SDimitry Andriclet Predicates = [HasVInstructionsAnyF] in {
1672e8d8bef9SDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = SlideUp in {
16736e75b2fbSDimitry Andricdefm VFSLIDE1UP_V : VSLD1_FV_F<"vfslide1up", 0b001110>;
1674e8d8bef9SDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = SlideUp
16756e75b2fbSDimitry Andricdefm VFSLIDE1DOWN_V : VSLD1_FV_F<"vfslide1down", 0b001111>;
167604eeddc0SDimitry Andric} // Predicates = [HasVInstructionsAnyF]
1677e8d8bef9SDimitry Andric
167804eeddc0SDimitry Andriclet Predicates = [HasVInstructions] in {
16795ffd83dbSDimitry Andric// Vector Register Gather Instruction
16805ffd83dbSDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = Vrgather in {
168106c3fb27SDimitry Andricdefm VRGATHER_V : VGTR_IV_V_X_I<"vrgather", 0b001100>;
16826e75b2fbSDimitry Andricdef VRGATHEREI16_VV : VALUVV<0b001110, OPIVV, "vrgatherei16.vv">,
1683*0fca6ea1SDimitry Andric                      SchedBinaryMC<"WriteVRGatherEI16VV",
1684*0fca6ea1SDimitry Andric                                    "ReadVRGatherEI16VV_data",
1685*0fca6ea1SDimitry Andric                                    "ReadVRGatherEI16VV_index">;
16865ffd83dbSDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = Vrgather
16875ffd83dbSDimitry Andric
16885ffd83dbSDimitry Andric// Vector Compress Instruction
16895ffd83dbSDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = Vcompress in {
16906e75b2fbSDimitry Andricdefm VCOMPRESS_V : VCPR_MV_Mask<"vcompress", 0b010111>;
16915ffd83dbSDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = Vcompress
16925ffd83dbSDimitry Andric
169306c3fb27SDimitry Andriclet hasSideEffects = 0, mayLoad = 0, mayStore = 0, isMoveReg = 1,
1694e8d8bef9SDimitry Andric    RVVConstraint = NoConstraint in {
16950eae32dcSDimitry Andric// A future extension may relax the vector register alignment restrictions.
1696753f127fSDimitry Andricforeach n = [1, 2, 4, 8] in {
1697753f127fSDimitry Andric  defvar vrc = !cast<VReg>(!if(!eq(n, 1), "VR", "VRM"#n));
16980eae32dcSDimitry Andric  def VMV#n#R_V  : RVInstV<0b100111, !add(n, -1), OPIVI, (outs vrc:$vd),
16990eae32dcSDimitry Andric                           (ins vrc:$vs2), "vmv" # n # "r.v", "$vd, $vs2">,
17006e75b2fbSDimitry Andric                   VMVRSched<n> {
17015ffd83dbSDimitry Andric    let Uses = [];
17025ffd83dbSDimitry Andric    let vm = 1;
17035ffd83dbSDimitry Andric  }
17045ffd83dbSDimitry Andric}
17055ffd83dbSDimitry Andric} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
170604eeddc0SDimitry Andric} // Predicates = [HasVInstructions]
1707e8d8bef9SDimitry Andric
170804eeddc0SDimitry Andriclet Predicates = [HasVInstructions] in {
1709e8d8bef9SDimitry Andric  foreach nf=2-8 in {
171004eeddc0SDimitry Andric    foreach eew = [8, 16, 32] in {
1711349cc55cSDimitry Andric      defvar w = !cast<RISCVWidth>("LSWidth"#eew);
1712e8d8bef9SDimitry Andric
1713349cc55cSDimitry Andric      def VLSEG#nf#E#eew#_V :
1714753f127fSDimitry Andric        VUnitStrideSegmentLoad<!add(nf, -1), w, "vlseg"#nf#"e"#eew#".v">,
17155f757f3fSDimitry Andric        VLSEGSchedMC<nf, eew>;
1716349cc55cSDimitry Andric      def VLSEG#nf#E#eew#FF_V :
1717753f127fSDimitry Andric        VUnitStrideSegmentLoadFF<!add(nf, -1), w, "vlseg"#nf#"e"#eew#"ff.v">,
17185f757f3fSDimitry Andric        VLSEGFFSchedMC<nf, eew>;
1719349cc55cSDimitry Andric      def VSSEG#nf#E#eew#_V :
1720753f127fSDimitry Andric        VUnitStrideSegmentStore<!add(nf, -1), w, "vsseg"#nf#"e"#eew#".v">,
17215f757f3fSDimitry Andric        VSSEGSchedMC<nf, eew>;
1722e8d8bef9SDimitry Andric      // Vector Strided Instructions
1723349cc55cSDimitry Andric      def VLSSEG#nf#E#eew#_V :
1724753f127fSDimitry Andric        VStridedSegmentLoad<!add(nf, -1), w, "vlsseg"#nf#"e"#eew#".v">,
17255f757f3fSDimitry Andric        VLSSEGSchedMC<nf, eew>;
1726349cc55cSDimitry Andric      def VSSSEG#nf#E#eew#_V :
1727753f127fSDimitry Andric        VStridedSegmentStore<!add(nf, -1), w, "vssseg"#nf#"e"#eew#".v">,
17285f757f3fSDimitry Andric        VSSSEGSchedMC<nf, eew>;
1729e8d8bef9SDimitry Andric
1730e8d8bef9SDimitry Andric      // Vector Indexed Instructions
1731349cc55cSDimitry Andric      def VLUXSEG#nf#EI#eew#_V :
1732349cc55cSDimitry Andric        VIndexedSegmentLoad<!add(nf, -1), MOPLDIndexedUnord, w,
1733bdd1243dSDimitry Andric                            "vluxseg"#nf#"ei"#eew#".v">,
17345f757f3fSDimitry Andric        VLXSEGSchedMC<nf, eew, isOrdered=0>;
1735349cc55cSDimitry Andric      def VLOXSEG#nf#EI#eew#_V :
1736349cc55cSDimitry Andric        VIndexedSegmentLoad<!add(nf, -1), MOPLDIndexedOrder, w,
1737bdd1243dSDimitry Andric                            "vloxseg"#nf#"ei"#eew#".v">,
17385f757f3fSDimitry Andric        VLXSEGSchedMC<nf, eew, isOrdered=1>;
1739349cc55cSDimitry Andric      def VSUXSEG#nf#EI#eew#_V :
1740349cc55cSDimitry Andric        VIndexedSegmentStore<!add(nf, -1), MOPSTIndexedUnord, w,
1741bdd1243dSDimitry Andric                             "vsuxseg"#nf#"ei"#eew#".v">,
17425f757f3fSDimitry Andric        VSXSEGSchedMC<nf, eew, isOrdered=0>;
1743349cc55cSDimitry Andric      def VSOXSEG#nf#EI#eew#_V :
1744349cc55cSDimitry Andric        VIndexedSegmentStore<!add(nf, -1), MOPSTIndexedOrder, w,
1745bdd1243dSDimitry Andric                             "vsoxseg"#nf#"ei"#eew#".v">,
17465f757f3fSDimitry Andric        VSXSEGSchedMC<nf, eew, isOrdered=1>;
1747349cc55cSDimitry Andric    }
1748e8d8bef9SDimitry Andric  }
174904eeddc0SDimitry Andric} // Predicates = [HasVInstructions]
175004eeddc0SDimitry Andric
175104eeddc0SDimitry Andriclet Predicates = [HasVInstructionsI64] in {
175204eeddc0SDimitry Andric  foreach nf=2-8 in {
175304eeddc0SDimitry Andric    // Vector Unit-strided Segment Instructions
175404eeddc0SDimitry Andric    def VLSEG#nf#E64_V :
1755753f127fSDimitry Andric      VUnitStrideSegmentLoad<!add(nf, -1), LSWidth64, "vlseg"#nf#"e64.v">,
17565f757f3fSDimitry Andric      VLSEGSchedMC<nf, 64>;
175704eeddc0SDimitry Andric    def VLSEG#nf#E64FF_V :
1758753f127fSDimitry Andric      VUnitStrideSegmentLoadFF<!add(nf, -1), LSWidth64, "vlseg"#nf#"e64ff.v">,
17595f757f3fSDimitry Andric      VLSEGFFSchedMC<nf, 64>;
176004eeddc0SDimitry Andric    def VSSEG#nf#E64_V :
1761753f127fSDimitry Andric      VUnitStrideSegmentStore<!add(nf, -1), LSWidth64, "vsseg"#nf#"e64.v">,
17625f757f3fSDimitry Andric      VSSEGSchedMC<nf, 64>;
176304eeddc0SDimitry Andric
176404eeddc0SDimitry Andric    // Vector Strided Segment Instructions
176504eeddc0SDimitry Andric    def VLSSEG#nf#E64_V :
1766753f127fSDimitry Andric      VStridedSegmentLoad<!add(nf, -1), LSWidth64, "vlsseg"#nf#"e64.v">,
17675f757f3fSDimitry Andric      VLSSEGSchedMC<nf, 64>;
176804eeddc0SDimitry Andric    def VSSSEG#nf#E64_V :
1769753f127fSDimitry Andric      VStridedSegmentStore<!add(nf, -1), LSWidth64, "vssseg"#nf#"e64.v">,
17705f757f3fSDimitry Andric      VSSSEGSchedMC<nf, 64>;
177104eeddc0SDimitry Andric  }
177204eeddc0SDimitry Andric} // Predicates = [HasVInstructionsI64]
177304eeddc0SDimitry Andriclet Predicates = [HasVInstructionsI64, IsRV64] in {
177404eeddc0SDimitry Andric  foreach nf = 2 - 8 in {
177504eeddc0SDimitry Andric    // Vector Indexed Segment Instructions
1776bdd1243dSDimitry Andric    def VLUXSEG #nf #EI64_V
1777bdd1243dSDimitry Andric        : VIndexedSegmentLoad<!add(nf, -1), MOPLDIndexedUnord, LSWidth64,
1778bdd1243dSDimitry Andric                              "vluxseg" #nf #"ei64.v">,
17795f757f3fSDimitry Andric          VLXSEGSchedMC<nf, 64, isOrdered=0>;
1780bdd1243dSDimitry Andric    def VLOXSEG #nf #EI64_V
1781bdd1243dSDimitry Andric        : VIndexedSegmentLoad<!add(nf, -1), MOPLDIndexedOrder, LSWidth64,
1782bdd1243dSDimitry Andric                              "vloxseg" #nf #"ei64.v">,
17835f757f3fSDimitry Andric          VLXSEGSchedMC<nf, 64, isOrdered=1>;
1784bdd1243dSDimitry Andric    def VSUXSEG #nf #EI64_V
1785bdd1243dSDimitry Andric        : VIndexedSegmentStore<!add(nf, -1), MOPSTIndexedUnord, LSWidth64,
1786bdd1243dSDimitry Andric                               "vsuxseg" #nf #"ei64.v">,
17875f757f3fSDimitry Andric          VSXSEGSchedMC<nf, 64, isOrdered=0>;
1788bdd1243dSDimitry Andric    def VSOXSEG #nf #EI64_V
1789bdd1243dSDimitry Andric        : VIndexedSegmentStore<!add(nf, -1), MOPSTIndexedOrder, LSWidth64,
1790bdd1243dSDimitry Andric                               "vsoxseg" #nf #"ei64.v">,
17915f757f3fSDimitry Andric          VSXSEGSchedMC<nf, 64, isOrdered=1>;
179204eeddc0SDimitry Andric  }
179304eeddc0SDimitry Andric} // Predicates = [HasVInstructionsI64, IsRV64]
1794e8d8bef9SDimitry Andric
17955f757f3fSDimitry Andricinclude "RISCVInstrInfoZvfbf.td"
1796e8d8bef9SDimitry Andricinclude "RISCVInstrInfoVPseudos.td"
1797