From patchwork Tue Dec 21 16:47:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526616 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5237687imb; Tue, 21 Dec 2021 09:06:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1srezgeRIrmHcGtZXB2jWsvvW8MDaCwctfM6aed3LnFvOVdzSkTAld6epGSjp/P03uoAO X-Received: by 2002:a05:622a:4e:: with SMTP id y14mr3082403qtw.106.1640106394639; Tue, 21 Dec 2021 09:06:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640106394; cv=none; d=google.com; s=arc-20160816; b=oGyI32lOQqeWq4fbRFt83h7+IC6l+rnvAdhFWUA7qmzVP+txPVUg2WMIlFnzqakjQ8 PLOo+T28E2FKP1S7zGa6Ug3qriEAqYcsy9ik7csiRhE2UZVb3rhfQRFQhbvTs9jE3lOX I7Iv++VMN6TTGO6jOhIO7jNKVAOc4w7MB5l0qNGcvrEB9PofoiXHuW9h21jnNYhvSSMH kXWNHqYffxyDpZXtKwpw/wGtt+9QZKAzxXUlumBcx8H56wDaaql6yr2HS7gk6vpdbmqv 9pQcvt1dZhAy8tsZxC2Oqvx8TxNUkUO+PvB/Vnhu2liE4M9wU05zclkk+xCturLRjfwT i8ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=zozyKTalGzaNsX7sRaTPXbvLzGeDnY64efJNy5c8mNI=; b=LOHRh83fLAJldDBSOMge1de/DlEIsIpxqQZe6jO4LZs6NZPca0saGtqxHWWpdMvOsl RQeUQWYOT82Ubll79XHUVMuPCFNpA99qaq1yQS1aXclnq8bQbUbEl9g4OEYvIrFsuihl cTz14GFgo2bCjBBpr6k0U4wUHeSxi0ke3mhAp2TWWGpHrYIIYfkHVz/LV9zQMAjLC+Yh 6lrYp5a8yHiamMH5UsmMzhwJRWthIcBJAT7sXAdUfnmvAijXXURp3kJbW8hk6Jref54U bKRz9kVu2AdLCVD+58j9+M440IBeoTDe9ktM/AjzlPf1Zw5jDNiEhnh6nySJME/TkS55 7VbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sUBGTFML; 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 12si8025277qvh.54.2021.12.21.09.06.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 09:06:34 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sUBGTFML; 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]:52936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziav-0004Zc-Em for patch@linaro.org; Tue, 21 Dec 2021 12:06:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziJ7-0000qM-Vp for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:09 -0500 Received: from [2607:f8b0:4864:20::52d] (port=45848 helo=mail-pg1-x52d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIw-0007e3-LJ for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:09 -0500 Received: by mail-pg1-x52d.google.com with SMTP id 2so6016855pgb.12 for ; Tue, 21 Dec 2021 08:47:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zozyKTalGzaNsX7sRaTPXbvLzGeDnY64efJNy5c8mNI=; b=sUBGTFML4qY2wz2qFthdH7oEbO4Pb7FXaScfAs+hdvqiw9fnbiCCl38w4lRDmCd4oU k3x1BY5LVNOF+ZVd69nDXvvCEDX4fOUr/UT+rajsFLTXSFEj9KkxnIT8MLFiHpMX+bAW tgMnj1QoTW0Cq7CUv7YzmDP0Wyfi4yHaa0eV6UmEQXMS+MBgZH8s3Sn377t7/Ql7bCyF MnbyxTtow0JzUq/oTVv2AvuEfLgXoL8NHFlUjvmhoQIwrLgf4mVMxGSpH1WJrHvOmwD7 yuPoVfp+VDb0R2K7FlfCNXEF8dPubKUGU8IwVWpg3z9z7uAx3wIW+PP0oC2LCHQ3dJH4 W6gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zozyKTalGzaNsX7sRaTPXbvLzGeDnY64efJNy5c8mNI=; b=dOz3x9ovbYJ4WxFqGxFrZj2XthMnRaufWR5Kigi7JiGe++uLFwmX3VSOIz+QcqSsdR WR08NBcDRh1My3FAP30cDWjBXtNRLh1VtfH5hSBl8vV5S7S2Zn6JQty5gbrRQ2ObafK8 jFltke+CUln8Zxqeuskr3Hk7zNWAB6Y0Gs3Y7vKb0cyOD6dIl4YIFgPHfkuSHB7Dyxsu 3diaG8uUnvDK1N1dm0THC4XfNFVnpX0hdnRAj04e0N0EJSWgqppYOLZVzk1K8aNEmIst pKMCN/uPSFIAma1VxyWyOlORtnuqj7sVBzE5apo5uom3aUxaf06yvs7dfUJ6cducP+K2 3LIw== X-Gm-Message-State: AOAM531a92pVlHavBJs6tjiFNMDOWRYlxvHcPUDKKSzbFmQ8GjWdHTj/ 1MJPB+GsInmN3MYzGhxMwDcLZA6o69SUYg== X-Received: by 2002:a63:5651:: with SMTP id g17mr3679821pgm.275.1640105277412; Tue, 21 Dec 2021 08:47:57 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 20/31] tcg/loongarch64: Implement setcond ops Date: Tue, 21 Dec 2021 08:47:26 -0800 Message-Id: <20211221164737.1076007-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::52d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: WANG Xuerui Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Message-Id: <20211221054105.178795-21-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target-con-set.h | 1 + tcg/loongarch64/tcg-target.c.inc | 69 ++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/tcg/loongarch64/tcg-target-con-set.h b/tcg/loongarch64/tcg-target-con-set.h index 367689c2e2..a2ec61237e 100644 --- a/tcg/loongarch64/tcg-target-con-set.h +++ b/tcg/loongarch64/tcg-target-con-set.h @@ -22,6 +22,7 @@ C_O1_I2(r, r, ri) C_O1_I2(r, r, rI) C_O1_I2(r, r, rU) C_O1_I2(r, r, rW) +C_O1_I2(r, r, rZ) C_O1_I2(r, 0, rZ) C_O1_I2(r, rZ, rN) C_O1_I2(r, rZ, rZ) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index aedfc0df84..23c151f473 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -434,6 +434,66 @@ static void tcg_out_clzctz(TCGContext *s, LoongArchInsn opc, tcg_out_opc_or(s, a0, TCG_REG_TMP0, a0); } +static void tcg_out_setcond(TCGContext *s, TCGCond cond, TCGReg ret, + TCGReg arg1, TCGReg arg2, bool c2) +{ + TCGReg tmp; + + if (c2) { + tcg_debug_assert(arg2 == 0); + } + + switch (cond) { + case TCG_COND_EQ: + if (c2) { + tmp = arg1; + } else { + tcg_out_opc_sub_d(s, ret, arg1, arg2); + tmp = ret; + } + tcg_out_opc_sltui(s, ret, tmp, 1); + break; + case TCG_COND_NE: + if (c2) { + tmp = arg1; + } else { + tcg_out_opc_sub_d(s, ret, arg1, arg2); + tmp = ret; + } + tcg_out_opc_sltu(s, ret, TCG_REG_ZERO, tmp); + break; + case TCG_COND_LT: + tcg_out_opc_slt(s, ret, arg1, arg2); + break; + case TCG_COND_GE: + tcg_out_opc_slt(s, ret, arg1, arg2); + tcg_out_opc_xori(s, ret, ret, 1); + break; + case TCG_COND_LE: + tcg_out_setcond(s, TCG_COND_GE, ret, arg2, arg1, false); + break; + case TCG_COND_GT: + tcg_out_setcond(s, TCG_COND_LT, ret, arg2, arg1, false); + break; + case TCG_COND_LTU: + tcg_out_opc_sltu(s, ret, arg1, arg2); + break; + case TCG_COND_GEU: + tcg_out_opc_sltu(s, ret, arg1, arg2); + tcg_out_opc_xori(s, ret, ret, 1); + break; + case TCG_COND_LEU: + tcg_out_setcond(s, TCG_COND_GEU, ret, arg2, arg1, false); + break; + case TCG_COND_GTU: + tcg_out_setcond(s, TCG_COND_LTU, ret, arg2, arg1, false); + break; + default: + g_assert_not_reached(); + break; + } +} + /* * Branch helpers */ @@ -815,6 +875,11 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_opc_mod_du(s, a0, a1, a2); break; + case INDEX_op_setcond_i32: + case INDEX_op_setcond_i64: + tcg_out_setcond(s, args[3], a0, a1, a2, c2); + break; + case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ case INDEX_op_mov_i64: default: @@ -901,6 +966,10 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_ctz_i64: return C_O1_I2(r, r, rW); + case INDEX_op_setcond_i32: + case INDEX_op_setcond_i64: + return C_O1_I2(r, r, rZ); + case INDEX_op_deposit_i32: case INDEX_op_deposit_i64: /* Must deposit into the same register as input */