Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/arm/tcg/translate-a64.c | 41 ++++++++++++++++++++++++++++++++++
target/arm/tcg/a64.decode | 2 ++
2 files changed, 43 insertions(+)
diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c
index f3970ac599..c47d4d0a0b 100644
--- a/target/arm/tcg/translate-a64.c
+++ b/target/arm/tcg/translate-a64.c
@@ -1766,6 +1766,47 @@ static bool trans_CBH_cond(DisasContext *s, arg_CBH_cond *a)
return do_cb_cond(s, a->cc, a->imm, 16, a->rt, a->rm);
}
+static bool trans_CB_cond_imm(DisasContext *s, arg_CB_cond_imm *a)
+{
+ static const TCGCond cb_cond[8] = {
+ [0] = TCG_COND_GT,
+ [1] = TCG_COND_LT,
+ [2] = TCG_COND_GTU,
+ [3] = TCG_COND_LTU,
+ [4] = TCG_COND_NEVER, /* reserved */
+ [5] = TCG_COND_NEVER, /* reserved */
+ [6] = TCG_COND_EQ,
+ [7] = TCG_COND_NE,
+ };
+ TCGCond cond = cb_cond[a->cc];
+ TCGv_i64 t;
+
+ if (!dc_isar_feature(aa64_cmpbr, s) || cond == TCG_COND_NEVER) {
+ return false;
+ }
+
+ t = cpu_reg(s, a->rt);
+ if (!a->sf) {
+ TCGv_i64 tt = tcg_temp_new_i64();
+
+ if (is_signed_cond(cond)) {
+ tcg_gen_ext32s_i64(tt, t);
+ } else {
+ tcg_gen_ext32u_i64(tt, t);
+ }
+ t = tt;
+ }
+
+ reset_btype(s);
+ DisasLabel match = gen_disas_label(s);
+
+ tcg_gen_brcondi_i64(cond, t, a->imm6, match.label);
+ gen_goto_tb(s, 0, 4);
+ set_disas_label(s, match);
+ gen_goto_tb(s, 1, a->imm9);
+ return true;
+}
+
static void set_btype_for_br(DisasContext *s, int rn)
{
if (dc_isar_feature(aa64_bti, s)) {
diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode
index fa94631123..02e0aa1fe4 100644
--- a/target/arm/tcg/a64.decode
+++ b/target/arm/tcg/a64.decode
@@ -213,6 +213,8 @@ CB_cond sf:1 1110100 cc:3 rm:5 00 ......... rt:5 imm=%imm9
CBB_cond 0 1110100 cc:3 rm:5 10 ......... rt:5 imm=%imm9
CBH_cond 0 1110100 cc:3 rm:5 11 ......... rt:5 imm=%imm9
+CB_cond_imm sf:1 1110101 cc:3 imm6:6 0 ......... rt:5 %imm9
+
BR 1101011 0000 11111 000000 rn:5 00000 &r
BLR 1101011 0001 11111 000000 rn:5 00000 &r
RET 1101011 0010 11111 000000 rn:5 00000 &r
--
2.43.0