[llvm-commits] [llvm] r44647 - in /llvm/trunk: include/llvm/ExecutionEngine/ExecutionEngine.h lib/ExecutionEngine/JIT/JIT.cpp lib/ExecutionEngine/JIT/JIT.h lib/ExecutionEngine/JIT/TargetSelect.cpp
Chris Lattner
sabre at nondot.org
Wed Dec 5 17:34:05 PST 2007
Author: lattner
Date: Wed Dec 5 19:34:04 2007
New Revision: 44647
URL: http://llvm.org/viewvc/llvm-project?rev=44647&view=rev
Log:
add a new ExecutionEngine::createJIT which can be used if you only want
to create a JIT. This lets you specify JIT-specific configuration items
like the JITMemoryManager to use.
Modified:
llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h
llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
llvm/trunk/lib/ExecutionEngine/JIT/JIT.h
llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp
Modified: llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h?rev=44647&r1=44646&r2=44647&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h Wed Dec 5 19:34:04 2007
@@ -108,6 +108,14 @@
/// is appropriate for the current machine. This takes ownership of the
/// module.
static ExecutionEngine *create(Module *M);
+
+ /// createJIT - This is the factory method for creating a JIT for the current
+ /// machine, it does not fall back to the interpreter. This takes ownership
+ /// of the ModuleProvider and JITMemoryManager if successful.
+ static ExecutionEngine *createJIT(ModuleProvider *MP,
+ std::string *ErrorStr = 0,
+ JITMemoryManager *JMM = 0);
+
/// addModuleProvider - Add a ModuleProvider to the list of modules that we
Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=44647&r1=44646&r2=44647&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Wed Dec 5 19:34:04 2007
@@ -61,12 +61,29 @@
}
}
-JIT::JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji)
+/// createJIT - This is the factory method for creating a JIT for the current
+/// machine, it does not fall back to the interpreter. This takes ownership
+/// of the module provider.
+ExecutionEngine *ExecutionEngine::createJIT(ModuleProvider *MP,
+ std::string *ErrorStr,
+ JITMemoryManager *JMM) {
+ ExecutionEngine *EE = JIT::createJIT(MP, ErrorStr, JMM);
+ if (!EE) return 0;
+
+
+ // Make sure we can resolve symbols in the program as well. The zero arg
+ // to the function tells DynamicLibrary to load the program, not a library.
+ sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr);
+ return EE;
+}
+
+JIT::JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji,
+ JITMemoryManager *JMM)
: ExecutionEngine(MP), TM(tm), TJI(tji), jitstate(MP) {
setTargetData(TM.getTargetData());
// Initialize MCE
- MCE = createEmitter(*this, 0);
+ MCE = createEmitter(*this, JMM);
// Add target data
MutexGuard locked(lock);
Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.h?rev=44647&r1=44646&r2=44647&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JIT.h (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.h Wed Dec 5 19:34:04 2007
@@ -56,7 +56,8 @@
JITState jitstate;
- JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji);
+ JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji,
+ JITMemoryManager *JMM);
public:
~JIT();
@@ -71,7 +72,9 @@
/// create - Create an return a new JIT compiler if there is one available
/// for the current target. Otherwise, return null.
///
- static ExecutionEngine *create(ModuleProvider *MP, std::string* = 0);
+ static ExecutionEngine *create(ModuleProvider *MP, std::string *Err) {
+ return createJIT(MP, Err, 0);
+ }
/// run - Start execution with the specified function and arguments.
///
@@ -120,6 +123,10 @@
/// getCodeEmitter - Return the code emitter this JIT is emitting into.
MachineCodeEmitter *getCodeEmitter() const { return MCE; }
+
+ static ExecutionEngine *createJIT(ModuleProvider *MP, std::string *Err,
+ JITMemoryManager *JMM);
+
private:
static MachineCodeEmitter *createEmitter(JIT &J, JITMemoryManager *JMM);
void runJITOnFunction (Function *F);
Modified: llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp?rev=44647&r1=44646&r2=44647&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp Wed Dec 5 19:34:04 2007
@@ -36,10 +36,11 @@
cl::desc("Target specific attributes (-mattr=help for details)"),
cl::value_desc("a1,+a2,-a3,..."));
-/// create - Create an return a new JIT compiler if there is one available
-/// for the current target. Otherwise, return null.
+/// createInternal - Create an return a new JIT compiler if there is one
+/// available for the current target. Otherwise, return null.
///
-ExecutionEngine *JIT::create(ModuleProvider *MP, std::string *ErrorStr) {
+ExecutionEngine *JIT::createJIT(ModuleProvider *MP, std::string *ErrorStr,
+ JITMemoryManager *JMM) {
const TargetMachineRegistry::entry *TheArch = MArch;
if (TheArch == 0) {
std::string Error;
@@ -71,7 +72,7 @@
// If the target supports JIT code generation, return a new JIT now.
if (TargetJITInfo *TJ = Target->getJITInfo())
- return new JIT(MP, *Target, *TJ);
+ return new JIT(MP, *Target, *TJ, JMM);
if (ErrorStr)
*ErrorStr = "target does not support JIT code generation";
More information about the llvm-commits
mailing list