diff options
| author | Lang Hames <lhames@gmail.com> | 2017-08-15 19:20:10 +0000 |
|---|---|---|
| committer | Lang Hames <lhames@gmail.com> | 2017-08-15 19:20:10 +0000 |
| commit | e815bf3cd8145cf6b70da06f25837baf81ded4f6 (patch) | |
| tree | bed8bdb8a8dff65076ef6f3ba21514449eac2259 /llvm/examples | |
| parent | 78a07ba4385d12b559dca55e4b8cd696a4f85ccb (diff) | |
| download | bcm5719-llvm-e815bf3cd8145cf6b70da06f25837baf81ded4f6.tar.gz bcm5719-llvm-e815bf3cd8145cf6b70da06f25837baf81ded4f6.zip | |
[ORC][Kaleidoscope] Update Chapter 1 of BuildingAJIT to incorporate recent ORC
API changes.
llvm-svn: 310947
Diffstat (limited to 'llvm/examples')
| -rw-r--r-- | llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h | 4 | ||||
| -rw-r--r-- | llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp | 12 |
2 files changed, 9 insertions, 7 deletions
diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h index 5a2148a14a1..ab675e3f742 100644 --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h @@ -86,6 +86,10 @@ public: return CompileLayer.findSymbol(MangledNameStream.str(), true); } + JITTargetAddress getSymbolAddress(const std::string Name) { + return cantFail(findSymbol(Name).getAddress()); + } + void removeModule(ModuleHandle H) { cantFail(CompileLayer.removeModule(H)); } diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp index 2471344c6d6..7652e80c69a 100644 --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp @@ -1144,13 +1144,11 @@ static void HandleTopLevelExpression() { auto H = TheJIT->addModule(std::move(TheModule)); InitializeModule(); - // Search the JIT for the __anon_expr symbol. - auto ExprSymbol = TheJIT->findSymbol("__anon_expr"); - assert(ExprSymbol && "Function not found"); - - // Get the symbol's address and cast it to the right type (takes no - // arguments, returns a double) so we can call it as a native function. - double (*FP)() = (double (*)())(intptr_t)cantFail(ExprSymbol.getAddress()); + // Get the anonymous expression's address and cast it to the right type, + // double(*)(), so we can call it as a native function. + double (*FP)() = + (double (*)())(intptr_t)TheJIT->getSymbolAddress("__anon_expr"); + assert(FP && "Failed to codegen function"); fprintf(stderr, "Evaluated to %f\n", FP()); // Delete the anonymous expression module from the JIT. |

