summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2011-02-04 17:12:15 +0000
committerDaniel Dunbar <daniel@zuster.org>2011-02-04 17:12:15 +0000
commitcf12067ae08dc7911c860070eaf2830dc1dc4ff7 (patch)
tree945ca88d2dde44c9d0f0acef186d628d5f88f93d /utils
parentc83e20375746c2910331ed29f5d976d80fe728e4 (diff)
MC/AsmMatcher: Add support for custom conversion functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124870 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/AsmMatcherEmitter.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp
index 76904de751..806f5d2224 100644
--- a/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/utils/TableGen/AsmMatcherEmitter.cpp
@@ -1388,6 +1388,26 @@ static void EmitConvertToMCInst(CodeGenTarget &Target,
ie = Infos.end(); it != ie; ++it) {
MatchableInfo &II = **it;
+ // Check if we have a custom match function.
+ StringRef AsmMatchConverter = II.getResultInst()->TheDef->getValueAsString(
+ "AsmMatchConverter");
+ if (!AsmMatchConverter.empty()) {
+ std::string Signature = "ConvertCustom_" + AsmMatchConverter.str();
+ II.ConversionFnKind = Signature;
+
+ // Check if we have already generated this signature.
+ if (!GeneratedFns.insert(Signature).second)
+ continue;
+
+ // If not, emit it now. Add to the enum list.
+ OS << " " << Signature << ",\n";
+
+ CvtOS << " case " << Signature << ":\n";
+ CvtOS << " " << AsmMatchConverter << "(Inst, Opcode, Operands);\n";
+ CvtOS << " return;\n";
+ continue;
+ }
+
// Build the conversion function signature.
std::string Signature = "Convert";
std::string CaseBody;
@@ -1988,7 +2008,6 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
it != ie; ++it) {
MatchableInfo &II = **it;
-
OS << " { " << Target.getName() << "::"
<< II.getResultInst()->TheDef->getName() << ", \"" << II.Mnemonic << "\""
<< ", " << II.ConversionFnKind << ", { ";