1234287Sdim/*===---- popcntintrin.h - POPCNT intrinsics -------------------------------=== 2234287Sdim * 3234287Sdim * Permission is hereby granted, free of charge, to any person obtaining a copy 4234287Sdim * of this software and associated documentation files (the "Software"), to deal 5234287Sdim * in the Software without restriction, including without limitation the rights 6234287Sdim * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7234287Sdim * copies of the Software, and to permit persons to whom the Software is 8234287Sdim * furnished to do so, subject to the following conditions: 9234287Sdim * 10234287Sdim * The above copyright notice and this permission notice shall be included in 11234287Sdim * all copies or substantial portions of the Software. 12234287Sdim * 13234287Sdim * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14234287Sdim * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15234287Sdim * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16234287Sdim * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17234287Sdim * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18234287Sdim * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19234287Sdim * THE SOFTWARE. 20234287Sdim * 21234287Sdim *===-----------------------------------------------------------------------=== 22234287Sdim */ 23234287Sdim 24234287Sdim#ifndef _POPCNTINTRIN_H 25234287Sdim#define _POPCNTINTRIN_H 26234287Sdim 27288943Sdim/* Define the default attributes for the functions in this file. */ 28296417Sdim#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("popcnt"))) 29288943Sdim 30288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS 31234287Sdim_mm_popcnt_u32(unsigned int __A) 32234287Sdim{ 33234287Sdim return __builtin_popcount(__A); 34234287Sdim} 35234287Sdim 36296417Sdimstatic __inline__ int __DEFAULT_FN_ATTRS 37296417Sdim_popcnt32(int __A) 38296417Sdim{ 39296417Sdim return __builtin_popcount(__A); 40296417Sdim} 41296417Sdim 42234287Sdim#ifdef __x86_64__ 43288943Sdimstatic __inline__ long long __DEFAULT_FN_ATTRS 44234287Sdim_mm_popcnt_u64(unsigned long long __A) 45234287Sdim{ 46234287Sdim return __builtin_popcountll(__A); 47234287Sdim} 48296417Sdim 49296417Sdimstatic __inline__ long long __DEFAULT_FN_ATTRS 50296417Sdim_popcnt64(long long __A) 51296417Sdim{ 52296417Sdim return __builtin_popcountll(__A); 53296417Sdim} 54234287Sdim#endif /* __x86_64__ */ 55234287Sdim 56288943Sdim#undef __DEFAULT_FN_ATTRS 57288943Sdim 58234287Sdim#endif /* _POPCNTINTRIN_H */ 59