Minor tweaks

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10983 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2004-01-27 21:49:42 +00:00
parent 7a31285c3f
commit 660f1e90ec
2 changed files with 22 additions and 10 deletions

View File

@@ -28,6 +28,7 @@ class Type;
class DSNode; // Each node in the graph class DSNode; // Each node in the graph
class DSGraph; // A graph for a function class DSGraph; // A graph for a function
class ReachabilityCloner;
namespace DS { // FIXME: After the paper, this should get cleaned up namespace DS { // FIXME: After the paper, this should get cleaned up
enum { PointerShift = 2, // 64bit ptrs = 3, 32 bit ptrs = 2 enum { PointerShift = 2, // 64bit ptrs = 3, 32 bit ptrs = 2
@@ -76,6 +77,7 @@ public:
} }
bool operator>(const DSNodeHandle &H) const { return H < *this; } bool operator>(const DSNodeHandle &H) const { return H < *this; }
bool operator==(const DSNodeHandle &H) const { // Allow comparison bool operator==(const DSNodeHandle &H) const { // Allow comparison
// getNode can change the offset, so we must call getNode() first.
return getNode() == H.getNode() && Offset == H.Offset; return getNode() == H.getNode() && Offset == H.Offset;
} }
bool operator!=(const DSNodeHandle &H) const { return !operator==(H); } bool operator!=(const DSNodeHandle &H) const { return !operator==(H); }
@@ -167,6 +169,10 @@ class DSCallSite {
} }
} }
static void InitNH(DSNodeHandle &NH, const DSNodeHandle &Src,
ReachabilityCloner &RC);
DSCallSite(); // DO NOT IMPLEMENT DSCallSite(); // DO NOT IMPLEMENT
public: public:
/// Constructor. Note - This ctor destroys the argument vector passed in. On /// Constructor. Note - This ctor destroys the argument vector passed in. On
@@ -194,7 +200,7 @@ public:
/// This is useful when moving a call site from one graph to another. /// This is useful when moving a call site from one graph to another.
/// ///
template<typename MapTy> template<typename MapTy>
DSCallSite(const DSCallSite &FromCall, const MapTy &NodeMap) { DSCallSite(const DSCallSite &FromCall, MapTy &NodeMap) {
Site = FromCall.Site; Site = FromCall.Site;
InitNH(RetVal, FromCall.RetVal, NodeMap); InitNH(RetVal, FromCall.RetVal, NodeMap);
InitNH(CalleeN, FromCall.CalleeN, NodeMap); InitNH(CalleeN, FromCall.CalleeN, NodeMap);
@@ -235,7 +241,7 @@ public:
assert(!CalleeN.getNode() && CalleeF); return CalleeF; assert(!CalleeN.getNode() && CalleeF); return CalleeF;
} }
unsigned getNumPtrArgs() const { return CallArgs.size(); } unsigned getNumPtrArgs() const { return CallArgs.size(); }
DSNodeHandle &getPtrArg(unsigned i) { DSNodeHandle &getPtrArg(unsigned i) {
assert(i < CallArgs.size() && "Argument to getPtrArgNode is out of range!"); assert(i < CallArgs.size() && "Argument to getPtrArgNode is out of range!");
@@ -256,7 +262,7 @@ public:
} }
} }
// MergeWith - Merge the return value and parameters of the these two call // mergeWith - Merge the return value and parameters of the these two call
// sites. // sites.
void mergeWith(DSCallSite &CS) { void mergeWith(DSCallSite &CS) {
getRetVal().mergeWith(CS.getRetVal()); getRetVal().mergeWith(CS.getRetVal());
@@ -289,8 +295,8 @@ public:
} }
bool operator==(const DSCallSite &CS) const { bool operator==(const DSCallSite &CS) const {
return RetVal == CS.RetVal && CalleeN == CS.CalleeN && return CalleeF == CS.CalleeF && CalleeN == CS.CalleeN &&
CalleeF == CS.CalleeF && CallArgs == CS.CallArgs; RetVal == CS.RetVal && CallArgs == CS.CallArgs;
} }
}; };

