@@ -1378,24 +1378,6 @@ static DecodeStatus DecodeRFEInstruction(MCInst &Inst, unsigned Insn,
13781378 DecodeStatus S = MCDisassembler::Success;
13791379
13801380 unsigned Rn = fieldFromInstruction (Insn, 16 , 4 );
1381- unsigned mode = fieldFromInstruction (Insn, 23 , 2 );
1382-
1383- switch (mode) {
1384- case 0 :
1385- mode = ARM_AM::da;
1386- break ;
1387- case 1 :
1388- mode = ARM_AM::ia;
1389- break ;
1390- case 2 :
1391- mode = ARM_AM::db;
1392- break ;
1393- case 3 :
1394- mode = ARM_AM::ib;
1395- break ;
1396- }
1397-
1398- Inst.addOperand (MCOperand::createImm (mode));
13991381 if (!Check (S, DecodeGPRRegisterClass (Inst, Rn, Address, Decoder)))
14001382 return MCDisassembler::Fail;
14011383
@@ -2792,10 +2774,6 @@ static DecodeStatus DecodeMVEModImmInstruction(MCInst &Inst, unsigned Insn,
27922774
27932775 Inst.addOperand (MCOperand::createImm (imm));
27942776
2795- Inst.addOperand (MCOperand::createImm (ARMVCC::None));
2796- Inst.addOperand (MCOperand::createReg (0 ));
2797- Inst.addOperand (MCOperand::createImm (0 ));
2798-
27992777 return S;
28002778}
28012779
@@ -2820,7 +2798,6 @@ static DecodeStatus DecodeMVEVADCInstruction(MCInst &Inst, unsigned Insn,
28202798 return MCDisassembler::Fail;
28212799 if (!fieldFromInstruction (Insn, 12 , 1 )) // I bit clear => need input FPSCR
28222800 Inst.addOperand (MCOperand::createReg (ARM::FPSCR_NZCV));
2823- Inst.addOperand (MCOperand::createImm (Qd));
28242801
28252802 return S;
28262803}
@@ -5926,10 +5903,6 @@ static DecodeStatus DecodeMVEVCMP(MCInst &Inst, unsigned Insn, uint64_t Address,
59265903 if (!Check (S, predicate_decoder (Inst, fc, Address, Decoder)))
59275904 return MCDisassembler::Fail;
59285905
5929- Inst.addOperand (MCOperand::createImm (ARMVCC::None));
5930- Inst.addOperand (MCOperand::createReg (0 ));
5931- Inst.addOperand (MCOperand::createImm (0 ));
5932-
59335906 return S;
59345907}
59355908
@@ -6073,9 +6046,23 @@ DecodeStatus ARMDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
60736046 ArrayRef<uint8_t > Bytes,
60746047 uint64_t Address,
60756048 raw_ostream &CS) const {
6049+ DecodeStatus S;
60766050 if (STI.hasFeature (ARM::ModeThumb))
6077- return getThumbInstruction (MI, Size, Bytes, Address, CS);
6078- return getARMInstruction (MI, Size, Bytes, Address, CS);
6051+ S = getThumbInstruction (MI, Size, Bytes, Address, CS);
6052+ else
6053+ S = getARMInstruction (MI, Size, Bytes, Address, CS);
6054+ if (S == DecodeStatus::Fail)
6055+ return S;
6056+
6057+ // Verify that the decoded instruction has the correct number of operands.
6058+ const MCInstrDesc &MCID = MCII->get (MI.getOpcode ());
6059+ if (!MCID.isVariadic () && MI.getNumOperands () != MCID.getNumOperands ()) {
6060+ reportFatalInternalError (MCII->getName (MI.getOpcode ()) + " : expected " +
6061+ Twine (MCID.getNumOperands ()) + " operands, got " +
6062+ Twine (MI.getNumOperands ()) + " \n " );
6063+ }
6064+
6065+ return S;
60796066}
60806067
60816068DecodeStatus ARMDisassembler::getARMInstruction (MCInst &MI, uint64_t &Size,
@@ -6114,7 +6101,7 @@ DecodeStatus ARMDisassembler::getARMInstruction(MCInst &MI, uint64_t &Size,
61146101 const DecodeTable Tables[] = {
61156102 {DecoderTableVFP32, false }, {DecoderTableVFPV832, false },
61166103 {DecoderTableNEONData32, true }, {DecoderTableNEONLoadStore32, true },
6117- {DecoderTableNEONDup32, true }, {DecoderTablev8NEON32, false },
6104+ {DecoderTableNEONDup32, false }, {DecoderTablev8NEON32, false },
61186105 {DecoderTablev8Crypto32, false },
61196106 };
61206107
@@ -6124,8 +6111,10 @@ DecodeStatus ARMDisassembler::getARMInstruction(MCInst &MI, uint64_t &Size,
61246111 Size = 4 ;
61256112 // Add a fake predicate operand, because we share these instruction
61266113 // definitions with Thumb2 where these instructions are predicable.
6127- if (Table.DecodePred && !DecodePredicateOperand (MI, 0xE , Address, this ))
6128- return MCDisassembler::Fail;
6114+ if (Table.DecodePred && MCII->get (MI.getOpcode ()).isPredicable ()) {
6115+ MI.addOperand (MCOperand::createImm (ARMCC::AL));
6116+ MI.addOperand (MCOperand::createReg (ARM::NoRegister));
6117+ }
61296118 return Result;
61306119 }
61316120 }
@@ -6159,8 +6148,6 @@ void ARMDisassembler::AddThumb1SBit(MCInst &MI, bool InITBlock) const {
61596148 return ;
61606149 }
61616150 }
6162-
6163- MI.insert (I, MCOperand::createReg (InITBlock ? ARM::NoRegister : ARM::CPSR));
61646151}
61656152
61666153bool ARMDisassembler::isVectorPredicable (const MCInst &MI) const {
@@ -6461,7 +6448,6 @@ DecodeStatus ARMDisassembler::getThumbInstruction(MCInst &MI, uint64_t &Size,
64616448 STI);
64626449 if (Result != MCDisassembler::Fail) {
64636450 Size = 4 ;
6464- Check (Result, AddThumbPredicate (MI));
64656451 return Result;
64666452 }
64676453 }
0 commit comments