From: Craig Topper Date: Tue, 2 Apr 2019 20:52:04 +0000 (+0000) Subject: [TableGen] Properly calculate the minimum size needed or ConvertFn in GenAsmmatcher... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b64f915ae0fdd3b6d0a46f17b2d30367f2d56c0b;p=platform%2Fupstream%2Fllvm.git [TableGen] Properly calculate the minimum size needed or ConvertFn in GenAsmmatcher.inc files We were using the number of Matchables rather than the number of rows in the converter table. This only matters for a few of the targets where the number of matchables is more than 255, but the number of converters is less than 255. Many of the targets have more than 256 converters. So already required a uint16_t. llvm-svn: 357527 --- diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp index 5a56d64..df089cb 100644 --- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp +++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp @@ -1927,10 +1927,11 @@ getConverterOperandID(const std::string &Name, return ID; } -static void emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName, - std::vector> &Infos, - bool HasMnemonicFirst, bool HasOptionalOperands, - raw_ostream &OS) { +static unsigned +emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName, + std::vector> &Infos, + bool HasMnemonicFirst, bool HasOptionalOperands, + raw_ostream &OS) { SmallSetVector OperandConversionKinds; SmallSetVector InstructionConversionKinds; std::vector > ConversionTable; @@ -2336,6 +2337,8 @@ static void emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName, // Spit out the operand number lookup function. OS << OpOS.str(); + + return ConversionTable.size(); } /// emitMatchClassEnumeration - Emit the enumeration for match class kinds. @@ -3274,8 +3277,9 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { // Generate the convertToMCInst function to convert operands into an MCInst. // Also, generate the convertToMapAndConstraints function for MS-style inline // assembly. The latter doesn't actually generate a MCInst. - emitConvertFuncs(Target, ClassName, Info.Matchables, HasMnemonicFirst, - HasOptionalOperands, OS); + unsigned NumConverters = emitConvertFuncs(Target, ClassName, Info.Matchables, + HasMnemonicFirst, + HasOptionalOperands, OS); // Emit the enumeration for classes which participate in matching. emitMatchClassEnumeration(Target, Info.Classes, OS); @@ -3390,7 +3394,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { OS << " " << getMinimalTypeForRange(MaxMnemonicIndex) << " Mnemonic;\n"; OS << " uint16_t Opcode;\n"; - OS << " " << getMinimalTypeForRange(Info.Matchables.size()) + OS << " " << getMinimalTypeForRange(NumConverters) << " ConvertFn;\n"; OS << " " << getMinimalTypeForRange(FeatureBitsets.size()) << " RequiredFeaturesIdx;\n";