mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-26 13:10:34 +00:00
MC/AsmMatcher: Add support for target specific "instruction cleanup" functions,
to allow custom post-processing of matched instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98857 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
618d0ed4bc
commit
8cc9c0c487
@ -491,6 +491,11 @@ class AsmParser {
|
||||
// class. Generated AsmParser classes are always prefixed with the target
|
||||
// name.
|
||||
string AsmParserClassName = "AsmParser";
|
||||
|
||||
// AsmParserInstCleanup - If non-empty, this is the name of a custom function on the
|
||||
// AsmParser class to call on every matched instruction. This can be used to
|
||||
// perform target specific instruction post-processing.
|
||||
string AsmParserInstCleanup = "";
|
||||
|
||||
// Variant - AsmParsers can be of multiple different variants. Variants are
|
||||
// used to support targets that need to parser multiple formats for the
|
||||
|
@ -998,7 +998,7 @@ static void EmitConvertToMCInst(CodeGenTarget &Target,
|
||||
|
||||
// Start the unified conversion function.
|
||||
|
||||
CvtOS << "static bool ConvertToMCInst(ConversionKind Kind, MCInst &Inst, "
|
||||
CvtOS << "static void ConvertToMCInst(ConversionKind Kind, MCInst &Inst, "
|
||||
<< "unsigned Opcode,\n"
|
||||
<< " const SmallVectorImpl<MCParsedAsmOperand*"
|
||||
<< "> &Operands) {\n";
|
||||
@ -1155,13 +1155,12 @@ static void EmitConvertToMCInst(CodeGenTarget &Target,
|
||||
}
|
||||
}
|
||||
|
||||
CvtOS << " break;\n";
|
||||
CvtOS << " return;\n";
|
||||
}
|
||||
|
||||
// Finish the convert function.
|
||||
|
||||
CvtOS << " }\n";
|
||||
CvtOS << " return false;\n";
|
||||
CvtOS << "}\n\n";
|
||||
|
||||
// Finish the enum, and drop the convert function after it.
|
||||
@ -1634,8 +1633,15 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
|
||||
OS << " continue;\n";
|
||||
}
|
||||
OS << "\n";
|
||||
OS << " return ConvertToMCInst(it->ConvertFn, Inst, "
|
||||
<< "it->Opcode, Operands);\n";
|
||||
OS << " ConvertToMCInst(it->ConvertFn, Inst, it->Opcode, Operands);\n";
|
||||
|
||||
// Call the post-processing function, if used.
|
||||
std::string InsnCleanupFn =
|
||||
AsmParser->getValueAsString("AsmParserInstCleanup");
|
||||
if (!InsnCleanupFn.empty())
|
||||
OS << " " << InsnCleanupFn << "(Inst);\n";
|
||||
|
||||
OS << " return false;\n";
|
||||
OS << " }\n\n";
|
||||
|
||||
OS << " return true;\n";
|
||||
|
Loading…
Reference in New Issue
Block a user