summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/X86
diff options
context:
space:
mode:
authorNicolas Geoffray <nicolas.geoffray@lip6.fr>2008-10-25 15:41:43 +0000
committerNicolas Geoffray <nicolas.geoffray@lip6.fr>2008-10-25 15:41:43 +0000
commit5457ce9ac34381f3cd66676dfe63d3aeb2620f42 (patch)
tree7224d798aaca619d5c646fc13bdfa85d6420469d /llvm/lib/Target/X86
parentdb30612fc4c61a72b30fe4c3dee92ba436bc483b (diff)
downloadbcm5719-llvm-5457ce9ac34381f3cd66676dfe63d3aeb2620f42.tar.gz
bcm5719-llvm-5457ce9ac34381f3cd66676dfe63d3aeb2620f42.zip
Support for allocation of TLS variables in the JIT. Allocation of a global
variable is moved to the execution engine. The JIT calls the TargetJITInfo to allocate thread local storage. Currently, only linux/x86 knows how to allocate thread local global variables. llvm-svn: 58142
Diffstat (limited to 'llvm/lib/Target/X86')
-rw-r--r--llvm/lib/Target/X86/X86JITInfo.cpp10
-rw-r--r--llvm/lib/Target/X86/X86JITInfo.h11
2 files changed, 20 insertions, 1 deletions
diff --git a/llvm/lib/Target/X86/X86JITInfo.cpp b/llvm/lib/Target/X86/X86JITInfo.cpp
index 7b3a0703277..f8761dc87e2 100644
--- a/llvm/lib/Target/X86/X86JITInfo.cpp
+++ b/llvm/lib/Target/X86/X86JITInfo.cpp
@@ -518,3 +518,13 @@ void X86JITInfo::relocate(void *Function, MachineRelocation *MR,
}
}
}
+
+char* X86JITInfo::allocateThreadLocalMemory(size_t size) {
+#if defined(X86_32_JIT) && !defined(__APPLE__) && !defined(_MSC_VER)
+ TLSOffset -= size;
+ return TLSOffset;
+#else
+ assert(0 && "Cannot allocate thread local storage on this arch!\n");
+ return 0;
+#endif
+}
diff --git a/llvm/lib/Target/X86/X86JITInfo.h b/llvm/lib/Target/X86/X86JITInfo.h
index f9fcefecff5..6b8d197846b 100644
--- a/llvm/lib/Target/X86/X86JITInfo.h
+++ b/llvm/lib/Target/X86/X86JITInfo.h
@@ -23,8 +23,12 @@ namespace llvm {
class X86JITInfo : public TargetJITInfo {
X86TargetMachine &TM;
intptr_t PICBase;
+ char* TLSOffset;
public:
- explicit X86JITInfo(X86TargetMachine &tm) : TM(tm) {useGOT = 0;}
+ explicit X86JITInfo(X86TargetMachine &tm) : TM(tm) {
+ useGOT = 0;
+ TLSOffset = 0;
+ }
/// replaceMachineCodeForFunction - Make it so that calling the function
/// whose machine code is at OLD turns into a call to NEW, perhaps by
@@ -56,6 +60,11 @@ namespace llvm {
/// referenced global symbols.
virtual void relocate(void *Function, MachineRelocation *MR,
unsigned NumRelocs, unsigned char* GOTBase);
+
+ /// allocateThreadLocalMemory - Each target has its own way of
+ /// handling thread local variables. This method returns a value only
+ /// meaningful to the target.
+ virtual char* allocateThreadLocalMemory(size_t size);
/// setPICBase / getPICBase - Getter / setter of PICBase, used to compute
/// PIC jumptable entry.
OpenPOWER on IntegriCloud