From 05fe4b02561f4431626a73ac2900be523e233cd6 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Tue, 14 Mar 2006 05:39:39 +0000 Subject: Changes docs for llvm.cs.uiuc.edu -> llvm.org git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26746 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/WritingAnLLVMPass.html | 68 ++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'docs/WritingAnLLVMPass.html') diff --git a/docs/WritingAnLLVMPass.html b/docs/WritingAnLLVMPass.html index 46c07d6bad..0ca54994f5 100644 --- a/docs/WritingAnLLVMPass.html +++ b/docs/WritingAnLLVMPass.html @@ -115,7 +115,7 @@ build the analysis results that are used by these transformations, and they are, above all, a structuring technique for compiler code.

All LLVM passes are subclasses of the Pass +href="http://llvm.org/doxygen/classllvm_1_1Pass.html">Pass class, which implement functionality by overriding virtual methods inherited from Pass. Depending on how your pass works, you should inherit from the ModulePass, Start out with:

-#include "llvm/Pass.h"
-#include "llvm/Function.h"
+#include "llvm/Pass.h"
+#include "llvm/Function.h"
 

Which are needed because we are writing a Pass, and +href="http://llvm.org/doxygen/classllvm_1_1Pass.html">Pass, and we are operating on Function's.

+href="http://llvm.org/doxygen/classllvm_1_1Function.html">Function's.

Next we have:

@@ -242,7 +242,7 @@ information.

This declares a "Hello" class that is a subclass of FunctionPass. +href="http://llvm.org/doxygen/classllvm_1_1FunctionPass.html">FunctionPass. The different builtin pass subclasses are described in detail later, but for now, know that FunctionPass's operate a function at a @@ -276,8 +276,8 @@ depending on what it is to be used for. For "optimizations" we use the

As a whole, the .cpp file looks like:

-#include "llvm/Pass.h"
-#include "llvm/Function.h"
+#include "llvm/Pass.h"
+#include "llvm/Function.h"
 
 using namespace llvm;
 
@@ -424,7 +424,7 @@ slow.

The most plain and boring type of pass is the "ImmutablePass" +href="http://llvm.org/doxygen/classllvm_1_1ImmutablePass.html">ImmutablePass" class. This pass type is used for passes that do not have to be run, do not change state, and never need to be updated. This is not a normal type of transformation or analysis, but can provide information about the current @@ -447,7 +447,7 @@ invalidated, and are never "run".

The "ModulePass" +href="http://llvm.org/doxygen/classllvm_1_1ModulePass.html">ModulePass" class is the most general of all superclasses that you can use. Deriving from ModulePass indicates that your pass uses the entire program as a unit, refering to function bodies in no predictable order, or adding and removing @@ -485,7 +485,7 @@ false otherwise.

The "CallGraphSCCPass" +href="http://llvm.org/doxygen/classllvm_1_1CallGraphSCCPass.html">CallGraphSCCPass" is used by passes that need to traverse the program bottom-up on the call graph (callees before callers). Deriving from CallGraphSCCPass provides some mechanics for building and traversing the CallGraph, but also allows the system @@ -593,7 +593,7 @@ program being compiled.

In contrast to ModulePass subclasses, FunctionPass +href="http://llvm.org/doxygen/classllvm_1_1Pass.html">FunctionPass subclasses do have a predictable, local behavior that can be expected by the system. All FunctionPass execute on each function in the program independent of all of the other functions in the program. @@ -638,7 +638,7 @@ scheduled to overlap with any other pass executions (thus it should be very fast).

A good example of how this method should be used is the LowerAllocations +href="http://llvm.org/doxygen/LowerAllocations_8cpp-source.html">LowerAllocations pass. This pass converts malloc and free instructions into platform dependent malloc() and free() function calls. It uses the doInitialization method to get a reference to the malloc and @@ -853,7 +853,7 @@ registering a pass that logically should be available for use in the Register* templates that should be used if you want your pass listed by multiple or no utilities. This template takes an extra third argument that specifies which tools it should be listed in. See the PassSupport.h +href="http://llvm.org/doxygen/PassSupport_8h-source.html">PassSupport.h file for more information. @@ -934,7 +934,7 @@ having any prerequisite passes, and invalidating all other passes.

By implementing the getAnalysisUsage method, the required and invalidated sets may be specified for your transformation. The implementation should fill in the AnalysisUsage +href="http://llvm.org/doxygen/classllvm_1_1AnalysisUsage.html">AnalysisUsage object with information about which passes are required and not invalidated. To do this, a pass may call any of the following methods on the AnalysisUsage object:

@@ -1011,9 +1011,9 @@ the fact that it hacks on the CFG.
   // This is an example implementation from an analysis, which does not modify
   // the program at all, yet has a prerequisite.
