Add INSTANTIATE_AG_PASS, which combines RegisterPass<> with RegisterAnalysisGroup<> for pass registration.

llvm-svn: 109058
This commit is contained in:
Owen Anderson 2010-07-21 23:07:00 +00:00
parent 965a73a28c
commit ac4a1ede17
12 changed files with 50 additions and 62 deletions

View File

@ -1247,7 +1247,7 @@ between passes</a> still apply.</p>
<p>Although <a href="#registration">Pass Registration</a> is optional for normal <p>Although <a href="#registration">Pass Registration</a> is optional for normal
passes, all analysis group implementations must be registered, and must use the passes, all analysis group implementations must be registered, and must use the
<A href="#registerag"><tt>RegisterAnalysisGroup</tt></a> template to join the <A href="#registerag"><tt>INITIALIZE_AG_PASS</tt></a> template to join the
implementation pool. Also, a default implementation of the interface implementation pool. Also, a default implementation of the interface
<b>must</b> be registered with <A <b>must</b> be registered with <A
href="#registerag"><tt>RegisterAnalysisGroup</tt></a>.</p> href="#registerag"><tt>RegisterAnalysisGroup</tt></a>.</p>
@ -1283,8 +1283,10 @@ hypothetical example) instead.</p>
<div class="doc_text"> <div class="doc_text">
<p>The <tt>RegisterAnalysisGroup</tt> template is used to register the analysis <p>The <tt>RegisterAnalysisGroup</tt> template is used to register the analysis
group itself as well as add pass implementations to the analysis group. First, group itself, while the <tt>INITIALIZE_AG_PASS</tt> is used to add pass
an analysis should be registered, with a human readable name provided for it. implementations to the analysis group. First,
an analysis group should be registered, with a human readable name
provided for it.
Unlike registration of passes, there is no command line argument to be specified Unlike registration of passes, there is no command line argument to be specified
for the Analysis Group Interface itself, because it is "abstract":</p> for the Analysis Group Interface itself, because it is "abstract":</p>
@ -1297,35 +1299,36 @@ implementations of the interface by using the following code:</p>
<div class="doc_code"><pre> <div class="doc_code"><pre>
<b>namespace</b> { <b>namespace</b> {
//<i> Analysis Group implementations <b>must</b> be registered normally...</i>
RegisterPass&lt;FancyAA&gt;
B("<i>somefancyaa</i>", "<i>A more complex alias analysis implementation</i>");
//<i> Declare that we implement the AliasAnalysis interface</i> //<i> Declare that we implement the AliasAnalysis interface</i>
RegisterAnalysisGroup&lt;<a href="http://llvm.org/doxygen/classllvm_1_1AliasAnalysis.html">AliasAnalysis</a>&gt; C(B); INITIALIZE_AG_PASS(FancyAA, <a href="http://llvm.org/doxygen/classllvm_1_1AliasAnalysis.html">AliasAnalysis</a>, "<i>somefancyaa</i>",
"<i>A more complex alias analysis implementation</i>",
false, // <i>Is CFG Only?</i>
true, // <i>Is Analysis?</i>
false, // <i>Is default Analysis Group implementation?</i>
);
} }
</pre></div> </pre></div>
<p>This just shows a class <tt>FancyAA</tt> that is registered normally, then <p>This just shows a class <tt>FancyAA</tt> that
uses the <tt>RegisterAnalysisGroup</tt> template to "join" the <tt><a uses the <tt>INITIALIZE_AG_PASS</tt> macro both to register and
href="http://llvm.org/doxygen/classllvm_1_1AliasAnalysis.html">AliasAnalysis</a></tt> to "join" the <tt><a href="http://llvm.org/doxygen/classllvm_1_1AliasAnalysis.html">AliasAnalysis</a></tt>
analysis group. Every implementation of an analysis group should join using analysis group. Every implementation of an analysis group should join using
this template. A single pass may join multiple different analysis groups with this macro.</p>
no problem.</p>
<div class="doc_code"><pre> <div class="doc_code"><pre>
<b>namespace</b> { <b>namespace</b> {
//<i> Analysis Group implementations <b>must</b> be registered normally...</i>
RegisterPass&lt;<a href="http://llvm.org/doxygen/structBasicAliasAnalysis.html">BasicAliasAnalysis</a>&gt;
D("<i>basicaa</i>", "<i>Basic Alias Analysis (default AA impl)</i>");
//<i> Declare that we implement the AliasAnalysis interface</i> //<i> Declare that we implement the AliasAnalysis interface</i>
RegisterAnalysisGroup&lt;<a href="http://llvm.org/doxygen/classllvm_1_1AliasAnalysis.html">AliasAnalysis</a>, <b>true</b>&gt; E(D); INITIALIZE_AG_PASS(BasicAA, <a href="http://llvm.org/doxygen/classllvm_1_1AliasAnalysis.html">AliasAnalysis</a>, "<i>basicaa</i>",
"<i>Basic Alias Analysis (default AA impl)</i>",
false, // <i>Is CFG Only?</i>
true, // <i>Is Analysis?</i>
true, // <i>Is default Analysis Group implementation?</i>
);
} }
</pre></div> </pre></div>
<p>Here we show how the default implementation is specified (using the extra <p>Here we show how the default implementation is specified (using the final
argument to the <tt>RegisterAnalysisGroup</tt> template). There must be exactly argument to the <tt>INITIALIZE_AG_PASS</tt> template). There must be exactly
one default implementation available at all times for an Analysis Group to be one default implementation available at all times for an Analysis Group to be
used. Only default implementation can derive from <tt>ImmutablePass</tt>. used. Only default implementation can derive from <tt>ImmutablePass</tt>.
Here we declare that the Here we declare that the

