[llvm-branch-commits] [llvm-branch] r119201 - /llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp
Daniel Dunbar
daniel at zuster.org
Mon Nov 15 13:43:20 PST 2010
Author: ddunbar
Date: Mon Nov 15 15:43:20 2010
New Revision: 119201
URL: http://llvm.org/viewvc/llvm-project?rev=119201&view=rev
Log:
Merge r117826:
--
Author: Chris Lattner <clattner at apple.com>
Date: Sat Oct 30 18:48:18 2010 +0000
emit the mnemonic aliases in their own helper function instead of
inline into MatchInstructionImpl.
Modified:
llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp
Modified: llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp?rev=119201&r1=119200&r2=119201&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp (original)
+++ llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp Mon Nov 15 15:43:20 2010
@@ -1515,23 +1515,28 @@
}
/// EmitMnemonicAliases - If the target has any MnemonicAlias<> definitions,
-/// emit them.
-static void EmitMnemonicAliases(raw_ostream &OS) {
+/// emit a function for them and return true, otherwise return false.
+static bool EmitMnemonicAliases(raw_ostream &OS) {
+ OS << "static void ApplyMnemonicAliases(StringRef &Mnemonic, "
+ "unsigned Features) {\n";
+
std::vector<Record*> Aliases =
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;
for (unsigned i = 0, e = Aliases.size(); i != e; ++i) {
Record *R = Aliases[i];
Cases.push_back(std::make_pair(R->getValueAsString("FromMnemonic"),
"Mnemonic = \"" +
R->getValueAsString("ToMnemonic") +
- "\"; break;"));
+ "\"; return;"));
}
StringMatcher("Mnemonic", Cases, OS).Emit();
+ OS << "}\n";
+
+ return true;
}
void AsmMatcherEmitter::run(raw_ostream &OS) {
@@ -1617,6 +1622,9 @@
OS << "\n#ifdef GET_MATCHER_IMPLEMENTATION\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.
EmitConvertToMCInst(Target, Info.Instructions, OS);
@@ -1725,7 +1733,10 @@
OS << " StringRef Mnemonic = ((" << Target.getName()
<< "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.
OS << " // Eliminate obvious mismatches.\n";
More information about the llvm-branch-commits
mailing list