2005-04-17 02:20:36 +04:00
/ *
* This f i l e i s s u b j e c t t o t h e t e r m s a n d c o n d i t i o n s o f t h e G N U G e n e r a l P u b l i c
* License. S e e t h e f i l e " C O P Y I N G " i n t h e m a i n d i r e c t o r y o f t h i s a r c h i v e
* for m o r e d e t a i l s .
*
* Copyright ( C ) 1 9 9 8 , 1 9 9 9 , 2 0 0 0 b y R a l f B a e c h l e
* Copyright ( C ) 1 9 9 9 , 2 0 0 0 S i l i c o n G r a p h i c s , I n c .
* /
# include < a s m / a s m . h >
2005-09-10 00:32:31 +04:00
# include < a s m / a s m - o f f s e t s . h >
2005-04-17 02:20:36 +04:00
# include < a s m / r e g d e f . h >
2006-12-17 18:07:40 +03:00
# if L O N G S I Z E = = 4
# define L O N G _ S _ L s w l
# define L O N G _ S _ R s w r
# else
# define L O N G _ S _ L s d l
# define L O N G _ S _ R s d r
# endif
2005-04-17 02:20:36 +04:00
# define E X ( i n s n ,r e g ,a d d r ,h a n d l e r ) \
9 : insn r e g , a d d r ; \
.section _ _ ex_ t a b l e ," a " ; \
PTR 9 b , h a n d l e r ; \
.previous
.macro f_fill64 dst, o f f s e t , v a l , f i x u p
EX( L O N G _ S , \ v a l , ( \ o f f s e t + 0 * L O N G S I Z E ) ( \ d s t ) , \ f i x u p )
EX( L O N G _ S , \ v a l , ( \ o f f s e t + 1 * L O N G S I Z E ) ( \ d s t ) , \ f i x u p )
EX( L O N G _ S , \ v a l , ( \ o f f s e t + 2 * L O N G S I Z E ) ( \ d s t ) , \ f i x u p )
EX( L O N G _ S , \ v a l , ( \ o f f s e t + 3 * L O N G S I Z E ) ( \ d s t ) , \ f i x u p )
EX( L O N G _ S , \ v a l , ( \ o f f s e t + 4 * L O N G S I Z E ) ( \ d s t ) , \ f i x u p )
EX( L O N G _ S , \ v a l , ( \ o f f s e t + 5 * L O N G S I Z E ) ( \ d s t ) , \ f i x u p )
EX( L O N G _ S , \ v a l , ( \ o f f s e t + 6 * L O N G S I Z E ) ( \ d s t ) , \ f i x u p )
EX( L O N G _ S , \ v a l , ( \ o f f s e t + 7 * L O N G S I Z E ) ( \ d s t ) , \ f i x u p )
2006-12-17 18:07:40 +03:00
# if L O N G S I Z E = = 4
2005-04-17 02:20:36 +04:00
EX( L O N G _ S , \ v a l , ( \ o f f s e t + 8 * L O N G S I Z E ) ( \ d s t ) , \ f i x u p )
EX( L O N G _ S , \ v a l , ( \ o f f s e t + 9 * L O N G S I Z E ) ( \ d s t ) , \ f i x u p )
EX( L O N G _ S , \ v a l , ( \ o f f s e t + 1 0 * L O N G S I Z E ) ( \ d s t ) , \ f i x u p )
EX( L O N G _ S , \ v a l , ( \ o f f s e t + 1 1 * L O N G S I Z E ) ( \ d s t ) , \ f i x u p )
EX( L O N G _ S , \ v a l , ( \ o f f s e t + 1 2 * L O N G S I Z E ) ( \ d s t ) , \ f i x u p )
EX( L O N G _ S , \ v a l , ( \ o f f s e t + 1 3 * L O N G S I Z E ) ( \ d s t ) , \ f i x u p )
EX( L O N G _ S , \ v a l , ( \ o f f s e t + 1 4 * L O N G S I Z E ) ( \ d s t ) , \ f i x u p )
EX( L O N G _ S , \ v a l , ( \ o f f s e t + 1 5 * L O N G S I Z E ) ( \ d s t ) , \ f i x u p )
2006-12-17 18:07:40 +03:00
# endif
2005-04-17 02:20:36 +04:00
.endm
/ *
* memset( v o i d * s , i n t c , s i z e _ t n )
*
* a0 : start o f a r e a t o c l e a r
* a1 : char t o f i l l w i t h
* a2 : size o f a r e a t o c l e a r
* /
.set noreorder
.align 5
LEAF( m e m s e t )
beqz a1 , 1 f
move v0 , a0 / * r e s u l t * /
andi a1 , 0 x f f / * s p r e a d f i l l w o r d * /
2006-12-17 18:07:40 +03:00
LONG_ S L L t 1 , a1 , 8
2005-04-17 02:20:36 +04:00
or a1 , t 1
2006-12-17 18:07:40 +03:00
LONG_ S L L t 1 , a1 , 1 6
# if L O N G S I Z E = = 8
or a1 , t 1
LONG_ S L L t 1 , a1 , 3 2
# endif
2005-04-17 02:20:36 +04:00
or a1 , t 1
1 :
FEXPORT( _ _ b z e r o )
sltiu t 0 , a2 , L O N G S I Z E / * v e r y s m a l l r e g i o n ? * /
bnez t 0 , s m a l l _ m e m s e t
andi t 0 , a0 , L O N G M A S K / * a l i g n e d ? * /
beqz t 0 , 1 f
PTR_ S U B U t 0 , L O N G S I Z E / * a l i g n m e n t i n b y t e s * /
# ifdef _ _ M I P S E B _ _
2006-12-17 18:07:40 +03:00
EX( L O N G _ S _ L , a1 , ( a0 ) , f i r s t _ f i x u p ) / * m a k e w o r d / d w o r d a l i g n e d * /
2005-04-17 02:20:36 +04:00
# endif
# ifdef _ _ M I P S E L _ _
2006-12-17 18:07:40 +03:00
EX( L O N G _ S _ R , a1 , ( a0 ) , f i r s t _ f i x u p ) / * m a k e w o r d / d w o r d a l i g n e d * /
2005-04-17 02:20:36 +04:00
# endif
PTR_ S U B U a0 , t 0 / * l o n g a l i g n p t r * /
PTR_ A D D U a2 , t 0 / * c o r r e c t s i z e * /
1 : ori t 1 , a2 , 0 x3 f / * # o f f u l l b l o c k s * /
xori t 1 , 0 x3 f
beqz t 1 , m e m s e t _ p a r t i a l / * n o b l o c k t o f i l l * /
2006-12-17 18:07:40 +03:00
andi t 0 , a2 , 0 x40 - L O N G S I Z E
2005-04-17 02:20:36 +04:00
PTR_ A D D U t 1 , a0 / * e n d a d d r e s s * /
.set reorder
1 : PTR_ A D D I U a0 , 6 4
f_ f i l l 6 4 a0 , - 6 4 , a1 , f w d _ f i x u p
bne t 1 , a0 , 1 b
.set noreorder
memset_partial :
PTR_ L A t 1 , 2 f / * w h e r e t o s t a r t * /
2006-12-17 18:07:40 +03:00
# if L O N G S I Z E = = 4
2005-04-17 02:20:36 +04:00
PTR_ S U B U t 1 , t 0
2006-12-17 18:07:40 +03:00
# else
.set noat
LONG_ S R L A T , t 0 , 1
PTR_ S U B U t 1 , A T
.set noat
# endif
2005-04-17 02:20:36 +04:00
jr t 1
PTR_ A D D U a0 , t 0 / * d e s t p t r * /
.set push
.set noreorder
.set nomacro
f_ f i l l 6 4 a0 , - 6 4 , a1 , p a r t i a l _ f i x u p / * . . . b u t f i r s t d o l o n g s . . . * /
2 : .set p o p
andi a2 , L O N G M A S K / * A t m o s t o n e l o n g t o g o * /
beqz a2 , 1 f
PTR_ A D D U a0 , a2 / * W h a t ' s l e f t * /
# ifdef _ _ M I P S E B _ _
2006-12-17 18:07:40 +03:00
EX( L O N G _ S _ R , a1 , - 1 ( a0 ) , l a s t _ f i x u p )
2005-04-17 02:20:36 +04:00
# endif
# ifdef _ _ M I P S E L _ _
2006-12-17 18:07:40 +03:00
EX( L O N G _ S _ L , a1 , - 1 ( a0 ) , l a s t _ f i x u p )
2005-04-17 02:20:36 +04:00
# endif
1 : jr r a
move a2 , z e r o
small_memset :
beqz a2 , 2 f
PTR_ A D D U t 1 , a0 , a2
1 : PTR_ A D D I U a0 , 1 / * f i l l b y t e w i s e * /
bne t 1 , a0 , 1 b
sb a1 , - 1 ( a0 )
2 : jr r a / * d o n e * /
move a2 , z e r o
END( m e m s e t )
first_fixup :
jr r a
nop
fwd_fixup :
PTR_ L t 0 , T I _ T A S K ( $ 2 8 )
LONG_ L t 0 , T H R E A D _ B U A D D R ( t 0 )
andi a2 , 0 x3 f
LONG_ A D D U a2 , t 1
jr r a
LONG_ S U B U a2 , t 0
partial_fixup :
PTR_ L t 0 , T I _ T A S K ( $ 2 8 )
LONG_ L t 0 , T H R E A D _ B U A D D R ( t 0 )
andi a2 , L O N G M A S K
LONG_ A D D U a2 , t 1
jr r a
LONG_ S U B U a2 , t 0
last_fixup :
jr r a
andi v1 , a2 , L O N G M A S K