15 #ifndef LLVM_CODEGEN_SELECTIONDAG_H
16 #define LLVM_CODEGEN_SELECTIONDAG_H
33 class MachineConstantPoolValue;
34 class MachineFunction;
38 class TargetSelectionDAGInfo;
39 class TargetTransformInfo;
54 FastID(ID), VTs(VT), NumVTs(Num) {
71 if (X.HashValue != IDHash)
73 return ID == X.FastID;
85 return static_cast<SDNode*
>(&Sentinel);
124 ByvalParmDbgValues.push_back(V);
125 }
else DbgValues.push_back(V);
127 DbgValMap[Node].push_back(V);
133 ByvalParmDbgValues.clear();
137 return DbgValues.empty() && ByvalParmDbgValues.empty();
142 if (I != DbgValMap.
end())
222 :
Next(D.UpdateListeners),
DAG(D) {
223 DAG.UpdateListeners =
this;
227 assert(
DAG.UpdateListeners ==
this &&
228 "DAGUpdateListeners must be destroyed in LIFO order");
258 bool setSubgraphColorHelper(
SDNode *
N,
const char *Color,
260 int level,
bool &printed);
289 void viewGraph(
const std::string &Title);
323 return AllNodes.size();
333 return SDValue(const_cast<SDNode *>(&EntryNode), 0);
340 "DAG root value is not a chain!");
432 int64_t offset = 0,
bool isTargetGA =
false,
433 unsigned char TargetFlags = 0);
436 unsigned char TargetFlags = 0) {
444 unsigned char TargetFlags = 0);
449 unsigned Align = 0,
int Offs = 0,
bool isT=
false,
450 unsigned char TargetFlags = 0);
452 unsigned Align = 0,
int Offset = 0,
453 unsigned char TargetFlags = 0) {
457 unsigned Align = 0,
int Offs = 0,
bool isT=
false,
458 unsigned char TargetFlags = 0);
461 int Offset = 0,
unsigned char TargetFlags=0) {
465 unsigned char TargetFlags = 0);
473 unsigned char TargetFlags = 0);
479 int64_t Offset = 0,
bool isTarget =
false,
480 unsigned char TargetFlags = 0);
483 unsigned char TargetFlags = 0) {
539 const int *MaskElts);
581 (
unsigned)Ops.
size() - (InGlue.
getNode() == 0 ? 1 : 0));
608 const SDUse *Ops,
unsigned NumOps);
610 const SDValue *Ops,
unsigned NumOps);
613 const SDValue *Ops,
unsigned NumOps);
615 const SDValue *Ops,
unsigned NumOps);
617 const SDValue *Ops,
unsigned NumOps);
637 SDValue Size,
unsigned Align,
bool isVol,
bool AlwaysInline,
656 "Cannot compare scalars to vectors");
658 "Cannot compare scalars to vectors");
660 "Cannot create a setCC of an invalid node.");
669 "Cannot use select on differing types");
671 "Cannot mix vectors and scalars");
738 const EVT *VTs,
unsigned NumVTs,
739 const SDValue *Ops,
unsigned NumOps,
741 unsigned Align = 0,
bool Vol =
false,
742 bool ReadMem =
true,
bool WriteMem =
true);
745 const SDValue *Ops,
unsigned NumOps,
747 unsigned Align = 0,
bool Vol =
false,
748 bool ReadMem =
true,
bool WriteMem =
true);
751 const SDValue *Ops,
unsigned NumOps,
762 bool isNonTemporal,
bool isInvariant,
unsigned Alignment,
768 EVT MemVT,
bool isVolatile,
769 bool isNonTemporal,
unsigned Alignment,
770 const MDNode *TBAAInfo = 0);
780 bool isVolatile,
bool isNonTemporal,
bool isInvariant,
781 unsigned Alignment,
const MDNode *TBAAInfo = 0,
782 const MDNode *Ranges = 0);
792 bool isNonTemporal,
unsigned Alignment,
793 const MDNode *TBAAInfo = 0);
798 bool isNonTemporal,
bool isVolatile,
800 const MDNode *TBAAInfo = 0);
814 unsigned SrcAS,
unsigned DestAS);
835 const SDValue *Ops,
unsigned NumOps);
848 const SDValue *Ops,
unsigned NumOps);
851 EVT VT2,
const SDValue *Ops,
unsigned NumOps);
866 const SDValue *Ops,
unsigned NumOps);
871 const SDValue *Ops,
unsigned NumOps);
925 const SDValue *Ops,
unsigned NumOps);
983 AllNodes.insert(Position, AllNodes.remove(N));
1007 default:
return false;
1085 unsigned Depth = 0)
const;
1127 unsigned Bytes,
int Dist)
const;
1140 const EVT &LoVT,
const EVT &HiVT);
1158 bool RemoveNodeFromCSEMaps(
SDNode *N);
1159 void AddModifiedNodeToCSEMaps(
SDNode *N);
1167 void DeleteNodeNotInCSEMaps(
SDNode *N);
1168 void DeallocateNode(
SDNode *N);
1170 unsigned getEVTAlignment(
EVT MemoryVT)
const;
1172 void allnodes_clear();
1178 std::vector<CondCodeSDNode*> CondCodeNodes;
1180 std::vector<SDNode*> ValueTypeNodes;
1181 std::map<EVT, SDNode*, EVT::compareRawBits> ExtendedValueTypeNodes;
1184 std::map<std::pair<std::string, unsigned char>,
SDNode*> TargetExternalSymbols;
void push_back(const T &Elt)
SDValue getConstant(uint64_t Val, EVT VT, bool isTarget=false)
const std::string getGraphAttrs(const SDNode *N) const
LLVMContext * getContext() const
SDValue getTargetIndex(int Index, EVT VT, int64_t Offset=0, unsigned char TargetFlags=0)
SDValue getCopyToReg(SDValue Chain, SDLoc dl, unsigned Reg, SDValue N)
SDValue UnrollVectorOp(SDNode *N, unsigned ResNE=0)
SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2, SDValue InGlue, SDLoc DL)
SDValue getIndexedLoad(SDValue OrigLoad, SDLoc dl, SDValue Base, SDValue Offset, ISD::MemIndexedMode AM)
bool isKnownNeverNaN(SDValue Op) const
isKnownNeverNan - Test whether the given SDValue is known to never be NaN.
bool hasDebugValues() const
static NodeTy * createNode(const NodeTy &V)
static const fltSemantics IEEEdouble
DbgIterator ByvalParmDbgEnd()
SDValue getVAArg(EVT VT, SDLoc dl, SDValue Chain, SDValue Ptr, SDValue SV, unsigned Align)
const TargetMachine & getTarget() const
unsigned InferPtrAlignment(SDValue Ptr) const
std::pair< EVT, EVT > GetSplitDestVTs(const EVT &VT) const
SDValue getBasicBlock(MachineBasicBlock *MBB)
SDValue getSelectCC(SDLoc DL, SDValue LHS, SDValue RHS, SDValue True, SDValue False, ISD::CondCode Cond)
const TargetSelectionDAGInfo & getSelectionDAGInfo() const
static bool Equals(const SDVTListNode &X, const FoldingSetNodeID &ID, unsigned IDHash, FoldingSetNodeID &TempID)
bool NewNodesMustHaveLegalTypes
SDValue getZeroExtendInReg(SDValue Op, SDLoc DL, EVT SrcTy)
static const fltSemantics & EVTToAPFloatSemantics(EVT VT)
void setSubgraphColor(SDNode *N, const char *Color)
MDNode - a tuple of other values.
const SDValue & getOperand(unsigned Num) const
static bool isCommutativeBinOp(unsigned Opcode)
SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned char TargetFlags=0)
ilist< SDNode >::iterator allnodes_iterator
void ComputeMaskedBits(SDValue Op, APInt &KnownZero, APInt &KnownOne, unsigned Depth=0) const
SDValue getCopyFromReg(SDValue Chain, SDLoc dl, unsigned Reg, EVT VT, SDValue Glue)
const SDValue & setRoot(SDValue N)
static void destroySentinel(SDNode *)
void DeleteNode(SDNode *N)
static void noteHead(SDNode *, SDNode *)
SDValue getConstantPool(const Constant *C, EVT VT, unsigned Align=0, int Offs=0, bool isT=false, unsigned char TargetFlags=0)
SDValue getCopyToReg(SDValue Chain, SDLoc dl, SDValue Reg, SDValue N, SDValue Glue)
void AddDbgValue(SDDbgValue *DB, SDNode *SD, bool isParameter)
iplist< NodeTy >::size_type size_type
void ReplaceAllUsesOfValuesWith(const SDValue *From, const SDValue *To, unsigned Num)
virtual void NodeUpdated(SDNode *N)
NodeUpdated - The node N that was updated.
void init(MachineFunction &mf, const TargetTransformInfo *TTI, const TargetLowering *TLI)
SDValue getExternalSymbol(const char *Sym, EVT VT)
bool isKnownNeverZero(SDValue Op) const
SDValue getLoad(EVT VT, SDLoc dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, bool isVolatile, bool isNonTemporal, bool isInvariant, unsigned Alignment, const MDNode *TBAAInfo=0, const MDNode *Ranges=0)
bool isVector() const
isVector - Return true if this is a vector value type.
void checkForCycles(const SDNode *N)
SDDbgInfo::DbgIterator DbgBegin()
static const fltSemantics x87DoubleExtended
SDValue getStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, bool isVolatile, bool isNonTemporal, unsigned Alignment, const MDNode *TBAAInfo=0)
SDValue getTargetConstantFP(const APFloat &Val, EVT VT)
SDNode * MorphNodeTo(SDNode *N, unsigned Opc, SDVTList VTs, const SDValue *Ops, unsigned NumOps)
unsigned ComputeHash() const
#define llvm_unreachable(msg)
MachineFunction & getMachineFunction() const
bool isConsecutiveLoad(LoadSDNode *LD, LoadSDNode *Base, unsigned Bytes, int Dist) const
SDValue getTargetGlobalAddress(const GlobalValue *GV, SDLoc DL, EVT VT, int64_t offset=0, unsigned char TargetFlags=0)
SDNode * provideInitialHead() const
EVT getScalarType() const
allnodes_const_iterator allnodes_end() const
static const fltSemantics IEEEquad
SDNode * getNodeIfExists(unsigned Opcode, SDVTList VTs, const SDValue *Ops, unsigned NumOps)
SDVTList getVTList(EVT VT)
ID
LLVM Calling Convention Representation.
SDDbgValue * getDbgValue(MDNode *MDPtr, SDNode *N, unsigned R, uint64_t Off, DebugLoc DL, unsigned O)
SDValue getConstantFP(double Val, EVT VT, bool isTarget=false)
unsigned AssignTopologicalOrder()
SDValue getAtomic(unsigned Opcode, SDLoc dl, EVT MemVT, SDValue Chain, SDValue Ptr, SDValue Cmp, SDValue Swp, MachinePointerInfo PtrInfo, unsigned Alignment, AtomicOrdering Ordering, SynchronizationScope SynchScope)
SDValue getCALLSEQ_START(SDValue Chain, SDValue Op, SDLoc DL)
SDValue getCopyToReg(SDValue Chain, SDLoc dl, unsigned Reg, SDValue N, SDValue Glue)
SDValue getRegisterMask(const uint32_t *RegMask)
DAGUpdateListener *const Next
SDValue getTargetFrameIndex(int FI, EVT VT)
Simple integer binary arithmetic operators.
SDValue getVectorShuffle(EVT VT, SDLoc dl, SDValue N1, SDValue N2, const int *MaskElts)
SDValue getUNDEF(EVT VT)
getUNDEF - Return an UNDEF node. UNDEF does not have a useful SDLoc.
allnodes_iterator allnodes_end()
SDValue getAnyExtOrTrunc(SDValue Op, SDLoc DL, EVT VT)
SelectionDAG::allnodes_iterator nodes_iterator
allnodes_iterator allnodes_begin()
UNDEF - An undefined node.
SDValue getAddrSpaceCast(SDLoc dl, EVT VT, SDValue Ptr, unsigned SrcAS, unsigned DestAS)
getAddrSpaceCast - Return an AddrSpaceCastSDNode.
virtual ~DAGUpdateListener()
SDDbgInfo::DbgIterator ByvalParmDbgEnd()
SDNode * getNode() const
get the SDNode which holds the desired result
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
void setGraphColor(const SDNode *N, const char *Color)
SDValue getMDNode(const MDNode *MD)
getMDNode - Return an MDNodeSDNode which holds an MDNode.
static nodes_iterator nodes_begin(SelectionDAG *G)
Simple binary floating point operators.
void Combine(CombineLevel Level, AliasAnalysis &AA, CodeGenOpt::Level OptLevel)
LLVM Constant Representation.
DAGUpdateListener(SelectionDAG &D)
std::pair< SDValue, SDValue > SplitVectorOperand(const SDNode *N, unsigned OpNo)
SDValue getCopyFromReg(SDValue Chain, SDLoc dl, unsigned Reg, EVT VT)
SDValue getSExtOrTrunc(SDValue Op, SDLoc DL, EVT VT)
static void deleteNode(SDNode *)
ArrayRef< SDDbgValue * > GetDbgValues(const SDNode *SD)
GetDbgValues - Get the debug values which reference the given SDNode.
void RepositionNode(allnodes_iterator Position, SDNode *N)
void RemoveDeadNode(SDNode *N)
std::pair< SDValue, SDValue > SplitVector(const SDValue &N, const SDLoc &DL)
ilist< SDNode >::size_type allnodes_size() const
bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
ArrayRef< SDDbgValue * > getSDDbgValues(const SDNode *Node)
SDValue getGlobalAddress(const GlobalValue *GV, SDLoc DL, EVT VT, int64_t offset=0, bool isTargetGA=false, unsigned char TargetFlags=0)
bool isEqualTo(SDValue A, SDValue B) const
SDValue getTargetConstantPool(MachineConstantPoolValue *C, EVT VT, unsigned Align=0, int Offset=0, unsigned char TargetFlags=0)
static const fltSemantics IEEEhalf
const SDValue & getRoot() const
SDValue CreateStackTemporary(EVT VT, unsigned minAlign=1)
SDValue getMemcpy(SDValue Chain, SDLoc dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
SDValue getTargetConstantPool(const Constant *C, EVT VT, unsigned Align=0, int Offset=0, unsigned char TargetFlags=0)
SDValue getTargetJumpTable(int JTI, EVT VT, unsigned char TargetFlags=0)
SDValue getTargetConstant(const ConstantInt &Val, EVT VT)
SDValue getConvertRndSat(EVT VT, SDLoc dl, SDValue Val, SDValue DTy, SDValue STy, SDValue Rnd, SDValue Sat, ISD::CvtCode Code)
SDValue getTargetConstantFP(double Val, EVT VT)
SDValue getNOT(SDLoc DL, SDValue Val, EVT VT)
getNOT - Create a bitwise NOT operation as (XOR Val, -1).
static const fltSemantics PPCDoubleDouble
SDNode * createSentinel() const
Class for constant integers.
allnodes_const_iterator allnodes_begin() const
virtual void NodeDeleted(SDNode *N, SDNode *E)
bool isBaseWithConstantOffset(SDValue Op) const
std::pair< SDValue, SDValue > SplitVector(const SDValue &N, const SDLoc &DL, const EVT &LoVT, const EVT &HiVT)
SDNode * UpdateNodeOperands(SDNode *N, SDValue Op)
static nodes_iterator nodes_end(SelectionDAG *G)
const TargetTransformInfo * getTargetTransformInfo() const
SDValue getTargetInsertSubreg(int SRIdx, SDLoc DL, EVT VT, SDValue Operand, SDValue Subreg)
SDNode * SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT)
SDValue getExtLoad(ISD::LoadExtType ExtType, SDLoc dl, EVT VT, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT, bool isVolatile, bool isNonTemporal, unsigned Alignment, const MDNode *TBAAInfo=0)
SDDbgInfo::DbgIterator DbgEnd()
SDValue getIntPtrConstant(uint64_t Val, bool isTarget=false)
SDValue getMemmove(SDValue Chain, SDLoc dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
SmallVectorImpl< SDDbgValue * >::iterator DbgIterator
SDDbgInfo::DbgIterator ByvalParmDbgBegin()
#define LLVM_DELETED_FUNCTION
Class for arbitrary precision integers.
SDValue getMemIntrinsicNode(unsigned Opcode, SDLoc dl, const EVT *VTs, unsigned NumVTs, const SDValue *Ops, unsigned NumOps, EVT MemVT, MachinePointerInfo PtrInfo, unsigned Align=0, bool Vol=false, bool ReadMem=true, bool WriteMem=true)
AtomicSDNode LargestSDNode
SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT)
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(DefaultAlign), cl::values(clEnumValN(DefaultAlign,"arm-default-align","Generate unaligned accesses only on hardware/OS ""combinations that are known to support them"), clEnumValN(StrictAlign,"arm-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"arm-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
SDValue getTargetConstant(const APInt &Val, EVT VT)
SDValue getShiftAmountOperand(EVT LHSTy, SDValue Op)
SDValue getBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, bool isTarget=false, unsigned char TargetFlags=0)
std::map< const SDNode *, std::string > NodeGraphAttrs
SDValue getStackArgumentTokenFactor(SDValue Chain)
SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, unsigned char TargetFlags=0)
static const fltSemantics IEEEsingle
SDVTListNode(const FoldingSetNodeIDRef ID, const EVT *VT, unsigned int Num)
Bitwise operators - logical and, logical or, logical xor.
static unsigned ComputeHash(const SDVTListNode &X, FoldingSetNodeID &TempID)
SDValue FoldConstantArithmetic(unsigned Opcode, EVT VT, SDNode *Cst1, SDNode *Cst2)
FoldConstantArithmetic -.
void ReplaceAllUsesWith(SDValue From, SDValue Op)
SDValue getIndexedStore(SDValue OrigStoe, SDLoc dl, SDValue Base, SDValue Offset, ISD::MemIndexedMode AM)
SDValue getTruncStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, EVT TVT, bool isNonTemporal, bool isVolatile, unsigned Alignment, const MDNode *TBAAInfo=0)
MachineSDNode * getMachineNode(unsigned Opcode, SDLoc dl, EVT VT)
SDValue getMemset(SDValue Chain, SDLoc dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, MachinePointerInfo DstPtrInfo)
SDValue FoldSetCC(EVT VT, SDValue N1, SDValue N2, ISD::CondCode Cond, SDLoc dl)
FoldSetCC - Constant fold a setcc to true or false.
SDValue getCondCode(ISD::CondCode Cond)
SDValue getGLOBAL_OFFSET_TABLE(EVT VT)
static NodeTy * createSentinel()
createSentinel - create the dynamic sentinel
SDValue getSelect(SDLoc DL, EVT VT, SDValue Cond, SDValue LHS, SDValue RHS)
void setGraphAttrs(const SDNode *N, const char *Attrs)
SDValue getJumpTable(int JTI, EVT VT, bool isTarget=false, unsigned char TargetFlags=0)
SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
SDValue getTargetExtractSubreg(int SRIdx, SDLoc DL, EVT VT, SDValue Operand)
SDValue getZExtOrTrunc(SDValue Op, SDLoc DL, EVT VT)
LLVM Value Representation.
SDValue getRegister(unsigned Reg, EVT VT)
SDValue getEHLabel(SDLoc dl, SDValue Root, MCSymbol *Label)
SDValue getValueType(EVT)
unsigned ComputeNumSignBits(SDValue Op, unsigned Depth=0) const
const TargetLowering & getTargetLoweringInfo() const
void ReplaceAllUsesOfValueWith(SDValue From, SDValue To)
void add(SDDbgValue *V, const SDNode *Node, bool isParameter)
SDValue getSrcValue(const Value *v)
getSrcValue - Construct a node to track a Value* through the backend.
SDValue getMergeValues(const SDValue *Ops, unsigned NumOps, SDLoc dl)
getMergeValues - Create a MERGE_VALUES node from the given operands.
SDValue getTargetConstant(uint64_t Val, EVT VT)
SDValue getSetCC(SDLoc DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond)
SDNode * ensureHead(SDNode *) const
SDValue getEntryNode() const
ilist< SDNode >::const_iterator allnodes_const_iterator
bool SignBitIsZero(SDValue Op, unsigned Depth=0) const
DbgIterator ByvalParmDbgBegin()
SDValue getTargetConstantFP(const ConstantFP &Val, EVT VT)
void TransferDbgValues(SDValue From, SDValue To)
TransferDbgValues - Transfer SDDbgValues.
iterator find(const KeyT &Val)
static void Profile(const SDVTListNode &X, FoldingSetNodeID &ID)
tier< T1, T2 > tie(T1 &f, T2 &s)
static RegisterPass< NVPTXAllocaHoisting > X("alloca-hoisting","Hoisting alloca instructions in non-entry ""blocks to the entry block")