From patchwork Fri Oct 13 21:27:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 733271 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1678342wrv; Fri, 13 Oct 2023 14:31:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHvKVJltSVMaSXNMjagFKGag8n0LhNE3sSmxm7r8fEscTtk8MkFPIJyIsngVjaWhS6byVX X-Received: by 2002:a05:6808:1aa5:b0:3ad:f6ad:b9ce with SMTP id bm37-20020a0568081aa500b003adf6adb9cemr25783967oib.15.1697232709904; Fri, 13 Oct 2023 14:31:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697232709; cv=none; d=google.com; s=arc-20160816; b=hFKw5PLVoh4kcIKNwp9n0234kfvX+pGH7MwDWmqjlG+pECLEZwZadaO26M4SUofNgB hNAmZq/oI5MmV6iO7b1jQ57sQ74gtavXkN5cnlWFF1NMVOTmyd024NwNqdWvUHMBpVef 1fp99d5Sb1mTu+5N+y1kXnZFw57FiM8+f6RiwWhdFKnYFul60azuQNENifV60yPOJI8x G+IjhfxCHd5HNnM3pA9kmbbJQ2oMAQutQUag9AWfx73L8LoZAu+2OY+GApGwRYWPcQK9 U2ssgkhFBGmJv3/Ye9794GDO1Pxqd8oiD05yP7tulRmNb2Q2M/ZFL6qjfiVC96zP5z35 h3NA== 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=WpwZzbCzugb1xyJsoESL1m5tuzzH5vNUu2M4VK3Jn88=; fh=OY/jf0qYEhT53LcIJp8d/e39mN3vEzshkseI36O8N8s=; b=iuLE7yDnk8LHvmXLtkRuq5YWqy3R7Vjt8zp+E1VkZR8zDDQcC2nnAFI3IVNhcP7LWh sXQK+Wv3W+U1OcG4I0jvUIHHygNv9HUnWaMqnkWrxzW50Owt2IZGymId63kDDKwPRZdf Z8ph1mW48UtTJLuWCPm41poICOlHlybGpXnA/dCIOE9DAPsoY5YtDETDlgqp9cKDhzGt BbHByk8xb9HAR/0Xs8NVJ0T1f+MWDryR9OKFdUSqGX81tURp1iGQvBWzKEw7f+XvWda8 hFXgvitOTVTMYCY4o1ufENj7UR28DM937MhMmgdWEEvKhLZD30b0HEo/MbhoGIwWCfgB sDqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MXLLi7I9; 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 s18-20020ad44b32000000b0065b269a1842si1854449qvw.245.2023.10.13.14.31.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Oct 2023 14:31:49 -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=MXLLi7I9; 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 1qrPiO-0006Cu-Gk; Fri, 13 Oct 2023 17:29:00 -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 1qrPiN-0006CA-IF for qemu-devel@nongnu.org; Fri, 13 Oct 2023 17:28:59 -0400 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrPiL-0000Ru-Rr for qemu-devel@nongnu.org; Fri, 13 Oct 2023 17:28:59 -0400 Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-3af604c3f8fso1515035b6e.1 for ; Fri, 13 Oct 2023 14:28:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697232537; x=1697837337; 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=WpwZzbCzugb1xyJsoESL1m5tuzzH5vNUu2M4VK3Jn88=; b=MXLLi7I9gJlKgiS/2/f9ERlJ9fi5FzdncYXjRgZfX+FU8Hlwb2gQNoU4eznoa1VEbG 53kSgjjz52DlCAfsSyfglQxzKgWn2ukYih9fXw+xQ1dh1nNa4eTcBIdBSW+GA25Rgb9V EdMFWXsxZio+7rnlZLl82sY0DY2Y4Afk1aAXzsBPfHER7Mi2DsIfYZCpAdNBaQcGbTUR 1syc21+c205okfwL3fAbS0i1CEIwGbuBx2ngopAfo++h80BXNe0QY5dSdUfcmqi26ZuF If6MXkW9dGIEk2NwoSpSy2hihUbUqIHNKfcjeXYrkFObBLzaiySLqFFzP9ovMDV+kXX2 YQTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697232537; x=1697837337; 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=WpwZzbCzugb1xyJsoESL1m5tuzzH5vNUu2M4VK3Jn88=; b=uyWafYEqSpcAkCE2YGpdsyV1iSL3MPuyjmdQpykmz/VAtAKOOwrT3dVKmA0ZsHrh0n 7JgbIcEkA2QSzUHXfujHdcz4hHxT00iCmsHPUnWsyA6HwrILjKN04RbXR8B3hFlgxW6G uC8EsGjlxCCmm2YXNOIUGGmLfTJBYx16pGPDTyymqs9JhoNoIZlV+DP+DAnCxLM5Shjq uBdvkX1aSfUf3NRmA3JQSXWfVR0Z7PHa7Mg9ngnwIXpnmP0qoGqEysraMUJFtc1PQJyQ moqdBMa4BPmRiG/TK04nlo7FLRg5/5FzE1merM1NXK/CLD+g9FMUTrzIZ995h92hHiK3 q0Gw== X-Gm-Message-State: AOJu0YxncXOj37cgQUKYSVbsqY3IfaVBacDuN7VHRqpxoUvAe3jco9og WYmfZhEsO6j1GWrvzkE3l18bqEcAKfM1vNmobuE= X-Received: by 2002:a05:6808:1302:b0:3a9:9bb4:485c with SMTP id y2-20020a056808130200b003a99bb4485cmr38757988oiv.8.1697232536455; Fri, 13 Oct 2023 14:28:56 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id b185-20020a6334c2000000b0058988954686sm70753pga.90.2023.10.13.14.28.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 14:28:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk, atar4qemu@gmail.com Subject: [PATCH 09/85] target/sparc: Move FBPfcc and FBfcc to decodetree Date: Fri, 13 Oct 2023 14:27:30 -0700 Message-Id: <20231013212846.165724-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013212846.165724-1-richard.henderson@linaro.org> References: <20231013212846.165724-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22b; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22b.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/sparc/insns.decode | 4 ++ target/sparc/translate.c | 105 +++++++++++++++----------------------- 2 files changed, 46 insertions(+), 63 deletions(-) diff --git a/target/sparc/insns.decode b/target/sparc/insns.decode index 838f4cdb1d..9ab3f2eb82 100644 --- a/target/sparc/insns.decode +++ b/target/sparc/insns.decode @@ -6,8 +6,12 @@ &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 +FBPfcc 00 a:1 cond:4 101 cc:2 - i:s19 &bcc +FBfcc 00 a:1 cond:4 110 i:s22 &bcc cc=0 %d16 20:s2 0:14 BPr 00 a:1 0 cond:3 011 .. - rs1:5 .............. i=%d16 +NCP 00 - ---- 111 ---------------------- # CBcc + CALL 01 i:s30 diff --git a/target/sparc/translate.c b/target/sparc/translate.c index f72e6eb756..8c15ca08c4 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -1312,44 +1312,6 @@ static void gen_compare_reg(DisasCompare *cmp, int cond, TCGv r_src) cmp->c2 = tcg_constant_tl(0); } -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)); - 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_fcond(cpu_cond, cc, cond); - if (a) { - gen_branch_a(dc, target); - } else { - gen_branch_n(dc, target); - } - } -} - #ifdef TARGET_SPARC64 static void gen_op_fcmps(int fccno, TCGv_i32 r_rs1, TCGv_i32 r_rs2) { @@ -2993,6 +2955,31 @@ static bool do_bpcc(DisasContext *dc, arg_bcc *a) TRANS(BPcc, 64, do_bpcc, a) TRANS(Bicc, ALL, do_bpcc, a) +static bool do_fbpfcc(DisasContext *dc, arg_bcc *a) +{ + target_long target = dc->pc + a->i * 4; + + if (gen_trap_ifnofpu(dc)) { + return true; + } + if (unlikely(AM_CHECK(dc))) { + target &= 0xffffffffULL; + } + 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_fcond(cpu_cond, a->cc, a->cond); + return advance_jump_cond(dc, a->a, target); + } +} + +TRANS(FBPfcc, 64, do_fbpfcc, a) +TRANS(FBfcc, ALL, do_fbpfcc, a) + static bool trans_BPr(DisasContext *dc, arg_BPr *a) { target_long target; @@ -3032,6 +3019,20 @@ static bool trans_CALL(DisasContext *dc, arg_CALL *a) return true; } +static bool trans_NCP(DisasContext *dc, arg_NCP *a) +{ + /* + * For sparc32, always generate the no-coprocessor exception. + * For sparc64, always generate illegal instruction. + */ +#ifdef TARGET_SPARC64 + return false; +#else + gen_exception(dc, TT_NCP_INSN); + return true; +#endif +} + #define CHECK_IU_FEATURE(dc, FEATURE) \ if (!((dc)->def->features & CPU_FEATURE_ ## FEATURE)) \ goto illegal_insn; @@ -3055,7 +3056,6 @@ static void disas_sparc_legacy(DisasContext *dc, unsigned int insn) case 0: /* branches/sethi */ { unsigned int xop = GET_FIELD(insn, 7, 9); - int32_t target; switch (xop) { #ifdef TARGET_SPARC64 case 0x1: /* V9 BPcc */ @@ -3063,36 +3063,15 @@ static void disas_sparc_legacy(DisasContext *dc, unsigned int insn) case 0x3: /* V9 BPr */ g_assert_not_reached(); /* in decodetree */ case 0x5: /* V9 FBPcc */ - { - int cc = GET_FIELD_SP(insn, 20, 21); - if (gen_trap_ifnofpu(dc)) { - goto jmp_insn; - } - target = GET_FIELD_SP(insn, 0, 18); - target = sign_extend(target, 19); - target <<= 2; - do_fbranch(dc, target, insn, cc); - goto jmp_insn; - } + g_assert_not_reached(); /* in decodetree */ #else case 0x7: /* CBN+x */ - { - goto ncp_insn; - } + g_assert_not_reached(); /* in decodetree */ #endif case 0x2: /* BN+x */ g_assert_not_reached(); /* in decodetree */ case 0x6: /* FBN+x */ - { - if (gen_trap_ifnofpu(dc)) { - goto jmp_insn; - } - target = GET_FIELD(insn, 10, 31); - target = sign_extend(target, 22); - target <<= 2; - do_fbranch(dc, target, insn, 0); - goto jmp_insn; - } + g_assert_not_reached(); /* in decodetree */ case 0x4: /* SETHI */ /* Special-case %g0 because that's the canonical nop. */ if (rd) {