[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 03/14] Hexagon (target/hexagon) Add overrides for endloop1/end
From: |
Taylor Simpson |
Subject: |
[PATCH v6 03/14] Hexagon (target/hexagon) Add overrides for endloop1/endloop01 |
Date: |
Mon, 6 Mar 2023 18:58:17 -0800 |
Signed-off-by: Taylor Simpson <tsimpson@quicinc.com>
Reviewed-by: Anton Johansson <anjo@rev.ng>
---
target/hexagon/gen_tcg.h | 4 +++
target/hexagon/genptr.c | 78 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+)
diff --git a/target/hexagon/gen_tcg.h b/target/hexagon/gen_tcg.h
index fa0dbbec7d..4f84baf03b 100644
--- a/target/hexagon/gen_tcg.h
+++ b/target/hexagon/gen_tcg.h
@@ -603,6 +603,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 592438f61e..f7017fd483 100644
--- a/target/hexagon/genptr.c
+++ b/target/hexagon/genptr.c
@@ -770,6 +770,84 @@ static void gen_endloop0(DisasContext *ctx)
}
}
+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_new();
+ TCGLabel *label1 = gen_new_label();
+ TCGLabel *label2 = gen_new_label();
+ TCGLabel *label3 = gen_new_label();
+ TCGLabel *done = gen_new_label();
+
+ GET_USR_FIELD(USR_LPCFG, lpcfg);
+
+ /*
+ * if (lpcfg == 1) {
+ * hex_new_pred_value[3] = 0xff;
+ * hex_pred_written |= 1 << 3;
+ * }
+ */
+ 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);
+ * }
+ */
+ 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;
+ * }
+ * }
+ */
+ 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);
+}
+
static void gen_cmp_jumpnv(DisasContext *ctx,
TCGCond cond, TCGv val, TCGv src, int pc_off)
{
--
2.25.1
- [PATCH v6 00/14] Hexagon: COF overrides, new generator, test/bug update, Taylor Simpson, 2023/03/06
- [PATCH v6 04/14] Hexagon (target/hexagon) Add overrides for dealloc-return instructions, Taylor Simpson, 2023/03/06
- [PATCH v6 03/14] Hexagon (target/hexagon) Add overrides for endloop1/endloop01,
Taylor Simpson <=
- [PATCH v6 01/14] Hexagon (target/hexagon) Add overrides for jumpr31 instructions, Taylor Simpson, 2023/03/06
- [PATCH v6 07/14] Hexagon (target/hexagon) Analyze packet for HVX, Taylor Simpson, 2023/03/06
- [PATCH v6 11/14] Hexagon (target/hexagon) Change subtract from zero to change sign, Taylor Simpson, 2023/03/06
- [PATCH v6 09/14] Hexagon (tests/tcg/hexagon) Remove __builtin from scatter_gather, Taylor Simpson, 2023/03/06
- [PATCH v6 13/14] Hexagon (target/hexagon) Reduce manipulation of slot_cancelled, Taylor Simpson, 2023/03/06
- [PATCH v6 02/14] Hexagon (target/hexagon) Add overrides for callr, Taylor Simpson, 2023/03/06
- [PATCH v6 05/14] Hexagon (target/hexagon) Analyze packet before generating TCG, Taylor Simpson, 2023/03/06
- [PATCH v6 06/14] Hexagon (target/hexagon) Don't set pkt_has_store_s1 when not needed, Taylor Simpson, 2023/03/06
- [PATCH v6 08/14] Hexagon (tests/tcg/hexagon) Update preg_alias.c, Taylor Simpson, 2023/03/06