diff options
author | Lang Hames <lhames@gmail.com> | 2015-02-26 23:52:42 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2015-02-26 23:52:42 +0000 |
commit | bee2099c494ecad3d3a1e90d7f8974941dc09e38 (patch) | |
tree | d0c06829a4e3f007145f9036b8cdce59bb958849 /llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp | |
parent | aa57c0a2b9a70bcdc3d85b1f53468624e819ada9 (diff) | |
download | bcm5719-llvm-bee2099c494ecad3d3a1e90d7f8974941dc09e38.tar.gz bcm5719-llvm-bee2099c494ecad3d3a1e90d7f8974941dc09e38.zip |
[Orc][Kaleidoscope] More tutorial cleanup, a little extra debugging output.
llvm-svn: 230705
Diffstat (limited to 'llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp')
-rw-r--r-- | llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp b/llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp index d7744ece655..388c3f9b7bd 100644 --- a/llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp +++ b/llvm/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp @@ -1174,7 +1174,8 @@ public: return MangledName; } - void addFunctionDefinition(std::unique_ptr<FunctionAST> FnAST) { + void addFunctionAST(std::unique_ptr<FunctionAST> FnAST) { + std::cerr << "Adding AST: " << FnAST->Proto->Name << "\n"; FunctionDefs[mangle(FnAST->Proto->Name)] = std::move(FnAST); } @@ -1190,7 +1191,7 @@ public: // If we don't already have a definition of 'Name' then search // the ASTs. - return searchUncompiledASTs(Name); + return searchFunctionASTs(Name); }, [](const std::string &S) { return 0; } ); @@ -1216,21 +1217,17 @@ private: // This method searches the FunctionDefs map for a definition of 'Name'. If it // finds one it generates a stub for it and returns the address of the stub. - TargetAddress searchUncompiledASTs(const std::string &Name) { + TargetAddress searchFunctionASTs(const std::string &Name) { auto DefI = FunctionDefs.find(Name); if (DefI == FunctionDefs.end()) return 0; - // We have AST for 'Name'. IRGen it, add it to the JIT, and - // return the address for it. - // FIXME: What happens if IRGen fails? - auto H = addModule(IRGen(Session, *DefI->second)); - - // Remove the function definition's AST now that we're - // finished with it. + // Take the FunctionAST out of the map. + auto FnAST = std::move(DefI->second); FunctionDefs.erase(DefI); - // Return the address of the function. + // IRGen the AST, add it to the JIT, and return the address for it. + auto H = addModule(IRGen(Session, *FnAST)); return findSymbolIn(H, Name).getAddress(); } @@ -1246,7 +1243,7 @@ private: static void HandleDefinition(SessionContext &S, KaleidoscopeJIT &J) { if (auto F = ParseDefinition()) { S.addPrototypeAST(llvm::make_unique<PrototypeAST>(*F->Proto)); - J.addFunctionDefinition(std::move(F)); + J.addFunctionAST(std::move(F)); } else { // Skip token for error recovery. getNextToken(); |