Skip to content

Commit 87748cf

Browse files
committed
Add awareness of some Armv8.1-M branch instructions
Armv8.1-M adds some new direct branch instructions. This commit adds support for parsing WLS, WLSTP, LE, and LETP instructions. The branch future (BF) family of instructions is not handled by this commit.
1 parent 1900c6f commit 87748cf

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

decoder/source/i_dec/trc_idec_arminst.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,16 @@ int inst_Thumb_is_direct_branch_link(uint32_t inst, uint8_t *is_link, uint8_t *i
154154
} else if ((inst & 0xf5000000) == 0xb1000000) {
155155
/* CB(NZ) */
156156
*is_cond = 1;
157+
} else if ((inst & 0xfffff001) == 0xf00fc001) {
158+
/* LE (encoding T1) */
159+
} else if ((inst & 0xfffff001) == 0xf02fc001) {
160+
/* LE (encoding T2) */
161+
} else if ((inst & 0xfffff001) == 0xf01fc001) {
162+
/* LETP (encoding T3) */
163+
} else if ((inst & 0xfff0f001) == 0xf040c001) {
164+
/* WLS (encoding T1) */
165+
} else if ((inst & 0xffc0f001) == 0xf000c001) {
166+
/* WLSTP (encoding T3) */
157167
} else {
158168
is_direct_branch = 0;
159169
}
@@ -410,6 +420,26 @@ int inst_Thumb_branch_destination(uint32_t addr, uint32_t inst, uint32_t *pnpc)
410420
npc = addr + 4 + ((((inst & 0x02000000) << 6) |
411421
((inst & 0x00f80000) << 7)) >> 25);
412422
npc |= 1;
423+
} else if ((inst & 0xfffff001) == 0xf00fc001) {
424+
/* LE (encoding T1) */
425+
npc = addr + 4 - (((inst & 0x000007fe) << 1) | ((inst & 0x00000800) >> 10));
426+
npc |= 1;
427+
} else if ((inst & 0xfffff001) == 0xf02fc001) {
428+
/* LE (encoding T2) */
429+
npc = addr + 4 - (((inst & 0x000007fe) << 1) | ((inst & 0x00000800) >> 10));
430+
npc |= 1;
431+
} else if ((inst & 0xfffff001) == 0xf01fc001) {
432+
/* LETP (encoding T3) */
433+
npc = addr + 4 - (((inst & 0x000007fe) << 1) | ((inst & 0x00000800) >> 10));
434+
npc |= 1;
435+
} else if ((inst & 0xfff0f001) == 0xf040c001) {
436+
/* WLS (encoding T1) */
437+
npc = addr + 4 + (((inst & 0x000007fe) << 1) | ((inst & 0x00000800) >> 10));
438+
npc |= 1;
439+
} else if ((inst & 0xffc0f001) == 0xf000c001) {
440+
/* WLSTP (encoding T3) */
441+
npc = addr + 4 + (((inst & 0x000007fe) << 1) | ((inst & 0x00000800) >> 10));
442+
npc |= 1;
413443
} else {
414444
is_direct_branch = 0;
415445
}

0 commit comments

Comments
 (0)