From patchwork Wed Jun 5 17:22:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 801606 Delivered-To: patch@linaro.org Received: by 2002:adf:cf0e:0:b0:35b:5a80:51b4 with SMTP id o14csp550148wrj; Wed, 5 Jun 2024 10:24:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX83XM4zNr+LxiRZewWgI/ZnrTONBKgGbY3FqOVT3ioeWIfekO7py+0zMBNPMbiq6kk3JZTPXDoKdxLH63X92f5 X-Google-Smtp-Source: AGHT+IFixr6CgrHS36OjIlB5xyh2+LWtgl2x4ZPUn+1cVzb4RAiVpFte+E9R3tVVEV8MDSuvikDf X-Received: by 2002:a05:622a:452:b0:43e:3a16:a7d with SMTP id d75a77b69052e-4402b5db77amr32611661cf.16.1717608287575; Wed, 05 Jun 2024 10:24:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717608287; cv=none; d=google.com; s=arc-20160816; b=h16hpbk73gedGOekd2J03JUgub+R88Xq2ufzUICx8tYyyvbGeBWuBTYsZG6aEuov4U LmbYKwC9HgMsoK8V+oCTLzmvenhmCXl/GNKULl0H4pbRt6VoHgrYK1Gpm9QnFttzBUfe Z54QHdDa51lZKShBLGW74Y6bzEVccmlSgAny9Zfw0EK+5Wl/h7Px+aje1vTms21lNxGn fqPXDrBefAhU3jpG0b0SKmHkWm37FxWh2Fc/E9OfIeS8HRUBBH7Rr06v0UL+LyYvLjcQ K6cNZXs1eleucrIK4XUwfJqwT9GeEWVUxI3UifNWX8JJgSRw35wyM2Fukf3xDjidJz3U tbsg== 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=wig9V+JSk/GjardrNp7xbhIFWmF6FqSzEEMhgBWz718=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=xsaC4eq3T7YBXa24G22oQ1X3PEghoume0zWRwEraWzq/mde60ZbwN5PdC1dgXR22Bz UJ22HGoj/e8QmJrvWk9LAi5iMfYFsvXPX3avMvImN3Sdh1/XIT7LZtXrWhBXcd+etFfu cRkAYhCxLNw5chrmCfbkb3WyRwinH3+KmRRuVjfrcem0BIorOKjrW4+mtX14D4EiNNda NqwpM9ruSGfiYkQjqnGVbEyh5IatLXxciZRx6rzkMS+Xhpv4BE3+vbAHGTf46/RG7uO8 ui+9WopwTLm6h5Rm/LkCXRb1G1RjEDnwquvRGnDJ2lnH7xESFVQk/bqH8WYa7yT4z6oi NJag==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RlUB40Kx; 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 d75a77b69052e-4402bd95d44si23161441cf.420.2024.06.05.10.24.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Jun 2024 10:24:47 -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=RlUB40Kx; 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 1sEuM1-0005xr-TQ; Wed, 05 Jun 2024 13:23: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 1sEuM0-0005xE-MN for qemu-devel@nongnu.org; Wed, 05 Jun 2024 13:23:16 -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 1sEuLy-0003rT-BX for qemu-devel@nongnu.org; Wed, 05 Jun 2024 13:23:16 -0400 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-6c4f3e0e407so22133a12.1 for ; Wed, 05 Jun 2024 10:23:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717608193; x=1718212993; 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=wig9V+JSk/GjardrNp7xbhIFWmF6FqSzEEMhgBWz718=; b=RlUB40KxwmsoovWDpV0zKzgIwH0CoQGiupV73W1EZqoLD3oJ2N59F/AYAZsRA4PX5k attpIEyHe5fvRmNnCBJbFQUnnQ+ZqoRpTGBOkZJ4EIyJTH39FWw2WclRrbFp4uz0yRF+ nJ6eiXaI9v6nAPn+lMqyKbebIMTbe/Q69U1VhHY1N2vJXJELDWGy//SFQZSvFQFy0EZp 1SgHB+jTNWvraDVplvvM9msuWFdu2Sc++pN3Xa3WhUVWbe2x6X4QQKLevvFSJe4+zJbQ iV/jppXvKbW6vMd0rBxQxoyZFOEwE/txpxmymdWqXTeJFzCDdRfuXRPkPYEqdYKyEQWh KT9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717608193; x=1718212993; 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=wig9V+JSk/GjardrNp7xbhIFWmF6FqSzEEMhgBWz718=; b=pbyzcCnwwzvOc2Tkqs+y8oS4oymo+yEpFCDV+3PXcN7ycFU1jurl+Gc/lKapP8cvj3 aU0WcuJlx5xSHGArjp/Ec6bIW/mRrdoNxh/XRyXZGDeA53MEky7aGQWHSe2BaG/JHAwd bLeqTsbNUpYAT4i9Wy9HUjW2wBoIL1TiEca04Nva2gyC2fL2I+fztMAnpZgB9w64odP1 m0BiKr8MfMI4x80N1njljfNwsZG0TDausJqCgZFFwgOi1fNQAciEJuC5ZuZN4PdZkq0M xIt3wsIViyhnjDnsU4xKX2F5X8RXKazhsSyMsx7giKhKNvmD2Q2jV3Q58y4JSMKYjARw YtEQ== X-Gm-Message-State: AOJu0YxxYA6bcU2ds3QrtUYrCpk67s0sgCs9DVyfsmoFXx0RJoZi2ICY 9oletKA8eb3aIC4dmGXPdpwtYyf5HaqqlLQtuMfvpAy0CJTKefycmtHpqnsjCX2vBUpK3az0D9b U X-Received: by 2002:a17:90b:60c:b0:2bf:9355:bfbc with SMTP id 98e67ed59e1d1-2c27dafce71mr2839848a91.3.1717608192885; Wed, 05 Jun 2024 10:23:12 -0700 (PDT) Received: from stoup.. ([71.212.132.216]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c28066d511sm1720915a91.9.2024.06.05.10.23.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 10:23:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 19/38] target/sparc: Implement FPADDS, FPSUBS Date: Wed, 5 Jun 2024 10:22:34 -0700 Message-Id: <20240605172253.356302-20-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::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, 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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/sparc/insns.decode | 9 +++++ target/sparc/translate.c | 82 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/target/sparc/insns.decode b/target/sparc/insns.decode index 70ca41a69a..b6553362eb 100644 --- a/target/sparc/insns.decode +++ b/target/sparc/insns.decode @@ -448,6 +448,15 @@ FCMPEq 10 000 cc:2 110101 ..... 0 0101 0111 ..... \ FPSUB32s 10 ..... 110110 ..... 0 0101 0111 ..... @r_r_r FPSUB64 10 ..... 110110 ..... 0 0100 0110 ..... @d_d_d + FPADDS16 10 ..... 110110 ..... 0 0101 1000 ..... @d_d_d + FPADDS16s 10 ..... 110110 ..... 0 0101 1001 ..... @r_r_r + FPADDS32 10 ..... 110110 ..... 0 0101 1010 ..... @d_d_d + FPADDS32s 10 ..... 110110 ..... 0 0101 1011 ..... @r_r_r + FPSUBS16 10 ..... 110110 ..... 0 0101 1100 ..... @d_d_d + FPSUBS16s 10 ..... 110110 ..... 0 0101 1101 ..... @r_r_r + FPSUBS32 10 ..... 110110 ..... 0 0101 1110 ..... @d_d_d + FPSUBS32s 10 ..... 110110 ..... 0 0101 1111 ..... @r_r_r + FNORd 10 ..... 110110 ..... 0 0110 0010 ..... @d_d_d FNORs 10 ..... 110110 ..... 0 0110 0011 ..... @r_r_r FANDNOTd 10 ..... 110110 ..... 0 0110 0100 ..... @d_d_d # FANDNOT2d diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 48cab59c07..7a5e8e0a9a 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -698,6 +698,78 @@ static void gen_op_fpack32(TCGv_i64 dst, TCGv_i64 src1, TCGv_i64 src2) #endif } +static void gen_op_fpadds16s(TCGv_i32 d, TCGv_i32 src1, TCGv_i32 src2) +{ + TCGv_i32 t[2]; + + for (int i = 0; i < 2; i++) { + TCGv_i32 u = tcg_temp_new_i32(); + TCGv_i32 v = tcg_temp_new_i32(); + + tcg_gen_sextract_i32(u, src1, i * 16, 16); + tcg_gen_sextract_i32(v, src2, i * 16, 16); + tcg_gen_add_i32(u, u, v); + tcg_gen_smax_i32(u, u, tcg_constant_i32(INT16_MIN)); + tcg_gen_smin_i32(u, u, tcg_constant_i32(INT16_MAX)); + t[i] = u; + } + tcg_gen_deposit_i32(d, t[0], t[1], 16, 16); +} + +static void gen_op_fpsubs16s(TCGv_i32 d, TCGv_i32 src1, TCGv_i32 src2) +{ + TCGv_i32 t[2]; + + for (int i = 0; i < 2; i++) { + TCGv_i32 u = tcg_temp_new_i32(); + TCGv_i32 v = tcg_temp_new_i32(); + + tcg_gen_sextract_i32(u, src1, i * 16, 16); + tcg_gen_sextract_i32(v, src2, i * 16, 16); + tcg_gen_sub_i32(u, u, v); + tcg_gen_smax_i32(u, u, tcg_constant_i32(INT16_MIN)); + tcg_gen_smin_i32(u, u, tcg_constant_i32(INT16_MAX)); + t[i] = u; + } + tcg_gen_deposit_i32(d, t[0], t[1], 16, 16); +} + +static void gen_op_fpadds32s(TCGv_i32 d, TCGv_i32 src1, TCGv_i32 src2) +{ + TCGv_i32 r = tcg_temp_new_i32(); + TCGv_i32 t = tcg_temp_new_i32(); + TCGv_i32 v = tcg_temp_new_i32(); + TCGv_i32 z = tcg_constant_i32(0); + + tcg_gen_add_i32(r, src1, src2); + tcg_gen_xor_i32(t, src1, src2); + tcg_gen_xor_i32(v, r, src2); + tcg_gen_andc_i32(v, v, t); + + tcg_gen_setcond_i32(TCG_COND_GE, t, r, z); + tcg_gen_addi_i32(t, t, INT32_MAX); + + tcg_gen_movcond_i32(TCG_COND_LT, d, v, z, t, r); +} + +static void gen_op_fpsubs32s(TCGv_i32 d, TCGv_i32 src1, TCGv_i32 src2) +{ + TCGv_i32 r = tcg_temp_new_i32(); + TCGv_i32 t = tcg_temp_new_i32(); + TCGv_i32 v = tcg_temp_new_i32(); + TCGv_i32 z = tcg_constant_i32(0); + + tcg_gen_sub_i32(r, src1, src2); + tcg_gen_xor_i32(t, src1, src2); + tcg_gen_xor_i32(v, r, src1); + tcg_gen_and_i32(v, v, t); + + tcg_gen_setcond_i32(TCG_COND_GE, t, r, z); + tcg_gen_addi_i32(t, t, INT32_MAX); + + tcg_gen_movcond_i32(TCG_COND_LT, d, v, z, t, r); +} + static void gen_op_faligndata(TCGv_i64 dst, TCGv_i64 s1, TCGv_i64 s2) { #ifdef TARGET_SPARC64 @@ -4788,6 +4860,11 @@ TRANS(FHADDs, VIS3, do_fff, a, gen_op_fhadds) TRANS(FHSUBs, VIS3, do_fff, a, gen_op_fhsubs) TRANS(FNHADDs, VIS3, do_fff, a, gen_op_fnhadds) +TRANS(FPADDS16s, VIS3, do_fff, a, gen_op_fpadds16s) +TRANS(FPSUBS16s, VIS3, do_fff, a, gen_op_fpsubs16s) +TRANS(FPADDS32s, VIS3, do_fff, a, gen_op_fpadds32s) +TRANS(FPSUBS32s, VIS3, do_fff, a, gen_op_fpsubs32s) + static bool do_env_fff(DisasContext *dc, arg_r_r_r *a, void (*func)(TCGv_i32, TCGv_env, TCGv_i32, TCGv_i32)) { @@ -4875,6 +4952,11 @@ TRANS(FPSUB32, VIS1, do_gvec_ddd, a, MO_32, tcg_gen_gvec_sub) TRANS(FCHKSM16, VIS3, do_gvec_ddd, a, MO_16, gen_op_fchksm16) TRANS(FMEAN16, VIS3, do_gvec_ddd, a, MO_16, gen_op_fmean16) +TRANS(FPADDS16, VIS3, do_gvec_ddd, a, MO_16, tcg_gen_gvec_ssadd) +TRANS(FPADDS32, VIS3, do_gvec_ddd, a, MO_32, tcg_gen_gvec_ssadd) +TRANS(FPSUBS16, VIS3, do_gvec_ddd, a, MO_16, tcg_gen_gvec_sssub) +TRANS(FPSUBS32, VIS3, do_gvec_ddd, a, MO_32, tcg_gen_gvec_sssub) + static bool do_ddd(DisasContext *dc, arg_r_r_r *a, void (*func)(TCGv_i64, TCGv_i64, TCGv_i64)) {