summaryrefslogtreecommitdiffstats
path: root/lib/libc/ia64/string
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>2000-10-14 17:01:12 +0000
committerdfr <dfr@FreeBSD.org>2000-10-14 17:01:12 +0000
commit7c5dc96d3cd8781bbda31c7e6ffc5bec59f4fc44 (patch)
tree548aa4a1389ff61b14a598f82b3e084ae21c9358 /lib/libc/ia64/string
parent2cd0661ce2f3ca080513c7f54c7e77b5209e23c9 (diff)
downloadFreeBSD-src-7c5dc96d3cd8781bbda31c7e6ffc5bec59f4fc44.zip
FreeBSD-src-7c5dc96d3cd8781bbda31c7e6ffc5bec59f4fc44.tar.gz
Initial libc port for ia64.
Diffstat (limited to 'lib/libc/ia64/string')
-rw-r--r--lib/libc/ia64/string/Makefile.inc3
-rw-r--r--lib/libc/ia64/string/bcopy.S96
-rw-r--r--lib/libc/ia64/string/bzero.S77
-rw-r--r--lib/libc/ia64/string/ffs.S99
-rw-r--r--lib/libc/ia64/string/memcpy.S38
-rw-r--r--lib/libc/ia64/string/memmove.S38
6 files changed, 351 insertions, 0 deletions
diff --git a/lib/libc/ia64/string/Makefile.inc b/lib/libc/ia64/string/Makefile.inc
new file mode 100644
index 0000000..7bbcc8d
--- /dev/null
+++ b/lib/libc/ia64/string/Makefile.inc
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+MDSRCS+= bcopy.S bzero.S ffs.S memcpy.S memmove.S
diff --git a/lib/libc/ia64/string/bcopy.S b/lib/libc/ia64/string/bcopy.S
new file mode 100644
index 0000000..5a2f9fd
--- /dev/null
+++ b/lib/libc/ia64/string/bcopy.S
@@ -0,0 +1,96 @@
+/*-
+ * Copyright (c) 2000 Doug Rabson
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * $FreeBSD$
+ */
+
+#include <machine/asm.h>
+
+/*
+ * Not the fastest bcopy in the world.
+ */
+ENTRY(bcopy, 3)
+
+ cmp.le p6,p0=in2,r0 // bail if len <= 0
+(p6) br.ret.spnt.few rp
+
+ sub r14=in1,in0 ;; // check for overlap
+ cmp.ltu p6,p0=r14,in2 // dst-src < len
+(p6) br.cond.spnt.few 5f
+
+ extr.u r14=in0,0,3 // src & 7
+ extr.u r15=in1,0,3 ;; // dst & 7
+ cmp.eq p6,p0=r14,r15 // different alignment?
+(p6) br.cond.spnt.few 2f // branch if same alignment
+
+1: ld1 r14=[in0],1 ;; // copy bytewise
+ st1 [in1]=r14,1
+ add in2=-1,in2 ;; // len--
+ cmp.ne p6,p0=r0,in2
+(p6) br.cond.dptk.few 1b // loop
+ br.ret.sptk.few rp // done
+
+2: cmp.eq p6,p0=r14,r0 // aligned?
+(p6) br.cond.sptk.few 4f
+
+3: ld1 r14=[in0],1 ;; // copy bytewise
+ st1 [in1]=r14,1
+ extr.u r15=in0,0,3 // src & 7
+ add in2=-1,in2 ;; // len--
+ cmp.eq p6,p0=r0,in2 // done?
+ cmp.eq p7,p0=r0,r15 ;; // aligned now?
+(p6) br.ret.spnt.few rp // return if done
+(p7) br.cond.spnt.few 4f // go to main copy
+ br.cond.sptk.few 3b // more bytes to copy
+
+ // At this point, in2 is non-zero
+
+4: mov r14=8 ;;
+ cmp.ltu p6,p0=in2,r14 ;; // len < 8?
+(p6) br.cond.spnt.few 1b // byte copy the end
+ ld8 r15=[in0],8 ;; // copy word
+ st8 [in1]=r15,8
+ add in2=-8,in2 ;; // len -= 8
+ cmp.ne p6,p0=r0,in2 // done?
+(p6) br.cond.spnt.few 4b // again
+
+ br.ret.sptk.few rp // return
+
+ // Don't bother optimising overlap case
+
+5: add in0=in0,in2
+ add in1=in1,in2 ;;
+ add in0=-1,in0
+ add in1=-1,in1 ;;
+
+6: ld1 r14=[in0],-1 ;;
+ st1 [in1]=r14,-1
+ add in2=-1,in2 ;;
+ cmp.ne p6,p0=r0,in2
+(p6) br.cond.spnt.few 6b
+
+ br.ret.sptk.few rp
+
+END(bcopy)
diff --git a/lib/libc/ia64/string/bzero.S b/lib/libc/ia64/string/bzero.S
new file mode 100644
index 0000000..a7ff010
--- /dev/null
+++ b/lib/libc/ia64/string/bzero.S
@@ -0,0 +1,77 @@
+/*-
+ * Copyright (c) 2000 Doug Rabson
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * $FreeBSD$
+ */
+
+#include <machine/asm.h>
+
+ENTRY(bzero, 2)
+
+ cmp.le p6,p0=in1,r0 // bail if len <= 0
+(p6) br.ret.spnt.few rp
+
+ mov r14=ar.lc // save ar.lc
+
+ cmp.geu p6,p0=17,in1 // check for small
+(p6) br.dptk.few 2f
+
+1: mov ar.lc=in1
+2: st1 [in0]=r0,1 // zero one byte
+ br.cloop.sptk.few 2b // loop
+
+ mov ar.lc=r14 // done
+ br.ret.sptk.few rp
+
+ // Zero up to 8byte alignment
+
+ tbit.nz p6,p0=in1,0 ;;
+(p6) st1 [in0]=r0,1
+(p6) add in1=-1,in1
+
+ tbit.nz p6,p0=in1,1 ;;
+(p6) st2 [in0]=r0,2
+(p6) add in1=-2,in1
+
+ tbit.nz p6,p0=in1,2 ;;
+(p6) st4 [in0]=r0,4
+(p6) add in1=-4,in1
+
+ shr.u r15=in1,3 // word count
+ extr.u in1=in1,0,3 ;; // trailing bytes
+ cmp.eq p6,p0=r15,r0 // check for zero
+ cmp.ne p7,p0=in1,r0
+(p6) br.dpnt.few 1b // zero last bytes
+
+ mov ar.lc=r15
+3: st8 [in0]=r0,8
+ br.cloop.sptk.few 3b
+
+(p7) br.dpnt.few 1b // zero last bytes
+
+ mov ar.lc=r14 // done
+ br.ret.sptk.few rp
+
+END(bzero) \ No newline at end of file
diff --git a/lib/libc/ia64/string/ffs.S b/lib/libc/ia64/string/ffs.S
new file mode 100644
index 0000000..9c6e56e
--- /dev/null
+++ b/lib/libc/ia64/string/ffs.S
@@ -0,0 +1,99 @@
+/* $FreeBSD$ */
+/* $NetBSD: ffs.S,v 1.3 1996/10/17 03:08:13 cgd Exp $ */
+
+/*
+ * Copyright (c) 1995 Christopher G. Demetriou
+ * All rights reserved.
+ *
+ * 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 Christopher G. Demetriou
+ * for the NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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/asm.h>
+
+ENTRY(ffs, 1)
+ sxt4 r14=in0 ;;
+ cmp.eq p6,p0=r14,r0
+(p6) br.dpnt.few Lallzero
+
+ /*
+ * Initialize return value (ret0), and set up r15 so that it
+ * contains the mask with only the lowest bit set.
+ */
+ sub r15=r0,r14
+ mov ret0=1 ;;
+ and r15=r14,r15
+
+ extr.u r16=r15,0,8 ;;
+ cmp.ne p6,p0=r0,r16
+(p6) br.dptk.few Ldo8
+
+ /*
+ * If lower 16 bits empty, add 16 to result and use upper 16.
+ */
+ extr.u r16=r15,0,16 ;;
+ cmp.ne p6,p0=r0,r16
+(p6) br.dptk.few Ldo16
+ extr.u r15=r15,16,16
+ add ret0=16,ret0
+
+Ldo16:
+ /*
+ * If lower 8 bits empty, add 8 to result and use upper 8.
+ */
+ extr.u r16=r15,0,8 ;;
+ cmp.ne p6,p0=r0,r16
+(p6) br.dptk.few Ldo8
+ extr.u r15=r15,8,24
+ add ret0=8,ret0
+
+Ldo8:
+ and r16=0x0f,r15 /* lower 4 of 8 empty? */
+ and r17=0x33,r15 /* lower 2 of each 4 empty? */
+ and r18=0x55,r15 ;; /* lower 1 of each 2 empty? */
+ cmp.ne p6,p0=r16,r0
+ cmp.ne p7,p0=r17,r0
+ cmp.ne p8,p0=r18,r0
+
+ /* If lower 4 bits empty, add 4 to result. */
+(p6) br.dptk.few Ldo4
+ add ret0=4,ret0
+
+Ldo4: /* If lower 2 bits of each 4 empty, add 2 to result. */
+(p7) br.dptk.few Ldo2
+ add ret0=2,ret0
+
+Ldo2: /* If lower bit of each 2 empty, add 1 to result. */
+(p8) br.dptk.few Ldone
+ add ret0=1,ret0
+
+Ldone:
+ br.ret.sptk.few rp
+
+Lallzero:
+ mov ret0=0
+ br.ret.sptk.few rp
+END(ffs)
diff --git a/lib/libc/ia64/string/memcpy.S b/lib/libc/ia64/string/memcpy.S
new file mode 100644
index 0000000..572e49a
--- /dev/null
+++ b/lib/libc/ia64/string/memcpy.S
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2000 Doug Rabson
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * $FreeBSD$
+ */
+
+#include <machine/asm.h>
+
+ENTRY(memcpy,3)
+
+ mov r14=in0 ;;
+ mov in0=in1 ;;
+ mov in1=r14
+ br.cond.sptk.few bcopy
+
+END(memcpy)
diff --git a/lib/libc/ia64/string/memmove.S b/lib/libc/ia64/string/memmove.S
new file mode 100644
index 0000000..5586a60
--- /dev/null
+++ b/lib/libc/ia64/string/memmove.S
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2000 Doug Rabson
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * $FreeBSD$
+ */
+
+#include <machine/asm.h>
+
+ENTRY(memmove,3)
+
+ mov r14=in0 ;;
+ mov in0=in1 ;;
+ mov in1=r14
+ br.cond.sptk.few bcopy
+
+END(memcpy)
OpenPOWER on IntegriCloud