forked from OSchip/llvm-project
emit the mnemonic aliases in their own helper function instead of
inline into MatchInstructionImpl. llvm-svn: 117826
This commit is contained in:
parent
92ef573550
commit
477fba4f54
|
@ -1515,23 +1515,28 @@ static void EmitComputeAvailableFeatures(CodeGenTarget &Target,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EmitMnemonicAliases - If the target has any MnemonicAlias<> definitions,
|
/// EmitMnemonicAliases - If the target has any MnemonicAlias<> definitions,
|
||||||
/// emit them.
|
/// emit a function for them and return true, otherwise return false.
|
||||||
static void EmitMnemonicAliases(raw_ostream &OS) {
|
static bool EmitMnemonicAliases(raw_ostream &OS) {
|
||||||
|
OS << "static void ApplyMnemonicAliases(StringRef &Mnemonic, "
|
||||||
|
"unsigned Features) {\n";
|
||||||
|
|
||||||
std::vector<Record*> Aliases =
|
std::vector<Record*> Aliases =
|
||||||
Records.getAllDerivedDefinitions("MnemonicAlias");
|
Records.getAllDerivedDefinitions("MnemonicAlias");
|
||||||
if (Aliases.empty()) return;
|
if (Aliases.empty()) return false;
|
||||||
|
|
||||||
OS << " // Process all MnemonicAliases to remap the mnemonic.\n";
|
|
||||||
std::vector<StringMatcher::StringPair> Cases;
|
std::vector<StringMatcher::StringPair> Cases;
|
||||||
for (unsigned i = 0, e = Aliases.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Aliases.size(); i != e; ++i) {
|
||||||
Record *R = Aliases[i];
|
Record *R = Aliases[i];
|
||||||
Cases.push_back(std::make_pair(R->getValueAsString("FromMnemonic"),
|
Cases.push_back(std::make_pair(R->getValueAsString("FromMnemonic"),
|
||||||
"Mnemonic = \"" +
|
"Mnemonic = \"" +
|
||||||
R->getValueAsString("ToMnemonic") +
|
R->getValueAsString("ToMnemonic") +
|
||||||
"\"; break;"));
|
"\"; return;"));
|
||||||
}
|
}
|
||||||
|
|
||||||
StringMatcher("Mnemonic", Cases, OS).Emit();
|
StringMatcher("Mnemonic", Cases, OS).Emit();
|
||||||
|
OS << "}\n";
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsmMatcherEmitter::run(raw_ostream &OS) {
|
void AsmMatcherEmitter::run(raw_ostream &OS) {
|
||||||
|
@ -1617,6 +1622,9 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
|
||||||
OS << "\n#ifdef GET_MATCHER_IMPLEMENTATION\n";
|
OS << "\n#ifdef GET_MATCHER_IMPLEMENTATION\n";
|
||||||
OS << "#undef GET_MATCHER_IMPLEMENTATION\n\n";
|
OS << "#undef GET_MATCHER_IMPLEMENTATION\n\n";
|
||||||
|
|
||||||
|
// Generate the function that remaps for mnemonic aliases.
|
||||||
|
bool HasMnemonicAliases = EmitMnemonicAliases(OS);
|
||||||
|
|
||||||
// Generate the unified function to convert operands into an MCInst.
|
// Generate the unified function to convert operands into an MCInst.
|
||||||
EmitConvertToMCInst(Target, Info.Instructions, OS);
|
EmitConvertToMCInst(Target, Info.Instructions, OS);
|
||||||
|
|
||||||
|
@ -1725,7 +1733,10 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
|
||||||
OS << " StringRef Mnemonic = ((" << Target.getName()
|
OS << " StringRef Mnemonic = ((" << Target.getName()
|
||||||
<< "Operand*)Operands[0])->getToken();\n\n";
|
<< "Operand*)Operands[0])->getToken();\n\n";
|
||||||
|
|
||||||
EmitMnemonicAliases(OS);
|
if (HasMnemonicAliases) {
|
||||||
|
OS << " // Process all MnemonicAliases to remap the mnemonic.\n";
|
||||||
|
OS << " ApplyMnemonicAliases(Mnemonic, AvailableFeatures);\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
// Emit code to compute the class list for this operand vector.
|
// Emit code to compute the class list for this operand vector.
|
||||||
OS << " // Eliminate obvious mismatches.\n";
|
OS << " // Eliminate obvious mismatches.\n";
|
||||||
|
|
Loading…
Reference in New Issue