From 5c95e28ed0ed8ba79ac69ec4ba2c5f5ffe779015 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Tue, 3 Apr 2018 10:10:53 +0100 Subject: [PATCH] A64: Implement ZIP2 --- src/frontend/A64/decoder/a64.inc | 2 +- .../A64/translate/impl/simd_permute.cpp | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/frontend/A64/decoder/a64.inc b/src/frontend/A64/decoder/a64.inc index c2d24228..9fcc5f6d 100644 --- a/src/frontend/A64/decoder/a64.inc +++ b/src/frontend/A64/decoder/a64.inc @@ -519,7 +519,7 @@ INST(SUB_1, "SUB (vector)", "01111 INST(ZIP1, "ZIP1", "0Q001110zz0mmmmm001110nnnnnddddd") //INST(UZP2, "UZP2", "0Q001110zz0mmmmm010110nnnnnddddd") //INST(TRN2, "TRN2", "0Q001110zz0mmmmm011010nnnnnddddd") -//INST(ZIP2, "ZIP2", "0Q001110zz0mmmmm011110nnnnnddddd") +INST(ZIP2, "ZIP2", "0Q001110zz0mmmmm011110nnnnnddddd") // Data Processing - FP and SIMD - SIMD Extract //INST(EXT, "EXT", "0Q101110000mmmmm0iiii0nnnnnddddd") diff --git a/src/frontend/A64/translate/impl/simd_permute.cpp b/src/frontend/A64/translate/impl/simd_permute.cpp index 2e6ffe2a..6bea5a30 100644 --- a/src/frontend/A64/translate/impl/simd_permute.cpp +++ b/src/frontend/A64/translate/impl/simd_permute.cpp @@ -24,4 +24,28 @@ bool TranslatorVisitor::ZIP1(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { return true; } +bool TranslatorVisitor::ZIP2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { + if (size == 0b11 && !Q) { + return ReservedValue(); + } + + const size_t esize = 8 << size.ZeroExtend(); + const size_t datasize = Q ? 128 : 64; + + const IR::U128 operand1 = V(datasize, Vn); + const IR::U128 operand2 = V(datasize, Vm); + const IR::U128 result = [&]{ + if (Q) { + return ir.VectorInterleaveUpper(esize, operand1, operand2); + } + + // TODO: Urgh. + const IR::U128 interleaved = ir.VectorInterleaveLower(esize, operand1, operand2); + return ir.VectorZeroUpper(ir.VectorShuffleWords(interleaved, 0b01001110)); + }(); + + V(datasize, Vd, result); + return true; +} + } // namespace Dynarmic::A64