17#define DEBUG_TYPE "vecustomdag"
51 switch (
Op.getOpcode()) {
65 return VEISD::VVP_LOAD;
67 return VEISD::VVP_STORE;
68#define HANDLE_VP_TO_VVP(VPOPC, VVPNAME) \
70 return VEISD::VVPNAME;
71#define ADD_VVP_OP(VVPNAME, SDNAME) \
72 case VEISD::VVPNAME: \
74 return VEISD::VVPNAME;
75#include "VVPNodes.def"
77 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
78 return VEISD::VVP_LOAD;
79 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
80 return VEISD::VVP_STORE;
87 auto Opc = VVPOpc.value_or(
Op->getOpcode());
93 case VEISD::VVP_SELECT:
110#define REGISTER_PACKED(VVP_NAME) case VEISD::VVP_NAME:
111#include "VVPNodes.def"
112 return IsPackedOp && !IsMaskOp;
129#define ADD_VVP_OP(VVPNAME, ...) case VEISD::VVPNAME:
130#include "VVPNodes.def"
138#define ADD_UNARY_VVP_OP(VVPNAME, ...) \
139 case VEISD::VVPNAME: \
141#include "VVPNodes.def"
148#define ADD_BINARY_VVP_OP(VVPNAME, ...) \
149 case VEISD::VVPNAME: \
151#include "VVPNodes.def"
158#define ADD_REDUCE_VVP_OP(VVP_NAME, SDNAME) case VEISD::VVP_NAME:
159#include "VVPNodes.def"
180 case VEISD::VVP_SELECT:
182 case VEISD::VVP_LOAD:
184 case VEISD::VVP_STORE:
207 case VEISD::VVP_SELECT:
220 return MemN->getChain();
222 switch (
Op->getOpcode()) {
223 case VEISD::VVP_LOAD:
224 case VEISD::VVP_STORE:
225 return Op->getOperand(0);
232 return MemN->getBasePtr();
234 switch (
Op->getOpcode()) {
235 case VEISD::VVP_LOAD:
236 return Op->getOperand(1);
237 case VEISD::VVP_STORE:
238 return Op->getOperand(2);
244 unsigned OC =
Op->getOpcode();
248 return MemN->getMemoryVT();
258 return Op->getValueType(0);
262 unsigned OriginalOC = OC;
272 case VEISD::VVP_SETCC:
273 return Op->getOperand(0).getValueType();
275 case VEISD::VVP_SELECT:
276#define ADD_BINARY_VVP_OP(VVP_NAME, ...) case VEISD::VVP_NAME:
277#include "VVPNodes.def"
278 return Op->getValueType(0);
280 case VEISD::VVP_LOAD:
281 return Op->getValueType(0);
283 case VEISD::VVP_STORE:
284 return Op->getOperand(1)->getValueType(0);
288 return Op->getValueType(0);
293 switch (
Op->getOpcode()) {
294 case VEISD::VVP_STORE:
295 return Op->getOperand(3);
296 case VEISD::VVP_LOAD:
297 return Op->getOperand(2);
301 return StoreN->getStride();
303 return StoreN->getStride();
309 ->getVectorElementType()
318 return N->getIndex();
320 return N->getIndex();
326 return N->getScale();
328 return N->getScale();
333 switch (
Op->getOpcode()) {
334 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
335 case VEISD::VVP_STORE:
336 return Op->getOperand(1);
339 return StoreN->getValue();
341 return StoreN->getValue();
343 return StoreN->getValue();
345 return StoreN->getValue();
347 return StoreN->getValue();
349 return StoreN->getValue();
355 return N->getPassThru();
357 return N->getPassThru();
370 assert(!IsMask &&
"Mask reduction isel");
373#define HANDLE_VVP_REDUCE_TO_SCALAR(VVP_RED_ISD, REDUCE_ISD) \
374 case VEISD::VVP_RED_ISD: \
375 return ISD::REDUCE_ISD;
376#include "VVPNodes.def"
387 return PosOpt ?
Op->getOperand(*PosOpt) :
SDValue();
392 return PosOpt ?
Op->getOperand(*PosOpt) :
SDValue();
405 bool IsOpaque)
const {
406 return DAG.getConstant(Val, DL, VT, IsTarget, IsOpaque);
413 auto TrueVal = DAG.getAllOnesConstant(DL, MVT::i32);
414 auto AVL =
getConstant(MaskVT.getVectorNumElements(), MVT::i32);
419 return DAG.getNOT(DL, Res, Res.getValueType());
427 BcConst->getSExtValue() != 0);
430 auto ScalarBoolVT = Scalar.getSimpleValueType();
431 assert(ScalarBoolVT == MVT::i32);
434 SDValue CmpElem = DAG.getSExtOrTrunc(Scalar, DL, MVT::i32);
442 getBroadcast(CmpVecTy, {DAG.getConstant(0, DL, ScalarBoolVT)}, AVL);
454 auto ScaVT = Scalar.getValueType();
464 if (ScaVT == MVT::f32) {
466 }
else if (ScaVT == MVT::i32) {
487 return DAG.getNode(OC, DL, DestVT, Vec, AVL);
516 NewMask =
getUnpack(MVT::v256i1, RawMask, Part, NewAVL);
532 return getConstant(2 * ConstBytes->getSExtValue(), MVT::i64);
539 EVT IndexVT = Index.getValueType();
548 getNode(VEISD::VVP_MUL, IndexVT, {Index, ScaleBroadcast, Mask, AVL});
558 getNode(VEISD::VVP_ADD, IndexVT, {BaseBroadcast, ScaledIndex, Mask, AVL});
571 assert(!IsMaskReduction &&
"TODO Implement");
572 auto AttachStartValue = [&](
SDValue ReductionResV) {
573 if (!scalarizeStartParam)
574 return ReductionResV;
576 return getNode(ScalarOC, ResVT, {StartV, ReductionResV});
580 if (!scalarizeStartParam && StartV) {
582 return AttachStartValue(
583 getNode(VVPOpcode, ResVT, {StartV, VectorV, Mask, AVL}, Flags));
585 return AttachStartValue(
586 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.