From a6e264c2dddddc94989a5d6787bd8d87319c5092 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 2 Apr 2018 11:39:40 -0400 Subject: [PATCH] A64: Implement UABA Now that we have unsigned absolute difference capabilities, we can just use this to append onto the result via a vector add. --- src/frontend/A64/decoder/a64.inc | 2 +- .../A64/translate/impl/simd_three_same.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/frontend/A64/decoder/a64.inc b/src/frontend/A64/decoder/a64.inc index d33087d9..cd9af850 100644 --- a/src/frontend/A64/decoder/a64.inc +++ b/src/frontend/A64/decoder/a64.inc @@ -755,7 +755,7 @@ INST(USHL_2, "USHL", "0Q101 INST(UMAX, "UMAX", "0Q101110zz1mmmmm011001nnnnnddddd") INST(UMIN, "UMIN", "0Q101110zz1mmmmm011011nnnnnddddd") INST(UABD, "UABD", "0Q101110zz1mmmmm011101nnnnnddddd") -//INST(UABA, "UABA", "0Q101110zz1mmmmm011111nnnnnddddd") +INST(UABA, "UABA", "0Q101110zz1mmmmm011111nnnnnddddd") INST(SUB_2, "SUB (vector)", "0Q101110zz1mmmmm100001nnnnnddddd") INST(CMEQ_reg_2, "CMEQ (register)", "0Q101110zz1mmmmm100011nnnnnddddd") INST(MLS_vec, "MLS (vector)", "0Q101110zz1mmmmm100101nnnnnddddd") diff --git a/src/frontend/A64/translate/impl/simd_three_same.cpp b/src/frontend/A64/translate/impl/simd_three_same.cpp index b389eb50..5d16e8a0 100644 --- a/src/frontend/A64/translate/impl/simd_three_same.cpp +++ b/src/frontend/A64/translate/impl/simd_three_same.cpp @@ -227,6 +227,25 @@ bool TranslatorVisitor::UMAX(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { return true; } +bool TranslatorVisitor::UABA(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { + if (size == 0b11) { + return ReservedValue(); + } + + const size_t datasize = Q ? 128 : 64; + const size_t esize = 8 << size.ZeroExtend(); + + const IR::U128 operand1 = V(datasize, Vn); + const IR::U128 operand2 = V(datasize, Vm); + const IR::U128 initial_dest = V(datasize, Vd); + + const IR::U128 result = ir.VectorAdd(esize, initial_dest, + ir.VectorUnsignedAbsoluteDifference(esize, operand1, operand2)); + + V(datasize, Vd, result); + return true; +} + bool TranslatorVisitor::UABD(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { if (size == 0b11) { return ReservedValue();