usr/src/lib/libc/sparcv9/crt/__align_cpy_8.s
author Mark J. Nelson <Mark.J.Nelson@Sun.COM>
Wed, 06 Aug 2008 16:29:39 -0600
changeset 7298 b69e27387f74
parent 6812 febeba71273d
permissions -rw-r--r--
6733918 Teamware has retired, please welcome your new manager, Mercurial 4758439 some files use "current date" sccs keywords 6560843 asm sources should not rely on .file "%M%" for naming STT_FILE symbols 6560958 Solaris:: perl modules should not use SCCS keywords in version information 6729074 webrev doesn't deal well with remote ssh hg parents
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     1
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     2
 * CDDL HEADER START
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     3
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
6812
febeba71273d PSARC 2008/309 expunge synonyms.h
raf
parents: 0
diff changeset
     5
 * Common Development and Distribution License (the "License").
febeba71273d PSARC 2008/309 expunge synonyms.h
raf
parents: 0
diff changeset
     6
 * You may not use this file except in compliance with the License.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     7
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    11
 * and limitations under the License.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    12
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    18
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    19
 * CDDL HEADER END
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    20
 */
6812
febeba71273d PSARC 2008/309 expunge synonyms.h
raf
parents: 0
diff changeset
    21
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    22
/*
6812
febeba71273d PSARC 2008/309 expunge synonyms.h
raf
parents: 0
diff changeset
    23
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
febeba71273d PSARC 2008/309 expunge synonyms.h
raf
parents: 0
diff changeset
    24
 * Use is subject to license terms.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    25
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    26
7298
b69e27387f74 6733918 Teamware has retired, please welcome your new manager, Mercurial
Mark J. Nelson <Mark.J.Nelson@Sun.COM>
parents: 6812
diff changeset
    27
	.file	"__align_cpy_8.s"
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    28
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    29
/* __align_cpy_8(s1, s2, n)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    30
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    31
 * Copy 8-byte aligned source to 8-byte aligned target in multiples of 8 bytes.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    32
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    33
 * Input:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    34
 *	o0	address of target
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    35
 *	o1	address of source
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    36
 *	o2	number of bytes to copy (must be a multiple of 8)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    37
 * Output:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    38
 *	o0	address of target
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    39
 * Caller's registers that have been changed by this function:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    40
 *	o1-o5
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    41
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    42
 * Note:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    43
 *	This helper routine will not be used by any 32-bit compilations. To do
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    44
 *	so would break binary compatibility with previous versions of Solaris.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    45
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    46
 * Assumptions:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    47
 *	Source and target addresses are 8-byte aligned.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    48
 *	Bytes to be copied are non-overlapping or _exactly_ overlapping.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    49
 *	The number of bytes to be copied is a multiple of 8.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    50
 *	Call will _usually_ be made with a byte count of more than 4*8 and
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    51
 *	less than a few hundred bytes.  Legal values are 0 to MAX_SIZE_T.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    52
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    53
 * Optimization attempt:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    54
 *	Reasonable speed for a generic v9.  Going for 32 bytes at a time
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    55
 *	rather than 16 bytes at a time did not result in a time saving for
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    56
 *	the number of bytes expected to be copied.  No timing runs using other
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    57
 *	levels of optimization have been tried yet.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    58
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    59
 * Even when multiples of 16 bytes were used, the savings by going for 32 bytes
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    60
 * at a time were about 2%.  Thus, __align_cpy_16 is a second entry point to
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    61
 * the same code as __align_cpy_8.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    62
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    63
 * Register usage:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    64
 *	o1	source address (updated for each read)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    65
 *	o2	byte count remaining
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    66
 *	o3	contents being copied
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    67
 *	o4	more contents being copied
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    68
 *	o5	target address
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    69
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    70
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    71
#include <sys/asm_linkage.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    72
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    73
	ENTRY(__align_cpy_8)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    74
	ENTRY(__align_cpy_16)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    75
	cmp	%o0, %o1		! Identical--do nothing.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    76
	be,pn	%xcc, .done
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    77
	subcc	%o2, 8, %o2
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    78
	bz,pn	%xcc, .wrdbl2		! Only 8 bytes need to be copied.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    79
	mov	%o0, %o5		! Original target address is returned.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    80
	bpos,a,pt %xcc, .wrdbl1		! Have at least 16 bytes to copy.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    81
	ldx	[%o1], %o3
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    82
.done:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    83
	retl				! No bytes to copy.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    84
	nop
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    85
	
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    86
	.align	32
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    87
.wrdbl1:				! Copy 16 bytes at a time.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    88
	subcc	%o2, 16, %o2
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    89
	ldx	[%o1+8], %o4
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    90
	add	%o1, 16, %o1
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    91
	stx	%o3, [%o5]
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    92
	stx	%o4, [%o5+8]
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    93
	add	%o5, 16, %o5
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    94
	bg,a,pt	%xcc, .wrdbl1		! Have at least 16 more bytes.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    95
	ldx	[%o1], %o3
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    96
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    97
	bz,a,pt	%xcc, .wrdbl3		! Have 8 bytes remaining to copy.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    98
	ldx	[%o1], %o3
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    99
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   100
	retl
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   101
	nop
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   102
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   103
.wrdbl2:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   104
	ldx	[%o1], %o3		! Copy last 8 bytes.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   105
.wrdbl3:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   106
	stx	%o3, [%o5]
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   107
	retl
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   108
	nop
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   109
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   110
	SET_SIZE(__align_cpy_8)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   111
	SET_SIZE(__align_cpy_16)