A64: Implement FRINTN (scalar)

This commit is contained in:
MerryMage 2018-07-16 13:55:19 +01:00
parent 8718dc1692
commit 5200bf41cf
2 changed files with 14 additions and 6 deletions

View file

@ -905,7 +905,7 @@ INST(FABS_float, "FABS (scalar)", "00011
INST(FNEG_float, "FNEG (scalar)", "00011110yy100001010000nnnnnddddd")
INST(FSQRT_float, "FSQRT (scalar)", "00011110yy100001110000nnnnnddddd")
INST(FCVT_float, "FCVT", "00011110yy10001oo10000nnnnnddddd")
//INST(FRINTN_float, "FRINTN (scalar)", "00011110yy100100010000nnnnnddddd")
INST(FRINTN_float, "FRINTN (scalar)", "00011110yy100100010000nnnnnddddd")
//INST(FRINTP_float, "FRINTP (scalar)", "00011110yy100100110000nnnnnddddd")
//INST(FRINTM_float, "FRINTM (scalar)", "00011110yy100101010000nnnnnddddd")
//INST(FRINTZ_float, "FRINTZ (scalar)", "00011110yy100101110000nnnnnddddd")

View file

@ -152,16 +152,24 @@ bool TranslatorVisitor::FCVT_float(Imm<2> type, Imm<2> opc, Vec Vn, Vec Vd) {
return true;
}
bool TranslatorVisitor::FRINTA_float(Imm<2> type, Vec Vn, Vec Vd) {
bool FloatingPointRoundToIntegral(TranslatorVisitor& v, Imm<2> type, Vec Vn, Vec Vd, FP::RoundingMode rounding_mode, bool exact) {
const boost::optional<size_t> datasize = GetDataSize(type);
if (!datasize || *datasize == 16) {
return UnallocatedEncoding();
return v.UnallocatedEncoding();
}
const IR::U32U64 operand = V_scalar(*datasize, Vn);
const IR::U32U64 result = ir.FPRoundInt(operand, FP::RoundingMode::ToNearest_TieAwayFromZero, false);
V_scalar(*datasize, Vd, result);
const IR::U32U64 operand = v.V_scalar(*datasize, Vn);
const IR::U32U64 result = v.ir.FPRoundInt(operand, rounding_mode, exact);
v.V_scalar(*datasize, Vd, result);
return true;
}
bool TranslatorVisitor::FRINTN_float(Imm<2> type, Vec Vn, Vec Vd) {
return FloatingPointRoundToIntegral(*this, type, Vn, Vd, FP::RoundingMode::ToNearest_TieEven, false);
}
bool TranslatorVisitor::FRINTA_float(Imm<2> type, Vec Vn, Vec Vd) {
return FloatingPointRoundToIntegral(*this, type, Vn, Vd, FP::RoundingMode::ToNearest_TieAwayFromZero, false);
}
} // namespace Dynarmic::A64