Merge pull request #699 from reicast/feat/build-defines-cleanup

(Imma merge this, as it's needed for rec-cpp work, but that doesn't mean the discussion is closed)
This commit is contained in:
Stefanos Kornilios Mitsis Poiitidis 2015-07-25 14:03:35 +02:00
commit 39ead6159b
30 changed files with 232 additions and 86 deletions

View File

@ -1,21 +1,121 @@
/*
reicast build options
nullDC-Beagle build configuration options
Reicast can support a lot of stuff, and this is an attempt
to organize the build time options
fine grained options
HOST_OS,HOST_CPU, ..
Option categories
BUILD_* - BUILD_COMPILER, etc...
definitions about the build machine
HOST_*
definitions about the host machine
FEAT_*
definitions about the features that this build targets
This is higly related to HOST_*, but it's for options that might
or might not be avaiable depending on the target host, or that
features that are irrelevant of the host
Eg, Alsa, Pulse Audio and OSS might sense as HOST dedinitions
but it usually makes more sense to detect them as runtime. In
that context, HOST_ALSA makes no sense because the host might
or might not have alsa installed/ running
MMU makes no sense as a HOST definition at all, so it should
be FEAT_HAS_MMU
TARGET_*
A preconfigured default. Eg TARGET_WIN86.
Naming of options, option values, and how to use them
for options that makes sense to have a list of values
{CATEGORY}_{OPTION}
{OPTION}_{VALUE}
eg.
BUILD_COMPILER == COMPILER_GCC, HOST_CPU != CPU_X64, ...
for options that are boolean
{CATEGORY}_IS_{OPTION} or {CATEGORY}_HAS_{OPTION}
Evaluates to 0 or 1
If an configuration cannot be neatly split into a set of
of orthogonal options, then it makes sense to break things
to "sets" or have a hierarchy of options.
Example
-------
In the beggining it made sense to have an audio backend
per operating system. It made sense to have it depend
on HOST_OS and seleect DirectSound or alsa.
// no option needed
Then, as android was introduced, which also uses OS_LINUX
atm, the audio could have been made an option. It could be
a HOST_* option, or FEAT_* one. I'd prefer FEAT_*.
FEAT_* makes more sense as future wise we might want
to support multiple backends.
FEAT_AUDIO_BACKEND
AUDIO_BACKEND_NONE
AUDIO_BACKEND_DS
AUDIO_BACKEND_ALSA
AUDIO_BACKEND_ANDROID
Used like
#if FEAT_AUDIO_BACKEND == AUDIO_BACKEND_DS ....
At some point, we might have multiple audio backends that
can be compiled in and autodetected/selected at runtime.
In that case, it might make sense to have the options like
FEAT_HAS_ALSA
FEAT_HAS_DIRECTSOUND
FEAT_HAS_ANDROID_AUDIO
or
FEAT_HAS_AUDIO_ALSA
FEAT_HAS_AUDIO_DS
FEAT_HAS_AUDIO_ANDROID
The none option might or might not make sense. In this
case it can be removed, as it should always be avaiable.
Guidelines
----------
General rule of thumb, don't overcomplicate things. Start
with a simple option, and then make it more complicated
as new uses apply (see the example above)
Don't use too long names, don't use too cryptic names.
Most team developers should be able to understand or
figure out most of the acronyms used.
Try to be consistent on the acronyms across all definitions
Code shouldn't depend on build level options whenever possible
Generally, the file should compile even if the option/module is
disabled. This makes makefiles etc much easier to write
TARGET_* options should generally only be used in this file
The current source is *not* good example of these guidelines
We'll try to be smart and figure out some options/defaults on this file
but this shouldn't get too complicated
build-level options
TARGET_BEAGLE, TARGET_WIN86, ...
code shouldn't depend on build level options whenever possible
*/
//ndc configs
#define NO_MMU
//#define HOST_NO_REC
#define DC_PLATFORM_MASK 7
#define DC_PLATFORM_NORMAL 0 /* Works, for the most part */
@ -30,7 +130,6 @@
#define DC_PLATFORM DC_PLATFORM_NORMAL
//Target platform configs
//HOST_OS
#define OS_WINDOWS 0x10000001
#define OS_LINUX 0x10000002
@ -46,8 +145,20 @@
#define COMPILER_VC 0x30000001
#define COMPILER_GCC 0x30000002
#if defined(_WIN32) && !defined(TARGET_WIN86)
#define TARGET_WIN86
//FEAT_SHREC, FEAT_AREC, FEAT_DSPREC
#define DYNAREC_NONE 0x40000001
#define DYNAREC_JIT 0x40000002
#define DYNAREC_CPP 0x40000003
//automatic
#if defined(_WIN32) && !defined(TARGET_WIN86) && !defined(TARGET_WIN64)
#if !defined(_M_AMD64)
#define TARGET_WIN86
#else
#define TARGET_WIN64
#endif
#endif
#ifdef __GNUC__
@ -56,43 +167,85 @@
#define BUILD_COMPILER COMPILER_VC
#endif
#ifdef TARGET_WIN86
//Targets
#if defined(TARGET_WIN86)
#define HOST_OS OS_WINDOWS
#if defined(_M_AMD64)
#define HOST_CPU CPU_X64
#else
#define HOST_CPU CPU_X86
#endif
#elif TARGET_PANDORA
#elif defined(TARGET_WIN64)
#define HOST_OS OS_WINDOWS
#define HOST_CPU CPU_X64
#elif defined(TARGET_PANDORA)
#define HOST_OS OS_LINUX
#define HOST_CPU CPU_ARM
#elif TARGET_LINUX_ARMELv7
#elif defined(TARGET_LINUX_ARMELv7)
#define HOST_OS OS_LINUX
#define HOST_CPU CPU_ARM
#elif TARGET_LINUX_x86
#elif defined(TARGET_LINUX_x86)
#define HOST_OS OS_LINUX
#define HOST_CPU CPU_X86
#elif TARGET_LINUX_x64
#elif defined(TARGET_LINUX_x64)
#define HOST_OS OS_LINUX
#define HOST_CPU CPU_X64
#elif TARGET_LINUX_MIPS
#elif defined(TARGET_LINUX_MIPS)
#define HOST_OS OS_LINUX
#define HOST_CPU CPU_MIPS
#elif TARGET_GCW0
#elif defined(TARGET_GCW0)
#define HOST_OS OS_LINUX
#define HOST_CPU CPU_MIPS
#elif TARGET_NACL32
#elif defined(TARGET_NACL32)
#define HOST_OS OS_LINUX
#define HOST_CPU CPU_X86
#elif TARGET_IPHONE
#elif defined(TARGET_IPHONE)
#define HOST_OS OS_DARWIN
#define HOST_CPU CPU_ARM
#else
#error Invalid Target: TARGET_* not defined
#endif
#ifdef HOST_NO_REC
#ifndef HOST_NO_AREC
#define HOST_NO_AREC 1
#if defined(TARGET_NO_REC)
#define FEAT_SHREC DYNAREC_NONE
#define FEAT_AREC DYNAREC_NONE
#define FEAT_DSPREC DYNAREC_NONE
#endif
#if defined(TARGET_NO_AREC)
#define FEAT_SHREC DYNAREC_JIT
#define FEAT_AREC DYNAREC_NONE
#define FEAT_DSPREC DYNAREC_NONE
#endif
#if defined(TARGET_NO_JIT)
#define FEAT_SHREC DYNAREC_CPP
#define FEAT_AREC DYNAREC_NONE
#define FEAT_DSPREC DYNAREC_NONE
#endif
//defaults
#ifndef FEAT_SHREC
#define FEAT_SHREC DYNAREC_JIT
#endif
#ifndef FEAT_AREC
#if HOST_CPU == CPU_ARM || HOST_CPU == CPU_X86
#define FEAT_AREC DYNAREC_JIT
#else
#define FEAT_AREC DYNAREC_NONE
#endif
#endif
#ifndef FEAT_DSPREC
#if HOST_CPU == CPU_X86
#define FEAT_DSPREC DYNAREC_JIT
#else
#define FEAT_DSPREC DYNAREC_NONE
#endif
#endif
//Depricated build configs
#ifdef HOST_NO_REC
#error Dont use HOST_NO_REC
#endif
#ifdef HOST_NO_AREC
#error Dont use HOST_NO_AREC
#endif

