Skip to content

Commit

Permalink
target-ppc: Implement round to odd variants of quad FP instructions
Browse files Browse the repository at this point in the history
xsaddqpo:  VSX Scalar Add Quad-Precision using round to Odd
xsmulqo:   VSX Scalar Multiply Quad-Precision using round to Odd
xsdivqpo:  VSX Scalar Divide Quad-Precision using round to Odd
xscvqpdpo: VSX Scalar round & Convert Quad-Precision format to
           Double-Precision format using round to Odd
xssqrtqpo: VSX Scalar Square Root Quad-Precision using round to Odd
xssubqpo:  VSX Scalar Subtract Quad-Precision using round to Odd

In addition, fix the invalid bitmask in the instruction encoding
of xssqrtqp[o].

Signed-off-by: Bharata B Rao <[email protected]>
CC: Jose Ricardo Ziviani <[email protected]>
Signed-off-by: David Gibson <[email protected]>
  • Loading branch information
Bharata B Rao authored and dgibson committed Feb 22, 2017
1 parent fd42503 commit a8d411a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
42 changes: 20 additions & 22 deletions target/ppc/fpu_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -1850,12 +1850,11 @@ void helper_xsaddqp(CPUPPCState *env, uint32_t opcode)
getVSR(rD(opcode) + 32, &xt, env);
helper_reset_fpstatus(env);

tstat = env->fp_status;
if (unlikely(Rc(opcode) != 0)) {
/* TODO: Support xsadddpo after round-to-odd is implemented */
abort();
tstat.float_rounding_mode = float_round_to_odd;
}

tstat = env->fp_status;
set_float_exception_flags(0, &tstat);
xt.f128 = float128_add(xa.f128, xb.f128, &tstat);
env->fp_status.float_exception_flags |= tstat.float_exception_flags;
Expand Down Expand Up @@ -1930,19 +1929,18 @@ VSX_MUL(xvmulsp, 4, float32, VsrW(i), 0, 0)
void helper_xsmulqp(CPUPPCState *env, uint32_t opcode)
{
ppc_vsr_t xt, xa, xb;
float_status tstat;

getVSR(rA(opcode) + 32, &xa, env);
getVSR(rB(opcode) + 32, &xb, env);
getVSR(rD(opcode) + 32, &xt, env);

helper_reset_fpstatus(env);
tstat = env->fp_status;
if (unlikely(Rc(opcode) != 0)) {
/* TODO: Support xsmulpo after round-to-odd is implemented */
abort();
tstat.float_rounding_mode = float_round_to_odd;
}

helper_reset_fpstatus(env);

float_status tstat = env->fp_status;
set_float_exception_flags(0, &tstat);
xt.f128 = float128_mul(xa.f128, xb.f128, &tstat);
env->fp_status.float_exception_flags |= tstat.float_exception_flags;
Expand Down Expand Up @@ -2019,18 +2017,18 @@ VSX_DIV(xvdivsp, 4, float32, VsrW(i), 0, 0)
void helper_xsdivqp(CPUPPCState *env, uint32_t opcode)
{
ppc_vsr_t xt, xa, xb;
float_status tstat;

getVSR(rA(opcode) + 32, &xa, env);
getVSR(rB(opcode) + 32, &xb, env);
getVSR(rD(opcode) + 32, &xt, env);

helper_reset_fpstatus(env);
tstat = env->fp_status;
if (unlikely(Rc(opcode) != 0)) {
/* TODO: Support xsdivqpo after round-to-odd is implemented */
abort();
tstat.float_rounding_mode = float_round_to_odd;
}

helper_reset_fpstatus(env);
float_status tstat = env->fp_status;
set_float_exception_flags(0, &tstat);
xt.f128 = float128_div(xa.f128, xb.f128, &tstat);
env->fp_status.float_exception_flags |= tstat.float_exception_flags;
Expand Down Expand Up @@ -2954,18 +2952,20 @@ VSX_CVT_FP_TO_FP_HP(xvcvhpsp, 4, float16, float32, VsrH(2 * i + 1), VsrW(i), 0)
void helper_xscvqpdp(CPUPPCState *env, uint32_t opcode)
{
ppc_vsr_t xt, xb;
float_status tstat;

getVSR(rB(opcode) + 32, &xb, env);
memset(&xt, 0, sizeof(xt));

tstat = env->fp_status;
if (unlikely(Rc(opcode) != 0)) {
/* TODO: Support xscvqpdpo after round-to-odd is implemented */
abort();
tstat.float_rounding_mode = float_round_to_odd;
}

xt.VsrD(0) = float128_to_float64(xb.f128, &env->fp_status);
xt.VsrD(0) = float128_to_float64(xb.f128, &tstat);
env->fp_status.float_exception_flags |= tstat.float_exception_flags;
if (unlikely(float128_is_signaling_nan(xb.f128,
&env->fp_status))) {
&tstat))) {
float_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 0);
xt.VsrD(0) = float64_snan_to_qnan(xt.VsrD(0));
}
Expand Down Expand Up @@ -3496,12 +3496,11 @@ void helper_xssqrtqp(CPUPPCState *env, uint32_t opcode)
memset(&xt, 0, sizeof(xt));
helper_reset_fpstatus(env);

tstat = env->fp_status;
if (unlikely(Rc(opcode) != 0)) {
/* TODO: Support xsadddpo after round-to-odd is implemented */
abort();
tstat.float_rounding_mode = float_round_to_odd;
}

tstat = env->fp_status;
set_float_exception_flags(0, &tstat);
xt.f128 = float128_sqrt(xb.f128, &tstat);
env->fp_status.float_exception_flags |= tstat.float_exception_flags;
Expand Down Expand Up @@ -3534,12 +3533,11 @@ void helper_xssubqp(CPUPPCState *env, uint32_t opcode)
getVSR(rD(opcode) + 32, &xt, env);
helper_reset_fpstatus(env);

tstat = env->fp_status;
if (unlikely(Rc(opcode) != 0)) {
/* TODO: Support xssubqp after round-to-odd is implemented */
abort();
tstat.float_rounding_mode = float_round_to_odd;
}

tstat = env->fp_status;
set_float_exception_flags(0, &tstat);
xt.f128 = float128_sub(xa.f128, xb.f128, &tstat);
env->fp_status.float_exception_flags |= tstat.float_exception_flags;
Expand Down
2 changes: 1 addition & 1 deletion target/ppc/translate/vsx-ops.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ GEN_VSX_XFORM_300_EO(name, opc2, opc3 | 0x18, opc4 | 0x1, inval)

GEN_VSX_Z23FORM_300(xsrqpi, 0x05, 0x0, 0x0, 0x0),
GEN_VSX_Z23FORM_300(xsrqpxp, 0x05, 0x1, 0x0, 0x0),
GEN_VSX_XFORM_300_EO(xssqrtqp, 0x04, 0x19, 0x1B, 0x00000001),
GEN_VSX_XFORM_300_EO(xssqrtqp, 0x04, 0x19, 0x1B, 0x0),
GEN_VSX_XFORM_300(xssubqp, 0x04, 0x10, 0x0),

GEN_XX2FORM(xsabsdp, 0x12, 0x15, PPC2_VSX),
Expand Down

0 comments on commit a8d411a

Please sign in to comment.