From patchwork Tue Oct 17 06:40:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734362 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp332295wro; Mon, 16 Oct 2023 23:48:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxJpk7MK+fYYSx3qEFa+OxSAuVHM1DC7NBPhkYVzzpRWfsA32tro2TMGsW1NJ1hZHOaxI1 X-Received: by 2002:a81:49c4:0:b0:5a7:ed69:120 with SMTP id w187-20020a8149c4000000b005a7ed690120mr1445960ywa.6.1697525282815; Mon, 16 Oct 2023 23:48:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697525282; cv=none; d=google.com; s=arc-20160816; b=A/xivcDvHYtZu8LunQgp3obua7H+na9MI/JwL9XP334awoC4dCJG/HSI7MJc1UInS8 oR2FkttZJ9HkAN5ktw6xXuf588LmkpsoKi2yPhwB1Y8wotlmQy5e963jusQXuppIGnvK pdJTCvBIF8LVyt5XQFIJ/atFczQ8eRA30TuWWugbosICnMOClGHUy9c9mrriaJa3TLhK RL4x9JgKR/IrFpq5hnMLDH1OKEJTkUWLNUnk9pMp/ozJcrIXrMOE7UuxPiUTafUK3GZt nVxbdpVz8nvDl43ct97KPol5QwfVAlJu7wGO6lkgSnzoJpSYw4krK7ynFNPj2D2gUw66 GT5Q== 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=HeMyfJcx+peR5itTdqsCZ9Xkp/oHQ/IkwnAHAyhPKRo=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=F1Je5VxyQNZBTF1dDhXBolCcK6uHkBCtM7dae2YxFhSGGkYAlLlCXMlS914w4SWmtw UsX8whhE6EDxcFOR3/uFRTUXdeMyF+w5oYWsCa1Em90/E6EHaNV0v/bFl2s3HIPtZRa+ K1LN+vw/lAWX/+QL1+P3hrM3XHjQUqqFDjr1gEotbqveWUulyqJkt/fhLFqzb+f5p+If CJgTaBlixWHtz7Gfuyj7o+17tTT0dcI8d+M+78Dk9AB/E1wLdLPztyrXlXHf9ma3I4xh H9OyFL+6zfEylIbafiiUMRqCE+0tpWYbXHPN5gO+QvH7DRyRwyDgR0FRBw+XNS3cvKt0 8l9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y9zUgqM8; 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 m12-20020a05620a290c00b007741b0f3fd8si652658qkp.283.2023.10.16.23.48.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:48:02 -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=Y9zUgqM8; 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 1qsdlV-0007qu-7z; Tue, 17 Oct 2023 02:41:17 -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 1qsdlT-0007q3-24 for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:15 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdlR-0001pi-8b for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:14 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6b87c1edfd5so2331316b3a.1 for ; Mon, 16 Oct 2023 23:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524871; x=1698129671; 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=HeMyfJcx+peR5itTdqsCZ9Xkp/oHQ/IkwnAHAyhPKRo=; b=Y9zUgqM8DPfJ0UdCyLoToyFn4fUjhbImQsQjgHV9kUgsCbeBoWgtBT4lKeQfMcc9sG cSj1g75mSeTR/ZzILARcR03YrsBo0UaPYVYcmCHf74+bLhE6NyHZV7Vu+ZJJl18weAxO ce6h9jYTlzradoib8UNl83hkWtD1pSNcP6JU1va+52fzggrp3AkSfi0HYBKNl7c/8F3p RgRYjH8qlqvThJMTI69OPHvjGY0ayDJpV+towNCBx6kGf3wCK0cc6Epea/DyvJUI8UDm TBEKbb8iqqGK8NnokFfrHvTNWX+UfY0CZtbSsVTOu6AD3rWafo0zmCai2tUXEZx36AK0 koBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524871; x=1698129671; 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=HeMyfJcx+peR5itTdqsCZ9Xkp/oHQ/IkwnAHAyhPKRo=; b=D6fzwX2h3P71zoldNQYW8V54eF6/qZvfiEvF2FPcoLT6rCAnST6j9Uh3B981w2rJG9 n7H4N8fdZDtS40tglFXtFrebplg5M345l2JEkhn4GaDyyPlBgtV1fV5ftTnMBY3+HxHx NfO/ZBSZ/fFFn+iRpU2HaRSJ5ct0tUUwv0Pxp+Yp/WANMJzHUAUUcBTkSoHytAKOpZwn bUStCm8yn7Iks1hc/JwDK7+ojCC6jnmLgvgs9zhllDaP74pDh/SR6E56h5hXbcSByCvi 9XN39EmxtXZoF9JQS+1IJGTPQt6fZB9INoZc2rx34JdV321H90K8+vFUptJ7v7yX4i7X z85A== X-Gm-Message-State: AOJu0YyqrOID4ekTUp2YytTzN9ojLOmRl9ZiYVsK7ZLfIvGRry6lBr/k uZSt7cHX7KNzZlJlJP7Bt5ygnko0FbcIZgM66Y4= X-Received: by 2002:a05:6a20:ceaa:b0:140:a25:1c1d with SMTP id if42-20020a056a20ceaa00b001400a251c1dmr1097705pzb.51.1697524871031; Mon, 16 Oct 2023 23:41:11 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 01/20] target/sparc: Introduce cpu_put_psr_icc Date: Mon, 16 Oct 2023 23:40:50 -0700 Message-Id: <20231017064109.681935-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.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 Isolate linux-user from changes to icc representation. Signed-off-by: Richard Henderson --- target/sparc/cpu.h | 1 + linux-user/sparc/signal.c | 2 +- target/sparc/win_helper.c | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index 758a4e8aaa..955329f6c9 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -619,6 +619,7 @@ void sparc_restore_state_to_opc(CPUState *cs, /* win_helper.c */ target_ulong cpu_get_psr(CPUSPARCState *env1); void cpu_put_psr(CPUSPARCState *env1, target_ulong val); +void cpu_put_psr_icc(CPUSPARCState *env1, target_ulong val); void cpu_put_psr_raw(CPUSPARCState *env1, target_ulong val); #ifdef TARGET_SPARC64 void cpu_change_pstate(CPUSPARCState *env1, uint32_t new_pstate); diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index 2be9000b9e..dfcae707e0 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -164,7 +164,7 @@ static void restore_pt_regs(struct target_pt_regs *regs, CPUSPARCState *env) */ uint32_t psr; __get_user(psr, ®s->psr); - env->psr = (psr & PSR_ICC) | (env->psr & ~PSR_ICC); + cpu_put_psr_icc(env, psr); #endif /* Note that pc and npc are handled in the caller. */ diff --git a/target/sparc/win_helper.c b/target/sparc/win_helper.c index 3a7c0ff943..bf2c90c780 100644 --- a/target/sparc/win_helper.c +++ b/target/sparc/win_helper.c @@ -67,9 +67,14 @@ target_ulong cpu_get_psr(CPUSPARCState *env) #endif } -void cpu_put_psr_raw(CPUSPARCState *env, target_ulong val) +void cpu_put_psr_icc(CPUSPARCState *env, target_ulong val) { env->psr = val & PSR_ICC; +} + +void cpu_put_psr_raw(CPUSPARCState *env, target_ulong val) +{ + cpu_put_psr_icc(env, val); #if !defined(TARGET_SPARC64) env->psref = (val & PSR_EF) ? 1 : 0; env->psrpil = (val & PSR_PIL) >> 8; From patchwork Tue Oct 17 06:40:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734349 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp330755wro; Mon, 16 Oct 2023 23:42:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAhORHyOBQUEBZbUuGpgxmJ6H8c8YINFFDVMBCffJ+W2BxMyhiqpbf9Z+XcNEIgQkS4wFb X-Received: by 2002:a05:6214:246f:b0:658:d8ec:c036 with SMTP id im15-20020a056214246f00b00658d8ecc036mr1883058qvb.3.1697524963118; Mon, 16 Oct 2023 23:42:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697524963; cv=none; d=google.com; s=arc-20160816; b=Wyj88KAfW6m1aJ6C6UEKelvpBhy+1aodG1PzsAt6kfxeriCRdNTq88up56jIJEUryy AZ/x+ZRAIUql6r0VZa0rQ1dGN+4PhfxkYPwLJX5reiCG+MpahE9oYEEpQmxhUQFQezcd Or+wpJKWwcPgtO8ZavWxSywkbY3L1O75wnZeDZVKLGeV99jXrfBGr0RdjtqFYfOQo5nL 6W5+1X9QZNWQi51+L1TsvNm2mzUH4apmbEt2lNz2+I+CNlxcFc6NnsOI0gZ5kmO4pDYU BfzsoAV+VBjBecugBKzcXEkn/kfq+BeGrNNSXdvhc3NMw6jtuHURvAUwBAfe5lzzf+5q 16dg== 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=7obh1xj62WyJcU1BfYfLTUfbiNd3asc7Dm3Hwtql9CA=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=pbdUIpiQ5F74YALGD797W1UMTiXi1fOJ6SQI8CtaR78LbkPPjWABDhVGktHeoeekJh w18bF3a6b5/GuSygmGy+QD1K/Zy73rzkTWPqcyYKlP2VPbjay7obwRiBd24yQTFFy8Hv MZOqbdCStwXlLPk4lUgPBLzxmF/v4r6n5yH+WLdY3X2nVv9FBDLb3fF9wI+xuxe2OFx1 +BNjyEo9u+o8a0YpE4LUNri4Ke6JfKdQj+6nBTFJeu+miYhueBWPim3uV0TXwSYaybBZ JyVQF4ltTjlw8pDprh3chPrMWAjuoR/nZmsgabN9HoluT9akdHPw/ldDjfK0r7doMX2Y dn1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EpffJd0V; 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 u6-20020a0ced26000000b0065b2e14c1c3si535884qvq.463.2023.10.16.23.42.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:42:43 -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=EpffJd0V; 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 1qsdlW-0007r6-Ak; Tue, 17 Oct 2023 02:41:18 -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 1qsdlU-0007qX-Ar for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:16 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdlR-0001ps-BC for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:16 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1c9d922c039so42782495ad.3 for ; Mon, 16 Oct 2023 23:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524872; x=1698129672; 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=7obh1xj62WyJcU1BfYfLTUfbiNd3asc7Dm3Hwtql9CA=; b=EpffJd0VefSw/9LjX+A38hOBesvPVEDyyteYESq1kYAFl1lyeVniAMoMSgNraooGb1 HhI23QjcpmgPFDB6BYSTH1/bBdmlEMHy0BkIrWxKgp5Fbv+C74av7EpJy7Jdm9zV2ecj P4F4xvqGKfY8EGfL7zk8UQ4cQC9cbrj+iPl2ErRJfISslx+UsjNpR305Xc10Ad6ENoVY qytVxOC0qbTihITfmJefklRyhBsuqseXEIrNsN284ueq+2xWK3KxN4zZSoVWV1xiKUtK wMyvZ5Q40g2GfhgL0E6t38ZSd0ARsubLtP6eXWQ2w8fX1he5BJrDgZXKvaDEd1wiOF/j RlZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524872; x=1698129672; 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=7obh1xj62WyJcU1BfYfLTUfbiNd3asc7Dm3Hwtql9CA=; b=qcr6MCKTSqiNQWS5CmhZH0rLoiGwh2yCrLOo7HAKKB66KzsA3DUbk6mSMZAzzUMiYd Dp6D2KJK1VROVyMZRWnG9S74jNfVieQLyAWIJT+N1zmJ/j0dO82BLIs7ykDhwjFuNPQ5 s1LBbu0MgMoiHpwFRnb/wXA07G6rKc3/J3YF0tupJRaQeZlh2kpK05acdgBK7HZf6Enz FhqDH6srwDW7wpDrYBzvAqVwmO2sVHp9VCe6oqRIWe5FbAViPDoSB3Kh8uHYbam7BaPQ HAYSf5fIzcedyjqL178P/l+jfQOGqhweigiw6VbTLROJ2Gl9CaTKa66GG2SyXHUVYm+o zIlQ== X-Gm-Message-State: AOJu0YwP8QZoaFNS6btNLb2INaanjFsTKmEFXkJPqW2vU2iljHz0vFWx jv5yLt4U5Pxe8tBTUaqRUdhxZ4v0mauNxEeVMJM= X-Received: by 2002:a17:902:ecce:b0:1c9:d940:78ea with SMTP id a14-20020a170902ecce00b001c9d94078eamr1521015plh.22.1697524871930; Mon, 16 Oct 2023 23:41:11 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 02/20] target/sparc: Split psr and xcc into components Date: Mon, 16 Oct 2023 23:40:51 -0700 Message-Id: <20231017064109.681935-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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 Step in removing CC_OP: change the representation of CC_OP_FLAGS. The 8 bits are distributed between 6 variables, which should make it easy to keep up to date. The code within cc_helper.c is quite ugly but is only temporary. Signed-off-by: Richard Henderson --- linux-user/sparc/target_cpu.h | 4 +- target/sparc/cpu.h | 30 ++- linux-user/sparc/cpu_loop.c | 18 +- target/sparc/cc_helper.c | 51 +++-- target/sparc/machine.c | 44 ++++- target/sparc/translate.c | 363 +++++++++++++--------------------- target/sparc/win_helper.c | 51 ++++- 7 files changed, 292 insertions(+), 269 deletions(-) diff --git a/linux-user/sparc/target_cpu.h b/linux-user/sparc/target_cpu.h index 1f4bed50f4..00a9fab98b 100644 --- a/linux-user/sparc/target_cpu.h +++ b/linux-user/sparc/target_cpu.h @@ -59,9 +59,9 @@ static inline void cpu_clone_regs_child(CPUSPARCState *env, target_ulong newsp, */ env->regwptr[WREG_O0] = 0; #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) - env->xcc &= ~PSR_CARRY; + env->cc_xcc_C = 0; #else - env->psr &= ~PSR_CARRY; + env->cc_icc_C = 0; #endif env->pc = env->npc; env->npc = env->npc + 4; diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index 955329f6c9..ac93658c33 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -149,7 +149,7 @@ enum { */ enum { CC_OP_DYNAMIC, /* must use dynamic code to get cc_op */ - CC_OP_FLAGS, /* all cc are back in status register */ + CC_OP_FLAGS, /* all cc are back in cc_*_[NZCV] registers */ CC_OP_DIV, /* modify N, Z and V, C = 0*/ CC_OP_ADD, /* modify all flags, CC_DST = res, CC_SRC = src1 */ CC_OP_ADDX, /* modify all flags, CC_DST = res, CC_SRC = src1 */ @@ -458,6 +458,32 @@ struct CPUArchState { target_ulong npc; /* next program counter */ target_ulong y; /* multiply/divide register */ + /* + * Bit 31 is for icc, bit 63 for xcc. + * Other bits are garbage. + */ + target_long cc_N; + target_long cc_V; + + /* + * Z is represented as == 0; any non-zero value is !Z. + * For sparc64, the high 32-bits of icc.Z are garbage. + */ + target_ulong cc_icc_Z; +#ifdef TARGET_SPARC64 + target_ulong cc_xcc_Z; +#endif + + /* + * For sparc32, icc.C is boolean. + * For sparc64, xcc.C is boolean; + * icc.C is bit 32 with other bits garbage. + */ + target_ulong cc_icc_C; +#ifdef TARGET_SPARC64 + target_ulong cc_xcc_C; +#endif + /* emulator internal flags handling */ target_ulong cc_src, cc_src2; target_ulong cc_dst; @@ -466,7 +492,6 @@ struct CPUArchState { target_ulong cond; /* conditional branch result (XXX: save it in a temporary register when possible) */ - uint32_t psr; /* processor state register */ target_ulong fsr; /* FPU state register */ CPU_DoubleU fpr[TARGET_DPREGS]; /* floating point registers */ uint32_t cwp; /* index of current register window (extracted @@ -522,7 +547,6 @@ struct CPUArchState { #define MAXTL_MAX 8 #define MAXTL_MASK (MAXTL_MAX - 1) trap_state ts[MAXTL_MAX]; - uint32_t xcc; /* Extended integer condition codes */ uint32_t asi; uint32_t pstate; uint32_t tl; diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index b36bb2574b..a2086afada 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -197,12 +197,22 @@ static uint32_t do_getpsr(CPUSPARCState *env) /* Avoid ifdefs below for the abi32 and abi64 paths. */ #ifdef TARGET_ABI32 #define TARGET_TT_SYSCALL (TT_TRAP + 0x10) /* t_linux */ -#define syscall_cc psr #else #define TARGET_TT_SYSCALL (TT_TRAP + 0x6d) /* tl0_linux64 */ -#define syscall_cc xcc #endif +static void set_syscall_cc(CPUSPARCState *env, bool val) +{ +#ifndef TARGET_SPARC64 + env->cc_icc_C = val; +#elif defined(TARGET_ABI32) + env->cc_icc_C = (uint64_t)val << 32; +#else + env->cc_xcc_C = val; +#endif +} + + /* Avoid ifdefs below for the v9 and pre-v9 hw traps. */ #ifdef TARGET_SPARC64 #define TARGET_TT_SPILL TT_SPILL @@ -240,10 +250,10 @@ void cpu_loop (CPUSPARCState *env) break; } if ((abi_ulong)ret >= (abi_ulong)(-515)) { - env->syscall_cc |= PSR_CARRY; + set_syscall_cc(env, 1); ret = -ret; } else { - env->syscall_cc &= ~PSR_CARRY; + set_syscall_cc(env, 0); } env->regwptr[0] = ret; /* next instruction */ diff --git a/target/sparc/cc_helper.c b/target/sparc/cc_helper.c index 7ad5b9b29e..fe4618ad34 100644 --- a/target/sparc/cc_helper.c +++ b/target/sparc/cc_helper.c @@ -21,16 +21,6 @@ #include "cpu.h" #include "exec/helper-proto.h" -static uint32_t compute_all_flags(CPUSPARCState *env) -{ - return env->psr & PSR_ICC; -} - -static uint32_t compute_C_flags(CPUSPARCState *env) -{ - return env->psr & PSR_CARRY; -} - static inline uint32_t get_NZ_icc(int32_t dst) { uint32_t ret = 0; @@ -44,16 +34,6 @@ static inline uint32_t get_NZ_icc(int32_t dst) } #ifdef TARGET_SPARC64 -static uint32_t compute_all_flags_xcc(CPUSPARCState *env) -{ - return env->xcc & PSR_ICC; -} - -static uint32_t compute_C_flags_xcc(CPUSPARCState *env) -{ - return env->xcc & PSR_CARRY; -} - static inline uint32_t get_NZ_xcc(target_long dst) { uint32_t ret = 0; @@ -422,7 +402,6 @@ typedef struct CCTable { static const CCTable icc_table[CC_OP_NB] = { /* CC_OP_DYNAMIC should never happen */ - [CC_OP_FLAGS] = { compute_all_flags, compute_C_flags }, [CC_OP_DIV] = { compute_all_div, compute_C_div }, [CC_OP_ADD] = { compute_all_add, compute_C_add }, [CC_OP_ADDX] = { compute_all_addx, compute_C_addx }, @@ -438,7 +417,6 @@ static const CCTable icc_table[CC_OP_NB] = { #ifdef TARGET_SPARC64 static const CCTable xcc_table[CC_OP_NB] = { /* CC_OP_DYNAMIC should never happen */ - [CC_OP_FLAGS] = { compute_all_flags_xcc, compute_C_flags_xcc }, [CC_OP_DIV] = { compute_all_logic_xcc, compute_C_logic }, [CC_OP_ADD] = { compute_all_add_xcc, compute_C_add_xcc }, [CC_OP_ADDX] = { compute_all_addx_xcc, compute_C_addx_xcc }, @@ -454,18 +432,37 @@ static const CCTable xcc_table[CC_OP_NB] = { void helper_compute_psr(CPUSPARCState *env) { - uint32_t new_psr; + if (CC_OP == CC_OP_FLAGS) { + return; + } - new_psr = icc_table[CC_OP].compute_all(env); - env->psr = new_psr; + uint32_t icc = icc_table[CC_OP].compute_all(env); #ifdef TARGET_SPARC64 - new_psr = xcc_table[CC_OP].compute_all(env); - env->xcc = new_psr; + uint32_t xcc = xcc_table[CC_OP].compute_all(env); + + env->cc_N = deposit64(-(icc & PSR_NEG), 32, 32, -(xcc & PSR_NEG)); + env->cc_V = deposit64(-(icc & PSR_OVF), 32, 32, -(xcc & PSR_OVF)); + env->cc_icc_C = (uint64_t)icc << (32 - PSR_CARRY_SHIFT); + env->cc_xcc_C = (xcc >> PSR_CARRY_SHIFT) & 1; + env->cc_xcc_Z = ~xcc & PSR_ZERO; +#else + env->cc_N = -(icc & PSR_NEG); + env->cc_V = -(icc & PSR_OVF); + env->cc_icc_C = (icc >> PSR_CARRY_SHIFT) & 1; #endif + env->cc_icc_Z = ~icc & PSR_ZERO; + CC_OP = CC_OP_FLAGS; } uint32_t helper_compute_C_icc(CPUSPARCState *env) { + if (CC_OP == CC_OP_FLAGS) { +#ifdef TARGET_SPARC64 + return extract64(env->cc_icc_C, 32, 1); +#else + return env->cc_icc_C; +#endif + } return icc_table[CC_OP].compute_c(env) >> PSR_CARRY_SHIFT; } diff --git a/target/sparc/machine.c b/target/sparc/machine.c index 274e1217df..72f6dc8220 100644 --- a/target/sparc/machine.c +++ b/target/sparc/machine.c @@ -83,6 +83,41 @@ static const VMStateInfo vmstate_psr = { .put = put_psr, }; +#ifdef TARGET_SPARC64 +static int get_xcc(QEMUFile *f, void *opaque, size_t size, + const VMStateField *field) +{ + SPARCCPU *cpu = opaque; + CPUSPARCState *env = &cpu->env; + uint32_t val = qemu_get_be32(f); + + env->cc_N = deposit64(env->cc_N, 32, 32, -(val & PSR_NEG)); + env->cc_V = deposit64(env->cc_V, 32, 32, -(val & PSR_OVF)); + env->cc_xcc_Z = ~val & PSR_ZERO; + env->cc_xcc_C = (val >> PSR_CARRY_SHIFT) & 1; + + return 0; +} + +static int put_xcc(QEMUFile *f, void *opaque, size_t size, + const VMStateField *field, JSONWriter *vmdesc) +{ + SPARCCPU *cpu = opaque; + CPUSPARCState *env = &cpu->env; + uint32_t val = cpu_get_ccr(env); + + /* Extract just xcc out of ccr and shift into legacy position. */ + qemu_put_be32(f, (val & 0xf0) << (20 - 4)); + return 0; +} + +static const VMStateInfo vmstate_xcc = { + .name = "xcc", + .get = get_xcc, + .put = put_xcc, +}; +#endif + static int cpu_pre_save(void *opaque) { SPARCCPU *cpu = opaque; @@ -155,7 +190,14 @@ const VMStateDescription vmstate_sparc_cpu = { VMSTATE_UINT32(env.mmu_version, SPARCCPU), VMSTATE_STRUCT_ARRAY(env.ts, SPARCCPU, MAXTL_MAX, 0, vmstate_trap_state, trap_state), - VMSTATE_UINT32(env.xcc, SPARCCPU), + { + .name = "xcc", + .version_id = 0, + .size = sizeof(uint32_t), + .info = &vmstate_xcc, + .flags = VMS_SINGLE, + .offset = 0, + }, VMSTATE_UINT32(env.asi, SPARCCPU), VMSTATE_UINT32(env.pstate, SPARCCPU), VMSTATE_UINT32(env.tl, SPARCCPU), diff --git a/target/sparc/translate.c b/target/sparc/translate.c index c458de2103..f2a2d69f91 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -118,20 +118,36 @@ static void gen_helper_array8(TCGv r, TCGv a, TCGv b) static TCGv_ptr cpu_regwptr; static TCGv cpu_cc_src, cpu_cc_src2, cpu_cc_dst; static TCGv_i32 cpu_cc_op; -static TCGv_i32 cpu_psr; static TCGv cpu_fsr, cpu_pc, cpu_npc; static TCGv cpu_regs[32]; static TCGv cpu_y; static TCGv cpu_tbr; static TCGv cpu_cond; +static TCGv cpu_cc_N; +static TCGv cpu_cc_V; +static TCGv cpu_icc_Z; +static TCGv cpu_icc_C; #ifdef TARGET_SPARC64 -static TCGv_i32 cpu_xcc, cpu_fprs; +static TCGv cpu_xcc_Z; +static TCGv cpu_xcc_C; +static TCGv_i32 cpu_fprs; static TCGv cpu_gsr; static TCGv cpu_tick_cmpr, cpu_stick_cmpr, cpu_hstick_cmpr; static TCGv cpu_hintp, cpu_htba, cpu_hver, cpu_ssr, cpu_ver; #else static TCGv cpu_wim; #endif + +#ifdef TARGET_SPARC64 +#define cpu_cc_Z cpu_xcc_Z +#define cpu_cc_C cpu_xcc_C +#else +#define cpu_cc_Z cpu_icc_Z +#define cpu_cc_C cpu_icc_C +#define cpu_xcc_Z ({ qemu_build_not_reached(); NULL; }) +#define cpu_xcc_C ({ qemu_build_not_reached(); NULL; }) +#endif + /* Floating point registers */ static TCGv_i64 cpu_fpr[TARGET_DPREGS]; @@ -364,31 +380,6 @@ static void gen_goto_tb(DisasContext *s, int tb_num, } } -// XXX suboptimal -static void gen_mov_reg_N(TCGv reg, TCGv_i32 src) -{ - tcg_gen_extu_i32_tl(reg, src); - tcg_gen_extract_tl(reg, reg, PSR_NEG_SHIFT, 1); -} - -static void gen_mov_reg_Z(TCGv reg, TCGv_i32 src) -{ - tcg_gen_extu_i32_tl(reg, src); - tcg_gen_extract_tl(reg, reg, PSR_ZERO_SHIFT, 1); -} - -static void gen_mov_reg_V(TCGv reg, TCGv_i32 src) -{ - tcg_gen_extu_i32_tl(reg, src); - tcg_gen_extract_tl(reg, reg, PSR_OVF_SHIFT, 1); -} - -static void gen_mov_reg_C(TCGv reg, TCGv_i32 src) -{ - tcg_gen_extu_i32_tl(reg, src); - tcg_gen_extract_tl(reg, reg, PSR_CARRY_SHIFT, 1); -} - static void gen_op_add_cc(TCGv dst, TCGv src1, TCGv src2) { tcg_gen_mov_tl(cpu_cc_src, src1); @@ -601,13 +592,11 @@ static void gen_op_mulscc(TCGv dst, TCGv src1, TCGv src2) tcg_gen_deposit_tl(cpu_y, t0, cpu_cc_src, 31, 1); // b1 = N ^ V; - gen_mov_reg_N(t0, cpu_psr); - gen_mov_reg_V(r_temp, cpu_psr); - tcg_gen_xor_tl(t0, t0, r_temp); + tcg_gen_xor_tl(t0, cpu_cc_N, cpu_cc_V); // T0 = (b1 << 31) | (T0 >> 1); // src1 = T0; - tcg_gen_shli_tl(t0, t0, 31); + tcg_gen_andi_tl(t0, t0, 1u << 31); tcg_gen_shri_tl(cpu_cc_src, cpu_cc_src, 1); tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, t0); @@ -779,114 +768,12 @@ static void gen_op_eval_ba(TCGv dst) tcg_gen_movi_tl(dst, 1); } -// Z -static void gen_op_eval_be(TCGv dst, TCGv_i32 src) -{ - gen_mov_reg_Z(dst, src); -} - -// Z | (N ^ V) -static void gen_op_eval_ble(TCGv dst, TCGv_i32 src) -{ - TCGv t0 = tcg_temp_new(); - gen_mov_reg_N(t0, src); - gen_mov_reg_V(dst, src); - tcg_gen_xor_tl(dst, dst, t0); - gen_mov_reg_Z(t0, src); - tcg_gen_or_tl(dst, dst, t0); -} - -// N ^ V -static void gen_op_eval_bl(TCGv dst, TCGv_i32 src) -{ - TCGv t0 = tcg_temp_new(); - gen_mov_reg_V(t0, src); - gen_mov_reg_N(dst, src); - tcg_gen_xor_tl(dst, dst, t0); -} - -// C | Z -static void gen_op_eval_bleu(TCGv dst, TCGv_i32 src) -{ - TCGv t0 = tcg_temp_new(); - gen_mov_reg_Z(t0, src); - gen_mov_reg_C(dst, src); - tcg_gen_or_tl(dst, dst, t0); -} - -// C -static void gen_op_eval_bcs(TCGv dst, TCGv_i32 src) -{ - gen_mov_reg_C(dst, src); -} - -// V -static void gen_op_eval_bvs(TCGv dst, TCGv_i32 src) -{ - gen_mov_reg_V(dst, src); -} - // 0 static void gen_op_eval_bn(TCGv dst) { tcg_gen_movi_tl(dst, 0); } -// N -static void gen_op_eval_bneg(TCGv dst, TCGv_i32 src) -{ - gen_mov_reg_N(dst, src); -} - -// !Z -static void gen_op_eval_bne(TCGv dst, TCGv_i32 src) -{ - gen_mov_reg_Z(dst, src); - tcg_gen_xori_tl(dst, dst, 0x1); -} - -// !(Z | (N ^ V)) -static void gen_op_eval_bg(TCGv dst, TCGv_i32 src) -{ - gen_op_eval_ble(dst, src); - tcg_gen_xori_tl(dst, dst, 0x1); -} - -// !(N ^ V) -static void gen_op_eval_bge(TCGv dst, TCGv_i32 src) -{ - gen_op_eval_bl(dst, src); - tcg_gen_xori_tl(dst, dst, 0x1); -} - -// !(C | Z) -static void gen_op_eval_bgu(TCGv dst, TCGv_i32 src) -{ - gen_op_eval_bleu(dst, src); - tcg_gen_xori_tl(dst, dst, 0x1); -} - -// !C -static void gen_op_eval_bcc(TCGv dst, TCGv_i32 src) -{ - gen_mov_reg_C(dst, src); - tcg_gen_xori_tl(dst, dst, 0x1); -} - -// !N -static void gen_op_eval_bpos(TCGv dst, TCGv_i32 src) -{ - gen_mov_reg_N(dst, src); - tcg_gen_xori_tl(dst, dst, 0x1); -} - -// !V -static void gen_op_eval_bvc(TCGv dst, TCGv_i32 src) -{ - gen_mov_reg_V(dst, src); - tcg_gen_xori_tl(dst, dst, 0x1); -} - /* FPSR bit field FCC1 | FCC0: 0 = @@ -1203,34 +1090,22 @@ static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond, TCG_COND_ALWAYS, /* vc: !V -> 1 */ }; - TCGv_i32 r_src; - TCGv r_dst; + TCGv t1, t2; -#ifdef TARGET_SPARC64 - if (xcc) { - r_src = cpu_xcc; - } else { - r_src = cpu_psr; - } -#else - r_src = cpu_psr; -#endif + cmp->is_bool = false; switch (dc->cc_op) { case CC_OP_LOGIC: cmp->cond = logic_cond[cond]; do_compare_dst_0: - cmp->is_bool = false; cmp->c2 = tcg_constant_tl(0); -#ifdef TARGET_SPARC64 - if (!xcc) { - cmp->c1 = tcg_temp_new(); - tcg_gen_ext32s_tl(cmp->c1, cpu_cc_dst); - break; + if (TARGET_LONG_BITS == 32 || xcc) { + cmp->c1 = cpu_cc_dst; + } else { + cmp->c1 = t1 = tcg_temp_new(); + tcg_gen_ext32s_tl(t1, cpu_cc_dst); } -#endif - cmp->c1 = cpu_cc_dst; - break; + return; case CC_OP_SUB: switch (cond) { @@ -1241,92 +1116,128 @@ static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond, case 7: /* overflow */ case 15: /* !overflow */ - goto do_dynamic; + break; default: cmp->cond = subcc_cond[cond]; - cmp->is_bool = false; -#ifdef TARGET_SPARC64 - if (!xcc) { + if (TARGET_LONG_BITS == 32 || xcc) { + cmp->c1 = cpu_cc_src; + cmp->c2 = cpu_cc_src2; + } else { /* Note that sign-extension works for unsigned compares as long as both operands are sign-extended. */ - cmp->c1 = tcg_temp_new(); - cmp->c2 = tcg_temp_new(); - tcg_gen_ext32s_tl(cmp->c1, cpu_cc_src); - tcg_gen_ext32s_tl(cmp->c2, cpu_cc_src2); - break; + cmp->c1 = t1 = tcg_temp_new(); + tcg_gen_ext32s_tl(t1, cpu_cc_src); + cmp->c2 = t2 = tcg_temp_new(); + tcg_gen_ext32s_tl(t2, cpu_cc_src2); } -#endif - cmp->c1 = cpu_cc_src; - cmp->c2 = cpu_cc_src2; - break; + return; } break; default: - do_dynamic: gen_helper_compute_psr(tcg_env); dc->cc_op = CC_OP_FLAGS; - /* FALLTHRU */ + break; case CC_OP_FLAGS: - /* We're going to generate a boolean result. */ - cmp->cond = TCG_COND_NE; - cmp->is_bool = true; - cmp->c1 = r_dst = tcg_temp_new(); - cmp->c2 = tcg_constant_tl(0); + break; + } - switch (cond) { - case 0x0: - gen_op_eval_bn(r_dst); - break; - case 0x1: - gen_op_eval_be(r_dst, r_src); - break; - case 0x2: - gen_op_eval_ble(r_dst, r_src); - break; - case 0x3: - gen_op_eval_bl(r_dst, r_src); - break; - case 0x4: - gen_op_eval_bleu(r_dst, r_src); - break; - case 0x5: - gen_op_eval_bcs(r_dst, r_src); - break; - case 0x6: - gen_op_eval_bneg(r_dst, r_src); - break; - case 0x7: - gen_op_eval_bvs(r_dst, r_src); - break; - case 0x8: - gen_op_eval_ba(r_dst); - break; - case 0x9: - gen_op_eval_bne(r_dst, r_src); - break; - case 0xa: - gen_op_eval_bg(r_dst, r_src); - break; - case 0xb: - gen_op_eval_bge(r_dst, r_src); - break; - case 0xc: - gen_op_eval_bgu(r_dst, r_src); - break; - case 0xd: - gen_op_eval_bcc(r_dst, r_src); - break; - case 0xe: - gen_op_eval_bpos(r_dst, r_src); - break; - case 0xf: - gen_op_eval_bvc(r_dst, r_src); - break; + cmp->c1 = NULL; + cmp->c2 = tcg_constant_tl(0); + + switch (cond & 7) { + case 0x0: /* never */ + cmp->cond = TCG_COND_NEVER; + cmp->c1 = cmp->c2; + break; + + case 0x1: /* eq */ + cmp->cond = TCG_COND_EQ; + if (TARGET_LONG_BITS == 32 || xcc) { + cmp->c1 = cpu_cc_Z; + } else { + cmp->c1 = t1 = tcg_temp_new(); + tcg_gen_ext32u_tl(t1, cpu_icc_Z); } break; + + case 0x2: /* le: Z | (N ^ V) */ + cmp->cond = TCG_COND_LT; + cmp->c1 = t1 = tcg_temp_new(); + if (TARGET_LONG_BITS == 32 || xcc) { + tcg_gen_negsetcond_tl(TCG_COND_EQ, t1, cpu_cc_Z, cmp->c2); + } else { + tcg_gen_ext32u_tl(t1, cpu_icc_Z); + tcg_gen_negsetcond_tl(TCG_COND_EQ, t1, t1, cmp->c2); + } + t2 = tcg_temp_new(); + tcg_gen_xor_tl(t2, cpu_cc_N, cpu_cc_V); + if (TARGET_LONG_BITS == 64 && !xcc) { + tcg_gen_ext32s_tl(t2, t2); + } + tcg_gen_or_tl(t1, t1, t2); + break; + + case 0x3: /* lt: N ^ V */ + cmp->cond = TCG_COND_LT; + cmp->c1 = t1 = tcg_temp_new(); + tcg_gen_xor_tl(t1, cpu_cc_N, cpu_cc_V); + if (TARGET_LONG_BITS == 64 && !xcc) { + tcg_gen_ext32s_tl(t1, t1); + } + break; + + case 0x4: /* leu: C | Z -> !(!C & !Z) */ + cmp->cond = TCG_COND_EQ; + cmp->c1 = t1 = tcg_temp_new(); + if (TARGET_LONG_BITS == 32 || xcc) { + tcg_gen_subi_tl(t1, cpu_cc_C, 1); + tcg_gen_and_tl(t1, t1, cpu_cc_Z); + } else { + tcg_gen_extract_tl(t1, cpu_icc_C, 32, 1); + tcg_gen_subi_tl(t1, t1, 1); + t2 = tcg_temp_new(); + tcg_gen_ext32u_tl(t2, cpu_icc_Z); + tcg_gen_and_tl(t1, t1, t2); + } + break; + + case 0x5: /* ltu: C */ + cmp->cond = TCG_COND_NE; + cmp->is_bool = true; + if (TARGET_LONG_BITS == 32 || xcc) { + cmp->c1 = cpu_cc_C; + } else { + cmp->c1 = t1 = tcg_temp_new(); + tcg_gen_extract_tl(t1, cpu_icc_C, 32, 1); + } + break; + + case 0x6: /* neg: N */ + cmp->cond = TCG_COND_LT; + if (TARGET_LONG_BITS == 32 || xcc) { + cmp->c1 = cpu_cc_N; + } else { + cmp->c1 = t1 = tcg_temp_new(); + tcg_gen_ext32s_tl(t1, cpu_cc_N); + } + break; + + case 0x7: /* vs: V */ + cmp->cond = TCG_COND_LT; + if (TARGET_LONG_BITS == 32 || xcc) { + cmp->c1 = cpu_cc_V; + } else { + cmp->c1 = t1 = tcg_temp_new(); + tcg_gen_ext32s_tl(t1, cpu_cc_V); + } + break; + } + if (cond & 8) { + cmp->cond = tcg_invert_cond(cmp->cond); + cmp->is_bool = false; } } @@ -5602,13 +5513,11 @@ void sparc_tcg_init(void) static const struct { TCGv_i32 *ptr; int off; const char *name; } r32[] = { #ifdef TARGET_SPARC64 - { &cpu_xcc, offsetof(CPUSPARCState, xcc), "xcc" }, { &cpu_fprs, offsetof(CPUSPARCState, fprs), "fprs" }, #else { &cpu_wim, offsetof(CPUSPARCState, wim), "wim" }, #endif { &cpu_cc_op, offsetof(CPUSPARCState, cc_op), "cc_op" }, - { &cpu_psr, offsetof(CPUSPARCState, psr), "psr" }, }; static const struct { TCGv *ptr; int off; const char *name; } rtl[] = { @@ -5623,7 +5532,13 @@ void sparc_tcg_init(void) { &cpu_hver, offsetof(CPUSPARCState, hver), "hver" }, { &cpu_ssr, offsetof(CPUSPARCState, ssr), "ssr" }, { &cpu_ver, offsetof(CPUSPARCState, version), "ver" }, + { &cpu_xcc_Z, offsetof(CPUSPARCState, cc_xcc_Z), "xcc_Z" }, + { &cpu_xcc_C, offsetof(CPUSPARCState, cc_xcc_C), "xcc_C" }, #endif + { &cpu_cc_N, offsetof(CPUSPARCState, cc_N), "cc_N" }, + { &cpu_cc_V, offsetof(CPUSPARCState, cc_V), "cc_V" }, + { &cpu_icc_Z, offsetof(CPUSPARCState, cc_icc_Z), "icc_Z" }, + { &cpu_icc_C, offsetof(CPUSPARCState, cc_icc_C), "icc_C" }, { &cpu_cond, offsetof(CPUSPARCState, cond), "cond" }, { &cpu_cc_src, offsetof(CPUSPARCState, cc_src), "cc_src" }, { &cpu_cc_src2, offsetof(CPUSPARCState, cc_src2), "cc_src2" }, diff --git a/target/sparc/win_helper.c b/target/sparc/win_helper.c index bf2c90c780..a446c1785d 100644 --- a/target/sparc/win_helper.c +++ b/target/sparc/win_helper.c @@ -53,23 +53,43 @@ void cpu_set_cwp(CPUSPARCState *env, int new_cwp) target_ulong cpu_get_psr(CPUSPARCState *env) { + target_ulong icc = 0; + helper_compute_psr(env); + icc |= ((int32_t)env->cc_N < 0) << PSR_NEG_SHIFT; + icc |= ((int32_t)env->cc_V < 0) << PSR_OVF_SHIFT; + icc |= ((int32_t)env->cc_icc_Z == 0) << PSR_ZERO_SHIFT; + if (TARGET_LONG_BITS == 64) { + icc |= extract64(env->cc_icc_C, 32, 1) << PSR_CARRY_SHIFT; + } else { + icc |= env->cc_icc_C << PSR_CARRY_SHIFT; + } + #if !defined(TARGET_SPARC64) - return env->version | (env->psr & PSR_ICC) | + return env->version | icc | (env->psref ? PSR_EF : 0) | (env->psrpil << 8) | (env->psrs ? PSR_S : 0) | (env->psrps ? PSR_PS : 0) | (env->psret ? PSR_ET : 0) | env->cwp; #else - return env->psr & PSR_ICC; + return icc; #endif } void cpu_put_psr_icc(CPUSPARCState *env, target_ulong val) { - env->psr = val & PSR_ICC; + if (TARGET_LONG_BITS == 64) { + env->cc_N = deposit64(env->cc_N, 0, 32, -(val & PSR_NEG)); + env->cc_V = deposit64(env->cc_V, 0, 32, -(val & PSR_OVF)); + env->cc_icc_C = -(val & PSR_CARRY); + } else { + env->cc_N = -(val & PSR_NEG); + env->cc_V = -(val & PSR_OVF); + env->cc_icc_C = (val >> PSR_CARRY_SHIFT) & 1; + } + env->cc_icc_Z = ~val & PSR_ZERO; } void cpu_put_psr_raw(CPUSPARCState *env, target_ulong val) @@ -249,17 +269,32 @@ void helper_restored(CPUSPARCState *env) target_ulong cpu_get_ccr(CPUSPARCState *env) { - target_ulong psr; + target_ulong ccr = 0; - psr = cpu_get_psr(env); + helper_compute_psr(env); - return ((env->xcc >> 20) << 4) | ((psr & PSR_ICC) >> 20); + ccr |= (env->cc_icc_C >> 32) & 1; + ccr |= ((int32_t)env->cc_V < 0) << 1; + ccr |= ((int32_t)env->cc_icc_Z == 0) << 2; + ccr |= ((int32_t)env->cc_N < 0) << 3; + + ccr |= env->cc_xcc_C << 4; + ccr |= (env->cc_V < 0) << 5; + ccr |= (env->cc_xcc_Z == 0) << 6; + ccr |= (env->cc_N < 0) << 7; + + return ccr; } void cpu_put_ccr(CPUSPARCState *env, target_ulong val) { - env->xcc = (val >> 4) << 20; - env->psr = (val & 0xf) << 20; + env->cc_N = deposit64(-(val & 0x08), 32, 32, -(val & 0x80)); + env->cc_V = deposit64(-(val & 0x02), 32, 32, -(val & 0x20)); + env->cc_icc_C = (uint64_t)val << 32; + env->cc_xcc_C = (val >> 4) & 1; + env->cc_icc_Z = ~val & 0x04; + env->cc_xcc_Z = ~val & 0x40; + CC_OP = CC_OP_FLAGS; } From patchwork Tue Oct 17 06:40:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734344 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp330470wro; Mon, 16 Oct 2023 23:41:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvisLgpoRMseYap/IaOark5PU8SqfojL65zeYiqTCfb/KCcssJl5ufhsbJm1ZHyyxZhoyZ X-Received: by 2002:a05:620a:c4e:b0:775:c2f3:dbf0 with SMTP id u14-20020a05620a0c4e00b00775c2f3dbf0mr1743154qki.33.1697524911726; Mon, 16 Oct 2023 23:41:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697524911; cv=none; d=google.com; s=arc-20160816; b=iyr2fn2h8Lk6QT8oEbonirXWSJ2Ev2No/JTgJirGs+KUiGKowPlKihztfujuRDqM5s SN6n9TwH955mb507DZnywShis+Qen15CgfFwdP+hU/EwENkpWS6Is9IikrnSgK0W9wfh k3QjU2s5LvgyxxIbWVqO9WDyGWhQ8CABVZZ+ohpgaZwQbKnNIv4mxZYXKv1ZFsfCbSPV 92RMG/Y3ZsEf6Yxxzm0zgcA/HksZhT2zBfc43R0DqCuXtUnRwU7/LdrDAjegkoBGRMWj x75lK4AY8b0qz7dKTGmbyOg7dsZ6/cu3smKrXiwLp6nQqWqzmGn51rWnH4r0W/u2BxWS EthA== 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=riTrpJJNJySZ4F/xCzfMwlO3A4jK43J/Vq77RdnNG0Q=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=YgIsBT2t5pH9EqnoUshUBNa92IJhvrQgB7DDH7wqaSe92dNOYWG0YKxh1CSkiPYZce xlSgBjkv6zGFjnyPR8oCVq93h017stuZB0O61aWGFAPI5VmrhyDcfWMw3haRIcBPWaC7 CIyVvuKQfmch/a1ZjHWspHhCfI9A1BTUezVRLf8B+psYxz1Tp2GDAUF9O0K3a9joKc0N zKUTvkWQ4GDYbRAbuF2ve7st0QcmWvPnBx7Qf/MT94R/dInv+gEZuvMx1PAaCOSdiIQv bHlAO+n6lvryG8Ds6SKSg1a2yL96pSkrbopCRB/MWshTV0OWqJSrMl/Nen5XIl1+T5WM zwhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZBQQCIhx; 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 a10-20020a05620a02ea00b007742f841ec5si598580qko.383.2023.10.16.23.41.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:41:51 -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=ZBQQCIhx; 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 1qsdlY-0007rb-RD; Tue, 17 Oct 2023 02:41:20 -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 1qsdlU-0007qf-R2 for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:17 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdlS-0001q3-RI for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:16 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1c894e4573bso34251695ad.0 for ; Mon, 16 Oct 2023 23:41:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524873; x=1698129673; 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=riTrpJJNJySZ4F/xCzfMwlO3A4jK43J/Vq77RdnNG0Q=; b=ZBQQCIhxtiu6+Yjz+B9MjvftoawPV/a81cNPXhTkbMZy87iPn/gqYYc5ZrqNR8WFJK xE31JoPCnq7PJLKZcUhaQ+WWhmBUn+4TqdEk+1zNMaA13BhhDylNGXf+/NgqoZOklkc/ slHe5VXAmfAjWt3c4hfUHV3Ser2iJoHIxyNOwnNryXcHEFJbhD8hoXn+S9j+sqGpziXK h8h6knktTKAfek7g4onWlQBc0LBk355HEEXiY1571H9PZqtf2aOxlsgg5RMgQWZ+2nMt 5hjeR6haGuD5VP2V7j6Ug6jR8ByZ/9lOAmxnWB+7uuE+VKbdcpX354hh8NWUTjMgsFFt bn8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524873; x=1698129673; 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=riTrpJJNJySZ4F/xCzfMwlO3A4jK43J/Vq77RdnNG0Q=; b=hX162AYRUVUM1oA6bm1Ydi38a0WRGL0R2nTKGkuvUevtsbIQ64ogf0zPuELAN5aD0B rFPaV91B8aR7/X4hook+dOS4SI4GiTUqF6zkqx9Yu0FVLPk9tAiTChMp/a3CpNqCe9bz +Zq8u/96m72BmrpaA6X1dWU6MRitA2YeNDF3NX9Fk2yM2QJKFgWxJk6P1qNBuIA93hlv zzFsLasa+hUUWgpfW0Emm6zeXSZSOnBihbOXlEkW2KDZgpc3aehQbn6jqbwX30ij6tZ7 CgsxHaYPv0j0HAYO4M1TbXx3G77eVSmIkeiMAvGymSEMg04v6fZnnnQvIxUk6UJZLTgi JXUQ== X-Gm-Message-State: AOJu0Ywo905xi3k6tP93Wk5kTMo5sgkHldyKwVE80YmOUgCGjxVmcZwR EQFBpq03OnceaY2MtAWzFW4XGYCP8ULqLQYZt+U= X-Received: by 2002:a17:903:80c:b0:1c3:5f05:922a with SMTP id kr12-20020a170903080c00b001c35f05922amr1323794plb.60.1697524872702; Mon, 16 Oct 2023 23:41:12 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 03/20] target/sparc: Remove CC_OP_DIV Date: Mon, 16 Oct 2023 23:40:52 -0700 Message-Id: <20231017064109.681935-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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 Return both result and overflow from helper_[us]div. Compute all flags explicitly in gen_op_[us]divcc. Marginally improve the INT64_MIN special case in do_sdiv. Signed-off-by: Richard Henderson --- target/sparc/cpu.h | 1 - target/sparc/helper.h | 4 +-- target/sparc/cc_helper.c | 26 -------------- target/sparc/helper.c | 75 ++++++++++++++++++++++++---------------- target/sparc/translate.c | 8 ++--- 5 files changed, 51 insertions(+), 63 deletions(-) diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index ac93658c33..df49d8423a 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -150,7 +150,6 @@ enum { enum { CC_OP_DYNAMIC, /* must use dynamic code to get cc_op */ CC_OP_FLAGS, /* all cc are back in cc_*_[NZCV] registers */ - CC_OP_DIV, /* modify N, Z and V, C = 0*/ CC_OP_ADD, /* modify all flags, CC_DST = res, CC_SRC = src1 */ CC_OP_ADDX, /* modify all flags, CC_DST = res, CC_SRC = src1 */ CC_OP_TADD, /* modify all flags, CC_DST = res, CC_SRC = src1 */ diff --git a/target/sparc/helper.h b/target/sparc/helper.h index dd1721a340..58d3c979d4 100644 --- a/target/sparc/helper.h +++ b/target/sparc/helper.h @@ -27,9 +27,9 @@ DEF_HELPER_FLAGS_2(tick_set_limit, TCG_CALL_NO_RWG, void, ptr, i64) DEF_HELPER_1(debug, void, env) DEF_HELPER_1(save, void, env) DEF_HELPER_1(restore, void, env) -DEF_HELPER_3(udiv, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(udiv, TCG_CALL_NO_WG, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(sdiv, TCG_CALL_NO_WG, tl, env, tl, tl) DEF_HELPER_3(udiv_cc, tl, env, tl, tl) -DEF_HELPER_3(sdiv, tl, env, tl, tl) DEF_HELPER_3(sdiv_cc, tl, env, tl, tl) DEF_HELPER_3(taddcctv, tl, env, tl, tl) DEF_HELPER_3(tsubcctv, tl, env, tl, tl) diff --git a/target/sparc/cc_helper.c b/target/sparc/cc_helper.c index fe4618ad34..a6d1a4b9ae 100644 --- a/target/sparc/cc_helper.c +++ b/target/sparc/cc_helper.c @@ -47,30 +47,6 @@ static inline uint32_t get_NZ_xcc(target_long dst) } #endif -static inline uint32_t get_V_div_icc(target_ulong src2) -{ - uint32_t ret = 0; - - if (src2 != 0) { - ret = PSR_OVF; - } - return ret; -} - -static uint32_t compute_all_div(CPUSPARCState *env) -{ - uint32_t ret; - - ret = get_NZ_icc(CC_DST); - ret |= get_V_div_icc(CC_SRC2); - return ret; -} - -static uint32_t compute_C_div(CPUSPARCState *env) -{ - return 0; -} - static inline uint32_t get_C_add_icc(uint32_t dst, uint32_t src1) { uint32_t ret = 0; @@ -402,7 +378,6 @@ typedef struct CCTable { static const CCTable icc_table[CC_OP_NB] = { /* CC_OP_DYNAMIC should never happen */ - [CC_OP_DIV] = { compute_all_div, compute_C_div }, [CC_OP_ADD] = { compute_all_add, compute_C_add }, [CC_OP_ADDX] = { compute_all_addx, compute_C_addx }, [CC_OP_TADD] = { compute_all_tadd, compute_C_add }, @@ -417,7 +392,6 @@ static const CCTable icc_table[CC_OP_NB] = { #ifdef TARGET_SPARC64 static const CCTable xcc_table[CC_OP_NB] = { /* CC_OP_DYNAMIC should never happen */ - [CC_OP_DIV] = { compute_all_logic_xcc, compute_C_logic }, [CC_OP_ADD] = { compute_all_add_xcc, compute_C_add_xcc }, [CC_OP_ADDX] = { compute_all_addx_xcc, compute_C_addx_xcc }, [CC_OP_TADD] = { compute_all_add_xcc, compute_C_add_xcc }, diff --git a/target/sparc/helper.c b/target/sparc/helper.c index c4358bba84..87a4258792 100644 --- a/target/sparc/helper.c +++ b/target/sparc/helper.c @@ -84,29 +84,32 @@ void helper_tick_set_limit(void *opaque, uint64_t limit) static target_ulong do_udiv(CPUSPARCState *env, target_ulong a, target_ulong b, int cc, uintptr_t ra) { - int overflow = 0; - uint64_t x0; - uint32_t x1; - - x0 = (a & 0xffffffff) | ((int64_t) (env->y) << 32); - x1 = (b & 0xffffffff); + target_ulong v, r; + uint64_t x0 = (uint32_t)a | ((uint64_t)env->y << 32); + uint32_t x1 = b; if (x1 == 0) { cpu_raise_exception_ra(env, TT_DIV_ZERO, ra); } x0 = x0 / x1; - if (x0 > UINT32_MAX) { - x0 = UINT32_MAX; - overflow = 1; + r = x0; + v = 0; + if (unlikely(x0 > UINT32_MAX)) { + v = r = UINT32_MAX; } if (cc) { - env->cc_dst = x0; - env->cc_src2 = overflow; - env->cc_op = CC_OP_DIV; + env->cc_N = r; + env->cc_V = v; + env->cc_icc_Z = r; + env->cc_icc_C = 0; +#ifdef TARGET_SPARC64 + env->cc_xcc_Z = r; + env->cc_xcc_C = 0; +#endif } - return x0; + return r; } target_ulong helper_udiv(CPUSPARCState *env, target_ulong a, target_ulong b) @@ -122,32 +125,46 @@ target_ulong helper_udiv_cc(CPUSPARCState *env, target_ulong a, target_ulong b) static target_ulong do_sdiv(CPUSPARCState *env, target_ulong a, target_ulong b, int cc, uintptr_t ra) { - int overflow = 0; - int64_t x0; - int32_t x1; - - x0 = (a & 0xffffffff) | ((int64_t) (env->y) << 32); - x1 = (b & 0xffffffff); + target_ulong v; + target_long r; + int64_t x0 = (uint32_t)a | ((uint64_t)env->y << 32); + int32_t x1 = b; if (x1 == 0) { cpu_raise_exception_ra(env, TT_DIV_ZERO, ra); - } else if (x1 == -1 && x0 == INT64_MIN) { - x0 = INT32_MAX; - overflow = 1; + } + if (unlikely(x0 == INT64_MIN)) { + /* + * Special case INT64_MIN / -1 is required to avoid trap on x86 host. + * However, with a dividend of INT64_MIN, there is no 32-bit divisor + * which can yield a 32-bit result: + * INT64_MIN / INT32_MIN = 0x1_0000_0000 + * INT64_MIN / INT32_MAX = -0x1_0000_0002 + * Therefore we know we must overflow and saturate. + */ + r = x1 < 0 ? INT32_MAX : INT32_MIN; + v = UINT32_MAX; } else { x0 = x0 / x1; - if ((int32_t) x0 != x0) { - x0 = x0 < 0 ? INT32_MIN : INT32_MAX; - overflow = 1; + r = (int32_t)x0; + v = 0; + if (unlikely(r != x0)) { + r = x0 < 0 ? INT32_MIN : INT32_MAX; + v = UINT32_MAX; } } if (cc) { - env->cc_dst = x0; - env->cc_src2 = overflow; - env->cc_op = CC_OP_DIV; + env->cc_N = r; + env->cc_V = v; + env->cc_icc_Z = r; + env->cc_icc_C = 0; +#ifdef TARGET_SPARC64 + env->cc_xcc_Z = r; + env->cc_xcc_C = 0; +#endif } - return x0; + return r; } target_ulong helper_sdiv(CPUSPARCState *env, target_ulong a, target_ulong b) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index f2a2d69f91..2ca20ba110 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -437,7 +437,6 @@ static void gen_op_addx_int(DisasContext *dc, TCGv dst, TCGv src1, TCGv carry; switch (dc->cc_op) { - case CC_OP_DIV: case CC_OP_LOGIC: /* Carry is known to be zero. Fall back to plain ADD. */ if (update_cc) { @@ -510,7 +509,6 @@ static void gen_op_subx_int(DisasContext *dc, TCGv dst, TCGv src1, TCGv carry; switch (dc->cc_op) { - case CC_OP_DIV: case CC_OP_LOGIC: /* Carry is known to be zero. Fall back to plain SUB. */ if (update_cc) { @@ -3759,7 +3757,7 @@ static bool do_flags_arith(DisasContext *dc, arg_r_r_ri *a, int cc_op, void (*func)(TCGv, TCGv, TCGv)) { if (do_arith(dc, a, func, NULL)) { - /* Assume FUNC has set env->cc_op and all cc_foo variables. */ + tcg_gen_movi_i32(cpu_cc_op, cc_op); dc->cc_op = cc_op; return true; } @@ -3816,8 +3814,8 @@ TRANS(ORNcc, ALL, do_cc_arith, a, CC_OP_LOGIC, tcg_gen_orc_tl, NULL) TRANS(XORNcc, ALL, do_cc_arith, a, CC_OP_LOGIC, tcg_gen_eqv_tl, NULL) TRANS(UMULcc, MUL, do_cc_arith, a, CC_OP_LOGIC, gen_op_umul, NULL) TRANS(SMULcc, MUL, do_cc_arith, a, CC_OP_LOGIC, gen_op_smul, NULL) -TRANS(UDIVcc, DIV, do_flags_arith, a, CC_OP_DIV, gen_op_udivcc) -TRANS(SDIVcc, DIV, do_flags_arith, a, CC_OP_DIV, gen_op_sdivcc) +TRANS(UDIVcc, DIV, do_flags_arith, a, CC_OP_FLAGS, gen_op_udivcc) +TRANS(SDIVcc, DIV, do_flags_arith, a, CC_OP_FLAGS, gen_op_sdivcc) TRANS(TADDcc, ALL, do_cc_arith, a, CC_OP_TADD, gen_op_add_cc, NULL) TRANS(TSUBcc, ALL, do_cc_arith, a, CC_OP_TSUB, gen_op_sub_cc, NULL) TRANS(TADDccTV, ALL, do_flags_arith, a, CC_OP_TADDTV, gen_op_taddcctv) From patchwork Tue Oct 17 06:40:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734347 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp330663wro; Mon, 16 Oct 2023 23:42:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFEtzLqEafFwG2W52BkBNZOcu1u2u18Yf6OLjevo/LNnXVMNsZT7lF5Z2/YBKrcMyBdOM9t X-Received: by 2002:a05:6214:300a:b0:66d:3021:23a8 with SMTP id ke10-20020a056214300a00b0066d302123a8mr1682322qvb.32.1697524945850; Mon, 16 Oct 2023 23:42:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697524945; cv=none; d=google.com; s=arc-20160816; b=QqfXGtxE5OjtaSFhjfXBWp+XiueQtmwawZzXkRtuOJNLt0kGAX2OK38JtCI+Y+0wGb 0NGeT54+zpuDEAoShdVcomae5kBFNBrALZk/6Y3Nq50JEINI7AGnvjbhAxjnemQSV171 MGl9TiBbX394lGb04a0whRZ2ZGZQ23RbrkLoLumv9793t0uNBthGpD/8m4TlaJiP0wB9 ZsqROTKGOfPxepFV6h1d/Iepw7S3kSzlFNcyYYCTSe1r5dVd1+PBazUZJBnIOxzjO3Vw boPG2WDWu9AjsWUeFhcREhX9d6Fha19ZbdPBGoRNIDDeMirFGuDICBqpq1PB6PeOurZL ocCA== 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=yfEgZHzJR6F/R4oI34yVNGiG2eavTL8cA83U55eNzd0=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=d02JW0ooo11usGDfpZ6WWKesahLeo2fSft6FfLFBeh7vcMo0GJsmlrItQ94Joj40bC izyjULyIsNfL5bq6mAA0Kogj8NCfXJQL9nLjbXw4EoMRTwT8MNk4d8pVf8VCZTM/59aX 8UxcLSipmCs/StuVmGqXnmPDEgVlF/UaaoWce6MwTJd/s0ng8xdqp1wzY3vdfXHPod99 gT3x3AFYpZxDaAGc993cchFBPFNb5EPVSBRcyXC6e3+3HYzpgwqrIe0BlcEWiAhc+C01 sOXJWxAmXzJWZFmsrdpDapyzOe4VHUfnCrh3tPyFdf5kzRi07QDwi0aG5rlsXnqd3Nkf EeCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NLuiPWnq; 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 di4-20020ad458e4000000b0066cfafee84fsi551666qvb.507.2023.10.16.23.42.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:42:25 -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=NLuiPWnq; 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 1qsdlZ-0007rc-10; Tue, 17 Oct 2023 02:41:21 -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 1qsdlW-0007qw-29 for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:18 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdlS-0001qD-Ru for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:16 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1ca72f8ff3aso11751105ad.0 for ; Mon, 16 Oct 2023 23:41:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524873; x=1698129673; 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=yfEgZHzJR6F/R4oI34yVNGiG2eavTL8cA83U55eNzd0=; b=NLuiPWnqlfPveViZTOyn9DDzAh3o5fHxzQIanZBn9YgsjOXim8/wEwPZbqsCLhzyZe KO2Hiu6dUKh8HbcfS3n9AAprJOXEnC7o83VRIfgIPqIXoZInhA/7yf0qbtOnurrqs8H4 O0e//d7jN2l705SjmoBhcB5ekkJzhPuWYztBb7zlOG7qFCye/57zTBCi5uIiHRO8FNNb NrkvL6VTCXrS4BlDaDGcG6O7jCCDD5QQ/M9gZwnl6t2+gmTg/FBmU3yel8M9Hxp+d1h4 IzKvE7B0Ku7c3nsC01elXZNXVRkRHOm3mjopPxGAjB1tQJX6pB5TwEHKpgfbPmM/jIo6 EH2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524873; x=1698129673; 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=yfEgZHzJR6F/R4oI34yVNGiG2eavTL8cA83U55eNzd0=; b=PRHGIM9YdRGzD1nymSOIpRZ86I/zIp3cxlBLwL2j70cx5XIT0cGxzXte8DaVD+X8y7 /wPY8J8dZMLi23AKGs6QqB6HW6hV47eYLzb6NxeSN/Aej0xPPygLvrxzCGPBbLu5+0EM Qmph8uxN880WOF6gDj2R6dIRBxRB8XpHlCxXJz88JxdiGNZPdJFmKvcdg/CV9b9sKnGr BPDVMz0sVuU+dTt6xwp3FNLJTosBQYkaZlDZz28Yr47fZvehqZRo3fcF+TZ94DcOHV5r fHZKsdJPt56pQ1/gSDAtMMtrIpFQTqGjiTZobbJhU8FpLiADjvc8LLPZ+J71+DP/TM7Q rXFg== X-Gm-Message-State: AOJu0YyszXGhbGMb0uzaoaFxiCu6I/ABaY++q2ioo1OADpp7VKTz0csU XtrF0Sup9F1bEpVQocZgWLa9NtUdp0ZUQ11GvKY= X-Received: by 2002:a17:903:2309:b0:1c9:e508:ad43 with SMTP id d9-20020a170903230900b001c9e508ad43mr1587210plh.8.1697524873510; Mon, 16 Oct 2023 23:41:13 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 04/20] target/sparc: Remove CC_OP_LOGIC Date: Mon, 16 Oct 2023 23:40:53 -0700 Message-Id: <20231017064109.681935-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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/cpu.h | 1 - target/sparc/cc_helper.c | 19 -------- target/sparc/translate.c | 97 +++++++++++++++++----------------------- 3 files changed, 40 insertions(+), 77 deletions(-) diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index df49d8423a..48e549f7cb 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -158,7 +158,6 @@ enum { CC_OP_SUBX, /* modify all flags, CC_DST = res, CC_SRC = src1 */ CC_OP_TSUB, /* modify all flags, CC_DST = res, CC_SRC = src1 */ CC_OP_TSUBTV, /* modify all flags except V, CC_DST = res, CC_SRC = src1 */ - CC_OP_LOGIC, /* modify N and Z, C = V = 0, CC_DST = res */ CC_OP_NB, }; diff --git a/target/sparc/cc_helper.c b/target/sparc/cc_helper.c index a6d1a4b9ae..a88399d74a 100644 --- a/target/sparc/cc_helper.c +++ b/target/sparc/cc_helper.c @@ -354,23 +354,6 @@ static uint32_t compute_all_tsubtv(CPUSPARCState *env) return ret; } -static uint32_t compute_all_logic(CPUSPARCState *env) -{ - return get_NZ_icc(CC_DST); -} - -static uint32_t compute_C_logic(CPUSPARCState *env) -{ - return 0; -} - -#ifdef TARGET_SPARC64 -static uint32_t compute_all_logic_xcc(CPUSPARCState *env) -{ - return get_NZ_xcc(CC_DST); -} -#endif - typedef struct CCTable { uint32_t (*compute_all)(CPUSPARCState *env); /* return all the flags */ uint32_t (*compute_c)(CPUSPARCState *env); /* return the C flag */ @@ -386,7 +369,6 @@ static const CCTable icc_table[CC_OP_NB] = { [CC_OP_SUBX] = { compute_all_subx, compute_C_subx }, [CC_OP_TSUB] = { compute_all_tsub, compute_C_sub }, [CC_OP_TSUBTV] = { compute_all_tsubtv, compute_C_sub }, - [CC_OP_LOGIC] = { compute_all_logic, compute_C_logic }, }; #ifdef TARGET_SPARC64 @@ -400,7 +382,6 @@ static const CCTable xcc_table[CC_OP_NB] = { [CC_OP_SUBX] = { compute_all_subx_xcc, compute_C_subx_xcc }, [CC_OP_TSUB] = { compute_all_sub_xcc, compute_C_sub_xcc }, [CC_OP_TSUBTV] = { compute_all_sub_xcc, compute_C_sub_xcc }, - [CC_OP_LOGIC] = { compute_all_logic_xcc, compute_C_logic }, }; #endif diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 2ca20ba110..989275b17d 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -437,15 +437,6 @@ static void gen_op_addx_int(DisasContext *dc, TCGv dst, TCGv src1, TCGv carry; switch (dc->cc_op) { - case CC_OP_LOGIC: - /* Carry is known to be zero. Fall back to plain ADD. */ - if (update_cc) { - gen_op_add_cc(dst, src1, src2); - } else { - tcg_gen_add_tl(dst, src1, src2); - } - return; - case CC_OP_ADD: case CC_OP_TADD: case CC_OP_TADDTV: @@ -509,15 +500,6 @@ static void gen_op_subx_int(DisasContext *dc, TCGv dst, TCGv src1, TCGv carry; switch (dc->cc_op) { - case CC_OP_LOGIC: - /* Carry is known to be zero. Fall back to plain SUB. */ - if (update_cc) { - gen_op_sub_cc(dst, src1, src2); - } else { - tcg_gen_sub_tl(dst, src1, src2); - } - return; - case CC_OP_ADD: case CC_OP_TADD: case CC_OP_TADDTV: @@ -1069,48 +1051,25 @@ static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond, -1, /* no overflow */ }; - static int logic_cond[16] = { - TCG_COND_NEVER, - TCG_COND_EQ, /* eq: Z */ - TCG_COND_LE, /* le: Z | (N ^ V) -> Z | N */ - TCG_COND_LT, /* lt: N ^ V -> N */ - TCG_COND_EQ, /* leu: C | Z -> Z */ - TCG_COND_NEVER, /* ltu: C -> 0 */ - TCG_COND_LT, /* neg: N */ - TCG_COND_NEVER, /* vs: V -> 0 */ - TCG_COND_ALWAYS, - TCG_COND_NE, /* ne: !Z */ - TCG_COND_GT, /* gt: !(Z | (N ^ V)) -> !(Z | N) */ - TCG_COND_GE, /* ge: !(N ^ V) -> !N */ - TCG_COND_NE, /* gtu: !(C | Z) -> !Z */ - TCG_COND_ALWAYS, /* geu: !C -> 1 */ - TCG_COND_GE, /* pos: !N */ - TCG_COND_ALWAYS, /* vc: !V -> 1 */ - }; - TCGv t1, t2; cmp->is_bool = false; switch (dc->cc_op) { - case CC_OP_LOGIC: - cmp->cond = logic_cond[cond]; - do_compare_dst_0: - cmp->c2 = tcg_constant_tl(0); - if (TARGET_LONG_BITS == 32 || xcc) { - cmp->c1 = cpu_cc_dst; - } else { - cmp->c1 = t1 = tcg_temp_new(); - tcg_gen_ext32s_tl(t1, cpu_cc_dst); - } - return; case CC_OP_SUB: switch (cond) { case 6: /* neg */ case 14: /* pos */ cmp->cond = (cond == 6 ? TCG_COND_LT : TCG_COND_GE); - goto do_compare_dst_0; + cmp->c2 = tcg_constant_tl(0); + if (TARGET_LONG_BITS == 32 || xcc) { + cmp->c1 = cpu_cc_dst; + } else { + cmp->c1 = t1 = tcg_temp_new(); + tcg_gen_ext32s_tl(t1, cpu_cc_dst); + } + return; case 7: /* overflow */ case 15: /* !overflow */ @@ -3726,6 +3685,8 @@ static bool do_cc_arith(DisasContext *dc, arg_r_r_ri *a, int cc_op, if (cc_op < 0) { dst = gen_dest_gpr(dc, a->rd); + } else if (cc_op == CC_OP_FLAGS) { + dst = cpu_cc_N; } else { dst = cpu_cc_dst; tcg_gen_movi_i32(cpu_cc_op, cc_op); @@ -3742,6 +3703,21 @@ static bool do_cc_arith(DisasContext *dc, arg_r_r_ri *a, int cc_op, } else { func(dst, src1, cpu_regs[a->rs2_or_imm]); } + + /* Logic insn; to be cleaned up later. */ + if (cc_op == CC_OP_FLAGS) { + tcg_gen_movi_tl(cpu_cc_V, 0); + tcg_gen_movi_tl(cpu_icc_C, 0); +#ifdef TARGET_SPARC64 + tcg_gen_movi_tl(cpu_xcc_C, 0); + tcg_gen_mov_tl(cpu_xcc_Z, dst); +#endif + tcg_gen_mov_tl(cpu_icc_Z, dst); + + tcg_gen_movi_i32(cpu_cc_op, CC_OP_FLAGS); + dc->cc_op = CC_OP_FLAGS; + } + gen_store_gpr(dc, a->rd, dst); return advance_pc(dc); } @@ -3764,6 +3740,13 @@ static bool do_flags_arith(DisasContext *dc, arg_r_r_ri *a, int cc_op, return false; } +static bool do_logic_cc(DisasContext *dc, arg_r_r_ri *a, + void (*func)(TCGv, TCGv, TCGv), + void (*funci)(TCGv, TCGv, target_long)) +{ + return do_cc_arith(dc, a, CC_OP_FLAGS, func, funci); +} + static bool trans_OR(DisasContext *dc, arg_r_r_ri *a) { /* For simplicity, we under-decoded the rs2 form. */ @@ -3805,15 +3788,15 @@ TRANS(SDIV, DIV, do_arith, a, gen_op_sdiv, NULL) TRANS(POPC, 64, do_arith, a, gen_op_popc, NULL) TRANS(ADDcc, ALL, do_cc_arith, a, CC_OP_ADD, gen_op_add_cc, NULL) -TRANS(ANDcc, ALL, do_cc_arith, a, CC_OP_LOGIC, tcg_gen_and_tl, tcg_gen_andi_tl) -TRANS(ORcc, ALL, do_cc_arith, a, CC_OP_LOGIC, tcg_gen_or_tl, tcg_gen_ori_tl) -TRANS(XORcc, ALL, do_cc_arith, a, CC_OP_LOGIC, tcg_gen_xor_tl, tcg_gen_xori_tl) +TRANS(ANDcc, ALL, do_logic_cc, a, tcg_gen_and_tl, tcg_gen_andi_tl) +TRANS(ORcc, ALL, do_logic_cc, a, tcg_gen_or_tl, tcg_gen_ori_tl) +TRANS(XORcc, ALL, do_logic_cc, a, tcg_gen_xor_tl, tcg_gen_xori_tl) TRANS(SUBcc, ALL, do_cc_arith, a, CC_OP_SUB, gen_op_sub_cc, NULL) -TRANS(ANDNcc, ALL, do_cc_arith, a, CC_OP_LOGIC, tcg_gen_andc_tl, NULL) -TRANS(ORNcc, ALL, do_cc_arith, a, CC_OP_LOGIC, tcg_gen_orc_tl, NULL) -TRANS(XORNcc, ALL, do_cc_arith, a, CC_OP_LOGIC, tcg_gen_eqv_tl, NULL) -TRANS(UMULcc, MUL, do_cc_arith, a, CC_OP_LOGIC, gen_op_umul, NULL) -TRANS(SMULcc, MUL, do_cc_arith, a, CC_OP_LOGIC, gen_op_smul, NULL) +TRANS(ANDNcc, ALL, do_logic_cc, a, tcg_gen_andc_tl, NULL) +TRANS(ORNcc, ALL, do_logic_cc, a, tcg_gen_orc_tl, NULL) +TRANS(XORNcc, ALL, do_logic_cc, a, tcg_gen_eqv_tl, NULL) +TRANS(UMULcc, MUL, do_logic_cc, a, gen_op_umul, NULL) +TRANS(SMULcc, MUL, do_logic_cc, a, gen_op_smul, NULL) TRANS(UDIVcc, DIV, do_flags_arith, a, CC_OP_FLAGS, gen_op_udivcc) TRANS(SDIVcc, DIV, do_flags_arith, a, CC_OP_FLAGS, gen_op_sdivcc) TRANS(TADDcc, ALL, do_cc_arith, a, CC_OP_TADD, gen_op_add_cc, NULL) From patchwork Tue Oct 17 06:40:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734355 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp331350wro; Mon, 16 Oct 2023 23:44:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqr9Lyu/+KcKs4IMA4nC6sJtvmwhcydz/XHASO2HDJNniu5A3RMQeUNRk0HXKauZFmgmR8 X-Received: by 2002:a67:e050:0:b0:457:6cf4:6fa2 with SMTP id n16-20020a67e050000000b004576cf46fa2mr1381514vsl.4.1697525083189; Mon, 16 Oct 2023 23:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697525083; cv=none; d=google.com; s=arc-20160816; b=OZvVP79N8FBHw6zw/7mblPD+qKFdP/g00Sh4kqZtnjxXhr5zjlq138n3CUvYBTFwmb Zoz0+OyB2sEWae18YtB3dybPqs+Wb0akU1oQh2ivTG2KpLjcJIGMzcRhVEXW/0PgPmN9 uRtjqh4du2l13FST0qyETCCuPom/upgYum3GdNHWtGI5WmiyXt94sqgN4rLRxQ9Nv9CL KvyZHHRU32YmdjwWWHTfHS9Ncg1K7IFBZBqEWScuvFpeD4McqLVaN5ILMesKxV/RePPN Nmpvpi3X221hCJpmOgV6m74WgLCUWT+IunR7eZWaPpYOJ358ihLcGi8ESq210cMY9peR 3bfw== 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=WB3jX7hDpS1YvwpXfJb6MXptcFpyUOv6GNIkU/8LrOg=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=ENx1Tr5uYH9CgziDoDZd1haBjLo8dm9rENlJv2kAHf8JgF3Iy7uRWZ3+erb8M7Sc57 1Icxjf7X80coYOjE2HmnNHdM8wqAWqIYxmDmqDLLJ6H9WSI1xHDLmZCusLyN1I1NIovf bXg+VGGZN4aSwbJ5n6G7yWPpWNz+s9z6wTfSR0SwOgvZI6AAcfGOkcmlOzGnS867UbCp hrq7q/wl1PAHfa3CCunHWsoNDVWOb7haXYObbmgxkfQn3TCWNzCW0Jl5+R3Z+Nd9l0q2 uERB3Yt6xgQ2H1vvsWqia6ope2a3KsrGdt+rQG4MJRXnJNPqGfvchr6eP6MtRcTZimmd Mnzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PKYbhE2v; 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 k16-20020a0cd690000000b0066d03b3e2a5si547930qvi.599.2023.10.16.23.44.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:44:43 -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=PKYbhE2v; 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 1qsdlo-0007vf-Bp; Tue, 17 Oct 2023 02:41:37 -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 1qsdlW-0007r7-8N for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:18 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdlT-0001qO-SE for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:17 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1c9d7a98abbso35091695ad.1 for ; Mon, 16 Oct 2023 23:41:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524874; x=1698129674; 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=WB3jX7hDpS1YvwpXfJb6MXptcFpyUOv6GNIkU/8LrOg=; b=PKYbhE2vY9DTA/LbQIub89QMJQNELhRRZHkN0nCwurimHirLNTagX1CZmjA2e7REPp mUs6/2MwC2+5u/hDs41qQGOepSqVwIyAlspjSsID+cB6dqj67c57dSv1l72OaGPIYnhw VseBDVx5bvmHXiE0I1qt+suz2wNh+qZUeL8b07Mk3w11xZhfuVobrURits78HTDJKE0G IrPI8mKp/PyAWslqjMjIszV9J1WOJtNnHN1Q2WHJwuC7J05ChuHM9vyF/5uH5GQazGa2 4ggIAbeirrTbxIIO4Xs4++ZlQBglmmUhhwDDRyRQB2bJ8gpPnmZ7DsgjOP5od/D1JZVu mQFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524874; x=1698129674; 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=WB3jX7hDpS1YvwpXfJb6MXptcFpyUOv6GNIkU/8LrOg=; b=PaWsgCdveth4nlWhrlebW2KWGDH6mokj6rAJKgptdSc88fukjJz9/y2utMeN9Or/Vj r569QusNdAiWrnIroVG9A5tfHDn4tPpR3iVnMeDAonHeRgSZ6gid7vR035ESPmYt+ghK BKlzG6DFre8GIZ56rhmXnUZxcRr/Rj0GAiXGR1gZHY9g6HI8kCHLfbJ7+t/gouO28X8X 0VvRfEvCAwwg0y0KReB0IbQrxUaAKXIKwRROKYqkqYQIr9GTPmkc+SgfvmaoOVU83S1p TbegOofNHzKBCkElP7z0jfFLtg6DI8qtJughESrgv4sM7BBRpcbYE9Pk+eC21lYJ5aF5 +GEw== X-Gm-Message-State: AOJu0Yw9TnTbpzB2pTJNiSnn53dsp+RIp++M+lnxtE8XmjumyMb7EEZe zfHmvpvjTfFKi95QDQdSddXXBXlA49IAE/X1Fhw= X-Received: by 2002:a17:903:23ca:b0:1c9:d667:4e4a with SMTP id o10-20020a17090323ca00b001c9d6674e4amr1333891plh.69.1697524874332; Mon, 16 Oct 2023 23:41:14 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 05/20] target/sparc: Remove CC_OP_ADD, CC_OP_ADDX, CC_OP_TADD Date: Mon, 16 Oct 2023 23:40:54 -0700 Message-Id: <20231017064109.681935-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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 These are all related and implementable with common code. Signed-off-by: Richard Henderson --- target/sparc/cpu.h | 3 - target/sparc/cc_helper.c | 59 ------------ target/sparc/translate.c | 199 +++++++++++++++++++-------------------- 3 files changed, 95 insertions(+), 166 deletions(-) diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index 48e549f7cb..4925b35859 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -150,9 +150,6 @@ enum { enum { CC_OP_DYNAMIC, /* must use dynamic code to get cc_op */ CC_OP_FLAGS, /* all cc are back in cc_*_[NZCV] registers */ - CC_OP_ADD, /* modify all flags, CC_DST = res, CC_SRC = src1 */ - CC_OP_ADDX, /* modify all flags, CC_DST = res, CC_SRC = src1 */ - CC_OP_TADD, /* modify all flags, CC_DST = res, CC_SRC = src1 */ CC_OP_TADDTV, /* modify all flags except V, CC_DST = res, CC_SRC = src1 */ CC_OP_SUB, /* modify all flags, CC_DST = res, CC_SRC = src1 */ CC_OP_SUBX, /* modify all flags, CC_DST = res, CC_SRC = src1 */ diff --git a/target/sparc/cc_helper.c b/target/sparc/cc_helper.c index a88399d74a..c004a9b1d8 100644 --- a/target/sparc/cc_helper.c +++ b/target/sparc/cc_helper.c @@ -128,53 +128,11 @@ static uint32_t compute_C_add_xcc(CPUSPARCState *env) } #endif -static uint32_t compute_all_add(CPUSPARCState *env) -{ - uint32_t ret; - - ret = get_NZ_icc(CC_DST); - ret |= get_C_add_icc(CC_DST, CC_SRC); - ret |= get_V_add_icc(CC_DST, CC_SRC, CC_SRC2); - return ret; -} - static uint32_t compute_C_add(CPUSPARCState *env) { return get_C_add_icc(CC_DST, CC_SRC); } -#ifdef TARGET_SPARC64 -static uint32_t compute_all_addx_xcc(CPUSPARCState *env) -{ - uint32_t ret; - - ret = get_NZ_xcc(CC_DST); - ret |= get_C_addx_xcc(CC_DST, CC_SRC, CC_SRC2); - ret |= get_V_add_xcc(CC_DST, CC_SRC, CC_SRC2); - return ret; -} - -static uint32_t compute_C_addx_xcc(CPUSPARCState *env) -{ - return get_C_addx_xcc(CC_DST, CC_SRC, CC_SRC2); -} -#endif - -static uint32_t compute_all_addx(CPUSPARCState *env) -{ - uint32_t ret; - - ret = get_NZ_icc(CC_DST); - ret |= get_C_addx_icc(CC_DST, CC_SRC, CC_SRC2); - ret |= get_V_add_icc(CC_DST, CC_SRC, CC_SRC2); - return ret; -} - -static uint32_t compute_C_addx(CPUSPARCState *env) -{ - return get_C_addx_icc(CC_DST, CC_SRC, CC_SRC2); -} - static inline uint32_t get_V_tag_icc(target_ulong src1, target_ulong src2) { uint32_t ret = 0; @@ -185,17 +143,6 @@ static inline uint32_t get_V_tag_icc(target_ulong src1, target_ulong src2) return ret; } -static uint32_t compute_all_tadd(CPUSPARCState *env) -{ - uint32_t ret; - - ret = get_NZ_icc(CC_DST); - ret |= get_C_add_icc(CC_DST, CC_SRC); - ret |= get_V_add_icc(CC_DST, CC_SRC, CC_SRC2); - ret |= get_V_tag_icc(CC_SRC, CC_SRC2); - return ret; -} - static uint32_t compute_all_taddtv(CPUSPARCState *env) { uint32_t ret; @@ -361,9 +308,6 @@ typedef struct CCTable { static const CCTable icc_table[CC_OP_NB] = { /* CC_OP_DYNAMIC should never happen */ - [CC_OP_ADD] = { compute_all_add, compute_C_add }, - [CC_OP_ADDX] = { compute_all_addx, compute_C_addx }, - [CC_OP_TADD] = { compute_all_tadd, compute_C_add }, [CC_OP_TADDTV] = { compute_all_taddtv, compute_C_add }, [CC_OP_SUB] = { compute_all_sub, compute_C_sub }, [CC_OP_SUBX] = { compute_all_subx, compute_C_subx }, @@ -374,9 +318,6 @@ static const CCTable icc_table[CC_OP_NB] = { #ifdef TARGET_SPARC64 static const CCTable xcc_table[CC_OP_NB] = { /* CC_OP_DYNAMIC should never happen */ - [CC_OP_ADD] = { compute_all_add_xcc, compute_C_add_xcc }, - [CC_OP_ADDX] = { compute_all_addx_xcc, compute_C_addx_xcc }, - [CC_OP_TADD] = { compute_all_add_xcc, compute_C_add_xcc }, [CC_OP_TADDTV] = { compute_all_add_xcc, compute_C_add_xcc }, [CC_OP_SUB] = { compute_all_sub_xcc, compute_C_sub_xcc }, [CC_OP_SUBX] = { compute_all_subx_xcc, compute_C_subx_xcc }, diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 989275b17d..59e96bf39d 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -380,12 +380,72 @@ static void gen_goto_tb(DisasContext *s, int tb_num, } } -static void gen_op_add_cc(TCGv dst, TCGv src1, TCGv src2) +static TCGv gen_carry32(void) { - tcg_gen_mov_tl(cpu_cc_src, src1); - tcg_gen_mov_tl(cpu_cc_src2, src2); - tcg_gen_add_tl(cpu_cc_dst, cpu_cc_src, cpu_cc_src2); - tcg_gen_mov_tl(dst, cpu_cc_dst); +#ifdef TARGET_SPARC64 + TCGv t = tcg_temp_new(); + tcg_gen_extract_tl(t, cpu_icc_C, 32, 1); + return t; +#else + return cpu_icc_C; +#endif +} + +static void gen_op_addcc_int(TCGv dst, TCGv src1, TCGv src2, TCGv cin) +{ + TCGv z = tcg_constant_tl(0); + + if (cin) { + tcg_gen_add2_tl(cpu_cc_N, cpu_cc_C, src1, z, cin, z); + tcg_gen_add2_tl(cpu_cc_N, cpu_cc_C, cpu_cc_N, cpu_cc_C, src2, z); + } else { + tcg_gen_add2_tl(cpu_cc_N, cpu_cc_C, src1, z, src2, z); + } + tcg_gen_xor_tl(cpu_cc_Z, src1, src2); + tcg_gen_xor_tl(cpu_cc_V, cpu_cc_N, src2); + tcg_gen_andc_tl(cpu_cc_V, cpu_cc_V, cpu_cc_Z); +#ifdef TARGET_SPARC64 + /* + * Carry-in to bit 32 is result ^ src1 ^ src2. + * We already have the src xor term in Z, from computation of V. + */ + tcg_gen_xor_tl(cpu_icc_C, cpu_cc_Z, cpu_cc_N); + tcg_gen_mov_tl(cpu_icc_Z, cpu_cc_N); +#endif + tcg_gen_mov_tl(cpu_cc_Z, cpu_cc_N); + tcg_gen_mov_tl(dst, cpu_cc_N); +} + +static void gen_op_addcc(TCGv dst, TCGv src1, TCGv src2) +{ + gen_op_addcc_int(dst, src1, src2, NULL); +} + +static void gen_op_taddcc(TCGv dst, TCGv src1, TCGv src2) +{ + TCGv t = tcg_temp_new(); + + /* Save the tag bits around modification of dst. */ + tcg_gen_or_tl(t, src1, src2); + + gen_op_addcc(dst, src1, src2); + + /* Incorprate tag bits into icc.V */ + tcg_gen_andi_tl(t, t, 3); + tcg_gen_neg_tl(t, t); + tcg_gen_ext32u_tl(t, t); + tcg_gen_or_tl(cpu_cc_N, cpu_cc_N, t); +} + +static void gen_op_addc(TCGv dst, TCGv src1, TCGv src2) +{ + tcg_gen_add_tl(dst, src1, src2); + tcg_gen_add_tl(dst, dst, gen_carry32()); +} + +static void gen_op_addccc(TCGv dst, TCGv src1, TCGv src2) +{ + gen_op_addcc_int(dst, src1, src2, gen_carry32()); } static TCGv_i32 gen_add32_carry32(void) @@ -430,61 +490,6 @@ static TCGv_i32 gen_sub32_carry32(void) return carry_32; } -static void gen_op_addx_int(DisasContext *dc, TCGv dst, TCGv src1, - TCGv src2, int update_cc) -{ - TCGv_i32 carry_32; - TCGv carry; - - switch (dc->cc_op) { - case CC_OP_ADD: - case CC_OP_TADD: - case CC_OP_TADDTV: - if (TARGET_LONG_BITS == 32) { - /* We can re-use the host's hardware carry generation by using - an ADD2 opcode. We discard the low part of the output. - Ideally we'd combine this operation with the add that - generated the carry in the first place. */ - carry = tcg_temp_new(); - tcg_gen_add2_tl(carry, dst, cpu_cc_src, src1, cpu_cc_src2, src2); - goto add_done; - } - carry_32 = gen_add32_carry32(); - break; - - case CC_OP_SUB: - case CC_OP_TSUB: - case CC_OP_TSUBTV: - carry_32 = gen_sub32_carry32(); - break; - - default: - /* We need external help to produce the carry. */ - carry_32 = tcg_temp_new_i32(); - gen_helper_compute_C_icc(carry_32, tcg_env); - break; - } - -#if TARGET_LONG_BITS == 64 - carry = tcg_temp_new(); - tcg_gen_extu_i32_i64(carry, carry_32); -#else - carry = carry_32; -#endif - - tcg_gen_add_tl(dst, src1, src2); - tcg_gen_add_tl(dst, dst, carry); - - add_done: - if (update_cc) { - tcg_gen_mov_tl(cpu_cc_src, src1); - tcg_gen_mov_tl(cpu_cc_src2, src2); - tcg_gen_mov_tl(cpu_cc_dst, dst); - tcg_gen_movi_i32(cpu_cc_op, CC_OP_ADDX); - dc->cc_op = CC_OP_ADDX; - } -} - static void gen_op_sub_cc(TCGv dst, TCGv src1, TCGv src2) { tcg_gen_mov_tl(cpu_cc_src, src1); @@ -500,8 +505,6 @@ static void gen_op_subx_int(DisasContext *dc, TCGv dst, TCGv src1, TCGv carry; switch (dc->cc_op) { - case CC_OP_ADD: - case CC_OP_TADD: case CC_OP_TADDTV: carry_32 = gen_add32_carry32(); break; @@ -550,39 +553,39 @@ static void gen_op_subx_int(DisasContext *dc, TCGv dst, TCGv src1, static void gen_op_mulscc(TCGv dst, TCGv src1, TCGv src2) { - TCGv r_temp, zero, t0; + TCGv zero = tcg_constant_tl(0); + TCGv t_src1 = tcg_temp_new(); + TCGv t_src2 = tcg_temp_new(); + TCGv t0 = tcg_temp_new(); - r_temp = tcg_temp_new(); - t0 = tcg_temp_new(); + tcg_gen_ext32u_tl(t_src1, src1); + tcg_gen_ext32u_tl(t_src2, src2); - /* old op: - if (!(env->y & 1)) - T1 = 0; - */ - zero = tcg_constant_tl(0); - tcg_gen_andi_tl(cpu_cc_src, src1, 0xffffffff); - tcg_gen_andi_tl(r_temp, cpu_y, 0x1); - tcg_gen_andi_tl(cpu_cc_src2, src2, 0xffffffff); - tcg_gen_movcond_tl(TCG_COND_EQ, cpu_cc_src2, r_temp, zero, - zero, cpu_cc_src2); + /* + * if (!(env->y & 1)) + * src2 = 0; + */ + tcg_gen_andi_tl(t0, cpu_y, 0x1); + tcg_gen_movcond_tl(TCG_COND_EQ, t_src2, t0, zero, zero, t_src2); - // b2 = T0 & 1; - // env->y = (b2 << 31) | (env->y >> 1); + /* + * b2 = src1 & 1; + * y = (b2 << 31) | (y >> 1); + */ tcg_gen_extract_tl(t0, cpu_y, 1, 31); - tcg_gen_deposit_tl(cpu_y, t0, cpu_cc_src, 31, 1); + tcg_gen_deposit_tl(cpu_y, t0, src1, 31, 1); // b1 = N ^ V; tcg_gen_xor_tl(t0, cpu_cc_N, cpu_cc_V); - // T0 = (b1 << 31) | (T0 >> 1); - // src1 = T0; + /* + * src1 = (b1 << 31) | (src1 >> 1) + */ tcg_gen_andi_tl(t0, t0, 1u << 31); - tcg_gen_shri_tl(cpu_cc_src, cpu_cc_src, 1); - tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, t0); + tcg_gen_shri_tl(t_src1, t_src1, 1); + tcg_gen_or_tl(t_src1, t_src1, t0); - tcg_gen_add_tl(cpu_cc_dst, cpu_cc_src, cpu_cc_src2); - - tcg_gen_mov_tl(dst, cpu_cc_dst); + gen_op_addcc(dst, t_src1, t_src2); } static void gen_op_multiply(TCGv dst, TCGv src1, TCGv src2, int sign_ext) @@ -3787,7 +3790,7 @@ TRANS(SDIV, DIV, do_arith, a, gen_op_sdiv, NULL) /* TODO: Should have feature bit -- comes in with UltraSparc T2. */ TRANS(POPC, 64, do_arith, a, gen_op_popc, NULL) -TRANS(ADDcc, ALL, do_cc_arith, a, CC_OP_ADD, gen_op_add_cc, NULL) +TRANS(ADDcc, ALL, do_flags_arith, a, CC_OP_FLAGS, gen_op_addcc) TRANS(ANDcc, ALL, do_logic_cc, a, tcg_gen_and_tl, tcg_gen_andi_tl) TRANS(ORcc, ALL, do_logic_cc, a, tcg_gen_or_tl, tcg_gen_ori_tl) TRANS(XORcc, ALL, do_logic_cc, a, tcg_gen_xor_tl, tcg_gen_xori_tl) @@ -3799,7 +3802,7 @@ TRANS(UMULcc, MUL, do_logic_cc, a, gen_op_umul, NULL) TRANS(SMULcc, MUL, do_logic_cc, a, gen_op_smul, NULL) TRANS(UDIVcc, DIV, do_flags_arith, a, CC_OP_FLAGS, gen_op_udivcc) TRANS(SDIVcc, DIV, do_flags_arith, a, CC_OP_FLAGS, gen_op_sdivcc) -TRANS(TADDcc, ALL, do_cc_arith, a, CC_OP_TADD, gen_op_add_cc, NULL) +TRANS(TADDcc, ALL, do_flags_arith, a, CC_OP_FLAGS, gen_op_taddcc) TRANS(TSUBcc, ALL, do_cc_arith, a, CC_OP_TSUB, gen_op_sub_cc, NULL) TRANS(TADDccTV, ALL, do_flags_arith, a, CC_OP_TADDTV, gen_op_taddcctv) TRANS(TSUBccTV, ALL, do_flags_arith, a, CC_OP_TSUBTV, gen_op_tsubcctv) @@ -3819,26 +3822,14 @@ static TCGv gen_rs2_or_imm(DisasContext *dc, bool imm, int rs2_or_imm) static bool trans_ADDC(DisasContext *dc, arg_r_r_ri *a) { - TCGv src2 = gen_rs2_or_imm(dc, a->imm, a->rs2_or_imm); - - if (src2 == NULL) { - return false; - } - gen_op_addx_int(dc, gen_dest_gpr(dc, a->rd), - gen_load_gpr(dc, a->rs1), src2, false); - return advance_pc(dc); + update_psr(dc); + return do_arith(dc, a, gen_op_addc, NULL); } static bool trans_ADDCcc(DisasContext *dc, arg_r_r_ri *a) { - TCGv src2 = gen_rs2_or_imm(dc, a->imm, a->rs2_or_imm); - - if (src2 == NULL) { - return false; - } - gen_op_addx_int(dc, gen_dest_gpr(dc, a->rd), - gen_load_gpr(dc, a->rs1), src2, true); - return advance_pc(dc); + update_psr(dc); + return do_flags_arith(dc, a, CC_OP_FLAGS, gen_op_addccc); } static bool trans_SUBC(DisasContext *dc, arg_r_r_ri *a) @@ -3868,7 +3859,7 @@ static bool trans_SUBCcc(DisasContext *dc, arg_r_r_ri *a) static bool trans_MULScc(DisasContext *dc, arg_r_r_ri *a) { update_psr(dc); - return do_cc_arith(dc, a, CC_OP_ADD, gen_op_mulscc, NULL); + return do_flags_arith(dc, a, CC_OP_FLAGS, gen_op_mulscc); } static bool gen_edge(DisasContext *dc, arg_r_r_r *a, From patchwork Tue Oct 17 06:40:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734359 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp331906wro; Mon, 16 Oct 2023 23:46:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IECvtqu0esfZwahUB04lA8rxYjZg7/TPQH49hfPi+QT0rVmL5bVQh+sjsUG8hoZNt3qZrQt X-Received: by 2002:ac8:59c1:0:b0:419:7623:ef6c with SMTP id f1-20020ac859c1000000b004197623ef6cmr1635878qtf.60.1697525190004; Mon, 16 Oct 2023 23:46:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697525189; cv=none; d=google.com; s=arc-20160816; b=vdsvy5BWJhUChQaqD/+hVDotaKyMwYQNdMRahqflbpb7xB6PilImtudPkPBOEfrXjP eQ1EAVgaJ/1802XjpnBz42QmeBcjGZHD+gUYWFlE1wn+WIRyN2It880CQNLV7JrRBGcM ebAyGzpzp3mN5qSEGa/jOOm4kEwuf9YrmJu8l3ire1TzQ0ynY1j7AtaIAOUdlSDLAZ0N KwcoAL6xnCapeWek1qbLTDzGEZRWJeSgjjCbKVDUimZgZjxS9T+Aeq1SDEtk3d2XGzrK uM47ZhJLNrEV76cNDLuAXqPk5IJVz+94XAvYrIi60v0jAgu1Khl+eftSIO8YWzQi92/l iowQ== 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=SXWrxOLh0hy4zGD+VY2suBXWmSC9zzwSi5d/2qfqkNE=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=fGK5WqpevZCuchkoVFM0Vbfzb/kEQuTXBneLmIsEb1yafnUJzt6ZnIOZ4cyHXYJis2 phmRWOLfD62pMXoaKseU55v+U5j3/Xc9atHW8WfD7BrKUQlWrP8gKC2s8QFKw6ebRZs5 C+u9sbArDKEL+DE/HX5cPAzW25zxjTkRP9Hgy0LT0JopZeRy62qw4BK2WNABfD/0Pg0n auN5R9i6klekInQUDw1BkmFsbgIGvdtwvuYLiAGmuzPLhCeeSQE0ZSTqQdugfnhDJ0hD DvxN4RJjKHmCIDYtbmwWoBK9g3KGcDpjD6LWyhZc0EBgs2U6qCJpdwnK09wihYTEBos9 FVjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fMdRvMei; 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 t9-20020a05622a01c900b004053819f665si678370qtw.608.2023.10.16.23.46.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:46:29 -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=fMdRvMei; 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 1qsdmO-0008I7-1S; Tue, 17 Oct 2023 02:42:13 -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 1qsdlk-0007vE-83 for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:36 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdlU-0001qb-K2 for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:31 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1c9c5a1b87bso35997385ad.3 for ; Mon, 16 Oct 2023 23:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524875; x=1698129675; 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=SXWrxOLh0hy4zGD+VY2suBXWmSC9zzwSi5d/2qfqkNE=; b=fMdRvMei5fl4zFNydzJTMOYtp8wb8NyfIwdj4qRXv1IYM0CSKzZmNJqbwq5HrnHSWM +CC1km9jt/G0tOfWboMipiEgU/cootQtBh7/n7pTPuTDDW8vS5gZ+C2C7q0n/YCOz6tH MKvuu6o1440R3ohYU8bdsQTSPJ6U7GzUgWGtsB59CLoWfh1Vfo3xou8c73MWBgS/SbYY /OjUinEFewt8h4b6Yy3hvxgZwFGflwMnGxP6G0B9qoJf6GtMnaVinJpO3rRFbv/L3FFg scrSuO9ZOvhXEojYjIIgE0kbfYrXAoUr4nZ9DrnSK+5GknXP7wKcEDy1Vv6ZMidcHRB/ eKiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524875; x=1698129675; 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=SXWrxOLh0hy4zGD+VY2suBXWmSC9zzwSi5d/2qfqkNE=; b=YBbyJtBcATrhh0eE82m2k1Z49wX8vmjXCniobV5dWM/O3L8yci6q1r7ithI6tOTIB0 DZ6PCiejdl055aW94XjxbcQZH5C8u0B/osC8+hLwC6ZE2SPYc6DpgNwT7GmGCKk1NazK c1to3MFBadQWsreKnaMAEwj6MJlW0D+bsU1NwvN6OW8kA/E75HM0USXEzvMrPAD3x8s9 SdUIYjkTzHlntnJcNH7oTCpmVQvYUZjjCCdLbk/XMbM3snUF6r74d7oM3p552DI6caj5 Df3ck3THfkbzEw7FJGiiIAhLh86qEBZMNPX3u65isCD8nbYPeE0VV9yVelBkUoQZl3d/ 8g7A== X-Gm-Message-State: AOJu0YxAOLpLgKLAKYWbtHuoQP0IrFXRDUPJf5nJ7d2GugapCxd5cFYL p3kLZWP4NrS39sFn7Huorb0AK7ACqutLPV9kQWQ= X-Received: by 2002:a17:903:32d0:b0:1b5:561a:5ca9 with SMTP id i16-20020a17090332d000b001b5561a5ca9mr1455121plr.50.1697524875057; Mon, 16 Oct 2023 23:41:15 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 06/20] target/sparc: Remove CC_OP_SUB, CC_OP_SUBX, CC_OP_TSUB Date: Mon, 16 Oct 2023 23:40:55 -0700 Message-Id: <20231017064109.681935-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=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 These are all related and implementable with common code. Signed-off-by: Richard Henderson --- target/sparc/cpu.h | 3 - target/sparc/cc_helper.c | 59 ---------- target/sparc/translate.c | 226 ++++++++++----------------------------- 3 files changed, 54 insertions(+), 234 deletions(-) diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index 4925b35859..8498bd07db 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -151,9 +151,6 @@ enum { CC_OP_DYNAMIC, /* must use dynamic code to get cc_op */ CC_OP_FLAGS, /* all cc are back in cc_*_[NZCV] registers */ CC_OP_TADDTV, /* modify all flags except V, CC_DST = res, CC_SRC = src1 */ - CC_OP_SUB, /* modify all flags, CC_DST = res, CC_SRC = src1 */ - CC_OP_SUBX, /* modify all flags, CC_DST = res, CC_SRC = src1 */ - CC_OP_TSUB, /* modify all flags, CC_DST = res, CC_SRC = src1 */ CC_OP_TSUBTV, /* modify all flags except V, CC_DST = res, CC_SRC = src1 */ CC_OP_NB, }; diff --git a/target/sparc/cc_helper.c b/target/sparc/cc_helper.c index c004a9b1d8..d31aa24b5d 100644 --- a/target/sparc/cc_helper.c +++ b/target/sparc/cc_helper.c @@ -234,64 +234,11 @@ static uint32_t compute_C_sub_xcc(CPUSPARCState *env) } #endif -static uint32_t compute_all_sub(CPUSPARCState *env) -{ - uint32_t ret; - - ret = get_NZ_icc(CC_DST); - ret |= get_C_sub_icc(CC_SRC, CC_SRC2); - ret |= get_V_sub_icc(CC_DST, CC_SRC, CC_SRC2); - return ret; -} - static uint32_t compute_C_sub(CPUSPARCState *env) { return get_C_sub_icc(CC_SRC, CC_SRC2); } -#ifdef TARGET_SPARC64 -static uint32_t compute_all_subx_xcc(CPUSPARCState *env) -{ - uint32_t ret; - - ret = get_NZ_xcc(CC_DST); - ret |= get_C_subx_xcc(CC_DST, CC_SRC, CC_SRC2); - ret |= get_V_sub_xcc(CC_DST, CC_SRC, CC_SRC2); - return ret; -} - -static uint32_t compute_C_subx_xcc(CPUSPARCState *env) -{ - return get_C_subx_xcc(CC_DST, CC_SRC, CC_SRC2); -} -#endif - -static uint32_t compute_all_subx(CPUSPARCState *env) -{ - uint32_t ret; - - ret = get_NZ_icc(CC_DST); - ret |= get_C_subx_icc(CC_DST, CC_SRC, CC_SRC2); - ret |= get_V_sub_icc(CC_DST, CC_SRC, CC_SRC2); - return ret; -} - -static uint32_t compute_C_subx(CPUSPARCState *env) -{ - return get_C_subx_icc(CC_DST, CC_SRC, CC_SRC2); -} - -static uint32_t compute_all_tsub(CPUSPARCState *env) -{ - uint32_t ret; - - ret = get_NZ_icc(CC_DST); - ret |= get_C_sub_icc(CC_SRC, CC_SRC2); - ret |= get_V_sub_icc(CC_DST, CC_SRC, CC_SRC2); - ret |= get_V_tag_icc(CC_SRC, CC_SRC2); - return ret; -} - static uint32_t compute_all_tsubtv(CPUSPARCState *env) { uint32_t ret; @@ -309,9 +256,6 @@ typedef struct CCTable { static const CCTable icc_table[CC_OP_NB] = { /* CC_OP_DYNAMIC should never happen */ [CC_OP_TADDTV] = { compute_all_taddtv, compute_C_add }, - [CC_OP_SUB] = { compute_all_sub, compute_C_sub }, - [CC_OP_SUBX] = { compute_all_subx, compute_C_subx }, - [CC_OP_TSUB] = { compute_all_tsub, compute_C_sub }, [CC_OP_TSUBTV] = { compute_all_tsubtv, compute_C_sub }, }; @@ -319,9 +263,6 @@ static const CCTable icc_table[CC_OP_NB] = { static const CCTable xcc_table[CC_OP_NB] = { /* CC_OP_DYNAMIC should never happen */ [CC_OP_TADDTV] = { compute_all_add_xcc, compute_C_add_xcc }, - [CC_OP_SUB] = { compute_all_sub_xcc, compute_C_sub_xcc }, - [CC_OP_SUBX] = { compute_all_subx_xcc, compute_C_subx_xcc }, - [CC_OP_TSUB] = { compute_all_sub_xcc, compute_C_sub_xcc }, [CC_OP_TSUBTV] = { compute_all_sub_xcc, compute_C_sub_xcc }, }; #endif diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 59e96bf39d..ff523a4e7d 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -448,107 +448,58 @@ static void gen_op_addccc(TCGv dst, TCGv src1, TCGv src2) gen_op_addcc_int(dst, src1, src2, gen_carry32()); } -static TCGv_i32 gen_add32_carry32(void) +static void gen_op_subcc_int(TCGv dst, TCGv src1, TCGv src2, TCGv cin) { - TCGv_i32 carry_32, cc_src1_32, cc_src2_32; + TCGv z = tcg_constant_tl(0); - /* Carry is computed from a previous add: (dst < src) */ -#if TARGET_LONG_BITS == 64 - cc_src1_32 = tcg_temp_new_i32(); - cc_src2_32 = tcg_temp_new_i32(); - tcg_gen_extrl_i64_i32(cc_src1_32, cpu_cc_dst); - tcg_gen_extrl_i64_i32(cc_src2_32, cpu_cc_src); -#else - cc_src1_32 = cpu_cc_dst; - cc_src2_32 = cpu_cc_src; -#endif - - carry_32 = tcg_temp_new_i32(); - tcg_gen_setcond_i32(TCG_COND_LTU, carry_32, cc_src1_32, cc_src2_32); - - return carry_32; -} - -static TCGv_i32 gen_sub32_carry32(void) -{ - TCGv_i32 carry_32, cc_src1_32, cc_src2_32; - - /* Carry is computed from a previous borrow: (src1 < src2) */ -#if TARGET_LONG_BITS == 64 - cc_src1_32 = tcg_temp_new_i32(); - cc_src2_32 = tcg_temp_new_i32(); - tcg_gen_extrl_i64_i32(cc_src1_32, cpu_cc_src); - tcg_gen_extrl_i64_i32(cc_src2_32, cpu_cc_src2); -#else - cc_src1_32 = cpu_cc_src; - cc_src2_32 = cpu_cc_src2; -#endif - - carry_32 = tcg_temp_new_i32(); - tcg_gen_setcond_i32(TCG_COND_LTU, carry_32, cc_src1_32, cc_src2_32); - - return carry_32; -} - -static void gen_op_sub_cc(TCGv dst, TCGv src1, TCGv src2) -{ - tcg_gen_mov_tl(cpu_cc_src, src1); - tcg_gen_mov_tl(cpu_cc_src2, src2); - tcg_gen_sub_tl(cpu_cc_dst, cpu_cc_src, cpu_cc_src2); - tcg_gen_mov_tl(dst, cpu_cc_dst); -} - -static void gen_op_subx_int(DisasContext *dc, TCGv dst, TCGv src1, - TCGv src2, int update_cc) -{ - TCGv_i32 carry_32; - TCGv carry; - - switch (dc->cc_op) { - case CC_OP_TADDTV: - carry_32 = gen_add32_carry32(); - break; - - case CC_OP_SUB: - case CC_OP_TSUB: - case CC_OP_TSUBTV: - if (TARGET_LONG_BITS == 32) { - /* We can re-use the host's hardware carry generation by using - a SUB2 opcode. We discard the low part of the output. - Ideally we'd combine this operation with the add that - generated the carry in the first place. */ - carry = tcg_temp_new(); - tcg_gen_sub2_tl(carry, dst, cpu_cc_src, src1, cpu_cc_src2, src2); - goto sub_done; - } - carry_32 = gen_sub32_carry32(); - break; - - default: - /* We need external help to produce the carry. */ - carry_32 = tcg_temp_new_i32(); - gen_helper_compute_C_icc(carry_32, tcg_env); - break; + if (cin) { + tcg_gen_sub2_tl(cpu_cc_N, cpu_cc_C, src1, z, cin, z); + tcg_gen_sub2_tl(cpu_cc_N, cpu_cc_C, cpu_cc_N, cpu_cc_C, src2, z); + } else { + tcg_gen_sub2_tl(cpu_cc_N, cpu_cc_C, src1, z, src2, z); } - -#if TARGET_LONG_BITS == 64 - carry = tcg_temp_new(); - tcg_gen_extu_i32_i64(carry, carry_32); -#else - carry = carry_32; + tcg_gen_neg_tl(cpu_cc_C, cpu_cc_C); + tcg_gen_xor_tl(cpu_cc_Z, src1, src2); + tcg_gen_xor_tl(cpu_cc_V, cpu_cc_N, src1); + tcg_gen_and_tl(cpu_cc_V, cpu_cc_V, cpu_cc_Z); +#ifdef TARGET_SPARC64 + tcg_gen_xor_tl(cpu_icc_C, cpu_cc_Z, cpu_cc_N); + tcg_gen_mov_tl(cpu_icc_Z, cpu_cc_N); #endif + tcg_gen_mov_tl(cpu_cc_Z, cpu_cc_N); + tcg_gen_mov_tl(dst, cpu_cc_N); +} +static void gen_op_subcc(TCGv dst, TCGv src1, TCGv src2) +{ + gen_op_subcc_int(dst, src1, src2, NULL); +} + +static void gen_op_tsubcc(TCGv dst, TCGv src1, TCGv src2) +{ + TCGv t = tcg_temp_new(); + + /* Save the tag bits around modification of dst. */ + tcg_gen_or_tl(t, src1, src2); + + gen_op_subcc(dst, src1, src2); + + /* Incorprate tag bits into icc.V */ + tcg_gen_andi_tl(t, t, 3); + tcg_gen_neg_tl(t, t); + tcg_gen_ext32u_tl(t, t); + tcg_gen_or_tl(cpu_cc_N, cpu_cc_N, t); +} + +static void gen_op_subc(TCGv dst, TCGv src1, TCGv src2) +{ tcg_gen_sub_tl(dst, src1, src2); - tcg_gen_sub_tl(dst, dst, carry); + tcg_gen_sub_tl(dst, dst, gen_carry32()); +} - sub_done: - if (update_cc) { - tcg_gen_mov_tl(cpu_cc_src, src1); - tcg_gen_mov_tl(cpu_cc_src2, src2); - tcg_gen_mov_tl(cpu_cc_dst, dst); - tcg_gen_movi_i32(cpu_cc_op, CC_OP_SUBX); - dc->cc_op = CC_OP_SUBX; - } +static void gen_op_subccc(TCGv dst, TCGv src1, TCGv src2) +{ + gen_op_subcc_int(dst, src1, src2, gen_carry32()); } static void gen_op_mulscc(TCGv dst, TCGv src1, TCGv src2) @@ -1035,66 +986,11 @@ static void gen_op_next_insn(void) static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond, DisasContext *dc) { - static int subcc_cond[16] = { - TCG_COND_NEVER, - TCG_COND_EQ, - TCG_COND_LE, - TCG_COND_LT, - TCG_COND_LEU, - TCG_COND_LTU, - -1, /* neg */ - -1, /* overflow */ - TCG_COND_ALWAYS, - TCG_COND_NE, - TCG_COND_GT, - TCG_COND_GE, - TCG_COND_GTU, - TCG_COND_GEU, - -1, /* pos */ - -1, /* no overflow */ - }; - TCGv t1, t2; cmp->is_bool = false; switch (dc->cc_op) { - - case CC_OP_SUB: - switch (cond) { - case 6: /* neg */ - case 14: /* pos */ - cmp->cond = (cond == 6 ? TCG_COND_LT : TCG_COND_GE); - cmp->c2 = tcg_constant_tl(0); - if (TARGET_LONG_BITS == 32 || xcc) { - cmp->c1 = cpu_cc_dst; - } else { - cmp->c1 = t1 = tcg_temp_new(); - tcg_gen_ext32s_tl(t1, cpu_cc_dst); - } - return; - - case 7: /* overflow */ - case 15: /* !overflow */ - break; - - default: - cmp->cond = subcc_cond[cond]; - if (TARGET_LONG_BITS == 32 || xcc) { - cmp->c1 = cpu_cc_src; - cmp->c2 = cpu_cc_src2; - } else { - /* Note that sign-extension works for unsigned compares as - long as both operands are sign-extended. */ - cmp->c1 = t1 = tcg_temp_new(); - tcg_gen_ext32s_tl(t1, cpu_cc_src); - cmp->c2 = t2 = tcg_temp_new(); - tcg_gen_ext32s_tl(t2, cpu_cc_src2); - } - return; - } - break; - default: gen_helper_compute_psr(tcg_env); dc->cc_op = CC_OP_FLAGS; @@ -3794,7 +3690,7 @@ TRANS(ADDcc, ALL, do_flags_arith, a, CC_OP_FLAGS, gen_op_addcc) TRANS(ANDcc, ALL, do_logic_cc, a, tcg_gen_and_tl, tcg_gen_andi_tl) TRANS(ORcc, ALL, do_logic_cc, a, tcg_gen_or_tl, tcg_gen_ori_tl) TRANS(XORcc, ALL, do_logic_cc, a, tcg_gen_xor_tl, tcg_gen_xori_tl) -TRANS(SUBcc, ALL, do_cc_arith, a, CC_OP_SUB, gen_op_sub_cc, NULL) +TRANS(SUBcc, ALL, do_flags_arith, a, CC_OP_FLAGS, gen_op_subcc) TRANS(ANDNcc, ALL, do_logic_cc, a, tcg_gen_andc_tl, NULL) TRANS(ORNcc, ALL, do_logic_cc, a, tcg_gen_orc_tl, NULL) TRANS(XORNcc, ALL, do_logic_cc, a, tcg_gen_eqv_tl, NULL) @@ -3803,7 +3699,7 @@ TRANS(SMULcc, MUL, do_logic_cc, a, gen_op_smul, NULL) TRANS(UDIVcc, DIV, do_flags_arith, a, CC_OP_FLAGS, gen_op_udivcc) TRANS(SDIVcc, DIV, do_flags_arith, a, CC_OP_FLAGS, gen_op_sdivcc) TRANS(TADDcc, ALL, do_flags_arith, a, CC_OP_FLAGS, gen_op_taddcc) -TRANS(TSUBcc, ALL, do_cc_arith, a, CC_OP_TSUB, gen_op_sub_cc, NULL) +TRANS(TSUBcc, ALL, do_flags_arith, a, CC_OP_FLAGS, gen_op_tsubcc) TRANS(TADDccTV, ALL, do_flags_arith, a, CC_OP_TADDTV, gen_op_taddcctv) TRANS(TSUBccTV, ALL, do_flags_arith, a, CC_OP_TSUBTV, gen_op_tsubcctv) @@ -3834,26 +3730,14 @@ static bool trans_ADDCcc(DisasContext *dc, arg_r_r_ri *a) static bool trans_SUBC(DisasContext *dc, arg_r_r_ri *a) { - TCGv src2 = gen_rs2_or_imm(dc, a->imm, a->rs2_or_imm); - - if (src2 == NULL) { - return false; - } - gen_op_subx_int(dc, gen_dest_gpr(dc, a->rd), - gen_load_gpr(dc, a->rs1), src2, false); - return advance_pc(dc); + update_psr(dc); + return do_arith(dc, a, gen_op_subc, NULL); } static bool trans_SUBCcc(DisasContext *dc, arg_r_r_ri *a) { - TCGv src2 = gen_rs2_or_imm(dc, a->imm, a->rs2_or_imm); - - if (src2 == NULL) { - return false; - } - gen_op_subx_int(dc, gen_dest_gpr(dc, a->rd), - gen_load_gpr(dc, a->rs1), src2, true); - return advance_pc(dc); + update_psr(dc); + return do_flags_arith(dc, a, CC_OP_FLAGS, gen_op_subccc); } static bool trans_MULScc(DisasContext *dc, arg_r_r_ri *a) @@ -3874,11 +3758,9 @@ static bool gen_edge(DisasContext *dc, arg_r_r_r *a, s2 = gen_load_gpr(dc, a->rs2); if (cc) { - tcg_gen_mov_tl(cpu_cc_src, s1); - tcg_gen_mov_tl(cpu_cc_src2, s2); - tcg_gen_sub_tl(cpu_cc_dst, s1, s2); - tcg_gen_movi_i32(cpu_cc_op, CC_OP_SUB); - dc->cc_op = CC_OP_SUB; + gen_op_subcc(cpu_cc_N, s1, s2); + tcg_gen_movi_i32(cpu_cc_op, CC_OP_FLAGS); + dc->cc_op = CC_OP_FLAGS; } /* From patchwork Tue Oct 17 06:40:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734345 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp330505wro; Mon, 16 Oct 2023 23:41:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjVSuxLqtga6jocna63B9dk8qWGMNHukbMD/17LyjfmzGDA23x7JCpzzaStC4CmZI8ooMg X-Received: by 2002:a0c:f2cf:0:b0:66d:66dd:bc14 with SMTP id c15-20020a0cf2cf000000b0066d66ddbc14mr1400499qvm.11.1697524915293; Mon, 16 Oct 2023 23:41:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697524915; cv=none; d=google.com; s=arc-20160816; b=ZvilovY4aolFJUF5aRvgfxqWZEVlMmclAX9BoJSO0zBr5YEurlW6kgp9NTxOn+Blz2 yQ5AWpQvcZHkJwhPbHXUHp5QDvCMFyMM3yJ8ApYVd9yhqh1+svh45uGotxdEVKClKJ2X OiPa3ytnSYm24C/KisviczsYJKfalB8PvtY+WMklpERD6K5ByI5Gr32o6rM/C338O1px jpD+W1Bqbczw+9XPwviln69N7va/UX/otUCSt2cE2Zc2HpsKjJOY2LAPlD0Qv8QvmBTx z3AMLXDavPUNaZu+Zxgnz7ze3pWQh7lF1yhLrSR2IrKqtFlUmSJBNmCp5d/XU08rRJOD oOLw== 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=h0OGT/ljR6h/FKMK8az8Ybfl519ArhwT7zqC2zzRTgE=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=ehljR+IDuJg79YMfPexR6Kn3LU7yBUHuxBlIt1TE7LCP/LCZZRcaY8r7auB8pOZ0Kb 8jeVz7m2YM83zskawYYsfaqlTOwjo4rlEYYp/GR+jC4ZD+nCmQkDOQA8Hr5QmPG4v7gF Z27W5C1kd/Ot3OuuNc5vjKjmAp9pFf1csdEWHYUvlJqAuxNLaxSr4s9q6/afefxexC/8 J+wdz8H2UGcW0bqXk7RlOE3baMyWIqAB4x54bkJo5YqRVrHVu+/oQwR+Jxwgq1GELLup e6eiCJZ4zOpNRZ95jup0recYBRlHcWe09VOQnsyUlJy5eZN9j4Y8+flN6Biozv03507V Mbow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UHEik1I+; 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 bp6-20020a05620a458600b007788b84dbc7si119802qkb.496.2023.10.16.23.41.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:41:55 -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=UHEik1I+; 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 1qsdlm-0007tx-21; Tue, 17 Oct 2023 02:41:36 -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 1qsdlZ-0007sG-LN for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:22 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdlW-0001qn-FZ for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:21 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1c77449a6daso42939455ad.0 for ; Mon, 16 Oct 2023 23:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524876; x=1698129676; 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=h0OGT/ljR6h/FKMK8az8Ybfl519ArhwT7zqC2zzRTgE=; b=UHEik1I+BlmomG5YP0E2DegfVJOkCf4LTBQPCiLxZygMnAVeb4y/2hu/H/1M4SVQNs g5OV8+8URIcioWxAf4WAoV5O1uLWHkuCzx/6PKn+c6CQZ4R5RDUxxWALs1tQjwKMC4PQ tMmc1vIctq6GKn+aS4pPO2a2NGuRHDlRkS2ywp3zwgIAQ7mzM0RzhiHs+CJTmQaPe2dO vC52w19y1rwl09biV6KopHPhcTnlaevgc2godYLiGAeKBrYUrD2k+FGnu1JocjlzRsFQ UKs/rNXtx5wFkd0XvyYJscyLjSPB6Br2TzeWQzvCXmYytFQJ49gW1k4siEacMxS9qVXM u/Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524876; x=1698129676; 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=h0OGT/ljR6h/FKMK8az8Ybfl519ArhwT7zqC2zzRTgE=; b=MtLDcQVifzU4gqPtbgPvoto6Cwg31aQyj8GavwWo6bRK2eiUS9fsIkXPy8T5Q/N3Fl 5xMkrrkBgrd8H6al4F0/uj1XNPkuYhcPCRakT1VsrFOP3K+c4oD0vCDnURjpDvWMzuse eZtDhLULB5yl0zuveSL/23pVLUnEraY+mrsUBX93YOANY9IZZR19b1s6GXodG5220hzP ZaxfYWTB1gNxE6cz3ArO/m7A1q7ctuX4ZmsAQKiBbB44lR5KGKfRFAe4IWOql4gsXslG yAnE9JiOKDMJCta36t1XleQr8Xk7YSZeAtZ3KGFZLXV0UnUY2fKK/qlkHTEuQ+U6zo1h XVag== X-Gm-Message-State: AOJu0YxbjCm5gq0Bpu7TvoEvIm5VJmrCY7b27lclacLxavCjnLKw8JVh LumXjjHlIKJZeIrm2AONCelMaem2ljlbdsvmgZk= X-Received: by 2002:a17:903:11c7:b0:1c3:2532:ac71 with SMTP id q7-20020a17090311c700b001c32532ac71mr1727305plh.31.1697524875757; Mon, 16 Oct 2023 23:41:15 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 07/20] target/sparc: Remove CC_OP_TADDTV, CC_OP_TSUBTV Date: Mon, 16 Oct 2023 23:40:56 -0700 Message-Id: <20231017064109.681935-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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/cpu.h | 2 - target/sparc/cc_helper.c | 267 +-------------------------------------- target/sparc/helper.c | 40 ++++-- target/sparc/translate.c | 4 +- 4 files changed, 32 insertions(+), 281 deletions(-) diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index 8498bd07db..27f7fed293 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -150,8 +150,6 @@ enum { enum { CC_OP_DYNAMIC, /* must use dynamic code to get cc_op */ CC_OP_FLAGS, /* all cc are back in cc_*_[NZCV] registers */ - CC_OP_TADDTV, /* modify all flags except V, CC_DST = res, CC_SRC = src1 */ - CC_OP_TSUBTV, /* modify all flags except V, CC_DST = res, CC_SRC = src1 */ CC_OP_NB, }; diff --git a/target/sparc/cc_helper.c b/target/sparc/cc_helper.c index d31aa24b5d..cebe03ff51 100644 --- a/target/sparc/cc_helper.c +++ b/target/sparc/cc_helper.c @@ -21,275 +21,12 @@ #include "cpu.h" #include "exec/helper-proto.h" -static inline uint32_t get_NZ_icc(int32_t dst) -{ - uint32_t ret = 0; - - if (dst == 0) { - ret = PSR_ZERO; - } else if (dst < 0) { - ret = PSR_NEG; - } - return ret; -} - -#ifdef TARGET_SPARC64 -static inline uint32_t get_NZ_xcc(target_long dst) -{ - uint32_t ret = 0; - - if (!dst) { - ret = PSR_ZERO; - } else if (dst < 0) { - ret = PSR_NEG; - } - return ret; -} -#endif - -static inline uint32_t get_C_add_icc(uint32_t dst, uint32_t src1) -{ - uint32_t ret = 0; - - if (dst < src1) { - ret = PSR_CARRY; - } - return ret; -} - -static inline uint32_t get_C_addx_icc(uint32_t dst, uint32_t src1, - uint32_t src2) -{ - uint32_t ret = 0; - - if (((src1 & src2) | (~dst & (src1 | src2))) & (1U << 31)) { - ret = PSR_CARRY; - } - return ret; -} - -static inline uint32_t get_V_add_icc(uint32_t dst, uint32_t src1, - uint32_t src2) -{ - uint32_t ret = 0; - - if (((src1 ^ src2 ^ -1) & (src1 ^ dst)) & (1U << 31)) { - ret = PSR_OVF; - } - return ret; -} - -#ifdef TARGET_SPARC64 -static inline uint32_t get_C_add_xcc(target_ulong dst, target_ulong src1) -{ - uint32_t ret = 0; - - if (dst < src1) { - ret = PSR_CARRY; - } - return ret; -} - -static inline uint32_t get_C_addx_xcc(target_ulong dst, target_ulong src1, - target_ulong src2) -{ - uint32_t ret = 0; - - if (((src1 & src2) | (~dst & (src1 | src2))) & (1ULL << 63)) { - ret = PSR_CARRY; - } - return ret; -} - -static inline uint32_t get_V_add_xcc(target_ulong dst, target_ulong src1, - target_ulong src2) -{ - uint32_t ret = 0; - - if (((src1 ^ src2 ^ -1) & (src1 ^ dst)) & (1ULL << 63)) { - ret = PSR_OVF; - } - return ret; -} - -static uint32_t compute_all_add_xcc(CPUSPARCState *env) -{ - uint32_t ret; - - ret = get_NZ_xcc(CC_DST); - ret |= get_C_add_xcc(CC_DST, CC_SRC); - ret |= get_V_add_xcc(CC_DST, CC_SRC, CC_SRC2); - return ret; -} - -static uint32_t compute_C_add_xcc(CPUSPARCState *env) -{ - return get_C_add_xcc(CC_DST, CC_SRC); -} -#endif - -static uint32_t compute_C_add(CPUSPARCState *env) -{ - return get_C_add_icc(CC_DST, CC_SRC); -} - -static inline uint32_t get_V_tag_icc(target_ulong src1, target_ulong src2) -{ - uint32_t ret = 0; - - if ((src1 | src2) & 0x3) { - ret = PSR_OVF; - } - return ret; -} - -static uint32_t compute_all_taddtv(CPUSPARCState *env) -{ - uint32_t ret; - - ret = get_NZ_icc(CC_DST); - ret |= get_C_add_icc(CC_DST, CC_SRC); - return ret; -} - -static inline uint32_t get_C_sub_icc(uint32_t src1, uint32_t src2) -{ - uint32_t ret = 0; - - if (src1 < src2) { - ret = PSR_CARRY; - } - return ret; -} - -static inline uint32_t get_C_subx_icc(uint32_t dst, uint32_t src1, - uint32_t src2) -{ - uint32_t ret = 0; - - if (((~src1 & src2) | (dst & (~src1 | src2))) & (1U << 31)) { - ret = PSR_CARRY; - } - return ret; -} - -static inline uint32_t get_V_sub_icc(uint32_t dst, uint32_t src1, - uint32_t src2) -{ - uint32_t ret = 0; - - if (((src1 ^ src2) & (src1 ^ dst)) & (1U << 31)) { - ret = PSR_OVF; - } - return ret; -} - - -#ifdef TARGET_SPARC64 -static inline uint32_t get_C_sub_xcc(target_ulong src1, target_ulong src2) -{ - uint32_t ret = 0; - - if (src1 < src2) { - ret = PSR_CARRY; - } - return ret; -} - -static inline uint32_t get_C_subx_xcc(target_ulong dst, target_ulong src1, - target_ulong src2) -{ - uint32_t ret = 0; - - if (((~src1 & src2) | (dst & (~src1 | src2))) & (1ULL << 63)) { - ret = PSR_CARRY; - } - return ret; -} - -static inline uint32_t get_V_sub_xcc(target_ulong dst, target_ulong src1, - target_ulong src2) -{ - uint32_t ret = 0; - - if (((src1 ^ src2) & (src1 ^ dst)) & (1ULL << 63)) { - ret = PSR_OVF; - } - return ret; -} - -static uint32_t compute_all_sub_xcc(CPUSPARCState *env) -{ - uint32_t ret; - - ret = get_NZ_xcc(CC_DST); - ret |= get_C_sub_xcc(CC_SRC, CC_SRC2); - ret |= get_V_sub_xcc(CC_DST, CC_SRC, CC_SRC2); - return ret; -} - -static uint32_t compute_C_sub_xcc(CPUSPARCState *env) -{ - return get_C_sub_xcc(CC_SRC, CC_SRC2); -} -#endif - -static uint32_t compute_C_sub(CPUSPARCState *env) -{ - return get_C_sub_icc(CC_SRC, CC_SRC2); -} - -static uint32_t compute_all_tsubtv(CPUSPARCState *env) -{ - uint32_t ret; - - ret = get_NZ_icc(CC_DST); - ret |= get_C_sub_icc(CC_SRC, CC_SRC2); - return ret; -} - -typedef struct CCTable { - uint32_t (*compute_all)(CPUSPARCState *env); /* return all the flags */ - uint32_t (*compute_c)(CPUSPARCState *env); /* return the C flag */ -} CCTable; - -static const CCTable icc_table[CC_OP_NB] = { - /* CC_OP_DYNAMIC should never happen */ - [CC_OP_TADDTV] = { compute_all_taddtv, compute_C_add }, - [CC_OP_TSUBTV] = { compute_all_tsubtv, compute_C_sub }, -}; - -#ifdef TARGET_SPARC64 -static const CCTable xcc_table[CC_OP_NB] = { - /* CC_OP_DYNAMIC should never happen */ - [CC_OP_TADDTV] = { compute_all_add_xcc, compute_C_add_xcc }, - [CC_OP_TSUBTV] = { compute_all_sub_xcc, compute_C_sub_xcc }, -}; -#endif - void helper_compute_psr(CPUSPARCState *env) { if (CC_OP == CC_OP_FLAGS) { return; } - - uint32_t icc = icc_table[CC_OP].compute_all(env); -#ifdef TARGET_SPARC64 - uint32_t xcc = xcc_table[CC_OP].compute_all(env); - - env->cc_N = deposit64(-(icc & PSR_NEG), 32, 32, -(xcc & PSR_NEG)); - env->cc_V = deposit64(-(icc & PSR_OVF), 32, 32, -(xcc & PSR_OVF)); - env->cc_icc_C = (uint64_t)icc << (32 - PSR_CARRY_SHIFT); - env->cc_xcc_C = (xcc >> PSR_CARRY_SHIFT) & 1; - env->cc_xcc_Z = ~xcc & PSR_ZERO; -#else - env->cc_N = -(icc & PSR_NEG); - env->cc_V = -(icc & PSR_OVF); - env->cc_icc_C = (icc >> PSR_CARRY_SHIFT) & 1; -#endif - env->cc_icc_Z = ~icc & PSR_ZERO; - - CC_OP = CC_OP_FLAGS; + g_assert_not_reached(); } uint32_t helper_compute_C_icc(CPUSPARCState *env) @@ -301,5 +38,5 @@ uint32_t helper_compute_C_icc(CPUSPARCState *env) return env->cc_icc_C; #endif } - return icc_table[CC_OP].compute_c(env) >> PSR_CARRY_SHIFT; + g_assert_not_reached(); } diff --git a/target/sparc/helper.c b/target/sparc/helper.c index 87a4258792..4887f295a5 100644 --- a/target/sparc/helper.c +++ b/target/sparc/helper.c @@ -204,7 +204,7 @@ uint64_t helper_udivx(CPUSPARCState *env, uint64_t a, uint64_t b) target_ulong helper_taddcctv(CPUSPARCState *env, target_ulong src1, target_ulong src2) { - target_ulong dst; + target_ulong dst, v; /* Tag overflow occurs if either input has bits 0 or 1 set. */ if ((src1 | src2) & 3) { @@ -214,15 +214,23 @@ target_ulong helper_taddcctv(CPUSPARCState *env, target_ulong src1, dst = src1 + src2; /* Tag overflow occurs if the addition overflows. */ - if (~(src1 ^ src2) & (src1 ^ dst) & (1u << 31)) { + v = ~(src1 ^ src2) & (src1 ^ dst); + if (v & (1u << 31)) { goto tag_overflow; } /* Only modify the CC after any exceptions have been generated. */ - env->cc_op = CC_OP_TADDTV; - env->cc_src = src1; - env->cc_src2 = src2; - env->cc_dst = dst; + env->cc_V = v; + env->cc_N = dst; + env->cc_icc_Z = dst; +#ifdef TARGET_SPARC64 + env->cc_xcc_Z = dst; + env->cc_icc_C = dst ^ src1 ^ src2; + env->cc_xcc_C = dst < src1; +#else + env->cc_icc_C = dst < src1; +#endif + return dst; tag_overflow: @@ -232,7 +240,7 @@ target_ulong helper_taddcctv(CPUSPARCState *env, target_ulong src1, target_ulong helper_tsubcctv(CPUSPARCState *env, target_ulong src1, target_ulong src2) { - target_ulong dst; + target_ulong dst, v; /* Tag overflow occurs if either input has bits 0 or 1 set. */ if ((src1 | src2) & 3) { @@ -242,15 +250,23 @@ target_ulong helper_tsubcctv(CPUSPARCState *env, target_ulong src1, dst = src1 - src2; /* Tag overflow occurs if the subtraction overflows. */ - if ((src1 ^ src2) & (src1 ^ dst) & (1u << 31)) { + v = (src1 ^ src2) & (src1 ^ dst); + if (v & (1u << 31)) { goto tag_overflow; } /* Only modify the CC after any exceptions have been generated. */ - env->cc_op = CC_OP_TSUBTV; - env->cc_src = src1; - env->cc_src2 = src2; - env->cc_dst = dst; + env->cc_V = v; + env->cc_N = dst; + env->cc_icc_Z = dst; +#ifdef TARGET_SPARC64 + env->cc_xcc_Z = dst; + env->cc_icc_C = dst ^ src1 ^ src2; + env->cc_xcc_C = src1 < src2; +#else + env->cc_icc_C = src1 < src2; +#endif + return dst; tag_overflow: diff --git a/target/sparc/translate.c b/target/sparc/translate.c index ff523a4e7d..d8cb669592 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -3700,8 +3700,8 @@ TRANS(UDIVcc, DIV, do_flags_arith, a, CC_OP_FLAGS, gen_op_udivcc) TRANS(SDIVcc, DIV, do_flags_arith, a, CC_OP_FLAGS, gen_op_sdivcc) TRANS(TADDcc, ALL, do_flags_arith, a, CC_OP_FLAGS, gen_op_taddcc) TRANS(TSUBcc, ALL, do_flags_arith, a, CC_OP_FLAGS, gen_op_tsubcc) -TRANS(TADDccTV, ALL, do_flags_arith, a, CC_OP_TADDTV, gen_op_taddcctv) -TRANS(TSUBccTV, ALL, do_flags_arith, a, CC_OP_TSUBTV, gen_op_tsubcctv) +TRANS(TADDccTV, ALL, do_flags_arith, a, CC_OP_FLAGS, gen_op_taddcctv) +TRANS(TSUBccTV, ALL, do_flags_arith, a, CC_OP_FLAGS, gen_op_tsubcctv) static TCGv gen_rs2_or_imm(DisasContext *dc, bool imm, int rs2_or_imm) { From patchwork Tue Oct 17 06:40:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734358 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp331591wro; Mon, 16 Oct 2023 23:45:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFGD7Wcfcj3EHIYrHaijv30DAIbY1BSU055F8A90mKHxBEuH5mEZwg6zkBfVYhPs0BcOlik X-Received: by 2002:a05:620a:20d5:b0:777:71db:43e4 with SMTP id f21-20020a05620a20d500b0077771db43e4mr1379627qka.62.1697525128818; Mon, 16 Oct 2023 23:45:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697525128; cv=none; d=google.com; s=arc-20160816; b=LP2vEeJOobwnhGu5JKCs207zQpJ7/37fO31OJhuEHPviN7UQc7Da+GvVY5mNpQp5eK JQN/9vEWg/hBLiw5tGP/TLZIimMJTYQVM08rH+2qHcSa05OUqLtPnMPnBKjSBKsEuMip uXcwXBIIoviDntUT3x0qeU4js6RqryIUY1hUxrMuiKKcZd9+C5onven7m5ax1RyVHbvW h7gz4QnQvLMAqda0xM4ujeSNc0blmR22y1JoO+/isze2JSKj/4G61zysVD8wurPwTyZl mUfxjcJEa/d8juOqCORWDdMR1+n5GFZtQ5A5AlPhPKzFK2/ggB/WMIS0JCL4FmAQP3Kq d5Qg== 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=ytX3I+Rcwm2SQxKX9URwzSdF8jj+n/0iYLiv3fomhxs=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=kLc0NKIN8GRZ6NiBuUAaWJ9JA8EcdPXMYWNlOEFEHLvU0tRSxh7WqV1k03T63sCekP 3GLKPdlNNHJ2Ud2iDiRwnLu+PU0a3Hk0a+kt1I9EEAugigwVE62gVHYVno1732oxxN5m QiMm62W9p46WlccuZic2++dCDIVEo5LgsLZ4f7F37cyTVzgOg89rRH9ykItuyQYkH9r1 DYWPkwVGb8K+jFB/JtXS3rOedinYJOZESamzV1WGPie9raMxy5Uu2WFPs+4Psl6PJZyz Lp35gn3p4PVvZcBUgumAirgA5cCVBLsG31xKy7/d3WKSvPlDx7h6p+bSRM6lsLn8acw0 gBlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SyDEbyTT; 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 az18-20020a05620a171200b0077428b66050si654104qkb.173.2023.10.16.23.45.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:45:28 -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=SyDEbyTT; 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 1qsdmV-00008K-4J; Tue, 17 Oct 2023 02:42:19 -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 1qsdlb-0007tK-Qn for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:26 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdlX-0001r7-DW for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:22 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1c8a1541233so32898205ad.1 for ; Mon, 16 Oct 2023 23:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524876; x=1698129676; 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=ytX3I+Rcwm2SQxKX9URwzSdF8jj+n/0iYLiv3fomhxs=; b=SyDEbyTTRxsi5gd1nnZMzMx1wI3vHPzmpROPpcxgRWmtvbFs2rua4A8eixyADKcgOu /3S6qtBT9twdcKADwVzg/SjR08rJOL0bBlUYXyQFETIU+NiceJGRPZcXhmbOIe2YTmdK CxlkbvplD3nWwS5huUFCX4wXvEJmQamrelxqr0pcY5h+S9U8YEkk7Ol2MiYKXuA+wdfs M7mKa5/SqIJeNAr39W07Zq1dz/71Yg4J4LUy81jutMmREv+5+a9EfHTbdasK0bOm4rMC rCO5F3WPFDo4n5FY6LWljKIOl4jpzbBRSd9naqIabEnSHjbxCMfyRhNiMd8DtglocBkK PjcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524876; x=1698129676; 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=ytX3I+Rcwm2SQxKX9URwzSdF8jj+n/0iYLiv3fomhxs=; b=Ul1cPANLYEi1kS4k9mem2YBMfXmUaLdPj9TL0DPrvQ5g65W+F1F54B9vuBHY6UnN+W khIMN0H483OHLlo/YPYO5mZOx2zjT6m44xKjg4XHN8FUOkl5hb3Iq53uszOxq+nPhkEt FpviWh/DUYDQztg1a7sK0RnrdsMOYJDikSCmXY16RwUZZSE/h4BZq3I5Fbf4MP/z0oUQ W0yG4qjuwGnxhlNqy9SwM6rXOJR5zornnFk6dyeOYJkTtvFymojOnaBMD4AB9Fey0NH/ FO605uiiWX7gOU2iUzR3BUIt1XDmaXf4IlzwPT97TjoeuFL8JkHUPAdLbV3rZPA3BewX L08A== X-Gm-Message-State: AOJu0Yxu9etFlB7kkr1xIlkH+sntuNbAn34lcXcp8ZlbTWTyAflGSzo7 bHHwngDLtHmBqnJ4mRJMkT9fQs+8Yt3DurxmjOU= X-Received: by 2002:a17:902:bd07:b0:1c9:e774:58e1 with SMTP id p7-20020a170902bd0700b001c9e77458e1mr1323318pls.8.1697524876603; Mon, 16 Oct 2023 23:41:16 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 08/20] target/sparc: Remove CC_OP leftovers Date: Mon, 16 Oct 2023 23:40:57 -0700 Message-Id: <20231017064109.681935-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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 All instructions have been converted to generate full condition codes explicitly. Signed-off-by: Richard Henderson --- target/sparc/cpu.h | 21 ------- target/sparc/helper.h | 2 - linux-user/sparc/cpu_loop.c | 5 -- target/sparc/cc_helper.c | 42 ------------- target/sparc/cpu.c | 1 - target/sparc/int32_helper.c | 5 -- target/sparc/int64_helper.c | 5 -- target/sparc/translate.c | 120 +++++++----------------------------- target/sparc/win_helper.c | 7 --- target/sparc/meson.build | 1 - 10 files changed, 22 insertions(+), 187 deletions(-) delete mode 100644 target/sparc/cc_helper.c diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index 27f7fed293..855ac8b59f 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -137,22 +137,6 @@ enum { #define PSR_CWP 0x1f #endif -#define CC_SRC (env->cc_src) -#define CC_SRC2 (env->cc_src2) -#define CC_DST (env->cc_dst) -#define CC_OP (env->cc_op) - -/* Even though lazy evaluation of CPU condition codes tends to be less - * important on RISC systems where condition codes are only updated - * when explicitly requested, SPARC uses it to update 32-bit and 64-bit - * condition codes. - */ -enum { - CC_OP_DYNAMIC, /* must use dynamic code to get cc_op */ - CC_OP_FLAGS, /* all cc are back in cc_*_[NZCV] registers */ - CC_OP_NB, -}; - /* Trap base register */ #define TBR_BASE_MASK 0xfffff000 @@ -474,11 +458,6 @@ struct CPUArchState { target_ulong cc_xcc_C; #endif - /* emulator internal flags handling */ - target_ulong cc_src, cc_src2; - target_ulong cc_dst; - uint32_t cc_op; - target_ulong cond; /* conditional branch result (XXX: save it in a temporary register when possible) */ diff --git a/target/sparc/helper.h b/target/sparc/helper.h index 58d3c979d4..6415942e03 100644 --- a/target/sparc/helper.h +++ b/target/sparc/helper.h @@ -150,5 +150,3 @@ VIS_CMPHELPER(cmpne) #undef F_HELPER_0_1 #undef VIS_HELPER #undef VIS_CMPHELPER -DEF_HELPER_1(compute_psr, void, env) -DEF_HELPER_FLAGS_1(compute_C_icc, TCG_CALL_NO_WG_SE, i32, env) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index a2086afada..e4d66cbbac 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -234,11 +234,6 @@ void cpu_loop (CPUSPARCState *env) cpu_exec_end(cs); process_queued_cpu_work(cs); - /* Compute PSR before exposing state. */ - if (env->cc_op != CC_OP_FLAGS) { - cpu_get_psr(env); - } - switch (trapnr) { case TARGET_TT_SYSCALL: ret = do_syscall (env, env->gregs[1], diff --git a/target/sparc/cc_helper.c b/target/sparc/cc_helper.c deleted file mode 100644 index cebe03ff51..0000000000 --- a/target/sparc/cc_helper.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Helpers for lazy condition code handling - * - * Copyright (c) 2003-2005 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#include "qemu/osdep.h" -#include "cpu.h" -#include "exec/helper-proto.h" - -void helper_compute_psr(CPUSPARCState *env) -{ - if (CC_OP == CC_OP_FLAGS) { - return; - } - g_assert_not_reached(); -} - -uint32_t helper_compute_C_icc(CPUSPARCState *env) -{ - if (CC_OP == CC_OP_FLAGS) { -#ifdef TARGET_SPARC64 - return extract64(env->cc_icc_C, 32, 1); -#else - return env->cc_icc_C; -#endif - } - g_assert_not_reached(); -} diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 0a3882653c..3980c2d3ca 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -46,7 +46,6 @@ static void sparc_cpu_reset_hold(Object *obj) env->wim = 1; #endif env->regwptr = env->regbase + (env->cwp * 16); - CC_OP = CC_OP_FLAGS; #if defined(CONFIG_USER_ONLY) #ifdef TARGET_SPARC64 env->cleanwin = env->nwindows - 2; diff --git a/target/sparc/int32_helper.c b/target/sparc/int32_helper.c index 82e8418e46..1563613582 100644 --- a/target/sparc/int32_helper.c +++ b/target/sparc/int32_helper.c @@ -103,11 +103,6 @@ void sparc_cpu_do_interrupt(CPUState *cs) CPUSPARCState *env = &cpu->env; int cwp, intno = cs->exception_index; - /* Compute PSR before exposing state. */ - if (env->cc_op != CC_OP_FLAGS) { - cpu_get_psr(env); - } - if (qemu_loglevel_mask(CPU_LOG_INT)) { static int count; const char *name; diff --git a/target/sparc/int64_helper.c b/target/sparc/int64_helper.c index 793e57c536..1b4155f5f3 100644 --- a/target/sparc/int64_helper.c +++ b/target/sparc/int64_helper.c @@ -135,11 +135,6 @@ void sparc_cpu_do_interrupt(CPUState *cs) int intno = cs->exception_index; trap_state *tsptr; - /* Compute PSR before exposing state. */ - if (env->cc_op != CC_OP_FLAGS) { - cpu_get_psr(env); - } - #ifdef DEBUG_PCALL if (qemu_loglevel_mask(CPU_LOG_INT)) { static int count; diff --git a/target/sparc/translate.c b/target/sparc/translate.c index d8cb669592..5c0b6b2764 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -116,8 +116,6 @@ static void gen_helper_array8(TCGv r, TCGv a, TCGv b) /* global register indexes */ static TCGv_ptr cpu_regwptr; -static TCGv cpu_cc_src, cpu_cc_src2, cpu_cc_dst; -static TCGv_i32 cpu_cc_op; static TCGv cpu_fsr, cpu_pc, cpu_npc; static TCGv cpu_regs[32]; static TCGv cpu_y; @@ -175,7 +173,6 @@ typedef struct DisasContext { #endif #endif - uint32_t cc_op; /* current CC operation */ sparc_def_t *def; #ifdef TARGET_SPARC64 int fprs_dirty; @@ -900,14 +897,6 @@ static void save_npc(DisasContext *dc) } } -static void update_psr(DisasContext *dc) -{ - if (dc->cc_op != CC_OP_FLAGS) { - dc->cc_op = CC_OP_FLAGS; - gen_helper_compute_psr(tcg_env); - } -} - static void save_state(DisasContext *dc) { tcg_gen_movi_tl(cpu_pc, dc->pc); @@ -989,17 +978,6 @@ static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond, TCGv t1, t2; cmp->is_bool = false; - - switch (dc->cc_op) { - default: - gen_helper_compute_psr(tcg_env); - dc->cc_op = CC_OP_FLAGS; - break; - - case CC_OP_FLAGS: - break; - } - cmp->c1 = NULL; cmp->c2 = tcg_constant_tl(0); @@ -2657,7 +2635,6 @@ TRANS(RDASR17, ASR17, do_rd_special, true, a->rd, do_rd_leon3_config) static TCGv do_rdccr(DisasContext *dc, TCGv dst) { - update_psr(dc); gen_helper_rdccr(dst, tcg_env); return dst; } @@ -2800,7 +2777,6 @@ TRANS(RDSTRAND_STATUS, HYPV, do_rd_special, true, a->rd, do_rdstrand_status) static TCGv do_rdpsr(DisasContext *dc, TCGv dst) { - update_psr(dc); gen_helper_rdpsr(dst, tcg_env); return dst; } @@ -3261,8 +3237,6 @@ TRANS(WRPOWERDOWN, POWERDOWN, do_wr_special, a, supervisor(dc), do_wrpowerdown) static void do_wrpsr(DisasContext *dc, TCGv src) { gen_helper_wrpsr(tcg_env, src); - tcg_gen_movi_i32(cpu_cc_op, CC_OP_FLAGS); - dc->cc_op = CC_OP_FLAGS; save_state(dc); gen_op_next_insn(); tcg_gen_exit_tb(NULL, 0); @@ -3571,9 +3545,10 @@ static bool trans_NOP_v9(DisasContext *dc, arg_NOP_v9 *a) return false; } -static bool do_cc_arith(DisasContext *dc, arg_r_r_ri *a, int cc_op, - void (*func)(TCGv, TCGv, TCGv), - void (*funci)(TCGv, TCGv, target_long)) +static bool do_arith_int(DisasContext *dc, arg_r_r_ri *a, + void (*func)(TCGv, TCGv, TCGv), + void (*funci)(TCGv, TCGv, target_long), + bool logic_cc) { TCGv dst, src1; @@ -3582,14 +3557,10 @@ static bool do_cc_arith(DisasContext *dc, arg_r_r_ri *a, int cc_op, return false; } - if (cc_op < 0) { - dst = gen_dest_gpr(dc, a->rd); - } else if (cc_op == CC_OP_FLAGS) { + if (logic_cc) { dst = cpu_cc_N; } else { - dst = cpu_cc_dst; - tcg_gen_movi_i32(cpu_cc_op, cc_op); - dc->cc_op = cc_op; + dst = gen_dest_gpr(dc, a->rd); } src1 = gen_load_gpr(dc, a->rs1); @@ -3603,8 +3574,7 @@ static bool do_cc_arith(DisasContext *dc, arg_r_r_ri *a, int cc_op, func(dst, src1, cpu_regs[a->rs2_or_imm]); } - /* Logic insn; to be cleaned up later. */ - if (cc_op == CC_OP_FLAGS) { + if (logic_cc) { tcg_gen_movi_tl(cpu_cc_V, 0); tcg_gen_movi_tl(cpu_icc_C, 0); #ifdef TARGET_SPARC64 @@ -3612,9 +3582,6 @@ static bool do_cc_arith(DisasContext *dc, arg_r_r_ri *a, int cc_op, tcg_gen_mov_tl(cpu_xcc_Z, dst); #endif tcg_gen_mov_tl(cpu_icc_Z, dst); - - tcg_gen_movi_i32(cpu_cc_op, CC_OP_FLAGS); - dc->cc_op = CC_OP_FLAGS; } gen_store_gpr(dc, a->rd, dst); @@ -3625,25 +3592,14 @@ static bool do_arith(DisasContext *dc, arg_r_r_ri *a, void (*func)(TCGv, TCGv, TCGv), void (*funci)(TCGv, TCGv, target_long)) { - return do_cc_arith(dc, a, -1, func, funci); -} - -static bool do_flags_arith(DisasContext *dc, arg_r_r_ri *a, int cc_op, - void (*func)(TCGv, TCGv, TCGv)) -{ - if (do_arith(dc, a, func, NULL)) { - tcg_gen_movi_i32(cpu_cc_op, cc_op); - dc->cc_op = cc_op; - return true; - } - return false; + return do_arith_int(dc, a, func, funci, false); } static bool do_logic_cc(DisasContext *dc, arg_r_r_ri *a, void (*func)(TCGv, TCGv, TCGv), void (*funci)(TCGv, TCGv, target_long)) { - return do_cc_arith(dc, a, CC_OP_FLAGS, func, funci); + return do_arith_int(dc, a, func, funci, true); } static bool trans_OR(DisasContext *dc, arg_r_r_ri *a) @@ -3683,25 +3639,30 @@ TRANS(UDIVX, 64, do_arith, a, gen_op_udivx, NULL) TRANS(SDIVX, 64, do_arith, a, gen_op_sdivx, NULL) TRANS(UDIV, DIV, do_arith, a, gen_op_udiv, NULL) TRANS(SDIV, DIV, do_arith, a, gen_op_sdiv, NULL) +TRANS(ADDC, ALL, do_arith, a, gen_op_addc, NULL) +TRANS(SUBC, ALL, do_arith, a, gen_op_subc, NULL) /* TODO: Should have feature bit -- comes in with UltraSparc T2. */ TRANS(POPC, 64, do_arith, a, gen_op_popc, NULL) -TRANS(ADDcc, ALL, do_flags_arith, a, CC_OP_FLAGS, gen_op_addcc) +TRANS(ADDcc, ALL, do_arith, a, gen_op_addcc, NULL) TRANS(ANDcc, ALL, do_logic_cc, a, tcg_gen_and_tl, tcg_gen_andi_tl) TRANS(ORcc, ALL, do_logic_cc, a, tcg_gen_or_tl, tcg_gen_ori_tl) TRANS(XORcc, ALL, do_logic_cc, a, tcg_gen_xor_tl, tcg_gen_xori_tl) -TRANS(SUBcc, ALL, do_flags_arith, a, CC_OP_FLAGS, gen_op_subcc) +TRANS(SUBcc, ALL, do_arith, a, gen_op_subcc, NULL) TRANS(ANDNcc, ALL, do_logic_cc, a, tcg_gen_andc_tl, NULL) TRANS(ORNcc, ALL, do_logic_cc, a, tcg_gen_orc_tl, NULL) TRANS(XORNcc, ALL, do_logic_cc, a, tcg_gen_eqv_tl, NULL) TRANS(UMULcc, MUL, do_logic_cc, a, gen_op_umul, NULL) TRANS(SMULcc, MUL, do_logic_cc, a, gen_op_smul, NULL) -TRANS(UDIVcc, DIV, do_flags_arith, a, CC_OP_FLAGS, gen_op_udivcc) -TRANS(SDIVcc, DIV, do_flags_arith, a, CC_OP_FLAGS, gen_op_sdivcc) -TRANS(TADDcc, ALL, do_flags_arith, a, CC_OP_FLAGS, gen_op_taddcc) -TRANS(TSUBcc, ALL, do_flags_arith, a, CC_OP_FLAGS, gen_op_tsubcc) -TRANS(TADDccTV, ALL, do_flags_arith, a, CC_OP_FLAGS, gen_op_taddcctv) -TRANS(TSUBccTV, ALL, do_flags_arith, a, CC_OP_FLAGS, gen_op_tsubcctv) +TRANS(UDIVcc, DIV, do_arith, a, gen_op_udivcc, NULL) +TRANS(SDIVcc, DIV, do_arith, a, gen_op_sdivcc, NULL) +TRANS(TADDcc, ALL, do_arith, a, gen_op_taddcc, NULL) +TRANS(TSUBcc, ALL, do_arith, a, gen_op_tsubcc, NULL) +TRANS(TADDccTV, ALL, do_arith, a, gen_op_taddcctv, NULL) +TRANS(TSUBccTV, ALL, do_arith, a, gen_op_tsubcctv, NULL) +TRANS(ADDCcc, ALL, do_arith, a, gen_op_addccc, NULL) +TRANS(SUBCcc, ALL, do_arith, a, gen_op_subccc, NULL) +TRANS(MULScc, ALL, do_arith, a, gen_op_mulscc, NULL) static TCGv gen_rs2_or_imm(DisasContext *dc, bool imm, int rs2_or_imm) { @@ -3716,36 +3677,6 @@ static TCGv gen_rs2_or_imm(DisasContext *dc, bool imm, int rs2_or_imm) } } -static bool trans_ADDC(DisasContext *dc, arg_r_r_ri *a) -{ - update_psr(dc); - return do_arith(dc, a, gen_op_addc, NULL); -} - -static bool trans_ADDCcc(DisasContext *dc, arg_r_r_ri *a) -{ - update_psr(dc); - return do_flags_arith(dc, a, CC_OP_FLAGS, gen_op_addccc); -} - -static bool trans_SUBC(DisasContext *dc, arg_r_r_ri *a) -{ - update_psr(dc); - return do_arith(dc, a, gen_op_subc, NULL); -} - -static bool trans_SUBCcc(DisasContext *dc, arg_r_r_ri *a) -{ - update_psr(dc); - return do_flags_arith(dc, a, CC_OP_FLAGS, gen_op_subccc); -} - -static bool trans_MULScc(DisasContext *dc, arg_r_r_ri *a) -{ - update_psr(dc); - return do_flags_arith(dc, a, CC_OP_FLAGS, gen_op_mulscc); -} - static bool gen_edge(DisasContext *dc, arg_r_r_r *a, int width, bool cc, bool left) { @@ -3759,8 +3690,6 @@ static bool gen_edge(DisasContext *dc, arg_r_r_r *a, if (cc) { gen_op_subcc(cpu_cc_N, s1, s2); - tcg_gen_movi_i32(cpu_cc_op, CC_OP_FLAGS); - dc->cc_op = CC_OP_FLAGS; } /* @@ -5176,7 +5105,6 @@ static void sparc_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) dc->pc = dc->base.pc_first; dc->npc = (target_ulong)dc->base.tb->cs_base; - dc->cc_op = CC_OP_DYNAMIC; dc->mem_idx = dc->base.tb->flags & TB_FLAG_MMU_MASK; dc->def = &env->def; dc->fpu_enabled = tb_fpu_enabled(dc->base.tb->flags); @@ -5371,7 +5299,6 @@ void sparc_tcg_init(void) #else { &cpu_wim, offsetof(CPUSPARCState, wim), "wim" }, #endif - { &cpu_cc_op, offsetof(CPUSPARCState, cc_op), "cc_op" }, }; static const struct { TCGv *ptr; int off; const char *name; } rtl[] = { @@ -5394,9 +5321,6 @@ void sparc_tcg_init(void) { &cpu_icc_Z, offsetof(CPUSPARCState, cc_icc_Z), "icc_Z" }, { &cpu_icc_C, offsetof(CPUSPARCState, cc_icc_C), "icc_C" }, { &cpu_cond, offsetof(CPUSPARCState, cond), "cond" }, - { &cpu_cc_src, offsetof(CPUSPARCState, cc_src), "cc_src" }, - { &cpu_cc_src2, offsetof(CPUSPARCState, cc_src2), "cc_src2" }, - { &cpu_cc_dst, offsetof(CPUSPARCState, cc_dst), "cc_dst" }, { &cpu_fsr, offsetof(CPUSPARCState, fsr), "fsr" }, { &cpu_pc, offsetof(CPUSPARCState, pc), "pc" }, { &cpu_npc, offsetof(CPUSPARCState, npc), "npc" }, diff --git a/target/sparc/win_helper.c b/target/sparc/win_helper.c index a446c1785d..64e498ce2b 100644 --- a/target/sparc/win_helper.c +++ b/target/sparc/win_helper.c @@ -55,8 +55,6 @@ target_ulong cpu_get_psr(CPUSPARCState *env) { target_ulong icc = 0; - helper_compute_psr(env); - icc |= ((int32_t)env->cc_N < 0) << PSR_NEG_SHIFT; icc |= ((int32_t)env->cc_V < 0) << PSR_OVF_SHIFT; icc |= ((int32_t)env->cc_icc_Z == 0) << PSR_ZERO_SHIFT; @@ -102,7 +100,6 @@ void cpu_put_psr_raw(CPUSPARCState *env, target_ulong val) env->psrps = (val & PSR_PS) ? 1 : 0; env->psret = (val & PSR_ET) ? 1 : 0; #endif - env->cc_op = CC_OP_FLAGS; #if !defined(TARGET_SPARC64) cpu_set_cwp(env, val & PSR_CWP); #endif @@ -271,8 +268,6 @@ target_ulong cpu_get_ccr(CPUSPARCState *env) { target_ulong ccr = 0; - helper_compute_psr(env); - ccr |= (env->cc_icc_C >> 32) & 1; ccr |= ((int32_t)env->cc_V < 0) << 1; ccr |= ((int32_t)env->cc_icc_Z == 0) << 2; @@ -294,8 +289,6 @@ void cpu_put_ccr(CPUSPARCState *env, target_ulong val) env->cc_xcc_C = (val >> 4) & 1; env->cc_icc_Z = ~val & 0x04; env->cc_xcc_Z = ~val & 0x40; - - CC_OP = CC_OP_FLAGS; } target_ulong cpu_get_cwp64(CPUSPARCState *env) diff --git a/target/sparc/meson.build b/target/sparc/meson.build index c316773db6..46289c8669 100644 --- a/target/sparc/meson.build +++ b/target/sparc/meson.build @@ -3,7 +3,6 @@ gen = decodetree.process('insns.decode') sparc_ss = ss.source_set() sparc_ss.add(gen) sparc_ss.add(files( - 'cc_helper.c', 'cpu.c', 'fop_helper.c', 'gdbstub.c', From patchwork Tue Oct 17 06:40:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734357 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp331542wro; Mon, 16 Oct 2023 23:45:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFVn4hfpaC/PZxmO4q6CipWY0/QXe79N5nt+ZS9m6c5axhltPc4TDQ3mdJUA//cPjdGWtzx X-Received: by 2002:a05:620a:158b:b0:776:f8b5:c35 with SMTP id d11-20020a05620a158b00b00776f8b50c35mr1455294qkk.4.1697525119560; Mon, 16 Oct 2023 23:45:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697525119; cv=none; d=google.com; s=arc-20160816; b=Tx0c+tJzZE3IhbqoYXqzj6r992aXD+/uLtpbnxzjd7jkg49fxMkD3Oql2wRezeecym O/mmz53aC4XwjoZuSyWLBWiyPbx9V73rO46rLkr3wiBhmm+0a6yIW0ZqLQSCPWgbMq2Z dZnXf/TDe9QZCGWNmMSgwHG/Jn+CPfZslagS8+uwWvGiKDwJ0HBVlMJtSKY8EP5vg6Rk RGJSIERrSMPv36xX4w6rSl83UjTprRDQwUAonJzWHV26kuVR5xMozrGAffMzuN87Aerh JDrY0nEAHP9SdMYnYxwM1wEapJr49i/nxhZmmWKP5y/7lvYS2dlfErGnwVbr55Pu3Id8 /U+A== 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=aFFgB4yBmei7bH3EbUpFJjxrZVUqKwAxw+HBszM2y2A=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=tIFZU1cTKMj2Knn73/dKP0pgN0kVyADqONERl+XKCVIiVtF2tBPcJ0j8AO/M1K+cev CWBJQj1PDnxsn5uh6CxCaEXjiSHTfpRoseI8f/Np4351v0DWBUajhvpyWe3dyXKjaGp6 HjNzH/ZxRBWqa3VpEN1molEBRppK/LeXKM1Ng/N/oXqqRs2A9M/cDSrWvp2qeq+Ve/yv PuA4Vz8WfMkq+XWrR+YoEcjEv+ORPxUCx4IQdVCxqi6lorbmzB7VOH6eCwbtsRVKSfZ6 25Q/r9mJeSlE0pm7lBufCPc7+ZSn/q/+pfCznEphcs+IGV25temQXCB7mPA4OwNkQPwr WT0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OJuxJMsU; 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 q7-20020ae9e407000000b00773fe581c18si601778qkc.463.2023.10.16.23.45.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:45:19 -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=OJuxJMsU; 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 1qsdlz-0007wb-ND; Tue, 17 Oct 2023 02:41:47 -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 1qsdlZ-0007s8-Ax for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:21 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdlW-0001rD-Kt for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:21 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1c9bf22fe05so32839355ad.2 for ; Mon, 16 Oct 2023 23:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524877; x=1698129677; 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=aFFgB4yBmei7bH3EbUpFJjxrZVUqKwAxw+HBszM2y2A=; b=OJuxJMsUhbM0GulOVoi/Bb63hiXU4lKbn2z1g2UnA+AHPu18CiPl2GBiZKNDXfVd1G GLrsUdwoBeh/51rNFJ+QauA+rlMucIPfInQf9PhjDvpEmFiStrO2bGO2Qqovp3d5XjDT jS9cziCGWJLp8kgt9mft/OSoXIMKgCq7vJUZX1rcMlnoXzTfUzudMXhr7yo1BXMC04x4 wEqnnu1ldF4UCqkrWnpHe/KEzgA8M88t9D/GpmNR02VQ0BSaXoaftohrk5J6afuj5Qzh 3WONUW2iHMKnfs9jDUp1Rp4XUSg5jDa8M5z93vO8tg3rC1/tOjEpnpxDFmjDSf9hlcTi KM5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524877; x=1698129677; 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=aFFgB4yBmei7bH3EbUpFJjxrZVUqKwAxw+HBszM2y2A=; b=slvaaJCQRqqLAaRj/yV6CjVCGh6BkiVqb5DusSTnsl52G52dVKxSNBoC4MzfQOdv7W irdZp1Ms8ZKdZZu04izqTzdj+BinoSSLM5OKWAXi3GOdCmQIFc0jQeRM9o2lTc9zcLbA iPfiZ6ZAWOwCLh3XGg3RqEgI1E3hPDqwkLuXDgsbkB/Ly07YuEIN/ouAAqepLtRaTPyZ BpBKDFWKSP9Cmo/yci0JG6wufuFLqOCU7qVzFiDW1lEWcl+fUrTEpQF4paGLVMEKQNSx A44/5nPQFWpc3fS7UJVMet9pTPNvGqEKBFYpCMCnXSQAMnmBrAZt/QlQ1iYyKCJZMHuh u9fg== X-Gm-Message-State: AOJu0YwQJZ8IKz0fNlGwzCIDZWK9WkmlVOm3IUvO2sQoaToR0QMNCGl2 OKRrygG99fQRNqgx59oR7pc7S84C3IC/WP1EolU= X-Received: by 2002:a17:902:fa07:b0:1ca:8541:e1fe with SMTP id la7-20020a170902fa0700b001ca8541e1femr1338699plb.62.1697524877294; Mon, 16 Oct 2023 23:41:17 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 09/20] target/sparc: Remove DisasCompare.is_bool Date: Mon, 16 Oct 2023 23:40:58 -0700 Message-Id: <20231017064109.681935-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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 Since we're going to feed cpu_cond to another comparison, we don't reqire a boolean value -- anything non-zero is sufficient. Signed-off-by: Richard Henderson --- target/sparc/translate.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 5c0b6b2764..a8933d2fc3 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -183,7 +183,6 @@ typedef struct DisasContext { typedef struct { TCGCond cond; - bool is_bool; TCGv c1, c2; } DisasCompare; @@ -977,7 +976,6 @@ static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond, { TCGv t1, t2; - cmp->is_bool = false; cmp->c1 = NULL; cmp->c2 = tcg_constant_tl(0); @@ -1040,7 +1038,6 @@ static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond, case 0x5: /* ltu: C */ cmp->cond = TCG_COND_NE; - cmp->is_bool = true; if (TARGET_LONG_BITS == 32 || xcc) { cmp->c1 = cpu_cc_C; } else { @@ -1071,7 +1068,6 @@ static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond, } if (cond & 8) { cmp->cond = tcg_invert_cond(cmp->cond); - cmp->is_bool = false; } } @@ -1082,7 +1078,6 @@ static void gen_fcompare(DisasCompare *cmp, unsigned int cc, unsigned int cond) /* For now we still generate a straight boolean result. */ cmp->cond = TCG_COND_NE; - cmp->is_bool = true; cmp->c1 = r_dst = tcg_temp_new(); cmp->c2 = tcg_constant_tl(0); @@ -1169,7 +1164,6 @@ static const TCGCond gen_tcg_cond_reg[8] = { static void gen_compare_reg(DisasCompare *cmp, int cond, TCGv r_src) { cmp->cond = tcg_invert_cond(gen_tcg_cond_reg[cond]); - cmp->is_bool = false; cmp->c1 = r_src; cmp->c2 = tcg_constant_tl(0); } @@ -2155,18 +2149,14 @@ static void gen_fmovs(DisasContext *dc, DisasCompare *cmp, int rd, int rs) { #ifdef TARGET_SPARC64 TCGv_i32 c32, zero, dst, s1, s2; + TCGv_i64 c64 = tcg_temp_new_i64(); /* We have two choices here: extend the 32 bit data and use movcond_i64, or fold the comparison down to 32 bits and use movcond_i32. Choose the later. */ c32 = tcg_temp_new_i32(); - if (cmp->is_bool) { - tcg_gen_extrl_i64_i32(c32, cmp->c1); - } else { - TCGv_i64 c64 = tcg_temp_new_i64(); - tcg_gen_setcond_i64(cmp->cond, c64, cmp->c1, cmp->c2); - tcg_gen_extrl_i64_i32(c32, c64); - } + tcg_gen_setcond_i64(cmp->cond, c64, cmp->c1, cmp->c2); + tcg_gen_extrl_i64_i32(c32, c64); s1 = gen_load_fpr_F(dc, rs); s2 = gen_load_fpr_F(dc, rd); @@ -2359,8 +2349,10 @@ static bool advance_jump_cond(DisasContext *dc, DisasCompare *cmp, dc->jump_pc[0] = dest; dc->jump_pc[1] = npc + 4; dc->npc = JUMP_PC; - if (cmp->is_bool) { - tcg_gen_mov_tl(cpu_cond, cmp->c1); + + /* The condition for cpu_cond is always NE -- normalize. */ + if (cmp->cond == TCG_COND_NE) { + tcg_gen_sub_tl(cpu_cond, cmp->c1, cmp->c2); } else { tcg_gen_setcond_tl(cmp->cond, cpu_cond, cmp->c1, cmp->c2); } From patchwork Tue Oct 17 06:40:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734364 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp332307wro; Mon, 16 Oct 2023 23:48:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFelA4M1YdUpYttZLUBgeYdfwMiuiZPRkG5YuoqvUUF+6yb8ieKTAqCR+FRlIiqEHcjXWRm X-Received: by 2002:ad4:5d6f:0:b0:65d:6a5:1a3f with SMTP id fn15-20020ad45d6f000000b0065d06a51a3fmr1829185qvb.43.1697525284460; Mon, 16 Oct 2023 23:48:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697525284; cv=none; d=google.com; s=arc-20160816; b=UXWuCi8UNrAo/YkWUv6ptfNFkmciBNm+iYwy2KWcro0motOXAJYf7JO2KJqPV+Gm/c tNCxYBJDmbVabe4wE7kMVnp6bDa9G2jw5CS3l/O/gspsqokvbmyGUJUw8O1FtYy3ra2i C1oPmHcizjFKamde3i8hYt7sjXESBDs70xEdoAja4t2tWyj4+hb+Ox6cWKlyqGFiPeFc znBMF/Gv5wQMXfex7TwQR3unpsojDiUORlxWVDHi+ER6XRL71SSRqftotT1KmV5mPiev DlTmccd064c2EzgTOJIwQAWi992WOusNnaAOZ4q4L1rVMsaWBVK019qga37LqaZ5nfZb ikHw== 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=qZyDk50srskapKLjo7jm3988q6EoPl5W35pXSSUqy8Q=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=fFT/v+885M693hTmjYRDCSPWIwNVwRi60LHLled1v9JHhIIwqwCz3lmmyBsDnsgb+0 2HcA7VOif9qBMMU7xJQRUybZw0qTGuUXc3zr2a0WKJjhwqzaIvsRQyZ5G5hehj2WbBN5 p5mvF7bwYVQEB6cczNIRL5ip0ymcxMPr1Ea2pKbDsfgPd6FlGWWuq6V/mPkVk5EdR9QO LmzIi8RxSkqvDdVqdFIylsNps/42Tz1Q6RMdk871KIxmCSWYADrRtdtPUyELUQ7oHpxs kh9DywJSyJeeLLu/HTUxrsfAOZ9jsV5hQlGh/kLn4I3k8QmFMSWrPZI5NSVIFt/f4TF4 KlXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eW3HtNtp; 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 h22-20020a05620a401600b0076efbe4639dsi658823qko.688.2023.10.16.23.48.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:48:04 -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=eW3HtNtp; 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 1qsdls-0007wH-RU; Tue, 17 Oct 2023 02:41:40 -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 1qsdlZ-0007sW-Rg for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:22 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdlX-0001rU-Df for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:21 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1c5cd27b1acso44513485ad.2 for ; Mon, 16 Oct 2023 23:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524878; x=1698129678; 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=qZyDk50srskapKLjo7jm3988q6EoPl5W35pXSSUqy8Q=; b=eW3HtNtpAXH5uyQTBflf1zQMPkyVCzzVIdXh9uQJXnyGWkQal96uvogdm+eUI9768q gK9CyX49GKJzDtg2bS3QfXnT/Q3ng2GfD5/en654yJTF7wBiF5eEcoCKDuDHcLfRro4a sxy717WsZ9kw59SAerbItkbtZZSRwvX93NJ5ZbZigLoORMO8mslIjeKEMrcd4GNqsLJ0 KfIPC2dUqcmdyvb/CAtysg8gu3br5gIdRbHPmvZCxWM2AIOTgsiF2zTyPWg7CFbxZe32 z0GXGTvDCNJ85YIoO3FoYtNajMxtOy1Be00k3r4TzqliewQOGnAtnsokGVUmpuIVLX4K H/dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524878; x=1698129678; 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=qZyDk50srskapKLjo7jm3988q6EoPl5W35pXSSUqy8Q=; b=hMAbndtxW6qDv2/VoeJf8cz2SGdlBrnDa05ujdd7i4o8oA/iqyZf6CIP/UgrQ59pM0 21Iis1Pg/1C1cmueRikGOxwJPspiFc7PxCRiPeq6cZNU5HGYeaZtK4xy4FJie7qxKCdX cs4AJmq+yIWO3nl42CtRe9tlVlcHHEMBS8EigwM625Owjxiq2scCGQ1vAZEBMDJOWPGn MTw54QnhsFPDIbpyFPVB6ksYyGzyWrUWk4l6WrscaJy0iM4kU94l2iJjQsNVeK+8D9XO 5wCPTTdlIu9RSyJyEK5HnsTkUWn/DbwqGVKruMM5pVb/vKgyZe8CbdvVm502Y0iWf75s hMbQ== X-Gm-Message-State: AOJu0YxgMUveYvH/AgXl327tJaw1UEnauZlifTAEpEqePG7GpA+h212+ HPU4bM93ads6YhEaALIrsduhY+579Bmdj2+k0Gc= X-Received: by 2002:a17:903:2307:b0:1c8:a63a:2087 with SMTP id d7-20020a170903230700b001c8a63a2087mr1899227plh.65.1697524878020; Mon, 16 Oct 2023 23:41:18 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 10/20] target/sparc: Change DisasCompare.c2 to int Date: Mon, 16 Oct 2023 23:40:59 -0700 Message-Id: <20231017064109.681935-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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 We don't require c2 to be variable, so emphasize that. We don't currently require c2 to be non-zero, but that will change. Signed-off-by: Richard Henderson --- target/sparc/translate.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index a8933d2fc3..32d29f16b5 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -183,7 +183,8 @@ typedef struct DisasContext { typedef struct { TCGCond cond; - TCGv c1, c2; + TCGv c1; + int c2; } DisasCompare; // This function uses non-native bit order @@ -974,15 +975,15 @@ static void gen_op_next_insn(void) static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond, DisasContext *dc) { - TCGv t1, t2; + TCGv t1, t2, zero; cmp->c1 = NULL; - cmp->c2 = tcg_constant_tl(0); + cmp->c2 = 0; switch (cond & 7) { case 0x0: /* never */ cmp->cond = TCG_COND_NEVER; - cmp->c1 = cmp->c2; + cmp->c1 = tcg_constant_tl(0); break; case 0x1: /* eq */ @@ -998,11 +999,12 @@ static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond, case 0x2: /* le: Z | (N ^ V) */ cmp->cond = TCG_COND_LT; cmp->c1 = t1 = tcg_temp_new(); + zero = tcg_constant_tl(0); if (TARGET_LONG_BITS == 32 || xcc) { - tcg_gen_negsetcond_tl(TCG_COND_EQ, t1, cpu_cc_Z, cmp->c2); + tcg_gen_negsetcond_tl(TCG_COND_EQ, t1, cpu_cc_Z, zero); } else { tcg_gen_ext32u_tl(t1, cpu_icc_Z); - tcg_gen_negsetcond_tl(TCG_COND_EQ, t1, t1, cmp->c2); + tcg_gen_negsetcond_tl(TCG_COND_EQ, t1, t1, zero); } t2 = tcg_temp_new(); tcg_gen_xor_tl(t2, cpu_cc_N, cpu_cc_V); @@ -1079,7 +1081,7 @@ static void gen_fcompare(DisasCompare *cmp, unsigned int cc, unsigned int cond) /* For now we still generate a straight boolean result. */ cmp->cond = TCG_COND_NE; cmp->c1 = r_dst = tcg_temp_new(); - cmp->c2 = tcg_constant_tl(0); + cmp->c2 = 0; switch (cc) { default: @@ -1165,7 +1167,7 @@ static void gen_compare_reg(DisasCompare *cmp, int cond, TCGv r_src) { cmp->cond = tcg_invert_cond(gen_tcg_cond_reg[cond]); cmp->c1 = r_src; - cmp->c2 = tcg_constant_tl(0); + cmp->c2 = 0; } static void gen_op_clear_ieee_excp_and_FTT(void) @@ -2155,7 +2157,7 @@ static void gen_fmovs(DisasContext *dc, DisasCompare *cmp, int rd, int rs) or fold the comparison down to 32 bits and use movcond_i32. Choose the later. */ c32 = tcg_temp_new_i32(); - tcg_gen_setcond_i64(cmp->cond, c64, cmp->c1, cmp->c2); + tcg_gen_setcondi_i64(cmp->cond, c64, cmp->c1, cmp->c2); tcg_gen_extrl_i64_i32(c32, c64); s1 = gen_load_fpr_F(dc, rs); @@ -2175,7 +2177,7 @@ static void gen_fmovd(DisasContext *dc, DisasCompare *cmp, int rd, int rs) { #ifdef TARGET_SPARC64 TCGv_i64 dst = gen_dest_fpr_D(dc, rd); - tcg_gen_movcond_i64(cmp->cond, dst, cmp->c1, cmp->c2, + tcg_gen_movcond_i64(cmp->cond, dst, cmp->c1, tcg_constant_tl(cmp->c2), gen_load_fpr_D(dc, rs), gen_load_fpr_D(dc, rd)); gen_store_fpr_D(dc, rd, dst); @@ -2189,10 +2191,11 @@ static void gen_fmovq(DisasContext *dc, DisasCompare *cmp, int rd, int rs) #ifdef TARGET_SPARC64 int qd = QFPREG(rd); int qs = QFPREG(rs); + TCGv c2 = tcg_constant_tl(cmp->c2); - tcg_gen_movcond_i64(cmp->cond, cpu_fpr[qd / 2], cmp->c1, cmp->c2, + tcg_gen_movcond_i64(cmp->cond, cpu_fpr[qd / 2], cmp->c1, c2, cpu_fpr[qs / 2], cpu_fpr[qd / 2]); - tcg_gen_movcond_i64(cmp->cond, cpu_fpr[qd / 2 + 1], cmp->c1, cmp->c2, + tcg_gen_movcond_i64(cmp->cond, cpu_fpr[qd / 2 + 1], cmp->c1, c2, cpu_fpr[qs / 2 + 1], cpu_fpr[qd / 2 + 1]); gen_update_fprs_dirty(dc, qd); @@ -2323,7 +2326,7 @@ static bool advance_jump_cond(DisasContext *dc, DisasCompare *cmp, if (annul) { TCGLabel *l1 = gen_new_label(); - tcg_gen_brcond_tl(tcg_invert_cond(cmp->cond), cmp->c1, cmp->c2, l1); + tcg_gen_brcondi_tl(tcg_invert_cond(cmp->cond), cmp->c1, cmp->c2, l1); gen_goto_tb(dc, 0, npc, dest); gen_set_label(l1); gen_goto_tb(dc, 1, npc + 4, npc + 8); @@ -2337,7 +2340,7 @@ static bool advance_jump_cond(DisasContext *dc, DisasCompare *cmp, tcg_gen_mov_tl(cpu_pc, cpu_npc); tcg_gen_addi_tl(cpu_npc, cpu_npc, 4); tcg_gen_movcond_tl(cmp->cond, cpu_npc, - cmp->c1, cmp->c2, + cmp->c1, tcg_constant_tl(cmp->c2), tcg_constant_tl(dest), cpu_npc); dc->pc = npc; break; @@ -2352,9 +2355,9 @@ static bool advance_jump_cond(DisasContext *dc, DisasCompare *cmp, /* The condition for cpu_cond is always NE -- normalize. */ if (cmp->cond == TCG_COND_NE) { - tcg_gen_sub_tl(cpu_cond, cmp->c1, cmp->c2); + tcg_gen_subi_tl(cpu_cond, cmp->c1, cmp->c2); } else { - tcg_gen_setcond_tl(cmp->cond, cpu_cond, cmp->c1, cmp->c2); + tcg_gen_setcondi_tl(cmp->cond, cpu_cond, cmp->c1, cmp->c2); } } } @@ -2554,7 +2557,7 @@ static bool trans_Tcc(DisasContext *dc, arg_Tcc *a) flush_cond(dc); lab = delay_exceptionv(dc, trap); gen_compare(&cmp, a->cc, a->cond, dc); - tcg_gen_brcond_tl(cmp.cond, cmp.c1, cmp.c2, lab); + tcg_gen_brcondi_tl(cmp.cond, cmp.c1, cmp.c2, lab); return advance_pc(dc); } @@ -3913,8 +3916,9 @@ TRANS(SRA_i, ALL, do_shift_i, a, false, false) static bool do_mov_cond(DisasContext *dc, DisasCompare *cmp, int rd, TCGv src2) { TCGv dst = gen_load_gpr(dc, rd); + TCGv c2 = tcg_constant_tl(cmp->c2); - tcg_gen_movcond_tl(cmp->cond, dst, cmp->c1, cmp->c2, src2, dst); + tcg_gen_movcond_tl(cmp->cond, dst, cmp->c1, c2, src2, dst); gen_store_gpr(dc, rd, dst); return advance_pc(dc); } From patchwork Tue Oct 17 06:41:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734351 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp331055wro; Mon, 16 Oct 2023 23:43:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE38LhuXgucjA4exKT8q0Q7tmuduMc3UgPHrCfWf8rTd9x+f58QvGDWlt9NAFwfH4FIWVem X-Received: by 2002:a05:6214:5194:b0:65b:2660:f58b with SMTP id kl20-20020a056214519400b0065b2660f58bmr1653195qvb.12.1697525020499; Mon, 16 Oct 2023 23:43:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697525020; cv=none; d=google.com; s=arc-20160816; b=gaoyB03mZCo81hsIcEer2lOnnrw3VZBctqsmokk3ixEmnleCGtGIEG2PAQD2MqoPwZ yKgvwg6mMod+e+KU1h/zfRHTuU5EVFoyOrqMK4W22316vC0XV2lH6Yvgh0ov9EiUu8vf brZBD5Oo6MihXP1IT5+7PvkuWoXE0T5CS2PjkZqyyWzAOGJAR5RGob/qzqA8iWH3eNeC RJ5yCatiZyTRXmjKCC0ZzpATrALeTnHci/sExscTxi6aL4tU285HtxeVaYeqLQ0c8aYh k+127lj6ZaSaS0qwzVi93p4mvq536+uobRShA0jidjbU3BhTTDVC8MRtQeuZCH8299jE 4ZsA== 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=yad38dQouP6DqHdsCPOXEG2JDxb1v+Imde3CiLnCBP4=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=WqZjM4/9dt3pkV51Y6kBNYFMvUdya+8gvGqoThrAIGcJAycOFNubseX/eSJBqCmo5D CzYTeiY2VHhtJlg+rfvszqrreTshaTItxLhEgfIYX0Urp0IK0+XqSF4F8J6z/mQX2VJ6 qVXWeZHMr1LEjxSr4N0348pRLLBEh7wz0vzL+NksxVA2JpnloA7OxwUdtV6OP1JncedN OteQ3aISy/bTnl3anotyfKaM+F8a3tB1QIRbElS8HGLmjH/XVWUANUYig4mGjenJp9j8 +4tdPQ229cG3eMdmqnoq+vFNoUEjm1vX2WBbxlKXkRfSs5D5loL8eQkvUPqN8jhCPFhB enyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CGGQu8YY; 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 qh25-20020a0562144c1900b00656467cfef8si540587qvb.254.2023.10.16.23.43.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:43:40 -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=CGGQu8YY; 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 1qsdmS-0008S7-HW; Tue, 17 Oct 2023 02:42:16 -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 1qsdld-0007tQ-9u for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:28 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdlY-0001rg-8X for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:25 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1c77449a6daso42939625ad.0 for ; Mon, 16 Oct 2023 23:41:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524879; x=1698129679; 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=yad38dQouP6DqHdsCPOXEG2JDxb1v+Imde3CiLnCBP4=; b=CGGQu8YYpnpzkY4xJO9hMLm+ZVbXFlsQtBEDSxtR38KXHg27CQQlK0StXSCOXxffqG Hbt+NB4ca6e8lqk74VDGcrPNUBm2gQjcCUd20JbAupYtXzy44FQZpPV549Y+B1fYH5Yn +iyzyzVssavMcIh6lkBTBCoYzLGmp/WO5flpWmirbQG6imcnpl+WAERBvWoDiTvMIsFK KcLemP3RjXsRPOUVxkzmV77j6tmRj4jGaa5egdQxldRsct5N3McB8vc6qqTGsQ2IpXqt ebqGxE64Tf+EC8/rbLZijUv+XExF2h1doR0Y1qNmazPn/9YI4eyuR9jbWLR4HiX++4yr 1w8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524879; x=1698129679; 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=yad38dQouP6DqHdsCPOXEG2JDxb1v+Imde3CiLnCBP4=; b=vxYWtuvnkvg7l+hHcoECApTzPyqJIQ0R7PDLzjfIHJMV8fSH8jj6KB/1g8VRQePPdr GkS3fef6pCNKdSb2ekU7ehMvs07/jgSdViW9uGwmMtGDDLOT+cYDBM7nr1zon0mlDC0z JOOsZTZviHvaZaAC25Hq6jaLSEKVb2DyQjXnJhEN7MeyiSnV8gN61X2RHFGh/nFM41oY ZAhegvk5i44Xh6QGLxnuDRKXkvUq1CvyXjLmDjtdLMIQSiAICuysiW+NUxnIj0bFLFk1 JnglCbZHNk/0YtiNdiu/EuM++44hhZaDk29bHY9AkUIzPOYKWgSPLNG1XCYIkgF+DL+/ 8B6Q== X-Gm-Message-State: AOJu0YzKJ9wdjX9p5wDmww1XEHg283SPMtZxE3MngqevKad/uN+GH4mi Ma4RUsnPU/l6kQIf8FKDHIM7I9hM7QocRjMl8pE= X-Received: by 2002:a17:902:d38d:b0:1c5:f0fd:51be with SMTP id e13-20020a170902d38d00b001c5f0fd51bemr1526928pld.69.1697524878790; Mon, 16 Oct 2023 23:41:18 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 11/20] target/sparc: Always copy conditions into a new temporary Date: Mon, 16 Oct 2023 23:41:00 -0700 Message-Id: <20231017064109.681935-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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, T_SPF_TEMPERROR=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 This will allow the condition to live across changes to the global cc variables. Signed-off-by: Richard Henderson --- target/sparc/translate.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 32d29f16b5..a75f75dfb9 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -977,7 +977,7 @@ static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond, { TCGv t1, t2, zero; - cmp->c1 = NULL; + cmp->c1 = t1 = tcg_temp_new(); cmp->c2 = 0; switch (cond & 7) { @@ -989,16 +989,14 @@ static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond, case 0x1: /* eq */ cmp->cond = TCG_COND_EQ; if (TARGET_LONG_BITS == 32 || xcc) { - cmp->c1 = cpu_cc_Z; + tcg_gen_mov_tl(t1, cpu_cc_Z); } else { - cmp->c1 = t1 = tcg_temp_new(); tcg_gen_ext32u_tl(t1, cpu_icc_Z); } break; case 0x2: /* le: Z | (N ^ V) */ cmp->cond = TCG_COND_LT; - cmp->c1 = t1 = tcg_temp_new(); zero = tcg_constant_tl(0); if (TARGET_LONG_BITS == 32 || xcc) { tcg_gen_negsetcond_tl(TCG_COND_EQ, t1, cpu_cc_Z, zero); @@ -1016,7 +1014,6 @@ static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond, case 0x3: /* lt: N ^ V */ cmp->cond = TCG_COND_LT; - cmp->c1 = t1 = tcg_temp_new(); tcg_gen_xor_tl(t1, cpu_cc_N, cpu_cc_V); if (TARGET_LONG_BITS == 64 && !xcc) { tcg_gen_ext32s_tl(t1, t1); @@ -1025,7 +1022,6 @@ static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond, case 0x4: /* leu: C | Z -> !(!C & !Z) */ cmp->cond = TCG_COND_EQ; - cmp->c1 = t1 = tcg_temp_new(); if (TARGET_LONG_BITS == 32 || xcc) { tcg_gen_subi_tl(t1, cpu_cc_C, 1); tcg_gen_and_tl(t1, t1, cpu_cc_Z); @@ -1041,9 +1037,8 @@ static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond, case 0x5: /* ltu: C */ cmp->cond = TCG_COND_NE; if (TARGET_LONG_BITS == 32 || xcc) { - cmp->c1 = cpu_cc_C; + tcg_gen_mov_tl(t1, cpu_cc_C); } else { - cmp->c1 = t1 = tcg_temp_new(); tcg_gen_extract_tl(t1, cpu_icc_C, 32, 1); } break; @@ -1051,9 +1046,8 @@ static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond, case 0x6: /* neg: N */ cmp->cond = TCG_COND_LT; if (TARGET_LONG_BITS == 32 || xcc) { - cmp->c1 = cpu_cc_N; + tcg_gen_mov_tl(t1, cpu_cc_N); } else { - cmp->c1 = t1 = tcg_temp_new(); tcg_gen_ext32s_tl(t1, cpu_cc_N); } break; @@ -1061,9 +1055,8 @@ static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond, case 0x7: /* vs: V */ cmp->cond = TCG_COND_LT; if (TARGET_LONG_BITS == 32 || xcc) { - cmp->c1 = cpu_cc_V; + tcg_gen_mov_tl(t1, cpu_cc_V); } else { - cmp->c1 = t1 = tcg_temp_new(); tcg_gen_ext32s_tl(t1, cpu_cc_V); } break; @@ -1166,8 +1159,9 @@ static const TCGCond gen_tcg_cond_reg[8] = { static void gen_compare_reg(DisasCompare *cmp, int cond, TCGv r_src) { cmp->cond = tcg_invert_cond(gen_tcg_cond_reg[cond]); - cmp->c1 = r_src; + cmp->c1 = tcg_temp_new(); cmp->c2 = 0; + tcg_gen_mov_tl(cmp->c1, r_src); } static void gen_op_clear_ieee_excp_and_FTT(void) From patchwork Tue Oct 17 06:41:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734361 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp331974wro; Mon, 16 Oct 2023 23:46:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFW2RvyqN7c0Vt7l/2UgUo93CQ4PVP8qwIO8AYLjxUmIpeTGveC2nu4EgrbFR0qYqZnLST/ X-Received: by 2002:a05:620a:4404:b0:773:b53d:1c6a with SMTP id v4-20020a05620a440400b00773b53d1c6amr1601331qkp.43.1697525209810; Mon, 16 Oct 2023 23:46:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697525209; cv=none; d=google.com; s=arc-20160816; b=rjNngTW4EmRcwsyEQ/m/kFJ0Z3znnKqVzdw8p11CRNF9lH9+PYc3eOyQCVDJ16tgSw 7H05vsDgVmj6J5qJp+lrVPMUTnXnDmTBGMhoS8v0wwdAiaJwkCXxTSSfLiaCednlItdN JnIjOtnq0notxo6cXnKoMGCVd6W3NcAlJDqs+a8eW2TXHqR6U9DnLiIidvOX2XD2YpvK ilzgQ9IZtf2fW1/dS1dgkIZ8iFCF5AioIv4kqd0zrJAFW9eKChEpmbhXpfwugu7I8aze BaLmyOIGJa9W7LUN8La1JtT70an4PIpszNC2dzlhiKziW1Kis8iVrPVTOLHUxWoxjO0i pj+w== 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=p+j4/EgNAa/NSiAxA0YoYGZzoI883LNmh9QZ4XGFq4U=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=hL/Y5v1tDLYZYi58PmTQACBKjhpK0+FY6uLQt+iqeYKMRNO1RPMgddzcoOXPl9ldsg MX5oS8OWWvVeXsxv9EXobAMaN5dninBEIDvHjah+wnCxvuDq40BUcnjrCFAPEUF9kZVB a2Iu5Ob/gawzVETEadIEnr1sMWXb80STuub9FqwDgt6DA5ujHxsY8eHzShSYbJFOmnr6 gAkuQC50HidOZaYLu9KRL/EXQhwrhZZYxPbfnO0EJE8plC3zTj1DW765xJu7LwNRjz6p MhMaAK12OTzXp7bi7X6jNIOjKy8IJ3R1WWDG6eYNUJrnulEj/vUX+mKuYPCc+Zql1wV9 G/FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vePgWRbd; 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 3-20020a05620a06c300b0076f185b6bd7si620343qky.432.2023.10.16.23.46.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:46: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=vePgWRbd; 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 1qsdlq-0007w3-4c; Tue, 17 Oct 2023 02:41:38 -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 1qsdlc-0007tO-MQ for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:27 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdla-0001rq-TF for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:24 -0400 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-5ab94fc098cso2001265a12.1 for ; Mon, 16 Oct 2023 23:41:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524879; x=1698129679; 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=p+j4/EgNAa/NSiAxA0YoYGZzoI883LNmh9QZ4XGFq4U=; b=vePgWRbdLlMyYOSLY5SqD/YCi4ee6WtBQjo0xRtp6u6CPHaFw4MP48MbjObT9EoLLM au23WUVQVfIVixA416pujNCTPiKnVYrFMnp30bRtqgCmql1I11OEHXRYxgt0j61oocQi jGWAqDlxrocKrqSW6n0LN5akSD/0yNFb/IXZD0UmqcrEt52HUmJkSHC+2HVYxIITTXZ5 eD04ngFO4M0mFfwKvVkLcUFawIjoPD8hODPAH6bWVZVCzYLHHgoxHjOJSCydRFA8pszr qI7wUZbY05VK0wpUxmr8oL2RIynQN8L6r8YQfPFU01mvgkTUHqGKWqca3ZDwQ/ryClDR HpJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524879; x=1698129679; 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=p+j4/EgNAa/NSiAxA0YoYGZzoI883LNmh9QZ4XGFq4U=; b=GVxvFuTiLVqPrHN/FJ+6m8dMcFuKesM59dDk9o4PMdLulNGuNIEpXryNNcjrNSlN1T E6e9xUZ+m1bORlWenzaY5aWaRZBfIQXatv0C7A+KVLEJITjq25zpzfSH3gncWRdW45Ya aPeJ5aBWmWoj2iqpkuj0i238eh9d9g8YjR4k2bqZys2mCoPeILQx24Kj5mpJrsfYqog5 3Bj9fTEWWnFWhi52gC8EpSKPRJQmat/kasEpyOuArSVFtLj3gQKRDX6oF6C/XRJQuCSE xlgbuMkShOH4ynk/hzHCL6kwVUBs7PqVGIFyAzfjaM8LGm8zSMwxJsZi1YUS3DHwv/ae RTOg== X-Gm-Message-State: AOJu0Yy1q2uA63DO1OEAXS2X0SvOKW8QjTnNzrN5akSxMws45ygg9z17 eVHHApZjCGg1/1oiQTXMg0yjM3OVYlnIef/XkF4= X-Received: by 2002:a05:6a20:2593:b0:14d:5580:8ff0 with SMTP id k19-20020a056a20259300b0014d55808ff0mr1267974pzd.25.1697524879642; Mon, 16 Oct 2023 23:41:19 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 12/20] target/sparc: Do flush_cond in advance_jump_cond Date: Mon, 16 Oct 2023 23:41:01 -0700 Message-Id: <20231017064109.681935-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.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 Do this here instead of in each caller. Signed-off-by: Richard Henderson --- target/sparc/translate.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index a75f75dfb9..74a0972bda 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -2317,6 +2317,8 @@ static bool advance_jump_cond(DisasContext *dc, DisasCompare *cmp, { target_ulong npc = dc->npc; + flush_cond(dc); + if (annul) { TCGLabel *l1 = gen_new_label(); @@ -2392,8 +2394,6 @@ static bool do_bpcc(DisasContext *dc, arg_bcc *a) case 0x8: return advance_jump_uncond_always(dc, a->a, target); default: - flush_cond(dc); - gen_compare(&cmp, a->cc, a->cond, dc); return advance_jump_cond(dc, &cmp, a->a, target); } @@ -2419,8 +2419,6 @@ static bool do_fbpfcc(DisasContext *dc, arg_bcc *a) case 0x8: return advance_jump_uncond_always(dc, a->a, target); default: - flush_cond(dc); - gen_fcompare(&cmp, a->cc, a->cond); return advance_jump_cond(dc, &cmp, a->a, target); } @@ -2446,8 +2444,6 @@ static bool trans_BPr(DisasContext *dc, arg_BPr *a) target &= 0xffffffffULL; } - flush_cond(dc); - gen_compare_reg(&cmp, a->cond, gen_load_gpr(dc, a->rs1)); return advance_jump_cond(dc, &cmp, a->a, target); } From patchwork Tue Oct 17 06:41:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734346 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp330643wro; Mon, 16 Oct 2023 23:42:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG111wY0eHF6CLDUKnbA9kc9CRClHS5RldyyjazZzVlA5989hIjlc8luoaFMiT0ShAhTW15 X-Received: by 2002:a05:622a:1a06:b0:40c:58a1:cb40 with SMTP id f6-20020a05622a1a0600b0040c58a1cb40mr1946607qtb.15.1697524940301; Mon, 16 Oct 2023 23:42:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697524940; cv=none; d=google.com; s=arc-20160816; b=CWfu5fcI2duy5z7yUHYlcZfiweG4YFoHiQ5BvmDCDLDmLGWXdM0kODytjLZYGQu/Wz PZ7gLFx4qankGA0uTLpogiXdOCRvPnu/dSwnZKBaeNEfq5+tIHGE+At/GYOCpkKwp12u /HyvaaU5+ZA/lhWquTluZlf3GXA0JnBD9+qtiwlu4TLlaWMJe+A1LoEiXLpwIvNmSr47 6ayprg7qYRYNnTnrt0odPLRfE0IyxtNC77mIRIiINilSL4dv4zM1+wcWI9Z1w70ILN68 CnLykJ6DGQncZRBFQvECadD8IYN5eOZefsAAAqmusoL0qPDioX1vQP0ChkrWqne/aT90 oRvA== 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=pp3zoEZUHKvoEOLikeNp6Ks+ZDD3//5iYusnkVex7j0=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=V6VnkKzXZBipX605W+tE+YGlA6OoG4jkWdX6b0S9vARmTupXtf7IvYqmL0h2tITukt q5XlUFIRSzm0EOtfi/y/rE9XBH1/h0Js036wOshmWC4b1S2Oe0CYmQWg5o9C1tLAB3DS zi3BMW0NlWhc/d7jGOz9n4pvlX/TQLY08Xo2w2KKr5xIj63OvKqGJQvujfpCm36V+oDz CN10Jo7UHh7QSyAXC7z6qlHW1+Ld1is+0fMZdNlKPR8xMVpCPMFZgQRlC+LZAh6XED/g U5WLWmgMKWTByiON6DKVj26yeB23sLR/3bSUKnpG9z5wxtpiMKPfriNrVDI2dZ1ILI5P cTKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TA+UqEda; 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 i5-20020ac85c05000000b004179519a8c5si661478qti.677.2023.10.16.23.42.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:42:20 -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=TA+UqEda; 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 1qsdmF-00083d-QV; Tue, 17 Oct 2023 02:42:06 -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 1qsdlb-0007tJ-FV for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:26 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdlZ-0001rw-TE for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:23 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6b6f4c118b7so2568193b3a.0 for ; Mon, 16 Oct 2023 23:41:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524880; x=1698129680; 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=pp3zoEZUHKvoEOLikeNp6Ks+ZDD3//5iYusnkVex7j0=; b=TA+UqEda9LB/Abdxjs3VryDZpFN7YBAwP761/ev9nKdOF0rt79Bp1vvWfLih/3Y7WI lNj7Cv5izN3i3kavuIUNMRPUKh86O423O0mEvgNcV2WAl0OcRgvwyaSTV+p8elbqJrjs BFGI056IJ8VwtyrJ3M9hTke5Zg5kkTe5X6+jMZLngzB9iN5ax+oUjG8xoRz57VvOEQZs tPI5JW7XVihNgceL414v1BCGlbCU0GPy/VuixX799eqqFfJtzrQWm/1GC+zEO0FElnck Zy2V0lQBXGpYordOC+Jc5kGm6abGvh33EkZQY87eNnzgVB37qJg/eq0YF/POuAwCjuic L/1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524880; x=1698129680; 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=pp3zoEZUHKvoEOLikeNp6Ks+ZDD3//5iYusnkVex7j0=; b=VKo94HTOkHb2oawvqfRY+8dkYzbULU5McYUVM5q4ginOa2AhGWn0Um9KzaDxXTWlGO nsB52Fjnasn8dRPNJSG0Rk6w7aR1d1O3YgOACDWxze5aEvEEQzVzYjYnwd8GJDxv82ge +VnwzjwuCqZt+TG/fbcxXH6XavsA+Zh2u9YsAIDfQeVWXQGNlyovKPXlxrk9p6bHDqS3 +Qm7Imbg60H8GckMQ3LBuU0v8aohfx9IisYFgTbav6+wpFeQ6J3nvB+t7KXagaNftpiX L02vJdF+3cxErGLQWcbg7YJ0loy8k5+XxjeHWHU8HlU5hFPXnaIOqfiH/b31y+8B6wYV AgLQ== X-Gm-Message-State: AOJu0YwnJz1VycBYdt1kEmlLycpBwCA5m76lLQgRemzpKXvrQS/a1mhV iPkD8WLcEca4KC/OZ9HyMLxcURGDaTg8QkKU+kM= X-Received: by 2002:a05:6a20:a21d:b0:157:54fd:5c26 with SMTP id u29-20020a056a20a21d00b0015754fd5c26mr995720pzk.38.1697524880624; Mon, 16 Oct 2023 23:41:20 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 13/20] target/sparc: Merge gen_branch2 into advance_pc Date: Mon, 16 Oct 2023 23:41:02 -0700 Message-Id: <20231017064109.681935-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x433.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 The function had only one caller. Canonicalize the cpu_cond test to TCG_COND_NE, the "natural" sense of its value. Signed-off-by: Richard Henderson --- target/sparc/translate.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 74a0972bda..4c52425702 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -846,19 +846,6 @@ static void gen_op_eval_fbo(TCGv dst, TCGv src, unsigned int fcc_offset) tcg_gen_xori_tl(dst, dst, 0x1); } -static void gen_branch2(DisasContext *dc, target_ulong pc1, - target_ulong pc2, TCGv r_cond) -{ - TCGLabel *l1 = gen_new_label(); - - tcg_gen_brcondi_tl(TCG_COND_EQ, r_cond, 0, l1); - - gen_goto_tb(dc, 0, pc1, pc1 + 4); - - gen_set_label(l1); - gen_goto_tb(dc, 1, pc2, pc2 + 4); -} - static void gen_generic_branch(DisasContext *dc) { TCGv npc0 = tcg_constant_tl(dc->jump_pc[0]); @@ -2260,6 +2247,8 @@ static int extract_qfpreg(DisasContext *dc, int x) /* Default case for non jump instructions. */ static bool advance_pc(DisasContext *dc) { + TCGLabel *l1; + if (dc->npc & 3) { switch (dc->npc) { case DYNAMIC_PC: @@ -2267,11 +2256,22 @@ static bool advance_pc(DisasContext *dc) dc->pc = dc->npc; gen_op_next_insn(); break; + case JUMP_PC: /* we can do a static jump */ - gen_branch2(dc, dc->jump_pc[0], dc->jump_pc[1], cpu_cond); + l1 = gen_new_label(); + tcg_gen_brcondi_tl(TCG_COND_NE, cpu_cond, 0, l1); + + /* jump not taken */ + gen_goto_tb(dc, 1, dc->jump_pc[1], dc->jump_pc[1] + 4); + + /* jump taken */ + gen_set_label(l1); + gen_goto_tb(dc, 0, dc->jump_pc[0], dc->jump_pc[0] + 4); + dc->base.is_jmp = DISAS_NORETURN; break; + default: g_assert_not_reached(); } From patchwork Tue Oct 17 06:41:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734363 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp332296wro; Mon, 16 Oct 2023 23:48:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFIS9fkEtXvO5qm4v0ZdsMjlOV2sqQN/kvrCam0pjtHYkfiOXKBbkEmsgl7JR03enVxmj06 X-Received: by 2002:a0c:b215:0:b0:66d:12a3:ec8c with SMTP id x21-20020a0cb215000000b0066d12a3ec8cmr1332443qvd.30.1697525283029; Mon, 16 Oct 2023 23:48:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697525283; cv=none; d=google.com; s=arc-20160816; b=d85fNy+dM7pepzHuSaYQlVFQWddoaQorbRqmRbP1jz3wT999UIRmLET6PzWHCvgygg GvBXdGUw4WqSQh9qPz40XlRYlGQWrSKGR5Dp9ISR6YZlDgtJ6AYbh4INkehvfKdRHeH5 fZjB7aXy8DWja/NVx7nyZ13p2+10pHWH/hnORjs4VY/sNZI34nBGqWiUt1KQGhgS4oYz y9NweqPaCa+z004nhnWJY+drLAZb8LPkPiEFYLv+3d+7gC9Vg3+uWzwm+CMtiDu1ze0I P+vzrWts+IPDsCTOXZ/Gn+Yh7l8BpefnyLWV/HAyOCpwamitu9eDxbxehrf3vVtJQsOc jLPA== 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=kewAVssE39LvjouWsvZcTjjrjFgZixtCBX1Kb1O7gh4=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=pNJjMWlguP4tbLLtU4WvsrQiVoxQS/c/6jjLo8w3bUMHv5OmpGWkbR9MSLaVvlno1Q DPzjpwLCGg99/YN4sx/DlPZYtIHOlIfHYq/aAXJeeJz1zG2627iXoUkjJQtitwFqHE2x VG9ug243ZYQ8+AINTZcqQlCtqfdJrlctQrvNU0Ehx2cBN/kYUlxivkbNouykbIGGvSUT ZCzbuzjFs+aCEbFlehTmv0S7vwP88w66ba2Xj1y+NnNZa4xonf5H/Ebm820qHeuy6RUx MPdD9b4t9KZLOTYQsbmVbtOD/1QNO84s56J2k6YSh0aW1BLtdzcxEzaDD0BMJbmWcyL1 LlUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=I3F0LaIG; 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 da14-20020a05621408ce00b0066d28ec81edsi572703qvb.36.2023.10.16.23.48.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:48:03 -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=fail header.i=@linaro.org header.s=google header.b=I3F0LaIG; 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 1qsdmW-0000BQ-0h; Tue, 17 Oct 2023 02:42:20 -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 1qsdld-0007tP-8L for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:28 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdla-0001sH-J1 for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:24 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6be0277c05bso1409427b3a.0 for ; Mon, 16 Oct 2023 23:41:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524881; x=1698129681; 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=kewAVssE39LvjouWsvZcTjjrjFgZixtCBX1Kb1O7gh4=; b=I3F0LaIGNg+z6xftua3Y7m977hvo+a5xhYLn1i5bX3eHNykkkomFUiu5FVWlnKoELl 46nu3M5uCYeXegdKHlBFZ2yXThZ/r9JHm2MB4UWtOo3eTK5hXh1tOXavFbZu7Iu7mQDr 7ftJZZ8ooeElwO0kVKTHuKXc1OnJC+TYme7cN8s7mbih0Zu5Hg8bjqNtcckuDebJPQYO ON5tn5XI5LEPqrF18smIivOUsAJUTm7gAdLmF/yUc61l3nPME442u6vyolWAh5ncnwcq kKkRhfJOYXOeAGQ+Tf7cEWFKoE4ZUFhhDCwEAq7Y6XYFw7q4+Gcc8kXdlNVhgMW2e0z4 IHMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524881; x=1698129681; 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=kewAVssE39LvjouWsvZcTjjrjFgZixtCBX1Kb1O7gh4=; b=Ie/G9cPLyJhMlu4lXVVAkEQ4bMRhLhJ5LG55AoWV7xiE++mhTLB1ZkVRwL4fkx4oeY nBGnsjx+izlf9KVjfRcyyp3HCev1NdEyIpXXKuWC/30rZp9c7+IOYq7kHXGx5DW6LBLc bHBGJI3dgUbYl9msQZWiwds+a/5rzmyBj1t8NPnJq23SUfwD2M/+Y8rdB8Z4fzrj4g9s SMa4FhQ5dAKhDF8R929BoxYS9iG901VDOL28fHReUX8IgSF9QHOkngcLAbpUrp8BLjRx WWAUNQNapPWBcMe7zJQByWnJuyGgL5i+6DNoN1ewhqqI0DzSEoGysvfHlI0eDY4zHRRU n8IA== X-Gm-Message-State: AOJu0YyabB+jS1Cy+1/bfiy0w9zV+10PVDSOPBZKu5iZZOpeqTSGTv3W vBNCDuC3HM8DORtlPNRghRPWgaOMJMKZn2S77Hs= X-Received: by 2002:a05:6a20:8f28:b0:16b:f3b1:c040 with SMTP id b40-20020a056a208f2800b0016bf3b1c040mr1398398pzk.38.1697524881283; Mon, 16 Oct 2023 23:41:21 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 14/20] target/sparc: Merge advance_jump_uncond_{never, always} into advance_jump_cond Date: Mon, 16 Oct 2023 23:41:03 -0700 Message-Id: <20231017064109.681935-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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 Handle these via TCG_COND_{ALWAYS,NEVER}. Allow dc->npc to be variable, using gen_mov_pc_npc. Signed-off-by: Richard Henderson --- target/sparc/translate.c | 73 ++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 44 deletions(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 4c52425702..53a755874e 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -2286,37 +2286,36 @@ 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 = dc->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) { + 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); if (annul) { @@ -2388,15 +2387,8 @@ static bool do_bpcc(DisasContext *dc, arg_bcc *a) 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: - 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(BPcc, 64, do_bpcc, a) @@ -2413,15 +2405,8 @@ static bool do_fbpfcc(DisasContext *dc, arg_bcc *a) 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: - 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) From patchwork Tue Oct 17 06:41:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734356 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp331480wro; Mon, 16 Oct 2023 23:45:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUN0354O3lbBm8Hg1AiQEKBK4z03/vO2mu8sC3HSZ/dlnfiKFmm6yP8v7d3Lx+AFhx3oKp X-Received: by 2002:a05:6122:a02:b0:49a:9146:ec02 with SMTP id 2-20020a0561220a0200b0049a9146ec02mr1731422vkn.1.1697525110237; Mon, 16 Oct 2023 23:45:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697525110; cv=none; d=google.com; s=arc-20160816; b=T7nsxNQXO+up6S2/OuSxQ7R4eqMKANeGMRbufLLOX1CGET/gRWC6EcVdD+NjtRkkCV GKp7rfYuaSFHYAeWmQFtvGCflNV5XcLw5ooFSEP4Su2iI7HyJjfPgS7cnhpOOLSW1Ha0 wuZXcXYErTRMn3pDDRrN3mdyNElAgx9Cq4vrtWwh/GXZqlDC4/hztFbPQWivgGsp2J/c SoIDIEUweiZ9P0EjEotZhafwiGdScGBVhW4NBfit16dOzUbHY2sKT+K60rRSNhjJxtB3 NUJym9FcqG6Onzk7nBYUfc38pxqoMk/cecUWLylZqQdeip5jcmFluZN2CLhG/F0Sqyz7 XrxA== 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=PXf3xiousk5WHR4e71h22tpjt54xl4eP0lZ+PfizJBM=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=DfwKkzl/v1TQu9kKWWmdp9JmW8lkNMvhXxEqC0IZ8RvxuUSoWVbZM89Z1KmMxUUbD8 Emd3BUMrQx6XP4yohHv68lLO593CCghJbmrOK/5342+AJbIfa2hILo89WmVxXxkslX7p 9+At4NvizUK377uUA1z9E4SLPpHFxCsBU6bj4OaMHb75ZY9H/phNv1Km1mVbux8h0biE V7g5vjBuJZ7Z79QzZAqLbh60kAmh9U7oGZES2GWUVZZ7ShwhZ1V1Wq1YSw/chwi36Ul8 L4qEWpSdsLvXIcg3eIfZxJfKbKcfbkitFotjwIyX741DHcPXRLJk3ULvwvw6vj2EyUXU 58xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ElS1HURP; 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 b10-20020ac86bca000000b0041cb3f5c40esi94594qtt.756.2023.10.16.23.45.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:45:10 -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=ElS1HURP; 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 1qsdlt-0007wR-5d; Tue, 17 Oct 2023 02:41:42 -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 1qsdld-0007tR-CW for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:28 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdlb-0001sS-Jl for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:25 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1ca82f015e4so10587935ad.1 for ; Mon, 16 Oct 2023 23:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524882; x=1698129682; 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=PXf3xiousk5WHR4e71h22tpjt54xl4eP0lZ+PfizJBM=; b=ElS1HURPdAUq16lSAUwxpKcOjwKKagdfguSdVMCsjILXa4PC4j2RwqR5sVFSDszC5/ S++wSJ/We3sUEY9GrhLZf7LpN0MPFjWhwwCq9OWOPMQqlSey/M0BrSZDyZvVwgsv1eO/ NqCrcTspGHh56t7Qwd7jtXz65FWRgkxhnhBwKLBqpq+VXsBqSmsN/JCO8yFN4JKF3Xgv ZvxqrVawVwmrb4lWBk6SQuy0oB/AM5AO3LTnlMCNGE+KEm2nDiGgmwIuMePLPnxqmi1b 2fzxMUM36hxD6o5mdGzzJnZxFIDkvQS2G6R2KIEUL/POUBcTy+QOcj1P8KTRjTv3negX pfYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524882; x=1698129682; 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=PXf3xiousk5WHR4e71h22tpjt54xl4eP0lZ+PfizJBM=; b=TzfuVvcST2zN2IR6yqtl4x58DqpU8KVdw8J/zyXS4v4MqvKgzpEv6YN3w3dyriOOUq U82yPTXPHEJIQKWXMmfS7PTdMtQp05ywvkDbPfyR4AytB5Q7+LK/Z+trgkS2ynSSLT4i AnXOvhN0Zh9DtbPOquy0iSsBVLcw3Gabx5qeqtcLMx/ZMyrbHWTjFzYwVeua5mSPs9Jv qQqjFGadCGDVHZMbPmc9p1+deni5Qy1H9kUO5WGGDGjUMhstFDV9GOX8KC+tA/Db2PUW YxBVMFCp2+uvLbmH8y1YYKEFER2QyCdnZq6s68d6EpOCg46Kuu+BuI9s4Ad9b+kaZrtn O1NQ== X-Gm-Message-State: AOJu0Yym1Vc+GB0nLG4Y2AF6FVxGP5eH9O4pPRPPWitNPGkTX0rmeDcb 77JS5Z8uUMYHyMrhKInhmri8H9I6ZDZno514d5s= X-Received: by 2002:a17:903:11cc:b0:1ca:362b:1482 with SMTP id q12-20020a17090311cc00b001ca362b1482mr1646060plh.67.1697524881998; Mon, 16 Oct 2023 23:41:21 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 15/20] target/sparc: Use DISAS_EXIT in do_wrpsr Date: Mon, 16 Oct 2023 23:41:04 -0700 Message-Id: <20231017064109.681935-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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/translate.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 53a755874e..18546d3bd2 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -3207,10 +3207,7 @@ TRANS(WRPOWERDOWN, POWERDOWN, do_wr_special, a, supervisor(dc), do_wrpowerdown) static void do_wrpsr(DisasContext *dc, TCGv src) { gen_helper_wrpsr(tcg_env, src); - save_state(dc); - gen_op_next_insn(); - tcg_gen_exit_tb(NULL, 0); - dc->base.is_jmp = DISAS_NORETURN; + dc->base.is_jmp = DISAS_EXIT; } TRANS(WRPSR, 32, do_wr_special, a, supervisor(dc), do_wrpsr) From patchwork Tue Oct 17 06:41:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734354 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp331252wro; Mon, 16 Oct 2023 23:44:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEKjqS/SMdu5dUVmvSWiJ+xM1OEX2JnjtTJon8ZeDCAip7kw1fdqcdwh+ACT/0kY9SpIVrf X-Received: by 2002:a05:622a:18a7:b0:419:5767:af55 with SMTP id v39-20020a05622a18a700b004195767af55mr1904421qtc.16.1697525058239; Mon, 16 Oct 2023 23:44:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697525058; cv=none; d=google.com; s=arc-20160816; b=KkRrazNzKkRJwGZ59ovfbCdLdO/vAyaPjlIoViwnZiUpf5NmQ/Z6f+Nye1rLOea2rn p139ac7vvXEL16XthDT/RMeDClkgCUCDQUAYVr23GAmC/6VDAV6Jv6CqiUxemn2I2fxM fjwY5gr9PKzguBTwN0mFgNBQi3YZvHMGjHNHZNBkz/E7oiISiojx00lJZEXeLFulXOYA aKEKJAp8sf0RlK0iga3QlBf4HgsAVmndnGPBoZ6wFQXlLV3NX2e49JYhTpmr/43nIs/U RcR8BpQmHuOMLQXSgQlo7TwXd+RwuVhLhjqk+kDr4DH3FfoqFodAGTzXLuARqtdI+W/W wUNg== 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=ESxuAUufQZOaFJVJzjW21Tj1f8ibVF8SktLSFdxgc2A=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=mqhJ54MxFmvqYi7iiF+7/c6coHTY8jpxPXBQEapCF/66PlJR9fQ9PK6yO9HzofF1kw 32WY6+9LIwgTYC4wxv3kd+RY6V9niYpLmb9zpNgakLui4Mbr0Ctb7cIoNYllAPdJAEp/ gmBuNMg8Yzbso4FL416/Y4T0kYqtda7INEOwQji0IxHppbBqOgsUn6yR+WocW7JM64YW HiLigVE9Ve6GCZ3K1GjqLlk6r//HUkKs6NR9Qb39W+f56qVGXztlxOovo/ygp8bSHmid 6DW2h4he6cIUlvCXa2N5tYxuQ0LuKBjhPXrPrNBcpINVKGmppTWNM4B8MdaJ0lgZww8v qNYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="AFZMIs/r"; 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 d14-20020ac85d8e000000b004180054f084si669764qtx.74.2023.10.16.23.44.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:44:18 -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="AFZMIs/r"; 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 1qsdlz-0007wc-ML; Tue, 17 Oct 2023 02:41:47 -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 1qsdle-0007tk-Ie for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:28 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdld-0001sc-0P for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:26 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1c871a095ceso36064015ad.2 for ; Mon, 16 Oct 2023 23:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524882; x=1698129682; 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=ESxuAUufQZOaFJVJzjW21Tj1f8ibVF8SktLSFdxgc2A=; b=AFZMIs/ryjjc62c4GswLH+YOdyq2HW7ZtkV6Zl0YhoCO+lAkIJ4qKpjQWOaWY4dUy0 oN6DCQmj8ldemuyERgoPGs3FCPc00UoQtdzxzQZT9+MbDGXbt1wUXV1zbfSSk+u7r3o0 OKz9u7wKFa7DyixVxkMIJCkI/MVMvEfnNkF477zL9paQPMNgAcRrT/3IPF7m/kXEUnir etWDSJBXzjJBO8OpsLNR3LUCZfnGkZyWJzBQ+pIPcjJCCxkuEgZpATGdMjp8xLtx/h1u bufeHKQdI8Byii1YidXntz+mo8JWIFVUZAFm8Lfs7XVor0AX+xO1UJxxJW90GN2qPaXi nNJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524882; x=1698129682; 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=ESxuAUufQZOaFJVJzjW21Tj1f8ibVF8SktLSFdxgc2A=; b=CD/uLtqfF3DuhwdFJdmCUJuuCNSvUhrJ6sxbpFKj6WnsbHSJBPCiRxBUEpZkoaOCok C/wAAiXGw73LHrrKO7mlkneO9UE/Cao+jvb13S/VTVtcz0sYRtCmqZRFF8aucf+jQBkH FQ5O6gDUy+Ru92v+MQAlXQ5fDHtYvnHme6AKxGY7lskOMZzuDzzD11maC1ugipAr5hlR vcnFyU7GZrNI/yF3uysmgvs162R/wDG3n8epxA+WMmeuOPnEQV1+bcq2abTr9yXSpXrF TLjnnKI3V/e0RuYhglV1YXTzMpfyyIITCs8KBX3Ki6IrHa0v/wEso7J+CiAHp0Evs2Wm C9AA== X-Gm-Message-State: AOJu0YxAUgDLngusYs0aF+tbr+vuZ78iVpBfsEt2g8yJaFtFGAObOeFq zoICB8kenqoLc9Bg1hx7DXPmfUSZakmBINYnPC0= X-Received: by 2002:a17:903:110d:b0:1c9:e774:58d1 with SMTP id n13-20020a170903110d00b001c9e77458d1mr1542367plh.36.1697524882716; Mon, 16 Oct 2023 23:41:22 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 16/20] target/sparc: Merge gen_op_next_insn into only caller Date: Mon, 16 Oct 2023 23:41:05 -0700 Message-Id: <20231017064109.681935-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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/translate.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 18546d3bd2..8a92fa4a1a 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -953,12 +953,6 @@ static void gen_mov_pc_npc(DisasContext *dc) } } -static void gen_op_next_insn(void) -{ - tcg_gen_mov_tl(cpu_pc, cpu_npc); - tcg_gen_addi_tl(cpu_npc, cpu_npc, 4); -} - static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond, DisasContext *dc) { @@ -2254,7 +2248,8 @@ static bool advance_pc(DisasContext *dc) case DYNAMIC_PC: case DYNAMIC_PC_LOOKUP: dc->pc = dc->npc; - gen_op_next_insn(); + tcg_gen_mov_tl(cpu_pc, cpu_npc); + tcg_gen_addi_tl(cpu_npc, cpu_npc, 4); break; case JUMP_PC: From patchwork Tue Oct 17 06:41:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734360 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp331965wro; Mon, 16 Oct 2023 23:46:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQnbaW6NW/FEzpoRwmwb7ql/nU4Mua1hjDDqpAkRHuIMtJBy6JPPquqJy8HuKwW+5AOjhv X-Received: by 2002:a05:6214:d4d:b0:65c:fec4:30a1 with SMTP id 13-20020a0562140d4d00b0065cfec430a1mr2320250qvr.55.1697525206291; Mon, 16 Oct 2023 23:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697525206; cv=none; d=google.com; s=arc-20160816; b=S/0a0qqa9I9v9hSCJy079BJapFzZt89M7oyRhmUYufI40t862McwAxLbc+o2lLMcs0 kdxtmhHMO+TlVkrlsJvTtNU8kFRKgRQNuWj3oAaknSl5UgaHF2HREiFB+D9/yAwUcyTM 96I/nCLPr6GSYSNGQHCeyigf4gYM8gQ9GSji9JzVLdqATrJ5CvW6mYsDfRRPT9gLXvFt FzPJownm2OcRDQ5afgyt8/8ZiAKLNPx/m/ABwzsjVAL1QtLqzIqgUaYMPV7TqaicvIm0 FPZthuzPeoHbj/Qw+7+0PzAG2k8WrSuFYBOJL1PyoYPXXE10axiuUv8fHx3aTvLobeWG lwOg== 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=Ye55zVt3/R/BevwAdDu8QM2ZndN+yEEyw8ybj2p0Xcc=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=CLrzletF1KoBoXXUwlEfPeSiq6boXtCTaOFwQ+uKg8lmT33YzIzGewadc5YtEESE4P zQ+NeV8NX3x6aw6aI6e4lonCWxmc5+4D2mVM5YCSd/WP72tkSolvbupOiDmYO4XtIbZ2 tz7G7UgWrV7CHxDfBqvRjOZlKpgk+ZiXFgupQK305Kt8XG++oZgXj5ETu/v+WBArkAQT sRMqQYtO6lGMNmaD21+TJSv98kijstxutZOGFC2tB12wZNSOs4FdBRPib39Nt9pbnES8 2MO5+WfQ9Di648vAAZM2MpuL8uDNXkNC5CCd7Pt4arvWcvPvlCtGJJW0ajs1d2v/3bCO Y4nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S7SNwd5H; 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 ek7-20020ad45987000000b0066d6b153797si549340qvb.233.2023.10.16.23.46.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:46:46 -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=S7SNwd5H; 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 1qsdlu-0007wV-WF; Tue, 17 Oct 2023 02:41:43 -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 1qsdlf-0007tp-WF for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:28 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdld-0001sz-QI for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:27 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1ca82f015e4so10588115ad.1 for ; Mon, 16 Oct 2023 23:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524883; x=1698129683; 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=Ye55zVt3/R/BevwAdDu8QM2ZndN+yEEyw8ybj2p0Xcc=; b=S7SNwd5Hy0gssronVMl2Xk8Nihw24RAy4sh1GvUCK6uOvEZvhCEq1CE4SuTAFXWLPu klITMz6220YBGKglrwUSDMEPafGWAT1pO8qruaeQ2VYE1/G5nb8oXKdJMhimfrfrbY4q vREbp6U0Xux4hHodgwAogFnFdrmmqzZVMuTsS53W5QYZ/cUoBi3fhTpRFpxmL4CEa+9w +s9bAUd5fMRjzsTYQhJjTn9NYI2hO0AVUoVXm7RPJO2iInKk6IFLQD1Yh7G20hYtGzQ+ rgTqBwnl7w6l1klYqt7bMK1Q34HMDDqtpmnK7AKR/ibpqOAN0K93j1C3zRKnPUyXn9nG BuPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524883; x=1698129683; 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=Ye55zVt3/R/BevwAdDu8QM2ZndN+yEEyw8ybj2p0Xcc=; b=SdBlqxaXChosGEyCAE5CgHjl2RC9yeVuGNNIxvPYiwr4r2m8dv5yZHxfyvThh3mAjl b4r/uJIGedsatOQBt1QoZUpk7oz/iNH8qcL3GlsSu2Q5jo0be1g4Icdfh4NSXUqj9zbZ puPe1C81bMnf48pYqoQMReBvryZC++d0ukpuDd52VmnDwD67fofSZZSdQkKTPpwWXNEl N1jN8kjk4glioJOgDif+ri13/vPGjvWMbRm2L/lHMxyXBLLA+kxa9XwkzKe+B5dBPDh/ B8mT7ZRFIQl0Hy2BKe4P/m1JoovhLIyxxHS12nc9kGolPwC1kfnlqTVquobNleWyUlYZ SXtQ== X-Gm-Message-State: AOJu0YyigR244X2E1bHaOEJoWSlb9FoUt0tEEbzAHWmsdohxN1FQY6+l IrgDQvduX7G0/SUaB5v4lyR+45Qme7FCV+r4WSs= X-Received: by 2002:a17:902:d2ca:b0:1c7:8446:d65c with SMTP id n10-20020a170902d2ca00b001c78446d65cmr1633123plc.43.1697524883533; Mon, 16 Oct 2023 23:41:23 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 17/20] target/sparc: Record entire jump condition in DisasContext Date: Mon, 16 Oct 2023 23:41:06 -0700 Message-Id: <20231017064109.681935-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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 Use the original condition instead of consuming cpu_cond, which will now only be live along exception paths. Signed-off-by: Richard Henderson --- target/sparc/translate.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 8a92fa4a1a..bdf1753a65 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -149,6 +149,12 @@ static TCGv cpu_wim; /* Floating point registers */ static TCGv_i64 cpu_fpr[TARGET_DPREGS]; +typedef struct DisasCompare { + TCGCond cond; + TCGv c1; + int c2; +} DisasCompare; + typedef struct DisasDelayException { struct DisasDelayException *next; TCGLabel *lab; @@ -162,7 +168,11 @@ typedef struct DisasContext { DisasContextBase base; target_ulong pc; /* current Program Counter: integer or DYNAMIC_PC */ target_ulong npc; /* next PC: integer or DYNAMIC_PC or JUMP_PC */ - target_ulong jump_pc[2]; /* used when JUMP_PC pc value is used */ + + /* Used when JUMP_PC value is used. */ + DisasCompare jump; + target_ulong jump_pc[2]; + int mem_idx; bool fpu_enabled; bool address_mask_32bit; @@ -181,12 +191,6 @@ typedef struct DisasContext { DisasDelayException *delay_excp_list; } DisasContext; -typedef struct { - TCGCond cond; - TCGv c1; - int c2; -} DisasCompare; - // This function uses non-native bit order #define GET_FIELD(X, FROM, TO) \ ((X) >> (31 - (TO)) & ((1 << ((TO) - (FROM) + 1)) - 1)) @@ -850,9 +854,9 @@ static void gen_generic_branch(DisasContext *dc) { TCGv npc0 = tcg_constant_tl(dc->jump_pc[0]); TCGv npc1 = tcg_constant_tl(dc->jump_pc[1]); - TCGv zero = tcg_constant_tl(0); + TCGv c2 = tcg_constant_tl(dc->jump.c2); - tcg_gen_movcond_tl(TCG_COND_NE, cpu_npc, cpu_cond, zero, npc0, npc1); + tcg_gen_movcond_tl(dc->jump.cond, cpu_npc, dc->jump.c1, c2, npc0, npc1); } /* call this function before using the condition register as it may @@ -2255,7 +2259,7 @@ static bool advance_pc(DisasContext *dc) case JUMP_PC: /* we can do a static jump */ l1 = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_NE, cpu_cond, 0, l1); + tcg_gen_brcondi_tl(dc->jump.cond, dc->jump.c1, dc->jump.c2, l1); /* jump not taken */ gen_goto_tb(dc, 1, dc->jump_pc[1], dc->jump_pc[1] + 4); @@ -2339,9 +2343,10 @@ static bool advance_jump_cond(DisasContext *dc, DisasCompare *cmp, } } else { dc->pc = npc; + dc->npc = JUMP_PC; + dc->jump = *cmp; dc->jump_pc[0] = dest; dc->jump_pc[1] = npc + 4; - dc->npc = JUMP_PC; /* The condition for cpu_cond is always NE -- normalize. */ if (cmp->cond == TCG_COND_NE) { From patchwork Tue Oct 17 06:41:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734352 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp331098wro; Mon, 16 Oct 2023 23:43:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFYAR0TPGQk6bMoZTA4+RK4SsizbCU5unZiXmMGSV4OvfUBZ1IKydk/AhfmRSTWURfN087d X-Received: by 2002:ad4:4ee7:0:b0:66d:66d5:7f83 with SMTP id dv7-20020ad44ee7000000b0066d66d57f83mr1721846qvb.63.1697525028585; Mon, 16 Oct 2023 23:43:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697525028; cv=none; d=google.com; s=arc-20160816; b=hm1yGSu31B5SYULHKJfEiGE8lFNyqP+ZnpagZOUh6gdzcoZZtHopeQu0H/XWhOGpJa VF6fNW8Rzun8ZhRco22AP8NL1EqQLa+/noQLgzHonPXUI27crRZp8OhXDYOrnU/9NWvk lhgbB9JyqM48Gc/0qe4z1IDiTwtNU6KxthAFSwshCnxRnY6yCS0kfJAl+QHXxaI+J5AM symC/mmXQ1wCtFsMwksAvpLxn/aMrc45+4gi1C3EpaKAxIBm0UpVFB2CU1xmGbS6MINn Jiha4ymzPgsfg1ECidHy+Acg2gQ03Ta3Oyt+NCuaCn1BRg+wa9IVXIZdHeKKq2EXu53a IqDQ== 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=xdO1Knle14XvqVU+j8YkOQCebKjxdVqO128wtqqFIi0=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=dLRBSMdOK7iXbraOZ6FFgKRLdDs7S2DPs/6pcz3Bi4bM3HofuD8BiyoGe23EpmhSHM aAhoqkzODh3GH+soTGODhvE0Lvbm67cSpIxz0EghEu+jDD0FhornUrsEos135IYgxyLS xvQ2HdEV5ra3xG2Uxp2KREBuxOs4qWpKrNqYUqLVU3blEtoJjNAHk9cofbR6ARHWMHVY qq0pSGSklxBUPVlKl/ZCo2CYvGqHKvT9t+11fXmskLzl73tQ6LDtpbodcEhBTdu0wYTH nL7QC0J/J77UCzLLhnTGXKI3xskZx3KG99lgEH3g6GB/Y/hI1nCcVPb0NMa/mjFI1isu 15RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PSMsELF6; 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 k2-20020ad44502000000b0066ad6036429si550352qvu.554.2023.10.16.23.43.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:43:48 -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=PSMsELF6; 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 1qsdlt-0007wM-4h; Tue, 17 Oct 2023 02:41:42 -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 1qsdlf-0007tm-9d for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:28 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdld-0001tD-Jp for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:27 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1c0ecb9a075so35034525ad.2 for ; Mon, 16 Oct 2023 23:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524884; x=1698129684; 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=xdO1Knle14XvqVU+j8YkOQCebKjxdVqO128wtqqFIi0=; b=PSMsELF62IDQ0n9O2uI9Vq+GAbTVS1fnUNEKhnahrlN9O9ec9mxq0u1jZDxaO6V1qW 0TCCL9z6sjUip8SmltVHhcb6P+KyjvdaFFwO0hlIi1o1BUzDfsePU8ZdSGaFVyejf/L4 RMklJSvE6VgTpZEAMmZiiD835WffigJw7KIhPSEAqrxjPld3D2nfDwiUKLqnepDhsXIv 0jJVTaaEMkjxTpojJsSR/tHO1DmZJJv6k266SragkST1mwxPBMcCoM5tMisaGJBXqevD dZPRNsMELQ+gUNpoD7XQVVUoSHT02LuHVnFAyYNdfG1jeKcadaAadWVX/H+5v2U2NGxF NAsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524884; x=1698129684; 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=xdO1Knle14XvqVU+j8YkOQCebKjxdVqO128wtqqFIi0=; b=pxUxXtnTU3Uf3x364AIMRhswxD+XH4g+qYN9+v203CM/2GdbnELMV4BP3XUoLCILya TIOe4tVzDwlZpLNMOHiUE+MgCzMbTEvt3k9v8C2yBXEXZv16B4j4IeKcPZZyqHINsuj4 VOABF+M/3h7ED3Eq9O8e1D9BBTcbNcg0a/4nOGXkuy3RnTYMSx2hRVq4ox30r3oPcp/D TUagtXw8wG622dCJHamV9VgNF/gwPvOCm+7mlne2Zvs5hDioVVBsH1CDBbK8//UTnHhE Cp3J/ddXAKz7oa7gtaa1hWtCJkb0Er0k5I0+jLOs+PfdDsHwZO8Q4KxLR5534JmehEWZ lVVQ== X-Gm-Message-State: AOJu0YyDWc7iC3mAr31LtzgReDeX0aVULmoO+Dc7cB1NOq0yfpUl9Y1q Gj5/uKrjMtyq5PmH4QXgMIZ1QB1zHOHpK0fNIJs= X-Received: by 2002:a17:902:d091:b0:1ca:abd:1c1e with SMTP id v17-20020a170902d09100b001ca0abd1c1emr1263367plv.23.1697524884349; Mon, 16 Oct 2023 23:41:24 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 18/20] target/sparc: Discard cpu_cond at the end of each insn Date: Mon, 16 Oct 2023 23:41:07 -0700 Message-Id: <20231017064109.681935-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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 If the insn raises no exceptions, there will be no path in which cpu_cond is used, and so the computation may be optimized away. Signed-off-by: Richard Henderson --- target/sparc/translate.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index bdf1753a65..9f53e703e6 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -174,6 +174,7 @@ typedef struct DisasContext { target_ulong jump_pc[2]; int mem_idx; + bool cpu_cond_live; bool fpu_enabled; bool address_mask_32bit; #ifndef CONFIG_USER_ONLY @@ -850,6 +851,19 @@ static void gen_op_eval_fbo(TCGv dst, TCGv src, unsigned int fcc_offset) tcg_gen_xori_tl(dst, dst, 0x1); } +static void finishing_insn(DisasContext *dc) +{ + /* + * From here, there is no future path through an unwinding exception. + * If the current insn cannot raise an exception, the computation of + * cpu_cond may be able to be elided. + */ + if (dc->cpu_cond_live) { + tcg_gen_discard_tl(cpu_cond); + dc->cpu_cond_live = false; + } +} + static void gen_generic_branch(DisasContext *dc) { TCGv npc0 = tcg_constant_tl(dc->jump_pc[0]); @@ -896,6 +910,7 @@ static void save_state(DisasContext *dc) static void gen_exception(DisasContext *dc, int which) { + finishing_insn(dc); save_state(dc); gen_helper_raise_exception(tcg_env, tcg_constant_i32(which)); dc->base.is_jmp = DISAS_NORETURN; @@ -937,6 +952,8 @@ static void gen_check_align(DisasContext *dc, TCGv addr, int mask) static void gen_mov_pc_npc(DisasContext *dc) { + finishing_insn(dc); + if (dc->npc & 3) { switch (dc->npc) { case JUMP_PC: @@ -2247,6 +2264,8 @@ static bool advance_pc(DisasContext *dc) { TCGLabel *l1; + finishing_insn(dc); + if (dc->npc & 3) { switch (dc->npc) { case DYNAMIC_PC: @@ -2290,6 +2309,8 @@ static bool advance_jump_cond(DisasContext *dc, DisasCompare *cmp, { target_ulong npc = dc->npc; + finishing_insn(dc); + if (cmp->cond == TCG_COND_ALWAYS) { if (annul) { dc->pc = dest; @@ -2354,6 +2375,7 @@ static bool advance_jump_cond(DisasContext *dc, DisasCompare *cmp, } else { tcg_gen_setcondi_tl(cmp->cond, cpu_cond, cmp->c1, cmp->c2); } + dc->cpu_cond_live = true; } } return true; @@ -2520,6 +2542,8 @@ static bool trans_Tcc(DisasContext *dc, arg_Tcc *a) tcg_gen_addi_i32(trap, trap, TT_TRAP); } + finishing_insn(dc); + /* Trap always. */ if (a->cond == 8) { save_state(dc); @@ -3198,6 +3222,7 @@ TRANS(WRSTICK_CMPR, 64, do_wr_special, a, supervisor(dc), do_wrstick_cmpr) static void do_wrpowerdown(DisasContext *dc, TCGv src) { + finishing_insn(dc); save_state(dc); gen_helper_power_down(tcg_env); } @@ -5148,6 +5173,8 @@ static void sparc_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) DisasDelayException *e, *e_next; bool may_lookup; + finishing_insn(dc); + switch (dc->base.is_jmp) { case DISAS_NEXT: case DISAS_TOO_MANY: From patchwork Tue Oct 17 06:41:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734353 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp331231wro; Mon, 16 Oct 2023 23:44:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG6tp9hDxob8YL2qIzzMu7ZRyl4zD1s16lJAwKPvSwS1dGFFkupIPwZ5UpAELZSSbxDrqPV X-Received: by 2002:a05:620a:f0c:b0:775:ed1e:2741 with SMTP id v12-20020a05620a0f0c00b00775ed1e2741mr1642252qkl.7.1697525055019; Mon, 16 Oct 2023 23:44:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697525055; cv=none; d=google.com; s=arc-20160816; b=QXD+f31z1y+KVU3yEHkp2lPUICgk8rvOe/TgsjndwqZgRvOgNnSN2qmxLSJXNmCpD4 qO0ar9X0Cvb7wz0kDsn2u2ENRD3b2zK8s+n/908t2Wdkzf+JzhAvbmmCdPPUE8ar7LoL RKlGkflKRptnL0mbeGq2IC32fdLLvkfIYTOyF5MOPWIglt1iKVln9msbxIwdc1r9vFDJ 2mo3tb2u8jc4YBZT/tcqfCQu38kIL6DsFFxo52dq2RO76sopeWH3yVa/rfBbRhs20J0o /z0GwZ1PZyhboQIZerLUfvHM+/jM0yxzeJiC844qUwVhlLYb2skfOWdPvk3pgk/DTkDe 20Kw== 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=ShJyWywDcW6kwGEIx4axsLzYdlXE0bNbLMVVcliJbPE=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=WHRhWswk/oYYfHKPGjGxUTKzd2YGTEg+T4IQt/e9qtsPVeHYuRbkj7Nud38tHGgVwU LP7ybUoW/XzWQLXhHM1eQs73N4Y0pDUmvzVErljbRdWWJ14XPfE07grCd/GD8GL4JsYA jUbO3PQUtWAqPUJMe3NtXxxRnUfZw4XWdh559I/OIz4Blgb/KXCZC1Ddd8UfXOKV9y7X 6B5Yv7Fz18HwCp6g3w/bKi5DbmSRijKW9C1ryc2AddozZkmoQ6u3VudCwlARC/oStLUO HwJKfOcaw36nMO/RS5d4jgmPdqJ7fUkr3BmHmEfmyvNVkd6cQmX6jZeh04SriBkgCe1e Ys2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bS6Bl90Y; 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 m20-20020a05620a24d400b00765aa805255si616572qkn.740.2023.10.16.23.44.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:44:14 -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=bS6Bl90Y; 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 1qsdm1-0007x3-8J; Tue, 17 Oct 2023 02:41:49 -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 1qsdlk-0007vF-86 for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:36 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdle-0001tb-SC for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:31 -0400 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-578b4981526so3146751a12.0 for ; Mon, 16 Oct 2023 23:41:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524885; x=1698129685; 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=ShJyWywDcW6kwGEIx4axsLzYdlXE0bNbLMVVcliJbPE=; b=bS6Bl90YpyO9xKL/ecqOqSUn4M38UnrAjgEBcRqPRBUWSMnQRb6ne32gPO9sFbov7d fQhzKGidGZ99CxW+SHN0I7Tlg1+WGIyknoP6+H4rHSd5Eujzdo8pAmsnsza/D8IzEoTF aI+ZHxXcL6Fxpfofv3fjhFBZtJdoYQZiD8/Dkila6gj/0hhUnkQ8ep+1rxTVpHNgiI/e 9l81ju+71vZ5yIykTYWWRuJCNtTT8mTYYNd3yFnxIV+BpvA/d8QLqLChbRL+iYIRo5f+ LDN1yo+TfYqXg7lgCBmuhsDYDS35wL/n0kFP2HgVy4EieEoX4M03Qvt7NvJqTp2GpXud k0pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524885; x=1698129685; 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=ShJyWywDcW6kwGEIx4axsLzYdlXE0bNbLMVVcliJbPE=; b=HzS1MwuBXaXAMZBtQaSjAclXSbcWiYTeffc/WKQvy+LsduJYVre21E/PidG2rbUs6l S0MByU3ao9gYUMT00GX8J1cKbt+3YI5HbcPJKdYXZ+x+DYhKViM+hCBU5k7FvqJvWG8o v7/lvs5cBhZZReeSTHMxs6R0rjjlzj/RtVQenLZN0c4XDCmssjZqO7/8eWfRprk0VN9K Pv+e3U8XiF5q89a4vRrjEBwg7Wqz/z7y1cgHO9IJxrtdBB0Udbt8y9KAxV+B0XxpFXYw Pg+zfrB9Vl8qD6iYAKn9quGLlvLeLik7jvm98YadFn+1uqwDa9rnuj6KJ32N2gHqVZyY n3IA== X-Gm-Message-State: AOJu0YzZgSbf2LwElD6VyIrRxeo1XwLhjOtHUmiWYDpHe8DsYab8rdS8 7h26MeR92vCkhVO4N/i/pszEunxcoS5werz04Z8= X-Received: by 2002:a05:6a20:4429:b0:153:a461:d96e with SMTP id ce41-20020a056a20442900b00153a461d96emr1433607pzb.47.1697524885024; Mon, 16 Oct 2023 23:41:25 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 19/20] target/sparc: Implement UDIVX and SDIVX inline Date: Mon, 16 Oct 2023 23:41:08 -0700 Message-Id: <20231017064109.681935-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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, T_SPF_TEMPERROR=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 Signed-off-by: Richard Henderson --- target/sparc/helper.h | 4 -- target/sparc/helper.c | 24 --------- target/sparc/translate.c | 109 ++++++++++++++++++++++++++++++++++----- 3 files changed, 95 insertions(+), 42 deletions(-) diff --git a/target/sparc/helper.h b/target/sparc/helper.h index 6415942e03..12181d1106 100644 --- a/target/sparc/helper.h +++ b/target/sparc/helper.h @@ -33,10 +33,6 @@ DEF_HELPER_3(udiv_cc, tl, env, tl, tl) DEF_HELPER_3(sdiv_cc, tl, env, tl, tl) DEF_HELPER_3(taddcctv, tl, env, tl, tl) DEF_HELPER_3(tsubcctv, tl, env, tl, tl) -#ifdef TARGET_SPARC64 -DEF_HELPER_FLAGS_3(sdivx, TCG_CALL_NO_WG, s64, env, s64, s64) -DEF_HELPER_FLAGS_3(udivx, TCG_CALL_NO_WG, i64, env, i64, i64) -#endif #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64) DEF_HELPER_FLAGS_4(ld_asi, TCG_CALL_NO_WG, i64, env, tl, int, i32) DEF_HELPER_FLAGS_5(st_asi, TCG_CALL_NO_WG, void, env, tl, i64, int, i32) diff --git a/target/sparc/helper.c b/target/sparc/helper.c index 4887f295a5..3830d01634 100644 --- a/target/sparc/helper.c +++ b/target/sparc/helper.c @@ -177,30 +177,6 @@ target_ulong helper_sdiv_cc(CPUSPARCState *env, target_ulong a, target_ulong b) return do_sdiv(env, a, b, 1, GETPC()); } -#ifdef TARGET_SPARC64 -int64_t helper_sdivx(CPUSPARCState *env, int64_t a, int64_t b) -{ - if (b == 0) { - /* Raise divide by zero trap. */ - cpu_raise_exception_ra(env, TT_DIV_ZERO, GETPC()); - } else if (b == -1) { - /* Avoid overflow trap with i386 divide insn. */ - return -a; - } else { - return a / b; - } -} - -uint64_t helper_udivx(CPUSPARCState *env, uint64_t a, uint64_t b) -{ - if (b == 0) { - /* Raise divide by zero trap. */ - cpu_raise_exception_ra(env, TT_DIV_ZERO, GETPC()); - } - return a / b; -} -#endif - target_ulong helper_taddcctv(CPUSPARCState *env, target_ulong src1, target_ulong src2) { diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 9f53e703e6..b344422f8a 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -65,8 +65,6 @@ #define gen_helper_fabsd(D, S) qemu_build_not_reached() #define gen_helper_done(E) qemu_build_not_reached() #define gen_helper_retry(E) qemu_build_not_reached() -#define gen_helper_udivx(D, E, A, B) qemu_build_not_reached() -#define gen_helper_sdivx(D, E, A, B) qemu_build_not_reached() #define gen_helper_fmul8x16 ({ g_assert_not_reached(); NULL; }) #define gen_helper_fmul8x16au ({ g_assert_not_reached(); NULL; }) #define gen_helper_fmul8x16al ({ g_assert_not_reached(); NULL; }) @@ -578,16 +576,6 @@ static void gen_op_smul(TCGv dst, TCGv src1, TCGv src2) gen_op_multiply(dst, src1, src2, 1); } -static void gen_op_udivx(TCGv dst, TCGv src1, TCGv src2) -{ - gen_helper_udivx(dst, tcg_env, src1, src2); -} - -static void gen_op_sdivx(TCGv dst, TCGv src1, TCGv src2) -{ - gen_helper_sdivx(dst, tcg_env, src1, src2); -} - static void gen_op_udiv(TCGv dst, TCGv src1, TCGv src2) { gen_helper_udiv(dst, tcg_env, src1, src2); @@ -3627,8 +3615,6 @@ TRANS(XORN, ALL, do_arith, a, tcg_gen_eqv_tl, NULL) TRANS(MULX, 64, do_arith, a, tcg_gen_mul_tl, tcg_gen_muli_tl) TRANS(UMUL, MUL, do_arith, a, gen_op_umul, NULL) TRANS(SMUL, MUL, do_arith, a, gen_op_smul, NULL) -TRANS(UDIVX, 64, do_arith, a, gen_op_udivx, NULL) -TRANS(SDIVX, 64, do_arith, a, gen_op_sdivx, NULL) TRANS(UDIV, DIV, do_arith, a, gen_op_udiv, NULL) TRANS(SDIV, DIV, do_arith, a, gen_op_sdiv, NULL) TRANS(ADDC, ALL, do_arith, a, gen_op_addc, NULL) @@ -3656,6 +3642,101 @@ TRANS(ADDCcc, ALL, do_arith, a, gen_op_addccc, NULL) TRANS(SUBCcc, ALL, do_arith, a, gen_op_subccc, NULL) TRANS(MULScc, ALL, do_arith, a, gen_op_mulscc, NULL) +static bool trans_UDIVX(DisasContext *dc, arg_r_r_ri *a) +{ + TCGv dst, src1, src2; + + if (!avail_64(dc)) { + return false; + } + /* For simplicity, we under-decoded the rs2 form. */ + if (!a->imm && a->rs2_or_imm & ~0x1f) { + return false; + } + + if (unlikely(a->rs2_or_imm == 0)) { + gen_exception(dc, TT_DIV_ZERO); + return true; + } + + if (a->imm) { + src2 = tcg_constant_tl(a->rs2_or_imm); + } else { + TCGLabel *lab; + + finishing_insn(dc); + flush_cond(dc); + + lab = delay_exception(dc, TT_DIV_ZERO); + src2 = cpu_regs[a->rs2_or_imm]; + tcg_gen_brcondi_tl(TCG_COND_EQ, src2, 0, lab); + } + + dst = gen_dest_gpr(dc, a->rd); + src1 = gen_load_gpr(dc, a->rs1); + + tcg_gen_divu_tl(dst, src1, src2); + gen_store_gpr(dc, a->rd, dst); + return advance_pc(dc); +} + +static bool trans_SDIVX(DisasContext *dc, arg_r_r_ri *a) +{ + TCGv dst, src1, src2; + + if (!avail_64(dc)) { + return false; + } + /* For simplicity, we under-decoded the rs2 form. */ + if (!a->imm && a->rs2_or_imm & ~0x1f) { + return false; + } + + if (unlikely(a->rs2_or_imm == 0)) { + gen_exception(dc, TT_DIV_ZERO); + return true; + } + + dst = gen_dest_gpr(dc, a->rd); + src1 = gen_load_gpr(dc, a->rs1); + + if (a->imm) { + if (unlikely(a->rs2_or_imm == -1)) { + tcg_gen_neg_tl(dst, src1); + gen_store_gpr(dc, a->rd, dst); + return advance_pc(dc); + } + src2 = tcg_constant_tl(a->rs2_or_imm); + } else { + TCGLabel *lab; + TCGv t1, t2; + + finishing_insn(dc); + flush_cond(dc); + + lab = delay_exception(dc, TT_DIV_ZERO); + src2 = cpu_regs[a->rs2_or_imm]; + tcg_gen_brcondi_tl(TCG_COND_EQ, src2, 0, lab); + + /* + * Need to avoid INT64_MIN / -1, which will trap on x86 host. + * Set SRC2 to 1 as a new divisor, to produce the correct result. + */ + t1 = tcg_temp_new(); + t2 = tcg_temp_new(); + tcg_gen_setcondi_tl(TCG_COND_EQ, t1, src1, (target_long)INT64_MIN); + tcg_gen_setcondi_tl(TCG_COND_EQ, t2, src2, -1); + tcg_gen_and_tl(t1, t1, t2); + tcg_gen_movcond_tl(TCG_COND_NE, t2, t1, tcg_constant_tl(0), + tcg_constant_tl(1), src2); + src2 = t2; + } + + tcg_gen_div_tl(dst, src1, src2); + gen_store_gpr(dc, a->rd, dst); + return advance_pc(dc); +} + static TCGv gen_rs2_or_imm(DisasContext *dc, bool imm, int rs2_or_imm) { /* For simplicity, we under-decoded the rs2 form. */ From patchwork Tue Oct 17 06:41:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 734350 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp330795wro; Mon, 16 Oct 2023 23:42:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmOrokIVJjVWosfTLrERRJ0tTYYoFDO20dFqotjONgLMfzgP5PhwSIgQg0szH7Ej6B4ofI X-Received: by 2002:a05:622a:190f:b0:418:c70:113e with SMTP id w15-20020a05622a190f00b004180c70113emr1786236qtc.40.1697524972214; Mon, 16 Oct 2023 23:42:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697524972; cv=none; d=google.com; s=arc-20160816; b=Ea3BS3/KF5l1qdr4jSd4KXhvw3jZIoySr1zkqqarKPTflHYTN51xTYCSq7uYsEBX1B fR6iSPpxF+dIxPJwUQrY3NqgIoxqvOgs3SHl6byCpMsFVdd9WSJ9Cdz5eMuWeKz8iObk ML0Ip4IqUjsMR5sqXiKMwf4bW+sV2c90GfFBPwfjFAnyyvy2jBkKzk201lRnJrP2BJzc i+KF6XFqIQLcx07tYtr5X9XODO+C4m4fux/o0QIxpOuo/QatiCYG89+KADVAGC62NPOR rB+y7lud5fRLQiK/zKcBPOPE1ildwtQzUUzk39TEMT4ggq59/oX0x1M+47Mwiv2aN2BQ 5g5A== 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=DqBVSa7X7Vl34L7v0vos+xD696qr1VhHUKnTWS4HUqY=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=JT8WUQJCJ1/71r5LQg27DOrg0F6rwjrv8+KWgV4c4mHFXXJ182RP8fCxLPNgQeJFqA izAi3Y1d0XL60DAl5aEGIggk4DPXlxik2IJs2ZSQ389zCKqykz/12+zPGmN1Bnv2GxQH MozPIKkv3hT2p17ZYnTlibcjP83tJkgUAT87dlokC06g6C9QgfsCFPAlIoPrFiX8Tday uLCrCFtKE9KcwJ/+OHfmt4fQTCuuXei+3p3W4k8C9kx/FO4MbxZgXgCRbsa3Qzk2hEVC /SxpyiKfMnQbSMFw+GI4jj57CeKO8gE0zF49hK/POQ+EuLProhJnu2T0gr6bQOUGnalI SgwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CZo+PXoJ; 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 y20-20020a05622a005400b00418040a82f8si667845qtw.156.2023.10.16.23.42.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2023 23:42: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=CZo+PXoJ; 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 1qsdmI-00086m-B7; Tue, 17 Oct 2023 02:42:06 -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 1qsdlj-0007vD-R8 for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:35 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsdle-0001ti-SJ for qemu-devel@nongnu.org; Tue, 17 Oct 2023 02:41:31 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1ca3a54d2c4so21126105ad.3 for ; Mon, 16 Oct 2023 23:41:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697524885; x=1698129685; 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=DqBVSa7X7Vl34L7v0vos+xD696qr1VhHUKnTWS4HUqY=; b=CZo+PXoJvCEUGjdT3X+Gn2ne+e2DqKFstD+Ettk7/vn8VsOCZswn24TmZnDnUC6HhT z55qdkt/qe+uNFi51NX2ePtTzxQgyHBKAgIG21lHYAY9N1rs30jdRh7WmFwASAxNbybd gp4eD75tQD2bXLn8bKqG3WQFabKAC958Drb4beMB7pEfp3SEypQDIBGTyKL6bOt/KHF3 b6oZ4uLsczZIrlk1HLZQpy3ryBsYRF1COZOVxQnsG2SmLsu5IZc7ohk4zaGUKGQpJDzk 6V0l+sw4Kv1AmWENYZwv/qMGuLA6QZ4FFUgAtt3FnGhnXyPVvr1mg9h8zHmwyOyUJy0G 2Huw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697524885; x=1698129685; 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=DqBVSa7X7Vl34L7v0vos+xD696qr1VhHUKnTWS4HUqY=; b=W9BLZZ2vcUK/6A9WoftjlDmxeIkEL2vd0uk4tMI2DbAv4GRSnBKHuwwdRtI8iSOlzj lGp+B9K7WFj0a9APZhLcWc5Q9mkRj57URib18dAiq4XTjFAKmlBpY5dTZD4ViAzLzbMb 33PKZ/dnvr1luK0d0m7BLzLtiq+RTMTdxfB4/5MibxyisbbEhtVF9CNTQmRzyiIz26MU Ze5WeHjaab4QXxVLZXFbIKtQd0psdZYrdilqfTeMafppZY9y8/uXO93al4eFqp2HFCli TmALxA0/RiTogPNQFYkf0MA6hq/PtFbq6DzGT9lgS9qypYskrmhyVwUyP06DYiLvcy2x gUiw== X-Gm-Message-State: AOJu0YxcptO096wlFqZl780mmnnix29NwcgNj58/7zDgmwM05XLHpM3F tZ0r0xbJ3FAkyimR7tXLhLIl4DB6xo6H5O33gMI= X-Received: by 2002:a17:902:bd09:b0:1c6:943:baca with SMTP id p9-20020a170902bd0900b001c60943bacamr1501660pls.28.1697524885693; Mon, 16 Oct 2023 23:41:25 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id x18-20020a17090300d200b001b891259eddsm685682plc.197.2023.10.16.23.41.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:41:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH 20/20] target/sparc: Implement UDIV inline Date: Mon, 16 Oct 2023 23:41:09 -0700 Message-Id: <20231017064109.681935-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017064109.681935-1-richard.henderson@linaro.org> References: <20231017064109.681935-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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, T_SPF_TEMPERROR=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 Signed-off-by: Richard Henderson --- target/sparc/helper.h | 1 - target/sparc/helper.c | 29 +++++++--------------- target/sparc/translate.c | 52 +++++++++++++++++++++++++++++++++++----- 3 files changed, 54 insertions(+), 28 deletions(-) diff --git a/target/sparc/helper.h b/target/sparc/helper.h index 12181d1106..624a8fdedf 100644 --- a/target/sparc/helper.h +++ b/target/sparc/helper.h @@ -27,7 +27,6 @@ DEF_HELPER_FLAGS_2(tick_set_limit, TCG_CALL_NO_RWG, void, ptr, i64) DEF_HELPER_1(debug, void, env) DEF_HELPER_1(save, void, env) DEF_HELPER_1(restore, void, env) -DEF_HELPER_FLAGS_3(udiv, TCG_CALL_NO_WG, tl, env, tl, tl) DEF_HELPER_FLAGS_3(sdiv, TCG_CALL_NO_WG, tl, env, tl, tl) DEF_HELPER_3(udiv_cc, tl, env, tl, tl) DEF_HELPER_3(sdiv_cc, tl, env, tl, tl) diff --git a/target/sparc/helper.c b/target/sparc/helper.c index 3830d01634..1a900753d7 100644 --- a/target/sparc/helper.c +++ b/target/sparc/helper.c @@ -81,15 +81,14 @@ void helper_tick_set_limit(void *opaque, uint64_t limit) } #endif -static target_ulong do_udiv(CPUSPARCState *env, target_ulong a, - target_ulong b, int cc, uintptr_t ra) +target_ulong helper_udiv_cc(CPUSPARCState *env, target_ulong a, target_ulong b) { target_ulong v, r; uint64_t x0 = (uint32_t)a | ((uint64_t)env->y << 32); uint32_t x1 = b; if (x1 == 0) { - cpu_raise_exception_ra(env, TT_DIV_ZERO, ra); + cpu_raise_exception_ra(env, TT_DIV_ZERO, GETPC()); } x0 = x0 / x1; @@ -99,29 +98,17 @@ static target_ulong do_udiv(CPUSPARCState *env, target_ulong a, v = r = UINT32_MAX; } - if (cc) { - env->cc_N = r; - env->cc_V = v; - env->cc_icc_Z = r; - env->cc_icc_C = 0; + env->cc_N = r; + env->cc_V = v; + env->cc_icc_Z = r; + env->cc_icc_C = 0; #ifdef TARGET_SPARC64 - env->cc_xcc_Z = r; - env->cc_xcc_C = 0; + env->cc_xcc_Z = r; + env->cc_xcc_C = 0; #endif - } return r; } -target_ulong helper_udiv(CPUSPARCState *env, target_ulong a, target_ulong b) -{ - return do_udiv(env, a, b, 0, GETPC()); -} - -target_ulong helper_udiv_cc(CPUSPARCState *env, target_ulong a, target_ulong b) -{ - return do_udiv(env, a, b, 1, GETPC()); -} - static target_ulong do_sdiv(CPUSPARCState *env, target_ulong a, target_ulong b, int cc, uintptr_t ra) { diff --git a/target/sparc/translate.c b/target/sparc/translate.c index b344422f8a..2c533a1998 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -576,11 +576,6 @@ static void gen_op_smul(TCGv dst, TCGv src1, TCGv src2) gen_op_multiply(dst, src1, src2, 1); } -static void gen_op_udiv(TCGv dst, TCGv src1, TCGv src2) -{ - gen_helper_udiv(dst, tcg_env, src1, src2); -} - static void gen_op_sdiv(TCGv dst, TCGv src1, TCGv src2) { gen_helper_sdiv(dst, tcg_env, src1, src2); @@ -3615,7 +3610,6 @@ TRANS(XORN, ALL, do_arith, a, tcg_gen_eqv_tl, NULL) TRANS(MULX, 64, do_arith, a, tcg_gen_mul_tl, tcg_gen_muli_tl) TRANS(UMUL, MUL, do_arith, a, gen_op_umul, NULL) TRANS(SMUL, MUL, do_arith, a, gen_op_smul, NULL) -TRANS(UDIV, DIV, do_arith, a, gen_op_udiv, NULL) TRANS(SDIV, DIV, do_arith, a, gen_op_sdiv, NULL) TRANS(ADDC, ALL, do_arith, a, gen_op_addc, NULL) TRANS(SUBC, ALL, do_arith, a, gen_op_subc, NULL) @@ -3642,6 +3636,52 @@ TRANS(ADDCcc, ALL, do_arith, a, gen_op_addccc, NULL) TRANS(SUBCcc, ALL, do_arith, a, gen_op_subccc, NULL) TRANS(MULScc, ALL, do_arith, a, gen_op_mulscc, NULL) +static bool trans_UDIV(DisasContext *dc, arg_r_r_ri *a) +{ + TCGv_i64 t1, t2; + TCGv dst; + + /* For simplicity, we under-decoded the rs2 form. */ + if (!a->imm && a->rs2_or_imm & ~0x1f) { + return false; + } + + if (unlikely(a->rs2_or_imm == 0)) { + gen_exception(dc, TT_DIV_ZERO); + return true; + } + + if (a->imm) { + t2 = tcg_constant_i64((uint32_t)a->rs2_or_imm); + } else { + TCGLabel *lab; + TCGv_i32 n2; + + finishing_insn(dc); + flush_cond(dc); + + n2 = tcg_temp_new_i32(); + tcg_gen_trunc_tl_i32(n2, cpu_regs[a->rs2_or_imm]); + + lab = delay_exception(dc, TT_DIV_ZERO); + tcg_gen_brcondi_i32(TCG_COND_EQ, n2, 0, lab); + + t2 = tcg_temp_new_i64(); + tcg_gen_extu_tl_i64(t2, cpu_regs[a->rs2_or_imm]); + } + + t1 = tcg_temp_new_i64(); + tcg_gen_concat_tl_i64(t1, gen_load_gpr(dc, a->rs1), cpu_y); + + tcg_gen_divu_i64(t1, t1, t2); + tcg_gen_umin_i64(t1, t1, tcg_constant_i64(UINT32_MAX)); + + dst = gen_dest_gpr(dc, a->rd); + tcg_gen_trunc_i64_tl(dst, t1); + gen_store_gpr(dc, a->rd, dst); + return advance_pc(dc); +} + static bool trans_UDIVX(DisasContext *dc, arg_r_r_ri *a) { TCGv dst, src1, src2;