1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00

[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
This commit is contained in:
Craig Topper 2019-04-02 20:52:04 +00:00
parent 166371ebcb
commit 409ce511c0

View File

@ -1927,10 +1927,11 @@ getConverterOperandID(const std::string &Name,
return ID;
}
static void emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName,
std::vector<std::unique_ptr<MatchableInfo>> &Infos,
bool HasMnemonicFirst, bool HasOptionalOperands,
raw_ostream &OS) {
static unsigned
emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName,
std::vector<std::unique_ptr<MatchableInfo>> &Infos,
bool HasMnemonicFirst, bool HasOptionalOperands,
raw_ostream &OS) {
SmallSetVector<CachedHashString, 16> OperandConversionKinds;
SmallSetVector<CachedHashString, 16> InstructionConversionKinds;
std::vector<std::vector<uint8_t> > 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";