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 .
2013-03-25 22:40:49 +04: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-17 02:20:36 +04:00
* /
# 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
2013-03-25 22:40:49 +04: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
2014-01-03 13:23:16 +04:00
# define L E G A C Y _ M O D E 1
# define E V A _ M O D E 2
2014-01-03 14:11:45 +04:00
/ *
* No n e e d t o p r o t e c t i t w i t h E V A #i f d e f e r y . T h e g e n e r a t e d b l o c k o f c o d e
* will n e v e r b e a s s e m b l e d i f E V A i s n o t e n a b l e d .
* /
# define _ _ E V A F Y ( i n s n , r e g , a d d r ) _ _ B U I L D _ E V A _ I N S N ( i n s n ## e , r e g , a d d r )
# define _ _ _ B U I L D _ E V A _ I N S N ( i n s n , r e g , a d d r ) _ _ E V A F Y ( i n s n , r e g , a d d r )
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 ) \
2014-01-03 14:11:45 +04:00
.if \ mode = = L E G A C Y _ M O D E ; \
9 : insn r e g , a d d r ; \
.else ; \
9 : _ _ _ BUILD_ E V A _ I N S N ( i n s n , r e g , a d d r ) ; \
.endif ; \
2013-01-22 15:59:30 +04:00
.section _ _ ex_ t a b l e ," a " ; \
PTR 9 b , h a n d l e r ; \
2005-04-17 02:20:36 +04:00
.previous
2014-01-03 14:11:45 +04:00
.macro f_fill64 dst, o f f s e t , v a l , f i x u p , m o d e
2013-03-25 22:40:49 +04: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-17 18:07:40 +03:00
# endif
2005-04-17 02:20:36 +04:00
.endm
.set noreorder
.align 5
2014-01-03 13:23:16 +04:00
/ *
* Macro t o g e n e r a t e t h e _ _ b z e r o { ,_ u s e r } s y m b o l
* Arguments :
* mode : LEGACY_ M O D E o r E V A _ M O D E
* /
.macro __BUILD_BZERO mode
/* Initialize __memset if this is the first time we call this macro */
.ifnotdef __memset
.set _ _ memset, 1
.hidden __memset /* Make sure it does not leak */
.endif
2005-04-17 02:20:36 +04:00
2013-03-25 22:40:49 +04: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 ? * /
2014-01-03 13:23:16 +04:00
bnez t 0 , . L s m a l l _ m e m s e t \ @
2014-01-03 13:21:20 +04:00
andi t 0 , a0 , S T O R M A S K / * a l i g n e d ? * /
2005-04-17 02:20:36 +04:00
2013-03-25 22:40:49 +04: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 15:43:25 +04: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-17 02:20:36 +04:00
beqz t 0 , 1 f
2014-01-03 13:21:20 +04: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 15:43:25 +04:00
# else
.set noat
2013-03-25 22:40:49 +04:00
li A T , S T O R S I Z E
2007-10-23 15:43:25 +04:00
beqz t 0 , 1 f
2014-01-03 13:21:20 +04:00
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 * /
2007-10-23 15:43:25 +04:00
.set at
# endif
2005-04-17 02:20:36 +04:00
2014-11-18 12:04:34 +03:00
# ifndef C O N F I G _ C P U _ M I P S R 6
2007-11-25 13:47:56 +03:00
R1 0 K C B A R R I E R ( 0 ( r a ) )
2005-04-17 02:20:36 +04:00
# ifdef _ _ M I P S E B _ _
2014-01-03 13:23:16 +04:00
EX( L O N G _ S _ L , a1 , ( a0 ) , . L f i r s t _ f i x u p \ @) /* make word/dword aligned */
2014-11-19 11:58:10 +03:00
# else
2014-01-03 13:23:16 +04:00
EX( L O N G _ S _ R , a1 , ( a0 ) , . L f i r s t _ f i x u p \ @) /* make word/dword aligned */
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 * /
2014-11-18 12:04:34 +03:00
# else / * C O N F I G _ C P U _ M I P S R 6 * /
# define S T O R E _ B Y T E ( N ) \
EX( s b , a1 , N ( a0 ) , . L b y t e _ f i x u p \ @); \
beqz t 0 , 0 f ; \
PTR_ A D D U t 0 , 1 ;
PTR_ A D D U a2 , t 0 / * c o r r e c t s i z e * /
PTR_ A D D U t 0 , 1
STORE_ B Y T E ( 0 )
STORE_ B Y T E ( 1 )
# if L O N G S I Z E = = 4
EX( s b , a1 , 2 ( a0 ) , . L b y t e _ f i x u p \ @)
# else
STORE_ B Y T E ( 2 )
STORE_ B Y T E ( 3 )
STORE_ B Y T E ( 4 )
STORE_ B Y T E ( 5 )
EX( s b , a1 , 6 ( a0 ) , . L b y t e _ f i x u p \ @)
# endif
0 :
ori a0 , S T O R M A S K
xori a0 , S T O R M A S K
PTR_ A D D I U a0 , S T O R S I Z E
# endif / * C O N F I G _ C P U _ M I P S R 6 * /
2005-04-17 02:20:36 +04:00
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
2014-01-03 13:23:16 +04:00
beqz t 1 , . L m e m s e t _ p a r t i a l \ @ /* no block to fill */
2014-01-03 13:21:20 +04:00
andi t 0 , a2 , 0 x40 - S T O R 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
2007-11-25 13:47:56 +03:00
R1 0 K C B A R R I E R ( 0 ( r a ) )
2014-01-03 14:11:45 +04: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 \ @, \mode
2005-04-17 02:20:36 +04:00
bne t 1 , a0 , 1 b
.set noreorder
2014-01-03 13:23:16 +04:00
.Lmemset_partial \ @:
2007-11-25 13:47:56 +03:00
R1 0 K C B A R R I E R ( 0 ( r a ) )
2005-04-17 02:20:36 +04:00
PTR_ L A t 1 , 2 f / * w h e r e t o s t a r t * /
2013-03-25 22:40:49 +04: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-17 18:07:40 +03:00
# if L O N G S I Z E = = 4
2013-03-25 22:40:49 +04:00
PTR_ S U B U t 1 , F I L L P T R G
2006-12-17 18:07:40 +03:00
# else
.set noat
2013-03-25 22:40:49 +04:00
LONG_ S R L A T , F I L L P T R G , 1
2006-12-17 18:07:40 +03:00
PTR_ S U B U t 1 , A T
2007-10-23 15:43:25 +04:00
.set at
2006-12-17 18:07:40 +03:00
# endif
2005-04-17 02:20:36 +04:00
jr t 1
2014-01-03 13:21:20 +04:00
PTR_ A D D U a0 , t 0 / * d e s t p t r * /
2005-04-17 02:20:36 +04:00
.set push
.set noreorder
.set nomacro
2014-01-03 13:23:16 +04:00
/* ... but first do longs ... */
2014-01-03 14:11:45 +04: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 \ @, \mode
2005-04-17 02:20:36 +04:00
2 : .set p o p
2013-03-25 22:40:49 +04: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-17 02:20:36 +04:00
beqz a2 , 1 f
2014-11-18 12:04:34 +03:00
# ifndef C O N F I G _ C P U _ M I P S R 6
2014-01-03 13:21:20 +04:00
PTR_ A D D U a0 , a2 / * W h a t ' s l e f t * /
2007-11-25 13:47:56 +03:00
R1 0 K C B A R R I E R ( 0 ( r a ) )
2005-04-17 02:20:36 +04:00
# ifdef _ _ M I P S E B _ _
2014-01-03 13:23:16 +04:00
EX( L O N G _ S _ R , a1 , - 1 ( a0 ) , . L l a s t _ f i x u p \ @)
2014-11-19 11:58:10 +03:00
# else
2014-01-03 13:23:16 +04:00
EX( L O N G _ S _ L , a1 , - 1 ( a0 ) , . L l a s t _ f i x u p \ @)
2005-04-17 02:20:36 +04:00
# endif
2014-11-18 12:04:34 +03:00
# else
PTR_ S U B U t 0 , $ 0 , a2
PTR_ A D D I U t 0 , 1
STORE_ B Y T E ( 0 )
STORE_ B Y T E ( 1 )
# if L O N G S I Z E = = 4
EX( s b , a1 , 2 ( a0 ) , . L b y t e _ f i x u p \ @)
# else
STORE_ B Y T E ( 2 )
STORE_ B Y T E ( 3 )
STORE_ B Y T E ( 4 )
STORE_ B Y T E ( 5 )
EX( s b , a1 , 6 ( a0 ) , . L b y t e _ f i x u p \ @)
# endif
0 :
# endif
2005-04-17 02:20:36 +04:00
1 : jr r a
2014-01-03 13:21:20 +04:00
move a2 , z e r o
2005-04-17 02:20:36 +04:00
2014-01-03 13:23:16 +04:00
.Lsmall_memset \ @:
2005-04-17 02:20:36 +04:00
beqz a2 , 2 f
2014-01-03 13:21:20 +04:00
PTR_ A D D U t 1 , a0 , a2
2005-04-17 02:20:36 +04:00
1 : PTR_ A D D I U a0 , 1 / * f i l l b y t e w i s e * /
2007-11-25 13:47:56 +03:00
R1 0 K C B A R R I E R ( 0 ( r a ) )
2005-04-17 02:20:36 +04:00
bne t 1 , a0 , 1 b
2014-01-03 13:21:20 +04:00
sb a1 , - 1 ( a0 )
2005-04-17 02:20:36 +04:00
2 : jr r a / * d o n e * /
2014-01-03 13:21:20 +04:00
move a2 , z e r o
2014-01-03 13:23:16 +04:00
.if __memset = = 1
2005-04-17 02:20:36 +04:00
END( m e m s e t )
2014-01-03 13:23:16 +04:00
.set _ _ memset, 0
.hidden __memset
.endif
2005-04-17 02:20:36 +04:00
2014-11-18 12:04:34 +03:00
.Lbyte_fixup \ @:
PTR_ S U B U a2 , $ 0 , t 0
jr r a
PTR_ A D D I U a2 , 1
2014-01-03 13:23:16 +04:00
.Lfirst_fixup \ @:
2005-04-17 02:20:36 +04:00
jr r a
2014-01-03 13:21:20 +04:00
nop
2005-04-17 02:20:36 +04:00
2014-01-03 13:23:16 +04:00
.Lfwd_fixup \ @:
2005-04-17 02:20:36 +04:00
PTR_ L t 0 , T I _ T A S K ( $ 2 8 )
andi a2 , 0 x3 f
2010-11-10 16:48:15 +03:00
LONG_ L t 0 , T H R E A D _ B U A D D R ( t 0 )
2005-04-17 02:20:36 +04:00
LONG_ A D D U a2 , t 1
jr r a
2014-01-03 13:21:20 +04:00
LONG_ S U B U a2 , t 0
2005-04-17 02:20:36 +04:00
2014-01-03 13:23:16 +04:00
.Lpartial_fixup \ @:
2005-04-17 02:20:36 +04:00
PTR_ L t 0 , T I _ T A S K ( $ 2 8 )
2013-03-25 22:40:49 +04:00
andi a2 , S T O R M A S K
2010-11-10 16:48:15 +03:00
LONG_ L t 0 , T H R E A D _ B U A D D R ( t 0 )
2005-04-17 02:20:36 +04:00
LONG_ A D D U a2 , t 1
jr r a
2014-01-03 13:21:20 +04:00
LONG_ S U B U a2 , t 0
2005-04-17 02:20:36 +04:00
2014-01-03 13:23:16 +04:00
.Llast_fixup \ @:
2005-04-17 02:20:36 +04:00
jr r a
2014-01-03 13:21:20 +04:00
andi v1 , a2 , S T O R M A S K
2014-01-03 13:23:16 +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
* /
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 * /
LONG_ S L L t 1 , a1 , 8
or a1 , t 1
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
or a1 , t 1
1 :
2014-01-03 14:11:45 +04:00
# ifndef C O N F I G _ E V A
2014-01-03 13:23:16 +04:00
FEXPORT( _ _ b z e r o )
2014-01-03 14:11:45 +04:00
# endif
2014-01-03 13:23:16 +04:00
_ _ BUILD_ B Z E R O L E G A C Y _ M O D E
2014-01-03 14:11:45 +04:00
# ifdef C O N F I G _ E V A
LEAF( _ _ b z e r o )
_ _ BUILD_ B Z E R O E V A _ M O D E
END( _ _ b z e r o )
# endif