Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IR Interpreter #8725

Merged
merged 82 commits into from
May 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
d399c4a
Initial commit for IRJit
hrydgard May 6, 2016
4acf85a
It's kind of starting to run
hrydgard May 7, 2016
12edfce
Enough to run cpu_alu.prx.
hrydgard May 7, 2016
38b7d89
Fix a performance issue in CallSyscall
hrydgard May 7, 2016
3c5510e
Disable debug file logging, fix issue with replacement functions, etc
hrydgard May 7, 2016
750d520
Initial work on mult and friends. Fix another bug.
hrydgard May 7, 2016
a33f8b6
ir-jit: Get rid of the regcache. Should be replaced with optimization…
hrydgard May 7, 2016
09969c0
Use the regcache in a new (incomplete) pass, PropagateConstants.
hrydgard May 7, 2016
ce8aae5
Make the IRJit core selectable in developer tools
hrydgard May 7, 2016
1a2edc6
Add support for float store/load
hrydgard May 8, 2016
7d4774d
Fix wsbw
hrydgard May 8, 2016
e750987
ir-jit: Fix bug in ext
hrydgard May 8, 2016
46e839b
ir-jit: Fix bugs in rounding
hrydgard May 8, 2016
aae32bd
ir-jit: Re-enable mult. Fix bvf/bvt
hrydgard May 8, 2016
14df39d
Fix IRTEMP clash bug. Add more cases to the constant propagation pass.
hrydgard May 8, 2016
98113ed
More simplify pass
hrydgard May 8, 2016
3eb5480
Initial VFPU
hrydgard May 8, 2016
492ea5f
Address a bunch of comments, thanks for the review
hrydgard May 8, 2016
f8659b8
Move the IR interpreter out into its own file. Rename it in the UI. …
hrydgard May 8, 2016
4e52f61
Additional fixes and buildfixes
hrydgard May 8, 2016
ed0a037
Another buildfix
hrydgard May 8, 2016
52517ab
Fix the fix
hrydgard May 8, 2016
5dbac16
Qt, gcc, and Symbian buildfixes.
unknownbrackets May 8, 2016
d4480d5
jit-ir: Less instructions cause flushing in constant propagation.
hrydgard May 8, 2016
c7e4658
More constant propagation
hrydgard May 8, 2016
d19174b
jit-ir: Skip const flush on downcount op.
unknownbrackets May 8, 2016
0d7f151
jit-ir: Add a utility func for applying passes.
unknownbrackets May 8, 2016
d09f3a2
jit-ir: Propagate single-op constants.
unknownbrackets May 8, 2016
a22ff68
jit-ir: Skip flushing when updating PC.
unknownbrackets May 9, 2016
a1b4b51
jit-ir: Propagate constants even for overlaps.
unknownbrackets May 9, 2016
5221a02
jit-ir: Propagate constants for shifts.
unknownbrackets May 9, 2016
6bd31ec
jit-ir: Flush consts better for a few f/v ops.
unknownbrackets May 9, 2016
7ce923d
jit-ir: Fix SetConstV.
unknownbrackets May 9, 2016
f638477
jit-ir: Add the rest to PropagateConstants.
unknownbrackets May 9, 2016
f6d245f
jit-ir: Remove redundant simplify pass.
unknownbrackets May 9, 2016
ccb8f8d
jit-ir: Fix replacement hooks.
unknownbrackets May 9, 2016
dee2a7e
Merge pull request #8727 from unknownbrackets/ir-jit
hrydgard May 9, 2016
eb6551d
jit-ir: Correct downcount handling.
unknownbrackets May 9, 2016
b1a180d
Merge pull request #8731 from unknownbrackets/ir-jit
hrydgard May 9, 2016
f50617d
Skip const flush on set float constant
hrydgard May 8, 2016
6e44e97
Refactor prep: Split JitInterface into MIPSFrontendInterface and JitI…
hrydgard May 9, 2016
e806c36
Separate the IR frontend from the IR "Jit"
hrydgard May 9, 2016
e711a47
Complete the separation of the IR compiler frontend from the "Jit"
hrydgard May 9, 2016
28087a6
IRFrontend shouldn't know about IRBlock
hrydgard May 9, 2016
a5d5c5c
Do the voffset remapping before the IR. This will let us easily add s…
hrydgard May 9, 2016
558bb19
More VFPU
hrydgard May 9, 2016
45efcda
IR: Some more VFPU
hrydgard May 10, 2016
db1d1ff
IR: Merge the FPU and VFPU instruction sets, no reason to keep them a…
hrydgard May 10, 2016
b3dd369
Prefix prep
hrydgard May 10, 2016
219548b
Prefix prep
hrydgard May 10, 2016
2cbfb19
IR: Lots more VFPU support, some with SIMD
hrydgard May 12, 2016
cb251ea
Crashfix in savestate (hmmmm...)
hrydgard May 12, 2016
182674c
IR: SIMD another matrix orientation. Fix various issues.
hrydgard May 12, 2016
850d0ab
IR: More VFPU. Support normal fp compares.
hrydgard May 12, 2016
c69a8c0
Forgot this
hrydgard May 12, 2016
1851458
Bugfixes
hrydgard May 12, 2016
7268abe
IR: vcmp, vcmov, vhdp
hrydgard May 12, 2016
99468c6
jit-ir: Optimize out unused temp regs.
unknownbrackets May 10, 2016
d06c6c0
jit-ir: Expand unused regs to regular GPRs.
unknownbrackets May 10, 2016
9f183c9
jit-ir: Prevent reading ahead for each reg write.
unknownbrackets May 13, 2016
29ed8d2
jit-ir: ExitToReg doesn't write to registers.
unknownbrackets May 13, 2016
a8126ca
jit-ir: Add some missing CONDITIONAL_DISABLEs.
unknownbrackets May 13, 2016
57b3dbf
jit-ir: Avoid flushing on a few Vec4 ops.
unknownbrackets May 13, 2016
1ddb2fb
jit-ir: Fix non-SSE Vec4Scale.
unknownbrackets May 13, 2016
c11c046
jir-ir: Correct vftm SIMD regs.
unknownbrackets May 13, 2016
f521203
jit-ir: Apply prefixes for vector init ops.
unknownbrackets May 13, 2016
9e3572d
jit-ir: Improve vidt to handle more cases.
unknownbrackets May 13, 2016
7b43e0e
jit-ir: Add nan/inf compares.
unknownbrackets May 13, 2016
49b1339
Merge pull request #8732 from unknownbrackets/ir-jit
hrydgard May 13, 2016
066b0b7
jit-ir: Optimize out beql; break; sequences.
unknownbrackets May 13, 2016
fc9159f
Merge pull request #8733 from unknownbrackets/ir-jit
hrydgard May 13, 2016
f636b2a
Minor build and other fixes
hrydgard May 13, 2016
91a6cf5
Add a couple more passes (2-op, optimize f<->v fp moves)
hrydgard May 13, 2016
5b25041
Optimize some common prefixes
hrydgard May 13, 2016
5923013
Simple workaround for timing issue with coreState after syscall.
hrydgard May 13, 2016
b7091a8
Simplifications and fixes
hrydgard May 13, 2016
b7224e2
Qt: Remove CPU core option from menu.
unknownbrackets May 14, 2016
efc8a8e
Hack to make Symbian build.
unknownbrackets May 14, 2016
e2aca38
Try enabling Travis caching.
unknownbrackets May 14, 2016
042dcc1
Merge pull request #8735 from hrydgard/ir-jit-test
hrydgard May 14, 2016
7a7c3b9
More VFPU, vmmul thoughts
hrydgard May 13, 2016
91bc3c3
Warning fixes
hrydgard May 14, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .travis.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#/bin/bash

