[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 13/44] Hexagon (target/hexagon) Add overrides for allocframe/de
|
From: |
Taylor Simpson |
|
Subject: |
[PULL v2 13/44] Hexagon (target/hexagon) Add overrides for allocframe/deallocframe |
|
Date: |
Thu, 18 May 2023 13:03:40 -0700 |
These instructions have implicit writes to registers, so we don't
want them to be helpers when idef-parser is off.
Signed-off-by: Taylor Simpson <tsimpson@quicinc.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230427230012.3800327-5-tsimpson@quicinc.com>
---
target/hexagon/gen_tcg.h | 32 +++++++++++++++++++++++++++
target/hexagon/genptr.c | 47 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 79 insertions(+)
diff --git a/target/hexagon/gen_tcg.h b/target/hexagon/gen_tcg.h
index 8d5e9826a0..ef17f2f18c 100644
--- a/target/hexagon/gen_tcg.h
+++ b/target/hexagon/gen_tcg.h
@@ -500,6 +500,38 @@
#define fGEN_TCG_Y2_icinva(SHORTCODE) \
do { RsV = RsV; } while (0)
+/*
+ * allocframe(#uiV)
+ * RxV == r29
+ */
+#define fGEN_TCG_S2_allocframe(SHORTCODE) \
+ gen_allocframe(ctx, RxV, uiV)
+
+/* sub-instruction version (no RxV, so handle it manually) */
+#define fGEN_TCG_SS2_allocframe(SHORTCODE) \
+ do { \
+ TCGv r29 = tcg_temp_new(); \
+ tcg_gen_mov_tl(r29, hex_gpr[HEX_REG_SP]); \
+ gen_allocframe(ctx, r29, uiV); \
+ gen_log_reg_write(ctx, HEX_REG_SP, r29); \
+ } while (0)
+
+/*
+ * Rdd32 = deallocframe(Rs32):raw
+ * RddV == r31:30
+ * RsV == r30
+ */
+#define fGEN_TCG_L2_deallocframe(SHORTCODE) \
+ gen_deallocframe(ctx, RddV, RsV)
+
+/* sub-instruction version (no RddV/RsV, so handle it manually) */
+#define fGEN_TCG_SL2_deallocframe(SHORTCODE) \
+ do { \
+ TCGv_i64 r31_30 = tcg_temp_new_i64(); \
+ gen_deallocframe(ctx, r31_30, hex_gpr[HEX_REG_FP]); \
+ gen_log_reg_write_pair(ctx, HEX_REG_FP, r31_30); \
+ } while (0)
+
/*
* dealloc_return
* Assembler mapped to
diff --git a/target/hexagon/genptr.c b/target/hexagon/genptr.c
index 6e5767ec5e..fa7b1754bd 100644
--- a/target/hexagon/genptr.c
+++ b/target/hexagon/genptr.c
@@ -709,6 +709,18 @@ static void gen_cond_callr(DisasContext *ctx,
gen_set_label(skip);
}
+#ifndef CONFIG_HEXAGON_IDEF_PARSER
+/* frame = ((LR << 32) | FP) ^ (FRAMEKEY << 32)) */
+static TCGv_i64 gen_frame_scramble(void)
+{
+ TCGv_i64 frame = tcg_temp_new_i64();
+ TCGv tmp = tcg_temp_new();
+ tcg_gen_xor_tl(tmp, hex_gpr[HEX_REG_LR], hex_gpr[HEX_REG_FRAMEKEY]);
+ tcg_gen_concat_i32_i64(frame, hex_gpr[HEX_REG_FP], tmp);
+ return frame;
+}
+#endif
+
/* frame ^= (int64_t)FRAMEKEY << 32 */
static void gen_frame_unscramble(TCGv_i64 frame)
{
@@ -725,6 +737,41 @@ static void gen_load_frame(DisasContext *ctx, TCGv_i64
frame, TCGv EA)
tcg_gen_qemu_ld_i64(frame, EA, ctx->mem_idx, MO_TEUQ);
}
+#ifndef CONFIG_HEXAGON_IDEF_PARSER
+/* Stack overflow check */
+static void gen_framecheck(TCGv EA, int framesize)
+{
+ /* Not modelled in linux-user mode */
+ /* Placeholder for system mode */
+#ifndef CONFIG_USER_ONLY
+ g_assert_not_reached();
+#endif
+}
+
+static void gen_allocframe(DisasContext *ctx, TCGv r29, int framesize)
+{
+ TCGv r30 = tcg_temp_new();
+ TCGv_i64 frame;
+ tcg_gen_addi_tl(r30, r29, -8);
+ frame = gen_frame_scramble();
+ gen_store8(cpu_env, r30, frame, ctx->insn->slot);
+ gen_log_reg_write(ctx, HEX_REG_FP, r30);
+ gen_framecheck(r30, framesize);
+ tcg_gen_subi_tl(r29, r30, framesize);
+}
+
+static void gen_deallocframe(DisasContext *ctx, TCGv_i64 r31_30, TCGv r30)
+{
+ TCGv r29 = tcg_temp_new();
+ TCGv_i64 frame = tcg_temp_new_i64();
+ gen_load_frame(ctx, frame, r30);
+ gen_frame_unscramble(frame);
+ tcg_gen_mov_i64(r31_30, frame);
+ tcg_gen_addi_tl(r29, r30, 8);
+ gen_log_reg_write(ctx, HEX_REG_SP, r29);
+}
+#endif
+
static void gen_return(DisasContext *ctx, TCGv_i64 dst, TCGv src)
{
/*
--
2.25.1
- [PULL v2 00/44] Hexagon update, Taylor Simpson, 2023/05/18
- [PULL v2 01/44] Hexagon (target/hexagon) Add support for v68/v69/v71/v73, Taylor Simpson, 2023/05/18
- [PULL v2 16/44] Hexagon (target/hexagon) Eliminate uses of log_pred_write function, Taylor Simpson, 2023/05/18
- [PULL v2 32/44] target/hexagon: fix = vs. == mishap, Taylor Simpson, 2023/05/18
- [PULL v2 05/44] Hexagon (tests/tcg/hexagon) Add v68 HVX tests, Taylor Simpson, 2023/05/18
- [PULL v2 13/44] Hexagon (target/hexagon) Add overrides for allocframe/deallocframe,
Taylor Simpson <=
- [PULL v2 38/44] Remove test_vshuff from hvx_misc tests, Taylor Simpson, 2023/05/18
- [PULL v2 17/44] Hexagon (target/hexagon) Clean up pred_written usage, Taylor Simpson, 2023/05/18
- [PULL v2 15/44] Hexagon (target/hexagon) Remove log_reg_write from op_helper.[ch], Taylor Simpson, 2023/05/18
- [PULL v2 39/44] gdbstub: only send stop-reply packets when allowed to, Taylor Simpson, 2023/05/18
- [PULL v2 06/44] Hexagon (target/hexagon) Add v69 HVX instructions, Taylor Simpson, 2023/05/18
- [PULL v2 12/44] Hexagon (target/hexagon) Add overrides for loop setup instructions, Taylor Simpson, 2023/05/18
- [PULL v2 22/44] Hexagon (target/hexagon) Short-circuit packet HVX writes, Taylor Simpson, 2023/05/18
- [PULL v2 26/44] Hexagon (target/hexagon) Move new_value to DisasContext, Taylor Simpson, 2023/05/18
- [PULL v2 34/44] Hexagon: list available CPUs with `-cpu help`, Taylor Simpson, 2023/05/18
- [PULL v2 14/44] Hexagon (target/hexagon) Add overrides for clr[tf]new, Taylor Simpson, 2023/05/18