diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2010-05-04 00:33:13 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2010-05-04 00:33:13 +0000 |
| commit | 9989417f33b1a268286b2cc98263cbcb1a39c157 (patch) | |
| tree | 0e1a8cd0357f7c6f46d7a4ea597f51d916f29d10 | |
| parent | ce0c1e11ce6031a9bc23579bcb35e21178eef4f8 (diff) | |
| download | bcm5719-llvm-9989417f33b1a268286b2cc98263cbcb1a39c157.tar.gz bcm5719-llvm-9989417f33b1a268286b2cc98263cbcb1a39c157.zip | |
MC/Matcher: Add support for over-riding the default MatchInstruction function
name (for example, to allow targets to interpose the actual MatchInstruction
function).
llvm-svn: 102987
| -rw-r--r-- | llvm/include/llvm/Target/Target.td | 12 | ||||
| -rw-r--r-- | llvm/utils/TableGen/AsmMatcherEmitter.cpp | 12 |
2 files changed, 16 insertions, 8 deletions
diff --git a/llvm/include/llvm/Target/Target.td b/llvm/include/llvm/Target/Target.td index 8e1cc53236f..cc19e0de8eb 100644 --- a/llvm/include/llvm/Target/Target.td +++ b/llvm/include/llvm/Target/Target.td @@ -485,10 +485,10 @@ def REG_SEQUENCE : Instruction { } //===----------------------------------------------------------------------===// -// AsmParser - This class can be implemented by targets that wish to implement +// AsmParser - This class can be implemented by targets that wish to implement // .s file parsing. // -// Subtargets can have multiple different assembly parsers (e.g. AT&T vs Intel +// Subtargets can have multiple different assembly parsers (e.g. AT&T vs Intel // syntax on X86 for example). // class AsmParser { @@ -501,9 +501,13 @@ class AsmParser { // AsmParser class to call on every matched instruction. This can be used to // perform target specific instruction post-processing. string AsmParserInstCleanup = ""; - + + // MatchInstructionName - The name of the instruction matching function to + // generate. + string MatchInstructionName = "MatchInstruction"; + // Variant - AsmParsers can be of multiple different variants. Variants are - // used to support targets that need to parser multiple formats for the + // used to support targets that need to parser multiple formats for the // assembly language. int Variant = 0; diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp index e5c068bcdf6..1947824cbf8 100644 --- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp +++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp @@ -1564,10 +1564,14 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { Info.Instructions.begin(), ie = Info.Instructions.end(); it != ie; ++it) MaxNumOperands = std::max(MaxNumOperands, (*it)->Operands.size()); - - OS << "bool " << Target.getName() << ClassName - << "::\nMatchInstruction(const SmallVectorImpl<MCParsedAsmOperand*> " - "&Operands,\n MCInst &Inst) {\n"; + + const std::string &MatchName = + AsmParser->getValueAsString("MatchInstructionName"); + OS << "bool " << Target.getName() << ClassName << "::\n" + << MatchName + << "(const SmallVectorImpl<MCParsedAsmOperand*> &Operands,\n"; + OS.indent(MatchName.size() + 1); + OS << "MCInst &Inst) {\n"; // Emit the static match table; unused classes get initalized to 0 which is // guaranteed to be InvalidMatchClass. |

