A64: Implement USHR (scalar)

This commit is contained in:
Lioncash 2018-04-12 14:19:42 -04:00 committed by MerryMage
parent 870e418b0b
commit d56fa8f735
2 changed files with 25 additions and 1 deletions

View file

@ -477,7 +477,7 @@ INST(SHL_1, "SHL", "01011
//INST(SQRSHRN_1, "SQRSHRN, SQRSHRN2", "010111110IIIIiii100111nnnnnddddd") //INST(SQRSHRN_1, "SQRSHRN, SQRSHRN2", "010111110IIIIiii100111nnnnnddddd")
//INST(SCVTF_fix_1, "SCVTF (vector, fixed-point)", "010111110IIIIiii111001nnnnnddddd") //INST(SCVTF_fix_1, "SCVTF (vector, fixed-point)", "010111110IIIIiii111001nnnnnddddd")
//INST(FCVTZS_fix_1, "FCVTZS (vector, fixed-point)", "010111110IIIIiii111111nnnnnddddd") //INST(FCVTZS_fix_1, "FCVTZS (vector, fixed-point)", "010111110IIIIiii111111nnnnnddddd")
//INST(USHR_1, "USHR", "011111110IIIIiii000001nnnnnddddd") INST(USHR_1, "USHR", "011111110IIIIiii000001nnnnnddddd")
//INST(USRA_1, "USRA", "011111110IIIIiii000101nnnnnddddd") //INST(USRA_1, "USRA", "011111110IIIIiii000101nnnnnddddd")
//INST(URSHR_1, "URSHR", "011111110IIIIiii001001nnnnnddddd") //INST(URSHR_1, "URSHR", "011111110IIIIiii001001nnnnnddddd")
//INST(URSRA_1, "URSRA", "011111110IIIIiii001101nnnnnddddd") //INST(URSRA_1, "URSRA", "011111110IIIIiii001101nnnnnddddd")

View file

@ -8,6 +8,21 @@
namespace Dynarmic::A64 { namespace Dynarmic::A64 {
static void ShiftRight(TranslatorVisitor& v, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) {
const size_t esize = 64;
const u8 shift_amount = static_cast<u8>((esize * 2) - concatenate(immh, immb).ZeroExtend());
const IR::U64 operand = v.V_scalar(esize, Vn);
const IR::U64 result = [&] {
if (shift_amount == esize) {
return v.ir.Imm64(0);
}
return v.ir.LogicalShiftRight(operand, v.ir.Imm8(shift_amount));
}();
v.V_scalar(esize, Vd, result);
}
bool TranslatorVisitor::SHL_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { bool TranslatorVisitor::SHL_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) {
if (!immh.Bit<3>()) { if (!immh.Bit<3>()) {
return ReservedValue(); return ReservedValue();
@ -23,4 +38,13 @@ bool TranslatorVisitor::SHL_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) {
return true; return true;
} }
bool TranslatorVisitor::USHR_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) {
if (!immh.Bit<3>()) {
return ReservedValue();
}
ShiftRight(*this, immh, immb, Vn, Vd);
return true;
}
} // namespace Dynarmic::A64 } // namespace Dynarmic::A64