X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FStacker.html;h=81b623efa9a15eca20c51a6d4b78b7f755147b7c;hb=0f4012f4759a6c6ca28f11ed1eb98feb8ab1481b;hp=bdd41bbfe59d10e45bdeb43de8c17bf959bdeedf;hpb=68fb553332f582f5f910fd346e0dd4de80346d67;p=oota-llvm.git diff --git a/docs/Stacker.html b/docs/Stacker.html index bdd41bbfe59..81b623efa9a 100644 --- a/docs/Stacker.html +++ b/docs/Stacker.html @@ -139,7 +139,7 @@ this:

Value* expression(BasicBlock* bb, Value* a, Value* b, Value* x, Value* y ) { - ConstantSInt* one = ConstantSInt::get(Type::IntTy, 1); + ConstantInt* one = ConstantInt::get(Type::IntTy, 1); BinaryOperator* or1 = BinaryOperator::createOr(a, b, "", bb); BinaryOperator* add1 = BinaryOperator::createAdd(x, one, "", bb); BinaryOperator* add2 = BinaryOperator::createAdd(y, one, "", bb); @@ -198,7 +198,7 @@ should be constructed. In general, here's what I learned:
  • Create your blocks early. While writing your compiler, you will encounter several situations where you know apriori that you will need several blocks. For example, if-then-else, switch, while, and for - statements in C/C++ all need multiple blocks for expression in LVVM. + statements in C/C++ all need multiple blocks for expression in LLVM. The rule is, create them early.
  • Terminate your blocks early. This just reduces the chances that you forget to terminate your blocks which is required (go @@ -219,8 +219,8 @@ should be constructed. In general, here's what I learned:

    The foregoing is such an important principal, its worth making an idiom:

    -BasicBlock* bb = new BasicBlock();
    -bb->getInstList().push_back( new Branch( ... ) );
    +BasicBlock* bb = BasicBlock::Create();
    +bb->getInstList().push_back( BranchInst::Create( ... ) );
     new Instruction(..., bb->getTerminator() );
     

    To make this clear, consider the typical if-then-else statement @@ -229,19 +229,19 @@ in a single function using LLVM in the following way:

     using namespace llvm;
     BasicBlock*
    -MyCompiler::handle_if( BasicBlock* bb, SetCondInst* condition )
    +MyCompiler::handle_if( BasicBlock* bb, ICmpInst* condition )
     {
         // Create the blocks to contain code in the structure of if/then/else
    -    BasicBlock* then_bb = new BasicBlock(); 
    -    BasicBlock* else_bb = new BasicBlock();
    -    BasicBlock* exit_bb = new BasicBlock();
    +    BasicBlock* then_bb = BasicBlock::Create(); 
    +    BasicBlock* else_bb = BasicBlock::Create();
    +    BasicBlock* exit_bb = BasicBlock::Create();
     
         // Insert the branch instruction for the "if"
    -    bb->getInstList().push_back( new BranchInst( then_bb, else_bb, condition ) );
    +    bb->getInstList().push_back( BranchInst::Create( then_bb, else_bb, condition ) );
     
         // Set up the terminating instructions
    -    then->getInstList().push_back( new BranchInst( exit_bb ) );
    -    else->getInstList().push_back( new BranchInst( exit_bb ) );
    +    then->getInstList().push_back( BranchInst::Create( exit_bb ) );
    +    else->getInstList().push_back( BranchInst::Create( exit_bb ) );
     
         // Fill in the then part .. details excised for brevity
         this->fill_in( then_bb );
    @@ -308,9 +308,9 @@ things, this leads to the idiom:
     

     std::vector<Value*> index_vector;
    -index_vector.push_back( ConstantSInt::get( Type::LongTy, 0 );
    +index_vector.push_back( ConstantInt::get( Type::LongTy, 0 );
     // ... push other indices ...
    -GetElementPtrInst* gep = new GetElementPtrInst( ptr, index_vector );
    +GetElementPtrInst* gep = GetElementPtrInst::Create( ptr, index_vector );
     

    For example, suppose we have a global variable whose type is [24 x int]. The variable itself represents a pointer to that array. To subscript the @@ -367,9 +367,9 @@ functions in the LLVM IR that make things easier. Here's what I learned:

    @@ -1296,13 +1296,26 @@ remainder of the story. +

    The source code, test programs, and sample programs can all be found -under the LLVM "projects" directory. You will need to obtain the LLVM sources -to find it (either via anonymous CVS or a tarball. See the -Getting Started document).

    -

    Under the "projects" directory there is a directory named "Stacker". That -directory contains everything, as follows:

    +in the LLVM repository named llvm-stacker This should be checked out to +the projects directory so that it will auto-configure. To do that, make +sure you have the llvm sources in llvm +(see Getting Started) and then use these +commands:

    + +
    +
    +% svn co http://llvm.org/svn/llvm-project/llvm-top/trunk llvm-top
    +% cd llvm-top
    +% make build MODULE=stacker
    +
    +
    + +

    Under the projects/llvm-stacker directory you will find the +implementation of the Stacker compiler, as follows:

    +
    • lib - contains most of the source code
        @@ -1317,35 +1330,38 @@ directory contains everything, as follows:

      • sample - contains the sample programs
    +
    The Lexer
    +
    -

    See projects/Stacker/lib/compiler/Lexer.l

    +

    See projects/llvm-stacker/lib/compiler/Lexer.l

    +
    The Parser
    -

    See projects/Stacker/lib/compiler/StackerParser.y

    +

    See projects/llvm-stacker/lib/compiler/StackerParser.y

    The Compiler
    -

    See projects/Stacker/lib/compiler/StackerCompiler.cpp

    +

    See projects/llvm-stacker/lib/compiler/StackerCompiler.cpp

    The Runtime
    -

    See projects/Stacker/lib/runtime/stacker_rt.c

    +

    See projects/llvm-stacker/lib/runtime/stacker_rt.c

    Compiler Driver
    -

    See projects/Stacker/tools/stkrc/stkrc.cpp

    +

    See projects/llvm-stacker/tools/stkrc/stkrc.cpp

    Test Programs
    -

    See projects/Stacker/test/*.st

    +

    See projects/llvm-stacker/test/*.st

    @@ -1404,7 +1420,7 @@ interested, here are some things that could be implemented better:

    src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"> Reid Spencer
    - LLVM Compiler Infrastructure
    + LLVM Compiler Infrastructure
    Last modified: $Date$