2019-05-29 07:12:41 -07:00
/* SPDX-License-Identifier: GPL-2.0-only */
2011-10-31 18:48:07 -05:00
/ *
* User s t r i n g l e n g t h f u n c t i o n s f o r k e r n e l
*
2012-09-19 16:22:02 -05:00
* Copyright ( c ) 2 0 1 0 - 2 0 1 1 , T h e L i n u x F o u n d a t i o n . A l l r i g h t s r e s e r v e d .
2011-10-31 18:48:07 -05:00
* /
# define i s r c r0
# define m a x r1 / * D o n o t c h a n g e ! * /
# define e n d r2
# define t m p1 r3
# define o b o r6 / * o f f - b y - o n e * /
# define s t a r t r7
# define m o d8 r8
# define d b u f r15 : 1 4
# define d c m p r13 : 1 2
/ *
* The v e c t o r m a s k v e r s i o n o f t h i s t u r n e d o u t * r e a l l y * b a d l y .
* The h a r d w a r e l o o p v e r s i o n a l s o t u r n e d o u t * r e a l l y * b a d l y .
* Seems s t r a i g h t p o i n t e r a r i t h m e t i c b a s i c a l l y w i n s h e r e .
* /
# define f n a m e _ _ s t r n l e n _ u s e r
.text
.global fname
.type fname, @function
.p2align 5 /* why? */
fname :
{
mod8 = a n d ( i s r c ,#7 ) ;
end = a d d ( i s r c ,m a x ) ;
start = i s r c ;
}
{
P0 = c m p . e q ( m o d8 ,#0 ) ;
mod8 = a n d ( e n d ,#7 ) ;
dcmp = #0 ;
if ( P 0 . n e w ) j u m p : t d w _ l o o p ; /* fire up the oven */
}
alignment_loop :
fail_1 : {
tmp1 = m e m b ( s t a r t + + #1 ) ;
}
{
P0 = c m p . e q ( t m p1 ,#0 ) ;
if ( P 0 . n e w ) j u m p : n t e x i t _ f o u n d ;
P1 = c m p . g t u ( e n d ,s t a r t ) ;
mod8 = a n d ( s t a r t ,#7 ) ;
}
{
if ( ! P 1 ) j u m p e x i t _ e r r o r ; /* hit the end */
P0 = c m p . e q ( m o d8 ,#0 ) ;
}
{
if ( ! P 0 ) j u m p a l i g n m e n t _ l o o p ;
}
dw_loop :
fail_2 : {
dbuf = m e m d ( s t a r t ) ;
obo = a d d ( s t a r t ,#1 ) ;
}
{
P0 = v c m p b . e q ( d b u f ,d c m p ) ;
}
{
tmp1 = P 0 ;
P0 = c m p . g t u ( e n d ,s t a r t ) ;
}
{
tmp1 = c t 0 ( t m p1 ) ;
mod8 = a n d ( e n d ,#7 ) ;
if ( ! P 0 ) j u m p e n d _ c h e c k ;
}
{
P0 = c m p . e q ( t m p1 ,#32 ) ;
if ( ! P 0 . n e w ) j u m p : n t e x i t _ f o u n d ;
if ( ! P 0 . n e w ) s t a r t = a d d ( o b o ,t m p1 ) ;
}
{
start = a d d ( s t a r t ,#8 ) ;
jump d w _ l o o p ;
} /* might be nice to combine these jumps... */
end_check :
{
P0 = c m p . g t ( t m p1 ,m o d8 ) ;
if ( P 0 . n e w ) j u m p : n t e x i t _ e r r o r ; /* neverfound! */
start = a d d ( o b o ,t m p1 ) ;
}
exit_found :
{
R0 = s u b ( s t a r t ,i s r c ) ;
jumpr R 3 1 ;
}
exit_error :
{
R0 = a d d ( m a x ,#1 ) ;
jumpr R 3 1 ;
}
/* Uh, what does the "fixup" return here? */
.falign
fix_1 :
{
R0 = #0 ;
jumpr R 3 1 ;
}
.size fname,. - f n a m e
.section _ _ ex_ t a b l e ," a "
.long fail_ 1 ,f i x _ 1
.long fail_ 2 ,f i x _ 1
.previous