xref: /linux/arch/arc/lib/memset.S (revision e58e871becec2d3b04ed91c0c16fe8deac9c9dfa)
1/*
2 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#include <linux/linkage.h>
10
11#define SMALL	7 /* Must be at least 6 to deal with alignment/loop issues.  */
12
13ENTRY_CFI(memset)
14	mov_s	r4,r0
15	or	r12,r0,r2
16	bmsk.f	r12,r12,1
17	extb_s	r1,r1
18	asl	r3,r1,8
19	beq.d	.Laligned
20	or_s	r1,r1,r3
21	brls	r2,SMALL,.Ltiny
22	add	r3,r2,r0
23	stb	r1,[r3,-1]
24	bclr_s	r3,r3,0
25	stw	r1,[r3,-2]
26	bmsk.f	r12,r0,1
27	add_s	r2,r2,r12
28	sub.ne	r2,r2,4
29	stb.ab	r1,[r4,1]
30	and	r4,r4,-2
31	stw.ab	r1,[r4,2]
32	and	r4,r4,-4
33.Laligned:	; This code address should be aligned for speed.
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]
49END_CFI(memset)
50
51; memzero: @r0 = mem, @r1 = size_t
52; memset:  @r0 = mem, @r1 = char, @r2 = size_t
53
54ENTRY_CFI(memzero)
55    ; adjust bzero args to memset args
56    mov r2, r1
57    mov r1, 0
58    b  memset    ;tail call so need to tinker with blink
59END_CFI(memzero)
60