#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Verifier.h"
-#include "llvm/PassManager.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Transforms/Scalar.h"
#include <cctype>
// new module. Create one that resolves symbols by looking back into the JIT.
auto MM = createLookasideRTDyldMM<SectionMemoryManager>(
[&](const std::string &S) {
- return getMangledSymbolAddress(S);
- },
+ return findMangledSymbol(S).getAddress();
+ },
[](const std::string &S) { return 0; } );
return CompileLayer.addModuleSet(std::move(S), std::move(MM));
void removeModule(ModuleHandleT H) { CompileLayer.removeModuleSet(H); }
- uint64_t getMangledSymbolAddress(const std::string &Name) {
- return CompileLayer.getSymbolAddress(Name, false);
+ JITSymbol findMangledSymbol(const std::string &Name) {
+ return CompileLayer.findSymbol(Name, false);
}
- uint64_t getSymbolAddress(const std::string Name) {
+ JITSymbol findSymbol(const std::string Name) {
std::string MangledName;
{
raw_string_ostream MangledNameStream(MangledName);
Mang.getNameWithPrefix(MangledNameStream, Name);
}
- return getMangledSymbolAddress(MangledName);
+ return findMangledSymbol(MangledName);
}
private:
CompileLayerT CompileLayer;
};
-static std::unique_ptr<llvm::Module>
-IRGen(KaleidoscopeJIT &J, SessionContext &S, const FunctionAST &F) {
+static std::unique_ptr<llvm::Module> IRGen(SessionContext &S,
+ const FunctionAST &F) {
IRGenContext C(S);
auto LF = F.IRGen(C);
if (!LF)
static void HandleDefinition(SessionContext &S, KaleidoscopeJIT &J) {
if (auto F = ParseDefinition()) {
- if (auto M = IRGen(J, S, *F)) {
+ if (auto M = IRGen(S, *F)) {
S.addPrototypeAST(llvm::make_unique<PrototypeAST>(*F->Proto));
J.addModule(std::move(M));
}
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