mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-03-08 00:06:28 +00:00
A32: Implement ASIMD VREV{16, 32, 64}
This commit is contained in:
@@ -9,6 +9,66 @@
|
||||
|
||||
namespace Dynarmic::A32 {
|
||||
|
||||
bool ArmTranslatorVisitor::asimd_VREV(bool D, size_t sz, size_t Vd, size_t op, bool Q, bool M, size_t Vm) {
|
||||
if (op + sz >= 3) {
|
||||
return UndefinedInstruction();
|
||||
}
|
||||
|
||||
if (Q && (Common::Bit<0>(Vd) || Common::Bit<0>(Vm))) {
|
||||
return UndefinedInstruction();
|
||||
}
|
||||
|
||||
const auto d = ToVector(Q, Vd, D);
|
||||
const auto m = ToVector(Q, Vm, M);
|
||||
const auto result = [this, m, op, sz] {
|
||||
const auto reg_m = ir.GetVector(m);
|
||||
const size_t esize = 16U << sz;
|
||||
const auto shift = static_cast<u8>(8U << sz);
|
||||
|
||||
// 64-bit regions
|
||||
if (op == 0b00) {
|
||||
IR::U128 result = ir.VectorOr(ir.VectorLogicalShiftRight(esize, reg_m, shift),
|
||||
ir.VectorLogicalShiftLeft(esize, reg_m, shift));
|
||||
|
||||
switch (sz) {
|
||||
case 0: // 8-bit elements
|
||||
result = ir.VectorShuffleLowHalfwords(result, 0b00011011);
|
||||
result = ir.VectorShuffleHighHalfwords(result, 0b00011011);
|
||||
break;
|
||||
case 1: // 16-bit elements
|
||||
result = ir.VectorShuffleLowHalfwords(result, 0b01001110);
|
||||
result = ir.VectorShuffleHighHalfwords(result, 0b01001110);
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// 32-bit regions
|
||||
if (op == 0b01) {
|
||||
IR::U128 result = ir.VectorOr(ir.VectorLogicalShiftRight(esize, reg_m, shift),
|
||||
ir.VectorLogicalShiftLeft(esize, reg_m, shift));
|
||||
|
||||
// If dealing with 8-bit elements we'll need to shuffle the bytes in each halfword
|
||||
// e.g. Assume the following numbers point out bytes in a 32-bit word, we're essentially
|
||||
// changing [3, 2, 1, 0] to [2, 3, 0, 1]
|
||||
if (sz == 0) {
|
||||
result = ir.VectorShuffleLowHalfwords(result, 0b10110001);
|
||||
result = ir.VectorShuffleHighHalfwords(result, 0b10110001);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// 16-bit regions
|
||||
return ir.VectorOr(ir.VectorLogicalShiftRight(esize, reg_m, 8),
|
||||
ir.VectorLogicalShiftLeft(esize, reg_m, 8));
|
||||
}();
|
||||
|
||||
ir.SetVector(d, result);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ArmTranslatorVisitor::asimd_VCLS(bool D, size_t sz, size_t Vd, bool Q, bool M, size_t Vm) {
|
||||
if (sz == 0b11) {
|
||||
return UndefinedInstruction();
|
||||
|
||||
Reference in New Issue
Block a user