summaryrefslogtreecommitdiffstats
path: root/llvm/docs/tutorial/LangImpl03.rst
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2017-02-11 21:26:52 +0000
committerMehdi Amini <mehdi.amini@apple.com>2017-02-11 21:26:52 +0000
commitbb6805d2632b0737e21a7a8987da9264b62d1452 (patch)
treed10ae324d2429163cd10423f78c055dacc6fcbb0 /llvm/docs/tutorial/LangImpl03.rst
parent315edb0216579960f532d6caa45d20d4ec2eb7af (diff)
downloadbcm5719-llvm-bb6805d2632b0737e21a7a8987da9264b62d1452.tar.gz
bcm5719-llvm-bb6805d2632b0737e21a7a8987da9264b62d1452.zip
Update Kaleidoscope tutorial and improve Windows support
Many quoted code blocks were not in sync with the actual toy.cpp files. Improve tutorial text slightly in several places. Added some step descriptions crucial to avoid crashes (like InitializeNativeTarget* calls). Solve/workaround problems with Windows (JIT'ed method not found, using custom and standard library functions from host process). Patch by: Moritz Kroll <moritz.kroll@gmx.de> Differential Revision: https://reviews.llvm.org/D29864 llvm-svn: 294870
Diffstat (limited to 'llvm/docs/tutorial/LangImpl03.rst')
-rw-r--r--llvm/docs/tutorial/LangImpl03.rst13
1 files changed, 7 insertions, 6 deletions
diff --git a/llvm/docs/tutorial/LangImpl03.rst b/llvm/docs/tutorial/LangImpl03.rst
index 2bb3a300026..1dfe10175c7 100644
--- a/llvm/docs/tutorial/LangImpl03.rst
+++ b/llvm/docs/tutorial/LangImpl03.rst
@@ -122,7 +122,7 @@ First we'll do numeric literals:
.. code-block:: c++
Value *NumberExprAST::codegen() {
- return ConstantFP::get(LLVMContext, APFloat(Val));
+ return ConstantFP::get(TheContext, APFloat(Val));
}
In the LLVM IR, numeric constants are represented with the
@@ -171,7 +171,7 @@ variables <LangImpl7.html#user-defined-local-variables>`_.
case '<':
L = Builder.CreateFCmpULT(L, R, "cmptmp");
// Convert bool 0/1 to double 0.0 or 1.0
- return Builder.CreateUIToFP(L, Type::getDoubleTy(LLVMContext),
+ return Builder.CreateUIToFP(L, Type::getDoubleTy(TheContext),
"booltmp");
default:
return LogErrorV("invalid binary operator");
@@ -270,9 +270,9 @@ with:
Function *PrototypeAST::codegen() {
// Make the function type: double(double,double) etc.
std::vector<Type*> Doubles(Args.size(),
- Type::getDoubleTy(LLVMContext));
+ Type::getDoubleTy(TheContext));
FunctionType *FT =
- FunctionType::get(Type::getDoubleTy(LLVMContext), Doubles, false);
+ FunctionType::get(Type::getDoubleTy(TheContext), Doubles, false);
Function *F =
Function::Create(FT, Function::ExternalLinkage, Name, TheModule);
@@ -346,7 +346,7 @@ assert that the function is empty (i.e. has no body yet) before we start.
.. code-block:: c++
// Create a new basic block to start insertion into.
- BasicBlock *BB = BasicBlock::Create(LLVMContext, "entry", TheFunction);
+ BasicBlock *BB = BasicBlock::Create(TheContext, "entry", TheFunction);
Builder.SetInsertPoint(BB);
// Record the function arguments in the NamedValues map.
@@ -533,7 +533,8 @@ This shows an extern for the libm "cos" function, and a call to it.
ret double %calltmp
}
-When you quit the current demo, it dumps out the IR for the entire
+When you quit the current demo (by sending an EOF via CTRL+D on Linux
+or CTRL+Z and ENTER on Windows), it dumps out the IR for the entire
module generated. Here you can see the big picture with all the
functions referencing each other.
OpenPOWER on IntegriCloud