Rip JIT specific stuff out of TargetMachine, as per PR176
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10542 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/X86/X86CodeEmitter.cpp b/lib/Target/X86/X86CodeEmitter.cpp
index 0b8ac11..1917e62 100644
--- a/lib/Target/X86/X86CodeEmitter.cpp
+++ b/lib/Target/X86/X86CodeEmitter.cpp
@@ -53,13 +53,21 @@
JITResolver *TheJITResolver;
}
-void *X86TargetMachine::getJITStubForFunction(Function *F,
- MachineCodeEmitter &MCE) {
+void *X86JITInfo::getJITStubForFunction(Function *F, MachineCodeEmitter &MCE) {
if (TheJITResolver == 0)
TheJITResolver = new JITResolver(MCE);
return (void*)((unsigned long)TheJITResolver->getLazyResolver(F));
}
+void X86JITInfo::replaceMachineCodeForFunction (void *Old, void *New) {
+ char *OldByte = (char *) Old;
+ *OldByte++ = 0xE9; // Emit JMP opcode.
+ int32_t *OldWord = (int32_t *) OldByte;
+ int32_t NewAddr = (intptr_t) New;
+ int32_t OldAddr = (intptr_t) OldWord;
+ *OldWord = NewAddr - OldAddr - 4; // Emit PC-relative addr of New code.
+}
+
/// addFunctionReference - This method is called when we need to emit the
/// address of a function that has not yet been emitted, so we don't know the
/// address. Instead, we emit a call to the CompilationCallback method, and