View File

@@ -28,6 +28,7 @@ class Type;
class DSNode; // Each node in the graph class DSNode; // Each node in the graph
class DSGraph; // A graph for a function class DSGraph; // A graph for a function
class ReachabilityCloner;
namespace DS { // FIXME: After the paper, this should get cleaned up namespace DS { // FIXME: After the paper, this should get cleaned up
enum { PointerShift = 2, // 64bit ptrs = 3, 32 bit ptrs = 2 enum { PointerShift = 2, // 64bit ptrs = 3, 32 bit ptrs = 2
@@ -76,6 +77,7 @@ public:
} }
bool operator>(const DSNodeHandle &H) const { return H < *this; } bool operator>(const DSNodeHandle &H) const { return H < *this; }
bool operator==(const DSNodeHandle &H) const { // Allow comparison bool operator==(const DSNodeHandle &H) const { // Allow comparison
// getNode can change the offset, so we must call getNode() first.
return getNode() == H.getNode() && Offset == H.Offset; return getNode() == H.getNode() && Offset == H.Offset;
} }
bool operator!=(const DSNodeHandle &H) const { return !operator==(H); } bool operator!=(const DSNodeHandle &H) const { return !operator==(H); }
@@ -167,6 +169,10 @@ class DSCallSite {
} }
} }
static void InitNH(DSNodeHandle &NH, const DSNodeHandle &Src,
ReachabilityCloner &RC);
DSCallSite(); // DO NOT IMPLEMENT DSCallSite(); // DO NOT IMPLEMENT
public: public:
/// Constructor. Note - This ctor destroys the argument vector passed in. On /// Constructor. Note - This ctor destroys the argument vector passed in. On
@@ -194,7 +200,7 @@ public:
/// This is useful when moving a call site from one graph to another. /// This is useful when moving a call site from one graph to another.
/// ///
template<typename MapTy> template<typename MapTy>
DSCallSite(const DSCallSite &FromCall, const MapTy &NodeMap) { DSCallSite(const DSCallSite &FromCall, MapTy &NodeMap) {
Site = FromCall.Site; Site = FromCall.Site;
InitNH(RetVal, FromCall.RetVal, NodeMap); InitNH(RetVal, FromCall.RetVal, NodeMap);
InitNH(CalleeN, FromCall.CalleeN, NodeMap); InitNH(CalleeN, FromCall.CalleeN, NodeMap);
@@ -235,7 +241,7 @@ public:
assert(!CalleeN.getNode() && CalleeF); return CalleeF; assert(!CalleeN.getNode() && CalleeF); return CalleeF;
} }
unsigned getNumPtrArgs() const { return CallArgs.size(); } unsigned getNumPtrArgs() const { return CallArgs.size(); }
DSNodeHandle &getPtrArg(unsigned i) { DSNodeHandle &getPtrArg(unsigned i) {
assert(i < CallArgs.size() && "Argument to getPtrArgNode is out of range!"); assert(i < CallArgs.size() && "Argument to getPtrArgNode is out of range!");
@@ -256,7 +262,7 @@ public:
} }
} }
// MergeWith - Merge the return value and parameters of the these two call // mergeWith - Merge the return value and parameters of the these two call
// sites. // sites.
void mergeWith(DSCallSite &CS) { void mergeWith(DSCallSite &CS) {
getRetVal().mergeWith(CS.getRetVal()); getRetVal().mergeWith(CS.getRetVal());
@@ -289,8 +295,8 @@ public:
} }
bool operator==(const DSCallSite &CS) const { bool operator==(const DSCallSite &CS) const {
return RetVal == CS.RetVal && CalleeN == CS.CalleeN && return CalleeF == CS.CalleeF && CalleeN == CS.CalleeN &&
CalleeF == CS.CalleeF && CallArgs == CS.CallArgs; RetVal == CS.RetVal && CallArgs == CS.CallArgs;
} }
}; };