forked from OSchip/llvm-project
Add support for representing the "compaction table"
Change protected members to private. Nothing should subclass SlotCalculator llvm-svn: 10912
This commit is contained in:
parent
f78819d9ad
commit
23e583b5dc
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -53,22 +54,50 @@ class SlotCalculator {
|
|||
///
|
||||
std::vector<unsigned> ModuleLevel;
|
||||
|
||||
/// ModuleContainsAllFunctionConstants - This flag is set to true if all
|
||||
/// function constants are incorporated into the module constant table. This
|
||||
/// is only possible if building information for a bytecode file.
|
||||
bool ModuleContainsAllFunctionConstants;
|
||||
|
||||
/// CompactionTable/NodeMap - When function compaction has been performed,
|
||||
/// these entries provide a compacted view of the namespace needed to emit
|
||||
/// instructions in a function body. The 'getSlot()' method automatically
|
||||
/// returns these entries if applicable, or the global entries if not.
|
||||
std::vector<TypePlane> CompactionTable;
|
||||
std::map<const Value*, unsigned> CompactionNodeMap;
|
||||
|
||||
SlotCalculator(const SlotCalculator &); // DO NOT IMPLEMENT
|
||||
void operator=(const SlotCalculator &); // DO NOT IMPLEMENT
|
||||
public:
|
||||
SlotCalculator(const Module *M, bool BuildBytecodeInfo);
|
||||
// Start out in incorp state
|
||||
SlotCalculator(const Function *F, bool BuildBytecodeInfo);
|
||||
|
||||
/// getSlot returns < 0 on error!
|
||||
/// getSlot - Return the slot number of the specified value in it's type
|
||||
/// plane. This returns < 0 on error!
|
||||
///
|
||||
int getSlot(const Value *D) const;
|
||||
int getSlot(const Value *V) const;
|
||||
|
||||
inline unsigned getNumPlanes() const { return Table.size(); }
|
||||
/// getGlobalSlot - Return a slot number from the global table. This can only
|
||||
/// be used when a compaction table is active.
|
||||
unsigned getGlobalSlot(const Value *V) const;
|
||||
|
||||
inline unsigned getNumPlanes() const {
|
||||
if (CompactionTable.empty())
|
||||
return Table.size();
|
||||
else
|
||||
return CompactionTable.size();
|
||||
}
|
||||
inline unsigned getModuleLevel(unsigned Plane) const {
|
||||
return Plane < ModuleLevel.size() ? ModuleLevel[Plane] : 0;
|
||||
}
|
||||
|
||||
inline const TypePlane &getPlane(unsigned Plane) const {
|
||||
return Table[Plane];
|
||||
if (CompactionTable.empty() || CompactionTable.size() <= Plane ||
|
||||
CompactionTable[Plane].empty())
|
||||
return Table[Plane];
|
||||
else
|
||||
return CompactionTable[Plane];
|
||||
}
|
||||
|
||||
/// incorporateFunction/purgeFunction - If you'd like to deal with a function,
|
||||
|
@ -84,8 +113,11 @@ public:
|
|||
string_iterator string_begin() const { return ConstantStrings.begin(); }
|
||||
string_iterator string_end() const { return ConstantStrings.end(); }
|
||||
|
||||
const std::vector<TypePlane> &getCompactionTable() const {
|
||||
return CompactionTable;
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
// getOrCreateSlot - Values can be crammed into here at will... if
|
||||
// they haven't been inserted already, they get inserted, otherwise
|
||||
// they are ignored.
|
||||
|
@ -111,6 +143,9 @@ protected:
|
|||
//
|
||||
void processSymbolTable(const SymbolTable *ST);
|
||||
void processSymbolTableConstants(const SymbolTable *ST);
|
||||
|
||||
void buildCompactionTable(const Function *F);
|
||||
unsigned getOrCreateCompactionTableSlot(const Value *V);
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
|
Loading…
Reference in New Issue