std::set<std::string> GeneratedFns;
// Start the unified conversion function.
- CvtOS << "static void ConvertToMCInst(ConversionKind Kind, MCInst &Inst, "
+ CvtOS << "static bool ConvertToMCInst(ConversionKind Kind, MCInst &Inst, "
<< "unsigned Opcode,\n"
<< " const SmallVectorImpl<MCParsedAsmOperand*"
<< "> &Operands) {\n";
OS << " " << Signature << ",\n";
CvtOS << " case " << Signature << ":\n";
- CvtOS << " " << AsmMatchConverter << "(Inst, Opcode, Operands);\n";
- CvtOS << " return;\n";
+ CvtOS << " return " << AsmMatchConverter
+ << "(Inst, Opcode, Operands);\n";
continue;
}
CvtOS << " case " << Signature << ":\n";
CvtOS << CaseOS.str();
- CvtOS << " return;\n";
+ CvtOS << " return true;\n";
}
// Finish the convert function.
CvtOS << " }\n";
+ CvtOS << " return false;\n";
CvtOS << "}\n\n";
// Finish the enum, and drop the convert function after it.
OS << " unsigned ComputeAvailableFeatures(const " <<
Target.getName() << "Subtarget *Subtarget) const;\n";
OS << " enum MatchResultTy {\n";
- OS << " Match_Success, Match_MnemonicFail, Match_InvalidOperand,\n";
- OS << " Match_MissingFeature\n";
+ OS << " Match_ConversionFail,\n";
+ OS << " Match_InvalidOperand,\n";
+ OS << " Match_MissingFeature,\n";
+ OS << " Match_MnemonicFail,\n";
+ OS << " Match_Success\n";
OS << " };\n";
OS << " bool MnemonicIsValid(StringRef Mnemonic);\n";
OS << " MatchResultTy MatchInstructionImpl(\n";
OS << " HadMatchOtherThanFeatures = true;\n";
OS << " continue;\n";
OS << " }\n";
-
OS << "\n";
- OS << " ConvertToMCInst(it->ConvertFn, Inst, it->Opcode, Operands);\n";
+ OS << " // We have selected a definite instruction, convert the parsed\n"
+ << " // operands into the appropriate MCInst.\n";
+ OS << " if (!ConvertToMCInst(it->ConvertFn, Inst,\n"
+ << " it->Opcode, Operands))\n";
+ OS << " return Match_ConversionFail;\n";
+ OS << "\n";
+ OS << " return Match_Success;\n";
// Call the post-processing function, if used.
std::string InsnCleanupFn =