2 * S/390 FPU helper routines
4 * Copyright (c) 2009 Ulrich Hecht
5 * Copyright (c) 2009 Alexander Graf
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 #include "qemu/osdep.h"
24 #include "exec/exec-all.h"
25 #include "exec/cpu_ldst.h"
26 #include "exec/helper-proto.h"
27 #include "fpu/softfloat.h"
29 /* #define DEBUG_HELPER */
31 #define HELPER_LOG(x...) qemu_log(x)
33 #define HELPER_LOG(x...)
36 #define RET128(F) (env->retxl = F.low, F.high)
38 #define convert_bit(mask, from, to) \
40 ? (mask / (from / to)) & to \
41 : (mask & from) * (to / from))
43 static void ieee_exception(CPUS390XState *env, uint32_t dxc, uintptr_t retaddr)
45 /* Install the DXC code. */
46 env->fpc = (env->fpc & ~0xff00) | (dxc << 8);
48 s390_program_interrupt(env, PGM_DATA, ILEN_AUTO, retaddr);
51 /* Should be called after any operation that may raise IEEE exceptions. */
52 static void handle_exceptions(CPUS390XState *env, uintptr_t retaddr)
54 unsigned s390_exc, qemu_exc;
56 /* Get the exceptions raised by the current operation. Reset the
57 fpu_status contents so that the next operation has a clean slate. */
58 qemu_exc = env->fpu_status.float_exception_flags;
62 env->fpu_status.float_exception_flags = 0;
64 /* Convert softfloat exception bits to s390 exception bits. */
66 s390_exc |= convert_bit(qemu_exc, float_flag_invalid, 0x80);
67 s390_exc |= convert_bit(qemu_exc, float_flag_divbyzero, 0x40);
68 s390_exc |= convert_bit(qemu_exc, float_flag_overflow, 0x20);
69 s390_exc |= convert_bit(qemu_exc, float_flag_underflow, 0x10);
70 s390_exc |= convert_bit(qemu_exc, float_flag_inexact, 0x08);
72 /* Install the exceptions that we raised. */
73 env->fpc |= s390_exc << 16;
75 /* Send signals for enabled exceptions. */
76 s390_exc &= env->fpc >> 24;
78 ieee_exception(env, s390_exc, retaddr);
82 static inline int float_comp_to_cc(CPUS390XState *env, int float_compare)
84 S390CPU *cpu = s390_env_get_cpu(env);
86 switch (float_compare) {
87 case float_relation_equal:
89 case float_relation_less:
91 case float_relation_greater:
93 case float_relation_unordered:
96 cpu_abort(CPU(cpu), "unknown return value for float compare\n");
100 /* condition codes for unary FP ops */
101 uint32_t set_cc_nz_f32(float32 v)
103 if (float32_is_any_nan(v)) {
105 } else if (float32_is_zero(v)) {
107 } else if (float32_is_neg(v)) {
114 uint32_t set_cc_nz_f64(float64 v)
116 if (float64_is_any_nan(v)) {
118 } else if (float64_is_zero(v)) {
120 } else if (float64_is_neg(v)) {
127 uint32_t set_cc_nz_f128(float128 v)
129 if (float128_is_any_nan(v)) {
131 } else if (float128_is_zero(v)) {
133 } else if (float128_is_neg(v)) {
140 /* 32-bit FP addition */
141 uint64_t HELPER(aeb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
143 float32 ret = float32_add(f1, f2, &env->fpu_status);
144 handle_exceptions(env, GETPC());
148 /* 64-bit FP addition */
149 uint64_t HELPER(adb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
151 float64 ret = float64_add(f1, f2, &env->fpu_status);
152 handle_exceptions(env, GETPC());
156 /* 128-bit FP addition */
157 uint64_t HELPER(axb)(CPUS390XState *env, uint64_t ah, uint64_t al,
158 uint64_t bh, uint64_t bl)
160 float128 ret = float128_add(make_float128(ah, al),
161 make_float128(bh, bl),
163 handle_exceptions(env, GETPC());
167 /* 32-bit FP subtraction */
168 uint64_t HELPER(seb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
170 float32 ret = float32_sub(f1, f2, &env->fpu_status);
171 handle_exceptions(env, GETPC());
175 /* 64-bit FP subtraction */
176 uint64_t HELPER(sdb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
178 float64 ret = float64_sub(f1, f2, &env->fpu_status);
179 handle_exceptions(env, GETPC());
183 /* 128-bit FP subtraction */
184 uint64_t HELPER(sxb)(CPUS390XState *env, uint64_t ah, uint64_t al,
185 uint64_t bh, uint64_t bl)
187 float128 ret = float128_sub(make_float128(ah, al),
188 make_float128(bh, bl),
190 handle_exceptions(env, GETPC());
194 /* 32-bit FP division */
195 uint64_t HELPER(deb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
197 float32 ret = float32_div(f1, f2, &env->fpu_status);
198 handle_exceptions(env, GETPC());
202 /* 64-bit FP division */
203 uint64_t HELPER(ddb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
205 float64 ret = float64_div(f1, f2, &env->fpu_status);
206 handle_exceptions(env, GETPC());
210 /* 128-bit FP division */
211 uint64_t HELPER(dxb)(CPUS390XState *env, uint64_t ah, uint64_t al,
212 uint64_t bh, uint64_t bl)
214 float128 ret = float128_div(make_float128(ah, al),
215 make_float128(bh, bl),
217 handle_exceptions(env, GETPC());
221 /* 32-bit FP multiplication */
222 uint64_t HELPER(meeb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
224 float32 ret = float32_mul(f1, f2, &env->fpu_status);
225 handle_exceptions(env, GETPC());
229 /* 64-bit FP multiplication */
230 uint64_t HELPER(mdb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
232 float64 ret = float64_mul(f1, f2, &env->fpu_status);
233 handle_exceptions(env, GETPC());
237 /* 64/32-bit FP multiplication */
238 uint64_t HELPER(mdeb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
240 float64 ret = float32_to_float64(f2, &env->fpu_status);
241 ret = float64_mul(f1, ret, &env->fpu_status);
242 handle_exceptions(env, GETPC());
246 /* 128-bit FP multiplication */
247 uint64_t HELPER(mxb)(CPUS390XState *env, uint64_t ah, uint64_t al,
248 uint64_t bh, uint64_t bl)
250 float128 ret = float128_mul(make_float128(ah, al),
251 make_float128(bh, bl),
253 handle_exceptions(env, GETPC());
257 /* 128/64-bit FP multiplication */
258 uint64_t HELPER(mxdb)(CPUS390XState *env, uint64_t ah, uint64_t al,
261 float128 ret = float64_to_float128(f2, &env->fpu_status);
262 ret = float128_mul(make_float128(ah, al), ret, &env->fpu_status);
263 handle_exceptions(env, GETPC());
267 /* convert 32-bit float to 64-bit float */
268 uint64_t HELPER(ldeb)(CPUS390XState *env, uint64_t f2)
270 float64 ret = float32_to_float64(f2, &env->fpu_status);
271 handle_exceptions(env, GETPC());
275 /* convert 128-bit float to 64-bit float */
276 uint64_t HELPER(ldxb)(CPUS390XState *env, uint64_t ah, uint64_t al)
278 float64 ret = float128_to_float64(make_float128(ah, al), &env->fpu_status);
279 handle_exceptions(env, GETPC());
283 /* convert 64-bit float to 128-bit float */
284 uint64_t HELPER(lxdb)(CPUS390XState *env, uint64_t f2)
286 float128 ret = float64_to_float128(f2, &env->fpu_status);
287 handle_exceptions(env, GETPC());
291 /* convert 32-bit float to 128-bit float */
292 uint64_t HELPER(lxeb)(CPUS390XState *env, uint64_t f2)
294 float128 ret = float32_to_float128(f2, &env->fpu_status);
295 handle_exceptions(env, GETPC());
299 /* convert 64-bit float to 32-bit float */
300 uint64_t HELPER(ledb)(CPUS390XState *env, uint64_t f2)
302 float32 ret = float64_to_float32(f2, &env->fpu_status);
303 handle_exceptions(env, GETPC());
307 /* convert 128-bit float to 32-bit float */
308 uint64_t HELPER(lexb)(CPUS390XState *env, uint64_t ah, uint64_t al)
310 float32 ret = float128_to_float32(make_float128(ah, al), &env->fpu_status);
311 handle_exceptions(env, GETPC());
315 /* 32-bit FP compare */
316 uint32_t HELPER(ceb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
318 int cmp = float32_compare_quiet(f1, f2, &env->fpu_status);
319 handle_exceptions(env, GETPC());
320 return float_comp_to_cc(env, cmp);
323 /* 64-bit FP compare */
324 uint32_t HELPER(cdb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
326 int cmp = float64_compare_quiet(f1, f2, &env->fpu_status);
327 handle_exceptions(env, GETPC());
328 return float_comp_to_cc(env, cmp);
331 /* 128-bit FP compare */
332 uint32_t HELPER(cxb)(CPUS390XState *env, uint64_t ah, uint64_t al,
333 uint64_t bh, uint64_t bl)
335 int cmp = float128_compare_quiet(make_float128(ah, al),
336 make_float128(bh, bl),
338 handle_exceptions(env, GETPC());
339 return float_comp_to_cc(env, cmp);
342 static int swap_round_mode(CPUS390XState *env, int m3)
344 int ret = env->fpu_status.float_rounding_mode;
350 /* biased round no nearest */
352 /* round to nearest */
353 set_float_rounding_mode(float_round_nearest_even, &env->fpu_status);
357 set_float_rounding_mode(float_round_to_zero, &env->fpu_status);
361 set_float_rounding_mode(float_round_up, &env->fpu_status);
365 set_float_rounding_mode(float_round_down, &env->fpu_status);
371 /* convert 64-bit int to 32-bit float */
372 uint64_t HELPER(cegb)(CPUS390XState *env, int64_t v2, uint32_t m3)
374 int hold = swap_round_mode(env, m3);
375 float32 ret = int64_to_float32(v2, &env->fpu_status);
376 set_float_rounding_mode(hold, &env->fpu_status);
377 handle_exceptions(env, GETPC());
381 /* convert 64-bit int to 64-bit float */
382 uint64_t HELPER(cdgb)(CPUS390XState *env, int64_t v2, uint32_t m3)
384 int hold = swap_round_mode(env, m3);
385 float64 ret = int64_to_float64(v2, &env->fpu_status);
386 set_float_rounding_mode(hold, &env->fpu_status);
387 handle_exceptions(env, GETPC());
391 /* convert 64-bit int to 128-bit float */
392 uint64_t HELPER(cxgb)(CPUS390XState *env, int64_t v2, uint32_t m3)
394 int hold = swap_round_mode(env, m3);
395 float128 ret = int64_to_float128(v2, &env->fpu_status);
396 set_float_rounding_mode(hold, &env->fpu_status);
397 handle_exceptions(env, GETPC());
401 /* convert 64-bit uint to 32-bit float */
402 uint64_t HELPER(celgb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
404 int hold = swap_round_mode(env, m3);
405 float32 ret = uint64_to_float32(v2, &env->fpu_status);
406 set_float_rounding_mode(hold, &env->fpu_status);
407 handle_exceptions(env, GETPC());
411 /* convert 64-bit uint to 64-bit float */
412 uint64_t HELPER(cdlgb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
414 int hold = swap_round_mode(env, m3);
415 float64 ret = uint64_to_float64(v2, &env->fpu_status);
416 set_float_rounding_mode(hold, &env->fpu_status);
417 handle_exceptions(env, GETPC());
421 /* convert 64-bit uint to 128-bit float */
422 uint64_t HELPER(cxlgb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
424 int hold = swap_round_mode(env, m3);
425 float128 ret = uint64_to_float128(v2, &env->fpu_status);
426 set_float_rounding_mode(hold, &env->fpu_status);
427 handle_exceptions(env, GETPC());
431 /* convert 32-bit float to 64-bit int */
432 uint64_t HELPER(cgeb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
434 int hold = swap_round_mode(env, m3);
435 int64_t ret = float32_to_int64(v2, &env->fpu_status);
436 set_float_rounding_mode(hold, &env->fpu_status);
437 handle_exceptions(env, GETPC());
441 /* convert 64-bit float to 64-bit int */
442 uint64_t HELPER(cgdb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
444 int hold = swap_round_mode(env, m3);
445 int64_t ret = float64_to_int64(v2, &env->fpu_status);
446 set_float_rounding_mode(hold, &env->fpu_status);
447 handle_exceptions(env, GETPC());
451 /* convert 128-bit float to 64-bit int */
452 uint64_t HELPER(cgxb)(CPUS390XState *env, uint64_t h, uint64_t l, uint32_t m3)
454 int hold = swap_round_mode(env, m3);
455 float128 v2 = make_float128(h, l);
456 int64_t ret = float128_to_int64(v2, &env->fpu_status);
457 set_float_rounding_mode(hold, &env->fpu_status);
458 handle_exceptions(env, GETPC());
462 /* convert 32-bit float to 32-bit int */
463 uint64_t HELPER(cfeb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
465 int hold = swap_round_mode(env, m3);
466 int32_t ret = float32_to_int32(v2, &env->fpu_status);
467 set_float_rounding_mode(hold, &env->fpu_status);
468 handle_exceptions(env, GETPC());
472 /* convert 64-bit float to 32-bit int */
473 uint64_t HELPER(cfdb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
475 int hold = swap_round_mode(env, m3);
476 int32_t ret = float64_to_int32(v2, &env->fpu_status);
477 set_float_rounding_mode(hold, &env->fpu_status);
478 handle_exceptions(env, GETPC());
482 /* convert 128-bit float to 32-bit int */
483 uint64_t HELPER(cfxb)(CPUS390XState *env, uint64_t h, uint64_t l, uint32_t m3)
485 int hold = swap_round_mode(env, m3);
486 float128 v2 = make_float128(h, l);
487 int32_t ret = float128_to_int32(v2, &env->fpu_status);
488 set_float_rounding_mode(hold, &env->fpu_status);
489 handle_exceptions(env, GETPC());
493 /* convert 32-bit float to 64-bit uint */
494 uint64_t HELPER(clgeb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
496 int hold = swap_round_mode(env, m3);
498 v2 = float32_to_float64(v2, &env->fpu_status);
499 ret = float64_to_uint64(v2, &env->fpu_status);
500 set_float_rounding_mode(hold, &env->fpu_status);
501 handle_exceptions(env, GETPC());
505 /* convert 64-bit float to 64-bit uint */
506 uint64_t HELPER(clgdb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
508 int hold = swap_round_mode(env, m3);
509 uint64_t ret = float64_to_uint64(v2, &env->fpu_status);
510 set_float_rounding_mode(hold, &env->fpu_status);
511 handle_exceptions(env, GETPC());
515 /* convert 128-bit float to 64-bit uint */
516 uint64_t HELPER(clgxb)(CPUS390XState *env, uint64_t h, uint64_t l, uint32_t m3)
518 int hold = swap_round_mode(env, m3);
519 float128 v2 = make_float128(h, l);
520 /* ??? Not 100% correct. */
521 uint64_t ret = float128_to_int64(v2, &env->fpu_status);
522 set_float_rounding_mode(hold, &env->fpu_status);
523 handle_exceptions(env, GETPC());
527 /* convert 32-bit float to 32-bit uint */
528 uint64_t HELPER(clfeb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
530 int hold = swap_round_mode(env, m3);
531 uint32_t ret = float32_to_uint32(v2, &env->fpu_status);
532 set_float_rounding_mode(hold, &env->fpu_status);
533 handle_exceptions(env, GETPC());
537 /* convert 64-bit float to 32-bit uint */
538 uint64_t HELPER(clfdb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
540 int hold = swap_round_mode(env, m3);
541 uint32_t ret = float64_to_uint32(v2, &env->fpu_status);
542 set_float_rounding_mode(hold, &env->fpu_status);
543 handle_exceptions(env, GETPC());
547 /* convert 128-bit float to 32-bit uint */
548 uint64_t HELPER(clfxb)(CPUS390XState *env, uint64_t h, uint64_t l, uint32_t m3)
550 int hold = swap_round_mode(env, m3);
551 float128 v2 = make_float128(h, l);
552 /* Not 100% correct. */
553 uint32_t ret = float128_to_int64(v2, &env->fpu_status);
554 set_float_rounding_mode(hold, &env->fpu_status);
555 handle_exceptions(env, GETPC());
559 /* round to integer 32-bit */
560 uint64_t HELPER(fieb)(CPUS390XState *env, uint64_t f2, uint32_t m3)
562 int hold = swap_round_mode(env, m3);
563 float32 ret = float32_round_to_int(f2, &env->fpu_status);
564 set_float_rounding_mode(hold, &env->fpu_status);
565 handle_exceptions(env, GETPC());
569 /* round to integer 64-bit */
570 uint64_t HELPER(fidb)(CPUS390XState *env, uint64_t f2, uint32_t m3)
572 int hold = swap_round_mode(env, m3);
573 float64 ret = float64_round_to_int(f2, &env->fpu_status);
574 set_float_rounding_mode(hold, &env->fpu_status);
575 handle_exceptions(env, GETPC());
579 /* round to integer 128-bit */
580 uint64_t HELPER(fixb)(CPUS390XState *env, uint64_t ah, uint64_t al, uint32_t m3)
582 int hold = swap_round_mode(env, m3);
583 float128 ret = float128_round_to_int(make_float128(ah, al),
585 set_float_rounding_mode(hold, &env->fpu_status);
586 handle_exceptions(env, GETPC());
590 /* 32-bit FP compare and signal */
591 uint32_t HELPER(keb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
593 int cmp = float32_compare(f1, f2, &env->fpu_status);
594 handle_exceptions(env, GETPC());
595 return float_comp_to_cc(env, cmp);
598 /* 64-bit FP compare and signal */
599 uint32_t HELPER(kdb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
601 int cmp = float64_compare(f1, f2, &env->fpu_status);
602 handle_exceptions(env, GETPC());
603 return float_comp_to_cc(env, cmp);
606 /* 128-bit FP compare and signal */
607 uint32_t HELPER(kxb)(CPUS390XState *env, uint64_t ah, uint64_t al,
608 uint64_t bh, uint64_t bl)
610 int cmp = float128_compare(make_float128(ah, al),
611 make_float128(bh, bl),
613 handle_exceptions(env, GETPC());
614 return float_comp_to_cc(env, cmp);
617 /* 32-bit FP multiply and add */
618 uint64_t HELPER(maeb)(CPUS390XState *env, uint64_t f1,
619 uint64_t f2, uint64_t f3)
621 float32 ret = float32_muladd(f2, f3, f1, 0, &env->fpu_status);
622 handle_exceptions(env, GETPC());
626 /* 64-bit FP multiply and add */
627 uint64_t HELPER(madb)(CPUS390XState *env, uint64_t f1,
628 uint64_t f2, uint64_t f3)
630 float64 ret = float64_muladd(f2, f3, f1, 0, &env->fpu_status);
631 handle_exceptions(env, GETPC());
635 /* 32-bit FP multiply and subtract */
636 uint64_t HELPER(mseb)(CPUS390XState *env, uint64_t f1,
637 uint64_t f2, uint64_t f3)
639 float32 ret = float32_muladd(f2, f3, f1, float_muladd_negate_c,
641 handle_exceptions(env, GETPC());
645 /* 64-bit FP multiply and subtract */
646 uint64_t HELPER(msdb)(CPUS390XState *env, uint64_t f1,
647 uint64_t f2, uint64_t f3)
649 float64 ret = float64_muladd(f2, f3, f1, float_muladd_negate_c,
651 handle_exceptions(env, GETPC());
655 /* test data class 32-bit */
656 uint32_t HELPER(tceb)(CPUS390XState *env, uint64_t f1, uint64_t m2)
659 int neg = float32_is_neg(v1);
662 if ((float32_is_zero(v1) && (m2 & (1 << (11-neg)))) ||
663 (float32_is_infinity(v1) && (m2 & (1 << (5-neg)))) ||
664 (float32_is_any_nan(v1) && (m2 & (1 << (3-neg)))) ||
665 (float32_is_signaling_nan(v1, &env->fpu_status) &&
666 (m2 & (1 << (1-neg))))) {
668 } else if (m2 & (1 << (9-neg))) {
669 /* assume normalized number */
672 /* FIXME: denormalized? */
676 /* test data class 64-bit */
677 uint32_t HELPER(tcdb)(CPUS390XState *env, uint64_t v1, uint64_t m2)
679 int neg = float64_is_neg(v1);
682 if ((float64_is_zero(v1) && (m2 & (1 << (11-neg)))) ||
683 (float64_is_infinity(v1) && (m2 & (1 << (5-neg)))) ||
684 (float64_is_any_nan(v1) && (m2 & (1 << (3-neg)))) ||
685 (float64_is_signaling_nan(v1, &env->fpu_status) &&
686 (m2 & (1 << (1-neg))))) {
688 } else if (m2 & (1 << (9-neg))) {
689 /* assume normalized number */
692 /* FIXME: denormalized? */
696 /* test data class 128-bit */
697 uint32_t HELPER(tcxb)(CPUS390XState *env, uint64_t ah,
698 uint64_t al, uint64_t m2)
700 float128 v1 = make_float128(ah, al);
701 int neg = float128_is_neg(v1);
704 if ((float128_is_zero(v1) && (m2 & (1 << (11-neg)))) ||
705 (float128_is_infinity(v1) && (m2 & (1 << (5-neg)))) ||
706 (float128_is_any_nan(v1) && (m2 & (1 << (3-neg)))) ||
707 (float128_is_signaling_nan(v1, &env->fpu_status) &&
708 (m2 & (1 << (1-neg))))) {
710 } else if (m2 & (1 << (9-neg))) {
711 /* assume normalized number */
714 /* FIXME: denormalized? */
718 /* square root 32-bit */
719 uint64_t HELPER(sqeb)(CPUS390XState *env, uint64_t f2)
721 float32 ret = float32_sqrt(f2, &env->fpu_status);
722 handle_exceptions(env, GETPC());
726 /* square root 64-bit */
727 uint64_t HELPER(sqdb)(CPUS390XState *env, uint64_t f2)
729 float64 ret = float64_sqrt(f2, &env->fpu_status);
730 handle_exceptions(env, GETPC());
734 /* square root 128-bit */
735 uint64_t HELPER(sqxb)(CPUS390XState *env, uint64_t ah, uint64_t al)
737 float128 ret = float128_sqrt(make_float128(ah, al), &env->fpu_status);
738 handle_exceptions(env, GETPC());
742 static const int fpc_to_rnd[4] = {
743 float_round_nearest_even,
750 void HELPER(sfpc)(CPUS390XState *env, uint64_t fpc)
752 /* Install everything in the main FPC. */
755 /* Install the rounding mode in the shadow fpu_status. */
756 set_float_rounding_mode(fpc_to_rnd[fpc & 3], &env->fpu_status);
759 /* set fpc and signal */
760 void HELPER(sfas)(CPUS390XState *env, uint64_t val)
762 uint32_t signalling = env->fpc;
763 uint32_t source = val;
766 /* The contents of the source operand are placed in the FPC register;
767 then the flags in the FPC register are set to the logical OR of the
768 signalling flags and the source flags. */
769 env->fpc = source | (signalling & 0x00ff0000);
770 set_float_rounding_mode(fpc_to_rnd[source & 3], &env->fpu_status);
772 /* If any signalling flag is 1 and the corresponding source mask
773 is also 1, a simulated-iee-exception trap occurs. */
774 s390_exc = (signalling >> 16) & (source >> 24);
776 ieee_exception(env, s390_exc | 3, GETPC());