summaryrefslogtreecommitdiffstats
path: root/llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2015-02-09 01:20:51 +0000
committerLang Hames <lhames@gmail.com>2015-02-09 01:20:51 +0000
commit114b4f324b24760d6c3e12e60b0ea75956e8168e (patch)
treefad5aaa9c03f553aaee89906691c3a151213d9a8 /llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp
parenta021ee62caf49739aa46164326d07909dbc8a989 (diff)
downloadbcm5719-llvm-114b4f324b24760d6c3e12e60b0ea75956e8168e.tar.gz
bcm5719-llvm-114b4f324b24760d6c3e12e60b0ea75956e8168e.zip
[Orc] Add a JITSymbol class to the Orc APIs, refactor APIs, update clients.
This patch refactors a key piece of the Orc APIs: It removes the *::getSymbolAddress and *::lookupSymbolAddressIn methods, which returned target addresses (uint64_ts), and replaces them with *::findSymbol and *::findSymbolIn respectively, which return instances of the new JITSymbol type. Unlike the old methods, calling findSymbol or findSymbolIn does not cause the symbol to be immediately materialized when found. Instead, the symbol will be materialized if/when the getAddress method is called on the returned JITSymbol. This allows us to query for the existence of symbols without actually materializing them. In the future I expect more information to be attached to the JITSymbol class, for example whether the returned symbol is a weak or strong definition. This will allow us to properly handle weak symbols and multiple definitions. llvm-svn: 228557
Diffstat (limited to 'llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp')
-rw-r--r--llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp b/llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp
index 2963f30e2ed..11a17dd9aee 100644
--- a/llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp
@@ -1174,8 +1174,8 @@ public:
auto MM = createLookasideRTDyldMM<SectionMemoryManager>(
[&](const std::string &Name) -> uint64_t {
// First try to find 'Name' within the JIT.
- if (uint64_t Addr = getMangledSymbolAddress(Name))
- return Addr;
+ if (auto Symbol = findMangledSymbol(Name))
+ return Symbol.getAddress();
// If we don't find 'Name' in the JIT, see if we have some AST
// for it.
@@ -1192,8 +1192,8 @@ public:
// finished with it.
Session.FunctionDefs.erase(DefI);
- return getMangledSymbolAddress(Name);
- },
+ return findMangledSymbol(Name).getAddress();
+ },
[](const std::string &S) { return 0; } );
return LazyEmitLayer.addModuleSet(std::move(S), std::move(MM));
@@ -1201,12 +1201,12 @@ public:
void removeModule(ModuleHandleT H) { LazyEmitLayer.removeModuleSet(H); }
- uint64_t getMangledSymbolAddress(const std::string &Name) {
- return LazyEmitLayer.getSymbolAddress(Name, false);
+ JITSymbol findMangledSymbol(const std::string &Name) {
+ return LazyEmitLayer.findSymbol(Name, false);
}
- uint64_t getSymbolAddress(const std::string &Name) {
- return getMangledSymbolAddress(Mangle(Name));
+ JITSymbol findSymbol(const std::string &Name) {
+ return findMangledSymbol(Mangle(Name));
}
private:
@@ -1253,11 +1253,11 @@ static void HandleTopLevelExpression(SessionContext &S, KaleidoscopeJIT &J) {
auto H = J.addModule(C.takeM());
// Get the address of the JIT'd function in memory.
- uint64_t ExprFuncAddr = J.getSymbolAddress("__anon_expr");
+ auto ExprSymbol = J.findSymbol("__anon_expr");
// 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)ExprFuncAddr;
+ double (*FP)() = (double (*)())(intptr_t)ExprSymbol.getAddress();
#ifdef MINIMAL_STDERR_OUTPUT
FP();
#else
OpenPOWER on IntegriCloud