Skip to content

Commit

Permalink
Comment out the old JIT
Browse files Browse the repository at this point in the history
  • Loading branch information
certik committed Mar 28, 2022
1 parent 0b132f5 commit 776d4e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
22 changes: 13 additions & 9 deletions src/libasr/codegen/evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
#include <llvm/Support/SourceMgr.h>
#include <llvm/ADT/StringRef.h>
#include <llvm/Target/TargetOptions.h>
#include <llvm/Support/TargetRegistry.h>
#include <llvm/MC/TargetRegistry.h>
#include <llvm/Support/Host.h>
#include <libasr/codegen/KaleidoscopeJIT.h>
//#include <libasr/codegen/KaleidoscopeJIT.h>

#include <libasr/codegen/evaluator.h>
#include <libasr/codegen/asr_to_llvm.h>
Expand Down Expand Up @@ -171,15 +171,15 @@ LLVMEvaluator::LLVMEvaluator(const std::string &t)
TM = target->createTargetMachine(target_triple, CPU, features, opt, RM);

// For some reason the JIT requires a different TargetMachine
llvm::TargetMachine *TM2 = llvm::EngineBuilder().selectTarget();
jit = std::make_unique<llvm::orc::KaleidoscopeJIT>(TM2);
// llvm::TargetMachine *TM2 = llvm::EngineBuilder().selectTarget();
// jit = std::make_unique<llvm::orc::KaleidoscopeJIT>(TM2);

_lfortran_stan(0.5);
}

LLVMEvaluator::~LLVMEvaluator()
{
jit.reset();
// jit.reset();
context.reset();
}

Expand All @@ -196,7 +196,7 @@ std::unique_ptr<llvm::Module> LLVMEvaluator::parse_module(const std::string &sou
throw LFortranException("parse_module(): module failed verification.");
};
module->setTargetTriple(target_triple);
module->setDataLayout(jit->getTargetMachine().createDataLayout());
// module->setDataLayout(jit->getTargetMachine().createDataLayout());
return module;
}

Expand All @@ -217,20 +217,21 @@ void LLVMEvaluator::add_module(std::unique_ptr<llvm::Module> mod) {
// These are already set in parse_module(), but we set it here again for
// cases when the Module was constructed directly, not via parse_module().
mod->setTargetTriple(target_triple);
mod->setDataLayout(jit->getTargetMachine().createDataLayout());
jit->addModule(std::move(mod));
// mod->setDataLayout(jit->getTargetMachine().createDataLayout());
// jit->addModule(std::move(mod));
}

void LLVMEvaluator::add_module(std::unique_ptr<LLVMModule> m) {
add_module(std::move(m->m_m));
}

intptr_t LLVMEvaluator::get_symbol_address(const std::string &name) {
llvm::JITSymbol s = jit->findSymbol(name);
llvm::JITSymbol s = nullptr;//jit->findSymbol(name);
if (!s) {
throw std::runtime_error("findSymbol() failed to find the symbol '"
+ name + "'");
}
/*
llvm::Expected<uint64_t> addr0 = s.getAddress();
if (!addr0) {
llvm::Error e = addr0.takeError();
Expand All @@ -242,6 +243,7 @@ intptr_t LLVMEvaluator::get_symbol_address(const std::string &name) {
throw LFortranException("JITSymbol::getAddress() returned an error: " + msg);
}
return (intptr_t)cantFail(std::move(addr0));
*/
}

int32_t LLVMEvaluator::int32fn(const std::string &name) {
Expand Down Expand Up @@ -305,9 +307,11 @@ std::string LLVMEvaluator::get_asm(llvm::Module &m)
llvm::CodeGenFileType ft = llvm::CGFT_AssemblyFile;
llvm::SmallVector<char, 128> buf;
llvm::raw_svector_ostream dest(buf);
/*
if (jit->getTargetMachine().addPassesToEmitFile(pass, dest, nullptr, ft)) {
throw std::runtime_error("TargetMachine can't emit a file of this type");
}
*/
pass.run(m);
return std::string(dest.str().data(), dest.str().size());
}
Expand Down
4 changes: 3 additions & 1 deletion src/libasr/codegen/evaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ namespace llvm {
class Module;
class Function;
class TargetMachine;
/*
namespace orc {
class KaleidoscopeJIT;
}
*/
}

namespace LFortran {
Expand All @@ -40,7 +42,7 @@ class LLVMModule
class LLVMEvaluator
{
private:
std::unique_ptr<llvm::orc::KaleidoscopeJIT> jit;
// std::unique_ptr<llvm::orc::KaleidoscopeJIT> jit;
std::unique_ptr<llvm::LLVMContext> context;
std::string target_triple;
llvm::TargetMachine *TM;
Expand Down

0 comments on commit 776d4e8

Please sign in to comment.