diff options
author | Lauro Ramos Venancio <lauro.venancio@gmail.com> | 2007-04-12 18:42:08 +0000 |
---|---|---|
committer | Lauro Ramos Venancio <lauro.venancio@gmail.com> | 2007-04-12 18:42:08 +0000 |
commit | e6818b2549393d040de019757772b123dde8a4d1 (patch) | |
tree | bb8dc0cae720e551fec2db8f29531b0b009ed665 /llvm/lib/Target/CBackend/CBackend.cpp | |
parent | 749e4668e76ae37566a315b4ace09f306cceb25b (diff) | |
download | bcm5719-llvm-e6818b2549393d040de019757772b123dde8a4d1.tar.gz bcm5719-llvm-e6818b2549393d040de019757772b123dde8a4d1.zip |
Implement Thread Local Storage (TLS) in CBackend.
llvm-svn: 35951
Diffstat (limited to 'llvm/lib/Target/CBackend/CBackend.cpp')
-rw-r--r-- | llvm/lib/Target/CBackend/CBackend.cpp | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/llvm/lib/Target/CBackend/CBackend.cpp b/llvm/lib/Target/CBackend/CBackend.cpp index f4852bf4909..9f64bd17bc5 100644 --- a/llvm/lib/Target/CBackend/CBackend.cpp +++ b/llvm/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()) |