libretro, more fixes and cleanups for windows and osx

This commit is contained in:
kub
2020-07-07 19:03:08 +02:00
parent ca9d270d13
commit f6f9a47b83
7 changed files with 76 additions and 120 deletions

View File

@@ -174,6 +174,7 @@ OBJS += platform/libretro/libretro-common/streams/file_stream.o
OBJS += platform/libretro/libretro-common/streams/file_stream_transforms.o
OBJS += platform/libretro/libretro-common/vfs/vfs_implementation.o
endif
PLATFORM_ZLIB = 1
endif
ifeq "$(USE_FRONTEND)" "1"

View File

@@ -52,6 +52,8 @@ asm_ym2612 = 0
asm_misc = 0
asm_cdmemory = 0
asm_mix = 0
asm_32xdraw = 0
asm_32xmemory = 0
fpic :=
@@ -97,8 +99,8 @@ else ifeq ($(platform), osx)
endif
ifeq ($(arch),ppc)
CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ -DFAMEC_NO_GOTOS
else
use_sh2drc = 1
else
use_sh2drc = 1
endif
OSXVER = `sw_vers -productVersion | cut -d. -f 2`
OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"`
@@ -120,14 +122,14 @@ else ifeq ($(platform), staticios)
CXX += -miphoneos-version-min=8.0
CC_AS += -miphoneos-version-min=8.0
CFLAGS += -miphoneos-version-min=8.0
ARCH := arm
ARCH := aarch64
STATIC_LINKING = 1
use_cyclone = 0
use_fame = 1
use_drz80 = 0
use_cz80 = 1
use_sh2drc = 0
use_sh2drc = 1
use_svpdrc = 0
# iOS
@@ -142,7 +144,7 @@ else ifneq (,$(findstring ios,$(platform)))
ifeq ($(platform),ios-arm64)
CC = clang -arch arm64 -isysroot $(IOSSDK)
CXX = clang++ -arch arm64 -isysroot $(IOSSDK)
CFLAGS += -marm -DARM -D__aarch64__=1
CFLAGS += -marm -DARM -D__aarch64__=1
else
CC = clang -arch armv7 -isysroot $(IOSSDK)
CXX = clang++ -arch armv7 -isysroot $(IOSSDK)
@@ -157,35 +159,32 @@ ifeq ($(platform),$(filter $(platform),ios9 ios-arm64))
CXX += -miphoneos-version-min=8.0
CC_AS += -miphoneos-version-min=8.0
CFLAGS += -miphoneos-version-min=8.0
ARCH := aarch64
else
CC += -miphoneos-version-min=5.0
CXX += -miphoneos-version-min=5.0
CC_AS += -miphoneos-version-min=5.0
CFLAGS += -miphoneos-version-min=5.0
endif
ARCH := arm
endif
use_cyclone = 0
use_fame = 1
use_drz80 = 0
use_cz80 = 1
ifeq ($(platform),ios-arm64)
use_sh2drc = 0
use_svpdrc = 0
else
use_sh2drc = 1
use_svpdrc = 1
endif
use_sh2drc = 1
use_svpdrc = 0
# tvOS
else ifeq ($(platform), tvos-arm64)
ARCH := arm
ARCH := aarch64
use_cyclone = 0
use_fame = 1
use_drz80 = 0
use_cz80 = 1
use_sh2drc = 0
use_sh2drc = 1
use_svpdrc = 0
TARGET := $(TARGET_NAME)_libretro_tvos.dylib
SHARED := -dynamiclib
fpic := -fPIC
@@ -194,6 +193,9 @@ else ifeq ($(platform), tvos-arm64)
IOSSDK := $(shell xcodebuild -version -sdk appletvos Path)
endif
CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
CC = clang -arch arm64 -isysroot $(IOSSDK)
CXX = clang++ -arch arm64 -isysroot $(IOSSDK)
CFLAGS += -marm -DARM -D__aarch64__=1
CFLAGS += -DIOS
# PS3
@@ -206,17 +208,11 @@ else ifeq ($(platform), ps3)
NO_MMAP = 1
DONT_COMPILE_IN_ZLIB = 1
asm_memory = 0
asm_render = 0
asm_ym2612 = 0
asm_misc = 0
asm_cdpico = 0
asm_cdmemory = 0
asm_mix = 0
use_cyclone = 0
use_fame = 1
use_drz80 = 0
use_cz80 = 1
use_sh2drc = 1
# sncps3
else ifeq ($(platform), sncps3)
@@ -228,17 +224,11 @@ else ifeq ($(platform), sncps3)
NO_MMAP = 1
DONT_COMPILE_IN_ZLIB = 1
asm_memory = 0
asm_render = 0
asm_ym2612 = 0
asm_misc = 0
asm_cdpico = 0
asm_cdmemory = 0
asm_mix = 0
use_cyclone = 0
use_fame = 1
use_drz80 = 0
use_cz80 = 1
use_sh2drc = 1
# Lightweight PS3 Homebrew SDK
else ifeq ($(platform), psl1ght)
@@ -250,17 +240,11 @@ else ifeq ($(platform), psl1ght)
NO_MMAP = 1
DONT_COMPILE_IN_ZLIB = 1
asm_memory = 0
asm_render = 0
asm_ym2612 = 0
asm_misc = 0
asm_cdpico = 0
asm_cdmemory = 0
asm_mix = 0
use_cyclone = 0
use_fame = 1
use_drz80 = 0
use_cz80 = 1
use_sh2drc = 1
# PSP
else ifeq ($(platform), psp1)
@@ -273,17 +257,11 @@ else ifeq ($(platform), psp1)
NO_MMAP = 1
DONT_COMPILE_IN_ZLIB = 1
asm_memory = 0
asm_render = 1
asm_ym2612 = 0
asm_misc = 0
asm_cdpico = 0
asm_cdmemory = 0
asm_mix = 0
use_cyclone = 0
use_fame = 1
use_drz80 = 0
use_cz80 = 1
use_sh2drc = 1
# PS2
else ifeq ($(platform), ps2)
@@ -297,17 +275,12 @@ else ifeq ($(platform), ps2)
NO_MMAP = 1
DONT_COMPILE_IN_ZLIB = 1
asm_memory = 0
asm_render = 1
asm_ym2612 = 0
asm_misc = 0
asm_cdpico = 0
asm_cdmemory = 0
asm_mix = 0
use_cyclone = 0
use_fame = 1
use_drz80 = 0
use_cz80 = 1
use_sh2drc = 1
OBJS += platform/ps2/asm.o
@@ -327,14 +300,6 @@ else ifeq ($(platform), ctr)
ARCH = arm
ARM_ASM = 1
asm_memory = 1
asm_render = 1
asm_ym2612 = 1
asm_misc = 1
asm_cdpico = 1
asm_cdmemory = 1
asm_mix = 1
use_cyclone = 1
use_fame = 0
use_drz80 = 1
@@ -357,14 +322,6 @@ else ifeq ($(platform), raspberrypi)
fpic := -fPIC
DONT_COMPILE_IN_ZLIB = 1
asm_memory = 1
asm_render = 1
asm_ym2612 = 1
asm_misc = 1
asm_cdpico = 1
asm_cdmemory = 1
asm_mix = 1
use_cyclone = 1
use_fame = 0
use_drz80 = 1
@@ -386,14 +343,8 @@ else ifeq ($(platform), vita)
NO_MMAP = 1
DONT_COMPILE_IN_ZLIB = 1
ARCH = arm
ARM_ASM=1
asm_memory = 1
asm_render = 1
asm_ym2612 = 1
asm_misc = 1
asm_cdpico = 1
asm_cdmemory = 1
asm_mix = 1
use_cyclone = 1
use_fame = 0
use_drz80 = 1
@@ -443,13 +394,14 @@ else ifeq ($(platform), switch)
else ifeq ($(platform), libnx)
include $(DEVKITPRO)/libnx/switch_rules
TARGET := $(TARGET_NAME)_libretro_$(platform).a
ARCH := arm64
ARCH := aarch64
CFLAGS += -O3 -fomit-frame-pointer -ffast-math -I$(DEVKITPRO)/libnx/include/ -fPIE -Wl,--allow-multiple-definition
CFLAGS += -specs=$(DEVKITPRO)/libnx/switch.specs
CFLAGS += -D__SWITCH__ -DHAVE_LIBNX
CFLAGS += -DARM -D__aarch64__=1 -march=armv8-a -mtune=cortex-a57 -mtp=soft -ffast-math -mcpu=cortex-a57+crc+fp+simd -ffunction-sections
CFLAGS += -Ifrontend/switch -ftree-vectorize
STATIC_LINKING=1
use_sh2drc = 1
# QNX
else ifeq ($(platform), qnx)
@@ -489,7 +441,6 @@ else ifeq ($(platform), classic_armv7_a7)
HAVE_NEON = 1
ARCH = arm
BUILTIN_GPU = neon
USE_DYNAREC = 1
ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1)
CFLAGS += -march=armv7-a
else
@@ -499,6 +450,9 @@ else ifeq ($(platform), classic_armv7_a7)
LDFLAGS += -static-libgcc -static-libstdc++
endif
endif
use_sh2drc = 1
use_svpdrc = 1
# (armv8 a35, hard point, neon based) ###
# Playstation Classic
@@ -518,19 +472,14 @@ else ifeq ($(platform), classic_armv8_a35)
CPPFLAGS += $(CFLAGS)
ASFLAGS += $(CFLAGS)
HAVE_NEON = 1
ARCH = arm
ARCH = aarch64
BUILTIN_GPU = neon
CFLAGS += -march=armv8-a
LDFLAGS += -static-libgcc -static-libstdc++
asm_memory = 0
asm_render = 0
asm_ym2612 = 0
asm_misc = 0
asm_cdpico = 0
asm_cdmemory = 0
asm_mix = 0
use_sh2drc = 1
use_cyclone = 0
use_fame = 1
use_fame = 1
use_drz80 = 0
use_cz80 = 1
#######################################
@@ -597,21 +546,14 @@ else ifeq ($(platform), emscripten)
# GCW0
else ifeq ($(platform), gcw0)
TARGET := $(TARGET_NAME)_libretro.so
CC = /opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc
AR = /opt/gcw0-toolchain/usr/bin/mipsel-linux-ar
CC = mipsel-linux-gcc
AR = mipsel-linux-ar
SHARED := -shared -nostdlib
fpic := -fPIC
LIBM :=
DONT_COMPILE_IN_ZLIB = 1
CFLAGS += -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float
asm_memory = 0
asm_render = 0
asm_ym2612 = 0
asm_misc = 0
asm_cdpico = 0
asm_cdmemory = 0
asm_mix = 0
use_cyclone = 0
use_fame = 1
use_drz80 = 0
@@ -744,6 +686,8 @@ asm_ym2612 = 1
asm_misc = 1
asm_cdmemory = 1
asm_mix = 1
asm_32xdraw = 1
asm_32xmemory = 1
endif
CFLAGS += $(fpic)

