For PR411:

Take an incremental step towards type plane elimination. This change
separates types from values in the symbol tables by finally making use
of the TypeSymbolTable class. This yields more natural interfaces for
dealing with types and unclutters the SymbolTable class.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32956 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer
2007-01-06 07:24:44 +00:00
parent f8383def5c
commit 78d033e086
31 changed files with 241 additions and 344 deletions

View File

@@ -27,6 +27,7 @@
#include "llvm/Instructions.h"
#include "llvm/Module.h"
#include "llvm/SymbolTable.h"
#include "llvm/TypeSymbolTable.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/Compressor.h"
#include "llvm/Support/MathExtras.h"
@@ -837,8 +838,11 @@ BytecodeWriter::BytecodeWriter(std::vector<unsigned char> &o, const Module *M)
for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I)
outputFunction(I);
// If needed, output the symbol table for the module...
outputSymbolTable(M->getSymbolTable());
// Output the symbole table for types
outputTypeSymbolTable(M->getTypeSymbolTable());
// Output the symbol table for values
outputValueSymbolTable(M->getValueSymbolTable());
}
void BytecodeWriter::outputTypes(unsigned TypeNum) {
@@ -1112,7 +1116,7 @@ void BytecodeWriter::outputFunction(const Function *F) {
outputInstructions(F);
// If needed, output the symbol table for the function...
outputSymbolTable(F->getSymbolTable());
outputValueSymbolTable(F->getValueSymbolTable());
Table.purgeFunction();
}
@@ -1187,24 +1191,33 @@ void BytecodeWriter::outputCompactionTable() {
}
}
void BytecodeWriter::outputSymbolTable(const SymbolTable &MST) {
// Do not output the Bytecode block for an empty symbol table, it just wastes
void BytecodeWriter::outputTypeSymbolTable(const TypeSymbolTable &TST) {
// Do not output the block for an empty symbol table, it just wastes
// space!
if (MST.isEmpty()) return;
if (TST.empty()) return;
BytecodeBlock SymTabBlock(BytecodeFormat::SymbolTableBlockID, *this,
// Create a header for the symbol table
BytecodeBlock SymTabBlock(BytecodeFormat::TypeSymbolTableBlockID, *this,
true/*ElideIfEmpty*/);
// Write the number of types
output_vbr(MST.num_types());
output_vbr(TST.size());
// Write each of the types
for (SymbolTable::type_const_iterator TI = MST.type_begin(),
TE = MST.type_end(); TI != TE; ++TI) {
for (TypeSymbolTable::const_iterator TI = TST.begin(), TE = TST.end();
TI != TE; ++TI) {
// Symtab entry:[def slot #][name]
output_typeid((unsigned)Table.getSlot(TI->second));
output(TI->first);
}
}
void BytecodeWriter::outputValueSymbolTable(const SymbolTable &MST) {
// Do not output the Bytecode block for an empty symbol table, it just wastes
// space!
if (MST.isEmpty()) return;
BytecodeBlock SymTabBlock(BytecodeFormat::ValueSymbolTableBlockID, *this,
true/*ElideIfEmpty*/);
// Now do each of the type planes in order.
for (SymbolTable::plane_const_iterator PI = MST.plane_begin(),