[Gmp-commit] /var/hg/gmp: New LEA64 macro for sparc64.

mercurial at gmplib.org mercurial at gmplib.org
Tue Apr 16 20:11:02 CEST 2013


details:   /var/hg/gmp/rev/4134409a5b31
changeset: 15724:4134409a5b31
user:      David S. Miller
date:      Tue Apr 16 20:10:59 2013 +0200
description:
New LEA64 macro for sparc64.

diffstat:

 mpn/sparc32/sparc-defs.m4                |  19 +++++++++++++++++++
 mpn/sparc64/gcd_1.asm                    |  22 ++++------------------
 mpn/sparc64/ultrasparct3/dive_1.asm      |  17 +----------------
 mpn/sparc64/ultrasparct3/invert_limb.asm |  25 ++++---------------------
 mpn/sparc64/ultrasparct3/mode1o.asm      |  17 +----------------
 5 files changed, 29 insertions(+), 71 deletions(-)

diffs (161 lines):

diff -r 5ea92466ab67 -r 4134409a5b31 mpn/sparc32/sparc-defs.m4
--- a/mpn/sparc32/sparc-defs.m4	Mon Apr 15 23:00:14 2013 +0200
+++ b/mpn/sparc32/sparc-defs.m4	Tue Apr 16 20:10:59 2013 +0200
@@ -46,4 +46,23 @@
   define(`lzcnt',	``lzd'	$1, $2')
 ')
 
+dnl  Usage: LEA64(symbol,reg,pic_reg)
+dnl
+dnl  Use whatever 64-bit code sequence is appropriate to load "symbol" into
+dnl  register "reg", potentially using register "pic_reg" to perform the
+dnl  calculations.
+
+define(LEA64,
+m4_assert_numargs(3)
+m4_assert_defined(`HAVE_GOTDATA')
+`ifdef(`PIC',`
+	rd	%pc, %`$2'
+	sethi	%hi(_GLOBAL_OFFSET_TABLE_+4), %`$3'
+	add	%`$3', %lo(_GLOBAL_OFFSET_TABLE_+8), %`$3'
+	add	%`$2', %`$3', %`$3'
+	sethi	%hi(`$1'), %`$2'
+	or	%`$2', %lo(`$1'), %`$2'
+	ldx	[%`$3' + %`$2'], %`$2'',`
+	setx	`$1', %`$3', %`$2'')')
+
 divert
diff -r 5ea92466ab67 -r 4134409a5b31 mpn/sparc64/gcd_1.asm
--- a/mpn/sparc64/gcd_1.asm	Mon Apr 15 23:00:14 2013 +0200
+++ b/mpn/sparc64/gcd_1.asm	Tue Apr 16 20:10:59 2013 +0200
@@ -37,13 +37,14 @@
 deflit(MAXSHIFT, 7)
 deflit(MASK, eval((m4_lshift(1,MAXSHIFT))-1))
 
-	.section	".rodata"
+	RODATA
+	TYPE(ctz_table,object)
 ctz_table:
 	.byte	MAXSHIFT
 forloop(i,1,MASK,
 `	.byte	m4_count_trailing_zeros(i)
 ')
-
+	SIZE(ctz_table,.-ctz_table)
 
 C Threshold of when to call bmod when U is one limb.  Should be about
 C (time_in_cycles(bmod_1,1) + call_overhead) / (cycles/bit).
@@ -94,22 +95,7 @@
 
 L(noreduce):
 
-ifdef(`PIC',`
-	rd	%pc, %g3
-	sethi	%hi(_GLOBAL_OFFSET_TABLE_+4), %g4
-	add	%g4, %lo(_GLOBAL_OFFSET_TABLE_+8), %g4
-	add	%g3, %g4, %g4
-	sethi	%hi(ctz_table), %g1
-	or	%g1, %lo(ctz_table), %g1
-	ldx	[%g4+%g1], %i5
-',`
-	sethi	%hh(ctz_table), %l7
-	or	%l7, %hm(ctz_table), %l7
-	sllx	%l7, 32, %l7
-	sethi	%lm(ctz_table), %g1
-	add	%l7, %g1, %l7
-	or	%l7, %lo(ctz_table), %i5
-')
+	LEA64(ctz_table, i5, g4)
 
 	cmp	%o0, 0
 	bnz	%xcc, L(mid)
diff -r 5ea92466ab67 -r 4134409a5b31 mpn/sparc64/ultrasparct3/dive_1.asm
--- a/mpn/sparc64/ultrasparct3/dive_1.asm	Mon Apr 15 23:00:14 2013 +0200
+++ b/mpn/sparc64/ultrasparct3/dive_1.asm	Tue Apr 16 20:10:59 2013 +0200
@@ -54,22 +54,7 @@
 	srlx	d, 1, %g1
 	and	%g1, 127, %g1
 
-ifdef(`PIC',`
-	rd	%pc, %g3
-	sethi	%hi(_GLOBAL_OFFSET_TABLE_+4), %g4
-	add	%g4, %lo(_GLOBAL_OFFSET_TABLE_+8), %g4
-	add	%g3, %g4, %g4
-	sethi	%hi(binvert_limb_table), %g2
-	or	%g2, %lo(binvert_limb_table), %g2
-	ldx	[%g4+%g2], %g2
-',`
-	sethi	%hh(binvert_limb_table), %g3
-	or	%g3, %hm(binvert_limb_table), %g3
-	sllx	%g3, 32, %g3
-	sethi	%lm(binvert_limb_table), %g2
-	add	%g3, %g2, %g3
-	or	%g3, %lo(binvert_limb_table), %g2
-')
+	LEA64(binvert_limb_table, g2, g4)
 	ldub	[%g2+%g1], %g1
 	add	%g1, %g1, %g2
 	mulx	%g1, %g1, %g1
diff -r 5ea92466ab67 -r 4134409a5b31 mpn/sparc64/ultrasparct3/invert_limb.asm
--- a/mpn/sparc64/ultrasparct3/invert_limb.asm	Mon Apr 15 23:00:14 2013 +0200
+++ b/mpn/sparc64/ultrasparct3/invert_limb.asm	Tue Apr 16 20:10:59 2013 +0200
@@ -32,28 +32,11 @@
 	REGISTER(%g2,#scratch)
 	REGISTER(%g3,#scratch)
 PROLOGUE(mpn_invert_limb)
-	srlx	d, 55, %g1
-	add	%g1, %g1, %g1
-
-ifdef(`PIC',`
-	rd	%pc, %g3
-	sethi	%hi(_GLOBAL_OFFSET_TABLE_+4), %g4
-	add	%g4, %lo(_GLOBAL_OFFSET_TABLE_+8), %g4
-	add	%g3, %g4, %g4
-	sethi	%hi(approx_tab), %g2
-	or	%g2, %lo(approx_tab), %g2
-	ldx	[%g4+%g2], %g2
-	add	%g1, -512, %g1
-',`
-	sethi	%hh(approx_tab-512), %g3
-	or	%g3, %hm(approx_tab-512), %g3
-	sllx	%g3, 32, %g3
-	sethi	%lm(approx_tab-512), %g2
-	add	%g3, %g2, %g3
-	or	%g3, %lo(approx_tab-512), %g2
-')
+	srlx	d, 54, %g1
+	LEA64(approx_tab, g2, g3)
+	and	%g1, 0x1fe, %g1
+	srlx	d, 24, %g4
 	lduh	[%g2+%g1], %g3
-	srlx	d, 24, %g4
 	add	%g4, 1, %g4
 	sllx	%g3, 11, %g2
 	add	%g2, -1, %g2
diff -r 5ea92466ab67 -r 4134409a5b31 mpn/sparc64/ultrasparct3/mode1o.asm
--- a/mpn/sparc64/ultrasparct3/mode1o.asm	Mon Apr 15 23:00:14 2013 +0200
+++ b/mpn/sparc64/ultrasparct3/mode1o.asm	Tue Apr 16 20:10:59 2013 +0200
@@ -41,22 +41,7 @@
 	srlx	d, 1, %g1
 	and	%g1, 127, %g1
 
-ifdef(`PIC',`
-	rd	%pc, %g3
-	sethi	%hi(_GLOBAL_OFFSET_TABLE_+4), %g4
-	add	%g4, %lo(_GLOBAL_OFFSET_TABLE_+8), %g4
-	add	%g3, %g4, %g4
-	sethi	%hi(binvert_limb_table), %g2
-	or	%g2, %lo(binvert_limb_table), %g2
-	ldx	[%g4+%g2], %g2
-',`
-	sethi	%hh(binvert_limb_table), %g3
-	or	%g3, %hm(binvert_limb_table), %g3
-	sllx	%g3, 32, %g3
-	sethi	%lm(binvert_limb_table), %g2
-	add	%g3, %g2, %g3
-	or	%g3, %lo(binvert_limb_table), %g2
-')
+	LEA64(binvert_limb_table, g2, g4)
 	ldub	[%g2+%g1], %g1
 	add	%g1, %g1, %g2
 	mulx	%g1, %g1, %g1


More information about the gmp-commit mailing list