From patchwork Wed May 15 09:40:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 796911 Delivered-To: patch@linaro.org Received: by 2002:a5d:452e:0:b0:34e:ceec:bfcd with SMTP id j14csp2889990wra; Wed, 15 May 2024 02:41:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWH+9iN+65KBA+Kp2lsd2+x2awU4g38Qg91ozKaT2FoeumM28tfFBcxU1qpmOSpejVMqbEvDqVcUdp115k1yxue X-Google-Smtp-Source: AGHT+IEehhWUDPaD2GwsB6PTZg9DUsjk9EBHs8KaHtsbx/z5CS6ZYYYGvktXQP1lK8Pg59rGhp6L X-Received: by 2002:a05:620a:2704:b0:792:fa98:276 with SMTP id af79cd13be357-792fa980402mr101849885a.27.1715766089735; Wed, 15 May 2024 02:41:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715766089; cv=none; d=google.com; s=arc-20160816; b=m2lsj8i2UH/odJoOtVIuZrxR0Lj+DZrfcRHwmtLlCd12juKMZz96bLxYGTSmTIjQ+Z czLKYJUCgKkGhkk8VKnQkMHSZII/B8fZj9/07nV5N7/r4xLKRBgfv/xl7cHtz7fUWr8W mlb5JlzuQ+MKenNtgG1E6yd5j+SwQxEL7yt93nGaRYzYv+SQnofbuNausMsVNq/W4RTC 7mZBXhadIOOxhgAeMkUD7k9jwqr2kmdYy6nU8qh2u0SoK9V50979yo7xcnG0NFWeEM8I iFpa8C+awZBN8JNU3xVq5wiN6Y6VI30KI6++yFOep+iOLPUOyOO/Nq3oG6+qsVX4a0Yq lnNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xIMB9DvpLVvL8O/ArHYL+McDtTeWMTKUufERzC06JL4=; fh=wDljmxUHXfz9MGj2//jPHYRc53BMWF157v8rVKELrf4=; b=v5mlowlyRlRyVoHgcsByj91eKZfXEh1Igs9Rs883fKNmBOOTUflO3seXOLAyjVwotv q2FgFT7IzHZUAoYX/As8BU80N7JCaRnqffGb03kY7CLFST3iGPLzTq9/LwIgyfrXODgf Ei5rmbtNI+xbnukrvj0B6tNdAK5QV2US8avSq3DQ6k7kMDcVrO3S4rigAMhdbNYXM0O0 2LBYEBfDTi3SJy/MXxYhu8jIAXN5Udf0FiyHAgju102m4Qzkn2zg9P1AkMd6OkOC5/45 SN3Pq+11+8DUa6E5R48MtL33yrhOWIBjhlPFA0ZyXHP1r5rjUGcAUA754FW4l8mxYZij n71g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HP58Fpsp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-792bf362709si1509665285a.570.2024.05.15.02.41.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 May 2024 02:41:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HP58Fpsp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s7B8S-0007M4-1t; Wed, 15 May 2024 05:41:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s7B8I-0006QV-HA for qemu-devel@nongnu.org; Wed, 15 May 2024 05:41:10 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s7B8F-0001hW-E5 for qemu-devel@nongnu.org; Wed, 15 May 2024 05:41:10 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-34e0d8b737eso4457048f8f.1 for ; Wed, 15 May 2024 02:41:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715766066; x=1716370866; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xIMB9DvpLVvL8O/ArHYL+McDtTeWMTKUufERzC06JL4=; b=HP58Fpspw7D/1dbIgRU7RJnkX+UxyhFGj6OWRB9zFtlfrPlbGILWaVe0EYfb42Vih6 MOr0psid/Z0DKe7ASmROdzZ4YELmysb5hAEKCEkp0/Y3MUmiiLCZkoYI7lbwsuqf4/C+ fIyEjzq2ZrHzO/qwcVL3gc3SzylppXJHW/w/O5IyWAZdfrqJQ4974Wbj8pijjOAra9Mz eBmWKlH+KYJAXEBYhLB9tyQAi3yVyC9tKR4lZv8cCmuNPf4J4BoIKYWmWNgoocv6Zvsp Bsh3INNVBZZqn/OaWXWLXapMwPcAJ3gaY7LXD16m2Q4CK59zuIsLlhpwSJfJF6oULmm2 GySw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715766066; x=1716370866; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xIMB9DvpLVvL8O/ArHYL+McDtTeWMTKUufERzC06JL4=; b=lCN0o9d5aixC2vDEAgSbIrDDg0RMHfu12nCxL3P/xbKinM+PuFLBr96K5zS5gDj4ZR IwI9i7N8U78ke2ExA5fO1eD5eD7OUIx/zmIOXeE4DDhREmwlnK7V3oryfewSEW3/pxjg nEQHwJh8ODpb5B/2y7v8NDu7pdTe6pGeqbtEU/mjeoHfz7O6zDes8DfuZ9ROD3JKU12n LAXs3J7dUUvlORiuzHZr/WmemPCM1351JkpM5025AvvlVZBc18J46Tm69vIzN9R/D4iO 8e+lIcdafy0rf0j8aqC2aH93aZiB5/HW6Eyrppsr5j0oUJE+XH7/Q5ryQSrTggN7I+mm 0VTw== X-Gm-Message-State: AOJu0YyNDGl2rsrGSDvzD6fkzERdDcOVdLGHu6YtILj6yN7Qnp1OC3B5 rMTHhNg7xj//3MYMHc6MsiWtQTW0oXMKLwHlOOBgBquv3zDUBPbHhUMPGYMyU/BvU4SV/HecLhe Ah0U= X-Received: by 2002:adf:f0c1:0:b0:34d:10a9:3a22 with SMTP id ffacd0b85a97d-35049bbf691mr11948821f8f.32.1715766066023; Wed, 15 May 2024 02:41:06 -0700 (PDT) Received: from stoup.. ([149.14.240.163]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502bbbbefdsm15897058f8f.94.2024.05.15.02.41.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 02:41:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Helge Deller Subject: [PULL 29/43] target/hppa: Use delay_excp for conditional traps Date: Wed, 15 May 2024 11:40:29 +0200 Message-Id: <20240515094043.82850-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240515094043.82850-1-richard.henderson@linaro.org> References: <20240515094043.82850-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Helge Deller Signed-off-by: Richard Henderson --- target/hppa/helper.h | 1 - target/hppa/int_helper.c | 2 +- target/hppa/op_helper.c | 7 ------- target/hppa/translate.c | 41 ++++++++++++++++++++++++++++++---------- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/target/hppa/helper.h b/target/hppa/helper.h index 5900fd70bc..3d0d143aed 100644 --- a/target/hppa/helper.h +++ b/target/hppa/helper.h @@ -1,6 +1,5 @@ DEF_HELPER_2(excp, noreturn, env, int) DEF_HELPER_FLAGS_2(tsv, TCG_CALL_NO_WG, void, env, tl) -DEF_HELPER_FLAGS_2(tcond, TCG_CALL_NO_WG, void, env, tl) DEF_HELPER_FLAGS_3(stby_b, TCG_CALL_NO_WG, void, env, tl, tl) DEF_HELPER_FLAGS_3(stby_b_parallel, TCG_CALL_NO_WG, void, env, tl, tl) diff --git a/target/hppa/int_helper.c b/target/hppa/int_helper.c index a667ee380d..1aa3e88ef1 100644 --- a/target/hppa/int_helper.c +++ b/target/hppa/int_helper.c @@ -134,13 +134,13 @@ void hppa_cpu_do_interrupt(CPUState *cs) switch (i) { case EXCP_ILL: case EXCP_BREAK: + case EXCP_COND: case EXCP_PRIV_REG: case EXCP_PRIV_OPR: /* IIR set via translate.c. */ break; case EXCP_OVERFLOW: - case EXCP_COND: case EXCP_ASSIST: case EXCP_DTLB_MISS: case EXCP_NA_ITLB_MISS: diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c index 6cf49f33b7..a8b69fd481 100644 --- a/target/hppa/op_helper.c +++ b/target/hppa/op_helper.c @@ -49,13 +49,6 @@ void HELPER(tsv)(CPUHPPAState *env, target_ulong cond) } } -void HELPER(tcond)(CPUHPPAState *env, target_ulong cond) -{ - if (unlikely(cond)) { - hppa_dynamic_excp(env, EXCP_COND, GETPC()); - } -} - static void atomic_store_mask32(CPUHPPAState *env, target_ulong addr, uint32_t val, uint32_t mask, uintptr_t ra) { diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 706537ea59..ae291124f2 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -1117,6 +1117,25 @@ static TCGv_i64 do_sub_sv(DisasContext *ctx, TCGv_i64 res, return sv; } +static void gen_tc(DisasContext *ctx, DisasCond *cond) +{ + DisasDelayException *e; + + switch (cond->c) { + case TCG_COND_NEVER: + break; + case TCG_COND_ALWAYS: + gen_excp_iir(ctx, EXCP_COND); + break; + default: + e = delay_excp(ctx, EXCP_COND); + tcg_gen_brcond_i64(cond->c, cond->a0, cond->a1, e->lab); + /* In the non-trap path, the condition is known false. */ + *cond = cond_make_f(); + break; + } +} + static void do_add(DisasContext *ctx, unsigned rt, TCGv_i64 orig_in1, TCGv_i64 in2, unsigned shift, bool is_l, bool is_tsv, bool is_tc, bool is_c, unsigned cf, bool d) @@ -1175,9 +1194,7 @@ static void do_add(DisasContext *ctx, unsigned rt, TCGv_i64 orig_in1, /* Emit any conditional trap before any writeback. */ cond = do_cond(ctx, cf, d, dest, uv, sv); if (is_tc) { - tmp = tcg_temp_new_i64(); - tcg_gen_setcond_i64(cond.c, tmp, cond.a0, cond.a1); - gen_helper_tcond(tcg_env, tmp); + gen_tc(ctx, &cond); } /* Write back the result. */ @@ -1196,6 +1213,10 @@ static bool do_add_reg(DisasContext *ctx, arg_rrr_cf_d_sh *a, { TCGv_i64 tcg_r1, tcg_r2; + if (unlikely(is_tc && a->cf == 1)) { + /* Unconditional trap on condition. */ + return gen_excp_iir(ctx, EXCP_COND); + } if (a->cf) { nullify_over(ctx); } @@ -1211,6 +1232,10 @@ static bool do_add_imm(DisasContext *ctx, arg_rri_cf *a, { TCGv_i64 tcg_im, tcg_r2; + if (unlikely(is_tc && a->cf == 1)) { + /* Unconditional trap on condition. */ + return gen_excp_iir(ctx, EXCP_COND); + } if (a->cf) { nullify_over(ctx); } @@ -1225,7 +1250,7 @@ static void do_sub(DisasContext *ctx, unsigned rt, TCGv_i64 in1, TCGv_i64 in2, bool is_tsv, bool is_b, bool is_tc, unsigned cf, bool d) { - TCGv_i64 dest, sv, cb, cb_msb, tmp; + TCGv_i64 dest, sv, cb, cb_msb; unsigned c = cf >> 1; DisasCond cond; @@ -1273,9 +1298,7 @@ static void do_sub(DisasContext *ctx, unsigned rt, TCGv_i64 in1, /* Emit any conditional trap before any writeback. */ if (is_tc) { - tmp = tcg_temp_new_i64(); - tcg_gen_setcond_i64(cond.c, tmp, cond.a0, cond.a1); - gen_helper_tcond(tcg_env, tmp); + gen_tc(ctx, &cond); } /* Write back the result. */ @@ -1441,9 +1464,7 @@ static void do_unit_addsub(DisasContext *ctx, unsigned rt, TCGv_i64 in1, } if (is_tc) { - TCGv_i64 tmp = tcg_temp_new_i64(); - tcg_gen_setcond_i64(cond.c, tmp, cond.a0, cond.a1); - gen_helper_tcond(tcg_env, tmp); + gen_tc(ctx, &cond); } save_gpr(ctx, rt, dest);