Blame sysdeps/sparc/sparc64/lshift.S

Packit 6c4009
/* SPARC v9 __mpn_lshift --
Packit 6c4009
Packit 6c4009
   Copyright (C) 1996-2018 Free Software Foundation, Inc.
Packit 6c4009
Packit 6c4009
   This file is part of the GNU MP Library.
Packit 6c4009
Packit 6c4009
   The GNU MP Library is free software; you can redistribute it and/or modify
Packit 6c4009
   it under the terms of the GNU Lesser General Public License as published by
Packit 6c4009
   the Free Software Foundation; either version 2.1 of the License, or (at your
Packit 6c4009
   option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU MP Library is distributed in the hope that it will be useful, but
Packit 6c4009
   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
Packit 6c4009
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
Packit 6c4009
   License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public License
Packit 6c4009
   along with the GNU MP Library; see the file COPYING.LIB.  If not,
Packit 6c4009
   see <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <sysdep.h>
Packit 6c4009
Packit 6c4009
/* INPUT PARAMETERS
Packit 6c4009
   res_ptr	%o0
Packit 6c4009
   src_ptr	%o1
Packit 6c4009
   size		%o2
Packit 6c4009
   cnt		%o3  */
Packit 6c4009
Packit 6c4009
	.register	%g2, #scratch
Packit 6c4009
	.register	%g3, #scratch
Packit 6c4009
Packit 6c4009
ENTRY(__mpn_lshift)
Packit 6c4009
	sllx	%o2,3,%g1
Packit 6c4009
	add	%o1,%g1,%o1	! make %o1 point at end of src
Packit 6c4009
	ldx	[%o1-8],%g2	! load first limb
Packit 6c4009
	sub	%g0,%o3,%o5	! negate shift count
Packit 6c4009
	add	%o0,%g1,%o0	! make %o0 point at end of res
Packit 6c4009
	add	%o2,-1,%o2
Packit 6c4009
	andcc	%o2,4-1,%g4	! number of limbs in first loop
Packit 6c4009
	srlx	%g2,%o5,%g1	! compute function result
Packit 6c4009
	be,pn	%xcc,.L0	! if multiple of 4 limbs, skip first loop
Packit 6c4009
	 mov	%g1,%g5
Packit 6c4009
Packit 6c4009
	sub	%o2,%g4,%o2	! adjust count for main loop
Packit 6c4009
Packit 6c4009
.Loop0:	ldx	[%o1-16],%g3
Packit 6c4009
	add	%o0,-8,%o0
Packit 6c4009
	add	%o1,-8,%o1
Packit 6c4009
	sllx	%g2,%o3,%o4
Packit 6c4009
	addcc	%g4,-1,%g4
Packit 6c4009
	srlx	%g3,%o5,%g1
Packit 6c4009
	mov	%g3,%g2
Packit 6c4009
	or	%o4,%g1,%o4
Packit 6c4009
	bne,pt	%xcc,.Loop0
Packit 6c4009
	 stx	%o4,[%o0+0]
Packit 6c4009
Packit 6c4009
.L0:	brz,pn	%o2,.Lend
Packit 6c4009
	 nop
Packit 6c4009
Packit 6c4009
.Loop:	ldx	[%o1-16],%g3
Packit 6c4009
	add	%o0,-32,%o0
Packit 6c4009
	sllx	%g2,%o3,%o4
Packit 6c4009
	addcc	%o2,-4,%o2
Packit 6c4009
	srlx	%g3,%o5,%g1
Packit 6c4009
Packit 6c4009
	ldx	[%o1-24],%g2
Packit 6c4009
	sllx	%g3,%o3,%g4
Packit 6c4009
	or	%o4,%g1,%o4
Packit 6c4009
	stx	%o4,[%o0+24]
Packit 6c4009
	srlx	%g2,%o5,%g1
Packit 6c4009
Packit 6c4009
	ldx	[%o1-32],%g3
Packit 6c4009
	sllx	%g2,%o3,%o4
Packit 6c4009
	or	%g4,%g1,%g4
Packit 6c4009
	stx	%g4,[%o0+16]
Packit 6c4009
	srlx	%g3,%o5,%g1
Packit 6c4009
Packit 6c4009
	ldx	[%o1-40],%g2
Packit 6c4009
	sllx	%g3,%o3,%g4
Packit 6c4009
	or	%o4,%g1,%o4
Packit 6c4009
	stx	%o4,[%o0+8]
Packit 6c4009
	srlx	%g2,%o5,%g1
Packit 6c4009
Packit 6c4009
	add	%o1,-32,%o1
Packit 6c4009
	or	%g4,%g1,%g4
Packit 6c4009
	bne,pt	%xcc,.Loop
Packit 6c4009
	 stx	%g4,[%o0+0]
Packit 6c4009
Packit 6c4009
.Lend:	sllx	%g2,%o3,%g2
Packit 6c4009
	stx	%g2,[%o0-8]
Packit 6c4009
Packit 6c4009
	jmpl	%o7+8, %g0
Packit 6c4009
	 mov	%g5,%o0
Packit 6c4009
Packit 6c4009
END(__mpn_lshift)