Skip to content

Commit 235b15d

Browse files
committed
[AVR] Remove workarounds for instructions using Z register
The generated disassembler can now correctly decode these instructions.
1 parent 9f30122 commit 235b15d

File tree

5 files changed

+10
-20
lines changed

5 files changed

+10
-20
lines changed

llvm/lib/Target/AVR/AVRInstrFormats.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class FRdRr<bits<4> opcode, bits<2> f, dag outs, dag ins, string asmstr,
7979
//===----------------------------------------------------------------------===//
8080
class FZRd<bits<3> t, dag outs, dag ins, string asmstr, list<dag> pattern>
8181
: AVRInst16<outs, ins, asmstr, pattern> {
82+
bits<0> z;
8283
bits<5> rd;
8384

8485
let Inst{15 - 12} = 0b1001;

llvm/lib/Target/AVR/AVRInstrInfo.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,9 @@ let Uses = [R1, R0] in {
12301230

12311231
let Defs = [R31R30] in
12321232
def SPMZPi : F16<0b1001010111111000, (outs), (ins ZREG:$z), "spm $z+", []>,
1233-
Requires<[HasSPMX]>;
1233+
Requires<[HasSPMX]> {
1234+
bits<0> z;
1235+
}
12341236
}
12351237

12361238
// Read data from IO location operations.

llvm/lib/Target/AVR/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ tablegen(LLVM AVRGenAsmMatcher.inc -gen-asm-matcher)
66
tablegen(LLVM AVRGenAsmWriter.inc -gen-asm-writer)
77
tablegen(LLVM AVRGenCallingConv.inc -gen-callingconv)
88
tablegen(LLVM AVRGenDAGISel.inc -gen-dag-isel)
9-
tablegen(LLVM AVRGenDisassemblerTables.inc -gen-disassembler
10-
-ignore-non-decodable-operands)
9+
tablegen(LLVM AVRGenDisassemblerTables.inc -gen-disassembler)
1110
tablegen(LLVM AVRGenInstrInfo.inc -gen-instr-info)
1211
tablegen(LLVM AVRGenMCCodeEmitter.inc -gen-emitter)
1312
tablegen(LLVM AVRGenRegisterInfo.inc -gen-register-info)

llvm/lib/Target/AVR/Disassembler/AVRDisassembler.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ static DecodeStatus DecodeLD8RegisterClass(MCInst &Inst, unsigned RegNo,
9191
return MCDisassembler::Success;
9292
}
9393

94+
static void DecodeZREGRegisterClass(MCInst &Inst,
95+
const MCDisassembler *Decoder) {
96+
Inst.addOperand(MCOperand::createReg(AVR::R31R30));
97+
}
98+
9499
static DecodeStatus decodeFIOARr(MCInst &Inst, unsigned Insn, uint64_t Address,
95100
const MCDisassembler *Decoder) {
96101
unsigned addr = 0;

llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,6 @@ const char *AVRInstPrinter::getPrettyRegisterName(MCRegister Reg,
101101
void AVRInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
102102
raw_ostream &O) {
103103
const MCOperandInfo &MOI = this->MII.get(MI->getOpcode()).operands()[OpNo];
104-
if (MOI.RegClass == AVR::ZREGRegClassID) {
105-
// Special case for the Z register, which sometimes doesn't have an operand
106-
// in the MCInst.
107-
O << "Z";
108-
return;
109-
}
110-
111-
if (OpNo >= MI->size()) {
112-
// Not all operands are correctly disassembled at the moment. This means
113-
// that some machine instructions won't have all the necessary operands
114-
// set.
115-
// To avoid asserting, print <unknown> instead until the necessary support
116-
// has been implemented.
117-
O << "<unknown>";
118-
return;
119-
}
120-
121104
const MCOperand &Op = MI->getOperand(OpNo);
122105

123106
if (Op.isReg()) {

0 commit comments

Comments
 (0)