@@ -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,10 @@ static DecodeStatus DecodeFPR128RegisterClass(MCInst &Inst, uint32_t RegNo,
196
194
return MCDisassembler::Success;
197
195
}
198
196
197
+ static void DecodeSPRegisterClass (MCInst &Inst, const MCDisassembler *Decoder) {
198
+ Inst.addOperand (MCOperand::createReg (RISCV::X2));
199
+ }
200
+
199
201
static DecodeStatus DecodeGPRNoX0RegisterClass (MCInst &Inst, uint32_t RegNo,
200
202
uint64_t Address,
201
203
const MCDisassembler *Decoder) {
@@ -600,15 +602,6 @@ static DecodeStatus decodeXTHeadMemPair(MCInst &Inst, uint32_t Insn,
600
602
601
603
#include " RISCVGenDisassemblerTables.inc"
602
604
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
605
namespace {
613
606
614
607
struct DecoderListEntry {
@@ -772,12 +765,8 @@ DecodeStatus RISCVDisassembler::getInstruction16(MCInst &MI, uint64_t &Size,
772
765
LLVM_DEBUG (dbgs () << " Trying " << Entry.Desc << " table:\n " );
773
766
DecodeStatus Result =
774
767
decodeInstruction (Entry.Table , MI, Insn, Address, this , STI);
775
- if (Result == MCDisassembler::Fail)
776
- continue ;
777
-
778
- addSPOperands (MI);
779
-
780
- return Result;
768
+ if (Result != MCDisassembler::Fail)
769
+ return Result;
781
770
}
782
771
783
772
return MCDisassembler::Fail;
0 commit comments