simplify AnalysisGroup registration, eliminating one typeid call.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29932 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2006-08-28 00:42:29 +00:00
parent 84f82f7fac
commit a5370172b6
15 changed files with 21 additions and 29 deletions

View File

@ -241,23 +241,15 @@ public:
~RegisterAGBase(); ~RegisterAGBase();
}; };
template<typename Interface, bool Default = false>
template<typename Interface, typename DefaultImplementationPass = void,
bool Default = false>
struct RegisterAnalysisGroup : public RegisterAGBase { struct RegisterAnalysisGroup : public RegisterAGBase {
RegisterAnalysisGroup() : RegisterAGBase(typeid(Interface), RegisterAnalysisGroup(RegisterPassBase &RPB)
&typeid(DefaultImplementationPass), : RegisterAGBase(typeid(Interface), &RPB.getPassInfo()->getTypeInfo(),
Default) { Default) {
} }
};
/// Define a specialization of RegisterAnalysisGroup that is used to set the
/// name for the analysis group.
///
template<typename Interface>
struct RegisterAnalysisGroup<Interface, void, false> : public RegisterAGBase {
RegisterAnalysisGroup(const char *Name) RegisterAnalysisGroup(const char *Name)
: RegisterAGBase(typeid(Interface)) { : RegisterAGBase(typeid(Interface)) {
setGroupName(Name); setGroupName(Name);
} }
}; };

View File

@ -111,7 +111,7 @@ namespace {
RegisterPass<AliasAnalysisCounter> RegisterPass<AliasAnalysisCounter>
X("count-aa", "Count Alias Analysis Query Responses"); X("count-aa", "Count Alias Analysis Query Responses");
RegisterAnalysisGroup<AliasAnalysis, AliasAnalysisCounter> Y; RegisterAnalysisGroup<AliasAnalysis> Y(X);
} }
ModulePass *llvm::createAliasAnalysisCounterPass() { ModulePass *llvm::createAliasAnalysisCounterPass() {

View File

@ -76,7 +76,7 @@ namespace {
U("no-aa", "No Alias Analysis (always returns 'may' alias)"); U("no-aa", "No Alias Analysis (always returns 'may' alias)");
// Declare that we implement the AliasAnalysis interface // Declare that we implement the AliasAnalysis interface
RegisterAnalysisGroup<AliasAnalysis, NoAA> V; RegisterAnalysisGroup<AliasAnalysis> V(U);
} // End of anonymous namespace } // End of anonymous namespace
ImmutablePass *llvm::createNoAAPass() { return new NoAA(); } ImmutablePass *llvm::createNoAAPass() { return new NoAA(); }
@ -121,7 +121,7 @@ namespace {
X("basicaa", "Basic Alias Analysis (default AA impl)"); X("basicaa", "Basic Alias Analysis (default AA impl)");
// Declare that we implement the AliasAnalysis interface // Declare that we implement the AliasAnalysis interface
RegisterAnalysisGroup<AliasAnalysis, BasicAliasAnalysis, true> Y; RegisterAnalysisGroup<AliasAnalysis, true> Y(X);
} // End of anonymous namespace } // End of anonymous namespace
ImmutablePass *llvm::createBasicAliasAnalysisPass() { ImmutablePass *llvm::createBasicAliasAnalysisPass() {

View File

@ -99,7 +99,7 @@ namespace {
RegisterPass<DSAA> X("ds-aa", "Data Structure Graph Based Alias Analysis"); RegisterPass<DSAA> X("ds-aa", "Data Structure Graph Based Alias Analysis");
// Register as an implementation of AliasAnalysis // Register as an implementation of AliasAnalysis
RegisterAnalysisGroup<AliasAnalysis, DSAA> Y; RegisterAnalysisGroup<AliasAnalysis> Y(X);
} }
ModulePass *llvm::createDSAAPass() { return new DSAA(); } ModulePass *llvm::createDSAAPass() { return new DSAA(); }

View File

@ -77,7 +77,7 @@ namespace {
"Steensgaard's alias analysis (DSGraph based)"); "Steensgaard's alias analysis (DSGraph based)");
// Register as an implementation of AliasAnalysis // Register as an implementation of AliasAnalysis
RegisterAnalysisGroup<AliasAnalysis, Steens> Y; RegisterAnalysisGroup<AliasAnalysis> Y(X);
} }
ModulePass *llvm::createSteensgaardPass() { return new Steens(); } ModulePass *llvm::createSteensgaardPass() { return new Steens(); }

View File

@ -338,7 +338,7 @@ namespace {
RegisterPass<Andersens> X("anders-aa", RegisterPass<Andersens> X("anders-aa",
"Andersen's Interprocedural Alias Analysis"); "Andersen's Interprocedural Alias Analysis");
RegisterAnalysisGroup<AliasAnalysis, Andersens> Y; RegisterAnalysisGroup<AliasAnalysis> Y(X);
} }
ModulePass *llvm::createAndersensPass() { return new Andersens(); } ModulePass *llvm::createAndersensPass() { return new Andersens(); }

View File

@ -183,7 +183,7 @@ private:
RegisterAnalysisGroup<CallGraph> X("Call Graph"); RegisterAnalysisGroup<CallGraph> X("Call Graph");
RegisterPass<BasicCallGraph> Y("basiccg", "Basic CallGraph Construction"); RegisterPass<BasicCallGraph> Y("basiccg", "Basic CallGraph Construction");
RegisterAnalysisGroup<CallGraph, BasicCallGraph, true> Z; RegisterAnalysisGroup<CallGraph, true> Z(Y);
} //End anonymous namespace } //End anonymous namespace

