target-s390: Implement SET ROUNDING MODE

Signed-off-by: Richard Henderson <rth@twiddle.net>
This commit is contained in:
Richard Henderson 2012-09-10 16:26:35 -07:00
parent d2d9feac6f
commit a12000b9ec
2 changed files with 44 additions and 0 deletions

View File

@ -566,6 +566,11 @@
C(0xb24e, SAR, RRE, Z, 0, r2_o, 0, 0, sar, 0)
/* SET FPC */
C(0xb384, SFPC, RRE, Z, 0, r1_o, 0, 0, sfpc, 0)
/* SET BFP ROUNDING MODE */
C(0xb299, SRNM, S, Z, 0, 0, 0, 0, srnm, 0)
C(0xb2b8, SRNMB, S, FPE, 0, 0, 0, 0, srnm, 0)
/* SET DFP ROUNDING MODE */
C(0xb2b9, SRNMT, S, DFP, 0, 0, 0, 0, srnm, 0)
/* SHIFT LEFT SINGLE */
D(0x8b00, SLA, RS_a, Z, r1, sh32, new, r1_32, sla, 0, 31)

View File

@ -2921,6 +2921,45 @@ static ExitStatus op_sfpc(DisasContext *s, DisasOps *o)
return NO_EXIT;
}
static ExitStatus op_srnm(DisasContext *s, DisasOps *o)
{
int b2 = get_field(s->fields, b2);
int d2 = get_field(s->fields, d2);
TCGv_i64 t1 = tcg_temp_new_i64();
TCGv_i64 t2 = tcg_temp_new_i64();
int mask, pos, len;
switch (s->fields->op2) {
case 0x99: /* SRNM */
pos = 0, len = 2;
break;
case 0xb8: /* SRNMB */
pos = 0, len = 3;
break;
case 0xb9: /* SRNMT */
pos = 4, len = 3;
default:
tcg_abort();
}
mask = (1 << len) - 1;
/* Insert the value into the appropriate field of the FPC. */
if (b2 == 0) {
tcg_gen_movi_i64(t1, d2 & mask);
} else {
tcg_gen_addi_i64(t1, regs[b2], d2);
tcg_gen_andi_i64(t1, t1, mask);
}
tcg_gen_ld32u_i64(t2, cpu_env, offsetof(CPUS390XState, fpc));
tcg_gen_deposit_i64(t2, t2, t1, pos, len);
tcg_temp_free_i64(t1);
/* Then install the new FPC to set the rounding mode in fpu_status. */
gen_helper_sfpc(cpu_env, t2);
tcg_temp_free_i64(t2);
return NO_EXIT;
}
#ifndef CONFIG_USER_ONLY
static ExitStatus op_spka(DisasContext *s, DisasOps *o)
{