aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Analysis/DataStructure/DataStructure.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-03-28 17:48:41 +0000
committerChris Lattner <sabre@nondot.org>2002-03-28 17:48:41 +0000
commit1d8ec6194a3c8d6e676f373af04171e5ad2ed4eb (patch)
treed4bd19c1706fd8ac4cf8bfc49117f743b2c93a9d /include/llvm/Analysis/DataStructure/DataStructure.h
parent0732c70ffb55d663fa2d1f5406c5c25bcd27a8b0 (diff)
* Define some operators on PointerVal and PVS's
* Nodes can determine whether they are foldable with another node * Rename NewDSNode to AllocDSNode * The Function graph breaks up all of the node types into individual vectors to alloc fast access when you are looking for a particular type of node. Simplifies much code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2009 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Analysis/DataStructure/DataStructure.h')
-rw-r--r--include/llvm/Analysis/DataStructure/DataStructure.h45
1 files changed, 39 insertions, 6 deletions
diff --git a/include/llvm/Analysis/DataStructure/DataStructure.h b/include/llvm/Analysis/DataStructure/DataStructure.h
index 73cc19f3f0..5132208277 100644
--- a/include/llvm/Analysis/DataStructure/DataStructure.h
+++ b/include/llvm/Analysis/DataStructure/DataStructure.h
@@ -40,6 +40,11 @@ public:
inline bool operator==(DSNode *N) const { return Node == N; }
inline bool operator!=(DSNode *N) const { return Node != N; }
+ // operator< - Allow insertion into a map...
+ bool operator<(const PointerVal &PV) const {
+ return Node < PV.Node || (Node == PV.Node && Index < PV.Index);
+ }
+
inline bool operator==(const PointerVal &PV) const {
return Node == PV.Node && Index == PV.Index;
}
@@ -63,6 +68,10 @@ public:
~PointerValSet() { dropRefs(); }
const PointerValSet &operator=(const PointerValSet &PVS);
+ // operator< - Allow insertion into a map...
+ bool operator<(const PointerValSet &PVS) const;
+ bool operator==(const PointerValSet &PVS) const;
+
const PointerVal &operator[](unsigned i) const { return Vals[i]; }
unsigned size() const { return Vals.size(); }
@@ -144,6 +153,9 @@ public:
return 0; // Default to nothing...
}
+ // isEquivalentTo - Return true if the nodes should be merged...
+ virtual bool isEquivalentTo(DSNode *Node) const = 0;
+
DSNode *clone() const {
DSNode *New = cloneImpl();
// Add all of the pointers to the new node...
@@ -165,23 +177,26 @@ protected:
};
-// NewDSNode - Represent all allocation (malloc or alloca) in the program.
+// AllocDSNode - Represent all allocation (malloc or alloca) in the program.
//
-class NewDSNode : public DSNode {
+class AllocDSNode : public DSNode {
AllocationInst *Allocation;
public:
- NewDSNode(AllocationInst *V);
+ AllocDSNode(AllocationInst *V);
virtual std::string getCaption() const;
bool isAllocaNode() const;
bool isMallocNode() const { return !isAllocaNode(); }
+ // isEquivalentTo - Return true if the nodes should be merged...
+ virtual bool isEquivalentTo(DSNode *Node) const;
+
// Support type inquiry through isa, cast, and dyn_cast...
- static bool classof(const NewDSNode *) { return true; }
+ static bool classof(const AllocDSNode *) { return true; }
static bool classof(const DSNode *N) { return N->NodeType == NewNode; }
protected:
- virtual NewDSNode *cloneImpl() const { return new NewDSNode(Allocation); }
+ virtual AllocDSNode *cloneImpl() const { return new AllocDSNode(Allocation); }
};
@@ -192,8 +207,13 @@ class GlobalDSNode : public DSNode {
public:
GlobalDSNode(GlobalValue *V);
+ GlobalValue *getGlobal() const { return Val; }
+
virtual std::string getCaption() const;
+ // isEquivalentTo - Return true if the nodes should be merged...
+ virtual bool isEquivalentTo(DSNode *Node) const;
+
// Support type inquiry through isa, cast, and dyn_cast...
static bool classof(const GlobalDSNode *) { return true; }
static bool classof(const DSNode *N) { return N->NodeType == GlobalNode; }
@@ -205,6 +225,7 @@ private:
// CallDSNode - Represent a call instruction in the program...
//
class CallDSNode : public DSNode {
+ friend class FunctionDSGraph;
CallInst *CI;
std::vector<PointerValSet> ArgLinks;
public:
@@ -224,12 +245,15 @@ public:
assert(ArgNo < ArgLinks.size() && "Arg # out of range!");
return ArgLinks[ArgNo];
}
+ const std::vector<PointerValSet> &getArgs() const { return ArgLinks; }
virtual void dropAllReferences() {
DSNode::dropAllReferences();
ArgLinks.clear();
}
+ // isEquivalentTo - Return true if the nodes should be merged...
+ virtual bool isEquivalentTo(DSNode *Node) const;
// Support type inquiry through isa, cast, and dyn_cast...
static bool classof(const CallDSNode *) { return true; }
@@ -249,6 +273,9 @@ public:
ArgDSNode(FunctionArgument *MA);
virtual std::string getCaption() const;
+ // isEquivalentTo - Return true if the nodes should be merged...
+ virtual bool isEquivalentTo(DSNode *Node) const;
+
// Support type inquiry through isa, cast, and dyn_cast...
static bool classof(const ArgDSNode *) { return true; }
static bool classof(const DSNode *N) { return N->NodeType == ArgNode; }
@@ -289,6 +316,9 @@ public:
bool isCriticalNode() const { return CriticalNode; }
void resetCriticalMark() { CriticalNode = false; }
+ // isEquivalentTo - Return true if the nodes should be merged...
+ virtual bool isEquivalentTo(DSNode *Node) const;
+
// Support type inquiry through isa, cast, and dyn_cast...
static bool classof(const ShadowDSNode *) { return true; }
static bool classof(const DSNode *N) { return N->NodeType == ShadowNode; }
@@ -311,8 +341,11 @@ protected:
//
class FunctionDSGraph {
Function *Func;
- std::vector<DSNode*> Nodes;
+ std::vector<ArgDSNode*> ArgNodes;
+ std::vector<AllocDSNode*> AllocNodes;
std::vector<ShadowDSNode*> ShadowNodes;
+ std::vector<GlobalDSNode*> GlobalNodes;
+ std::vector<CallDSNode*> CallNodes;
PointerValSet RetNode; // Node that gets returned...
std::map<Value*, PointerValSet> ValueMap;