2018-01-21 18:45:43 +01:00
|
|
|
/* 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 "frontend/A64/translate/impl/impl.h"
|
|
|
|
|
|
2018-01-26 14:51:48 +01:00
|
|
|
namespace Dynarmic::A64 {
|
2018-01-21 18:45:43 +01:00
|
|
|
|
|
|
|
|
bool TranslatorVisitor::ADD_vector(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) {
|
|
|
|
|
if (size == 0b11 && !Q) return ReservedValue();
|
|
|
|
|
const size_t esize = 8 << size.ZeroExtend<size_t>();
|
|
|
|
|
const size_t datasize = Q ? 128 : 64;
|
|
|
|
|
|
|
|
|
|
auto operand1 = V(datasize, Vn);
|
|
|
|
|
auto operand2 = V(datasize, Vm);
|
|
|
|
|
|
2018-02-10 11:18:10 +01:00
|
|
|
auto result = ir.VectorAdd(esize, operand1, operand2);
|
2018-01-21 18:45:43 +01:00
|
|
|
|
|
|
|
|
V(datasize, Vd, result);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-11 11:18:47 +01:00
|
|
|
bool TranslatorVisitor::MUL_vec(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) {
|
|
|
|
|
if (size == 0b11) return ReservedValue();
|
|
|
|
|
const size_t esize = 8 << size.ZeroExtend<size_t>();
|
|
|
|
|
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 = ir.VectorMultiply(esize, operand1, operand2);
|
|
|
|
|
|
|
|
|
|
V(datasize, Vd, result);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-23 18:44:34 +01:00
|
|
|
bool TranslatorVisitor::ADDP_vec(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) {
|
|
|
|
|
if (size == 0b11 && !Q) return ReservedValue();
|
|
|
|
|
const size_t esize = 8 << size.ZeroExtend<size_t>();
|
|
|
|
|
const size_t datasize = Q ? 128 : 64;
|
|
|
|
|
|
|
|
|
|
const IR::U128 operand1 = V(datasize, Vn);
|
|
|
|
|
const IR::U128 operand2 = V(datasize, Vm);
|
|
|
|
|
|
2018-02-10 11:18:10 +01:00
|
|
|
const IR::U128 result = Q ? ir.VectorPairedAdd(esize, operand1, operand2) : ir.VectorPairedAddLower(esize, operand1, operand2);
|
2018-01-23 18:44:34 +01:00
|
|
|
|
|
|
|
|
V(datasize, Vd, result);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-21 19:27:06 +01:00
|
|
|
bool TranslatorVisitor::AND_asimd(bool Q, Vec Vm, Vec Vn, Vec Vd) {
|
|
|
|
|
const size_t datasize = Q ? 128 : 64;
|
|
|
|
|
|
|
|
|
|
auto operand1 = V(datasize, Vn);
|
|
|
|
|
auto operand2 = V(datasize, Vm);
|
|
|
|
|
|
|
|
|
|
auto result = ir.VectorAnd(operand1, operand2);
|
|
|
|
|
|
|
|
|
|
V(datasize, Vd, result);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-06 19:30:36 +01:00
|
|
|
bool TranslatorVisitor::BIC_asimd_reg(bool Q, Vec Vm, Vec Vn, Vec Vd) {
|
|
|
|
|
const size_t datasize = Q ? 128 : 64;
|
|
|
|
|
|
|
|
|
|
const IR::U128 operand1 = V(datasize, Vn);
|
|
|
|
|
const IR::U128 operand2 = V(datasize, Vm);
|
|
|
|
|
|
|
|
|
|
IR::U128 result = ir.VectorAnd(operand1, ir.VectorNot(operand2));
|
2018-01-27 19:23:55 +01:00
|
|
|
|
2018-02-06 19:30:36 +01:00
|
|
|
if (datasize == 64) {
|
|
|
|
|
result = ir.VectorZeroUpper(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
V(datasize, Vd, result);
|
2018-01-27 19:23:55 +01:00
|
|
|
|
2018-02-06 19:30:36 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-26 01:57:56 +01:00
|
|
|
bool TranslatorVisitor::ORR_asimd_reg(bool Q, Vec Vm, Vec Vn, Vec Vd) {
|
|
|
|
|
const size_t datasize = Q ? 128 : 64;
|
|
|
|
|
|
|
|
|
|
auto operand1 = V(datasize, Vn);
|
|
|
|
|
auto operand2 = V(datasize, Vm);
|
|
|
|
|
|
|
|
|
|
auto result = ir.VectorOr(operand1, operand2);
|
|
|
|
|
|
|
|
|
|
V(datasize, Vd, result);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TranslatorVisitor::ORN_asimd(bool Q, Vec Vm, Vec Vn, Vec Vd) {
|
|
|
|
|
const size_t datasize = Q ? 128 : 64;
|
|
|
|
|
|
|
|
|
|
auto operand1 = V(datasize, Vn);
|
|
|
|
|
auto operand2 = V(datasize, Vm);
|
|
|
|
|
|
|
|
|
|
auto result = ir.VectorOr(operand1, ir.VectorNot(operand2));
|
|
|
|
|
|
2018-01-26 18:00:27 +01:00
|
|
|
if (datasize == 64) {
|
|
|
|
|
result = ir.VectorZeroUpper(result);
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-26 01:57:56 +01:00
|
|
|
V(datasize, Vd, result);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-11 00:58:33 +01:00
|
|
|
bool TranslatorVisitor::SUB_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) {
|
|
|
|
|
if (size == 0b11 && !Q) return ReservedValue();
|
|
|
|
|
const size_t esize = 8 << size.ZeroExtend<size_t>();
|
|
|
|
|
const size_t datasize = Q ? 128 : 64;
|
|
|
|
|
|
|
|
|
|
auto operand1 = V(datasize, Vn);
|
|
|
|
|
auto operand2 = V(datasize, Vm);
|
|
|
|
|
|
|
|
|
|
auto result = ir.VectorSub(esize, operand1, operand2);
|
|
|
|
|
|
|
|
|
|
V(datasize, Vd, result);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-06 19:30:36 +01:00
|
|
|
bool TranslatorVisitor::CMEQ_reg_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) {
|
|
|
|
|
if (size == 0b11 && !Q) return ReservedValue();
|
|
|
|
|
const size_t esize = 8 << size.ZeroExtend<size_t>();
|
|
|
|
|
const size_t datasize = Q ? 128 : 64;
|
|
|
|
|
|
|
|
|
|
const IR::U128 operand1 = V(datasize, Vn);
|
|
|
|
|
const IR::U128 operand2 = V(datasize, Vm);
|
|
|
|
|
|
2018-02-10 11:18:10 +01:00
|
|
|
IR::U128 result = ir.VectorEqual(esize, operand1, operand2);
|
2018-02-06 19:30:36 +01:00
|
|
|
|
|
|
|
|
if (datasize == 64) {
|
|
|
|
|
result = ir.VectorZeroUpper(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
V(datasize, Vd, result);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-26 01:57:56 +01:00
|
|
|
bool TranslatorVisitor::EOR_asimd(bool Q, Vec Vm, Vec Vn, Vec Vd) {
|
|
|
|
|
const size_t datasize = Q ? 128 : 64;
|
|
|
|
|
|
|
|
|
|
auto operand1 = V(datasize, Vn);
|
|
|
|
|
auto operand2 = V(datasize, Vm);
|
|
|
|
|
|
|
|
|
|
auto result = ir.VectorEor(operand1, operand2);
|
|
|
|
|
|
|
|
|
|
V(datasize, Vd, result);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-27 19:23:55 +01:00
|
|
|
bool TranslatorVisitor::BIF(bool Q, Vec Vm, Vec Vn, Vec Vd) {
|
|
|
|
|
const size_t datasize = Q ? 128 : 64;
|
|
|
|
|
|
|
|
|
|
auto operand1 = V(datasize, Vd);
|
|
|
|
|
auto operand4 = V(datasize, Vn);
|
|
|
|
|
auto operand3 = ir.VectorNot(V(datasize, Vm));
|
|
|
|
|
|
2018-02-10 11:18:10 +01:00
|
|
|
auto result = ir.VectorEor(operand1, ir.VectorAnd(ir.VectorEor(operand1, operand4), operand3));
|
2018-01-27 19:23:55 +01:00
|
|
|
|
|
|
|
|
V(datasize, Vd, result);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TranslatorVisitor::BIT(bool Q, Vec Vm, Vec Vn, Vec Vd) {
|
|
|
|
|
const size_t datasize = Q ? 128 : 64;
|
|
|
|
|
|
|
|
|
|
auto operand1 = V(datasize, Vd);
|
|
|
|
|
auto operand4 = V(datasize, Vn);
|
|
|
|
|
auto operand3 = V(datasize, Vm);
|
|
|
|
|
|
2018-02-10 11:18:10 +01:00
|
|
|
auto result = ir.VectorEor(operand1, ir.VectorAnd(ir.VectorEor(operand1, operand4), operand3));
|
2018-01-27 19:23:55 +01:00
|
|
|
|
|
|
|
|
V(datasize, Vd, result);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TranslatorVisitor::BSL(bool Q, Vec Vm, Vec Vn, Vec Vd) {
|
|
|
|
|
const size_t datasize = Q ? 128 : 64;
|
|
|
|
|
|
|
|
|
|
auto operand4 = V(datasize, Vn);
|
|
|
|
|
auto operand1 = V(datasize, Vm);
|
|
|
|
|
auto operand3 = V(datasize, Vd);
|
|
|
|
|
|
2018-02-10 11:18:10 +01:00
|
|
|
auto result = ir.VectorEor(operand1, ir.VectorAnd(ir.VectorEor(operand1, operand4), operand3));
|
2018-01-27 19:23:55 +01:00
|
|
|
|
|
|
|
|
V(datasize, Vd, result);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-26 14:51:48 +01:00
|
|
|
} // namespace Dynarmic::A64
|