[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/17] Hexagon (target/hexagon) Add overrides for endloop1/endloop
From: |
Taylor Simpson |
Subject: |
[PULL 06/17] Hexagon (target/hexagon) Add overrides for endloop1/endloop01 |
Date: |
Mon, 6 Mar 2023 21:34:27 -0800 |
Signed-off-by: Taylor Simpson <tsimpson@quicinc.com>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Message-Id: <20230307025828.1612809-4-tsimpson@quicinc.com>
---
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 fb23d56d4a..5b7263a82c 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
- [PULL 04/17] Hexagon (target/hexagon) Add overrides for jumpr31 instructions, (continued)
- [PULL 04/17] Hexagon (target/hexagon) Add overrides for jumpr31 instructions, Taylor Simpson, 2023/03/07
- [PULL 10/17] Hexagon (target/hexagon) Analyze packet for HVX, Taylor Simpson, 2023/03/07
- [PULL 16/17] Hexagon (target/hexagon) Reduce manipulation of slot_cancelled, Taylor Simpson, 2023/03/07
- [PULL 05/17] Hexagon (target/hexagon) Add overrides for callr, Taylor Simpson, 2023/03/07
- [PULL 09/17] Hexagon (target/hexagon) Don't set pkt_has_store_s1 when not needed, Taylor Simpson, 2023/03/07
- [PULL 03/17] target/hexagon/idef-parser: Remove unused code paths, Taylor Simpson, 2023/03/07
- [PULL 17/17] Hexagon (target/hexagon) Improve code gen for predicated HVX instructions, Taylor Simpson, 2023/03/07
- [PULL 14/17] Hexagon (target/hexagon) Change subtract from zero to change sign, Taylor Simpson, 2023/03/07
- [PULL 02/17] target/hexagon/idef-parser: Elide mov in gen_pred_assign, Taylor Simpson, 2023/03/07
- [PULL 07/17] Hexagon (target/hexagon) Add overrides for dealloc-return instructions, Taylor Simpson, 2023/03/07
- [PULL 06/17] Hexagon (target/hexagon) Add overrides for endloop1/endloop01,
Taylor Simpson <=
- [PULL 15/17] Hexagon (target/hexagon) Remove gen_log_predicated_reg_write[_pair], Taylor Simpson, 2023/03/07
- [PULL 01/17] Hexagon (target/hexagon) Restore --disable-hexagon-idef-parser build, Taylor Simpson, 2023/03/07
- [PULL 11/17] Hexagon (tests/tcg/hexagon) Update preg_alias.c, Taylor Simpson, 2023/03/07
- [PULL 08/17] Hexagon (target/hexagon) Analyze packet before generating TCG, Taylor Simpson, 2023/03/07
- [PULL 12/17] Hexagon (tests/tcg/hexagon) Remove __builtin from scatter_gather, Taylor Simpson, 2023/03/07
- RE: [PULL 00/17] Hexagon (target/hexagon) updates, Taylor Simpson, 2023/03/08
- Re: [PULL 00/17] Hexagon (target/hexagon) updates, Peter Maydell, 2023/03/10