[llvm-commits] CVS: llvm/lib/ExecutionEngine/JIT/JIT.cpp VM.cpp VM.h
Chris Lattner
lattner at cs.uiuc.edu
Fri Dec 19 19:23:19 PST 2003
Changes in directory llvm/lib/ExecutionEngine/JIT:
JIT.cpp updated: 1.26 -> 1.27
VM.cpp updated: 1.16 -> 1.17
VM.h updated: 1.18 -> 1.19
---
Log message:
Rip JIT specific stuff out of TargetMachine, as per PR176
---
Diffs of the changes: (+16 -15)
Index: llvm/lib/ExecutionEngine/JIT/JIT.cpp
diff -u llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.26 llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.27
--- llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.26 Mon Dec 8 02:06:28 2003
+++ llvm/lib/ExecutionEngine/JIT/JIT.cpp Fri Dec 19 19:22:19 2003
@@ -80,19 +80,20 @@
// Allocate a target...
TargetMachine *Target = TargetMachineAllocator(*MP->getModule());
assert(Target && "Could not allocate target machine!");
-
- // Create the virtual machine object...
- return new VM(MP, Target);
+
+ // If the target supports JIT code generation, return a new JIT now.
+ if (TargetJITInfo *TJ = Target->getJITInfo())
+ return new VM(MP, *Target, *TJ);
+ return 0;
}
-VM::VM(ModuleProvider *MP, TargetMachine *tm) : ExecutionEngine(MP), TM(*tm),
- PM(MP)
-{
+VM::VM(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji)
+ : ExecutionEngine(MP), TM(tm), TJI(tji), PM(MP) {
setTargetData(TM.getTargetData());
// Initialize MCE
MCE = createEmitter(*this);
-
+
setupPassManager();
emitGlobals();
Index: llvm/lib/ExecutionEngine/JIT/VM.cpp
diff -u llvm/lib/ExecutionEngine/JIT/VM.cpp:1.16 llvm/lib/ExecutionEngine/JIT/VM.cpp:1.17
--- llvm/lib/ExecutionEngine/JIT/VM.cpp:1.16 Fri Dec 12 01:12:02 2003
+++ llvm/lib/ExecutionEngine/JIT/VM.cpp Fri Dec 19 19:22:19 2003
@@ -18,6 +18,7 @@
#include "llvm/CodeGen/MachineCodeEmitter.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/Target/TargetMachine.h"
+#include "llvm/Target/TargetJITInfo.h"
using namespace llvm;
VM::~VM() {
@@ -30,11 +31,7 @@
///
void VM::setupPassManager() {
// Compile LLVM Code down to machine code in the intermediate representation
- if (TM.addPassesToJITCompile(PM)) {
- std::cerr << "lli: target '" << TM.getName()
- << "' doesn't support JIT compilation!\n";
- abort();
- }
+ TJI.addPassesToJITCompile(PM);
// Turn the machine code intermediate representation into bytes in memory that
// may be executed.
@@ -87,7 +84,7 @@
if (I != GlobalAddress.end()) return I->second;
// If the target supports "stubs" for functions, get a stub now.
- if (void *Ptr = TM.getJITStubForFunction(F, *MCE))
+ if (void *Ptr = TJI.getJITStubForFunction(F, *MCE))
return Ptr;
// Otherwise, if the target doesn't support it, just codegen the function.
@@ -112,6 +109,6 @@
MachineFunction::destruct(F);
runJITOnFunction(F);
assert(Addr && "Code generation didn't add function to GlobalAddress table!");
- TM.replaceMachineCodeForFunction(OldAddr, Addr);
+ TJI.replaceMachineCodeForFunction(OldAddr, Addr);
return Addr;
}
Index: llvm/lib/ExecutionEngine/JIT/VM.h
diff -u llvm/lib/ExecutionEngine/JIT/VM.h:1.18 llvm/lib/ExecutionEngine/JIT/VM.h:1.19
--- llvm/lib/ExecutionEngine/JIT/VM.h:1.18 Fri Dec 12 01:12:02 2003
+++ llvm/lib/ExecutionEngine/JIT/VM.h Fri Dec 19 19:22:19 2003
@@ -24,15 +24,18 @@
class GlobalValue;
class Constant;
class TargetMachine;
+class TargetJITInfo;
class MachineCodeEmitter;
class VM : public ExecutionEngine {
TargetMachine &TM; // The current target we are compiling to
+ TargetJITInfo &TJI; // The JITInfo for the target we are compiling to
+
FunctionPassManager PM; // Passes to compile a function
MachineCodeEmitter *MCE; // MCE object
+ VM(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji);
public:
- VM(ModuleProvider *MP, TargetMachine *tm);
~VM();
/// create - Create an return a new JIT compiler if there is one available
More information about the llvm-commits
mailing list