2005-04-16 15:20:36 -07:00
/ *
* arch/ a l p h a / l i b / e v6 - c l e a r _ u s e r . S
* 2 1 2 6 4 version c o n t r i b u t e d b y R i c k G o r t o n < r i c k . g o r t o n @alpha-processor.com>
*
* Zero u s e r s p a c e , h a n d l i n g e x c e p t i o n s a s w e g o .
*
* We h a v e t o m a k e s u r e t h a t $ 0 i s a l w a y s u p - t o - d a t e a n d c o n t a i n s t h e
* right " b y t e s l e f t t o z e r o " v a l u e ( a n d t h a t i t i s u p d a t e d o n l y _ a f t e r _
* a s u c c e s s f u l c o p y ) . T h e r e i s a l s o s o m e r a t h e r m i n o r e x c e p t i o n s e t u p
* stuff.
*
* NOTE! T h i s i s n o t d i r e c t l y C - c a l l a b l e , b e c a u s e t h e c a l l i n g s e m a n t i c s
* are d i f f e r e n t :
*
* Inputs :
* length i n $ 0
* destination a d d r e s s i n $ 6
* exception p o i n t e r i n $ 7
* return a d d r e s s i n $ 2 8 ( e x c e p t i o n s e x p e c t i t t h e r e )
*
* Outputs :
* bytes l e f t t o c o p y i n $ 0
*
* Clobbers :
* $ 1 , $ 2 , $ 3 , $ 4 , $ 5 , $ 6
*
* Much o f t h e i n f o r m a t i o n a b o u t 2 1 2 6 4 s c h e d u l i n g / c o d i n g c o m e s f r o m :
* Compiler W r i t e r ' s G u i d e f o r t h e A l p h a 2 1 2 6 4
* abbreviated a s ' C W G ' i n o t h e r c o m m e n t s h e r e
* ftp. d i g i t a l . c o m / p u b / D i g i t a l / i n f o / s e m i c o n d u c t o r / l i t e r a t u r e / d s c - l i b r a r y . h t m l
* Scheduling n o t a t i o n :
* E - e i t h e r c l u s t e r
* U - u p p e r s u b c l u s t e r ; U0 - subcluster U0; U1 - subcluster U1
* L - l o w e r s u b c l u s t e r ; L0 - subcluster L0; L1 - subcluster L1
* Try n o t t o c h a n g e t h e a c t u a l a l g o r i t h m i f p o s s i b l e f o r c o n s i s t e n c y .
* Determining a c t u a l s t a l l s ( o t h e r t h a n s l o t t i n g ) d o e s n ' t a p p e a r t o b e e a s y t o d o .
* From p e r u s i n g t h e s o u r c e c o d e c o n t e x t w h e r e t h i s r o u t i n e i s c a l l e d , i t i s
* a f a i r a s s u m p t i o n t h a t s i g n i f i c a n t f r a c t i o n s o f e n t i r e p a g e s a r e z e r o e d , s o
* it' s g o i n g t o b e w o r t h t h e e f f o r t t o h a n d - u n r o l l a b i g l o o p , a n d u s e w h64 .
* ASSUMPTION :
* The b e l i e v e d p u r p o s e o f o n l y u p d a t i n g $ 0 a f t e r a s t o r e i s t h a t a s i g n a l
* may c o m e a l o n g d u r i n g t h e e x e c u t i o n o f t h i s c h u n k o f c o d e , a n d w e d o n ' t
* want t o l e a v e a h o l e ( a n d w e a l s o w a n t t o a v o i d r e p e a t i n g l o t s o f w o r k )
* /
2016-01-11 09:51:29 -05:00
# include < a s m / e x p o r t . h >
2005-04-16 15:20:36 -07:00
/* Allow an exception for an insn; exit if we get one. */
# define E X ( x ,y . . . ) \
99 : x,## y ; \
.section _ _ ex_ t a b l e ," a " ; \
.long 99b - . ; \
lda $ 3 1 , $ e x c e p t i o n - 9 9 b ( $ 3 1 ) ; \
.previous
.set noat
.set noreorder
.align 4
.globl __do_clear_user
.ent __do_clear_user
.frame $ 3 0 , 0 , $ 2 8
.prologue 0
# Pipeline i n f o : S l o t t i n g & C o m m e n t s
__do_clear_user :
and $ 6 , 7 , $ 4 # . . E . . . . : f i n d d e s t h e a d m i s a l i g n m e n t
beq $ 0 , $ z e r o l e n g t h # U . . . . . . : U L U L
addq $ 0 , $ 4 , $ 1 # . . . . . . E : b i a s c o u n t e r
and $ 1 , 7 , $ 2 # . . . . E . . : n u m b e r o f m i s a l i g n e d b y t e s i n t a i l
# Note - w e n e v e r a c t u a l l y u s e $ 2 , s o t h i s i s a m o o t c o m p u t a t i o n
# and w e c a n r e w r i t e t h i s l a t e r . . .
srl $ 1 , 3 , $ 1 # . . E . . . . : n u m b e r o f q u a d w o r d s t o c l e a r
beq $ 4 , $ h e a d a l i g n # U . . . . . . : U L U L
/ *
* Head i s n o t a l i g n e d . W r i t e ( 8 - $ 4 ) b y t e s t o h e a d o f d e s t i n a t i o n
* This m e a n s $ 6 i s k n o w n t o b e m i s a l i g n e d
* /
EX( l d q _ u $ 5 , 0 ( $ 6 ) ) # . . . . . . L : l o a d d s t w o r d t o m a s k b a c k i n
beq $ 1 , $ o n e b y t e # . . . . U . . : s u b - w o r d s t o r e ?
mskql $ 5 , $ 6 , $ 5 # . . U . . . . : t a k e c a r e o f m i s a l i g n e d h e a d
addq $ 6 , 8 , $ 6 # E . . . . . . : L U U L
EX( s t q _ u $ 5 , - 8 ( $ 6 ) ) # . . . . . . L :
subq $ 1 , 1 , $ 1 # . . . . E . . :
addq $ 0 , $ 4 , $ 0 # . . E . . . . : b y t e s l e f t - = 8 - m i s a l i g n m e n t
subq $ 0 , 8 , $ 0 # E . . . . . . : U L U L
.align 4
/ *
* ( The . a l i g n d i r e c t i v e o u g h t t o b e a m o o t p o i n t )
* values u p o n i n i t i a l e n t r y t o t h e l o o p
* $ 1 is n u m b e r o f q u a d w o r d s t o c l e a r ( z e r o i s a v a l i d v a l u e )
* $ 2 is n u m b e r o f t r a i l i n g b y t e s ( 0 . . 7 ) ( $ 2 n e v e r u s e d . . . )
* $ 6 is k n o w n t o b e a l i g n e d 0 m o d8
* /
$ headalign :
subq $ 1 , 1 6 , $ 4 # . . . . . . E : I f < 16 , w e c a n n o t u s e t h e h u g e l o o p
and $ 6 , 0 x3 f , $ 2 # . . . . E . . : F o r w a r d w o r k f o r h u g e l o o p
subq $ 2 , 0 x40 , $ 3 # . . E . . . . : b i a s c o u n t e r ( h u g e l o o p )
blt $ 4 , $ t r a i l q u a d # U . . . . . . : U L U L
/ *
* We k n o w t h a t w e ' r e g o i n g t o d o a t l e a s t 1 6 q u a d s , w h i c h m e a n s w e a r e
* going t o b e a b l e t o u s e t h e l a r g e b l o c k c l e a r l o o p a t l e a s t o n c e .
* Figure o u t h o w m a n y q u a d s w e n e e d t o c l e a r b e f o r e w e a r e 0 m o d64 a l i g n e d
* so w e c a n u s e t h e w h64 i n s t r u c t i o n .
* /
nop # . . . . . . E
nop # . . . . E . .
nop # . . E . . . .
beq $ 3 , $ b i g a l i g n # U . . . . . . : U L U L : A l i g n e d 0 m o d64
$ alignmod64 :
EX( s t q _ u $ 3 1 , 0 ( $ 6 ) ) # . . . . . . L
addq $ 3 , 8 , $ 3 # . . . . E . .
subq $ 0 , 8 , $ 0 # . . E . . . .
nop # E . . . . . . : U L U L
nop # . . . . . . E
subq $ 1 , 1 , $ 1 # . . . . E . .
addq $ 6 , 8 , $ 6 # . . E . . . .
blt $ 3 , $ a l i g n m o d64 # U . . . . . . : U L U L
$ bigalign :
/ *
* $ 0 is t h e n u m b e r o f b y t e s l e f t
* $ 1 is t h e n u m b e r o f q u a d s l e f t
* $ 6 is a l i g n e d 0 m o d64
* we k n o w t h a t w e ' l l b e t a k i n g a m i n i m u m o f o n e t r i p t h r o u g h
* CWG S e c t i o n 3 . 7 . 6 : d o n o t e x p e c t a s u s t a i n e d s t o r e r a t e o f > 1 / c y c l e
* We a r e _ n o t _ g o i n g t o u p d a t e $ 0 a f t e r e v e r y s i n g l e s t o r e . T h a t
* would b e s i l l y , b e c a u s e t h e r e w i l l b e c r o s s - c l u s t e r d e p e n d e n c i e s
* no m a t t e r h o w t h e c o d e i s s c h e d u l e d . B y d o i n g i t i n s l i g h t l y
* staggered f a s h i o n , w e c a n s t i l l d o t h i s l o o p i n 5 f e t c h e s
* The w o r s e c a s e w i l l b e d o i n g t w o e x t r a q u a d s i n s o m e f u t u r e e x e c u t i o n ,
* in t h e e v e n t o f a n i n t e r r u p t e d c l e a r .
* Assumes t h e w h64 n e e d s t o b e f o r 2 t r i p s t h r o u g h t h e l o o p i n t h e f u t u r e
* The w h64 i s i s s u e d o n f o r t h e s t a r t i n g d e s t i n a t i o n a d d r e s s f o r t r i p + 2
* through t h e l o o p , a n d i f t h e r e a r e l e s s t h a n t w o t r i p s l e f t , t h e t a r g e t
* address w i l l b e f o r t h e c u r r e n t t r i p .
* /
nop # E :
nop # E :
nop # E :
bis $ 6 ,$ 6 ,$ 3 # E : U L U L : I n i t i a l w h 64 a d d r e s s i s d e s t
/* This might actually help for the current trip... */
$ do_wh64 :
wh6 4 ( $ 3 ) # . . . . . . L 1 : m e m o r y s u b s y s t e m h i n t
subq $ 1 , 1 6 , $ 4 # . . . . E . . : F o r w a r d c a l c u l a t i o n - r e p e a t t h e l o o p ?
EX( s t q _ u $ 3 1 , 0 ( $ 6 ) ) # . . L . . . .
subq $ 0 , 8 , $ 0 # E . . . . . . : U L U L
addq $ 6 , 1 2 8 , $ 3 # E : T a r g e t a d d r e s s o f w h 64
EX( s t q _ u $ 3 1 , 8 ( $ 6 ) ) # L :
EX( s t q _ u $ 3 1 , 1 6 ( $ 6 ) ) # L :
subq $ 0 , 1 6 , $ 0 # E : U L L U
nop # E :
EX( s t q _ u $ 3 1 , 2 4 ( $ 6 ) ) # L :
EX( s t q _ u $ 3 1 , 3 2 ( $ 6 ) ) # L :
subq $ 0 , 1 6 8 , $ 5 # E : U L L U : t w o t r i p s t h r o u g h t h e l o o p l e f t ?
/* 168 = 192 - 24, since we've already completed some stores */
subq $ 0 , 1 6 , $ 0 # E :
EX( s t q _ u $ 3 1 , 4 0 ( $ 6 ) ) # L :
EX( s t q _ u $ 3 1 , 4 8 ( $ 6 ) ) # L :
cmovlt $ 5 , $ 6 , $ 3 # E : U L L U : L a t e n c y 2 , e x t r a m a p p i n g c y c l e
subq $ 1 , 8 , $ 1 # E :
subq $ 0 , 1 6 , $ 0 # E :
EX( s t q _ u $ 3 1 , 5 6 ( $ 6 ) ) # L :
nop # E : U L U L
nop # E :
subq $ 0 , 8 , $ 0 # E :
addq $ 6 , 6 4 , $ 6 # E :
bge $ 4 , $ d o _ w h64 # U : U L U L
$ trailquad :
# zero t o 1 6 q u a d w o r d s l e f t t o s t o r e , p l u s a n y t r a i l i n g b y t e s
# $ 1 is t h e n u m b e r o f q u a d w o r d s l e f t t o g o .
#
nop # . . . . . . E
nop # . . . . E . .
nop # . . E . . . .
beq $ 1 , $ t r a i l b y t e s # U . . . . . . : U L U L : O n l y 0 . . 7 b y t e s t o g o
$ onequad :
EX( s t q _ u $ 3 1 , 0 ( $ 6 ) ) # . . . . . . L
subq $ 1 , 1 , $ 1 # . . . . E . .
subq $ 0 , 8 , $ 0 # . . E . . . .
nop # E . . . . . . : U L U L
nop # . . . . . . E
nop # . . . . E . .
addq $ 6 , 8 , $ 6 # . . E . . . .
bgt $ 1 , $ o n e q u a d # U . . . . . . : U L U L
# We h a v e a n u n k n o w n n u m b e r o f b y t e s l e f t t o g o .
$ trailbytes :
nop # . . . . . . E
nop # . . . . E . .
nop # . . E . . . .
beq $ 0 , $ z e r o l e n g t h # U . . . . . . : U L U L
# $ 0 contains t h e n u m b e r o f b y t e s l e f t t o c o p y ( 0 . . 3 1 )
# so w e w i l l u s e $ 0 a s t h e l o o p c o u n t e r
# We k n o w f o r a f a c t t h a t $ 0 > 0 z e r o d u e t o p r e v i o u s c o n t e x t
$ onebyte :
EX( s t b $ 3 1 , 0 ( $ 6 ) ) # . . . . . . L
subq $ 0 , 1 , $ 0 # . . . . E . . :
addq $ 6 , 1 , $ 6 # . . E . . . . :
bgt $ 0 , $ o n e b y t e # U . . . . . . : U L U L
$ zerolength :
$ exception : # Destination f o r e x c e p t i o n r e c o v e r y ( ? )
nop # . . . . . . E :
nop # . . . . E . . :
nop # . . E . . . . :
ret $ 3 1 , ( $ 2 8 ) , 1 # L 0 . . . . . . : L U L U
.end __do_clear_user
2016-01-11 09:51:29 -05:00
EXPORT_ S Y M B O L ( _ _ d o _ c l e a r _ u s e r )