diff options
author | Lauro Ramos Venancio <lauro.venancio@gmail.com> | 2007-04-12 18:32:50 +0000 |
---|---|---|
committer | Lauro Ramos Venancio <lauro.venancio@gmail.com> | 2007-04-12 18:32:50 +0000 |
commit | c763552299165b88d34a7d4f2d76ff413cbc7f67 (patch) | |
tree | bf83c987dadf556bcc766f071383969b0812058b /lib/Bytecode | |
parent | 558385fd93a89a3f2186c5c76b6735cea32ac333 (diff) |
Implement the "thread_local" keyword.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35950 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode')
-rw-r--r-- | lib/Bytecode/Reader/Analyzer.cpp | 4 | ||||
-rw-r--r-- | lib/Bytecode/Reader/Reader.cpp | 9 | ||||
-rw-r--r-- | lib/Bytecode/Writer/Writer.cpp | 11 |
3 files changed, 14 insertions, 10 deletions
diff --git a/lib/Bytecode/Reader/Analyzer.cpp b/lib/Bytecode/Reader/Analyzer.cpp index aef482a289..2a752d769c 100644 --- a/lib/Bytecode/Reader/Analyzer.cpp +++ b/lib/Bytecode/Reader/Analyzer.cpp @@ -154,12 +154,14 @@ public: GlobalValue::LinkageTypes Linkage, GlobalValue::VisibilityTypes Visibility, unsigned SlotNum, - unsigned initSlot + unsigned initSlot, + bool isThreadLocal ) { if (os) { *os << " GV: " << ( initSlot == 0 ? "Uni" : "I" ) << "nitialized, " << ( isConstant? "Constant, " : "Variable, ") + << " Thread Local = " << ( isThreadLocal? "yes, " : "no, ") << " Linkage=" << Linkage << " Visibility="<< Visibility << " Type="; diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index fd4a54920f..49792693dc 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -1704,11 +1704,12 @@ void BytecodeReader::ParseModuleGlobalInfo() { unsigned VarType = read_vbr_uint(); while (VarType != Type::VoidTyID) { // List is terminated by Void // VarType Fields: bit0 = isConstant, bit1 = hasInitializer, bit2,3,4 = - // Linkage, bit4+ = slot# - unsigned SlotNo = VarType >> 5; + // Linkage, bit5 = isThreadLocal, bit6+ = slot# + unsigned SlotNo = VarType >> 6; unsigned LinkageID = (VarType >> 2) & 7; unsigned VisibilityID = 0; bool isConstant = VarType & 1; + bool isThreadLocal = (VarType >> 5) & 1; bool hasInitializer = (VarType & 2) != 0; unsigned Alignment = 0; unsigned GlobalSectionID = 0; @@ -1764,7 +1765,7 @@ void BytecodeReader::ParseModuleGlobalInfo() { // Create the global variable... GlobalVariable *GV = new GlobalVariable(ElTy, isConstant, Linkage, - 0, "", TheModule); + 0, "", TheModule, isThreadLocal); GV->setAlignment(Alignment); GV->setVisibility(Visibility); insertValue(GV, SlotNo, ModuleValues); @@ -1781,7 +1782,7 @@ void BytecodeReader::ParseModuleGlobalInfo() { // Notify handler about the global value. if (Handler) Handler->handleGlobalVariable(ElTy, isConstant, Linkage, Visibility, - SlotNo, initSlot); + SlotNo, initSlot, isThreadLocal); // Get next item VarType = read_vbr_uint(); diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index dfc84be037..c48bb223a8 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -950,7 +950,7 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) { "Global must have an initializer or have external linkage!"); // Fields: bit0 = isConstant, bit1 = hasInitializer, bit2-4=Linkage, - // bit5+ = Slot # for type. + // bit5 = isThreadLocal, bit6+ = Slot # for type. bool HasExtensionWord = (I->getAlignment() != 0) || I->hasSection() || (I->getVisibility() != GlobalValue::DefaultVisibility); @@ -958,12 +958,13 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) { // If we need to use the extension byte, set linkage=3(internal) and // initializer = 0 (impossible!). if (!HasExtensionWord) { - unsigned oSlot = (Slot << 5) | (getEncodedLinkage(I) << 2) | - (I->hasInitializer() << 1) | (unsigned)I->isConstant(); + unsigned oSlot = (Slot << 6)| (((unsigned)I->isThreadLocal()) << 5) | + (getEncodedLinkage(I) << 2) | (I->hasInitializer() << 1) + | (unsigned)I->isConstant(); output_vbr(oSlot); } else { - unsigned oSlot = (Slot << 5) | (3 << 2) | - (0 << 1) | (unsigned)I->isConstant(); + unsigned oSlot = (Slot << 6) | (((unsigned)I->isThreadLocal()) << 5) | + (3 << 2) | (0 << 1) | (unsigned)I->isConstant(); output_vbr(oSlot); // The extension word has this format: bit 0 = has initializer, bit 1-3 = |