diff --git a/llvm/test/TableGen/get-operand-type.td b/llvm/test/TableGen/get-operand-type.td index a8d96e25b2899..6ebda5cffe8af 100644 --- a/llvm/test/TableGen/get-operand-type.td +++ b/llvm/test/TableGen/get-operand-type.td @@ -46,7 +46,8 @@ def InstC : Instruction { } // CHECK: #ifdef GET_INSTRINFO_OPERAND_TYPE -// CHECK: OpcodeOperandTypes[] = { +// CHECK: static const uint{{.*}}_t Offsets[] = { +// CHECK: static const {{.*}} OpcodeOperandTypes[] = { // CHECK: /* InstA */ // CHECK-NEXT: OpA, OpB, i32imm, // CHECK-NEXT: /* InstB */ diff --git a/llvm/utils/TableGen/InstrInfoEmitter.cpp b/llvm/utils/TableGen/InstrInfoEmitter.cpp index 14ee24c15a65d..4eef1fef2a91e 100644 --- a/llvm/utils/TableGen/InstrInfoEmitter.cpp +++ b/llvm/utils/TableGen/InstrInfoEmitter.cpp @@ -419,8 +419,7 @@ void InstrInfoEmitter::emitOperandTypeMappings( // Size the unsigned integer offset to save space. assert(OperandRecords.size() <= UINT32_MAX && "Too many operands for offset table"); - OS << ((OperandRecords.size() <= UINT16_MAX) ? " const uint16_t" - : " const uint32_t"); + OS << " static const " << getMinimalTypeForRange(OperandRecords.size()); OS << " Offsets[] = {\n"; for (int I = 0, E = OperandOffsets.size(); I != E; ++I) { OS << " /* " << getInstrName(I) << " */\n"; @@ -436,7 +435,8 @@ void InstrInfoEmitter::emitOperandTypeMappings( assert(EnumVal <= INT16_MAX && "Too many operand types for operand types table"); OS << "\n using namespace OpTypes;\n"; - OS << ((EnumVal <= INT8_MAX) ? " const int8_t" : " const int16_t"); + OS << " static"; + OS << ((EnumVal <= INT8_MAX) ? " const int8_t" : " const int16_t"); OS << " OpcodeOperandTypes[] = {\n "; for (int I = 0, E = OperandRecords.size(), CurOffset = 0; I != E; ++I) { // We print each Opcode's operands in its own row.