From 718f3e9bb47e8d442ab818162b950e3e9bf57770 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 15 Apr 2018 06:36:37 -0400 Subject: [PATCH] A64: Implement scalar variants of CMEQ, CMGT, and CMGE zero comparison instructions These can trivially use the ScalarCompare helper function. --- src/frontend/A64/decoder/a64.inc | 6 ++-- .../translate/impl/simd_scalar_three_same.cpp | 33 +++++++++++++++---- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/frontend/A64/decoder/a64.inc b/src/frontend/A64/decoder/a64.inc index f2aa8ab7..6a1050eb 100644 --- a/src/frontend/A64/decoder/a64.inc +++ b/src/frontend/A64/decoder/a64.inc @@ -407,14 +407,14 @@ INST(UCVTF_int_2, "UCVTF (vector, integer)", "01111 // Data Processing - FP and SIMD - Scalar two-register misc //INST(SUQADD_1, "SUQADD", "01011110zz100000001110nnnnnddddd") //INST(SQABS_1, "SQABS", "01011110zz100000011110nnnnnddddd") -//INST(CMGT_zero_1, "CMGT (zero)", "01011110zz100000100010nnnnnddddd") -//INST(CMEQ_zero_1, "CMEQ (zero)", "01011110zz100000100110nnnnnddddd") +INST(CMGT_zero_1, "CMGT (zero)", "01011110zz100000100010nnnnnddddd") +INST(CMEQ_zero_1, "CMEQ (zero)", "01011110zz100000100110nnnnnddddd") //INST(CMLT_1, "CMLT (zero)", "01011110zz100000101010nnnnnddddd") //INST(ABS_1, "ABS", "01011110zz100000101110nnnnnddddd") //INST(SQXTN_1, "SQXTN, SQXTN2", "01011110zz100001010010nnnnnddddd") //INST(USQADD_1, "USQADD", "01111110zz100000001110nnnnnddddd") //INST(SQNEG_1, "SQNEG", "01111110zz100000011110nnnnnddddd") -//INST(CMGE_zero_1, "CMGE (zero)", "01111110zz100000100010nnnnnddddd") +INST(CMGE_zero_1, "CMGE (zero)", "01111110zz100000100010nnnnnddddd") //INST(CMLE_1, "CMLE (zero)", "01111110zz100000100110nnnnnddddd") INST(NEG_1, "NEG (vector)", "01111110zz100000101110nnnnnddddd") //INST(SQXTUN_1, "SQXTUN, SQXTUN2", "01111110zz100001001010nnnnnddddd") diff --git a/src/frontend/A64/translate/impl/simd_scalar_three_same.cpp b/src/frontend/A64/translate/impl/simd_scalar_three_same.cpp index fa2d238b..6c93cd58 100644 --- a/src/frontend/A64/translate/impl/simd_scalar_three_same.cpp +++ b/src/frontend/A64/translate/impl/simd_scalar_three_same.cpp @@ -4,6 +4,7 @@ * General Public License version 2 or any later version. */ +#include #include "common/bit_util.h" #include "frontend/A64/translate/impl/impl.h" @@ -17,7 +18,13 @@ enum class ComparisonType { HS, }; -bool ScalarCompare(TranslatorVisitor& v, Imm<2> size, Vec Vm, Vec Vn, Vec Vd, ComparisonType type) { +enum class ComparisonVariant { + Register, + Zero, +}; + +bool ScalarCompare(TranslatorVisitor& v, Imm<2> size, boost::optional Vm, Vec Vn, Vec Vd, + ComparisonType type, ComparisonVariant variant) { if (size != 0b11) { return v.ReservedValue(); } @@ -26,7 +33,7 @@ bool ScalarCompare(TranslatorVisitor& v, Imm<2> size, Vec Vm, Vec Vn, Vec Vd, Co const size_t datasize = 64; const IR::U128 operand1 = v.V(datasize, Vn); - const IR::U128 operand2 = v.V(datasize, Vm); + const IR::U128 operand2 = variant == ComparisonVariant::Register ? v.V(datasize, Vm.get()) : v.ir.ZeroVector(); const IR::U128 result = [&] { switch (type) { @@ -64,23 +71,35 @@ bool TranslatorVisitor::ADD_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { } bool TranslatorVisitor::CMEQ_reg_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { - return ScalarCompare(*this, size, Vm, Vn, Vd, ComparisonType::EQ); + return ScalarCompare(*this, size, Vm, Vn, Vd, ComparisonType::EQ, ComparisonVariant::Register); +} + +bool TranslatorVisitor::CMEQ_zero_1(Imm<2> size, Vec Vn, Vec Vd) { + return ScalarCompare(*this, size, {}, Vn, Vd, ComparisonType::EQ, ComparisonVariant::Zero); } bool TranslatorVisitor::CMGE_reg_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { - return ScalarCompare(*this, size, Vm, Vn, Vd, ComparisonType::GE); + return ScalarCompare(*this, size, Vm, Vn, Vd, ComparisonType::GE, ComparisonVariant::Register); +} + +bool TranslatorVisitor::CMGE_zero_1(Imm<2> size, Vec Vn, Vec Vd) { + return ScalarCompare(*this, size, {}, Vn, Vd, ComparisonType::GE, ComparisonVariant::Zero); } bool TranslatorVisitor::CMGT_reg_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { - return ScalarCompare(*this, size, Vm, Vn, Vd, ComparisonType::GT); + return ScalarCompare(*this, size, Vm, Vn, Vd, ComparisonType::GT, ComparisonVariant::Register); +} + +bool TranslatorVisitor::CMGT_zero_1(Imm<2> size, Vec Vn, Vec Vd) { + return ScalarCompare(*this, size, {}, Vn, Vd, ComparisonType::GT, ComparisonVariant::Zero); } bool TranslatorVisitor::CMHI_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { - return ScalarCompare(*this, size, Vm, Vn, Vd, ComparisonType::HI); + return ScalarCompare(*this, size, Vm, Vn, Vd, ComparisonType::HI, ComparisonVariant::Register); } bool TranslatorVisitor::CMHS_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { - return ScalarCompare(*this, size, Vm, Vn, Vd, ComparisonType::HS); + return ScalarCompare(*this, size, Vm, Vn, Vd, ComparisonType::HS, ComparisonVariant::Register); } bool TranslatorVisitor::SUB_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) {