summaryrefslogtreecommitdiff
path: root/lib/Bytecode/Writer
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-10 04:29:03 +0000
committerChris Lattner <sabre@nondot.org>2007-02-10 04:29:03 +0000
commit44bd331c225f580e56632b4479239b2e6f688002 (patch)
treed6dd70b86c4e272b53a6d48a9f7577e91b071674 /lib/Bytecode/Writer
parent87dddc5262ee6c85a83d9c25dd9cafc544a6d390 (diff)
downloadllvm-44bd331c225f580e56632b4479239b2e6f688002.tar.gz
llvm-44bd331c225f580e56632b4479239b2e6f688002.tar.bz2
llvm-44bd331c225f580e56632b4479239b2e6f688002.tar.xz
inline hasNullValue, rename some variables, simplify some code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34118 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Writer')
-rw-r--r--lib/Bytecode/Writer/SlotCalculator.cpp53
-rw-r--r--lib/Bytecode/Writer/SlotCalculator.h1
2 files changed, 24 insertions, 30 deletions
diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp
index 0b148ec176..8de1d67f29 100644
--- a/lib/Bytecode/Writer/SlotCalculator.cpp
+++ b/lib/Bytecode/Writer/SlotCalculator.cpp
@@ -314,11 +314,6 @@ void SlotCalculator::purgeFunction() {
SC_DEBUG("end purgeFunction!\n");
}
-static inline bool hasNullValue(const Type *Ty) {
- return Ty != Type::LabelTy && Ty != Type::VoidTy && !isa<OpaqueType>(Ty);
-}
-
-
int SlotCalculator::getSlot(const Value *V) const {
std::map<const Value*, unsigned>::const_iterator I = NodeMap.find(V);
if (I != NodeMap.end())
@@ -336,7 +331,8 @@ int SlotCalculator::getTypeSlot(const Type*T) const {
}
int SlotCalculator::getOrCreateSlot(const Value *V) {
- if (V->getType() == Type::VoidTy) return -1;
+ const Type *Ty = V->getType();
+ if (Ty == Type::VoidTy) return -1;
int SlotNo = getSlot(V); // Check to see if it's already in!
if (SlotNo != -1) return SlotNo;
@@ -367,43 +363,42 @@ int SlotCalculator::getOrCreateSlot(const Value *V) {
}
}
- const Type *Typ = V->getType();
- assert(Typ != Type::VoidTy && "Can't handle voidty");
-
- unsigned Ty;
-
- if (Typ->isDerivedType()) {
- int ValSlot = getTypeSlot(Typ);
+ unsigned TyPlane;
+ if (Ty->isDerivedType()) {
+ int ValSlot = getTypeSlot(Ty);
if (ValSlot == -1) { // Have we already entered this type?
// Nope, this is the first we have seen the type, process it.
- ValSlot = insertType(Typ);
+ ValSlot = insertType(Ty);
assert(ValSlot != -1 && "ProcessType returned -1 for a type?");
}
- Ty = (unsigned)ValSlot;
+ TyPlane = (unsigned)ValSlot;
} else {
- Ty = Typ->getTypeID();
+ TyPlane = Ty->getTypeID();
}
- if (Table.size() <= Ty) // Make sure we have the type plane allocated...
- Table.resize(Ty+1, TypePlane());
+ if (Table.size() <= TyPlane) // Make sure we have the type plane allocated.
+ Table.resize(TyPlane+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;
+ // to insert the implicit null value.
+ if (Table[TyPlane].empty()) {
+ // Label's and opaque types can't have a null value.
+ if (Ty != Type::LabelTy && !isa<OpaqueType>(Ty)) {
+ Value *ZeroInitializer = Constant::getNullValue(Ty);
+
+ // If we are pushing zeroinit, it will be handled below.
+ if (V != ZeroInitializer) {
+ Table[TyPlane].push_back(ZeroInitializer);
+ NodeMap[ZeroInitializer] = 0;
+ }
}
}
// Insert node into table and NodeMap...
- unsigned DestSlot = NodeMap[V] = Table[Ty].size();
- Table[Ty].push_back(V);
+ unsigned DestSlot = NodeMap[V] = Table[TyPlane].size();
+ Table[TyPlane].push_back(V);
- SC_DEBUG(" Inserting value [" << Ty << "] = " << *V << " slot=" <<
+ SC_DEBUG(" Inserting value [" << TyPlane << "] = " << *V << " slot=" <<
DestSlot << " [");
// G = Global, C = Constant, T = Type, F = Function, o = other
SC_DEBUG((isa<GlobalVariable>(V) ? "G" : (isa<Constant>(V) ? "C" :
diff --git a/lib/Bytecode/Writer/SlotCalculator.h b/lib/Bytecode/Writer/SlotCalculator.h
index 10e2e0e96f..8837a6013e 100644
--- a/lib/Bytecode/Writer/SlotCalculator.h
+++ b/lib/Bytecode/Writer/SlotCalculator.h
@@ -122,7 +122,6 @@ private:
// slot that it occupies, or -1 if the declaration is to be ignored
// because of the IgnoreNamedNodes flag.
//
- int insertValue(const Value *V);
int insertType(const Type *T);
// doInsertValue - Small helper function to be called only be insertVal.