From patchwork Thu Apr 25 00:00:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791784 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1119507wrq; Wed, 24 Apr 2024 17:11:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWq5SQcNIXL1/YdUu9kGQj4PzZdOOwGIOCpgBimqK/aBhd1BB/ckF6Iw3gfacZXCM8DF3jqU6+YDpMrC9cBCCxd X-Google-Smtp-Source: AGHT+IHbuBNcAOXTIlI6uqptlmdyb9ZWgCV4MsgCgluekpgDvBJxLG1WHq9pPjoSvUpZWTkzWMQ2 X-Received: by 2002:a0c:e38a:0:b0:6a0:5652:31e4 with SMTP id a10-20020a0ce38a000000b006a0565231e4mr3953767qvl.54.1714003899772; Wed, 24 Apr 2024 17:11:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714003899; cv=none; d=google.com; s=arc-20160816; b=bIiz40i2YHsA0H7Oo3dSRGnj7mMeViYScD5s4axEQRB5/qI5+kKUYxcdq2HPpynWaM L84O1IHmORWZ+rTOFfr1wS6iEJ++NmKckHi/YdBL1N1TWsqHgOW3Ib9MEATbBWyq2GuR clhfNNYopVQPRAr76Y9o35A77j5QBwh60H7oVqXo9pM/BoVhpeKJ/h7hbRHx1LLLfHqh wiYZsLQ2iQP9iRjND0GpnF4aU/51bYDe0zmkjfHv8FqqeJsx3KkZgAflG7JimpyBx5FH 60nbyVJKN4LurntFwdy3nxbjTNzbdCfMNVDzvPhC92fKLC2pDXvhBfqY5yoxzaKD4Trv MnKg== 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:to:from :dkim-signature; bh=5wlGs/id23E87HIx9ekP/PHGIDt2Ux5/Yk7Een8ixEg=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=b4+4KkG6H7IUv8EqzV+mc7+XzzY2vPYkU0bdffsIJ9gbeguoSxcf8aGarg8r96/iMx yPXDYQjN9i87Hri28QFJEcYD5GJ9HXCAk/JB0AGPljy3yhagmQ/NWMgw7R+HfG5u/WD1 QstTI/Vm/ZkySUNhnZjDQJKNxqAaDHLrgkYayxLeRoj4ciSYcyQd8oJ05TOe77Y8ZNsC c1qf9O8S2fPWbXZYAF6AscH2GlSUTsdmzFIsaVo3R63HHVZRQKW0dIvAWqM/6Gn9b08x AYrNcPdPsoaqhStROWDvZ4cvgeg76xBYs+JBF+mgj9cbZlH2Ir7AOFaUrtDF54RA9eRt FXOw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PvyYCeUc; 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 im4-20020a056214246400b0069b676dab8dsi16497029qvb.316.2024.04.24.17.11.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 17:11:39 -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=PvyYCeUc; 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 1rzmY3-0008Lo-UQ; Wed, 24 Apr 2024 20:01:11 -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 1rzmXr-0008Gl-81 for qemu-devel@nongnu.org; Wed, 24 Apr 2024 20:01:01 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzmXm-0006Ho-SQ for qemu-devel@nongnu.org; Wed, 24 Apr 2024 20:00:57 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1e50a04c317so2386935ad.1 for ; Wed, 24 Apr 2024 17:00:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714003253; x=1714608053; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=5wlGs/id23E87HIx9ekP/PHGIDt2Ux5/Yk7Een8ixEg=; b=PvyYCeUcAgz47cqA4rXWN0N8o9Z4hwhGEFvBYTKMfiId1BsmS+g9X1+/NtFYc0AE4W zRWexKvUkoyQaw/1PqLpEu5hSsc1m+3X+I6tyBN21Wl5Ud9bd/74XkJeX6HzNFtkb2jg FAzYXYaggcJdl0tv8+DyXbcbo5Klf70MuDqvbwEwQ5xUaXjiRTJaVguh2zEBJutngNGU SSKqgPuaGTlkKcozA+kXfWh7PfhL06kd5Miyzgxyydjew1zZggbBd3J/AtW9B2Ai3NEZ z7CU0MmHBiKibZwqNRqkvSQ9Bg5qRN4pz2YfjDiHfO4u9BSfj8i09dbfUiGEKpDy4wbW L4Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714003253; x=1714608053; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5wlGs/id23E87HIx9ekP/PHGIDt2Ux5/Yk7Een8ixEg=; b=V9aX89vFc+ww344FQI4FhTHdnHL3byrQ73iO17QRYdDh+j6dmQHrZ++Q4suz0Gdk/G NvlsfvF2La3eRW0RFrRx8TA2cl3KjCmet8GzP/Ju5CJ85VetldfYUmBDtwS+Qnvhe3hu QejOzavbbMXV72NtIEo4cWDD3D4iEsD9qlq2yW5sOSD6QqTgCAEEkNQfb0hczkmE679r 2TLJAqUuPKHcVJLLkBO86QuPW2OFESHlDCEdfD/8WzgA0kvCGx0TUc6van/+hMFLXVOt K4ECG5hk7QS638vAYuYZuJsf8sDcPvu+OS/9/r4wbKRZMuGHYEQ42FGVNSJzoNCf/TNn 8acA== X-Gm-Message-State: AOJu0YxQCLrTEa3msDiyxpMmw0dEEv8G10ikXmTIxhRas5Pf81OAQO/8 /0AZOdec2NiQozXmglGLV6Je5lkTeByzdT6XAVM2d+QCaBVkxuj+HbUQCA2aojnYfRckcCShfIA S X-Received: by 2002:a17:902:ec8a:b0:1e3:e6cb:a33c with SMTP id x10-20020a170902ec8a00b001e3e6cba33cmr4958074plg.65.1714003253530; Wed, 24 Apr 2024 17:00:53 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id t6-20020a170902e84600b001e604438791sm12465715plg.156.2024.04.24.17.00.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 17:00:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 29/45] target/hppa: Use delay_excp for conditional traps Date: Wed, 24 Apr 2024 17:00:07 -0700 Message-Id: <20240425000023.1002026-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240425000023.1002026-1-richard.henderson@linaro.org> References: <20240425000023.1002026-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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 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 7a92901e18..080a52e5e4 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -1115,6 +1115,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) @@ -1173,9 +1192,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. */ @@ -1194,6 +1211,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); } @@ -1209,6 +1230,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); } @@ -1223,7 +1248,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; @@ -1271,9 +1296,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. */ @@ -1439,9 +1462,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);