From 8765b421b7d8d9eb57325a77e23b19b8164db868 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sun, 4 Feb 2018 13:40:37 +0000 Subject: [PATCH] A64: Implement FCSEL --- src/CMakeLists.txt | 1 + src/frontend/A64/decoder/a64.inc | 2 +- .../floating_point_conditional_select.cpp | 39 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/frontend/A64/translate/impl/floating_point_conditional_select.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 04a67e2c..9795b357 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -76,6 +76,7 @@ add_library(dynarmic frontend/A64/translate/impl/exception_generating.cpp frontend/A64/translate/impl/floating_point_compare.cpp frontend/A64/translate/impl/floating_point_conversion_integer.cpp + frontend/A64/translate/impl/floating_point_conditional_select.cpp frontend/A64/translate/impl/floating_point_data_processing_one_register.cpp frontend/A64/translate/impl/floating_point_data_processing_two_register.cpp frontend/A64/translate/impl/impl.cpp diff --git a/src/frontend/A64/decoder/a64.inc b/src/frontend/A64/decoder/a64.inc index bfadf3be..31281442 100644 --- a/src/frontend/A64/decoder/a64.inc +++ b/src/frontend/A64/decoder/a64.inc @@ -943,7 +943,7 @@ INST(FSUB_float, "FSUB (scalar)", "00011 INST(FNMUL_float, "FNMUL (scalar)", "00011110yy1mmmmm100010nnnnnddddd") // Data Processing - FP and SIMD - Floating point conditional select -//INST(FCSEL_float, "FCSEL", "00011110yy1mmmmmcccc11nnnnnddddd") +INST(FCSEL_float, "FCSEL", "00011110yy1mmmmmcccc11nnnnnddddd") // Data Processing - FP and SIMD - Floating point data processing three register //INST(FMADD_float, "FMADD", "00011111yy0mmmmm0aaaaannnnnddddd") diff --git a/src/frontend/A64/translate/impl/floating_point_conditional_select.cpp b/src/frontend/A64/translate/impl/floating_point_conditional_select.cpp new file mode 100644 index 00000000..5b016db4 --- /dev/null +++ b/src/frontend/A64/translate/impl/floating_point_conditional_select.cpp @@ -0,0 +1,39 @@ +/* This file is part of the dynarmic project. + * Copyright (c) 2018 MerryMage + * This software may be used and distributed according to the terms of the GNU + * General Public License version 2 or any later version. + */ + +#include + +#include "frontend/A64/translate/impl/impl.h" + +namespace Dynarmic::A64 { + +static boost::optional GetDataSize(Imm<2> type) { + switch (type.ZeroExtend()) { + case 0b00: + return 32; + case 0b01: + return 64; + case 0b11: + return 16; + } + return boost::none; +} + +bool TranslatorVisitor::FCSEL_float(Imm<2> type, Vec Vm, Cond cond, Vec Vn, Vec Vd) { + const auto datasize = GetDataSize(type); + if (!datasize || *datasize == 16) { + return UnallocatedEncoding(); + } + + const IR::U32U64 operand1 = V_scalar(*datasize, Vn); + const IR::U32U64 operand2 = V_scalar(*datasize, Vm); + const IR::U32U64 result = ir.ConditionalSelect(cond, operand1, operand2); + V_scalar(*datasize, Vd, result); + + return true; +} + +} // namespace Dynarmic::A64