Remove powerpc64 bounded-pointers code.
[glibc.git] / sysdeps / powerpc / powerpc64 / strcpy.S
blob4c6fd3f9d7f062e3b9f892c153cf075020db8c1d
1 /* Optimized strcpy implementation for PowerPC64.
2    Copyright (C) 1997-2013 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
19 #include <sysdep.h>
21 /* See strlen.s for comments on how the end-of-string testing works.  */
23 /* char * [r3] strcpy (char *dest [r3], const char *src [r4])  */
25 EALIGN (strcpy, 4, 0)
26         CALL_MCOUNT 2
28 #define rTMP    r0
29 #define rRTN    r3      /* incoming DEST arg preserved as result */
30 #define rSRC    r4      /* pointer to previous word in src */
31 #define rDEST   r5      /* pointer to previous word in dest */
32 #define rWORD   r6      /* current word from src */
33 #define rFEFE   r7      /* constant 0xfefefefefefefeff (-0x0101010101010101) */
34 #define r7F7F   r8      /* constant 0x7f7f7f7f7f7f7f7f */
35 #define rNEG    r9      /* ~(word in s1 | 0x7f7f7f7f7f7f7f7f) */
36 #define rALT    r10     /* alternate word from src */
38         dcbt    0,rSRC
39         or      rTMP, rSRC, rRTN
40         clrldi. rTMP, rTMP, 61
41         addi    rDEST, rRTN, -8
42         dcbtst  0,rRTN
43         bne     L(unaligned)
45         lis     rFEFE, -0x101
46         lis     r7F7F, 0x7f7f
47         ld      rWORD, 0(rSRC)
48         addi    rFEFE, rFEFE, -0x101
49         addi    r7F7F, r7F7F, 0x7f7f
50         sldi    rTMP, rFEFE, 32
51         insrdi  r7F7F, r7F7F, 32, 0
52         add     rFEFE, rFEFE, rTMP
53         b       L(g2)
55 L(g0):  ldu     rALT, 8(rSRC)
56         stdu    rWORD, 8(rDEST)
57         add     rTMP, rFEFE, rALT
58         nor     rNEG, r7F7F, rALT
59         and.    rTMP, rTMP, rNEG
60         bne-    L(g1)
61         ldu     rWORD, 8(rSRC)
62         stdu    rALT, 8(rDEST)
63 L(g2):  add     rTMP, rFEFE, rWORD
64         nor     rNEG, r7F7F, rWORD
65         and.    rTMP, rTMP, rNEG
66         beq+    L(g0)
68         mr      rALT, rWORD
69 /* We've hit the end of the string.  Do the rest byte-by-byte.  */
70 L(g1):
71         extrdi. rTMP, rALT, 8, 0
72         stb     rTMP, 8(rDEST)
73         beqlr-
74         extrdi. rTMP, rALT, 8, 8
75         stb     rTMP, 9(rDEST)
76         beqlr-
77         extrdi. rTMP, rALT, 8, 16
78         stb     rTMP, 10(rDEST)
79         beqlr-
80         extrdi. rTMP, rALT, 8, 24
81         stb     rTMP, 11(rDEST)
82         beqlr-
83         extrdi. rTMP, rALT, 8, 32
84         stb     rTMP, 12(rDEST)
85         beqlr-
86         extrdi. rTMP, rALT, 8, 40
87         stb     rTMP, 13(rDEST)
88         beqlr-
89         extrdi. rTMP, rALT, 8, 48
90         stb     rTMP, 14(rDEST)
91         beqlr-
92         stb     rALT, 15(rDEST)
93         blr
95 /* Oh well.  In this case, we just do a byte-by-byte copy.  */
96         .align 4
97         nop
98 L(unaligned):
99         lbz     rWORD, 0(rSRC)
100         addi    rDEST, rRTN, -1
101         cmpwi   rWORD, 0
102         beq-    L(u2)
104 L(u0):  lbzu    rALT, 1(rSRC)
105         stbu    rWORD, 1(rDEST)
106         cmpwi   rALT, 0
107         beq-    L(u1)
108         nop             /* Let 601 load start of loop.  */
109         lbzu    rWORD, 1(rSRC)
110         stbu    rALT, 1(rDEST)
111         cmpwi   rWORD, 0
112         bne+    L(u0)
113 L(u2):  stb     rWORD, 1(rDEST)
114         blr
115 L(u1):  stb     rALT, 1(rDEST)
116         blr
118 END (strcpy)
119 libc_hidden_builtin_def (strcpy)