Ongoing work on improving the instruction selection infrastructure:

Rename SDOperandImpl back to SDOperand.
Introduce the SDUse class that represents a use of the SDNode referred by
an SDOperand. Now it is more similar to Use/Value classes.

Patch is approved by Dan Gohman.

llvm-svn: 49795
This commit is contained in:
Roman Levenstein 2008-04-16 16:15:27 +00:00
parent a7040d914f
commit 728d59166f
10 changed files with 324 additions and 244 deletions

View File

@ -334,7 +334,7 @@ namespace llvm {
/// register number for the results of the node. /// register number for the results of the node.
/// ///
void EmitNode(SDNode *Node, unsigned InstNo, void EmitNode(SDNode *Node, unsigned InstNo,
DenseMap<SDOperandImpl, unsigned> &VRBaseMap); DenseMap<SDOperand, unsigned> &VRBaseMap);
/// EmitNoop - Emit a noop instruction. /// EmitNoop - Emit a noop instruction.
/// ///
@ -352,11 +352,11 @@ namespace llvm {
/// EmitSubregNode - Generate machine code for subreg nodes. /// EmitSubregNode - Generate machine code for subreg nodes.
/// ///
void EmitSubregNode(SDNode *Node, void EmitSubregNode(SDNode *Node,
DenseMap<SDOperandImpl, unsigned> &VRBaseMap); DenseMap<SDOperand, unsigned> &VRBaseMap);
/// getVR - Return the virtual register corresponding to the specified result /// getVR - Return the virtual register corresponding to the specified result
/// of the specified node. /// 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 /// getDstOfCopyToRegUse - If the only use of the specified result number of
/// node is a CopyToReg, return its destination register. Return 0 otherwise. /// 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, void AddOperand(MachineInstr *MI, SDOperand Op, unsigned IIOpNum,
const TargetInstrDesc *II, const TargetInstrDesc *II,
DenseMap<SDOperandImpl, unsigned> &VRBaseMap); DenseMap<SDOperand, unsigned> &VRBaseMap);
void AddMemOperand(MachineInstr *MI, const MachineMemOperand &MO); void AddMemOperand(MachineInstr *MI, const MachineMemOperand &MO);
@ -374,11 +374,11 @@ namespace llvm {
/// implicit physical register output. /// implicit physical register output.
void EmitCopyFromReg(SDNode *Node, unsigned ResNo, unsigned InstNo, void EmitCopyFromReg(SDNode *Node, unsigned ResNo, unsigned InstNo,
unsigned SrcReg, unsigned SrcReg,
DenseMap<SDOperandImpl, unsigned> &VRBaseMap); DenseMap<SDOperand, unsigned> &VRBaseMap);
void CreateVirtualRegisters(SDNode *Node, MachineInstr *MI, void CreateVirtualRegisters(SDNode *Node, MachineInstr *MI,
const TargetInstrDesc &II, const TargetInstrDesc &II,
DenseMap<SDOperandImpl, unsigned> &VRBaseMap); DenseMap<SDOperand, unsigned> &VRBaseMap);
/// EmitLiveInCopy - Emit a copy for a live in physical register. If the /// EmitLiveInCopy - Emit a copy for a live in physical register. If the
/// physical register has only a single copy use, then coalesced the copy /// physical register has only a single copy use, then coalesced the copy

View File

@ -304,11 +304,11 @@ public:
SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4, SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4,
SDOperand N5); SDOperand N5);
SDOperand getNode(unsigned Opcode, MVT::ValueType VT, 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, 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, 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 getNode(unsigned Opcode, SDVTList VTs, SDOperand N); SDOperand getNode(unsigned Opcode, SDVTList VTs, SDOperand N);
SDOperand getNode(unsigned Opcode, SDVTList VTs, SDOperand getNode(unsigned Opcode, SDVTList VTs,
@ -321,7 +321,7 @@ public:
SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4, SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4,
SDOperand N5); SDOperand N5);
SDOperand getNode(unsigned Opcode, SDVTList VTs, SDOperand getNode(unsigned Opcode, SDVTList VTs,
const SDOperand *Ops, unsigned NumOps); SDOperandPtr Ops, unsigned NumOps);
SDOperand getMemcpy(SDOperand Chain, SDOperand Dst, SDOperand Src, SDOperand getMemcpy(SDOperand Chain, SDOperand Dst, SDOperand Src,
SDOperand Size, unsigned Align, SDOperand Size, unsigned Align,
@ -420,7 +420,7 @@ public:
SDOperand Op3, SDOperand Op4); SDOperand Op3, SDOperand Op4);
SDOperand UpdateNodeOperands(SDOperand N, SDOperand Op1, SDOperand Op2, SDOperand UpdateNodeOperands(SDOperand N, SDOperand Op1, SDOperand Op2,
SDOperand Op3, SDOperand Op4, SDOperand Op5); 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 /// SelectNodeTo - These are used for target selectors to *mutate* the
/// specified node to have the specified return type, Target opcode, and /// 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, SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT,
SDOperand Op1, SDOperand Op2, SDOperand Op3); SDOperand Op1, SDOperand Op2, SDOperand Op3);
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT, 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, SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT1,
MVT::ValueType VT2, SDOperand Op1, SDOperand Op2); MVT::ValueType VT2, SDOperand Op1, SDOperand Op2);
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT1, SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT1,
@ -457,7 +457,7 @@ public:
SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT, SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
SDOperand Op1, SDOperand Op2, SDOperand Op3); SDOperand Op1, SDOperand Op2, SDOperand Op3);
SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT, SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
const SDOperand *Ops, unsigned NumOps); SDOperandPtr Ops, unsigned NumOps);
SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1, SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
MVT::ValueType VT2); MVT::ValueType VT2);
SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1, SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
@ -469,7 +469,7 @@ public:
SDOperand Op3); SDOperand Op3);
SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1, SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
MVT::ValueType VT2, MVT::ValueType VT2,
const SDOperand *Ops, unsigned NumOps); SDOperandPtr Ops, unsigned NumOps);
SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1, SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
MVT::ValueType VT2, MVT::ValueType VT3, MVT::ValueType VT2, MVT::ValueType VT3,
SDOperand Op1, SDOperand Op2); SDOperand Op1, SDOperand Op2);
@ -478,18 +478,18 @@ public:
SDOperand Op1, SDOperand Op2, SDOperand Op3); SDOperand Op1, SDOperand Op2, SDOperand Op3);
SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1, SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
MVT::ValueType VT2, MVT::ValueType VT3, MVT::ValueType VT2, MVT::ValueType VT3,
const SDOperand *Ops, unsigned NumOps); SDOperandPtr Ops, unsigned NumOps);
SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1, SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
MVT::ValueType VT2, MVT::ValueType VT3, MVT::ValueType VT2, MVT::ValueType VT3,
MVT::ValueType VT4, MVT::ValueType VT4,
const SDOperand *Ops, unsigned NumOps); SDOperandPtr Ops, unsigned NumOps);
SDNode *getTargetNode(unsigned Opcode, std::vector<MVT::ValueType> &ResultTys, 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 /// getNodeIfExists - Get the specified node if it's already available, or
/// else return NULL. /// else return NULL.
SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTs, 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 /// DAGUpdateListener - Clients of various APIs that cause global effects on
/// the DAG can optionally implement this interface. This allows the clients /// the DAG can optionally implement this interface. This allows the clients
@ -519,7 +519,7 @@ public:
DAGUpdateListener *UpdateListener = 0); DAGUpdateListener *UpdateListener = 0);
void ReplaceAllUsesWith(SDNode *From, SDNode *To, void ReplaceAllUsesWith(SDNode *From, SDNode *To,
DAGUpdateListener *UpdateListener = 0); DAGUpdateListener *UpdateListener = 0);
void ReplaceAllUsesWith(SDNode *From, const SDOperand *To, void ReplaceAllUsesWith(SDNode *From, SDOperandPtr To,
DAGUpdateListener *UpdateListener = 0); DAGUpdateListener *UpdateListener = 0);
/// ReplaceAllUsesOfValueWith - Replace any uses of From with To, leaving /// 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 Op, void *&InsertPos);
SDNode *FindModifiedNodeSlot(SDNode *N, SDOperand Op1, SDOperand Op2, SDNode *FindModifiedNodeSlot(SDNode *N, SDOperand Op1, SDOperand Op2,
void *&InsertPos); void *&InsertPos);
SDNode *FindModifiedNodeSlot(SDNode *N, const SDOperand *Ops, unsigned NumOps, SDNode *FindModifiedNodeSlot(SDNode *N, SDOperandPtr Ops, unsigned NumOps,
void *&InsertPos); void *&InsertPos);
void DeleteNodeNotInCSEMaps(SDNode *N); void DeleteNodeNotInCSEMaps(SDNode *N);

View File

