Home | History | Annotate | Line # | Download | only in string
bzero.S revision 1.3
      1  1.3  ross /*	$NetBSD: bzero.S,v 1.3 2006/07/07 06:53:42 ross Exp $	*/
      2  1.3  ross 
      3  1.1  ross /*-
      4  1.2  ross  * Copyright (c) 2006 The NetBSD Foundation, Inc.
      5  1.1  ross  * All rights reserved.
      6  1.1  ross  *
      7  1.2  ross  * This code is derived from software contributed to The NetBSD Foundation
      8  1.2  ross  * by Ross Harvey.
      9  1.2  ross  *
     10  1.1  ross  * Redistribution and use in source and binary forms, with or without
     11  1.1  ross  * modification, are permitted provided that the following conditions
     12  1.1  ross  * are met:
     13  1.1  ross  * 1. Redistributions of source code must retain the above copyright
     14  1.1  ross  *    notice, this list of conditions and the following disclaimer.
     15  1.1  ross  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1  ross  *    notice, this list of conditions and the following disclaimer in the
     17  1.1  ross  *    documentation and/or other materials provided with the distribution.
     18  1.2  ross  * 3. All advertising materials mentioning features or use of this software
     19  1.2  ross  *    must display the following acknowledgement:
     20  1.2  ross  *        This product includes software developed by the NetBSD
     21  1.2  ross  *        Foundation, Inc. and its contributors.
     22  1.2  ross  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.2  ross  *    contributors may be used to endorse or promote products derived
     24  1.2  ross  *    from this software without specific prior written permission.
     25  1.1  ross  *
     26  1.2  ross  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.2  ross  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,  BUT NOT LIMITED
     28  1.2  ross  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.2  ross  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.2  ross  * BE LIABLE FOR ANY DIRECT, INDIRECT,  INCIDENTAL,  SPECIAL,  EXEMPLARY,  OR
     31  1.2  ross  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,  PROCUREMENT OF
     32  1.2  ross  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,  OR PROFITS; OR BUSINESS
     33  1.2  ross  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.2  ross  * CONTRACT, STRICT LIABILITY,  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.2  ross  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.2  ross  * POSSIBILITY OF SUCH DAMAGE.
     37  1.1  ross  */
     38  1.1  ross 
     39  1.2  ross #include	<machine/asm.h>
     40  1.1  ross 
     41  1.2  ross 	.file	"bzero.c"
     42  1.1  ross ENTRY(bzero)
     43  1.2  ross 	mr	5, 4		# translate to memcpy signature
     44  1.2  ross 	li	4, 0		# add missing memcpy param
     45  1.1  ross ENTRY(memset)
     46  1.2  ross 	cmpldi	7, 5, 7		# only optimize if len >= 8
     47  1.2  ross 	mr	9, 3
     48  1.2  ross 	ble	7, 2f
     49  1.2  ross 	rldicl.	0, 3, 0, 61	# only optimize if aligned
     50  1.2  ross 	beq	0, 4f
     51  1.2  ross 2:
     52  1.2  ross 	cmpdi	7, 5, 0
     53  1.2  ross 	beqlr	7
     54  1.2  ross 3:
     55  1.2  ross 	mtctr	5
     56  1.2  ross 	rldicl	0, 4, 0, 56
     57  1.3  ross 	.p2align 4,, 15
     58  1.2  ross 2:
     59  1.2  ross 	stb	0, 0(9)		# byte-at-a-time loop
     60  1.2  ross 	addi	9, 9, 1
     61  1.2  ross 	bdnz	2b
     62  1.2  ross 	blr			# done
     63  1.2  ross 4:
     64  1.2  ross 	rldicl	4, 4, 0, 56	# construct parallel store
     65  1.2  ross 	cmpldi	7, 5, 31
     66  1.2  ross 	mr	10, 3
     67  1.2  ross 	sldi	0, 4, 8
     68  1.2  ross 	or	0, 0, 4
     69  1.2  ross 	sldi	9, 0, 16
     70  1.2  ross 	or	0, 0, 9
     71  1.2  ross 	sldi	11, 0, 32
     72  1.2  ross 	or	0, 0, 11
     73  1.2  ross 	ble	7, 5f
     74  1.2  ross 	addi	9, 5, -32
     75  1.2  ross 	srdi	9, 9, 5
     76  1.2  ross 	addi	9, 9, 1
     77  1.2  ross 	mtctr	9
     78  1.3  ross 	.p2align 4,, 15
     79  1.2  ross 2:
     80  1.2  ross 	std	0, 0(10)	# 8-way + unrolled store loop
     81  1.2  ross 	std	0, 8(10)
     82  1.2  ross 	addi	5, 5, -32	# schedule count decrement
     83  1.2  ross 	std	0, 16(10)
     84  1.2  ross 	std	0, 24(10)
     85  1.2  ross 	addi	10, 10, 32
     86  1.2  ross 	bdnz	2b
     87  1.2  ross 	cmpldi	7, 5, 7
     88  1.2  ross 	ble	7, 8f
     89  1.2  ross 5:
     90  1.2  ross 	addi	9, 5, -8
     91  1.2  ross 	srdi	9, 9, 3
     92  1.2  ross 	addi	9, 9, 1
     93  1.2  ross 	mtctr	9
     94  1.3  ross 	.p2align 4,, 15
     95  1.2  ross 14:
     96  1.2  ross 	std	0, 0(10)	# 8-way not-unrolled loop
     97  1.2  ross 	addi	5, 5, -8
     98  1.2  ross 	addi	10, 10, 8
     99  1.2  ross 	bdnz	14b
    100  1.2  ross 8:
    101  1.2  ross 	cmpdi	7, 5, 0
    102  1.2  ross 	mr	9, 10
    103  1.2  ross 	bne	7, 3b
    104  1.2  ross 	blr
    105  1.2  ross 	.long	0
    106  1.2  ross 	.byte	0, 0, 0, 0, 0, 0, 0, 0
    107  1.2  ross 	.size	.memset, .-.memset
    108