mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-09 18:55:33 +00:00
MC/AsmParser: Add support for allowing the conversion process to fail (via
custom conversion functions). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124872 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5e342ecc19
commit
b412915ff6
@ -1393,6 +1393,8 @@ MatchAndEmitInstruction(SMLoc IDLoc,
|
|||||||
}
|
}
|
||||||
case Match_MnemonicFail:
|
case Match_MnemonicFail:
|
||||||
return Error(IDLoc, "unrecognized instruction mnemonic");
|
return Error(IDLoc, "unrecognized instruction mnemonic");
|
||||||
|
case Match_ConversionFail:
|
||||||
|
return Error(IDLoc, "unable to convert operands to instruction");
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm_unreachable("Implement any new match types added!");
|
llvm_unreachable("Implement any new match types added!");
|
||||||
|
@ -334,6 +334,8 @@ MatchAndEmitInstruction(SMLoc IDLoc,
|
|||||||
return Error(IDLoc, "instruction use requires an option to be enabled");
|
return Error(IDLoc, "instruction use requires an option to be enabled");
|
||||||
case Match_MnemonicFail:
|
case Match_MnemonicFail:
|
||||||
return Error(IDLoc, "unrecognized instruction mnemonic");
|
return Error(IDLoc, "unrecognized instruction mnemonic");
|
||||||
|
case Match_ConversionFail:
|
||||||
|
return Error(IDLoc, "unable to convert operands to instruction");
|
||||||
case Match_InvalidOperand:
|
case Match_InvalidOperand:
|
||||||
ErrorLoc = IDLoc;
|
ErrorLoc = IDLoc;
|
||||||
if (ErrorInfo != ~0U) {
|
if (ErrorInfo != ~0U) {
|
||||||
|
@ -842,6 +842,8 @@ MatchAndEmitInstruction(SMLoc IDLoc,
|
|||||||
case Match_MissingFeature:
|
case Match_MissingFeature:
|
||||||
Error(IDLoc, "instruction requires a CPU feature not currently enabled");
|
Error(IDLoc, "instruction requires a CPU feature not currently enabled");
|
||||||
return true;
|
return true;
|
||||||
|
case Match_ConversionFail:
|
||||||
|
return Error(IDLoc, "unable to convert operands to instruction");
|
||||||
case Match_InvalidOperand:
|
case Match_InvalidOperand:
|
||||||
WasOriginallyInvalidOperand = true;
|
WasOriginallyInvalidOperand = true;
|
||||||
break;
|
break;
|
||||||
|
@ -1368,7 +1368,7 @@ 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 void ConvertToMCInst(ConversionKind Kind, MCInst &Inst, "
|
CvtOS << "static bool ConvertToMCInst(ConversionKind Kind, MCInst &Inst, "
|
||||||
<< "unsigned Opcode,\n"
|
<< "unsigned Opcode,\n"
|
||||||
<< " const SmallVectorImpl<MCParsedAsmOperand*"
|
<< " const SmallVectorImpl<MCParsedAsmOperand*"
|
||||||
<< "> &Operands) {\n";
|
<< "> &Operands) {\n";
|
||||||
@ -1403,8 +1403,8 @@ static void EmitConvertToMCInst(CodeGenTarget &Target,
|
|||||||
OS << " " << Signature << ",\n";
|
OS << " " << Signature << ",\n";
|
||||||
|
|
||||||
CvtOS << " case " << Signature << ":\n";
|
CvtOS << " case " << Signature << ":\n";
|
||||||
CvtOS << " " << AsmMatchConverter << "(Inst, Opcode, Operands);\n";
|
CvtOS << " return " << AsmMatchConverter
|
||||||
CvtOS << " return;\n";
|
<< "(Inst, Opcode, Operands);\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1479,12 +1479,13 @@ static void EmitConvertToMCInst(CodeGenTarget &Target,
|
|||||||
|
|
||||||
CvtOS << " case " << Signature << ":\n";
|
CvtOS << " case " << Signature << ":\n";
|
||||||
CvtOS << CaseOS.str();
|
CvtOS << CaseOS.str();
|
||||||
CvtOS << " return;\n";
|
CvtOS << " return true;\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finish the convert function.
|
// Finish the convert function.
|
||||||
|
|
||||||
CvtOS << " }\n";
|
CvtOS << " }\n";
|
||||||
|
CvtOS << " return false;\n";
|
||||||
CvtOS << "}\n\n";
|
CvtOS << "}\n\n";
|
||||||
|
|
||||||
// Finish the enum, and drop the convert function after it.
|
// Finish the enum, and drop the convert function after it.
|
||||||
@ -1914,8 +1915,11 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
|
|||||||
OS << " unsigned ComputeAvailableFeatures(const " <<
|
OS << " unsigned ComputeAvailableFeatures(const " <<
|
||||||
Target.getName() << "Subtarget *Subtarget) const;\n";
|
Target.getName() << "Subtarget *Subtarget) const;\n";
|
||||||
OS << " enum MatchResultTy {\n";
|
OS << " enum MatchResultTy {\n";
|
||||||
OS << " Match_Success, Match_MnemonicFail, Match_InvalidOperand,\n";
|
OS << " Match_ConversionFail,\n";
|
||||||
OS << " Match_MissingFeature\n";
|
OS << " Match_InvalidOperand,\n";
|
||||||
|
OS << " Match_MissingFeature,\n";
|
||||||
|
OS << " Match_MnemonicFail,\n";
|
||||||
|
OS << " Match_Success\n";
|
||||||
OS << " };\n";
|
OS << " };\n";
|
||||||
OS << " bool MnemonicIsValid(StringRef Mnemonic);\n";
|
OS << " bool MnemonicIsValid(StringRef Mnemonic);\n";
|
||||||
OS << " MatchResultTy MatchInstructionImpl(\n";
|
OS << " MatchResultTy MatchInstructionImpl(\n";
|
||||||
@ -2132,9 +2136,14 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
|
|||||||
OS << " HadMatchOtherThanFeatures = true;\n";
|
OS << " HadMatchOtherThanFeatures = true;\n";
|
||||||
OS << " continue;\n";
|
OS << " continue;\n";
|
||||||
OS << " }\n";
|
OS << " }\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.
|
// Call the post-processing function, if used.
|
||||||
std::string InsnCleanupFn =
|
std::string InsnCleanupFn =
|
||||||
|
Loading…
Reference in New Issue
Block a user