From patchwork Sun Oct 22 23:28:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 737221 Delivered-To: patch@linaro.org Received: by 2002:adf:dd81:0:b0:32d:baff:b0ca with SMTP id x1csp1284727wrl; Sun, 22 Oct 2023 16:41:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFhwCxNDSrO6hPTWhUp6MMy1kBbrqeUS+gk4+btY6bZ0WmhRQKxuvhaCupgTlmzpJSVNl57 X-Received: by 2002:a05:6214:3b84:b0:66d:ad78:130d with SMTP id nf4-20020a0562143b8400b0066dad78130dmr2889376qvb.21.1698018112553; Sun, 22 Oct 2023 16:41:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698018112; cv=none; d=google.com; s=arc-20160816; b=06bvqgXO4xUG/+FyWqsYbIKOYs/rEt5CDA//RB4xlpdLkg0hGdUCsE2KuksgH32szW IrefeWuQ5eNqB/So7zPmaZMnTLMKyMMUda6HmVnb2aFw7jm54Yp93PV2LxM1qoLU3foW YJ4xG4V7LlwSLsE3+5SX9ekW7EyFnQXFDRV01DfYZ18ypn6IfWNGf5VBzUBd550utTh9 pb2+sUZ/y4bIb8wnwwxjfmaJHXyrclwRX0sHVKOIdeBsdiNYKeiI3qLtFmdNrrGqprJl i5gXxh34VIcJS74LGwOtCYC5chC/CcQygX6Zk2/rW9q8BOa4jaO86nHerlvGiIKkxLGV 2uPw== 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=gdQgXOjAL0pMRTrOYm1bbz3Vj0JDl4iRceiONBfWCq0=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=pJPT/ntwqtvVHzR2re3czZ7OICc1ucvUVx4CVIp7s2v7CUT4KiFXYDeWeOdQsAD+sm NDrbMeZ7lGuNIfwZYA++iOdujDisoMr3AaSNIG1MypmXthvOoYbClnfnMsoggYS/iXRN dnxWIm+TROgSHlKyxwtoSXMRuFgL9uiL6cA10QcGHlITI5e8M9oSleeVBWu3gPaqIxZC Kk8gjVpin2mBmD5Ac5dmIQRj13edjIqRKoidHKR6+q2dlTVAzM3JTYgtbb2IPIsWe3w5 Yo3Mav2o9BJZZcbWINHVT1+pNqWp8fv2twiOvyyx3zdhhaYjf+L6rVcZimIh9v4VUX1R xZ6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tQuTxTAr; 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 y7-20020ac85f47000000b0041965cec4bdsi4680866qta.140.2023.10.22.16.41.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Oct 2023 16:41:52 -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=tQuTxTAr; 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 1quhtZ-0007HQ-15; Sun, 22 Oct 2023 19:30:09 -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 1quhtI-00077M-Rm for qemu-devel@nongnu.org; Sun, 22 Oct 2023 19:29:52 -0400 Received: from mail-oo1-xc31.google.com ([2607:f8b0:4864:20::c31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1quhtC-0006jI-R8 for qemu-devel@nongnu.org; Sun, 22 Oct 2023 19:29:51 -0400 Received: by mail-oo1-xc31.google.com with SMTP id 006d021491bc7-581e92f615fso1690483eaf.2 for ; Sun, 22 Oct 2023 16:29:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698017385; x=1698622185; 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=gdQgXOjAL0pMRTrOYm1bbz3Vj0JDl4iRceiONBfWCq0=; b=tQuTxTAra3n5MzgM3We2FBZxPnJGxotQ1i1QNykzERY2oHiJ8x7s9B0tvhTVRXnNH1 Jt5nfTKH33UDjVzE4e99flHRg4a7YvzxGRRd4rR9Kx+W/hOYeNyEXQruzdkHFkc8K5CJ rE6n9QPIsahrb02pdDkYqzzoSovKEF4vKJU/c55yRQbPCzVy2EGuDIqIOPPpM8BkjCeL duqzvlTOo9myp43Pb309470JVgHarHPN9xY1HWX9q21j2kaOKqpCfpD9NdGhqW5bSK6A tA5/rLTuCfSIZcywlzGDoeMjis6VmYKPyBpghjvDxELCN2T9lKC7BCH3+EglUa1EknHn Pi4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698017385; x=1698622185; 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=gdQgXOjAL0pMRTrOYm1bbz3Vj0JDl4iRceiONBfWCq0=; b=d+Z6LoBrGgk1mfpJpm01m+qHT+COIjUqpe5Wl+T1uEqOGPK9xay2h+lqsaJujRdwJT q/vCHP+Am2z3fUqk02o1+1/SQwbMvAoRMSVxs67SL6MPO1oJYC9HTXDCRH1faxhz7CHq FVo+uruUVpk5Wo2hhVivHig8nMN6yZ1oUzSGx1ozR09pQ3amUkT1BdBsmHFH/T/1luW5 RxkD816Yz5NWGTC7YVmeRh4J93Hu2HbiuWKW3YvJk3Au8xSiUlwUfin3Im55d3pjJDVW SFr6Xi0tZj17QAYCflilmYU7FhnBczFPzvaEELZT0gkDBsW4PTDzTJd+bLY5c4/ck/KI WbpA== X-Gm-Message-State: AOJu0YzkXirJEOPBQOpS8Yh2bTT1RpMruCvEtP9yT2zg1BVK3Ez43Yvz r0znQPe9KDQoWY3wqmj7QI92cTRZug24dc1mZxE= X-Received: by 2002:a05:6358:72a0:b0:168:ce1d:5a51 with SMTP id w32-20020a05635872a000b00168ce1d5a51mr4450353rwf.4.1698017385405; Sun, 22 Oct 2023 16:29:45 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id k26-20020a63ba1a000000b005b25a04cf8bsm4023772pgf.12.2023.10.22.16.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 16:29:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH v5 13/94] target/sparc: Move BPcc and Bicc to decodetree Date: Sun, 22 Oct 2023 16:28:11 -0700 Message-Id: <20231022232932.80507-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231022232932.80507-1-richard.henderson@linaro.org> References: <20231022232932.80507-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::c31; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc31.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 Tested-by: Mark Cave-Ayland Acked-by: Mark Cave-Ayland Signed-off-by: Richard Henderson --- target/sparc/insns.decode | 4 ++ target/sparc/translate.c | 117 +++++++++++++++++++------------------- 2 files changed, 61 insertions(+), 60 deletions(-) diff --git a/target/sparc/insns.decode b/target/sparc/insns.decode index a5f5d2681e..15cd975f4e 100644 --- a/target/sparc/insns.decode +++ b/target/sparc/insns.decode @@ -3,4 +3,8 @@ # Sparc instruction decode definitions. # Copyright (c) 2023 Richard Henderson +&bcc i a cond cc +BPcc 00 a:1 cond:4 001 cc:1 0 - i:s19 &bcc +Bicc 00 a:1 cond:4 010 i:s22 &bcc cc=0 + CALL 01 i:s30 diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 7ef4c6d4f7..92ea6bab6b 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -1367,44 +1367,6 @@ static void gen_cond_reg(TCGv r_dst, int cond, TCGv r_src) } #endif -static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc) -{ - unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29)); - target_ulong target = dc->pc + offset; - - if (unlikely(AM_CHECK(dc))) { - target &= 0xffffffffULL; - } - if (cond == 0x0) { - /* unconditional not taken */ - if (a) { - dc->pc = dc->npc + 4; - dc->npc = dc->pc + 4; - } else { - dc->pc = dc->npc; - dc->npc = dc->pc + 4; - } - } else if (cond == 0x8) { - /* unconditional taken */ - if (a) { - dc->pc = target; - dc->npc = dc->pc + 4; - } else { - dc->pc = dc->npc; - dc->npc = target; - tcg_gen_mov_tl(cpu_pc, cpu_npc); - } - } else { - flush_cond(dc); - gen_cond(cpu_cond, cc, cond, dc); - if (a) { - gen_branch_a(dc, target); - } else { - gen_branch_n(dc, target); - } - } -} - static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc) { unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29)); @@ -3046,6 +3008,61 @@ static bool advance_pc(DisasContext *dc) return true; } +static bool advance_jump_uncond_never(DisasContext *dc, bool annul) +{ + if (annul) { + dc->pc = dc->npc + 4; + dc->npc = dc->pc + 4; + } else { + dc->pc = dc->npc; + dc->npc = dc->pc + 4; + } + return true; +} + +static bool advance_jump_uncond_always(DisasContext *dc, bool annul, + target_ulong dest) +{ + if (annul) { + dc->pc = dest; + dc->npc = dest + 4; + } else { + dc->pc = dc->npc; + dc->npc = dest; + tcg_gen_mov_tl(cpu_pc, cpu_npc); + } + return true; +} + +static bool advance_jump_cond(DisasContext *dc, bool annul, target_ulong dest) +{ + if (annul) { + gen_branch_a(dc, dest); + } else { + gen_branch_n(dc, dest); + } + return true; +} + +static bool do_bpcc(DisasContext *dc, arg_bcc *a) +{ + target_long target = address_mask_i(dc, dc->pc + a->i * 4); + + switch (a->cond) { + case 0x0: + return advance_jump_uncond_never(dc, a->a); + case 0x8: + return advance_jump_uncond_always(dc, a->a, target); + default: + flush_cond(dc); + gen_cond(cpu_cond, a->cc, a->cond, dc); + return advance_jump_cond(dc, a->a, target); + } +} + +TRANS(Bicc, ALL, do_bpcc, a) +TRANS(BPcc, 64, do_bpcc, a) + static bool trans_CALL(DisasContext *dc, arg_CALL *a) { target_long target = address_mask_i(dc, dc->pc + a->i * 4); @@ -3083,21 +3100,7 @@ static void disas_sparc_legacy(DisasContext *dc, unsigned int insn) switch (xop) { #ifdef TARGET_SPARC64 case 0x1: /* V9 BPcc */ - { - int cc; - - target = GET_FIELD_SP(insn, 0, 18); - target = sign_extend(target, 19); - target <<= 2; - cc = GET_FIELD_SP(insn, 20, 21); - if (cc == 0) - do_branch(dc, target, insn, 0); - else if (cc == 2) - do_branch(dc, target, insn, 1); - else - goto illegal_insn; - goto jmp_insn; - } + g_assert_not_reached(); /* in decodetree */ case 0x3: /* V9 BPr */ { target = GET_FIELD_SP(insn, 0, 13) | @@ -3127,13 +3130,7 @@ static void disas_sparc_legacy(DisasContext *dc, unsigned int insn) } #endif case 0x2: /* BN+x */ - { - target = GET_FIELD(insn, 10, 31); - target = sign_extend(target, 22); - target <<= 2; - do_branch(dc, target, insn, 0); - goto jmp_insn; - } + g_assert_not_reached(); /* in decodetree */ case 0x6: /* FBN+x */ { if (gen_trap_ifnofpu(dc)) {