Reduce size of register name index tables by using uint16_t for all in tree targets...
authorCraig Topper <craig.topper@gmail.com>
Fri, 14 Sep 2012 06:37:49 +0000 (06:37 +0000)
committerCraig Topper <craig.topper@gmail.com>
Fri, 14 Sep 2012 06:37:49 +0000 (06:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163878 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/AsmWriterEmitter.cpp
utils/TableGen/SequenceToOffsetTable.h

index 7f9d4061f9b5b9b30cadfcf3d1bd0e563629e711..fe16bfbf9dcacc058321358785a4220c07090664 100644 (file)
@@ -581,12 +581,13 @@ emitRegisterNameString(raw_ostream &O, StringRef AltName,
     StringTable.add(AsmName);
   }
 
-  StringTable.layout();
+  unsigned Entries = StringTable.layout();
   O << "  static const char AsmStrs" << AltName << "[] = {\n";
   StringTable.emit(O, printChar);
   O << "  };\n\n";
 
-  O << "  static const unsigned RegAsmOffset" << AltName << "[] = {";
+  O << "  static const uint" << ((Entries > 0xffff) ? "32" : "16")
+    << "_t RegAsmOffset" << AltName << "[] = {";
   for (unsigned i = 0, e = Registers.size(); i != e; ++i) {
     if ((i % 14) == 0)
       O << "\n    ";
index 60202b5ade077d90a5f9255de8d022afbd7bfb22..a4f16ca9a6a2ec3ecb6a6e4d97f84366bcd5a763 100644 (file)
@@ -82,9 +82,9 @@ public:
   }
 
   bool empty() const { return Seqs.empty(); }
-  
+
   /// layout - Computes the final table layout.
-  void layout() {
+  unsigned layout() {
     assert(Entries == 0 && "Can only call layout() once");
     // Lay out the table in Seqs iteration order.
     for (typename SeqMap::iterator I = Seqs.begin(), E = Seqs.end(); I != E;
@@ -93,6 +93,7 @@ public:
       // Include space for a terminator.
       Entries += I->first.size() + 1;
     }
+    return Entries;
   }
 
   /// get - Returns the offset of Seq in the final table.