1 //===-------------- VVPInstrInfo.td - VVP_* SDNode patterns ---------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines the VE Vector Predicated SDNodes (VVP SDNodes). VVP
10 // SDNodes are an intermediate isel layer between the vector SDNodes emitted by
11 // LLVM and the actual VE vector instructions. For example:
13 // ADD(x,y) --> VVP_ADD(x,y,mask,evl) --> VADDSWSXrvml(x,y,mask,evl)
15 // The standard The VVP layer SDNode. The VE vector instruction.
18 // TODO explain how VVP nodes relate to VP SDNodes once VP ISel is uptream.
19 //===----------------------------------------------------------------------===//
21 // vvp_load(ptr, stride, mask, avl)
22 def SDTLoadVVP : SDTypeProfile<1, 4, [
30 // vvp_store(data, ptr, stride, mask, avl)
31 def SDTStoreVVP: SDTypeProfile<0, 5, [
39 // vvp_scatter(chain, data, addr, mask, avl)
40 def SDTScatterVVP: SDTypeProfile<0, 4, [
44 SDTCisSameNumEltsAs<0, 2>,
48 // vvp_gather(chain, addr, mask, avl)
49 def SDTGatherVVP: SDTypeProfile<1, 3, [
52 SDTCisSameNumEltsAs<0, 2>,
56 // BinaryOp(x,y,mask,vl)
57 def SDTIntBinOpVVP : SDTypeProfile<1, 4, [ // vp_add, vp_and, etc.
61 SDTCisSameNumEltsAs<0, 3>,
65 // UnaryFPOp(x,mask,vl)
66 def SDTFPUnaryOpVVP : SDTypeProfile<1, 3, [
70 SDTCisSameNumEltsAs<0, 2>,
74 // BinaryFPOp(x,y,mask,vl)
75 def SDTFPBinOpVVP : SDTypeProfile<1, 4, [ // vvp_fadd, etc.
80 SDTCisSameNumEltsAs<0, 3>,
84 // TernaryFPOp(x,y,z,mask,vl)
85 def SDTFPTernaryOpVVP : SDTypeProfile<1, 5, [
91 SDTCisSameNumEltsAs<0, 4>,
95 // Select(OnTrue, OnFalse, SelMask, vl)
96 def SDTSelectVVP : SDTypeProfile<1, 4, [ // vp_select, vp_merge
98 SDTCisSameNumEltsAs<0, 3>,
104 // SetCC (lhs, rhs, cc, mask, vl)
105 def SDTSetCCVVP : SDTypeProfile<1, 5, [ // vp_setcc
108 SDTCisSameNumEltsAs<0, 1>,
110 SDTCisVT<3, OtherVT>,
112 SDTCisSameNumEltsAs<0, 4>,
116 // vvp_reduce(vector, mask, vl)
117 def SDTReduceVVP : SDTypeProfile<1, 3, [
121 SDTCisSameNumEltsAs<1,2>,
126 // Binary operator commutative pattern.
127 class vvp_commutative<SDNode RootOp> :
129 (ops node:$lhs, node:$rhs, node:$mask, node:$vlen),
130 [(RootOp node:$lhs, node:$rhs, node:$mask, node:$vlen),
131 (RootOp node:$rhs, node:$lhs, node:$mask, node:$vlen)]>;
133 class vvp_fma_commutative<SDNode RootOp> :
135 (ops node:$X, node:$Y, node:$Z, node:$mask, node:$vlen),
136 [(RootOp node:$X, node:$Y, node:$Z, node:$mask, node:$vlen),
137 (RootOp node:$X, node:$Z, node:$Y, node:$mask, node:$vlen)]>;
139 // VVP node definitions.
140 def vvp_add : SDNode<"VEISD::VVP_ADD", SDTIntBinOpVVP>;
141 def c_vvp_add : vvp_commutative<vvp_add>;
143 def vvp_sub : SDNode<"VEISD::VVP_SUB", SDTIntBinOpVVP>;
145 def vvp_mul : SDNode<"VEISD::VVP_MUL", SDTIntBinOpVVP>;
146 def c_vvp_mul : vvp_commutative<vvp_mul>;
148 def vvp_sdiv : SDNode<"VEISD::VVP_SDIV", SDTIntBinOpVVP>;
149 def vvp_udiv : SDNode<"VEISD::VVP_UDIV", SDTIntBinOpVVP>;
151 def vvp_and : SDNode<"VEISD::VVP_AND", SDTIntBinOpVVP>;
152 def c_vvp_and : vvp_commutative<vvp_and>;
154 def vvp_or : SDNode<"VEISD::VVP_OR", SDTIntBinOpVVP>;
155 def c_vvp_or : vvp_commutative<vvp_or>;
157 def vvp_xor : SDNode<"VEISD::VVP_XOR", SDTIntBinOpVVP>;
158 def c_vvp_xor : vvp_commutative<vvp_xor>;
160 def vvp_srl : SDNode<"VEISD::VVP_SRL", SDTIntBinOpVVP>;
161 def vvp_sra : SDNode<"VEISD::VVP_SRA", SDTIntBinOpVVP>;
162 def vvp_shl : SDNode<"VEISD::VVP_SHL", SDTIntBinOpVVP>;
164 def vvp_fneg : SDNode<"VEISD::VVP_FNEG", SDTFPUnaryOpVVP>;
166 def vvp_fadd : SDNode<"VEISD::VVP_FADD", SDTFPBinOpVVP>;
167 def c_vvp_fadd : vvp_commutative<vvp_fadd>;
168 def vvp_fsub : SDNode<"VEISD::VVP_FSUB", SDTFPBinOpVVP>;
169 def vvp_fmul : SDNode<"VEISD::VVP_FMUL", SDTFPBinOpVVP>;
170 def c_vvp_fmul : vvp_commutative<vvp_fmul>;
171 def vvp_fdiv : SDNode<"VEISD::VVP_FDIV", SDTFPBinOpVVP>;
173 def vvp_ffma : SDNode<"VEISD::VVP_FFMA", SDTFPTernaryOpVVP>;
174 def c_vvp_ffma : vvp_fma_commutative<vvp_ffma>;
176 def vvp_scatter : SDNode<"VEISD::VVP_SCATTER", SDTScatterVVP,
177 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
178 def vvp_gather : SDNode<"VEISD::VVP_GATHER", SDTGatherVVP,
179 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
181 def vvp_load : SDNode<"VEISD::VVP_LOAD", SDTLoadVVP,
182 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand ]>;
183 def vvp_store : SDNode<"VEISD::VVP_STORE", SDTStoreVVP,
184 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
189 def vvp_reduce_add : SDNode<"VEISD::VVP_REDUCE_ADD", SDTReduceVVP>;
190 def vvp_reduce_and : SDNode<"VEISD::VVP_REDUCE_AND", SDTReduceVVP>;
191 def vvp_reduce_or : SDNode<"VEISD::VVP_REDUCE_OR", SDTReduceVVP>;
192 def vvp_reduce_xor : SDNode<"VEISD::VVP_REDUCE_XOR", SDTReduceVVP>;
193 def vvp_reduce_smax : SDNode<"VEISD::VVP_REDUCE_SMAX", SDTReduceVVP>;
196 def vvp_select : SDNode<"VEISD::VVP_SELECT", SDTSelectVVP>;
198 // setcc (lhs, rhs, cc, mask, vl)
199 def vvp_setcc : SDNode<"VEISD::VVP_SETCC", SDTSetCCVVP>;