insertType(Type::FloatTy, true); // 1: FloatTySlot
insertType(Type::DoubleTy, true); // 2: DoubleTySlot
insertType(Type::LabelTy, true); // 3: LabelTySlot
- assert(TypeMap.size() == Type::FirstDerivedTyID && "Invalid primitive insert");
+ assert(TypeMap.size() == Type::FirstDerivedTyID &&"Invalid primitive insert");
// Above here *must* correspond 1:1 with the primitive types.
insertType(Type::Int1Ty, true); // 4: BoolTySlot
insertType(Type::Int8Ty, true); // 5: Int8TySlot
isa<InlineAsm>(*OI))
getOrCreateSlot(*OI);
}
- getOrCreateSlot(I->getType());
+ getOrCreateTypeSlot(I->getType());
}
}
void SlotCalculator::processTypeSymbolTable(const TypeSymbolTable *TST) {
for (TypeSymbolTable::const_iterator TI = TST->begin(), TE = TST->end();
TI != TE; ++TI )
- getOrCreateSlot(TI->second);
+ getOrCreateTypeSlot(TI->second);
}
// processSymbolTable - Insert all of the values in the specified symbol table
ModuleTypeLevel = Types.size();
// Iterate over function arguments, adding them to the value table...
- for(Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I)
+ for(Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end();
+ I != E; ++I)
getOrCreateSlot(I);
if (!ModuleContainsAllFunctionConstants) {
return -1;
}
-int SlotCalculator::getSlot(const Type*T) const {
+int SlotCalculator::getTypeSlot(const Type*T) const {
std::map<const Type*, unsigned>::const_iterator I = TypeMap.find(T);
if (I != TypeMap.end())
return (int)I->second;
return insertValue(V);
}
-int SlotCalculator::getOrCreateSlot(const Type* T) {
- int SlotNo = getSlot(T); // Check to see if it's already in!
- if (SlotNo != -1) return SlotNo;
- return insertType(T);
-}
-
-int SlotCalculator::insertValue(const Value *D, bool dontIgnore) {
- assert(D && "Can't insert a null value!");
- assert(getSlot(D) == -1 && "Value is already in the table!");
+int SlotCalculator::insertValue(const Value *V, bool dontIgnore) {
+ assert(V && "Can't insert a null value!");
+ assert(getSlot(V) == -1 && "Value is already in the table!");
// If this node does not contribute to a plane, or if the node has a
// name and we don't want names, then ignore the silly node... Note that types
// do need slot numbers so that we can keep track of where other values land.
//
- if (!dontIgnore) // Don't ignore nonignorables!
- if (D->getType() == Type::VoidTy ) { // Ignore void type nodes
- SC_DEBUG("ignored value " << *D << "\n");
+ if (!dontIgnore) // Don't ignore nonignorables!
+ if (V->getType() == Type::VoidTy) { // Ignore void type nodes
+ SC_DEBUG("ignored value " << *V << "\n");
return -1; // We do need types unconditionally though
}
// Okay, everything is happy, actually insert the silly value now...
- return doInsertValue(D);
+ return doInsertValue(V);
+}
+
+int SlotCalculator::getOrCreateTypeSlot(const Type* T) {
+ int SlotNo = getTypeSlot(T); // Check to see if it's already in!
+ if (SlotNo != -1) return SlotNo;
+ return insertType(T);
}
int SlotCalculator::insertType(const Type *Ty, bool dontIgnore) {
assert(Ty && "Can't insert a null type!");
- assert(getSlot(Ty) == -1 && "Type is already in the table!");
+ assert(getTypeSlot(Ty) == -1 && "Type is already in the table!");
// Insert the current type before any subtypes. This is important because
// recursive types elements are inserted in a bottom up order. Changing
if (*I != Ty) {
const Type *SubTy = *I;
// If we haven't seen this sub type before, add it to our type table!
- if (getSlot(SubTy) == -1) {
+ if (getTypeSlot(SubTy) == -1) {
SC_DEBUG(" Inserting subtype: " << SubTy->getDescription() << "\n");
doInsertType(SubTy);
SC_DEBUG(" Inserted subtype: " << SubTy->getDescription() << "\n");
// llvm_cerr << "Inserting type '"<<cast<Type>(D)->getDescription() <<"'!\n";
if (Typ->isDerivedType()) {
- int ValSlot = getSlot(Typ);
+ 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, true);
break;
case Type::FunctionTyID: {
const FunctionType *MT = cast<FunctionType>(T);
- int Slot = Table.getSlot(MT->getReturnType());
+ int Slot = Table.getTypeSlot(MT->getReturnType());
assert(Slot != -1 && "Type used but not available!!");
output_typeid((unsigned)Slot);
output_vbr(unsigned(MT->getParamAttrs(0)));
FunctionType::param_iterator I = MT->param_begin();
unsigned Idx = 1;
for (; I != MT->param_end(); ++I) {
- Slot = Table.getSlot(*I);
+ Slot = Table.getTypeSlot(*I);
assert(Slot != -1 && "Type used but not available!!");
output_typeid((unsigned)Slot);
output_vbr(unsigned(MT->getParamAttrs(Idx)));
case Type::ArrayTyID: {
const ArrayType *AT = cast<ArrayType>(T);
- int Slot = Table.getSlot(AT->getElementType());
+ int Slot = Table.getTypeSlot(AT->getElementType());
assert(Slot != -1 && "Type used but not available!!");
output_typeid((unsigned)Slot);
output_vbr(AT->getNumElements());
case Type::PackedTyID: {
const PackedType *PT = cast<PackedType>(T);
- int Slot = Table.getSlot(PT->getElementType());
+ int Slot = Table.getTypeSlot(PT->getElementType());
assert(Slot != -1 && "Type used but not available!!");
output_typeid((unsigned)Slot);
output_vbr(PT->getNumElements());
// Output all of the element types...
for (StructType::element_iterator I = ST->element_begin(),
E = ST->element_end(); I != E; ++I) {
- int Slot = Table.getSlot(*I);
+ int Slot = Table.getTypeSlot(*I);
assert(Slot != -1 && "Type used but not available!!");
output_typeid((unsigned)Slot);
}
case Type::PointerTyID: {
const PointerType *PT = cast<PointerType>(T);
- int Slot = Table.getSlot(PT->getElementType());
+ int Slot = Table.getTypeSlot(PT->getElementType());
assert(Slot != -1 && "Type used but not available!!");
output_typeid((unsigned)Slot);
break;
int Slot = Table.getSlot(*OI);
assert(Slot != -1 && "Unknown constant used in ConstantExpr!!");
output_vbr((unsigned)Slot);
- Slot = Table.getSlot((*OI)->getType());
+ Slot = Table.getTypeSlot((*OI)->getType());
output_typeid((unsigned)Slot);
}
if (CE->isCompare())
// Emit all of the strings.
for (I = Table.string_begin(); I != E; ++I) {
const ConstantArray *Str = *I;
- int Slot = Table.getSlot(Str->getType());
+ int Slot = Table.getTypeSlot(Str->getType());
assert(Slot != -1 && "Constant string of unknown type?");
output_typeid((unsigned)Slot);
}
if (isa<CastInst>(I) || isa<VAArgInst>(I)) {
- int Slot = Table.getSlot(I->getType());
+ int Slot = Table.getTypeSlot(I->getType());
assert(Slot != -1 && "Cast return type unknown?");
output_typeid((unsigned)Slot);
} else if (isa<CmpInst>(I)) {
for (unsigned i = NumFixedOperands, e = I->getNumOperands(); i != e; ++i) {
// Output Arg Type ID
- int Slot = Table.getSlot(I->getOperand(i)->getType());
+ int Slot = Table.getTypeSlot(I->getOperand(i)->getType());
assert(Slot >= 0 && "No slot number for value!?!?");
output_typeid((unsigned)Slot);
}
unsigned Type;
- int Slot = Table.getSlot(Ty);
+ int Slot = Table.getTypeSlot(Ty);
assert(Slot != -1 && "Type not available!!?!");
Type = (unsigned)Slot;
if (isa<CastInst>(I) || isa<VAArgInst>(I)) {
// Cast has to encode the destination type as the second argument in the
// packet, or else we won't know what type to cast to!
- Slots[1] = Table.getSlot(I.getType());
+ Slots[1] = Table.getTypeSlot(I.getType());
assert(Slots[1] != ~0U && "Cast return type unknown?");
if (Slots[1] > MaxOpSlot) MaxOpSlot = Slots[1];
NumOperands++;
output_vbr(NC);
// Put out the Type ID Number...
- int Slot = Table.getSlot(Plane.front()->getType());
+ int Slot = Table.getTypeSlot(Plane.front()->getType());
assert (Slot != -1 && "Type in constant pool but not in function!!");
output_typeid((unsigned)Slot);
// Output the types for the global variables in the module...
for (Module::const_global_iterator I = M->global_begin(),
End = M->global_end(); I != End; ++I) {
- int Slot = Table.getSlot(I->getType());
+ int Slot = Table.getTypeSlot(I->getType());
assert(Slot != -1 && "Module global vars is broken!");
assert((I->hasInitializer() || !I->hasInternalLinkage()) &&
output_vbr((unsigned)Slot);
}
}
- output_typeid((unsigned)Table.getSlot(Type::VoidTy));
+ output_typeid((unsigned)Table.getTypeSlot(Type::VoidTy));
// Output the types of the functions in this module.
for (Module::const_iterator I = M->begin(), End = M->end(); I != End; ++I) {
- int Slot = Table.getSlot(I->getType());
+ int Slot = Table.getTypeSlot(I->getType());
assert(Slot != -1 && "Module slot calculator is broken!");
assert(Slot >= Type::FirstDerivedTyID && "Derived type not in range!");
assert(((Slot << 6) >> 6) == Slot && "Slot # too big!");
}
}
}
- output_vbr((unsigned)Table.getSlot(Type::VoidTy) << 5);
+ output_vbr((unsigned)Table.getTypeSlot(Type::VoidTy) << 5);
// Emit the list of dependent libraries for the Module.
Module::lib_iterator LI = M->lib_begin();
for (TypeSymbolTable::const_iterator TI = TST.begin(), TE = TST.end();
TI != TE; ++TI) {
// Symtab entry:[def slot #][name]
- output_typeid((unsigned)Table.getSlot(TI->second));
+ output_typeid((unsigned)Table.getTypeSlot(TI->second));
output(TI->first);
}
}
output_vbr((unsigned)PI->second.size());
// Write the slot number of the type for this plane
- Slot = Table.getSlot(PI->first);
+ Slot = Table.getTypeSlot(PI->first);
assert(Slot != -1 && "Type in symtab, but not in table!");
output_typeid((unsigned)Slot);