summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2016-04-09 23:46:13 +0200
committerbunnei <bunneidev@gmail.com>2016-04-14 05:04:52 +0200
commit60749f2cda38f35a80a144f990d45c9b016ed0e2 (patch)
treec707d521fe591fb4c02d374ca33f860f5dff176d /src
parentemitter: Add CALL that can be fixed up. (diff)
downloadyuzu-60749f2cda38f35a80a144f990d45c9b016ed0e2.tar
yuzu-60749f2cda38f35a80a144f990d45c9b016ed0e2.tar.gz
yuzu-60749f2cda38f35a80a144f990d45c9b016ed0e2.tar.bz2
yuzu-60749f2cda38f35a80a144f990d45c9b016ed0e2.tar.lz
yuzu-60749f2cda38f35a80a144f990d45c9b016ed0e2.tar.xz
yuzu-60749f2cda38f35a80a144f990d45c9b016ed0e2.tar.zst
yuzu-60749f2cda38f35a80a144f990d45c9b016ed0e2.zip
Diffstat (limited to 'src')
-rw-r--r--src/video_core/shader/shader_jit_x64.cpp24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp
index efea55811..503fad158 100644
--- a/src/video_core/shader/shader_jit_x64.cpp
+++ b/src/video_core/shader/shader_jit_x64.cpp
@@ -583,23 +583,15 @@ void JitCompiler::Compile_END(Instruction instr) {
}
void JitCompiler::Compile_CALL(Instruction instr) {
- // Need to advance the return address past the proceeding instructions, this is the number of bytes to skip
- constexpr unsigned SKIP = 21;
- const uintptr_t start = reinterpret_cast<uintptr_t>(GetCodePtr());
-
- // Push return address - not using CALL because we also want to push the offset of the return before jumping
- MOV(64, R(RAX), ImmPtr(GetCodePtr() + SKIP));
- PUSH(RAX);
-
// Push offset of the return
- PUSH(32, Imm32(instr.flow_control.dest_offset + instr.flow_control.num_instructions));
+ PUSH(64, Imm32(instr.flow_control.dest_offset + instr.flow_control.num_instructions));
- // Jump
- FixupBranch b = J(true);
+ // Call the subroutine
+ FixupBranch b = CALL();
fixup_branches.push_back({ b, instr.flow_control.dest_offset });
- // Make sure that if the above code changes, SKIP gets updated
- ASSERT(reinterpret_cast<ptrdiff_t>(GetCodePtr()) - start == SKIP);
+ // Skip over the return offset that's on the stack
+ ADD(64, R(RSP), Imm32(8));
}
void JitCompiler::Compile_CALLC(Instruction instr) {
@@ -758,14 +750,12 @@ void JitCompiler::Compile_Block(unsigned end) {
void JitCompiler::Compile_Return() {
// Peek return offset on the stack and check if we're at that offset
- MOV(64, R(RAX), MDisp(RSP, 0));
+ MOV(64, R(RAX), MDisp(RSP, 8));
CMP(32, R(RAX), Imm32(program_counter));
// If so, jump back to before CALL
FixupBranch b = J_CC(CC_NZ, true);
- ADD(64, R(RSP), Imm32(8)); // Ignore return offset that's on the stack
- POP(RAX); // Pop off return address
- JMPptr(R(RAX));
+ RET();
SetJumpTarget(b);
}