summaryrefslogtreecommitdiff
path: root/docs/tutorial/LangImpl6.html
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2009-09-13 21:38:54 +0000
committerNick Lewycky <nicholas@mxc.ca>2009-09-13 21:38:54 +0000
commit422094c38dfe6878de40f4ad443dcd77542fac22 (patch)
tree7824c7f6ede61d33ee538f497d02cc1c90e8cd16 /docs/tutorial/LangImpl6.html
parentf845c74c6243a10ee5df2af003dcf81bbd0b51a0 (diff)
downloadllvm-422094c38dfe6878de40f4ad443dcd77542fac22.tar.gz
llvm-422094c38dfe6878de40f4ad443dcd77542fac22.tar.bz2
llvm-422094c38dfe6878de40f4ad443dcd77542fac22.tar.xz
Update the tutorial to match changes to examples/Kaleidoscope.
One change I'm not folding in is the removal of two unused variables that caused warnings, because those were there for expository purposes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81721 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/tutorial/LangImpl6.html')
-rw-r--r--docs/tutorial/LangImpl6.html25
1 files changed, 17 insertions, 8 deletions
diff --git a/docs/tutorial/LangImpl6.html b/docs/tutorial/LangImpl6.html
index a61c82cd47..c2ac84c866 100644
--- a/docs/tutorial/LangImpl6.html
+++ b/docs/tutorial/LangImpl6.html
@@ -207,7 +207,7 @@ the prototype for a user-defined operator, we need to parse it:</p>
static PrototypeAST *ParsePrototype() {
std::string FnName;
- <b>int Kind = 0; // 0 = identifier, 1 = unary, 2 = binary.
+ <b>unsigned Kind = 0; // 0 = identifier, 1 = unary, 2 = binary.
unsigned BinaryPrecedence = 30;</b>
switch (CurTok) {
@@ -283,7 +283,8 @@ Value *BinaryExprAST::Codegen() {
case '&lt;':
L = Builder.CreateFCmpULT(L, R, "cmptmp");
// Convert bool 0/1 to double 0.0 or 1.0
- return Builder.CreateUIToFP(L, Type::getDoubleTy(getGlobalContext()), "booltmp");
+ return Builder.CreateUIToFP(L, Type::getDoubleTy(getGlobalContext()),
+ "booltmp");
<b>default: break;</b>
}
@@ -438,7 +439,7 @@ with:</p>
static PrototypeAST *ParsePrototype() {
std::string FnName;
- int Kind = 0; // 0 = identifier, 1 = unary, 2 = binary.
+ unsigned Kind = 0; // 0 = identifier, 1 = unary, 2 = binary.
unsigned BinaryPrecedence = 30;
switch (CurTok) {
@@ -821,12 +822,15 @@ if/then/else and for expressions.. To build this example, use:
<pre>
#include "llvm/DerivedTypes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
+#include "llvm/ExecutionEngine/Interpreter.h"
+#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/ModuleProvider.h"
#include "llvm/PassManager.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/Target/TargetData.h"
+#include "llvm/Target/TargetSelect.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Support/IRBuilder.h"
#include &lt;cstdio&gt;
@@ -1268,7 +1272,7 @@ static ExprAST *ParseExpression() {
static PrototypeAST *ParsePrototype() {
std::string FnName;
- int Kind = 0; // 0 = identifier, 1 = unary, 2 = binary.
+ unsigned Kind = 0; // 0 = identifier, 1 = unary, 2 = binary.
unsigned BinaryPrecedence = 30;
switch (CurTok) {
@@ -1473,7 +1477,8 @@ Value *IfExprAST::Codegen() {
// Emit merge block.
TheFunction-&gt;getBasicBlockList().push_back(MergeBB);
Builder.SetInsertPoint(MergeBB);
- PHINode *PN = Builder.CreatePHI(Type::getDoubleTy(getGlobalContext()), "iftmp");
+ PHINode *PN = Builder.CreatePHI(Type::getDoubleTy(getGlobalContext()),
+ "iftmp");
PN-&gt;addIncoming(ThenV, ThenBB);
PN-&gt;addIncoming(ElseV, ElseBB);
@@ -1575,8 +1580,10 @@ 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()));
- FunctionType *FT = FunctionType::get(Type::getDoubleTy(getGlobalContext()), Doubles, false);
+ std::vector&lt;const Type*&gt; Doubles(Args.size(),
+ Type::getDoubleTy(getGlobalContext()));
+ FunctionType *FT = FunctionType::get(Type::getDoubleTy(getGlobalContext()),
+ Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);
@@ -1688,7 +1695,7 @@ static void HandleTopLevelExpression() {
// Cast it to the right type (takes no arguments, returns a double) so we
// can call it as a native function.
- double (*FP)() = (double (*)())FPtr;
+ double (*FP)() = (double (*)())(intptr_t)FPtr;
fprintf(stderr, "Evaluated to %f\n", FP());
}
} else {
@@ -1770,6 +1777,8 @@ int main() {
// Simplify the control flow graph (deleting unreachable blocks, etc).
OurFPM.add(createCFGSimplificationPass());
+ OurFPM.doInitialization();
+
// Set the global so the code gen can use this.
TheFPM = &amp;OurFPM;