From patchwork Wed Jan 18 01:11:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 643667 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp1489699pvb; Tue, 17 Jan 2023 17:12:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXuPwHMsanNVHDK5vidgKSx1LvspsI+os8LjbPItB71UGjTSKlK/CFMmzpGRrESavxf7KuSb X-Received: by 2002:a1f:5e4c:0:b0:3dd:fcae:155a with SMTP id s73-20020a1f5e4c000000b003ddfcae155amr2622126vkb.0.1674004356477; Tue, 17 Jan 2023 17:12:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674004356; cv=none; d=google.com; s=arc-20160816; b=xUHYtmACsDC7TUwZH9pdSw+2sd6/NerkVmkdQ/0vRPlZH/RMxzWfui7wMsLmc8QLxY lZQgr4HnzBfgPwJWQvVIv9NAHwOD5CxKvoZCFM9q0LjJtywow9WPeFCTDnQT3UWQjdj/ ccCr0QCJCJDOHqTIu00M2lSmlg7Bu7FmvuIkLD29S4zfZGaZ+J6JnvTlnlzMFwiaZtQv Kopzo7jcMN+o1qlV15BTYUKFRCrz874qFKh5sFaBw/WwRIry26g+FsEoiGakDD9DtfIJ VMG+iGaJOZzAyjU5ENa2t5lhwF3YSUBK93Q79MO8kcZTrHQ4iItCmAxxEQJ8+fDsh4vd EMvQ== 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=di6N0vCGrpxWgO4hD16WY7qQUgaqSSofB9q2lj/lJG4=; b=qGlpoHJcSm/dyZNRFbVvY77qM3jbyTB0hLqBPtXxNWfbyp2hIGaiedm1FvW4dtSolv u8YfEinUc6Jl25DHVnbW50+WeTpa1X8ICXZDlAp3zqPBTowsz4GBa71CqLwdmdgLg45I fla4jSK6+1t2mxauaDLRXb83G3ERj05dYF9fPm4WRWmNGhoijiczb/rNSJpqg2D5oSEt 7LgtGYNkjTyZ9aqnB8gjKuXbreOGmniuwMgu8lJDAPmVIfUE9PWmr+/mTxSbt0SBSMCr Nq1NN2Hj9+/KwMlrNpukjMNF2GDXbqLYdNTWja9eEPY3JtVlMl36eOYoa/ri7HPw5Mag cIFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tmIYp5OI; 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 ow9-20020a05620a820900b006fa9e4de9c3si17896044qkn.408.2023.01.17.17.12.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jan 2023 17:12:36 -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=tmIYp5OI; 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 1pHwzO-00027F-Ga; Tue, 17 Jan 2023 20:11:42 -0500 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 1pHwzN-00024S-DH for qemu-devel@nongnu.org; Tue, 17 Jan 2023 20:11:41 -0500 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pHwzL-0002FV-Nk for qemu-devel@nongnu.org; Tue, 17 Jan 2023 20:11:41 -0500 Received: by mail-pj1-x102e.google.com with SMTP id gz9-20020a17090b0ec900b002290bda1b07so635809pjb.1 for ; Tue, 17 Jan 2023 17:11:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=di6N0vCGrpxWgO4hD16WY7qQUgaqSSofB9q2lj/lJG4=; b=tmIYp5OIpIWHVYofD6pgKSZYCAKeY0nUi6RiH0NXATZfGILkug6rO0X2feiuT4386p ZYA7Sevznhv2b4ie8X2Y0VJXHO3R8VR1TfL0hyYK9k82XsEX1Ttn5JDk/483sdDx9Lx+ 3cNHH7ko7eODorOl1Lx2onFdBUyRHi0SP+xqKVl/oZIhZH7nUhOM2vOcAZZrdZijBfPe 9SIW3wiyPQFypdU9/CmxMT7p/fB8aMYauqAGZCzW62+0hxJyOCZEfQayl9MQxOvtpObs cNn9My7H1INYU2yoPWObXchjO1yUzelQ+xSoogqxuQzs+k95ZeTwpa1uNiguqamq3sv3 w7UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=di6N0vCGrpxWgO4hD16WY7qQUgaqSSofB9q2lj/lJG4=; b=MUF9l4nX9E6Q8hYAXGci4p0Nkd8LF9c88TePJGrsw1z5MReqHInkSPCTQPVywAEig5 CitNRcFF1LziHizhjY9IonE6FsMO98tx7bIGyB9VhgT0QQDaWSVTT31z3wK75boOX+eb p1ywCsippGk5zw40AI+Xkc4tpow3ezxs+lXQn6I2qS6ysjkV9m0zJnviKZ6pJWg/w+FV 2rbjiuPoH/CFX+paVfRUvw1XoilRXG8dO8rY5Ulty18zRSLKqHtapNaA4gkpQujl30Gb +rvloz3Ffof2Aft+VnU8Hmvdn2X3hcD9DNKo7+oiKoGjZGyAb9hryD+pslsTcFaSFb2N 8u7g== X-Gm-Message-State: AFqh2kpmghJNopKW66i/PDEOIY2LZ9mrB4LVpX3zThVF0aR3ERktxg/5 JR+d4N/dBsVBkILhhv89zW3GGZprC4GXPGdu X-Received: by 2002:a17:902:c1d2:b0:194:7400:7c14 with SMTP id c18-20020a170902c1d200b0019474007c14mr5792877plc.34.1674004298492; Tue, 17 Jan 2023 17:11:38 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id s7-20020a170902988700b0017ec1b1bf9fsm21660259plp.217.2023.01.17.17.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 17:11:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: git@xen0n.name Subject: [PATCH v2 08/10] tcg/loongarch64: Implement movcond Date: Tue, 17 Jan 2023 15:11:21 -1000 Message-Id: <20230118011123.392823-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118011123.392823-1-richard.henderson@linaro.org> References: <20230118011123.392823-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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 Reviewed-by: WANG Xuerui --- tcg/loongarch64/tcg-target-con-set.h | 1 + tcg/loongarch64/tcg-target.h | 4 ++-- tcg/loongarch64/tcg-target.c.inc | 33 ++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/tcg/loongarch64/tcg-target-con-set.h b/tcg/loongarch64/tcg-target-con-set.h index 7b5a7a3f5d..172c107289 100644 --- a/tcg/loongarch64/tcg-target-con-set.h +++ b/tcg/loongarch64/tcg-target-con-set.h @@ -31,3 +31,4 @@ C_O1_I2(r, 0, rZ) C_O1_I2(r, rZ, ri) C_O1_I2(r, rZ, rJ) C_O1_I2(r, rZ, rZ) +C_O1_I4(r, rZ, rJ, rZ, rZ) diff --git a/tcg/loongarch64/tcg-target.h b/tcg/loongarch64/tcg-target.h index 1c3e48d662..533a539ce9 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -97,7 +97,7 @@ typedef enum { #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL /* optional instructions */ -#define TCG_TARGET_HAS_movcond_i32 0 +#define TCG_TARGET_HAS_movcond_i32 1 #define TCG_TARGET_HAS_div_i32 1 #define TCG_TARGET_HAS_rem_i32 1 #define TCG_TARGET_HAS_div2_i32 0 @@ -133,7 +133,7 @@ typedef enum { #define TCG_TARGET_HAS_qemu_st8_i32 0 /* 64-bit operations */ -#define TCG_TARGET_HAS_movcond_i64 0 +#define TCG_TARGET_HAS_movcond_i64 1 #define TCG_TARGET_HAS_div_i64 1 #define TCG_TARGET_HAS_rem_i64 1 #define TCG_TARGET_HAS_div2_i64 0 diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index ccc1c0f392..29d75c80eb 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -596,6 +596,30 @@ static void tcg_out_setcond(TCGContext *s, TCGCond cond, TCGReg ret, } } +static void tcg_out_movcond(TCGContext *s, TCGCond cond, TCGReg ret, + TCGReg c1, tcg_target_long c2, bool const2, + TCGReg v1, TCGReg v2) +{ + int tmpflags = tcg_out_setcond_int(s, cond, TCG_REG_TMP0, c1, c2, const2); + TCGReg t; + + /* Standardize the test below to t != 0. */ + if (tmpflags & SETCOND_INV) { + t = v1, v1 = v2, v2 = t; + } + + t = tmpflags & ~SETCOND_FLAGS; + if (v1 == TCG_REG_ZERO) { + tcg_out_opc_masknez(s, ret, v2, t); + } else if (v2 == TCG_REG_ZERO) { + tcg_out_opc_maskeqz(s, ret, v1, t); + } else { + tcg_out_opc_masknez(s, TCG_REG_TMP2, v2, t); /* t ? 0 : v2 */ + tcg_out_opc_maskeqz(s, TCG_REG_TMP1, v1, t); /* t ? v1 : 0 */ + tcg_out_opc_or(s, ret, TCG_REG_TMP1, TCG_REG_TMP2); + } +} + /* * Branch helpers */ @@ -1538,6 +1562,11 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_setcond(s, args[3], a0, a1, a2, c2); break; + case INDEX_op_movcond_i32: + case INDEX_op_movcond_i64: + tcg_out_movcond(s, args[5], a0, a1, a2, c2, args[3], args[4]); + break; + case INDEX_op_ld8s_i32: case INDEX_op_ld8s_i64: tcg_out_ldst(s, OPC_LD_B, a0, a1, a2); @@ -1741,6 +1770,10 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_remu_i64: return C_O1_I2(r, rZ, rZ); + case INDEX_op_movcond_i32: + case INDEX_op_movcond_i64: + return C_O1_I4(r, rZ, rJ, rZ, rZ); + default: g_assert_not_reached(); }