compile UMULLs and some fixes

This commit is contained in:
RSDuck 2020-04-25 14:42:37 +02:00
parent 3787bab1f6
commit 68d552074b
4 changed files with 30 additions and 12 deletions

View File

@ -301,10 +301,11 @@ void Compiler::A_Comp_MUL_MLA()
Comp_MulOp(S, add, rd, rm, rs, rn); Comp_MulOp(S, add, rd, rm, rs, rn);
} }
void Compiler::A_Comp_SMULL_SMLAL() void Compiler::A_Comp_Mul_Long()
{ {
bool S = CurInstr.Instr & (1 << 20); bool S = CurInstr.Instr & (1 << 20);
bool add = CurInstr.Instr & (1 << 21); bool add = CurInstr.Instr & (1 << 21);
bool sign = CurInstr.Instr & (1 << 22);
OpArg rd = MapReg(CurInstr.A_Reg(16)); OpArg rd = MapReg(CurInstr.A_Reg(16));
OpArg rm = MapReg(CurInstr.A_Reg(0)); OpArg rm = MapReg(CurInstr.A_Reg(0));
OpArg rs = MapReg(CurInstr.A_Reg(8)); OpArg rs = MapReg(CurInstr.A_Reg(8));
@ -318,18 +319,34 @@ void Compiler::A_Comp_SMULL_SMLAL()
MOV(32, R(RSCRATCH3), rs); MOV(32, R(RSCRATCH3), rs);
TEST(32, R(RSCRATCH3), R(RSCRATCH3)); TEST(32, R(RSCRATCH3), R(RSCRATCH3));
FixupBranch zeroBSR = J_CC(CC_Z); FixupBranch zeroBSR = J_CC(CC_Z);
if (sign)
{
BSR(32, RSCRATCH2, R(RSCRATCH3)); BSR(32, RSCRATCH2, R(RSCRATCH3));
NOT(32, R(RSCRATCH3)); NOT(32, R(RSCRATCH3));
BSR(32, RSCRATCH, R(RSCRATCH3)); BSR(32, RSCRATCH, R(RSCRATCH3));
CMP(32, R(RSCRATCH2), R(RSCRATCH)); CMP(32, R(RSCRATCH2), R(RSCRATCH));
CMOVcc(32, RSCRATCH, R(RSCRATCH2), CC_L); CMOVcc(32, RSCRATCH, R(RSCRATCH2), CC_L);
}
else
{
BSR(32, RSCRATCH, R(RSCRATCH3));
}
SHR(32, R(RSCRATCH), Imm8(3)); SHR(32, R(RSCRATCH), Imm8(3));
SetJumpTarget(zeroBSR); // fortunately that's even right SetJumpTarget(zeroBSR); // fortunately that's even right
Comp_AddCycles_CI(RSCRATCH, 2); Comp_AddCycles_CI(RSCRATCH, 2);
} }
if (sign)
{
MOVSX(64, 32, RSCRATCH2, rm); MOVSX(64, 32, RSCRATCH2, rm);
MOVSX(64, 32, RSCRATCH3, rs); MOVSX(64, 32, RSCRATCH3, rs);
}
else
{
MOV(32, R(RSCRATCH2), rm);
MOV(32, R(RSCRATCH3), rs);
}
if (add) if (add)
{ {
MOV(32, R(RSCRATCH), rd); MOV(32, R(RSCRATCH), rd);

View File

@ -300,7 +300,7 @@ const Compiler::CompileFunc A_Comp[ARMInstrInfo::ak_Count] =
// CMN // CMN
F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp), F(A_Comp_CmpOp),
// Mul // Mul
F(A_Comp_MUL_MLA), F(A_Comp_MUL_MLA), NULL, NULL, NULL, F(A_Comp_SMULL_SMLAL), NULL, NULL, NULL, NULL, NULL, F(A_Comp_MUL_MLA), F(A_Comp_MUL_MLA), F(A_Comp_Mul_Long), F(A_Comp_Mul_Long), F(A_Comp_Mul_Long), F(A_Comp_Mul_Long), NULL, NULL, NULL, NULL, NULL,
// ARMv5 stuff // ARMv5 stuff
F(A_Comp_CLZ), NULL, NULL, NULL, NULL, F(A_Comp_CLZ), NULL, NULL, NULL, NULL,
// STR // STR
@ -628,7 +628,7 @@ void Compiler::Comp_AddCycles_CI(Gen::X64Reg i, int add)
} }
else else
{ {
ConstantCycles += i + cycles; ConstantCycles += cycles;
SUB(32, MDisp(RCPU, offsetof(ARM, Cycles)), R(i)); SUB(32, MDisp(RCPU, offsetof(ARM, Cycles)), R(i));
} }
} }

View File

@ -89,7 +89,7 @@ public:
void A_Comp_CmpOp(); void A_Comp_CmpOp();
void A_Comp_MUL_MLA(); void A_Comp_MUL_MLA();
void A_Comp_SMULL_SMLAL(); void A_Comp_Mul_Long();
void A_Comp_CLZ(); void A_Comp_CLZ();

View File

@ -423,6 +423,7 @@ void Compiler::Comp_MemAccess(int rd, int rn, const ComplexOperand& op2, int siz
if (flags & memop_SubtractOffset) if (flags & memop_SubtractOffset)
{ {
if (R(finalAddr) != rnMapped)
MOV(32, R(finalAddr), rnMapped); MOV(32, R(finalAddr), rnMapped);
if (!offset.IsZero()) if (!offset.IsZero())
SUB(32, R(finalAddr), offset); SUB(32, R(finalAddr), offset);