template <typename T> struct simplify_type;
template <typename T> struct ilist_traits;
+void checkForCycles(const SDNode *N);
+
/// SDVTList - This represents a list of ValueType's that has been intern'd by
/// a SelectionDAG. Instances of this simple value class are returned by
/// SelectionDAG::getVTList(...).
/// X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
FP_EXTEND,
- // BIT_CONVERT - Theis operator converts between integer and FP values, as
- // if one was stored to memory as integer and the other was loaded from the
- // same address (or equivalently for vector format conversions, etc). The
- // source and result are required to have the same bit size (e.g.
- // f32 <-> i32). This can also be used for int-to-int or fp-to-fp
- // conversions, but that is a noop, deleted by getNode().
+ // BIT_CONVERT - This operator converts between integer, vector and FP
+ // values, as if the value was stored to memory with one type and loaded
+ // from the same address with the other type (or equivalently for vector
+ // format conversions, etc). The source and result are required to have
+ // the same bit size (e.g. f32 <-> i32). This can also be used for
+ // int-to-int or fp-to-fp conversions, but that is a noop, deleted by
+ // getNode().
BIT_CONVERT,
// CONVERT_RNDSAT - This operator is used to support various conversions
// Operand #last: Optional, an incoming flag.
INLINEASM,
- // DBG_LABEL, EH_LABEL - Represents a label in mid basic block used to track
+ // EH_LABEL - Represents a label in mid basic block used to track
// locations needed for debug and exception handling tables. These nodes
// take a chain as input and return a chain.
- DBG_LABEL,
EH_LABEL,
// STACKSAVE - STACKSAVE has one operand, an input chain. It produces a
// HANDLENODE node - Used as a handle for various purposes.
HANDLENODE,
- // DBG_STOPPOINT - This node is used to represent a source location for
- // debug info. It takes token chain as input, and carries a line number,
- // column number, and a pointer to a CompileUnit object identifying
- // the containing compilation unit. It produces a token chain as output.
- DBG_STOPPOINT,
-
- // DEBUG_LOC - This node is used to represent source line information
- // embedded in the code. It takes a token chain as input, then a line
- // number, then a column then a file id (provided by MachineModuleInfo.) It
- // produces a token chain as output.
- DEBUG_LOC,
-
// TRAMPOLINE - This corresponds to the init_trampoline intrinsic.
// It takes as input a token chain, the pointer to the trampoline,
// the pointer to the nested function, the pointer to pass for the
/// element is not an undef.
bool isScalarToVector(const SDNode *N);
- /// isDebugLabel - Return true if the specified node represents a debug
- /// label (i.e. ISD::DBG_LABEL or TargetInstrInfo::DBG_LABEL node).
- bool isDebugLabel(const SDNode *N);
-
//===--------------------------------------------------------------------===//
/// MemIndexedMode enum - This enum defines the load / store indexed
/// addressing modes.
static bool isEqual(const SDValue &LHS, const SDValue &RHS) {
return LHS == RHS;
}
- static bool isPod() { return true; }
};
+template <> struct isPodLike<SDValue> { static const bool value = true; };
+
/// simplify_type specializations - Allow casting operators to work directly on
/// SDValues as if they were SDNode*'s.
/// hasOneUse - Return true if there is exactly one use of this node.
///
bool hasOneUse() const {
- return !use_empty() && next(use_begin()) == use_end();
+ return !use_empty() && llvm::next(use_begin()) == use_end();
}
/// use_size - Return the number of uses of this node. This method takes
SDVTList getVTList() const {
SDVTList X = { ValueList, NumValues };
return X;
- };
+ }
/// getFlaggedNode - If this node has a flag operand, return the node
/// to which the flag operand points. Otherwise return NULL.
void print_details(raw_ostream &OS, const SelectionDAG *G) const;
void print(raw_ostream &OS, const SelectionDAG *G = 0) const;
void printr(raw_ostream &OS, const SelectionDAG *G = 0) const;
+
+ /// printrFull - Print a SelectionDAG node and all children down to
+ /// the leaves. The given SelectionDAG allows target-specific nodes
+ /// to be printed in human-readable form. Unlike printr, this will
+ /// print the whole DAG, including children that appear multiple
+ /// times.
+ ///
+ void printrFull(raw_ostream &O, const SelectionDAG *G = 0) const;
+
+ /// printrWithDepth - Print a SelectionDAG node and children up to
+ /// depth "depth." The given SelectionDAG allows target-specific
+ /// nodes to be printed in human-readable form. Unlike printr, this
+ /// will print children that appear multiple times wherever they are
+ /// used.
+ ///
+ void printrWithDepth(raw_ostream &O, const SelectionDAG *G = 0,
+ unsigned depth = 100) const;
+
+
+ /// dump - Dump this node, for debugging.
void dump() const;
+
+ /// dumpr - Dump (recursively) this node and its use-def subgraph.
void dumpr() const;
+
+ /// dump - Dump this node, for debugging.
+ /// The given SelectionDAG allows target-specific nodes to be printed
+ /// in human-readable form.
void dump(const SelectionDAG *G) const;
+
+ /// dumpr - Dump (recursively) this node and its use-def subgraph.
+ /// The given SelectionDAG allows target-specific nodes to be printed
+ /// in human-readable form.
void dumpr(const SelectionDAG *G) const;
+ /// dumprFull - printrFull to dbgs(). The given SelectionDAG allows
+ /// target-specific nodes to be printed in human-readable form.
+ /// Unlike dumpr, this will print the whole DAG, including children
+ /// that appear multiple times.
+ ///
+ void dumprFull(const SelectionDAG *G = 0) const;
+
+ /// dumprWithDepth - printrWithDepth to dbgs(). The given
+ /// SelectionDAG allows target-specific nodes to be printed in
+ /// human-readable form. Unlike dumpr, this will print children
+ /// that appear multiple times wherever they are used.
+ ///
+ void dumprWithDepth(const SelectionDAG *G = 0, unsigned depth = 100) const;
+
+
static bool classof(const SDNode *) { return true; }
/// Profile - Gather unique data for the node.
OperandList[i].setUser(this);
OperandList[i].setInitial(Ops[i]);
}
+ checkForCycles(this);
}
/// This constructor adds no operands itself; operands can be
Ops[0].setInitial(Op0);
NumOperands = 1;
OperandList = Ops;
+ checkForCycles(this);
}
/// InitOperands - Initialize the operands list of this with 2 operands.
Ops[1].setInitial(Op1);
NumOperands = 2;
OperandList = Ops;
+ checkForCycles(this);
}
/// InitOperands - Initialize the operands list of this with 3 operands.
Ops[2].setInitial(Op2);
NumOperands = 3;
OperandList = Ops;
+ checkForCycles(this);
}
/// InitOperands - Initialize the operands list of this with 4 operands.
Ops[3].setInitial(Op3);
NumOperands = 4;
OperandList = Ops;
+ checkForCycles(this);
}
/// InitOperands - Initialize the operands list of this with N operands.
}
NumOperands = N;
OperandList = Ops;
+ checkForCycles(this);
}
/// DropOperands - Release the operands and set this node to have
/// that value are zero, and the corresponding bits in the SplatUndef mask
/// are set. The SplatBitSize value is set to the splat element size in
/// bits. HasAnyUndefs is set to true if any bits in the vector are
- /// undefined.
+ /// undefined. isBigEndian describes the endianness of the target.
bool isConstantSplat(APInt &SplatValue, APInt &SplatUndef,
unsigned &SplatBitSize, bool &HasAnyUndefs,
- unsigned MinSplatBits = 0);
+ unsigned MinSplatBits = 0, bool isBigEndian = false);
static inline bool classof(const BuildVectorSDNode *) { return true; }
static inline bool classof(const SDNode *N) {
}
};
-class DbgStopPointSDNode : public SDNode {
- SDUse Chain;
- unsigned Line;
- unsigned Column;
- MDNode *CU;
- friend class SelectionDAG;
- DbgStopPointSDNode(SDValue ch, unsigned l, unsigned c,
- MDNode *cu)
- : SDNode(ISD::DBG_STOPPOINT, DebugLoc::getUnknownLoc(),
- getSDVTList(MVT::Other)), Line(l), Column(c), CU(cu) {
- InitOperands(&Chain, ch);
- }
-public:
- unsigned getLine() const { return Line; }
- unsigned getColumn() const { return Column; }
- MDNode *getCompileUnit() const { return CU; }
-
- static bool classof(const DbgStopPointSDNode *) { return true; }
- static bool classof(const SDNode *N) {
- return N->getOpcode() == ISD::DBG_STOPPOINT;
- }
-};
-
class BlockAddressSDNode : public SDNode {
BlockAddress *BA;
+ unsigned char TargetFlags;
friend class SelectionDAG;
- BlockAddressSDNode(unsigned NodeTy, DebugLoc dl, EVT VT, BlockAddress *ba)
- : SDNode(NodeTy, dl, getSDVTList(VT)), BA(ba) {
+ BlockAddressSDNode(unsigned NodeTy, EVT VT, BlockAddress *ba,
+ unsigned char Flags)
+ : SDNode(NodeTy, DebugLoc::getUnknownLoc(), getSDVTList(VT)),
+ BA(ba), TargetFlags(Flags) {
}
public:
BlockAddress *getBlockAddress() const { return BA; }
+ unsigned char getTargetFlags() const { return TargetFlags; }
static bool classof(const BlockAddressSDNode *) { return true; }
static bool classof(const SDNode *N) {
static bool classof(const LabelSDNode *) { return true; }
static bool classof(const SDNode *N) {
- return N->getOpcode() == ISD::DBG_LABEL ||
- N->getOpcode() == ISD::EH_LABEL;
+ return N->getOpcode() == ISD::EH_LABEL;
}
};
SDNodeIterator operator++(int) { // Postincrement
SDNodeIterator tmp = *this; ++*this; return tmp;
}
+ size_t operator-(SDNodeIterator Other) const {
+ assert(Node == Other.Node &&
+ "Cannot compare iterators of two different nodes!");
+ return Operand - Other.Operand;
+ }
static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); }
static SDNodeIterator end (SDNode *N) {