[llvm-commits] CVS: llvm/lib/Bytecode/Writer/SlotCalculator.cpp SlotCalculator.h
Chris Lattner
sabre at nondot.org
Fri Feb 9 20:29:19 PST 2007
Changes in directory llvm/lib/Bytecode/Writer:
SlotCalculator.cpp updated: 1.89 -> 1.90
SlotCalculator.h updated: 1.33 -> 1.34
---
Log message:
inline hasNullValue, rename some variables, simplify some code.
---
Diffs of the changes: (+24 -30)
SlotCalculator.cpp | 53 ++++++++++++++++++++++++-----------------------------
SlotCalculator.h | 1 -
2 files changed, 24 insertions(+), 30 deletions(-)
Index: llvm/lib/Bytecode/Writer/SlotCalculator.cpp
diff -u llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.89 llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.90
--- llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.89 Fri Feb 9 22:25:02 2007
+++ llvm/lib/Bytecode/Writer/SlotCalculator.cpp Fri Feb 9 22:29:03 2007
@@ -314,11 +314,6 @@
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::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 @@
}
}
- 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" :
Index: llvm/lib/Bytecode/Writer/SlotCalculator.h
diff -u llvm/lib/Bytecode/Writer/SlotCalculator.h:1.33 llvm/lib/Bytecode/Writer/SlotCalculator.h:1.34
--- llvm/lib/Bytecode/Writer/SlotCalculator.h:1.33 Fri Feb 9 22:22:30 2007
+++ llvm/lib/Bytecode/Writer/SlotCalculator.h Fri Feb 9 22:29:03 2007
@@ -122,7 +122,6 @@
// 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.
More information about the llvm-commits
mailing list