From patchwork Sun Nov 5 20:12:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 741047 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp793052wrr; Sun, 5 Nov 2023 12:13:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IH9Ro0rC59yVzFQyOsBJ/XSmTOgKPKjrD84O8LchGVA4KUz70Whjw90DUpqu9QeD1nU5QKw X-Received: by 2002:ad4:5c65:0:b0:656:3b4c:b98b with SMTP id i5-20020ad45c65000000b006563b4cb98bmr38575496qvh.11.1699215217437; Sun, 05 Nov 2023 12:13:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699215217; cv=none; d=google.com; s=arc-20160816; b=KhSQXmFIP/Gg6wOiBTmztVLTdpH0XNzZnyFfVJ+8yCrEMajpifhI9Tcnmdc3ZfsBrk jaoqUvNnZXZNzYA8djjPmz7MzUv9n6/IsWFWEI5IJUBHBceyPlehIbqCEdJjMWe+545H aAmEw3QrK9Iz3RURf5A0nka2Xa1obiQYcSjIOR93bFVaqHVf+X5KRWwtt3ADPWP0b4ZE 0IWsdAjlTCk87Ctno6aLVQGaf+EMboGBowGkClWL2ovonqxp+Xj8TyGpCfmyncdLJNVd Jfzf1W9qeaP3fNXK7yrKAdZ/oOZSoxbEUPZz2iB2572mK9rZA9wOj8otfGzzwR0me3+g +hcw== 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=TFSCl5lnV2U9VXq8eQaIzYhW+oJcX4r3EEzkiMuRW8Q=; fh=rYI8DiHAAFX3O5g969KmOAQ7d45Sb8OxQX1+DywGDk4=; b=Mo29Sv7c+6q91AZT3opG0EWHHtPzSfqdvzRwFR+aeIYfQPq7HIOUtyjLNssK2YTN2M pwmBiLhMHtBCv+a5ymdeHfVfdfsZ0YYzK1C20y2Yub0ARSAVjdLaJ1sofEDEvMyODO0x fNC4VWicNG7kqRXVnWRY1OJDAN3ZgxuoYEGn9Vva1VdcOmQo/okt1SGdz1QfajDOk+HP S7pwZOXFxfovcawEUuNTD4M4D5DAEVouG+VS5QUo2fLzgU1nJAUAcDuE/3Ps+XHM2Ujd dswRs3DYqpk78jLGLM3zSqkEF7UuWimRukpRVGBQ9UundbgmD2Pdcrq3fuoPUjR/JKjd kQ9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YnQx0Y1K; 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=fail (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 x20-20020ad44594000000b0065af2299bafsi4804440qvu.276.2023.11.05.12.13.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 05 Nov 2023 12:13:37 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=YnQx0Y1K; 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=fail (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 1qzjU9-0003PR-1Q; Sun, 05 Nov 2023 15:12:41 -0500 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 1qzjU7-0003O4-DI for qemu-devel@nongnu.org; Sun, 05 Nov 2023 15:12:39 -0500 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qzjU5-0002AC-RL for qemu-devel@nongnu.org; Sun, 05 Nov 2023 15:12:39 -0500 Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3b2b1af964dso2546617b6e.1 for ; Sun, 05 Nov 2023 12:12:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699215156; x=1699819956; 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=TFSCl5lnV2U9VXq8eQaIzYhW+oJcX4r3EEzkiMuRW8Q=; b=YnQx0Y1Kk+MI3wAaE1eCCUCQ/hzSeW6nEHpveCX994v7Tns4JBGCr9fDZ32iaWORpk EGDKIt1tPoi98AUR0+VmJeWz/rpkD8O5V77WuqLHn7CLeC+lHOwPXW/WVrDRNbu2MRJZ 4ZQXT+SkEoxDbZ30yd93SNGhTmitbDZUlz+mvfVDiN7L1uLcFvBcWxYnIftkQIlbWUvh ZqVJE1Gq9Y+nCE307kAfcnfGGe0rvsGUAr1JbwY8Mitq6ylO/mLXu41CxTmeOqkwgZbX IgsNex4MPojngJCCz7/2iDQfNcpm+WPU97CmJyehinhWyKyrwNtCIwMwgLOTWHGEP0HO x7Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699215156; x=1699819956; 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=TFSCl5lnV2U9VXq8eQaIzYhW+oJcX4r3EEzkiMuRW8Q=; b=AcbtiILXQHqbWKInmadQtBup2AO5DKWIjK9Hov3+Dv2RVl+mZ7y2gm5M91Ua6dVTx7 /hj9yptARzzF7JF22KzQxIfyQJvlWiwg5eTHPSEyw99K3EJZNzqzVxK85TGHZdA+i/pi W06lP2TVWU/Pk0CXfleq5CCu2a16FLLRkiB6WzR+ASNIN9UljSuU2kkdbQ4AiKYl2784 I4ekuvv3y73FsDdRg8zRizVr1NKZomevLHYqkeHJ/hawyVZmvLrPuGaIxi2ko4MPDJRk QVnMBjZWCLESi9vp3ui8OJLasqfUlNL039bWLofRWKI8bDiD4URYGODnL4FNFthOTupl n3gQ== X-Gm-Message-State: AOJu0Yzvu6ebpnZwhTrWGToq7dx0TuDTFdDnVrC8TXBWWBC1eX8r/5hn PhDzeP64k27npnCFUCPO1gq86slD8lU+vMW3bhI= X-Received: by 2002:a05:6808:189c:b0:3b5:9541:cb43 with SMTP id bi28-20020a056808189c00b003b59541cb43mr9291154oib.14.1699215155774; Sun, 05 Nov 2023 12:12:35 -0800 (PST) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id u23-20020a056a00099700b006884549adc8sm4359777pfg.29.2023.11.05.12.12.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 12:12:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland Subject: [PULL 14/21] target/sparc: Merge advance_jump_uncond_{never, always} into advance_jump_cond Date: Sun, 5 Nov 2023 12:12:15 -0800 Message-Id: <20231105201222.202395-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231105201222.202395-1-richard.henderson@linaro.org> References: <20231105201222.202395-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::231; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x231.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Handle these via TCG_COND_{ALWAYS,NEVER}. Allow dc->npc to be variable, using gen_mov_pc_npc. Tested-by: Mark Cave-Ayland Acked-by: Mark Cave-Ayland Signed-off-by: Richard Henderson --- target/sparc/translate.c | 74 ++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 44 deletions(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index e134ba8821..cbee5435a3 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -2378,37 +2378,37 @@ static bool advance_pc(DisasContext *dc) * Major opcodes 00 and 01 -- branches, call, and sethi */ -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, DisasCompare *cmp, bool annul, target_ulong dest) { target_ulong npc; + if (cmp->cond == TCG_COND_ALWAYS) { + if (annul) { + dc->pc = dest; + dc->npc = dest + 4; + } else { + gen_mov_pc_npc(dc); + dc->npc = dest; + } + return true; + } + + if (cmp->cond == TCG_COND_NEVER) { + npc = dc->npc; + if (npc & 3) { + gen_mov_pc_npc(dc); + if (annul) { + tcg_gen_addi_tl(cpu_pc, cpu_pc, 4); + } + tcg_gen_addi_tl(cpu_npc, cpu_pc, 4); + } else { + dc->pc = npc + (annul ? 4 : 0); + dc->npc = dc->pc + 4; + } + return true; + } + flush_cond(dc); npc = dc->npc; @@ -2478,15 +2478,8 @@ static bool do_bpcc(DisasContext *dc, arg_bcc *a) target_long target = address_mask_i(dc, dc->pc + a->i * 4); DisasCompare cmp; - 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: - gen_compare(&cmp, a->cc, a->cond, dc); - return advance_jump_cond(dc, &cmp, a->a, target); - } + gen_compare(&cmp, a->cc, a->cond, dc); + return advance_jump_cond(dc, &cmp, a->a, target); } TRANS(Bicc, ALL, do_bpcc, a) @@ -2500,15 +2493,8 @@ static bool do_fbpfcc(DisasContext *dc, arg_bcc *a) if (gen_trap_ifnofpu(dc)) { return true; } - 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: - gen_fcompare(&cmp, a->cc, a->cond); - return advance_jump_cond(dc, &cmp, a->a, target); - } + gen_fcompare(&cmp, a->cc, a->cond); + return advance_jump_cond(dc, &cmp, a->a, target); } TRANS(FBPfcc, 64, do_fbpfcc, a)