Blame sysdeps/sparc/sparc64/fpu/multiarch/s_nearbyint-vis3.S

Packit 6c4009
/* Round float to int floating-point values without generating
Packit 6c4009
   an inexact exception, sparc64 vis3 version.
Packit 6c4009
Packit 6c4009
   Copyright (C) 2013-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
   Contributed by David S. Miller <davem@davemloft.net>, 2013.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <sysdep.h>
Packit 6c4009
Packit 6c4009
	/* We pop constants into the FPU registers using the incoming
Packit 6c4009
	   argument stack slots, since this avoid having to use any PIC
Packit 6c4009
	   references.  We also thus avoid having to allocate a register
Packit 6c4009
	   window.
Packit 6c4009
Packit 6c4009
	   VIS instructions are used to facilitate the formation of
Packit 6c4009
	   easier constants, and the propagation of the sign bit.  */
Packit 6c4009
Packit 6c4009
#define TWO_FIFTYTWO	0x43300000		/* 2**52 */
Packit 6c4009
Packit 6c4009
#define ZERO		%f10			/* 0.0 */
Packit 6c4009
#define SIGN_BIT	%f12			/* -0.0 */
Packit 6c4009
Packit 6c4009
ENTRY (__nearbyint_vis3)
Packit 6c4009
	fcmpd	%fcc3, %f0, %f0			/* Check for sNaN */
Packit 6c4009
	stx	%fsr, [%sp + STACK_BIAS + 144]
Packit 6c4009
	sethi	%hi(TWO_FIFTYTWO), %o2
Packit 6c4009
	sllx	%o2, 32, %o2
Packit 6c4009
	ldx	[%sp + STACK_BIAS + 144], %o4
Packit 6c4009
	sethi	%hi(0xf8003e0), %o5
Packit 6c4009
	fzero	ZERO
Packit 6c4009
	or	%o5, %lo(0xf8003e0), %o5
Packit 6c4009
	fnegd	ZERO, SIGN_BIT
Packit 6c4009
	andn	%o4, %o5, %o4
Packit 6c4009
	movxtod	%o2, %f16
Packit 6c4009
	stx	%o4, [%sp + STACK_BIAS + 136]
Packit 6c4009
	ldx	[%sp + STACK_BIAS + 136], %fsr
Packit 6c4009
	fabsd	%f0, %f14
Packit 6c4009
	fcmpd	%fcc3, %f14, %f16
Packit 6c4009
	fmovduge %fcc3, ZERO, %f16
Packit 6c4009
	fand	%f0, SIGN_BIT, SIGN_BIT
Packit 6c4009
	for	%f16, SIGN_BIT, %f16
Packit 6c4009
	faddd	%f0, %f16, %f6
Packit 6c4009
	fsubd	%f6, %f16, %f0
Packit 6c4009
	fabsd	%f0, %f0
Packit 6c4009
	for	%f0, SIGN_BIT, %f0
Packit 6c4009
	retl
Packit 6c4009
	 ldx	[%sp + STACK_BIAS + 144], %fsr
Packit 6c4009
END (__nearbyint_vis3)