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
27*5f757f3fSDimitry 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
60*5f757f3fSDimitry 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
75*5f757f3fSDimitry 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
94*5f757f3fSDimitry Andric// Common class of scheduling definitions.
95*5f757f3fSDimitry Andric// `ReadVMergeOp` will be prepended to reads if instruction is masked.
96*5f757f3fSDimitry Andric// `ReadVMask` will be appended to reads if instruction is masked.
97*5f757f3fSDimitry Andric// Operands:
98*5f757f3fSDimitry Andric//   `writes`       SchedWrites that are listed for each explicit def operand
99*5f757f3fSDimitry Andric//                  in order.
100*5f757f3fSDimitry Andric//   `reads`        SchedReads that are listed for each explicit use operand.
101*5f757f3fSDimitry Andric//   `forceMasked`  Forced to be masked (e.g. Add-with-Carry Instructions).
102*5f757f3fSDimitry Andric//   `forceMergeOpRead` Force to have read for merge operand.
103*5f757f3fSDimitry Andricclass SchedCommon<list<SchedWrite> writes, list<SchedRead> reads,
104*5f757f3fSDimitry Andric                  string mx = "WorstCase", int sew = 0, bit forceMasked = 0,
105*5f757f3fSDimitry Andric                  bit forceMergeOpRead = 0> : Sched<[]> {
106*5f757f3fSDimitry Andric  defvar isMasked = !ne(!find(NAME, "_MASK"), -1);
107*5f757f3fSDimitry Andric  defvar isMaskedOrForceMasked = !or(forceMasked, isMasked);
108*5f757f3fSDimitry Andric  defvar mergeRead = !if(!or(!eq(mx, "WorstCase"), !eq(sew, 0)),
109*5f757f3fSDimitry Andric                            !cast<SchedRead>("ReadVMergeOp_" # mx),
110*5f757f3fSDimitry Andric                            !cast<SchedRead>("ReadVMergeOp_" # mx # "_E" #sew));
111*5f757f3fSDimitry Andric  defvar needsMergeRead = !or(isMaskedOrForceMasked, forceMergeOpRead);
112*5f757f3fSDimitry Andric  defvar readsWithMask =
113*5f757f3fSDimitry Andric      !if(isMaskedOrForceMasked, !listconcat(reads, [ReadVMask]), reads);
114*5f757f3fSDimitry Andric  defvar allReads =
115*5f757f3fSDimitry Andric      !if(needsMergeRead, !listconcat([mergeRead], readsWithMask), reads);
116*5f757f3fSDimitry Andric  let SchedRW = !listconcat(writes, allReads);
117*5f757f3fSDimitry Andric}
1186e75b2fbSDimitry Andric
119*5f757f3fSDimitry Andric// Common class of scheduling definitions for n-ary instructions.
120*5f757f3fSDimitry Andric// The scheudling resources are relevant to LMUL and may be relevant to SEW.
121*5f757f3fSDimitry Andricclass SchedNary<string write, list<string> reads, string mx, int sew = 0,
122*5f757f3fSDimitry Andric                bit forceMasked = 0, bit forceMergeOpRead = 0>
123*5f757f3fSDimitry Andric    : SchedCommon<[!cast<SchedWrite>(
124*5f757f3fSDimitry Andric                      !if(sew,
125*5f757f3fSDimitry Andric                          write # "_" # mx # "_E" # sew,
126*5f757f3fSDimitry Andric                          write # "_" # mx))],
127*5f757f3fSDimitry Andric                  !foreach(read, reads,
128*5f757f3fSDimitry Andric                           !cast<SchedRead>(!if(sew, read #"_" #mx #"_E" #sew,
129*5f757f3fSDimitry Andric                                                 read #"_" #mx))),
130*5f757f3fSDimitry Andric                  mx, sew, forceMasked, forceMergeOpRead>;
1316e75b2fbSDimitry Andric
132*5f757f3fSDimitry Andric// Classes with postfix "MC" are only used in MC layer.
133*5f757f3fSDimitry Andric// For these classes, we assume that they are with the worst case costs and
134*5f757f3fSDimitry Andric// `ReadVMask` is always needed (with some exceptions).
1356e75b2fbSDimitry Andric
136*5f757f3fSDimitry Andric// For instructions with no operand.
137*5f757f3fSDimitry Andricclass SchedNullary<string write, string mx, int sew = 0, bit forceMasked = 0,
138*5f757f3fSDimitry Andric                   bit forceMergeOpRead = 0>:
139*5f757f3fSDimitry Andric  SchedNary<write, [], mx, sew, forceMasked, forceMergeOpRead>;
140*5f757f3fSDimitry Andricclass SchedNullaryMC<string write, bit forceMasked = 1>:
141*5f757f3fSDimitry Andric  SchedNullary<write, "WorstCase", forceMasked=forceMasked>;
1426e75b2fbSDimitry Andric
143*5f757f3fSDimitry Andric// For instructions with one operand.
144*5f757f3fSDimitry Andricclass SchedUnary<string write, string read0, string mx, int sew = 0,
145*5f757f3fSDimitry Andric                 bit forceMasked = 0, bit forceMergeOpRead = 0>:
146*5f757f3fSDimitry Andric  SchedNary<write, [read0], mx, sew, forceMasked, forceMergeOpRead>;
147*5f757f3fSDimitry Andricclass SchedUnaryMC<string write, string read0, bit forceMasked = 1>:
148*5f757f3fSDimitry Andric  SchedUnary<write, read0, "WorstCase", forceMasked=forceMasked>;
1496e75b2fbSDimitry Andric
150*5f757f3fSDimitry Andric// For instructions with two operands.
151*5f757f3fSDimitry Andricclass SchedBinary<string write, string read0, string read1, string mx,
152*5f757f3fSDimitry Andric                  int sew = 0, bit forceMasked = 0, bit forceMergeOpRead = 0>
153*5f757f3fSDimitry Andric    : SchedNary<write, [read0, read1], mx, sew, forceMasked, forceMergeOpRead>;
154*5f757f3fSDimitry Andricclass SchedBinaryMC<string write, string read0, string read1,
155*5f757f3fSDimitry Andric                    bit forceMasked = 1>:
156*5f757f3fSDimitry Andric  SchedBinary<write, read0, read1, "WorstCase", forceMasked=forceMasked>;
1576e75b2fbSDimitry Andric
158*5f757f3fSDimitry Andric// For instructions with three operands.
159*5f757f3fSDimitry Andricclass SchedTernary<string write, string read0, string read1, string read2,
160*5f757f3fSDimitry Andric                   string mx, int sew = 0, bit forceMasked = 0,
161*5f757f3fSDimitry Andric                   bit forceMergeOpRead = 0>
162*5f757f3fSDimitry Andric    : SchedNary<write, [read0, read1, read2], mx, sew, forceMasked,
163*5f757f3fSDimitry Andric                forceMergeOpRead>;
164*5f757f3fSDimitry Andricclass SchedTernaryMC<string write, string read0, string read1, string read2,
165*5f757f3fSDimitry Andric                     int sew = 0, bit forceMasked = 1>:
166*5f757f3fSDimitry Andric  SchedNary<write, [read0, read1, read2], "WorstCase", sew, forceMasked>;
1676e75b2fbSDimitry Andric
168*5f757f3fSDimitry Andric// For reduction instructions.
169*5f757f3fSDimitry Andricclass SchedReduction<string write, string read, string mx, int sew,
170*5f757f3fSDimitry Andric                     bit forceMergeOpRead = 0>
171*5f757f3fSDimitry Andric    : SchedCommon<[!cast<SchedWrite>(write #"_" #mx #"_E" #sew)],
172*5f757f3fSDimitry Andric                  !listsplat(!cast<SchedRead>(read), 3), mx, sew, forceMergeOpRead>;
173*5f757f3fSDimitry Andricclass SchedReductionMC<string write, string readV, string readV0>:
174*5f757f3fSDimitry Andric  SchedCommon<[!cast<SchedWrite>(write # "_WorstCase")],
175*5f757f3fSDimitry Andric              [!cast<SchedRead>(readV), !cast<SchedRead>(readV0)],
176*5f757f3fSDimitry Andric              forceMasked=1>;
177*5f757f3fSDimitry Andric
178*5f757f3fSDimitry Andric// Whole Vector Register Move
179*5f757f3fSDimitry Andricclass VMVRSched<int n> : SchedCommon<
180*5f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVMov" # n # "V")],
181*5f757f3fSDimitry Andric  [!cast<SchedRead>("ReadVMov" # n # "V")]
182*5f757f3fSDimitry Andric>;
183*5f757f3fSDimitry Andric
184*5f757f3fSDimitry Andric// Vector Unit-Stride Loads and Stores
185*5f757f3fSDimitry Andricclass VLESched<string lmul, bit forceMasked = 0> : SchedCommon<
186*5f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVLDE_" # lmul)],
187*5f757f3fSDimitry Andric  [ReadVLDX], mx=lmul, forceMasked=forceMasked
188*5f757f3fSDimitry Andric>;
189*5f757f3fSDimitry Andricclass VLESchedMC : VLESched<"WorstCase", forceMasked=1>;
190*5f757f3fSDimitry Andric
191*5f757f3fSDimitry Andricclass VSESched<string lmul, bit forceMasked = 0> : SchedCommon<
192*5f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVSTE_" # lmul)],
193*5f757f3fSDimitry Andric  [!cast<SchedRead>("ReadVSTEV_" # lmul), ReadVSTX], mx=lmul,
194*5f757f3fSDimitry Andric  forceMasked=forceMasked
195*5f757f3fSDimitry Andric>;
196*5f757f3fSDimitry Andricclass VSESchedMC : VSESched<"WorstCase", forceMasked=1>;
197*5f757f3fSDimitry Andric
198*5f757f3fSDimitry Andric// Vector Strided Loads and Stores
199*5f757f3fSDimitry Andricclass VLSSched<int eew, string emul, bit forceMasked = 0> : SchedCommon<
200*5f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVLDS" # eew # "_" # emul)],
201*5f757f3fSDimitry Andric  [ReadVLDX, ReadVLDSX], emul, eew, forceMasked
202*5f757f3fSDimitry Andric>;
203*5f757f3fSDimitry Andricclass VLSSchedMC<int eew> : VLSSched<eew, "WorstCase", forceMasked=1>;
204*5f757f3fSDimitry Andric
205*5f757f3fSDimitry Andricclass VSSSched<int eew, string emul, bit forceMasked = 0> : SchedCommon<
206*5f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVSTS" # eew # "_" # emul)],
207*5f757f3fSDimitry Andric  [!cast<SchedRead>("ReadVSTS" # eew # "V_" # emul), ReadVSTX, ReadVSTSX],
208*5f757f3fSDimitry Andric  emul, eew, forceMasked
209*5f757f3fSDimitry Andric>;
210*5f757f3fSDimitry Andricclass VSSSchedMC<int eew> : VSSSched<eew, "WorstCase", forceMasked=1>;
211*5f757f3fSDimitry Andric
212*5f757f3fSDimitry Andric// Vector Indexed Loads and Stores
213*5f757f3fSDimitry Andricclass VLXSched<int dataEEW, bit isOrdered, string dataEMUL, string idxEMUL,
214*5f757f3fSDimitry Andric               bit forceMasked = 0> : SchedCommon<
215*5f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVLD" # !if(isOrdered, "O", "U") # "X" # dataEEW # "_" # dataEMUL)],
216*5f757f3fSDimitry Andric  [ReadVLDX, !cast<SchedRead>("ReadVLD" # !if(isOrdered, "O", "U") # "XV_" # idxEMUL)],
217*5f757f3fSDimitry Andric  dataEMUL, dataEEW, forceMasked
218*5f757f3fSDimitry Andric>;
219*5f757f3fSDimitry Andricclass VLXSchedMC<int dataEEW, bit isOrdered>:
220*5f757f3fSDimitry Andric  VLXSched<dataEEW, isOrdered, "WorstCase", "WorstCase", forceMasked=1>;
221*5f757f3fSDimitry Andric
222*5f757f3fSDimitry Andricclass VSXSched<int dataEEW, bit isOrdered, string dataEMUL, string idxEMUL,
223*5f757f3fSDimitry Andric               bit forceMasked = 0> : SchedCommon<
224*5f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVST" # !if(isOrdered, "O", "U") # "X" # dataEEW # "_" # dataEMUL)],
225*5f757f3fSDimitry Andric  [!cast<SchedRead>("ReadVST" # !if(isOrdered, "O", "U") #"X" # dataEEW # "_" # dataEMUL),
226*5f757f3fSDimitry Andric   ReadVSTX, !cast<SchedRead>("ReadVST" # !if(isOrdered, "O", "U") # "XV_" # idxEMUL)],
227*5f757f3fSDimitry Andric  dataEMUL, dataEEW, forceMasked
228*5f757f3fSDimitry Andric>;
229*5f757f3fSDimitry Andricclass VSXSchedMC<int dataEEW, bit isOrdered>:
230*5f757f3fSDimitry Andric  VSXSched<dataEEW, isOrdered, "WorstCase", "WorstCase", forceMasked=1>;
231*5f757f3fSDimitry Andric
232*5f757f3fSDimitry Andric// Unit-stride Fault-Only-First Loads
233*5f757f3fSDimitry Andricclass VLFSched<string lmul, bit forceMasked = 0> : SchedCommon<
234*5f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVLDFF_" # lmul)],
235*5f757f3fSDimitry Andric  [ReadVLDX], mx=lmul, forceMasked=forceMasked
236*5f757f3fSDimitry Andric>;
237*5f757f3fSDimitry Andricclass VLFSchedMC: VLFSched<"WorstCase", forceMasked=1>;
2386e75b2fbSDimitry Andric
239753f127fSDimitry Andric// Unit-Stride Segment Loads and Stores
240*5f757f3fSDimitry Andricclass VLSEGSched<int nf, int eew, string emul, bit forceMasked = 0> : SchedCommon<
241*5f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVLSEG" #nf #"e" #eew #"_" #emul)],
242*5f757f3fSDimitry Andric  [ReadVLDX], emul, eew, forceMasked
243*5f757f3fSDimitry Andric>;
244*5f757f3fSDimitry Andricclass VLSEGSchedMC<int nf, int eew> : VLSEGSched<nf, eew, "WorstCase",
245*5f757f3fSDimitry Andric                                                 forceMasked=1>;
246*5f757f3fSDimitry Andric
247*5f757f3fSDimitry Andricclass VSSEGSched<int nf, int eew, string emul, bit forceMasked = 0> : SchedCommon<
248*5f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVSSEG" # nf # "e" # eew # "_" # emul)],
249*5f757f3fSDimitry Andric  [!cast<SchedRead>("ReadVSTEV_" #emul), ReadVSTX], emul, eew, forceMasked
250*5f757f3fSDimitry Andric>;
251*5f757f3fSDimitry Andricclass VSSEGSchedMC<int nf, int eew> : VSSEGSched<nf, eew, "WorstCase",
252*5f757f3fSDimitry Andric                                                 forceMasked=1>;
253*5f757f3fSDimitry Andric
254*5f757f3fSDimitry Andricclass VLSEGFFSched<int nf, int eew, string emul, bit forceMasked = 0> : SchedCommon<
255*5f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVLSEGFF" # nf # "e" # eew # "_" # emul)],
256*5f757f3fSDimitry Andric  [ReadVLDX], emul, eew, forceMasked
257*5f757f3fSDimitry Andric>;
258*5f757f3fSDimitry Andricclass VLSEGFFSchedMC<int nf, int eew> : VLSEGFFSched<nf, eew, "WorstCase",
259*5f757f3fSDimitry Andric                                                     forceMasked=1>;
260*5f757f3fSDimitry Andric
261753f127fSDimitry Andric// Strided Segment Loads and Stores
262*5f757f3fSDimitry Andricclass VLSSEGSched<int nf, int eew, string emul, bit forceMasked = 0> : SchedCommon<
263*5f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVLSSEG" #nf #"e" #eew #"_" #emul)],
264*5f757f3fSDimitry Andric  [ReadVLDX, ReadVLDSX], emul, eew, forceMasked
265*5f757f3fSDimitry Andric>;
266*5f757f3fSDimitry Andricclass VLSSEGSchedMC<int nf, int eew> : VLSSEGSched<nf, eew, "WorstCase",
267*5f757f3fSDimitry Andric                                                   forceMasked=1>;
268*5f757f3fSDimitry Andric
269*5f757f3fSDimitry Andricclass VSSSEGSched<int nf, int eew, string emul, bit forceMasked = 0> : SchedCommon<
270*5f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVSSSEG" #nf #"e" #eew #"_" #emul)],
271*5f757f3fSDimitry Andric  [!cast<SchedRead>("ReadVSTS" #eew #"V_" #emul),
272*5f757f3fSDimitry Andric   ReadVSTX, ReadVSTSX], emul, eew, forceMasked
273*5f757f3fSDimitry Andric>;
274*5f757f3fSDimitry Andricclass VSSSEGSchedMC<int nf, int eew> : VSSSEGSched<nf, eew, "WorstCase",
275*5f757f3fSDimitry Andric                                                   forceMasked=1>;
276*5f757f3fSDimitry Andric
277753f127fSDimitry Andric// Indexed Segment Loads and Stores
278*5f757f3fSDimitry Andricclass VLXSEGSched<int nf, int eew, bit isOrdered, string emul,
279*5f757f3fSDimitry Andric                  bit forceMasked = 0> : SchedCommon<
280*5f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVL" #!if(isOrdered, "O", "U") #"XSEG" #nf #"e" #eew #"_" #emul)],
281*5f757f3fSDimitry Andric  [ReadVLDX, !cast<SchedRead>("ReadVLD" #!if(isOrdered, "O", "U") #"XV_" #emul)],
282*5f757f3fSDimitry Andric  emul, eew, forceMasked
283*5f757f3fSDimitry Andric>;
284*5f757f3fSDimitry Andricclass VLXSEGSchedMC<int nf, int eew, bit isOrdered>:
285*5f757f3fSDimitry Andric  VLXSEGSched<nf, eew, isOrdered, "WorstCase", forceMasked=1>;
286*5f757f3fSDimitry Andric
287*5f757f3fSDimitry Andric// Passes sew=0 instead of eew=0 since this pseudo does not follow MX_E form.
288*5f757f3fSDimitry Andricclass VSXSEGSched<int nf, int eew, bit isOrdered, string emul,
289*5f757f3fSDimitry Andric                  bit forceMasked = 0> : SchedCommon<
290*5f757f3fSDimitry Andric  [!cast<SchedWrite>("WriteVS" #!if(isOrdered, "O", "U") #"XSEG" #nf #"e" #eew #"_" #emul)],
291*5f757f3fSDimitry Andric  [!cast<SchedRead>("ReadVST" #!if(isOrdered, "O", "U") #"X" #eew #"_" #emul),
292*5f757f3fSDimitry Andric   ReadVSTX, !cast<SchedRead>("ReadVST" #!if(isOrdered, "O", "U") #"XV_" #emul)],
293*5f757f3fSDimitry Andric  emul, sew=0, forceMasked=forceMasked
294*5f757f3fSDimitry Andric>;
295*5f757f3fSDimitry Andricclass VSXSEGSchedMC<int nf, int eew, bit isOrdered>:
296*5f757f3fSDimitry Andric  VSXSEGSched<nf, eew, isOrdered, "WorstCase", forceMasked=1>;
297753f127fSDimitry Andric
2986e75b2fbSDimitry Andric//===----------------------------------------------------------------------===//
2995ffd83dbSDimitry Andric// Instruction class templates
3005ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
3015ffd83dbSDimitry Andric
3025ffd83dbSDimitry Andriclet hasSideEffects = 0, mayLoad = 1, mayStore = 0 in {
303349cc55cSDimitry Andric// unit-stride load vd, (rs1), vm
304349cc55cSDimitry Andricclass VUnitStrideLoad<RISCVWidth width, string opcodestr>
305349cc55cSDimitry Andric    : RVInstVLU<0b000, width.Value{3}, LUMOPUnitStride, width.Value{2-0},
306e8d8bef9SDimitry Andric                (outs VR:$vd),
30706c3fb27SDimitry Andric                (ins GPRMemZeroOffset:$rs1, VMaskOp:$vm), opcodestr, "$vd, ${rs1}$vm">;
3085ffd83dbSDimitry Andric
309349cc55cSDimitry Andriclet vm = 1, RVVConstraint = NoConstraint in {
310349cc55cSDimitry Andric// unit-stride whole register load vl<nf>r.v vd, (rs1)
311349cc55cSDimitry Andricclass VWholeLoad<bits<3> nf, RISCVWidth width, string opcodestr, RegisterClass VRC>
312349cc55cSDimitry Andric    : RVInstVLU<nf, width.Value{3}, LUMOPUnitStrideWholeReg,
31306c3fb27SDimitry Andric                width.Value{2-0}, (outs VRC:$vd), (ins GPRMemZeroOffset:$rs1),
31406c3fb27SDimitry Andric                opcodestr, "$vd, $rs1"> {
315349cc55cSDimitry Andric  let Uses = [];
316349cc55cSDimitry Andric}
317349cc55cSDimitry Andric
318349cc55cSDimitry Andric// unit-stride mask load vd, (rs1)
319349cc55cSDimitry Andricclass VUnitStrideLoadMask<string opcodestr>
320349cc55cSDimitry Andric    : RVInstVLU<0b000, LSWidth8.Value{3}, LUMOPUnitStrideMask, LSWidth8.Value{2-0},
321349cc55cSDimitry Andric                (outs VR:$vd),
32206c3fb27SDimitry Andric                (ins GPRMemZeroOffset:$rs1), opcodestr, "$vd, $rs1">;
323349cc55cSDimitry Andric} // vm = 1, RVVConstraint = NoConstraint
324349cc55cSDimitry Andric
325349cc55cSDimitry Andric// unit-stride fault-only-first load vd, (rs1), vm
326349cc55cSDimitry Andricclass VUnitStrideLoadFF<RISCVWidth width, string opcodestr>
327349cc55cSDimitry Andric    : RVInstVLU<0b000, width.Value{3}, LUMOPUnitStrideFF, width.Value{2-0},
328349cc55cSDimitry Andric                (outs VR:$vd),
32906c3fb27SDimitry Andric                (ins GPRMemZeroOffset:$rs1, VMaskOp:$vm), opcodestr, "$vd, ${rs1}$vm">;
330349cc55cSDimitry Andric
331349cc55cSDimitry Andric// strided load vd, (rs1), rs2, vm
332e8d8bef9SDimitry Andricclass VStridedLoad<RISCVWidth width, string opcodestr>
333e8d8bef9SDimitry Andric    : RVInstVLS<0b000, width.Value{3}, width.Value{2-0},
334e8d8bef9SDimitry Andric                (outs VR:$vd),
33506c3fb27SDimitry Andric                (ins GPRMemZeroOffset:$rs1, GPR:$rs2, VMaskOp:$vm), opcodestr,
33606c3fb27SDimitry Andric                "$vd, $rs1, $rs2$vm">;
3375ffd83dbSDimitry Andric
338349cc55cSDimitry Andric// indexed load vd, (rs1), vs2, vm
3395ffd83dbSDimitry Andricclass VIndexedLoad<RISCVMOP mop, RISCVWidth width, string opcodestr>
340e8d8bef9SDimitry Andric    : RVInstVLX<0b000, width.Value{3}, mop, width.Value{2-0},
341e8d8bef9SDimitry Andric                (outs VR:$vd),
34206c3fb27SDimitry Andric                (ins GPRMemZeroOffset:$rs1, VR:$vs2, VMaskOp:$vm), opcodestr,
34306c3fb27SDimitry Andric                "$vd, $rs1, $vs2$vm">;
3445ffd83dbSDimitry Andric
345349cc55cSDimitry Andric// unit-stride segment load vd, (rs1), vm
346349cc55cSDimitry Andricclass VUnitStrideSegmentLoad<bits<3> nf, RISCVWidth width, string opcodestr>
347349cc55cSDimitry Andric    : RVInstVLU<nf, width.Value{3}, LUMOPUnitStride, width.Value{2-0},
348e8d8bef9SDimitry Andric                (outs VR:$vd),
34906c3fb27SDimitry Andric                (ins GPRMemZeroOffset:$rs1, VMaskOp:$vm), opcodestr, "$vd, ${rs1}$vm">;
350e8d8bef9SDimitry Andric
351349cc55cSDimitry Andric// segment fault-only-first load vd, (rs1), vm
352349cc55cSDimitry Andricclass VUnitStrideSegmentLoadFF<bits<3> nf, RISCVWidth width, string opcodestr>
353349cc55cSDimitry Andric    : RVInstVLU<nf, width.Value{3}, LUMOPUnitStrideFF, width.Value{2-0},
354349cc55cSDimitry Andric                (outs VR:$vd),
35506c3fb27SDimitry Andric                (ins GPRMemZeroOffset:$rs1, VMaskOp:$vm), opcodestr, "$vd, ${rs1}$vm">;
356349cc55cSDimitry Andric
357349cc55cSDimitry Andric// strided segment load vd, (rs1), rs2, vm
358e8d8bef9SDimitry Andricclass VStridedSegmentLoad<bits<3> nf, RISCVWidth width, string opcodestr>
359e8d8bef9SDimitry Andric    : RVInstVLS<nf, width.Value{3}, width.Value{2-0},
360e8d8bef9SDimitry Andric                (outs VR:$vd),
36106c3fb27SDimitry Andric                (ins GPRMemZeroOffset:$rs1, GPR:$rs2, VMaskOp:$vm), opcodestr,
36206c3fb27SDimitry Andric                "$vd, $rs1, $rs2$vm">;
363e8d8bef9SDimitry Andric
364349cc55cSDimitry Andric// indexed segment load vd, (rs1), vs2, vm
365e8d8bef9SDimitry Andricclass VIndexedSegmentLoad<bits<3> nf, RISCVMOP mop, RISCVWidth width,
366e8d8bef9SDimitry Andric                          string opcodestr>
367e8d8bef9SDimitry Andric    : RVInstVLX<nf, width.Value{3}, mop, width.Value{2-0},
368e8d8bef9SDimitry Andric                (outs VR:$vd),
36906c3fb27SDimitry Andric                (ins GPRMemZeroOffset:$rs1, VR:$vs2, VMaskOp:$vm), opcodestr,
37006c3fb27SDimitry Andric                "$vd, $rs1, $vs2$vm">;
3715ffd83dbSDimitry Andric} // hasSideEffects = 0, mayLoad = 1, mayStore = 0
3725ffd83dbSDimitry Andric
3735ffd83dbSDimitry Andriclet hasSideEffects = 0, mayLoad = 0, mayStore = 1 in {
374349cc55cSDimitry Andric// unit-stride store vd, vs3, (rs1), vm
375349cc55cSDimitry Andricclass VUnitStrideStore<RISCVWidth width, string opcodestr>
376349cc55cSDimitry Andric    : RVInstVSU<0b000, width.Value{3}, SUMOPUnitStride, width.Value{2-0},
37706c3fb27SDimitry Andric                (outs), (ins VR:$vs3, GPRMemZeroOffset:$rs1, VMaskOp:$vm), opcodestr,
37806c3fb27SDimitry Andric                "$vs3, ${rs1}$vm">;
3795ffd83dbSDimitry Andric
380349cc55cSDimitry Andriclet vm = 1 in {
3815ffd83dbSDimitry Andric// vs<nf>r.v vd, (rs1)
382fe6060f1SDimitry Andricclass VWholeStore<bits<3> nf, string opcodestr, RegisterClass VRC>
383e8d8bef9SDimitry Andric    : RVInstVSU<nf, 0, SUMOPUnitStrideWholeReg,
38406c3fb27SDimitry Andric                0b000, (outs), (ins VRC:$vs3, GPRMemZeroOffset:$rs1),
38506c3fb27SDimitry Andric                opcodestr, "$vs3, $rs1"> {
3865ffd83dbSDimitry Andric  let Uses = [];
3875ffd83dbSDimitry Andric}
388e8d8bef9SDimitry Andric
389349cc55cSDimitry Andric// unit-stride mask store vd, vs3, (rs1)
390349cc55cSDimitry Andricclass VUnitStrideStoreMask<string opcodestr>
391349cc55cSDimitry Andric    : RVInstVSU<0b000, LSWidth8.Value{3}, SUMOPUnitStrideMask, LSWidth8.Value{2-0},
39206c3fb27SDimitry Andric                (outs), (ins VR:$vs3, GPRMemZeroOffset:$rs1), opcodestr,
39306c3fb27SDimitry Andric                "$vs3, $rs1">;
394349cc55cSDimitry Andric} // vm = 1
395349cc55cSDimitry Andric
396349cc55cSDimitry Andric// strided store vd, vs3, (rs1), rs2, vm
397349cc55cSDimitry Andricclass VStridedStore<RISCVWidth width, string opcodestr>
398349cc55cSDimitry Andric    : RVInstVSS<0b000, width.Value{3}, width.Value{2-0}, (outs),
39906c3fb27SDimitry Andric                (ins VR:$vs3, GPRMemZeroOffset:$rs1, GPR:$rs2, VMaskOp:$vm),
40006c3fb27SDimitry Andric                opcodestr, "$vs3, $rs1, $rs2$vm">;
401349cc55cSDimitry Andric
402349cc55cSDimitry Andric// indexed store vd, vs3, (rs1), vs2, vm
403349cc55cSDimitry Andricclass VIndexedStore<RISCVMOP mop, RISCVWidth width, string opcodestr>
404349cc55cSDimitry Andric    : RVInstVSX<0b000, width.Value{3}, mop, width.Value{2-0}, (outs),
40506c3fb27SDimitry Andric                (ins VR:$vs3, GPRMemZeroOffset:$rs1, VR:$vs2, VMaskOp:$vm),
40606c3fb27SDimitry Andric                opcodestr, "$vs3, $rs1, $vs2$vm">;
407349cc55cSDimitry Andric
408e8d8bef9SDimitry Andric// segment store vd, vs3, (rs1), vm
409e8d8bef9SDimitry Andricclass VUnitStrideSegmentStore<bits<3> nf, RISCVWidth width, string opcodestr>
410e8d8bef9SDimitry Andric    : RVInstVSU<nf, width.Value{3}, SUMOPUnitStride, width.Value{2-0},
41106c3fb27SDimitry Andric                (outs), (ins VR:$vs3, GPRMemZeroOffset:$rs1, VMaskOp:$vm), opcodestr,
41206c3fb27SDimitry Andric                "$vs3, ${rs1}$vm">;
413e8d8bef9SDimitry Andric
414e8d8bef9SDimitry Andric// segment store vd, vs3, (rs1), rs2, vm
415e8d8bef9SDimitry Andricclass VStridedSegmentStore<bits<3> nf, RISCVWidth width, string opcodestr>
416e8d8bef9SDimitry Andric    : RVInstVSS<nf, width.Value{3}, width.Value{2-0}, (outs),
41706c3fb27SDimitry Andric                (ins VR:$vs3, GPRMemZeroOffset:$rs1, GPR:$rs2, VMaskOp:$vm),
41806c3fb27SDimitry Andric                opcodestr, "$vs3, $rs1, $rs2$vm">;
419e8d8bef9SDimitry Andric
420e8d8bef9SDimitry Andric// segment store vd, vs3, (rs1), vs2, vm
421e8d8bef9SDimitry Andricclass VIndexedSegmentStore<bits<3> nf, RISCVMOP mop, RISCVWidth width,
422e8d8bef9SDimitry Andric                           string opcodestr>
423e8d8bef9SDimitry Andric    : RVInstVSX<nf, width.Value{3}, mop, width.Value{2-0}, (outs),
42406c3fb27SDimitry Andric                (ins VR:$vs3, GPRMemZeroOffset:$rs1, VR:$vs2, VMaskOp:$vm),
42506c3fb27SDimitry Andric                opcodestr, "$vs3, $rs1, $vs2$vm">;
4265ffd83dbSDimitry Andric} // hasSideEffects = 0, mayLoad = 0, mayStore = 1
4275ffd83dbSDimitry Andric
4285ffd83dbSDimitry Andriclet hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
4295ffd83dbSDimitry Andric// op vd, vs2, vs1, vm
4305ffd83dbSDimitry Andricclass VALUVV<bits<6> funct6, RISCVVFormat opv, string opcodestr>
431e8d8bef9SDimitry Andric    : RVInstVV<funct6, opv, (outs VR:$vd),
432e8d8bef9SDimitry Andric                (ins VR:$vs2, VR:$vs1, VMaskOp:$vm),
4335ffd83dbSDimitry Andric                opcodestr, "$vd, $vs2, $vs1$vm">;
4345ffd83dbSDimitry Andric
4355ffd83dbSDimitry Andric// op vd, vs2, vs1, v0 (without mask, use v0 as carry input)
4365ffd83dbSDimitry Andricclass VALUmVV<bits<6> funct6, RISCVVFormat opv, string opcodestr>
437e8d8bef9SDimitry Andric    : RVInstVV<funct6, opv, (outs VR:$vd),
438e8d8bef9SDimitry Andric                (ins VR:$vs2, VR:$vs1, VMV0:$v0),
4395ffd83dbSDimitry Andric                opcodestr, "$vd, $vs2, $vs1, v0"> {
4405ffd83dbSDimitry Andric  let vm = 0;
4415ffd83dbSDimitry Andric}
4425ffd83dbSDimitry Andric
4435ffd83dbSDimitry Andric// op vd, vs1, vs2, vm (reverse the order of vs1 and vs2)
444*5f757f3fSDimitry Andricclass VALUrVV<bits<6> funct6, RISCVVFormat opv, string opcodestr,
445*5f757f3fSDimitry Andric              bit EarlyClobber = 0>
446*5f757f3fSDimitry Andric    : RVInstVV<funct6, opv, (outs VR:$vd_wb),
447*5f757f3fSDimitry Andric                (ins VR:$vd, VR:$vs1, VR:$vs2, VMaskOp:$vm),
448*5f757f3fSDimitry Andric                opcodestr, "$vd, $vs1, $vs2$vm"> {
449*5f757f3fSDimitry Andric  let Constraints = !if(EarlyClobber, "@earlyclobber $vd_wb, $vd = $vd_wb",
450*5f757f3fSDimitry Andric                                      "$vd = $vd_wb");
451*5f757f3fSDimitry Andric}
4525ffd83dbSDimitry Andric
453e8d8bef9SDimitry Andric// op vd, vs2, vs1
4545ffd83dbSDimitry Andricclass VALUVVNoVm<bits<6> funct6, RISCVVFormat opv, string opcodestr>
455e8d8bef9SDimitry Andric    : RVInstVV<funct6, opv, (outs VR:$vd),
456e8d8bef9SDimitry Andric               (ins VR:$vs2, VR:$vs1),
4575ffd83dbSDimitry Andric               opcodestr, "$vd, $vs2, $vs1"> {
4585ffd83dbSDimitry Andric  let vm = 1;
4595ffd83dbSDimitry Andric}
4605ffd83dbSDimitry Andric
4615ffd83dbSDimitry Andric// op vd, vs2, rs1, vm
4625ffd83dbSDimitry Andricclass VALUVX<bits<6> funct6, RISCVVFormat opv, string opcodestr>
463e8d8bef9SDimitry Andric    : RVInstVX<funct6, opv, (outs VR:$vd),
464e8d8bef9SDimitry Andric                (ins VR:$vs2, GPR:$rs1, VMaskOp:$vm),
4655ffd83dbSDimitry Andric                opcodestr, "$vd, $vs2, $rs1$vm">;
4665ffd83dbSDimitry Andric
4675ffd83dbSDimitry Andric// op vd, vs2, rs1, v0 (without mask, use v0 as carry input)
4685ffd83dbSDimitry Andricclass VALUmVX<bits<6> funct6, RISCVVFormat opv, string opcodestr>
469e8d8bef9SDimitry Andric    : RVInstVX<funct6, opv, (outs VR:$vd),
470e8d8bef9SDimitry Andric                (ins VR:$vs2, GPR:$rs1, VMV0:$v0),
4715ffd83dbSDimitry Andric                opcodestr, "$vd, $vs2, $rs1, v0"> {
4725ffd83dbSDimitry Andric  let vm = 0;
4735ffd83dbSDimitry Andric}
4745ffd83dbSDimitry Andric
4755ffd83dbSDimitry Andric// op vd, rs1, vs2, vm (reverse the order of rs1 and vs2)
476*5f757f3fSDimitry Andricclass VALUrVX<bits<6> funct6, RISCVVFormat opv, string opcodestr,
477*5f757f3fSDimitry Andric              bit EarlyClobber = 0>
478*5f757f3fSDimitry Andric    : RVInstVX<funct6, opv, (outs VR:$vd_wb),
479*5f757f3fSDimitry Andric                (ins VR:$vd, GPR:$rs1, VR:$vs2, VMaskOp:$vm),
480*5f757f3fSDimitry Andric                opcodestr, "$vd, $rs1, $vs2$vm"> {
481*5f757f3fSDimitry Andric  let Constraints = !if(EarlyClobber, "@earlyclobber $vd_wb, $vd = $vd_wb",
482*5f757f3fSDimitry Andric                                      "$vd = $vd_wb");
483*5f757f3fSDimitry Andric}
4845ffd83dbSDimitry Andric
4855ffd83dbSDimitry Andric// op vd, vs1, vs2
4865ffd83dbSDimitry Andricclass VALUVXNoVm<bits<6> funct6, RISCVVFormat opv, string opcodestr>
487e8d8bef9SDimitry Andric    : RVInstVX<funct6, opv, (outs VR:$vd),
488e8d8bef9SDimitry Andric               (ins VR:$vs2, GPR:$rs1),
4895ffd83dbSDimitry Andric               opcodestr, "$vd, $vs2, $rs1"> {
4905ffd83dbSDimitry Andric  let vm = 1;
4915ffd83dbSDimitry Andric}
4925ffd83dbSDimitry Andric
4935ffd83dbSDimitry Andric// op vd, vs2, imm, vm
4945ffd83dbSDimitry Andricclass VALUVI<bits<6> funct6, string opcodestr, Operand optype = simm5>
495e8d8bef9SDimitry Andric    : RVInstIVI<funct6, (outs VR:$vd),
496e8d8bef9SDimitry Andric                (ins VR:$vs2, optype:$imm, VMaskOp:$vm),
4975ffd83dbSDimitry Andric                opcodestr, "$vd, $vs2, $imm$vm">;
4985ffd83dbSDimitry Andric
4995ffd83dbSDimitry Andric// op vd, vs2, imm, v0 (without mask, use v0 as carry input)
5005ffd83dbSDimitry Andricclass VALUmVI<bits<6> funct6, string opcodestr, Operand optype = simm5>
501e8d8bef9SDimitry Andric    : RVInstIVI<funct6, (outs VR:$vd),
502e8d8bef9SDimitry Andric                (ins VR:$vs2, optype:$imm, VMV0:$v0),
5035ffd83dbSDimitry Andric                opcodestr, "$vd, $vs2, $imm, v0"> {
5045ffd83dbSDimitry Andric  let vm = 0;
5055ffd83dbSDimitry Andric}
5065ffd83dbSDimitry Andric
5075ffd83dbSDimitry Andric// op vd, vs2, imm, vm
5085ffd83dbSDimitry Andricclass VALUVINoVm<bits<6> funct6, string opcodestr, Operand optype = simm5>
509e8d8bef9SDimitry Andric    : RVInstIVI<funct6, (outs VR:$vd),
510e8d8bef9SDimitry Andric                (ins VR:$vs2, optype:$imm),
5115ffd83dbSDimitry Andric                opcodestr, "$vd, $vs2, $imm"> {
5125ffd83dbSDimitry Andric  let vm = 1;
5135ffd83dbSDimitry Andric}
5145ffd83dbSDimitry Andric
5155ffd83dbSDimitry Andric// op vd, vs2, rs1, vm (Float)
5165ffd83dbSDimitry Andricclass VALUVF<bits<6> funct6, RISCVVFormat opv, string opcodestr>
517e8d8bef9SDimitry Andric    : RVInstVX<funct6, opv, (outs VR:$vd),
518e8d8bef9SDimitry Andric                (ins VR:$vs2, FPR32:$rs1, VMaskOp:$vm),
5195ffd83dbSDimitry Andric                opcodestr, "$vd, $vs2, $rs1$vm">;
5205ffd83dbSDimitry Andric
5215ffd83dbSDimitry Andric// op vd, rs1, vs2, vm (Float) (with mask, reverse the order of rs1 and vs2)
522*5f757f3fSDimitry Andricclass VALUrVF<bits<6> funct6, RISCVVFormat opv, string opcodestr,
523*5f757f3fSDimitry Andric              bit EarlyClobber = 0>
524*5f757f3fSDimitry Andric    : RVInstVX<funct6, opv, (outs VR:$vd_wb),
525*5f757f3fSDimitry Andric                (ins VR:$vd, FPR32:$rs1, VR:$vs2, VMaskOp:$vm),
526*5f757f3fSDimitry Andric                opcodestr, "$vd, $rs1, $vs2$vm"> {
527*5f757f3fSDimitry Andric  let Constraints = !if(EarlyClobber, "@earlyclobber $vd_wb, $vd = $vd_wb",
528*5f757f3fSDimitry Andric                                      "$vd = $vd_wb");
529*5f757f3fSDimitry Andric}
5305ffd83dbSDimitry Andric
5315ffd83dbSDimitry Andric// op vd, vs2, vm (use vs1 as instruction encoding)
5325ffd83dbSDimitry Andricclass VALUVs2<bits<6> funct6, bits<5> vs1, RISCVVFormat opv, string opcodestr>
533e8d8bef9SDimitry Andric    : RVInstV<funct6, vs1, opv, (outs VR:$vd),
534e8d8bef9SDimitry Andric               (ins VR:$vs2, VMaskOp:$vm),
5355ffd83dbSDimitry Andric               opcodestr, "$vd, $vs2$vm">;
53606c3fb27SDimitry Andric
53706c3fb27SDimitry Andric// op vd, vs2 (use vs1 as instruction encoding)
53806c3fb27SDimitry Andricclass VALUVs2NoVm<bits<6> funct6, bits<5> vs1, RISCVVFormat opv, string opcodestr>
53906c3fb27SDimitry Andric    : RVInstV<funct6, vs1, opv, (outs VR:$vd),
54006c3fb27SDimitry Andric              (ins VR:$vs2), opcodestr,
54106c3fb27SDimitry Andric              "$vd, $vs2"> {
54206c3fb27SDimitry Andric  let vm = 1;
54306c3fb27SDimitry Andric}
5445ffd83dbSDimitry Andric} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
5455ffd83dbSDimitry Andric
5465ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
5475ffd83dbSDimitry Andric// Combination of instruction classes.
5485ffd83dbSDimitry Andric// Use these multiclasses to define instructions more easily.
5495ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
55004eeddc0SDimitry Andric
551*5f757f3fSDimitry Andricmulticlass VIndexLoadStore<int eew> {
552*5f757f3fSDimitry Andric  defvar w = !cast<RISCVWidth>("LSWidth" # eew);
55304eeddc0SDimitry Andric
554*5f757f3fSDimitry Andric  def VLUXEI # eew # _V :
555*5f757f3fSDimitry Andric    VIndexedLoad<MOPLDIndexedUnord, w, "vluxei" # eew # ".v">,
556*5f757f3fSDimitry Andric    VLXSchedMC<eew, isOrdered=0>;
557*5f757f3fSDimitry Andric  def VLOXEI # eew # _V :
558*5f757f3fSDimitry Andric    VIndexedLoad<MOPLDIndexedOrder, w, "vloxei" # eew # ".v">,
559*5f757f3fSDimitry Andric    VLXSchedMC<eew, isOrdered=1>;
56004eeddc0SDimitry Andric
561*5f757f3fSDimitry Andric  def VSUXEI # eew # _V :
562*5f757f3fSDimitry Andric    VIndexedStore<MOPSTIndexedUnord, w, "vsuxei" # eew # ".v">,
563*5f757f3fSDimitry Andric    VSXSchedMC<eew, isOrdered=0>;
564*5f757f3fSDimitry Andric  def VSOXEI # eew # _V :
565*5f757f3fSDimitry Andric    VIndexedStore<MOPSTIndexedOrder, w, "vsoxei" # eew # ".v">,
566*5f757f3fSDimitry Andric    VSXSchedMC<eew, isOrdered=1>;
56704eeddc0SDimitry Andric}
56804eeddc0SDimitry Andric
56906c3fb27SDimitry Andricmulticlass VALU_IV_V<string opcodestr, bits<6> funct6> {
57006c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".vv">,
571*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIALUV", "ReadVIALUV", "ReadVIALUV">;
57206c3fb27SDimitry Andric}
57306c3fb27SDimitry Andric
57406c3fb27SDimitry Andricmulticlass VALU_IV_X<string opcodestr, bits<6> funct6> {
57506c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".vx">,
576*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIALUX", "ReadVIALUV", "ReadVIALUX">;
57706c3fb27SDimitry Andric}
57806c3fb27SDimitry Andric
57906c3fb27SDimitry Andricmulticlass VALU_IV_I<string opcodestr, bits<6> funct6> {
58006c3fb27SDimitry Andric  def I  : VALUVI<funct6, opcodestr # ".vi", simm5>,
581*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVIALUI", "ReadVIALUV">;
5825ffd83dbSDimitry Andric}
5835ffd83dbSDimitry Andric
58406c3fb27SDimitry Andricmulticlass VALU_IV_V_X_I<string opcodestr, bits<6> funct6>
58506c3fb27SDimitry Andric    : VALU_IV_V<opcodestr, funct6>,
58606c3fb27SDimitry Andric      VALU_IV_X<opcodestr, funct6>,
58706c3fb27SDimitry Andric      VALU_IV_I<opcodestr, funct6>;
5885ffd83dbSDimitry Andric
58906c3fb27SDimitry Andricmulticlass VALU_IV_V_X<string opcodestr, bits<6> funct6>
59006c3fb27SDimitry Andric    : VALU_IV_V<opcodestr, funct6>,
59106c3fb27SDimitry Andric      VALU_IV_X<opcodestr, funct6>;
5925ffd83dbSDimitry Andric
59306c3fb27SDimitry Andricmulticlass VALU_IV_X_I<string opcodestr, bits<6> funct6>
59406c3fb27SDimitry Andric    : VALU_IV_X<opcodestr, funct6>,
59506c3fb27SDimitry Andric      VALU_IV_I<opcodestr, funct6>;
59606c3fb27SDimitry Andric
59706c3fb27SDimitry Andricmulticlass VALU_MV_V_X<string opcodestr, bits<6> funct6, string vw> {
5986e75b2fbSDimitry Andric  def V  : VALUVV<funct6, OPMVV, opcodestr # "." # vw # "v">,
599*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIWALUV", "ReadVIWALUV", "ReadVIWALUV">;
6006e75b2fbSDimitry Andric  def X  : VALUVX<funct6, OPMVX, opcodestr # "." # vw # "x">,
601*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIWALUX", "ReadVIWALUV", "ReadVIWALUX">;
6025ffd83dbSDimitry Andric}
6035ffd83dbSDimitry Andric
60406c3fb27SDimitry Andricmulticlass VMAC_MV_V_X<string opcodestr, bits<6> funct6> {
60506c3fb27SDimitry Andric  def V : VALUrVV<funct6, OPMVV, opcodestr # ".vv">,
606*5f757f3fSDimitry Andric          SchedTernaryMC<"WriteVIMulAddV", "ReadVIMulAddV", "ReadVIMulAddV",
607*5f757f3fSDimitry Andric                         "ReadVIMulAddV">;
60806c3fb27SDimitry Andric  def X : VALUrVX<funct6, OPMVX, opcodestr # ".vx">,
609*5f757f3fSDimitry Andric          SchedTernaryMC<"WriteVIMulAddX", "ReadVIMulAddV", "ReadVIMulAddX",
610*5f757f3fSDimitry Andric                         "ReadVIMulAddV">;
6115ffd83dbSDimitry Andric}
6125ffd83dbSDimitry Andric
61306c3fb27SDimitry Andricmulticlass VWMAC_MV_X<string opcodestr, bits<6> funct6> {
614*5f757f3fSDimitry Andric  let RVVConstraint = WidenV in
61506c3fb27SDimitry Andric  def X : VALUrVX<funct6, OPMVX, opcodestr # ".vx">,
616*5f757f3fSDimitry Andric          SchedTernaryMC<"WriteVIWMulAddX", "ReadVIWMulAddV", "ReadVIWMulAddX",
617*5f757f3fSDimitry Andric                         "ReadVIWMulAddV">;
6185ffd83dbSDimitry Andric}
6195ffd83dbSDimitry Andric
62006c3fb27SDimitry Andricmulticlass VWMAC_MV_V_X<string opcodestr, bits<6> funct6>
62106c3fb27SDimitry Andric   : VWMAC_MV_X<opcodestr, funct6> {
622*5f757f3fSDimitry Andric  let RVVConstraint = WidenV in
623*5f757f3fSDimitry Andric  def V : VALUrVV<funct6, OPMVV, opcodestr # ".vv", EarlyClobber=1>,
624*5f757f3fSDimitry Andric          SchedTernaryMC<"WriteVIWMulAddV", "ReadVIWMulAddV", "ReadVIWMulAddV",
625*5f757f3fSDimitry Andric                         "ReadVIWMulAddV">;
6265ffd83dbSDimitry Andric}
6275ffd83dbSDimitry Andric
6285ffd83dbSDimitry Andricmulticlass VALU_MV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
6296e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPMVV, opcodestr>,
630*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVExtV", "ReadVExtV">;
6316e75b2fbSDimitry Andric}
6326e75b2fbSDimitry Andric
6336e75b2fbSDimitry Andricmulticlass VMRG_IV_V_X_I<string opcodestr, bits<6> funct6> {
6346e75b2fbSDimitry Andric  def VM : VALUmVV<funct6, OPIVV, opcodestr # ".vvm">,
635*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIMergeV", "ReadVIMergeV", "ReadVIMergeV">;
6366e75b2fbSDimitry Andric  def XM : VALUmVX<funct6, OPIVX, opcodestr # ".vxm">,
637*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIMergeX", "ReadVIMergeV", "ReadVIMergeX">;
6386e75b2fbSDimitry Andric  def IM : VALUmVI<funct6, opcodestr # ".vim">,
639*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVIMergeI", "ReadVIMergeV">;
6405ffd83dbSDimitry Andric}
6415ffd83dbSDimitry Andric
6425ffd83dbSDimitry Andricmulticlass VALUm_IV_V_X<string opcodestr, bits<6> funct6> {
6436e75b2fbSDimitry Andric  def VM : VALUmVV<funct6, OPIVV, opcodestr # ".vvm">,
644*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVICALUV", "ReadVICALUV", "ReadVICALUV">;
6456e75b2fbSDimitry Andric  def XM : VALUmVX<funct6, OPIVX, opcodestr # ".vxm">,
646*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVICALUX", "ReadVICALUV", "ReadVICALUX">;
6475ffd83dbSDimitry Andric}
6485ffd83dbSDimitry Andric
64906c3fb27SDimitry Andricmulticlass VALUm_IV_V_X_I<string opcodestr, bits<6> funct6>
65006c3fb27SDimitry Andric    : VALUm_IV_V_X<opcodestr, funct6> {
65106c3fb27SDimitry Andric  def IM : VALUmVI<funct6, opcodestr # ".vim">,
652*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVICALUI", "ReadVICALUV">;
6535ffd83dbSDimitry Andric}
6545ffd83dbSDimitry Andric
6555ffd83dbSDimitry Andricmulticlass VALUNoVm_IV_V_X<string opcodestr, bits<6> funct6> {
6566e75b2fbSDimitry Andric  def V : VALUVVNoVm<funct6, OPIVV, opcodestr # ".vv">,
657*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVICALUV", "ReadVICALUV", "ReadVICALUV",
658*5f757f3fSDimitry Andric                        forceMasked=0>;
6596e75b2fbSDimitry Andric  def X : VALUVXNoVm<funct6, OPIVX, opcodestr # ".vx">,
660*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVICALUX", "ReadVICALUV", "ReadVICALUX",
661*5f757f3fSDimitry Andric                        forceMasked=0>;
6625ffd83dbSDimitry Andric}
6635ffd83dbSDimitry Andric
66406c3fb27SDimitry Andricmulticlass VALUNoVm_IV_V_X_I<string opcodestr, bits<6> funct6>
66506c3fb27SDimitry Andric   : VALUNoVm_IV_V_X<opcodestr, funct6> {
66606c3fb27SDimitry Andric  def I : VALUVINoVm<funct6, opcodestr # ".vi", simm5>,
667*5f757f3fSDimitry Andric          SchedUnaryMC<"WriteVICALUI", "ReadVICALUV", forceMasked=0>;
66806c3fb27SDimitry Andric}
66906c3fb27SDimitry Andric
67006c3fb27SDimitry Andricmulticlass VALU_FV_F<string opcodestr, bits<6> funct6> {
67106c3fb27SDimitry Andric  def F : VALUVF<funct6, OPFVF, opcodestr # ".vf">,
672*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFALUF", "ReadVFALUV", "ReadVFALUF">;
67306c3fb27SDimitry Andric}
67406c3fb27SDimitry Andric
67506c3fb27SDimitry Andricmulticlass VALU_FV_V_F<string opcodestr, bits<6> funct6>
67606c3fb27SDimitry Andric    : VALU_FV_F<opcodestr, funct6> {
67706c3fb27SDimitry Andric  def V : VALUVV<funct6, OPFVV, opcodestr # ".vv">,
678*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFALUV", "ReadVFALUV", "ReadVFALUV">;
67906c3fb27SDimitry Andric}
68006c3fb27SDimitry Andric
68106c3fb27SDimitry Andricmulticlass VWALU_FV_V_F<string opcodestr, bits<6> funct6, string vw> {
6826e75b2fbSDimitry Andric  def V : VALUVV<funct6, OPFVV, opcodestr # "." # vw # "v">,
683*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFWALUV", "ReadVFWALUV", "ReadVFWALUV">;
6846e75b2fbSDimitry Andric  def F : VALUVF<funct6, OPFVF, opcodestr # "." # vw # "f">,
685*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFWALUF", "ReadVFWALUV", "ReadVFWALUF">;
6865ffd83dbSDimitry Andric}
6875ffd83dbSDimitry Andric
68806c3fb27SDimitry Andricmulticlass VMUL_FV_V_F<string opcodestr, bits<6> funct6> {
68906c3fb27SDimitry Andric  def V : VALUVV<funct6, OPFVV, opcodestr # ".vv">,
690*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFMulV", "ReadVFMulV", "ReadVFMulV">;
69106c3fb27SDimitry Andric  def F : VALUVF<funct6, OPFVF, opcodestr # ".vf">,
692*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFMulF", "ReadVFMulV", "ReadVFMulF">;
6935ffd83dbSDimitry Andric}
6945ffd83dbSDimitry Andric
69506c3fb27SDimitry Andricmulticlass VDIV_FV_F<string opcodestr, bits<6> funct6> {
69606c3fb27SDimitry Andric  def F : VALUVF<funct6, OPFVF, opcodestr # ".vf">,
697*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFDivF", "ReadVFDivV", "ReadVFDivF">;
6985ffd83dbSDimitry Andric}
6995ffd83dbSDimitry Andric
70006c3fb27SDimitry Andricmulticlass VDIV_FV_V_F<string opcodestr, bits<6> funct6>
70106c3fb27SDimitry Andric    : VDIV_FV_F<opcodestr, funct6> {
70206c3fb27SDimitry Andric  def V : VALUVV<funct6, OPFVV, opcodestr # ".vv">,
703*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFDivV", "ReadVFDivV", "ReadVFDivV">;
7045ffd83dbSDimitry Andric}
7055ffd83dbSDimitry Andric
70606c3fb27SDimitry Andricmulticlass VWMUL_FV_V_F<string opcodestr, bits<6> funct6> {
70706c3fb27SDimitry Andric  def V : VALUVV<funct6, OPFVV, opcodestr # ".vv">,
708*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFWMulV", "ReadVFWMulV", "ReadVFWMulV">;
70906c3fb27SDimitry Andric  def F : VALUVF<funct6, OPFVF, opcodestr # ".vf">,
710*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFWMulF", "ReadVFWMulV", "ReadVFWMulF">;
7116e75b2fbSDimitry Andric}
7126e75b2fbSDimitry Andric
71306c3fb27SDimitry Andricmulticlass VMAC_FV_V_F<string opcodestr, bits<6> funct6> {
71406c3fb27SDimitry Andric  def V : VALUrVV<funct6, OPFVV, opcodestr # ".vv">,
715*5f757f3fSDimitry Andric          SchedTernaryMC<"WriteVFMulAddV", "ReadVFMulAddV", "ReadVFMulAddV",
716*5f757f3fSDimitry Andric                         "ReadVFMulAddV">;
71706c3fb27SDimitry Andric  def F : VALUrVF<funct6, OPFVF, opcodestr # ".vf">,
718*5f757f3fSDimitry Andric          SchedTernaryMC<"WriteVFMulAddF", "ReadVFMulAddV", "ReadVFMulAddF",
719*5f757f3fSDimitry Andric                         "ReadVFMulAddV">;
7206e75b2fbSDimitry Andric}
7216e75b2fbSDimitry Andric
72206c3fb27SDimitry Andricmulticlass VWMAC_FV_V_F<string opcodestr, bits<6> funct6> {
723*5f757f3fSDimitry Andric  let RVVConstraint = WidenV in {
724*5f757f3fSDimitry Andric  def V : VALUrVV<funct6, OPFVV, opcodestr # ".vv", EarlyClobber=1>,
725*5f757f3fSDimitry Andric          SchedTernaryMC<"WriteVFWMulAddV", "ReadVFWMulAddV", "ReadVFWMulAddV",
726*5f757f3fSDimitry Andric                         "ReadVFWMulAddV">;
727*5f757f3fSDimitry Andric  def F : VALUrVF<funct6, OPFVF, opcodestr # ".vf", EarlyClobber=1>,
728*5f757f3fSDimitry Andric          SchedTernaryMC<"WriteVFWMulAddF", "ReadVFWMulAddV", "ReadVFWMulAddF",
729*5f757f3fSDimitry Andric                         "ReadVFWMulAddV">;
730*5f757f3fSDimitry Andric  }
7316e75b2fbSDimitry Andric}
7326e75b2fbSDimitry Andric
7336e75b2fbSDimitry Andricmulticlass VSQR_FV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7346e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
735*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFSqrtV", "ReadVFSqrtV">;
7366e75b2fbSDimitry Andric}
7376e75b2fbSDimitry Andric
7386e75b2fbSDimitry Andricmulticlass VRCP_FV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7396e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
740*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFRecpV", "ReadVFRecpV">;
7416e75b2fbSDimitry Andric}
7426e75b2fbSDimitry Andric
74306c3fb27SDimitry Andricmulticlass VMINMAX_FV_V_F<string opcodestr, bits<6> funct6> {
74406c3fb27SDimitry Andric  def V : VALUVV<funct6, OPFVV, opcodestr # ".vv">,
745*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFMinMaxV", "ReadVFMinMaxV", "ReadVFMinMaxV">;
74606c3fb27SDimitry Andric  def F : VALUVF<funct6, OPFVF, opcodestr # ".vf">,
747*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFMinMaxF", "ReadVFMinMaxV", "ReadVFMinMaxF">;
7486e75b2fbSDimitry Andric}
7496e75b2fbSDimitry Andric
75006c3fb27SDimitry Andricmulticlass VCMP_FV_F<string opcodestr, bits<6> funct6> {
75106c3fb27SDimitry Andric  def F : VALUVF<funct6, OPFVF, opcodestr # ".vf">,
752*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFCmpF", "ReadVFCmpV", "ReadVFCmpF">;
7536e75b2fbSDimitry Andric}
7546e75b2fbSDimitry Andric
75506c3fb27SDimitry Andricmulticlass VCMP_FV_V_F<string opcodestr, bits<6> funct6>
75606c3fb27SDimitry Andric    : VCMP_FV_F<opcodestr, funct6> {
75706c3fb27SDimitry Andric  def V : VALUVV<funct6, OPFVV, opcodestr # ".vv">,
758*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFCmpV", "ReadVFCmpV", "ReadVFCmpV">;
75906c3fb27SDimitry Andric}
76006c3fb27SDimitry Andric
76106c3fb27SDimitry Andricmulticlass VSGNJ_FV_V_F<string opcodestr, bits<6> funct6> {
76206c3fb27SDimitry Andric  def V : VALUVV<funct6, OPFVV, opcodestr # ".vv">,
763*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFSgnjV", "ReadVFSgnjV", "ReadVFSgnjV">;
76406c3fb27SDimitry Andric  def F : VALUVF<funct6, OPFVF, opcodestr # ".vf">,
765*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFSgnjF", "ReadVFSgnjV", "ReadVFSgnjF">;
7666e75b2fbSDimitry Andric}
7676e75b2fbSDimitry Andric
7686e75b2fbSDimitry Andricmulticlass VCLS_FV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7696e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
770*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFClassV", "ReadVFClassV">;
7716e75b2fbSDimitry Andric}
7726e75b2fbSDimitry Andric
7736e75b2fbSDimitry Andricmulticlass VCVTF_IV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7746e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
775*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFCvtIToFV", "ReadVFCvtIToFV">;
7766e75b2fbSDimitry Andric}
7776e75b2fbSDimitry Andric
7786e75b2fbSDimitry Andricmulticlass VCVTI_FV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7796e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
780*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFCvtFToIV", "ReadVFCvtFToIV">;
7816e75b2fbSDimitry Andric}
7826e75b2fbSDimitry Andric
7836e75b2fbSDimitry Andricmulticlass VWCVTF_IV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7846e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
785*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFWCvtIToFV", "ReadVFWCvtIToFV">;
7866e75b2fbSDimitry Andric}
7876e75b2fbSDimitry Andric
7886e75b2fbSDimitry Andricmulticlass VWCVTI_FV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7896e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
790*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFWCvtFToIV", "ReadVFWCvtFToIV">;
7916e75b2fbSDimitry Andric}
7926e75b2fbSDimitry Andric
7936e75b2fbSDimitry Andricmulticlass VWCVTF_FV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7946e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
795*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFWCvtFToFV", "ReadVFWCvtFToFV">;
7966e75b2fbSDimitry Andric}
7976e75b2fbSDimitry Andric
7986e75b2fbSDimitry Andricmulticlass VNCVTF_IV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
7996e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
800*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFNCvtIToFV", "ReadVFNCvtIToFV">;
8016e75b2fbSDimitry Andric}
8026e75b2fbSDimitry Andric
8036e75b2fbSDimitry Andricmulticlass VNCVTI_FV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
8046e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
805*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFNCvtFToIV", "ReadVFNCvtFToIV">;
8066e75b2fbSDimitry Andric}
8076e75b2fbSDimitry Andric
8086e75b2fbSDimitry Andricmulticlass VNCVTF_FV_VS2<string opcodestr, bits<6> funct6, bits<5> vs1> {
8096e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPFVV, opcodestr>,
810*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVFNCvtFToFV", "ReadVFNCvtFToFV">;
8116e75b2fbSDimitry Andric}
8126e75b2fbSDimitry Andric
8136e75b2fbSDimitry Andricmulticlass VRED_MV_V<string opcodestr, bits<6> funct6> {
8146e75b2fbSDimitry Andric  def _VS : VALUVV<funct6, OPMVV, opcodestr # ".vs">,
815*5f757f3fSDimitry Andric            SchedReductionMC<"WriteVIRedV_From", "ReadVIRedV", "ReadVIRedV0">;
81606c3fb27SDimitry Andric}
81706c3fb27SDimitry Andric
81806c3fb27SDimitry Andricmulticlass VREDMINMAX_MV_V<string opcodestr, bits<6> funct6> {
81906c3fb27SDimitry Andric  def _VS : VALUVV<funct6, OPMVV, opcodestr # ".vs">,
820*5f757f3fSDimitry Andric            SchedReductionMC<"WriteVIRedMinMaxV_From", "ReadVIRedV", "ReadVIRedV0">;
8216e75b2fbSDimitry Andric}
8226e75b2fbSDimitry Andric
8236e75b2fbSDimitry Andricmulticlass VWRED_IV_V<string opcodestr, bits<6> funct6> {
8246e75b2fbSDimitry Andric  def _VS : VALUVV<funct6, OPIVV, opcodestr # ".vs">,
825*5f757f3fSDimitry Andric            SchedReductionMC<"WriteVIWRedV_From", "ReadVIWRedV", "ReadVIWRedV0">;
8266e75b2fbSDimitry Andric}
8276e75b2fbSDimitry Andric
8286e75b2fbSDimitry Andricmulticlass VRED_FV_V<string opcodestr, bits<6> funct6> {
8296e75b2fbSDimitry Andric  def _VS : VALUVV<funct6, OPFVV, opcodestr # ".vs">,
830*5f757f3fSDimitry Andric            SchedReductionMC<"WriteVFRedV_From", "ReadVFRedV", "ReadVFRedV0">;
83106c3fb27SDimitry Andric}
83206c3fb27SDimitry Andric
83306c3fb27SDimitry Andricmulticlass VREDMINMAX_FV_V<string opcodestr, bits<6> funct6> {
83406c3fb27SDimitry Andric  def _VS : VALUVV<funct6, OPFVV, opcodestr # ".vs">,
835*5f757f3fSDimitry Andric            SchedReductionMC<"WriteVFRedMinMaxV_From", "ReadVFRedV", "ReadVFRedV0">;
8366e75b2fbSDimitry Andric}
8376e75b2fbSDimitry Andric
8386e75b2fbSDimitry Andricmulticlass VREDO_FV_V<string opcodestr, bits<6> funct6> {
8396e75b2fbSDimitry Andric  def _VS : VALUVV<funct6, OPFVV, opcodestr # ".vs">,
840*5f757f3fSDimitry Andric            SchedReductionMC<"WriteVFRedOV_From", "ReadVFRedOV", "ReadVFRedOV0">;
8416e75b2fbSDimitry Andric}
8426e75b2fbSDimitry Andric
8436e75b2fbSDimitry Andricmulticlass VWRED_FV_V<string opcodestr, bits<6> funct6> {
8446e75b2fbSDimitry Andric  def _VS : VALUVV<funct6, OPFVV, opcodestr # ".vs">,
845*5f757f3fSDimitry Andric            SchedReductionMC<"WriteVFWRedV_From", "ReadVFWRedV", "ReadVFWRedV0">;
8466e75b2fbSDimitry Andric}
8476e75b2fbSDimitry Andric
8486e75b2fbSDimitry Andricmulticlass VWREDO_FV_V<string opcodestr, bits<6> funct6> {
8496e75b2fbSDimitry Andric  def _VS : VALUVV<funct6, OPFVV, opcodestr # ".vs">,
850*5f757f3fSDimitry Andric            SchedReductionMC<"WriteVFWRedOV_From", "ReadVFWRedOV", "ReadVFWRedOV0">;
8516e75b2fbSDimitry Andric}
8526e75b2fbSDimitry Andric
8536e75b2fbSDimitry Andricmulticlass VMALU_MV_Mask<string opcodestr, bits<6> funct6, string vm = "v"> {
8546e75b2fbSDimitry Andric  def M : VALUVVNoVm<funct6, OPMVV, opcodestr #"." #vm #"m">,
855*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVMALUV", "ReadVMALUV", "ReadVMALUV",
856*5f757f3fSDimitry Andric                        forceMasked=0>;
8576e75b2fbSDimitry Andric}
8586e75b2fbSDimitry Andric
8596e75b2fbSDimitry Andricmulticlass VMSFS_MV_V<string opcodestr, bits<6> funct6, bits<5> vs1> {
8606e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPMVV, opcodestr>,
861*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVMSFSV", "ReadVMSFSV">;
8626e75b2fbSDimitry Andric}
8636e75b2fbSDimitry Andric
8646e75b2fbSDimitry Andricmulticlass VMIOT_MV_V<string opcodestr, bits<6> funct6, bits<5> vs1> {
8656e75b2fbSDimitry Andric  def "" : VALUVs2<funct6, vs1, OPMVV, opcodestr>,
866*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVMIotV", "ReadVMIotV">;
8676e75b2fbSDimitry Andric}
8686e75b2fbSDimitry Andric
86906c3fb27SDimitry Andricmulticlass VSHT_IV_V_X_I<string opcodestr, bits<6> funct6> {
87006c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".vv">,
871*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVShiftV", "ReadVShiftV", "ReadVShiftV">;
87206c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".vx">,
873*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVShiftX", "ReadVShiftV", "ReadVShiftX">;
87406c3fb27SDimitry Andric  def I  : VALUVI<funct6, opcodestr # ".vi", uimm5>,
875*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVShiftI", "ReadVShiftV">;
8766e75b2fbSDimitry Andric}
8776e75b2fbSDimitry Andric
87806c3fb27SDimitry Andricmulticlass VNSHT_IV_V_X_I<string opcodestr, bits<6> funct6> {
87906c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".wv">,
880*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVNShiftV", "ReadVNShiftV", "ReadVNShiftV">;
88106c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".wx">,
882*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVNShiftX", "ReadVNShiftV", "ReadVNShiftX">;
88306c3fb27SDimitry Andric  def I  : VALUVI<funct6, opcodestr # ".wi", uimm5>,
884*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVNShiftI", "ReadVNShiftV">;
8856e75b2fbSDimitry Andric}
8866e75b2fbSDimitry Andric
88706c3fb27SDimitry Andricmulticlass VMINMAX_IV_V_X<string opcodestr, bits<6> funct6> {
88806c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".vv">,
889*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIMinMaxV", "ReadVIMinMaxV", "ReadVIMinMaxV">;
89006c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".vx">,
891*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIMinMaxX", "ReadVIMinMaxV", "ReadVIMinMaxX">;
89206c3fb27SDimitry Andric}
89306c3fb27SDimitry Andric
89406c3fb27SDimitry Andricmulticlass VCMP_IV_V<string opcodestr, bits<6> funct6> {
89506c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".vv">,
896*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVICmpV", "ReadVICmpV", "ReadVICmpV">;
89706c3fb27SDimitry Andric}
89806c3fb27SDimitry Andric
89906c3fb27SDimitry Andricmulticlass VCMP_IV_X<string opcodestr, bits<6> funct6> {
90006c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".vx">,
901*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVICmpX", "ReadVICmpV", "ReadVICmpX">;
90206c3fb27SDimitry Andric}
90306c3fb27SDimitry Andric
90406c3fb27SDimitry Andricmulticlass VCMP_IV_I<string opcodestr, bits<6> funct6> {
90506c3fb27SDimitry Andric  def I  : VALUVI<funct6, opcodestr # ".vi", simm5>,
906*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVICmpI", "ReadVICmpV">;
9076e75b2fbSDimitry Andric}
9086e75b2fbSDimitry Andric
90906c3fb27SDimitry Andricmulticlass VCMP_IV_V_X_I<string opcodestr, bits<6> funct6>
91006c3fb27SDimitry Andric    : VCMP_IV_V<opcodestr, funct6>,
91106c3fb27SDimitry Andric      VCMP_IV_X<opcodestr, funct6>,
91206c3fb27SDimitry Andric      VCMP_IV_I<opcodestr, funct6>;
91306c3fb27SDimitry Andric
91406c3fb27SDimitry Andricmulticlass VCMP_IV_X_I<string opcodestr, bits<6> funct6>
91506c3fb27SDimitry Andric    : VCMP_IV_X<opcodestr, funct6>,
91606c3fb27SDimitry Andric      VCMP_IV_I<opcodestr, funct6>;
91706c3fb27SDimitry Andric
91806c3fb27SDimitry Andricmulticlass VCMP_IV_V_X<string opcodestr, bits<6> funct6>
91906c3fb27SDimitry Andric    : VCMP_IV_V<opcodestr, funct6>,
92006c3fb27SDimitry Andric      VCMP_IV_X<opcodestr, funct6>;
92106c3fb27SDimitry Andric
92206c3fb27SDimitry Andricmulticlass VMUL_MV_V_X<string opcodestr, bits<6> funct6> {
92306c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPMVV, opcodestr # ".vv">,
924*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIMulV", "ReadVIMulV", "ReadVIMulV">;
92506c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPMVX, opcodestr # ".vx">,
926*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIMulX", "ReadVIMulV", "ReadVIMulX">;
92706c3fb27SDimitry Andric}
92806c3fb27SDimitry Andric
92906c3fb27SDimitry Andricmulticlass VWMUL_MV_V_X<string opcodestr, bits<6> funct6> {
93006c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPMVV, opcodestr # ".vv">,
931*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIWMulV", "ReadVIWMulV", "ReadVIWMulV">;
93206c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPMVX, opcodestr # ".vx">,
933*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIWMulX", "ReadVIWMulV", "ReadVIWMulX">;
93406c3fb27SDimitry Andric}
93506c3fb27SDimitry Andric
93606c3fb27SDimitry Andricmulticlass VDIV_MV_V_X<string opcodestr, bits<6> funct6> {
93706c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPMVV, opcodestr # ".vv">,
938*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIDivV", "ReadVIDivV", "ReadVIDivV">;
93906c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPMVX, opcodestr # ".vx">,
940*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVIDivX", "ReadVIDivV", "ReadVIDivX">;
94106c3fb27SDimitry Andric}
94206c3fb27SDimitry Andric
94306c3fb27SDimitry Andricmulticlass VSALU_IV_V_X<string opcodestr, bits<6> funct6> {
94406c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".vv">,
945*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVSALUV", "ReadVSALUV", "ReadVSALUV">;
94606c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".vx">,
947*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVSALUX", "ReadVSALUV", "ReadVSALUX">;
94806c3fb27SDimitry Andric}
94906c3fb27SDimitry Andric
95006c3fb27SDimitry Andricmulticlass VSALU_IV_V_X_I<string opcodestr, bits<6> funct6>
95106c3fb27SDimitry Andric    : VSALU_IV_V_X<opcodestr, funct6> {
95206c3fb27SDimitry Andric  def I  : VALUVI<funct6, opcodestr # ".vi", simm5>,
953*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVSALUI", "ReadVSALUV">;
9546e75b2fbSDimitry Andric}
9556e75b2fbSDimitry Andric
95606c3fb27SDimitry Andricmulticlass VAALU_MV_V_X<string opcodestr, bits<6> funct6> {
95706c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPMVV, opcodestr # ".vv">,
958*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVAALUV", "ReadVAALUV", "ReadVAALUV">;
95906c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPMVX, opcodestr # ".vx">,
960*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVAALUX", "ReadVAALUV", "ReadVAALUX">;
9616e75b2fbSDimitry Andric}
9626e75b2fbSDimitry Andric
96306c3fb27SDimitry Andricmulticlass VSMUL_IV_V_X<string opcodestr, bits<6> funct6> {
96406c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".vv">,
965*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVSMulV", "ReadVSMulV", "ReadVSMulV">;
96606c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".vx">,
967*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVSMulX", "ReadVSMulV", "ReadVSMulX">;
9686e75b2fbSDimitry Andric}
9696e75b2fbSDimitry Andric
97006c3fb27SDimitry Andricmulticlass VSSHF_IV_V_X_I<string opcodestr, bits<6> funct6> {
97106c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".vv">,
972*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVSShiftV", "ReadVSShiftV", "ReadVSShiftV">;
97306c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".vx">,
974*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVSShiftX", "ReadVSShiftV", "ReadVSShiftX">;
97506c3fb27SDimitry Andric  def I  : VALUVI<funct6, opcodestr # ".vi", uimm5>,
976*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVSShiftI", "ReadVSShiftV">;
9776e75b2fbSDimitry Andric}
9786e75b2fbSDimitry Andric
97906c3fb27SDimitry Andricmulticlass VNCLP_IV_V_X_I<string opcodestr, bits<6> funct6> {
98006c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".wv">,
981*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVNClipV", "ReadVNClipV", "ReadVNClipV">;
98206c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".wx">,
983*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVNClipX", "ReadVNClipV", "ReadVNClipX">;
98406c3fb27SDimitry Andric  def I  : VALUVI<funct6, opcodestr # ".wi", uimm5>,
985*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVNClipI", "ReadVNClipV">;
9866e75b2fbSDimitry Andric}
9876e75b2fbSDimitry Andric
98806c3fb27SDimitry Andricmulticlass VSLD_IV_X_I<string opcodestr, bits<6> funct6> {
98906c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".vx">,
990*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVISlideX", "ReadVISlideV", "ReadVISlideX">;
99106c3fb27SDimitry Andric  def I  : VALUVI<funct6, opcodestr # ".vi", uimm5>,
992*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVISlideI", "ReadVISlideV">;
9936e75b2fbSDimitry Andric}
9946e75b2fbSDimitry Andric
99506c3fb27SDimitry Andricmulticlass VSLD1_MV_X<string opcodestr, bits<6> funct6> {
99606c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPMVX, opcodestr # ".vx">,
997*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVISlide1X", "ReadVISlideV", "ReadVISlideX">;
9986e75b2fbSDimitry Andric}
9996e75b2fbSDimitry Andric
100006c3fb27SDimitry Andricmulticlass VSLD1_FV_F<string opcodestr, bits<6> funct6> {
100106c3fb27SDimitry Andric  def F : VALUVF<funct6, OPFVF, opcodestr # ".vf">,
1002*5f757f3fSDimitry Andric          SchedBinaryMC<"WriteVFSlide1F", "ReadVFSlideV", "ReadVFSlideF">;
10036e75b2fbSDimitry Andric}
10046e75b2fbSDimitry Andric
100506c3fb27SDimitry Andricmulticlass VGTR_IV_V_X_I<string opcodestr, bits<6> funct6> {
100606c3fb27SDimitry Andric  def V  : VALUVV<funct6, OPIVV, opcodestr # ".vv">,
1007*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVRGatherVV", "ReadVRGatherVV_data",
1008*5f757f3fSDimitry Andric                         "ReadVRGatherVV_index">;
100906c3fb27SDimitry Andric  def X  : VALUVX<funct6, OPIVX, opcodestr # ".vx">,
1010*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVRGatherVX", "ReadVRGatherVX_data",
1011*5f757f3fSDimitry Andric                         "ReadVRGatherVX_index">;
101206c3fb27SDimitry Andric  def I  : VALUVI<funct6, opcodestr # ".vi", uimm5>,
1013*5f757f3fSDimitry Andric           SchedUnaryMC<"WriteVRGatherVI", "ReadVRGatherVI_data">;
10146e75b2fbSDimitry Andric}
10156e75b2fbSDimitry Andric
10166e75b2fbSDimitry Andricmulticlass VCPR_MV_Mask<string opcodestr, bits<6> funct6, string vm = "v"> {
10176e75b2fbSDimitry Andric  def M  : VALUVVNoVm<funct6, OPMVV, opcodestr # "." # vm # "m">,
1018*5f757f3fSDimitry Andric           SchedBinaryMC<"WriteVCompressV", "ReadVCompressV", "ReadVCompressV">;
10195ffd83dbSDimitry Andric}
10205ffd83dbSDimitry Andric
1021*5f757f3fSDimitry Andricmulticlass VWholeLoadN<int l, bits<3> nf, string opcodestr, RegisterClass VRC> {
1022349cc55cSDimitry Andric  defvar w = !cast<RISCVWidth>("LSWidth" # l);
1023bdd1243dSDimitry Andric  defvar s = !cast<SchedWrite>("WriteVLD" # !add(nf, 1) # "R");
10246e75b2fbSDimitry Andric
1025349cc55cSDimitry Andric  def E # l # _V : VWholeLoad<nf, w, opcodestr # "e" # l # ".v", VRC>,
102606c3fb27SDimitry Andric                   Sched<[s, ReadVLDX]>;
10276e75b2fbSDimitry Andric}
1028e8d8bef9SDimitry Andric
10295ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
10305ffd83dbSDimitry Andric// Instructions
10315ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
10325ffd83dbSDimitry Andric
103304eeddc0SDimitry Andriclet Predicates = [HasVInstructions] in {
10345ffd83dbSDimitry Andriclet hasSideEffects = 1, mayLoad = 0, mayStore = 0 in {
103504eeddc0SDimitry Andricdef VSETVLI : RVInstSetVLi<(outs GPR:$rd), (ins GPR:$rs1, VTypeIOp11:$vtypei),
1036bdd1243dSDimitry Andric                           "vsetvli", "$rd, $rs1, $vtypei">,
1037bdd1243dSDimitry Andric                           Sched<[WriteVSETVLI, ReadVSETVLI]>;
103804eeddc0SDimitry Andricdef VSETIVLI : RVInstSetiVLi<(outs GPR:$rd), (ins uimm5:$uimm, VTypeIOp10:$vtypei),
1039bdd1243dSDimitry Andric                             "vsetivli", "$rd, $uimm, $vtypei">,
1040bdd1243dSDimitry Andric                             Sched<[WriteVSETIVLI]>;
1041d409305fSDimitry Andric
10425ffd83dbSDimitry Andricdef VSETVL : RVInstSetVL<(outs GPR:$rd), (ins GPR:$rs1, GPR:$rs2),
1043bdd1243dSDimitry Andric                         "vsetvl", "$rd, $rs1, $rs2">,
1044bdd1243dSDimitry Andric                          Sched<[WriteVSETVL, ReadVSETVL, ReadVSETVL]>;
10455ffd83dbSDimitry Andric} // hasSideEffects = 1, mayLoad = 0, mayStore = 0
1046*5f757f3fSDimitry Andric} // Predicates = [HasVInstructions]
1047*5f757f3fSDimitry Andric
1048*5f757f3fSDimitry Andricforeach eew = [8, 16, 32, 64] in {
1049349cc55cSDimitry Andric  defvar w = !cast<RISCVWidth>("LSWidth" # eew);
10505ffd83dbSDimitry Andric
1051*5f757f3fSDimitry Andric  let Predicates = !if(!eq(eew, 64), [HasVInstructionsI64],
1052*5f757f3fSDimitry Andric                                     [HasVInstructions]) in {
10535ffd83dbSDimitry Andric    // Vector Unit-Stride Instructions
1054*5f757f3fSDimitry Andric    def VLE#eew#_V : VUnitStrideLoad<w, "vle"#eew#".v">, VLESchedMC;
1055*5f757f3fSDimitry Andric    def VSE#eew#_V  : VUnitStrideStore<w,  "vse"#eew#".v">, VSESchedMC;
10565ffd83dbSDimitry Andric
1057349cc55cSDimitry Andric    // Vector Unit-Stride Fault-only-First Loads
1058*5f757f3fSDimitry Andric    def VLE#eew#FF_V : VUnitStrideLoadFF<w,  "vle"#eew#"ff.v">, VLFSchedMC;
10595ffd83dbSDimitry Andric
10605ffd83dbSDimitry Andric    // Vector Strided Instructions
1061*5f757f3fSDimitry Andric    def VLSE#eew#_V  : VStridedLoad<w,  "vlse"#eew#".v">, VLSSchedMC<eew>;
1062*5f757f3fSDimitry Andric    def VSSE#eew#_V  : VStridedStore<w,  "vsse"#eew#".v">, VSSSchedMC<eew>;
1063*5f757f3fSDimitry Andric
1064*5f757f3fSDimitry Andric    defm VL1R : VWholeLoadN<eew, 0, "vl1r", VR>;
1065*5f757f3fSDimitry Andric    defm VL2R : VWholeLoadN<eew, 1, "vl2r", VRM2>;
1066*5f757f3fSDimitry Andric    defm VL4R : VWholeLoadN<eew, 3, "vl4r", VRM4>;
1067*5f757f3fSDimitry Andric    defm VL8R : VWholeLoadN<eew, 7, "vl8r", VRM8>;
10686e75b2fbSDimitry Andric  }
10695ffd83dbSDimitry Andric
1070*5f757f3fSDimitry Andric  let Predicates = !if(!eq(eew, 64), [IsRV64, HasVInstructionsI64],
1071*5f757f3fSDimitry Andric                                     [HasVInstructions]) in
1072*5f757f3fSDimitry Andric  defm "" : VIndexLoadStore<eew>;
1073*5f757f3fSDimitry Andric}
107404eeddc0SDimitry Andric
107504eeddc0SDimitry Andriclet Predicates = [HasVInstructions] in {
1076349cc55cSDimitry Andricdef VLM_V : VUnitStrideLoadMask<"vlm.v">,
107706c3fb27SDimitry Andric             Sched<[WriteVLDM_WorstCase, ReadVLDX]>;
1078349cc55cSDimitry Andricdef VSM_V : VUnitStrideStoreMask<"vsm.v">,
107906c3fb27SDimitry Andric             Sched<[WriteVSTM_WorstCase, ReadVSTM_WorstCase, ReadVSTX]>;
1080349cc55cSDimitry Andricdef : InstAlias<"vle1.v $vd, (${rs1})",
1081349cc55cSDimitry Andric                (VLM_V VR:$vd, GPR:$rs1), 0>;
1082349cc55cSDimitry Andricdef : InstAlias<"vse1.v $vs3, (${rs1})",
1083349cc55cSDimitry Andric                (VSM_V VR:$vs3, GPR:$rs1), 0>;
1084349cc55cSDimitry Andric
10856e75b2fbSDimitry Andricdef VS1R_V : VWholeStore<0, "vs1r.v", VR>,
108606c3fb27SDimitry Andric             Sched<[WriteVST1R, ReadVST1R, ReadVSTX]>;
10876e75b2fbSDimitry Andricdef VS2R_V : VWholeStore<1, "vs2r.v", VRM2>,
108806c3fb27SDimitry Andric             Sched<[WriteVST2R, ReadVST2R, ReadVSTX]>;
10896e75b2fbSDimitry Andricdef VS4R_V : VWholeStore<3, "vs4r.v", VRM4>,
109006c3fb27SDimitry Andric             Sched<[WriteVST4R, ReadVST4R, ReadVSTX]>;
10916e75b2fbSDimitry Andricdef VS8R_V : VWholeStore<7, "vs8r.v", VRM8>,
109206c3fb27SDimitry Andric             Sched<[WriteVST8R, ReadVST8R, ReadVSTX]>;
10935ffd83dbSDimitry Andric
109404eeddc0SDimitry Andricdef : InstAlias<"vl1r.v $vd, (${rs1})", (VL1RE8_V VR:$vd, GPR:$rs1)>;
109504eeddc0SDimitry Andricdef : InstAlias<"vl2r.v $vd, (${rs1})", (VL2RE8_V VRM2:$vd, GPR:$rs1)>;
109604eeddc0SDimitry Andricdef : InstAlias<"vl4r.v $vd, (${rs1})", (VL4RE8_V VRM4:$vd, GPR:$rs1)>;
109704eeddc0SDimitry Andricdef : InstAlias<"vl8r.v $vd, (${rs1})", (VL8RE8_V VRM8:$vd, GPR:$rs1)>;
109804eeddc0SDimitry Andric} // Predicates = [HasVInstructions]
109904eeddc0SDimitry Andric
110004eeddc0SDimitry Andriclet Predicates = [HasVInstructions] in {
11015ffd83dbSDimitry Andric// Vector Single-Width Integer Add and Subtract
11025ffd83dbSDimitry Andricdefm VADD_V : VALU_IV_V_X_I<"vadd", 0b000000>;
11035ffd83dbSDimitry Andricdefm VSUB_V : VALU_IV_V_X<"vsub", 0b000010>;
11045ffd83dbSDimitry Andricdefm VRSUB_V : VALU_IV_X_I<"vrsub", 0b000011>;
11055ffd83dbSDimitry Andric
1106e8d8bef9SDimitry Andricdef : InstAlias<"vneg.v $vd, $vs$vm", (VRSUB_VX VR:$vd, VR:$vs, X0, VMaskOp:$vm)>;
110781ad6265SDimitry Andricdef : InstAlias<"vneg.v $vd, $vs", (VRSUB_VX VR:$vd, VR:$vs, X0, zero_reg)>;
1108e8d8bef9SDimitry Andric
11095ffd83dbSDimitry Andric// Vector Widening Integer Add/Subtract
11105ffd83dbSDimitry Andric// Refer to 11.2 Widening Vector Arithmetic Instructions
11115ffd83dbSDimitry Andric// The destination vector register group cannot overlap a source vector
11125ffd83dbSDimitry Andric// register group of a different element width (including the mask register
11135ffd83dbSDimitry Andric// if masked), otherwise an illegal instruction exception is raised.
11145ffd83dbSDimitry Andriclet Constraints = "@earlyclobber $vd" in {
11155ffd83dbSDimitry Andriclet RVVConstraint = WidenV in {
111606c3fb27SDimitry Andricdefm VWADDU_V : VALU_MV_V_X<"vwaddu", 0b110000, "v">;
111706c3fb27SDimitry Andricdefm VWSUBU_V : VALU_MV_V_X<"vwsubu", 0b110010, "v">;
111806c3fb27SDimitry Andricdefm VWADD_V : VALU_MV_V_X<"vwadd", 0b110001, "v">;
111906c3fb27SDimitry Andricdefm VWSUB_V : VALU_MV_V_X<"vwsub", 0b110011, "v">;
11205ffd83dbSDimitry Andric} // RVVConstraint = WidenV
11215ffd83dbSDimitry Andric// Set earlyclobber for following instructions for second and mask operands.
11225ffd83dbSDimitry Andric// This has the downside that the earlyclobber constraint is too coarse and
11235ffd83dbSDimitry Andric// will impose unnecessary restrictions by not allowing the destination to
11245ffd83dbSDimitry Andric// overlap with the first (wide) operand.
11255ffd83dbSDimitry Andriclet RVVConstraint = WidenW in {
11265ffd83dbSDimitry Andricdefm VWADDU_W : VALU_MV_V_X<"vwaddu", 0b110100, "w">;
11275ffd83dbSDimitry Andricdefm VWSUBU_W : VALU_MV_V_X<"vwsubu", 0b110110, "w">;
11285ffd83dbSDimitry Andricdefm VWADD_W : VALU_MV_V_X<"vwadd", 0b110101, "w">;
11295ffd83dbSDimitry Andricdefm VWSUB_W : VALU_MV_V_X<"vwsub", 0b110111, "w">;
11305ffd83dbSDimitry Andric} // RVVConstraint = WidenW
11315ffd83dbSDimitry Andric} // Constraints = "@earlyclobber $vd"
11325ffd83dbSDimitry Andric
11335ffd83dbSDimitry Andricdef : InstAlias<"vwcvt.x.x.v $vd, $vs$vm",
1134e8d8bef9SDimitry Andric                (VWADD_VX VR:$vd, VR:$vs, X0, VMaskOp:$vm)>;
113581ad6265SDimitry Andricdef : InstAlias<"vwcvt.x.x.v $vd, $vs",
113681ad6265SDimitry Andric                (VWADD_VX VR:$vd, VR:$vs, X0, zero_reg)>;
11375ffd83dbSDimitry Andricdef : InstAlias<"vwcvtu.x.x.v $vd, $vs$vm",
1138e8d8bef9SDimitry Andric                (VWADDU_VX VR:$vd, VR:$vs, X0, VMaskOp:$vm)>;
113981ad6265SDimitry Andricdef : InstAlias<"vwcvtu.x.x.v $vd, $vs",
114081ad6265SDimitry Andric                (VWADDU_VX VR:$vd, VR:$vs, X0, zero_reg)>;
1141e8d8bef9SDimitry Andric
1142e8d8bef9SDimitry Andric// Vector Integer Extension
1143e8d8bef9SDimitry Andricdefm VZEXT_VF8 : VALU_MV_VS2<"vzext.vf8", 0b010010, 0b00010>;
1144e8d8bef9SDimitry Andricdefm VSEXT_VF8 : VALU_MV_VS2<"vsext.vf8", 0b010010, 0b00011>;
1145e8d8bef9SDimitry Andricdefm VZEXT_VF4 : VALU_MV_VS2<"vzext.vf4", 0b010010, 0b00100>;
1146e8d8bef9SDimitry Andricdefm VSEXT_VF4 : VALU_MV_VS2<"vsext.vf4", 0b010010, 0b00101>;
1147e8d8bef9SDimitry Andricdefm VZEXT_VF2 : VALU_MV_VS2<"vzext.vf2", 0b010010, 0b00110>;
1148e8d8bef9SDimitry Andricdefm VSEXT_VF2 : VALU_MV_VS2<"vsext.vf2", 0b010010, 0b00111>;
11495ffd83dbSDimitry Andric
11505ffd83dbSDimitry Andric// Vector Integer Add-with-Carry / Subtract-with-Borrow Instructions
11515ffd83dbSDimitry Andricdefm VADC_V : VALUm_IV_V_X_I<"vadc", 0b010000>;
1152e8d8bef9SDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = NoConstraint in {
11535ffd83dbSDimitry Andricdefm VMADC_V : VALUm_IV_V_X_I<"vmadc", 0b010001>;
11545ffd83dbSDimitry Andricdefm VMADC_V : VALUNoVm_IV_V_X_I<"vmadc", 0b010001>;
1155e8d8bef9SDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = NoConstraint
11565ffd83dbSDimitry Andricdefm VSBC_V : VALUm_IV_V_X<"vsbc", 0b010010>;
1157e8d8bef9SDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = NoConstraint in {
11585ffd83dbSDimitry Andricdefm VMSBC_V : VALUm_IV_V_X<"vmsbc", 0b010011>;
11595ffd83dbSDimitry Andricdefm VMSBC_V : VALUNoVm_IV_V_X<"vmsbc", 0b010011>;
1160e8d8bef9SDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = NoConstraint
11615ffd83dbSDimitry Andric
11625ffd83dbSDimitry Andric// Vector Bitwise Logical Instructions
11635ffd83dbSDimitry Andricdefm VAND_V : VALU_IV_V_X_I<"vand", 0b001001>;
11645ffd83dbSDimitry Andricdefm VOR_V : VALU_IV_V_X_I<"vor", 0b001010>;
11655ffd83dbSDimitry Andricdefm VXOR_V : VALU_IV_V_X_I<"vxor", 0b001011>;
11665ffd83dbSDimitry Andric
11675ffd83dbSDimitry Andricdef : InstAlias<"vnot.v $vd, $vs$vm",
1168e8d8bef9SDimitry Andric                (VXOR_VI VR:$vd, VR:$vs, -1, VMaskOp:$vm)>;
116981ad6265SDimitry Andricdef : InstAlias<"vnot.v $vd, $vs",
117081ad6265SDimitry Andric                (VXOR_VI VR:$vd, VR:$vs, -1, zero_reg)>;
11715ffd83dbSDimitry Andric
11725ffd83dbSDimitry Andric// Vector Single-Width Bit Shift Instructions
117306c3fb27SDimitry Andricdefm VSLL_V : VSHT_IV_V_X_I<"vsll", 0b100101>;
117406c3fb27SDimitry Andricdefm VSRL_V : VSHT_IV_V_X_I<"vsrl", 0b101000>;
117506c3fb27SDimitry Andricdefm VSRA_V : VSHT_IV_V_X_I<"vsra", 0b101001>;
11765ffd83dbSDimitry Andric
11775ffd83dbSDimitry Andric// Vector Narrowing Integer Right Shift Instructions
11785ffd83dbSDimitry Andric// Refer to 11.3. Narrowing Vector Arithmetic Instructions
11795ffd83dbSDimitry Andric// The destination vector register group cannot overlap the first source
11805ffd83dbSDimitry Andric// vector register group (specified by vs2). The destination vector register
11815ffd83dbSDimitry Andric// group cannot overlap the mask register if used, unless LMUL=1.
1182e8d8bef9SDimitry Andriclet Constraints = "@earlyclobber $vd" in {
118306c3fb27SDimitry Andricdefm VNSRL_W : VNSHT_IV_V_X_I<"vnsrl", 0b101100>;
118406c3fb27SDimitry Andricdefm VNSRA_W : VNSHT_IV_V_X_I<"vnsra", 0b101101>;
1185e8d8bef9SDimitry Andric} // Constraints = "@earlyclobber $vd"
1186e8d8bef9SDimitry Andric
1187e8d8bef9SDimitry Andricdef : InstAlias<"vncvt.x.x.w $vd, $vs$vm",
1188e8d8bef9SDimitry Andric                (VNSRL_WX VR:$vd, VR:$vs, X0, VMaskOp:$vm)>;
118981ad6265SDimitry Andricdef : InstAlias<"vncvt.x.x.w $vd, $vs",
119081ad6265SDimitry Andric                (VNSRL_WX VR:$vd, VR:$vs, X0, zero_reg)>;
11915ffd83dbSDimitry Andric
11925ffd83dbSDimitry Andric// Vector Integer Comparison Instructions
1193e8d8bef9SDimitry Andriclet RVVConstraint = NoConstraint in {
11946e75b2fbSDimitry Andricdefm VMSEQ_V : VCMP_IV_V_X_I<"vmseq", 0b011000>;
11956e75b2fbSDimitry Andricdefm VMSNE_V : VCMP_IV_V_X_I<"vmsne", 0b011001>;
11966e75b2fbSDimitry Andricdefm VMSLTU_V : VCMP_IV_V_X<"vmsltu", 0b011010>;
11976e75b2fbSDimitry Andricdefm VMSLT_V : VCMP_IV_V_X<"vmslt", 0b011011>;
11986e75b2fbSDimitry Andricdefm VMSLEU_V : VCMP_IV_V_X_I<"vmsleu", 0b011100>;
11996e75b2fbSDimitry Andricdefm VMSLE_V : VCMP_IV_V_X_I<"vmsle", 0b011101>;
12006e75b2fbSDimitry Andricdefm VMSGTU_V : VCMP_IV_X_I<"vmsgtu", 0b011110>;
12016e75b2fbSDimitry Andricdefm VMSGT_V : VCMP_IV_X_I<"vmsgt", 0b011111>;
1202e8d8bef9SDimitry Andric} // RVVConstraint = NoConstraint
12035ffd83dbSDimitry Andric
12045ffd83dbSDimitry Andricdef : InstAlias<"vmsgtu.vv $vd, $va, $vb$vm",
1205e8d8bef9SDimitry Andric                (VMSLTU_VV VR:$vd, VR:$vb, VR:$va, VMaskOp:$vm), 0>;
12065ffd83dbSDimitry Andricdef : InstAlias<"vmsgt.vv $vd, $va, $vb$vm",
1207e8d8bef9SDimitry Andric                (VMSLT_VV VR:$vd, VR:$vb, VR:$va, VMaskOp:$vm), 0>;
12085ffd83dbSDimitry Andricdef : InstAlias<"vmsgeu.vv $vd, $va, $vb$vm",
1209e8d8bef9SDimitry Andric                (VMSLEU_VV VR:$vd, VR:$vb, VR:$va, VMaskOp:$vm), 0>;
12105ffd83dbSDimitry Andricdef : InstAlias<"vmsge.vv $vd, $va, $vb$vm",
1211e8d8bef9SDimitry Andric                (VMSLE_VV VR:$vd, VR:$vb, VR:$va, VMaskOp:$vm), 0>;
1212e8d8bef9SDimitry Andric
1213e8d8bef9SDimitry Andriclet isCodeGenOnly = 0, isAsmParserOnly = 1, hasSideEffects = 0, mayLoad = 0,
1214e8d8bef9SDimitry Andric    mayStore = 0 in {
1215e8d8bef9SDimitry Andric// For unsigned comparisons we need to special case 0 immediate to maintain
1216e8d8bef9SDimitry Andric// the always true/false semantics we would invert if we just decremented the
1217e8d8bef9SDimitry Andric// immediate like we do for signed. To match the GNU assembler we will use
1218e8d8bef9SDimitry Andric// vmseq/vmsne.vv with the same register for both operands which we can't do
1219e8d8bef9SDimitry Andric// from an InstAlias.
1220e8d8bef9SDimitry Andricdef PseudoVMSGEU_VI : Pseudo<(outs VR:$vd),
1221e8d8bef9SDimitry Andric                             (ins VR:$vs2, simm5_plus1:$imm, VMaskOp:$vm),
1222e8d8bef9SDimitry Andric                             [], "vmsgeu.vi", "$vd, $vs2, $imm$vm">;
1223e8d8bef9SDimitry Andricdef PseudoVMSLTU_VI : Pseudo<(outs VR:$vd),
1224e8d8bef9SDimitry Andric                             (ins VR:$vs2, simm5_plus1:$imm, VMaskOp:$vm),
1225e8d8bef9SDimitry Andric                             [], "vmsltu.vi", "$vd, $vs2, $imm$vm">;
1226e8d8bef9SDimitry Andric// Handle signed with pseudos as well for more consistency in the
1227e8d8bef9SDimitry Andric// implementation.
1228e8d8bef9SDimitry Andricdef PseudoVMSGE_VI : Pseudo<(outs VR:$vd),
1229e8d8bef9SDimitry Andric                            (ins VR:$vs2, simm5_plus1:$imm, VMaskOp:$vm),
1230e8d8bef9SDimitry Andric                            [], "vmsge.vi", "$vd, $vs2, $imm$vm">;
1231e8d8bef9SDimitry Andricdef PseudoVMSLT_VI : Pseudo<(outs VR:$vd),
1232e8d8bef9SDimitry Andric                            (ins VR:$vs2, simm5_plus1:$imm, VMaskOp:$vm),
1233e8d8bef9SDimitry Andric                            [], "vmslt.vi", "$vd, $vs2, $imm$vm">;
1234e8d8bef9SDimitry Andric}
1235e8d8bef9SDimitry Andric
1236e8d8bef9SDimitry Andriclet isCodeGenOnly = 0, isAsmParserOnly = 1, hasSideEffects = 0, mayLoad = 0,
1237e8d8bef9SDimitry Andric    mayStore = 0 in {
1238e8d8bef9SDimitry Andricdef PseudoVMSGEU_VX : Pseudo<(outs VR:$vd),
1239e8d8bef9SDimitry Andric                             (ins VR:$vs2, GPR:$rs1),
1240e8d8bef9SDimitry Andric                             [], "vmsgeu.vx", "$vd, $vs2, $rs1">;
1241e8d8bef9SDimitry Andricdef PseudoVMSGE_VX : Pseudo<(outs VR:$vd),
1242e8d8bef9SDimitry Andric                            (ins VR:$vs2, GPR:$rs1),
1243e8d8bef9SDimitry Andric                            [], "vmsge.vx", "$vd, $vs2, $rs1">;
1244e8d8bef9SDimitry Andricdef PseudoVMSGEU_VX_M : Pseudo<(outs VRNoV0:$vd),
1245e8d8bef9SDimitry Andric                               (ins VR:$vs2, GPR:$rs1, VMaskOp:$vm),
1246e8d8bef9SDimitry Andric                               [], "vmsgeu.vx", "$vd, $vs2, $rs1$vm">;
1247e8d8bef9SDimitry Andricdef PseudoVMSGE_VX_M : Pseudo<(outs VRNoV0:$vd),
1248e8d8bef9SDimitry Andric                              (ins VR:$vs2, GPR:$rs1, VMaskOp:$vm),
1249e8d8bef9SDimitry Andric                              [], "vmsge.vx", "$vd, $vs2, $rs1$vm">;
1250fe6060f1SDimitry Andricdef PseudoVMSGEU_VX_M_T : Pseudo<(outs VR:$vd, VRNoV0:$scratch),
1251e8d8bef9SDimitry Andric                                 (ins VR:$vs2, GPR:$rs1, VMaskOp:$vm),
1252e8d8bef9SDimitry Andric                                 [], "vmsgeu.vx", "$vd, $vs2, $rs1$vm, $scratch">;
1253fe6060f1SDimitry Andricdef PseudoVMSGE_VX_M_T : Pseudo<(outs VR:$vd, VRNoV0:$scratch),
1254e8d8bef9SDimitry Andric                                (ins VR:$vs2, GPR:$rs1, VMaskOp:$vm),
1255e8d8bef9SDimitry Andric                                [], "vmsge.vx", "$vd, $vs2, $rs1$vm, $scratch">;
1256e8d8bef9SDimitry Andric}
12575ffd83dbSDimitry Andric
12585ffd83dbSDimitry Andric// Vector Integer Min/Max Instructions
125906c3fb27SDimitry Andricdefm VMINU_V : VMINMAX_IV_V_X<"vminu", 0b000100>;
126006c3fb27SDimitry Andricdefm VMIN_V : VMINMAX_IV_V_X<"vmin", 0b000101>;
126106c3fb27SDimitry Andricdefm VMAXU_V : VMINMAX_IV_V_X<"vmaxu", 0b000110>;
126206c3fb27SDimitry Andricdefm VMAX_V : VMINMAX_IV_V_X<"vmax", 0b000111>;
12635ffd83dbSDimitry Andric
12645ffd83dbSDimitry Andric// Vector Single-Width Integer Multiply Instructions
12656e75b2fbSDimitry Andricdefm VMUL_V : VMUL_MV_V_X<"vmul", 0b100101>;
12666e75b2fbSDimitry Andricdefm VMULH_V : VMUL_MV_V_X<"vmulh", 0b100111>;
12676e75b2fbSDimitry Andricdefm VMULHU_V : VMUL_MV_V_X<"vmulhu", 0b100100>;
12686e75b2fbSDimitry Andricdefm VMULHSU_V : VMUL_MV_V_X<"vmulhsu", 0b100110>;
12695ffd83dbSDimitry Andric
12705ffd83dbSDimitry Andric// Vector Integer Divide Instructions
12716e75b2fbSDimitry Andricdefm VDIVU_V : VDIV_MV_V_X<"vdivu", 0b100000>;
12726e75b2fbSDimitry Andricdefm VDIV_V : VDIV_MV_V_X<"vdiv", 0b100001>;
12736e75b2fbSDimitry Andricdefm VREMU_V : VDIV_MV_V_X<"vremu", 0b100010>;
12746e75b2fbSDimitry Andricdefm VREM_V : VDIV_MV_V_X<"vrem", 0b100011>;
12755ffd83dbSDimitry Andric
12765ffd83dbSDimitry Andric// Vector Widening Integer Multiply Instructions
12775ffd83dbSDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = WidenV in {
12786e75b2fbSDimitry Andricdefm VWMUL_V : VWMUL_MV_V_X<"vwmul", 0b111011>;
12796e75b2fbSDimitry Andricdefm VWMULU_V : VWMUL_MV_V_X<"vwmulu", 0b111000>;
12806e75b2fbSDimitry Andricdefm VWMULSU_V : VWMUL_MV_V_X<"vwmulsu", 0b111010>;
12815ffd83dbSDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = WidenV
12825ffd83dbSDimitry Andric
12835ffd83dbSDimitry Andric// Vector Single-Width Integer Multiply-Add Instructions
12846e75b2fbSDimitry Andricdefm VMACC_V : VMAC_MV_V_X<"vmacc", 0b101101>;
12856e75b2fbSDimitry Andricdefm VNMSAC_V : VMAC_MV_V_X<"vnmsac", 0b101111>;
12866e75b2fbSDimitry Andricdefm VMADD_V : VMAC_MV_V_X<"vmadd", 0b101001>;
12876e75b2fbSDimitry Andricdefm VNMSUB_V : VMAC_MV_V_X<"vnmsub", 0b101011>;
12885ffd83dbSDimitry Andric
12895ffd83dbSDimitry Andric// Vector Widening Integer Multiply-Add Instructions
12906e75b2fbSDimitry Andricdefm VWMACCU_V : VWMAC_MV_V_X<"vwmaccu", 0b111100>;
12916e75b2fbSDimitry Andricdefm VWMACC_V : VWMAC_MV_V_X<"vwmacc", 0b111101>;
12926e75b2fbSDimitry Andricdefm VWMACCSU_V : VWMAC_MV_V_X<"vwmaccsu", 0b111111>;
12936e75b2fbSDimitry Andricdefm VWMACCUS_V : VWMAC_MV_X<"vwmaccus", 0b111110>;
12945ffd83dbSDimitry Andric
12955ffd83dbSDimitry Andric// Vector Integer Merge Instructions
12966e75b2fbSDimitry Andricdefm VMERGE_V : VMRG_IV_V_X_I<"vmerge", 0b010111>;
12975ffd83dbSDimitry Andric
12985ffd83dbSDimitry Andric// Vector Integer Move Instructions
1299e8d8bef9SDimitry Andriclet hasSideEffects = 0, mayLoad = 0, mayStore = 0, vs2 = 0, vm = 1,
1300e8d8bef9SDimitry Andric    RVVConstraint = NoConstraint  in {
13015ffd83dbSDimitry Andric// op vd, vs1
1302e8d8bef9SDimitry Andricdef VMV_V_V : RVInstVV<0b010111, OPIVV, (outs VR:$vd),
13036e75b2fbSDimitry Andric                       (ins VR:$vs1), "vmv.v.v", "$vd, $vs1">,
1304*5f757f3fSDimitry Andric              SchedUnaryMC<"WriteVIMovV", "ReadVIMovV", forceMasked=0>;
13055ffd83dbSDimitry Andric// op vd, rs1
1306e8d8bef9SDimitry Andricdef VMV_V_X : RVInstVX<0b010111, OPIVX, (outs VR:$vd),
13076e75b2fbSDimitry Andric                       (ins GPR:$rs1), "vmv.v.x", "$vd, $rs1">,
1308*5f757f3fSDimitry Andric              SchedUnaryMC<"WriteVIMovX", "ReadVIMovX", forceMasked=0>;
13095ffd83dbSDimitry Andric// op vd, imm
1310e8d8bef9SDimitry Andricdef VMV_V_I : RVInstIVI<0b010111, (outs VR:$vd),
13116e75b2fbSDimitry Andric                       (ins simm5:$imm), "vmv.v.i", "$vd, $imm">,
1312*5f757f3fSDimitry Andric              SchedNullaryMC<"WriteVIMovI", forceMasked=0>;
13135ffd83dbSDimitry Andric} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
13145ffd83dbSDimitry Andric
13155ffd83dbSDimitry Andric// Vector Fixed-Point Arithmetic Instructions
13166e75b2fbSDimitry Andricdefm VSADDU_V : VSALU_IV_V_X_I<"vsaddu", 0b100000>;
13176e75b2fbSDimitry Andricdefm VSADD_V : VSALU_IV_V_X_I<"vsadd", 0b100001>;
13186e75b2fbSDimitry Andricdefm VSSUBU_V : VSALU_IV_V_X<"vssubu", 0b100010>;
13196e75b2fbSDimitry Andricdefm VSSUB_V : VSALU_IV_V_X<"vssub", 0b100011>;
13205ffd83dbSDimitry Andric
13215ffd83dbSDimitry Andric// Vector Single-Width Averaging Add and Subtract
13226e75b2fbSDimitry Andricdefm VAADDU_V : VAALU_MV_V_X<"vaaddu", 0b001000>;
13236e75b2fbSDimitry Andricdefm VAADD_V : VAALU_MV_V_X<"vaadd", 0b001001>;
13246e75b2fbSDimitry Andricdefm VASUBU_V : VAALU_MV_V_X<"vasubu", 0b001010>;
13256e75b2fbSDimitry Andricdefm VASUB_V : VAALU_MV_V_X<"vasub", 0b001011>;
13265ffd83dbSDimitry Andric
13275ffd83dbSDimitry Andric// Vector Single-Width Fractional Multiply with Rounding and Saturation
13286e75b2fbSDimitry Andricdefm VSMUL_V : VSMUL_IV_V_X<"vsmul", 0b100111>;
13295ffd83dbSDimitry Andric
13305ffd83dbSDimitry Andric// Vector Single-Width Scaling Shift Instructions
133106c3fb27SDimitry Andricdefm VSSRL_V : VSSHF_IV_V_X_I<"vssrl", 0b101010>;
133206c3fb27SDimitry Andricdefm VSSRA_V : VSSHF_IV_V_X_I<"vssra", 0b101011>;
13335ffd83dbSDimitry Andric
13345ffd83dbSDimitry Andric// Vector Narrowing Fixed-Point Clip Instructions
1335e8d8bef9SDimitry Andriclet Constraints = "@earlyclobber $vd" in {
133606c3fb27SDimitry Andricdefm VNCLIPU_W : VNCLP_IV_V_X_I<"vnclipu", 0b101110>;
133706c3fb27SDimitry Andricdefm VNCLIP_W : VNCLP_IV_V_X_I<"vnclip", 0b101111>;
1338e8d8bef9SDimitry Andric} // Constraints = "@earlyclobber $vd"
133904eeddc0SDimitry Andric} // Predicates = [HasVInstructions]
13405ffd83dbSDimitry Andric
134104eeddc0SDimitry Andriclet Predicates = [HasVInstructionsAnyF] in {
13425ffd83dbSDimitry Andric// Vector Single-Width Floating-Point Add/Subtract Instructions
134381ad6265SDimitry Andriclet Uses = [FRM], mayRaiseFPException = true in {
13445ffd83dbSDimitry Andricdefm VFADD_V : VALU_FV_V_F<"vfadd", 0b000000>;
13455ffd83dbSDimitry Andricdefm VFSUB_V : VALU_FV_V_F<"vfsub", 0b000010>;
13465ffd83dbSDimitry Andricdefm VFRSUB_V : VALU_FV_F<"vfrsub", 0b100111>;
134781ad6265SDimitry Andric}
13485ffd83dbSDimitry Andric
13495ffd83dbSDimitry Andric// Vector Widening Floating-Point Add/Subtract Instructions
135081ad6265SDimitry Andriclet Constraints = "@earlyclobber $vd",
135181ad6265SDimitry Andric    Uses = [FRM],
135281ad6265SDimitry Andric    mayRaiseFPException = true in {
13535ffd83dbSDimitry Andriclet RVVConstraint = WidenV in {
135406c3fb27SDimitry Andricdefm VFWADD_V : VWALU_FV_V_F<"vfwadd", 0b110000, "v">;
135506c3fb27SDimitry Andricdefm VFWSUB_V : VWALU_FV_V_F<"vfwsub", 0b110010, "v">;
13565ffd83dbSDimitry Andric} // RVVConstraint = WidenV
13575ffd83dbSDimitry Andric// Set earlyclobber for following instructions for second and mask operands.
13585ffd83dbSDimitry Andric// This has the downside that the earlyclobber constraint is too coarse and
13595ffd83dbSDimitry Andric// will impose unnecessary restrictions by not allowing the destination to
13605ffd83dbSDimitry Andric// overlap with the first (wide) operand.
13615ffd83dbSDimitry Andriclet RVVConstraint = WidenW in {
13626e75b2fbSDimitry Andricdefm VFWADD_W : VWALU_FV_V_F<"vfwadd", 0b110100, "w">;
13636e75b2fbSDimitry Andricdefm VFWSUB_W : VWALU_FV_V_F<"vfwsub", 0b110110, "w">;
13645ffd83dbSDimitry Andric} // RVVConstraint = WidenW
136581ad6265SDimitry Andric} // Constraints = "@earlyclobber $vd", Uses = [FRM], mayRaiseFPException = true
13665ffd83dbSDimitry Andric
13675ffd83dbSDimitry Andric// Vector Single-Width Floating-Point Multiply/Divide Instructions
136881ad6265SDimitry Andriclet Uses = [FRM], mayRaiseFPException = true in {
13696e75b2fbSDimitry Andricdefm VFMUL_V : VMUL_FV_V_F<"vfmul", 0b100100>;
13706e75b2fbSDimitry Andricdefm VFDIV_V : VDIV_FV_V_F<"vfdiv", 0b100000>;
137106c3fb27SDimitry Andricdefm VFRDIV_V : VDIV_FV_F<"vfrdiv", 0b100001>;
137281ad6265SDimitry Andric}
13735ffd83dbSDimitry Andric
13745ffd83dbSDimitry Andric// Vector Widening Floating-Point Multiply
137581ad6265SDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = WidenV,
137681ad6265SDimitry Andric    Uses = [FRM], mayRaiseFPException = true in {
13776e75b2fbSDimitry Andricdefm VFWMUL_V : VWMUL_FV_V_F<"vfwmul", 0b111000>;
137881ad6265SDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = WidenV, Uses = [FRM], mayRaiseFPException = true
13795ffd83dbSDimitry Andric
13805ffd83dbSDimitry Andric// Vector Single-Width Floating-Point Fused Multiply-Add Instructions
138181ad6265SDimitry Andriclet Uses = [FRM], mayRaiseFPException = true in {
13826e75b2fbSDimitry Andricdefm VFMACC_V : VMAC_FV_V_F<"vfmacc", 0b101100>;
13836e75b2fbSDimitry Andricdefm VFNMACC_V : VMAC_FV_V_F<"vfnmacc", 0b101101>;
13846e75b2fbSDimitry Andricdefm VFMSAC_V : VMAC_FV_V_F<"vfmsac", 0b101110>;
13856e75b2fbSDimitry Andricdefm VFNMSAC_V : VMAC_FV_V_F<"vfnmsac", 0b101111>;
13866e75b2fbSDimitry Andricdefm VFMADD_V : VMAC_FV_V_F<"vfmadd", 0b101000>;
13876e75b2fbSDimitry Andricdefm VFNMADD_V : VMAC_FV_V_F<"vfnmadd", 0b101001>;
13886e75b2fbSDimitry Andricdefm VFMSUB_V : VMAC_FV_V_F<"vfmsub", 0b101010>;
13896e75b2fbSDimitry Andricdefm VFNMSUB_V : VMAC_FV_V_F<"vfnmsub", 0b101011>;
139081ad6265SDimitry Andric}
13915ffd83dbSDimitry Andric
13925ffd83dbSDimitry Andric// Vector Widening Floating-Point Fused Multiply-Add Instructions
1393*5f757f3fSDimitry Andriclet Uses = [FRM], mayRaiseFPException = true in {
13946e75b2fbSDimitry Andricdefm VFWMACC_V : VWMAC_FV_V_F<"vfwmacc", 0b111100>;
13956e75b2fbSDimitry Andricdefm VFWNMACC_V : VWMAC_FV_V_F<"vfwnmacc", 0b111101>;
13966e75b2fbSDimitry Andricdefm VFWMSAC_V : VWMAC_FV_V_F<"vfwmsac", 0b111110>;
13976e75b2fbSDimitry Andricdefm VFWNMSAC_V : VWMAC_FV_V_F<"vfwnmsac", 0b111111>;
139881ad6265SDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = WidenV, Uses = [FRM], mayRaiseFPException = true
13995ffd83dbSDimitry Andric
14005ffd83dbSDimitry Andric// Vector Floating-Point Square-Root Instruction
140181ad6265SDimitry Andriclet Uses = [FRM], mayRaiseFPException = true in {
14026e75b2fbSDimitry Andricdefm VFSQRT_V : VSQR_FV_VS2<"vfsqrt.v", 0b010011, 0b00000>;
14036e75b2fbSDimitry Andricdefm VFREC7_V : VRCP_FV_VS2<"vfrec7.v", 0b010011, 0b00101>;
140481ad6265SDimitry Andric}
140581ad6265SDimitry Andric
140681ad6265SDimitry Andriclet mayRaiseFPException = true in
140781ad6265SDimitry Andricdefm VFRSQRT7_V : VRCP_FV_VS2<"vfrsqrt7.v", 0b010011, 0b00100>;
14085ffd83dbSDimitry Andric
14095ffd83dbSDimitry Andric// Vector Floating-Point MIN/MAX Instructions
141081ad6265SDimitry Andriclet mayRaiseFPException = true in {
141106c3fb27SDimitry Andricdefm VFMIN_V : VMINMAX_FV_V_F<"vfmin", 0b000100>;
141206c3fb27SDimitry Andricdefm VFMAX_V : VMINMAX_FV_V_F<"vfmax", 0b000110>;
141381ad6265SDimitry Andric}
14145ffd83dbSDimitry Andric
14155ffd83dbSDimitry Andric// Vector Floating-Point Sign-Injection Instructions
14166e75b2fbSDimitry Andricdefm VFSGNJ_V : VSGNJ_FV_V_F<"vfsgnj", 0b001000>;
14176e75b2fbSDimitry Andricdefm VFSGNJN_V : VSGNJ_FV_V_F<"vfsgnjn", 0b001001>;
14186e75b2fbSDimitry Andricdefm VFSGNJX_V : VSGNJ_FV_V_F<"vfsgnjx", 0b001010>;
14195ffd83dbSDimitry Andric
1420e8d8bef9SDimitry Andricdef : InstAlias<"vfneg.v $vd, $vs$vm",
1421e8d8bef9SDimitry Andric                (VFSGNJN_VV VR:$vd, VR:$vs, VR:$vs, VMaskOp:$vm)>;
142281ad6265SDimitry Andricdef : InstAlias<"vfneg.v $vd, $vs",
142381ad6265SDimitry Andric                (VFSGNJN_VV VR:$vd, VR:$vs, VR:$vs, zero_reg)>;
1424fe6060f1SDimitry Andricdef : InstAlias<"vfabs.v $vd, $vs$vm",
1425fe6060f1SDimitry Andric                (VFSGNJX_VV VR:$vd, VR:$vs, VR:$vs, VMaskOp:$vm)>;
142681ad6265SDimitry Andricdef : InstAlias<"vfabs.v $vd, $vs",
142781ad6265SDimitry Andric                (VFSGNJX_VV VR:$vd, VR:$vs, VR:$vs, zero_reg)>;
1428e8d8bef9SDimitry Andric
14295ffd83dbSDimitry Andric// Vector Floating-Point Compare Instructions
143081ad6265SDimitry Andriclet RVVConstraint = NoConstraint, mayRaiseFPException = true in {
14316e75b2fbSDimitry Andricdefm VMFEQ_V : VCMP_FV_V_F<"vmfeq", 0b011000>;
14326e75b2fbSDimitry Andricdefm VMFNE_V : VCMP_FV_V_F<"vmfne", 0b011100>;
14336e75b2fbSDimitry Andricdefm VMFLT_V : VCMP_FV_V_F<"vmflt", 0b011011>;
14346e75b2fbSDimitry Andricdefm VMFLE_V : VCMP_FV_V_F<"vmfle", 0b011001>;
14356e75b2fbSDimitry Andricdefm VMFGT_V : VCMP_FV_F<"vmfgt", 0b011101>;
14366e75b2fbSDimitry Andricdefm VMFGE_V : VCMP_FV_F<"vmfge", 0b011111>;
143781ad6265SDimitry Andric} // RVVConstraint = NoConstraint, mayRaiseFPException = true
14385ffd83dbSDimitry Andric
14395ffd83dbSDimitry Andricdef : InstAlias<"vmfgt.vv $vd, $va, $vb$vm",
1440e8d8bef9SDimitry Andric                (VMFLT_VV VR:$vd, VR:$vb, VR:$va, VMaskOp:$vm), 0>;
14415ffd83dbSDimitry Andricdef : InstAlias<"vmfge.vv $vd, $va, $vb$vm",
1442e8d8bef9SDimitry Andric                (VMFLE_VV VR:$vd, VR:$vb, VR:$va, VMaskOp:$vm), 0>;
14435ffd83dbSDimitry Andric
14445ffd83dbSDimitry Andric// Vector Floating-Point Classify Instruction
14456e75b2fbSDimitry Andricdefm VFCLASS_V : VCLS_FV_VS2<"vfclass.v", 0b010011, 0b10000>;
14465ffd83dbSDimitry Andric
14475ffd83dbSDimitry Andriclet hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
14486e75b2fbSDimitry Andric
14495ffd83dbSDimitry Andric// Vector Floating-Point Merge Instruction
14506e75b2fbSDimitry Andriclet vm = 0 in
1451e8d8bef9SDimitry Andricdef VFMERGE_VFM : RVInstVX<0b010111, OPFVF, (outs VR:$vd),
1452e8d8bef9SDimitry Andric                           (ins VR:$vs2, FPR32:$rs1, VMV0:$v0),
14536e75b2fbSDimitry Andric                           "vfmerge.vfm", "$vd, $vs2, $rs1, v0">,
1454*5f757f3fSDimitry Andric                  SchedBinaryMC<"WriteVFMergeV", "ReadVFMergeV", "ReadVFMergeF">;
14555ffd83dbSDimitry Andric
14565ffd83dbSDimitry Andric// Vector Floating-Point Move Instruction
1457e8d8bef9SDimitry Andriclet RVVConstraint = NoConstraint in
14586e75b2fbSDimitry Andriclet vm = 1, vs2 = 0 in
1459e8d8bef9SDimitry Andricdef VFMV_V_F : RVInstVX<0b010111, OPFVF, (outs VR:$vd),
14606e75b2fbSDimitry Andric                       (ins FPR32:$rs1), "vfmv.v.f", "$vd, $rs1">,
1461*5f757f3fSDimitry Andric               SchedUnaryMC<"WriteVFMovV", "ReadVFMovF", forceMasked=0>;
14626e75b2fbSDimitry Andric
14635ffd83dbSDimitry Andric} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
14645ffd83dbSDimitry Andric
14655ffd83dbSDimitry Andric// Single-Width Floating-Point/Integer Type-Convert Instructions
1466bdd1243dSDimitry Andriclet mayRaiseFPException = true in {
1467bdd1243dSDimitry Andriclet Uses = [FRM] in {
14686e75b2fbSDimitry Andricdefm VFCVT_XU_F_V : VCVTI_FV_VS2<"vfcvt.xu.f.v", 0b010010, 0b00000>;
14696e75b2fbSDimitry Andricdefm VFCVT_X_F_V : VCVTI_FV_VS2<"vfcvt.x.f.v", 0b010010, 0b00001>;
1470bdd1243dSDimitry Andric}
14716e75b2fbSDimitry Andricdefm VFCVT_RTZ_XU_F_V : VCVTI_FV_VS2<"vfcvt.rtz.xu.f.v", 0b010010, 0b00110>;
14726e75b2fbSDimitry Andricdefm VFCVT_RTZ_X_F_V : VCVTI_FV_VS2<"vfcvt.rtz.x.f.v", 0b010010, 0b00111>;
1473bdd1243dSDimitry Andriclet Uses = [FRM] in {
14746e75b2fbSDimitry Andricdefm VFCVT_F_XU_V : VCVTF_IV_VS2<"vfcvt.f.xu.v", 0b010010, 0b00010>;
14756e75b2fbSDimitry Andricdefm VFCVT_F_X_V : VCVTF_IV_VS2<"vfcvt.f.x.v", 0b010010, 0b00011>;
1476bdd1243dSDimitry Andric}
1477bdd1243dSDimitry Andric} // mayRaiseFPException = true
14785ffd83dbSDimitry Andric
14795ffd83dbSDimitry Andric// Widening Floating-Point/Integer Type-Convert Instructions
1480bdd1243dSDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = WidenCvt,
1481bdd1243dSDimitry Andric    mayRaiseFPException = true in {
1482bdd1243dSDimitry Andriclet Uses = [FRM] in {
14836e75b2fbSDimitry Andricdefm VFWCVT_XU_F_V : VWCVTI_FV_VS2<"vfwcvt.xu.f.v", 0b010010, 0b01000>;
14846e75b2fbSDimitry Andricdefm VFWCVT_X_F_V : VWCVTI_FV_VS2<"vfwcvt.x.f.v", 0b010010, 0b01001>;
1485bdd1243dSDimitry Andric}
14866e75b2fbSDimitry Andricdefm VFWCVT_RTZ_XU_F_V : VWCVTI_FV_VS2<"vfwcvt.rtz.xu.f.v", 0b010010, 0b01110>;
14876e75b2fbSDimitry Andricdefm VFWCVT_RTZ_X_F_V : VWCVTI_FV_VS2<"vfwcvt.rtz.x.f.v", 0b010010, 0b01111>;
14886e75b2fbSDimitry Andricdefm VFWCVT_F_XU_V : VWCVTF_IV_VS2<"vfwcvt.f.xu.v", 0b010010, 0b01010>;
14896e75b2fbSDimitry Andricdefm VFWCVT_F_X_V : VWCVTF_IV_VS2<"vfwcvt.f.x.v", 0b010010, 0b01011>;
14906e75b2fbSDimitry Andricdefm VFWCVT_F_F_V : VWCVTF_FV_VS2<"vfwcvt.f.f.v", 0b010010, 0b01100>;
14915ffd83dbSDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = WidenCvt
14925ffd83dbSDimitry Andric
14935ffd83dbSDimitry Andric// Narrowing Floating-Point/Integer Type-Convert Instructions
1494bdd1243dSDimitry Andriclet Constraints = "@earlyclobber $vd", mayRaiseFPException = true in {
1495bdd1243dSDimitry Andriclet Uses = [FRM] in {
14966e75b2fbSDimitry Andricdefm VFNCVT_XU_F_W : VNCVTI_FV_VS2<"vfncvt.xu.f.w", 0b010010, 0b10000>;
14976e75b2fbSDimitry Andricdefm VFNCVT_X_F_W : VNCVTI_FV_VS2<"vfncvt.x.f.w", 0b010010, 0b10001>;
1498bdd1243dSDimitry Andric}
14996e75b2fbSDimitry Andricdefm VFNCVT_RTZ_XU_F_W : VNCVTI_FV_VS2<"vfncvt.rtz.xu.f.w", 0b010010, 0b10110>;
15006e75b2fbSDimitry Andricdefm VFNCVT_RTZ_X_F_W : VNCVTI_FV_VS2<"vfncvt.rtz.x.f.w", 0b010010, 0b10111>;
1501bdd1243dSDimitry Andriclet Uses = [FRM] in {
15026e75b2fbSDimitry Andricdefm VFNCVT_F_XU_W : VNCVTF_IV_VS2<"vfncvt.f.xu.w", 0b010010, 0b10010>;
15036e75b2fbSDimitry Andricdefm VFNCVT_F_X_W : VNCVTF_IV_VS2<"vfncvt.f.x.w", 0b010010, 0b10011>;
15046e75b2fbSDimitry Andricdefm VFNCVT_F_F_W : VNCVTF_FV_VS2<"vfncvt.f.f.w", 0b010010, 0b10100>;
1505bdd1243dSDimitry Andric}
15066e75b2fbSDimitry Andricdefm VFNCVT_ROD_F_F_W : VNCVTF_FV_VS2<"vfncvt.rod.f.f.w", 0b010010, 0b10101>;
1507bdd1243dSDimitry Andric} // Constraints = "@earlyclobber $vd", mayRaiseFPException = true
150804eeddc0SDimitry Andric} // Predicates = HasVInstructionsAnyF]
15095ffd83dbSDimitry Andric
151004eeddc0SDimitry Andriclet Predicates = [HasVInstructions] in {
15116e75b2fbSDimitry Andric
15125ffd83dbSDimitry Andric// Vector Single-Width Integer Reduction Instructions
1513e8d8bef9SDimitry Andriclet RVVConstraint = NoConstraint in {
15146e75b2fbSDimitry Andricdefm VREDSUM  : VRED_MV_V<"vredsum", 0b000000>;
151506c3fb27SDimitry Andricdefm VREDMAXU : VREDMINMAX_MV_V<"vredmaxu", 0b000110>;
151606c3fb27SDimitry Andricdefm VREDMAX  : VREDMINMAX_MV_V<"vredmax", 0b000111>;
151706c3fb27SDimitry Andricdefm VREDMINU : VREDMINMAX_MV_V<"vredminu", 0b000100>;
151806c3fb27SDimitry Andricdefm VREDMIN  : VREDMINMAX_MV_V<"vredmin", 0b000101>;
15196e75b2fbSDimitry Andricdefm VREDAND  : VRED_MV_V<"vredand", 0b000001>;
15206e75b2fbSDimitry Andricdefm VREDOR   : VRED_MV_V<"vredor", 0b000010>;
15216e75b2fbSDimitry Andricdefm VREDXOR  : VRED_MV_V<"vredxor", 0b000011>;
1522e8d8bef9SDimitry Andric} // RVVConstraint = NoConstraint
15235ffd83dbSDimitry Andric
15245ffd83dbSDimitry Andric// Vector Widening Integer Reduction Instructions
1525e8d8bef9SDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = NoConstraint in {
15265ffd83dbSDimitry Andric// Set earlyclobber for following instructions for second and mask operands.
15275ffd83dbSDimitry Andric// This has the downside that the earlyclobber constraint is too coarse and
15285ffd83dbSDimitry Andric// will impose unnecessary restrictions by not allowing the destination to
15295ffd83dbSDimitry Andric// overlap with the first (wide) operand.
15306e75b2fbSDimitry Andricdefm VWREDSUMU : VWRED_IV_V<"vwredsumu", 0b110000>;
15316e75b2fbSDimitry Andricdefm VWREDSUM : VWRED_IV_V<"vwredsum", 0b110001>;
1532e8d8bef9SDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = NoConstraint
15336e75b2fbSDimitry Andric
153404eeddc0SDimitry Andric} // Predicates = [HasVInstructions]
15355ffd83dbSDimitry Andric
153604eeddc0SDimitry Andriclet Predicates = [HasVInstructionsAnyF] in {
15375ffd83dbSDimitry Andric// Vector Single-Width Floating-Point Reduction Instructions
1538e8d8bef9SDimitry Andriclet RVVConstraint = NoConstraint in {
153981ad6265SDimitry Andriclet Uses = [FRM], mayRaiseFPException = true in {
15406e75b2fbSDimitry Andricdefm VFREDOSUM : VREDO_FV_V<"vfredosum", 0b000011>;
1541349cc55cSDimitry Andricdefm VFREDUSUM : VRED_FV_V<"vfredusum", 0b000001>;
154281ad6265SDimitry Andric}
154381ad6265SDimitry Andriclet mayRaiseFPException = true in {
154406c3fb27SDimitry Andricdefm VFREDMAX : VREDMINMAX_FV_V<"vfredmax", 0b000111>;
154506c3fb27SDimitry Andricdefm VFREDMIN : VREDMINMAX_FV_V<"vfredmin", 0b000101>;
154681ad6265SDimitry Andric}
1547e8d8bef9SDimitry Andric} // RVVConstraint = NoConstraint
15485ffd83dbSDimitry Andric
1549349cc55cSDimitry Andricdef : InstAlias<"vfredsum.vs $vd, $vs2, $vs1$vm",
1550349cc55cSDimitry Andric                (VFREDUSUM_VS VR:$vd, VR:$vs2, VR:$vs1, VMaskOp:$vm), 0>;
1551349cc55cSDimitry Andric
15525ffd83dbSDimitry Andric// Vector Widening Floating-Point Reduction Instructions
1553e8d8bef9SDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = NoConstraint in {
15545ffd83dbSDimitry Andric// Set earlyclobber for following instructions for second and mask operands.
15555ffd83dbSDimitry Andric// This has the downside that the earlyclobber constraint is too coarse and
15565ffd83dbSDimitry Andric// will impose unnecessary restrictions by not allowing the destination to
15575ffd83dbSDimitry Andric// overlap with the first (wide) operand.
155881ad6265SDimitry Andriclet Uses = [FRM], mayRaiseFPException = true in {
15596e75b2fbSDimitry Andricdefm VFWREDOSUM : VWREDO_FV_V<"vfwredosum", 0b110011>;
1560349cc55cSDimitry Andricdefm VFWREDUSUM : VWRED_FV_V<"vfwredusum", 0b110001>;
156181ad6265SDimitry Andric}
1562e8d8bef9SDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = NoConstraint
1563349cc55cSDimitry Andric
1564349cc55cSDimitry Andricdef : InstAlias<"vfwredsum.vs $vd, $vs2, $vs1$vm",
1565349cc55cSDimitry Andric                (VFWREDUSUM_VS VR:$vd, VR:$vs2, VR:$vs1, VMaskOp:$vm), 0>;
156604eeddc0SDimitry Andric} // Predicates = [HasVInstructionsAnyF]
15675ffd83dbSDimitry Andric
156804eeddc0SDimitry Andriclet Predicates = [HasVInstructions] in {
15695ffd83dbSDimitry Andric// Vector Mask-Register Logical Instructions
1570e8d8bef9SDimitry Andriclet RVVConstraint = NoConstraint in {
15716e75b2fbSDimitry Andricdefm VMAND_M : VMALU_MV_Mask<"vmand", 0b011001, "m">;
15726e75b2fbSDimitry Andricdefm VMNAND_M : VMALU_MV_Mask<"vmnand", 0b011101, "m">;
1573349cc55cSDimitry Andricdefm VMANDN_M : VMALU_MV_Mask<"vmandn", 0b011000, "m">;
15746e75b2fbSDimitry Andricdefm VMXOR_M : VMALU_MV_Mask<"vmxor", 0b011011, "m">;
15756e75b2fbSDimitry Andricdefm VMOR_M : VMALU_MV_Mask<"vmor", 0b011010, "m">;
15766e75b2fbSDimitry Andricdefm VMNOR_M : VMALU_MV_Mask<"vmnor", 0b011110, "m">;
1577349cc55cSDimitry Andricdefm VMORN_M : VMALU_MV_Mask<"vmorn", 0b011100, "m">;
15786e75b2fbSDimitry Andricdefm VMXNOR_M : VMALU_MV_Mask<"vmxnor", 0b011111, "m">;
1579e8d8bef9SDimitry Andric}
15805ffd83dbSDimitry Andric
1581e8d8bef9SDimitry Andricdef : InstAlias<"vmmv.m $vd, $vs",
1582e8d8bef9SDimitry Andric                (VMAND_MM VR:$vd, VR:$vs, VR:$vs)>;
15835ffd83dbSDimitry Andricdef : InstAlias<"vmclr.m $vd",
1584e8d8bef9SDimitry Andric                (VMXOR_MM VR:$vd, VR:$vd, VR:$vd)>;
15855ffd83dbSDimitry Andricdef : InstAlias<"vmset.m $vd",
1586e8d8bef9SDimitry Andric                (VMXNOR_MM VR:$vd, VR:$vd, VR:$vd)>;
15875ffd83dbSDimitry Andricdef : InstAlias<"vmnot.m $vd, $vs",
1588e8d8bef9SDimitry Andric                (VMNAND_MM VR:$vd, VR:$vs, VR:$vs)>;
15895ffd83dbSDimitry Andric
1590349cc55cSDimitry Andricdef : InstAlias<"vmandnot.mm $vd, $vs2, $vs1",
1591349cc55cSDimitry Andric                (VMANDN_MM VR:$vd, VR:$vs2, VR:$vs1), 0>;
1592349cc55cSDimitry Andricdef : InstAlias<"vmornot.mm $vd, $vs2, $vs1",
1593349cc55cSDimitry Andric                (VMORN_MM VR:$vd, VR:$vs2, VR:$vs1), 0>;
1594349cc55cSDimitry Andric
1595e8d8bef9SDimitry Andriclet hasSideEffects = 0, mayLoad = 0, mayStore = 0,
1596e8d8bef9SDimitry Andric    RVVConstraint = NoConstraint  in {
15976e75b2fbSDimitry Andric
1598349cc55cSDimitry Andric// Vector mask population count vcpop
1599349cc55cSDimitry Andricdef VCPOP_M : RVInstV<0b010000, 0b10000, OPMVV, (outs GPR:$vd),
1600e8d8bef9SDimitry Andric                      (ins VR:$vs2, VMaskOp:$vm),
1601349cc55cSDimitry Andric                      "vcpop.m", "$vd, $vs2$vm">,
1602*5f757f3fSDimitry Andric              SchedUnaryMC<"WriteVMPopV", "ReadVMPopV">;
16035ffd83dbSDimitry Andric
16045ffd83dbSDimitry Andric// vfirst find-first-set mask bit
16055ffd83dbSDimitry Andricdef VFIRST_M : RVInstV<0b010000, 0b10001, OPMVV, (outs GPR:$vd),
1606e8d8bef9SDimitry Andric                       (ins VR:$vs2, VMaskOp:$vm),
16076e75b2fbSDimitry Andric                       "vfirst.m", "$vd, $vs2$vm">,
1608*5f757f3fSDimitry Andric              SchedUnaryMC<"WriteVMFFSV", "ReadVMFFSV">;
16096e75b2fbSDimitry Andric
16105ffd83dbSDimitry Andric} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
16115ffd83dbSDimitry Andric
1612349cc55cSDimitry Andricdef : InstAlias<"vpopc.m $vd, $vs2$vm",
1613349cc55cSDimitry Andric                (VCPOP_M GPR:$vd, VR:$vs2, VMaskOp:$vm), 0>;
1614349cc55cSDimitry Andric
1615e8d8bef9SDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = Iota in {
16166e75b2fbSDimitry Andric
16175ffd83dbSDimitry Andric// vmsbf.m set-before-first mask bit
16186e75b2fbSDimitry Andricdefm VMSBF_M : VMSFS_MV_V<"vmsbf.m", 0b010100, 0b00001>;
16195ffd83dbSDimitry Andric// vmsif.m set-including-first mask bit
16206e75b2fbSDimitry Andricdefm VMSIF_M : VMSFS_MV_V<"vmsif.m", 0b010100, 0b00011>;
16215ffd83dbSDimitry Andric// vmsof.m set-only-first mask bit
16226e75b2fbSDimitry Andricdefm VMSOF_M : VMSFS_MV_V<"vmsof.m", 0b010100, 0b00010>;
16235ffd83dbSDimitry Andric// Vector Iota Instruction
16246e75b2fbSDimitry Andricdefm VIOTA_M : VMIOT_MV_V<"viota.m", 0b010100, 0b10000>;
16256e75b2fbSDimitry Andric
16265ffd83dbSDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = Iota
16275ffd83dbSDimitry Andric
16285ffd83dbSDimitry Andric// Vector Element Index Instruction
16295ffd83dbSDimitry Andriclet hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
16306e75b2fbSDimitry Andric
16316e75b2fbSDimitry Andriclet vs2 = 0 in
1632e8d8bef9SDimitry Andricdef VID_V : RVInstV<0b010100, 0b10001, OPMVV, (outs VR:$vd),
16336e75b2fbSDimitry Andric                    (ins VMaskOp:$vm), "vid.v", "$vd$vm">,
1634*5f757f3fSDimitry Andric            SchedNullaryMC<"WriteVMIdxV">;
16355ffd83dbSDimitry Andric
16365ffd83dbSDimitry Andric// Integer Scalar Move Instructions
1637e8d8bef9SDimitry Andriclet vm = 1, RVVConstraint = NoConstraint in {
16385ffd83dbSDimitry Andricdef VMV_X_S : RVInstV<0b010000, 0b00000, OPMVV, (outs GPR:$vd),
16396e75b2fbSDimitry Andric                      (ins VR:$vs2), "vmv.x.s", "$vd, $vs2">,
164006c3fb27SDimitry Andric              Sched<[WriteVIMovVX, ReadVIMovVX]>;
1641e8d8bef9SDimitry Andriclet Constraints = "$vd = $vd_wb" in
1642e8d8bef9SDimitry Andricdef VMV_S_X : RVInstV2<0b010000, 0b00000, OPMVX, (outs VR:$vd_wb),
16436e75b2fbSDimitry Andric                      (ins VR:$vd, GPR:$rs1), "vmv.s.x", "$vd, $rs1">,
164406c3fb27SDimitry Andric              Sched<[WriteVIMovXV, ReadVIMovXV, ReadVIMovXX]>;
16455ffd83dbSDimitry Andric}
16466e75b2fbSDimitry Andric
16475ffd83dbSDimitry Andric} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
16486e75b2fbSDimitry Andric
164904eeddc0SDimitry Andric} // Predicates = [HasVInstructions]
16505ffd83dbSDimitry Andric
165104eeddc0SDimitry Andriclet Predicates = [HasVInstructionsAnyF] in {
16526e75b2fbSDimitry Andric
1653e8d8bef9SDimitry Andriclet hasSideEffects = 0, mayLoad = 0, mayStore = 0, vm = 1,
1654e8d8bef9SDimitry Andric    RVVConstraint = NoConstraint  in {
16555ffd83dbSDimitry Andric// Floating-Point Scalar Move Instructions
16565ffd83dbSDimitry Andricdef VFMV_F_S : RVInstV<0b010000, 0b00000, OPFVV, (outs FPR32:$vd),
16576e75b2fbSDimitry Andric                      (ins VR:$vs2), "vfmv.f.s", "$vd, $vs2">,
165806c3fb27SDimitry Andric               Sched<[WriteVFMovVF, ReadVFMovVF]>;
1659e8d8bef9SDimitry Andriclet Constraints = "$vd = $vd_wb" in
1660e8d8bef9SDimitry Andricdef VFMV_S_F : RVInstV2<0b010000, 0b00000, OPFVF, (outs VR:$vd_wb),
16616e75b2fbSDimitry Andric                       (ins VR:$vd, FPR32:$rs1), "vfmv.s.f", "$vd, $rs1">,
166206c3fb27SDimitry Andric               Sched<[WriteVFMovFV, ReadVFMovFV, ReadVFMovFX]>;
16635ffd83dbSDimitry Andric
16645ffd83dbSDimitry Andric} // hasSideEffects = 0, mayLoad = 0, mayStore = 0, vm = 1
16656e75b2fbSDimitry Andric
166604eeddc0SDimitry Andric} // Predicates = [HasVInstructionsAnyF]
16675ffd83dbSDimitry Andric
166804eeddc0SDimitry Andriclet Predicates = [HasVInstructions] in {
16695ffd83dbSDimitry Andric// Vector Slide Instructions
16705ffd83dbSDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = SlideUp in {
167106c3fb27SDimitry Andricdefm VSLIDEUP_V : VSLD_IV_X_I<"vslideup", 0b001110>;
16726e75b2fbSDimitry Andricdefm VSLIDE1UP_V : VSLD1_MV_X<"vslide1up", 0b001110>;
16735ffd83dbSDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = SlideUp
167406c3fb27SDimitry Andricdefm VSLIDEDOWN_V : VSLD_IV_X_I<"vslidedown", 0b001111>;
16756e75b2fbSDimitry Andricdefm VSLIDE1DOWN_V : VSLD1_MV_X<"vslide1down", 0b001111>;
167604eeddc0SDimitry Andric} // Predicates = [HasVInstructions]
16775ffd83dbSDimitry Andric
167804eeddc0SDimitry Andriclet Predicates = [HasVInstructionsAnyF] in {
1679e8d8bef9SDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = SlideUp in {
16806e75b2fbSDimitry Andricdefm VFSLIDE1UP_V : VSLD1_FV_F<"vfslide1up", 0b001110>;
1681e8d8bef9SDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = SlideUp
16826e75b2fbSDimitry Andricdefm VFSLIDE1DOWN_V : VSLD1_FV_F<"vfslide1down", 0b001111>;
168304eeddc0SDimitry Andric} // Predicates = [HasVInstructionsAnyF]
1684e8d8bef9SDimitry Andric
168504eeddc0SDimitry Andriclet Predicates = [HasVInstructions] in {
16865ffd83dbSDimitry Andric// Vector Register Gather Instruction
16875ffd83dbSDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = Vrgather in {
168806c3fb27SDimitry Andricdefm VRGATHER_V : VGTR_IV_V_X_I<"vrgather", 0b001100>;
16896e75b2fbSDimitry Andricdef VRGATHEREI16_VV : VALUVV<0b001110, OPIVV, "vrgatherei16.vv">,
1690*5f757f3fSDimitry Andric                      SchedBinaryMC<"WriteVRGatherVV", "ReadVRGatherVV_data",
1691*5f757f3fSDimitry Andric                                    "ReadVRGatherVV_index">;
16925ffd83dbSDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = Vrgather
16935ffd83dbSDimitry Andric
16945ffd83dbSDimitry Andric// Vector Compress Instruction
16955ffd83dbSDimitry Andriclet Constraints = "@earlyclobber $vd", RVVConstraint = Vcompress in {
16966e75b2fbSDimitry Andricdefm VCOMPRESS_V : VCPR_MV_Mask<"vcompress", 0b010111>;
16975ffd83dbSDimitry Andric} // Constraints = "@earlyclobber $vd", RVVConstraint = Vcompress
16985ffd83dbSDimitry Andric
169906c3fb27SDimitry Andriclet hasSideEffects = 0, mayLoad = 0, mayStore = 0, isMoveReg = 1,
1700e8d8bef9SDimitry Andric    RVVConstraint = NoConstraint in {
17010eae32dcSDimitry Andric// A future extension may relax the vector register alignment restrictions.
1702753f127fSDimitry Andricforeach n = [1, 2, 4, 8] in {
1703753f127fSDimitry Andric  defvar vrc = !cast<VReg>(!if(!eq(n, 1), "VR", "VRM"#n));
17040eae32dcSDimitry Andric  def VMV#n#R_V  : RVInstV<0b100111, !add(n, -1), OPIVI, (outs vrc:$vd),
17050eae32dcSDimitry Andric                           (ins vrc:$vs2), "vmv" # n # "r.v", "$vd, $vs2">,
17066e75b2fbSDimitry Andric                   VMVRSched<n> {
17075ffd83dbSDimitry Andric    let Uses = [];
17085ffd83dbSDimitry Andric    let vm = 1;
17095ffd83dbSDimitry Andric  }
17105ffd83dbSDimitry Andric}
17115ffd83dbSDimitry Andric} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
171204eeddc0SDimitry Andric} // Predicates = [HasVInstructions]
1713e8d8bef9SDimitry Andric
171404eeddc0SDimitry Andriclet Predicates = [HasVInstructions] in {
1715e8d8bef9SDimitry Andric  foreach nf=2-8 in {
171604eeddc0SDimitry Andric    foreach eew = [8, 16, 32] in {
1717349cc55cSDimitry Andric      defvar w = !cast<RISCVWidth>("LSWidth"#eew);
1718e8d8bef9SDimitry Andric
1719349cc55cSDimitry Andric      def VLSEG#nf#E#eew#_V :
1720753f127fSDimitry Andric        VUnitStrideSegmentLoad<!add(nf, -1), w, "vlseg"#nf#"e"#eew#".v">,
1721*5f757f3fSDimitry Andric        VLSEGSchedMC<nf, eew>;
1722349cc55cSDimitry Andric      def VLSEG#nf#E#eew#FF_V :
1723753f127fSDimitry Andric        VUnitStrideSegmentLoadFF<!add(nf, -1), w, "vlseg"#nf#"e"#eew#"ff.v">,
1724*5f757f3fSDimitry Andric        VLSEGFFSchedMC<nf, eew>;
1725349cc55cSDimitry Andric      def VSSEG#nf#E#eew#_V :
1726753f127fSDimitry Andric        VUnitStrideSegmentStore<!add(nf, -1), w, "vsseg"#nf#"e"#eew#".v">,
1727*5f757f3fSDimitry Andric        VSSEGSchedMC<nf, eew>;
1728e8d8bef9SDimitry Andric      // Vector Strided Instructions
1729349cc55cSDimitry Andric      def VLSSEG#nf#E#eew#_V :
1730753f127fSDimitry Andric        VStridedSegmentLoad<!add(nf, -1), w, "vlsseg"#nf#"e"#eew#".v">,
1731*5f757f3fSDimitry Andric        VLSSEGSchedMC<nf, eew>;
1732349cc55cSDimitry Andric      def VSSSEG#nf#E#eew#_V :
1733753f127fSDimitry Andric        VStridedSegmentStore<!add(nf, -1), w, "vssseg"#nf#"e"#eew#".v">,
1734*5f757f3fSDimitry Andric        VSSSEGSchedMC<nf, eew>;
1735e8d8bef9SDimitry Andric
1736e8d8bef9SDimitry Andric      // Vector Indexed Instructions
1737349cc55cSDimitry Andric      def VLUXSEG#nf#EI#eew#_V :
1738349cc55cSDimitry Andric        VIndexedSegmentLoad<!add(nf, -1), MOPLDIndexedUnord, w,
1739bdd1243dSDimitry Andric                            "vluxseg"#nf#"ei"#eew#".v">,
1740*5f757f3fSDimitry Andric        VLXSEGSchedMC<nf, eew, isOrdered=0>;
1741349cc55cSDimitry Andric      def VLOXSEG#nf#EI#eew#_V :
1742349cc55cSDimitry Andric        VIndexedSegmentLoad<!add(nf, -1), MOPLDIndexedOrder, w,
1743bdd1243dSDimitry Andric                            "vloxseg"#nf#"ei"#eew#".v">,
1744*5f757f3fSDimitry Andric        VLXSEGSchedMC<nf, eew, isOrdered=1>;
1745349cc55cSDimitry Andric      def VSUXSEG#nf#EI#eew#_V :
1746349cc55cSDimitry Andric        VIndexedSegmentStore<!add(nf, -1), MOPSTIndexedUnord, w,
1747bdd1243dSDimitry Andric                             "vsuxseg"#nf#"ei"#eew#".v">,
1748*5f757f3fSDimitry Andric        VSXSEGSchedMC<nf, eew, isOrdered=0>;
1749349cc55cSDimitry Andric      def VSOXSEG#nf#EI#eew#_V :
1750349cc55cSDimitry Andric        VIndexedSegmentStore<!add(nf, -1), MOPSTIndexedOrder, w,
1751bdd1243dSDimitry Andric                             "vsoxseg"#nf#"ei"#eew#".v">,
1752*5f757f3fSDimitry Andric        VSXSEGSchedMC<nf, eew, isOrdered=1>;
1753349cc55cSDimitry Andric    }
1754e8d8bef9SDimitry Andric  }
175504eeddc0SDimitry Andric} // Predicates = [HasVInstructions]
175604eeddc0SDimitry Andric
175704eeddc0SDimitry Andriclet Predicates = [HasVInstructionsI64] in {
175804eeddc0SDimitry Andric  foreach nf=2-8 in {
175904eeddc0SDimitry Andric    // Vector Unit-strided Segment Instructions
176004eeddc0SDimitry Andric    def VLSEG#nf#E64_V :
1761753f127fSDimitry Andric      VUnitStrideSegmentLoad<!add(nf, -1), LSWidth64, "vlseg"#nf#"e64.v">,
1762*5f757f3fSDimitry Andric      VLSEGSchedMC<nf, 64>;
176304eeddc0SDimitry Andric    def VLSEG#nf#E64FF_V :
1764753f127fSDimitry Andric      VUnitStrideSegmentLoadFF<!add(nf, -1), LSWidth64, "vlseg"#nf#"e64ff.v">,
1765*5f757f3fSDimitry Andric      VLSEGFFSchedMC<nf, 64>;
176604eeddc0SDimitry Andric    def VSSEG#nf#E64_V :
1767753f127fSDimitry Andric      VUnitStrideSegmentStore<!add(nf, -1), LSWidth64, "vsseg"#nf#"e64.v">,
1768*5f757f3fSDimitry Andric      VSSEGSchedMC<nf, 64>;
176904eeddc0SDimitry Andric
177004eeddc0SDimitry Andric    // Vector Strided Segment Instructions
177104eeddc0SDimitry Andric    def VLSSEG#nf#E64_V :
1772753f127fSDimitry Andric      VStridedSegmentLoad<!add(nf, -1), LSWidth64, "vlsseg"#nf#"e64.v">,
1773*5f757f3fSDimitry Andric      VLSSEGSchedMC<nf, 64>;
177404eeddc0SDimitry Andric    def VSSSEG#nf#E64_V :
1775753f127fSDimitry Andric      VStridedSegmentStore<!add(nf, -1), LSWidth64, "vssseg"#nf#"e64.v">,
1776*5f757f3fSDimitry Andric      VSSSEGSchedMC<nf, 64>;
177704eeddc0SDimitry Andric  }
177804eeddc0SDimitry Andric} // Predicates = [HasVInstructionsI64]
177904eeddc0SDimitry Andriclet Predicates = [HasVInstructionsI64, IsRV64] in {
178004eeddc0SDimitry Andric  foreach nf = 2 - 8 in {
178104eeddc0SDimitry Andric    // Vector Indexed Segment Instructions
1782bdd1243dSDimitry Andric    def VLUXSEG #nf #EI64_V
1783bdd1243dSDimitry Andric        : VIndexedSegmentLoad<!add(nf, -1), MOPLDIndexedUnord, LSWidth64,
1784bdd1243dSDimitry Andric                              "vluxseg" #nf #"ei64.v">,
1785*5f757f3fSDimitry Andric          VLXSEGSchedMC<nf, 64, isOrdered=0>;
1786bdd1243dSDimitry Andric    def VLOXSEG #nf #EI64_V
1787bdd1243dSDimitry Andric        : VIndexedSegmentLoad<!add(nf, -1), MOPLDIndexedOrder, LSWidth64,
1788bdd1243dSDimitry Andric                              "vloxseg" #nf #"ei64.v">,
1789*5f757f3fSDimitry Andric          VLXSEGSchedMC<nf, 64, isOrdered=1>;
1790bdd1243dSDimitry Andric    def VSUXSEG #nf #EI64_V
1791bdd1243dSDimitry Andric        : VIndexedSegmentStore<!add(nf, -1), MOPSTIndexedUnord, LSWidth64,
1792bdd1243dSDimitry Andric                               "vsuxseg" #nf #"ei64.v">,
1793*5f757f3fSDimitry Andric          VSXSEGSchedMC<nf, 64, isOrdered=0>;
1794bdd1243dSDimitry Andric    def VSOXSEG #nf #EI64_V
1795bdd1243dSDimitry Andric        : VIndexedSegmentStore<!add(nf, -1), MOPSTIndexedOrder, LSWidth64,
1796bdd1243dSDimitry Andric                               "vsoxseg" #nf #"ei64.v">,
1797*5f757f3fSDimitry Andric          VSXSEGSchedMC<nf, 64, isOrdered=1>;
179804eeddc0SDimitry Andric  }
179904eeddc0SDimitry Andric} // Predicates = [HasVInstructionsI64, IsRV64]
1800e8d8bef9SDimitry Andric
1801*5f757f3fSDimitry Andricinclude "RISCVInstrInfoZvfbf.td"
1802e8d8bef9SDimitry Andricinclude "RISCVInstrInfoVPseudos.td"
1803