@@ -46,8 +46,6 @@ class RISCVDisassembler : public MCDisassembler {
46
46
raw_ostream &CStream) const override ;
47
47
48
48
private:
49
- void addSPOperands (MCInst &MI) const ;
50
-
51
49
DecodeStatus getInstruction48 (MCInst &Instr, uint64_t &Size,
52
50
ArrayRef<uint8_t > Bytes, uint64_t Address,
53
51
raw_ostream &CStream) const ;
@@ -196,6 +194,12 @@ static DecodeStatus DecodeFPR128RegisterClass(MCInst &Inst, uint32_t RegNo,
196
194
return MCDisassembler::Success;
197
195
}
198
196
197
+ static DecodeStatus DecodeSPRegisterClass (MCInst &Inst,
198
+ const MCDisassembler *Decoder) {
199
+ Inst.addOperand (MCOperand::createReg (RISCV::X2));
200
+ return MCDisassembler::Success;
201
+ }
202
+
199
203
static DecodeStatus DecodeGPRNoX0RegisterClass (MCInst &Inst, uint32_t RegNo,
200
204
uint64_t Address,
201
205
const MCDisassembler *Decoder) {
@@ -600,15 +604,6 @@ static DecodeStatus decodeXTHeadMemPair(MCInst &Inst, uint32_t Insn,
600
604
601
605
#include " RISCVGenDisassemblerTables.inc"
602
606
603
- // Add implied SP operand for C.*SP compressed instructions. The SP operand
604
- // isn't explicitly encoded in the instruction.
605
- void RISCVDisassembler::addSPOperands (MCInst &MI) const {
606
- const MCInstrDesc &MCID = MCII->get (MI.getOpcode ());
607
- for (unsigned i = 0 ; i < MCID.getNumOperands (); i++)
608
- if (MCID.operands ()[i].RegClass == RISCV::SPRegClassID)
609
- MI.insert (MI.begin () + i, MCOperand::createReg (RISCV::X2));
610
- }
611
-
612
607
namespace {
613
608
614
609
struct DecoderListEntry {
@@ -774,12 +769,8 @@ DecodeStatus RISCVDisassembler::getInstruction16(MCInst &MI, uint64_t &Size,
774
769
LLVM_DEBUG (dbgs () << " Trying " << Entry.Desc << " table:\n " );
775
770
DecodeStatus Result =
776
771
decodeInstruction (Entry.Table , MI, Insn, Address, this , STI);
777
- if (Result == MCDisassembler::Fail)
778
- continue ;
779
-
780
- addSPOperands (MI);
781
-
782
- return Result;
772
+ if (Result != MCDisassembler::Fail)
773
+ return Result;
783
774
}
784
775
785
776
return MCDisassembler::Fail;
0 commit comments