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 __POPCNT__
25234287Sdim#error "POPCNT instruction set not enabled"
26234287Sdim#endif
27234287Sdim
28234287Sdim#ifndef _POPCNTINTRIN_H
29234287Sdim#define _POPCNTINTRIN_H
30234287Sdim
31234287Sdimstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
32234287Sdim_mm_popcnt_u32(unsigned int __A)
33234287Sdim{
34234287Sdim  return __builtin_popcount(__A);
35234287Sdim}
36234287Sdim
37234287Sdim#ifdef __x86_64__
38234287Sdimstatic __inline__ long long __attribute__((__always_inline__, __nodebug__))
39234287Sdim_mm_popcnt_u64(unsigned long long __A)
40234287Sdim{
41234287Sdim  return __builtin_popcountll(__A);
42234287Sdim}
43234287Sdim#endif /* __x86_64__ */
44234287Sdim
45234287Sdim#endif /* _POPCNTINTRIN_H */
46