This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

popcount support


On 25 Feb 2017 19:53, Jim Wilson wrote:
> +/* Return the number of bits set in the input value.  */
> +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
> +# define popcount __builtin_popcount
> +#else
> +static int
> +popcount (unsigned char x)
> +{
> +  static const unsigned char popcnt[16] =
> +    {
> +      0, 1, 1, 2,
> +      1, 2, 2, 3,
> +      1, 2, 2, 3,
> +      2, 3, 3, 4
> +    };
> +
> +  /* Only counts the low 8 bits of the input as that is all we need.  */
> +  return popcnt[x % 16] + popcnt[x / 16];
> +}
> +#endif

gas/config/tc-ia64.c does the same thing, and bfd/elf32-arm.c.
should we consolidate these in libiberty ?
-mike

Attachment: signature.asc
Description: Digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]