[AVR] Don't assert on an undefined operand

Not all operands are correctly disassembled at the moment. This means
that some machine instructions won't have all the necessary operands
set.
To avoid asserting, print an error instead until the necessary support
has been implemented.

Differential Revision: https://reviews.llvm.org/D73958
This commit is contained in:
Ayke van Laethem 2020-02-04 14:12:43 +01:00
parent a5424ded37
commit d1af6011e5
No known key found for this signature in database
GPG Key ID: E97FF5335DFDFDED
1 changed files with 20 additions and 0 deletions

View File

@ -100,6 +100,16 @@ const char *AVRInstPrinter::getPrettyRegisterName(unsigned RegNum,
void AVRInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
raw_ostream &O) {
if (OpNo >= MI->size()) {
// Not all operands are correctly disassembled at the moment. This means
// that some machine instructions won't have all the necessary operands
// set.
// To avoid asserting, print <unknown> instead until the necessary support
// has been implemented.
O << "<unknown>";
return;
}
const MCOperand &Op = MI->getOperand(OpNo);
const MCOperandInfo &MOI = this->MII.get(MI->getOpcode()).OpInfo[OpNo];
@ -125,6 +135,16 @@ void AVRInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
/// being encoded as a pc-relative value.
void AVRInstPrinter::printPCRelImm(const MCInst *MI, unsigned OpNo,
raw_ostream &O) {
if (OpNo >= MI->size()) {
// Not all operands are correctly disassembled at the moment. This means
// that some machine instructions won't have all the necessary operands
// set.
// To avoid asserting, print <unknown> instead until the necessary support
// has been implemented.
O << "<unknown>";
return;
}
const MCOperand &Op = MI->getOperand(OpNo);
if (Op.isImm()) {