aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-02-29 21:57:08 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-02-29 21:57:08 +0000
commitc80c3fd5a7a75a33e0e740ebd3ff3d9b3054ec1f (patch)
treeacf2565c44f4492168a54631d30492fcd8269ac7 /llvm/utils/TableGen
parentbc34a59d8f8df7f8b71ed37b5d5b88c825bc5503 (diff)
downloadllvm-c80c3fd5a7a75a33e0e740ebd3ff3d9b3054ec1f.zip
llvm-c80c3fd5a7a75a33e0e740ebd3ff3d9b3054ec1f.tar.gz
llvm-c80c3fd5a7a75a33e0e740ebd3ff3d9b3054ec1f.tar.bz2
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. llvm-svn: 151760
Diffstat (limited to 'llvm/utils/TableGen')
-rw-r--r--llvm/utils/TableGen/AsmMatcherEmitter.cpp9
-rw-r--r--llvm/utils/TableGen/CodeGenTarget.cpp8
-rw-r--r--llvm/utils/TableGen/CodeGenTarget.h4
-rw-r--r--llvm/utils/TableGen/RegisterInfoEmitter.cpp4
4 files changed, 14 insertions, 11 deletions
diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
index 80467ff..88e787c 100644
--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
@@ -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;
diff --git a/llvm/utils/TableGen/CodeGenTarget.cpp b/llvm/utils/TableGen/CodeGenTarget.cpp
index cf67935..1eb1a54 100644
--- a/llvm/utils/TableGen/CodeGenTarget.cpp
+++ b/llvm/utils/TableGen/CodeGenTarget.cpp
@@ -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.
///
diff --git a/llvm/utils/TableGen/CodeGenTarget.h b/llvm/utils/TableGen/CodeGenTarget.h
index 85463da..a0df08b 100644
--- a/llvm/utils/TableGen/CodeGenTarget.h
+++ b/llvm/utils/TableGen/CodeGenTarget.h
@@ -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 {
diff --git a/llvm/utils/TableGen/RegisterInfoEmitter.cpp b/llvm/utils/TableGen/RegisterInfoEmitter.cpp
index 6aea4ad..899f5523 100644
--- a/llvm/utils/TableGen/RegisterInfoEmitter.cpp
+++ b/llvm/utils/TableGen/RegisterInfoEmitter.cpp
@@ -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";