diff options
Diffstat (limited to 'examples/Kaleidoscope/Chapter5/toy.cpp')
-rw-r--r-- | examples/Kaleidoscope/Chapter5/toy.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/examples/Kaleidoscope/Chapter5/toy.cpp b/examples/Kaleidoscope/Chapter5/toy.cpp index 568ec8de5c30..6852973bae40 100644 --- a/examples/Kaleidoscope/Chapter5/toy.cpp +++ b/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"); @@ -845,7 +845,8 @@ static void HandleDefinition() { if (auto FnAST = ParseDefinition()) { if (auto *FnIR = FnAST->codegen()) { fprintf(stderr, "Read function definition:"); - FnIR->dump(); + FnIR->print(errs()); + fprintf(stderr, "\n"); TheJIT->addModule(std::move(TheModule)); InitializeModuleAndPassManager(); } @@ -859,7 +860,8 @@ static void HandleExtern() { if (auto ProtoAST = ParseExtern()) { if (auto *FnIR = ProtoAST->codegen()) { fprintf(stderr, "Read extern: "); - FnIR->dump(); + FnIR->print(errs()); + fprintf(stderr, "\n"); FunctionProtos[ProtoAST->getName()] = std::move(ProtoAST); } } else { @@ -922,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; } |