-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IRInterpreter: Various SIMD optimization. Move out the reverse-bits i…
…mplementation
- Loading branch information
Showing
3 changed files
with
53 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
#pragma once | ||
|
||
#include "Common/CommonTypes.h" | ||
#include "Core/Core.h" | ||
#include "Core/MemMap.h" | ||
|
||
class MIPSState; | ||
struct IRInst; | ||
|
||
inline static u32 ReverseBits32(u32 v) { | ||
// http://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel | ||
// swap odd and even bits | ||
v = ((v >> 1) & 0x55555555) | ((v & 0x55555555) << 1); | ||
// swap consecutive pairs | ||
v = ((v >> 2) & 0x33333333) | ((v & 0x33333333) << 2); | ||
// swap nibbles ... | ||
v = ((v >> 4) & 0x0F0F0F0F) | ((v & 0x0F0F0F0F) << 4); | ||
// swap bytes | ||
v = ((v >> 8) & 0x00FF00FF) | ((v & 0x00FF00FF) << 8); | ||
// swap 2-byte long pairs | ||
v = ( v >> 16 ) | ( v << 16); | ||
return v; | ||
} | ||
|
||
u32 IRRunBreakpoint(u32 pc); | ||
u32 IRRunMemCheck(u32 pc, u32 addr); | ||
|
||
u32 IRInterpret(MIPSState *ms, const IRInst *inst); | ||
|
||
template <uint32_t alignment> | ||
u32 RunValidateAddress(u32 pc, u32 addr, u32 isWrite) { | ||
const auto toss = [&](MemoryExceptionType t) { | ||
Core_MemoryException(addr, alignment, pc, t); | ||
return coreState != CORE_RUNNING ? 1 : 0; | ||
}; | ||
|
||
if (!Memory::IsValidRange(addr, alignment)) { | ||
MemoryExceptionType t = isWrite == 1 ? MemoryExceptionType::WRITE_WORD : MemoryExceptionType::READ_WORD; | ||
if constexpr (alignment > 4) | ||
t = isWrite ? MemoryExceptionType::WRITE_BLOCK : MemoryExceptionType::READ_BLOCK; | ||
return toss(t); | ||
} | ||
if constexpr (alignment > 1) | ||
if ((addr & (alignment - 1)) != 0) | ||
return toss(MemoryExceptionType::ALIGNMENT); | ||
return 0; | ||
} |