2 * Copyright (C) 2013, 2014-2015, 2017, 2022 Synopsys, Inc. (www.synopsys.com)
3 * Copyright (C) 2007 ARC International (UK) LTD
5 * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
12 #if defined(__ARC700__)
13 #define SMALL 7 /* Must be at least 6 to deal with alignment/loop issues. */
34 .Laligned: ; This code address should be aligned for speed.
52 #elif defined(__ARCHS__)
53 #ifdef DONT_USE_PREALLOC
54 #define PREWRITE(A,B) prefetchw [(A),(B)]
56 #define PREWRITE(A,B) prealloc [(A),(B)]
59 prefetchw [r0] ; Prefetch the write location
63 mov r3, r0 ; don't clobber ret val
66 brls.d.nt r2, 8, .Lsmallchunk
71 lpnz @.Laligndestination
77 ;;; Destination is aligned
91 ;;; Convert len to Dwords, unfold x8
92 lsr.f lp_count, lp_count, 6
95 PREWRITE(r3, 64) ;Prefetch the next write location
96 #if defined(__LL64__) || defined(__ARC_LL64__)
125 lsr.f lp_count, r2, 5 ;Last remaining max 124 bytes
128 prefetchw [r3, 32] ;Prefetch the next write location
129 #if defined(__LL64__) || defined(__ARC_LL64__)
146 and.f lp_count, r2, 0x1F ;Last remaining 31 bytes
155 #elif defined(__ARC64_ARCH32__)
156 ;; Based on Synopsys code from newlib's arc64/memset.S
158 ;; Assemble the bytes to 32bit words
159 bmsk_s r1, r1, 7 ; treat it like unsigned char
166 lsr.f r5, r2, 4 ; counter for 16-byte chunks
167 beq.d @.L_write_15_bytes
168 mov r4, r0 ; work on a copy of "r0"
171 #if defined(__ARC64_LL64__)
174 dbnz r5, @.L_write_16_bytes
179 dbnz.d r5, @.L_write_16_bytes
201 #error "Unsupported ARC CPU type"
205 libc_hidden_def(memset)