Add INSTANTIATE_AG_PASS, which combines RegisterPass<> with RegisterAnalysisGroup...
authorOwen Anderson <resistor@mac.com>
Wed, 21 Jul 2010 23:07:00 +0000 (23:07 +0000)
committerOwen Anderson <resistor@mac.com>
Wed, 21 Jul 2010 23:07:00 +0000 (23:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109058 91177308-0d34-0410-b5e6-96231b3b80d8

12 files changed:
docs/WritingAnLLVMPass.html
include/llvm/PassSupport.h
lib/Analysis/AliasAnalysisCounter.cpp
lib/Analysis/AliasDebugger.cpp
lib/Analysis/BasicAliasAnalysis.cpp
lib/Analysis/CFGPrinter.cpp
lib/Analysis/IPA/CallGraph.cpp
lib/Analysis/IPA/FindUsedTypes.cpp
lib/Analysis/LibCallAliasAnalysis.cpp
lib/Analysis/PostDominators.cpp
lib/Analysis/ProfileInfo.cpp
lib/Analysis/ScalarEvolutionAliasAnalysis.cpp

index f6360a19c3247946334861b8efc71d1ae2bbb86b..3cef2c934482485586b113e27b6416bc2f288734 100644 (file)
@@ -1247,7 +1247,7 @@ between passes</a> still apply.</p>
 
 <p>Although <a href="#registration">Pass Registration</a> is optional for normal
 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
 <b>must</b> be registered with <A
 href="#registerag"><tt>RegisterAnalysisGroup</tt></a>.</p>
@@ -1283,8 +1283,10 @@ hypothetical example) instead.</p>
 <div class="doc_text">
 
 <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,
-an analysis should be registered, with a human readable name provided for it.
+group itself, while the <tt>INITIALIZE_AG_PASS</tt> is used to add pass
+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
 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>
 <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>
-  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>
 
-<p>This just shows a class <tt>FancyAA</tt> that is registered normally, then
-uses the <tt>RegisterAnalysisGroup</tt> template to "join" the <tt><a
-href="http://llvm.org/doxygen/classllvm_1_1AliasAnalysis.html">AliasAnalysis</a></tt>
+<p>This just shows a class <tt>FancyAA</tt> that 
+uses the <tt>INITIALIZE_AG_PASS</tt> macro both to register and
+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
-this template.  A single pass may join multiple different analysis groups with
-no problem.</p>
+this macro.</p>
 
 <div class="doc_code"><pre>
 <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>
-  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>
 