View File

@ -88,7 +88,7 @@ RZDCY_CFLAGS := \
endif
ifdef NO_REC
RZDCY_CFLAGS += -DHOST_NO_REC
RZDCY_CFLAGS += -DTARGET_NO_REC
endif
ifndef DESKTOPGL

View File

@ -22,7 +22,7 @@
DECL_ALIGN(4096) dsp_t dsp;
#if HOST_OS==OS_WINDOWS && !defined(HOST_NO_REC)
#if HOST_CPU == CPU_X86 && FEAT_DSPREC == DYNAREC_JIT
#include "emitter/x86_emitter.h"
const bool SUPPORT_NOFL=false;

View File

@ -188,7 +188,7 @@ void armt_init();
//void CreateTables();
void arm_Init()
{
#if !defined(HOST_NO_AREC)
#if FEAT_AREC != DYNAREC_NONE
armt_init();
#endif
//CreateTables();
@ -398,7 +398,7 @@ void FlushCache();
void arm_Reset()
{
#if !defined(HOST_NO_AREC)
#if FEAT_AREC != DYNAREC_NONE
FlushCache();
#endif
Arm7Enabled = false;
@ -514,7 +514,7 @@ void update_armintc()
void libAICA_TimeStep();
#ifdef HOST_NO_AREC
#if FEAT_AREC == DYNAREC_NONE
void arm_Run(u32 CycleCount) {
for (int i=0;i<32;i++)
{
@ -798,7 +798,7 @@ u32 DYNACALL DoMemOp(u32 addr,u32 data)
{
u32 rv=0;
#if HOST_CPU==CPU_X86 && !defined(HOST_NO_AREC)
#if HOST_CPU==CPU_X86 && FEAT_AREC != DYNAREC_NONE
addr=virt_arm_reg(0);
data=virt_arm_reg(1);
#endif
@ -818,7 +818,7 @@ u32 DYNACALL DoMemOp(u32 addr,u32 data)
arm_WriteMem32(addr,data);
}
#if HOST_CPU==CPU_X86 && !defined(HOST_NO_AREC)
#if HOST_CPU==CPU_X86 && FEAT_AREC != DYNAREC_NONE
virt_arm_reg(0)=rv;
#endif

View File

@ -1,6 +1,6 @@
#include "virt_arm.h"
#if HOST_CPU==CPU_X86 && !defined(HOST_NO_AREC)
#if HOST_CPU==CPU_X86 && FEAT_AREC != DYNAREC_NONE
#define C_CORE

View File

@ -606,7 +606,7 @@ void _vmem_bm_reset()
bool BM_LockedWrite(u8* address)
{
#if !defined(HOST_NO_REC)
#if FEAT_SHREC != DYNAREC_NONE
u32 addr=address-(u8*)p_sh4rcb->fpcb;
address=(u8*)p_sh4rcb->fpcb+ (addr&~PAGE_MASK);

View File

@ -25,7 +25,7 @@
op_agent_t oprofHandle;
#endif
#ifndef HOST_NO_REC
#if FEAT_SHREC != DYNAREC_NONE
typedef vector<RuntimeBlockInfo*> bm_List;
@ -683,5 +683,5 @@ void print_blocks()
if (f) fclose(f);
}
#endif //#ifndef HOST_NO_REC
#endif

View File

@ -5,7 +5,7 @@
#include "types.h"
#ifndef HOST_NO_REC
#if FEAT_SHREC != DYNAREC_NONE
#include "decoder.h"
#include "shil.h"
@ -1040,9 +1040,7 @@ void dec_DecodeBlock(RuntimeBlockInfo* rbi,u32 max_cycles)
{
blk=rbi;
state.Setup(blk->addr,blk->fpu_cfg);
#ifndef HOST_NO_REC
ngen_GetFeatures(&state.ngen);
#endif
blk->guest_opcodes=0;

View File

@ -1,5 +1,5 @@
#pragma once
#if !defined(HOST_NO_REC)
#if FEAT_SHREC != DYNAREC_NONE
#define sh4dec(str) void dec_##str (u32 op)
#else
#define sh4dec(str) static void dec_##str (u32 op) { }

View File

@ -25,7 +25,7 @@
#include "ngen.h"
#include "decoder.h"
#ifndef HOST_NO_REC
#if FEAT_SHREC != DYNAREC_NONE
//uh uh
#if HOST_OS == OS_WINDOWS
@ -459,24 +459,19 @@ bool recSh4_IsCpuRunning()
{
return Sh4_int_IsCpuRunning();
}
#endif
void Get_Sh4Recompiler(sh4_if* rv)
{
#ifdef HOST_NO_REC
Get_Sh4Interpreter(rv);
#else
rv->Run=recSh4_Run;
rv->Stop=recSh4_Stop;
rv->Step=recSh4_Step;
rv->Skip=recSh4_Skip;
rv->Reset=recSh4_Reset;
rv->Init=recSh4_Init;
rv->Term=recSh4_Term;
rv->IsCpuRunning=recSh4_IsCpuRunning;
rv->Run = recSh4_Run;
rv->Stop = recSh4_Stop;
rv->Step = recSh4_Step;
rv->Skip = recSh4_Skip;
rv->Reset = recSh4_Reset;
rv->Init = recSh4_Init;
rv->Term = recSh4_Term;
rv->IsCpuRunning = recSh4_IsCpuRunning;
//rv->GetRegister=Sh4_int_GetRegister;
//rv->SetRegister=Sh4_int_SetRegister;
rv->ResetCache=recSh4_ClearCache;
#endif
rv->ResetCache = recSh4_ClearCache;
}
#endif

View File

@ -1017,7 +1017,7 @@ bool UpdateSR();
//#define SHIL_MODE 2
//#include "shil_canonical.h"
#ifndef HOST_NO_REC
#if FEAT_SHREC != DYNAREC_NONE
#define SHIL_MODE 3
#include "shil_canonical.h"
#endif

View File

@ -180,7 +180,7 @@ int DreamcastSecond(int tag, int c, int j)
prof_periodical();
#endif
#if !defined(HOST_NO_REC)
#if FEAT_SHREC != DYNAREC_NONE
bm_Periodical_1s();
#endif

View File

@ -460,7 +460,7 @@ return;
if ('a' == key) rt[port]=255;
if ('s' == key) lt[port]=255;
#if !defined(HOST_NO_REC)
#if FEAT_SHREC != DYNAREC_NONE
if ('b' == key) emit_WriteCodeCache();
if ('n' == key) bm_Reset();
if ('m' == key) bm_Sort();

View File

@ -65,7 +65,7 @@ void fault_handler (int sn, siginfo_t * si, void *segfault_ctx)
if (VramLockedWrite((u8*)si->si_addr) || BM_LockedWrite((u8*)si->si_addr))
return;
#if !defined(HOST_NO_REC)
#if FEAT_SHREC != DYNAREC_NONE
#if HOST_CPU==CPU_ARM
else if (dyna_cde)
{

View File

@ -249,7 +249,7 @@ void* prof(void *ptr)
//Write shrec syms file !
prof_head(prof_out, "jitsym", "SH4");
#if !defined(HOST_NO_REC)
#if FEAT_SHREC != DYNAREC_NONE
sh4_jitsym(prof_out);
#endif

View File

@ -183,7 +183,7 @@ int dc_init(int argc,wchar* argv[])
printf("Did not load bios, using reios\n");
}
#if !defined(HOST_NO_REC)
#if FEAT_SHREC != DYNAREC_NONE
if(settings.dynarec.Enable)
{
Get_Sh4Recompiler(&sh4_cpu);

View File

@ -67,7 +67,7 @@ extern u32 samples_gen;
void print_blocks();
#ifndef HOST_NO_REC
#if FEAT_SHREC != DYNAREC_NONE
//called every emulated second
void prof_periodical()
{
@ -77,7 +77,7 @@ void prof_periodical()
DMAW=SQW=0;
#endif
#if !defined(HOST_NO_REC)
#if FEAT_SHREC != DYNAREC_NONE
print_blocks();
#endif

View File

@ -66,7 +66,7 @@ vstm r3,{d0-d3}
bx lr
#ifndef HOST_NO_REC
#if FEAT_SHREC != DYNAREC_NONE
@@@@@@@@@@ ngen_LinkBlock_*****_stub @@@@@@@@@@

View File

@ -2,7 +2,7 @@
#include <sys/mman.h>
#include "types.h"
#ifndef HOST_NO_REC
#if FEAT_SHREC == DYNAREC_JIT
#include "hw/sh4/sh4_opcode_list.h"
#include "hw/sh4/sh4_mmr.h"

View File

@ -2,7 +2,7 @@
#include "types.h"
#if HOST_CPU == CPU_X64
#if FEAT_SHREC == DYNAREC_JIT && HOST_CPU == CPU_X64
#include "hw/sh4/sh4_opcode_list.h"
#include "hw/sh4/modules/ccn.h"
#include "hw/sh4/sh4_interrupts.h"

View File

@ -1,6 +1,6 @@
#include "types.h"
#ifndef HOST_NO_REC
#if FEAT_SHREC == DYNAREC_JIT && HOST_CPU == CPU_X86
#include "rec_x86_ngen.h"

View File

@ -1,6 +1,6 @@
#include "types.h"
#ifndef HOST_NO_REC
#if FEAT_SHREC == DYNAREC_JIT && HOST_CPU == CPU_X86
#include "rec_x86_ngen.h"

View File

@ -1,6 +1,6 @@
#include "types.h"
#ifndef HOST_NO_REC
#if FEAT_SHREC == DYNAREC_JIT && HOST_CPU == CPU_X86
#include "rec_x86_ngen.h"
#include "hw/sh4/sh4_mmr.h"
#include "hw/sh4/sh4_rom.h"

View File

@ -125,7 +125,7 @@ int ExeptionHandler(u32 dwCode, void* pExceptionPointers)
{
return EXCEPTION_CONTINUE_EXECUTION;
}
#if !defined(HOST_NO_REC) && HOST_CPU != CPU_X64
#if FEAT_SHREC == DYNAREC_JIT && HOST_CPU == CPU_X86
else if ( ngen_Rewrite((unat&)ep->ContextRecord->Eip,*(unat*)ep->ContextRecord->Esp,ep->ContextRecord->Eax) )
{
//remove the call from call stack

View File

@ -54,9 +54,9 @@ LOCAL_CXXFLAGS := $(RZDCY_CXXFLAGS) -fvisibility=hidden -fvisibility-inlines-hi
LOCAL_CPPFLAGS := $(RZDCY_CXXFLAGS) -fvisibility=hidden -fvisibility-inlines-hidden -ffunction-sections -fdata-sections
ifeq ($(TARGET_ARCH_ABI),x86)
LOCAL_CFLAGS+= -DHOST_NO_AREC
LOCAL_CXXFLAGS+= -DHOST_NO_AREC -fpermissive
LOCAL_CPPFLAGS+= -DHOST_NO_AREC
LOCAL_CFLAGS+= -DTARGET_NO_AREC
LOCAL_CXXFLAGS+= -DTARGET_NO_AREC -fpermissive
LOCAL_CPPFLAGS+= -DTARGET_NO_AREC
endif
LOCAL_CPP_FEATURES :=

View File

@ -387,12 +387,12 @@ JNIEXPORT jint JNICALL Java_com_reicast_emulator_emu_JNIdc_send(JNIEnv *env,jobj
if (param==1)
{
settings.pvr.ta_skip^=1;
printf("settings.pvr.ta_skip: %d\n",settings.pvr.ta_skip);
settings.pvr.ta_skip^=1;
printf("settings.pvr.ta_skip: %d\n",settings.pvr.ta_skip);
}
if (param==2)
{
#if !defined(HOST_NO_REC)
#if FEAT_SHREC != DYNAREC_NONE
print_stats=true;
printf("Storing blocks ...\n");
#endif

View File

@ -33,7 +33,7 @@ SOURCES := cfg/ hw/arm7/ hw/aica/ hw/asic/ hw/ hw/gdrom/ hw/maple/ \
hw/extdev/ hw/arm/ imgread/ linux/ linux-dist/ ./ rec-ARM/ deps/zlib/ deps/chdr/ deps/crypto/ arm_emitter/
CXXFLAGS := -g -O3 -D RELEASE -c -D TARGET_GCW0 -D USES_HOMEDIR -D HOST_NO_REC #-D NO_REND
CXXFLAGS := -g -O3 -D RELEASE -c -D TARGET_GCW0 -D USES_HOMEDIR -D TARGET_NO_REC #-D NO_REND
CXXFLAGS += -frename-registers -fno-strict-aliasing -fsingle-precision-constant
CXXFLAGS += -ffast-math -ftree-vectorize
#-fprefetch-loop-arrays

View File

@ -30,7 +30,7 @@ SOURCES := cfg/ hw/arm7/ hw/aica/ hw/asic/ hw/ hw/gdrom/ hw/maple/ \
hw/extdev/ hw/arm/ imgread/ linux/ linux-dist/ ./ rec-ARM/ deps/zlib/ deps/chdr/ deps/crypto/ arm_emitter/
CXXFLAGS := -m32 -g -O3 -D RELEASE -c -D TARGET_LINUX_x86 -D HOST_NO_REC -D NO_REND
CXXFLAGS := -m32 -g -O3 -D RELEASE -c -D TARGET_LINUX_x86 -D TARGET_NO_REC -D NO_REND
CXXFLAGS += -fno-strict-aliasing
CXXFLAGS += -ffast-math -ftree-vectorize
#-fprefetch-loop-arrays

View File

@ -23,7 +23,7 @@ LDFLAGS:=-lppapi_gles2 -lppapi_cpp -lppapi
WARNINGS:=-Wno-long-long -Wswitch-enum
CXXFLAGS:=-pthread -std=gnu++0x $(WARNINGS)
CXXFLAGS += -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/deps -I$(RZDCY_SRC_DIR)/khronos -I../linux-deps/include -D RELEASE -D HOST_NO_REC -D TARGET_NACL32
CXXFLAGS += -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/deps -I$(RZDCY_SRC_DIR)/khronos -I../linux-deps/include -D RELEASE -D TARGET_NO_REC -D TARGET_NACL32
#
# Compute tool paths

View File

@ -445,7 +445,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Full</Optimization>
<PreprocessorDefinitions>WIN32;HOST_NO_AREC=1;NDEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
@ -498,7 +498,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;HOST_NO_AREC=1;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>