@@ -152,7 +152,7 @@ class ARMDisassembler : public MCDisassembler {
152
152
void AddThumb1SBit (MCInst &MI, bool InITBlock) const ;
153
153
bool isVectorPredicable (const MCInst &MI) const ;
154
154
DecodeStatus AddThumbPredicate (MCInst&) const ;
155
- void UpdateThumbVFPPredicate (DecodeStatus &, MCInst& ) const ;
155
+ void UpdateThumbPredicate (DecodeStatus &S , MCInst &MI ) const ;
156
156
157
157
llvm::endianness InstructionEndianness;
158
158
};
@@ -1378,24 +1378,6 @@ static DecodeStatus DecodeRFEInstruction(MCInst &Inst, unsigned Insn,
1378
1378
DecodeStatus S = MCDisassembler::Success;
1379
1379
1380
1380
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));
1399
1381
if (!Check (S, DecodeGPRRegisterClass (Inst, Rn, Address, Decoder)))
1400
1382
return MCDisassembler::Fail;
1401
1383
@@ -2792,10 +2774,6 @@ static DecodeStatus DecodeMVEModImmInstruction(MCInst &Inst, unsigned Insn,
2792
2774
2793
2775
Inst.addOperand (MCOperand::createImm (imm));
2794
2776
2795
- Inst.addOperand (MCOperand::createImm (ARMVCC::None));
2796
- Inst.addOperand (MCOperand::createReg (0 ));
2797
- Inst.addOperand (MCOperand::createImm (0 ));
2798
-
2799
2777
return S;
2800
2778
}
2801
2779
@@ -2820,7 +2798,6 @@ static DecodeStatus DecodeMVEVADCInstruction(MCInst &Inst, unsigned Insn,
2820
2798
return MCDisassembler::Fail;
2821
2799
if (!fieldFromInstruction (Insn, 12 , 1 )) // I bit clear => need input FPSCR
2822
2800
Inst.addOperand (MCOperand::createReg (ARM::FPSCR_NZCV));
2823
- Inst.addOperand (MCOperand::createImm (Qd));
2824
2801
2825
2802
return S;
2826
2803
}
@@ -5926,10 +5903,6 @@ static DecodeStatus DecodeMVEVCMP(MCInst &Inst, unsigned Insn, uint64_t Address,
5926
5903
if (!Check (S, predicate_decoder (Inst, fc, Address, Decoder)))
5927
5904
return MCDisassembler::Fail;
5928
5905
5929
- Inst.addOperand (MCOperand::createImm (ARMVCC::None));
5930
- Inst.addOperand (MCOperand::createReg (0 ));
5931
- Inst.addOperand (MCOperand::createImm (0 ));
5932
-
5933
5906
return S;
5934
5907
}
5935
5908
@@ -6073,9 +6046,23 @@ DecodeStatus ARMDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
6073
6046
ArrayRef<uint8_t > Bytes,
6074
6047
uint64_t Address,
6075
6048
raw_ostream &CS) const {
6049
+ DecodeStatus S;
6076
6050
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;
6079
6066
}
6080
6067
6081
6068
DecodeStatus ARMDisassembler::getARMInstruction (MCInst &MI, uint64_t &Size,
@@ -6114,7 +6101,7 @@ DecodeStatus ARMDisassembler::getARMInstruction(MCInst &MI, uint64_t &Size,
6114
6101
const DecodeTable Tables[] = {
6115
6102
{DecoderTableVFP32, false }, {DecoderTableVFPV832, false },
6116
6103
{DecoderTableNEONData32, true }, {DecoderTableNEONLoadStore32, true },
6117
- {DecoderTableNEONDup32, true }, {DecoderTablev8NEON32, false },
6104
+ {DecoderTableNEONDup32, false }, {DecoderTablev8NEON32, false },
6118
6105
{DecoderTablev8Crypto32, false },
6119
6106
};
6120
6107
@@ -6124,8 +6111,10 @@ DecodeStatus ARMDisassembler::getARMInstruction(MCInst &MI, uint64_t &Size,
6124
6111
Size = 4 ;
6125
6112
// Add a fake predicate operand, because we share these instruction
6126
6113
// 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
+ }
6129
6118
return Result;
6130
6119
}
6131
6120
}
@@ -6159,8 +6148,6 @@ void ARMDisassembler::AddThumb1SBit(MCInst &MI, bool InITBlock) const {
6159
6148
return ;
6160
6149
}
6161
6150
}
6162
-
6163
- MI.insert (I, MCOperand::createReg (InITBlock ? ARM::NoRegister : ARM::CPSR));
6164
6151
}
6165
6152
6166
6153
bool ARMDisassembler::isVectorPredicable (const MCInst &MI) const {
@@ -6291,13 +6278,12 @@ ARMDisassembler::AddThumbPredicate(MCInst &MI) const {
6291
6278
return S;
6292
6279
}
6293
6280
6294
- // Thumb VFP instructions are a special case. Because we share their
6295
- // encodings between ARM and Thumb modes, and they are predicable in ARM
6281
+ // Thumb VFP and some NEON instructions are a special case. Because we share
6282
+ // their encodings between ARM and Thumb modes, and they are predicable in ARM
6296
6283
// mode, the auto-generated decoder will give them an (incorrect)
6297
6284
// predicate operand. We need to rewrite these operands based on the IT
6298
6285
// context as a post-pass.
6299
- void ARMDisassembler::UpdateThumbVFPPredicate (
6300
- DecodeStatus &S, MCInst &MI) const {
6286
+ void ARMDisassembler::UpdateThumbPredicate (DecodeStatus &S, MCInst &MI) const {
6301
6287
unsigned CC;
6302
6288
CC = ITBlock.getITCC ();
6303
6289
if (CC == 0xF )
@@ -6444,7 +6430,7 @@ DecodeStatus ARMDisassembler::getThumbInstruction(MCInst &MI, uint64_t &Size,
6444
6430
decodeInstruction (DecoderTableVFP32, MI, Insn32, Address, this , STI);
6445
6431
if (Result != MCDisassembler::Fail) {
6446
6432
Size = 4 ;
6447
- UpdateThumbVFPPredicate (Result, MI);
6433
+ UpdateThumbPredicate (Result, MI);
6448
6434
return Result;
6449
6435
}
6450
6436
}
@@ -6461,7 +6447,7 @@ DecodeStatus ARMDisassembler::getThumbInstruction(MCInst &MI, uint64_t &Size,
6461
6447
STI);
6462
6448
if (Result != MCDisassembler::Fail) {
6463
6449
Size = 4 ;
6464
- Check (Result, AddThumbPredicate (MI) );
6450
+ UpdateThumbPredicate (Result, MI );
6465
6451
return Result;
6466
6452
}
6467
6453
}
0 commit comments