Emit the SubRegTable with the smallest possible integer type.

Doesn't help ARM with its massive register set, but halves the size on x86 and all other targets.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151760 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer 2012-02-29 21:57:08 +00:00
parent eea87153d1
commit b9ace0215d
4 changed files with 14 additions and 11 deletions

View File

@ -2008,15 +2008,6 @@ static bool EmitMnemonicAliases(raw_ostream &OS, const AsmMatcherInfo &Info) {
return true;
}
static const char *getMinimalTypeForRange(uint64_t Range) {
assert(Range < 0xFFFFFFFFULL && "Enum too large");
if (Range > 0xFFFF)
return "uint32_t";
if (Range > 0xFF)
return "uint16_t";
return "uint8_t";
}
static void EmitCustomOperandParsing(raw_ostream &OS, CodeGenTarget &Target,
const AsmMatcherInfo &Info, StringRef ClassName) {
// Emit the static custom operand parsing table;

View File

@ -108,6 +108,14 @@ std::string llvm::getQualifiedName(const Record *R) {
return Namespace + "::" + R->getName();
}
const char *llvm::getMinimalTypeForRange(uint64_t Range) {
assert(Range < 0xFFFFFFFFULL && "Enum too large");
if (Range > 0xFFFF)
return "uint32_t";
if (Range > 0xFF)
return "uint16_t";
return "uint8_t";
}
/// getTarget - Return the current instance of the Target class.
///

View File

@ -58,6 +58,10 @@ std::string getEnumName(MVT::SimpleValueType T);
/// namespace qualifier if the record contains one.
std::string getQualifiedName(const Record *R);
/// getMinimalTypeForRange - Helper method to get the minimum data type required
/// to represent Range.
const char *getMinimalTypeForRange(uint64_t Range);
/// CodeGenTarget - This class corresponds to the Target class in the .td files.
///
class CodeGenTarget {

View File

@ -736,8 +736,8 @@ RegisterInfoEmitter::runTargetDesc(raw_ostream &OS, CodeGenTarget &Target,
// Emit the data table for getSubReg().
if (SubRegIndices.size()) {
OS << "static const unsigned short " << TargetName << "SubRegTable[]["
<< SubRegIndices.size() << "] = {\n";
OS << "static const " << getMinimalTypeForRange(Regs.size()) << ' '
<< TargetName << "SubRegTable[][" << SubRegIndices.size() << "] = {\n";
for (unsigned i = 0, e = Regs.size(); i != e; ++i) {
const CodeGenRegister::SubRegMap &SRM = Regs[i]->getSubRegs();
OS << " /* " << Regs[i]->TheDef->getName() << " */\n";