blob: 017e8af0e88036228d90d0500fc72b65791bdb58 [file] [log] [blame]
Alexey Brodkin22723822014-02-04 12:56:15 +04001/*
2 * Copyright (C) 2004, 2007-2010, 2011-2014 Synopsys, Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#define SMALL 7 /* Must be at least 6 to deal with alignment/loop issues. */
8
9.global memset
10.align 4
11memset:
12 mov_s %r4, %r0
13 or %r12, %r0, %r2
14 bmsk.f %r12, %r12, 1
15 extb_s %r1, %r1
16 asl %r3, %r1, 8
17 beq.d .Laligned
18 or_s %r1, %r1, %r3
19 brls %r2, SMALL, .Ltiny
20 add %r3, %r2, %r0
21 stb %r1, [%r3, -1]
22 bclr_s %r3, %r3, 0
23 stw %r1, [%r3, -2]
24 bmsk.f %r12, %r0, 1
25 add_s %r2, %r2, %r12
26 sub.ne %r2, %r2, 4
27 stb.ab %r1, [%r4, 1]
28 and %r4, %r4, -2
29 stw.ab %r1, [%r4, 2]
30 and %r4, %r4, -4
31
32 .balign 4
33.Laligned:
34 asl %r3, %r1, 16
35 lsr.f %lp_count, %r2, 2
36 or_s %r1, %r1, %r3
37 lpne .Loop_end
38 st.ab %r1, [%r4, 4]
39.Loop_end:
40 j_s [%blink]
41
42 .balign 4
43.Ltiny:
44 mov.f %lp_count, %r2
45 lpne .Ltiny_end
46 stb.ab %r1, [%r4, 1]
47.Ltiny_end:
48 j_s [%blink]
49
50/*
51 * memzero: @r0 = mem, @r1 = size_t
52 * memset: @r0 = mem, @r1 = char, @r2 = size_t
53 */
54
55.global memzero
56.align 4
57memzero:
58 /* adjust bzero args to memset args */
59 mov %r2, %r1
60 mov %r1, 0
61 /* tail call so need to tinker with blink */
62 b memset