From patchwork Wed Aug 23 14:55:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 716088 Delivered-To: patch@linaro.org Received: by 2002:adf:f747:0:b0:317:ecd7:513f with SMTP id z7csp845858wrp; Wed, 23 Aug 2023 07:57:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE+JTUFnR5GDggTFhMdSww19mwhWTr4OjLAZpjEvwWcSuKUvm4onuF6lFPk+XeMaFc7g902 X-Received: by 2002:a0c:cb8a:0:b0:61f:ace6:e94e with SMTP id p10-20020a0ccb8a000000b0061face6e94emr13016710qvk.0.1692802637128; Wed, 23 Aug 2023 07:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692802637; cv=none; d=google.com; s=arc-20160816; b=AhPW38N3sjPMazEUOf/xEI6j6u1oCgWiTvQyeoqI2MyHJnjSA5Dfa8m+QUK9y2xb6o uiNPHUbB35ZUIgTV6KaZGIxB+7/oWKWvfADrilPpVq6CuvgoTwtqRAplCoazPYnk0TK5 BGh2MeuECGHweQSStRdW6bANbfOfsmkhbuhi5mjrO+7/kga066p++h5LVq92PUB6be+C kyNcSr/A2pXObbJnRd66Ahj//sOj0V47+BW5vAfMmwAKjKHcBUkdE/9gXvc7JFPvx0nn 3pada5J+MVg7ML3EJkIzrBT4Z6hOafLe0us51I40xQfOyxF0u3lahV4L+8UxvYhmiN51 mjZA== 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=bgZaltKaeNfzqYDJtYBATNYhh0W6KTRpUukWBytbNs8=; fh=yu5WrcKZQNMrhC/JtztxdBEgrd5tmo4xnBF1jMP240s=; b=tshf5ljsBsUN5QrRZZVvOID1QM/lHaSDc+RNJo8vSQ/IhdzH1bSPjnQWdIFp0Mm4O6 7oW3S9trFmoRRmn5NzDUgvHZklt2tc69q64Kcw00wETS+eY+1fsfsD5QqSKZnwrHkbal T66Qv3qyHLsc7hL/2jZi6eKo5uCoPbDfuDeEQzVzosopFH/cOx7ykoRiQFLh8ifGI9L+ Gct1/xm3v6tvaXSI935e8Iqm2zFtoSK1aGQpDjATsqJBdAjH4e02Bk+MeHmo4A3TTJU5 F5mayHz598KZ9BeSX8SI4zWLJsgsDKRES2ejjKyCJ+6kM3LvGb9Prux69TeJulX599vu 0H7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=imbUPrQa; 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 x1-20020a0ce241000000b006418d1582b2si7288936qvl.392.2023.08.23.07.57.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Aug 2023 07:57:17 -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=imbUPrQa; 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 1qYpHk-0006vF-Te; Wed, 23 Aug 2023 10:56:40 -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 1qYpH5-0006lY-KF for qemu-devel@nongnu.org; Wed, 23 Aug 2023 10:55:59 -0400 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qYpH4-0007WK-40 for qemu-devel@nongnu.org; Wed, 23 Aug 2023 10:55:59 -0400 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-98377c5d53eso725828766b.0 for ; Wed, 23 Aug 2023 07:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692802556; x=1693407356; 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=bgZaltKaeNfzqYDJtYBATNYhh0W6KTRpUukWBytbNs8=; b=imbUPrQay4ivpe5Hg6tytg00Gi8LZDnmAqBGnTv8aeYRYLu94QSvKsMefHzNCAL5K5 ouE8/ljprGj62ECOTYxtmb8eLj4rX8WClgPiCGUu53EjXbUZDe3B3mb4IW0lIt/0rAyN fJUwzgm2iCsGX3PG4tqkaUHULG1R+9xZKG3SH5dGVXr0IExMTRCZ49/pPorxGnAUOJ4A zfwQTUFVXxfBfc5kA1TXGI+POcCnE9KhVp3WsTRHGCnORBHrLmTIVYceuk5HHLyzsXAo iw2KuNpXUumrKFCOSZNvEwHaNC9rTtFoVhAfQ2vuY/kIe93iR7HA9n2Qqhvmultie+Zf 8kkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692802556; x=1693407356; 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=bgZaltKaeNfzqYDJtYBATNYhh0W6KTRpUukWBytbNs8=; b=XKauATygfvhQgNlKraQE6HZob0FeQ9wFPUoN3kmUSNqrpELxm2c010Xf3n5GqHxeVD kDn21jqhRf4gKShpNNojq8MyZsCCR2rirmYJKBT0HiLxqYpUGZ1ctsyW2LCxnABT2RL/ Ki/omMYQQik3yYQdVrYIw6iXVwu6gyddKo2v2cbz0IaSspBGjRyTCN4FTpn+ufcrsC0x Wg12hKj69VEnvhRpbR6OAl2BxyPo2eNOqQbg8QA5aBhZRNEe8621HbmEuElni3D+6hLs uUOUa55MBwDaOBr3uWol1KyHGXWZE1rqq1R+2ga6QeOhZmCeVC7xe6JdL6K+9Ig2ewpZ /2fQ== X-Gm-Message-State: AOJu0YwaXTRP37s5OiMLG2jluIZ55U3iqdiD062HYpdQRW8Lbha+5TmV 8QpN2FVaCSQStJFKp3To+yhwt+BdXFk013ZKaiSKBg== X-Received: by 2002:a17:906:538d:b0:99d:6dd7:42c2 with SMTP id g13-20020a170906538d00b0099d6dd742c2mr10913390ejo.40.1692802556337; Wed, 23 Aug 2023 07:55:56 -0700 (PDT) Received: from m1x-phil.lan (gsv95-h03-176-172-10-165.dsl.sta.abo.bbox.fr. [176.172.10.165]) by smtp.gmail.com with ESMTPSA id d16-20020a17090648d000b0098d2d219649sm9942518ejt.174.2023.08.23.07.55.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 23 Aug 2023 07:55:55 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , "Edgar E. Iglesias" , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 2/8] tcg/tcg-op: Document bswap16_i64() byte pattern Date: Wed, 23 Aug 2023 16:55:36 +0200 Message-ID: <20230823145542.79633-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230823145542.79633-1-philmd@linaro.org> References: <20230823145542.79633-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=philmd@linaro.org; helo=mail-ej1-x62b.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: Philippe Mathieu-Daudé --- tcg/tcg-op.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index c1b9a3e34c..80ec6f01c4 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -1737,6 +1737,15 @@ void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg) } } +/* + * bswap16_i64: 16-bit byte swap on the low bits of a 64-bit value. + * + * flags + * Byte pattern: bswap16_i32(......ab) -> ......ba (TCG_BSWAP_IZ) + * bswap16_i32(xxxxxxab) -> ......ba (TCG_BSWAP_OZ) + * bswap16_i32(xxxxxxab) -> ssssssba (TCG_BSWAP_OS) + * bswap16_i32(xxxxxxab) -> xxxxxxba + */ void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg, int flags) { /* Only one extension flag may be present. */ @@ -1755,22 +1764,28 @@ void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg, int flags) TCGv_i64 t0 = tcg_temp_ebb_new_i64(); TCGv_i64 t1 = tcg_temp_ebb_new_i64(); - tcg_gen_shri_i64(t0, arg, 8); + /* arg = xxxxxxab (IZ=0) */ + /* = ......ab (IZ=1) */ + tcg_gen_shri_i64(t0, arg, 8); /* t0 = .xxxxxxa (IZ=0) */ + /* = .......a (IZ=1) */ if (!(flags & TCG_BSWAP_IZ)) { - tcg_gen_ext8u_i64(t0, t0); + tcg_gen_ext8u_i64(t0, t0); /* t0 = .......a (IZ=0) */ } if (flags & TCG_BSWAP_OS) { - tcg_gen_shli_i64(t1, arg, 56); - tcg_gen_sari_i64(t1, t1, 48); + tcg_gen_shli_i64(t1, arg, 56); /* t1 = b....... (OS=1) */ + tcg_gen_sari_i64(t1, t1, 48); /* t1 = ssssssb. (OS=1) */ } else if (flags & TCG_BSWAP_OZ) { - tcg_gen_ext8u_i64(t1, arg); - tcg_gen_shli_i64(t1, t1, 8); + tcg_gen_ext8u_i64(t1, arg); /* t1 = .......b (OZ=1) */ + tcg_gen_shli_i64(t1, t1, 8); /* t1 = ......b. (OZ=1) */ } else { - tcg_gen_shli_i64(t1, arg, 8); + tcg_gen_shli_i64(t1, arg, 8); /* t1 = xxxxxxb. (IZ=0) */ + /* ......b. (IZ=1) */ } - tcg_gen_or_i64(ret, t0, t1); + tcg_gen_or_i64(ret, t0, t1); /* ret = ......ba (IZ=1 or OZ=1) */ + /* ssssssba (OS=1) */ + /* xxxxxxba (no flag) */ tcg_temp_free_i64(t0); tcg_temp_free_i64(t1); }