-  void PostDominanceFrontier::getAnalysisUsage(AnalysisUsage &AU) const {
+  void PostDominanceFrontier::getAnalysisUsage(AnalysisUsage &AU) const {
     AU.setPreservesAll();
-    AU.addRequired<PostDominatorTree>();
+    AU.addRequired<PostDominatorTree>();
   }
 
@@ -1021,9 +1021,9 @@ the fact that it hacks on the CFG.
   // This example modifies the program, but does not modify the CFG
-  void LICM::getAnalysisUsage(AnalysisUsage &AU) const {
+  void LICM::getAnalysisUsage(AnalysisUsage &AU) const {
     AU.setPreservesCFG();
-    AU.addRequired<LoopInfo>();
+    AU.addRequired<LoopInfo>();
   }
 
@@ -1128,16 +1128,16 @@ implementation pool. Also, a default implementation of the interface href="#registerag">RegisterAnalysisGroup.

As a concrete example of an Analysis Group in action, consider the AliasAnalysis +href="http://llvm.org/doxygen/classllvm_1_1AliasAnalysis.html">AliasAnalysis analysis group. The default implementation of the alias analysis interface (the basicaa +href="http://llvm.org/doxygen/structBasicAliasAnalysis.html">basicaa pass) just does a few simple checks that don't require significant analysis to compute (such as: two different globals can never alias each other, etc). Passes that use the AliasAnalysis +href="http://llvm.org/doxygen/classllvm_1_1AliasAnalysis.html">AliasAnalysis interface (for example the gcse pass), do +href="http://llvm.org/doxygen/structGCSE.html">gcse pass), do not care which implementation of alias analysis is actually provided, they just use the designated interface.

@@ -1164,7 +1164,7 @@ Unlike registration of passes, there is no command line argument to be specified for the Analysis Group Interface itself, because it is "abstract":

-  static RegisterAnalysisGroup<AliasAnalysis> A("Alias Analysis");
+  static RegisterAnalysisGroup<AliasAnalysis> A("Alias Analysis");
 

Once the analysis is registered, passes can declare that they are valid @@ -1177,13 +1177,13 @@ implementations of the interface by using the following code:

B("somefancyaa", "A more complex alias analysis implementation"); // Declare that we implement the AliasAnalysis interface - RegisterAnalysisGroup<AliasAnalysis, FancyAA> C; + RegisterAnalysisGroup<AliasAnalysis, FancyAA> C; }

This just shows a class FancyAA that is registered normally, then uses the RegisterAnalysisGroup template to "join" the AliasAnalysis +href="http://llvm.org/doxygen/classllvm_1_1AliasAnalysis.html">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.

@@ -1191,11 +1191,11 @@ no problem.

 namespace {
   // Analysis Group implementations must be registered normally...
-  RegisterOpt<BasicAliasAnalysis>
+  RegisterOpt<BasicAliasAnalysis>
   D("basicaa", "Basic Alias Analysis (default AA impl)");
 
   // Declare that we implement the AliasAnalysis interface
-  RegisterAnalysisGroup<AliasAnalysis, BasicAliasAnalysis, true> E;
+  RegisterAnalysisGroup<AliasAnalysis, BasicAliasAnalysis, true> E;
 }
 
@@ -1203,7 +1203,7 @@ no problem.

argument to the RegisterAnalysisGroup template). There must be exactly one default implementation available at all times for an Analysis Group to be used. Here we declare that the BasicAliasAnalysis +href="http://llvm.org/doxygen/structBasicAliasAnalysis.html">BasicAliasAnalysis pass is the default implementation for the interface.

@@ -1216,7 +1216,7 @@ pass is the default implementation for the interface.

The Statistic +href="http://llvm.org/doxygen/Statistic_8h-source.html">Statistic class is designed to be an easy way to expose various success metrics from passes. These statistics are printed at the end of a run, when the -stats command line option is enabled on the command @@ -1234,9 +1234,9 @@ line. See the St

The PassManager +href="http://llvm.org/doxygen/PassManager_8h-source.html">PassManager class +href="http://llvm.org/doxygen/classllvm_1_1PassManager.html">class takes a list of passes, ensures their prerequisites are set up correctly, and then schedules passes to run efficiently. All of the LLVM tools that run passes use the PassManager for execution of these @@ -1267,7 +1267,7 @@ etc... until the entire program has been run through the passes. the LLVM program representation for a single function at a time, instead of traversing the entire program. It reduces the memory consumption of compiler, because, for example, only one DominatorSet +href="http://llvm.org/doxygen/classllvm_1_1DominatorSet.html">DominatorSet needs to be calculated at a time. This also makes it possible some interesting enhancements in the future.

@@ -1592,7 +1592,7 @@ href="#ModulePass">ModulePass, only the other way around.

src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> Chris Lattner
- The LLVM Compiler Infrastructure
+ The LLVM Compiler Infrastructure
Last modified: $Date$ -- cgit v1.2.3