X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FWritingAnLLVMPass.html;h=a1d55649016c7e35145867c6034e910b84bc3726;hb=a75ce9f5d2236d93c117e861e60e6f3f748c9555;hp=f6360a19c3247946334861b8efc71d1ae2bbb86b;hpb=20813e01e76e71c0400165b7fb8b2e412d18c0a2;p=oota-llvm.git diff --git a/docs/WritingAnLLVMPass.html b/docs/WritingAnLLVMPass.html index f6360a19c32..a1d55649016 100644 --- a/docs/WritingAnLLVMPass.html +++ b/docs/WritingAnLLVMPass.html @@ -51,6 +51,14 @@
RegionPass is similar to LoopPass, +but executes on each single entry single exit region in the function. +RegionPass processes regions in nested order such that the outer most +region is processed last.
+ +RegionPass subclasses are allowed to update the region tree by using +the RGPassManager interface. You may overload three virtual methods of +RegionPass to implementing your own region pass is usually. All these +methods should return true if they modified the program, or false if they didn not. +
++ virtual bool doInitialization(Region *, RGPassManager &RGM); +
The doInitialization method is designed to do simple initialization +type of stuff that does not depend on the functions being processed. The +doInitialization method call is not scheduled to overlap with any +other pass executions (thus it should be very fast). RPPassManager +interface should be used to access Function or Module level analysis +information.
+ ++ virtual bool runOnRegion(Region *, RGPassManager &RGM) = 0; +
+ +
The runOnRegion method must be implemented by your subclass to do +the transformation or analysis work of your pass. As usual, a true value should +be returned if the region is modified. RGPassManager interface +should be used to update region tree.
+ ++ virtual bool doFinalization(); +
The doFinalization method is an infrequently used method that is +called when the pass framework has finished calling runOnRegion for every region in the +program being compiled.
+ +Although Pass Registration is optional for normal passes, all analysis group implementations must be registered, and must use the -RegisterAnalysisGroup template to join the +INITIALIZE_AG_PASS template to join the implementation pool. Also, a default implementation of the interface must be registered with RegisterAnalysisGroup.
@@ -1283,8 +1370,10 @@ hypothetical example) instead.The RegisterAnalysisGroup 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 INITIALIZE_AG_PASS 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":
@@ -1297,35 +1386,36 @@ implementations of the interface by using the following code:namespace { - // Analysis Group implementations must be registered normally... - RegisterPass<FancyAA> - B("somefancyaa", "A more complex alias analysis implementation"); - // Declare that we implement the AliasAnalysis interface - RegisterAnalysisGroup<AliasAnalysis> C(B); + INITIALIZE_AG_PASS(FancyAA, AliasAnalysis, "somefancyaa", + "A more complex alias analysis implementation", + false, // Is CFG Only? + true, // Is Analysis? + false, // Is default Analysis Group implementation? + ); }
This just shows a class FancyAA that is registered normally, then -uses the RegisterAnalysisGroup template to "join" the AliasAnalysis +
This just shows a class FancyAA that +uses the INITIALIZE_AG_PASS macro both to register and +to "join" the AliasAnalysis 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.
+this macro.namespace { - // Analysis Group implementations must be registered normally... - RegisterPass<BasicAliasAnalysis> - D("basicaa", "Basic Alias Analysis (default AA impl)"); - // Declare that we implement the AliasAnalysis interface - RegisterAnalysisGroup<AliasAnalysis, true> E(D); + INITIALIZE_AG_PASS(BasicAA, AliasAnalysis, "basicaa", + "Basic Alias Analysis (default AA impl)", + false, // Is CFG Only? + true, // Is Analysis? + true, // Is default Analysis Group implementation? + ); }
Here we show how the default implementation is specified (using the extra -argument to the RegisterAnalysisGroup template). There must be exactly +
Here we show how the default implementation is specified (using the final +argument to the INITIALIZE_AG_PASS 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 ImmutablePass. Here we declare that the