18#define DEBUG_TYPE "vecustomdag"
52 switch (
Op.getOpcode()) {
66 return VEISD::VVP_LOAD;
68 return VEISD::VVP_STORE;
69#define HANDLE_VP_TO_VVP(VPOPC, VVPNAME) \
71 return VEISD::VVPNAME;
72#define ADD_VVP_OP(VVPNAME, SDNAME) \
73 case VEISD::VVPNAME: \
75 return VEISD::VVPNAME;
76#include "VVPNodes.def"
78 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
79 return VEISD::VVP_LOAD;
80 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
81 return VEISD::VVP_STORE;
88 auto Opc = VVPOpc.value_or(
Op->getOpcode());
94 case VEISD::VVP_SELECT:
109 case VEISD::VEC_BROADCAST:
111#define REGISTER_PACKED(VVP_NAME) case VEISD::VVP_NAME:
112#include "VVPNodes.def"
113 return IsPackedOp && !IsMaskOp;
119 case VEISD::VEC_PACK:
120 case VEISD::VEC_UNPACK_LO:
121 case VEISD::VEC_UNPACK_HI:
129 case VEISD::VEC_BROADCAST:
130#define ADD_VVP_OP(VVPNAME, ...) case VEISD::VVPNAME:
131#include "VVPNodes.def"
139#define ADD_UNARY_VVP_OP(VVPNAME, ...) \
140 case VEISD::VVPNAME: \
142#include "VVPNodes.def"
149#define ADD_BINARY_VVP_OP(VVPNAME, ...) \
150 case VEISD::VVPNAME: \
152#include "VVPNodes.def"
159#define ADD_REDUCE_VVP_OP(VVP_NAME, SDNAME) case VEISD::VVP_NAME:
160#include "VVPNodes.def"
179 case VEISD::VEC_BROADCAST:
181 case VEISD::VVP_SELECT:
183 case VEISD::VVP_LOAD:
185 case VEISD::VVP_STORE:
208 case VEISD::VVP_SELECT:
221 return MemN->getChain();
223 switch (
Op->getOpcode()) {
224 case VEISD::VVP_LOAD:
225 case VEISD::VVP_STORE:
226 return Op->getOperand(0);
233 return MemN->getBasePtr();
235 switch (
Op->getOpcode()) {
236 case VEISD::VVP_LOAD:
237 return Op->getOperand(1);
238 case VEISD::VVP_STORE:
239 return Op->getOperand(2);
245 unsigned OC =
Op->getOpcode();
249 return MemN->getMemoryVT();
259 return Op->getValueType(0);
263 unsigned OriginalOC = OC;
273 case VEISD::VVP_SETCC:
274 return Op->getOperand(0).getValueType();
276 case VEISD::VVP_SELECT:
277#define ADD_BINARY_VVP_OP(VVP_NAME, ...) case VEISD::VVP_NAME:
278#include "VVPNodes.def"
279 return Op->getValueType(0);
281 case VEISD::VVP_LOAD:
282 return Op->getValueType(0);
284 case VEISD::VVP_STORE:
285 return Op->getOperand(1)->getValueType(0);
288 case VEISD::VEC_BROADCAST:
289 return Op->getValueType(0);
294 switch (
Op->getOpcode()) {
295 case VEISD::VVP_STORE:
296 return Op->getOperand(3);
297 case VEISD::VVP_LOAD:
298 return Op->getOperand(2);
302 return StoreN->getStride();
304 return StoreN->getStride();
310 ->getVectorElementType()
319 return N->getIndex();
321 return N->getIndex();
327 return N->getScale();
329 return N->getScale();
334 switch (
Op->getOpcode()) {
335 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
336 case VEISD::VVP_STORE:
337 return Op->getOperand(1);
340 return StoreN->getValue();
342 return StoreN->getValue();
344 return StoreN->getValue();
346 return StoreN->getValue();
348 return StoreN->getValue();
350 return StoreN->getValue();
356 return N->getPassThru();
358 return N->getPassThru();
371 assert(!IsMask &&
"Mask reduction isel");
374#define HANDLE_VVP_REDUCE_TO_SCALAR(VVP_RED_ISD, REDUCE_ISD) \
375 case VEISD::VVP_RED_ISD: \
376 return ISD::REDUCE_ISD;
377#include "VVPNodes.def"
388 return PosOpt ?
Op->getOperand(*PosOpt) :
SDValue();
393 return PosOpt ?
Op->getOperand(*PosOpt) :
SDValue();
406 bool IsOpaque)
const {
407 return DAG.getConstant(Val, DL, VT, IsTarget, IsOpaque);
414 auto TrueVal = DAG.getAllOnesConstant(DL, MVT::i32);
415 auto AVL =
getConstant(MaskVT.getVectorNumElements(), MVT::i32);
416 auto Res =
getNode(VEISD::VEC_BROADCAST, MaskVT, {TrueVal, AVL});
420 return DAG.getNOT(DL, Res, Res.getValueType());
428 BcConst->getSExtValue() != 0);
431 auto ScalarBoolVT = Scalar.getSimpleValueType();
432 assert(ScalarBoolVT == MVT::i32);
435 SDValue CmpElem = DAG.getSExtOrTrunc(Scalar, DL, MVT::i32);
441 DAG.
getNode(VEISD::VEC_BROADCAST, DL, CmpVecTy, {CmpElem, AVL});
443 getBroadcast(CmpVecTy, {DAG.getConstant(0, DL, ScalarBoolVT)}, AVL);
455 auto ScaVT = Scalar.getValueType();
465 if (ScaVT == MVT::f32) {
466 Scalar =
getNode(VEISD::REPL_F32, MVT::i64, Scalar);
467 }
else if (ScaVT == MVT::i32) {
468 Scalar =
getNode(VEISD::REPL_I32, MVT::i64, Scalar);
472 return getNode(VEISD::VEC_BROADCAST, ResultVT, {Scalar, AVL});
487 (Part ==
PackElem::Lo) ? VEISD::VEC_UNPACK_LO : VEISD::VEC_UNPACK_HI;
488 return DAG.getNode(OC, DL, DestVT, Vec, AVL);
496 return DAG.getNode(VEISD::VEC_PACK, DL, DestVT, LoVec, HiVec, AVL);
517 NewMask =
getUnpack(MVT::v256i1, RawMask, Part, NewAVL);
533 return getConstant(2 * ConstBytes->getSExtValue(), MVT::i64);
540 EVT IndexVT = Index.getValueType();
549 getNode(VEISD::VVP_MUL, IndexVT, {Index, ScaleBroadcast, Mask, AVL});
559 getNode(VEISD::VVP_ADD, IndexVT, {BaseBroadcast, ScaledIndex, Mask, AVL});
572 assert(!IsMaskReduction &&
"TODO Implement");
573 auto AttachStartValue = [&](
SDValue ReductionResV) {
574 if (!scalarizeStartParam)
575 return ReductionResV;
577 return getNode(ScalarOC, ResVT, {StartV, ReductionResV});
581 if (!scalarizeStartParam && StartV) {
583 return AttachStartValue(
584 getNode(VVPOpcode, ResVT, {StartV, VectorV, Mask, AVL}, Flags));
586 return AttachStartValue(
587 getNode(VVPOpcode, ResVT, {VectorV, Mask, AVL}, Flags));
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
bool isVector() const
Return true if this is a vector value type.
static MVT getVectorVT(MVT VT, unsigned NumElements)
MVT getVectorElementType() const
This is an abstract virtual class for memory operations.
Represents one node in the SelectionDAG.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
const SDValue & getOperand(unsigned Num) const
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
EVT getValueType() const
Return the ValueType of the referenced return value.
SDValue getSplitPtrOffset(SDValue Ptr, SDValue ByteStride, PackElem Part) const
SDValue getBroadcast(EVT ResultVT, SDValue Scalar, SDValue AVL) const
SDValue getConstantMask(Packing Packing, bool AllTrue) const
SDValue getGatherScatterAddress(SDValue BasePtr, SDValue Scale, SDValue Index, SDValue Mask, SDValue AVL) const
SDValue getMaskBroadcast(EVT ResultVT, SDValue Scalar, SDValue AVL) const
SDValue getLegalReductionOpVVP(unsigned VVPOpcode, EVT ResVT, SDValue StartV, SDValue VectorV, SDValue Mask, SDValue AVL, SDNodeFlags Flags) const
} getNode
SDValue getNode(unsigned OC, SDVTList VTL, ArrayRef< SDValue > OpV, std::optional< SDNodeFlags > Flags=std::nullopt) const
getNode {
SDValue annotateLegalAVL(SDValue AVL) const
SDValue getUnpack(EVT DestVT, SDValue Vec, PackElem Part, SDValue AVL) const
} Legalizing getNode
SDValue getPack(EVT DestVT, SDValue LoVec, SDValue HiVec, SDValue AVL) const
SDValue getConstant(uint64_t Val, EVT VT, bool IsTarget=false, bool IsOpaque=false) const
SDValue getSplitPtrStride(SDValue PackStride) const
VETargetMasks getTargetSplitMask(SDValue RawMask, SDValue RawAVL, PackElem Part) const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ ADD
Simple integer binary arithmetic operators.
@ CONCAT_VECTORS
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
@ SCALAR_TO_VECTOR
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ SHL
Shift and rotation operations.
@ VECTOR_SHUFFLE
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
@ EXTRACT_SUBVECTOR
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
LLVM_ABI std::optional< unsigned > getVPMaskIdx(unsigned Opcode)
The operand position of the vector mask.
LLVM_ABI std::optional< unsigned > getVPExplicitVectorLengthIdx(unsigned Opcode)
The operand position of the explicit vector length parameter.
LLVM_ABI bool isVPReduction(unsigned Opcode)
Whether this is a vector-predicated reduction opcode.
This is an optimization pass for GlobalISel generic memory operations.
bool isVVPReductionOp(unsigned Opcode)
bool isPackedVectorType(EVT SomeVT)
bool supportsPackedMode(unsigned Opcode, EVT IdiomVT)
std::optional< int > getAVLPos(unsigned Opc)
The VE backend uses a two-staged process to lower and legalize vector instructions:
LLVM_ABI bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
SDValue getGatherScatterScale(SDValue Op)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
SDValue getStoredValue(SDValue Op)
bool isVVPBinaryOp(unsigned VVPOpcode)
std::optional< EVT > getIdiomaticVectorType(SDNode *Op)
} AVL Functions
SDValue getNodeChain(SDValue Op)
Node Properties {.
static const unsigned StandardVectorWidth
static const unsigned PackedVectorWidth
bool isMaskArithmetic(SDValue Op)
SDValue getNodeAVL(SDValue Op)
} Node Properties
bool isMaskType(EVT SomeVT)
bool isLegalAVL(SDValue AVL)
MVT splitVectorType(MVT VT)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
SDValue getNodePassthru(SDValue Op)
bool maySafelyIgnoreMask(SDValue Op)
bool isVVPOrVEC(unsigned Opcode)
MVT getLegalVectorType(Packing P, MVT ElemVT)
SDValue getMemoryPtr(SDValue Op)
std::optional< int > getMaskPos(unsigned Opc)
bool isPackingSupportOpcode(unsigned Opc)
std::pair< SDValue, bool > getAnnotatedNodeAVL(SDValue Op)
DWARFExpression::Operation Op
LLVM_ABI bool isOneConstant(SDValue V)
Returns true if V is a constant integer one.
bool hasReductionStartParam(unsigned OPC)
SDValue getGatherScatterIndex(SDValue Op)
Packing getTypePacking(EVT VT)
unsigned getScalarReductionOpcode(unsigned VVPOC, bool IsMask)
std::optional< unsigned > getVVPOpcode(unsigned Opcode)
bool isVVPUnaryOp(unsigned VVPOpcode)
SDValue getNodeMask(SDValue Op)
SDValue getLoadStoreStride(SDValue Op, VECustomDAG &CDAG)
bool isVector() const
Return true if this is a vector value type.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
These are IR-level optimization flags that may be propagated to SDNodes.