aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorUros Bizjak <ubizjak@gmail.com>2007-05-18 22:14:31 +0200
committerUros Bizjak <uros@gcc.gnu.org>2007-05-18 22:14:31 +0200
commite7e0aaeca8ab3390677fa3a950504c93d75c2060 (patch)
treecc31f94616ff65d8a33f7b6997c826eb83304d8e /gcc
parentb86448d7eabbebee7b24e07d2bc8d05edcec04ab (diff)
downloadgcc-e7e0aaeca8ab3390677fa3a950504c93d75c2060.zip
gcc-e7e0aaeca8ab3390677fa3a950504c93d75c2060.tar.gz
gcc-e7e0aaeca8ab3390677fa3a950504c93d75c2060.tar.bz2
longlong.h (__x86_64__): Add definitions for add_ssaaaa...
* longlong.h (__x86_64__): Add definitions for add_ssaaaa, sub_ddmmss, umul_ppmm, udiv_qrnnd, count_leading_zeros and count_trailing_zeros. (__i386__): Implement count_leading_zeros using __builtin_clz(). Implement count_trailing_zeros usign __builtin_ctz(). From-SVN: r124832
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/longlong.h47
2 files changed, 46 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f24184b..e0c6b5f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2007-05-18 Uros Bizjak <ubizjak@gmail.com>
+
+ * longlong.h (__x86_64__): Add definitions for add_ssaaaa,
+ sub_ddmmss, umul_ppmm, udiv_qrnnd, count_leading_zeros and
+ count_trailing_zeros.
+ (__i386__): Implement count_leading_zeros using __builtin_clz().
+ Implement count_trailing_zeros usign __builtin_ctz().
+
2007-05-18 Richard Sandiford <richard@codesourcery.com>
* config/i386/vxworks.h (ASM_PREFERRED_EH_DATA_FORMAT): Undefine.
diff --git a/gcc/longlong.h b/gcc/longlong.h
index 8b512d2..b96e8bb 100644
--- a/gcc/longlong.h
+++ b/gcc/longlong.h
@@ -341,19 +341,48 @@ UDItype __umulsidi3 (USItype, USItype);
: "0" ((USItype) (n0)), \
"1" ((USItype) (n1)), \
"rm" ((USItype) (dv)))
-#define count_leading_zeros(count, x) \
- do { \
- USItype __cbtmp; \
- __asm__ ("bsrl %1,%0" \
- : "=r" (__cbtmp) : "rm" ((USItype) (x))); \
- (count) = __cbtmp ^ 31; \
- } while (0)
-#define count_trailing_zeros(count, x) \
- __asm__ ("bsfl %1,%0" : "=r" (count) : "rm" ((USItype)(x)))
+#define count_leading_zeros(count, x) ((count) = __builtin_clz (x))
+#define count_trailing_zeros(count, x) ((count) = __builtin_ctz (x))
#define UMUL_TIME 40
#define UDIV_TIME 40
#endif /* 80x86 */
+#if (defined (__x86_64__) || defined (__i386__)) && W_TYPE_SIZE == 64
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("addq %5,%1\n\tadcq %3,%0" \
+ : "=r" ((UDItype) (sh)), \
+ "=&r" ((UDItype) (sl)) \
+ : "%0" ((UDItype) (ah)), \
+ "rme" ((UDItype) (bh)), \
+ "%1" ((UDItype) (al)), \
+ "rme" ((UDItype) (bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("subq %5,%1\n\tsbbq %3,%0" \
+ : "=r" ((UDItype) (sh)), \
+ "=&r" ((UDItype) (sl)) \
+ : "0" ((UDItype) (ah)), \
+ "rme" ((UDItype) (bh)), \
+ "1" ((UDItype) (al)), \
+ "rme" ((UDItype) (bl)))
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("mulq %3" \
+ : "=a" ((UDItype) (w0)), \
+ "=d" ((UDItype) (w1)) \
+ : "%0" ((UDItype) (u)), \
+ "rm" ((UDItype) (v)))
+#define udiv_qrnnd(q, r, n1, n0, dv) \
+ __asm__ ("divq %4" \
+ : "=a" ((UDItype) (q)), \
+ "=d" ((UDItype) (r)) \
+ : "0" ((UDItype) (n0)), \
+ "1" ((UDItype) (n1)), \
+ "rm" ((UDItype) (dv)))
+#define count_leading_zeros(count, x) ((count) = __builtin_clzl (x))
+#define count_trailing_zeros(count, x) ((count) = __builtin_ctzl (x))
+#define UMUL_TIME 40
+#define UDIV_TIME 40
+#endif /* x86_64 */
+
#if defined (__i960__) && W_TYPE_SIZE == 32
#define umul_ppmm(w1, w0, u, v) \
({union {UDItype __ll; \