Introduce Simple Analysis interface for loop passes.
authorDevang Patel <dpatel@apple.com>
Tue, 31 Jul 2007 08:00:57 +0000 (08:00 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 31 Jul 2007 08:00:57 +0000 (08:00 +0000)
Right now, this interface provides hooks for only to operations, 1) clone basic block 2) delete value.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40625 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/LoopPass.h
lib/Analysis/LoopPass.cpp

index 33135156ad3df9be44a362b7b59c8f810576ddf1..4914df78e444cbca91dd8143d3c494d2a8b85858 100644 (file)
@@ -63,6 +63,21 @@ class LoopPass : public Pass {
   virtual PassManagerType getPotentialPassManagerType() const {
     return PMT_LoopPassManager;
   }
+
+  //===--------------------------------------------------------------------===//
+  /// SimpleAnalysis - Provides simple interface to update analysis info
+  /// maintained by various passes. Note, if required this interface can
+  /// be extracted into a separate abstract class but it would require
+  /// additional use of multiple inheritance in Pass class hierarcy, someting
+  /// we are trying to avoid.
+
+  /// Each loop pass can override these simple analysis hookss to update
+  /// desired analysis information.
+  /// cloneBasicBlockAnalysis - Clone analysis info associated with basic block.
+  virtual void cloneBasicBlockAnalysis(BasicBlock *F, BasicBlock *T, Loop *L) {}
+
+  /// deletekAnalysisValue - Delete analysis info associated with value V.
+  virtual void deleteAnalysisValue(Value *V, Loop *L) {}
 };
 
 class LPPassManager : public FunctionPass, public PMDataManager {
@@ -115,6 +130,20 @@ public:
   // utility may send LPPassManager into infinite loops so use caution.
   void redoLoop(Loop *L);
 
+  //===--------------------------------------------------------------------===//
+  /// SimpleAnalysis - Provides simple interface to update analysis info
+  /// maintained by various passes. Note, if required this interface can
+  /// be extracted into a separate abstract class but it would require
+  /// additional use of multiple inheritance in Pass class hierarcy, someting
+  /// we are trying to avoid.
+
+  /// cloneBasicBlockSimpleAnalysis - Invoke cloneBasicBlockAnalysis hook for
+  /// all passes that implement simple analysis interface.
+  void cloneBasicBlockSimpleAnalysis(BasicBlock *From, BasicBlock *To, Loop *L);
+
+  /// deleteSimpleAnalysisValue - Invoke deleteAnalysisValue hook for all passes
+  /// that implement simple analysis interface.
+  void deleteSimpleAnalysisValue(Value *V, Loop *L);
 private:
   std::deque<Loop *> LQ;
   bool skipThisLoop;
index dc3e86844eb8658993c98f6f0e9ba97e2b689171..21c14c6293ebefe9135acb6cfb4bb0e0887950c4 100644 (file)
@@ -140,6 +140,27 @@ void LPPassManager::redoLoop(Loop *L) {
   redoThisLoop = true;
 }
 
+/// cloneBasicBlockSimpleAnalysis - Invoke cloneBasicBlockAnalysis hook for
+/// all loop passes.
+void LPPassManager::cloneBasicBlockSimpleAnalysis(BasicBlock *From, 
+                                                  BasicBlock *To, Loop *L) {
+  for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {  
+    Pass *P = getContainedPass(Index);
+    LoopPass *LP = dynamic_cast<LoopPass *>(P);
+    LP->cloneBasicBlockAnalysis(From, To, L);
+  }
+}
+
+/// deleteSimpleAnalysisValue - Invoke deleteAnalysisValue hook for all passes.
+void LPPassManager::deleteSimpleAnalysisValue(Value *V, Loop *L) {
+  for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {  
+    Pass *P = getContainedPass(Index);
+    LoopPass *LP = dynamic_cast<LoopPass *>(P);
+    LP->deleteAnalysisValue(V, L);
+  }
+}
+
+
 // Recurse through all subloops and all loops  into LQ.
 static void addLoopIntoQueue(Loop *L, std::deque<Loop *> &LQ) {
   LQ.push_back(L);