summaryrefslogtreecommitdiff
path: root/lib/Target
diff options
context:
space:
mode:
authorNicolas Geoffray <nicolas.geoffray@lip6.fr>2008-04-16 20:46:05 +0000
committerNicolas Geoffray <nicolas.geoffray@lip6.fr>2008-04-16 20:46:05 +0000
commit51cc3c13eac78da242f0518fc42580e48dd5304f (patch)
tree8cabb5d8c03920e8df85546c5c76465ae2dc131e /lib/Target
parente20bbc81012e636cb59bbbe3a114895a2f7fa0da (diff)
downloadllvm-51cc3c13eac78da242f0518fc42580e48dd5304f.tar.gz
llvm-51cc3c13eac78da242f0518fc42580e48dd5304f.tar.bz2
llvm-51cc3c13eac78da242f0518fc42580e48dd5304f.tar.xz
Correlate stubs with functions in JIT: when emitting a stub, the JIT tells the memory manager which function
the stub will resolve. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49814 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r--lib/Target/ARM/ARMJITInfo.cpp10
-rw-r--r--lib/Target/ARM/ARMJITInfo.h3
-rw-r--r--lib/Target/Alpha/AlphaJITInfo.cpp8
-rw-r--r--lib/Target/Alpha/AlphaJITInfo.h3
-rw-r--r--lib/Target/PowerPC/PPCJITInfo.cpp12
-rw-r--r--lib/Target/PowerPC/PPCJITInfo.h3
-rw-r--r--lib/Target/X86/X86JITInfo.cpp29
-rw-r--r--lib/Target/X86/X86JITInfo.h9
8 files changed, 46 insertions, 31 deletions
diff --git a/lib/Target/ARM/ARMJITInfo.cpp b/lib/Target/ARM/ARMJITInfo.cpp
index 915963c26c..bc2bba36c8 100644
--- a/lib/Target/ARM/ARMJITInfo.cpp
+++ b/lib/Target/ARM/ARMJITInfo.cpp
@@ -15,6 +15,7 @@
#include "ARMJITInfo.h"
#include "ARMRelocations.h"
#include "ARMSubtarget.h"
+#include "llvm/Function.h"
#include "llvm/CodeGen/MachineCodeEmitter.h"
#include "llvm/Config/alloca.h"
#include <cstdlib>
@@ -93,20 +94,21 @@ ARMJITInfo::getLazyResolverFunction(JITCompilerFn F) {
return ARMCompilationCallback;
}
-void *ARMJITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) {
+void *ARMJITInfo::emitFunctionStub(const Function* F, void *Fn,
+ MachineCodeEmitter &MCE) {
unsigned addr = (intptr_t)Fn;
// If this is just a call to an external function, emit a branch instead of a
// call. The code is the same except for one bit of the last instruction.
if (Fn != (void*)(intptr_t)ARMCompilationCallback) {
// branch to the corresponding function addr
// the stub is 8-byte size and 4-aligned
- MCE.startFunctionStub(8, 4);
+ MCE.startFunctionStub(F, 8, 4);
MCE.emitWordLE(0xE51FF004); // LDR PC, [PC,#-4]
MCE.emitWordLE(addr); // addr of function
} else {
// branch and link to the corresponding function addr
// the stub is 20-byte size and 4-aligned
- MCE.startFunctionStub(20, 4);
+ MCE.startFunctionStub(F, 20, 4);
MCE.emitWordLE(0xE92D4800); // STMFD SP!, [R11, LR]
MCE.emitWordLE(0xE28FE004); // ADD LR, PC, #4
MCE.emitWordLE(0xE51FF004); // LDR PC, [PC,#-4]
@@ -114,7 +116,7 @@ void *ARMJITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) {
MCE.emitWordLE(0xE8BD8800); // LDMFD SP!, [R11, PC]
}
- return MCE.finishFunctionStub(0);
+ return MCE.finishFunctionStub(F);
}
/// relocate - Before the JIT can run a block of code that has been emitted,
diff --git a/lib/Target/ARM/ARMJITInfo.h b/lib/Target/ARM/ARMJITInfo.h
index 81d896b7f1..de3ff08ad2 100644
--- a/lib/Target/ARM/ARMJITInfo.h
+++ b/lib/Target/ARM/ARMJITInfo.h
@@ -34,7 +34,8 @@ namespace llvm {
/// emitFunctionStub - Use the specified MachineCodeEmitter object to emit a
/// small native function that simply calls the function at the specified
/// address.
- virtual void *emitFunctionStub(void *Fn, MachineCodeEmitter &MCE);
+ virtual void *emitFunctionStub(const Function* F, void *Fn,
+ MachineCodeEmitter &MCE);
/// getLazyResolverFunction - Expose the lazy resolver to the JIT.
virtual LazyResolverFn getLazyResolverFunction(JITCompilerFn);
diff --git a/lib/Target/Alpha/AlphaJITInfo.cpp b/lib/Target/Alpha/AlphaJITInfo.cpp
index a20ae9fd5e..4fd0ebcaef 100644
--- a/lib/Target/Alpha/AlphaJITInfo.cpp
+++ b/lib/Target/Alpha/AlphaJITInfo.cpp
@@ -14,6 +14,7 @@
#define DEBUG_TYPE "jit"
#include "AlphaJITInfo.h"
#include "AlphaRelocations.h"
+#include "llvm/Function.h"
#include "llvm/CodeGen/MachineCodeEmitter.h"
#include "llvm/Config/alloca.h"
#include "llvm/Support/Debug.h"
@@ -190,16 +191,17 @@ extern "C" {
#endif
}
-void *AlphaJITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) {
+void *AlphaJITInfo::emitFunctionStub(const Function* F, void *Fn,
+ MachineCodeEmitter &MCE) {
//assert(Fn == AlphaCompilationCallback && "Where are you going?\n");
//Do things in a stupid slow way!
- MCE.startFunctionStub(19*4);
+ MCE.startFunctionStub(F, 19*4);
void* Addr = (void*)(intptr_t)MCE.getCurrentPCValue();
for (int x = 0; x < 19; ++ x)
MCE.emitWordLE(0);
EmitBranchToAt(Addr, Fn);
DOUT << "Emitting Stub to " << Fn << " at [" << Addr << "]\n";
- return MCE.finishFunctionStub(0);
+ return MCE.finishFunctionStub(F);
}
TargetJITInfo::LazyResolverFn
diff --git a/lib/Target/Alpha/AlphaJITInfo.h b/lib/Target/Alpha/AlphaJITInfo.h
index 29511694d8..7bf51d628d 100644
--- a/lib/Target/Alpha/AlphaJITInfo.h
+++ b/lib/Target/Alpha/AlphaJITInfo.h
@@ -29,7 +29,8 @@ namespace llvm {
explicit AlphaJITInfo(TargetMachine &tm) : TM(tm)
{ useGOT = true; }
- virtual void *emitFunctionStub(void *Fn, MachineCodeEmitter &MCE);
+ virtual void *emitFunctionStub(const Function* F, void *Fn,
+ MachineCodeEmitter &MCE);
virtual LazyResolverFn getLazyResolverFunction(JITCompilerFn);
virtual void relocate(void *Function, MachineRelocation *MR,
unsigned NumRelocs, unsigned char* GOTBase);
diff --git a/lib/Target/PowerPC/PPCJITInfo.cpp b/lib/Target/PowerPC/PPCJITInfo.cpp
index 6dea3d3306..461cfec34a 100644
--- a/lib/Target/PowerPC/PPCJITInfo.cpp
+++ b/lib/Target/PowerPC/PPCJITInfo.cpp
@@ -15,6 +15,7 @@
#include "PPCJITInfo.h"
#include "PPCRelocations.h"
#include "PPCTargetMachine.h"
+#include "llvm/Function.h"
#include "llvm/CodeGen/MachineCodeEmitter.h"
#include "llvm/Config/alloca.h"
#include "llvm/Support/Debug.h"
@@ -338,12 +339,13 @@ defined(__APPLE__)
#endif
}
-void *PPCJITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) {
+void *PPCJITInfo::emitFunctionStub(const Function* F, void *Fn,
+ MachineCodeEmitter &MCE) {
// If this is just a call to an external function, emit a branch instead of a
// call. The code is the same except for one bit of the last instruction.
if (Fn != (void*)(intptr_t)PPC32CompilationCallback &&
Fn != (void*)(intptr_t)PPC64CompilationCallback) {
- MCE.startFunctionStub(7*4);
+ MCE.startFunctionStub(F, 7*4);
intptr_t Addr = (intptr_t)MCE.getCurrentPCValue();
MCE.emitWordBE(0);
MCE.emitWordBE(0);
@@ -354,10 +356,10 @@ void *PPCJITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) {
MCE.emitWordBE(0);
EmitBranchToAt(Addr, (intptr_t)Fn, false, is64Bit);
SyncICache((void*)Addr, 7*4);
- return MCE.finishFunctionStub(0);
+ return MCE.finishFunctionStub(F);
}
- MCE.startFunctionStub(10*4);
+ MCE.startFunctionStub(F, 10*4);
intptr_t Addr = (intptr_t)MCE.getCurrentPCValue();
if (is64Bit) {
MCE.emitWordBE(0xf821ffb1); // stdu r1,-80(r1)
@@ -382,7 +384,7 @@ void *PPCJITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) {
MCE.emitWordBE(0);
EmitBranchToAt(BranchAddr, (intptr_t)Fn, true, is64Bit);
SyncICache((void*)Addr, 10*4);
- return MCE.finishFunctionStub(0);
+ return MCE.finishFunctionStub(F);
}
diff --git a/lib/Target/PowerPC/PPCJITInfo.h b/lib/Target/PowerPC/PPCJITInfo.h
index cce07484d3..c93a84aca0 100644
--- a/lib/Target/PowerPC/PPCJITInfo.h
+++ b/lib/Target/PowerPC/PPCJITInfo.h
@@ -29,7 +29,8 @@ namespace llvm {
is64Bit = tmIs64Bit;
}
- virtual void *emitFunctionStub(void *Fn, MachineCodeEmitter &MCE);
+ virtual void *emitFunctionStub(const Function* F, void *Fn,
+ MachineCodeEmitter &MCE);
virtual LazyResolverFn getLazyResolverFunction(JITCompilerFn);
virtual void relocate(void *Function, MachineRelocation *MR,
unsigned NumRelocs, unsigned char* GOTBase);
diff --git a/lib/Target/X86/X86JITInfo.cpp b/lib/Target/X86/X86JITInfo.cpp
index 5d942a1768..7f72bd473e 100644
--- a/lib/Target/X86/X86JITInfo.cpp
+++ b/lib/Target/X86/X86JITInfo.cpp
@@ -15,6 +15,7 @@
#include "X86JITInfo.h"
#include "X86Relocations.h"
#include "X86Subtarget.h"
+#include "llvm/Function.h"
#include "llvm/CodeGen/MachineCodeEmitter.h"
#include "llvm/Config/alloca.h"
#include <cstdlib>
@@ -391,19 +392,21 @@ X86JITInfo::getLazyResolverFunction(JITCompilerFn F) {
return X86CompilationCallback;
}
-void *X86JITInfo::emitGlobalValueLazyPtr(void *GV, MachineCodeEmitter &MCE) {
+void *X86JITInfo::emitGlobalValueLazyPtr(const GlobalValue* GV, void *ptr,
+ MachineCodeEmitter &MCE) {
#if defined (X86_64_JIT)
MCE.startFunctionStub(8, 8);
- MCE.emitWordLE(((unsigned *)&GV)[0]);
- MCE.emitWordLE(((unsigned *)&GV)[1]);
+ MCE.emitWordLE(((unsigned *)&ptr)[0]);
+ MCE.emitWordLE(((unsigned *)&ptr)[1]);
#else
- MCE.startFunctionStub(4, 4);
- MCE.emitWordLE((intptr_t)GV);
+ MCE.startFunctionStub(GV, 4, 4);
+ MCE.emitWordLE((intptr_t)ptr);
#endif
- return MCE.finishFunctionStub(0);
+ return MCE.finishFunctionStub(GV);
}
-void *X86JITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) {
+void *X86JITInfo::emitFunctionStub(const Function* F, void *Fn,
+ 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.
#if defined (X86_32_JIT) && !defined (_MSC_VER)
@@ -414,7 +417,7 @@ void *X86JITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) {
#endif
if (NotCC) {
#if defined (X86_64_JIT)
- MCE.startFunctionStub(13, 4);
+ MCE.startFunctionStub(F, 13, 4);
MCE.emitByte(0x49); // REX prefix
MCE.emitByte(0xB8+2); // movabsq r10
MCE.emitWordLE(((unsigned *)&Fn)[0]);
@@ -423,15 +426,15 @@ void *X86JITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) {
MCE.emitByte(0xFF); // jmpq *r10
MCE.emitByte(2 | (4 << 3) | (3 << 6));
#else
- MCE.startFunctionStub(5, 4);
+ MCE.startFunctionStub(F, 5, 4);
MCE.emitByte(0xE9);
MCE.emitWordLE((intptr_t)Fn-MCE.getCurrentPCValue()-4);
#endif
- return MCE.finishFunctionStub(0);
+ return MCE.finishFunctionStub(F);
}
#if defined (X86_64_JIT)
- MCE.startFunctionStub(14, 4);
+ MCE.startFunctionStub(F, 14, 4);
MCE.emitByte(0x49); // REX prefix
MCE.emitByte(0xB8+2); // movabsq r10
MCE.emitWordLE(((unsigned *)&Fn)[0]);
@@ -440,14 +443,14 @@ void *X86JITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) {
MCE.emitByte(0xFF); // callq *r10
MCE.emitByte(2 | (2 << 3) | (3 << 6));
#else
- MCE.startFunctionStub(6, 4);
+ MCE.startFunctionStub(F, 6, 4);
MCE.emitByte(0xE8); // Call with 32 bit pc-rel destination...
MCE.emitWordLE((intptr_t)Fn-MCE.getCurrentPCValue()-4);
#endif
MCE.emitByte(0xCD); // Interrupt - Just a marker identifying the stub!
- return MCE.finishFunctionStub(0);
+ return MCE.finishFunctionStub(F);
}
/// getPICJumpTableEntry - Returns the value of the jumptable entry for the
diff --git a/lib/Target/X86/X86JITInfo.h b/lib/Target/X86/X86JITInfo.h
index 69bebd0270..f9fcefecff 100644
--- a/lib/Target/X86/X86JITInfo.h
+++ b/lib/Target/X86/X86JITInfo.h
@@ -14,6 +14,7 @@
#ifndef X86JITINFO_H
#define X86JITINFO_H
+#include "llvm/Function.h"
#include "llvm/Target/TargetJITInfo.h"
namespace llvm {
@@ -33,13 +34,15 @@ namespace llvm {
virtual void replaceMachineCodeForFunction(void *Old, void *New);
/// emitGlobalValueLazyPtr - Use the specified MachineCodeEmitter object to
- /// emit a lazy pointer which contains the address of the specified GV.
- virtual void *emitGlobalValueLazyPtr(void *GV, MachineCodeEmitter &MCE);
+ /// emit a lazy pointer which contains the address of the specified ptr.
+ virtual void *emitGlobalValueLazyPtr(const GlobalValue* GV, void *ptr,
+ MachineCodeEmitter &MCE);
/// emitFunctionStub - Use the specified MachineCodeEmitter object to emit a
/// small native function that simply calls the function at the specified
/// address.
- virtual void *emitFunctionStub(void *Fn, MachineCodeEmitter &MCE);
+ virtual void *emitFunctionStub(const Function* F, void *Fn,
+ MachineCodeEmitter &MCE);
/// getPICJumpTableEntry - Returns the value of the jumptable entry for the
/// specific basic block.