ROOT-Sim core  3.0.0-rc.2
A General-Purpose Multi-threaded Parallel/Distributed Simulation Library
Macros
intrinsics.h File Reference

Easier access to compiler extensions. More...

#include <assert.h>
Include dependency graph for intrinsics.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define intrinsics_ctz(x)
 Counts the trailing zeros in a base 2 number. More...
 
#define intrinsics_clz(x)
 Counts the leading zeros in a base 2 number. More...
 
#define intrinsics_popcount(x)
 Counts the set bits in a base 2 number. More...
 

Detailed Description

Easier access to compiler extensions.

This header defines some macros which allow to easily rely on some compiler optimizations which can be used to produce more efficient code.

Macro Definition Documentation

◆ intrinsics_clz

#define intrinsics_clz (   x)
Value:
__extension__({ \
assert((x) != 0); \
__builtin_choose_expr(__builtin_types_compatible_p(__typeof__(x), unsigned), __builtin_clz(x), \
__builtin_choose_expr(__builtin_types_compatible_p(__typeof__(x), unsigned long), \
__builtin_clzl(x), \
__builtin_choose_expr(__builtin_types_compatible_p(__typeof__(x), unsigned long long), \
__builtin_clzll(x), (void)0))); \
})

Counts the leading zeros in a base 2 number.

Parameters
xthe number on which to compute this operation
Returns
the count of leading zeros in the base 2 representation of x

The argument x may be of one of the supported types of the underlying compiler built-ins. Selection of the matching built-in is done statically at compile time. If no matching built-in is found a compilation error is thrown.

◆ intrinsics_ctz

#define intrinsics_ctz (   x)
Value:
__extension__({ \
assert((x) != 0); \
__builtin_choose_expr(__builtin_types_compatible_p(__typeof__(x), unsigned), __builtin_ctz(x), \
__builtin_choose_expr(__builtin_types_compatible_p(__typeof__(x), unsigned long), \
__builtin_ctzl(x), \
__builtin_choose_expr(__builtin_types_compatible_p(__typeof__(x), unsigned long long), \
__builtin_ctzll(x), (void)0))); \
})

Counts the trailing zeros in a base 2 number.

Parameters
xthe number on which to compute this operation
Returns
the count of trailing zeros in the base 2 representation of x

The argument x may be of one of the supported types of the underlying compiler built-ins. Selection of the matching built-in is done statically at compile time. If no matching built-in is found a compilation error is thrown.

◆ intrinsics_popcount

#define intrinsics_popcount (   x)
Value:
__extension__({ \
__builtin_choose_expr(__builtin_types_compatible_p(__typeof__(x), unsigned), __builtin_popcount(x), \
__builtin_choose_expr(__builtin_types_compatible_p(__typeof__(x), unsigned long), \
__builtin_popcountl(x), \
__builtin_choose_expr(__builtin_types_compatible_p(__typeof__(x), unsigned long long), \
__builtin_popcountll(x), (void)0))); \
})

Counts the set bits in a base 2 number.

Parameters
xthe number on which to compute this operation
Returns
the count of set bits in the base 2 representation of x

The argument x may be of one of the supported types of the underlying compiler built-ins. Selection of the matching built-in is done statically at compile time. If no matching built-in is found a compilation error is thrown.