aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode/Writer/Writer.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-01-06 07:24:44 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-01-06 07:24:44 +0000
commit78d033e086e19e016273de014f9214aa6f3f844b (patch)
tree3af27ec8e6611c9380be3b8ce3e643138488851c /lib/Bytecode/Writer/Writer.cpp
parentf8383def5c31acfab4fd55c9fb395d417fd65c45 (diff)
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
Diffstat (limited to 'lib/Bytecode/Writer/Writer.cpp')
-rw-r--r--lib/Bytecode/Writer/Writer.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp
index 58cc13a141..37e4abfae2 100644
--- a/lib/Bytecode/Writer/Writer.cpp
+++ b/lib/Bytecode/Writer/Writer.cpp
@@ -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(),