diff options
| author | 2016-04-13 23:36:39 -0400 | |
|---|---|---|
| committer | 2016-04-13 23:36:39 -0400 | |
| commit | d89e48679e93f8a6242d9c8d0837053f5aa708d0 (patch) | |
| tree | 7bb6c9fd8e9a659369e92661478925512ac8eddd /src/common | |
| parent | Merge pull request #1660 from MerryMage/file_util (diff) | |
| parent | shader_jit_x64: Rename RuntimeAssert to Compile_Assert. (diff) | |
| download | yuzu-d89e48679e93f8a6242d9c8d0837053f5aa708d0.tar.gz yuzu-d89e48679e93f8a6242d9c8d0837053f5aa708d0.tar.xz yuzu-d89e48679e93f8a6242d9c8d0837053f5aa708d0.zip | |
Merge pull request #1546 from bunnei/refactor-shader-jit
Shader JIT Part 2
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/x64/emitter.cpp | 28 | ||||
| -rw-r--r-- | src/common/x64/emitter.h | 2 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/common/x64/emitter.cpp b/src/common/x64/emitter.cpp index 1dcf2416c..5662f7f86 100644 --- a/src/common/x64/emitter.cpp +++ b/src/common/x64/emitter.cpp | |||
| @@ -455,6 +455,18 @@ void XEmitter::CALL(const void* fnptr) | |||
| 455 | Write32(u32(distance)); | 455 | Write32(u32(distance)); |
| 456 | } | 456 | } |
| 457 | 457 | ||
| 458 | FixupBranch XEmitter::CALL() | ||
| 459 | { | ||
| 460 | FixupBranch branch; | ||
| 461 | branch.type = 1; | ||
| 462 | branch.ptr = code + 5; | ||
| 463 | |||
| 464 | Write8(0xE8); | ||
| 465 | Write32(0); | ||
| 466 | |||
| 467 | return branch; | ||
| 468 | } | ||
| 469 | |||
| 458 | FixupBranch XEmitter::J(bool force5bytes) | 470 | FixupBranch XEmitter::J(bool force5bytes) |
| 459 | { | 471 | { |
| 460 | FixupBranch branch; | 472 | FixupBranch branch; |
| @@ -531,6 +543,22 @@ void XEmitter::SetJumpTarget(const FixupBranch& branch) | |||
| 531 | } | 543 | } |
| 532 | } | 544 | } |
| 533 | 545 | ||
| 546 | void XEmitter::SetJumpTarget(const FixupBranch& branch, const u8* target) | ||
| 547 | { | ||
| 548 | if (branch.type == 0) | ||
| 549 | { | ||
| 550 | s64 distance = (s64)(target - branch.ptr); | ||
| 551 | ASSERT_MSG(distance >= -0x80 && distance < 0x80, "Jump target too far away, needs force5Bytes = true"); | ||
| 552 | branch.ptr[-1] = (u8)(s8)distance; | ||
| 553 | } | ||
| 554 | else if (branch.type == 1) | ||
| 555 | { | ||
| 556 | s64 distance = (s64)(target - branch.ptr); | ||
| 557 | ASSERT_MSG(distance >= -0x80000000LL && distance < 0x80000000LL, "Jump target too far away, needs indirect register"); | ||
| 558 | ((s32*)branch.ptr)[-1] = (s32)distance; | ||
| 559 | } | ||
| 560 | } | ||
| 561 | |||
| 534 | //Single byte opcodes | 562 | //Single byte opcodes |
| 535 | //There is no PUSHAD/POPAD in 64-bit mode. | 563 | //There is no PUSHAD/POPAD in 64-bit mode. |
| 536 | void XEmitter::INT3() {Write8(0xCC);} | 564 | void XEmitter::INT3() {Write8(0xCC);} |
diff --git a/src/common/x64/emitter.h b/src/common/x64/emitter.h index 7c6548fb5..a33724146 100644 --- a/src/common/x64/emitter.h +++ b/src/common/x64/emitter.h | |||
| @@ -425,12 +425,14 @@ public: | |||
| 425 | #undef CALL | 425 | #undef CALL |
| 426 | #endif | 426 | #endif |
| 427 | void CALL(const void* fnptr); | 427 | void CALL(const void* fnptr); |
| 428 | FixupBranch CALL(); | ||
| 428 | void CALLptr(OpArg arg); | 429 | void CALLptr(OpArg arg); |
| 429 | 430 | ||
| 430 | FixupBranch J_CC(CCFlags conditionCode, bool force5bytes = false); | 431 | FixupBranch J_CC(CCFlags conditionCode, bool force5bytes = false); |
| 431 | void J_CC(CCFlags conditionCode, const u8* addr, bool force5Bytes = false); | 432 | void J_CC(CCFlags conditionCode, const u8* addr, bool force5Bytes = false); |
| 432 | 433 | ||
| 433 | void SetJumpTarget(const FixupBranch& branch); | 434 | void SetJumpTarget(const FixupBranch& branch); |
| 435 | void SetJumpTarget(const FixupBranch& branch, const u8* target); | ||
| 434 | 436 | ||
| 435 | void SETcc(CCFlags flag, OpArg dest); | 437 | void SETcc(CCFlags flag, OpArg dest); |
| 436 | // Note: CMOV brings small if any benefit on current cpus. | 438 | // Note: CMOV brings small if any benefit on current cpus. |