-<p>Here we show how the default implementation is specified (using the extra
-argument to the <tt>RegisterAnalysisGroup</tt> template).  There must be exactly
+<p>Here we show how the default implementation is specified (using the final
+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
 used.  Only default implementation can derive from <tt>ImmutablePass</tt>. 
 Here we declare that the
index 4e936c1b213acc2f9fb40dc66f6813f0079f8a69..07dc7f1d15cde7f349e048a1959085419b4ad240 100644 (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
index 1053955ea23397654a33b904b7a8742e1dc26087..25786c786376de82bdbac5cf879169143623fa81 100644 (file)
@@ -111,9 +111,8 @@ namespace {
 }
 
 char AliasAnalysisCounter::ID = 0;
-static RegisterPass<AliasAnalysisCounter>
-X("count-aa", "Count Alias Analysis Query Responses", false, true);
-static RegisterAnalysisGroup<AliasAnalysis> Y(X);
+INITIALIZE_AG_PASS(AliasAnalysisCounter, AliasAnalysis, "count-aa",
+                   "Count Alias Analysis Query Responses", false, true, false);
 
 ModulePass *llvm::createAliasAnalysisCounterPass() {
   return new AliasAnalysisCounter();
index bc2d9c55d18376812d3a8ced6143ea3edfc6ba38..79bc99e2006720f0f7daac484f6867ee3429be8f 100644 (file)
@@ -126,9 +126,8 @@ namespace {
 }
 
 char AliasDebugger::ID = 0;
-static RegisterPass<AliasDebugger>
-X("debug-aa", "AA use debugger", false, true);
-static RegisterAnalysisGroup<AliasAnalysis> Y(X);
+INITIALIZE_AG_PASS(AliasDebugger, AliasAnalysis, "debug-aa",
+                   "AA use debugger", false, true, false);
 
 Pass *llvm::createAliasDebugger() { return new AliasDebugger(); }
 
index 4f53a6d62559bea022d1ae547c1530481f759ec4..b025ec623c3d5b93c80dbda29e5416d4cd55b215 100644 (file)
@@ -182,11 +182,9 @@ namespace {
 
 // Register this pass...
 char NoAA::ID = 0;
-static RegisterPass<NoAA>
-U("no-aa", "No Alias Analysis (always returns 'may' alias)", true, true);
-
-// Declare that we implement the AliasAnalysis interface
-static RegisterAnalysisGroup<AliasAnalysis> V(U);
+INITIALIZE_AG_PASS(NoAA, AliasAnalysis, "no-aa",
+                   "No Alias Analysis (always returns 'may' alias)",
+                   true, true, false);
 
 ImmutablePass *llvm::createNoAAPass() { return new NoAA(); }
 
@@ -275,11 +273,9 @@ namespace {
 
 // Register this pass...
 char BasicAliasAnalysis::ID = 0;
-static RegisterPass<BasicAliasAnalysis>
-X("basicaa", "Basic Alias Analysis (default AA impl)", false, true);
-
-// Declare that we implement the AliasAnalysis interface
-static RegisterAnalysisGroup<AliasAnalysis, true> Y(X);
+INITIALIZE_AG_PASS(BasicAliasAnalysis, AliasAnalysis, "basicaa",
+                   "Basic Alias Analysis (default AA impl)",
+                   false, true, true);
 
 ImmutablePass *llvm::createBasicAliasAnalysisPass() {
   return new BasicAliasAnalysis();
index c16f3286df2c48c802bac23f57536a5ecbb61de9..da2f0a6dbf0c31917b78133476d10e188339f061 100644 (file)
@@ -62,9 +62,8 @@ namespace {
 }
 
 char CFGOnlyViewer::ID = 0;
-static RegisterPass<CFGOnlyViewer>
-V1("view-cfg-only",
-   "View CFG of function (with no function bodies)", false, true);
+INITIALIZE_PASS(CFGOnlyViewer, "view-cfg-only",
+                "View CFG of function (with no function bodies)", false, true);
 
 namespace {
   struct CFGPrinter : public FunctionPass {
index 65c7c6efd8027e74ee5931d13c72eebf1aceba86..0e474e66682987a2d590143058842f499f9e5640 100644 (file)
@@ -172,9 +172,8 @@ private:
 } //End anonymous namespace
 
 static RegisterAnalysisGroup<CallGraph> X("Call Graph");
-static RegisterPass<BasicCallGraph>
-Y("basiccg", "Basic CallGraph Construction", false, true);
-static RegisterAnalysisGroup<CallGraph, true> Z(Y);
+INITIALIZE_AG_PASS(BasicCallGraph, CallGraph, "basiccg",
+                   "Basic CallGraph Construction", false, true, true);
 
 char CallGraph::ID = 0;
 char BasicCallGraph::ID = 0;
index c4fb0b9a4e3ddc8fee591159df4ed6ebe93d9012..8eed9d6f68bc59908a547cb1f15b2b2621c1571e 100644 (file)
@@ -23,8 +23,8 @@
 using namespace llvm;
 
 char FindUsedTypes::ID = 0;
-static RegisterPass<FindUsedTypes>
-X("print-used-types", "Find Used Types", false, true);
+INITIALIZE_PASS(FindUsedTypes, "print-used-types",
+                "Find Used Types", false, true);
 
 // IncorporateType - Incorporate one type and all of its subtypes into the
 // collection of used types.
index 74196592989025b784f4602ca12adc62e8f4db1c..9dca93f9e7607d62e0401e7822f3fa2a41ed7136 100644 (file)
@@ -20,11 +20,8 @@ using namespace llvm;
   
 // Register this pass...
 char LibCallAliasAnalysis::ID = 0;
-static RegisterPass<LibCallAliasAnalysis>
-X("libcall-aa", "LibCall Alias Analysis", false, true);
-  
-// Declare that we implement the AliasAnalysis interface
-static RegisterAnalysisGroup<AliasAnalysis> Y(X);
+INITIALIZE_AG_PASS(LibCallAliasAnalysis, AliasAnalysis, "libcall-aa",
+                   "LibCall Alias Analysis", false, true, false);
 
 FunctionPass *llvm::createLibCallAliasAnalysisPass(LibCallInfo *LCI) {
   return new LibCallAliasAnalysis(LCI);
index 51eb14525802496689bdf077ea870b3de23b85b8..cbe8d1867e4f1d3e91a4401e00aadda75b23128f 100644 (file)
@@ -53,8 +53,8 @@ FunctionPass* llvm::createPostDomTree() {
 //  PostDominanceFrontier Implementation
 //===----------------------------------------------------------------------===//
 
-static RegisterPass<PostDominanceFrontier>
-H("postdomfrontier", "Post-Dominance Frontier Construction", true, true);
+INITIALIZE_PASS(PostDominanceFrontier, "postdomfrontier",
+                "Post-Dominance Frontier Construction", true, true);
 
 const DominanceFrontier::DomSetType &
 PostDominanceFrontier::calculate(const PostDominatorTree &DT,
index 8d2712fd6e063e7ccfdd893699536e03d1eb557e..eb33e78af7800417238f477728a017c3147fc9b7 100644 (file)
@@ -1096,10 +1096,7 @@ namespace {
 
 char NoProfileInfo::ID = 0;
 // Register this pass...
-static RegisterPass<NoProfileInfo>
-X("no-profile", "No Profile Information", false, true);
-
-// Declare that we implement the ProfileInfo interface
-static RegisterAnalysisGroup<ProfileInfo, true> Y(X);
+INITIALIZE_AG_PASS(NoProfileInfo, ProfileInfo, "no-profile",
+                   "No Profile Information", false, true, true);
 
 ImmutablePass *llvm::createNoProfileInfoPass() { return new NoProfileInfo(); }
index 58711b8be59e8bb38659753133faa70400771890..b3d90cb5c12b0c17921a8ee4fa3f2d97a0b6eed1 100644 (file)
@@ -58,11 +58,8 @@ namespace {
 
 // Register this pass...
 char ScalarEvolutionAliasAnalysis::ID = 0;
-static RegisterPass<ScalarEvolutionAliasAnalysis>
-X("scev-aa", "ScalarEvolution-based Alias Analysis", false, true);
-
-// Declare that we implement the AliasAnalysis interface
-static RegisterAnalysisGroup<AliasAnalysis> Y(X);
+INITIALIZE_AG_PASS(ScalarEvolutionAliasAnalysis, AliasAnalysis, "scev-aa",
+                   "ScalarEvolution-based Alias Analysis", false, true, false);
 
 FunctionPass *llvm::createScalarEvolutionAliasAnalysisPass() {
   return new ScalarEvolutionAliasAnalysis();