T clz(T x)
Returns the number of leading 0-bits in
x
,
starting at the most significant bit position. If
x
is 0, returns the size in bits of the type of x or
component type of
x
, if
x
is a vector
T ctz(T x)
Returns the count of trailing 0-bits in
x
. If
x
is 0,
returns the size in bits of the type of x or
component type of
x
, if
x
is a vector.
T extract_bits(T x,
uint offset,
uint bits)
Extract bits [
offset
,
offset+bits-1
] from
x
,
returning them in the least significant bits of the
result.
For unsigned data types, the most significant
bits of the result are set to zero. For signed data
types, the most significant bits are set to the
value of bit
offset+bits-1
.
If
bits
is zero, the result is zero. The result is
undefined if the sum of
offset
and
bits
is
greater than the number of bits used to store
the operand.
T hadd(T x, T y)
Returns
(x + y) >> 1
. The intermediate sum
does not modulo overflow.
T insert_bits(T base,
T insert,
uint offset, uint bits)
Returns the insertion of the
bits
least-
significant bits of
insert
into
base
.
The result will have bits [
offset
,
offset+bits-1
] taken from bits [
0
,
bits-1
] of
insert
, and all other bits taken directly from
the corresponding bits of
base
. If
bits
is zero,
the result is
base
. The result is undefined if the
sum of
offset
and
bits
is greater than the
number of bits used to store the operand.
T madhi(T a, T b, T c)
Returns
mulhi(a, b) + c
.
T madsat(T a, T b, T c)
Returns
a * b + c
and saturates the result.
T max(T x, T y)
Returns
y
if
x < y
, otherwise it returns
x
.
T min(T x, T x)
Returns
y
if
y < x
, otherwise it returns
x
.
T mulhi(T x, T y)
Computes
x * y
and returns the high half of
the product of
x
and
y
.
T popcount(T x)
Returns the number of non-zero bits in
x
.
Built-in integer functions
Description
2017-9-12 | Copyright © 2017 Apple Inc. All Rights Reserved.
Page
of
109
174