namespace llvm {
+/// \returns the VVP_* SDNode opcode corresponsing to \p OC.
+Optional<unsigned> getVVPOpcode(unsigned Opcode) {
+ switch (Opcode) {
+#define HANDLE_VP_TO_VVP(VPOPC, VVPNAME) \
+ case ISD::VPOPC: \
+ return VEISD::VVPNAME;
+#define ADD_VVP_OP(VVPNAME, SDNAME) \
+ case VEISD::VVPNAME: \
+ case ISD::SDNAME: \
+ return VEISD::VVPNAME;
+#include "VVPNodes.def"
+ }
+ return None;
+}
+
+bool isVVPBinaryOp(unsigned VVPOpcode) {
+ switch (VVPOpcode) {
+#define ADD_BINARY_VVP_OP(VVPNAME, ...) \
+ case VEISD::VVPNAME: \
+ return true;
+#include "VVPNodes.def"
+ }
+ return false;
+}
+
SDValue VECustomDAG::getConstant(uint64_t Val, EVT VT, bool IsTarget,
bool IsOpaque) const {
return DAG.getConstant(Val, DL, VT, IsTarget, IsOpaque);
}
+SDValue VECustomDAG::getBroadcast(EVT ResultVT, SDValue Scalar,
+ SDValue AVL) const {
+ return getNode(VEISD::VEC_BROADCAST, ResultVT, {Scalar, AVL});
+}
+
} // namespace llvm
MVT LegalResVT = MVT::getVectorVT(ElemVT, 256);
auto AVL = CDAG.getConstant(NumEls, MVT::i32);
- return CDAG.getNode(VEISD::VEC_BROADCAST, LegalResVT,
- {Op.getOperand(0), AVL});
+ return CDAG.getBroadcast(LegalResVT, Op.getOperand(0), AVL);
}
// Expand
return true;
}
-/// \returns the VVP_* SDNode opcode corresponsing to \p OC.
-static Optional<unsigned> getVVPOpcode(unsigned Opcode) {
- switch (Opcode) {
-#define HANDLE_VP_TO_VVP(VPOPC, VVPNAME) \
- case ISD::VPOPC: \
- return VEISD::VVPNAME;
-#define ADD_VVP_OP(VVPNAME, SDNAME) \
- case VEISD::VVPNAME: \
- case ISD::SDNAME: \
- return VEISD::VVPNAME;
-#include "VVPNodes.def"
- }
- return None;
-}
-
SDValue VETargetLowering::lowerToVVP(SDValue Op, SelectionDAG &DAG) const {
// Can we represent this as a VVP node.
const unsigned Opcode = Op->getOpcode();
// Materialize the VL parameter.
AVL = CDAG.getConstant(OpVecVT.getVectorNumElements(), MVT::i32);
SDValue ConstTrue = CDAG.getConstant(1, MVT::i32);
- Mask = CDAG.getNode(VEISD::VEC_BROADCAST, MaskVT,
- ConstTrue); // emit a VEISD::VEC_BROADCAST here.
+ Mask = CDAG.getBroadcast(MaskVT, ConstTrue, AVL);
}
- // Categories we are interested in.
- bool IsBinaryOp = false;
-
- switch (VVPOpcode) {
-#define ADD_BINARY_VVP_OP(VVPNAME, ...) \
- case VEISD::VVPNAME: \
- IsBinaryOp = true; \
- break;
-#include "VVPNodes.def"
- }
-
- if (IsBinaryOp) {
+ if (isVVPBinaryOp(VVPOpcode)) {
assert(LegalVecVT.isSimple());
return CDAG.getNode(VVPOpcode, LegalVecVT,
{Op->getOperand(0), Op->getOperand(1), Mask, AVL});
- } else if (VVPOpcode == VEISD::VVP_SELECT) {
+ }
+ if (VVPOpcode == VEISD::VVP_SELECT) {
auto Mask = Op->getOperand(0);
auto OnTrue = Op->getOperand(1);
auto OnFalse = Op->getOperand(2);