1
0
mirror of https://github.com/RPCS3/llvm.git synced 2024-12-21 03:28:31 +00:00

Inline insertValue into CreateModuleSlot/CreateFunctionSlot

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33038 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2007-01-09 08:04:59 +00:00
parent 22990aae5c
commit cf8790aaff

View File

@ -108,9 +108,6 @@ private:
/// CreateFunctionSlot - Insert the specified Value* into the slot table.
void CreateFunctionSlot(const Value *V);
/// Insert a value into the value table.
void insertValue(const Value *V);
/// Add all of the module level global variables (and their initializers)
/// and function declarations, but not the contents of those functions.
void processModule();
@ -1539,7 +1536,20 @@ int SlotMachine::getSlot(const Value *V) {
/// CreateModuleSlot - Insert the specified GlobalValue* into the slot table.
void SlotMachine::CreateModuleSlot(const GlobalValue *V) {
return insertValue(V);
assert(V && "Can't insert a null Value into SlotMachine!");
unsigned DestSlot = 0;
const Type *VTy = V->getType();
TypedPlanes::iterator I = mMap.find(VTy);
if (I == mMap.end())
I = mMap.insert(std::make_pair(VTy,ValuePlane())).first;
DestSlot = I->second.map[V] = I->second.next_slot++;
SC_DEBUG(" Inserting value [" << VTy << "] = " << V << " slot=" <<
DestSlot << " [");
// G = Global, F = Function, o = other
SC_DEBUG((isa<GlobalVariable>(V) ? 'G' : 'F') << "]\n");
}
@ -1547,36 +1557,15 @@ void SlotMachine::CreateModuleSlot(const GlobalValue *V) {
void SlotMachine::CreateFunctionSlot(const Value *V) {
const Type *VTy = V->getType();
assert(VTy != Type::VoidTy && !V->hasName() && "Doesn't need a slot!");
return insertValue(V);
}
// Low level insert function. Minimal checking is done. This
// function is just for the convenience of CreateSlot (above).
void SlotMachine::insertValue(const Value *V) {
assert(V && "Can't insert a null Value into SlotMachine!");
assert(!isa<Constant>(V) || isa<GlobalValue>(V) &&
"Can't insert a non-GlobalValue Constant into SlotMachine");
assert(V->getType() != Type::VoidTy && !V->hasName());
const Type *VTy = V->getType();
unsigned DestSlot = 0;
if (TheFunction) {
TypedPlanes::iterator I = fMap.find(VTy);
if (I == fMap.end())
I = fMap.insert(std::make_pair(VTy,ValuePlane())).first;
DestSlot = I->second.map[V] = I->second.next_slot++;
} else {
TypedPlanes::iterator I = mMap.find(VTy);
if (I == mMap.end())
I = mMap.insert(std::make_pair(VTy,ValuePlane())).first;
DestSlot = I->second.map[V] = I->second.next_slot++;
}
SC_DEBUG(" Inserting value [" << VTy << "] = " << V << " slot=" <<
DestSlot << " [");
TypedPlanes::iterator I = fMap.find(VTy);
if (I == fMap.end())
I = fMap.insert(std::make_pair(VTy,ValuePlane())).first;
DestSlot = I->second.map[V] = I->second.next_slot++;
// G = Global, F = Function, o = other
SC_DEBUG((isa<GlobalVariable>(V) ? 'G' : (isa<Function>(V) ? 'F' : 'o')));
SC_DEBUG("]\n");
}
SC_DEBUG(" Inserting value [" << VTy << "] = " << V << " slot=" <<
DestSlot << " [o]\n");
}