summaryrefslogtreecommitdiff
path: root/sys/lib/libkern/arch
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2016-09-01 09:34:39 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2016-09-01 09:34:39 +0000
commit0eda11d90d22020b557398a0672fffdd4e949f1f (patch)
treee9a6756114a9cd0fd914fa5b68fce2e89a6d969c /sys/lib/libkern/arch
parent455db9251dbe4cfe327232340e9a98ac8cba9a2c (diff)
retire sparc
Diffstat (limited to 'sys/lib/libkern/arch')
-rw-r--r--sys/lib/libkern/arch/sparc/DEFS.h40
-rw-r--r--sys/lib/libkern/arch/sparc/Makefile30
-rw-r--r--sys/lib/libkern/arch/sparc/SYS.h88
-rw-r--r--sys/lib/libkern/arch/sparc/_setjmp.S84
-rw-r--r--sys/lib/libkern/arch/sparc/bcopy.S1
-rw-r--r--sys/lib/libkern/arch/sparc/bzero.S140
-rw-r--r--sys/lib/libkern/arch/sparc/divrem.m4274
-rw-r--r--sys/lib/libkern/arch/sparc/ffs.S109
-rw-r--r--sys/lib/libkern/arch/sparc/htonl.S47
-rw-r--r--sys/lib/libkern/arch/sparc/htons.S47
-rw-r--r--sys/lib/libkern/arch/sparc/memcpy.S1
-rw-r--r--sys/lib/libkern/arch/sparc/memmove.S420
-rw-r--r--sys/lib/libkern/arch/sparc/memset.c1
-rw-r--r--sys/lib/libkern/arch/sparc/mul.S149
-rw-r--r--sys/lib/libkern/arch/sparc/rem.S434
-rw-r--r--sys/lib/libkern/arch/sparc/saveregs.S58
-rw-r--r--sys/lib/libkern/arch/sparc/sdiv.S434
-rw-r--r--sys/lib/libkern/arch/sparc/strlen.S49
-rw-r--r--sys/lib/libkern/arch/sparc/udiv.S417
-rw-r--r--sys/lib/libkern/arch/sparc/umul.S182
-rw-r--r--sys/lib/libkern/arch/sparc/urem.S417
21 files changed, 0 insertions, 3422 deletions
diff --git a/sys/lib/libkern/arch/sparc/DEFS.h b/sys/lib/libkern/arch/sparc/DEFS.h
deleted file mode 100644
index 823c770f999..00000000000
--- a/sys/lib/libkern/arch/sparc/DEFS.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* $OpenBSD: DEFS.h,v 1.3 2003/06/02 23:28:09 millert Exp $ */
-/* $NetBSD: DEFS.h,v 1.2 1994/10/26 06:39:51 cgd Exp $ */
-
-/*-
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)DEFS.h 8.1 (Berkeley) 6/4/93
- */
-
-#include <machine/asm.h>
-
diff --git a/sys/lib/libkern/arch/sparc/Makefile b/sys/lib/libkern/arch/sparc/Makefile
deleted file mode 100644
index a7da47aa6ec..00000000000
--- a/sys/lib/libkern/arch/sparc/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-# $OpenBSD: Makefile,v 1.1 2007/11/25 18:25:36 deraadt Exp $
-# $NetBSD: Makefile.inc,v 1.12 1996/04/23 23:05:22 christos Exp $
-
-all: rem.S sdiv.S udiv.S urem.S
-
-sdiv.S: divrem.m4
- echo 'building ${.TARGET} from ${.ALLSRC}'
- (echo "define(NAME,\`.div')define(NAME2,\`_C_LABEL(_div)')define(OP,\`div')define(S,\`true')"; \
- cat ${.ALLSRC}) | m4 > ${.TARGET}
- chmod 444 ${.TARGET}
-
-udiv.S: divrem.m4
- @echo 'building ${.TARGET} from ${.ALLSRC}'
- @(echo "define(NAME,\`.udiv')define(NAME2,\`_C_LABEL(_udiv)')define(OP,\`div')define(S,\`false')"; \
- cat ${.ALLSRC}) | m4 > ${.TARGET}
- @chmod 444 ${.TARGET}
-
-rem.S: divrem.m4
- echo 'building ${.TARGET} from ${.ALLSRC}'
- (echo "define(NAME,\`.rem')define(NAME2,\`_C_LABEL(_rem)')define(OP,\`rem')define(S,\`true')"; \
- cat ${.ALLSRC}) | m4 > ${.TARGET}
- chmod 444 ${.TARGET}
-
-urem.S: divrem.m4
- @echo 'building ${.TARGET} from ${.ALLSRC}'
- @(echo "define(NAME,\`.urem')define(NAME2,\`_C_LABEL(_urem)')define(OP,\`rem')define(S,\`false')"; \
- cat ${.ALLSRC}) | m4 > ${.TARGET}
- @chmod 444 ${.TARGET}
-
-.include <bsd.own.mk>
diff --git a/sys/lib/libkern/arch/sparc/SYS.h b/sys/lib/libkern/arch/sparc/SYS.h
deleted file mode 100644
index c0b773edc81..00000000000
--- a/sys/lib/libkern/arch/sparc/SYS.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* $OpenBSD: SYS.h,v 1.3 2003/06/02 23:28:09 millert Exp $ */
-/* $NetBSD: SYS.h,v 1.2 1994/10/26 06:39:53 cgd Exp $ */
-
-/*-
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)SYS.h 8.1 (Berkeley) 6/4/93
- *
- * Header: SYS.h,v 1.2 92/07/03 18:57:00 torek Exp
- */
-
-#include <machine/asm.h>
-#include <sys/syscall.h>
-#include <machine/trap.h>
-
-#ifdef __STDC__
-#define _CAT(x,y) x##y
-#else
-#define _CAT(x,y) x/**/y
-#endif
-
-/*
- * ERROR branches to cerror. This is done with a macro so that I can
- * change it to be position independent later, if need be.
- */
-#ifdef PIC
-#define ERROR() \
- PIC_PROLOGUE(%g1,%g2); \
- ld [%g1+cerror],%g2; jmp %g2; nop
-#else
-#define ERROR() \
- sethi %hi(cerror),%g1; or %lo(cerror),%g1,%g1; jmp %g1; nop
-#endif
-
-/*
- * SYSCALL is used when further action must be taken before returning.
- * Note that it adds a `nop' over what we could do, if we only knew what
- * came at label 1....
- */
-#define SYSCALL(x) \
- ENTRY(x); mov _CAT(SYS_,x),%g1; t ST_SYSCALL; bcc 1f; nop; ERROR(); 1:
-
-/*
- * RSYSCALL is used when the system call should just return. Here
- * we use the SYSCALL_G2RFLAG to put the `success' return address in %g2
- * and avoid a branch.
- */
-#define RSYSCALL(x) \
- ENTRY(x); mov (_CAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \
- t ST_SYSCALL; ERROR()
-
-/*
- * PSEUDO(x,y) is like RSYSCALL(y) except that the name is x.
- */
-#define PSEUDO(x,y) \
- ENTRY(x); mov (_CAT(SYS_,y))|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \
- t ST_SYSCALL; ERROR()
-
- .globl cerror
diff --git a/sys/lib/libkern/arch/sparc/_setjmp.S b/sys/lib/libkern/arch/sparc/_setjmp.S
deleted file mode 100644
index 72a87a4cb6a..00000000000
--- a/sys/lib/libkern/arch/sparc/_setjmp.S
+++ /dev/null
@@ -1,84 +0,0 @@
-/* $OpenBSD: _setjmp.S,v 1.4 2007/11/24 19:47:05 deraadt Exp $ */
-/* $NetBSD: _setjmp.S,v 1.2 1994/10/26 06:39:54 cgd Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Header: _setjmp.s,v 1.1 91/07/06 16:45:53 torek Exp
- */
-
-/*
- * C library -- _setjmp, _longjmp
- *
- * _longjmp(a,v)
- * will generate a "return(v?v:1)" from
- * the last call to
- * _setjmp(a)
- * by unwinding the call stack.
- * The previous signal state is NOT restored.
- */
-
-#include "DEFS.h"
-
-ENTRY(_setjmp)
- std %sp, [%o0+0] /* caller's stack pointer and return pc */
- st %fp, [%o0+8] /* store caller's frame pointer */
- retl
- clr %o0 ! return 0
-
-ENTRY(_longjmp)
- addcc %o1, %g0, %g6 ! compute v ? v : 1 in a global register
- be,a 0f
- mov 1, %g6
-0:
- mov %o0, %g1 ! save a in another global register
- ld [%g1+8], %g7 /* get caller's frame */
-1:
- cmp %fp, %g7 ! compare against desired frame
- bl,a 1b ! if below,
- restore ! pop frame and loop
- be,a 2f ! if there,
- ldd [%g1+0], %o2 ! fetch return %sp and pc, and get out
-
-Lbotch:
- call _longjmperror ! otherwise, went too far; bomb out
- nop
- unimp 0
-
-2:
- cmp %o2, %sp ! %sp must not decrease
- bge,a 3f
- mov %o2, %sp ! it is OK, put it in place
- b,a Lbotch
-3:
- jmp %o3 + 8 ! success, return %g6
- mov %g6, %o0
diff --git a/sys/lib/libkern/arch/sparc/bcopy.S b/sys/lib/libkern/arch/sparc/bcopy.S
deleted file mode 100644
index c9361568da4..00000000000
--- a/sys/lib/libkern/arch/sparc/bcopy.S
+++ /dev/null
@@ -1 +0,0 @@
-/* This code is contained in memmove.S */
diff --git a/sys/lib/libkern/arch/sparc/bzero.S b/sys/lib/libkern/arch/sparc/bzero.S
deleted file mode 100644
index 8c61480b68b..00000000000
--- a/sys/lib/libkern/arch/sparc/bzero.S
+++ /dev/null
@@ -1,140 +0,0 @@
-/* $OpenBSD: bzero.S,v 1.4 2007/11/24 19:47:05 deraadt Exp $ */
-/* $NetBSD: bzero.S,v 1.2 1994/10/26 06:39:54 cgd Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Header: bzero.s,v 1.1 92/06/25 12:52:46 torek Exp
- */
-
-#include "DEFS.h"
-
-/*
- * bzero(addr, len)
- *
- * We should unroll the loop, but at the moment this would
- * gain nothing since the `std' instructions are what limits us.
- */
-ENTRY(bzero)
- ! %o0 = addr, %o1 = len
-
- ! Optimize a common case: addr and len are both multiples of 8.
- or %o0, %o1, %o2
- btst 7, %o2 ! ((addr | len) & 7) != 0?
- bnz 1f ! if so, cannot optimize
- clr %g1 ! in any case, we want g1=0
-
- /* `Good' operands, can just store doubles. */
-0:
- deccc 8, %o1 ! while ((len -= 8) >= 0)
- bge,a 0b
- std %g0, [%o0 + %o1] ! *(quad *)(addr + len) = 0;
- retl
- nop
-
- /*
- * Either the address is unaligned, or the count is not a
- * multiple of 8, or both. We will have to align the address
- * in order to use anything `better' than stb.
- */
-1:
- cmp %o1, 15 ! len >= 15?
- bge,a Lstd ! yes, use std
- btst 1, %o0 ! (but first check alignment)
-
- ! not enough to bother: do byte-at-a-time loop.
-2:
- deccc %o1 ! while (--len >= 0)
- bge,a 2b
- stb %g0, [%o0 + %o1] ! addr[len] = 0;
- retl
- nop
-
-Lstd:
- /*
- * There are at least 15 bytes to zero.
- * We may have to zero some initial stuff to align
- * the address.
- */
- bz,a 1f ! if (addr & 1) {
- btst 2, %o0
- stb %g0, [%o0] ! *addr = 0;
- inc %o0 ! addr++;
- dec %o1 ! len--;
- btst 2, %o0 ! }
-1:
- bz,a 1f ! if (addr & 2) {
- btst 4, %o0
- sth %g0, [%o0] ! *(short *)addr = 0;
- inc 2, %o0 ! addr += 2;
- dec 2, %o1 ! len -= 2;
- btst 4, %o0 ! }
-1:
- bz 1f ! if (addr & 4) {
- dec 8, %o1
- st %g0, [%o0] ! *(int *)addr = 0;
- inc 4, %o0 ! addr += 4;
- dec 4, %o1 ! len -= 4;
- ! }
- /*
- * Address is double word aligned; len is 8 less than
- * the number of bytes remaining (i.e., len is 0 if
- * the remaining count is 8, 1 if it is 9, etc.).
- */
-1:
- std %g0, [%o0] ! do {
-2: ! *(quad *)addr = 0;
- inc 8, %o0 ! addr += 8;
- deccc 8, %o1 ! } while ((len -= 8) >= 0);
- bge,a 2b
- std %g0, [%o0]
-
- /*
- * Len is in [-8..-1] where -8 => done, -7 => 1 byte to zero,
- * -6 => two bytes, etc. Mop up this remainder, if any.
- */
- btst 4, %o1
- bz 1f ! if (len & 4) {
- btst 2, %o1
- st %g0, [%o0] ! *(int *)addr = 0;
- inc 4, %o0 ! addr += 4;
-1:
- bz 1f ! if (len & 2) {
- btst 1, %o1
- sth %g0, [%o0] ! *(short *)addr = 0;
- inc 2, %o0 ! addr += 2;
-1:
- bnz,a 1f ! if (len & 1)
- stb %g0, [%o0] ! *addr = 0;
-1:
- retl
- nop
diff --git a/sys/lib/libkern/arch/sparc/divrem.m4 b/sys/lib/libkern/arch/sparc/divrem.m4
deleted file mode 100644
index b7b5b609477..00000000000
--- a/sys/lib/libkern/arch/sparc/divrem.m4
+++ /dev/null
@@ -1,274 +0,0 @@
-/* $OpenBSD: divrem.m4,v 1.8 2011/03/12 18:50:07 deraadt Exp $ */
-/* $NetBSD: divrem.m4,v 1.3 1995/04/22 09:37:39 pk Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Header: divrem.m4,v 1.4 92/06/25 13:23:57 torek Exp
- */
-
-/*
- * Division and remainder, from Appendix E of the Sparc Version 8
- * Architecture Manual, with fixes from Gordon Irlam.
- */
-
-/*
- * Input: dividend and divisor in %o0 and %o1 respectively.
- *
- * m4 parameters:
- * NAME name of function to generate
- * NAME2 secondary name of function to generate
- * OP OP=div => %o0 / %o1; OP=rem => %o0 % %o1
- * S S=true => signed; S=false => unsigned
- *
- * Algorithm parameters:
- * N how many bits per iteration we try to get (4)
- * WORDSIZE total number of bits (32)
- *
- * Derived constants:
- * TWOSUPN 2^N, for label generation (m4 exponentiation currently broken)
- * TOPBITS number of bits in the top `decade' of a number
- *
- * Important variables:
- * Q the partial quotient under development (initially 0)
- * R the remainder so far, initially the dividend
- * ITER number of main division loop iterations required;
- * equal to ceil(log2(quotient) / N). Note that this
- * is the log base (2^N) of the quotient.
- * V the current comparand, initially divisor*2^(ITER*N-1)
- *
- * Cost:
- * Current estimate for non-large dividend is
- * ceil(log2(quotient) / N) * (10 + 7N/2) + C
- * A large dividend is one greater than 2^(31-TOPBITS) and takes a
- * different path, as the upper bits of the quotient must be developed
- * one bit at a time.
- */
-
-define(N, `4')
-define(TWOSUPN, `16')
-define(WORDSIZE, `32')
-define(TOPBITS, eval(WORDSIZE - N*((WORDSIZE-1)/N)))
-
-define(dividend, `%o0')
-define(divisor, `%o1')
-define(Q, `%o2')
-define(R, `%o3')
-define(ITER, `%o4')
-define(V, `%o5')
-
-/* m4 reminder: ifelse(a,b,c,d) => if a is b, then c, else d */
-define(T, `%g1')
-define(SC, `%g5')
-ifelse(S, `true', `define(SIGN, `%g6')')
-
-/*
- * This is the recursive definition for developing quotient digits.
- *
- * Parameters:
- * $1 the current depth, 1 <= $1 <= N
- * $2 the current accumulation of quotient bits
- * N max depth
- *
- * We add a new bit to $2 and either recurse or insert the bits in
- * the quotient. R, Q, and V are inputs and outputs as defined above;
- * the condition codes are expected to reflect the input R, and are
- * modified to reflect the output R.
- */
-define(DEVELOP_QUOTIENT_BITS,
-` ! depth $1, accumulated bits $2
- bl L.$1.eval(TWOSUPN+$2)
- srl V,1,V
- ! remainder is positive
- subcc R,V,R
- ifelse($1, N,
- ` b 9f
- add Q, ($2*2+1), Q
- ', ` DEVELOP_QUOTIENT_BITS(incr($1), `eval(2*$2+1)')')
-L.$1.eval(TWOSUPN+$2):
- ! remainder is negative
- addcc R,V,R
- ifelse($1, N,
- ` b 9f
- add Q, ($2*2-1), Q
- ', ` DEVELOP_QUOTIENT_BITS(incr($1), `eval(2*$2-1)')')
- ifelse($1, 1, `9:')')
-
-#include "DEFS.h"
-#include <machine/trap.h>
-#include <machine/asm.h>
-
- .globl NAME2
-NAME2:
-FUNC(NAME)
-ifelse(S, `true',
-` ! compute sign of result; if neither is negative, no problem
- orcc divisor, dividend, %g0 ! either negative?
- bge 2f ! no, go do the divide
- ifelse(OP, `div',
- `xor divisor, dividend, SIGN',
- `mov dividend, SIGN') ! compute sign in any case
- tst divisor
- bge 1f
- tst dividend
- ! divisor is definitely negative; dividend might also be negative
- bge 2f ! if dividend not negative...
- neg divisor ! in any case, make divisor nonneg
-1: ! dividend is negative, divisor is nonnegative
- neg dividend ! make dividend nonnegative
-2:
-')
- ! Ready to divide. Compute size of quotient; scale comparand.
- orcc divisor, %g0, V
- bnz 1f
- mov dividend, R
-
- ! Divide by zero trap. If it returns, return 0 (about as
- ! wrong as possible, but that is what SunOS does...).
- t ST_DIV0
- retl
- clr %o0
-
-1:
- cmp R, V ! if divisor exceeds dividend, done
- blu Lgot_result ! (and algorithm fails otherwise)
- clr Q
- sethi %hi(1 << (WORDSIZE - TOPBITS - 1)), T
- cmp R, T
- blu Lnot_really_big
- clr ITER
-
- ! `Here the dividend is >= 2^(31-N) or so. We must be careful here,
- ! as our usual N-at-a-shot divide step will cause overflow and havoc.
- ! The number of bits in the result here is N*ITER+SC, where SC <= N.
- ! Compute ITER in an unorthodox manner: know we need to shift V into
- ! the top decade: so do not even bother to compare to R.'
- 1:
- cmp V, T
- bgeu 3f
- mov 1, SC
- sll V, N, V
- b 1b
- inc ITER
-
- ! Now compute SC.
- 2: addcc V, V, V
- bcc Lnot_too_big
- inc SC
-
- ! We get here if the divisor overflowed while shifting.
- ! This means that R has the high-order bit set.
- ! Restore V and subtract from R.
- sll T, TOPBITS, T ! high order bit
- srl V, 1, V ! rest of V
- add V, T, V
- b Ldo_single_div
- dec SC
-
- Lnot_too_big:
- 3: cmp V, R
- blu 2b
- nop
- be Ldo_single_div
- nop
- /* NB: these are commented out in the V8-Sparc manual as well */
- /* (I do not understand this) */
- ! V > R: went too far: back up 1 step
- ! srl V, 1, V
- ! dec SC
- ! do single-bit divide steps
- !
- ! We have to be careful here. We know that R >= V, so we can do the
- ! first divide step without thinking. BUT, the others are conditional,
- ! and are only done if R >= 0. Because both R and V may have the high-
- ! order bit set in the first step, just falling into the regular
- ! division loop will mess up the first time around.
- ! So we unroll slightly...
- Ldo_single_div:
- deccc SC
- bl Lend_regular_divide
- nop
- sub R, V, R
- mov 1, Q
- b Lend_single_divloop
- nop
- Lsingle_divloop:
- sll Q, 1, Q
- bl 1f
- srl V, 1, V
- ! R >= 0
- sub R, V, R
- b 2f
- inc Q
- 1: ! R < 0
- add R, V, R
- dec Q
- 2:
- Lend_single_divloop:
- deccc SC
- bge Lsingle_divloop
- tst R
- b,a Lend_regular_divide
-
-Lnot_really_big:
-1:
- sll V, N, V
- cmp V, R
- bleu 1b
- inccc ITER
- be Lgot_result
- dec ITER
-
- tst R ! set up for initial iteration
-Ldivloop:
- sll Q, N, Q
- DEVELOP_QUOTIENT_BITS(1, 0)
-Lend_regular_divide:
- deccc ITER
- bge Ldivloop
- tst R
- bl,a Lgot_result
- ! non-restoring fixup here (one instruction only!)
-ifelse(OP, `div',
-` dec Q
-', ` add R, divisor, R
-')
-
-Lgot_result:
-ifelse(S, `true',
-` ! check to see if answer should be < 0
- tst SIGN
- bl,a 1f
- ifelse(OP, `div', `neg Q', `neg R')
-1:')
- retl
- ifelse(OP, `div', `mov Q, %o0', `mov R, %o0')
diff --git a/sys/lib/libkern/arch/sparc/ffs.S b/sys/lib/libkern/arch/sparc/ffs.S
deleted file mode 100644
index c4371332c4d..00000000000
--- a/sys/lib/libkern/arch/sparc/ffs.S
+++ /dev/null
@@ -1,109 +0,0 @@
-/* $OpenBSD: ffs.S,v 1.5 2007/11/25 18:25:36 deraadt Exp $ */
-/* $NetBSD: ffs.S,v 1.2 1994/10/26 06:39:57 cgd Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Header: ffs.s,v 1.3 92/07/07 00:23:57 torek Exp
- */
-
-#include "DEFS.h"
-
-#ifndef _KERNEL
-/*
- * ffs returns the number of the rightmost bit set in its argument,
- * i.e., the lowest value such that (x & (ffs(x) - 1)) is nonzero.
- * If no bits are set, ffs returns 0.
- *
- * We use a table lookup on each byte.
- *
- * In each section below, %o1 is the current byte (0, 1, 2, or 3).
- * The last byte is handled specially: for the first three,
- * if that byte is nonzero, we return the table value
- * (plus 0, 8, or 16 for the byte number), but for the last
- * one, we just return the table value plus 24. This means
- * that ffstab[0] must be -24 so that ffs(0) will return 0.
- */
-ENTRY(ffs)
-#ifdef PIC
- PICCY_SET(ffstab, %o2, %o5)
-#else
- set ffstab, %o2
-#endif
- andcc %o0, 0xff, %o1 ! get low byte
- be,a 1f ! try again if 0
- srl %o0, 8, %o0 ! delay slot, get ready for next byte
-
- retl ! return ffstab[%o1]
- ldsb [%o2 + %o1], %o0
-
-1:
- andcc %o0, 0xff, %o1 ! byte 1 like byte 0...
- be,a 2f
- srl %o0, 8, %o0 ! (use delay to prepare for byte 2)
-
- ldsb [%o2 + %o1], %o0
- retl ! return ffstab[%o1] + 8
- add %o0, 8, %o0
-
-2:
- andcc %o0, 0xff, %o1
- be,a 3f
- srl %o0, 8, %o0 ! (prepare for byte 3)
-
- ldsb [%o2 + %o1], %o0
- retl ! return ffstab[%o1] + 16
- add %o0, 16, %o0
-
-3: ! just return ffstab[%o0] + 24
- ldsb [%o2 + %o0], %o0
- retl
- add %o0, 24, %o0
-
-ffstab:
- .byte -24,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 00-0f */
- .byte 5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 10-1f */
- .byte 6,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 20-2f */
- .byte 5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 30-3f */
- .byte 7,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 40-4f */
- .byte 5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 50-5f */
- .byte 6,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 60-6f */
- .byte 5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 70-7f */
- .byte 8,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 80-8f */
- .byte 5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 10-9f */
- .byte 6,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* a0-af */
- .byte 5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* b0-bf */
- .byte 7,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* c0-cf */
- .byte 5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* d0-df */
- .byte 6,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* e0-ef */
- .byte 5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* f0-ff */
-#endif
diff --git a/sys/lib/libkern/arch/sparc/htonl.S b/sys/lib/libkern/arch/sparc/htonl.S
deleted file mode 100644
index ccc691839c0..00000000000
--- a/sys/lib/libkern/arch/sparc/htonl.S
+++ /dev/null
@@ -1,47 +0,0 @@
-/* $OpenBSD: htonl.S,v 1.4 2007/11/25 18:25:36 deraadt Exp $ */
-/* $NetBSD: htonl.S,v 1.2 1994/10/26 06:39:58 cgd Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Header: htonl.s,v 1.1 92/06/25 12:47:05 torek Exp
- */
-
-/* netorder = htonl(hostorder) */
-
-#include "DEFS.h"
-
-_ENTRY(bswap32)
-_ENTRY(ntohl)
-ENTRY(htonl)
- retl
- nop
diff --git a/sys/lib/libkern/arch/sparc/htons.S b/sys/lib/libkern/arch/sparc/htons.S
deleted file mode 100644
index d490c75bdd3..00000000000
--- a/sys/lib/libkern/arch/sparc/htons.S
+++ /dev/null
@@ -1,47 +0,0 @@
-/* $OpenBSD: htons.S,v 1.4 2007/11/25 18:25:36 deraadt Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Header: htons.s,v 1.1 92/06/25 12:47:05 torek Exp
- */
-
-/* netorder = htons(hostorder) */
-
-#include "DEFS.h"
-
-_ENTRY(bswap16)
-_ENTRY(ntohs)
-ENTRY(htons)
- sethi %hi(0xffff0000), %o1
- retl
- andn %o0, %o1, %o0
diff --git a/sys/lib/libkern/arch/sparc/memcpy.S b/sys/lib/libkern/arch/sparc/memcpy.S
deleted file mode 100644
index c9361568da4..00000000000
--- a/sys/lib/libkern/arch/sparc/memcpy.S
+++ /dev/null
@@ -1 +0,0 @@
-/* This code is contained in memmove.S */
diff --git a/sys/lib/libkern/arch/sparc/memmove.S b/sys/lib/libkern/arch/sparc/memmove.S
deleted file mode 100644
index c03e831a375..00000000000
--- a/sys/lib/libkern/arch/sparc/memmove.S
+++ /dev/null
@@ -1,420 +0,0 @@
-/* $OpenBSD: memmove.S,v 1.6 2014/11/09 16:41:26 miod Exp $ */
-
-/*
- * Copyright (c) 1996
- * The President and Fellows of Harvard College. All rights reserved.
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Lawrence Berkeley Laboratory.
- * This product includes software developed by Harvard University.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * This product includes software developed by Harvard University.
- * This product includes software developed by Paul Kranenburg.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <machine/param.h>
-#include <machine/asm.h>
-
-/*
- * GNU assembler does not understand `.empty' directive; Sun assembler
- * gripes about labels without it. To allow cross-compilation using
- * the Sun assembler, and because .empty directives are useful documentation,
- * we use this trick.
- */
-#ifdef SUN_AS
-#define EMPTY .empty
-#else
-#define EMPTY /* .empty */
-#endif
-
-/* use as needed to align things on longword boundaries */
-#define _ALIGN .align 4
-
-#define BCOPY_SMALL 32 /* if < 32, copy by bytes */
-
-/*
- * memcpy(dst, src, len). Assumes regions do not overlap; returns dst.
- */
-ENTRY(memcpy)
- /*
- * Swap args, because we may end up in bcopy.
- */
- mov %o0, %o5 ! save return value
- mov %o1, %o0
- mov %o5, %o1
-Lbcopy_old:
- cmp %o2, BCOPY_SMALL
-Lbcopy_start:
- bge,a Lbcopy_fancy ! if >= this many, go be fancy.
- btst 7, %o0 ! (part of being fancy)
-
- /*
- * Not much to copy, just do it a byte at a time.
- */
- deccc %o2 ! while (--len >= 0)
- bl 1f
- EMPTY
-0:
- inc %o0
- ldsb [%o0 - 1], %o4 ! (++dst)[-1] = *src++;
- stb %o4, [%o1]
- deccc %o2
- bge 0b
- inc %o1
-1:
- retl
- mov %o5, %o0 ! return (dst)
- /* NOTREACHED */
-
- /*
- * Plenty of data to copy, so try to do it optimally.
- */
-Lbcopy_fancy:
- ! check for common case first: everything lines up.
-! btst 7, %o0 ! done already
- bne 1f
- EMPTY
- btst 7, %o1
- be,a Lbcopy_doubles
- dec 8, %o2 ! if all lined up, len -= 8, goto bcopy_doubles
-
- ! If the low bits match, we can make these line up.
-1:
- xor %o0, %o1, %o3 ! t = src ^ dst;
- btst 1, %o3 ! if (t & 1) {
- be,a 1f
- btst 1, %o0 ! [delay slot: if (src & 1)]
-
- ! low bits do not match, must copy by bytes.
-0:
- ldsb [%o0], %o4 ! do {
- inc %o0 ! (++dst)[-1] = *src++;
- inc %o1
- deccc %o2
- bnz 0b ! } while (--len != 0);
- stb %o4, [%o1 - 1]
- retl
- mov %o5, %o0 ! return (dst)
- /* NOTREACHED */
-
- ! lowest bit matches, so we can copy by words, if nothing else
-1:
- be,a 1f ! if (src & 1) {
- btst 2, %o3 ! [delay slot: if (t & 2)]
-
- ! although low bits match, both are 1: must copy 1 byte to align
- ldsb [%o0], %o4 ! *dst++ = *src++;
- stb %o4, [%o1]
- inc %o0
- inc %o1
- dec %o2 ! len--;
- btst 2, %o3 ! } [if (t & 2)]
-1:
- be,a 1f ! if (t & 2) {
- btst 2, %o0 ! [delay slot: if (src & 2)]
- dec 2, %o2 ! len -= 2;
-0:
- ldsh [%o0], %o4 ! do {
- sth %o4, [%o1] ! *(short *)dst = *(short *)src;
- inc 2, %o0 ! dst += 2, src += 2;
- deccc 2, %o2 ! } while ((len -= 2) >= 0);
- bge 0b
- inc 2, %o1
- b Lbcopy_mopb ! goto mop_up_byte;
- btst 1, %o2 ! } [delay slot: if (len & 1)]
- /* NOTREACHED */
-
- ! low two bits match, so we can copy by longwords
-1:
- be,a 1f ! if (src & 2) {
- btst 4, %o3 ! [delay slot: if (t & 4)]
-
- ! although low 2 bits match, they are 10: must copy one short to align
- ldsh [%o0], %o4 ! (*short *)dst = *(short *)src;
- sth %o4, [%o1]
- inc 2, %o0 ! dst += 2;
- inc 2, %o1 ! src += 2;
- dec 2, %o2 ! len -= 2;
- btst 4, %o3 ! } [if (t & 4)]
-1:
- be,a 1f ! if (t & 4) {
- btst 4, %o0 ! [delay slot: if (src & 4)]
- dec 4, %o2 ! len -= 4;
-0:
- ld [%o0], %o4 ! do {
- st %o4, [%o1] ! *(int *)dst = *(int *)src;
- inc 4, %o0 ! dst += 4, src += 4;
- deccc 4, %o2 ! } while ((len -= 4) >= 0);
- bge 0b
- inc 4, %o1
- b Lbcopy_mopw ! goto mop_up_word_and_byte;
- btst 2, %o2 ! } [delay slot: if (len & 2)]
- /* NOTREACHED */
-
- ! low three bits match, so we can copy by doublewords
-1:
- be 1f ! if (src & 4) {
- dec 8, %o2 ! [delay slot: len -= 8]
- ld [%o0], %o4 ! *(int *)dst = *(int *)src;
- st %o4, [%o1]
- inc 4, %o0 ! dst += 4, src += 4, len -= 4;
- inc 4, %o1
- dec 4, %o2 ! }
-1:
-Lbcopy_doubles:
- mov %o5, %o3 ! save return value
-1:
- ldd [%o0], %o4 ! do {
- std %o4, [%o1] ! *(double *)dst = *(double *)src;
- inc 8, %o0 ! dst += 8, src += 8;
- deccc 8, %o2 ! } while ((len -= 8) >= 0);
- bge 1b
- inc 8, %o1
-
- ! check for a usual case again (save work)
- btst 7, %o2 ! if ((len & 7) == 0)
- be Lbcopy_done ! goto bcopy_done;
- mov %o3, %o5 ! [delay slot: restore return value]
-
- btst 4, %o2 ! if ((len & 4) == 0)
- be,a Lbcopy_mopw ! goto mop_up_word_and_byte;
- btst 2, %o2 ! [delay slot: if (len & 2)]
- ld [%o0], %o4 ! *(int *)dst = *(int *)src;
- st %o4, [%o1]
- inc 4, %o0 ! dst += 4;
- inc 4, %o1 ! src += 4;
- btst 2, %o2 ! } [if (len & 2)]
-
-1:
- ! mop up trailing word (if present) and byte (if present).
-Lbcopy_mopw:
- be Lbcopy_mopb ! no word, go mop up byte
- btst 1, %o2 ! [delay slot: if (len & 1)]
- ldsh [%o0], %o4 ! *(short *)dst = *(short *)src;
- be Lbcopy_done ! if ((len & 1) == 0) goto done;
- sth %o4, [%o1]
- ldsb [%o0 + 2], %o4 ! dst[2] = src[2];
- stb %o4, [%o1 + 2]
- retl
- mov %o5, %o0 ! return (dst)
- /* NOTREACHED */
-
- ! mop up trailing byte (if present).
-Lbcopy_mopb:
- bne,a 1f
- ldsb [%o0], %o4
-
-Lbcopy_done:
- retl
- mov %o5, %o0 ! return (dst)
-
-1:
- stb %o4,[%o1]
- retl
- mov %o5, %o0 ! return (dst)
-
-/*
- * memmove(dst, src, len). Handles overlap; returns dst.
- */
-ENTRY(memmove)
- /*
- * Swap args and continue to bcopy.
- */
- mov %o0, %o5 ! save dst
- mov %o1, %o0
- mov %o5, %o1
-/*
- * bcopy(src, dst, len): regions may overlap.
- */
-ENTRY(bcopy)
- cmp %o0, %o1 ! src < dst?
- bgeu Lbcopy_start ! no, go copy forwards as via old bcopy
- cmp %o2, BCOPY_SMALL! (check length for doublecopy first)
-
- /*
- * Since src comes before dst, and the regions might overlap,
- * we have to do the copy starting at the end and working backwards.
- */
- add %o2, %o0, %o0 ! src += len
- add %o2, %o1, %o1 ! dst += len
- bge,a Lback_fancy ! if len >= BCOPY_SMALL, go be fancy
- btst 3, %o0
-
- /*
- * Not much to copy, just do it a byte at a time.
- */
- deccc %o2 ! while (--len >= 0)
- bl 1f
- EMPTY
-0:
- dec %o0 ! *--dst = *--src;
- ldsb [%o0], %o4
- dec %o1
- deccc %o2
- bge 0b
- stb %o4, [%o1]
-1:
- retl
- mov %o5, %o0 ! return (dst)
-
- /*
- * Plenty to copy, try to be optimal.
- * We only bother with word/halfword/byte copies here.
- */
-Lback_fancy:
-! btst 3, %o0 ! done already
- bnz 1f ! if ((src & 3) == 0 &&
- btst 3, %o1 ! (dst & 3) == 0)
- bz,a Lback_words ! goto words;
- dec 4, %o2 ! (done early for word copy)
-
-1:
- /*
- * See if the low bits match.
- */
- xor %o0, %o1, %o3 ! t = src ^ dst;
- btst 1, %o3
- bz,a 3f ! if (t & 1) == 0, can do better
- btst 1, %o0
-
- /*
- * Nope; gotta do byte copy.
- */
-2:
- dec %o0 ! do {
- ldsb [%o0], %o4 ! *--dst = *--src;
- dec %o1
- deccc %o2 ! } while (--len != 0);
- bnz 2b
- stb %o4, [%o1]
- retl
- mov %o5, %o0 ! return (dst)
-
-3:
- /*
- * Can do halfword or word copy, but might have to copy 1 byte first.
- */
-! btst 1, %o0 ! done earlier
- bz,a 4f ! if (src & 1) { /* copy 1 byte */
- btst 2, %o3 ! (done early)
- dec %o0 ! *--dst = *--src;
- ldsb [%o0], %o4
- dec %o1
- stb %o4, [%o1]
- dec %o2 ! len--;
- btst 2, %o3 ! }
-
-4:
- /*
- * See if we can do a word copy ((t&2) == 0).
- */
-! btst 2, %o3 ! done earlier
- bz,a 6f ! if (t & 2) == 0, can do word copy
- btst 2, %o0 ! (src&2, done early)
-
- /*
- * Gotta do halfword copy.
- */
- dec 2, %o2 ! len -= 2;
-5:
- dec 2, %o0 ! do {
- ldsh [%o0], %o4 ! src -= 2;
- dec 2, %o1 ! dst -= 2;
- deccc 2, %o2 ! *(short *)dst = *(short *)src;
- bge 5b ! } while ((len -= 2) >= 0);
- sth %o4, [%o1]
- b Lback_mopb ! goto mop_up_byte;
- btst 1, %o2 ! (len&1, done early)
-
-6:
- /*
- * We can do word copies, but we might have to copy
- * one halfword first.
- */
-! btst 2, %o0 ! done already
- bz 7f ! if (src & 2) {
- dec 4, %o2 ! (len -= 4, done early)
- dec 2, %o0 ! src -= 2, dst -= 2;
- ldsh [%o0], %o4 ! *(short *)dst = *(short *)src;
- dec 2, %o1
- sth %o4, [%o1]
- dec 2, %o2 ! len -= 2;
- ! }
-
-7:
-Lback_words:
- /*
- * Do word copies (backwards), then mop up trailing halfword
- * and byte if any.
- */
-! dec 4, %o2 ! len -= 4, done already
-0: ! do {
- dec 4, %o0 ! src -= 4;
- dec 4, %o1 ! src -= 4;
- ld [%o0], %o4 ! *(int *)dst = *(int *)src;
- deccc 4, %o2 ! } while ((len -= 4) >= 0);
- bge 0b
- st %o4, [%o1]
-
- /*
- * Check for trailing shortword.
- */
- btst 2, %o2 ! if (len & 2) {
- bz,a 1f
- btst 1, %o2 ! (len&1, done early)
- dec 2, %o0 ! src -= 2, dst -= 2;
- ldsh [%o0], %o4 ! *(short *)dst = *(short *)src;
- dec 2, %o1
- sth %o4, [%o1] ! }
- btst 1, %o2
-
- /*
- * Check for trailing byte.
- */
-1:
-Lback_mopb:
-! btst 1, %o2 ! (done already)
- bnz,a 1f ! if (len & 1) {
- ldsb [%o0 - 1], %o4 ! b = src[-1];
- retl
- mov %o5, %o0 ! return (dst)
-
-1:
- stb %o4, [%o1 - 1] ! }
- retl ! dst[-1] = b;
- mov %o5, %o0 ! return (dst)
diff --git a/sys/lib/libkern/arch/sparc/memset.c b/sys/lib/libkern/arch/sparc/memset.c
deleted file mode 100644
index f53f078520d..00000000000
--- a/sys/lib/libkern/arch/sparc/memset.c
+++ /dev/null
@@ -1 +0,0 @@
-/* $OpenBSD: memset.c,v 1.3 1996/05/01 15:17:32 deraadt Exp $ */
diff --git a/sys/lib/libkern/arch/sparc/mul.S b/sys/lib/libkern/arch/sparc/mul.S
deleted file mode 100644
index fb5600d330f..00000000000
--- a/sys/lib/libkern/arch/sparc/mul.S
+++ /dev/null
@@ -1,149 +0,0 @@
-/* $OpenBSD: mul.S,v 1.6 2007/11/24 19:47:05 deraadt Exp $ */
-/* $NetBSD: mul.S,v 1.2 1994/10/26 06:40:01 cgd Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Header: mul.s,v 1.5 92/06/25 13:24:03 torek Exp
- */
-
-/*
- * Signed multiply, from Appendix E of the Sparc Version 8
- * Architecture Manual.
- *
- * Returns %o0 * %o1 in %o1%o0 (i.e., %o1 holds the upper 32 bits of
- * the 64-bit product).
- *
- * This code optimizes short (less than 13-bit) multiplies.
- */
-
-#include "DEFS.h"
-FUNC(.mul)
- mov %o0, %y ! multiplier -> Y
- andncc %o0, 0xfff, %g0 ! test bits 12..31
- be Lmul_shortway ! if zero, can do it the short way
- andcc %g0, %g0, %o4 ! zero the partial product and clear N and V
-
- /*
- * Long multiply. 32 steps, followed by a final shift step.
- */
- mulscc %o4, %o1, %o4 ! 1
- mulscc %o4, %o1, %o4 ! 2
- mulscc %o4, %o1, %o4 ! 3
- mulscc %o4, %o1, %o4 ! 4
- mulscc %o4, %o1, %o4 ! 5
- mulscc %o4, %o1, %o4 ! 6
- mulscc %o4, %o1, %o4 ! 7
- mulscc %o4, %o1, %o4 ! 8
- mulscc %o4, %o1, %o4 ! 9
- mulscc %o4, %o1, %o4 ! 10
- mulscc %o4, %o1, %o4 ! 11
- mulscc %o4, %o1, %o4 ! 12
- mulscc %o4, %o1, %o4 ! 13
- mulscc %o4, %o1, %o4 ! 14
- mulscc %o4, %o1, %o4 ! 15
- mulscc %o4, %o1, %o4 ! 16
- mulscc %o4, %o1, %o4 ! 17
- mulscc %o4, %o1, %o4 ! 18
- mulscc %o4, %o1, %o4 ! 19
- mulscc %o4, %o1, %o4 ! 20
- mulscc %o4, %o1, %o4 ! 21
- mulscc %o4, %o1, %o4 ! 22
- mulscc %o4, %o1, %o4 ! 23
- mulscc %o4, %o1, %o4 ! 24
- mulscc %o4, %o1, %o4 ! 25
- mulscc %o4, %o1, %o4 ! 26
- mulscc %o4, %o1, %o4 ! 27
- mulscc %o4, %o1, %o4 ! 28
- mulscc %o4, %o1, %o4 ! 29
- mulscc %o4, %o1, %o4 ! 30
- mulscc %o4, %o1, %o4 ! 31
- mulscc %o4, %o1, %o4 ! 32
- mulscc %o4, %g0, %o4 ! final shift
-
- ! If %o0 was negative, the result is
- ! (%o0 * %o1) + (%o1 << 32))
- ! We fix that here.
-
- tst %o0
- bge 1f
- rd %y, %o0
-
- ! %o0 was indeed negative; fix upper 32 bits of result by subtracting
- ! %o1 (i.e., return %o4 - %o1 in %o1).
- retl
- sub %o4, %o1, %o1
-
-1:
- retl
- mov %o4, %o1
-
-Lmul_shortway:
- /*
- * Short multiply. 12 steps, followed by a final shift step.
- * The resulting bits are off by 12 and (32-12) = 20 bit positions,
- * but there is no problem with %o0 being negative (unlike above).
- */
- mulscc %o4, %o1, %o4 ! 1
- mulscc %o4, %o1, %o4 ! 2
- mulscc %o4, %o1, %o4 ! 3
- mulscc %o4, %o1, %o4 ! 4
- mulscc %o4, %o1, %o4 ! 5
- mulscc %o4, %o1, %o4 ! 6
- mulscc %o4, %o1, %o4 ! 7
- mulscc %o4, %o1, %o4 ! 8
- mulscc %o4, %o1, %o4 ! 9
- mulscc %o4, %o1, %o4 ! 10
- mulscc %o4, %o1, %o4 ! 11
- mulscc %o4, %o1, %o4 ! 12
- mulscc %o4, %g0, %o4 ! final shift
-
- /*
- * %o4 has 20 of the bits that should be in the low part of the
- * result; %y has the bottom 12 (as %y's top 12). That is:
- *
- * %o4 %y
- * +----------------+----------------+
- * | -12- | -20- | -12- | -20- |
- * +------(---------+------)---------+
- * --hi-- ----low-part----
- *
- * The upper 12 bits of %o4 should be sign-extended to form the
- * high part of the product (i.e., highpart = %o4 >> 20).
- */
-
- rd %y, %o5
- sll %o4, 12, %o0 ! shift middle bits left 12
- srl %o5, 20, %o5 ! shift low bits right 20, zero fill at left
- or %o5, %o0, %o0 ! construct low part of result
- retl
- sra %o4, 20, %o1 ! ... and extract high part of result
diff --git a/sys/lib/libkern/arch/sparc/rem.S b/sys/lib/libkern/arch/sparc/rem.S
deleted file mode 100644
index 7b56d2bf90d..00000000000
--- a/sys/lib/libkern/arch/sparc/rem.S
+++ /dev/null
@@ -1,434 +0,0 @@
-
-/* $OpenBSD: rem.S,v 1.2 2011/03/12 18:51:31 deraadt Exp $ */
-/* $NetBSD: divrem.m4,v 1.3 1995/04/22 09:37:39 pk Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS `AS IS' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Header: divrem.m4,v 1.4 92/06/25 13:23:57 torek Exp
- */
-
-/*
- * Division and remainder, from Appendix E of the Sparc Version 8
- * Architecture Manual, with fixes from Gordon Irlam.
- */
-
-/*
- * Input: dividend and divisor in %o0 and %o1 respectively.
- *
- * m4 parameters:
- * .rem name of function to generate
- * _C_LABEL(_rem) secondary name of function to generate
- * rem rem=div => %o0 / %o1; rem=rem => %o0 % %o1
- * true true=true => signed; true=false => unsigned
- *
- * Algorithm parameters:
- * N how many bits per iteration we try to get (4)
- * WORDSIZE total number of bits (32)
- *
- * Derived constants:
- * TWOSUPN 2^N, for label generation (m4 exponentiation currently broken)
- * TOPBITS number of bits in the top decade of a number
- *
- * Important variables:
- * Q the partial quotient under development (initially 0)
- * R the remainder so far, initially the dividend
- * ITER number of main division loop iterations required;
- * equal to ceil(log2(quotient) / N). Note that this
- * is the log base (2^N) of the quotient.
- * V the current comparand, initially divisor*2^(ITER*N-1)
- *
- * Cost:
- * Current estimate for non-large dividend is
- * ceil(log2(quotient) / N) * (10 + 7N/2) + C
- * A large dividend is one greater than 2^(31-TOPBITS) and takes a
- * different path, as the upper bits of the quotient must be developed
- * one bit at a time.
- */
-
-
-
-
-
-
-
-
-
-
-
-
-
-/* m4 reminder: d => if a is b, then c, else d */
-
-
-
-
-/*
- * This is the recursive definition for developing quotient digits.
- *
- * Parameters:
- * $1 the current depth, 1 <= $1 <= 4
- * $2 the current accumulation of quotient bits
- * 4 max depth
- *
- * We add a new bit to $2 and either recurse or insert the bits in
- * the quotient. %o3, %o2, and %o5 are inputs and outputs as defined above;
- * the condition codes are expected to reflect the input %o3, and are
- * modified to reflect the output %o3.
- */
-
-
-#include "DEFS.h"
-#include <machine/trap.h>
-#include <machine/asm.h>
-
- .globl _C_LABEL(_rem)
-_C_LABEL(_rem):
-FUNC(.rem)
- ! compute sign of result; if neither is negative, no problem
- orcc %o1, %o0, %g0 ! either negative?
- bge 2f ! no, go do the divide
- mov %o0, %g6 ! compute sign in any case
- tst %o1
- bge 1f
- tst %o0
- ! %o1 is definitely negative; %o0 might also be negative
- bge 2f ! if %o0 not negative...
- neg %o1 ! in any case, make %o1 nonneg
-1: ! %o0 is negative, %o1 is nonnegative
- neg %o0 ! make %o0 nonnegative
-2:
-
- ! Ready to divide. Compute size of quotient; scale comparand.
- orcc %o1, %g0, %o5
- bnz 1f
- mov %o0, %o3
-
- ! Divide by zero trap. If it returns, return 0 (about as
- ! wrong as possible, but that is what SunOS does...).
- t ST_DIV0
- retl
- clr %o0
-
-1:
- cmp %o3, %o5 ! if %o1 exceeds %o0, done
- blu Lgot_result ! (and algorithm fails otherwise)
- clr %o2
- sethi %hi(1 << (32 - 4 - 1)), %g1
- cmp %o3, %g1
- blu Lnot_really_big
- clr %o4
-
- ! Here the dividend is >= 2^(31-N) or so. We must be careful here,
- ! as our usual N-at-a-shot divide step will cause overflow and havoc.
- ! The number of bits in the result here is N*ITER+SC, where SC <= N.
- ! Compute ITER in an unorthodox manner: know we need to shift V into
- ! the top decade: so do not even bother to compare to R.
- 1:
- cmp %o5, %g1
- bgeu 3f
- mov 1, %g5
- sll %o5, 4, %o5
- b 1b
- inc %o4
-
- ! Now compute %g5.
- 2: addcc %o5, %o5, %o5
- bcc Lnot_too_big
- inc %g5
-
- ! We get here if the %o1 overflowed while shifting.
- ! This means that %o3 has the high-order bit set.
- ! Restore %o5 and subtract from %o3.
- sll %g1, 4, %g1 ! high order bit
- srl %o5, 1, %o5 ! rest of %o5
- add %o5, %g1, %o5
- b Ldo_single_div
- dec %g5
-
- Lnot_too_big:
- 3: cmp %o5, %o3
- blu 2b
- nop
- be Ldo_single_div
- nop
- /* NB: these are commented out in the V8-Sparc manual as well */
- /* (I do not understand this) */
- ! %o5 > %o3: went too far: back up 1 step
- ! srl %o5, 1, %o5
- ! dec %g5
- ! do single-bit divide steps
- !
- ! We have to be careful here. We know that %o3 >= %o5, so we can do the
- ! first divide step without thinking. BUT, the others are conditional,
- ! and are only done if %o3 >= 0. Because both %o3 and %o5 may have the high-
- ! order bit set in the first step, just falling into the regular
- ! division loop will mess up the first time around.
- ! So we unroll slightly...
- Ldo_single_div:
- deccc %g5
- bl Lend_regular_divide
- nop
- sub %o3, %o5, %o3
- mov 1, %o2
- b Lend_single_divloop
- nop
- Lsingle_divloop:
- sll %o2, 1, %o2
- bl 1f
- srl %o5, 1, %o5
- ! %o3 >= 0
- sub %o3, %o5, %o3
- b 2f
- inc %o2
- 1: ! %o3 < 0
- add %o3, %o5, %o3
- dec %o2
- 2:
- Lend_single_divloop:
- deccc %g5
- bge Lsingle_divloop
- tst %o3
- b,a Lend_regular_divide
-
-Lnot_really_big:
-1:
- sll %o5, 4, %o5
- cmp %o5, %o3
- bleu 1b
- inccc %o4
- be Lgot_result
- dec %o4
-
- tst %o3 ! set up for initial iteration
-Ldivloop:
- sll %o2, 4, %o2
- ! depth 1, accumulated bits 0
- bl L.1.16
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 2, accumulated bits 1
- bl L.2.17
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 3, accumulated bits 3
- bl L.3.19
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits 7
- bl L.4.23
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (7*2+1), %o2
-
-L.4.23:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (7*2-1), %o2
-
-
-L.3.19:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits 5
- bl L.4.21
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (5*2+1), %o2
-
-L.4.21:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (5*2-1), %o2
-
-
-
-L.2.17:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 3, accumulated bits 1
- bl L.3.17
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits 3
- bl L.4.19
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (3*2+1), %o2
-
-L.4.19:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (3*2-1), %o2
-
-
-L.3.17:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits 1
- bl L.4.17
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (1*2+1), %o2
-
-L.4.17:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (1*2-1), %o2
-
-
-
-
-L.1.16:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 2, accumulated bits -1
- bl L.2.15
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 3, accumulated bits -1
- bl L.3.15
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits -1
- bl L.4.15
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-1*2+1), %o2
-
-L.4.15:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-1*2-1), %o2
-
-
-L.3.15:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits -3
- bl L.4.13
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-3*2+1), %o2
-
-L.4.13:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-3*2-1), %o2
-
-
-
-L.2.15:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 3, accumulated bits -3
- bl L.3.13
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits -5
- bl L.4.11
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-5*2+1), %o2
-
-L.4.11:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-5*2-1), %o2
-
-
-L.3.13:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits -7
- bl L.4.9
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-7*2+1), %o2
-
-L.4.9:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-7*2-1), %o2
-
-
-
-
- 9:
-Lend_regular_divide:
- deccc %o4
- bge Ldivloop
- tst %o3
- bl,a Lgot_result
- ! non-restoring fixup here (one instruction only!)
- add %o3, %o1, %o3
-
-
-Lgot_result:
- ! check to see if answer should be < 0
- tst %g6
- bl,a 1f
- neg %o3
-1:
- retl
- mov %o3, %o0
diff --git a/sys/lib/libkern/arch/sparc/saveregs.S b/sys/lib/libkern/arch/sparc/saveregs.S
deleted file mode 100644
index 01ebc7513eb..00000000000
--- a/sys/lib/libkern/arch/sparc/saveregs.S
+++ /dev/null
@@ -1,58 +0,0 @@
-/* $OpenBSD: saveregs.S,v 1.3 2003/06/02 23:28:09 millert Exp $ */
-/* $NetBSD: saveregs.S,v 1.2 1994/10/26 06:40:07 cgd Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Header: saveregs.s,v 1.1 91/07/06 17:22:33 torek Exp
- */
-
-/*
- * Save register arguments in caller's `arg dump' area, so that
- * stdarg functions work.
- *
- * This really should be done with a pointer to the arg dump area;
- * our caller should allocate that area, not our caller's caller.
- * But then, they did not let me invent the calling sequence....
- *
- * We assume the caller has executed a `save' instruction.
- */
-#include "DEFS.h"
-
-ENTRY(__builtin_saveregs)
- st %i0, [%fp + 0x44] ! fr->fr_argd[0]
- st %i1, [%fp + 0x48] ! fr->fr_argd[1]
- st %i2, [%fp + 0x4c] ! fr->fr_argd[2]
- st %i3, [%fp + 0x50] ! fr->fr_argd[3]
- st %i4, [%fp + 0x54] ! fr->fr_argd[4]
- retl
- st %i5, [%fp + 0x58] ! fr->fr_argd[5]
diff --git a/sys/lib/libkern/arch/sparc/sdiv.S b/sys/lib/libkern/arch/sparc/sdiv.S
deleted file mode 100644
index a09e2ce2a63..00000000000
--- a/sys/lib/libkern/arch/sparc/sdiv.S
+++ /dev/null
@@ -1,434 +0,0 @@
-
-/* $OpenBSD: sdiv.S,v 1.2 2011/03/12 18:51:31 deraadt Exp $ */
-/* $NetBSD: divrem.m4,v 1.3 1995/04/22 09:37:39 pk Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS `AS IS' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Header: divrem.m4,v 1.4 92/06/25 13:23:57 torek Exp
- */
-
-/*
- * Division and remainder, from Appendix E of the Sparc Version 8
- * Architecture Manual, with fixes from Gordon Irlam.
- */
-
-/*
- * Input: dividend and divisor in %o0 and %o1 respectively.
- *
- * m4 parameters:
- * .div name of function to generate
- * _C_LABEL(_div) secondary name of function to generate
- * div div=div => %o0 / %o1; div=rem => %o0 % %o1
- * true true=true => signed; true=false => unsigned
- *
- * Algorithm parameters:
- * N how many bits per iteration we try to get (4)
- * WORDSIZE total number of bits (32)
- *
- * Derived constants:
- * TWOSUPN 2^N, for label generation (m4 exponentiation currently broken)
- * TOPBITS number of bits in the top decade of a number
- *
- * Important variables:
- * Q the partial quotient under development (initially 0)
- * R the remainder so far, initially the dividend
- * ITER number of main division loop iterations required;
- * equal to ceil(log2(quotient) / N). Note that this
- * is the log base (2^N) of the quotient.
- * V the current comparand, initially divisor*2^(ITER*N-1)
- *
- * Cost:
- * Current estimate for non-large dividend is
- * ceil(log2(quotient) / N) * (10 + 7N/2) + C
- * A large dividend is one greater than 2^(31-TOPBITS) and takes a
- * different path, as the upper bits of the quotient must be developed
- * one bit at a time.
- */
-
-
-
-
-
-
-
-
-
-
-
-
-
-/* m4 reminder: d => if a is b, then c, else d */
-
-
-
-
-/*
- * This is the recursive definition for developing quotient digits.
- *
- * Parameters:
- * $1 the current depth, 1 <= $1 <= 4
- * $2 the current accumulation of quotient bits
- * 4 max depth
- *
- * We add a new bit to $2 and either recurse or insert the bits in
- * the quotient. %o3, %o2, and %o5 are inputs and outputs as defined above;
- * the condition codes are expected to reflect the input %o3, and are
- * modified to reflect the output %o3.
- */
-
-
-#include "DEFS.h"
-#include <machine/trap.h>
-#include <machine/asm.h>
-
- .globl _C_LABEL(_div)
-_C_LABEL(_div):
-FUNC(.div)
- ! compute sign of result; if neither is negative, no problem
- orcc %o1, %o0, %g0 ! either negative?
- bge 2f ! no, go do the divide
- xor %o1, %o0, %g6 ! compute sign in any case
- tst %o1
- bge 1f
- tst %o0
- ! %o1 is definitely negative; %o0 might also be negative
- bge 2f ! if %o0 not negative...
- neg %o1 ! in any case, make %o1 nonneg
-1: ! %o0 is negative, %o1 is nonnegative
- neg %o0 ! make %o0 nonnegative
-2:
-
- ! Ready to divide. Compute size of quotient; scale comparand.
- orcc %o1, %g0, %o5
- bnz 1f
- mov %o0, %o3
-
- ! Divide by zero trap. If it returns, return 0 (about as
- ! wrong as possible, but that is what SunOS does...).
- t ST_DIV0
- retl
- clr %o0
-
-1:
- cmp %o3, %o5 ! if %o1 exceeds %o0, done
- blu Lgot_result ! (and algorithm fails otherwise)
- clr %o2
- sethi %hi(1 << (32 - 4 - 1)), %g1
- cmp %o3, %g1
- blu Lnot_really_big
- clr %o4
-
- ! Here the dividend is >= 2^(31-N) or so. We must be careful here,
- ! as our usual N-at-a-shot divide step will cause overflow and havoc.
- ! The number of bits in the result here is N*ITER+SC, where SC <= N.
- ! Compute ITER in an unorthodox manner: know we need to shift V into
- ! the top decade: so do not even bother to compare to R.
- 1:
- cmp %o5, %g1
- bgeu 3f
- mov 1, %g5
- sll %o5, 4, %o5
- b 1b
- inc %o4
-
- ! Now compute %g5.
- 2: addcc %o5, %o5, %o5
- bcc Lnot_too_big
- inc %g5
-
- ! We get here if the %o1 overflowed while shifting.
- ! This means that %o3 has the high-order bit set.
- ! Restore %o5 and subtract from %o3.
- sll %g1, 4, %g1 ! high order bit
- srl %o5, 1, %o5 ! rest of %o5
- add %o5, %g1, %o5
- b Ldo_single_div
- dec %g5
-
- Lnot_too_big:
- 3: cmp %o5, %o3
- blu 2b
- nop
- be Ldo_single_div
- nop
- /* NB: these are commented out in the V8-Sparc manual as well */
- /* (I do not understand this) */
- ! %o5 > %o3: went too far: back up 1 step
- ! srl %o5, 1, %o5
- ! dec %g5
- ! do single-bit divide steps
- !
- ! We have to be careful here. We know that %o3 >= %o5, so we can do the
- ! first divide step without thinking. BUT, the others are conditional,
- ! and are only done if %o3 >= 0. Because both %o3 and %o5 may have the high-
- ! order bit set in the first step, just falling into the regular
- ! division loop will mess up the first time around.
- ! So we unroll slightly...
- Ldo_single_div:
- deccc %g5
- bl Lend_regular_divide
- nop
- sub %o3, %o5, %o3
- mov 1, %o2
- b Lend_single_divloop
- nop
- Lsingle_divloop:
- sll %o2, 1, %o2
- bl 1f
- srl %o5, 1, %o5
- ! %o3 >= 0
- sub %o3, %o5, %o3
- b 2f
- inc %o2
- 1: ! %o3 < 0
- add %o3, %o5, %o3
- dec %o2
- 2:
- Lend_single_divloop:
- deccc %g5
- bge Lsingle_divloop
- tst %o3
- b,a Lend_regular_divide
-
-Lnot_really_big:
-1:
- sll %o5, 4, %o5
- cmp %o5, %o3
- bleu 1b
- inccc %o4
- be Lgot_result
- dec %o4
-
- tst %o3 ! set up for initial iteration
-Ldivloop:
- sll %o2, 4, %o2
- ! depth 1, accumulated bits 0
- bl L.1.16
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 2, accumulated bits 1
- bl L.2.17
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 3, accumulated bits 3
- bl L.3.19
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits 7
- bl L.4.23
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (7*2+1), %o2
-
-L.4.23:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (7*2-1), %o2
-
-
-L.3.19:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits 5
- bl L.4.21
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (5*2+1), %o2
-
-L.4.21:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (5*2-1), %o2
-
-
-
-L.2.17:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 3, accumulated bits 1
- bl L.3.17
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits 3
- bl L.4.19
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (3*2+1), %o2
-
-L.4.19:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (3*2-1), %o2
-
-
-L.3.17:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits 1
- bl L.4.17
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (1*2+1), %o2
-
-L.4.17:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (1*2-1), %o2
-
-
-
-
-L.1.16:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 2, accumulated bits -1
- bl L.2.15
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 3, accumulated bits -1
- bl L.3.15
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits -1
- bl L.4.15
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-1*2+1), %o2
-
-L.4.15:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-1*2-1), %o2
-
-
-L.3.15:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits -3
- bl L.4.13
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-3*2+1), %o2
-
-L.4.13:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-3*2-1), %o2
-
-
-
-L.2.15:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 3, accumulated bits -3
- bl L.3.13
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits -5
- bl L.4.11
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-5*2+1), %o2
-
-L.4.11:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-5*2-1), %o2
-
-
-L.3.13:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits -7
- bl L.4.9
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-7*2+1), %o2
-
-L.4.9:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-7*2-1), %o2
-
-
-
-
- 9:
-Lend_regular_divide:
- deccc %o4
- bge Ldivloop
- tst %o3
- bl,a Lgot_result
- ! non-restoring fixup here (one instruction only!)
- dec %o2
-
-
-Lgot_result:
- ! check to see if answer should be < 0
- tst %g6
- bl,a 1f
- neg %o2
-1:
- retl
- mov %o2, %o0
diff --git a/sys/lib/libkern/arch/sparc/strlen.S b/sys/lib/libkern/arch/sparc/strlen.S
deleted file mode 100644
index 02bc2991a83..00000000000
--- a/sys/lib/libkern/arch/sparc/strlen.S
+++ /dev/null
@@ -1,49 +0,0 @@
-/* $OpenBSD: strlen.S,v 1.4 2007/11/24 19:47:05 deraadt Exp $ */
-/* $NetBSD: strlen.S,v 1.2 1994/10/26 06:40:09 cgd Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Header: strlen.s,v 1.1 92/06/25 12:52:47 torek Exp
- */
-
-#include "DEFS.h"
-
-ENTRY(strlen)
- add %o0, 1, %o1 ! save starting point + 1
-1:
- ldsb [%o0], %o2 ! fetch byte
- tst %o2 ! null?
- bne 1b ! no, keep going
- inc %o0 ! always increment pointer
- retl
- sub %o0, %o1, %o0 ! return length (ptr - (origptr+1))
diff --git a/sys/lib/libkern/arch/sparc/udiv.S b/sys/lib/libkern/arch/sparc/udiv.S
deleted file mode 100644
index b2271f0b470..00000000000
--- a/sys/lib/libkern/arch/sparc/udiv.S
+++ /dev/null
@@ -1,417 +0,0 @@
-
-/* $OpenBSD: udiv.S,v 1.2 2011/03/12 18:51:31 deraadt Exp $ */
-/* $NetBSD: divrem.m4,v 1.3 1995/04/22 09:37:39 pk Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS `AS IS' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Header: divrem.m4,v 1.4 92/06/25 13:23:57 torek Exp
- */
-
-/*
- * Division and remainder, from Appendix E of the Sparc Version 8
- * Architecture Manual, with fixes from Gordon Irlam.
- */
-
-/*
- * Input: dividend and divisor in %o0 and %o1 respectively.
- *
- * m4 parameters:
- * .udiv name of function to generate
- * _C_LABEL(_udiv) secondary name of function to generate
- * div div=div => %o0 / %o1; div=rem => %o0 % %o1
- * false false=true => signed; false=false => unsigned
- *
- * Algorithm parameters:
- * N how many bits per iteration we try to get (4)
- * WORDSIZE total number of bits (32)
- *
- * Derived constants:
- * TWOSUPN 2^N, for label generation (m4 exponentiation currently broken)
- * TOPBITS number of bits in the top decade of a number
- *
- * Important variables:
- * Q the partial quotient under development (initially 0)
- * R the remainder so far, initially the dividend
- * ITER number of main division loop iterations required;
- * equal to ceil(log2(quotient) / N). Note that this
- * is the log base (2^N) of the quotient.
- * V the current comparand, initially divisor*2^(ITER*N-1)
- *
- * Cost:
- * Current estimate for non-large dividend is
- * ceil(log2(quotient) / N) * (10 + 7N/2) + C
- * A large dividend is one greater than 2^(31-TOPBITS) and takes a
- * different path, as the upper bits of the quotient must be developed
- * one bit at a time.
- */
-
-
-
-
-
-
-
-
-
-
-
-
-
-/* m4 reminder: d => if a is b, then c, else d */
-
-
-
-
-/*
- * This is the recursive definition for developing quotient digits.
- *
- * Parameters:
- * $1 the current depth, 1 <= $1 <= 4
- * $2 the current accumulation of quotient bits
- * 4 max depth
- *
- * We add a new bit to $2 and either recurse or insert the bits in
- * the quotient. %o3, %o2, and %o5 are inputs and outputs as defined above;
- * the condition codes are expected to reflect the input %o3, and are
- * modified to reflect the output %o3.
- */
-
-
-#include "DEFS.h"
-#include <machine/trap.h>
-#include <machine/asm.h>
-
- .globl _C_LABEL(_udiv)
-_C_LABEL(_udiv):
-FUNC(.udiv)
-
- ! Ready to divide. Compute size of quotient; scale comparand.
- orcc %o1, %g0, %o5
- bnz 1f
- mov %o0, %o3
-
- ! Divide by zero trap. If it returns, return 0 (about as
- ! wrong as possible, but that is what SunOS does...).
- t ST_DIV0
- retl
- clr %o0
-
-1:
- cmp %o3, %o5 ! if %o1 exceeds %o0, done
- blu Lgot_result ! (and algorithm fails otherwise)
- clr %o2
- sethi %hi(1 << (32 - 4 - 1)), %g1
- cmp %o3, %g1
- blu Lnot_really_big
- clr %o4
-
- ! Here the dividend is >= 2^(31-N) or so. We must be careful here,
- ! as our usual N-at-a-shot divide step will cause overflow and havoc.
- ! The number of bits in the result here is N*ITER+SC, where SC <= N.
- ! Compute ITER in an unorthodox manner: know we need to shift V into
- ! the top decade: so do not even bother to compare to R.
- 1:
- cmp %o5, %g1
- bgeu 3f
- mov 1, %g5
- sll %o5, 4, %o5
- b 1b
- inc %o4
-
- ! Now compute %g5.
- 2: addcc %o5, %o5, %o5
- bcc Lnot_too_big
- inc %g5
-
- ! We get here if the %o1 overflowed while shifting.
- ! This means that %o3 has the high-order bit set.
- ! Restore %o5 and subtract from %o3.
- sll %g1, 4, %g1 ! high order bit
- srl %o5, 1, %o5 ! rest of %o5
- add %o5, %g1, %o5
- b Ldo_single_div
- dec %g5
-
- Lnot_too_big:
- 3: cmp %o5, %o3
- blu 2b
- nop
- be Ldo_single_div
- nop
- /* NB: these are commented out in the V8-Sparc manual as well */
- /* (I do not understand this) */
- ! %o5 > %o3: went too far: back up 1 step
- ! srl %o5, 1, %o5
- ! dec %g5
- ! do single-bit divide steps
- !
- ! We have to be careful here. We know that %o3 >= %o5, so we can do the
- ! first divide step without thinking. BUT, the others are conditional,
- ! and are only done if %o3 >= 0. Because both %o3 and %o5 may have the high-
- ! order bit set in the first step, just falling into the regular
- ! division loop will mess up the first time around.
- ! So we unroll slightly...
- Ldo_single_div:
- deccc %g5
- bl Lend_regular_divide
- nop
- sub %o3, %o5, %o3
- mov 1, %o2
- b Lend_single_divloop
- nop
- Lsingle_divloop:
- sll %o2, 1, %o2
- bl 1f
- srl %o5, 1, %o5
- ! %o3 >= 0
- sub %o3, %o5, %o3
- b 2f
- inc %o2
- 1: ! %o3 < 0
- add %o3, %o5, %o3
- dec %o2
- 2:
- Lend_single_divloop:
- deccc %g5
- bge Lsingle_divloop
- tst %o3
- b,a Lend_regular_divide
-
-Lnot_really_big:
-1:
- sll %o5, 4, %o5
- cmp %o5, %o3
- bleu 1b
- inccc %o4
- be Lgot_result
- dec %o4
-
- tst %o3 ! set up for initial iteration
-Ldivloop:
- sll %o2, 4, %o2
- ! depth 1, accumulated bits 0
- bl L.1.16
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 2, accumulated bits 1
- bl L.2.17
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 3, accumulated bits 3
- bl L.3.19
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits 7
- bl L.4.23
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (7*2+1), %o2
-
-L.4.23:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (7*2-1), %o2
-
-
-L.3.19:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits 5
- bl L.4.21
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (5*2+1), %o2
-
-L.4.21:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (5*2-1), %o2
-
-
-
-L.2.17:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 3, accumulated bits 1
- bl L.3.17
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits 3
- bl L.4.19
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (3*2+1), %o2
-
-L.4.19:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (3*2-1), %o2
-
-
-L.3.17:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits 1
- bl L.4.17
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (1*2+1), %o2
-
-L.4.17:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (1*2-1), %o2
-
-
-
-
-L.1.16:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 2, accumulated bits -1
- bl L.2.15
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 3, accumulated bits -1
- bl L.3.15
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits -1
- bl L.4.15
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-1*2+1), %o2
-
-L.4.15:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-1*2-1), %o2
-
-
-L.3.15:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits -3
- bl L.4.13
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-3*2+1), %o2
-
-L.4.13:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-3*2-1), %o2
-
-
-
-L.2.15:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 3, accumulated bits -3
- bl L.3.13
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits -5
- bl L.4.11
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-5*2+1), %o2
-
-L.4.11:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-5*2-1), %o2
-
-
-L.3.13:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits -7
- bl L.4.9
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-7*2+1), %o2
-
-L.4.9:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-7*2-1), %o2
-
-
-
-
- 9:
-Lend_regular_divide:
- deccc %o4
- bge Ldivloop
- tst %o3
- bl,a Lgot_result
- ! non-restoring fixup here (one instruction only!)
- dec %o2
-
-
-Lgot_result:
-
- retl
- mov %o2, %o0
diff --git a/sys/lib/libkern/arch/sparc/umul.S b/sys/lib/libkern/arch/sparc/umul.S
deleted file mode 100644
index 9aa571ca12d..00000000000
--- a/sys/lib/libkern/arch/sparc/umul.S
+++ /dev/null
@@ -1,182 +0,0 @@
-/* $OpenBSD: umul.S,v 1.6 2007/11/24 19:47:05 deraadt Exp $ */
-/* $NetBSD: umul.S,v 1.2 1994/10/26 06:40:10 cgd Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Header: umul.s,v 1.4 92/06/25 13:24:05 torek Exp
- */
-
-/*
- * Unsigned multiply. Returns %o0 * %o1 in %o1%o0 (i.e., %o1 holds the
- * upper 32 bits of the 64-bit product).
- *
- * This code optimizes short (less than 13-bit) multiplies. Short
- * multiplies require 25 instruction cycles, and long ones require
- * 45 instruction cycles.
- *
- * On return, overflow has occurred (%o1 is not zero) if and only if
- * the Z condition code is clear, allowing, e.g., the following:
- *
- * call .umul
- * nop
- * bnz overflow (or tnz)
- */
-
-#include "DEFS.h"
-FUNC(.umul)
- or %o0, %o1, %o4
- mov %o0, %y ! multiplier -> Y
- andncc %o4, 0xfff, %g0 ! test bits 12..31 of *both* args
- be Lmul_shortway ! if zero, can do it the short way
- andcc %g0, %g0, %o4 ! zero the partial product and clear N and V
-
- /*
- * Long multiply. 32 steps, followed by a final shift step.
- */
- mulscc %o4, %o1, %o4 ! 1
- mulscc %o4, %o1, %o4 ! 2
- mulscc %o4, %o1, %o4 ! 3
- mulscc %o4, %o1, %o4 ! 4
- mulscc %o4, %o1, %o4 ! 5
- mulscc %o4, %o1, %o4 ! 6
- mulscc %o4, %o1, %o4 ! 7
- mulscc %o4, %o1, %o4 ! 8
- mulscc %o4, %o1, %o4 ! 9
- mulscc %o4, %o1, %o4 ! 10
- mulscc %o4, %o1, %o4 ! 11
- mulscc %o4, %o1, %o4 ! 12
- mulscc %o4, %o1, %o4 ! 13
- mulscc %o4, %o1, %o4 ! 14
- mulscc %o4, %o1, %o4 ! 15
- mulscc %o4, %o1, %o4 ! 16
- mulscc %o4, %o1, %o4 ! 17
- mulscc %o4, %o1, %o4 ! 18
- mulscc %o4, %o1, %o4 ! 19
- mulscc %o4, %o1, %o4 ! 20
- mulscc %o4, %o1, %o4 ! 21
- mulscc %o4, %o1, %o4 ! 22
- mulscc %o4, %o1, %o4 ! 23
- mulscc %o4, %o1, %o4 ! 24
- mulscc %o4, %o1, %o4 ! 25
- mulscc %o4, %o1, %o4 ! 26
- mulscc %o4, %o1, %o4 ! 27
- mulscc %o4, %o1, %o4 ! 28
- mulscc %o4, %o1, %o4 ! 29
- mulscc %o4, %o1, %o4 ! 30
- mulscc %o4, %o1, %o4 ! 31
- mulscc %o4, %o1, %o4 ! 32
- mulscc %o4, %g0, %o4 ! final shift
-
-
- /*
- * Normally, with the shift-and-add approach, if both numbers are
- * positive you get the correct result. WIth 32-bit two's-complement
- * numbers, -x is represented as
- *
- * x 32
- * ( 2 - ------ ) mod 2 * 2
- * 32
- * 2
- *
- * (the `mod 2' subtracts 1 from 1.bbbb). To avoid lots of 2^32s,
- * we can treat this as if the radix point were just to the left
- * of the sign bit (multiply by 2^32), and get
- *
- * -x = (2 - x) mod 2
- *
- * Then, ignoring the `mod 2's for convenience:
- *
- * x * y = xy
- * -x * y = 2y - xy
- * x * -y = 2x - xy
- * -x * -y = 4 - 2x - 2y + xy
- *
- * For signed multiplies, we subtract (x << 32) from the partial
- * product to fix this problem for negative multipliers (see mul.s).
- * Because of the way the shift into the partial product is calculated
- * (N xor V), this term is automatically removed for the multiplicand,
- * so we don't have to adjust.
- *
- * But for unsigned multiplies, the high order bit wasn't a sign bit,
- * and the correction is wrong. So for unsigned multiplies where the
- * high order bit is one, we end up with xy - (y << 32). To fix it
- * we add y << 32.
- */
- tst %o1
- bl,a 1f ! if %o1 < 0 (high order bit = 1),
- add %o4, %o0, %o4 ! %o4 += %o0 (add y to upper half)
-1: rd %y, %o0 ! get lower half of product
- retl
- addcc %o4, %g0, %o1 ! put upper half in place and set Z for %o1==0
-
-Lmul_shortway:
- /*
- * Short multiply. 12 steps, followed by a final shift step.
- * The resulting bits are off by 12 and (32-12) = 20 bit positions,
- * but there is no problem with %o0 being negative (unlike above),
- * and overflow is impossible (the answer is at most 24 bits long).
- */
- mulscc %o4, %o1, %o4 ! 1
- mulscc %o4, %o1, %o4 ! 2
- mulscc %o4, %o1, %o4 ! 3
- mulscc %o4, %o1, %o4 ! 4
- mulscc %o4, %o1, %o4 ! 5
- mulscc %o4, %o1, %o4 ! 6
- mulscc %o4, %o1, %o4 ! 7
- mulscc %o4, %o1, %o4 ! 8
- mulscc %o4, %o1, %o4 ! 9
- mulscc %o4, %o1, %o4 ! 10
- mulscc %o4, %o1, %o4 ! 11
- mulscc %o4, %o1, %o4 ! 12
- mulscc %o4, %g0, %o4 ! final shift
-
- /*
- * %o4 has 20 of the bits that should be in the result; %y has
- * the bottom 12 (as %y's top 12). That is:
- *
- * %o4 %y
- * +----------------+----------------+
- * | -12- | -20- | -12- | -20- |
- * +------(---------+------)---------+
- * -----result-----
- *
- * The 12 bits of %o4 left of the `result' area are all zero;
- * in fact, all top 20 bits of %o4 are zero.
- */
-
- rd %y, %o5
- sll %o4, 12, %o0 ! shift middle bits left 12
- srl %o5, 20, %o5 ! shift low bits right 20
- or %o5, %o0, %o0
- retl
- addcc %g0, %g0, %o1 ! %o1 = zero, and set Z
diff --git a/sys/lib/libkern/arch/sparc/urem.S b/sys/lib/libkern/arch/sparc/urem.S
deleted file mode 100644
index b88d3f4ac02..00000000000
--- a/sys/lib/libkern/arch/sparc/urem.S
+++ /dev/null
@@ -1,417 +0,0 @@
-
-/* $OpenBSD: urem.S,v 1.2 2011/03/12 18:51:31 deraadt Exp $ */
-/* $NetBSD: divrem.m4,v 1.3 1995/04/22 09:37:39 pk Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS `AS IS' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Header: divrem.m4,v 1.4 92/06/25 13:23:57 torek Exp
- */
-
-/*
- * Division and remainder, from Appendix E of the Sparc Version 8
- * Architecture Manual, with fixes from Gordon Irlam.
- */
-
-/*
- * Input: dividend and divisor in %o0 and %o1 respectively.
- *
- * m4 parameters:
- * .urem name of function to generate
- * _C_LABEL(_urem) secondary name of function to generate
- * rem rem=div => %o0 / %o1; rem=rem => %o0 % %o1
- * false false=true => signed; false=false => unsigned
- *
- * Algorithm parameters:
- * N how many bits per iteration we try to get (4)
- * WORDSIZE total number of bits (32)
- *
- * Derived constants:
- * TWOSUPN 2^N, for label generation (m4 exponentiation currently broken)
- * TOPBITS number of bits in the top decade of a number
- *
- * Important variables:
- * Q the partial quotient under development (initially 0)
- * R the remainder so far, initially the dividend
- * ITER number of main division loop iterations required;
- * equal to ceil(log2(quotient) / N). Note that this
- * is the log base (2^N) of the quotient.
- * V the current comparand, initially divisor*2^(ITER*N-1)
- *
- * Cost:
- * Current estimate for non-large dividend is
- * ceil(log2(quotient) / N) * (10 + 7N/2) + C
- * A large dividend is one greater than 2^(31-TOPBITS) and takes a
- * different path, as the upper bits of the quotient must be developed
- * one bit at a time.
- */
-
-
-
-
-
-
-
-
-
-
-
-
-
-/* m4 reminder: d => if a is b, then c, else d */
-
-
-
-
-/*
- * This is the recursive definition for developing quotient digits.
- *
- * Parameters:
- * $1 the current depth, 1 <= $1 <= 4
- * $2 the current accumulation of quotient bits
- * 4 max depth
- *
- * We add a new bit to $2 and either recurse or insert the bits in
- * the quotient. %o3, %o2, and %o5 are inputs and outputs as defined above;
- * the condition codes are expected to reflect the input %o3, and are
- * modified to reflect the output %o3.
- */
-
-
-#include "DEFS.h"
-#include <machine/trap.h>
-#include <machine/asm.h>
-
- .globl _C_LABEL(_urem)
-_C_LABEL(_urem):
-FUNC(.urem)
-
- ! Ready to divide. Compute size of quotient; scale comparand.
- orcc %o1, %g0, %o5
- bnz 1f
- mov %o0, %o3
-
- ! Divide by zero trap. If it returns, return 0 (about as
- ! wrong as possible, but that is what SunOS does...).
- t ST_DIV0
- retl
- clr %o0
-
-1:
- cmp %o3, %o5 ! if %o1 exceeds %o0, done
- blu Lgot_result ! (and algorithm fails otherwise)
- clr %o2
- sethi %hi(1 << (32 - 4 - 1)), %g1
- cmp %o3, %g1
- blu Lnot_really_big
- clr %o4
-
- ! Here the dividend is >= 2^(31-N) or so. We must be careful here,
- ! as our usual N-at-a-shot divide step will cause overflow and havoc.
- ! The number of bits in the result here is N*ITER+SC, where SC <= N.
- ! Compute ITER in an unorthodox manner: know we need to shift V into
- ! the top decade: so do not even bother to compare to R.
- 1:
- cmp %o5, %g1
- bgeu 3f
- mov 1, %g5
- sll %o5, 4, %o5
- b 1b
- inc %o4
-
- ! Now compute %g5.
- 2: addcc %o5, %o5, %o5
- bcc Lnot_too_big
- inc %g5
-
- ! We get here if the %o1 overflowed while shifting.
- ! This means that %o3 has the high-order bit set.
- ! Restore %o5 and subtract from %o3.
- sll %g1, 4, %g1 ! high order bit
- srl %o5, 1, %o5 ! rest of %o5
- add %o5, %g1, %o5
- b Ldo_single_div
- dec %g5
-
- Lnot_too_big:
- 3: cmp %o5, %o3
- blu 2b
- nop
- be Ldo_single_div
- nop
- /* NB: these are commented out in the V8-Sparc manual as well */
- /* (I do not understand this) */
- ! %o5 > %o3: went too far: back up 1 step
- ! srl %o5, 1, %o5
- ! dec %g5
- ! do single-bit divide steps
- !
- ! We have to be careful here. We know that %o3 >= %o5, so we can do the
- ! first divide step without thinking. BUT, the others are conditional,
- ! and are only done if %o3 >= 0. Because both %o3 and %o5 may have the high-
- ! order bit set in the first step, just falling into the regular
- ! division loop will mess up the first time around.
- ! So we unroll slightly...
- Ldo_single_div:
- deccc %g5
- bl Lend_regular_divide
- nop
- sub %o3, %o5, %o3
- mov 1, %o2
- b Lend_single_divloop
- nop
- Lsingle_divloop:
- sll %o2, 1, %o2
- bl 1f
- srl %o5, 1, %o5
- ! %o3 >= 0
- sub %o3, %o5, %o3
- b 2f
- inc %o2
- 1: ! %o3 < 0
- add %o3, %o5, %o3
- dec %o2
- 2:
- Lend_single_divloop:
- deccc %g5
- bge Lsingle_divloop
- tst %o3
- b,a Lend_regular_divide
-
-Lnot_really_big:
-1:
- sll %o5, 4, %o5
- cmp %o5, %o3
- bleu 1b
- inccc %o4
- be Lgot_result
- dec %o4
-
- tst %o3 ! set up for initial iteration
-Ldivloop:
- sll %o2, 4, %o2
- ! depth 1, accumulated bits 0
- bl L.1.16
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 2, accumulated bits 1
- bl L.2.17
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 3, accumulated bits 3
- bl L.3.19
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits 7
- bl L.4.23
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (7*2+1), %o2
-
-L.4.23:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (7*2-1), %o2
-
-
-L.3.19:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits 5
- bl L.4.21
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (5*2+1), %o2
-
-L.4.21:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (5*2-1), %o2
-
-
-
-L.2.17:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 3, accumulated bits 1
- bl L.3.17
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits 3
- bl L.4.19
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (3*2+1), %o2
-
-L.4.19:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (3*2-1), %o2
-
-
-L.3.17:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits 1
- bl L.4.17
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (1*2+1), %o2
-
-L.4.17:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (1*2-1), %o2
-
-
-
-
-L.1.16:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 2, accumulated bits -1
- bl L.2.15
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 3, accumulated bits -1
- bl L.3.15
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits -1
- bl L.4.15
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-1*2+1), %o2
-
-L.4.15:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-1*2-1), %o2
-
-
-L.3.15:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits -3
- bl L.4.13
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-3*2+1), %o2
-
-L.4.13:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-3*2-1), %o2
-
-
-
-L.2.15:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 3, accumulated bits -3
- bl L.3.13
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits -5
- bl L.4.11
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-5*2+1), %o2
-
-L.4.11:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-5*2-1), %o2
-
-
-L.3.13:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits -7
- bl L.4.9
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-7*2+1), %o2
-
-L.4.9:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-7*2-1), %o2
-
-
-
-
- 9:
-Lend_regular_divide:
- deccc %o4
- bge Ldivloop
- tst %o3
- bl,a Lgot_result
- ! non-restoring fixup here (one instruction only!)
- add %o3, %o1, %o3
-
-
-Lgot_result:
-
- retl
- mov %o3, %o0