thumb32: Implement SASX/UASX

This commit is contained in:
Lioncash 2021-02-01 16:30:08 -05:00
parent d529417875
commit 21e404d3ab
4 changed files with 36 additions and 2 deletions

View file

@ -236,7 +236,7 @@ std::optional<std::reference_wrapper<const Thumb32Matcher<V>>> DecodeThumb32(u32
// Parallel Addition and Subtraction (signed)
INST(&V::thumb32_SADD16, "SADD16", "111110101001nnnn1111dddd0000mmmm"),
//INST(&V::thumb32_SASX, "SASX", "111110101010----1111----0000----"),
INST(&V::thumb32_SASX, "SASX", "111110101010nnnn1111dddd0000mmmm"),
//INST(&V::thumb32_SSAX, "SSAX", "111110101110----1111----0000----"),
//INST(&V::thumb32_SSUB16, "SSUB16", "111110101101----1111----0000----"),
//INST(&V::thumb32_SADD8, "SADD8", "111110101000----1111----0000----"),
@ -256,7 +256,7 @@ std::optional<std::reference_wrapper<const Thumb32Matcher<V>>> DecodeThumb32(u32
// Parallel Addition and Subtraction (unsigned)
INST(&V::thumb32_UADD16, "UADD16", "111110101001nnnn1111dddd0100mmmm"),
//INST(&V::thumb32_UASX, "UASX", "111110101010----1111----0100----"),
INST(&V::thumb32_UASX, "UASX", "111110101010nnnn1111dddd0100mmmm"),
//INST(&V::thumb32_USAX, "USAX", "111110101110----1111----0100----"),
//INST(&V::thumb32_USUB16, "USUB16", "111110101101----1111----0100----"),
//INST(&V::thumb32_UADD8, "UADD8", "111110101000----1111----0100----"),

View file

@ -21,6 +21,20 @@ bool ThumbTranslatorVisitor::thumb32_SADD16(Reg n, Reg d, Reg m) {
return true;
}
bool ThumbTranslatorVisitor::thumb32_SASX(Reg n, Reg d, Reg m) {
if (d == Reg::PC || n == Reg::PC || m == Reg::PC) {
return UnpredictableInstruction();
}
const auto reg_m = ir.GetRegister(m);
const auto reg_n = ir.GetRegister(n);
const auto result = ir.PackedAddSubS16(reg_n, reg_m);
ir.SetRegister(d, result.result);
ir.SetGEFlags(result.ge);
return true;
}
bool ThumbTranslatorVisitor::thumb32_UADD16(Reg n, Reg d, Reg m) {
if (d == Reg::PC || n == Reg::PC || m == Reg::PC) {
return UnpredictableInstruction();
@ -35,4 +49,18 @@ bool ThumbTranslatorVisitor::thumb32_UADD16(Reg n, Reg d, Reg m) {
return true;
}
bool ThumbTranslatorVisitor::thumb32_UASX(Reg n, Reg d, Reg m) {
if (d == Reg::PC || n == Reg::PC || m == Reg::PC) {
return UnpredictableInstruction();
}
const auto reg_m = ir.GetRegister(m);
const auto reg_n = ir.GetRegister(n);
const auto result = ir.PackedAddSubU16(reg_n, reg_m);
ir.SetRegister(d, result.result);
ir.SetGEFlags(result.ge);
return true;
}
} // namespace Dynarmic::A32

View file

@ -130,7 +130,9 @@ struct ThumbTranslatorVisitor final {
// thumb32 parallel add/sub instructions
bool thumb32_SADD16(Reg n, Reg d, Reg m);
bool thumb32_SASX(Reg n, Reg d, Reg m);
bool thumb32_UADD16(Reg n, Reg d, Reg m);
bool thumb32_UASX(Reg n, Reg d, Reg m);
};
} // namespace Dynarmic::A32

View file

@ -414,10 +414,14 @@ TEST_CASE("Fuzz Thumb32 instructions set", "[JitX64][Thumb][Thumb32]") {
}),
ThumbInstGen("111110101001nnnn1111dddd0000mmmm", // SADD16
three_reg_not_r15),
ThumbInstGen("111110101010nnnn1111dddd0000mmmm", // SASX
three_reg_not_r15),
ThumbInstGen("111110101010nnnn1111dddd1000mmmm", // SEL
three_reg_not_r15),
ThumbInstGen("111110101001nnnn1111dddd0100mmmm", // UADD16
three_reg_not_r15),
ThumbInstGen("111110101010nnnn1111dddd0100mmmm", // UASX
three_reg_not_r15),
};
const auto instruction_select = [&]() -> u32 {