From 1f94abea182e4f09a058c3825eb8daca3bcb71e3 Mon Sep 17 00:00:00 2001 From: degasus Date: Sun, 11 Sep 2016 11:15:50 +0200 Subject: [PATCH] JitArm64: Optimize logic immediate instructions. Try to use also the immediate instruction on ARM. --- Source/Core/Core/PowerPC/JitArm64/Jit.h | 7 +--- .../PowerPC/JitArm64/JitArm64_Integer.cpp | 37 +++++-------------- 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitArm64/Jit.h b/Source/Core/Core/PowerPC/JitArm64/Jit.h index c2832ff460..66f9b07337 100644 --- a/Source/Core/Core/PowerPC/JitArm64/Jit.h +++ b/Source/Core/Core/PowerPC/JitArm64/Jit.h @@ -238,9 +238,6 @@ private: void ComputeCarry(bool Carry); void ComputeCarry(); - typedef u32 (*Operation)(u32, u32); - void reg_imm(u32 d, u32 a, u32 value, Operation do_op, - void (ARM64XEmitter::*op)(Arm64Gen::ARM64Reg, Arm64Gen::ARM64Reg, Arm64Gen::ARM64Reg, - ArithOption), - bool Rc = false); + void reg_imm(u32 d, u32 a, u32 value, u32 (*do_op)(u32, u32), + void (ARM64XEmitter::*op)(ARM64Reg, ARM64Reg, u64, ARM64Reg), bool Rc = false); }; diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp index 0144ef3832..c9a54a3d52 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp @@ -75,25 +75,8 @@ void JitArm64::ComputeCarry() gpr.Unlock(WA); } -// Following static functions are used in conjunction with reg_imm -static u32 Or(u32 a, u32 b) -{ - return a | b; -} - -static u32 And(u32 a, u32 b) -{ - return a & b; -} - -static u32 Xor(u32 a, u32 b) -{ - return a ^ b; -} - -void JitArm64::reg_imm(u32 d, u32 a, u32 value, Operation do_op, - void (ARM64XEmitter::*op)(ARM64Reg, ARM64Reg, ARM64Reg, ArithOption), - bool Rc) +void JitArm64::reg_imm(u32 d, u32 a, u32 value, u32 (*do_op)(u32, u32), + void (ARM64XEmitter::*op)(ARM64Reg, ARM64Reg, u64, ARM64Reg), bool Rc) { if (gpr.IsImm(a)) { @@ -105,8 +88,7 @@ void JitArm64::reg_imm(u32 d, u32 a, u32 value, Operation do_op, { gpr.BindToRegister(d, d == a); ARM64Reg WA = gpr.GetReg(); - MOVI2R(WA, value); - (this->*op)(gpr.R(d), gpr.R(a), WA, ArithOption(WA, ST_LSL, 0)); + (this->*op)(gpr.R(d), gpr.R(a), value, WA); gpr.Unlock(WA); if (Rc) @@ -128,22 +110,23 @@ void JitArm64::arith_imm(UGeckoInstruction inst) // NOP return; } - reg_imm(a, s, inst.UIMM, Or, &ARM64XEmitter::ORR); + reg_imm(a, s, inst.UIMM, [](u32 a, u32 b) { return a | b; }, &ARM64XEmitter::ORRI2R); break; case 25: // oris - reg_imm(a, s, inst.UIMM << 16, Or, &ARM64XEmitter::ORR); + reg_imm(a, s, inst.UIMM << 16, [](u32 a, u32 b) { return a | b; }, &ARM64XEmitter::ORRI2R); break; case 28: // andi - reg_imm(a, s, inst.UIMM, And, &ARM64XEmitter::AND, true); + reg_imm(a, s, inst.UIMM, [](u32 a, u32 b) { return a & b; }, &ARM64XEmitter::ANDI2R, true); break; case 29: // andis - reg_imm(a, s, inst.UIMM << 16, And, &ARM64XEmitter::AND, true); + reg_imm(a, s, inst.UIMM << 16, [](u32 a, u32 b) { return a & b; }, &ARM64XEmitter::ANDI2R, + true); break; case 26: // xori - reg_imm(a, s, inst.UIMM, Xor, &ARM64XEmitter::EOR); + reg_imm(a, s, inst.UIMM, [](u32 a, u32 b) { return a ^ b; }, &ARM64XEmitter::EORI2R); break; case 27: // xoris - reg_imm(a, s, inst.UIMM << 16, Xor, &ARM64XEmitter::EOR); + reg_imm(a, s, inst.UIMM << 16, [](u32 a, u32 b) { return a ^ b; }, &ARM64XEmitter::EORI2R); break; } }