aboutsummaryrefslogtreecommitdiffstats
path: root/examples/Kaleidoscope/MCJIT
diff options
context:
space:
mode:
Diffstat (limited to 'examples/Kaleidoscope/MCJIT')
-rw-r--r--examples/Kaleidoscope/MCJIT/cached/toy-jit.cpp1
-rw-r--r--examples/Kaleidoscope/MCJIT/cached/toy.cpp1
-rw-r--r--examples/Kaleidoscope/MCJIT/complete/toy.cpp129
-rw-r--r--examples/Kaleidoscope/MCJIT/initial/toy.cpp1
-rw-r--r--examples/Kaleidoscope/MCJIT/lazy/toy-jit.cpp1
-rw-r--r--examples/Kaleidoscope/MCJIT/lazy/toy.cpp1
6 files changed, 8 insertions, 126 deletions
diff --git a/examples/Kaleidoscope/MCJIT/cached/toy-jit.cpp b/examples/Kaleidoscope/MCJIT/cached/toy-jit.cpp
index 9466360..00f5b83 100644
--- a/examples/Kaleidoscope/MCJIT/cached/toy-jit.cpp
+++ b/examples/Kaleidoscope/MCJIT/cached/toy-jit.cpp
@@ -2,7 +2,6 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
diff --git a/examples/Kaleidoscope/MCJIT/cached/toy.cpp b/examples/Kaleidoscope/MCJIT/cached/toy.cpp
index 16c548c..af51b4a 100644
--- a/examples/Kaleidoscope/MCJIT/cached/toy.cpp
+++ b/examples/Kaleidoscope/MCJIT/cached/toy.cpp
@@ -897,7 +897,6 @@ ExecutionEngine *MCJITHelper::compileModule(Module *M) {
std::string ErrStr;
ExecutionEngine *NewEngine = EngineBuilder(M)
.setErrorStr(&ErrStr)
- .setUseMCJIT(true)
.setMCJITMemoryManager(new HelpingMemoryManager(this))
.create();
if (!NewEngine) {
diff --git a/examples/Kaleidoscope/MCJIT/complete/toy.cpp b/examples/Kaleidoscope/MCJIT/complete/toy.cpp
index 10e7ada..3beb0d8 100644
--- a/examples/Kaleidoscope/MCJIT/complete/toy.cpp
+++ b/examples/Kaleidoscope/MCJIT/complete/toy.cpp
@@ -1,6 +1,5 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/ExecutionEngine/MCJIT.h"
#include "llvm/ExecutionEngine/ObjectCache.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
@@ -52,10 +51,6 @@ namespace {
cl::desc("Dump IR from modules to stderr on shutdown"),
cl::init(false));
- cl::opt<bool> UseMCJIT(
- "use-mcjit", cl::desc("Use the MCJIT execution engine"),
- cl::init(true));
-
cl::opt<bool> EnableLazyCompilation(
"enable-lazy-compilation", cl::desc("Enable lazy compilation when using the MCJIT engine"),
cl::init(true));
@@ -793,96 +788,6 @@ public:
};
//===----------------------------------------------------------------------===//
-// Helper class for JIT execution engine
-//===----------------------------------------------------------------------===//
-
-class JITHelper : public BaseHelper {
-public:
- JITHelper(LLVMContext &Context) {
- // Make the module, which holds all the code.
- if (!InputIR.empty()) {
- TheModule = parseInputIR(InputIR, Context);
- } else {
- TheModule = new Module("my cool jit", Context);
- }
-
- // Create the JIT. This takes ownership of the module.
- std::string ErrStr;
- TheExecutionEngine = EngineBuilder(TheModule).setErrorStr(&ErrStr).create();
- if (!TheExecutionEngine) {
- fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
- exit(1);
- }
-
- TheFPM = new FunctionPassManager(TheModule);
-
- // Set up the optimizer pipeline. Start with registering info about how the
- // target lays out data structures.
- TheFPM->add(new DataLayout(*TheExecutionEngine->getDataLayout()));
- // Provide basic AliasAnalysis support for GVN.
- TheFPM->add(createBasicAliasAnalysisPass());
- // Promote allocas to registers.
- TheFPM->add(createPromoteMemoryToRegisterPass());
- // Do simple "peephole" optimizations and bit-twiddling optzns.
- TheFPM->add(createInstructionCombiningPass());
- // Reassociate expressions.
- TheFPM->add(createReassociatePass());
- // Eliminate Common SubExpressions.
- TheFPM->add(createGVNPass());
- // Simplify the control flow graph (deleting unreachable blocks, etc).
- TheFPM->add(createCFGSimplificationPass());
-
- TheFPM->doInitialization();
- }
-
- virtual ~JITHelper() {
- if (TheFPM)
- delete TheFPM;
- if (TheExecutionEngine)
- delete TheExecutionEngine;
- }
-
- virtual Function *getFunction(const std::string FnName) {
- assert(TheModule);
- return TheModule->getFunction(FnName);
- }
-
- virtual Module *getModuleForNewFunction() {
- assert(TheModule);
- return TheModule;
- }
-
- virtual void *getPointerToFunction(Function* F) {
- assert(TheExecutionEngine);
- return TheExecutionEngine->getPointerToFunction(F);
- }
-
- virtual void *getPointerToNamedFunction(const std::string &Name) {
- return TheExecutionEngine->getPointerToNamedFunction(Name);
- }
-
- virtual void runFPM(Function &F) {
- assert(TheFPM);
- TheFPM->run(F);
- }
-
- virtual void closeCurrentModule() {
- // This should never be called for JIT
- assert(false);
- }
-
- virtual void dump() {
- assert(TheModule);
- TheModule->dump();
- }
-
-private:
- Module *TheModule;
- ExecutionEngine *TheExecutionEngine;
- FunctionPassManager *TheFPM;
-};
-
-//===----------------------------------------------------------------------===//
// MCJIT helper class
//===----------------------------------------------------------------------===//
@@ -1034,7 +939,6 @@ ExecutionEngine *MCJITHelper::compileModule(Module *M) {
std::string ErrStr;
ExecutionEngine *EE = EngineBuilder(M)
.setErrorStr(&ErrStr)
- .setUseMCJIT(true)
.setMCJITMemoryManager(new HelpingMemoryManager(this))
.create();
if (!EE) {
@@ -1194,10 +1098,8 @@ Value *UnaryExprAST::Codegen() {
Value *OperandV = Operand->Codegen();
if (OperandV == 0) return 0;
Function *F;
- if (UseMCJIT)
- F = TheHelper->getFunction(MakeLegalFunctionName(std::string("unary")+Opcode));
- else
- F = TheHelper->getFunction(std::string("unary")+Opcode);
+ F = TheHelper->getFunction(
+ MakeLegalFunctionName(std::string("unary") + Opcode));
if (F == 0)
return ErrorV("Unknown unary operator");
@@ -1246,10 +1148,7 @@ Value *BinaryExprAST::Codegen() {
// If it wasn't a builtin binary operator, it must be a user defined one. Emit
// a call to it.
Function *F;
- if (UseMCJIT)
- F = TheHelper->getFunction(MakeLegalFunctionName(std::string("binary")+Op));
- else
- F = TheHelper->getFunction(std::string("binary")+Op);
+ F = TheHelper->getFunction(MakeLegalFunctionName(std::string("binary")+Op));
assert(F && "binary operator not found!");
Value *Ops[] = { L, R };
@@ -1482,10 +1381,7 @@ Function *PrototypeAST::Codegen() {
Doubles, false);
std::string FnName;
- if (UseMCJIT)
- FnName = MakeLegalFunctionName(Name);
- else
- FnName = Name;
+ FnName = MakeLegalFunctionName(Name);
Module* M = TheHelper->getModuleForNewFunction();
Function *F = Function::Create(FT, Function::ExternalLinkage, FnName, M);
@@ -1560,10 +1456,6 @@ Function *FunctionAST::Codegen() {
// Validate the generated code, checking for consistency.
verifyFunction(*TheFunction);
- // Optimize the function.
- if (!UseMCJIT)
- TheHelper->runFPM(*TheFunction);
-
return TheFunction;
}
@@ -1581,7 +1473,7 @@ Function *FunctionAST::Codegen() {
static void HandleDefinition() {
if (FunctionAST *F = ParseDefinition()) {
- if (UseMCJIT && EnableLazyCompilation)
+ if (EnableLazyCompilation)
TheHelper->closeCurrentModule();
Function *LF = F->Codegen();
if (LF && VerboseOutput) {
@@ -1671,10 +1563,8 @@ double printlf() {
int main(int argc, char **argv) {
InitializeNativeTarget();
- if (UseMCJIT) {
- InitializeNativeTargetAsmPrinter();
- InitializeNativeTargetAsmParser();
- }
+ InitializeNativeTargetAsmPrinter();
+ InitializeNativeTargetAsmParser();
LLVMContext &Context = getGlobalContext();
cl::ParseCommandLineOptions(argc, argv,
@@ -1690,10 +1580,7 @@ int main(int argc, char **argv) {
BinopPrecedence['*'] = 40; // highest.
// Make the Helper, which holds all the code.
- if (UseMCJIT)
- TheHelper = new MCJITHelper(Context);
- else
- TheHelper = new JITHelper(Context);
+ TheHelper = new MCJITHelper(Context);
// Prime the first token.
if (!SuppressPrompts)
diff --git a/examples/Kaleidoscope/MCJIT/initial/toy.cpp b/examples/Kaleidoscope/MCJIT/initial/toy.cpp
index 4c47113..2c1b297 100644
--- a/examples/Kaleidoscope/MCJIT/initial/toy.cpp
+++ b/examples/Kaleidoscope/MCJIT/initial/toy.cpp
@@ -778,7 +778,6 @@ void *MCJITHelper::getPointerToFunction(Function* F) {
std::string ErrStr;
ExecutionEngine *NewEngine = EngineBuilder(OpenModule)
.setErrorStr(&ErrStr)
- .setUseMCJIT(true)
.setMCJITMemoryManager(new HelpingMemoryManager(this))
.create();
if (!NewEngine) {
diff --git a/examples/Kaleidoscope/MCJIT/lazy/toy-jit.cpp b/examples/Kaleidoscope/MCJIT/lazy/toy-jit.cpp
index 2d540dd..98c1001 100644
--- a/examples/Kaleidoscope/MCJIT/lazy/toy-jit.cpp
+++ b/examples/Kaleidoscope/MCJIT/lazy/toy-jit.cpp
@@ -2,7 +2,6 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
diff --git a/examples/Kaleidoscope/MCJIT/lazy/toy.cpp b/examples/Kaleidoscope/MCJIT/lazy/toy.cpp
index ff88e23..9c2a0d4 100644
--- a/examples/Kaleidoscope/MCJIT/lazy/toy.cpp
+++ b/examples/Kaleidoscope/MCJIT/lazy/toy.cpp
@@ -808,7 +808,6 @@ ExecutionEngine *MCJITHelper::compileModule(Module *M) {
std::string ErrStr;
ExecutionEngine *NewEngine = EngineBuilder(M)
.setErrorStr(&ErrStr)
- .setUseMCJIT(true)
.setMCJITMemoryManager(new HelpingMemoryManager(this))
.create();
if (!NewEngine) {