thumb32: Implement MLS

This commit is contained in:
Lioncash 2021-02-06 18:54:30 -05:00 committed by MerryMage
parent cf5058bccb
commit b07fab604f
3 changed files with 16 additions and 1 deletions

View file

@ -263,7 +263,7 @@ INST(thumb32_CLZ, "CLZ", "111110101011nnnn1111dd
// Multiply, Multiply Accumulate, and Absolute Difference // Multiply, Multiply Accumulate, and Absolute Difference
INST(thumb32_MUL, "MUL", "111110110000nnnn1111dddd0000mmmm") INST(thumb32_MUL, "MUL", "111110110000nnnn1111dddd0000mmmm")
INST(thumb32_MLA, "MLA", "111110110000nnnnaaaadddd0000mmmm") INST(thumb32_MLA, "MLA", "111110110000nnnnaaaadddd0000mmmm")
//INST(thumb32_MLS, "MLS", "111110110000------------0001----") INST(thumb32_MLS, "MLS", "111110110000nnnnaaaadddd0001mmmm")
//INST(thumb32_SMULXY, "SMULXY", "111110110001----1111----00------") //INST(thumb32_SMULXY, "SMULXY", "111110110001----1111----00------")
//INST(thumb32_SMLAXY, "SMLAXY", "111110110001------------00------") //INST(thumb32_SMLAXY, "SMLAXY", "111110110001------------00------")
//INST(thumb32_SMUAD, "SMUAD", "111110110010----1111----000-----") //INST(thumb32_SMUAD, "SMUAD", "111110110010----1111----000-----")

View file

@ -21,6 +21,20 @@ bool ThumbTranslatorVisitor::thumb32_MLA(Reg n, Reg a, Reg d, Reg m) {
return true; return true;
} }
bool ThumbTranslatorVisitor::thumb32_MLS(Reg n, Reg a, Reg d, Reg m) {
if (d == Reg::PC || n == Reg::PC || m == Reg::PC) {
return UnpredictableInstruction();
}
const auto reg_a = ir.GetRegister(a);
const auto reg_m = ir.GetRegister(m);
const auto reg_n = ir.GetRegister(n);
const auto result = ir.Sub(reg_a, ir.Mul(reg_n, reg_m));
ir.SetRegister(d, result);
return true;
}
bool ThumbTranslatorVisitor::thumb32_MUL(Reg n, Reg d, Reg m) { bool ThumbTranslatorVisitor::thumb32_MUL(Reg n, Reg d, Reg m) {
if (d == Reg::PC || n == Reg::PC || m == Reg::PC) { if (d == Reg::PC || n == Reg::PC || m == Reg::PC) {
return UnpredictableInstruction(); return UnpredictableInstruction();

View file

@ -130,6 +130,7 @@ struct ThumbTranslatorVisitor final {
// thumb32 multiply instructions // thumb32 multiply instructions
bool thumb32_MLA(Reg n, Reg a, Reg d, Reg m); bool thumb32_MLA(Reg n, Reg a, Reg d, Reg m);
bool thumb32_MLS(Reg n, Reg a, Reg d, Reg m);
bool thumb32_MUL(Reg n, Reg d, Reg m); bool thumb32_MUL(Reg n, Reg d, Reg m);
// thumb32 parallel add/sub instructions // thumb32 parallel add/sub instructions