mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
riscv: Initial staffolding for IR based jit.
This commit is contained in:
parent
3468423bb4
commit
e271e43ec5
@ -1609,6 +1609,8 @@ list(APPEND CoreExtra
|
||||
)
|
||||
|
||||
list(APPEND CoreExtra
|
||||
Core/MIPS/RiscV/RiscVJit.cpp
|
||||
Core/MIPS/RiscV/RiscVJit.h
|
||||
GPU/Common/VertexDecoderRiscV.cpp
|
||||
)
|
||||
|
||||
|
@ -593,6 +593,7 @@
|
||||
<ClCompile Include="MIPS\IR\IRPassSimplify.cpp" />
|
||||
<ClCompile Include="MIPS\IR\IRRegCache.cpp" />
|
||||
<ClCompile Include="MIPS\MIPSVFPUFallbacks.cpp" />
|
||||
<ClCompile Include="MIPS\RiscV\RiscVJit.cpp" />
|
||||
<ClCompile Include="Replay.cpp" />
|
||||
<ClCompile Include="Compatibility.cpp" />
|
||||
<ClCompile Include="Config.cpp" />
|
||||
@ -1161,6 +1162,7 @@
|
||||
<ClInclude Include="MIPS\IR\IRPassSimplify.h" />
|
||||
<ClInclude Include="MIPS\IR\IRRegCache.h" />
|
||||
<ClInclude Include="MIPS\MIPSVFPUFallbacks.h" />
|
||||
<ClInclude Include="MIPS\RiscV\RiscVJit.h" />
|
||||
<ClInclude Include="Replay.h" />
|
||||
<ClInclude Include="Compatibility.h" />
|
||||
<ClInclude Include="Config.h" />
|
||||
|
@ -91,6 +91,9 @@
|
||||
<Filter Include="MIPS\fake">
|
||||
<UniqueIdentifier>{678fa299-0ff7-4983-982d-2da47b52e238}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="MIPS\RiscV">
|
||||
<UniqueIdentifier>{067e3128-3aaf-4ed1-b19e-bab11606abe7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ELF\ElfReader.cpp">
|
||||
@ -1204,6 +1207,9 @@
|
||||
<ClCompile Include="RetroAchievements.cpp">
|
||||
<Filter>Core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MIPS\RiscV\RiscVJit.cpp">
|
||||
<Filter>MIPS\RiscV</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ELF\ElfReader.h">
|
||||
@ -1950,6 +1956,9 @@
|
||||
<ClInclude Include="RetroAchievements.h">
|
||||
<Filter>Core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MIPS\RiscV\RiscVJit.h">
|
||||
<Filter>MIPS\RiscV</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\LICENSE.TXT" />
|
||||
|
@ -170,8 +170,8 @@ public:
|
||||
void LinkBlock(u8 *exitPoint, const u8 *checkedEntry) override;
|
||||
void UnlinkBlock(u8 *checkedEntry, u32 originalAddress) override;
|
||||
|
||||
private:
|
||||
bool CompileBlock(u32 em_address, std::vector<IRInst> &instructions, u32 &mipsBytes, bool preload);
|
||||
protected:
|
||||
virtual bool CompileBlock(u32 em_address, std::vector<IRInst> &instructions, u32 &mipsBytes, bool preload);
|
||||
|
||||
JitOptions jo;
|
||||
|
||||
|
@ -45,6 +45,8 @@
|
||||
#include "../x86/Jit.h"
|
||||
#elif PPSSPP_ARCH(MIPS)
|
||||
#include "../MIPS/MipsJit.h"
|
||||
#elif PPSSPP_ARCH(RISCV64)
|
||||
#include "../RiscV/RiscVJit.h"
|
||||
#else
|
||||
#include "../fake/FakeJit.h"
|
||||
#endif
|
||||
@ -108,6 +110,8 @@ namespace MIPSComp {
|
||||
return new MIPSComp::Jit(mipsState);
|
||||
#elif PPSSPP_ARCH(MIPS)
|
||||
return new MIPSComp::MipsJit(mipsState);
|
||||
#elif PPSSPP_ARCH(RISCV64)
|
||||
return new MIPSComp::RiscVJit(mipsState);
|
||||
#else
|
||||
return new MIPSComp::FakeJit(mipsState);
|
||||
#endif
|
||||
|
79
Core/MIPS/RiscV/RiscVJit.cpp
Normal file
79
Core/MIPS/RiscV/RiscVJit.cpp
Normal file
@ -0,0 +1,79 @@
|
||||
// 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 "Core/MIPS/RiscV/RiscVJit.h"
|
||||
#include "Common/Profiler/Profiler.h"
|
||||
|
||||
namespace MIPSComp {
|
||||
|
||||
RiscVJit::RiscVJit(MIPSState *mipsState) : IRJit(mipsState) {
|
||||
AllocCodeSpace(1024 * 1024 * 16);
|
||||
|
||||
// TODO: gpr, fpr, GenerateFixedCode(jo);
|
||||
}
|
||||
|
||||
void RiscVJit::RunLoopUntil(u64 globalticks) {
|
||||
PROFILE_THIS_SCOPE("jit");
|
||||
((void (*)())enterDispatcher_)();
|
||||
}
|
||||
|
||||
bool RiscVJit::CompileBlock(u32 em_address, std::vector<IRInst> &instructions, u32 &mipsBytes, bool preload) {
|
||||
if (!IRJit::CompileBlock(em_address, instructions, mipsBytes, preload))
|
||||
return false;
|
||||
|
||||
// TODO: Compile native.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RiscVJit::DescribeCodePtr(const u8 *ptr, std::string &name) {
|
||||
// TODO: Describe for debugging / profiling.
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RiscVJit::CodeInRange(const u8 *ptr) const {
|
||||
return IsInSpace(ptr);
|
||||
}
|
||||
|
||||
bool RiscVJit::IsAtDispatchFetch(const u8 *ptr) const {
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
const u8 *RiscVJit::GetDispatcher() const {
|
||||
// TODO
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const u8 *RiscVJit::GetCrashHandler() const {
|
||||
// TODO: Implement a crash handler
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void RiscVJit::ClearCache() {
|
||||
IRJit::ClearCache();
|
||||
|
||||
ClearCodeSpace(jitStartOffset_);
|
||||
FlushIcacheSection(region + jitStartOffset_, region + region_size - jitStartOffset_);
|
||||
}
|
||||
|
||||
void RiscVJit::UpdateFCR31() {
|
||||
IRJit::UpdateFCR31();
|
||||
|
||||
// TODO: Handle rounding modes.
|
||||
}
|
||||
|
||||
} // namespace MIPSComp
|
53
Core/MIPS/RiscV/RiscVJit.h
Normal file
53
Core/MIPS/RiscV/RiscVJit.h
Normal file
@ -0,0 +1,53 @@
|
||||
// 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 "Common/RiscVEmitter.h"
|
||||
#include "Core/MIPS/IR/IRJit.h"
|
||||
|
||||
namespace MIPSComp {
|
||||
|
||||
class RiscVJit : public RiscVGen::RiscVCodeBlock, public IRJit {
|
||||
public:
|
||||
RiscVJit(MIPSState *mipsState);
|
||||
|
||||
void RunLoopUntil(u64 globalticks) override;
|
||||
|
||||
bool DescribeCodePtr(const u8 *ptr, std::string &name) override;
|
||||
bool CodeInRange(const u8 *ptr) const override;
|
||||
bool IsAtDispatchFetch(const u8 *ptr) const override;
|
||||
const u8 *GetDispatcher() const override;
|
||||
const u8 *GetCrashHandler() const override;
|
||||
|
||||
void ClearCache() override;
|
||||
void UpdateFCR31() override;
|
||||
|
||||
// TODO: GetBlockCacheDebugInterface, block linking?
|
||||
|
||||
protected:
|
||||
bool CompileBlock(u32 em_address, std::vector<IRInst> &instructions, u32 &mipsBytes, bool preload) override;
|
||||
|
||||
private:
|
||||
void GenerateFixedCode(const JitOptions &jo);
|
||||
|
||||
const u8 *enterDispatcher_ = nullptr;
|
||||
|
||||
int jitStartOffset_ = 0;
|
||||
};
|
||||
|
||||
} // namespace MIPSComp
|
Loading…
Reference in New Issue
Block a user