[llvm-commits] CVS: llvm/docs/Stacker.html

Chris Lattner lattner at cs.uiuc.edu
Mon Aug 2 17:17:31 PDT 2004



Changes in directory llvm/docs:

Stacker.html updated: 1.15 -> 1.16

---
Log message:

Simplify the first example, as the LLVM IR interfaces have evolved.  Other
examples in this doc could also be simplified dramatically in similar ways.


---
Diffs of the changes:  (+14 -17)

Index: llvm/docs/Stacker.html
diff -u llvm/docs/Stacker.html:1.15 llvm/docs/Stacker.html:1.16
--- llvm/docs/Stacker.html:1.15	Thu Jun  3 18:47:34 2004
+++ llvm/docs/Stacker.html	Mon Aug  2 19:17:21 2004
@@ -131,31 +131,28 @@
 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.</p>
+
 <p>This really makes your programming go faster. Think about compiling code
 for the following C/C++ expression: <code>(a|b)*((x+1)/(y+1))</code>. Assuming
 the values are on the stack in the order a, b, x, y, this could be
 expressed in stacker as: <code>1 + SWAP 1 + / ROT2 OR *</code>.
-You could write a function using LLVM that computes this expression like this: </p>
-<pre><code>
+You could write a function using LLVM that computes this expression like 
+this: </p>
+
+<div class="doc_code"><pre>
 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;
 }
-</code></pre>
+</pre></div>
+
 <p>"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
 <code>Instruction</code>s, <code>Constant</code>s, <code>GlobalVariable</code>s, or
@@ -1410,7 +1407,7 @@
 
   <a href="mailto:rspencer at x10sys.com">Reid Spencer</a><br>
   <a href="http://llvm.cs.uiuc.edu">LLVM Compiler Infrastructure</a><br>
-  Last modified: $Date: 2004/06/03 23:47:34 $
+  Last modified: $Date: 2004/08/03 00:17:21 $
 </address>
 
 </body>





More information about the llvm-commits mailing list