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:
219 if (
MemSDNode *MemN = dyn_cast<MemSDNode>(
Op.getNode()))
220 return MemN->getChain();
222 switch (
Op->getOpcode()) {
223 case VEISD::VVP_LOAD:
224 case VEISD::VVP_STORE:
225 return Op->getOperand(0);
231 if (
auto *MemN = dyn_cast<MemSDNode>(
Op.getNode()))
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();
247 if (
auto MemN = dyn_cast<MemSDNode>(
Op))
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);
300 if (
auto *StoreN = dyn_cast<VPStridedStoreSDNode>(
Op.getNode()))
301 return StoreN->getStride();
302 if (
auto *StoreN = dyn_cast<VPStridedLoadSDNode>(
Op.getNode()))
303 return StoreN->getStride();
305 if (isa<MemSDNode>(
Op.getNode())) {
309 ->getVectorElementType()
317 if (
auto *
N = dyn_cast<MaskedGatherScatterSDNode>(
Op.getNode()))
318 return N->getIndex();
319 if (
auto *
N = dyn_cast<VPGatherScatterSDNode>(
Op.getNode()))
320 return N->getIndex();
325 if (
auto *
N = dyn_cast<MaskedGatherScatterSDNode>(
Op.getNode()))
326 return N->getScale();
327 if (
auto *
N = dyn_cast<VPGatherScatterSDNode>(
Op.getNode()))
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);
338 if (
auto *StoreN = dyn_cast<StoreSDNode>(
Op.getNode()))
339 return StoreN->getValue();
340 if (
auto *StoreN = dyn_cast<MaskedStoreSDNode>(
Op.getNode()))
341 return StoreN->getValue();
342 if (
auto *StoreN = dyn_cast<VPStridedStoreSDNode>(
Op.getNode()))
343 return StoreN->getValue();
344 if (
auto *StoreN = dyn_cast<VPStoreSDNode>(
Op.getNode()))
345 return StoreN->getValue();
346 if (
auto *StoreN = dyn_cast<MaskedScatterSDNode>(
Op.getNode()))
347 return StoreN->getValue();
348 if (
auto *StoreN = dyn_cast<VPScatterSDNode>(
Op.getNode()))
349 return StoreN->getValue();
354 if (
auto *
N = dyn_cast<MaskedLoadSDNode>(
Op.getNode()))
355 return N->getPassThru();
356 if (
auto *
N = dyn_cast<MaskedGatherSDNode>(
Op.getNode()))
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);
414 auto AVL =
getConstant(MaskVT.getVectorNumElements(), MVT::i32);
419 return DAG.
getNOT(DL, Res, Res.getValueType());
425 if (
auto BcConst = dyn_cast<ConstantSDNode>(Scalar))
427 BcConst->getSExtValue() != 0);
430 auto ScalarBoolVT = Scalar.getSimpleValueType();
431 assert(ScalarBoolVT == MVT::i32);
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);
531 if (
auto ConstBytes = dyn_cast<ConstantSDNode>(PackStride))
532 return getConstant(2 * ConstBytes->getSExtValue(), MVT::i64);
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(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class represents an Operation in the Expression.
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.
EVT getValueType() const
Return the ValueType of the referenced return value.
SDValue getAllOnesConstant(const SDLoc &DL, EVT VT, bool IsTarget=false, bool IsOpaque=false)
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond, SDValue Chain=SDValue(), bool IsSignaling=false)
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
SDValue getNOT(const SDLoc &DL, SDValue Val, EVT VT)
Create a bitwise NOT operation as (XOR Val, -1).
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
SDValue getSExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either sign-extending or trunca...
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
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.
@ MLOAD
Masked load and store - consecutive vector load and store operations with additional mask operand tha...
@ 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,...
std::optional< unsigned > getVPMaskIdx(unsigned Opcode)
The operand position of the vector mask.
std::optional< unsigned > getVPExplicitVectorLengthIdx(unsigned Opcode)
The operand position of the explicit vector length parameter.
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:
bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
SDValue getGatherScatterScale(SDValue Op)
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)
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)
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.