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