diff --git a/utils/TableGen/AsmWriterEmitter.cpp b/utils/TableGen/AsmWriterEmitter.cpp index 7f9d4061f9b..fe16bfbf9dc 100644 --- a/utils/TableGen/AsmWriterEmitter.cpp +++ b/utils/TableGen/AsmWriterEmitter.cpp @@ -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 "; diff --git a/utils/TableGen/SequenceToOffsetTable.h b/utils/TableGen/SequenceToOffsetTable.h index 60202b5ade0..a4f16ca9a6a 100644 --- a/utils/TableGen/SequenceToOffsetTable.h +++ b/utils/TableGen/SequenceToOffsetTable.h @@ -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.