From patchwork Tue Dec 21 16:47:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526605 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5228380imb; Tue, 21 Dec 2021 08:57:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXDESpHpV81v/zkOx5aLe+MPcW0Okk1c7JeSPDj0+bngV2fBu830Sqr+U5Xif8z1pqwj5D X-Received: by 2002:a05:6902:508:: with SMTP id x8mr5577790ybs.353.1640105820085; Tue, 21 Dec 2021 08:57:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640105820; cv=none; d=google.com; s=arc-20160816; b=LWg6kC8lPDKBUzl8jLvctZxE/aMqYr0QbbzQHj4+hWw2ifcHNzYBiWO3nsjYf1Tgu9 JqnpaQYpRV8csbwxp459qpMU/tQLKi7qFEBFJqbI3eQmnCLcxH5dP9RbMuXrz2yeQtl3 T0urCdOHl7kHiCJffnKI+PXnarjDLGupaTrKqKbdDCGA/VuDXvnYewP/ue+i3jm4lhw8 wWU/5qDvXi9pWV+Obu61PjRtadm2OV7HzM3dhzqac9smmGGLgFZBGS2DJEpD5JPr6Jx4 I8ZoY2rNPPxnPOzzMn0owAPRVnHQLqYVXVndW9vYitUz4BLg+fXR/U4hUdy2rjPc04xP dUsA== 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=cHpfaLVydfnDFFFHb5r43nae1+7GWHTxLwo4cKt6VDc=; b=N9YmRIjDP6BGsNhhr0KDjwFxT2K+tdi+oU47JqxrXAyv4LUP1WxygkE6KWhI2bPhyN Iric5n8R9EeuDNkOVhPmuf8jYPeAovwigtSx7z9wftzKECTKEfMki1U0LsCI4zSZIwNe 95z9SxmDo1RBf3cPVIA5odkvZqDn1PrtluV4Nuqlq7eURiiHO3vjKPeBwGsKCyf+OzKw T7Q3Ebm7pNGhpgAsBcGqyv0yYiOJavhv6/t4MfXzB2afFcKAu42v6Amjx0kurhpJ+8km fKNtccX2Y9Uy/44ZLmVUqDJziDxk2db/fcBsheat+xCkCJ5Q+mKNcI4cJBweEdBV61ae ziXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pXKNKqfZ; 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 z6si14511827ybn.234.2021.12.21.08.57.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 08:57:00 -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=pXKNKqfZ; 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]:54894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziRe-0003Ls-PR for patch@linaro.org; Tue, 21 Dec 2021 11:56:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziIu-0000EP-Uu for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:56 -0500 Received: from [2607:f8b0:4864:20::52e] (port=38654 helo=mail-pg1-x52e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIr-0007ct-17 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:56 -0500 Received: by mail-pg1-x52e.google.com with SMTP id y9so12829083pgj.5 for ; Tue, 21 Dec 2021 08:47:52 -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=cHpfaLVydfnDFFFHb5r43nae1+7GWHTxLwo4cKt6VDc=; b=pXKNKqfZjsDQ+6yOh6nvQ0YaCZMGFCD3yJMRbDKJtfogwvOYeB4j0YgzL1ofrOc++5 AZIW7LDUZJfIzDyGgQ8Mhtm+ZfMSXriiWJySrlFcNKelkvidcWTU3VJSqVauWzLhLZZp f1CBL8gWMloQ8nY0GVmE2SqYJz0io1oo8kOicnj627B/33cBGog/lsAEQ65GbHBwO6UN JUaxN784UfykO5eojhI31JlCFn8S/9Naw0j7uDyFS6mop7tEIUbWlip5LN5jl/6q8i+3 w4VGi31MadTkcLemLxLx362j+Vv/WTxluSNaZiMGII7MY0YUGGoLkzGFe5mOMD2SRZD3 ESFQ== 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=cHpfaLVydfnDFFFHb5r43nae1+7GWHTxLwo4cKt6VDc=; b=jSGB9QW1seWRo7SOzXkj7ysdxCoResEKjeKouAhCmIU+SKI0hrf3txziP341dXrV/p HhhcL99Oetx21X+5phwMO1NB+77Yc+qHlCXy3xbQ09n5LZFjsvNU8IJZir7dEJJNQwB/ 10evDIFkTO13T501HJ+eSYlr6UdiCoFBr402PW3wvuNoKPKmIsqc8W+duZwQ3FYvajvK 3UyQDadd96d2YBe7Q1KoXMe0FIeAJ00mNVgjgFisUDik9vSF7czE4OJi/xuCwgase9k8 BdYZ05b+6byKi4hDF5GyepInYdt7/09npb6oxc8b/oEHJX+kYSNuuqyjTaHsQambhcvg CSdQ== X-Gm-Message-State: AOAM533s0Bb4TtN4eZ2uB2jT7GtCZjsNx7KeFEv1Adfl241JVbV3/ssb CV4ROclAuMF4+r9ye7x4Nm4Hn/104EhaAg== X-Received: by 2002:a63:5250:: with SMTP id s16mr3741012pgl.202.1640105271789; Tue, 21 Dec 2021 08:47:51 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:51 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 14/31] tcg/loongarch64: Implement bswap{16,32,64} ops Date: Tue, 21 Dec 2021 08:47:20 -0800 Message-Id: <20211221164737.1076007-15-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::52e (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.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-15-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target.h | 10 +++++----- tcg/loongarch64/tcg-target.c.inc | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/tcg/loongarch64/tcg-target.h b/tcg/loongarch64/tcg-target.h index 1c9d0a9988..5303001653 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -111,8 +111,8 @@ typedef enum { #define TCG_TARGET_HAS_ext16s_i32 1 #define TCG_TARGET_HAS_ext8u_i32 1 #define TCG_TARGET_HAS_ext16u_i32 1 -#define TCG_TARGET_HAS_bswap16_i32 0 -#define TCG_TARGET_HAS_bswap32_i32 0 +#define TCG_TARGET_HAS_bswap16_i32 1 +#define TCG_TARGET_HAS_bswap32_i32 1 #define TCG_TARGET_HAS_not_i32 1 #define TCG_TARGET_HAS_neg_i32 0 #define TCG_TARGET_HAS_andc_i32 1 @@ -146,9 +146,9 @@ typedef enum { #define TCG_TARGET_HAS_ext8u_i64 1 #define TCG_TARGET_HAS_ext16u_i64 1 #define TCG_TARGET_HAS_ext32u_i64 1 -#define TCG_TARGET_HAS_bswap16_i64 0 -#define TCG_TARGET_HAS_bswap32_i64 0 -#define TCG_TARGET_HAS_bswap64_i64 0 +#define TCG_TARGET_HAS_bswap16_i64 1 +#define TCG_TARGET_HAS_bswap32_i64 1 +#define TCG_TARGET_HAS_bswap64_i64 1 #define TCG_TARGET_HAS_not_i64 1 #define TCG_TARGET_HAS_neg_i64 0 #define TCG_TARGET_HAS_andc_i64 1 diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 9eba8f8146..3b056dd358 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -545,6 +545,33 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_opc_bstrins_d(s, a0, a2, args[3], args[3] + args[4] - 1); break; + case INDEX_op_bswap16_i32: + case INDEX_op_bswap16_i64: + tcg_out_opc_revb_2h(s, a0, a1); + if (a2 & TCG_BSWAP_OS) { + tcg_out_ext16s(s, a0, a0); + } else if ((a2 & (TCG_BSWAP_IZ | TCG_BSWAP_OZ)) == TCG_BSWAP_OZ) { + tcg_out_ext16u(s, a0, a0); + } + break; + + case INDEX_op_bswap32_i32: + /* All 32-bit values are computed sign-extended in the register. */ + a2 = TCG_BSWAP_OS; + /* fallthrough */ + case INDEX_op_bswap32_i64: + tcg_out_opc_revb_2w(s, a0, a1); + if (a2 & TCG_BSWAP_OS) { + tcg_out_ext32s(s, a0, a0); + } else if ((a2 & (TCG_BSWAP_IZ | TCG_BSWAP_OZ)) == TCG_BSWAP_OZ) { + tcg_out_ext32u(s, a0, a0); + } + break; + + case INDEX_op_bswap64_i64: + tcg_out_opc_revb_d(s, a0, a1); + break; + case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ case INDEX_op_mov_i64: default: @@ -576,6 +603,11 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_not_i64: case INDEX_op_extract_i32: case INDEX_op_extract_i64: + case INDEX_op_bswap16_i32: + case INDEX_op_bswap16_i64: + case INDEX_op_bswap32_i32: + case INDEX_op_bswap32_i64: + case INDEX_op_bswap64_i64: return C_O1_I1(r, r); case INDEX_op_andc_i32: