Merge branch 'master' into dev-loongarch64

This commit is contained in:
Wang Xiang authored and GitHub committed 2023-09-04 21:12:40 +08:00
commit 75cb0d3fe0
74 files changed
+4289 -252

No files matched your search

+11
View File
@@ -1608,6 +1608,17 @@ list(APPEND CoreExtra
Core/MIPS/ARM64/Arm64RegCache.h
Core/MIPS/ARM64/Arm64RegCacheFPU.cpp
Core/MIPS/ARM64/Arm64RegCacheFPU.h
Core/MIPS/ARM64/Arm64IRAsm.cpp
Core/MIPS/ARM64/Arm64IRCompALU.cpp
Core/MIPS/ARM64/Arm64IRCompBranch.cpp
Core/MIPS/ARM64/Arm64IRCompFPU.cpp
Core/MIPS/ARM64/Arm64IRCompLoadStore.cpp
Core/MIPS/ARM64/Arm64IRCompSystem.cpp
Core/MIPS/ARM64/Arm64IRCompVec.cpp
Core/MIPS/ARM64/Arm64IRJit.cpp
Core/MIPS/ARM64/Arm64IRJit.h
Core/MIPS/ARM64/Arm64IRRegCache.cpp
Core/MIPS/ARM64/Arm64IRRegCache.h
GPU/Common/VertexDecoderArm64.cpp
Core/Util/DisArm64.cpp
)
+1 -1
View File
@@ -514,7 +514,7 @@ void ARM64XEmitter::EncodeTestBranchInst(u32 op, ARM64Reg Rt, u8 bits, const voi
distance >>= 2;
_assert_msg_(distance >= -0x1FFF && distance < 0x1FFF, "%s: Received too large distance: %llx", __FUNCTION__, distance);
_assert_msg_(distance >= -0x2000 && distance <= 0x1FFF, "%s: Received too large distance: %llx", __FUNCTION__, distance);
Rt = DecodeReg(Rt);
Write32((b64Bit << 31) | (0x36 << 24) | (op << 24) | \
+17
View File
@@ -290,6 +290,23 @@ public:
}
m_shifttype = ST_LSL;
}
ArithOption(ARM64Reg Rd, bool index, bool signExtend) {
if (index)
m_shift = 4;
else
m_shift = 0;
m_destReg = Rd;
m_type = TYPE_EXTENDEDREG;
if (Is64Bit(Rd)) {
m_width = WIDTH_64BIT;
m_extend = EXTEND_UXTX;
} else {
m_width = WIDTH_32BIT;
m_extend = signExtend ? EXTEND_SXTW : EXTEND_UXTW;
}
m_shifttype = ST_LSL;
}
ArithOption(ARM64Reg Rd, ShiftType shift_type, u32 shift)
{
m_destReg = Rd;
+7
View File
@@ -39,6 +39,13 @@ float OnScreenDisplay::SidebarAlpha() const {
return saturatef(1.0f - ((float)timeSinceNudge - 0.1f) * 4.0f);
}
void OnScreenDisplay::DismissEntry(size_t index, double now) {
std::lock_guard<std::mutex> guard(mutex_);
if (index < entries_.size() && entries_[index].type != OSDType::ACHIEVEMENT_CHALLENGE_INDICATOR) {
entries_[index].endTime = std::min(now + FadeoutTime(), entries_[index].endTime);
}
}
void OnScreenDisplay::Show(OSDType type, const std::string &text, const std::string &text2, const std::string &icon, float duration_s, const char *id) {
// Automatic duration based on type.
if (duration_s <= 0.0f) {
+3
View File
@@ -87,6 +87,9 @@ public:
std::vector<Entry> Entries();
// TODO: Use something more stable than the index.
void DismissEntry(size_t index, double now);
static float FadeinTime() { return 0.1f; }
static float FadeoutTime() { return 0.25f; }
+12 -2
View File
@@ -48,6 +48,9 @@ void ScreenManager::update() {
switchToNext();
}
if (overlayScreen_) {
overlayScreen_->update();
}
if (stack_.size()) {
stack_.back().screen->update();
}
@@ -90,8 +93,15 @@ void ScreenManager::touch(const TouchInput &touch) {
layer.screen->UnsyncTouch(screen->transformTouch(touch));
}
} else if (!stack_.empty()) {
Screen *screen = stack_.back().screen;
stack_.back().screen->UnsyncTouch(screen->transformTouch(touch));
// Let the overlay know about touch-downs, to be able to dismiss popups.
bool skip = false;
if (overlayScreen_ && (touch.flags & TOUCH_DOWN)) {
skip = overlayScreen_->UnsyncTouch(overlayScreen_->transformTouch(touch));
}
if (!skip) {
Screen *screen = stack_.back().screen;
stack_.back().screen->UnsyncTouch(screen->transformTouch(touch));
}
}
}
+3 -1
View File
@@ -59,7 +59,9 @@ public:
virtual void deviceLost() {}
virtual void deviceRestored() {}
virtual void UnsyncTouch(const TouchInput &touch) = 0;
// Return value of UnsyncTouch is only used to let the overlay screen block touches.
virtual bool UnsyncTouch(const TouchInput &touch) = 0;
// Return value of UnsyncKey is used to not block certain system keys like volume when unhandled, on Android.
virtual bool UnsyncKey(const KeyInput &touch) = 0;
virtual void UnsyncAxis(const AxisInput &touch) = 0;
+2 -1
View File
@@ -81,7 +81,7 @@ bool UIScreen::key(const KeyInput &key) {
}
}
void UIScreen::UnsyncTouch(const TouchInput &touch) {
bool UIScreen::UnsyncTouch(const TouchInput &touch) {
if (ClickDebug && root_ && (touch.flags & TOUCH_DOWN)) {
INFO_LOG(SYSTEM, "Touch down!");
std::vector<UI::View *> views;
@@ -96,6 +96,7 @@ void UIScreen::UnsyncTouch(const TouchInput &touch) {
ev.type = QueuedEventType::TOUCH;
ev.touch = touch;
eventQueue_.push_back(ev);
return false;
}
void UIScreen::UnsyncAxis(const AxisInput &axis) {
+1 -1
View File
@@ -46,7 +46,7 @@ public:
virtual bool key(const KeyInput &key);
virtual void axis(const AxisInput &axis);
void UnsyncTouch(const TouchInput &touch) override;
bool UnsyncTouch(const TouchInput &touch) override;
bool UnsyncKey(const KeyInput &key) override;
void UnsyncAxis(const AxisInput &axis) override;
+11
View File
@@ -580,6 +580,15 @@
<ClCompile Include="KeyMap.cpp" />
<ClCompile Include="KeyMapDefaults.cpp" />
<ClCompile Include="MemFault.cpp" />
<ClCompile Include="MIPS\ARM64\Arm64IRAsm.cpp" />
<ClCompile Include="MIPS\ARM64\Arm64IRCompALU.cpp" />
<ClCompile Include="MIPS\ARM64\Arm64IRCompBranch.cpp" />
<ClCompile Include="MIPS\ARM64\Arm64IRCompFPU.cpp" />
<ClCompile Include="MIPS\ARM64\Arm64IRCompLoadStore.cpp" />
<ClCompile Include="MIPS\ARM64\Arm64IRCompSystem.cpp" />
<ClCompile Include="MIPS\ARM64\Arm64IRCompVec.cpp" />
<ClCompile Include="MIPS\ARM64\Arm64IRJit.cpp" />
<ClCompile Include="MIPS\ARM64\Arm64IRRegCache.cpp" />
<ClCompile Include="MIPS\fake\FakeJit.cpp" />
<ClCompile Include="MIPS\IR\IRAnalysis.cpp" />
<ClCompile Include="MIPS\IR\IRAsm.cpp" />
@@ -1175,6 +1184,8 @@
<ClInclude Include="KeyMap.h" />
<ClInclude Include="KeyMapDefaults.h" />
<ClInclude Include="MemFault.h" />
<ClInclude Include="MIPS\ARM64\Arm64IRJit.h" />
<ClInclude Include="MIPS\ARM64\Arm64IRRegCache.h" />
<ClInclude Include="MIPS\fake\FakeJit.h" />
<ClInclude Include="MIPS\IR\IRAnalysis.h" />
<ClInclude Include="MIPS\IR\IRFrontend.h" />
+33
View File
@@ -1270,6 +1270,33 @@
<ClCompile Include="MIPS\x86\X64IRCompALU.cpp">
<Filter>MIPS\x86</Filter>
</ClCompile>
<ClCompile Include="MIPS\ARM64\Arm64IRCompLoadStore.cpp">
<Filter>MIPS\ARM64</Filter>
</ClCompile>
<ClCompile Include="MIPS\ARM64\Arm64IRCompSystem.cpp">
<Filter>MIPS\ARM64</Filter>
</ClCompile>
<ClCompile Include="MIPS\ARM64\Arm64IRCompVec.cpp">
<Filter>MIPS\ARM64</Filter>
</ClCompile>
<ClCompile Include="MIPS\ARM64\Arm64IRJit.cpp">
<Filter>MIPS\ARM64</Filter>
</ClCompile>
<ClCompile Include="MIPS\ARM64\Arm64IRRegCache.cpp">
<Filter>MIPS\ARM64</Filter>
</ClCompile>
<ClCompile Include="MIPS\ARM64\Arm64IRAsm.cpp">
<Filter>MIPS\ARM64</Filter>
</ClCompile>
<ClCompile Include="MIPS\ARM64\Arm64IRCompALU.cpp">
<Filter>MIPS\ARM64</Filter>
</ClCompile>
<ClCompile Include="MIPS\ARM64\Arm64IRCompBranch.cpp">
<Filter>MIPS\ARM64</Filter>
</ClCompile>
<ClCompile Include="MIPS\ARM64\Arm64IRCompFPU.cpp">
<Filter>MIPS\ARM64</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ELF\ElfReader.h">
@@ -2037,6 +2064,12 @@
<ClInclude Include="MIPS\x86\X64IRJit.h">
<Filter>MIPS\x86</Filter>
</ClInclude>
<ClInclude Include="MIPS\ARM64\Arm64IRJit.h">
<Filter>MIPS\ARM64</Filter>
</ClInclude>
<ClInclude Include="MIPS\ARM64\Arm64IRRegCache.h">
<Filter>MIPS\ARM64</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\LICENSE.TXT" />
+1 -1
View File
@@ -311,7 +311,7 @@ BreakAction CBreakPoints::ExecBreakPoint(u32 addr) {
std::unique_lock<std::mutex> guard(breakPointsMutex_);
size_t bp = FindBreakpoint(addr, false);
if (bp != INVALID_BREAKPOINT) {
BreakPoint info = breakPoints_[bp];
const BreakPoint &info = breakPoints_[bp];
guard.unlock();
if (info.hasCond) {
+1 -1
View File
@@ -2375,7 +2375,7 @@ static u32 _sceAtracGetContextAddress(int atracID) {
if (!atrac->context_.IsValid()) {
// allocate a new context_
u32 contextsize = 256;
atrac->context_ = kernelMemory.Alloc(contextsize, false, "Atrac Context");
atrac->context_ = kernelMemory.Alloc(contextsize, false, StringFromFormat("AtracCtx/%d", atracID).c_str());
if (atrac->context_.IsValid())
Memory::Memset(atrac->context_.ptr, 0, 256, "AtracContextClear");
+2 -1
View File
@@ -19,6 +19,7 @@
#include "Common/Serialize/Serializer.h"
#include "Common/Serialize/SerializeFuncs.h"
#include "Common/Serialize/SerializeMap.h"
#include "Common/StringUtils.h"
#include "Core/MemMap.h"
#include "Core/Reporting.h"
#include "Core/HLE/HLE.h"
@@ -193,7 +194,7 @@ static int sceHeapCreateHeap(const char* name, u32 heapSize, int attr, u32 param
Heap *heap = new Heap;
heap->size = allocSize;
heap->fromtop = (attr & PSP_HEAP_ATTR_HIGHMEM) != 0;
u32 addr = userMemory.Alloc(heap->size, heap->fromtop, "Heap");
u32 addr = userMemory.Alloc(heap->size, heap->fromtop, StringFromFormat("Heap/%s", name).c_str());
if (addr == (u32)-1) {
ERROR_LOG(HLE, "sceHeapCreateHeap(): Failed to allocate %i bytes memory", allocSize);
delete heap;
+2 -1
View File
@@ -2,6 +2,7 @@
#include "Common/Serialize/Serializer.h"
#include "Common/Serialize/SerializeFuncs.h"
#include "Common/StringUtils.h"
#include "Core/HLE/HLE.h"
#include "Core/HLE/FunctionWrappers.h"
#include "Core/HLE/sceKernel.h"
@@ -52,7 +53,7 @@ static int sceKernelCreateHeap(int partitionId, int size, int flags, const char
return hleLogError(SCEKERNEL, SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT, "invalid partition");
// TODO: This should probably actually use flags? Name?
u32 addr = allocator->Alloc(allocSize, g_fromBottom, "SysMemForKernel-Heap");
u32 addr = allocator->Alloc(allocSize, g_fromBottom, StringFromFormat("KernelHeap/%s", Name).c_str());
if (addr == (u32)-1) {
// TODO: Validate error code.
return hleLogError(SCEKERNEL, SCE_KERNEL_ERROR_NO_MEMORY, "fFailed to allocate %d bytes of memory", size);
+3 -3
View File
@@ -678,7 +678,7 @@ int sceKernelCreateFpl(const char *name, u32 mpid, u32 attr, u32 blockSize, u32
int alignedSize = ((int)blockSize + alignment - 1) & ~(alignment - 1);
u32 totalSize = alignedSize * numBlocks;
bool atEnd = (attr & PSP_FPL_ATTR_HIGHMEM) != 0;
u32 address = allocator->Alloc(totalSize, atEnd, "FPL");
u32 address = allocator->Alloc(totalSize, atEnd, StringFromFormat("FPL/%s", name).c_str());
if (address == (u32)-1) {
DEBUG_LOG(SCEKERNEL, "sceKernelCreateFpl(\"%s\", partition=%i, attr=%08x, bsize=%i, nb=%i) FAILED - out of ram",
name, mpid, attr, blockSize, numBlocks);
@@ -1521,7 +1521,7 @@ SceUID sceKernelCreateVpl(const char *name, int partition, u32 attr, u32 vplSize
// We ignore the upalign to 256 and do it ourselves by 8.
u32 allocSize = vplSize;
u32 memBlockPtr = allocator->Alloc(allocSize, (attr & PSP_VPL_ATTR_HIGHMEM) != 0, "VPL");
u32 memBlockPtr = allocator->Alloc(allocSize, (attr & PSP_VPL_ATTR_HIGHMEM) != 0, StringFromFormat("VPL/%s", name).c_str());
if (memBlockPtr == (u32)-1)
return hleLogError(SCEKERNEL, SCE_KERNEL_ERROR_NO_MEMORY, "failed to allocate %i bytes of pool data", vplSize);
@@ -2124,7 +2124,7 @@ SceUID sceKernelCreateTlspl(const char *name, u32 partition, u32 attr, u32 block
u32 alignedSize = (blockSize + alignment - 1) & ~(alignment - 1);
u32 totalSize = alignedSize * count;
u32 blockPtr = allocator->Alloc(totalSize, (attr & PSP_TLSPL_ATTR_HIGHMEM) != 0, name);
u32 blockPtr = allocator->Alloc(totalSize, (attr & PSP_TLSPL_ATTR_HIGHMEM) != 0, StringFromFormat("TLS/%s", name).c_str());
#ifdef _DEBUG
allocator->ListBlocks();
#endif
+1 -1
View File
@@ -687,7 +687,7 @@ int sceKernelCreateMsgPipe(const char *name, int partition, u32 attr, u32 size,
if (size != 0) {
// We ignore the upalign to 256.
u32 allocSize = size;
memBlockPtr = allocator->Alloc(allocSize, (attr & SCE_KERNEL_MPA_HIGHMEM) != 0, "MsgPipe");
memBlockPtr = allocator->Alloc(allocSize, (attr & SCE_KERNEL_MPA_HIGHMEM) != 0, StringFromFormat("MsgPipe/%s", name).c_str());
if (memBlockPtr == (u32)-1)
return hleLogError(SCEKERNEL, SCE_KERNEL_ERROR_NO_MEMORY, "failed to allocate %i bytes for buffer", size);
}
+10 -15
View File
@@ -401,15 +401,7 @@ public:
FreeStack();
bool fromTop = (nt.attr & PSP_THREAD_ATTR_LOW_STACK) == 0;
if (nt.attr & PSP_THREAD_ATTR_KERNEL)
{
// Allocate stacks for kernel threads (idle) in kernel RAM
currentStack.start = kernelMemory.Alloc(stackSize, fromTop, (std::string("stack/") + nt.name).c_str());
}
else
{
currentStack.start = userMemory.Alloc(stackSize, fromTop, (std::string("stack/") + nt.name).c_str());
}
currentStack.start = StackAllocator().Alloc(stackSize, fromTop, StringFromFormat("stack/%s", nt.name).c_str());
if (currentStack.start == (u32)-1)
{
currentStack.start = 0;
@@ -453,18 +445,14 @@ public:
Memory::Memset(nt.initialStack, 0, nt.stackSize, "ThreadFreeStack");
}
if (nt.attr & PSP_THREAD_ATTR_KERNEL) {
kernelMemory.Free(currentStack.start);
} else {
userMemory.Free(currentStack.start);
}
StackAllocator().Free(currentStack.start);
currentStack.start = 0;
}
}
bool PushExtendedStack(u32 size)
{
u32 stack = userMemory.Alloc(size, true, (std::string("extended/") + nt.name).c_str());
u32 stack = userMemory.Alloc(size, true, StringFromFormat("extended/%s", nt.name).c_str());
if (stack == (u32)-1)
return false;
@@ -509,6 +497,13 @@ public:
FreeStack();
}
BlockAllocator &StackAllocator() {
if (nt.attr & PSP_THREAD_ATTR_KERNEL) {
return kernelMemory;
}
return userMemory;
}
void setReturnValue(u32 retval);
void setReturnValue(u64 retval);
void resumeFromWait();
+274
View File
@@ -0,0 +1,274 @@
// Copyright (c) 2023- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "ppsspp_config.h"
// In other words, PPSSPP_ARCH(ARM64) || DISASM_ALL.
#if PPSSPP_ARCH(ARM64) || (PPSSPP_PLATFORM(WINDOWS) && !defined(__LIBRETRO__))
#include "Common/Log.h"
#include "Core/CoreTiming.h"
#include "Core/MemMap.h"
#include "Core/MIPS/ARM64/Arm64IRJit.h"
#include "Core/MIPS/ARM64/Arm64IRRegCache.h"
#include "Core/MIPS/JitCommon/JitCommon.h"
#include "Core/MIPS/JitCommon/JitState.h"
#include "Core/System.h"
namespace MIPSComp {
using namespace Arm64Gen;
using namespace Arm64IRJitConstants;
static const bool enableDebug = false;
static const bool enableDisasm = false;
static void ShowPC(void *membase, void *jitbase) {
static int count = 0;
if (currentMIPS) {
u32 downcount = currentMIPS->downcount;
ERROR_LOG(JIT, "[%08x] ShowPC Downcount : %08x %d %p %p", currentMIPS->pc, downcount, count, membase, jitbase);
} else {
ERROR_LOG(JIT, "Universe corrupt?");
}
//if (count > 2000)
// exit(0);
count++;
}
void Arm64JitBackend::GenerateFixedCode(MIPSState *mipsState) {
BeginWrite(GetMemoryProtectPageSize());
const u8 *start = AlignCodePage();
if (jo.useStaticAlloc) {
saveStaticRegisters_ = AlignCode16();
STR(INDEX_UNSIGNED, DOWNCOUNTREG, CTXREG, offsetof(MIPSState, downcount));
regs_.EmitSaveStaticRegisters();
RET();
loadStaticRegisters_ = AlignCode16();
regs_.EmitLoadStaticRegisters();
LDR(INDEX_UNSIGNED, DOWNCOUNTREG, CTXREG, offsetof(MIPSState, downcount));
RET();
start = saveStaticRegisters_;
} else {
saveStaticRegisters_ = nullptr;
loadStaticRegisters_ = nullptr;
}
restoreRoundingMode_ = AlignCode16();
{
MRS(SCRATCH2_64, FIELD_FPCR);
// We are not in flush-to-zero mode outside the JIT, so let's turn it off.
uint32_t mask = ~(4 << 22);
// Assume we're always in round-to-nearest mode beforehand.
mask &= ~(3 << 22);
ANDI2R(SCRATCH2, SCRATCH2, mask);
_MSR(FIELD_FPCR, SCRATCH2_64);
RET();
}
applyRoundingMode_ = AlignCode16();
{
LDR(INDEX_UNSIGNED, SCRATCH1, CTXREG, offsetof(MIPSState, fcr31));
ANDI2R(SCRATCH2, SCRATCH1, 3);
FixupBranch skip1 = TBZ(SCRATCH1, 24);
ADDI2R(SCRATCH2, SCRATCH2, 4);
SetJumpTarget(skip1);
// We can skip if the rounding mode is nearest (0) and flush is not set.
// (as restoreRoundingMode cleared it out anyway)
FixupBranch skip = CBZ(SCRATCH2);
// MIPS Rounding Mode: ARM Rounding Mode
// 0: Round nearest 0
// 1: Round to zero 3
// 2: Round up (ceil) 1
// 3: Round down (floor) 2
ANDI2R(SCRATCH1, SCRATCH2, 3);
CMPI2R(SCRATCH1, 1);
FixupBranch skipadd = B(CC_NEQ);
ADDI2R(SCRATCH2, SCRATCH2, 2);
SetJumpTarget(skipadd);
FixupBranch skipsub = B(CC_LE);
SUBI2R(SCRATCH2, SCRATCH2, 1);
SetJumpTarget(skipsub);
// Actually change the system FPCR register
MRS(SCRATCH1_64, FIELD_FPCR);
// Clear both flush-to-zero and rounding before re-setting them.
ANDI2R(SCRATCH1, SCRATCH1, ~((4 | 3) << 22));
ORR(SCRATCH1, SCRATCH1, SCRATCH2, ArithOption(SCRATCH2, ST_LSL, 22));
_MSR(FIELD_FPCR, SCRATCH1_64);
SetJumpTarget(skip);
RET();
}
updateRoundingMode_ = AlignCode16();
{
LDR(INDEX_UNSIGNED, SCRATCH1, CTXREG, offsetof(MIPSState, fcr31));
// Set SCRATCH2 to FZ:RM (FZ is bit 24, and RM are lowest 2 bits.)
ANDI2R(SCRATCH2, SCRATCH1, 3);
FixupBranch skip = TBZ(SCRATCH1, 24);
ADDI2R(SCRATCH2, SCRATCH2, 4);
SetJumpTarget(skip);
// Update currentRoundingFunc_ with the right convertS0ToSCRATCH1_ func.
MOVP2R(SCRATCH1_64, convertS0ToSCRATCH1_);
LSL(SCRATCH2, SCRATCH2, 3);
LDR(SCRATCH2_64, SCRATCH1_64, SCRATCH2);
MOVP2R(SCRATCH1_64, &currentRoundingFunc_);
STR(INDEX_UNSIGNED, SCRATCH2_64, SCRATCH1_64, 0);
RET();
}
hooks_.enterDispatcher = (IRNativeFuncNoArg)AlignCode16();
uint32_t regs_to_save = Arm64Gen::ALL_CALLEE_SAVED;
uint32_t regs_to_save_fp = Arm64Gen::ALL_CALLEE_SAVED_FP;
fp_.ABI_PushRegisters(regs_to_save, regs_to_save_fp);
// Fixed registers, these are always kept when in Jit context.
MOVP2R(MEMBASEREG, Memory::base);
MOVP2R(CTXREG, mipsState);
// Pre-subtract this to save time later.
MOVI2R(JITBASEREG, (intptr_t)GetBasePtr() - MIPS_EMUHACK_OPCODE);
LoadStaticRegisters();
MovFromPC(SCRATCH1);
outerLoopPCInSCRATCH1_ = GetCodePtr();
MovToPC(SCRATCH1);
outerLoop_ = GetCodePtr();
SaveStaticRegisters(); // Advance can change the downcount, so must save/restore
RestoreRoundingMode(true);
QuickCallFunction(SCRATCH1_64, &CoreTiming::Advance);
ApplyRoundingMode(true);
LoadStaticRegisters();
dispatcherCheckCoreState_ = GetCodePtr();
MOVP2R(SCRATCH1_64, &coreState);
LDR(INDEX_UNSIGNED, SCRATCH1, SCRATCH1_64, 0);
FixupBranch badCoreState = CBNZ(SCRATCH1);
// Check downcount.
TBNZ(DOWNCOUNTREG, 31, outerLoop_);
FixupBranch skipToRealDispatch = B();
dispatcherPCInSCRATCH1_ = GetCodePtr();
MovToPC(SCRATCH1);
hooks_.dispatcher = GetCodePtr();
FixupBranch bail = TBNZ(DOWNCOUNTREG, 31);
SetJumpTarget(skipToRealDispatch);
dispatcherNoCheck_ = GetCodePtr();
// Debug
if (enableDebug) {
MOV(W0, DOWNCOUNTREG);
MOV(X1, MEMBASEREG);
MOV(X2, JITBASEREG);
QuickCallFunction(SCRATCH1_64, &ShowPC);
}
MovFromPC(SCRATCH1);
#ifdef MASKED_PSP_MEMORY
ANDI2R(SCRATCH1, SCRATCH1, Memory::MEMVIEW32_MASK);
#endif
hooks_.dispatchFetch = GetCodePtr();
LDR(SCRATCH1, MEMBASEREG, SCRATCH1_64);
LSR(SCRATCH2, SCRATCH1, 24); // or UBFX(SCRATCH2, SCRATCH1, 24, 8)
// We don't mask SCRATCH1 as that's already baked into JITBASEREG.
CMP(SCRATCH2, MIPS_EMUHACK_OPCODE >> 24);
FixupBranch skipJump = B(CC_NEQ);
ADD(SCRATCH1_64, JITBASEREG, SCRATCH1_64);
BR(SCRATCH1_64);
SetJumpTarget(skipJump);
// No block found, let's jit. We don't need to save static regs, they're all callee saved.
RestoreRoundingMode(true);
QuickCallFunction(SCRATCH1_64, &MIPSComp::JitAt);
ApplyRoundingMode(true);
// Let's just dispatch again, we'll enter the block since we know it's there.
B(dispatcherNoCheck_);
SetJumpTarget(bail);
MOVP2R(SCRATCH1_64, &coreState);
LDR(INDEX_UNSIGNED, SCRATCH1, SCRATCH1_64, 0);
CBZ(SCRATCH1, outerLoop_);
const uint8_t *quitLoop = GetCodePtr();
SetJumpTarget(badCoreState);
SaveStaticRegisters();
RestoreRoundingMode(true);
fp_.ABI_PopRegisters(regs_to_save, regs_to_save_fp);
RET();
hooks_.crashHandler = GetCodePtr();
MOVP2R(SCRATCH1_64, &coreState);
MOVI2R(SCRATCH2, CORE_RUNTIME_ERROR);
STR(INDEX_UNSIGNED, SCRATCH2, SCRATCH1_64, 0);
B(quitLoop);
// Generate some integer conversion funcs.
// MIPS order!
static const RoundingMode roundModes[8] = { ROUND_N, ROUND_Z, ROUND_P, ROUND_M, ROUND_N, ROUND_Z, ROUND_P, ROUND_M };
for (size_t i = 0; i < ARRAY_SIZE(roundModes); ++i) {
convertS0ToSCRATCH1_[i] = AlignCode16();
fp_.FCMP(S0, S0); // Detect NaN
fp_.FCVTS(S0, S0, roundModes[i]);
FixupBranch skip = B(CC_VC);
MOVI2R(SCRATCH2, 0x7FFFFFFF);
fp_.FMOV(S0, SCRATCH2);
SetJumpTarget(skip);
RET();
}
// Leave this at the end, add more stuff above.
if (enableDisasm) {
std::vector<std::string> lines = DisassembleArm64(start, (int)(GetCodePtr() - start));
for (auto s : lines) {
INFO_LOG(JIT, "%s", s.c_str());
}
}
// Let's spare the pre-generated code from unprotect-reprotect.
AlignCodePage();
jitStartOffset_ = (int)(GetCodePtr() - start);
// Don't forget to zap the instruction cache! This must stay at the end of this function.
FlushIcache();
EndWrite();
// Update our current cached rounding mode func, too.
UpdateFCR31(mipsState);
}
} // namespace MIPSComp
#endif
+455
View File
@@ -0,0 +1,455 @@
// Copyright (c) 2023- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "ppsspp_config.h"
// In other words, PPSSPP_ARCH(ARM64) || DISASM_ALL.
#if PPSSPP_ARCH(ARM64) || (PPSSPP_PLATFORM(WINDOWS) && !defined(__LIBRETRO__))
#include "Common/CPUDetect.h"
#include "Core/MemMap.h"
#include "Core/MIPS/ARM64/Arm64IRJit.h"
#include "Core/MIPS/ARM64/Arm64IRRegCache.h"
// This file contains compilation for integer / arithmetic / logic related instructions.
//
// All functions should have CONDITIONAL_DISABLE, so we can narrow things down to a file quickly.
// Currently known non working ones should have DISABLE. No flags because that's in IR already.
// #define CONDITIONAL_DISABLE { CompIR_Generic(inst); return; }
#define CONDITIONAL_DISABLE {}
#define DISABLE { CompIR_Generic(inst); return; }
#define INVALIDOP { _assert_msg_(false, "Invalid IR inst %d", (int)inst.op); CompIR_Generic(inst); return; }
namespace MIPSComp {
using namespace Arm64Gen;
using namespace Arm64IRJitConstants;
void Arm64JitBackend::CompIR_Arith(IRInst inst) {
CONDITIONAL_DISABLE;
bool allowPtrMath = inst.constant <= 0x7FFFFFFF;
#ifdef MASKED_PSP_MEMORY
// Since we modify it, we can't safely.
allowPtrMath = false;
#endif
switch (inst.op) {
case IROp::Add:
regs_.Map(inst);
ADD(regs_.R(inst.dest), regs_.R(inst.src1), regs_.R(inst.src2));
break;
case IROp::Sub:
regs_.Map(inst);
SUB(regs_.R(inst.dest), regs_.R(inst.src1), regs_.R(inst.src2));
break;
case IROp::AddConst:
if (regs_.IsGPRMappedAsPointer(inst.dest) && inst.dest == inst.src1 && allowPtrMath) {
regs_.MarkGPRAsPointerDirty(inst.dest);
ADDI2R(regs_.RPtr(inst.dest), regs_.RPtr(inst.src1), (int)inst.constant, SCRATCH1_64);
} else {
regs_.Map(inst);
ADDI2R(regs_.R(inst.dest), regs_.R(inst.src1), inst.constant, SCRATCH1);
}
break;
case IROp::SubConst:
if (regs_.IsGPRMappedAsPointer(inst.dest) && inst.dest == inst.src1 && allowPtrMath) {
regs_.MarkGPRAsPointerDirty(inst.dest);
SUBI2R(regs_.RPtr(inst.dest), regs_.RPtr(inst.src1), (int)inst.constant, SCRATCH1_64);
} else {
regs_.Map(inst);
SUBI2R(regs_.R(inst.dest), regs_.R(inst.src1), inst.constant, SCRATCH1);
}
break;
case IROp::Neg:
regs_.Map(inst);
NEG(regs_.R(inst.dest), regs_.R(inst.src1));
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_Assign(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::Mov:
if (inst.dest != inst.src1) {
regs_.Map(inst);
MOV(regs_.R(inst.dest), regs_.R(inst.src1));
}
break;
case IROp::Ext8to32:
regs_.Map(inst);
SXTB(regs_.R(inst.dest), regs_.R(inst.src1));
break;
case IROp::Ext16to32:
regs_.Map(inst);
SXTH(regs_.R(inst.dest), regs_.R(inst.src1));
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_Bits(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::BSwap16:
regs_.Map(inst);
REV16(regs_.R(inst.dest), regs_.R(inst.src1));
break;
case IROp::BSwap32:
regs_.Map(inst);
REV32(regs_.R(inst.dest), regs_.R(inst.src1));
break;
case IROp::Clz:
regs_.Map(inst);
CLZ(regs_.R(inst.dest), regs_.R(inst.src1));
break;
case IROp::ReverseBits:
regs_.Map(inst);
RBIT(regs_.R(inst.dest), regs_.R(inst.src1));
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_Compare(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::Slt:
regs_.Map(inst);
CMP(regs_.R(inst.src1), regs_.R(inst.src2));
CSET(regs_.R(inst.dest), CC_LT);
break;
case IROp::SltConst:
if (inst.constant == 0) {
// Basically, getting the sign bit.
regs_.Map(inst);
UBFX(regs_.R(inst.dest), regs_.R(inst.src1), 31, 1);
} else {
regs_.Map(inst);
CMPI2R(regs_.R(inst.src1), (int32_t)inst.constant, SCRATCH1);
CSET(regs_.R(inst.dest), CC_LT);
}
break;
case IROp::SltU:
regs_.Map(inst);
CMP(regs_.R(inst.src1), regs_.R(inst.src2));
CSET(regs_.R(inst.dest), CC_LO);
break;
case IROp::SltUConst:
if (inst.constant == 0) {
regs_.SetGPRImm(inst.dest, 0);
} else {
regs_.Map(inst);
CMPI2R(regs_.R(inst.src1), (int32_t)inst.constant, SCRATCH1);
CSET(regs_.R(inst.dest), CC_LO);
}
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_CondAssign(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::MovZ:
if (inst.dest != inst.src2) {
regs_.Map(inst);
CMP(regs_.R(inst.src1), 0);
CSEL(regs_.R(inst.dest), regs_.R(inst.src2), regs_.R(inst.dest), CC_EQ);
}
break;
case IROp::MovNZ:
if (inst.dest != inst.src2) {
regs_.Map(inst);
CMP(regs_.R(inst.src1), 0);
CSEL(regs_.R(inst.dest), regs_.R(inst.src2), regs_.R(inst.dest), CC_NEQ);
}
break;
case IROp::Max:
if (inst.src1 != inst.src2) {
regs_.Map(inst);
CMP(regs_.R(inst.src1), regs_.R(inst.src2));
CSEL(regs_.R(inst.dest), regs_.R(inst.src1), regs_.R(inst.src2), CC_GE);
} else if (inst.dest != inst.src1) {
regs_.Map(inst);
MOV(regs_.R(inst.dest), regs_.R(inst.src1));
}
break;
case IROp::Min:
if (inst.src1 != inst.src2) {
regs_.Map(inst);
CMP(regs_.R(inst.src1), regs_.R(inst.src2));
CSEL(regs_.R(inst.dest), regs_.R(inst.src1), regs_.R(inst.src2), CC_LE);
} else if (inst.dest != inst.src1) {
regs_.Map(inst);
MOV(regs_.R(inst.dest), regs_.R(inst.src1));
}
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_Div(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::Div:
case IROp::DivU:
CompIR_Generic(inst);
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_HiLo(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::MtLo:
regs_.MapWithExtra(inst, { { 'G', IRREG_LO, 2, MIPSMap::DIRTY } });
BFI(regs_.R64(IRREG_LO), regs_.R64(inst.src1), 0, 32);
break;
case IROp::MtHi:
regs_.MapWithExtra(inst, { { 'G', IRREG_LO, 2, MIPSMap::DIRTY } });
BFI(regs_.R64(IRREG_LO), regs_.R64(inst.src1), 32, 32);
break;
case IROp::MfLo:
regs_.MapWithExtra(inst, { { 'G', IRREG_LO, 2, MIPSMap::INIT } });
MOV(regs_.R(inst.dest), regs_.R(IRREG_LO));
break;
case IROp::MfHi:
regs_.MapWithExtra(inst, { { 'G', IRREG_LO, 2, MIPSMap::INIT } });
UBFX(regs_.R64(inst.dest), regs_.R64(IRREG_LO), 32, 32);
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_Logic(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::And:
if (inst.src1 != inst.src2) {
regs_.Map(inst);
AND(regs_.R(inst.dest), regs_.R(inst.src1), regs_.R(inst.src2));
} else if (inst.src1 != inst.dest) {
regs_.Map(inst);
MOV(regs_.R(inst.dest), regs_.R(inst.src1));
}
break;
case IROp::Or:
if (inst.src1 != inst.src2) {
regs_.Map(inst);
ORR(regs_.R(inst.dest), regs_.R(inst.src1), regs_.R(inst.src2));
} else if (inst.src1 != inst.dest) {
regs_.Map(inst);
MOV(regs_.R(inst.dest), regs_.R(inst.src1));
}
break;
case IROp::Xor:
if (inst.src1 == inst.src2) {
regs_.SetGPRImm(inst.dest, 0);
} else {
regs_.Map(inst);
EOR(regs_.R(inst.dest), regs_.R(inst.src1), regs_.R(inst.src2));
}
break;
case IROp::AndConst:
regs_.Map(inst);
ANDI2R(regs_.R(inst.dest), regs_.R(inst.src1), inst.constant, SCRATCH1);
break;
case IROp::OrConst:
regs_.Map(inst);
ORRI2R(regs_.R(inst.dest), regs_.R(inst.src1), inst.constant, SCRATCH1);
break;
case IROp::XorConst:
regs_.Map(inst);
EORI2R(regs_.R(inst.dest), regs_.R(inst.src1), inst.constant, SCRATCH1);
break;
case IROp::Not:
regs_.Map(inst);
MVN(regs_.R(inst.dest), regs_.R(inst.src1));
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_Mult(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::Mult:
case IROp::MultU:
case IROp::Madd:
case IROp::MaddU:
case IROp::Msub:
case IROp::MsubU:
CompIR_Generic(inst);
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_Shift(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::Shl:
regs_.Map(inst);
LSLV(regs_.R(inst.dest), regs_.R(inst.src1), regs_.R(inst.src2));
break;
case IROp::Shr:
regs_.Map(inst);
LSRV(regs_.R(inst.dest), regs_.R(inst.src1), regs_.R(inst.src2));
break;
case IROp::Sar:
regs_.Map(inst);
ASRV(regs_.R(inst.dest), regs_.R(inst.src1), regs_.R(inst.src2));
break;
case IROp::Ror:
regs_.Map(inst);
RORV(regs_.R(inst.dest), regs_.R(inst.src1), regs_.R(inst.src2));
break;
case IROp::ShlImm:
// Shouldn't happen, but let's be safe of any passes that modify the ops.
if (inst.src2 >= 32) {
regs_.SetGPRImm(inst.dest, 0);
} else if (inst.src2 == 0) {
if (inst.dest != inst.src1) {
regs_.Map(inst);
MOV(regs_.R(inst.dest), regs_.R(inst.src1));
}
} else {
regs_.Map(inst);
MOV(regs_.R(inst.dest), regs_.R(inst.src1), ArithOption(regs_.R(inst.src1), ST_LSL, inst.src2));
}
break;
case IROp::ShrImm:
// Shouldn't happen, but let's be safe of any passes that modify the ops.
if (inst.src2 >= 32) {
regs_.SetGPRImm(inst.dest, 0);
} else if (inst.src2 == 0) {
if (inst.dest != inst.src1) {
regs_.Map(inst);
MOV(regs_.R(inst.dest), regs_.R(inst.src1));
}
} else {
regs_.Map(inst);
MOV(regs_.R(inst.dest), regs_.R(inst.src1), ArithOption(regs_.R(inst.src1), ST_LSR, inst.src2));
}
break;
case IROp::SarImm:
// Shouldn't happen, but let's be safe of any passes that modify the ops.
if (inst.src2 >= 32) {
regs_.Map(inst);
MOV(regs_.R(inst.dest), regs_.R(inst.src1), ArithOption(regs_.R(inst.src1), ST_ASR, 31));
} else if (inst.src2 == 0) {
if (inst.dest != inst.src1) {
regs_.Map(inst);
MOV(regs_.R(inst.dest), regs_.R(inst.src1));
}
} else {
regs_.Map(inst);
MOV(regs_.R(inst.dest), regs_.R(inst.src1), ArithOption(regs_.R(inst.src1), ST_ASR, inst.src2));
}
break;
case IROp::RorImm:
if (inst.src2 == 0) {
if (inst.dest != inst.src1) {
regs_.Map(inst);
MOV(regs_.R(inst.dest), regs_.R(inst.src1));
}
} else {
regs_.Map(inst);
MOV(regs_.R(inst.dest), regs_.R(inst.src1), ArithOption(regs_.R(inst.src1), ST_ROR, inst.src2 & 31));
}
break;
default:
INVALIDOP;
break;
}
}
} // namespace MIPSComp
#endif
+166
View File
@@ -0,0 +1,166 @@
// Copyright (c) 2023- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "ppsspp_config.h"
// In other words, PPSSPP_ARCH(ARM64) || DISASM_ALL.
#if PPSSPP_ARCH(ARM64) || (PPSSPP_PLATFORM(WINDOWS) && !defined(__LIBRETRO__))
#include "Core/MIPS/ARM64/Arm64IRJit.h"
#include "Core/MIPS/ARM64/Arm64IRRegCache.h"
// This file contains compilation for exits.
//
// All functions should have CONDITIONAL_DISABLE, so we can narrow things down to a file quickly.
// Currently known non working ones should have DISABLE. No flags because that's in IR already.
// #define CONDITIONAL_DISABLE { CompIR_Generic(inst); return; }
#define CONDITIONAL_DISABLE {}
#define DISABLE { CompIR_Generic(inst); return; }
#define INVALIDOP { _assert_msg_(false, "Invalid IR inst %d", (int)inst.op); CompIR_Generic(inst); return; }
namespace MIPSComp {
using namespace Arm64Gen;
using namespace Arm64IRJitConstants;
void Arm64JitBackend::CompIR_Exit(IRInst inst) {
CONDITIONAL_DISABLE;
ARM64Reg exitReg = INVALID_REG;
switch (inst.op) {
case IROp::ExitToConst:
FlushAll();
WriteConstExit(inst.constant);
break;
case IROp::ExitToReg:
exitReg = regs_.MapGPR(inst.src1);
FlushAll();
MOV(SCRATCH1, exitReg);
B(dispatcherPCInSCRATCH1_);
break;
case IROp::ExitToPC:
FlushAll();
B(dispatcherCheckCoreState_);
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_ExitIf(IRInst inst) {
CONDITIONAL_DISABLE;
ARM64Reg lhs = INVALID_REG;
ARM64Reg rhs = INVALID_REG;
FixupBranch fixup;
switch (inst.op) {
case IROp::ExitToConstIfEq:
case IROp::ExitToConstIfNeq:
if (regs_.IsGPRImm(inst.src1) && regs_.GetGPRImm(inst.src1) == 0) {
lhs = regs_.MapGPR(inst.src2);
FlushAll();
if (inst.op == IROp::ExitToConstIfEq)
fixup = CBNZ(lhs);
else if (inst.op == IROp::ExitToConstIfNeq)
fixup = CBZ(lhs);
else
_assert_(false);
} else if (regs_.IsGPRImm(inst.src2) && regs_.GetGPRImm(inst.src2) == 0) {
lhs = regs_.MapGPR(inst.src1);
FlushAll();
if (inst.op == IROp::ExitToConstIfEq)
fixup = CBNZ(lhs);
else if (inst.op == IROp::ExitToConstIfNeq)
fixup = CBZ(lhs);
else
_assert_(false);
} else {
regs_.Map(inst);
lhs = regs_.R(inst.src1);
rhs = regs_.R(inst.src2);
FlushAll();
CMP(lhs, rhs);
if (inst.op == IROp::ExitToConstIfEq)
fixup = B(CC_NEQ);
else if (inst.op == IROp::ExitToConstIfNeq)
fixup = B(CC_EQ);
else
_assert_(false);
}
WriteConstExit(inst.constant);
SetJumpTarget(fixup);
break;
case IROp::ExitToConstIfGtZ:
lhs = regs_.MapGPR(inst.src1);
FlushAll();
CMP(lhs, 0);
fixup = B(CC_LE);
WriteConstExit(inst.constant);
SetJumpTarget(fixup);
break;
case IROp::ExitToConstIfGeZ:
// In other words, exit if sign bit is 0.
lhs = regs_.MapGPR(inst.src1);
FlushAll();
fixup = TBNZ(lhs, 31);
WriteConstExit(inst.constant);
SetJumpTarget(fixup);
break;
case IROp::ExitToConstIfLtZ:
// In other words, exit if sign bit is 1.
lhs = regs_.MapGPR(inst.src1);
FlushAll();
fixup = TBZ(lhs, 31);
WriteConstExit(inst.constant);
SetJumpTarget(fixup);
break;
case IROp::ExitToConstIfLeZ:
lhs = regs_.MapGPR(inst.src1);
FlushAll();
CMP(lhs, 0);
fixup = B(CC_GT);
WriteConstExit(inst.constant);
SetJumpTarget(fixup);
break;
case IROp::ExitToConstIfFpTrue:
case IROp::ExitToConstIfFpFalse:
// Note: not used.
DISABLE;
break;
default:
INVALIDOP;
break;
}
}
} // namespace MIPSComp
#endif
+249
View File
@@ -0,0 +1,249 @@
// Copyright (c) 2023- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "ppsspp_config.h"
// In other words, PPSSPP_ARCH(ARM64) || DISASM_ALL.
#if PPSSPP_ARCH(ARM64) || (PPSSPP_PLATFORM(WINDOWS) && !defined(__LIBRETRO__))
#ifndef offsetof
#include <cstddef>
#endif
#include "Core/MIPS/ARM64/Arm64IRJit.h"
#include "Core/MIPS/ARM64/Arm64IRRegCache.h"
// This file contains compilation for floating point related instructions.
//
// All functions should have CONDITIONAL_DISABLE, so we can narrow things down to a file quickly.
// Currently known non working ones should have DISABLE. No flags because that's in IR already.
// #define CONDITIONAL_DISABLE { CompIR_Generic(inst); return; }
#define CONDITIONAL_DISABLE {}
#define DISABLE { CompIR_Generic(inst); return; }
#define INVALIDOP { _assert_msg_(false, "Invalid IR inst %d", (int)inst.op); CompIR_Generic(inst); return; }
namespace MIPSComp {
using namespace Arm64Gen;
using namespace Arm64IRJitConstants;
void Arm64JitBackend::CompIR_FArith(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::FAdd:
regs_.Map(inst);
fp_.FADD(regs_.F(inst.dest), regs_.F(inst.src1), regs_.F(inst.src2));
break;
case IROp::FSub:
regs_.Map(inst);
fp_.FSUB(regs_.F(inst.dest), regs_.F(inst.src1), regs_.F(inst.src2));
break;
case IROp::FMul:
regs_.Map(inst);
fp_.FMUL(regs_.F(inst.dest), regs_.F(inst.src1), regs_.F(inst.src2));
break;
case IROp::FDiv:
regs_.Map(inst);
fp_.FDIV(regs_.F(inst.dest), regs_.F(inst.src1), regs_.F(inst.src2));
break;
case IROp::FSqrt:
regs_.Map(inst);
fp_.FSQRT(regs_.F(inst.dest), regs_.F(inst.src1));
break;
case IROp::FNeg:
regs_.Map(inst);
fp_.FNEG(regs_.F(inst.dest), regs_.F(inst.src1));
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_FAssign(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::FMov:
if (inst.dest != inst.src1) {
regs_.Map(inst);
fp_.FMOV(regs_.F(inst.dest), regs_.F(inst.src1));
}
break;
case IROp::FAbs:
regs_.Map(inst);
fp_.FABS(regs_.F(inst.dest), regs_.F(inst.src1));
break;
case IROp::FSign:
CompIR_Generic(inst);
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_FCompare(IRInst inst) {
CONDITIONAL_DISABLE;
constexpr IRReg IRREG_VFPU_CC = IRREG_VFPU_CTRL_BASE + VFPU_CTRL_CC;
switch (inst.op) {
case IROp::FCmp:
switch (inst.dest) {
case IRFpCompareMode::False:
case IRFpCompareMode::EitherUnordered:
case IRFpCompareMode::EqualOrdered:
case IRFpCompareMode::EqualUnordered:
case IRFpCompareMode::LessEqualOrdered:
case IRFpCompareMode::LessEqualUnordered:
case IRFpCompareMode::LessOrdered:
case IRFpCompareMode::LessUnordered:
CompIR_Generic(inst);
break;
}
break;
case IROp::FCmovVfpuCC:
case IROp::FCmpVfpuBit:
case IROp::FCmpVfpuAggregate:
CompIR_Generic(inst);
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_FCondAssign(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::FMin:
case IROp::FMax:
CompIR_Generic(inst);
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_FCvt(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::FCvtWS:
case IROp::FCvtSW:
case IROp::FCvtScaledWS:
case IROp::FCvtScaledSW:
CompIR_Generic(inst);
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_FRound(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::FRound:
case IROp::FTrunc:
case IROp::FCeil:
case IROp::FFloor:
CompIR_Generic(inst);
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_FSat(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::FSat0_1:
case IROp::FSatMinus1_1:
CompIR_Generic(inst);
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_FSpecial(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::FSin:
case IROp::FCos:
case IROp::FRSqrt:
case IROp::FRecip:
case IROp::FAsin:
CompIR_Generic(inst);
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_RoundingMode(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::RestoreRoundingMode:
RestoreRoundingMode();
break;
case IROp::ApplyRoundingMode:
ApplyRoundingMode();
break;
case IROp::UpdateRoundingMode:
UpdateRoundingMode();
break;
default:
INVALIDOP;
break;
}
}
} // namespace MIPSComp
#endif
+448
View File
@@ -0,0 +1,448 @@
// Copyright (c) 2023- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "ppsspp_config.h"
// In other words, PPSSPP_ARCH(ARM64) || DISASM_ALL.
#if PPSSPP_ARCH(ARM64) || (PPSSPP_PLATFORM(WINDOWS) && !defined(__LIBRETRO__))
#include "Core/MemMap.h"
#include "Core/MIPS/ARM64/Arm64IRJit.h"
#include "Core/MIPS/ARM64/Arm64IRRegCache.h"
// This file contains compilation for load/store instructions.
//
// All functions should have CONDITIONAL_DISABLE, so we can narrow things down to a file quickly.
// Currently known non working ones should have DISABLE. No flags because that's in IR already.
// #define CONDITIONAL_DISABLE { CompIR_Generic(inst); return; }
#define CONDITIONAL_DISABLE {}
#define DISABLE { CompIR_Generic(inst); return; }
#define INVALIDOP { _assert_msg_(false, "Invalid IR inst %d", (int)inst.op); CompIR_Generic(inst); return; }
namespace MIPSComp {
using namespace Arm64Gen;
using namespace Arm64IRJitConstants;
static int IROpToByteWidth(IROp op) {
switch (op) {
case IROp::Load8:
case IROp::Load8Ext:
case IROp::Store8:
return 1;
case IROp::Load16:
case IROp::Load16Ext:
case IROp::Store16:
return 2;
case IROp::Load32:
case IROp::Load32Linked:
case IROp::Load32Left:
case IROp::Load32Right:
case IROp::LoadFloat:
case IROp::Store32:
case IROp::Store32Conditional:
case IROp::Store32Left:
case IROp::Store32Right:
case IROp::StoreFloat:
return 4;
case IROp::LoadVec4:
case IROp::StoreVec4:
return 16;
default:
_assert_msg_(false, "Unexpected op: %s", GetIRMeta(op) ? GetIRMeta(op)->name : "?");
return -1;
}
}
Arm64JitBackend::LoadStoreArg Arm64JitBackend::PrepareSrc1Address(IRInst inst) {
const IRMeta *m = GetIRMeta(inst.op);
bool src1IsPointer = regs_.IsGPRMappedAsPointer(inst.src1);
bool readsFromSrc1 = inst.src1 == inst.src3 && (m->flags & (IRFLAG_SRC3 | IRFLAG_SRC3DST)) != 0;
// If it's about to be clobbered, don't waste time pointerifying. Use displacement.
bool clobbersSrc1 = !readsFromSrc1 && regs_.IsGPRClobbered(inst.src1);
int32_t imm = (int32_t)inst.constant;
LoadStoreArg addrArg;
if (inst.src1 == MIPS_REG_ZERO) {
// The constant gets applied later.
addrArg.base = MEMBASEREG;
#ifdef MASKED_PSP_MEMORY
imm &= Memory::MEMVIEW32_MASK;
#endif
} else if (!jo.enablePointerify && readsFromSrc1) {
#ifndef MASKED_PSP_MEMORY
if (imm == 0) {
addrArg.base = MEMBASEREG;
addrArg.regOffset = regs_.MapGPR(inst.src1);
addrArg.useRegisterOffset = true;
addrArg.signExtendRegOffset = false;
}
#endif
// Since we can't modify src1, let's just use a temp reg while copying.
if (!addrArg.useRegisterOffset) {
ADDI2R(SCRATCH1, regs_.MapGPR(inst.src1), (s64)imm, SCRATCH2);
#ifdef MASKED_PSP_MEMORY
ANDI2R(SCRATCH1, SCRATCH1, Memory::MEMVIEW32_MASK, SCRATCH2);
#endif
addrArg.base = MEMBASEREG;
addrArg.regOffset = SCRATCH1;
addrArg.useRegisterOffset = true;
addrArg.signExtendRegOffset = false;
}
} else if ((jo.cachePointers && !clobbersSrc1) || src1IsPointer) {
// The offset gets set later.
addrArg.base = regs_.MapGPRAsPointer(inst.src1);
} else {
ADDI2R(SCRATCH1, regs_.MapGPR(inst.src1), (s64)imm, SCRATCH2);
#ifdef MASKED_PSP_MEMORY
ANDI2R(SCRATCH1, SCRATCH1, Memory::MEMVIEW32_MASK, SCRATCH2);
#endif
addrArg.base = MEMBASEREG;
addrArg.regOffset = SCRATCH1;
addrArg.useRegisterOffset = true;
addrArg.signExtendRegOffset = false;
}
// That's src1 taken care of, and possibly imm.
// If useRegisterOffset is false, imm still needs to be accounted for.
if (!addrArg.useRegisterOffset && imm != 0) {
#ifdef MASKED_PSP_MEMORY
// In case we have an address + offset reg.
if (imm > 0)
imm &= Memory::MEMVIEW32_MASK;
#endif
int scale = IROpToByteWidth(inst.op);
if (imm > 0 && (imm & (scale - 1)) == 0 && imm <= 0xFFF * scale) {
// Okay great, use the LDR/STR form.
addrArg.immOffset = imm;
addrArg.useUnscaled = false;
} else if (imm >= -256 && imm < 256) {
// An unscaled offset (LDUR/STUR) should work fine for this range.
addrArg.immOffset = imm;
addrArg.useUnscaled = true;
} else {
// No luck, we'll need to load into a register.
MOVI2R(SCRATCH1, (s64)imm);
addrArg.regOffset = SCRATCH1;
addrArg.useRegisterOffset = true;
addrArg.signExtendRegOffset = true;
}
}
return addrArg;
}
void Arm64JitBackend::CompIR_CondStore(IRInst inst) {
CONDITIONAL_DISABLE;
if (inst.op != IROp::Store32Conditional)
INVALIDOP;
regs_.SpillLockGPR(IRREG_LLBIT, inst.src3, inst.src1);
LoadStoreArg addrArg = PrepareSrc1Address(inst);
ARM64Reg valueReg = regs_.MapGPR(inst.src3, MIPSMap::INIT);
regs_.MapGPR(IRREG_LLBIT, MIPSMap::INIT);
// TODO: Safe memory? Or enough to have crash handler + validate?
FixupBranch condFailed = CBZ(regs_.R(IRREG_LLBIT));
if (addrArg.useRegisterOffset) {
STR(valueReg, addrArg.base, ArithOption(addrArg.regOffset, false, addrArg.signExtendRegOffset));
} else if (addrArg.useUnscaled) {
STUR(valueReg, addrArg.base, addrArg.immOffset);
} else {
STR(INDEX_UNSIGNED, valueReg, addrArg.base, addrArg.immOffset);
}
if (inst.dest != MIPS_REG_ZERO) {
MOVI2R(regs_.R(inst.dest), 1);
FixupBranch finish = B();
SetJumpTarget(condFailed);
MOVI2R(regs_.R(inst.dest), 0);
SetJumpTarget(finish);
} else {
SetJumpTarget(condFailed);
}
}
void Arm64JitBackend::CompIR_FLoad(IRInst inst) {
CONDITIONAL_DISABLE;
LoadStoreArg addrArg = PrepareSrc1Address(inst);
switch (inst.op) {
case IROp::LoadFloat:
regs_.MapFPR(inst.dest, MIPSMap::NOINIT);
if (addrArg.useRegisterOffset) {
fp_.LDR(32, regs_.F(inst.dest), addrArg.base, ArithOption(addrArg.regOffset, false, addrArg.signExtendRegOffset));
} else if (addrArg.useUnscaled) {
fp_.LDUR(32, regs_.F(inst.dest), addrArg.base, addrArg.immOffset);
} else {
fp_.LDR(32, INDEX_UNSIGNED, regs_.F(inst.dest), addrArg.base, addrArg.immOffset);
}
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_FStore(IRInst inst) {
CONDITIONAL_DISABLE;
LoadStoreArg addrArg = PrepareSrc1Address(inst);
switch (inst.op) {
case IROp::StoreFloat:
regs_.MapFPR(inst.src3);
if (addrArg.useRegisterOffset) {
fp_.STR(32, regs_.F(inst.src3), addrArg.base, ArithOption(addrArg.regOffset, false, addrArg.signExtendRegOffset));
} else if (addrArg.useUnscaled) {
fp_.STUR(32, regs_.F(inst.src3), addrArg.base, addrArg.immOffset);
} else {
fp_.STR(32, INDEX_UNSIGNED, regs_.F(inst.src3), addrArg.base, addrArg.immOffset);
}
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_Load(IRInst inst) {
CONDITIONAL_DISABLE;
regs_.SpillLockGPR(inst.dest, inst.src1);
LoadStoreArg addrArg = PrepareSrc1Address(inst);
// With NOINIT, MapReg won't subtract MEMBASEREG even if dest == src1.
regs_.MapGPR(inst.dest, MIPSMap::NOINIT);
// TODO: Safe memory? Or enough to have crash handler + validate?
switch (inst.op) {
case IROp::Load8:
if (addrArg.useRegisterOffset) {
LDRB(regs_.R(inst.dest), addrArg.base, ArithOption(addrArg.regOffset, false, addrArg.signExtendRegOffset));
} else if (addrArg.useUnscaled) {
LDURB(regs_.R(inst.dest), addrArg.base, addrArg.immOffset);
} else {
LDRB(INDEX_UNSIGNED, regs_.R(inst.dest), addrArg.base, addrArg.immOffset);
}
break;
case IROp::Load8Ext:
if (addrArg.useRegisterOffset) {
LDRSB(regs_.R(inst.dest), addrArg.base, ArithOption(addrArg.regOffset, false, addrArg.signExtendRegOffset));
} else if (addrArg.useUnscaled) {
LDURSB(regs_.R(inst.dest), addrArg.base, addrArg.immOffset);
} else {
LDRSB(INDEX_UNSIGNED, regs_.R(inst.dest), addrArg.base, addrArg.immOffset);
}
break;
case IROp::Load16:
if (addrArg.useRegisterOffset) {
LDRH(regs_.R(inst.dest), addrArg.base, ArithOption(addrArg.regOffset, false, addrArg.signExtendRegOffset));
} else if (addrArg.useUnscaled) {
LDURH(regs_.R(inst.dest), addrArg.base, addrArg.immOffset);
} else {
LDRH(INDEX_UNSIGNED, regs_.R(inst.dest), addrArg.base, addrArg.immOffset);
}
break;
case IROp::Load16Ext:
if (addrArg.useRegisterOffset) {
LDRSH(regs_.R(inst.dest), addrArg.base, ArithOption(addrArg.regOffset, false, addrArg.signExtendRegOffset));
} else if (addrArg.useUnscaled) {
LDURSH(regs_.R(inst.dest), addrArg.base, addrArg.immOffset);
} else {
LDRSH(INDEX_UNSIGNED, regs_.R(inst.dest), addrArg.base, addrArg.immOffset);
}
break;
case IROp::Load32:
if (addrArg.useRegisterOffset) {
LDR(regs_.R(inst.dest), addrArg.base, ArithOption(addrArg.regOffset, false, addrArg.signExtendRegOffset));
} else if (addrArg.useUnscaled) {
LDUR(regs_.R(inst.dest), addrArg.base, addrArg.immOffset);
} else {
LDR(INDEX_UNSIGNED, regs_.R(inst.dest), addrArg.base, addrArg.immOffset);
}
break;
case IROp::Load32Linked:
if (inst.dest != MIPS_REG_ZERO) {
if (addrArg.useRegisterOffset) {
LDR(regs_.R(inst.dest), addrArg.base, ArithOption(addrArg.regOffset, false, addrArg.signExtendRegOffset));
} else if (addrArg.useUnscaled) {
LDUR(regs_.R(inst.dest), addrArg.base, addrArg.immOffset);
} else {
LDR(INDEX_UNSIGNED, regs_.R(inst.dest), addrArg.base, addrArg.immOffset);
}
}
regs_.SetGPRImm(IRREG_LLBIT, 1);
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_LoadShift(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::Load32Left:
case IROp::Load32Right:
// Should not happen if the pass to split is active.
DISABLE;
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_Store(IRInst inst) {
CONDITIONAL_DISABLE;
regs_.SpillLockGPR(inst.src3, inst.src1);
LoadStoreArg addrArg = PrepareSrc1Address(inst);
ARM64Reg valueReg = regs_.TryMapTempImm(inst.src3);
if (valueReg == INVALID_REG)
valueReg = regs_.MapGPR(inst.src3);
// TODO: Safe memory? Or enough to have crash handler + validate?
switch (inst.op) {
case IROp::Store8:
if (addrArg.useRegisterOffset) {
STRB(valueReg, addrArg.base, ArithOption(addrArg.regOffset, false, addrArg.signExtendRegOffset));
} else if (addrArg.useUnscaled) {
STURB(valueReg, addrArg.base, addrArg.immOffset);
} else {
STRB(INDEX_UNSIGNED, valueReg, addrArg.base, addrArg.immOffset);
}
break;
case IROp::Store16:
if (addrArg.useRegisterOffset) {
STRH(valueReg, addrArg.base, ArithOption(addrArg.regOffset, false, addrArg.signExtendRegOffset));
} else if (addrArg.useUnscaled) {
STURH(valueReg, addrArg.base, addrArg.immOffset);
} else {
STRH(INDEX_UNSIGNED, valueReg, addrArg.base, addrArg.immOffset);
}
break;
case IROp::Store32:
if (addrArg.useRegisterOffset) {
STR(valueReg, addrArg.base, ArithOption(addrArg.regOffset, false, addrArg.signExtendRegOffset));
} else if (addrArg.useUnscaled) {
STUR(valueReg, addrArg.base, addrArg.immOffset);
} else {
STR(INDEX_UNSIGNED, valueReg, addrArg.base, addrArg.immOffset);
}
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_StoreShift(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::Store32Left:
case IROp::Store32Right:
// Should not happen if the pass to split is active.
DISABLE;
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_VecLoad(IRInst inst) {
CONDITIONAL_DISABLE;
LoadStoreArg addrArg = PrepareSrc1Address(inst);
switch (inst.op) {
case IROp::LoadVec4:
regs_.MapVec4(inst.dest, MIPSMap::NOINIT);
if (addrArg.useRegisterOffset) {
fp_.LDR(128, regs_.FQ(inst.dest), addrArg.base, ArithOption(addrArg.regOffset, false, addrArg.signExtendRegOffset));
} else if (addrArg.useUnscaled) {
fp_.LDUR(128, regs_.FQ(inst.dest), addrArg.base, addrArg.immOffset);
} else {
fp_.LDR(128, INDEX_UNSIGNED, regs_.FQ(inst.dest), addrArg.base, addrArg.immOffset);
}
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_VecStore(IRInst inst) {
CONDITIONAL_DISABLE;
LoadStoreArg addrArg = PrepareSrc1Address(inst);
switch (inst.op) {
case IROp::StoreVec4:
regs_.MapVec4(inst.src3);
if (addrArg.useRegisterOffset) {
fp_.STR(128, regs_.FQ(inst.src3), addrArg.base, ArithOption(addrArg.regOffset, false, addrArg.signExtendRegOffset));
} else if (addrArg.useUnscaled) {
fp_.STUR(128, regs_.FQ(inst.src3), addrArg.base, addrArg.immOffset);
} else {
fp_.STR(128, INDEX_UNSIGNED, regs_.FQ(inst.src3), addrArg.base, addrArg.immOffset);
}
break;
default:
INVALIDOP;
break;
}
}
} // namespace MIPSComp
#endif
+257
View File
@@ -0,0 +1,257 @@
// Copyright (c) 2023- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "ppsspp_config.h"
// In other words, PPSSPP_ARCH(ARM64) || DISASM_ALL.
#if PPSSPP_ARCH(ARM64) || (PPSSPP_PLATFORM(WINDOWS) && !defined(__LIBRETRO__))
#include "Common/Profiler/Profiler.h"
#include "Core/Core.h"
#include "Core/HLE/HLE.h"
#include "Core/HLE/ReplaceTables.h"
#include "Core/MemMap.h"
#include "Core/MIPS/ARM64/Arm64IRJit.h"
#include "Core/MIPS/ARM64/Arm64IRRegCache.h"
// This file contains compilation for basic PC/downcount accounting, syscalls, debug funcs, etc.
//
// All functions should have CONDITIONAL_DISABLE, so we can narrow things down to a file quickly.
// Currently known non working ones should have DISABLE. No flags because that's in IR already.
// #define CONDITIONAL_DISABLE { CompIR_Generic(inst); return; }
#define CONDITIONAL_DISABLE {}
#define DISABLE { CompIR_Generic(inst); return; }
#define INVALIDOP { _assert_msg_(false, "Invalid IR inst %d", (int)inst.op); CompIR_Generic(inst); return; }
namespace MIPSComp {
using namespace Arm64Gen;
using namespace Arm64IRJitConstants;
void Arm64JitBackend::CompIR_Basic(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::Downcount:
SUBI2R(DOWNCOUNTREG, DOWNCOUNTREG, (s64)(s32)inst.constant, SCRATCH1);
break;
case IROp::SetConst:
regs_.SetGPRImm(inst.dest, inst.constant);
break;
case IROp::SetConstF:
{
regs_.Map(inst);
float f;
memcpy(&f, &inst.constant, sizeof(f));
fp_.MOVI2F(regs_.F(inst.dest), f, SCRATCH1);
break;
}
case IROp::SetPC:
regs_.Map(inst);
MovToPC(regs_.R(inst.src1));
break;
case IROp::SetPCConst:
MOVI2R(SCRATCH1, inst.constant);
MovToPC(SCRATCH1);
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_Breakpoint(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::Breakpoint:
case IROp::MemoryCheck:
CompIR_Generic(inst);
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_System(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::Syscall:
FlushAll();
SaveStaticRegisters();
#ifdef USE_PROFILER
// When profiling, we can't skip CallSyscall, since it times syscalls.
MOVI2R(W0, inst.constant);
QuickCallFunction(SCRATCH2_64, &CallSyscall);
#else
// Skip the CallSyscall where possible.
{
MIPSOpcode op(inst.constant);
void *quickFunc = GetQuickSyscallFunc(op);
if (quickFunc) {
MOVP2R(X0, GetSyscallFuncPointer(op));
QuickCallFunction(SCRATCH2_64, (const u8 *)quickFunc);
} else {
MOVI2R(W0, inst.constant);
QuickCallFunction(SCRATCH2_64, &CallSyscall);
}
}
#endif
LoadStaticRegisters();
// This is always followed by an ExitToPC, where we check coreState.
break;
case IROp::CallReplacement:
FlushAll();
SaveStaticRegisters();
QuickCallFunction(SCRATCH2_64, GetReplacementFunc(inst.constant)->replaceFunc);
LoadStaticRegisters();
SUB(DOWNCOUNTREG, DOWNCOUNTREG, W0);
break;
case IROp::Break:
FlushAll();
// This doesn't naturally have restore/apply around it.
RestoreRoundingMode(true);
SaveStaticRegisters();
MovFromPC(W0);
QuickCallFunction(SCRATCH2_64, &Core_Break);
LoadStaticRegisters();
ApplyRoundingMode(true);
MovFromPC(SCRATCH1);
ADDI2R(SCRATCH1, SCRATCH1, 4, SCRATCH2);
B(dispatcherPCInSCRATCH1_);
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_Transfer(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::SetCtrlVFPU:
regs_.SetGPRImm(IRREG_VFPU_CTRL_BASE + inst.dest, inst.constant);
break;
case IROp::SetCtrlVFPUReg:
regs_.Map(inst);
MOV(regs_.R(IRREG_VFPU_CTRL_BASE + inst.dest), regs_.R(inst.src1));
break;
case IROp::SetCtrlVFPUFReg:
regs_.Map(inst);
fp_.FMOV(regs_.R(IRREG_VFPU_CTRL_BASE + inst.dest), regs_.F(inst.src1));
break;
case IROp::FpCondFromReg:
regs_.MapWithExtra(inst, { { 'G', IRREG_FPCOND, 1, MIPSMap::NOINIT } });
MOV(regs_.R(IRREG_FPCOND), regs_.R(inst.src1));
break;
case IROp::FpCondToReg:
regs_.MapWithExtra(inst, { { 'G', IRREG_FPCOND, 1, MIPSMap::INIT } });
MOV(regs_.R(inst.dest), regs_.R(IRREG_FPCOND));
break;
case IROp::FpCtrlFromReg:
regs_.MapWithExtra(inst, { { 'G', IRREG_FPCOND, 1, MIPSMap::NOINIT } });
ANDI2R(SCRATCH1, regs_.R(inst.src1), 0x0181FFFF, SCRATCH2);
// Extract the new fpcond value.
UBFX(regs_.R(IRREG_FPCOND), SCRATCH1, 23, 1);
STR(INDEX_UNSIGNED, SCRATCH1, CTXREG, IRREG_FCR31 * 4);
break;
case IROp::FpCtrlToReg:
regs_.MapWithExtra(inst, { { 'G', IRREG_FPCOND, 1, MIPSMap::INIT } });
// Load fcr31 and clear the fpcond bit.
LDR(INDEX_UNSIGNED, regs_.R(inst.dest), CTXREG, IRREG_FCR31 * 4);
BFI(regs_.R(inst.dest), regs_.R(IRREG_FPCOND), 23, 1);
// Also update mips->fcr31 while we're here.
STR(INDEX_UNSIGNED, regs_.R(inst.dest), CTXREG, IRREG_FCR31 * 4);
break;
case IROp::VfpuCtrlToReg:
regs_.Map(inst);
MOV(regs_.R(inst.dest), regs_.R(IRREG_VFPU_CTRL_BASE + inst.src1));
break;
case IROp::FMovFromGPR:
if (regs_.IsGPRImm(inst.src1) && regs_.GetGPRImm(inst.src1) == 0) {
regs_.MapFPR(inst.dest, MIPSMap::NOINIT);
fp_.MOVI2F(regs_.F(inst.dest), 0.0f, SCRATCH1);
} else {
regs_.Map(inst);
fp_.FMOV(regs_.F(inst.dest), regs_.R(inst.src1));
}
break;
case IROp::FMovToGPR:
regs_.Map(inst);
fp_.FMOV(regs_.R(inst.dest), regs_.F(inst.src1));
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_ValidateAddress(IRInst inst) {
CONDITIONAL_DISABLE;
bool isWrite = inst.src2 & 1;
int alignment = 0;
switch (inst.op) {
case IROp::ValidateAddress8:
alignment = 1;
break;
case IROp::ValidateAddress16:
alignment = 2;
break;
case IROp::ValidateAddress32:
alignment = 4;
break;
case IROp::ValidateAddress128:
alignment = 16;
break;
default:
INVALIDOP;
break;
}
}
} // namespace MIPSComp
#endif
+160
View File
@@ -0,0 +1,160 @@
// Copyright (c) 2023- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "ppsspp_config.h"
// In other words, PPSSPP_ARCH(ARM64) || DISASM_ALL.
#if PPSSPP_ARCH(ARM64) || (PPSSPP_PLATFORM(WINDOWS) && !defined(__LIBRETRO__))
#include <algorithm>
#include "Common/CPUDetect.h"
#include "Core/MemMap.h"
#include "Core/MIPS/ARM64/Arm64IRJit.h"
#include "Core/MIPS/ARM64/Arm64IRRegCache.h"
// This file contains compilation for vector instructions.
//
// All functions should have CONDITIONAL_DISABLE, so we can narrow things down to a file quickly.
// Currently known non working ones should have DISABLE. No flags because that's in IR already.
// #define CONDITIONAL_DISABLE { CompIR_Generic(inst); return; }
#define CONDITIONAL_DISABLE {}
#define DISABLE { CompIR_Generic(inst); return; }
#define INVALIDOP { _assert_msg_(false, "Invalid IR inst %d", (int)inst.op); CompIR_Generic(inst); return; }
namespace MIPSComp {
using namespace Arm64Gen;
using namespace Arm64IRJitConstants;
void Arm64JitBackend::CompIR_VecArith(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::Vec4Add:
regs_.Map(inst);
fp_.FADD(32, regs_.FQ(inst.dest), regs_.FQ(inst.src1), regs_.FQ(inst.src2));
break;
case IROp::Vec4Sub:
regs_.Map(inst);
fp_.FSUB(32, regs_.FQ(inst.dest), regs_.FQ(inst.src1), regs_.FQ(inst.src2));
break;
case IROp::Vec4Mul:
regs_.Map(inst);
fp_.FMUL(32, regs_.FQ(inst.dest), regs_.FQ(inst.src1), regs_.FQ(inst.src2));
break;
case IROp::Vec4Div:
regs_.Map(inst);
fp_.FDIV(32, regs_.FQ(inst.dest), regs_.FQ(inst.src1), regs_.FQ(inst.src2));
break;
case IROp::Vec4Scale:
CompIR_Generic(inst);
break;
case IROp::Vec4Neg:
regs_.Map(inst);
fp_.FNEG(32, regs_.FQ(inst.dest), regs_.FQ(inst.src1));
break;
case IROp::Vec4Abs:
regs_.Map(inst);
fp_.FABS(32, regs_.FQ(inst.dest), regs_.FQ(inst.src1));
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_VecAssign(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::Vec4Init:
case IROp::Vec4Shuffle:
case IROp::Vec4Blend:
CompIR_Generic(inst);
break;
case IROp::Vec4Mov:
regs_.Map(inst);
fp_.MOV(regs_.FQ(inst.dest), regs_.FQ(inst.src1));
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_VecClamp(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::Vec4ClampToZero:
case IROp::Vec2ClampToZero:
CompIR_Generic(inst);
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_VecHoriz(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::Vec4Dot:
CompIR_Generic(inst);
break;
default:
INVALIDOP;
break;
}
}
void Arm64JitBackend::CompIR_VecPack(IRInst inst) {
CONDITIONAL_DISABLE;
switch (inst.op) {
case IROp::Vec2Unpack16To31:
case IROp::Vec4Pack32To8:
case IROp::Vec2Pack31To16:
case IROp::Vec4Unpack8To32:
case IROp::Vec2Unpack16To32:
case IROp::Vec4DuplicateUpperBitsAndShift1:
case IROp::Vec4Pack31To8:
case IROp::Vec2Pack32To16:
CompIR_Generic(inst);
break;
default:
INVALIDOP;
break;
}
}
} // namespace MIPSComp
#endif
+372
View File
@@ -0,0 +1,372 @@
// Copyright (c) 2023- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "ppsspp_config.h"
// In other words, PPSSPP_ARCH(ARM64) || DISASM_ALL.
#if PPSSPP_ARCH(ARM64) || (PPSSPP_PLATFORM(WINDOWS) && !defined(__LIBRETRO__))
#include <cstddef>
#include "Core/MemMap.h"
#include "Core/MIPS/MIPSTables.h"
#include "Core/MIPS/ARM64/Arm64IRJit.h"
#include "Core/MIPS/ARM64/Arm64IRRegCache.h"
namespace MIPSComp {
using namespace Arm64Gen;
using namespace Arm64IRJitConstants;
// Invalidations just need at most two MOVs and B.
static constexpr int MIN_BLOCK_NORMAL_LEN = 12;
// As long as we can fit a B, we should be fine.
static constexpr int MIN_BLOCK_EXIT_LEN = 4;
Arm64JitBackend::Arm64JitBackend(JitOptions &jitopt, IRBlockCache &blocks)
: IRNativeBackend(blocks), jo(jitopt), regs_(&jo), fp_(this) {
// Automatically disable incompatible options.
if (((intptr_t)Memory::base & 0x00000000FFFFFFFFUL) != 0) {
jo.enablePointerify = false;
}
#ifdef MASKED_PSP_MEMORY
jo.enablePointerify = false;
#endif
// Since we store the offset, this is as big as it can be.
AllocCodeSpace(1024 * 1024 * 16);
regs_.Init(this, &fp_);
}
Arm64JitBackend::~Arm64JitBackend() {}
void Arm64JitBackend::UpdateFCR31(MIPSState *mipsState) {
currentRoundingFunc_ = convertS0ToSCRATCH1_[mipsState->fcr31 & 3];
}
static void NoBlockExits() {
_assert_msg_(false, "Never exited block, invalid IR?");
}
bool Arm64JitBackend::CompileBlock(IRBlock *block, int block_num, bool preload) {
if (GetSpaceLeft() < 0x800)
return false;
BeginWrite(std::min(GetSpaceLeft(), (size_t)block->GetNumInstructions() * 32));
u32 startPC = block->GetOriginalStart();
bool wroteCheckedOffset = false;
if (jo.enableBlocklink && !jo.useBackJump) {
SetBlockCheckedOffset(block_num, (int)GetOffset(GetCodePointer()));
wroteCheckedOffset = true;
// Check the sign bit to check if negative.
FixupBranch normalEntry = TBZ(DOWNCOUNTREG, 31);
MOVI2R(SCRATCH1, startPC);
B(outerLoopPCInSCRATCH1_);
SetJumpTarget(normalEntry);
}
// Don't worry, the codespace isn't large enough to overflow offsets.
const u8 *blockStart = GetCodePointer();
block->SetTargetOffset((int)GetOffset(blockStart));
compilingBlockNum_ = block_num;
regs_.Start(block);
std::map<const u8 *, int> addresses;
for (int i = 0; i < block->GetNumInstructions(); ++i) {
const IRInst &inst = block->GetInstructions()[i];
regs_.SetIRIndex(i);
// TODO: This might be a little wasteful when compiling if we're not debugging jit...
addresses[GetCodePtr()] = i;
CompileIRInst(inst);
if (jo.Disabled(JitDisable::REGALLOC_GPR) || jo.Disabled(JitDisable::REGALLOC_FPR))
regs_.FlushAll(jo.Disabled(JitDisable::REGALLOC_GPR), jo.Disabled(JitDisable::REGALLOC_FPR));
// Safety check, in case we get a bunch of really large jit ops without a lot of branching.
if (GetSpaceLeft() < 0x800) {
compilingBlockNum_ = -1;
return false;
}
}
// We should've written an exit above. If we didn't, bad things will happen.
// Only check if debug stats are enabled - needlessly wastes jit space.
if (DebugStatsEnabled()) {
QuickCallFunction(SCRATCH2_64, &NoBlockExits);
B(hooks_.crashHandler);
}
int len = (int)GetOffset(GetCodePointer()) - block->GetTargetOffset();
if (len < MIN_BLOCK_NORMAL_LEN) {
// We need at least 10 bytes to invalidate blocks with.
ReserveCodeSpace(MIN_BLOCK_NORMAL_LEN - len);
}
if (!wroteCheckedOffset) {
// Always record this, even if block link disabled - it's used for size calc.
SetBlockCheckedOffset(block_num, (int)GetOffset(GetCodePointer()));
}
if (jo.enableBlocklink && jo.useBackJump) {
// Small blocks are common, check if it's < 32KB long.
ptrdiff_t distance = blockStart - GetCodePointer();
if (distance >= -0x8000 && distance < 0x8000) {
TBZ(DOWNCOUNTREG, 31, blockStart);
} else {
FixupBranch toDispatch = TBNZ(DOWNCOUNTREG, 31);
B(blockStart);
SetJumpTarget(toDispatch);
}
MOVI2R(SCRATCH1, startPC);
B(outerLoopPCInSCRATCH1_);
}
if (logBlocks_ > 0) {
--logBlocks_;
INFO_LOG(JIT, "=============== ARM64 (%08x, %d bytes) ===============", startPC, len);
for (const u8 *p = blockStart; p < GetCodePointer(); ) {
auto it = addresses.find(p);
if (it != addresses.end()) {
const IRInst &inst = block->GetInstructions()[it->second];
char temp[512];
DisassembleIR(temp, sizeof(temp), inst);
INFO_LOG(JIT, "IR: #%d %s", it->second, temp);
}
auto next = std::next(it);
const u8 *nextp = next == addresses.end() ? GetCodePointer() : next->first;
auto lines = DisassembleArm64(p, (int)(nextp - p));
for (const auto &line : lines)
INFO_LOG(JIT, " A: %s", line.c_str());
p = nextp;
}
}
EndWrite();
FlushIcache();
compilingBlockNum_ = -1;
return true;
}
void Arm64JitBackend::WriteConstExit(uint32_t pc) {
int block_num = blocks_.GetBlockNumberFromStartAddress(pc);
const IRNativeBlock *nativeBlock = GetNativeBlock(block_num);
int exitStart = (int)GetOffset(GetCodePointer());
if (block_num >= 0 && jo.enableBlocklink && nativeBlock && nativeBlock->checkedOffset != 0) {
B(GetBasePtr() + nativeBlock->checkedOffset);
} else {
MOVI2R(SCRATCH1, pc);
B(dispatcherPCInSCRATCH1_);
}
if (jo.enableBlocklink) {
// In case of compression or early link, make sure it's large enough.
int len = (int)GetOffset(GetCodePointer()) - exitStart;
if (len < MIN_BLOCK_EXIT_LEN) {
ReserveCodeSpace(MIN_BLOCK_EXIT_LEN - len);
len = MIN_BLOCK_EXIT_LEN;
}
AddLinkableExit(compilingBlockNum_, pc, exitStart, len);
}
}
void Arm64JitBackend::OverwriteExit(int srcOffset, int len, int block_num) {
_dbg_assert_(len >= MIN_BLOCK_EXIT_LEN);
const IRNativeBlock *nativeBlock = GetNativeBlock(block_num);
if (nativeBlock) {
u8 *writable = GetWritablePtrFromCodePtr(GetBasePtr()) + srcOffset;
if (PlatformIsWXExclusive()) {
ProtectMemoryPages(writable, len, MEM_PROT_READ | MEM_PROT_WRITE);
}
ARM64XEmitter emitter(GetBasePtr() + srcOffset, writable);
emitter.B(GetBasePtr() + nativeBlock->checkedOffset);
int bytesWritten = (int)(emitter.GetWritableCodePtr() - writable);
_dbg_assert_(bytesWritten <= MIN_BLOCK_EXIT_LEN);
if (bytesWritten < len)
emitter.ReserveCodeSpace(len - bytesWritten);
emitter.FlushIcache();
if (PlatformIsWXExclusive()) {
ProtectMemoryPages(writable, 16, MEM_PROT_READ | MEM_PROT_EXEC);
}
}
}
void Arm64JitBackend::CompIR_Generic(IRInst inst) {
// If we got here, we're going the slow way.
uint64_t value;
memcpy(&value, &inst, sizeof(inst));
FlushAll();
SaveStaticRegisters();
MOVI2R(X0, value);
QuickCallFunction(SCRATCH2_64, &DoIRInst);
LoadStaticRegisters();
// We only need to check the return value if it's a potential exit.
if ((GetIRMeta(inst.op)->flags & IRFLAG_EXIT) != 0) {
MOV(SCRATCH1, X0);
ptrdiff_t distance = dispatcherPCInSCRATCH1_ - GetCodePointer();
if (distance >= -0x100000 && distance < 0x100000) {
// Convenient, we can do a simple branch if within 1MB.
CBNZ(W0, dispatcherPCInSCRATCH1_);
} else {
// That's a shame, we need a long branch.
FixupBranch keepOnKeepingOn = CBZ(W0);
B(dispatcherPCInSCRATCH1_);
SetJumpTarget(keepOnKeepingOn);
}
}
}
void Arm64JitBackend::CompIR_Interpret(IRInst inst) {
MIPSOpcode op(inst.constant);
// IR protects us against this being a branching instruction (well, hopefully.)
FlushAll();
SaveStaticRegisters();
if (DebugStatsEnabled()) {
MOVP2R(X0, MIPSGetName(op));
QuickCallFunction(SCRATCH2_64, &NotifyMIPSInterpret);
}
MOVI2R(X0, inst.constant);
QuickCallFunction(SCRATCH2_64, MIPSGetInterpretFunc(op));
LoadStaticRegisters();
}
void Arm64JitBackend::FlushAll() {
regs_.FlushAll();
}
bool Arm64JitBackend::DescribeCodePtr(const u8 *ptr, std::string &name) const {
// Used in disassembly viewer and profiling tools.
// Don't use spaces; profilers get confused or truncate them.
if (ptr == dispatcherPCInSCRATCH1_) {
name = "dispatcherPCInSCRATCH1";
} else if (ptr == outerLoopPCInSCRATCH1_) {
name = "outerLoopPCInSCRATCH1";
} else if (ptr == dispatcherNoCheck_) {
name = "dispatcherNoCheck";
} else if (ptr == saveStaticRegisters_) {
name = "saveStaticRegisters";
} else if (ptr == loadStaticRegisters_) {
name = "loadStaticRegisters";
} else if (ptr == restoreRoundingMode_) {
name = "restoreRoundingMode";
} else if (ptr == applyRoundingMode_) {
name = "applyRoundingMode";
} else if (ptr == updateRoundingMode_) {
name = "updateRoundingMode";
} else if (ptr == currentRoundingFunc_) {
name = "currentRoundingFunc";
} else if (ptr >= convertS0ToSCRATCH1_[0] && ptr <= convertS0ToSCRATCH1_[7]) {
name = "convertS0ToSCRATCH1";
} else if (ptr >= GetBasePtr() && ptr < GetBasePtr() + jitStartOffset_) {
name = "fixedCode";
} else {
return IRNativeBackend::DescribeCodePtr(ptr, name);
}
return true;
}
void Arm64JitBackend::ClearAllBlocks() {
ClearCodeSpace(jitStartOffset_);
FlushIcacheSection(region + jitStartOffset_, region + region_size - jitStartOffset_);
EraseAllLinks(-1);
}
void Arm64JitBackend::InvalidateBlock(IRBlock *block, int block_num) {
int offset = block->GetTargetOffset();
u8 *writable = GetWritablePtrFromCodePtr(GetBasePtr()) + offset;
// Overwrite the block with a jump to compile it again.
u32 pc = block->GetOriginalStart();
if (pc != 0) {
// Hopefully we always have at least 16 bytes, which should be all we need.
if (PlatformIsWXExclusive()) {
ProtectMemoryPages(writable, MIN_BLOCK_NORMAL_LEN, MEM_PROT_READ | MEM_PROT_WRITE);
}
ARM64XEmitter emitter(GetBasePtr() + offset, writable);
emitter.MOVI2R(SCRATCH1, pc);
emitter.B(dispatcherPCInSCRATCH1_);
int bytesWritten = (int)(emitter.GetWritableCodePtr() - writable);
if (bytesWritten < MIN_BLOCK_NORMAL_LEN)
emitter.ReserveCodeSpace(MIN_BLOCK_NORMAL_LEN - bytesWritten);
emitter.FlushIcache();
if (PlatformIsWXExclusive()) {
ProtectMemoryPages(writable, MIN_BLOCK_NORMAL_LEN, MEM_PROT_READ | MEM_PROT_EXEC);
}
}
EraseAllLinks(block_num);
}
void Arm64JitBackend::RestoreRoundingMode(bool force) {
QuickCallFunction(SCRATCH2_64, restoreRoundingMode_);
}
void Arm64JitBackend::ApplyRoundingMode(bool force) {
QuickCallFunction(SCRATCH2_64, applyRoundingMode_);
}
void Arm64JitBackend::UpdateRoundingMode(bool force) {
QuickCallFunction(SCRATCH2_64, updateRoundingMode_);
}
void Arm64JitBackend::MovFromPC(ARM64Reg r) {
LDR(INDEX_UNSIGNED, r, CTXREG, offsetof(MIPSState, pc));
}
void Arm64JitBackend::MovToPC(ARM64Reg r) {
STR(INDEX_UNSIGNED, r, CTXREG, offsetof(MIPSState, pc));
}
void Arm64JitBackend::SaveStaticRegisters() {
if (jo.useStaticAlloc) {
QuickCallFunction(SCRATCH2_64, saveStaticRegisters_);
} else {
// Inline the single operation
STR(INDEX_UNSIGNED, DOWNCOUNTREG, CTXREG, offsetof(MIPSState, downcount));
}
}
void Arm64JitBackend::LoadStaticRegisters() {
if (jo.useStaticAlloc) {
QuickCallFunction(SCRATCH2_64, loadStaticRegisters_);
} else {
LDR(INDEX_UNSIGNED, DOWNCOUNTREG, CTXREG, offsetof(MIPSState, downcount));
}
}
} // namespace MIPSComp
#endif
+163
View File
@@ -0,0 +1,163 @@
// Copyright (c) 2023- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#pragma once
#include "ppsspp_config.h"
// In other words, PPSSPP_ARCH(ARM64) || DISASM_ALL.
#if PPSSPP_ARCH(ARM64) || (PPSSPP_PLATFORM(WINDOWS) && !defined(__LIBRETRO__))
#include <string>
#include <vector>
#include "Common/Arm64Emitter.h"
#include "Core/MIPS/IR/IRJit.h"
#include "Core/MIPS/IR/IRNativeCommon.h"
#include "Core/MIPS/JitCommon/JitState.h"
#include "Core/MIPS/JitCommon/JitCommon.h"
#include "Core/MIPS/ARM64/Arm64IRRegCache.h"
namespace MIPSComp {
class Arm64JitBackend : public Arm64Gen::ARM64CodeBlock, public IRNativeBackend {
public:
Arm64JitBackend(JitOptions &jo, IRBlockCache &blocks);
~Arm64JitBackend();
bool DescribeCodePtr(const u8 *ptr, std::string &name) const override;
void GenerateFixedCode(MIPSState *mipsState) override;
bool CompileBlock(IRBlock *block, int block_num, bool preload) override;
void ClearAllBlocks() override;
void InvalidateBlock(IRBlock *block, int block_num) override;
void UpdateFCR31(MIPSState *mipsState) override;
protected:
const CodeBlockCommon &CodeBlock() const override {
return *this;
}
private:
void RestoreRoundingMode(bool force = false);
void ApplyRoundingMode(bool force = false);
void UpdateRoundingMode(bool force = false);
void MovFromPC(Arm64Gen::ARM64Reg r);
void MovToPC(Arm64Gen::ARM64Reg r);
void SaveStaticRegisters();
void LoadStaticRegisters();
// Note: destroys SCRATCH1.
void FlushAll();
void WriteConstExit(uint32_t pc);
void OverwriteExit(int srcOffset, int len, int block_num) override;
void CompIR_Arith(IRInst inst) override;
void CompIR_Assign(IRInst inst) override;
void CompIR_Basic(IRInst inst) override;
void CompIR_Bits(IRInst inst) override;
void CompIR_Breakpoint(IRInst inst) override;
void CompIR_Compare(IRInst inst) override;
void CompIR_CondAssign(IRInst inst) override;
void CompIR_CondStore(IRInst inst) override;
void CompIR_Div(IRInst inst) override;
void CompIR_Exit(IRInst inst) override;
void CompIR_ExitIf(IRInst inst) override;
void CompIR_FArith(IRInst inst) override;
void CompIR_FAssign(IRInst inst) override;
void CompIR_FCompare(IRInst inst) override;
void CompIR_FCondAssign(IRInst inst) override;
void CompIR_FCvt(IRInst inst) override;
void CompIR_FLoad(IRInst inst) override;
void CompIR_FRound(IRInst inst) override;
void CompIR_FSat(IRInst inst) override;
void CompIR_FSpecial(IRInst inst) override;
void CompIR_FStore(IRInst inst) override;
void CompIR_Generic(IRInst inst) override;
void CompIR_HiLo(IRInst inst) override;
void CompIR_Interpret(IRInst inst) override;
void CompIR_Load(IRInst inst) override;
void CompIR_LoadShift(IRInst inst) override;
void CompIR_Logic(IRInst inst) override;
void CompIR_Mult(IRInst inst) override;
void CompIR_RoundingMode(IRInst inst) override;
void CompIR_Shift(IRInst inst) override;
void CompIR_Store(IRInst inst) override;
void CompIR_StoreShift(IRInst inst) override;
void CompIR_System(IRInst inst) override;
void CompIR_Transfer(IRInst inst) override;
void CompIR_VecArith(IRInst inst) override;
void CompIR_VecAssign(IRInst inst) override;
void CompIR_VecClamp(IRInst inst) override;
void CompIR_VecHoriz(IRInst inst) override;
void CompIR_VecLoad(IRInst inst) override;
void CompIR_VecPack(IRInst inst) override;
void CompIR_VecStore(IRInst inst) override;
void CompIR_ValidateAddress(IRInst inst) override;
struct LoadStoreArg {
Arm64Gen::ARM64Reg base = Arm64Gen::INVALID_REG;
Arm64Gen::ARM64Reg regOffset = Arm64Gen::INVALID_REG;
int immOffset = 0;
bool useUnscaled = false;
bool useRegisterOffset = false;
bool signExtendRegOffset = false;
};
LoadStoreArg PrepareSrc1Address(IRInst inst);
JitOptions &jo;
Arm64IRRegCache regs_;
Arm64Gen::ARM64FloatEmitter fp_;
const u8 *outerLoop_ = nullptr;
const u8 *outerLoopPCInSCRATCH1_ = nullptr;
const u8 *dispatcherCheckCoreState_ = nullptr;
const u8 *dispatcherPCInSCRATCH1_ = nullptr;
const u8 *dispatcherNoCheck_ = nullptr;
const u8 *restoreRoundingMode_ = nullptr;
const u8 *applyRoundingMode_ = nullptr;
const u8 *updateRoundingMode_ = nullptr;
const u8 *saveStaticRegisters_ = nullptr;
const u8 *loadStaticRegisters_ = nullptr;
// Indexed by FPCR FZ:RN bits for convenience. Uses SCRATCH2.
const u8 *convertS0ToSCRATCH1_[8];
// Note: mutable state used at runtime.
const u8 *currentRoundingFunc_ = nullptr;
int jitStartOffset_ = 0;
int compilingBlockNum_ = -1;
int logBlocks_ = 0;
};
class Arm64IRJit : public IRNativeJit {
public:
Arm64IRJit(MIPSState *mipsState)
: IRNativeJit(mipsState), arm64Backend_(jo, blocks_) {
Init(arm64Backend_);
}
private:
Arm64JitBackend arm64Backend_;
};
} // namespace MIPSComp
#endif
+581
View File
@@ -0,0 +1,581 @@
// Copyright (c) 2023- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "ppsspp_config.h"
// In other words, PPSSPP_ARCH(ARM64) || DISASM_ALL.
#if PPSSPP_ARCH(ARM64) || (PPSSPP_PLATFORM(WINDOWS) && !defined(__LIBRETRO__))
#ifndef offsetof
#include <cstddef>
#endif
#include "Common/CPUDetect.h"
#include "Common/LogReporting.h"
#include "Core/MemMap.h"
#include "Core/MIPS/IR/IRInst.h"
#include "Core/MIPS/IR/IRAnalysis.h"
#include "Core/MIPS/ARM64/Arm64IRRegCache.h"
#include "Core/MIPS/JitCommon/JitState.h"
using namespace Arm64Gen;
using namespace Arm64IRJitConstants;
Arm64IRRegCache::Arm64IRRegCache(MIPSComp::JitOptions *jo)
: IRNativeRegCacheBase(jo) {
// The S/D/Q regs overlap, so we just use one slot. The numbers don't match ARM64Reg.
config_.totalNativeRegs = NUM_X_REGS + NUM_X_FREGS;
config_.mapFPUSIMD = true;
// XMM regs are used for both FPU and Vec, so we don't need VREGs.
config_.mapUseVRegs = false;
}
void Arm64IRRegCache::Init(ARM64XEmitter *emitter, ARM64FloatEmitter *fp) {
emit_ = emitter;
fp_ = fp;
}
const int *Arm64IRRegCache::GetAllocationOrder(MIPSLoc type, MIPSMap flags, int &count, int &base) const {
if (type == MIPSLoc::REG) {
// See register alloc remarks in Arm64Asm.cpp.
base = W0;
// W19-W23 are most suitable for static allocation. Those that are chosen for static allocation
// should be omitted here and added in GetStaticAllocations.
static const int allocationOrder[] = {
W19, W20, W21, W22, W23, W24, W0, W1, W2, W3, W4, W5, W6, W7, W8, W9, W10, W11, W12, W13, W14, W15,
};
static const int allocationOrderStaticAlloc[] = {
W0, W1, W2, W3, W4, W5, W6, W7, W8, W9, W10, W11, W12, W13, W14, W15,
};
if (jo_->useStaticAlloc) {
count = ARRAY_SIZE(allocationOrderStaticAlloc);
return allocationOrderStaticAlloc;
}
count = ARRAY_SIZE(allocationOrder);
return allocationOrder;
} else if (type == MIPSLoc::FREG) {
base = S0 - NUM_X_REGS;
// We don't really need four temps, probably.
// We start with S8 for call flushes.
static const int allocationOrder[] = {
// Reserve four full 128-bit temp registers, should be plenty.
S8, S9, S10, S11, // Partially callee-save (bottom 64 bits)
S12, S13, S14, S15, // Partially callee-save (bottom 64 bits)
S16, S17, S18, S19,
S20, S21, S22, S23,
S24, S25, S26, S27,
S28, S29, S30, S31,
S4, S5, S6, S7,
};
count = ARRAY_SIZE(allocationOrder);
return allocationOrder;
} else {
_assert_msg_(false, "Allocation order not yet implemented");
count = 0;
return nullptr;
}
}
const Arm64IRRegCache::StaticAllocation *Arm64IRRegCache::GetStaticAllocations(int &count) const {
static const StaticAllocation allocs[] = {
{ MIPS_REG_SP, W19, MIPSLoc::REG, true },
{ MIPS_REG_V0, W20, MIPSLoc::REG },
{ MIPS_REG_V1, W21, MIPSLoc::REG },
{ MIPS_REG_A0, W22, MIPSLoc::REG },
{ MIPS_REG_A1, W23, MIPSLoc::REG },
{ MIPS_REG_RA, W24, MIPSLoc::REG },
};
if (jo_->useStaticAlloc) {
count = ARRAY_SIZE(allocs);
return allocs;
}
return IRNativeRegCacheBase::GetStaticAllocations(count);
}
void Arm64IRRegCache::EmitLoadStaticRegisters() {
int count = 0;
const StaticAllocation *allocs = GetStaticAllocations(count);
for (int i = 0; i < count; ++i) {
int offset = GetMipsRegOffset(allocs[i].mr);
if (i + 1 < count && allocs[i].mr == allocs[i + 1].mr - 1) {
_assert_(!allocs[i].pointerified && !allocs[i + 1].pointerified);
emit_->LDP(INDEX_SIGNED, FromNativeReg(allocs[i].nr), FromNativeReg(allocs[i + 1].nr), CTXREG, offset);
++i;
} else {
emit_->LDR(INDEX_UNSIGNED, FromNativeReg(allocs[i].nr), CTXREG, offset);
if (allocs[i].pointerified && jo_->enablePointerify) {
ARM64Reg r64 = FromNativeReg64(allocs[i].nr);
uint32_t membaseHigh = (uint32_t)((uint64_t)Memory::base >> 32);
emit_->MOVK(r64, membaseHigh & 0xFFFF, SHIFT_32);
if (membaseHigh & 0xFFFF0000)
emit_->MOVK(r64, membaseHigh >> 16, SHIFT_48);
}
}
}
}
void Arm64IRRegCache::EmitSaveStaticRegisters() {
int count = 0;
const StaticAllocation *allocs = GetStaticAllocations(count);
// This only needs to run once (by Asm) so checks don't need to be fast.
for (int i = 0; i < count; ++i) {
int offset = GetMipsRegOffset(allocs[i].mr);
if (i + 1 < count && allocs[i].mr == allocs[i + 1].mr - 1) {
emit_->STP(INDEX_SIGNED, FromNativeReg(allocs[i].nr), FromNativeReg(allocs[i + 1].nr), CTXREG, offset);
++i;
} else {
emit_->STR(INDEX_UNSIGNED, FromNativeReg(allocs[i].nr), CTXREG, offset);
}
}
}
void Arm64IRRegCache::FlushBeforeCall() {
// These registers are not preserved by function calls.
auto isGPRSaved = [&](IRNativeReg nreg) {
ARM64Reg ar = FromNativeReg(nreg);
return ar >= W19 && ar <= W29;
};
auto isFPRSaved = [&](IRNativeReg nreg) {
ARM64Reg ar = FromNativeReg(nreg);
return ar >= S8 && ar <= S15;
};
// Go through by IR index first, to use STP where we can.
for (int i = 1; i < TOTAL_MAPPABLE_IRREGS - 1; ++i) {
if (mr[i].nReg == -1 || mr[i + 1].nReg == -1 || mr[i].isStatic || mr[i + 1].isStatic)
continue;
// Ignore multilane regs.
if (mr[i].lane != -1 || mr[i + 1].lane != -1)
continue;
if (!nr[mr[i].nReg].isDirty || !nr[mr[i + 1].nReg].isDirty)
continue;
int offset = GetMipsRegOffset(i);
// Okay, it's a maybe. Are we flushing both as GPRs?
if (!isGPRSaved(mr[i].nReg) && !isGPRSaved(mr[i + 1].nReg) && offset <= 252) {
// If either is mapped as a pointer, fix it.
if (mr[i].loc == MIPSLoc::REG_AS_PTR)
AdjustNativeRegAsPtr(mr[i].nReg, false);
if (mr[i + 1].loc == MIPSLoc::REG_AS_PTR)
AdjustNativeRegAsPtr(mr[i + 1].nReg, false);
// That means we should use STP.
emit_->STP(INDEX_SIGNED, FromNativeReg(mr[i].nReg), FromNativeReg(mr[i + 1].nReg), CTXREG, offset);
DiscardNativeReg(mr[i].nReg);
DiscardNativeReg(mr[i + 1].nReg);
++i;
continue;
}
// Perhaps as FPRs? Note: these must be single lane at this point.
// TODO: Could use STP on quads etc. too, i.e. i & i + 4.
if (!isFPRSaved(mr[i].nReg) && !isFPRSaved(mr[i + 1].nReg) && offset <= 252) {
fp_->STP(32, INDEX_SIGNED, FromNativeReg(mr[i].nReg), FromNativeReg(mr[i + 1].nReg), CTXREG, offset);
DiscardNativeReg(mr[i].nReg);
DiscardNativeReg(mr[i + 1].nReg);
++i;
continue;
}
}
// Alright, now go through any that didn't get flushed with STP.
for (int i = 0; i < 19; ++i) {
FlushNativeReg(GPRToNativeReg(ARM64Reg(W0 + i)));
}
FlushNativeReg(GPRToNativeReg(W30));
for (int i = 0; i < 8; ++i) {
FlushNativeReg(VFPToNativeReg(ARM64Reg(S0 + i)));
}
for (int i = 8; i < 16; ++i) {
// These are preserved but only the low 64 bits.
IRNativeReg nreg = VFPToNativeReg(ARM64Reg(S0 + i));
if (nr[nreg].mipsReg != IRREG_INVALID && GetFPRLaneCount(nr[nreg].mipsReg - 32) > 2)
FlushNativeReg(nreg);
}
for (int i = 16; i < 32; ++i) {
FlushNativeReg(VFPToNativeReg(ARM64Reg(S0 + i)));
}
}
ARM64Reg Arm64IRRegCache::TryMapTempImm(IRReg r) {
_dbg_assert_(IsValidGPR(r));
// If already mapped, no need for a temporary.
if (IsGPRMapped(r)) {
return R(r);
}
if (mr[r].loc == MIPSLoc::IMM) {
// Can we just use zero?
if (mr[r].imm == 0)
return WZR;
// Try our luck - check for an exact match in another xreg.
for (int i = 1; i < TOTAL_MAPPABLE_IRREGS; ++i) {
if (mr[i].loc == MIPSLoc::REG_IMM && mr[i].imm == mr[r].imm) {
// Awesome, let's just use this reg.
return FromNativeReg(mr[i].nReg);
}
}
}
return INVALID_REG;
}
ARM64Reg Arm64IRRegCache::GetAndLockTempGPR() {
IRNativeReg reg = AllocateReg(MIPSLoc::REG, MIPSMap::INIT);
if (reg != -1) {
nr[reg].tempLockIRIndex = irIndex_;
}
return FromNativeReg(reg);
}
ARM64Reg Arm64IRRegCache::GetAndLockTempFPR() {
IRNativeReg reg = AllocateReg(MIPSLoc::FREG, MIPSMap::INIT);
if (reg != -1) {
nr[reg].tempLockIRIndex = irIndex_;
}
return FromNativeReg(reg);
}
ARM64Reg Arm64IRRegCache::MapWithFPRTemp(const IRInst &inst) {
return FromNativeReg(MapWithTemp(inst, MIPSLoc::FREG));
}
ARM64Reg Arm64IRRegCache::MapGPR(IRReg mipsReg, MIPSMap mapFlags) {
_dbg_assert_(IsValidGPR(mipsReg));
// Okay, not mapped, so we need to allocate an arm64 register.
IRNativeReg nreg = MapNativeReg(MIPSLoc::REG, mipsReg, 1, mapFlags);
return FromNativeReg(nreg);
}
ARM64Reg Arm64IRRegCache::MapGPR2(IRReg mipsReg, MIPSMap mapFlags) {
_dbg_assert_(IsValidGPR(mipsReg) && IsValidGPR(mipsReg + 1));
// Okay, not mapped, so we need to allocate an arm64 register.
IRNativeReg nreg = MapNativeReg(MIPSLoc::REG, mipsReg, 2, mapFlags);
return FromNativeReg64(nreg);
}
ARM64Reg Arm64IRRegCache::MapGPRAsPointer(IRReg reg) {
return FromNativeReg64(MapNativeRegAsPointer(reg));
}
ARM64Reg Arm64IRRegCache::MapFPR(IRReg mipsReg, MIPSMap mapFlags) {
_dbg_assert_(IsValidFPR(mipsReg));
_dbg_assert_(mr[mipsReg + 32].loc == MIPSLoc::MEM || mr[mipsReg + 32].loc == MIPSLoc::FREG);
IRNativeReg nreg = MapNativeReg(MIPSLoc::FREG, mipsReg + 32, 1, mapFlags);
if (nreg != -1)
return FromNativeReg(nreg);
return INVALID_REG;
}
ARM64Reg Arm64IRRegCache::MapVec4(IRReg first, MIPSMap mapFlags) {
_dbg_assert_(IsValidFPR(first));
_dbg_assert_((first & 3) == 0);
_dbg_assert_(mr[first + 32].loc == MIPSLoc::MEM || mr[first + 32].loc == MIPSLoc::FREG);
IRNativeReg nreg = MapNativeReg(MIPSLoc::FREG, first + 32, 4, mapFlags);
if (nreg != -1)
return EncodeRegToQuad(FromNativeReg(nreg));
return INVALID_REG;
}
void Arm64IRRegCache::AdjustNativeRegAsPtr(IRNativeReg nreg, bool state) {
_assert_(nreg >= 0 && nreg < (IRNativeReg)WZR);
ARM64Reg r = FromNativeReg64(nreg);
if (state) {
if (!jo_->enablePointerify) {
#if defined(MASKED_PSP_MEMORY)
// This destroys the value...
_dbg_assert_(!nr[nreg].isDirty);
emit_->ANDI2R(r, r, Memory::MEMVIEW32_MASK);
#endif
emit_->ADD(r, r, MEMBASEREG);
} else {
uint32_t membaseHigh = (uint32_t)((uint64_t)Memory::base >> 32);
emit_->MOVK(r, membaseHigh & 0xFFFF, SHIFT_32);
if (membaseHigh & 0xFFFF0000)
emit_->MOVK(r, membaseHigh >> 16, SHIFT_48);
}
} else {
if (!jo_->enablePointerify) {
#if defined(MASKED_PSP_MEMORY)
_dbg_assert_(!nr[nreg].isDirty);
#endif
emit_->SUB(r, r, MEMBASEREG);
} else {
// Nothing to do, just ignore the high 32 bits.
}
}
}
bool Arm64IRRegCache::IsNativeRegCompatible(IRNativeReg nreg, MIPSLoc type, MIPSMap flags) {
// No special flags, skip the check for a little speed.
return true;
}
void Arm64IRRegCache::LoadNativeReg(IRNativeReg nreg, IRReg first, int lanes) {
ARM64Reg r = FromNativeReg(nreg);
_dbg_assert_(first != MIPS_REG_ZERO);
if (nreg < NUM_X_REGS) {
_assert_(lanes == 1 || (lanes == 2 && first == IRREG_LO));
if (lanes == 1)
emit_->LDR(INDEX_UNSIGNED, r, CTXREG, GetMipsRegOffset(first));
else if (lanes == 2)
emit_->LDR(INDEX_UNSIGNED, EncodeRegTo64(r), CTXREG, GetMipsRegOffset(first));
else
_assert_(false);
} else {
_dbg_assert_(nreg < NUM_X_REGS + NUM_X_FREGS);
_assert_msg_(mr[first].loc == MIPSLoc::FREG, "Cannot load this type: %d", (int)mr[first].loc);
if (lanes == 1)
fp_->LDR(32, INDEX_UNSIGNED, r, CTXREG, GetMipsRegOffset(first));
else if (lanes == 2)
fp_->LDR(64, INDEX_UNSIGNED, r, CTXREG, GetMipsRegOffset(first));
else if (lanes == 4)
fp_->LDR(128, INDEX_UNSIGNED, r, CTXREG, GetMipsRegOffset(first));
else
_assert_(false);
}
}
void Arm64IRRegCache::StoreNativeReg(IRNativeReg nreg, IRReg first, int lanes) {
ARM64Reg r = FromNativeReg(nreg);
_dbg_assert_(first != MIPS_REG_ZERO);
if (nreg < NUM_X_REGS) {
_assert_(lanes == 1 || (lanes == 2 && first == IRREG_LO));
_assert_(mr[first].loc == MIPSLoc::REG || mr[first].loc == MIPSLoc::REG_IMM);
if (lanes == 1)
emit_->STR(INDEX_UNSIGNED, r, CTXREG, GetMipsRegOffset(first));
else if (lanes == 2)
emit_->STR(INDEX_UNSIGNED, EncodeRegTo64(r), CTXREG, GetMipsRegOffset(first));
else
_assert_(false);
} else {
_dbg_assert_(nreg < NUM_X_REGS + NUM_X_FREGS);
_assert_msg_(mr[first].loc == MIPSLoc::FREG, "Cannot store this type: %d", (int)mr[first].loc);
if (lanes == 1)
fp_->STR(32, INDEX_UNSIGNED, r, CTXREG, GetMipsRegOffset(first));
else if (lanes == 2)
fp_->STR(64, INDEX_UNSIGNED, r, CTXREG, GetMipsRegOffset(first));
else if (lanes == 4)
fp_->STR(128, INDEX_UNSIGNED, r, CTXREG, GetMipsRegOffset(first));
else
_assert_(false);
}
}
void Arm64IRRegCache::SetNativeRegValue(IRNativeReg nreg, uint32_t imm) {
ARM64Reg r = FromNativeReg(nreg);
_dbg_assert_(nreg >= 0 && nreg < (IRNativeReg)WZR);
// On ARM64, MOVZ/MOVK is really fast.
emit_->MOVI2R(r, imm);
}
void Arm64IRRegCache::StoreRegValue(IRReg mreg, uint32_t imm) {
_assert_(IsValidGPRNoZero(mreg));
// Try to optimize using a different reg.
ARM64Reg storeReg = INVALID_REG;
if (imm == 0)
storeReg = WZR;
// Could we get lucky? Check for an exact match in another xreg.
for (int i = 1; i < TOTAL_MAPPABLE_IRREGS; ++i) {
if (mr[i].loc == MIPSLoc::REG_IMM && mr[i].imm == imm) {
// Awesome, let's just store this reg.
storeReg = (ARM64Reg)mr[i].nReg;
break;
}
}
if (storeReg == INVALID_REG) {
emit_->MOVI2R(SCRATCH1, imm);
storeReg = SCRATCH1;
}
emit_->STR(INDEX_UNSIGNED, storeReg, CTXREG, GetMipsRegOffset(mreg));
}
void Arm64IRRegCache::FlushAll(bool gprs, bool fprs) {
// Note: make sure not to change the registers when flushing:
// Branching code may expect the armreg to retain its value.
// Try to flush in pairs when possible.
for (int i = 1; i < TOTAL_MAPPABLE_IRREGS - 1; ++i) {
if (mr[i].loc == MIPSLoc::MEM || mr[i].loc == MIPSLoc::MEM || mr[i].isStatic || mr[i + 1].isStatic)
continue;
// Ignore multilane regs. Could handle with more smartness...
if (mr[i].lane != -1 || mr[i + 1].lane != -1)
continue;
if (mr[i].nReg != -1 && !nr[mr[i].nReg].isDirty)
continue;
if (mr[i + 1].nReg != -1 && !nr[mr[i + 1].nReg].isDirty)
continue;
if (mr[i].loc == MIPSLoc::MEM || mr[i + 1].loc == MIPSLoc::MEM)
continue;
int offset = GetMipsRegOffset(i);
// If both are imms, let's materialize a single reg and store.
if (mr[i].loc == MIPSLoc::IMM && mr[i + 1].loc == MIPSLoc::IMM) {
if ((i & 1) == 0) {
uint64_t fullImm = ((uint64_t) mr[i + 1].imm << 32) | mr[i].imm;
emit_->MOVI2R(SCRATCH1_64, fullImm);
emit_->STR(INDEX_UNSIGNED, SCRATCH1_64, CTXREG, offset);
DiscardReg(i);
DiscardReg(i + 1);
++i;
}
continue;
}
// Okay, two dirty regs in a row, in need of flushing. Both GPRs?
if (IsValidGPR(i) && IsValidGPR(i + 1) && offset <= 252) {
auto setupForFlush = [&](ARM64Reg &ar, IRReg r) {
if (mr[r].loc == MIPSLoc::IMM) {
ar = TryMapTempImm(r);
if (ar == INVALID_REG) {
// Both cannot be imms, so this is safe.
ar = SCRATCH1;
emit_->MOVI2R(ar, mr[r].imm);
}
} else if (mr[r].loc == MIPSLoc::REG_AS_PTR) {
AdjustNativeRegAsPtr(r, false);
ar = FromNativeReg(mr[r].nReg);
} else {
_dbg_assert_(mr[r].loc == MIPSLoc::REG || mr[r].loc == MIPSLoc::REG_IMM);
ar = FromNativeReg(mr[r].nReg);
}
};
ARM64Reg armRegs[2]{ INVALID_REG, INVALID_REG };
setupForFlush(armRegs[0], i);
setupForFlush(armRegs[1], i + 1);
emit_->STP(INDEX_SIGNED, armRegs[0], armRegs[1], CTXREG, offset);
DiscardReg(i);
DiscardReg(i + 1);
++i;
continue;
}
// Perhaps as FPRs? Note: these must be single lane at this point.
// TODO: Could use STP on quads etc. too, i.e. i & i + 4.
if (i >= 32 && IsValidFPR(i - 32) && IsValidFPR(i + 1 - 32) && offset <= 252) {
_dbg_assert_(mr[i].loc == MIPSLoc::FREG && mr[i + 1].loc == MIPSLoc::FREG);
fp_->STP(32, INDEX_SIGNED, FromNativeReg(mr[i].nReg), FromNativeReg(mr[i + 1].nReg), CTXREG, offset);
DiscardNativeReg(mr[i].nReg);
DiscardNativeReg(mr[i + 1].nReg);
++i;
continue;
}
}
// Flush all the rest that weren't done via STP.
IRNativeRegCacheBase::FlushAll(gprs, fprs);
}
ARM64Reg Arm64IRRegCache::R(IRReg mipsReg) {
_dbg_assert_(IsValidGPR(mipsReg));
_dbg_assert_(mr[mipsReg].loc == MIPSLoc::REG || mr[mipsReg].loc == MIPSLoc::REG_IMM);
if (mr[mipsReg].loc == MIPSLoc::REG || mr[mipsReg].loc == MIPSLoc::REG_IMM) {
return FromNativeReg(mr[mipsReg].nReg);
} else {
ERROR_LOG_REPORT(JIT, "Reg %i not in arm64 reg", mipsReg);
return INVALID_REG; // BAAAD
}
}
ARM64Reg Arm64IRRegCache::R64(IRReg mipsReg) {
return EncodeRegTo64(R(mipsReg));
}
ARM64Reg Arm64IRRegCache::RPtr(IRReg mipsReg) {
_dbg_assert_(IsValidGPR(mipsReg));
_dbg_assert_(mr[mipsReg].loc == MIPSLoc::REG || mr[mipsReg].loc == MIPSLoc::REG_IMM || mr[mipsReg].loc == MIPSLoc::REG_AS_PTR);
if (mr[mipsReg].loc == MIPSLoc::REG_AS_PTR) {
return FromNativeReg64(mr[mipsReg].nReg);
} else if (mr[mipsReg].loc == MIPSLoc::REG || mr[mipsReg].loc == MIPSLoc::REG_IMM) {
int r = mr[mipsReg].nReg;
_dbg_assert_(nr[r].pointerified);
if (nr[r].pointerified) {
return FromNativeReg64(mr[mipsReg].nReg);
} else {
ERROR_LOG(JIT, "Tried to use a non-pointer register as a pointer");
return INVALID_REG;
}
} else {
ERROR_LOG_REPORT(JIT, "Reg %i not in arm64 reg", mipsReg);
return INVALID_REG; // BAAAD
}
}
ARM64Reg Arm64IRRegCache::F(IRReg mipsReg) {
_dbg_assert_(IsValidFPR(mipsReg));
_dbg_assert_(mr[mipsReg + 32].loc == MIPSLoc::FREG);
if (mr[mipsReg + 32].loc == MIPSLoc::FREG) {
return FromNativeReg(mr[mipsReg + 32].nReg);
} else {
ERROR_LOG_REPORT(JIT, "Reg %i not in arm64 reg", mipsReg);
return INVALID_REG; // BAAAD
}
}
ARM64Reg Arm64IRRegCache::FD(IRReg mipsReg) {
return EncodeRegToDouble(F(mipsReg));
}
ARM64Reg Arm64IRRegCache::FQ(IRReg mipsReg) {
return EncodeRegToQuad(F(mipsReg));
}
IRNativeReg Arm64IRRegCache::GPRToNativeReg(ARM64Reg r) {
_dbg_assert_msg_(r >= 0 && r < 0x40, "Not a GPR?");
return (IRNativeReg)DecodeReg(r);
}
IRNativeReg Arm64IRRegCache::VFPToNativeReg(ARM64Reg r) {
_dbg_assert_msg_(r >= 0x40 && r < 0xE0, "Not VFP?");
return (IRNativeReg)(NUM_X_REGS + (int)DecodeReg(r));
}
ARM64Reg Arm64IRRegCache::FromNativeReg(IRNativeReg r) {
if (r >= NUM_X_REGS)
return EncodeRegToSingle((Arm64Gen::ARM64Reg)r);
return (Arm64Gen::ARM64Reg)r;
}
ARM64Reg Arm64IRRegCache::FromNativeReg64(IRNativeReg r) {
_dbg_assert_msg_(r >= 0 && r < NUM_X_REGS, "Not a GPR?");
return EncodeRegTo64((Arm64Gen::ARM64Reg)r);
}
#endif
+109
View File
@@ -0,0 +1,109 @@
// Copyright (c) 2023- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#pragma once
#include "ppsspp_config.h"
// In other words, PPSSPP_ARCH(ARM64) || DISASM_ALL.
#if PPSSPP_ARCH(ARM64) || (PPSSPP_PLATFORM(WINDOWS) && !defined(__LIBRETRO__))
#include "Common/Arm64Emitter.h"
#include "Core/MIPS/MIPS.h"
#include "Core/MIPS/IR/IRJit.h"
#include "Core/MIPS/IR/IRRegCache.h"
namespace Arm64IRJitConstants {
const Arm64Gen::ARM64Reg DOWNCOUNTREG = Arm64Gen::W25;
// Note: this is actually offset from the base.
const Arm64Gen::ARM64Reg JITBASEREG = Arm64Gen::X26;
const Arm64Gen::ARM64Reg CTXREG = Arm64Gen::X27;
const Arm64Gen::ARM64Reg MEMBASEREG = Arm64Gen::X28;
const Arm64Gen::ARM64Reg SCRATCH1_64 = Arm64Gen::X16;
const Arm64Gen::ARM64Reg SCRATCH2_64 = Arm64Gen::X17;
const Arm64Gen::ARM64Reg SCRATCH1 = Arm64Gen::W16;
const Arm64Gen::ARM64Reg SCRATCH2 = Arm64Gen::W17;
// TODO: How many do we actually need?
const Arm64Gen::ARM64Reg SCRATCHF1 = Arm64Gen::S0;
const Arm64Gen::ARM64Reg SCRATCHF2 = Arm64Gen::S1;
const Arm64Gen::ARM64Reg SCRATCHF3 = Arm64Gen::S2;
const Arm64Gen::ARM64Reg SCRATCHF4 = Arm64Gen::S3;
} // namespace X64IRJitConstants
class Arm64IRRegCache : public IRNativeRegCacheBase {
public:
Arm64IRRegCache(MIPSComp::JitOptions *jo);
void Init(Arm64Gen::ARM64XEmitter *emitter, Arm64Gen::ARM64FloatEmitter *fp);
// May fail and return INVALID_REG if it needs flushing.
Arm64Gen::ARM64Reg TryMapTempImm(IRReg reg);
// Returns an arm64 register containing the requested MIPS register.
Arm64Gen::ARM64Reg MapGPR(IRReg reg, MIPSMap mapFlags = MIPSMap::INIT);
Arm64Gen::ARM64Reg MapGPR2(IRReg reg, MIPSMap mapFlags = MIPSMap::INIT);
Arm64Gen::ARM64Reg MapGPRAsPointer(IRReg reg);
Arm64Gen::ARM64Reg MapFPR(IRReg reg, MIPSMap mapFlags = MIPSMap::INIT);
Arm64Gen::ARM64Reg MapVec4(IRReg first, MIPSMap mapFlags = MIPSMap::INIT);
Arm64Gen::ARM64Reg MapWithFPRTemp(const IRInst &inst);
void FlushBeforeCall();
void FlushAll(bool gprs = true, bool fprs = true) override;
Arm64Gen::ARM64Reg GetAndLockTempGPR();
Arm64Gen::ARM64Reg GetAndLockTempFPR();
Arm64Gen::ARM64Reg R(IRReg preg); // Returns a cached register, while checking that it's NOT mapped as a pointer
Arm64Gen::ARM64Reg R64(IRReg preg);
Arm64Gen::ARM64Reg RPtr(IRReg preg); // Returns a cached register, if it has been mapped as a pointer
Arm64Gen::ARM64Reg F(IRReg preg);
Arm64Gen::ARM64Reg FD(IRReg preg);
Arm64Gen::ARM64Reg FQ(IRReg preg);
// These are called once on startup to generate functions, that you should then call.
void EmitLoadStaticRegisters();
void EmitSaveStaticRegisters();
protected:
const StaticAllocation *GetStaticAllocations(int &count) const override;
const int *GetAllocationOrder(MIPSLoc type, MIPSMap flags, int &count, int &base) const override;
void AdjustNativeRegAsPtr(IRNativeReg nreg, bool state) override;
bool IsNativeRegCompatible(IRNativeReg nreg, MIPSLoc type, MIPSMap flags) override;
void LoadNativeReg(IRNativeReg nreg, IRReg first, int lanes) override;
void StoreNativeReg(IRNativeReg nreg, IRReg first, int lanes) override;
void SetNativeRegValue(IRNativeReg nreg, uint32_t imm) override;
void StoreRegValue(IRReg mreg, uint32_t imm) override;
private:
IRNativeReg GPRToNativeReg(Arm64Gen::ARM64Reg r);
IRNativeReg VFPToNativeReg(Arm64Gen::ARM64Reg r);
Arm64Gen::ARM64Reg FromNativeReg(IRNativeReg r);
Arm64Gen::ARM64Reg FromNativeReg64(IRNativeReg r);
Arm64Gen::ARM64XEmitter *emit_ = nullptr;
Arm64Gen::ARM64FloatEmitter *fp_ = nullptr;
enum {
NUM_X_REGS = 32,
NUM_X_FREGS = 32,
};
};
#endif
+5 -5
View File
@@ -1196,20 +1196,20 @@ namespace MIPSComp {
ir.Write(IROp::FCvtScaledWS, dregs[i], sregs[i], imm | (rmode << 6));
} else {
for (int i = 0; i < n; i++) {
switch (rmode) {
case 0: // vf2in
switch (IRRoundMode(rmode)) {
case IRRoundMode::RINT_0: // vf2in
ir.Write(IROp::FRound, dregs[i], sregs[i]);
break;
case 1: // vf2iz
case IRRoundMode::CAST_1: // vf2iz
ir.Write(IROp::FTrunc, dregs[i], sregs[i]);
break;
case 2: // vf2iu
case IRRoundMode::CEIL_2: // vf2iu
ir.Write(IROp::FCeil, dregs[i], sregs[i]);
break;
case 3: // vf2id
case IRRoundMode::FLOOR_3: // vf2id
ir.Write(IROp::FFloor, dregs[i], sregs[i]);
break;
+35 -15
View File
@@ -34,7 +34,6 @@ namespace MIPSComp {
IRFrontend::IRFrontend(bool startDefaultPrefix) {
js.startDefaultPrefix = startDefaultPrefix;
js.hasSetRounding = false;
// js.currentRoundingFunc = convertS0ToSCRATCH1[0];
// The debugger sets this so that "go" on a breakpoint will actually... go.
// But if they reset, we can end up hitting it by mistake, since it's based on PC and ticks.
@@ -281,6 +280,7 @@ void IRFrontend::DoJit(u32 em_address, std::vector<IRInst> &instructions, u32 &m
&OptimizeFPMoves,
&PropagateConstants,
&PurgeTemps,
&ReduceVec4Flush,
// &ReorderLoadStore,
// &MergeLoadStore,
// &ThreeOpToTwoOp,
@@ -339,16 +339,27 @@ void IRFrontend::CheckBreakpoint(u32 addr) {
if (CBreakPoints::IsAddressBreakPoint(addr)) {
FlushAll();
if (GetCompilerPC() != js.blockStart)
ir.Write(IROp::SetPCConst, 0, ir.AddConstant(GetCompilerPC()));
RestoreRoundingMode();
ir.Write(IROp::SetPCConst, 0, ir.AddConstant(GetCompilerPC()));
// 0 because we normally execute before increasing.
// TODO: In likely branches, downcount will be incorrect.
int downcountOffset = js.inDelaySlot && js.downcountAmount >= 2 ? -2 : 0;
// At this point, downcount HAS the delay slot, but not the instruction itself.
int downcountOffset = 0;
if (js.inDelaySlot) {
MIPSOpcode branchOp = Memory::Read_Opcode_JIT(GetCompilerPC());
MIPSOpcode delayOp = Memory::Read_Opcode_JIT(addr);
downcountOffset = -MIPSGetInstructionCycleEstimate(delayOp);
if ((MIPSGetInfo(branchOp) & LIKELY) != 0) {
// Okay, we're in a likely branch. Also negate the branch cycles.
downcountOffset += -MIPSGetInstructionCycleEstimate(branchOp);
}
}
int downcountAmount = js.downcountAmount + downcountOffset;
ir.Write(IROp::Downcount, 0, ir.AddConstant(downcountAmount));
if (downcountAmount != 0)
ir.Write(IROp::Downcount, 0, ir.AddConstant(downcountAmount));
// Note that this means downcount can't be metadata on the block.
js.downcountAmount = -downcountOffset;
ir.Write(IROp::Breakpoint);
ir.Write(IROp::Breakpoint, 0, ir.AddConstant(addr));
ApplyRoundingMode();
js.hadBreakpoints = true;
@@ -359,19 +370,28 @@ void IRFrontend::CheckMemoryBreakpoint(int rs, int offset) {
if (CBreakPoints::HasMemChecks()) {
FlushAll();
if (GetCompilerPC() != js.blockStart)
ir.Write(IROp::SetPCConst, 0, ir.AddConstant(GetCompilerPC()));
RestoreRoundingMode();
ir.Write(IROp::SetPCConst, 0, ir.AddConstant(GetCompilerPC()));
// 0 because we normally execute before increasing.
int downcountOffset = js.inDelaySlot ? -2 : -1;
// TODO: In likely branches, downcount will be incorrect. This might make resume fail.
if (js.downcountAmount == 0) {
downcountOffset = 0;
// At this point, downcount HAS the delay slot, but not the instruction itself.
int downcountOffset = 0;
if (js.inDelaySlot) {
// We assume delay slot in compilerPC + 4.
MIPSOpcode branchOp = Memory::Read_Opcode_JIT(GetCompilerPC());
MIPSOpcode delayOp = Memory::Read_Opcode_JIT(GetCompilerPC() + 4);
downcountOffset = -MIPSGetInstructionCycleEstimate(delayOp);
if ((MIPSGetInfo(branchOp) & LIKELY) != 0) {
// Okay, we're in a likely branch. Also negate the branch cycles.
downcountOffset += -MIPSGetInstructionCycleEstimate(branchOp);
}
}
int downcountAmount = js.downcountAmount + downcountOffset;
ir.Write(IROp::Downcount, 0, ir.AddConstant(downcountAmount));
if (downcountAmount != 0)
ir.Write(IROp::Downcount, 0, ir.AddConstant(downcountAmount));
// Note that this means downcount can't be metadata on the block.
js.downcountAmount = -downcountOffset;
ir.Write(IROp::MemoryCheck, 0, rs, ir.AddConstant(offset));
ir.Write(IROp::MemoryCheck, js.inDelaySlot ? 4 : 0, rs, ir.AddConstant(offset));
ApplyRoundingMode();
js.hadBreakpoints = true;
+4 -4
View File
@@ -147,8 +147,8 @@ static const IRMeta irMeta[] = {
{ IROp::Vec2ClampToZero, "Vec2ClampToZero", "22" },
{ IROp::Vec4Pack32To8, "Vec4Pack32To8", "FV" },
{ IROp::Vec4Pack31To8, "Vec4Pack31To8", "FV" },
{ IROp::Vec2Pack32To16, "Vec2Pack32To16", "2V" },
{ IROp::Vec2Pack31To16, "Vec2Pack31To16", "2V" },
{ IROp::Vec2Pack32To16, "Vec2Pack32To16", "F2" },
{ IROp::Vec2Pack31To16, "Vec2Pack31To16", "F2" },
{ IROp::Interpret, "Interpret", "_C", IRFLAG_BARRIER },
{ IROp::Downcount, "Downcount", "_C" },
@@ -166,8 +166,8 @@ static const IRMeta irMeta[] = {
{ IROp::SetPC, "SetPC", "_G" },
{ IROp::SetPCConst, "SetPC", "_C" },
{ IROp::CallReplacement, "CallRepl", "_C", IRFLAG_BARRIER },
{ IROp::Breakpoint, "Breakpoint", "", IRFLAG_BARRIER },
{ IROp::MemoryCheck, "MemoryCheck", "_GC", IRFLAG_BARRIER },
{ IROp::Breakpoint, "Breakpoint", "_C", IRFLAG_BARRIER },
{ IROp::MemoryCheck, "MemoryCheck", "IGC", IRFLAG_BARRIER },
{ IROp::ValidateAddress8, "ValidAddr8", "_GC", IRFLAG_BARRIER },
{ IROp::ValidateAddress16, "ValidAddr16", "_GC", IRFLAG_BARRIER },
+7
View File
@@ -252,6 +252,13 @@ enum class Vec4Init {
Set_0001,
};
enum class IRRoundMode : uint8_t {
RINT_0 = 0,
CAST_1 = 1,
CEIL_2 = 2,
FLOOR_3 = 3,
};
// Hm, unused
inline IRComparison Invert(IRComparison comp) {
switch (comp) {
+28 -18
View File
@@ -60,20 +60,30 @@ alignas(16) static const uint32_t lowBytesMask[4] = {
0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF,
};
u32 RunBreakpoint(u32 pc) {
u32 IRRunBreakpoint(u32 pc) {
// Should we skip this breakpoint?
if (CBreakPoints::CheckSkipFirst() == pc)
uint32_t skipFirst = CBreakPoints::CheckSkipFirst();
if (skipFirst == pc || skipFirst == currentMIPS->pc)
return 0;
CBreakPoints::ExecBreakPoint(currentMIPS->pc);
// Did we already hit one?
if (coreState != CORE_RUNNING && coreState != CORE_NEXTFRAME)
return 1;
CBreakPoints::ExecBreakPoint(pc);
return coreState != CORE_RUNNING ? 1 : 0;
}
u32 RunMemCheck(u32 pc, u32 addr) {
u32 IRRunMemCheck(u32 pc, u32 addr) {
// Should we skip this breakpoint?
if (CBreakPoints::CheckSkipFirst() == pc)
uint32_t skipFirst = CBreakPoints::CheckSkipFirst();
if (skipFirst == pc || skipFirst == currentMIPS->pc)
return 0;
// Did we already hit one?
if (coreState != CORE_RUNNING && coreState != CORE_NEXTFRAME)
return 1;
CBreakPoints::ExecOpMemCheck(addr, pc);
return coreState != CORE_RUNNING ? 1 : 0;
}
@@ -966,11 +976,11 @@ u32 IRInterpret(MIPSState *mips, const IRInst *inst, int count) {
mips->fs[inst->dest] = my_isinf(src) && src < 0.0f ? -2147483648LL : 2147483647LL;
break;
}
switch (mips->fcr31 & 3) {
case 0: mips->fs[inst->dest] = (int)round_ieee_754(src); break; // RINT_0
case 1: mips->fs[inst->dest] = (int)src; break; // CAST_1
case 2: mips->fs[inst->dest] = (int)ceilf(src); break; // CEIL_2
case 3: mips->fs[inst->dest] = (int)floorf(src); break; // FLOOR_3
switch (IRRoundMode(mips->fcr31 & 3)) {
case IRRoundMode::RINT_0: mips->fs[inst->dest] = (int)round_ieee_754(src); break;
case IRRoundMode::CAST_1: mips->fs[inst->dest] = (int)src; break;
case IRRoundMode::CEIL_2: mips->fs[inst->dest] = (int)ceilf(src); break;
case IRRoundMode::FLOOR_3: mips->fs[inst->dest] = (int)floorf(src); break;
}
break; //cvt.w.s
}
@@ -994,11 +1004,11 @@ u32 IRInterpret(MIPSState *mips, const IRInst *inst, int count) {
} else if (sv <= (double)(int)0x80000000) {
mips->fs[inst->dest] = 0x80000000;
} else {
switch (inst->src2 >> 6) {
case 0: mips->fs[inst->dest] = (int)round_ieee_754(sv); break;
case 1: mips->fs[inst->dest] = src >= 0 ? (int)floor(sv) : (int)ceil(sv); break;
case 2: mips->fs[inst->dest] = (int)ceil(sv); break;
case 3: mips->fs[inst->dest] = (int)floor(sv); break;
switch (IRRoundMode(inst->src2 >> 6)) {
case IRRoundMode::RINT_0: mips->fs[inst->dest] = (int)round_ieee_754(sv); break;
case IRRoundMode::CAST_1: mips->fs[inst->dest] = src >= 0 ? (int)floor(sv) : (int)ceil(sv); break;
case IRRoundMode::CEIL_2: mips->fs[inst->dest] = (int)ceil(sv); break;
case IRRoundMode::FLOOR_3: mips->fs[inst->dest] = (int)floor(sv); break;
}
}
break;
@@ -1043,7 +1053,7 @@ u32 IRInterpret(MIPSState *mips, const IRInst *inst, int count) {
break;
case IROp::Downcount:
mips->downcount -= inst->constant;
mips->downcount -= (int)inst->constant;
break;
case IROp::SetPC:
@@ -1100,14 +1110,14 @@ u32 IRInterpret(MIPSState *mips, const IRInst *inst, int count) {
break;
case IROp::Breakpoint:
if (RunBreakpoint(mips->pc)) {
if (IRRunBreakpoint(inst->constant)) {
CoreTiming::ForceCheck();
return mips->pc;
}
break;
case IROp::MemoryCheck:
if (RunMemCheck(mips->pc, mips->r[inst->src1] + inst->constant)) {
if (IRRunMemCheck(mips->pc + inst->dest, mips->r[inst->src1] + inst->constant)) {
CoreTiming::ForceCheck();
return mips->pc;
}
+3
View File
@@ -20,4 +20,7 @@ inline static u32 ReverseBits32(u32 v) {
return v;
}
u32 IRRunBreakpoint(u32 pc);
u32 IRRunMemCheck(u32 pc, u32 addr);
u32 IRInterpret(MIPSState *ms, const IRInst *inst, int count);
+4
View File
@@ -490,6 +490,10 @@ const u8 *IRNativeJit::GetCrashHandler() const {
return backend_->GetNativeHooks().crashHandler;
}
void IRNativeJit::UpdateFCR31() {
backend_->UpdateFCR31(mips_);
}
JitBlockCacheDebugInterface *IRNativeJit::GetBlockCacheDebugInterface() {
return &debugInterface_;
}
+4
View File
@@ -59,6 +59,8 @@ public:
virtual void InvalidateBlock(IRBlock *block, int block_num) = 0;
void FinalizeBlock(IRBlock *block, int block_num, const JitOptions &jo);
virtual void UpdateFCR31(MIPSState *mipsState) {}
const IRNativeHooks &GetNativeHooks() const {
return hooks_;
}
@@ -168,6 +170,8 @@ public:
const u8 *GetDispatcher() const override;
const u8 *GetCrashHandler() const override;
void UpdateFCR31() override;
JitBlockCacheDebugInterface *GetBlockCacheDebugInterface() override;
protected:
+278
View File
@@ -6,6 +6,7 @@
#include "Common/Data/Convert/SmallDataConvert.h"
#include "Common/Log.h"
#include "Core/Config.h"
#include "Core/MIPS/MIPSVFPUUtils.h"
#include "Core/MIPS/IR/IRAnalysis.h"
#include "Core/MIPS/IR/IRInterpreter.h"
#include "Core/MIPS/IR/IRPassSimplify.h"
@@ -1874,3 +1875,280 @@ bool ApplyMemoryValidation(const IRWriter &in, IRWriter &out, const IROptions &o
}
return logBlocks;
}
bool ReduceVec4Flush(const IRWriter &in, IRWriter &out, const IROptions &opts) {
CONDITIONAL_DISABLE;
// Only do this when using a SIMD backend.
if (!opts.preferVec4) {
DISABLE;
}
bool isVec4[256]{};
bool isUsed[256]{};
bool isVec4Dirty[256]{};
auto updateVec4 = [&](char type, IRReg r) {
bool downgraded = false;
switch (type) {
case 'F':
downgraded = isVec4[r & ~3];
isVec4[r & ~3] = false;
isUsed[r] = true;
break;
case 'V':
_dbg_assert_((r & 3) == 0);
isVec4[r] = true;
for (int i = 0; i < 4; ++i)
isUsed[r + i] = true;
break;
case '2':
downgraded = isVec4[r & ~3];
isVec4[r & ~3] = false;
for (int i = 0; i < 2; ++i)
isUsed[r + i] = true;
break;
default:
break;
}
return downgraded;
};
auto updateVec4Dest = [&](char type, IRReg r, uint32_t flags) {
if ((flags & IRFLAG_SRC3) == 0) {
switch (type) {
case 'F':
isVec4Dirty[r & ~3] = false;
break;
case 'V':
_dbg_assert_((r & 3) == 0);
isVec4Dirty[r] = true;
break;
case '2':
isVec4Dirty[r & ~3] = false;
break;
default:
break;
}
}
return updateVec4(type, r);
};
// Checks overlap from r1 to other params.
auto overlapped = [](IRReg r1, int l1, IRReg r2, int l2, IRReg r3 = IRREG_INVALID, int l3 = 0) {
if (r1 < r2 + l2 && r1 + l1 > r2)
return true;
if (r1 < r3 + l3 && r1 + l1 > r3)
return true;
return false;
};
bool logBlocks = false;
int inCount = (int)in.GetInstructions().size();
for (int i = 0; i < inCount; ++i) {
IRInst inst = in.GetInstructions()[i];
const IRMeta *m = GetIRMeta(inst.op);
if ((m->flags & (IRFLAG_EXIT | IRFLAG_BARRIER)) != 0) {
memset(isVec4, 0, sizeof(isVec4));
out.Write(inst);
continue;
}
IRReg temp = IRREG_INVALID;
auto findAvailTempVec4 = [&]() {
// If it's not used yet in this block, we can use it.
// Note: even if the instruction uses it to write, that should be fine.
for (IRReg r = IRVTEMP_PFX_S; r < IRVTEMP_0 + 4; r += 4) {
if (isUsed[r])
continue;
bool usable = true;
for (int j = 1; j < 4; ++j)
usable = usable && !isUsed[r + j];
if (usable) {
temp = r;
// We don't update isUsed because our temporary doesn't need to last.
return true;
}
}
return false;
};
auto usedLaterAsVec4 = [&](IRReg r) {
for (int j = i + 1; j < inCount; ++j) {
IRInst inst = in.GetInstructions()[j];
const IRMeta *m = GetIRMeta(inst.op);
if (m->types[0] == 'V' && inst.dest == r)
return true;
if (m->types[1] == 'V' && inst.src1 == r)
return true;
if (m->types[2] == 'V' && inst.src2 == r)
return true;
}
return false;
};
bool skip = false;
switch (inst.op) {
case IROp::SetConstF:
if (isVec4[inst.dest & ~3] && findAvailTempVec4()) {
// Check if we're setting multiple in a row, this is a bit common.
u8 blendMask = 1 << (inst.dest & 3);
while (i + 1 < inCount) {
IRInst next = in.GetInstructions()[i + 1];
if (next.op != IROp::SetConstF || (next.dest & ~3) != (inst.dest & ~3))
break;
if (next.constant != inst.constant)
break;
blendMask |= 1 << (next.dest & 3);
i++;
}
if (inst.constant == 0) {
out.Write(IROp::Vec4Init, temp, (int)Vec4Init::AllZERO);
} else if (inst.constant == 0x3F800000) {
out.Write(IROp::Vec4Init, temp, (int)Vec4Init::AllONE);
} else if (inst.constant == 0xBF800000) {
out.Write(IROp::Vec4Init, temp, (int)Vec4Init::AllMinusONE);
} else {
out.Write(IROp::SetConstF, temp, out.AddConstant(inst.constant));
out.Write(IROp::Vec4Shuffle, temp, temp, 0);
}
out.Write(IROp::Vec4Blend, inst.dest & ~3, inst.dest & ~3, temp, blendMask);
isVec4Dirty[inst.dest & ~3] = true;
continue;
}
break;
case IROp::FMovFromGPR:
if (isVec4[inst.dest & ~3] && findAvailTempVec4()) {
u8 blendMask = 1 << (inst.dest & 3);
out.Write(IROp::FMovFromGPR, temp, inst.src1);
out.Write(IROp::Vec4Shuffle, temp, temp, 0);
out.Write(IROp::Vec4Blend, inst.dest & ~3, inst.dest & ~3, temp, blendMask);
isVec4Dirty[inst.dest & ~3] = true;
continue;
}
break;
case IROp::LoadFloat:
if (isVec4[inst.dest & ~3] && isVec4Dirty[inst.dest & ~3] && usedLaterAsVec4(inst.dest & ~3) && findAvailTempVec4()) {
u8 blendMask = 1 << (inst.dest & 3);
out.Write(inst.op, temp, inst.src1, inst.src2, inst.constant);
out.Write(IROp::Vec4Shuffle, temp, temp, 0);
out.Write(IROp::Vec4Blend, inst.dest & ~3, inst.dest & ~3, temp, blendMask);
isVec4Dirty[inst.dest & ~3] = true;
continue;
}
break;
case IROp::StoreFloat:
if (isVec4[inst.src3 & ~3] && isVec4Dirty[inst.src3 & ~3] && usedLaterAsVec4(inst.src3 & ~3) && findAvailTempVec4()) {
out.Write(IROp::FMov, temp, inst.src3, 0);
out.Write(inst.op, temp, inst.src1, inst.src2, inst.constant);
continue;
}
break;
case IROp::FMov:
if (isVec4[inst.dest & ~3] && (inst.dest & ~3) == (inst.src1 & ~3)) {
// Oh, actually a shuffle?
uint8_t shuffle = (uint8_t)VFPU_SWIZZLE(0, 1, 2, 3);
uint8_t destShift = (inst.dest & 3) * 2;
shuffle = (shuffle & ~(3 << destShift)) | ((inst.src1 & 3) << destShift);
out.Write(IROp::Vec4Shuffle, inst.dest & ~3, inst.dest & ~3, shuffle);
isVec4Dirty[inst.dest & ~3] = true;
continue;
} else if (isVec4[inst.dest & ~3] && (inst.dest & 3) == (inst.src1 & 3)) {
// We can turn this directly into a blend, since it's the same lane.
out.Write(IROp::Vec4Blend, inst.dest & ~3, inst.dest & ~3, inst.src1 & ~3, 1 << (inst.dest & 3));
isVec4Dirty[inst.dest & ~3] = true;
continue;
} else if (isVec4[inst.dest & ~3] && isVec4[inst.src1 & ~3] && findAvailTempVec4()) {
// For this, we'll need a temporary to move to the right lane.
int lane = inst.src1 & 3;
uint8_t shuffle = (uint8_t)VFPU_SWIZZLE(lane, lane, lane, lane);
out.Write(IROp::Vec4Shuffle, temp, inst.src1 & ~3, shuffle);
out.Write(IROp::Vec4Blend, inst.dest & ~3, inst.dest & ~3, temp, 1 << (inst.dest & 3));
isVec4Dirty[inst.dest & ~3] = true;
continue;
}
break;
case IROp::FAdd:
case IROp::FSub:
case IROp::FMul:
case IROp::FDiv:
if (isVec4[inst.dest & ~3] && isVec4Dirty[inst.dest & ~3] && usedLaterAsVec4(inst.dest & ~3)) {
if (!overlapped(inst.dest & ~3, 4, inst.src1, 1, inst.src2, 1) && findAvailTempVec4()) {
u8 blendMask = 1 << (inst.dest & 3);
out.Write(inst.op, temp, inst.src1, inst.src2);
out.Write(IROp::Vec4Shuffle, temp, temp, 0);
out.Write(IROp::Vec4Blend, inst.dest & ~3, inst.dest & ~3, temp, blendMask);
updateVec4('F', inst.src1);
updateVec4('F', inst.src2);
isVec4Dirty[inst.dest & ~3] = true;
continue;
}
}
break;
case IROp::Vec4Dot:
if (overlapped(inst.dest, 1, inst.src1, 4, inst.src2, 4) && findAvailTempVec4()) {
out.Write(inst.op, temp, inst.src1, inst.src2, inst.constant);
if (usedLaterAsVec4(inst.dest & ~3)) {
out.Write(IROp::Vec4Shuffle, temp, inst.src1 & ~3, 0);
out.Write(IROp::Vec4Blend, inst.dest & ~3, inst.dest & ~3, temp, 1 << (inst.dest & 3));
// It's overlapped, so it'll get marked as Vec4 and used anyway.
isVec4Dirty[inst.dest & ~3] = true;
inst.dest = IRREG_INVALID;
} else {
out.Write(IROp::FMov, inst.dest, temp);
}
skip = true;
}
break;
case IROp::Vec4Scale:
if (overlapped(inst.src2, 1, inst.src1, 4, inst.dest, 4) && findAvailTempVec4()) {
out.Write(IROp::FMov, temp, inst.src2);
out.Write(inst.op, inst.dest, inst.src1, temp, inst.constant);
skip = true;
inst.src2 = IRREG_INVALID;
} else if (isVec4[inst.src2 & 3] && usedLaterAsVec4(inst.src2 & ~3) && findAvailTempVec4()) {
out.Write(IROp::FMov, temp, inst.src2);
out.Write(inst.op, inst.dest, inst.src1, temp, inst.constant);
skip = true;
inst.src2 = IRREG_INVALID;
}
break;
default:
break;
}
bool downgrade = false;
if (inst.src1 != IRREG_INVALID && updateVec4(m->types[1], inst.src1))
downgrade = true;
if (inst.src2 != IRREG_INVALID && updateVec4(m->types[2], inst.src2))
downgrade = true;
if (inst.dest != IRREG_INVALID && updateVec4Dest(m->types[0], inst.dest, m->flags))
downgrade = true;
if (downgrade) {
//WARN_LOG(JIT, "Vec4 downgrade by: %s", m->name);
}
if (!skip)
out.Write(inst);
}
return logBlocks;
}
+1
View File
@@ -15,3 +15,4 @@ bool OptimizeFPMoves(const IRWriter &in, IRWriter &out, const IROptions &opts);
bool ReorderLoadStore(const IRWriter &in, IRWriter &out, const IROptions &opts);
bool MergeLoadStore(const IRWriter &in, IRWriter &out, const IROptions &opts);
bool ApplyMemoryValidation(const IRWriter &in, IRWriter &out, const IROptions &opts);
bool ReduceVec4Flush(const IRWriter &in, IRWriter &out, const IROptions &opts);
+51 -13
View File
@@ -404,6 +404,52 @@ IRNativeReg IRNativeRegCacheBase::FindFreeReg(MIPSLoc type, MIPSMap flags) const
return -1;
}
bool IRNativeRegCacheBase::IsGPRClobbered(IRReg gpr) const {
_dbg_assert_(IsValidGPR(gpr));
return IsRegClobbered(MIPSLoc::REG, MIPSMap::INIT, gpr);
}
bool IRNativeRegCacheBase::IsFPRClobbered(IRReg fpr) const {
_dbg_assert_(IsValidFPR(fpr));
return IsRegClobbered(MIPSLoc::FREG, MIPSMap::INIT, fpr + 32);
}
IRUsage IRNativeRegCacheBase::GetNextRegUsage(const IRSituation &info, MIPSLoc type, IRReg r) const {
if (type == MIPSLoc::REG)
return IRNextGPRUsage(r, info);
else if (type == MIPSLoc::FREG || type == MIPSLoc::VREG)
return IRNextFPRUsage(r - 32, info);
_assert_msg_(false, "Unknown spill allocation type");
return IRUsage::UNKNOWN;
}
bool IRNativeRegCacheBase::IsRegClobbered(MIPSLoc type, MIPSMap flags, IRReg r) const {
static const int UNUSED_LOOKAHEAD_OPS = 30;
IRSituation info;
info.lookaheadCount = UNUSED_LOOKAHEAD_OPS;
// We look starting one ahead, unlike spilling. We want to know if it clobbers later.
info.currentIndex = irIndex_ + 1;
info.instructions = irBlock_->GetInstructions();
info.numInstructions = irBlock_->GetNumInstructions();
// Make sure we're on the first one if this is multi-lane.
IRReg first = r;
if (mr[r].lane != -1)
first -= mr[r].lane;
IRUsage usage = GetNextRegUsage(info, type, first);
if (usage == IRUsage::CLOBBERED) {
// If multiple mips regs use this native reg (i.e. vector, HI/LO), check each.
bool canClobber = true;
for (IRReg m = first + 1; mr[m].nReg == mr[first].nReg && m < IRREG_INVALID && canClobber; ++m)
canClobber = GetNextRegUsage(info, type, m) == IRUsage::CLOBBERED;
return canClobber;
}
return false;
}
IRNativeReg IRNativeRegCacheBase::FindBestToSpill(MIPSLoc type, MIPSMap flags, bool unusedOnly, bool *clobbered) const {
int allocCount = 0, base = 0;
const int *allocOrder = GetAllocationOrder(type, flags, allocCount, base);
@@ -416,15 +462,6 @@ IRNativeReg IRNativeRegCacheBase::FindBestToSpill(MIPSLoc type, MIPSMap flags, b
info.instructions = irBlock_->GetInstructions();
info.numInstructions = irBlock_->GetNumInstructions();
auto getUsage = [type, &info](IRReg mipsReg) {
if (type == MIPSLoc::REG)
return IRNextGPRUsage(mipsReg, info);
else if (type == MIPSLoc::FREG || type == MIPSLoc::VREG)
return IRNextFPRUsage(mipsReg - 32, info);
_assert_msg_(false, "Unknown spill allocation type");
return IRUsage::UNKNOWN;
};
*clobbered = false;
for (int i = 0; i < allocCount; i++) {
IRNativeReg nreg = IRNativeReg(allocOrder[i] - base);
@@ -435,7 +472,7 @@ IRNativeReg IRNativeRegCacheBase::FindBestToSpill(MIPSLoc type, MIPSMap flags, b
// As it's in alloc-order, we know it's not static so we don't need to check for that.
IRReg mipsReg = nr[nreg].mipsReg;
IRUsage usage = getUsage(mipsReg);
IRUsage usage = GetNextRegUsage(info, type, mipsReg);
// Awesome, a clobbered reg. Let's use it?
if (usage == IRUsage::CLOBBERED) {
@@ -443,7 +480,7 @@ IRNativeReg IRNativeRegCacheBase::FindBestToSpill(MIPSLoc type, MIPSMap flags, b
// Note: mipsReg points to the lowest numbered IRReg.
bool canClobber = true;
for (IRReg m = mipsReg + 1; mr[m].nReg == nreg && m < IRREG_INVALID && canClobber; ++m)
canClobber = getUsage(m) == IRUsage::CLOBBERED;
canClobber = GetNextRegUsage(info, type, m) == IRUsage::CLOBBERED;
// Okay, if all can be clobbered, we're good to go.
if (canClobber) {
@@ -747,10 +784,11 @@ void IRNativeRegCacheBase::ApplyMapping(const Mapping *mapping, int count) {
return;
}
bool mapSIMD = config_.mapFPUSIMD || mapping[i].type == 'G';
MIPSMap flags = mapping[i].flags;
for (int j = 0; j < count; ++j) {
if (mapping[j].type == mapping[i].type && mapping[j].reg == mapping[i].reg && i != j) {
_assert_msg_(mapping[j].lanes == mapping[i].lanes, "Lane aliasing not supported yet");
_assert_msg_(!mapSIMD || mapping[j].lanes == mapping[i].lanes, "Lane aliasing not supported yet");
if (!isNoinit(mapping[j].flags) && isNoinit(flags)) {
flags = (flags & MIPSMap::BACKEND_MASK) | MIPSMap::DIRTY;
@@ -758,7 +796,7 @@ void IRNativeRegCacheBase::ApplyMapping(const Mapping *mapping, int count) {
}
}
if (config_.mapFPUSIMD || mapping[i].type == 'G') {
if (mapSIMD) {
MapNativeReg(type, mapping[i].reg, mapping[i].lanes, flags);
return;
}
+7
View File
@@ -22,6 +22,7 @@
#include "Common/CommonTypes.h"
#include "Core/MIPS/MIPS.h"
#include "Core/MIPS/IR/IRAnalysis.h"
#include "Core/MIPS/IR/IRInst.h"
@@ -183,6 +184,9 @@ public:
void MarkGPRDirty(IRReg gpr, bool andNormalized32 = false);
void MarkGPRAsPointerDirty(IRReg gpr);
bool IsGPRClobbered(IRReg gpr) const;
bool IsFPRClobbered(IRReg gpr) const;
struct Mapping {
char type = '?';
IRReg reg = IRREG_INVALID;
@@ -234,6 +238,9 @@ protected:
void SetSpillLockIRIndex(IRReg reg, int index);
int GetMipsRegOffset(IRReg r);
bool IsRegClobbered(MIPSLoc type, MIPSMap flags, IRReg r) const;
IRUsage GetNextRegUsage(const IRSituation &info, MIPSLoc type, IRReg r) const;
bool IsValidGPR(IRReg r) const;
bool IsValidGPRNoZero(IRReg r) const;
bool IsValidFPR(IRReg r) const;
+3
View File
@@ -41,6 +41,7 @@
#include "../ARM/ArmJit.h"
#elif PPSSPP_ARCH(ARM64)
#include "../ARM64/Arm64Jit.h"
#include "../ARM64/Arm64IRJit.h"
#elif PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)
#include "../x86/Jit.h"
#include "../x86/X64IRJit.h"
@@ -106,6 +107,8 @@ namespace MIPSComp {
#if PPSSPP_ARCH(ARM)
return new MIPSComp::ArmJit(mipsState);
#elif PPSSPP_ARCH(ARM64)
if (useIR)
return new MIPSComp::Arm64IRJit(mipsState);
return new MIPSComp::Arm64Jit(mipsState);
#elif PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)
if (useIR)
+2 -4
View File
@@ -121,7 +121,7 @@ void RiscVJitBackend::GenerateFixedCode(MIPSState *mipsState) {
// Fixed registers, these are always kept when in Jit context.
LI(MEMBASEREG, Memory::base, SCRATCH1);
LI(CTXREG, mipsState, SCRATCH1);
LI(JITBASEREG, GetBasePtr(), SCRATCH1);
LI(JITBASEREG, GetBasePtr() - MIPS_EMUHACK_OPCODE, SCRATCH1);
LoadStaticRegisters();
MovFromPC(SCRATCH1);
@@ -173,9 +173,7 @@ void RiscVJitBackend::GenerateFixedCode(MIPSState *mipsState) {
// We're in other words comparing to the top 8 bits of MIPS_EMUHACK_OPCODE by subtracting.
ADDI(SCRATCH2, SCRATCH2, -(MIPS_EMUHACK_OPCODE >> 24));
FixupBranch needsCompile = BNE(SCRATCH2, R_ZERO);
// Use a wall to mask by 0x00FFFFFF and extract the block jit offset.
SLLI(SCRATCH1, SCRATCH1, XLEN - 24);
SRLI(SCRATCH1, SCRATCH1, XLEN - 24);
// No need to mask, JITBASEREG has already accounted for the upper bits.
ADD(SCRATCH1, JITBASEREG, SCRATCH1);
JR(SCRATCH1);
SetJumpTarget(needsCompile);
+4
View File
@@ -55,6 +55,10 @@ void RiscVJitBackend::SetScratch1ToSrc1Address(IRReg src1) {
int32_t RiscVJitBackend::AdjustForAddressOffset(RiscVGen::RiscVReg *reg, int32_t constant, int32_t range) {
if (constant < -2048 || constant + range > 2047) {
#ifdef MASKED_PSP_MEMORY
if (constant > 0)
constant &= Memory::MEMVIEW32_MASK;
#endif
LI(SCRATCH2, constant);
ADD(SCRATCH1, *reg, SCRATCH2);
*reg = SCRATCH1;
+1 -1
View File
@@ -90,7 +90,7 @@ void RiscVJitBackend::CompIR_Transfer(IRInst inst) {
switch (inst.op) {
case IROp::SetCtrlVFPU:
regs_.SetGPRImm(IRREG_VFPU_CTRL_BASE + inst.dest, (int32_t)inst.constant);
regs_.SetGPRImm(IRREG_VFPU_CTRL_BASE + inst.dest, inst.constant);
break;
case IROp::SetCtrlVFPUReg:
+19 -5
View File
@@ -35,6 +35,10 @@ namespace MIPSComp {
using namespace RiscVGen;
using namespace RiscVJitConstants;
static bool Overlap(IRReg r1, int l1, IRReg r2, int l2) {
return r1 < r2 + l2 && r1 + l1 > r2;
}
void RiscVJitBackend::CompIR_VecAssign(IRInst inst) {
CONDITIONAL_DISABLE;
@@ -215,10 +219,21 @@ void RiscVJitBackend::CompIR_VecArith(IRInst inst) {
break;
case IROp::Vec4Scale:
// TODO: This works for now, but may need to handle aliasing for vectors.
regs_.Map(inst);
for (int i = 0; i < 4; ++i)
FMUL(32, regs_.F(inst.dest + i), regs_.F(inst.src1 + i), regs_.F(inst.src2));
if (Overlap(inst.src2, 1, inst.dest, 3)) {
// We have to handle overlap, doing dest == src2 last.
for (int i = 0; i < 4; ++i) {
if (inst.src2 != inst.dest + i)
FMUL(32, regs_.F(inst.dest + i), regs_.F(inst.src1 + i), regs_.F(inst.src2));
}
for (int i = 0; i < 4; ++i) {
if (inst.src2 == inst.dest + i)
FMUL(32, regs_.F(inst.dest + i), regs_.F(inst.src1 + i), regs_.F(inst.src2));
}
} else {
for (int i = 0; i < 4; ++i)
FMUL(32, regs_.F(inst.dest + i), regs_.F(inst.src1 + i), regs_.F(inst.src2));
}
break;
case IROp::Vec4Neg:
@@ -244,9 +259,8 @@ void RiscVJitBackend::CompIR_VecHoriz(IRInst inst) {
switch (inst.op) {
case IROp::Vec4Dot:
// TODO: This works for now, but may need to handle aliasing for vectors.
regs_.Map(inst);
if ((inst.dest < inst.src1 + 4 && inst.dest >= inst.src1) || (inst.dest < inst.src2 + 4 && inst.dest >= inst.src2)) {
if (Overlap(inst.dest, 1, inst.src1, 4) || Overlap(inst.dest, 1, inst.src2, 4)) {
// This means inst.dest overlaps one of src1 or src2. We have to do that one first.
// Technically this may impact -0.0 and such, but dots accurately need to be aligned anyway.
for (int i = 0; i < 4; ++i) {
+3 -2
View File
@@ -56,6 +56,8 @@ bool RiscVJitBackend::CompileBlock(IRBlock *block, int block_num, bool preload)
if (GetSpaceLeft() < 0x800)
return false;
BeginWrite(std::min(GetSpaceLeft(), (size_t)block->GetNumInstructions() * 32));
u32 startPC = block->GetOriginalStart();
bool wroteCheckedOffset = false;
if (jo.enableBlocklink && !jo.useBackJump) {
@@ -151,6 +153,7 @@ bool RiscVJitBackend::CompileBlock(IRBlock *block, int block_num, bool preload)
}
}
EndWrite();
FlushIcache();
compilingBlockNum_ = -1;
@@ -163,8 +166,6 @@ void RiscVJitBackend::WriteConstExit(uint32_t pc) {
int exitStart = (int)GetOffset(GetCodePointer());
if (block_num >= 0 && jo.enableBlocklink && nativeBlock && nativeBlock->checkedOffset != 0) {
// Don't bother recording, we don't ever overwrite to "unlink".
// Instead, we would mark the target block to jump to the dispatcher.
QuickJ(SCRATCH1, GetBasePtr() + nativeBlock->checkedOffset);
} else {
LI(SCRATCH1, pc);
+4 -2
View File
@@ -77,7 +77,6 @@ const int *RiscVRegCache::GetAllocationOrder(MIPSLoc type, MIPSMap flags, int &c
}
} else if (type == MIPSLoc::FREG) {
// F8 through F15 are used for compression, so they are great.
// TODO: Maybe we could remove some saved regs since we rarely need that many? Or maybe worth it?
static const int allocationOrder[] = {
F8, F9, F10, F11, F12, F13, F14, F15,
F0, F1, F2, F3, F4, F5, F6, F7,
@@ -206,6 +205,10 @@ RiscVGen::RiscVReg RiscVRegCache::Normalize32(IRReg mipsReg, RiscVGen::RiscVReg
emit_->SEXT_W(destReg, (RiscVReg)mr[mipsReg].nReg);
}
break;
default:
_assert_msg_(false, "Should not normalize32 floats");
break;
}
return destReg == INVALID_REG ? reg : destReg;
@@ -312,7 +315,6 @@ void RiscVRegCache::LoadNativeReg(IRNativeReg nreg, IRReg first, int lanes) {
_dbg_assert_(r > X0);
_dbg_assert_(first != MIPS_REG_ZERO);
if (r <= X31) {
// Multilane not yet supported.
_assert_(lanes == 1 || (lanes == 2 && first == IRREG_LO));
if (lanes == 1)
emit_->LW(r, CTXREG, GetMipsRegOffset(first));
+1 -1
View File
@@ -44,7 +44,7 @@ public:
void Init(RiscVGen::RiscVEmitter *emitter);
// May fail and return INVALID_REG if it needs flushing.
RiscVGen::RiscVReg TryMapTempImm(IRReg);
RiscVGen::RiscVReg TryMapTempImm(IRReg reg);
// Returns an RV register containing the requested MIPS register.
RiscVGen::RiscVReg MapGPR(IRReg reg, MIPSMap mapFlags = MIPSMap::INIT);
+19 -9
View File
@@ -55,13 +55,18 @@ void X64JitBackend::GenerateFixedCode(MIPSState *mipsState) {
jo.downcountInRegister = false;
#if PPSSPP_ARCH(AMD64)
bool jitbaseInR15 = false;
uintptr_t jitbase = (uintptr_t)GetBasePtr();
if (jitbase > 0x7FFFFFFFULL) {
int jitbaseCtxDisp = 0;
// We pre-bake the MIPS_EMUHACK_OPCODE subtraction into our jitbase value.
intptr_t jitbase = (intptr_t)GetBasePtr() - MIPS_EMUHACK_OPCODE;
if ((jitbase < -0x80000000ULL || jitbase > 0x7FFFFFFFULL) && !Accessible((const u8 *)&mipsState->f[0], GetBasePtr())) {
jo.reserveR15ForAsm = true;
jitbaseInR15 = true;
} else {
jo.downcountInRegister = true;
jo.reserveR15ForAsm = true;
if (jitbase < -0x80000000ULL || jitbase > 0x7FFFFFFFULL) {
jitbaseCtxDisp = (int)(jitbase - (intptr_t)&mipsState->f[0]);
}
}
#endif
@@ -135,7 +140,7 @@ void X64JitBackend::GenerateFixedCode(MIPSState *mipsState) {
// Two x64-specific statically allocated registers.
MOV(64, R(MEMBASEREG), ImmPtr(Memory::base));
if (jitbaseInR15)
MOV(64, R(JITBASEREG), ImmPtr(GetBasePtr()));
MOV(64, R(JITBASEREG), ImmPtr((const void *)jitbase));
#endif
// From the start of the FP reg, a single byte offset can reach all GPR + all FPR (but not VFPR.)
MOV(PTRBITS, R(CTXREG), ImmPtr(&mipsState->f[0]));
@@ -190,10 +195,14 @@ void X64JitBackend::GenerateFixedCode(MIPSState *mipsState) {
// Debug
if (enableDebug) {
#if PPSSPP_ARCH(AMD64)
if (jitbaseInR15)
if (jitbaseInR15) {
ABI_CallFunctionAA(reinterpret_cast<void *>(&ShowPC), R(MEMBASEREG), R(JITBASEREG));
else
} else if (jitbaseCtxDisp != 0) {
LEA(64, SCRATCH1, MDisp(CTXREG, jitbaseCtxDisp));
ABI_CallFunctionAA(reinterpret_cast<void *>(&ShowPC), R(MEMBASEREG), R(SCRATCH1));
} else {
ABI_CallFunctionAC(reinterpret_cast<void *>(&ShowPC), R(MEMBASEREG), (u32)jitbase);
}
#else
ABI_CallFunctionCC(reinterpret_cast<void *>(&ShowPC), (u32)Memory::base, (u32)GetBasePtr());
#endif
@@ -220,16 +229,17 @@ void X64JitBackend::GenerateFixedCode(MIPSState *mipsState) {
CMP(32, R(EDX), Imm8(MIPS_EMUHACK_OPCODE >> 24));
}
FixupBranch needsCompile = J_CC(CC_NE);
// Mask by 0x00FFFFFF and extract the block jit offset.
AND(32, R(SCRATCH1), Imm32(MIPS_EMUHACK_VALUE_MASK));
// We don't mask here - that's baked into jitbase.
#if PPSSPP_ARCH(X86)
LEA(32, SCRATCH1, MDisp(SCRATCH1, (u32)GetBasePtr()));
LEA(32, SCRATCH1, MDisp(SCRATCH1, (u32)GetBasePtr() - MIPS_EMUHACK_VALUE_MASK));
#elif PPSSPP_ARCH(AMD64)
if (jitbaseInR15) {
ADD(64, R(SCRATCH1), R(JITBASEREG));
} else if (jitbaseCtxDisp) {
LEA(64, SCRATCH1, MComplex(CTXREG, SCRATCH1, SCALE_1, jitbaseCtxDisp));
} else {
// See above, reserveR15ForAsm is used when above 0x7FFFFFFF.
LEA(64, SCRATCH1, MDisp(SCRATCH1, (u32)jitbase));
LEA(64, SCRATCH1, MDisp(SCRATCH1, (s32)jitbase));
}
#endif
JMPptr(R(SCRATCH1));
+2 -1
View File
@@ -64,7 +64,7 @@ void X64JitBackend::CompIR_Arith(IRInst inst) {
case IROp::Sub:
regs_.Map(inst);
if (inst.dest == inst.src2 && inst.dest == inst.src1) {
if (inst.src1 == inst.src2) {
regs_.SetGPRImm(inst.dest, 0);
} else if (inst.dest == inst.src2) {
NEG(32, regs_.R(inst.src2));
@@ -505,6 +505,7 @@ void X64JitBackend::CompIR_Logic(IRInst inst) {
AND(32, regs_.R(inst.dest), regs_.R(inst.src2));
}
break;
case IROp::Or:
regs_.Map(inst);
if (inst.dest == inst.src1) {
+145 -23
View File
@@ -56,6 +56,39 @@ void X64JitBackend::EmitFPUConstants() {
Write32(val);
}
constants.mulTableVf2i = (const double *)GetCodePointer();
for (uint8_t i = 0; i < 32; ++i) {
double fval = (1UL << i);
uint64_t val;
memcpy(&val, &fval, sizeof(val));
Write64(val);
}
// Note: this first one is (double)(int)0x80000000, sign extended.
constants.minIntAsDouble = (const double *)GetCodePointer();
Write64(0xC1E0000000000000ULL);
constants.maxIntAsDouble = (const double *)GetCodePointer();
Write64(0x41DFFFFFFFC00000ULL);
}
void X64JitBackend::CopyVec4ToFPRLane0(Gen::X64Reg dest, Gen::X64Reg src, int lane) {
// TODO: Move to regcache or emitter maybe?
if (lane == 0) {
if (dest != src)
MOVAPS(dest, R(src));
} else if (lane == 1 && cpu_info.bSSE3) {
MOVSHDUP(dest, R(src));
} else if (lane == 2) {
MOVHLPS(dest, src);
} else if (cpu_info.bAVX) {
VPERMILPS(128, dest, R(src), VFPU_SWIZZLE(lane, lane, lane, lane));
} else {
if (dest != src)
MOVAPS(dest, R(src));
SHUFPS(dest, R(dest), VFPU_SWIZZLE(lane, lane, lane, lane));
}
}
void X64JitBackend::CompIR_FArith(IRInst inst) {
@@ -174,7 +207,15 @@ void X64JitBackend::CompIR_FAssign(IRInst inst) {
switch (inst.op) {
case IROp::FMov:
if (inst.dest != inst.src1) {
// Just to make sure we don't generate bad code.
if (inst.dest == inst.src1)
break;
if (regs_.IsFPRMapped(inst.src1 & 3) && regs_.GetFPRLaneCount(inst.src1 & ~3) == 4 && (inst.dest & ~3) != (inst.src1 & ~3)) {
// Okay, this is an extract. Avoid unvec4ing src1.
regs_.SpillLockFPR(inst.src1);
regs_.MapFPR(inst.dest, MIPSMap::NOINIT);
CopyVec4ToFPRLane0(regs_.FX(inst.dest), regs_.FX(inst.src1 & ~3), inst.src1 & 3);
} else {
regs_.Map(inst);
MOVAPS(regs_.FX(inst.dest), regs_.F(inst.src1));
}
@@ -533,8 +574,18 @@ void X64JitBackend::CompIR_FCvt(IRInst inst) {
switch (inst.op) {
case IROp::FCvtWS:
CompIR_Generic(inst);
{
regs_.Map(inst);
UCOMISS(regs_.FX(inst.src1), M(constants.positiveInfinity)); // rip accessible
CVTPS2DQ(regs_.FX(inst.dest), regs_.F(inst.src1));
// UCOMISS set ZF if EQUAL (to infinity) or UNORDERED.
FixupBranch skip = J_CC(CC_NZ);
MOVAPS(regs_.FX(inst.dest), M(constants.noSignMask)); // rip accessible
SetJumpTarget(skip);
break;
}
case IROp::FCvtSW:
regs_.Map(inst);
@@ -542,7 +593,96 @@ void X64JitBackend::CompIR_FCvt(IRInst inst) {
break;
case IROp::FCvtScaledWS:
CompIR_Generic(inst);
regs_.Map(inst);
if (cpu_info.bSSE4_1) {
int scale = inst.src2 & 0x1F;
int rmode = inst.src2 >> 6;
CVTSS2SD(regs_.FX(inst.dest), regs_.F(inst.src1));
if (scale != 0)
MULSD(regs_.FX(inst.dest), M(&constants.mulTableVf2i[scale])); // rip accessible
// On NAN, we want maxInt anyway, so let's let it be the second param.
MAXSD(regs_.FX(inst.dest), M(constants.minIntAsDouble)); // rip accessible
MINSD(regs_.FX(inst.dest), M(constants.maxIntAsDouble)); // rip accessible
switch (rmode) {
case 0:
ROUNDNEARPD(regs_.FX(inst.dest), regs_.F(inst.dest));
CVTPD2DQ(regs_.FX(inst.dest), regs_.F(inst.dest));
break;
case 1:
CVTTPD2DQ(regs_.FX(inst.dest), regs_.F(inst.dest));
break;
case 2:
ROUNDCEILPD(regs_.FX(inst.dest), regs_.F(inst.dest));
CVTPD2DQ(regs_.FX(inst.dest), regs_.F(inst.dest));
break;
case 3:
ROUNDFLOORPD(regs_.FX(inst.dest), regs_.F(inst.dest));
CVTPD2DQ(regs_.FX(inst.dest), regs_.F(inst.dest));
break;
}
} else {
int scale = inst.src2 & 0x1F;
int rmode = inst.src2 >> 6;
int setMXCSR = -1;
bool useTrunc = false;
switch (rmode) {
case 0:
// TODO: Could skip if hasSetRounding, but we don't have the flag.
setMXCSR = 0;
break;
case 1:
useTrunc = true;
break;
case 2:
setMXCSR = 2;
break;
case 3:
setMXCSR = 1;
break;
}
// Except for truncate, we need to update MXCSR to our preferred rounding mode.
// TODO: Might be possible to cache this and update between instructions?
// Probably kinda expensive to switch each time...
if (setMXCSR != -1) {
STMXCSR(MDisp(CTXREG, mxcsrTempOffset));
MOV(32, R(SCRATCH1), MDisp(CTXREG, mxcsrTempOffset));
AND(32, R(SCRATCH1), Imm32(~(3 << 13)));
if (setMXCSR != 0) {
OR(32, R(SCRATCH1), Imm32(setMXCSR << 13));
}
MOV(32, MDisp(CTXREG, tempOffset), R(SCRATCH1));
LDMXCSR(MDisp(CTXREG, tempOffset));
}
CVTSS2SD(regs_.FX(inst.dest), regs_.F(inst.src1));
if (scale != 0)
MULSD(regs_.FX(inst.dest), M(&constants.mulTableVf2i[scale]));
// On NAN, we want maxInt anyway, so let's let it be the second param.
MAXSD(regs_.FX(inst.dest), M(constants.minIntAsDouble));
MINSD(regs_.FX(inst.dest), M(constants.maxIntAsDouble));
if (useTrunc) {
CVTTSD2SI(SCRATCH1, regs_.F(inst.dest));
} else {
CVTSD2SI(SCRATCH1, regs_.F(inst.dest));
}
MOVD_xmm(regs_.FX(inst.dest), R(SCRATCH1));
// Return MXCSR to its previous value.
if (setMXCSR != -1) {
LDMXCSR(MDisp(CTXREG, mxcsrTempOffset));
}
}
break;
case IROp::FCvtScaledSW:
@@ -688,31 +828,13 @@ static uint32_t x64_asin(uint32_t v) {
void X64JitBackend::CompIR_FSpecial(IRInst inst) {
CONDITIONAL_DISABLE;
// TODO: Regcache... maybe emitter helper too?
auto laneToReg0 = [&](X64Reg dest, X64Reg src, int lane) {
if (lane == 0) {
if (dest != src)
MOVAPS(dest, R(src));
} else if (lane == 1 && cpu_info.bSSE3) {
MOVSHDUP(dest, R(src));
} else if (lane == 2) {
MOVHLPS(dest, src);
} else if (cpu_info.bAVX) {
VPERMILPS(128, dest, R(src), VFPU_SWIZZLE(lane, lane, lane, lane));
} else {
if (dest != src)
MOVAPS(dest, R(src));
SHUFPS(dest, R(dest), VFPU_SWIZZLE(lane, lane, lane, lane));
}
};
auto callFuncF_F = [&](const void *func) {
regs_.FlushBeforeCall();
#if X64JIT_USE_XMM_CALL
if (regs_.IsFPRMapped(inst.src1)) {
int lane = regs_.GetFPRLane(inst.src1);
laneToReg0(XMM0, regs_.FX(inst.src1), lane);
CopyVec4ToFPRLane0(XMM0, regs_.FX(inst.src1), lane);
} else {
// Account for CTXREG being increased by 128 to reduce imm sizes.
int offset = offsetof(MIPSState, f) + inst.src1 * 4 - 128;
@@ -728,7 +850,7 @@ void X64JitBackend::CompIR_FSpecial(IRInst inst) {
if (lane == 0) {
MOVD_xmm(R(SCRATCH1), regs_.FX(inst.src1));
} else {
laneToReg0(XMM0, regs_.FX(inst.src1), lane);
CopyVec4ToFPRLane0(XMM0, regs_.FX(inst.src1), lane);
MOVD_xmm(R(SCRATCH1), XMM0);
}
} else {
+13 -5
View File
@@ -39,7 +39,16 @@ using namespace X64IRJitConstants;
Gen::OpArg X64JitBackend::PrepareSrc1Address(IRInst inst) {
const IRMeta *m = GetIRMeta(inst.op);
bool src1IsPointer = regs_.IsGPRMappedAsPointer(inst.src1);
bool readsFromSrc1 = inst.src1 == inst.src3 && (m->flags & (IRFLAG_SRC3 | IRFLAG_SRC3DST)) != 0;
// If it's about to be clobbered, don't waste time pointerifying. Use displacement.
bool clobbersSrc1 = !readsFromSrc1 && regs_.IsGPRClobbered(inst.src1);
#ifdef MASKED_PSP_MEMORY
if (inst.constant > 0)
inst.constant &= Memory::MEMVIEW32_MASK;
#endif
OpArg addrArg;
if (inst.src1 == MIPS_REG_ZERO) {
@@ -51,7 +60,7 @@ Gen::OpArg X64JitBackend::PrepareSrc1Address(IRInst inst) {
#else
addrArg = M(Memory::base + inst.constant);
#endif
} else if ((jo.cachePointers || regs_.IsGPRMappedAsPointer(inst.src1)) && !readsFromSrc1) {
} else if ((jo.cachePointers || src1IsPointer) && !readsFromSrc1 && (!clobbersSrc1 || src1IsPointer)) {
X64Reg src1 = regs_.MapGPRAsPointer(inst.src1);
addrArg = MDisp(src1, (int)inst.constant);
} else {
@@ -59,8 +68,7 @@ Gen::OpArg X64JitBackend::PrepareSrc1Address(IRInst inst) {
#ifdef MASKED_PSP_MEMORY
LEA(PTRBITS, SCRATCH1, MDisp(regs_.RX(inst.src1), (int)inst.constant));
AND(PTRBITS, R(SCRATCH1), Imm32(Memory::MEMVIEW32_MASK));
ADD(PTRBITS, R(SCRATCH1), ImmPtr(Memory::base));
addrArg = MatR(SCRATCH1);
addrArg = MDisp(SCRATCH1, (intptr_t)Memory::base);
#else
#if PPSSPP_ARCH(AMD64)
addrArg = MComplex(MEMBASEREG, regs_.RX(inst.src1), SCALE_1, (int)inst.constant);
@@ -127,7 +135,7 @@ void X64JitBackend::CompIR_FStore(IRInst inst) {
switch (inst.op) {
case IROp::StoreFloat:
regs_.MapFPR(inst.src3);
MOVSS(addrArg, regs_.FX(inst.dest));
MOVSS(addrArg, regs_.FX(inst.src3));
break;
default:
@@ -284,7 +292,7 @@ void X64JitBackend::CompIR_VecStore(IRInst inst) {
switch (inst.op) {
case IROp::StoreVec4:
regs_.MapVec4(inst.src3);
MOVUPS(addrArg, regs_.FX(inst.dest));
MOVUPS(addrArg, regs_.FX(inst.src3));
break;
default:
+20 -3
View File
@@ -23,6 +23,7 @@
#include "Core/HLE/HLE.h"
#include "Core/HLE/ReplaceTables.h"
#include "Core/MemMap.h"
#include "Core/MIPS/IR/IRInterpreter.h"
#include "Core/MIPS/x86/X64IRJit.h"
#include "Core/MIPS/x86/X64IRRegCache.h"
@@ -88,10 +89,26 @@ void X64JitBackend::CompIR_Breakpoint(IRInst inst) {
switch (inst.op) {
case IROp::Breakpoint:
case IROp::MemoryCheck:
CompIR_Generic(inst);
FlushAll();
// Note: the constant could be a delay slot.
ABI_CallFunctionC((const void *)&IRRunBreakpoint, inst.constant);
TEST(32, R(EAX), R(EAX));
J_CC(CC_NZ, dispatcherCheckCoreState_, true);
break;
case IROp::MemoryCheck:
{
X64Reg addrBase = regs_.MapGPR(inst.src1);
FlushAll();
LEA(32, addrBase, MDisp(addrBase, inst.constant));
MovFromPC(SCRATCH1);
LEA(32, SCRATCH1, MDisp(SCRATCH1, inst.dest));
ABI_CallFunctionRR((const void *)&IRRunMemCheck, SCRATCH1, addrBase);
TEST(32, R(EAX), R(EAX));
J_CC(CC_NZ, dispatcherCheckCoreState_, true);
break;
}
default:
INVALIDOP;
break;
@@ -219,7 +236,7 @@ int ReportBadAddress(uint32_t addr, uint32_t alignment, uint32_t isWrite) {
return toss(MemoryExceptionType::ALIGNMENT);
}
return 0;
};
}
void X64JitBackend::CompIR_ValidateAddress(IRInst inst) {
CONDITIONAL_DISABLE;
+6 -6
View File
@@ -29,9 +29,10 @@ namespace MIPSComp {
using namespace Gen;
using namespace X64IRJitConstants;
// This should be enough for exits and invalidations.
static constexpr int MIN_BLOCK_NORMAL_LEN = 16;
static constexpr int MIN_BLOCK_EXIT_LEN = 16;
// Invalidations just need a MOV and JMP.
static constexpr int MIN_BLOCK_NORMAL_LEN = 10;
// As long as we can fit a JMP, we should be fine.
static constexpr int MIN_BLOCK_EXIT_LEN = 5;
X64JitBackend::X64JitBackend(JitOptions &jitopt, IRBlockCache &blocks)
: IRNativeBackend(blocks), jo(jitopt), regs_(&jo) {
@@ -109,7 +110,7 @@ bool X64JitBackend::CompileBlock(IRBlock *block, int block_num, bool preload) {
int len = (int)GetOffset(GetCodePointer()) - block->GetTargetOffset();
if (len < MIN_BLOCK_NORMAL_LEN) {
// We need at least 16 bytes to invalidate blocks with, but larger doesn't need to align.
// We need at least 10 bytes to invalidate blocks with.
ReserveCodeSpace(MIN_BLOCK_NORMAL_LEN - len);
}
@@ -165,8 +166,6 @@ void X64JitBackend::WriteConstExit(uint32_t pc) {
int exitStart = (int)GetOffset(GetCodePointer());
if (block_num >= 0 && jo.enableBlocklink && nativeBlock && nativeBlock->checkedOffset != 0) {
// Don't bother recording, we don't ever overwrite to "unlink".
// Instead, we would mark the target block to jump to the dispatcher.
JMP(GetBasePtr() + nativeBlock->checkedOffset, true);
} else {
MOV(32, R(SCRATCH1), Imm32(pc));
@@ -198,6 +197,7 @@ void X64JitBackend::OverwriteExit(int srcOffset, int len, int block_num) {
XEmitter emitter(writable);
emitter.JMP(GetBasePtr() + nativeBlock->checkedOffset, true);
int bytesWritten = (int)(emitter.GetWritableCodePtr() - writable);
_dbg_assert_(bytesWritten <= MIN_BLOCK_EXIT_LEN);
if (bytesWritten < len)
emitter.ReserveCodeSpace(len - bytesWritten);
+7 -3
View File
@@ -124,6 +124,7 @@ private:
void EmitVecConstants();
Gen::OpArg PrepareSrc1Address(IRInst inst);
void CopyVec4ToFPRLane0(Gen::X64Reg dest, Gen::X64Reg src, int lane);
JitOptions &jo;
X64IRRegCache regs_;
@@ -148,6 +149,9 @@ private:
const void *negativeOnes;
const void *qNAN;
const float *mulTableVi2f;
const double *mulTableVf2i;
const double *minIntAsDouble;
const double *maxIntAsDouble;
const Float4Constant *vec4InitValues;
};
Constants constants;
@@ -160,12 +164,12 @@ private:
class X64IRJit : public IRNativeJit {
public:
X64IRJit(MIPSState *mipsState)
: IRNativeJit(mipsState), rvBackend_(jo, blocks_) {
Init(rvBackend_);
: IRNativeJit(mipsState), x64Backend_(jo, blocks_) {
Init(x64Backend_);
}
private:
X64JitBackend rvBackend_;
X64JitBackend x64Backend_;
};
} // namespace MIPSComp
+5 -7
View File
@@ -262,7 +262,7 @@ void X64IRRegCache::MapWithFlags(IRInst inst, X64Map destFlags, X64Map src1Flags
X64Reg X64IRRegCache::MapGPR(IRReg mipsReg, MIPSMap mapFlags) {
_dbg_assert_(IsValidGPR(mipsReg));
// Okay, not mapped, so we need to allocate an RV register.
// Okay, not mapped, so we need to allocate an x64 register.
IRNativeReg nreg = MapNativeReg(MIPSLoc::REG, mipsReg, 1, mapFlags);
return FromNativeReg(nreg);
}
@@ -270,7 +270,7 @@ X64Reg X64IRRegCache::MapGPR(IRReg mipsReg, MIPSMap mapFlags) {
X64Reg X64IRRegCache::MapGPR2(IRReg mipsReg, MIPSMap mapFlags) {
_dbg_assert_(IsValidGPR(mipsReg) && IsValidGPR(mipsReg + 1));
// Okay, not mapped, so we need to allocate an RV register.
// Okay, not mapped, so we need to allocate an x64 register.
IRNativeReg nreg = MapNativeReg(MIPSLoc::REG, mipsReg, 2, mapFlags);
return FromNativeReg(nreg);
}
@@ -326,7 +326,6 @@ void X64IRRegCache::LoadNativeReg(IRNativeReg nreg, IRReg first, int lanes) {
X64Reg r = FromNativeReg(nreg);
_dbg_assert_(first != MIPS_REG_ZERO);
if (nreg < NUM_X_REGS) {
// Multilane not yet supported.
_assert_(lanes == 1 || (lanes == 2 && first == IRREG_LO));
if (lanes == 1)
emit_->MOV(32, ::R(r), MDisp(CTXREG, -128 + GetMipsRegOffset(first)));
@@ -354,7 +353,6 @@ void X64IRRegCache::StoreNativeReg(IRNativeReg nreg, IRReg first, int lanes) {
X64Reg r = FromNativeReg(nreg);
_dbg_assert_(first != MIPS_REG_ZERO);
if (nreg < NUM_X_REGS) {
// Multilane not yet supported.
_assert_(lanes == 1 || (lanes == 2 && first == IRREG_LO));
_assert_(mr[first].loc == MIPSLoc::REG || mr[first].loc == MIPSLoc::REG_IMM);
if (lanes == 1)
@@ -434,9 +432,9 @@ X64Reg X64IRRegCache::RXPtr(IRReg mipsReg) {
if (mr[mipsReg].loc == MIPSLoc::REG_AS_PTR) {
return FromNativeReg(mr[mipsReg].nReg);
} else if (mr[mipsReg].loc == MIPSLoc::REG || mr[mipsReg].loc == MIPSLoc::REG_IMM) {
int rv = mr[mipsReg].nReg;
_dbg_assert_(nr[rv].pointerified);
if (nr[rv].pointerified) {
int r = mr[mipsReg].nReg;
_dbg_assert_(nr[r].pointerified);
if (nr[r].pointerified) {
return FromNativeReg(mr[mipsReg].nReg);
} else {
ERROR_LOG(JIT, "Tried to use a non-pointer register as a pointer");
+4 -2
View File
@@ -30,6 +30,7 @@ namespace X64IRJitConstants {
#if PPSSPP_ARCH(AMD64)
const Gen::X64Reg MEMBASEREG = Gen::RBX;
const Gen::X64Reg CTXREG = Gen::R14;
// Note: this is actually offset from the base.
const Gen::X64Reg JITBASEREG = Gen::R15;
const Gen::X64Reg DOWNCOUNTREG = Gen::R15;
#else
@@ -42,6 +43,7 @@ static constexpr auto downcountOffset = offsetof(MIPSState, downcount) - 128;
static constexpr auto tempOffset = offsetof(MIPSState, temp) - 128;
static constexpr auto fcr31Offset = offsetof(MIPSState, fcr31) - 128;
static constexpr auto pcOffset = offsetof(MIPSState, pc) - 128;
static constexpr auto mxcsrTempOffset = offsetof(MIPSState, mxcsrTemp) - 128;
enum class X64Map : uint8_t {
NONE = 0,
@@ -77,9 +79,9 @@ public:
void Init(Gen::XEmitter *emitter);
// May fail and return INVALID_REG if it needs flushing.
Gen::X64Reg TryMapTempImm(IRReg, X64IRJitConstants::X64Map flags = X64IRJitConstants::X64Map::NONE);
Gen::X64Reg TryMapTempImm(IRReg reg, X64IRJitConstants::X64Map flags = X64IRJitConstants::X64Map::NONE);
// Returns an RV register containing the requested MIPS register.
// Returns an X64 register containing the requested MIPS register.
Gen::X64Reg MapGPR(IRReg reg, MIPSMap mapFlags = MIPSMap::INIT);
Gen::X64Reg MapGPR2(IRReg reg, MIPSMap mapFlags = MIPSMap::INIT);
Gen::X64Reg MapGPRAsPointer(IRReg reg);
+22
View File
@@ -863,6 +863,28 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta
g_rebootEmuThread = true;
}
#endif
// Convenience subset of what
// "Enable standard shortcut keys"
// does on Windows.
if(g_Config.bSystemControls) {
bool ctrl = bool(event.key.keysym.mod & KMOD_CTRL);
if (ctrl && (k == SDLK_w))
{
if (Core_IsStepping())
Core_EnableStepping(false);
Core_Stop();
System_PostUIMessage("stop", "");
// NOTE: Unlike Windows version, this
// does not need Core_WaitInactive();
// since SDL does not have a separate
// UI thread.
}
if (ctrl && (k == SDLK_b))
{
System_PostUIMessage("reset", "");
Core_EnableStepping(false);
}
}
break;
}
case SDL_KEYUP:
+12 -1
View File
@@ -858,7 +858,19 @@ void SystemInfoScreen::CreateTabs() {
}
}
#ifdef _DEBUG
LinearLayout *internals = AddTab("DevSystemInfoInternals", si->T("Internals"));
CreateInternalsTab(internals);
#endif
}
void SystemInfoScreen::CreateInternalsTab(UI::ViewGroup *internals) {
using namespace UI;
auto di = GetI18NCategory(I18NCat::DIALOG);
auto si = GetI18NCategory(I18NCat::SYSINFO);
auto sy = GetI18NCategory(I18NCat::SYSTEM);
auto ac = GetI18NCategory(I18NCat::ACHIEVEMENTS);
internals->Add(new ItemHeader(si->T("Icon cache")));
IconCacheStats iconStats = g_iconCache.GetStats();
@@ -929,7 +941,6 @@ void SystemInfoScreen::CreateTabs() {
});
static const char *positions[] = { "Bottom Left", "Bottom Center", "Bottom Right", "Top Left", "Top Center", "Top Right", "Center Left", "Center Right", "None" };
auto ac = GetI18NCategory(I18NCat::ACHIEVEMENTS);
internals->Add(new ItemHeader(ac->T("Notifications")));
internals->Add(new PopupMultiChoice(&g_Config.iAchievementsLeaderboardTrackerPos, ac->T("Leaderboard tracker"), positions, 0, ARRAY_SIZE(positions), I18NCat::DIALOG, screenManager()))->SetEnabledPtr(&g_Config.bAchievementsEnable);
+1 -1
View File
@@ -110,11 +110,11 @@ public:
const char *tag() const override { return "SystemInfo"; }
void CreateTabs() override;
void update() override;
protected:
bool ShowSearchControls() const override { return false; }
void CreateInternalsTab(UI::ViewGroup *internals);
};
class AddressPromptScreen : public PopupScreen {
+3 -2
View File
@@ -563,14 +563,14 @@ void EmuScreen::sendMessage(const char *message, const char *value) {
}
}
void EmuScreen::UnsyncTouch(const TouchInput &touch) {
bool EmuScreen::UnsyncTouch(const TouchInput &touch) {
System_Notify(SystemNotification::ACTIVITY);
if (chatMenu_ && chatMenu_->GetVisibility() == UI::V_VISIBLE) {
// Avoid pressing touch button behind the chat
if (chatMenu_->Contains(touch.x, touch.y)) {
chatMenu_->Touch(touch);
return;
return true;
} else if ((touch.flags & TOUCH_DOWN) != 0) {
chatMenu_->Close();
if (chatButton_)
@@ -582,6 +582,7 @@ void EmuScreen::UnsyncTouch(const TouchInput &touch) {
if (root_) {
root_->Touch(touch);
}
return true;
}
void EmuScreen::onVKey(int virtualKeyCode, bool down) {
+1 -1
View File
@@ -51,7 +51,7 @@ public:
// Note: Unlike your average boring UIScreen, here we override the Unsync* functions
// to get minimal latency and full control. We forward to UIScreen when needed.
void UnsyncTouch(const TouchInput &touch) override;
bool UnsyncTouch(const TouchInput &touch) override;
bool UnsyncKey(const KeyInput &key) override;
void UnsyncAxis(const AxisInput &axis) override;
+3 -1
View File
@@ -645,8 +645,10 @@ void GameSettingsScreen::CreateControlsSettings(UI::ViewGroup *controlsSettings)
controlsSettings->Add(new Choice(co->T("Control Mapping")))->OnClick.Handle(this, &GameSettingsScreen::OnControlMapping);
controlsSettings->Add(new Choice(co->T("Calibrate Analog Stick")))->OnClick.Handle(this, &GameSettingsScreen::OnCalibrateAnalogs);
#if defined(USING_WIN_UI)
#if defined(USING_WIN_UI) || (PPSSPP_PLATFORM(LINUX) && !PPSSPP_PLATFORM(ANDROID))
controlsSettings->Add(new CheckBox(&g_Config.bSystemControls, co->T("Enable standard shortcut keys")));
#endif
#if defined(USING_WIN_UI)
controlsSettings->Add(new CheckBox(&g_Config.bGamepadOnlyFocused, co->T("Ignore gamepads when not focused")));
#endif
+44 -1
View File
@@ -367,6 +367,8 @@ void OnScreenMessagesView::Draw(UIContext &dc) {
edges[(size_t)pos].maxWidth = std::max(edges[(size_t)pos].maxWidth, measuredEntry.w);
}
std::vector<ClickZone> dismissZones;
// Now, perform layout for all 8 edges.
for (size_t i = 0; i < (size_t)ScreenEdgePosition::VALUE_COUNT; i++) {
if (edges[i].height == 0.0f) {
@@ -444,13 +446,30 @@ void OnScreenMessagesView::Draw(UIContext &dc) {
float alpha = Clamp((float)(entry.endTime - now) * 4.0f, 0.0f, 1.0f);
RenderOSDEntry(dc, entry, b, measuredEntry.h1, measuredEntry.align, alpha);
switch (entry.type) {
case OSDType::MESSAGE_INFO:
case OSDType::MESSAGE_SUCCESS:
case OSDType::MESSAGE_WARNING:
case OSDType::MESSAGE_ERROR:
case OSDType::MESSAGE_ERROR_DUMP:
case OSDType::MESSAGE_FILE_LINK:
case OSDType::ACHIEVEMENT_UNLOCKED:
// Save the location of the popup, for easy dismissal.
dismissZones.push_back(ClickZone{ (int)j, b });
break;
}
break;
}
}
y += (measuredEntry.h + 4.0f) * measuredEntry.alpha;
}
}
std::lock_guard<std::mutex> lock(clickMutex_);
clickZones_ = dismissZones;
}
std::string OnScreenMessagesView::DescribeText() const {
@@ -465,10 +484,34 @@ std::string OnScreenMessagesView::DescribeText() const {
return ss.str();
}
// Asynchronous!
bool OnScreenMessagesView::Dismiss(float x, float y) {
bool dismissed = false;
std::lock_guard<std::mutex> lock(clickMutex_);
double now = time_now_d();
for (auto &zone : clickZones_) {
if (zone.bounds.Contains(x, y)) {
g_OSD.DismissEntry(zone.index, now);
dismissed = true;
}
}
return dismissed;
}
bool OSDOverlayScreen::UnsyncTouch(const TouchInput &touch) {
// Don't really need to forward.
// UIScreen::UnsyncTouch(touch);
if ((touch.flags & TOUCH_DOWN) && osmView_) {
return osmView_->Dismiss(touch.x, touch.y);
} else {
return false;
}
}
void OSDOverlayScreen::CreateViews() {
root_ = new UI::AnchorLayout();
root_->SetTag("OSDOverlayScreen");
root_->Add(new OnScreenMessagesView(new UI::AnchorLayoutParams(0.0f, 0.0f, 0.0f, 0.0f)));
osmView_ = root_->Add(new OnScreenMessagesView(new UI::AnchorLayoutParams(0.0f, 0.0f, 0.0f, 0.0f)));
}
void OSDOverlayScreen::render() {
+16
View File
@@ -21,14 +21,30 @@ class OnScreenMessagesView : public UI::InertView {
public:
OnScreenMessagesView(UI::LayoutParams *layoutParams = nullptr) : UI::InertView(layoutParams) {}
void Draw(UIContext &dc) override;
bool Dismiss(float x, float y); // Not reusing Touch since it's asynchronous.
std::string DescribeText() const override;
private:
struct ClickZone {
int index;
Bounds bounds;
};
// Argh, would really like to avoid this.
std::mutex clickMutex_;
std::vector<ClickZone> clickZones_;
};
class OSDOverlayScreen : public UIScreen {
public:
const char *tag() const override { return "OSDOverlayScreen"; }
bool UnsyncTouch(const TouchInput &touch) override;
void CreateViews() override;
void render() override;
private:
OnScreenMessagesView *osmView_ = nullptr;
};
enum class NoticeLevel {
+11
View File
@@ -271,6 +271,8 @@
<ClInclude Include="..\..\Core\MIPS\ARM64\Arm64Jit.h" />
<ClInclude Include="..\..\Core\MIPS\ARM64\Arm64RegCache.h" />
<ClInclude Include="..\..\Core\MIPS\ARM64\Arm64RegCacheFPU.h" />
<ClInclude Include="..\..\Core\MIPS\ARM64\Arm64IRJit.h" />
<ClInclude Include="..\..\Core\MIPS\ARM64\Arm64IRRegCache.h" />
<ClInclude Include="..\..\Core\MIPS\ARM\ArmCompVFPUNEONUtil.h" />
<ClInclude Include="..\..\Core\MIPS\ARM\ArmJit.h" />
<ClInclude Include="..\..\Core\MIPS\ARM\ArmRegCache.h" />
@@ -520,6 +522,15 @@
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64Jit.cpp" />
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64RegCache.cpp" />
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64RegCacheFPU.cpp" />
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64IRAsm.cpp" />
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64IRCompALU.cpp" />
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64IRCompBranch.cpp" />
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64IRCompFPU.cpp" />
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64IRCompLoadStore.cpp" />
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64IRCompSystem.cpp" />
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64IRCompVec.cpp" />
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64IRJit.cpp" />
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64IRRegCache.cpp" />
<ClCompile Include="..\..\Core\MIPS\ARM\ArmAsm.cpp" />
<ClCompile Include="..\..\Core\MIPS\ARM\ArmCompALU.cpp" />
<ClCompile Include="..\..\Core\MIPS\ARM\ArmCompBranch.cpp" />
+33
View File
@@ -782,6 +782,33 @@
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64RegCacheFPU.cpp">
<Filter>MIPS\ARM64</Filter>
</ClCompile>
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64IRAsm.cpp">
<Filter>MIPS\ARM64</Filter>
</ClCompile>
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64IRCompALU.cpp">
<Filter>MIPS\ARM64</Filter>
</ClCompile>
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64IRCompBranch.cpp">
<Filter>MIPS\ARM64</Filter>
</ClCompile>
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64IRCompFPU.cpp">
<Filter>MIPS\ARM64</Filter>
</ClCompile>
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64IRCompLoadStore.cpp">
<Filter>MIPS\ARM64</Filter>
</ClCompile>
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64IRCompSystem.cpp">
<Filter>MIPS\ARM64</Filter>
</ClCompile>
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64IRCompVec.cpp">
<Filter>MIPS\ARM64</Filter>
</ClCompile>
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64IRJit.cpp">
<Filter>MIPS\ARM64</Filter>
</ClCompile>
<ClCompile Include="..\..\Core\MIPS\ARM64\Arm64IRRegCache.cpp">
<Filter>MIPS\ARM64</Filter>
</ClCompile>
<ClCompile Include="..\..\Core\HW\BufferQueue.cpp">
<Filter>HW</Filter>
</ClCompile>
@@ -1790,6 +1817,12 @@
<ClInclude Include="..\..\Core\MIPS\ARM64\Arm64RegCacheFPU.h">
<Filter>MIPS\ARM64</Filter>
</ClInclude>
<ClInclude Include="..\..\Core\MIPS\ARM64\Arm64IRJit.h">
<Filter>MIPS\ARM64</Filter>
</ClInclude>
<ClInclude Include="..\..\Core\MIPS\ARM64\Arm64IRRegCache.h">
<Filter>MIPS\ARM64</Filter>
</ClInclude>
<ClInclude Include="..\..\Core\HW\Camera.h">
<Filter>HW</Filter>
</ClInclude>
+9
View File
@@ -343,6 +343,15 @@ ARCH_FILES := \
$(SRC)/Core/MIPS/ARM64/Arm64Jit.cpp \
$(SRC)/Core/MIPS/ARM64/Arm64RegCache.cpp \
$(SRC)/Core/MIPS/ARM64/Arm64RegCacheFPU.cpp \
$(SRC)/Core/MIPS/ARM64/Arm64IRAsm.cpp \
$(SRC)/Core/MIPS/ARM64/Arm64IRCompALU.cpp \
$(SRC)/Core/MIPS/ARM64/Arm64IRCompBranch.cpp \
$(SRC)/Core/MIPS/ARM64/Arm64IRCompFPU.cpp \
$(SRC)/Core/MIPS/ARM64/Arm64IRCompLoadStore.cpp \
$(SRC)/Core/MIPS/ARM64/Arm64IRCompSystem.cpp \
$(SRC)/Core/MIPS/ARM64/Arm64IRCompVec.cpp \
$(SRC)/Core/MIPS/ARM64/Arm64IRJit.cpp \
$(SRC)/Core/MIPS/ARM64/Arm64IRRegCache.cpp \
$(SRC)/Core/Util/DisArm64.cpp \
$(SRC)/GPU/Common/VertexDecoderArm64.cpp \
Arm64EmitterTest.cpp
+42 -42
View File
@@ -1,7 +1,7 @@
[Achievements]
%1: Attempt failed = %1: Próba nieudana
%1: Attempt started = %1: Próba wystartowała
%d achievements, %d points = %d achievements, %d points
%d achievements, %d points = %d Osiągnięć, %d punktów
Account = Konto
Achievement progress = Postęp osiągnięcia
Achievement unlocked = Osiągnięcie odblokowane
@@ -20,15 +20,15 @@ Customize = Dostosuj
Earned = Zdobyłeś %d z %d osiągnięć i %d z %d punktów
Encore Mode = Encore Mode
Failed logging in to RetroAchievements = Logowanie do RetroAchievements nieudane
Failed to connect to RetroAchievements. Achievements will not unlock. = Failed to connect to RetroAchievements. Achievements will not unlock.
Failed to identify game. Achievements will not unlock. = Failed to identify game. Achievements will not unlock.
Failed to connect to RetroAchievements. Achievements will not unlock. = Łączenie z serwerem RetroAchievements nieudane. Osiągnięcia nie będą odblokowywane.
Failed to identify game. Achievements will not unlock. = Identyfikacja gry nieudana. Osiągnięcia nie będą odblokowywane.
How to use RetroAchievements = Jak używać RetroAchievements
In Encore mode - listings may be wrong below = In Encore mode - listings may be wrong below
Leaderboard attempt started or failed = Leaderboard attempt started or failed
Leaderboard result submitted = Leaderboard result submitted
Leaderboard score submission = Leaderboard score submission
Leaderboard submission is enabled = Leaderboard submission is enabled
Leaderboard tracker = Leaderboard tracker
Leaderboard attempt started or failed = Start Tabeli wyników udany lub nieudany
Leaderboard result submitted = Rezultat tabeli wyników przesłany
Leaderboard score submission = Przesyłanie rezultatów tabeli wyników
Leaderboard submission is enabled = Przesyłanie rezultatów tabeli wyników włączone
Leaderboard tracker = Śledzenie tabeli wyników
Leaderboards = Tabele wyników
Links = Linki
Locked achievements = Zablokowane osiągnięcia
@@ -36,21 +36,21 @@ Log bad memory accesses = Rejestruj złe dostępy do pamięci
Mastered %1 = Wymaksowane %1
Notifications = Powiadomiemia
Recently unlocked achievements = Ostatnio odblokowane osiągnięcia
Reconnected to RetroAchievements. = Reconnected to RetroAchievements.
Reconnected to RetroAchievements. = Połączono ponownie z RetroAchievements.
Register on www.retroachievements.org = Zarejestruj się na www.retroachievements.org
RetroAchievements are not available for this game = Usługa RetroAchievements nie jest dostępna dla tej gry
RetroAchievements website = Strona internetowa RetroAchievements
Rich Presence = Rich Presence
Save state loaded without achievement data = Save state loaded without achievement data
Save states not available in Challenge Mode = Save states not available in Challenge Mode
Save state loaded without achievement data = Zapis stanu załadowany bez danych osiągnięć
Save states not available in Challenge Mode = Zapisy stanu nie są dostępne w Trybie Wyzwania
Sound Effects = Efekty dźwiękowe
Statistics = Statystyki
Submitted %1 for %2 = Submitted %1 for %2
Submitted %1 for %2 = Przesłano %1 dla %2
Syncing achievements data... = Synchronizacja osiągnięć...
Test Mode = Tryb Testowy
This feature is not available in Challenge Mode = This feature is not available in Challenge Mode
This game has no achievements = Ta gra nie ma osiągnięć
Top players = Top players
This feature is not available in Challenge Mode = Ta funkcja nie jest dostępna w Trybie Wyzwania
This game has no achievements = Ta gra nie posiada osiągnięć
Top players = Najlepsi gracze
Unlocked achievements = Odblokowane osiągnięcia
Unofficial achievements = Nieoficjalnie osiągnięcia
Unsupported achievements = Niewspierane osiągnięcia
@@ -106,10 +106,10 @@ Deadzone radius = Promień martwej strefy
Disable D-Pad diagonals (4-way touch) = Wył. przekątne krzyżaka (pozostaw 4 kierunki)
Disable diagonal input = Wyłącz wejście cyfrowe
Double tap = Dwukrotne dotknięcie
Enable analog stick gesture = Enable analog stick gesture
Enable gesture control = Włącz kontrolę kestami
Enable analog stick gesture = Włącz gesty gałki analogowej
Enable gesture control = Włącz kontrolę gestami
Enable standard shortcut keys = Włącz standardowe klawisze skrótów
frames = frames
frames = klatki
Gesture = Gesty
Gesture mapping = Konfiguracja gestów
Glowing borders = Świecące krawędzie
@@ -138,7 +138,7 @@ OnScreen = Przyciski ekranowe
Portrait = Pionowo
Portrait Reversed = Odwrócone pionowo
PSP Action Buttons = Klawisze akcji PSP
Rapid fire interval = Rapid fire interval
Rapid fire interval =
Raw input = Zwykłe wejście
Repeat mode = Tryb powtarzania
Reset to defaults = Domyślne
@@ -147,7 +147,7 @@ Sensitivity (scale) = Czułość (dostosuj)
Sensitivity = Czułość
Shape = Kształt
Show Touch Pause Menu Button = Pokaż dotykowy przycisk Menu Pauzy
Sticky D-Pad (easier sweeping movements) = Sticky D-Pad (easier sweeping movements)
Sticky D-Pad (easier sweeping movements) = Lepki D-Pad (łatwiejsze ruchy rozległe)
Swipe = Przesunięcie palcem
Swipe sensitivity = Czułość przesunięcia
Swipe smoothing = Wygładzanie przesunięcia
@@ -159,10 +159,10 @@ Tilt Sensitivity along Y axis = Czułość przechyłu wzdłuż osi Y
To Calibrate = Trzymaj urządzenie pod preferowanym kątem i naciśnij „Kalibracja”.
Toggle mode = Zmień tryb
Touch Control Visibility = Kontroler dotykowy (widoczny)
Use custom right analog = Use custom right analog
Use custom right analog = Użyj niestandardowego prawego analoga
Use Mouse Control = Włącz kontrolę myszką
Visibility = Widoczność
Visible = WIdoczny
Visible = Widoczny
X = X
Y = Y
@@ -186,7 +186,7 @@ Break = Zatrzymaj
Break on Load = Zatrzymaj po załadowaniu
Buy Gold = Kup wersję Gold
Control Mapping... = Ustawienia przycisków...
Copy PSP memory base address = Copy PSP memory base &address
Copy PSP memory base address = Copy Skopiuj bazę i adresy pamięci PSP
Debugging = &Debugowanie
Deposterize = Deposteryzacja
Direct3D9 = &Direct3D9
@@ -281,11 +281,11 @@ Backspace = Backspace
Block address = Adres bloku
By Address = Po adresie
Copy savestates to memstick root = Skopiuj zapisane stany do folderu głównego Karty Pamięci
Create frame dump = Create frame dump
Create frame dump = Stwórz zrzut klatki
Create/Open textures.ini file for current game = Stwórz/otwórz plik textures.ini z bieżącej gry
Current = Obecny
Debug overlay = Debug overlay
Debug stats = Debug stats
Debug overlay = Nakładka debugowania
Debug stats = Statystyki debugowania
Dev Tools = Narzędzia Developerskie
DevMenu = Menu deweloperskie
Disabled JIT functionality = Wyłącz funkcje JIT
@@ -310,10 +310,10 @@ Log Dropped Frame Statistics = Loguj statystyki pominiętych klatek
Log Level = Poziom dziennika zdarzeń
Log View = Pokaż dziennik zdarzeń
Logging Channels = Kanały dziennika zdarzeń debugera
Multi-threaded rendering = Multi-threaded rendering
Multi-threaded rendering = Renderowanie wielowątkowe
Next = Następny
No block = Brak bloku
Off = Off
Off = Wyłączone
Prev = Poprzedni
Random = Przypadkowy
Replace textures = Podmiana tekstur
@@ -332,7 +332,7 @@ System Information = Informacje o systemie
Texture ini file created = Stworzono plik ini Tekstury
Texture Replacement = Podmiana tekstur
Audio Debug = Debugowanie audio
Control Debug = Control Debug
Control Debug = Debugowanie sterowania
Toggle Freeze = Wł./Wył. zamrożenie
Touchscreen Test = Test ekranu dotykowego
Ubershaders = Ubershaders
@@ -386,7 +386,7 @@ Grid = Rozmiar siatki
Inactive = Nieaktywny
Installing... = Instalowanie...
InternalError = Występił wewnętrzny błąd aplikacji
Links = Links
Links = Linki
Load = Wczytaj
Load completed = Ładowanie zakończone.
Loading = Ładowanie\nProszę czekać...
@@ -483,7 +483,7 @@ PS1 EBOOTs are not supported by PPSSPP. = Pliki EBOOT PS1 nie są obsługiwane p
PSX game image detected. = Plik jest obrazem MODE2. PPSSPP nie obsługuje gier z PS1.
RAR file detected (Require UnRAR) = Wykryto plik RAR.\nRozpakuj go przed użyciem (spróbuj UnRAR).
RAR file detected (Require WINRAR) = Wykryto plik RAR.\nRozpakuj go przed użyciem (spróbuj WinRAR).
Running slow: try frameskip, sound is choppy when slow = Running slow: try frameskip, sound is choppy when slow
Running slow: Wypróbuj pomijania klatek, dźwięk przerywa gdy emulacja spowalnia = Running slow: try frameskip, sound is choppy when slow
Running slow: Try turning off Software Rendering = Running slow: try turning off "software rendering"
Running slow: Wolne działanie: spróbuj pomijania klatek, dźwięk zacina przy wolnym działaniu
Running slow: Wolne działanie: spróbuj wyłączyć "Renderowanie programowe"
@@ -647,7 +647,7 @@ Software Rendering = Renderowanie programowe (wolne)
Software Skinning = Programowy skinning
SoftwareSkinning Tip = Łączy na CPU wywołania rysujące modele z animacjami, przyspieszenie w większości gier
Speed = Prędkość (procentowo)
Speed Hacks = Speed Hacks (powodują problemy)
Speed Hacks = Haki Prędkościowe (powodują problemy)
Stereo display shader = Stereoskopowe wyświetlanie shaderów
Stereo rendering = Renderowanie stereoskopowe
Stretch = Rozciąganie
@@ -764,12 +764,12 @@ L = L
Left = Strzałka w lewo
Load State = Wczytaj stan
Mute toggle = Przełącznik wyciszenia
Next Slot = Następny slot
Next Slot = Następny Slot
None = Nic
Note = Notka
OpenChat = Otwórz czat
Pause = Pauza
Previous Slot = Previous Slot
Previous Slot = Poprzedni Slot
R = R
RapidFire = Auto. strzelanie
Record = Nagraj
@@ -784,7 +784,7 @@ RightAn.Up = Pr. gałk. w górę
Rotate Analog (CCW) = Obróć analog (CCW)
Rotate Analog (CW) = Obróć analog (CW)
Save State = Zapisz stan
Screen = Screen
Screen = Ekran
Screenshot = Zrzut ekranu
Select = Select
SpeedToggle = Zmień prędkość
@@ -799,7 +799,7 @@ Texture Dumping = Zrzut tekstur
Texture Replacement = Podmiana tekstur
Toggle Fullscreen = Wł./wył. pełny ekran
Toggle mode = Tryb przełączania
Toggle WLAN = Toggle WLAN
Toggle WLAN = Przełącz WLAN
Triangle = Trójkąt
Fast-forward = Pełna prędkość
Up = Strzałka w górę
@@ -809,7 +809,7 @@ Wlan = WLAN
[MemStick]
Already contains PSP data = Już zawiera dane PSP
Cancelled - try again = Cancelled - try again
Cancelled - try again = Anulowano - spróbuj ponownie
Create or Choose a PSP folder = Utwórz lub Wybierz folder PSP
Current = Obecny
DataCanBeShared = Dane mogą być udostępniane pomiędzy zwykłą wersją PPSSPP, a wersją Gold
@@ -870,7 +870,7 @@ Failed to Bind Port = Błąd przy przypisywaniu portu
Failed to connect to Adhoc Server = Błąd przy łączeniu z serwerem Ad-Hoc
Forced First Connect = Wymuszenie pierwszego połączenie (szybsze łączenie)
#GM = Dane z nieznanego portu
GM: Data from Unknown Port = GM: Data from Unknown Port
GM: Data from Unknown Port = GM: Dane z nieznanego portu
Hostname = Nazwa hosta
Invalid IP or hostname = Niepoprawny adres IP lub nazwa hosta
Minimum Timeout = Minimalny czas oczekiwania (podaj w ms, domyślnie 0)
@@ -886,7 +886,7 @@ Quick Chat 3 = Szybki czat 3
Quick Chat 4 = Szybki czat 4
Quick Chat 5 = Szybki czat 5
QuickChat = Szybki czat
Randomize = Randomize
Randomize = Losuj
Send = Wyślij
Send Discord Presence information = Przesyłaj informacje Discord Rich Presence
Unable to find UPnP device = Nie udało się zlokalizować urządzenia UPnP
@@ -905,7 +905,7 @@ Chinese (traditional) = Chinese (traditional)
Dutch = Dutch
English = English
French = French
Game language = Game language
Game language = Język gry
German = German
Italian = Italian
Japanese = Japanese
@@ -1006,7 +1006,7 @@ tools = Wykorzystane narzędzia:
# Add translators1-6 for up to 6 lines of translator credits.
# Leave extra lines blank. 4 contributors per line seems to look best.
translators1 = Daniel Kluz, Michał Kasprzak, Mateusz Godlewski, Łukasz Bereza
translators2 = oop23, Silent, Patrxgt
translators2 = oop23, Silent, Patrxgt, Dominik
translators3 = Poprzednią edycję tłumaczenia stworzyli:
translators4 = hrydgard, The Dax, mikusp, adrian17
translators5 =
@@ -1187,7 +1187,7 @@ OpenGL Extensions = Rozszerzenia OpenGL
Optimal frames per buffer = Optymalna ilość klatek na bufor
Optimal sample rate = Optymalna częstotliwość próbkowania
OS Information = Informacje o OS
Pixel resolution = Pixel resolution
Pixel resolution = Rozdzielczość pixeli
PPSSPP build = Kompilacja PPSSPP
Present modes = Present modes
Refresh rate = Częstotliwość odświeżania
+17 -18
View File
@@ -130,7 +130,7 @@ Deadzone radius = Raio da zona morta
Disable D-Pad diagonals (4-way touch) = Desativar diagonais do D-Pad (toque de 4 direções)
Disable diagonal input = Desativar entrada diagonal
Double tap = Toque duplo
Enable analog stick gesture = Enable analog stick gesture
Enable analog stick gesture = Ativar gesto do direcional analógico
Enable gesture control = Ativar controle dos gestos
Enable standard shortcut keys = Ativar teclas padrão dos atalhos
frames = frames
@@ -170,7 +170,7 @@ Sensitivity = Sensibilidade
Sensitivity (scale) = Sensibilidade (escala)
Shape = Forma
Show Touch Pause Menu Button = Mostrar o botão do menu da pausa
Sticky D-Pad (easier sweeping movements) = Sticky D-Pad (easier sweeping movements)
Sticky D-Pad (easier sweeping movements) = Direcional pegajoso (movimentos abrangentes mais fáceis)
Swipe = Deslizar
Swipe sensitivity = Sensibilidade do deslizar
Swipe smoothing = Suavidade do deslizar
@@ -310,8 +310,8 @@ Copy savestates to memstick root = Copiar os save states pra raiz do cartão de
Create frame dump = Criar dump do frame
Create/Open textures.ini file for current game = Criar/Abrir o arquivo textures.ini pro jogo atual
Current = Atual
Debug overlay = Debug overlay
Debug stats = Debug stats
Debug overlay = Sobreposição do debug
Debug stats = Estatísticas do debug
Dev Tools = Ferramentas de desenvolvimento
DevMenu = Menu do DEV
Disabled JIT functionality = Funcionalidade do JIT desativada
@@ -326,7 +326,7 @@ FPU = FPU
Framedump tests = Testes dos dumps dos frames
Frame Profiler = Analista dos frames
Frame timing = Tempo do frame
GPU Allocator Viewer = GPU Allocator Viewer
GPU Allocator Viewer = Visualizador do Distribuidor da GPU
GPU Driver Test = Teste do driver da GPU
GPU Profile = Perfil da GPU
GPU log profiler = Criador do perfil do registro da GPU
@@ -339,7 +339,7 @@ Logging Channels = Canais do registro
Multi-threaded rendering = Renderização multi-threads
Next = Próximo
No block = Nenhum bloco
Off = Off
Off = Desligado
Prev = Anterior
Random = Aleatório
Replace textures = Substituir texturas
@@ -454,7 +454,6 @@ Supported = Suportado
There is no data = Não há dados.
Toggle All = Alternar todos
Toggle List = Alternar lista
Top Center = Top center
Unsupported = Não suportado
Top Left = A esquerda do topo
Top Right = A direita do topo
@@ -615,7 +614,7 @@ Frame Skipping = Pulo dos frames
Frame Skipping Type = Tipo de pulo dos frames
FullScreen = Tela cheia
Geometry shader culling = Abate do shader da geometria
Hack Settings = Configurações dos hacks (pode causar erros gráficos)
Hack Settings = Configurações dos hacks (pode causar erros gráficos)
Hardware Tessellation = Tesselação por hardware
Hardware Transform = Transformação por hardware
hardware transform error - falling back to software = Erro de transformação pelo hardware, retrocedendo pro software.
@@ -980,17 +979,17 @@ tools = Ferramentas grátis usadas:
# Leave extra lines blank. 4 contributors per line seems to look best.
translators1 = Papel, gabrielmop, Efraim Lopes, AkiraJkr
translators2 = Felipe
translators3 =
translators4 =
translators5 =
translators6 =
translators3 =
translators4 =
translators5 =
translators6 =
Twitter @PPSSPP_emu = Twitter @PPSSPP_emu
website = Verifique o site da web:
written = Escrito em C++ pela velocidade e portabilidade
[MemStick]
Already contains PSP data = Já contém dados do PSP
Cancelled - try again = Cancelled - try again
Cancelled - try again = Cancelado - tente de novo
Create or Choose a PSP folder = Criar ou escolher uma pasta do PSP
Current = Atual
DataCanBeShared = Os dados podem ser compartilhados entre o PPSSPP regular/Gold
@@ -1189,7 +1188,7 @@ Icon cache = Cache do ícone
JIT available = JIT disponível
Lang/Region = Idioma/Região
Memory Page Size = Tamanho da página de memória
Native resolution = Resolução nativa
Native Resolution = Resolução nativa
No GPU driver bugs detected = Não foram detectado bugs no driver da GPU
OGL Extensions = Extensões do OGL
OpenGL ES 2.0 Extensions = Extensões do OpenGL 2.0 ES
@@ -1198,12 +1197,12 @@ OpenGL Extensions = Extensões do OpenGL
Optimal frames per buffer = Melhores frames por buffer
Optimal sample rate = Melhor taxa de amostragem
OS Information = Informação do sistema operacional
Pixel resolution = Pixel resolution
Pixel resolution = Resolução dos pixels
PPSSPP build = Build do PPSSPP
Present modes = Present modes
Present modes = Modos presentes
Refresh rate = Taxa de atualização
Release = Lançamento
RW/RX exclusive = RW/RX exclusivo
RW/RX exclusive = Exclusivo do RW/RX
Sample rate = Taxa de amostragem
Shading Language = Idioma do shader
Storage = Armazenagem
@@ -1212,7 +1211,7 @@ System Information = Informação do sistema
System Name = Nome
System Version = Versão do sistema
Threads = Threads
UI resolution = Resolução da Interface do Usuário
UI Resolution = Resolução da Interface do Usuário
Vendor = Vendedor
Vendor (detected) = Vendedor (detectado)
Version Information = Informação da versão
+15 -15
View File
@@ -106,7 +106,7 @@ Deadzone radius = Радиус мертвой зоны
Disable D-Pad diagonals (4-way touch) = Отключить крестовину по диагонали
Disable diagonal input = Отключить диагональный ввод
Double tap = Двойное нажатие
Enable analog stick gesture = Enable analog stick gesture
Enable analog stick gesture = Включить жест аналогового стика
Enable gesture control = Включить настройку жестов
Enable standard shortcut keys = Включить стандартные сочетания клавиш
frames = кадров
@@ -147,7 +147,7 @@ Sensitivity (scale) = Чувствительность (шкала)
Sensitivity = Чувствительность
Shape = Форма
Show Touch Pause Menu Button = Показывать кнопку паузы
Sticky D-Pad (easier sweeping movements) = Sticky D-Pad (easier sweeping movements)
Sticky D-Pad (easier sweeping movements) = Прилипающий D-Pad (облегченные масштабные движения)
Swipe = Свайпы
Swipe sensitivity = Чувствительность свайпов
Swipe smoothing = Сглаживание свайпов
@@ -284,8 +284,8 @@ Copy savestates to memstick root = Копировать состояния со
Create frame dump = Создать дамп кадра
Create/Open textures.ini file for current game = Создать/открыть файл textures.ini для текущей игры
Current = Текущий
Debug overlay = Debug overlay
Debug stats = Debug stats
Debug overlay = Оверлей отладки
Debug stats = Статистика отладки
Dev Tools = Инструменты разработчика
DevMenu = Меню разраб.
Disabled JIT functionality = Отключение функционала JIT
@@ -300,7 +300,7 @@ Fragment = Фрагмент
Frame timing = Время кадра
Framedump tests = Тест дампов кадров
Frame Profiler = Профайлер кадров
GPU Allocator Viewer = GPU Allocator Viewer
GPU Allocator Viewer = Просмотрщик аллокатора ГП
GPU Driver Test = Проверка драйвера ГП
GPU log profiler = Профилировщик логов ГП
GPU Profile = Профиль ГП
@@ -313,7 +313,7 @@ Logging Channels = Параметры логирования
Multi-threaded rendering = Многопоточный рендеринг
Next = Следующий
No block = Нет блока
Off = Off
Off = Выкл.
Prev = Предыдущий
Random = Случайный
Replace textures = Подменять текстуры
@@ -331,8 +331,8 @@ Stats = Статистика
System Information = Информация о системе
Texture ini file created = Создан файл textures.ini
Texture Replacement = Подмена текстур
Audio Debug = отладку аудио
Control Debug = отладку управления
Audio Debug = Отладка аудио
Control Debug = Отладка управления
Toggle Freeze = Запустить/остановить
Touchscreen Test = Тест сенсорного экрана
Ubershaders = Убершейдеры
@@ -375,7 +375,7 @@ Disabled = Отключено
Dumps = Дампы
Edit = Изменить
Enable All = Включить все
Enabled = Enabled
Enabled = Включено
Enter = Ввод
Failed to connect to server, check your internet connection. = Не удалось подключиться к серверу, проверьте ваше интернет-соединение.
Failed to log in, check your username and password. = Не удалось войти, проверьте ваши имя пользователя и пароль.
@@ -386,7 +386,7 @@ Grid = Сетка
Inactive = Неактивно
Installing... = Установка...
InternalError = Произошла внутренняя ошибка.
Links = Links
Links = Ссылки
Load = Загрузить
Load completed = Загрузка завершена
Loading = Загрузка\nПожалуйста, подождите...
@@ -419,7 +419,7 @@ SavingFailed = Не удалось сохранить.
Search = Поиск
seconds, 0:off = секунд, 0 = выкл.
Select = Выбрать
Settings = Settings
Settings = Настройки
Shift = Сдвинуть
Skip = Пропустить
Snap = Разметка
@@ -434,7 +434,7 @@ Top Center = Вверху в центре
Top Left = Вверху слева
Top Right = Вверу справа
Unsupported = Не поддерживается
Username = Username
Username = Имя пользователя
When you save, it will load on a PSP, but not an older PPSSPP = Когда вы сохранитесь, оно может быть загружено на PSP, но не на старой версии PPSSPP
When you save, it will not work on outdated PSP Firmware anymore = Когда вы сохранитесь, оно больше не будет работать на устаревших версиях прошивки PSP
Yes = Да
@@ -982,7 +982,7 @@ written = Написан на C++ для скорости и портируем
[MemStick]
Already contains PSP data = Уже содержит данные PSP
Cancelled - try again = Cancelled - try again
Cancelled - try again = Отменено - попробуйте еще раз
Create or Choose a PSP folder = Создайте или выберите папку PSP
Current = Текущая
DataCanBeShared = Данные могут передаваться между обычным PPSSPP и Gold
@@ -1182,9 +1182,9 @@ OpenGL Extensions = Расширения OpenGL
Optimal frames per buffer = Оптимально кадров на буфер
Optimal sample rate = Оптимальная частота дискретизации
OS Information = Информация об ОС
Pixel resolution = Pixel resolution
Pixel resolution = Пиксельное разрешение
PPSSPP build = Сборка PPSSPP
Present modes = Present modes
Present modes = Режимы представления
Refresh rate = Частота обновления
Release = Релизная
RW/RX exclusive = Захват RW/RX
+11 -12
View File
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.13)
# option() honors normal variables.
# see: https://cmake.org/cmake/help/git-stage/policy/CMP0077.html
@@ -51,15 +51,15 @@ set(PROCESSOR_IS_X86 FALSE)
set(PROCESSOR_IS_POWER FALSE)
set(PROCESSOR_IS_S390X FALSE)
set(PROCESSOR_IS_RISCV FALSE)
set(PROCESSOR_IS_LOONGARCH64 FALSE)
set(PROCESSOR_IS_LOONGARCH FALSE)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
set(PROCESSOR_IS_MIPS TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(^aarch64)|(^arm64)|(^ARM64)")
set(PROCESSOR_IS_AARCH64 TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
set(PROCESSOR_IS_ARM TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(AMD64|amd64)|(^i.86$)")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(x86_64)|(AMD64|amd64)|(^i.86$)")
set(PROCESSOR_IS_X86 TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
set(PROCESSOR_IS_POWER TRUE)
@@ -67,8 +67,8 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(s390x)")
set(PROCESSOR_IS_S390X TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^riscv")
set(PROCESSOR_IS_RISCV TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^loongarch64")
set(PROCESSOR_IS_LOONGARCH64 TRUE)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^loongarch")
set(PROCESSOR_IS_LOONGARCH TRUE)
endif()
macro(add_cpu_features_headers_and_sources HDRS_LIST_NAME SRCS_LIST_NAME)
@@ -82,6 +82,7 @@ macro(add_cpu_features_headers_and_sources HDRS_LIST_NAME SRCS_LIST_NAME)
list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/../../cpu_features/include/cpuinfo_arm.h)
elseif(PROCESSOR_IS_AARCH64)
list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/../../cpu_features/include/cpuinfo_aarch64.h)
list(APPEND ${SRCS_LIST_NAME} ${PROJECT_SOURCE_DIR}/../../cpu_features/include/internal/windows_utils.h)
elseif(PROCESSOR_IS_X86)
list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/../../cpu_features/include/cpuinfo_x86.h)
list(APPEND ${SRCS_LIST_NAME} ${PROJECT_SOURCE_DIR}/../../cpu_features/include/internal/cpuid_x86.h)
@@ -92,8 +93,8 @@ macro(add_cpu_features_headers_and_sources HDRS_LIST_NAME SRCS_LIST_NAME)
list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/../../cpu_features/include/cpuinfo_s390x.h)
elseif(PROCESSOR_IS_RISCV)
list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/../../cpu_features/include/cpuinfo_riscv.h)
elseif(PROCESSOR_IS_LOONGARCH64)
# TODO
elseif(PROCESSOR_IS_LOONGARCH)
list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/../../cpu_features/include/cpuinfo_loongarch.h)
else()
message(FATAL_ERROR "Unsupported architectures ${CMAKE_SYSTEM_PROCESSOR}")
endif()
@@ -153,10 +154,8 @@ endif()
target_include_directories(cpu_features
PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/cpu_features>
)
if(PROCESSOR_IS_X86)
if(APPLE)
target_compile_definitions(cpu_features PRIVATE HAVE_SYSCTLBYNAME)
endif()
if(APPLE)
target_compile_definitions(cpu_features PRIVATE HAVE_SYSCTLBYNAME)
endif()
add_library(CpuFeature::cpu_features ALIAS cpu_features)
+9
View File
@@ -757,6 +757,15 @@ ifeq ($(WITH_DYNAREC),1)
$(COREDIR)/MIPS/ARM64/Arm64Jit.cpp \
$(COREDIR)/MIPS/ARM64/Arm64RegCache.cpp \
$(COREDIR)/MIPS/ARM64/Arm64RegCacheFPU.cpp \
$(COREDIR)/MIPS/ARM64/Arm64IRAsm.cpp \
$(COREDIR)/MIPS/ARM64/Arm64IRCompALU.cpp \
$(COREDIR)/MIPS/ARM64/Arm64IRCompBranch.cpp \
$(COREDIR)/MIPS/ARM64/Arm64IRCompFPU.cpp \
$(COREDIR)/MIPS/ARM64/Arm64IRCompLoadStore.cpp \
$(COREDIR)/MIPS/ARM64/Arm64IRCompSystem.cpp \
$(COREDIR)/MIPS/ARM64/Arm64IRCompVec.cpp \
$(COREDIR)/MIPS/ARM64/Arm64IRJit.cpp \
$(COREDIR)/MIPS/ARM64/Arm64IRRegCache.cpp \
$(COREDIR)/Util/DisArm64.cpp \
$(GPUCOMMONDIR)/VertexDecoderArm64.cpp