Merge pull request #701 from reicast/feat/rec-cpp
Initial implementation of a "dynarec-structured" cached shop interpreter
This commit is contained in:
commit
75fd698695
|
@ -37,6 +37,10 @@ ifdef X64_REC
|
|||
RZDCY_MODULES += rec-x64/
|
||||
endif
|
||||
|
||||
ifdef CPP_REC
|
||||
RZDCY_MODULES += rec-cpp/
|
||||
endif
|
||||
|
||||
ifndef NO_REND
|
||||
RZDCY_MODULES += rend/gles/
|
||||
else
|
||||
|
|
|
@ -86,6 +86,8 @@ extern double speed_load_mspdf;
|
|||
double speed_load_mspdf;
|
||||
#endif
|
||||
|
||||
int mips_counter;
|
||||
|
||||
double full_rps;
|
||||
|
||||
u32 fskip=0;
|
||||
|
@ -184,12 +186,13 @@ int spg_line_sched(int tag, int cycl, int jit)
|
|||
spd_cpu*100/200,spd_vbs,
|
||||
mode,res,fullvbs,
|
||||
spd_fps,fskip/ts);
|
||||
#else
|
||||
sprintf(fpsStr,"%s/%c - %4.2f (%4.2f) - %4.2f - V: %4.2f (%.2f, %s%s%4.2f) R: %4.2f+%4.2f VTX: %4.2f%c",
|
||||
#else
|
||||
sprintf(fpsStr,"%s/%c - %4.2f (%4.2f) - %4.2f - V: %4.2f (%.2f, %s%s%4.2f) R: %4.2f+%4.2f VTX: %4.2f%c, MIPS: %.2f",
|
||||
VER_SHORTNAME,'n',mspdf,speed_load_mspdf,spd_cpu*100/200,spd_vbs,
|
||||
spd_vbs/full_rps,mode,res,fullvbs,
|
||||
spd_fps,fskip/ts
|
||||
,mv,mv_c);
|
||||
, mv, mv_c, mips_counter/ 1024.0 / 1024.0);
|
||||
mips_counter = 0;
|
||||
#endif
|
||||
|
||||
fskip=0;
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
#include "hw/sh4/sh4_mem.h"
|
||||
#include "decoder_opcodes.h"
|
||||
|
||||
#define BLOCK_MAX_SH_OPS_SOFT 500
|
||||
#define BLOCK_MAX_SH_OPS_HARD 511
|
||||
|
||||
RuntimeBlockInfo* blk;
|
||||
|
||||
|
||||
|
@ -1054,7 +1057,10 @@ void dec_DecodeBlock(RuntimeBlockInfo* rbi,u32 max_cycles)
|
|||
//there is no break here by design
|
||||
case NDO_NextOp:
|
||||
{
|
||||
if (blk->guest_cycles>=max_cycles && !state.cpu.is_delayslot)
|
||||
if (
|
||||
( (blk->oplist.size() >= BLOCK_MAX_SH_OPS_SOFT) || (blk->guest_cycles >= max_cycles) )
|
||||
&& !state.cpu.is_delayslot
|
||||
)
|
||||
{
|
||||
dec_End(state.cpu.rpc,BET_StaticJump,false);
|
||||
}
|
||||
|
@ -1142,6 +1148,8 @@ _end:
|
|||
blk->NextBlock=state.NextAddr;
|
||||
blk->BranchBlock=state.JumpAddr;
|
||||
blk->BlockType=state.BlockType;
|
||||
|
||||
verify(blk->oplist.size() <= BLOCK_MAX_SH_OPS_HARD);
|
||||
|
||||
#if HOST_OS == OS_WINDOWS
|
||||
switch(rbi->addr)
|
||||
|
|
|
@ -28,12 +28,13 @@
|
|||
#if FEAT_SHREC != DYNAREC_NONE
|
||||
//uh uh
|
||||
|
||||
#if HOST_OS == OS_WINDOWS
|
||||
u8 SH4_TCB[2*CODE_SIZE+4096];
|
||||
u8 SH4_TCB[2*CODE_SIZE+4096]
|
||||
#if HOST_OS == OS_WINDOWS || FEAT_SHREC != DYNAREC_JIT
|
||||
;
|
||||
#elif HOST_OS == OS_LINUX
|
||||
u8 SH4_TCB[2*CODE_SIZE+4096] __attribute__((section(".text")));
|
||||
__attribute__((section(".text")));
|
||||
#elif HOST_OS==OS_DARWIN
|
||||
u8 SH4_TCB[2*CODE_SIZE+4096] __attribute__((section("__TEXT,.text")));
|
||||
__attribute__((section("__TEXT,.text")));
|
||||
#else
|
||||
#error SH4_TCB ALLOC
|
||||
#endif
|
||||
|
|
|
@ -42,7 +42,7 @@ extern "C" f32 fipr_asm(float* fn, float* fm);
|
|||
#define shil_opc(name) struct shil_opcl_##name {
|
||||
#define shil_opc_end() };
|
||||
|
||||
#define shil_canonical(rv,name,args,code) static rv name args { code }
|
||||
#define shil_canonical(rv,name,args,code) struct name { static rv impl args { code } };
|
||||
|
||||
#define shil_cf_arg_u32(x) ngen_CC_Param(op,&op->x,CPT_u32);
|
||||
#define shil_cf_arg_f32(x) ngen_CC_Param(op,&op->x,CPT_f32);
|
||||
|
@ -50,7 +50,8 @@ extern "C" f32 fipr_asm(float* fn, float* fm);
|
|||
#define shil_cf_rv_u32(x) ngen_CC_Param(op,&op->x,CPT_u32rv);
|
||||
#define shil_cf_rv_f32(x) ngen_CC_Param(op,&op->x,CPT_f32rv);
|
||||
#define shil_cf_rv_u64(x) ngen_CC_Param(op,&op->rd,CPT_u64rvL); ngen_CC_Param(op,&op->rd2,CPT_u64rvH);
|
||||
#define shil_cf(x) ngen_CC_Call(op,(void*)x);
|
||||
#define shil_cf_ext(x) ngen_CC_Call(op,(void*)&x);
|
||||
#define shil_cf(x) shil_cf_ext(x::impl)
|
||||
|
||||
#define shil_compile(code) static void compile(shil_opcode* op) { ngen_CC_Start(op); code ngen_CC_Finish(op); }
|
||||
#elif SHIL_MODE==2
|
||||
|
@ -61,7 +62,7 @@ extern "C" f32 fipr_asm(float* fn, float* fm);
|
|||
#define shil_opc(name) struct shil_opcl_##name {
|
||||
#define shil_opc_end() };
|
||||
|
||||
#define shil_canonical(rv,name,args,code) static rv cimpl_##name args;
|
||||
#define shil_canonical(rv,name,args,code) struct name { static rv impl args; };
|
||||
#define shil_compile(code) static void compile(shil_opcode* op);
|
||||
#elif SHIL_MODE==3
|
||||
//generate struct list ...
|
||||
|
@ -93,7 +94,7 @@ extern "C" f32 fipr_asm(float* fn, float* fm);
|
|||
|
||||
|
||||
|
||||
#if SHIL_MODE==1
|
||||
#if SHIL_MODE==1 || SHIL_MODE==2
|
||||
//only in structs we use the code :)
|
||||
#include <math.h>
|
||||
#include "types.h"
|
||||
|
@ -206,18 +207,26 @@ shil_opc_end()
|
|||
|
||||
//Canonical impl. opcodes !
|
||||
shil_opc(sync_sr)
|
||||
shil_canonical
|
||||
(
|
||||
void, f1, (),
|
||||
UpdateSR();
|
||||
)
|
||||
shil_compile
|
||||
(
|
||||
shil_cf(UpdateSR);
|
||||
//die();
|
||||
shil_cf(f1);
|
||||
)
|
||||
shil_opc_end()
|
||||
|
||||
shil_opc(sync_fpscr)
|
||||
shil_canonical
|
||||
(
|
||||
void, f1, (),
|
||||
UpdateFPSCR();
|
||||
)
|
||||
shil_compile
|
||||
(
|
||||
shil_cf(UpdateFPSCR);
|
||||
//die();
|
||||
shil_cf(f1);
|
||||
)
|
||||
shil_opc_end()
|
||||
|
||||
|
@ -981,7 +990,7 @@ shil_opc_end()
|
|||
|
||||
|
||||
|
||||
//shop_ftrv
|
||||
//shop_frswap
|
||||
shil_opc(frswap)
|
||||
shil_canonical
|
||||
(
|
||||
|
|
|
@ -13,23 +13,23 @@ u8* sh4_dyna_rcb;
|
|||
|
||||
INLINE void ChangeGPR()
|
||||
{
|
||||
u32 temp[8];
|
||||
u32 temp;
|
||||
for (int i=0;i<8;i++)
|
||||
{
|
||||
temp[i]=r[i];
|
||||
temp=r[i];
|
||||
r[i]=r_bank[i];
|
||||
r_bank[i]=temp[i];
|
||||
r_bank[i]=temp;
|
||||
}
|
||||
}
|
||||
|
||||
INLINE void ChangeFP()
|
||||
{
|
||||
u32 temp[16];
|
||||
u32 temp;
|
||||
for (int i=0;i<16;i++)
|
||||
{
|
||||
temp[i]=fr_hex[i];
|
||||
temp=fr_hex[i];
|
||||
fr_hex[i]=xf_hex[i];
|
||||
xf_hex[i]=temp[i];
|
||||
xf_hex[i]=temp;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -265,6 +265,7 @@ u32* GetRegPtr(u32 reg)
|
|||
u32 cvld;
|
||||
u32 rdmt[6];
|
||||
extern u32 memops_t,memops_l;
|
||||
extern int mips_counter;
|
||||
|
||||
void CheckBlock(RuntimeBlockInfo* block,x86_ptr_imm place)
|
||||
{
|
||||
|
@ -286,6 +287,8 @@ void CheckBlock(RuntimeBlockInfo* block,x86_ptr_imm place)
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ngen_Compile(RuntimeBlockInfo* block,bool force_checks, bool reset, bool staging,bool optimise)
|
||||
{
|
||||
//initialise stuff
|
||||
|
@ -305,7 +308,11 @@ void ngen_Compile(RuntimeBlockInfo* block,bool force_checks, bool reset, bool st
|
|||
|
||||
x86e->Emit(op_add32,&memops_t,block->memops);
|
||||
x86e->Emit(op_add32,&memops_l,block->linkedmemops);
|
||||
|
||||
|
||||
#ifdef MIPS_COUNTER
|
||||
x86e->Emit(op_add32, &mips_counter, block->oplist.size());
|
||||
#endif
|
||||
|
||||
//run register allocator
|
||||
reg.DoAlloc(block,alloc_regs,xmm_alloc_regs);
|
||||
|
||||
|
|
|
@ -1034,7 +1034,7 @@ void tryfit(float* x,float* y)
|
|||
for (int i=0;i<128;i++)
|
||||
{
|
||||
float diff=min(max(b*logf(x[i])/logf(2.0)+a,(double)0),(double)1)-y[i];
|
||||
maxdev=max((float)abs(diff),(float)maxdev);
|
||||
maxdev=max((float)fabs((float)diff),(float)maxdev);
|
||||
}
|
||||
printf("FOG TABLE Curve match: maxdev: %.02f cents\n",maxdev*100);
|
||||
fog_coefs[0]=a;
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
FOR_LINUX :=1
|
||||
NOT_ARM := 1
|
||||
CPP_REC := 1
|
||||
#NO_REC := 1
|
||||
#NO_REND := 1
|
||||
WEBUI :=1
|
||||
USE_ALSA := 1
|
||||
USE_OSS := 1
|
||||
#USE_PULSEAUDIO := 1
|
||||
|
||||
RZDCY_SRC_DIR = ../../core
|
||||
|
||||
include $(RZDCY_SRC_DIR)/core.mk
|
||||
|
||||
|
||||
CXX=${CC_PREFIX}g++
|
||||
CC=${CC_PREFIX}gcc
|
||||
AS=${CC_PREFIX}as
|
||||
STRIP=${CC_PREFIX}strip
|
||||
|
||||
LD=${CC}
|
||||
|
||||
MFLAGS := #-m32
|
||||
#-marm -march=armv7-a -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp -funroll-loops
|
||||
ASFLAGS :=
|
||||
#-march=armv7-a -mfpu=neon -mfloat-abi=softfp
|
||||
|
||||
LDFLAGS := -g -Wl,-Map,$(notdir $@).map,--gc-sections -Wl,-O3 -Wl,--sort-common
|
||||
|
||||
CFLAGS := -g -O3 -D RELEASE -c -D TARGET_LINUX_x64 -D USES_HOMEDIR -D TARGET_NO_JIT
|
||||
CFLAGS += -D SUPPORT_X11
|
||||
CFLAGS += -frename-registers -fno-strict-aliasing #-fsingle-precision-constant
|
||||
CFLAGS += -ffast-math -ftree-vectorize
|
||||
|
||||
|
||||
#-fprefetch-loop-arrays
|
||||
#-std=c++0x
|
||||
CXXFLAGS += $(CFLAGS) $(MFLAGS) -fexceptions -fno-rtti -fpermissive -std=gnu++11
|
||||
CXXFLAGS += -D SUPPORT_X11
|
||||
CXXFLAGS += -fno-operator-names
|
||||
|
||||
ifdef PGO_MAKE
|
||||
CFLAGS += -fprofile-generate -pg
|
||||
LDFLAGS += -fprofile-generate
|
||||
else
|
||||
CFLAGS += -fomit-frame-pointer
|
||||
endif
|
||||
|
||||
ifdef PGO_USE
|
||||
CFLAGS += -fprofile-use
|
||||
endif
|
||||
|
||||
|
||||
ifdef LTO_TEST
|
||||
CFLAGS += -flto -fwhole-program
|
||||
LDFLAGS +=-flto -fwhole-program
|
||||
endif
|
||||
|
||||
INCS := -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/deps -I$(RZDCY_SRC_DIR)/khronos
|
||||
|
||||
LIBS := # use system libs
|
||||
LIBS += -lm -lrt -ldl
|
||||
LIBS += -lpthread -lX11
|
||||
|
||||
ifdef USE_ALSA
|
||||
CXXFLAGS += -D USE_ALSA
|
||||
LIBS += -lasound
|
||||
endif
|
||||
|
||||
ifdef USE_OSS
|
||||
CXXFLAGS += -D USE_OSS
|
||||
endif
|
||||
|
||||
ifdef USE_PULSEAUDIO
|
||||
CXXFLAGS += -D USE_PULSEAUDIO
|
||||
LIBS += -lpulse-simple
|
||||
endif
|
||||
|
||||
ifdef USE_GLES
|
||||
CXXFLAGS += -DGLES
|
||||
LIBS += -lEGL -lGLESv2
|
||||
else
|
||||
LIBS += -ldl -lGL #for desktop gl
|
||||
endif
|
||||
|
||||
|
||||
OBJECTS=$(RZDCY_FILES:.cpp=.build_obj)
|
||||
OBJECTS:=$(OBJECTS:.c=.build_obj)
|
||||
OBJECTS:=$(OBJECTS:.S=.build_obj)
|
||||
OBJECTS:=$(patsubst $(RZDCY_SRC_DIR)/%,obj/%,$(OBJECTS))
|
||||
|
||||
|
||||
EXECUTABLE_STRIPPED=nosym-reicast.elf
|
||||
EXECUTABLE=reicast.elf
|
||||
|
||||
PACKAGE_FILES=$(EXECUTABLE_STRIPPED) default.gcw0.desktop icon-32.png
|
||||
|
||||
all: $(CPPFILES) $(EXECUTABLE) $(EXECUTABLE_STRIPPED)
|
||||
|
||||
$(EXECUTABLE): $(OBJECTS)
|
||||
$(CXX) $(MFLAGS) $(EXTRAFLAGS) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@
|
||||
|
||||
$(EXECUTABLE_STRIPPED): $(EXECUTABLE)
|
||||
cp $< $@ && $(STRIP) $@
|
||||
|
||||
obj/%.build_obj : $(RZDCY_SRC_DIR)/%.cpp
|
||||
mkdir -p $(dir $@)
|
||||
$(CXX) $(EXTRAFLAGS) $(INCS) $(CFLAGS) $(CXXFLAGS) $< -o $@
|
||||
|
||||
obj/%.build_obj : $(RZDCY_SRC_DIR)/%.c
|
||||
mkdir -p $(dir $@)
|
||||
$(CC) $(EXTRAFLAGS) $(INCS) $(CFLAGS) $< -o $@
|
||||
|
||||
obj/%.build_obj : $(RZDCY_SRC_DIR)/%.S
|
||||
mkdir -p $(dir $@)
|
||||
$(AS) $(ASFLAGS) $(INCS) $< -o $@
|
||||
|
||||
|
||||
clean:
|
||||
rm $(OBJECTS) $(EXECUTABLE) -f
|
|
@ -1,8 +1,15 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.31101.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reicast", "reicast.vcxproj", "{58B14048-EACB-4780-8B1E-9C84C2C30A8E}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B03DF793-41BA-4F47-A4F2-C06E52FAFB13}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
Performance2.psess = Performance2.psess
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
|
@ -23,4 +30,7 @@ Global
|
|||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(Performance) = preSolution
|
||||
HasPerformanceSessions = true
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -162,6 +162,10 @@
|
|||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Fast|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Fast|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\core\rec-cpp\rec_cpp.cpp">
|
||||
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Fast|x64'">/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Slow|x64'">/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\core\rec-x64\rec_x64.cpp" />
|
||||
<ClCompile Include="..\core\rec-x86\rec_x86_driver.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Fast|x64'">true</ExcludedFromBuild>
|
||||
|
|
|
@ -414,6 +414,9 @@
|
|||
<ClCompile Include="..\core\rec-x64\rec_x64.cpp">
|
||||
<Filter>rec-x64</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\core\rec-cpp\rec_cpp.cpp">
|
||||
<Filter>rec-cpp</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="hw">
|
||||
|
@ -542,6 +545,9 @@
|
|||
<Filter Include="rec-x64">
|
||||
<UniqueIdentifier>{f73263e9-dbe8-4a6f-8b73-335af8307551}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="rec-cpp">
|
||||
<UniqueIdentifier>{63d1fcf2-64b4-4973-995f-cd471f51117c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\core\hw\aica\aica.h">
|
||||
|
|
Loading…
Reference in New Issue