This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Add framework for using sparc VIS3 instructions, use itfor copysign/signbit.


This lays down the initial framework to add VIS3 optimized
routines on sparc.  signbit and copysign are used as initial
examples of such optimizations.

The main major feature VIS3 gives us is support for moving values
between the float and integer registers without using the stack.  On
32-bit this is a huge issue since the 32-bit sparc ABI passes float
arguments in via the integer registers (and even more strangely
returns float values in float registers).

VIS3 also makes float multiply-add instructions available.

Another VIS3 optimization I am eager to add, and will show up in a
forthcoming commit, is to use VIS3 for fmin/fmax.  Both can be done in
2 instructions using the VIS3 "lexicographic compare" instructions.
These special float compare instructions distinguish -0 and +0,
treating -0 as less-than +0.  The float condition codes are written as:

	rs1 >= rs2, neither is NaN	--> 0
	rs1 < rs2, neither is NaN	--> 1
	rs1 is NaN, rs2 is not NaN	--> 2
	rs2 is NaN, rs2 is don't care	--> 3

So for fmaxf you can do something like:

	flcmps	%fcc0, %f1, %f3
	retl
	 fmovslg %fcc0, %f3, %f0

and fminf would be:

	flcmps	%fcc0, %f1, %f3
	retl
	 fmovsge %fcc0, %f3, %f0

I also anticipate that I'll templatize or macroize the ifunc assembler
since they are all looking identical except for the base name of the
function.  But I want to convert some more routines to VIS3 first so
I can get a better handle on how that should look.

Committed to master.

	* sysdeps/sparc/configure.in: New file.
	* sysdeps/sparc/configure: Generate.
	* configure.in (libc_cv_sparc_as_vis3): Substitute.
	* configure: Regenerate.
	* config.h.in (HAVE_AS_VIS3_SUPPORT): New.
	* config.make.in (have-as-vis3): New.
	* sysdeps/sparc/sparc32/sparcv9/Makefile (ASFLAGS-*): If VIS3 is
	available use -Av9d instead of -Av9a.
	* sysdeps/sparc/sparc64/Makefile: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile: New file.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign-vis3.S: New file.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.S: New file.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf-vis3.S: New file.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.S: New file.
	* sysdeps/sparc/sparc64/fpu/multiarch/Makefile: New file.
	* sysdeps/sparc/sparc64/fpu/multiarch/s_signbit-vis3.S: New file.
	* sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.S: New file.
	* sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf-vis3.S: New file.
	* sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.S: New file.
---
 ChangeLog                                          |   20 +++
 config.h.in                                        |    3 +
 config.make.in                                     |    1 +
 configure                                          |    2 +
 configure.in                                       |    1 +
 sysdeps/sparc/configure                            |  124 ++++++++++++++++++++
 sysdeps/sparc/configure.in                         |   30 +++++
 sysdeps/sparc/sparc32/sparcv9/Makefile             |    9 ++
 .../sparc/sparc32/sparcv9/fpu/multiarch/Makefile   |    9 ++
 .../sparcv9/fpu/multiarch/s_copysign-vis3.S        |   30 +++++
 .../sparc32/sparcv9/fpu/multiarch/s_copysign.S     |   46 +++++++
 .../sparcv9/fpu/multiarch/s_copysignf-vis3.S       |   29 +++++
 .../sparc32/sparcv9/fpu/multiarch/s_copysignf.S    |   46 +++++++
 sysdeps/sparc/sparc64/Makefile                     |    9 ++
 sysdeps/sparc/sparc64/fpu/multiarch/Makefile       |    9 ++
 .../sparc/sparc64/fpu/multiarch/s_signbit-vis3.S   |   25 ++++
 sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.S    |   57 +++++++++
 .../sparc/sparc64/fpu/multiarch/s_signbitf-vis3.S  |   25 ++++
 sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.S   |   46 +++++++
 19 files changed, 521 insertions(+), 0 deletions(-)
 create mode 100644 sysdeps/sparc/configure
 create mode 100644 sysdeps/sparc/configure.in
 create mode 100644 sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile
 create mode 100644 sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign-vis3.S
 create mode 100644 sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.S
 create mode 100644 sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf-vis3.S
 create mode 100644 sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.S
 create mode 100644 sysdeps/sparc/sparc64/fpu/multiarch/Makefile
 create mode 100644 sysdeps/sparc/sparc64/fpu/multiarch/s_signbit-vis3.S
 create mode 100644 sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.S
 create mode 100644 sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf-vis3.S
 create mode 100644 sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.S

