llvm.org GIT mirror llvm / 3862709
ARM: Fix STREX/LDREX reecoding The decoded MCInst wasn't reencoded as the same instruction git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183729 91177308-0d34-0410-b5e6-96231b3b80d8 Amaury de la Vieuville 7 years ago
3 changed file(s) with 58 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
163163 static DecodeStatus DecodetcGPRRegisterClass(MCInst &Inst, unsigned RegNo,
164164 uint64_t Address, const void *Decoder);
165165 static DecodeStatus DecoderGPRRegisterClass(MCInst &Inst, unsigned RegNo,
166 uint64_t Address, const void *Decoder);
167 static DecodeStatus DecodeGPRPairRegisterClass(MCInst &Inst, unsigned RegNo,
166168 uint64_t Address, const void *Decoder);
167169 static DecodeStatus DecodeSPRRegisterClass(MCInst &Inst, unsigned RegNo,
168170 uint64_t Address, const void *Decoder);
851853 if (RegNo > 7)
852854 return MCDisassembler::Fail;
853855 return DecodeGPRRegisterClass(Inst, RegNo, Address, Decoder);
856 }
857
858 static const uint16_t GPRPairDecoderTable[] = {
859 ARM::R0_R1, ARM::R2_R3, ARM::R4_R5, ARM::R6_R7,
860 ARM::R8_R9, ARM::R10_R11, ARM::R12_SP
861 };
862
863 static DecodeStatus DecodeGPRPairRegisterClass(MCInst &Inst, unsigned RegNo,
864 uint64_t Address, const void *Decoder) {
865 DecodeStatus S = MCDisassembler::Success;
866
867 if (RegNo > 13)
868 return MCDisassembler::Fail;
869
870 if ((RegNo & 1) || RegNo == 0xe)
871 S = MCDisassembler::SoftFail;
872
873 unsigned RegisterPair = GPRPairDecoderTable[RegNo/2];
874 Inst.addOperand(MCOperand::CreateReg(RegisterPair));
875 return S;
854876 }
855877
856878 static DecodeStatus DecodetcGPRRegisterClass(MCInst &Inst, unsigned RegNo,
35783600 unsigned Rn = fieldFromInstruction(Insn, 16, 4);
35793601 unsigned pred = fieldFromInstruction(Insn, 28, 4);
35803602
3581 if ((Rt & 1) || Rt == 0xE || Rn == 0xF) return MCDisassembler::Fail;
3582
3583 if (!Check(S, DecodeGPRRegisterClass(Inst, Rt, Address, Decoder)))
3584 return MCDisassembler::Fail;
3585 if (!Check(S, DecodeGPRRegisterClass(Inst, Rt+1, Address, Decoder)))
3603 if (Rn == 0xF)
3604 S = MCDisassembler::SoftFail;
3605
3606 if (!Check(S, DecodeGPRPairRegisterClass(Inst, Rt, Address, Decoder)))
35863607 return MCDisassembler::Fail;
35873608 if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
35883609 return MCDisassembler::Fail;
35913612
35923613 return S;
35933614 }
3594
35953615
35963616 static DecodeStatus DecodeDoubleRegStore(MCInst &Inst, unsigned Insn,
35973617 uint64_t Address, const void *Decoder){
36053625 if (!Check(S, DecodeGPRnopcRegisterClass(Inst, Rd, Address, Decoder)))
36063626 return MCDisassembler::Fail;
36073627
3608 if ((Rt & 1) || Rt == 0xE || Rn == 0xF) return MCDisassembler::Fail;
3609 if (Rd == Rn || Rd == Rt || Rd == Rt+1) return MCDisassembler::Fail;
3610
3611 if (!Check(S, DecodeGPRRegisterClass(Inst, Rt, Address, Decoder)))
3612 return MCDisassembler::Fail;
3613 if (!Check(S, DecodeGPRRegisterClass(Inst, Rt+1, Address, Decoder)))
3628 if (Rn == 0xF || Rd == Rn || Rd == Rt || Rd == Rt+1)
3629 S = MCDisassembler::SoftFail;
3630
3631 if (!Check(S, DecodeGPRPairRegisterClass(Inst, Rt, Address, Decoder)))
36143632 return MCDisassembler::Fail;
36153633 if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
36163634 return MCDisassembler::Fail;
0 # RUN: llvm-mc -triple armv7 -show-encoding -disassemble < %s | FileCheck %s
1
2 0x9f 0x0f 0xb0 0xe1
3 0x9f 0xcf 0xb1 0xe1
4 0x9f 0xcf 0xb3 0xe1
5 0x9f 0x8f 0xbd 0xe1
6 0x9f 0xcf 0xbe 0xe1
7
8 # CHECK: ldrexd r0, r1, [r0] @ encoding: [0x9f,0x0f,0xb0,0xe1]
9 # CHECK: ldrexd r12, sp, [r1] @ encoding: [0x9f,0xcf,0xb1,0xe1]
10 # CHECK: ldrexd r12, sp, [r3] @ encoding: [0x9f,0xcf,0xb3,0xe1]
11 # CHECK: ldrexd r8, r9, [sp] @ encoding: [0x9f,0x8f,0xbd,0xe1]
12 # CHECK: ldrexd r12, sp, [lr] @ encoding: [0x9f,0xcf,0xbe,0xe1]
13
0 # RUN: llvm-mc -triple armv7 -show-encoding -disassemble < %s | FileCheck %s
1
2 0x92 0x1f 0xa0 0xe1
3 0x90 0x4f 0xa3 0xe1
4 0x92 0xdf 0xa4 0xe1
5 0x90 0xaf 0xa6 0xe1
6 0x9c 0x5f 0xa8 0xe1
7
8 # CHECK: strexd r1, r2, r3, [r0] @ encoding: [0x92,0x1f,0xa0,0xe1]
9 # CHECK: strexd r4, r0, r1, [r3] @ encoding: [0x90,0x4f,0xa3,0xe1]
10 # CHECK: strexd sp, r2, r3, [r4] @ encoding: [0x92,0xdf,0xa4,0xe1]
11 # CHECK: strexd r10, r0, r1, [r6] @ encoding: [0x90,0xaf,0xa6,0xe1]
12 # CHECK: strexd r5, r12, sp, [r8] @ encoding: [0x9c,0x5f,0xa8,0xe1]
13