LDA analysis output scaffolding.
authorAndreas Bolka <a@bolka.at>
Sun, 28 Jun 2009 00:16:08 +0000 (00:16 +0000)
committerAndreas Bolka <a@bolka.at>
Sun, 28 Jun 2009 00:16:08 +0000 (00:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74400 91177308-0d34-0410-b5e6-96231b3b80d8

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

index c69bc60bead2627c5b37b7b6b69f674d563afc7d..0c3dadea75fcae03acac898892901910510ff3ff 100644 (file)
 #define LLVM_ANALYSIS_LOOP_DEPENDENCE_ANALYSIS_H
 
 #include "llvm/Analysis/LoopPass.h"
+#include "llvm/Support/raw_ostream.h"
+#include <iosfwd>
 
 namespace llvm {
 
   class AnalysisUsage;
-  class LoopPass;
   class ScalarEvolution;
 
   class LoopDependenceAnalysis : public LoopPass {
@@ -39,6 +40,12 @@ namespace llvm {
     bool runOnLoop(Loop*, LPPassManager&);
 
     virtual void getAnalysisUsage(AnalysisUsage&) const;
+
+    void print(raw_ostream&, const Module* = 0) const;
+    virtual void print(std::ostream&, const Module* = 0) const;
+    void print(std::ostream *OS, const Module *M = 0) const {
+      if (OS) print(*OS, M);
+    }
   }; // class LoopDependenceAnalysis
 
 
index 172a2be6bcf7cee14a6774673430e3371a035919..8f3e6baf5c57596f06ec714dfcb8928a71aed996 100644 (file)
@@ -43,5 +43,23 @@ bool LoopDependenceAnalysis::runOnLoop(Loop *L, LPPassManager &) {
 
 void LoopDependenceAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.setPreservesAll();
-  AU.addRequired<ScalarEvolution>();
+  AU.addRequiredTransitive<ScalarEvolution>();
+}
+
+static void PrintLoopInfo(
+    raw_ostream &OS, const LoopDependenceAnalysis *LDA, const Loop *L) {
+  if (!L->empty()) return; // ignore non-innermost loops
+
+  OS << "Loop at depth " << L->getLoopDepth() << ", header block: ";
+  WriteAsOperand(OS, L->getHeader(), false);
+  OS << "\n";
+}
+
+void LoopDependenceAnalysis::print(raw_ostream &OS, const Module*) const {
+  PrintLoopInfo(OS, this, this->L);
+}
+
+void LoopDependenceAnalysis::print(std::ostream &OS, const Module *M) const {
+  raw_os_ostream os(OS);
+  print(os, M);
 }