[Gmp-commit] /var/hg/gmp: 4 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Sun Nov 29 22:45:48 UTC 2020


details:   /var/hg/gmp/rev/0d19622b27a9
changeset: 18165:0d19622b27a9
user:      Torbjorn Granlund <tg at gmplib.org>
date:      Sun Nov 29 23:39:12 2020 +0100
description:
Recognise CPU "applem1".

details:   /var/hg/gmp/rev/7f4dd5915721
changeset: 18166:7f4dd5915721
user:      Torbjorn Granlund <tg at gmplib.org>
date:      Sun Nov 29 23:41:34 2020 +0100
description:
New file.

details:   /var/hg/gmp/rev/fc3d6bcb38e9
changeset: 18167:fc3d6bcb38e9
user:      Torbjorn Granlund <tg at gmplib.org>
date:      Sun Nov 29 23:45:15 2020 +0100
description:
New file.

details:   /var/hg/gmp/rev/607b394997d1
changeset: 18168:607b394997d1
user:      Torbjorn Granlund <tg at gmplib.org>
date:      Sun Nov 29 23:45:44 2020 +0100
description:
ChangeLog

diffstat:

 ChangeLog                       |    9 +
 config.guess                    |    9 +
 config.sub                      |    2 +-
 configure.ac                    |   12 +-
 mpn/arm64/applem1/aorsmul_1.asm |  153 ++++++++++++++++++++++++++
 mpn/arm64/divrem_1.asm          |  231 ++++++++++++++++++++++++++++++++++++++++
 6 files changed, 413 insertions(+), 3 deletions(-)

diffs (truncated from 475 to 300 lines):

diff -r 5f32dbc41afc -r 607b394997d1 ChangeLog
--- a/ChangeLog	Sun Nov 29 22:31:40 2020 +0100
+++ b/ChangeLog	Sun Nov 29 23:45:44 2020 +0100
@@ -1,3 +1,12 @@
+2020-11-29  Torbjörn Granlund  <tg at gmplib.org>
+
+	* mpn/arm64/divrem_1.asm: New file.
+	* mpn/arm64/applem1/aorsmul_1.asm: New file.
+
+	* configure.ac, config.guess, config.sub: Recognise CPU "applem1".
+
+	* mpn/arm64: Avoid the x18 register since it is reserved on Darwin.
+
 2020-11-28 Marco Bodrato <bodrato at mail.dm.unipi.it>
 
 	* tests/mpz/t-pprime_p.c (check_fermat_mersenne): Check return
diff -r 5f32dbc41afc -r 607b394997d1 config.guess
--- a/config.guess	Sun Nov 29 22:31:40 2020 +0100
+++ b/config.guess	Sun Nov 29 23:45:44 2020 +0100
@@ -173,6 +173,15 @@
   ;;
 
 arm*-*-* | aarch64-*-*)
+  if [ $((uname -s) 2>/dev/null) = Darwin ]; then
+      case $(system_profiler SPHardwareDataType | grep Chip) in
+	  *Apple\ M1)
+	    exact_cpu="applem1";;
+	  *Apple\ M2)
+	    exact_cpu="applem2";;
+      esac
+  fi
+
   cpu_code=`sed -n 's/^CPU part.*\(0x.*\)$/\1/p' /proc/cpuinfo 2>/dev/null | sort -r | head -n 1 2>/dev/null`
   cpu_implementer=`sed -n 's/^CPU implementer.*\(0x.*\)$/\1/p' /proc/cpuinfo 2>/dev/null | head -n 1 2>/dev/null`
   case "${cpu_implementer}_${cpu_code}" in
diff -r 5f32dbc41afc -r 607b394997d1 config.sub
--- a/config.sub	Sun Nov 29 22:31:40 2020 +0100
+++ b/config.sub	Sun Nov 29 23:45:44 2020 +0100
@@ -130,7 +130,7 @@
 armsa1 | armxscale | arm9tdmi | arm9te |				\
 arm10* | arm11mpcore | armsa1 | arm1136 | arm1156 | arm1176 |		\
 armcortex[arm][0-9] | armcortex[arm][0-9][0-9] |			\
-arm*neon | armxgene1 | armexynosm1 | armthunderx)
+arm*neon | armxgene1 | armexynosm1 | armthunderx | applem[1-9])
   test_cpu="arm";;
 
 *)
diff -r 5f32dbc41afc -r 607b394997d1 configure.ac
--- a/configure.ac	Sun Nov 29 22:31:40 2020 +0100
+++ b/configure.ac	Sun Nov 29 23:45:44 2020 +0100
@@ -612,7 +612,7 @@
     ;;
 
 
