MC/AsmMatcher: Sink ConvertToMCInst into the TargetAsmParser instance, which

implicitly allows custom conversions to be member functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124908 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2011-02-04 23:17:40 +00:00
parent 45e53975f8
commit 5c228a945f

View File

@ -1356,7 +1356,7 @@ void MatchableInfo::BuildAliasResultOperands() {
} }
} }
static void EmitConvertToMCInst(CodeGenTarget &Target, static void EmitConvertToMCInst(CodeGenTarget &Target, StringRef ClassName,
std::vector<MatchableInfo*> &Infos, std::vector<MatchableInfo*> &Infos,
raw_ostream &OS) { raw_ostream &OS) {
// Write the convert function to a separate stream, so we can drop it after // Write the convert function to a separate stream, so we can drop it after
@ -1368,7 +1368,8 @@ static void EmitConvertToMCInst(CodeGenTarget &Target,
std::set<std::string> GeneratedFns; std::set<std::string> GeneratedFns;
// Start the unified conversion function. // Start the unified conversion function.
CvtOS << "static bool ConvertToMCInst(ConversionKind Kind, MCInst &Inst, " CvtOS << "bool " << Target.getName() << ClassName << "::\n";
CvtOS << "ConvertToMCInst(unsigned Kind, MCInst &Inst, "
<< "unsigned Opcode,\n" << "unsigned Opcode,\n"
<< " const SmallVectorImpl<MCParsedAsmOperand*" << " const SmallVectorImpl<MCParsedAsmOperand*"
<< "> &Operands) {\n"; << "> &Operands) {\n";
@ -1921,6 +1922,10 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
OS << " Match_MnemonicFail,\n"; OS << " Match_MnemonicFail,\n";
OS << " Match_Success\n"; OS << " Match_Success\n";
OS << " };\n"; OS << " };\n";
OS << " bool ConvertToMCInst(unsigned Kind, MCInst &Inst, "
<< "unsigned Opcode,\n"
<< " const SmallVectorImpl<MCParsedAsmOperand*> "
<< "&Operands);\n";
OS << " bool MnemonicIsValid(StringRef Mnemonic);\n"; OS << " bool MnemonicIsValid(StringRef Mnemonic);\n";
OS << " MatchResultTy MatchInstructionImpl(\n"; OS << " MatchResultTy MatchInstructionImpl(\n";
OS << " const SmallVectorImpl<MCParsedAsmOperand*> &Operands,\n"; OS << " const SmallVectorImpl<MCParsedAsmOperand*> &Operands,\n";
@ -1946,7 +1951,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
bool HasMnemonicAliases = EmitMnemonicAliases(OS, Info); bool HasMnemonicAliases = EmitMnemonicAliases(OS, Info);
// Generate the unified function to convert operands into an MCInst. // Generate the unified function to convert operands into an MCInst.
EmitConvertToMCInst(Target, Info.Matchables, OS); EmitConvertToMCInst(Target, ClassName, Info.Matchables, OS);
// Emit the enumeration for classes which participate in matching. // Emit the enumeration for classes which participate in matching.
EmitMatchClassEnumeration(Target, Info.Classes, OS); EmitMatchClassEnumeration(Target, Info.Classes, OS);