[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 28/45] target/hppa: Introduce DisasDelayException
|
From: |
Richard Henderson |
|
Subject: |
[PATCH 28/45] target/hppa: Introduce DisasDelayException |
|
Date: |
Wed, 24 Apr 2024 17:00:06 -0700 |
Allow an exception to be emitted at the end of the TranslationBlock,
leaving only the conditional branch inline. Use it for simple
exception instructions like break, which happen to be nullified.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/hppa/translate.c | 60 +++++++++++++++++++++++++++++++++++++----
1 file changed, 55 insertions(+), 5 deletions(-)
diff --git a/target/hppa/translate.c b/target/hppa/translate.c
index 5714e2ad25..7a92901e18 100644
--- a/target/hppa/translate.c
+++ b/target/hppa/translate.c
@@ -50,6 +50,17 @@ typedef struct DisasIAQE {
int64_t disp;
} DisasIAQE;
+typedef struct DisasDelayException {
+ struct DisasDelayException *next;
+ TCGLabel *lab;
+ uint32_t insn;
+ bool set_iir;
+ int8_t set_n;
+ uint8_t excp;
+ /* Saved state at parent insn. */
+ DisasIAQE iaq_f, iaq_b;
+} DisasDelayException;
+
typedef struct DisasContext {
DisasContextBase base;
CPUState *cs;
@@ -65,6 +76,7 @@ typedef struct DisasContext {
DisasCond null_cond;
TCGLabel *null_lab;
+ DisasDelayException *delay_excp_list;
TCGv_i64 zero;
uint32_t insn;
@@ -682,13 +694,38 @@ static void gen_excp(DisasContext *ctx, int exception)
ctx->base.is_jmp = DISAS_NORETURN;
}
+static DisasDelayException *delay_excp(DisasContext *ctx, uint8_t excp)
+{
+ DisasDelayException *e = tcg_malloc(sizeof(DisasDelayException));
+
+ memset(e, 0, sizeof(*e));
+ e->next = ctx->delay_excp_list;
+ ctx->delay_excp_list = e;
+
+ e->lab = gen_new_label();
+ e->insn = ctx->insn;
+ e->set_iir = true;
+ e->set_n = ctx->psw_n_nonzero ? 0 : -1;
+ e->excp = excp;
+ e->iaq_f = ctx->iaq_f;
+ e->iaq_b = ctx->iaq_b;
+
+ return e;
+}
+
static bool gen_excp_iir(DisasContext *ctx, int exc)
{
- nullify_over(ctx);
- tcg_gen_st_i64(tcg_constant_i64(ctx->insn),
- tcg_env, offsetof(CPUHPPAState, cr[CR_IIR]));
- gen_excp(ctx, exc);
- return nullify_end(ctx);
+ if (ctx->null_cond.c == TCG_COND_NEVER) {
+ tcg_gen_st_i64(tcg_constant_i64(ctx->insn),
+ tcg_env, offsetof(CPUHPPAState, cr[CR_IIR]));
+ gen_excp(ctx, exc);
+ } else {
+ DisasDelayException *e = delay_excp(ctx, exc);
+ tcg_gen_brcond_i64(tcg_invert_cond(ctx->null_cond.c),
+ ctx->null_cond.a0, ctx->null_cond.a1, e->lab);
+ ctx->null_cond = cond_make_f();
+ }
+ return true;
}
static bool gen_illegal(DisasContext *ctx)
@@ -4695,6 +4732,19 @@ static void hppa_tr_tb_stop(DisasContextBase *dcbase,
CPUState *cs)
default:
g_assert_not_reached();
}
+
+ for (DisasDelayException *e = ctx->delay_excp_list; e ; e = e->next) {
+ gen_set_label(e->lab);
+ if (e->set_n >= 0) {
+ tcg_gen_movi_i64(cpu_psw_n, e->set_n);
+ }
+ if (e->set_iir) {
+ tcg_gen_st_i64(tcg_constant_i64(e->insn), tcg_env,
+ offsetof(CPUHPPAState, cr[CR_IIR]));
+ }
+ install_iaq_entries(ctx, &e->iaq_f, &e->iaq_b);
+ gen_excp_1(e->excp);
+ }
}
static void hppa_tr_disas_log(const DisasContextBase *dcbase,
--
2.34.1
- [PATCH 10/45] target/hppa: Skip nullified insns in unconditional dbranch path, (continued)
- [PATCH 10/45] target/hppa: Skip nullified insns in unconditional dbranch path, Richard Henderson, 2024/04/24
- [PATCH 15/45] target/hppa: Use umax in do_ibranch_priv, Richard Henderson, 2024/04/24
- [PATCH 20/45] target/hppa: Use TCG_COND_TST* in do_cond, Richard Henderson, 2024/04/24
- [PATCH 19/45] target/hppa: Rename cond_make_* helpers, Richard Henderson, 2024/04/24
- [PATCH 04/45] target/hppa: Pass displacement to do_dbranch, Richard Henderson, 2024/04/24
- [PATCH 14/45] target/hppa: Add space argument to do_ibranch, Richard Henderson, 2024/04/24
- [PATCH 12/45] target/hppa: Add IASQ entries to DisasContext, Richard Henderson, 2024/04/24
- [PATCH 22/45] target/hppa: Use TCG_COND_TST* in do_unit_zero_cond, Richard Henderson, 2024/04/24
- [PATCH 23/45] target/hppa: Use TCG_COND_TST* in do_unit_addsub, Richard Henderson, 2024/04/24
- [PATCH 29/45] target/hppa: Use delay_excp for conditional traps, Richard Henderson, 2024/04/24
- [PATCH 28/45] target/hppa: Introduce DisasDelayException,
Richard Henderson <=
- [PATCH 07/45] target/hppa: Add install_iaq_entries, Richard Henderson, 2024/04/24
- [PATCH 17/45] target/hppa: Introduce and use DisasIAQE for branch management, Richard Henderson, 2024/04/24
- [PATCH 11/45] target/hppa: Simplify TB end, Richard Henderson, 2024/04/24
- [PATCH 09/45] target/hppa: Delay computation of IAQ_Next, Richard Henderson, 2024/04/24
- [PATCH 25/45] target/hppa: Use registerfields.h for FPSR, Richard Henderson, 2024/04/24
- [PATCH 32/45] target/hppa: Store full iaoq_f and page bits of iaoq_d in TB, Richard Henderson, 2024/04/24
- [PATCH 31/45] linux-user/hppa: Force all code addresses to PRIV_USER, Richard Henderson, 2024/04/24
- [PATCH 26/45] target/hppa: Use TCG_COND_TST* in trans_ftest, Richard Henderson, 2024/04/24
- [PATCH 30/45] target/hppa: Use delay_excp for conditional trap on overflow, Richard Henderson, 2024/04/24
- [PATCH 34/45] target/hppa: Improve hppa_cpu_dump_state, Richard Henderson, 2024/04/24