-  arm*-*-* | aarch64*-*-*)
+  arm*-*-* | aarch64*-*-* | [applem[1-9]-*-*])
     abilist="32"
     gcc_cflags="$gcc_cflags $fomit_frame_pointer"
     gcc_cflags_optlist="arch fpmode neon tune"
@@ -778,6 +778,14 @@
 	gcc_cflags_neon="-mfpu=neon"
 	gcc_cflags_tune=""
 	;;
+      [applem[1-9]*])
+	abilist="64"
+	path_64="arm64/applem1 arm64"
+	gcc_cflags_arch="-march=armv8-a"
+	gcc_cflags_neon="-mfpu=neon"
+	gcc_cflags_tune=""
+	CALLING_CONVENTIONS_OBJS=""
+	;;
       *)
 	path="arm"
 	gcc_cflags_arch="-march=armv4"
@@ -3696,7 +3704,7 @@
   GMP_ASM_ALIGN_LOG
 
   case $host in
-    arm*-*-* | aarch64*-*-*)
+    arm*-*-* | aarch64*-*-* | [applem[1-9]-*-*])
       case $ABI in
         32)
 	  GMP_INCLUDE_MPN(arm/arm-defs.m4) ;;
diff -r 5f32dbc41afc -r 607b394997d1 mpn/arm64/applem1/aorsmul_1.asm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpn/arm64/applem1/aorsmul_1.asm	Sun Nov 29 23:45:44 2020 +0100
@@ -0,0 +1,153 @@
+dnl  ARM64 mpn_addmmul_1 and mpn_submul_1.
+
+dnl  Contributed to the GNU project by Torbjörn Granlund.
+
+dnl  Copyright 2020 Free Software Foundation, Inc.
+
+dnl  This file is part of the GNU MP Library.
+dnl
+dnl  The GNU MP Library is free software; you can redistribute it and/or modify
+dnl  it under the terms of either:
+dnl
+dnl    * the GNU Lesser General Public License as published by the Free
+dnl      Software Foundation; either version 3 of the License, or (at your
+dnl      option) any later version.
+dnl
+dnl  or
+dnl
+dnl    * the GNU General Public License as published by the Free Software
+dnl      Foundation; either version 2 of the License, or (at your option) any
+dnl      later version.
+dnl
+dnl  or both in parallel, as here.
+dnl
+dnl  The GNU MP Library is distributed in the hope that it will be useful, but
+dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+dnl  for more details.
+dnl
+dnl  You should have received copies of the GNU General Public License and the
+dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
+dnl  see https://www.gnu.org/licenses/.
+
+include(`../config.m4')
+
+C	     cycles/limb
+C Cortex-A53
+C Cortex-A55
+C Cortex-A57
+C Cortex-A72
+C Cortex-A73
+C X-Gene
+C Apple M1	 1.25
+
+changecom(blah)
+
+define(`rp', x0)
+define(`up', x1)
+define(`n',  x2)
+define(`v0', x3)
+
+define(`CY',x17)
+
+ifdef(`OPERATION_addmul_1', `
+  define(`ADDSUB',	adds)
+  define(`ADDSUBC',	adcs)
+  define(`COND',	`cc')
+  define(`func',	mpn_addmul_1)')
+ifdef(`OPERATION_submul_1', `
+  define(`ADDSUB',	subs)
+  define(`ADDSUBC',	sbcs)
+  define(`COND',	`cs')
+  define(`func',	mpn_submul_1)')
+
+MULFUNC_PROLOGUE(mpn_addmul_1 mpn_submul_1)
+
+PROLOGUE(func)
+	mov	CY, #0		C W0
+	lsr	x16, n, #2
+	tbz	n, #0, L(bx0)
+
+L(bx1):	ldr	x4, [up], #8
+	mul	x8, x4, v0
+	umulh	x4, x4, v0
+	tbz	n, #1, L(b01)
+
+L(b11):	ldp	x5,x6, [up], #16
+	ldp	x12,x13, [rp]
+	ldr	x14, [rp,#16]
+	mul	x9, x5, v0
+	umulh	x5, x5, v0
+	mul	x10, x6, v0
+	umulh	x6, x6, v0
+	ADDSUB	x8, x12, x8
+	ADDSUBC	x4, x13, x4
+	ADDSUBC	x5, x14, x5
+	csinc	x6, x6, x6, COND
+	ADDSUB	x8, x8, CY
+	ADDSUBC	x4, x4, x9
+	ADDSUBC	x5, x5, x10
+	csinc	CY, x6, x6, COND
+	stp	x8, x4, [rp], #16
+	str	x5, [rp], #8
+	cbnz	x16, L(top)
+	mov	x0, CY
+	ret
+
+L(b01):	ldr	x12, [rp]
+	ADDSUB	x8, x12, x8
+	csinc	x4, x4, x4, COND
+	ADDSUB	x8, x8, CY
+	csinc	CY, x4, x5, COND
+	str	x8, [rp], #8
+	cbnz	x16, L(top)
+	mov	x0, CY
+	ret
+
+L(bx0):	ldp	x4,x5, [up], #16
+	tbz	n, #1, L(top)+4
+
+L(b10):	ldp	x12,x13, [rp]
+	mul	x8, x4, v0
+	umulh	x4, x4, v0
+	mul	x9, x5, v0
+	umulh	x5, x5, v0
+	ADDSUB	x8, x12, x8
+	ADDSUBC	x4, x13, x4
+	csinc	x5, x5, x5, COND
+	ADDSUB	x8, x8, CY
+	ADDSUBC	x4, x4, x9
+	csinc	CY, x5, x5, COND
+	stp	x8, x4, [rp], #16
+	cbz	x16, L(done)
+
+L(top):	ldp	x4,x5, [up], #16	C W0 W1
+	ldp	x6,x7, [up], #16	C W2 W3
+	ldp	x12,x13, [rp]		C W0 W1
+	ldp	x14,x15, [rp,#16]	C W2 W3
+	mul	x8, x4, v0		C W0
+	umulh	x4, x4, v0		C W1
+	mul	x9, x5, v0		C W1
+	umulh	x5, x5, v0		C W2
+	mul	x10, x6, v0		C W2
+	umulh	x6, x6, v0		C W3
+	mul	x11, x7, v0		C W3
+	umulh	x7, x7, v0		C W4
+	ADDSUB	x8, x12, x8		C W0
+	ADDSUBC	x4, x13, x4		C W1
+	ADDSUBC	x5, x14, x5		C W2
+	ADDSUBC	x6, x15, x6		C W3
+	csinc	x7, x7, x7, COND	C W4
+	ADDSUB	x8, x8, CY		C W0	carry-in
+	ADDSUBC	x4, x4, x9		C W1
+	ADDSUBC	x5, x5, x10		C W2
+	ADDSUBC	x6, x6, x11		C W2
+	csinc	CY, x7, x7, COND	C W3	carry-out
+	stp	x8, x4, [rp], #16
+	stp	x5, x6, [rp], #16
+	sub	x16, x16, #1
+	cbnz	x16, L(top)
+
+L(done):mov	x0, CY
+	ret
+EPILOGUE()
diff -r 5f32dbc41afc -r 607b394997d1 mpn/arm64/divrem_1.asm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpn/arm64/divrem_1.asm	Sun Nov 29 23:45:44 2020 +0100
@@ -0,0 +1,231 @@
+dnl  ARM64 mpn_divrem_1 and mpn_preinv_divrem_1.
+
+dnl  Contributed to the GNU project by Torbjörn Granlund.
+
+dnl  Copyright 2020 Free Software Foundation, Inc.
+
+dnl  This file is part of the GNU MP Library.
+dnl
+dnl  The GNU MP Library is free software; you can redistribute it and/or modify
+dnl  it under the terms of either:
+dnl
+dnl    * the GNU Lesser General Public License as published by the Free
+dnl      Software Foundation; either version 3 of the License, or (at your
+dnl      option) any later version.
+dnl
+dnl  or
+dnl
+dnl    * the GNU General Public License as published by the Free Software
+dnl      Foundation; either version 2 of the License, or (at your option) any
+dnl      later version.
+dnl
+dnl  or both in parallel, as here.
+dnl
+dnl  The GNU MP Library is distributed in the hope that it will be useful, but
+dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+dnl  for more details.
+dnl
+dnl  You should have received copies of the GNU General Public License and the
+dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
+dnl  see https://www.gnu.org/licenses/.
+
+include(`../config.m4')
+
+dnl TODO
+dnl  * Handle the most significant quotient limb for the unnormalised case
+dml    specially, just like in the C code.  (It is very often 0.)
+
+define(`qp_arg',   x0)
+define(`fn_arg',   x1)
+define(`np_arg',   x2)
+define(`n_arg',    x3)
+define(`d_arg',    x4)
+define(`dinv_arg', x5)
+define(`cnt_arg',  x6)
+
+define(`qp',   x19)
+define(`np',   x20)
+define(`n',    x21)
+define(`d',    x22)
+define(`fn',   x24)
+define(`dinv', x0)
+define(`cnt',  x23)
+define(`tnc',  x8)
+
+dnl mp_limb_t



More information about the gmp-commit mailing list