summaryrefslogtreecommitdiffstats
path: root/package/gmp/gmp-aarch64-make-add_ssaaaa-and-sub_ddmmss-actually-work.patch
blob: 1b835a569cf59550e0ef638fbafca1b1b6a0a619 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# HG changeset patch
# User Torbjorn Granlund <tege@gmplib.org>
# Date 1357413121 -3600
# Node ID 187b7b1646ee0ace782768bb36117b62c8408bb6
# Parent  87a24013e9ee2cabf74e32282c18584a2c669009
(aarch64): Make add_ssaaaa and sub_ddmmss actually work.

Taken upstream from http://gmplib.org:8000/gmp/rev/187b7b1646ee.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

diff -r 87a24013e9ee -r 187b7b1646ee longlong.h
--- a/longlong.h	Fri Jan 04 16:32:01 2013 +0100
+++ b/longlong.h	Sat Jan 05 20:12:01 2013 +0100
@@ -530,23 +530,16 @@
 #endif /* __arm__ */
 
 #if defined (__aarch64__) && W_TYPE_SIZE == 64
+/* FIXME: Extend the immediate range for the low word by using both
+   ADDS and SUBS, since they set carry in the same way.  */
 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
-  __asm__ ("adds\t%1, %4, %5\n\tadc\t%0, %2, %3"			\
+  __asm__ ("adds\t%1, %x4, %5\n\tadc\t%0, %x2, %x3"			\
 	   : "=r" (sh), "=&r" (sl)					\
-	   : "r" (ah), "rZ" (bh), "%r" (al), "rI" (bl) __CLOBBER_CC)
+	   : "rZ" (ah), "rZ" (bh), "%r" (al), "rI" (bl) __CLOBBER_CC)
 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
-  do {									\
-    if (__builtin_constant_p (bl))					\
-      {									\
-	__asm__ ("subs\t%1, %4, %5\n\tsbc\t%0, %2, %3"			\
-		 : "=r" (sh), "=&r" (sl)				\
-		 : "r" (ah), "r" (bh), "r" (al), "rI" (bl) __CLOBBER_CC); \
-      }									\
-    else /* only bh might be a constant */				\
-      __asm__ ("subs\t%1, %4, %5\n\tsbc\t%0, %2, %3"			\
-	       : "=r" (sh), "=&r" (sl)					\
-	       : "r" (ah), "rZ" (bh), "r" (al), "rI" (bl) __CLOBBER_CC);\
-    } while (0)
+  __asm__ ("subs\t%1, %x4, %5\n\tsbc\t%0, %x2, %x3"			\
+	   : "=r,r" (sh), "=&r,&r" (sl)					\
+	   : "rZ,rZ" (ah), "rZ,rZ" (bh), "r,Z" (al), "rI,r" (bl) __CLOBBER_CC)
 #define umul_ppmm(ph, pl, m0, m1) \
   do {									\
     UDItype __m0 = (m0), __m1 = (m1);					\