From patchwork Sat May 8 01:46:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 432516 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp840412jao; Fri, 7 May 2021 18:49:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1iWUrW3Lyqw3QrZgE1TVKw84jruOeq6lPynUIOiukxkuJeS0GAaF0k6A6PH8w3T6PHZOH X-Received: by 2002:a05:6602:8d0:: with SMTP id h16mr10059892ioz.145.1620438562646; Fri, 07 May 2021 18:49:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620438562; cv=none; d=google.com; s=arc-20160816; b=ZYUI4DE19/IYGayqRQ9zaB7Ix+Ml7GCsPUdBDPHQ9Phys6NyH25SCKLrwo++4AoCun WlTnbRLIF7K/CpV8vXK0nlYkMr5Cla7B2x9oGKaFigSS4uwxDWH20d1dj2OIinNuW8y0 TI+UPvBMM83rkePLTjx1hKGnjnzwDHOKjCk6UJDpBep2NjqGa/J4jOVC0USmR3UGyj8I wnWThMB1AK+D2X+LSQjewsZenW2uQsTkfQTNr7qHT0LdiGFGnUxlC9R8S31APgdxURXa f7t1BRIPisci6cKiuTUcmCL5UqF5XpIA6VsGYh3DWutJeGnR0yKJ/pA5GDtpr80jFd9n 7Gkg== 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=kll+dPeHhZ1ZNnNxSh3IWKjU47wCoWRq1+9XapRC/iw=; b=S1/XvRnV+oqaSW4waC6NptzbllK3AIxn3gMQfJ6PZSwFZishUuRIODd4nGBvANGRE5 OxSw+lQkIBx+hxp/n/BBP8mrWhAjzVo3P7V5x9pPqV9xl1EF+bP04BChmtUdnRcXWJsk h8Zzd+CckuVOGW9hwQ8KdP0/i2v4vJIqI0sFF00PummkKBqfBzqdvvPYaXtv2BgWQCV7 03A82roNPH4BSb7R4YT2iyPMSyiW7mb2zer/h0y3YTpOKzApua9RfSht6inmlPN8ipzv u+UDxnkuh5zesfPIa6os+O521Zs3Fcq6oAqRQNrrFI+J9Mhl0f8E+ymaIwf0y8scCqmn SQXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=rqZvmS7Y; 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=fail (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 a8si9258707ilj.99.2021.05.07.18.49.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 May 2021 18:49:22 -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=fail header.i=@linaro.org header.s=google header.b=rqZvmS7Y; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lfC5q-0003vZ-3K for patch@linaro.org; Fri, 07 May 2021 21:49:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40412) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lfC4d-0003ux-R1 for qemu-devel@nongnu.org; Fri, 07 May 2021 21:48:07 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:34419) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lfC4c-0003Ud-6O for qemu-devel@nongnu.org; Fri, 07 May 2021 21:48:07 -0400 Received: by mail-pl1-x62b.google.com with SMTP id h7so6156348plt.1 for ; Fri, 07 May 2021 18:48:05 -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=kll+dPeHhZ1ZNnNxSh3IWKjU47wCoWRq1+9XapRC/iw=; b=rqZvmS7YVE3xScwFbcjkv3pcDwAe2i+MSe3ozkVfLmG9xp81Oyg8zH4qDKqWF7E5SV FN0AEwSH6PgoYIk33tD4ukSZ06JUa+U1wwy+brWDSepKcOGPhsuBE5olrcyqWGv27puU LuM6re/SO7cA8p4ydAPayUbARSISXwlf4LE16EXPtkFSUh5ljKT913f9mChWjS1M+9rj PRyGbUPP7UO5Rl7rgnzfufoUvRn0waPwCaAUp7ykr+8zB+ofKpE9p61kJBgL5OoroLi4 OyXrnCEqbXEZJ1kLm6OjEcrgiiuG9WZ+pMp39hKxSA1bZImEfCqkjcv5KgpXxjgbnmU1 ijWA== 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=kll+dPeHhZ1ZNnNxSh3IWKjU47wCoWRq1+9XapRC/iw=; b=FsalIuW6ZiaElYby/W2/vEqhNF+U1L5Pl3MZYm7LxoZ65J6vaGjnc01EXb9KzQqTlz T3QWF5ddHpzBoJL73CU9egw2O1Y05ryX4vdq5CknZ1IlrMcrGpNktVeGkcN4U8cVQmkg xHuUz3kCEZsy4nn1ABYujibT/ch3lUWFDuqq8X9wQnIWo1p9+kY6esSkdhEu+SxugKNF SC6vrhRweLhHfSkP+uXovINOBI4KKBT5mdOeOZNzV/0cnG+UIiIGtjOszYngj9ErRwcn Hwl4p/VN55pOFkkKkQ7j5whWN+7SwpV9JAe1WucoD6GovK2XLr7i1VW57JEaSRZmy4Ss Bk5g== X-Gm-Message-State: AOAM531k+C8KHrRfXMGTXCaGtzjpl4z9rOQoC9sgERrmz1XCzShUHzvu yKnQuGtByv+WdmyMfhKWSXUZ1KDpqzLFaw== X-Received: by 2002:a17:90b:915:: with SMTP id bo21mr13130414pjb.27.1620438484793; Fri, 07 May 2021 18:48:04 -0700 (PDT) Received: from localhost.localdomain ([71.212.144.24]) by smtp.gmail.com with ESMTPSA id t4sm5819681pfq.165.2021.05.07.18.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 18:48:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 01/72] qemu/host-utils: Use __builtin_bitreverseN Date: Fri, 7 May 2021 18:46:51 -0700 Message-Id: <20210508014802.892561-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210508014802.892561-1-richard.henderson@linaro.org> References: <20210508014802.892561-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, david@redhat.com 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. Signed-off-by: Richard Henderson --- include/qemu/host-utils.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.25.1 Reviewed-by: Alex Bennée Reviewed-by: David Hildenbrand 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. */