blob: 92d573c734b5b3d52dec2d8fcf6eb67cc96d16f6 [file] [log] [blame]
Claudiu Zissulescu1f7e3dc2014-11-21 13:39:25 +05301/*
2 * Copyright (C) 2014-15 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#undef PREALLOC_NOT_AVAIL
12
13#ifdef PREALLOC_NOT_AVAIL
14#define PREWRITE(A,B) prefetchw [(A),(B)]
15#else
16#define PREWRITE(A,B) prealloc [(A),(B)]
17#endif
18
19ENTRY(memset)
20 prefetchw [r0] ; Prefetch the write location
21 mov.f 0, r2
22;;; if size is zero
23 jz.d [blink]
24 mov r3, r0 ; don't clobber ret val
25
26;;; if length < 8
27 brls.d.nt r2, 8, .Lsmallchunk
28 mov.f lp_count,r2
29
30 and.f r4, r0, 0x03
31 rsub lp_count, r4, 4
32 lpnz @.Laligndestination
33 ;; LOOP BEGIN
34 stb.ab r1, [r3,1]
35 sub r2, r2, 1
36.Laligndestination:
37
38;;; Destination is aligned
39 and r1, r1, 0xFF
40 asl r4, r1, 8
41 or r4, r4, r1
42 asl r5, r4, 16
43 or r5, r5, r4
44 mov r4, r5
45
46 sub3 lp_count, r2, 8
47 cmp r2, 64
48 bmsk.hi r2, r2, 5
49 mov.ls lp_count, 0
50 add3.hi r2, r2, 8
51
52;;; Convert len to Dwords, unfold x8
53 lsr.f lp_count, lp_count, 6
54 lpnz @.Lset64bytes
55 ;; LOOP START
56 PREWRITE(r3, 64) ;Prefetch the next write location
57 std.ab r4, [r3, 8]
58 std.ab r4, [r3, 8]
59 std.ab r4, [r3, 8]
60 std.ab r4, [r3, 8]
61 std.ab r4, [r3, 8]
62 std.ab r4, [r3, 8]
63 std.ab r4, [r3, 8]
64 std.ab r4, [r3, 8]
65.Lset64bytes:
66
67 lsr.f lp_count, r2, 5 ;Last remaining max 124 bytes
68 lpnz .Lset32bytes
69 ;; LOOP START
70 prefetchw [r3, 32] ;Prefetch the next write location
71 std.ab r4, [r3, 8]
72 std.ab r4, [r3, 8]
73 std.ab r4, [r3, 8]
74 std.ab r4, [r3, 8]
75.Lset32bytes:
76
77 and.f lp_count, r2, 0x1F ;Last remaining 31 bytes
78.Lsmallchunk:
79 lpnz .Lcopy3bytes
80 ;; LOOP START
81 stb.ab r1, [r3, 1]
82.Lcopy3bytes:
83
84 j [blink]
85
86END(memset)
87
88ENTRY(memzero)
89 ; adjust bzero args to memset args
90 mov r2, r1
91 b.d memset ;tail call so need to tinker with blink
92 mov r1, 0
93END(memzero)