X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FStacker.html;h=04b796b1122121f37205b02f747dc9d2797f0712;hb=004e19e38d810c3146c77b68a9274210ee008b1d;hp=41b77fe55fc20ea919b37017a2fa58760aa31e0c;hpb=fd90f88b586a9a1a7d36a38b69b1f3d51dd9217b;p=oota-llvm.git diff --git a/docs/Stacker.html b/docs/Stacker.html index 41b77fe55fc..04b796b1122 100644 --- a/docs/Stacker.html +++ b/docs/Stacker.html @@ -4,10 +4,6 @@ Stacker: An Example Of Using LLVM - @@ -33,7 +29,7 @@
  • Comments
  • Literals
  • Words
  • -
  • Standard Style
  • +
  • Standard Style
  • Built-Ins
  • Prime: A Complete Example
  • @@ -51,8 +47,8 @@ -
    -

    Written by Reid Spencer

    +
    +

    Written by Reid Spencer

    @@ -131,31 +127,28 @@ I noted that most of the important LLVM IR (Intermediate Representation) C++ classes were derived from the Value class. The full power of that simple design only became fully understood once I started constructing executable expressions for Stacker.

    +

    This really makes your programming go faster. Think about compiling code for the following C/C++ expression: (a|b)*((x+1)/(y+1)). Assuming the values are on the stack in the order a, b, x, y, this could be expressed in stacker as: 1 + SWAP 1 + / ROT2 OR *. -You could write a function using LLVM that computes this expression like this:

    -
    
    +You could write a function using LLVM that computes this expression like 
    +this: 

    + +
     Value* 
     expression(BasicBlock* bb, Value* a, Value* b, Value* x, Value* y )
     {
    -    Instruction* tail = bb->getTerminator();
    -    ConstantSInt* one = ConstantSInt::get( Type::IntTy, 1);
    -    BinaryOperator* or1 = 
    -	BinaryOperator::create( Instruction::Or, a, b, "", tail );
    -    BinaryOperator* add1 = 
    -	BinaryOperator::create( Instruction::Add, x, one, "", tail );
    -    BinaryOperator* add2 =
    -	BinaryOperator::create( Instruction::Add, y, one, "", tail );
    -    BinaryOperator* div1 = 
    -	BinaryOperator::create( Instruction::Div, add1, add2, "", tail);
    -    BinaryOperator* mult1 = 
    -	BinaryOperator::create( Instruction::Mul, or1, div1, "", tail );
    -
    +    ConstantSInt* one = ConstantSInt::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);
    +    BinaryOperator* div1 = BinaryOperator::createDiv(add1, add2, "", bb);
    +    BinaryOperator* mult1 = BinaryOperator::createMul(or1, div1, "", bb);
         return mult1;
     }
    -
    +
    +

    "Okay, big deal," you say? It is a big deal. Here's why. Note that I didn't have to tell this function which kinds of Values are being passed in. They could be Instructions, Constants, GlobalVariables, or @@ -470,6 +463,11 @@ unit. Anything declared with FORWARD is an external symbol for linking.

    +
    Standard Style
    +
    +

    TODO

    +
    +
    Built In Words

    The built-in words of the Stacker language are put in several groups @@ -513,16 +511,16 @@ using the following construction:

    - - - - +
    Definition Of Operation Of Built In Words
    LOGICAL OPERATIONS
    + + + - + @@ -579,7 +577,7 @@ using the following construction:

    - + @@ -621,7 +619,7 @@ using the following construction:

    are bitwise exclusive OR'd together and pushed back on the stack. For example, The sequence 1 3 XOR yields 2. - + @@ -702,7 +700,7 @@ using the following construction:

    - + @@ -847,7 +845,7 @@ using the following construction:

    how much to rotate. That is, ROLL with n=1 is the same as ROT and ROLL with n=2 is the same as ROT2. - + @@ -900,7 +898,7 @@ using the following construction:

    pushed back on the stack so this doesn't count as a "use ptr" in the FREE idiom. - + @@ -967,7 +965,7 @@ using the following construction:

    the top of stack is decremented to 0 at which the WHILE test fails and control is transfered to the word after the END. - + @@ -1374,16 +1372,9 @@ interested, here are some things that could be implemented better:

  • Write an LLVM pass to compute the correct stack depth needed by the program. Currently the stack is set to a fixed number which means programs with large numbers of definitions might fail.
  • -
  • Enhance to run on 64-bit platforms like SPARC. Right now the size of a - pointer on 64-bit machines will cause incorrect results because of the - 32-bit size of a stack element currently supported. This feature was not - implemented because LLVM needs a union type to be able to support the - different sizes correctly (portably and efficiently).
  • Write an LLVM pass to optimize the use of the global stack. The code emitted currently is somewhat wasteful. It gets cleaned up a lot by existing passes but more could be done.
  • -
  • Add -O -O1 -O2 and -O3 optimization switches to the compiler driver to - allow LLVM optimization without using "opt."
  • Make the compiler driver use the LLVM linking facilities (with IPO) before depending on GCC to do the final link.
  • Clean up parsing. It doesn't handle errors very well.
  • Definition Of Operation Of Built In Words
    LOGICAL OPERATIONS
    Word Name Operation Description
    < LT w1 w2 -- b -- b The boolean value TRUE (-1) is pushed on to the stack.
    BITWISE OPERATORS
    BITWISE OPERATORS
    Word Name
    ARITHMETIC OPERATORS
    ARITHMETIC OPERATORS
    Word Name Two values are popped off the stack. The larger value is pushed back on to the stack.
    STACK MANIPULATION OPERATORS
    STACK MANIPULATION OPERATORS
    Word Name
    MEMORY OPERATORS
    MEMORY OPERATORS
    Word Name
    CONTROL FLOW OPERATORS
    CONTROL FLOW OPERATORS
    Word Name
    INPUT & OUTPUT OPERATORS
    INPUT & OUTPUT OPERATORS
    Word Name