Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * Hypervisor Software File: __align_cpy_8.s | |
5 | * | |
6 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
7 | * | |
8 | * - Do no alter or remove copyright notices | |
9 | * | |
10 | * - Redistribution and use of this software in source and binary forms, with | |
11 | * or without modification, are permitted provided that the following | |
12 | * conditions are met: | |
13 | * | |
14 | * - Redistribution of source code must retain the above copyright notice, | |
15 | * this list of conditions and the following disclaimer. | |
16 | * | |
17 | * - Redistribution in binary form must reproduce the above copyright notice, | |
18 | * this list of conditions and the following disclaimer in the | |
19 | * documentation and/or other materials provided with the distribution. | |
20 | * | |
21 | * Neither the name of Sun Microsystems, Inc. or the names of contributors | |
22 | * may be used to endorse or promote products derived from this software | |
23 | * without specific prior written permission. | |
24 | * | |
25 | * This software is provided "AS IS," without a warranty of any kind. | |
26 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
27 | * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
28 | * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
29 | * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
30 | * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
31 | * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
32 | * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
33 | * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
34 | * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
35 | * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
36 | * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
37 | * | |
38 | * You acknowledge that this software is not designed, licensed or | |
39 | * intended for use in the design, construction, operation or maintenance of | |
40 | * any nuclear facility. | |
41 | * | |
42 | * ========== Copyright Header End ============================================ | |
43 | */ | |
44 | /* | |
45 | * Copyright (c) 1997, Sun Microsystems, Inc. | |
46 | * All rights reserved. | |
47 | */ | |
48 | ||
49 | .ident "@(#)__align_cpy_8.s 1.1 97/02/10 SMI" | |
50 | ||
51 | .file "__align_cpy_8.s" | |
52 | ||
53 | /* __align_cpy_8(s1, s2, n) | |
54 | * | |
55 | * Copy 8-byte aligned source to 8-byte aligned target in multiples of 8 bytes. | |
56 | * | |
57 | * Input: | |
58 | * o0 address of target | |
59 | * o1 address of source | |
60 | * o2 number of bytes to copy (must be a multiple of 8) | |
61 | * Output: | |
62 | * o0 address of target | |
63 | * Caller's registers that have been changed by this function: | |
64 | * o1-o5 | |
65 | * | |
66 | * Note: | |
67 | * This helper routine will not be used by any 32-bit compilations. To do | |
68 | * so would break binary compatibility with previous versions of Solaris. | |
69 | * | |
70 | * Assumptions: | |
71 | * Source and target addresses are 8-byte aligned. | |
72 | * Bytes to be copied are non-overlapping or _exactly_ overlapping. | |
73 | * The number of bytes to be copied is a multiple of 8. | |
74 | * Call will _usually_ be made with a byte count of more than 4*8 and | |
75 | * less than a few hundred bytes. Legal values are 0 to MAX_SIZE_T. | |
76 | * | |
77 | * Optimization attempt: | |
78 | * Reasonable speed for a generic v9. Going for 32 bytes at a time | |
79 | * rather than 16 bytes at a time did not result in a time saving for | |
80 | * the number of bytes expected to be copied. No timing runs using other | |
81 | * levels of optimization have been tried yet. | |
82 | * | |
83 | * Even when multiples of 16 bytes were used, the savings by going for 32 bytes | |
84 | * at a time were about 2%. Thus, __align_cpy_16 is a second entry point to | |
85 | * the same code as __align_cpy_8. | |
86 | * | |
87 | * Register usage: | |
88 | * o1 source address (updated for each read) | |
89 | * o2 byte count remaining | |
90 | * o3 contents being copied | |
91 | * o4 more contents being copied | |
92 | * o5 target address | |
93 | */ | |
94 | ||
95 | #include <sys/asm_linkage.h> | |
96 | ||
97 | !#include "synonyms.h" | |
98 | ||
99 | ENTRY(__align_cpy_8) | |
100 | ENTRY(__align_cpy_16) | |
101 | cmp %o0, %o1 ! Identical--do nothing. | |
102 | be,pn %xcc, .done | |
103 | subcc %o2, 8, %o2 | |
104 | bz,pn %xcc, .wrdbl2 ! Only 8 bytes need to be copied. | |
105 | mov %o0, %o5 ! Original target address is returned. | |
106 | bpos,a,pt %xcc, .wrdbl1 ! Have at least 16 bytes to copy. | |
107 | ldx [%o1], %o3 | |
108 | .done: | |
109 | retl ! No bytes to copy. | |
110 | nop | |
111 | ||
112 | .align 32 | |
113 | .wrdbl1: ! Copy 16 bytes at a time. | |
114 | subcc %o2, 16, %o2 | |
115 | ldx [%o1+8], %o4 | |
116 | add %o1, 16, %o1 | |
117 | stx %o3, [%o5] | |
118 | stx %o4, [%o5+8] | |
119 | add %o5, 16, %o5 | |
120 | bg,a,pt %xcc, .wrdbl1 ! Have at least 16 more bytes. | |
121 | ldx [%o1], %o3 | |
122 | ||
123 | bz,a,pt %xcc, .wrdbl3 ! Have 8 bytes remaining to copy. | |
124 | ldx [%o1], %o3 | |
125 | ||
126 | retl | |
127 | nop | |
128 | ||
129 | .wrdbl2: | |
130 | ldx [%o1], %o3 ! Copy last 8 bytes. | |
131 | .wrdbl3: | |
132 | stx %o3, [%o5] | |
133 | retl | |
134 | nop | |
135 | ||
136 | SET_SIZE(__align_cpy_8) | |
137 | SET_SIZE(__align_cpy_16) |