View File

@ -137,7 +137,7 @@ namespace {
RegisterPass<GlobalsModRef> X("globalsmodref-aa", RegisterPass<GlobalsModRef> X("globalsmodref-aa",
"Simple mod/ref analysis for globals"); "Simple mod/ref analysis for globals");
RegisterAnalysisGroup<AliasAnalysis, GlobalsModRef> Y; RegisterAnalysisGroup<AliasAnalysis> Y(X);
} }
Pass *llvm::createGlobalsModRefPass() { return new GlobalsModRef(); } Pass *llvm::createGlobalsModRefPass() { return new GlobalsModRef(); }

View File

@ -84,7 +84,7 @@ namespace {
RegisterPass<LoadVN> X("load-vn", "Load Value Numbering"); RegisterPass<LoadVN> X("load-vn", "Load Value Numbering");
// Declare that we implement the ValueNumbering interface // Declare that we implement the ValueNumbering interface
RegisterAnalysisGroup<ValueNumbering, LoadVN> Y; RegisterAnalysisGroup<ValueNumbering> Y(X);
} }
FunctionPass *llvm::createLoadValueNumberingPass() { return new LoadVN(); } FunctionPass *llvm::createLoadValueNumberingPass() { return new LoadVN(); }

View File

@ -89,7 +89,7 @@ namespace {
X("no-profile", "No Profile Information"); X("no-profile", "No Profile Information");
// Declare that we implement the ProfileInfo interface // Declare that we implement the ProfileInfo interface
RegisterAnalysisGroup<ProfileInfo, NoProfileInfo, true> Y; RegisterAnalysisGroup<ProfileInfo, true> Y(X);
} // End of anonymous namespace } // End of anonymous namespace
ImmutablePass *llvm::createNoProfileInfoPass() { return new NoProfileInfo(); } ImmutablePass *llvm::createNoProfileInfoPass() { return new NoProfileInfo(); }

View File

@ -52,7 +52,7 @@ namespace {
RegisterPass<LoaderPass> RegisterPass<LoaderPass>
X("profile-loader", "Load profile information from llvmprof.out"); X("profile-loader", "Load profile information from llvmprof.out");
RegisterAnalysisGroup<ProfileInfo, LoaderPass> Y; RegisterAnalysisGroup<ProfileInfo> Y(X);
} // End of anonymous namespace } // End of anonymous namespace
ModulePass *llvm::createProfileLoaderPass() { return new LoaderPass(); } ModulePass *llvm::createProfileLoaderPass() { return new LoaderPass(); }

View File

@ -64,7 +64,7 @@ namespace {
X("basicvn", "Basic Value Numbering (default GVN impl)"); X("basicvn", "Basic Value Numbering (default GVN impl)");
// Declare that we implement the ValueNumbering interface // Declare that we implement the ValueNumbering interface
RegisterAnalysisGroup<ValueNumbering, BasicVN, true> Y; RegisterAnalysisGroup<ValueNumbering, true> Y(X);
/// BVNImpl - Implement BasicVN in terms of a visitor class that /// BVNImpl - Implement BasicVN in terms of a visitor class that
/// handles the different types of instructions as appropriate. /// handles the different types of instructions as appropriate.

View File

@ -53,7 +53,7 @@ using namespace sys;
// is configured into the LIBS variable. // is configured into the LIBS variable.
// Note: this line of code generates a warning if pthread_mutex_init is not // Note: this line of code generates a warning if pthread_mutex_init is not
// declared with weak linkage. It's safe to ignore the warning. // declared with weak linkage. It's safe to ignore the warning.
static const bool pthread_enabled = static_cast<bool>(pthread_mutex_init); static const bool pthread_enabled = true;
// Construct a Mutex using pthread calls // Construct a Mutex using pthread calls
Mutex::Mutex( bool recursive) Mutex::Mutex( bool recursive)

View File

@ -37,7 +37,7 @@ namespace {
RegisterPass<FunctionProfiler> X("insert-function-profiling", RegisterPass<FunctionProfiler> X("insert-function-profiling",
"Insert instrumentation for function profiling"); "Insert instrumentation for function profiling");
RegisterAnalysisGroup<RSProfilers, FunctionProfiler> XG; RegisterAnalysisGroup<RSProfilers> XG(X);
} }
@ -83,7 +83,7 @@ namespace {
RegisterPass<BlockProfiler> Y("insert-block-profiling", RegisterPass<BlockProfiler> Y("insert-block-profiling",
"Insert instrumentation for block profiling"); "Insert instrumentation for block profiling");
RegisterAnalysisGroup<RSProfilers, BlockProfiler> YG; RegisterAnalysisGroup<RSProfilers> YG(Y);
} }
ModulePass *llvm::createBlockProfilerPass() { return new BlockProfiler(); } ModulePass *llvm::createBlockProfilerPass() { return new BlockProfiler(); }

View File

@ -89,7 +89,7 @@ namespace {
static RegisterAnalysisGroup<RSProfilers> A("Profiling passes"); static RegisterAnalysisGroup<RSProfilers> A("Profiling passes");
static RegisterPass<NullProfilerRS> NP("insert-null-profiling-rs", static RegisterPass<NullProfilerRS> NP("insert-null-profiling-rs",
"Measure profiling framework overhead"); "Measure profiling framework overhead");
static RegisterAnalysisGroup<RSProfilers, NullProfilerRS, true> NPT; static RegisterAnalysisGroup<RSProfilers, true> NPT(NP);
/// Chooser - Something that chooses when to make a sample of the profiled code /// Chooser - Something that chooses when to make a sample of the profiled code
class Chooser { class Chooser {