summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bytecode/Writer/Writer.cpp
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2007-01-12 19:20:47 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2007-01-12 19:20:47 +0000
commita0554d90e87f339b6c0d7482a3e47f4a85c588be (patch)
tree4e989acdda62e6f10c329ed2669c557c15ffb09b /llvm/lib/Bytecode/Writer/Writer.cpp
parente759955c668b72ec15b5e35bdb07bb5b00e65172 (diff)
downloadbcm5719-llvm-a0554d90e87f339b6c0d7482a3e47f4a85c588be.tar.gz
bcm5719-llvm-a0554d90e87f339b6c0d7482a3e47f4a85c588be.zip
* PIC codegen for X86/Linux has been implemented
* PIC-aware internal structures in X86 Codegen have been refactored * Visibility (default/weak) has been added * Docs fixes (external weak linkage, visibility, formatting) llvm-svn: 33136
Diffstat (limited to 'llvm/lib/Bytecode/Writer/Writer.cpp')
-rw-r--r--llvm/lib/Bytecode/Writer/Writer.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/llvm/lib/Bytecode/Writer/Writer.cpp b/llvm/lib/Bytecode/Writer/Writer.cpp
index c7003cdd7f2..10a151d19cf 100644
--- a/llvm/lib/Bytecode/Writer/Writer.cpp
+++ b/llvm/lib/Bytecode/Writer/Writer.cpp
@@ -960,6 +960,14 @@ static unsigned getEncodedLinkage(const GlobalValue *GV) {
}
}
+static unsigned getEncodedVisibility(const GlobalValue *GV) {
+ switch (GV->getVisibility()) {
+ default: assert(0 && "Invalid visibility!");
+ case GlobalValue::DefaultVisibility: return 0;
+ case GlobalValue::HiddenVisibility: return 1;
+ }
+}
+
void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
BytecodeBlock ModuleInfoBlock(BytecodeFormat::ModuleGlobalInfoBlockID, *this);
@@ -979,7 +987,9 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
// Fields: bit0 = isConstant, bit1 = hasInitializer, bit2-4=Linkage,
// bit5+ = Slot # for type.
- bool HasExtensionWord = (I->getAlignment() != 0) || I->hasSection();
+ bool HasExtensionWord = (I->getAlignment() != 0) ||
+ I->hasSection() ||
+ (I->getVisibility() != GlobalValue::DefaultVisibility);
// If we need to use the extension byte, set linkage=3(internal) and
// initializer = 0 (impossible!).
@@ -993,12 +1003,13 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
output_vbr(oSlot);
// The extension word has this format: bit 0 = has initializer, bit 1-3 =
- // linkage, bit 4-8 = alignment (log2), bit 9 = has SectionID,
- // bits 10+ = future use.
+ // linkage, bit 4-8 = alignment (log2), bit 9 = has SectionID,
+ // bits 10-12 = visibility, bits 13+ = future use.
unsigned ExtWord = (unsigned)I->hasInitializer() |
(getEncodedLinkage(I) << 1) |
((Log2_32(I->getAlignment())+1) << 4) |
- ((unsigned)I->hasSection() << 9);
+ ((unsigned)I->hasSection() << 9) |
+ (getEncodedVisibility(I) << 10);
output_vbr(ExtWord);
if (I->hasSection()) {
// Give section names unique ID's.
@@ -1102,7 +1113,8 @@ void BytecodeWriter::outputFunction(const Function *F) {
if (F->isExternal()) return;
BytecodeBlock FunctionBlock(BytecodeFormat::FunctionBlockID, *this);
- output_vbr(getEncodedLinkage(F));
+ unsigned rWord = (getEncodedVisibility(F) << 16) | getEncodedLinkage(F);
+ output_vbr(rWord);
// Get slot information about the function...
Table.incorporateFunction(F);
OpenPOWER on IntegriCloud