summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bytecode/Writer/Writer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-10-16 18:28:50 +0000
committerChris Lattner <sabre@nondot.org>2003-10-16 18:28:50 +0000
commit2d05c60bac33d65c9f47b3de66534eeccab787e1 (patch)
tree51701c56f9280a1370f2906e68eb071b7aec5a31 /llvm/lib/Bytecode/Writer/Writer.cpp
parent06bd29b53b32c7e3497115ef0f2e11868c2ad154 (diff)
downloadbcm5719-llvm-2d05c60bac33d65c9f47b3de66534eeccab787e1.tar.gz
bcm5719-llvm-2d05c60bac33d65c9f47b3de66534eeccab787e1.zip
Add support for 'weak' linkage.
For now, we translate linkonce into weak linkage in the bytecode format because we don't have enough bits to represent it. We will rev the bytecode version soon anyways, so this will be fixed in the near future. llvm-svn: 9170
Diffstat (limited to 'llvm/lib/Bytecode/Writer/Writer.cpp')
-rw-r--r--llvm/lib/Bytecode/Writer/Writer.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/lib/Bytecode/Writer/Writer.cpp b/llvm/lib/Bytecode/Writer/Writer.cpp
index 413fd293dbd..1e6d63a0f1e 100644
--- a/llvm/lib/Bytecode/Writer/Writer.cpp
+++ b/llvm/lib/Bytecode/Writer/Writer.cpp
@@ -158,6 +158,17 @@ void BytecodeWriter::outputConstants(bool isFunction) {
}
}
+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;
+ }
+}
+
void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
BytecodeBlock ModuleInfoBlock(BytecodeFormat::ModuleGlobalInfo, Out);
@@ -168,7 +179,7 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
// Fields: bit0 = isConstant, bit1 = hasInitializer, bit2,3=Linkage,
// bit4+ = Slot # for type
- unsigned oSlot = ((unsigned)Slot << 4) | ((unsigned)I->getLinkage() << 2) |
+ unsigned oSlot = ((unsigned)Slot << 4) | (getEncodedLinkage(I) << 2) |
(I->hasInitializer() << 1) | I->isConstant();
output_vbr(oSlot, Out);
@@ -195,7 +206,7 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
void BytecodeWriter::outputFunction(const Function *F) {
BytecodeBlock FunctionBlock(BytecodeFormat::Function, Out);
- output_vbr((unsigned)F->getLinkage(), Out);
+ output_vbr(getEncodedLinkage(F), Out);
// Only output the constant pool and other goodies if needed...
if (!F->isExternal()) {
OpenPOWER on IntegriCloud