[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 07/11] Hexagon (target/hexagon) Add overrides for direct call
From: |
Taylor Simpson |
Subject: |
[PATCH v5 07/11] Hexagon (target/hexagon) Add overrides for direct call instructions |
Date: |
Tue, 8 Nov 2022 08:29:02 -0800 |
Add overrides for
J2_call
J2_callt
J2_callf
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Taylor Simpson <tsimpson@quicinc.com>
---
target/hexagon/gen_tcg.h | 8 ++++++
target/hexagon/genptr.c | 55 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+)
diff --git a/target/hexagon/gen_tcg.h b/target/hexagon/gen_tcg.h
index df279ab43b..1bdc787a02 100644
--- a/target/hexagon/gen_tcg.h
+++ b/target/hexagon/gen_tcg.h
@@ -612,6 +612,14 @@
tcg_temp_free(tmp); \
} while (0)
+#define fGEN_TCG_J2_call(SHORTCODE) \
+ gen_call(ctx, riV)
+
+#define fGEN_TCG_J2_callt(SHORTCODE) \
+ gen_cond_call(ctx, PuV, TCG_COND_EQ, riV)
+#define fGEN_TCG_J2_callf(SHORTCODE) \
+ gen_cond_call(ctx, PuV, TCG_COND_NE, riV)
+
#define fGEN_TCG_J2_pause(SHORTCODE) \
do { \
uiV = uiV; \
diff --git a/target/hexagon/genptr.c b/target/hexagon/genptr.c
index cd3d74525e..580c403879 100644
--- a/target/hexagon/genptr.c
+++ b/target/hexagon/genptr.c
@@ -456,6 +456,61 @@ static TCGv gen_8bitsof(TCGv result, TCGv value)
return result;
}
+static void gen_write_new_pc_addr(DisasContext *ctx, TCGv addr,
+ TCGCond cond, TCGv pred)
+{
+ TCGLabel *pred_false = NULL;
+ if (cond != TCG_COND_ALWAYS) {
+ pred_false = gen_new_label();
+ tcg_gen_brcondi_tl(cond, pred, 0, pred_false);
+ }
+
+ if (ctx->pkt->pkt_has_multi_cof) {
+ /* If there are multiple branches in a packet, ignore the second one */
+ tcg_gen_movcond_tl(TCG_COND_NE, hex_gpr[HEX_REG_PC],
+ hex_branch_taken, tcg_constant_tl(0),
+ hex_gpr[HEX_REG_PC], addr);
+ tcg_gen_movi_tl(hex_branch_taken, 1);
+ } else {
+ tcg_gen_mov_tl(hex_gpr[HEX_REG_PC], addr);
+ }
+
+ if (cond != TCG_COND_ALWAYS) {
+ gen_set_label(pred_false);
+ }
+}
+
+static void gen_write_new_pc_pcrel(DisasContext *ctx, int pc_off,
+ TCGCond cond, TCGv pred)
+{
+ target_ulong dest = ctx->pkt->pc + pc_off;
+ gen_write_new_pc_addr(ctx, tcg_constant_tl(dest), cond, pred);
+}
+
+static void gen_call(DisasContext *ctx, int pc_off)
+{
+ TCGv next_PC =
+ tcg_constant_tl(ctx->pkt->pc + ctx->pkt->encod_pkt_size_in_bytes);
+ gen_log_reg_write(HEX_REG_LR, next_PC);
+ gen_write_new_pc_pcrel(ctx, pc_off, TCG_COND_ALWAYS, NULL);
+}
+
+static void gen_cond_call(DisasContext *ctx, TCGv pred,
+ TCGCond cond, int pc_off)
+{
+ TCGv next_PC;
+ TCGv lsb = tcg_temp_local_new();
+ TCGLabel *skip = gen_new_label();
+ tcg_gen_andi_tl(lsb, pred, 1);
+ gen_write_new_pc_pcrel(ctx, pc_off, cond, lsb);
+ tcg_gen_brcondi_tl(cond, lsb, 0, skip);
+ tcg_temp_free(lsb);
+ next_PC =
+ tcg_constant_tl(ctx->pkt->pc + ctx->pkt->encod_pkt_size_in_bytes);
+ gen_log_reg_write(HEX_REG_LR, next_PC);
+ gen_set_label(skip);
+}
+
/* Shift left with saturation */
static void gen_shl_sat(TCGv dst, TCGv src, TCGv shift_amt)
{
--
2.17.1
- [PATCH v5 00/11] Hexagon (target/hexagon) performance and bug fixes, Taylor Simpson, 2022/11/08
- [PATCH v5 02/11] Hexagon (target/hexagon) Fix predicated assignment to .tmp and .cur, Taylor Simpson, 2022/11/08
- [PATCH v5 09/11] Hexagon (target/hexagon) Add overrides for various forms of jump, Taylor Simpson, 2022/11/08
- [PATCH v5 11/11] Hexagon (target/hexagon) Use direct block chaining for tight loops, Taylor Simpson, 2022/11/08
- [PATCH v5 08/11] Hexagon (target/hexagon) Add overrides for compound compare and jump, Taylor Simpson, 2022/11/08
- [PATCH v5 04/11] Hexagon (target/hexagon) Only use branch_taken when packet has multi cof, Taylor Simpson, 2022/11/08
- [PATCH v5 07/11] Hexagon (target/hexagon) Add overrides for direct call instructions,
Taylor Simpson <=
- [PATCH v5 03/11] Hexagon (target/hexagon) Add overrides for S2_asr_r_r_sat/S2_asl_r_r_sat, Taylor Simpson, 2022/11/08
- [PATCH v5 05/11] Hexagon (target/hexagon) Remove PC from the runtime state, Taylor Simpson, 2022/11/08
- [PATCH v5 06/11] Hexagon (target/hexagon) Remove next_PC from runtime state, Taylor Simpson, 2022/11/08
- [PATCH v5 10/11] Hexagon (target/hexagon) Use direct block chaining for direct jump/branch, Taylor Simpson, 2022/11/08
- [PATCH v5 01/11] Hexagon (target/hexagon) Add pkt and insn to DisasContext, Taylor Simpson, 2022/11/08