From patchwork Tue Dec 21 16:47:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526609 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5230332imb; Tue, 21 Dec 2021 08:59:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUVkfRVMbwnNX+MYTXLGPdL0CqnRd1rzE/ePdNKdC0xPb+v+byPAaRjxrOn069sAK+rXqq X-Received: by 2002:a25:cd47:: with SMTP id d68mr5837266ybf.537.1640105992917; Tue, 21 Dec 2021 08:59:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640105992; cv=none; d=google.com; s=arc-20160816; b=dn4M4gY3CkXA54YSbxulQQ8+hqKkc/cjx3H+A0dz4j8ZfA0Nx/RXQ/4v41H0rRLhVi xUa0vmhfHVK2tOl4erE2owfNxUFAC4mRhWNehOhAfP+nhd8Hqei24nRqRrSGms5BG2aZ hweReZkmxCWgubgC40o0SpJQrbskd0lUQPuI38uK0Mzs83IdOylEVwuLgRHrBQXSVxtb WoCeCBTBDc+NnZMf9CTppU+L4/X54Q9niRSOraMKkpP4wtjHLnM71q7Xox8k7YhxuiL4 htub7aJWAQe0FdLdKjQ6m8iPSmnAwDgdMFkqvUiD+7WGQAB0f6Or0EmFN0gZIFYk6GNt sF9A== 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=h3IfsTdV++ttG/ya2ZB3/Tnu3hCKPlZE3g7VrtqS5qs=; b=0PT9PTNfFVN3TBSY0E//jftmx5n2fBlir5hL2o8KnSQe7N+xRvnyjeGCmVqBiBJLNF ERfSv7MW+zYNH3+9P15jY8PHvU3lZwongAlFggcROc5tM/ldo7CjH1I2azWeim72OF1Y D3O1g0wzYV/q9eb7nuQdLa2vos8PJTQXcozj8bbj9Is9bRFtO+5MWdqYM81kUNEXvbic OP96Ep5eHoH/pmaRYhFzVnjJyCvbps1jG6o8DjD+xwQs/Y0o6vHC0ncMSTlEwv9fokKM kjgLQac4Gw2MM17pXfnRP1yrZBWJ4KPsi2ZJSEg02BAvPj5hv29Ht6aEYvCCusEpQble CCpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yeg8AST4; 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 l3si31078237ybt.551.2021.12.21.08.59.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 08:59:52 -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=Yeg8AST4; 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]:35522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziUS-00010W-Bc for patch@linaro.org; Tue, 21 Dec 2021 11:59:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziIz-0000Ti-OK for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:01 -0500 Received: from [2607:f8b0:4864:20::630] (port=42659 helo=mail-pl1-x630.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIu-0007dj-P7 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:01 -0500 Received: by mail-pl1-x630.google.com with SMTP id u16so5130121plg.9 for ; Tue, 21 Dec 2021 08:47:56 -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=h3IfsTdV++ttG/ya2ZB3/Tnu3hCKPlZE3g7VrtqS5qs=; b=Yeg8AST4CNOucOgTT6w+X4gPmPq5dcct0qbHq2JkL5nEHNHlh0dx+rISAlupygPxzt Ff2jVbxD/KF5PIQK9hxsSLWgH3W821ISL/bXTdcKK9XPZaxs9GVU4wBblVzO12Fq9IJ2 yYfKKy9+YtlNtfSSWTXpUMHHEEdou7NNbO+JvJt114QPkNRc20QSVpOptQUTRBGlRB4M hfr3hR9SlIwz7CZcF889CeqBwooRaBhZouLAcsvymdu2RZ2LreOKzOkkvyenugEELdzF mpuMptmYva963iBIqu1ELWPE73mDHSKZ8TQzCKZayjHuRPPP1gblXtdAeLzi1toUKftV zxdA== 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=h3IfsTdV++ttG/ya2ZB3/Tnu3hCKPlZE3g7VrtqS5qs=; b=xem4hCenScfQAczQX5kO2GG2ADnXbnE1OGRuvYEz3vWDunDD1DoM3VvCv8eB85QhJ+ Z13GrQqycccNCSHeZzyM2XQfWdn/3zqDDRtMahGLUxHtcjSd8BobUNpd9x5T0HjUYsqf NMQFaZnGGEpXoYleEBJmOHizCsZCLDOw/s9jwX5e20L9DxILklp1rXKJ0uM+oLEpR3f1 NjB2CEgsAPWCdYxH42qRtC/IJe16/fFYdg9Lz4/Jhsx/9pGKf1djRJCZwUqtc1AXzc3b e9PYoIsvMBaJWCXN9Vcf6u4tYqU4RKk/y4+RuY7ACVHwEMum+OK1hUiG7fHrK+3n6Vvw hmiA== X-Gm-Message-State: AOAM530Cup0PYcYfAxejewYNr88Q8RG4NU+H11mvhiNyDsKnkj0cSugD X60a9Ocux9ayg8CtTv3bnYL2pInmVm3unQ== X-Received: by 2002:a17:90b:3b81:: with SMTP id pc1mr5095709pjb.67.1640105275604; Tue, 21 Dec 2021 08:47:55 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 18/31] tcg/loongarch64: Implement mul/mulsh/muluh/div/divu/rem/remu ops Date: Tue, 21 Dec 2021 08:47:24 -0800 Message-Id: <20211221164737.1076007-19-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::630 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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 , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= 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 Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-19-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target-con-set.h | 1 + tcg/loongarch64/tcg-target.h | 16 +++---- tcg/loongarch64/tcg-target.c.inc | 65 ++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 8 deletions(-) diff --git a/tcg/loongarch64/tcg-target-con-set.h b/tcg/loongarch64/tcg-target-con-set.h index 4b8ce85897..fb56f3a295 100644 --- a/tcg/loongarch64/tcg-target-con-set.h +++ b/tcg/loongarch64/tcg-target-con-set.h @@ -23,3 +23,4 @@ C_O1_I2(r, r, rU) C_O1_I2(r, r, rW) 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.h b/tcg/loongarch64/tcg-target.h index d1ded50cb0..05010805e7 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -93,8 +93,8 @@ typedef enum { /* optional instructions */ #define TCG_TARGET_HAS_movcond_i32 0 -#define TCG_TARGET_HAS_div_i32 0 -#define TCG_TARGET_HAS_rem_i32 0 +#define TCG_TARGET_HAS_div_i32 1 +#define TCG_TARGET_HAS_rem_i32 1 #define TCG_TARGET_HAS_div2_i32 0 #define TCG_TARGET_HAS_rot_i32 1 #define TCG_TARGET_HAS_deposit_i32 1 @@ -105,8 +105,8 @@ typedef enum { #define TCG_TARGET_HAS_sub2_i32 0 #define TCG_TARGET_HAS_mulu2_i32 0 #define TCG_TARGET_HAS_muls2_i32 0 -#define TCG_TARGET_HAS_muluh_i32 0 -#define TCG_TARGET_HAS_mulsh_i32 0 +#define TCG_TARGET_HAS_muluh_i32 1 +#define TCG_TARGET_HAS_mulsh_i32 1 #define TCG_TARGET_HAS_ext8s_i32 1 #define TCG_TARGET_HAS_ext16s_i32 1 #define TCG_TARGET_HAS_ext8u_i32 1 @@ -130,8 +130,8 @@ typedef enum { /* 64-bit operations */ #define TCG_TARGET_HAS_movcond_i64 0 -#define TCG_TARGET_HAS_div_i64 0 -#define TCG_TARGET_HAS_rem_i64 0 +#define TCG_TARGET_HAS_div_i64 1 +#define TCG_TARGET_HAS_rem_i64 1 #define TCG_TARGET_HAS_div2_i64 0 #define TCG_TARGET_HAS_rot_i64 1 #define TCG_TARGET_HAS_deposit_i64 1 @@ -163,8 +163,8 @@ typedef enum { #define TCG_TARGET_HAS_sub2_i64 0 #define TCG_TARGET_HAS_mulu2_i64 0 #define TCG_TARGET_HAS_muls2_i64 0 -#define TCG_TARGET_HAS_muluh_i64 0 -#define TCG_TARGET_HAS_mulsh_i64 0 +#define TCG_TARGET_HAS_muluh_i64 1 +#define TCG_TARGET_HAS_mulsh_i64 1 /* not defined -- call should be eliminated at compile time */ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index c71d25d3fe..0ae193fba5 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -717,6 +717,55 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, } break; + case INDEX_op_mul_i32: + tcg_out_opc_mul_w(s, a0, a1, a2); + break; + case INDEX_op_mul_i64: + tcg_out_opc_mul_d(s, a0, a1, a2); + break; + + case INDEX_op_mulsh_i32: + tcg_out_opc_mulh_w(s, a0, a1, a2); + break; + case INDEX_op_mulsh_i64: + tcg_out_opc_mulh_d(s, a0, a1, a2); + break; + + case INDEX_op_muluh_i32: + tcg_out_opc_mulh_wu(s, a0, a1, a2); + break; + case INDEX_op_muluh_i64: + tcg_out_opc_mulh_du(s, a0, a1, a2); + break; + + case INDEX_op_div_i32: + tcg_out_opc_div_w(s, a0, a1, a2); + break; + case INDEX_op_div_i64: + tcg_out_opc_div_d(s, a0, a1, a2); + break; + + case INDEX_op_divu_i32: + tcg_out_opc_div_wu(s, a0, a1, a2); + break; + case INDEX_op_divu_i64: + tcg_out_opc_div_du(s, a0, a1, a2); + break; + + case INDEX_op_rem_i32: + tcg_out_opc_mod_w(s, a0, a1, a2); + break; + case INDEX_op_rem_i64: + tcg_out_opc_mod_d(s, a0, a1, a2); + break; + + case INDEX_op_remu_i32: + tcg_out_opc_mod_wu(s, a0, a1, a2); + break; + case INDEX_op_remu_i64: + tcg_out_opc_mod_du(s, a0, a1, a2); + break; + case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ case INDEX_op_mov_i64: default: @@ -808,6 +857,22 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_sub_i64: return C_O1_I2(r, rZ, rN); + case INDEX_op_mul_i32: + case INDEX_op_mul_i64: + case INDEX_op_mulsh_i32: + case INDEX_op_mulsh_i64: + case INDEX_op_muluh_i32: + case INDEX_op_muluh_i64: + case INDEX_op_div_i32: + case INDEX_op_div_i64: + case INDEX_op_divu_i32: + case INDEX_op_divu_i64: + case INDEX_op_rem_i32: + case INDEX_op_rem_i64: + case INDEX_op_remu_i32: + case INDEX_op_remu_i64: + return C_O1_I2(r, rZ, rZ); + default: g_assert_not_reached(); }