@@ -157,12 +157,6 @@ class ARMDisassembler : public MCDisassembler {
157157
158158} // end anonymous namespace
159159
160- // Forward declare these because the autogenerated code will reference them.
161- // Definitions are further down.
162- static DecodeStatus DecodeT2AddrModeImm8 (MCInst &Inst, unsigned Val,
163- uint64_t Address,
164- const MCDisassembler *Decoder);
165-
166160typedef DecodeStatus OperandDecoder (MCInst &Inst, unsigned Val,
167161 uint64_t Address,
168162 const MCDisassembler *Decoder);
@@ -3167,6 +3161,65 @@ static DecodeStatus DecodeT2LoadShift(MCInst &Inst, unsigned Insn,
31673161 return S;
31683162}
31693163
3164+ static DecodeStatus DecodeT2Imm8 (MCInst &Inst, unsigned Val, uint64_t Address,
3165+ const MCDisassembler *Decoder) {
3166+ int imm = Val & 0xFF ;
3167+ if (Val == 0 )
3168+ imm = INT32_MIN;
3169+ else if (!(Val & 0x100 ))
3170+ imm *= -1 ;
3171+ Inst.addOperand (MCOperand::createImm (imm));
3172+
3173+ return MCDisassembler::Success;
3174+ }
3175+
3176+ static DecodeStatus DecodeT2AddrModeImm8 (MCInst &Inst, unsigned Val,
3177+ uint64_t Address,
3178+ const MCDisassembler *Decoder) {
3179+ DecodeStatus S = MCDisassembler::Success;
3180+
3181+ unsigned Rn = fieldFromInstruction (Val, 9 , 4 );
3182+ unsigned imm = fieldFromInstruction (Val, 0 , 9 );
3183+
3184+ // Thumb stores cannot use PC as dest register.
3185+ switch (Inst.getOpcode ()) {
3186+ case ARM::t2STRT:
3187+ case ARM::t2STRBT:
3188+ case ARM::t2STRHT:
3189+ case ARM::t2STRi8:
3190+ case ARM::t2STRHi8:
3191+ case ARM::t2STRBi8:
3192+ if (Rn == 15 )
3193+ return MCDisassembler::Fail;
3194+ break ;
3195+ default :
3196+ break ;
3197+ }
3198+
3199+ // Some instructions always use an additive offset.
3200+ switch (Inst.getOpcode ()) {
3201+ case ARM::t2LDRT:
3202+ case ARM::t2LDRBT:
3203+ case ARM::t2LDRHT:
3204+ case ARM::t2LDRSBT:
3205+ case ARM::t2LDRSHT:
3206+ case ARM::t2STRT:
3207+ case ARM::t2STRBT:
3208+ case ARM::t2STRHT:
3209+ imm |= 0x100 ;
3210+ break ;
3211+ default :
3212+ break ;
3213+ }
3214+
3215+ if (!Check (S, DecodeGPRRegisterClass (Inst, Rn, Address, Decoder)))
3216+ return MCDisassembler::Fail;
3217+ if (!Check (S, DecodeT2Imm8 (Inst, imm, Address, Decoder)))
3218+ return MCDisassembler::Fail;
3219+
3220+ return S;
3221+ }
3222+
31703223static DecodeStatus DecodeT2LoadImm8 (MCInst &Inst, unsigned Insn,
31713224 uint64_t Address,
31723225 const MCDisassembler *Decoder) {
@@ -3476,18 +3529,6 @@ static DecodeStatus DecodeT2AddrModeImm0_1020s4(MCInst &Inst, unsigned Val,
34763529 return S;
34773530}
34783531
3479- static DecodeStatus DecodeT2Imm8 (MCInst &Inst, unsigned Val, uint64_t Address,
3480- const MCDisassembler *Decoder) {
3481- int imm = Val & 0xFF ;
3482- if (Val == 0 )
3483- imm = INT32_MIN;
3484- else if (!(Val & 0x100 ))
3485- imm *= -1 ;
3486- Inst.addOperand (MCOperand::createImm (imm));
3487-
3488- return MCDisassembler::Success;
3489- }
3490-
34913532template <int shift>
34923533static DecodeStatus DecodeT2Imm7 (MCInst &Inst, unsigned Val, uint64_t Address,
34933534 const MCDisassembler *Decoder) {
@@ -3503,53 +3544,6 @@ static DecodeStatus DecodeT2Imm7(MCInst &Inst, unsigned Val, uint64_t Address,
35033544 return MCDisassembler::Success;
35043545}
35053546
3506- static DecodeStatus DecodeT2AddrModeImm8 (MCInst &Inst, unsigned Val,
3507- uint64_t Address,
3508- const MCDisassembler *Decoder) {
3509- DecodeStatus S = MCDisassembler::Success;
3510-
3511- unsigned Rn = fieldFromInstruction (Val, 9 , 4 );
3512- unsigned imm = fieldFromInstruction (Val, 0 , 9 );
3513-
3514- // Thumb stores cannot use PC as dest register.
3515- switch (Inst.getOpcode ()) {
3516- case ARM::t2STRT:
3517- case ARM::t2STRBT:
3518- case ARM::t2STRHT:
3519- case ARM::t2STRi8:
3520- case ARM::t2STRHi8:
3521- case ARM::t2STRBi8:
3522- if (Rn == 15 )
3523- return MCDisassembler::Fail;
3524- break ;
3525- default :
3526- break ;
3527- }
3528-
3529- // Some instructions always use an additive offset.
3530- switch (Inst.getOpcode ()) {
3531- case ARM::t2LDRT:
3532- case ARM::t2LDRBT:
3533- case ARM::t2LDRHT:
3534- case ARM::t2LDRSBT:
3535- case ARM::t2LDRSHT:
3536- case ARM::t2STRT:
3537- case ARM::t2STRBT:
3538- case ARM::t2STRHT:
3539- imm |= 0x100 ;
3540- break ;
3541- default :
3542- break ;
3543- }
3544-
3545- if (!Check (S, DecodeGPRRegisterClass (Inst, Rn, Address, Decoder)))
3546- return MCDisassembler::Fail;
3547- if (!Check (S, DecodeT2Imm8 (Inst, imm, Address, Decoder)))
3548- return MCDisassembler::Fail;
3549-
3550- return S;
3551- }
3552-
35533547template <int shift>
35543548static DecodeStatus DecodeTAddrModeImm7 (MCInst &Inst, unsigned Val,
35553549 uint64_t Address,
0 commit comments