summaryrefslogtreecommitdiffstats
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
commit77b7c3f1e652fbec0b2fb68d9f48c5de812fe90c (patch)
tree53f6cb466c11fa6a61c6df179057128d54efe7b1
parent094442d3315faa23e88a10b2d5bf4a4714a9b11c (diff)
downloadbcm5719-llvm-77b7c3f1e652fbec0b2fb68d9f48c5de812fe90c.tar.gz
bcm5719-llvm-77b7c3f1e652fbec0b2fb68d9f48c5de812fe90c.zip
MC/AsmMatcher: Add support for custom conversion functions.
llvm-svn: 124870
-rw-r--r--llvm/include/llvm/Target/Target.td7
-rw-r--r--llvm/utils/TableGen/AsmMatcherEmitter.cpp21
2 files changed, 27 insertions, 1 deletions
diff --git a/llvm/include/llvm/Target/Target.td b/llvm/include/llvm/Target/Target.td
index 1bc00b610e5..82628a148b0 100644
--- a/llvm/include/llvm/Target/Target.td
+++ b/llvm/include/llvm/Target/Target.td
@@ -248,6 +248,13 @@ class Instruction {
/// Target-specific flags. This becomes the TSFlags field in TargetInstrDesc.
bits<64> TSFlags = 0;
+
+ ///@name Assembler Parser Support
+ ///@{
+
+ string AsmMatchConverter = "";
+
+ ///@}
}
/// Predicates - These are extra conditionals which are turned into instruction
diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
index 76904de7513..806f5d22246 100644
--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/llvm/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 << ", { ";
OpenPOWER on IntegriCloud