@@ -46,8 +46,6 @@ class RISCVDisassembler : public MCDisassembler {
4646 raw_ostream &CStream) const override ;
4747
4848private:
49- void addSPOperands (MCInst &MI) const ;
50-
5149 DecodeStatus getInstruction48 (MCInst &Instr, uint64_t &Size,
5250 ArrayRef<uint8_t > Bytes, uint64_t Address,
5351 raw_ostream &CStream) const ;
@@ -196,6 +194,10 @@ static DecodeStatus DecodeFPR128RegisterClass(MCInst &Inst, uint32_t RegNo,
196194 return MCDisassembler::Success;
197195}
198196
197+ static void DecodeSPRegisterClass (MCInst &Inst, const MCDisassembler *Decoder) {
198+ Inst.addOperand (MCOperand::createReg (RISCV::X2));
199+ }
200+
199201static DecodeStatus DecodeGPRNoX0RegisterClass (MCInst &Inst, uint32_t RegNo,
200202 uint64_t Address,
201203 const MCDisassembler *Decoder) {
@@ -600,15 +602,6 @@ static DecodeStatus decodeXTHeadMemPair(MCInst &Inst, uint32_t Insn,
600602
601603#include " RISCVGenDisassemblerTables.inc"
602604
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-
612605namespace {
613606
614607struct DecoderListEntry {
@@ -772,12 +765,8 @@ DecodeStatus RISCVDisassembler::getInstruction16(MCInst &MI, uint64_t &Size,
772765 LLVM_DEBUG (dbgs () << " Trying " << Entry.Desc << " table:\n " );
773766 DecodeStatus Result =
774767 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;
781770 }
782771
783772 return MCDisassembler::Fail;
0 commit comments