aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog74
-rwxr-xr-xconfigure4
-rw-r--r--configure.in4
-rw-r--r--sysdeps/sparc/sparc32/bcopy.c1
-rw-r--r--sysdeps/sparc/sparc32/bzero.c1
-rw-r--r--sysdeps/sparc/sparc32/memchr.S143
-rw-r--r--sysdeps/sparc/sparc32/memcpy.S974
-rw-r--r--sysdeps/sparc/sparc32/memmove.c1
-rw-r--r--sysdeps/sparc/sparc32/memset.S154
-rw-r--r--sysdeps/sparc/sparc32/sparcv8/Makefile1
-rw-r--r--sysdeps/sparc/sparc32/sparcv8/rem.S3
-rw-r--r--sysdeps/sparc/sparc32/sparcv8/sdiv.S10
-rw-r--r--sysdeps/sparc/sparc32/sparcv8/udiv.S2
-rw-r--r--sysdeps/sparc/sparc32/sparcv8/urem.S3
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/Makefile1
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/bcopy.c1
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/bzero.c1
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/dotmul.S17
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/memchr.S4
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/memcmp.S4
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/memcpy.S4
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/memset.S4
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/rem.S22
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/sdiv.S20
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/stpcpy.S4
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/stpncpy.S4
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/strcat.S4
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/strchr.S4
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/strcmp.S4
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/strcpy.S4
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/strcspn.S4
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/strlen.S4
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/strncmp.S4
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/strncpy.S4
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/strpbrk.S4
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/strrchr.c1
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/strspn.S4
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/udiv.S17
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/umul.S17
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/urem.S19
-rw-r--r--sysdeps/sparc/sparc32/stpcpy.S163
-rw-r--r--sysdeps/sparc/sparc32/strcat.S348
-rw-r--r--sysdeps/sparc/sparc32/strchr.S282
-rw-r--r--sysdeps/sparc/sparc32/strcmp.S257
-rw-r--r--sysdeps/sparc/sparc32/strcpy.S274
-rw-r--r--sysdeps/sparc/sparc32/strlen.S102
-rw-r--r--sysdeps/sparc/sparc32/strrchr.c1
-rw-r--r--sysdeps/sparc/sparc64/bcopy.c1
-rw-r--r--sysdeps/sparc/sparc64/bzero.c1
-rw-r--r--sysdeps/sparc/sparc64/memchr.S256
-rw-r--r--sysdeps/sparc/sparc64/memcmp.S140
-rw-r--r--sysdeps/sparc/sparc64/memcpy.S574
-rw-r--r--sysdeps/sparc/sparc64/memset.S316
-rw-r--r--sysdeps/sparc/sparc64/stpcpy.S268
-rw-r--r--sysdeps/sparc/sparc64/stpncpy.S421
-rw-r--r--sysdeps/sparc/sparc64/strcat.S336
-rw-r--r--sysdeps/sparc/sparc64/strchr.S479
-rw-r--r--sysdeps/sparc/sparc64/strcmp.S274
-rw-r--r--sysdeps/sparc/sparc64/strcpy.S239
-rw-r--r--sysdeps/sparc/sparc64/strcspn.S211
-rw-r--r--sysdeps/sparc/sparc64/strlen.S172
-rw-r--r--sysdeps/sparc/sparc64/strncmp.S359
-rw-r--r--sysdeps/sparc/sparc64/strncpy.S393
-rw-r--r--sysdeps/sparc/sparc64/strpbrk.S229
-rw-r--r--sysdeps/sparc/sparc64/strrchr.c1
-rw-r--r--sysdeps/sparc/sparc64/strspn.S211
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc32/Makefile4
67 files changed, 7861 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index a660ec6a7b..224e3636f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,77 @@
+1999-03-29 Jakub Jelinek <jj@ultra.linux.cz>
+
+ * sysdeps/sparc/sparc32/sparcv8/Makefile: New file.
+ * sysdeps/sparc/sparc32/sparcv8/rem.S: Delay after write %y.
+ * sysdeps/sparc/sparc32/sparcv8/sdiv.S: Likewise.
+ * sysdeps/sparc/sparc32/sparcv8/udiv.S: Likewise.
+ * sysdeps/sparc/sparc32/sparcv8/urem.S: Likewise.
+
+ * sysdeps/sparc/sparc32/sparcv9/bcopy.c: New file.
+ * sysdeps/sparc/sparc32/sparcv9/bzero.c: New file.
+ * sysdeps/sparc/sparc32/sparcv9/memchr.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/memcmp.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/memcpy.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/memset.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/stpcpy.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/strcat.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/strchr.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/strcmp.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/strcpy.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/strcspn.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/strlen.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/strncpy.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/strpbrk.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/strrchr.c: New file.
+ * sysdeps/sparc/sparc32/sparcv9/strspn.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/dotmul.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/rem.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/sdiv.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/udiv.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/umul.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/urem.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/Makefile: New file.
+ * sysdeps/sparc/sparc32/sparcv9/stpncpy.S: New file.
+ * sysdeps/sparc/sparc32/sparcv9/strncmp.S: New file.
+
+ * sysdeps/sparc/sparc32/bcopy.c: New file.
+ * sysdeps/sparc/sparc32/bzero.c: New file.
+ * sysdeps/sparc/sparc32/memchr.S: New file.
+ * sysdeps/sparc/sparc32/memcpy.S: New file.
+ * sysdeps/sparc/sparc32/memmove.c: New file.
+ * sysdeps/sparc/sparc32/memset.S: New file.
+ * sysdeps/sparc/sparc32/stpcpy.S: New file.
+ * sysdeps/sparc/sparc32/strchr.S: New file.
+ * sysdeps/sparc/sparc32/strrchr.c: New file.
+ * sysdeps/sparc/sparc32/strcpy.S: New file.
+ * sysdeps/sparc/sparc32/strlen.S: New file.
+ * sysdeps/sparc/sparc32/strcat.S: New file.
+ * sysdeps/sparc/sparc32/strcmp.S: New file.
+
+ * sysdeps/sparc/sparc64/bcopy.c: New file.
+ * sysdeps/sparc/sparc64/bzero.c: New file.
+ * sysdeps/sparc/sparc64/memchr.S: New file.
+ * sysdeps/sparc/sparc64/memcmp.S: New file.
+ * sysdeps/sparc/sparc64/memcpy.S: New file.
+ * sysdeps/sparc/sparc64/memset.S: New file.
+ * sysdeps/sparc/sparc64/stpcpy.S: New file.
+ * sysdeps/sparc/sparc64/strcat.S: New file.
+ * sysdeps/sparc/sparc64/strchr.S: New file.
+ * sysdeps/sparc/sparc64/strcmp.S: New file.
+ * sysdeps/sparc/sparc64/strcpy.S: New file.
+ * sysdeps/sparc/sparc64/strcspn.S: New file.
+ * sysdeps/sparc/sparc64/strlen.S: New file.
+ * sysdeps/sparc/sparc64/strncpy.S: New file.
+ * sysdeps/sparc/sparc64/strpbrk.S: New file.
+ * sysdeps/sparc/sparc64/strrchr.c: New file.
+ * sysdeps/sparc/sparc64/strspn.S: New file.
+ * sysdeps/sparc/sparc64/stpncpy.S: New file.
+ * sysdeps/sparc/sparc64/strncmp.S: New file.
+
+ * sysdeps/unix/sysv/linux/sparc/sparc32/Makefile (ASFLAGS-.os):
+ Append -fPIC, don't replace.
+
+ * configure.in: Recognize sparcv8plus / sparcv9.
+
1999-03-27 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* malloc/obstack.h (obstack_free): Explicitly convert __obj to
diff --git a/configure b/configure
index a3879b77d8..27ce331ea5 100755
--- a/configure
+++ b/configure
@@ -907,6 +907,8 @@ sparc | sparcv[67])
base_machine=sparc machine=sparc/sparc32 ;;
sparcv8 | supersparc | hypersparc)
base_machine=sparc machine=sparc/sparc32/sparcv8 ;;
+sparcv8plus | sparcv8plusa | sparcv9)
+ base_machine=sparc machine=sparc/sparc32/sparcv9 ;;
sparc64 | ultrasparc)
base_machine=sparc machine=sparc/sparc64 ;;
esac
@@ -972,7 +974,7 @@ while b=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$b"; do
tail="$2"
done
-# For sparc/sparc9, try sparc/sparc9 and then sparc.
+# For sparc/sparc32, try sparc/sparc32 and then sparc.
mach=
tail=$machine
while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do
diff --git a/configure.in b/configure.in
index 7a639231a8..ccbec0c994 100644
--- a/configure.in
+++ b/configure.in
@@ -223,6 +223,8 @@ sparc | sparcv[67])
base_machine=sparc machine=sparc/sparc32 ;;
sparcv8 | supersparc | hypersparc)
base_machine=sparc machine=sparc/sparc32/sparcv8 ;;
+sparcv8plus | sparcv8plusa | sparcv9)
+ base_machine=sparc machine=sparc/sparc32/sparcv9 ;;
sparc64 | ultrasparc)
base_machine=sparc machine=sparc/sparc64 ;;
esac
@@ -287,7 +289,7 @@ while b=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$b"; do
tail="$2"
done
-# For sparc/sparc9, try sparc/sparc9 and then sparc.
+# For sparc/sparc32, try sparc/sparc32 and then sparc.
mach=
tail=$machine
while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do
diff --git a/sysdeps/sparc/sparc32/bcopy.c b/sysdeps/sparc/sparc32/bcopy.c
new file mode 100644
index 0000000000..9a455f33c4
--- /dev/null
+++ b/sysdeps/sparc/sparc32/bcopy.c
@@ -0,0 +1 @@
+/* bcopy is in memcpy.S */
diff --git a/sysdeps/sparc/sparc32/bzero.c b/sysdeps/sparc/sparc32/bzero.c
new file mode 100644
index 0000000000..37f0f6f993
--- /dev/null
+++ b/sysdeps/sparc/sparc32/bzero.c
@@ -0,0 +1 @@
+/* bzero is in memset.S */
diff --git a/sysdeps/sparc/sparc32/memchr.S b/sysdeps/sparc/sparc32/memchr.S
new file mode 100644
index 0000000000..270216e6d8
--- /dev/null
+++ b/sysdeps/sparc/sparc32/memchr.S
@@ -0,0 +1,143 @@
+/* memchr (str, ch, n) -- Return pointer to first occurrence of CH in STR less
+ than N.
+ For SPARC v7.
+ Copyright (C) 1996,1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jj@ultra.linux.cz> and
+ David S. Miller <davem@caip.rutgers.edu>.
+
+ This version is developed using the same algorithm as the fast C
+ version which carries the following introduction:
+
+ Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
+ with help from Dan Sahlin (dan@sics.se) and
+ commentary by Jim Blandy (jimb@ai.mit.edu);
+ adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
+ and implemented by Roland McGrath (roland@ai.mit.edu).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+
+ .text
+ .align 4
+0: cmp %o2, 0
+ be 9f
+ sethi %hi(0x80808080), %o4
+ ldub [%o0], %g4
+ cmp %g4, %o1
+ be 1f
+ add %o0, 1, %o0
+ subcc %o2, 1, %o2
+ be 9f
+ andcc %o0, 3, %g0
+ be 4f
+ or %o4, %lo(0x80808080), %o3
+ ldub [%o0], %g4
+ cmp %g4, %o1
+ be 1f
+ add %o0, 1, %o0
+ subcc %o2, 1, %o2
+ be 9f
+ andcc %o0, 3, %g0
+ be 5f
+ sethi %hi(0x01010101), %o5
+ ldub [%o0], %g4
+ cmp %g4, %o1
+ be 1f
+ add %o0, 1, %o0
+ subcc %o2, 1, %o2
+ bne,a 7f
+ and %o2, 3, %g1
+ retl
+ clr %o0
+1: retl
+ sub %o0, 1, %o0
+
+ENTRY(memchr)
+ andcc %o1, 0xff, %o1
+ sll %o1, 8, %g7
+ andcc %o0, 3, %g0
+ or %o1, %g7, %g7
+ sll %g7, 16, %o3
+ bne 0b
+ or %o3, %g7, %g2
+ sethi %hi(0x80808080), %o4
+ or %o4, %lo(0x80808080), %o3
+4: sethi %hi(0x01010101), %o5
+5: and %o2, 3, %g1
+7: andcc %o2, 0xfffffffc, %o2
+ be 0f
+ or %o5, %lo(0x01010101), %g7
+ ld [%o0], %g4
+6: xor %g4, %g2, %g5
+ add %o0, 4, %o0
+ sub %g5, %g7, %g5
+ andcc %g5, %o3, %g0
+ bne 8f
+ subcc %o2, 4, %o2
+ bne,a 6b
+ ld [%o0], %g4
+0: cmp %g1, 0
+1: be 9f
+ add %o0, 4, %o0
+ ldub [%o0 - 4], %g4
+ cmp %g4, %o1
+ be 4f
+ cmp %g1, 1
+ be 9f
+ ldub [%o0 - 3], %g4
+ cmp %g4, %o1
+ be 3f
+ cmp %g1, 2
+ be 9f
+ ldub [%o0 - 2], %g4
+ cmp %g4, %o1
+ be 2f
+ nop
+9: retl
+ clr %o0
+
+ /* Check every byte. */
+8: srl %g4, 24, %g5
+ and %g5, 0xff, %g5
+ cmp %g5, %o1
+ be 4f
+ srl %g4, 16, %g5
+ and %g5, 0xff, %g5
+ cmp %g5, %o1
+ be 3f
+ srl %g4, 8, %g5
+ and %g5, 0xff, %g5
+ cmp %g5, %o1
+ be 2f
+ and %g4, 0xff, %g5
+ cmp %g5, %o1
+ be 1f
+ cmp %o2, 0
+ bne,a 6b
+ ld [%o0], %g4
+ b 1b
+ cmp %g1, 0
+1: retl
+ sub %o0, 1, %o0
+2: retl
+ sub %o0, 2, %o0
+3: retl
+ sub %o0, 3, %o0
+4: retl
+ sub %o0, 4, %o0
+END(memchr)
diff --git a/sysdeps/sparc/sparc32/memcpy.S b/sysdeps/sparc/sparc32/memcpy.S
new file mode 100644
index 0000000000..24d9e04346
--- /dev/null
+++ b/sysdeps/sparc/sparc32/memcpy.S
@@ -0,0 +1,974 @@
+/* Copy SIZE bytes from SRC to DEST.
+ For SPARC v7.
+ Copyright (C) 1996, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David S. Miller <davem@caip.rutgers.edu>,
+ Eddie C. Dost <ecd@skynet.be> and
+ Jakub Jelinek <jj@ultra.linux.cz>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+
+/* Both these macros have to start with exactly the same insn */
+#define MOVE_BIGCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
+ ldd [%src + offset + 0x00], %t0; \
+ ldd [%src + offset + 0x08], %t2; \
+ ldd [%src + offset + 0x10], %t4; \
+ ldd [%src + offset + 0x18], %t6; \
+ st %t0, [%dst + offset + 0x00]; \
+ st %t1, [%dst + offset + 0x04]; \
+ st %t2, [%dst + offset + 0x08]; \
+ st %t3, [%dst + offset + 0x0c]; \
+ st %t4, [%dst + offset + 0x10]; \
+ st %t5, [%dst + offset + 0x14]; \
+ st %t6, [%dst + offset + 0x18]; \
+ st %t7, [%dst + offset + 0x1c];
+
+#define MOVE_BIGALIGNCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
+ ldd [%src + offset + 0x00], %t0; \
+ ldd [%src + offset + 0x08], %t2; \
+ ldd [%src + offset + 0x10], %t4; \
+ ldd [%src + offset + 0x18], %t6; \
+ std %t0, [%dst + offset + 0x00]; \
+ std %t2, [%dst + offset + 0x08]; \
+ std %t4, [%dst + offset + 0x10]; \
+ std %t6, [%dst + offset + 0x18];
+
+#define MOVE_LASTCHUNK(src, dst, offset, t0, t1, t2, t3) \
+ ldd [%src - offset - 0x10], %t0; \
+ ldd [%src - offset - 0x08], %t2; \
+ st %t0, [%dst - offset - 0x10]; \
+ st %t1, [%dst - offset - 0x0c]; \
+ st %t2, [%dst - offset - 0x08]; \
+ st %t3, [%dst - offset - 0x04];
+
+#define MOVE_LASTALIGNCHUNK(src, dst, offset, t0, t1, t2, t3) \
+ ldd [%src - offset - 0x10], %t0; \
+ ldd [%src - offset - 0x08], %t2; \
+ std %t0, [%dst - offset - 0x10]; \
+ std %t2, [%dst - offset - 0x08];
+
+#define MOVE_SHORTCHUNK(src, dst, offset, t0, t1) \
+ ldub [%src - offset - 0x02], %t0; \
+ ldub [%src - offset - 0x01], %t1; \
+ stb %t0, [%dst - offset - 0x02]; \
+ stb %t1, [%dst - offset - 0x01];
+
+/* Both these macros have to start with exactly the same insn */
+#define RMOVE_BIGCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
+ ldd [%src - offset - 0x20], %t0; \
+ ldd [%src - offset - 0x18], %t2; \
+ ldd [%src - offset - 0x10], %t4; \
+ ldd [%src - offset - 0x08], %t6; \
+ st %t0, [%dst - offset - 0x20]; \
+ st %t1, [%dst - offset - 0x1c]; \
+ st %t2, [%dst - offset - 0x18]; \
+ st %t3, [%dst - offset - 0x14]; \
+ st %t4, [%dst - offset - 0x10]; \
+ st %t5, [%dst - offset - 0x0c]; \
+ st %t6, [%dst - offset - 0x08]; \
+ st %t7, [%dst - offset - 0x04];
+
+#define RMOVE_BIGALIGNCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
+ ldd [%src - offset - 0x20], %t0; \
+ ldd [%src - offset - 0x18], %t2; \
+ ldd [%src - offset - 0x10], %t4; \
+ ldd [%src - offset - 0x08], %t6; \
+ std %t0, [%dst - offset - 0x20]; \
+ std %t2, [%dst - offset - 0x18]; \
+ std %t4, [%dst - offset - 0x10]; \
+ std %t6, [%dst - offset - 0x08];
+
+#define RMOVE_LASTCHUNK(src, dst, offset, t0, t1, t2, t3) \
+ ldd [%src + offset + 0x00], %t0; \
+ ldd [%src + offset + 0x08], %t2; \
+ st %t0, [%dst + offset + 0x00]; \
+ st %t1, [%dst + offset + 0x04]; \
+ st %t2, [%dst + offset + 0x08]; \
+ st %t3, [%dst + offset + 0x0c];
+
+#define RMOVE_SHORTCHUNK(src, dst, offset, t0, t1) \
+ ldub [%src + offset + 0x00], %t0; \
+ ldub [%src + offset + 0x01], %t1; \
+ stb %t0, [%dst + offset + 0x00]; \
+ stb %t1, [%dst + offset + 0x01];
+
+#define SMOVE_CHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, prev, shil, shir, offset2) \
+ ldd [%src + offset + 0x00], %t0; \
+ ldd [%src + offset + 0x08], %t2; \
+ srl %t0, shir, %t5; \
+ srl %t1, shir, %t6; \
+ sll %t0, shil, %t0; \
+ or %t5, %prev, %t5; \
+ sll %t1, shil, %prev; \
+ or %t6, %t0, %t0; \
+ srl %t2, shir, %t1; \
+ srl %t3, shir, %t6; \
+ sll %t2, shil, %t2; \
+ or %t1, %prev, %t1; \
+ std %t4, [%dst + offset + offset2 - 0x04]; \
+ std %t0, [%dst + offset + offset2 + 0x04]; \
+ sll %t3, shil, %prev; \
+ or %t6, %t2, %t4;
+
+#define SMOVE_ALIGNCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, prev, shil, shir, offset2) \
+ ldd [%src + offset + 0x00], %t0; \
+ ldd [%src + offset + 0x08], %t2; \
+ srl %t0, shir, %t4; \
+ srl %t1, shir, %t5; \
+ sll %t0, shil, %t6; \
+ or %t4, %prev, %t0; \
+ sll %t1, shil, %prev; \
+ or %t5, %t6, %t1; \
+ srl %t2, shir, %t4; \
+ srl %t3, shir, %t5; \
+ sll %t2, shil, %t6; \
+ or %t4, %prev, %t2; \
+ sll %t3, shil, %prev; \
+ or %t5, %t6, %t3; \
+ std %t0, [%dst + offset + offset2 + 0x00]; \
+ std %t2, [%dst + offset + offset2 + 0x08];
+
+ .text
+ .align 4
+
+70: andcc %o1, 1, %g0
+ be 4f
+ andcc %o1, 2, %g0
+
+ ldub [%o1 - 1], %g2
+ sub %o1, 1, %o1
+ stb %g2, [%o0 - 1]
+ sub %o2, 1, %o2
+ be 3f
+ sub %o0, 1, %o0
+4: lduh [%o1 - 2], %g2
+ sub %o1, 2, %o1
+ sth %g2, [%o0 - 2]
+ sub %o2, 2, %o2
+ b 3f
+ sub %o0, 2, %o0
+
+0: retl
+ nop ! Only bcopy returns here and it retuns void...
+
+ENTRY(bcopy)
+ mov %o0, %o3
+ mov %o1, %o0
+ mov %o3, %o1
+ tst %o2
+ bcs 0b
+ /* Do the cmp in the delay slot */
+END(bcopy)
+ENTRY(memmove)
+ cmp %o0, %o1
+ st %o0, [%sp + 64]
+ bleu 9f
+ sub %o0, %o1, %o4
+
+ add %o1, %o2, %o3
+ cmp %o3, %o0
+ bleu 0f
+ andcc %o4, 3, %o5
+
+ add %o1, %o2, %o1
+ add %o0, %o2, %o0
+ bne 77f
+ cmp %o2, 15
+ bleu 91f
+ andcc %o1, 3, %g0
+ bne 70b
+3: andcc %o1, 4, %g0
+
+ be 2f
+ mov %o2, %g1
+
+ ld [%o1 - 4], %o4
+ sub %g1, 4, %g1
+ st %o4, [%o0 - 4]
+ sub %o1, 4, %o1
+ sub %o0, 4, %o0
+2: andcc %g1, 0xffffff80, %g7
+ be 3f
+ andcc %o0, 4, %g0
+
+ be 74f + 4
+5: RMOVE_BIGCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
+ RMOVE_BIGCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
+ RMOVE_BIGCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
+ RMOVE_BIGCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
+ subcc %g7, 128, %g7
+ sub %o1, 128, %o1
+ bne 5b
+ sub %o0, 128, %o0
+
+3: andcc %g1, 0x70, %g7
+ be 72f
+ andcc %g1, 8, %g0
+
+ srl %g7, 1, %o4
+ mov %o7, %g2
+ add %g7, %o4, %o4
+101: call 100f
+ sub %o1, %g7, %o1
+ mov %g2, %o7
+ jmpl %o5 + (72f - 101b), %g0
+ sub %o0, %g7, %o0
+
+71: RMOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
+ RMOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
+ RMOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
+ RMOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g4, g5)
+ RMOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g4, g5)
+ RMOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
+ RMOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
+72: be 73f
+ andcc %g1, 4, %g0
+
+ ldd [%o1 - 0x08], %g2
+ sub %o0, 8, %o0
+ sub %o1, 8, %o1
+ st %g2, [%o0]
+ st %g3, [%o0 + 0x04]
+73: be 1f
+ andcc %g1, 2, %g0
+
+ ld [%o1 - 4], %g2
+ sub %o1, 4, %o1
+ st %g2, [%o0 - 4]
+ sub %o0, 4, %o0
+1: be 1f
+ andcc %g1, 1, %g0
+
+ lduh [%o1 - 2], %g2
+ sub %o1, 2, %o1
+ sth %g2, [%o0 - 2]
+ sub %o0, 2, %o0
+1: be 1f
+ nop
+
+ ldub [%o1 - 1], %g2
+ stb %g2, [%o0 - 1]
+1: retl
+ ld [%sp + 64], %o0
+
+74: RMOVE_BIGALIGNCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
+ RMOVE_BIGALIGNCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
+ RMOVE_BIGALIGNCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
+ RMOVE_BIGALIGNCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
+ subcc %g7, 128, %g7
+ sub %o1, 128, %o1
+ bne 74b
+ sub %o0, 128, %o0
+
+ andcc %g1, 0x70, %g7
+ be 72b
+ andcc %g1, 8, %g0
+
+ srl %g7, 1, %o4
+ mov %o7, %g2
+ add %g7, %o4, %o4
+102: call 100f
+ sub %o1, %g7, %o1
+ mov %g2, %o7
+ jmpl %o5 + (72b - 102b), %g0
+ sub %o0, %g7, %o0
+
+75: and %o2, 0xe, %o3
+ mov %o7, %g2
+ sll %o3, 3, %o4
+ sub %o0, %o3, %o0
+103: call 100f
+ sub %o1, %o3, %o1
+ mov %g2, %o7
+ jmpl %o5 + (76f - 103b), %g0
+ andcc %o2, 1, %g0
+
+ RMOVE_SHORTCHUNK(o1, o0, 0x0c, g2, g3)
+ RMOVE_SHORTCHUNK(o1, o0, 0x0a, g2, g3)
+ RMOVE_SHORTCHUNK(o1, o0, 0x08, g2, g3)
+ RMOVE_SHORTCHUNK(o1, o0, 0x06, g2, g3)
+ RMOVE_SHORTCHUNK(o1, o0, 0x04, g2, g3)
+ RMOVE_SHORTCHUNK(o1, o0, 0x02, g2, g3)
+ RMOVE_SHORTCHUNK(o1, o0, 0x00, g2, g3)
+
+76: be 1f
+ nop
+ ldub [%o1 - 1], %g2
+ stb %g2, [%o0 - 1]
+1: retl
+ ld [%sp + 64], %o0
+
+91: bne 75b
+ andcc %o2, 8, %g0
+
+ be 1f
+ andcc %o2, 4, %g0
+
+ ld [%o1 - 0x08], %g2
+ ld [%o1 - 0x04], %g3
+ sub %o1, 8, %o1
+ st %g2, [%o0 - 0x08]
+ st %g3, [%o0 - 0x04]
+ sub %o0, 8, %o0
+1: b 73b
+ mov %o2, %g1
+
+77: cmp %o2, 15
+ bleu 75b
+ andcc %o0, 3, %g0
+ be 64f
+ andcc %o0, 1, %g0
+ be 63f
+ andcc %o0, 2, %g0
+ ldub [%o1 - 1], %g5
+ sub %o1, 1, %o1
+ stb %g5, [%o0 - 1]
+ sub %o0, 1, %o0
+ be 64f
+ sub %o2, 1, %o2
+
+63: ldub [%o1 - 1], %g5
+ sub %o1, 2, %o1
+ stb %g5, [%o0 - 1]
+ sub %o0, 2, %o0
+ ldub [%o1], %g5
+ sub %o2, 2, %o2
+ stb %g5, [%o0]
+64: and %o1, 3, %g2
+ and %o1, -4, %o1
+ and %o2, 0xc, %g3
+ add %o1, 4, %o1
+ cmp %g3, 4
+ sll %g2, 3, %g4
+ mov 32, %g2
+ be 4f
+ sub %g2, %g4, %g7
+
+ blu 3f
+ cmp %g3, 8
+
+ be 2f
+ srl %o2, 2, %g3
+
+ ld [%o1 - 4], %o3
+ add %o0, -8, %o0
+ ld [%o1 - 8], %o4
+ add %o1, -16, %o1
+ b 7f
+ add %g3, 1, %g3
+2: ld [%o1 - 4], %o4
+ add %o0, -4, %o0
+ ld [%o1 - 8], %g1
+ add %o1, -12, %o1
+ b 8f
+ add %g3, 2, %g3
+3: ld [%o1 - 4], %o5
+ add %o0, -12, %o0
+ ld [%o1 - 8], %o3
+ add %o1, -20, %o1
+ b 6f
+ srl %o2, 2, %g3
+4: ld [%o1 - 4], %g1
+ srl %o2, 2, %g3
+ ld [%o1 - 8], %o5
+ add %o1, -24, %o1
+ add %o0, -16, %o0
+ add %g3, -1, %g3
+
+ ld [%o1 + 12], %o3
+5: sll %o5, %g4, %g2
+ srl %g1, %g7, %g5
+ or %g2, %g5, %g2
+ st %g2, [%o0 + 12]
+6: ld [%o1 + 8], %o4
+ sll %o3, %g4, %g2
+ srl %o5, %g7, %g5
+ or %g2, %g5, %g2
+ st %g2, [%o0 + 8]
+7: ld [%o1 + 4], %g1
+ sll %o4, %g4, %g2
+ srl %o3, %g7, %g5
+ or %g2, %g5, %g2
+ st %g2, [%o0 + 4]
+8: ld [%o1], %o5
+ sll %g1, %g4, %g2
+ srl %o4, %g7, %g5
+ addcc %g3, -4, %g3
+ or %g2, %g5, %g2
+ add %o1, -16, %o1
+ st %g2, [%o0]
+ add %o0, -16, %o0
+ bne,a 5b
+ ld [%o1 + 12], %o3
+ sll %o5, %g4, %g2
+ srl %g1, %g7, %g5
+ srl %g4, 3, %g3
+ or %g2, %g5, %g2
+ add %o1, %g3, %o1
+ andcc %o2, 2, %g0
+ st %g2, [%o0 + 12]
+ be 1f
+ andcc %o2, 1, %g0
+
+ ldub [%o1 + 15], %g5
+ add %o1, -2, %o1
+ stb %g5, [%o0 + 11]
+ add %o0, -2, %o0
+ ldub [%o1 + 16], %g5
+ stb %g5, [%o0 + 12]
+1: be 1f
+ nop
+ ldub [%o1 + 15], %g5
+ stb %g5, [%o0 + 11]
+1: retl
+ ld [%sp + 64], %o0
+
+78: andcc %o1, 1, %g0
+ be 4f
+ andcc %o1, 2, %g0
+
+ ldub [%o1], %g2
+ add %o1, 1, %o1
+ stb %g2, [%o0]
+ sub %o2, 1, %o2
+ bne 3f
+ add %o0, 1, %o0
+4: lduh [%o1], %g2
+ add %o1, 2, %o1
+ sth %g2, [%o0]
+ sub %o2, 2, %o2
+ b 3f
+ add %o0, 2, %o0
+END(memmove)
+
+ENTRY(memcpy) /* %o0=dst %o1=src %o2=len */
+ sub %o0, %o1, %o4
+ st %o0, [%sp + 64]
+9: andcc %o4, 3, %o5
+0: bne 86f
+ cmp %o2, 15
+
+ bleu 90f
+ andcc %o1, 3, %g0
+
+ bne 78b
+3: andcc %o1, 4, %g0
+
+ be 2f
+ mov %o2, %g1
+
+ ld [%o1], %o4
+ sub %g1, 4, %g1
+ st %o4, [%o0]
+ add %o1, 4, %o1
+ add %o0, 4, %o0
+2: andcc %g1, 0xffffff80, %g7
+ be 3f
+ andcc %o0, 4, %g0
+
+ be 82f + 4
+5: MOVE_BIGCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
+ MOVE_BIGCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
+ MOVE_BIGCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
+ MOVE_BIGCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
+ subcc %g7, 128, %g7
+ add %o1, 128, %o1
+ bne 5b
+ add %o0, 128, %o0
+3: andcc %g1, 0x70, %g7
+ be 80f
+ andcc %g1, 8, %g0
+
+ srl %g7, 1, %o4
+ mov %o7, %g2
+ add %g7, %o4, %o4
+ add %o1, %g7, %o1
+104: call 100f
+ add %o0, %g7, %o0
+ jmpl %o5 + (80f - 104b), %g0
+ mov %g2, %o7
+
+79: MOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
+ MOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
+ MOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
+ MOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g4, g5)
+ MOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g4, g5)
+ MOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
+ MOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
+
+80: be 81f
+ andcc %g1, 4, %g0
+
+ ldd [%o1], %g2
+ add %o0, 8, %o0
+ st %g2, [%o0 - 0x08]
+ add %o1, 8, %o1
+ st %g3, [%o0 - 0x04]
+
+81: be 1f
+ andcc %g1, 2, %g0
+
+ ld [%o1], %g2
+ add %o1, 4, %o1
+ st %g2, [%o0]
+ add %o0, 4, %o0
+1: be 1f
+ andcc %g1, 1, %g0
+
+ lduh [%o1], %g2
+ add %o1, 2, %o1
+ sth %g2, [%o0]
+ add %o0, 2, %o0
+1: be 1f
+ nop
+
+ ldub [%o1], %g2
+ stb %g2, [%o0]
+1: retl
+ ld [%sp + 64], %o0
+
+82: /* ldd_std */
+ MOVE_BIGALIGNCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
+ MOVE_BIGALIGNCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
+ MOVE_BIGALIGNCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
+ MOVE_BIGALIGNCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
+ subcc %g7, 128, %g7
+ add %o1, 128, %o1
+ bne 82b
+ add %o0, 128, %o0
+
+ andcc %g1, 0x70, %g7
+ be 84f
+ andcc %g1, 8, %g0
+
+ mov %o7, %g2
+111: call 110f
+ add %o1, %g7, %o1
+ mov %g2, %o7
+ jmpl %o5 + (84f - 111b), %g0
+ add %o0, %g7, %o0
+
+83: MOVE_LASTALIGNCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
+ MOVE_LASTALIGNCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
+ MOVE_LASTALIGNCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
+ MOVE_LASTALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5)
+ MOVE_LASTALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5)
+ MOVE_LASTALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
+ MOVE_LASTALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
+
+84: be 85f
+ andcc %g1, 4, %g0
+
+ ldd [%o1], %g2
+ add %o0, 8, %o0
+ std %g2, [%o0 - 0x08]
+ add %o1, 8, %o1
+85: be 1f
+ andcc %g1, 2, %g0
+
+ ld [%o1], %g2
+ add %o1, 4, %o1
+ st %g2, [%o0]
+ add %o0, 4, %o0
+1: be 1f
+ andcc %g1, 1, %g0
+
+ lduh [%o1], %g2
+ add %o1, 2, %o1
+ sth %g2, [%o0]
+ add %o0, 2, %o0
+1: be 1f
+ nop
+
+ ldub [%o1], %g2
+ stb %g2, [%o0]
+1: retl
+ ld [%sp + 64], %o0
+
+86: cmp %o2, 6
+ bleu 88f
+
+ cmp %o2, 256
+ bcc 87f
+
+ andcc %o0, 3, %g0
+ be 61f
+ andcc %o0, 1, %g0
+ be 60f
+ andcc %o0, 2, %g0
+
+ ldub [%o1], %g5
+ add %o1, 1, %o1
+ stb %g5, [%o0]
+ sub %o2, 1, %o2
+ bne 61f
+ add %o0, 1, %o0
+60: ldub [%o1], %g3
+ add %o1, 2, %o1
+ stb %g3, [%o0]
+ sub %o2, 2, %o2
+ ldub [%o1 - 1], %g3
+ add %o0, 2, %o0
+ stb %g3, [%o0 - 1]
+61: and %o1, 3, %g2
+ and %o2, 0xc, %g3
+ and %o1, -4, %o1
+ cmp %g3, 4
+ sll %g2, 3, %g4
+ mov 32, %g2
+ be 4f
+ sub %g2, %g4, %g7
+
+ blu 3f
+ cmp %g3, 0x8
+
+ be 2f
+ srl %o2, 2, %g3
+
+ ld [%o1], %o3
+ add %o0, -8, %o0
+ ld [%o1 + 4], %o4
+ b 8f
+ add %g3, 1, %g3
+2: ld [%o1], %o4
+ add %o0, -12, %o0
+ ld [%o1 + 4], %o5
+ add %g3, 2, %g3
+ b 9f
+ add %o1, -4, %o1
+3: ld [%o1], %g1
+ add %o0, -4, %o0
+ ld [%o1 + 4], %o3
+ srl %o2, 2, %g3
+ b 7f
+ add %o1, 4, %o1
+4: ld [%o1], %o5
+ cmp %o2, 7
+ ld [%o1 + 4], %g1
+ srl %o2, 2, %g3
+ bleu 10f
+ add %o1, 8, %o1
+
+ ld [%o1], %o3
+ add %g3, -1, %g3
+5: sll %o5, %g4, %g2
+ srl %g1, %g7, %g5
+ or %g2, %g5, %g2
+ st %g2, [%o0]
+7: ld [%o1 + 4], %o4
+ sll %g1, %g4, %g2
+ srl %o3, %g7, %g5
+ or %g2, %g5, %g2
+ st %g2, [%o0 + 4]
+8: ld [%o1 + 8], %o5
+ sll %o3, %g4, %g2
+ srl %o4, %g7, %g5
+ or %g2, %g5, %g2
+ st %g2, [%o0 + 8]
+9: ld [%o1 + 12], %g1
+ sll %o4, %g4, %g2
+ srl %o5, %g7, %g5
+ addcc %g3, -4, %g3
+ or %g2, %g5, %g2
+ add %o1, 16, %o1
+ st %g2, [%o0 + 12]
+ add %o0, 16, %o0
+ bne,a 5b
+ ld [%o1], %o3
+10: sll %o5, %g4, %g2
+ srl %g1, %g7, %g5
+ srl %g7, 3, %g3
+ or %g2, %g5, %g2
+ sub %o1, %g3, %o1
+ andcc %o2, 2, %g0
+ st %g2, [%o0]
+ be 1f
+ andcc %o2, 1, %g0
+
+ ldub [%o1], %g2
+ add %o1, 2, %o1
+ stb %g2, [%o0 + 4]
+ add %o0, 2, %o0
+ ldub [%o1 - 1], %g2
+ stb %g2, [%o0 + 3]
+1: be 1f
+ nop
+ ldub [%o1], %g2
+ stb %g2, [%o0 + 4]
+1: retl
+ ld [%sp + 64], %o0
+
+87: andcc %o1, 3, %g0
+ be 3f
+ andcc %o1, 1, %g0
+
+ be 4f
+ andcc %o1, 2, %g0
+
+ ldub [%o1], %g2
+ add %o1, 1, %o1
+ stb %g2, [%o0]
+ sub %o2, 1, %o2
+ bne 3f
+ add %o0, 1, %o0
+4: lduh [%o1], %g2
+ add %o1, 2, %o1
+ srl %g2, 8, %g3
+ sub %o2, 2, %o2
+ stb %g3, [%o0]
+ add %o0, 2, %o0
+ stb %g2, [%o0 - 1]
+3: andcc %o1, 4, %g0
+
+ bne 2f
+ cmp %o5, 1
+
+ ld [%o1], %o4
+ srl %o4, 24, %g2
+ stb %g2, [%o0]
+ srl %o4, 16, %g3
+ stb %g3, [%o0 + 1]
+ srl %o4, 8, %g2
+ stb %g2, [%o0 + 2]
+ sub %o2, 4, %o2
+ stb %o4, [%o0 + 3]
+ add %o1, 4, %o1
+ add %o0, 4, %o0
+2: be 33f
+ cmp %o5, 2
+ be 32f
+ sub %o2, 4, %o2
+31: ld [%o1], %g2
+ add %o1, 4, %o1
+ srl %g2, 24, %g3
+ and %o0, 7, %g5
+ stb %g3, [%o0]
+ cmp %g5, 7
+ sll %g2, 8, %g1
+ add %o0, 4, %o0
+ be 41f
+ and %o2, 0xffffffc0, %o3
+ ld [%o0 - 7], %o4
+4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g7, g1, 8, 24, -3)
+ SMOVE_CHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g7, g1, 8, 24, -3)
+ SMOVE_CHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g7, g1, 8, 24, -3)
+ SMOVE_CHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g7, g1, 8, 24, -3)
+ subcc %o3, 64, %o3
+ add %o1, 64, %o1
+ bne 4b
+ add %o0, 64, %o0
+
+ andcc %o2, 0x30, %o3
+ be,a 1f
+ srl %g1, 16, %g2
+4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g7, g1, 8, 24, -3)
+ subcc %o3, 16, %o3
+ add %o1, 16, %o1
+ bne 4b
+ add %o0, 16, %o0
+
+ srl %g1, 16, %g2
+1: st %o4, [%o0 - 7]
+ sth %g2, [%o0 - 3]
+ srl %g1, 8, %g4
+ b 88f
+ stb %g4, [%o0 - 1]
+32: ld [%o1], %g2
+ add %o1, 4, %o1
+ srl %g2, 16, %g3
+ and %o0, 7, %g5
+ sth %g3, [%o0]
+ cmp %g5, 6
+ sll %g2, 16, %g1
+ add %o0, 4, %o0
+ be 42f
+ and %o2, 0xffffffc0, %o3
+ ld [%o0 - 6], %o4
+4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g7, g1, 16, 16, -2)
+ SMOVE_CHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g7, g1, 16, 16, -2)
+ SMOVE_CHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g7, g1, 16, 16, -2)
+ SMOVE_CHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g7, g1, 16, 16, -2)
+ subcc %o3, 64, %o3
+ add %o1, 64, %o1
+ bne 4b
+ add %o0, 64, %o0
+
+ andcc %o2, 0x30, %o3
+ be,a 1f
+ srl %g1, 16, %g2
+4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g7, g1, 16, 16, -2)
+ subcc %o3, 16, %o3
+ add %o1, 16, %o1
+ bne 4b
+ add %o0, 16, %o0
+
+ srl %g1, 16, %g2
+1: st %o4, [%o0 - 6]
+ b 88f
+ sth %g2, [%o0 - 2]
+33: ld [%o1], %g2
+ sub %o2, 4, %o2
+ srl %g2, 24, %g3
+ and %o0, 7, %g5
+ stb %g3, [%o0]
+ cmp %g5, 5
+ srl %g2, 8, %g4
+ sll %g2, 24, %g1
+ sth %g4, [%o0 + 1]
+ add %o1, 4, %o1
+ be 43f
+ and %o2, 0xffffffc0, %o3
+
+ ld [%o0 - 1], %o4
+ add %o0, 4, %o0
+4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g7, g1, 24, 8, -1)
+ SMOVE_CHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g7, g1, 24, 8, -1)
+ SMOVE_CHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g7, g1, 24, 8, -1)
+ SMOVE_CHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g7, g1, 24, 8, -1)
+ subcc %o3, 64, %o3
+ add %o1, 64, %o1
+ bne 4b
+ add %o0, 64, %o0
+
+ andcc %o2, 0x30, %o3
+ be,a 1f
+ srl %g1, 24, %g2
+4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g7, g1, 24, 8, -1)
+ subcc %o3, 16, %o3
+ add %o1, 16, %o1
+ bne 4b
+ add %o0, 16, %o0
+
+ srl %g1, 24, %g2
+1: st %o4, [%o0 - 5]
+ b 88f
+ stb %g2, [%o0 - 1]
+41: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g7, g1, 8, 24, -3)
+ SMOVE_ALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g7, g1, 8, 24, -3)
+ SMOVE_ALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g7, g1, 8, 24, -3)
+ SMOVE_ALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g7, g1, 8, 24, -3)
+ subcc %o3, 64, %o3
+ add %o1, 64, %o1
+ bne 41b
+ add %o0, 64, %o0
+
+ andcc %o2, 0x30, %o3
+ be,a 1f
+ srl %g1, 16, %g2
+4: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g7, g1, 8, 24, -3)
+ subcc %o3, 16, %o3
+ add %o1, 16, %o1
+ bne 4b
+ add %o0, 16, %o0
+
+ srl %g1, 16, %g2
+1: sth %g2, [%o0 - 3]
+ srl %g1, 8, %g4
+ b 88f
+ stb %g4, [%o0 - 1]
+43: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g7, g1, 24, 8, 3)
+ SMOVE_ALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g7, g1, 24, 8, 3)
+ SMOVE_ALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g7, g1, 24, 8, 3)
+ SMOVE_ALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g7, g1, 24, 8, 3)
+ subcc %o3, 64, %o3
+ add %o1, 64, %o1
+ bne 43b
+ add %o0, 64, %o0
+
+ andcc %o2, 0x30, %o3
+ be,a 1f
+ srl %g1, 24, %g2
+4: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g7, g1, 24, 8, 3)
+ subcc %o3, 16, %o3
+ add %o1, 16, %o1
+ bne 4b
+ add %o0, 16, %o0
+
+ srl %g1, 24, %g2
+1: stb %g2, [%o0 + 3]
+ b 88f
+ add %o0, 4, %o0
+42: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g7, g1, 16, 16, -2)
+ SMOVE_ALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g7, g1, 16, 16, -2)
+ SMOVE_ALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g7, g1, 16, 16, -2)
+ SMOVE_ALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g7, g1, 16, 16, -2)
+ subcc %o3, 64, %o3
+ add %o1, 64, %o1
+ bne 42b
+ add %o0, 64, %o0
+
+ andcc %o2, 0x30, %o3
+ be,a 1f
+ srl %g1, 16, %g2
+4: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g7, g1, 16, 16, -2)
+ subcc %o3, 16, %o3
+ add %o1, 16, %o1
+ bne 4b
+ add %o0, 16, %o0
+
+ srl %g1, 16, %g2
+1: sth %g2, [%o0 - 2]
+
+ /* Fall through */
+
+88: and %o2, 0xe, %o3
+ mov %o7, %g2
+ sll %o3, 3, %o4
+ add %o0, %o3, %o0
+106: call 100f
+ add %o1, %o3, %o1
+ mov %g2, %o7
+ jmpl %o5 + (89f - 106b), %g0
+ andcc %o2, 1, %g0
+
+ MOVE_SHORTCHUNK(o1, o0, 0x0c, g2, g3)
+ MOVE_SHORTCHUNK(o1, o0, 0x0a, g2, g3)
+ MOVE_SHORTCHUNK(o1, o0, 0x08, g2, g3)
+ MOVE_SHORTCHUNK(o1, o0, 0x06, g2, g3)
+ MOVE_SHORTCHUNK(o1, o0, 0x04, g2, g3)
+ MOVE_SHORTCHUNK(o1, o0, 0x02, g2, g3)
+ MOVE_SHORTCHUNK(o1, o0, 0x00, g2, g3)
+
+89: be 1f
+ nop
+
+ ldub [%o1], %g2
+ stb %g2, [%o0]
+1: retl
+ ld [%sp + 64], %o0
+
+90: bne 88b
+ andcc %o2, 8, %g0
+
+ be 1f
+ andcc %o2, 4, %g0
+
+ ld [%o1 + 0x00], %g2
+ ld [%o1 + 0x04], %g3
+ add %o1, 8, %o1
+ st %g2, [%o0 + 0x00]
+ st %g3, [%o0 + 0x04]
+ add %o0, 8, %o0
+1: b 81b
+ mov %o2, %g1
+
+100: retl
+ sub %o7, %o4, %o5
+110: retl
+ sub %o7, %g7, %o5
+END(memcpy)
diff --git a/sysdeps/sparc/sparc32/memmove.c b/sysdeps/sparc/sparc32/memmove.c
new file mode 100644
index 0000000000..a8d2d49948
--- /dev/null
+++ b/sysdeps/sparc/sparc32/memmove.c
@@ -0,0 +1 @@
+/* memmove is in memcpy.S */
diff --git a/sysdeps/sparc/sparc32/memset.S b/sysdeps/sparc/sparc32/memset.S
new file mode 100644
index 0000000000..65e3243b3a
--- /dev/null
+++ b/sysdeps/sparc/sparc32/memset.S
@@ -0,0 +1,154 @@
+/* Set a block of memory to some byte value.
+ For SPARC v7.
+ Copyright (C) 1996, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David S. Miller <davem@caip.rutgers.edu> and
+ Jakub Jelinek <jj@ultra.linux.cz>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+
+ /* Store 64 bytes at (BASE + OFFSET) using value SOURCE. */
+#define ZERO_BIG_BLOCK(base, offset, source) \
+ std source, [base + offset + 0x00]; \
+ std source, [base + offset + 0x08]; \
+ std source, [base + offset + 0x10]; \
+ std source, [base + offset + 0x18]; \
+ std source, [base + offset + 0x20]; \
+ std source, [base + offset + 0x28]; \
+ std source, [base + offset + 0x30]; \
+ std source, [base + offset + 0x38];
+
+#define ZERO_LAST_BLOCKS(base, offset, source) \
+ std source, [base - offset - 0x38]; \
+ std source, [base - offset - 0x30]; \
+ std source, [base - offset - 0x28]; \
+ std source, [base - offset - 0x20]; \
+ std source, [base - offset - 0x18]; \
+ std source, [base - offset - 0x10]; \
+ std source, [base - offset - 0x08]; \
+ std source, [base - offset - 0x00];
+
+ .text
+ .align 4
+ENTRY(__bzero)
+ b 1f
+ mov %g0, %g3
+
+3: cmp %o2, 3
+ be 2f
+ stb %g3, [%o0]
+
+ cmp %o2, 2
+ be 2f
+ stb %g3, [%o0 + 0x01]
+
+ stb %g3, [%o0 + 0x02]
+2: sub %o2, 4, %o2
+ add %o1, %o2, %o1
+ b 4f
+ sub %o0, %o2, %o0
+END(__bzero)
+
+ENTRY(memset)
+ and %o1, 0xff, %g3
+ sll %g3, 8, %g2
+ or %g3, %g2, %g3
+ sll %g3, 16, %g2
+ or %g3, %g2, %g3
+ orcc %o2, %g0, %o1
+1: cmp %o1, 7
+ bleu 7f
+ mov %o0, %g1
+
+ andcc %o0, 3, %o2
+ bne 3b
+4: andcc %o0, 4, %g0
+
+ be 2f
+ mov %g3, %g2
+
+ st %g3, [%o0]
+ sub %o1, 4, %o1
+ add %o0, 4, %o0
+2: andcc %o1, 0xffffff80, %o3
+ be 9f
+ andcc %o1, 0x78, %o2
+4: ZERO_BIG_BLOCK (%o0, 0x00, %g2)
+ subcc %o3, 128, %o3
+ ZERO_BIG_BLOCK (%o0, 0x40, %g2)
+ bne 4b
+ add %o0, 128, %o0
+
+ orcc %o2, %g0, %g0
+9: be 6f
+ andcc %o1, 7, %o1
+
+ mov %o7, %g4
+101: call 100f
+ srl %o2, 1, %o3
+ mov %g4, %o7
+ jmpl %o4 + (20f + 64 - 101b), %g0
+ add %o0, %o2, %o0
+
+100: retl
+ sub %o7, %o3, %o4
+
+20: ZERO_LAST_BLOCKS(%o0, 0x48, %g2)
+ ZERO_LAST_BLOCKS(%o0, 0x08, %g2)
+
+6: be 8f
+ andcc %o1, 4, %g0
+ be 1f
+ andcc %o1, 2, %g0
+ st %g3, [%o0]
+ add %o0, 4, %o0
+1: be 1f
+ andcc %o1, 1, %g0
+ sth %g3, [%o0]
+ add %o0, 2, %o0
+1: bne,a 8f
+ stb %g3, [%o0]
+8: retl
+ mov %g1, %o0
+7: orcc %o1, 0, %g0
+ be 0f
+ subcc %o1, 1, %o1
+ stb %g3, [%o0]
+ be 0f
+ subcc %o1, 1, %o1
+ stb %g3, [%o0 + 1]
+ be 0f
+ subcc %o1, 1, %o1
+ stb %g3, [%o0 + 2]
+ be 0f
+ subcc %o1, 1, %o1
+ stb %g3, [%o0 + 3]
+ be 0f
+ subcc %o1, 1, %o1
+ stb %g3, [%o0 + 4]
+ be 0f
+ subcc %o1, 1, %o1
+ stb %g3, [%o0 + 5]
+ be 0f
+ subcc %o1, 1, %o1
+ stb %g3, [%o0 + 6]
+0: retl
+ nop
+END(memset)
+
+weak_alias(__bzero, bzero)
diff --git a/sysdeps/sparc/sparc32/sparcv8/Makefile b/sysdeps/sparc/sparc32/sparcv8/Makefile
new file mode 100644
index 0000000000..02139eceb0
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv8/Makefile
@@ -0,0 +1 @@
+CFLAGS += -mv8
diff --git a/sysdeps/sparc/sparc32/sparcv8/rem.S b/sysdeps/sparc/sparc32/sparcv8/rem.S
index 061e80093c..a2694e699e 100644
--- a/sysdeps/sparc/sparc32/sparcv8/rem.S
+++ b/sysdeps/sparc/sparc32/sparcv8/rem.S
@@ -8,6 +8,9 @@ ENTRY(.rem)
sra %o0, 31, %o2
wr %o2, 0, %y
+ nop
+ nop
+ nop
sdivcc %o0, %o1, %o2
bvs,a 1f
xnor %o2, %g0, %o2
diff --git a/sysdeps/sparc/sparc32/sparcv8/sdiv.S b/sysdeps/sparc/sparc32/sparcv8/sdiv.S
index 81c3ac1c97..bfc4acf2fa 100644
--- a/sysdeps/sparc/sparc32/sparcv8/sdiv.S
+++ b/sysdeps/sparc/sparc32/sparcv8/sdiv.S
@@ -8,7 +8,13 @@ ENTRY(.div)
sra %o0, 31, %o2
wr %o2, 0, %y
- ret
- sdiv %o0, %o1, %o0
+ nop
+ nop
+ nop
+ sdivcc %o0, %o1, %o0
+ bvs,a 1f
+ xnor %o0, %g0, %o0
+1: retl
+ nop
END(.div)
diff --git a/sysdeps/sparc/sparc32/sparcv8/udiv.S b/sysdeps/sparc/sparc32/sparcv8/udiv.S
index 4e3cddc63f..d71954351e 100644
--- a/sysdeps/sparc/sparc32/sparcv8/udiv.S
+++ b/sysdeps/sparc/sparc32/sparcv8/udiv.S
@@ -7,6 +7,8 @@
ENTRY(.udiv)
wr %g0, 0, %y
+ nop
+ nop
retl
udiv %o0, %o1, %o0
diff --git a/sysdeps/sparc/sparc32/sparcv8/urem.S b/sysdeps/sparc/sparc32/sparcv8/urem.S
index 81e123f3da..cc2689d514 100644
--- a/sysdeps/sparc/sparc32/sparcv8/urem.S
+++ b/sysdeps/sparc/sparc32/sparcv8/urem.S
@@ -7,6 +7,9 @@
ENTRY(.urem)
wr %g0, 0, %y
+ nop
+ nop
+ nop
udiv %o0, %o1, %o2
umul %o2, %o1, %o2
retl
diff --git a/sysdeps/sparc/sparc32/sparcv9/Makefile b/sysdeps/sparc/sparc32/sparcv9/Makefile
new file mode 100644
index 0000000000..00675fd671
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/Makefile
@@ -0,0 +1 @@
+CFLAGS += -mv8 -mtune=ultrasparc
diff --git a/sysdeps/sparc/sparc32/sparcv9/bcopy.c b/sysdeps/sparc/sparc32/sparcv9/bcopy.c
new file mode 100644
index 0000000000..9a455f33c4
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/bcopy.c
@@ -0,0 +1 @@
+/* bcopy is in memcpy.S */
diff --git a/sysdeps/sparc/sparc32/sparcv9/bzero.c b/sysdeps/sparc/sparc32/sparcv9/bzero.c
new file mode 100644
index 0000000000..37f0f6f993
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/bzero.c
@@ -0,0 +1 @@
+/* bzero is in memset.S */
diff --git a/sysdeps/sparc/sparc32/sparcv9/dotmul.S b/sysdeps/sparc/sparc32/sparcv9/dotmul.S
new file mode 100644
index 0000000000..811cf1e89e
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/dotmul.S
@@ -0,0 +1,17 @@
+/*
+ * Sparc v9 has multiply.
+ */
+
+#include <sysdep.h>
+
+ .text
+ .align 32
+ENTRY(.mul)
+
+ sra %o0, 0, %o0
+ sra %o1, 0, %o1
+ mulx %o0, %o1, %o0
+ retl
+ srax %o0, 32, %o1
+
+END(.mul)
diff --git a/sysdeps/sparc/sparc32/sparcv9/memchr.S b/sysdeps/sparc/sparc32/sparcv9/memchr.S
new file mode 100644
index 0000000000..c5dfbef184
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/memchr.S
@@ -0,0 +1,4 @@
+#define ASI_PNF 0x82
+#define ASI_BLK_P 0xf0
+#define XCC icc
+#include <sparc64/memchr.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/memcmp.S b/sysdeps/sparc/sparc32/sparcv9/memcmp.S
new file mode 100644
index 0000000000..44878f4486
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/memcmp.S
@@ -0,0 +1,4 @@
+#define ASI_PNF 0x82
+#define ASI_BLK_P 0xf0
+#define XCC icc
+#include <sparc64/memcmp.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/memcpy.S b/sysdeps/sparc/sparc32/sparcv9/memcpy.S
new file mode 100644
index 0000000000..675ec496b9
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/memcpy.S
@@ -0,0 +1,4 @@
+#define ASI_PNF 0x82
+#define ASI_BLK_P 0xf0
+#define XCC icc
+#include <sparc64/memcpy.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/memset.S b/sysdeps/sparc/sparc32/sparcv9/memset.S
new file mode 100644
index 0000000000..ac67b7ab7c
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/memset.S
@@ -0,0 +1,4 @@
+#define ASI_PNF 0x82
+#define ASI_BLK_P 0xf0
+#define XCC icc
+#include <sparc64/memset.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/rem.S b/sysdeps/sparc/sparc32/sparcv9/rem.S
new file mode 100644
index 0000000000..5385bd8305
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/rem.S
@@ -0,0 +1,22 @@
+/*
+ * Sparc v9 has divide.
+ * As divx takes 68 cycles and sdivcc only 36,
+ * we use sdivcc eventhough it is deprecated.
+ */
+
+#include <sysdep.h>
+
+ .text
+ .align 32
+ENTRY(.rem)
+
+ sra %o0, 31, %o2
+ wr %o2, 0, %y
+ sdivcc %o0, %o1, %o2
+ xnor %o2, %g0, %o3
+ movvs %icc, %o3, %o2
+ smul %o2, %o1, %o2
+ retl
+ sub %o0, %o2, %o0
+
+END(.rem)
diff --git a/sysdeps/sparc/sparc32/sparcv9/sdiv.S b/sysdeps/sparc/sparc32/sparcv9/sdiv.S
new file mode 100644
index 0000000000..d765514cea
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/sdiv.S
@@ -0,0 +1,20 @@
+/*
+ * Sparc v9 has divide.
+ * As divx takes 68 cycles and sdivcc only 36,
+ * we use sdivcc eventhough it is deprecated.
+ */
+
+#include <sysdep.h>
+
+ .text
+ .align 32
+ENTRY(.div)
+
+ sra %o0, 31, %o2
+ wr %o2, 0, %y
+ sdivcc %o0, %o1, %o0
+ xnor %o0, %g0, %o2
+ retl
+ movvs %icc, %o2, %o0
+
+END(.div)
diff --git a/sysdeps/sparc/sparc32/sparcv9/stpcpy.S b/sysdeps/sparc/sparc32/sparcv9/stpcpy.S
new file mode 100644
index 0000000000..440ad7e215
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/stpcpy.S
@@ -0,0 +1,4 @@
+#define ASI_PNF 0x82
+#define ASI_BLK_P 0xf0
+#define XCC icc
+#include <sparc64/stpcpy.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/stpncpy.S b/sysdeps/sparc/sparc32/sparcv9/stpncpy.S
new file mode 100644
index 0000000000..124136a0b2
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/stpncpy.S
@@ -0,0 +1,4 @@
+#define ASI_PNF 0x82
+#define ASI_BLK_P 0xf0
+#define XCC icc
+#include <sparc64/stpncpy.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/strcat.S b/sysdeps/sparc/sparc32/sparcv9/strcat.S
new file mode 100644
index 0000000000..7a22235703
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/strcat.S
@@ -0,0 +1,4 @@
+#define ASI_PNF 0x82
+#define ASI_BLK_P 0xf0
+#define XCC icc
+#include <sparc64/strcat.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/strchr.S b/sysdeps/sparc/sparc32/sparcv9/strchr.S
new file mode 100644
index 0000000000..ddd32120d4
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/strchr.S
@@ -0,0 +1,4 @@
+#define ASI_PNF 0x82
+#define ASI_BLK_P 0xf0
+#define XCC icc
+#include <sparc64/strchr.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/strcmp.S b/sysdeps/sparc/sparc32/sparcv9/strcmp.S
new file mode 100644
index 0000000000..5330f4359b
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/strcmp.S
@@ -0,0 +1,4 @@
+#define ASI_PNF 0x82
+#define ASI_BLK_P 0xf0
+#define XCC icc
+#include <sparc64/strcmp.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/strcpy.S b/sysdeps/sparc/sparc32/sparcv9/strcpy.S
new file mode 100644
index 0000000000..0b35c9be08
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/strcpy.S
@@ -0,0 +1,4 @@
+#define ASI_PNF 0x82
+#define ASI_BLK_P 0xf0
+#define XCC icc
+#include <sparc64/strcpy.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/strcspn.S b/sysdeps/sparc/sparc32/sparcv9/strcspn.S
new file mode 100644
index 0000000000..f9d6beabe4
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/strcspn.S
@@ -0,0 +1,4 @@
+#define ASI_PNF 0x82
+#define ASI_BLK_P 0xf0
+#define XCC icc
+#include <sparc64/strcspn.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/strlen.S b/sysdeps/sparc/sparc32/sparcv9/strlen.S
new file mode 100644
index 0000000000..b8f4dba4f4
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/strlen.S
@@ -0,0 +1,4 @@
+#define ASI_PNF 0x82
+#define ASI_BLK_P 0xf0
+#define XCC icc
+#include <sparc64/strlen.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/strncmp.S b/sysdeps/sparc/sparc32/sparcv9/strncmp.S
new file mode 100644
index 0000000000..addd89e05b
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/strncmp.S
@@ -0,0 +1,4 @@
+#define ASI_PNF 0x82
+#define ASI_BLK_P 0xf0
+#define XCC icc
+#include <sparc64/strncmp.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/strncpy.S b/sysdeps/sparc/sparc32/sparcv9/strncpy.S
new file mode 100644
index 0000000000..688f9dfd65
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/strncpy.S
@@ -0,0 +1,4 @@
+#define ASI_PNF 0x82
+#define ASI_BLK_P 0xf0
+#define XCC icc
+#include <sparc64/strncpy.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/strpbrk.S b/sysdeps/sparc/sparc32/sparcv9/strpbrk.S
new file mode 100644
index 0000000000..62294c0af4
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/strpbrk.S
@@ -0,0 +1,4 @@
+#define ASI_PNF 0x82
+#define ASI_BLK_P 0xf0
+#define XCC icc
+#include <sparc64/strpbrk.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/strrchr.c b/sysdeps/sparc/sparc32/sparcv9/strrchr.c
new file mode 100644
index 0000000000..ec608d6ab3
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/strrchr.c
@@ -0,0 +1 @@
+/* strrchr is in strchr.S */
diff --git a/sysdeps/sparc/sparc32/sparcv9/strspn.S b/sysdeps/sparc/sparc32/sparcv9/strspn.S
new file mode 100644
index 0000000000..291e798085
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/strspn.S
@@ -0,0 +1,4 @@
+#define ASI_PNF 0x82
+#define ASI_BLK_P 0xf0
+#define XCC icc
+#include <sparc64/strspn.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/udiv.S b/sysdeps/sparc/sparc32/sparcv9/udiv.S
new file mode 100644
index 0000000000..de79899756
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/udiv.S
@@ -0,0 +1,17 @@
+/*
+ * Sparc v9 has divide.
+ * As divx takes 68 cycles and udiv only 37,
+ * we use udiv eventhough it is deprecated.
+ */
+
+#include <sysdep.h>
+
+ .text
+ .align 32
+ENTRY(.udiv)
+
+ wr %g0, 0, %y
+ retl
+ udiv %o0, %o1, %o0
+
+END(.udiv)
diff --git a/sysdeps/sparc/sparc32/sparcv9/umul.S b/sysdeps/sparc/sparc32/sparcv9/umul.S
new file mode 100644
index 0000000000..608b72aca1
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/umul.S
@@ -0,0 +1,17 @@
+/*
+ * Sparc v9 has multiply.
+ */
+
+#include <sysdep.h>
+
+ .text
+ .align 32
+ENTRY(.umul)
+
+ srl %o0, 0, %o0
+ srl %o1, 0, %o1
+ mulx %o0, %o1, %o0
+ retl
+ srlx %o0, 32, %o1
+
+END(.umul)
diff --git a/sysdeps/sparc/sparc32/sparcv9/urem.S b/sysdeps/sparc/sparc32/sparcv9/urem.S
new file mode 100644
index 0000000000..cab16c9193
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/urem.S
@@ -0,0 +1,19 @@
+/*
+ * Sparc v9 has divide.
+ * As divx takes 68 cycles and udiv only 37,
+ * we use udiv eventhough it is deprecated.
+ */
+
+#include <sysdep.h>
+
+ .text
+ .align 32
+ENTRY(.urem)
+
+ wr %g0, 0, %y
+ udiv %o0, %o1, %o2
+ umul %o2, %o1, %o2
+ retl
+ sub %o0, %o2, %o0
+
+END(.urem)
diff --git a/sysdeps/sparc/sparc32/stpcpy.S b/sysdeps/sparc/sparc32/stpcpy.S
new file mode 100644
index 0000000000..9d496dd8a9
--- /dev/null
+++ b/sysdeps/sparc/sparc32/stpcpy.S
@@ -0,0 +1,163 @@
+/* Copy SRC to DEST returning the address of the terminating '\0' in DEST.
+ For SPARC v7.
+ Copyright (C) 1996, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jj@ultra.linux.cz>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+
+ /* Normally, this uses ((xword - 0x01010101) & 0x80808080) test
+ to find out if any byte in xword could be zero. This is fast, but
+ also gives false alarm for any byte in range 0x81-0xff. It does
+ not matter for correctness, as if this test tells us there could
+ be some zero byte, we check it byte by byte, but if bytes with
+ high bits set are common in the strings, then this will give poor
+ performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
+ will use one tick slower, but more precise test
+ ((xword - 0x01010101) & (~xword) & 0x80808080),
+ which does not give any false alarms (but if some bits are set,
+ one cannot assume from it which bytes are zero and which are not).
+ It is yet to be measured, what is the correct default for glibc
+ in these days for an average user.
+ */
+
+ .text
+ .align 4
+10: ldub [%o1], %o5
+ stb %o5, [%o0]
+ cmp %o5, 0
+ add %o0, 1, %o0
+ be 1f
+ add %o1, 1, %o1
+ andcc %o1, 3, %g0
+ be 4f
+ or %o4, %lo(0x80808080), %o3
+ ldub [%o1], %o5
+ stb %o5, [%o0]
+ cmp %o5, 0
+ add %o0, 1, %o0
+ be 1f
+ add %o1, 1, %o1
+ andcc %o1, 3, %g0
+ be 5f
+ sethi %hi(0x01010101), %o4
+ ldub [%o1], %o5
+ stb %o5, [%o0]
+ cmp %o5, 0
+ add %o0, 1, %o0
+ be 1f
+ add %o1, 1, %o1
+ b 6f
+ or %o4, %lo(0x01010101), %o2
+1: retl
+ add %o0, -1, %o0
+
+ENTRY(__stpcpy)
+ andcc %o1, 3, %g0
+ bne 10b
+ sethi %hi(0x80808080), %o4
+ or %o4, %lo(0x80808080), %o3
+4: sethi %hi(0x01010101), %o4
+5: or %o4, %lo(0x01010101), %o2
+6: andcc %o0, 3, %g0
+ bne 16f
+ sub %g0, 4, %g1
+
+11: add %g1, 4, %g1
+ ld [%o1 + %g1], %o5
+ sub %o5, %o2, %o4
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o4, %o5, %o4
+#endif
+ andcc %o4, %o3, %g0
+ be,a 11b
+ st %o5, [%o0 + %g1]
+
+ /* Check every byte. */
+ srl %o5, 24, %g5
+ andcc %g5, 0xff, %g0
+ be 14f
+ srl %o5, 16, %g5
+ andcc %g5, 0xff, %g0
+ be 13f
+ srl %o5, 8, %g5
+ andcc %g5, 0xff, %g0
+ be 12f
+ andcc %o5, 0xff, %g0
+ bne 11b
+ st %o5, [%o0 + %g1]
+ add %o0, %g1, %o0
+ retl
+ add %o0, 3, %o0
+12: srl %o5, 16, %o5
+ sth %o5, [%o0 + %g1]
+ add %g1, 2, %g1
+ stb %g0, [%o0 + %g1]
+ retl
+ add %o0, %g1, %o0
+13: srl %o5, 16, %o5
+ sth %o5, [%o0 + %g1]
+ add %g1, 1, %g1
+ retl
+ add %o0, %g1, %o0
+14: stb %g0, [%o0 + %g1]
+ retl
+ add %o0, %g1, %o0
+
+15: srl %o5, 24, %o4
+ srl %o5, 16, %g1
+ stb %o4, [%o0]
+ srl %o5, 8, %g4
+ stb %g1, [%o0 + 1]
+ stb %g4, [%o0 + 2]
+ stb %o5, [%o0 + 3]
+ add %o0, 4, %o0
+16: ld [%o1], %o5
+ sub %o5, %o2, %o4
+ andcc %o4, %o3, %g0
+ be 15b
+ add %o1, 4, %o1
+
+ /* Check every byte. */
+ srl %o5, 24, %g5
+ andcc %g5, 0xff, %g4
+ be 19f
+ stb %g4, [%o0]
+ srl %o5, 16, %g5
+ andcc %g5, 0xff, %g4
+ be 18f
+ stb %g4, [%o0 + 1]
+ srl %o5, 8, %g5
+ andcc %g5, 0xff, %g4
+ be 17f
+ stb %g4, [%o0 + 2]
+ andcc %o5, 0xff, %g4
+ stb %g4, [%o0 + 3]
+ bne 16b
+ add %o0, 4, %o0
+ retl
+ sub %o0, 1, %o0
+17: retl
+ add %o0, 2, %o0
+18: retl
+ add %o0, 1, %o0
+19: retl
+ nop
+END(__stpcpy)
+
+weak_alias(__stpcpy, stpcpy)
diff --git a/sysdeps/sparc/sparc32/strcat.S b/sysdeps/sparc/sparc32/strcat.S
new file mode 100644
index 0000000000..d901087672
--- /dev/null
+++ b/sysdeps/sparc/sparc32/strcat.S
@@ -0,0 +1,348 @@
+/* strcat (dest, src) -- Append SRC on the end of DEST.
+ For SPARC v7.
+ Copyright (C) 1996, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jj@ultra.linux.cz>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+
+ /* Normally, this uses ((xword - 0x01010101) & 0x80808080) test
+ to find out if any byte in xword could be zero. This is fast, but
+ also gives false alarm for any byte in range 0x81-0xff. It does
+ not matter for correctness, as if this test tells us there could
+ be some zero byte, we check it byte by byte, but if bytes with
+ high bits set are common in the strings, then this will give poor
+ performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
+ will use one tick slower, but more precise test
+ ((xword - 0x01010101) & (~xword) & 0x80808080),
+ which does not give any false alarms (but if some bits are set,
+ one cannot assume from it which bytes are zero and which are not).
+ It is yet to be measured, what is the correct default for glibc
+ in these days for an average user.
+ */
+
+ .text
+ .align 4
+10: cmp %o4, 2
+ be 1f
+ cmp %o4, 3
+ ldub [%o1], %o5
+ add %o1, 1, %o1
+ stb %o5, [%o0]
+ be 3f
+ cmp %o5, 0
+ be 0f
+ add %o0, 1, %o0
+1: lduh [%o1], %o5
+ add %o1, 2, %o1
+ srl %o5, 8, %o4
+ cmp %o4, 0
+ stb %o4, [%o0]
+ bne,a 2f
+ stb %o5, [%o0 + 1]
+ retl
+ mov %g2, %o0
+2: andcc %o5, 0xff, %o5
+ bne 4f
+ add %o0, 2, %o0
+ retl
+ mov %g2, %o0
+3: bne 4f
+ add %o0, 1, %o0
+ retl
+ mov %g2, %o0
+
+11: ldub [%o0], %o5
+ cmp %o5, 0
+ be 1f
+ add %o0, 1, %o0
+ andcc %o0, 3, %g0
+ be 7f
+ or %o4, %lo(0x80808080), %o3
+ ldub [%o0], %o5
+ cmp %o5, 0
+ be 2f
+ add %o0, 1, %o0
+ andcc %o0, 3, %g0
+ be 8f
+ sethi %hi(0x01010101), %o4
+ ldub [%o0], %o5
+ cmp %o5, 0
+ be 3f
+ add %o0, 1, %o0
+ b 9f
+ or %o4, %lo(0x01010101), %o2
+1: or %o4, %lo(0x80808080), %o3
+2: sethi %hi(0x01010101), %o4
+3: or %o4, %lo(0x01010101), %o2
+ b 3f
+ sub %o0, 1, %o0
+
+ENTRY(strcat)
+ mov %o0, %g2
+ andcc %o0, 3, %g0
+ bne 11b
+ sethi %hi(0x80808080), %o4
+ or %o4, %lo(0x80808080), %o3
+7: sethi %hi(0x01010101), %o4
+8: or %o4, %lo(0x01010101), %o2
+9: ld [%o0], %o5
+7: sub %o5, %o2, %o4
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o4, %o5, %o4
+#endif
+ andcc %o4, %o3, %g0
+ be 9b
+ add %o0, 4, %o0
+
+ srl %o5, 24, %g5
+ andcc %g5, 0xff, %g0
+ be 3f
+ add %o0, -4, %o0
+ srl %o5, 16, %g5
+ andcc %g5, 0xff, %g0
+ be 3f
+ add %o0, 1, %o0
+ srl %o5, 8, %g5
+ andcc %g5, 0xff, %g0
+ be 3f
+ add %o0, 1, %o0
+ andcc %o5, 0xff, %g0
+ add %o0, 2, %o0
+ bne,a 7b
+ ld [%o0], %o5
+ sub %o0, 1, %o0
+3: andcc %o1, 3, %o4
+ bne 10b
+4: andcc %o0, 3, %g3
+ bne 12f
+1: ld [%o1], %o5
+ add %o1, 4, %o1
+ sub %o5, %o2, %o4
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o4, %o5, %o4
+#endif
+ add %o0, 4, %o0
+ andcc %o4, %o3, %g0
+ be,a 1b
+ st %o5, [%o0 - 4]
+
+ srl %o5, 24, %g5
+ andcc %g5, 0xff, %g0
+ be 1f
+ srl %o5, 16, %g5
+ andcc %g5, 0xff, %g0
+ be 2f
+ srl %o5, 8, %g5
+ andcc %g5, 0xff, %g0
+ be 3f
+ andcc %o5, 0xff, %g0
+ bne 1b
+ st %o5, [%o0 - 4]
+ retl
+ mov %g2, %o0
+3: srl %o5, 16, %o5
+ sth %o5, [%o0 - 4]
+ stb %g0, [%o0 - 2]
+ retl
+ mov %g2, %o0
+2: srl %o5, 16, %o5
+ sth %o5, [%o0 - 4]
+ retl
+ mov %g2, %o0
+1: stb %g0, [%o0 - 4]
+ retl
+ mov %g2, %o0
+
+12: add %o1, 4, %o1
+ sub %o5, %o2, %o4
+ cmp %g3, 2
+ be 2f
+ cmp %g3, 3
+ be 3f
+ andcc %o4, %o3, %g0
+ bne 5f
+ srl %o5, 24, %g5
+ stb %g5, [%o0]
+ sub %o0, 1, %o0
+ srl %o5, 8, %g5
+ sth %g5, [%o0 + 2]
+1: add %o0, 4, %o0
+4: sll %o5, 24, %g6
+ ld [%o1], %o5
+ add %o1, 4, %o1
+ srl %o5, 8, %g5
+ sub %o5, %o2, %o4
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o4, %o5, %o4
+#endif
+ or %g5, %g6, %g5
+ andcc %o4, %o3, %g0
+ be,a 1b
+ st %g5, [%o0]
+ srl %o5, 24, %o4
+ andcc %o4, 0xff, %g0
+ be 6f
+ srl %o5, 16, %o4
+ andcc %o4, 0xff, %g0
+ be 7f
+ srl %o5, 8, %o4
+ st %g5, [%o0]
+ andcc %o4, 0xff, %g0
+ be 0f
+ andcc %o5, 0xff, %g0
+1: bne 4b
+ add %o0, 4, %o0
+9: stb %g0, [%o0]
+0: retl
+ mov %g2, %o0
+
+6: srl %g5, 16, %g5
+ sth %g5, [%o0]
+ retl
+ mov %g2, %o0
+
+7: srl %g5, 16, %g5
+ sth %g5, [%o0]
+ stb %g0, [%o0 + 2]
+ retl
+ mov %g2, %o0
+
+5: andcc %g5, 0xff, %g4
+ be 9b
+ srl %o5, 16, %g5
+ andcc %g5, 0xff, %g0
+ be 7f
+ srl %o5, 8, %g5
+ andcc %g5, 0xff, %g0
+ stb %g4, [%o0]
+ sth %g5, [%o0 + 1]
+ sub %o0, 1, %o0
+ bne 1b
+ andcc %o5, 0xff, %g0
+ retl
+ mov %g2, %o0
+
+7: stb %g4, [%o0]
+ stb %g0, [%o0 + 1]
+ retl
+ mov %g2, %o0
+
+2: andcc %o4, %o3, %g0
+ bne 5f
+ srl %o5, 16, %g5
+ sth %g5, [%o0]
+ sub %o0, 2, %o0
+1: add %o0, 4, %o0
+4: sll %o5, 16, %g6
+ ld [%o1], %o5
+ add %o1, 4, %o1
+ srl %o5, 16, %g5
+ sub %o5, %o2, %o4
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o4, %o5, %o4
+#endif
+ or %g5, %g6, %g5
+ andcc %o4, %o3, %g0
+ be,a 1b
+ st %g5, [%o0]
+ srl %o5, 24, %o4
+ andcc %o4, 0xff, %g0
+ be 7f
+ srl %o5, 16, %o4
+ st %g5, [%o0]
+ andcc %o4, 0xff, %g0
+ be 0b
+ srl %o5, 8, %o4
+1: andcc %o4, 0xff, %g0
+ be 8f
+ andcc %o5, 0xff, %g0
+ bne 4b
+ add %o0, 4, %o0
+ sth %o5, [%o0]
+ retl
+ mov %g2, %o0
+
+7: srl %g5, 16, %g5
+ sth %g5, [%o0]
+ stb %g0, [%o0 + 2]
+ retl
+ mov %g2, %o0
+
+8: stb %g0, [%o0 + 4]
+ retl
+ mov %g2, %o0
+
+5: srl %o5, 24, %g5
+ andcc %g5, 0xff, %g0
+ be 9b
+ srl %o5, 16, %g5
+ andcc %g5, 0xff, %g0
+ sth %g5, [%o0]
+ sub %o0, 2, %o0
+ bne 1b
+ srl %o5, 8, %o4
+ retl
+ mov %g2, %o0
+
+3: bne 5f
+ srl %o5, 24, %g5
+ stb %g5, [%o0]
+ sub %o0, 3, %o0
+1: add %o0, 4, %o0
+4: sll %o5, 8, %g6
+ ld [%o1], %o5
+ add %o1, 4, %o1
+ srl %o5, 24, %g5
+ sub %o5, %o2, %o4
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o4, %o5, %o4
+#endif
+ or %g5, %g6, %g5
+ andcc %o4, %o3, %g0
+ be 1b
+ st %g5, [%o0]
+ srl %o5, 24, %o4
+ andcc %o4, 0xff, %g0
+ be 0b
+ srl %o5, 16, %o4
+1: andcc %o4, 0xff, %g0
+ be 8b
+ srl %o5, 8, %o4
+ andcc %o4, 0xff, %g0
+ be 9f
+ andcc %o5, 0xff, %g0
+ bne 4b
+ add %o0, 4, %o0
+ srl %o5, 8, %o5
+ sth %o5, [%o0]
+ stb %g0, [%o0 + 2]
+ retl
+ mov %g2, %o0
+9: srl %o5, 8, %o5
+ sth %o5, [%o0 + 4]
+ retl
+ mov %g2, %o0
+5: andcc %g5, 0xff, %g0
+ stb %g5, [%o0]
+ sub %o0, 3, %o0
+ bne 1b
+ srl %o5, 16, %o4
+ retl
+ mov %g2, %o0
+END(strcat)
diff --git a/sysdeps/sparc/sparc32/strchr.S b/sysdeps/sparc/sparc32/strchr.S
new file mode 100644
index 0000000000..d1a70ad7ff
--- /dev/null
+++ b/sysdeps/sparc/sparc32/strchr.S
@@ -0,0 +1,282 @@
+/* strchr (str, ch) -- Return pointer to first occurrence of CH in STR.
+ For SPARC v7.
+ Copyright (C) 1996, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jj@ultra.linux.cz> and
+ David S. Miller <davem@caip.rutgers.edu>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+
+ /* Normally, this uses ((xword - 0x01010101) & 0x80808080) test
+ to find out if any byte in xword could be zero. This is fast, but
+ also gives false alarm for any byte in range 0x81-0xff. It does
+ not matter for correctness, as if this test tells us there could
+ be some zero byte, we check it byte by byte, but if bytes with
+ high bits set are common in the strings, then this will give poor
+ performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
+ will use one tick slower, but more precise test
+ ((xword - 0x01010101) & (~xword) & 0x80808080),
+ which does not give any false alarms (but if some bits are set,
+ one cannot assume from it which bytes are zero and which are not).
+ It is yet to be measured, what is the correct default for glibc
+ in these days for an average user.
+ */
+
+ .text
+ .align 4
+10: ldub [%o0], %g4
+ cmp %g4, %o1
+ be 1f
+ add %o0, 1, %o0
+ cmp %g4, 0
+ be 9f
+ andcc %o0, 3, %g0
+ be 4f
+ or %o4, %lo(0x80808080), %o3
+ ldub [%o0], %g4
+ cmp %g4, %o1
+ be 1f
+ add %o0, 1, %o0
+ cmp %g4, 0
+ be 9f
+ andcc %o0, 3, %g0
+ be 5f
+ sethi %hi(0x01010101), %o5
+ ldub [%o0], %g4
+ cmp %g4, %o1
+ be 1f
+ add %o0, 1, %o0
+ cmp %g4, 0
+ be 9f
+ or %o5, %lo(0x01010101), %o2
+ b 6f
+ ld [%o0], %g4
+1: retl
+ sub %o0, 1, %o0
+
+ENTRY(strchr)
+ andcc %o1, 0xff, %o1
+ be 12f
+ sll %o1, 8, %o2
+ andcc %o0, 3, %g0
+ or %o1, %o2, %o2
+ sethi %hi(0x80808080), %o4
+ sll %o2, 16, %o3
+ bne 10b
+ or %o3, %o2, %g2
+ or %o4, %lo(0x80808080), %o3
+4: sethi %hi(0x01010101), %o5
+5: or %o5, %lo(0x01010101), %o2
+7: ld [%o0], %g4
+6: xor %g4, %g2, %g5
+ sub %g4, %o2, %o4
+#ifdef EIGHTBIT_NOT_RARE
+ sub %g5, %o2, %g7
+ andn %o4, %g4, %o4
+ andn %g7, %g5, %g5
+#else
+ sub %g5, %o2, %g5
+#endif
+ or %g5, %o4, %o4
+ andcc %o4, %o3, %g0
+ be 7b
+ add %o0, 4, %o0
+
+ /* Check every byte. */
+8: srl %g4, 24, %g5
+7: andcc %g5, 0xff, %g5
+ be 9f
+ cmp %g5, %o1
+ be 4f
+ srl %g4, 16, %g5
+ andcc %g5, 0xff, %g5
+ be 9f
+ cmp %g5, %o1
+ be 3f
+ srl %g4, 8, %g5
+ andcc %g5, 0xff, %g5
+ be 9f
+ cmp %g5, %o1
+ be 2f
+ andcc %g4, 0xff, %g5
+ be 9f
+ cmp %g5, %o1
+ bne,a 6b
+ ld [%o0], %g4
+ retl
+ sub %o0, 1, %o0
+2: retl
+ sub %o0, 2, %o0
+3: retl
+ sub %o0, 3, %o0
+4: retl
+ sub %o0, 4, %o0
+9: retl
+ clr %o0
+
+11: ldub [%o0], %o5
+ cmp %o5, 0
+ be 1f
+ add %o0, 1, %o0
+ andcc %o0, 3, %g0
+ be 4f
+ or %o4, %lo(0x80808080), %o3
+ ldub [%o0], %o5
+ cmp %o5, 0
+ be 1f
+ add %o0, 1, %o0
+ andcc %o0, 3, %g0
+ be 5f
+ sethi %hi(0x01010101), %o4
+ ldub [%o0], %o5
+ cmp %o5, 0
+ be 1f
+ add %o0, 1, %o0
+ b 6f
+ or %o4, %lo(0x01010101), %o2
+1: retl
+ sub %o0, 1, %o0
+
+12: andcc %o0, 3, %g0
+ bne 11b
+ sethi %hi(0x80808080), %o4
+ or %o4, %lo(0x80808080), %o3
+4: sethi %hi(0x01010101), %o4
+5: or %o4, %lo(0x01010101), %o2
+6: ld [%o0], %o5
+7: sub %o5, %o2, %o4
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o4, %o5, %o4
+#endif
+ andcc %o4, %o3, %g0
+ be 6b
+ add %o0, 4, %o0
+
+ /* Check every byte. */
+ srl %o5, 24, %g5
+ andcc %g5, 0xff, %g0
+ be 8f
+ add %o0, -4, %o4
+ srl %o5, 16, %g5
+ andcc %g5, 0xff, %g0
+ be 8f
+ add %o4, 1, %o4
+ srl %o5, 8, %g5
+ andcc %g5, 0xff, %g0
+ be 8f
+ add %o4, 1, %o4
+ andcc %o5, 0xff, %g0
+ bne,a 7b
+ ld [%o0], %o5
+ add %o4, 1, %o4
+8: retl
+ mov %o4, %o0
+
+13: ldub [%o0], %g4
+ cmp %g4, %o1
+ add %o0, 1, %o0
+ be,a 1f
+ sub %o0, 1, %o5
+ cmp %g4, 0
+ be 9f
+1: andcc %o0, 3, %g0
+ be 4f
+ or %o4, %lo(0x80808080), %o3
+ ldub [%o0], %g4
+ cmp %g4, %o1
+ add %o0, 1, %o0
+ be,a 1f
+ sub %o0, 1, %o5
+ cmp %g4, 0
+ be 9f
+1: andcc %o0, 3, %g0
+ be 5f
+ sethi %hi(0x01010101), %o4
+ ldub [%o0], %g4
+ cmp %g4, %o1
+ add %o0, 1, %o0
+ be,a 1f
+ sub %o0, 1, %o5
+ cmp %g4, 0
+ be 9f
+1: or %o4, %lo(0x01010101), %o2
+ b 7f
+ ld [%o0], %g4
+END(strchr)
+
+ENTRY(strrchr)
+ andcc %o1, 0xff, %o1
+ clr %o5
+ be 12b
+ sll %o1, 8, %o2
+ andcc %o0, 3, %g0
+ or %o1, %o2, %o2
+ sethi %hi(0x80808080), %o4
+ sll %o2, 16, %o3
+ bne 13b
+ or %o3, %o2, %g2
+ or %o4, %lo(0x80808080), %o3
+4: sethi %hi(0x01010101), %o4
+5: or %o4, %lo(0x01010101), %o2
+6: ld [%o0], %g4
+7: xor %g4, %g2, %g5
+ sub %g4, %o2, %o4
+#ifdef EIGHTBIT_NOT_RARE
+ sub %g5, %o2, %g7
+ andn %o4, %g4, %o4
+ andn %g7, %g5, %g5
+#else
+ sub %g5, %o2, %g5
+#endif
+ or %g5, %o4, %o4
+ andcc %o4, %o3, %g0
+ be 6b
+ add %o0, 4, %o0
+
+ /* Check every byte. */
+3: srl %g4, 24, %g5
+8: andcc %g5, 0xff, %g5
+ be 9f
+ cmp %g5, %o1
+ be,a 1f
+ sub %o0, 4, %o5
+1: srl %g4, 16, %g5
+ andcc %g5, 0xff, %g5
+ be 9f
+ cmp %g5, %o1
+ be,a 1f
+ sub %o0, 3, %o5
+1: srl %g4, 8, %g5
+ andcc %g5, 0xff, %g5
+ be 9f
+ cmp %g5, %o1
+ be,a 1f
+ sub %o0, 2, %o5
+1: andcc %g4, 0xff, %g5
+ be 9f
+ cmp %g5, %o1
+ be,a 1f
+ sub %o0, 1, %o5
+1: b 7b
+ ld [%o0], %g4
+9: retl
+ mov %o5, %o0
+END(strrchr)
+
+weak_alias(strchr, index)
+weak_alias(strrchr, rindex)
diff --git a/sysdeps/sparc/sparc32/strcmp.S b/sysdeps/sparc/sparc32/strcmp.S
new file mode 100644
index 0000000000..99c6e6f399
--- /dev/null
+++ b/sysdeps/sparc/sparc32/strcmp.S
@@ -0,0 +1,257 @@
+/* Compare two strings for differences.
+ For SPARC v7.
+ Copyright (C) 1996, 97, 99 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jj@ultra.linux.cz>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+
+ /* Normally, this uses ((xword - 0x01010101) & 0x80808080) test
+ to find out if any byte in xword could be zero. This is fast, but
+ also gives false alarm for any byte in range 0x81-0xff. It does
+ not matter for correctness, as if this test tells us there could
+ be some zero byte, we check it byte by byte, but if bytes with
+ high bits set are common in the strings, then this will give poor
+ performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
+ will use one tick slower, but more precise test
+ ((xword - 0x01010101) & (~xword) & 0x80808080),
+ which does not give any false alarms (but if some bits are set,
+ one cannot assume from it which bytes are zero and which are not).
+ It is yet to be measured, what is the correct default for glibc
+ in these days for an average user.
+ */
+
+ .text
+ .align 4
+10: ldub [%o0], %o4
+ add %o0, 1, %o0
+ ldub [%o1], %o5
+ cmp %o4, 0
+ add %o1, 1, %o1
+ be 2f
+ subcc %o4, %o5, %o4
+ bne 2f
+ andcc %o0, 3, %g0
+ be 4f
+ or %g1, %lo(0x80808080), %o3
+ ldub [%o0], %o4
+ add %o0, 1, %o0
+ ldub [%o1], %o5
+ cmp %o4, 0
+ add %o1, 1, %o1
+ be 2f
+ subcc %o4, %o5, %o4
+ bne 2f
+ andcc %o0, 3, %g0
+ be 5f
+ sethi %hi(0x01010101), %g1
+ ldub [%o0], %o4
+ add %o0, 1, %o0
+ ldub [%o1], %o5
+ cmp %o4, 0
+ add %o1, 1, %o1
+ be 2f
+ subcc %o4, %o5, %o4
+ bne 2f
+ andcc %o1, 3, %g2
+ bne 12f
+ or %g1, %lo(0x01010101), %o2
+ b 1f
+ ld [%o0], %o4
+2: retl
+ mov %o4, %o0
+
+ENTRY(strcmp)
+ andcc %o0, 3, %g0
+ bne 10b
+ sethi %hi(0x80808080), %g1
+ or %g1, %lo(0x80808080), %o3
+4: sethi %hi(0x01010101), %g1
+5: andcc %o1, 3, %g2
+ bne 12f
+ or %g1, %lo(0x01010101), %o2
+
+0: ld [%o0], %o4
+1: ld [%o1], %o5
+ sub %o4, %o2, %g1
+ add %o0, 4, %o0
+ cmp %o4, %o5
+#ifdef EIGHTBIT_NOT_RARE
+ andn %g1, %o4, %g1
+#endif
+ bne 11f
+ andcc %g1, %o3, %g0
+ be 0b
+ add %o1, 4, %o1
+
+ srl %o4, 24, %g4
+ andcc %g4, 0xff, %g0
+ be 2f
+ srl %o4, 16, %g4
+ andcc %g4, 0xff, %g0
+ be 2f
+ srl %o4, 8, %g4
+ andcc %g4, 0xff, %g0
+ be 2f
+ andcc %o4, 0xff, %g0
+ bne,a 1b
+ ld [%o0], %o4
+2: retl
+ clr %o0
+
+11: srl %o4, 24, %g4
+ srl %o5, 24, %g5
+ andcc %g4, 0xff, %g0
+ be 3f
+ subcc %g4, %g5, %g4
+ bne 3f
+ srl %o5, 16, %g5
+ srl %o4, 16, %g4
+ andcc %g4, 0xff, %g0
+ be 3f
+ subcc %g4, %g5, %g4
+ bne 3f
+ srl %o5, 8, %g5
+ srl %o4, 8, %g4
+ andcc %g4, 0xff, %g0
+ be 3f
+ subcc %g4, %g5, %g4
+ bne 3f
+ subcc %o4, %o5, %o4
+ retl
+ mov %o4, %o0
+3: retl
+ mov %g4, %o0
+
+12: save %sp, -64, %sp
+ ld [%i0], %i4
+ sll %g2, 3, %g3
+ andn %i1, 3, %i1
+ mov 32, %l1
+ ld [%i1], %l2
+ mov -1, %g7
+ add %i1, 4, %i1
+ sub %l1, %g3, %l1
+ sll %g7, %g3, %g7
+
+1: sll %l2, %g3, %g5
+ and %i4, %g7, %l3
+ sub %i4, %i2, %g1
+#ifdef EIGHTBIT_NOT_RARE
+ andn %g1, %i4, %g1
+#endif
+ andcc %g1, %i3, %g1
+ bne 3f
+ cmp %g5, %l3
+ bne 2f
+ add %i0, 4, %i0
+ ld [%i1], %l2
+ add %i1, 4, %i1
+ srl %l2, %l1, %l4
+ or %l4, %g5, %l4
+ cmp %l4, %i4
+ be,a 1b
+ ld [%i0], %i4
+ restore %l4, %g0, %o3
+ retl
+ sub %o4, %o3, %o0
+
+2: sll %l2, %g3, %i2
+ srl %i4, %g3, %i3
+ srl %i2, %g3, %i2
+ restore
+ retl
+ sub %o3, %o2, %o0
+
+3: srl %i4, 24, %g4
+ srl %g5, 24, %l6
+ andcc %g4, 0xff, %g0
+ be 4f
+ subcc %g4, %l6, %g4
+ bne 4f
+ cmp %g2, 3
+ be 6f
+ srl %i4, 16, %g4
+ srl %g5, 16, %l6
+ andcc %g4, 0xff, %g0
+ be 4f
+ subcc %g4, %l6, %g4
+ bne 4f
+ cmp %g2, 2
+ be 5f
+ srl %i4, 8, %g4
+ srl %g5, 8, %l6
+ andcc %g4, 0xff, %g0
+ be 4f
+ subcc %g4, %l6, %g4
+ bne 4f
+ add %i0, 4, %i0
+ ld [%i1], %l2
+ add %i1, 4, %i1
+ srl %l2, 24, %g5
+ andcc %i4, 0xff, %g4
+ be 4f
+ subcc %g4, %g5, %g4
+ be,a 1b
+ ld [%i0], %i4
+4: jmpl %i7 + 8, %g0
+ restore %g4, %g0, %o0
+
+5: ld [%i1], %l2
+ add %i1, 4, %i1
+ add %i0, 4, %i0
+ srl %l2, 24, %l6
+ andcc %g4, 0xff, %g4
+ be 4b
+ subcc %g4, %l6, %g4
+ bne 4b
+ srl %l2, 16, %l6
+ andcc %i4, 0xff, %g4
+ and %l6, 0xff, %l6
+ be 4b
+ subcc %g4, %l6, %g4
+ be,a 1b
+ ld [%i0], %i4
+ jmpl %i7 + 8, %g0
+ restore %g4, %g0, %o0
+
+6: ld [%i1], %l2
+ add %i1, 4, %i1
+ add %i0, 4, %i0
+ srl %l2, 24, %l6
+ andcc %g4, 0xff, %g4
+ be 4b
+ subcc %g4, %l6, %g4
+ bne 4b
+ srl %l2, 16, %l6
+ srl %i4, 8, %g4
+ and %l6, 0xff, %l6
+ andcc %g4, 0xff, %g4
+ be 4b
+ subcc %g4, %l6, %g4
+ bne 4b
+ srl %l2, 8, %l6
+ andcc %i4, 0xff, %g4
+ and %l6, 0xff, %l6
+ be 4b
+ subcc %g4, %l6, %g4
+ be,a 1b
+ ld [%i0], %i4
+ jmpl %i7 + 8, %g0
+ restore %g4, %g0, %o0
+END(strcmp)
diff --git a/sysdeps/sparc/sparc32/strcpy.S b/sysdeps/sparc/sparc32/strcpy.S
new file mode 100644
index 0000000000..e376bb41b8
--- /dev/null
+++ b/sysdeps/sparc/sparc32/strcpy.S
@@ -0,0 +1,274 @@
+/* Copy SRC to DEST returning DEST.
+ For SPARC v7.
+ Copyright (C) 1996, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jj@ultra.linux.cz>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+
+ /* Normally, this uses ((xword - 0x01010101) & 0x80808080) test
+ to find out if any byte in xword could be zero. This is fast, but
+ also gives false alarm for any byte in range 0x81-0xff. It does
+ not matter for correctness, as if this test tells us there could
+ be some zero byte, we check it byte by byte, but if bytes with
+ high bits set are common in the strings, then this will give poor
+ performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
+ will use one tick slower, but more precise test
+ ((xword - 0x01010101) & (~xword) & 0x80808080),
+ which does not give any false alarms (but if some bits are set,
+ one cannot assume from it which bytes are zero and which are not).
+ It is yet to be measured, what is the correct default for glibc
+ in these days for an average user.
+ */
+
+ .text
+ .align 4
+1: ldub [%o1], %o5
+ stb %o5, [%o0]
+ cmp %o5, 0
+ add %o0, 1, %o0
+ be 0f
+ add %o1, 1, %o1
+ andcc %o1, 3, %g0
+ be 4f
+ or %o4, %lo(0x80808080), %o3
+ ldub [%o1], %o5
+ stb %o5, [%o0]
+ cmp %o5, 0
+ add %o0, 1, %o0
+ be 0f
+ add %o1, 1, %o1
+ andcc %o1, 3, %g0
+ be 5f
+ sethi %hi(0x01010101), %o4
+ ldub [%o1], %o5
+ stb %o5, [%o0]
+ cmp %o5, 0
+ add %o0, 1, %o0
+ be 0f
+ add %o1, 1, %o1
+ b 6f
+ andcc %o0, 3, %g3
+
+ENTRY(strcpy)
+ mov %o0, %g2
+ andcc %o1, 3, %g0
+ bne 1b
+ sethi %hi(0x80808080), %o4
+ or %o4, %lo(0x80808080), %o3
+4: sethi %hi(0x01010101), %o4
+5: andcc %o0, 3, %g3
+6: bne 10f
+ or %o4, %lo(0x01010101), %o2
+1: ld [%o1], %o5
+ add %o1, 4, %o1
+ sub %o5, %o2, %o4
+ add %o0, 4, %o0
+ andcc %o4, %o3, %g0
+ be,a 1b
+ st %o5, [%o0 - 4]
+
+ srl %o5, 24, %g5
+ andcc %g5, 0xff, %g0
+ be 1f
+ srl %o5, 16, %g5
+ andcc %g5, 0xff, %g0
+ be 2f
+ srl %o5, 8, %g5
+ andcc %g5, 0xff, %g0
+ be 3f
+ andcc %o5, 0xff, %g0
+ bne 1b
+ st %o5, [%o0 - 4]
+ retl
+ mov %g2, %o0
+3: srl %o5, 16, %o5
+ sth %o5, [%o0 - 4]
+ stb %g0, [%o0 - 2]
+ retl
+ mov %g2, %o0
+2: srl %o5, 16, %o5
+ sth %o5, [%o0 - 4]
+ retl
+ mov %g2, %o0
+1: stb %g0, [%o0 - 4]
+ retl
+ mov %g2, %o0
+
+10: ld [%o1], %o5
+ add %o1, 4, %o1
+ sub %o5, %o2, %o4
+ cmp %g3, 2
+ be 2f
+ cmp %g3, 3
+ be 3f
+ andcc %o4, %o3, %g0
+ bne 5f
+ srl %o5, 24, %g5
+ stb %g5, [%o0]
+ sub %o0, 1, %o0
+ srl %o5, 8, %g5
+ sth %g5, [%o0 + 2]
+1: add %o0, 4, %o0
+4: sll %o5, 24, %g6
+ ld [%o1], %o5
+ add %o1, 4, %o1
+ srl %o5, 8, %g5
+ sub %o5, %o2, %o4
+ or %g5, %g6, %g5
+ andcc %o4, %o3, %g0
+ be,a 1b
+ st %g5, [%o0]
+ srl %o5, 24, %o4
+ andcc %o4, 0xff, %g0
+ be 6f
+ srl %o5, 16, %o4
+ andcc %o4, 0xff, %g0
+ be 7f
+ srl %o5, 8, %o4
+ st %g5, [%o0]
+ andcc %o4, 0xff, %g0
+ be 0f
+ andcc %o5, 0xff, %g0
+1: bne 4b
+ add %o0, 4, %o0
+9: stb %g0, [%o0]
+0: retl
+ mov %g2, %o0
+6: srl %g5, 16, %g5
+ sth %g5, [%o0]
+ retl
+ mov %g2, %o0
+7: srl %g5, 16, %g5
+ sth %g5, [%o0]
+ stb %g0, [%o0 + 2]
+ retl
+ mov %g2, %o0
+5: andcc %g5, 0xff, %g4
+ be 9b
+ srl %o5, 16, %g5
+ andcc %g5, 0xff, %g0
+ be 7f
+ srl %o5, 8, %g5
+ andcc %g5, 0xff, %g0
+ stb %g4, [%o0]
+ sth %g5, [%o0 + 1]
+ sub %o0, 1, %o0
+ bne 1b
+ andcc %o5, 0xff, %g0
+ retl
+ mov %g2, %o0
+7: stb %g4, [%o0]
+ stb %g0, [%o0 + 1]
+ retl
+ mov %g2, %o0
+
+2: andcc %o4, %o3, %g0
+ bne 5f
+ srl %o5, 16, %g5
+ sth %g5, [%o0]
+ sub %o0, 2, %o0
+1: add %o0, 4, %o0
+4: sll %o5, 16, %g6
+ ld [%o1], %o5
+ add %o1, 4, %o1
+ srl %o5, 16, %g5
+ sub %o5, %o2, %o4
+ or %g5, %g6, %g5
+ andcc %o4, %o3, %g0
+ be,a 1b
+ st %g5, [%o0]
+ srl %o5, 24, %o4
+ andcc %o4, 0xff, %g0
+ be 7f
+ srl %o5, 16, %o4
+ st %g5, [%o0]
+ andcc %o4, 0xff, %g0
+ be 0b
+ srl %o5, 8, %o4
+1: andcc %o4, 0xff, %g0
+ be 8f
+ andcc %o5, 0xff, %g0
+ bne 4b
+ add %o0, 4, %o0
+ sth %o5, [%o0]
+ retl
+ mov %g2, %o0
+7: srl %g5, 16, %g5
+ sth %g5, [%o0]
+ stb %g0, [%o0 + 2]
+ retl
+ mov %g2, %o0
+8: stb %g0, [%o0 + 4]
+ retl
+ mov %g2, %o0
+5: srl %o5, 24, %g5
+ andcc %g5, 0xff, %g0
+ be 9b
+ srl %o5, 16, %g5
+ andcc %g5, 0xff, %g0
+ sth %g5, [%o0]
+ sub %o0, 2, %o0
+ bne 1b
+ srl %o5, 8, %o4
+ retl
+ mov %g2, %o0
+
+3: bne 5f
+ srl %o5, 24, %g5
+ stb %g5, [%o0]
+ sub %o0, 3, %o0
+1: add %o0, 4, %o0
+4: sll %o5, 8, %g6
+ ld [%o1], %o5
+ add %o1, 4, %o1
+ srl %o5, 24, %g5
+ sub %o5, %o2, %o4
+ or %g5, %g6, %g5
+ andcc %o4, %o3, %g0
+ be 1b
+ st %g5, [%o0]
+ srl %o5, 24, %o4
+ andcc %o4, 0xff, %g0
+ be 0b
+ srl %o5, 16, %o4
+1: andcc %o4, 0xff, %g0
+ be 8b
+ srl %o5, 8, %o4
+ andcc %o4, 0xff, %g0
+ be 9f
+ andcc %o5, 0xff, %g0
+ bne 4b
+ add %o0, 4, %o0
+ srl %o5, 8, %o5
+ sth %o5, [%o0]
+ stb %g0, [%o0 + 2]
+ retl
+ mov %g2, %o0
+9: srl %o5, 8, %o5
+ sth %o5, [%o0 + 4]
+ retl
+ mov %g2, %o0
+5: andcc %g5, 0xff, %g0
+ stb %g5, [%o0]
+ sub %o0, 3, %o0
+ bne 1b
+ srl %o5, 16, %o4
+ retl
+ mov %g2, %o0
+END(strcpy)
diff --git a/sysdeps/sparc/sparc32/strlen.S b/sysdeps/sparc/sparc32/strlen.S
new file mode 100644
index 0000000000..2dc9a9d33c
--- /dev/null
+++ b/sysdeps/sparc/sparc32/strlen.S
@@ -0,0 +1,102 @@
+/* Determine the length of a string.
+ For SPARC v7.
+ Copyright (C) 1996, 1999 Free Software Foundation, Inc.
+ Contributed by Jakub Jelinek <jj@ultra.linux.cz>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+
+ /* Normally, this uses ((xword - 0x01010101) & 0x80808080) test
+ to find out if any byte in xword could be zero. This is fast, but
+ also gives false alarm for any byte in range 0x81-0xff. It does
+ not matter for correctness, as if this test tells us there could
+ be some zero byte, we check it byte by byte, but if bytes with
+ high bits set are common in the strings, then this will give poor
+ performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
+ will use one tick slower, but more precise test
+ ((xword - 0x01010101) & (~xword) & 0x80808080),
+ which does not give any false alarms (but if some bits are set,
+ one cannot assume from it which bytes are zero and which are not).
+ It is yet to be measured, what is the correct default for glibc
+ in these days for an average user.
+ */
+
+ .text
+ .align 4
+10: ldub [%o0], %o5
+ cmp %o5, 0
+ be 1f
+ add %o0, 1, %o0
+ andcc %o0, 3, %g0
+ be 4f
+ or %o4, %lo(0x80808080), %o3
+ ldub [%o0], %o5
+ cmp %o5, 0
+ be 2f
+ add %o0, 1, %o0
+ andcc %o0, 3, %g0
+ be 5f
+ sethi %hi(0x01010101), %o4
+ ldub [%o0], %o5
+ cmp %o5, 0
+ be 3f
+ add %o0, 1, %o0
+ b 11f
+ or %o4, %lo(0x01010101), %o2
+1: retl
+ mov 0, %o0
+2: retl
+ mov 1, %o0
+3: retl
+ mov 2, %o0
+
+ENTRY(strlen)
+ mov %o0, %o1
+ andcc %o0, 3, %g0
+ bne 10b
+ sethi %hi(0x80808080), %o4
+ or %o4, %lo(0x80808080), %o3
+4: sethi %hi(0x01010101), %o4
+5: or %o4, %lo(0x01010101), %o2
+11: ld [%o0], %o5
+12: sub %o5, %o2, %o4
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o4, %o5, %o4
+#endif
+ andcc %o4, %o3, %g0
+ be 11b
+ add %o0, 4, %o0
+
+ srl %o5, 24, %g5
+ andcc %g5, 0xff, %g0
+ be 13f
+ add %o0, -4, %o4
+ srl %o5, 16, %g5
+ andcc %g5, 0xff, %g0
+ be 13f
+ add %o4, 1, %o4
+ srl %o5, 8, %g5
+ andcc %g5, 0xff, %g0
+ be 13f
+ add %o4, 1, %o4
+ andcc %o5, 0xff, %g0
+ bne,a 12b
+ ld [%o0], %o5
+ add %o4, 1, %o4
+13: retl
+ sub %o4, %o1, %o0
+END(strlen)
diff --git a/sysdeps/sparc/sparc32/strrchr.c b/sysdeps/sparc/sparc32/strrchr.c
new file mode 100644
index 0000000000..ec608d6ab3
--- /dev/null
+++ b/sysdeps/sparc/sparc32/strrchr.c
@@ -0,0 +1 @@
+/* strrchr is in strchr.S */
diff --git a/sysdeps/sparc/sparc64/bcopy.c b/sysdeps/sparc/sparc64/bcopy.c
new file mode 100644
index 0000000000..9a455f33c4
--- /dev/null
+++ b/sysdeps/sparc/sparc64/bcopy.c
@@ -0,0 +1 @@
+/* bcopy is in memcpy.S */
diff --git a/sysdeps/sparc/sparc64/bzero.c b/sysdeps/sparc/sparc64/bzero.c
new file mode 100644
index 0000000000..37f0f6f993
--- /dev/null
+++ b/sysdeps/sparc/sparc64/bzero.c
@@ -0,0 +1 @@
+/* bzero is in memset.S */
diff --git a/sysdeps/sparc/sparc64/memchr.S b/sysdeps/sparc/sparc64/memchr.S
new file mode 100644
index 0000000000..9adf33ffc6
--- /dev/null
+++ b/sysdeps/sparc/sparc64/memchr.S
@@ -0,0 +1,256 @@
+/* memchr (str, ch, n) -- Return pointer to first occurrence of CH in STR less
+ than N.
+ For SPARC v9.
+ Copyright (C) 1998,1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz> and
+ Jakub Jelinek <jj@ultra.linux.cz>.
+
+ This version is developed using the same algorithm as the fast C
+ version which carries the following introduction:
+
+ Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
+ with help from Dan Sahlin (dan@sics.se) and
+ commentary by Jim Blandy (jimb@ai.mit.edu);
+ adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
+ and implemented by Roland McGrath (roland@ai.mit.edu).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <asm/asi.h>
+#ifndef XCC
+#define XCC xcc
+#define USE_BPR
+#endif
+
+ /* Normally, this uses
+ ((xword - 0x0101010101010101) & 0x8080808080808080) test
+ to find out if any byte in xword could be zero. This is fast, but
+ also gives false alarm for any byte in range 0x81-0xff. It does
+ not matter for correctness, as if this test tells us there could
+ be some zero byte, we check it byte by byte, but if bytes with
+ high bits set are common in the strings, then this will give poor
+ performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
+ will use one tick slower, but more precise test
+ ((xword - 0x0101010101010101) & (~xword) & 0x8080808080808080),
+ which does not give any false alarms (but if some bits are set,
+ one cannot assume from it which bytes are zero and which are not).
+ It is yet to be measured, what is the correct default for glibc
+ in these days for an average user.
+ */
+
+ .text
+ .align 32
+ENTRY(memchr)
+ sll %o1, 8, %g3 /* IEU0 Group */
+#ifdef USE_BPR
+ brz,pn %o2, 12f /* CTI+IEU1 */
+#else
+ tst %o2 /* IEU1 */
+ be,pn %XCC, 12f /* CTI */
+ srl %o1, 0, %o1 /* IEU0 */
+#endif
+ add %o0, %o2, %o2 /* IEU0 Group */
+ sethi %hi(0x01010101), %g1 /* IEU1 */
+
+ or %g3, %o1, %g3 /* IEU0 Group */
+ ldub [%o0], %o3 /* Load */
+ sllx %g3, 16, %g5 /* IEU0 Group */
+ or %g1, %lo(0x01010101), %g1 /* IEU1 */
+
+ sllx %g1, 32, %g2 /* IEU0 Group */
+ or %g3, %g5, %g3 /* IEU1 */
+ sllx %g3, 32, %g5 /* IEU0 Group */
+ cmp %o3, %o1 /* IEU1 */
+
+ be,pn %xcc, 13f /* CTI */
+ or %g1, %g2, %g1 /* IEU0 Group */
+ andcc %o0, 7, %g0 /* IEU1 */
+ bne,a,pn %icc, 21f /* CTI */
+
+ add %o0, 1, %o0 /* IEU0 Group */
+ ldx [%o0], %o3 /* Load Group */
+ sllx %g1, 7, %g2 /* IEU0 */
+ or %g3, %g5, %g3 /* IEU1 */
+
+1: add %o0, 8, %o0 /* IEU0 Group */
+ xor %o3, %g3, %o4 /* IEU1 */
+ /* %g1 = 0101010101010101 *
+ * %g2 = 8080088080808080 *
+ * %g3 = c c c c c c c c *
+ * %o3 = value *
+ * %o4 = value XOR c */
+2: cmp %o0, %o2 /* IEU1 Group */
+ bg,pn %XCC, 11f /* CTI */
+
+ ldxa [%o0] ASI_PNF, %o3 /* Load */
+ sub %o4, %g1, %o5 /* IEU0 Group */
+ add %o0, 8, %o0 /* IEU1 */
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o5, %o4, %o5 /* IEU0 Group */
+#endif
+ andcc %o5, %g2, %g0 /* IEU1 Group */
+
+ be,a,pt %xcc, 2b /* CTI */
+ xor %o3, %g3, %o4 /* IEU0 */
+ srlx %o4, 56, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 3f /* CTI */
+ srlx %o4, 48, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4f /* CTI */
+
+ srlx %o4, 40, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 5f /* CTI */
+ srlx %o4, 32, %g5 /* IEU0 */
+
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 6f /* CTI */
+ srlx %o4, 24, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 7f /* CTI */
+ srlx %o4, 16, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 8f /* CTI */
+
+ srlx %o4, 8, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 9f /* CTI */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+
+ bne,pt %icc, 2b /* CTI */
+ xor %o3, %g3, %o4 /* IEU0 */
+ retl /* CTI+IEU1 Group */
+ add %o0, -9, %o0 /* IEU0 */
+
+ .align 16
+3: retl /* CTI+IEU1 Group */
+ add %o0, -16, %o0 /* IEU0 */
+4: retl /* CTI+IEU1 Group */
+ add %o0, -15, %o0 /* IEU0 */
+
+5: retl /* CTI+IEU1 Group */
+ add %o0, -14, %o0 /* IEU0 */
+6: retl /* CTI+IEU1 Group */
+ add %o0, -13, %o0 /* IEU0 */
+
+7: retl /* CTI+IEU1 Group */
+ add %o0, -12, %o0 /* IEU0 */
+8: retl /* CTI+IEU1 Group */
+ add %o0, -11, %o0 /* IEU0 */
+
+9: retl /* CTI+IEU1 Group */
+ add %o0, -10, %o0 /* IEU0 */
+11: sub %o4, %g1, %o5 /* IEU0 Group */
+ sub %o0, 8, %o0 /* IEU1 */
+
+ andcc %o5, %g2, %g0 /* IEU1 Group */
+ be,pt %xcc, 12f /* CTI */
+ sub %o2, %o0, %o2 /* IEU0 */
+ tst %o2 /* IEU1 Group */
+
+ be,pn %XCC, 12f /* CTI */
+ srlx %o4, 56, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 13f /* CTI */
+
+ cmp %o2, 1 /* IEU0 */
+ be,pn %XCC, 12f /* CTI Group */
+ srlx %o4, 48, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 14f /* CTI */
+ cmp %o2, 2 /* IEU1 Group */
+ be,pn %XCC, 12f /* CTI */
+ srlx %o4, 40, %g5 /* IEU0 */
+
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 15f /* CTI */
+ cmp %o2, 3 /* IEU1 Group */
+ be,pn %XCC, 12f /* CTI */
+
+ srlx %o4, 32, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 16f /* CTI */
+ cmp %o2, 4 /* IEU1 Group */
+
+ be,pn %XCC, 12f /* CTI */
+ srlx %o4, 24, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 17f /* CTI */
+
+ cmp %o2, 5 /* IEU1 Group */
+ be,pn %XCC, 12f /* CTI */
+ srlx %o4, 16, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 18f /* CTI */
+ cmp %o2, 6 /* IEU1 Group */
+ be,pn %XCC, 12f /* CTI */
+ srlx %o4, 8, %g5 /* IEU0 */
+
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 19f /* CTI */
+ nop /* IEU0 */
+12: retl /* CTI+IEU1 Group */
+
+ clr %o0 /* IEU0 */
+ nop /* Stub */
+13: retl /* CTI+IEU1 Group */
+ nop /* IEU0 */
+
+14: retl /* CTI+IEU1 Group */
+ add %o0, 1, %o0 /* IEU0 */
+15: retl /* CTI+IEU1 Group */
+ add %o0, 2, %o0 /* IEU0 */
+
+16: retl /* CTI+IEU1 Group */
+ add %o0, 3, %o0 /* IEU0 */
+17: retl /* CTI+IEU1 Group */
+ add %o0, 4, %o0 /* IEU0 */
+
+18: retl /* CTI+IEU1 Group */
+ add %o0, 5, %o0 /* IEU0 */
+19: retl /* CTI+IEU1 Group */
+ add %o0, 6, %o0 /* IEU0 */
+
+21: cmp %o0, %o2 /* IEU1 */
+ be,pn %XCC, 12b /* CTI */
+ sllx %g1, 7, %g2 /* IEU0 Group */
+ ldub [%o0], %o3 /* Load */
+
+ or %g3, %g5, %g3 /* IEU1 */
+22: andcc %o0, 7, %g0 /* IEU1 Group */
+ be,a,pn %icc, 1b /* CTI */
+ ldx [%o0], %o3 /* Load */
+
+ cmp %o3, %o1 /* IEU1 Group */
+ be,pn %xcc, 23f /* CTI */
+ add %o0, 1, %o0 /* IEU0 */
+ cmp %o0, %o2 /* IEU1 Group */
+
+ bne,a,pt %XCC, 22b /* CTI */
+ ldub [%o0], %o3 /* Load */
+ retl /* CTI+IEU1 Group */
+ clr %o0 /* IEU0 */
+
+23: retl /* CTI+IEU1 Group */
+ add %o0, -1, %o0 /* IEU0 */
+END(memchr)
diff --git a/sysdeps/sparc/sparc64/memcmp.S b/sysdeps/sparc/sparc64/memcmp.S
new file mode 100644
index 0000000000..bd3253ce5c
--- /dev/null
+++ b/sysdeps/sparc/sparc64/memcmp.S
@@ -0,0 +1,140 @@
+/* Compare two memory blocks for differences in the first COUNT bytes.
+ For SPARC v9.
+ Copyright (C) 1998,1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz> and
+ Jakub Jelinek <jj@ultra.linux.cz>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <asm/asi.h>
+#ifndef XCC
+#define XCC xcc
+#define USE_BPR
+#endif
+
+ .text
+ .align 32
+ENTRY(memcmp)
+#ifdef USE_BPR
+ brz,pn %o2, 3f /* CTI+IEU1 Group */
+#else
+ tst %o2 /* IEU1 Group */
+ be,pn %XCC, 3f /* CTI */
+#endif
+ andcc %o0, 7, %g0 /* IEU1 Group */
+ bne,pn %icc, 8f /* CTI */
+1: andcc %o1, 7, %g1 /* IEU1 Group */
+
+ bne,pn %icc, 10f /* CTI */
+ mov 64, %g3 /* IEU0 */
+ ldx [%o0], %g1 /* Load Group */
+ sub %o1, %o0, %o1 /* IEU0 */
+
+ ldx [%o0 + %o1], %g2 /* Load Group */
+ add %o0, 8, %o0 /* IEU0 */
+2: mov %g1, %o3 /* IEU0 Group */
+ subcc %o2, 8, %o2 /* IEU1 */
+
+ bl,pn %XCC, 5f /* CTI */
+ ldxa [%o0] ASI_PNF, %g1 /* Load Group */
+ mov %g2, %o4 /* IEU0 */
+ ldxa [%o0 + %o1] ASI_PNF, %g2 /* Load Group */
+
+ cmp %o3, %o4 /* IEU1 */
+ be,pt %xcc, 2b /* CTI */
+ add %o0, 8, %o0 /* IEU0 */
+7: mov -1, %o0 /* IEU1 */
+
+ retl /* CTI+IEU1 Group */
+ movgu %xcc, 1, %o0 /* Single Group */
+3: retl /* CTI+IEU1 Group */
+ clr %o0 /* IEU0 */
+
+ .align 16
+5: mov %g2, %o4 /* IEU0 */
+6: cmp %o2, -8 /* IEU1 */
+ be,pn %XCC, 3b /* CTI */
+ sub %g0, %o2, %o2 /* IEU0 Group */
+
+ sllx %o2, 3, %o2 /* IEU0 Group */
+ srlx %o3, %o2, %o3 /* IEU0 Group */
+ srlx %o4, %o2, %o4 /* IEU0 Group */
+ clr %o0 /* IEU1 */
+
+ cmp %o3, %o4 /* IEU1 Group */
+ movgu %xcc, 1, %o0 /* Single Group */
+ retl /* CTI+IEU1 Group */
+ movlu %xcc, -1, %o0 /* Single Group */
+
+8: ldub [%o0], %o3 /* Load */
+ add %o0, 1, %o0 /* IEU0 */
+ ldub [%o1], %o4 /* Load Group */
+ add %o1, 1, %o1 /* IEU0 */
+
+9: cmp %o3, %o4 /* IEU1 Group */
+ bne,pn %xcc, 12f /* CTI */
+ subcc %o2, 1, %o2 /* IEU1 Group */
+ be,pn %XCC, 3b /* CTI */
+
+ lduba [%o0] ASI_PNF, %o3 /* Load */
+ andcc %o0, 7, %g0 /* IEU1 Group */
+ be,pn %icc, 1b /* CTI */
+ lduba [%o1] ASI_PNF, %o4 /* Load */
+
+ add %o0, 1, %o0 /* IEU0 Group */
+ ba,pt %xcc, 9b /* CTI */
+ add %o1, 1, %o1 /* IEU1 */
+
+ .align 16
+12: mov -1, %o0 /* IEU0 Group */
+ cmp %o3, %o4 /* IEU1 */
+ retl /* CTI+IEU1 Group */
+ movgu %xcc, 1, %o0 /* Single Group */
+
+ .align 16
+ nop /* Stub */
+10: sllx %g1, 3, %g2 /* IEU0 Group */
+ sub %o1, %g1, %o1 /* IEU1 */
+ sub %g3, %g2, %g3 /* IEU0 Group */
+
+ ldxa [%o0] ASI_PNF, %g5 /* Load */
+ sub %o1, %o0, %o1 /* IEU1 */
+ ldxa [%o0 + %o1] ASI_PNF, %g7 /* Load Group */
+ add %o0, 8, %o0 /* IEU0 */
+
+11: sllx %g7, %g2, %o4 /* IEU0 Group */
+ ldxa [%o0 + %o1] ASI_PNF, %g7 /* Load */
+ srlx %g7, %g3, %o5 /* IEU0 Group */
+ mov %g5, %o3 /* IEU1 */
+
+ ldxa [%o0] ASI_PNF, %g5 /* Load */
+ subcc %o2, 8, %o2 /* IEU1 Group */
+ bl,pn %XCC, 6b /* CTI */
+ or %o4, %o5, %o4 /* IEU0 */
+
+ cmp %o3, %o4 /* IEU1 Group */
+ be,pt %xcc, 11b /* CTI */
+ add %o0, 8, %o0 /* IEU0 */
+ mov -1, %o0 /* IEU0 */
+
+ retl /* CTI+IEU1 Group */
+ movgu %xcc, 1, %o0 /* Single Group */
+END(memcmp)
+
+#undef bcmp
+weak_alias(memcmp, bcmp)
diff --git a/sysdeps/sparc/sparc64/memcpy.S b/sysdeps/sparc/sparc64/memcpy.S
new file mode 100644
index 0000000000..fa08507d0c
--- /dev/null
+++ b/sysdeps/sparc/sparc64/memcpy.S
@@ -0,0 +1,574 @@
+/* Copy SIZE bytes from SRC to DEST.
+ For UltraSPARC.
+ Copyright (C) 1996, 97, 98, 99 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David S. Miller (davem@caip.rutgers.edu) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <asm/asi.h>
+#ifndef XCC
+#define USE_BPR
+#endif
+#define FPRS_FEF 4
+
+#define FREG_FROB(f1, f2, f3, f4, f5, f6, f7, f8, f9) \
+ faligndata %f1, %f2, %f48; \
+ faligndata %f2, %f3, %f50; \
+ faligndata %f3, %f4, %f52; \
+ faligndata %f4, %f5, %f54; \
+ faligndata %f5, %f6, %f56; \
+ faligndata %f6, %f7, %f58; \
+ faligndata %f7, %f8, %f60; \
+ faligndata %f8, %f9, %f62;
+
+#define MAIN_LOOP_CHUNK(src, dest, fdest, fsrc, len, jmptgt) \
+ ldda [%src] %asi, %fdest; \
+ add %src, 0x40, %src; \
+ add %dest, 0x40, %dest; \
+ subcc %len, 0x40, %len; \
+ be,pn %xcc, jmptgt; \
+ stda %fsrc, [%dest - 0x40] %asi;
+
+#define LOOP_CHUNK1(src, dest, len, branch_dest) \
+ MAIN_LOOP_CHUNK(src, dest, f0, f48, len, branch_dest)
+#define LOOP_CHUNK2(src, dest, len, branch_dest) \
+ MAIN_LOOP_CHUNK(src, dest, f16, f48, len, branch_dest)
+#define LOOP_CHUNK3(src, dest, len, branch_dest) \
+ MAIN_LOOP_CHUNK(src, dest, f32, f48, len, branch_dest)
+
+#define STORE_SYNC(dest, fsrc) \
+ stda %fsrc, [%dest] %asi; \
+ add %dest, 0x40, %dest;
+
+#define STORE_JUMP(dest, fsrc, target) \
+ stda %fsrc, [%dest] %asi; \
+ add %dest, 0x40, %dest; \
+ ba,pt %xcc, target;
+
+#define VISLOOP_PAD nop; nop; nop; nop; \
+ nop; nop; nop; nop; \
+ nop; nop; nop; nop; \
+ nop; nop; nop;
+
+#define FINISH_VISCHUNK(dest, f0, f1, left) \
+ subcc %left, 8, %left; \
+ bl,pn %xcc, 205f; \
+ faligndata %f0, %f1, %f48; \
+ std %f48, [%dest]; \
+ add %dest, 8, %dest;
+
+#define UNEVEN_VISCHUNK(dest, f0, f1, left) \
+ subcc %left, 8, %left; \
+ bl,pn %xcc, 205f; \
+ fsrc1 %f0, %f1; \
+ ba,a,pt %xcc, 204f;
+
+ /* Macros for non-VIS memcpy code. */
+#define MOVE_BIGCHUNK(src, dst, offset, t0, t1, t2, t3) \
+ ldx [%src + offset + 0x00], %t0; \
+ ldx [%src + offset + 0x08], %t1; \
+ ldx [%src + offset + 0x10], %t2; \
+ ldx [%src + offset + 0x18], %t3; \
+ stw %t0, [%dst + offset + 0x04]; \
+ srlx %t0, 32, %t0; \
+ stw %t0, [%dst + offset + 0x00]; \
+ stw %t1, [%dst + offset + 0x0c]; \
+ srlx %t1, 32, %t1; \
+ stw %t1, [%dst + offset + 0x08]; \
+ stw %t2, [%dst + offset + 0x14]; \
+ srlx %t2, 32, %t2; \
+ stw %t2, [%dst + offset + 0x10]; \
+ stw %t3, [%dst + offset + 0x1c]; \
+ srlx %t3, 32, %t3; \
+ stw %t3, [%dst + offset + 0x18];
+
+#define MOVE_BIGALIGNCHUNK(src, dst, offset, t0, t1, t2, t3) \
+ ldx [%src + offset + 0x00], %t0; \
+ ldx [%src + offset + 0x08], %t1; \
+ ldx [%src + offset + 0x10], %t2; \
+ ldx [%src + offset + 0x18], %t3; \
+ stx %t0, [%dst + offset + 0x00]; \
+ stx %t1, [%dst + offset + 0x08]; \
+ stx %t2, [%dst + offset + 0x10]; \
+ stx %t3, [%dst + offset + 0x18]; \
+ ldx [%src + offset + 0x20], %t0; \
+ ldx [%src + offset + 0x28], %t1; \
+ ldx [%src + offset + 0x30], %t2; \
+ ldx [%src + offset + 0x38], %t3; \
+ stx %t0, [%dst + offset + 0x20]; \
+ stx %t1, [%dst + offset + 0x28]; \
+ stx %t2, [%dst + offset + 0x30]; \
+ stx %t3, [%dst + offset + 0x38];
+
+#define MOVE_LASTCHUNK(src, dst, offset, t0, t1, t2, t3) \
+ ldx [%src - offset - 0x10], %t0; \
+ ldx [%src - offset - 0x08], %t1; \
+ stw %t0, [%dst - offset - 0x0c]; \
+ srlx %t0, 32, %t2; \
+ stw %t2, [%dst - offset - 0x10]; \
+ stw %t1, [%dst - offset - 0x04]; \
+ srlx %t1, 32, %t3; \
+ stw %t3, [%dst - offset - 0x08];
+
+#define MOVE_LASTALIGNCHUNK(src, dst, offset, t0, t1) \
+ ldx [%src - offset - 0x10], %t0; \
+ ldx [%src - offset - 0x08], %t1; \
+ stx %t0, [%dst - offset - 0x10]; \
+ stx %t1, [%dst - offset - 0x08];
+
+ .text
+ .align 32
+
+ENTRY(bcopy)
+ or %o0, 0, %g3 /* IEU0 Group */
+ addcc %o1, 0, %o0 /* IEU1 */
+ brgez,pt %o2, 210f /* CTI */
+ or %g3, 0, %o1 /* IEU0 Group */
+ retl /* CTI Group brk forced*/
+ clr %o0 /* IEU0 */
+END(bcopy)
+
+ .align 32
+200: be,pt %xcc, 201f /* CTI */
+ andcc %o0, 0x38, %g5 /* IEU1 Group */
+ mov 8, %g1 /* IEU0 */
+ sub %g1, %g2, %g2 /* IEU0 Group */
+ andcc %o0, 1, %g0 /* IEU1 */
+ be,pt %icc, 2f /* CTI */
+ sub %o2, %g2, %o2 /* IEU0 Group */
+1: ldub [%o1], %o5 /* Load Group */
+ add %o1, 1, %o1 /* IEU0 */
+ add %o0, 1, %o0 /* IEU1 */
+ subcc %g2, 1, %g2 /* IEU1 Group */
+ be,pn %xcc, 3f /* CTI */
+ stb %o5, [%o0 - 1] /* Store */
+2: ldub [%o1], %o5 /* Load Group */
+ add %o0, 2, %o0 /* IEU0 */
+ ldub [%o1 + 1], %g3 /* Load Group */
+ subcc %g2, 2, %g2 /* IEU1 Group */
+ stb %o5, [%o0 - 2] /* Store */
+ add %o1, 2, %o1 /* IEU0 */
+ bne,pt %xcc, 2b /* CTI Group */
+ stb %g3, [%o0 - 1] /* Store */
+3: andcc %o0, 0x38, %g5 /* IEU1 Group */
+201: be,pt %icc, 202f /* CTI */
+ mov 64, %g1 /* IEU0 */
+ fmovd %f0, %f2 /* FPU */
+ sub %g1, %g5, %g5 /* IEU0 Group */
+ alignaddr %o1, %g0, %g1 /* GRU Group */
+ ldd [%g1], %f4 /* Load Group */
+ sub %o2, %g5, %o2 /* IEU0 */
+1: ldd [%g1 + 0x8], %f6 /* Load Group */
+ add %g1, 0x8, %g1 /* IEU0 Group */
+ subcc %g5, 8, %g5 /* IEU1 */
+ faligndata %f4, %f6, %f0 /* GRU Group */
+ std %f0, [%o0] /* Store */
+ add %o1, 8, %o1 /* IEU0 Group */
+ be,pn %xcc, 202f /* CTI */
+ add %o0, 8, %o0 /* IEU1 */
+ ldd [%g1 + 0x8], %f4 /* Load Group */
+ add %g1, 8, %g1 /* IEU0 */
+ subcc %g5, 8, %g5 /* IEU1 */
+ faligndata %f6, %f4, %f0 /* GRU Group */
+ std %f0, [%o0] /* Store */
+ add %o1, 8, %o1 /* IEU0 */
+ bne,pt %xcc, 1b /* CTI Group */
+ add %o0, 8, %o0 /* IEU0 */
+202: membar #LoadStore | #StoreStore | #StoreLoad /* LSU Group */
+ wr %g0, ASI_BLK_P, %asi /* LSU Group */
+ subcc %o2, 0x40, %g7 /* IEU1 Group */
+ mov %o1, %g1 /* IEU0 */
+ andncc %g7, (0x40 - 1), %g7 /* IEU1 Group */
+ srl %g1, 3, %g2 /* IEU0 */
+ sub %o2, %g7, %g3 /* IEU0 Group */
+ andn %o1, (0x40 - 1), %o1 /* IEU1 */
+ and %g2, 7, %g2 /* IEU0 Group */
+ andncc %g3, 0x7, %g3 /* IEU1 */
+ fmovd %f0, %f2 /* FPU */
+ sub %g3, 0x10, %g3 /* IEU0 Group */
+ sub %o2, %g7, %o2 /* IEU1 */
+ alignaddr %g1, %g0, %g0 /* GRU Group */
+ add %g1, %g7, %g1 /* IEU0 Group */
+ subcc %o2, %g3, %o2 /* IEU1 */
+ ldda [%o1 + 0x00] %asi, %f0 /* LSU Group */
+ add %g1, %g3, %g1 /* IEU0 */
+ ldda [%o1 + 0x40] %asi, %f16 /* LSU Group */
+ sub %g7, 0x80, %g7 /* IEU0 */
+ ldda [%o1 + 0x80] %asi, %f32 /* LSU Group */
+ /* Clk1 Group 8-( */
+ /* Clk2 Group 8-( */
+ /* Clk3 Group 8-( */
+ /* Clk4 Group 8-( */
+203: rd %pc, %g5 /* PDU Group 8-( */
+ addcc %g5, %lo(300f - 203b), %g5 /* IEU1 Group */
+ sll %g2, 9, %g2 /* IEU0 */
+ jmpl %g5 + %g2, %g0 /* CTI Group brk forced*/
+ addcc %o1, 0xc0, %o1 /* IEU1 Group */
+
+ .align 512 /* OK, here comes the fun part... */
+300: FREG_FROB(f0, f2, f4, f6, f8, f10,f12,f14,f16) LOOP_CHUNK1(o1, o0, g7, 301f)
+ FREG_FROB(f16,f18,f20,f22,f24,f26,f28,f30,f32) LOOP_CHUNK2(o1, o0, g7, 302f)
+ FREG_FROB(f32,f34,f36,f38,f40,f42,f44,f46,f0) LOOP_CHUNK3(o1, o0, g7, 303f)
+ b,pt %xcc, 300b+4; faligndata %f0, %f2, %f48
+301: FREG_FROB(f16,f18,f20,f22,f24,f26,f28,f30,f32) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f32,f34,f36,f38,f40,f42,f44,f46,f0) STORE_JUMP(o0, f48, 400f) membar #Sync
+302: FREG_FROB(f32,f34,f36,f38,f40,f42,f44,f46,f0) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f0, f2, f4, f6, f8, f10,f12,f14,f16) STORE_JUMP(o0, f48, 416f) membar #Sync
+303: FREG_FROB(f0, f2, f4, f6, f8, f10,f12,f14,f16) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f16,f18,f20,f22,f24,f26,f28,f30,f32) STORE_JUMP(o0, f48, 432f) membar #Sync
+ VISLOOP_PAD
+310: FREG_FROB(f2, f4, f6, f8, f10,f12,f14,f16,f18) LOOP_CHUNK1(o1, o0, g7, 311f)
+ FREG_FROB(f18,f20,f22,f24,f26,f28,f30,f32,f34) LOOP_CHUNK2(o1, o0, g7, 312f)
+ FREG_FROB(f34,f36,f38,f40,f42,f44,f46,f0, f2) LOOP_CHUNK3(o1, o0, g7, 313f)
+ b,pt %xcc, 310b+4; faligndata %f2, %f4, %f48
+311: FREG_FROB(f18,f20,f22,f24,f26,f28,f30,f32,f34) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f34,f36,f38,f40,f42,f44,f46,f0, f2) STORE_JUMP(o0, f48, 402f) membar #Sync
+312: FREG_FROB(f34,f36,f38,f40,f42,f44,f46,f0, f2) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f2, f4, f6, f8, f10,f12,f14,f16,f18) STORE_JUMP(o0, f48, 418f) membar #Sync
+313: FREG_FROB(f2, f4, f6, f8, f10,f12,f14,f16,f18) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f18,f20,f22,f24,f26,f28,f30,f32,f34) STORE_JUMP(o0, f48, 434f) membar #Sync
+ VISLOOP_PAD
+320: FREG_FROB(f4, f6, f8, f10,f12,f14,f16,f18,f20) LOOP_CHUNK1(o1, o0, g7, 321f)
+ FREG_FROB(f20,f22,f24,f26,f28,f30,f32,f34,f36) LOOP_CHUNK2(o1, o0, g7, 322f)
+ FREG_FROB(f36,f38,f40,f42,f44,f46,f0, f2, f4) LOOP_CHUNK3(o1, o0, g7, 323f)
+ b,pt %xcc, 320b+4; faligndata %f4, %f6, %f48
+321: FREG_FROB(f20,f22,f24,f26,f28,f30,f32,f34,f36) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f36,f38,f40,f42,f44,f46,f0, f2, f4) STORE_JUMP(o0, f48, 404f) membar #Sync
+322: FREG_FROB(f36,f38,f40,f42,f44,f46,f0, f2, f4) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f4, f6, f8, f10,f12,f14,f16,f18,f20) STORE_JUMP(o0, f48, 420f) membar #Sync
+323: FREG_FROB(f4, f6, f8, f10,f12,f14,f16,f18,f20) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f20,f22,f24,f26,f28,f30,f32,f34,f36) STORE_JUMP(o0, f48, 436f) membar #Sync
+ VISLOOP_PAD
+330: FREG_FROB(f6, f8, f10,f12,f14,f16,f18,f20,f22) LOOP_CHUNK1(o1, o0, g7, 331f)
+ FREG_FROB(f22,f24,f26,f28,f30,f32,f34,f36,f38) LOOP_CHUNK2(o1, o0, g7, 332f)
+ FREG_FROB(f38,f40,f42,f44,f46,f0, f2, f4, f6) LOOP_CHUNK3(o1, o0, g7, 333f)
+ b,pt %xcc, 330b+4; faligndata %f6, %f8, %f48
+331: FREG_FROB(f22,f24,f26,f28,f30,f32,f34,f36,f38) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f38,f40,f42,f44,f46,f0, f2, f4, f6) STORE_JUMP(o0, f48, 406f) membar #Sync
+332: FREG_FROB(f38,f40,f42,f44,f46,f0, f2, f4, f6) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f6, f8, f10,f12,f14,f16,f18,f20,f22) STORE_JUMP(o0, f48, 422f) membar #Sync
+333: FREG_FROB(f6, f8, f10,f12,f14,f16,f18,f20,f22) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f22,f24,f26,f28,f30,f32,f34,f36,f38) STORE_JUMP(o0, f48, 438f) membar #Sync
+ VISLOOP_PAD
+340: FREG_FROB(f8, f10,f12,f14,f16,f18,f20,f22,f24) LOOP_CHUNK1(o1, o0, g7, 341f)
+ FREG_FROB(f24,f26,f28,f30,f32,f34,f36,f38,f40) LOOP_CHUNK2(o1, o0, g7, 342f)
+ FREG_FROB(f40,f42,f44,f46,f0, f2, f4, f6, f8) LOOP_CHUNK3(o1, o0, g7, 343f)
+ b,pt %xcc, 340b+4; faligndata %f8, %f10, %f48
+341: FREG_FROB(f24,f26,f28,f30,f32,f34,f36,f38,f40) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f40,f42,f44,f46,f0, f2, f4, f6, f8) STORE_JUMP(o0, f48, 408f) membar #Sync
+342: FREG_FROB(f40,f42,f44,f46,f0, f2, f4, f6, f8) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f8, f10,f12,f14,f16,f18,f20,f22,f24) STORE_JUMP(o0, f48, 424f) membar #Sync
+343: FREG_FROB(f8, f10,f12,f14,f16,f18,f20,f22,f24) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f24,f26,f28,f30,f32,f34,f36,f38,f40) STORE_JUMP(o0, f48, 440f) membar #Sync
+ VISLOOP_PAD
+350: FREG_FROB(f10,f12,f14,f16,f18,f20,f22,f24,f26) LOOP_CHUNK1(o1, o0, g7, 351f)
+ FREG_FROB(f26,f28,f30,f32,f34,f36,f38,f40,f42) LOOP_CHUNK2(o1, o0, g7, 352f)
+ FREG_FROB(f42,f44,f46,f0, f2, f4, f6, f8, f10) LOOP_CHUNK3(o1, o0, g7, 353f)
+ b,pt %xcc, 350b+4; faligndata %f10, %f12, %f48
+351: FREG_FROB(f26,f28,f30,f32,f34,f36,f38,f40,f42) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f42,f44,f46,f0, f2, f4, f6, f8, f10) STORE_JUMP(o0, f48, 410f) membar #Sync
+352: FREG_FROB(f42,f44,f46,f0, f2, f4, f6, f8, f10) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f10,f12,f14,f16,f18,f20,f22,f24,f26) STORE_JUMP(o0, f48, 426f) membar #Sync
+353: FREG_FROB(f10,f12,f14,f16,f18,f20,f22,f24,f26) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f26,f28,f30,f32,f34,f36,f38,f40,f42) STORE_JUMP(o0, f48, 442f) membar #Sync
+ VISLOOP_PAD
+360: FREG_FROB(f12,f14,f16,f18,f20,f22,f24,f26,f28) LOOP_CHUNK1(o1, o0, g7, 361f)
+ FREG_FROB(f28,f30,f32,f34,f36,f38,f40,f42,f44) LOOP_CHUNK2(o1, o0, g7, 362f)
+ FREG_FROB(f44,f46,f0, f2, f4, f6, f8, f10,f12) LOOP_CHUNK3(o1, o0, g7, 363f)
+ b,pt %xcc, 360b+4; faligndata %f12, %f14, %f48
+361: FREG_FROB(f28,f30,f32,f34,f36,f38,f40,f42,f44) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f44,f46,f0, f2, f4, f6, f8, f10,f12) STORE_JUMP(o0, f48, 412f) membar #Sync
+362: FREG_FROB(f44,f46,f0, f2, f4, f6, f8, f10,f12) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f12,f14,f16,f18,f20,f22,f24,f26,f28) STORE_JUMP(o0, f48, 428f) membar #Sync
+363: FREG_FROB(f12,f14,f16,f18,f20,f22,f24,f26,f28) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f28,f30,f32,f34,f36,f38,f40,f42,f44) STORE_JUMP(o0, f48, 444f) membar #Sync
+ VISLOOP_PAD
+370: FREG_FROB(f14,f16,f18,f20,f22,f24,f26,f28,f30) LOOP_CHUNK1(o1, o0, g7, 371f)
+ FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46) LOOP_CHUNK2(o1, o0, g7, 372f)
+ FREG_FROB(f46,f0, f2, f4, f6, f8, f10,f12,f14) LOOP_CHUNK3(o1, o0, g7, 373f)
+ b,pt %xcc, 370b+4; faligndata %f14, %f16, %f48
+371: FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f46,f0, f2, f4, f6, f8, f10,f12,f14) STORE_JUMP(o0, f48, 414f) membar #Sync
+372: FREG_FROB(f46,f0, f2, f4, f6, f8, f10,f12,f14) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f14,f16,f18,f20,f22,f24,f26,f28,f30) STORE_JUMP(o0, f48, 430f) membar #Sync
+373: FREG_FROB(f14,f16,f18,f20,f22,f24,f26,f28,f30) STORE_SYNC(o0, f48) membar #Sync
+ FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46) STORE_JUMP(o0, f48, 446f) membar #Sync
+ VISLOOP_PAD
+400: FINISH_VISCHUNK(o0, f0, f2, g3)
+402: FINISH_VISCHUNK(o0, f2, f4, g3)
+404: FINISH_VISCHUNK(o0, f4, f6, g3)
+406: FINISH_VISCHUNK(o0, f6, f8, g3)
+408: FINISH_VISCHUNK(o0, f8, f10, g3)
+410: FINISH_VISCHUNK(o0, f10, f12, g3)
+412: FINISH_VISCHUNK(o0, f12, f14, g3)
+414: UNEVEN_VISCHUNK(o0, f14, f0, g3)
+416: FINISH_VISCHUNK(o0, f16, f18, g3)
+418: FINISH_VISCHUNK(o0, f18, f20, g3)
+420: FINISH_VISCHUNK(o0, f20, f22, g3)
+422: FINISH_VISCHUNK(o0, f22, f24, g3)
+424: FINISH_VISCHUNK(o0, f24, f26, g3)
+426: FINISH_VISCHUNK(o0, f26, f28, g3)
+428: FINISH_VISCHUNK(o0, f28, f30, g3)
+430: UNEVEN_VISCHUNK(o0, f30, f0, g3)
+432: FINISH_VISCHUNK(o0, f32, f34, g3)
+434: FINISH_VISCHUNK(o0, f34, f36, g3)
+436: FINISH_VISCHUNK(o0, f36, f38, g3)
+438: FINISH_VISCHUNK(o0, f38, f40, g3)
+440: FINISH_VISCHUNK(o0, f40, f42, g3)
+442: FINISH_VISCHUNK(o0, f42, f44, g3)
+444: FINISH_VISCHUNK(o0, f44, f46, g3)
+446: UNEVEN_VISCHUNK(o0, f46, f0, g3)
+204: ldd [%o1], %f2 /* Load Group */
+ add %o1, 8, %o1 /* IEU0 */
+ subcc %g3, 8, %g3 /* IEU1 */
+ faligndata %f0, %f2, %f8 /* GRU Group */
+ std %f8, [%o0] /* Store */
+ bl,pn %xcc, 205f /* CTI */
+ add %o0, 8, %o0 /* IEU0 Group */
+ ldd [%o1], %f0 /* Load Group */
+ add %o1, 8, %o1 /* IEU0 */
+ subcc %g3, 8, %g3 /* IEU1 */
+ faligndata %f2, %f0, %f8 /* GRU Group */
+ std %f8, [%o0] /* Store */
+ bge,pt %xcc, 204b /* CTI */
+ add %o0, 8, %o0 /* IEU0 Group */
+205: brz,pt %o2, 207f /* CTI Group */
+ mov %g1, %o1 /* IEU0 */
+206: ldub [%o1], %g5 /* LOAD */
+ add %o1, 1, %o1 /* IEU0 */
+ add %o0, 1, %o0 /* IEU1 */
+ subcc %o2, 1, %o2 /* IEU1 */
+ bne,pt %xcc, 206b /* CTI */
+ stb %g5, [%o0 - 1] /* Store Group */
+207: membar #StoreLoad | #StoreStore /* LSU Group */
+ wr %g0, FPRS_FEF, %fprs
+ retl
+ mov %g4, %o0
+
+208: andcc %o2, 1, %g0 /* IEU1 Group */
+ be,pt %icc, 2f+4 /* CTI */
+1: ldub [%o1], %g5 /* LOAD Group */
+ add %o1, 1, %o1 /* IEU0 */
+ add %o0, 1, %o0 /* IEU1 */
+ subcc %o2, 1, %o2 /* IEU1 Group */
+ be,pn %xcc, 209f /* CTI */
+ stb %g5, [%o0 - 1] /* Store */
+2: ldub [%o1], %g5 /* LOAD Group */
+ add %o0, 2, %o0 /* IEU0 */
+ ldub [%o1 + 1], %o5 /* LOAD Group */
+ add %o1, 2, %o1 /* IEU0 */
+ subcc %o2, 2, %o2 /* IEU1 Group */
+ stb %g5, [%o0 - 2] /* Store */
+ bne,pt %xcc, 2b /* CTI */
+ stb %o5, [%o0 - 1] /* Store */
+209: retl
+ mov %g4, %o0
+
+ENTRY(memcpy)
+210:
+#ifndef USE_BPR
+ srl %o2, 0, %o2 /* IEU1 Group */
+#endif
+ brz,pn %o2, 209b /* CTI Group */
+ mov %o0, %g4 /* IEU0 */
+ cmp %o2, 15 /* IEU1 Group */
+ bleu,pn %xcc, 208b /* CTI */
+ cmp %o2, (64 * 6) /* IEU1 Group */
+ bgeu,pn %xcc, 200b /* CTI */
+ andcc %o0, 7, %g2 /* IEU1 Group */
+ sub %o0, %o1, %g5 /* IEU0 */
+ andcc %g5, 3, %o5 /* IEU1 Group */
+ bne,pn %xcc, 212f /* CTI */
+ andcc %o1, 3, %g0 /* IEU1 Group */
+ be,a,pt %xcc, 3f /* CTI */
+ andcc %o1, 4, %g0 /* IEU1 Group */
+ andcc %o1, 1, %g0 /* IEU1 Group */
+ be,pn %xcc, 4f /* CTI */
+ andcc %o1, 2, %g0 /* IEU1 Group */
+ ldub [%o1], %g2 /* Load Group */
+ add %o1, 1, %o1 /* IEU0 */
+ add %o0, 1, %o0 /* IEU1 */
+ sub %o2, 1, %o2 /* IEU0 Group */
+ bne,pn %xcc, 5f /* CTI Group */
+ stb %g2, [%o0 - 1] /* Store */
+4: lduh [%o1], %g2 /* Load Group */
+ add %o1, 2, %o1 /* IEU0 */
+ add %o0, 2, %o0 /* IEU1 */
+ sub %o2, 2, %o2 /* IEU0 */
+ sth %g2, [%o0 - 2] /* Store Group + bubble */
+5: andcc %o1, 4, %g0 /* IEU1 */
+3: be,a,pn %xcc, 2f /* CTI */
+ andcc %o2, -128, %g7 /* IEU1 Group */
+ lduw [%o1], %g5 /* Load Group */
+ add %o1, 4, %o1 /* IEU0 */
+ add %o0, 4, %o0 /* IEU1 */
+ sub %o2, 4, %o2 /* IEU0 Group */
+ stw %g5, [%o0 - 4] /* Store */
+ andcc %o2, -128, %g7 /* IEU1 Group */
+2: be,pn %xcc, 3f /* CTI */
+ andcc %o0, 4, %g0 /* IEU1 Group */
+ be,pn %xcc, 82f + 4 /* CTI Group */
+5: MOVE_BIGCHUNK(o1, o0, 0x00, g1, g3, g5, o5)
+ MOVE_BIGCHUNK(o1, o0, 0x20, g1, g3, g5, o5)
+ MOVE_BIGCHUNK(o1, o0, 0x40, g1, g3, g5, o5)
+ MOVE_BIGCHUNK(o1, o0, 0x60, g1, g3, g5, o5)
+35: subcc %g7, 128, %g7 /* IEU1 Group */
+ add %o1, 128, %o1 /* IEU0 */
+ bne,pt %xcc, 5b /* CTI */
+ add %o0, 128, %o0 /* IEU0 Group */
+3: andcc %o2, 0x70, %g7 /* IEU1 Group */
+41: be,pn %xcc, 80f /* CTI */
+ andcc %o2, 8, %g0 /* IEU1 Group */
+ /* Clk1 8-( */
+ /* Clk2 8-( */
+ /* Clk3 8-( */
+ /* Clk4 8-( */
+79: rd %pc, %o5 /* PDU Group */
+ sll %g7, 1, %g5 /* IEU0 Group */
+ add %o1, %g7, %o1 /* IEU1 */
+ sub %o5, %g5, %o5 /* IEU0 Group */
+ jmpl %o5 + %lo(80f - 79b), %g0 /* CTI Group brk forced*/
+ add %o0, %g7, %o0 /* IEU0 Group */
+36: MOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g5, o5)
+ MOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g5, o5)
+ MOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g5, o5)
+ MOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g5, o5)
+ MOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g5, o5)
+ MOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g5, o5)
+ MOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g5, o5)
+80: be,pt %xcc, 81f /* CTI */
+ andcc %o2, 4, %g0 /* IEU1 */
+ ldx [%o1], %g2 /* Load Group */
+ add %o0, 8, %o0 /* IEU0 */
+ stw %g2, [%o0 - 0x4] /* Store Group */
+ add %o1, 8, %o1 /* IEU1 */
+ srlx %g2, 32, %g2 /* IEU0 Group */
+ stw %g2, [%o0 - 0x8] /* Store */
+81: be,pt %xcc, 1f /* CTI */
+ andcc %o2, 2, %g0 /* IEU1 Group */
+ lduw [%o1], %g2 /* Load Group */
+ add %o1, 4, %o1 /* IEU0 */
+ stw %g2, [%o0] /* Store Group */
+ add %o0, 4, %o0 /* IEU0 */
+1: be,pt %xcc, 1f /* CTI */
+ andcc %o2, 1, %g0 /* IEU1 Group */
+ lduh [%o1], %g2 /* Load Group */
+ add %o1, 2, %o1 /* IEU0 */
+ sth %g2, [%o0] /* Store Group */
+ add %o0, 2, %o0 /* IEU0 */
+1: be,pt %xcc, 211f /* CTI */
+ nop /* IEU1 */
+ ldub [%o1], %g2 /* Load Group */
+ stb %g2, [%o0] /* Store Group + bubble */
+211: retl
+ mov %g4, %o0
+
+82: MOVE_BIGALIGNCHUNK(o1, o0, 0x00, g1, g3, g5, o5)
+ MOVE_BIGALIGNCHUNK(o1, o0, 0x40, g1, g3, g5, o5)
+37: subcc %g7, 128, %g7 /* IEU1 Group */
+ add %o1, 128, %o1 /* IEU0 */
+ bne,pt %xcc, 82b /* CTI */
+ add %o0, 128, %o0 /* IEU0 Group */
+ andcc %o2, 0x70, %g7 /* IEU1 */
+ be,pn %xcc, 84f /* CTI */
+ andcc %o2, 8, %g0 /* IEU1 Group */
+ /* Clk1 8-( */
+ /* Clk2 8-( */
+ /* Clk3 8-( */
+ /* Clk4 8-( */
+83: rd %pc, %o5 /* PDU Group */
+ add %o1, %g7, %o1 /* IEU0 Group */
+ sub %o5, %g7, %o5 /* IEU1 */
+ jmpl %o5 + %lo(84f - 83b), %g0 /* CTI Group brk forced*/
+ add %o0, %g7, %o0 /* IEU0 Group */
+38: MOVE_LASTALIGNCHUNK(o1, o0, 0x60, g2, g3)
+ MOVE_LASTALIGNCHUNK(o1, o0, 0x50, g2, g3)
+ MOVE_LASTALIGNCHUNK(o1, o0, 0x40, g2, g3)
+ MOVE_LASTALIGNCHUNK(o1, o0, 0x30, g2, g3)
+ MOVE_LASTALIGNCHUNK(o1, o0, 0x20, g2, g3)
+ MOVE_LASTALIGNCHUNK(o1, o0, 0x10, g2, g3)
+ MOVE_LASTALIGNCHUNK(o1, o0, 0x00, g2, g3)
+84: be,pt %xcc, 85f /* CTI Group */
+ andcc %o2, 4, %g0 /* IEU1 */
+ ldx [%o1], %g2 /* Load Group */
+ add %o0, 8, %o0 /* IEU0 */
+ add %o1, 8, %o1 /* IEU0 Group */
+ stx %g2, [%o0 - 0x8] /* Store */
+85: be,pt %xcc, 1f /* CTI */
+ andcc %o2, 2, %g0 /* IEU1 Group */
+ lduw [%o1], %g2 /* Load Group */
+ add %o0, 4, %o0 /* IEU0 */
+ add %o1, 4, %o1 /* IEU0 Group */
+ stw %g2, [%o0 - 0x4] /* Store */
+1: be,pt %xcc, 1f /* CTI */
+ andcc %o2, 1, %g0 /* IEU1 Group */
+ lduh [%o1], %g2 /* Load Group */
+ add %o0, 2, %o0 /* IEU0 */
+ add %o1, 2, %o1 /* IEU0 Group */
+ sth %g2, [%o0 - 0x2] /* Store */
+1: be,pt %xcc, 1f /* CTI */
+ nop /* IEU0 Group */
+ ldub [%o1], %g2 /* Load Group */
+ stb %g2, [%o0] /* Store Group + bubble */
+1: retl
+ mov %g4, %o0
+
+212: brz,pt %g2, 2f /* CTI Group */
+ mov 8, %g1 /* IEU0 */
+ sub %g1, %g2, %g2 /* IEU0 Group */
+ sub %o2, %g2, %o2 /* IEU0 Group */
+1: ldub [%o1], %g5 /* Load Group */
+ add %o1, 1, %o1 /* IEU0 */
+ add %o0, 1, %o0 /* IEU1 */
+ subcc %g2, 1, %g2 /* IEU1 Group */
+ bne,pt %xcc, 1b /* CTI */
+ stb %g5, [%o0 - 1] /* Store */
+2: andn %o2, 7, %g5 /* IEU0 Group */
+ and %o2, 7, %o2 /* IEU1 */
+ fmovd %f0, %f2 /* FPU */
+ alignaddr %o1, %g0, %g1 /* GRU Group */
+ ldd [%g1], %f4 /* Load Group */
+1: ldd [%g1 + 0x8], %f6 /* Load Group */
+ add %g1, 0x8, %g1 /* IEU0 Group */
+ subcc %g5, 8, %g5 /* IEU1 */
+ faligndata %f4, %f6, %f0 /* GRU Group */
+ std %f0, [%o0] /* Store */
+ add %o1, 8, %o1 /* IEU0 Group */
+ be,pn %xcc, 213f /* CTI */
+ add %o0, 8, %o0 /* IEU1 */
+ ldd [%g1 + 0x8], %f4 /* Load Group */
+ add %g1, 8, %g1 /* IEU0 */
+ subcc %g5, 8, %g5 /* IEU1 */
+ faligndata %f6, %f4, %f0 /* GRU Group */
+ std %f0, [%o0] /* Store */
+ add %o1, 8, %o1 /* IEU0 */
+ bne,pn %xcc, 1b /* CTI Group */
+ add %o0, 8, %o0 /* IEU0 */
+213: brz,pn %o2, 214f /* CTI Group */
+ nop /* IEU0 */
+ ldub [%o1], %g5 /* LOAD */
+ add %o1, 1, %o1 /* IEU0 */
+ add %o0, 1, %o0 /* IEU1 */
+ subcc %o2, 1, %o2 /* IEU1 */
+ bne,pt %xcc, 206b /* CTI */
+ stb %g5, [%o0 - 1] /* Store Group */
+214: wr %g0, FPRS_FEF, %fprs
+ retl
+ mov %g4, %o0
+END(memcpy)
diff --git a/sysdeps/sparc/sparc64/memset.S b/sysdeps/sparc/sparc64/memset.S
new file mode 100644
index 0000000000..8106a5c999
--- /dev/null
+++ b/sysdeps/sparc/sparc64/memset.S
@@ -0,0 +1,316 @@
+/* Set a block of memory to some byte value.
+ For UltraSPARC.
+ Copyright (C) 1996, 97, 98, 99 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David S. Miller (davem@caip.rutgers.edu) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <asm/asi.h>
+#ifndef XCC
+#define XCC xcc
+#define USE_BPR
+#endif
+#define FPRS_FEF 4
+
+#define SET_BLOCKS(base, offset, source) \
+ stx source, [base - offset - 0x18]; \
+ stx source, [base - offset - 0x10]; \
+ stx source, [base - offset - 0x08]; \
+ stx source, [base - offset - 0x00];
+
+ /* Well, memset is a lot easier to get right than bcopy... */
+ .text
+ .align 32
+ENTRY(memset)
+#ifndef USE_BPR
+ srl %o1, 0, %o1
+ mov %o0, %g3
+#endif
+ brz,a,pt %o1, 50f
+#ifndef USE_BPR
+ srl %o2, 0, %o1
+#else
+ mov %o2, %o1
+#endif
+ cmp %o2, 7
+#ifndef USE_BPR
+ srl %o2, 0, %o2
+#endif
+ bleu,pn %XCC, 17f
+ andcc %o0, 3, %g5
+ be,pt %xcc, 4f
+ and %o1, 0xff, %o1
+ cmp %g5, 3
+ be,pn %xcc, 2f
+ stb %o1, [%o0 + 0x00]
+ cmp %g5, 2
+ be,pt %xcc, 2f
+ stb %o1, [%o0 + 0x01]
+ stb %o1, [%o0 + 0x02]
+2: sub %g5, 4, %g5
+ sub %o0, %g5, %o0
+ add %o2, %g5, %o2
+4: sllx %o1, 8, %g1
+ andcc %o0, 4, %g0
+ or %o1, %g1, %o1
+ sllx %o1, 16, %g1
+ or %o1, %g1, %o1
+ be,pt %xcc, 2f
+ sllx %o1, 32, %g1
+ stw %o1, [%o0]
+ sub %o2, 4, %o2
+ add %o0, 4, %o0
+2: cmp %o2, 128
+ or %o1, %g1, %o1
+ blu,pn %xcc, 9f
+ andcc %o0, 0x38, %g5
+ be,pn %icc, 6f
+ mov 64, %o5
+ andcc %o0, 8, %g0
+ be,pn %icc, 1f
+ sub %o5, %g5, %o5
+ stx %o1, [%o0]
+ add %o0, 8, %o0
+1: andcc %o5, 16, %g0
+ be,pn %icc, 1f
+ sub %o2, %o5, %o2
+ stx %o1, [%o0]
+ stx %o1, [%o0 + 8]
+ add %o0, 16, %o0
+1: andcc %o5, 32, %g0
+ be,pn %icc, 7f
+ andncc %o2, 0x3f, %o3
+ stw %o1, [%o0]
+ stw %o1, [%o0 + 4]
+ stw %o1, [%o0 + 8]
+ stw %o1, [%o0 + 12]
+ stw %o1, [%o0 + 16]
+ stw %o1, [%o0 + 20]
+ stw %o1, [%o0 + 24]
+ stw %o1, [%o0 + 28]
+ add %o0, 32, %o0
+7: be,pn %xcc, 9f
+ nop
+ ldd [%o0 - 8], %f0
+18: wr %g0, ASI_BLK_P, %asi
+ membar #StoreStore | #LoadStore
+ andcc %o3, 0xc0, %g5
+ and %o2, 0x3f, %o2
+ fmovd %f0, %f2
+ fmovd %f0, %f4
+ andn %o3, 0xff, %o3
+ fmovd %f0, %f6
+ cmp %g5, 64
+ fmovd %f0, %f8
+ fmovd %f0, %f10
+ fmovd %f0, %f12
+ brz,pn %g5, 10f
+ fmovd %f0, %f14
+ be,pn %icc, 2f
+ stda %f0, [%o0 + 0x00] %asi
+ cmp %g5, 128
+ be,pn %icc, 2f
+ stda %f0, [%o0 + 0x40] %asi
+ stda %f0, [%o0 + 0x80] %asi
+2: brz,pn %o3, 12f
+ add %o0, %g5, %o0
+10: stda %f0, [%o0 + 0x00] %asi
+ stda %f0, [%o0 + 0x40] %asi
+ stda %f0, [%o0 + 0x80] %asi
+ stda %f0, [%o0 + 0xc0] %asi
+11: subcc %o3, 256, %o3
+ bne,pt %xcc, 10b
+ add %o0, 256, %o0
+12: wr %g0, FPRS_FEF, %fprs
+ membar #StoreLoad | #StoreStore
+9: andcc %o2, 0x78, %g5
+ be,pn %xcc, 13f
+ andcc %o2, 7, %o2
+14: rd %pc, %o4
+ srl %g5, 1, %o3
+ sub %o4, %o3, %o4
+ jmpl %o4 + (13f - 14b), %g0
+ add %o0, %g5, %o0
+12: SET_BLOCKS (%o0, 0x68, %o1)
+ SET_BLOCKS (%o0, 0x48, %o1)
+ SET_BLOCKS (%o0, 0x28, %o1)
+ SET_BLOCKS (%o0, 0x08, %o1)
+13: be,pn %xcc, 8f
+ andcc %o2, 4, %g0
+ be,pn %xcc, 1f
+ andcc %o2, 2, %g0
+ stw %o1, [%o0]
+ add %o0, 4, %o0
+1: be,pn %xcc, 1f
+ andcc %o2, 1, %g0
+ sth %o1, [%o0]
+ add %o0, 2, %o0
+1: bne,a,pn %xcc, 8f
+ stb %o1, [%o0]
+8: retl
+ mov %g3, %o0
+17: brz,pn %o2, 0f
+8: add %o0, 1, %o0
+ subcc %o2, 1, %o2
+ bne,pt %xcc, 8b
+ stb %o1, [%o0 - 1]
+0: retl
+ mov %g3, %o0
+
+6: stx %o1, [%o0]
+ andncc %o2, 0x3f, %o3
+ be,pn %xcc, 9b
+ nop
+ ba,pt %xcc, 18b
+ ldd [%o0], %f0
+END(memset)
+
+#define ZERO_BLOCKS(base, offset, source) \
+ stx source, [base - offset - 0x38]; \
+ stx source, [base - offset - 0x30]; \
+ stx source, [base - offset - 0x28]; \
+ stx source, [base - offset - 0x20]; \
+ stx source, [base - offset - 0x18]; \
+ stx source, [base - offset - 0x10]; \
+ stx source, [base - offset - 0x08]; \
+ stx source, [base - offset - 0x00];
+
+ .text
+ .align 32
+ENTRY(__bzero)
+#ifndef USE_BPR
+ srl %o1, 0, %o1
+#endif
+ mov %o0, %g3
+50: cmp %o1, 7
+ bleu,pn %xcc, 17f
+ andcc %o0, 3, %o2
+ be,a,pt %xcc, 4f
+ andcc %o0, 4, %g0
+ cmp %o2, 3
+ be,pn %xcc, 2f
+ stb %g0, [%o0 + 0x00]
+ cmp %o2, 2
+ be,pt %xcc, 2f
+ stb %g0, [%o0 + 0x01]
+ stb %g0, [%o0 + 0x02]
+2: sub %o2, 4, %o2
+ sub %o0, %o2, %o0
+ add %o1, %o2, %o1
+ andcc %o0, 4, %g0
+4: be,pt %xcc, 2f
+ cmp %o1, 128
+ stw %g0, [%o0]
+ sub %o1, 4, %o1
+ add %o0, 4, %o0
+2: blu,pn %xcc, 9f
+ andcc %o0, 0x38, %o2
+ be,pn %icc, 6f
+ mov 64, %o5
+ andcc %o0, 8, %g0
+ be,pn %icc, 1f
+ sub %o5, %o2, %o5
+ stx %g0, [%o0]
+ add %o0, 8, %o0
+1: andcc %o5, 16, %g0
+ be,pn %icc, 1f
+ sub %o1, %o5, %o1
+ stx %g0, [%o0]
+ stx %g0, [%o0 + 8]
+ add %o0, 16, %o0
+1: andcc %o5, 32, %g0
+ be,pn %icc, 7f
+ andncc %o1, 0x3f, %o3
+ stx %g0, [%o0]
+ stx %g0, [%o0 + 8]
+ stx %g0, [%o0 + 16]
+ stx %g0, [%o0 + 24]
+ add %o0, 32, %o0
+6: andncc %o1, 0x3f, %o3
+7: be,pn %xcc, 9f
+ wr %g0, ASI_BLK_P, %asi
+ membar #StoreLoad | #StoreStore | #LoadStore
+ fzero %f0
+ andcc %o3, 0xc0, %o2
+ and %o1, 0x3f, %o1
+ fzero %f2
+ andn %o3, 0xff, %o3
+ faddd %f0, %f2, %f4
+ fmuld %f0, %f2, %f6
+ cmp %o2, 64
+ faddd %f0, %f2, %f8
+ fmuld %f0, %f2, %f10
+ faddd %f0, %f2, %f12
+ brz,pn %o2, 10f
+ fmuld %f0, %f2, %f14
+ be,pn %icc, 2f
+ stda %f0, [%o0 + 0x00] %asi
+ cmp %o2, 128
+ be,pn %icc, 2f
+ stda %f0, [%o0 + 0x40] %asi
+ stda %f0, [%o0 + 0x80] %asi
+2: brz,pn %o3, 12f
+ add %o0, %o2, %o0
+10: stda %f0, [%o0 + 0x00] %asi
+ stda %f0, [%o0 + 0x40] %asi
+ stda %f0, [%o0 + 0x80] %asi
+ stda %f0, [%o0 + 0xc0] %asi
+11: subcc %o3, 256, %o3
+ bne,pt %xcc, 10b
+ add %o0, 256, %o0
+12: wr %g0, FPRS_FEF, %fprs
+ membar #StoreLoad | #StoreStore
+9: andcc %o1, 0xf8, %o2
+ be,pn %xcc, 13f
+ andcc %o1, 7, %o1
+14: rd %pc, %o4
+ srl %o2, 1, %o3
+ sub %o4, %o3, %o4
+ jmpl %o4 + (13f - 14b), %g0
+ add %o0, %o2, %o0
+12: ZERO_BLOCKS (%o0, 0xc8, %g0)
+ ZERO_BLOCKS (%o0, 0x88, %g0)
+ ZERO_BLOCKS (%o0, 0x48, %g0)
+ ZERO_BLOCKS (%o0, 0x08, %g0)
+13: be,pn %xcc, 8f
+ andcc %o1, 4, %g0
+ be,pn %xcc, 1f
+ andcc %o1, 2, %g0
+ stw %g0, [%o0]
+ add %o0, 4, %o0
+1: be,pn %xcc, 1f
+ andcc %o1, 1, %g0
+ sth %g0, [%o0]
+ add %o0, 2, %o0
+1: bne,a,pn %xcc, 8f
+ stb %g0, [%o0]
+8: retl
+ mov %g3, %o0
+17: be,pn %xcc, 13b
+ orcc %o1, 0, %g0
+ be,pn %xcc, 0f
+8: add %o0, 1, %o0
+ subcc %o1, 1, %o1
+ bne,pt %xcc, 8b
+ stb %g0, [%o0 - 1]
+0: retl
+ mov %g3, %o0
+END(__bzero)
+
+weak_alias(__bzero, bzero)
diff --git a/sysdeps/sparc/sparc64/stpcpy.S b/sysdeps/sparc/sparc64/stpcpy.S
new file mode 100644
index 0000000000..1dd48e701a
--- /dev/null
+++ b/sysdeps/sparc/sparc64/stpcpy.S
@@ -0,0 +1,268 @@
+/* Copy SRC to DEST returning the address of the terminating '\0' in DEST.
+ For SPARC v9.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz> and
+ Jakub Jelinek <jj@ultra.linux.cz>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <asm/asi.h>
+
+ /* Normally, this uses
+ ((xword - 0x0101010101010101) & 0x8080808080808080) test
+ to find out if any byte in xword could be zero. This is fast, but
+ also gives false alarm for any byte in range 0x81-0xff. It does
+ not matter for correctness, as if this test tells us there could
+ be some zero byte, we check it byte by byte, but if bytes with
+ high bits set are common in the strings, then this will give poor
+ performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
+ will use one tick slower, but more precise test
+ ((xword - 0x0101010101010101) & (~xword) & 0x8080808080808080),
+ which does not give any false alarms (but if some bits are set,
+ one cannot assume from it which bytes are zero and which are not).
+ It is yet to be measured, what is the correct default for glibc
+ in these days for an average user.
+ */
+
+ .text
+ .align 32
+ENTRY(__stpcpy)
+ sethi %hi(0x01010101), %g1 /* IEU0 Group */
+ or %g1, %lo(0x01010101), %g1 /* IEU0 Group */
+ andcc %o0, 7, %g0 /* IEU1 */
+ sllx %g1, 32, %g2 /* IEU0 Group */
+
+ bne,pn %icc, 12f /* CTI */
+ andcc %o1, 7, %g3 /* IEU1 */
+ or %g1, %g2, %g1 /* IEU0 Group */
+ bne,pn %icc, 14f /* CTI */
+
+ sllx %g1, 7, %g2 /* IEU0 Group */
+1: ldx [%o1], %o3 /* Load */
+ add %o1, 8, %o1 /* IEU1 */
+2: mov %o3, %g3 /* IEU0 Group */
+
+ sub %o3, %g1, %o2 /* IEU1 */
+3: ldxa [%o1] ASI_PNF, %o3 /* Load */
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o2, %g3, %o2 /* IEU0 Group */
+#endif
+ add %o0, 8, %o0 /* IEU0 Group */
+ andcc %o2, %g2, %g0 /* IEU1 */
+
+ add %o1, 8, %o1 /* IEU0 Group */
+ be,a,pt %xcc, 2b /* CTI */
+ stx %g3, [%o0 - 8] /* Store */
+ srlx %g3, 56, %g5 /* IEU0 Group */
+
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 11f /* CTI */
+ srlx %g3, 48, %g4 /* IEU0 */
+ andcc %g4, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 10f /* CTI */
+ srlx %g3, 40, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 9f /* CTI */
+
+ srlx %g3, 32, %g4 /* IEU0 */
+ andcc %g4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 8f /* CTI */
+ srlx %g3, 24, %g5 /* IEU0 */
+
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 7f /* CTI */
+ srlx %g3, 16, %g4 /* IEU0 */
+ andcc %g4, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 6f /* CTI */
+ srlx %g3, 8, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 5f /* CTI */
+
+ sub %o3, %g1, %o2 /* IEU0 */
+ stx %g3, [%o0 - 8] /* Store Group */
+ andcc %g3, 0xff, %g0 /* IEU1 */
+ bne,pt %icc, 3b /* CTI */
+
+ mov %o3, %g3 /* IEU0 Group */
+4: retl /* CTI+IEU1 Group */
+ sub %o0, 1, %o0 /* IEU0 */
+
+ .align 16
+6: ba,pt %xcc, 23f /* CTI Group */
+ sub %o0, 3, %g7 /* IEU0 */
+5: sub %o0, 2, %g7 /* IEU0 Group */
+ stb %g5, [%o0 - 2] /* Store */
+
+ srlx %g3, 16, %g4 /* IEU0 Group */
+23: sth %g4, [%o0 - 4] /* Store */
+ srlx %g3, 32, %g4 /* IEU0 Group */
+ stw %g4, [%o0 - 8] /* Store */
+
+ retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+8: ba,pt %xcc, 24f /* CTI Group */
+ sub %o0, 5, %g7 /* IEU0 */
+
+7: sub %o0, 4, %g7 /* IEU0 Group */
+ stb %g5, [%o0 - 4] /* Store */
+ srlx %g3, 32, %g4 /* IEU0 Group */
+24: stw %g4, [%o0 - 8] /* Store */
+
+ retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+10: ba,pt %xcc, 25f /* CTI Group */
+ sub %o0, 7, %g7 /* IEU0 */
+
+9: sub %o0, 6, %g7 /* IEU0 Group */
+ stb %g5, [%o0 - 6] /* Store */
+ srlx %g3, 48, %g4 /* IEU0 */
+25: sth %g4, [%o0 - 8] /* Store Group */
+
+ retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+11: stb %g5, [%o0 - 8] /* Store Group */
+ retl /* CTI+IEU1 Group */
+
+ sub %o0, 8, %o0 /* IEU0 */
+
+ .align 16
+12: or %g1, %g2, %g1 /* IEU0 Group */
+ ldub [%o1], %o3 /* Load */
+ sllx %g1, 7, %g2 /* IEU0 Group */
+ stb %o3, [%o0] /* Store Group */
+
+13: add %o0, 1, %o0 /* IEU0 */
+ add %o1, 1, %o1 /* IEU1 */
+ andcc %o3, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4b /* CTI */
+
+ lduba [%o1] ASI_PNF, %o3 /* Load */
+ andcc %o0, 7, %g0 /* IEU1 Group */
+ bne,a,pt %icc, 13b /* CTI */
+ stb %o3, [%o0] /* Store */
+
+ andcc %o1, 7, %g3 /* IEU1 Group */
+ be,a,pt %icc, 1b /* CTI */
+ ldx [%o1], %o3 /* Load */
+14: orcc %g0, 64, %g4 /* IEU1 Group */
+
+ sllx %g3, 3, %g5 /* IEU0 */
+ sub %o1, %g3, %o1 /* IEU0 Group */
+ sub %g4, %g5, %g4 /* IEU1 */
+ /* %g1 = 0101010101010101 *
+ * %g2 = 8080808080808080 *
+ * %g3 = source alignment *
+ * %g5 = number of bits to shift left *
+ * %g4 = number of bits to shift right */
+ ldxa [%o1] ASI_PNF, %o5 /* Load Group */
+
+ addcc %o1, 8, %o1 /* IEU1 */
+15: sllx %o5, %g5, %o3 /* IEU0 Group */
+ ldxa [%o1] ASI_PNF, %o5 /* Load */
+ srlx %o5, %g4, %o4 /* IEU0 Group */
+
+ add %o0, 8, %o0 /* IEU1 */
+ or %o3, %o4, %o3 /* IEU0 Group */
+ add %o1, 8, %o1 /* IEU1 */
+ sub %o3, %g1, %o4 /* IEU0 Group */
+
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o4, %o3, %o4 /* IEU0 Group */
+#endif
+ andcc %o4, %g2, %g0 /* IEU1 Group */
+ be,a,pt %xcc, 15b /* CTI */
+ stx %o3, [%o0 - 8] /* Store */
+ srlx %o3, 56, %o4 /* IEU0 Group */
+
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 22f /* CTI */
+ srlx %o3, 48, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 21f /* CTI */
+ srlx %o3, 40, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 20f /* CTI */
+
+ srlx %o3, 32, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 19f /* CTI */
+ srlx %o3, 24, %o4 /* IEU0 */
+
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 18f /* CTI */
+ srlx %o3, 16, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 17f /* CTI */
+ srlx %o3, 8, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 16f /* CTI */
+
+ andcc %o3, 0xff, %g0 /* IEU1 Group */
+ bne,pn %icc, 15b /* CTI */
+ stx %o3, [%o0 - 8] /* Store */
+ retl /* CTI+IEU1 Group */
+
+ sub %o0, 1, %o0 /* IEU0 */
+
+ .align 16
+17: ba,pt %xcc, 26f /* CTI Group */
+ subcc %o0, 3, %g7 /* IEU1 */
+18: ba,pt %xcc, 27f /* CTI Group */
+ subcc %o0, 4, %g7 /* IEU1 */
+
+19: ba,pt %xcc, 28f /* CTI Group */
+ subcc %o0, 5, %g7 /* IEU1 */
+16: subcc %o0, 2, %g7 /* IEU1 Group */
+ srlx %o3, 8, %o4 /* IEU0 */
+
+ stb %o4, [%o0 - 2] /* Store */
+26: srlx %o3, 16, %o4 /* IEU0 Group */
+ stb %o4, [%o0 - 3] /* Store */
+27: srlx %o3, 24, %o4 /* IEU0 Group */
+
+ stb %o4, [%o0 - 4] /* Store */
+28: srlx %o3, 32, %o4 /* IEU0 Group */
+ stw %o4, [%o0 - 8] /* Store */
+ retl /* CTI+IEU1 Group */
+
+ mov %g7, %o0 /* IEU0 */
+
+ .align 16
+21: ba,pt %xcc, 29f /* CTI Group */
+ subcc %o0, 7, %g7 /* IEU1 */
+22: ba,pt %xcc, 30f /* CTI Group */
+ subcc %o0, 8, %g7 /* IEU1 */
+
+20: subcc %o0, 6, %g7 /* IEU1 Group */
+ srlx %o3, 40, %o4 /* IEU0 */
+ stb %o4, [%o0 - 6] /* Store */
+29: srlx %o3, 48, %o4 /* IEU0 Group */
+
+ stb %o4, [%o0 - 7] /* Store */
+30: srlx %o3, 56, %o4 /* IEU0 Group */
+ stb %o4, [%o0 - 8] /* Store */
+ retl /* CTI+IEU1 Group */
+
+ mov %g7, %o0 /* IEU0 */
+END(__stpcpy)
+
+weak_alias (__stpcpy, stpcpy)
diff --git a/sysdeps/sparc/sparc64/stpncpy.S b/sysdeps/sparc/sparc64/stpncpy.S
new file mode 100644
index 0000000000..ee1a935d3e
--- /dev/null
+++ b/sysdeps/sparc/sparc64/stpncpy.S
@@ -0,0 +1,421 @@
+/* stpncpy(DST, SRC, COUNT) - Copy no more than N characters of
+ SRC to DEST, returning the address of the terminating '\0' in
+ DEST, if any, or else DEST + N.
+ For SPARC v9.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jj@ultra.linux.cz> and
+ Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <asm/asi.h>
+#ifndef XCC
+#define XCC xcc
+#define USE_BPR
+#endif
+
+ /* Normally, this uses
+ ((xword - 0x0101010101010101) & 0x8080808080808080) test
+ to find out if any byte in xword could be zero. This is fast, but
+ also gives false alarm for any byte in range 0x81-0xff. It does
+ not matter for correctness, as if this test tells us there could
+ be some zero byte, we check it byte by byte, but if bytes with
+ high bits set are common in the strings, then this will give poor
+ performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
+ will use one tick slower, but more precise test
+ ((xword - 0x0101010101010101) & (~xword) & 0x8080808080808080),
+ which does not give any false alarms (but if some bits are set,
+ one cannot assume from it which bytes are zero and which are not).
+ It is yet to be measured, what is the correct default for glibc
+ in these days for an average user.
+ */
+
+ .text
+ .align 32
+ENTRY(__stpncpy)
+ sethi %hi(0x01010101), %g1 /* IEU0 Group */
+#ifdef USE_BPR
+ brz,pn %o2, 19f /* CTI+IEU1 */
+#else
+ tst %o2 /* IEU1 */
+ be,pn %XCC, 19f /* CTI */
+#endif
+ or %g1, %lo(0x01010101), %g1 /* IEU1 */
+ andcc %o0, 7, %g0 /* IEU1 Group */
+
+ sllx %g1, 32, %g2 /* IEU0 */
+ bne,pn %icc, 26f /* CTI */
+ or %g1, %g2, %g1 /* IEU0 Group */
+ andcc %o1, 7, %g3 /* IEU1 */
+
+ bne,pn %icc, 28f /* CTI */
+ sllx %g1, 7, %g2 /* IEU0 Group */
+ ldx [%o1], %o3 /* Load */
+1: add %o1, 8, %o1 /* IEU1 */
+
+2: subcc %o2, 8, %o2 /* IEU1 Group */
+ bl,pn %XCC, 18f /* CTI */
+ sub %o3, %g1, %o4 /* IEU0 */
+ add %o0, 8, %o0 /* IEU0 Group */
+
+#ifdef EIGHTBIT_NOT_MORE
+ andn %o4, %o3, %o4 /* IEU1 */
+#endif
+ mov %o3, %g3 /* IEU1 */
+ ldxa [%o1] ASI_PNF, %o3 /* Load */
+ add %o1, 8, %o1 /* IEU0 Group */
+ andcc %o4, %g2, %g0 /* IEU1 */
+
+ be,a,pt %xcc, 2b /* CTI */
+ stx %g3, [%o0-8] /* Store Group */
+ srlx %g3, 56, %g5 /* IEU0 Group */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 16f /* CTI */
+ srlx %g3, 48, %g4 /* IEU0 */
+ andcc %g4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 15f /* CTI */
+
+ srlx %g3, 40, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 14f /* CTI */
+ srlx %g3, 32, %g4 /* IEU0 */
+
+ andcc %g4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 13f /* CTI */
+ srlx %g3, 24, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 12f /* CTI */
+ srlx %g3, 16, %g4 /* IEU0 */
+ andcc %g4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 11f /* CTI */
+
+ srlx %g3, 8, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 10f /* CTI */
+ sub %o0, 1, %g7 /* IEU0 */
+
+ andcc %g3, 0xff, %g0 /* IEU1 Group */
+ bne,pt %icc, 2b /* CTI */
+3: stx %g3, [%o0-8] /* Store */
+ andncc %o2, 31, %g3 /* IEU1 Group */
+
+4: be,pn %XCC, 41f /* CTI */
+ and %o2, 31, %o2 /* IEU1 Group */
+40: stx %g0, [%o0] /* Store */
+ stx %g0, [%o0 + 8] /* Store Group */
+
+ subcc %g3, 32, %g3 /* IEU1 */
+ stx %g0, [%o0 + 16] /* Store Group */
+ stx %g0, [%o0 + 24] /* Store Group */
+ bne,pt %XCC, 40b /* CTI */
+
+ add %o0, 32, %o0 /* IEU0 */
+41: subcc %o2, 8, %o2 /* IEU1 Group */
+ bl,a,pn %XCC, 6f /* CTI */
+ andcc %o2, 4, %g0 /* IEU1 Group */
+
+5: stx %g0, [%o0] /* Store */
+ subcc %o2, 8, %o2 /* IEU1 Group */
+ bge,pt %XCC, 5b /* CTI */
+ add %o0, 8, %o0 /* IEU0 */
+
+ andcc %o2, 4, %g0 /* IEU1 Group */
+6: be,a,pn %icc, 7f /* CTI */
+ andcc %o2, 2, %g0 /* IEU1 Group */
+ stw %g0, [%o0] /* Store */
+
+ add %o0, 4, %o0 /* IEU0 */
+ andcc %o2, 2, %g0 /* IEU1 Group */
+7: be,a,pn %icc, 8f /* CTI */
+ andcc %o2, 1, %g0 /* IEU1 Group */
+
+ sth %g0, [%o0] /* Store */
+ add %o0, 2, %o0 /* IEU0 */
+ andcc %o2, 1, %g0 /* IEU1 Group */
+8: bne,a,pn %icc, 9f /* CTI */
+
+ stb %g0, [%o0] /* Store */
+9: retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+10: subcc %o0, 2, %g7 /* IEU1 Group */
+
+ ba,pt %xcc, 3b /* CTI */
+ sllx %g5, 8, %g3 /* IEU0 */
+11: subcc %o0, 3, %g7 /* IEU1 Group */
+ ba,pt %xcc, 3b /* CTI */
+
+ sllx %g4, 16, %g3 /* IEU0 */
+12: subcc %o0, 4, %g7 /* IEU1 Group */
+ ba,pt %xcc, 3b /* CTI */
+ sllx %g5, 24, %g3 /* IEU0 */
+
+13: subcc %o0, 5, %g7 /* IEU1 Group */
+ ba,pt %xcc, 3b /* CTI */
+ sllx %g4, 32, %g3 /* IEU0 */
+14: subcc %o0, 6, %g7 /* IEU1 Group */
+
+ ba,pt %xcc, 3b /* CTI */
+ sllx %g5, 40, %g3 /* IEU0 */
+15: subcc %o0, 7, %g7 /* IEU1 Group */
+ ba,pt %xcc, 3b /* CTI */
+
+ sllx %g4, 48, %g3 /* IEU0 */
+16: subcc %o0, 8, %g7 /* IEU1 Group */
+ ba,pt %xcc, 3b /* CTI */
+ clr %g3 /* IEU0 */
+
+ .align 16
+17: or %o3, %o4, %o3 /* IEU0 Group */
+ sub %o3, %g1, %o4 /* IEU1 */
+18: addcc %o2, 8, %o2 /* IEU1 Group */
+ be,pn %XCC, 19f /* CTI */
+
+ andcc %o4, %g2, %g0 /* IEU1 Group */
+ be,pt %xcc, 21f /* CTI */
+ srlx %o3, 56, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 20f /* CTI */
+ stb %g5, [%o0] /* Store */
+ add %o0, 1, %o0 /* IEU0 Group */
+ subcc %o2, 1, %o2 /* IEU1 */
+
+ be,pn %XCC, 19f /* CTI */
+ srlx %o3, 48, %g5 /* IEU0 Group */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 20f /* CTI */
+
+ stb %g5, [%o0] /* Store */
+ add %o0, 1, %o0 /* IEU0 Group */
+ subcc %o2, 1, %o2 /* IEU1 */
+ be,pn %XCC, 19f /* CTI */
+
+ srlx %o3, 40, %g5 /* IEU0 Group */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 20f /* CTI */
+ stb %g5, [%o0] /* Store */
+
+ add %o0, 1, %o0 /* IEU0 Group */
+ subcc %o2, 1, %o2 /* IEU1 */
+ be,pn %XCC, 19f /* CTI */
+ srlx %o3, 32, %g5 /* IEU0 Group */
+
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 20f /* CTI */
+ stb %g5, [%o0] /* Store */
+ add %o0, 1, %o0 /* IEU0 Group */
+
+ subcc %o2, 1, %o2 /* IEU1 */
+ be,pn %XCC, 19f /* CTI */
+ srlx %o3, 24, %g5 /* IEU0 Group */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 20f /* CTI */
+ stb %g5, [%o0] /* Store */
+ add %o0, 1, %o0 /* IEU0 Group */
+ subcc %o2, 1, %o2 /* IEU1 */
+
+ be,pn %XCC, 19f /* CTI */
+ srlx %o3, 16, %g5 /* IEU0 Group */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 20f /* CTI */
+
+ stb %g5, [%o0] /* Store */
+ add %o0, 1, %o0 /* IEU0 Group */
+ subcc %o2, 1, %o2 /* IEU1 */
+ be,pn %XCC, 19f /* CTI */
+
+ srlx %o3, 8, %o3 /* IEU0 Group */
+ stb %o3, [%o0] /* Store */
+59: add %o0, 1, %o2 /* IEU1 */
+ andcc %o3, 0xff, %g0 /* IEU1 Group */
+
+ retl /* CTI+IEU1 Group */
+ movne %icc, %o2, %o0 /* Single Group */
+19: retl /* CTI+IEU1 Group */
+ nop /* IEU0 */
+
+20: mov %o0, %g7 /* IEU0 Group */
+ subcc %o2, 1, %o2 /* IEU1 */
+ be,pn %XCC, 51f /* CTI */
+ add %o0, 1, %o0 /* IEU0 Group */
+
+50: stb %g0, [%o0] /* Store Group */
+ subcc %o2, 1, %o2 /* IEU1 Group */
+ bne,pt %XCC, 50b /* CTI */
+ add %o0, 1, %o0 /* IEU0 */
+
+51: retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+
+ .align 16
+21: andcc %o2, 4, %g0 /* IEU1 Group */
+ be,pn %icc, 22f /* CTI */
+ srlx %o3, 32, %g5 /* IEU0 */
+ stw %g5, [%o0] /* Store Group */
+
+ add %o0, 4, %o0 /* IEU0 */
+ mov %o3, %g5 /* IEU1 */
+22: andcc %o2, 2, %g0 /* IEU1 Group */
+ be,pn %icc, 23f /* CTI */
+
+ srlx %g5, 16, %g4 /* IEU0 */
+ sth %g4, [%o0] /* Store Group */
+ add %o0, 2, %o0 /* IEU0 */
+ mov %g5, %g4 /* IEU1 */
+
+23: srlx %g4, 8, %g4 /* IEU0 Group */
+ andcc %o2, 1, %g0 /* IEU1 */
+ bne,a,pn %icc, 24f /* CTI */
+ stb %g4, [%o0] /* Store Group */
+
+ retl /* CTI+IEU1 Group */
+ nop /* IEU0 */
+24: retl /* CTI+IEU1 Group */
+ add %o0, 1, %o0 /* IEU0 */
+
+ .align 16
+55: sub %o0, 1, %g7 /* IEU0 Group */
+25: andcc %o0, 7, %g0 /* IEU1 */
+ be,a,pn %icc, 4b /* CTI */
+ andncc %o2, 31, %g3 /* IEU1 Group */
+
+ stb %g0, [%o0] /* Store Group */
+ subcc %o2, 1, %o2 /* IEU1 */
+ bne,pt %XCC, 25b /* CTI */
+ add %o0, 1, %o0 /* IEU0 Group */
+
+ retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+
+ .align 16
+26: ldub [%o1], %o3 /* Load */
+ sllx %g1, 7, %g2 /* IEU0 Group */
+ stb %o3, [%o0] /* Store */
+27: subcc %o2, 1, %o2 /* IEU1 */
+
+ be,pn %XCC, 59b /* CTI */
+ add %o1, 1, %o1 /* IEU0 Group */
+ add %o0, 1, %o0 /* IEU1 */
+ andcc %o3, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 55b /* CTI */
+ lduba [%o1] ASI_PNF, %o3 /* Load */
+ andcc %o0, 7, %g0 /* IEU1 Group */
+ bne,a,pt %icc, 27b /* CTI */
+
+ stb %o3, [%o0] /* Store */
+ andcc %o1, 7, %g3 /* IEU1 Group */
+ be,a,pt %icc, 1b /* CTI */
+ ldx [%o1], %o3 /* Load */
+
+28: orcc %g0, 64, %g4 /* IEU1 Group */
+ sllx %g3, 3, %g5 /* IEU0 */
+ sub %g4, %g5, %g4 /* IEU0 Group */
+ sub %o1, %g3, %o1 /* IEU1 */
+ /* %g1 = 0101010101010101
+ %g2 = 8080808080808080
+ %g3 = source alignment
+ %g5 = number of bits to shift left
+ %g4 = number of bits to shift right */
+
+ ldxa [%o1] ASI_PNF, %o5 /* Load Group */
+ addcc %o1, 8, %o1 /* IEU1 */
+29: sllx %o5, %g5, %o3 /* IEU0 Group */
+ ldxa [%o1] ASI_PNF, %o5 /* Load */
+
+ subcc %o2, 8, %o2 /* IEU1 */
+ bl,pn %XCC, 17b /* CTI */
+ srlx %o5, %g4, %o4 /* IEU0 Group */
+ add %o1, 8, %o1 /* IEU1 */
+
+ or %o3, %o4, %o3 /* IEU0 Group */
+ add %o0, 8, %o0 /* IEU1 */
+ sub %o3, %g1, %o4 /* IEU0 Group */
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o4, %o3, %o4 /* IEU0 Group */
+#endif
+ andcc %o4, %g2, %g0 /* IEU1 Group */
+
+ be,a,pt %xcc, 29b /* CTI */
+ stx %o3, [%o0-8] /* Store */
+ srlx %o3, 56, %o4 /* IEU0 Group */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 36f /* CTI */
+ srlx %o3, 48, %g7 /* IEU0 */
+ andcc %g7, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 35f /* CTI */
+
+ srlx %o3, 40, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 34f /* CTI */
+ srlx %o3, 32, %g7 /* IEU0 */
+
+ andcc %g7, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 33f /* CTI */
+ srlx %o3, 24, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 32f /* CTI */
+ srlx %o3, 16, %g7 /* IEU0 */
+ andcc %g7, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 31f /* CTI */
+
+ srlx %o3, 8, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 30f /* CTI */
+ andcc %o3, 0xff, %g0 /* IEU1 Group */
+
+ bne,pn %icc, 29b /* CTI */
+ stx %o3, [%o0-8] /* Store */
+ sub %o0, 1, %g7 /* IEU0 Group */
+ ba,pt %xcc, 4b /* CTI */
+
+ andncc %o2, 31, %g3 /* IEU1 */
+30: subcc %o0, 2, %g7 /* IEU0 */
+ ba,pt %xcc, 3b /* CTI */
+ sllx %o4, 8, %g3 /* IEU0 Group */
+
+31: sllx %g7, 16, %g3 /* IEU0 Group */
+ ba,pt %xcc, 3b /* CTI */
+ sub %o0, 3, %g7 /* IEU1 */
+32: subcc %o0, 4, %g7 /* IEU1 Group */
+
+ ba,pt %xcc, 3b /* CTI */
+ sllx %o4, 24, %g3 /* IEU0 */
+33: sllx %g7, 32, %g3 /* IEU0 Group */
+ ba,pt %xcc, 3b /* CTI */
+
+ sub %o0, 5, %g7 /* IEU1 */
+34: subcc %o0, 6, %g7 /* IEU1 Group */
+ ba,pt %xcc, 3b /* CTI */
+ sllx %o4, 40, %g3 /* IEU0 */
+
+35: sllx %g7, 48, %g3 /* IEU0 Group */
+ ba,pt %xcc, 3b /* CTI */
+ sub %o0, 7, %g7 /* IEU1 */
+36: subcc %o0, 8, %g7 /* IEU1 Group */
+
+ ba,pt %xcc, 3b /* CTI */
+ sllx %o4, 56, %g3 /* IEU0 */
+END(__stpncpy)
+
+weak_alias(__stpncpy, stpncpy)
diff --git a/sysdeps/sparc/sparc64/strcat.S b/sysdeps/sparc/sparc64/strcat.S
new file mode 100644
index 0000000000..55a6468665
--- /dev/null
+++ b/sysdeps/sparc/sparc64/strcat.S
@@ -0,0 +1,336 @@
+/* strcat (dest, src) -- Append SRC on the end of DEST.
+ For SPARC v9.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jj@ultra.linux.cz> and
+ Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <asm/asi.h>
+#ifndef XCC
+#define XCC xcc
+#define USE_BPR
+#endif
+
+ /* Normally, this uses
+ ((xword - 0x0101010101010101) & 0x8080808080808080) test
+ to find out if any byte in xword could be zero. This is fast, but
+ also gives false alarm for any byte in range 0x81-0xff. It does
+ not matter for correctness, as if this test tells us there could
+ be some zero byte, we check it byte by byte, but if bytes with
+ high bits set are common in the strings, then this will give poor
+ performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
+ will use one tick slower, but more precise test
+ ((xword - 0x0101010101010101) & (~xword) & 0x8080808080808080),
+ which does not give any false alarms (but if some bits are set,
+ one cannot assume from it which bytes are zero and which are not).
+ It is yet to be measured, what is the correct default for glibc
+ in these days for an average user.
+ */
+
+ .text
+ .align 32
+ENTRY(strcat)
+ sethi %hi(0x01010101), %g1 /* IEU0 Group */
+ ldub [%o0], %o3 /* Load */
+ or %g1, %lo(0x01010101), %g1 /* IEU0 Group */
+ mov %o0, %g7 /* IEU1 */
+
+ sllx %g1, 32, %g2 /* IEU0 Group */
+ andcc %o0, 7, %g0 /* IEU1 */
+ or %g1, %g2, %g1 /* IEU0 Group */
+ bne,pn %icc, 32f /* CTI */
+
+ sllx %g1, 7, %g2 /* IEU0 Group */
+ brz,pn %o3, 30f /* CTI+IEU1 */
+ ldx [%o0], %o3 /* Load */
+48: add %o0, 8, %o0 /* IEU0 Group */
+
+49: sub %o3, %g1, %o2 /* IEU0 Group */
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o2, %o3, %g5 /* IEU0 Group */
+ ldxa [%o0] ASI_PNF, %o3 /* Load */
+ andcc %g5, %g2, %g0 /* IEU1 Group */
+#else
+ ldxa [%o0] ASI_PNF, %o3 /* Load */
+ andcc %o2, %g2, %g0 /* IEU1 Group */
+#endif
+ be,pt %xcc, 49b /* CTI */
+
+ add %o0, 8, %o0 /* IEU0 */
+ addcc %o2, %g1, %g3 /* IEU1 Group */
+ srlx %o2, 32, %o2 /* IEU0 */
+50: andcc %o2, %g2, %g0 /* IEU1 Group */
+
+ be,pn %xcc, 51f /* CTI */
+ srlx %g3, 56, %o2 /* IEU0 */
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 29f /* CTI */
+
+ srlx %g3, 48, %o2 /* IEU0 */
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 28f /* CTI */
+ srlx %g3, 40, %o2 /* IEU0 */
+
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 27f /* CTI */
+ srlx %g3, 32, %o2 /* IEU0 */
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 26f /* CTI */
+51: srlx %g3, 24, %o2 /* IEU0 */
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 25f /* CTI */
+
+ srlx %g3, 16, %o2 /* IEU0 */
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 24f /* CTI */
+ srlx %g3, 8, %o2 /* IEU0 */
+
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 23f /* CTI */
+ sub %o3, %g1, %o2 /* IEU0 */
+ andcc %g3, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 52f /* CTI */
+ ldxa [%o0] ASI_PNF, %o3 /* Load */
+ andcc %o2, %g2, %g0 /* IEU1 Group */
+ be,pt %xcc, 49b /* CTI */
+
+ add %o0, 8, %o0 /* IEU0 */
+ addcc %o2, %g1, %g3 /* IEU1 Group */
+ ba,pt %xcc, 50b /* CTI */
+ srlx %o2, 32, %o2 /* IEU0 */
+
+ .align 16
+52: ba,pt %xcc, 12f /* CTI Group */
+ add %o0, -9, %o0 /* IEU0 */
+23: ba,pt %xcc, 12f /* CTI Group */
+ add %o0, -10, %o0 /* IEU0 */
+
+24: ba,pt %xcc, 12f /* CTI Group */
+ add %o0, -11, %o0 /* IEU0 */
+25: ba,pt %xcc, 12f /* CTI Group */
+ add %o0, -12, %o0 /* IEU0 */
+
+26: ba,pt %xcc, 12f /* CTI Group */
+ add %o0, -13, %o0 /* IEU0 */
+27: ba,pt %xcc, 12f /* CTI Group */
+ add %o0, -14, %o0 /* IEU0 */
+
+28: ba,pt %xcc, 12f /* CTI Group */
+ add %o0, -15, %o0 /* IEU0 */
+29: add %o0, -16, %o0 /* IEU0 Group */
+30: andcc %o1, 7, %g3 /* IEU1 */
+
+31: bne,pn %icc, 14f /* CTI */
+ orcc %g0, 64, %g4 /* IEU1 Group */
+1: ldx [%o1], %o3 /* Load */
+ add %o1, 8, %o1 /* IEU1 */
+
+2: mov %o3, %g3 /* IEU0 Group */
+3: sub %o3, %g1, %o2 /* IEU1 */
+ ldxa [%o1] ASI_PNF, %o3 /* Load */
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o2, %g3, %o2 /* IEU0 Group */
+#endif
+ add %o0, 8, %o0 /* IEU0 Group */
+
+ andcc %o2, %g2, %g0 /* IEU1 */
+ add %o1, 8, %o1 /* IEU0 Group */
+ be,a,pt %xcc, 2b /* CTI */
+ stx %g3, [%o0 - 8] /* Store */
+
+ srlx %g3, 56, %g5 /* IEU0 Group */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 11f /* CTI */
+ srlx %g3, 48, %g4 /* IEU0 */
+
+ andcc %g4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 10f /* CTI */
+ srlx %g3, 40, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 9f /* CTI */
+ srlx %g3, 32, %g4 /* IEU0 */
+ andcc %g4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 8f /* CTI */
+
+ srlx %g3, 24, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 7f /* CTI */
+ srlx %g3, 16, %g4 /* IEU0 */
+
+ andcc %g4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 6f /* CTI */
+ srlx %g3, 8, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 5f /* CTI */
+ sub %o3, %g1, %o2 /* IEU0 */
+ stx %g3, [%o0 - 8] /* Store Group */
+ andcc %g3, 0xff, %g0 /* IEU1 */
+
+ bne,pt %icc, 3b /* CTI */
+ mov %o3, %g3 /* IEU0 Group */
+4: retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+
+ .align 16
+5: stb %g5, [%o0 - 2] /* Store Group */
+ srlx %g3, 16, %g4 /* IEU0 */
+6: sth %g4, [%o0 - 4] /* Store Group */
+ srlx %g3, 32, %g4 /* IEU0 */
+
+ stw %g4, [%o0 - 8] /* Store Group */
+ retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+7: stb %g5, [%o0 - 4] /* Store Group */
+
+ srlx %g3, 32, %g4 /* IEU0 */
+8: stw %g4, [%o0 - 8] /* Store Group */
+ retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+
+9: stb %g5, [%o0 - 6] /* Store Group */
+ srlx %g3, 48, %g4 /* IEU0 */
+10: sth %g4, [%o0 - 8] /* Store Group */
+ retl /* CTI+IEU1 Group */
+
+ mov %g7, %o0 /* IEU0 */
+11: stb %g5, [%o0 - 8] /* Store Group */
+ retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+
+ .align 16
+32: andcc %o0, 7, %g0 /* IEU1 Group */
+ be,a,pn %icc, 48b /* CTI */
+ ldx [%o0], %o3 /* Load */
+ add %o0, 1, %o0 /* IEU0 Group */
+
+ brnz,a,pt %o3, 32b /* CTI+IEU1 */
+ lduba [%o0] ASI_PNF, %o3 /* Load */
+ add %o0, -1, %o0 /* IEU0 Group */
+ andcc %o0, 7, %g0 /* IEU1 Group */
+
+ be,a,pn %icc, 31b /* CTI */
+ andcc %o1, 7, %g3 /* IEU1 Group */
+12: ldub [%o1], %o3 /* Load */
+ stb %o3, [%o0] /* Store Group */
+
+13: add %o0, 1, %o0 /* IEU0 */
+ add %o1, 1, %o1 /* IEU1 */
+ andcc %o3, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4b /* CTI */
+
+ lduba [%o1] ASI_PNF, %o3 /* Load */
+ andcc %o0, 7, %g0 /* IEU1 Group */
+ bne,a,pt %icc, 13b /* CTI */
+ stb %o3, [%o0] /* Store */
+
+ andcc %o1, 7, %g3 /* IEU1 Group */
+ be,a,pt %icc, 1b /* CTI */
+ ldx [%o1], %o3 /* Load */
+ orcc %g0, 64, %g4 /* IEU1 Group */
+
+14: sllx %g3, 3, %g5 /* IEU0 */
+ sub %o1, %g3, %o1 /* IEU0 Group */
+ sub %g4, %g5, %g4 /* IEU1 */
+ /* %g1 = 0101010101010101 *
+ * %g2 = 8080808080808080 *
+ * %g3 = source alignment *
+ * %g5 = number of bits to shift left *
+ * %g4 = number of bits to shift right */
+ ldxa [%o1] ASI_PNF, %o5 /* Load Group */
+
+ addcc %o1, 8, %o1 /* IEU1 */
+15: sllx %o5, %g5, %o3 /* IEU0 Group */
+ ldxa [%o1] ASI_PNF, %o5 /* Load */
+ srlx %o5, %g4, %o4 /* IEU0 Group */
+
+ add %o0, 8, %o0 /* IEU1 */
+ or %o3, %o4, %o3 /* IEU0 Group */
+ add %o1, 8, %o1 /* IEU1 */
+ sub %o3, %g1, %o4 /* IEU0 Group */
+
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o4, %o3, %o4 /* IEU0 Group */
+#endif
+ andcc %o4, %g2, %g0 /* IEU1 Group */
+ be,a,pt %xcc, 15b /* CTI */
+ stx %o3, [%o0 - 8] /* Store */
+ srlx %o3, 56, %o4 /* IEU0 Group */
+
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 22f /* CTI */
+ srlx %o3, 48, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 21f /* CTI */
+ srlx %o3, 40, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 20f /* CTI */
+
+ srlx %o3, 32, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 19f /* CTI */
+ srlx %o3, 24, %o4 /* IEU0 */
+
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 18f /* CTI */
+ srlx %o3, 16, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 17f /* CTI */
+ srlx %o3, 8, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 16f /* CTI */
+
+ andcc %o3, 0xff, %g0 /* IEU1 Group */
+ bne,pn %icc, 15b /* CTI */
+ stx %o3, [%o0 - 8] /* Store */
+ retl /* CTI+IEU1 Group */
+
+ mov %g7, %o0 /* IEU0 */
+
+ .align 16
+16: srlx %o3, 8, %o4 /* IEU0 Group */
+ stb %o4, [%o0 - 2] /* Store */
+17: srlx %o3, 16, %o4 /* IEU0 Group */
+ stb %o4, [%o0 - 3] /* Store */
+
+18: srlx %o3, 24, %o4 /* IEU0 Group */
+ stb %o4, [%o0 - 4] /* Store */
+19: srlx %o3, 32, %o4 /* IEU0 Group */
+ stw %o4, [%o0 - 8] /* Store */
+
+ retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+ nop
+ nop
+
+20: srlx %o3, 40, %o4 /* IEU0 Group */
+ stb %o4, [%o0 - 6] /* Store */
+21: srlx %o3, 48, %o4 /* IEU0 Group */
+ stb %o4, [%o0 - 7] /* Store */
+
+22: srlx %o3, 56, %o4 /* IEU0 Group */
+ stb %o4, [%o0 - 8] /* Store */
+ retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+END(strcat)
diff --git a/sysdeps/sparc/sparc64/strchr.S b/sysdeps/sparc/sparc64/strchr.S
new file mode 100644
index 0000000000..8324c4c8d6
--- /dev/null
+++ b/sysdeps/sparc/sparc64/strchr.S
@@ -0,0 +1,479 @@
+/* strchr (str, ch) -- Return pointer to first occurrence of CH in STR.
+ For SPARC v9.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz> and
+ Jakub Jelinek <jj@ultra.linux.cz>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <asm/asi.h>
+#ifndef XCC
+#define XCC xcc
+#define USE_BPR
+#endif
+
+ /* Normally, this uses
+ ((xword - 0x0101010101010101) & 0x8080808080808080) test
+ to find out if any byte in xword could be zero. This is fast, but
+ also gives false alarm for any byte in range 0x81-0xff. It does
+ not matter for correctness, as if this test tells us there could
+ be some zero byte, we check it byte by byte, but if bytes with
+ high bits set are common in the strings, then this will give poor
+ performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
+ will use one tick slower, but more precise test
+ ((xword - 0x0101010101010101) & (~xword) & 0x8080808080808080),
+ which does not give any false alarms (but if some bits are set,
+ one cannot assume from it which bytes are zero and which are not).
+ It is yet to be measured, what is the correct default for glibc
+ in these days for an average user.
+ */
+
+ .text
+ .align 32
+ENTRY(strchr)
+#ifndef USE_BPR
+ srl %o1, 0, %o1 /* IEU0 Group */
+#endif
+ brz,pn %o1, 17f /* CTI+IEU1 Group */
+ sllx %o1, 8, %g3 /* IEU0 */
+ sethi %hi(0x01010101), %g1 /* IEU0 Group */
+ or %g3, %o1, %g3 /* IEU1 */
+
+ ldub [%o0], %o3 /* Load */
+ sllx %g3, 16, %g5 /* IEU0 Group */
+ or %g1, %lo(0x01010101), %g1 /* IEU1 */
+ sllx %g1, 32, %g2 /* IEU0 Group */
+
+ brz,pn %o3, 5f /* CTI+IEU1 */
+ orcc %g3, %g5, %g3 /* IEU1 Group */
+ sllx %g3, 32, %g5 /* IEU0 */
+ cmp %o3, %o1 /* IEU1 Group */
+
+ be,pn %xcc, 14f /* CTI */
+ or %g1, %g2, %g1 /* IEU0 */
+ andcc %o0, 7, %g0 /* IEU1 Group */
+ bne,a,pn %icc, 15f /* CTI */
+
+ add %o0, 1, %o0 /* IEU0 */
+ ldx [%o0], %o3 /* Load Group */
+1: sllx %g1, 7, %g2 /* IEU0 */
+ or %g3, %g5, %g3 /* IEU1 */
+
+ add %o0, 8, %o0 /* IEU0 Group */
+ xor %o3, %g3, %o4 /* IEU1 */
+ /* %g1 = 0101010101010101 *
+ * %g2 = 8080088080808080 *
+ * %g3 = c c c c c c c c *
+ * %o3 = value *
+ * %o4 = value XOR c */
+2: sub %o3, %g1, %o2 /* IEU0 Group */
+ sub %o4, %g1, %o5 /* IEU1 */
+
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o2, %o3, %g7 /* IEU0 Group */
+ andn %o5, %o4, %o5 /* IEU1 */
+ ldxa [%o0] ASI_PNF, %o3 /* Load */
+ or %o5, %g7, %o5 /* IEU0 Group */
+#else
+ ldxa [%o0] ASI_PNF, %o3 /* Load */
+ or %o5, %o2, %o5 /* IEU0 Group */
+#endif
+ add %o0, 8, %o0 /* IEU1 */
+ andcc %o5, %g2, %g0 /* IEU1 Group */
+
+ be,a,pt %xcc, 2b /* CTI */
+ xor %o3, %g3, %o4 /* IEU0 */
+ srlx %o5, 32, %g5 /* IEU0 Group */
+ add %o2, %g1, %o2 /* IEU1 */
+
+3: andcc %g5, %g2, %g0 /* IEU1 Group */
+ be,pn %xcc, 4f /* CTI */
+ srlx %o2, 56, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 5f /* CTI */
+ srlx %o4, 56, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 6f /* CTI */
+
+ srlx %o2, 48, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 5f /* CTI */
+ srlx %o4, 48, %g5 /* IEU0 */
+
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 7f /* CTI */
+ srlx %o2, 40, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 5f /* CTI */
+ srlx %o4, 40, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 8f /* CTI */
+
+ srlx %o2, 32, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 5f /* CTI */
+ srlx %o4, 32, %g5 /* IEU0 */
+
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 9f /* CTI */
+4: srlx %o2, 24, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 5f /* CTI */
+ srlx %o4, 24, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 10f /* CTI */
+
+ srlx %o2, 16, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 5f /* CTI */
+ srlx %o4, 16, %g5 /* IEU0 */
+
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 11f /* CTI */
+ srlx %o2, 8, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 5f /* CTI */
+ srlx %o4, 8, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 12f /* CTI */
+
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 5f /* CTI */
+ sub %o3, %g1, %o2 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 13f /* CTI */
+ xor %o3, %g3, %o4 /* IEU0 */
+ ldxa [%o0] ASI_PNF, %o3 /* Load Group */
+ sub %o4, %g1, %o5 /* IEU0 */
+
+ or %o5, %o2, %o5 /* IEU1 */
+ add %o0, 8, %o0 /* IEU0 Group */
+ andcc %o5, %g2, %g0 /* IEU1 */
+ be,a,pt %xcc, 2b /* CTI */
+
+ xor %o3, %g3, %o4 /* IEU0 Group */
+ srlx %o5, 32, %g5 /* IEU0 Group */
+ ba,pt %xcc, 3b /* CTI */
+ add %o2, %g1, %o2 /* IEU1 */
+
+ .align 16
+5: retl /* CTI+IEU1 Group */
+ clr %o0 /* IEU0 */
+6: retl /* CTI+IEU1 Group */
+ add %o0, -16, %o0 /* IEU0 */
+
+7: retl /* CTI+IEU1 Group */
+ add %o0, -15, %o0 /* IEU0 */
+8: retl /* CTI+IEU1 Group */
+ add %o0, -14, %o0 /* IEU0 */
+
+9: retl /* CTI+IEU1 Group */
+ add %o0, -13, %o0 /* IEU0 */
+10: retl /* CTI+IEU1 Group */
+ add %o0, -12, %o0 /* IEU0 */
+
+11: retl /* CTI+IEU1 Group */
+ add %o0, -11, %o0 /* IEU0 */
+12: retl /* CTI+IEU1 Group */
+ add %o0, -10, %o0 /* IEU0 */
+
+13: retl /* CTI+IEU1 Group */
+ add %o0, -9, %o0 /* IEU0 */
+14: retl /* CTI+IEU1 Group */
+ nop /* IEU0 */
+
+ .align 16
+15: ldub [%o0], %o3 /* Load Group */
+16: andcc %o0, 7, %g0 /* IEU1 */
+ be,a,pn %icc, 1b /* CTI */
+ ldx [%o0], %o3 /* Load Group */
+
+ andcc %o3, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 5b /* CTI */
+ add %o0, 1, %o0 /* IEU0 */
+ cmp %o3, %o1 /* IEU1 Group */
+
+ bne,a,pn %icc, 16b /* CTI */
+ ldub [%o0], %o3 /* Load */
+ retl /* CTI+IEU1 Group */
+ add %o0, -1, %o0 /* IEU0 */
+
+ /* strchr (str, 0) */
+ .align 32
+ nop
+ .align 16
+17: sethi %hi(0x01010101), %g1 /* IEU0 Group */
+ ldub [%o0], %o3 /* Load */
+ or %g1, %lo(0x01010101), %g1 /* IEU0 Group */
+ sllx %g1, 32, %g2 /* IEU0 Group */
+
+ andcc %o0, 7, %g0 /* IEU1 */
+ or %g1, %g2, %g1 /* IEU0 Group */
+ bne,pn %icc, 32f /* CTI */
+ sllx %g1, 7, %g2 /* IEU0 Group */
+
+ brz,pn %o3, 30f /* CTI+IEU1 */
+ ldx [%o0], %o3 /* Load */
+18: add %o0, 8, %o0 /* IEU0 Group */
+19: sub %o3, %g1, %o2 /* IEU0 Group */
+
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o2, %o3, %g7 /* IEU0 Group */
+ ldxa [%o0] ASI_PNF, %o3 /* Load */
+ andcc %g7, %g2, %g0 /* IEU1 Group */
+#else
+ ldxa [%o0] ASI_PNF, %o3 /* Load */
+ andcc %o2, %g2, %g0 /* IEU1 Group */
+#endif
+ be,pt %xcc, 19b /* CTI */
+ add %o0, 8, %o0 /* IEU0 */
+
+ addcc %o2, %g1, %g3 /* IEU1 Group */
+ srlx %o2, 32, %o2 /* IEU0 */
+20: andcc %o2, %g2, %g0 /* IEU1 Group */
+ be,pn %xcc, 21f /* CTI */
+
+ srlx %g3, 56, %o2 /* IEU0 */
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 29f /* CTI */
+ srlx %g3, 48, %o2 /* IEU0 */
+
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 28f /* CTI */
+ srlx %g3, 40, %o2 /* IEU0 */
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 27f /* CTI */
+ srlx %g3, 32, %o2 /* IEU0 */
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 26f /* CTI */
+
+21: srlx %g3, 24, %o2 /* IEU0 */
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 25f /* CTI */
+ srlx %g3, 16, %o2 /* IEU0 */
+
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 24f /* CTI */
+ srlx %g3, 8, %o2 /* IEU0 */
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 23f /* CTI */
+ sub %o3, %g1, %o2 /* IEU0 */
+ andcc %g3, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 22f /* CTI */
+
+ ldxa [%o0] ASI_PNF, %o3 /* Load */
+ andcc %o2, %g2, %g0 /* IEU1 Group */
+ be,pt %xcc, 19b /* CTI */
+ add %o0, 8, %o0 /* IEU0 */
+
+ addcc %o2, %g1, %g3 /* IEU1 Group */
+ ba,pt %xcc, 20b /* CTI */
+ srlx %o2, 32, %o2 /* IEU0 */
+
+ .align 16
+22: retl /* CTI+IEU1 Group */
+ add %o0, -9, %o0 /* IEU0 */
+23: retl /* CTI+IEU1 Group */
+ add %o0, -10, %o0 /* IEU0 */
+
+24: retl /* CTI+IEU1 Group */
+ add %o0, -11, %o0 /* IEU0 */
+25: retl /* CTI+IEU1 Group */
+ add %o0, -12, %o0 /* IEU0 */
+
+26: retl /* CTI+IEU1 Group */
+ add %o0, -13, %o0 /* IEU0 */
+27: retl /* CTI+IEU1 Group */
+ add %o0, -14, %o0 /* IEU0 */
+
+28: retl /* CTI+IEU1 Group */
+ add %o0, -15, %o0 /* IEU0 */
+29: retl /* CTI+IEU1 Group */
+ add %o0, -16, %o0 /* IEU0 */
+
+30: retl /* CTI+IEU1 Group */
+ nop /* IEU0 */
+
+ .align 16
+32: andcc %o0, 7, %g0 /* IEU1 Group */
+ be,a,pn %icc, 18b /* CTI */
+ ldx [%o0], %o3 /* Load */
+ add %o0, 1, %o0 /* IEU0 Group */
+
+ brnz,a,pt %o3, 32b /* CTI+IEU1 */
+ lduba [%o0] ASI_PNF, %o3 /* Load */
+ retl /* CTI+IEU1 Group */
+ add %o0, -1, %o0 /* IEU0 */
+END(strchr)
+
+ .align 32
+ENTRY(strrchr)
+#ifndef USE_BPR
+ srl %o1, 0, %o1 /* IEU0 Group */
+#endif
+ brz,pn %o1, 17b /* CTI+IEU1 Group */
+ clr %g4 /* IEU0 */
+ andcc %o0, 7, %g0 /* IEU1 Group */
+ bne,pn %icc, 13f /* CTI */
+
+ sllx %o1, 8, %g3 /* IEU0 */
+ ldx [%o0], %o3 /* Load Group */
+1: sethi %hi(0x01010101), %g1 /* IEU0 */
+ or %g3, %o1, %g3 /* IEU1 */
+
+ sllx %g3, 16, %g5 /* IEU0 Group */
+ or %g1, %lo(0x01010101), %g1 /* IEU1 */
+ sllx %g1, 32, %g2 /* IEU0 Group */
+ or %g3, %g5, %g3 /* IEU1 */
+
+ sllx %g3, 32, %g5 /* IEU0 Group */
+ or %g1, %g2, %g1 /* IEU1 */
+ sllx %g1, 7, %g2 /* IEU0 Group */
+ or %g3, %g5, %g3 /* IEU1 */
+
+ add %o0, 8, %o0 /* IEU0 Group */
+ xor %o3, %g3, %o4 /* IEU1 */
+ /* %g1 = 0101010101010101 *
+ * %g2 = 8080088080808080 *
+ * %g3 = c c c c c c c c *
+ * %o3 = value *
+ * %o4 = value XOR c */
+2: sub %o3, %g1, %o2 /* IEU0 Group */
+3: sub %o4, %g1, %o5 /* IEU1 */
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o2, %o3, %g7 /* IEU0 Group */
+ andn %o5, %o4, %o5 /* IEU1 */
+ ldxa [%o0] ASI_PNF, %o3 /* Load */
+ or %o5, %g7, %o5 /* IEU0 Group */
+#else
+ ldxa [%o0] ASI_PNF, %o3 /* Load */
+ or %o5, %o2, %o5 /* IEU0 Group */
+#endif
+
+ add %o0, 8, %o0 /* IEU1 */
+ andcc %o5, %g2, %g0 /* IEU1 Group */
+ be,a,pt %xcc, 2b /* CTI */
+ xor %o3, %g3, %o4 /* IEU0 */
+
+ srlx %o5, 32, %g5 /* IEU0 Group */
+ add %o2, %g1, %o2 /* IEU1 */
+ andcc %g5, %g2, %g0 /* IEU1 Group */
+ be,pn %xcc, 7f /* CTI */
+
+ srlx %o2, 56, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 12f /* CTI */
+ srlx %o4, 56, %g5 /* IEU0 */
+
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ srlx %o2, 48, %g5 /* IEU0 */
+ be,a,pn %icc, 4f /* CTI */
+ add %o0, -16, %g4 /* IEU0 Group */
+
+4: andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 12f /* CTI */
+ srlx %o4, 48, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ srlx %o2, 40, %g5 /* IEU0 */
+ be,a,pn %icc, 5f /* CTI */
+ add %o0, -15, %g4 /* IEU0 Group */
+5: andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 12f /* CTI */
+ srlx %o4, 40, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ srlx %o2, 32, %g5 /* IEU0 */
+
+ be,a,pn %icc, 6f /* CTI */
+ add %o0, -14, %g4 /* IEU0 Group */
+6: andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 12f /* CTI */
+
+ srlx %o4, 32, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,a,pn %icc, 7f /* CTI */
+ add %o0, -13, %g4 /* IEU0 */
+
+7: srlx %o2, 24, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 12f /* CTI */
+ srlx %o4, 24, %g5 /* IEU0 */
+
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ srlx %o2, 16, %g5 /* IEU0 */
+ be,a,pn %icc, 8f /* CTI */
+ add %o0, -12, %g4 /* IEU0 Group */
+
+8: andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 12f /* CTI */
+ srlx %o4, 16, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ srlx %o2, 8, %g5 /* IEU0 */
+ be,a,pn %icc, 9f /* CTI */
+ add %o0, -11, %g4 /* IEU0 Group */
+9: andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 12f /* CTI */
+ srlx %o4, 8, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,a,pn %icc, 10f /* CTI */
+
+ add %o0, -10, %g4 /* IEU0 */
+10: andcc %o2, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 12f /* CTI */
+ sub %o3, %g1, %o2 /* IEU0 */
+
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,a,pn %icc, 11f /* CTI */
+ add %o0, -9, %g4 /* IEU0 */
+11: ba,pt %xcc, 3b /* CTI Group */
+
+ xor %o3, %g3, %o4 /* IEU0 Group */
+12: retl /* CTI+IEU1 Group */
+ mov %g4, %o0 /* IEU0 */
+
+ .align 16
+13: ldub [%o0], %o3 /* Load Group */
+ add %o0, 1, %o0 /* IEU0 */
+14: andcc %o3, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 12b /* CTI */
+
+ cmp %o3, %o1 /* IEU1 Group */
+ ldub [%o0], %o3 /* Load */
+ be,a,pn %icc, 15f /* CTI */
+ add %o0, -1, %g4 /* IEU0 Group */
+
+15: andcc %o0, 7, %g0 /* IEU1 Group */
+ bne,a,pt %icc, 14b /* CTI */
+ add %o0, 1, %o0 /* IEU0 */
+ ba,pt %xcc, 1b /* CTI Group */
+
+ ldx [%o0], %o3 /* Load */
+END(strrchr)
+
+weak_alias (strchr, index)
+weak_alias (strrchr, rindex)
diff --git a/sysdeps/sparc/sparc64/strcmp.S b/sysdeps/sparc/sparc64/strcmp.S
new file mode 100644
index 0000000000..1288688c0c
--- /dev/null
+++ b/sysdeps/sparc/sparc64/strcmp.S
@@ -0,0 +1,274 @@
+/* Compare two strings for differences.
+ For SPARC v9.
+ Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz> and
+ Jakub Jelinek <jj@ultra.linux.cz>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <asm/asi.h>
+
+ /* Normally, this uses
+ ((xword - 0x0101010101010101) & 0x8080808080808080) test
+ to find out if any byte in xword could be zero. This is fast, but
+ also gives false alarm for any byte in range 0x81-0xff. It does
+ not matter for correctness, as if this test tells us there could
+ be some zero byte, we check it byte by byte, but if bytes with
+ high bits set are common in the strings, then this will give poor
+ performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
+ will use one tick slower, but more precise test
+ ((xword - 0x0101010101010101) & (~xword) & 0x8080808080808080),
+ which does not give any false alarms (but if some bits are set,
+ one cannot assume from it which bytes are zero and which are not).
+ It is yet to be measured, what is the correct default for glibc
+ in these days for an average user.
+ */
+
+ .text
+ .align 32
+ENTRY(strcmp)
+ sethi %hi(0x01010101), %g1 /* IEU0 Group */
+ andcc %o0, 7, %g0 /* IEU1 */
+ bne,pn %icc, 7f /* CTI */
+ or %g1, %lo(0x01010101), %g1 /* IEU0 Group */
+
+ andcc %o1, 7, %g3 /* IEU1 */
+ bne,pn %icc, 9f /* CTI */
+ sllx %g1, 32, %g2 /* IEU0 Group */
+ ldx [%o0], %o2 /* Load */
+
+ or %g1, %g2, %g1 /* IEU0 Group */
+1: ldx [%o1], %o3 /* Load */
+ sub %o1, %o0, %o1 /* IEU1 */
+ sllx %g1, 7, %g2 /* IEU0 Group */
+
+2: add %o0, 8, %o0 /* IEU1 */
+ sub %o2, %g1, %g3 /* IEU0 Group */
+ subcc %o2, %o3, %g0 /* IEU1 */
+ bne,pn %xcc, 13f /* CTI */
+
+#ifdef EIGHTBIT_NOT_RARE
+ andn %g3, %o2, %g4 /* IEU0 Group */
+ ldxa [%o0] ASI_PNF, %o2 /* Load */
+ andcc %g4, %g2, %g0 /* IEU1 Group */
+#else
+ ldxa [%o0] ASI_PNF, %o2 /* Load Group */
+ andcc %g3, %g2, %g0 /* IEU1 */
+#endif
+ be,a,pt %xcc, 2b /* CTI */
+ ldxa [%o1 + %o0] ASI_PNF, %o3 /* Load Group */
+
+ addcc %g3, %g1, %o4 /* IEU1 */
+ srlx %g3, 32, %g3 /* IEU0 */
+ andcc %g3, %g2, %g0 /* IEU1 Group */
+ be,pt %xcc, 3f /* CTI */
+
+ srlx %o4, 56, %o5 /* IEU0 */
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4f /* CTI */
+ srlx %o4, 48, %o5 /* IEU0 */
+
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4f /* CTI */
+ srlx %o4, 40, %o5 /* IEU0 */
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 4f /* CTI */
+ srlx %o4, 32, %o5 /* IEU0 */
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4f /* CTI */
+
+3: srlx %o4, 24, %o5 /* IEU0 */
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4f /* CTI */
+ srlx %o4, 16, %o5 /* IEU0 */
+
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4f /* CTI */
+ srlx %o4, 8, %o5 /* IEU0 */
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 4f /* CTI */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ bne,a,pn %icc, 2b /* CTI */
+ ldxa [%o1 + %o0] ASI_PNF, %o3 /* Load */
+
+4: retl /* CTI+IEU1 Group */
+ clr %o0 /* IEU0 */
+
+ .align 32
+13: mov 0xff, %g7 /* IEU0 Group */
+#ifdef EIGHTBIT_NOT_RARE
+ andcc %g4, %g2, %g0 /* IEU1 */
+#else
+ andcc %g3, %g2, %g0 /* IEU1 */
+#endif
+ be,pt %xcc, 25f /* CTI */
+ addcc %g3, %g1, %o4 /* IEU1 Group */
+
+ srlx %g3, 32, %g3 /* IEU0 */
+ andcc %g3, %g2, %g0 /* IEU1 Group */
+ be,pt %xcc, 23f /* CTI */
+ sllx %g7, 56, %o5 /* IEU0 */
+
+ andcc %o4, %o5, %g0 /* IEU1 Group */
+ be,pn %xcc, 24f /* CTI */
+ sllx %g7, 48, %o5 /* IEU0 */
+ andcc %o4, %o5, %g0 /* IEU1 Group */
+
+ be,pn %xcc, 24f /* CTI */
+ sllx %g7, 40, %o5 /* IEU0 */
+ andcc %o4, %o5, %g0 /* IEU1 Group */
+ be,pn %xcc, 24f /* CTI */
+
+ sllx %g7, 32, %o5 /* IEU0 */
+ andcc %o4, %o5, %g0 /* IEU1 Group */
+ be,pn %xcc, 24f /* CTI */
+23: sllx %g7, 24, %o5 /* IEU0 */
+
+ andcc %o4, %o5, %g0 /* IEU1 Group */
+ be,pn %icc, 24f /* CTI */
+ sllx %g7, 16, %o5 /* IEU0 */
+ andcc %o4, %o5, %g0 /* IEU1 Group */
+
+ be,pn %icc, 24f /* CTI */
+ sllx %g7, 8, %o5 /* IEU0 */
+ andcc %o4, %o5, %g0 /* IEU1 Group */
+ be,pn %icc, 24f /* CTI */
+
+ mov %g7, %o5 /* IEU0 */
+25: cmp %o4, %o3 /* IEU1 Group */
+5: mov -1, %o0 /* IEU0 */
+ retl /* CTI+IEU1 Group */
+
+ movgu %xcc, 1, %o0 /* Single Group */
+
+ .align 16
+24: sub %o5, 1, %g7 /* IEU0 Group */
+ clr %o0 /* IEU1 */
+ or %o5, %g7, %o5 /* IEU0 Group */
+ andn %o4, %o5, %o4 /* IEU0 Group */
+
+ andn %o3, %o5, %o3 /* IEU1 */
+ cmp %o4, %o3 /* IEU1 Group */
+ movgu %xcc, 1, %o0 /* Single Group */
+ retl /* CTI+IEU1 Group */
+
+ movlu %xcc, -1, %o0 /* Single Group */
+6: retl /* CTI+IEU1 Group */
+ mov %o4, %o0 /* IEU0 */
+
+ .align 16
+7: ldub [%o0], %o2 /* Load */
+ add %o0, 1, %o0 /* IEU1 */
+ ldub [%o1], %o3 /* Load Group */
+ sllx %g1, 32, %g2 /* IEU0 */
+
+8: add %o1, 1, %o1 /* IEU1 */
+ subcc %o2, %o3, %o4 /* IEU1 Group */
+ bne,pn %xcc, 6b /* CTI */
+ lduba [%o0] ASI_PNF, %o2 /* Load */
+
+ brz,pn %o3, 4b /* CTI+IEU1 Group */
+ lduba [%o1] ASI_PNF, %o3 /* Load */
+ andcc %o0, 7, %g0 /* IEU1 Group */
+ bne,a,pn %icc, 8b /* CTI */
+
+ add %o0, 1, %o0 /* IEU0 */
+ or %g1, %g2, %g1 /* IEU0 Group */
+ andcc %o1, 7, %g3 /* IEU1 */
+ be,a,pn %icc, 1b /* CTI */
+
+ ldxa [%o0] ASI_PNF, %o2 /* Load Group */
+9: sllx %g3, 3, %g5 /* IEU0 */
+ mov 64, %o5 /* IEU1 */
+ sub %o1, %g3, %o1 /* IEU0 Group */
+
+ sub %o5, %g5, %o5 /* IEU1 */
+ ldxa [%o1] ASI_PNF, %g7 /* Load Group */
+ or %g1, %g2, %g1 /* IEU0 */
+ sub %o1, %o0, %o1 /* IEU1 */
+
+ sllx %g1, 7, %g2 /* IEU0 Group */
+ add %o1, 8, %o1 /* IEU1 */
+ /* %g1 = 0101010101010101
+ * %g2 = 8080808080800880
+ * %g5 = number of bits to shift left
+ * %o5 = number of bits to shift right */
+10: sllx %g7, %g5, %o3 /* IEU0 Group */
+ ldxa [%o1 + %o0] ASI_PNF, %g7 /* Load */
+
+11: srlx %g7, %o5, %o4 /* IEU0 Group */
+ ldxa [%o0] ASI_PNF, %o2 /* Load */
+ or %o3, %o4, %o3 /* IEU1 */
+ add %o0, 8, %o0 /* IEU0 Group */
+
+ subcc %o2, %o3, %g0 /* IEU1 */
+#ifdef EIGHTBIT_NOT_RARE
+ sub %o2, %g1, %g3 /* IEU0 Group */
+ bne,pn %xcc, 13b /* CTI */
+ andn %g3, %o2, %g4 /* IEU0 Group */
+
+ andcc %g4, %g2, %g0 /* IEU1 Group */
+ be,pt %xcc, 10b /* CTI */
+ srlx %g4, 32, %g4 /* IEU0 */
+ andcc %g4, %g2, %g0 /* IEU1 Group */
+#else
+ bne,pn %xcc, 13b /* CTI */
+ sub %o2, %g1, %g3 /* IEU0 Group */
+ andcc %g3, %g2, %g0 /* IEU1 Group */
+
+ be,pt %xcc, 10b /* CTI */
+ srlx %g3, 32, %g3 /* IEU0 */
+ andcc %g3, %g2, %g0 /* IEU1 Group */
+#endif
+ be,pt %xcc, 12f /* CTI */
+
+ srlx %o2, 56, %g3 /* IEU0 */
+ andcc %g3, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4b /* CTI */
+ srlx %o2, 48, %g3 /* IEU0 */
+
+ andcc %g3, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4b /* CTI */
+ srlx %o2, 40, %g3 /* IEU0 */
+ andcc %g3, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 4b /* CTI */
+ srlx %o2, 32, %g3 /* IEU0 */
+ andcc %g3, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4b /* CTI */
+
+12: srlx %o2, 24, %g3 /* IEU0 */
+ andcc %g3, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4b /* CTI */
+ srlx %o2, 16, %g3 /* IEU0 */
+
+ andcc %g3, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4b /* CTI */
+ srlx %o2, 8, %g3 /* IEU0 */
+ andcc %g3, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 4b /* CTI */
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4b /* CTI */
+ sllx %g7, %g5, %o3 /* IEU0 */
+
+ ba,pt %xcc, 11b /* CTI Group */
+ ldxa [%o1 + %o0] ASI_PNF, %g7 /* Load */
+END(strcmp)
diff --git a/sysdeps/sparc/sparc64/strcpy.S b/sysdeps/sparc/sparc64/strcpy.S
new file mode 100644
index 0000000000..773caf5656
--- /dev/null
+++ b/sysdeps/sparc/sparc64/strcpy.S
@@ -0,0 +1,239 @@
+/* Copy SRC to DEST returning DEST.
+ For SPARC v9.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz> and
+ Jakub Jelinek <jj@ultra.linux.cz>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <asm/asi.h>
+
+ /* Normally, this uses
+ ((xword - 0x0101010101010101) & 0x8080808080808080) test
+ to find out if any byte in xword could be zero. This is fast, but
+ also gives false alarm for any byte in range 0x81-0xff. It does
+ not matter for correctness, as if this test tells us there could
+ be some zero byte, we check it byte by byte, but if bytes with
+ high bits set are common in the strings, then this will give poor
+ performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
+ will use one tick slower, but more precise test
+ ((xword - 0x0101010101010101) & (~xword) & 0x8080808080808080),
+ which does not give any false alarms (but if some bits are set,
+ one cannot assume from it which bytes are zero and which are not).
+ It is yet to be measured, what is the correct default for glibc
+ in these days for an average user.
+ */
+
+ .text
+ .align 32
+ENTRY(strcpy)
+ sethi %hi(0x01010101), %g1 /* IEU0 Group */
+ mov %o0, %g7 /* IEU1 */
+ or %g1, %lo(0x01010101), %g1 /* IEU0 Group */
+ andcc %o0, 7, %g0 /* IEU1 */
+
+ sllx %g1, 32, %g2 /* IEU0 Group */
+ bne,pn %icc, 12f /* CTI */
+ andcc %o1, 7, %g3 /* IEU1 */
+ or %g1, %g2, %g1 /* IEU0 Group */
+
+ bne,pn %icc, 14f /* CTI */
+ sllx %g1, 7, %g2 /* IEU0 Group */
+1: ldx [%o1], %o3 /* Load */
+ add %o1, 8, %o1 /* IEU1 */
+
+2: mov %o3, %g3 /* IEU0 Group */
+3: sub %o3, %g1, %o2 /* IEU1 */
+ ldxa [%o1] ASI_PNF, %o3 /* Load */
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o2, %g3, %o2 /* IEU0 Group */
+#endif
+ add %o0, 8, %o0 /* IEU0 Group */
+
+ andcc %o2, %g2, %g0 /* IEU1 */
+ add %o1, 8, %o1 /* IEU0 Group */
+ be,a,pt %xcc, 2b /* CTI */
+ stx %g3, [%o0 - 8] /* Store */
+
+ srlx %g3, 56, %g5 /* IEU0 Group */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 11f /* CTI */
+ srlx %g3, 48, %g4 /* IEU0 */
+
+ andcc %g4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 10f /* CTI */
+ srlx %g3, 40, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 9f /* CTI */
+ srlx %g3, 32, %g4 /* IEU0 */
+ andcc %g4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 8f /* CTI */
+
+ srlx %g3, 24, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 7f /* CTI */
+ srlx %g3, 16, %g4 /* IEU0 */
+
+ andcc %g4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 6f /* CTI */
+ srlx %g3, 8, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 5f /* CTI */
+ sub %o3, %g1, %o2 /* IEU0 */
+ stx %g3, [%o0 - 8] /* Store Group */
+ andcc %g3, 0xff, %g0 /* IEU1 */
+
+ bne,pt %icc, 3b /* CTI */
+ mov %o3, %g3 /* IEU0 Group */
+4: retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+
+ .align 16
+5: stb %g5, [%o0 - 2] /* Store Group */
+ srlx %g3, 16, %g4 /* IEU0 */
+6: sth %g4, [%o0 - 4] /* Store Group */
+ srlx %g3, 32, %g4 /* IEU0 */
+
+ stw %g4, [%o0 - 8] /* Store Group */
+ retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+7: stb %g5, [%o0 - 4] /* Store Group */
+
+ srlx %g3, 32, %g4 /* IEU0 */
+8: stw %g4, [%o0 - 8] /* Store Group */
+ retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+
+9: stb %g5, [%o0 - 6] /* Store Group */
+ srlx %g3, 48, %g4 /* IEU0 */
+10: sth %g4, [%o0 - 8] /* Store Group */
+ retl /* CTI+IEU1 Group */
+
+ mov %g7, %o0 /* IEU0 */
+11: stb %g5, [%o0 - 8] /* Store Group */
+ retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+
+12: or %g1, %g2, %g1 /* IEU0 Group */
+ ldub [%o1], %o3 /* Load */
+ sllx %g1, 7, %g2 /* IEU0 Group */
+ stb %o3, [%o0] /* Store Group */
+
+13: add %o0, 1, %o0 /* IEU0 */
+ add %o1, 1, %o1 /* IEU1 */
+ andcc %o3, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4b /* CTI */
+
+ lduba [%o1] ASI_PNF, %o3 /* Load */
+ andcc %o0, 7, %g0 /* IEU1 Group */
+ bne,a,pt %icc, 13b /* CTI */
+ stb %o3, [%o0] /* Store */
+
+ andcc %o1, 7, %g3 /* IEU1 Group */
+ be,a,pt %icc, 1b /* CTI */
+ ldx [%o1], %o3 /* Load */
+14: orcc %g0, 64, %g4 /* IEU1 Group */
+
+ sllx %g3, 3, %g5 /* IEU0 */
+ sub %o1, %g3, %o1 /* IEU0 Group */
+ sub %g4, %g5, %g4 /* IEU1 */
+ /* %g1 = 0101010101010101 *
+ * %g2 = 8080808080808080 *
+ * %g3 = source alignment *
+ * %g5 = number of bits to shift left *
+ * %g4 = number of bits to shift right */
+ ldxa [%o1] ASI_PNF, %o5 /* Load Group */
+
+ addcc %o1, 8, %o1 /* IEU1 */
+15: sllx %o5, %g5, %o3 /* IEU0 Group */
+ ldxa [%o1] ASI_PNF, %o5 /* Load */
+ srlx %o5, %g4, %o4 /* IEU0 Group */
+
+ add %o0, 8, %o0 /* IEU1 */
+ or %o3, %o4, %o3 /* IEU0 Group */
+ add %o1, 8, %o1 /* IEU1 */
+ sub %o3, %g1, %o4 /* IEU0 Group */
+
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o4, %o3, %o4 /* IEU0 Group */
+#endif
+ andcc %o4, %g2, %g0 /* IEU1 Group */
+ be,a,pt %xcc, 15b /* CTI */
+ stx %o3, [%o0 - 8] /* Store */
+ srlx %o3, 56, %o4 /* IEU0 Group */
+
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 22f /* CTI */
+ srlx %o3, 48, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 21f /* CTI */
+ srlx %o3, 40, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 20f /* CTI */
+
+ srlx %o3, 32, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 19f /* CTI */
+ srlx %o3, 24, %o4 /* IEU0 */
+
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 18f /* CTI */
+ srlx %o3, 16, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 17f /* CTI */
+ srlx %o3, 8, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 16f /* CTI */
+
+ andcc %o3, 0xff, %g0 /* IEU1 Group */
+ bne,pn %icc, 15b /* CTI */
+ stx %o3, [%o0 - 8] /* Store */
+ retl /* CTI+IEU1 Group */
+
+ mov %g7, %o0 /* IEU0 */
+
+ .align 16
+16: srlx %o3, 8, %o4 /* IEU0 Group */
+ stb %o4, [%o0 - 2] /* Store */
+17: srlx %o3, 16, %o4 /* IEU0 Group */
+ stb %o4, [%o0 - 3] /* Store */
+
+18: srlx %o3, 24, %o4 /* IEU0 Group */
+ stb %o4, [%o0 - 4] /* Store */
+19: srlx %o3, 32, %o4 /* IEU0 Group */
+ stw %o4, [%o0 - 8] /* Store */
+
+ retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+ nop
+ nop
+
+20: srlx %o3, 40, %o4 /* IEU0 Group */
+ stb %o4, [%o0 - 6] /* Store */
+21: srlx %o3, 48, %o4 /* IEU0 Group */
+ stb %o4, [%o0 - 7] /* Store */
+
+22: srlx %o3, 56, %o4 /* IEU0 Group */
+ stb %o4, [%o0 - 8] /* Store */
+ retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+END(strcpy)
diff --git a/sysdeps/sparc/sparc64/strcspn.S b/sysdeps/sparc/sparc64/strcspn.S
new file mode 100644
index 0000000000..51876b0455
--- /dev/null
+++ b/sysdeps/sparc/sparc64/strcspn.S
@@ -0,0 +1,211 @@
+/* strcspn (str, ss) -- Return the length of the initial segment of STR
+ which contains no characters from SS.
+ For SPARC v9.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jj@ultra.linux.cz>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <asm/asi.h>
+#ifndef XCC
+#define XCC xcc
+#define STACK_SIZE 128
+#define STACK_OFFSET 128+0x7ff
+#else
+#define STACK_SIZE 64
+#define STACK_OFFSET 64
+#endif
+
+ .text
+ .align 32
+ENTRY(strcspn)
+ sub %sp, STACK_SIZE+32, %sp /* IEU0 Group */
+ mov 1, %o4 /* IEU1 */
+ stx %o4, [%sp + STACK_OFFSET] /* Store Group */
+ mov %o0, %g7 /* IEU0 */
+
+ stx %g0, [%sp + STACK_OFFSET + 8] /* Store Group */
+ add %sp, STACK_OFFSET, %o5 /* IEU0 */
+ stx %g0, [%sp + STACK_OFFSET + 16] /* Store Group */
+ stx %g0, [%sp + STACK_OFFSET + 24] /* Store Group */
+
+1: ldub [%o1], %o2 /* Load Group */
+ brz,pn %o2, 2f /* CTI+IEU1 Group */
+ srl %o2, 3, %o3 /* IEU0 */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+
+ and %o2, 0x3f, %o2 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+ sllx %o4, %o2, %g1 /* IEU0 */
+ add %o1, 1, %o1 /* IEU1 */
+
+ or %g2, %g1, %g2 /* IEU0 Group */
+ ba,pt %xcc, 1b /* CTI */
+ stx %g2, [%o5 + %o3] /* Store */
+2: andcc %o0, 7, %g0 /* IEU1 Group */
+
+ be,a,pt %xcc, 4f /* CTI */
+ ldx [%o0], %o2 /* Load */
+ ldub [%o0], %o2 /* Load Group */
+3: srl %o2, 3, %o3 /* IEU0 Group */
+
+ and %o2, 0x3f, %o2 /* IEU1 */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+ sllx %o4, %o2, %g1 /* IEU0 */
+
+ add %o0, 1, %o0 /* IEU1 */
+ andcc %g2, %g1, %g0 /* IEU1 Group */
+ bne,pn %xcc, 12f /* CTI */
+ andcc %o0, 7, %g0 /* IEU1 Group */
+
+ bne,a,pt %icc, 3b /* CTI */
+ ldub [%o0], %o2 /* Load */
+ ldx [%o0], %o2 /* Load Group */
+4: srlx %o2, 59, %o3 /* IEU0 Group */
+
+ srlx %o2, 56, %g3 /* IEU0 Group */
+5: and %o3, 0x18, %o3 /* IEU1 */
+ andcc %g3, 0x3f, %g3 /* IEU1 Group */
+ ldx [%o5 + %o3], %g2 /* Load */
+
+ srlx %o2, 51, %o3 /* IEU0 */
+ sllx %o4, %g3, %g1 /* IEU0 Group */
+ srlx %o2, 48, %g3 /* IEU0 Group */
+ andcc %g2, %g1, %g2 /* IEU1 */
+
+ bne,pn %xcc, 13f /* CTI */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %g3, 0x3f, %g3 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+
+ srlx %o2, 43, %o3 /* IEU0 */
+ sllx %o4, %g3, %g1 /* IEU0 Group */
+ srlx %o2, 40, %g3 /* IEU0 Group */
+ andcc %g2, %g1, %g2 /* IEU1 */
+
+ bne,pn %xcc, 14f /* CTI */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %g3, 0x3f, %g3 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+
+ srlx %o2, 35, %o3 /* IEU0 */
+ sllx %o4, %g3, %g1 /* IEU0 Group */
+ srlx %o2, 32, %g3 /* IEU0 Group */
+ andcc %g2, %g1, %g2 /* IEU1 */
+
+ bne,pn %xcc, 15f /* CTI */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %g3, 0x3f, %g3 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+
+ srlx %o2, 27, %o3 /* IEU0 */
+ sllx %o4, %g3, %g1 /* IEU0 Group */
+ srlx %o2, 24, %g3 /* IEU0 Group */
+ andcc %g2, %g1, %g2 /* IEU1 */
+
+ bne,pn %xcc, 16f /* CTI */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %g3, 0x3f, %g3 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+
+ srlx %o2, 19, %o3 /* IEU0 */
+ sllx %o4, %g3, %g1 /* IEU0 Group */
+ srlx %o2, 16, %g3 /* IEU0 Group */
+ andcc %g2, %g1, %g2 /* IEU1 */
+
+ bne,pn %xcc, 17f /* CTI */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %g3, 0x3f, %g3 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+
+ srlx %o2, 11, %o3 /* IEU0 */
+ sllx %o4, %g3, %g1 /* IEU0 Group */
+ add %o0, 8, %o0 /* IEU1 */
+ srlx %o2, 8, %g3 /* IEU0 Group */
+
+ andcc %g2, %g1, %g2 /* IEU1 */
+ bne,pn %xcc, 18f /* CTI */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %g3, 0x3f, %g3 /* IEU1 */
+
+ ldx [%o5 + %o3], %g2 /* Load Group */
+ sllx %o4, %g3, %g1 /* IEU0 */
+ mov %o2, %g3 /* IEU1 */
+ srlx %o2, 3, %o3 /* IEU0 Group */
+
+ ldxa [%o0] ASI_PNF, %o2 /* Load */
+ andcc %g2, %g1, %g2 /* IEU1 Group */
+ bne,pn %xcc, 19f /* CTI */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+
+ and %g3, 0x3f, %g3 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+ sllx %o4, %g3, %g1 /* IEU0 */
+ srlx %o2, 59, %o3 /* IEU0 Group */
+
+ andcc %g2, %g1, %g2 /* IEU1 Group */
+ be,pt %xcc, 5b /* CTI */
+ srlx %o2, 56, %g3 /* IEU0 Group */
+ sub %o0, 1, %o0 /* IEU1 */
+
+ add %sp, STACK_SIZE+32, %sp /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %g7, %o0 /* IEU0 */
+
+ .align 16
+19: sub %o0, 2, %o0 /* IEU1 */
+ add %sp, STACK_SIZE+32, %sp /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %g7, %o0 /* IEU0 */
+
+18: sub %o0, 3, %o0 /* IEU1 */
+ add %sp, STACK_SIZE+32, %sp /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %g7, %o0 /* IEU0 */
+
+17: add %o0, 4, %o0 /* IEU1 */
+ add %sp, STACK_SIZE+32, %sp /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %g7, %o0 /* IEU0 */
+
+16: add %o0, 3, %o0 /* IEU1 */
+ add %sp, STACK_SIZE+32, %sp /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %g7, %o0 /* IEU0 */
+
+15: add %o0, 2, %o0 /* IEU1 */
+ add %sp, STACK_SIZE+32, %sp /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %g7, %o0 /* IEU0 */
+
+14: add %o0, 1, %o0 /* IEU1 */
+ add %sp, STACK_SIZE+32, %sp /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %g7, %o0 /* IEU0 */
+
+13: add %sp, STACK_SIZE+32, %sp /* IEU1 */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %g7, %o0 /* IEU0 */
+
+ .align 16
+12: sub %o0, 1, %o0 /* IEU0 Group */
+ add %sp, STACK_SIZE+32, %sp /* IEU1 */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %g7, %o0 /* IEU0 */
+END(strcspn)
diff --git a/sysdeps/sparc/sparc64/strlen.S b/sysdeps/sparc/sparc64/strlen.S
new file mode 100644
index 0000000000..3facf40746
--- /dev/null
+++ b/sysdeps/sparc/sparc64/strlen.S
@@ -0,0 +1,172 @@
+/* Determine the length of a string. For SPARC v9.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ Contributed by Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz> and
+ Jakub Jelinek <jj@ultra.linux.cz>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <asm/asi.h>
+
+ /* Normally, this uses
+ ((xword - 0x0101010101010101) & 0x8080808080808080) test
+ to find out if any byte in xword could be zero. This is fast, but
+ also gives false alarm for any byte in range 0x81-0xff. It does
+ not matter for correctness, as if this test tells us there could
+ be some zero byte, we check it byte by byte, but if bytes with
+ high bits set are common in the strings, then this will give poor
+ performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
+ will use one tick slower, but more precise test
+ ((xword - 0x0101010101010101) & (~xword) & 0x8080808080808080),
+ which does not give any false alarms (but if some bits are set,
+ one cannot assume from it which bytes are zero and which are not).
+ It is yet to be measured, what is the correct default for glibc
+ in these days for an average user.
+ */
+
+ .text
+ .align 32
+ENTRY(strlen)
+ sethi %hi(0x01010101), %g1 /* IEU0 Group */
+ ldub [%o0], %o3 /* Load */
+ or %g1, %lo(0x01010101), %g1 /* IEU0 Group */
+ mov %o0, %o1 /* IEU1 */
+
+ sllx %g1, 32, %g2 /* IEU0 Group */
+ andcc %o0, 7, %g0 /* IEU1 */
+ or %g1, %g2, %g1 /* IEU0 Group */
+ brz,pn %o3, 13f /* CTI+IEU1 */
+
+ sllx %g1, 7, %g2 /* IEU0 Group */
+ bne,a,pn %icc, 15f /* CTI */
+ add %o0, 1, %o0 /* IEU1 */
+ /* %g1 = 0x0101010101010101 *
+ * %g2 = 0x8080808080808080 *
+ * %o0 = string pointer *
+ * %o1 = start of string */
+1: ldx [%o0], %o3 /* Load Group */
+
+ add %o0, 8, %o0 /* IEU1 */
+2: sub %o3, %g1, %o2 /* IEU0 Group */
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o2, %o3, %g7 /* IEU0 Group */
+ ldxa [%o0] ASI_PNF, %o3 /* Load */
+ andcc %g7, %g2, %g0 /* IEU1 Group */
+#else
+ ldxa [%o0] ASI_PNF, %o3 /* Load */
+ andcc %o2, %g2, %g0 /* IEU1 Group */
+#endif
+
+ be,pt %xcc, 2b /* CTI */
+ add %o0, 8, %o0 /* IEU0 */
+ addcc %o2, %g1, %g3 /* IEU1 Group */
+#ifdef EIGHTBIT_NOT_RARE
+ srlx %g7, 32, %g7 /* IEU0 */
+
+3: andcc %g7, %g2, %g0 /* IEU1 Group */
+#else
+ srlx %o2, 32, %o2 /* IEU0 */
+
+3: andcc %o2, %g2, %g0 /* IEU1 Group */
+#endif
+ be,pn %xcc, 4f /* CTI */
+ srlx %g3, 56, %o2 /* IEU0 */
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 12f /* CTI */
+ srlx %g3, 48, %o2 /* IEU0 */
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 11f /* CTI */
+
+ srlx %g3, 40, %o2 /* IEU0 */
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 10f /* CTI */
+ srlx %g3, 32, %o2 /* IEU0 */
+
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 9f /* CTI */
+4: srlx %g3, 24, %o2 /* IEU0 */
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 8f /* CTI */
+ srlx %g3, 16, %o2 /* IEU0 */
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 7f /* CTI */
+
+ srlx %g3, 8, %o2 /* IEU0 */
+ andcc %o2, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 6f /* CTI */
+ sub %o3, %g1, %o2 /* IEU0 */
+
+ andcc %g3, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 5f /* CTI */
+ ldxa [%o0] ASI_PNF, %o3 /* Load */
+ andcc %o2, %g2, %g0 /* IEU1 Group */
+
+ be,pt %xcc, 2b /* CTI */
+ add %o0, 8, %o0 /* IEU0 */
+ addcc %o2, %g1, %g3 /* IEU1 Group */
+ ba,pt %xcc, 3b /* CTI */
+
+ srlx %o2, 32, %o2 /* IEU0 */
+5: add %o0, -9, %o0 /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %o1, %o0 /* IEU0 */
+
+6: add %o0, -10, %o0 /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %o1, %o0 /* IEU0 */
+7: add %o0, -11, %o0 /* IEU0 Group */
+
+ retl /* CTI+IEU1 Group */
+ sub %o0, %o1, %o0 /* IEU0 */
+8: add %o0, -12, %o0 /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+
+ sub %o0, %o1, %o0 /* IEU0 */
+9: add %o0, -13, %o0 /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %o1, %o0 /* IEU0 */
+
+10: add %o0, -14, %o0 /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %o1, %o0 /* IEU0 */
+11: add %o0, -15, %o0 /* IEU0 Group */
+
+ retl /* CTI+IEU1 Group */
+ sub %o0, %o1, %o0 /* IEU0 */
+12: add %o0, -16, %o0 /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+
+ sub %o0, %o1, %o0 /* IEU0 */
+13: retl /* CTI+IEU1 Group */
+ mov 0, %o0 /* IEU0 */
+ nop
+
+15: ldub [%o0], %o3 /* Load Group */
+16: andcc %o0, 7, %g0 /* IEU1 */
+ be,pn %icc, 1b /* CTI */
+ nop /* IEU0 Group */
+
+ add %o0, 1, %o0 /* IEU1 */
+ andcc %o3, 0xff, %g0 /* IEU1 Group */
+ bne,a,pt %icc, 16b /* CTI */
+ lduba [%o0] ASI_PNF, %o3 /* Load */
+
+ add %o0, -1, %o0 /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %o1, %o0 /* IEU0 */
+END(strlen)
diff --git a/sysdeps/sparc/sparc64/strncmp.S b/sysdeps/sparc/sparc64/strncmp.S
new file mode 100644
index 0000000000..361748dd26
--- /dev/null
+++ b/sysdeps/sparc/sparc64/strncmp.S
@@ -0,0 +1,359 @@
+/* Compare no more than N characters of S1 and S2, returning less than,
+ equal to or greater than zero if S1 is lexicographically less than,
+ equal to or greater than S2.
+ For SPARC v9.
+ Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz> and
+ Jakub Jelinek <jj@ultra.linux.cz>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <asm/asi.h>
+#ifndef XCC
+#define XCC xcc
+#define USE_BPR
+#endif
+
+ /* Normally, this uses
+ ((xword - 0x0101010101010101) & 0x8080808080808080) test
+ to find out if any byte in xword could be zero. This is fast, but
+ also gives false alarm for any byte in range 0x81-0xff. It does
+ not matter for correctness, as if this test tells us there could
+ be some zero byte, we check it byte by byte, but if bytes with
+ high bits set are common in the strings, then this will give poor
+ performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
+ will use one tick slower, but more precise test
+ ((xword - 0x0101010101010101) & (~xword) & 0x8080808080808080),
+ which does not give any false alarms (but if some bits are set,
+ one cannot assume from it which bytes are zero and which are not).
+ It is yet to be measured, what is the correct default for glibc
+ in these days for an average user.
+ */
+
+ .text
+ .align 32
+ENTRY(strncmp)
+#ifdef USE_BPR
+ brz,pn %o2, 4f /* CTI+IEU1 Group */
+#else
+ tst %o2 /* IEU1 Group */
+ be,pn %XCC, 4f /* CTI */
+#endif
+ sethi %hi(0x1010101), %g1 /* IEU0 */
+ andcc %o0, 7, %g0 /* IEU1 Group */
+ bne,pn %icc, 9f /* CTI */
+
+ or %g1, %lo(0x1010101), %g1 /* IEU0 */
+ andcc %o1, 7, %g3 /* IEU1 Group */
+ bne,pn %icc, 11f /* CTI */
+ sllx %g1, 32, %g2 /* IEU0 */
+
+ ldx [%o0], %g4 /* Load Group */
+ or %g1, %g2, %g1 /* IEU0 */
+1: ldx [%o1], %o3 /* Load Group */
+ sllx %g1, 7, %g2 /* IEU0 */
+
+ add %o0, 8, %o0 /* IEU1 */
+2: subcc %o2, 8, %o2 /* IEU1 Group */
+ bl,pn %XCC, 5f /* CTI */
+ add %o1, 8, %o1 /* IEU0 */
+
+ sub %g4, %g1, %g3 /* IEU0 Group */
+ subcc %g4, %o3, %o4 /* IEU1 */
+#ifdef EIGHTBIT_NOT_RARE
+ andn %g3, %g4, %g7 /* IEU0 Group */
+#endif
+ bne,pn %xcc, 6f /* CTI */
+ ldxa [%o0] ASI_PNF, %g4 /* Load Group */
+
+ add %o0, 8, %o0 /* IEU0 */
+#ifdef EIGHTBIT_NOT_RARE
+ andcc %g7, %g2, %g0 /* IEU1 */
+#else
+ andcc %g3, %g2, %g0 /* IEU1 */
+#endif
+ be,a,pt %xcc, 2b /* CTI */
+ ldxa [%o1] ASI_PNF, %o3 /* Load Group */
+
+ addcc %g3, %g1, %o4 /* IEU1 */
+#ifdef EIGHTBIT_NOT_RARE
+ srlx %g7, 32, %g7 /* IEU0 */
+ andcc %g7, %g2, %g0 /* IEU1 Group */
+#else
+ srlx %g3, 32, %g3 /* IEU0 */
+ andcc %g3, %g2, %g0 /* IEU1 Group */
+#endif
+ be,pt %xcc, 3f /* CTI */
+
+ srlx %o4, 56, %o5 /* IEU0 */
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4f /* CTI */
+ srlx %o4, 48, %o5 /* IEU0 */
+
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4f /* CTI */
+ srlx %o4, 40, %o5 /* IEU0 */
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 4f /* CTI */
+ srlx %o4, 32, %o5 /* IEU0 */
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4f /* CTI */
+
+3: srlx %o4, 24, %o5 /* IEU0 */
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4f /* CTI */
+ srlx %o4, 16, %o5 /* IEU0 */
+
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4f /* CTI */
+ srlx %o4, 8, %o5 /* IEU0 */
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 4f /* CTI */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ bne,a,pn %icc, 2b /* CTI */
+ ldxa [%o1] ASI_PNF, %o3 /* Load */
+
+4: retl /* CTI+IEU1 Group */
+ clr %o0 /* IEU0 */
+
+ .align 16
+5: srlx %g4, 56, %o4 /* IEU0 Group */
+ cmp %o2, -8 /* IEU1 */
+ be,pn %XCC, 4b /* CTI */
+ srlx %o3, 56, %o5 /* IEU0 Group */
+
+ andcc %o4, 0xff, %g0 /* IEU1 */
+ be,pn %xcc, 8f /* CTI */
+ subcc %o4, %o5, %o4 /* IEU1 Group */
+ bne,pn %xcc, 8f /* CTI */
+
+ srlx %o3, 48, %o5 /* IEU0 */
+ cmp %o2, -7 /* IEU1 Group */
+ be,pn %XCC, 4b /* CTI */
+ srlx %g4, 48, %o4 /* IEU0 */
+
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %xcc, 8f /* CTI */
+ subcc %o4, %o5, %o4 /* IEU1 Group */
+ bne,pn %xcc, 8f /* CTI */
+
+ srlx %o3, 40, %o5 /* IEU0 */
+ cmp %o2, -6 /* IEU1 Group */
+ be,pn %XCC, 4b /* CTI */
+ srlx %g4, 40, %o4 /* IEU0 */
+
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %xcc, 8f /* CTI */
+ subcc %o4, %o5, %o4 /* IEU1 Group */
+ bne,pn %xcc, 8f /* CTI */
+
+ srlx %o3, 32, %o5 /* IEU0 */
+ cmp %o2, -5 /* IEU1 Group */
+ be,pn %XCC, 4b /* CTI */
+ srlx %g4, 32, %o4 /* IEU0 */
+
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %xcc, 8f /* CTI */
+ subcc %o4, %o5, %o4 /* IEU1 Group */
+ bne,pn %xcc, 8f /* CTI */
+
+ srlx %o3, 24, %o5 /* IEU0 */
+ cmp %o2, -4 /* IEU1 Group */
+ be,pn %XCC, 4b /* CTI */
+ srlx %g4, 24, %o4 /* IEU0 */
+
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %xcc, 8f /* CTI */
+ subcc %o4, %o5, %o4 /* IEU1 Group */
+ bne,pn %xcc, 8f /* CTI */
+
+ srlx %o3, 16, %o5 /* IEU0 */
+ cmp %o2, -3 /* IEU1 Group */
+ be,pn %XCC, 4b /* CTI */
+ srlx %g4, 16, %o4 /* IEU0 */
+
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %xcc, 8f /* CTI */
+ subcc %o4, %o5, %o4 /* IEU1 Group */
+ bne,pn %xcc, 8f /* CTI */
+
+ srlx %o3, 8, %o5 /* IEU0 */
+ cmp %o2, -2 /* IEU1 Group */
+ be,pn %XCC, 4b /* CTI */
+ srlx %g4, 8, %o4 /* IEU0 */
+
+ retl /* CTI+IEU1 Group */
+ sub %o4, %o5, %o0 /* IEU0 */
+6: addcc %o3, %o4, %g4 /* IEU1 */
+7: srlx %o3, 56, %o5 /* IEU0 */
+
+ srlx %g4, 56, %o4 /* IEU0 Group */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %xcc, 8f /* CTI */
+ subcc %o4, %o5, %o4 /* IEU1 Group */
+
+ bne,pn %xcc, 8f /* CTI */
+ srlx %o3, 48, %o5 /* IEU0 */
+ srlx %g4, 48, %o4 /* IEU0 Group */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %xcc, 8f /* CTI */
+ subcc %o4, %o5, %o4 /* IEU1 Group */
+ bne,pn %xcc, 8f /* CTI */
+ srlx %o3, 40, %o5 /* IEU0 */
+
+ srlx %g4, 40, %o4 /* IEU0 Group */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %xcc, 8f /* CTI */
+ subcc %o4, %o5, %o4 /* IEU1 Group */
+
+ bne,pn %xcc, 8f /* CTI */
+ srlx %o3, 32, %o5 /* IEU0 */
+ srlx %g4, 32, %o4 /* IEU0 Group */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %xcc, 8f /* CTI */
+ subcc %o4, %o5, %o4 /* IEU1 Group */
+ bne,pn %xcc, 8f /* CTI */
+ srlx %o3, 24, %o5 /* IEU0 */
+
+ srlx %g4, 24, %o4 /* IEU0 Group */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %xcc, 8f /* CTI */
+ subcc %o4, %o5, %o4 /* IEU1 Group */
+
+ bne,pn %xcc, 8f /* CTI */
+ srlx %o3, 16, %o5 /* IEU0 */
+ srlx %g4, 16, %o4 /* IEU0 Group */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %xcc, 8f /* CTI */
+ subcc %o4, %o5, %o4 /* IEU1 Group */
+ bne,pn %xcc, 8f /* CTI */
+ srlx %o3, 8, %o5 /* IEU0 */
+
+ srlx %g4, 8, %o4 /* IEU0 Group */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %xcc, 8f /* CTI */
+ subcc %o4, %o5, %o4 /* IEU1 Group */
+
+ retl /* CTI+IEU1 Group */
+ sub %g4, %o3, %o0 /* IEU0 */
+8: retl /* CTI+IEU1 Group */
+ mov %o4, %o0 /* IEU0 */
+
+9: ldub [%o0], %g4 /* Load Group */
+ add %o0, 1, %o0 /* IEU0 */
+ ldub [%o1], %o3 /* Load Group */
+ sllx %g1, 32, %g2 /* IEU0 */
+
+10: subcc %o2, 1, %o2 /* IEU1 Group */
+ be,pn %XCC, 8b /* CTI */
+ sub %g4, %o3, %o4 /* IEU0 */
+ add %o1, 1, %o1 /* IEU0 Group */
+
+ cmp %g4, %o3 /* IEU1 */
+ bne,pn %xcc, 8b /* CTI */
+ lduba [%o0] ASI_PNF, %g4 /* Load Group */
+ andcc %o3, 0xff, %g0 /* IEU1 */
+
+ be,pn %icc, 4b /* CTI */
+ lduba [%o1] ASI_PNF, %o3 /* Load Group */
+ andcc %o0, 7, %g0 /* IEU1 */
+ bne,a,pn %icc, 10b /* CTI */
+
+ add %o0, 1, %o0 /* IEU0 Group */
+ or %g1, %g2, %g1 /* IEU1 */
+ andcc %o1, 7, %g3 /* IEU1 Group */
+ be,pn %icc, 1b /* CTI */
+
+ ldxa [%o0] ASI_PNF, %g4 /* Load */
+11: sllx %g3, 3, %g5 /* IEU0 Group */
+ mov 64, %g7 /* IEU1 */
+ sub %o1, %g3, %o1 /* IEU0 Group */
+
+ sub %g7, %g5, %g7 /* IEU1 */
+ ldxa [%o1] ASI_PNF, %o4 /* Load */
+ sllx %g1, 7, %g2 /* IEU0 Group */
+ add %o1, 8, %o1 /* IEU1 */
+ /* %g1 = 0101010101010101
+ %g2 = 8080808080800880
+ %g3 = %o1 alignment
+ %g5 = number of bits to shift left
+ %g7 = number of bits to shift right */
+
+12: sllx %o4, %g5, %o3 /* IEU0 Group */
+ ldxa [%o1] ASI_PNF, %o4 /* Load */
+ add %o1, 8, %o1 /* IEU1 */
+13: ldxa [%o0] ASI_PNF, %g4 /* Load Group */
+
+ addcc %o0, 8, %o0 /* IEU1 */
+ srlx %o4, %g7, %o5 /* IEU0 */
+ subcc %o2, 8, %o2 /* IEU1 Group */
+ bl,pn %XCC, 5b /* CTI */
+
+ or %o3, %o5, %o3 /* IEU0 */
+ cmp %g4, %o3 /* IEU1 Group */
+ bne,pn %xcc, 7b /* CTI */
+ sub %g4, %g1, %o5 /* IEU0 */
+
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o5, %g4, %o5 /* IEU0 Group */
+#endif
+ andcc %o5, %g2, %g0 /* IEU1 Group */
+ be,pt %xcc, 12b /* CTI */
+ srlx %o5, 32, %o5 /* IEU0 */
+ andcc %o5, %g2, %g0 /* IEU1 Group */
+
+ be,pt %xcc, 14f /* CTI */
+ srlx %g4, 56, %o5 /* IEU0 */
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4b /* CTI */
+
+ srlx %g4, 48, %o5 /* IEU0 */
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4b /* CTI */
+ srlx %g4, 40, %o5 /* IEU0 */
+
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4b /* CTI */
+ srlx %g4, 32, %o5 /* IEU0 */
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 4b /* CTI */
+14: srlx %g4, 24, %o5 /* IEU0 */
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4b /* CTI */
+
+ srlx %g4, 16, %o5 /* IEU0 */
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4b /* CTI */
+ srlx %g4, 8, %o5 /* IEU0 */
+
+ andcc %o5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4b /* CTI */
+ andcc %g4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 4b /* CTI */
+
+ sllx %o4, %g5, %o3 /* IEU0 */
+ ldxa [%o1] ASI_PNF, %o4 /* Load Group */
+ ba,pt %xcc, 13b /* CTI */
+ add %o1, 8, %o1 /* IEU0 */
+END(strncmp)
diff --git a/sysdeps/sparc/sparc64/strncpy.S b/sysdeps/sparc/sparc64/strncpy.S
new file mode 100644
index 0000000000..3d850a8db2
--- /dev/null
+++ b/sysdeps/sparc/sparc64/strncpy.S
@@ -0,0 +1,393 @@
+/* strncpy(DST, SRC, COUNT) - Copy no more than COUNT bytes of the
+ null-terminated string from SRC to DST. If SRC does not cover all of
+ COUNT, the balance is zeroed.
+ For SPARC v9.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz> and
+ Jakub Jelinek <jj@ultra.linux.cz>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <asm/asi.h>
+#ifndef XCC
+#define XCC xcc
+#define USE_BPR
+#endif
+
+ /* Normally, this uses
+ ((xword - 0x0101010101010101) & 0x8080808080808080) test
+ to find out if any byte in xword could be zero. This is fast, but
+ also gives false alarm for any byte in range 0x81-0xff. It does
+ not matter for correctness, as if this test tells us there could
+ be some zero byte, we check it byte by byte, but if bytes with
+ high bits set are common in the strings, then this will give poor
+ performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
+ will use one tick slower, but more precise test
+ ((xword - 0x0101010101010101) & (~xword) & 0x8080808080808080),
+ which does not give any false alarms (but if some bits are set,
+ one cannot assume from it which bytes are zero and which are not).
+ It is yet to be measured, what is the correct default for glibc
+ in these days for an average user.
+ */
+
+ .text
+ .align 32
+ENTRY(strncpy)
+ sethi %hi(0x01010101), %g1 /* IEU0 Group */
+#ifdef USE_BPR
+ brz,pn %o2, 19f /* CTI+IEU1 */
+#else
+ tst %o2 /* IEU1 */
+ be,pn %XCC, 19f /* CTI */
+#endif
+ mov %o0, %g7 /* IEU0 Group */
+ or %g1, %lo(0x01010101), %g1 /* IEU1 */
+
+ andcc %o0, 7, %g0 /* IEU1 Group */
+ sllx %g1, 32, %g2 /* IEU0 */
+ bne,pn %icc, 26f /* CTI */
+ or %g1, %g2, %g1 /* IEU0 Group */
+
+ andcc %o1, 7, %g3 /* IEU1 */
+ bne,pn %icc, 28f /* CTI */
+ sllx %g1, 7, %g2 /* IEU0 Group */
+ ldx [%o1], %o3 /* Load */
+
+1: add %o1, 8, %o1 /* IEU1 */
+2: subcc %o2, 8, %o2 /* IEU1 Group */
+ bl,pn %XCC, 18f /* CTI */
+ sub %o3, %g1, %o4 /* IEU0 */
+
+ add %o0, 8, %o0 /* IEU0 Group */
+#ifdef EIGHTBIT_NOT_MORE
+ andn %o4, %o3, %o4 /* IEU1 */
+#endif
+ mov %o3, %g3 /* IEU1 */
+ ldxa [%o1] ASI_PNF, %o3 /* Load */
+ add %o1, 8, %o1 /* IEU0 Group */
+
+ andcc %o4, %g2, %g0 /* IEU1 */
+ be,a,pt %xcc, 2b /* CTI */
+ stx %g3, [%o0-8] /* Store Group */
+ srlx %g3, 56, %g5 /* IEU0 Group */
+
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 16f /* CTI */
+ srlx %g3, 48, %g4 /* IEU0 */
+ andcc %g4, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 15f /* CTI */
+ srlx %g3, 40, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 14f /* CTI */
+
+ srlx %g3, 32, %g4 /* IEU0 */
+ andcc %g4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 13f /* CTI */
+ srlx %g3, 24, %g5 /* IEU0 */
+
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 12f /* CTI */
+ srlx %g3, 16, %g4 /* IEU0 */
+ andcc %g4, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 11f /* CTI */
+ srlx %g3, 8, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 10f /* CTI */
+
+ andcc %g3, 0xff, %g0 /* IEU1 Group */
+ bne,pt %icc, 2b /* CTI */
+3: stx %g3, [%o0-8] /* Store */
+ andncc %o2, 31, %g3 /* IEU1 Group */
+
+4: be,pn %XCC, 41f /* CTI */
+ and %o2, 31, %o2 /* IEU1 Group */
+40: stx %g0, [%o0] /* Store */
+ stx %g0, [%o0 + 8] /* Store Group */
+
+ subcc %g3, 32, %g3 /* IEU1 */
+ stx %g0, [%o0 + 16] /* Store Group */
+ stx %g0, [%o0 + 24] /* Store Group */
+ bne,pt %XCC, 40b /* CTI */
+
+ add %o0, 32, %o0 /* IEU0 */
+41: subcc %o2, 8, %o2 /* IEU1 Group */
+ bl,a,pn %XCC, 6f /* CTI */
+ andcc %o2, 4, %g0 /* IEU1 Group */
+
+5: stx %g0, [%o0] /* Store */
+ subcc %o2, 8, %o2 /* IEU1 Group */
+ bge,pt %XCC, 5b /* CTI */
+ add %o0, 8, %o0 /* IEU0 */
+
+ andcc %o2, 4, %g0 /* IEU1 Group */
+6: be,a,pn %icc, 7f /* CTI */
+ andcc %o2, 2, %g0 /* IEU1 Group */
+ stw %g0, [%o0] /* Store */
+
+ add %o0, 4, %o0 /* IEU0 */
+ andcc %o2, 2, %g0 /* IEU1 Group */
+7: be,a,pn %icc, 8f /* CTI */
+ andcc %o2, 1, %g0 /* IEU1 Group */
+
+ sth %g0, [%o0] /* Store */
+ add %o0, 2, %o0 /* IEU0 */
+ andcc %o2, 1, %g0 /* IEU1 Group */
+8: bne,a,pn %icc, 9f /* CTI */
+
+ stb %g0, [%o0] /* Store */
+9: retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+
+ .align 16
+10: ba,pt %xcc, 3b /* CTI */
+ sllx %g5, 8, %g3 /* IEU0 */
+11: ba,pt %xcc, 3b /* CTI Group */
+ sllx %g4, 16, %g3 /* IEU0 */
+
+12: ba,pt %xcc, 3b /* CTI Group */
+ sllx %g5, 24, %g3 /* IEU0 */
+13: ba,pt %xcc, 3b /* CTI Group */
+ sllx %g4, 32, %g3 /* IEU0 */
+
+14: ba,pt %xcc, 3b /* CTI Group */
+ sllx %g5, 40, %g3 /* IEU0 */
+15: ba,pt %xcc, 3b /* CTI Group */
+ sllx %g4, 48, %g3 /* IEU0 */
+
+16: ba,pt %xcc, 3b /* CTI */
+ sllx %g5, 56, %g3 /* IEU0 */
+17: or %o3, %o4, %o3 /* IEU0 Group */
+ sub %o3, %g1, %o4 /* IEU1 */
+
+18: addcc %o2, 8, %o2 /* IEU1 Group */
+ be,pn %XCC, 19f /* CTI */
+ andcc %o4, %g2, %g0 /* IEU1 Group */
+ be,pt %xcc, 21f /* CTI */
+
+ srlx %o3, 56, %g5 /* IEU0 */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 20f /* CTI */
+ stb %g5, [%o0] /* Store */
+
+ add %o0, 1, %o0 /* IEU0 Group */
+ subcc %o2, 1, %o2 /* IEU1 */
+ be,pn %XCC, 19f /* CTI */
+ srlx %o3, 48, %g5 /* IEU0 Group */
+
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 20f /* CTI */
+ stb %g5, [%o0] /* Store */
+ add %o0, 1, %o0 /* IEU0 Group */
+
+ subcc %o2, 1, %o2 /* IEU1 */
+ be,pn %XCC, 19f /* CTI */
+ srlx %o3, 40, %g5 /* IEU0 Group */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 20f /* CTI */
+ stb %g5, [%o0] /* Store */
+ add %o0, 1, %o0 /* IEU0 Group */
+ subcc %o2, 1, %o2 /* IEU1 */
+
+ be,pn %XCC, 19f /* CTI */
+ srlx %o3, 32, %g5 /* IEU0 Group */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 20f /* CTI */
+
+ stb %g5, [%o0] /* Store */
+ add %o0, 1, %o0 /* IEU0 Group */
+ subcc %o2, 1, %o2 /* IEU1 */
+ be,pn %XCC, 19f /* CTI */
+
+ srlx %o3, 24, %g5 /* IEU0 Group */
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 20f /* CTI */
+ stb %g5, [%o0] /* Store */
+
+ add %o0, 1, %o0 /* IEU0 Group */
+ subcc %o2, 1, %o2 /* IEU1 */
+ be,pn %XCC, 19f /* CTI */
+ srlx %o3, 16, %g5 /* IEU0 Group */
+
+ andcc %g5, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 20f /* CTI */
+ stb %g5, [%o0] /* Store */
+ add %o0, 1, %o0 /* IEU0 Group */
+
+ subcc %o2, 1, %o2 /* IEU1 */
+ be,pn %XCC, 19f /* CTI */
+ srlx %o3, 8, %g5 /* IEU0 Group */
+ stb %g5, [%o0] /* Store */
+
+19: retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+50: stb %g0, [%o0] /* Store Group */
+20: subcc %o2, 1, %o2 /* IEU1 Group */
+
+ bne,pt %XCC, 50b /* CTI */
+ add %o0, 1, %o0 /* IEU0 */
+ retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+
+21: andcc %o2, 4, %g0 /* IEU1 Group */
+ be,pn %icc, 22f /* CTI */
+ srlx %o3, 32, %g5 /* IEU0 */
+ stw %g5, [%o0] /* Store Group */
+
+ add %o0, 4, %o0 /* IEU0 */
+ mov %o3, %g5 /* IEU1 */
+22: andcc %o2, 2, %g0 /* IEU1 Group */
+ be,pn %icc, 23f /* CTI */
+
+ srlx %g5, 16, %g4 /* IEU0 */
+ sth %g4, [%o0] /* Store Group */
+ add %o0, 2, %o0 /* IEU0 */
+ mov %g5, %g4 /* IEU1 */
+
+23: srlx %g4, 8, %g4 /* IEU0 Group */
+ andcc %o2, 1, %g0 /* IEU1 */
+ bne,a,pn %icc, 24f /* CTI */
+ stb %g4, [%o0] /* Store Group */
+
+24: retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+25: andcc %o0, 7, %g0 /* IEU1 Group */
+ be,a,pn %icc, 4b /* CTI */
+
+ andncc %o2, 31, %g3 /* IEU1 Group */
+ stb %g0, [%o0] /* Store Group */
+ subcc %o2, 1, %o2 /* IEU1 */
+ bne,pt %XCC, 25b /* CTI */
+
+ add %o0, 1, %o0 /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ mov %g7, %o0 /* IEU0 */
+
+ .align 16
+26: ldub [%o1], %o3 /* Load */
+ sllx %g1, 7, %g2 /* IEU0 Group */
+ stb %o3, [%o0] /* Store */
+27: subcc %o2, 1, %o2 /* IEU1 */
+
+ be,pn %XCC, 9b /* CTI */
+ add %o1, 1, %o1 /* IEU0 Group */
+ add %o0, 1, %o0 /* IEU1 */
+ andcc %o3, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 25b /* CTI */
+ lduba [%o1] ASI_PNF, %o3 /* Load */
+ andcc %o0, 7, %g0 /* IEU1 Group */
+ bne,a,pt %icc, 27b /* CTI */
+
+ stb %o3, [%o0] /* Store */
+ andcc %o1, 7, %g3 /* IEU1 Group */
+ be,a,pt %icc, 1b /* CTI */
+ ldx [%o1], %o3 /* Load */
+
+28: orcc %g0, 64, %g4 /* IEU1 Group */
+ sllx %g3, 3, %g5 /* IEU0 */
+ sub %g4, %g5, %g4 /* IEU0 Group */
+ sub %o1, %g3, %o1 /* IEU1 */
+ /* %g1 = 0101010101010101
+ %g2 = 8080808080808080
+ %g3 = source alignment
+ %g5 = number of bits to shift left
+ %g4 = number of bits to shift right */
+
+ ldxa [%o1] ASI_PNF, %o5 /* Load Group */
+ addcc %o1, 8, %o1 /* IEU1 */
+
+29: sllx %o5, %g5, %o3 /* IEU0 Group */
+ ldxa [%o1] ASI_PNF, %o5 /* Load */
+ subcc %o2, 8, %o2 /* IEU1 */
+ bl,pn %XCC, 17b /* CTI */
+
+ srlx %o5, %g4, %o4 /* IEU0 Group */
+ add %o1, 8, %o1 /* IEU1 */
+ or %o3, %o4, %o3 /* IEU0 Group */
+ add %o0, 8, %o0 /* IEU1 */
+
+ sub %o3, %g1, %o4 /* IEU0 Group */
+#ifdef EIGHTBIT_NOT_RARE
+ andn %o4, %o3, %o4 /* IEU0 Group */
+#endif
+ andcc %o4, %g2, %g0 /* IEU1 Group */
+ be,a,pt %xcc, 29b /* CTI */
+ stx %o3, [%o0-8] /* Store */
+
+ srlx %o3, 56, %o4 /* IEU0 Group */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 36f /* CTI */
+ srlx %o3, 48, %o4 /* IEU0 */
+
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 35f /* CTI */
+ srlx %o3, 40, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 34f /* CTI */
+ srlx %o3, 32, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 33f /* CTI */
+
+ srlx %o3, 24, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 32f /* CTI */
+ srlx %o3, 16, %o4 /* IEU0 */
+
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+ be,pn %icc, 31f /* CTI */
+ srlx %o3, 8, %o4 /* IEU0 */
+ andcc %o4, 0xff, %g0 /* IEU1 Group */
+
+ be,pn %icc, 30f /* CTI */
+ andcc %o3, 0xff, %g0 /* IEU1 Group */
+ bne,pn %icc, 29b /* CTI */
+ stx %o3, [%o0-8] /* Store */
+
+ ba,pt %xcc, 4b /* CTI Group */
+ andncc %o2, 31, %g3 /* IEU1 */
+30: srlx %o3, 8, %o4 /* IEU0 */
+ ba,pt %xcc, 3b /* CTI */
+
+ sllx %o4, 8, %g3 /* IEU0 Group */
+31: srlx %o3, 16, %o4 /* IEU0 Group */
+ ba,pt %xcc, 3b /* CTI */
+ sllx %o4, 16, %g3 /* IEU0 Group */
+
+32: srlx %o3, 24, %o4 /* IEU0 Group */
+ ba,pt %xcc, 3b /* CTI */
+ sllx %o4, 24, %g3 /* IEU0 Group */
+33: srlx %o3, 32, %o4 /* IEU0 Group */
+
+ ba,pt %xcc, 3b /* CTI */
+ sllx %o4, 32, %g3 /* IEU0 Group */
+34: srlx %o3, 40, %o4 /* IEU0 Group */
+ ba,pt %xcc, 3b /* CTI */
+
+ sllx %o4, 40, %g3 /* IEU0 Group */
+35: srlx %o3, 48, %o4 /* IEU0 Group */
+ ba,pt %xcc, 3b /* CTI */
+ sllx %o4, 48, %g3 /* IEU0 Group */
+
+36: srlx %o3, 56, %o4 /* IEU0 Group */
+ ba,pt %xcc, 3b /* CTI */
+ sllx %o4, 56, %g3 /* IEU0 Group */
+END(strncpy)
diff --git a/sysdeps/sparc/sparc64/strpbrk.S b/sysdeps/sparc/sparc64/strpbrk.S
new file mode 100644
index 0000000000..c23ae9995d
--- /dev/null
+++ b/sysdeps/sparc/sparc64/strpbrk.S
@@ -0,0 +1,229 @@
+/* strpbrk (s, accept) -- Find the first occurrence in S of any character in
+ ACCEPT.
+ For SPARC v9.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jj@ultra.linux.cz>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <asm/asi.h>
+#ifndef XCC
+#define XCC xcc
+#define STACK_SIZE 128
+#define STACK_OFFSET 128+0x7ff
+#else
+#define STACK_SIZE 64
+#define STACK_OFFSET 64
+#endif
+
+ .text
+ .align 32
+ENTRY(strpbrk)
+ sub %sp, STACK_SIZE+32, %sp /* IEU0 Group */
+ mov 1, %o4 /* IEU1 */
+ stx %o4, [%sp + STACK_OFFSET] /* Store Group */
+ stx %g0, [%sp + STACK_OFFSET + 8] /* Store Group */
+
+ add %sp, STACK_OFFSET, %o5 /* IEU0 */
+ stx %g0, [%sp + STACK_OFFSET + 16] /* Store Group */
+ stx %g0, [%sp + STACK_OFFSET + 24] /* Store Group */
+1: ldub [%o1], %o2 /* Load Group */
+
+ brz,pn %o2, 2f /* CTI+IEU1 Group */
+ srl %o2, 3, %o3 /* IEU0 */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %o2, 0x3f, %o2 /* IEU1 */
+
+ ldx [%o5 + %o3], %g2 /* Load Group */
+ sllx %o4, %o2, %g1 /* IEU0 */
+ add %o1, 1, %o1 /* IEU1 */
+ or %g2, %g1, %g2 /* IEU0 Group */
+
+ ba,pt %xcc, 1b /* CTI */
+ stx %g2, [%o5 + %o3] /* Store */
+2: andcc %o0, 7, %g0 /* IEU1 Group */
+ be,a,pt %xcc, 4f /* CTI */
+
+ ldx [%o0], %o2 /* Load */
+ ldub [%o0], %o2 /* Load Group */
+3: srl %o2, 3, %o3 /* IEU0 Group */
+ and %o2, 0x3f, %o2 /* IEU1 */
+
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+ sllx %o4, %o2, %g1 /* IEU0 */
+ add %o0, 1, %o0 /* IEU1 */
+
+ andcc %g2, %g1, %g0 /* IEU1 Group */
+ bne,pn %xcc, 12f /* CTI */
+ andcc %o0, 7, %g0 /* IEU1 Group */
+ bne,a,pt %icc, 3b /* CTI */
+
+ ldub [%o0], %o2 /* Load */
+ ldx [%o0], %o2 /* Load Group */
+4: srlx %o2, 59, %o3 /* IEU0 Group */
+ srlx %o2, 56, %g3 /* IEU0 Group */
+
+5: and %o3, 0x18, %o3 /* IEU1 */
+ andcc %g3, 0x3f, %g3 /* IEU1 Group */
+ ldx [%o5 + %o3], %g2 /* Load */
+ srlx %o2, 51, %o3 /* IEU0 */
+
+ sllx %o4, %g3, %g1 /* IEU0 Group */
+ srlx %o2, 48, %g3 /* IEU0 Group */
+ andcc %g2, %g1, %g2 /* IEU1 */
+ bne,pn %xcc, 13f /* CTI */
+
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %g3, 0x3f, %g3 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+ srlx %o2, 43, %o3 /* IEU0 */
+
+ sllx %o4, %g3, %g1 /* IEU0 Group */
+ srlx %o2, 40, %g3 /* IEU0 Group */
+ andcc %g2, %g1, %g2 /* IEU1 */
+ bne,pn %xcc, 14f /* CTI */
+
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %g3, 0x3f, %g3 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+ srlx %o2, 35, %o3 /* IEU0 */
+
+ sllx %o4, %g3, %g1 /* IEU0 Group */
+ srlx %o2, 32, %g3 /* IEU0 Group */
+ andcc %g2, %g1, %g2 /* IEU1 */
+ bne,pn %xcc, 15f /* CTI */
+
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %g3, 0x3f, %g3 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+ srlx %o2, 27, %o3 /* IEU0 */
+
+ sllx %o4, %g3, %g1 /* IEU0 Group */
+ srlx %o2, 24, %g3 /* IEU0 Group */
+ andcc %g2, %g1, %g2 /* IEU1 */
+ bne,pn %xcc, 16f /* CTI */
+
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %g3, 0x3f, %g3 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+ srlx %o2, 19, %o3 /* IEU0 */
+
+ sllx %o4, %g3, %g1 /* IEU0 Group */
+ srlx %o2, 16, %g3 /* IEU0 Group */
+ andcc %g2, %g1, %g2 /* IEU1 */
+ bne,pn %xcc, 17f /* CTI */
+
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %g3, 0x3f, %g3 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+ srlx %o2, 11, %o3 /* IEU0 */
+
+ sllx %o4, %g3, %g1 /* IEU0 Group */
+ add %o0, 8, %o0 /* IEU1 */
+ srlx %o2, 8, %g3 /* IEU0 Group */
+ andcc %g2, %g1, %g2 /* IEU1 */
+
+ bne,pn %xcc, 18f /* CTI */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %g3, 0x3f, %g3 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+
+ sllx %o4, %g3, %g1 /* IEU0 */
+ mov %o2, %g5 /* IEU1 */
+ srlx %o2, 3, %o3 /* IEU0 Group */
+ ldxa [%o0] ASI_PNF, %o2 /* Load */
+
+ andcc %g2, %g1, %g2 /* IEU1 Group */
+ bne,pn %xcc, 19f /* CTI */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %g5, 0x3f, %g3 /* IEU1 */
+
+ ldx [%o5 + %o3], %g2 /* Load Group */
+ sllx %o4, %g3, %g1 /* IEU0 */
+ srlx %o2, 59, %o3 /* IEU0 Group */
+ andcc %g2, %g1, %g2 /* IEU1 Group */
+
+ be,pt %xcc, 5b /* CTI */
+ srlx %o2, 56, %g3 /* IEU0 Group */
+ sub %o0, 1, %o0 /* IEU1 */
+ add %sp, STACK_SIZE+32, %sp /* IEU0 Group */
+
+ andcc %g5, 0xff, %g0 /* IEU1 */
+ retl /* CTI+IEU1 Group */
+ move %icc, 0, %o0 /* Single Group */
+
+ .align 16
+19: sub %o0, 2, %o0 /* IEU1 */
+ srl %g5, 8, %g1 /* IEU0 Group */
+ add %sp, STACK_SIZE+32, %sp /* IEU1 */
+ andcc %g1, 0xff, %g0 /* IEU1 Group */
+
+ retl /* CTI+IEU1 Group */
+ move %icc, 0, %o0 /* Single Group */
+18: sub %o0, 3, %o0 /* IEU1 */
+ srl %o2, 16, %g1 /* IEU0 Group */
+
+ add %sp, STACK_SIZE+32, %sp /* IEU1 */
+ andcc %g1, 0xff, %g0 /* IEU1 Group */
+ retl /* CTI+IEU1 Group */
+ move %icc, 0, %o0 /* Single Group */
+
+17: add %o0, 4, %o0 /* IEU1 */
+ srl %o2, 24, %g1 /* IEU0 Group */
+ add %sp, STACK_SIZE+32, %sp /* IEU1 */
+ retl /* CTI+IEU1 Group */
+
+ movrz %g1, 0, %o0 /* Single Group */
+16: add %o0, 3, %o0 /* IEU1 */
+ srlx %o2, 32, %g1 /* IEU0 Group */
+ add %sp, STACK_SIZE+32, %sp /* IEU1 */
+
+ andcc %g1, 0xff, %g0 /* IEU1 Group */
+ retl /* CTI+IEU1 Group */
+ move %icc, 0, %o0 /* Single Group */
+
+ .align 16
+15: add %o0, 2, %o0 /* IEU1 */
+ srlx %o2, 40, %g1 /* IEU0 Group */
+ add %sp, STACK_SIZE+32, %sp /* IEU1 */
+ andcc %g1, 0xff, %g0 /* IEU1 Group */
+
+ retl /* CTI+IEU1 Group */
+ move %icc, 0, %o0 /* Single Group */
+14: add %o0, 1, %o0 /* IEU1 */
+ srlx %o2, 48, %g1 /* IEU0 Group */
+
+ add %sp, STACK_SIZE+32, %sp /* IEU1 */
+ andcc %g1, 0xff, %g0 /* IEU1 Group */
+ retl /* CTI+IEU1 Group */
+ move %icc, 0, %o0 /* Single Group */
+
+13: add %sp, STACK_SIZE+32, %sp /* IEU1 */
+ srlx %o2, 56, %g1 /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ movrz %g1, 0, %o0 /* Single Group */
+
+ .align 16
+12: sub %o0, 1, %o0 /* IEU0 Group */
+ or %o3, %o2, %g1 /* IEU1 */
+ add %sp, STACK_SIZE+32, %sp /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+
+ movrz %g1, 0, %o0 /* Single Group */
+END(strpbrk)
diff --git a/sysdeps/sparc/sparc64/strrchr.c b/sysdeps/sparc/sparc64/strrchr.c
new file mode 100644
index 0000000000..ec608d6ab3
--- /dev/null
+++ b/sysdeps/sparc/sparc64/strrchr.c
@@ -0,0 +1 @@
+/* strrchr is in strchr.S */
diff --git a/sysdeps/sparc/sparc64/strspn.S b/sysdeps/sparc/sparc64/strspn.S
new file mode 100644
index 0000000000..de440c0755
--- /dev/null
+++ b/sysdeps/sparc/sparc64/strspn.S
@@ -0,0 +1,211 @@
+/* strspn (str, ss) -- Return the length of the maximum initial segment
+ of S which contains only characters in ACCEPT.
+ For SPARC v9.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jj@ultra.linux.cz>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <asm/asi.h>
+#ifndef XCC
+#define XCC xcc
+#define STACK_SIZE 128
+#define STACK_OFFSET 128+0x7ff
+#else
+#define STACK_SIZE 64
+#define STACK_OFFSET 64
+#endif
+
+ .text
+ .align 32
+ENTRY(strspn)
+ sub %sp, STACK_SIZE+32, %sp /* IEU0 Group */
+ mov 1, %o4 /* IEU1 */
+ stx %g0, [%sp + STACK_OFFSET] /* Store Group */
+ mov %o0, %g7 /* IEU0 */
+
+ stx %g0, [%sp + STACK_OFFSET + 8] /* Store Group */
+ add %sp, STACK_OFFSET, %o5 /* IEU0 */
+ stx %g0, [%sp + STACK_OFFSET + 16] /* Store Group */
+ stx %g0, [%sp + STACK_OFFSET + 24] /* Store Group */
+
+1: ldub [%o1], %o2 /* Load Group */
+ brz,pn %o2, 2f /* CTI+IEU1 Group */
+ srl %o2, 3, %o3 /* IEU0 */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+
+ and %o2, 0x3f, %o2 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+ sllx %o4, %o2, %g1 /* IEU0 */
+ add %o1, 1, %o1 /* IEU1 */
+
+ or %g2, %g1, %g2 /* IEU0 Group */
+ ba,pt %xcc, 1b /* CTI */
+ stx %g2, [%o5 + %o3] /* Store */
+2: andcc %o0, 7, %g0 /* IEU1 Group */
+
+ be,a,pt %xcc, 4f /* CTI */
+ ldx [%o0], %o2 /* Load */
+ ldub [%o0], %o2 /* Load Group */
+3: srl %o2, 3, %o3 /* IEU0 Group */
+
+ and %o2, 0x3f, %o2 /* IEU1 */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+ sllx %o4, %o2, %g1 /* IEU0 */
+
+ add %o0, 1, %o0 /* IEU1 */
+ andcc %g2, %g1, %g0 /* IEU1 Group */
+ be,pn %xcc, 12f /* CTI */
+ andcc %o0, 7, %g0 /* IEU1 Group */
+
+ bne,a,pt %icc, 3b /* CTI */
+ ldub [%o0], %o2 /* Load */
+ ldx [%o0], %o2 /* Load Group */
+4: srlx %o2, 59, %o3 /* IEU0 Group */
+
+ srlx %o2, 56, %g3 /* IEU0 Group */
+5: and %o3, 0x18, %o3 /* IEU1 */
+ andcc %g3, 0x3f, %g3 /* IEU1 Group */
+ ldx [%o5 + %o3], %g2 /* Load */
+
+ srlx %o2, 51, %o3 /* IEU0 */
+ sllx %o4, %g3, %g1 /* IEU0 Group */
+ srlx %o2, 48, %g3 /* IEU0 Group */
+ andcc %g2, %g1, %g2 /* IEU1 */
+
+ be,pn %xcc, 13f /* CTI */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %g3, 0x3f, %g3 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+
+ srlx %o2, 43, %o3 /* IEU0 */
+ sllx %o4, %g3, %g1 /* IEU0 Group */
+ srlx %o2, 40, %g3 /* IEU0 Group */
+ andcc %g2, %g1, %g2 /* IEU1 */
+
+ be,pn %xcc, 14f /* CTI */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %g3, 0x3f, %g3 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+
+ srlx %o2, 35, %o3 /* IEU0 */
+ sllx %o4, %g3, %g1 /* IEU0 Group */
+ srlx %o2, 32, %g3 /* IEU0 Group */
+ andcc %g2, %g1, %g2 /* IEU1 */
+
+ be,pn %xcc, 15f /* CTI */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %g3, 0x3f, %g3 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+
+ srlx %o2, 27, %o3 /* IEU0 */
+ sllx %o4, %g3, %g1 /* IEU0 Group */
+ srlx %o2, 24, %g3 /* IEU0 Group */
+ andcc %g2, %g1, %g2 /* IEU1 */
+
+ be,pn %xcc, 16f /* CTI */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %g3, 0x3f, %g3 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+
+ srlx %o2, 19, %o3 /* IEU0 */
+ sllx %o4, %g3, %g1 /* IEU0 Group */
+ srlx %o2, 16, %g3 /* IEU0 Group */
+ andcc %g2, %g1, %g2 /* IEU1 */
+
+ be,pn %xcc, 17f /* CTI */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %g3, 0x3f, %g3 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+
+ srlx %o2, 11, %o3 /* IEU0 */
+ sllx %o4, %g3, %g1 /* IEU0 Group */
+ add %o0, 8, %o0 /* IEU1 */
+ srlx %o2, 8, %g3 /* IEU0 Group */
+
+ andcc %g2, %g1, %g2 /* IEU1 */
+ be,pn %xcc, 18f /* CTI */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+ and %g3, 0x3f, %g3 /* IEU1 */
+
+ ldx [%o5 + %o3], %g2 /* Load Group */
+ sllx %o4, %g3, %g1 /* IEU0 */
+ mov %o2, %g3 /* IEU1 */
+ srlx %o2, 3, %o3 /* IEU0 Group */
+
+ ldxa [%o0] ASI_PNF, %o2 /* Load */
+ andcc %g2, %g1, %g2 /* IEU1 Group */
+ be,pn %xcc, 19f /* CTI */
+ and %o3, 0x18, %o3 /* IEU0 Group */
+
+ and %g3, 0x3f, %g3 /* IEU1 */
+ ldx [%o5 + %o3], %g2 /* Load Group */
+ sllx %o4, %g3, %g1 /* IEU0 */
+ srlx %o2, 59, %o3 /* IEU0 Group */
+
+ andcc %g2, %g1, %g2 /* IEU1 Group */
+ bne,pt %xcc, 5b /* CTI */
+ srlx %o2, 56, %g3 /* IEU0 Group */
+ sub %o0, 1, %o0 /* IEU1 */
+
+ add %sp, STACK_SIZE+32, %sp /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %g7, %o0 /* IEU0 */
+
+ .align 16
+19: sub %o0, 2, %o0 /* IEU1 */
+ add %sp, STACK_SIZE+32, %sp /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %g7, %o0 /* IEU0 */
+
+18: sub %o0, 3, %o0 /* IEU1 */
+ add %sp, STACK_SIZE+32, %sp /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %g7, %o0 /* IEU0 */
+
+17: add %o0, 4, %o0 /* IEU1 */
+ add %sp, STACK_SIZE+32, %sp /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %g7, %o0 /* IEU0 */
+
+16: add %o0, 3, %o0 /* IEU1 */
+ add %sp, STACK_SIZE+32, %sp /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %g7, %o0 /* IEU0 */
+
+15: add %o0, 2, %o0 /* IEU1 */
+ add %sp, STACK_SIZE+32, %sp /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %g7, %o0 /* IEU0 */
+
+14: add %o0, 1, %o0 /* IEU1 */
+ add %sp, STACK_SIZE+32, %sp /* IEU0 Group */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %g7, %o0 /* IEU0 */
+
+13: add %sp, STACK_SIZE+32, %sp /* IEU1 */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %g7, %o0 /* IEU0 */
+
+ .align 16
+12: sub %o0, 1, %o0 /* IEU0 Group */
+ add %sp, STACK_SIZE+32, %sp /* IEU1 */
+ retl /* CTI+IEU1 Group */
+ sub %o0, %g7, %o0 /* IEU0 */
+END(strspn)
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile b/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile
index db33fc31ec..0268751286 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile
@@ -1,5 +1,5 @@
-asm-CPPFLAGS=-D__ASSEMBLY__
-ASFLAGS-.os=-fPIC
+asm-CPPFLAGS = -D__ASSEMBLY__
+ASFLAGS-.os += -fPIC
ifeq ($(subdir),misc)
sysdep_routines += setfsgid setfsuid setresgid setresuid