#ifndef LLVM_LIB_TARGET_VE_VECUSTOMDAG_H
#define LLVM_LIB_TARGET_VE_VECUSTOMDAG_H
#include "VE.h"
#include "VEISelLowering.h"
#include "llvm/CodeGen/SelectionDAG.h"
#include "llvm/CodeGen/TargetLowering.h"
namespace llvm {
Optional<unsigned> getVVPOpcode(unsigned Opcode);
bool isVVPUnaryOp(unsigned Opcode);
bool isVVPBinaryOp(unsigned Opcode);
bool isVVPReductionOp(unsigned Opcode);
MVT splitVectorType(MVT VT);
bool isPackedVectorType(EVT SomeVT);
bool isMaskType(EVT SomeVT);
bool isMaskArithmetic(SDValue Op);
bool isVVPOrVEC(unsigned);
bool supportsPackedMode(unsigned Opcode, EVT IdiomVT);
bool isPackingSupportOpcode(unsigned Opc);
bool maySafelyIgnoreMask(SDValue Op);
Optional<int> getAVLPos(unsigned);
bool isLegalAVL(SDValue AVL);
SDValue getNodeAVL(SDValue);
Optional<int> getMaskPos(unsigned);
SDValue getNodeMask(SDValue);
std::pair<SDValue, bool> getAnnotatedNodeAVL(SDValue);
Optional<EVT> getIdiomaticVectorType(SDNode *Op);
SDValue getLoadStoreStride(SDValue Op, VECustomDAG &CDAG);
SDValue getMemoryPtr(SDValue Op);
SDValue getNodeChain(SDValue Op);
SDValue getStoredValue(SDValue Op);
SDValue getNodePassthru(SDValue Op);
SDValue getGatherScatterIndex(SDValue Op);
SDValue getGatherScatterScale(SDValue Op);
unsigned getScalarReductionOpcode(unsigned VVPOC, bool IsMask);
bool hasReductionStartParam(unsigned VVPOC);
enum class Packing {
Normal = 0, Dense = 1 };
MVT getLegalVectorType(Packing P, MVT ElemVT);
Packing getTypePacking(EVT);
enum class PackElem : int8_t {
Lo = 0, Hi = 1 };
struct VETargetMasks {
SDValue Mask;
SDValue AVL;
VETargetMasks(SDValue Mask = SDValue(), SDValue AVL = SDValue())
: Mask(Mask), AVL(AVL) {}
};
class VECustomDAG {
SelectionDAG &DAG;
SDLoc DL;
public:
SelectionDAG *getDAG() const { return &DAG; }
VECustomDAG(SelectionDAG &DAG, SDLoc DL) : DAG(DAG), DL(DL) {}
VECustomDAG(SelectionDAG &DAG, SDValue WhereOp) : DAG(DAG), DL(WhereOp) {}
VECustomDAG(SelectionDAG &DAG, const SDNode *WhereN) : DAG(DAG), DL(WhereN) {}
SDValue getNode(unsigned OC, SDVTList VTL, ArrayRef<SDValue> OpV,
Optional<SDNodeFlags> Flags = None) const {
auto N = DAG.getNode(OC, DL, VTL, OpV);
if (Flags)
N->setFlags(*Flags);
return N;
}
SDValue getNode(unsigned OC, ArrayRef<EVT> ResVT, ArrayRef<SDValue> OpV,
Optional<SDNodeFlags> Flags = None) const {
auto N = DAG.getNode(OC, DL, ResVT, OpV);
if (Flags)
N->setFlags(*Flags);
return N;
}
SDValue getNode(unsigned OC, EVT ResVT, ArrayRef<SDValue> OpV,
Optional<SDNodeFlags> Flags = None) const {
auto N = DAG.getNode(OC, DL, ResVT, OpV);
if (Flags)
N->setFlags(*Flags);
return N;
}
SDValue getUNDEF(EVT VT) const { return DAG.getUNDEF(VT); }
SDValue getLegalReductionOpVVP(unsigned VVPOpcode, EVT ResVT, SDValue StartV,
SDValue VectorV, SDValue Mask, SDValue AVL,
SDNodeFlags Flags) const;
SDValue getUnpack(EVT DestVT, SDValue Vec, PackElem Part, SDValue AVL) const;
SDValue getPack(EVT DestVT, SDValue LoVec, SDValue HiVec, SDValue AVL) const;
SDValue getMergeValues(ArrayRef<SDValue> Values) const {
return DAG.getMergeValues(Values, DL);
}
SDValue getConstant(uint64_t Val, EVT VT, bool IsTarget = false,
bool IsOpaque = false) const;
SDValue getConstantMask(Packing Packing, bool AllTrue) const;
SDValue getMaskBroadcast(EVT ResultVT, SDValue Scalar, SDValue AVL) const;
SDValue getBroadcast(EVT ResultVT, SDValue Scalar, SDValue AVL) const;
SDValue annotateLegalAVL(SDValue AVL) const;
VETargetMasks getTargetSplitMask(SDValue RawMask, SDValue RawAVL,
PackElem Part) const;
SDValue getSplitPtrOffset(SDValue Ptr, SDValue ByteStride,
PackElem Part) const;
SDValue getSplitPtrStride(SDValue PackStride) const;
SDValue getGatherScatterAddress(SDValue BasePtr, SDValue Scale, SDValue Index,
SDValue Mask, SDValue AVL) const;
EVT getVectorVT(EVT ElemVT, unsigned NumElems) const {
return EVT::getVectorVT(*DAG.getContext(), ElemVT, NumElems);
}
};
}
#endif