From: Chris Lattner Date: Sat, 18 Oct 2003 06:30:21 +0000 (+0000) Subject: add support for new linkage types X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=22482a14be04acd36dd1564ece09caa8a941a93c;p=oota-llvm.git add support for new linkage types git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9228 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index 1674786fb76..e338c41e526 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -434,14 +434,24 @@ void BytecodeParser::ParseModuleGlobalInfo(const unsigned char *&Buf, GlobalValue::LinkageTypes Linkage; if (!hasInternalMarkerOnly) { - // VarType Fields: bit0 = isConstant, bit1 = hasInitializer, - // bit2,3 = Linkage, bit4+ = slot# - SlotNo = VarType >> 4; - switch ((VarType >> 2) & 3) { + unsigned LinkageID; + if (hasExtendedLinkageSpecs) { + // VarType Fields: bit0 = isConstant, bit1 = hasInitializer, + // bit2,3,4 = Linkage, bit4+ = slot# + SlotNo = VarType >> 5; + LinkageID = (VarType >> 2) & 7; + } else { + // VarType Fields: bit0 = isConstant, bit1 = hasInitializer, + // bit2,3 = Linkage, bit4+ = slot# + SlotNo = VarType >> 4; + LinkageID = (VarType >> 2) & 3; + } + switch (LinkageID) { case 0: Linkage = GlobalValue::ExternalLinkage; break; case 1: Linkage = GlobalValue::WeakLinkage; break; case 2: Linkage = GlobalValue::AppendingLinkage; break; case 3: Linkage = GlobalValue::InternalLinkage; break; + case 4: Linkage = GlobalValue::LinkOnceLinkage; break; } } else { // VarType Fields: bit0 = isConstant, bit1 = hasInitializer, diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index 09684614567..5cc3eec8722 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -162,10 +162,10 @@ static unsigned getEncodedLinkage(const GlobalValue *GV) { switch (GV->getLinkage()) { default: assert(0 && "Invalid linkage!"); case GlobalValue::ExternalLinkage: return 0; - case GlobalValue::LinkOnceLinkage: return 1; case GlobalValue::WeakLinkage: return 1; case GlobalValue::AppendingLinkage: return 2; case GlobalValue::InternalLinkage: return 3; + case GlobalValue::LinkOnceLinkage: return 4; } } @@ -177,9 +177,9 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) { int Slot = Table.getSlot(I->getType()); assert(Slot != -1 && "Module global vars is broken!"); - // Fields: bit0 = isConstant, bit1 = hasInitializer, bit2,3=Linkage, - // bit4+ = Slot # for type - unsigned oSlot = ((unsigned)Slot << 4) | (getEncodedLinkage(I) << 2) | + // Fields: bit0 = isConstant, bit1 = hasInitializer, bit2-4=Linkage, + // bit5+ = Slot # for type + unsigned oSlot = ((unsigned)Slot << 5) | (getEncodedLinkage(I) << 2) | (I->hasInitializer() << 1) | I->isConstant(); output_vbr(oSlot, Out);