popcntintrin.h revision 234353
174462Salfred/*===---- popcntintrin.h - POPCNT intrinsics -------------------------------===
274462Salfred *
374462Salfred * Permission is hereby granted, free of charge, to any person obtaining a copy
474462Salfred * of this software and associated documentation files (the "Software"), to deal
574462Salfred * in the Software without restriction, including without limitation the rights
674462Salfred * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
774462Salfred * copies of the Software, and to permit persons to whom the Software is
874462Salfred * furnished to do so, subject to the following conditions:
974462Salfred *
1074462Salfred * The above copyright notice and this permission notice shall be included in
1174462Salfred * all copies or substantial portions of the Software.
1274462Salfred *
1374462Salfred * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1474462Salfred * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1574462Salfred * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1674462Salfred * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1774462Salfred * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1874462Salfred * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1974462Salfred * THE SOFTWARE.
2074462Salfred *
2174462Salfred *===-----------------------------------------------------------------------===
2274462Salfred */
2374462Salfred
2474462Salfred#ifndef __POPCNT__
2574462Salfred#error "POPCNT instruction set not enabled"
2674462Salfred#endif
2774462Salfred
2874462Salfred#ifndef _POPCNTINTRIN_H
2974462Salfred#define _POPCNTINTRIN_H
3074462Salfred
3174462Salfredstatic __inline__ int __attribute__((__always_inline__, __nodebug__))
3274462Salfred_mm_popcnt_u32(unsigned int __A)
3374462Salfred{
3474462Salfred  return __builtin_popcount(__A);
3574462Salfred}
3674462Salfred
3774462Salfred#ifdef __x86_64__
3874462Salfredstatic __inline__ long long __attribute__((__always_inline__, __nodebug__))
3974462Salfred_mm_popcnt_u64(unsigned long long __A)
4074462Salfred{
4174462Salfred  return __builtin_popcountll(__A);
4274462Salfred}
4374462Salfred#endif /* __x86_64__ */
4474462Salfred
4574462Salfred#endif /* _POPCNTINTRIN_H */
4674462Salfred