diff mbox series

[v5,03/14] Hexagon (target/hexagon) Add overrides for endloop1/endloop01

Message ID 20230131225647.25274-4-tsimpson@quicinc.com (mailing list archive)
State New, archived
Headers show
Series Hexagon: COF overrides, new generator, test/bug update | expand

Commit Message

Taylor Simpson Jan. 31, 2023, 10:56 p.m. UTC
Signed-off-by: Taylor Simpson <tsimpson@quicinc.com>
---
 target/hexagon/gen_tcg.h |  4 ++
 target/hexagon/genptr.c  | 79 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+)

Comments

Gao,Shiyuan" via Feb. 1, 2023, 12:29 p.m. UTC | #1
> +
> +static void gen_endloop01(DisasContext *ctx)
> +{
> +    TCGv lpcfg = tcg_temp_local_new();
Move label declarations here per coding style
> +
> +    GET_USR_FIELD(USR_LPCFG, lpcfg);
> +
> +    /*
> +     *    if (lpcfg == 1) {
> +     *        hex_new_pred_value[3] = 0xff;
> +     *        hex_pred_written |= 1 << 3;
> +     *    }
> +     */
> +    TCGLabel *label1 = gen_new_label();
> +    tcg_gen_brcondi_tl(TCG_COND_NE, lpcfg, 1, label1);
> +    {
> +        tcg_gen_movi_tl(hex_new_pred_value[3], 0xff);
> +        tcg_gen_ori_tl(hex_pred_written, hex_pred_written, 1 << 3);
> +    }
> +    gen_set_label(label1);
> +
> +    /*
> +     *    if (lpcfg) {
> +     *        SET_USR_FIELD(USR_LPCFG, lpcfg - 1);
> +     *    }
> +     */
> +    TCGLabel *label2 = gen_new_label();
> +    tcg_gen_brcondi_tl(TCG_COND_EQ, lpcfg, 0, label2);
> +    {
> +        tcg_gen_subi_tl(lpcfg, lpcfg, 1);
> +        SET_USR_FIELD(USR_LPCFG, lpcfg);
> +    }
> +    gen_set_label(label2);
Move tcg_temp_free(lpcfg) here
> +
> +    /*
> +     *    if (hex_gpr[HEX_REG_LC0] > 1) {
> +     *        PC = hex_gpr[HEX_REG_SA0];
> +     *        hex_new_value[HEX_REG_LC0] = hex_gpr[HEX_REG_LC0] - 1;
> +     *    } else {
> +     *        if (hex_gpr[HEX_REG_LC1] > 1) {
> +     *            hex_next_pc = hex_gpr[HEX_REG_SA1];
> +     *            hex_new_value[HEX_REG_LC1] = hex_gpr[HEX_REG_LC1] - 1;
> +     *        }
> +     *    }
> +     */
> +    TCGLabel *label3 = gen_new_label();
> +    TCGLabel *done = gen_new_label();
> +    tcg_gen_brcondi_tl(TCG_COND_LEU, hex_gpr[HEX_REG_LC0], 1, label3);
> +    {
> +        gen_jumpr(ctx, hex_gpr[HEX_REG_SA0]);
> +        tcg_gen_subi_tl(hex_new_value[HEX_REG_LC0], hex_gpr[HEX_REG_LC0], 1);
> +        tcg_gen_br(done);
> +    }
> +    gen_set_label(label3);
> +    tcg_gen_brcondi_tl(TCG_COND_LEU, hex_gpr[HEX_REG_LC1], 1, done);
> +    {
> +        gen_jumpr(ctx, hex_gpr[HEX_REG_SA1]);
> +        tcg_gen_subi_tl(hex_new_value[HEX_REG_LC1], hex_gpr[HEX_REG_LC1], 1);
> +    }
> +    gen_set_label(done);
> +    tcg_temp_free(lpcfg);
> +}
> +
>   static void gen_cmp_jumpnv(DisasContext *ctx,
>                              TCGCond cond, TCGv val, TCGv src, int pc_off)
>   {

Otherwise this patch looks good,

Reviewed-by: Anton Johansson <anjo@rev.ng>
Taylor Simpson Feb. 1, 2023, 6:43 p.m. UTC | #2
> -----Original Message-----
> From: Anton Johansson <anjo@rev.ng>
> Sent: Wednesday, February 1, 2023 6:30 AM
> To: Taylor Simpson <tsimpson@quicinc.com>; qemu-devel@nongnu.org
> Cc: richard.henderson@linaro.org; philmd@linaro.org; ale@rev.ng; Brian Cain
> <bcain@quicinc.com>; Matheus Bernardino (QUIC)
> <quic_mathbern@quicinc.com>
> Subject: Re: [PATCH v5 03/14] Hexagon (target/hexagon) Add overrides for
> endloop1/endloop01
> 
> Otherwise this patch looks good,
> 
> Reviewed-by: Anton Johansson <anjo@rev.ng>

Thanks for the feedback.  I'll make the changes in the next version of the series.

Taylor
diff mbox series

Patch

diff --git a/target/hexagon/gen_tcg.h b/target/hexagon/gen_tcg.h
index 9e8f3373ad..6267f51ccc 100644
--- a/target/hexagon/gen_tcg.h
+++ b/target/hexagon/gen_tcg.h
@@ -628,6 +628,10 @@ 
 
 #define fGEN_TCG_J2_endloop0(SHORTCODE) \
     gen_endloop0(ctx)
+#define fGEN_TCG_J2_endloop1(SHORTCODE) \
+    gen_endloop1(ctx)
+#define fGEN_TCG_J2_endloop01(SHORTCODE) \
+    gen_endloop01(ctx)
 
 /*
  * Compound compare and jump instructions
diff --git a/target/hexagon/genptr.c b/target/hexagon/genptr.c
index 360bcd0a19..e17ac93a59 100644
--- a/target/hexagon/genptr.c
+++ b/target/hexagon/genptr.c
@@ -803,6 +803,85 @@  static void gen_endloop0(DisasContext *ctx)
     tcg_temp_free(lpcfg);
 }
 
+static void gen_endloop1(DisasContext *ctx)
+{
+    /*
+     *    if (hex_gpr[HEX_REG_LC1] > 1) {
+     *        PC = hex_gpr[HEX_REG_SA1];
+     *        hex_new_value[HEX_REG_LC1] = hex_gpr[HEX_REG_LC1] - 1;
+     *    }
+     */
+    TCGLabel *label = gen_new_label();
+    tcg_gen_brcondi_tl(TCG_COND_LEU, hex_gpr[HEX_REG_LC1], 1, label);
+    {
+        gen_jumpr(ctx, hex_gpr[HEX_REG_SA1]);
+        tcg_gen_subi_tl(hex_new_value[HEX_REG_LC1], hex_gpr[HEX_REG_LC1], 1);
+    }
+    gen_set_label(label);
+}
+
+static void gen_endloop01(DisasContext *ctx)
+{
+    TCGv lpcfg = tcg_temp_local_new();
+
+    GET_USR_FIELD(USR_LPCFG, lpcfg);
+
+    /*
+     *    if (lpcfg == 1) {
+     *        hex_new_pred_value[3] = 0xff;
+     *        hex_pred_written |= 1 << 3;
+     *    }
+     */
+    TCGLabel *label1 = gen_new_label();
+    tcg_gen_brcondi_tl(TCG_COND_NE, lpcfg, 1, label1);
+    {
+        tcg_gen_movi_tl(hex_new_pred_value[3], 0xff);
+        tcg_gen_ori_tl(hex_pred_written, hex_pred_written, 1 << 3);
+    }
+    gen_set_label(label1);
+
+    /*
+     *    if (lpcfg) {
+     *        SET_USR_FIELD(USR_LPCFG, lpcfg - 1);
+     *    }
+     */
+    TCGLabel *label2 = gen_new_label();
+    tcg_gen_brcondi_tl(TCG_COND_EQ, lpcfg, 0, label2);
+    {
+        tcg_gen_subi_tl(lpcfg, lpcfg, 1);
+        SET_USR_FIELD(USR_LPCFG, lpcfg);
+    }
+    gen_set_label(label2);
+
+    /*
+     *    if (hex_gpr[HEX_REG_LC0] > 1) {
+     *        PC = hex_gpr[HEX_REG_SA0];
+     *        hex_new_value[HEX_REG_LC0] = hex_gpr[HEX_REG_LC0] - 1;
+     *    } else {
+     *        if (hex_gpr[HEX_REG_LC1] > 1) {
+     *            hex_next_pc = hex_gpr[HEX_REG_SA1];
+     *            hex_new_value[HEX_REG_LC1] = hex_gpr[HEX_REG_LC1] - 1;
+     *        }
+     *    }
+     */
+    TCGLabel *label3 = gen_new_label();
+    TCGLabel *done = gen_new_label();
+    tcg_gen_brcondi_tl(TCG_COND_LEU, hex_gpr[HEX_REG_LC0], 1, label3);
+    {
+        gen_jumpr(ctx, hex_gpr[HEX_REG_SA0]);
+        tcg_gen_subi_tl(hex_new_value[HEX_REG_LC0], hex_gpr[HEX_REG_LC0], 1);
+        tcg_gen_br(done);
+    }
+    gen_set_label(label3);
+    tcg_gen_brcondi_tl(TCG_COND_LEU, hex_gpr[HEX_REG_LC1], 1, done);
+    {
+        gen_jumpr(ctx, hex_gpr[HEX_REG_SA1]);
+        tcg_gen_subi_tl(hex_new_value[HEX_REG_LC1], hex_gpr[HEX_REG_LC1], 1);
+    }
+    gen_set_label(done);
+    tcg_temp_free(lpcfg);
+}
+
 static void gen_cmp_jumpnv(DisasContext *ctx,
                            TCGCond cond, TCGv val, TCGv src, int pc_off)
 {