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 @@
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
Instruction
s, Constant
s, GlobalVariable
s, or
@@ -470,6 +463,11 @@ unit. Anything declared with FORWARD
is an external symbol for
linking.
TODO
+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 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Definition Of Operation Of Built In Words | ||||
---|---|---|---|---|
LOGICAL OPERATIONS | ||||
Word | Name | Operation | Description | |
< | LT | w1 w2 -- b | @@ -579,7 +577,7 @@ using the following construction:-- b | The boolean value TRUE (-1) is pushed on to the stack. |
BITWISE OPERATORS | ||||
BITWISE OPERATORS | ||||
Word | Name | @@ -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.|||
ARITHMETIC OPERATORS | ||||
ARITHMETIC OPERATORS | ||||
Word | Name | @@ -702,7 +700,7 @@ using the following construction: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 | @@ -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.|||
MEMORY OPERATORS | ||||
MEMORY OPERATORS | ||||
Word | Name | @@ -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.|||
CONTROL FLOW OPERATORS | ||||
CONTROL FLOW OPERATORS | ||||
Word | Name | @@ -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.|||
INPUT & OUTPUT OPERATORS | ||||
INPUT & OUTPUT OPERATORS | ||||
Word | Name | @@ -1374,16 +1372,9 @@ interested, here are some things that could be implemented better: