From 6e5750e4ec201d8464056827e65069803b2b0869 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 11 May 2018 10:55:41 -0400 Subject: [PATCH] A64: Implement FABS' single and double precision variant --- src/frontend/A64/decoder/a64.inc | 2 +- .../translate/impl/simd_two_register_misc.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/frontend/A64/decoder/a64.inc b/src/frontend/A64/decoder/a64.inc index 4eec0016..f1c6663c 100644 --- a/src/frontend/A64/decoder/a64.inc +++ b/src/frontend/A64/decoder/a64.inc @@ -601,7 +601,7 @@ INST(SCVTF_int_4, "SCVTF (vector, integer)", "0Q001 //INST(FCMLT_3, "FCMLT (zero)", "0Q00111011111000111010nnnnnddddd") //INST(FCMLT_4, "FCMLT (zero)", "0Q0011101z100000111010nnnnnddddd") //INST(FABS_1, "FABS (vector)", "0Q00111011111000111110nnnnnddddd") -//INST(FABS_2, "FABS (vector)", "0Q0011101z100000111110nnnnnddddd") +INST(FABS_2, "FABS (vector)", "0Q0011101z100000111110nnnnnddddd") //INST(FRINTP_1, "FRINTP (vector)", "0Q00111011111001100010nnnnnddddd") //INST(FRINTP_2, "FRINTP (vector)", "0Q0011101z100001100010nnnnnddddd") //INST(FRINTZ_1, "FRINTZ (vector)", "0Q00111011111001100110nnnnnddddd") diff --git a/src/frontend/A64/translate/impl/simd_two_register_misc.cpp b/src/frontend/A64/translate/impl/simd_two_register_misc.cpp index f0300fb3..5ae936cc 100644 --- a/src/frontend/A64/translate/impl/simd_two_register_misc.cpp +++ b/src/frontend/A64/translate/impl/simd_two_register_misc.cpp @@ -114,6 +114,23 @@ bool TranslatorVisitor::XTN(bool Q, Imm<2> size, Vec Vn, Vec Vd) { return true; } +bool TranslatorVisitor::FABS_2(bool Q, bool sz, Vec Vn, Vec Vd) { + if (sz && !Q) { + return ReservedValue(); + } + + const size_t datasize = Q ? 128 : 64; + const size_t esize = sz ? 64 : 32; + const size_t mask_value = sz ? 0x7FFFFFFFFFFFFFFF : 0x7FFFFFFF; + + const IR::U128 operand = V(datasize, Vn); + const IR::U128 mask = ir.VectorBroadcast(esize, I(esize, mask_value)); + const IR::U128 result = ir.VectorAnd(operand, mask); + + V(datasize, Vd, result); + return true; +} + bool TranslatorVisitor::FNEG_1(bool Q, Vec Vn, Vec Vd) { const size_t datasize = Q ? 128 : 64;