thumb32: Implement SMLAWY

This commit is contained in:
Lioncash 2021-02-07 13:34:56 -05:00
parent 96895d2eb5
commit b58cd3a996
3 changed files with 21 additions and 1 deletions

View file

@ -269,7 +269,7 @@ INST(thumb32_SMLAXY, "SMLAXY", "111110110001nnnnaaaadd
INST(thumb32_SMUAD, "SMUAD", "111110110010nnnn1111dddd000Mmmmm") INST(thumb32_SMUAD, "SMUAD", "111110110010nnnn1111dddd000Mmmmm")
INST(thumb32_SMLAD, "SMLAD", "111110110010nnnnaaaadddd000Xmmmm") INST(thumb32_SMLAD, "SMLAD", "111110110010nnnnaaaadddd000Xmmmm")
INST(thumb32_SMULWY, "SMULWY", "111110110011nnnn1111dddd000Mmmmm") INST(thumb32_SMULWY, "SMULWY", "111110110011nnnn1111dddd000Mmmmm")
//INST(thumb32_SMLAWY, "SMLAWY", "111110110011------------000-----") INST(thumb32_SMLAWY, "SMLAWY", "111110110011nnnnaaaadddd000Mmmmm")
INST(thumb32_SMUSD, "SMUSD", "111110110100nnnn1111dddd000Mmmmm") INST(thumb32_SMUSD, "SMUSD", "111110110100nnnn1111dddd000Mmmmm")
INST(thumb32_SMLSD, "SMLSD", "111110110100nnnnaaaadddd000Xmmmm") INST(thumb32_SMLSD, "SMLSD", "111110110100nnnnaaaadddd000Xmmmm")
INST(thumb32_SMMUL, "SMMUL", "111110110101nnnn1111dddd000Rmmmm") INST(thumb32_SMMUL, "SMMUL", "111110110101nnnn1111dddd000Rmmmm")

View file

@ -245,6 +245,25 @@ bool ThumbTranslatorVisitor::thumb32_SMULXY(Reg n, Reg d, bool N, bool M, Reg m)
return true; return true;
} }
bool ThumbTranslatorVisitor::thumb32_SMLAWY(Reg n, Reg a, Reg d, bool M, Reg m) {
if (d == Reg::PC || n == Reg::PC || m == Reg::PC || a == Reg::PC) {
return UnpredictableInstruction();
}
const IR::U64 n32 = ir.SignExtendWordToLong(ir.GetRegister(n));
IR::U32 m32 = ir.GetRegister(m);
if (M) {
m32 = ir.LogicalShiftRight(m32, ir.Imm8(16), ir.Imm1(0)).result;
}
const IR::U64 m16 = ir.SignExtendWordToLong(ir.SignExtendHalfToWord(ir.LeastSignificantHalf(m32)));
const auto product = ir.LeastSignificantWord(ir.LogicalShiftRight(ir.Mul(n32, m16), ir.Imm8(16)));
const auto result_overflow = ir.AddWithCarry(product, ir.GetRegister(a), ir.Imm1(0));
ir.SetRegister(d, result_overflow.result);
ir.OrQFlag(result_overflow.overflow);
return true;
}
bool ThumbTranslatorVisitor::thumb32_SMULWY(Reg n, Reg d, bool M, Reg m) { bool ThumbTranslatorVisitor::thumb32_SMULWY(Reg n, Reg d, bool M, 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

@ -134,6 +134,7 @@ struct ThumbTranslatorVisitor final {
bool thumb32_MUL(Reg n, Reg d, Reg m); bool thumb32_MUL(Reg n, Reg d, Reg m);
bool thumb32_SMLAD(Reg n, Reg a, Reg d, bool X, Reg m); bool thumb32_SMLAD(Reg n, Reg a, Reg d, bool X, Reg m);
bool thumb32_SMLAXY(Reg n, Reg a, Reg d, bool N, bool M, Reg m); bool thumb32_SMLAXY(Reg n, Reg a, Reg d, bool N, bool M, Reg m);
bool thumb32_SMLAWY(Reg n, Reg a, Reg d, bool M, Reg m);
bool thumb32_SMLSD(Reg n, Reg a, Reg d, bool X, Reg m); bool thumb32_SMLSD(Reg n, Reg a, Reg d, bool X, Reg m);
bool thumb32_SMMLA(Reg n, Reg a, Reg d, bool R, Reg m); bool thumb32_SMMLA(Reg n, Reg a, Reg d, bool R, Reg m);
bool thumb32_SMMLS(Reg n, Reg a, Reg d, bool R, Reg m); bool thumb32_SMMLS(Reg n, Reg a, Reg d, bool R, Reg m);