2.9
[glibc/nacl-glibc.git] / sysdeps / sparc / sparc64 / sparcv9v / memset.S
blob64817b8871ed4aae3c2711b51922be34ed7d862f
1 /* Set a block of memory to some byte value.  For SUN4V Niagara.
2    Copyright (C) 2006, 2008 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4    Contributed by David S. Miller (davem@davemloft.net)
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.
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.
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, write to the Free
18    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
21 #include <sysdep.h>
23 #define ASI_BLK_INIT_QUAD_LDD_P 0xe2
24 #define ASI_P                   0x80
25 #define ASI_PNF                 0x82
27 #ifndef XCC
28 #define USE_BPR
29 #define XCC xcc
30 #endif
32         .register       %g2,#scratch
34         .text
35         .align          32
37 ENTRY(memset)
38         /* %o0=buf, %o1=pat, %o2=len */
39         and             %o1, 0xff, %o3
40         mov             %o2, %o1
41         sllx            %o3, 8, %g1
42         or              %g1, %o3, %o2
43         sllx            %o2, 16, %g1
44         or              %g1, %o2, %o2
45         sllx            %o2, 32, %g1
46         ba,pt           %XCC, 1f
47          or             %g1, %o2, %o2
48 END(memset)
50 ENTRY(__bzero)
51         clr             %o2
53 #ifndef USE_BRP
54         srl             %o1, 0, %o1
55 #endif
56         brz,pn          %o1, 90f
57          mov            %o0, %o3
59         wr              %g0, ASI_P, %asi
61         cmp             %o1, 15
62         bl,pn           %icc, 70f
63          andcc          %o0, 0x7, %g1
64         be,pt           %XCC, 2f
65          mov            8, %g2
66         sub             %g2, %g1, %g1
67         sub             %o1, %g1, %o1
68 1:      stba            %o2, [%o0 + 0x00] %asi
69         subcc           %g1, 1, %g1
70         bne,pt          %XCC, 1b
71          add            %o0, 1, %o0
72 2:      cmp             %o1, 128
73         bl,pn           %icc, 60f
74          andcc          %o0, (64 - 1), %g1
75         be,pt           %XCC, 40f
76          mov            64, %g2
77         sub             %g2, %g1, %g1
78         sub             %o1, %g1, %o1
79 1:      stxa            %o2, [%o0 + 0x00] %asi
80         subcc           %g1, 8, %g1
81         bne,pt          %XCC, 1b
82          add            %o0, 8, %o0
84 40:
85         wr              %g0, ASI_BLK_INIT_QUAD_LDD_P, %asi
86         andn            %o1, (64 - 1), %g1
87         sub             %o1, %g1, %o1
88 50:
89         stxa            %o2, [%o0 + 0x00] %asi
90         stxa            %o2, [%o0 + 0x08] %asi
91         stxa            %o2, [%o0 + 0x10] %asi
92         stxa            %o2, [%o0 + 0x18] %asi
93         stxa            %o2, [%o0 + 0x20] %asi
94         stxa            %o2, [%o0 + 0x28] %asi
95         stxa            %o2, [%o0 + 0x30] %asi
96         stxa            %o2, [%o0 + 0x38] %asi
97         subcc           %g1, 64, %g1
98         bne,pt          %XCC, 50b
99          add            %o0, 64, %o0
101         wr              %g0, ASI_P, %asi
102         brz,pn          %o1, 80f
104          andncc         %o1, 0x7, %g1
105         be,pn           %XCC, 2f
106          sub            %o1, %g1, %o1
107 1:      stxa            %o2, [%o0 + 0x00] %asi
108         subcc           %g1, 8, %g1
109         bne,pt          %XCC, 1b
110          add            %o0, 8, %o0
111 2:      brz,pt          %o1, 80f
112          nop
115 1:      stba            %o2, [%o0 + 0x00] %asi
116         subcc           %o1, 1, %o1
117         bne,pt          %icc, 1b
118          add            %o0, 1, %o0
120         /* fallthrough */
123         wr              %g0, ASI_PNF, %asi
126         retl
127          mov            %o3, %o0
128 END(__bzero)
130 libc_hidden_builtin_def (memset)
131 weak_alias (__bzero, bzero)