make -print-machineinstrs work for both SparcV9 and X86
[oota-llvm.git] / include / llvm / PassAnalysisSupport.h
index 38987b56159d0c837b0b9a8f4cc189d2c46338bf..f62465a8b8b5949cead86c8228cee40b94aa9087 100644 (file)
@@ -1,4 +1,11 @@
-//===- llvm/PassAnalysisSupport.h - Analysis Pass Support code ---*- C++ -*-==//
+//===- llvm/PassAnalysisSupport.h - Analysis Pass Support code --*- C++ -*-===//
+// 
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// 
+//===----------------------------------------------------------------------===//
 //
 // This file defines stuff that is used to define and "use" Analysis Passes.
 // This file is automatically #included by Pass.h, so:
@@ -12,9 +19,9 @@
 #ifndef LLVM_PASS_ANALYSIS_SUPPORT_H
 #define LLVM_PASS_ANALYSIS_SUPPORT_H
 
-// No need to include Pass.h, we are being included by it!
-
+namespace llvm {
 
+// No need to include Pass.h, we are being included by it!
 
 //===----------------------------------------------------------------------===//
 // AnalysisUsage - Represent the analysis usage information of a pass.  This
@@ -112,4 +119,22 @@ protected:
   void setAnalysisResolver(Pass *P, AnalysisResolver *AR);
 };
 
+/// getAnalysisToUpdate<AnalysisType>() - This function is used by subclasses
+/// to get to the analysis information that might be around that needs to be
+/// updated.  This is different than getAnalysis in that it can fail (ie the
+/// analysis results haven't been computed), so should only be used if you
+/// provide the capability to update an analysis that exists.  This method is
+/// often used by transformation APIs to update analysis results for a pass
+/// automatically as the transform is performed.
+///
+template<typename AnalysisType>
+AnalysisType *Pass::getAnalysisToUpdate() const {
+  assert(Resolver && "Pass not resident in a PassManager object!");
+  const PassInfo *PI = getClassPassInfo<AnalysisType>();
+  if (PI == 0) return 0;
+  return dynamic_cast<AnalysisType*>(Resolver->getAnalysisToUpdate(PI));
+}
+
+} // End llvm namespace
+
 #endif