summaryrefslogtreecommitdiff
path: root/include/llvm
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-02-04 20:00:08 +0000
committerChris Lattner <sabre@nondot.org>2002-02-04 20:00:08 +0000
commit4fd2dbbf1dacf098e97fd358bb2b3f48000703a8 (patch)
tree224873e4c6a3d99332a993594729244803d60ae8 /include/llvm
parent017e4cca8c953dc01cc6d1378f117a012a5c0d04 (diff)
downloadllvm-4fd2dbbf1dacf098e97fd358bb2b3f48000703a8.tar.gz
llvm-4fd2dbbf1dacf098e97fd358bb2b3f48000703a8.tar.bz2
llvm-4fd2dbbf1dacf098e97fd358bb2b3f48000703a8.tar.xz
Turn live variable analysis into a real MethodPass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1699 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h40
-rw-r--r--include/llvm/CodeGen/FunctionLiveVarInfo.h40
2 files changed, 50 insertions, 30 deletions
diff --git a/include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h b/include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h
index a1470fe485..9e44be4642 100644
--- a/include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h
+++ b/include/llvm/Analysis/LiveVar/FunctionLiveVarInfo.h
@@ -67,12 +67,13 @@
static const int DEBUG_LV = 0;
-#include "BBLiveVar.h"
+#include "llvm/Analysis/LiveVar/BBLiveVar.h"
+#include "llvm/Pass.h"
-class MethodLiveVarInfo {
+class MethodLiveVarInfo : public MethodPass {
// Live var anal is done on this method - set by constructor
- const Method *const Meth;
+ const Method *Meth;
// A map betwn the BasicBlock and BBLiveVar
BBToBBLiveVarMapType BB2BBLVMap;
@@ -83,10 +84,6 @@ class MethodLiveVarInfo {
// Machine Instr to LiveVarSet Map for providing LVset AFTER each inst
MInstToLiveVarSetMapType MInst2LVSetAI;
- // True if the analyze() method has been called. This is checked when
- // getInSet/OutSet is called to prevent calling those methods before analyze
- bool HasAnalyzed;
-
// --------- private methods -----------------------------------------
@@ -100,22 +97,36 @@ class MethodLiveVarInfo {
void calcLiveVarSetsForBB(const BasicBlock *BB);
- public:
- MethodLiveVarInfo(const Method *Meth);
- ~MethodLiveVarInfo();
+public:
+ static AnalysisID ID; // We are an analysis, we must have an ID
+
+ MethodLiveVarInfo(AnalysisID id = ID) : Meth(0) { assert(id == ID); }
+ ~MethodLiveVarInfo() { releaseMemory(); }
+
+ // --------- Implement the MethodPass interface ----------------------
+
+ // runOnMethod - Perform analysis, update internal data structures.
+ virtual bool runOnMethod(Method *M);
- // performs a liver var analysis of a single method
- void analyze();
+ // releaseMemory - After LiveVariable analysis has been used, forget!
+ virtual void releaseMemory();
+
+ // getAnalysisUsageInfo - Provide self!
+ virtual void getAnalysisUsageInfo(AnalysisSet &Required,
+ AnalysisSet &Destroyed,
+ AnalysisSet &Provided) {
+ Provided.push_back(ID);
+ }
+
+ // --------- Functions to access analysis results -------------------
// gets OutSet of a BB
inline const LiveVarSet *getOutSetOfBB( const BasicBlock *BB) const {
- assert( HasAnalyzed && "call analyze() before calling this" );
return BB2BBLVMap.find(BB)->second->getOutSet();
}
// gets InSet of a BB
inline const LiveVarSet *getInSetOfBB( const BasicBlock *BB) const {
- assert(HasAnalyzed && "call analyze() before calling this" );
return BB2BBLVMap.find(BB)->second->getInSet();
}
@@ -126,7 +137,6 @@ class MethodLiveVarInfo {
// gets the Live var set AFTER an instruction
const LiveVarSet * getLiveVarSetAfterMInst(const MachineInstr *MInst,
const BasicBlock *CurBB);
-
};
#endif
diff --git a/include/llvm/CodeGen/FunctionLiveVarInfo.h b/include/llvm/CodeGen/FunctionLiveVarInfo.h
index a1470fe485..9e44be4642 100644
--- a/include/llvm/CodeGen/FunctionLiveVarInfo.h
+++ b/include/llvm/CodeGen/FunctionLiveVarInfo.h
@@ -67,12 +67,13 @@
static const int DEBUG_LV = 0;
-#include "BBLiveVar.h"
+#include "llvm/Analysis/LiveVar/BBLiveVar.h"
+#include "llvm/Pass.h"
-class MethodLiveVarInfo {
+class MethodLiveVarInfo : public MethodPass {
// Live var anal is done on this method - set by constructor
- const Method *const Meth;
+ const Method *Meth;
// A map betwn the BasicBlock and BBLiveVar
BBToBBLiveVarMapType BB2BBLVMap;
@@ -83,10 +84,6 @@ class MethodLiveVarInfo {
// Machine Instr to LiveVarSet Map for providing LVset AFTER each inst
MInstToLiveVarSetMapType MInst2LVSetAI;
- // True if the analyze() method has been called. This is checked when
- // getInSet/OutSet is called to prevent calling those methods before analyze
- bool HasAnalyzed;
-
// --------- private methods -----------------------------------------
@@ -100,22 +97,36 @@ class MethodLiveVarInfo {
void calcLiveVarSetsForBB(const BasicBlock *BB);
- public:
- MethodLiveVarInfo(const Method *Meth);
- ~MethodLiveVarInfo();
+public:
+ static AnalysisID ID; // We are an analysis, we must have an ID
+
+ MethodLiveVarInfo(AnalysisID id = ID) : Meth(0) { assert(id == ID); }
+ ~MethodLiveVarInfo() { releaseMemory(); }
+
+ // --------- Implement the MethodPass interface ----------------------
+
+ // runOnMethod - Perform analysis, update internal data structures.
+ virtual bool runOnMethod(Method *M);
- // performs a liver var analysis of a single method
- void analyze();
+ // releaseMemory - After LiveVariable analysis has been used, forget!
+ virtual void releaseMemory();
+
+ // getAnalysisUsageInfo - Provide self!
+ virtual void getAnalysisUsageInfo(AnalysisSet &Required,
+ AnalysisSet &Destroyed,
+ AnalysisSet &Provided) {
+ Provided.push_back(ID);
+ }
+
+ // --------- Functions to access analysis results -------------------
// gets OutSet of a BB
inline const LiveVarSet *getOutSetOfBB( const BasicBlock *BB) const {
- assert( HasAnalyzed && "call analyze() before calling this" );
return BB2BBLVMap.find(BB)->second->getOutSet();
}
// gets InSet of a BB
inline const LiveVarSet *getInSetOfBB( const BasicBlock *BB) const {
- assert(HasAnalyzed && "call analyze() before calling this" );
return BB2BBLVMap.find(BB)->second->getInSet();
}
@@ -126,7 +137,6 @@ class MethodLiveVarInfo {
// gets the Live var set AFTER an instruction
const LiveVarSet * getLiveVarSetAfterMInst(const MachineInstr *MInst,
const BasicBlock *CurBB);
-
};
#endif