aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/X86/X86CodeEmitter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-12-20 01:22:19 +0000
committerChris Lattner <sabre@nondot.org>2003-12-20 01:22:19 +0000
commit1e60a9165dc4d6ce5650dacc026f2942696af920 (patch)
tree6af93d79e843f6f224f31d291f0b7a7aca81e7b8 /lib/Target/X86/X86CodeEmitter.cpp
parent370e809107c5baf5671daa8709e7d981c0a89685 (diff)
downloadexternal_llvm-1e60a9165dc4d6ce5650dacc026f2942696af920.tar.gz
external_llvm-1e60a9165dc4d6ce5650dacc026f2942696af920.tar.bz2
external_llvm-1e60a9165dc4d6ce5650dacc026f2942696af920.zip
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
Diffstat (limited to 'lib/Target/X86/X86CodeEmitter.cpp')
-rw-r--r--lib/Target/X86/X86CodeEmitter.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Target/X86/X86CodeEmitter.cpp b/lib/Target/X86/X86CodeEmitter.cpp
index 0b8ac11014..1917e626a5 100644
--- a/lib/Target/X86/X86CodeEmitter.cpp
+++ b/lib/Target/X86/X86CodeEmitter.cpp
@@ -53,13 +53,21 @@ namespace {
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