xref: /freebsd/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1fe6060f1SDimitry Andric//===- RISCVInstrInfoVVLPatterns.td - RVV VL patterns ------*- tablegen -*-===//
2fe6060f1SDimitry Andric//
3fe6060f1SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4fe6060f1SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
5fe6060f1SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6fe6060f1SDimitry Andric//
7fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
8fe6060f1SDimitry Andric///
9fe6060f1SDimitry Andric/// This file contains the required infrastructure and VL patterns to
10fe6060f1SDimitry Andric/// support code generation for the standard 'V' (Vector) extension, version
1181ad6265SDimitry Andric/// version 1.0.
12fe6060f1SDimitry Andric///
13fe6060f1SDimitry Andric/// This file is included from and depends upon RISCVInstrInfoVPseudos.td
14fe6060f1SDimitry Andric///
15fe6060f1SDimitry Andric/// Note: the patterns for RVV intrinsics are found in
16fe6060f1SDimitry Andric/// RISCVInstrInfoVPseudos.td.
17fe6060f1SDimitry Andric///
18fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
19fe6060f1SDimitry Andric
20fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
21fe6060f1SDimitry Andric// Helpers to define the VL patterns.
22fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
23fe6060f1SDimitry Andric
2406c3fb27SDimitry Andricdef SDT_RISCVIntUnOp_VL : SDTypeProfile<1, 4, [SDTCisSameAs<0, 1>,
2506c3fb27SDimitry Andric                                               SDTCisSameAs<0, 2>,
2606c3fb27SDimitry Andric                                               SDTCisVec<0>, SDTCisInt<0>,
2706c3fb27SDimitry Andric                                               SDTCVecEltisVT<3, i1>,
2806c3fb27SDimitry Andric                                               SDTCisSameNumEltsAs<0, 3>,
2906c3fb27SDimitry Andric                                               SDTCisVT<4, XLenVT>]>;
3006c3fb27SDimitry Andric
31bdd1243dSDimitry Andricdef SDT_RISCVIntBinOp_VL : SDTypeProfile<1, 5, [SDTCisSameAs<0, 1>,
32fe6060f1SDimitry Andric                                                SDTCisSameAs<0, 2>,
33fe6060f1SDimitry Andric                                                SDTCisVec<0>, SDTCisInt<0>,
34bdd1243dSDimitry Andric                                                SDTCisSameAs<0, 3>,
35bdd1243dSDimitry Andric                                                SDTCVecEltisVT<4, i1>,
36bdd1243dSDimitry Andric                                                SDTCisSameNumEltsAs<0, 4>,
37bdd1243dSDimitry Andric                                                SDTCisVT<5, XLenVT>]>;
38fe6060f1SDimitry Andric
39*0fca6ea1SDimitry Andric// Input: (vector, vector/scalar, merge, mask, roundmode, vl)
40*0fca6ea1SDimitry Andricdef SDT_RISCVVNBinOp_RM_VL : SDTypeProfile<1, 6, [SDTCisVec<0>, SDTCisInt<0>,
41*0fca6ea1SDimitry Andric                                                  SDTCisSameAs<0, 3>,
42*0fca6ea1SDimitry Andric                                                  SDTCisSameNumEltsAs<0, 1>,
43*0fca6ea1SDimitry Andric                                                  SDTCisVec<1>,
44*0fca6ea1SDimitry Andric                                                  SDTCisOpSmallerThanOp<2, 1>,
45*0fca6ea1SDimitry Andric                                                  SDTCisSameAs<0, 2>,
46*0fca6ea1SDimitry Andric                                                  SDTCisSameNumEltsAs<0, 4>,
47*0fca6ea1SDimitry Andric                                                  SDTCVecEltisVT<4, i1>,
48*0fca6ea1SDimitry Andric                                                  SDTCisVT<5, XLenVT>,
49*0fca6ea1SDimitry Andric                                                  SDTCisVT<6, XLenVT>]>;
50*0fca6ea1SDimitry Andric
51fe6060f1SDimitry Andricdef SDT_RISCVFPUnOp_VL : SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>,
52fe6060f1SDimitry Andric                                              SDTCisVec<0>, SDTCisFP<0>,
53fe6060f1SDimitry Andric                                              SDTCVecEltisVT<2, i1>,
54fe6060f1SDimitry Andric                                              SDTCisSameNumEltsAs<0, 2>,
55fe6060f1SDimitry Andric                                              SDTCisVT<3, XLenVT>]>;
56bdd1243dSDimitry Andricdef SDT_RISCVFPBinOp_VL : SDTypeProfile<1, 5, [SDTCisSameAs<0, 1>,
57fe6060f1SDimitry Andric                                               SDTCisSameAs<0, 2>,
58fe6060f1SDimitry Andric                                               SDTCisVec<0>, SDTCisFP<0>,
59bdd1243dSDimitry Andric                                               SDTCisSameAs<0, 3>,
60bdd1243dSDimitry Andric                                               SDTCVecEltisVT<4, i1>,
61bdd1243dSDimitry Andric                                               SDTCisSameNumEltsAs<0, 4>,
62bdd1243dSDimitry Andric                                               SDTCisVT<5, XLenVT>]>;
63bdd1243dSDimitry Andric
64bdd1243dSDimitry Andricdef SDT_RISCVCopySign_VL : SDTypeProfile<1, 5, [SDTCisSameAs<0, 1>,
65bdd1243dSDimitry Andric                                                SDTCisSameAs<0, 2>,
66bdd1243dSDimitry Andric                                                SDTCisVec<0>, SDTCisFP<0>,
67bdd1243dSDimitry Andric                                                SDTCisSameAs<0, 3>,
68bdd1243dSDimitry Andric                                                SDTCVecEltisVT<4, i1>,
69bdd1243dSDimitry Andric                                                SDTCisSameNumEltsAs<0, 4>,
70bdd1243dSDimitry Andric                                                SDTCisVT<5, XLenVT>]>;
71fe6060f1SDimitry Andric
7206c3fb27SDimitry Andricdef riscv_vmv_v_v_vl : SDNode<"RISCVISD::VMV_V_V_VL",
7306c3fb27SDimitry Andric                              SDTypeProfile<1, 3, [SDTCisVec<0>,
7406c3fb27SDimitry Andric                                                   SDTCisSameAs<0, 1>,
7506c3fb27SDimitry Andric                                                   SDTCisSameAs<0, 2>,
7606c3fb27SDimitry Andric                                                   SDTCisVT<3, XLenVT>]>>;
77fe6060f1SDimitry Andricdef riscv_vmv_v_x_vl : SDNode<"RISCVISD::VMV_V_X_VL",
7881ad6265SDimitry Andric                              SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisInt<0>,
7981ad6265SDimitry Andric                                                   SDTCisSameAs<0, 1>,
8081ad6265SDimitry Andric                                                   SDTCisVT<2, XLenVT>,
8181ad6265SDimitry Andric                                                   SDTCisVT<3, XLenVT>]>>;
82fe6060f1SDimitry Andricdef riscv_vfmv_v_f_vl : SDNode<"RISCVISD::VFMV_V_F_VL",
8381ad6265SDimitry Andric                               SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisFP<0>,
8481ad6265SDimitry Andric                                                    SDTCisSameAs<0, 1>,
8581ad6265SDimitry Andric                                                    SDTCisEltOfVec<2, 0>,
8681ad6265SDimitry Andric                                                    SDTCisVT<3, XLenVT>]>>;
87fe6060f1SDimitry Andricdef riscv_vmv_s_x_vl : SDNode<"RISCVISD::VMV_S_X_VL",
88fe6060f1SDimitry Andric                              SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>,
89fe6060f1SDimitry Andric                                                   SDTCisInt<0>,
90fe6060f1SDimitry Andric                                                   SDTCisVT<2, XLenVT>,
91fe6060f1SDimitry Andric                                                   SDTCisVT<3, XLenVT>]>>;
92fe6060f1SDimitry Andricdef riscv_vfmv_s_f_vl : SDNode<"RISCVISD::VFMV_S_F_VL",
93fe6060f1SDimitry Andric                               SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>,
94fe6060f1SDimitry Andric                                                    SDTCisFP<0>,
95fe6060f1SDimitry Andric                                                    SDTCisEltOfVec<2, 0>,
96fe6060f1SDimitry Andric                                                    SDTCisVT<3, XLenVT>]>>;
97fe6060f1SDimitry Andric
98fe6060f1SDimitry Andricdef riscv_add_vl   : SDNode<"RISCVISD::ADD_VL",   SDT_RISCVIntBinOp_VL, [SDNPCommutative]>;
99fe6060f1SDimitry Andricdef riscv_sub_vl   : SDNode<"RISCVISD::SUB_VL",   SDT_RISCVIntBinOp_VL>;
100fe6060f1SDimitry Andricdef riscv_mul_vl   : SDNode<"RISCVISD::MUL_VL",   SDT_RISCVIntBinOp_VL, [SDNPCommutative]>;
101fe6060f1SDimitry Andricdef riscv_mulhs_vl : SDNode<"RISCVISD::MULHS_VL", SDT_RISCVIntBinOp_VL, [SDNPCommutative]>;
102fe6060f1SDimitry Andricdef riscv_mulhu_vl : SDNode<"RISCVISD::MULHU_VL", SDT_RISCVIntBinOp_VL, [SDNPCommutative]>;
103fe6060f1SDimitry Andricdef riscv_and_vl   : SDNode<"RISCVISD::AND_VL",   SDT_RISCVIntBinOp_VL, [SDNPCommutative]>;
104fe6060f1SDimitry Andricdef riscv_or_vl    : SDNode<"RISCVISD::OR_VL",    SDT_RISCVIntBinOp_VL, [SDNPCommutative]>;
105fe6060f1SDimitry Andricdef riscv_xor_vl   : SDNode<"RISCVISD::XOR_VL",   SDT_RISCVIntBinOp_VL, [SDNPCommutative]>;
106fe6060f1SDimitry Andricdef riscv_sdiv_vl  : SDNode<"RISCVISD::SDIV_VL",  SDT_RISCVIntBinOp_VL>;
107fe6060f1SDimitry Andricdef riscv_srem_vl  : SDNode<"RISCVISD::SREM_VL",  SDT_RISCVIntBinOp_VL>;
108fe6060f1SDimitry Andricdef riscv_udiv_vl  : SDNode<"RISCVISD::UDIV_VL",  SDT_RISCVIntBinOp_VL>;
109fe6060f1SDimitry Andricdef riscv_urem_vl  : SDNode<"RISCVISD::UREM_VL",  SDT_RISCVIntBinOp_VL>;
110fe6060f1SDimitry Andricdef riscv_shl_vl   : SDNode<"RISCVISD::SHL_VL",   SDT_RISCVIntBinOp_VL>;
111fe6060f1SDimitry Andricdef riscv_sra_vl   : SDNode<"RISCVISD::SRA_VL",   SDT_RISCVIntBinOp_VL>;
112fe6060f1SDimitry Andricdef riscv_srl_vl   : SDNode<"RISCVISD::SRL_VL",   SDT_RISCVIntBinOp_VL>;
1135f757f3fSDimitry Andricdef riscv_rotl_vl  : SDNode<"RISCVISD::ROTL_VL",  SDT_RISCVIntBinOp_VL>;
1145f757f3fSDimitry Andricdef riscv_rotr_vl  : SDNode<"RISCVISD::ROTR_VL",  SDT_RISCVIntBinOp_VL>;
115753f127fSDimitry Andricdef riscv_smin_vl  : SDNode<"RISCVISD::SMIN_VL",  SDT_RISCVIntBinOp_VL, [SDNPCommutative]>;
116753f127fSDimitry Andricdef riscv_smax_vl  : SDNode<"RISCVISD::SMAX_VL",  SDT_RISCVIntBinOp_VL, [SDNPCommutative]>;
117753f127fSDimitry Andricdef riscv_umin_vl  : SDNode<"RISCVISD::UMIN_VL",  SDT_RISCVIntBinOp_VL, [SDNPCommutative]>;
118753f127fSDimitry Andricdef riscv_umax_vl  : SDNode<"RISCVISD::UMAX_VL",  SDT_RISCVIntBinOp_VL, [SDNPCommutative]>;
119fe6060f1SDimitry Andric
12006c3fb27SDimitry Andricdef riscv_bitreverse_vl : SDNode<"RISCVISD::BITREVERSE_VL", SDT_RISCVIntUnOp_VL>;
12106c3fb27SDimitry Andricdef riscv_bswap_vl      : SDNode<"RISCVISD::BSWAP_VL",      SDT_RISCVIntUnOp_VL>;
12206c3fb27SDimitry Andricdef riscv_ctlz_vl       : SDNode<"RISCVISD::CTLZ_VL",       SDT_RISCVIntUnOp_VL>;
12306c3fb27SDimitry Andricdef riscv_cttz_vl       : SDNode<"RISCVISD::CTTZ_VL",       SDT_RISCVIntUnOp_VL>;
12406c3fb27SDimitry Andricdef riscv_ctpop_vl      : SDNode<"RISCVISD::CTPOP_VL",      SDT_RISCVIntUnOp_VL>;
12506c3fb27SDimitry Andric
126*0fca6ea1SDimitry Andricdef riscv_avgfloors_vl  : SDNode<"RISCVISD::AVGFLOORS_VL", SDT_RISCVIntBinOp_VL, [SDNPCommutative]>;
1271db9f3b2SDimitry Andricdef riscv_avgflooru_vl  : SDNode<"RISCVISD::AVGFLOORU_VL", SDT_RISCVIntBinOp_VL, [SDNPCommutative]>;
128*0fca6ea1SDimitry Andricdef riscv_avgceils_vl   : SDNode<"RISCVISD::AVGCEILS_VL", SDT_RISCVIntBinOp_VL, [SDNPCommutative]>;
129297eecfbSDimitry Andricdef riscv_avgceilu_vl   : SDNode<"RISCVISD::AVGCEILU_VL", SDT_RISCVIntBinOp_VL, [SDNPCommutative]>;
130753f127fSDimitry Andricdef riscv_saddsat_vl   : SDNode<"RISCVISD::SADDSAT_VL", SDT_RISCVIntBinOp_VL, [SDNPCommutative]>;
131753f127fSDimitry Andricdef riscv_uaddsat_vl   : SDNode<"RISCVISD::UADDSAT_VL", SDT_RISCVIntBinOp_VL, [SDNPCommutative]>;
132fe6060f1SDimitry Andricdef riscv_ssubsat_vl   : SDNode<"RISCVISD::SSUBSAT_VL", SDT_RISCVIntBinOp_VL>;
133fe6060f1SDimitry Andricdef riscv_usubsat_vl   : SDNode<"RISCVISD::USUBSAT_VL", SDT_RISCVIntBinOp_VL>;
134fe6060f1SDimitry Andric
135*0fca6ea1SDimitry Andricdef riscv_vnclipu_vl : SDNode<"RISCVISD::VNCLIPU_VL", SDT_RISCVVNBinOp_RM_VL>;
136*0fca6ea1SDimitry Andricdef riscv_vnclip_vl : SDNode<"RISCVISD::VNCLIP_VL", SDT_RISCVVNBinOp_RM_VL>;
137*0fca6ea1SDimitry Andric
138fe6060f1SDimitry Andricdef riscv_fadd_vl  : SDNode<"RISCVISD::FADD_VL",  SDT_RISCVFPBinOp_VL, [SDNPCommutative]>;
139fe6060f1SDimitry Andricdef riscv_fsub_vl  : SDNode<"RISCVISD::FSUB_VL",  SDT_RISCVFPBinOp_VL>;
140fe6060f1SDimitry Andricdef riscv_fmul_vl  : SDNode<"RISCVISD::FMUL_VL",  SDT_RISCVFPBinOp_VL, [SDNPCommutative]>;
141fe6060f1SDimitry Andricdef riscv_fdiv_vl  : SDNode<"RISCVISD::FDIV_VL",  SDT_RISCVFPBinOp_VL>;
142fe6060f1SDimitry Andricdef riscv_fneg_vl  : SDNode<"RISCVISD::FNEG_VL",  SDT_RISCVFPUnOp_VL>;
143fe6060f1SDimitry Andricdef riscv_fabs_vl  : SDNode<"RISCVISD::FABS_VL",  SDT_RISCVFPUnOp_VL>;
144fe6060f1SDimitry Andricdef riscv_fsqrt_vl : SDNode<"RISCVISD::FSQRT_VL", SDT_RISCVFPUnOp_VL>;
145bdd1243dSDimitry Andricdef riscv_fcopysign_vl : SDNode<"RISCVISD::FCOPYSIGN_VL", SDT_RISCVCopySign_VL>;
1465f757f3fSDimitry Andricdef riscv_vfmin_vl   : SDNode<"RISCVISD::VFMIN_VL",  SDT_RISCVFPBinOp_VL, [SDNPCommutative]>;
1475f757f3fSDimitry Andricdef riscv_vfmax_vl   : SDNode<"RISCVISD::VFMAX_VL",  SDT_RISCVFPBinOp_VL, [SDNPCommutative]>;
148fe6060f1SDimitry Andric
14906c3fb27SDimitry Andricdef riscv_strict_fadd_vl  : SDNode<"RISCVISD::STRICT_FADD_VL",  SDT_RISCVFPBinOp_VL, [SDNPCommutative, SDNPHasChain]>;
15006c3fb27SDimitry Andricdef riscv_strict_fsub_vl  : SDNode<"RISCVISD::STRICT_FSUB_VL",  SDT_RISCVFPBinOp_VL, [SDNPHasChain]>;
15106c3fb27SDimitry Andricdef riscv_strict_fmul_vl  : SDNode<"RISCVISD::STRICT_FMUL_VL",  SDT_RISCVFPBinOp_VL, [SDNPCommutative, SDNPHasChain]>;
15206c3fb27SDimitry Andricdef riscv_strict_fdiv_vl  : SDNode<"RISCVISD::STRICT_FDIV_VL",  SDT_RISCVFPBinOp_VL, [SDNPHasChain]>;
15306c3fb27SDimitry Andricdef riscv_strict_fsqrt_vl : SDNode<"RISCVISD::STRICT_FSQRT_VL", SDT_RISCVFPUnOp_VL, [SDNPHasChain]>;
15406c3fb27SDimitry Andric
15506c3fb27SDimitry Andricdef any_riscv_fadd_vl : PatFrags<(ops node:$lhs, node:$rhs, node:$merge, node:$mask, node:$vl),
15606c3fb27SDimitry Andric                        [(riscv_fadd_vl node:$lhs, node:$rhs, node:$merge, node:$mask, node:$vl),
15706c3fb27SDimitry Andric                         (riscv_strict_fadd_vl node:$lhs, node:$rhs, node:$merge, node:$mask, node:$vl)]>;
15806c3fb27SDimitry Andricdef any_riscv_fsub_vl : PatFrags<(ops node:$lhs, node:$rhs, node:$merge, node:$mask, node:$vl),
15906c3fb27SDimitry Andric                        [(riscv_fsub_vl node:$lhs, node:$rhs, node:$merge, node:$mask, node:$vl),
16006c3fb27SDimitry Andric                         (riscv_strict_fsub_vl node:$lhs, node:$rhs, node:$merge, node:$mask, node:$vl)]>;
16106c3fb27SDimitry Andricdef any_riscv_fmul_vl : PatFrags<(ops node:$lhs, node:$rhs, node:$merge, node:$mask, node:$vl),
16206c3fb27SDimitry Andric                        [(riscv_fmul_vl node:$lhs, node:$rhs, node:$merge, node:$mask, node:$vl),
16306c3fb27SDimitry Andric                         (riscv_strict_fmul_vl node:$lhs, node:$rhs, node:$merge, node:$mask, node:$vl)]>;
16406c3fb27SDimitry Andricdef any_riscv_fdiv_vl : PatFrags<(ops node:$lhs, node:$rhs, node:$merge, node:$mask, node:$vl),
16506c3fb27SDimitry Andric                        [(riscv_fdiv_vl node:$lhs, node:$rhs, node:$merge, node:$mask, node:$vl),
16606c3fb27SDimitry Andric                         (riscv_strict_fdiv_vl node:$lhs, node:$rhs, node:$merge, node:$mask, node:$vl)]>;
16706c3fb27SDimitry Andricdef any_riscv_fsqrt_vl : PatFrags<(ops node:$src, node:$mask, node:$vl),
16806c3fb27SDimitry Andric                        [(riscv_fsqrt_vl node:$src, node:$mask, node:$vl),
16906c3fb27SDimitry Andric                         (riscv_strict_fsqrt_vl node:$src, node:$mask, node:$vl)]>;
17006c3fb27SDimitry Andric
17106c3fb27SDimitry Andricdef riscv_fclass_vl : SDNode<"RISCVISD::FCLASS_VL",
17206c3fb27SDimitry Andric                             SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisVec<0>,
17306c3fb27SDimitry Andric                                                  SDTCisFP<1>, SDTCisVec<1>,
17406c3fb27SDimitry Andric                                                  SDTCisSameSizeAs<0, 1>,
17506c3fb27SDimitry Andric                                                  SDTCisSameNumEltsAs<0, 1>,
17606c3fb27SDimitry Andric                                                  SDTCVecEltisVT<2, i1>,
17706c3fb27SDimitry Andric                                                  SDTCisSameNumEltsAs<0, 2>,
17806c3fb27SDimitry Andric                                                  SDTCisVT<3, XLenVT>]>>;
17906c3fb27SDimitry Andric
180fe6060f1SDimitry Andricdef SDT_RISCVVecFMA_VL : SDTypeProfile<1, 5, [SDTCisSameAs<0, 1>,
181fe6060f1SDimitry Andric                                              SDTCisSameAs<0, 2>,
182fe6060f1SDimitry Andric                                              SDTCisSameAs<0, 3>,
183fe6060f1SDimitry Andric                                              SDTCisVec<0>, SDTCisFP<0>,
184fe6060f1SDimitry Andric                                              SDTCVecEltisVT<4, i1>,
185fe6060f1SDimitry Andric                                              SDTCisSameNumEltsAs<0, 4>,
186fe6060f1SDimitry Andric                                              SDTCisVT<5, XLenVT>]>;
18781ad6265SDimitry Andricdef riscv_vfmadd_vl  : SDNode<"RISCVISD::VFMADD_VL",  SDT_RISCVVecFMA_VL, [SDNPCommutative]>;
18881ad6265SDimitry Andricdef riscv_vfnmadd_vl : SDNode<"RISCVISD::VFNMADD_VL", SDT_RISCVVecFMA_VL, [SDNPCommutative]>;
18981ad6265SDimitry Andricdef riscv_vfmsub_vl  : SDNode<"RISCVISD::VFMSUB_VL",  SDT_RISCVVecFMA_VL, [SDNPCommutative]>;
19081ad6265SDimitry Andricdef riscv_vfnmsub_vl : SDNode<"RISCVISD::VFNMSUB_VL", SDT_RISCVVecFMA_VL, [SDNPCommutative]>;
191fe6060f1SDimitry Andric
19206c3fb27SDimitry Andricdef SDT_RISCVWVecFMA_VL : SDTypeProfile<1, 5, [SDTCisVec<0>, SDTCisFP<0>,
19306c3fb27SDimitry Andric                                               SDTCisVec<1>, SDTCisFP<1>,
19406c3fb27SDimitry Andric                                               SDTCisOpSmallerThanOp<1, 0>,
19506c3fb27SDimitry Andric                                               SDTCisSameNumEltsAs<0, 1>,
19606c3fb27SDimitry Andric                                               SDTCisSameAs<1, 2>,
19706c3fb27SDimitry Andric                                               SDTCisSameAs<0, 3>,
19806c3fb27SDimitry Andric                                               SDTCVecEltisVT<4, i1>,
19906c3fb27SDimitry Andric                                               SDTCisSameNumEltsAs<0, 4>,
20006c3fb27SDimitry Andric                                               SDTCisVT<5, XLenVT>]>;
20106c3fb27SDimitry Andricdef riscv_vfwmadd_vl  : SDNode<"RISCVISD::VFWMADD_VL",  SDT_RISCVWVecFMA_VL, [SDNPCommutative]>;
20206c3fb27SDimitry Andricdef riscv_vfwnmadd_vl : SDNode<"RISCVISD::VFWNMADD_VL", SDT_RISCVWVecFMA_VL, [SDNPCommutative]>;
20306c3fb27SDimitry Andricdef riscv_vfwmsub_vl  : SDNode<"RISCVISD::VFWMSUB_VL",  SDT_RISCVWVecFMA_VL, [SDNPCommutative]>;
20406c3fb27SDimitry Andricdef riscv_vfwnmsub_vl : SDNode<"RISCVISD::VFWNMSUB_VL", SDT_RISCVWVecFMA_VL, [SDNPCommutative]>;
20506c3fb27SDimitry Andric
20606c3fb27SDimitry Andricdef riscv_strict_vfmadd_vl : SDNode<"RISCVISD::STRICT_VFMADD_VL", SDT_RISCVVecFMA_VL, [SDNPCommutative, SDNPHasChain]>;
20706c3fb27SDimitry Andricdef riscv_strict_vfnmadd_vl : SDNode<"RISCVISD::STRICT_VFNMADD_VL", SDT_RISCVVecFMA_VL, [SDNPCommutative, SDNPHasChain]>;
20806c3fb27SDimitry Andricdef riscv_strict_vfmsub_vl : SDNode<"RISCVISD::STRICT_VFMSUB_VL", SDT_RISCVVecFMA_VL, [SDNPCommutative, SDNPHasChain]>;
20906c3fb27SDimitry Andricdef riscv_strict_vfnmsub_vl : SDNode<"RISCVISD::STRICT_VFNMSUB_VL", SDT_RISCVVecFMA_VL, [SDNPCommutative, SDNPHasChain]>;
21006c3fb27SDimitry Andric
21106c3fb27SDimitry Andricdef any_riscv_vfmadd_vl : PatFrags<(ops node:$rs1, node:$rs2, node:$rs3, node:$mask, node:$vl),
21206c3fb27SDimitry Andric                        [(riscv_vfmadd_vl node:$rs1, node:$rs2, node:$rs3, node:$mask, node:$vl),
21306c3fb27SDimitry Andric                         (riscv_strict_vfmadd_vl node:$rs1, node:$rs2, node:$rs3, node:$mask, node:$vl)]>;
21406c3fb27SDimitry Andricdef any_riscv_vfnmadd_vl : PatFrags<(ops node:$rs1, node:$rs2, node:$rs3, node:$mask, node:$vl),
21506c3fb27SDimitry Andric                        [(riscv_vfnmadd_vl node:$rs1, node:$rs2, node:$rs3, node:$mask, node:$vl),
21606c3fb27SDimitry Andric                         (riscv_strict_vfnmadd_vl node:$rs1, node:$rs2, node:$rs3, node:$mask, node:$vl)]>;
21706c3fb27SDimitry Andricdef any_riscv_vfmsub_vl : PatFrags<(ops node:$rs1, node:$rs2, node:$rs3, node:$mask, node:$vl),
21806c3fb27SDimitry Andric                        [(riscv_vfmsub_vl node:$rs1, node:$rs2, node:$rs3, node:$mask, node:$vl),
21906c3fb27SDimitry Andric                         (riscv_strict_vfmsub_vl node:$rs1, node:$rs2, node:$rs3, node:$mask, node:$vl)]>;
22006c3fb27SDimitry Andricdef any_riscv_vfnmsub_vl : PatFrags<(ops node:$rs1, node:$rs2, node:$rs3, node:$mask, node:$vl),
22106c3fb27SDimitry Andric                        [(riscv_vfnmsub_vl node:$rs1, node:$rs2, node:$rs3, node:$mask, node:$vl),
22206c3fb27SDimitry Andric                         (riscv_strict_vfnmsub_vl node:$rs1, node:$rs2, node:$rs3, node:$mask, node:$vl)]>;
22306c3fb27SDimitry Andric
224fe6060f1SDimitry Andricdef SDT_RISCVFPRoundOp_VL  : SDTypeProfile<1, 3, [
225fe6060f1SDimitry Andric  SDTCisFP<0>, SDTCisFP<1>, SDTCisOpSmallerThanOp<0, 1>, SDTCisSameNumEltsAs<0, 1>,
226fe6060f1SDimitry Andric  SDTCVecEltisVT<2, i1>, SDTCisSameNumEltsAs<1, 2>, SDTCisVT<3, XLenVT>
227fe6060f1SDimitry Andric]>;
228fe6060f1SDimitry Andricdef SDT_RISCVFPExtendOp_VL  : SDTypeProfile<1, 3, [
229fe6060f1SDimitry Andric  SDTCisFP<0>, SDTCisFP<1>, SDTCisOpSmallerThanOp<1, 0>, SDTCisSameNumEltsAs<0, 1>,
230fe6060f1SDimitry Andric  SDTCVecEltisVT<2, i1>, SDTCisSameNumEltsAs<1, 2>, SDTCisVT<3, XLenVT>
231fe6060f1SDimitry Andric]>;
232fe6060f1SDimitry Andric
233fe6060f1SDimitry Andricdef riscv_fpround_vl : SDNode<"RISCVISD::FP_ROUND_VL", SDT_RISCVFPRoundOp_VL>;
23406c3fb27SDimitry Andricdef riscv_strict_fpround_vl : SDNode<"RISCVISD::STRICT_FP_ROUND_VL", SDT_RISCVFPRoundOp_VL, [SDNPHasChain]>;
235fe6060f1SDimitry Andricdef riscv_fpextend_vl : SDNode<"RISCVISD::FP_EXTEND_VL", SDT_RISCVFPExtendOp_VL>;
23606c3fb27SDimitry Andricdef riscv_strict_fpextend_vl : SDNode<"RISCVISD::STRICT_FP_EXTEND_VL", SDT_RISCVFPExtendOp_VL, [SDNPHasChain]>;
237fe6060f1SDimitry Andricdef riscv_fncvt_rod_vl : SDNode<"RISCVISD::VFNCVT_ROD_VL", SDT_RISCVFPRoundOp_VL>;
23806c3fb27SDimitry Andricdef riscv_strict_fncvt_rod_vl : SDNode<"RISCVISD::STRICT_VFNCVT_ROD_VL", SDT_RISCVFPRoundOp_VL, [SDNPHasChain]>;
23906c3fb27SDimitry Andric
24006c3fb27SDimitry Andricdef any_riscv_fpround_vl : PatFrags<(ops node:$src, node:$mask, node:$vl),
24106c3fb27SDimitry Andric                            [(riscv_fpround_vl node:$src, node:$mask, node:$vl),
24206c3fb27SDimitry Andric                             (riscv_strict_fpround_vl node:$src, node:$mask, node:$vl)]>;
24306c3fb27SDimitry Andricdef any_riscv_fpextend_vl : PatFrags<(ops node:$src, node:$mask, node:$vl),
24406c3fb27SDimitry Andric                            [(riscv_fpextend_vl node:$src, node:$mask, node:$vl),
24506c3fb27SDimitry Andric                             (riscv_strict_fpextend_vl node:$src, node:$mask, node:$vl)]>;
24606c3fb27SDimitry Andricdef any_riscv_fncvt_rod_vl : PatFrags<(ops node:$src, node:$mask, node:$vl),
24706c3fb27SDimitry Andric                            [(riscv_fncvt_rod_vl node:$src, node:$mask, node:$vl),
24806c3fb27SDimitry Andric                             (riscv_strict_fncvt_rod_vl node:$src, node:$mask, node:$vl)]>;
249fe6060f1SDimitry Andric
250fe6060f1SDimitry Andricdef SDT_RISCVFP2IOp_VL  : SDTypeProfile<1, 3, [
251fe6060f1SDimitry Andric  SDTCisInt<0>, SDTCisFP<1>, SDTCisSameNumEltsAs<0, 1>,
252fe6060f1SDimitry Andric  SDTCVecEltisVT<2, i1>, SDTCisSameNumEltsAs<1, 2>, SDTCisVT<3, XLenVT>
253fe6060f1SDimitry Andric]>;
254bdd1243dSDimitry Andricdef SDT_RISCVFP2IOp_RM_VL  : SDTypeProfile<1, 4, [
255bdd1243dSDimitry Andric  SDTCisInt<0>, SDTCisFP<1>, SDTCisSameNumEltsAs<0, 1>,
256bdd1243dSDimitry Andric  SDTCVecEltisVT<2, i1>, SDTCisSameNumEltsAs<1, 2>, SDTCisVT<3, XLenVT>,
257bdd1243dSDimitry Andric  SDTCisVT<4, XLenVT> // Rounding mode
258bdd1243dSDimitry Andric]>;
259bdd1243dSDimitry Andric
260fe6060f1SDimitry Andricdef SDT_RISCVI2FPOp_VL  : SDTypeProfile<1, 3, [
261fe6060f1SDimitry Andric  SDTCisFP<0>, SDTCisInt<1>, SDTCisSameNumEltsAs<0, 1>,
262fe6060f1SDimitry Andric  SDTCVecEltisVT<2, i1>, SDTCisSameNumEltsAs<1, 2>, SDTCisVT<3, XLenVT>
263fe6060f1SDimitry Andric]>;
264bdd1243dSDimitry Andricdef SDT_RISCVI2FPOp_RM_VL  : SDTypeProfile<1, 4, [
265bdd1243dSDimitry Andric  SDTCisFP<0>, SDTCisInt<1>, SDTCisSameNumEltsAs<0, 1>,
266bdd1243dSDimitry Andric  SDTCVecEltisVT<2, i1>, SDTCisSameNumEltsAs<1, 2>, SDTCisVT<3, XLenVT>,
267bdd1243dSDimitry Andric  SDTCisVT<4, XLenVT> // Rounding mode
268bdd1243dSDimitry Andric]>;
269fe6060f1SDimitry Andric
27006c3fb27SDimitry Andricdef SDT_RISCVSETCCOP_VL : SDTypeProfile<1, 6, [
27106c3fb27SDimitry Andric  SDTCVecEltisVT<0, i1>, SDTCisVec<1>, SDTCisSameNumEltsAs<0, 1>,
27206c3fb27SDimitry Andric  SDTCisSameAs<1, 2>, SDTCisVT<3, OtherVT>, SDTCisSameAs<0, 4>,
27306c3fb27SDimitry Andric  SDTCisSameAs<0, 5>, SDTCisVT<6, XLenVT>]>;
27406c3fb27SDimitry Andric
275bdd1243dSDimitry Andric// Float -> Int
276bdd1243dSDimitry Andricdef riscv_vfcvt_xu_f_vl : SDNode<"RISCVISD::VFCVT_XU_F_VL", SDT_RISCVFP2IOp_VL>;
277bdd1243dSDimitry Andricdef riscv_vfcvt_x_f_vl : SDNode<"RISCVISD::VFCVT_X_F_VL", SDT_RISCVFP2IOp_VL>;
278bdd1243dSDimitry Andricdef riscv_vfcvt_rm_xu_f_vl : SDNode<"RISCVISD::VFCVT_RM_XU_F_VL", SDT_RISCVFP2IOp_RM_VL>;
279bdd1243dSDimitry Andricdef riscv_vfcvt_rm_x_f_vl : SDNode<"RISCVISD::VFCVT_RM_X_F_VL", SDT_RISCVFP2IOp_RM_VL>;
280bdd1243dSDimitry Andric
281bdd1243dSDimitry Andricdef riscv_vfcvt_rtz_xu_f_vl : SDNode<"RISCVISD::VFCVT_RTZ_XU_F_VL", SDT_RISCVFP2IOp_VL>;
282bdd1243dSDimitry Andricdef riscv_vfcvt_rtz_x_f_vl  : SDNode<"RISCVISD::VFCVT_RTZ_X_F_VL",  SDT_RISCVFP2IOp_VL>;
283bdd1243dSDimitry Andric
28406c3fb27SDimitry Andricdef riscv_strict_vfcvt_rm_x_f_vl : SDNode<"RISCVISD::STRICT_VFCVT_RM_X_F_VL", SDT_RISCVFP2IOp_RM_VL, [SDNPHasChain]>;
28506c3fb27SDimitry Andricdef riscv_strict_vfcvt_rtz_xu_f_vl : SDNode<"RISCVISD::STRICT_VFCVT_RTZ_XU_F_VL", SDT_RISCVFP2IOp_VL, [SDNPHasChain]>;
28606c3fb27SDimitry Andricdef riscv_strict_vfcvt_rtz_x_f_vl  : SDNode<"RISCVISD::STRICT_VFCVT_RTZ_X_F_VL",  SDT_RISCVFP2IOp_VL, [SDNPHasChain]>;
28706c3fb27SDimitry Andric
28806c3fb27SDimitry Andricdef any_riscv_vfcvt_rm_x_f_vl : PatFrags<(ops node:$src, node:$mask, node:$vl, node:$rm),
28906c3fb27SDimitry Andric                            [(riscv_vfcvt_rm_x_f_vl node:$src, node:$mask, node:$vl, node:$rm),
29006c3fb27SDimitry Andric                             (riscv_strict_vfcvt_rm_x_f_vl node:$src, node:$mask, node:$vl, node:$rm)]>;
29106c3fb27SDimitry Andricdef any_riscv_vfcvt_rtz_xu_f_vl : PatFrags<(ops node:$src, node:$mask, node:$vl),
29206c3fb27SDimitry Andric                            [(riscv_vfcvt_rtz_xu_f_vl node:$src, node:$mask, node:$vl),
29306c3fb27SDimitry Andric                             (riscv_strict_vfcvt_rtz_xu_f_vl node:$src, node:$mask, node:$vl)]>;
29406c3fb27SDimitry Andricdef any_riscv_vfcvt_rtz_x_f_vl : PatFrags<(ops node:$src, node:$mask, node:$vl),
29506c3fb27SDimitry Andric                            [(riscv_vfcvt_rtz_x_f_vl node:$src, node:$mask, node:$vl),
29606c3fb27SDimitry Andric                             (riscv_strict_vfcvt_rtz_x_f_vl node:$src, node:$mask, node:$vl)]>;
29706c3fb27SDimitry Andric
298bdd1243dSDimitry Andric// Int -> Float
299fe6060f1SDimitry Andricdef riscv_sint_to_fp_vl : SDNode<"RISCVISD::SINT_TO_FP_VL", SDT_RISCVI2FPOp_VL>;
300fe6060f1SDimitry Andricdef riscv_uint_to_fp_vl : SDNode<"RISCVISD::UINT_TO_FP_VL", SDT_RISCVI2FPOp_VL>;
301bdd1243dSDimitry Andricdef riscv_vfcvt_rm_f_xu_vl : SDNode<"RISCVISD::VFCVT_RM_F_XU_VL", SDT_RISCVI2FPOp_RM_VL>;
302bdd1243dSDimitry Andricdef riscv_vfcvt_rm_f_x_vl : SDNode<"RISCVISD::VFCVT_RM_F_X_VL", SDT_RISCVI2FPOp_RM_VL>;
303bdd1243dSDimitry Andric
30406c3fb27SDimitry Andricdef riscv_strict_sint_to_fp_vl : SDNode<"RISCVISD::STRICT_SINT_TO_FP_VL", SDT_RISCVI2FPOp_VL, [SDNPHasChain]>;
30506c3fb27SDimitry Andricdef riscv_strict_uint_to_fp_vl : SDNode<"RISCVISD::STRICT_UINT_TO_FP_VL", SDT_RISCVI2FPOp_VL, [SDNPHasChain]>;
30606c3fb27SDimitry Andric
30706c3fb27SDimitry Andricdef any_riscv_sint_to_fp_vl : PatFrags<(ops node:$src, node:$mask, node:$vl),
30806c3fb27SDimitry Andric                            [(riscv_sint_to_fp_vl node:$src, node:$mask, node:$vl),
30906c3fb27SDimitry Andric                             (riscv_strict_sint_to_fp_vl node:$src, node:$mask, node:$vl)]>;
31006c3fb27SDimitry Andricdef any_riscv_uint_to_fp_vl : PatFrags<(ops node:$src, node:$mask, node:$vl),
31106c3fb27SDimitry Andric                            [(riscv_uint_to_fp_vl node:$src, node:$mask, node:$vl),
31206c3fb27SDimitry Andric                             (riscv_strict_uint_to_fp_vl node:$src, node:$mask, node:$vl)]>;
313bdd1243dSDimitry Andric
314bdd1243dSDimitry Andricdef riscv_vfround_noexcept_vl: SDNode<"RISCVISD::VFROUND_NOEXCEPT_VL", SDT_RISCVFPUnOp_VL>;
31506c3fb27SDimitry Andricdef riscv_strict_vfround_noexcept_vl: SDNode<"RISCVISD::STRICT_VFROUND_NOEXCEPT_VL", SDT_RISCVFPUnOp_VL, [SDNPHasChain]>;
316fe6060f1SDimitry Andric
31706c3fb27SDimitry Andricdef any_riscv_vfround_noexcept_vl : PatFrags<(ops node:$src, node:$mask, node:$vl),
31806c3fb27SDimitry Andric                        [(riscv_vfround_noexcept_vl node:$src, node:$mask, node:$vl),
31906c3fb27SDimitry Andric                         (riscv_strict_vfround_noexcept_vl node:$src, node:$mask, node:$vl)]>;
32006c3fb27SDimitry Andric
32106c3fb27SDimitry Andricdef riscv_setcc_vl : SDNode<"RISCVISD::SETCC_VL", SDT_RISCVSETCCOP_VL>;
32206c3fb27SDimitry Andricdef riscv_strict_fsetcc_vl : SDNode<"RISCVISD::STRICT_FSETCC_VL", SDT_RISCVSETCCOP_VL, [SDNPHasChain]>;
32306c3fb27SDimitry Andricdef riscv_strict_fsetccs_vl : SDNode<"RISCVISD::STRICT_FSETCCS_VL", SDT_RISCVSETCCOP_VL, [SDNPHasChain]>;
32406c3fb27SDimitry Andricdef any_riscv_fsetcc_vl : PatFrags<(ops node:$lhs, node:$rhs, node:$cc, node:$merge, node:$mask, node:$vl),
32506c3fb27SDimitry Andric                            [(riscv_setcc_vl node:$lhs, node:$rhs, node:$cc, node:$merge, node:$mask, node:$vl),
32606c3fb27SDimitry Andric                             (riscv_strict_fsetcc_vl node:$lhs, node:$rhs, node:$cc, node:$merge, node:$mask, node:$vl)]>;
32706c3fb27SDimitry Andricdef any_riscv_fsetccs_vl : PatFrags<(ops node:$lhs, node:$rhs, node:$cc, node:$merge, node:$mask, node:$vl),
32806c3fb27SDimitry Andric                            [(riscv_setcc_vl node:$lhs, node:$rhs, node:$cc, node:$merge, node:$mask, node:$vl),
32906c3fb27SDimitry Andric                             (riscv_strict_fsetccs_vl node:$lhs, node:$rhs, node:$cc, node:$merge, node:$mask, node:$vl)]>;
330fe6060f1SDimitry Andric
331fe6060f1SDimitry Andricdef riscv_vrgather_vx_vl : SDNode<"RISCVISD::VRGATHER_VX_VL",
33281ad6265SDimitry Andric                                  SDTypeProfile<1, 5, [SDTCisVec<0>,
333fe6060f1SDimitry Andric                                                       SDTCisSameAs<0, 1>,
334fe6060f1SDimitry Andric                                                       SDTCisVT<2, XLenVT>,
335bdd1243dSDimitry Andric                                                       SDTCisSameAs<0, 3>,
336bdd1243dSDimitry Andric                                                       SDTCVecEltisVT<4, i1>,
337bdd1243dSDimitry Andric                                                       SDTCisSameNumEltsAs<0, 4>,
33881ad6265SDimitry Andric                                                       SDTCisVT<5, XLenVT>]>>;
339fe6060f1SDimitry Andricdef riscv_vrgather_vv_vl : SDNode<"RISCVISD::VRGATHER_VV_VL",
34081ad6265SDimitry Andric                                  SDTypeProfile<1, 5, [SDTCisVec<0>,
341fe6060f1SDimitry Andric                                                       SDTCisSameAs<0, 1>,
342fe6060f1SDimitry Andric                                                       SDTCisInt<2>,
343fe6060f1SDimitry Andric                                                       SDTCisSameNumEltsAs<0, 2>,
344fe6060f1SDimitry Andric                                                       SDTCisSameSizeAs<0, 2>,
345bdd1243dSDimitry Andric                                                       SDTCisSameAs<0, 3>,
346bdd1243dSDimitry Andric                                                       SDTCVecEltisVT<4, i1>,
347bdd1243dSDimitry Andric                                                       SDTCisSameNumEltsAs<0, 4>,
34881ad6265SDimitry Andric                                                       SDTCisVT<5, XLenVT>]>>;
349fe6060f1SDimitry Andricdef riscv_vrgatherei16_vv_vl : SDNode<"RISCVISD::VRGATHEREI16_VV_VL",
35081ad6265SDimitry Andric                                      SDTypeProfile<1, 5, [SDTCisVec<0>,
351fe6060f1SDimitry Andric                                                           SDTCisSameAs<0, 1>,
352fe6060f1SDimitry Andric                                                           SDTCisInt<2>,
353fe6060f1SDimitry Andric                                                           SDTCVecEltisVT<2, i16>,
354fe6060f1SDimitry Andric                                                           SDTCisSameNumEltsAs<0, 2>,
355bdd1243dSDimitry Andric                                                           SDTCisSameAs<0, 3>,
356bdd1243dSDimitry Andric                                                           SDTCVecEltisVT<4, i1>,
357bdd1243dSDimitry Andric                                                           SDTCisSameNumEltsAs<0, 4>,
35881ad6265SDimitry Andric                                                           SDTCisVT<5, XLenVT>]>>;
359fe6060f1SDimitry Andric
360cb14a3feSDimitry Andricdef SDT_RISCVVMERGE_VL  : SDTypeProfile<1, 5, [
361cb14a3feSDimitry Andric  SDTCisVec<0>, SDTCisVec<1>, SDTCisSameNumEltsAs<0, 1>, SDTCVecEltisVT<1, i1>,
362cb14a3feSDimitry Andric  SDTCisSameAs<0, 2>, SDTCisSameAs<2, 3>, SDTCisSameAs<0, 4>,
363cb14a3feSDimitry Andric  SDTCisVT<5, XLenVT>
364cb14a3feSDimitry Andric]>;
365cb14a3feSDimitry Andric
366cb14a3feSDimitry Andricdef riscv_vmerge_vl : SDNode<"RISCVISD::VMERGE_VL", SDT_RISCVVMERGE_VL>;
367fe6060f1SDimitry Andric
36881ad6265SDimitry Andricdef SDT_RISCVVMSETCLR_VL : SDTypeProfile<1, 1, [SDTCVecEltisVT<0, i1>,
36981ad6265SDimitry Andric                                                SDTCisVT<1, XLenVT>]>;
37081ad6265SDimitry Andricdef riscv_vmclr_vl : SDNode<"RISCVISD::VMCLR_VL", SDT_RISCVVMSETCLR_VL>;
37181ad6265SDimitry Andricdef riscv_vmset_vl : SDNode<"RISCVISD::VMSET_VL", SDT_RISCVVMSETCLR_VL>;
37281ad6265SDimitry Andric
373fe6060f1SDimitry Andricdef SDT_RISCVMaskBinOp_VL : SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>,
374fe6060f1SDimitry Andric                                                 SDTCisSameAs<0, 2>,
375fe6060f1SDimitry Andric                                                 SDTCVecEltisVT<0, i1>,
376fe6060f1SDimitry Andric                                                 SDTCisVT<3, XLenVT>]>;
377fe6060f1SDimitry Andricdef riscv_vmand_vl : SDNode<"RISCVISD::VMAND_VL", SDT_RISCVMaskBinOp_VL, [SDNPCommutative]>;
378fe6060f1SDimitry Andricdef riscv_vmor_vl  : SDNode<"RISCVISD::VMOR_VL",  SDT_RISCVMaskBinOp_VL, [SDNPCommutative]>;
379fe6060f1SDimitry Andricdef riscv_vmxor_vl : SDNode<"RISCVISD::VMXOR_VL", SDT_RISCVMaskBinOp_VL, [SDNPCommutative]>;
380fe6060f1SDimitry Andric
381fe6060f1SDimitry Andricdef true_mask : PatLeaf<(riscv_vmset_vl (XLenVT srcvalue))>;
382fe6060f1SDimitry Andric
383fe6060f1SDimitry Andricdef riscv_vmnot_vl : PatFrag<(ops node:$rs, node:$vl),
384fe6060f1SDimitry Andric                             (riscv_vmxor_vl node:$rs, true_mask, node:$vl)>;
385fe6060f1SDimitry Andric
386349cc55cSDimitry Andricdef riscv_vcpop_vl : SDNode<"RISCVISD::VCPOP_VL",
387fe6060f1SDimitry Andric                            SDTypeProfile<1, 3, [SDTCisVT<0, XLenVT>,
388fe6060f1SDimitry Andric                                                 SDTCisVec<1>, SDTCisInt<1>,
389fe6060f1SDimitry Andric                                                 SDTCVecEltisVT<2, i1>,
390fe6060f1SDimitry Andric                                                 SDTCisSameNumEltsAs<1, 2>,
391fe6060f1SDimitry Andric                                                 SDTCisVT<3, XLenVT>]>>;
392fe6060f1SDimitry Andric
393bdd1243dSDimitry Andricdef riscv_vfirst_vl : SDNode<"RISCVISD::VFIRST_VL",
394bdd1243dSDimitry Andric                            SDTypeProfile<1, 3, [SDTCisVT<0, XLenVT>,
395bdd1243dSDimitry Andric                                                 SDTCisVec<1>, SDTCisInt<1>,
396bdd1243dSDimitry Andric                                                 SDTCVecEltisVT<2, i1>,
397bdd1243dSDimitry Andric                                                 SDTCisSameNumEltsAs<1, 2>,
398bdd1243dSDimitry Andric                                                 SDTCisVT<3, XLenVT>]>>;
399bdd1243dSDimitry Andric
400fe6060f1SDimitry Andricdef SDT_RISCVVEXTEND_VL : SDTypeProfile<1, 3, [SDTCisVec<0>,
401fe6060f1SDimitry Andric                                               SDTCisSameNumEltsAs<0, 1>,
402fe6060f1SDimitry Andric                                               SDTCisSameNumEltsAs<1, 2>,
403fe6060f1SDimitry Andric                                               SDTCVecEltisVT<2, i1>,
404fe6060f1SDimitry Andric                                               SDTCisVT<3, XLenVT>]>;
405fe6060f1SDimitry Andricdef riscv_sext_vl : SDNode<"RISCVISD::VSEXT_VL", SDT_RISCVVEXTEND_VL>;
406fe6060f1SDimitry Andricdef riscv_zext_vl : SDNode<"RISCVISD::VZEXT_VL", SDT_RISCVVEXTEND_VL>;
407*0fca6ea1SDimitry Andricdef riscv_ext_vl : PatFrags<(ops node:$A, node:$B, node:$C),
408*0fca6ea1SDimitry Andric                            [(riscv_sext_vl node:$A, node:$B, node:$C),
409*0fca6ea1SDimitry Andric                             (riscv_zext_vl node:$A, node:$B, node:$C)]>;
410fe6060f1SDimitry Andric
411fe6060f1SDimitry Andricdef riscv_trunc_vector_vl : SDNode<"RISCVISD::TRUNCATE_VECTOR_VL",
412fe6060f1SDimitry Andric                                   SDTypeProfile<1, 3, [SDTCisVec<0>,
41304eeddc0SDimitry Andric                                                        SDTCisSameNumEltsAs<0, 1>,
414fe6060f1SDimitry Andric                                                        SDTCisSameNumEltsAs<0, 2>,
415fe6060f1SDimitry Andric                                                        SDTCVecEltisVT<2, i1>,
416fe6060f1SDimitry Andric                                                        SDTCisVT<3, XLenVT>]>>;
417fe6060f1SDimitry Andric
41806c3fb27SDimitry Andricdef SDT_RISCVVWIntBinOp_VL : SDTypeProfile<1, 5, [SDTCisVec<0>, SDTCisInt<0>,
41906c3fb27SDimitry Andric                                                  SDTCisInt<1>,
420fe6060f1SDimitry Andric                                                  SDTCisSameNumEltsAs<0, 1>,
42106c3fb27SDimitry Andric                                                  SDTCisOpSmallerThanOp<1, 0>,
422fe6060f1SDimitry Andric                                                  SDTCisSameAs<1, 2>,
423bdd1243dSDimitry Andric                                                  SDTCisSameAs<0, 3>,
424bdd1243dSDimitry Andric                                                  SDTCisSameNumEltsAs<1, 4>,
425bdd1243dSDimitry Andric                                                  SDTCVecEltisVT<4, i1>,
426bdd1243dSDimitry Andric                                                  SDTCisVT<5, XLenVT>]>;
42706c3fb27SDimitry Andricdef riscv_vwmul_vl   : SDNode<"RISCVISD::VWMUL_VL",   SDT_RISCVVWIntBinOp_VL, [SDNPCommutative]>;
42806c3fb27SDimitry Andricdef riscv_vwmulu_vl  : SDNode<"RISCVISD::VWMULU_VL",  SDT_RISCVVWIntBinOp_VL, [SDNPCommutative]>;
42906c3fb27SDimitry Andricdef riscv_vwmulsu_vl : SDNode<"RISCVISD::VWMULSU_VL", SDT_RISCVVWIntBinOp_VL>;
43006c3fb27SDimitry Andricdef riscv_vwadd_vl   : SDNode<"RISCVISD::VWADD_VL",   SDT_RISCVVWIntBinOp_VL, [SDNPCommutative]>;
43106c3fb27SDimitry Andricdef riscv_vwaddu_vl  : SDNode<"RISCVISD::VWADDU_VL",  SDT_RISCVVWIntBinOp_VL, [SDNPCommutative]>;
43206c3fb27SDimitry Andricdef riscv_vwsub_vl   : SDNode<"RISCVISD::VWSUB_VL",   SDT_RISCVVWIntBinOp_VL, []>;
43306c3fb27SDimitry Andricdef riscv_vwsubu_vl  : SDNode<"RISCVISD::VWSUBU_VL",  SDT_RISCVVWIntBinOp_VL, []>;
4345f757f3fSDimitry Andricdef riscv_vwsll_vl   : SDNode<"RISCVISD::VWSLL_VL",   SDT_RISCVVWIntBinOp_VL, []>;
43581ad6265SDimitry Andric
43606c3fb27SDimitry Andricdef SDT_RISCVVWIntTernOp_VL : SDTypeProfile<1, 5, [SDTCisVec<0>, SDTCisInt<0>,
43706c3fb27SDimitry Andric                                                   SDTCisInt<1>,
43806c3fb27SDimitry Andric                                                   SDTCisSameNumEltsAs<0, 1>,
43906c3fb27SDimitry Andric                                                   SDTCisOpSmallerThanOp<1, 0>,
44006c3fb27SDimitry Andric                                                   SDTCisSameAs<1, 2>,
44106c3fb27SDimitry Andric                                                   SDTCisSameAs<0, 3>,
44206c3fb27SDimitry Andric                                                   SDTCisSameNumEltsAs<1, 4>,
44306c3fb27SDimitry Andric                                                   SDTCVecEltisVT<4, i1>,
44406c3fb27SDimitry Andric                                                   SDTCisVT<5, XLenVT>]>;
44506c3fb27SDimitry Andricdef riscv_vwmacc_vl : SDNode<"RISCVISD::VWMACC_VL", SDT_RISCVVWIntTernOp_VL, [SDNPCommutative]>;
44606c3fb27SDimitry Andricdef riscv_vwmaccu_vl : SDNode<"RISCVISD::VWMACCU_VL", SDT_RISCVVWIntTernOp_VL, [SDNPCommutative]>;
44706c3fb27SDimitry Andricdef riscv_vwmaccsu_vl : SDNode<"RISCVISD::VWMACCSU_VL", SDT_RISCVVWIntTernOp_VL, []>;
44806c3fb27SDimitry Andric
44906c3fb27SDimitry Andricdef SDT_RISCVVWFPBinOp_VL : SDTypeProfile<1, 5, [SDTCisVec<0>, SDTCisFP<0>,
45006c3fb27SDimitry Andric                                                 SDTCisFP<1>,
45106c3fb27SDimitry Andric                                                 SDTCisSameNumEltsAs<0, 1>,
45206c3fb27SDimitry Andric                                                 SDTCisOpSmallerThanOp<1, 0>,
45306c3fb27SDimitry Andric                                                 SDTCisSameAs<1, 2>,
45406c3fb27SDimitry Andric                                                 SDTCisSameAs<0, 3>,
45506c3fb27SDimitry Andric                                                 SDTCisSameNumEltsAs<1, 4>,
45606c3fb27SDimitry Andric                                                 SDTCVecEltisVT<4, i1>,
45706c3fb27SDimitry Andric                                                 SDTCisVT<5, XLenVT>]>;
45806c3fb27SDimitry Andricdef riscv_vfwmul_vl : SDNode<"RISCVISD::VFWMUL_VL", SDT_RISCVVWFPBinOp_VL, [SDNPCommutative]>;
45906c3fb27SDimitry Andricdef riscv_vfwadd_vl : SDNode<"RISCVISD::VFWADD_VL", SDT_RISCVVWFPBinOp_VL, [SDNPCommutative]>;
46006c3fb27SDimitry Andricdef riscv_vfwsub_vl : SDNode<"RISCVISD::VFWSUB_VL", SDT_RISCVVWFPBinOp_VL, []>;
46106c3fb27SDimitry Andric
46206c3fb27SDimitry Andricdef SDT_RISCVVNIntBinOp_VL : SDTypeProfile<1, 5, [SDTCisVec<0>, SDTCisInt<0>,
46306c3fb27SDimitry Andric                                                  SDTCisInt<1>,
464bdd1243dSDimitry Andric                                                  SDTCisSameNumEltsAs<0, 1>,
465bdd1243dSDimitry Andric                                                  SDTCisOpSmallerThanOp<0, 1>,
466bdd1243dSDimitry Andric                                                  SDTCisSameAs<0, 2>,
467bdd1243dSDimitry Andric                                                  SDTCisSameAs<0, 3>,
468bdd1243dSDimitry Andric                                                  SDTCisSameNumEltsAs<0, 4>,
469bdd1243dSDimitry Andric                                                  SDTCVecEltisVT<4, i1>,
470bdd1243dSDimitry Andric                                                  SDTCisVT<5, XLenVT>]>;
47106c3fb27SDimitry Andricdef riscv_vnsrl_vl : SDNode<"RISCVISD::VNSRL_VL", SDT_RISCVVNIntBinOp_VL>;
472bdd1243dSDimitry Andric
47306c3fb27SDimitry Andricdef SDT_RISCVVWIntBinOpW_VL : SDTypeProfile<1, 5, [SDTCisVec<0>, SDTCisInt<0>,
47481ad6265SDimitry Andric                                                   SDTCisSameAs<0, 1>,
47506c3fb27SDimitry Andric                                                   SDTCisInt<2>,
47681ad6265SDimitry Andric                                                   SDTCisSameNumEltsAs<1, 2>,
47781ad6265SDimitry Andric                                                   SDTCisOpSmallerThanOp<2, 1>,
478bdd1243dSDimitry Andric                                                   SDTCisSameAs<0, 3>,
479bdd1243dSDimitry Andric                                                   SDTCisSameNumEltsAs<1, 4>,
480bdd1243dSDimitry Andric                                                   SDTCVecEltisVT<4, i1>,
481bdd1243dSDimitry Andric                                                   SDTCisVT<5, XLenVT>]>;
48206c3fb27SDimitry Andricdef riscv_vwadd_w_vl :  SDNode<"RISCVISD::VWADD_W_VL",  SDT_RISCVVWIntBinOpW_VL>;
48306c3fb27SDimitry Andricdef riscv_vwaddu_w_vl : SDNode<"RISCVISD::VWADDU_W_VL", SDT_RISCVVWIntBinOpW_VL>;
48406c3fb27SDimitry Andricdef riscv_vwsub_w_vl :  SDNode<"RISCVISD::VWSUB_W_VL",  SDT_RISCVVWIntBinOpW_VL>;
48506c3fb27SDimitry Andricdef riscv_vwsubu_w_vl : SDNode<"RISCVISD::VWSUBU_W_VL", SDT_RISCVVWIntBinOpW_VL>;
486fe6060f1SDimitry Andric
48706c3fb27SDimitry Andricdef SDT_RISCVVWFPBinOpW_VL : SDTypeProfile<1, 5, [SDTCisVec<0>, SDTCisFP<0>,
48806c3fb27SDimitry Andric                                                  SDTCisSameAs<0, 1>,
48906c3fb27SDimitry Andric                                                  SDTCisFP<2>,
49006c3fb27SDimitry Andric                                                  SDTCisSameNumEltsAs<1, 2>,
49106c3fb27SDimitry Andric                                                  SDTCisOpSmallerThanOp<2, 1>,
49206c3fb27SDimitry Andric                                                  SDTCisSameAs<0, 3>,
49306c3fb27SDimitry Andric                                                  SDTCisSameNumEltsAs<1, 4>,
49406c3fb27SDimitry Andric                                                  SDTCVecEltisVT<4, i1>,
49506c3fb27SDimitry Andric                                                  SDTCisVT<5, XLenVT>]>;
49606c3fb27SDimitry Andric
49706c3fb27SDimitry Andricdef riscv_vfwadd_w_vl :  SDNode<"RISCVISD::VFWADD_W_VL", SDT_RISCVVWFPBinOpW_VL>;
49806c3fb27SDimitry Andricdef riscv_vfwsub_w_vl :  SDNode<"RISCVISD::VFWSUB_W_VL", SDT_RISCVVWFPBinOpW_VL>;
49906c3fb27SDimitry Andric
50006c3fb27SDimitry Andricdef SDTRVVVecReduce : SDTypeProfile<1, 6, [
501349cc55cSDimitry Andric  SDTCisVec<0>, SDTCisVec<1>, SDTCisVec<2>, SDTCisSameAs<0, 3>,
50206c3fb27SDimitry Andric  SDTCVecEltisVT<4, i1>, SDTCisSameNumEltsAs<2, 4>, SDTCisVT<5, XLenVT>,
50306c3fb27SDimitry Andric  SDTCisVT<6, XLenVT>
504fe6060f1SDimitry Andric]>;
505fe6060f1SDimitry Andric
506bdd1243dSDimitry Andricdef riscv_add_vl_oneuse : PatFrag<(ops node:$A, node:$B, node:$C, node:$D,
507bdd1243dSDimitry Andric                                       node:$E),
508bdd1243dSDimitry Andric                                  (riscv_add_vl node:$A, node:$B, node:$C,
509bdd1243dSDimitry Andric                                                node:$D, node:$E), [{
510bdd1243dSDimitry Andric  return N->hasOneUse();
511bdd1243dSDimitry Andric}]>;
512bdd1243dSDimitry Andric
513bdd1243dSDimitry Andricdef riscv_sub_vl_oneuse : PatFrag<(ops node:$A, node:$B, node:$C, node:$D,
514bdd1243dSDimitry Andric                                       node:$E),
515bdd1243dSDimitry Andric                                  (riscv_sub_vl node:$A, node:$B, node:$C,
516bdd1243dSDimitry Andric                                                node:$D, node:$E), [{
517bdd1243dSDimitry Andric  return N->hasOneUse();
518bdd1243dSDimitry Andric}]>;
519bdd1243dSDimitry Andric
520bdd1243dSDimitry Andricdef riscv_mul_vl_oneuse : PatFrag<(ops node:$A, node:$B, node:$C, node:$D,
521bdd1243dSDimitry Andric                                       node:$E),
522fe6060f1SDimitry Andric                                  (riscv_mul_vl node:$A, node:$B, node:$C,
523bdd1243dSDimitry Andric                                                node:$D, node:$E), [{
524fe6060f1SDimitry Andric  return N->hasOneUse();
525fe6060f1SDimitry Andric}]>;
526fe6060f1SDimitry Andric
527bdd1243dSDimitry Andricdef riscv_vwmul_vl_oneuse : PatFrag<(ops node:$A, node:$B, node:$C, node:$D,
528bdd1243dSDimitry Andric                                         node:$E),
529fe6060f1SDimitry Andric                                    (riscv_vwmul_vl node:$A, node:$B, node:$C,
530bdd1243dSDimitry Andric                                                    node:$D, node:$E), [{
531fe6060f1SDimitry Andric  return N->hasOneUse();
532fe6060f1SDimitry Andric}]>;
533fe6060f1SDimitry Andric
534bdd1243dSDimitry Andricdef riscv_vwmulu_vl_oneuse : PatFrag<(ops node:$A, node:$B, node:$C, node:$D,
535bdd1243dSDimitry Andric                                          node:$E),
536fe6060f1SDimitry Andric                                     (riscv_vwmulu_vl node:$A, node:$B, node:$C,
537bdd1243dSDimitry Andric                                                      node:$D, node:$E), [{
538fe6060f1SDimitry Andric  return N->hasOneUse();
539fe6060f1SDimitry Andric}]>;
540fe6060f1SDimitry Andric
541bdd1243dSDimitry Andricdef riscv_vwmulsu_vl_oneuse : PatFrag<(ops node:$A, node:$B, node:$C, node:$D,
542bdd1243dSDimitry Andric                                           node:$E),
54381ad6265SDimitry Andric                                      (riscv_vwmulsu_vl node:$A, node:$B, node:$C,
544bdd1243dSDimitry Andric                                                        node:$D, node:$E), [{
54581ad6265SDimitry Andric  return N->hasOneUse();
54681ad6265SDimitry Andric}]>;
54781ad6265SDimitry Andric
54881ad6265SDimitry Andricdef riscv_sext_vl_oneuse : PatFrag<(ops node:$A, node:$B, node:$C),
54981ad6265SDimitry Andric                           (riscv_sext_vl node:$A, node:$B, node:$C), [{
55081ad6265SDimitry Andric  return N->hasOneUse();
55181ad6265SDimitry Andric}]>;
55281ad6265SDimitry Andric
55381ad6265SDimitry Andricdef riscv_zext_vl_oneuse : PatFrag<(ops node:$A, node:$B, node:$C),
55481ad6265SDimitry Andric                           (riscv_zext_vl node:$A, node:$B, node:$C), [{
55581ad6265SDimitry Andric  return N->hasOneUse();
55681ad6265SDimitry Andric}]>;
55781ad6265SDimitry Andric
558*0fca6ea1SDimitry Andricdef riscv_ext_vl_oneuse : PatFrag<(ops node:$A, node:$B, node:$C),
559*0fca6ea1SDimitry Andric                          (riscv_ext_vl node:$A, node:$B, node:$C), [{
560*0fca6ea1SDimitry Andric  return N->hasOneUse();
561*0fca6ea1SDimitry Andric}]>;
562*0fca6ea1SDimitry Andric
56381ad6265SDimitry Andricdef riscv_fpextend_vl_oneuse : PatFrag<(ops node:$A, node:$B, node:$C),
56481ad6265SDimitry Andric                           (riscv_fpextend_vl node:$A, node:$B, node:$C), [{
56581ad6265SDimitry Andric  return N->hasOneUse();
56681ad6265SDimitry Andric}]>;
56781ad6265SDimitry Andric
568bdd1243dSDimitry Andricdef riscv_vfmadd_vl_oneuse : PatFrag<(ops node:$A, node:$B, node:$C, node:$D,
569bdd1243dSDimitry Andric                                          node:$E),
570bdd1243dSDimitry Andric                                     (riscv_vfmadd_vl node:$A, node:$B,
571bdd1243dSDimitry Andric                                          node:$C, node:$D, node:$E), [{
572bdd1243dSDimitry Andric  return N->hasOneUse();
573bdd1243dSDimitry Andric}]>;
574bdd1243dSDimitry Andric
575bdd1243dSDimitry Andricdef riscv_vfnmadd_vl_oneuse : PatFrag<(ops node:$A, node:$B, node:$C, node:$D,
576bdd1243dSDimitry Andric                                           node:$E),
577bdd1243dSDimitry Andric                                      (riscv_vfnmadd_vl node:$A, node:$B,
578bdd1243dSDimitry Andric                                           node:$C, node:$D, node:$E), [{
579bdd1243dSDimitry Andric  return N->hasOneUse();
580bdd1243dSDimitry Andric}]>;
581bdd1243dSDimitry Andric
582bdd1243dSDimitry Andricdef riscv_vfmsub_vl_oneuse : PatFrag<(ops node:$A, node:$B, node:$C, node:$D,
583bdd1243dSDimitry Andric                                          node:$E),
584bdd1243dSDimitry Andric                                     (riscv_vfmsub_vl node:$A, node:$B,
585bdd1243dSDimitry Andric                                          node:$C, node:$D, node:$E), [{
586bdd1243dSDimitry Andric  return N->hasOneUse();
587bdd1243dSDimitry Andric}]>;
588bdd1243dSDimitry Andric
589bdd1243dSDimitry Andricdef riscv_vfnmsub_vl_oneuse : PatFrag<(ops node:$A, node:$B, node:$C, node:$D,
590bdd1243dSDimitry Andric                                           node:$E),
591bdd1243dSDimitry Andric                                      (riscv_vfnmsub_vl node:$A, node:$B,
592bdd1243dSDimitry Andric                                           node:$C, node:$D, node:$E), [{
593bdd1243dSDimitry Andric  return N->hasOneUse();
594bdd1243dSDimitry Andric}]>;
595bdd1243dSDimitry Andric
596fe6060f1SDimitry Andricforeach kind = ["ADD", "UMAX", "SMAX", "UMIN", "SMIN", "AND", "OR", "XOR",
597fe6060f1SDimitry Andric                "FADD", "SEQ_FADD", "FMIN", "FMAX"] in
598fe6060f1SDimitry Andric  def rvv_vecreduce_#kind#_vl : SDNode<"RISCVISD::VECREDUCE_"#kind#"_VL", SDTRVVVecReduce>;
599fe6060f1SDimitry Andric
60081ad6265SDimitry Andric// Give explicit Complexity to prefer simm5/uimm5.
60181ad6265SDimitry Andricdef SplatPat       : ComplexPattern<vAny, 1, "selectVSplat",      [], [], 1>;
60206c3fb27SDimitry Andricdef SplatPat_simm5 : ComplexPattern<vAny, 1, "selectVSplatSimm5", [], [], 3>;
60306c3fb27SDimitry Andricdef SplatPat_uimm5 : ComplexPattern<vAny, 1, "selectVSplatUimmBits<5>", [], [], 3>;
60406c3fb27SDimitry Andricdef SplatPat_uimm6 : ComplexPattern<vAny, 1, "selectVSplatUimmBits<6>", [], [], 3>;
60581ad6265SDimitry Andricdef SplatPat_simm5_plus1
60606c3fb27SDimitry Andric    : ComplexPattern<vAny, 1, "selectVSplatSimm5Plus1", [], [], 3>;
60781ad6265SDimitry Andricdef SplatPat_simm5_plus1_nonzero
60806c3fb27SDimitry Andric    : ComplexPattern<vAny, 1, "selectVSplatSimm5Plus1NonZero", [], [], 3>;
60906c3fb27SDimitry Andric
6105f757f3fSDimitry Andric// Selects extends or truncates of splats where we only care about the lowest 8
6115f757f3fSDimitry Andric// bits of each element.
6125f757f3fSDimitry Andricdef Low8BitsSplatPat
6135f757f3fSDimitry Andric    : ComplexPattern<vAny, 1, "selectLow8BitsVSplat", [], [], 2>;
61406c3fb27SDimitry Andric
6155f757f3fSDimitry Andric// Ignore the vl operand on vmv_v_f, and vmv_s_f.
6165f757f3fSDimitry Andricdef SplatFPOp : PatFrags<(ops node:$op),
6175f757f3fSDimitry Andric                         [(riscv_vfmv_v_f_vl undef, node:$op, srcvalue),
6185f757f3fSDimitry Andric                          (riscv_vfmv_s_f_vl undef, node:$op, srcvalue)]>;
619fe6060f1SDimitry Andric
620fe6060f1SDimitry Andricdef sew8simm5  : ComplexPattern<XLenVT, 1, "selectRVVSimm5<8>",  []>;
621fe6060f1SDimitry Andricdef sew16simm5 : ComplexPattern<XLenVT, 1, "selectRVVSimm5<16>", []>;
622fe6060f1SDimitry Andricdef sew32simm5 : ComplexPattern<XLenVT, 1, "selectRVVSimm5<32>", []>;
623fe6060f1SDimitry Andricdef sew64simm5 : ComplexPattern<XLenVT, 1, "selectRVVSimm5<64>", []>;
624fe6060f1SDimitry Andric
62506c3fb27SDimitry Andricclass VPatBinaryVL_V<SDPatternOperator vop,
626fe6060f1SDimitry Andric                     string instruction_name,
62781ad6265SDimitry Andric                     string suffix,
628fe6060f1SDimitry Andric                     ValueType result_type,
62981ad6265SDimitry Andric                     ValueType op1_type,
63081ad6265SDimitry Andric                     ValueType op2_type,
631fe6060f1SDimitry Andric                     ValueType mask_type,
63206c3fb27SDimitry Andric                     int log2sew,
633fe6060f1SDimitry Andric                     LMULInfo vlmul,
634bdd1243dSDimitry Andric                     VReg result_reg_class,
63581ad6265SDimitry Andric                     VReg op1_reg_class,
63606c3fb27SDimitry Andric                     VReg op2_reg_class,
63706c3fb27SDimitry Andric                     bit isSEWAware = 0>
63806c3fb27SDimitry Andric    : Pat<(result_type (vop
63981ad6265SDimitry Andric                       (op1_type op1_reg_class:$rs1),
64081ad6265SDimitry Andric                       (op2_type op2_reg_class:$rs2),
641bdd1243dSDimitry Andric                       (result_type result_reg_class:$merge),
642349cc55cSDimitry Andric                       (mask_type V0),
643fe6060f1SDimitry Andric                       VLOpFrag)),
64406c3fb27SDimitry Andric      (!cast<Instruction>(
64506c3fb27SDimitry Andric                   !if(isSEWAware,
64606c3fb27SDimitry Andric                       instruction_name#"_"#suffix#"_"#vlmul.MX#"_E"#!shl(1, log2sew)#"_MASK",
64706c3fb27SDimitry Andric                       instruction_name#"_"#suffix#"_"#vlmul.MX#"_MASK"))
648bdd1243dSDimitry Andric                   result_reg_class:$merge,
64981ad6265SDimitry Andric                   op1_reg_class:$rs1,
65081ad6265SDimitry Andric                   op2_reg_class:$rs2,
65106c3fb27SDimitry Andric                   (mask_type V0), GPR:$vl, log2sew, TAIL_AGNOSTIC)>;
65206c3fb27SDimitry Andric
653*0fca6ea1SDimitry Andricmulticlass VPatBinaryRM_VL_V<SDNode vop,
654*0fca6ea1SDimitry Andric                             string instruction_name,
655*0fca6ea1SDimitry Andric                             string suffix,
656*0fca6ea1SDimitry Andric                             ValueType result_type,
657*0fca6ea1SDimitry Andric                             ValueType op1_type,
658*0fca6ea1SDimitry Andric                             ValueType op2_type,
659*0fca6ea1SDimitry Andric                             ValueType mask_type,
660*0fca6ea1SDimitry Andric                             int sew,
661*0fca6ea1SDimitry Andric                             LMULInfo vlmul,
662*0fca6ea1SDimitry Andric                             VReg result_reg_class,
663*0fca6ea1SDimitry Andric                             VReg op1_reg_class,
664*0fca6ea1SDimitry Andric                             VReg op2_reg_class> {
665*0fca6ea1SDimitry Andric  def : Pat<(result_type (vop
666*0fca6ea1SDimitry Andric                         (op1_type op1_reg_class:$rs1),
667*0fca6ea1SDimitry Andric                         (op2_type op2_reg_class:$rs2),
668*0fca6ea1SDimitry Andric                         (result_type result_reg_class:$merge),
669*0fca6ea1SDimitry Andric                         (mask_type V0),
670*0fca6ea1SDimitry Andric                         (XLenVT timm:$roundmode),
671*0fca6ea1SDimitry Andric                         VLOpFrag)),
672*0fca6ea1SDimitry Andric        (!cast<Instruction>(instruction_name#"_"#suffix#"_"# vlmul.MX#"_MASK")
673*0fca6ea1SDimitry Andric                     result_reg_class:$merge,
674*0fca6ea1SDimitry Andric                     op1_reg_class:$rs1,
675*0fca6ea1SDimitry Andric                     op2_reg_class:$rs2,
676*0fca6ea1SDimitry Andric                     (mask_type V0),
677*0fca6ea1SDimitry Andric                     (XLenVT timm:$roundmode),
678*0fca6ea1SDimitry Andric                     GPR:$vl, sew, TAIL_AGNOSTIC)>;
679*0fca6ea1SDimitry Andric}
680*0fca6ea1SDimitry Andric
68106c3fb27SDimitry Andricclass VPatBinaryVL_V_RM<SDPatternOperator vop,
68206c3fb27SDimitry Andric                        string instruction_name,
68306c3fb27SDimitry Andric                        string suffix,
68406c3fb27SDimitry Andric                        ValueType result_type,
68506c3fb27SDimitry Andric                        ValueType op1_type,
68606c3fb27SDimitry Andric                        ValueType op2_type,
68706c3fb27SDimitry Andric                        ValueType mask_type,
68806c3fb27SDimitry Andric                        int log2sew,
68906c3fb27SDimitry Andric                        LMULInfo vlmul,
69006c3fb27SDimitry Andric                        VReg result_reg_class,
69106c3fb27SDimitry Andric                        VReg op1_reg_class,
69206c3fb27SDimitry Andric                        VReg op2_reg_class,
69306c3fb27SDimitry Andric                        bit isSEWAware = 0>
69406c3fb27SDimitry Andric    : Pat<(result_type (vop
69506c3fb27SDimitry Andric                       (op1_type op1_reg_class:$rs1),
69606c3fb27SDimitry Andric                       (op2_type op2_reg_class:$rs2),
69706c3fb27SDimitry Andric                       (result_type result_reg_class:$merge),
69806c3fb27SDimitry Andric                       (mask_type V0),
69906c3fb27SDimitry Andric                       VLOpFrag)),
70006c3fb27SDimitry Andric      (!cast<Instruction>(
70106c3fb27SDimitry Andric                   !if(isSEWAware,
70206c3fb27SDimitry Andric                       instruction_name#"_"#suffix#"_"#vlmul.MX#"_E"#!shl(1, log2sew)#"_MASK",
70306c3fb27SDimitry Andric                       instruction_name#"_"#suffix#"_"#vlmul.MX#"_MASK"))
70406c3fb27SDimitry Andric                   result_reg_class:$merge,
70506c3fb27SDimitry Andric                   op1_reg_class:$rs1,
70606c3fb27SDimitry Andric                   op2_reg_class:$rs2,
70706c3fb27SDimitry Andric                   (mask_type V0),
70806c3fb27SDimitry Andric                   // Value to indicate no rounding mode change in
70906c3fb27SDimitry Andric                   // RISCVInsertReadWriteCSR
71006c3fb27SDimitry Andric                   FRM_DYN,
71106c3fb27SDimitry Andric                   GPR:$vl, log2sew, TAIL_AGNOSTIC)>;
712fe6060f1SDimitry Andric
713bdd1243dSDimitry Andricmulticlass VPatTiedBinaryNoMaskVL_V<SDNode vop,
714bdd1243dSDimitry Andric                                    string instruction_name,
715bdd1243dSDimitry Andric                                    string suffix,
716bdd1243dSDimitry Andric                                    ValueType result_type,
717bdd1243dSDimitry Andric                                    ValueType op2_type,
718bdd1243dSDimitry Andric                                    int sew,
719bdd1243dSDimitry Andric                                    LMULInfo vlmul,
720bdd1243dSDimitry Andric                                    VReg result_reg_class,
721bdd1243dSDimitry Andric                                    VReg op2_reg_class> {
722bdd1243dSDimitry Andric  def : Pat<(result_type (vop
723bdd1243dSDimitry Andric                         (result_type result_reg_class:$rs1),
724bdd1243dSDimitry Andric                         (op2_type op2_reg_class:$rs2),
725bdd1243dSDimitry Andric                         srcvalue,
726bdd1243dSDimitry Andric                         true_mask,
727bdd1243dSDimitry Andric                         VLOpFrag)),
728bdd1243dSDimitry Andric        (!cast<Instruction>(instruction_name#"_"#suffix#"_"# vlmul.MX#"_TIED")
729bdd1243dSDimitry Andric                     result_reg_class:$rs1,
730bdd1243dSDimitry Andric                     op2_reg_class:$rs2,
731bdd1243dSDimitry Andric                     GPR:$vl, sew, TAIL_AGNOSTIC)>;
732bdd1243dSDimitry Andric  // Tail undisturbed
733cb14a3feSDimitry Andric  def : Pat<(riscv_vmerge_vl true_mask,
734bdd1243dSDimitry Andric             (result_type (vop
735bdd1243dSDimitry Andric                           result_reg_class:$rs1,
736bdd1243dSDimitry Andric                           (op2_type op2_reg_class:$rs2),
737bdd1243dSDimitry Andric                           srcvalue,
738bdd1243dSDimitry Andric                           true_mask,
739bdd1243dSDimitry Andric                           VLOpFrag)),
740cb14a3feSDimitry Andric             result_reg_class:$rs1, result_reg_class:$rs1, VLOpFrag),
741bdd1243dSDimitry Andric            (!cast<Instruction>(instruction_name#"_"#suffix#"_"# vlmul.MX#"_TIED")
742bdd1243dSDimitry Andric                     result_reg_class:$rs1,
743bdd1243dSDimitry Andric                     op2_reg_class:$rs2,
74406c3fb27SDimitry Andric                     GPR:$vl, sew, TU_MU)>;
745bdd1243dSDimitry Andric}
746bdd1243dSDimitry Andric
747*0fca6ea1SDimitry Andricclass VPatTiedBinaryMaskVL_V<SDNode vop,
748*0fca6ea1SDimitry Andric                             string instruction_name,
749*0fca6ea1SDimitry Andric                             string suffix,
750*0fca6ea1SDimitry Andric                             ValueType result_type,
751*0fca6ea1SDimitry Andric                             ValueType op2_type,
752*0fca6ea1SDimitry Andric                             ValueType mask_type,
753*0fca6ea1SDimitry Andric                             int sew,
754*0fca6ea1SDimitry Andric                             LMULInfo vlmul,
755*0fca6ea1SDimitry Andric                             VReg result_reg_class,
756*0fca6ea1SDimitry Andric                             VReg op2_reg_class> :
757*0fca6ea1SDimitry Andric  Pat<(result_type (vop
758*0fca6ea1SDimitry Andric                   (result_type result_reg_class:$rs1),
759*0fca6ea1SDimitry Andric                   (op2_type op2_reg_class:$rs2),
760*0fca6ea1SDimitry Andric                   (result_type result_reg_class:$rs1),
761*0fca6ea1SDimitry Andric                   (mask_type V0),
762*0fca6ea1SDimitry Andric                   VLOpFrag)),
763*0fca6ea1SDimitry Andric      (!cast<Instruction>(instruction_name#"_"#suffix#"_"# vlmul.MX#"_MASK_TIED")
764*0fca6ea1SDimitry Andric                   result_reg_class:$rs1,
765*0fca6ea1SDimitry Andric                   op2_reg_class:$rs2,
766*0fca6ea1SDimitry Andric                   (mask_type V0), GPR:$vl, sew, TU_MU)>;
767*0fca6ea1SDimitry Andric
76806c3fb27SDimitry Andricmulticlass VPatTiedBinaryNoMaskVL_V_RM<SDNode vop,
76906c3fb27SDimitry Andric                                       string instruction_name,
77006c3fb27SDimitry Andric                                       string suffix,
77106c3fb27SDimitry Andric                                       ValueType result_type,
77206c3fb27SDimitry Andric                                       ValueType op2_type,
773*0fca6ea1SDimitry Andric                                       int log2sew,
77406c3fb27SDimitry Andric                                       LMULInfo vlmul,
77506c3fb27SDimitry Andric                                       VReg result_reg_class,
776*0fca6ea1SDimitry Andric                                       VReg op2_reg_class,
777*0fca6ea1SDimitry Andric                                       bit isSEWAware = 0> {
778*0fca6ea1SDimitry Andric  defvar name = !if(isSEWAware,
779*0fca6ea1SDimitry Andric                    instruction_name#"_"#suffix#"_"#vlmul.MX#"_E"#!shl(1, log2sew)#"_TIED",
780*0fca6ea1SDimitry Andric                    instruction_name#"_"#suffix#"_"#vlmul.MX#"_TIED");
78106c3fb27SDimitry Andric  def : Pat<(result_type (vop
78206c3fb27SDimitry Andric                         (result_type result_reg_class:$rs1),
78306c3fb27SDimitry Andric                         (op2_type op2_reg_class:$rs2),
78406c3fb27SDimitry Andric                         srcvalue,
78506c3fb27SDimitry Andric                         true_mask,
78606c3fb27SDimitry Andric                         VLOpFrag)),
787*0fca6ea1SDimitry Andric        (!cast<Instruction>(name)
78806c3fb27SDimitry Andric                     result_reg_class:$rs1,
78906c3fb27SDimitry Andric                     op2_reg_class:$rs2,
79006c3fb27SDimitry Andric                     // Value to indicate no rounding mode change in
79106c3fb27SDimitry Andric                     // RISCVInsertReadWriteCSR
79206c3fb27SDimitry Andric                     FRM_DYN,
793*0fca6ea1SDimitry Andric                     GPR:$vl, log2sew, TAIL_AGNOSTIC)>;
79406c3fb27SDimitry Andric  // Tail undisturbed
795cb14a3feSDimitry Andric  def : Pat<(riscv_vmerge_vl true_mask,
79606c3fb27SDimitry Andric             (result_type (vop
79706c3fb27SDimitry Andric                           result_reg_class:$rs1,
79806c3fb27SDimitry Andric                           (op2_type op2_reg_class:$rs2),
79906c3fb27SDimitry Andric                           srcvalue,
80006c3fb27SDimitry Andric                           true_mask,
80106c3fb27SDimitry Andric                           VLOpFrag)),
802cb14a3feSDimitry Andric             result_reg_class:$rs1, result_reg_class:$rs1, VLOpFrag),
803*0fca6ea1SDimitry Andric            (!cast<Instruction>(name)
80406c3fb27SDimitry Andric                     result_reg_class:$rs1,
80506c3fb27SDimitry Andric                     op2_reg_class:$rs2,
80606c3fb27SDimitry Andric                     // Value to indicate no rounding mode change in
80706c3fb27SDimitry Andric                     // RISCVInsertReadWriteCSR
80806c3fb27SDimitry Andric                     FRM_DYN,
809*0fca6ea1SDimitry Andric                     GPR:$vl, log2sew, TU_MU)>;
81006c3fb27SDimitry Andric}
81106c3fb27SDimitry Andric
81206c3fb27SDimitry Andricclass VPatBinaryVL_XI<SDPatternOperator vop,
813fe6060f1SDimitry Andric                      string instruction_name,
814fe6060f1SDimitry Andric                      string suffix,
815fe6060f1SDimitry Andric                      ValueType result_type,
81681ad6265SDimitry Andric                      ValueType vop1_type,
81781ad6265SDimitry Andric                      ValueType vop2_type,
818fe6060f1SDimitry Andric                      ValueType mask_type,
81906c3fb27SDimitry Andric                      int log2sew,
820fe6060f1SDimitry Andric                      LMULInfo vlmul,
821bdd1243dSDimitry Andric                      VReg result_reg_class,
822fe6060f1SDimitry Andric                      VReg vop_reg_class,
823fe6060f1SDimitry Andric                      ComplexPattern SplatPatKind,
82406c3fb27SDimitry Andric                      DAGOperand xop_kind,
82506c3fb27SDimitry Andric                      bit isSEWAware = 0>
82606c3fb27SDimitry Andric    : Pat<(result_type (vop
82781ad6265SDimitry Andric                   (vop1_type vop_reg_class:$rs1),
82881ad6265SDimitry Andric                   (vop2_type (SplatPatKind (XLenVT xop_kind:$rs2))),
829bdd1243dSDimitry Andric                   (result_type result_reg_class:$merge),
830349cc55cSDimitry Andric                   (mask_type V0),
831fe6060f1SDimitry Andric                   VLOpFrag)),
83206c3fb27SDimitry Andric      (!cast<Instruction>(
83306c3fb27SDimitry Andric                   !if(isSEWAware,
83406c3fb27SDimitry Andric                       instruction_name#_#suffix#_#vlmul.MX#"_E"#!shl(1, log2sew)#"_MASK",
83506c3fb27SDimitry Andric                       instruction_name#_#suffix#_#vlmul.MX#"_MASK"))
836bdd1243dSDimitry Andric                   result_reg_class:$merge,
837fe6060f1SDimitry Andric                   vop_reg_class:$rs1,
838fe6060f1SDimitry Andric                   xop_kind:$rs2,
83906c3fb27SDimitry Andric                   (mask_type V0), GPR:$vl, log2sew, TAIL_AGNOSTIC)>;
840fe6060f1SDimitry Andric
841*0fca6ea1SDimitry Andricmulticlass VPatBinaryRM_VL_XI<SDNode vop,
842*0fca6ea1SDimitry Andric                              string instruction_name,
843*0fca6ea1SDimitry Andric                              string suffix,
844*0fca6ea1SDimitry Andric                              ValueType result_type,
845*0fca6ea1SDimitry Andric                              ValueType vop1_type,
846*0fca6ea1SDimitry Andric                              ValueType vop2_type,
847*0fca6ea1SDimitry Andric                              ValueType mask_type,
848*0fca6ea1SDimitry Andric                              int sew,
849*0fca6ea1SDimitry Andric                              LMULInfo vlmul,
850*0fca6ea1SDimitry Andric                              VReg result_reg_class,
851*0fca6ea1SDimitry Andric                              VReg vop_reg_class,
852*0fca6ea1SDimitry Andric                              ComplexPattern SplatPatKind,
853*0fca6ea1SDimitry Andric                              DAGOperand xop_kind> {
854*0fca6ea1SDimitry Andric  def : Pat<(result_type (vop
855*0fca6ea1SDimitry Andric                     (vop1_type vop_reg_class:$rs1),
856*0fca6ea1SDimitry Andric                     (vop2_type (SplatPatKind (XLenVT xop_kind:$rs2))),
857*0fca6ea1SDimitry Andric                     (result_type result_reg_class:$merge),
858*0fca6ea1SDimitry Andric                     (mask_type V0),
859*0fca6ea1SDimitry Andric                     (XLenVT timm:$roundmode),
860*0fca6ea1SDimitry Andric                     VLOpFrag)),
861*0fca6ea1SDimitry Andric        (!cast<Instruction>(instruction_name#_#suffix#_# vlmul.MX#"_MASK")
862*0fca6ea1SDimitry Andric                     result_reg_class:$merge,
863*0fca6ea1SDimitry Andric                     vop_reg_class:$rs1,
864*0fca6ea1SDimitry Andric                     xop_kind:$rs2,
865*0fca6ea1SDimitry Andric                     (mask_type V0),
866*0fca6ea1SDimitry Andric                     (XLenVT timm:$roundmode),
867*0fca6ea1SDimitry Andric                     GPR:$vl, sew, TAIL_AGNOSTIC)>;
868*0fca6ea1SDimitry Andric}
869*0fca6ea1SDimitry Andric
87006c3fb27SDimitry Andricmulticlass VPatBinaryVL_VV_VX<SDPatternOperator vop, string instruction_name,
87106c3fb27SDimitry Andric                              list<VTypeInfo> vtilist = AllIntegerVectors,
87206c3fb27SDimitry Andric                              bit isSEWAware = 0> {
87306c3fb27SDimitry Andric  foreach vti = vtilist in {
87406c3fb27SDimitry Andric    let Predicates = GetVTypePredicates<vti>.Predicates in {
87506c3fb27SDimitry Andric      def : VPatBinaryVL_V<vop, instruction_name, "VV",
87681ad6265SDimitry Andric                           vti.Vector, vti.Vector, vti.Vector, vti.Mask,
877bdd1243dSDimitry Andric                           vti.Log2SEW, vti.LMul, vti.RegClass, vti.RegClass,
87806c3fb27SDimitry Andric                           vti.RegClass, isSEWAware>;
87906c3fb27SDimitry Andric      def : VPatBinaryVL_XI<vop, instruction_name, "VX",
88081ad6265SDimitry Andric                            vti.Vector, vti.Vector, vti.Vector, vti.Mask,
881bdd1243dSDimitry Andric                            vti.Log2SEW, vti.LMul, vti.RegClass, vti.RegClass,
88206c3fb27SDimitry Andric                            SplatPat, GPR, isSEWAware>;
88306c3fb27SDimitry Andric    }
884fe6060f1SDimitry Andric  }
885fe6060f1SDimitry Andric}
886fe6060f1SDimitry Andric
88706c3fb27SDimitry Andricmulticlass VPatBinaryVL_VV_VX_VI<SDPatternOperator vop, string instruction_name,
888fe6060f1SDimitry Andric                                 Operand ImmType = simm5>
889fe6060f1SDimitry Andric    : VPatBinaryVL_VV_VX<vop, instruction_name> {
890fe6060f1SDimitry Andric  foreach vti = AllIntegerVectors in {
89106c3fb27SDimitry Andric    let Predicates = GetVTypePredicates<vti>.Predicates in
89206c3fb27SDimitry Andric    def : VPatBinaryVL_XI<vop, instruction_name, "VI",
89381ad6265SDimitry Andric                          vti.Vector, vti.Vector, vti.Vector, vti.Mask,
894bdd1243dSDimitry Andric                          vti.Log2SEW, vti.LMul, vti.RegClass, vti.RegClass,
895fe6060f1SDimitry Andric                          !cast<ComplexPattern>(SplatPat#_#ImmType),
896fe6060f1SDimitry Andric                          ImmType>;
897fe6060f1SDimitry Andric  }
898fe6060f1SDimitry Andric}
899fe6060f1SDimitry Andric
90006c3fb27SDimitry Andricmulticlass VPatBinaryWVL_VV_VX<SDPatternOperator vop, string instruction_name> {
901fe6060f1SDimitry Andric  foreach VtiToWti = AllWidenableIntVectors in {
902fe6060f1SDimitry Andric    defvar vti = VtiToWti.Vti;
903fe6060f1SDimitry Andric    defvar wti = VtiToWti.Wti;
90406c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
90506c3fb27SDimitry Andric                                 GetVTypePredicates<wti>.Predicates) in {
90606c3fb27SDimitry Andric      def : VPatBinaryVL_V<vop, instruction_name, "VV",
90781ad6265SDimitry Andric                           wti.Vector, vti.Vector, vti.Vector, vti.Mask,
908bdd1243dSDimitry Andric                           vti.Log2SEW, vti.LMul, wti.RegClass, vti.RegClass,
909bdd1243dSDimitry Andric                           vti.RegClass>;
91006c3fb27SDimitry Andric      def : VPatBinaryVL_XI<vop, instruction_name, "VX",
91181ad6265SDimitry Andric                            wti.Vector, vti.Vector, vti.Vector, vti.Mask,
912bdd1243dSDimitry Andric                            vti.Log2SEW, vti.LMul, wti.RegClass, vti.RegClass,
913bdd1243dSDimitry Andric                            SplatPat, GPR>;
91481ad6265SDimitry Andric    }
91581ad6265SDimitry Andric  }
91606c3fb27SDimitry Andric}
91706c3fb27SDimitry Andric
91806c3fb27SDimitry Andricmulticlass VPatBinaryWVL_VV_VX_WV_WX<SDPatternOperator vop, SDNode vop_w,
91981ad6265SDimitry Andric                                     string instruction_name>
92081ad6265SDimitry Andric    : VPatBinaryWVL_VV_VX<vop, instruction_name> {
92181ad6265SDimitry Andric  foreach VtiToWti = AllWidenableIntVectors in {
92281ad6265SDimitry Andric    defvar vti = VtiToWti.Vti;
92381ad6265SDimitry Andric    defvar wti = VtiToWti.Wti;
92406c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
92506c3fb27SDimitry Andric                                 GetVTypePredicates<wti>.Predicates) in {
926bdd1243dSDimitry Andric      defm : VPatTiedBinaryNoMaskVL_V<vop_w, instruction_name, "WV",
927bdd1243dSDimitry Andric                                      wti.Vector, vti.Vector, vti.Log2SEW,
928bdd1243dSDimitry Andric                                      vti.LMul, wti.RegClass, vti.RegClass>;
929*0fca6ea1SDimitry Andric      def : VPatTiedBinaryMaskVL_V<vop_w, instruction_name, "WV",
930*0fca6ea1SDimitry Andric                                   wti.Vector, vti.Vector, wti.Mask,
931*0fca6ea1SDimitry Andric                                   vti.Log2SEW, vti.LMul, wti.RegClass,
932*0fca6ea1SDimitry Andric                                   vti.RegClass>;
93306c3fb27SDimitry Andric      def : VPatBinaryVL_V<vop_w, instruction_name, "WV",
93481ad6265SDimitry Andric                           wti.Vector, wti.Vector, vti.Vector, vti.Mask,
935bdd1243dSDimitry Andric                           vti.Log2SEW, vti.LMul, wti.RegClass, wti.RegClass,
936bdd1243dSDimitry Andric                           vti.RegClass>;
93706c3fb27SDimitry Andric      def : VPatBinaryVL_XI<vop_w, instruction_name, "WX",
93881ad6265SDimitry Andric                            wti.Vector, wti.Vector, vti.Vector, vti.Mask,
939bdd1243dSDimitry Andric                            vti.Log2SEW, vti.LMul, wti.RegClass, wti.RegClass,
940bdd1243dSDimitry Andric                            SplatPat, GPR>;
941bdd1243dSDimitry Andric    }
942bdd1243dSDimitry Andric  }
94306c3fb27SDimitry Andric}
944bdd1243dSDimitry Andric
94506c3fb27SDimitry Andricmulticlass VPatBinaryNVL_WV_WX_WI<SDPatternOperator vop, string instruction_name> {
946bdd1243dSDimitry Andric  foreach VtiToWti = AllWidenableIntVectors in {
947bdd1243dSDimitry Andric    defvar vti = VtiToWti.Vti;
948bdd1243dSDimitry Andric    defvar wti = VtiToWti.Wti;
94906c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
95006c3fb27SDimitry Andric                                 GetVTypePredicates<wti>.Predicates) in {
95106c3fb27SDimitry Andric      def : VPatBinaryVL_V<vop, instruction_name, "WV",
952bdd1243dSDimitry Andric                           vti.Vector, wti.Vector, vti.Vector, vti.Mask,
953bdd1243dSDimitry Andric                           vti.Log2SEW, vti.LMul, vti.RegClass, wti.RegClass,
954bdd1243dSDimitry Andric                           vti.RegClass>;
95506c3fb27SDimitry Andric      def : VPatBinaryVL_XI<vop, instruction_name, "WX",
956bdd1243dSDimitry Andric                            vti.Vector, wti.Vector, vti.Vector, vti.Mask,
957bdd1243dSDimitry Andric                            vti.Log2SEW, vti.LMul, vti.RegClass, wti.RegClass,
958bdd1243dSDimitry Andric                            SplatPat, GPR>;
95906c3fb27SDimitry Andric      def : VPatBinaryVL_XI<vop, instruction_name, "WI",
960bdd1243dSDimitry Andric                            vti.Vector, wti.Vector, vti.Vector, vti.Mask,
961bdd1243dSDimitry Andric                            vti.Log2SEW, vti.LMul, vti.RegClass, wti.RegClass,
962bdd1243dSDimitry Andric                            !cast<ComplexPattern>(SplatPat#_#uimm5),
963bdd1243dSDimitry Andric                            uimm5>;
964fe6060f1SDimitry Andric    }
965fe6060f1SDimitry Andric  }
96606c3fb27SDimitry Andric}
967fe6060f1SDimitry Andric
968*0fca6ea1SDimitry Andricmulticlass VPatBinaryRM_NVL_WV_WX_WI<SDNode vop, string instruction_name> {
969*0fca6ea1SDimitry Andric  foreach VtiToWti = AllWidenableIntVectors in {
970*0fca6ea1SDimitry Andric    defvar vti = VtiToWti.Vti;
971*0fca6ea1SDimitry Andric    defvar wti = VtiToWti.Wti;
972*0fca6ea1SDimitry Andric    defm : VPatBinaryRM_VL_V<vop, instruction_name, "WV",
973*0fca6ea1SDimitry Andric                             vti.Vector, wti.Vector, vti.Vector, vti.Mask,
974*0fca6ea1SDimitry Andric                             vti.Log2SEW, vti.LMul, vti.RegClass, wti.RegClass, vti.RegClass>;
975*0fca6ea1SDimitry Andric    defm : VPatBinaryRM_VL_XI<vop, instruction_name, "WX",
976*0fca6ea1SDimitry Andric                              vti.Vector, wti.Vector, vti.Vector, vti.Mask,
977*0fca6ea1SDimitry Andric                              vti.Log2SEW, vti.LMul, vti.RegClass, wti.RegClass, SplatPat, GPR>;
978*0fca6ea1SDimitry Andric    defm : VPatBinaryRM_VL_XI<vop, instruction_name, "WI",
979*0fca6ea1SDimitry Andric                              vti.Vector, wti.Vector, vti.Vector, vti.Mask,
980*0fca6ea1SDimitry Andric                              vti.Log2SEW, vti.LMul, vti.RegClass, wti.RegClass,
981*0fca6ea1SDimitry Andric                              !cast<ComplexPattern>(SplatPat#_#uimm5),
982*0fca6ea1SDimitry Andric                              uimm5>;
983*0fca6ea1SDimitry Andric  }
984*0fca6ea1SDimitry Andric}
985*0fca6ea1SDimitry Andric
98606c3fb27SDimitry Andricclass VPatBinaryVL_VF<SDPatternOperator vop,
987fe6060f1SDimitry Andric                      string instruction_name,
988fe6060f1SDimitry Andric                      ValueType result_type,
98906c3fb27SDimitry Andric                      ValueType vop1_type,
99006c3fb27SDimitry Andric                      ValueType vop2_type,
991fe6060f1SDimitry Andric                      ValueType mask_type,
99206c3fb27SDimitry Andric                      int log2sew,
993fe6060f1SDimitry Andric                      LMULInfo vlmul,
994bdd1243dSDimitry Andric                      VReg result_reg_class,
995fe6060f1SDimitry Andric                      VReg vop_reg_class,
99606c3fb27SDimitry Andric                      RegisterClass scalar_reg_class,
99706c3fb27SDimitry Andric                      bit isSEWAware = 0>
99806c3fb27SDimitry Andric    : Pat<(result_type (vop (vop1_type vop_reg_class:$rs1),
99906c3fb27SDimitry Andric                       (vop2_type (SplatFPOp scalar_reg_class:$rs2)),
1000bdd1243dSDimitry Andric                       (result_type result_reg_class:$merge),
100104eeddc0SDimitry Andric                       (mask_type V0),
100204eeddc0SDimitry Andric                       VLOpFrag)),
100306c3fb27SDimitry Andric      (!cast<Instruction>(
100406c3fb27SDimitry Andric                   !if(isSEWAware,
100506c3fb27SDimitry Andric                       instruction_name#"_"#vlmul.MX#"_E"#!shl(1, log2sew)#"_MASK",
100606c3fb27SDimitry Andric                       instruction_name#"_"#vlmul.MX#"_MASK"))
1007bdd1243dSDimitry Andric                   result_reg_class:$merge,
100804eeddc0SDimitry Andric                   vop_reg_class:$rs1,
100904eeddc0SDimitry Andric                   scalar_reg_class:$rs2,
101006c3fb27SDimitry Andric                   (mask_type V0), GPR:$vl, log2sew, TAIL_AGNOSTIC)>;
1011fe6060f1SDimitry Andric
101206c3fb27SDimitry Andricclass VPatBinaryVL_VF_RM<SDPatternOperator vop,
101306c3fb27SDimitry Andric                      string instruction_name,
101406c3fb27SDimitry Andric                      ValueType result_type,
101506c3fb27SDimitry Andric                      ValueType vop1_type,
101606c3fb27SDimitry Andric                      ValueType vop2_type,
101706c3fb27SDimitry Andric                      ValueType mask_type,
101806c3fb27SDimitry Andric                      int log2sew,
101906c3fb27SDimitry Andric                      LMULInfo vlmul,
102006c3fb27SDimitry Andric                      VReg result_reg_class,
102106c3fb27SDimitry Andric                      VReg vop_reg_class,
102206c3fb27SDimitry Andric                      RegisterClass scalar_reg_class,
102306c3fb27SDimitry Andric                      bit isSEWAware = 0>
102406c3fb27SDimitry Andric    : Pat<(result_type (vop (vop1_type vop_reg_class:$rs1),
102506c3fb27SDimitry Andric                       (vop2_type (SplatFPOp scalar_reg_class:$rs2)),
102606c3fb27SDimitry Andric                       (result_type result_reg_class:$merge),
102706c3fb27SDimitry Andric                       (mask_type V0),
102806c3fb27SDimitry Andric                       VLOpFrag)),
102906c3fb27SDimitry Andric      (!cast<Instruction>(
103006c3fb27SDimitry Andric                   !if(isSEWAware,
103106c3fb27SDimitry Andric                       instruction_name#"_"#vlmul.MX#"_E"#!shl(1, log2sew)#"_MASK",
103206c3fb27SDimitry Andric                       instruction_name#"_"#vlmul.MX#"_MASK"))
103306c3fb27SDimitry Andric                   result_reg_class:$merge,
103406c3fb27SDimitry Andric                   vop_reg_class:$rs1,
103506c3fb27SDimitry Andric                   scalar_reg_class:$rs2,
103606c3fb27SDimitry Andric                   (mask_type V0),
103706c3fb27SDimitry Andric                   // Value to indicate no rounding mode change in
103806c3fb27SDimitry Andric                   // RISCVInsertReadWriteCSR
103906c3fb27SDimitry Andric                   FRM_DYN,
104006c3fb27SDimitry Andric                   GPR:$vl, log2sew, TAIL_AGNOSTIC)>;
104106c3fb27SDimitry Andric
104206c3fb27SDimitry Andricmulticlass VPatBinaryFPVL_VV_VF<SDPatternOperator vop, string instruction_name,
104306c3fb27SDimitry Andric                                bit isSEWAware = 0> {
1044fe6060f1SDimitry Andric  foreach vti = AllFloatVectors in {
104506c3fb27SDimitry Andric    let Predicates = GetVTypePredicates<vti>.Predicates in {
104606c3fb27SDimitry Andric      def : VPatBinaryVL_V<vop, instruction_name, "VV",
104781ad6265SDimitry Andric                           vti.Vector, vti.Vector, vti.Vector, vti.Mask,
1048bdd1243dSDimitry Andric                           vti.Log2SEW, vti.LMul, vti.RegClass, vti.RegClass,
104906c3fb27SDimitry Andric                           vti.RegClass, isSEWAware>;
105006c3fb27SDimitry Andric      def : VPatBinaryVL_VF<vop, instruction_name#"_V"#vti.ScalarSuffix,
105106c3fb27SDimitry Andric                            vti.Vector, vti.Vector, vti.Vector, vti.Mask,
105206c3fb27SDimitry Andric                            vti.Log2SEW, vti.LMul, vti.RegClass, vti.RegClass,
105306c3fb27SDimitry Andric                            vti.ScalarRegClass, isSEWAware>;
105406c3fb27SDimitry Andric    }
1055fe6060f1SDimitry Andric  }
1056fe6060f1SDimitry Andric}
1057fe6060f1SDimitry Andric
105806c3fb27SDimitry Andricmulticlass VPatBinaryFPVL_VV_VF_RM<SDPatternOperator vop, string instruction_name,
105906c3fb27SDimitry Andric                                bit isSEWAware = 0> {
106006c3fb27SDimitry Andric  foreach vti = AllFloatVectors in {
106106c3fb27SDimitry Andric    let Predicates = GetVTypePredicates<vti>.Predicates in {
106206c3fb27SDimitry Andric      def : VPatBinaryVL_V_RM<vop, instruction_name, "VV",
106306c3fb27SDimitry Andric                             vti.Vector, vti.Vector, vti.Vector, vti.Mask,
106406c3fb27SDimitry Andric                             vti.Log2SEW, vti.LMul, vti.RegClass, vti.RegClass,
106506c3fb27SDimitry Andric                             vti.RegClass, isSEWAware>;
106606c3fb27SDimitry Andric      def : VPatBinaryVL_VF_RM<vop, instruction_name#"_V"#vti.ScalarSuffix,
106706c3fb27SDimitry Andric                               vti.Vector, vti.Vector, vti.Vector, vti.Mask,
106806c3fb27SDimitry Andric                               vti.Log2SEW, vti.LMul, vti.RegClass, vti.RegClass,
106906c3fb27SDimitry Andric                               vti.ScalarRegClass, isSEWAware>;
107006c3fb27SDimitry Andric      }
107106c3fb27SDimitry Andric  }
107206c3fb27SDimitry Andric}
107306c3fb27SDimitry Andric
107406c3fb27SDimitry Andricmulticlass VPatBinaryFPVL_R_VF<SDPatternOperator vop, string instruction_name,
107506c3fb27SDimitry Andric                               bit isSEWAware = 0> {
107604eeddc0SDimitry Andric  foreach fvti = AllFloatVectors in {
107706c3fb27SDimitry Andric    let Predicates = GetVTypePredicates<fvti>.Predicates in
1078fe6060f1SDimitry Andric    def : Pat<(fvti.Vector (vop (SplatFPOp fvti.ScalarRegClass:$rs2),
1079fe6060f1SDimitry Andric                                fvti.RegClass:$rs1,
1080bdd1243dSDimitry Andric                                (fvti.Vector fvti.RegClass:$merge),
108104eeddc0SDimitry Andric                                (fvti.Mask V0),
108204eeddc0SDimitry Andric                                VLOpFrag)),
108306c3fb27SDimitry Andric              (!cast<Instruction>(
108406c3fb27SDimitry Andric                           !if(isSEWAware,
108506c3fb27SDimitry Andric                               instruction_name#"_V"#fvti.ScalarSuffix#"_"#fvti.LMul.MX#"_E"#fvti.SEW#"_MASK",
108606c3fb27SDimitry Andric                               instruction_name#"_V"#fvti.ScalarSuffix#"_"#fvti.LMul.MX#"_MASK"))
1087bdd1243dSDimitry Andric                           fvti.RegClass:$merge,
108804eeddc0SDimitry Andric                           fvti.RegClass:$rs1, fvti.ScalarRegClass:$rs2,
108904eeddc0SDimitry Andric                           (fvti.Mask V0), GPR:$vl, fvti.Log2SEW, TAIL_AGNOSTIC)>;
109004eeddc0SDimitry Andric  }
1091fe6060f1SDimitry Andric}
1092fe6060f1SDimitry Andric
109306c3fb27SDimitry Andricmulticlass VPatBinaryFPVL_R_VF_RM<SDPatternOperator vop, string instruction_name,
109406c3fb27SDimitry Andric                                  bit isSEWAware = 0> {
109506c3fb27SDimitry Andric  foreach fvti = AllFloatVectors in {
109606c3fb27SDimitry Andric    let Predicates = GetVTypePredicates<fvti>.Predicates in
109706c3fb27SDimitry Andric    def : Pat<(fvti.Vector (vop (SplatFPOp fvti.ScalarRegClass:$rs2),
109806c3fb27SDimitry Andric                                fvti.RegClass:$rs1,
109906c3fb27SDimitry Andric                                (fvti.Vector fvti.RegClass:$merge),
110006c3fb27SDimitry Andric                                (fvti.Mask V0),
110106c3fb27SDimitry Andric                                VLOpFrag)),
110206c3fb27SDimitry Andric              (!cast<Instruction>(
110306c3fb27SDimitry Andric                           !if(isSEWAware,
110406c3fb27SDimitry Andric                               instruction_name#"_V"#fvti.ScalarSuffix#"_"#fvti.LMul.MX#"_E"#fvti.SEW#"_MASK",
110506c3fb27SDimitry Andric                               instruction_name#"_V"#fvti.ScalarSuffix#"_"#fvti.LMul.MX#"_MASK"))
110606c3fb27SDimitry Andric                           fvti.RegClass:$merge,
110706c3fb27SDimitry Andric                           fvti.RegClass:$rs1, fvti.ScalarRegClass:$rs2,
110806c3fb27SDimitry Andric                           (fvti.Mask V0),
110906c3fb27SDimitry Andric                           // Value to indicate no rounding mode change in
111006c3fb27SDimitry Andric                           // RISCVInsertReadWriteCSR
111106c3fb27SDimitry Andric                           FRM_DYN,
111206c3fb27SDimitry Andric                           GPR:$vl, fvti.Log2SEW, TAIL_AGNOSTIC)>;
111306c3fb27SDimitry Andric  }
111406c3fb27SDimitry Andric}
111506c3fb27SDimitry Andric
1116fe6060f1SDimitry Andricmulticlass VPatIntegerSetCCVL_VV<VTypeInfo vti, string instruction_name,
1117fe6060f1SDimitry Andric                                 CondCode cc> {
1118fe6060f1SDimitry Andric  def : Pat<(vti.Mask (riscv_setcc_vl (vti.Vector vti.RegClass:$rs1),
1119fe6060f1SDimitry Andric                                      vti.RegClass:$rs2, cc,
1120bdd1243dSDimitry Andric                                      VR:$merge,
112181ad6265SDimitry Andric                                      (vti.Mask V0),
1122fe6060f1SDimitry Andric                                      VLOpFrag)),
112381ad6265SDimitry Andric            (!cast<Instruction>(instruction_name#"_VV_"#vti.LMul.MX#"_MASK")
1124bdd1243dSDimitry Andric                         VR:$merge,
112581ad6265SDimitry Andric                         vti.RegClass:$rs1,
112681ad6265SDimitry Andric                         vti.RegClass:$rs2,
112781ad6265SDimitry Andric                         (vti.Mask V0), GPR:$vl, vti.Log2SEW)>;
1128fe6060f1SDimitry Andric}
1129fe6060f1SDimitry Andric
1130fe6060f1SDimitry Andric// Inherits from VPatIntegerSetCCVL_VV and adds a pattern with operands swapped.
1131fe6060f1SDimitry Andricmulticlass VPatIntegerSetCCVL_VV_Swappable<VTypeInfo vti, string instruction_name,
113281ad6265SDimitry Andric                                           CondCode cc, CondCode invcc>
113381ad6265SDimitry Andric    : VPatIntegerSetCCVL_VV<vti, instruction_name, cc> {
1134fe6060f1SDimitry Andric  def : Pat<(vti.Mask (riscv_setcc_vl (vti.Vector vti.RegClass:$rs2),
1135fe6060f1SDimitry Andric                                      vti.RegClass:$rs1, invcc,
1136bdd1243dSDimitry Andric                                      VR:$merge,
113781ad6265SDimitry Andric                                      (vti.Mask V0),
1138fe6060f1SDimitry Andric                                      VLOpFrag)),
113981ad6265SDimitry Andric            (!cast<Instruction>(instruction_name#"_VV_"#vti.LMul.MX#"_MASK")
1140bdd1243dSDimitry Andric                         VR:$merge, vti.RegClass:$rs1,
114181ad6265SDimitry Andric                         vti.RegClass:$rs2, (vti.Mask V0), GPR:$vl, vti.Log2SEW)>;
1142fe6060f1SDimitry Andric}
1143fe6060f1SDimitry Andric
1144fe6060f1SDimitry Andricmulticlass VPatIntegerSetCCVL_VX_Swappable<VTypeInfo vti, string instruction_name,
1145fe6060f1SDimitry Andric                                           CondCode cc, CondCode invcc> {
114681ad6265SDimitry Andric  defvar instruction_masked = !cast<Instruction>(instruction_name#"_VX_"#vti.LMul.MX#"_MASK");
1147fe6060f1SDimitry Andric  def : Pat<(vti.Mask (riscv_setcc_vl (vti.Vector vti.RegClass:$rs1),
1148fe6060f1SDimitry Andric                                      (SplatPat (XLenVT GPR:$rs2)), cc,
1149bdd1243dSDimitry Andric                                      VR:$merge,
115081ad6265SDimitry Andric                                      (vti.Mask V0),
1151fe6060f1SDimitry Andric                                      VLOpFrag)),
1152bdd1243dSDimitry Andric            (instruction_masked VR:$merge, vti.RegClass:$rs1,
115381ad6265SDimitry Andric                                GPR:$rs2, (vti.Mask V0), GPR:$vl, vti.Log2SEW)>;
1154fe6060f1SDimitry Andric  def : Pat<(vti.Mask (riscv_setcc_vl (SplatPat (XLenVT GPR:$rs2)),
1155fe6060f1SDimitry Andric                                      (vti.Vector vti.RegClass:$rs1), invcc,
1156bdd1243dSDimitry Andric                                      VR:$merge,
115781ad6265SDimitry Andric                                      (vti.Mask V0),
1158fe6060f1SDimitry Andric                                      VLOpFrag)),
1159bdd1243dSDimitry Andric            (instruction_masked VR:$merge, vti.RegClass:$rs1,
116081ad6265SDimitry Andric                                GPR:$rs2, (vti.Mask V0), GPR:$vl, vti.Log2SEW)>;
1161fe6060f1SDimitry Andric}
1162fe6060f1SDimitry Andric
1163fe6060f1SDimitry Andricmulticlass VPatIntegerSetCCVL_VI_Swappable<VTypeInfo vti, string instruction_name,
1164fe6060f1SDimitry Andric                                           CondCode cc, CondCode invcc> {
116581ad6265SDimitry Andric  defvar instruction_masked = !cast<Instruction>(instruction_name#"_VI_"#vti.LMul.MX#"_MASK");
1166fe6060f1SDimitry Andric  def : Pat<(vti.Mask (riscv_setcc_vl (vti.Vector vti.RegClass:$rs1),
1167fe6060f1SDimitry Andric                                      (SplatPat_simm5 simm5:$rs2), cc,
1168bdd1243dSDimitry Andric                                      VR:$merge,
116981ad6265SDimitry Andric                                      (vti.Mask V0),
1170fe6060f1SDimitry Andric                                      VLOpFrag)),
1171bdd1243dSDimitry Andric            (instruction_masked VR:$merge, vti.RegClass:$rs1,
117281ad6265SDimitry Andric                                XLenVT:$rs2, (vti.Mask V0), GPR:$vl,
117381ad6265SDimitry Andric                                vti.Log2SEW)>;
117481ad6265SDimitry Andric
117581ad6265SDimitry Andric  // FIXME: Can do some canonicalization to remove these patterns.
1176fe6060f1SDimitry Andric  def : Pat<(vti.Mask (riscv_setcc_vl (SplatPat_simm5 simm5:$rs2),
1177fe6060f1SDimitry Andric                                      (vti.Vector vti.RegClass:$rs1), invcc,
1178bdd1243dSDimitry Andric                                      VR:$merge,
117981ad6265SDimitry Andric                                      (vti.Mask V0),
1180fe6060f1SDimitry Andric                                      VLOpFrag)),
1181bdd1243dSDimitry Andric            (instruction_masked VR:$merge, vti.RegClass:$rs1,
118281ad6265SDimitry Andric                                simm5:$rs2, (vti.Mask V0), GPR:$vl,
118381ad6265SDimitry Andric                                vti.Log2SEW)>;
1184fe6060f1SDimitry Andric}
1185fe6060f1SDimitry Andric
118681ad6265SDimitry Andricmulticlass VPatIntegerSetCCVL_VIPlus1_Swappable<VTypeInfo vti,
118781ad6265SDimitry Andric                                                string instruction_name,
118881ad6265SDimitry Andric                                                CondCode cc, CondCode invcc,
118981ad6265SDimitry Andric                                                ComplexPattern splatpat_kind> {
119081ad6265SDimitry Andric  defvar instruction_masked = !cast<Instruction>(instruction_name#"_VI_"#vti.LMul.MX#"_MASK");
1191fe6060f1SDimitry Andric  def : Pat<(vti.Mask (riscv_setcc_vl (vti.Vector vti.RegClass:$rs1),
1192fe6060f1SDimitry Andric                                      (splatpat_kind simm5:$rs2), cc,
1193bdd1243dSDimitry Andric                                      VR:$merge,
119481ad6265SDimitry Andric                                      (vti.Mask V0),
1195fe6060f1SDimitry Andric                                      VLOpFrag)),
1196bdd1243dSDimitry Andric            (instruction_masked VR:$merge, vti.RegClass:$rs1,
119781ad6265SDimitry Andric                                (DecImm simm5:$rs2), (vti.Mask V0), GPR:$vl,
119881ad6265SDimitry Andric                                vti.Log2SEW)>;
119981ad6265SDimitry Andric
120081ad6265SDimitry Andric  // FIXME: Can do some canonicalization to remove these patterns.
120181ad6265SDimitry Andric  def : Pat<(vti.Mask (riscv_setcc_vl (splatpat_kind simm5:$rs2),
120281ad6265SDimitry Andric                                      (vti.Vector vti.RegClass:$rs1), invcc,
1203bdd1243dSDimitry Andric                                      VR:$merge,
120481ad6265SDimitry Andric                                      (vti.Mask V0),
120581ad6265SDimitry Andric                                      VLOpFrag)),
1206bdd1243dSDimitry Andric            (instruction_masked VR:$merge, vti.RegClass:$rs1,
120781ad6265SDimitry Andric                                (DecImm simm5:$rs2), (vti.Mask V0), GPR:$vl,
120881ad6265SDimitry Andric                                vti.Log2SEW)>;
1209fe6060f1SDimitry Andric}
1210fe6060f1SDimitry Andric
121106c3fb27SDimitry Andricmulticlass VPatFPSetCCVL_VV_VF_FV<SDPatternOperator vop, CondCode cc,
1212fe6060f1SDimitry Andric                                  string inst_name,
1213fe6060f1SDimitry Andric                                  string swapped_op_inst_name> {
1214fe6060f1SDimitry Andric  foreach fvti = AllFloatVectors in {
121506c3fb27SDimitry Andric    let Predicates = GetVTypePredicates<fvti>.Predicates in {
121606c3fb27SDimitry Andric      def : Pat<(fvti.Mask (vop (fvti.Vector fvti.RegClass:$rs1),
1217fe6060f1SDimitry Andric                                 fvti.RegClass:$rs2,
1218fe6060f1SDimitry Andric                                 cc,
1219bdd1243dSDimitry Andric                                 VR:$merge,
122081ad6265SDimitry Andric                                 (fvti.Mask V0),
1221fe6060f1SDimitry Andric                                 VLOpFrag)),
122281ad6265SDimitry Andric                (!cast<Instruction>(inst_name#"_VV_"#fvti.LMul.MX#"_MASK")
1223bdd1243dSDimitry Andric                    VR:$merge, fvti.RegClass:$rs1,
122481ad6265SDimitry Andric                    fvti.RegClass:$rs2, (fvti.Mask V0),
122581ad6265SDimitry Andric                    GPR:$vl, fvti.Log2SEW)>;
122606c3fb27SDimitry Andric      def : Pat<(fvti.Mask (vop (fvti.Vector fvti.RegClass:$rs1),
1227fe6060f1SDimitry Andric                                (SplatFPOp fvti.ScalarRegClass:$rs2),
1228fe6060f1SDimitry Andric                                cc,
1229bdd1243dSDimitry Andric                                VR:$merge,
123081ad6265SDimitry Andric                                (fvti.Mask V0),
1231fe6060f1SDimitry Andric                                VLOpFrag)),
123281ad6265SDimitry Andric                (!cast<Instruction>(inst_name#"_V"#fvti.ScalarSuffix#"_"#fvti.LMul.MX#"_MASK")
1233bdd1243dSDimitry Andric                    VR:$merge, fvti.RegClass:$rs1,
123481ad6265SDimitry Andric                    fvti.ScalarRegClass:$rs2, (fvti.Mask V0),
1235fe6060f1SDimitry Andric                    GPR:$vl, fvti.Log2SEW)>;
123606c3fb27SDimitry Andric      def : Pat<(fvti.Mask (vop (SplatFPOp fvti.ScalarRegClass:$rs2),
1237fe6060f1SDimitry Andric                                (fvti.Vector fvti.RegClass:$rs1),
1238fe6060f1SDimitry Andric                                cc,
1239bdd1243dSDimitry Andric                                VR:$merge,
124081ad6265SDimitry Andric                                (fvti.Mask V0),
1241fe6060f1SDimitry Andric                                VLOpFrag)),
124281ad6265SDimitry Andric                (!cast<Instruction>(swapped_op_inst_name#"_V"#fvti.ScalarSuffix#"_"#fvti.LMul.MX#"_MASK")
1243bdd1243dSDimitry Andric                    VR:$merge, fvti.RegClass:$rs1,
124481ad6265SDimitry Andric                    fvti.ScalarRegClass:$rs2, (fvti.Mask V0),
1245fe6060f1SDimitry Andric                    GPR:$vl, fvti.Log2SEW)>;
1246fe6060f1SDimitry Andric    }
1247fe6060f1SDimitry Andric  }
124806c3fb27SDimitry Andric}
1249fe6060f1SDimitry Andric
1250bdd1243dSDimitry Andricmulticlass VPatExtendVL_V<SDNode vop, string inst_name, string suffix,
1251fe6060f1SDimitry Andric                          list <VTypeInfoToFraction> fraction_list> {
1252fe6060f1SDimitry Andric  foreach vtiTofti = fraction_list in {
1253fe6060f1SDimitry Andric    defvar vti = vtiTofti.Vti;
1254fe6060f1SDimitry Andric    defvar fti = vtiTofti.Fti;
125506c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
125606c3fb27SDimitry Andric                                 GetVTypePredicates<fti>.Predicates) in
1257fe6060f1SDimitry Andric    def : Pat<(vti.Vector (vop (fti.Vector fti.RegClass:$rs2),
125881ad6265SDimitry Andric                               (fti.Mask V0), VLOpFrag)),
125981ad6265SDimitry Andric              (!cast<Instruction>(inst_name#"_"#suffix#"_"#vti.LMul.MX#"_MASK")
126081ad6265SDimitry Andric                  (vti.Vector (IMPLICIT_DEF)),
126181ad6265SDimitry Andric                  fti.RegClass:$rs2,
1262bdd1243dSDimitry Andric                  (fti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
1263fe6060f1SDimitry Andric  }
1264fe6060f1SDimitry Andric}
1265fe6060f1SDimitry Andric
1266bdd1243dSDimitry Andric// Single width converting
1267bdd1243dSDimitry Andric
126806c3fb27SDimitry Andricmulticlass VPatConvertFP2IVL_V<SDPatternOperator vop, string instruction_name> {
1269fe6060f1SDimitry Andric  foreach fvti = AllFloatVectors in {
1270fe6060f1SDimitry Andric    defvar ivti = GetIntVTypeInfo<fvti>.Vti;
127106c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
127206c3fb27SDimitry Andric                                 GetVTypePredicates<ivti>.Predicates) in
1273fe6060f1SDimitry Andric    def : Pat<(ivti.Vector (vop (fvti.Vector fvti.RegClass:$rs1),
127481ad6265SDimitry Andric                                (fvti.Mask V0),
1275fe6060f1SDimitry Andric                                VLOpFrag)),
127681ad6265SDimitry Andric              (!cast<Instruction>(instruction_name#"_"#ivti.LMul.MX#"_MASK")
127781ad6265SDimitry Andric                  (ivti.Vector (IMPLICIT_DEF)), fvti.RegClass:$rs1,
1278bdd1243dSDimitry Andric                  (fvti.Mask V0), GPR:$vl, ivti.Log2SEW, TA_MA)>;
1279fe6060f1SDimitry Andric  }
1280fe6060f1SDimitry Andric}
1281fe6060f1SDimitry Andric
128206c3fb27SDimitry Andricmulticlass VPatConvertFP2IVL_V_RM<SDPatternOperator vop, string instruction_name> {
1283bdd1243dSDimitry Andric  foreach fvti = AllFloatVectors in {
1284bdd1243dSDimitry Andric    defvar ivti = GetIntVTypeInfo<fvti>.Vti;
128506c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
128606c3fb27SDimitry Andric                                 GetVTypePredicates<ivti>.Predicates) in
128706c3fb27SDimitry Andric    def : Pat<(ivti.Vector (vop (fvti.Vector fvti.RegClass:$rs1),
128806c3fb27SDimitry Andric                                (fvti.Mask V0),
128906c3fb27SDimitry Andric                                VLOpFrag)),
129006c3fb27SDimitry Andric              (!cast<Instruction>(instruction_name#"_"#ivti.LMul.MX#"_MASK")
129106c3fb27SDimitry Andric                  (ivti.Vector (IMPLICIT_DEF)), fvti.RegClass:$rs1,
129206c3fb27SDimitry Andric                  (fvti.Mask V0),
129306c3fb27SDimitry Andric                  // Value to indicate no rounding mode change in
129406c3fb27SDimitry Andric                  // RISCVInsertReadWriteCSR
129506c3fb27SDimitry Andric                  FRM_DYN,
129606c3fb27SDimitry Andric                  GPR:$vl, ivti.Log2SEW, TA_MA)>;
129706c3fb27SDimitry Andric  }
129806c3fb27SDimitry Andric}
129906c3fb27SDimitry Andric
130006c3fb27SDimitry Andric
130106c3fb27SDimitry Andricmulticlass VPatConvertFP2I_RM_VL_V<SDPatternOperator vop, string instruction_name> {
130206c3fb27SDimitry Andric  foreach fvti = AllFloatVectors in {
130306c3fb27SDimitry Andric    defvar ivti = GetIntVTypeInfo<fvti>.Vti;
130406c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
130506c3fb27SDimitry Andric                                 GetVTypePredicates<ivti>.Predicates) in
1306bdd1243dSDimitry Andric    def : Pat<(ivti.Vector (vop (fvti.Vector fvti.RegClass:$rs1),
1307bdd1243dSDimitry Andric                                (fvti.Mask V0), (XLenVT timm:$frm),
1308bdd1243dSDimitry Andric                                VLOpFrag)),
1309bdd1243dSDimitry Andric              (!cast<Instruction>(instruction_name#"_"#ivti.LMul.MX#"_MASK")
1310bdd1243dSDimitry Andric                  (ivti.Vector (IMPLICIT_DEF)), fvti.RegClass:$rs1,
1311bdd1243dSDimitry Andric                  (fvti.Mask V0), timm:$frm, GPR:$vl, ivti.Log2SEW,
1312bdd1243dSDimitry Andric                  TA_MA)>;
1313bdd1243dSDimitry Andric  }
1314bdd1243dSDimitry Andric}
1315bdd1243dSDimitry Andric
131606c3fb27SDimitry Andricmulticlass VPatConvertI2FPVL_V_RM<SDPatternOperator vop, string instruction_name> {
1317fe6060f1SDimitry Andric  foreach fvti = AllFloatVectors in {
1318fe6060f1SDimitry Andric    defvar ivti = GetIntVTypeInfo<fvti>.Vti;
131906c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
132006c3fb27SDimitry Andric                                 GetVTypePredicates<ivti>.Predicates) in
1321fe6060f1SDimitry Andric    def : Pat<(fvti.Vector (vop (ivti.Vector ivti.RegClass:$rs1),
132281ad6265SDimitry Andric                                (ivti.Mask V0),
1323fe6060f1SDimitry Andric                                VLOpFrag)),
1324*0fca6ea1SDimitry Andric              (!cast<Instruction>(instruction_name#"_"#fvti.LMul.MX#"_E"#fvti.SEW#"_MASK")
132581ad6265SDimitry Andric                  (fvti.Vector (IMPLICIT_DEF)), ivti.RegClass:$rs1,
132606c3fb27SDimitry Andric                  (ivti.Mask V0),
132706c3fb27SDimitry Andric                  // Value to indicate no rounding mode change in
132806c3fb27SDimitry Andric                  // RISCVInsertReadWriteCSR
132906c3fb27SDimitry Andric                  FRM_DYN,
133006c3fb27SDimitry Andric                  GPR:$vl, fvti.Log2SEW, TA_MA)>;
1331fe6060f1SDimitry Andric  }
1332fe6060f1SDimitry Andric}
1333fe6060f1SDimitry Andric
1334bdd1243dSDimitry Andricmulticlass VPatConvertI2FP_RM_VL_V<SDNode vop, string instruction_name> {
1335bdd1243dSDimitry Andric  foreach fvti = AllFloatVectors in {
1336bdd1243dSDimitry Andric    defvar ivti = GetIntVTypeInfo<fvti>.Vti;
133706c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
133806c3fb27SDimitry Andric                                 GetVTypePredicates<ivti>.Predicates) in
1339bdd1243dSDimitry Andric    def : Pat<(fvti.Vector (vop (ivti.Vector ivti.RegClass:$rs1),
1340bdd1243dSDimitry Andric                                (ivti.Mask V0), (XLenVT timm:$frm),
1341bdd1243dSDimitry Andric                                VLOpFrag)),
1342*0fca6ea1SDimitry Andric              (!cast<Instruction>(instruction_name#"_"#fvti.LMul.MX#"_E"#fvti.SEW#"_MASK")
1343bdd1243dSDimitry Andric                  (fvti.Vector (IMPLICIT_DEF)), ivti.RegClass:$rs1,
1344bdd1243dSDimitry Andric                  (ivti.Mask V0), timm:$frm, GPR:$vl, fvti.Log2SEW, TA_MA)>;
1345bdd1243dSDimitry Andric  }
1346bdd1243dSDimitry Andric}
1347bdd1243dSDimitry Andric
1348bdd1243dSDimitry Andric// Widening converting
1349bdd1243dSDimitry Andric
135006c3fb27SDimitry Andricmulticlass VPatWConvertFP2IVL_V<SDPatternOperator vop, string instruction_name> {
1351fe6060f1SDimitry Andric  foreach fvtiToFWti = AllWidenableFloatVectors in {
1352fe6060f1SDimitry Andric    defvar fvti = fvtiToFWti.Vti;
1353fe6060f1SDimitry Andric    defvar iwti = GetIntVTypeInfo<fvtiToFWti.Wti>.Vti;
135406c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
135506c3fb27SDimitry Andric                                 GetVTypePredicates<iwti>.Predicates) in
1356fe6060f1SDimitry Andric    def : Pat<(iwti.Vector (vop (fvti.Vector fvti.RegClass:$rs1),
135781ad6265SDimitry Andric                                (fvti.Mask V0),
1358fe6060f1SDimitry Andric                                VLOpFrag)),
135981ad6265SDimitry Andric              (!cast<Instruction>(instruction_name#"_"#fvti.LMul.MX#"_MASK")
136081ad6265SDimitry Andric                  (iwti.Vector (IMPLICIT_DEF)), fvti.RegClass:$rs1,
1361bdd1243dSDimitry Andric                  (fvti.Mask V0), GPR:$vl, fvti.Log2SEW, TA_MA)>;
1362fe6060f1SDimitry Andric  }
1363fe6060f1SDimitry Andric}
1364fe6060f1SDimitry Andric
136506c3fb27SDimitry Andricmulticlass VPatWConvertFP2IVL_V_RM<SDPatternOperator vop, string instruction_name> {
136606c3fb27SDimitry Andric  foreach fvtiToFWti = AllWidenableFloatVectors in {
136706c3fb27SDimitry Andric    defvar fvti = fvtiToFWti.Vti;
136806c3fb27SDimitry Andric    defvar iwti = GetIntVTypeInfo<fvtiToFWti.Wti>.Vti;
136906c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
137006c3fb27SDimitry Andric                                 GetVTypePredicates<iwti>.Predicates) in
137106c3fb27SDimitry Andric    def : Pat<(iwti.Vector (vop (fvti.Vector fvti.RegClass:$rs1),
137206c3fb27SDimitry Andric                                (fvti.Mask V0),
137306c3fb27SDimitry Andric                                VLOpFrag)),
137406c3fb27SDimitry Andric              (!cast<Instruction>(instruction_name#"_"#fvti.LMul.MX#"_MASK")
137506c3fb27SDimitry Andric                  (iwti.Vector (IMPLICIT_DEF)), fvti.RegClass:$rs1,
137606c3fb27SDimitry Andric                  (fvti.Mask V0),
137706c3fb27SDimitry Andric                  // Value to indicate no rounding mode change in
137806c3fb27SDimitry Andric                  // RISCVInsertReadWriteCSR
137906c3fb27SDimitry Andric                  FRM_DYN,
138006c3fb27SDimitry Andric                  GPR:$vl, fvti.Log2SEW, TA_MA)>;
138106c3fb27SDimitry Andric  }
138206c3fb27SDimitry Andric}
138306c3fb27SDimitry Andric
138406c3fb27SDimitry Andric
1385bdd1243dSDimitry Andricmulticlass VPatWConvertFP2I_RM_VL_V<SDNode vop, string instruction_name> {
1386bdd1243dSDimitry Andric  foreach fvtiToFWti = AllWidenableFloatVectors in {
1387bdd1243dSDimitry Andric    defvar fvti = fvtiToFWti.Vti;
1388bdd1243dSDimitry Andric    defvar iwti = GetIntVTypeInfo<fvtiToFWti.Wti>.Vti;
138906c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
139006c3fb27SDimitry Andric                                 GetVTypePredicates<iwti>.Predicates) in
1391bdd1243dSDimitry Andric    def : Pat<(iwti.Vector (vop (fvti.Vector fvti.RegClass:$rs1),
1392bdd1243dSDimitry Andric                                (fvti.Mask V0), (XLenVT timm:$frm),
1393bdd1243dSDimitry Andric                                VLOpFrag)),
1394bdd1243dSDimitry Andric              (!cast<Instruction>(instruction_name#"_"#fvti.LMul.MX#"_MASK")
1395bdd1243dSDimitry Andric                  (iwti.Vector (IMPLICIT_DEF)), fvti.RegClass:$rs1,
1396bdd1243dSDimitry Andric                  (fvti.Mask V0), timm:$frm, GPR:$vl, fvti.Log2SEW, TA_MA)>;
1397bdd1243dSDimitry Andric  }
1398bdd1243dSDimitry Andric}
1399bdd1243dSDimitry Andric
140006c3fb27SDimitry Andricmulticlass VPatWConvertI2FPVL_V<SDPatternOperator vop,
140106c3fb27SDimitry Andric                                string instruction_name> {
1402fe6060f1SDimitry Andric  foreach vtiToWti = AllWidenableIntToFloatVectors in {
1403fe6060f1SDimitry Andric    defvar ivti = vtiToWti.Vti;
1404fe6060f1SDimitry Andric    defvar fwti = vtiToWti.Wti;
140506c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<ivti>.Predicates,
140606c3fb27SDimitry Andric                                 GetVTypePredicates<fwti>.Predicates) in
1407fe6060f1SDimitry Andric    def : Pat<(fwti.Vector (vop (ivti.Vector ivti.RegClass:$rs1),
140881ad6265SDimitry Andric                                (ivti.Mask V0),
1409fe6060f1SDimitry Andric                                VLOpFrag)),
1410*0fca6ea1SDimitry Andric              (!cast<Instruction>(instruction_name#"_"#ivti.LMul.MX#"_E"#ivti.SEW#"_MASK")
141181ad6265SDimitry Andric                  (fwti.Vector (IMPLICIT_DEF)), ivti.RegClass:$rs1,
141206c3fb27SDimitry Andric                  (ivti.Mask V0),
141306c3fb27SDimitry Andric                  GPR:$vl, ivti.Log2SEW, TA_MA)>;
1414bdd1243dSDimitry Andric  }
1415bdd1243dSDimitry Andric}
1416bdd1243dSDimitry Andric
1417bdd1243dSDimitry Andric// Narrowing converting
1418bdd1243dSDimitry Andric
141906c3fb27SDimitry Andricmulticlass VPatNConvertFP2IVL_W<SDPatternOperator vop,
142006c3fb27SDimitry Andric                                string instruction_name> {
1421bdd1243dSDimitry Andric  // Reuse the same list of types used in the widening nodes, but just swap the
1422bdd1243dSDimitry Andric  // direction of types around so we're converting from Wti -> Vti
1423fe6060f1SDimitry Andric  foreach vtiToWti = AllWidenableIntToFloatVectors in {
1424fe6060f1SDimitry Andric    defvar vti = vtiToWti.Vti;
1425fe6060f1SDimitry Andric    defvar fwti = vtiToWti.Wti;
142606c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
142706c3fb27SDimitry Andric                                 GetVTypePredicates<fwti>.Predicates) in
1428fe6060f1SDimitry Andric    def : Pat<(vti.Vector (vop (fwti.Vector fwti.RegClass:$rs1),
142981ad6265SDimitry Andric                               (fwti.Mask V0),
1430fe6060f1SDimitry Andric                               VLOpFrag)),
143181ad6265SDimitry Andric              (!cast<Instruction>(instruction_name#"_"#vti.LMul.MX#"_MASK")
143281ad6265SDimitry Andric                  (vti.Vector (IMPLICIT_DEF)), fwti.RegClass:$rs1,
1433bdd1243dSDimitry Andric                  (fwti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
1434fe6060f1SDimitry Andric  }
1435fe6060f1SDimitry Andric}
1436fe6060f1SDimitry Andric
143706c3fb27SDimitry Andricmulticlass VPatNConvertFP2IVL_W_RM<SDPatternOperator vop,
143806c3fb27SDimitry Andric                                string instruction_name> {
143906c3fb27SDimitry Andric  // Reuse the same list of types used in the widening nodes, but just swap the
144006c3fb27SDimitry Andric  // direction of types around so we're converting from Wti -> Vti
1441bdd1243dSDimitry Andric  foreach vtiToWti = AllWidenableIntToFloatVectors in {
1442bdd1243dSDimitry Andric    defvar vti = vtiToWti.Vti;
1443bdd1243dSDimitry Andric    defvar fwti = vtiToWti.Wti;
144406c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
144506c3fb27SDimitry Andric                                 GetVTypePredicates<fwti>.Predicates) in
144606c3fb27SDimitry Andric    def : Pat<(vti.Vector (vop (fwti.Vector fwti.RegClass:$rs1),
144706c3fb27SDimitry Andric                               (fwti.Mask V0),
144806c3fb27SDimitry Andric                               VLOpFrag)),
144906c3fb27SDimitry Andric              (!cast<Instruction>(instruction_name#"_"#vti.LMul.MX#"_MASK")
145006c3fb27SDimitry Andric                  (vti.Vector (IMPLICIT_DEF)), fwti.RegClass:$rs1,
145106c3fb27SDimitry Andric                  (fwti.Mask V0),
145206c3fb27SDimitry Andric                  // Value to indicate no rounding mode change in
145306c3fb27SDimitry Andric                  // RISCVInsertReadWriteCSR
145406c3fb27SDimitry Andric                  FRM_DYN,
145506c3fb27SDimitry Andric                  GPR:$vl, vti.Log2SEW, TA_MA)>;
145606c3fb27SDimitry Andric  }
145706c3fb27SDimitry Andric}
145806c3fb27SDimitry Andric
145906c3fb27SDimitry Andricmulticlass VPatNConvertFP2I_RM_VL_W<SDNode vop, string instruction_name> {
146006c3fb27SDimitry Andric  foreach vtiToWti = AllWidenableIntToFloatVectors in {
146106c3fb27SDimitry Andric    defvar vti = vtiToWti.Vti;
146206c3fb27SDimitry Andric    defvar fwti = vtiToWti.Wti;
146306c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
146406c3fb27SDimitry Andric                                 GetVTypePredicates<fwti>.Predicates) in
1465bdd1243dSDimitry Andric    def : Pat<(vti.Vector (vop (fwti.Vector fwti.RegClass:$rs1),
1466bdd1243dSDimitry Andric                               (fwti.Mask V0), (XLenVT timm:$frm),
1467bdd1243dSDimitry Andric                               VLOpFrag)),
1468bdd1243dSDimitry Andric              (!cast<Instruction>(instruction_name#"_"#vti.LMul.MX#"_MASK")
1469bdd1243dSDimitry Andric                  (vti.Vector (IMPLICIT_DEF)), fwti.RegClass:$rs1,
1470bdd1243dSDimitry Andric                  (fwti.Mask V0), timm:$frm, GPR:$vl, vti.Log2SEW, TA_MA)>;
1471bdd1243dSDimitry Andric  }
1472bdd1243dSDimitry Andric}
1473bdd1243dSDimitry Andric
147406c3fb27SDimitry Andricmulticlass VPatNConvertI2FPVL_W_RM<SDPatternOperator vop,
147506c3fb27SDimitry Andric                                string instruction_name> {
1476fe6060f1SDimitry Andric  foreach fvtiToFWti = AllWidenableFloatVectors in {
1477fe6060f1SDimitry Andric    defvar fvti = fvtiToFWti.Vti;
1478fe6060f1SDimitry Andric    defvar iwti = GetIntVTypeInfo<fvtiToFWti.Wti>.Vti;
147906c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
148006c3fb27SDimitry Andric                                 GetVTypePredicates<iwti>.Predicates) in
1481fe6060f1SDimitry Andric    def : Pat<(fvti.Vector (vop (iwti.Vector iwti.RegClass:$rs1),
148281ad6265SDimitry Andric                                (iwti.Mask V0),
1483fe6060f1SDimitry Andric                                VLOpFrag)),
1484*0fca6ea1SDimitry Andric              (!cast<Instruction>(instruction_name#"_"#fvti.LMul.MX#"_E"#fvti.SEW#"_MASK")
148581ad6265SDimitry Andric                  (fvti.Vector (IMPLICIT_DEF)), iwti.RegClass:$rs1,
148606c3fb27SDimitry Andric                  (iwti.Mask V0),
148706c3fb27SDimitry Andric                  // Value to indicate no rounding mode change in
148806c3fb27SDimitry Andric                  // RISCVInsertReadWriteCSR
148906c3fb27SDimitry Andric                  FRM_DYN,
149006c3fb27SDimitry Andric                  GPR:$vl, fvti.Log2SEW, TA_MA)>;
1491bdd1243dSDimitry Andric  }
1492bdd1243dSDimitry Andric}
1493bdd1243dSDimitry Andric
149406c3fb27SDimitry Andricmulticlass VPatNConvertI2FP_RM_VL_W<SDNode vop, string instruction_name> {
1495bdd1243dSDimitry Andric  foreach fvtiToFWti = AllWidenableFloatVectors in {
1496bdd1243dSDimitry Andric    defvar fvti = fvtiToFWti.Vti;
1497bdd1243dSDimitry Andric    defvar iwti = GetIntVTypeInfo<fvtiToFWti.Wti>.Vti;
149806c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
149906c3fb27SDimitry Andric                                 GetVTypePredicates<iwti>.Predicates) in
1500bdd1243dSDimitry Andric    def : Pat<(fvti.Vector (vop (iwti.Vector iwti.RegClass:$rs1),
1501bdd1243dSDimitry Andric                                (iwti.Mask V0),  (XLenVT timm:$frm),
1502bdd1243dSDimitry Andric                                VLOpFrag)),
1503*0fca6ea1SDimitry Andric              (!cast<Instruction>(instruction_name#"_"#fvti.LMul.MX#"_E"#fvti.SEW#"_MASK")
1504bdd1243dSDimitry Andric                  (fvti.Vector (IMPLICIT_DEF)), iwti.RegClass:$rs1,
1505bdd1243dSDimitry Andric                  (iwti.Mask V0), timm:$frm, GPR:$vl, fvti.Log2SEW, TA_MA)>;
1506fe6060f1SDimitry Andric  }
1507fe6060f1SDimitry Andric}
1508fe6060f1SDimitry Andric
1509fe6060f1SDimitry Andricmulticlass VPatReductionVL<SDNode vop, string instruction_name, bit is_float> {
1510fe6060f1SDimitry Andric  foreach vti = !if(is_float, AllFloatVectors, AllIntegerVectors) in {
1511fe6060f1SDimitry Andric    defvar vti_m1 = !cast<VTypeInfo>(!if(is_float, "VF", "VI") # vti.SEW # "M1");
151206c3fb27SDimitry Andric    let Predicates = GetVTypePredicates<vti>.Predicates in {
151306c3fb27SDimitry Andric      def: Pat<(vti_m1.Vector (vop (vti_m1.Vector VR:$merge),
151406c3fb27SDimitry Andric                                   (vti.Vector vti.RegClass:$rs1), VR:$rs2,
151506c3fb27SDimitry Andric                                   (vti.Mask V0), VLOpFrag,
151606c3fb27SDimitry Andric                                   (XLenVT timm:$policy))),
151706c3fb27SDimitry Andric          (!cast<Instruction>(instruction_name#"_VS_"#vti.LMul.MX#"_E"#vti.SEW#"_MASK")
1518349cc55cSDimitry Andric              (vti_m1.Vector VR:$merge),
1519349cc55cSDimitry Andric              (vti.Vector vti.RegClass:$rs1),
1520349cc55cSDimitry Andric              (vti_m1.Vector VR:$rs2),
152106c3fb27SDimitry Andric              (vti.Mask V0), GPR:$vl, vti.Log2SEW, (XLenVT timm:$policy))>;
152206c3fb27SDimitry Andric    }
1523fe6060f1SDimitry Andric  }
1524fe6060f1SDimitry Andric}
1525fe6060f1SDimitry Andric
152606c3fb27SDimitry Andricmulticlass VPatReductionVL_RM<SDNode vop, string instruction_name, bit is_float> {
152706c3fb27SDimitry Andric  foreach vti = !if(is_float, AllFloatVectors, AllIntegerVectors) in {
152806c3fb27SDimitry Andric    defvar vti_m1 = !cast<VTypeInfo>(!if(is_float, "VF", "VI") # vti.SEW # "M1");
152906c3fb27SDimitry Andric    let Predicates = GetVTypePredicates<vti>.Predicates in {
153006c3fb27SDimitry Andric      def: Pat<(vti_m1.Vector (vop (vti_m1.Vector VR:$merge),
153106c3fb27SDimitry Andric                                   (vti.Vector vti.RegClass:$rs1), VR:$rs2,
153206c3fb27SDimitry Andric                                   (vti.Mask V0), VLOpFrag,
153306c3fb27SDimitry Andric                                   (XLenVT timm:$policy))),
153406c3fb27SDimitry Andric          (!cast<Instruction>(instruction_name#"_VS_"#vti.LMul.MX#"_E"#vti.SEW#"_MASK")
153506c3fb27SDimitry Andric              (vti_m1.Vector VR:$merge),
153606c3fb27SDimitry Andric              (vti.Vector vti.RegClass:$rs1),
153706c3fb27SDimitry Andric              (vti_m1.Vector VR:$rs2),
153806c3fb27SDimitry Andric              (vti.Mask V0),
153906c3fb27SDimitry Andric              // Value to indicate no rounding mode change in
154006c3fb27SDimitry Andric              // RISCVInsertReadWriteCSR
154106c3fb27SDimitry Andric              FRM_DYN,
154206c3fb27SDimitry Andric              GPR:$vl, vti.Log2SEW, (XLenVT timm:$policy))>;
154306c3fb27SDimitry Andric    }
154404eeddc0SDimitry Andric  }
154504eeddc0SDimitry Andric}
154604eeddc0SDimitry Andric
1547bdd1243dSDimitry Andricmulticlass VPatBinaryVL_WV_WX_WI<SDNode op, string instruction_name> {
154881ad6265SDimitry Andric  foreach vtiToWti = AllWidenableIntVectors in {
154981ad6265SDimitry Andric    defvar vti = vtiToWti.Vti;
155081ad6265SDimitry Andric    defvar wti = vtiToWti.Wti;
155106c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
155206c3fb27SDimitry Andric                                 GetVTypePredicates<wti>.Predicates) in {
155306c3fb27SDimitry Andric      def : Pat<
155406c3fb27SDimitry Andric        (vti.Vector
155506c3fb27SDimitry Andric          (riscv_trunc_vector_vl
155606c3fb27SDimitry Andric            (op (wti.Vector wti.RegClass:$rs2),
155706c3fb27SDimitry Andric                (wti.Vector (ext_oneuse (vti.Vector vti.RegClass:$rs1)))),
155806c3fb27SDimitry Andric            (vti.Mask true_mask),
155906c3fb27SDimitry Andric            VLOpFrag)),
156006c3fb27SDimitry Andric        (!cast<Instruction>(instruction_name#"_WV_"#vti.LMul.MX)
156106c3fb27SDimitry Andric          (vti.Vector (IMPLICIT_DEF)),
15625f757f3fSDimitry Andric          wti.RegClass:$rs2, vti.RegClass:$rs1, GPR:$vl, vti.Log2SEW, TA_MA)>;
156306c3fb27SDimitry Andric
156406c3fb27SDimitry Andric      def : Pat<
156506c3fb27SDimitry Andric        (vti.Vector
156606c3fb27SDimitry Andric          (riscv_trunc_vector_vl
156706c3fb27SDimitry Andric            (op (wti.Vector wti.RegClass:$rs2),
15685f757f3fSDimitry Andric                (wti.Vector (Low8BitsSplatPat (XLenVT GPR:$rs1)))),
156906c3fb27SDimitry Andric            (vti.Mask true_mask),
157006c3fb27SDimitry Andric            VLOpFrag)),
157106c3fb27SDimitry Andric        (!cast<Instruction>(instruction_name#"_WX_"#vti.LMul.MX)
157206c3fb27SDimitry Andric          (vti.Vector (IMPLICIT_DEF)),
15735f757f3fSDimitry Andric          wti.RegClass:$rs2, GPR:$rs1, GPR:$vl, vti.Log2SEW, TA_MA)>;
157406c3fb27SDimitry Andric
157581ad6265SDimitry Andric      def : Pat<
157681ad6265SDimitry Andric        (vti.Vector
157781ad6265SDimitry Andric          (riscv_trunc_vector_vl
157881ad6265SDimitry Andric            (op (wti.Vector wti.RegClass:$rs2),
157981ad6265SDimitry Andric                (wti.Vector (SplatPat_uimm5 uimm5:$rs1))), (vti.Mask true_mask),
158081ad6265SDimitry Andric            VLOpFrag)),
158181ad6265SDimitry Andric        (!cast<Instruction>(instruction_name#"_WI_"#vti.LMul.MX)
158206c3fb27SDimitry Andric          (vti.Vector (IMPLICIT_DEF)),
15835f757f3fSDimitry Andric          wti.RegClass:$rs2, uimm5:$rs1, GPR:$vl, vti.Log2SEW, TA_MA)>;
158406c3fb27SDimitry Andric    }
158581ad6265SDimitry Andric  }
158604eeddc0SDimitry Andric}
158704eeddc0SDimitry Andric
158881ad6265SDimitry Andricmulticlass VPatWidenReductionVL<SDNode vop, PatFrags extop, string instruction_name, bit is_float> {
158981ad6265SDimitry Andric  foreach vtiToWti = !if(is_float, AllWidenableFloatVectors, AllWidenableIntVectors) in {
159081ad6265SDimitry Andric    defvar vti = vtiToWti.Vti;
159181ad6265SDimitry Andric    defvar wti = vtiToWti.Wti;
159281ad6265SDimitry Andric    defvar wti_m1 = !cast<VTypeInfo>(!if(is_float, "VF", "VI") # wti.SEW # "M1");
159306c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
159406c3fb27SDimitry Andric                                 GetVTypePredicates<wti>.Predicates) in {
159581ad6265SDimitry Andric      def: Pat<(wti_m1.Vector (vop (wti_m1.Vector VR:$merge),
159681ad6265SDimitry Andric                                   (wti.Vector (extop (vti.Vector vti.RegClass:$rs1))),
159706c3fb27SDimitry Andric                                   VR:$rs2, (vti.Mask V0), VLOpFrag,
159806c3fb27SDimitry Andric                                   (XLenVT timm:$policy))),
159906c3fb27SDimitry Andric               (!cast<Instruction>(instruction_name#"_VS_"#vti.LMul.MX#"_E"#vti.SEW#"_MASK")
160081ad6265SDimitry Andric                  (wti_m1.Vector VR:$merge), (vti.Vector vti.RegClass:$rs1),
160106c3fb27SDimitry Andric                  (wti_m1.Vector VR:$rs2), (vti.Mask V0), GPR:$vl, vti.Log2SEW,
160206c3fb27SDimitry Andric                  (XLenVT timm:$policy))>;
160306c3fb27SDimitry Andric    }
160406c3fb27SDimitry Andric  }
160506c3fb27SDimitry Andric}
160606c3fb27SDimitry Andric
160706c3fb27SDimitry Andricmulticlass VPatWidenReductionVL_RM<SDNode vop, PatFrags extop, string instruction_name, bit is_float> {
160806c3fb27SDimitry Andric  foreach vtiToWti = !if(is_float, AllWidenableFloatVectors, AllWidenableIntVectors) in {
160906c3fb27SDimitry Andric    defvar vti = vtiToWti.Vti;
161006c3fb27SDimitry Andric    defvar wti = vtiToWti.Wti;
161106c3fb27SDimitry Andric    defvar wti_m1 = !cast<VTypeInfo>(!if(is_float, "VF", "VI") # wti.SEW # "M1");
161206c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
161306c3fb27SDimitry Andric                                 GetVTypePredicates<wti>.Predicates) in {
161406c3fb27SDimitry Andric      def: Pat<(wti_m1.Vector (vop (wti_m1.Vector VR:$merge),
161506c3fb27SDimitry Andric                                   (wti.Vector (extop (vti.Vector vti.RegClass:$rs1))),
161606c3fb27SDimitry Andric                                   VR:$rs2, (vti.Mask V0), VLOpFrag,
161706c3fb27SDimitry Andric                                   (XLenVT timm:$policy))),
161806c3fb27SDimitry Andric               (!cast<Instruction>(instruction_name#"_VS_"#vti.LMul.MX#"_E"#vti.SEW#"_MASK")
161906c3fb27SDimitry Andric                  (wti_m1.Vector VR:$merge), (vti.Vector vti.RegClass:$rs1),
162006c3fb27SDimitry Andric                  (wti_m1.Vector VR:$rs2), (vti.Mask V0),
162106c3fb27SDimitry Andric                  // Value to indicate no rounding mode change in
162206c3fb27SDimitry Andric                  // RISCVInsertReadWriteCSR
162306c3fb27SDimitry Andric                  FRM_DYN,
162406c3fb27SDimitry Andric                  GPR:$vl, vti.Log2SEW,
162506c3fb27SDimitry Andric                  (XLenVT timm:$policy))>;
162606c3fb27SDimitry Andric    }
162781ad6265SDimitry Andric  }
162881ad6265SDimitry Andric}
162981ad6265SDimitry Andric
163081ad6265SDimitry Andricmulticlass VPatWidenReductionVL_Ext_VL<SDNode vop, PatFrags extop, string instruction_name, bit is_float> {
163181ad6265SDimitry Andric  foreach vtiToWti = !if(is_float, AllWidenableFloatVectors, AllWidenableIntVectors) in {
163281ad6265SDimitry Andric    defvar vti = vtiToWti.Vti;
163381ad6265SDimitry Andric    defvar wti = vtiToWti.Wti;
163481ad6265SDimitry Andric    defvar wti_m1 = !cast<VTypeInfo>(!if(is_float, "VF", "VI") # wti.SEW # "M1");
163506c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
163606c3fb27SDimitry Andric                                 GetVTypePredicates<wti>.Predicates) in {
163781ad6265SDimitry Andric      def: Pat<(wti_m1.Vector (vop (wti_m1.Vector VR:$merge),
163881ad6265SDimitry Andric                                   (wti.Vector (extop (vti.Vector vti.RegClass:$rs1), (vti.Mask true_mask), VLOpFrag)),
163906c3fb27SDimitry Andric                                   VR:$rs2, (vti.Mask V0), VLOpFrag,
164006c3fb27SDimitry Andric                                   (XLenVT timm:$policy))),
164106c3fb27SDimitry Andric               (!cast<Instruction>(instruction_name#"_VS_"#vti.LMul.MX#"_E"#vti.SEW#"_MASK")
164281ad6265SDimitry Andric                  (wti_m1.Vector VR:$merge), (vti.Vector vti.RegClass:$rs1),
164306c3fb27SDimitry Andric                  (wti_m1.Vector VR:$rs2), (vti.Mask V0), GPR:$vl, vti.Log2SEW,
164406c3fb27SDimitry Andric                  (XLenVT timm:$policy))>;
164506c3fb27SDimitry Andric    }
164681ad6265SDimitry Andric  }
164781ad6265SDimitry Andric}
164881ad6265SDimitry Andric
164906c3fb27SDimitry Andricmulticlass VPatWidenReductionVL_Ext_VL_RM<SDNode vop, PatFrags extop, string instruction_name, bit is_float> {
165006c3fb27SDimitry Andric  foreach vtiToWti = !if(is_float, AllWidenableFloatVectors, AllWidenableIntVectors) in {
165106c3fb27SDimitry Andric    defvar vti = vtiToWti.Vti;
165206c3fb27SDimitry Andric    defvar wti = vtiToWti.Wti;
165306c3fb27SDimitry Andric    defvar wti_m1 = !cast<VTypeInfo>(!if(is_float, "VF", "VI") # wti.SEW # "M1");
165406c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
165506c3fb27SDimitry Andric                                 GetVTypePredicates<wti>.Predicates) in {
165606c3fb27SDimitry Andric      def: Pat<(wti_m1.Vector (vop (wti_m1.Vector VR:$merge),
165706c3fb27SDimitry Andric                                   (wti.Vector (extop (vti.Vector vti.RegClass:$rs1), (vti.Mask true_mask), VLOpFrag)),
165806c3fb27SDimitry Andric                                   VR:$rs2, (vti.Mask V0), VLOpFrag,
165906c3fb27SDimitry Andric                                   (XLenVT timm:$policy))),
166006c3fb27SDimitry Andric               (!cast<Instruction>(instruction_name#"_VS_"#vti.LMul.MX#"_E"#vti.SEW#"_MASK")
166106c3fb27SDimitry Andric                  (wti_m1.Vector VR:$merge), (vti.Vector vti.RegClass:$rs1),
166206c3fb27SDimitry Andric                  (wti_m1.Vector VR:$rs2), (vti.Mask V0),
166306c3fb27SDimitry Andric                  // Value to indicate no rounding mode change in
166406c3fb27SDimitry Andric                  // RISCVInsertReadWriteCSR
166506c3fb27SDimitry Andric                  FRM_DYN,
166606c3fb27SDimitry Andric                  GPR:$vl, vti.Log2SEW,
166706c3fb27SDimitry Andric                  (XLenVT timm:$policy))>;
166806c3fb27SDimitry Andric    }
166906c3fb27SDimitry Andric  }
167006c3fb27SDimitry Andric}
167106c3fb27SDimitry Andric
167206c3fb27SDimitry Andricmulticlass VPatBinaryFPWVL_VV_VF<SDNode vop, string instruction_name> {
167381ad6265SDimitry Andric  foreach fvtiToFWti = AllWidenableFloatVectors in {
167406c3fb27SDimitry Andric    defvar vti = fvtiToFWti.Vti;
167506c3fb27SDimitry Andric    defvar wti = fvtiToFWti.Wti;
167606c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
167706c3fb27SDimitry Andric                                 GetVTypePredicates<wti>.Predicates) in {
167806c3fb27SDimitry Andric      def : VPatBinaryVL_V<vop, instruction_name, "VV",
167906c3fb27SDimitry Andric                           wti.Vector, vti.Vector, vti.Vector, vti.Mask,
168006c3fb27SDimitry Andric                           vti.Log2SEW, vti.LMul, wti.RegClass, vti.RegClass,
168106c3fb27SDimitry Andric                           vti.RegClass>;
168206c3fb27SDimitry Andric      def : VPatBinaryVL_VF<vop, instruction_name#"_V"#vti.ScalarSuffix,
168306c3fb27SDimitry Andric                            wti.Vector, vti.Vector, vti.Vector, vti.Mask,
168406c3fb27SDimitry Andric                            vti.Log2SEW, vti.LMul, wti.RegClass, vti.RegClass,
168506c3fb27SDimitry Andric                            vti.ScalarRegClass>;
168606c3fb27SDimitry Andric    }
168781ad6265SDimitry Andric  }
168881ad6265SDimitry Andric}
168981ad6265SDimitry Andric
1690*0fca6ea1SDimitry Andricmulticlass VPatBinaryFPWVL_VV_VF_RM<SDNode vop, string instruction_name,
1691*0fca6ea1SDimitry Andric                                    bit isSEWAware = 0> {
169281ad6265SDimitry Andric  foreach fvtiToFWti = AllWidenableFloatVectors in {
169306c3fb27SDimitry Andric    defvar vti = fvtiToFWti.Vti;
169406c3fb27SDimitry Andric    defvar wti = fvtiToFWti.Wti;
169506c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
169606c3fb27SDimitry Andric                                 GetVTypePredicates<wti>.Predicates) in {
169706c3fb27SDimitry Andric      def : VPatBinaryVL_V_RM<vop, instruction_name, "VV",
169806c3fb27SDimitry Andric                                       wti.Vector, vti.Vector, vti.Vector, vti.Mask,
169906c3fb27SDimitry Andric                                       vti.Log2SEW, vti.LMul, wti.RegClass, vti.RegClass,
1700*0fca6ea1SDimitry Andric                                       vti.RegClass, isSEWAware>;
170106c3fb27SDimitry Andric      def : VPatBinaryVL_VF_RM<vop, instruction_name#"_V"#vti.ScalarSuffix,
170206c3fb27SDimitry Andric                                        wti.Vector, vti.Vector, vti.Vector, vti.Mask,
170306c3fb27SDimitry Andric                                        vti.Log2SEW, vti.LMul, wti.RegClass, vti.RegClass,
1704*0fca6ea1SDimitry Andric                                        vti.ScalarRegClass, isSEWAware>;
170506c3fb27SDimitry Andric    }
170681ad6265SDimitry Andric  }
170781ad6265SDimitry Andric}
170881ad6265SDimitry Andric
170906c3fb27SDimitry Andricmulticlass VPatBinaryFPWVL_VV_VF_WV_WF<SDNode vop, SDNode vop_w, string instruction_name>
171006c3fb27SDimitry Andric    : VPatBinaryFPWVL_VV_VF<vop, instruction_name> {
171106c3fb27SDimitry Andric  foreach fvtiToFWti = AllWidenableFloatVectors in {
171206c3fb27SDimitry Andric    defvar vti = fvtiToFWti.Vti;
171306c3fb27SDimitry Andric    defvar wti = fvtiToFWti.Wti;
171406c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
171506c3fb27SDimitry Andric                                 GetVTypePredicates<wti>.Predicates) in {
171606c3fb27SDimitry Andric      defm : VPatTiedBinaryNoMaskVL_V<vop_w, instruction_name, "WV",
171706c3fb27SDimitry Andric                                      wti.Vector, vti.Vector, vti.Log2SEW,
171806c3fb27SDimitry Andric                                      vti.LMul, wti.RegClass, vti.RegClass>;
171906c3fb27SDimitry Andric      def : VPatBinaryVL_V<vop_w, instruction_name, "WV",
172006c3fb27SDimitry Andric                           wti.Vector, wti.Vector, vti.Vector, vti.Mask,
172106c3fb27SDimitry Andric                           vti.Log2SEW, vti.LMul, wti.RegClass, wti.RegClass,
172206c3fb27SDimitry Andric                           vti.RegClass>;
172306c3fb27SDimitry Andric      def : VPatBinaryVL_VF<vop_w, instruction_name#"_W"#vti.ScalarSuffix,
172406c3fb27SDimitry Andric                            wti.Vector, wti.Vector, vti.Vector, vti.Mask,
172506c3fb27SDimitry Andric                            vti.Log2SEW, vti.LMul, wti.RegClass, wti.RegClass,
172606c3fb27SDimitry Andric                            vti.ScalarRegClass>;
172706c3fb27SDimitry Andric    }
172806c3fb27SDimitry Andric  }
172906c3fb27SDimitry Andric}
173006c3fb27SDimitry Andric
1731*0fca6ea1SDimitry Andricmulticlass VPatBinaryFPWVL_VV_VF_WV_WF_RM<
1732*0fca6ea1SDimitry Andric    SDNode vop, SDNode vop_w, string instruction_name, bit isSEWAware = 0>
1733*0fca6ea1SDimitry Andric    : VPatBinaryFPWVL_VV_VF_RM<vop, instruction_name, isSEWAware> {
173406c3fb27SDimitry Andric  foreach fvtiToFWti = AllWidenableFloatVectors in {
173506c3fb27SDimitry Andric    defvar vti = fvtiToFWti.Vti;
173606c3fb27SDimitry Andric    defvar wti = fvtiToFWti.Wti;
173706c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
173806c3fb27SDimitry Andric                                 GetVTypePredicates<wti>.Predicates) in {
173906c3fb27SDimitry Andric      defm : VPatTiedBinaryNoMaskVL_V_RM<vop_w, instruction_name, "WV",
174006c3fb27SDimitry Andric                                         wti.Vector, vti.Vector, vti.Log2SEW,
1741*0fca6ea1SDimitry Andric                                         vti.LMul, wti.RegClass, vti.RegClass,
1742*0fca6ea1SDimitry Andric                                         isSEWAware>;
174306c3fb27SDimitry Andric      def : VPatBinaryVL_V_RM<vop_w, instruction_name, "WV",
174406c3fb27SDimitry Andric                                       wti.Vector, wti.Vector, vti.Vector, vti.Mask,
174506c3fb27SDimitry Andric                                       vti.Log2SEW, vti.LMul, wti.RegClass, wti.RegClass,
1746*0fca6ea1SDimitry Andric                                       vti.RegClass, isSEWAware>;
174706c3fb27SDimitry Andric      def : VPatBinaryVL_VF_RM<vop_w, instruction_name#"_W"#vti.ScalarSuffix,
174806c3fb27SDimitry Andric                                        wti.Vector, wti.Vector, vti.Vector, vti.Mask,
174906c3fb27SDimitry Andric                                        vti.Log2SEW, vti.LMul, wti.RegClass, wti.RegClass,
1750*0fca6ea1SDimitry Andric                                        vti.ScalarRegClass, isSEWAware>;
175106c3fb27SDimitry Andric    }
175206c3fb27SDimitry Andric  }
175381ad6265SDimitry Andric}
175481ad6265SDimitry Andric
175581ad6265SDimitry Andricmulticlass VPatNarrowShiftSplatExt_WX<SDNode op, PatFrags extop, string instruction_name> {
175681ad6265SDimitry Andric  foreach vtiToWti = AllWidenableIntVectors in {
175781ad6265SDimitry Andric    defvar vti = vtiToWti.Vti;
175881ad6265SDimitry Andric    defvar wti = vtiToWti.Wti;
175906c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
176006c3fb27SDimitry Andric                                 GetVTypePredicates<wti>.Predicates) in
176181ad6265SDimitry Andric    def : Pat<
176281ad6265SDimitry Andric      (vti.Vector
176381ad6265SDimitry Andric        (riscv_trunc_vector_vl
176481ad6265SDimitry Andric          (op (wti.Vector wti.RegClass:$rs2),
176506c3fb27SDimitry Andric              (wti.Vector (extop (vti.Vector (SplatPat (XLenVT GPR:$rs1))),
176681ad6265SDimitry Andric                                 (vti.Mask true_mask), VLOpFrag)),
1767bdd1243dSDimitry Andric          srcvalue, (wti.Mask true_mask), VLOpFrag),
176881ad6265SDimitry Andric        (vti.Mask true_mask), VLOpFrag)),
176981ad6265SDimitry Andric      (!cast<Instruction>(instruction_name#"_WX_"#vti.LMul.MX)
177006c3fb27SDimitry Andric        (vti.Vector (IMPLICIT_DEF)),
17715f757f3fSDimitry Andric        wti.RegClass:$rs2, GPR:$rs1, GPR:$vl, vti.Log2SEW, TA_MA)>;
177281ad6265SDimitry Andric  }
177381ad6265SDimitry Andric}
177481ad6265SDimitry Andric
177506c3fb27SDimitry Andricmulticlass VPatNarrowShiftExtVL_WV<SDNode op, PatFrags extop, string instruction_name> {
177606c3fb27SDimitry Andric  foreach vtiToWti = AllWidenableIntVectors in {
177706c3fb27SDimitry Andric    defvar vti = vtiToWti.Vti;
177806c3fb27SDimitry Andric    defvar wti = vtiToWti.Wti;
177906c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
178006c3fb27SDimitry Andric                                 GetVTypePredicates<wti>.Predicates) in
178106c3fb27SDimitry Andric    def : Pat<
178206c3fb27SDimitry Andric      (vti.Vector
178306c3fb27SDimitry Andric        (riscv_trunc_vector_vl
178406c3fb27SDimitry Andric          (op (wti.Vector wti.RegClass:$rs2),
178506c3fb27SDimitry Andric              (wti.Vector (extop (vti.Vector vti.RegClass:$rs1),
178606c3fb27SDimitry Andric                                 (vti.Mask true_mask), VLOpFrag)),
178706c3fb27SDimitry Andric          srcvalue, (vti.Mask true_mask), VLOpFrag),
178806c3fb27SDimitry Andric        (vti.Mask V0), VLOpFrag)),
178906c3fb27SDimitry Andric      (!cast<Instruction>(instruction_name#"_WV_"#vti.LMul.MX#"_MASK")
179006c3fb27SDimitry Andric        (vti.Vector (IMPLICIT_DEF)), wti.RegClass:$rs2, vti.RegClass:$rs1,
17915f757f3fSDimitry Andric        (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
179206c3fb27SDimitry Andric  }
179306c3fb27SDimitry Andric}
179406c3fb27SDimitry Andric
179506c3fb27SDimitry Andricmulticlass VPatNarrowShiftVL_WV<SDNode op, string instruction_name> {
179606c3fb27SDimitry Andric  defm : VPatNarrowShiftExtVL_WV<op, riscv_sext_vl_oneuse, instruction_name>;
179706c3fb27SDimitry Andric  defm : VPatNarrowShiftExtVL_WV<op, riscv_zext_vl_oneuse, instruction_name>;
179806c3fb27SDimitry Andric}
179906c3fb27SDimitry Andric
180081ad6265SDimitry Andricmulticlass VPatMultiplyAddVL_VV_VX<SDNode op, string instruction_name> {
180181ad6265SDimitry Andric  foreach vti = AllIntegerVectors in {
180281ad6265SDimitry Andric    defvar suffix = vti.LMul.MX;
180306c3fb27SDimitry Andric    let Predicates = GetVTypePredicates<vti>.Predicates in {
180481ad6265SDimitry Andric      // NOTE: We choose VMADD because it has the most commuting freedom. So it
180581ad6265SDimitry Andric      // works best with how TwoAddressInstructionPass tries commuting.
180681ad6265SDimitry Andric      def : Pat<(vti.Vector
180781ad6265SDimitry Andric               (op vti.RegClass:$rs2,
180881ad6265SDimitry Andric                   (riscv_mul_vl_oneuse vti.RegClass:$rs1,
180981ad6265SDimitry Andric                                        vti.RegClass:$rd,
1810bdd1243dSDimitry Andric                                        srcvalue, (vti.Mask true_mask), VLOpFrag),
1811bdd1243dSDimitry Andric                             srcvalue, (vti.Mask true_mask), VLOpFrag)),
181281ad6265SDimitry Andric              (!cast<Instruction>(instruction_name#"_VV_"# suffix)
181381ad6265SDimitry Andric                   vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
181481ad6265SDimitry Andric                   GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
181581ad6265SDimitry Andric      // The choice of VMADD here is arbitrary, vmadd.vx and vmacc.vx are equally
181681ad6265SDimitry Andric      // commutable.
181781ad6265SDimitry Andric      def : Pat<(vti.Vector
181881ad6265SDimitry Andric               (op vti.RegClass:$rs2,
181981ad6265SDimitry Andric                   (riscv_mul_vl_oneuse (SplatPat XLenVT:$rs1),
182081ad6265SDimitry Andric                                         vti.RegClass:$rd,
1821bdd1243dSDimitry Andric                                         srcvalue, (vti.Mask true_mask), VLOpFrag),
1822bdd1243dSDimitry Andric                             srcvalue, (vti.Mask true_mask), VLOpFrag)),
182381ad6265SDimitry Andric              (!cast<Instruction>(instruction_name#"_VX_" # suffix)
182481ad6265SDimitry Andric                   vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
182581ad6265SDimitry Andric                   GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
182681ad6265SDimitry Andric    }
182781ad6265SDimitry Andric  }
182806c3fb27SDimitry Andric}
182981ad6265SDimitry Andric
1830bdd1243dSDimitry Andricmulticlass VPatMultiplyAccVL_VV_VX<PatFrag op, string instruction_name> {
1831bdd1243dSDimitry Andric  foreach vti = AllIntegerVectors in {
1832bdd1243dSDimitry Andric  defvar suffix = vti.LMul.MX;
183306c3fb27SDimitry Andric  let Predicates = GetVTypePredicates<vti>.Predicates in {
1834cb14a3feSDimitry Andric    def : Pat<(riscv_vmerge_vl (vti.Mask V0),
1835bdd1243dSDimitry Andric                (vti.Vector (op vti.RegClass:$rd,
1836bdd1243dSDimitry Andric                                (riscv_mul_vl_oneuse vti.RegClass:$rs1, vti.RegClass:$rs2,
1837bdd1243dSDimitry Andric                                    srcvalue, (vti.Mask true_mask), VLOpFrag),
1838bdd1243dSDimitry Andric                                srcvalue, (vti.Mask true_mask), VLOpFrag)),
1839cb14a3feSDimitry Andric                            vti.RegClass:$rd, vti.RegClass:$rd, VLOpFrag),
1840bdd1243dSDimitry Andric              (!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
1841bdd1243dSDimitry Andric                   vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
184206c3fb27SDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TU_MU)>;
1843cb14a3feSDimitry Andric    def : Pat<(riscv_vmerge_vl (vti.Mask V0),
1844bdd1243dSDimitry Andric                (vti.Vector (op vti.RegClass:$rd,
1845bdd1243dSDimitry Andric                                (riscv_mul_vl_oneuse (SplatPat XLenVT:$rs1), vti.RegClass:$rs2,
1846bdd1243dSDimitry Andric                                    srcvalue, (vti.Mask true_mask), VLOpFrag),
1847bdd1243dSDimitry Andric                                srcvalue, (vti.Mask true_mask), VLOpFrag)),
1848cb14a3feSDimitry Andric                            vti.RegClass:$rd, vti.RegClass:$rd, VLOpFrag),
1849bdd1243dSDimitry Andric              (!cast<Instruction>(instruction_name#"_VX_"# suffix #"_MASK")
1850bdd1243dSDimitry Andric                   vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
185106c3fb27SDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TU_MU)>;
18521db9f3b2SDimitry Andric    def : Pat<(riscv_vmerge_vl (vti.Mask V0),
1853bdd1243dSDimitry Andric                (vti.Vector (op vti.RegClass:$rd,
1854bdd1243dSDimitry Andric                                (riscv_mul_vl_oneuse vti.RegClass:$rs1, vti.RegClass:$rs2,
1855bdd1243dSDimitry Andric                                    srcvalue, (vti.Mask true_mask), VLOpFrag),
1856bdd1243dSDimitry Andric                                srcvalue, (vti.Mask true_mask), VLOpFrag)),
18571db9f3b2SDimitry Andric                            vti.RegClass:$rd, undef, VLOpFrag),
1858bdd1243dSDimitry Andric              (!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
1859bdd1243dSDimitry Andric                   vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
1860bdd1243dSDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
18611db9f3b2SDimitry Andric    def : Pat<(riscv_vmerge_vl (vti.Mask V0),
1862bdd1243dSDimitry Andric                (vti.Vector (op vti.RegClass:$rd,
1863bdd1243dSDimitry Andric                                (riscv_mul_vl_oneuse (SplatPat XLenVT:$rs1), vti.RegClass:$rs2,
1864bdd1243dSDimitry Andric                                    srcvalue, (vti.Mask true_mask), VLOpFrag),
1865bdd1243dSDimitry Andric                                srcvalue, (vti.Mask true_mask), VLOpFrag)),
18661db9f3b2SDimitry Andric                            vti.RegClass:$rd, undef, VLOpFrag),
1867bdd1243dSDimitry Andric              (!cast<Instruction>(instruction_name#"_VX_"# suffix #"_MASK")
1868bdd1243dSDimitry Andric                   vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
1869bdd1243dSDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
1870bdd1243dSDimitry Andric    }
1871bdd1243dSDimitry Andric  }
187206c3fb27SDimitry Andric}
1873bdd1243dSDimitry Andric
187406c3fb27SDimitry Andricmulticlass VPatWidenMultiplyAddVL_VV_VX<SDNode vwmacc_op, string instr_name> {
187581ad6265SDimitry Andric  foreach vtiTowti = AllWidenableIntVectors in {
187681ad6265SDimitry Andric    defvar vti = vtiTowti.Vti;
187781ad6265SDimitry Andric    defvar wti = vtiTowti.Wti;
187806c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
187906c3fb27SDimitry Andric                                 GetVTypePredicates<wti>.Predicates) in {
188006c3fb27SDimitry Andric      def : Pat<(vwmacc_op (vti.Vector vti.RegClass:$rs1),
188181ad6265SDimitry Andric                           (vti.Vector vti.RegClass:$rs2),
188206c3fb27SDimitry Andric                           (wti.Vector wti.RegClass:$rd),
188306c3fb27SDimitry Andric                           (vti.Mask V0), VLOpFrag),
188406c3fb27SDimitry Andric                (!cast<Instruction>(instr_name#"_VV_"#vti.LMul.MX#"_MASK")
188581ad6265SDimitry Andric                    wti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
188606c3fb27SDimitry Andric                    (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
188706c3fb27SDimitry Andric      def : Pat<(vwmacc_op (SplatPat XLenVT:$rs1),
188881ad6265SDimitry Andric                           (vti.Vector vti.RegClass:$rs2),
188906c3fb27SDimitry Andric                           (wti.Vector wti.RegClass:$rd),
189006c3fb27SDimitry Andric                           (vti.Mask V0), VLOpFrag),
189106c3fb27SDimitry Andric                (!cast<Instruction>(instr_name#"_VX_"#vti.LMul.MX#"_MASK")
189206c3fb27SDimitry Andric                    wti.RegClass:$rd, vti.ScalarRegClass:$rs1,
189306c3fb27SDimitry Andric                    vti.RegClass:$rs2, (vti.Mask V0), GPR:$vl, vti.Log2SEW,
189406c3fb27SDimitry Andric                    TAIL_AGNOSTIC)>;
189506c3fb27SDimitry Andric    }
189681ad6265SDimitry Andric  }
189781ad6265SDimitry Andric}
189881ad6265SDimitry Andric
189981ad6265SDimitry Andricmulticlass VPatNarrowShiftSplat_WX_WI<SDNode op, string instruction_name> {
190081ad6265SDimitry Andric  foreach vtiTowti = AllWidenableIntVectors in {
190181ad6265SDimitry Andric    defvar vti = vtiTowti.Vti;
190281ad6265SDimitry Andric    defvar wti = vtiTowti.Wti;
190306c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
190406c3fb27SDimitry Andric                                 GetVTypePredicates<wti>.Predicates) in {
190581ad6265SDimitry Andric      def : Pat<(vti.Vector (riscv_trunc_vector_vl
190681ad6265SDimitry Andric                (wti.Vector (op wti.RegClass:$rs1, (SplatPat XLenVT:$rs2),
1907bdd1243dSDimitry Andric                                srcvalue, true_mask, VLOpFrag)), true_mask, VLOpFrag)),
190881ad6265SDimitry Andric                (!cast<Instruction>(instruction_name#"_WX_"#vti.LMul.MX)
190906c3fb27SDimitry Andric                    (vti.Vector (IMPLICIT_DEF)),
19105f757f3fSDimitry Andric                     wti.RegClass:$rs1, GPR:$rs2, GPR:$vl, vti.Log2SEW, TA_MA)>;
191181ad6265SDimitry Andric      def : Pat<(vti.Vector (riscv_trunc_vector_vl
191281ad6265SDimitry Andric                (wti.Vector (op wti.RegClass:$rs1, (SplatPat_uimm5 uimm5:$rs2),
1913bdd1243dSDimitry Andric                                srcvalue, true_mask, VLOpFrag)), true_mask, VLOpFrag)),
191481ad6265SDimitry Andric                (!cast<Instruction>(instruction_name#"_WI_"#vti.LMul.MX)
191506c3fb27SDimitry Andric                (vti.Vector (IMPLICIT_DEF)),
19165f757f3fSDimitry Andric                wti.RegClass:$rs1, uimm5:$rs2, GPR:$vl, vti.Log2SEW, TA_MA)>;
191706c3fb27SDimitry Andric    }
191881ad6265SDimitry Andric  }
191981ad6265SDimitry Andric}
192081ad6265SDimitry Andric
192106c3fb27SDimitry Andricmulticlass VPatFPMulAddVL_VV_VF<SDPatternOperator vop, string instruction_name> {
192281ad6265SDimitry Andric  foreach vti = AllFloatVectors in {
192381ad6265SDimitry Andric  defvar suffix = vti.LMul.MX;
192406c3fb27SDimitry Andric  let Predicates = GetVTypePredicates<vti>.Predicates in {
192581ad6265SDimitry Andric    def : Pat<(vti.Vector (vop vti.RegClass:$rs1, vti.RegClass:$rd,
192681ad6265SDimitry Andric                               vti.RegClass:$rs2, (vti.Mask V0),
192781ad6265SDimitry Andric                               VLOpFrag)),
192881ad6265SDimitry Andric              (!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
192981ad6265SDimitry Andric                   vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
193006c3fb27SDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
193181ad6265SDimitry Andric
193281ad6265SDimitry Andric    def : Pat<(vti.Vector (vop (SplatFPOp vti.ScalarRegClass:$rs1),
193381ad6265SDimitry Andric                               vti.RegClass:$rd, vti.RegClass:$rs2,
193481ad6265SDimitry Andric                               (vti.Mask V0),
193581ad6265SDimitry Andric                               VLOpFrag)),
193681ad6265SDimitry Andric              (!cast<Instruction>(instruction_name#"_V" # vti.ScalarSuffix # "_" # suffix # "_MASK")
193781ad6265SDimitry Andric                   vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
193806c3fb27SDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
193906c3fb27SDimitry Andric    }
194006c3fb27SDimitry Andric  }
194106c3fb27SDimitry Andric}
194206c3fb27SDimitry Andric
194306c3fb27SDimitry Andricmulticlass VPatFPMulAddVL_VV_VF_RM<SDPatternOperator vop, string instruction_name> {
194406c3fb27SDimitry Andric  foreach vti = AllFloatVectors in {
1945*0fca6ea1SDimitry Andric  defvar suffix = vti.LMul.MX # "_E" # vti.SEW;
194606c3fb27SDimitry Andric  let Predicates = GetVTypePredicates<vti>.Predicates in {
194706c3fb27SDimitry Andric    def : Pat<(vti.Vector (vop vti.RegClass:$rs1, vti.RegClass:$rd,
194806c3fb27SDimitry Andric                               vti.RegClass:$rs2, (vti.Mask V0),
194906c3fb27SDimitry Andric                               VLOpFrag)),
195006c3fb27SDimitry Andric              (!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
195106c3fb27SDimitry Andric                   vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
195206c3fb27SDimitry Andric                   (vti.Mask V0),
195306c3fb27SDimitry Andric                   // Value to indicate no rounding mode change in
195406c3fb27SDimitry Andric                   // RISCVInsertReadWriteCSR
195506c3fb27SDimitry Andric                   FRM_DYN,
195606c3fb27SDimitry Andric                   GPR:$vl, vti.Log2SEW, TA_MA)>;
195706c3fb27SDimitry Andric
195806c3fb27SDimitry Andric    def : Pat<(vti.Vector (vop (SplatFPOp vti.ScalarRegClass:$rs1),
195906c3fb27SDimitry Andric                               vti.RegClass:$rd, vti.RegClass:$rs2,
196006c3fb27SDimitry Andric                               (vti.Mask V0),
196106c3fb27SDimitry Andric                               VLOpFrag)),
196206c3fb27SDimitry Andric              (!cast<Instruction>(instruction_name#"_V" # vti.ScalarSuffix # "_" # suffix # "_MASK")
196306c3fb27SDimitry Andric                   vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
196406c3fb27SDimitry Andric                   (vti.Mask V0),
196506c3fb27SDimitry Andric                   // Value to indicate no rounding mode change in
196606c3fb27SDimitry Andric                   // RISCVInsertReadWriteCSR
196706c3fb27SDimitry Andric                   FRM_DYN,
196806c3fb27SDimitry Andric                   GPR:$vl, vti.Log2SEW, TA_MA)>;
196906c3fb27SDimitry Andric    }
197081ad6265SDimitry Andric  }
197181ad6265SDimitry Andric}
197281ad6265SDimitry Andric
1973bdd1243dSDimitry Andricmulticlass VPatFPMulAccVL_VV_VF<PatFrag vop, string instruction_name> {
1974bdd1243dSDimitry Andric  foreach vti = AllFloatVectors in {
1975bdd1243dSDimitry Andric  defvar suffix = vti.LMul.MX;
197606c3fb27SDimitry Andric  let Predicates = GetVTypePredicates<vti>.Predicates in {
1977cb14a3feSDimitry Andric    def : Pat<(riscv_vmerge_vl (vti.Mask V0),
1978bdd1243dSDimitry Andric                           (vti.Vector (vop vti.RegClass:$rs1, vti.RegClass:$rs2,
1979bdd1243dSDimitry Andric                            vti.RegClass:$rd, (vti.Mask true_mask), VLOpFrag)),
1980cb14a3feSDimitry Andric                            vti.RegClass:$rd, vti.RegClass:$rd, VLOpFrag),
1981bdd1243dSDimitry Andric              (!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
1982bdd1243dSDimitry Andric                   vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
198306c3fb27SDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TU_MU)>;
1984cb14a3feSDimitry Andric    def : Pat<(riscv_vmerge_vl (vti.Mask V0),
1985bdd1243dSDimitry Andric                           (vti.Vector (vop (SplatFPOp vti.ScalarRegClass:$rs1), vti.RegClass:$rs2,
1986bdd1243dSDimitry Andric                            vti.RegClass:$rd, (vti.Mask true_mask), VLOpFrag)),
1987cb14a3feSDimitry Andric                            vti.RegClass:$rd, vti.RegClass:$rd, VLOpFrag),
1988bdd1243dSDimitry Andric              (!cast<Instruction>(instruction_name#"_V" # vti.ScalarSuffix # "_" # suffix # "_MASK")
1989bdd1243dSDimitry Andric                   vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
199006c3fb27SDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TU_MU)>;
19911db9f3b2SDimitry Andric    def : Pat<(riscv_vmerge_vl (vti.Mask V0),
1992bdd1243dSDimitry Andric                           (vti.Vector (vop vti.RegClass:$rs1, vti.RegClass:$rs2,
1993bdd1243dSDimitry Andric                            vti.RegClass:$rd, (vti.Mask true_mask), VLOpFrag)),
19941db9f3b2SDimitry Andric                            vti.RegClass:$rd, undef, VLOpFrag),
1995bdd1243dSDimitry Andric              (!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
1996bdd1243dSDimitry Andric                   vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
1997bdd1243dSDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
19981db9f3b2SDimitry Andric    def : Pat<(riscv_vmerge_vl (vti.Mask V0),
1999bdd1243dSDimitry Andric                           (vti.Vector (vop (SplatFPOp vti.ScalarRegClass:$rs1), vti.RegClass:$rs2,
2000bdd1243dSDimitry Andric                            vti.RegClass:$rd, (vti.Mask true_mask), VLOpFrag)),
20011db9f3b2SDimitry Andric                            vti.RegClass:$rd, undef, VLOpFrag),
2002bdd1243dSDimitry Andric              (!cast<Instruction>(instruction_name#"_V" # vti.ScalarSuffix # "_" # suffix # "_MASK")
2003bdd1243dSDimitry Andric                   vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
2004bdd1243dSDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
2005bdd1243dSDimitry Andric    }
2006bdd1243dSDimitry Andric  }
200706c3fb27SDimitry Andric}
200806c3fb27SDimitry Andric
200906c3fb27SDimitry Andricmulticlass VPatFPMulAccVL_VV_VF_RM<PatFrag vop, string instruction_name> {
201006c3fb27SDimitry Andric  foreach vti = AllFloatVectors in {
2011*0fca6ea1SDimitry Andric  defvar suffix = vti.LMul.MX # "_E" # vti.SEW;
201206c3fb27SDimitry Andric  let Predicates = GetVTypePredicates<vti>.Predicates in {
2013cb14a3feSDimitry Andric    def : Pat<(riscv_vmerge_vl (vti.Mask V0),
201406c3fb27SDimitry Andric                           (vti.Vector (vop vti.RegClass:$rs1, vti.RegClass:$rs2,
201506c3fb27SDimitry Andric                            vti.RegClass:$rd, (vti.Mask true_mask), VLOpFrag)),
2016cb14a3feSDimitry Andric                            vti.RegClass:$rd, vti.RegClass:$rd, VLOpFrag),
201706c3fb27SDimitry Andric              (!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
201806c3fb27SDimitry Andric                   vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
201906c3fb27SDimitry Andric                   (vti.Mask V0),
202006c3fb27SDimitry Andric                   // Value to indicate no rounding mode change in
202106c3fb27SDimitry Andric                   // RISCVInsertReadWriteCSR
202206c3fb27SDimitry Andric                   FRM_DYN,
202306c3fb27SDimitry Andric                   GPR:$vl, vti.Log2SEW, TU_MU)>;
2024cb14a3feSDimitry Andric    def : Pat<(riscv_vmerge_vl (vti.Mask V0),
202506c3fb27SDimitry Andric                           (vti.Vector (vop (SplatFPOp vti.ScalarRegClass:$rs1), vti.RegClass:$rs2,
202606c3fb27SDimitry Andric                            vti.RegClass:$rd, (vti.Mask true_mask), VLOpFrag)),
2027cb14a3feSDimitry Andric                            vti.RegClass:$rd, vti.RegClass:$rd, VLOpFrag),
202806c3fb27SDimitry Andric              (!cast<Instruction>(instruction_name#"_V" # vti.ScalarSuffix # "_" # suffix # "_MASK")
202906c3fb27SDimitry Andric                   vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
203006c3fb27SDimitry Andric                   (vti.Mask V0),
203106c3fb27SDimitry Andric                   // Value to indicate no rounding mode change in
203206c3fb27SDimitry Andric                   // RISCVInsertReadWriteCSR
203306c3fb27SDimitry Andric                   FRM_DYN,
203406c3fb27SDimitry Andric                   GPR:$vl, vti.Log2SEW, TU_MU)>;
20351db9f3b2SDimitry Andric    def : Pat<(riscv_vmerge_vl (vti.Mask V0),
203606c3fb27SDimitry Andric                           (vti.Vector (vop vti.RegClass:$rs1, vti.RegClass:$rs2,
203706c3fb27SDimitry Andric                            vti.RegClass:$rd, (vti.Mask true_mask), VLOpFrag)),
20381db9f3b2SDimitry Andric                            vti.RegClass:$rd, undef, VLOpFrag),
203906c3fb27SDimitry Andric              (!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
204006c3fb27SDimitry Andric                   vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
204106c3fb27SDimitry Andric                   (vti.Mask V0),
204206c3fb27SDimitry Andric                   // Value to indicate no rounding mode change in
204306c3fb27SDimitry Andric                   // RISCVInsertReadWriteCSR
204406c3fb27SDimitry Andric                   FRM_DYN,
204506c3fb27SDimitry Andric                   GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
20461db9f3b2SDimitry Andric    def : Pat<(riscv_vmerge_vl (vti.Mask V0),
204706c3fb27SDimitry Andric                           (vti.Vector (vop (SplatFPOp vti.ScalarRegClass:$rs1), vti.RegClass:$rs2,
204806c3fb27SDimitry Andric                            vti.RegClass:$rd, (vti.Mask true_mask), VLOpFrag)),
20491db9f3b2SDimitry Andric                            vti.RegClass:$rd, undef, VLOpFrag),
205006c3fb27SDimitry Andric              (!cast<Instruction>(instruction_name#"_V" # vti.ScalarSuffix # "_" # suffix # "_MASK")
205106c3fb27SDimitry Andric                   vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
205206c3fb27SDimitry Andric                   (vti.Mask V0),
205306c3fb27SDimitry Andric                   // Value to indicate no rounding mode change in
205406c3fb27SDimitry Andric                   // RISCVInsertReadWriteCSR
205506c3fb27SDimitry Andric                   FRM_DYN,
205606c3fb27SDimitry Andric                   GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
205706c3fb27SDimitry Andric    }
205806c3fb27SDimitry Andric  }
205906c3fb27SDimitry Andric}
2060bdd1243dSDimitry Andric
206181ad6265SDimitry Andricmulticlass VPatWidenFPMulAccVL_VV_VF<SDNode vop, string instruction_name> {
206281ad6265SDimitry Andric  foreach vtiToWti = AllWidenableFloatVectors in {
206381ad6265SDimitry Andric    defvar vti = vtiToWti.Vti;
206481ad6265SDimitry Andric    defvar wti = vtiToWti.Wti;
206506c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
206606c3fb27SDimitry Andric                                 GetVTypePredicates<wti>.Predicates) in {
206706c3fb27SDimitry Andric      def : Pat<(vop (vti.Vector vti.RegClass:$rs1),
206881ad6265SDimitry Andric                     (vti.Vector vti.RegClass:$rs2),
206906c3fb27SDimitry Andric                     (wti.Vector wti.RegClass:$rd), (vti.Mask V0),
207081ad6265SDimitry Andric                     VLOpFrag),
207106c3fb27SDimitry Andric                (!cast<Instruction>(instruction_name#"_VV_"#vti.LMul.MX #"_MASK")
207281ad6265SDimitry Andric                   wti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
207306c3fb27SDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
207406c3fb27SDimitry Andric      def : Pat<(vop (vti.Vector (SplatFPOp vti.ScalarRegClass:$rs1)),
207581ad6265SDimitry Andric                     (vti.Vector vti.RegClass:$rs2),
207606c3fb27SDimitry Andric                     (wti.Vector wti.RegClass:$rd), (vti.Mask V0),
207781ad6265SDimitry Andric                     VLOpFrag),
207806c3fb27SDimitry Andric                (!cast<Instruction>(instruction_name#"_V"#vti.ScalarSuffix#"_"#vti.LMul.MX #"_MASK")
207981ad6265SDimitry Andric                   wti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
208006c3fb27SDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
208106c3fb27SDimitry Andric    }
208206c3fb27SDimitry Andric  }
208306c3fb27SDimitry Andric}
208406c3fb27SDimitry Andric
208506c3fb27SDimitry Andricmulticlass VPatWidenFPMulAccVL_VV_VF_RM<SDNode vop, string instruction_name> {
208606c3fb27SDimitry Andric  foreach vtiToWti = AllWidenableFloatVectors in {
208706c3fb27SDimitry Andric    defvar vti = vtiToWti.Vti;
208806c3fb27SDimitry Andric    defvar wti = vtiToWti.Wti;
2089*0fca6ea1SDimitry Andric    defvar suffix = vti.LMul.MX # "_E" # vti.SEW;
209006c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
209106c3fb27SDimitry Andric                                 GetVTypePredicates<wti>.Predicates) in {
209206c3fb27SDimitry Andric      def : Pat<(vop (vti.Vector vti.RegClass:$rs1),
209306c3fb27SDimitry Andric                     (vti.Vector vti.RegClass:$rs2),
209406c3fb27SDimitry Andric                     (wti.Vector wti.RegClass:$rd), (vti.Mask V0),
209506c3fb27SDimitry Andric                     VLOpFrag),
2096*0fca6ea1SDimitry Andric                (!cast<Instruction>(instruction_name#"_VV_"#suffix#"_MASK")
209706c3fb27SDimitry Andric                   wti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
209806c3fb27SDimitry Andric                   (vti.Mask V0),
209906c3fb27SDimitry Andric                   // Value to indicate no rounding mode change in
210006c3fb27SDimitry Andric                   // RISCVInsertReadWriteCSR
210106c3fb27SDimitry Andric                   FRM_DYN,
210206c3fb27SDimitry Andric                   GPR:$vl, vti.Log2SEW, TA_MA)>;
210306c3fb27SDimitry Andric      def : Pat<(vop (vti.Vector (SplatFPOp vti.ScalarRegClass:$rs1)),
210406c3fb27SDimitry Andric                     (vti.Vector vti.RegClass:$rs2),
210506c3fb27SDimitry Andric                     (wti.Vector wti.RegClass:$rd), (vti.Mask V0),
210606c3fb27SDimitry Andric                     VLOpFrag),
2107*0fca6ea1SDimitry Andric                (!cast<Instruction>(instruction_name#"_V"#vti.ScalarSuffix#"_"#suffix#"_MASK")
210806c3fb27SDimitry Andric                   wti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
210906c3fb27SDimitry Andric                   (vti.Mask V0),
211006c3fb27SDimitry Andric                   // Value to indicate no rounding mode change in
211106c3fb27SDimitry Andric                   // RISCVInsertReadWriteCSR
211206c3fb27SDimitry Andric                   FRM_DYN,
211306c3fb27SDimitry Andric                   GPR:$vl, vti.Log2SEW, TA_MA)>;
211406c3fb27SDimitry Andric    }
211581ad6265SDimitry Andric  }
211604eeddc0SDimitry Andric}
211704eeddc0SDimitry Andric
21185f757f3fSDimitry Andricmulticlass VPatSlideVL_VX_VI<SDNode vop, string instruction_name> {
21195f757f3fSDimitry Andric  foreach vti = AllVectors in {
2120*0fca6ea1SDimitry Andric    defvar ivti = GetIntVTypeInfo<vti>.Vti;
2121*0fca6ea1SDimitry Andric    let Predicates = GetVTypePredicates<ivti>.Predicates in {
21225f757f3fSDimitry Andric      def : Pat<(vti.Vector (vop (vti.Vector vti.RegClass:$rd),
21235f757f3fSDimitry Andric                                 (vti.Vector vti.RegClass:$rs1),
21245f757f3fSDimitry Andric                                 uimm5:$rs2, (vti.Mask V0),
21255f757f3fSDimitry Andric                                 VLOpFrag, (XLenVT timm:$policy))),
21265f757f3fSDimitry Andric                (!cast<Instruction>(instruction_name#"_VI_"#vti.LMul.MX#"_MASK")
21275f757f3fSDimitry Andric                    vti.RegClass:$rd, vti.RegClass:$rs1, uimm5:$rs2,
21285f757f3fSDimitry Andric                    (vti.Mask V0), GPR:$vl, vti.Log2SEW,
21295f757f3fSDimitry Andric                    (XLenVT timm:$policy))>;
21305f757f3fSDimitry Andric
21315f757f3fSDimitry Andric      def : Pat<(vti.Vector (vop (vti.Vector vti.RegClass:$rd),
21325f757f3fSDimitry Andric                                 (vti.Vector vti.RegClass:$rs1),
21335f757f3fSDimitry Andric                                 GPR:$rs2, (vti.Mask V0),
21345f757f3fSDimitry Andric                                 VLOpFrag, (XLenVT timm:$policy))),
21355f757f3fSDimitry Andric                (!cast<Instruction>(instruction_name#"_VX_"#vti.LMul.MX#"_MASK")
21365f757f3fSDimitry Andric                    vti.RegClass:$rd, vti.RegClass:$rs1, GPR:$rs2,
21375f757f3fSDimitry Andric                    (vti.Mask V0), GPR:$vl, vti.Log2SEW,
21385f757f3fSDimitry Andric                    (XLenVT timm:$policy))>;
21395f757f3fSDimitry Andric    }
21405f757f3fSDimitry Andric  }
21415f757f3fSDimitry Andric}
21425f757f3fSDimitry Andric
21435f757f3fSDimitry Andricmulticlass VPatSlide1VL_VX<SDNode vop, string instruction_name> {
21445f757f3fSDimitry Andric  foreach vti = AllIntegerVectors in {
21455f757f3fSDimitry Andric    let Predicates = GetVTypePredicates<vti>.Predicates in {
21465f757f3fSDimitry Andric      def : Pat<(vti.Vector (vop (vti.Vector vti.RegClass:$rs3),
21475f757f3fSDimitry Andric                                 (vti.Vector vti.RegClass:$rs1),
21485f757f3fSDimitry Andric                                 GPR:$rs2, (vti.Mask V0), VLOpFrag)),
21495f757f3fSDimitry Andric                (!cast<Instruction>(instruction_name#"_VX_"#vti.LMul.MX#"_MASK")
21505f757f3fSDimitry Andric                    vti.RegClass:$rs3, vti.RegClass:$rs1, GPR:$rs2,
21515f757f3fSDimitry Andric                    (vti.Mask V0), GPR:$vl, vti.Log2SEW, TU_MU)>;
21525f757f3fSDimitry Andric    }
21535f757f3fSDimitry Andric  }
21545f757f3fSDimitry Andric}
21555f757f3fSDimitry Andric
21565f757f3fSDimitry Andricmulticlass VPatSlide1VL_VF<SDNode vop, string instruction_name> {
21575f757f3fSDimitry Andric  foreach vti = AllFloatVectors in {
21585f757f3fSDimitry Andric    let Predicates = GetVTypePredicates<vti>.Predicates in {
21595f757f3fSDimitry Andric      def : Pat<(vti.Vector (vop (vti.Vector vti.RegClass:$rs3),
21605f757f3fSDimitry Andric                                 (vti.Vector vti.RegClass:$rs1),
21615f757f3fSDimitry Andric                                 vti.Scalar:$rs2, (vti.Mask V0), VLOpFrag)),
21625f757f3fSDimitry Andric                (!cast<Instruction>(instruction_name#"_V"#vti.ScalarSuffix#"_"#vti.LMul.MX#"_MASK")
21635f757f3fSDimitry Andric                    vti.RegClass:$rs3, vti.RegClass:$rs1, vti.Scalar:$rs2,
21645f757f3fSDimitry Andric                    (vti.Mask V0), GPR:$vl, vti.Log2SEW, TU_MU)>;
21655f757f3fSDimitry Andric    }
21665f757f3fSDimitry Andric  }
21675f757f3fSDimitry Andric}
21685f757f3fSDimitry Andric
2169*0fca6ea1SDimitry Andricmulticlass VPatAVGADDVL_VV_VX_RM<SDNode vop, int vxrm, string suffix = ""> {
2170297eecfbSDimitry Andric  foreach vti = AllIntegerVectors in {
2171297eecfbSDimitry Andric    let Predicates = GetVTypePredicates<vti>.Predicates in {
2172297eecfbSDimitry Andric      def : Pat<(vop (vti.Vector vti.RegClass:$rs1),
2173297eecfbSDimitry Andric                     (vti.Vector vti.RegClass:$rs2),
2174297eecfbSDimitry Andric                     vti.RegClass:$merge, (vti.Mask V0), VLOpFrag),
2175*0fca6ea1SDimitry Andric                (!cast<Instruction>("PseudoVAADD"#suffix#"_VV_"#vti.LMul.MX#"_MASK")
2176297eecfbSDimitry Andric                  vti.RegClass:$merge, vti.RegClass:$rs1, vti.RegClass:$rs2,
2177297eecfbSDimitry Andric                  (vti.Mask V0), vxrm, GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
2178297eecfbSDimitry Andric      def : Pat<(vop (vti.Vector vti.RegClass:$rs1),
2179297eecfbSDimitry Andric                     (vti.Vector (SplatPat (XLenVT GPR:$rs2))),
2180297eecfbSDimitry Andric                     vti.RegClass:$merge, (vti.Mask V0), VLOpFrag),
2181*0fca6ea1SDimitry Andric                (!cast<Instruction>("PseudoVAADD"#suffix#"_VX_"#vti.LMul.MX#"_MASK")
2182297eecfbSDimitry Andric                  vti.RegClass:$merge, vti.RegClass:$rs1, GPR:$rs2,
2183297eecfbSDimitry Andric                  (vti.Mask V0), vxrm, GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
2184297eecfbSDimitry Andric    }
2185297eecfbSDimitry Andric  }
2186297eecfbSDimitry Andric}
2187297eecfbSDimitry Andric
2188fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
2189fe6060f1SDimitry Andric// Patterns.
2190fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
2191fe6060f1SDimitry Andric
2192bdd1243dSDimitry Andric// 11. Vector Integer Arithmetic Instructions
2193bdd1243dSDimitry Andric
2194bdd1243dSDimitry Andric// 11.1. Vector Single-Width Integer Add and Subtract
2195fe6060f1SDimitry Andricdefm : VPatBinaryVL_VV_VX_VI<riscv_add_vl, "PseudoVADD">;
2196fe6060f1SDimitry Andricdefm : VPatBinaryVL_VV_VX<riscv_sub_vl, "PseudoVSUB">;
2197fe6060f1SDimitry Andric// Handle VRSUB specially since it's the only integer binary op with reversed
2198fe6060f1SDimitry Andric// pattern operands
2199fe6060f1SDimitry Andricforeach vti = AllIntegerVectors in {
220006c3fb27SDimitry Andric  let Predicates = GetVTypePredicates<vti>.Predicates in {
2201fe6060f1SDimitry Andric    def : Pat<(riscv_sub_vl (vti.Vector (SplatPat (XLenVT GPR:$rs2))),
2202bdd1243dSDimitry Andric                            (vti.Vector vti.RegClass:$rs1),
2203bdd1243dSDimitry Andric                            vti.RegClass:$merge, (vti.Mask V0), VLOpFrag),
2204fe6060f1SDimitry Andric              (!cast<Instruction>("PseudoVRSUB_VX_"# vti.LMul.MX#"_MASK")
2205bdd1243dSDimitry Andric                   vti.RegClass:$merge, vti.RegClass:$rs1, GPR:$rs2,
2206349cc55cSDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
2207fe6060f1SDimitry Andric    def : Pat<(riscv_sub_vl (vti.Vector (SplatPat_simm5 simm5:$rs2)),
2208bdd1243dSDimitry Andric                            (vti.Vector vti.RegClass:$rs1),
2209bdd1243dSDimitry Andric                            vti.RegClass:$merge, (vti.Mask V0), VLOpFrag),
2210fe6060f1SDimitry Andric              (!cast<Instruction>("PseudoVRSUB_VI_"# vti.LMul.MX#"_MASK")
2211bdd1243dSDimitry Andric                   vti.RegClass:$merge, vti.RegClass:$rs1, simm5:$rs2,
2212349cc55cSDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
2213fe6060f1SDimitry Andric  }
221406c3fb27SDimitry Andric}
2215fe6060f1SDimitry Andric
2216bdd1243dSDimitry Andric// 11.2. Vector Widening Integer Add/Subtract
221781ad6265SDimitry Andricdefm : VPatBinaryWVL_VV_VX_WV_WX<riscv_vwadd_vl,  riscv_vwadd_w_vl,  "PseudoVWADD">;
221881ad6265SDimitry Andricdefm : VPatBinaryWVL_VV_VX_WV_WX<riscv_vwaddu_vl, riscv_vwaddu_w_vl, "PseudoVWADDU">;
221981ad6265SDimitry Andricdefm : VPatBinaryWVL_VV_VX_WV_WX<riscv_vwsub_vl,  riscv_vwsub_w_vl,  "PseudoVWSUB">;
222081ad6265SDimitry Andricdefm : VPatBinaryWVL_VV_VX_WV_WX<riscv_vwsubu_vl, riscv_vwsubu_w_vl, "PseudoVWSUBU">;
222104eeddc0SDimitry Andric
222206c3fb27SDimitry Andric// shl_vl (ext_vl v, splat 1) is a special case of widening add.
222306c3fb27SDimitry Andricforeach vtiToWti = AllWidenableIntVectors in {
222406c3fb27SDimitry Andric  defvar vti = vtiToWti.Vti;
222506c3fb27SDimitry Andric  defvar wti = vtiToWti.Wti;
222606c3fb27SDimitry Andric  let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
222706c3fb27SDimitry Andric                               GetVTypePredicates<wti>.Predicates) in {
222806c3fb27SDimitry Andric    def : Pat<(riscv_shl_vl (wti.Vector (riscv_sext_vl_oneuse
222906c3fb27SDimitry Andric                              (vti.Vector vti.RegClass:$rs1),
223006c3fb27SDimitry Andric                              (vti.Mask V0), VLOpFrag)),
223106c3fb27SDimitry Andric                            (wti.Vector (riscv_vmv_v_x_vl
223206c3fb27SDimitry Andric                              (wti.Vector undef), 1, VLOpFrag)),
223306c3fb27SDimitry Andric                              wti.RegClass:$merge, (vti.Mask V0), VLOpFrag),
223406c3fb27SDimitry Andric              (!cast<Instruction>("PseudoVWADD_VV_"#vti.LMul.MX#"_MASK")
223506c3fb27SDimitry Andric               wti.RegClass:$merge, vti.RegClass:$rs1, vti.RegClass:$rs1,
223606c3fb27SDimitry Andric               (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
223706c3fb27SDimitry Andric    def : Pat<(riscv_shl_vl (wti.Vector (riscv_zext_vl_oneuse
223806c3fb27SDimitry Andric                              (vti.Vector vti.RegClass:$rs1),
223906c3fb27SDimitry Andric                              (vti.Mask V0), VLOpFrag)),
224006c3fb27SDimitry Andric                            (wti.Vector (riscv_vmv_v_x_vl
224106c3fb27SDimitry Andric                              (wti.Vector undef), 1, VLOpFrag)),
224206c3fb27SDimitry Andric                              wti.RegClass:$merge, (vti.Mask V0), VLOpFrag),
224306c3fb27SDimitry Andric              (!cast<Instruction>("PseudoVWADDU_VV_"#vti.LMul.MX#"_MASK")
224406c3fb27SDimitry Andric               wti.RegClass:$merge, vti.RegClass:$rs1, vti.RegClass:$rs1,
224506c3fb27SDimitry Andric               (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
224606c3fb27SDimitry Andric  }
224706c3fb27SDimitry Andric}
224806c3fb27SDimitry Andric
2249bdd1243dSDimitry Andric// 11.3. Vector Integer Extension
2250bdd1243dSDimitry Andricdefm : VPatExtendVL_V<riscv_zext_vl, "PseudoVZEXT", "VF2",
2251fe6060f1SDimitry Andric                      AllFractionableVF2IntVectors>;
2252bdd1243dSDimitry Andricdefm : VPatExtendVL_V<riscv_sext_vl, "PseudoVSEXT", "VF2",
2253fe6060f1SDimitry Andric                      AllFractionableVF2IntVectors>;
2254bdd1243dSDimitry Andricdefm : VPatExtendVL_V<riscv_zext_vl, "PseudoVZEXT", "VF4",
2255fe6060f1SDimitry Andric                      AllFractionableVF4IntVectors>;
2256bdd1243dSDimitry Andricdefm : VPatExtendVL_V<riscv_sext_vl, "PseudoVSEXT", "VF4",
2257fe6060f1SDimitry Andric                      AllFractionableVF4IntVectors>;
2258bdd1243dSDimitry Andricdefm : VPatExtendVL_V<riscv_zext_vl, "PseudoVZEXT", "VF8",
2259fe6060f1SDimitry Andric                      AllFractionableVF8IntVectors>;
2260bdd1243dSDimitry Andricdefm : VPatExtendVL_V<riscv_sext_vl, "PseudoVSEXT", "VF8",
2261fe6060f1SDimitry Andric                      AllFractionableVF8IntVectors>;
2262fe6060f1SDimitry Andric
2263bdd1243dSDimitry Andric// 11.5. Vector Bitwise Logical Instructions
2264fe6060f1SDimitry Andricdefm : VPatBinaryVL_VV_VX_VI<riscv_and_vl, "PseudoVAND">;
2265fe6060f1SDimitry Andricdefm : VPatBinaryVL_VV_VX_VI<riscv_or_vl,  "PseudoVOR">;
2266fe6060f1SDimitry Andricdefm : VPatBinaryVL_VV_VX_VI<riscv_xor_vl, "PseudoVXOR">;
2267fe6060f1SDimitry Andric
2268bdd1243dSDimitry Andric// 11.6. Vector Single-Width Bit Shift Instructions
2269fe6060f1SDimitry Andricdefm : VPatBinaryVL_VV_VX_VI<riscv_shl_vl, "PseudoVSLL", uimm5>;
2270fe6060f1SDimitry Andricdefm : VPatBinaryVL_VV_VX_VI<riscv_srl_vl, "PseudoVSRL", uimm5>;
2271fe6060f1SDimitry Andricdefm : VPatBinaryVL_VV_VX_VI<riscv_sra_vl, "PseudoVSRA", uimm5>;
2272fe6060f1SDimitry Andric
2273fe6060f1SDimitry Andricforeach vti = AllIntegerVectors in {
2274fe6060f1SDimitry Andric  // Emit shift by 1 as an add since it might be faster.
227506c3fb27SDimitry Andric  let Predicates = GetVTypePredicates<vti>.Predicates in
2276fe6060f1SDimitry Andric  def : Pat<(riscv_shl_vl (vti.Vector vti.RegClass:$rs1),
227781ad6265SDimitry Andric                          (riscv_vmv_v_x_vl (vti.Vector undef), 1, (XLenVT srcvalue)),
2278bdd1243dSDimitry Andric                          srcvalue, (vti.Mask true_mask), VLOpFrag),
2279fe6060f1SDimitry Andric            (!cast<Instruction>("PseudoVADD_VV_"# vti.LMul.MX)
228006c3fb27SDimitry Andric                 (vti.Vector (IMPLICIT_DEF)),
22815f757f3fSDimitry Andric                 vti.RegClass:$rs1, vti.RegClass:$rs1, GPR:$vl, vti.Log2SEW, TA_MA)>;
2282fe6060f1SDimitry Andric}
2283fe6060f1SDimitry Andric
2284bdd1243dSDimitry Andric// 11.7. Vector Narrowing Integer Right Shift Instructions
2285bdd1243dSDimitry Andricdefm : VPatBinaryVL_WV_WX_WI<srl, "PseudoVNSRL">;
2286bdd1243dSDimitry Andricdefm : VPatBinaryVL_WV_WX_WI<sra, "PseudoVNSRA">;
228781ad6265SDimitry Andric
228881ad6265SDimitry Andricdefm : VPatNarrowShiftSplat_WX_WI<riscv_sra_vl, "PseudoVNSRA">;
228981ad6265SDimitry Andricdefm : VPatNarrowShiftSplat_WX_WI<riscv_srl_vl, "PseudoVNSRL">;
229081ad6265SDimitry Andricdefm : VPatNarrowShiftSplatExt_WX<riscv_sra_vl, riscv_sext_vl_oneuse, "PseudoVNSRA">;
229181ad6265SDimitry Andricdefm : VPatNarrowShiftSplatExt_WX<riscv_sra_vl, riscv_zext_vl_oneuse, "PseudoVNSRA">;
229281ad6265SDimitry Andricdefm : VPatNarrowShiftSplatExt_WX<riscv_srl_vl, riscv_sext_vl_oneuse, "PseudoVNSRL">;
229381ad6265SDimitry Andricdefm : VPatNarrowShiftSplatExt_WX<riscv_srl_vl, riscv_zext_vl_oneuse, "PseudoVNSRL">;
229404eeddc0SDimitry Andric
229506c3fb27SDimitry Andricdefm : VPatNarrowShiftVL_WV<riscv_srl_vl, "PseudoVNSRL">;
229606c3fb27SDimitry Andricdefm : VPatNarrowShiftVL_WV<riscv_sra_vl, "PseudoVNSRA">;
229706c3fb27SDimitry Andric
2298bdd1243dSDimitry Andricdefm : VPatBinaryNVL_WV_WX_WI<riscv_vnsrl_vl, "PseudoVNSRL">;
2299bdd1243dSDimitry Andric
2300fe6060f1SDimitry Andricforeach vtiTowti = AllWidenableIntVectors in {
2301fe6060f1SDimitry Andric  defvar vti = vtiTowti.Vti;
2302fe6060f1SDimitry Andric  defvar wti = vtiTowti.Wti;
230306c3fb27SDimitry Andric  let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
230406c3fb27SDimitry Andric                               GetVTypePredicates<wti>.Predicates) in
2305fe6060f1SDimitry Andric  def : Pat<(vti.Vector (riscv_trunc_vector_vl (wti.Vector wti.RegClass:$rs1),
230681ad6265SDimitry Andric                                               (vti.Mask V0),
2307fe6060f1SDimitry Andric                                               VLOpFrag)),
2308bdd1243dSDimitry Andric            (!cast<Instruction>("PseudoVNSRL_WI_"#vti.LMul.MX#"_MASK")
2309bdd1243dSDimitry Andric                (vti.Vector (IMPLICIT_DEF)), wti.RegClass:$rs1, 0,
2310bdd1243dSDimitry Andric                (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
2311fe6060f1SDimitry Andric}
2312fe6060f1SDimitry Andric
2313bdd1243dSDimitry Andric// 11.8. Vector Integer Comparison Instructions
2314fe6060f1SDimitry Andricforeach vti = AllIntegerVectors in {
231506c3fb27SDimitry Andric  let Predicates = GetVTypePredicates<vti>.Predicates in {
2316fe6060f1SDimitry Andric    defm : VPatIntegerSetCCVL_VV<vti, "PseudoVMSEQ", SETEQ>;
2317fe6060f1SDimitry Andric    defm : VPatIntegerSetCCVL_VV<vti, "PseudoVMSNE", SETNE>;
2318fe6060f1SDimitry Andric
2319fe6060f1SDimitry Andric    defm : VPatIntegerSetCCVL_VV_Swappable<vti, "PseudoVMSLT",  SETLT,  SETGT>;
2320fe6060f1SDimitry Andric    defm : VPatIntegerSetCCVL_VV_Swappable<vti, "PseudoVMSLTU", SETULT, SETUGT>;
2321fe6060f1SDimitry Andric    defm : VPatIntegerSetCCVL_VV_Swappable<vti, "PseudoVMSLE",  SETLE,  SETGE>;
2322fe6060f1SDimitry Andric    defm : VPatIntegerSetCCVL_VV_Swappable<vti, "PseudoVMSLEU", SETULE, SETUGE>;
2323fe6060f1SDimitry Andric
2324fe6060f1SDimitry Andric    defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSEQ",  SETEQ,  SETEQ>;
2325fe6060f1SDimitry Andric    defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSNE",  SETNE,  SETNE>;
2326fe6060f1SDimitry Andric    defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSLT",  SETLT,  SETGT>;
2327fe6060f1SDimitry Andric    defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSLTU", SETULT, SETUGT>;
2328fe6060f1SDimitry Andric    defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSLE",  SETLE,  SETGE>;
2329fe6060f1SDimitry Andric    defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSLEU", SETULE, SETUGE>;
2330fe6060f1SDimitry Andric    defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSGT",  SETGT,  SETLT>;
2331fe6060f1SDimitry Andric    defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSGTU", SETUGT, SETULT>;
2332fe6060f1SDimitry Andric    // There is no VMSGE(U)_VX instruction
2333fe6060f1SDimitry Andric
2334fe6060f1SDimitry Andric    defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSEQ",  SETEQ,  SETEQ>;
2335fe6060f1SDimitry Andric    defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSNE",  SETNE,  SETNE>;
2336fe6060f1SDimitry Andric    defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSLE",  SETLE,  SETGE>;
2337fe6060f1SDimitry Andric    defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSLEU", SETULE, SETUGE>;
233804eeddc0SDimitry Andric    defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSGT",  SETGT,  SETLT>;
233904eeddc0SDimitry Andric    defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSGTU", SETUGT, SETULT>;
2340fe6060f1SDimitry Andric
234181ad6265SDimitry Andric    defm : VPatIntegerSetCCVL_VIPlus1_Swappable<vti, "PseudoVMSLE",  SETLT, SETGT,
234206c3fb27SDimitry Andric                                                SplatPat_simm5_plus1>;
234381ad6265SDimitry Andric    defm : VPatIntegerSetCCVL_VIPlus1_Swappable<vti, "PseudoVMSLEU", SETULT, SETUGT,
2344fe6060f1SDimitry Andric                                                SplatPat_simm5_plus1_nonzero>;
234581ad6265SDimitry Andric    defm : VPatIntegerSetCCVL_VIPlus1_Swappable<vti, "PseudoVMSGT",  SETGE, SETLE,
2346fe6060f1SDimitry Andric                                                SplatPat_simm5_plus1>;
234781ad6265SDimitry Andric    defm : VPatIntegerSetCCVL_VIPlus1_Swappable<vti, "PseudoVMSGTU", SETUGE, SETULE,
2348fe6060f1SDimitry Andric                                                SplatPat_simm5_plus1_nonzero>;
234906c3fb27SDimitry Andric  }
2350fe6060f1SDimitry Andric} // foreach vti = AllIntegerVectors
2351fe6060f1SDimitry Andric
2352bdd1243dSDimitry Andric// 11.9. Vector Integer Min/Max Instructions
2353fe6060f1SDimitry Andricdefm : VPatBinaryVL_VV_VX<riscv_umin_vl, "PseudoVMINU">;
2354fe6060f1SDimitry Andricdefm : VPatBinaryVL_VV_VX<riscv_smin_vl, "PseudoVMIN">;
2355fe6060f1SDimitry Andricdefm : VPatBinaryVL_VV_VX<riscv_umax_vl, "PseudoVMAXU">;
2356fe6060f1SDimitry Andricdefm : VPatBinaryVL_VV_VX<riscv_smax_vl, "PseudoVMAX">;
2357fe6060f1SDimitry Andric
2358bdd1243dSDimitry Andric// 11.10. Vector Single-Width Integer Multiply Instructions
2359fe6060f1SDimitry Andricdefm : VPatBinaryVL_VV_VX<riscv_mul_vl, "PseudoVMUL">;
236006c3fb27SDimitry Andricdefm : VPatBinaryVL_VV_VX<riscv_mulhs_vl, "PseudoVMULH", IntegerVectorsExceptI64>;
236106c3fb27SDimitry Andricdefm : VPatBinaryVL_VV_VX<riscv_mulhu_vl, "PseudoVMULHU", IntegerVectorsExceptI64>;
236206c3fb27SDimitry Andric// vsmul.vv and vsmul.vx are not included in EEW=64 in Zve64*.
236306c3fb27SDimitry Andriclet Predicates = [HasVInstructionsFullMultiply] in {
236406c3fb27SDimitry Andric  defm : VPatBinaryVL_VV_VX<riscv_mulhs_vl, "PseudoVMULH", I64IntegerVectors>;
236506c3fb27SDimitry Andric  defm : VPatBinaryVL_VV_VX<riscv_mulhu_vl, "PseudoVMULHU", I64IntegerVectors>;
236606c3fb27SDimitry Andric}
2367fe6060f1SDimitry Andric
2368bdd1243dSDimitry Andric// 11.11. Vector Integer Divide Instructions
236906c3fb27SDimitry Andricdefm : VPatBinaryVL_VV_VX<riscv_udiv_vl, "PseudoVDIVU", isSEWAware=1>;
237006c3fb27SDimitry Andricdefm : VPatBinaryVL_VV_VX<riscv_sdiv_vl, "PseudoVDIV", isSEWAware=1>;
237106c3fb27SDimitry Andricdefm : VPatBinaryVL_VV_VX<riscv_urem_vl, "PseudoVREMU", isSEWAware=1>;
237206c3fb27SDimitry Andricdefm : VPatBinaryVL_VV_VX<riscv_srem_vl, "PseudoVREM", isSEWAware=1>;
2373fe6060f1SDimitry Andric
2374bdd1243dSDimitry Andric// 11.12. Vector Widening Integer Multiply Instructions
2375fe6060f1SDimitry Andricdefm : VPatBinaryWVL_VV_VX<riscv_vwmul_vl, "PseudoVWMUL">;
2376fe6060f1SDimitry Andricdefm : VPatBinaryWVL_VV_VX<riscv_vwmulu_vl, "PseudoVWMULU">;
23771fd87a68SDimitry Andricdefm : VPatBinaryWVL_VV_VX<riscv_vwmulsu_vl, "PseudoVWMULSU">;
2378fe6060f1SDimitry Andric
2379bdd1243dSDimitry Andric// 11.13 Vector Single-Width Integer Multiply-Add Instructions
238081ad6265SDimitry Andricdefm : VPatMultiplyAddVL_VV_VX<riscv_add_vl, "PseudoVMADD">;
238181ad6265SDimitry Andricdefm : VPatMultiplyAddVL_VV_VX<riscv_sub_vl, "PseudoVNMSUB">;
2382bdd1243dSDimitry Andricdefm : VPatMultiplyAccVL_VV_VX<riscv_add_vl_oneuse, "PseudoVMACC">;
2383bdd1243dSDimitry Andricdefm : VPatMultiplyAccVL_VV_VX<riscv_sub_vl_oneuse, "PseudoVNMSAC">;
2384fe6060f1SDimitry Andric
2385bdd1243dSDimitry Andric// 11.14. Vector Widening Integer Multiply-Add Instructions
238606c3fb27SDimitry Andricdefm : VPatWidenMultiplyAddVL_VV_VX<riscv_vwmacc_vl, "PseudoVWMACC">;
238706c3fb27SDimitry Andricdefm : VPatWidenMultiplyAddVL_VV_VX<riscv_vwmaccu_vl, "PseudoVWMACCU">;
238806c3fb27SDimitry Andricdefm : VPatWidenMultiplyAddVL_VV_VX<riscv_vwmaccsu_vl, "PseudoVWMACCSU">;
2389fe6060f1SDimitry Andricforeach vtiTowti = AllWidenableIntVectors in {
2390fe6060f1SDimitry Andric  defvar vti = vtiTowti.Vti;
2391fe6060f1SDimitry Andric  defvar wti = vtiTowti.Wti;
239206c3fb27SDimitry Andric  let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
239306c3fb27SDimitry Andric                               GetVTypePredicates<wti>.Predicates) in
239406c3fb27SDimitry Andric  def : Pat<(riscv_vwmaccsu_vl (vti.Vector vti.RegClass:$rs1),
239581ad6265SDimitry Andric                               (SplatPat XLenVT:$rs2),
239606c3fb27SDimitry Andric                               (wti.Vector wti.RegClass:$rd),
239706c3fb27SDimitry Andric                               (vti.Mask V0), VLOpFrag),
239806c3fb27SDimitry Andric            (!cast<Instruction>("PseudoVWMACCUS_VX_"#vti.LMul.MX#"_MASK")
239981ad6265SDimitry Andric                wti.RegClass:$rd, vti.ScalarRegClass:$rs2, vti.RegClass:$rs1,
240006c3fb27SDimitry Andric                (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
2401fe6060f1SDimitry Andric}
2402fe6060f1SDimitry Andric
2403bdd1243dSDimitry Andric// 11.15. Vector Integer Merge Instructions
2404fe6060f1SDimitry Andricforeach vti = AllIntegerVectors in {
240506c3fb27SDimitry Andric  let Predicates = GetVTypePredicates<vti>.Predicates in {
2406cb14a3feSDimitry Andric    def : Pat<(vti.Vector (riscv_vmerge_vl (vti.Mask V0),
240704eeddc0SDimitry Andric                                           vti.RegClass:$rs1,
240804eeddc0SDimitry Andric                                           vti.RegClass:$rs2,
2409cb14a3feSDimitry Andric                                           vti.RegClass:$merge,
241004eeddc0SDimitry Andric                                           VLOpFrag)),
241106c3fb27SDimitry Andric              (!cast<Instruction>("PseudoVMERGE_VVM_"#vti.LMul.MX)
2412cb14a3feSDimitry Andric                  vti.RegClass:$merge, vti.RegClass:$rs2, vti.RegClass:$rs1,
241304eeddc0SDimitry Andric                  (vti.Mask V0), GPR:$vl, vti.Log2SEW)>;
241404eeddc0SDimitry Andric
2415cb14a3feSDimitry Andric    def : Pat<(vti.Vector (riscv_vmerge_vl (vti.Mask V0),
241604eeddc0SDimitry Andric                                            (SplatPat XLenVT:$rs1),
241704eeddc0SDimitry Andric                                            vti.RegClass:$rs2,
2418cb14a3feSDimitry Andric                                            vti.RegClass:$merge,
241904eeddc0SDimitry Andric                                            VLOpFrag)),
242006c3fb27SDimitry Andric              (!cast<Instruction>("PseudoVMERGE_VXM_"#vti.LMul.MX)
2421cb14a3feSDimitry Andric                  vti.RegClass:$merge, vti.RegClass:$rs2, GPR:$rs1,
242204eeddc0SDimitry Andric                  (vti.Mask V0), GPR:$vl, vti.Log2SEW)>;
242304eeddc0SDimitry Andric
2424cb14a3feSDimitry Andric    def : Pat<(vti.Vector (riscv_vmerge_vl (vti.Mask V0),
242504eeddc0SDimitry Andric                                           (SplatPat_simm5 simm5:$rs1),
242604eeddc0SDimitry Andric                                           vti.RegClass:$rs2,
2427cb14a3feSDimitry Andric                                           vti.RegClass:$merge,
242804eeddc0SDimitry Andric                                           VLOpFrag)),
242906c3fb27SDimitry Andric              (!cast<Instruction>("PseudoVMERGE_VIM_"#vti.LMul.MX)
2430cb14a3feSDimitry Andric                  vti.RegClass:$merge, vti.RegClass:$rs2, simm5:$rs1,
243104eeddc0SDimitry Andric                  (vti.Mask V0), GPR:$vl, vti.Log2SEW)>;
2432fe6060f1SDimitry Andric  }
243306c3fb27SDimitry Andric}
2434fe6060f1SDimitry Andric
2435bdd1243dSDimitry Andric// 11.16. Vector Integer Move Instructions
243606c3fb27SDimitry Andricforeach vti = AllVectors in {
243706c3fb27SDimitry Andric  let Predicates = GetVTypePredicates<vti>.Predicates in {
243806c3fb27SDimitry Andric    def : Pat<(vti.Vector (riscv_vmv_v_v_vl vti.RegClass:$passthru,
243906c3fb27SDimitry Andric                                            vti.RegClass:$rs2, VLOpFrag)),
244006c3fb27SDimitry Andric              (!cast<Instruction>("PseudoVMV_V_V_"#vti.LMul.MX)
244106c3fb27SDimitry Andric               vti.RegClass:$passthru, vti.RegClass:$rs2, GPR:$vl, vti.Log2SEW, TU_MU)>;
244206c3fb27SDimitry Andric}
244306c3fb27SDimitry Andric
2444fe6060f1SDimitry Andricforeach vti = AllIntegerVectors in {
244506c3fb27SDimitry Andric    def : Pat<(vti.Vector (riscv_vmv_v_x_vl vti.RegClass:$passthru, GPR:$rs2, VLOpFrag)),
2446fe6060f1SDimitry Andric              (!cast<Instruction>("PseudoVMV_V_X_"#vti.LMul.MX)
244706c3fb27SDimitry Andric               vti.RegClass:$passthru, GPR:$rs2, GPR:$vl, vti.Log2SEW, TU_MU)>;
2448fe6060f1SDimitry Andric    defvar ImmPat = !cast<ComplexPattern>("sew"#vti.SEW#"simm5");
244906c3fb27SDimitry Andric    def : Pat<(vti.Vector (riscv_vmv_v_x_vl vti.RegClass:$passthru, (ImmPat simm5:$imm5),
2450fe6060f1SDimitry Andric                                                VLOpFrag)),
2451fe6060f1SDimitry Andric              (!cast<Instruction>("PseudoVMV_V_I_"#vti.LMul.MX)
245206c3fb27SDimitry Andric               vti.RegClass:$passthru, simm5:$imm5, GPR:$vl, vti.Log2SEW, TU_MU)>;
245306c3fb27SDimitry Andric  }
2454fe6060f1SDimitry Andric}
2455fe6060f1SDimitry Andric
2456bdd1243dSDimitry Andric// 12. Vector Fixed-Point Arithmetic Instructions
2457bdd1243dSDimitry Andric
2458fe6060f1SDimitry Andric// 12.1. Vector Single-Width Saturating Add and Subtract
2459fe6060f1SDimitry Andricdefm : VPatBinaryVL_VV_VX_VI<riscv_saddsat_vl, "PseudoVSADD">;
2460fe6060f1SDimitry Andricdefm : VPatBinaryVL_VV_VX_VI<riscv_uaddsat_vl, "PseudoVSADDU">;
2461fe6060f1SDimitry Andricdefm : VPatBinaryVL_VV_VX<riscv_ssubsat_vl, "PseudoVSSUB">;
2462fe6060f1SDimitry Andricdefm : VPatBinaryVL_VV_VX<riscv_usubsat_vl, "PseudoVSSUBU">;
2463fe6060f1SDimitry Andric
24641db9f3b2SDimitry Andric// 12.2. Vector Single-Width Averaging Add and Subtract
2465*0fca6ea1SDimitry Andricdefm : VPatAVGADDVL_VV_VX_RM<riscv_avgfloors_vl, 0b10>;
2466*0fca6ea1SDimitry Andricdefm : VPatAVGADDVL_VV_VX_RM<riscv_avgflooru_vl, 0b10, suffix="U">;
2467*0fca6ea1SDimitry Andricdefm : VPatAVGADDVL_VV_VX_RM<riscv_avgceils_vl, 0b00>;
2468*0fca6ea1SDimitry Andricdefm : VPatAVGADDVL_VV_VX_RM<riscv_avgceilu_vl, 0b00, suffix="U">;
24691db9f3b2SDimitry Andric
2470647cbc5dSDimitry Andric// 12.5. Vector Narrowing Fixed-Point Clip Instructions
2471*0fca6ea1SDimitry Andricdefm : VPatBinaryRM_NVL_WV_WX_WI<riscv_vnclip_vl, "PseudoVNCLIP">;
2472*0fca6ea1SDimitry Andricdefm : VPatBinaryRM_NVL_WV_WX_WI<riscv_vnclipu_vl, "PseudoVNCLIPU">;
2473647cbc5dSDimitry Andric
2474bdd1243dSDimitry Andric// 13. Vector Floating-Point Instructions
2475fe6060f1SDimitry Andric
2476bdd1243dSDimitry Andric// 13.2. Vector Single-Width Floating-Point Add/Subtract Instructions
2477*0fca6ea1SDimitry Andricdefm : VPatBinaryFPVL_VV_VF_RM<any_riscv_fadd_vl, "PseudoVFADD", isSEWAware=1>;
2478*0fca6ea1SDimitry Andricdefm : VPatBinaryFPVL_VV_VF_RM<any_riscv_fsub_vl, "PseudoVFSUB", isSEWAware=1>;
2479*0fca6ea1SDimitry Andricdefm : VPatBinaryFPVL_R_VF_RM<any_riscv_fsub_vl, "PseudoVFRSUB", isSEWAware=1>;
2480fe6060f1SDimitry Andric
2481bdd1243dSDimitry Andric// 13.3. Vector Widening Floating-Point Add/Subtract Instructions
2482*0fca6ea1SDimitry Andricdefm : VPatBinaryFPWVL_VV_VF_WV_WF_RM<riscv_vfwadd_vl, riscv_vfwadd_w_vl,
2483*0fca6ea1SDimitry Andric                                      "PseudoVFWADD", isSEWAware=1>;
2484*0fca6ea1SDimitry Andricdefm : VPatBinaryFPWVL_VV_VF_WV_WF_RM<riscv_vfwsub_vl, riscv_vfwsub_w_vl,
2485*0fca6ea1SDimitry Andric                                      "PseudoVFWSUB", isSEWAware=1>;
248681ad6265SDimitry Andric
2487bdd1243dSDimitry Andric// 13.4. Vector Single-Width Floating-Point Multiply/Divide Instructions
2488*0fca6ea1SDimitry Andricdefm : VPatBinaryFPVL_VV_VF_RM<any_riscv_fmul_vl, "PseudoVFMUL", isSEWAware=1>;
248906c3fb27SDimitry Andricdefm : VPatBinaryFPVL_VV_VF_RM<any_riscv_fdiv_vl, "PseudoVFDIV", isSEWAware=1>;
249006c3fb27SDimitry Andricdefm : VPatBinaryFPVL_R_VF_RM<any_riscv_fdiv_vl, "PseudoVFRDIV", isSEWAware=1>;
2491fe6060f1SDimitry Andric
2492bdd1243dSDimitry Andric// 13.5. Vector Widening Floating-Point Multiply Instructions
2493*0fca6ea1SDimitry Andricdefm : VPatBinaryFPWVL_VV_VF_RM<riscv_vfwmul_vl, "PseudoVFWMUL", isSEWAware=1>;
249481ad6265SDimitry Andric
2495bdd1243dSDimitry Andric// 13.6 Vector Single-Width Floating-Point Fused Multiply-Add Instructions.
249606c3fb27SDimitry Andricdefm : VPatFPMulAddVL_VV_VF_RM<any_riscv_vfmadd_vl,  "PseudoVFMADD">;
249706c3fb27SDimitry Andricdefm : VPatFPMulAddVL_VV_VF_RM<any_riscv_vfmsub_vl,  "PseudoVFMSUB">;
249806c3fb27SDimitry Andricdefm : VPatFPMulAddVL_VV_VF_RM<any_riscv_vfnmadd_vl, "PseudoVFNMADD">;
249906c3fb27SDimitry Andricdefm : VPatFPMulAddVL_VV_VF_RM<any_riscv_vfnmsub_vl, "PseudoVFNMSUB">;
250006c3fb27SDimitry Andricdefm : VPatFPMulAccVL_VV_VF_RM<riscv_vfmadd_vl_oneuse,  "PseudoVFMACC">;
250106c3fb27SDimitry Andricdefm : VPatFPMulAccVL_VV_VF_RM<riscv_vfmsub_vl_oneuse,  "PseudoVFMSAC">;
250206c3fb27SDimitry Andricdefm : VPatFPMulAccVL_VV_VF_RM<riscv_vfnmadd_vl_oneuse, "PseudoVFNMACC">;
250306c3fb27SDimitry Andricdefm : VPatFPMulAccVL_VV_VF_RM<riscv_vfnmsub_vl_oneuse, "PseudoVFNMSAC">;
2504fe6060f1SDimitry Andric
2505bdd1243dSDimitry Andric// 13.7. Vector Widening Floating-Point Fused Multiply-Add Instructions
250606c3fb27SDimitry Andricdefm : VPatWidenFPMulAccVL_VV_VF_RM<riscv_vfwmadd_vl, "PseudoVFWMACC">;
250706c3fb27SDimitry Andricdefm : VPatWidenFPMulAccVL_VV_VF_RM<riscv_vfwnmadd_vl, "PseudoVFWNMACC">;
250806c3fb27SDimitry Andricdefm : VPatWidenFPMulAccVL_VV_VF_RM<riscv_vfwmsub_vl, "PseudoVFWMSAC">;
250906c3fb27SDimitry Andricdefm : VPatWidenFPMulAccVL_VV_VF_RM<riscv_vfwnmsub_vl, "PseudoVFWNMSAC">;
2510fe6060f1SDimitry Andric
2511bdd1243dSDimitry Andric// 13.11. Vector Floating-Point MIN/MAX Instructions
2512*0fca6ea1SDimitry Andricdefm : VPatBinaryFPVL_VV_VF<riscv_vfmin_vl, "PseudoVFMIN", isSEWAware=1>;
2513*0fca6ea1SDimitry Andricdefm : VPatBinaryFPVL_VV_VF<riscv_vfmax_vl, "PseudoVFMAX", isSEWAware=1>;
2514fe6060f1SDimitry Andric
2515bdd1243dSDimitry Andric// 13.13. Vector Floating-Point Compare Instructions
251606c3fb27SDimitry Andricdefm : VPatFPSetCCVL_VV_VF_FV<any_riscv_fsetcc_vl, SETEQ,
251706c3fb27SDimitry Andric                              "PseudoVMFEQ", "PseudoVMFEQ">;
251806c3fb27SDimitry Andricdefm : VPatFPSetCCVL_VV_VF_FV<any_riscv_fsetcc_vl, SETOEQ,
251906c3fb27SDimitry Andric                              "PseudoVMFEQ", "PseudoVMFEQ">;
252006c3fb27SDimitry Andricdefm : VPatFPSetCCVL_VV_VF_FV<any_riscv_fsetcc_vl, SETNE,
252106c3fb27SDimitry Andric                              "PseudoVMFNE", "PseudoVMFNE">;
252206c3fb27SDimitry Andricdefm : VPatFPSetCCVL_VV_VF_FV<any_riscv_fsetcc_vl, SETUNE,
252306c3fb27SDimitry Andric                              "PseudoVMFNE", "PseudoVMFNE">;
252406c3fb27SDimitry Andricdefm : VPatFPSetCCVL_VV_VF_FV<any_riscv_fsetccs_vl, SETLT,
252506c3fb27SDimitry Andric                              "PseudoVMFLT", "PseudoVMFGT">;
252606c3fb27SDimitry Andricdefm : VPatFPSetCCVL_VV_VF_FV<any_riscv_fsetccs_vl, SETOLT,
252706c3fb27SDimitry Andric                              "PseudoVMFLT", "PseudoVMFGT">;
252806c3fb27SDimitry Andricdefm : VPatFPSetCCVL_VV_VF_FV<any_riscv_fsetccs_vl, SETLE,
252906c3fb27SDimitry Andric                              "PseudoVMFLE", "PseudoVMFGE">;
253006c3fb27SDimitry Andricdefm : VPatFPSetCCVL_VV_VF_FV<any_riscv_fsetccs_vl, SETOLE,
253106c3fb27SDimitry Andric                              "PseudoVMFLE", "PseudoVMFGE">;
2532fe6060f1SDimitry Andric
2533fe6060f1SDimitry Andricforeach vti = AllFloatVectors in {
253406c3fb27SDimitry Andric  let Predicates = GetVTypePredicates<vti>.Predicates in {
2535bdd1243dSDimitry Andric    // 13.8. Vector Floating-Point Square-Root Instruction
253606c3fb27SDimitry Andric    def : Pat<(any_riscv_fsqrt_vl (vti.Vector vti.RegClass:$rs2), (vti.Mask V0),
2537fe6060f1SDimitry Andric                              VLOpFrag),
253806c3fb27SDimitry Andric              (!cast<Instruction>("PseudoVFSQRT_V_"# vti.LMul.MX # "_E" # vti.SEW # "_MASK")
2539bdd1243dSDimitry Andric                   (vti.Vector (IMPLICIT_DEF)), vti.RegClass:$rs2,
254006c3fb27SDimitry Andric                   (vti.Mask V0),
254106c3fb27SDimitry Andric                   // Value to indicate no rounding mode change in
254206c3fb27SDimitry Andric                   // RISCVInsertReadWriteCSR
254306c3fb27SDimitry Andric                   FRM_DYN,
254406c3fb27SDimitry Andric                   GPR:$vl, vti.Log2SEW, TA_MA)>;
2545fe6060f1SDimitry Andric
2546bdd1243dSDimitry Andric    // 13.12. Vector Floating-Point Sign-Injection Instructions
2547bdd1243dSDimitry Andric    def : Pat<(riscv_fabs_vl (vti.Vector vti.RegClass:$rs), (vti.Mask V0),
2548fe6060f1SDimitry Andric                             VLOpFrag),
2549*0fca6ea1SDimitry Andric              (!cast<Instruction>("PseudoVFSGNJX_VV_"# vti.LMul.MX #"_E"#vti.SEW#"_MASK")
2550bdd1243dSDimitry Andric                   (vti.Vector (IMPLICIT_DEF)), vti.RegClass:$rs,
2551bdd1243dSDimitry Andric                   vti.RegClass:$rs, (vti.Mask V0), GPR:$vl, vti.Log2SEW,
2552bdd1243dSDimitry Andric                   TA_MA)>;
2553fe6060f1SDimitry Andric    // Handle fneg with VFSGNJN using the same input for both operands.
255481ad6265SDimitry Andric    def : Pat<(riscv_fneg_vl (vti.Vector vti.RegClass:$rs), (vti.Mask V0),
2555fe6060f1SDimitry Andric                             VLOpFrag),
2556*0fca6ea1SDimitry Andric              (!cast<Instruction>("PseudoVFSGNJN_VV_"# vti.LMul.MX#"_E"#vti.SEW #"_MASK")
255781ad6265SDimitry Andric                   (vti.Vector (IMPLICIT_DEF)), vti.RegClass:$rs,
255881ad6265SDimitry Andric                   vti.RegClass:$rs, (vti.Mask V0), GPR:$vl, vti.Log2SEW,
2559bdd1243dSDimitry Andric                   TA_MA)>;
256081ad6265SDimitry Andric
2561fe6060f1SDimitry Andric    def : Pat<(riscv_fcopysign_vl (vti.Vector vti.RegClass:$rs1),
2562fe6060f1SDimitry Andric                                  (vti.Vector vti.RegClass:$rs2),
2563bdd1243dSDimitry Andric                                  vti.RegClass:$merge,
2564bdd1243dSDimitry Andric                                  (vti.Mask V0),
2565fe6060f1SDimitry Andric                                  VLOpFrag),
2566*0fca6ea1SDimitry Andric              (!cast<Instruction>("PseudoVFSGNJ_VV_"# vti.LMul.MX#"_E"#vti.SEW#"_MASK")
2567bdd1243dSDimitry Andric                   vti.RegClass:$merge, vti.RegClass:$rs1,
2568bdd1243dSDimitry Andric                   vti.RegClass:$rs2, (vti.Mask V0), GPR:$vl, vti.Log2SEW,
2569bdd1243dSDimitry Andric                   TAIL_AGNOSTIC)>;
2570bdd1243dSDimitry Andric
2571fe6060f1SDimitry Andric    def : Pat<(riscv_fcopysign_vl (vti.Vector vti.RegClass:$rs1),
2572fe6060f1SDimitry Andric                                  (riscv_fneg_vl vti.RegClass:$rs2,
2573fe6060f1SDimitry Andric                                                 (vti.Mask true_mask),
2574fe6060f1SDimitry Andric                                                 VLOpFrag),
2575bdd1243dSDimitry Andric                                  srcvalue,
2576fe6060f1SDimitry Andric                                  (vti.Mask true_mask),
2577fe6060f1SDimitry Andric                                  VLOpFrag),
2578*0fca6ea1SDimitry Andric              (!cast<Instruction>("PseudoVFSGNJN_VV_"# vti.LMul.MX#"_E"#vti.SEW)
257906c3fb27SDimitry Andric        (vti.Vector (IMPLICIT_DEF)),
25805f757f3fSDimitry Andric                   vti.RegClass:$rs1, vti.RegClass:$rs2, GPR:$vl, vti.Log2SEW, TA_MA)>;
2581fe6060f1SDimitry Andric
2582fe6060f1SDimitry Andric    def : Pat<(riscv_fcopysign_vl (vti.Vector vti.RegClass:$rs1),
2583fe6060f1SDimitry Andric                                  (SplatFPOp vti.ScalarRegClass:$rs2),
2584bdd1243dSDimitry Andric                                  vti.RegClass:$merge,
2585bdd1243dSDimitry Andric                                  (vti.Mask V0),
2586fe6060f1SDimitry Andric                                  VLOpFrag),
2587*0fca6ea1SDimitry Andric              (!cast<Instruction>("PseudoVFSGNJ_V"#vti.ScalarSuffix#"_"# vti.LMul.MX#"_E"#vti.SEW#"_MASK")
2588bdd1243dSDimitry Andric                   vti.RegClass:$merge, vti.RegClass:$rs1,
2589bdd1243dSDimitry Andric                   vti.ScalarRegClass:$rs2, (vti.Mask V0), GPR:$vl, vti.Log2SEW,
2590bdd1243dSDimitry Andric                   TAIL_AGNOSTIC)>;
2591bdd1243dSDimitry Andric
2592bdd1243dSDimitry Andric    // Rounding without exception to implement nearbyint.
259306c3fb27SDimitry Andric    def : Pat<(any_riscv_vfround_noexcept_vl (vti.Vector vti.RegClass:$rs1),
2594bdd1243dSDimitry Andric                                             (vti.Mask V0), VLOpFrag),
2595bdd1243dSDimitry Andric              (!cast<Instruction>("PseudoVFROUND_NOEXCEPT_V_" # vti.LMul.MX #"_MASK")
2596bdd1243dSDimitry Andric                    (vti.Vector (IMPLICIT_DEF)), vti.RegClass:$rs1,
2597bdd1243dSDimitry Andric                    (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
259806c3fb27SDimitry Andric
259906c3fb27SDimitry Andric    // 14.14. Vector Floating-Point Classify Instruction
260006c3fb27SDimitry Andric    def : Pat<(riscv_fclass_vl (vti.Vector vti.RegClass:$rs2),
26015f757f3fSDimitry Andric                               (vti.Mask V0), VLOpFrag),
26025f757f3fSDimitry Andric              (!cast<Instruction>("PseudoVFCLASS_V_"# vti.LMul.MX #"_MASK")
26035f757f3fSDimitry Andric                 (vti.Vector (IMPLICIT_DEF)), vti.RegClass:$rs2,
26045f757f3fSDimitry Andric                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
260506c3fb27SDimitry Andric  }
2606fe6060f1SDimitry Andric}
2607fe6060f1SDimitry Andric
2608*0fca6ea1SDimitry Andricforeach fvti = !listconcat(AllFloatVectors, AllBFloatVectors) in {
2609fe6060f1SDimitry Andric  // Floating-point vselects:
2610bdd1243dSDimitry Andric  // 11.15. Vector Integer Merge Instructions
2611bdd1243dSDimitry Andric  // 13.15. Vector Floating-Point Merge Instruction
26125f757f3fSDimitry Andric  defvar ivti = GetIntVTypeInfo<fvti>.Vti;
26135f757f3fSDimitry Andric  let Predicates = GetVTypePredicates<ivti>.Predicates in {
2614cb14a3feSDimitry Andric  def : Pat<(fvti.Vector (riscv_vmerge_vl (fvti.Mask V0),
261504eeddc0SDimitry Andric                                          fvti.RegClass:$rs1,
261604eeddc0SDimitry Andric                                          fvti.RegClass:$rs2,
2617cb14a3feSDimitry Andric                                          fvti.RegClass:$merge,
261804eeddc0SDimitry Andric                                          VLOpFrag)),
261906c3fb27SDimitry Andric            (!cast<Instruction>("PseudoVMERGE_VVM_"#fvti.LMul.MX)
2620cb14a3feSDimitry Andric                 fvti.RegClass:$merge, fvti.RegClass:$rs2, fvti.RegClass:$rs1, (fvti.Mask V0),
262104eeddc0SDimitry Andric                 GPR:$vl, fvti.Log2SEW)>;
262204eeddc0SDimitry Andric
2623cb14a3feSDimitry Andric  def : Pat<(fvti.Vector (riscv_vmerge_vl (fvti.Mask V0),
26241db9f3b2SDimitry Andric                                          (SplatFPOp (SelectFPImm (XLenVT GPR:$imm))),
26251db9f3b2SDimitry Andric                                          fvti.RegClass:$rs2,
26261db9f3b2SDimitry Andric                                          fvti.RegClass:$merge,
26271db9f3b2SDimitry Andric                                          VLOpFrag)),
26281db9f3b2SDimitry Andric            (!cast<Instruction>("PseudoVMERGE_VXM_"#fvti.LMul.MX)
26291db9f3b2SDimitry Andric                 fvti.RegClass:$merge, fvti.RegClass:$rs2, GPR:$imm, (fvti.Mask V0),
26301db9f3b2SDimitry Andric                 GPR:$vl, fvti.Log2SEW)>;
26311db9f3b2SDimitry Andric
26321db9f3b2SDimitry Andric
26331db9f3b2SDimitry Andric  def : Pat<(fvti.Vector (riscv_vmerge_vl (fvti.Mask V0),
26345f757f3fSDimitry Andric                                          (SplatFPOp (fvti.Scalar fpimm0)),
26355f757f3fSDimitry Andric                                          fvti.RegClass:$rs2,
2636cb14a3feSDimitry Andric                                          fvti.RegClass:$merge,
26375f757f3fSDimitry Andric                                          VLOpFrag)),
26385f757f3fSDimitry Andric            (!cast<Instruction>("PseudoVMERGE_VIM_"#fvti.LMul.MX)
2639cb14a3feSDimitry Andric                 fvti.RegClass:$merge, fvti.RegClass:$rs2, 0, (fvti.Mask V0),
26405f757f3fSDimitry Andric                 GPR:$vl, fvti.Log2SEW)>;
26415f757f3fSDimitry Andric  }
2642*0fca6ea1SDimitry Andric}
26435f757f3fSDimitry Andric
2644*0fca6ea1SDimitry Andricforeach fvti = AllFloatVectors in {
26455f757f3fSDimitry Andric  let Predicates = GetVTypePredicates<fvti>.Predicates in {
2646cb14a3feSDimitry Andric    def : Pat<(fvti.Vector (riscv_vmerge_vl (fvti.Mask V0),
264704eeddc0SDimitry Andric                                            (SplatFPOp fvti.ScalarRegClass:$rs1),
264804eeddc0SDimitry Andric                                            fvti.RegClass:$rs2,
2649cb14a3feSDimitry Andric                                            fvti.RegClass:$merge,
265004eeddc0SDimitry Andric                                            VLOpFrag)),
265106c3fb27SDimitry Andric              (!cast<Instruction>("PseudoVFMERGE_V"#fvti.ScalarSuffix#"M_"#fvti.LMul.MX)
2652cb14a3feSDimitry Andric                   fvti.RegClass:$merge, fvti.RegClass:$rs2,
265304eeddc0SDimitry Andric                   (fvti.Scalar fvti.ScalarRegClass:$rs1),
265404eeddc0SDimitry Andric                   (fvti.Mask V0), GPR:$vl, fvti.Log2SEW)>;
2655*0fca6ea1SDimitry Andric  }
2656*0fca6ea1SDimitry Andric}
265704eeddc0SDimitry Andric
2658*0fca6ea1SDimitry Andricforeach fvti = !listconcat(AllFloatVectors, AllBFloatVectors) in {
2659*0fca6ea1SDimitry Andric  defvar ivti = GetIntVTypeInfo<fvti>.Vti;
2660*0fca6ea1SDimitry Andric  let Predicates = GetVTypePredicates<ivti>.Predicates in {
2661bdd1243dSDimitry Andric    // 13.16. Vector Floating-Point Move Instruction
2662fe6060f1SDimitry Andric    // If we're splatting fpimm0, use vmv.v.x vd, x0.
2663fe6060f1SDimitry Andric    def : Pat<(fvti.Vector (riscv_vfmv_v_f_vl
266481ad6265SDimitry Andric                           fvti.Vector:$passthru, (fvti.Scalar (fpimm0)), VLOpFrag)),
266506c3fb27SDimitry Andric              (!cast<Instruction>("PseudoVMV_V_I_"#fvti.LMul.MX)
266606c3fb27SDimitry Andric               $passthru, 0, GPR:$vl, fvti.Log2SEW, TU_MU)>;
2667fe6060f1SDimitry Andric    def : Pat<(fvti.Vector (riscv_vfmv_v_f_vl
266806c3fb27SDimitry Andric                           fvti.Vector:$passthru, (fvti.Scalar (SelectFPImm (XLenVT GPR:$imm))), VLOpFrag)),
266906c3fb27SDimitry Andric              (!cast<Instruction>("PseudoVMV_V_X_"#fvti.LMul.MX)
267006c3fb27SDimitry Andric               $passthru, GPR:$imm, GPR:$vl, fvti.Log2SEW, TU_MU)>;
2671*0fca6ea1SDimitry Andric  }
2672*0fca6ea1SDimitry Andric}
267306c3fb27SDimitry Andric
2674*0fca6ea1SDimitry Andricforeach fvti = AllFloatVectors in {
2675*0fca6ea1SDimitry Andric  let Predicates = GetVTypePredicates<fvti>.Predicates in {
267681ad6265SDimitry Andric    def : Pat<(fvti.Vector (riscv_vfmv_v_f_vl
267781ad6265SDimitry Andric                           fvti.Vector:$passthru, (fvti.Scalar fvti.ScalarRegClass:$rs2), VLOpFrag)),
267881ad6265SDimitry Andric              (!cast<Instruction>("PseudoVFMV_V_" # fvti.ScalarSuffix # "_" #
267906c3fb27SDimitry Andric                                  fvti.LMul.MX)
268081ad6265SDimitry Andric               $passthru, (fvti.Scalar fvti.ScalarRegClass:$rs2),
268106c3fb27SDimitry Andric               GPR:$vl, fvti.Log2SEW, TU_MU)>;
268206c3fb27SDimitry Andric  }
268306c3fb27SDimitry Andric}
2684fe6060f1SDimitry Andric
2685bdd1243dSDimitry Andric// 13.17. Vector Single-Width Floating-Point/Integer Type-Convert Instructions
268606c3fb27SDimitry Andricdefm : VPatConvertFP2IVL_V_RM<riscv_vfcvt_xu_f_vl, "PseudoVFCVT_XU_F_V">;
268706c3fb27SDimitry Andricdefm : VPatConvertFP2IVL_V_RM<riscv_vfcvt_x_f_vl, "PseudoVFCVT_X_F_V">;
2688bdd1243dSDimitry Andricdefm : VPatConvertFP2I_RM_VL_V<riscv_vfcvt_rm_xu_f_vl, "PseudoVFCVT_RM_XU_F_V">;
268906c3fb27SDimitry Andricdefm : VPatConvertFP2I_RM_VL_V<any_riscv_vfcvt_rm_x_f_vl, "PseudoVFCVT_RM_X_F_V">;
2690fe6060f1SDimitry Andric
269106c3fb27SDimitry Andricdefm : VPatConvertFP2IVL_V<any_riscv_vfcvt_rtz_xu_f_vl, "PseudoVFCVT_RTZ_XU_F_V">;
269206c3fb27SDimitry Andricdefm : VPatConvertFP2IVL_V<any_riscv_vfcvt_rtz_x_f_vl, "PseudoVFCVT_RTZ_X_F_V">;
2693bdd1243dSDimitry Andric
269406c3fb27SDimitry Andricdefm : VPatConvertI2FPVL_V_RM<any_riscv_uint_to_fp_vl, "PseudoVFCVT_F_XU_V">;
269506c3fb27SDimitry Andricdefm : VPatConvertI2FPVL_V_RM<any_riscv_sint_to_fp_vl, "PseudoVFCVT_F_X_V">;
2696bdd1243dSDimitry Andric
2697bdd1243dSDimitry Andricdefm : VPatConvertI2FP_RM_VL_V<riscv_vfcvt_rm_f_xu_vl, "PseudoVFCVT_RM_F_XU_V">;
2698bdd1243dSDimitry Andricdefm : VPatConvertI2FP_RM_VL_V<riscv_vfcvt_rm_f_x_vl, "PseudoVFCVT_RM_F_X_V">;
2699bdd1243dSDimitry Andric
2700bdd1243dSDimitry Andric// 13.18. Widening Floating-Point/Integer Type-Convert Instructions
270106c3fb27SDimitry Andricdefm : VPatWConvertFP2IVL_V_RM<riscv_vfcvt_xu_f_vl, "PseudoVFWCVT_XU_F_V">;
270206c3fb27SDimitry Andricdefm : VPatWConvertFP2IVL_V_RM<riscv_vfcvt_x_f_vl, "PseudoVFWCVT_X_F_V">;
2703bdd1243dSDimitry Andricdefm : VPatWConvertFP2I_RM_VL_V<riscv_vfcvt_rm_xu_f_vl, "PseudoVFWCVT_RM_XU_F_V">;
2704bdd1243dSDimitry Andricdefm : VPatWConvertFP2I_RM_VL_V<riscv_vfcvt_rm_x_f_vl, "PseudoVFWCVT_RM_X_F_V">;
2705bdd1243dSDimitry Andric
270606c3fb27SDimitry Andricdefm : VPatWConvertFP2IVL_V<any_riscv_vfcvt_rtz_xu_f_vl, "PseudoVFWCVT_RTZ_XU_F_V">;
270706c3fb27SDimitry Andricdefm : VPatWConvertFP2IVL_V<any_riscv_vfcvt_rtz_x_f_vl, "PseudoVFWCVT_RTZ_X_F_V">;
2708bdd1243dSDimitry Andric
270906c3fb27SDimitry Andricdefm : VPatWConvertI2FPVL_V<any_riscv_uint_to_fp_vl, "PseudoVFWCVT_F_XU_V">;
271006c3fb27SDimitry Andricdefm : VPatWConvertI2FPVL_V<any_riscv_sint_to_fp_vl, "PseudoVFWCVT_F_X_V">;
2711bdd1243dSDimitry Andric
2712fe6060f1SDimitry Andricforeach fvtiToFWti = AllWidenableFloatVectors in {
2713fe6060f1SDimitry Andric  defvar fvti = fvtiToFWti.Vti;
2714fe6060f1SDimitry Andric  defvar fwti = fvtiToFWti.Wti;
27155f757f3fSDimitry Andric  let Predicates = !if(!eq(fvti.Scalar, f16), [HasVInstructionsF16Minimal],
27165f757f3fSDimitry Andric                       !listconcat(GetVTypePredicates<fvti>.Predicates,
27175f757f3fSDimitry Andric                                   GetVTypePredicates<fwti>.Predicates)) in
271806c3fb27SDimitry Andric  def : Pat<(fwti.Vector (any_riscv_fpextend_vl
271906c3fb27SDimitry Andric                             (fvti.Vector fvti.RegClass:$rs1),
272081ad6265SDimitry Andric                             (fvti.Mask V0),
2721fe6060f1SDimitry Andric                             VLOpFrag)),
2722*0fca6ea1SDimitry Andric            (!cast<Instruction>("PseudoVFWCVT_F_F_V_"#fvti.LMul.MX#"_E"#fvti.SEW#"_MASK")
2723*0fca6ea1SDimitry Andric                (fwti.Vector (IMPLICIT_DEF)), fvti.RegClass:$rs1,
2724*0fca6ea1SDimitry Andric                (fvti.Mask V0),
2725*0fca6ea1SDimitry Andric                GPR:$vl, fvti.Log2SEW, TA_MA)>;
2726*0fca6ea1SDimitry Andric}
2727*0fca6ea1SDimitry Andric
2728*0fca6ea1SDimitry Andricforeach fvtiToFWti = AllWidenableBFloatToFloatVectors in {
2729*0fca6ea1SDimitry Andric  defvar fvti = fvtiToFWti.Vti;
2730*0fca6ea1SDimitry Andric  defvar fwti = fvtiToFWti.Wti;
2731*0fca6ea1SDimitry Andric  let Predicates = [HasVInstructionsBF16] in
2732*0fca6ea1SDimitry Andric  def : Pat<(fwti.Vector (any_riscv_fpextend_vl
2733*0fca6ea1SDimitry Andric                             (fvti.Vector fvti.RegClass:$rs1),
2734*0fca6ea1SDimitry Andric                             (fvti.Mask V0),
2735*0fca6ea1SDimitry Andric                             VLOpFrag)),
2736*0fca6ea1SDimitry Andric            (!cast<Instruction>("PseudoVFWCVTBF16_F_F_V_"#fvti.LMul.MX#"_E"#fvti.SEW#"_MASK")
273781ad6265SDimitry Andric                (fwti.Vector (IMPLICIT_DEF)), fvti.RegClass:$rs1,
273806c3fb27SDimitry Andric                (fvti.Mask V0),
273906c3fb27SDimitry Andric                GPR:$vl, fvti.Log2SEW, TA_MA)>;
2740fe6060f1SDimitry Andric}
2741fe6060f1SDimitry Andric
2742bdd1243dSDimitry Andric// 13.19 Narrowing Floating-Point/Integer Type-Convert Instructions
274306c3fb27SDimitry Andricdefm : VPatNConvertFP2IVL_W_RM<riscv_vfcvt_xu_f_vl, "PseudoVFNCVT_XU_F_W">;
274406c3fb27SDimitry Andricdefm : VPatNConvertFP2IVL_W_RM<riscv_vfcvt_x_f_vl, "PseudoVFNCVT_X_F_W">;
274506c3fb27SDimitry Andricdefm : VPatNConvertFP2I_RM_VL_W<riscv_vfcvt_rm_xu_f_vl, "PseudoVFNCVT_RM_XU_F_W">;
274606c3fb27SDimitry Andricdefm : VPatNConvertFP2I_RM_VL_W<riscv_vfcvt_rm_x_f_vl, "PseudoVFNCVT_RM_X_F_W">;
2747bdd1243dSDimitry Andric
274806c3fb27SDimitry Andricdefm : VPatNConvertFP2IVL_W<any_riscv_vfcvt_rtz_xu_f_vl, "PseudoVFNCVT_RTZ_XU_F_W">;
274906c3fb27SDimitry Andricdefm : VPatNConvertFP2IVL_W<any_riscv_vfcvt_rtz_x_f_vl, "PseudoVFNCVT_RTZ_X_F_W">;
2750bdd1243dSDimitry Andric
275106c3fb27SDimitry Andricdefm : VPatNConvertI2FPVL_W_RM<any_riscv_uint_to_fp_vl, "PseudoVFNCVT_F_XU_W">;
275206c3fb27SDimitry Andricdefm : VPatNConvertI2FPVL_W_RM<any_riscv_sint_to_fp_vl, "PseudoVFNCVT_F_X_W">;
2753bdd1243dSDimitry Andric
275406c3fb27SDimitry Andricdefm : VPatNConvertI2FP_RM_VL_W<riscv_vfcvt_rm_f_xu_vl, "PseudoVFNCVT_RM_F_XU_W">;
275506c3fb27SDimitry Andricdefm : VPatNConvertI2FP_RM_VL_W<riscv_vfcvt_rm_f_x_vl, "PseudoVFNCVT_RM_F_X_W">;
2756bdd1243dSDimitry Andric
2757fe6060f1SDimitry Andricforeach fvtiToFWti = AllWidenableFloatVectors in {
2758fe6060f1SDimitry Andric  defvar fvti = fvtiToFWti.Vti;
2759fe6060f1SDimitry Andric  defvar fwti = fvtiToFWti.Wti;
27605f757f3fSDimitry Andric  // Define vfwcvt.f.f.v for f16 when Zvfhmin is enable.
27615f757f3fSDimitry Andric  let Predicates = !if(!eq(fvti.Scalar, f16), [HasVInstructionsF16Minimal],
27625f757f3fSDimitry Andric                       !listconcat(GetVTypePredicates<fvti>.Predicates,
27635f757f3fSDimitry Andric                                   GetVTypePredicates<fwti>.Predicates)) in {
276406c3fb27SDimitry Andric    def : Pat<(fvti.Vector (any_riscv_fpround_vl
276506c3fb27SDimitry Andric                               (fwti.Vector fwti.RegClass:$rs1),
276606c3fb27SDimitry Andric                               (fwti.Mask V0), VLOpFrag)),
2767*0fca6ea1SDimitry Andric              (!cast<Instruction>("PseudoVFNCVT_F_F_W_"#fvti.LMul.MX#"_E"#fvti.SEW#"_MASK")
276881ad6265SDimitry Andric                  (fvti.Vector (IMPLICIT_DEF)), fwti.RegClass:$rs1,
276981ad6265SDimitry Andric                  (fwti.Mask V0),
277006c3fb27SDimitry Andric                  // Value to indicate no rounding mode change in
277106c3fb27SDimitry Andric                  // RISCVInsertReadWriteCSR
277206c3fb27SDimitry Andric                  FRM_DYN,
277306c3fb27SDimitry Andric                  GPR:$vl, fvti.Log2SEW, TA_MA)>;
277406c3fb27SDimitry Andric
27755f757f3fSDimitry Andric  let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
27765f757f3fSDimitry Andric                               GetVTypePredicates<fwti>.Predicates) in
277706c3fb27SDimitry Andric    def : Pat<(fvti.Vector (any_riscv_fncvt_rod_vl
277806c3fb27SDimitry Andric                               (fwti.Vector fwti.RegClass:$rs1),
277906c3fb27SDimitry Andric                               (fwti.Mask V0), VLOpFrag)),
2780*0fca6ea1SDimitry Andric              (!cast<Instruction>("PseudoVFNCVT_ROD_F_F_W_"#fvti.LMul.MX#"_E"#fvti.SEW#"_MASK")
278181ad6265SDimitry Andric                  (fvti.Vector (IMPLICIT_DEF)), fwti.RegClass:$rs1,
2782bdd1243dSDimitry Andric                  (fwti.Mask V0), GPR:$vl, fvti.Log2SEW, TA_MA)>;
2783fe6060f1SDimitry Andric  }
2784fe6060f1SDimitry Andric}
2785fe6060f1SDimitry Andric
2786*0fca6ea1SDimitry Andricforeach fvtiToFWti = AllWidenableBFloatToFloatVectors in {
2787*0fca6ea1SDimitry Andric  defvar fvti = fvtiToFWti.Vti;
2788*0fca6ea1SDimitry Andric  defvar fwti = fvtiToFWti.Wti;
2789*0fca6ea1SDimitry Andric  let Predicates = [HasVInstructionsBF16] in
2790*0fca6ea1SDimitry Andric    def : Pat<(fvti.Vector (any_riscv_fpround_vl
2791*0fca6ea1SDimitry Andric                               (fwti.Vector fwti.RegClass:$rs1),
2792*0fca6ea1SDimitry Andric                               (fwti.Mask V0), VLOpFrag)),
2793*0fca6ea1SDimitry Andric              (!cast<Instruction>("PseudoVFNCVTBF16_F_F_W_"#fvti.LMul.MX#"_E"#fvti.SEW#"_MASK")
2794*0fca6ea1SDimitry Andric                  (fvti.Vector (IMPLICIT_DEF)), fwti.RegClass:$rs1,
2795*0fca6ea1SDimitry Andric                  (fwti.Mask V0),
2796*0fca6ea1SDimitry Andric                  // Value to indicate no rounding mode change in
2797*0fca6ea1SDimitry Andric                  // RISCVInsertReadWriteCSR
2798*0fca6ea1SDimitry Andric                  FRM_DYN,
2799*0fca6ea1SDimitry Andric                  GPR:$vl, fvti.Log2SEW, TA_MA)>;
2800*0fca6ea1SDimitry Andric}
2801*0fca6ea1SDimitry Andric
2802bdd1243dSDimitry Andric// 14. Vector Reduction Operations
2803bdd1243dSDimitry Andric
2804bdd1243dSDimitry Andric// 14.1. Vector Single-Width Integer Reduction Instructions
280506c3fb27SDimitry Andricdefm : VPatReductionVL<rvv_vecreduce_ADD_vl,  "PseudoVREDSUM", is_float=0>;
280606c3fb27SDimitry Andricdefm : VPatReductionVL<rvv_vecreduce_UMAX_vl, "PseudoVREDMAXU", is_float=0>;
280706c3fb27SDimitry Andricdefm : VPatReductionVL<rvv_vecreduce_SMAX_vl, "PseudoVREDMAX", is_float=0>;
280806c3fb27SDimitry Andricdefm : VPatReductionVL<rvv_vecreduce_UMIN_vl, "PseudoVREDMINU", is_float=0>;
280906c3fb27SDimitry Andricdefm : VPatReductionVL<rvv_vecreduce_SMIN_vl, "PseudoVREDMIN", is_float=0>;
281006c3fb27SDimitry Andricdefm : VPatReductionVL<rvv_vecreduce_AND_vl,  "PseudoVREDAND", is_float=0>;
281106c3fb27SDimitry Andricdefm : VPatReductionVL<rvv_vecreduce_OR_vl,   "PseudoVREDOR", is_float=0>;
281206c3fb27SDimitry Andricdefm : VPatReductionVL<rvv_vecreduce_XOR_vl,  "PseudoVREDXOR", is_float=0>;
2813bdd1243dSDimitry Andric
2814bdd1243dSDimitry Andric// 14.2. Vector Widening Integer Reduction Instructions
281506c3fb27SDimitry Andricdefm : VPatWidenReductionVL<rvv_vecreduce_ADD_vl, anyext_oneuse, "PseudoVWREDSUMU", is_float=0>;
281606c3fb27SDimitry Andricdefm : VPatWidenReductionVL<rvv_vecreduce_ADD_vl, zext_oneuse, "PseudoVWREDSUMU", is_float=0>;
281706c3fb27SDimitry Andricdefm : VPatWidenReductionVL_Ext_VL<rvv_vecreduce_ADD_vl, riscv_zext_vl_oneuse, "PseudoVWREDSUMU", is_float=0>;
281806c3fb27SDimitry Andricdefm : VPatWidenReductionVL<rvv_vecreduce_ADD_vl, sext_oneuse, "PseudoVWREDSUM", is_float=0>;
281906c3fb27SDimitry Andricdefm : VPatWidenReductionVL_Ext_VL<rvv_vecreduce_ADD_vl, riscv_sext_vl_oneuse, "PseudoVWREDSUM", is_float=0>;
2820bdd1243dSDimitry Andric
2821bdd1243dSDimitry Andric// 14.3. Vector Single-Width Floating-Point Reduction Instructions
282206c3fb27SDimitry Andricdefm : VPatReductionVL_RM<rvv_vecreduce_SEQ_FADD_vl, "PseudoVFREDOSUM", is_float=1>;
282306c3fb27SDimitry Andricdefm : VPatReductionVL_RM<rvv_vecreduce_FADD_vl,     "PseudoVFREDUSUM", is_float=1>;
282406c3fb27SDimitry Andricdefm : VPatReductionVL<rvv_vecreduce_FMIN_vl,     "PseudoVFREDMIN", is_float=1>;
282506c3fb27SDimitry Andricdefm : VPatReductionVL<rvv_vecreduce_FMAX_vl,     "PseudoVFREDMAX", is_float=1>;
2826bdd1243dSDimitry Andric
2827bdd1243dSDimitry Andric// 14.4. Vector Widening Floating-Point Reduction Instructions
282806c3fb27SDimitry Andricdefm : VPatWidenReductionVL_RM<rvv_vecreduce_SEQ_FADD_vl, fpext_oneuse,
282906c3fb27SDimitry Andric                               "PseudoVFWREDOSUM", is_float=1>;
283006c3fb27SDimitry Andricdefm : VPatWidenReductionVL_Ext_VL_RM<rvv_vecreduce_SEQ_FADD_vl,
283106c3fb27SDimitry Andric                                      riscv_fpextend_vl_oneuse,
283206c3fb27SDimitry Andric                                      "PseudoVFWREDOSUM", is_float=1>;
283306c3fb27SDimitry Andricdefm : VPatWidenReductionVL_RM<rvv_vecreduce_FADD_vl, fpext_oneuse,
283406c3fb27SDimitry Andric                               "PseudoVFWREDUSUM", is_float=1>;
283506c3fb27SDimitry Andricdefm : VPatWidenReductionVL_Ext_VL_RM<rvv_vecreduce_FADD_vl,
283606c3fb27SDimitry Andric                                      riscv_fpextend_vl_oneuse,
283706c3fb27SDimitry Andric                                      "PseudoVFWREDUSUM", is_float=1>;
2838bdd1243dSDimitry Andric
2839bdd1243dSDimitry Andric// 15. Vector Mask Instructions
2840bdd1243dSDimitry Andric
2841fe6060f1SDimitry Andricforeach mti = AllMasks in {
284206c3fb27SDimitry Andric  let Predicates = [HasVInstructions] in {
2843bdd1243dSDimitry Andric    // 15.1 Vector Mask-Register Logical Instructions
2844fe6060f1SDimitry Andric    def : Pat<(mti.Mask (riscv_vmset_vl VLOpFrag)),
2845fe6060f1SDimitry Andric              (!cast<Instruction>("PseudoVMSET_M_" # mti.BX) GPR:$vl, mti.Log2SEW)>;
2846fe6060f1SDimitry Andric    def : Pat<(mti.Mask (riscv_vmclr_vl VLOpFrag)),
2847fe6060f1SDimitry Andric              (!cast<Instruction>("PseudoVMCLR_M_" # mti.BX) GPR:$vl, mti.Log2SEW)>;
2848fe6060f1SDimitry Andric
2849fe6060f1SDimitry Andric    def : Pat<(mti.Mask (riscv_vmand_vl VR:$rs1, VR:$rs2, VLOpFrag)),
2850fe6060f1SDimitry Andric              (!cast<Instruction>("PseudoVMAND_MM_" # mti.LMul.MX)
2851fe6060f1SDimitry Andric                   VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
2852fe6060f1SDimitry Andric    def : Pat<(mti.Mask (riscv_vmor_vl VR:$rs1, VR:$rs2, VLOpFrag)),
2853fe6060f1SDimitry Andric              (!cast<Instruction>("PseudoVMOR_MM_" # mti.LMul.MX)
2854fe6060f1SDimitry Andric                   VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
2855fe6060f1SDimitry Andric    def : Pat<(mti.Mask (riscv_vmxor_vl VR:$rs1, VR:$rs2, VLOpFrag)),
2856fe6060f1SDimitry Andric              (!cast<Instruction>("PseudoVMXOR_MM_" # mti.LMul.MX)
2857fe6060f1SDimitry Andric                   VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
2858fe6060f1SDimitry Andric
2859fe6060f1SDimitry Andric    def : Pat<(mti.Mask (riscv_vmand_vl VR:$rs1,
2860fe6060f1SDimitry Andric                                        (riscv_vmnot_vl VR:$rs2, VLOpFrag),
2861fe6060f1SDimitry Andric                                        VLOpFrag)),
2862349cc55cSDimitry Andric              (!cast<Instruction>("PseudoVMANDN_MM_" # mti.LMul.MX)
2863fe6060f1SDimitry Andric                   VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
2864fe6060f1SDimitry Andric    def : Pat<(mti.Mask (riscv_vmor_vl VR:$rs1,
2865fe6060f1SDimitry Andric                                       (riscv_vmnot_vl VR:$rs2, VLOpFrag),
2866fe6060f1SDimitry Andric                                       VLOpFrag)),
2867349cc55cSDimitry Andric              (!cast<Instruction>("PseudoVMORN_MM_" # mti.LMul.MX)
2868fe6060f1SDimitry Andric                   VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
2869fe6060f1SDimitry Andric    // XOR is associative so we need 2 patterns for VMXNOR.
2870fe6060f1SDimitry Andric    def : Pat<(mti.Mask (riscv_vmxor_vl (riscv_vmnot_vl VR:$rs1,
2871fe6060f1SDimitry Andric                                                        VLOpFrag),
2872fe6060f1SDimitry Andric                                       VR:$rs2, VLOpFrag)),
2873fe6060f1SDimitry Andric              (!cast<Instruction>("PseudoVMXNOR_MM_" # mti.LMul.MX)
2874fe6060f1SDimitry Andric                   VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
2875fe6060f1SDimitry Andric
2876fe6060f1SDimitry Andric    def : Pat<(mti.Mask (riscv_vmnot_vl (riscv_vmand_vl VR:$rs1, VR:$rs2,
2877fe6060f1SDimitry Andric                                                        VLOpFrag),
2878fe6060f1SDimitry Andric                                        VLOpFrag)),
2879fe6060f1SDimitry Andric              (!cast<Instruction>("PseudoVMNAND_MM_" # mti.LMul.MX)
2880fe6060f1SDimitry Andric                   VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
2881fe6060f1SDimitry Andric    def : Pat<(mti.Mask (riscv_vmnot_vl (riscv_vmor_vl VR:$rs1, VR:$rs2,
2882fe6060f1SDimitry Andric                                                       VLOpFrag),
2883fe6060f1SDimitry Andric                                        VLOpFrag)),
2884fe6060f1SDimitry Andric              (!cast<Instruction>("PseudoVMNOR_MM_" # mti.LMul.MX)
2885fe6060f1SDimitry Andric                   VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
2886fe6060f1SDimitry Andric    def : Pat<(mti.Mask (riscv_vmnot_vl (riscv_vmxor_vl VR:$rs1, VR:$rs2,
2887fe6060f1SDimitry Andric                                                        VLOpFrag),
2888fe6060f1SDimitry Andric                                        VLOpFrag)),
2889fe6060f1SDimitry Andric              (!cast<Instruction>("PseudoVMXNOR_MM_" # mti.LMul.MX)
2890fe6060f1SDimitry Andric                   VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
2891fe6060f1SDimitry Andric
2892fe6060f1SDimitry Andric    // Match the not idiom to the vmnot.m pseudo.
2893fe6060f1SDimitry Andric    def : Pat<(mti.Mask (riscv_vmnot_vl VR:$rs, VLOpFrag)),
2894fe6060f1SDimitry Andric              (!cast<Instruction>("PseudoVMNAND_MM_" # mti.LMul.MX)
2895fe6060f1SDimitry Andric                   VR:$rs, VR:$rs, GPR:$vl, mti.Log2SEW)>;
2896fe6060f1SDimitry Andric
2897bdd1243dSDimitry Andric    // 15.2 Vector count population in mask vcpop.m
2898349cc55cSDimitry Andric    def : Pat<(XLenVT (riscv_vcpop_vl (mti.Mask VR:$rs2), (mti.Mask true_mask),
2899fe6060f1SDimitry Andric                                      VLOpFrag)),
2900349cc55cSDimitry Andric              (!cast<Instruction>("PseudoVCPOP_M_" # mti.BX)
2901fe6060f1SDimitry Andric                   VR:$rs2, GPR:$vl, mti.Log2SEW)>;
2902349cc55cSDimitry Andric    def : Pat<(XLenVT (riscv_vcpop_vl (mti.Mask VR:$rs2), (mti.Mask V0),
2903349cc55cSDimitry Andric                                      VLOpFrag)),
2904349cc55cSDimitry Andric              (!cast<Instruction>("PseudoVCPOP_M_" # mti.BX # "_MASK")
2905349cc55cSDimitry Andric                   VR:$rs2, (mti.Mask V0), GPR:$vl, mti.Log2SEW)>;
2906bdd1243dSDimitry Andric
2907bdd1243dSDimitry Andric    // 15.3 vfirst find-first-set mask bit
2908bdd1243dSDimitry Andric    def : Pat<(XLenVT (riscv_vfirst_vl (mti.Mask VR:$rs2), (mti.Mask true_mask),
2909bdd1243dSDimitry Andric                                      VLOpFrag)),
2910bdd1243dSDimitry Andric              (!cast<Instruction>("PseudoVFIRST_M_" # mti.BX)
2911bdd1243dSDimitry Andric                   VR:$rs2, GPR:$vl, mti.Log2SEW)>;
2912bdd1243dSDimitry Andric    def : Pat<(XLenVT (riscv_vfirst_vl (mti.Mask VR:$rs2), (mti.Mask V0),
2913bdd1243dSDimitry Andric                                      VLOpFrag)),
2914bdd1243dSDimitry Andric              (!cast<Instruction>("PseudoVFIRST_M_" # mti.BX # "_MASK")
2915bdd1243dSDimitry Andric                   VR:$rs2, (mti.Mask V0), GPR:$vl, mti.Log2SEW)>;
2916fe6060f1SDimitry Andric  }
291706c3fb27SDimitry Andric}
2918fe6060f1SDimitry Andric
2919bdd1243dSDimitry Andric// 16. Vector Permutation Instructions
2920bdd1243dSDimitry Andric
2921bdd1243dSDimitry Andric// 16.1. Integer Scalar Move Instructions
29227a6dacacSDimitry Andricforeach vti = NoGroupIntegerVectors in {
292306c3fb27SDimitry Andric  let Predicates = GetVTypePredicates<vti>.Predicates in {
2924fe6060f1SDimitry Andric    def : Pat<(vti.Vector (riscv_vmv_s_x_vl (vti.Vector vti.RegClass:$merge),
2925fe6060f1SDimitry Andric                                            vti.ScalarRegClass:$rs1,
2926fe6060f1SDimitry Andric                                            VLOpFrag)),
29277a6dacacSDimitry Andric              (PseudoVMV_S_X $merge, vti.ScalarRegClass:$rs1, GPR:$vl,
29287a6dacacSDimitry Andric                             vti.Log2SEW)>;
29297a6dacacSDimitry Andric  }
29307a6dacacSDimitry Andric}
2931fe6060f1SDimitry Andric
29327a6dacacSDimitry Andric// 16.4. Vector Register Gather Instruction
29337a6dacacSDimitry Andricforeach vti = AllIntegerVectors in {
29347a6dacacSDimitry Andric  let Predicates = GetVTypePredicates<vti>.Predicates in {
293581ad6265SDimitry Andric    def : Pat<(vti.Vector (riscv_vrgather_vv_vl vti.RegClass:$rs2,
2936fe6060f1SDimitry Andric                                                vti.RegClass:$rs1,
2937fe6060f1SDimitry Andric                                                vti.RegClass:$merge,
2938bdd1243dSDimitry Andric                                                (vti.Mask V0),
2939fe6060f1SDimitry Andric                                                VLOpFrag)),
294006c3fb27SDimitry Andric              (!cast<Instruction>("PseudoVRGATHER_VV_"# vti.LMul.MX#"_E"# vti.SEW#"_MASK")
2941fe6060f1SDimitry Andric                   vti.RegClass:$merge, vti.RegClass:$rs2, vti.RegClass:$rs1,
2942349cc55cSDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
294381ad6265SDimitry Andric    def : Pat<(vti.Vector (riscv_vrgather_vx_vl vti.RegClass:$rs2, GPR:$rs1,
294481ad6265SDimitry Andric                                                vti.RegClass:$merge,
2945bdd1243dSDimitry Andric                                                (vti.Mask V0),
294681ad6265SDimitry Andric                                                VLOpFrag)),
294781ad6265SDimitry Andric              (!cast<Instruction>("PseudoVRGATHER_VX_"# vti.LMul.MX#"_MASK")
294881ad6265SDimitry Andric                   vti.RegClass:$merge, vti.RegClass:$rs2, GPR:$rs1,
294981ad6265SDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
295081ad6265SDimitry Andric    def : Pat<(vti.Vector (riscv_vrgather_vx_vl vti.RegClass:$rs2,
2951349cc55cSDimitry Andric                                                uimm5:$imm,
2952349cc55cSDimitry Andric                                                vti.RegClass:$merge,
2953bdd1243dSDimitry Andric                                                (vti.Mask V0),
2954349cc55cSDimitry Andric                                                VLOpFrag)),
2955349cc55cSDimitry Andric              (!cast<Instruction>("PseudoVRGATHER_VI_"# vti.LMul.MX#"_MASK")
2956349cc55cSDimitry Andric                   vti.RegClass:$merge, vti.RegClass:$rs2, uimm5:$imm,
2957349cc55cSDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
295806c3fb27SDimitry Andric  }
2959fe6060f1SDimitry Andric
2960fe6060f1SDimitry Andric  // emul = lmul * 16 / sew
2961fe6060f1SDimitry Andric  defvar vlmul = vti.LMul;
2962fe6060f1SDimitry Andric  defvar octuple_lmul = vlmul.octuple;
2963fe6060f1SDimitry Andric  defvar octuple_emul = !srl(!mul(octuple_lmul, 16), vti.Log2SEW);
2964fe6060f1SDimitry Andric  if !and(!ge(octuple_emul, 1), !le(octuple_emul, 64)) then {
2965fe6060f1SDimitry Andric    defvar emul_str = octuple_to_str<octuple_emul>.ret;
2966fe6060f1SDimitry Andric    defvar ivti = !cast<VTypeInfo>("VI16" # emul_str);
296706c3fb27SDimitry Andric    defvar inst = "PseudoVRGATHEREI16_VV_" # vti.LMul.MX # "_E" # vti.SEW # "_" # emul_str;
296806c3fb27SDimitry Andric    let Predicates = GetVTypePredicates<vti>.Predicates in
296981ad6265SDimitry Andric    def : Pat<(vti.Vector
297081ad6265SDimitry Andric               (riscv_vrgatherei16_vv_vl vti.RegClass:$rs2,
2971fe6060f1SDimitry Andric                                         (ivti.Vector ivti.RegClass:$rs1),
2972fe6060f1SDimitry Andric                                         vti.RegClass:$merge,
2973bdd1243dSDimitry Andric                                         (vti.Mask V0),
2974fe6060f1SDimitry Andric                                         VLOpFrag)),
2975fe6060f1SDimitry Andric              (!cast<Instruction>(inst#"_MASK")
2976fe6060f1SDimitry Andric                   vti.RegClass:$merge, vti.RegClass:$rs2, ivti.RegClass:$rs1,
2977349cc55cSDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
2978fe6060f1SDimitry Andric  }
2979fe6060f1SDimitry Andric}
2980fe6060f1SDimitry Andric
2981bdd1243dSDimitry Andric// 16.2. Floating-Point Scalar Move Instructions
29827a6dacacSDimitry Andricforeach vti = NoGroupFloatVectors in {
298306c3fb27SDimitry Andric  let Predicates = GetVTypePredicates<vti>.Predicates in {
2984fe6060f1SDimitry Andric    def : Pat<(vti.Vector (riscv_vfmv_s_f_vl (vti.Vector vti.RegClass:$merge),
298504eeddc0SDimitry Andric                                             (vti.Scalar (fpimm0)),
298604eeddc0SDimitry Andric                                             VLOpFrag)),
29877a6dacacSDimitry Andric              (PseudoVMV_S_X $merge, (XLenVT X0), GPR:$vl, vti.Log2SEW)>;
298806c3fb27SDimitry Andric    def : Pat<(vti.Vector (riscv_vfmv_s_f_vl (vti.Vector vti.RegClass:$merge),
298906c3fb27SDimitry Andric                                             (vti.Scalar (SelectFPImm (XLenVT GPR:$imm))),
299006c3fb27SDimitry Andric                                             VLOpFrag)),
29917a6dacacSDimitry Andric              (PseudoVMV_S_X $merge, GPR:$imm, GPR:$vl, vti.Log2SEW)>;
29927a6dacacSDimitry Andric  }
29937a6dacacSDimitry Andric}
29947a6dacacSDimitry Andric
29957a6dacacSDimitry Andricforeach vti = AllFloatVectors in {
29967a6dacacSDimitry Andric  let Predicates = GetVTypePredicates<vti>.Predicates in {
299704eeddc0SDimitry Andric    def : Pat<(vti.Vector (riscv_vfmv_s_f_vl (vti.Vector vti.RegClass:$merge),
2998fe6060f1SDimitry Andric                                             vti.ScalarRegClass:$rs1,
2999fe6060f1SDimitry Andric                                             VLOpFrag)),
3000fe6060f1SDimitry Andric              (!cast<Instruction>("PseudoVFMV_S_"#vti.ScalarSuffix#"_"#vti.LMul.MX)
3001fe6060f1SDimitry Andric                  vti.RegClass:$merge,
3002fe6060f1SDimitry Andric                  (vti.Scalar vti.ScalarRegClass:$rs1), GPR:$vl, vti.Log2SEW)>;
300306c3fb27SDimitry Andric  }
3004fe6060f1SDimitry Andric  defvar ivti = GetIntVTypeInfo<vti>.Vti;
3005*0fca6ea1SDimitry Andric  let Predicates = GetVTypePredicates<ivti>.Predicates in {
300681ad6265SDimitry Andric    def : Pat<(vti.Vector
300781ad6265SDimitry Andric               (riscv_vrgather_vv_vl vti.RegClass:$rs2,
3008fe6060f1SDimitry Andric                                     (ivti.Vector vti.RegClass:$rs1),
3009fe6060f1SDimitry Andric                                     vti.RegClass:$merge,
3010bdd1243dSDimitry Andric                                     (vti.Mask V0),
3011fe6060f1SDimitry Andric                                     VLOpFrag)),
301206c3fb27SDimitry Andric              (!cast<Instruction>("PseudoVRGATHER_VV_"# vti.LMul.MX#"_E"# vti.SEW#"_MASK")
3013fe6060f1SDimitry Andric                   vti.RegClass:$merge, vti.RegClass:$rs2, vti.RegClass:$rs1,
3014349cc55cSDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
301581ad6265SDimitry Andric    def : Pat<(vti.Vector (riscv_vrgather_vx_vl vti.RegClass:$rs2, GPR:$rs1,
301681ad6265SDimitry Andric                                                vti.RegClass:$merge,
3017bdd1243dSDimitry Andric                                                (vti.Mask V0),
301881ad6265SDimitry Andric                                                VLOpFrag)),
301981ad6265SDimitry Andric              (!cast<Instruction>("PseudoVRGATHER_VX_"# vti.LMul.MX#"_MASK")
302081ad6265SDimitry Andric                   vti.RegClass:$merge, vti.RegClass:$rs2, GPR:$rs1,
302181ad6265SDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
302281ad6265SDimitry Andric    def : Pat<(vti.Vector
302381ad6265SDimitry Andric               (riscv_vrgather_vx_vl vti.RegClass:$rs2,
3024349cc55cSDimitry Andric                                     uimm5:$imm,
3025349cc55cSDimitry Andric                                     vti.RegClass:$merge,
3026bdd1243dSDimitry Andric                                     (vti.Mask V0),
3027349cc55cSDimitry Andric                                     VLOpFrag)),
3028349cc55cSDimitry Andric              (!cast<Instruction>("PseudoVRGATHER_VI_"# vti.LMul.MX#"_MASK")
3029349cc55cSDimitry Andric                   vti.RegClass:$merge, vti.RegClass:$rs2, uimm5:$imm,
3030349cc55cSDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
303106c3fb27SDimitry Andric  }
3032fe6060f1SDimitry Andric
3033fe6060f1SDimitry Andric  defvar vlmul = vti.LMul;
3034fe6060f1SDimitry Andric  defvar octuple_lmul = vlmul.octuple;
3035fe6060f1SDimitry Andric  defvar octuple_emul = !srl(!mul(octuple_lmul, 16), vti.Log2SEW);
3036fe6060f1SDimitry Andric  if !and(!ge(octuple_emul, 1), !le(octuple_emul, 64)) then {
3037fe6060f1SDimitry Andric    defvar emul_str = octuple_to_str<octuple_emul>.ret;
3038fe6060f1SDimitry Andric    defvar ivti = !cast<VTypeInfo>("VI16" # emul_str);
303906c3fb27SDimitry Andric    defvar inst = "PseudoVRGATHEREI16_VV_" # vti.LMul.MX # "_E" # vti.SEW # "_" # emul_str;
304006c3fb27SDimitry Andric    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
304106c3fb27SDimitry Andric                                 GetVTypePredicates<ivti>.Predicates) in
304281ad6265SDimitry Andric    def : Pat<(vti.Vector
304381ad6265SDimitry Andric               (riscv_vrgatherei16_vv_vl vti.RegClass:$rs2,
3044fe6060f1SDimitry Andric                                         (ivti.Vector ivti.RegClass:$rs1),
3045fe6060f1SDimitry Andric                                         vti.RegClass:$merge,
3046bdd1243dSDimitry Andric                                         (vti.Mask V0),
3047fe6060f1SDimitry Andric                                         VLOpFrag)),
3048fe6060f1SDimitry Andric              (!cast<Instruction>(inst#"_MASK")
3049fe6060f1SDimitry Andric                   vti.RegClass:$merge, vti.RegClass:$rs2, ivti.RegClass:$rs1,
3050349cc55cSDimitry Andric                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
3051fe6060f1SDimitry Andric  }
3052fe6060f1SDimitry Andric}
3053fe6060f1SDimitry Andric
3054fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
3055fe6060f1SDimitry Andric// Miscellaneous RISCVISD SDNodes
3056fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
3057fe6060f1SDimitry Andric
3058fe6060f1SDimitry Andricdef riscv_vid_vl : SDNode<"RISCVISD::VID_VL", SDTypeProfile<1, 2,
3059fe6060f1SDimitry Andric                          [SDTCisVec<0>, SDTCVecEltisVT<1, i1>,
3060fe6060f1SDimitry Andric                           SDTCisSameNumEltsAs<0, 1>, SDTCisVT<2, XLenVT>]>, []>;
3061fe6060f1SDimitry Andric
3062bdd1243dSDimitry Andricdef SDTRVVSlide : SDTypeProfile<1, 6, [
3063fe6060f1SDimitry Andric  SDTCisVec<0>, SDTCisSameAs<1, 0>, SDTCisSameAs<2, 0>, SDTCisVT<3, XLenVT>,
3064bdd1243dSDimitry Andric  SDTCVecEltisVT<4, i1>, SDTCisSameNumEltsAs<0, 4>, SDTCisVT<5, XLenVT>,
3065bdd1243dSDimitry Andric  SDTCisVT<6, XLenVT>
3066fe6060f1SDimitry Andric]>;
306781ad6265SDimitry Andricdef SDTRVVSlide1 : SDTypeProfile<1, 5, [
306881ad6265SDimitry Andric  SDTCisVec<0>, SDTCisSameAs<1, 0>, SDTCisSameAs<2, 0>, SDTCisInt<0>,
306981ad6265SDimitry Andric  SDTCisVT<3, XLenVT>, SDTCVecEltisVT<4, i1>, SDTCisSameNumEltsAs<0, 4>,
307081ad6265SDimitry Andric  SDTCisVT<5, XLenVT>
3071fe6060f1SDimitry Andric]>;
307206c3fb27SDimitry Andricdef SDTRVVFSlide1 : SDTypeProfile<1, 5, [
307306c3fb27SDimitry Andric  SDTCisVec<0>, SDTCisSameAs<1, 0>, SDTCisSameAs<2, 0>, SDTCisFP<0>,
307406c3fb27SDimitry Andric  SDTCisEltOfVec<3, 0>, SDTCVecEltisVT<4, i1>, SDTCisSameNumEltsAs<0, 4>,
307506c3fb27SDimitry Andric  SDTCisVT<5, XLenVT>
307606c3fb27SDimitry Andric]>;
3077fe6060f1SDimitry Andric
3078fe6060f1SDimitry Andricdef riscv_slideup_vl   : SDNode<"RISCVISD::VSLIDEUP_VL", SDTRVVSlide, []>;
3079fe6060f1SDimitry Andricdef riscv_slide1up_vl  : SDNode<"RISCVISD::VSLIDE1UP_VL", SDTRVVSlide1, []>;
3080fe6060f1SDimitry Andricdef riscv_slidedown_vl : SDNode<"RISCVISD::VSLIDEDOWN_VL", SDTRVVSlide, []>;
3081fe6060f1SDimitry Andricdef riscv_slide1down_vl  : SDNode<"RISCVISD::VSLIDE1DOWN_VL", SDTRVVSlide1, []>;
308206c3fb27SDimitry Andricdef riscv_fslide1up_vl  : SDNode<"RISCVISD::VFSLIDE1UP_VL", SDTRVVFSlide1, []>;
308306c3fb27SDimitry Andricdef riscv_fslide1down_vl  : SDNode<"RISCVISD::VFSLIDE1DOWN_VL", SDTRVVFSlide1, []>;
3084fe6060f1SDimitry Andric
3085fe6060f1SDimitry Andricforeach vti = AllIntegerVectors in {
308606c3fb27SDimitry Andric  let Predicates = GetVTypePredicates<vti>.Predicates in {
308706c3fb27SDimitry Andric    def : Pat<(vti.Vector (riscv_vid_vl (vti.Mask V0),
3088fe6060f1SDimitry Andric                                        VLOpFrag)),
308906c3fb27SDimitry Andric              (!cast<Instruction>("PseudoVID_V_"#vti.LMul.MX#"_MASK")
309006c3fb27SDimitry Andric                  (vti.Vector (IMPLICIT_DEF)), (vti.Mask V0), GPR:$vl, vti.Log2SEW,
309106c3fb27SDimitry Andric                  TAIL_AGNOSTIC)>;
309206c3fb27SDimitry Andric  }
3093fe6060f1SDimitry Andric}
3094fe6060f1SDimitry Andric
30955f757f3fSDimitry Andricdefm : VPatSlideVL_VX_VI<riscv_slideup_vl, "PseudoVSLIDEUP">;
30965f757f3fSDimitry Andricdefm : VPatSlideVL_VX_VI<riscv_slidedown_vl, "PseudoVSLIDEDOWN">;
30975f757f3fSDimitry Andricdefm : VPatSlide1VL_VX<riscv_slide1up_vl, "PseudoVSLIDE1UP">;
30985f757f3fSDimitry Andricdefm : VPatSlide1VL_VF<riscv_fslide1up_vl, "PseudoVFSLIDE1UP">;
30995f757f3fSDimitry Andricdefm : VPatSlide1VL_VX<riscv_slide1down_vl, "PseudoVSLIDE1DOWN">;
31005f757f3fSDimitry Andricdefm : VPatSlide1VL_VF<riscv_fslide1down_vl, "PseudoVFSLIDE1DOWN">;
3101