Skip to content

Commit 0f56fdd

Browse files
committed
[ARMv7] Expand ARM, Thumb, and NEON lifting coverage
Add LLIL support for a broad set of previously unimplemented or partially implemented ARMv7, Thumb2, VFP, and NEON instructions. Cover system, control, synchronization, hint, and coprocessor operations, including MRS, MSR, VMSR, VMRS, SMC, HVC, CPS/CPSID/CPSIE, CLREX, DMB, DSB, ISB, PLD, SETEND, SRS/RFE, STC/LDC variants, and related intrinsics. Add integer, DSP, saturation, CRC, multiply, and packed arithmetic lifting, including CRC32 variants, QADD/QSUB forms, SSAT/USAT forms, SMMUL/SMMLA, SMLA/SMLAL variants, SXT/UXT variants, REV/RBIT/SEL, packed add/sub variants, UQASX/UQSAX, and Thumb writeback/control-transfer cases. Expand VFP/NEON support for vector moves, arithmetic, comparisons, conversions, shifts, narrowing/widening operations, structured loads/stores, table lookup, reductions, duplicate/reverse/ext operations, and fused multiply forms, wiring new intrinsics and metadata where needed. Extend ARM/Thumb decoder support where required, including CRC32 Thumb variants, and add focused ARM and Thumb lift tests for the new coverage.
1 parent f49bc8f commit 0f56fdd

9 files changed

Lines changed: 8623 additions & 1660 deletions

File tree

arch/armv7/arch_armv7.cpp

Lines changed: 987 additions & 0 deletions
Large diffs are not rendered by default.

arch/armv7/armv7_disasm/armv7.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,32 @@ static Register regMap[2] = {REG_D0, REG_Q0};
4848
#define SET_REGISTER(x) (1<<((x)))
4949
#define DECODE_DT(s,u) (enum DataType)(1+((((u&1))<<2) | ((s)&3)))
5050

51+
static uint32_t armv7_crc32(uint32_t instructionValue, Instruction* restrict instruction)
52+
{
53+
if ((instructionValue & 0x0f900df0) != 0x01000040)
54+
return 1;
55+
56+
uint32_t size = (instructionValue >> 21) & 3;
57+
uint32_t castagnoli = (instructionValue >> 9) & 1;
58+
if (size == 3)
59+
return 1;
60+
61+
static Operation crc32Operation[2][3] = {
62+
{ ARMV7_CRC32B, ARMV7_CRC32H, ARMV7_CRC32W },
63+
{ ARMV7_CRC32CB, ARMV7_CRC32CH, ARMV7_CRC32CW },
64+
};
65+
66+
instruction->operation = crc32Operation[castagnoli][size];
67+
instruction->cond = (enum Condition)(instructionValue >> 28);
68+
instruction->operands[0].cls = REG;
69+
instruction->operands[0].reg = (enum Register)((instructionValue >> 12) & 0xf);
70+
instruction->operands[1].cls = REG;
71+
instruction->operands[1].reg = (enum Register)((instructionValue >> 16) & 0xf);
72+
instruction->operands[2].cls = REG;
73+
instruction->operands[2].reg = (enum Register)(instructionValue & 0xf);
74+
return 0;
75+
}
76+
5177
static const char* operationString[] = {
5278
"UNDEFINED",
5379
"UNPREDICTABLE",
@@ -77,6 +103,12 @@ static const char* operationString[] = {
77103
"cdp2",
78104
"clrex",
79105
"clz",
106+
"crc32b",
107+
"crc32cb",
108+
"crc32ch",
109+
"crc32cw",
110+
"crc32h",
111+
"crc32w",
80112
"cmn",
81113
"cmp",
82114
"cps",
@@ -1081,6 +1113,9 @@ uint32_t armv7_data_processing_and_misc(uint32_t instructionValue, Instruction*
10811113
} decode;
10821114

10831115
decode.value = instructionValue;
1116+
if (armv7_crc32(instructionValue, instruction) == 0)
1117+
return 0;
1118+
10841119
if (decode.op == 0)
10851120
{
10861121
if ((decode.op1 & 0x19) == 0x10) //10xx0

arch/armv7/armv7_disasm/armv7.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ enum Operation {
5555
ARMV7_CDP2,
5656
ARMV7_CLREX,
5757
ARMV7_CLZ,
58+
ARMV7_CRC32B,
59+
ARMV7_CRC32CB,
60+
ARMV7_CRC32CH,
61+
ARMV7_CRC32CW,
62+
ARMV7_CRC32H,
63+
ARMV7_CRC32W,
5864
ARMV7_CMN,
5965
ARMV7_CMP,
6066
ARMV7_CPS,

0 commit comments

Comments
 (0)