From patchwork Wed Jun 5 17:22:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 801599 Delivered-To: patch@linaro.org Received: by 2002:adf:cf0e:0:b0:35b:5a80:51b4 with SMTP id o14csp549934wrj; Wed, 5 Jun 2024 10:24:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVR17x+5CXX+lWgpTfYgdm++K6WI6Ih716AMeExKOwdlTEEvXII+r8e7scdTsE0VxmFLwm1nbuKFXKlwn7grf9+ X-Google-Smtp-Source: AGHT+IHisPx88B5jSHyuLOgQJquDj/NqZTrkO5l1Gkn/c+kWEyUHqL0F7dI/ihKqBlq8fADSBPpr X-Received: by 2002:a54:4704:0:b0:3c9:76b0:753b with SMTP id 5614622812f47-3d2042959f2mr3261403b6e.14.1717608260024; Wed, 05 Jun 2024 10:24:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717608259; cv=none; d=google.com; s=arc-20160816; b=RDvTDI05s9/UNR/fBi+AOAF6+ZzTvUE4fLlI0WvCp0arJ+XkAzc6+WMM8nHQENPHln 4E9twWcISd5KUyVZ4pUWRgoT4eMyCEdPoOEapsWMmMdYkKYsjfYlgVRoiemDSsnHnuHy ztMuYfG/hTpe8AcHq4+GUN+RH8LbM1WTaPlDPw+p+lL98I8XDpEIkbG1cf47z91TzwIq EVQ7eKOq/d1+U9aJ4PhK7imlFENTh9bvxEQSdLEOVtB7RaLCMxOAn+gBzhwEdwGuUAJd FnL8/WR7huy89tdBGD7gJsXPO2x1IF5M+MXqTRb2d8BKxSPuT0j9H/6EnhrEBKKnGnaB MkhA== 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:to:from :dkim-signature; bh=o5Xge3aFlICjGEwQnJKGgTBQ+hnW7Zmp0P/rXCoGoes=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=FT1/sI5pl3i9WVEwzA/9h0xXK36nFWCRsoWpaFK5ITZO6L7H7068t25/55aP06jNsH F/2HqoVAp0LvTzkqkxdFg094qbe1Upx+Nx/Cydb7PkU1Uy0Rl93NZ5NCsJkIWu93iVLU 8azIGWQhxJ/JS9Sm5iKvasGLHC7Z+ZzNEvZDGl7ZuWs9KjtwDlaAAmp4bdLwJDlTk+lJ irIc80/xBeDprVlAxjZD5Dro2EY5vWh0BHy0rIPE4hsvpuTcsBDOk/YiJK5IaWmip8Y3 xEmxMJRl5LrRAanjhauiBLmUsXWcnB8qQDYeiF6CD/+pGofNgSbk1w33v0vDm8pPM3+e PYzA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UX7hDMZ+; 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 af79cd13be357-794f2f05911si1339202985a.151.2024.06.05.10.24.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Jun 2024 10:24: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=UX7hDMZ+; 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 1sEuLz-0005wb-1b; Wed, 05 Jun 2024 13:23:15 -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 1sEuLx-0005vq-A3 for qemu-devel@nongnu.org; Wed, 05 Jun 2024 13:23:13 -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 1sEuLv-0003qn-F6 for qemu-devel@nongnu.org; Wed, 05 Jun 2024 13:23:13 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1f44b441b08so892215ad.0 for ; Wed, 05 Jun 2024 10:23:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717608190; x=1718212990; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=o5Xge3aFlICjGEwQnJKGgTBQ+hnW7Zmp0P/rXCoGoes=; b=UX7hDMZ+6cXetkgyZ8o1D2+cnlh4FN7Xa07dIJLjoDMPytBXevgYzx1BTMfTAp7ybZ /Tty9WOMn9ZVPf/ru/Rm6fhSL/ky1IG34Z32fe0OWVCqs1ChzaEbaaNu+WCMg6czlQ7w RVBqRLO0rsR++5QQWcASmRNsN9GnrWJmPYbEPScyDS41QpbMR1VcSQgirlzkbp4LABT2 zaQDlowpVB+ePZynM/+E2fG1FjVDWxMzuiQURXePsd6V+bWIVwPZv2kcyV5qRLs5ntHj EIOW4pxqddCqkujqnvgYjuvxPl4g4smLlufjNwwD9gppbLb8ryBtMTbIyExHe7wIGf3+ 0q/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717608190; x=1718212990; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o5Xge3aFlICjGEwQnJKGgTBQ+hnW7Zmp0P/rXCoGoes=; b=BNbPttB4vlXfbxTFOw+lXwttopN3MnS+UX2sqefwR+hnMlP9EjFQoDCqHj+y4xdbui 7YkTgnTHuQa4BbkWgUXfajDF2fmiB55SatKK1x3vt+dg6bCUjC4SfCe3YpJ+BMLGFKHE KRcTIRkeSqIW8QH6MbExXhsH2N6CwfafZ50vwr1FcpA+C3xc9t6uRG07iGmDMtLuI33R APfqX+adFdZYAETqg9rW7PR5/ajt3B+0aBqz31mfW577zQ+5ZeiBnAQ7s+fCdj378NBn n4INPXznSiE+rdGHybUOvsZi2CluOE+GzYd/31u4RUAarJB7XQlkADm5Hn0NCRBIQcQB K57w== X-Gm-Message-State: AOJu0YxQkChkKsET5YDjkOb/CaEE1H7CCbjNZItQXGTBTmYRSmKVXDyh O9VQddaxml9HEcUnvjlQrXgdBWf5EraC90WvMvN3SE5Bq0bjkabo2eY2+6q2VSIhsD59PMc7aK7 / X-Received: by 2002:a17:90b:f8c:b0:2bd:fa57:b35c with SMTP id 98e67ed59e1d1-2c27db1b5d7mr2921938a91.28.1717608190022; Wed, 05 Jun 2024 10:23:10 -0700 (PDT) Received: from stoup.. ([71.212.132.216]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c28066d511sm1720915a91.9.2024.06.05.10.23.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 10:23:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 16/38] target/sparc: Implement FLCMP Date: Wed, 5 Jun 2024 10:22:31 -0700 Message-Id: <20240605172253.356302-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240605172253.356302-1-richard.henderson@linaro.org> References: <20240605172253.356302-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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson --- target/sparc/helper.h | 2 ++ target/sparc/insns.decode | 4 ++++ target/sparc/fop_helper.c | 46 +++++++++++++++++++++++++++++++++++++++ target/sparc/translate.c | 34 +++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+) diff --git a/target/sparc/helper.h b/target/sparc/helper.h index 15f0907a1b..ab79954bb5 100644 --- a/target/sparc/helper.h +++ b/target/sparc/helper.h @@ -50,6 +50,8 @@ DEF_HELPER_FLAGS_3(fcmpd, TCG_CALL_NO_WG, i32, env, f64, f64) DEF_HELPER_FLAGS_3(fcmped, TCG_CALL_NO_WG, i32, env, f64, f64) DEF_HELPER_FLAGS_3(fcmpq, TCG_CALL_NO_WG, i32, env, i128, i128) DEF_HELPER_FLAGS_3(fcmpeq, TCG_CALL_NO_WG, i32, env, i128, i128) +DEF_HELPER_FLAGS_2(flcmps, TCG_CALL_NO_RWG_SE, i32, f32, f32) +DEF_HELPER_FLAGS_2(flcmpd, TCG_CALL_NO_RWG_SE, i32, f64, f64) DEF_HELPER_2(raise_exception, noreturn, env, int) DEF_HELPER_FLAGS_3(faddd, TCG_CALL_NO_WG, f64, env, f64, f64) diff --git a/target/sparc/insns.decode b/target/sparc/insns.decode index 6ec3838865..de29996304 100644 --- a/target/sparc/insns.decode +++ b/target/sparc/insns.decode @@ -470,6 +470,10 @@ FCMPEq 10 000 cc:2 110101 ..... 0 0101 0111 ..... \ FZEROs 10 rd:5 110110 00000 0 0110 0001 00000 FONEd 10 ..... 110110 00000 0 0111 1110 00000 rd=%dfp_rd FONEs 10 rd:5 110110 00000 0 0111 1111 00000 + + FLCMPs 10 000 cc:2 110110 rs1:5 1 0101 0001 rs2:5 + FLCMPd 10 000 cc:2 110110 ..... 1 0101 0010 ..... \ + rs1=%dfp_rs1 rs2=%dfp_rs2 ] NCP 10 ----- 110110 ----- --------- ----- # v8 CPop1 } diff --git a/target/sparc/fop_helper.c b/target/sparc/fop_helper.c index 08b5f96f95..1b524c6d3c 100644 --- a/target/sparc/fop_helper.c +++ b/target/sparc/fop_helper.c @@ -490,6 +490,52 @@ uint32_t helper_fcmpeq(CPUSPARCState *env, Int128 src1, Int128 src2) return finish_fcmp(env, r, GETPC()); } +uint32_t helper_flcmps(float32 src1, float32 src2) +{ + /* + * FLCMP never raises an exception nor modifies any FSR fields. + * Perform the comparison with a dummy fp environment. + */ + float_status discard = { }; + FloatRelation r = float32_compare_quiet(src1, src2, &discard); + + switch (r) { + case float_relation_equal: + if (src2 == float32_zero && src1 != float32_zero) { + return 1; /* -0.0 < +0.0 */ + } + return 0; + case float_relation_less: + return 1; + case float_relation_greater: + return 0; + case float_relation_unordered: + return float32_is_any_nan(src2) ? 3 : 2; + } + g_assert_not_reached(); +} + +uint32_t helper_flcmpd(float64 src1, float64 src2) +{ + float_status discard = { }; + FloatRelation r = float64_compare_quiet(src1, src2, &discard); + + switch (r) { + case float_relation_equal: + if (src2 == float64_zero && src1 != float64_zero) { + return 1; /* -0.0 < +0.0 */ + } + return 0; + case float_relation_less: + return 1; + case float_relation_greater: + return 0; + case float_relation_unordered: + return float64_is_any_nan(src2) ? 3 : 2; + } + g_assert_not_reached(); +} + target_ulong cpu_get_fsr(CPUSPARCState *env) { target_ulong fsr = env->fsr | env->fsr_cexc_ftt; diff --git a/target/sparc/translate.c b/target/sparc/translate.c index d81b9ce5a8..db3a153c6e 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -5207,6 +5207,40 @@ static bool do_fcmpq(DisasContext *dc, arg_FCMPq *a, bool e) TRANS(FCMPq, ALL, do_fcmpq, a, false) TRANS(FCMPEq, ALL, do_fcmpq, a, true) +static bool trans_FLCMPs(DisasContext *dc, arg_FLCMPs *a) +{ + TCGv_i32 src1, src2; + + if (!avail_VIS3(dc)) { + return false; + } + if (gen_trap_ifnofpu(dc)) { + return true; + } + + src1 = gen_load_fpr_F(dc, a->rs1); + src2 = gen_load_fpr_F(dc, a->rs2); + gen_helper_flcmps(cpu_fcc[a->cc], src1, src2); + return advance_pc(dc); +} + +static bool trans_FLCMPd(DisasContext *dc, arg_FLCMPd *a) +{ + TCGv_i64 src1, src2; + + if (!avail_VIS3(dc)) { + return false; + } + if (gen_trap_ifnofpu(dc)) { + return true; + } + + src1 = gen_load_fpr_D(dc, a->rs1); + src2 = gen_load_fpr_D(dc, a->rs2); + gen_helper_flcmpd(cpu_fcc[a->cc], src1, src2); + return advance_pc(dc); +} + static void sparc_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) { DisasContext *dc = container_of(dcbase, DisasContext, base);