MC/Matcher: Add support for over-riding the default MatchInstruction function

name (for example, to allow targets to interpose the actual MatchInstruction
function).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102987 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2010-05-04 00:33:13 +00:00
parent 31e8e1d085
commit 4f83e73a6d
2 changed files with 16 additions and 8 deletions

View File

@ -502,6 +502,10 @@ class AsmParser {
// 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
// assembly language.

View File

@ -1565,9 +1565,13 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
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.