support.h revision 1.1.1.1
1// -*- C++ -*- 2//===-----------------------------------------------------------------------===// 3// 4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5// See https://llvm.org/LICENSE.txt for license information. 6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef _LIBCPP_SUPPORT_IBM_SUPPORT_H 11#define _LIBCPP_SUPPORT_IBM_SUPPORT_H 12 13extern "builtin" int __popcnt4(unsigned int); 14extern "builtin" int __popcnt8(unsigned long long); 15extern "builtin" unsigned int __cnttz4(unsigned int); 16extern "builtin" unsigned int __cnttz8(unsigned long long); 17extern "builtin" unsigned int __cntlz4(unsigned int); 18extern "builtin" unsigned int __cntlz8(unsigned long long); 19 20// Builtin functions for counting population 21#define __builtin_popcount(x) __popcnt4(x) 22#define __builtin_popcountll(x) __popcnt8(x) 23#if defined(__64BIT__) 24#define __builtin_popcountl(x) __builtin_popcountll(x) 25#else 26#define __builtin_popcountl(x) __builtin_popcount(x) 27#endif 28 29// Builtin functions for counting trailing zeros 30#define __builtin_ctz(x) __cnttz4(x) 31#define __builtin_ctzll(x) __cnttz8(x) 32#if defined(__64BIT__) 33#define __builtin_ctzl(x) __builtin_ctzll(x) 34#else 35#define __builtin_ctzl(x) __builtin_ctz(x) 36#endif 37 38// Builtin functions for counting leading zeros 39#define __builtin_clz(x) __cntlz4(x) 40#define __builtin_clzll(x) __cntlz8(x) 41#if defined(__64BIT__) 42#define __builtin_clzl(x) __builtin_clzll(x) 43#else 44#define __builtin_clzl(x) __builtin_clz(x) 45#endif 46 47#if defined(__64BIT__) 48#define __SIZE_WIDTH__ 64 49#else 50#define __SIZE_WIDTH__ 32 51#endif 52 53#endif // _LIBCPP_SUPPORT_IBM_SUPPORT_H 54