summaryrefslogtreecommitdiff
path: root/stdlib/longlong.h
diff options
context:
space:
mode:
authorYufeng Zhang <yufeng.zhang@arm.com>2014-04-22 17:26:59 +0100
committerMarcus Shawcroft <marcus.shawcroft@arm.com>2014-04-22 17:26:59 +0100
commitea6c92f3be6d59736ee6183a61c538e5d1cc46f8 (patch)
tree0ad25404aa0f39cdbdd7ca401cb0e472f0195893 /stdlib/longlong.h
parent766c4a363d5487dde04bb5e968c3db8b383ec3c2 (diff)
downloadglibc-ea6c92f3be6d59736ee6183a61c538e5d1cc46f8.tar.gz
[AArch64] Use GCC builtins to count leading/tailing zeros.
Diffstat (limited to 'stdlib/longlong.h')
-rw-r--r--stdlib/longlong.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/stdlib/longlong.h b/stdlib/longlong.h
index 10d76cf65e..d45dbe2b73 100644
--- a/stdlib/longlong.h
+++ b/stdlib/longlong.h
@@ -122,6 +122,22 @@ extern const UQItype __clz_tab[256] attribute_hidden;
#define __AND_CLOBBER_CC , "cc"
#endif /* __GNUC__ < 2 */
+#if defined (__aarch64__)
+
+#if W_TYPE_SIZE == 32
+#define count_leading_zeros(COUNT, X) ((COUNT) = __builtin_clz (X))
+#define count_trailing_zeros(COUNT, X) ((COUNT) = __builtin_ctz (X))
+#define COUNT_LEADING_ZEROS_0 32
+#endif /* W_TYPE_SIZE == 32 */
+
+#if W_TYPE_SIZE == 64
+#define count_leading_zeros(COUNT, X) ((COUNT) = __builtin_clzll (X))
+#define count_trailing_zeros(COUNT, X) ((COUNT) = __builtin_ctzll (X))
+#define COUNT_LEADING_ZEROS_0 64
+#endif /* W_TYPE_SIZE == 64 */
+
+#endif /* __aarch64__ */
+
#if defined (__alpha) && W_TYPE_SIZE == 64
#define umul_ppmm(ph, pl, m0, m1) \
do { \