forked from OSchip/llvm-project
remove more code that was only used by the bc writer
llvm-svn: 32259
This commit is contained in:
parent
7e4e76625e
commit
a9f0a11bcc
|
@ -49,7 +49,6 @@ public:
|
|||
|
||||
/// @brief A mapping of Values to slot numbers
|
||||
typedef std::map<const Value*, unsigned> ValueMap;
|
||||
typedef std::map<const Type*, unsigned> TypeMap;
|
||||
|
||||
/// @brief A plane with next slot number and ValueMap
|
||||
struct ValuePlane {
|
||||
|
@ -58,13 +57,6 @@ public:
|
|||
ValuePlane() { next_slot = 0; } ///< Make sure we start at 0
|
||||
};
|
||||
|
||||
struct TypePlane {
|
||||
unsigned next_slot;
|
||||
TypeMap map;
|
||||
TypePlane() { next_slot = 0; }
|
||||
void clear() { map.clear(); next_slot = 0; }
|
||||
};
|
||||
|
||||
/// @brief The map of planes by Type
|
||||
typedef std::map<const Type*, ValuePlane> TypedPlanes;
|
||||
|
||||
|
@ -86,7 +78,6 @@ public:
|
|||
/// plane. Its an error to ask for something not in the SlotMachine.
|
||||
/// Its an error to ask for a Type*
|
||||
int getSlot(const Value *V);
|
||||
int getSlot(const Type*Ty);
|
||||
|
||||
/// Determine if a Value has a slot or not
|
||||
bool hasSlot(const Value* V);
|
||||
|
@ -149,11 +140,9 @@ public:
|
|||
|
||||
/// @brief The TypePlanes map for the module level data
|
||||
TypedPlanes mMap;
|
||||
TypePlane mTypes;
|
||||
|
||||
/// @brief The TypePlanes map for the function level data
|
||||
TypedPlanes fMap;
|
||||
TypePlane fTypes;
|
||||
|
||||
/// @}
|
||||
|
||||
|
@ -168,12 +157,7 @@ Y("print","Print function to stderr");
|
|||
|
||||
static void WriteAsOperandInternal(std::ostream &Out, const Value *V,
|
||||
bool PrintName,
|
||||
std::map<const Type *, std::string> &TypeTable,
|
||||
SlotMachine *Machine);
|
||||
|
||||
static void WriteAsOperandInternal(std::ostream &Out, const Type *T,
|
||||
bool PrintName,
|
||||
std::map<const Type *, std::string> &TypeTable,
|
||||
std::map<const Type *, std::string> &TypeTable,
|
||||
SlotMachine *Machine);
|
||||
|
||||
static const Module *getModuleFromVal(const Value *V) {
|
||||
|
@ -653,26 +637,6 @@ std::ostream &llvm::WriteAsOperand(std::ostream &Out, const Value *V,
|
|||
return Out;
|
||||
}
|
||||
|
||||
/// WriteAsOperandInternal - Write the name of the specified value out to
|
||||
/// the specified ostream. This can be useful when you just want to print
|
||||
/// int %reg126, not the whole instruction that generated it.
|
||||
///
|
||||
static void WriteAsOperandInternal(std::ostream &Out, const Type *T,
|
||||
bool PrintName,
|
||||
std::map<const Type*, std::string> &TypeTable,
|
||||
SlotMachine *Machine) {
|
||||
Out << ' ';
|
||||
int Slot;
|
||||
if (Machine) {
|
||||
Slot = Machine->getSlot(T);
|
||||
if (Slot != -1)
|
||||
Out << '%' << Slot;
|
||||
else
|
||||
Out << "<badref>";
|
||||
} else {
|
||||
Out << T->getDescription();
|
||||
}
|
||||
}
|
||||
|
||||
/// WriteAsOperand - Write the name of the specified value out to the specified
|
||||
/// ostream. This can be useful when you just want to print int %reg126, not
|
||||
|
@ -686,13 +650,9 @@ std::ostream &llvm::WriteAsOperand(std::ostream &Out, const Type *Ty,
|
|||
|
||||
fillTypeNameTable(Context, TypeNames);
|
||||
|
||||
// if (PrintType)
|
||||
// printTypeInt(Out, V->getType(), TypeNames);
|
||||
|
||||
printTypeInt(Out, Ty, TypeNames);
|
||||
|
||||
WriteAsOperandInternal(Out, Ty, PrintName, TypeNames, 0);
|
||||
return Out;
|
||||
return Out << ' ' << Ty->getDescription();
|
||||
}
|
||||
|
||||
namespace llvm {
|
||||
|
@ -1468,10 +1428,6 @@ SlotMachine::SlotMachine(const Module *M)
|
|||
: TheModule(M) ///< Saved for lazy initialization.
|
||||
, TheFunction(0)
|
||||
, FunctionProcessed(false)
|
||||
, mMap()
|
||||
, mTypes()
|
||||
, fMap()
|
||||
, fTypes()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1481,10 +1437,6 @@ SlotMachine::SlotMachine(const Function *F)
|
|||
: TheModule(F ? F->getParent() : 0) ///< Saved for lazy initialization
|
||||
, TheFunction(F) ///< Saved for lazy initialization
|
||||
, FunctionProcessed(false)
|
||||
, mMap()
|
||||
, mTypes()
|
||||
, fMap()
|
||||
, fTypes()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1547,7 +1499,6 @@ void SlotMachine::processFunction() {
|
|||
void SlotMachine::purgeFunction() {
|
||||
SC_DEBUG("begin purgeFunction!\n");
|
||||
fMap.clear(); // Simply discard the function level map
|
||||
fTypes.clear();
|
||||
TheFunction = 0;
|
||||
FunctionProcessed = false;
|
||||
SC_DEBUG("end purgeFunction!\n");
|
||||
|
@ -1614,45 +1565,6 @@ int SlotMachine::getSlot(const Value *V) {
|
|||
return MVI->second;
|
||||
}
|
||||
|
||||
/// Get the slot number for a value. This function will assert if you
|
||||
/// ask for a Value that hasn't previously been inserted with getOrCreateSlot.
|
||||
/// Types are forbidden because Type does not inherit from Value (any more).
|
||||
int SlotMachine::getSlot(const Type *Ty) {
|
||||
assert(Ty && "Can't get slot for null Type");
|
||||
|
||||
// Check for uninitialized state and do lazy initialization
|
||||
this->initialize();
|
||||
|
||||
if (TheFunction) {
|
||||
// Lookup the Type in the function map
|
||||
TypeMap::const_iterator FTI = fTypes.map.find(Ty);
|
||||
// If the Type doesn't exist in the function map
|
||||
if (FTI == fTypes.map.end()) {
|
||||
TypeMap::const_iterator MTI = mTypes.map.find(Ty);
|
||||
// If we didn't find it, it wasn't inserted
|
||||
if (MTI == mTypes.map.end())
|
||||
return -1;
|
||||
// We found it only at the module level
|
||||
return MTI->second;
|
||||
|
||||
// else the value exists in the function map
|
||||
} else {
|
||||
// Return the slot number as the module's contribution to
|
||||
// the type plane plus the index in the function's contribution
|
||||
// to the type plane.
|
||||
return mTypes.next_slot + FTI->second;
|
||||
}
|
||||
}
|
||||
|
||||
// N.B. Can get here only if either !TheFunction
|
||||
|
||||
// Lookup the value in the module's map
|
||||
TypeMap::const_iterator MTI = mTypes.map.find(Ty);
|
||||
// Make sure we found it.
|
||||
if (MTI == mTypes.map.end()) return -1;
|
||||
// Return it.
|
||||
return MTI->second;
|
||||
}
|
||||
|
||||
// Create a new slot, or return the existing slot if it is already
|
||||
// inserted. Note that the logic here parallels getSlot but instead
|
||||
|
|
Loading…
Reference in New Issue