export NDK_CCACHE=ccache
NDK_VER=android-ndk-r10d

download_extract() {
Expand Down Expand Up @@ -85,7 +86,7 @@ travis_script() {
# Compile PPSSPP
if [ "$PPSSPP_BUILD_TYPE" = "Linux" ]; then
if [ "$CXX" = "g++" ]; then
export CXX="g++-4.8" CC="gcc-4.8"
export CXX="ccache g++-4.8" CC="ccache gcc-4.8"
fi

if [ "$QT" = "TRUE" ]; then
Expand Down Expand Up @@ -123,6 +124,8 @@ travis_script() {
}

travis_after_success() {
ccache -s

if [ "$PPSSPP_BUILD_TYPE" = "Linux" ]; then
./test.py
fi
Expand Down
43 changes: 29 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ sudo: required

language: cpp

os: linux

dist: trusty

compiler:
- gcc
addons:
apt:
packages:
- build-essential
- libgl1-mesa-dev
- libglu1-mesa-dev
- cmake

env:
- PPSSPP_BUILD_TYPE=Linux
CMAKE=TRUE
- PPSSPP_BUILD_TYPE=Android
- PPSSPP_BUILD_TYPE=Blackberry
CMAKE=TRUE
- PPSSPP_BUILD_TYPE=Symbian
cache:
- apt
- ccache

notifications:
irc:
Expand All @@ -30,15 +29,31 @@ notifications:

matrix:
include:
- compiler: clang
- os: linux
compiler: "gcc linux"
env: PPSSPP_BUILD_TYPE=Linux
CMAKE=TRUE
- os: linux
compiler: "gcc android"
env: PPSSPP_BUILD_TYPE=Android
- os: linux
compiler: "gcc blackberry"
env: PPSSPP_BUILD_TYPE=Blackberry
CMAKE=TRUE
- os: linux
compiler: "gcc symbian"
env: PPSSPP_BUILD_TYPE=Symbian
- os: linux
compiler: "clang linux"
env: PPSSPP_BUILD_TYPE=Linux
CMAKE=TRUE
- compiler: gcc
- os: linux
compiler: "gcc qt"
env: PPSSPP_BUILD_TYPE=Linux
QT=TRUE
# Can't get iOS to work.
# - os: osx
# compiler: clang
# compiler: "clang ios"
# env: PPSSPP_BUILD_TYPE=iOS
# CMAKE=TRUE

Expand Down
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,27 @@ include_directories(ext/xxhash)

set(CoreExtra)
set(CoreExtraLibs)

set(CoreExtra ${CoreExtra}
Core/MIPS/IR/IRCompALU.cpp
Core/MIPS/IR/IRCompBranch.cpp
Core/MIPS/IR/IRCompFPU.cpp
Core/MIPS/IR/IRCompLoadStore.cpp
Core/MIPS/IR/IRCompVFPU.cpp
Core/MIPS/IR/IRFrontend.cpp
Core/MIPS/IR/IRFrontend.h
Core/MIPS/IR/IRInst.cpp
Core/MIPS/IR/IRInst.h
Core/MIPS/IR/IRInterpreter.cpp
Core/MIPS/IR/IRInterpreter.h
Core/MIPS/IR/IRJit.cpp
Core/MIPS/IR/IRJit.h
Core/MIPS/IR/IRPassSimplify.cpp
Core/MIPS/IR/IRPassSimplify.h
Core/MIPS/IR/IRRegCache.cpp
Core/MIPS/IR/IRRegCache.h
)

if(ARM)
set(CoreExtra ${CoreExtra}
Core/MIPS/ARM/ArmAsm.cpp
Expand Down
17 changes: 7 additions & 10 deletions Common/CommonFuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,27 @@
#include "base/compat.h"
#include "CommonTypes.h"

#if defined(IOS) || defined(MIPS)
#include <signal.h>
#endif

template <bool> struct CompileTimeAssert;
template<> struct CompileTimeAssert<true> {};

#ifndef _WIN32
#if !defined(_WIN32)

#include <unistd.h>
#include <errno.h>

#if defined(_M_IX86) || defined(_M_X86)
#define Crash() {asm ("int $3");}
#define Crash() {asm ("int $3");}
#else
#define Crash() {kill(getpid(), SIGINT);}
#include <signal.h>
#define Crash() {kill(getpid(), SIGINT);}
#endif

#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))

inline u32 __rotl(u32 x, int shift) {
shift &= 31;
if (!shift) return x;
return (x << shift) | (x >> (32 - shift));
shift &= 31;
if (!shift) return x;
return (x << shift) | (x >> (32 - shift));
}

inline u64 __rotl64(u64 x, unsigned int shift){
Expand Down
27 changes: 19 additions & 8 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,20 @@ static int DefaultNumWorkers() {
return cpu_info.num_cores;
}

static bool DefaultJit() {
// TODO: Default to IRJit on iOS when it's done.
static int DefaultCpuCore() {
#ifdef IOS
return iosCanUseJit;
return iosCanUseJit ? CPU_CORE_JIT : CPU_CORE_INTERPRETER;
#elif defined(ARM) || defined(ARM64) || defined(_M_IX86) || defined(_M_X64)
return CPU_CORE_JIT;
#else
return CPU_CORE_INTERPRETER;
#endif
}

static bool DefaultCodeGen() {
#ifdef IOS
return iosCanUseJit ? true : false;
#elif defined(ARM) || defined(ARM64) || defined(_M_IX86) || defined(_M_X64)
return true;
#else
Expand Down Expand Up @@ -353,7 +364,7 @@ static bool DefaultSasThread() {
}

static ConfigSetting cpuSettings[] = {
ReportedConfigSetting("Jit", &g_Config.bJit, &DefaultJit, true, true),
ReportedConfigSetting("CPUCore", &g_Config.iCpuCore, &DefaultCpuCore, true, true),
ReportedConfigSetting("SeparateCPUThread", &g_Config.bSeparateCPUThread, false, true, true),
ReportedConfigSetting("SeparateSASThread", &g_Config.bSeparateSASThread, &DefaultSasThread, true, true),
ReportedConfigSetting("SeparateIOThread", &g_Config.bSeparateIOThread, true, true, true),
Expand Down Expand Up @@ -463,7 +474,7 @@ static ConfigSetting graphicsSettings[] = {
ReportedConfigSetting("VertexCache", &g_Config.bVertexCache, true, true, true),
ReportedConfigSetting("TextureBackoffCache", &g_Config.bTextureBackoffCache, false, true, true),
ReportedConfigSetting("TextureSecondaryCache", &g_Config.bTextureSecondaryCache, false, true, true),
ReportedConfigSetting("VertexDecJit", &g_Config.bVertexDecoderJit, &DefaultJit, false),
ReportedConfigSetting("VertexDecJit", &g_Config.bVertexDecoderJit, &DefaultCodeGen, false),

#ifndef MOBILE_DEVICE
ConfigSetting("FullScreen", &g_Config.bFullScreen, false),
Expand Down Expand Up @@ -958,16 +969,16 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
}

// Override ppsspp.ini JIT value to prevent crashing
if (!DefaultJit() && g_Config.bJit) {
if (DefaultCpuCore() != CPU_CORE_JIT && g_Config.iCpuCore == CPU_CORE_JIT) {
jitForcedOff = true;
g_Config.bJit = false;
g_Config.iCpuCore = CPU_CORE_INTERPRETER;
}
}

void Config::Save() {
if (jitForcedOff) {
// if JIT has been forced off, we don't want to screw up the user's ppsspp.ini
g_Config.bJit = true;
g_Config.iCpuCore = CPU_CORE_JIT;
}
if (iniFilename_.size() && g_Config.bSaveSettings) {

Expand Down Expand Up @@ -1036,7 +1047,7 @@ void Config::Save() {
}
if (jitForcedOff) {
// force JIT off again just in case Config::Save() is called without exiting PPSSPP
g_Config.bJit = false;
g_Config.iCpuCore = CPU_CORE_INTERPRETER;
}
}

Expand Down
8 changes: 7 additions & 1 deletion Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ const int PSP_DEFAULT_FIRMWARE = 150;
static const s8 VOLUME_OFF = 0;
static const s8 VOLUME_MAX = 10;

enum CPUCore {
CPU_CORE_INTERPRETER = 0,
CPU_CORE_JIT = 1,
CPU_CORE_IRJIT = 2,
};

enum {
ROTATION_AUTO = 0,
ROTATION_LOCKED_HORIZONTAL = 1,
Expand Down Expand Up @@ -119,7 +125,7 @@ struct Config {
// Core
bool bIgnoreBadMemAccess;
bool bFastMemory;
bool bJit;
int iCpuCore;
bool bCheckForNewVersion;
bool bForceLagSync;
bool bFuncReplacements;
Expand Down
18 changes: 18 additions & 0 deletions Core/Core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,18 @@
<ClCompile Include="..\ext\udis86\syn-intel.c" />
<ClCompile Include="..\ext\udis86\syn.c" />
<ClCompile Include="..\ext\udis86\udis86.c" />
<ClCompile Include="MIPS\IR\IRAsm.cpp" />
<ClCompile Include="MIPS\IR\IRCompALU.cpp" />
<ClCompile Include="MIPS\IR\IRCompBranch.cpp" />
<ClCompile Include="MIPS\IR\IRCompFPU.cpp" />
<ClCompile Include="MIPS\IR\IRCompLoadStore.cpp" />
<ClCompile Include="MIPS\IR\IRCompVFPU.cpp" />
<ClCompile Include="MIPS\IR\IRFrontend.cpp" />
<ClCompile Include="MIPS\IR\IRInst.cpp" />
<ClCompile Include="MIPS\IR\IRInterpreter.cpp" />
<ClCompile Include="MIPS\IR\IRJit.cpp" />
<ClCompile Include="MIPS\IR\IRPassSimplify.cpp" />
<ClCompile Include="MIPS\IR\IRRegCache.cpp" />
<ClCompile Include="TextureReplacer.cpp" />
<ClCompile Include="Compatibility.cpp" />
<ClCompile Include="Config.cpp" />
Expand Down Expand Up @@ -507,6 +519,12 @@
<ClInclude Include="..\ext\udis86\types.h" />
<ClInclude Include="..\ext\udis86\udint.h" />
<ClInclude Include="..\ext\udis86\udis86.h" />
<ClInclude Include="MIPS\IR\IRFrontend.h" />
<ClInclude Include="MIPS\IR\IRInst.h" />
<ClInclude Include="MIPS\IR\IRInterpreter.h" />
<ClInclude Include="MIPS\IR\IRJit.h" />
<ClInclude Include="MIPS\IR\IRPassSimplify.h" />
<ClInclude Include="MIPS\IR\IRRegCache.h" />
<ClInclude Include="TextureReplacer.h" />
<ClInclude Include="Compatibility.h" />
<ClInclude Include="Config.h" />
Expand Down
57 changes: 57 additions & 0 deletions Core/Core.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
<Filter Include="FileLoaders">
<UniqueIdentifier>{67687dba-8313-4442-b4eb-4be8c4867b65}</UniqueIdentifier>
</Filter>
<Filter Include="MIPS\IR">
<UniqueIdentifier>{119ac973-e457-4025-9e1e-4fb34022ae23}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="ELF\ElfReader.cpp">
Expand Down Expand Up @@ -634,6 +637,42 @@
<ClCompile Include="TextureReplacer.cpp">
<Filter>Core</Filter>
</ClCompile>
<ClCompile Include="MIPS\IR\IRAsm.cpp">
<Filter>MIPS\IR</Filter>
</ClCompile>
<ClCompile Include="MIPS\IR\IRCompALU.cpp">
<Filter>MIPS\IR</Filter>
</ClCompile>
<ClCompile Include="MIPS\IR\IRCompBranch.cpp">
<Filter>MIPS\IR</Filter>
</ClCompile>
<ClCompile Include="MIPS\IR\IRCompFPU.cpp">
<Filter>MIPS\IR</Filter>
</ClCompile>
<ClCompile Include="MIPS\IR\IRCompLoadStore.cpp">
<Filter>MIPS\IR</Filter>
</ClCompile>
<ClCompile Include="MIPS\IR\IRCompVFPU.cpp">
<Filter>MIPS\IR</Filter>
</ClCompile>
<ClCompile Include="MIPS\IR\IRJit.cpp">
<Filter>MIPS\IR</Filter>
</ClCompile>
<ClCompile Include="MIPS\IR\IRRegCache.cpp">
<Filter>MIPS\IR</Filter>
</ClCompile>
<ClCompile Include="MIPS\IR\IRInst.cpp">
<Filter>MIPS\IR</Filter>
</ClCompile>
<ClCompile Include="MIPS\IR\IRPassSimplify.cpp">
<Filter>MIPS\IR</Filter>
</ClCompile>
<ClCompile Include="MIPS\IR\IRInterpreter.cpp">
<Filter>MIPS\IR</Filter>
</ClCompile>
<ClCompile Include="MIPS\IR\IRFrontend.cpp">
<Filter>MIPS\IR</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ELF\ElfReader.h">
Expand Down Expand Up @@ -1179,6 +1218,24 @@
<ClInclude Include="TextureReplacer.h">
<Filter>Core</Filter>
</ClInclude>
<ClInclude Include="MIPS\IR\IRJit.h">
<Filter>MIPS\IR</Filter>
</ClInclude>
<ClInclude Include="MIPS\IR\IRRegCache.h">
<Filter>MIPS\IR</Filter>
</ClInclude>
<ClInclude Include="MIPS\IR\IRInst.h">
<Filter>MIPS\IR</Filter>
</ClInclude>
<ClInclude Include="MIPS\IR\IRPassSimplify.h">
<Filter>MIPS\IR</Filter>
</ClInclude>
<ClInclude Include="MIPS\IR\IRInterpreter.h">
<Filter>MIPS\IR</Filter>
</ClInclude>
<ClInclude Include="MIPS\IR\IRFrontend.h">
<Filter>MIPS\IR</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
Expand Down
7 changes: 2 additions & 5 deletions Core/CoreParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
#include <string>

#include "Core/Compatibility.h"

enum CPUCore {
CPU_INTERPRETER,
CPU_JIT,
};
#include "Core/Config.h"

enum GPUCore {
GPUCORE_NULL,
Expand All @@ -46,6 +42,7 @@ struct CoreParameter {

CPUCore cpuCore;
GPUCore gpuCore;

GraphicsContext *graphicsContext; // TODO: Find a better place.
Thin3DContext *thin3d;
bool enableSound; // there aren't multiple sound cores.
Expand Down
4 changes: 2 additions & 2 deletions Core/CoreTiming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,9 @@ void ForceCheck()
int cyclesExecuted = slicelength - currentMIPS->downcount;
globalTimer += cyclesExecuted;
// This will cause us to check for new events immediately.
currentMIPS->downcount = 0;
currentMIPS->downcount = -1;
// But let's not eat a bunch more time in Advance() because of this.
slicelength = 0;
slicelength = 1;
}

void Advance()
Expand Down
Loading