Blame mpn/sparc64/ultrasparct3/aorslsh_n.asm

Packit 5c3484
dnl  SPARC v9 mpn_addlsh_n and mpn_sublsh_n for T3/T4/T5.
Packit 5c3484
Packit 5c3484
dnl  Contributed to the GNU project by Torbjörn Granlund.
Packit 5c3484
Packit 5c3484
dnl  Copyright 2013 Free Software Foundation, Inc.
Packit 5c3484
Packit 5c3484
dnl  This file is part of the GNU MP Library.
Packit 5c3484
dnl
Packit 5c3484
dnl  The GNU MP Library is free software; you can redistribute it and/or modify
Packit 5c3484
dnl  it under the terms of either:
Packit 5c3484
dnl
Packit 5c3484
dnl    * the GNU Lesser General Public License as published by the Free
Packit 5c3484
dnl      Software Foundation; either version 3 of the License, or (at your
Packit 5c3484
dnl      option) any later version.
Packit 5c3484
dnl
Packit 5c3484
dnl  or
Packit 5c3484
dnl
Packit 5c3484
dnl    * the GNU General Public License as published by the Free Software
Packit 5c3484
dnl      Foundation; either version 2 of the License, or (at your option) any
Packit 5c3484
dnl      later version.
Packit 5c3484
dnl
Packit 5c3484
dnl  or both in parallel, as here.
Packit 5c3484
dnl
Packit 5c3484
dnl  The GNU MP Library is distributed in the hope that it will be useful, but
Packit 5c3484
dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
Packit 5c3484
dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
Packit 5c3484
dnl  for more details.
Packit 5c3484
dnl
Packit 5c3484
dnl  You should have received copies of the GNU General Public License and the
Packit 5c3484
dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
Packit 5c3484
dnl  see https://www.gnu.org/licenses/.
Packit 5c3484
Packit 5c3484
include(`../config.m4')
Packit 5c3484
Packit 5c3484
C		   cycles/limb
Packit 5c3484
C UltraSPARC T3:	11
Packit 5c3484
C UltraSPARC T4:	 4
Packit 5c3484
Packit 5c3484
C For sublsh_n we combine the two shifted limbs using xnor, using the identity
Packit 5c3484
C (a xor not b) = (not (a xor b)) which equals (not (a or b)) when (a and b) =
Packit 5c3484
C 0 as it is in our usage.  This gives us the ones complement for free.
Packit 5c3484
C Unfortunately, the same trick will not work for rsblsh_n, which will instead
Packit 5c3484
C require a separate negation.
Packit 5c3484
C
Packit 5c3484
C FIXME: Add rsblsh_n to this file.
Packit 5c3484
Packit 5c3484
define(`rp', `%i0')
Packit 5c3484
define(`up', `%i1')
Packit 5c3484
define(`vp', `%i2')
Packit 5c3484
define(`n',  `%i3')
Packit 5c3484
define(`cnt',`%i4')
Packit 5c3484
Packit 5c3484
define(`tnc',`%o5')
Packit 5c3484
Packit 5c3484
ifdef(`OPERATION_addlsh_n',`
Packit 5c3484
  define(`INITCY', `subcc	%g0, 0, %g0')
Packit 5c3484
  define(`MERGE',  `or')
Packit 5c3484
  define(`func',   `mpn_addlsh_n')
Packit 5c3484
')
Packit 5c3484
ifdef(`OPERATION_sublsh_n',`
Packit 5c3484
  define(`INITCY', `subcc	%g0, 1, %g0')
Packit 5c3484
  define(`MERGE',  `xnor')
Packit 5c3484
  define(`func',   `mpn_sublsh_n')
Packit 5c3484
')
Packit 5c3484
Packit 5c3484
define(`rp0',  `rp')
Packit 5c3484
define(`rp1',  `%o2')
Packit 5c3484
define(`up0',  `up')
Packit 5c3484
define(`up1',  `%o3')
Packit 5c3484
define(`vp0',  `vp')
Packit 5c3484
define(`vp1',  `%o4')
Packit 5c3484
Packit 5c3484
MULFUNC_PROLOGUE(mpn_addlsh_n mpn_sublsh_n)
Packit 5c3484
ASM_START()
Packit 5c3484
	REGISTER(%g2,#scratch)
Packit 5c3484
	REGISTER(%g3,#scratch)
Packit 5c3484
PROLOGUE(func)
Packit 5c3484
	save	%sp, -176, %sp
Packit 5c3484
	mov	64, tnc
Packit 5c3484
	sub	tnc, cnt, tnc
Packit 5c3484
Packit 5c3484
	andcc	n, 1, %g0
Packit 5c3484
	sllx	n, 3, n
Packit 5c3484
	add	n, -16, n
Packit 5c3484
	add	up, n, up0
Packit 5c3484
	add	vp, n, vp0
Packit 5c3484
	add	rp, n, rp0
Packit 5c3484
	add	up0, 8, up1
Packit 5c3484
	add	vp0, 8, vp1
Packit 5c3484
	add	rp0, -8, rp1
Packit 5c3484
	add	rp0, -16, rp0
Packit 5c3484
	neg	n, n
Packit 5c3484
	be	L(evn)
Packit 5c3484
	 INITCY
Packit 5c3484
Packit 5c3484
L(odd):	ldx	[vp0 + n], %l1
Packit 5c3484
	mov	0, %l2
Packit 5c3484
	ldx	[up0 + n], %l5
Packit 5c3484
	sllx	%l1, cnt, %g3
Packit 5c3484
	brgez	n, L(wd1)
Packit 5c3484
	 add	n, 8, n
Packit 5c3484
	ldx	[vp0 + n], %l0
Packit 5c3484
	b	L(lo1)
Packit 5c3484
	 sllx	%l1, cnt, %g3
Packit 5c3484
Packit 5c3484
L(evn):	ldx	[vp0 + n], %l0
Packit 5c3484
	mov	0, %l3
Packit 5c3484
	ldx	[up0 + n], %l4
Packit 5c3484
	ldx	[vp1 + n], %l1
Packit 5c3484
	b	L(lo0)
Packit 5c3484
	 sllx	%l0, cnt, %g1
Packit 5c3484
Packit 5c3484
L(top):	addxccc(%l6, %l4, %o0)
Packit 5c3484
	ldx	[vp0 + n], %l0
Packit 5c3484
	sllx	%l1, cnt, %g3
Packit 5c3484
	stx	%o0, [rp0 + n]
Packit 5c3484
L(lo1):	srlx	%l1, tnc, %l3
Packit 5c3484
	MERGE	%l2, %g3, %l7
Packit 5c3484
	ldx	[up0 + n], %l4
Packit 5c3484
	addxccc(%l7, %l5, %o1)
Packit 5c3484
	ldx	[vp1 + n], %l1
Packit 5c3484
	sllx	%l0, cnt, %g1
Packit 5c3484
	stx	%o1, [rp1 + n]
Packit 5c3484
L(lo0):	srlx	%l0, tnc, %l2
Packit 5c3484
	MERGE	%l3, %g1, %l6
Packit 5c3484
	ldx	[up1 + n], %l5
Packit 5c3484
	brlz,pt	n, L(top)
Packit 5c3484
	 add	n, 16, n
Packit 5c3484
Packit 5c3484
	addxccc(%l6, %l4, %o0)
Packit 5c3484
	sllx	%l1, cnt, %g3
Packit 5c3484
	stx	%o0, [rp0 + n]
Packit 5c3484
L(wd1):	srlx	%l1, tnc, %l3
Packit 5c3484
	MERGE	%l2, %g3, %l7
Packit 5c3484
	addxccc(%l7, %l5, %o1)
Packit 5c3484
	stx	%o1, [rp1 + n]
Packit 5c3484
Packit 5c3484
ifdef(`OPERATION_addlsh_n',
Packit 5c3484
`	addxc(	%l3, %g0, %i0)')
Packit 5c3484
ifdef(`OPERATION_sublsh_n',
Packit 5c3484
`	addxc(	%g0, %g0, %g1)
Packit 5c3484
	add	%g1, -1, %g1
Packit 5c3484
	sub	%l3, %g1, %i0')
Packit 5c3484
Packit 5c3484
	ret
Packit 5c3484
	 restore
Packit 5c3484
EPILOGUE()