@ -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, /// 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 /// 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 /// 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 /// 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 /// 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: public:
SDNode *Val; // The node defining the value we are using. SDNode *Val; // The node defining the value we are using.
unsigned ResNo; // Which return value of the node we are using. unsigned ResNo; // Which return value of the node we are using.
SDOperandImpl() : Val(0), ResNo(0) {} SDOperand() : Val(0), ResNo(0) {}
SDOperandImpl(SDNode *val, unsigned resno) : Val(val), ResNo(resno) {} 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; return Val == O.Val && ResNo == O.ResNo;
} }
bool operator!=(const SDOperandImpl &O) const { bool operator!=(const SDOperand &O) const {
return !operator==(O); 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); return Val < O.Val || (Val == O.Val && ResNo < O.ResNo);
} }
SDOperandImpl getValue(unsigned R) const { SDOperand getValue(unsigned R) const {
return SDOperandImpl(Val, R); return SDOperand(Val, R);
} }
// isOperandOf - Return true if this node is an operand of N. // 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. // Forwarding methods - These forward to the corresponding methods in SDNode.
inline unsigned getOpcode() const; inline unsigned getOpcode() const;
inline unsigned getNumOperands() 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 uint64_t getConstantOperandVal(unsigned i) const;
inline bool isTargetOpcode() const; inline bool isTargetOpcode() const;
inline unsigned getTargetOpcode() const; inline unsigned getTargetOpcode() const;
@ -830,7 +830,7 @@ public:
/// side-effecting instructions. In practice, this looks through token /// side-effecting instructions. In practice, this looks through token
/// factors and non-volatile loads. In order to remain efficient, this only /// 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. /// 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; unsigned Depth = 2) const;
/// hasOneUse - Return true if there is exactly one operation using this /// hasOneUse - Return true if there is exactly one operation using this
@ -843,105 +843,23 @@ public:
}; };
template<> struct DenseMapInfo<SDOperandImpl> { template<> struct DenseMapInfo<SDOperand> {
static inline SDOperandImpl getEmptyKey() { static inline SDOperand getEmptyKey() {
return SDOperandImpl((SDNode*)-1, -1U); return SDOperand((SDNode*)-1, -1U);
} }
static inline SDOperandImpl getTombstoneKey() { static inline SDOperand getTombstoneKey() {
return SDOperandImpl((SDNode*)-1, 0); return SDOperand((SDNode*)-1, 0);
} }
static unsigned getHashValue(const SDOperandImpl &Val) { static unsigned getHashValue(const SDOperand &Val) {
return ((unsigned)((uintptr_t)Val.Val >> 4) ^ return ((unsigned)((uintptr_t)Val.Val >> 4) ^
(unsigned)((uintptr_t)Val.Val >> 9)) + Val.ResNo; (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; return LHS == RHS;
} }
static bool isPod() { return true; } 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<SDOperandImpl> {
typedef SDNode* SimpleType;
static SimpleType getSimplifiedValue(const SDOperandImpl &Val) {
return static_cast<SimpleType>(Val.Val);
}
};
template<> struct simplify_type<const SDOperandImpl> {
typedef SDNode* SimpleType;
static SimpleType getSimplifiedValue(const SDOperandImpl &Val) {
return static_cast<SimpleType>(Val.Val);
}
};
/// SDOperand - Represents a use of the SDNode referred by
/// the SDOperandImpl.
class SDOperand: public SDOperandImpl {
/// 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;
public:
friend class SDNode;
SDOperand(): SDOperandImpl(), parent(NULL), Prev(NULL), Next(NULL) {}
SDOperand(SDNode *val, unsigned resno) :
SDOperandImpl(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;
Next = NULL;
Prev = NULL;
return *this;
}
SDOperand& operator= (const SDOperandImpl& Op) {
*(SDOperandImpl*)this = Op;
Next = NULL;
Prev = NULL;
return *this;
}
SDOperand& operator= (SDOperand& Op) {
*(SDOperandImpl*)this = Op;
Next = NULL;
Prev = NULL;
return *this;
}
SDOperand& operator= (const SDOperand& Op) {
*(SDOperandImpl*)this = Op;
Next = NULL;
Prev = NULL;
return *this;
}
SDOperand * getNext() { return Next; }
SDNode *getUser() { return parent; }
void setUser(SDNode *p) { parent = p; }
protected:
void addToList(SDOperand **List) {
Next = *List;
if (Next) Next->Prev = &Next;
Prev = List;
*List = this;
}
void removeFromList() {
*Prev = Next;
if (Next) Next->Prev = Prev;
}
};
/// simplify_type specializations - Allow casting operators to work directly on /// simplify_type specializations - Allow casting operators to work directly on
/// SDOperands as if they were SDNode*'s. /// SDOperands as if they were SDNode*'s.
template<> struct simplify_type<SDOperand> { template<> struct simplify_type<SDOperand> {
@ -957,6 +875,147 @@ template<> struct simplify_type<const SDOperand> {
} }
}; };
/// 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.
SDUse **Prev, *Next;
public:
friend class SDNode;
SDUse(): Operand(), parent(NULL), Prev(NULL), Next(NULL) {}
SDUse(SDNode *val, unsigned resno) :
Operand(val,resno), parent(NULL), Prev(NULL), Next(NULL) {}
SDUse& operator= (SDOperand& Op) {
Operand = Op;
Next = NULL;
Prev = NULL;
return *this;
}
SDUse& operator= (const SDOperand& Op) {
Operand = Op;
Next = NULL;
Prev = NULL;
return *this;
}
SDUse& operator= (SDUse& Op) {
Operand = Op;
Next = NULL;
Prev = NULL;
return *this;
}
SDUse& operator= (const SDUse& Op) {
Operand = Op;
Next = NULL;
Prev = NULL;
return *this;
}
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(SDUse **List) {
Next = *List;
if (Next) Next->Prev = &Next;
Prev = List;
*List = this;
}
void removeFromList() {
*Prev = Next;
if (Next) Next->Prev = Prev;
}
};
/// simplify_type specializations - Allow casting operators to work directly on
/// SDOperands as if they were SDNode*'s.
template<> struct simplify_type<SDUse> {
typedef SDNode* SimpleType;
static SimpleType getSimplifiedValue(const SDUse &Val) {
return static_cast<SimpleType>(Val.getSDOperand().Val);
}
};
template<> struct simplify_type<const SDUse> {
typedef SDNode* SimpleType;
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. /// SDNode - Represents one node in the SelectionDAG.
/// ///
@ -975,7 +1034,7 @@ private:
/// OperandList - The values that are used by this operation. /// 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 /// ValueList - The types of the values this node defines. SDNode's may
/// define multiple values simultaneously. /// define multiple values simultaneously.
@ -993,10 +1052,10 @@ private:
unsigned UsesSize; unsigned UsesSize;
/// Uses - List of uses for this SDNode. /// Uses - List of uses for this SDNode.
SDOperand *Uses; SDUse *Uses;
/// addUse - add SDOperand to the list of uses. /// addUse - add SDUse to the list of uses.
void addUse(SDOperand &U) { U.addToList(&Uses); } void addUse(SDUse &U) { U.addToList(&Uses); }
// Out-of-line virtual method to give class a home. // Out-of-line virtual method to give class a home.
virtual void ANCHOR(); virtual void ANCHOR();
@ -1027,17 +1086,17 @@ public:
/// setNodeId - Set unique node id. /// setNodeId - Set unique node id.
void setNodeId(int Id) { NodeId = 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. /// operands that use a specific SDNode.
class use_iterator class use_iterator
: public forward_iterator<SDOperand, ptrdiff_t> { : public forward_iterator<SDUse, ptrdiff_t> {
SDOperand *Op; SDUse *Op;
explicit use_iterator(SDOperand *op) : Op(op) { explicit use_iterator(SDUse *op) : Op(op) {
} }
friend class SDNode; friend class SDNode;
public: public:
typedef forward_iterator<SDOperand, ptrdiff_t>::reference reference; typedef forward_iterator<SDUse, ptrdiff_t>::reference reference;
typedef forward_iterator<SDOperand, ptrdiff_t>::pointer pointer; typedef forward_iterator<SDUse, ptrdiff_t>::pointer pointer;
use_iterator(const use_iterator &I) : Op(I.Op) {} use_iterator(const use_iterator &I) : Op(I.Op) {}
use_iterator() : Op(0) {} use_iterator() : Op(0) {}
@ -1071,13 +1130,13 @@ public:
} }
/// Retrieve a reference to the current operand. /// Retrieve a reference to the current operand.
SDOperand &operator*() const { SDUse &operator*() const {
assert(Op && "Cannot dereference end iterator!"); assert(Op && "Cannot dereference end iterator!");
return *Op; return *Op;
} }
/// Retrieve a pointer to the current operand. /// Retrieve a pointer to the current operand.
SDOperand *operator->() const { SDUse *operator->() const {
assert(Op && "Cannot dereference end iterator!"); assert(Op && "Cannot dereference end iterator!");
return Op; return Op;
} }
@ -1130,10 +1189,10 @@ public:
const SDOperand &getOperand(unsigned Num) const { const SDOperand &getOperand(unsigned Num) const {
assert(Num < NumOperands && "Invalid child # of SDNode!"); 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_begin() const { return OperandList; }
op_iterator op_end() const { return OperandList+NumOperands; } op_iterator op_end() const { return OperandList+NumOperands; }
@ -1193,7 +1252,25 @@ protected:
: NodeType(Opc), NodeId(-1), UsesSize(0), Uses(NULL) { : NodeType(Opc), NodeId(-1), UsesSize(0), Uses(NULL) {
OperandsNeedDelete = true; OperandsNeedDelete = true;
NumOperands = NumOps; 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) { for (unsigned i = 0; i != NumOps; ++i) {
OperandList[i] = Ops[i]; OperandList[i] = Ops[i];
@ -1220,7 +1297,7 @@ protected:
/// InitOperands - Initialize the operands list of this node with the /// 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 /// specified values, which are part of the node (thus they don't need to be
/// copied in or allocated). /// copied in or allocated).
void InitOperands(SDOperand *Ops, unsigned NumOps) { void InitOperands(SDUse *Ops, unsigned NumOps) {
assert(OperandList == 0 && "Operands already set!"); assert(OperandList == 0 && "Operands already set!");
NumOperands = NumOps; NumOperands = NumOps;
OperandList = Ops; OperandList = Ops;
@ -1229,8 +1306,8 @@ protected:
for (unsigned i = 0; i != NumOps; ++i) { for (unsigned i = 0; i != NumOps; ++i) {
OperandList[i].setUser(this); OperandList[i].setUser(this);
Ops[i].Val->addUse(OperandList[i]); Ops[i].getVal()->addUse(OperandList[i]);
++Ops[i].Val->UsesSize; ++Ops[i].getVal()->UsesSize;
} }
} }
@ -1248,40 +1325,40 @@ protected:
void removeUser(unsigned i, SDNode *User) { void removeUser(unsigned i, SDNode *User) {
assert(User->OperandList[i].getUser() && "Node without parent"); assert(User->OperandList[i].getUser() && "Node without parent");
SDOperand &Op = User->OperandList[i]; SDUse &Op = User->OperandList[i];
Op.removeFromList(); Op.removeFromList();
--UsesSize; --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(); return Val->getOpcode();
} }
inline MVT::ValueType SDOperandImpl::getValueType() const { inline MVT::ValueType SDOperand::getValueType() const {
return Val->getValueType(ResNo); return Val->getValueType(ResNo);
} }
inline unsigned SDOperandImpl::getNumOperands() const { inline unsigned SDOperand::getNumOperands() const {
return Val->getNumOperands(); return Val->getNumOperands();
} }
inline const SDOperandImpl &SDOperandImpl::getOperand(unsigned i) const { inline const SDOperand &SDOperand::getOperand(unsigned i) const {
return Val->getOperand(i); return Val->getOperand(i);
} }
inline uint64_t SDOperandImpl::getConstantOperandVal(unsigned i) const { inline uint64_t SDOperand::getConstantOperandVal(unsigned i) const {
return Val->getConstantOperandVal(i); return Val->getConstantOperandVal(i);
} }
inline bool SDOperandImpl::isTargetOpcode() const { inline bool SDOperand::isTargetOpcode() const {
return Val->isTargetOpcode(); return Val->isTargetOpcode();
} }
inline unsigned SDOperandImpl::getTargetOpcode() const { inline unsigned SDOperand::getTargetOpcode() const {
return Val->getTargetOpcode(); return Val->getTargetOpcode();
} }
inline bool SDOperandImpl::hasOneUse() const { inline bool SDOperand::hasOneUse() const {
return Val->hasNUsesOfValue(1, ResNo); return Val->hasNUsesOfValue(1, ResNo);
} }
inline bool SDOperandImpl::use_empty() const { inline bool SDOperand::use_empty() const {
return !Val->hasAnyUseOfValue(ResNo); 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. /// to allow co-allocation of node operands with the node itself.
class UnarySDNode : public SDNode { class UnarySDNode : public SDNode {
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.
SDOperand Op; SDUse Op;
public: public:
UnarySDNode(unsigned Opc, SDVTList VTs, SDOperand X) UnarySDNode(unsigned Opc, SDVTList VTs, SDOperand X)
: SDNode(Opc, VTs), Op(X) { : SDNode(Opc, VTs) {
Op = X;
InitOperands(&Op, 1); InitOperands(&Op, 1);
} }
}; };
@ -1301,7 +1379,7 @@ public:
/// to allow co-allocation of node operands with the node itself. /// to allow co-allocation of node operands with the node itself.
class BinarySDNode : public SDNode { class BinarySDNode : public SDNode {
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.
SDOperand Ops[2]; SDUse Ops[2];
public: public:
BinarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y) BinarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y)
: SDNode(Opc, VTs) { : SDNode(Opc, VTs) {
@ -1315,7 +1393,7 @@ public:
/// to allow co-allocation of node operands with the node itself. /// to allow co-allocation of node operands with the node itself.
class TernarySDNode : public SDNode { class TernarySDNode : public SDNode {
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.
SDOperand Ops[3]; SDUse Ops[3];
public: public:
TernarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y, TernarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y,
SDOperand Z) SDOperand Z)
@ -1334,19 +1412,20 @@ public:
/// the AllNodes list. /// the AllNodes list.
class HandleSDNode : public SDNode { class HandleSDNode : public SDNode {
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.
SDOperand Op; SDUse Op;
public: public:
explicit HandleSDNode(SDOperand X) explicit HandleSDNode(SDOperand X)
: SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)), Op(X) { : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)) {
Op = X;
InitOperands(&Op, 1); InitOperands(&Op, 1);
} }
~HandleSDNode(); ~HandleSDNode();
SDOperand getValue() const { return Op; } SDUse getValue() const { return Op; }
}; };
class AtomicSDNode : public SDNode { class AtomicSDNode : public SDNode {
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.
SDOperand Ops[4]; SDUse Ops[4];
MVT::ValueType OrigVT; MVT::ValueType OrigVT;
public: public:
AtomicSDNode(unsigned Opc, SDVTList VTL, SDOperand Chain, SDOperand Ptr, AtomicSDNode(unsigned Opc, SDVTList VTL, SDOperand Chain, SDOperand Ptr,
@ -1867,7 +1946,7 @@ protected:
common functionality shared between LoadSDNode and common functionality shared between LoadSDNode and
StoreSDNode StoreSDNode
*/ */
SDOperand Ops[4]; SDUse Ops[4];
public: public:
LSBaseSDNode(ISD::NodeType NodeTy, SDOperand *Operands, unsigned NumOperands, LSBaseSDNode(ISD::NodeType NodeTy, SDOperand *Operands, unsigned NumOperands,
SDVTList VTs, ISD::MemIndexedMode AM, MVT::ValueType VT, SDVTList VTs, ISD::MemIndexedMode AM, MVT::ValueType VT,

View File

@ -3880,7 +3880,8 @@ SDOperand DAGCombiner::visitFP_EXTEND(SDNode *N) {
MVT::ValueType VT = N->getValueType(0); MVT::ValueType VT = N->getValueType(0);
// If this is fp_round(fpextend), don't fold it, allow ourselves to be folded. // 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(); return SDOperand();
// fold (fp_extend c1fp) -> c1fp // fold (fp_extend c1fp) -> c1fp

View File

@ -86,17 +86,17 @@ class VISIBILITY_HIDDEN SelectionDAGLegalize {
/// LegalizedNodes - For nodes that are of legal width, and that have more /// LegalizedNodes - For nodes that are of legal width, and that have more
/// than one use, this map indicates what regularized operand to use. This /// than one use, this map indicates what regularized operand to use. This
/// allows us to avoid legalizing the same thing more than once. /// 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 /// 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 /// than one use, this map indicates what promoted value to use. This allows
/// us to avoid promoting the same thing more than once. /// 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 /// ExpandedNodes - For nodes that need to be expanded this map indicates
/// which which operands are the expanded version of the input. This allows /// which which operands are the expanded version of the input. This allows
/// us to avoid expanding the same node more than once. /// 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 /// 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 /// 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 // Note that LegalizeOp may be reentered even from single-use nodes, which
// means that we always must cache transformed nodes. // 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; if (I != LegalizedNodes.end()) return I->second;
SDOperand Tmp1, Tmp2, Tmp3, Tmp4; 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. // will cause this node to be legalized as well as handling libcalls right.
if (LastCALLSEQ_END.Val != Node) { if (LastCALLSEQ_END.Val != Node) {
LegalizeOp(SDOperand(FindCallStartFromCallEnd(Node), 0)); 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() && assert(I != LegalizedNodes.end() &&
"Legalizing the call start should have legalized this node!"); "Legalizing the call start should have legalized this node!");
return I->second; return I->second;
@ -4016,7 +4016,7 @@ SDOperand SelectionDAGLegalize::PromoteOp(SDOperand Op) {
SDOperand Result; SDOperand Result;
SDNode *Node = Op.Val; 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; if (I != PromotedNodes.end()) return I->second;
switch (Node->getOpcode()) { 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!"); "Cannot expand to FP value or to larger int value!");
// See if we already expanded it. // 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); = ExpandedNodes.find(Op);
if (I != ExpandedNodes.end()) { if (I != ExpandedNodes.end()) {
Lo = I->second.first; Lo = I->second.first;

View File

@ -273,39 +273,39 @@ void DAGTypeLegalizer::SanityCheck(SDNode *N) {
E = Worklist.end(); I != E; ++I) E = Worklist.end(); I != E; ++I)
assert(*I != N); 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) { E = ReplacedNodes.end(); I != E; ++I) {
assert(I->first.Val != N); assert(I->first.Val != N);
assert(I->second.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) { E = PromotedNodes.end(); I != E; ++I) {
assert(I->first.Val != N); assert(I->first.Val != N);
assert(I->second.Val != N); assert(I->second.Val != N);
} }
for (DenseMap<SDOperandImpl, SDOperand>::iterator for (DenseMap<SDOperand, SDOperand>::iterator
I = FloatToIntedNodes.begin(), I = FloatToIntedNodes.begin(),
E = FloatToIntedNodes.end(); I != E; ++I) { E = FloatToIntedNodes.end(); I != E; ++I) {
assert(I->first.Val != N); assert(I->first.Val != N);
assert(I->second.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) { E = ScalarizedNodes.end(); I != E; ++I) {
assert(I->first.Val != N); assert(I->first.Val != N);
assert(I->second.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) { I = ExpandedNodes.begin(), E = ExpandedNodes.end(); I != E; ++I) {
assert(I->first.Val != N); assert(I->first.Val != N);
assert(I->second.first.Val != N); assert(I->second.first.Val != N);
assert(I->second.second.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) { I = SplitNodes.begin(), E = SplitNodes.end(); I != E; ++I) {
assert(I->first.Val != N); assert(I->first.Val != N);
assert(I->second.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, /// RemapNode - If the specified value was already legalized to another value,
/// replace it by that value. /// replace it by that value.
void DAGTypeLegalizer::RemapNode(SDOperand &N) { 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()) { if (I != ReplacedNodes.end()) {
// Use path compression to speed up future lookups if values get multiply // Use path compression to speed up future lookups if values get multiply
// replaced with other values. // replaced with other values.

View File

@ -110,27 +110,27 @@ private:
/// PromotedNodes - For nodes that are below legal width, this map indicates /// PromotedNodes - For nodes that are below legal width, this map indicates
/// what promoted value to use. /// what promoted value to use.
DenseMap<SDOperandImpl, SDOperand> PromotedNodes; DenseMap<SDOperand, SDOperand> PromotedNodes;
/// ExpandedNodes - For nodes that need to be expanded this map indicates /// ExpandedNodes - For nodes that need to be expanded this map indicates
/// which operands are the expanded version of the input. /// 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 /// FloatToIntedNodes - For floating point nodes converted to integers of
/// the same size, this map indicates the converted value to use. /// 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 /// ScalarizedNodes - For nodes that are <1 x ty>, this map indicates the
/// scalar value of type 'ty' to use. /// 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 /// SplitNodes - For nodes that need to be split this map indicates
/// which operands are the expanded version of the input. /// which operands are the expanded version of the input.
DenseMap<SDOperandImpl, std::pair<SDOperand, SDOperand> > SplitNodes; DenseMap<SDOperand, std::pair<SDOperand, SDOperand> > SplitNodes;
/// ReplacedNodes - For nodes that have been replaced with another, /// ReplacedNodes - For nodes that have been replaced with another,
/// indicates the replacement node to use. /// indicates the replacement node to use.
DenseMap<SDOperandImpl, SDOperand> ReplacedNodes; DenseMap<SDOperand, SDOperand> ReplacedNodes;
/// Worklist - This defines a worklist of nodes to process. In order to be /// Worklist - This defines a worklist of nodes to process. In order to be
/// pushed onto this worklist, all operands of a node must have already been /// pushed onto this worklist, all operands of a node must have already been

View File

@ -400,7 +400,7 @@ static const TargetRegisterClass *getInstrOperandRegClass(
void ScheduleDAG::EmitCopyFromReg(SDNode *Node, unsigned ResNo, void ScheduleDAG::EmitCopyFromReg(SDNode *Node, unsigned ResNo,
unsigned InstanceNo, unsigned SrcReg, unsigned InstanceNo, unsigned SrcReg,
DenseMap<SDOperandImpl, unsigned> &VRBaseMap) { DenseMap<SDOperand, unsigned> &VRBaseMap) {
unsigned VRBase = 0; unsigned VRBase = 0;
if (TargetRegisterInfo::isVirtualRegister(SrcReg)) { if (TargetRegisterInfo::isVirtualRegister(SrcReg)) {
// Just use the input register directly! // Just use the input register directly!
@ -488,7 +488,7 @@ unsigned ScheduleDAG::getDstOfOnlyCopyToRegUse(SDNode *Node,
void ScheduleDAG::CreateVirtualRegisters(SDNode *Node, MachineInstr *MI, void ScheduleDAG::CreateVirtualRegisters(SDNode *Node, MachineInstr *MI,
const TargetInstrDesc &II, const TargetInstrDesc &II,
DenseMap<SDOperandImpl, unsigned> &VRBaseMap) { DenseMap<SDOperand, unsigned> &VRBaseMap) {
assert(Node->getTargetOpcode() != TargetInstrInfo::IMPLICIT_DEF && assert(Node->getTargetOpcode() != TargetInstrInfo::IMPLICIT_DEF &&
"IMPLICIT_DEF should have been handled as a special case elsewhere!"); "IMPLICIT_DEF should have been handled as a special case elsewhere!");
@ -529,7 +529,7 @@ void ScheduleDAG::CreateVirtualRegisters(SDNode *Node, MachineInstr *MI,
/// getVR - Return the virtual register corresponding to the specified result /// getVR - Return the virtual register corresponding to the specified result
/// of the specified node. /// of the specified node.
unsigned ScheduleDAG::getVR(SDOperand Op, unsigned ScheduleDAG::getVR(SDOperand Op,
DenseMap<SDOperandImpl, unsigned> &VRBaseMap) { DenseMap<SDOperand, unsigned> &VRBaseMap) {
if (Op.isTargetOpcode() && if (Op.isTargetOpcode() &&
Op.getTargetOpcode() == TargetInstrInfo::IMPLICIT_DEF) { Op.getTargetOpcode() == TargetInstrInfo::IMPLICIT_DEF) {
// Add an IMPLICIT_DEF instruction before every use. // Add an IMPLICIT_DEF instruction before every use.
@ -544,7 +544,7 @@ unsigned ScheduleDAG::getVR(SDOperand Op,
return VReg; return VReg;
} }
DenseMap<SDOperandImpl, unsigned>::iterator I = VRBaseMap.find(Op); DenseMap<SDOperand, unsigned>::iterator I = VRBaseMap.find(Op);
assert(I != VRBaseMap.end() && "Node emitted out of order - late"); assert(I != VRBaseMap.end() && "Node emitted out of order - late");
return I->second; return I->second;
} }
@ -557,7 +557,7 @@ unsigned ScheduleDAG::getVR(SDOperand Op,
void ScheduleDAG::AddOperand(MachineInstr *MI, SDOperand Op, void ScheduleDAG::AddOperand(MachineInstr *MI, SDOperand Op,
unsigned IIOpNum, unsigned IIOpNum,
const TargetInstrDesc *II, const TargetInstrDesc *II,
DenseMap<SDOperandImpl, unsigned> &VRBaseMap) { DenseMap<SDOperand, unsigned> &VRBaseMap) {
if (Op.isTargetOpcode()) { if (Op.isTargetOpcode()) {
// Note that this case is redundant with the final else block, but we // Note that this case is redundant with the final else block, but we
// include it because it is the most common and it makes the logic // include it because it is the most common and it makes the logic
@ -688,7 +688,7 @@ static const TargetRegisterClass *getSuperregRegisterClass(
/// EmitSubregNode - Generate machine code for subreg nodes. /// EmitSubregNode - Generate machine code for subreg nodes.
/// ///
void ScheduleDAG::EmitSubregNode(SDNode *Node, void ScheduleDAG::EmitSubregNode(SDNode *Node,
DenseMap<SDOperandImpl, unsigned> &VRBaseMap) { DenseMap<SDOperand, unsigned> &VRBaseMap) {
unsigned VRBase = 0; unsigned VRBase = 0;
unsigned Opc = Node->getTargetOpcode(); unsigned Opc = Node->getTargetOpcode();
@ -779,7 +779,7 @@ void ScheduleDAG::EmitSubregNode(SDNode *Node,
/// EmitNode - Generate machine code for an node and needed dependencies. /// EmitNode - Generate machine code for an node and needed dependencies.
/// ///
void ScheduleDAG::EmitNode(SDNode *Node, unsigned InstanceNo, void ScheduleDAG::EmitNode(SDNode *Node, unsigned InstanceNo,
DenseMap<SDOperandImpl, unsigned> &VRBaseMap) { DenseMap<SDOperand, unsigned> &VRBaseMap) {
// If machine instruction // If machine instruction
if (Node->isTargetOpcode()) { if (Node->isTargetOpcode()) {
unsigned Opc = Node->getTargetOpcode(); unsigned Opc = Node->getTargetOpcode();
@ -1102,7 +1102,7 @@ void ScheduleDAG::EmitSchedule() {
} }
// Finally, emit the code for all of the scheduled instructions. // Finally, emit the code for all of the scheduled instructions.
DenseMap<SDOperandImpl, unsigned> VRBaseMap; DenseMap<SDOperand, unsigned> VRBaseMap;
DenseMap<SUnit*, unsigned> CopyVRBaseMap; DenseMap<SUnit*, unsigned> CopyVRBaseMap;
for (unsigned i = 0, e = Sequence.size(); i != e; i++) { for (unsigned i = 0, e = Sequence.size(); i != e; i++) {
SUnit *SU = Sequence[i]; SUnit *SU = Sequence[i];

View File

@ -328,7 +328,7 @@ void AddNodeIDValueTypes(FoldingSetNodeID &ID, SDVTList VTList) {
/// AddNodeIDOperands - Various routines for adding operands to the NodeID data. /// AddNodeIDOperands - Various routines for adding operands to the NodeID data.
/// ///
static void AddNodeIDOperands(FoldingSetNodeID &ID, static void AddNodeIDOperands(FoldingSetNodeID &ID,
const SDOperand *Ops, unsigned NumOps) { SDOperandPtr Ops, unsigned NumOps) {
for (; NumOps; --NumOps, ++Ops) { for (; NumOps; --NumOps, ++Ops) {
ID.AddPointer(Ops->Val); ID.AddPointer(Ops->Val);
ID.AddInteger(Ops->ResNo); ID.AddInteger(Ops->ResNo);
@ -343,6 +343,7 @@ static void AddNodeIDNode(FoldingSetNodeID &ID,
AddNodeIDOperands(ID, OpList, N); AddNodeIDOperands(ID, OpList, N);
} }
/// AddNodeIDNode - Generic routine for adding a nodes info to the NodeID /// AddNodeIDNode - Generic routine for adding a nodes info to the NodeID
/// data. /// data.
static void AddNodeIDNode(FoldingSetNodeID &ID, SDNode *N) { static void AddNodeIDNode(FoldingSetNodeID &ID, SDNode *N) {
@ -464,7 +465,7 @@ void SelectionDAG::RemoveDeadNodes() {
// Next, brutally remove the operand list. This is safe to do, as there are // Next, brutally remove the operand list. This is safe to do, as there are
// no cycles in the graph. // no cycles in the graph.
for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I) { for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I) {
SDNode *Operand = I->Val; SDNode *Operand = I->getVal();
Operand->removeUser(std::distance(N->op_begin(), I), N); Operand->removeUser(std::distance(N->op_begin(), I), N);
// Now that we removed this operand, see if there are no uses of it left. // Now that we removed this operand, see if there are no uses of it left.
@ -504,7 +505,7 @@ void SelectionDAG::RemoveDeadNode(SDNode *N, DAGUpdateListener *UpdateListener){
// Next, brutally remove the operand list. This is safe to do, as there are // Next, brutally remove the operand list. This is safe to do, as there are
// no cycles in the graph. // no cycles in the graph.
for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I) { for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I) {
SDNode *Operand = I->Val; SDNode *Operand = I->getVal();
Operand->removeUser(std::distance(N->op_begin(), I), N); Operand->removeUser(std::distance(N->op_begin(), I), N);
// Now that we removed this operand, see if there are no uses of it left. // Now that we removed this operand, see if there are no uses of it left.
@ -540,7 +541,7 @@ void SelectionDAG::DeleteNodeNotInCSEMaps(SDNode *N) {
// Drop all of the operands and decrement used nodes use counts. // Drop all of the operands and decrement used nodes use counts.
for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I) for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I)
I->Val->removeUser(std::distance(N->op_begin(), I), N); I->getVal()->removeUser(std::distance(N->op_begin(), I), N);
if (N->OperandsNeedDelete) { if (N->OperandsNeedDelete) {
delete[] N->OperandList; delete[] N->OperandList;
} }
@ -669,7 +670,7 @@ SDNode *SelectionDAG::FindModifiedNodeSlot(SDNode *N,
/// return null, otherwise return a pointer to the slot it would take. If a /// return null, otherwise return a pointer to the slot it would take. If a
/// node already exists with these operands, the slot will be non-null. /// node already exists with these operands, the slot will be non-null.
SDNode *SelectionDAG::FindModifiedNodeSlot(SDNode *N, SDNode *SelectionDAG::FindModifiedNodeSlot(SDNode *N,
const SDOperand *Ops,unsigned NumOps, SDOperandPtr Ops,unsigned NumOps,
void *&InsertPos) { void *&InsertPos) {
if (N->getOpcode() == ISD::HANDLENODE || N->getValueType(0) == MVT::Flag) if (N->getOpcode() == ISD::HANDLENODE || N->getValueType(0) == MVT::Flag)
return 0; // Never add these nodes. return 0; // Never add these nodes.
@ -748,7 +749,7 @@ SDOperand SelectionDAG::getConstant(const APInt &Val, MVT::ValueType VT, bool is
unsigned Opc = isT ? ISD::TargetConstant : ISD::Constant; unsigned Opc = isT ? ISD::TargetConstant : ISD::Constant;
FoldingSetNodeID ID; FoldingSetNodeID ID;
AddNodeIDNode(ID, Opc, getVTList(EltVT), 0, 0); AddNodeIDNode(ID, Opc, getVTList(EltVT), (SDOperand*)0, 0);
ID.Add(Val); ID.Add(Val);
void *IP = 0; void *IP = 0;
SDNode *N = NULL; SDNode *N = NULL;
@ -787,7 +788,7 @@ SDOperand SelectionDAG::getConstantFP(const APFloat& V, MVT::ValueType VT,
// we don't have issues with SNANs. // we don't have issues with SNANs.
unsigned Opc = isTarget ? ISD::TargetConstantFP : ISD::ConstantFP; unsigned Opc = isTarget ? ISD::TargetConstantFP : ISD::ConstantFP;
FoldingSetNodeID ID; FoldingSetNodeID ID;
AddNodeIDNode(ID, Opc, getVTList(EltVT), 0, 0); AddNodeIDNode(ID, Opc, getVTList(EltVT), (SDOperand*)0, 0);
ID.Add(V); ID.Add(V);
void *IP = 0; void *IP = 0;
SDNode *N = NULL; SDNode *N = NULL;
@ -837,7 +838,7 @@ SDOperand SelectionDAG::getGlobalAddress(const GlobalValue *GV,
Opc = isTargetGA ? ISD::TargetGlobalAddress : ISD::GlobalAddress; Opc = isTargetGA ? ISD::TargetGlobalAddress : ISD::GlobalAddress;
FoldingSetNodeID ID; FoldingSetNodeID ID;
AddNodeIDNode(ID, Opc, getVTList(VT), 0, 0); AddNodeIDNode(ID, Opc, getVTList(VT), (SDOperand*)0, 0);
ID.AddPointer(GV); ID.AddPointer(GV);
ID.AddInteger(Offset); ID.AddInteger(Offset);
void *IP = 0; void *IP = 0;
@ -853,7 +854,7 @@ SDOperand SelectionDAG::getFrameIndex(int FI, MVT::ValueType VT,
bool isTarget) { bool isTarget) {
unsigned Opc = isTarget ? ISD::TargetFrameIndex : ISD::FrameIndex; unsigned Opc = isTarget ? ISD::TargetFrameIndex : ISD::FrameIndex;
FoldingSetNodeID ID; FoldingSetNodeID ID;
AddNodeIDNode(ID, Opc, getVTList(VT), 0, 0); AddNodeIDNode(ID, Opc, getVTList(VT), (SDOperand*)0, 0);
ID.AddInteger(FI); ID.AddInteger(FI);
void *IP = 0; void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP)) if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
@ -867,7 +868,7 @@ SDOperand SelectionDAG::getFrameIndex(int FI, MVT::ValueType VT,
SDOperand SelectionDAG::getJumpTable(int JTI, MVT::ValueType VT, bool isTarget){ SDOperand SelectionDAG::getJumpTable(int JTI, MVT::ValueType VT, bool isTarget){
unsigned Opc = isTarget ? ISD::TargetJumpTable : ISD::JumpTable; unsigned Opc = isTarget ? ISD::TargetJumpTable : ISD::JumpTable;
FoldingSetNodeID ID; FoldingSetNodeID ID;
AddNodeIDNode(ID, Opc, getVTList(VT), 0, 0); AddNodeIDNode(ID, Opc, getVTList(VT), (SDOperand*)0, 0);
ID.AddInteger(JTI); ID.AddInteger(JTI);
void *IP = 0; void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP)) if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
@ -883,7 +884,7 @@ SDOperand SelectionDAG::getConstantPool(Constant *C, MVT::ValueType VT,
bool isTarget) { bool isTarget) {
unsigned Opc = isTarget ? ISD::TargetConstantPool : ISD::ConstantPool; unsigned Opc = isTarget ? ISD::TargetConstantPool : ISD::ConstantPool;
FoldingSetNodeID ID; FoldingSetNodeID ID;
AddNodeIDNode(ID, Opc, getVTList(VT), 0, 0); AddNodeIDNode(ID, Opc, getVTList(VT), (SDOperand*)0, 0);
ID.AddInteger(Alignment); ID.AddInteger(Alignment);
ID.AddInteger(Offset); ID.AddInteger(Offset);
ID.AddPointer(C); ID.AddPointer(C);
@ -903,7 +904,7 @@ SDOperand SelectionDAG::getConstantPool(MachineConstantPoolValue *C,
bool isTarget) { bool isTarget) {
unsigned Opc = isTarget ? ISD::TargetConstantPool : ISD::ConstantPool; unsigned Opc = isTarget ? ISD::TargetConstantPool : ISD::ConstantPool;
FoldingSetNodeID ID; FoldingSetNodeID ID;
AddNodeIDNode(ID, Opc, getVTList(VT), 0, 0); AddNodeIDNode(ID, Opc, getVTList(VT), (SDOperand*)0, 0);
ID.AddInteger(Alignment); ID.AddInteger(Alignment);
ID.AddInteger(Offset); ID.AddInteger(Offset);
C->AddSelectionDAGCSEId(ID); C->AddSelectionDAGCSEId(ID);
@ -919,7 +920,7 @@ SDOperand SelectionDAG::getConstantPool(MachineConstantPoolValue *C,
SDOperand SelectionDAG::getBasicBlock(MachineBasicBlock *MBB) { SDOperand SelectionDAG::getBasicBlock(MachineBasicBlock *MBB) {
FoldingSetNodeID ID; FoldingSetNodeID ID;
AddNodeIDNode(ID, ISD::BasicBlock, getVTList(MVT::Other), 0, 0); AddNodeIDNode(ID, ISD::BasicBlock, getVTList(MVT::Other), (SDOperand*)0, 0);
ID.AddPointer(MBB); ID.AddPointer(MBB);
void *IP = 0; void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP)) if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
@ -932,7 +933,7 @@ SDOperand SelectionDAG::getBasicBlock(MachineBasicBlock *MBB) {
SDOperand SelectionDAG::getArgFlags(ISD::ArgFlagsTy Flags) { SDOperand SelectionDAG::getArgFlags(ISD::ArgFlagsTy Flags) {
FoldingSetNodeID ID; FoldingSetNodeID ID;
AddNodeIDNode(ID, ISD::ARG_FLAGS, getVTList(MVT::Other), 0, 0); AddNodeIDNode(ID, ISD::ARG_FLAGS, getVTList(MVT::Other), (SDOperand*)0, 0);
ID.AddInteger(Flags.getRawBits()); ID.AddInteger(Flags.getRawBits());
void *IP = 0; void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP)) if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
@ -986,7 +987,7 @@ SDOperand SelectionDAG::getCondCode(ISD::CondCode Cond) {
SDOperand SelectionDAG::getRegister(unsigned RegNo, MVT::ValueType VT) { SDOperand SelectionDAG::getRegister(unsigned RegNo, MVT::ValueType VT) {
FoldingSetNodeID ID; FoldingSetNodeID ID;
AddNodeIDNode(ID, ISD::Register, getVTList(VT), 0, 0); AddNodeIDNode(ID, ISD::Register, getVTList(VT), (SDOperand*)0, 0);
ID.AddInteger(RegNo); ID.AddInteger(RegNo);
void *IP = 0; void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP)) if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
@ -1002,7 +1003,7 @@ SDOperand SelectionDAG::getSrcValue(const Value *V) {
"SrcValue is not a pointer?"); "SrcValue is not a pointer?");
FoldingSetNodeID ID; FoldingSetNodeID ID;
AddNodeIDNode(ID, ISD::SRCVALUE, getVTList(MVT::Other), 0, 0); AddNodeIDNode(ID, ISD::SRCVALUE, getVTList(MVT::Other), (SDOperand*)0, 0);
ID.AddPointer(V); ID.AddPointer(V);
void *IP = 0; void *IP = 0;
@ -1021,7 +1022,7 @@ SDOperand SelectionDAG::getMemOperand(const MachineMemOperand &MO) {
"SrcValue is not a pointer?"); "SrcValue is not a pointer?");
FoldingSetNodeID ID; FoldingSetNodeID ID;
AddNodeIDNode(ID, ISD::MEMOPERAND, getVTList(MVT::Other), 0, 0); AddNodeIDNode(ID, ISD::MEMOPERAND, getVTList(MVT::Other), (SDOperand*)0, 0);
ID.AddPointer(v); ID.AddPointer(v);
ID.AddInteger(MO.getFlags()); ID.AddInteger(MO.getFlags());
ID.AddInteger(MO.getOffset()); ID.AddInteger(MO.getOffset());
@ -1751,7 +1752,7 @@ bool SelectionDAG::isVerifiedDebugInfoDesc(SDOperand Op) const {
/// ///
SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT) { SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT) {
FoldingSetNodeID ID; FoldingSetNodeID ID;
AddNodeIDNode(ID, Opcode, getVTList(VT), 0, 0); AddNodeIDNode(ID, Opcode, getVTList(VT), (SDOperand*)0, 0);
void *IP = 0; void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP)) if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDOperand(E, 0); return SDOperand(E, 0);
@ -2987,7 +2988,7 @@ SDOperand SelectionDAG::getVAArg(MVT::ValueType VT,
} }
SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
const SDOperand *Ops, unsigned NumOps) { SDOperandPtr Ops, unsigned NumOps) {
switch (NumOps) { switch (NumOps) {
case 0: return getNode(Opcode, VT); case 0: return getNode(Opcode, VT);
case 1: return getNode(Opcode, VT, Ops[0]); case 1: return getNode(Opcode, VT, Ops[0]);
@ -3036,21 +3037,21 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
SDOperand SelectionDAG::getNode(unsigned Opcode, SDOperand SelectionDAG::getNode(unsigned Opcode,
std::vector<MVT::ValueType> &ResultTys, std::vector<MVT::ValueType> &ResultTys,
const SDOperand *Ops, unsigned NumOps) { SDOperandPtr Ops, unsigned NumOps) {
return getNode(Opcode, getNodeValueTypes(ResultTys), ResultTys.size(), return getNode(Opcode, getNodeValueTypes(ResultTys), ResultTys.size(),
Ops, NumOps); Ops, NumOps);
} }
SDOperand SelectionDAG::getNode(unsigned Opcode, SDOperand SelectionDAG::getNode(unsigned Opcode,
const MVT::ValueType *VTs, unsigned NumVTs, const MVT::ValueType *VTs, unsigned NumVTs,
const SDOperand *Ops, unsigned NumOps) { SDOperandPtr Ops, unsigned NumOps) {
if (NumVTs == 1) if (NumVTs == 1)
return getNode(Opcode, VTs[0], Ops, NumOps); return getNode(Opcode, VTs[0], Ops, NumOps);
return getNode(Opcode, makeVTList(VTs, NumVTs), Ops, NumOps); return getNode(Opcode, makeVTList(VTs, NumVTs), Ops, NumOps);
} }
SDOperand SelectionDAG::getNode(unsigned Opcode, SDVTList VTList, SDOperand SelectionDAG::getNode(unsigned Opcode, SDVTList VTList,
const SDOperand *Ops, unsigned NumOps) { SDOperandPtr Ops, unsigned NumOps) {
if (VTList.NumVTs == 1) if (VTList.NumVTs == 1)
return getNode(Opcode, VTList.VTs[0], Ops, NumOps); return getNode(Opcode, VTList.VTs[0], Ops, NumOps);
@ -3109,7 +3110,7 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, SDVTList VTList,
} }
SDOperand SelectionDAG::getNode(unsigned Opcode, SDVTList VTList) { SDOperand SelectionDAG::getNode(unsigned Opcode, SDVTList VTList) {
return getNode(Opcode, VTList, 0, 0); return getNode(Opcode, VTList, (SDOperand*)0, 0);
} }
SDOperand SelectionDAG::getNode(unsigned Opcode, SDVTList VTList, SDOperand SelectionDAG::getNode(unsigned Opcode, SDVTList VTList,
@ -3228,7 +3229,7 @@ UpdateNodeOperands(SDOperand InN, SDOperand Op) {
RemoveNodeFromCSEMaps(N); RemoveNodeFromCSEMaps(N);
// Now we update the operands. // Now we update the operands.
N->OperandList[0].Val->removeUser(0, N); N->OperandList[0].getVal()->removeUser(0, N);
N->OperandList[0] = Op; N->OperandList[0] = Op;
N->OperandList[0].setUser(N); N->OperandList[0].setUser(N);
Op.Val->addUser(0, N); Op.Val->addUser(0, N);
@ -3258,13 +3259,13 @@ UpdateNodeOperands(SDOperand InN, SDOperand Op1, SDOperand Op2) {
// Now we update the operands. // Now we update the operands.
if (N->OperandList[0] != Op1) { if (N->OperandList[0] != Op1) {
N->OperandList[0].Val->removeUser(0, N); N->OperandList[0].getVal()->removeUser(0, N);
N->OperandList[0] = Op1; N->OperandList[0] = Op1;
N->OperandList[0].setUser(N); N->OperandList[0].setUser(N);
Op1.Val->addUser(0, N); Op1.Val->addUser(0, N);
} }
if (N->OperandList[1] != Op2) { if (N->OperandList[1] != Op2) {
N->OperandList[1].Val->removeUser(1, N); N->OperandList[1].getVal()->removeUser(1, N);
N->OperandList[1] = Op2; N->OperandList[1] = Op2;
N->OperandList[1].setUser(N); N->OperandList[1].setUser(N);
Op2.Val->addUser(1, N); Op2.Val->addUser(1, N);
@ -3296,7 +3297,7 @@ UpdateNodeOperands(SDOperand N, SDOperand Op1, SDOperand Op2,
} }
SDOperand SelectionDAG:: SDOperand SelectionDAG::
UpdateNodeOperands(SDOperand InN, SDOperand *Ops, unsigned NumOps) { UpdateNodeOperands(SDOperand InN, SDOperandPtr Ops, unsigned NumOps) {
SDNode *N = InN.Val; SDNode *N = InN.Val;
assert(N->getNumOperands() == NumOps && assert(N->getNumOperands() == NumOps &&
"Update with wrong number of operands"); "Update with wrong number of operands");
@ -3325,7 +3326,7 @@ UpdateNodeOperands(SDOperand InN, SDOperand *Ops, unsigned NumOps) {
// Now we update the operands. // Now we update the operands.
for (unsigned i = 0; i != NumOps; ++i) { for (unsigned i = 0; i != NumOps; ++i) {
if (N->OperandList[i] != Ops[i]) { if (N->OperandList[i] != Ops[i]) {
N->OperandList[i].Val->removeUser(i, N); N->OperandList[i].getVal()->removeUser(i, N);
N->OperandList[i] = Ops[i]; N->OperandList[i] = Ops[i];
N->OperandList[i].setUser(N); N->OperandList[i].setUser(N);
Ops[i].Val->addUser(i, N); Ops[i].Val->addUser(i, N);
@ -3349,7 +3350,7 @@ void SDNode::MorphNodeTo(unsigned Opc, SDVTList L,
// Clear the operands list, updating used nodes to remove this from their // Clear the operands list, updating used nodes to remove this from their
// use list. // use list.
for (op_iterator I = op_begin(), E = op_end(); I != E; ++I) for (op_iterator I = op_begin(), E = op_end(); I != E; ++I)
I->Val->removeUser(std::distance(op_begin(), I), this); I->getVal()->removeUser(std::distance(op_begin(), I), this);
// If NumOps is larger than the # of operands we currently have, reallocate // If NumOps is larger than the # of operands we currently have, reallocate
// the operand list. // the operand list.
@ -3357,7 +3358,7 @@ void SDNode::MorphNodeTo(unsigned Opc, SDVTList L,
if (OperandsNeedDelete) { if (OperandsNeedDelete) {
delete [] OperandList; delete [] OperandList;
} }
OperandList = new SDOperand[NumOps]; OperandList = new SDUse[NumOps];
OperandsNeedDelete = true; OperandsNeedDelete = true;
} }
@ -3367,7 +3368,7 @@ void SDNode::MorphNodeTo(unsigned Opc, SDVTList L,
for (unsigned i = 0, e = NumOps; i != e; ++i) { for (unsigned i = 0, e = NumOps; i != e; ++i) {
OperandList[i] = Ops[i]; OperandList[i] = Ops[i];
OperandList[i].setUser(this); OperandList[i].setUser(this);
SDNode *N = OperandList[i].Val; SDNode *N = OperandList[i].getVal();
N->addUser(i, this); N->addUser(i, this);
++N->UsesSize; ++N->UsesSize;
} }
@ -3385,7 +3386,7 @@ SDNode *SelectionDAG::SelectNodeTo(SDNode *N, unsigned TargetOpc,
MVT::ValueType VT) { MVT::ValueType VT) {
SDVTList VTs = getVTList(VT); SDVTList VTs = getVTList(VT);
FoldingSetNodeID ID; FoldingSetNodeID ID;
AddNodeIDNode(ID, ISD::BUILTIN_OP_END+TargetOpc, VTs, 0, 0); AddNodeIDNode(ID, ISD::BUILTIN_OP_END+TargetOpc, VTs, (SDOperand*)0, 0);
void *IP = 0; void *IP = 0;
if (SDNode *ON = CSEMap.FindNodeOrInsertPos(ID, IP)) if (SDNode *ON = CSEMap.FindNodeOrInsertPos(ID, IP))
return ON; return ON;
@ -3458,7 +3459,7 @@ SDNode *SelectionDAG::SelectNodeTo(SDNode *N, unsigned TargetOpc,
} }
SDNode *SelectionDAG::SelectNodeTo(SDNode *N, unsigned TargetOpc, SDNode *SelectionDAG::SelectNodeTo(SDNode *N, unsigned TargetOpc,
MVT::ValueType VT, const SDOperand *Ops, MVT::ValueType VT, SDOperandPtr Ops,
unsigned NumOps) { unsigned NumOps) {
// If an identical node already exists, use it. // If an identical node already exists, use it.
SDVTList VTs = getVTList(VT); SDVTList VTs = getVTList(VT);
@ -3536,7 +3537,7 @@ SDNode *SelectionDAG::getTargetNode(unsigned Opcode, MVT::ValueType VT,
return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Op1, Op2, Op3).Val; return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Op1, Op2, Op3).Val;
} }
SDNode *SelectionDAG::getTargetNode(unsigned Opcode, MVT::ValueType VT, SDNode *SelectionDAG::getTargetNode(unsigned Opcode, MVT::ValueType VT,
const SDOperand *Ops, unsigned NumOps) { SDOperandPtr Ops, unsigned NumOps) {
return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Ops, NumOps).Val; return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Ops, NumOps).Val;
} }
SDNode *SelectionDAG::getTargetNode(unsigned Opcode, MVT::ValueType VT1, SDNode *SelectionDAG::getTargetNode(unsigned Opcode, MVT::ValueType VT1,
@ -3566,7 +3567,7 @@ SDNode *SelectionDAG::getTargetNode(unsigned Opcode, MVT::ValueType VT1,
} }
SDNode *SelectionDAG::getTargetNode(unsigned Opcode, MVT::ValueType VT1, SDNode *SelectionDAG::getTargetNode(unsigned Opcode, MVT::ValueType VT1,
MVT::ValueType VT2, MVT::ValueType VT2,
const SDOperand *Ops, unsigned NumOps) { SDOperandPtr Ops, unsigned NumOps) {
const MVT::ValueType *VTs = getNodeValueTypes(VT1, VT2); const MVT::ValueType *VTs = getNodeValueTypes(VT1, VT2);
return getNode(ISD::BUILTIN_OP_END+Opcode, VTs, 2, Ops, NumOps).Val; return getNode(ISD::BUILTIN_OP_END+Opcode, VTs, 2, Ops, NumOps).Val;
} }
@ -3587,14 +3588,14 @@ SDNode *SelectionDAG::getTargetNode(unsigned Opcode, MVT::ValueType VT1,
} }
SDNode *SelectionDAG::getTargetNode(unsigned Opcode, MVT::ValueType VT1, SDNode *SelectionDAG::getTargetNode(unsigned Opcode, MVT::ValueType VT1,
MVT::ValueType VT2, MVT::ValueType VT3, MVT::ValueType VT2, MVT::ValueType VT3,
const SDOperand *Ops, unsigned NumOps) { SDOperandPtr Ops, unsigned NumOps) {
const MVT::ValueType *VTs = getNodeValueTypes(VT1, VT2, VT3); const MVT::ValueType *VTs = getNodeValueTypes(VT1, VT2, VT3);
return getNode(ISD::BUILTIN_OP_END+Opcode, VTs, 3, Ops, NumOps).Val; return getNode(ISD::BUILTIN_OP_END+Opcode, VTs, 3, Ops, NumOps).Val;
} }
SDNode *SelectionDAG::getTargetNode(unsigned Opcode, MVT::ValueType VT1, SDNode *SelectionDAG::getTargetNode(unsigned Opcode, MVT::ValueType VT1,
MVT::ValueType VT2, MVT::ValueType VT3, MVT::ValueType VT2, MVT::ValueType VT3,
MVT::ValueType VT4, MVT::ValueType VT4,
const SDOperand *Ops, unsigned NumOps) { SDOperandPtr Ops, unsigned NumOps) {
std::vector<MVT::ValueType> VTList; std::vector<MVT::ValueType> VTList;
VTList.push_back(VT1); VTList.push_back(VT1);
VTList.push_back(VT2); VTList.push_back(VT2);
@ -3605,7 +3606,7 @@ SDNode *SelectionDAG::getTargetNode(unsigned Opcode, MVT::ValueType VT1,
} }
SDNode *SelectionDAG::getTargetNode(unsigned Opcode, SDNode *SelectionDAG::getTargetNode(unsigned Opcode,
std::vector<MVT::ValueType> &ResultTys, std::vector<MVT::ValueType> &ResultTys,
const SDOperand *Ops, unsigned NumOps) { SDOperandPtr Ops, unsigned NumOps) {
const MVT::ValueType *VTs = getNodeValueTypes(ResultTys); const MVT::ValueType *VTs = getNodeValueTypes(ResultTys);
return getNode(ISD::BUILTIN_OP_END+Opcode, VTs, ResultTys.size(), return getNode(ISD::BUILTIN_OP_END+Opcode, VTs, ResultTys.size(),
Ops, NumOps).Val; Ops, NumOps).Val;
@ -3614,7 +3615,7 @@ SDNode *SelectionDAG::getTargetNode(unsigned Opcode,
/// getNodeIfExists - Get the specified node if it's already available, or /// getNodeIfExists - Get the specified node if it's already available, or
/// else return NULL. /// else return NULL.
SDNode *SelectionDAG::getNodeIfExists(unsigned Opcode, SDVTList VTList, SDNode *SelectionDAG::getNodeIfExists(unsigned Opcode, SDVTList VTList,
const SDOperand *Ops, unsigned NumOps) { SDOperandPtr Ops, unsigned NumOps) {
if (VTList.VTs[VTList.NumVTs-1] != MVT::Flag) { if (VTList.VTs[VTList.NumVTs-1] != MVT::Flag) {
FoldingSetNodeID ID; FoldingSetNodeID ID;
AddNodeIDNode(ID, Opcode, VTList, Ops, NumOps); AddNodeIDNode(ID, Opcode, VTList, Ops, NumOps);
@ -3647,7 +3648,7 @@ void SelectionDAG::ReplaceAllUsesWith(SDOperand FromN, SDOperand To,
int operandNum = 0; int operandNum = 0;
for (SDNode::op_iterator I = U->op_begin(), E = U->op_end(); for (SDNode::op_iterator I = U->op_begin(), E = U->op_end();
I != E; ++I, ++operandNum) I != E; ++I, ++operandNum)
if (I->Val == From) { if (I->getVal() == From) {
From->removeUser(operandNum, U); From->removeUser(operandNum, U);
*I = To; *I = To;
I->setUser(U); I->setUser(U);
@ -3695,9 +3696,9 @@ void SelectionDAG::ReplaceAllUsesWith(SDNode *From, SDNode *To,
int operandNum = 0; int operandNum = 0;
for (SDNode::op_iterator I = U->op_begin(), E = U->op_end(); for (SDNode::op_iterator I = U->op_begin(), E = U->op_end();
I != E; ++I, ++operandNum) I != E; ++I, ++operandNum)
if (I->Val == From) { if (I->getVal() == From) {
From->removeUser(operandNum, U); From->removeUser(operandNum, U);
I->Val = To; I->getVal() = To;
To->addUser(operandNum, U); To->addUser(operandNum, U);
} }
@ -3724,7 +3725,7 @@ void SelectionDAG::ReplaceAllUsesWith(SDNode *From, SDNode *To,
/// This version can replace From with any result values. To must match the /// This version can replace From with any result values. To must match the
/// number and types of values returned by From. /// number and types of values returned by From.
void SelectionDAG::ReplaceAllUsesWith(SDNode *From, void SelectionDAG::ReplaceAllUsesWith(SDNode *From,
const SDOperand *To, SDOperandPtr To,
DAGUpdateListener *UpdateListener) { DAGUpdateListener *UpdateListener) {
if (From->getNumValues() == 1) // Handle the simple case efficiently. if (From->getNumValues() == 1) // Handle the simple case efficiently.
return ReplaceAllUsesWith(SDOperand(From, 0), To[0], UpdateListener); return ReplaceAllUsesWith(SDOperand(From, 0), To[0], UpdateListener);
@ -3738,8 +3739,8 @@ void SelectionDAG::ReplaceAllUsesWith(SDNode *From,
int operandNum = 0; int operandNum = 0;
for (SDNode::op_iterator I = U->op_begin(), E = U->op_end(); for (SDNode::op_iterator I = U->op_begin(), E = U->op_end();
I != E; ++I, ++operandNum) I != E; ++I, ++operandNum)
if (I->Val == From) { if (I->getVal() == From) {
const SDOperand &ToOp = To[I->ResNo]; const SDOperand &ToOp = To[I->getSDOperand().ResNo];
From->removeUser(operandNum, U); From->removeUser(operandNum, U);
*I = ToOp; *I = ToOp;
I->setUser(U); I->setUser(U);
@ -3865,7 +3866,6 @@ void SelectionDAG::ReplaceAllUsesOfValueWith(SDOperand From, SDOperand To,
} }
} }
/// AssignNodeIds - Assign a unique node id for each node in the DAG based on /// AssignNodeIds - Assign a unique node id for each node in the DAG based on
/// their allnodes order. It returns the maximum id. /// their allnodes order. It returns the maximum id.
unsigned SelectionDAG::AssignNodeIds() { unsigned SelectionDAG::AssignNodeIds() {
@ -3902,7 +3902,7 @@ unsigned SelectionDAG::AssignTopologicalOrder(std::vector<SDNode*> &TopOrder) {
Sources.pop_back(); Sources.pop_back();
TopOrder.push_back(N); TopOrder.push_back(N);
for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I) { for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I) {
SDNode *P = I->Val; SDNode *P = I->getVal();
unsigned Degree = --InDegree[P->getNodeId()]; unsigned Degree = --InDegree[P->getNodeId()];
if (Degree == 0) if (Degree == 0)
Sources.push_back(P); Sources.push_back(P);
@ -4077,7 +4077,7 @@ bool SDNode::isOnlyUseOf(SDNode *N) const {
/// isOperand - Return true if this node is an operand of N. /// isOperand - Return true if this node is an operand of N.
/// ///
bool SDOperandImpl::isOperandOf(SDNode *N) const { bool SDOperand::isOperandOf(SDNode *N) const {
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
if (*this == N->getOperand(i)) if (*this == N->getOperand(i))
return true; return true;
@ -4086,7 +4086,7 @@ bool SDOperandImpl::isOperandOf(SDNode *N) const {
bool SDNode::isOperandOf(SDNode *N) const { bool SDNode::isOperandOf(SDNode *N) const {
for (unsigned i = 0, e = N->NumOperands; i != e; ++i) for (unsigned i = 0, e = N->NumOperands; i != e; ++i)
if (this == N->OperandList[i].Val) if (this == N->OperandList[i].getVal())
return true; return true;
return false; return false;
} }
@ -4096,7 +4096,7 @@ bool SDNode::isOperandOf(SDNode *N) const {
/// side-effecting instructions. In practice, this looks through token /// side-effecting instructions. In practice, this looks through token
/// factors and non-volatile loads. In order to remain efficient, this only /// 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. /// looks a couple of nodes in, it does not do an exhaustive search.
bool SDOperandImpl::reachesChainWithoutSideEffects(SDOperandImpl Dest, bool SDOperand::reachesChainWithoutSideEffects(SDOperand Dest,
unsigned Depth) const { unsigned Depth) const {
if (*this == Dest) return true; if (*this == Dest) return true;

View File

@ -2094,7 +2094,7 @@ bool X86::isPSHUFLWMask(SDNode *N) {
/// isSHUFPMask - Return true if the specified VECTOR_SHUFFLE operand /// isSHUFPMask - Return true if the specified VECTOR_SHUFFLE operand
/// specifies a shuffle of elements that is suitable for input to SHUFP*. /// specifies a shuffle of elements that is suitable for input to SHUFP*.
static bool isSHUFPMask(const SDOperand *Elems, unsigned NumElems) { static bool isSHUFPMask(SDOperandPtr Elems, unsigned NumElems) {
if (NumElems != 2 && NumElems != 4) return false; if (NumElems != 2 && NumElems != 4) return false;
unsigned Half = NumElems / 2; unsigned Half = NumElems / 2;
@ -2117,7 +2117,7 @@ bool X86::isSHUFPMask(SDNode *N) {
/// the reverse of what x86 shuffles want. x86 shuffles requires the lower /// the reverse of what x86 shuffles want. x86 shuffles requires the lower
/// half elements to come from vector 1 (which would equal the dest.) and /// half elements to come from vector 1 (which would equal the dest.) and
/// the upper half to come from vector 2. /// the upper half to come from vector 2.
static bool isCommutedSHUFP(const SDOperand *Ops, unsigned NumOps) { static bool isCommutedSHUFP(SDOperandPtr Ops, unsigned NumOps) {
if (NumOps != 2 && NumOps != 4) return false; if (NumOps != 2 && NumOps != 4) return false;
unsigned Half = NumOps / 2; unsigned Half = NumOps / 2;
@ -2211,7 +2211,7 @@ bool X86::isMOVHPMask(SDNode *N) {
/// isUNPCKLMask - Return true if the specified VECTOR_SHUFFLE operand /// isUNPCKLMask - Return true if the specified VECTOR_SHUFFLE operand
/// specifies a shuffle of elements that is suitable for input to UNPCKL. /// specifies a shuffle of elements that is suitable for input to UNPCKL.
bool static isUNPCKLMask(const SDOperand *Elts, unsigned NumElts, bool static isUNPCKLMask(SDOperandPtr Elts, unsigned NumElts,
bool V2IsSplat = false) { bool V2IsSplat = false) {
if (NumElts != 2 && NumElts != 4 && NumElts != 8 && NumElts != 16) if (NumElts != 2 && NumElts != 4 && NumElts != 8 && NumElts != 16)
return false; return false;
@ -2240,7 +2240,7 @@ bool X86::isUNPCKLMask(SDNode *N, bool V2IsSplat) {
/// isUNPCKHMask - Return true if the specified VECTOR_SHUFFLE operand /// isUNPCKHMask - Return true if the specified VECTOR_SHUFFLE operand
/// specifies a shuffle of elements that is suitable for input to UNPCKH. /// specifies a shuffle of elements that is suitable for input to UNPCKH.
bool static isUNPCKHMask(const SDOperand *Elts, unsigned NumElts, bool static isUNPCKHMask(SDOperandPtr Elts, unsigned NumElts,
bool V2IsSplat = false) { bool V2IsSplat = false) {
if (NumElts != 2 && NumElts != 4 && NumElts != 8 && NumElts != 16) if (NumElts != 2 && NumElts != 4 && NumElts != 8 && NumElts != 16)
return false; return false;
@ -2316,7 +2316,7 @@ bool X86::isUNPCKH_v_undef_Mask(SDNode *N) {
/// isMOVLMask - Return true if the specified VECTOR_SHUFFLE operand /// isMOVLMask - Return true if the specified VECTOR_SHUFFLE operand
/// specifies a shuffle of elements that is suitable for input to MOVSS, /// specifies a shuffle of elements that is suitable for input to MOVSS,
/// MOVSD, and MOVD, i.e. setting the lowest element. /// MOVSD, and MOVD, i.e. setting the lowest element.
static bool isMOVLMask(const SDOperand *Elts, unsigned NumElts) { static bool isMOVLMask(SDOperandPtr Elts, unsigned NumElts) {
if (NumElts != 2 && NumElts != 4) if (NumElts != 2 && NumElts != 4)
return false; return false;
@ -2339,7 +2339,7 @@ bool X86::isMOVLMask(SDNode *N) {
/// isCommutedMOVL - Returns true if the shuffle mask is except the reverse /// isCommutedMOVL - Returns true if the shuffle mask is except the reverse
/// of what x86 movss want. X86 movs requires the lowest element to be lowest /// of what x86 movss want. X86 movs requires the lowest element to be lowest
/// element of vector 2 and the other elements to come from vector 1 in order. /// element of vector 2 and the other elements to come from vector 1 in order.
static bool isCommutedMOVL(const SDOperand *Ops, unsigned NumOps, static bool isCommutedMOVL(SDOperandPtr Ops, unsigned NumOps,
bool V2IsSplat = false, bool V2IsSplat = false,
bool V2IsUndef = false) { bool V2IsUndef = false) {
if (NumOps != 2 && NumOps != 4 && NumOps != 8 && NumOps != 16) if (NumOps != 2 && NumOps != 4 && NumOps != 8 && NumOps != 16)