From 7bcb1c115aa21982ceb0a8c75256f80bfdad74a7 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 2 Apr 2018 17:11:56 -0400 Subject: [PATCH] A64: Implement ABS (vector) --- src/frontend/A64/decoder/a64.inc | 2 +- .../A64/translate/impl/simd_two_register_misc.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/frontend/A64/decoder/a64.inc b/src/frontend/A64/decoder/a64.inc index 3c4611ca..d149bb52 100644 --- a/src/frontend/A64/decoder/a64.inc +++ b/src/frontend/A64/decoder/a64.inc @@ -576,7 +576,7 @@ INST(CNT, "CNT", "0Q001 INST(CMGT_zero_2, "CMGT (zero)", "0Q001110zz100000100010nnnnnddddd") INST(CMEQ_zero_2, "CMEQ (zero)", "0Q001110zz100000100110nnnnnddddd") INST(CMLT_2, "CMLT (zero)", "0Q001110zz100000101010nnnnnddddd") -//INST(ABS_2, "ABS", "0Q001110zz100000101110nnnnnddddd") +INST(ABS_2, "ABS", "0Q001110zz100000101110nnnnnddddd") INST(XTN, "XTN, XTN2", "0Q001110zz100001001010nnnnnddddd") //INST(SQXTN_2, "SQXTN, SQXTN2", "0Q001110zz100001010010nnnnnddddd") //INST(FCVTN, "FCVTN, FCVTN2", "0Q0011100z100001011010nnnnnddddd") 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 7a9726f3..03a65c08 100644 --- a/src/frontend/A64/translate/impl/simd_two_register_misc.cpp +++ b/src/frontend/A64/translate/impl/simd_two_register_misc.cpp @@ -52,6 +52,21 @@ bool TranslatorVisitor::CMEQ_zero_2(bool Q, Imm<2> size, Vec Vn, Vec Vd) { return true; } +bool TranslatorVisitor::ABS_2(bool Q, Imm<2> size, Vec Vn, Vec Vd) { + if (!Q && size == 0b11) { + return ReservedValue(); + } + + const size_t datasize = Q ? 128 : 64; + const size_t esize = 8 << size.ZeroExtend(); + + const IR::U128 data = V(datasize, Vn); + const IR::U128 result = ir.VectorAbs(esize, data); + + V(datasize, Vd, result); + return true; +} + bool TranslatorVisitor::CMLT_2(bool Q, Imm<2> size, Vec Vn, Vec Vd) { if (size == 0b11 && !Q) { return ReservedValue();