clean up some sloppy and inconsistent spacing

llvm-svn: 32255
This commit is contained in:
Chris Lattner 2006-12-06 05:12:21 +00:00
parent 54932b015e
commit 23e829acf1
1 changed files with 46 additions and 46 deletions

View File

@ -73,10 +73,10 @@ public:
/// @{ /// @{
public: public:
/// @brief Construct from a module /// @brief Construct from a module
SlotMachine(const Module *M ); SlotMachine(const Module *M);
/// @brief Construct from a function, starting out in incorp state. /// @brief Construct from a function, starting out in incorp state.
SlotMachine(const Function *F ); SlotMachine(const Function *F);
/// @} /// @}
/// @name Accessors /// @name Accessors
@ -119,13 +119,13 @@ private:
/// been inserted already, they get inserted, otherwise they are ignored. /// been inserted already, they get inserted, otherwise they are ignored.
/// Either way, the slot number for the Value* is returned. /// Either way, the slot number for the Value* is returned.
unsigned createSlot(const Value *V); unsigned createSlot(const Value *V);
unsigned createSlot(const Type* Ty); unsigned createSlot(const Type *Ty);
/// Insert a value into the value table. Return the slot number /// Insert a value into the value table. Return the slot number
/// that it now occupies. BadThings(TM) will happen if you insert a /// that it now occupies. BadThings(TM) will happen if you insert a
/// Value that's already been inserted. /// Value that's already been inserted.
unsigned insertValue( const Value *V ); unsigned insertValue(const Value *V);
unsigned insertValue( const Type* Ty); unsigned insertValue(const Type *Ty);
/// Add all of the module level global variables (and their initializers) /// Add all of the module level global variables (and their initializers)
/// and function declarations, but not the contents of those functions. /// and function declarations, but not the contents of those functions.
@ -242,7 +242,7 @@ static void fillTypeNameTable(const Module *M,
if (!M) return; if (!M) return;
const SymbolTable &ST = M->getSymbolTable(); const SymbolTable &ST = M->getSymbolTable();
SymbolTable::type_const_iterator TI = ST.type_begin(); SymbolTable::type_const_iterator TI = ST.type_begin();
for (; TI != ST.type_end(); ++TI ) { for (; TI != ST.type_end(); ++TI) {
// As a heuristic, don't insert pointer to primitive types, because // As a heuristic, don't insert pointer to primitive types, because
// they are used too often to have a single useful name. // they are used too often to have a single useful name.
// //
@ -933,7 +933,7 @@ void AssemblyWriter::printSymbolTable(const SymbolTable &ST) {
// Print the types. // Print the types.
for (SymbolTable::type_const_iterator TI = ST.type_begin(); for (SymbolTable::type_const_iterator TI = ST.type_begin();
TI != ST.type_end(); ++TI ) { TI != ST.type_end(); ++TI) {
Out << "\t" << getLLVMName(TI->first) << " = type "; Out << "\t" << getLLVMName(TI->first) << " = type ";
// Make sure we print out at least one level of the type structure, so // Make sure we print out at least one level of the type structure, so
@ -944,7 +944,7 @@ void AssemblyWriter::printSymbolTable(const SymbolTable &ST) {
// Print the constants, in type plane order. // Print the constants, in type plane order.
for (SymbolTable::plane_const_iterator PI = ST.plane_begin(); for (SymbolTable::plane_const_iterator PI = ST.plane_begin();
PI != ST.plane_end(); ++PI ) { PI != ST.plane_end(); ++PI) {
SymbolTable::value_const_iterator VI = ST.value_begin(PI->first); SymbolTable::value_const_iterator VI = ST.value_begin(PI->first);
SymbolTable::value_const_iterator VE = ST.value_end(PI->first); SymbolTable::value_const_iterator VE = ST.value_end(PI->first);
@ -1417,7 +1417,7 @@ void Type::dump() const { print(std::cerr); llvm_cerr << '\n'; }
void CachedWriter::setModule(const Module *M) { void CachedWriter::setModule(const Module *M) {
delete SC; delete AW; delete SC; delete AW;
if (M) { if (M) {
SC = new SlotMachine(M ); SC = new SlotMachine(M);
AW = new AssemblyWriter(Out, *SC, M, 0); AW = new AssemblyWriter(Out, *SC, M, 0);
} else { } else {
SC = 0; AW = 0; SC = 0; AW = 0;
@ -1479,8 +1479,8 @@ SlotMachine::SlotMachine(const Module *M)
// Function level constructor. Causes the contents of the Module and the one // Function level constructor. Causes the contents of the Module and the one
// function provided to be added to the slot table. // function provided to be added to the slot table.
SlotMachine::SlotMachine(const Function *F ) SlotMachine::SlotMachine(const Function *F)
: TheModule( F ? F->getParent() : 0 ) ///< Saved for lazy initialization : TheModule(F ? F->getParent() : 0) ///< Saved for lazy initialization
, TheFunction(F) ///< Saved for lazy initialization , TheFunction(F) ///< Saved for lazy initialization
, FunctionProcessed(false) , FunctionProcessed(false)
, mMap() , mMap()
@ -1491,11 +1491,11 @@ SlotMachine::SlotMachine(const Function *F )
} }
inline void SlotMachine::initialize(void) { inline void SlotMachine::initialize(void) {
if ( TheModule) { if (TheModule) {
processModule(); processModule();
TheModule = 0; ///< Prevent re-processing next time we're called. TheModule = 0; ///< Prevent re-processing next time we're called.
} }
if ( TheFunction && ! FunctionProcessed) { if (TheFunction && ! FunctionProcessed) {
processFunction(); processFunction();
} }
} }
@ -1561,7 +1561,7 @@ void SlotMachine::purgeFunction() {
/// ask for a Value that hasn't previously been inserted with createSlot. /// ask for a Value that hasn't previously been inserted with createSlot.
/// Types are forbidden because Type does not inherit from Value (any more). /// Types are forbidden because Type does not inherit from Value (any more).
int SlotMachine::getSlot(const Value *V) { int SlotMachine::getSlot(const Value *V) {
assert( V && "Can't get slot for null Value" ); assert(V && "Can't get slot for null Value");
assert(!isa<Constant>(V) || isa<GlobalValue>(V) && assert(!isa<Constant>(V) || isa<GlobalValue>(V) &&
"Can't insert a non-GlobalValue Constant into SlotMachine"); "Can't insert a non-GlobalValue Constant into SlotMachine");
@ -1574,21 +1574,21 @@ int SlotMachine::getSlot(const Value *V) {
// Find the type plane in the module map // Find the type plane in the module map
TypedPlanes::const_iterator MI = mMap.find(VTy); TypedPlanes::const_iterator MI = mMap.find(VTy);
if ( TheFunction ) { if (TheFunction) {
// Lookup the type in the function map too // Lookup the type in the function map too
TypedPlanes::const_iterator FI = fMap.find(VTy); TypedPlanes::const_iterator FI = fMap.find(VTy);
// If there is a corresponding type plane in the function map // If there is a corresponding type plane in the function map
if ( FI != fMap.end() ) { if (FI != fMap.end()) {
// Lookup the Value in the function map // Lookup the Value in the function map
ValueMap::const_iterator FVI = FI->second.map.find(V); ValueMap::const_iterator FVI = FI->second.map.find(V);
// If the value doesn't exist in the function map // If the value doesn't exist in the function map
if ( FVI == FI->second.map.end() ) { if (FVI == FI->second.map.end()) {
// Look up the value in the module map. // Look up the value in the module map.
if (MI == mMap.end()) return -1; if (MI == mMap.end()) return -1;
ValueMap::const_iterator MVI = MI->second.map.find(V); ValueMap::const_iterator MVI = MI->second.map.find(V);
// If we didn't find it, it wasn't inserted // If we didn't find it, it wasn't inserted
if (MVI == MI->second.map.end()) return -1; if (MVI == MI->second.map.end()) return -1;
assert( MVI != MI->second.map.end() && "Value not found"); assert(MVI != MI->second.map.end() && "Value not found");
// We found it only at the module level // We found it only at the module level
return MVI->second; return MVI->second;
@ -1622,16 +1622,16 @@ int SlotMachine::getSlot(const Value *V) {
/// ask for a Value that hasn't previously been inserted with createSlot. /// ask for a Value that hasn't previously been inserted with createSlot.
/// Types are forbidden because Type does not inherit from Value (any more). /// Types are forbidden because Type does not inherit from Value (any more).
int SlotMachine::getSlot(const Type *Ty) { int SlotMachine::getSlot(const Type *Ty) {
assert( Ty && "Can't get slot for null Type" ); assert(Ty && "Can't get slot for null Type");
// Check for uninitialized state and do lazy initialization // Check for uninitialized state and do lazy initialization
this->initialize(); this->initialize();
if ( TheFunction ) { if (TheFunction) {
// Lookup the Type in the function map // Lookup the Type in the function map
TypeMap::const_iterator FTI = fTypes.map.find(Ty); TypeMap::const_iterator FTI = fTypes.map.find(Ty);
// If the Type doesn't exist in the function map // If the Type doesn't exist in the function map
if ( FTI == fTypes.map.end() ) { if (FTI == fTypes.map.end()) {
TypeMap::const_iterator MTI = mTypes.map.find(Ty); TypeMap::const_iterator MTI = mTypes.map.find(Ty);
// If we didn't find it, it wasn't inserted // If we didn't find it, it wasn't inserted
if (MTI == mTypes.map.end()) if (MTI == mTypes.map.end())
@ -1662,7 +1662,7 @@ int SlotMachine::getSlot(const Type *Ty) {
// inserted. Note that the logic here parallels getSlot but instead // inserted. Note that the logic here parallels getSlot but instead
// of asserting when the Value* isn't found, it inserts the value. // of asserting when the Value* isn't found, it inserts the value.
unsigned SlotMachine::createSlot(const Value *V) { unsigned SlotMachine::createSlot(const Value *V) {
assert( V && "Can't insert a null Value to SlotMachine"); assert(V && "Can't insert a null Value to SlotMachine");
assert(!isa<Constant>(V) || isa<GlobalValue>(V) && assert(!isa<Constant>(V) || isa<GlobalValue>(V) &&
"Can't insert a non-GlobalValue Constant into SlotMachine"); "Can't insert a non-GlobalValue Constant into SlotMachine");
@ -1674,22 +1674,22 @@ unsigned SlotMachine::createSlot(const Value *V) {
// Look up the type plane for the Value's type from the module map // Look up the type plane for the Value's type from the module map
TypedPlanes::const_iterator MI = mMap.find(VTy); TypedPlanes::const_iterator MI = mMap.find(VTy);
if ( TheFunction ) { if (TheFunction) {
// Get the type plane for the Value's type from the function map // Get the type plane for the Value's type from the function map
TypedPlanes::const_iterator FI = fMap.find(VTy); TypedPlanes::const_iterator FI = fMap.find(VTy);
// If there is a corresponding type plane in the function map // If there is a corresponding type plane in the function map
if ( FI != fMap.end() ) { if (FI != fMap.end()) {
// Lookup the Value in the function map // Lookup the Value in the function map
ValueMap::const_iterator FVI = FI->second.map.find(V); ValueMap::const_iterator FVI = FI->second.map.find(V);
// If the value doesn't exist in the function map // If the value doesn't exist in the function map
if ( FVI == FI->second.map.end() ) { if (FVI == FI->second.map.end()) {
// If there is no corresponding type plane in the module map // If there is no corresponding type plane in the module map
if ( MI == mMap.end() ) if (MI == mMap.end())
return insertValue(V); return insertValue(V);
// Look up the value in the module map // Look up the value in the module map
ValueMap::const_iterator MVI = MI->second.map.find(V); ValueMap::const_iterator MVI = MI->second.map.find(V);
// If we didn't find it, it wasn't inserted // If we didn't find it, it wasn't inserted
if ( MVI == MI->second.map.end() ) if (MVI == MI->second.map.end())
return insertValue(V); return insertValue(V);
else else
// We found it only at the module level // We found it only at the module level
@ -1697,7 +1697,7 @@ unsigned SlotMachine::createSlot(const Value *V) {
// else the value exists in the function map // else the value exists in the function map
} else { } else {
if ( MI == mMap.end() ) if (MI == mMap.end())
return FVI->second; return FVI->second;
else else
// Return the slot number as the module's contribution to // Return the slot number as the module's contribution to
@ -1709,14 +1709,14 @@ unsigned SlotMachine::createSlot(const Value *V) {
// else there is not a corresponding type plane in the function map // else there is not a corresponding type plane in the function map
} else { } else {
// If the type plane doesn't exists at the module level // If the type plane doesn't exists at the module level
if ( MI == mMap.end() ) { if (MI == mMap.end()) {
return insertValue(V); return insertValue(V);
// else type plane exists at the module level, examine it // else type plane exists at the module level, examine it
} else { } else {
// Look up the value in the module's map // Look up the value in the module's map
ValueMap::const_iterator MVI = MI->second.map.find(V); ValueMap::const_iterator MVI = MI->second.map.find(V);
// If we didn't find it there either // If we didn't find it there either
if ( MVI == MI->second.map.end() ) if (MVI == MI->second.map.end())
// Return the slot number as the module's contribution to // Return the slot number as the module's contribution to
// the type plane plus the index of the function map insertion. // the type plane plus the index of the function map insertion.
return MI->second.next_slot + insertValue(V); return MI->second.next_slot + insertValue(V);
@ -1729,10 +1729,10 @@ unsigned SlotMachine::createSlot(const Value *V) {
// N.B. Can only get here if !TheFunction // N.B. Can only get here if !TheFunction
// If the module map's type plane is not for the Value's type // If the module map's type plane is not for the Value's type
if ( MI != mMap.end() ) { if (MI != mMap.end()) {
// Lookup the value in the module's map // Lookup the value in the module's map
ValueMap::const_iterator MVI = MI->second.map.find(V); ValueMap::const_iterator MVI = MI->second.map.find(V);
if ( MVI != MI->second.map.end() ) if (MVI != MI->second.map.end())
return MVI->second; return MVI->second;
} }
@ -1743,17 +1743,17 @@ unsigned SlotMachine::createSlot(const Value *V) {
// inserted. Note that the logic here parallels getSlot but instead // inserted. Note that the logic here parallels getSlot but instead
// of asserting when the Value* isn't found, it inserts the value. // of asserting when the Value* isn't found, it inserts the value.
unsigned SlotMachine::createSlot(const Type *Ty) { unsigned SlotMachine::createSlot(const Type *Ty) {
assert( Ty && "Can't insert a null Type to SlotMachine"); assert(Ty && "Can't insert a null Type to SlotMachine");
if ( TheFunction ) { if (TheFunction) {
// Lookup the Type in the function map // Lookup the Type in the function map
TypeMap::const_iterator FTI = fTypes.map.find(Ty); TypeMap::const_iterator FTI = fTypes.map.find(Ty);
// If the type doesn't exist in the function map // If the type doesn't exist in the function map
if ( FTI == fTypes.map.end() ) { if (FTI == fTypes.map.end()) {
// Look up the type in the module map // Look up the type in the module map
TypeMap::const_iterator MTI = mTypes.map.find(Ty); TypeMap::const_iterator MTI = mTypes.map.find(Ty);
// If we didn't find it, it wasn't inserted // If we didn't find it, it wasn't inserted
if ( MTI == mTypes.map.end() ) if (MTI == mTypes.map.end())
return insertValue(Ty); return insertValue(Ty);
else else
// We found it only at the module level // We found it only at the module level
@ -1772,7 +1772,7 @@ unsigned SlotMachine::createSlot(const Type *Ty) {
// Lookup the type in the module's map // Lookup the type in the module's map
TypeMap::const_iterator MTI = mTypes.map.find(Ty); TypeMap::const_iterator MTI = mTypes.map.find(Ty);
if ( MTI != mTypes.map.end() ) if (MTI != mTypes.map.end())
return MTI->second; return MTI->second;
return insertValue(Ty); return insertValue(Ty);
@ -1780,14 +1780,14 @@ unsigned SlotMachine::createSlot(const Type *Ty) {
// Low level insert function. Minimal checking is done. This // Low level insert function. Minimal checking is done. This
// function is just for the convenience of createSlot (above). // function is just for the convenience of createSlot (above).
unsigned SlotMachine::insertValue(const Value *V ) { unsigned SlotMachine::insertValue(const Value *V) {
assert(V && "Can't insert a null Value into SlotMachine!"); assert(V && "Can't insert a null Value into SlotMachine!");
assert(!isa<Constant>(V) || isa<GlobalValue>(V) && assert(!isa<Constant>(V) || isa<GlobalValue>(V) &&
"Can't insert a non-GlobalValue Constant into SlotMachine"); "Can't insert a non-GlobalValue Constant into SlotMachine");
// If this value does not contribute to a plane (is void) // If this value does not contribute to a plane (is void)
// or if the value already has a name then ignore it. // or if the value already has a name then ignore it.
if (V->getType() == Type::VoidTy || V->hasName() ) { if (V->getType() == Type::VoidTy || V->hasName()) {
SC_DEBUG("ignored value " << *V << "\n"); SC_DEBUG("ignored value " << *V << "\n");
return 0; // FIXME: Wrong return value return 0; // FIXME: Wrong return value
} }
@ -1795,14 +1795,14 @@ unsigned SlotMachine::insertValue(const Value *V ) {
const Type *VTy = V->getType(); const Type *VTy = V->getType();
unsigned DestSlot = 0; unsigned DestSlot = 0;
if ( TheFunction ) { if (TheFunction) {
TypedPlanes::iterator I = fMap.find( VTy ); TypedPlanes::iterator I = fMap.find(VTy);
if ( I == fMap.end() ) if (I == fMap.end())
I = fMap.insert(std::make_pair(VTy,ValuePlane())).first; I = fMap.insert(std::make_pair(VTy,ValuePlane())).first;
DestSlot = I->second.map[V] = I->second.next_slot++; DestSlot = I->second.map[V] = I->second.next_slot++;
} else { } else {
TypedPlanes::iterator I = mMap.find( VTy ); TypedPlanes::iterator I = mMap.find(VTy);
if ( I == mMap.end() ) if (I == mMap.end())
I = mMap.insert(std::make_pair(VTy,ValuePlane())).first; I = mMap.insert(std::make_pair(VTy,ValuePlane())).first;
DestSlot = I->second.map[V] = I->second.next_slot++; DestSlot = I->second.map[V] = I->second.next_slot++;
} }
@ -1818,12 +1818,12 @@ unsigned SlotMachine::insertValue(const Value *V ) {
// Low level insert function. Minimal checking is done. This // Low level insert function. Minimal checking is done. This
// function is just for the convenience of createSlot (above). // function is just for the convenience of createSlot (above).
unsigned SlotMachine::insertValue(const Type *Ty ) { unsigned SlotMachine::insertValue(const Type *Ty) {
assert(Ty && "Can't insert a null Type into SlotMachine!"); assert(Ty && "Can't insert a null Type into SlotMachine!");
unsigned DestSlot = 0; unsigned DestSlot = 0;
if ( TheFunction ) { if (TheFunction) {
DestSlot = fTypes.map[Ty] = fTypes.next_slot++; DestSlot = fTypes.map[Ty] = fTypes.next_slot++;
} else { } else {
DestSlot = fTypes.map[Ty] = fTypes.next_slot++; DestSlot = fTypes.map[Ty] = fTypes.next_slot++;