mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-21 03:53:04 +02:00
simplify code.
llvm-svn: 34123
This commit is contained in:
parent
8e07ddf937
commit
fea071b3c8
@ -64,12 +64,11 @@ void SlotCalculator::insertPrimitives() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SlotCalculator::SlotCalculator(const Module *M) {
|
SlotCalculator::SlotCalculator(const Module *M) {
|
||||||
|
assert(M);
|
||||||
ModuleTypeLevel = 0;
|
ModuleTypeLevel = 0;
|
||||||
TheModule = M;
|
TheModule = M;
|
||||||
|
|
||||||
insertPrimitives();
|
insertPrimitives();
|
||||||
|
|
||||||
if (M == 0) return; // Empty table...
|
|
||||||
processModule();
|
processModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,19 +323,7 @@ int SlotCalculator::getOrCreateSlot(const Value *V) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned TyPlane;
|
unsigned TyPlane = getOrCreateTypeSlot(Ty);
|
||||||
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(Ty);
|
|
||||||
assert(ValSlot != -1 && "ProcessType returned -1 for a type?");
|
|
||||||
}
|
|
||||||
TyPlane = (unsigned)ValSlot;
|
|
||||||
} else {
|
|
||||||
TyPlane = Ty->getTypeID();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Table.size() <= TyPlane) // Make sure we have the type plane allocated.
|
if (Table.size() <= TyPlane) // Make sure we have the type plane allocated.
|
||||||
Table.resize(TyPlane+1, TypePlane());
|
Table.resize(TyPlane+1, TypePlane());
|
||||||
|
|
||||||
@ -369,13 +356,13 @@ int SlotCalculator::getOrCreateSlot(const Value *V) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SlotCalculator::getOrCreateTypeSlot(const Type* T) {
|
unsigned SlotCalculator::getOrCreateTypeSlot(const Type* T) {
|
||||||
int SlotNo = getTypeSlot(T); // Check to see if it's already in!
|
int SlotNo = getTypeSlot(T); // Check to see if it's already in!
|
||||||
if (SlotNo != -1) return SlotNo;
|
if (SlotNo != -1) return (unsigned)SlotNo;
|
||||||
return insertType(T);
|
return insertType(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SlotCalculator::insertType(const Type *Ty) {
|
unsigned SlotCalculator::insertType(const Type *Ty) {
|
||||||
assert(Ty && "Can't insert a null type!");
|
assert(Ty && "Can't insert a null type!");
|
||||||
assert(getTypeSlot(Ty) == -1 && "Type is already in the table!");
|
assert(getTypeSlot(Ty) == -1 && "Type is already in the table!");
|
||||||
|
|
||||||
@ -385,7 +372,7 @@ int SlotCalculator::insertType(const Type *Ty) {
|
|||||||
//
|
//
|
||||||
// global { \2 * } { { \2 }* null }
|
// global { \2 * } { { \2 }* null }
|
||||||
//
|
//
|
||||||
int ResultSlot = doInsertType(Ty);
|
unsigned ResultSlot = doInsertType(Ty);
|
||||||
SC_DEBUG(" Inserted type: " << Ty->getDescription() << " slot=" <<
|
SC_DEBUG(" Inserted type: " << Ty->getDescription() << " slot=" <<
|
||||||
ResultSlot << "\n");
|
ResultSlot << "\n");
|
||||||
|
|
||||||
@ -394,13 +381,8 @@ int SlotCalculator::insertType(const Type *Ty) {
|
|||||||
for (po_iterator<const Type*> I = po_begin(Ty), E = po_end(Ty);
|
for (po_iterator<const Type*> I = po_begin(Ty), E = po_end(Ty);
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
if (*I != Ty) {
|
if (*I != Ty) {
|
||||||
const Type *SubTy = *I;
|
|
||||||
// If we haven't seen this sub type before, add it to our type table!
|
// If we haven't seen this sub type before, add it to our type table!
|
||||||
if (getTypeSlot(SubTy) == -1) {
|
getOrCreateTypeSlot(*I);
|
||||||
SC_DEBUG(" Inserting subtype: " << SubTy->getDescription() << "\n");
|
|
||||||
doInsertType(SubTy);
|
|
||||||
SC_DEBUG(" Inserted subtype: " << SubTy->getDescription() << "\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ResultSlot;
|
return ResultSlot;
|
||||||
@ -410,12 +392,10 @@ int SlotCalculator::insertType(const Type *Ty) {
|
|||||||
// doInsertType - This is a small helper function to be called only
|
// doInsertType - This is a small helper function to be called only
|
||||||
// be insertType.
|
// be insertType.
|
||||||
//
|
//
|
||||||
int SlotCalculator::doInsertType(const Type *Ty) {
|
unsigned SlotCalculator::doInsertType(const Type *Ty) {
|
||||||
|
// Insert into TypeMap.
|
||||||
// Insert node into table and NodeMap...
|
|
||||||
unsigned DestSlot = TypeMap[Ty] = Types.size();
|
unsigned DestSlot = TypeMap[Ty] = Types.size();
|
||||||
Types.push_back(Ty);
|
Types.push_back(Ty);
|
||||||
|
|
||||||
SC_DEBUG(" Inserting type [" << DestSlot << "] = " << *Ty << "\n" );
|
SC_DEBUG(" Inserting type [" << DestSlot << "] = " << *Ty << "\n" );
|
||||||
return (int)DestSlot;
|
return DestSlot;
|
||||||
}
|
}
|
||||||
|
@ -109,16 +109,16 @@ private:
|
|||||||
// they are ignored.
|
// they are ignored.
|
||||||
//
|
//
|
||||||
int getOrCreateSlot(const Value *V);
|
int getOrCreateSlot(const Value *V);
|
||||||
int getOrCreateTypeSlot(const Type *T);
|
unsigned getOrCreateTypeSlot(const Type *T);
|
||||||
|
|
||||||
// insertValue - Insert a value into the value table... Return the
|
// insertValue - Insert a value into the value table... Return the
|
||||||
// slot that it occupies, or -1 if the declaration is to be ignored
|
// slot that it occupies, or -1 if the declaration is to be ignored
|
||||||
// because of the IgnoreNamedNodes flag.
|
// because of the IgnoreNamedNodes flag.
|
||||||
//
|
//
|
||||||
int insertType(const Type *T);
|
unsigned insertType(const Type *T);
|
||||||
|
|
||||||
// doInsertValue - Small helper function to be called only be insertVal.
|
// doInsertValue - Small helper function to be called only be insertVal.
|
||||||
int doInsertType(const Type *T);
|
unsigned doInsertType(const Type *T);
|
||||||
|
|
||||||
// processModule - Process all of the module level function declarations and
|
// processModule - Process all of the module level function declarations and
|
||||||
// types that are available.
|
// types that are available.
|
||||||
|
Loading…
Reference in New Issue
Block a user