summaryrefslogtreecommitdiff
path: root/longlong.h
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2002-03-09 23:43:18 +0100
committerKevin Ryde <user42@zip.com.au>2002-03-09 23:43:18 +0100
commit9262a18b652b66e71b8fd0fb84f77e3c8588e21c (patch)
tree2bab29bf574a076e8f1497a0561d6a042056d826 /longlong.h
parent5b6f493adeef191a68771a3a961529cd3d6e1c0a (diff)
downloadgmp-9262a18b652b66e71b8fd0fb84f77e3c8588e21c.tar.gz
* longlong.h (count_leading_zeros, count_trailing_zeros) [x86_64]: New
macros.
Diffstat (limited to 'longlong.h')
-rw-r--r--longlong.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/longlong.h b/longlong.h
index e03f44f2d..09d6f58d6 100644
--- a/longlong.h
+++ b/longlong.h
@@ -701,6 +701,18 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
__asm__ ("divq %4" /* stringification in K&R C */ \
: "=a" (q), "=d" (r) \
: "0" ((UDItype)(n0)), "1" ((UDItype)(n1)), "rm" ((UDItype)(dx)))
+#define count_leading_zeros(count, x) \
+ do { \
+ USItype __cbtmp; \
+ ASSERT ((x) != 0); \
+ __asm__ ("bsrq %1,%0" : "=r" (__cbtmp) : "rm" ((USItype)(x))); \
+ (count) = __cbtmp ^ 63; \
+ } while (0)
+#define count_trailing_zeros(count, x) \
+ do { \
+ ASSERT ((x) != 0); \
+ __asm__ ("bsfq %1,%0" : "=r" (count) : "rm" ((USItype)(x))); \
+ } while (0)
#endif /* x86_64 */
#if defined (__i860__) && W_TYPE_SIZE == 32