X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FWritingAnLLVMPass.html;h=dc70d036c8aeb98edb2fb2cc32673918b458a2e4;hb=fc592231941dadb60cc419613adbd41a0b48b321;hp=d1cf63cae8f5baae4f9429ff59286b81c8c343da;hpb=480e2efb2e3638cd202551ed53fb456d6179d5e0;p=oota-llvm.git diff --git a/docs/WritingAnLLVMPass.html b/docs/WritingAnLLVMPass.html index d1cf63cae8f..dc70d036c8a 100644 --- a/docs/WritingAnLLVMPass.html +++ b/docs/WritingAnLLVMPass.html @@ -19,19 +19,32 @@
  • Pass classes and requirements
  • Pass Registration @@ -125,9 +138,7 @@ First thing you need to do is create a new directory somewhere in the LLVM source base. For this example, we'll assume that you made "lib/Transforms/Hello". The first thing you must do is set up a build script (Makefile) that will compile the source code for the new pass. To do -this, copy this into "Makefile" (be very careful that there are no -extra space characters at the end of the lines though... that seems to confuse -gmake):

    +this, copy this into "Makefile":


    +
       + +The ImmutablePass class +
    @@ -404,7 +436,7 @@ In contrast to direct Pass subclasses, direct FunctionPass subclasses do have a predictable, local behavior that can be expected by the system. All FunctionPass execute on each function in the program -independant of all of the other functions in the program. +independent of all of the other functions in the program. FunctionPass's do not require that they are executed in a particular order, and FunctionPass's do not modify external functions.

    @@ -424,8 +456,8 @@ may overload three virtual methods to do their work. All of these methods should return true if they modified the program, or false if they didn't.

    -


    The doInitialization -method


    The +doInitialization(Module &) method

    +
       + +The MachineFunctionPass class +


    The +runOnMachineFunction(MachineFunction &MF) method

    @@ -635,14 +747,14 @@ href="http://llvm.cs.uiuc.edu/doxygen/classAnalysisUsage.html">AnalysisUsage // setPreservesAll - Call this if the pass does not modify its input at all void AnalysisUsage::setPreservesAll(); - // preservesCFG - This function should be called by the pass, iff they do not: + // setPreservesCFG - This function should be called by the pass, iff they do not: // // 1. Add or remove basic blocks from the function // 2. Modify terminator instructions in any way. // // This is automatically implied for BasicBlockPass's // - void AnalysisUsage::preservesCFG(); + void AnalysisUsage::setPreservesCFG();

    Some examples of how to use these methods are:

    @@ -661,7 +773,7 @@ and:

       // This example modifies the program, but does not modify the CFG
       void LICM::getAnalysisUsage(AnalysisUsage &AU) const {
    -    AU.preservesCFG();
    +    AU.setPreservesCFG();
         AU.addRequired<LoopInfo>();
       }
     

    @@ -1047,9 +1159,8 @@ want:

     (gdb) break PassManager::run
     Breakpoint 1 at 0x2413bc: file Pass.cpp, line 70.
    -(gdb) run test.bc -load /shared/lattner/cvs/llvm/lib/Debug/[libname].so -[passoption]
    -Starting program: /shared/lattner/cvs/llvm/tools/Debug/opt test.bc 
    -    -load /shared/lattner/cvs/llvm/lib/Debug/[libname].so -[passoption]
    +(gdb) run test.bc -load $(LLVMTOP)/llvm/lib/Debug/[libname].so -[passoption]
    +Starting program: opt test.bc -load $(LLVMTOP)/llvm/lib/Debug/[libname].so -[passoption]
     Breakpoint 1, PassManager::run (this=0xffbef174, M=@0x70b298) at Pass.cpp:70
     70      bool PassManager::run(Module &M) { return PM->run(M); }
     (gdb)
    @@ -1102,12 +1213,12 @@ where we are going:


    Multithreaded LLVM