/// addUse - add SDUse to the list of uses.
void addUse(SDUse &U) { U.addToList(&Uses); }
- // Out-of-line virtual method to give class a home.
- virtual void ANCHOR();
public:
- virtual ~SDNode() {
- assert(NumOperands == 0 && "Operand list not cleared before deletion");
- NodeType = ISD::DELETED_NODE;
- }
-
//===--------------------------------------------------------------------===//
// Accessors
//
/// UnarySDNode - This class is used for single-operand SDNodes. This is solely
/// to allow co-allocation of node operands with the node itself.
class UnarySDNode : public SDNode {
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
SDUse Op;
public:
UnarySDNode(unsigned Opc, SDVTList VTs, SDValue X)
/// BinarySDNode - This class is used for two-operand SDNodes. This is solely
/// to allow co-allocation of node operands with the node itself.
class BinarySDNode : public SDNode {
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
SDUse Ops[2];
public:
BinarySDNode(unsigned Opc, SDVTList VTs, SDValue X, SDValue Y)
/// TernarySDNode - This class is used for three-operand SDNodes. This is solely
/// to allow co-allocation of node operands with the node itself.
class TernarySDNode : public SDNode {
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
SDUse Ops[3];
public:
TernarySDNode(unsigned Opc, SDVTList VTs, SDValue X, SDValue Y,
/// operand. This node should be directly created by end-users and not added to
/// the AllNodes list.
class HandleSDNode : public SDNode {
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
SDUse Op;
public:
// FIXME: Remove the "noinline" attribute once <rdar://problem/5852746> is
/// Abstact virtual class for operations for memory operations
class MemSDNode : public SDNode {
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
-
private:
// MemoryVT - VT of in-memory value.
MVT MemoryVT;
/// AtomicSDNode - A SDNode reprenting atomic operations.
///
class AtomicSDNode : public MemSDNode {
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
SDUse Ops[4];
- public:
+public:
// Opc: opcode for atomic
// VTL: value type list
// Chain: memory chain for operaand
/// memory and need an associated memory operand.
///
class MemIntrinsicSDNode : public MemSDNode {
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
bool ReadMem; // Intrinsic reads memory
bool WriteMem; // Intrinsic writes memory
public:
class ConstantSDNode : public SDNode {
const ConstantInt *Value;
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
ConstantSDNode(bool isTarget, const ConstantInt *val, MVT VT)
class ConstantFPSDNode : public SDNode {
const ConstantFP *Value;
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
ConstantFPSDNode(bool isTarget, const ConstantFP *val, MVT VT)
class GlobalAddressSDNode : public SDNode {
GlobalValue *TheGlobal;
int64_t Offset;
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT VT,
class FrameIndexSDNode : public SDNode {
int FI;
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
FrameIndexSDNode(int fi, MVT VT, bool isTarg)
class JumpTableSDNode : public SDNode {
int JTI;
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
JumpTableSDNode(int jti, MVT VT, bool isTarg)
} Val;
int Offset; // It's a MachineConstantPoolValue if top bit is set.
unsigned Alignment;
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o=0)
class BasicBlockSDNode : public SDNode {
MachineBasicBlock *MBB;
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
explicit BasicBlockSDNode(MachineBasicBlock *mbb)
///
class SrcValueSDNode : public SDNode {
const Value *V;
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
/// Create a SrcValue for a general value.
/// and ISD::STORE have been lowered.
///
class MemOperandSDNode : public SDNode {
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
/// Create a MachineMemOperand node
class RegisterSDNode : public SDNode {
unsigned Reg;
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
RegisterSDNode(unsigned reg, MVT VT)
unsigned Line;
unsigned Column;
Value *CU;
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
DbgStopPointSDNode(SDValue ch, unsigned l, unsigned c,
class LabelSDNode : public SDNode {
SDUse Chain;
unsigned LabelID;
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
LabelSDNode(unsigned NodeTy, SDValue ch, unsigned id)
class ExternalSymbolSDNode : public SDNode {
const char *Symbol;
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT VT)
class CondCodeSDNode : public SDNode {
ISD::CondCode Condition;
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
explicit CondCodeSDNode(ISD::CondCode Cond)
/// future and most targets don't support it.
class CvtRndSatSDNode : public SDNode {
ISD::CvtCode CvtCode;
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
explicit CvtRndSatSDNode(MVT VT, const SDValue *Ops, unsigned NumOps,
/// ARG_FLAGSSDNode - Leaf node holding parameter flags.
class ARG_FLAGSSDNode : public SDNode {
ISD::ArgFlagsTy TheFlags;
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
explicit ARG_FLAGSSDNode(ISD::ArgFlagsTy Flags)
// will expand the size of the representation. At the moment we only
// need Inreg.
bool Inreg;
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
CallSDNode(unsigned cc, bool isvararg, bool istailcall, bool isinreg,
/// to parameterize some operations.
class VTSDNode : public SDNode {
MVT ValueType;
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
explicit VTSDNode(MVT VT)
/// LoadSDNode - This class is used to represent ISD::LOAD nodes.
///
class LoadSDNode : public LSBaseSDNode {
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
LoadSDNode(SDValue *ChainPtrOff, SDVTList VTs,
/// StoreSDNode - This class is used to represent ISD::STORE nodes.
///
class StoreSDNode : public LSBaseSDNode {
- virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
StoreSDNode(SDValue *ChainValuePtrOff, SDVTList VTs,
DeadNodes.push_back(Operand);
}
- if (N->OperandsNeedDelete)
- delete[] N->OperandList;
-
- N->OperandList = 0;
- N->NumOperands = 0;
-
- // Finally, remove N itself.
- NodeAllocator.Deallocate(AllNodes.remove(N));
+ DeallocateNode(N);
}
}
}
void SelectionDAG::DeleteNodeNotInCSEMaps(SDNode *N) {
+ assert(N != AllNodes.begin());
+
// Drop all of the operands and decrement used node's use counts.
for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I)
I->getVal()->removeUser(std::distance(N->op_begin(), I), N);
- if (N->OperandsNeedDelete) {
+ DeallocateNode(N);
+}
+
+void SelectionDAG::DeallocateNode(SDNode *N) {
+ if (N->OperandsNeedDelete)
delete[] N->OperandList;
- N->OperandList = 0;
- }
- assert(N != AllNodes.begin());
+ // Set the opcode to DELETED_NODE to help catch bugs when node
+ // memory is reallocated.
+ N->NodeType = ISD::DELETED_NODE;
+
NodeAllocator.Deallocate(AllNodes.remove(N));
}
void SelectionDAG::allnodes_clear() {
assert(&*AllNodes.begin() == &EntryNode);
AllNodes.remove(AllNodes.begin());
- while (!AllNodes.empty()) {
- SDNode *N = AllNodes.remove(AllNodes.begin());
- N->SetNextInBucket(0);
-
- if (N->OperandsNeedDelete) {
- delete [] N->OperandList;
- N->OperandList = 0;
- }
-
- NodeAllocator.Deallocate(N);
- }
+ while (!AllNodes.empty())
+ DeallocateNode(AllNodes.begin());
}
void SelectionDAG::clear() {
// SDNode Class
//===----------------------------------------------------------------------===//
-// Out-of-line virtual method to give class a home.
-void SDNode::ANCHOR() {}
-void UnarySDNode::ANCHOR() {}
-void BinarySDNode::ANCHOR() {}
-void TernarySDNode::ANCHOR() {}
-void HandleSDNode::ANCHOR() {}
-void ConstantSDNode::ANCHOR() {}
-void ConstantFPSDNode::ANCHOR() {}
-void GlobalAddressSDNode::ANCHOR() {}
-void FrameIndexSDNode::ANCHOR() {}
-void JumpTableSDNode::ANCHOR() {}
-void ConstantPoolSDNode::ANCHOR() {}
-void BasicBlockSDNode::ANCHOR() {}
-void SrcValueSDNode::ANCHOR() {}
-void MemOperandSDNode::ANCHOR() {}
-void RegisterSDNode::ANCHOR() {}
-void DbgStopPointSDNode::ANCHOR() {}
-void LabelSDNode::ANCHOR() {}
-void ExternalSymbolSDNode::ANCHOR() {}
-void CondCodeSDNode::ANCHOR() {}
-void ARG_FLAGSSDNode::ANCHOR() {}
-void VTSDNode::ANCHOR() {}
-void MemSDNode::ANCHOR() {}
-void LoadSDNode::ANCHOR() {}
-void StoreSDNode::ANCHOR() {}
-void AtomicSDNode::ANCHOR() {}
-void MemIntrinsicSDNode::ANCHOR() {}
-void CallSDNode::ANCHOR() {}
-void CvtRndSatSDNode::ANCHOR() {}
-
HandleSDNode::~HandleSDNode() {
DropOperands();
}