[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 13/20] target/arm: Convert unconditional branch immediate to deco
From: |
Peter Maydell |
Subject: |
[PATCH 13/20] target/arm: Convert unconditional branch immediate to decodetree |
Date: |
Fri, 12 May 2023 15:40:59 +0100 |
Convert the unconditional branch immediate insns B and BL to
decodetree.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/arm/tcg/a64.decode | 9 +++++++++
target/arm/tcg/translate-a64.c | 31 +++++++++++--------------------
2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode
index eb5d4cb0d57..d54c6522028 100644
--- a/target/arm/tcg/a64.decode
+++ b/target/arm/tcg/a64.decode
@@ -21,6 +21,7 @@
&ri rd imm
&rri_sf rd rn imm sf
+&i imm
### Data Processing - Immediate
@@ -106,3 +107,11 @@ UBFM . 10 100110 . ...... ...... ..... .....
@bitfield_32
EXTR . 00 100111 . 0 ..... ...... ..... ..... @extract_64
EXTR . 00 100111 . 0 ..... ...... ..... ..... @extract_32
+
+# Branches
+
+%imm26 0:s26 !function=times_4
+@branch . ..... .......................... &i imm=%imm26
+
+B 0 00101 .......................... @branch
+BL 1 00101 .......................... @branch
diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c
index 4319559057f..fe6b4a68288 100644
--- a/target/arm/tcg/translate-a64.c
+++ b/target/arm/tcg/translate-a64.c
@@ -1319,24 +1319,19 @@ static inline AArch64DecodeFn *lookup_disas_fn(const
AArch64DecodeTable *table,
* match up with those in the manual.
*/
-/* Unconditional branch (immediate)
- * 31 30 26 25 0
- * +----+-----------+-------------------------------------+
- * | op | 0 0 1 0 1 | imm26 |
- * +----+-----------+-------------------------------------+
- */
-static void disas_uncond_b_imm(DisasContext *s, uint32_t insn)
+static bool trans_B(DisasContext *s, arg_i *a)
{
- int64_t diff = sextract32(insn, 0, 26) * 4;
-
- if (insn & (1U << 31)) {
- /* BL Branch with link */
- gen_pc_plus_diff(s, cpu_reg(s, 30), curr_insn_len(s));
- }
-
- /* B Branch / BL Branch with link */
reset_btype(s);
- gen_goto_tb(s, 0, diff);
+ gen_goto_tb(s, 0, a->imm);
+ return true;
+}
+
+static bool trans_BL(DisasContext *s, arg_i *a)
+{
+ gen_pc_plus_diff(s, cpu_reg(s, 30), curr_insn_len(s));
+ reset_btype(s);
+ gen_goto_tb(s, 0, a->imm);
+ return true;
}
/* Compare and branch (immediate)
@@ -2413,10 +2408,6 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t
insn)
static void disas_b_exc_sys(DisasContext *s, uint32_t insn)
{
switch (extract32(insn, 25, 7)) {
- case 0x0a: case 0x0b:
- case 0x4a: case 0x4b: /* Unconditional branch (immediate) */
- disas_uncond_b_imm(s, insn);
- break;
case 0x1a: case 0x5a: /* Compare & branch (immediate) */
disas_comp_b_imm(s, insn);
break;
--
2.34.1
- [PATCH 02/20] target/arm: Create decodetree skeleton for A64, (continued)
- [PATCH 02/20] target/arm: Create decodetree skeleton for A64, Peter Maydell, 2023/05/12
- [PATCH 06/20] target/arm: Convert Add/subtract (immediate) to decodetree, Peter Maydell, 2023/05/12
- [PATCH 07/20] target/arm: Convert Add/subtract (immediate with tags) to decodetree, Peter Maydell, 2023/05/12
- [PATCH 01/20] target/arm: Split out disas_a64_legacy, Peter Maydell, 2023/05/12
- [PATCH 09/20] target/arm: Convert Logical (immediate) to decodetree, Peter Maydell, 2023/05/12
- [PATCH 10/20] target/arm: Convert Move wide (immediate) to decodetree, Peter Maydell, 2023/05/12
- [PATCH 11/20] target/arm: Convert Bitfield to decodetree, Peter Maydell, 2023/05/12
- [PATCH 12/20] target/arm: Convert Extract instructions to decodetree, Peter Maydell, 2023/05/12
- [PATCH 13/20] target/arm: Convert unconditional branch immediate to decodetree,
Peter Maydell <=
- [PATCH 16/20] target/arm: Convert conditional branch insns to decodetree, Peter Maydell, 2023/05/12
- [PATCH 14/20] target/arm: Convert CBZ, CBNZ to decodetree, Peter Maydell, 2023/05/12
- [PATCH 15/20] target/arm: Convert TBZ, TBNZ to decodetree, Peter Maydell, 2023/05/12
- [PATCH 18/20] target/arm: Convert BRA[AB]Z, BLR[AB]Z, RETA[AB] to decodetree, Peter Maydell, 2023/05/12
- [PATCH 20/20] target/arm: Convert ERET, ERETAA, ERETAB to decodetree, Peter Maydell, 2023/05/12