#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/Value.h"
#include "llvm/ADT/GraphTraits.h"
-#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/iterator"
#include "llvm/Support/DataTypes.h"
#include <cassert>
class MachineBasicBlock;
class SDNode;
template <typename T> struct simplify_type;
+template <typename T> struct ilist_traits;
+template<typename NodeTy, typename Traits> class iplist;
+template<typename NodeTy> class ilist_iterator;
/// ISD namespace - This namespace contains an enum which represents all of the
/// SelectionDAG node types and value types.
// EntryToken - This is the marker used to indicate the start of the region.
EntryToken,
- // Token factor - This node is takes multiple tokens as input and produces a
+ // Token factor - This node takes multiple tokens as input and produces a
// single token result. This is used to represent the fact that the operand
// operators are independent of each other.
TokenFactor,
+
+ // AssertSext, AssertZext - These nodes record if a register contains a
+ // value that has already been zero or sign extended from a narrower type.
+ // These nodes take two operands. The first is the node that has already
+ // been extended, and the second is a value type node indicating the width
+ // of the extension
+ AssertSext, AssertZext,
// Various leaf nodes.
- Constant, ConstantFP, GlobalAddress, FrameIndex, ConstantPool,
+ Constant, ConstantFP, STRING,
+ GlobalAddress, FrameIndex, ConstantPool,
BasicBlock, ExternalSymbol, VALUETYPE, CONDCODE, Register,
+ // ConstantVec works like Constant or ConstantFP, except that it is not a
+ // leaf node. All operands are either Constant or ConstantFP nodes.
+ ConstantVec,
+
// TargetConstant - Like Constant, but the DAG does not do any folding or
// simplification of the constant. This is used by the DAG->DAG selector.
TargetConstant,
+
+ // TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or
+ // anything else with this node, and this is valid in the target-specific
+ // dag, turning into a GlobalAddress operand.
+ TargetGlobalAddress,
+ TargetFrameIndex,
+ TargetConstantPool,
+ TargetExternalSymbol,
// CopyToReg - This node has three operands: a chain, a register number to
// set to this value, and a value.
// SelectionDAG. The register is available from the RegSDNode object.
CopyFromReg,
- // ImplicitDef - This node indicates that the specified register is
- // implicitly defined by some operation (e.g. its a live-in argument). The
- // two operands to this are the token chain coming in and the register.
- // The only result is the token chain going out.
- ImplicitDef,
-
// UNDEF - An undefined node
UNDEF,
// two values of the same integer value type, this produces a value twice as
// big. Like EXTRACT_ELEMENT, this can only be used before legalization.
BUILD_PAIR,
-
-
- // Simple binary arithmetic operators.
+
+ // MERGE_VALUES - This node takes multiple discrete operands and returns
+ // them all as its individual results. This nodes has exactly the same
+ // number of inputs and outputs, and is only valid before legalization.
+ // This node is useful for some pieces of the code generator that want to
+ // think about a single node with multiple results, not multiple nodes.
+ MERGE_VALUES,
+
+ // Simple integer binary arithmetic operators.
ADD, SUB, MUL, SDIV, UDIV, SREM, UREM,
+
+ // Simple binary floating point operators.
+ FADD, FSUB, FMUL, FDIV, FREM,
+
+ // 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 op0, op1, count, type. All vector opcodes,
+ // including VLOAD, must currently have count and type as their 3rd and 4th
+ // arguments.
+ VADD, VSUB, VMUL,
// MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing
// an unsigned/signed value of type i[2*n], then return the top part.
// ZERO_EXTEND - Used for integer types, zeroing the new bits.
ZERO_EXTEND,
+ // ANY_EXTEND - Used for integer types. The high bits are undefined.
+ ANY_EXTEND,
+
// TRUNCATE - Completely drop the high bits.
TRUNCATE,
// FP_EXTEND - 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,
+
// FNEG, FABS, FSQRT, FSIN, FCOS - Perform unary floating point negation,
// absolute value, square root, sine and cosine operations.
FNEG, FABS, FSQRT, FSIN, FCOS,
// operand, then the same operands as an LLVM load/store instruction, then a
// SRCVALUE node that provides alias analysis information.
LOAD, STORE,
+
+ // Abstract vector version of LOAD. VLOAD has a token chain as the first
+ // operand, followed by a pointer operand, a constant element count, a value
+ // type node indicating the type of the elements, and a SRCVALUE node.
+ VLOAD,
// EXTLOAD, SEXTLOAD, ZEXTLOAD - These three operators all load a value from
// memory and extend them to a larger value (e.g. load a byte into a word
// 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.
+ // 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,
// Control flow instructions. These all have token chains.
// PCMARKER - This corresponds to the pcmarker intrinsic.
PCMARKER,
+ // READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
+ // The only operand is a chain and a value and a chain are produced. The
+ // value is the contents of the architecture specific cycle counter like
+ // register (or other high accuracy low latency clock source)
+ READCYCLECOUNTER,
+
// READPORT, WRITEPORT, READIO, WRITEIO - These correspond to the LLVM
// intrinsics of the same name. The first operand is a token chain, the
// other operands match the intrinsic. These produce a token chain in
// addition to a value (if any).
READPORT, WRITEPORT, READIO, WRITEIO,
-
+
+ // HANDLENODE node - Used as a handle for various purposes.
+ HANDLENODE,
+
+ // LOCATION - This node is used to represent a source location for debug
+ // info. It takes token chain as input, then a line number, then a column
+ // number, then a filename, then a working dir. It produces a token chain
+ // as output.
+ LOCATION,
+
+ // 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 MachineDebugInfo.) It
+ // produces a token chain as output.
+ DEBUG_LOC,
+
+ // DEBUG_LABEL - This node is used to mark a location in the code where a
+ // label should be generated for use by the debug information. It takes a
+ // token chain as input and then a unique id (provided by MachineDebugInfo.)
+ // It produces a token chain as output.
+ DEBUG_LABEL,
+
// BUILTIN_OP_END - This must be the last enum value in this list.
BUILTIN_OP_END,
};
inline unsigned getNodeDepth() const;
inline unsigned getNumOperands() const;
inline const SDOperand &getOperand(unsigned i) const;
+ inline bool isTargetOpcode() const;
+ inline unsigned getTargetOpcode() const;
/// hasOneUse - Return true if there is exactly one operation using this
/// result value of the defining operator.
/// depth of 2, etc.
unsigned short NodeDepth;
- /// Operands - The values that are used by this operation.
+ /// OperandList - The values that are used by this operation.
///
- std::vector<SDOperand> Operands;
+ SDOperand *OperandList;
+
+ /// ValueList - The types of the values this node defines. SDNode's may
+ /// define multiple values simultaneously.
+ MVT::ValueType *ValueList;
- /// Values - The types of the values this node defines. SDNode's may define
- /// multiple values simultaneously.
- std::vector<MVT::ValueType> Values;
+ /// NumOperands/NumValues - The number of entries in the Operand/Value list.
+ unsigned short NumOperands, NumValues;
+
+ /// Prev/Next pointers - These pointers form the linked list of of the
+ /// AllNodes list in the current DAG.
+ SDNode *Prev, *Next;
+ friend struct ilist_traits<SDNode>;
/// Uses - These are all of the SDNode's that use a value produced by this
/// node.
std::vector<SDNode*> Uses;
public:
-
+ virtual ~SDNode() {
+ assert(NumOperands == 0 && "Operand list not cleared before deletion");
+ }
+
//===--------------------------------------------------------------------===//
// Accessors
//
unsigned getOpcode() const { return NodeType; }
+ bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
+ unsigned getTargetOpcode() const {
+ assert(isTargetOpcode() && "Not a target opcode!");
+ return NodeType - ISD::BUILTIN_OP_END;
+ }
size_t use_size() const { return Uses.size(); }
bool use_empty() const { return Uses.empty(); }
/// getNumOperands - Return the number of values used by this operation.
///
- unsigned getNumOperands() const { return Operands.size(); }
-
- const SDOperand &getOperand(unsigned Num) {
- assert(Num < Operands.size() && "Invalid child # of SDNode!");
- return Operands[Num];
- }
+ unsigned getNumOperands() const { return NumOperands; }
const SDOperand &getOperand(unsigned Num) const {
- assert(Num < Operands.size() && "Invalid child # of SDNode!");
- return Operands[Num];
+ assert(Num < NumOperands && "Invalid child # of SDNode!");
+ return OperandList[Num];
}
- typedef std::vector<SDOperand>::const_iterator op_iterator;
- op_iterator op_begin() const { return Operands.begin(); }
- op_iterator op_end() const { return Operands.end(); }
+ typedef const SDOperand* op_iterator;
+ op_iterator op_begin() const { return OperandList; }
+ op_iterator op_end() const { return OperandList+NumOperands; }
/// getNumValues - Return the number of values defined/returned by this
/// operator.
///
- unsigned getNumValues() const { return Values.size(); }
+ unsigned getNumValues() const { return NumValues; }
/// getValueType - Return the type of a specified result.
///
MVT::ValueType getValueType(unsigned ResNo) const {
- assert(ResNo < Values.size() && "Illegal result number!");
- return Values[ResNo];
+ assert(ResNo < NumValues && "Illegal result number!");
+ return ValueList[ResNo];
}
- typedef std::vector<MVT::ValueType>::const_iterator value_iterator;
- value_iterator value_begin() const { return Values.begin(); }
- value_iterator value_end() const { return Values.end(); }
+ typedef const MVT::ValueType* value_iterator;
+ value_iterator value_begin() const { return ValueList; }
+ value_iterator value_end() const { return ValueList+NumValues; }
/// getOperationName - Return the opcode of this operation for printing.
///
protected:
friend class SelectionDAG;
+
+ /// getValueTypeList - Return a pointer to the specified value type.
+ ///
+ static MVT::ValueType *getValueTypeList(MVT::ValueType VT);
SDNode(unsigned NT, MVT::ValueType VT) : NodeType(NT), NodeDepth(1) {
- Values.reserve(1);
- Values.push_back(VT);
+ OperandList = 0; NumOperands = 0;
+ ValueList = getValueTypeList(VT);
+ NumValues = 1;
+ Prev = 0; Next = 0;
}
SDNode(unsigned NT, SDOperand Op)
: NodeType(NT), NodeDepth(Op.Val->getNodeDepth()+1) {
- Operands.reserve(1); Operands.push_back(Op);
+ OperandList = new SDOperand[1];
+ OperandList[0] = Op;
+ NumOperands = 1;
Op.Val->Uses.push_back(this);
+ ValueList = 0;
+ NumValues = 0;
+ Prev = 0; Next = 0;
}
SDNode(unsigned NT, SDOperand N1, SDOperand N2)
: NodeType(NT) {
NodeDepth = N1.Val->getNodeDepth()+1;
else
NodeDepth = N2.Val->getNodeDepth()+1;
- Operands.reserve(2); Operands.push_back(N1); Operands.push_back(N2);
+ OperandList = new SDOperand[2];
+ OperandList[0] = N1;
+ OperandList[1] = N2;
+ NumOperands = 2;
N1.Val->Uses.push_back(this); N2.Val->Uses.push_back(this);
+ ValueList = 0;
+ NumValues = 0;
+ Prev = 0; Next = 0;
}
SDNode(unsigned NT, SDOperand N1, SDOperand N2, SDOperand N3)
: NodeType(NT) {
ND = N3.Val->getNodeDepth();
NodeDepth = ND+1;
- Operands.reserve(3); Operands.push_back(N1); Operands.push_back(N2);
- Operands.push_back(N3);
+ OperandList = new SDOperand[3];
+ OperandList[0] = N1;
+ OperandList[1] = N2;
+ OperandList[2] = N3;
+ NumOperands = 3;
+
N1.Val->Uses.push_back(this); N2.Val->Uses.push_back(this);
N3.Val->Uses.push_back(this);
+ ValueList = 0;
+ NumValues = 0;
+ Prev = 0; Next = 0;
}
SDNode(unsigned NT, SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4)
: NodeType(NT) {
ND = N4.Val->getNodeDepth();
NodeDepth = ND+1;
- Operands.reserve(4); Operands.push_back(N1); Operands.push_back(N2);
- Operands.push_back(N3); Operands.push_back(N4);
+ OperandList = new SDOperand[4];
+ OperandList[0] = N1;
+ OperandList[1] = N2;
+ OperandList[2] = N3;
+ OperandList[3] = N4;
+ NumOperands = 4;
+
N1.Val->Uses.push_back(this); N2.Val->Uses.push_back(this);
N3.Val->Uses.push_back(this); N4.Val->Uses.push_back(this);
+ ValueList = 0;
+ NumValues = 0;
+ Prev = 0; Next = 0;
}
- SDNode(unsigned NT, std::vector<SDOperand> &Nodes) : NodeType(NT) {
- Operands.swap(Nodes);
+ SDNode(unsigned Opc, const std::vector<SDOperand> &Nodes) : NodeType(Opc) {
+ NumOperands = Nodes.size();
+ OperandList = new SDOperand[NumOperands];
+
unsigned ND = 0;
- for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
- Operands[i].Val->Uses.push_back(this);
- if (ND < Operands[i].Val->getNodeDepth())
- ND = Operands[i].Val->getNodeDepth();
+ for (unsigned i = 0, e = Nodes.size(); i != e; ++i) {
+ OperandList[i] = Nodes[i];
+ SDNode *N = OperandList[i].Val;
+ N->Uses.push_back(this);
+ if (ND < N->getNodeDepth()) ND = N->getNodeDepth();
}
NodeDepth = ND+1;
+ ValueList = 0;
+ NumValues = 0;
+ Prev = 0; Next = 0;
}
- virtual ~SDNode() {}
-
/// MorphNodeTo - This clears the return value and operands list, and sets the
/// opcode of the node to the specified value. This should only be used by
/// the SelectionDAG class.
void MorphNodeTo(unsigned Opc) {
NodeType = Opc;
- Values.clear();
+ ValueList = 0;
+ NumValues = 0;
// Clear the operands list, updating used nodes to remove this from their
// use list.
- while (!Operands.empty()) {
- SDNode *O = Operands.back().Val;
- Operands.pop_back();
- O->removeUser(this);
- }
+ for (op_iterator I = op_begin(), E = op_end(); I != E; ++I)
+ I->Val->removeUser(this);
+ delete [] OperandList;
+ OperandList = 0;
+ NumOperands = 0;
}
void setValueTypes(MVT::ValueType VT) {
- Values.reserve(1);
- Values.push_back(VT);
+ assert(NumValues == 0 && "Should not have values yet!");
+ ValueList = getValueTypeList(VT);
+ NumValues = 1;
}
- void setValueTypes(MVT::ValueType VT1, MVT::ValueType VT2) {
- Values.reserve(2);
- Values.push_back(VT1);
- Values.push_back(VT2);
- }
- /// Note: this method destroys the vector passed in.
- void setValueTypes(std::vector<MVT::ValueType> &VTs) {
- std::swap(Values, VTs);
+ void setValueTypes(MVT::ValueType *List, unsigned NumVal) {
+ assert(NumValues == 0 && "Should not have values yet!");
+ ValueList = List;
+ NumValues = NumVal;
}
void setOperands(SDOperand Op0) {
- Operands.reserve(1);
- Operands.push_back(Op0);
+ assert(NumOperands == 0 && "Should not have operands yet!");
+ OperandList = new SDOperand[1];
+ OperandList[0] = Op0;
+ NumOperands = 1;
Op0.Val->Uses.push_back(this);
}
void setOperands(SDOperand Op0, SDOperand Op1) {
- Operands.reserve(2);
- Operands.push_back(Op0);
- Operands.push_back(Op1);
+ assert(NumOperands == 0 && "Should not have operands yet!");
+ OperandList = new SDOperand[2];
+ OperandList[0] = Op0;
+ OperandList[1] = Op1;
+ NumOperands = 2;
Op0.Val->Uses.push_back(this); Op1.Val->Uses.push_back(this);
}
void setOperands(SDOperand Op0, SDOperand Op1, SDOperand Op2) {
- Operands.reserve(3);
- Operands.push_back(Op0);
- Operands.push_back(Op1);
- Operands.push_back(Op2);
+ assert(NumOperands == 0 && "Should not have operands yet!");
+ OperandList = new SDOperand[3];
+ OperandList[0] = Op0;
+ OperandList[1] = Op1;
+ OperandList[2] = Op2;
+ NumOperands = 3;
Op0.Val->Uses.push_back(this); Op1.Val->Uses.push_back(this);
Op2.Val->Uses.push_back(this);
}
+ void setOperands(SDOperand Op0, SDOperand Op1, SDOperand Op2, SDOperand Op3) {
+ assert(NumOperands == 0 && "Should not have operands yet!");
+ OperandList = new SDOperand[4];
+ OperandList[0] = Op0;
+ OperandList[1] = Op1;
+ OperandList[2] = Op2;
+ OperandList[3] = Op3;
+ NumOperands = 4;
+ Op0.Val->Uses.push_back(this); Op1.Val->Uses.push_back(this);
+ Op2.Val->Uses.push_back(this); Op3.Val->Uses.push_back(this);
+ }
+ void setOperands(SDOperand Op0, SDOperand Op1, SDOperand Op2, SDOperand Op3,
+ SDOperand Op4) {
+ assert(NumOperands == 0 && "Should not have operands yet!");
+ OperandList = new SDOperand[5];
+ OperandList[0] = Op0;
+ OperandList[1] = Op1;
+ OperandList[2] = Op2;
+ OperandList[3] = Op3;
+ OperandList[4] = Op4;
+ NumOperands = 5;
+ Op0.Val->Uses.push_back(this); Op1.Val->Uses.push_back(this);
+ Op2.Val->Uses.push_back(this); Op3.Val->Uses.push_back(this);
+ Op4.Val->Uses.push_back(this);
+ }
+ void setOperands(SDOperand Op0, SDOperand Op1, SDOperand Op2, SDOperand Op3,
+ SDOperand Op4, SDOperand Op5) {
+ assert(NumOperands == 0 && "Should not have operands yet!");
+ OperandList = new SDOperand[6];
+ OperandList[0] = Op0;
+ OperandList[1] = Op1;
+ OperandList[2] = Op2;
+ OperandList[3] = Op3;
+ OperandList[4] = Op4;
+ OperandList[5] = Op5;
+ NumOperands = 6;
+ Op0.Val->Uses.push_back(this); Op1.Val->Uses.push_back(this);
+ Op2.Val->Uses.push_back(this); Op3.Val->Uses.push_back(this);
+ Op4.Val->Uses.push_back(this); Op5.Val->Uses.push_back(this);
+ }
void addUser(SDNode *User) {
Uses.push_back(User);
}
inline const SDOperand &SDOperand::getOperand(unsigned i) const {
return Val->getOperand(i);
}
+inline bool SDOperand::isTargetOpcode() const {
+ return Val->isTargetOpcode();
+}
+inline unsigned SDOperand::getTargetOpcode() const {
+ return Val->getTargetOpcode();
+}
inline bool SDOperand::hasOneUse() const {
return Val->hasNUsesOfValue(1, ResNo);
}
+/// HandleSDNode - This class is used to form a handle around another node that
+/// is persistant and is updated across invocations of replaceAllUsesWith on its
+/// operand. This node should be directly created by end-users and not added to
+/// the AllNodes list.
+class HandleSDNode : public SDNode {
+public:
+ HandleSDNode(SDOperand X) : SDNode(ISD::HANDLENODE, X) {}
+ ~HandleSDNode() {
+ MorphNodeTo(ISD::HANDLENODE); // Drops operand uses.
+ }
+
+ SDOperand getValue() const { return getOperand(0); }
+};
+
+class StringSDNode : public SDNode {
+ std::string Value;
+protected:
+ friend class SelectionDAG;
+ StringSDNode(const std::string &val)
+ : SDNode(ISD::STRING, MVT::Other), Value(val) {
+ }
+public:
+ const std::string &getValue() const { return Value; }
+ static bool classof(const StringSDNode *) { return true; }
+ static bool classof(const SDNode *N) {
+ return N->getOpcode() == ISD::STRING;
+ }
+};
class ConstantSDNode : public SDNode {
uint64_t Value;
/// it returns true for things that are clearly not equal, like -0.0 and 0.0.
/// As such, this method can be used to do an exact bit-for-bit comparison of
/// two floating point values.
- bool isExactlyValue(double V) const {
- union {
- double V;
- uint64_t I;
- } T1;
- T1.V = Value;
- union {
- double V;
- uint64_t I;
- } T2;
- T2.V = V;
- return T1.I == T2.I;
- }
+ bool isExactlyValue(double V) const;
static bool classof(const ConstantFPSDNode *) { return true; }
static bool classof(const SDNode *N) {
class GlobalAddressSDNode : public SDNode {
GlobalValue *TheGlobal;
+ int offset;
protected:
friend class SelectionDAG;
- GlobalAddressSDNode(const GlobalValue *GA, MVT::ValueType VT)
- : SDNode(ISD::GlobalAddress, VT) {
+ GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT::ValueType VT,
+ int o=0)
+ : SDNode(isTarget ? ISD::TargetGlobalAddress : ISD::GlobalAddress, VT) {
TheGlobal = const_cast<GlobalValue*>(GA);
+ offset = o;
}
public:
GlobalValue *getGlobal() const { return TheGlobal; }
+ int getOffset() const { return offset; }
static bool classof(const GlobalAddressSDNode *) { return true; }
static bool classof(const SDNode *N) {
- return N->getOpcode() == ISD::GlobalAddress;
+ return N->getOpcode() == ISD::GlobalAddress ||
+ N->getOpcode() == ISD::TargetGlobalAddress;
}
};
int FI;
protected:
friend class SelectionDAG;
- FrameIndexSDNode(int fi, MVT::ValueType VT)
- : SDNode(ISD::FrameIndex, VT), FI(fi) {}
+ FrameIndexSDNode(int fi, MVT::ValueType VT, bool isTarg)
+ : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, VT), FI(fi) {}
public:
int getIndex() const { return FI; }
static bool classof(const FrameIndexSDNode *) { return true; }
static bool classof(const SDNode *N) {
- return N->getOpcode() == ISD::FrameIndex;
+ return N->getOpcode() == ISD::FrameIndex ||
+ N->getOpcode() == ISD::TargetFrameIndex;
}
};
class ConstantPoolSDNode : public SDNode {
- unsigned CPI;
+ Constant *C;
protected:
friend class SelectionDAG;
- ConstantPoolSDNode(unsigned cpi, MVT::ValueType VT)
- : SDNode(ISD::ConstantPool, VT), CPI(cpi) {}
+ ConstantPoolSDNode(Constant *c, MVT::ValueType VT, bool isTarget)
+ : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, VT),
+ C(c) {}
public:
- unsigned getIndex() const { return CPI; }
+ Constant *get() const { return C; }
static bool classof(const ConstantPoolSDNode *) { return true; }
static bool classof(const SDNode *N) {
- return N->getOpcode() == ISD::ConstantPool;
+ return N->getOpcode() == ISD::ConstantPool ||
+ N->getOpcode() == ISD::TargetConstantPool;
}
};
const char *Symbol;
protected:
friend class SelectionDAG;
- ExternalSymbolSDNode(const char *Sym, MVT::ValueType VT)
- : SDNode(ISD::ExternalSymbol, VT), Symbol(Sym) {
+ ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT::ValueType VT)
+ : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, VT),
+ Symbol(Sym) {
}
public:
static bool classof(const ExternalSymbolSDNode *) { return true; }
static bool classof(const SDNode *N) {
- return N->getOpcode() == ISD::ExternalSymbol;
+ return N->getOpcode() == ISD::ExternalSymbol ||
+ N->getOpcode() == ISD::TargetExternalSymbol;
}
};
}
};
+template<>
+struct ilist_traits<SDNode> {
+ static SDNode *getPrev(const SDNode *N) { return N->Prev; }
+ static SDNode *getNext(const SDNode *N) { return N->Next; }
+
+ static void setPrev(SDNode *N, SDNode *Prev) { N->Prev = Prev; }
+ static void setNext(SDNode *N, SDNode *Next) { N->Next = Next; }
+
+ static SDNode *createSentinel() {
+ return new SDNode(ISD::EntryToken, MVT::Other);
+ }
+ static void destroySentinel(SDNode *N) { delete N; }
+ //static SDNode *createNode(const SDNode &V) { return new SDNode(V); }
+
+
+ void addNodeToList(SDNode *NTy) {}
+ void removeNodeFromList(SDNode *NTy) {}
+ void transferNodesFromList(iplist<SDNode, ilist_traits> &L2,
+ const ilist_iterator<SDNode> &X,
+ const ilist_iterator<SDNode> &Y) {}
+};
+
} // end llvm namespace
#endif