This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] longlong.h support for S/390, take 2
- From: "Ulrich Weigand" <Ulrich dot Weigand at de dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: tege at king dot swox dot de, dje at watson dot ibm dot com
- Date: Mon, 30 Sep 2002 18:48:43 +0200
- Subject: [PATCH] longlong.h support for S/390, take 2
- Sensitivity:
Hello,
here's an updated version of the longlong.h patch, incorporating
suggestions by Torbjorn Granlund.
This version makes the i370/s390 section of longlong.h identical
to the one in GMP-4.1, and also copies the generic implementation
of umul_ppmm in terms of smul_ppmm from the GMP version.
Bootstrapped/regtested on s390-ibm-linux and s390x-ibm-linux.
OK to apply?
[As suggested by David Edelsohn, I'll forward that patch also to
the glibc maintainers to bring that copy of longlong.h in sync as well.]
ChangeLog:
* longlong.h: Partially synchronize with GMP-4.1 version:
Use i370 definitions also for s390.
Add generic definition of umul_ppmm in terms of smul_ppmm.
[s390] (umul_ppmm): Remove.
[s390] (smul_ppmm): Fix incorrect assembler constraints.
[s390] (smul_ppmm, sdiv_qrnnd): Rename __xx to __x.
Index: gcc/longlong.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/longlong.h,v
retrieving revision 1.31
diff -c -p -r1.31 longlong.h
*** gcc/longlong.h 22 Sep 2002 14:09:34 -0000 1.31
--- gcc/longlong.h 30 Sep 2002 12:10:29 -0000
*************** UDItype __umulsidi3 (USItype, USItype);
*** 292,335 ****
} while (0)
#endif
! #if (defined (__i370__) || defined (__mvs__)) && W_TYPE_SIZE == 32
! #define umul_ppmm(xh, xl, m0, m1) \
! do { \
! union {UDItype __ll; \
! struct {USItype __h, __l;} __i; \
! } __xx; \
! USItype __m0 = (m0), __m1 = (m1); \
! __asm__ ("mr %0,%3" \
! : "=r" (__xx.__i.__h), \
! "=r" (__xx.__i.__l) \
! : "%1" (__m0), \
! "r" (__m1)); \
! (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
! (xh) += ((((SItype) __m0 >> 31) & __m1) \
! + (((SItype) __m1 >> 31) & __m0)); \
! } while (0)
#define smul_ppmm(xh, xl, m0, m1) \
do { \
union {DItype __ll; \
struct {USItype __h, __l;} __i; \
! } __xx; \
! __asm__ ("mr %0,%3" \
! : "=r" (__xx.__i.__h), \
! "=r" (__xx.__i.__l) \
! : "%1" (m0), \
! "r" (m1)); \
! (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
} while (0)
#define sdiv_qrnnd(q, r, n1, n0, d) \
do { \
union {DItype __ll; \
struct {USItype __h, __l;} __i; \
! } __xx; \
! __xx.__i.__h = n1; __xx.__i.__l = n0; \
__asm__ ("dr %0,%2" \
! : "=r" (__xx.__ll) \
! : "0" (__xx.__ll), "r" (d)); \
! (q) = __xx.__i.__l; (r) = __xx.__i.__h; \
} while (0)
#endif
--- 292,318 ----
} while (0)
#endif
! #if (defined (__i370__) || defined (__s390__) || defined (__mvs__)) && W_TYPE_SIZE == 32
#define smul_ppmm(xh, xl, m0, m1) \
do { \
union {DItype __ll; \
struct {USItype __h, __l;} __i; \
! } __x; \
! __asm__ ("lr %N0,%1\n\tmr %0,%2" \
! : "=&r" (__x.__ll) \
! : "r" (m0), "r" (m1)); \
! (xh) = __x.__i.__h; (xl) = __x.__i.__l; \
} while (0)
#define sdiv_qrnnd(q, r, n1, n0, d) \
do { \
union {DItype __ll; \
struct {USItype __h, __l;} __i; \
! } __x; \
! __x.__i.__h = n1; __x.__i.__l = n0; \
__asm__ ("dr %0,%2" \
! : "=r" (__x.__ll) \
! : "0" (__x.__ll), "r" (d)); \
! (q) = __x.__i.__l; (r) = __x.__i.__h; \
} while (0)
#endif
*************** UDItype __umulsidi3 (USItype, USItype);
*** 1201,1206 ****
--- 1184,1203 ----
} while (0)
#endif
+ /* If we lack umul_ppmm but have smul_ppmm, define umul_ppmm in terms of
+ smul_ppmm. */
+ #if !defined (umul_ppmm) && defined (smul_ppmm)
+ #define umul_ppmm(w1, w0, u, v) \
+ do { \
+ UWtype __w1; \
+ UWtype __xm0 = (u), __xm1 = (v); \
+ smul_ppmm (__w1, w0, __xm0, __xm1); \
+ (w1) = __w1 + (-(__xm0 >> (W_TYPE_SIZE - 1)) & __xm1) \
+ + (-(__xm1 >> (W_TYPE_SIZE - 1)) & __xm0); \
+ } while (0)
+ #endif
+
+ /* If we still don't have umul_ppmm, define it using plain C. */
#if !defined (umul_ppmm)
#define umul_ppmm(w1, w0, u, v) \
do { \
Mit freundlichen Gruessen / Best Regards
Ulrich Weigand
--
Dr. Ulrich Weigand
Linux for S/390 Design & Development
IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
Phone: +49-7031/16-3727 --- Email: Ulrich.Weigand@de.ibm.com