[llvm-commits] CVS: llvm/lib/Bytecode/Writer/SlotCalculator.cpp SlotCalculator.h Writer.cpp
Chris Lattner
sabre at nondot.org
Fri Feb 9 20:15:56 PST 2007
Changes in directory llvm/lib/Bytecode/Writer:
SlotCalculator.cpp updated: 1.84 -> 1.85
SlotCalculator.h updated: 1.29 -> 1.30
Writer.cpp updated: 1.159 -> 1.160
---
Log message:
rename getSlot -> getSlotType and getOrCreateSlot ->getOrCreateTypeSlot
for types.
---
Diffs of the changes: (+43 -42)
SlotCalculator.cpp | 43 ++++++++++++++++++++++---------------------
SlotCalculator.h | 4 ++--
Writer.cpp | 38 +++++++++++++++++++-------------------
3 files changed, 43 insertions(+), 42 deletions(-)
Index: llvm/lib/Bytecode/Writer/SlotCalculator.cpp
diff -u llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.84 llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.85
--- llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.84 Fri Feb 9 09:25:50 2007
+++ llvm/lib/Bytecode/Writer/SlotCalculator.cpp Fri Feb 9 22:15:40 2007
@@ -55,7 +55,7 @@
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
@@ -161,7 +161,7 @@
isa<InlineAsm>(*OI))
getOrCreateSlot(*OI);
}
- getOrCreateSlot(I->getType());
+ getOrCreateTypeSlot(I->getType());
}
}
@@ -212,7 +212,7 @@
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
@@ -237,7 +237,8 @@
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) {
@@ -326,7 +327,7 @@
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;
@@ -369,33 +370,33 @@
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
@@ -414,7 +415,7 @@
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");
@@ -436,7 +437,7 @@
// 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);
Index: llvm/lib/Bytecode/Writer/SlotCalculator.h
diff -u llvm/lib/Bytecode/Writer/SlotCalculator.h:1.29 llvm/lib/Bytecode/Writer/SlotCalculator.h:1.30
--- llvm/lib/Bytecode/Writer/SlotCalculator.h:1.29 Fri Feb 9 09:25:50 2007
+++ llvm/lib/Bytecode/Writer/SlotCalculator.h Fri Feb 9 22:15:40 2007
@@ -73,7 +73,7 @@
/// plane. This returns < 0 on error!
///
int getSlot(const Value *V) const;
- int getSlot(const Type* T) const;
+ int getTypeSlot(const Type* T) const;
inline unsigned getNumPlanes() const { return Table.size(); }
inline unsigned getNumTypes() const { return Types.size(); }
@@ -116,7 +116,7 @@
// they are ignored.
//
int getOrCreateSlot(const Value *V);
- int getOrCreateSlot(const Type *T);
+ int getOrCreateTypeSlot(const Type *T);
// insertValue - Insert a value into the value table... Return the
// slot that it occupies, or -1 if the declaration is to be ignored
Index: llvm/lib/Bytecode/Writer/Writer.cpp
diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.159 llvm/lib/Bytecode/Writer/Writer.cpp:1.160
--- llvm/lib/Bytecode/Writer/Writer.cpp:1.159 Fri Feb 9 12:03:35 2007
+++ llvm/lib/Bytecode/Writer/Writer.cpp Fri Feb 9 22:15:40 2007
@@ -214,7 +214,7 @@
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)));
@@ -226,7 +226,7 @@
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)));
@@ -241,7 +241,7 @@
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());
@@ -250,7 +250,7 @@
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());
@@ -262,7 +262,7 @@
// 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);
}
@@ -274,7 +274,7 @@
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;
@@ -309,7 +309,7 @@
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())
@@ -419,7 +419,7 @@
// 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);
@@ -459,7 +459,7 @@
}
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)) {
@@ -545,7 +545,7 @@
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);
@@ -672,7 +672,7 @@
}
unsigned Type;
- int Slot = Table.getSlot(Ty);
+ int Slot = Table.getTypeSlot(Ty);
assert(Slot != -1 && "Type not available!!?!");
Type = (unsigned)Slot;
@@ -710,7 +710,7 @@
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++;
@@ -887,7 +887,7 @@
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);
@@ -961,7 +961,7 @@
// 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()) &&
@@ -1011,11 +1011,11 @@
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!");
@@ -1062,7 +1062,7 @@
}
}
}
- 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();
@@ -1129,7 +1129,7 @@
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);
}
}
@@ -1165,7 +1165,7 @@
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);
More information about the llvm-commits
mailing list