diff --git a/ChangeLog b/ChangeLog
index 4983816..b36ecb9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,25 @@
 2012-03-14  David S. Miller  <davem@davemloft.net>
 
+	* sysdeps/sparc/configure.in: New file.
+	* sysdeps/sparc/configure: Generate.
+	* configure.in (libc_cv_sparc_as_vis3): Substitute.
+	* configure: Regenerate.
+	* config.h.in (HAVE_AS_VIS3_SUPPORT): New.
+	* config.make.in (have-as-vis3): New.
+	* sysdeps/sparc/sparc32/sparcv9/Makefile (ASFLAGS-*): If VIS3 is
+	available use -Av9d instead of -Av9a.
+	* sysdeps/sparc/sparc64/Makefile: Likewise.
+	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile: New file.
+	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign-vis3.S: New file.
+	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.S: New file.
+	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf-vis3.S: New file.
+	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.S: New file.
+	* sysdeps/sparc/sparc64/fpu/multiarch/Makefile: New file.
+	* sysdeps/sparc/sparc64/fpu/multiarch/s_signbit-vis3.S: New file.
+	* sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.S: New file.
+	* sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf-vis3.S: New file.
+	* sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.S: New file.
+
 	* sysdeps/sparc/sparc64/fpu/s_copysign.S (__copysign): Use fzeros/fnegs
 	to load 0x80000000 into a float register instead of using the stack.
 	* sysdeps/sparc/sparc64/fpu/s_copysignf.S (__copysignf): Likewise.
diff --git a/config.h.in b/config.h.in
index 7e5f4d4..3b938f8 100644
--- a/config.h.in
+++ b/config.h.in
@@ -90,6 +90,9 @@
 /* Defined on SPARC if GCC emits GOTDATA relocations.  */
 #undef  HAVE_GCC_GOTDATA
 
+/* Define on SPARC if AS supports VIS3 instructions.  */
+#undef  HAVE_AS_VIS3_SUPPORT
+
 /* Define if the linker supports the -z combreloc option.  */
 #undef	HAVE_Z_COMBRELOC
 
diff --git a/config.make.in b/config.make.in
index 46a14b4..2b9a939 100644
--- a/config.make.in
+++ b/config.make.in
@@ -58,6 +58,7 @@ enable-check-abi = @enable_check_abi@
 have-forced-unwind = @libc_cv_forced_unwind@
 have-fpie = @libc_cv_fpie@
 have-mfma4 = @libc_cv_cc_fma4@
+have-as-vis3 = @libc_cv_sparc_as_vis3@
 gnu89-inline-CFLAGS = @gnu89_inline@
 have-ssp = @libc_cv_ssp@
 have-selinux = @have_selinux@
diff --git a/configure b/configure
index f415389..94b15bb 100755
--- a/configure
+++ b/configure
@@ -616,6 +616,7 @@ shared
 static
 ldd_rewrite_script
 use_ldconfig
+libc_cv_sparc_as_vis3
 libc_cv_as_i686
 libc_cv_cc_fma4
 libc_cv_cc_novzeroupper
@@ -7647,6 +7648,7 @@ fi
 
 
 
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -fPIC is default" >&5
 $as_echo_n "checking whether -fPIC is default... " >&6; }
 if ${libc_cv_pic_default+:} false; then :
diff --git a/configure.in b/configure.in
index ee9e3d8..119d5be 100644
--- a/configure.in
+++ b/configure.in
@@ -2151,6 +2151,7 @@ AC_SUBST(libc_cv_cc_sse2avx)
 AC_SUBST(libc_cv_cc_novzeroupper)
 AC_SUBST(libc_cv_cc_fma4)
 AC_SUBST(libc_cv_as_i686)
