summaryrefslogtreecommitdiff
path: root/lib/Target/CBackend
diff options
context:
space:
mode:
authorLauro Ramos Venancio <lauro.venancio@gmail.com>2007-04-12 18:42:08 +0000
committerLauro Ramos Venancio <lauro.venancio@gmail.com>2007-04-12 18:42:08 +0000
commit26ca64c884c0c74a91ec18b0451cddfce464af02 (patch)
tree384d7b362eb694239d7e860a6df7cfa8a26a6fc7 /lib/Target/CBackend
parentc763552299165b88d34a7d4f2d76ff413cbc7f67 (diff)
downloadllvm-26ca64c884c0c74a91ec18b0451cddfce464af02.tar.gz
llvm-26ca64c884c0c74a91ec18b0451cddfce464af02.tar.bz2
llvm-26ca64c884c0c74a91ec18b0451cddfce464af02.tar.xz
Implement Thread Local Storage (TLS) in CBackend.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35951 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/CBackend')
-rw-r--r--lib/Target/CBackend/CBackend.cpp44
1 files changed, 27 insertions, 17 deletions
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index f4852bf490..9f64bd17bc 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -1505,22 +1505,23 @@ bool CWriter::doInitialization(Module &M) {
Out << "\n/* External Global Variable Declarations */\n";
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I) {
- if (I->hasExternalLinkage()) {
+
+ if (I->hasExternalLinkage() || I->hasExternalWeakLinkage())
Out << "extern ";
- printType(Out, I->getType()->getElementType(), false,
- GetValueName(I));
- Out << ";\n";
- } else if (I->hasDLLImportLinkage()) {
+ else if (I->hasDLLImportLinkage())
Out << "__declspec(dllimport) ";
- printType(Out, I->getType()->getElementType(), false,
- GetValueName(I));
- Out << ";\n";
- } else if (I->hasExternalWeakLinkage()) {
- Out << "extern ";
- printType(Out, I->getType()->getElementType(), false,
- GetValueName(I));
- Out << " __EXTERNAL_WEAK__ ;\n";
- }
+ else
+ continue; // Internal Global
+
+ // Thread Local Storage
+ if (I->isThreadLocal())
+ Out << "__thread ";
+
+ printType(Out, I->getType()->getElementType(), false, GetValueName(I));
+
+ if (I->hasExternalWeakLinkage())
+ Out << " __EXTERNAL_WEAK__";
+ Out << ";\n";
}
}
@@ -1563,11 +1564,16 @@ bool CWriter::doInitialization(Module &M) {
// Ignore special globals, such as debug info.
if (getGlobalVariableClass(I))
continue;
-
+
if (I->hasInternalLinkage())
Out << "static ";
else
Out << "extern ";
+
+ // Thread Local Storage
+ if (I->isThreadLocal())
+ Out << "__thread ";
+
printType(Out, I->getType()->getElementType(), false,
GetValueName(I));
@@ -1592,14 +1598,18 @@ bool CWriter::doInitialization(Module &M) {
// Ignore special globals, such as debug info.
if (getGlobalVariableClass(I))
continue;
-
+
if (I->hasInternalLinkage())
Out << "static ";
else if (I->hasDLLImportLinkage())
Out << "__declspec(dllimport) ";
else if (I->hasDLLExportLinkage())
Out << "__declspec(dllexport) ";
-
+
+ // Thread Local Storage
+ if (I->isThreadLocal())
+ Out << "__thread ";
+
printType(Out, I->getType()->getElementType(), false,
GetValueName(I));
if (I->hasLinkOnceLinkage())