1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00

Implement Thread Local Storage (TLS) in CBackend.

llvm-svn: 35951
This commit is contained in:
Lauro Ramos Venancio 2007-04-12 18:42:08 +00:00
parent a76c2806de
commit 6c5f53f6ac

View File

@ -1505,22 +1505,23 @@ bool CWriter::doInitialization(Module &M) {
Out << "\n/* External Global Variable Declarations */\n"; Out << "\n/* External Global Variable Declarations */\n";
for (Module::global_iterator I = M.global_begin(), E = M.global_end(); for (Module::global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I) { I != E; ++I) {
if (I->hasExternalLinkage()) {
if (I->hasExternalLinkage() || I->hasExternalWeakLinkage())
Out << "extern "; Out << "extern ";
printType(Out, I->getType()->getElementType(), false, else if (I->hasDLLImportLinkage())
GetValueName(I));
Out << ";\n";
} else if (I->hasDLLImportLinkage()) {
Out << "__declspec(dllimport) "; Out << "__declspec(dllimport) ";
printType(Out, I->getType()->getElementType(), false, else
GetValueName(I)); continue; // Internal Global
Out << ";\n";
} else if (I->hasExternalWeakLinkage()) { // Thread Local Storage
Out << "extern "; if (I->isThreadLocal())
printType(Out, I->getType()->getElementType(), false, Out << "__thread ";
GetValueName(I));
Out << " __EXTERNAL_WEAK__ ;\n"; 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. // Ignore special globals, such as debug info.
if (getGlobalVariableClass(I)) if (getGlobalVariableClass(I))
continue; continue;
if (I->hasInternalLinkage()) if (I->hasInternalLinkage())
Out << "static "; Out << "static ";
else else
Out << "extern "; Out << "extern ";
// Thread Local Storage
if (I->isThreadLocal())
Out << "__thread ";
printType(Out, I->getType()->getElementType(), false, printType(Out, I->getType()->getElementType(), false,
GetValueName(I)); GetValueName(I));
@ -1592,14 +1598,18 @@ bool CWriter::doInitialization(Module &M) {
// Ignore special globals, such as debug info. // Ignore special globals, such as debug info.
if (getGlobalVariableClass(I)) if (getGlobalVariableClass(I))
continue; continue;
if (I->hasInternalLinkage()) if (I->hasInternalLinkage())
Out << "static "; Out << "static ";
else if (I->hasDLLImportLinkage()) else if (I->hasDLLImportLinkage())
Out << "__declspec(dllimport) "; Out << "__declspec(dllimport) ";
else if (I->hasDLLExportLinkage()) else if (I->hasDLLExportLinkage())
Out << "__declspec(dllexport) "; Out << "__declspec(dllexport) ";
// Thread Local Storage
if (I->isThreadLocal())
Out << "__thread ";
printType(Out, I->getType()->getElementType(), false, printType(Out, I->getType()->getElementType(), false,
GetValueName(I)); GetValueName(I));
if (I->hasLinkOnceLinkage()) if (I->hasLinkOnceLinkage())