diff options
author | Chris Lattner <sabre@nondot.org> | 2001-09-18 04:01:05 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-09-18 04:01:05 +0000 |
commit | 3779864fcf9c2b1df53b4841c6d87e92b5bbce4a (patch) | |
tree | 6755ed22c12e875f46dbd2db30c964cf0a323239 /llvm/lib/Bytecode/Writer | |
parent | 7fb14f54f84ab9a49a3eaf50286f65cf24fbe37b (diff) | |
download | bcm5719-llvm-3779864fcf9c2b1df53b4841c6d87e92b5bbce4a.tar.gz bcm5719-llvm-3779864fcf9c2b1df53b4841c6d87e92b5bbce4a.zip |
Add support for global constants, and for initializers for constants
llvm-svn: 598
Diffstat (limited to 'llvm/lib/Bytecode/Writer')
-rw-r--r-- | llvm/lib/Bytecode/Writer/Writer.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/Bytecode/Writer/Writer.cpp b/llvm/lib/Bytecode/Writer/Writer.cpp index e6562f5fb94..da480180a8b 100644 --- a/llvm/lib/Bytecode/Writer/Writer.cpp +++ b/llvm/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); |