2019-06-04 10:11:33 +02:00
/* SPDX-License-Identifier: GPL-2.0-only */
2014-11-21 13:39:25 +05:30
/ *
* Copyright ( C ) 2 0 1 4 - 1 5 S y n o p s y s , I n c . ( w w w . s y n o p s y s . c o m )
* /
# include < l i n u x / l i n k a g e . h >
2019-01-14 18:16:48 +03:00
# include < a s m / c a c h e . h >
2014-11-21 13:39:25 +05:30
2019-01-14 18:16:48 +03:00
/ *
* The m e m s e t i m p l e m e n t a t i o n b e l o w i s o p t i m i z e d t o u s e p r e f e t c h w a n d p r e a l l o c
* instruction i n c a s e o f C P U w i t h 6 4 B L 1 d a t a c a c h e l i n e ( L 1 _ C A C H E _ S H I F T = = 6 )
* If y o u w a n t t o i m p l e m e n t o p t i m i z e d m e m s e t f o r o t h e r p o s s i b l e L 1 d a t a c a c h e
* line l e n g t h s ( 3 2 B a n d 1 2 8 B ) y o u s h o u l d r e w r i t e c o d e c a r e f u l l y c h e c k i n g
* we d o n ' t c a l l a n y p r e f e t c h w / p r e a l l o c i n s t r u c t i o n f o r L 1 c a c h e l i n e s w h i c h
* don' t b e l o n g s t o m e m s e t a r e a .
* /
# if L 1 _ C A C H E _ S H I F T = = 6
.macro PREALLOC_INSTR reg, o f f
prealloc [ \ r e g , \ o f f ]
.endm
.macro PREFETCHW_INSTR reg, o f f
prefetchw [ \ r e g , \ o f f ]
.endm
# else
2019-04-08 16:04:38 +03:00
.macro PREALLOC_INSTR reg, o f f
2019-01-14 18:16:48 +03:00
.endm
2019-04-08 16:04:38 +03:00
.macro PREFETCHW_INSTR reg, o f f
2019-01-14 18:16:48 +03:00
.endm
# endif
2014-11-21 13:39:25 +05:30
2016-09-19 16:42:25 -07:00
ENTRY_ C F I ( m e m s e t )
2019-01-14 18:16:48 +03:00
PREFETCHW_ I N S T R r0 , 0 ; Prefetch the first write location
2014-11-21 13:39:25 +05:30
mov. f 0 , r2
;;; if size is zero
jz. d [ b l i n k ]
mov r3 , r0 ; don't clobber ret val
;;; if length < 8
brls. d . n t r2 , 8 , . L s m a l l c h u n k
mov. f l p _ c o u n t ,r2
and. f r4 , r0 , 0 x03
rsub l p _ c o u n t , r4 , 4
lpnz @.Laligndestination
;; LOOP BEGIN
stb. a b r1 , [ r3 ,1 ]
sub r2 , r2 , 1
.Laligndestination :
;;; Destination is aligned
and r1 , r1 , 0 x F F
asl r4 , r1 , 8
or r4 , r4 , r1
asl r5 , r4 , 1 6
or r5 , r5 , r4
mov r4 , r5
sub3 l p _ c o u n t , r2 , 8
cmp r2 , 6 4
bmsk. h i r2 , r2 , 5
mov. l s l p _ c o u n t , 0
add3 . h i r2 , r2 , 8
;;; Convert len to Dwords, unfold x8
lsr. f l p _ c o u n t , l p _ c o u n t , 6
2015-07-20 12:05:03 +03:00
2014-11-21 13:39:25 +05:30
lpnz @.Lset64bytes
;; LOOP START
2019-01-14 18:16:48 +03:00
PREALLOC_ I N S T R r3 , 6 4 ; alloc next line w/o fetching
2015-07-20 12:05:03 +03:00
# ifdef C O N F I G _ A R C _ H A S _ L L 6 4
2014-11-21 13:39:25 +05:30
std. a b r4 , [ r3 , 8 ]
std. a b r4 , [ r3 , 8 ]
std. a b r4 , [ r3 , 8 ]
std. a b r4 , [ r3 , 8 ]
std. a b r4 , [ r3 , 8 ]
std. a b r4 , [ r3 , 8 ]
std. a b r4 , [ r3 , 8 ]
std. a b r4 , [ r3 , 8 ]
2015-07-20 12:05:03 +03:00
# else
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
# endif
2014-11-21 13:39:25 +05:30
.Lset64bytes :
lsr. f l p _ c o u n t , r2 , 5 ;Last remaining max 124 bytes
lpnz . L s e t 3 2 b y t e s
;; LOOP START
2015-07-20 12:05:03 +03:00
# ifdef C O N F I G _ A R C _ H A S _ L L 6 4
2014-11-21 13:39:25 +05:30
std. a b r4 , [ r3 , 8 ]
std. a b r4 , [ r3 , 8 ]
std. a b r4 , [ r3 , 8 ]
std. a b r4 , [ r3 , 8 ]
2015-07-20 12:05:03 +03:00
# else
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
st. a b r4 , [ r3 , 4 ]
# endif
2014-11-21 13:39:25 +05:30
.Lset32bytes :
and. f l p _ c o u n t , r2 , 0 x1 F ;Last remaining 31 bytes
.Lsmallchunk :
lpnz . L c o p y 3 b y t e s
;; LOOP START
stb. a b r1 , [ r3 , 1 ]
.Lcopy3bytes :
j [ b l i n k ]
2016-09-19 16:42:25 -07:00
END_ C F I ( m e m s e t )
2014-11-21 13:39:25 +05:30
2016-09-19 16:42:25 -07:00
ENTRY_ C F I ( m e m z e r o )
2014-11-21 13:39:25 +05:30
; adjust bzero args to memset args
mov r2 , r1
b. d m e m s e t ;tail call so need to tinker with blink
mov r1 , 0
2016-09-19 16:42:25 -07:00
END_ C F I ( m e m z e r o )