net: cadence_gem: Make phy respond to broadcast
[qemu.git] / target-s390x / fpu_helper.c
blob3e9c7b2d6834013b5694a1f0370b909da1dc77f6
1 /*
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 "cpu.h"
22 #include "helper.h"
24 #if !defined(CONFIG_USER_ONLY)
25 #include "exec/softmmu_exec.h"
26 #endif
28 /* #define DEBUG_HELPER */
29 #ifdef DEBUG_HELPER
30 #define HELPER_LOG(x...) qemu_log(x)
31 #else
32 #define HELPER_LOG(x...)
33 #endif
35 #define RET128(F) (env->retxl = F.low, F.high)
37 #define convert_bit(mask, from, to) \
38 (to < from \
39 ? (mask / (from / to)) & to \
40 : (mask & from) * (to / from))
42 static void ieee_exception(CPUS390XState *env, uint32_t dxc, uintptr_t retaddr)
44 /* Install the DXC code. */
45 env->fpc = (env->fpc & ~0xff00) | (dxc << 8);
46 /* Trap. */
47 runtime_exception(env, PGM_DATA, retaddr);
50 /* Should be called after any operation that may raise IEEE exceptions. */
51 static void handle_exceptions(CPUS390XState *env, uintptr_t retaddr)
53 unsigned s390_exc, qemu_exc;
55 /* Get the exceptions raised by the current operation. Reset the
56 fpu_status contents so that the next operation has a clean slate. */
57 qemu_exc = env->fpu_status.float_exception_flags;
58 if (qemu_exc == 0) {
59 return;
61 env->fpu_status.float_exception_flags = 0;
63 /* Convert softfloat exception bits to s390 exception bits. */
64 s390_exc = 0;
65 s390_exc |= convert_bit(qemu_exc, float_flag_invalid, 0x80);
66 s390_exc |= convert_bit(qemu_exc, float_flag_divbyzero, 0x40);
67 s390_exc |= convert_bit(qemu_exc, float_flag_overflow, 0x20);
68 s390_exc |= convert_bit(qemu_exc, float_flag_underflow, 0x10);
69 s390_exc |= convert_bit(qemu_exc, float_flag_inexact, 0x08);
71 /* Install the exceptions that we raised. */
72 env->fpc |= s390_exc << 16;
74 /* Send signals for enabled exceptions. */
75 s390_exc &= env->fpc >> 24;
76 if (s390_exc) {
77 ieee_exception(env, s390_exc, retaddr);
81 static inline int float_comp_to_cc(CPUS390XState *env, int float_compare)
83 S390CPU *cpu = s390_env_get_cpu(env);
85 switch (float_compare) {
86 case float_relation_equal:
87 return 0;
88 case float_relation_less:
89 return 1;
90 case float_relation_greater:
91 return 2;
92 case float_relation_unordered:
93 return 3;
94 default:
95 cpu_abort(CPU(cpu), "unknown return value for float compare\n");
99 /* condition codes for unary FP ops */
100 uint32_t set_cc_nz_f32(float32 v)
102 if (float32_is_any_nan(v)) {
103 return 3;
104 } else if (float32_is_zero(v)) {
105 return 0;
106 } else if (float32_is_neg(v)) {
107 return 1;
108 } else {
109 return 2;
113 uint32_t set_cc_nz_f64(float64 v)
115 if (float64_is_any_nan(v)) {
116 return 3;
117 } else if (float64_is_zero(v)) {
118 return 0;
119 } else if (float64_is_neg(v)) {
120 return 1;
121 } else {
122 return 2;
126 uint32_t set_cc_nz_f128(float128 v)
128 if (float128_is_any_nan(v)) {
129 return 3;
130 } else if (float128_is_zero(v)) {
131 return 0;
132 } else if (float128_is_neg(v)) {
133 return 1;
134 } else {
135 return 2;
139 /* 32-bit FP addition */
140 uint64_t HELPER(aeb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
142 float32 ret = float32_add(f1, f2, &env->fpu_status);
143 handle_exceptions(env, GETPC());
144 return ret;
147 /* 64-bit FP addition */
148 uint64_t HELPER(adb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
150 float64 ret = float64_add(f1, f2, &env->fpu_status);
151 handle_exceptions(env, GETPC());
152 return ret;
155 /* 128-bit FP addition */
156 uint64_t HELPER(axb)(CPUS390XState *env, uint64_t ah, uint64_t al,
157 uint64_t bh, uint64_t bl)
159 float128 ret = float128_add(make_float128(ah, al),
160 make_float128(bh, bl),
161 &env->fpu_status);
162 handle_exceptions(env, GETPC());
163 return RET128(ret);
166 /* 32-bit FP subtraction */
167 uint64_t HELPER(seb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
169 float32 ret = float32_sub(f1, f2, &env->fpu_status);
170 handle_exceptions(env, GETPC());
171 return ret;
174 /* 64-bit FP subtraction */
175 uint64_t HELPER(sdb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
177 float64 ret = float64_sub(f1, f2, &env->fpu_status);
178 handle_exceptions(env, GETPC());
179 return ret;
182 /* 128-bit FP subtraction */
183 uint64_t HELPER(sxb)(CPUS390XState *env, uint64_t ah, uint64_t al,
184 uint64_t bh, uint64_t bl)
186 float128 ret = float128_sub(make_float128(ah, al),
187 make_float128(bh, bl),
188 &env->fpu_status);
189 handle_exceptions(env, GETPC());
190 return RET128(ret);
193 /* 32-bit FP division */
194 uint64_t HELPER(deb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
196 float32 ret = float32_div(f1, f2, &env->fpu_status);
197 handle_exceptions(env, GETPC());
198 return ret;
201 /* 64-bit FP division */
202 uint64_t HELPER(ddb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
204 float64 ret = float64_div(f1, f2, &env->fpu_status);
205 handle_exceptions(env, GETPC());
206 return ret;
209 /* 128-bit FP division */
210 uint64_t HELPER(dxb)(CPUS390XState *env, uint64_t ah, uint64_t al,
211 uint64_t bh, uint64_t bl)
213 float128 ret = float128_div(make_float128(ah, al),
214 make_float128(bh, bl),
215 &env->fpu_status);
216 handle_exceptions(env, GETPC());
217 return RET128(ret);
220 /* 32-bit FP multiplication */
221 uint64_t HELPER(meeb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
223 float32 ret = float32_mul(f1, f2, &env->fpu_status);
224 handle_exceptions(env, GETPC());
225 return ret;
228 /* 64-bit FP multiplication */
229 uint64_t HELPER(mdb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
231 float64 ret = float64_mul(f1, f2, &env->fpu_status);
232 handle_exceptions(env, GETPC());
233 return ret;
236 /* 64/32-bit FP multiplication */
237 uint64_t HELPER(mdeb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
239 float64 ret = float32_to_float64(f2, &env->fpu_status);
240 ret = float64_mul(f1, ret, &env->fpu_status);
241 handle_exceptions(env, GETPC());
242 return ret;
245 /* 128-bit FP multiplication */
246 uint64_t HELPER(mxb)(CPUS390XState *env, uint64_t ah, uint64_t al,
247 uint64_t bh, uint64_t bl)
249 float128 ret = float128_mul(make_float128(ah, al),
250 make_float128(bh, bl),
251 &env->fpu_status);
252 handle_exceptions(env, GETPC());
253 return RET128(ret);
256 /* 128/64-bit FP multiplication */
257 uint64_t HELPER(mxdb)(CPUS390XState *env, uint64_t ah, uint64_t al,
258 uint64_t f2)
260 float128 ret = float64_to_float128(f2, &env->fpu_status);
261 ret = float128_mul(make_float128(ah, al), ret, &env->fpu_status);
262 handle_exceptions(env, GETPC());
263 return RET128(ret);
266 /* convert 32-bit float to 64-bit float */
267 uint64_t HELPER(ldeb)(CPUS390XState *env, uint64_t f2)
269 float64 ret = float32_to_float64(f2, &env->fpu_status);
270 handle_exceptions(env, GETPC());
271 return ret;
274 /* convert 128-bit float to 64-bit float */
275 uint64_t HELPER(ldxb)(CPUS390XState *env, uint64_t ah, uint64_t al)
277 float64 ret = float128_to_float64(make_float128(ah, al), &env->fpu_status);
278 handle_exceptions(env, GETPC());
279 return ret;
282 /* convert 64-bit float to 128-bit float */
283 uint64_t HELPER(lxdb)(CPUS390XState *env, uint64_t f2)
285 float128 ret = float64_to_float128(f2, &env->fpu_status);
286 handle_exceptions(env, GETPC());
287 return RET128(ret);
290 /* convert 32-bit float to 128-bit float */
291 uint64_t HELPER(lxeb)(CPUS390XState *env, uint64_t f2)
293 float128 ret = float32_to_float128(f2, &env->fpu_status);
294 handle_exceptions(env, GETPC());
295 return RET128(ret);
298 /* convert 64-bit float to 32-bit float */
299 uint64_t HELPER(ledb)(CPUS390XState *env, uint64_t f2)
301 float32 ret = float64_to_float32(f2, &env->fpu_status);
302 handle_exceptions(env, GETPC());
303 return ret;
306 /* convert 128-bit float to 32-bit float */
307 uint64_t HELPER(lexb)(CPUS390XState *env, uint64_t ah, uint64_t al)
309 float32 ret = float128_to_float32(make_float128(ah, al), &env->fpu_status);
310 handle_exceptions(env, GETPC());
311 return ret;
314 /* 32-bit FP compare */
315 uint32_t HELPER(ceb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
317 int cmp = float32_compare_quiet(f1, f2, &env->fpu_status);
318 handle_exceptions(env, GETPC());
319 return float_comp_to_cc(env, cmp);
322 /* 64-bit FP compare */
323 uint32_t HELPER(cdb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
325 int cmp = float64_compare_quiet(f1, f2, &env->fpu_status);
326 handle_exceptions(env, GETPC());
327 return float_comp_to_cc(env, cmp);
330 /* 128-bit FP compare */
331 uint32_t HELPER(cxb)(CPUS390XState *env, uint64_t ah, uint64_t al,
332 uint64_t bh, uint64_t bl)
334 int cmp = float128_compare_quiet(make_float128(ah, al),
335 make_float128(bh, bl),
336 &env->fpu_status);
337 handle_exceptions(env, GETPC());
338 return float_comp_to_cc(env, cmp);
341 static int swap_round_mode(CPUS390XState *env, int m3)
343 int ret = env->fpu_status.float_rounding_mode;
344 switch (m3) {
345 case 0:
346 /* current mode */
347 break;
348 case 1:
349 /* biased round no nearest */
350 case 4:
351 /* round to nearest */
352 set_float_rounding_mode(float_round_nearest_even, &env->fpu_status);
353 break;
354 case 5:
355 /* round to zero */
356 set_float_rounding_mode(float_round_to_zero, &env->fpu_status);
357 break;
358 case 6:
359 /* round to +inf */
360 set_float_rounding_mode(float_round_up, &env->fpu_status);
361 break;
362 case 7:
363 /* round to -inf */
364 set_float_rounding_mode(float_round_down, &env->fpu_status);
365 break;
367 return ret;
370 /* convert 64-bit int to 32-bit float */
371 uint64_t HELPER(cegb)(CPUS390XState *env, int64_t v2, uint32_t m3)
373 int hold = swap_round_mode(env, m3);
374 float32 ret = int64_to_float32(v2, &env->fpu_status);
375 set_float_rounding_mode(hold, &env->fpu_status);
376 handle_exceptions(env, GETPC());
377 return ret;
380 /* convert 64-bit int to 64-bit float */
381 uint64_t HELPER(cdgb)(CPUS390XState *env, int64_t v2, uint32_t m3)
383 int hold = swap_round_mode(env, m3);
384 float64 ret = int64_to_float64(v2, &env->fpu_status);
385 set_float_rounding_mode(hold, &env->fpu_status);
386 handle_exceptions(env, GETPC());
387 return ret;
390 /* convert 64-bit int to 128-bit float */
391 uint64_t HELPER(cxgb)(CPUS390XState *env, int64_t v2, uint32_t m3)
393 int hold = swap_round_mode(env, m3);
394 float128 ret = int64_to_float128(v2, &env->fpu_status);
395 set_float_rounding_mode(hold, &env->fpu_status);
396 handle_exceptions(env, GETPC());
397 return RET128(ret);
400 /* convert 64-bit uint to 32-bit float */
401 uint64_t HELPER(celgb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
403 int hold = swap_round_mode(env, m3);
404 float32 ret = uint64_to_float32(v2, &env->fpu_status);
405 set_float_rounding_mode(hold, &env->fpu_status);
406 handle_exceptions(env, GETPC());
407 return ret;
410 /* convert 64-bit uint to 64-bit float */
411 uint64_t HELPER(cdlgb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
413 int hold = swap_round_mode(env, m3);
414 float64 ret = uint64_to_float64(v2, &env->fpu_status);
415 set_float_rounding_mode(hold, &env->fpu_status);
416 handle_exceptions(env, GETPC());
417 return ret;
420 /* convert 64-bit uint to 128-bit float */
421 uint64_t HELPER(cxlgb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
423 int hold = swap_round_mode(env, m3);
424 float128 ret = uint64_to_float128(v2, &env->fpu_status);
425 set_float_rounding_mode(hold, &env->fpu_status);
426 handle_exceptions(env, GETPC());
427 return RET128(ret);
430 /* convert 32-bit float to 64-bit int */
431 uint64_t HELPER(cgeb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
433 int hold = swap_round_mode(env, m3);
434 int64_t ret = float32_to_int64(v2, &env->fpu_status);
435 set_float_rounding_mode(hold, &env->fpu_status);
436 handle_exceptions(env, GETPC());
437 return ret;
440 /* convert 64-bit float to 64-bit int */
441 uint64_t HELPER(cgdb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
443 int hold = swap_round_mode(env, m3);
444 int64_t ret = float64_to_int64(v2, &env->fpu_status);
445 set_float_rounding_mode(hold, &env->fpu_status);
446 handle_exceptions(env, GETPC());
447 return ret;
450 /* convert 128-bit float to 64-bit int */
451 uint64_t HELPER(cgxb)(CPUS390XState *env, uint64_t h, uint64_t l, uint32_t m3)
453 int hold = swap_round_mode(env, m3);
454 float128 v2 = make_float128(h, l);
455 int64_t ret = float128_to_int64(v2, &env->fpu_status);
456 set_float_rounding_mode(hold, &env->fpu_status);
457 handle_exceptions(env, GETPC());
458 return ret;
461 /* convert 32-bit float to 32-bit int */
462 uint64_t HELPER(cfeb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
464 int hold = swap_round_mode(env, m3);
465 int32_t ret = float32_to_int32(v2, &env->fpu_status);
466 set_float_rounding_mode(hold, &env->fpu_status);
467 handle_exceptions(env, GETPC());
468 return ret;
471 /* convert 64-bit float to 32-bit int */
472 uint64_t HELPER(cfdb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
474 int hold = swap_round_mode(env, m3);
475 int32_t ret = float64_to_int32(v2, &env->fpu_status);
476 set_float_rounding_mode(hold, &env->fpu_status);
477 handle_exceptions(env, GETPC());
478 return ret;
481 /* convert 128-bit float to 32-bit int */
482 uint64_t HELPER(cfxb)(CPUS390XState *env, uint64_t h, uint64_t l, uint32_t m3)
484 int hold = swap_round_mode(env, m3);
485 float128 v2 = make_float128(h, l);
486 int32_t ret = float128_to_int32(v2, &env->fpu_status);
487 set_float_rounding_mode(hold, &env->fpu_status);
488 handle_exceptions(env, GETPC());
489 return ret;
492 /* convert 32-bit float to 64-bit uint */
493 uint64_t HELPER(clgeb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
495 int hold = swap_round_mode(env, m3);
496 uint64_t ret;
497 v2 = float32_to_float64(v2, &env->fpu_status);
498 ret = float64_to_uint64(v2, &env->fpu_status);
499 set_float_rounding_mode(hold, &env->fpu_status);
500 handle_exceptions(env, GETPC());
501 return ret;
504 /* convert 64-bit float to 64-bit uint */
505 uint64_t HELPER(clgdb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
507 int hold = swap_round_mode(env, m3);
508 uint64_t ret = float64_to_uint64(v2, &env->fpu_status);
509 set_float_rounding_mode(hold, &env->fpu_status);
510 handle_exceptions(env, GETPC());
511 return ret;
514 /* convert 128-bit float to 64-bit uint */
515 uint64_t HELPER(clgxb)(CPUS390XState *env, uint64_t h, uint64_t l, uint32_t m3)
517 int hold = swap_round_mode(env, m3);
518 float128 v2 = make_float128(h, l);
519 /* ??? Not 100% correct. */
520 uint64_t ret = float128_to_int64(v2, &env->fpu_status);
521 set_float_rounding_mode(hold, &env->fpu_status);
522 handle_exceptions(env, GETPC());
523 return ret;
526 /* convert 32-bit float to 32-bit uint */
527 uint64_t HELPER(clfeb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
529 int hold = swap_round_mode(env, m3);
530 uint32_t ret = float32_to_uint32(v2, &env->fpu_status);
531 set_float_rounding_mode(hold, &env->fpu_status);
532 handle_exceptions(env, GETPC());
533 return ret;
536 /* convert 64-bit float to 32-bit uint */
537 uint64_t HELPER(clfdb)(CPUS390XState *env, uint64_t v2, uint32_t m3)
539 int hold = swap_round_mode(env, m3);
540 uint32_t ret = float64_to_uint32(v2, &env->fpu_status);
541 set_float_rounding_mode(hold, &env->fpu_status);
542 handle_exceptions(env, GETPC());
543 return ret;
546 /* convert 128-bit float to 32-bit uint */
547 uint64_t HELPER(clfxb)(CPUS390XState *env, uint64_t h, uint64_t l, uint32_t m3)
549 int hold = swap_round_mode(env, m3);
550 float128 v2 = make_float128(h, l);
551 /* Not 100% correct. */
552 uint32_t ret = float128_to_int64(v2, &env->fpu_status);
553 set_float_rounding_mode(hold, &env->fpu_status);
554 handle_exceptions(env, GETPC());
555 return ret;
558 /* 32-bit FP multiply and add */
559 uint64_t HELPER(maeb)(CPUS390XState *env, uint64_t f1,
560 uint64_t f2, uint64_t f3)
562 float32 ret = float32_muladd(f2, f3, f1, 0, &env->fpu_status);
563 handle_exceptions(env, GETPC());
564 return ret;
567 /* 64-bit FP multiply and add */
568 uint64_t HELPER(madb)(CPUS390XState *env, uint64_t f1,
569 uint64_t f2, uint64_t f3)
571 float64 ret = float64_muladd(f2, f3, f1, 0, &env->fpu_status);
572 handle_exceptions(env, GETPC());
573 return ret;
576 /* 32-bit FP multiply and subtract */
577 uint64_t HELPER(mseb)(CPUS390XState *env, uint64_t f1,
578 uint64_t f2, uint64_t f3)
580 float32 ret = float32_muladd(f2, f3, f1, float_muladd_negate_c,
581 &env->fpu_status);
582 handle_exceptions(env, GETPC());
583 return ret;
586 /* 64-bit FP multiply and subtract */
587 uint64_t HELPER(msdb)(CPUS390XState *env, uint64_t f1,
588 uint64_t f2, uint64_t f3)
590 float64 ret = float64_muladd(f2, f3, f1, float_muladd_negate_c,
591 &env->fpu_status);
592 handle_exceptions(env, GETPC());
593 return ret;
596 /* test data class 32-bit */
597 uint32_t HELPER(tceb)(uint64_t f1, uint64_t m2)
599 float32 v1 = f1;
600 int neg = float32_is_neg(v1);
601 uint32_t cc = 0;
603 if ((float32_is_zero(v1) && (m2 & (1 << (11-neg)))) ||
604 (float32_is_infinity(v1) && (m2 & (1 << (5-neg)))) ||
605 (float32_is_any_nan(v1) && (m2 & (1 << (3-neg)))) ||
606 (float32_is_signaling_nan(v1) && (m2 & (1 << (1-neg))))) {
607 cc = 1;
608 } else if (m2 & (1 << (9-neg))) {
609 /* assume normalized number */
610 cc = 1;
612 /* FIXME: denormalized? */
613 return cc;
616 /* test data class 64-bit */
617 uint32_t HELPER(tcdb)(uint64_t v1, uint64_t m2)
619 int neg = float64_is_neg(v1);
620 uint32_t cc = 0;
622 if ((float64_is_zero(v1) && (m2 & (1 << (11-neg)))) ||
623 (float64_is_infinity(v1) && (m2 & (1 << (5-neg)))) ||
624 (float64_is_any_nan(v1) && (m2 & (1 << (3-neg)))) ||
625 (float64_is_signaling_nan(v1) && (m2 & (1 << (1-neg))))) {
626 cc = 1;
627 } else if (m2 & (1 << (9-neg))) {
628 /* assume normalized number */
629 cc = 1;
631 /* FIXME: denormalized? */
632 return cc;
635 /* test data class 128-bit */
636 uint32_t HELPER(tcxb)(uint64_t ah, uint64_t al, uint64_t m2)
638 float128 v1 = make_float128(ah, al);
639 int neg = float128_is_neg(v1);
640 uint32_t cc = 0;
642 if ((float128_is_zero(v1) && (m2 & (1 << (11-neg)))) ||
643 (float128_is_infinity(v1) && (m2 & (1 << (5-neg)))) ||
644 (float128_is_any_nan(v1) && (m2 & (1 << (3-neg)))) ||
645 (float128_is_signaling_nan(v1) && (m2 & (1 << (1-neg))))) {
646 cc = 1;
647 } else if (m2 & (1 << (9-neg))) {
648 /* assume normalized number */
649 cc = 1;
651 /* FIXME: denormalized? */
652 return cc;
655 /* square root 32-bit */
656 uint64_t HELPER(sqeb)(CPUS390XState *env, uint64_t f2)
658 float32 ret = float32_sqrt(f2, &env->fpu_status);
659 handle_exceptions(env, GETPC());
660 return ret;
663 /* square root 64-bit */
664 uint64_t HELPER(sqdb)(CPUS390XState *env, uint64_t f2)
666 float64 ret = float64_sqrt(f2, &env->fpu_status);
667 handle_exceptions(env, GETPC());
668 return ret;
671 /* square root 128-bit */
672 uint64_t HELPER(sqxb)(CPUS390XState *env, uint64_t ah, uint64_t al)
674 float128 ret = float128_sqrt(make_float128(ah, al), &env->fpu_status);
675 handle_exceptions(env, GETPC());
676 return RET128(ret);
679 static const int fpc_to_rnd[4] = {
680 float_round_nearest_even,
681 float_round_to_zero,
682 float_round_up,
683 float_round_down
686 /* set fpc */
687 void HELPER(sfpc)(CPUS390XState *env, uint64_t fpc)
689 /* Install everything in the main FPC. */
690 env->fpc = fpc;
692 /* Install the rounding mode in the shadow fpu_status. */
693 set_float_rounding_mode(fpc_to_rnd[fpc & 3], &env->fpu_status);
696 /* set fpc and signal */
697 void HELPER(sfas)(CPUS390XState *env, uint64_t val)
699 uint32_t signalling = env->fpc;
700 uint32_t source = val;
701 uint32_t s390_exc;
703 /* The contents of the source operand are placed in the FPC register;
704 then the flags in the FPC register are set to the logical OR of the
705 signalling flags and the source flags. */
706 env->fpc = source | (signalling & 0x00ff0000);
707 set_float_rounding_mode(fpc_to_rnd[source & 3], &env->fpu_status);
709 /* If any signalling flag is 1 and the corresponding source mask
710 is also 1, a simulated-iee-exception trap occurs. */
711 s390_exc = (signalling >> 16) & (source >> 24);
712 if (s390_exc) {
713 ieee_exception(env, s390_exc | 3, GETPC());