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
: 0;
647 static inline int64_t msa_div_u_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
649 uint64_t u_arg1
= UNSIGNED(arg1
, df
);
650 uint64_t u_arg2
= UNSIGNED(arg2
, df
);
651 return u_arg2
? u_arg1
/ u_arg2
: 0;
654 static inline int64_t msa_mod_s_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
656 if (arg1
== DF_MIN_INT(df
) && arg2
== -1) {
659 return arg2
? arg1
% arg2
: 0;
662 static inline int64_t msa_mod_u_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
664 uint64_t u_arg1
= UNSIGNED(arg1
, df
);
665 uint64_t u_arg2
= UNSIGNED(arg2
, df
);
666 return u_arg2
? u_arg1
% u_arg2
: 0;
669 #define SIGNED_EVEN(a, df) \
670 ((((int64_t)(a)) << (64 - DF_BITS(df)/2)) >> (64 - DF_BITS(df)/2))
672 #define UNSIGNED_EVEN(a, df) \
673 ((((uint64_t)(a)) << (64 - DF_BITS(df)/2)) >> (64 - DF_BITS(df)/2))
675 #define SIGNED_ODD(a, df) \
676 ((((int64_t)(a)) << (64 - DF_BITS(df))) >> (64 - DF_BITS(df)/2))
678 #define UNSIGNED_ODD(a, df) \
679 ((((uint64_t)(a)) << (64 - DF_BITS(df))) >> (64 - DF_BITS(df)/2))
681 #define SIGNED_EXTRACT(e, o, a, df) \
683 e = SIGNED_EVEN(a, df); \
684 o = SIGNED_ODD(a, df); \
687 #define UNSIGNED_EXTRACT(e, o, a, df) \
689 e = UNSIGNED_EVEN(a, df); \
690 o = UNSIGNED_ODD(a, df); \
693 static inline int64_t msa_dotp_s_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
699 SIGNED_EXTRACT(even_arg1
, odd_arg1
, arg1
, df
);
700 SIGNED_EXTRACT(even_arg2
, odd_arg2
, arg2
, df
);
701 return (even_arg1
* even_arg2
) + (odd_arg1
* odd_arg2
);
704 static inline int64_t msa_dotp_u_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
710 UNSIGNED_EXTRACT(even_arg1
, odd_arg1
, arg1
, df
);
711 UNSIGNED_EXTRACT(even_arg2
, odd_arg2
, arg2
, df
);
712 return (even_arg1
* even_arg2
) + (odd_arg1
* odd_arg2
);
715 #define CONCATENATE_AND_SLIDE(s, k) \
717 for (i = 0; i < s; i++) { \
718 v[i] = pws->b[s * k + i]; \
719 v[i + s] = pwd->b[s * k + i]; \
721 for (i = 0; i < s; i++) { \
722 pwd->b[s * k + i] = v[i + n]; \
726 static inline void msa_sld_df(uint32_t df
, wr_t
*pwd
,
727 wr_t
*pws
, target_ulong rt
)
729 uint32_t n
= rt
% DF_ELEMENTS(df
);
735 CONCATENATE_AND_SLIDE(DF_ELEMENTS(DF_BYTE
), 0);
738 for (k
= 0; k
< 2; k
++) {
739 CONCATENATE_AND_SLIDE(DF_ELEMENTS(DF_HALF
), k
);
743 for (k
= 0; k
< 4; k
++) {
744 CONCATENATE_AND_SLIDE(DF_ELEMENTS(DF_WORD
), k
);
748 for (k
= 0; k
< 8; k
++) {
749 CONCATENATE_AND_SLIDE(DF_ELEMENTS(DF_DOUBLE
), k
);
757 static inline int64_t msa_hadd_s_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
759 return SIGNED_ODD(arg1
, df
) + SIGNED_EVEN(arg2
, df
);
762 static inline int64_t msa_hadd_u_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
764 return UNSIGNED_ODD(arg1
, df
) + UNSIGNED_EVEN(arg2
, df
);
767 static inline int64_t msa_hsub_s_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
769 return SIGNED_ODD(arg1
, df
) - SIGNED_EVEN(arg2
, df
);
772 static inline int64_t msa_hsub_u_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
774 return UNSIGNED_ODD(arg1
, df
) - UNSIGNED_EVEN(arg2
, df
);
777 static inline int64_t msa_mul_q_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
779 int64_t q_min
= DF_MIN_INT(df
);
780 int64_t q_max
= DF_MAX_INT(df
);
782 if (arg1
== q_min
&& arg2
== q_min
) {
785 return (arg1
* arg2
) >> (DF_BITS(df
) - 1);
788 static inline int64_t msa_mulr_q_df(uint32_t df
, int64_t arg1
, int64_t arg2
)
790 int64_t q_min
= DF_MIN_INT(df
);
791 int64_t q_max
= DF_MAX_INT(df
);
792 int64_t r_bit
= 1 << (DF_BITS(df
) - 2);
794 if (arg1
== q_min
&& arg2
== q_min
) {
797 return (arg1
* arg2
+ r_bit
) >> (DF_BITS(df
) - 1);
800 #define MSA_BINOP_DF(func) \
801 void helper_msa_ ## func ## _df(CPUMIPSState *env, uint32_t df, \
802 uint32_t wd, uint32_t ws, uint32_t wt) \
804 wr_t *pwd = &(env->active_fpu.fpr[wd].wr); \
805 wr_t *pws = &(env->active_fpu.fpr[ws].wr); \
806 wr_t *pwt = &(env->active_fpu.fpr[wt].wr); \
811 for (i = 0; i < DF_ELEMENTS(DF_BYTE); i++) { \
812 pwd->b[i] = msa_ ## func ## _df(df, pws->b[i], pwt->b[i]); \
816 for (i = 0; i < DF_ELEMENTS(DF_HALF); i++) { \
817 pwd->h[i] = msa_ ## func ## _df(df, pws->h[i], pwt->h[i]); \
821 for (i = 0; i < DF_ELEMENTS(DF_WORD); i++) { \
822 pwd->w[i] = msa_ ## func ## _df(df, pws->w[i], pwt->w[i]); \
826 for (i = 0; i < DF_ELEMENTS(DF_DOUBLE); i++) { \
827 pwd->d[i] = msa_ ## func ## _df(df, pws->d[i], pwt->d[i]); \
864 MSA_BINOP_DF(subsus_u
)
865 MSA_BINOP_DF(subsuu_s
)
886 void helper_msa_sld_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
887 uint32_t ws
, uint32_t rt
)
889 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
890 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
892 msa_sld_df(df
, pwd
, pws
, env
->active_tc
.gpr
[rt
]);
895 static inline int64_t msa_maddv_df(uint32_t df
, int64_t dest
, int64_t arg1
,
898 return dest
+ arg1
* arg2
;
901 static inline int64_t msa_msubv_df(uint32_t df
, int64_t dest
, int64_t arg1
,
904 return dest
- arg1
* arg2
;
907 static inline int64_t msa_dpadd_s_df(uint32_t df
, int64_t dest
, int64_t arg1
,
914 SIGNED_EXTRACT(even_arg1
, odd_arg1
, arg1
, df
);
915 SIGNED_EXTRACT(even_arg2
, odd_arg2
, arg2
, df
);
916 return dest
+ (even_arg1
* even_arg2
) + (odd_arg1
* odd_arg2
);
919 static inline int64_t msa_dpadd_u_df(uint32_t df
, int64_t dest
, int64_t arg1
,
926 UNSIGNED_EXTRACT(even_arg1
, odd_arg1
, arg1
, df
);
927 UNSIGNED_EXTRACT(even_arg2
, odd_arg2
, arg2
, df
);
928 return dest
+ (even_arg1
* even_arg2
) + (odd_arg1
* odd_arg2
);
931 static inline int64_t msa_dpsub_s_df(uint32_t df
, int64_t dest
, int64_t arg1
,
938 SIGNED_EXTRACT(even_arg1
, odd_arg1
, arg1
, df
);
939 SIGNED_EXTRACT(even_arg2
, odd_arg2
, arg2
, df
);
940 return dest
- ((even_arg1
* even_arg2
) + (odd_arg1
* odd_arg2
));
943 static inline int64_t msa_dpsub_u_df(uint32_t df
, int64_t dest
, int64_t arg1
,
950 UNSIGNED_EXTRACT(even_arg1
, odd_arg1
, arg1
, df
);
951 UNSIGNED_EXTRACT(even_arg2
, odd_arg2
, arg2
, df
);
952 return dest
- ((even_arg1
* even_arg2
) + (odd_arg1
* odd_arg2
));
955 static inline int64_t msa_madd_q_df(uint32_t df
, int64_t dest
, int64_t arg1
,
958 int64_t q_prod
, q_ret
;
960 int64_t q_max
= DF_MAX_INT(df
);
961 int64_t q_min
= DF_MIN_INT(df
);
963 q_prod
= arg1
* arg2
;
964 q_ret
= ((dest
<< (DF_BITS(df
) - 1)) + q_prod
) >> (DF_BITS(df
) - 1);
966 return (q_ret
< q_min
) ? q_min
: (q_max
< q_ret
) ? q_max
: q_ret
;
969 static inline int64_t msa_msub_q_df(uint32_t df
, int64_t dest
, int64_t arg1
,
972 int64_t q_prod
, q_ret
;
974 int64_t q_max
= DF_MAX_INT(df
);
975 int64_t q_min
= DF_MIN_INT(df
);
977 q_prod
= arg1
* arg2
;
978 q_ret
= ((dest
<< (DF_BITS(df
) - 1)) - q_prod
) >> (DF_BITS(df
) - 1);
980 return (q_ret
< q_min
) ? q_min
: (q_max
< q_ret
) ? q_max
: q_ret
;
983 static inline int64_t msa_maddr_q_df(uint32_t df
, int64_t dest
, int64_t arg1
,
986 int64_t q_prod
, q_ret
;
988 int64_t q_max
= DF_MAX_INT(df
);
989 int64_t q_min
= DF_MIN_INT(df
);
990 int64_t r_bit
= 1 << (DF_BITS(df
) - 2);
992 q_prod
= arg1
* arg2
;
993 q_ret
= ((dest
<< (DF_BITS(df
) - 1)) + q_prod
+ r_bit
) >> (DF_BITS(df
) - 1);
995 return (q_ret
< q_min
) ? q_min
: (q_max
< q_ret
) ? q_max
: q_ret
;
998 static inline int64_t msa_msubr_q_df(uint32_t df
, int64_t dest
, int64_t arg1
,
1001 int64_t q_prod
, q_ret
;
1003 int64_t q_max
= DF_MAX_INT(df
);
1004 int64_t q_min
= DF_MIN_INT(df
);
1005 int64_t r_bit
= 1 << (DF_BITS(df
) - 2);
1007 q_prod
= arg1
* arg2
;
1008 q_ret
= ((dest
<< (DF_BITS(df
) - 1)) - q_prod
+ r_bit
) >> (DF_BITS(df
) - 1);
1010 return (q_ret
< q_min
) ? q_min
: (q_max
< q_ret
) ? q_max
: q_ret
;
1013 #define MSA_TEROP_DF(func) \
1014 void helper_msa_ ## func ## _df(CPUMIPSState *env, uint32_t df, uint32_t wd, \
1015 uint32_t ws, uint32_t wt) \
1017 wr_t *pwd = &(env->active_fpu.fpr[wd].wr); \
1018 wr_t *pws = &(env->active_fpu.fpr[ws].wr); \
1019 wr_t *pwt = &(env->active_fpu.fpr[wt].wr); \
1024 for (i = 0; i < DF_ELEMENTS(DF_BYTE); i++) { \
1025 pwd->b[i] = msa_ ## func ## _df(df, pwd->b[i], pws->b[i], \
1030 for (i = 0; i < DF_ELEMENTS(DF_HALF); i++) { \
1031 pwd->h[i] = msa_ ## func ## _df(df, pwd->h[i], pws->h[i], \
1036 for (i = 0; i < DF_ELEMENTS(DF_WORD); i++) { \
1037 pwd->w[i] = msa_ ## func ## _df(df, pwd->w[i], pws->w[i], \
1042 for (i = 0; i < DF_ELEMENTS(DF_DOUBLE); i++) { \
1043 pwd->d[i] = msa_ ## func ## _df(df, pwd->d[i], pws->d[i], \
1054 MSA_TEROP_DF(dpadd_s
)
1055 MSA_TEROP_DF(dpadd_u
)
1056 MSA_TEROP_DF(dpsub_s
)
1057 MSA_TEROP_DF(dpsub_u
)
1060 MSA_TEROP_DF(madd_q
)
1061 MSA_TEROP_DF(msub_q
)
1062 MSA_TEROP_DF(maddr_q
)
1063 MSA_TEROP_DF(msubr_q
)
1066 static inline void msa_splat_df(uint32_t df
, wr_t
*pwd
,
1067 wr_t
*pws
, target_ulong rt
)
1069 uint32_t n
= rt
% DF_ELEMENTS(df
);
1074 for (i
= 0; i
< DF_ELEMENTS(DF_BYTE
); i
++) {
1075 pwd
->b
[i
] = pws
->b
[n
];
1079 for (i
= 0; i
< DF_ELEMENTS(DF_HALF
); i
++) {
1080 pwd
->h
[i
] = pws
->h
[n
];
1084 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
1085 pwd
->w
[i
] = pws
->w
[n
];
1089 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
1090 pwd
->d
[i
] = pws
->d
[n
];
1098 void helper_msa_splat_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
1099 uint32_t ws
, uint32_t rt
)
1101 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1102 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
1104 msa_splat_df(df
, pwd
, pws
, env
->active_tc
.gpr
[rt
]);
1107 #define MSA_DO_B MSA_DO(b)
1108 #define MSA_DO_H MSA_DO(h)
1109 #define MSA_DO_W MSA_DO(w)
1110 #define MSA_DO_D MSA_DO(d)
1112 #define MSA_LOOP_B MSA_LOOP(B)
1113 #define MSA_LOOP_H MSA_LOOP(H)
1114 #define MSA_LOOP_W MSA_LOOP(W)
1115 #define MSA_LOOP_D MSA_LOOP(D)
1117 #define MSA_LOOP_COND_B MSA_LOOP_COND(DF_BYTE)
1118 #define MSA_LOOP_COND_H MSA_LOOP_COND(DF_HALF)
1119 #define MSA_LOOP_COND_W MSA_LOOP_COND(DF_WORD)
1120 #define MSA_LOOP_COND_D MSA_LOOP_COND(DF_DOUBLE)
1122 #define MSA_LOOP(DF) \
1124 for (i = 0; i < (MSA_LOOP_COND_ ## DF) ; i++) { \
1129 #define MSA_FN_DF(FUNC) \
1130 void helper_msa_##FUNC(CPUMIPSState *env, uint32_t df, uint32_t wd, \
1131 uint32_t ws, uint32_t wt) \
1133 wr_t *pwd = &(env->active_fpu.fpr[wd].wr); \
1134 wr_t *pws = &(env->active_fpu.fpr[ws].wr); \
1135 wr_t *pwt = &(env->active_fpu.fpr[wt].wr); \
1136 wr_t wx, *pwx = &wx; \
1154 msa_move_v(pwd, pwx); \
1157 #define MSA_LOOP_COND(DF) \
1158 (DF_ELEMENTS(DF) / 2)
1160 #define Rb(pwr, i) (pwr->b[i])
1161 #define Lb(pwr, i) (pwr->b[i + DF_ELEMENTS(DF_BYTE)/2])
1162 #define Rh(pwr, i) (pwr->h[i])
1163 #define Lh(pwr, i) (pwr->h[i + DF_ELEMENTS(DF_HALF)/2])
1164 #define Rw(pwr, i) (pwr->w[i])
1165 #define Lw(pwr, i) (pwr->w[i + DF_ELEMENTS(DF_WORD)/2])
1166 #define Rd(pwr, i) (pwr->d[i])
1167 #define Ld(pwr, i) (pwr->d[i + DF_ELEMENTS(DF_DOUBLE)/2])
1169 #define MSA_DO(DF) \
1171 R##DF(pwx, i) = pwt->DF[2*i]; \
1172 L##DF(pwx, i) = pws->DF[2*i]; \
1177 #define MSA_DO(DF) \
1179 R##DF(pwx, i) = pwt->DF[2*i+1]; \
1180 L##DF(pwx, i) = pws->DF[2*i+1]; \
1185 #define MSA_DO(DF) \
1187 pwx->DF[2*i] = L##DF(pwt, i); \
1188 pwx->DF[2*i+1] = L##DF(pws, i); \
1193 #define MSA_DO(DF) \
1195 pwx->DF[2*i] = R##DF(pwt, i); \
1196 pwx->DF[2*i+1] = R##DF(pws, i); \
1201 #define MSA_DO(DF) \
1203 pwx->DF[2*i] = pwt->DF[2*i]; \
1204 pwx->DF[2*i+1] = pws->DF[2*i]; \
1209 #define MSA_DO(DF) \
1211 pwx->DF[2*i] = pwt->DF[2*i+1]; \
1212 pwx->DF[2*i+1] = pws->DF[2*i+1]; \
1216 #undef MSA_LOOP_COND
1218 #define MSA_LOOP_COND(DF) \
1221 #define MSA_DO(DF) \
1223 uint32_t n = DF_ELEMENTS(df); \
1224 uint32_t k = (pwd->DF[i] & 0x3f) % (2 * n); \
1226 (pwd->DF[i] & 0xc0) ? 0 : k < n ? pwt->DF[k] : pws->DF[k - n]; \
1230 #undef MSA_LOOP_COND
1233 void helper_msa_sldi_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
1234 uint32_t ws
, uint32_t n
)
1236 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1237 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
1239 msa_sld_df(df
, pwd
, pws
, n
);
1242 void helper_msa_splati_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
1243 uint32_t ws
, uint32_t n
)
1245 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1246 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
1248 msa_splat_df(df
, pwd
, pws
, n
);
1251 void helper_msa_copy_s_df(CPUMIPSState
*env
, uint32_t df
, uint32_t rd
,
1252 uint32_t ws
, uint32_t n
)
1254 n
%= DF_ELEMENTS(df
);
1258 env
->active_tc
.gpr
[rd
] = (int8_t)env
->active_fpu
.fpr
[ws
].wr
.b
[n
];
1261 env
->active_tc
.gpr
[rd
] = (int16_t)env
->active_fpu
.fpr
[ws
].wr
.h
[n
];
1264 env
->active_tc
.gpr
[rd
] = (int32_t)env
->active_fpu
.fpr
[ws
].wr
.w
[n
];
1266 #ifdef TARGET_MIPS64
1268 env
->active_tc
.gpr
[rd
] = (int64_t)env
->active_fpu
.fpr
[ws
].wr
.d
[n
];
1276 void helper_msa_copy_u_df(CPUMIPSState
*env
, uint32_t df
, uint32_t rd
,
1277 uint32_t ws
, uint32_t n
)
1279 n
%= DF_ELEMENTS(df
);
1283 env
->active_tc
.gpr
[rd
] = (uint8_t)env
->active_fpu
.fpr
[ws
].wr
.b
[n
];
1286 env
->active_tc
.gpr
[rd
] = (uint16_t)env
->active_fpu
.fpr
[ws
].wr
.h
[n
];
1289 env
->active_tc
.gpr
[rd
] = (uint32_t)env
->active_fpu
.fpr
[ws
].wr
.w
[n
];
1291 #ifdef TARGET_MIPS64
1293 env
->active_tc
.gpr
[rd
] = (uint64_t)env
->active_fpu
.fpr
[ws
].wr
.d
[n
];
1301 void helper_msa_insert_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
1302 uint32_t rs_num
, uint32_t n
)
1304 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1305 target_ulong rs
= env
->active_tc
.gpr
[rs_num
];
1309 pwd
->b
[n
] = (int8_t)rs
;
1312 pwd
->h
[n
] = (int16_t)rs
;
1315 pwd
->w
[n
] = (int32_t)rs
;
1318 pwd
->d
[n
] = (int64_t)rs
;
1325 void helper_msa_insve_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
1326 uint32_t ws
, uint32_t n
)
1328 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1329 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
1333 pwd
->b
[n
] = (int8_t)pws
->b
[0];
1336 pwd
->h
[n
] = (int16_t)pws
->h
[0];
1339 pwd
->w
[n
] = (int32_t)pws
->w
[0];
1342 pwd
->d
[n
] = (int64_t)pws
->d
[0];
1349 void helper_msa_ctcmsa(CPUMIPSState
*env
, target_ulong elm
, uint32_t cd
)
1355 env
->active_tc
.msacsr
= (int32_t)elm
& MSACSR_MASK
;
1356 restore_msa_fp_status(env
);
1357 /* check exception */
1358 if ((GET_FP_ENABLE(env
->active_tc
.msacsr
) | FP_UNIMPLEMENTED
)
1359 & GET_FP_CAUSE(env
->active_tc
.msacsr
)) {
1360 do_raise_exception(env
, EXCP_MSAFPE
, GETPC());
1366 target_ulong
helper_msa_cfcmsa(CPUMIPSState
*env
, uint32_t cs
)
1372 return env
->active_tc
.msacsr
& MSACSR_MASK
;
1377 void helper_msa_move_v(CPUMIPSState
*env
, uint32_t wd
, uint32_t ws
)
1379 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1380 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
1382 msa_move_v(pwd
, pws
);
1385 static inline int64_t msa_pcnt_df(uint32_t df
, int64_t arg
)
1389 x
= UNSIGNED(arg
, df
);
1391 x
= (x
& 0x5555555555555555ULL
) + ((x
>> 1) & 0x5555555555555555ULL
);
1392 x
= (x
& 0x3333333333333333ULL
) + ((x
>> 2) & 0x3333333333333333ULL
);
1393 x
= (x
& 0x0F0F0F0F0F0F0F0FULL
) + ((x
>> 4) & 0x0F0F0F0F0F0F0F0FULL
);
1394 x
= (x
& 0x00FF00FF00FF00FFULL
) + ((x
>> 8) & 0x00FF00FF00FF00FFULL
);
1395 x
= (x
& 0x0000FFFF0000FFFFULL
) + ((x
>> 16) & 0x0000FFFF0000FFFFULL
);
1396 x
= (x
& 0x00000000FFFFFFFFULL
) + ((x
>> 32));
1401 static inline int64_t msa_nlzc_df(uint32_t df
, int64_t arg
)
1406 x
= UNSIGNED(arg
, df
);
1408 c
= DF_BITS(df
) / 2;
1422 static inline int64_t msa_nloc_df(uint32_t df
, int64_t arg
)
1424 return msa_nlzc_df(df
, UNSIGNED((~arg
), df
));
1427 void helper_msa_fill_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
1430 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1435 for (i
= 0; i
< DF_ELEMENTS(DF_BYTE
); i
++) {
1436 pwd
->b
[i
] = (int8_t)env
->active_tc
.gpr
[rs
];
1440 for (i
= 0; i
< DF_ELEMENTS(DF_HALF
); i
++) {
1441 pwd
->h
[i
] = (int16_t)env
->active_tc
.gpr
[rs
];
1445 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
1446 pwd
->w
[i
] = (int32_t)env
->active_tc
.gpr
[rs
];
1450 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
1451 pwd
->d
[i
] = (int64_t)env
->active_tc
.gpr
[rs
];
1459 #define MSA_UNOP_DF(func) \
1460 void helper_msa_ ## func ## _df(CPUMIPSState *env, uint32_t df, \
1461 uint32_t wd, uint32_t ws) \
1463 wr_t *pwd = &(env->active_fpu.fpr[wd].wr); \
1464 wr_t *pws = &(env->active_fpu.fpr[ws].wr); \
1469 for (i = 0; i < DF_ELEMENTS(DF_BYTE); i++) { \
1470 pwd->b[i] = msa_ ## func ## _df(df, pws->b[i]); \
1474 for (i = 0; i < DF_ELEMENTS(DF_HALF); i++) { \
1475 pwd->h[i] = msa_ ## func ## _df(df, pws->h[i]); \
1479 for (i = 0; i < DF_ELEMENTS(DF_WORD); i++) { \
1480 pwd->w[i] = msa_ ## func ## _df(df, pws->w[i]); \
1484 for (i = 0; i < DF_ELEMENTS(DF_DOUBLE); i++) { \
1485 pwd->d[i] = msa_ ## func ## _df(df, pws->d[i]); \
1498 #define FLOAT_ONE32 make_float32(0x3f8 << 20)
1499 #define FLOAT_ONE64 make_float64(0x3ffULL << 52)
1501 #define FLOAT_SNAN16(s) (float16_default_nan(s) ^ 0x0220)
1503 #define FLOAT_SNAN32(s) (float32_default_nan(s) ^ 0x00400020)
1505 #define FLOAT_SNAN64(s) (float64_default_nan(s) ^ 0x0008000000000020ULL)
1506 /* 0x7ff0000000000020 */
1508 static inline void clear_msacsr_cause(CPUMIPSState
*env
)
1510 SET_FP_CAUSE(env
->active_tc
.msacsr
, 0);
1513 static inline void check_msacsr_cause(CPUMIPSState
*env
, uintptr_t retaddr
)
1515 if ((GET_FP_CAUSE(env
->active_tc
.msacsr
) &
1516 (GET_FP_ENABLE(env
->active_tc
.msacsr
) | FP_UNIMPLEMENTED
)) == 0) {
1517 UPDATE_FP_FLAGS(env
->active_tc
.msacsr
,
1518 GET_FP_CAUSE(env
->active_tc
.msacsr
));
1520 do_raise_exception(env
, EXCP_MSAFPE
, retaddr
);
1524 /* Flush-to-zero use cases for update_msacsr() */
1525 #define CLEAR_FS_UNDERFLOW 1
1526 #define CLEAR_IS_INEXACT 2
1527 #define RECIPROCAL_INEXACT 4
1529 static inline int update_msacsr(CPUMIPSState
*env
, int action
, int denormal
)
1537 ieee_ex
= get_float_exception_flags(&env
->active_tc
.msa_fp_status
);
1539 /* QEMU softfloat does not signal all underflow cases */
1541 ieee_ex
|= float_flag_underflow
;
1544 c
= ieee_ex_to_mips(ieee_ex
);
1545 enable
= GET_FP_ENABLE(env
->active_tc
.msacsr
) | FP_UNIMPLEMENTED
;
1547 /* Set Inexact (I) when flushing inputs to zero */
1548 if ((ieee_ex
& float_flag_input_denormal
) &&
1549 (env
->active_tc
.msacsr
& MSACSR_FS_MASK
) != 0) {
1550 if (action
& CLEAR_IS_INEXACT
) {
1557 /* Set Inexact (I) and Underflow (U) when flushing outputs to zero */
1558 if ((ieee_ex
& float_flag_output_denormal
) &&
1559 (env
->active_tc
.msacsr
& MSACSR_FS_MASK
) != 0) {
1561 if (action
& CLEAR_FS_UNDERFLOW
) {
1568 /* Set Inexact (I) when Overflow (O) is not enabled */
1569 if ((c
& FP_OVERFLOW
) != 0 && (enable
& FP_OVERFLOW
) == 0) {
1573 /* Clear Exact Underflow when Underflow (U) is not enabled */
1574 if ((c
& FP_UNDERFLOW
) != 0 && (enable
& FP_UNDERFLOW
) == 0 &&
1575 (c
& FP_INEXACT
) == 0) {
1579 /* Reciprocal operations set only Inexact when valid and not
1581 if ((action
& RECIPROCAL_INEXACT
) &&
1582 (c
& (FP_INVALID
| FP_DIV0
)) == 0) {
1586 cause
= c
& enable
; /* all current enabled exceptions */
1589 /* No enabled exception, update the MSACSR Cause
1590 with all current exceptions */
1591 SET_FP_CAUSE(env
->active_tc
.msacsr
,
1592 (GET_FP_CAUSE(env
->active_tc
.msacsr
) | c
));
1594 /* Current exceptions are enabled */
1595 if ((env
->active_tc
.msacsr
& MSACSR_NX_MASK
) == 0) {
1596 /* Exception(s) will trap, update MSACSR Cause
1597 with all enabled exceptions */
1598 SET_FP_CAUSE(env
->active_tc
.msacsr
,
1599 (GET_FP_CAUSE(env
->active_tc
.msacsr
) | c
));
1606 static inline int get_enabled_exceptions(const CPUMIPSState
*env
, int c
)
1608 int enable
= GET_FP_ENABLE(env
->active_tc
.msacsr
) | FP_UNIMPLEMENTED
;
1612 static inline float16
float16_from_float32(int32_t a
, flag ieee
,
1613 float_status
*status
)
1617 f_val
= float32_to_float16((float32
)a
, ieee
, status
);
1619 return a
< 0 ? (f_val
| (1 << 15)) : f_val
;
1622 static inline float32
float32_from_float64(int64_t a
, float_status
*status
)
1626 f_val
= float64_to_float32((float64
)a
, status
);
1628 return a
< 0 ? (f_val
| (1 << 31)) : f_val
;
1631 static inline float32
float32_from_float16(int16_t a
, flag ieee
,
1632 float_status
*status
)
1636 f_val
= float16_to_float32((float16
)a
, ieee
, status
);
1638 return a
< 0 ? (f_val
| (1 << 31)) : f_val
;
1641 static inline float64
float64_from_float32(int32_t a
, float_status
*status
)
1645 f_val
= float32_to_float64((float64
)a
, status
);
1647 return a
< 0 ? (f_val
| (1ULL << 63)) : f_val
;
1650 static inline float32
float32_from_q16(int16_t a
, float_status
*status
)
1654 /* conversion as integer and scaling */
1655 f_val
= int32_to_float32(a
, status
);
1656 f_val
= float32_scalbn(f_val
, -15, status
);
1661 static inline float64
float64_from_q32(int32_t a
, float_status
*status
)
1665 /* conversion as integer and scaling */
1666 f_val
= int32_to_float64(a
, status
);
1667 f_val
= float64_scalbn(f_val
, -31, status
);
1672 static inline int16_t float32_to_q16(float32 a
, float_status
*status
)
1675 int32_t q_min
= 0xffff8000;
1676 int32_t q_max
= 0x00007fff;
1680 if (float32_is_any_nan(a
)) {
1681 float_raise(float_flag_invalid
, status
);
1686 a
= float32_scalbn(a
, 15, status
);
1688 ieee_ex
= get_float_exception_flags(status
);
1689 set_float_exception_flags(ieee_ex
& (~float_flag_underflow
)
1692 if (ieee_ex
& float_flag_overflow
) {
1693 float_raise(float_flag_inexact
, status
);
1694 return (int32_t)a
< 0 ? q_min
: q_max
;
1697 /* conversion to int */
1698 q_val
= float32_to_int32(a
, status
);
1700 ieee_ex
= get_float_exception_flags(status
);
1701 set_float_exception_flags(ieee_ex
& (~float_flag_underflow
)
1704 if (ieee_ex
& float_flag_invalid
) {
1705 set_float_exception_flags(ieee_ex
& (~float_flag_invalid
)
1707 float_raise(float_flag_overflow
| float_flag_inexact
, status
);
1708 return (int32_t)a
< 0 ? q_min
: q_max
;
1711 if (q_val
< q_min
) {
1712 float_raise(float_flag_overflow
| float_flag_inexact
, status
);
1713 return (int16_t)q_min
;
1716 if (q_max
< q_val
) {
1717 float_raise(float_flag_overflow
| float_flag_inexact
, status
);
1718 return (int16_t)q_max
;
1721 return (int16_t)q_val
;
1724 static inline int32_t float64_to_q32(float64 a
, float_status
*status
)
1727 int64_t q_min
= 0xffffffff80000000LL
;
1728 int64_t q_max
= 0x000000007fffffffLL
;
1732 if (float64_is_any_nan(a
)) {
1733 float_raise(float_flag_invalid
, status
);
1738 a
= float64_scalbn(a
, 31, status
);
1740 ieee_ex
= get_float_exception_flags(status
);
1741 set_float_exception_flags(ieee_ex
& (~float_flag_underflow
)
1744 if (ieee_ex
& float_flag_overflow
) {
1745 float_raise(float_flag_inexact
, status
);
1746 return (int64_t)a
< 0 ? q_min
: q_max
;
1749 /* conversion to integer */
1750 q_val
= float64_to_int64(a
, status
);
1752 ieee_ex
= get_float_exception_flags(status
);
1753 set_float_exception_flags(ieee_ex
& (~float_flag_underflow
)
1756 if (ieee_ex
& float_flag_invalid
) {
1757 set_float_exception_flags(ieee_ex
& (~float_flag_invalid
)
1759 float_raise(float_flag_overflow
| float_flag_inexact
, status
);
1760 return (int64_t)a
< 0 ? q_min
: q_max
;
1763 if (q_val
< q_min
) {
1764 float_raise(float_flag_overflow
| float_flag_inexact
, status
);
1765 return (int32_t)q_min
;
1768 if (q_max
< q_val
) {
1769 float_raise(float_flag_overflow
| float_flag_inexact
, status
);
1770 return (int32_t)q_max
;
1773 return (int32_t)q_val
;
1776 #define MSA_FLOAT_COND(DEST, OP, ARG1, ARG2, BITS, QUIET) \
1778 float_status *status = &env->active_tc.msa_fp_status; \
1781 set_float_exception_flags(0, status); \
1783 cond = float ## BITS ## _ ## OP(ARG1, ARG2, status); \
1785 cond = float ## BITS ## _ ## OP ## _quiet(ARG1, ARG2, status); \
1787 DEST = cond ? M_MAX_UINT(BITS) : 0; \
1788 c = update_msacsr(env, CLEAR_IS_INEXACT, 0); \
1790 if (get_enabled_exceptions(env, c)) { \
1791 DEST = ((FLOAT_SNAN ## BITS(status) >> 6) << 6) | c; \
1795 #define MSA_FLOAT_AF(DEST, ARG1, ARG2, BITS, QUIET) \
1797 MSA_FLOAT_COND(DEST, eq, ARG1, ARG2, BITS, QUIET); \
1798 if ((DEST & M_MAX_UINT(BITS)) == M_MAX_UINT(BITS)) { \
1803 #define MSA_FLOAT_UEQ(DEST, ARG1, ARG2, BITS, QUIET) \
1805 MSA_FLOAT_COND(DEST, unordered, ARG1, ARG2, BITS, QUIET); \
1807 MSA_FLOAT_COND(DEST, eq, ARG1, ARG2, BITS, QUIET); \
1811 #define MSA_FLOAT_NE(DEST, ARG1, ARG2, BITS, QUIET) \
1813 MSA_FLOAT_COND(DEST, lt, ARG1, ARG2, BITS, QUIET); \
1815 MSA_FLOAT_COND(DEST, lt, ARG2, ARG1, BITS, QUIET); \
1819 #define MSA_FLOAT_UNE(DEST, ARG1, ARG2, BITS, QUIET) \
1821 MSA_FLOAT_COND(DEST, unordered, ARG1, ARG2, BITS, QUIET); \
1823 MSA_FLOAT_COND(DEST, lt, ARG1, ARG2, BITS, QUIET); \
1825 MSA_FLOAT_COND(DEST, lt, ARG2, ARG1, BITS, QUIET); \
1830 #define MSA_FLOAT_ULE(DEST, ARG1, ARG2, BITS, QUIET) \
1832 MSA_FLOAT_COND(DEST, unordered, ARG1, ARG2, BITS, QUIET); \
1834 MSA_FLOAT_COND(DEST, le, ARG1, ARG2, BITS, QUIET); \
1838 #define MSA_FLOAT_ULT(DEST, ARG1, ARG2, BITS, QUIET) \
1840 MSA_FLOAT_COND(DEST, unordered, ARG1, ARG2, BITS, QUIET); \
1842 MSA_FLOAT_COND(DEST, lt, ARG1, ARG2, BITS, QUIET); \
1846 #define MSA_FLOAT_OR(DEST, ARG1, ARG2, BITS, QUIET) \
1848 MSA_FLOAT_COND(DEST, le, ARG1, ARG2, BITS, QUIET); \
1850 MSA_FLOAT_COND(DEST, le, ARG2, ARG1, BITS, QUIET); \
1854 static inline void compare_af(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
1855 wr_t
*pwt
, uint32_t df
, int quiet
,
1858 wr_t wx
, *pwx
= &wx
;
1861 clear_msacsr_cause(env
);
1865 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
1866 MSA_FLOAT_AF(pwx
->w
[i
], pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
1870 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
1871 MSA_FLOAT_AF(pwx
->d
[i
], pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
1878 check_msacsr_cause(env
, retaddr
);
1880 msa_move_v(pwd
, pwx
);
1883 static inline void compare_un(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
1884 wr_t
*pwt
, uint32_t df
, int quiet
,
1887 wr_t wx
, *pwx
= &wx
;
1890 clear_msacsr_cause(env
);
1894 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
1895 MSA_FLOAT_COND(pwx
->w
[i
], unordered
, pws
->w
[i
], pwt
->w
[i
], 32,
1900 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
1901 MSA_FLOAT_COND(pwx
->d
[i
], unordered
, pws
->d
[i
], pwt
->d
[i
], 64,
1909 check_msacsr_cause(env
, retaddr
);
1911 msa_move_v(pwd
, pwx
);
1914 static inline void compare_eq(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
1915 wr_t
*pwt
, uint32_t df
, int quiet
,
1918 wr_t wx
, *pwx
= &wx
;
1921 clear_msacsr_cause(env
);
1925 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
1926 MSA_FLOAT_COND(pwx
->w
[i
], eq
, pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
1930 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
1931 MSA_FLOAT_COND(pwx
->d
[i
], eq
, pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
1938 check_msacsr_cause(env
, retaddr
);
1940 msa_move_v(pwd
, pwx
);
1943 static inline void compare_ueq(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
1944 wr_t
*pwt
, uint32_t df
, int quiet
,
1947 wr_t wx
, *pwx
= &wx
;
1950 clear_msacsr_cause(env
);
1954 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
1955 MSA_FLOAT_UEQ(pwx
->w
[i
], pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
1959 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
1960 MSA_FLOAT_UEQ(pwx
->d
[i
], pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
1967 check_msacsr_cause(env
, retaddr
);
1969 msa_move_v(pwd
, pwx
);
1972 static inline void compare_lt(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
1973 wr_t
*pwt
, uint32_t df
, int quiet
,
1976 wr_t wx
, *pwx
= &wx
;
1979 clear_msacsr_cause(env
);
1983 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
1984 MSA_FLOAT_COND(pwx
->w
[i
], lt
, pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
1988 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
1989 MSA_FLOAT_COND(pwx
->d
[i
], lt
, pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
1996 check_msacsr_cause(env
, retaddr
);
1998 msa_move_v(pwd
, pwx
);
2001 static inline void compare_ult(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
2002 wr_t
*pwt
, uint32_t df
, int quiet
,
2005 wr_t wx
, *pwx
= &wx
;
2008 clear_msacsr_cause(env
);
2012 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2013 MSA_FLOAT_ULT(pwx
->w
[i
], pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
2017 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2018 MSA_FLOAT_ULT(pwx
->d
[i
], pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
2025 check_msacsr_cause(env
, retaddr
);
2027 msa_move_v(pwd
, pwx
);
2030 static inline void compare_le(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
2031 wr_t
*pwt
, uint32_t df
, int quiet
,
2034 wr_t wx
, *pwx
= &wx
;
2037 clear_msacsr_cause(env
);
2041 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2042 MSA_FLOAT_COND(pwx
->w
[i
], le
, pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
2046 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2047 MSA_FLOAT_COND(pwx
->d
[i
], le
, pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
2054 check_msacsr_cause(env
, retaddr
);
2056 msa_move_v(pwd
, pwx
);
2059 static inline void compare_ule(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
2060 wr_t
*pwt
, uint32_t df
, int quiet
,
2063 wr_t wx
, *pwx
= &wx
;
2066 clear_msacsr_cause(env
);
2070 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2071 MSA_FLOAT_ULE(pwx
->w
[i
], pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
2075 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2076 MSA_FLOAT_ULE(pwx
->d
[i
], pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
2083 check_msacsr_cause(env
, retaddr
);
2085 msa_move_v(pwd
, pwx
);
2088 static inline void compare_or(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
2089 wr_t
*pwt
, uint32_t df
, int quiet
,
2092 wr_t wx
, *pwx
= &wx
;
2095 clear_msacsr_cause(env
);
2099 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2100 MSA_FLOAT_OR(pwx
->w
[i
], pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
2104 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2105 MSA_FLOAT_OR(pwx
->d
[i
], pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
2112 check_msacsr_cause(env
, retaddr
);
2114 msa_move_v(pwd
, pwx
);
2117 static inline void compare_une(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
2118 wr_t
*pwt
, uint32_t df
, int quiet
,
2121 wr_t wx
, *pwx
= &wx
;
2124 clear_msacsr_cause(env
);
2128 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2129 MSA_FLOAT_UNE(pwx
->w
[i
], pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
2133 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2134 MSA_FLOAT_UNE(pwx
->d
[i
], pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
2141 check_msacsr_cause(env
, retaddr
);
2143 msa_move_v(pwd
, pwx
);
2146 static inline void compare_ne(CPUMIPSState
*env
, wr_t
*pwd
, wr_t
*pws
,
2147 wr_t
*pwt
, uint32_t df
, int quiet
,
2150 wr_t wx
, *pwx
= &wx
;
2153 clear_msacsr_cause(env
);
2157 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2158 MSA_FLOAT_NE(pwx
->w
[i
], pws
->w
[i
], pwt
->w
[i
], 32, quiet
);
2162 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2163 MSA_FLOAT_NE(pwx
->d
[i
], pws
->d
[i
], pwt
->d
[i
], 64, quiet
);
2170 check_msacsr_cause(env
, retaddr
);
2172 msa_move_v(pwd
, pwx
);
2175 void helper_msa_fcaf_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2176 uint32_t ws
, uint32_t wt
)
2178 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2179 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2180 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2181 compare_af(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2184 void helper_msa_fcun_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2185 uint32_t ws
, uint32_t wt
)
2187 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2188 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2189 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2190 compare_un(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2193 void helper_msa_fceq_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2194 uint32_t ws
, uint32_t wt
)
2196 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2197 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2198 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2199 compare_eq(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2202 void helper_msa_fcueq_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2203 uint32_t ws
, uint32_t wt
)
2205 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2206 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2207 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2208 compare_ueq(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2211 void helper_msa_fclt_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2212 uint32_t ws
, uint32_t wt
)
2214 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2215 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2216 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2217 compare_lt(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2220 void helper_msa_fcult_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2221 uint32_t ws
, uint32_t wt
)
2223 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2224 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2225 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2226 compare_ult(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2229 void helper_msa_fcle_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2230 uint32_t ws
, uint32_t wt
)
2232 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2233 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2234 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2235 compare_le(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2238 void helper_msa_fcule_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2239 uint32_t ws
, uint32_t wt
)
2241 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2242 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2243 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2244 compare_ule(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2247 void helper_msa_fsaf_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2248 uint32_t ws
, uint32_t wt
)
2250 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2251 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2252 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2253 compare_af(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2256 void helper_msa_fsun_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2257 uint32_t ws
, uint32_t wt
)
2259 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2260 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2261 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2262 compare_un(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2265 void helper_msa_fseq_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2266 uint32_t ws
, uint32_t wt
)
2268 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2269 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2270 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2271 compare_eq(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2274 void helper_msa_fsueq_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2275 uint32_t ws
, uint32_t wt
)
2277 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2278 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2279 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2280 compare_ueq(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2283 void helper_msa_fslt_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2284 uint32_t ws
, uint32_t wt
)
2286 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2287 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2288 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2289 compare_lt(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2292 void helper_msa_fsult_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2293 uint32_t ws
, uint32_t wt
)
2295 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2296 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2297 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2298 compare_ult(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2301 void helper_msa_fsle_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2302 uint32_t ws
, uint32_t wt
)
2304 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2305 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2306 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2307 compare_le(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2310 void helper_msa_fsule_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2311 uint32_t ws
, uint32_t wt
)
2313 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2314 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2315 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2316 compare_ule(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2319 void helper_msa_fcor_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2320 uint32_t ws
, uint32_t wt
)
2322 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2323 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2324 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2325 compare_or(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2328 void helper_msa_fcune_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2329 uint32_t ws
, uint32_t wt
)
2331 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2332 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2333 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2334 compare_une(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2337 void helper_msa_fcne_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2338 uint32_t ws
, uint32_t wt
)
2340 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2341 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2342 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2343 compare_ne(env
, pwd
, pws
, pwt
, df
, 1, GETPC());
2346 void helper_msa_fsor_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2347 uint32_t ws
, uint32_t wt
)
2349 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2350 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2351 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2352 compare_or(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2355 void helper_msa_fsune_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2356 uint32_t ws
, uint32_t wt
)
2358 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2359 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2360 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2361 compare_une(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2364 void helper_msa_fsne_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2365 uint32_t ws
, uint32_t wt
)
2367 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2368 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2369 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2370 compare_ne(env
, pwd
, pws
, pwt
, df
, 0, GETPC());
2373 #define float16_is_zero(ARG) 0
2374 #define float16_is_zero_or_denormal(ARG) 0
2376 #define IS_DENORMAL(ARG, BITS) \
2377 (!float ## BITS ## _is_zero(ARG) \
2378 && float ## BITS ## _is_zero_or_denormal(ARG))
2380 #define MSA_FLOAT_BINOP(DEST, OP, ARG1, ARG2, BITS) \
2382 float_status *status = &env->active_tc.msa_fp_status; \
2385 set_float_exception_flags(0, status); \
2386 DEST = float ## BITS ## _ ## OP(ARG1, ARG2, status); \
2387 c = update_msacsr(env, 0, IS_DENORMAL(DEST, BITS)); \
2389 if (get_enabled_exceptions(env, c)) { \
2390 DEST = ((FLOAT_SNAN ## BITS(status) >> 6) << 6) | c; \
2394 void helper_msa_fadd_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2395 uint32_t ws
, uint32_t wt
)
2397 wr_t wx
, *pwx
= &wx
;
2398 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2399 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2400 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2403 clear_msacsr_cause(env
);
2407 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2408 MSA_FLOAT_BINOP(pwx
->w
[i
], add
, pws
->w
[i
], pwt
->w
[i
], 32);
2412 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2413 MSA_FLOAT_BINOP(pwx
->d
[i
], add
, pws
->d
[i
], pwt
->d
[i
], 64);
2420 check_msacsr_cause(env
, GETPC());
2421 msa_move_v(pwd
, pwx
);
2424 void helper_msa_fsub_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2425 uint32_t ws
, uint32_t wt
)
2427 wr_t wx
, *pwx
= &wx
;
2428 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2429 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2430 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2433 clear_msacsr_cause(env
);
2437 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2438 MSA_FLOAT_BINOP(pwx
->w
[i
], sub
, pws
->w
[i
], pwt
->w
[i
], 32);
2442 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2443 MSA_FLOAT_BINOP(pwx
->d
[i
], sub
, pws
->d
[i
], pwt
->d
[i
], 64);
2450 check_msacsr_cause(env
, GETPC());
2451 msa_move_v(pwd
, pwx
);
2454 void helper_msa_fmul_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2455 uint32_t ws
, uint32_t wt
)
2457 wr_t wx
, *pwx
= &wx
;
2458 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2459 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2460 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2463 clear_msacsr_cause(env
);
2467 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2468 MSA_FLOAT_BINOP(pwx
->w
[i
], mul
, pws
->w
[i
], pwt
->w
[i
], 32);
2472 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2473 MSA_FLOAT_BINOP(pwx
->d
[i
], mul
, pws
->d
[i
], pwt
->d
[i
], 64);
2480 check_msacsr_cause(env
, GETPC());
2482 msa_move_v(pwd
, pwx
);
2485 void helper_msa_fdiv_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2486 uint32_t ws
, uint32_t wt
)
2488 wr_t wx
, *pwx
= &wx
;
2489 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2490 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2491 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2494 clear_msacsr_cause(env
);
2498 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2499 MSA_FLOAT_BINOP(pwx
->w
[i
], div
, pws
->w
[i
], pwt
->w
[i
], 32);
2503 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2504 MSA_FLOAT_BINOP(pwx
->d
[i
], div
, pws
->d
[i
], pwt
->d
[i
], 64);
2511 check_msacsr_cause(env
, GETPC());
2513 msa_move_v(pwd
, pwx
);
2516 #define MSA_FLOAT_MULADD(DEST, ARG1, ARG2, ARG3, NEGATE, BITS) \
2518 float_status *status = &env->active_tc.msa_fp_status; \
2521 set_float_exception_flags(0, status); \
2522 DEST = float ## BITS ## _muladd(ARG2, ARG3, ARG1, NEGATE, status); \
2523 c = update_msacsr(env, 0, IS_DENORMAL(DEST, BITS)); \
2525 if (get_enabled_exceptions(env, c)) { \
2526 DEST = ((FLOAT_SNAN ## BITS(status) >> 6) << 6) | c; \
2530 void helper_msa_fmadd_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2531 uint32_t ws
, uint32_t wt
)
2533 wr_t wx
, *pwx
= &wx
;
2534 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2535 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2536 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2539 clear_msacsr_cause(env
);
2543 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2544 MSA_FLOAT_MULADD(pwx
->w
[i
], pwd
->w
[i
],
2545 pws
->w
[i
], pwt
->w
[i
], 0, 32);
2549 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2550 MSA_FLOAT_MULADD(pwx
->d
[i
], pwd
->d
[i
],
2551 pws
->d
[i
], pwt
->d
[i
], 0, 64);
2558 check_msacsr_cause(env
, GETPC());
2560 msa_move_v(pwd
, pwx
);
2563 void helper_msa_fmsub_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2564 uint32_t ws
, uint32_t wt
)
2566 wr_t wx
, *pwx
= &wx
;
2567 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2568 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2569 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2572 clear_msacsr_cause(env
);
2576 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2577 MSA_FLOAT_MULADD(pwx
->w
[i
], pwd
->w
[i
],
2578 pws
->w
[i
], pwt
->w
[i
],
2579 float_muladd_negate_product
, 32);
2583 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2584 MSA_FLOAT_MULADD(pwx
->d
[i
], pwd
->d
[i
],
2585 pws
->d
[i
], pwt
->d
[i
],
2586 float_muladd_negate_product
, 64);
2593 check_msacsr_cause(env
, GETPC());
2595 msa_move_v(pwd
, pwx
);
2598 void helper_msa_fexp2_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2599 uint32_t ws
, uint32_t wt
)
2601 wr_t wx
, *pwx
= &wx
;
2602 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2603 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2604 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2607 clear_msacsr_cause(env
);
2611 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2612 MSA_FLOAT_BINOP(pwx
->w
[i
], scalbn
, pws
->w
[i
],
2613 pwt
->w
[i
] > 0x200 ? 0x200 :
2614 pwt
->w
[i
] < -0x200 ? -0x200 : pwt
->w
[i
],
2619 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2620 MSA_FLOAT_BINOP(pwx
->d
[i
], scalbn
, pws
->d
[i
],
2621 pwt
->d
[i
] > 0x1000 ? 0x1000 :
2622 pwt
->d
[i
] < -0x1000 ? -0x1000 : pwt
->d
[i
],
2630 check_msacsr_cause(env
, GETPC());
2632 msa_move_v(pwd
, pwx
);
2635 #define MSA_FLOAT_UNOP(DEST, OP, ARG, BITS) \
2637 float_status *status = &env->active_tc.msa_fp_status; \
2640 set_float_exception_flags(0, status); \
2641 DEST = float ## BITS ## _ ## OP(ARG, status); \
2642 c = update_msacsr(env, 0, IS_DENORMAL(DEST, BITS)); \
2644 if (get_enabled_exceptions(env, c)) { \
2645 DEST = ((FLOAT_SNAN ## BITS(status) >> 6) << 6) | c; \
2649 void helper_msa_fexdo_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2650 uint32_t ws
, uint32_t wt
)
2652 wr_t wx
, *pwx
= &wx
;
2653 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2654 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2655 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2658 clear_msacsr_cause(env
);
2662 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2663 /* Half precision floats come in two formats: standard
2664 IEEE and "ARM" format. The latter gains extra exponent
2665 range by omitting the NaN/Inf encodings. */
2668 MSA_FLOAT_BINOP(Lh(pwx
, i
), from_float32
, pws
->w
[i
], ieee
, 16);
2669 MSA_FLOAT_BINOP(Rh(pwx
, i
), from_float32
, pwt
->w
[i
], ieee
, 16);
2673 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2674 MSA_FLOAT_UNOP(Lw(pwx
, i
), from_float64
, pws
->d
[i
], 32);
2675 MSA_FLOAT_UNOP(Rw(pwx
, i
), from_float64
, pwt
->d
[i
], 32);
2682 check_msacsr_cause(env
, GETPC());
2683 msa_move_v(pwd
, pwx
);
2686 #define MSA_FLOAT_UNOP_XD(DEST, OP, ARG, BITS, XBITS) \
2688 float_status *status = &env->active_tc.msa_fp_status; \
2691 set_float_exception_flags(0, status); \
2692 DEST = float ## BITS ## _ ## OP(ARG, status); \
2693 c = update_msacsr(env, CLEAR_FS_UNDERFLOW, 0); \
2695 if (get_enabled_exceptions(env, c)) { \
2696 DEST = ((FLOAT_SNAN ## XBITS(status) >> 6) << 6) | c; \
2700 void helper_msa_ftq_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2701 uint32_t ws
, uint32_t wt
)
2703 wr_t wx
, *pwx
= &wx
;
2704 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2705 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2706 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2709 clear_msacsr_cause(env
);
2713 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2714 MSA_FLOAT_UNOP_XD(Lh(pwx
, i
), to_q16
, pws
->w
[i
], 32, 16);
2715 MSA_FLOAT_UNOP_XD(Rh(pwx
, i
), to_q16
, pwt
->w
[i
], 32, 16);
2719 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2720 MSA_FLOAT_UNOP_XD(Lw(pwx
, i
), to_q32
, pws
->d
[i
], 64, 32);
2721 MSA_FLOAT_UNOP_XD(Rw(pwx
, i
), to_q32
, pwt
->d
[i
], 64, 32);
2728 check_msacsr_cause(env
, GETPC());
2730 msa_move_v(pwd
, pwx
);
2733 #define NUMBER_QNAN_PAIR(ARG1, ARG2, BITS, STATUS) \
2734 !float ## BITS ## _is_any_nan(ARG1) \
2735 && float ## BITS ## _is_quiet_nan(ARG2, STATUS)
2737 #define MSA_FLOAT_MAXOP(DEST, OP, ARG1, ARG2, BITS) \
2739 float_status *status = &env->active_tc.msa_fp_status; \
2742 set_float_exception_flags(0, status); \
2743 DEST = float ## BITS ## _ ## OP(ARG1, ARG2, status); \
2744 c = update_msacsr(env, 0, 0); \
2746 if (get_enabled_exceptions(env, c)) { \
2747 DEST = ((FLOAT_SNAN ## BITS(status) >> 6) << 6) | c; \
2751 #define FMAXMIN_A(F, G, X, _S, _T, BITS, STATUS) \
2753 uint## BITS ##_t S = _S, T = _T; \
2754 uint## BITS ##_t as, at, xs, xt, xd; \
2755 if (NUMBER_QNAN_PAIR(S, T, BITS, STATUS)) { \
2758 else if (NUMBER_QNAN_PAIR(T, S, BITS, STATUS)) { \
2761 as = float## BITS ##_abs(S); \
2762 at = float## BITS ##_abs(T); \
2763 MSA_FLOAT_MAXOP(xs, F, S, T, BITS); \
2764 MSA_FLOAT_MAXOP(xt, G, S, T, BITS); \
2765 MSA_FLOAT_MAXOP(xd, F, as, at, BITS); \
2766 X = (as == at || xd == float## BITS ##_abs(xs)) ? xs : xt; \
2769 void helper_msa_fmin_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2770 uint32_t ws
, uint32_t wt
)
2772 float_status
*status
= &env
->active_tc
.msa_fp_status
;
2773 wr_t wx
, *pwx
= &wx
;
2774 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2775 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2776 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2779 clear_msacsr_cause(env
);
2783 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2784 if (NUMBER_QNAN_PAIR(pws
->w
[i
], pwt
->w
[i
], 32, status
)) {
2785 MSA_FLOAT_MAXOP(pwx
->w
[i
], min
, pws
->w
[i
], pws
->w
[i
], 32);
2786 } else if (NUMBER_QNAN_PAIR(pwt
->w
[i
], pws
->w
[i
], 32, status
)) {
2787 MSA_FLOAT_MAXOP(pwx
->w
[i
], min
, pwt
->w
[i
], pwt
->w
[i
], 32);
2789 MSA_FLOAT_MAXOP(pwx
->w
[i
], min
, pws
->w
[i
], pwt
->w
[i
], 32);
2794 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2795 if (NUMBER_QNAN_PAIR(pws
->d
[i
], pwt
->d
[i
], 64, status
)) {
2796 MSA_FLOAT_MAXOP(pwx
->d
[i
], min
, pws
->d
[i
], pws
->d
[i
], 64);
2797 } else if (NUMBER_QNAN_PAIR(pwt
->d
[i
], pws
->d
[i
], 64, status
)) {
2798 MSA_FLOAT_MAXOP(pwx
->d
[i
], min
, pwt
->d
[i
], pwt
->d
[i
], 64);
2800 MSA_FLOAT_MAXOP(pwx
->d
[i
], min
, pws
->d
[i
], pwt
->d
[i
], 64);
2808 check_msacsr_cause(env
, GETPC());
2810 msa_move_v(pwd
, pwx
);
2813 void helper_msa_fmin_a_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2814 uint32_t ws
, uint32_t wt
)
2816 float_status
*status
= &env
->active_tc
.msa_fp_status
;
2817 wr_t wx
, *pwx
= &wx
;
2818 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2819 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2820 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2823 clear_msacsr_cause(env
);
2827 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2828 FMAXMIN_A(min
, max
, pwx
->w
[i
], pws
->w
[i
], pwt
->w
[i
], 32, status
);
2832 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2833 FMAXMIN_A(min
, max
, pwx
->d
[i
], pws
->d
[i
], pwt
->d
[i
], 64, status
);
2840 check_msacsr_cause(env
, GETPC());
2842 msa_move_v(pwd
, pwx
);
2845 void helper_msa_fmax_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2846 uint32_t ws
, uint32_t wt
)
2848 float_status
*status
= &env
->active_tc
.msa_fp_status
;
2849 wr_t wx
, *pwx
= &wx
;
2850 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2851 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2852 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2855 clear_msacsr_cause(env
);
2859 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2860 if (NUMBER_QNAN_PAIR(pws
->w
[i
], pwt
->w
[i
], 32, status
)) {
2861 MSA_FLOAT_MAXOP(pwx
->w
[i
], max
, pws
->w
[i
], pws
->w
[i
], 32);
2862 } else if (NUMBER_QNAN_PAIR(pwt
->w
[i
], pws
->w
[i
], 32, status
)) {
2863 MSA_FLOAT_MAXOP(pwx
->w
[i
], max
, pwt
->w
[i
], pwt
->w
[i
], 32);
2865 MSA_FLOAT_MAXOP(pwx
->w
[i
], max
, pws
->w
[i
], pwt
->w
[i
], 32);
2870 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2871 if (NUMBER_QNAN_PAIR(pws
->d
[i
], pwt
->d
[i
], 64, status
)) {
2872 MSA_FLOAT_MAXOP(pwx
->d
[i
], max
, pws
->d
[i
], pws
->d
[i
], 64);
2873 } else if (NUMBER_QNAN_PAIR(pwt
->d
[i
], pws
->d
[i
], 64, status
)) {
2874 MSA_FLOAT_MAXOP(pwx
->d
[i
], max
, pwt
->d
[i
], pwt
->d
[i
], 64);
2876 MSA_FLOAT_MAXOP(pwx
->d
[i
], max
, pws
->d
[i
], pwt
->d
[i
], 64);
2884 check_msacsr_cause(env
, GETPC());
2886 msa_move_v(pwd
, pwx
);
2889 void helper_msa_fmax_a_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2890 uint32_t ws
, uint32_t wt
)
2892 float_status
*status
= &env
->active_tc
.msa_fp_status
;
2893 wr_t wx
, *pwx
= &wx
;
2894 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2895 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2896 wr_t
*pwt
= &(env
->active_fpu
.fpr
[wt
].wr
);
2899 clear_msacsr_cause(env
);
2903 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2904 FMAXMIN_A(max
, min
, pwx
->w
[i
], pws
->w
[i
], pwt
->w
[i
], 32, status
);
2908 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2909 FMAXMIN_A(max
, min
, pwx
->d
[i
], pws
->d
[i
], pwt
->d
[i
], 64, status
);
2916 check_msacsr_cause(env
, GETPC());
2918 msa_move_v(pwd
, pwx
);
2921 void helper_msa_fclass_df(CPUMIPSState
*env
, uint32_t df
,
2922 uint32_t wd
, uint32_t ws
)
2924 float_status
* status
= &env
->active_tc
.msa_fp_status
;
2926 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2927 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2928 if (df
== DF_WORD
) {
2929 pwd
->w
[0] = float_class_s(pws
->w
[0], status
);
2930 pwd
->w
[1] = float_class_s(pws
->w
[1], status
);
2931 pwd
->w
[2] = float_class_s(pws
->w
[2], status
);
2932 pwd
->w
[3] = float_class_s(pws
->w
[3], status
);
2934 pwd
->d
[0] = float_class_d(pws
->d
[0], status
);
2935 pwd
->d
[1] = float_class_d(pws
->d
[1], status
);
2939 #define MSA_FLOAT_UNOP0(DEST, OP, ARG, BITS) \
2941 float_status *status = &env->active_tc.msa_fp_status; \
2944 set_float_exception_flags(0, status); \
2945 DEST = float ## BITS ## _ ## OP(ARG, status); \
2946 c = update_msacsr(env, CLEAR_FS_UNDERFLOW, 0); \
2948 if (get_enabled_exceptions(env, c)) { \
2949 DEST = ((FLOAT_SNAN ## BITS(status) >> 6) << 6) | c; \
2950 } else if (float ## BITS ## _is_any_nan(ARG)) { \
2955 void helper_msa_ftrunc_s_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2958 wr_t wx
, *pwx
= &wx
;
2959 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2960 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2963 clear_msacsr_cause(env
);
2967 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2968 MSA_FLOAT_UNOP0(pwx
->w
[i
], to_int32_round_to_zero
, pws
->w
[i
], 32);
2972 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
2973 MSA_FLOAT_UNOP0(pwx
->d
[i
], to_int64_round_to_zero
, pws
->d
[i
], 64);
2980 check_msacsr_cause(env
, GETPC());
2982 msa_move_v(pwd
, pwx
);
2985 void helper_msa_ftrunc_u_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
2988 wr_t wx
, *pwx
= &wx
;
2989 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
2990 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
2993 clear_msacsr_cause(env
);
2997 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
2998 MSA_FLOAT_UNOP0(pwx
->w
[i
], to_uint32_round_to_zero
, pws
->w
[i
], 32);
3002 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3003 MSA_FLOAT_UNOP0(pwx
->d
[i
], to_uint64_round_to_zero
, pws
->d
[i
], 64);
3010 check_msacsr_cause(env
, GETPC());
3012 msa_move_v(pwd
, pwx
);
3015 void helper_msa_fsqrt_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3018 wr_t wx
, *pwx
= &wx
;
3019 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3020 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3023 clear_msacsr_cause(env
);
3027 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3028 MSA_FLOAT_UNOP(pwx
->w
[i
], sqrt
, pws
->w
[i
], 32);
3032 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3033 MSA_FLOAT_UNOP(pwx
->d
[i
], sqrt
, pws
->d
[i
], 64);
3040 check_msacsr_cause(env
, GETPC());
3042 msa_move_v(pwd
, pwx
);
3045 #define MSA_FLOAT_RECIPROCAL(DEST, ARG, BITS) \
3047 float_status *status = &env->active_tc.msa_fp_status; \
3050 set_float_exception_flags(0, status); \
3051 DEST = float ## BITS ## _ ## div(FLOAT_ONE ## BITS, ARG, status); \
3052 c = update_msacsr(env, float ## BITS ## _is_infinity(ARG) || \
3053 float ## BITS ## _is_quiet_nan(DEST, status) ? \
3054 0 : RECIPROCAL_INEXACT, \
3055 IS_DENORMAL(DEST, BITS)); \
3057 if (get_enabled_exceptions(env, c)) { \
3058 DEST = ((FLOAT_SNAN ## BITS(status) >> 6) << 6) | c; \
3062 void helper_msa_frsqrt_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3065 wr_t wx
, *pwx
= &wx
;
3066 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3067 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3070 clear_msacsr_cause(env
);
3074 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3075 MSA_FLOAT_RECIPROCAL(pwx
->w
[i
], float32_sqrt(pws
->w
[i
],
3076 &env
->active_tc
.msa_fp_status
), 32);
3080 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3081 MSA_FLOAT_RECIPROCAL(pwx
->d
[i
], float64_sqrt(pws
->d
[i
],
3082 &env
->active_tc
.msa_fp_status
), 64);
3089 check_msacsr_cause(env
, GETPC());
3091 msa_move_v(pwd
, pwx
);
3094 void helper_msa_frcp_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3097 wr_t wx
, *pwx
= &wx
;
3098 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3099 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3102 clear_msacsr_cause(env
);
3106 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3107 MSA_FLOAT_RECIPROCAL(pwx
->w
[i
], pws
->w
[i
], 32);
3111 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3112 MSA_FLOAT_RECIPROCAL(pwx
->d
[i
], pws
->d
[i
], 64);
3119 check_msacsr_cause(env
, GETPC());
3121 msa_move_v(pwd
, pwx
);
3124 void helper_msa_frint_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3127 wr_t wx
, *pwx
= &wx
;
3128 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3129 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3132 clear_msacsr_cause(env
);
3136 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3137 MSA_FLOAT_UNOP(pwx
->w
[i
], round_to_int
, pws
->w
[i
], 32);
3141 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3142 MSA_FLOAT_UNOP(pwx
->d
[i
], round_to_int
, pws
->d
[i
], 64);
3149 check_msacsr_cause(env
, GETPC());
3151 msa_move_v(pwd
, pwx
);
3154 #define MSA_FLOAT_LOGB(DEST, ARG, BITS) \
3156 float_status *status = &env->active_tc.msa_fp_status; \
3159 set_float_exception_flags(0, status); \
3160 set_float_rounding_mode(float_round_down, status); \
3161 DEST = float ## BITS ## _ ## log2(ARG, status); \
3162 DEST = float ## BITS ## _ ## round_to_int(DEST, status); \
3163 set_float_rounding_mode(ieee_rm[(env->active_tc.msacsr & \
3164 MSACSR_RM_MASK) >> MSACSR_RM], \
3167 set_float_exception_flags(get_float_exception_flags(status) & \
3168 (~float_flag_inexact), \
3171 c = update_msacsr(env, 0, IS_DENORMAL(DEST, BITS)); \
3173 if (get_enabled_exceptions(env, c)) { \
3174 DEST = ((FLOAT_SNAN ## BITS(status) >> 6) << 6) | c; \
3178 void helper_msa_flog2_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3181 wr_t wx
, *pwx
= &wx
;
3182 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3183 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3186 clear_msacsr_cause(env
);
3190 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3191 MSA_FLOAT_LOGB(pwx
->w
[i
], pws
->w
[i
], 32);
3195 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3196 MSA_FLOAT_LOGB(pwx
->d
[i
], pws
->d
[i
], 64);
3203 check_msacsr_cause(env
, GETPC());
3205 msa_move_v(pwd
, pwx
);
3208 void helper_msa_fexupl_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3211 wr_t wx
, *pwx
= &wx
;
3212 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3213 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3216 clear_msacsr_cause(env
);
3220 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3221 /* Half precision floats come in two formats: standard
3222 IEEE and "ARM" format. The latter gains extra exponent
3223 range by omitting the NaN/Inf encodings. */
3226 MSA_FLOAT_BINOP(pwx
->w
[i
], from_float16
, Lh(pws
, i
), ieee
, 32);
3230 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3231 MSA_FLOAT_UNOP(pwx
->d
[i
], from_float32
, Lw(pws
, i
), 64);
3238 check_msacsr_cause(env
, GETPC());
3239 msa_move_v(pwd
, pwx
);
3242 void helper_msa_fexupr_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3245 wr_t wx
, *pwx
= &wx
;
3246 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3247 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3250 clear_msacsr_cause(env
);
3254 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3255 /* Half precision floats come in two formats: standard
3256 IEEE and "ARM" format. The latter gains extra exponent
3257 range by omitting the NaN/Inf encodings. */
3260 MSA_FLOAT_BINOP(pwx
->w
[i
], from_float16
, Rh(pws
, i
), ieee
, 32);
3264 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3265 MSA_FLOAT_UNOP(pwx
->d
[i
], from_float32
, Rw(pws
, i
), 64);
3272 check_msacsr_cause(env
, GETPC());
3273 msa_move_v(pwd
, pwx
);
3276 void helper_msa_ffql_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3279 wr_t wx
, *pwx
= &wx
;
3280 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3281 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3286 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3287 MSA_FLOAT_UNOP(pwx
->w
[i
], from_q16
, Lh(pws
, i
), 32);
3291 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3292 MSA_FLOAT_UNOP(pwx
->d
[i
], from_q32
, Lw(pws
, i
), 64);
3299 msa_move_v(pwd
, pwx
);
3302 void helper_msa_ffqr_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3305 wr_t wx
, *pwx
= &wx
;
3306 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3307 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3312 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3313 MSA_FLOAT_UNOP(pwx
->w
[i
], from_q16
, Rh(pws
, i
), 32);
3317 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3318 MSA_FLOAT_UNOP(pwx
->d
[i
], from_q32
, Rw(pws
, i
), 64);
3325 msa_move_v(pwd
, pwx
);
3328 void helper_msa_ftint_s_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3331 wr_t wx
, *pwx
= &wx
;
3332 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3333 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3336 clear_msacsr_cause(env
);
3340 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3341 MSA_FLOAT_UNOP0(pwx
->w
[i
], to_int32
, pws
->w
[i
], 32);
3345 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3346 MSA_FLOAT_UNOP0(pwx
->d
[i
], to_int64
, pws
->d
[i
], 64);
3353 check_msacsr_cause(env
, GETPC());
3355 msa_move_v(pwd
, pwx
);
3358 void helper_msa_ftint_u_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3361 wr_t wx
, *pwx
= &wx
;
3362 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3363 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3366 clear_msacsr_cause(env
);
3370 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3371 MSA_FLOAT_UNOP0(pwx
->w
[i
], to_uint32
, pws
->w
[i
], 32);
3375 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3376 MSA_FLOAT_UNOP0(pwx
->d
[i
], to_uint64
, pws
->d
[i
], 64);
3383 check_msacsr_cause(env
, GETPC());
3385 msa_move_v(pwd
, pwx
);
3388 #define float32_from_int32 int32_to_float32
3389 #define float32_from_uint32 uint32_to_float32
3391 #define float64_from_int64 int64_to_float64
3392 #define float64_from_uint64 uint64_to_float64
3394 void helper_msa_ffint_s_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3397 wr_t wx
, *pwx
= &wx
;
3398 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3399 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3402 clear_msacsr_cause(env
);
3406 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3407 MSA_FLOAT_UNOP(pwx
->w
[i
], from_int32
, pws
->w
[i
], 32);
3411 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3412 MSA_FLOAT_UNOP(pwx
->d
[i
], from_int64
, pws
->d
[i
], 64);
3419 check_msacsr_cause(env
, GETPC());
3421 msa_move_v(pwd
, pwx
);
3424 void helper_msa_ffint_u_df(CPUMIPSState
*env
, uint32_t df
, uint32_t wd
,
3427 wr_t wx
, *pwx
= &wx
;
3428 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
3429 wr_t
*pws
= &(env
->active_fpu
.fpr
[ws
].wr
);
3432 clear_msacsr_cause(env
);
3436 for (i
= 0; i
< DF_ELEMENTS(DF_WORD
); i
++) {
3437 MSA_FLOAT_UNOP(pwx
->w
[i
], from_uint32
, pws
->w
[i
], 32);
3441 for (i
= 0; i
< DF_ELEMENTS(DF_DOUBLE
); i
++) {
3442 MSA_FLOAT_UNOP(pwx
->d
[i
], from_uint64
, pws
->d
[i
], 64);
3449 check_msacsr_cause(env
, GETPC());
3451 msa_move_v(pwd
, pwx
);