From 5791bb70b12dfce83e2fcd3857af5a5c7fe9782e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 8 Aug 2002 19:01:11 +0000 Subject: [PATCH] - Cleaned up the interface to AnalysisUsage to take analysis class names instead of ::ID's. - Pass::getAnalysis<> now no longer takes an optional argument git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3263 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Pass.h | 14 ++++++++++---- include/llvm/PassAnalysisSupport.h | 24 +++++++++++++++++------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index 0ff286a50d2..edd7e738c8d 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -114,9 +114,15 @@ protected: // getAnalysisUsage function. // template - AnalysisType &getAnalysis(AnalysisID AID = AnalysisType::ID) { + AnalysisType &getAnalysis() { assert(Resolver && "Pass not resident in a PassManager object!"); - return *(AnalysisType*)Resolver->getAnalysis(AID); + return *(AnalysisType*)Resolver->getAnalysis(AnalysisType::ID); + } + + template + AnalysisType &getAnalysisID(const PassInfo *PI) { + assert(Resolver && "Pass not resident in a PassManager object!"); + return *(AnalysisType*)Resolver->getAnalysis(PI); } // getAnalysisToUpdate() - This function is used by subclasses @@ -126,9 +132,9 @@ protected: // provide the capability to update an analysis that exists. // template - AnalysisType *getAnalysisToUpdate(AnalysisID AID = AnalysisType::ID) { + AnalysisType *getAnalysisToUpdate() { assert(Resolver && "Pass not resident in a PassManager object!"); - return (AnalysisType*)Resolver->getAnalysisToUpdate(AID); + return (AnalysisType*)Resolver->getAnalysisToUpdate(AnalysisType::ID); } diff --git a/include/llvm/PassAnalysisSupport.h b/include/llvm/PassAnalysisSupport.h index c08b8830242..f04b4a6b468 100644 --- a/include/llvm/PassAnalysisSupport.h +++ b/include/llvm/PassAnalysisSupport.h @@ -30,28 +30,38 @@ class AnalysisUsage { public: AnalysisUsage() : PreservesAll(false) {} - // addRequires - Add the specified ID to the required set of the usage info + // addRequired - Add the specified ID to the required set of the usage info // for a pass. // - AnalysisUsage &addRequired(AnalysisID ID) { + AnalysisUsage &addRequiredID(AnalysisID ID) { Required.push_back(ID); return *this; } + template + AnalysisUsage &addRequired() { + Required.push_back(PassClass::ID); + return *this; + } - // addPreserves - Add the specified ID to the set of analyses preserved by + // addPreserved - Add the specified ID to the set of analyses preserved by // this pass // - AnalysisUsage &addPreserved(AnalysisID ID) { + AnalysisUsage &addPreservedID(AnalysisID ID) { Preserved.push_back(ID); return *this; } - // PreservesAll - Set by analyses that do not transform their input at all + template + AnalysisUsage &addPreserved() { + Preserved.push_back(PassClass::ID); + return *this; + } + + // setPreservesAll - Set by analyses that do not transform their input at all void setPreservesAll() { PreservesAll = true; } bool preservesAll() const { return PreservesAll; } - // preservesCFG - This function should be called to by the pass, iff they do - // not: + // preservesCFG - This function should be called by the pass, iff they do not: // // 1. Add or remove basic blocks from the function // 2. Modify terminator instructions in any way.