thumb32: Implement SEL

This commit is contained in:
Lioncash 2021-02-01 15:01:21 -05:00
parent 8d53048750
commit 1ad99bb9b5
4 changed files with 22 additions and 1 deletions

View file

@ -283,7 +283,7 @@ std::optional<std::reference_wrapper<const Thumb32Matcher<V>>> DecodeThumb32(u32
//INST(&V::thumb32_REV16, "REV16", "111110101001----1111----1001----"), //INST(&V::thumb32_REV16, "REV16", "111110101001----1111----1001----"),
//INST(&V::thumb32_RBIT, "RBIT", "111110101001----1111----1010----"), //INST(&V::thumb32_RBIT, "RBIT", "111110101001----1111----1010----"),
//INST(&V::thumb32_REVSH, "REVSH", "111110101001----1111----1011----"), //INST(&V::thumb32_REVSH, "REVSH", "111110101001----1111----1011----"),
//INST(&V::thumb32_SEL, "SEL", "111110101010----1111----1000----"), INST(&V::thumb32_SEL, "SEL", "111110101010nnnn1111dddd1000mmmm"),
INST(&V::thumb32_CLZ, "CLZ", "111110101011nnnn1111dddd1000mmmm"), INST(&V::thumb32_CLZ, "CLZ", "111110101011nnnn1111dddd1000mmmm"),
// Multiply, Multiply Accumulate, and Absolute Difference // Multiply, Multiply Accumulate, and Absolute Difference

View file

@ -19,4 +19,17 @@ bool ThumbTranslatorVisitor::thumb32_CLZ(Reg n, Reg d, Reg m) {
return true; return true;
} }
bool ThumbTranslatorVisitor::thumb32_SEL(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.PackedSelect(ir.GetGEFlags(), reg_m, reg_n);
ir.SetRegister(d, result);
return true;
}
} // namespace Dynarmic::A32 } // namespace Dynarmic::A32

View file

@ -118,6 +118,7 @@ struct ThumbTranslatorVisitor final {
// thumb32 miscellaneous instructions // thumb32 miscellaneous instructions
bool thumb32_CLZ(Reg n, Reg d, Reg m); bool thumb32_CLZ(Reg n, Reg d, Reg m);
bool thumb32_SEL(Reg n, Reg d, Reg m);
}; };
} // namespace Dynarmic::A32 } // namespace Dynarmic::A32

View file

@ -369,6 +369,13 @@ TEST_CASE("Fuzz Thumb32 instructions set", "[JitX64][Thumb][Thumb32]") {
const auto n = Common::Bits<16, 19>(inst); const auto n = Common::Bits<16, 19>(inst);
return m == n && d != 15 && m != 15; return m == n && d != 15 && m != 15;
}), }),
ThumbInstGen("111110101010nnnn1111dddd1000mmmm",
[](u32 inst) {
const auto d = Common::Bits<8, 11>(inst);
const auto m = Common::Bits<0, 3>(inst);
const auto n = Common::Bits<16, 19>(inst);
return d != 15 && m != 15 && n != 15;
}),
}; };
const auto instruction_select = [&]() -> u32 { const auto instruction_select = [&]() -> u32 {