2005-04-16 15:20:36 -07: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 .
2013-03-25 13:40:49 -05:00
* Copyright ( C ) 2 0 0 7 b y M a c i e j W . R o z y c k i
* Copyright ( C ) 2 0 1 1 , 2 0 1 2 M I P S T e c h n o l o g i e s , I n c .
2005-04-16 15:20:36 -07:00
* /
# include < a s m / a s m . h >
2005-09-09 22:32:31 +02:00
# include < a s m / a s m - o f f s e t s . h >
2005-04-16 15:20:36 -07:00
# include < a s m / r e g d e f . h >
2006-12-18 00:07:40 +09: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
2013-03-25 13:40:49 -05:00
# ifdef C O N F I G _ C P U _ M I C R O M I P S
# define S T O R S I Z E ( L O N G S I Z E * 2 )
# define S T O R M A S K ( S T O R S I Z E - 1 )
# define F I L L 6 4 R G t 8
# define F I L L P T R G t 7
# undef L O N G _ S
# define L O N G _ S L O N G _ S P
# else
# define S T O R S I Z E L O N G S I Z E
# define S T O R M A S K L O N G M A S K
# define F I L L 6 4 R G a1
# define F I L L P T R G t 0
# endif
2005-04-16 15:20:36 -07: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 ; \
2013-01-22 12:59:30 +01:00
.section _ _ ex_ t a b l e ," a " ; \
PTR 9 b , h a n d l e r ; \
2005-04-16 15:20:36 -07:00
.previous
.macro f_fill64 dst, o f f s e t , v a l , f i x u p
2013-03-25 13:40:49 -05:00
EX( L O N G _ S , \ v a l , ( \ o f f s e t + 0 * S T O R 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 * S T O R 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 * S T O R 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 * S T O R S I Z E ) ( \ d s t ) , \ f i x u p )
# if ( ( d e f i n e d ( C O N F I G _ C P U _ M I C R O M I P S ) & & ( L O N G S I Z E = = 4 ) ) | | ! d e f i n e d ( C O N F I G _ C P U _ M I C R O M I P S ) )
EX( L O N G _ S , \ v a l , ( \ o f f s e t + 4 * S T O R 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 * S T O R 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 * S T O R 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 * S T O R S I Z E ) ( \ d s t ) , \ f i x u p )
# endif
# if ( ! d e f i n e d ( C O N F I G _ C P U _ M I C R O M I P S ) & & ( L O N G S I Z E = = 4 ) )
EX( L O N G _ S , \ v a l , ( \ o f f s e t + 8 * S T O R 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 * S T O R 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 * S T O R 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 * S T O R 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 * S T O R 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 * S T O R 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 * S T O R 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 * S T O R S I Z E ) ( \ d s t ) , \ f i x u p )
2006-12-18 00:07:40 +09:00
# endif
2005-04-16 15:20:36 -07: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-18 00:07:40 +09:00
LONG_ S L L t 1 , a1 , 8
2005-04-16 15:20:36 -07:00
or a1 , t 1
2006-12-18 00:07:40 +09: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-16 15:20:36 -07:00
or a1 , t 1
1 :
FEXPORT( _ _ b z e r o )
2013-03-25 13:40:49 -05:00
sltiu t 0 , a2 , S T O R S I Z E / * v e r y s m a l l r e g i o n ? * /
2008-01-29 10:14:59 +00:00
bnez t 0 , . L s m a l l _ m e m s e t
2013-03-25 13:40:49 -05:00
andi t 0 , a0 , S T O R M A S K / * a l i g n e d ? * /
2005-04-16 15:20:36 -07:00
2013-03-25 13:40:49 -05:00
# ifdef C O N F I G _ C P U _ M I C R O M I P S
move t 8 , a1 / * u s e d b y ' s w p ' i n s t r u c t i o n * /
move t 9 , a1
# endif
2007-10-23 12:43:25 +01:00
# ifndef C O N F I G _ C P U _ D A D D I _ W O R K A R O U N D S
2005-04-16 15:20:36 -07:00
beqz t 0 , 1 f
2013-03-25 13:40:49 -05:00
PTR_ S U B U t 0 , S T O R S I Z E / * a l i g n m e n t i n b y t e s * /
2007-10-23 12:43:25 +01:00
# else
.set noat
2013-03-25 13:40:49 -05:00
li A T , S T O R S I Z E
2007-10-23 12:43:25 +01:00
beqz t 0 , 1 f
PTR_ S U B U t 0 , A T / * a l i g n m e n t i n b y t e s * /
.set at
# endif
2005-04-16 15:20:36 -07:00
2007-11-25 11:47:56 +01:00
R1 0 K C B A R R I E R ( 0 ( r a ) )
2005-04-16 15:20:36 -07:00
# ifdef _ _ M I P S E B _ _
2008-01-29 10:14:59 +00:00
EX( L O N G _ S _ L , a1 , ( a0 ) , . L 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-16 15:20:36 -07:00
# endif
# ifdef _ _ M I P S E L _ _
2008-01-29 10:14:59 +00:00
EX( L O N G _ S _ R , a1 , ( a0 ) , . L 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-16 15:20:36 -07: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
2008-01-29 10:14:59 +00:00
beqz t 1 , . L 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 * /
2013-03-25 13:40:49 -05:00
andi t 0 , a2 , 0 x40 - S T O R S I Z E
2005-04-16 15:20:36 -07: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
2007-11-25 11:47:56 +01:00
R1 0 K C B A R R I E R ( 0 ( r a ) )
2013-03-25 13:40:49 -05:00
f_ f i l l 6 4 a0 , - 6 4 , F I L L 6 4 R G , . L f w d _ f i x u p
2005-04-16 15:20:36 -07:00
bne t 1 , a0 , 1 b
.set noreorder
2008-01-29 10:14:59 +00:00
.Lmemset_partial :
2007-11-25 11:47:56 +01:00
R1 0 K C B A R R I E R ( 0 ( r a ) )
2005-04-16 15:20:36 -07:00
PTR_ L A t 1 , 2 f / * w h e r e t o s t a r t * /
2013-03-25 13:40:49 -05:00
# ifdef C O N F I G _ C P U _ M I C R O M I P S
LONG_ S R L t 7 , t 0 , 1
# endif
2006-12-18 00:07:40 +09:00
# if L O N G S I Z E = = 4
2013-03-25 13:40:49 -05:00
PTR_ S U B U t 1 , F I L L P T R G
2006-12-18 00:07:40 +09:00
# else
.set noat
2013-03-25 13:40:49 -05:00
LONG_ S R L A T , F I L L P T R G , 1
2006-12-18 00:07:40 +09:00
PTR_ S U B U t 1 , A T
2007-10-23 12:43:25 +01:00
.set at
2006-12-18 00:07:40 +09:00
# endif
2005-04-16 15:20:36 -07: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
2013-03-25 13:40:49 -05:00
f_ f i l l 6 4 a0 , - 6 4 , F I L L 6 4 R G , . L 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 . . . * /
2005-04-16 15:20:36 -07:00
2 : .set p o p
2013-03-25 13:40:49 -05:00
andi a2 , S T O R M A S K / * A t m o s t o n e l o n g t o g o * /
2005-04-16 15:20:36 -07:00
beqz a2 , 1 f
PTR_ A D D U a0 , a2 / * W h a t ' s l e f t * /
2007-11-25 11:47:56 +01:00
R1 0 K C B A R R I E R ( 0 ( r a ) )
2005-04-16 15:20:36 -07:00
# ifdef _ _ M I P S E B _ _
2008-01-29 10:14:59 +00:00
EX( L O N G _ S _ R , a1 , - 1 ( a0 ) , . L l a s t _ f i x u p )
2005-04-16 15:20:36 -07:00
# endif
# ifdef _ _ M I P S E L _ _
2008-01-29 10:14:59 +00:00
EX( L O N G _ S _ L , a1 , - 1 ( a0 ) , . L l a s t _ f i x u p )
2005-04-16 15:20:36 -07:00
# endif
1 : jr r a
move a2 , z e r o
2008-01-29 10:14:59 +00:00
.Lsmall_memset :
2005-04-16 15:20:36 -07:00
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 * /
2007-11-25 11:47:56 +01:00
R1 0 K C B A R R I E R ( 0 ( r a ) )
2005-04-16 15:20:36 -07:00
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 )
2008-01-29 10:14:59 +00:00
.Lfirst_fixup :
2005-04-16 15:20:36 -07:00
jr r a
nop
2008-01-29 10:14:59 +00:00
.Lfwd_fixup :
2005-04-16 15:20:36 -07:00
PTR_ L t 0 , T I _ T A S K ( $ 2 8 )
andi a2 , 0 x3 f
2010-11-10 21:48:15 +08:00
LONG_ L t 0 , T H R E A D _ B U A D D R ( t 0 )
2005-04-16 15:20:36 -07:00
LONG_ A D D U a2 , t 1
jr r a
LONG_ S U B U a2 , t 0
2008-01-29 10:14:59 +00:00
.Lpartial_fixup :
2005-04-16 15:20:36 -07:00
PTR_ L t 0 , T I _ T A S K ( $ 2 8 )
2013-03-25 13:40:49 -05:00
andi a2 , S T O R M A S K
2010-11-10 21:48:15 +08:00
LONG_ L t 0 , T H R E A D _ B U A D D R ( t 0 )
2005-04-16 15:20:36 -07:00
LONG_ A D D U a2 , t 1
jr r a
LONG_ S U B U a2 , t 0
2008-01-29 10:14:59 +00:00
.Llast_fixup :
2005-04-16 15:20:36 -07:00
jr r a
2013-03-25 13:40:49 -05:00
andi v1 , a2 , S T O R M A S K