View File

@ -209,7 +209,9 @@ struct RegisterAnalysisGroup : public RegisterAGBase {
} }
}; };
#define INITIALIZE_AG_PASS(passName, agName, arg, name, cfg, analysis, def) \
static RegisterPass<passName> passName ## _info(arg, name, cfg, analysis); \
static RegisterAnalysisGroup<agName, def> passName ## _ag(passName ## _info)
//===--------------------------------------------------------------------------- //===---------------------------------------------------------------------------
/// PassRegistrationListener class - This class is meant to be derived from by /// PassRegistrationListener class - This class is meant to be derived from by

View File

@ -111,9 +111,8 @@ namespace {
} }
char AliasAnalysisCounter::ID = 0; char AliasAnalysisCounter::ID = 0;
static RegisterPass<AliasAnalysisCounter> INITIALIZE_AG_PASS(AliasAnalysisCounter, AliasAnalysis, "count-aa",
X("count-aa", "Count Alias Analysis Query Responses", false, true); "Count Alias Analysis Query Responses", false, true, false);
static RegisterAnalysisGroup<AliasAnalysis> Y(X);
ModulePass *llvm::createAliasAnalysisCounterPass() { ModulePass *llvm::createAliasAnalysisCounterPass() {
return new AliasAnalysisCounter(); return new AliasAnalysisCounter();

View File

@ -126,9 +126,8 @@ namespace {
} }
char AliasDebugger::ID = 0; char AliasDebugger::ID = 0;
static RegisterPass<AliasDebugger> INITIALIZE_AG_PASS(AliasDebugger, AliasAnalysis, "debug-aa",
X("debug-aa", "AA use debugger", false, true); "AA use debugger", false, true, false);
static RegisterAnalysisGroup<AliasAnalysis> Y(X);
Pass *llvm::createAliasDebugger() { return new AliasDebugger(); } Pass *llvm::createAliasDebugger() { return new AliasDebugger(); }

View File

@ -182,11 +182,9 @@ namespace {
// Register this pass... // Register this pass...
char NoAA::ID = 0; char NoAA::ID = 0;
static RegisterPass<NoAA> INITIALIZE_AG_PASS(NoAA, AliasAnalysis, "no-aa",
U("no-aa", "No Alias Analysis (always returns 'may' alias)", true, true); "No Alias Analysis (always returns 'may' alias)",
true, true, false);
// Declare that we implement the AliasAnalysis interface
static RegisterAnalysisGroup<AliasAnalysis> V(U);
ImmutablePass *llvm::createNoAAPass() { return new NoAA(); } ImmutablePass *llvm::createNoAAPass() { return new NoAA(); }
@ -275,11 +273,9 @@ namespace {
// Register this pass... // Register this pass...
char BasicAliasAnalysis::ID = 0; char BasicAliasAnalysis::ID = 0;
static RegisterPass<BasicAliasAnalysis> INITIALIZE_AG_PASS(BasicAliasAnalysis, AliasAnalysis, "basicaa",
X("basicaa", "Basic Alias Analysis (default AA impl)", false, true); "Basic Alias Analysis (default AA impl)",
false, true, true);
// Declare that we implement the AliasAnalysis interface
static RegisterAnalysisGroup<AliasAnalysis, true> Y(X);
ImmutablePass *llvm::createBasicAliasAnalysisPass() { ImmutablePass *llvm::createBasicAliasAnalysisPass() {
return new BasicAliasAnalysis(); return new BasicAliasAnalysis();

View File

@ -62,9 +62,8 @@ namespace {
} }
char CFGOnlyViewer::ID = 0; char CFGOnlyViewer::ID = 0;
static RegisterPass<CFGOnlyViewer> INITIALIZE_PASS(CFGOnlyViewer, "view-cfg-only",
V1("view-cfg-only", "View CFG of function (with no function bodies)", false, true);
"View CFG of function (with no function bodies)", false, true);
namespace { namespace {
struct CFGPrinter : public FunctionPass { struct CFGPrinter : public FunctionPass {

View File

@ -172,9 +172,8 @@ private:
} //End anonymous namespace } //End anonymous namespace
static RegisterAnalysisGroup<CallGraph> X("Call Graph"); static RegisterAnalysisGroup<CallGraph> X("Call Graph");
static RegisterPass<BasicCallGraph> INITIALIZE_AG_PASS(BasicCallGraph, CallGraph, "basiccg",
Y("basiccg", "Basic CallGraph Construction", false, true); "Basic CallGraph Construction", false, true, true);
static RegisterAnalysisGroup<CallGraph, true> Z(Y);
char CallGraph::ID = 0; char CallGraph::ID = 0;
char BasicCallGraph::ID = 0; char BasicCallGraph::ID = 0;

View File

@ -23,8 +23,8 @@
using namespace llvm; using namespace llvm;
char FindUsedTypes::ID = 0; char FindUsedTypes::ID = 0;
static RegisterPass<FindUsedTypes> INITIALIZE_PASS(FindUsedTypes, "print-used-types",
X("print-used-types", "Find Used Types", false, true); "Find Used Types", false, true);
// IncorporateType - Incorporate one type and all of its subtypes into the // IncorporateType - Incorporate one type and all of its subtypes into the
// collection of used types. // collection of used types.

View File

@ -20,11 +20,8 @@ using namespace llvm;
// Register this pass... // Register this pass...
char LibCallAliasAnalysis::ID = 0; char LibCallAliasAnalysis::ID = 0;
static RegisterPass<LibCallAliasAnalysis> INITIALIZE_AG_PASS(LibCallAliasAnalysis, AliasAnalysis, "libcall-aa",
X("libcall-aa", "LibCall Alias Analysis", false, true); "LibCall Alias Analysis", false, true, false);
// Declare that we implement the AliasAnalysis interface
static RegisterAnalysisGroup<AliasAnalysis> Y(X);
FunctionPass *llvm::createLibCallAliasAnalysisPass(LibCallInfo *LCI) { FunctionPass *llvm::createLibCallAliasAnalysisPass(LibCallInfo *LCI) {
return new LibCallAliasAnalysis(LCI); return new LibCallAliasAnalysis(LCI);

View File

@ -53,8 +53,8 @@ FunctionPass* llvm::createPostDomTree() {
// PostDominanceFrontier Implementation // PostDominanceFrontier Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
static RegisterPass<PostDominanceFrontier> INITIALIZE_PASS(PostDominanceFrontier, "postdomfrontier",
H("postdomfrontier", "Post-Dominance Frontier Construction", true, true); "Post-Dominance Frontier Construction", true, true);
const DominanceFrontier::DomSetType & const DominanceFrontier::DomSetType &
PostDominanceFrontier::calculate(const PostDominatorTree &DT, PostDominanceFrontier::calculate(const PostDominatorTree &DT,

View File

@ -1096,10 +1096,7 @@ namespace {
char NoProfileInfo::ID = 0; char NoProfileInfo::ID = 0;
// Register this pass... // Register this pass...
static RegisterPass<NoProfileInfo> INITIALIZE_AG_PASS(NoProfileInfo, ProfileInfo, "no-profile",
X("no-profile", "No Profile Information", false, true); "No Profile Information", false, true, true);
// Declare that we implement the ProfileInfo interface
static RegisterAnalysisGroup<ProfileInfo, true> Y(X);
ImmutablePass *llvm::createNoProfileInfoPass() { return new NoProfileInfo(); } ImmutablePass *llvm::createNoProfileInfoPass() { return new NoProfileInfo(); }

View File

@ -58,11 +58,8 @@ namespace {
// Register this pass... // Register this pass...
char ScalarEvolutionAliasAnalysis::ID = 0; char ScalarEvolutionAliasAnalysis::ID = 0;
static RegisterPass<ScalarEvolutionAliasAnalysis> INITIALIZE_AG_PASS(ScalarEvolutionAliasAnalysis, AliasAnalysis, "scev-aa",
X("scev-aa", "ScalarEvolution-based Alias Analysis", false, true); "ScalarEvolution-based Alias Analysis", false, true, false);
// Declare that we implement the AliasAnalysis interface
static RegisterAnalysisGroup<AliasAnalysis> Y(X);
FunctionPass *llvm::createScalarEvolutionAliasAnalysisPass() { FunctionPass *llvm::createScalarEvolutionAliasAnalysisPass() {
return new ScalarEvolutionAliasAnalysis(); return new ScalarEvolutionAliasAnalysis();