diff --git a/src/frontend/A64/decoder/a64.inc b/src/frontend/A64/decoder/a64.inc index c011936b..6e4bf6f7 100644 --- a/src/frontend/A64/decoder/a64.inc +++ b/src/frontend/A64/decoder/a64.inc @@ -703,7 +703,7 @@ INST(UMULL_vec, "UMULL, UMULL2 (vector)", "0Q101 // Data Processing - FP and SIMD - SIMD three same INST(SHADD, "SHADD", "0Q001110zz1mmmmm000001nnnnnddddd") //INST(SQADD_2, "SQADD", "0Q001110zz1mmmmm000011nnnnnddddd") -//INST(SRHADD, "SRHADD", "0Q001110zz1mmmmm000101nnnnnddddd") +INST(SRHADD, "SRHADD", "0Q001110zz1mmmmm000101nnnnnddddd") INST(SHSUB, "SHSUB", "0Q001110zz1mmmmm001001nnnnnddddd") //INST(SQSUB_2, "SQSUB", "0Q001110zz1mmmmm001011nnnnnddddd") INST(CMGT_reg_2, "CMGT (register)", "0Q001110zz1mmmmm001101nnnnnddddd") @@ -744,7 +744,7 @@ INST(ORR_asimd_reg, "ORR (vector, register)", "0Q001 INST(ORN_asimd, "ORN (vector)", "0Q001110111mmmmm000111nnnnnddddd") INST(UHADD, "UHADD", "0Q101110zz1mmmmm000001nnnnnddddd") //INST(UQADD_2, "UQADD", "0Q101110zz1mmmmm000011nnnnnddddd") -//INST(URHADD, "URHADD", "0Q101110zz1mmmmm000101nnnnnddddd") +INST(URHADD, "URHADD", "0Q101110zz1mmmmm000101nnnnnddddd") INST(UHSUB, "UHSUB", "0Q101110zz1mmmmm001001nnnnnddddd") //INST(UQSUB_2, "UQSUB", "0Q101110zz1mmmmm001011nnnnnddddd") INST(CMHI_2, "CMHI (register)", "0Q101110zz1mmmmm001101nnnnnddddd") diff --git a/src/frontend/A64/translate/impl/simd_three_same.cpp b/src/frontend/A64/translate/impl/simd_three_same.cpp index aecd1023..64f21e90 100644 --- a/src/frontend/A64/translate/impl/simd_three_same.cpp +++ b/src/frontend/A64/translate/impl/simd_three_same.cpp @@ -75,6 +75,27 @@ bool SignedAbsoluteDifference(TranslatorVisitor& v, bool Q, Imm<2> size, Vec Vm, return true; } +enum class Signedness { + Signed, + Unsigned +}; + +bool RoundingHalvingAdd(TranslatorVisitor& v, bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd, Signedness sign) { + if (size == 0b11) { + return v.ReservedValue(); + } + + const size_t esize = 8 << size.ZeroExtend(); + const size_t datasize = Q ? 128 : 64; + + const IR::U128 operand1 = v.V(datasize, Vm); + const IR::U128 operand2 = v.V(datasize, Vn); + const IR::U128 result = sign == Signedness::Signed ? v.ir.VectorRoundingHalvingAddSigned(esize, operand1, operand2) + : v.ir.VectorRoundingHalvingAddUnsigned(esize, operand1, operand2); + + v.V(datasize, Vd, result); + return true; +} } // Anonymous namespace bool TranslatorVisitor::CMGT_reg_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { @@ -254,6 +275,10 @@ bool TranslatorVisitor::SHSUB(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { return true; } +bool TranslatorVisitor::SRHADD(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { + return RoundingHalvingAdd(*this, Q, size, Vm, Vn, Vd, Signedness::Signed); +} + bool TranslatorVisitor::UHADD(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { if (size == 0b11) { return ReservedValue(); @@ -286,6 +311,10 @@ bool TranslatorVisitor::UHSUB(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { return true; } +bool TranslatorVisitor::URHADD(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { + return RoundingHalvingAdd(*this, Q, size, Vm, Vn, Vd, Signedness::Unsigned); +} + bool TranslatorVisitor::ADDP_vec(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { if (size == 0b11 && !Q) return ReservedValue(); const size_t esize = 8 << size.ZeroExtend();