From patchwork Mon May 13 07:47:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 796532 Delivered-To: patch@linaro.org Received: by 2002:a5d:452e:0:b0:34e:ceec:bfcd with SMTP id j14csp1884534wra; Mon, 13 May 2024 00:53:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVmnZSUnFuPWiW8VbS0/wpKyfthdi5Y6FzhslQLYYpydzIszVKHzKs87DxRoBR6+GH9btdR18bgvhi52ABRi3FQ X-Google-Smtp-Source: AGHT+IHVOyDt7d6spBeKOA5ZlyODNDDsy0q8JYmhKw5mUY3fqqXXmspR6tzAyImqWXSFUXjIBGSb X-Received: by 2002:a05:6214:33c1:b0:6a0:54da:b7ca with SMTP id 6a1803df08f44-6a1681956e7mr108183696d6.36.1715586827931; Mon, 13 May 2024 00:53:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715586827; cv=none; d=google.com; s=arc-20160816; b=DAwERj3FL13ju2bXUAHz0G8/YGzgJEKhKI6RgSYVsQyiVILTrkHTBI39M79TIu3LfM phb9kf+krjBOZQ42C4xC2T43ASgNQ9T6fOF5qPFyJwc0TL8a0sMv5+tsHE+5qaWxi8k/ 1cfUA/V3t/OXCM09ins+gNLzkU+x4T6Ys0usdHbVEpoT3VoYs41VfosiJ4D2gmvf888q xSuuAfZPOGbZSpiS1b7elTXoD5Lec+Vr2snAhQIIMgyz+Ev1+xz8aUESEBD4E8p91Kw2 xSvmZkJ9gGmYZfxIA72lJKGkapEZ/+FHcJi+c1LVsylk66UpAzlyv2PTYzgI8Zr1Bemc kBgw== 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=eissEZfbvjUIHa56B6rsG+Z6yFq1Hi6OaQz39ftd2Uo=; fh=f2WZoDMBYjCKWIIOoPI+rQtxlv4fmOm4u+dLdQLqpOk=; b=0pJND/hIF1gcGZeOw87VumLxciMc7R8LffSf+qvLZVxlIJsAwIFcMZT1jzIosb3fem VJsCDgRPDpbgj/6BLy2zViA5kql/UVSvoDSaB6pMEwZugkXUdhG8A2JIMdc26DMSLwgs FbwTRhV7B+4vla3l/MHX4w5f+EV19aUelSawRyqb7VBmCvmf605HOBaJssMfNACiAW+f iAW0+Hc2TAwFpezroXqoQftxQPDUHTLqYIsGlNSbhqlI9bAz5x4Za5K3+u+JRM44iWic quxX3CiziioieVFl0OSFfG7lbuWmPz+tnYxEZ2ML2HuVGYItlt+ZE3JPzOiDxEQeigpL Z1BA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LxL1L+H4; 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 6a1803df08f44-6a15f2ee8bfsi91665276d6.490.2024.05.13.00.53.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 May 2024 00:53:47 -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=LxL1L+H4; 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 1s6QR3-00055U-9x; Mon, 13 May 2024 03:49:25 -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 1s6QPT-0002va-Ho for qemu-devel@nongnu.org; Mon, 13 May 2024 03:47:47 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s6QPM-0001P4-MK for qemu-devel@nongnu.org; Mon, 13 May 2024 03:47:47 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4201986d60aso1691605e9.3 for ; Mon, 13 May 2024 00:47:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715586459; x=1716191259; 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=eissEZfbvjUIHa56B6rsG+Z6yFq1Hi6OaQz39ftd2Uo=; b=LxL1L+H4S2RpDxUjJja6TLbyCztXkC3qwWwxzuKB73g4lo8X9mTSypA5wsSLETMPi9 CsADXBrl1lv8w2DOctLn1qbaz6itZlmmrHqmGWCQCk+f61Gh9rKN2nJUK4RzdbK1voFg Wy/4xLY1iNM3IcuXyj3vOaE8Jtlb8IgKKK7nAcQdymMnjaY1z24zXrm8uZSZCeEMdtJY EpVVGTwglvSHlZV/RA3MO+Udlx8CSGOs0RnAcExf9EtNkkylkihbK4QastpUiiXL35nZ f71XyYXytlfOInjyulmi97Jy+dq8kLsIaXBToL4j8JX602e3r+Qy1tVNkGTNy6L+GKEs DMtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715586459; x=1716191259; 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=eissEZfbvjUIHa56B6rsG+Z6yFq1Hi6OaQz39ftd2Uo=; b=C+g/oHjO8rorzzyCzZrmrsgoHiKHfjshK11ZOrC7rVKnJD1YT5EURqKzzyoPmr4sN/ SWUuzoDqAYwBbi2/JClJmHjmOJKPUlx01fzyW/F8AvG7KhtncLfKfmCJgbsxvTBk9Ha4 9I+NupyiAS8lqzUT5endRSYQfXZPmS80zkn5AMqyrpFLFsSWymaqfegU65y0iQnglHjJ KqRxzqvAhKMFEMa83b08VNsBHAcC0WAPj43QSk2Xs4xKki4/V5By6CcTwGDXnCvoFAUO RfhFmyTpk8oSTpZA+ZnwiGgpjz6opoNSBFWB4PgmQ1Qu/+PSWP+C92OtwZPyNbK+I8ia 4yfQ== X-Gm-Message-State: AOJu0YyncHZFBLzkA0+HrEmQlBlsfBKBRsofPuCwYeS1PMd5SjFyewTX WPoom102tdbSo51/nhFv/nzSmfXYjiHO4f/jwFIIFMxKK2cxmkgZeSkJbkdWDzGS8BDuySTGWwt Mh5s= X-Received: by 2002:a7b:c4da:0:b0:41e:1f78:314d with SMTP id 5b1f17b1804b1-41feab42b5emr63487715e9.24.1715586459326; Mon, 13 May 2024 00:47:39 -0700 (PDT) Received: from stoup.. (12.red-213-97-13.staticip.rima-tde.net. [213.97.13.12]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-41fccee9318sm148204765e9.30.2024.05.13.00.47.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 00:47:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@gmx.de Subject: [PATCH v2 28/45] target/hppa: Introduce DisasDelayException Date: Mon, 13 May 2024 09:47:00 +0200 Message-Id: <20240513074717.130949-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240513074717.130949-1-richard.henderson@linaro.org> References: <20240513074717.130949-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32d.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 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 Reviewed-by: Helge Deller --- 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 e06c14dd15..e75e7e5b54 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -51,6 +51,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; @@ -66,6 +77,7 @@ typedef struct DisasContext { DisasCond null_cond; TCGLabel *null_lab; + DisasDelayException *delay_excp_list; TCGv_i64 zero; uint32_t insn; @@ -683,13 +695,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) @@ -4696,6 +4733,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,