]> sourceware.org Git - newlib-cygwin.git/blame - newlib/libc/machine/arc/strcpy-bs.S
arc: libc: Add support of 16-entry register file
[newlib-cygwin.git] / newlib / libc / machine / arc / strcpy-bs.S
CommitLineData
c0a99f02 1/*
d85bb55f 2 Copyright (c) 2015-2024, Synopsys, Inc. All rights reserved.
c0a99f02
AK
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6
7 1) Redistributions of source code must retain the above copyright notice,
8 this list of conditions and the following disclaimer.
9
10 2) Redistributions in binary form must reproduce the above copyright notice,
11 this list of conditions and the following disclaimer in the documentation
12 and/or other materials provided with the distribution.
13
14 3) Neither the name of the Synopsys, Inc., nor the names of its contributors
15 may be used to endorse or promote products derived from this software
16 without specific prior written permission.
17
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 POSSIBILITY OF SUCH DAMAGE.
29*/
30
31/* This implementation is optimized for performance. For code size a generic
32 implementation of this function from newlib/libc/string/strcpy.c will be
33 used. */
d85bb55f
CZ
34#if !defined (__OPTIMIZE_SIZE__) && !defined (PREFER_SIZE_OVER_SPEED) \
35 && !defined (__ARC_RF16__)
c0a99f02
AK
36
37#include "asm.h"
38
06537f05
AK
39#if (defined (__ARC700__) || defined (__ARCEM__) || defined (__ARCHS__)) \
40 && defined (__ARC_BARREL_SHIFTER__)
c0a99f02
AK
41
42/* If dst and src are 4 byte aligned, copy 8 bytes at a time.
43 If the src is 4, but not 8 byte aligned, we first read 4 bytes to get
44 it 8 byte aligned. Thus, we can do a little read-ahead, without
45 dereferencing a cache line that we should not touch.
46 Note that short and long instructions have been scheduled to avoid
47 branch stalls.
48 The beq_s to r3z could be made unaligned & long to avoid a stall
49 there, but the it is not likely to be taken often, and it
50 would also be likey to cost an unaligned mispredict at the next call. */
51
52ENTRY (strcpy)
53 or r2,r0,r1
54 bmsk_s r2,r2,1
55 brne.d r2,0,charloop
56 mov_s r10,r0
57 ld_s r3,[r1,0]
58 mov r8,0x01010101
59 bbit0.d r1,2,loop_start
60 ror r12,r8
61 sub r2,r3,r8
62 bic_s r2,r2,r3
63 tst_s r2,r12
64 bne_l r3z
65 mov_s r4,r3
66 .balign 4
67loop:
68 ld.a r3,[r1,4]
69 st.ab r4,[r10,4]
70loop_start:
71 ld.a r4,[r1,4]
72 sub r2,r3,r8
73 bic_s r2,r2,r3
74 tst_l r2,r12
75 bne_l r3z
76 st.ab r3,[r10,4]
77 sub r2,r4,r8
78 bic r2,r2,r4
79 tst_l r2,r12
80 beq_l loop
81 mov_s r3,r4
82#ifdef __LITTLE_ENDIAN__
83r3z: bmsk.f r1,r3,7
84 lsr_s r3,r3,8
85#else
86r3z: lsr.f r1,r3,24
87 asl_s r3,r3,8
88#endif
89 bne.d r3z
90 stb.ab r1,[r10,1]
91 j_s [blink]
92
93 .balign 4
94charloop:
95 ldb.ab r3,[r1,1]
96
97
98 brne.d r3,0,charloop
99 stb.ab r3,[r10,1]
100 j [blink]
101ENDFUNC (strcpy)
06537f05 102#endif /* (__ARC700__ || __ARCEM__ || __ARCHS__) && __ARC_BARREL_SHIFTER__ */
c0a99f02
AK
103
104#endif /* !__OPTIMIZE_SIZE__ && !PREFER_SIZE_OVER_SPEED */
This page took 0.100116 seconds and 5 git commands to generate.