From patchwork Wed Aug 23 20:23:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 716126 Delivered-To: patch@linaro.org Received: by 2002:adf:f747:0:b0:317:ecd7:513f with SMTP id z7csp1002960wrp; Wed, 23 Aug 2023 13:27:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGElYi6hARkJFDDbCFy9oWoddsA+fRBs+0G8iDdr8ZS5PwiVXTZk6j41Wi07gMwBj0PhAZp X-Received: by 2002:ae9:f70e:0:b0:76c:df65:b5fb with SMTP id s14-20020ae9f70e000000b0076cdf65b5fbmr13410403qkg.72.1692822470584; Wed, 23 Aug 2023 13:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692822470; cv=none; d=google.com; s=arc-20160816; b=UkuC7pLK8gVuFB8lOcgR/Aoihlx/J4oEl4QThW14cILIwu1ym0S2tuQyMnUikFSBSB qzqTk53m47VXaHteXsSR/jD6rFgHiWV1jqG4ijMaqAfvvGOEBizNsYNlo/sZqrBd30Uu xNMEwosRV/GP1rJApo+zc5f3/K9yUmSqOLixgfediSamYfPH6Xkpkew8ryjlgIE9KJvd DqpE8EYue5CL29HUvW4k38U7sQ7I3YSugN+cVFoREol/vIGopoagr7hoeKK5stPeF3MU iRhT7guMFSbj7xoIguh9WZkziCEuyGOzbzo80SOuVthFJljOvAkVQZphaeHP8+pbkeY1 oHuQ== 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=GM9qcgiCUzexTHGWX5t+ahLOGZIdFkTo6Y1+THQiB14=; fh=i1mkeM7bD/ppus3C3v+92ltBBCUUU0zBXrpbYjAjHqE=; b=V0ZFxSVkPjneisyy1rM84jjPtMGmAtjMDN4YvExfXxOQhjRQZPaxWIfE/0umqGXdgE JWdZw1ZeWiMU1DYduWwTOmNscuKvvdc6pduNzD91b4m8EYIQ/QMwhW/GGfzdOaCWtd6J Q5xT1ihfVJ3qNyqJ4U5L/0dOuBQC1I354mZDCSN4/pSme9Rr6eVesfQEO+rXKFp1/s28 Ra1pSNUJAkSDqDnvbvhL3INcVeG4XhGGVgzahk18yrSI38uZ9opZ8s9WN3ULZQ5214aW B6VgqtBaMEmVLXMH/ncOZhQNgf4OZZbjxszzc47K3QX3irjc0hNqoqBmOXtdH3VOmAtw J48g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fhjxzxnW; 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 l10-20020a05620a28ca00b0076ce743152dsi7897696qkp.754.2023.08.23.13.27.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Aug 2023 13:27:50 -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=fhjxzxnW; 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 1qYuRc-0005KL-J0; Wed, 23 Aug 2023 16:27:12 -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 1qYuRY-00055e-8v for qemu-devel@nongnu.org; Wed, 23 Aug 2023 16:27:08 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qYuRW-0006CR-G0 for qemu-devel@nongnu.org; Wed, 23 Aug 2023 16:27:07 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-68a1af910e0so3238923b3a.2 for ; Wed, 23 Aug 2023 13:27:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692822425; x=1693427225; 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=GM9qcgiCUzexTHGWX5t+ahLOGZIdFkTo6Y1+THQiB14=; b=fhjxzxnWlPTHUNn54KpsaVCc/2JvLM79nZ8K6ZpVMzklcPrjcFx4/Oi16r8WIiLo9O wOyNOQWXTD3ajs9cNqrIvtxHfcXpK+DTOEL+FAU1HnbtLCXjfMxkOaXIX79AzCQtgIS5 pPA8tvUFxbWQbMBOeyFvijE2FyfnSbVDS1pzqvZjgVNxXVfkwD2CsrwQD4vmBJdscaIY qaZyHhgpymOsvcHipqawipP4EI6wb4jUlcf23SiNT2u1tazKJzd9pqmkqCsB6QbuGxnv yThp99c6RbCWKDojhZtP0cSKb/I5xT2Y9J6sP+tBdeG7VllGB/yJUObJHJaeeSfFqbhM Hpgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692822425; x=1693427225; 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=GM9qcgiCUzexTHGWX5t+ahLOGZIdFkTo6Y1+THQiB14=; b=g9MZ3RDxGv/YJApLn2jjOgBEhDR5L4k7jf7tqA4Qa3jyAPgT4Iq5Bn27J78B9jChvK gnmQhNs+cRLwWBEaXW1AU+QPSrqcZc04bBeZCJA3pDTHpP4pNpIhM9mKU6VoKBfB+2Xa VmfjafzJG9zwHKzBf6/a5LXSU7KMQ6fckanzsqf+LAmUZ4ECm80xUmv+oFuyZl5QRx1q tYbVIGHRmntKY7uoreaNLZCb7WiehWU2XSvKecFBOl+oAeKOqKSME+ynk2whdGdjLt3X snkO9wU2KtcuQThFbf/dlX4E9y+y6UBMLhytgI8mbEXH/1oa4zvolXMeoottWSU9rwgX OcOw== X-Gm-Message-State: AOJu0YyNvyNdWcaatu5OJ9KoENB6PWpCjAnxLzOFdgMKv4xAu/afa1nU Rxs2jTYO5zS5Fr2LQTtQ6l+VlwB5XhNwmf5Yk04= X-Received: by 2002:a05:6a00:896:b0:68a:582b:6b6d with SMTP id q22-20020a056a00089600b0068a582b6b6dmr9084609pfj.1.1692822424760; Wed, 23 Aug 2023 13:27:04 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:72f0:1ea7:85d2:141e]) by smtp.gmail.com with ESMTPSA id j25-20020aa783d9000000b006873aa079aasm10117871pfn.171.2023.08.23.13.27.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 13:27:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 40/48] tcg/tcg-op: Document bswap16_i64() byte pattern Date: Wed, 23 Aug 2023 13:23:18 -0700 Message-Id: <20230823202326.1353645-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823202326.1353645-1-richard.henderson@linaro.org> References: <20230823202326.1353645-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.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 From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20230823145542.79633-3-philmd@linaro.org> Signed-off-by: Richard Henderson --- tcg/tcg-op.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index fc3a0ab7fc..88c7c60ffe 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -1767,6 +1767,14 @@ 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. + * + * Byte pattern: xxxxxxxxab -> yyyyyyyyba + * + * With TCG_BSWAP_IZ, x == zero, else undefined. + * With TCG_BSWAP_OZ, y == zero, with TCG_BSWAP_OS y == sign, else undefined. + */ void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg, int flags) { /* Only one extension flag may be present. */ @@ -1785,22 +1793,25 @@ 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 = ......ab or xxxxxxab */ + tcg_gen_shri_i64(t0, arg, 8); /* t0 = .......a or .xxxxxxa */ if (!(flags & TCG_BSWAP_IZ)) { - tcg_gen_ext8u_i64(t0, t0); + tcg_gen_ext8u_i64(t0, t0); /* t0 = .......a */ } 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....... */ + tcg_gen_sari_i64(t1, t1, 48); /* t1 = ssssssb. */ } 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 */ + tcg_gen_shli_i64(t1, t1, 8); /* t1 = ......b. */ } else { - tcg_gen_shli_i64(t1, arg, 8); + tcg_gen_shli_i64(t1, arg, 8); /* t1 = xxxxxab. */ } - tcg_gen_or_i64(ret, t0, t1); + tcg_gen_or_i64(ret, t0, t1); /* ret = ......ba (OZ) */ + /* ssssssba (OS) */ + /* xxxxxaba (no flag) */ tcg_temp_free_i64(t0); tcg_temp_free_i64(t1); }