summaryrefslogtreecommitdiffstats
path: root/llvm/examples/Kaleidoscope/Chapter5/toy.cpp
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/examples/Kaleidoscope/Chapter5/toy.cpp
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/examples/Kaleidoscope/Chapter5/toy.cpp')
-rw-r--r--llvm/examples/Kaleidoscope/Chapter5/toy.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/examples/Kaleidoscope/Chapter5/toy.cpp b/llvm/examples/Kaleidoscope/Chapter5/toy.cpp
index 795f49c847e..6852973bae4 100644
--- a/llvm/examples/Kaleidoscope/Chapter5/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter5/toy.cpp
@@ -622,7 +622,7 @@ Value *IfExprAST::codegen() {
if (!CondV)
return nullptr;
- // Convert condition to a bool by comparing equal to 0.0.
+ // Convert condition to a bool by comparing non-equal to 0.0.
CondV = Builder.CreateFCmpONE(
CondV, ConstantFP::get(TheContext, APFloat(0.0)), "ifcond");
@@ -736,7 +736,7 @@ Value *ForExprAST::codegen() {
if (!EndCond)
return nullptr;
- // Convert condition to a bool by comparing equal to 0.0.
+ // Convert condition to a bool by comparing non-equal to 0.0.
EndCond = Builder.CreateFCmpONE(
EndCond, ConstantFP::get(TheContext, APFloat(0.0)), "loopcond");
@@ -924,14 +924,20 @@ static void MainLoop() {
// "Library" functions that can be "extern'd" from user code.
//===----------------------------------------------------------------------===//
+#ifdef LLVM_ON_WIN32
+#define DLLEXPORT __declspec(dllexport)
+#else
+#define DLLEXPORT
+#endif
+
/// putchard - putchar that takes a double and returns 0.
-extern "C" double putchard(double X) {
+extern "C" DLLEXPORT double putchard(double X) {
fputc((char)X, stderr);
return 0;
}
/// printd - printf that takes a double prints it as "%f\n", returning 0.
-extern "C" double printd(double X) {
+extern "C" DLLEXPORT double printd(double X) {
fprintf(stderr, "%f\n", X);
return 0;
}
OpenPOWER on IntegriCloud