2 * MIPS SIMD Architecture Module Instruction emulation helpers for QEMU.
4 * Copyright (c) 2014 Imagination Technologies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 #include "qemu/osdep.h"
23 #include "exec/exec-all.h"
24 #include "exec/helper-proto.h"
26 /* Data format min and max values */
27 #define DF_BITS(df) (1 << ((df) + 3))
29 #define DF_MAX_INT(df) (int64_t)((1LL << (DF_BITS(df) - 1)) - 1)
30 #define M_MAX_INT(m) (int64_t)((1LL << ((m) - 1)) - 1)
32 #define DF_MIN_INT(df) (int64_t)(-(1LL << (DF_BITS(df) - 1)))
33 #define M_MIN_INT(m) (int64_t)(-(1LL << ((m) - 1)))
35 #define DF_MAX_UINT(df) (uint64_t)(-1ULL >> (64 - DF_BITS(df)))
36 #define M_MAX_UINT(m) (uint64_t)(-1ULL >> (64 - (m)))
38 #define UNSIGNED(x, df) ((x) & DF_MAX_UINT(df))
39 #define SIGNED(x, df) \
40 ((((int64_t)x) << (64 - DF_BITS(df))) >> (64 - DF_BITS(df)))
42 /* Element-by-element access macros */
43 #define DF_ELEMENTS(df) (MSA_WRLEN / DF_BITS(df))
45 static inline void msa_move_v(wr_t
*pwd
, wr_t
*pws
)
49 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
50 pwd
->d
[i
] = pws
->d
[i
];
54 #define MSA_FN_IMM8(FUNC, DEST, OPERATION) \
55 void helper_msa_ ## FUNC(CPUMIPSState *env, uint32_t wd, uint32_t ws, \
58 wr_t *pwd = &(env->active_fpu.fpr[wd].wr); \
59 wr_t *pws = &(env->active_fpu.fpr[ws].wr); \
61 for (i = 0; i < DF_ELEMENTS(DF_BYTE); i++) { \
66 MSA_FN_IMM8(andi_b
, pwd
->b
[i
], pws
->b
[i
] & i8
)
67 MSA_FN_IMM8(ori_b
, pwd
->b
[i
], pws
->b
[i
] | i8
)
68 MSA_FN_IMM8(nori_b
, pwd
->b
[i
], ~(pws
->b
[i
] | i8
))
69 MSA_FN_IMM8(xori_b
, pwd
->b
[i
], pws
->b
[i
] ^ i8
)
71 #define BIT_MOVE_IF_NOT_ZERO(dest, arg1, arg2, df) \
72 UNSIGNED(((dest & (~arg2)) | (arg1 & arg2)), df)
73 MSA_FN_IMM8(bmnzi_b
, pwd
->b
[i
],
74 BIT_MOVE_IF_NOT_ZERO(pwd
->b
[i
], pws
->b
[i
], i8
, DF_BYTE
))
76 #define BIT_MOVE_IF_ZERO(dest, arg1, arg2, df) \
77 UNSIGNED((dest & arg2) | (arg1 & (~arg2)), df)
78 MSA_FN_IMM8(bmzi_b
, pwd
->b
[i
],
79 BIT_MOVE_IF_ZERO(pwd
->b
[i
], pws
->b
[i
], i8
, DF_BYTE
))
81 #define BIT_SELECT(dest, arg1, arg2, df) \
82 UNSIGNED((arg1 & (~dest)) | (arg2 & dest), df)
83 MSA_FN_IMM8(bseli_b
, pwd
->b
[i
],
84 BIT_SELECT(pwd
->b
[i
], pws
->b
[i
], i8
, DF_BYTE
))
88 #define SHF_POS(i, imm) (((i) & 0xfc) + (((imm) >> (2 * ((i) & 0x03))) & 0x03))
90 void helper_msa_shf_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
91 uint32_t ws
, uint32_t imm
)
93 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
94 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
100 for (i
= 0; i
< DF_ELEMENTS(DF_BYTE
); i
++) {
101 pwx
->b
[i
] = pws
->b
[SHF_POS(i
, imm
)];
105 for (i
= 0; i
< DF_ELEMENTS(DF_HALF
); i
++) {
106 pwx
->h
[i
] = pws
->h
[SHF_POS(i
, imm
)];
110 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
111 pwx
->w
[i
] = pws
->w
[SHF_POS(i
, imm
)];
117 msa_move_v(pwd
, pwx
);
120 #define MSA_FN_VECTOR(FUNC, DEST, OPERATION) \
121 void helper_msa_ ## FUNC(CPUMIPSState *env, uint32_t wd, uint32_t ws, \
124 wr_t *pwd = &(env->active_fpu.fpr[wd].wr); \
125 wr_t *pws = &(env->active_fpu.fpr[ws].wr); \
126 wr_t *pwt = &(env->active_fpu.fpr[wt].wr); \
128 for (i = 0; i < DF_ELEMENTS(DF_DOUBLE); i++) { \
133 MSA_FN_VECTOR(and_v
, pwd
->d
[i
], pws
->d
[i
] & pwt
->d
[i
])
134 MSA_FN_VECTOR(or_v
, pwd
->d
[i
], pws
->d
[i
] | pwt
->d
[i
])
135 MSA_FN_VECTOR(nor_v
, pwd
->d
[i
], ~(pws
->d
[i
] | pwt
->d
[i
]))
136 MSA_FN_VECTOR(xor_v
, pwd
->d
[i
], pws
->d
[i
] ^ pwt
->d
[i
])
137 MSA_FN_VECTOR(bmnz_v
, pwd
->d
[i
],
138 BIT_MOVE_IF_NOT_ZERO(pwd
->d
[i
], pws
->d
[i
], pwt
->d
[i
], DF_DOUBLE
))
139 MSA_FN_VECTOR(bmz_v
, pwd
->d
[i
],
140 BIT_MOVE_IF_ZERO(pwd
->d
[i
], pws
->d
[i
], pwt
->d
[i
], DF_DOUBLE
))
141 MSA_FN_VECTOR(bsel_v
, pwd
->d
[i
],
142 BIT_SELECT(pwd
->d
[i
], pws
->d
[i
], pwt
->d
[i
], DF_DOUBLE
))
143 #undef BIT_MOVE_IF_NOT_ZERO
144 #undef BIT_MOVE_IF_ZERO
148 static inline int64_t msa_addv_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
153 static inline int64_t msa_subv_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
158 static inline int64_t msa_ceq_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
160 return arg1
== arg2
? -1 : 0;
163 static inline int64_t msa_cle_s_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
165 return arg1
<= arg2
? -1 : 0;
168 static inline int64_t msa_cle_u_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
170 uint64_t u_arg1
= UNSIGNED(arg1
, df
);
171 uint64_t u_arg2
= UNSIGNED(arg2
, df
);
172 return u_arg1
<= u_arg2
? -1 : 0;
175 static inline int64_t msa_clt_s_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
177 return arg1
< arg2
? -1 : 0;
180 static inline int64_t msa_clt_u_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
182 uint64_t u_arg1
= UNSIGNED(arg1
, df
);
183 uint64_t u_arg2
= UNSIGNED(arg2
, df
);
184 return u_arg1
< u_arg2
? -1 : 0;
187 static inline int64_t msa_max_s_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
189 return arg1
> arg2
? arg1
: arg2
;
192 static inline int64_t msa_max_u_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
194 uint64_t u_arg1
= UNSIGNED(arg1
, df
);
195 uint64_t u_arg2
= UNSIGNED(arg2
, df
);
196 return u_arg1
> u_arg2
? arg1
: arg2
;
199 static inline int64_t msa_min_s_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
201 return arg1
< arg2
? arg1
: arg2
;
204 static inline int64_t msa_min_u_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
206 uint64_t u_arg1
= UNSIGNED(arg1
, df
);
207 uint64_t u_arg2
= UNSIGNED(arg2
, df
);
208 return u_arg1
< u_arg2
? arg1
: arg2
;
211 #define MSA_BINOP_IMM_DF(helper, func) \
212 void helper_msa_ ## helper ## _df(CPUMIPSState *env, uint32_t df, \
213 uint32_t wd, uint32_t ws, int32_t u5) \
215 wr_t *pwd = &(env->active_fpu.fpr[wd].wr); \
216 wr_t *pws = &(env->active_fpu.fpr[ws].wr); \
221 for (i = 0; i < DF_ELEMENTS(DF_BYTE); i++) { \
222 pwd->b[i] = msa_ ## func ## _df(df, pws->b[i], u5); \
226 for (i = 0; i < DF_ELEMENTS(DF_HALF); i++) { \
227 pwd->h[i] = msa_ ## func ## _df(df, pws->h[i], u5); \
231 for (i = 0; i < DF_ELEMENTS(DF_WORD); i++) { \
232 pwd->w[i] = msa_ ## func ## _df(df, pws->w[i], u5); \
236 for (i = 0; i < DF_ELEMENTS(DF_DOUBLE); i++) { \
237 pwd->d[i] = msa_ ## func ## _df(df, pws->d[i], u5); \
245 MSA_BINOP_IMM_DF(addvi
, addv
)
246 MSA_BINOP_IMM_DF(subvi
, subv
)
247 MSA_BINOP_IMM_DF(ceqi
, ceq
)
248 MSA_BINOP_IMM_DF(clei_s
, cle_s
)
249 MSA_BINOP_IMM_DF(clei_u
, cle_u
)
250 MSA_BINOP_IMM_DF(clti_s
, clt_s
)
251 MSA_BINOP_IMM_DF(clti_u
, clt_u
)
252 MSA_BINOP_IMM_DF(maxi_s
, max_s
)
253 MSA_BINOP_IMM_DF(maxi_u
, max_u
)
254 MSA_BINOP_IMM_DF(mini_s
, min_s
)
255 MSA_BINOP_IMM_DF(mini_u
, min_u
)
256 #undef MSA_BINOP_IMM_DF
258 void helper_msa_ldi_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
261 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
266 for (i
= 0; i
< DF_ELEMENTS(DF_BYTE
); i
++) {
267 pwd
->b
[i
] = (int8_t)s10
;
271 for (i
= 0; i
< DF_ELEMENTS(DF_HALF
); i
++) {
272 pwd
->h
[i
] = (int16_t)s10
;
276 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
277 pwd
->w
[i
] = (int32_t)s10
;
281 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
282 pwd
->d
[i
] = (int64_t)s10
;
290 /* Data format bit position and unsigned values */
291 #define BIT_POSITION(x, df) ((uint64_t)(x) % DF_BITS(df))
293 static inline int64_t msa_sll_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
295 int32_t b_arg2
= BIT_POSITION(arg2
, df
);
296 return arg1
<< b_arg2
;
299 static inline int64_t msa_sra_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
301 int32_t b_arg2
= BIT_POSITION(arg2
, df
);
302 return arg1
>> b_arg2
;
305 static inline int64_t msa_srl_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
307 uint64_t u_arg1
= UNSIGNED(arg1
, df
);
308 int32_t b_arg2
= BIT_POSITION(arg2
, df
);
309 return u_arg1
>> b_arg2
;
312 static inline int64_t msa_bclr_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
314 int32_t b_arg2
= BIT_POSITION(arg2
, df
);
315 return UNSIGNED(arg1
& (~(1LL << b_arg2
)), df
);
318 static inline int64_t msa_bset_df(uint32_t df
, int64_t arg1
,
321 int32_t b_arg2
= BIT_POSITION(arg2
, df
);
322 return UNSIGNED(arg1
| (1LL << b_arg2
), df
);
325 static inline int64_t msa_bneg_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
327 int32_t b_arg2
= BIT_POSITION(arg2
, df
);
328 return UNSIGNED(arg1
^ (1LL << b_arg2
), df
);
331 static inline int64_t msa_binsl_df(uint32_t df
, int64_t dest
, int64_t arg1
,
334 uint64_t u_arg1
= UNSIGNED(arg1
, df
);
335 uint64_t u_dest
= UNSIGNED(dest
, df
);
336 int32_t sh_d
= BIT_POSITION(arg2
, df
) + 1;
337 int32_t sh_a
= DF_BITS(df
) - sh_d
;
338 if (sh_d
== DF_BITS(df
)) {
341 return UNSIGNED(UNSIGNED(u_dest
<< sh_d
, df
) >> sh_d
, df
) |
342 UNSIGNED(UNSIGNED(u_arg1
>> sh_a
, df
) << sh_a
, df
);
346 static inline int64_t msa_binsr_df(uint32_t df
, int64_t dest
, int64_t arg1
,
349 uint64_t u_arg1
= UNSIGNED(arg1
, df
);
350 uint64_t u_dest
= UNSIGNED(dest
, df
);
351 int32_t sh_d
= BIT_POSITION(arg2
, df
) + 1;
352 int32_t sh_a
= DF_BITS(df
) - sh_d
;
353 if (sh_d
== DF_BITS(df
)) {
356 return UNSIGNED(UNSIGNED(u_dest
>> sh_d
, df
) << sh_d
, df
) |
357 UNSIGNED(UNSIGNED(u_arg1
<< sh_a
, df
) >> sh_a
, df
);
361 static inline int64_t msa_sat_s_df(uint32_t df
, int64_t arg
, uint32_t m
)
363 return arg
< M_MIN_INT(m
+1) ? M_MIN_INT(m
+1) :
364 arg
> M_MAX_INT(m
+1) ? M_MAX_INT(m
+1) :
368 static inline int64_t msa_sat_u_df(uint32_t df
, int64_t arg
, uint32_t m
)
370 uint64_t u_arg
= UNSIGNED(arg
, df
);
371 return u_arg
< M_MAX_UINT(m
+1) ? u_arg
:
375 static inline int64_t msa_srar_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
377 int32_t b_arg2
= BIT_POSITION(arg2
, df
);
381 int64_t r_bit
= (arg1
>> (b_arg2
- 1)) & 1;
382 return (arg1
>> b_arg2
) + r_bit
;
386 static inline int64_t msa_srlr_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
388 uint64_t u_arg1
= UNSIGNED(arg1
, df
);
389 int32_t b_arg2
= BIT_POSITION(arg2
, df
);
393 uint64_t r_bit
= (u_arg1
>> (b_arg2
- 1)) & 1;
394 return (u_arg1
>> b_arg2
) + r_bit
;
398 #define MSA_BINOP_IMMU_DF(helper, func) \
399 void helper_msa_ ## helper ## _df(CPUMIPSState *env, uint32_t df, uint32_t wd, \
400 uint32_t ws, uint32_t u5) \
402 wr_t *pwd = &(env->active_fpu.fpr[wd].wr); \
403 wr_t *pws = &(env->active_fpu.fpr[ws].wr); \
408 for (i = 0; i < DF_ELEMENTS(DF_BYTE); i++) { \
409 pwd->b[i] = msa_ ## func ## _df(df, pws->b[i], u5); \
413 for (i = 0; i < DF_ELEMENTS(DF_HALF); i++) { \
414 pwd->h[i] = msa_ ## func ## _df(df, pws->h[i], u5); \
418 for (i = 0; i < DF_ELEMENTS(DF_WORD); i++) { \
419 pwd->w[i] = msa_ ## func ## _df(df, pws->w[i], u5); \
423 for (i = 0; i < DF_ELEMENTS(DF_DOUBLE); i++) { \
424 pwd->d[i] = msa_ ## func ## _df(df, pws->d[i], u5); \
432 MSA_BINOP_IMMU_DF(slli
, sll
)
433 MSA_BINOP_IMMU_DF(srai
, sra
)
434 MSA_BINOP_IMMU_DF(srli
, srl
)
435 MSA_BINOP_IMMU_DF(bclri
, bclr
)
436 MSA_BINOP_IMMU_DF(bseti
, bset
)
437 MSA_BINOP_IMMU_DF(bnegi
, bneg
)
438 MSA_BINOP_IMMU_DF(sat_s
, sat_s
)
439 MSA_BINOP_IMMU_DF(sat_u
, sat_u
)
440 MSA_BINOP_IMMU_DF(srari
, srar
)
441 MSA_BINOP_IMMU_DF(srlri
, srlr
)
442 #undef MSA_BINOP_IMMU_DF
444 #define MSA_TEROP_IMMU_DF(helper, func) \
445 void helper_msa_ ## helper ## _df(CPUMIPSState *env, uint32_t df, \
446 uint32_t wd, uint32_t ws, uint32_t u5) \
448 wr_t *pwd = &(env->active_fpu.fpr[wd].wr); \
449 wr_t *pws = &(env->active_fpu.fpr[ws].wr); \
454 for (i = 0; i < DF_ELEMENTS(DF_BYTE); i++) { \
455 pwd->b[i] = msa_ ## func ## _df(df, pwd->b[i], pws->b[i], \
460 for (i = 0; i < DF_ELEMENTS(DF_HALF); i++) { \
461 pwd->h[i] = msa_ ## func ## _df(df, pwd->h[i], pws->h[i], \
466 for (i = 0; i < DF_ELEMENTS(DF_WORD); i++) { \
467 pwd->w[i] = msa_ ## func ## _df(df, pwd->w[i], pws->w[i], \
472 for (i = 0; i < DF_ELEMENTS(DF_DOUBLE); i++) { \
473 pwd->d[i] = msa_ ## func ## _df(df, pwd->d[i], pws->d[i], \
482 MSA_TEROP_IMMU_DF(binsli
, binsl
)
483 MSA_TEROP_IMMU_DF(binsri
, binsr
)
484 #undef MSA_TEROP_IMMU_DF
486 static inline int64_t msa_max_a_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
488 uint64_t abs_arg1
= arg1
>= 0 ? arg1
: -arg1
;
489 uint64_t abs_arg2
= arg2
>= 0 ? arg2
: -arg2
;
490 return abs_arg1
> abs_arg2
? arg1
: arg2
;
493 static inline int64_t msa_min_a_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
495 uint64_t abs_arg1
= arg1
>= 0 ? arg1
: -arg1
;
496 uint64_t abs_arg2
= arg2
>= 0 ? arg2
: -arg2
;
497 return abs_arg1
< abs_arg2
? arg1
: arg2
;
500 static inline int64_t msa_add_a_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
502 uint64_t abs_arg1
= arg1
>= 0 ? arg1
: -arg1
;
503 uint64_t abs_arg2
= arg2
>= 0 ? arg2
: -arg2
;
504 return abs_arg1
+ abs_arg2
;
507 static inline int64_t msa_adds_a_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
509 uint64_t max_int
= (uint64_t)DF_MAX_INT(df
);
510 uint64_t abs_arg1
= arg1
>= 0 ? arg1
: -arg1
;
511 uint64_t abs_arg2
= arg2
>= 0 ? arg2
: -arg2
;
512 if (abs_arg1
> max_int
|| abs_arg2
> max_int
) {
513 return (int64_t)max_int
;
515 return (abs_arg1
< max_int
- abs_arg2
) ? abs_arg1
+ abs_arg2
: max_int
;
519 static inline int64_t msa_adds_s_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
521 int64_t max_int
= DF_MAX_INT(df
);
522 int64_t min_int
= DF_MIN_INT(df
);
524 return (min_int
- arg1
< arg2
) ? arg1
+ arg2
: min_int
;
526 return (arg2
< max_int
- arg1
) ? arg1
+ arg2
: max_int
;
530 static inline uint64_t msa_adds_u_df(uint32_t df
, uint64_t arg1
, uint64_t arg2
)
532 uint64_t max_uint
= DF_MAX_UINT(df
);
533 uint64_t u_arg1
= UNSIGNED(arg1
, df
);
534 uint64_t u_arg2
= UNSIGNED(arg2
, df
);
535 return (u_arg1
< max_uint
- u_arg2
) ? u_arg1
+ u_arg2
: max_uint
;
538 static inline int64_t msa_ave_s_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
541 return (arg1
>> 1) + (arg2
>> 1) + (arg1
& arg2
& 1);
544 static inline uint64_t msa_ave_u_df(uint32_t df
, uint64_t arg1
, uint64_t arg2
)
546 uint64_t u_arg1
= UNSIGNED(arg1
, df
);
547 uint64_t u_arg2
= UNSIGNED(arg2
, df
);
549 return (u_arg1
>> 1) + (u_arg2
>> 1) + (u_arg1
& u_arg2
& 1);
552 static inline int64_t msa_aver_s_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
555 return (arg1
>> 1) + (arg2
>> 1) + ((arg1
| arg2
) & 1);
558 static inline uint64_t msa_aver_u_df(uint32_t df
, uint64_t arg1
, uint64_t arg2
)
560 uint64_t u_arg1
= UNSIGNED(arg1
, df
);
561 uint64_t u_arg2
= UNSIGNED(arg2
, df
);
563 return (u_arg1
>> 1) + (u_arg2
>> 1) + ((u_arg1
| u_arg2
) & 1);
566 static inline int64_t msa_subs_s_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
568 int64_t max_int
= DF_MAX_INT(df
);
569 int64_t min_int
= DF_MIN_INT(df
);
571 return (min_int
+ arg2
< arg1
) ? arg1
- arg2
: min_int
;
573 return (arg1
< max_int
+ arg2
) ? arg1
- arg2
: max_int
;
577 static inline int64_t msa_subs_u_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
579 uint64_t u_arg1
= UNSIGNED(arg1
, df
);
580 uint64_t u_arg2
= UNSIGNED(arg2
, df
);
581 return (u_arg1
> u_arg2
) ? u_arg1
- u_arg2
: 0;
584 static inline int64_t msa_subsus_u_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
586 uint64_t u_arg1
= UNSIGNED(arg1
, df
);
587 uint64_t max_uint
= DF_MAX_UINT(df
);
589 uint64_t u_arg2
= (uint64_t)arg2
;
590 return (u_arg1
> u_arg2
) ?
591 (int64_t)(u_arg1
- u_arg2
) :
594 uint64_t u_arg2
= (uint64_t)(-arg2
);
595 return (u_arg1
< max_uint
- u_arg2
) ?
596 (int64_t)(u_arg1
+ u_arg2
) :
601 static inline int64_t msa_subsuu_s_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
603 uint64_t u_arg1
= UNSIGNED(arg1
, df
);
604 uint64_t u_arg2
= UNSIGNED(arg2
, df
);
605 int64_t max_int
= DF_MAX_INT(df
);
606 int64_t min_int
= DF_MIN_INT(df
);
607 if (u_arg1
> u_arg2
) {
608 return u_arg1
- u_arg2
< (uint64_t)max_int
?
609 (int64_t)(u_arg1
- u_arg2
) :
612 return u_arg2
- u_arg1
< (uint64_t)(-min_int
) ?
613 (int64_t)(u_arg1
- u_arg2
) :
618 static inline int64_t msa_asub_s_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
621 return (arg1
< arg2
) ?
622 (uint64_t)(arg2
- arg1
) : (uint64_t)(arg1
- arg2
);
625 static inline uint64_t msa_asub_u_df(uint32_t df
, uint64_t arg1
, uint64_t arg2
)
627 uint64_t u_arg1
= UNSIGNED(arg1
, df
);
628 uint64_t u_arg2
= UNSIGNED(arg2
, df
);
629 /* unsigned compare */
630 return (u_arg1
< u_arg2
) ?
631 (uint64_t)(u_arg2
- u_arg1
) : (uint64_t)(u_arg1
- u_arg2
);
634 static inline int64_t msa_mulv_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
639 static inline int64_t msa_div_s_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
641 if (arg1
== DF_MIN_INT(df
) && arg2
== -1) {
642 return DF_MIN_INT(df
);
644 return arg2
? arg1
/ arg2
645 : arg1
>= 0 ? -1 : 1;
648 static inline int64_t msa_div_u_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
650 uint64_t u_arg1
= UNSIGNED(arg1
, df
);
651 uint64_t u_arg2
= UNSIGNED(arg2
, df
);
652 return arg2
? u_arg1
/ u_arg2
: -1;
655 static inline int64_t msa_mod_s_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
657 if (arg1
== DF_MIN_INT(df
) && arg2
== -1) {
660 return arg2
? arg1
% arg2
: arg1
;
663 static inline int64_t msa_mod_u_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
665 uint64_t u_arg1
= UNSIGNED(arg1
, df
);
666 uint64_t u_arg2
= UNSIGNED(arg2
, df
);
667 return u_arg2
? u_arg1
% u_arg2
: u_arg1
;
670 #define SIGNED_EVEN(a, df) \
671 ((((int64_t)(a)) << (64 - DF_BITS(df)/2)) >> (64 - DF_BITS(df)/2))
673 #define UNSIGNED_EVEN(a, df) \
674 ((((uint64_t)(a)) << (64 - DF_BITS(df)/2)) >> (64 - DF_BITS(df)/2))
676 #define SIGNED_ODD(a, df) \
677 ((((int64_t)(a)) << (64 - DF_BITS(df))) >> (64 - DF_BITS(df)/2))
679 #define UNSIGNED_ODD(a, df) \
680 ((((uint64_t)(a)) << (64 - DF_BITS(df))) >> (64 - DF_BITS(df)/2))
682 #define SIGNED_EXTRACT(e, o, a, df) \
684 e = SIGNED_EVEN(a, df); \
685 o = SIGNED_ODD(a, df); \
688 #define UNSIGNED_EXTRACT(e, o, a, df) \
690 e = UNSIGNED_EVEN(a, df); \
691 o = UNSIGNED_ODD(a, df); \
694 static inline int64_t msa_dotp_s_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
700 SIGNED_EXTRACT(even_arg1
, odd_arg1
, arg1
, df
);
701 SIGNED_EXTRACT(even_arg2
, odd_arg2
, arg2
, df
);
702 return (even_arg1
* even_arg2
) + (odd_arg1
* odd_arg2
);
705 static inline int64_t msa_dotp_u_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
711 UNSIGNED_EXTRACT(even_arg1
, odd_arg1
, arg1
, df
);
712 UNSIGNED_EXTRACT(even_arg2
, odd_arg2
, arg2
, df
);
713 return (even_arg1
* even_arg2
) + (odd_arg1
* odd_arg2
);
716 #define CONCATENATE_AND_SLIDE(s, k) \
718 for (i = 0; i < s; i++) { \
719 v[i] = pws->b[s * k + i]; \
720 v[i + s] = pwd->b[s * k + i]; \
722 for (i = 0; i < s; i++) { \
723 pwd->b[s * k + i] = v[i + n]; \
727 static inline void msa_sld_df(uint32_t df
, wr_t
*pwd
,
728 wr_t
*pws
, target_ulong rt
)
730 uint32_t n
= rt
% DF_ELEMENTS(df
);
736 CONCATENATE_AND_SLIDE(DF_ELEMENTS(DF_BYTE
), 0);
739 for (k
= 0; k
< 2; k
++) {
740 CONCATENATE_AND_SLIDE(DF_ELEMENTS(DF_HALF
), k
);
744 for (k
= 0; k
< 4; k
++) {
745 CONCATENATE_AND_SLIDE(DF_ELEMENTS(DF_WORD
), k
);
749 for (k
= 0; k
< 8; k
++) {
750 CONCATENATE_AND_SLIDE(DF_ELEMENTS(DF_DOUBLE
), k
);
758 static inline int64_t msa_hadd_s_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
760 return SIGNED_ODD(arg1
, df
) + SIGNED_EVEN(arg2
, df
);
763 static inline int64_t msa_hadd_u_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
765 return UNSIGNED_ODD(arg1
, df
) + UNSIGNED_EVEN(arg2
, df
);
768 static inline int64_t msa_hsub_s_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
770 return SIGNED_ODD(arg1
, df
) - SIGNED_EVEN(arg2
, df
);
773 static inline int64_t msa_hsub_u_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
775 return UNSIGNED_ODD(arg1
, df
) - UNSIGNED_EVEN(arg2
, df
);
778 static inline int64_t msa_mul_q_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
780 int64_t q_min
= DF_MIN_INT(df
);
781 int64_t q_max
= DF_MAX_INT(df
);
783 if (arg1
== q_min
&& arg2
== q_min
) {
786 return (arg1
* arg2
) >> (DF_BITS(df
) - 1);
789 static inline int64_t msa_mulr_q_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
791 int64_t q_min
= DF_MIN_INT(df
);
792 int64_t q_max
= DF_MAX_INT(df
);
793 int64_t r_bit
= 1 << (DF_BITS(df
) - 2);
795 if (arg1
== q_min
&& arg2
== q_min
) {
798 return (arg1
* arg2
+ r_bit
) >> (DF_BITS(df
) - 1);
801 #define MSA_BINOP_DF(func) \
802 void helper_msa_ ## func ## _df(CPUMIPSState *env, uint32_t df, \
803 uint32_t wd, uint32_t ws, uint32_t wt) \
805 wr_t *pwd = &(env->active_fpu.fpr[wd].wr); \
806 wr_t *pws = &(env->active_fpu.fpr[ws].wr); \
807 wr_t *pwt = &(env->active_fpu.fpr[wt].wr); \
812 for (i = 0; i < DF_ELEMENTS(DF_BYTE); i++) { \
813 pwd->b[i] = msa_ ## func ## _df(df, pws->b[i], pwt->b[i]); \
817 for (i = 0; i < DF_ELEMENTS(DF_HALF); i++) { \
818 pwd->h[i] = msa_ ## func ## _df(df, pws->h[i], pwt->h[i]); \
822 for (i = 0; i < DF_ELEMENTS(DF_WORD); i++) { \
823 pwd->w[i] = msa_ ## func ## _df(df, pws->w[i], pwt->w[i]); \
827 for (i = 0; i < DF_ELEMENTS(DF_DOUBLE); i++) { \
828 pwd->d[i] = msa_ ## func ## _df(df, pws->d[i], pwt->d[i]); \
865 MSA_BINOP_DF(subsus_u
)
866 MSA_BINOP_DF(subsuu_s
)
887 void helper_msa_sld_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
888 uint32_t ws
, uint32_t rt
)
890 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
891 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
893 msa_sld_df(df
, pwd
, pws
, env
->active_tc
.gpr
[rt
]);
896 static inline int64_t msa_maddv_df(uint32_t df
, int64_t dest
, int64_t arg1
,
899 return dest
+ arg1
* arg2
;
902 static inline int64_t msa_msubv_df(uint32_t df
, int64_t dest
, int64_t arg1
,
905 return dest
- arg1
* arg2
;
908 static inline int64_t msa_dpadd_s_df(uint32_t df
, int64_t dest
, int64_t arg1
,
915 SIGNED_EXTRACT(even_arg1
, odd_arg1
, arg1
, df
);
916 SIGNED_EXTRACT(even_arg2
, odd_arg2
, arg2
, df
);
917 return dest
+ (even_arg1
* even_arg2
) + (odd_arg1
* odd_arg2
);
920 static inline int64_t msa_dpadd_u_df(uint32_t df
, int64_t dest
, int64_t arg1
,
927 UNSIGNED_EXTRACT(even_arg1
, odd_arg1
, arg1
, df
);
928 UNSIGNED_EXTRACT(even_arg2
, odd_arg2
, arg2
, df
);
929 return dest
+ (even_arg1
* even_arg2
) + (odd_arg1
* odd_arg2
);
932 static inline int64_t msa_dpsub_s_df(uint32_t df
, int64_t dest
, int64_t arg1
,
939 SIGNED_EXTRACT(even_arg1
, odd_arg1
, arg1
, df
);
940 SIGNED_EXTRACT(even_arg2
, odd_arg2
, arg2
, df
);
941 return dest
- ((even_arg1
* even_arg2
) + (odd_arg1
* odd_arg2
));
944 static inline int64_t msa_dpsub_u_df(uint32_t df
, int64_t dest
, int64_t arg1
,
951 UNSIGNED_EXTRACT(even_arg1
, odd_arg1
, arg1
, df
);
952 UNSIGNED_EXTRACT(even_arg2
, odd_arg2
, arg2
, df
);
953 return dest
- ((even_arg1
* even_arg2
) + (odd_arg1
* odd_arg2
));
956 static inline int64_t msa_madd_q_df(uint32_t df
, int64_t dest
, int64_t arg1
,
959 int64_t q_prod
, q_ret
;
961 int64_t q_max
= DF_MAX_INT(df
);
962 int64_t q_min
= DF_MIN_INT(df
);
964 q_prod
= arg1
* arg2
;
965 q_ret
= ((dest
<< (DF_BITS(df
) - 1)) + q_prod
) >> (DF_BITS(df
) - 1);
967 return (q_ret
< q_min
) ? q_min
: (q_max
< q_ret
) ? q_max
: q_ret
;
970 static inline int64_t msa_msub_q_df(uint32_t df
, int64_t dest
, int64_t arg1
,
973 int64_t q_prod
, q_ret
;
975 int64_t q_max
= DF_MAX_INT(df
);
976 int64_t q_min
= DF_MIN_INT(df
);
978 q_prod
= arg1
* arg2
;
979 q_ret
= ((dest
<< (DF_BITS(df
) - 1)) - q_prod
) >> (DF_BITS(df
) - 1);
981 return (q_ret
< q_min
) ? q_min
: (q_max
< q_ret
) ? q_max
: q_ret
;
984 static inline int64_t msa_maddr_q_df(uint32_t df
, int64_t dest
, int64_t arg1
,
987 int64_t q_prod
, q_ret
;
989 int64_t q_max
= DF_MAX_INT(df
);
990 int64_t q_min
= DF_MIN_INT(df
);
991 int64_t r_bit
= 1 << (DF_BITS(df
) - 2);
993 q_prod
= arg1
* arg2
;
994 q_ret
= ((dest
<< (DF_BITS(df
) - 1)) + q_prod
+ r_bit
) >> (DF_BITS(df
) - 1);
996 return (q_ret
< q_min
) ? q_min
: (q_max
< q_ret
) ? q_max
: q_ret
;
999 static inline int64_t msa_msubr_q_df(uint32_t df
, int64_t dest
, int64_t arg1
,
1002 int64_t q_prod
, q_ret
;
1004 int64_t q_max
= DF_MAX_INT(df
);
1005 int64_t q_min
= DF_MIN_INT(df
);
1006 int64_t r_bit
= 1 << (DF_BITS(df
) - 2);
1008 q_prod
= arg1
* arg2
;
1009 q_ret
= ((dest
<< (DF_BITS(df
) - 1)) - q_prod
+ r_bit
) >> (DF_BITS(df
) - 1);
1011 return (q_ret
< q_min
) ? q_min
: (q_max
< q_ret
) ? q_max
: q_ret
;
1014 #define MSA_TEROP_DF(func) \
1015 void helper_msa_ ## func ## _df(CPUMIPSState *env, uint32_t df, uint32_t wd, \
1016 uint32_t ws, uint32_t wt) \
1018 wr_t *pwd = &(env->active_fpu.fpr[wd].wr); \
1019 wr_t *pws = &(env->active_fpu.fpr[ws].wr); \
1020 wr_t *pwt = &(env->active_fpu.fpr[wt].wr); \
1025 for (i = 0; i < DF_ELEMENTS(DF_BYTE); i++) { \
1026 pwd->b[i] = msa_ ## func ## _df(df, pwd->b[i], pws->b[i], \
1031 for (i = 0; i < DF_ELEMENTS(DF_HALF); i++) { \
1032 pwd->h[i] = msa_ ## func ## _df(df, pwd->h[i], pws->h[i], \
1037 for (i = 0; i < DF_ELEMENTS(DF_WORD); i++) { \
1038 pwd->w[i] = msa_ ## func ## _df(df, pwd->w[i], pws->w[i], \
1043 for (i = 0; i < DF_ELEMENTS(DF_DOUBLE); i++) { \
1044 pwd->d[i] = msa_ ## func ## _df(df, pwd->d[i], pws->d[i], \
1055 MSA_TEROP_DF(dpadd_s
)
1056 MSA_TEROP_DF(dpadd_u
)
1057 MSA_TEROP_DF(dpsub_s
)
1058 MSA_TEROP_DF(dpsub_u
)
1061 MSA_TEROP_DF(madd_q
)
1062 MSA_TEROP_DF(msub_q
)
1063 MSA_TEROP_DF(maddr_q
)
1064 MSA_TEROP_DF(msubr_q
)
1067 static inline void msa_splat_df(uint32_t df
, wr_t
*pwd
,
1068 wr_t
*pws
, target_ulong rt
)
1070 uint32_t n
= rt
% DF_ELEMENTS(df
);
1075 for (i
= 0; i
< DF_ELEMENTS(DF_BYTE
); i
++) {
1076 pwd
->b
[i
] = pws
->b
[n
];
1080 for (i
= 0; i
< DF_ELEMENTS(DF_HALF
); i
++) {
1081 pwd
->h
[i
] = pws
->h
[n
];
1085 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
1086 pwd
->w
[i
] = pws
->w
[n
];
1090 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
1091 pwd
->d
[i
] = pws
->d
[n
];
1099 void helper_msa_splat_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
1100 uint32_t ws
, uint32_t rt
)
1102 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1103 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
1105 msa_splat_df(df
, pwd
, pws
, env
->active_tc
.gpr
[rt
]);
1108 #define MSA_DO_B MSA_DO(b)
1109 #define MSA_DO_H MSA_DO(h)
1110 #define MSA_DO_W MSA_DO(w)
1111 #define MSA_DO_D MSA_DO(d)
1113 #define MSA_LOOP_B MSA_LOOP(B)
1114 #define MSA_LOOP_H MSA_LOOP(H)
1115 #define MSA_LOOP_W MSA_LOOP(W)
1116 #define MSA_LOOP_D MSA_LOOP(D)
1118 #define MSA_LOOP_COND_B MSA_LOOP_COND(DF_BYTE)
1119 #define MSA_LOOP_COND_H MSA_LOOP_COND(DF_HALF)
1120 #define MSA_LOOP_COND_W MSA_LOOP_COND(DF_WORD)
1121 #define MSA_LOOP_COND_D MSA_LOOP_COND(DF_DOUBLE)
1123 #define MSA_LOOP(DF) \
1125 for (i = 0; i < (MSA_LOOP_COND_ ## DF) ; i++) { \
1130 #define MSA_FN_DF(FUNC) \
1131 void helper_msa_##FUNC(CPUMIPSState *env, uint32_t df, uint32_t wd, \
1132 uint32_t ws, uint32_t wt) \
1134 wr_t *pwd = &(env->active_fpu.fpr[wd].wr); \
1135 wr_t *pws = &(env->active_fpu.fpr[ws].wr); \
1136 wr_t *pwt = &(env->active_fpu.fpr[wt].wr); \
1137 wr_t wx, *pwx = &wx; \
1155 msa_move_v(pwd, pwx); \
1158 #define MSA_LOOP_COND(DF) \
1159 (DF_ELEMENTS(DF) / 2)
1161 #define Rb(pwr, i) (pwr->b[i])
1162 #define Lb(pwr, i) (pwr->b[i + DF_ELEMENTS(DF_BYTE)/2])
1163 #define Rh(pwr, i) (pwr->h[i])
1164 #define Lh(pwr, i) (pwr->h[i + DF_ELEMENTS(DF_HALF)/2])
1165 #define Rw(pwr, i) (pwr->w[i])
1166 #define Lw(pwr, i) (pwr->w[i + DF_ELEMENTS(DF_WORD)/2])
1167 #define Rd(pwr, i) (pwr->d[i])
1168 #define Ld(pwr, i) (pwr->d[i + DF_ELEMENTS(DF_DOUBLE)/2])
1170 #define MSA_DO(DF) \
1172 R##DF(pwx, i) = pwt->DF[2*i]; \
1173 L##DF(pwx, i) = pws->DF[2*i]; \
1178 #define MSA_DO(DF) \
1180 R##DF(pwx, i) = pwt->DF[2*i+1]; \
1181 L##DF(pwx, i) = pws->DF[2*i+1]; \
1186 #define MSA_DO(DF) \
1188 pwx->DF[2*i] = L##DF(pwt, i); \
1189 pwx->DF[2*i+1] = L##DF(pws, i); \
1194 #define MSA_DO(DF) \
1196 pwx->DF[2*i] = R##DF(pwt, i); \
1197 pwx->DF[2*i+1] = R##DF(pws, i); \
1202 #define MSA_DO(DF) \
1204 pwx->DF[2*i] = pwt->DF[2*i]; \
1205 pwx->DF[2*i+1] = pws->DF[2*i]; \
1210 #define MSA_DO(DF) \
1212 pwx->DF[2*i] = pwt->DF[2*i+1]; \
1213 pwx->DF[2*i+1] = pws->DF[2*i+1]; \
1217 #undef MSA_LOOP_COND
1219 #define MSA_LOOP_COND(DF) \
1222 #define MSA_DO(DF) \
1224 uint32_t n = DF_ELEMENTS(df); \
1225 uint32_t k = (pwd->DF[i] & 0x3f) % (2 * n); \
1227 (pwd->DF[i] & 0xc0) ? 0 : k < n ? pwt->DF[k] : pws->DF[k - n]; \
1231 #undef MSA_LOOP_COND
1234 void helper_msa_sldi_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
1235 uint32_t ws
, uint32_t n
)
1237 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1238 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
1240 msa_sld_df(df
, pwd
, pws
, n
);
1243 void helper_msa_splati_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
1244 uint32_t ws
, uint32_t n
)
1246 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1247 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
1249 msa_splat_df(df
, pwd
, pws
, n
);
1252 void helper_msa_copy_s_b(CPUMIPSState
*env
, uint32_t rd
,
1253 uint32_t ws
, uint32_t n
)
1256 #if defined(HOST_WORDS_BIGENDIAN)
1263 env
->active_tc
.gpr
[rd
] = (int8_t)env
->active_fpu
.fpr
[ws
].wr
.b
[n
];
1266 void helper_msa_copy_s_h(CPUMIPSState
*env
, uint32_t rd
,
1267 uint32_t ws
, uint32_t n
)
1270 #if defined(HOST_WORDS_BIGENDIAN)
1277 env
->active_tc
.gpr
[rd
] = (int16_t)env
->active_fpu
.fpr
[ws
].wr
.h
[n
];
1280 void helper_msa_copy_s_w(CPUMIPSState
*env
, uint32_t rd
,
1281 uint32_t ws
, uint32_t n
)
1284 #if defined(HOST_WORDS_BIGENDIAN)
1291 env
->active_tc
.gpr
[rd
] = (int32_t)env
->active_fpu
.fpr
[ws
].wr
.w
[n
];
1294 void helper_msa_copy_s_d(CPUMIPSState
*env
, uint32_t rd
,
1295 uint32_t ws
, uint32_t n
)
1298 env
->active_tc
.gpr
[rd
] = (int64_t)env
->active_fpu
.fpr
[ws
].wr
.d
[n
];
1301 void helper_msa_copy_u_b(CPUMIPSState
*env
, uint32_t rd
,
1302 uint32_t ws
, uint32_t n
)
1305 #if defined(HOST_WORDS_BIGENDIAN)
1312 env
->active_tc
.gpr
[rd
] = (uint8_t)env
->active_fpu
.fpr
[ws
].wr
.b
[n
];
1315 void helper_msa_copy_u_h(CPUMIPSState
*env
, uint32_t rd
,
1316 uint32_t ws
, uint32_t n
)
1319 #if defined(HOST_WORDS_BIGENDIAN)
1326 env
->active_tc
.gpr
[rd
] = (uint16_t)env
->active_fpu
.fpr
[ws
].wr
.h
[n
];
1329 void helper_msa_copy_u_w(CPUMIPSState
*env
, uint32_t rd
,
1330 uint32_t ws
, uint32_t n
)
1333 #if defined(HOST_WORDS_BIGENDIAN)
1340 env
->active_tc
.gpr
[rd
] = (uint32_t)env
->active_fpu
.fpr
[ws
].wr
.w
[n
];
1343 void helper_msa_insert_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
1344 uint32_t rs_num
, uint32_t n
)
1346 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1347 target_ulong rs
= env
->active_tc
.gpr
[rs_num
];
1351 pwd
->b
[n
] = (int8_t)rs
;
1354 pwd
->h
[n
] = (int16_t)rs
;
1357 pwd
->w
[n
] = (int32_t)rs
;
1360 pwd
->d
[n
] = (int64_t)rs
;
1367 void helper_msa_insve_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
1368 uint32_t ws
, uint32_t n
)
1370 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1371 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
1375 pwd
->b
[n
] = (int8_t)pws
->b
[0];
1378 pwd
->h
[n
] = (int16_t)pws
->h
[0];
1381 pwd
->w
[n
] = (int32_t)pws
->w
[0];
1384 pwd
->d
[n
] = (int64_t)pws
->d
[0];
1391 void helper_msa_ctcmsa(CPUMIPSState
*env
, target_ulong elm
, uint32_t cd
)
1397 env
->active_tc
.msacsr
= (int32_t)elm
& MSACSR_MASK
;
1398 restore_msa_fp_status(env
);
1399 /* check exception */
1400 if ((GET_FP_ENABLE(env
->active_tc
.msacsr
) | FP_UNIMPLEMENTED
)
1401 & GET_FP_CAUSE(env
->active_tc
.msacsr
)) {
1402 do_raise_exception(env
, EXCP_MSAFPE
, GETPC());
1408 target_ulong
helper_msa_cfcmsa(CPUMIPSState
*env
, uint32_t cs
)
1414 return env
->active_tc
.msacsr
& MSACSR_MASK
;
1419 void helper_msa_move_v(CPUMIPSState
*env
, uint32_t wd
, uint32_t ws
)
1421 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1422 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
1424 msa_move_v(pwd
, pws
);
1427 static inline int64_t msa_pcnt_df(uint32_t df
, int64_t arg
)
1431 x
= UNSIGNED(arg
, df
);
1433 x
= (x
& 0x5555555555555555ULL
) + ((x
>> 1) & 0x5555555555555555ULL
);
1434 x
= (x
& 0x3333333333333333ULL
) + ((x
>> 2) & 0x3333333333333333ULL
);
1435 x
= (x
& 0x0F0F0F0F0F0F0F0FULL
) + ((x
>> 4) & 0x0F0F0F0F0F0F0F0FULL
);
1436 x
= (x
& 0x00FF00FF00FF00FFULL
) + ((x
>> 8) & 0x00FF00FF00FF00FFULL
);
1437 x
= (x
& 0x0000FFFF0000FFFFULL
) + ((x
>> 16) & 0x0000FFFF0000FFFFULL
);
1438 x
= (x
& 0x00000000FFFFFFFFULL
) + ((x
>> 32));
1443 static inline int64_t msa_nlzc_df(uint32_t df
, int64_t arg
)
1448 x
= UNSIGNED(arg
, df
);
1450 c
= DF_BITS(df
) / 2;
1464 static inline int64_t msa_nloc_df(uint32_t df
, int64_t arg
)
1466 return msa_nlzc_df(df
, UNSIGNED((~arg
), df
));
1469 void helper_msa_fill_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
1472 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1477 for (i
= 0; i
< DF_ELEMENTS(DF_BYTE
); i
++) {
1478 pwd
->b
[i
] = (int8_t)env
->active_tc
.gpr
[rs
];
1482 for (i
= 0; i
< DF_ELEMENTS(DF_HALF
); i
++) {
1483 pwd
->h
[i
] = (int16_t)env
->active_tc
.gpr
[rs
];
1487 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
1488 pwd
->w
[i
] = (int32_t)env
->active_tc
.gpr
[rs
];
1492 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
1493 pwd
->d
[i
] = (int64_t)env
->active_tc
.gpr
[rs
];
1501 #define MSA_UNOP_DF(func) \
1502 void helper_msa_ ## func ## _df(CPUMIPSState *env, uint32_t df, \
1503 uint32_t wd, uint32_t ws) \
1505 wr_t *pwd = &(env->active_fpu.fpr[wd].wr); \
1506 wr_t *pws = &(env->active_fpu.fpr[ws].wr); \
1511 for (i = 0; i < DF_ELEMENTS(DF_BYTE); i++) { \
1512 pwd->b[i] = msa_ ## func ## _df(df, pws->b[i]); \
1516 for (i = 0; i < DF_ELEMENTS(DF_HALF); i++) { \
1517 pwd->h[i] = msa_ ## func ## _df(df, pws->h[i]); \
1521 for (i = 0; i < DF_ELEMENTS(DF_WORD); i++) { \
1522 pwd->w[i] = msa_ ## func ## _df(df, pws->w[i]); \
1526 for (i = 0; i < DF_ELEMENTS(DF_DOUBLE); i++) { \
1527 pwd->d[i] = msa_ ## func ## _df(df, pws->d[i]); \
1540 #define FLOAT_ONE32 make_float32(0x3f8 << 20)
1541 #define FLOAT_ONE64 make_float64(0x3ffULL << 52)
1543 #define FLOAT_SNAN16(s) (float16_default_nan(s) ^ 0x0220)
1545 #define FLOAT_SNAN32(s) (float32_default_nan(s) ^ 0x00400020)
1547 #define FLOAT_SNAN64(s) (float64_default_nan(s) ^ 0x0008000000000020ULL)
1548 /* 0x7ff0000000000020 */
1550 static inline void clear_msacsr_cause(CPUMIPSState
*env
)
1552 SET_FP_CAUSE(env
->active_tc
.msacsr
, 0);
1555 static inline void check_msacsr_cause(CPUMIPSState
*env
, uintptr_t retaddr
)
1557 if ((GET_FP_CAUSE(env
->active_tc
.msacsr
) &
1558 (GET_FP_ENABLE(env
->active_tc
.msacsr
) | FP_UNIMPLEMENTED
)) == 0) {
1559 UPDATE_FP_FLAGS(env
->active_tc
.msacsr
,
1560 GET_FP_CAUSE(env
->active_tc
.msacsr
));
1562 do_raise_exception(env
, EXCP_MSAFPE
, retaddr
);
1566 /* Flush-to-zero use cases for update_msacsr() */
1567 #define CLEAR_FS_UNDERFLOW 1
1568 #define CLEAR_IS_INEXACT 2
1569 #define RECIPROCAL_INEXACT 4
1571 static inline int update_msacsr(CPUMIPSState
*env
, int action
, int denormal
)
1579 ieee_ex
= get_float_exception_flags(&env
->active_tc
.msa_fp_status
);
1581 /* QEMU softfloat does not signal all underflow cases */
1583 ieee_ex
|= float_flag_underflow
;
1586 c
= ieee_ex_to_mips(ieee_ex
);
1587 enable
= GET_FP_ENABLE(env
->active_tc
.msacsr
) | FP_UNIMPLEMENTED
;
1589 /* Set Inexact (I) when flushing inputs to zero */
1590 if ((ieee_ex
& float_flag_input_denormal
) &&
1591 (env
->active_tc
.msacsr
& MSACSR_FS_MASK
) != 0) {
1592 if (action
& CLEAR_IS_INEXACT
) {
1599 /* Set Inexact (I) and Underflow (U) when flushing outputs to zero */
1600 if ((ieee_ex
& float_flag_output_denormal
) &&
1601 (env
->active_tc
.msacsr
& MSACSR_FS_MASK
) != 0) {
1603 if (action
& CLEAR_FS_UNDERFLOW
) {
1610 /* Set Inexact (I) when Overflow (O) is not enabled */
1611 if ((c
& FP_OVERFLOW
) != 0 && (enable
& FP_OVERFLOW
) == 0) {
1615 /* Clear Exact Underflow when Underflow (U) is not enabled */
1616 if ((c
& FP_UNDERFLOW
) != 0 && (enable
& FP_UNDERFLOW
) == 0 &&
1617 (c
& FP_INEXACT
) == 0) {
1621 /* Reciprocal operations set only Inexact when valid and not
1623 if ((action
& RECIPROCAL_INEXACT
) &&
1624 (c
& (FP_INVALID
| FP_DIV0
)) == 0) {
1628 cause
= c
& enable
; /* all current enabled exceptions */
1631 /* No enabled exception, update the MSACSR Cause
1632 with all current exceptions */
1633 SET_FP_CAUSE(env
->active_tc
.msacsr
,
1634 (GET_FP_CAUSE(env
->active_tc
.msacsr
) | c
));
1636 /* Current exceptions are enabled */
1637 if ((env
->active_tc
.msacsr
& MSACSR_NX_MASK
) == 0) {
1638 /* Exception(s) will trap, update MSACSR Cause
1639 with all enabled exceptions */
1640 SET_FP_CAUSE(env
->active_tc
.msacsr
,
1641 (GET_FP_CAUSE(env
->active_tc
.msacsr
) | c
));
1648 static inline int get_enabled_exceptions(const CPUMIPSState
*env
, int c
)
1650 int enable
= GET_FP_ENABLE(env
->active_tc
.msacsr
) | FP_UNIMPLEMENTED
;
1654 static inline float16
float16_from_float32(int32_t a
, flag ieee
,
1655 float_status
*status
)
1659 f_val
= float32_to_float16((float32
)a
, ieee
, status
);
1661 return a
< 0 ? (f_val
| (1 << 15)) : f_val
;
1664 static inline float32
float32_from_float64(int64_t a
, float_status
*status
)
1668 f_val
= float64_to_float32((float64
)a
, status
);
1670 return a
< 0 ? (f_val
| (1 << 31)) : f_val
;
1673 static inline float32
float32_from_float16(int16_t a
, flag ieee
,
1674 float_status
*status
)
1678 f_val
= float16_to_float32((float16
)a
, ieee
, status
);
1680 return a
< 0 ? (f_val
| (1 << 31)) : f_val
;
1683 static inline float64
float64_from_float32(int32_t a
, float_status
*status
)
1687 f_val
= float32_to_float64((float64
)a
, status
);
1689 return a
< 0 ? (f_val
| (1ULL << 63)) : f_val
;
1692 static inline float32
float32_from_q16(int16_t a
, float_status
*status
)
1696 /* conversion as integer and scaling */
1697 f_val
= int32_to_float32(a
, status
);
1698 f_val
= float32_scalbn(f_val
, -15, status
);
1703 static inline float64
float64_from_q32(int32_t a
, float_status
*status
)
1707 /* conversion as integer and scaling */
1708 f_val
= int32_to_float64(a
, status
);
1709 f_val
= float64_scalbn(f_val
, -31, status
);
1714 static inline int16_t float32_to_q16(float32 a
, float_status
*status
)
1717 int32_t q_min
= 0xffff8000;
1718 int32_t q_max
= 0x00007fff;
1722 if (float32_is_any_nan(a
)) {
1723 float_raise(float_flag_invalid
, status
);
1728 a
= float32_scalbn(a
, 15, status
);
1730 ieee_ex
= get_float_exception_flags(status
);
1731 set_float_exception_flags(ieee_ex
& (~float_flag_underflow
)
1734 if (ieee_ex
& float_flag_overflow
) {
1735 float_raise(float_flag_inexact
, status
);
1736 return (int32_t)a
< 0 ? q_min
: q_max
;
1739 /* conversion to int */
1740 q_val
= float32_to_int32(a
, status
);
1742 ieee_ex
= get_float_exception_flags(status
);
1743 set_float_exception_flags(ieee_ex
& (~float_flag_underflow
)
1746 if (ieee_ex
& float_flag_invalid
) {
1747 set_float_exception_flags(ieee_ex
& (~float_flag_invalid
)
1749 float_raise(float_flag_overflow
| float_flag_inexact
, status
);
1750 return (int32_t)a
< 0 ? q_min
: q_max
;
1753 if (q_val
< q_min
) {
1754 float_raise(float_flag_overflow
| float_flag_inexact
, status
);
1755 return (int16_t)q_min
;
1758 if (q_max
< q_val
) {
1759 float_raise(float_flag_overflow
| float_flag_inexact
, status
);
1760 return (int16_t)q_max
;
1763 return (int16_t)q_val
;
1766 static inline int32_t float64_to_q32(float64 a
, float_status
*status
)
1769 int64_t q_min
= 0xffffffff80000000LL
;
1770 int64_t q_max
= 0x000000007fffffffLL
;
1774 if (float64_is_any_nan(a
)) {
1775 float_raise(float_flag_invalid
, status
);
1780 a
= float64_scalbn(a
, 31, status
);
1782 ieee_ex
= get_float_exception_flags(status
);
1783 set_float_exception_flags(ieee_ex
& (~float_flag_underflow
)
1786 if (ieee_ex
& float_flag_overflow
) {
1787 float_raise(float_flag_inexact
, status
);
1788 return (int64_t)a
< 0 ? q_min
: q_max
;
1791 /* conversion to integer */
1792 q_val
= float64_to_int64(a
, status
);
1794 ieee_ex
= get_float_exception_flags(status
);
1795 set_float_exception_flags(ieee_ex
& (~float_flag_underflow
)
1798 if (ieee_ex
& float_flag_invalid
) {
1799 set_float_exception_flags(ieee_ex
& (~float_flag_invalid
)
1801 float_raise(float_flag_overflow
| float_flag_inexact
, status
);
1802 return (int64_t)a
< 0 ? q_min
: q_max
;
1805 if (q_val
< q_min
) {
1806 float_raise(float_flag_overflow
| float_flag_inexact
, status
);
1807 return (int32_t)q_min
;
1810 if (q_max
< q_val
) {
1811 float_raise(float_flag_overflow
| float_flag_inexact
, status
);
1812 return (int32_t)q_max
;
1815 return (int32_t)q_val
;
1818 #define MSA_FLOAT_COND(DEST, OP, ARG1, ARG2, BITS, QUIET) \
1820 float_status *status = &env->active_tc.msa_fp_status; \
1823 set_float_exception_flags(0, status); \
1825 cond = float ## BITS ## _ ## OP(ARG1, ARG2, status); \
1827 cond = float ## BITS ## _ ## OP ## _quiet(ARG1, ARG2, status); \
1829 DEST = cond ? M_MAX_UINT(BITS) : 0; \
1830 c = update_msacsr(env, CLEAR_IS_INEXACT, 0); \
1832 if (get_enabled_exceptions(env, c)) { \
1833 DEST = ((FLOAT_SNAN ## BITS(status) >> 6) << 6) | c; \
1837 #define MSA_FLOAT_AF(DEST, ARG1, ARG2, BITS, QUIET) \
1839 MSA_FLOAT_COND(DEST, eq, ARG1, ARG2, BITS, QUIET); \
1840 if ((DEST & M_MAX_UINT(BITS)) == M_MAX_UINT(BITS)) { \
1845 #define MSA_FLOAT_UEQ(DEST, ARG1, ARG2, BITS, QUIET) \
1847 MSA_FLOAT_COND(DEST, unordered, ARG1, ARG2, BITS, QUIET); \
1849 MSA_FLOAT_COND(DEST, eq, ARG1, ARG2, BITS, QUIET); \
1853 #define MSA_FLOAT_NE(DEST, ARG1, ARG2, BITS, QUIET) \
1855 MSA_FLOAT_COND(DEST, lt, ARG1, ARG2, BITS, QUIET); \
1857 MSA_FLOAT_COND(DEST, lt, ARG2, ARG1, BITS, QUIET); \
1861 #define MSA_FLOAT_UNE(DEST, ARG1, ARG2, BITS, QUIET) \
1863 MSA_FLOAT_COND(DEST, unordered, ARG1, ARG2, BITS, QUIET); \
1865 MSA_FLOAT_COND(DEST, lt, ARG1, ARG2, BITS, QUIET); \
1867 MSA_FLOAT_COND(DEST, lt, ARG2, ARG1, BITS, QUIET); \
1872 #define MSA_FLOAT_ULE(DEST, ARG1, ARG2, BITS, QUIET) \
1874 MSA_FLOAT_COND(DEST, unordered, ARG1, ARG2, BITS, QUIET); \
1876 MSA_FLOAT_COND(DEST, le, ARG1, ARG2, BITS, QUIET); \
1880 #define MSA_FLOAT_ULT(DEST, ARG1, ARG2, BITS, QUIET) \
1882 MSA_FLOAT_COND(DEST, unordered, ARG1, ARG2, BITS, QUIET); \
1884 MSA_FLOAT_COND(DEST, lt, ARG1, ARG2, BITS, QUIET); \
1888 #define MSA_FLOAT_OR(DEST, ARG1, ARG2, BITS, QUIET) \
1890 MSA_FLOAT_COND(DEST, le, ARG1, ARG2, BITS, QUIET); \
1892 MSA_FLOAT_COND(DEST, le, ARG2, ARG1, BITS, QUIET); \
1896 static inline void compare_af(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
1897 wr_t
*pwt
, uint32_t df
, int quiet
,
1900 wr_t wx
, *pwx
= &wx
;
1903 clear_msacsr_cause(env
);
1907 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
1908 MSA_FLOAT_AF(pwx
->w
[i
], pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
1912 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
1913 MSA_FLOAT_AF(pwx
->d
[i
], pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
1920 check_msacsr_cause(env
, retaddr
);
1922 msa_move_v(pwd
, pwx
);
1925 static inline void compare_un(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
1926 wr_t
*pwt
, uint32_t df
, int quiet
,
1929 wr_t wx
, *pwx
= &wx
;
1932 clear_msacsr_cause(env
);
1936 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
1937 MSA_FLOAT_COND(pwx
->w
[i
], unordered
, pws
->w
[i
], pwt
->w
[i
], 32,
1942 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
1943 MSA_FLOAT_COND(pwx
->d
[i
], unordered
, pws
->d
[i
], pwt
->d
[i
], 64,
1951 check_msacsr_cause(env
, retaddr
);
1953 msa_move_v(pwd
, pwx
);
1956 static inline void compare_eq(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
1957 wr_t
*pwt
, uint32_t df
, int quiet
,
1960 wr_t wx
, *pwx
= &wx
;
1963 clear_msacsr_cause(env
);
1967 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
1968 MSA_FLOAT_COND(pwx
->w
[i
], eq
, pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
1972 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
1973 MSA_FLOAT_COND(pwx
->d
[i
], eq
, pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
1980 check_msacsr_cause(env
, retaddr
);
1982 msa_move_v(pwd
, pwx
);
1985 static inline void compare_ueq(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
1986 wr_t
*pwt
, uint32_t df
, int quiet
,
1989 wr_t wx
, *pwx
= &wx
;
1992 clear_msacsr_cause(env
);
1996 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
1997 MSA_FLOAT_UEQ(pwx
->w
[i
], pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
2001 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2002 MSA_FLOAT_UEQ(pwx
->d
[i
], pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
2009 check_msacsr_cause(env
, retaddr
);
2011 msa_move_v(pwd
, pwx
);
2014 static inline void compare_lt(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
2015 wr_t
*pwt
, uint32_t df
, int quiet
,
2018 wr_t wx
, *pwx
= &wx
;
2021 clear_msacsr_cause(env
);
2025 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2026 MSA_FLOAT_COND(pwx
->w
[i
], lt
, pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
2030 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2031 MSA_FLOAT_COND(pwx
->d
[i
], lt
, pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
2038 check_msacsr_cause(env
, retaddr
);
2040 msa_move_v(pwd
, pwx
);
2043 static inline void compare_ult(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
2044 wr_t
*pwt
, uint32_t df
, int quiet
,
2047 wr_t wx
, *pwx
= &wx
;
2050 clear_msacsr_cause(env
);
2054 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2055 MSA_FLOAT_ULT(pwx
->w
[i
], pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
2059 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2060 MSA_FLOAT_ULT(pwx
->d
[i
], pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
2067 check_msacsr_cause(env
, retaddr
);
2069 msa_move_v(pwd
, pwx
);
2072 static inline void compare_le(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
2073 wr_t
*pwt
, uint32_t df
, int quiet
,
2076 wr_t wx
, *pwx
= &wx
;
2079 clear_msacsr_cause(env
);
2083 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2084 MSA_FLOAT_COND(pwx
->w
[i
], le
, pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
2088 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2089 MSA_FLOAT_COND(pwx
->d
[i
], le
, pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
2096 check_msacsr_cause(env
, retaddr
);
2098 msa_move_v(pwd
, pwx
);
2101 static inline void compare_ule(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
2102 wr_t
*pwt
, uint32_t df
, int quiet
,
2105 wr_t wx
, *pwx
= &wx
;
2108 clear_msacsr_cause(env
);
2112 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2113 MSA_FLOAT_ULE(pwx
->w
[i
], pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
2117 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2118 MSA_FLOAT_ULE(pwx
->d
[i
], pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
2125 check_msacsr_cause(env
, retaddr
);
2127 msa_move_v(pwd
, pwx
);
2130 static inline void compare_or(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
2131 wr_t
*pwt
, uint32_t df
, int quiet
,
2134 wr_t wx
, *pwx
= &wx
;
2137 clear_msacsr_cause(env
);
2141 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2142 MSA_FLOAT_OR(pwx
->w
[i
], pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
2146 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2147 MSA_FLOAT_OR(pwx
->d
[i
], pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
2154 check_msacsr_cause(env
, retaddr
);
2156 msa_move_v(pwd
, pwx
);
2159 static inline void compare_une(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
2160 wr_t
*pwt
, uint32_t df
, int quiet
,
2163 wr_t wx
, *pwx
= &wx
;
2166 clear_msacsr_cause(env
);
2170 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2171 MSA_FLOAT_UNE(pwx
->w
[i
], pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
2175 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2176 MSA_FLOAT_UNE(pwx
->d
[i
], pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
2183 check_msacsr_cause(env
, retaddr
);
2185 msa_move_v(pwd
, pwx
);
2188 static inline void compare_ne(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
2189 wr_t
*pwt
, uint32_t df
, int quiet
,
2192 wr_t wx
, *pwx
= &wx
;
2195 clear_msacsr_cause(env
);
2199 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2200 MSA_FLOAT_NE(pwx
->w
[i
], pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
2204 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2205 MSA_FLOAT_NE(pwx
->d
[i
], pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
2212 check_msacsr_cause(env
, retaddr
);
2214 msa_move_v(pwd
, pwx
);
2217 void helper_msa_fcaf_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2218 uint32_t ws
, uint32_t wt
)
2220 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2221 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2222 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2223 compare_af(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2226 void helper_msa_fcun_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2227 uint32_t ws
, uint32_t wt
)
2229 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2230 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2231 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2232 compare_un(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2235 void helper_msa_fceq_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2236 uint32_t ws
, uint32_t wt
)
2238 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2239 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2240 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2241 compare_eq(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2244 void helper_msa_fcueq_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2245 uint32_t ws
, uint32_t wt
)
2247 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2248 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2249 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2250 compare_ueq(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2253 void helper_msa_fclt_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2254 uint32_t ws
, uint32_t wt
)
2256 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2257 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2258 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2259 compare_lt(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2262 void helper_msa_fcult_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2263 uint32_t ws
, uint32_t wt
)
2265 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2266 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2267 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2268 compare_ult(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2271 void helper_msa_fcle_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2272 uint32_t ws
, uint32_t wt
)
2274 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2275 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2276 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2277 compare_le(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2280 void helper_msa_fcule_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2281 uint32_t ws
, uint32_t wt
)
2283 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2284 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2285 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2286 compare_ule(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2289 void helper_msa_fsaf_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2290 uint32_t ws
, uint32_t wt
)
2292 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2293 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2294 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2295 compare_af(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2298 void helper_msa_fsun_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2299 uint32_t ws
, uint32_t wt
)
2301 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2302 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2303 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2304 compare_un(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2307 void helper_msa_fseq_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2308 uint32_t ws
, uint32_t wt
)
2310 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2311 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2312 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2313 compare_eq(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2316 void helper_msa_fsueq_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2317 uint32_t ws
, uint32_t wt
)
2319 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2320 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2321 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2322 compare_ueq(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2325 void helper_msa_fslt_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2326 uint32_t ws
, uint32_t wt
)
2328 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2329 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2330 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2331 compare_lt(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2334 void helper_msa_fsult_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2335 uint32_t ws
, uint32_t wt
)
2337 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2338 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2339 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2340 compare_ult(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2343 void helper_msa_fsle_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2344 uint32_t ws
, uint32_t wt
)
2346 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2347 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2348 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2349 compare_le(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2352 void helper_msa_fsule_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2353 uint32_t ws
, uint32_t wt
)
2355 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2356 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2357 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2358 compare_ule(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2361 void helper_msa_fcor_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2362 uint32_t ws
, uint32_t wt
)
2364 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2365 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2366 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2367 compare_or(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2370 void helper_msa_fcune_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2371 uint32_t ws
, uint32_t wt
)
2373 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2374 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2375 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2376 compare_une(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2379 void helper_msa_fcne_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2380 uint32_t ws
, uint32_t wt
)
2382 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2383 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2384 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2385 compare_ne(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2388 void helper_msa_fsor_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2389 uint32_t ws
, uint32_t wt
)
2391 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2392 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2393 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2394 compare_or(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2397 void helper_msa_fsune_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2398 uint32_t ws
, uint32_t wt
)
2400 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2401 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2402 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2403 compare_une(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2406 void helper_msa_fsne_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2407 uint32_t ws
, uint32_t wt
)
2409 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2410 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2411 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2412 compare_ne(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2415 #define float16_is_zero(ARG) 0
2416 #define float16_is_zero_or_denormal(ARG) 0
2418 #define IS_DENORMAL(ARG, BITS) \
2419 (!float ## BITS ## _is_zero(ARG) \
2420 && float ## BITS ## _is_zero_or_denormal(ARG))
2422 #define MSA_FLOAT_BINOP(DEST, OP, ARG1, ARG2, BITS) \
2424 float_status *status = &env->active_tc.msa_fp_status; \
2427 set_float_exception_flags(0, status); \
2428 DEST = float ## BITS ## _ ## OP(ARG1, ARG2, status); \
2429 c = update_msacsr(env, 0, IS_DENORMAL(DEST, BITS)); \
2431 if (get_enabled_exceptions(env, c)) { \
2432 DEST = ((FLOAT_SNAN ## BITS(status) >> 6) << 6) | c; \
2436 void helper_msa_fadd_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2437 uint32_t ws
, uint32_t wt
)
2439 wr_t wx
, *pwx
= &wx
;
2440 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2441 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2442 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2445 clear_msacsr_cause(env
);
2449 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2450 MSA_FLOAT_BINOP(pwx
->w
[i
], add
, pws
->w
[i
], pwt
->w
[i
], 32);
2454 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2455 MSA_FLOAT_BINOP(pwx
->d
[i
], add
, pws
->d
[i
], pwt
->d
[i
], 64);
2462 check_msacsr_cause(env
, GETPC());
2463 msa_move_v(pwd
, pwx
);
2466 void helper_msa_fsub_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2467 uint32_t ws
, uint32_t wt
)
2469 wr_t wx
, *pwx
= &wx
;
2470 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2471 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2472 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2475 clear_msacsr_cause(env
);
2479 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2480 MSA_FLOAT_BINOP(pwx
->w
[i
], sub
, pws
->w
[i
], pwt
->w
[i
], 32);
2484 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2485 MSA_FLOAT_BINOP(pwx
->d
[i
], sub
, pws
->d
[i
], pwt
->d
[i
], 64);
2492 check_msacsr_cause(env
, GETPC());
2493 msa_move_v(pwd
, pwx
);
2496 void helper_msa_fmul_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2497 uint32_t ws
, uint32_t wt
)
2499 wr_t wx
, *pwx
= &wx
;
2500 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2501 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2502 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2505 clear_msacsr_cause(env
);
2509 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2510 MSA_FLOAT_BINOP(pwx
->w
[i
], mul
, pws
->w
[i
], pwt
->w
[i
], 32);
2514 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2515 MSA_FLOAT_BINOP(pwx
->d
[i
], mul
, pws
->d
[i
], pwt
->d
[i
], 64);
2522 check_msacsr_cause(env
, GETPC());
2524 msa_move_v(pwd
, pwx
);
2527 void helper_msa_fdiv_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2528 uint32_t ws
, uint32_t wt
)
2530 wr_t wx
, *pwx
= &wx
;
2531 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2532 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2533 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2536 clear_msacsr_cause(env
);
2540 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2541 MSA_FLOAT_BINOP(pwx
->w
[i
], div
, pws
->w
[i
], pwt
->w
[i
], 32);
2545 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2546 MSA_FLOAT_BINOP(pwx
->d
[i
], div
, pws
->d
[i
], pwt
->d
[i
], 64);
2553 check_msacsr_cause(env
, GETPC());
2555 msa_move_v(pwd
, pwx
);
2558 #define MSA_FLOAT_MULADD(DEST, ARG1, ARG2, ARG3, NEGATE, BITS) \
2560 float_status *status = &env->active_tc.msa_fp_status; \
2563 set_float_exception_flags(0, status); \
2564 DEST = float ## BITS ## _muladd(ARG2, ARG3, ARG1, NEGATE, status); \
2565 c = update_msacsr(env, 0, IS_DENORMAL(DEST, BITS)); \
2567 if (get_enabled_exceptions(env, c)) { \
2568 DEST = ((FLOAT_SNAN ## BITS(status) >> 6) << 6) | c; \
2572 void helper_msa_fmadd_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2573 uint32_t ws
, uint32_t wt
)
2575 wr_t wx
, *pwx
= &wx
;
2576 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2577 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2578 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2581 clear_msacsr_cause(env
);
2585 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2586 MSA_FLOAT_MULADD(pwx
->w
[i
], pwd
->w
[i
],
2587 pws
->w
[i
], pwt
->w
[i
], 0, 32);
2591 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2592 MSA_FLOAT_MULADD(pwx
->d
[i
], pwd
->d
[i
],
2593 pws
->d
[i
], pwt
->d
[i
], 0, 64);
2600 check_msacsr_cause(env
, GETPC());
2602 msa_move_v(pwd
, pwx
);
2605 void helper_msa_fmsub_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2606 uint32_t ws
, uint32_t wt
)
2608 wr_t wx
, *pwx
= &wx
;
2609 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2610 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2611 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2614 clear_msacsr_cause(env
);
2618 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2619 MSA_FLOAT_MULADD(pwx
->w
[i
], pwd
->w
[i
],
2620 pws
->w
[i
], pwt
->w
[i
],
2621 float_muladd_negate_product
, 32);
2625 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2626 MSA_FLOAT_MULADD(pwx
->d
[i
], pwd
->d
[i
],
2627 pws
->d
[i
], pwt
->d
[i
],
2628 float_muladd_negate_product
, 64);
2635 check_msacsr_cause(env
, GETPC());
2637 msa_move_v(pwd
, pwx
);
2640 void helper_msa_fexp2_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2641 uint32_t ws
, uint32_t wt
)
2643 wr_t wx
, *pwx
= &wx
;
2644 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2645 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2646 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2649 clear_msacsr_cause(env
);
2653 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2654 MSA_FLOAT_BINOP(pwx
->w
[i
], scalbn
, pws
->w
[i
],
2655 pwt
->w
[i
] > 0x200 ? 0x200 :
2656 pwt
->w
[i
] < -0x200 ? -0x200 : pwt
->w
[i
],
2661 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2662 MSA_FLOAT_BINOP(pwx
->d
[i
], scalbn
, pws
->d
[i
],
2663 pwt
->d
[i
] > 0x1000 ? 0x1000 :
2664 pwt
->d
[i
] < -0x1000 ? -0x1000 : pwt
->d
[i
],
2672 check_msacsr_cause(env
, GETPC());
2674 msa_move_v(pwd
, pwx
);
2677 #define MSA_FLOAT_UNOP(DEST, OP, ARG, BITS) \
2679 float_status *status = &env->active_tc.msa_fp_status; \
2682 set_float_exception_flags(0, status); \
2683 DEST = float ## BITS ## _ ## OP(ARG, status); \
2684 c = update_msacsr(env, 0, IS_DENORMAL(DEST, BITS)); \
2686 if (get_enabled_exceptions(env, c)) { \
2687 DEST = ((FLOAT_SNAN ## BITS(status) >> 6) << 6) | c; \
2691 void helper_msa_fexdo_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2692 uint32_t ws
, uint32_t wt
)
2694 wr_t wx
, *pwx
= &wx
;
2695 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2696 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2697 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2700 clear_msacsr_cause(env
);
2704 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2705 /* Half precision floats come in two formats: standard
2706 IEEE and "ARM" format. The latter gains extra exponent
2707 range by omitting the NaN/Inf encodings. */
2710 MSA_FLOAT_BINOP(Lh(pwx
, i
), from_float32
, pws
->w
[i
], ieee
, 16);
2711 MSA_FLOAT_BINOP(Rh(pwx
, i
), from_float32
, pwt
->w
[i
], ieee
, 16);
2715 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2716 MSA_FLOAT_UNOP(Lw(pwx
, i
), from_float64
, pws
->d
[i
], 32);
2717 MSA_FLOAT_UNOP(Rw(pwx
, i
), from_float64
, pwt
->d
[i
], 32);
2724 check_msacsr_cause(env
, GETPC());
2725 msa_move_v(pwd
, pwx
);
2728 #define MSA_FLOAT_UNOP_XD(DEST, OP, ARG, BITS, XBITS) \
2730 float_status *status = &env->active_tc.msa_fp_status; \
2733 set_float_exception_flags(0, status); \
2734 DEST = float ## BITS ## _ ## OP(ARG, status); \
2735 c = update_msacsr(env, CLEAR_FS_UNDERFLOW, 0); \
2737 if (get_enabled_exceptions(env, c)) { \
2738 DEST = ((FLOAT_SNAN ## XBITS(status) >> 6) << 6) | c; \
2742 void helper_msa_ftq_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2743 uint32_t ws
, uint32_t wt
)
2745 wr_t wx
, *pwx
= &wx
;
2746 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2747 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2748 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2751 clear_msacsr_cause(env
);
2755 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2756 MSA_FLOAT_UNOP_XD(Lh(pwx
, i
), to_q16
, pws
->w
[i
], 32, 16);
2757 MSA_FLOAT_UNOP_XD(Rh(pwx
, i
), to_q16
, pwt
->w
[i
], 32, 16);
2761 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2762 MSA_FLOAT_UNOP_XD(Lw(pwx
, i
), to_q32
, pws
->d
[i
], 64, 32);
2763 MSA_FLOAT_UNOP_XD(Rw(pwx
, i
), to_q32
, pwt
->d
[i
], 64, 32);
2770 check_msacsr_cause(env
, GETPC());
2772 msa_move_v(pwd
, pwx
);
2775 #define NUMBER_QNAN_PAIR(ARG1, ARG2, BITS, STATUS) \
2776 !float ## BITS ## _is_any_nan(ARG1) \
2777 && float ## BITS ## _is_quiet_nan(ARG2, STATUS)
2779 #define MSA_FLOAT_MAXOP(DEST, OP, ARG1, ARG2, BITS) \
2781 float_status *status = &env->active_tc.msa_fp_status; \
2784 set_float_exception_flags(0, status); \
2785 DEST = float ## BITS ## _ ## OP(ARG1, ARG2, status); \
2786 c = update_msacsr(env, 0, 0); \
2788 if (get_enabled_exceptions(env, c)) { \
2789 DEST = ((FLOAT_SNAN ## BITS(status) >> 6) << 6) | c; \
2793 #define FMAXMIN_A(F, G, X, _S, _T, BITS, STATUS) \
2795 uint## BITS ##_t S = _S, T = _T; \
2796 uint## BITS ##_t as, at, xs, xt, xd; \
2797 if (NUMBER_QNAN_PAIR(S, T, BITS, STATUS)) { \
2800 else if (NUMBER_QNAN_PAIR(T, S, BITS, STATUS)) { \
2803 as = float## BITS ##_abs(S); \
2804 at = float## BITS ##_abs(T); \
2805 MSA_FLOAT_MAXOP(xs, F, S, T, BITS); \
2806 MSA_FLOAT_MAXOP(xt, G, S, T, BITS); \
2807 MSA_FLOAT_MAXOP(xd, F, as, at, BITS); \
2808 X = (as == at || xd == float## BITS ##_abs(xs)) ? xs : xt; \
2811 void helper_msa_fmin_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2812 uint32_t ws
, uint32_t wt
)
2814 float_status
*status
= &env
->active_tc
.msa_fp_status
;
2815 wr_t wx
, *pwx
= &wx
;
2816 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2817 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2818 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2821 clear_msacsr_cause(env
);
2825 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2826 if (NUMBER_QNAN_PAIR(pws
->w
[i
], pwt
->w
[i
], 32, status
)) {
2827 MSA_FLOAT_MAXOP(pwx
->w
[i
], min
, pws
->w
[i
], pws
->w
[i
], 32);
2828 } else if (NUMBER_QNAN_PAIR(pwt
->w
[i
], pws
->w
[i
], 32, status
)) {
2829 MSA_FLOAT_MAXOP(pwx
->w
[i
], min
, pwt
->w
[i
], pwt
->w
[i
], 32);
2831 MSA_FLOAT_MAXOP(pwx
->w
[i
], min
, pws
->w
[i
], pwt
->w
[i
], 32);
2836 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2837 if (NUMBER_QNAN_PAIR(pws
->d
[i
], pwt
->d
[i
], 64, status
)) {
2838 MSA_FLOAT_MAXOP(pwx
->d
[i
], min
, pws
->d
[i
], pws
->d
[i
], 64);
2839 } else if (NUMBER_QNAN_PAIR(pwt
->d
[i
], pws
->d
[i
], 64, status
)) {
2840 MSA_FLOAT_MAXOP(pwx
->d
[i
], min
, pwt
->d
[i
], pwt
->d
[i
], 64);
2842 MSA_FLOAT_MAXOP(pwx
->d
[i
], min
, pws
->d
[i
], pwt
->d
[i
], 64);
2850 check_msacsr_cause(env
, GETPC());
2852 msa_move_v(pwd
, pwx
);
2855 void helper_msa_fmin_a_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2856 uint32_t ws
, uint32_t wt
)
2858 float_status
*status
= &env
->active_tc
.msa_fp_status
;
2859 wr_t wx
, *pwx
= &wx
;
2860 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2861 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2862 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2865 clear_msacsr_cause(env
);
2869 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2870 FMAXMIN_A(min
, max
, pwx
->w
[i
], pws
->w
[i
], pwt
->w
[i
], 32, status
);
2874 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2875 FMAXMIN_A(min
, max
, pwx
->d
[i
], pws
->d
[i
], pwt
->d
[i
], 64, status
);
2882 check_msacsr_cause(env
, GETPC());
2884 msa_move_v(pwd
, pwx
);
2887 void helper_msa_fmax_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2888 uint32_t ws
, uint32_t wt
)
2890 float_status
*status
= &env
->active_tc
.msa_fp_status
;
2891 wr_t wx
, *pwx
= &wx
;
2892 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2893 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2894 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2897 clear_msacsr_cause(env
);
2901 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2902 if (NUMBER_QNAN_PAIR(pws
->w
[i
], pwt
->w
[i
], 32, status
)) {
2903 MSA_FLOAT_MAXOP(pwx
->w
[i
], max
, pws
->w
[i
], pws
->w
[i
], 32);
2904 } else if (NUMBER_QNAN_PAIR(pwt
->w
[i
], pws
->w
[i
], 32, status
)) {
2905 MSA_FLOAT_MAXOP(pwx
->w
[i
], max
, pwt
->w
[i
], pwt
->w
[i
], 32);
2907 MSA_FLOAT_MAXOP(pwx
->w
[i
], max
, pws
->w
[i
], pwt
->w
[i
], 32);
2912 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2913 if (NUMBER_QNAN_PAIR(pws
->d
[i
], pwt
->d
[i
], 64, status
)) {
2914 MSA_FLOAT_MAXOP(pwx
->d
[i
], max
, pws
->d
[i
], pws
->d
[i
], 64);
2915 } else if (NUMBER_QNAN_PAIR(pwt
->d
[i
], pws
->d
[i
], 64, status
)) {
2916 MSA_FLOAT_MAXOP(pwx
->d
[i
], max
, pwt
->d
[i
], pwt
->d
[i
], 64);
2918 MSA_FLOAT_MAXOP(pwx
->d
[i
], max
, pws
->d
[i
], pwt
->d
[i
], 64);
2926 check_msacsr_cause(env
, GETPC());
2928 msa_move_v(pwd
, pwx
);
2931 void helper_msa_fmax_a_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2932 uint32_t ws
, uint32_t wt
)
2934 float_status
*status
= &env
->active_tc
.msa_fp_status
;
2935 wr_t wx
, *pwx
= &wx
;
2936 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2937 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2938 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2941 clear_msacsr_cause(env
);
2945 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2946 FMAXMIN_A(max
, min
, pwx
->w
[i
], pws
->w
[i
], pwt
->w
[i
], 32, status
);
2950 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2951 FMAXMIN_A(max
, min
, pwx
->d
[i
], pws
->d
[i
], pwt
->d
[i
], 64, status
);
2958 check_msacsr_cause(env
, GETPC());
2960 msa_move_v(pwd
, pwx
);
2963 void helper_msa_fclass_df(CPUMIPSState
*env
, uint32_t df
,
2964 uint32_t wd
, uint32_t ws
)
2966 float_status
* status
= &env
->active_tc
.msa_fp_status
;
2968 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2969 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2970 if (df
== DF_WORD
) {
2971 pwd
->w
[0] = float_class_s(pws
->w
[0], status
);
2972 pwd
->w
[1] = float_class_s(pws
->w
[1], status
);
2973 pwd
->w
[2] = float_class_s(pws
->w
[2], status
);
2974 pwd
->w
[3] = float_class_s(pws
->w
[3], status
);
2976 pwd
->d
[0] = float_class_d(pws
->d
[0], status
);
2977 pwd
->d
[1] = float_class_d(pws
->d
[1], status
);
2981 #define MSA_FLOAT_UNOP0(DEST, OP, ARG, BITS) \
2983 float_status *status = &env->active_tc.msa_fp_status; \
2986 set_float_exception_flags(0, status); \
2987 DEST = float ## BITS ## _ ## OP(ARG, status); \
2988 c = update_msacsr(env, CLEAR_FS_UNDERFLOW, 0); \
2990 if (get_enabled_exceptions(env, c)) { \
2991 DEST = ((FLOAT_SNAN ## BITS(status) >> 6) << 6) | c; \
2992 } else if (float ## BITS ## _is_any_nan(ARG)) { \
2997 void helper_msa_ftrunc_s_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3000 wr_t wx
, *pwx
= &wx
;
3001 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3002 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3005 clear_msacsr_cause(env
);
3009 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3010 MSA_FLOAT_UNOP0(pwx
->w
[i
], to_int32_round_to_zero
, pws
->w
[i
], 32);
3014 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3015 MSA_FLOAT_UNOP0(pwx
->d
[i
], to_int64_round_to_zero
, pws
->d
[i
], 64);
3022 check_msacsr_cause(env
, GETPC());
3024 msa_move_v(pwd
, pwx
);
3027 void helper_msa_ftrunc_u_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3030 wr_t wx
, *pwx
= &wx
;
3031 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3032 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3035 clear_msacsr_cause(env
);
3039 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3040 MSA_FLOAT_UNOP0(pwx
->w
[i
], to_uint32_round_to_zero
, pws
->w
[i
], 32);
3044 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3045 MSA_FLOAT_UNOP0(pwx
->d
[i
], to_uint64_round_to_zero
, pws
->d
[i
], 64);
3052 check_msacsr_cause(env
, GETPC());
3054 msa_move_v(pwd
, pwx
);
3057 void helper_msa_fsqrt_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3060 wr_t wx
, *pwx
= &wx
;
3061 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3062 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3065 clear_msacsr_cause(env
);
3069 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3070 MSA_FLOAT_UNOP(pwx
->w
[i
], sqrt
, pws
->w
[i
], 32);
3074 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3075 MSA_FLOAT_UNOP(pwx
->d
[i
], sqrt
, pws
->d
[i
], 64);
3082 check_msacsr_cause(env
, GETPC());
3084 msa_move_v(pwd
, pwx
);
3087 #define MSA_FLOAT_RECIPROCAL(DEST, ARG, BITS) \
3089 float_status *status = &env->active_tc.msa_fp_status; \
3092 set_float_exception_flags(0, status); \
3093 DEST = float ## BITS ## _ ## div(FLOAT_ONE ## BITS, ARG, status); \
3094 c = update_msacsr(env, float ## BITS ## _is_infinity(ARG) || \
3095 float ## BITS ## _is_quiet_nan(DEST, status) ? \
3096 0 : RECIPROCAL_INEXACT, \
3097 IS_DENORMAL(DEST, BITS)); \
3099 if (get_enabled_exceptions(env, c)) { \
3100 DEST = ((FLOAT_SNAN ## BITS(status) >> 6) << 6) | c; \
3104 void helper_msa_frsqrt_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3107 wr_t wx
, *pwx
= &wx
;
3108 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3109 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3112 clear_msacsr_cause(env
);
3116 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3117 MSA_FLOAT_RECIPROCAL(pwx
->w
[i
], float32_sqrt(pws
->w
[i
],
3118 &env
->active_tc
.msa_fp_status
), 32);
3122 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3123 MSA_FLOAT_RECIPROCAL(pwx
->d
[i
], float64_sqrt(pws
->d
[i
],
3124 &env
->active_tc
.msa_fp_status
), 64);
3131 check_msacsr_cause(env
, GETPC());
3133 msa_move_v(pwd
, pwx
);
3136 void helper_msa_frcp_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3139 wr_t wx
, *pwx
= &wx
;
3140 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3141 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3144 clear_msacsr_cause(env
);
3148 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3149 MSA_FLOAT_RECIPROCAL(pwx
->w
[i
], pws
->w
[i
], 32);
3153 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3154 MSA_FLOAT_RECIPROCAL(pwx
->d
[i
], pws
->d
[i
], 64);
3161 check_msacsr_cause(env
, GETPC());
3163 msa_move_v(pwd
, pwx
);
3166 void helper_msa_frint_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3169 wr_t wx
, *pwx
= &wx
;
3170 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3171 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3174 clear_msacsr_cause(env
);
3178 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3179 MSA_FLOAT_UNOP(pwx
->w
[i
], round_to_int
, pws
->w
[i
], 32);
3183 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3184 MSA_FLOAT_UNOP(pwx
->d
[i
], round_to_int
, pws
->d
[i
], 64);
3191 check_msacsr_cause(env
, GETPC());
3193 msa_move_v(pwd
, pwx
);
3196 #define MSA_FLOAT_LOGB(DEST, ARG, BITS) \
3198 float_status *status = &env->active_tc.msa_fp_status; \
3201 set_float_exception_flags(0, status); \
3202 set_float_rounding_mode(float_round_down, status); \
3203 DEST = float ## BITS ## _ ## log2(ARG, status); \
3204 DEST = float ## BITS ## _ ## round_to_int(DEST, status); \
3205 set_float_rounding_mode(ieee_rm[(env->active_tc.msacsr & \
3206 MSACSR_RM_MASK) >> MSACSR_RM], \
3209 set_float_exception_flags(get_float_exception_flags(status) & \
3210 (~float_flag_inexact), \
3213 c = update_msacsr(env, 0, IS_DENORMAL(DEST, BITS)); \
3215 if (get_enabled_exceptions(env, c)) { \
3216 DEST = ((FLOAT_SNAN ## BITS(status) >> 6) << 6) | c; \
3220 void helper_msa_flog2_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3223 wr_t wx
, *pwx
= &wx
;
3224 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3225 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3228 clear_msacsr_cause(env
);
3232 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3233 MSA_FLOAT_LOGB(pwx
->w
[i
], pws
->w
[i
], 32);
3237 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3238 MSA_FLOAT_LOGB(pwx
->d
[i
], pws
->d
[i
], 64);
3245 check_msacsr_cause(env
, GETPC());
3247 msa_move_v(pwd
, pwx
);
3250 void helper_msa_fexupl_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3253 wr_t wx
, *pwx
= &wx
;
3254 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3255 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3258 clear_msacsr_cause(env
);
3262 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3263 /* Half precision floats come in two formats: standard
3264 IEEE and "ARM" format. The latter gains extra exponent
3265 range by omitting the NaN/Inf encodings. */
3268 MSA_FLOAT_BINOP(pwx
->w
[i
], from_float16
, Lh(pws
, i
), ieee
, 32);
3272 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3273 MSA_FLOAT_UNOP(pwx
->d
[i
], from_float32
, Lw(pws
, i
), 64);
3280 check_msacsr_cause(env
, GETPC());
3281 msa_move_v(pwd
, pwx
);
3284 void helper_msa_fexupr_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3287 wr_t wx
, *pwx
= &wx
;
3288 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3289 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3292 clear_msacsr_cause(env
);
3296 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3297 /* Half precision floats come in two formats: standard
3298 IEEE and "ARM" format. The latter gains extra exponent
3299 range by omitting the NaN/Inf encodings. */
3302 MSA_FLOAT_BINOP(pwx
->w
[i
], from_float16
, Rh(pws
, i
), ieee
, 32);
3306 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3307 MSA_FLOAT_UNOP(pwx
->d
[i
], from_float32
, Rw(pws
, i
), 64);
3314 check_msacsr_cause(env
, GETPC());
3315 msa_move_v(pwd
, pwx
);
3318 void helper_msa_ffql_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3321 wr_t wx
, *pwx
= &wx
;
3322 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3323 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3328 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3329 MSA_FLOAT_UNOP(pwx
->w
[i
], from_q16
, Lh(pws
, i
), 32);
3333 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3334 MSA_FLOAT_UNOP(pwx
->d
[i
], from_q32
, Lw(pws
, i
), 64);
3341 msa_move_v(pwd
, pwx
);
3344 void helper_msa_ffqr_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3347 wr_t wx
, *pwx
= &wx
;
3348 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3349 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3354 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3355 MSA_FLOAT_UNOP(pwx
->w
[i
], from_q16
, Rh(pws
, i
), 32);
3359 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3360 MSA_FLOAT_UNOP(pwx
->d
[i
], from_q32
, Rw(pws
, i
), 64);
3367 msa_move_v(pwd
, pwx
);
3370 void helper_msa_ftint_s_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3373 wr_t wx
, *pwx
= &wx
;
3374 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3375 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3378 clear_msacsr_cause(env
);
3382 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3383 MSA_FLOAT_UNOP0(pwx
->w
[i
], to_int32
, pws
->w
[i
], 32);
3387 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3388 MSA_FLOAT_UNOP0(pwx
->d
[i
], to_int64
, pws
->d
[i
], 64);
3395 check_msacsr_cause(env
, GETPC());
3397 msa_move_v(pwd
, pwx
);
3400 void helper_msa_ftint_u_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3403 wr_t wx
, *pwx
= &wx
;
3404 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3405 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3408 clear_msacsr_cause(env
);
3412 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3413 MSA_FLOAT_UNOP0(pwx
->w
[i
], to_uint32
, pws
->w
[i
], 32);
3417 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3418 MSA_FLOAT_UNOP0(pwx
->d
[i
], to_uint64
, pws
->d
[i
], 64);
3425 check_msacsr_cause(env
, GETPC());
3427 msa_move_v(pwd
, pwx
);
3430 #define float32_from_int32 int32_to_float32
3431 #define float32_from_uint32 uint32_to_float32
3433 #define float64_from_int64 int64_to_float64
3434 #define float64_from_uint64 uint64_to_float64
3436 void helper_msa_ffint_s_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3439 wr_t wx
, *pwx
= &wx
;
3440 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3441 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3444 clear_msacsr_cause(env
);
3448 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3449 MSA_FLOAT_UNOP(pwx
->w
[i
], from_int32
, pws
->w
[i
], 32);
3453 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3454 MSA_FLOAT_UNOP(pwx
->d
[i
], from_int64
, pws
->d
[i
], 64);
3461 check_msacsr_cause(env
, GETPC());
3463 msa_move_v(pwd
, pwx
);
3466 void helper_msa_ffint_u_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3469 wr_t wx
, *pwx
= &wx
;
3470 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3471 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3474 clear_msacsr_cause(env
);
3478 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3479 MSA_FLOAT_UNOP(pwx
->w
[i
], from_uint32
, pws
->w
[i
], 32);
3483 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3484 MSA_FLOAT_UNOP(pwx
->d
[i
], from_uint64
, pws
->d
[i
], 64);
3491 check_msacsr_cause(env
, GETPC());
3493 msa_move_v(pwd
, pwx
);