diff options
author | Chris Lattner <sabre@nondot.org> | 2002-06-25 16:13:21 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-06-25 16:13:21 +0000 |
commit | 0b12b5f50ec77a8bd01b92d287c52d748619bb4b (patch) | |
tree | 5764db59facb124b023f1de96f0e45d37657c82e /lib/Bytecode/Writer/Writer.cpp | |
parent | 18961504fc2b299578dba817900a0696cf3ccc4d (diff) |
MEGAPATCH checkin.
For details, See: docs/2002-06-25-MegaPatchInfo.txt
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2778 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Writer/Writer.cpp')
-rw-r--r-- | lib/Bytecode/Writer/Writer.cpp | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index 145004b716..5545834ff7 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -21,9 +21,6 @@ #include "WriterInternals.h" #include "llvm/Module.h" -#include "llvm/GlobalVariable.h" -#include "llvm/Function.h" -#include "llvm/BasicBlock.h" #include "llvm/SymbolTable.h" #include "llvm/DerivedTypes.h" #include "Support/STLExtras.h" @@ -49,8 +46,8 @@ BytecodeWriter::BytecodeWriter(std::deque<unsigned char> &o, const Module *M) outputModuleInfoBlock(M); // Do the whole module now! Process each function at a time... - for_each(M->begin(), M->end(), - bind_obj(this, &BytecodeWriter::processMethod)); + for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) + processMethod(I); // If needed, output the symbol table for the module... if (M->hasSymbolTable()) @@ -112,19 +109,18 @@ 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) { - const GlobalVariable *GV = *I; - int Slot = Table.getValSlot(GV->getType()); + int Slot = Table.getValSlot(I->getType()); assert(Slot != -1 && "Module global vars is broken!"); // Fields: bit0 = isConstant, bit1 = hasInitializer, bit2=InternalLinkage, // bit3+ = slot# - unsigned oSlot = ((unsigned)Slot << 3) | (GV->hasInternalLinkage() << 2) | - (GV->hasInitializer() << 1) | GV->isConstant(); + unsigned oSlot = ((unsigned)Slot << 3) | (I->hasInternalLinkage() << 2) | + (I->hasInitializer() << 1) | I->isConstant(); output_vbr(oSlot, Out); // If we have an initializer, output it now. - if (GV->hasInitializer()) { - Slot = Table.getValSlot((Value*)GV->getInitializer()); + if (I->hasInitializer()) { + Slot = Table.getValSlot((Value*)I->getInitializer()); assert(Slot != -1 && "No slot for global var initializer!"); output_vbr((unsigned)Slot, Out); } @@ -133,7 +129,7 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) { // Output the types of the functions in this module... for (Module::const_iterator I = M->begin(), End = M->end(); I != End; ++I) { - int Slot = Table.getValSlot((*I)->getType()); + int Slot = Table.getValSlot(I->getType()); assert(Slot != -1 && "Module const pool is broken!"); assert(Slot >= Type::FirstDerivedTyID && "Derived type not in range!"); output_vbr((unsigned)Slot, Out); @@ -144,36 +140,36 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) { align32(Out); } -void BytecodeWriter::processMethod(const Function *M) { +void BytecodeWriter::processMethod(const Function *F) { BytecodeBlock FunctionBlock(BytecodeFormat::Function, Out); - output_vbr((unsigned)M->hasInternalLinkage(), Out); + output_vbr((unsigned)F->hasInternalLinkage(), Out); // Only output the constant pool and other goodies if needed... - if (!M->isExternal()) { + if (!F->isExternal()) { // Get slot information about the function... - Table.incorporateFunction(M); + Table.incorporateFunction(F); // Output information about the constants in the function... outputConstants(true); // Output basic block nodes... - for_each(M->begin(), M->end(), - bind_obj(this, &BytecodeWriter::processBasicBlock)); + for (Function::const_iterator I = F->begin(), E = F->end(); I != E; ++I) + processBasicBlock(*I); // If needed, output the symbol table for the function... - if (M->hasSymbolTable()) - outputSymbolTable(*M->getSymbolTable()); + if (F->hasSymbolTable()) + outputSymbolTable(*F->getSymbolTable()); Table.purgeFunction(); } } -void BytecodeWriter::processBasicBlock(const BasicBlock *BB) { +void BytecodeWriter::processBasicBlock(const BasicBlock &BB) { BytecodeBlock FunctionBlock(BytecodeFormat::BasicBlock, Out); // Process all the instructions in the bb... - for_each(BB->begin(), BB->end(), - bind_obj(this, &BytecodeWriter::processInstruction)); + for(BasicBlock::const_iterator I = BB.begin(), E = BB.end(); I != E; ++I) + processInstruction(*I); } void BytecodeWriter::outputSymbolTable(const SymbolTable &MST) { |