thumb32: Implement SMMUL{R}

This commit is contained in:
Lioncash 2021-02-07 13:11:25 -05:00
parent 44f4f437a7
commit b6add0ddf4
3 changed files with 20 additions and 1 deletions

View file

@ -272,7 +272,7 @@ INST(thumb32_SMUAD, "SMUAD", "111110110010nnnn1111dd
//INST(thumb32_SMLAWY, "SMLAWY", "111110110011------------000-----")
INST(thumb32_SMUSD, "SMUSD", "111110110100nnnn1111dddd000Mmmmm")
//INST(thumb32_SMLSD, "SMLSD", "111110110100------------000-----")
//INST(thumb32_SMMUL, "SMMUL", "111110110101----1111----000-----")
INST(thumb32_SMMUL, "SMMUL", "111110110101nnnn1111dddd000Mmmmm")
//INST(thumb32_SMMLA, "SMMLA", "111110110101------------000-----")
//INST(thumb32_SMMLS, "SMMLS", "111110110110------------000-----")
INST(thumb32_USAD8, "USAD8", "111110110111nnnn1111dddd0000mmmm")

View file

@ -67,6 +67,24 @@ bool ThumbTranslatorVisitor::thumb32_SMLAXY(Reg n, Reg a, Reg d, bool N, bool M,
return true;
}
bool ThumbTranslatorVisitor::thumb32_SMMUL(Reg n, Reg d, bool R, Reg m) {
if (d == Reg::PC || n == Reg::PC || m == Reg::PC) {
return UnpredictableInstruction();
}
const auto n64 = ir.SignExtendWordToLong(ir.GetRegister(n));
const auto m64 = ir.SignExtendWordToLong(ir.GetRegister(m));
const auto product = ir.Mul(n64, m64);
const auto result_carry = ir.MostSignificantWord(product);
auto result = result_carry.result;
if (R) {
result = ir.AddWithCarry(result, ir.Imm32(0), result_carry.carry).result;
}
ir.SetRegister(d, result);
return true;
}
bool ThumbTranslatorVisitor::thumb32_SMUAD(Reg n, Reg d, bool M, Reg m) {
if (d == Reg::PC || n == Reg::PC || m == Reg::PC) {
return UnpredictableInstruction();

View file

@ -133,6 +133,7 @@ struct ThumbTranslatorVisitor final {
bool thumb32_MLS(Reg n, Reg a, Reg d, Reg m);
bool thumb32_MUL(Reg n, Reg d, Reg m);
bool thumb32_SMLAXY(Reg n, Reg a, Reg d, bool N, bool M, Reg m);
bool thumb32_SMMUL(Reg n, Reg d, bool R, Reg m);
bool thumb32_SMUAD(Reg n, Reg d, bool M, Reg m);
bool thumb32_SMUSD(Reg n, Reg d, bool M, Reg m);
bool thumb32_SMULXY(Reg n, Reg d, bool N, bool M, Reg m);