aboutsummaryrefslogtreecommitdiff
path: root/lib/Target
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target')
-rw-r--r--lib/Target/X86/X86JITInfo.cpp15
-rw-r--r--lib/Target/X86/X86JITInfo.h6
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/Target/X86/X86JITInfo.cpp b/lib/Target/X86/X86JITInfo.cpp
index f8d32b0961..4bbccf380c 100644
--- a/lib/Target/X86/X86JITInfo.cpp
+++ b/lib/Target/X86/X86JITInfo.cpp
@@ -490,6 +490,21 @@ void *X86JITInfo::emitFunctionStub(const Function* F, void *Fn,
return MCE.finishGVStub(F);
}
+void X86JITInfo::emitFunctionStubAtAddr(const Function* F, void *Fn, void *Stub,
+ MachineCodeEmitter &MCE) {
+ // Note, we cast to intptr_t here to silence a -pedantic warning that
+ // complains about casting a function pointer to a normal pointer.
+ MCE.startGVStub(F, Stub, 5);
+ MCE.emitByte(0xE9);
+#if defined (X86_64_JIT)
+ assert(((((intptr_t)Fn-MCE.getCurrentPCValue()-5) << 32) >> 32) ==
+ ((intptr_t)Fn-MCE.getCurrentPCValue()-5)
+ && "PIC displacement does not fit in displacement field!");
+#endif
+ MCE.emitWordLE((intptr_t)Fn-MCE.getCurrentPCValue()-4);
+ MCE.finishGVStub(F);
+}
+
/// getPICJumpTableEntry - Returns the value of the jumptable entry for the
/// specific basic block.
uintptr_t X86JITInfo::getPICJumpTableEntry(uintptr_t BB, uintptr_t Entry) {
diff --git a/lib/Target/X86/X86JITInfo.h b/lib/Target/X86/X86JITInfo.h
index ed660b0b58..9affa3176b 100644
--- a/lib/Target/X86/X86JITInfo.h
+++ b/lib/Target/X86/X86JITInfo.h
@@ -49,6 +49,12 @@ namespace llvm {
virtual void *emitFunctionStub(const Function* F, void *Fn,
MachineCodeEmitter &MCE);
+ /// emitFunctionStubAtAddr - Use the specified MachineCodeEmitter object to
+ /// emit a small native function that simply calls Fn. Emit the stub into
+ /// the supplied buffer.
+ virtual void emitFunctionStubAtAddr(const Function* F, void *Fn,
+ void *Buffer, MachineCodeEmitter &MCE);
+
/// getPICJumpTableEntry - Returns the value of the jumptable entry for the
/// specific basic block.
virtual uintptr_t getPICJumpTableEntry(uintptr_t BB, uintptr_t JTBase);