aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/CodeGen/ScheduleDAG.h12
-rw-r--r--include/llvm/CodeGen/SelectionDAG.h28
-rw-r--r--include/llvm/CodeGen/SelectionDAGNodes.h253
-rw-r--r--lib/CodeGen/SelectionDAG/DAGCombiner.cpp3
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeDAG.cpp14
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeTypes.cpp14
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeTypes.h12
-rw-r--r--lib/CodeGen/SelectionDAG/ScheduleDAG.cpp16
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp100
-rw-r--r--lib/Target/X86/X86ISelLowering.cpp12
10 files changed, 272 insertions, 192 deletions
diff --git a/include/llvm/CodeGen/ScheduleDAG.h b/include/llvm/CodeGen/ScheduleDAG.h
index 48f1b78482..bc9ec11260 100644
--- a/include/llvm/CodeGen/ScheduleDAG.h
+++ b/include/llvm/CodeGen/ScheduleDAG.h
@@ -334,7 +334,7 @@ namespace llvm {
/// register number for the results of the node.
///
void EmitNode(SDNode *Node, unsigned InstNo,
- DenseMap<SDOperandImpl, unsigned> &VRBaseMap);
+ DenseMap<SDOperand, unsigned> &VRBaseMap);
/// EmitNoop - Emit a noop instruction.
///
@@ -352,11 +352,11 @@ namespace llvm {
/// EmitSubregNode - Generate machine code for subreg nodes.
///
void EmitSubregNode(SDNode *Node,
- DenseMap<SDOperandImpl, unsigned> &VRBaseMap);
+ DenseMap<SDOperand, unsigned> &VRBaseMap);
/// getVR - Return the virtual register corresponding to the specified result
/// of the specified node.
- unsigned getVR(SDOperand Op, DenseMap<SDOperandImpl, unsigned> &VRBaseMap);
+ unsigned getVR(SDOperand Op, DenseMap<SDOperand, unsigned> &VRBaseMap);
/// getDstOfCopyToRegUse - If the only use of the specified result number of
/// node is a CopyToReg, return its destination register. Return 0 otherwise.
@@ -364,7 +364,7 @@ namespace llvm {
void AddOperand(MachineInstr *MI, SDOperand Op, unsigned IIOpNum,
const TargetInstrDesc *II,
- DenseMap<SDOperandImpl, unsigned> &VRBaseMap);
+ DenseMap<SDOperand, unsigned> &VRBaseMap);
void AddMemOperand(MachineInstr *MI, const MachineMemOperand &MO);
@@ -374,11 +374,11 @@ namespace llvm {
/// implicit physical register output.
void EmitCopyFromReg(SDNode *Node, unsigned ResNo, unsigned InstNo,
unsigned SrcReg,
- DenseMap<SDOperandImpl, unsigned> &VRBaseMap);
+ DenseMap<SDOperand, unsigned> &VRBaseMap);
void CreateVirtualRegisters(SDNode *Node, MachineInstr *MI,
const TargetInstrDesc &II,
- DenseMap<SDOperandImpl, unsigned> &VRBaseMap);
+ DenseMap<SDOperand, unsigned> &VRBaseMap);
/// EmitLiveInCopy - Emit a copy for a live in physical register. If the
/// physical register has only a single copy use, then coalesced the copy
diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h
index 390e44dc53..eceb0272f5 100644
--- a/include/llvm/CodeGen/SelectionDAG.h
+++ b/include/llvm/CodeGen/SelectionDAG.h
@@ -304,11 +304,11 @@ public:
SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4,
SDOperand N5);
SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
- const SDOperand *Ops, unsigned NumOps);
+ SDOperandPtr Ops, unsigned NumOps);
SDOperand getNode(unsigned Opcode, std::vector<MVT::ValueType> &ResultTys,
- const SDOperand *Ops, unsigned NumOps);
+ SDOperandPtr Ops, unsigned NumOps);
SDOperand getNode(unsigned Opcode, const MVT::ValueType *VTs, unsigned NumVTs,
- const SDOperand *Ops, unsigned NumOps);
+ SDOperandPtr Ops, unsigned NumOps);
SDOperand getNode(unsigned Opcode, SDVTList VTs);
SDOperand getNode(unsigned Opcode, SDVTList VTs, SDOperand N);
SDOperand getNode(unsigned Opcode, SDVTList VTs,
@@ -321,7 +321,7 @@ public:
SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4,
SDOperand N5);
SDOperand getNode(unsigned Opcode, SDVTList VTs,
- const SDOperand *Ops, unsigned NumOps);
+ SDOperandPtr Ops, unsigned NumOps);
SDOperand getMemcpy(SDOperand Chain, SDOperand Dst, SDOperand Src,
SDOperand Size, unsigned Align,
@@ -420,7 +420,7 @@ public:
SDOperand Op3, SDOperand Op4);
SDOperand UpdateNodeOperands(SDOperand N, SDOperand Op1, SDOperand Op2,
SDOperand Op3, SDOperand Op4, SDOperand Op5);
- SDOperand UpdateNodeOperands(SDOperand N, SDOperand *Ops, unsigned NumOps);
+ SDOperand UpdateNodeOperands(SDOperand N, SDOperandPtr Ops, unsigned NumOps);
/// SelectNodeTo - These are used for target selectors to *mutate* the
/// specified node to have the specified return type, Target opcode, and
@@ -435,7 +435,7 @@ public:
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT,
SDOperand Op1, SDOperand Op2, SDOperand Op3);
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT,
- const SDOperand *Ops, unsigned NumOps);
+ SDOperandPtr Ops, unsigned NumOps);
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT1,
MVT::ValueType VT2, SDOperand Op1, SDOperand Op2);
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT1,
@@ -457,7 +457,7 @@ public:
SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
SDOperand Op1, SDOperand Op2, SDOperand Op3);
SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
- const SDOperand *Ops, unsigned NumOps);
+ SDOperandPtr Ops, unsigned NumOps);
SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
MVT::ValueType VT2);
SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
@@ -469,7 +469,7 @@ public:
SDOperand Op3);
SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
MVT::ValueType VT2,
- const SDOperand *Ops, unsigned NumOps);
+ SDOperandPtr Ops, unsigned NumOps);
SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
MVT::ValueType VT2, MVT::ValueType VT3,
SDOperand Op1, SDOperand Op2);
@@ -478,18 +478,18 @@ public:
SDOperand Op1, SDOperand Op2, SDOperand Op3);
SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
MVT::ValueType VT2, MVT::ValueType VT3,
- const SDOperand *Ops, unsigned NumOps);
+ SDOperandPtr Ops, unsigned NumOps);
SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
MVT::ValueType VT2, MVT::ValueType VT3,
MVT::ValueType VT4,
- const SDOperand *Ops, unsigned NumOps);
+ SDOperandPtr Ops, unsigned NumOps);
SDNode *getTargetNode(unsigned Opcode, std::vector<MVT::ValueType> &ResultTys,
- const SDOperand *Ops, unsigned NumOps);
+ SDOperandPtr Ops, unsigned NumOps);
/// getNodeIfExists - Get the specified node if it's already available, or
/// else return NULL.
SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTs,
- const SDOperand *Ops, unsigned NumOps);
+ SDOperandPtr Ops, unsigned NumOps);
/// DAGUpdateListener - Clients of various APIs that cause global effects on
/// the DAG can optionally implement this interface. This allows the clients
@@ -519,7 +519,7 @@ public:
DAGUpdateListener *UpdateListener = 0);
void ReplaceAllUsesWith(SDNode *From, SDNode *To,
DAGUpdateListener *UpdateListener = 0);
- void ReplaceAllUsesWith(SDNode *From, const SDOperand *To,
+ void ReplaceAllUsesWith(SDNode *From, SDOperandPtr To,
DAGUpdateListener *UpdateListener = 0);
/// ReplaceAllUsesOfValueWith - Replace any uses of From with To, leaving
@@ -606,7 +606,7 @@ private:
SDNode *FindModifiedNodeSlot(SDNode *N, SDOperand Op, void *&InsertPos);
SDNode *FindModifiedNodeSlot(SDNode *N, SDOperand Op1, SDOperand Op2,
void *&InsertPos);
- SDNode *FindModifiedNodeSlot(SDNode *N, const SDOperand *Ops, unsigned NumOps,
+ SDNode *FindModifiedNodeSlot(SDNode *N, SDOperandPtr Ops, unsigned NumOps,
void *&InsertPos);
void DeleteNodeNotInCSEMaps(SDNode *N);
diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h
index bc654946a7..74f7600f53 100644
--- a/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -771,7 +771,7 @@ namespace ISD {
//===----------------------------------------------------------------------===//
-/// SDOperandImpl - Unlike LLVM values, Selection DAG nodes may return multiple
+/// SDOperand - Unlike LLVM values, Selection DAG nodes may return multiple
/// values as the result of a computation. Many nodes return multiple values,
/// from loads (which define a token and a return value) to ADDC (which returns
/// a result and a carry value), to calls (which may return an arbitrary number
@@ -779,28 +779,28 @@ namespace ISD {
///
/// As such, each use of a SelectionDAG computation must indicate the node that
/// computes it as well as which return value to use from that node. This pair
-/// of information is represented with the SDOperandImpl value type.
+/// of information is represented with the SDOperand value type.
///
-class SDOperandImpl {
+class SDOperand {
public:
SDNode *Val; // The node defining the value we are using.
unsigned ResNo; // Which return value of the node we are using.
- SDOperandImpl() : Val(0), ResNo(0) {}
- SDOperandImpl(SDNode *val, unsigned resno) : Val(val), ResNo(resno) {}
+ SDOperand() : Val(0), ResNo(0) {}
+ SDOperand(SDNode *val, unsigned resno) : Val(val), ResNo(resno) {}
- bool operator==(const SDOperandImpl &O) const {
+ bool operator==(const SDOperand &O) const {
return Val == O.Val && ResNo == O.ResNo;
}
- bool operator!=(const SDOperandImpl &O) const {
+ bool operator!=(const SDOperand &O) const {
return !operator==(O);
}
- bool operator<(const SDOperandImpl &O) const {
+ bool operator<(const SDOperand &O) const {
return Val < O.Val || (Val == O.Val && ResNo < O.ResNo);
}
- SDOperandImpl getValue(unsigned R) const {
- return SDOperandImpl(Val, R);
+ SDOperand getValue(unsigned R) const {
+ return SDOperand(Val, R);
}
// isOperandOf - Return true if this node is an operand of N.
@@ -819,7 +819,7 @@ public:
// Forwarding methods - These forward to the corresponding methods in SDNode.
inline unsigned getOpcode() const;
inline unsigned getNumOperands() const;
- inline const SDOperandImpl &getOperand(unsigned i) const;
+ inline const SDOperand &getOperand(unsigned i) const;
inline uint64_t getConstantOperandVal(unsigned i) const;
inline bool isTargetOpcode() const;
inline unsigned getTargetOpcode() const;
@@ -830,7 +830,7 @@ public:
/// side-effecting instructions. In practice, this looks through token
/// factors and non-volatile loads. In order to remain efficient, this only
/// looks a couple of nodes in, it does not do an exhaustive search.
- bool reachesChainWithoutSideEffects(SDOperandImpl Dest,
+ bool reachesChainWithoutSideEffects(SDOperand Dest,
unsigned Depth = 2) const;
/// hasOneUse - Return true if there is exactly one operation using this
@@ -843,18 +843,18 @@ public:
};
-template<> struct DenseMapInfo<SDOperandImpl> {
- static inline SDOperandImpl getEmptyKey() {
- return SDOperandImpl((SDNode*)-1, -1U);
+template<> struct DenseMapInfo<SDOperand> {
+ static inline SDOperand getEmptyKey() {
+ return SDOperand((SDNode*)-1, -1U);
}
- static inline SDOperandImpl getTombstoneKey() {
- return SDOperandImpl((SDNode*)-1, 0);
+ static inline SDOperand getTombstoneKey() {
+ return SDOperand((SDNode*)-1, 0);
}
- static unsigned getHashValue(const SDOperandImpl &Val) {
+ static unsigned getHashValue(const SDOperand &Val) {
return ((unsigned)((uintptr_t)Val.Val >> 4) ^
(unsigned)((uintptr_t)Val.Val >> 9)) + Val.ResNo;
}
- static bool isEqual(const SDOperandImpl &LHS, const SDOperandImpl &RHS) {
+ static bool isEqual(const SDOperand &LHS, const SDOperand &RHS) {
return LHS == RHS;
}
static bool isPod() { return true; }
@@ -862,73 +862,90 @@ template<> struct DenseMapInfo<SDOperandImpl> {
/// simplify_type specializations - Allow casting operators to work directly on
/// SDOperands as if they were SDNode*'s.
-template<> struct simplify_type<SDOperandImpl> {
+template<> struct simplify_type<SDOperand> {
typedef SDNode* SimpleType;
- static SimpleType getSimplifiedValue(const SDOperandImpl &Val) {
+ static SimpleType getSimplifiedValue(const SDOperand &Val) {
return static_cast<SimpleType>(Val.Val);
}
};
-template<> struct simplify_type<const SDOperandImpl> {
+template<> struct simplify_type<const SDOperand> {
typedef SDNode* SimpleType;
- static SimpleType getSimplifiedValue(const SDOperandImpl &Val) {
+ static SimpleType getSimplifiedValue(const SDOperand &Val) {
return static_cast<SimpleType>(Val.Val);
}
};
-/// SDOperand - Represents a use of the SDNode referred by
-/// the SDOperandImpl.
-class SDOperand: public SDOperandImpl {
+/// SDUse - Represents a use of the SDNode referred by
+/// the SDOperand.
+class SDUse {
+ SDOperand Operand;
/// parent - Parent node of this operand.
SDNode *parent;
/// Prev, next - Pointers to the uses list of the SDNode referred by
/// this operand.
- SDOperand **Prev, *Next;
+ SDUse **Prev, *Next;
public:
friend class SDNode;
- SDOperand(): SDOperandImpl(), parent(NULL), Prev(NULL), Next(NULL) {}
+ SDUse(): Operand(), parent(NULL), Prev(NULL), Next(NULL) {}
- SDOperand(SDNode *val, unsigned resno) :
- SDOperandImpl(val,resno), parent(NULL), Prev(NULL), Next(NULL) {}
+ SDUse(SDNode *val, unsigned resno) :
+ Operand(val,resno), parent(NULL), Prev(NULL), Next(NULL) {}
- SDOperand(const SDOperandImpl& Op): SDOperandImpl(Op),parent(NULL),
- Prev(NULL), Next(NULL) {
- }
- SDOperand& operator= (SDOperandImpl& Op) {
- *(SDOperandImpl*)this = Op;
+ SDUse& operator= (SDOperand& Op) {
+ Operand = Op;
Next = NULL;
Prev = NULL;
return *this;
}
- SDOperand& operator= (const SDOperandImpl& Op) {
- *(SDOperandImpl*)this = Op;
+ SDUse& operator= (const SDOperand& Op) {
+ Operand = Op;
Next = NULL;
Prev = NULL;
return *this;
}
- SDOperand& operator= (SDOperand& Op) {
- *(SDOperandImpl*)this = Op;
+ SDUse& operator= (SDUse& Op) {
+ Operand = Op;
Next = NULL;
Prev = NULL;
return *this;
}
- SDOperand& operator= (const SDOperand& Op) {
- *(SDOperandImpl*)this = Op;
+ SDUse& operator= (const SDUse& Op) {
+ Operand = Op;
Next = NULL;
Prev = NULL;
return *this;
}
- SDOperand * getNext() { return Next; }
+ SDUse * getNext() { return Next; }
SDNode *getUser() { return parent; }
+
void setUser(SDNode *p) { parent = p; }
+ operator SDOperand() const { return Operand; }
+
+ const SDOperand& getSDOperand() const { return Operand; }
+
+ SDNode* &getVal () { return Operand.Val; }
+
+ bool operator==(const SDOperand &O) const {
+ return Operand == O;
+ }
+
+ bool operator!=(const SDOperand &O) const {
+ return !(Operand == O);
+ }
+
+ bool operator<(const SDOperand &O) const {
+ return Operand < O;
+ }
+
protected:
- void addToList(SDOperand **List) {
+ void addToList(SDUse **List) {
Next = *List;
if (Next) Next->Prev = &Next;
Prev = List;
@@ -944,20 +961,62 @@ protected:
/// simplify_type specializations - Allow casting operators to work directly on
/// SDOperands as if they were SDNode*'s.
-template<> struct simplify_type<SDOperand> {
+template<> struct simplify_type<SDUse> {
typedef SDNode* SimpleType;
- static SimpleType getSimplifiedValue(const SDOperand &Val) {
- return static_cast<SimpleType>(Val.Val);
+ static SimpleType getSimplifiedValue(const SDUse &Val) {
+ return static_cast<SimpleType>(Val.getSDOperand().Val);
}
};
-template<> struct simplify_type<const SDOperand> {
+template<> struct simplify_type<const SDUse> {
typedef SDNode* SimpleType;
- static SimpleType getSimplifiedValue(const SDOperand &Val) {
- return static_cast<SimpleType>(Val.Val);
+ static SimpleType getSimplifiedValue(const SDUse &Val) {
+ return static_cast<SimpleType>(Val.getSDOperand().Val);
}
};
+/// SDOperandPtr - A helper SDOperand poiner class, that can handle
+/// arrays of SDUse and arrays of SDOperand objects. This is required
+/// in many places inside the SelectionDAG.
+///
+class SDOperandPtr {
+ const SDOperand *ptr; // The pointer to the SDOperand object
+ int object_size; // The size of the object containg the SDOperand
+public:
+ SDOperandPtr(SDUse * use_ptr) {
+ ptr = &use_ptr->getSDOperand();
+ object_size = sizeof(SDUse);
+ }
+
+ SDOperandPtr(const SDOperand * op_ptr) {
+ ptr = op_ptr;
+ object_size = sizeof(SDOperand);
+ }
+
+ operator const SDOperand *() const {
+ assert(object_size == sizeof(SDOperand) &&
+ "Only SDOperand can be converted");
+ return ptr;
+ }
+
+ const SDOperand operator *() { return *ptr; }
+ const SDOperand *operator ->() { return ptr; }
+ SDOperandPtr operator ++ () {
+ ptr = (SDOperand*)((char *)ptr + object_size);
+ return *this;
+ }
+
+ SDOperandPtr operator ++ (int) {
+ SDOperandPtr tmp = *this;
+ ptr = (SDOperand*)((char *)ptr + object_size);
+ return tmp;
+ }
+
+ SDOperand operator[] (int idx) const {
+ return *(SDOperand*)((char*) ptr + object_size * idx);
+ }
+};
+
/// SDNode - Represents one node in the SelectionDAG.
///
class SDNode : public FoldingSetNode {
@@ -975,7 +1034,7 @@ private:
/// OperandList - The values that are used by this operation.
///
- SDOperand *OperandList;
+ SDUse *OperandList;
/// ValueList - The types of the values this node defines. SDNode's may
/// define multiple values simultaneously.
@@ -993,10 +1052,10 @@ private:
unsigned UsesSize;
/// Uses - List of uses for this SDNode.
- SDOperand *Uses;
+ SDUse *Uses;
- /// addUse - add SDOperand to the list of uses.
- void addUse(SDOperand &U) { U.addToList(&Uses); }
+ /// 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();
@@ -1027,17 +1086,17 @@ public:
/// setNodeId - Set unique node id.
void setNodeId(int Id) { NodeId = Id; }
- /// use_iterator - This class provides iterator support for SDOperand
+ /// use_iterator - This class provides iterator support for SDUse
/// operands that use a specific SDNode.
class use_iterator
- : public forward_iterator<SDOperand, ptrdiff_t> {
- SDOperand *Op;
- explicit use_iterator(SDOperand *op) : Op(op) {
+ : public forward_iterator<SDUse, ptrdiff_t> {
+ SDUse *Op;
+ explicit use_iterator(SDUse *op) : Op(op) {
}
friend class SDNode;
public:
- typedef forward_iterator<SDOperand, ptrdiff_t>::reference reference;
- typedef forward_iterator<SDOperand, ptrdiff_t>::pointer pointer;
+ typedef forward_iterator<SDUse, ptrdiff_t>::reference reference;
+ typedef forward_iterator<SDUse, ptrdiff_t>::pointer pointer;
use_iterator(const use_iterator &I) : Op(I.Op) {}
use_iterator() : Op(0) {}
@@ -1071,13 +1130,13 @@ public:
}
/// Retrieve a reference to the current operand.
- SDOperand &operator*() const {
+ SDUse &operator*() const {
assert(Op && "Cannot dereference end iterator!");
return *Op;
}
/// Retrieve a pointer to the current operand.
- SDOperand *operator->() const {
+ SDUse *operator->() const {
assert(Op && "Cannot dereference end iterator!");
return Op;
}
@@ -1130,10 +1189,10 @@ public:
const SDOperand &getOperand(unsigned Num) const {
assert(Num < NumOperands && "Invalid child # of SDNode!");
- return OperandList[Num];
+ return OperandList[Num].getSDOperand();
}
- typedef SDOperand* op_iterator;
+ typedef SDUse* op_iterator;
op_iterator op_begin() const { return OperandList; }
op_iterator op_end() const { return OperandList+NumOperands; }
@@ -1193,7 +1252,25 @@ protected:
: NodeType(Opc), NodeId(-1), UsesSize(0), Uses(NULL) {
OperandsNeedDelete = true;
NumOperands = NumOps;
- OperandList = NumOps ? new SDOperand[NumOperands] : 0;
+ OperandList = NumOps ? new SDUse[NumOperands] : 0;
+
+ for (unsigned i = 0; i != NumOps; ++i) {
+ OperandList[i] = Ops[i];
+ OperandList[i].setUser(this);
+ Ops[i].Val->addUse(OperandList[i]);
+ ++Ops[i].Val->UsesSize;
+ }
+
+ ValueList = VTs.VTs;
+ NumValues = VTs.NumVTs;
+ Prev = 0; Next = 0;
+ }
+
+ SDNode(unsigned Opc, SDVTList VTs, SDOperandPtr Ops, unsigned NumOps)
+ : NodeType(Opc), NodeId(-1), UsesSize(0), Uses(NULL) {
+ OperandsNeedDelete = true;
+ NumOperands = NumOps;
+ OperandList = NumOps ? new SDUse[NumOperands] : 0;
for (unsigned i = 0; i != NumOps; ++i) {
OperandList[i] = Ops[i];
@@ -1220,7 +1297,7 @@ protected:
/// InitOperands - Initialize the operands list of this node with the
/// specified values, which are part of the node (thus they don't need to be
/// copied in or allocated).
- void InitOperands(SDOperand *Ops, unsigned NumOps) {
+ void InitOperands(SDUse *Ops, unsigned NumOps) {
assert(OperandList == 0 && "Operands already set!");
NumOperands = NumOps;
OperandList = Ops;
@@ -1229,8 +1306,8 @@ protected:
for (unsigned i = 0; i != NumOps; ++i) {
OperandList[i].setUser(this);
- Ops[i].Val->addUse(OperandList[i]);
- ++Ops[i].Val->UsesSize;
+ Ops[i].getVal()->addUse(OperandList[i]);
+ ++Ops[i].getVal()->UsesSize;
}
}
@@ -1248,40 +1325,40 @@ protected:
void removeUser(unsigned i, SDNode *User) {
assert(User->OperandList[i].getUser() && "Node without parent");
- SDOperand &Op = User->OperandList[i];
+ SDUse &Op = User->OperandList[i];
Op.removeFromList();
--UsesSize;
}
};
-// Define inline functions from the SDOperandImpl class.
+// Define inline functions from the SDOperand class.
-inline unsigned SDOperandImpl::getOpcode() const {
+inline unsigned SDOperand::getOpcode() const {
return Val->getOpcode();
}
-inline MVT::ValueType SDOperandImpl::getValueType() const {
+inline MVT::ValueType SDOperand::getValueType() const {
return Val->getValueType(ResNo);
}
-inline unsigned SDOperandImpl::getNumOperands() const {
+inline unsigned SDOperand::getNumOperands() const {
return Val->getNumOperands();
}
-inline const SDOperandImpl &SDOperandImpl::getOperand(unsigned i) const {
+inline const SDOperand &SDOperand::getOperand(unsigned i) const {
return Val->getOperand(i);
}
-inline uint64_t SDOperandImpl::getConstantOperandVal(unsigned i) const {
+inline uint64_t SDOperand::getConstantOperandVal(unsigned i) const {
return Val->getConstantOperandVal(i);
}
-inline bool SDOperandImpl::isTargetOpcode() const {
+inline bool SDOperand::isTargetOpcode() const {
return Val->isTargetOpcode();
}
-inline unsigned SDOperandImpl::getTargetOpcode() const {
+inline unsigned SDOperand::getTargetOpcode() const {
return Val->getTargetOpcode();
}
-inline bool SDOperandImpl::hasOneUse() const {
+inline bool SDOperand::hasOneUse() const {
return Val->hasNUsesOfValue(1, ResNo);
}
-inline bool SDOperandImpl::use_empty() const {
+inline bool SDOperand::use_empty() const {
return !Val->hasAnyUseOfValue(ResNo);
}
@@ -1289,10 +1366,11 @@ inline bool SDOperandImpl::use_empty() const {
/// 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.
- SDOperand Op;
+ SDUse Op;
public:
UnarySDNode(unsigned Opc, SDVTList VTs, SDOperand X)
- : SDNode(Opc, VTs), Op(X) {
+ : SDNode(Opc, VTs) {
+ Op = X;
InitOperands(&Op, 1);
}
};
@@ -1301,7 +1379,7 @@ public:
/// 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.
- SDOperand Ops[2];
+ SDUse Ops[2];
public:
BinarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y)
: SDNode(Opc, VTs) {
@@ -1315,7 +1393,7 @@ public:
/// 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.
- SDOperand Ops[3];
+ SDUse Ops[3];
public:
TernarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y,
SDOperand Z)
@@ -1334,19 +1412,20 @@ public:
/// the AllNodes list.
class HandleSDNode : public SDNode {
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
- SDOperand Op;
+ SDUse Op;
public:
explicit HandleSDNode(SDOperand X)
- : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)), Op(X) {
+ : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)) {
+ Op = X;
InitOperands(&Op, 1);
}
~HandleSDNode();
- SDOperand getValue() const { return Op; }
+ SDUse getValue() const { return Op; }
};
class AtomicSDNode : public SDNode {
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
- SDOperand Ops[4];
+ SDUse Ops[4];
MVT::ValueType OrigVT;
public:
AtomicSDNode(unsigned Opc, SDVTList VTL, SDOperand Chain, SDOperand Ptr,
@@ -1867,7 +1946,7 @@ protected:
common functionality shared between LoadSDNode and
StoreSDNode
*/
- SDOperand Ops[4];
+ SDUse Ops[4];
public:
LSBaseSDNode(ISD::NodeType NodeTy, SDOperand *Operands, unsigned NumOperands,
SDVTList VTs, ISD::MemIndexedMode AM, MVT::ValueType VT,
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 4eccb815e3..6ac549b9cf 100644
--- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -3880,7 +3880,8 @@ SDOperand DAGCombiner::visitFP_EXTEND(SDNode *N) {
MVT::ValueType VT = N->getValueType(0);
// If this is fp_round(fpextend), don't fold it, allow ourselves to be folded.
- if (N->hasOneUse() && (N->use_begin())->getOpcode() == ISD::FP_ROUND)
+ if (N->hasOneUse() &&
+ N->use_begin()->getSDOperand().getOpcode() == ISD::FP_ROUND)
return SDOperand();
// fold (fp_extend c1fp) -> c1fp
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index d8bc82df85..377c627b23 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -86,17 +86,17 @@ class VISIBILITY_HIDDEN SelectionDAGLegalize {
/// LegalizedNodes - For nodes that are of legal width, and that have more
/// than one use, this map indicates what regularized operand to use. This
/// allows us to avoid legalizing the same thing more than once.
- DenseMap<SDOperandImpl, SDOperand> LegalizedNodes;
+ DenseMap<SDOperand, SDOperand> LegalizedNodes;
/// PromotedNodes - For nodes that are below legal width, and that have more
/// than one use, this map indicates what promoted value to use. This allows
/// us to avoid promoting the same thing more than once.
- DenseMap<SDOperandImpl, SDOperand> PromotedNodes;
+ DenseMap<SDOperand, SDOperand> PromotedNodes;
/// ExpandedNodes - For nodes that need to be expanded this map indicates
/// which which operands are the expanded version of the input. This allows
/// us to avoid expanding the same node more than once.
- DenseMap<SDOperandImpl, std::pair<SDOperand, SDOperand> > ExpandedNodes;
+ DenseMap<SDOperand, std::pair<SDOperand, SDOperand> > ExpandedNodes;
/// SplitNodes - For vector nodes that need to be split, this map indicates
/// which which operands are the split version of the input. This allows us
@@ -784,7 +784,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
// Note that LegalizeOp may be reentered even from single-use nodes, which
// means that we always must cache transformed nodes.
- DenseMap<SDOperandImpl, SDOperand>::iterator I = LegalizedNodes.find(Op);
+ DenseMap<SDOperand, SDOperand>::iterator I = LegalizedNodes.find(Op);
if (I != LegalizedNodes.end()) return I->second;
SDOperand Tmp1, Tmp2, Tmp3, Tmp4;
@@ -1600,7 +1600,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
// will cause this node to be legalized as well as handling libcalls right.
if (LastCALLSEQ_END.Val != Node) {
LegalizeOp(SDOperand(FindCallStartFromCallEnd(Node), 0));
- DenseMap<SDOperandImpl, SDOperand>::iterator I = LegalizedNodes.find(Op);
+ DenseMap<SDOperand, SDOperand>::iterator I = LegalizedNodes.find(Op);
assert(I != LegalizedNodes.end() &&
"Legalizing the call start should have legalized this node!");
return I->second;
@@ -4016,7 +4016,7 @@ SDOperand SelectionDAGLegalize::PromoteOp(SDOperand Op) {
SDOperand Result;
SDNode *Node = Op.Val;
- DenseMap<SDOperandImpl, SDOperand>::iterator I = PromotedNodes.find(Op);
+ DenseMap<SDOperand, SDOperand>::iterator I = PromotedNodes.find(Op);
if (I != PromotedNodes.end()) return I->second;
switch (Node->getOpcode()) {
@@ -5721,7 +5721,7 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){
"Cannot expand to FP value or to larger int value!");
// See if we already expanded it.
- DenseMap<SDOperandImpl, std::pair<SDOperand, SDOperand> >::iterator I
+ DenseMap<SDOperand, std::pair<SDOperand, SDOperand> >::iterator I
= ExpandedNodes.find(Op);
if (I != ExpandedNodes.end()) {
Lo = I->second.first;
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
index c26656a867..67977b1eb3 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
@@ -273,39 +273,39 @@ void DAGTypeLegalizer::SanityCheck(SDNode *N) {
E = Worklist.end(); I != E; ++I)
assert(*I != N);
- for (DenseMap<SDOperandImpl, SDOperand>::iterator I = ReplacedNodes.begin(),
+ for (DenseMap<SDOperand, SDOperand>::iterator I = ReplacedNodes.begin(),
E = ReplacedNodes.end(); I != E; ++I) {
assert(I->first.Val != N);
assert(I->second.Val != N);
}
- for (DenseMap<SDOperandImpl, SDOperand>::iterator I = PromotedNodes.begin(),
+ for (DenseMap<SDOperand, SDOperand>::iterator I = PromotedNodes.begin(),
E = PromotedNodes.end(); I != E; ++I) {
assert(I->first.Val != N);
assert(I->second.Val != N);
}
- for (DenseMap<SDOperandImpl, SDOperand>::iterator
+ for (DenseMap<SDOperand, SDOperand>::iterator
I = FloatToIntedNodes.begin(),
E = FloatToIntedNodes.end(); I != E; ++I) {
assert(I->first.Val != N);
assert(I->second.Val != N);
}
- for (DenseMap<SDOperandImpl, SDOperand>::iterator I = ScalarizedNodes.begin(),
+ for (DenseMap<SDOperand, SDOperand>::iterator I = ScalarizedNodes.begin(),
E = ScalarizedNodes.end(); I != E; ++I) {
assert(I->first.Val != N);
assert(I->second.Val != N);
}
- for (DenseMap<SDOperandImpl, std::pair<SDOperand, SDOperand> >::iterator
+ for (DenseMap<SDOperand, std::pair<SDOperand, SDOperand> >::iterator
I = ExpandedNodes.begin(), E = ExpandedNodes.end(); I != E; ++I) {
assert(I->first.Val != N);
assert(I->second.first.Val != N);
assert(I->second.second.Val != N);
}
- for (DenseMap<SDOperandImpl, std::pair<SDOperand, SDOperand> >::iterator
+ for (DenseMap<SDOperand, std::pair<SDOperand, SDOperand> >::iterator
I = SplitNodes.begin(), E = SplitNodes.end(); I != E; ++I) {
assert(I->first.Val != N);
assert(I->second.first.Val != N);
@@ -393,7 +393,7 @@ void DAGTypeLegalizer::ReplaceNodeWith(SDNode *From, SDNode *To) {
/// RemapNode - If the specified value was already legalized to another value,
/// replace it by that value.
void DAGTypeLegalizer::RemapNode(SDOperand &N) {
- DenseMap<SDOperandImpl, SDOperand>::iterator I = ReplacedNodes.find(N);
+ DenseMap<SDOperand, SDOperand>::iterator I = ReplacedNodes.find(N);
if (I != ReplacedNodes.end()) {
// Use path compression to speed up future lookups if values get multiply
// replaced with other values.
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.h b/lib/CodeGen/SelectionDAG/LegalizeTypes.h
index d2196f3dd5..7ca4ae4579 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeTypes.h
+++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.h
@@ -110,27 +110,27 @@ private:
/// PromotedNodes - For nodes that are below legal width, this map indicates
/// what promoted value to use.
- DenseMap<SDOperandImpl, SDOperand> PromotedNodes;
+ DenseMap<SDOperand, SDOperand> PromotedNodes;
/// ExpandedNodes - For nodes that need to be expanded this map indicates
/// which operands are the expanded version of the input.
- DenseMap<SDOperandImpl, std::pair<SDOperand, SDOperand> > ExpandedNodes;
+ DenseMap<SDOperand, std::pair<SDOperand, SDOperand> > ExpandedNodes;
/// FloatToIntedNodes - For floating point nodes converted to integers of
/// the same size, this map indicates the converted value to use.
- DenseMap<SDOperandImpl, SDOperand> FloatToIntedNodes;
+ DenseMap<SDOperand, SDOperand> FloatToIntedNodes;
/// ScalarizedNodes - For nodes that are <1 x ty>, this map indicates the
/// scalar value of type 'ty' to use.
- DenseMap<SDOperandImpl, SDOperand> ScalarizedNodes;
+ DenseMap<SDOperand, SDOperand> ScalarizedNodes;
/// SplitNodes - For nodes that need to be split this map indicates