+AC_SUBST(libc_cv_sparc_as_vis3)
 
 AC_SUBST(use_ldconfig)
 AC_SUBST(ldd_rewrite_script)
diff --git a/sysdeps/sparc/configure b/sysdeps/sparc/configure
new file mode 100644
index 0000000..9ce761b
--- /dev/null
+++ b/sysdeps/sparc/configure
@@ -0,0 +1,124 @@
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+
+
+  as_lineno_1=$LINENO as_lineno_1a=$LINENO
+  as_lineno_2=$LINENO as_lineno_2a=$LINENO
+  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
+  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+# This file is generated from configure.in by Autoconf.  DO NOT EDIT!
+ # Local configure fragment for sysdeps/sparc.
+
+# Check for support of VIS3 et al. instructions in the assembler.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sparc assembler VIS3 support" >&5
+$as_echo_n "checking for sparc assembler VIS3 support... " >&6; }
+if ${libc_cv_sparc_as_vis3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.S <<\EOF
+	.text
+foo:	fmadds		%f1, %f2, %f3, %f5
+	fmaddd		%f2, %f4, %f8, %f10
+	fhadds		%f2, %f3, %f5
+	fhaddd		%f4, %f8, %f10
+	pdistn		%f2, %f4, %g1
+	movdtox		%f10, %o0
+	movstouw	%f9, %o1
+	movstosw	%f7, %o2
+	movxtod		%o3, %f18
+	movwtos		%o4, %f15
+	flcmps		%fcc0, %f3, %f5
+	flcmpd		%fcc1, %f4, %f6
+EOF
+if { ac_try='${CC-cc} -c $CFLAGS -Wa,-Av9d conftest.S'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+  libc_cv_sparc_as_vis3=yes
+else
+  libc_cv_sparc_as_vis3=no
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_sparc_as_vis3" >&5
+$as_echo "$libc_cv_sparc_as_vis3" >&6; }
+if test $libc_cv_sparc_as_vis3 = yes; then
+  $as_echo "#define HAVE_AS_VIS3_SUPPORT 1" >>confdefs.h
+
+fi
diff --git a/sysdeps/sparc/configure.in b/sysdeps/sparc/configure.in
new file mode 100644
index 0000000..b80d9cb
--- /dev/null
+++ b/sysdeps/sparc/configure.in
@@ -0,0 +1,30 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/sparc.
+
+# Check for support of VIS3 et al. instructions in the assembler.
+AC_CACHE_CHECK(for sparc assembler VIS3 support, libc_cv_sparc_as_vis3, [dnl
+cat > conftest.S <<\EOF
+	.text
+foo:	fmadds		%f1, %f2, %f3, %f5
+	fmaddd		%f2, %f4, %f8, %f10
+	fhadds		%f2, %f3, %f5
+	fhaddd		%f4, %f8, %f10
+	pdistn		%f2, %f4, %g1
+	movdtox		%f10, %o0
+	movstouw	%f9, %o1
+	movstosw	%f7, %o2
+	movxtod		%o3, %f18
+	movwtos		%o4, %f15
+	flcmps		%fcc0, %f3, %f5
+	flcmpd		%fcc1, %f4, %f6
+EOF
+dnl
+if AC_TRY_COMMAND([${CC-cc} -c $CFLAGS -Wa,-Av9d conftest.S]); then
+  libc_cv_sparc_as_vis3=yes
+else
+  libc_cv_sparc_as_vis3=no
+fi
+rm -f conftest*])
+if test $libc_cv_sparc_as_vis3 = yes; then
+  AC_DEFINE(HAVE_AS_VIS3_SUPPORT)
+fi
diff --git a/sysdeps/sparc/sparc32/sparcv9/Makefile b/sysdeps/sparc/sparc32/sparcv9/Makefile
index 58f5759..8a9330f 100644
--- a/sysdeps/sparc/sparc32/sparcv9/Makefile
+++ b/sysdeps/sparc/sparc32/sparcv9/Makefile
@@ -5,9 +5,18 @@ sysdep_routines += hp-timing
 elide-routines.os += hp-timing
 endif
 
+ifeq ($(have-as-vis3),yes)
+ASFLAGS-.o += -Wa,-Av9d
+ASFLAGS-.os += -Wa,-Av9d
+ASFLAGS-.op += -Wa,-Av9d
+ASFLAGS-.og += -Wa,-Av9d
+ASFLAGS-.ob += -Wa,-Av9d
+ASFLAGS-.oS += -Wa,-Av9d
+else
 ASFLAGS-.o += -Wa,-Av9a
 ASFLAGS-.os += -Wa,-Av9a
 ASFLAGS-.op += -Wa,-Av9a
 ASFLAGS-.og += -Wa,-Av9a
 ASFLAGS-.ob += -Wa,-Av9a
 ASFLAGS-.oS += -Wa,-Av9a
+endif
diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile
new file mode 100644
index 0000000..33b03ac
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile
@@ -0,0 +1,9 @@
+ifeq ($(subdir),math)
+ifeq ($(have-as-vis3),yes)
+libm-sysdep_routines += m_copysignf-vis3 m_copysign-vis3
+sysdep_routines += s_copysignf-vis3 s_copysign-vis3
+
+CFLAGS-s_copysignf-vis3.S = -Wa,-Av9d
+CFLAGS-s_copysign-vis3.S = -Wa,-Av9d
+endif
+endif
\ No newline at end of file
diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign-vis3.S b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign-vis3.S
new file mode 100644
index 0000000..db27bb7
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign-vis3.S
@@ -0,0 +1,30 @@
+/* copysign function, sparc32 vis3 version.
+   Copyright (C) 2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by David S. Miller <davem@davemloft.net>, 2012.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+
+ENTRY (__copysign_vis3)
+	sethi	%hi(0x80000000), %g1
+	and	%o2, %g1, %o4
+	andn	%o0, %g1, %o0
+	or	%o0, %o4, %o0
+	movwtos %o0, %f0
+	retl
+	 movwtos %o1, %f1
+END (__copysign_vis3)
diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.S b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.S
new file mode 100644
index 0000000..7179058
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.S
@@ -0,0 +1,46 @@
+#include <sysdep.h>
+
+	.text
+ENTRY(__copysign)
+	.type	__copysign, @gnu_indirect_function
+# ifdef SHARED
+	SETUP_PIC_REG_LEAF(o3, o5)
+# endif
+# ifdef HAVE_AS_VIS3_SUPPORT
+	set	HWCAP_SPARC_VIS3, %o1
+	andcc	%o0, %o1, %g0
+	be	9f
+	 nop
+#  ifdef SHARED
+	sethi	%gdop_hix22(__copysign_vis3), %o1
+	xor	%o1, %gdop_lox10(__copysign_vis3), %o1
+#  else
+	set	__copysign_vis3, %o1
+#  endif
+	ba	10f
+	 nop
+9:
+# endif
+# ifdef SHARED
+	sethi	%gdop_hix22(__copysign_generic), %o1
+	xor	%o1, %gdop_lox10(__copysign_generic), %o1
+# else
+	set	__copysign_generic, %o1
+# endif
+# ifdef HAVE_AS_VIS3_SUPPORT
+10:
+# endif
+# ifdef SHARED
+	add	%o3, %o1, %o1
+# endif
+	retl
+	 mov	%o1, %o0
+END(__copysign)
+weak_alias (__copysign, copysign)
+
+# undef weak_alias
+# define weak_alias(a, b)
+
+#define __copysign __copysign_generic
+
+#include "../../../fpu/s_copysign.S"
diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf-vis3.S b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf-vis3.S
new file mode 100644
index 0000000..7cdc540
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf-vis3.S
@@ -0,0 +1,29 @@
+/* float copysign function, sparc32 vis3 version.
+   Copyright (C) 2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by David S. Miller <davem@davemloft.net>, 2012.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+
+ENTRY (__copysignf_vis3)
+	sethi	%hi(0x80000000), %g1
+	and	%o1, %g1, %o4
+	andn	%o0, %g1, %o0
+	or	%o0, %o4, %o0
+	retl
+	 movwtos %o0, %f0
+END (__copysignf_vis3)
diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.S b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.S
new file mode 100644
index 0000000..4d055f2
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.S
@@ -0,0 +1,46 @@
+#include <sysdep.h>
+
+	.text
+ENTRY(__copysignf)
+	.type	__copysignf, @gnu_indirect_function
+# ifdef SHARED
+	SETUP_PIC_REG_LEAF(o3, o5)
+# endif
+# ifdef HAVE_AS_VIS3_SUPPORT
+	set	HWCAP_SPARC_VIS3, %o1
+	andcc	%o0, %o1, %g0
+	be	9f
+	 nop
+#  ifdef SHARED
+	sethi	%gdop_hix22(__copysignf_vis3), %o1
+	xor	%o1, %gdop_lox10(__copysignf_vis3), %o1
+#  else
+	set	__copysignf_vis3, %o1
+#  endif
+	ba	10f
+	 nop
+9:
+# endif
+# ifdef SHARED
+	sethi	%gdop_hix22(__copysignf_generic), %o1
+	xor	%o1, %gdop_lox10(__copysignf_generic), %o1
+# else
+	set	__copysignf_generic, %o1
+# endif
+# ifdef HAVE_AS_VIS3_SUPPORT
+10:
+# endif
+# ifdef SHARED
+	add	%o3, %o1, %o1
+# endif
+	retl
+	 mov	%o1, %o0
+END(__copysignf)
+weak_alias (__copysignf, copysignf)
+
+# undef weak_alias
+# define weak_alias(a, b)
+
+#define __copysignf __copysignf_generic
+
+#include "../../../fpu/s_copysignf.S"
diff --git a/sysdeps/sparc/sparc64/Makefile b/sysdeps/sparc/sparc64/Makefile
index fb8b011..2b7b830 100644
--- a/sysdeps/sparc/sparc64/Makefile
+++ b/sysdeps/sparc/sparc64/Makefile
@@ -6,3 +6,12 @@ endif
 ifeq ($(subdir),string)
 sysdep_routines += align-cpy
 endif
+
+ifeq ($(have-as-vis3),yes)
+ASFLAGS-.o += -Wa,-Av9d
+ASFLAGS-.os += -Wa,-Av9d
+ASFLAGS-.op += -Wa,-Av9d
+ASFLAGS-.og += -Wa,-Av9d
+ASFLAGS-.ob += -Wa,-Av9d
+ASFLAGS-.oS += -Wa,-Av9d
+endif
diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/Makefile b/sysdeps/sparc/sparc64/fpu/multiarch/Makefile
new file mode 100644
index 0000000..b03884d
--- /dev/null
+++ b/sysdeps/sparc/sparc64/fpu/multiarch/Makefile
@@ -0,0 +1,9 @@
+ifeq ($(subdir),math)
+ifeq ($(have-as-vis3),yes)
+libm-sysdep_routines += m_signbitf-vis3 m_signbit-vis3
+sysdep_routines += s_signbitf-vis3 s_signbit-vis3
+
+CFLAGS-s_signbitf-vis3.S = -Wa,-Av9d
+CFLAGS-s_signbit-vis3.S = -Wa,-Av9d
+endif
+endif
\ No newline at end of file
diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/s_signbit-vis3.S b/sysdeps/sparc/sparc64/fpu/multiarch/s_signbit-vis3.S
new file mode 100644
index 0000000..8d54e32
--- /dev/null
+++ b/sysdeps/sparc/sparc64/fpu/multiarch/s_signbit-vis3.S
@@ -0,0 +1,25 @@
+/* signbit().  sparc64 vis3 version.
+   Copyright (C) 2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+
+ENTRY (__signbit_vis3)
+	movdtox	%f0, %o0
+	retl
+	 srlx	%o0, 63, %o0
+END (__signbit_vis3)
diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.S b/sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.S
new file mode 100644
index 0000000..a8e9728
--- /dev/null
+++ b/sysdeps/sparc/sparc64/fpu/multiarch/s_signbit.S
@@ -0,0 +1,57 @@
+#include <sysdep.h>
+
+	.text
+ENTRY(__signbit)
+	.type	__signbit, @gnu_indirect_function
+# ifdef SHARED
+	SETUP_PIC_REG_LEAF(o3, o5)
+# endif
+# ifdef HAVE_AS_VIS3_SUPPORT
+	set	HWCAP_SPARC_VIS3, %o1
+	andcc	%o0, %o1, %g0
+	be	9f
+	 nop
+#  ifdef SHARED
+	sethi	%gdop_hix22(__signbit_vis3), %o1
+	xor	%o1, %gdop_lox10(__signbit_vis3), %o1
+#  else
+	set	__signbit_vis3, %o1
+#  endif
+	ba	10f
+	 nop
+9:
+# endif
+# ifdef SHARED
+	sethi	%gdop_hix22(__signbit_generic), %o1
+	xor	%o1, %gdop_lox10(__signbit_generic), %o1
+# else
+	set	__signbit_generic, %o1
+# endif
+# ifdef HAVE_AS_VIS3_SUPPORT
+10:
+# endif
+# ifdef SHARED
+	add	%o3, %o1, %o1
+# endif
+	retl
+	 mov	%o1, %o0
+END(__signbit)
+weak_alias (__signbit, signbit)
+
+/* On 64-bit the double version will also always work for
+   long-double-precision since in both cases the word with the
+   sign bit in it is passed always in register %f0.  */
+strong_alias (__signbit, __signbitl)
+hidden_def (__signbitl)
+weak_alias (__signbitl, signbitl)
+
+# undef weak_alias
+# define weak_alias(a, b)
+# undef strong_alias
+# define strong_alias(a, b)
+# undef hidden_def
+# define hidden_def(a)
+
+#define __signbit __signbit_generic
+
+#include "../s_signbit.S"
diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf-vis3.S b/sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf-vis3.S
new file mode 100644
index 0000000..004b087
--- /dev/null
+++ b/sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf-vis3.S
@@ -0,0 +1,25 @@
+/* signbitf().  sparc64 vis3 version.
+   Copyright (C) 2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+
+ENTRY (__signbitf_vis3)
+	movstouw %f1, %o0
+	retl
+	 srl	%o0, 31, %o0
+END (__signbitf_vis3)
diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.S b/sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.S
new file mode 100644
index 0000000..721bc7f
--- /dev/null
+++ b/sysdeps/sparc/sparc64/fpu/multiarch/s_signbitf.S
@@ -0,0 +1,46 @@
+#include <sysdep.h>
+
+	.text
+ENTRY(__signbitf)
+	.type	__signbitf, @gnu_indirect_function
+# ifdef SHARED
+	SETUP_PIC_REG_LEAF(o3, o5)
+# endif
+# ifdef HAVE_AS_VIS3_SUPPORT
+	set	HWCAP_SPARC_VIS3, %o1
+	andcc	%o0, %o1, %g0
+	be	9f
+	 nop
+#  ifdef SHARED
+	sethi	%gdop_hix22(__signbitf_vis3), %o1
+	xor	%o1, %gdop_lox10(__signbitf_vis3), %o1
+#  else
+	set	__signbitf_vis3, %o1
+#  endif
+	ba	10f
+	 nop
+9:
+# endif
+# ifdef SHARED
+	sethi	%gdop_hix22(__signbitf_generic), %o1
+	xor	%o1, %gdop_lox10(__signbitf_generic), %o1
+# else
+	set	__signbitf_generic, %o1
+# endif
+# ifdef HAVE_AS_VIS3_SUPPORT
+10:
+# endif
+# ifdef SHARED
+	add	%o3, %o1, %o1
+# endif
+	retl
+	 mov	%o1, %o0
+END(__signbitf)
+weak_alias (__signbitf, signbitf)
+
+# undef weak_alias
+# define weak_alias(a, b)
+
+#define __signbitf __signbitf_generic
+
+#include "../s_signbitf.S"
-- 
1.7.9.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]