@@ -159,12 +159,6 @@ class ARMDisassembler : public MCDisassembler {
159159
160160} // end anonymous namespace
161161
162- // Forward declare these because the autogenerated code will reference them.
163- // Definitions are further down.
164- static DecodeStatus DecodeT2AddrModeImm8 (MCInst &Inst, unsigned Val,
165- uint64_t Address,
166- const MCDisassembler *Decoder);
167-
168162typedef DecodeStatus OperandDecoder (MCInst &Inst, unsigned Val,
169163 uint64_t Address,
170164 const MCDisassembler *Decoder);
@@ -3181,6 +3175,65 @@ static DecodeStatus DecodeT2LoadShift(MCInst &Inst, unsigned Insn,
31813175 return S;
31823176}
31833177
3178+ static DecodeStatus DecodeT2Imm8 (MCInst &Inst, unsigned Val, uint64_t Address,
3179+ const MCDisassembler *Decoder) {
3180+ int imm = Val & 0xFF ;
3181+ if (Val == 0 )
3182+ imm = INT32_MIN;
3183+ else if (!(Val & 0x100 ))
3184+ imm *= -1 ;
3185+ Inst.addOperand (MCOperand::createImm (imm));
3186+
3187+ return MCDisassembler::Success;
3188+ }
3189+
3190+ static DecodeStatus DecodeT2AddrModeImm8 (MCInst &Inst, unsigned Val,
3191+ uint64_t Address,
3192+ const MCDisassembler *Decoder) {
3193+ DecodeStatus S = MCDisassembler::Success;
3194+
3195+ unsigned Rn = fieldFromInstruction (Val, 9 , 4 );
3196+ unsigned imm = fieldFromInstruction (Val, 0 , 9 );
3197+
3198+ // Thumb stores cannot use PC as dest register.
3199+ switch (Inst.getOpcode ()) {
3200+ case ARM::t2STRT:
3201+ case ARM::t2STRBT:
3202+ case ARM::t2STRHT:
3203+ case ARM::t2STRi8:
3204+ case ARM::t2STRHi8:
3205+ case ARM::t2STRBi8:
3206+ if (Rn == 15 )
3207+ return MCDisassembler::Fail;
3208+ break ;
3209+ default :
3210+ break ;
3211+ }
3212+
3213+ // Some instructions always use an additive offset.
3214+ switch (Inst.getOpcode ()) {
3215+ case ARM::t2LDRT:
3216+ case ARM::t2LDRBT:
3217+ case ARM::t2LDRHT:
3218+ case ARM::t2LDRSBT:
3219+ case ARM::t2LDRSHT:
3220+ case ARM::t2STRT:
3221+ case ARM::t2STRBT:
3222+ case ARM::t2STRHT:
3223+ imm |= 0x100 ;
3224+ break ;
3225+ default :
3226+ break ;
3227+ }
3228+
3229+ if (!Check (S, DecodeGPRRegisterClass (Inst, Rn, Address, Decoder)))
3230+ return MCDisassembler::Fail;
3231+ if (!Check (S, DecodeT2Imm8 (Inst, imm, Address, Decoder)))
3232+ return MCDisassembler::Fail;
3233+
3234+ return S;
3235+ }
3236+
31843237static DecodeStatus DecodeT2LoadImm8 (MCInst &Inst, unsigned Insn,
31853238 uint64_t Address,
31863239 const MCDisassembler *Decoder) {
@@ -3490,18 +3543,6 @@ static DecodeStatus DecodeT2AddrModeImm0_1020s4(MCInst &Inst, unsigned Val,
34903543 return S;
34913544}
34923545
3493- static DecodeStatus DecodeT2Imm8 (MCInst &Inst, unsigned Val, uint64_t Address,
3494- const MCDisassembler *Decoder) {
3495- int imm = Val & 0xFF ;
3496- if (Val == 0 )
3497- imm = INT32_MIN;
3498- else if (!(Val & 0x100 ))
3499- imm *= -1 ;
3500- Inst.addOperand (MCOperand::createImm (imm));
3501-
3502- return MCDisassembler::Success;
3503- }
3504-
35053546template <int shift>
35063547static DecodeStatus DecodeT2Imm7 (MCInst &Inst, unsigned Val, uint64_t Address,
35073548 const MCDisassembler *Decoder) {
@@ -3517,53 +3558,6 @@ static DecodeStatus DecodeT2Imm7(MCInst &Inst, unsigned Val, uint64_t Address,
35173558 return MCDisassembler::Success;
35183559}
35193560
3520- static DecodeStatus DecodeT2AddrModeImm8 (MCInst &Inst, unsigned Val,
3521- uint64_t Address,
3522- const MCDisassembler *Decoder) {
3523- DecodeStatus S = MCDisassembler::Success;
3524-
3525- unsigned Rn = fieldFromInstruction (Val, 9 , 4 );
3526- unsigned imm = fieldFromInstruction (Val, 0 , 9 );
3527-
3528- // Thumb stores cannot use PC as dest register.
3529- switch (Inst.getOpcode ()) {
3530- case ARM::t2STRT:
3531- case ARM::t2STRBT:
3532- case ARM::t2STRHT:
3533- case ARM::t2STRi8:
3534- case ARM::t2STRHi8:
3535- case ARM::t2STRBi8:
3536- if (Rn == 15 )
3537- return MCDisassembler::Fail;
3538- break ;
3539- default :
3540- break ;
3541- }
3542-
3543- // Some instructions always use an additive offset.
3544- switch (Inst.getOpcode ()) {
3545- case ARM::t2LDRT:
3546- case ARM::t2LDRBT:
3547- case ARM::t2LDRHT:
3548- case ARM::t2LDRSBT:
3549- case ARM::t2LDRSHT:
3550- case ARM::t2STRT:
3551- case ARM::t2STRBT:
3552- case ARM::t2STRHT:
3553- imm |= 0x100 ;
3554- break ;
3555- default :
3556- break ;
3557- }
3558-
3559- if (!Check (S, DecodeGPRRegisterClass (Inst, Rn, Address, Decoder)))
3560- return MCDisassembler::Fail;
3561- if (!Check (S, DecodeT2Imm8 (Inst, imm, Address, Decoder)))
3562- return MCDisassembler::Fail;
3563-
3564- return S;
3565- }
3566-
35673561template <int shift>
35683562static DecodeStatus DecodeTAddrModeImm7 (MCInst &Inst, unsigned Val,
35693563 uint64_t Address,
0 commit comments