mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-01-01 12:14:50 +01:00
Merge pull request #442 from lioncash/fcvtxn
A64: Implement scalar and vector variants of FCVTXN
This commit is contained in:
commit
fb039e232c
14 changed files with 210 additions and 32 deletions
|
|
@ -479,12 +479,13 @@ bool ArmTranslatorVisitor::vfp2_VCVT_f_to_f(Cond cond, bool D, size_t Vd, bool s
|
|||
const auto d = ToExtReg(!sz, Vd, D); // Destination is of opposite size to source
|
||||
const auto m = ToExtReg(sz, Vm, M);
|
||||
const auto reg_m = ir.GetExtendedRegister(m);
|
||||
const auto rounding_mode = ir.current_location.FPSCR().RMode();
|
||||
|
||||
if (sz) {
|
||||
const auto result = ir.FPDoubleToSingle(reg_m, true);
|
||||
const auto result = ir.FPDoubleToSingle(reg_m, rounding_mode);
|
||||
ir.SetExtendedRegister(d, result);
|
||||
} else {
|
||||
const auto result = ir.FPSingleToDouble(reg_m, true);
|
||||
const auto result = ir.FPSingleToDouble(reg_m, rounding_mode);
|
||||
ir.SetExtendedRegister(d, result);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -462,7 +462,7 @@ INST(CMLE_1, "CMLE (zero)", "01111
|
|||
INST(NEG_1, "NEG (vector)", "01111110zz100000101110nnnnnddddd")
|
||||
INST(SQXTUN_1, "SQXTUN, SQXTUN2", "01111110zz100001001010nnnnnddddd")
|
||||
INST(UQXTN_1, "UQXTN, UQXTN2", "01111110zz100001010010nnnnnddddd")
|
||||
//INST(FCVTXN_1, "FCVTXN, FCVTXN2", "011111100z100001011010nnnnnddddd")
|
||||
INST(FCVTXN_1, "FCVTXN, FCVTXN2", "011111100z100001011010nnnnnddddd")
|
||||
|
||||
// Data Processing - FP and SIMD - SIMD Scalar pairwise
|
||||
INST(ADDP_pair, "ADDP (scalar)", "01011110zz110001101110nnnnnddddd")
|
||||
|
|
@ -664,7 +664,7 @@ INST(NEG_2, "NEG (vector)", "0Q101
|
|||
INST(SQXTUN_2, "SQXTUN, SQXTUN2", "0Q101110zz100001001010nnnnnddddd")
|
||||
INST(SHLL, "SHLL, SHLL2", "0Q101110zz100001001110nnnnnddddd")
|
||||
INST(UQXTN_2, "UQXTN, UQXTN2", "0Q101110zz100001010010nnnnnddddd")
|
||||
//INST(FCVTXN_2, "FCVTXN, FCVTXN2", "0Q1011100z100001011010nnnnnddddd")
|
||||
INST(FCVTXN_2, "FCVTXN, FCVTXN2", "0Q1011100z100001011010nnnnnddddd")
|
||||
//INST(FRINTA_1, "FRINTA (vector)", "0Q10111001111001100010nnnnnddddd")
|
||||
INST(FRINTA_2, "FRINTA (vector)", "0Q1011100z100001100010nnnnnddddd")
|
||||
//INST(FRINTX_1, "FRINTX (vector)", "0Q10111001111001100110nnnnnddddd")
|
||||
|
|
|
|||
|
|
@ -104,7 +104,9 @@ bool TranslatorVisitor::FCVT_float(Imm<2> type, Imm<2> opc, Vec Vn, Vec Vd) {
|
|||
return UnallocatedEncoding();
|
||||
}
|
||||
|
||||
IR::UAny operand = V_scalar(*srcsize, Vn);
|
||||
const IR::UAny operand = V_scalar(*srcsize, Vn);
|
||||
const auto rounding_mode = ir.current_location->FPCR().RMode();
|
||||
|
||||
IR::UAny result;
|
||||
switch (*srcsize) {
|
||||
case 16:
|
||||
|
|
@ -120,7 +122,7 @@ bool TranslatorVisitor::FCVT_float(Imm<2> type, Imm<2> opc, Vec Vn, Vec Vd) {
|
|||
case 16:
|
||||
return InterpretThisInstruction();
|
||||
case 64:
|
||||
result = ir.FPSingleToDouble(operand, true);
|
||||
result = ir.FPSingleToDouble(operand, rounding_mode);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
|
@ -129,7 +131,7 @@ bool TranslatorVisitor::FCVT_float(Imm<2> type, Imm<2> opc, Vec Vn, Vec Vd) {
|
|||
case 16:
|
||||
return InterpretThisInstruction();
|
||||
case 32:
|
||||
result = ir.FPDoubleToSingle(operand, true);
|
||||
result = ir.FPDoubleToSingle(operand, rounding_mode);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -746,7 +746,7 @@ struct TranslatorVisitor final {
|
|||
bool NEG_2(bool Q, Imm<2> size, Vec Vn, Vec Vd);
|
||||
bool SQXTUN_2(bool Q, Imm<2> size, Vec Vn, Vec Vd);
|
||||
bool UQXTN_2(bool Q, Imm<2> size, Vec Vn, Vec Vd);
|
||||
bool FCVTXN_2(bool Q, bool sz, Vec Vn, Reg Rd);
|
||||
bool FCVTXN_2(bool Q, bool sz, Vec Vn, Vec Vd);
|
||||
bool FRINTN_1(bool Q, Vec Vn, Vec Vd);
|
||||
bool FRINTN_2(bool Q, bool sz, Vec Vn, Vec Vd);
|
||||
bool FRINTM_1(bool Q, Vec Vn, Vec Vd);
|
||||
|
|
|
|||
|
|
@ -152,6 +152,18 @@ bool TranslatorVisitor::FCVTPU_2(bool sz, Vec Vn, Vec Vd) {
|
|||
return ScalarFPConvertWithRound(*this, sz, Vn, Vd, FP::RoundingMode::TowardsPlusInfinity, Signedness::Unsigned);
|
||||
}
|
||||
|
||||
bool TranslatorVisitor::FCVTXN_1(bool sz, Vec Vn, Vec Vd) {
|
||||
if (!sz) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
||||
const IR::U64 element = V_scalar(64, Vn);
|
||||
const IR::U32 result = ir.FPDoubleToSingle(element, FP::RoundingMode::ToOdd);
|
||||
|
||||
V_scalar(32, Vd, result);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TranslatorVisitor::FCVTZS_int_2(bool sz, Vec Vn, Vec Vd) {
|
||||
return ScalarFPConvertWithRound(*this, sz, Vn, Vd, FP::RoundingMode::TowardsZero, Signedness::Signed);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -348,10 +348,11 @@ bool TranslatorVisitor::FCVTL(bool Q, bool sz, Vec Vn, Vec Vd) {
|
|||
}
|
||||
|
||||
const IR::U128 part = Vpart(64, Vn, Q);
|
||||
const auto rounding_mode = ir.current_location->FPCR().RMode();
|
||||
IR::U128 result = ir.ZeroVector();
|
||||
|
||||
for (size_t i = 0; i < 2; i++) {
|
||||
const IR::U64 element = ir.FPSingleToDouble(ir.VectorGetElement(32, part, i), true);
|
||||
const IR::U64 element = ir.FPSingleToDouble(ir.VectorGetElement(32, part, i), rounding_mode);
|
||||
|
||||
result = ir.VectorSetElement(64, result, i, element);
|
||||
}
|
||||
|
|
@ -367,10 +368,11 @@ bool TranslatorVisitor::FCVTN(bool Q, bool sz, Vec Vn, Vec Vd) {
|
|||
}
|
||||
|
||||
const IR::U128 operand = V(128, Vn);
|
||||
const auto rounding_mode = ir.current_location->FPCR().RMode();
|
||||
IR::U128 result = ir.ZeroVector();
|
||||
|
||||
for (size_t i = 0; i < 2; i++) {
|
||||
const IR::U32 element = ir.FPDoubleToSingle(ir.VectorGetElement(64, operand, i), true);
|
||||
const IR::U32 element = ir.FPDoubleToSingle(ir.VectorGetElement(64, operand, i), rounding_mode);
|
||||
|
||||
result = ir.VectorSetElement(32, result, i, element);
|
||||
}
|
||||
|
|
@ -395,6 +397,26 @@ bool TranslatorVisitor::FCVTPS_4(bool Q, bool sz, Vec Vn, Vec Vd) {
|
|||
return FloatConvertToInteger(*this, Q, sz, Vn, Vd, Signedness::Signed, FP::RoundingMode::TowardsPlusInfinity);
|
||||
}
|
||||
|
||||
bool TranslatorVisitor::FCVTXN_2(bool Q, bool sz, Vec Vn, Vec Vd) {
|
||||
if (!sz) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
||||
const size_t part = Q ? 1 : 0;
|
||||
const auto operand = ir.GetQ(Vn);
|
||||
auto result = ir.ZeroVector();
|
||||
|
||||
for (size_t e = 0; e < 2; ++e) {
|
||||
const IR::U64 element = ir.VectorGetElement(64, operand, e);
|
||||
const IR::U32 converted = ir.FPDoubleToSingle(element, FP::RoundingMode::ToOdd);
|
||||
|
||||
result = ir.VectorSetElement(32, result, e, converted);
|
||||
}
|
||||
|
||||
Vpart(64, Vd, part, result);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TranslatorVisitor::FCVTZS_int_4(bool Q, bool sz, Vec Vn, Vec Vd) {
|
||||
return FloatConvertToInteger(*this, Q, sz, Vn, Vd, Signedness::Signed, FP::RoundingMode::TowardsZero);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1948,14 +1948,12 @@ U32U64 IREmitter::FPSub(const U32U64& a, const U32U64& b, bool fpcr_controlled)
|
|||
}
|
||||
}
|
||||
|
||||
U32 IREmitter::FPDoubleToSingle(const U64& a, bool fpcr_controlled) {
|
||||
ASSERT(fpcr_controlled);
|
||||
return Inst<U32>(Opcode::FPDoubleToSingle, a);
|
||||
U32 IREmitter::FPDoubleToSingle(const U64& a, FP::RoundingMode rounding) {
|
||||
return Inst<U32>(Opcode::FPDoubleToSingle, a, Imm8(static_cast<u8>(rounding)));
|
||||
}
|
||||
|
||||
U64 IREmitter::FPSingleToDouble(const U32& a, bool fpcr_controlled) {
|
||||
ASSERT(fpcr_controlled);
|
||||
return Inst<U64>(Opcode::FPSingleToDouble, a);
|
||||
U64 IREmitter::FPSingleToDouble(const U32& a, FP::RoundingMode rounding) {
|
||||
return Inst<U64>(Opcode::FPSingleToDouble, a, Imm8(static_cast<u8>(rounding)));
|
||||
}
|
||||
|
||||
U32 IREmitter::FPToFixedS32(const U32U64& a, size_t fbits, FP::RoundingMode rounding) {
|
||||
|
|
|
|||
|
|
@ -312,8 +312,8 @@ public:
|
|||
U32U64 FPRSqrtStepFused(const U32U64& a, const U32U64& b);
|
||||
U32U64 FPSqrt(const U32U64& a);
|
||||
U32U64 FPSub(const U32U64& a, const U32U64& b, bool fpcr_controlled);
|
||||
U32 FPDoubleToSingle(const U64& a, bool fpcr_controlled);
|
||||
U64 FPSingleToDouble(const U32& a, bool fpcr_controlled);
|
||||
U32 FPDoubleToSingle(const U64& a, FP::RoundingMode rounding);
|
||||
U64 FPSingleToDouble(const U32& a, FP::RoundingMode rounding);
|
||||
U32 FPToFixedS32(const U32U64& a, size_t fbits, FP::RoundingMode rounding);
|
||||
U64 FPToFixedS64(const U32U64& a, size_t fbits, FP::RoundingMode rounding);
|
||||
U32 FPToFixedU32(const U32U64& a, size_t fbits, FP::RoundingMode rounding);
|
||||
|
|
|
|||
|
|
@ -500,8 +500,8 @@ OPCODE(FPSub32, U32, U32,
|
|||
OPCODE(FPSub64, U64, U64, U64 )
|
||||
|
||||
// Floating-point conversions
|
||||
OPCODE(FPSingleToDouble, U64, U32 )
|
||||
OPCODE(FPDoubleToSingle, U32, U64 )
|
||||
OPCODE(FPSingleToDouble, U64, U32, U8 )
|
||||
OPCODE(FPDoubleToSingle, U32, U64, U8 )
|
||||
OPCODE(FPDoubleToFixedS32, U32, U64, U8, U8 )
|
||||
OPCODE(FPDoubleToFixedS64, U64, U64, U8, U8 )
|
||||
OPCODE(FPDoubleToFixedU32, U32, U64, U8, U8 )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue