2019-06-04 10:11:33 +02:00
/* SPDX-License-Identifier: GPL-2.0-only */
2013-01-18 15:12:18 +05:30
/ *
* Copyright ( C ) 2 0 0 4 , 2 0 0 7 - 2 0 1 0 , 2 0 1 1 - 2 0 1 2 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 )
* /
2014-02-07 13:47:43 +05:30
# include < l i n u x / l i n k a g e . h >
2013-01-18 15:12:18 +05:30
# ifdef _ _ L I T T L E _ E N D I A N _ _
# define W O R D 2 r2
# define S H I F T r3
# else / * B I G E N D I A N * /
# define W O R D 2 r3
# define S H I F T r2
# endif
2016-09-19 16:42:25 -07:00
ENTRY_ C F I ( m e m c m p )
2013-01-18 15:12:18 +05:30
or r12 ,r0 ,r1
asl_ s r12 ,r12 ,3 0
sub r3 ,r2 ,1
brls r2 ,r12 ,. L b y t e w i s e
ld r4 ,[ r0 ,0 ]
ld r5 ,[ r1 ,0 ]
lsr. f l p _ c o u n t ,r3 ,3
2013-10-07 18:10:08 +05:30
# ifdef C O N F I G _ I S A _ A R C V 2
/ * In A R C v2 a b r a n c h c a n ' t b e t h e l a s t i n s t r u c t i o n i n a z e r o o v e r h e a d
* loop.
* So w e m o v e t h e b r a n c h t o t h e s t a r t o f t h e l o o p , d u p l i c a t e i t
* after t h e e n d , a n d s e t u p r12 s o t h a t t h e b r a n c h i s n ' t t a k e n
* initially.
* /
mov_ s r12 ,W O R D 2
lpne . L o o p _ e n d
brne W O R D 2 ,r12 ,. L o d d
ld W O R D 2 ,[ r0 ,4 ]
# else
2013-01-18 15:12:18 +05:30
lpne . L o o p _ e n d
ld_ s W O R D 2 ,[ r0 ,4 ]
2013-10-07 18:10:08 +05:30
# endif
2013-01-18 15:12:18 +05:30
ld_ s r12 ,[ r1 ,4 ]
brne r4 ,r5 ,. L e v e n
ld. a r4 ,[ r0 ,8 ]
ld. a r5 ,[ r1 ,8 ]
2013-10-07 18:10:08 +05:30
# ifdef C O N F I G _ I S A _ A R C V 2
.Loop_end :
brne W O R D 2 ,r12 ,. L o d d
# else
2013-01-18 15:12:18 +05:30
brne W O R D 2 ,r12 ,. L o d d
.Loop_end :
2013-10-07 18:10:08 +05:30
# endif
2013-01-18 15:12:18 +05:30
asl_ s S H I F T ,S H I F T ,3
bhs_ s . L a s t _ c m p
brne r4 ,r5 ,. L e v e n
ld r4 ,[ r0 ,4 ]
ld r5 ,[ r1 ,4 ]
# ifdef _ _ L I T T L E _ E N D I A N _ _
nop_ s
; one more load latency cycle
.Last_cmp :
xor r0 ,r4 ,r5
bset r0 ,r0 ,S H I F T
sub_ s r1 ,r0 ,1
bic_ s r1 ,r1 ,r0
norm r1 ,r1
b. d . L e v e n _ c m p
and r1 ,r1 ,2 4
.Leven :
xor r0 ,r4 ,r5
sub_ s r1 ,r0 ,1
bic_ s r1 ,r1 ,r0
norm r1 ,r1
; slow track insn
and r1 ,r1 ,2 4
.Leven_cmp :
asl r2 ,r4 ,r1
asl r12 ,r5 ,r1
lsr_ s r2 ,r2 ,1
lsr_ s r12 ,r12 ,1
j_ s . d [ b l i n k ]
sub r0 ,r2 ,r12
.balign 4
.Lodd :
xor r0 ,W O R D 2 ,r12
sub_ s r1 ,r0 ,1
bic_ s r1 ,r1 ,r0
norm r1 ,r1
; slow track insn
and r1 ,r1 ,2 4
asl_ s r2 ,r2 ,r1
asl_ s r12 ,r12 ,r1
lsr_ s r2 ,r2 ,1
lsr_ s r12 ,r12 ,1
j_ s . d [ b l i n k ]
sub r0 ,r2 ,r12
# else / * B I G E N D I A N * /
.Last_cmp :
neg_ s S H I F T ,S H I F T
lsr r4 ,r4 ,S H I F T
lsr r5 ,r5 ,S H I F T
; slow track insn
.Leven :
sub. f r0 ,r4 ,r5
mov. n e r0 ,1
j_ s . d [ b l i n k ]
bset. c s r0 ,r0 ,3 1
.Lodd :
cmp_ s W O R D 2 ,r12
mov_ s r0 ,1
j_ s . d [ b l i n k ]
bset. c s r0 ,r0 ,3 1
# endif / * E N D I A N * /
.balign 4
.Lbytewise :
breq r2 ,0 ,. L n i l
ldb r4 ,[ r0 ,0 ]
ldb r5 ,[ r1 ,0 ]
lsr. f l p _ c o u n t ,r3
2013-10-07 18:10:08 +05:30
# ifdef C O N F I G _ I S A _ A R C V 2
mov r12 ,r3
2013-01-18 15:12:18 +05:30
lpne . L b y t e _ e n d
2013-10-07 18:10:08 +05:30
brne r3 ,r12 ,. L b y t e _ o d d
# else
lpne . L b y t e _ e n d
# endif
2013-01-18 15:12:18 +05:30
ldb_ s r3 ,[ r0 ,1 ]
ldb r12 ,[ r1 ,1 ]
brne r4 ,r5 ,. L b y t e _ e v e n
ldb. a r4 ,[ r0 ,2 ]
ldb. a r5 ,[ r1 ,2 ]
2013-10-07 18:10:08 +05:30
# ifdef C O N F I G _ I S A _ A R C V 2
.Lbyte_end :
brne r3 ,r12 ,. L b y t e _ o d d
# else
2013-01-18 15:12:18 +05:30
brne r3 ,r12 ,. L b y t e _ o d d
.Lbyte_end :
2013-10-07 18:10:08 +05:30
# endif
2013-01-18 15:12:18 +05:30
bcc . L b y t e _ e v e n
brne r4 ,r5 ,. L b y t e _ e v e n
ldb_ s r3 ,[ r0 ,1 ]
ldb_ s r12 ,[ r1 ,1 ]
.Lbyte_odd :
j_ s . d [ b l i n k ]
sub r0 ,r3 ,r12
.Lbyte_even :
j_ s . d [ b l i n k ]
sub r0 ,r4 ,r5
.Lnil :
j_ s . d [ b l i n k ]
mov r0 ,0
2016-09-19 16:42:25 -07:00
END_ C F I ( m e m c m p )