]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/sparc/sparc64/multiarch/memset-niagara1.S
8752b16f4a079694dfa8a99a554764a0258d284d
[thirdparty/glibc.git] / sysdeps / sparc / sparc64 / multiarch / memset-niagara1.S
1 /* Set a block of memory to some byte value. For SUN4V Niagara.
2 Copyright (C) 2006-2018 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by David S. Miller (davem@davemloft.net)
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20 #include <sysdep.h>
21
22 #define ASI_BLK_INIT_QUAD_LDD_P 0xe2
23 #define ASI_P 0x80
24 #define ASI_PNF 0x82
25
26 #ifndef XCC
27 #define USE_BPR
28 #define XCC xcc
29 #endif
30
31 #if IS_IN (libc)
32
33 .register %g2,#scratch
34
35 .text
36 .align 32
37
38 ENTRY(__memset_niagara1)
39 /* %o0=buf, %o1=pat, %o2=len */
40 and %o1, 0xff, %o3
41 mov %o2, %o1
42 sllx %o3, 8, %g1
43 or %g1, %o3, %o2
44 sllx %o2, 16, %g1
45 or %g1, %o2, %o2
46 sllx %o2, 32, %g1
47 ba,pt %XCC, 1f
48 or %g1, %o2, %o2
49 END(__memset_niagara1)
50
51 ENTRY(__bzero_niagara1)
52 clr %o2
53 1:
54 # ifndef USE_BRP
55 srl %o1, 0, %o1
56 # endif
57 brz,pn %o1, 90f
58 mov %o0, %o3
59
60 wr %g0, ASI_P, %asi
61
62 cmp %o1, 15
63 blu,pn %XCC, 70f
64 andcc %o0, 0x7, %g1
65 be,pt %XCC, 2f
66 mov 8, %g2
67 sub %g2, %g1, %g1
68 sub %o1, %g1, %o1
69 1: stba %o2, [%o0 + 0x00] %asi
70 subcc %g1, 1, %g1
71 bne,pt %XCC, 1b
72 add %o0, 1, %o0
73 2: cmp %o1, 128
74 blu,pn %XCC, 60f
75 andcc %o0, (64 - 1), %g1
76 be,pt %XCC, 40f
77 mov 64, %g2
78 sub %g2, %g1, %g1
79 sub %o1, %g1, %o1
80 1: stxa %o2, [%o0 + 0x00] %asi
81 subcc %g1, 8, %g1
82 bne,pt %XCC, 1b
83 add %o0, 8, %o0
84
85 40:
86 wr %g0, ASI_BLK_INIT_QUAD_LDD_P, %asi
87 andn %o1, (64 - 1), %g1
88 sub %o1, %g1, %o1
89
90 andn %g1, (256 - 1), %g2
91 brz,pt %g2, 50f
92 and %g1, (256 - 1), %g1
93
94 45:
95 stxa %o2, [%o0 + 0x00] %asi
96 stxa %o2, [%o0 + 0x08] %asi
97 stxa %o2, [%o0 + 0x10] %asi
98 stxa %o2, [%o0 + 0x18] %asi
99 stxa %o2, [%o0 + 0x20] %asi
100 stxa %o2, [%o0 + 0x28] %asi
101 stxa %o2, [%o0 + 0x30] %asi
102 stxa %o2, [%o0 + 0x38] %asi
103 stxa %o2, [%o0 + 0x40] %asi
104 stxa %o2, [%o0 + 0x48] %asi
105 stxa %o2, [%o0 + 0x50] %asi
106 stxa %o2, [%o0 + 0x58] %asi
107 stxa %o2, [%o0 + 0x60] %asi
108 stxa %o2, [%o0 + 0x68] %asi
109 stxa %o2, [%o0 + 0x70] %asi
110 stxa %o2, [%o0 + 0x78] %asi
111 stxa %o2, [%o0 + 0x80] %asi
112 stxa %o2, [%o0 + 0x88] %asi
113 stxa %o2, [%o0 + 0x90] %asi
114 stxa %o2, [%o0 + 0x98] %asi
115 stxa %o2, [%o0 + 0xa0] %asi
116 stxa %o2, [%o0 + 0xa8] %asi
117 stxa %o2, [%o0 + 0xb0] %asi
118 stxa %o2, [%o0 + 0xb8] %asi
119 stxa %o2, [%o0 + 0xc0] %asi
120 stxa %o2, [%o0 + 0xc8] %asi
121 stxa %o2, [%o0 + 0xd0] %asi
122 stxa %o2, [%o0 + 0xd8] %asi
123 stxa %o2, [%o0 + 0xe0] %asi
124 stxa %o2, [%o0 + 0xe8] %asi
125 stxa %o2, [%o0 + 0xf0] %asi
126 stxa %o2, [%o0 + 0xf8] %asi
127 subcc %g2, 256, %g2
128 bne,pt %XCC, 45b
129 add %o0, 256, %o0
130
131 brz,pn %g1, 55f
132 nop
133
134 50:
135 stxa %o2, [%o0 + 0x00] %asi
136 stxa %o2, [%o0 + 0x08] %asi
137 stxa %o2, [%o0 + 0x10] %asi
138 stxa %o2, [%o0 + 0x18] %asi
139 stxa %o2, [%o0 + 0x20] %asi
140 stxa %o2, [%o0 + 0x28] %asi
141 stxa %o2, [%o0 + 0x30] %asi
142 stxa %o2, [%o0 + 0x38] %asi
143 subcc %g1, 64, %g1
144 bne,pt %XCC, 50b
145 add %o0, 64, %o0
146
147 55:
148 wr %g0, ASI_P, %asi
149 brz,pn %o1, 80f
150 60:
151 andncc %o1, 0x7, %g1
152 be,pn %XCC, 2f
153 sub %o1, %g1, %o1
154 1: stxa %o2, [%o0 + 0x00] %asi
155 subcc %g1, 8, %g1
156 bne,pt %XCC, 1b
157 add %o0, 8, %o0
158 2: brz,pt %o1, 80f
159 nop
160
161 70:
162 1: stba %o2, [%o0 + 0x00] %asi
163 subcc %o1, 1, %o1
164 bne,pt %XCC, 1b
165 add %o0, 1, %o0
166
167 /* fallthrough */
168
169 80:
170 wr %g0, ASI_PNF, %asi
171
172 90:
173 retl
174 mov %o3, %o0
175 END(__bzero_niagara1)
176
177 #endif