2022-05-31 18:04:11 +08:00
/* SPDX-License-Identifier: GPL-2.0 */
/ *
* Author : Lu Z e n g < z e n g l u @loongson.cn>
* Pei H u a n g < h u a n g p e i @loongson.cn>
* Huacai C h e n < c h e n h u a c a i @loongson.cn>
*
* Copyright ( C ) 2 0 2 0 - 2 0 2 2 L o o n g s o n T e c h n o l o g y C o r p o r a t i o n L i m i t e d
* /
# include < a s m / a s m . h >
# include < a s m / a s m m a c r o . h >
2022-12-10 22:39:48 +08:00
# include < a s m / a s m - e x t a b l e . h >
2022-05-31 18:04:11 +08:00
# include < a s m / a s m - o f f s e t s . h >
# include < a s m / e r r n o . h >
# include < a s m / e x p o r t . h >
# include < a s m / f p r e g d e f . h >
# include < a s m / l o o n g a r c h . h >
# include < a s m / r e g d e f . h >
# define F P U _ R E G _ W I D T H 8
# define L S X _ R E G _ W I D T H 1 6
# define L A S X _ R E G _ W I D T H 3 2
.macro EX insn, r e g , s r c , o f f s
.ex \ @: \insn \reg, \src, \offs
2022-12-10 22:39:48 +08:00
_ asm_ e x t a b l e . e x \ @, fault
2022-05-31 18:04:11 +08:00
.endm
.macro sc_save_fp base
2022-07-26 23:57:22 +08:00
EX f s t . d $ f0 , \ b a s e , ( 0 * F P U _ R E G _ W I D T H )
EX f s t . d $ f1 , \ b a s e , ( 1 * F P U _ R E G _ W I D T H )
EX f s t . d $ f2 , \ b a s e , ( 2 * F P U _ R E G _ W I D T H )
EX f s t . d $ f3 , \ b a s e , ( 3 * F P U _ R E G _ W I D T H )
EX f s t . d $ f4 , \ b a s e , ( 4 * F P U _ R E G _ W I D T H )
EX f s t . d $ f5 , \ b a s e , ( 5 * F P U _ R E G _ W I D T H )
EX f s t . d $ f6 , \ b a s e , ( 6 * F P U _ R E G _ W I D T H )
EX f s t . d $ f7 , \ b a s e , ( 7 * F P U _ R E G _ W I D T H )
EX f s t . d $ f8 , \ b a s e , ( 8 * F P U _ R E G _ W I D T H )
EX f s t . d $ f9 , \ b a s e , ( 9 * F P U _ R E G _ W I D T H )
EX f s t . d $ f10 , \ b a s e , ( 1 0 * F P U _ R E G _ W I D T H )
EX f s t . d $ f11 , \ b a s e , ( 1 1 * F P U _ R E G _ W I D T H )
EX f s t . d $ f12 , \ b a s e , ( 1 2 * F P U _ R E G _ W I D T H )
EX f s t . d $ f13 , \ b a s e , ( 1 3 * F P U _ R E G _ W I D T H )
EX f s t . d $ f14 , \ b a s e , ( 1 4 * F P U _ R E G _ W I D T H )
EX f s t . d $ f15 , \ b a s e , ( 1 5 * F P U _ R E G _ W I D T H )
EX f s t . d $ f16 , \ b a s e , ( 1 6 * F P U _ R E G _ W I D T H )
EX f s t . d $ f17 , \ b a s e , ( 1 7 * F P U _ R E G _ W I D T H )
EX f s t . d $ f18 , \ b a s e , ( 1 8 * F P U _ R E G _ W I D T H )
EX f s t . d $ f19 , \ b a s e , ( 1 9 * F P U _ R E G _ W I D T H )
EX f s t . d $ f20 , \ b a s e , ( 2 0 * F P U _ R E G _ W I D T H )
EX f s t . d $ f21 , \ b a s e , ( 2 1 * F P U _ R E G _ W I D T H )
EX f s t . d $ f22 , \ b a s e , ( 2 2 * F P U _ R E G _ W I D T H )
EX f s t . d $ f23 , \ b a s e , ( 2 3 * F P U _ R E G _ W I D T H )
EX f s t . d $ f24 , \ b a s e , ( 2 4 * F P U _ R E G _ W I D T H )
EX f s t . d $ f25 , \ b a s e , ( 2 5 * F P U _ R E G _ W I D T H )
EX f s t . d $ f26 , \ b a s e , ( 2 6 * F P U _ R E G _ W I D T H )
EX f s t . d $ f27 , \ b a s e , ( 2 7 * F P U _ R E G _ W I D T H )
EX f s t . d $ f28 , \ b a s e , ( 2 8 * F P U _ R E G _ W I D T H )
EX f s t . d $ f29 , \ b a s e , ( 2 9 * F P U _ R E G _ W I D T H )
EX f s t . d $ f30 , \ b a s e , ( 3 0 * F P U _ R E G _ W I D T H )
EX f s t . d $ f31 , \ b a s e , ( 3 1 * F P U _ R E G _ W I D T H )
2022-05-31 18:04:11 +08:00
.endm
.macro sc_restore_fp base
2022-07-26 23:57:22 +08:00
EX f l d . d $ f0 , \ b a s e , ( 0 * F P U _ R E G _ W I D T H )
EX f l d . d $ f1 , \ b a s e , ( 1 * F P U _ R E G _ W I D T H )
EX f l d . d $ f2 , \ b a s e , ( 2 * F P U _ R E G _ W I D T H )
EX f l d . d $ f3 , \ b a s e , ( 3 * F P U _ R E G _ W I D T H )
EX f l d . d $ f4 , \ b a s e , ( 4 * F P U _ R E G _ W I D T H )
EX f l d . d $ f5 , \ b a s e , ( 5 * F P U _ R E G _ W I D T H )
EX f l d . d $ f6 , \ b a s e , ( 6 * F P U _ R E G _ W I D T H )
EX f l d . d $ f7 , \ b a s e , ( 7 * F P U _ R E G _ W I D T H )
EX f l d . d $ f8 , \ b a s e , ( 8 * F P U _ R E G _ W I D T H )
EX f l d . d $ f9 , \ b a s e , ( 9 * F P U _ R E G _ W I D T H )
EX f l d . d $ f10 , \ b a s e , ( 1 0 * F P U _ R E G _ W I D T H )
EX f l d . d $ f11 , \ b a s e , ( 1 1 * F P U _ R E G _ W I D T H )
EX f l d . d $ f12 , \ b a s e , ( 1 2 * F P U _ R E G _ W I D T H )
EX f l d . d $ f13 , \ b a s e , ( 1 3 * F P U _ R E G _ W I D T H )
EX f l d . d $ f14 , \ b a s e , ( 1 4 * F P U _ R E G _ W I D T H )
EX f l d . d $ f15 , \ b a s e , ( 1 5 * F P U _ R E G _ W I D T H )
EX f l d . d $ f16 , \ b a s e , ( 1 6 * F P U _ R E G _ W I D T H )
EX f l d . d $ f17 , \ b a s e , ( 1 7 * F P U _ R E G _ W I D T H )
EX f l d . d $ f18 , \ b a s e , ( 1 8 * F P U _ R E G _ W I D T H )
EX f l d . d $ f19 , \ b a s e , ( 1 9 * F P U _ R E G _ W I D T H )
EX f l d . d $ f20 , \ b a s e , ( 2 0 * F P U _ R E G _ W I D T H )
EX f l d . d $ f21 , \ b a s e , ( 2 1 * F P U _ R E G _ W I D T H )
EX f l d . d $ f22 , \ b a s e , ( 2 2 * F P U _ R E G _ W I D T H )
EX f l d . d $ f23 , \ b a s e , ( 2 3 * F P U _ R E G _ W I D T H )
EX f l d . d $ f24 , \ b a s e , ( 2 4 * F P U _ R E G _ W I D T H )
EX f l d . d $ f25 , \ b a s e , ( 2 5 * F P U _ R E G _ W I D T H )
EX f l d . d $ f26 , \ b a s e , ( 2 6 * F P U _ R E G _ W I D T H )
EX f l d . d $ f27 , \ b a s e , ( 2 7 * F P U _ R E G _ W I D T H )
EX f l d . d $ f28 , \ b a s e , ( 2 8 * F P U _ R E G _ W I D T H )
EX f l d . d $ f29 , \ b a s e , ( 2 9 * F P U _ R E G _ W I D T H )
EX f l d . d $ f30 , \ b a s e , ( 3 0 * F P U _ R E G _ W I D T H )
EX f l d . d $ f31 , \ b a s e , ( 3 1 * F P U _ R E G _ W I D T H )
2022-05-31 18:04:11 +08:00
.endm
.macro sc_save_fcc base, t m p0 , t m p1
movcf2 g r \ t m p0 , $ f c c0
2022-07-26 23:57:22 +08:00
move \ t m p1 , \ t m p0
2022-05-31 18:04:11 +08:00
movcf2 g r \ t m p0 , $ f c c1
bstrins. d \ t m p1 , \ t m p0 , 1 5 , 8
movcf2 g r \ t m p0 , $ f c c2
bstrins. d \ t m p1 , \ t m p0 , 2 3 , 1 6
movcf2 g r \ t m p0 , $ f c c3
bstrins. d \ t m p1 , \ t m p0 , 3 1 , 2 4
movcf2 g r \ t m p0 , $ f c c4
bstrins. d \ t m p1 , \ t m p0 , 3 9 , 3 2
movcf2 g r \ t m p0 , $ f c c5
bstrins. d \ t m p1 , \ t m p0 , 4 7 , 4 0
movcf2 g r \ t m p0 , $ f c c6
bstrins. d \ t m p1 , \ t m p0 , 5 5 , 4 8
movcf2 g r \ t m p0 , $ f c c7
bstrins. d \ t m p1 , \ t m p0 , 6 3 , 5 6
2022-07-26 23:57:22 +08:00
EX s t . d \ t m p1 , \ b a s e , 0
2022-05-31 18:04:11 +08:00
.endm
.macro sc_restore_fcc base, t m p0 , t m p1
2022-07-26 23:57:22 +08:00
EX l d . d \ t m p0 , \ b a s e , 0
2022-05-31 18:04:11 +08:00
bstrpick. d \ t m p1 , \ t m p0 , 7 , 0
movgr2 c f $ f c c0 , \ t m p1
bstrpick. d \ t m p1 , \ t m p0 , 1 5 , 8
movgr2 c f $ f c c1 , \ t m p1
bstrpick. d \ t m p1 , \ t m p0 , 2 3 , 1 6
movgr2 c f $ f c c2 , \ t m p1
bstrpick. d \ t m p1 , \ t m p0 , 3 1 , 2 4
movgr2 c f $ f c c3 , \ t m p1
bstrpick. d \ t m p1 , \ t m p0 , 3 9 , 3 2
movgr2 c f $ f c c4 , \ t m p1
bstrpick. d \ t m p1 , \ t m p0 , 4 7 , 4 0
movgr2 c f $ f c c5 , \ t m p1
bstrpick. d \ t m p1 , \ t m p0 , 5 5 , 4 8
movgr2 c f $ f c c6 , \ t m p1
bstrpick. d \ t m p1 , \ t m p0 , 6 3 , 5 6
movgr2 c f $ f c c7 , \ t m p1
.endm
.macro sc_save_fcsr base, t m p0
movfcsr2 g r \ t m p0 , f c s r0
2022-07-26 23:57:22 +08:00
EX s t . w \ t m p0 , \ b a s e , 0
2022-05-31 18:04:11 +08:00
.endm
.macro sc_restore_fcsr base, t m p0
2022-07-26 23:57:22 +08:00
EX l d . w \ t m p0 , \ b a s e , 0
2022-05-31 18:04:11 +08:00
movgr2 f c s r f c s r0 , \ t m p0
.endm
2023-06-29 20:58:43 +08:00
.macro sc_save_lsx base
# ifdef C O N F I G _ C P U _ H A S _ L S X
EX v s t $ v r0 , \ b a s e , ( 0 * L S X _ R E G _ W I D T H )
EX v s t $ v r1 , \ b a s e , ( 1 * L S X _ R E G _ W I D T H )
EX v s t $ v r2 , \ b a s e , ( 2 * L S X _ R E G _ W I D T H )
EX v s t $ v r3 , \ b a s e , ( 3 * L S X _ R E G _ W I D T H )
EX v s t $ v r4 , \ b a s e , ( 4 * L S X _ R E G _ W I D T H )
EX v s t $ v r5 , \ b a s e , ( 5 * L S X _ R E G _ W I D T H )
EX v s t $ v r6 , \ b a s e , ( 6 * L S X _ R E G _ W I D T H )
EX v s t $ v r7 , \ b a s e , ( 7 * L S X _ R E G _ W I D T H )
EX v s t $ v r8 , \ b a s e , ( 8 * L S X _ R E G _ W I D T H )
EX v s t $ v r9 , \ b a s e , ( 9 * L S X _ R E G _ W I D T H )
EX v s t $ v r10 , \ b a s e , ( 1 0 * L S X _ R E G _ W I D T H )
EX v s t $ v r11 , \ b a s e , ( 1 1 * L S X _ R E G _ W I D T H )
EX v s t $ v r12 , \ b a s e , ( 1 2 * L S X _ R E G _ W I D T H )
EX v s t $ v r13 , \ b a s e , ( 1 3 * L S X _ R E G _ W I D T H )
EX v s t $ v r14 , \ b a s e , ( 1 4 * L S X _ R E G _ W I D T H )
EX v s t $ v r15 , \ b a s e , ( 1 5 * L S X _ R E G _ W I D T H )
EX v s t $ v r16 , \ b a s e , ( 1 6 * L S X _ R E G _ W I D T H )
EX v s t $ v r17 , \ b a s e , ( 1 7 * L S X _ R E G _ W I D T H )
EX v s t $ v r18 , \ b a s e , ( 1 8 * L S X _ R E G _ W I D T H )
EX v s t $ v r19 , \ b a s e , ( 1 9 * L S X _ R E G _ W I D T H )
EX v s t $ v r20 , \ b a s e , ( 2 0 * L S X _ R E G _ W I D T H )
EX v s t $ v r21 , \ b a s e , ( 2 1 * L S X _ R E G _ W I D T H )
EX v s t $ v r22 , \ b a s e , ( 2 2 * L S X _ R E G _ W I D T H )
EX v s t $ v r23 , \ b a s e , ( 2 3 * L S X _ R E G _ W I D T H )
EX v s t $ v r24 , \ b a s e , ( 2 4 * L S X _ R E G _ W I D T H )
EX v s t $ v r25 , \ b a s e , ( 2 5 * L S X _ R E G _ W I D T H )
EX v s t $ v r26 , \ b a s e , ( 2 6 * L S X _ R E G _ W I D T H )
EX v s t $ v r27 , \ b a s e , ( 2 7 * L S X _ R E G _ W I D T H )
EX v s t $ v r28 , \ b a s e , ( 2 8 * L S X _ R E G _ W I D T H )
EX v s t $ v r29 , \ b a s e , ( 2 9 * L S X _ R E G _ W I D T H )
EX v s t $ v r30 , \ b a s e , ( 3 0 * L S X _ R E G _ W I D T H )
EX v s t $ v r31 , \ b a s e , ( 3 1 * L S X _ R E G _ W I D T H )
# endif
.endm
.macro sc_restore_lsx base
# ifdef C O N F I G _ C P U _ H A S _ L S X
EX v l d $ v r0 , \ b a s e , ( 0 * L S X _ R E G _ W I D T H )
EX v l d $ v r1 , \ b a s e , ( 1 * L S X _ R E G _ W I D T H )
EX v l d $ v r2 , \ b a s e , ( 2 * L S X _ R E G _ W I D T H )
EX v l d $ v r3 , \ b a s e , ( 3 * L S X _ R E G _ W I D T H )
EX v l d $ v r4 , \ b a s e , ( 4 * L S X _ R E G _ W I D T H )
EX v l d $ v r5 , \ b a s e , ( 5 * L S X _ R E G _ W I D T H )
EX v l d $ v r6 , \ b a s e , ( 6 * L S X _ R E G _ W I D T H )
EX v l d $ v r7 , \ b a s e , ( 7 * L S X _ R E G _ W I D T H )
EX v l d $ v r8 , \ b a s e , ( 8 * L S X _ R E G _ W I D T H )
EX v l d $ v r9 , \ b a s e , ( 9 * L S X _ R E G _ W I D T H )
EX v l d $ v r10 , \ b a s e , ( 1 0 * L S X _ R E G _ W I D T H )
EX v l d $ v r11 , \ b a s e , ( 1 1 * L S X _ R E G _ W I D T H )
EX v l d $ v r12 , \ b a s e , ( 1 2 * L S X _ R E G _ W I D T H )
EX v l d $ v r13 , \ b a s e , ( 1 3 * L S X _ R E G _ W I D T H )
EX v l d $ v r14 , \ b a s e , ( 1 4 * L S X _ R E G _ W I D T H )
EX v l d $ v r15 , \ b a s e , ( 1 5 * L S X _ R E G _ W I D T H )
EX v l d $ v r16 , \ b a s e , ( 1 6 * L S X _ R E G _ W I D T H )
EX v l d $ v r17 , \ b a s e , ( 1 7 * L S X _ R E G _ W I D T H )
EX v l d $ v r18 , \ b a s e , ( 1 8 * L S X _ R E G _ W I D T H )
EX v l d $ v r19 , \ b a s e , ( 1 9 * L S X _ R E G _ W I D T H )
EX v l d $ v r20 , \ b a s e , ( 2 0 * L S X _ R E G _ W I D T H )
EX v l d $ v r21 , \ b a s e , ( 2 1 * L S X _ R E G _ W I D T H )
EX v l d $ v r22 , \ b a s e , ( 2 2 * L S X _ R E G _ W I D T H )
EX v l d $ v r23 , \ b a s e , ( 2 3 * L S X _ R E G _ W I D T H )
EX v l d $ v r24 , \ b a s e , ( 2 4 * L S X _ R E G _ W I D T H )
EX v l d $ v r25 , \ b a s e , ( 2 5 * L S X _ R E G _ W I D T H )
EX v l d $ v r26 , \ b a s e , ( 2 6 * L S X _ R E G _ W I D T H )
EX v l d $ v r27 , \ b a s e , ( 2 7 * L S X _ R E G _ W I D T H )
EX v l d $ v r28 , \ b a s e , ( 2 8 * L S X _ R E G _ W I D T H )
EX v l d $ v r29 , \ b a s e , ( 2 9 * L S X _ R E G _ W I D T H )
EX v l d $ v r30 , \ b a s e , ( 3 0 * L S X _ R E G _ W I D T H )
EX v l d $ v r31 , \ b a s e , ( 3 1 * L S X _ R E G _ W I D T H )
# endif
.endm
.macro sc_save_lasx base
# ifdef C O N F I G _ C P U _ H A S _ L A S X
EX x v s t $ x r0 , \ b a s e , ( 0 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r1 , \ b a s e , ( 1 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r2 , \ b a s e , ( 2 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r3 , \ b a s e , ( 3 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r4 , \ b a s e , ( 4 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r5 , \ b a s e , ( 5 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r6 , \ b a s e , ( 6 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r7 , \ b a s e , ( 7 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r8 , \ b a s e , ( 8 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r9 , \ b a s e , ( 9 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r10 , \ b a s e , ( 1 0 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r11 , \ b a s e , ( 1 1 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r12 , \ b a s e , ( 1 2 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r13 , \ b a s e , ( 1 3 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r14 , \ b a s e , ( 1 4 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r15 , \ b a s e , ( 1 5 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r16 , \ b a s e , ( 1 6 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r17 , \ b a s e , ( 1 7 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r18 , \ b a s e , ( 1 8 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r19 , \ b a s e , ( 1 9 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r20 , \ b a s e , ( 2 0 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r21 , \ b a s e , ( 2 1 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r22 , \ b a s e , ( 2 2 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r23 , \ b a s e , ( 2 3 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r24 , \ b a s e , ( 2 4 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r25 , \ b a s e , ( 2 5 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r26 , \ b a s e , ( 2 6 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r27 , \ b a s e , ( 2 7 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r28 , \ b a s e , ( 2 8 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r29 , \ b a s e , ( 2 9 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r30 , \ b a s e , ( 3 0 * L A S X _ R E G _ W I D T H )
EX x v s t $ x r31 , \ b a s e , ( 3 1 * L A S X _ R E G _ W I D T H )
# endif
.endm
.macro sc_restore_lasx base
# ifdef C O N F I G _ C P U _ H A S _ L A S X
EX x v l d $ x r0 , \ b a s e , ( 0 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r1 , \ b a s e , ( 1 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r2 , \ b a s e , ( 2 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r3 , \ b a s e , ( 3 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r4 , \ b a s e , ( 4 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r5 , \ b a s e , ( 5 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r6 , \ b a s e , ( 6 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r7 , \ b a s e , ( 7 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r8 , \ b a s e , ( 8 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r9 , \ b a s e , ( 9 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r10 , \ b a s e , ( 1 0 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r11 , \ b a s e , ( 1 1 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r12 , \ b a s e , ( 1 2 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r13 , \ b a s e , ( 1 3 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r14 , \ b a s e , ( 1 4 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r15 , \ b a s e , ( 1 5 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r16 , \ b a s e , ( 1 6 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r17 , \ b a s e , ( 1 7 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r18 , \ b a s e , ( 1 8 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r19 , \ b a s e , ( 1 9 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r20 , \ b a s e , ( 2 0 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r21 , \ b a s e , ( 2 1 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r22 , \ b a s e , ( 2 2 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r23 , \ b a s e , ( 2 3 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r24 , \ b a s e , ( 2 4 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r25 , \ b a s e , ( 2 5 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r26 , \ b a s e , ( 2 6 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r27 , \ b a s e , ( 2 7 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r28 , \ b a s e , ( 2 8 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r29 , \ b a s e , ( 2 9 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r30 , \ b a s e , ( 3 0 * L A S X _ R E G _ W I D T H )
EX x v l d $ x r31 , \ b a s e , ( 3 1 * L A S X _ R E G _ W I D T H )
# endif
.endm
2022-05-31 18:04:11 +08:00
/ *
* Save a t h r e a d ' s f p c o n t e x t .
* /
SYM_ F U N C _ S T A R T ( _ s a v e _ f p )
fpu_ s a v e _ c s r a0 t 1
2022-07-26 23:57:22 +08:00
fpu_ s a v e _ d o u b l e a0 t 1 # c l o b b e r s t 1
2022-05-31 18:04:11 +08:00
fpu_ s a v e _ c c a0 t 1 t 2 # c l o b b e r s t 1 , t 2
2022-07-26 23:57:22 +08:00
jr r a
2022-05-31 18:04:11 +08:00
SYM_ F U N C _ E N D ( _ s a v e _ f p )
EXPORT_ S Y M B O L ( _ s a v e _ f p )
/ *
* Restore a t h r e a d ' s f p c o n t e x t .
* /
SYM_ F U N C _ S T A R T ( _ r e s t o r e _ f p )
2022-07-26 23:57:22 +08:00
fpu_ r e s t o r e _ d o u b l e a0 t 1 # c l o b b e r s t 1
fpu_ r e s t o r e _ c s r a0 t 1
fpu_ r e s t o r e _ c c a0 t 1 t 2 # c l o b b e r s t 1 , t 2
jr r a
2022-05-31 18:04:11 +08:00
SYM_ F U N C _ E N D ( _ r e s t o r e _ f p )
2023-06-29 20:58:43 +08:00
# ifdef C O N F I G _ C P U _ H A S _ L S X
/ *
* Save a t h r e a d ' s L S X v e c t o r c o n t e x t .
* /
SYM_ F U N C _ S T A R T ( _ s a v e _ l s x )
lsx_ s a v e _ a l l a0 t 1 t 2
jr r a
SYM_ F U N C _ E N D ( _ s a v e _ l s x )
EXPORT_ S Y M B O L ( _ s a v e _ l s x )
/ *
* Restore a t h r e a d ' s L S X v e c t o r c o n t e x t .
* /
SYM_ F U N C _ S T A R T ( _ r e s t o r e _ l s x )
lsx_ r e s t o r e _ a l l a0 t 1 t 2
jr r a
SYM_ F U N C _ E N D ( _ r e s t o r e _ l s x )
SYM_ F U N C _ S T A R T ( _ s a v e _ l s x _ u p p e r )
lsx_ s a v e _ a l l _ u p p e r a0 t 0 t 1
jr r a
SYM_ F U N C _ E N D ( _ s a v e _ l s x _ u p p e r )
SYM_ F U N C _ S T A R T ( _ r e s t o r e _ l s x _ u p p e r )
lsx_ r e s t o r e _ a l l _ u p p e r a0 t 0 t 1
jr r a
SYM_ F U N C _ E N D ( _ r e s t o r e _ l s x _ u p p e r )
SYM_ F U N C _ S T A R T ( _ i n i t _ l s x _ u p p e r )
lsx_ i n i t _ a l l _ u p p e r t 1
jr r a
SYM_ F U N C _ E N D ( _ i n i t _ l s x _ u p p e r )
# endif
# ifdef C O N F I G _ C P U _ H A S _ L A S X
/ *
* Save a t h r e a d ' s L A S X v e c t o r c o n t e x t .
* /
SYM_ F U N C _ S T A R T ( _ s a v e _ l a s x )
lasx_ s a v e _ a l l a0 t 1 t 2
jr r a
SYM_ F U N C _ E N D ( _ s a v e _ l a s x )
EXPORT_ S Y M B O L ( _ s a v e _ l a s x )
/ *
* Restore a t h r e a d ' s L A S X v e c t o r c o n t e x t .
* /
SYM_ F U N C _ S T A R T ( _ r e s t o r e _ l a s x )
lasx_ r e s t o r e _ a l l a0 t 1 t 2
jr r a
SYM_ F U N C _ E N D ( _ r e s t o r e _ l a s x )
SYM_ F U N C _ S T A R T ( _ s a v e _ l a s x _ u p p e r )
lasx_ s a v e _ a l l _ u p p e r a0 t 0 t 1
jr r a
SYM_ F U N C _ E N D ( _ s a v e _ l a s x _ u p p e r )
SYM_ F U N C _ S T A R T ( _ r e s t o r e _ l a s x _ u p p e r )
lasx_ r e s t o r e _ a l l _ u p p e r a0 t 0 t 1
jr r a
SYM_ F U N C _ E N D ( _ r e s t o r e _ l a s x _ u p p e r )
SYM_ F U N C _ S T A R T ( _ i n i t _ l a s x _ u p p e r )
lasx_ i n i t _ a l l _ u p p e r t 1
jr r a
SYM_ F U N C _ E N D ( _ i n i t _ l a s x _ u p p e r )
# endif
2022-05-31 18:04:11 +08:00
/ *
* Load t h e F P U w i t h s i g n a l l i n g N A N S . T h i s b i t p a t t e r n w e ' r e u s i n g h a s
* the p r o p e r t y t h a t n o m a t t e r w h e t h e r c o n s i d e r e d a s s i n g l e o r a s d o u b l e
* precision r e p r e s e n t s s i g n a l i n g N A N S .
*
* The v a l u e t o i n i t i a l i z e f c s r0 t o c o m e s i n $ a0 .
* /
SYM_ F U N C _ S T A R T ( _ i n i t _ f p u )
li. w t 1 , C S R _ E U E N _ F P E N
csrxchg t 1 , t 1 , L O O N G A R C H _ C S R _ E U E N
movgr2 f c s r f c s r0 , a0
li. w t 1 , - 1 # S N a N
movgr2 f r . d $ f0 , t 1
movgr2 f r . d $ f1 , t 1
movgr2 f r . d $ f2 , t 1
movgr2 f r . d $ f3 , t 1
movgr2 f r . d $ f4 , t 1
movgr2 f r . d $ f5 , t 1
movgr2 f r . d $ f6 , t 1
movgr2 f r . d $ f7 , t 1
movgr2 f r . d $ f8 , t 1
movgr2 f r . d $ f9 , t 1
movgr2 f r . d $ f10 , t 1
movgr2 f r . d $ f11 , t 1
movgr2 f r . d $ f12 , t 1
movgr2 f r . d $ f13 , t 1
movgr2 f r . d $ f14 , t 1
movgr2 f r . d $ f15 , t 1
movgr2 f r . d $ f16 , t 1
movgr2 f r . d $ f17 , t 1
movgr2 f r . d $ f18 , t 1
movgr2 f r . d $ f19 , t 1
movgr2 f r . d $ f20 , t 1
movgr2 f r . d $ f21 , t 1
movgr2 f r . d $ f22 , t 1
movgr2 f r . d $ f23 , t 1
movgr2 f r . d $ f24 , t 1
movgr2 f r . d $ f25 , t 1
movgr2 f r . d $ f26 , t 1
movgr2 f r . d $ f27 , t 1
movgr2 f r . d $ f28 , t 1
movgr2 f r . d $ f29 , t 1
movgr2 f r . d $ f30 , t 1
movgr2 f r . d $ f31 , t 1
2022-07-26 23:57:17 +08:00
jr r a
2022-05-31 18:04:11 +08:00
SYM_ F U N C _ E N D ( _ i n i t _ f p u )
/ *
* a0 : fpregs
* a1 : fcc
* a2 : fcsr
* /
SYM_ F U N C _ S T A R T ( _ s a v e _ f p _ c o n t e x t )
2022-07-26 23:57:22 +08:00
sc_ s a v e _ f c c a1 t 1 t 2
sc_ s a v e _ f c s r a2 t 1
sc_ s a v e _ f p a0
li. w a0 , 0 # s u c c e s s
jr r a
2022-05-31 18:04:11 +08:00
SYM_ F U N C _ E N D ( _ s a v e _ f p _ c o n t e x t )
/ *
* a0 : fpregs
* a1 : fcc
* a2 : fcsr
* /
SYM_ F U N C _ S T A R T ( _ r e s t o r e _ f p _ c o n t e x t )
2022-07-26 23:57:22 +08:00
sc_ r e s t o r e _ f p a0
sc_ r e s t o r e _ f c c a1 t 1 t 2
sc_ r e s t o r e _ f c s r a2 t 1
li. w a0 , 0 # s u c c e s s
jr r a
2022-05-31 18:04:11 +08:00
SYM_ F U N C _ E N D ( _ r e s t o r e _ f p _ c o n t e x t )
2023-06-29 20:58:43 +08:00
/ *
* a0 : fpregs
* a1 : fcc
* a2 : fcsr
* /
SYM_ F U N C _ S T A R T ( _ s a v e _ l s x _ c o n t e x t )
sc_ s a v e _ f c c a1 , t 0 , t 1
sc_ s a v e _ f c s r a2 , t 0
sc_ s a v e _ l s x a0
li. w a0 , 0 # s u c c e s s
jr r a
SYM_ F U N C _ E N D ( _ s a v e _ l s x _ c o n t e x t )
/ *
* a0 : fpregs
* a1 : fcc
* a2 : fcsr
* /
SYM_ F U N C _ S T A R T ( _ r e s t o r e _ l s x _ c o n t e x t )
sc_ r e s t o r e _ l s x a0
sc_ r e s t o r e _ f c c a1 , t 1 , t 2
sc_ r e s t o r e _ f c s r a2 , t 1
li. w a0 , 0 # s u c c e s s
jr r a
SYM_ F U N C _ E N D ( _ r e s t o r e _ l s x _ c o n t e x t )
/ *
* a0 : fpregs
* a1 : fcc
* a2 : fcsr
* /
SYM_ F U N C _ S T A R T ( _ s a v e _ l a s x _ c o n t e x t )
sc_ s a v e _ f c c a1 , t 0 , t 1
sc_ s a v e _ f c s r a2 , t 0
sc_ s a v e _ l a s x a0
li. w a0 , 0 # s u c c e s s
jr r a
SYM_ F U N C _ E N D ( _ s a v e _ l a s x _ c o n t e x t )
/ *
* a0 : fpregs
* a1 : fcc
* a2 : fcsr
* /
SYM_ F U N C _ S T A R T ( _ r e s t o r e _ l a s x _ c o n t e x t )
sc_ r e s t o r e _ l a s x a0
sc_ r e s t o r e _ f c c a1 , t 1 , t 2
sc_ r e s t o r e _ f c s r a2 , t 1
li. w a0 , 0 # s u c c e s s
jr r a
SYM_ F U N C _ E N D ( _ r e s t o r e _ l a s x _ c o n t e x t )
2022-05-31 18:04:11 +08:00
SYM_ F U N C _ S T A R T ( f a u l t )
li. w a0 , - E F A U L T # f a i l u r e
2022-07-26 23:57:17 +08:00
jr r a
2022-05-31 18:04:11 +08:00
SYM_ F U N C _ E N D ( f a u l t )