From patchwork Sun May 16 12:33:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 439843 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp255307jac; Sun, 16 May 2021 05:39:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbcicg9bjZSJiHuLfMFT1entlBchqLHAJ+3Q42wtu47G/BsWsLU57Itupx7i7sfBWa/q5S X-Received: by 2002:a05:6e02:1baf:: with SMTP id n15mr48953169ili.148.1621168750639; Sun, 16 May 2021 05:39:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621168750; cv=none; d=google.com; s=arc-20160816; b=RJYAWSMiFEA6H0kjI6lWzmMYPBdqAbGAhLb+nmYqO7gAHDoHcyyVi7UP07bX69d6sx zwts1eBJkDBxlzuZ0Hxaf+IK4gXV4KuP6SqaX0AfngJEmtfM3LTWOMXqzD3WXiyJeNej Wp1ZL55Ert7LBe/UwRCdv8Ln5o8UeYt8vnrqz5ebFQPvSzDjKhJL2r+ZR+lcQ0a5NImG J1ef9OuA+umexSPtPfKCQySinrk5fOcjRw34S4RvPAW5HAxgLID5RkxSVRVEXTq4D5lV 6YJ13BJRV6eSoClnsvMqQR8Qk3UtS1BzoRnS+23Vv8J+/xaxXY+xsDTw2SCEFkJJrJ6B 7lqQ== 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=Fn81QolisoGBee6Unux0EG9mqgMNVVRkx5P5b1nS6oI=; b=JNV5ZM8yAdTEQ5TDDaNcfDYzIOtwtUwfnqklhOoHkI7wigvA4wx0vj71TuOFHL/zQU bVQyhFNJLqf/olt8MWNaE/vogwkxclPCXt39kViqITqAfaSApjPO4Ykp+49DPlf6OLgf TyvHONfyZNQzXrrugyQ9/X7vIF0CoBpwRp8guys++G6TWIaqsCrWPhqwmHNPLxtTdWXL UFpXoLqA2a16DNTbvU9LrUkY01EVNIQItcIDDbEAof8L5jo+JXcHmvKbfYv5XoKsnoiY sODXAo1iqi/hMVQ8T9JUyslYhfAdyS6OfWLOHthJo+9sm2nFx6oggqiSk4HgYDUad6Pw w34A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QZ9nI0XH; 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 c6si17258952iot.35.2021.05.16.05.39.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 16 May 2021 05:39:10 -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=QZ9nI0XH; 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]:60662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1liG34-0004eU-3W for patch@linaro.org; Sun, 16 May 2021 08:39:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1liFye-00079w-Pn for qemu-devel@nongnu.org; Sun, 16 May 2021 08:34:36 -0400 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]:34425) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1liFyc-0007da-Mj for qemu-devel@nongnu.org; Sun, 16 May 2021 08:34:36 -0400 Received: by mail-qt1-x82a.google.com with SMTP id v4so3033998qtp.1 for ; Sun, 16 May 2021 05:34:34 -0700 (PDT) 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=Fn81QolisoGBee6Unux0EG9mqgMNVVRkx5P5b1nS6oI=; b=QZ9nI0XHOe6nyyuHev0MOy1yF7amwTnAXleu8eQwyD7RJMrNHiClhuXWMXBO/WG0RE 9Mwsa0hBIgH/4IpHvSBCRtTmSr+kFSrYHhfsIr/GUm7j59T8EN8ISkfbMnyVnEwXcYmv YiQq4bmObLwv4QO4tljq/lLO8e4NQWyeF5ZEAHig85HiWfgjuPnl98geylf+rMAVa28s UKJlc+Zv+DR0joEjZmA67hHnglxM9u/O5ygSfIYKNSznLz9sKryWi1KqgPEwSGjiHuTM YfgVUC5Kl3FeRWrxv7ki5+M5Bb/kqvIbMOJWmM2QGjdYFpRQ5TMeY8dhcnKCgGkuci+W LzMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fn81QolisoGBee6Unux0EG9mqgMNVVRkx5P5b1nS6oI=; b=DmVzZLvMJj3c+rt98t79wUhRm09qfzAXlm1KnUAF0PTiEp+eqwAO+Zl4GgJIilJVGs /jbplp1QqdqpC0RraJY2APwkF3pWH8DVSZPhTkCbUIOsAhjsIIQiTJiRBh8PyklPxPDk VZmSHA01tn2m7u11vmGvot+0oZxEUSMW+UD8hF9HxG/XW/KfxzVbymSWhOsFO/V9RgPV zq4J1gfQdnU171Jwo/tAtMtCwjkb1affUG5UZlrt4IWDuLGuFpKDSUmEHhwot128ubOs PRbgOV0Fo2u9SSnd+UpJhtXzHdbJZXocksgspdKL0DKQG6jvVt4S2u/c+7hP7lwX4cgO RkTA== X-Gm-Message-State: AOAM530T01js/ZUieKLVLRzJCRn833AE9vsujWPUdEOiTZ/PPO8eVSng +6P1tS2cqm4sclrJ+Moa4xi98htiYmjHb0x3Z9M= X-Received: by 2002:ac8:12c5:: with SMTP id b5mr52250331qtj.203.1621168473720; Sun, 16 May 2021 05:34:33 -0700 (PDT) Received: from localhost.localdomain (163.189-204-200.bestelclientes.com.mx. [189.204.200.163]) by smtp.gmail.com with ESMTPSA id s5sm8500553qkg.88.2021.05.16.05.34.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 May 2021 05:34:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 01/46] qemu/host-utils: Use __builtin_bitreverseN Date: Sun, 16 May 2021 07:33:46 -0500 Message-Id: <20210516123431.718318-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210516123431.718318-1-richard.henderson@linaro.org> References: <20210516123431.718318-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82a; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82a.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , David Hildenbrand Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Clang has added some builtins for these operations; use them if available. Reviewed-by: Alex Bennée Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- include/qemu/host-utils.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.25.1 diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h index cdca2991d8..f1e52851e0 100644 --- a/include/qemu/host-utils.h +++ b/include/qemu/host-utils.h @@ -272,6 +272,9 @@ static inline int ctpop64(uint64_t val) */ static inline uint8_t revbit8(uint8_t x) { +#if __has_builtin(__builtin_bitreverse8) + return __builtin_bitreverse8(x); +#else /* Assign the correct nibble position. */ x = ((x & 0xf0) >> 4) | ((x & 0x0f) << 4); @@ -281,6 +284,7 @@ static inline uint8_t revbit8(uint8_t x) | ((x & 0x22) << 1) | ((x & 0x11) << 3); return x; +#endif } /** @@ -289,6 +293,9 @@ static inline uint8_t revbit8(uint8_t x) */ static inline uint16_t revbit16(uint16_t x) { +#if __has_builtin(__builtin_bitreverse16) + return __builtin_bitreverse16(x); +#else /* Assign the correct byte position. */ x = bswap16(x); /* Assign the correct nibble position. */ @@ -300,6 +307,7 @@ static inline uint16_t revbit16(uint16_t x) | ((x & 0x2222) << 1) | ((x & 0x1111) << 3); return x; +#endif } /** @@ -308,6 +316,9 @@ static inline uint16_t revbit16(uint16_t x) */ static inline uint32_t revbit32(uint32_t x) { +#if __has_builtin(__builtin_bitreverse32) + return __builtin_bitreverse32(x); +#else /* Assign the correct byte position. */ x = bswap32(x); /* Assign the correct nibble position. */ @@ -319,6 +330,7 @@ static inline uint32_t revbit32(uint32_t x) | ((x & 0x22222222u) << 1) | ((x & 0x11111111u) << 3); return x; +#endif } /** @@ -327,6 +339,9 @@ static inline uint32_t revbit32(uint32_t x) */ static inline uint64_t revbit64(uint64_t x) { +#if __has_builtin(__builtin_bitreverse64) + return __builtin_bitreverse64(x); +#else /* Assign the correct byte position. */ x = bswap64(x); /* Assign the correct nibble position. */ @@ -338,6 +353,7 @@ static inline uint64_t revbit64(uint64_t x) | ((x & 0x2222222222222222ull) << 1) | ((x & 0x1111111111111111ull) << 3); return x; +#endif } /* Host type specific sizes of these routines. */