summaryrefslogtreecommitdiffstats
path: root/docs/tutorial/LangImpl5.html
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2011-10-16 08:06:54 +0000
committerBill Wendling <isanbard@gmail.com>2011-10-16 08:06:54 +0000
commit545a2beb44e10e02f590f50053129935db54b9bf (patch)
tree6cccf134db31d7c559e2972450709e59e6c4da09 /docs/tutorial/LangImpl5.html
parentb53fa8bf19a51f0c49a9f8b6ede3e2ff3bdfb961 (diff)
downloadexternal_llvm-545a2beb44e10e02f590f50053129935db54b9bf.zip
external_llvm-545a2beb44e10e02f590f50053129935db54b9bf.tar.gz
external_llvm-545a2beb44e10e02f590f50053129935db54b9bf.tar.bz2
Update tutorial to reflect the current APIs. Also correct a small omission in
LangImpl6.html (it needed to defined the 'binary :' operator). PR9052 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142123 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/tutorial/LangImpl5.html')
-rw-r--r--docs/tutorial/LangImpl5.html71
1 files changed, 36 insertions, 35 deletions
diff --git a/docs/tutorial/LangImpl5.html b/docs/tutorial/LangImpl5.html
index e46ded1..a42636f 100644
--- a/docs/tutorial/LangImpl5.html
+++ b/docs/tutorial/LangImpl5.html
@@ -259,20 +259,20 @@ declare double @bar()
define double @baz(double %x) {
entry:
- %ifcond = fcmp one double %x, 0.000000e+00
- br i1 %ifcond, label %then, label %else
+ %ifcond = fcmp one double %x, 0.000000e+00
+ br i1 %ifcond, label %then, label %else
then: ; preds = %entry
- %calltmp = call double @foo()
- br label %ifcont
+ %calltmp = call double @foo()
+ br label %ifcont
else: ; preds = %entry
- %calltmp1 = call double @bar()
- br label %ifcont
+ %calltmp1 = call double @bar()
+ br label %ifcont
ifcont: ; preds = %else, %then
- %iftmp = phi double [ %calltmp, %then ], [ %calltmp1, %else ]
- ret double %iftmp
+ %iftmp = phi double [ %calltmp, %then ], [ %calltmp1, %else ]
+ ret double %iftmp
}
</pre>
</div>
@@ -660,25 +660,25 @@ declare double @putchard(double)
define double @printstar(double %n) {
entry:
- ; initial value = 1.0 (inlined into phi)
- br label %loop
+ ; initial value = 1.0 (inlined into phi)
+ br label %loop
loop: ; preds = %loop, %entry
- %i = phi double [ 1.000000e+00, %entry ], [ %nextvar, %loop ]
- ; body
- %calltmp = call double @putchard(double 4.200000e+01)
- ; increment
- %nextvar = fadd double %i, 1.000000e+00
-
- ; termination test
- %cmptmp = fcmp ult double %i, %n
- %booltmp = uitofp i1 %cmptmp to double
- %loopcond = fcmp one double %booltmp, 0.000000e+00
- br i1 %loopcond, label %loop, label %afterloop
+ %i = phi double [ 1.000000e+00, %entry ], [ %nextvar, %loop ]
+ ; body
+ %calltmp = call double @putchard(double 4.200000e+01)
+ ; increment
+ %nextvar = fadd double %i, 1.000000e+00
+
+ ; termination test
+ %cmptmp = fcmp ult double %i, %n
+ %booltmp = uitofp i1 %cmptmp to double
+ %loopcond = fcmp one double %booltmp, 0.000000e+00
+ br i1 %loopcond, label %loop, label %afterloop
afterloop: ; preds = %loop
- ; loop always returns 0.0
- ret double 0.000000e+00
+ ; loop always returns 0.0
+ ret double 0.000000e+00
}
</pre>
</div>
@@ -829,10 +829,11 @@ statement.</p>
</div>
<p>With the code for the body of the loop complete, we just need to finish up
-the control flow for it. This code remembers the end block (for the phi node), then creates the block for the loop exit ("afterloop"). Based on the value of the
-exit condition, it creates a conditional branch that chooses between executing
-the loop again and exiting the loop. Any future code is emitted in the
-"afterloop" block, so it sets the insertion position to it.</p>
+the control flow for it. This code remembers the end block (for the phi node),
+then creates the block for the loop exit ("afterloop"). Based on the value of
+the exit condition, it creates a conditional branch that chooses between
+executing the loop again and exiting the loop. Any future code is emitted in
+the "afterloop" block, so it sets the insertion position to it.</p>
<div class="doc_code">
<pre>
@@ -880,10 +881,10 @@ if/then/else and for expressions.. To build this example, use:
<div class="doc_code">
<pre>
- # Compile
- g++ -g toy.cpp `llvm-config --cppflags --ldflags --libs core jit native` -O3 -o toy
- # Run
- ./toy
+# Compile
+clang++ -g toy.cpp `llvm-config --cppflags --ldflags --libs core jit native` -O3 -o toy
+# Run
+./toy
</pre>
</div>
@@ -900,9 +901,9 @@ if/then/else and for expressions.. To build this example, use:
#include "llvm/Analysis/Verifier.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/Target/TargetData.h"
-#include "llvm/Target/TargetSelect.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Support/IRBuilder.h"
+#include "llvm/Support/TargetSelect.h"
#include &lt;cstdio&gt;
#include &lt;string&gt;
#include &lt;map&gt;
@@ -1397,7 +1398,7 @@ Value *CallExprAST::Codegen() {
if (ArgsV.back() == 0) return 0;
}
- return Builder.CreateCall(CalleeF, ArgsV.begin(), ArgsV.end(), "calltmp");
+ return Builder.CreateCall(CalleeF, ArgsV, "calltmp");
}
Value *IfExprAST::Codegen() {
@@ -1546,8 +1547,8 @@ Value *ForExprAST::Codegen() {
Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc.
- std::vector&lt;const Type*&gt; Doubles(Args.size(),
- Type::getDoubleTy(getGlobalContext()));
+ std::vector&lt;Type*&gt; Doubles(Args.size(),
+ Type::getDoubleTy(getGlobalContext()));
FunctionType *FT = FunctionType::get(Type::getDoubleTy(getGlobalContext()),
Doubles, false);