aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-10 04:22:30 +0000
committerChris Lattner <sabre@nondot.org>2007-02-10 04:22:30 +0000
commit75e2cf555cb52e3b22571d8c2953dfabe73d21e3 (patch)
treef28e5df1f59bc44b3187a5f7bb82871145687db3 /lib/Bytecode
parent618181ea0e128fe7f9c394dc10ac1a497983e5a0 (diff)
merge doInsertValue into insertValue
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34116 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode')
-rw-r--r--lib/Bytecode/Writer/SlotCalculator.cpp96
-rw-r--r--lib/Bytecode/Writer/SlotCalculator.h1
2 files changed, 43 insertions, 54 deletions
diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp
index a87bf104eb..99e353cf52 100644
--- a/lib/Bytecode/Writer/SlotCalculator.cpp
+++ b/lib/Bytecode/Writer/SlotCalculator.cpp
@@ -375,15 +375,55 @@ int SlotCalculator::insertValue(const Value *V) {
assert(getSlot(V) == -1 && "Value is already in the table!");
// If this node does not contribute to a plane, ignore the node.
- if (V->getType() == Type::VoidTy) { // Ignore void type nodes
+ const Type *Typ = V->getType();
+ if (Typ == Type::VoidTy) { // Ignore void type nodes
SC_DEBUG("ignored value " << *V << "\n");
return -1;
}
- // Okay, everything is happy, actually insert the silly value now...
- return doInsertValue(V);
+ unsigned Ty;
+
+ if (Typ->isDerivedType()) {
+ int ValSlot = getTypeSlot(Typ);
+ if (ValSlot == -1) { // Have we already entered this type?
+ // Nope, this is the first we have seen the type, process it.
+ ValSlot = insertType(Typ);
+ assert(ValSlot != -1 && "ProcessType returned -1 for a type?");
+ }
+ Ty = (unsigned)ValSlot;
+ } else {
+ Ty = Typ->getTypeID();
+ }
+
+ if (Table.size() <= Ty) // Make sure we have the type plane allocated...
+ Table.resize(Ty+1, TypePlane());
+
+ // If this is the first value to get inserted into the type plane, make sure
+ // to insert the implicit null value...
+ if (Table[Ty].empty() && hasNullValue(Typ)) {
+ Value *ZeroInitializer = Constant::getNullValue(Typ);
+
+ // If we are pushing zeroinit, it will be handled below.
+ if (V != ZeroInitializer) {
+ Table[Ty].push_back(ZeroInitializer);
+ NodeMap[ZeroInitializer] = 0;
+ }
+ }
+
+ // Insert node into table and NodeMap...
+ unsigned DestSlot = NodeMap[V] = Table[Ty].size();
+ Table[Ty].push_back(V);
+
+ SC_DEBUG(" Inserting value [" << Ty << "] = " << *V << " slot=" <<
+ DestSlot << " [");
+ // G = Global, C = Constant, T = Type, F = Function, o = other
+ SC_DEBUG((isa<GlobalVariable>(V) ? "G" : (isa<Constant>(V) ? "C" :
+ (isa<Function>(V) ? "F" : "o"))));
+ SC_DEBUG("]\n");
+ return (int)DestSlot;
}
+
int SlotCalculator::getOrCreateTypeSlot(const Type* T) {
int SlotNo = getTypeSlot(T); // Check to see if it's already in!
if (SlotNo != -1) return SlotNo;
@@ -421,56 +461,6 @@ int SlotCalculator::insertType(const Type *Ty) {
return ResultSlot;
}
-// doInsertValue - This is a small helper function to be called only
-// be insertValue.
-//
-int SlotCalculator::doInsertValue(const Value *D) {
- const Type *Typ = D->getType();
- unsigned Ty;
-
- // Used for debugging DefSlot=-1 assertion...
- //if (Typ == Type::TypeTy)
- // llvm_cerr << "Inserting type '"<<cast<Type>(D)->getDescription() <<"'!\n";
-
- if (Typ->isDerivedType()) {
- int ValSlot = getTypeSlot(Typ);
- if (ValSlot == -1) { // Have we already entered this type?
- // Nope, this is the first we have seen the type, process it.
- ValSlot = insertType(Typ);
- assert(ValSlot != -1 && "ProcessType returned -1 for a type?");
- }
- Ty = (unsigned)ValSlot;
- } else {
- Ty = Typ->getTypeID();
- }
-
- if (Table.size() <= Ty) // Make sure we have the type plane allocated...
- Table.resize(Ty+1, TypePlane());
-
- // If this is the first value to get inserted into the type plane, make sure
- // to insert the implicit null value...
- if (Table[Ty].empty() && hasNullValue(Typ)) {
- Value *ZeroInitializer = Constant::getNullValue(Typ);
-
- // If we are pushing zeroinit, it will be handled below.
- if (D != ZeroInitializer) {
- Table[Ty].push_back(ZeroInitializer);
- NodeMap[ZeroInitializer] = 0;
- }
- }
-
- // Insert node into table and NodeMap...
- unsigned DestSlot = NodeMap[D] = Table[Ty].size();
- Table[Ty].push_back(D);
-
- SC_DEBUG(" Inserting value [" << Ty << "] = " << *D << " slot=" <<
- DestSlot << " [");
- // G = Global, C = Constant, T = Type, F = Function, o = other
- SC_DEBUG((isa<GlobalVariable>(D) ? "G" : (isa<Constant>(D) ? "C" :
- (isa<Function>(D) ? "F" : "o"))));
- SC_DEBUG("]\n");
- return (int)DestSlot;
-}
// doInsertType - This is a small helper function to be called only
// be insertType.
diff --git a/lib/Bytecode/Writer/SlotCalculator.h b/lib/Bytecode/Writer/SlotCalculator.h
index 54249a7347..10e2e0e96f 100644
--- a/lib/Bytecode/Writer/SlotCalculator.h
+++ b/lib/Bytecode/Writer/SlotCalculator.h
@@ -126,7 +126,6 @@ private:
int insertType(const Type *T);
// doInsertValue - Small helper function to be called only be insertVal.
- int doInsertValue(const Value *V);
int doInsertType(const Type *T);
// processModule - Process all of the module level function declarations and