aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode/Writer/Writer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-09-18 04:01:05 +0000
committerChris Lattner <sabre@nondot.org>2001-09-18 04:01:05 +0000
commitd70684f7585a85c4248c1c224059478108741c70 (patch)
tree17d40698895d1c3efb8655ec7059be714bb940e7 /lib/Bytecode/Writer/Writer.cpp
parent1781acab34447ad679c5c952ec12c942fb63f887 (diff)
Add support for global constants, and for initializers for constants
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@598 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Writer/Writer.cpp')
-rw-r--r--lib/Bytecode/Writer/Writer.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp
index e6562f5fb9..da480180a8 100644
--- a/lib/Bytecode/Writer/Writer.cpp
+++ b/lib/Bytecode/Writer/Writer.cpp
@@ -120,9 +120,21 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
// Output the types for the global variables in the module...
for (Module::const_giterator I = M->gbegin(), End = M->gend(); I != End;++I) {
- int Slot = Table.getValSlot((*I)->getType());
+ const GlobalVariable *GV = *I;
+ int Slot = Table.getValSlot(GV->getType());
assert(Slot != -1 && "Module global vars is broken!");
- output_vbr((unsigned)Slot, Out);
+
+ // Fields: bit0 = isConstant, bit1 = hasInitializer, bit2+ = slot#
+ unsigned oSlot = ((unsigned)Slot << 2) | (GV->hasInitializer() << 1) |
+ GV->isConstant();
+ output_vbr(oSlot, Out);
+
+ // If we have an initialized, output it now.
+ if (GV->hasInitializer()) {
+ Slot = Table.getValSlot(GV->getInitializer());
+ assert(Slot != -1 && "No slot for global var initializer!");
+ output_vbr((unsigned)Slot, Out);
+ }
}
output_vbr((unsigned)Table.getValSlot(Type::VoidTy), Out);