/* Copyright (c) 2018 ZAO "MCST". All rights reserved. */

#ifndef __POPCNT__
# error "POPCNT instruction set not enabled"
#endif /* __POPCNT__ */

#ifndef _POPCNTINTRIN_H_INCLUDED
#define _POPCNTINTRIN_H_INCLUDED

#include <e2kintrin.h> /* for __E2K_INLINE */

/* Define the default attributes for the functions in this file */
#define __DEFAULT_FUNCS_ATTRS __attribute__((/*__gnu_inline__,*/ __always_inline__, __artificial__))

/* Calculate a number of bits set to 1.  */
__E2K_INLINE int __DEFAULT_FUNCS_ATTRS
_mm_popcnt_u32 (unsigned int __X)
{
  return __builtin_popcount (__X);
}

__E2K_INLINE long long __DEFAULT_FUNCS_ATTRS
_mm_popcnt_u64 (unsigned long long __X)
{
  return __builtin_popcountll (__X);
}

#undef __DEFAULT_FUNCS_ATTRS

#endif /* _POPCNTINTRIN_H_INCLUDED */
