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 | a7007af1c7b10c3a1aebbbf0b4f348da6f94f1b3 (patch) | |
tree | 19567342cc294f81d6b07c418954b9490c39c568 /examples | |
parent | d9d323f05677ccd05e8881df26ac0da6b3cf4ade (diff) |
[ORC][Kaleidoscope] Update Chapter 1 of BuildingAJIT to incorporate recent ORC
API changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310947 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h | 4 | ||||
-rw-r--r-- | examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp | 12 |
2 files changed, 9 insertions, 7 deletions
diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h index 5a2148a14a1..ab675e3f742 100644 --- a/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h +++ b/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/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp b/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp index 2471344c6d6..7652e80c69a 100644 --- a/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp +++ b/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. |