From b20c518bf043c1f7fc5f2f71c49d2eaef6332079 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Wed, 30 Aug 2023 16:06:08 -0700 Subject: [PATCH] OpcodeDispatcher: Optimize calls with push InstCountCI doesn't cover branch instructions so needs manual inspection. --- FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp b/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp index 64d0ca025..89a85d19f 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp @@ -789,17 +789,14 @@ void OpDispatchBuilder::CALLOp(OpcodeArgs) { OrderedNode *JMPPCOffset = LoadSource(GPRClass, Op, Op->Src[0], Op->Flags, -1); OrderedNode *NewRIP = _Add(IR::SizeToOpSize(GPRSize), ConstantPC, JMPPCOffset); - auto ConstantPCReturn = GetRelocatedPC(Op); - auto ConstantSize = _Constant(GPRSize); + // Push the return address. auto OldSP = LoadGPRRegister(X86State::REG_RSP); - auto NewSP = _Sub(OpSize::i64Bit, OldSP, ConstantSize); + auto NewSP = _Push(GPRSize, GPRSize, ConstantPC, OldSP); // Store the new stack pointer StoreGPRRegister(X86State::REG_RSP, NewSP); - _StoreMem(GPRClass, GPRSize, NewSP, ConstantPCReturn, GPRSize); - const uint64_t NextRIP = Op->PC + Op->InstSize; LOGMAN_THROW_A_FMT(Op->Src[0].IsLiteral(), "Had wrong operand type"); const uint64_t TargetRIP = Op->PC + Op->InstSize + Op->Src[0].Data.Literal.Value; @@ -825,15 +822,13 @@ void OpDispatchBuilder::CALLAbsoluteOp(OpcodeArgs) { auto ConstantPCReturn = GetRelocatedPC(Op); - auto ConstantSize = _Constant(Size); + // Push the return address. auto OldSP = LoadGPRRegister(X86State::REG_RSP); - auto NewSP = _Sub(OpSize::i64Bit, OldSP, ConstantSize); + auto NewSP = _Push(Size, Size, ConstantPCReturn, OldSP); // Store the new stack pointer StoreGPRRegister(X86State::REG_RSP, NewSP); - _StoreMem(GPRClass, Size, NewSP, ConstantPCReturn, Size); - // Store the RIP CalculateDeferredFlags(); _ExitFunction(JMPPCOffset); // If we get here then leave the function now