View File

@@ -733,7 +733,7 @@ enum { xAX = 0, xCX, xDX, xBX, xSP, xBP, xSI, xDI, // x86-64,i386 common
/* mov r <-> [ebp+#offs] */ \
if ((offs) == 0) { \
emith_deref_modrm(op, 0, r, rs); \
} else if (abs(offs) >= 0x80) { \
} else if ((s32)(offs) < -0x80 || (s32)(offs) >= 0x80) { \
emith_deref_modrm(op, 2, r, rs); \
EMIT(offs, u32); \
} else { \
@@ -1075,7 +1075,7 @@ enum { xAX = 0, xCX, xDX, xBX, xSP, xBP, xSI, xDI, // x86-64,i386 common
#define PARAM_REGS { xCX, xDX, xR8, xR9 }
#define PRESERVED_REGS { xSI, xDI, xR12, xR13, xR14, xR15, xBX, xBP }
#define TEMPORARY_REGS { xAX, xR10, xR11 }
#define STATIC_SH2_REGS { SHR_SR,xBX , SHR_R(0),xR15 , SH2_R(1),xR14 }
#define STATIC_SH2_REGS { SHR_SR,xBX , SHR_R(0),xR15 , SHR_R(1),xR14 }
#define host_arg2reg(rd, arg) \
switch (arg) { \

View File

@@ -1273,24 +1273,23 @@ static void dr_flush_tcache(int tcid)
blink_free[tcid] = NULL;
memset(unresolved_links[tcid], 0, sizeof(*unresolved_links[0]) * HASH_TABLE_SIZE(tcid));
memset(hash_tables[tcid], 0, sizeof(*hash_tables[0]) * HASH_TABLE_SIZE(tcid));
if (Pico32xMem->sdram != NULL) {
if (tcid == 0) { // ROM, RAM
memset(Pico32xMem->drcblk_ram, 0, sizeof(Pico32xMem->drcblk_ram));
memset(Pico32xMem->drclit_ram, 0, sizeof(Pico32xMem->drclit_ram));
memset(sh2s[0].branch_cache, -1, sizeof(sh2s[0].branch_cache));
memset(sh2s[1].branch_cache, -1, sizeof(sh2s[1].branch_cache));
memset(sh2s[0].rts_cache, -1, sizeof(sh2s[0].rts_cache));
memset(sh2s[1].rts_cache, -1, sizeof(sh2s[1].rts_cache));
sh2s[0].rts_cache_idx = sh2s[1].rts_cache_idx = 0;
} else {
memset(Pico32xMem->drcblk_ram, 0, sizeof(Pico32xMem->drcblk_ram));
memset(Pico32xMem->drclit_ram, 0, sizeof(Pico32xMem->drclit_ram));
memset(Pico32xMem->drcblk_da[tcid - 1], 0, sizeof(Pico32xMem->drcblk_da[tcid - 1]));
memset(Pico32xMem->drclit_da[tcid - 1], 0, sizeof(Pico32xMem->drclit_da[tcid - 1]));
memset(sh2s[tcid - 1].branch_cache, -1, sizeof(sh2s[0].branch_cache));
memset(sh2s[tcid - 1].rts_cache, -1, sizeof(sh2s[0].rts_cache));
sh2s[tcid - 1].rts_cache_idx = 0;
}
if (tcid == 0) { // ROM, RAM
memset(Pico32xMem->drcblk_ram, 0, sizeof(Pico32xMem->drcblk_ram));
memset(Pico32xMem->drclit_ram, 0, sizeof(Pico32xMem->drclit_ram));
memset(sh2s[0].branch_cache, -1, sizeof(sh2s[0].branch_cache));
memset(sh2s[1].branch_cache, -1, sizeof(sh2s[1].branch_cache));
memset(sh2s[0].rts_cache, -1, sizeof(sh2s[0].rts_cache));
memset(sh2s[1].rts_cache, -1, sizeof(sh2s[1].rts_cache));
sh2s[0].rts_cache_idx = sh2s[1].rts_cache_idx = 0;
} else {
memset(Pico32xMem->drcblk_ram, 0, sizeof(Pico32xMem->drcblk_ram));
memset(Pico32xMem->drclit_ram, 0, sizeof(Pico32xMem->drclit_ram));
memset(Pico32xMem->drcblk_da[tcid - 1], 0, sizeof(Pico32xMem->drcblk_da[tcid - 1]));
memset(Pico32xMem->drclit_da[tcid - 1], 0, sizeof(Pico32xMem->drclit_da[tcid - 1]));
memset(sh2s[tcid - 1].branch_cache, -1, sizeof(sh2s[0].branch_cache));
memset(sh2s[tcid - 1].rts_cache, -1, sizeof(sh2s[0].rts_cache));
sh2s[tcid - 1].rts_cache_idx = 0;
}
#if (DRC_DEBUG & 4)
tcache_dsm_ptrs[tcid] = tcache_ring[tcid].base;

View File

@@ -31,7 +31,7 @@ unsigned short scan_block(uint32_t base_pc, int is_slave,
unsigned char *op_flags, uint32_t *end_pc,
uint32_t *base_literals, uint32_t *end_literals);
#if defined(DRC_SH2) && defined(__GNUC__)
#if defined(DRC_SH2) && defined(__GNUC__) && !defined(__clang__)
// direct access to some host CPU registers used by the DRC if gcc is used.
// XXX MUST match SHR_SR definitions in cpu/drc/emit_*.c; should be moved there
// XXX yuck, there's no portable way to determine register size. Use long long

View File

@@ -106,7 +106,11 @@ int sh2_execute_interpreter(SH2 *sh2c, int cycles);
static __inline void sh2_execute_prepare(SH2 *sh2, int use_drc)
{
#ifdef DRC_SH2
sh2->run = use_drc ? sh2_execute_drc : sh2_execute_interpreter;
#else
sh2->run = sh2_execute_interpreter;
#endif
}
static __inline int sh2_execute(SH2 *sh2, int cycles)

View File

@@ -8,6 +8,20 @@ CC=${CC:-gcc}
# endianess of target (automagically determined below)
ENDIAN=
# don't do this if ELF format isn't used. it doesn't matter since offsets are
# only needed for the asm parts (currently mips/arm32) and those have ELF
check_elf ()
{
echo '#include <stdint.h>' >/tmp/getoffs.c
echo "const int32_t val = 1;" >>/tmp/getoffs.c
$CC $CFLAGS -I .. -c /tmp/getoffs.c -o /tmp/getoffs.o || exit 1
if ! command -v readelf >/dev/null || ! file /tmp/getoffs.o | grep -q ELF; then
echo "/* mkoffset.sh: no readelf or not ELF, offset table not created */" >$fn
echo "WARNING: no readelf or not ELF, offset table not created"
exit
fi
}
# compile with target C compiler and extract value from .rodata section
compile_rodata ()
{
@@ -49,13 +63,7 @@ get_define () # prefix struct member member...
fn="${1:-.}/pico_int_offs.h"
if echo $CFLAGS | grep -qe -flto; then CFLAGS="$CFLAGS -fno-lto"; fi
# don't do this if readelf isn't available. it doesn't matter since offsets are
# only needed for the asm parts (currently mips/arm32) and those have readelf
if ! command -v readelf >/dev/null; then
echo "/* mkoffset.sh: readelf not found, offset table not created */" >$fn
echo "WARNING: readelf not found, offset table not created"
exit
fi
check_elf
# determine endianess
echo '#include <stdint.h>' >/tmp/getoffs.c
echo "const int32_t val = 1;" >>/tmp/getoffs.c