aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode/Writer/SlotCalculator.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/SlotCalculator.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/SlotCalculator.cpp')
-rw-r--r--lib/Bytecode/Writer/SlotCalculator.cpp36
1 files changed, 15 insertions, 21 deletions
diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp
index cf770c4bbc..fdf7174b85 100644
--- a/lib/Bytecode/Writer/SlotCalculator.cpp
+++ b/lib/Bytecode/Writer/SlotCalculator.cpp
@@ -22,6 +22,7 @@
#include "llvm/Instructions.h"
#include "llvm/Module.h"
#include "llvm/SymbolTable.h"
+#include "llvm/TypeSymbolTable.h"
#include "llvm/Type.h"
#include "llvm/Analysis/ConstantsScanner.h"
#include "llvm/ADT/PostOrderIterator.h"
@@ -189,13 +190,14 @@ void SlotCalculator::processModule() {
}
getOrCreateSlot(I->getType());
}
- processSymbolTableConstants(&F->getSymbolTable());
+ processSymbolTableConstants(&F->getValueSymbolTable());
}
// Insert constants that are named at module level into the slot pool so that
// the module symbol table can refer to them...
SC_DEBUG("Inserting SymbolTable values:\n");
- processSymbolTable(&TheModule->getSymbolTable());
+ processTypeSymbolTable(&TheModule->getTypeSymbolTable());
+ processValueSymbolTable(&TheModule->getValueSymbolTable());
// Now that we have collected together all of the information relevant to the
// module, compactify the type table if it is particularly big and outputting
@@ -233,16 +235,18 @@ void SlotCalculator::processModule() {
SC_DEBUG("end processModule!\n");
}
+// processTypeSymbolTable - Insert all of the type sin the specified symbol
+// table.
+void SlotCalculator::processTypeSymbolTable(const TypeSymbolTable *ST) {
+ for (TypeSymbolTable::const_iterator TI = ST->begin(), TE = ST->end();
+ TI != TE; ++TI )
+ getOrCreateSlot(TI->second);
+}
+
// processSymbolTable - Insert all of the values in the specified symbol table
// into the values table...
//
-void SlotCalculator::processSymbolTable(const SymbolTable *ST) {
- // Do the types first.
- for (SymbolTable::type_const_iterator TI = ST->type_begin(),
- TE = ST->type_end(); TI != TE; ++TI )
- getOrCreateSlot(TI->second);
-
- // Now do the values.
+void SlotCalculator::processValueSymbolTable(const SymbolTable *ST) {
for (SymbolTable::plane_const_iterator PI = ST->plane_begin(),
PE = ST->plane_end(); PI != PE; ++PI)
for (SymbolTable::value_const_iterator VI = PI->second.begin(),
@@ -251,11 +255,6 @@ void SlotCalculator::processSymbolTable(const SymbolTable *ST) {
}
void SlotCalculator::processSymbolTableConstants(const SymbolTable *ST) {
- // Do the types first
- for (SymbolTable::type_const_iterator TI = ST->type_begin(),
- TE = ST->type_end(); TI != TE; ++TI )
- getOrCreateSlot(TI->second);
-
// Now do the constant values in all planes
for (SymbolTable::plane_const_iterator PI = ST->plane_begin(),
PE = ST->plane_end(); PI != PE; ++PI)
@@ -306,7 +305,7 @@ void SlotCalculator::incorporateFunction(const Function *F) {
// symbol table references to constants not in the output. Scan for these
// constants now.
//
- processSymbolTableConstants(&F->getSymbolTable());
+ processSymbolTableConstants(&F->getValueSymbolTable());
}
SC_DEBUG("Inserting Instructions:\n");
@@ -468,13 +467,8 @@ void SlotCalculator::buildCompactionTable(const Function *F) {
getOrCreateCompactionTableSlot(I->getOperand(op));
}
- // Do the types in the symbol table
- const SymbolTable &ST = F->getSymbolTable();
- for (SymbolTable::type_const_iterator TI = ST.type_begin(),
- TE = ST.type_end(); TI != TE; ++TI)
- getOrCreateCompactionTableSlot(TI->second);
-
// Now do the constants and global values
+ const SymbolTable &ST = F->getValueSymbolTable();
for (SymbolTable::plane_const_iterator PI = ST.plane_begin(),
PE = ST.plane_end(); PI != PE; ++PI)
for (SymbolTable::value_const_iterator VI = PI->second.begin(),