class MachineBasicBlock;
class MachineConstantPoolValue;
class SDNode;
+template <typename T> struct DenseMapKeyInfo;
template <typename T> struct simplify_type;
template <typename T> struct ilist_traits;
template<typename NodeTy, typename Traits> class iplist;
unsigned short NumVTs;
};
-
/// ISD namespace - This namespace contains an enum which represents all of the
/// SelectionDAG node types and value types.
///
namespace ISD {
+ namespace ParamFlags {
+ enum Flags {
+ NoFlagSet = 0,
+ ZExt = 1<<0, ///< Parameter should be zero extended
+ ZExtOffs = 0,
+ SExt = 1<<1, ///< Parameter should be sign extended
+ SExtOffs = 1,
+ InReg = 1<<2, ///< Parameter should be passed in register
+ InRegOffs = 2,
+ StructReturn = 1<<3, ///< Hidden struct-return pointer
+ StructReturnOffs = 3,
+ ByVal = 1<<4, ///< Struct passed by value
+ ByValOffs = 4,
+ OrigAlignment = 0x1F<<27,
+ OrigAlignmentOffs = 27
+ };
+ }
+
//===--------------------------------------------------------------------===//
/// ISD::NodeType enum - This enum defines all of the operators valid in a
/// SelectionDAG.
// Various leaf nodes.
STRING, BasicBlock, VALUETYPE, CONDCODE, Register,
Constant, ConstantFP,
- GlobalAddress, FrameIndex, JumpTable, ConstantPool, ExternalSymbol,
+ GlobalAddress, GlobalTLSAddress, FrameIndex,
+ JumpTable, ConstantPool, ExternalSymbol,
// The address of the GOT
GLOBAL_OFFSET_TABLE,
// parent's frame or return address, and so on.
FRAMEADDR, RETURNADDR,
+ // FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to
+ // first (possible) on-stack argument. This is needed for correct stack
+ // adjustment during unwind.
+ FRAME_TO_ARGS_OFFSET,
+
+ // RESULT, OUTCHAIN = EXCEPTIONADDR(INCHAIN) - This node represents the
+ // address of the exception block on entry to an landing pad block.
+ EXCEPTIONADDR,
+
+ // RESULT, OUTCHAIN = EHSELECTION(INCHAIN, EXCEPTION) - This node represents
+ // the selection index of the exception thrown.
+ EHSELECTION,
+
+ // OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents
+ // 'eh_return' gcc dwarf builtin, which is used to return from
+ // exception. The general meaning is: adjust stack by OFFSET and pass
+ // execution to HANDLER. Many platform-related details also :)
+ EH_RETURN,
+
// TargetConstant* - Like Constant*, but the DAG does not do any folding or
// simplification of the constant.
TargetConstant,
// anything else with this node, and this is valid in the target-specific
// dag, turning into a GlobalAddress operand.
TargetGlobalAddress,
+ TargetGlobalTLSAddress,
TargetFrameIndex,
TargetJumpTable,
TargetConstantPool,
/// Bit 0 - signness
/// Bit 1 - 'inreg' attribute
/// Bit 2 - 'sret' attribute
+ /// Bits 31:27 - argument ABI alignment in the first argument piece and
+ /// alignment '1' in other argument pieces.
CALL,
// EXTRACT_ELEMENT - This is used to get the first or second (determined by
// Simple integer binary arithmetic operators.
ADD, SUB, MUL, SDIV, UDIV, SREM, UREM,
+ // CARRY_FALSE - This node is used when folding other nodes,
+ // like ADDC/SUBC, which indicate the carry result is always false.
+ CARRY_FALSE,
+
// Carry-setting nodes for multiple precision addition and subtraction.
// These nodes take two operands of the same value type, and produce two
// results. The first result is the normal add or sub result, the second
// FCOPYSIGN(f32, f64) is allowed.
FCOPYSIGN,
- /// VBUILD_VECTOR(ELT1, ELT2, ELT3, ELT4,..., COUNT,TYPE) - Return a vector
- /// with the specified, possibly variable, elements. The number of elements
- /// is required to be a power of two.
- VBUILD_VECTOR,
-
- /// BUILD_VECTOR(ELT1, ELT2, ELT3, ELT4,...) - Return a vector
+ /// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector
/// with the specified, possibly variable, elements. The number of elements
/// is required to be a power of two.
BUILD_VECTOR,
- /// VINSERT_VECTOR_ELT(VECTOR, VAL, IDX, COUNT,TYPE) - Given a vector
- /// VECTOR, an element ELEMENT, and a (potentially variable) index IDX,
- /// return an vector with the specified element of VECTOR replaced with VAL.
- /// COUNT and TYPE specify the type of vector, as is standard for V* nodes.
- VINSERT_VECTOR_ELT,
-
- /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR (a legal packed
- /// type) with the element at IDX replaced with VAL.
+ /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element
+ /// at IDX replaced with VAL.
INSERT_VECTOR_ELT,
- /// VEXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR
- /// (an MVT::Vector value) identified by the (potentially variable) element
- /// number IDX.
- VEXTRACT_VECTOR_ELT,
-
/// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR
- /// (a legal packed type vector) identified by the (potentially variable)
- /// element number IDX.
+ /// identified by the (potentially variable) element number IDX.
EXTRACT_VECTOR_ELT,
- /// VVECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC, COUNT,TYPE) - Returns a vector,
- /// of the same type as VEC1/VEC2. SHUFFLEVEC is a VBUILD_VECTOR of
- /// constant int values that indicate which value each result element will
- /// get. The elements of VEC1/VEC2 are enumerated in order. This is quite
- /// similar to the Altivec 'vperm' instruction, except that the indices must
- /// be constants and are in terms of the element size of VEC1/VEC2, not in
- /// terms of bytes.
- VVECTOR_SHUFFLE,
-
+ /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of
+ /// vector type with the same length and element type, this produces a
+ /// concatenated vector result value, with length equal to the sum of the
+ /// lengths of the input vectors.
+ CONCAT_VECTORS,
+
+ /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an
+ /// vector value) starting with the (potentially variable) element number
+ /// IDX, which must be a multiple of the result vector length.
+ EXTRACT_SUBVECTOR,
+
/// VECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC) - Returns a vector, of the same
/// type as VEC1/VEC2. SHUFFLEVEC is a BUILD_VECTOR of constant int values
/// (regardless of whether its datatype is legal or not) that indicate
/// of the element size of VEC1/VEC2, not in terms of bytes.
VECTOR_SHUFFLE,
- /// X = VBIT_CONVERT(Y) and X = VBIT_CONVERT(Y, COUNT,TYPE) - This node
- /// represents a conversion from or to an ISD::Vector type.
- ///
- /// This is lowered to a BIT_CONVERT of the appropriate input/output types.
- /// The input and output are required to have the same size and at least one
- /// is required to be a vector (if neither is a vector, just use
- /// BIT_CONVERT).
- ///
- /// If the result is a vector, this takes three operands (like any other
- /// vector producer) which indicate the size and type of the vector result.
- /// Otherwise it takes one input.
- VBIT_CONVERT,
-
- /// BINOP(LHS, RHS, COUNT,TYPE)
- /// Simple abstract vector operators. Unlike the integer and floating point
- /// binary operators, these nodes also take two additional operands:
- /// a constant element count, and a value type node indicating the type of
- /// the elements. The order is count, type, op0, op1. All vector opcodes,
- /// including VLOAD and VConstant must currently have count and type as
- /// their last two operands.
- VADD, VSUB, VMUL, VSDIV, VUDIV,
- VAND, VOR, VXOR,
-
- /// VSELECT(COND,LHS,RHS, COUNT,TYPE) - Select for MVT::Vector values.
- /// COND is a boolean value. This node return LHS if COND is true, RHS if
- /// COND is false.
- VSELECT,
-
/// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a
/// scalar value into the low element of the resultant vector type. The top
/// elements of the vector are undefined.
// indexed memory ops).
LOAD, STORE,
- // Abstract vector version of LOAD. VLOAD has a constant element count as
- // the first operand, followed by a value type node indicating the type of
- // the elements, a token chain, a pointer operand, and a SRCVALUE node.
- VLOAD,
-
// TRUNCSTORE - This operators truncates (for integer) or rounds (for FP) a
// value and stores it to memory in one operation. This can be used for
// either integer or floating point operands. The first four operands of
TRUNCSTORE,
// DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned
- // to a specified boundary. The first operand is the token chain, the
- // second is the number of bytes to allocate, and the third is the alignment
- // boundary. The size is guaranteed to be a multiple of the stack
- // alignment, and the alignment is guaranteed to be bigger than the stack
+ // to a specified boundary. This node always has two return values: a new
+ // stack pointer value and a chain. The first operand is the token chain,
+ // the second is the number of bytes to allocate, and the third is the
+ // alignment boundary. The size is guaranteed to be a multiple of the stack
+ // alignment, and the alignment is guaranteed to be bigger than the stack
// alignment (if required) or 0 to get standard stack alignment.
DYNAMIC_STACKALLOC,
// Operand #0 : input chain.
// Operand #1 : module unique number use to identify the label.
LABEL,
-
+
// STACKSAVE - STACKSAVE has one operand, an input chain. It produces a
// value, the same type as the pointer type for the system, and an output
// chain.
};
+template<> struct DenseMapKeyInfo<SDOperand> {
+ static inline SDOperand getEmptyKey() { return SDOperand((SDNode*)-1, -1U); }
+ static inline SDOperand getTombstoneKey() { return SDOperand((SDNode*)-1, 0);}
+ static unsigned getHashValue(const SDOperand &Val) {
+ return (unsigned)((uintptr_t)Val.Val >> 4) ^
+ (unsigned)((uintptr_t)Val.Val >> 9) + Val.ResNo;
+ }
+ static bool isPod() { return true; }
+};
+
/// simplify_type specializations - Allow casting operators to work directly on
/// SDOperands as if they were SDNode*'s.
template<> struct simplify_type<SDOperand> {
/// getOperationName - Return the opcode of this operation for printing.
///
- const char* getOperationName(const SelectionDAG *G = 0) const;
+ std::string getOperationName(const SelectionDAG *G = 0) const;
static const char* getIndexedModeName(ISD::MemIndexedMode AM);
void dump() const;
void dump(const SelectionDAG *G) const;
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
SDOperand Op;
public:
- HandleSDNode(SDOperand X)
+ explicit HandleSDNode(SDOperand X)
: SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)), Op(X) {
InitOperands(&Op, 1);
}
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
- StringSDNode(const std::string &val)
+ explicit StringSDNode(const std::string &val)
: SDNode(ISD::STRING, getSDVTList(MVT::Other)), Value(val) {
}
public:
protected:
friend class SelectionDAG;
GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT::ValueType VT,
- int o = 0)
- : SDNode(isTarget ? ISD::TargetGlobalAddress : ISD::GlobalAddress,
- getSDVTList(VT)), Offset(o) {
- TheGlobal = const_cast<GlobalValue*>(GA);
- }
+ int o = 0);
public:
GlobalValue *getGlobal() const { return TheGlobal; }
static bool classof(const GlobalAddressSDNode *) { return true; }
static bool classof(const SDNode *N) {
return N->getOpcode() == ISD::GlobalAddress ||
- N->getOpcode() == ISD::TargetGlobalAddress;
+ N->getOpcode() == ISD::TargetGlobalAddress ||
+ N->getOpcode() == ISD::GlobalTLSAddress ||
+ N->getOpcode() == ISD::TargetGlobalTLSAddress;
}
};
-
class FrameIndexSDNode : public SDNode {
int FI;
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
- BasicBlockSDNode(MachineBasicBlock *mbb)
+ explicit BasicBlockSDNode(MachineBasicBlock *mbb)
: SDNode(ISD::BasicBlock, getSDVTList(MVT::Other)), MBB(mbb) {
}
public:
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
- CondCodeSDNode(ISD::CondCode Cond)
+ explicit CondCodeSDNode(ISD::CondCode Cond)
: SDNode(ISD::CONDCODE, getSDVTList(MVT::Other)), Condition(Cond) {
}
public:
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
- VTSDNode(MVT::ValueType VT)
+ explicit VTSDNode(MVT::ValueType VT)
: SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other)), ValueType(VT) {
}
public:
friend class SelectionDAG;
LoadSDNode(SDOperand *ChainPtrOff, SDVTList VTs,
ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT::ValueType LVT,
- const Value *SV, int O=0, unsigned Align=1, bool Vol=false)
+ const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
: SDNode(ISD::LOAD, VTs),
AddrMode(AM), ExtType(ETy), LoadedVT(LVT), SrcValue(SV), SVOffset(O),
Alignment(Align), IsVolatile(Vol) {
Ops[1] = ChainPtrOff[1]; // Ptr
Ops[2] = ChainPtrOff[2]; // Off
InitOperands(Ops, 3);
+ assert(Align != 0 && "Loads should have non-zero aligment");
assert((getOffset().getOpcode() == ISD::UNDEF ||
AddrMode != ISD::UNINDEXED) &&
"Only indexed load has a non-undef offset operand");
Ops[2] = ChainValuePtrOff[2]; // Ptr
Ops[3] = ChainValuePtrOff[3]; // Off
InitOperands(Ops, 4);
+ assert(Align != 0 && "Stores should have non-zero aligment");
assert((getOffset().getOpcode() == ISD::UNDEF ||
AddrMode != ISD::UNINDEXED) &&
"Only indexed store has a non-undef offset operand");
cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
}
+ /// isUNINDEXEDLoad - Returns true if the specified node is a unindexed load.
+ ///
+ inline bool isUNINDEXEDLoad(const SDNode *N) {
+ return N->getOpcode() == ISD::LOAD &&
+ cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
+ }
+
/// isNON_TRUNCStore - Returns true if the specified node is a non-truncating
/// store.
inline bool isNON_TRUNCStore(const SDNode *N) {