Skip to content

[TableGen] Remove duplicate code in applyMnemonicAliases when target uses DefaultAsmParserVariant. #108494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions llvm/utils/TableGen/AsmMatcherEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2849,18 +2849,29 @@ static bool emitMnemonicAliases(raw_ostream &OS, const AsmMatcherInfo &Info,

OS << "static void applyMnemonicAliases(StringRef &Mnemonic, "
"const FeatureBitset &Features, unsigned VariantID) {\n";
OS << " switch (VariantID) {\n";
unsigned VariantCount = Target.getAsmParserVariantCount();
for (unsigned VC = 0; VC != VariantCount; ++VC) {
Record *AsmVariant = Target.getAsmParserVariant(VC);
int AsmParserVariantNo = AsmVariant->getValueAsInt("Variant");
StringRef AsmParserVariantName = AsmVariant->getValueAsString("Name");

// If the variant doesn't have a name, defer to the emitMnemonicAliasVariant
// call after the loop.
if (AsmParserVariantName.empty()) {
assert(VariantCount == 1 && "Multiple variants should each be named");
continue;
}

if (VC == 0)
OS << " switch (VariantID) {\n";
OS << " case " << AsmParserVariantNo << ":\n";
emitMnemonicAliasVariant(OS, Info, Aliases, /*Indent=*/2,
AsmParserVariantName);
OS << " break;\n";

if (VC == VariantCount - 1)
OS << " }\n";
}
OS << " }\n";

// Emit aliases that apply to all variants.
emitMnemonicAliasVariant(OS, Info, Aliases);
Expand Down
Loading