From patchwork Fri Aug 18 22:13:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714702 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp749617wrs; Fri, 18 Aug 2023 15:16:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOl3WDIcfbvB68uoyDfsJ1RiIFr4iMnMT6tne/03M1SfBbugBZYmhWMpF30cepQ4SVQ6g7 X-Received: by 2002:a0c:aa9e:0:b0:63d:6755:d1cd with SMTP id f30-20020a0caa9e000000b0063d6755d1cdmr536786qvb.16.1692397017572; Fri, 18 Aug 2023 15:16:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692397017; cv=none; d=google.com; s=arc-20160816; b=rG2bnQLyZlblx8TbTu/IZWdALWBbP5NeVvUP2PGIKVRhSW33zd8+Fl/Un4rbaqPPdn T0syBiZdPqN76cKeyRh7F46zNHDT3aVYFzYLEgAHYPti0xqNB/3nmphjnUmsJP+kdsQi ER2n5oVRFWfiD1vAMJRrPD95R+ncj24KDatdVLRKarpfqfteb61atkpJOZjxeWBM0E12 7+Pz6rHHUBs8E68o/CUQWlntg//WVl6DXuMCfEZnuz74EGdpq2nc8+xqBVTia8Llk1sk CoiknZU/v/J/B2+zOnTBUkwk9A86EPpBL8yPLrcQWd5CZ9LXyGYrZ9p5dgrXsIButv5w gkuQ== 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=rH9kYuzwfqQwVhoLvPDezMMK6fzY2PUYkGYYUhMfg8U=; fh=iKWO5kImkBaf5P/04M2d2o+fJodoyCg8YLKe8/cbiwg=; b=eIGTojYuIW/fQS1S1Z7cN2xqGr9ZqJPwAhd9vUNkaydFcnth4ScKowM1oUIrm2XJPy C7RJR8E/sG1HJK7/A5cFPX+CJv8d/jjYi980eeB/zwgNqZ+Szh7qaLwC/OYLbHN1qZot LpC/3VskntWOuQkrb45pbS3TYnGm0ocYpm18xuGS2j+1KhKvsxhfwMseO4YwQQjr79Io A1vZ+W86g1pzfyb+vOh+ErF/Bknf1SEIKQRo1+T6ffAO7JY5VFQV3VYNClcyGnXvUv39 s4vPB3YgywyeBgY0rrY732Xklr7rfUydiDYCjaHboGWnn+jIBOsSBXrFoR2aiqEyvKpc FABQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sFgel9tR; 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 m19-20020a0cf193000000b0064a4c8e2515si1933802qvl.373.2023.08.18.15.16.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 15:16:57 -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=sFgel9tR; 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 1qX7j2-000532-Ga; Fri, 18 Aug 2023 18:13:48 -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 1qX7j0-00050i-Dw for qemu-devel@nongnu.org; Fri, 18 Aug 2023 18:13:46 -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 1qX7ix-0004PQ-U9 for qemu-devel@nongnu.org; Fri, 18 Aug 2023 18:13:46 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1bc0d39b52cso10960615ad.2 for ; Fri, 18 Aug 2023 15:13:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692396822; x=1693001622; 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=rH9kYuzwfqQwVhoLvPDezMMK6fzY2PUYkGYYUhMfg8U=; b=sFgel9tR9YZ3tf+54Q5jPRS6iF+BW3DgpMWDE9ivGfzRx2J14dX3qjYvvf6Dqlyy2W 1WAfHKluS5g++3pWequ4WQ69NBBMgHFCv1zlljBAiizkQeWoTKN9pztmnYzjZxGivBCW lP86trhrtFetoTtT6lceeERPsdXV+3lvBcsp2GqeZl3GNhmNx/w/zOSbahbzQiKEWYgV 6PnuCGz7zGi2d0MMabkDU72dBP0/9Yev4Bo4ZQmxqKlHxOGSrnLrs8vNVT0+DqIjWuvy XNkoOuTBQ7Pzd69kCBs/gEF3DJ4sVM9dz4xyCwnL/4oQEbz7fp1YjZvrKhIaagY53X/s pAng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692396822; x=1693001622; 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=rH9kYuzwfqQwVhoLvPDezMMK6fzY2PUYkGYYUhMfg8U=; b=edJLgN9icb4Fh4AwMcBisCBrg6OlyrQTbZ976EdVOYHTbCoW9TJwkU8AQBlcDpDjiT kF20B9/Myk6PFpdcW7mdaHKhn/3e5OSivxCmSkMswNvwmDRwGfnp5RGjURElSKdbC9KE flTIwgpXxVMReJ+2O7/p3BZCW3PFvVpBTXkXg8NLtFr0U4jg/crKwDZ3IFVrC5PEYbu5 3Q9UoYiW1JLt80Jl3el1n8HPoxc4qiBpwFNqlfjaaPXRCmT8m1Im9H3lUgcN+GLIttdH hdwZOGneQkLCqoKyueH6XSwF/vaa2WEyaumVrHzKlhWS+zzmwLRsaGN19YsheElJKJGQ 2LUQ== X-Gm-Message-State: AOJu0YxThAVBQj4MIIc+QRY0esUYWWewIM5TxVYfcyI58YzvMY3gjwmE 9WVjkSwGGXAr4OIeniYzuVz/fzm5EO5SYQv7UGU= X-Received: by 2002:a17:902:dac1:b0:1a6:74f6:fa92 with SMTP id q1-20020a170902dac100b001a674f6fa92mr638545plx.19.1692396822562; Fri, 18 Aug 2023 15:13:42 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id y7-20020a17090322c700b001bdb85291casm2231417plg.208.2023.08.18.15.13.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 15:13:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Peter Maydell Subject: [PATCH v2 16/23] tcg/sparc64: Implement negsetcond_* Date: Fri, 18 Aug 2023 15:13:20 -0700 Message-Id: <20230818221327.150194-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818221327.150194-1-richard.henderson@linaro.org> References: <20230818221327.150194-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 Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/sparc64/tcg-target.h | 4 ++-- tcg/sparc64/tcg-target.c.inc | 36 ++++++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/tcg/sparc64/tcg-target.h b/tcg/sparc64/tcg-target.h index 1faadc704b..4bbd825bd8 100644 --- a/tcg/sparc64/tcg-target.h +++ b/tcg/sparc64/tcg-target.h @@ -112,7 +112,7 @@ extern bool use_vis3_instructions; #define TCG_TARGET_HAS_muls2_i32 1 #define TCG_TARGET_HAS_muluh_i32 0 #define TCG_TARGET_HAS_mulsh_i32 0 -#define TCG_TARGET_HAS_negsetcond_i32 0 +#define TCG_TARGET_HAS_negsetcond_i32 1 #define TCG_TARGET_HAS_qemu_st8_i32 0 #define TCG_TARGET_HAS_extrl_i64_i32 1 @@ -150,7 +150,7 @@ extern bool use_vis3_instructions; #define TCG_TARGET_HAS_muls2_i64 0 #define TCG_TARGET_HAS_muluh_i64 use_vis3_instructions #define TCG_TARGET_HAS_mulsh_i64 0 -#define TCG_TARGET_HAS_negsetcond_i64 0 +#define TCG_TARGET_HAS_negsetcond_i64 1 #define TCG_TARGET_HAS_qemu_ldst_i128 0 diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index ffcb879211..37839f9a21 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -720,7 +720,7 @@ static void tcg_out_movcond_i64(TCGContext *s, TCGCond cond, TCGReg ret, } static void tcg_out_setcond_i32(TCGContext *s, TCGCond cond, TCGReg ret, - TCGReg c1, int32_t c2, int c2const) + TCGReg c1, int32_t c2, int c2const, bool neg) { /* For 32-bit comparisons, we can play games with ADDC/SUBC. */ switch (cond) { @@ -760,22 +760,30 @@ static void tcg_out_setcond_i32(TCGContext *s, TCGCond cond, TCGReg ret, default: tcg_out_cmp(s, c1, c2, c2const); tcg_out_movi_s13(s, ret, 0); - tcg_out_movcc(s, cond, MOVCC_ICC, ret, 1, 1); + tcg_out_movcc(s, cond, MOVCC_ICC, ret, neg ? -1 : 1, 1); return; } tcg_out_cmp(s, c1, c2, c2const); if (cond == TCG_COND_LTU) { - tcg_out_arithi(s, ret, TCG_REG_G0, 0, ARITH_ADDC); + if (neg) { + tcg_out_arithi(s, ret, TCG_REG_G0, 0, ARITH_SUBC); + } else { + tcg_out_arithi(s, ret, TCG_REG_G0, 0, ARITH_ADDC); + } } else { - tcg_out_arithi(s, ret, TCG_REG_G0, -1, ARITH_SUBC); + if (neg) { + tcg_out_arithi(s, ret, TCG_REG_G0, -1, ARITH_ADDC); + } else { + tcg_out_arithi(s, ret, TCG_REG_G0, -1, ARITH_SUBC); + } } } static void tcg_out_setcond_i64(TCGContext *s, TCGCond cond, TCGReg ret, - TCGReg c1, int32_t c2, int c2const) + TCGReg c1, int32_t c2, int c2const, bool neg) { - if (use_vis3_instructions) { + if (use_vis3_instructions && !neg) { switch (cond) { case TCG_COND_NE: if (c2 != 0) { @@ -796,11 +804,11 @@ static void tcg_out_setcond_i64(TCGContext *s, TCGCond cond, TCGReg ret, if the input does not overlap the output. */ if (c2 == 0 && !is_unsigned_cond(cond) && c1 != ret) { tcg_out_movi_s13(s, ret, 0); - tcg_out_movr(s, cond, ret, c1, 1, 1); + tcg_out_movr(s, cond, ret, c1, neg ? -1 : 1, 1); } else { tcg_out_cmp(s, c1, c2, c2const); tcg_out_movi_s13(s, ret, 0); - tcg_out_movcc(s, cond, MOVCC_XCC, ret, 1, 1); + tcg_out_movcc(s, cond, MOVCC_XCC, ret, neg ? -1 : 1, 1); } } @@ -1355,7 +1363,10 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_brcond_i32(s, a2, a0, a1, const_args[1], arg_label(args[3])); break; case INDEX_op_setcond_i32: - tcg_out_setcond_i32(s, args[3], a0, a1, a2, c2); + tcg_out_setcond_i32(s, args[3], a0, a1, a2, c2, false); + break; + case INDEX_op_negsetcond_i32: + tcg_out_setcond_i32(s, args[3], a0, a1, a2, c2, true); break; case INDEX_op_movcond_i32: tcg_out_movcond_i32(s, args[5], a0, a1, a2, c2, args[3], const_args[3]); @@ -1437,7 +1448,10 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_brcond_i64(s, a2, a0, a1, const_args[1], arg_label(args[3])); break; case INDEX_op_setcond_i64: - tcg_out_setcond_i64(s, args[3], a0, a1, a2, c2); + tcg_out_setcond_i64(s, args[3], a0, a1, a2, c2, false); + break; + case INDEX_op_negsetcond_i64: + tcg_out_setcond_i64(s, args[3], a0, a1, a2, c2, true); break; case INDEX_op_movcond_i64: tcg_out_movcond_i64(s, args[5], a0, a1, a2, c2, args[3], const_args[3]); @@ -1564,6 +1578,8 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_sar_i64: case INDEX_op_setcond_i32: case INDEX_op_setcond_i64: + case INDEX_op_negsetcond_i32: + case INDEX_op_negsetcond_i64: return C_O1_I2(r, rZ, rJ); case INDEX_op_brcond_i32: