From: Chris Lattner Date: Sat, 10 Feb 2007 04:22:30 +0000 (+0000) Subject: merge doInsertValue into insertValue X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=75e2cf555cb52e3b22571d8c2953dfabe73d21e3;p=oota-llvm.git merge doInsertValue into insertValue git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34116 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp index a87bf104ebd..99e353cf525 100644 --- a/lib/Bytecode/Writer/SlotCalculator.cpp +++ b/lib/Bytecode/Writer/SlotCalculator.cpp @@ -375,15 +375,55 @@ int SlotCalculator::insertValue(const Value *V) { assert(getSlot(V) == -1 && "Value is already in the table!"); // If this node does not contribute to a plane, ignore the node. - if (V->getType() == Type::VoidTy) { // Ignore void type nodes + const Type *Typ = V->getType(); + if (Typ == Type::VoidTy) { // Ignore void type nodes SC_DEBUG("ignored value " << *V << "\n"); return -1; } - // Okay, everything is happy, actually insert the silly value now... - return doInsertValue(V); + unsigned Ty; + + if (Typ->isDerivedType()) { + 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); + assert(ValSlot != -1 && "ProcessType returned -1 for a type?"); + } + Ty = (unsigned)ValSlot; + } else { + Ty = Typ->getTypeID(); + } + + if (Table.size() <= Ty) // Make sure we have the type plane allocated... + Table.resize(Ty+1, TypePlane()); + + // If this is the first value to get inserted into the type plane, make sure + // to insert the implicit null value... + if (Table[Ty].empty() && hasNullValue(Typ)) { + Value *ZeroInitializer = Constant::getNullValue(Typ); + + // If we are pushing zeroinit, it will be handled below. + if (V != ZeroInitializer) { + Table[Ty].push_back(ZeroInitializer); + NodeMap[ZeroInitializer] = 0; + } + } + + // Insert node into table and NodeMap... + unsigned DestSlot = NodeMap[V] = Table[Ty].size(); + Table[Ty].push_back(V); + + SC_DEBUG(" Inserting value [" << Ty << "] = " << *V << " slot=" << + DestSlot << " ["); + // G = Global, C = Constant, T = Type, F = Function, o = other + SC_DEBUG((isa(V) ? "G" : (isa(V) ? "C" : + (isa(V) ? "F" : "o")))); + SC_DEBUG("]\n"); + return (int)DestSlot; } + int SlotCalculator::getOrCreateTypeSlot(const Type* T) { int SlotNo = getTypeSlot(T); // Check to see if it's already in! if (SlotNo != -1) return SlotNo; @@ -421,56 +461,6 @@ int SlotCalculator::insertType(const Type *Ty) { return ResultSlot; } -// doInsertValue - This is a small helper function to be called only -// be insertValue. -// -int SlotCalculator::doInsertValue(const Value *D) { - const Type *Typ = D->getType(); - unsigned Ty; - - // Used for debugging DefSlot=-1 assertion... - //if (Typ == Type::TypeTy) - // llvm_cerr << "Inserting type '"<(D)->getDescription() <<"'!\n"; - - if (Typ->isDerivedType()) { - 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); - assert(ValSlot != -1 && "ProcessType returned -1 for a type?"); - } - Ty = (unsigned)ValSlot; - } else { - Ty = Typ->getTypeID(); - } - - if (Table.size() <= Ty) // Make sure we have the type plane allocated... - Table.resize(Ty+1, TypePlane()); - - // If this is the first value to get inserted into the type plane, make sure - // to insert the implicit null value... - if (Table[Ty].empty() && hasNullValue(Typ)) { - Value *ZeroInitializer = Constant::getNullValue(Typ); - - // If we are pushing zeroinit, it will be handled below. - if (D != ZeroInitializer) { - Table[Ty].push_back(ZeroInitializer); - NodeMap[ZeroInitializer] = 0; - } - } - - // Insert node into table and NodeMap... - unsigned DestSlot = NodeMap[D] = Table[Ty].size(); - Table[Ty].push_back(D); - - SC_DEBUG(" Inserting value [" << Ty << "] = " << *D << " slot=" << - DestSlot << " ["); - // G = Global, C = Constant, T = Type, F = Function, o = other - SC_DEBUG((isa(D) ? "G" : (isa(D) ? "C" : - (isa(D) ? "F" : "o")))); - SC_DEBUG("]\n"); - return (int)DestSlot; -} // doInsertType - This is a small helper function to be called only // be insertType. diff --git a/lib/Bytecode/Writer/SlotCalculator.h b/lib/Bytecode/Writer/SlotCalculator.h index 54249a73470..10e2e0e96f9 100644 --- a/lib/Bytecode/Writer/SlotCalculator.h +++ b/lib/Bytecode/Writer/SlotCalculator.h @@ -126,7 +126,6 @@ private: int insertType(const Type *T); // doInsertValue - Small helper function to be called only be insertVal. - int doInsertValue(const Value *V); int doInsertType(const Type *T); // processModule - Process all of the module level function declarations and