Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
ef78f8d7
Commit
ef78f8d7
authored
Dec 01, 2016
by
Matthieu Schaller
Browse files
Added two more intrinsics for long long types.
parent
903385a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/intrinsics.h
View file @
ef78f8d7
...
...
@@ -66,6 +66,23 @@ __attribute__((always_inline)) INLINE static int intrinsics_clz(
#endif
}
/**
* @brief Returns the number of leading 0-bits in x, starting at the most
* significant bit position. If x is 0, the result is undefined.
*
* This is a wrapper for the GNU intrinsic with an implementation.
*/
__attribute__
((
always_inline
))
INLINE
static
int
intrinsics_clzll
(
unsigned
long
long
x
)
{
#ifdef __GNUC__
/* Use GCC intrinsics if possible */
return
__builtin_clzll
(
x
);
#else
#error "Missing definition of clz for long long on this platform."
#endif
}
/**
* @brief Returns the number of 1-bits in x.
*
...
...
@@ -88,4 +105,21 @@ __attribute__((always_inline)) INLINE static int intrinsics_popcount(
#endif
}
/**
* @brief Returns the number of 1-bits in x.
*
* This is a wrapper for the GNU intrinsic with an implementation (from
* Hacker's Delight) if the compiler intrinsics are not available.
*/
__attribute__
((
always_inline
))
INLINE
static
int
intrinsics_popcountll
(
unsigned
long
long
x
)
{
#ifdef __GNUC__
/* Use GCC intrinsics if possible */
return
__builtin_popcountll
(
x
);
#else
#error "Missing definition of popcount for long long on this platform."
#endif
}
#endif
/* SWIFT_INTRINSICS_H */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment