@@ -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,12 @@ static DecodeStatus DecodeFPR128RegisterClass(MCInst &Inst, uint32_t RegNo,
196194 return MCDisassembler::Success;
197195}
198196
197+ static DecodeStatus DecodeSPRegisterClass (MCInst &Inst,
198+ const MCDisassembler *Decoder) {
199+ Inst.addOperand (MCOperand::createReg (RISCV::X2));
200+ return MCDisassembler::Success;
201+ }
202+
199203static DecodeStatus DecodeGPRNoX0RegisterClass (MCInst &Inst, uint32_t RegNo,
200204 uint64_t Address,
201205 const MCDisassembler *Decoder) {
@@ -600,15 +604,6 @@ static DecodeStatus decodeXTHeadMemPair(MCInst &Inst, uint32_t Insn,
600604
601605#include " RISCVGenDisassemblerTables.inc"
602606
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-
612607namespace {
613608
614609struct DecoderListEntry {
@@ -774,12 +769,8 @@ DecodeStatus RISCVDisassembler::getInstruction16(MCInst &MI, uint64_t &Size,
774769 LLVM_DEBUG (dbgs () << " Trying " << Entry.Desc << " table:\n " );
775770 DecodeStatus Result =
776771 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;
783774 }
784775
785776 return MCDisassembler::Fail;
0 commit comments