From a4c71501b85f6bfd791cea93082beadb8a49cdaa Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 8 Oct 2024 02:46:33 +0300 Subject: [PATCH] enable lightrec --- .gitmodules | 6 ++++++ Makefile | 56 ++++++++++++++++++++++++++++++++++++++++++++++++-- configure | 33 +++++++++++++++++++---------- deps/libchdr | 2 +- deps/lightning | 1 + deps/lightrec | 1 + 6 files changed, 85 insertions(+), 14 deletions(-) create mode 160000 deps/lightning create mode 160000 deps/lightrec diff --git a/.gitmodules b/.gitmodules index 44495e68..fa655497 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,9 @@ [submodule "libchdr"] path = deps/libchdr url = https://github.com/rtissera/libchdr.git +[submodule "deps/lightrec"] + path = deps/lightrec + url = https://github.com/pcercuei/lightrec.git +[submodule "deps/lightning"] + path = deps/lightning + url = https://github.com/pcercuei/gnu_lightning.git diff --git a/Makefile b/Makefile index 61eb95ef..1e965a69 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,9 @@ CXXFLAGS += $(CFLAGS) #DRC_DBG = 1 #PCNT = 1 +# Suppress minor warnings for dependencies +deps/%: CFLAGS += -Wno-unused -Wno-unused-function + all: config.mak target_ plugins_ ifndef NO_CONFIG_MAK @@ -67,7 +70,54 @@ endif libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull # dynarec -ifeq "$(USE_DYNAREC)" "1" +ifeq "$(DYNAREC)" "lightrec" +CFLAGS += -Ideps/lightning/include -Ideps/lightrec -Iinclude/lightning -Iinclude/lightrec \ + -DLIGHTREC -DLIGHTREC_STATIC +LIGHTREC_CUSTOM_MAP ?= 0 +LIGHTREC_CUSTOM_MAP_OBJ ?= libpcsxcore/lightrec/mem.o +LIGHTREC_THREADED_COMPILER ?= 0 +LIGHTREC_CODE_INV ?= 0 +CFLAGS += -DLIGHTREC_CUSTOM_MAP=$(LIGHTREC_CUSTOM_MAP) \ + -DLIGHTREC_CODE_INV=$(LIGHTREC_CODE_INV) \ + -DLIGHTREC_ENABLE_THREADED_COMPILER=$(LIGHTREC_THREADED_COMPILER) +ifeq ($(LIGHTREC_CUSTOM_MAP),1) +LDLIBS += -lrt +OBJS += $(LIGHTREC_CUSTOM_MAP_OBJ) +endif +ifeq ($(NEED_SYSCONF),1) +OBJS += libpcsxcore/lightrec/sysconf.o +endif +ifeq ($(LIGHTREC_THREADED_COMPILER),1) +OBJS += deps/lightrec/recompiler.o \ + deps/lightrec/reaper.o +endif +OBJS += deps/lightrec/tlsf/tlsf.o +OBJS += libpcsxcore/lightrec/plugin.o +OBJS += deps/lightning/lib/jit_disasm.o \ + deps/lightning/lib/jit_memory.o \ + deps/lightning/lib/jit_names.o \ + deps/lightning/lib/jit_note.o \ + deps/lightning/lib/jit_print.o \ + deps/lightning/lib/jit_size.o \ + deps/lightning/lib/lightning.o \ + deps/lightrec/blockcache.o \ + deps/lightrec/constprop.o \ + deps/lightrec/disassembler.o \ + deps/lightrec/emitter.o \ + deps/lightrec/interpreter.o \ + deps/lightrec/lightrec.o \ + deps/lightrec/memmanager.o \ + deps/lightrec/optimizer.o \ + deps/lightrec/regcache.o +deps/lightning/%.o: CFLAGS += -DHAVE_MMAP=P_HAVE_MMAP +deps/lightning/%: CFLAGS += -Wno-uninitialized +deps/lightrec/%: CFLAGS += -Wno-uninitialized +libpcsxcore/lightrec/mem.o: CFLAGS += -D_GNU_SOURCE +ifeq ($(MMAP_WIN32),1) +CFLAGS += -Iinclude/mman -I deps/mman +OBJS += deps/mman/mman.o +endif +else ifeq "$(DYNAREC)" "ari64" OBJS += libpcsxcore/new_dynarec/new_dynarec.o OBJS += libpcsxcore/new_dynarec/pcsxmem.o ifeq "$(ARCH)" "arm" @@ -176,7 +226,7 @@ OBJS += $(LCHDR)/src/libchdr_cdrom.o OBJS += $(LCHDR)/src/libchdr_chd.o OBJS += $(LCHDR)/src/libchdr_flac.o OBJS += $(LCHDR)/src/libchdr_huffman.o -$(LCHDR)/src/%.o: CFLAGS += -Wno-unused -std=gnu11 +$(LCHDR)/src/%.o: CFLAGS += -Wno-unused -Wno-maybe-uninitialized -std=gnu11 OBJS += $(LCHDR_LZMA)/src/Alloc.o OBJS += $(LCHDR_LZMA)/src/CpuArch.o OBJS += $(LCHDR_LZMA)/src/Delta.o @@ -292,10 +342,12 @@ endif OBJS += frontend/libretro.o CFLAGS += -DFRONTEND_SUPPORTS_RGB565 +ifneq ($(DYNAREC),lightrec) ifeq ($(MMAP_WIN32),1) OBJS += libpcsxcore/memmap_win32.o endif endif +endif ifeq "$(USE_PLUGIN_LIB)" "1" OBJS += frontend/plugin_lib.o diff --git a/configure b/configure index ac7af0e2..be2c4ff4 100755 --- a/configure +++ b/configure @@ -40,6 +40,7 @@ check_define_val() platform_list="generic pandora maemo caanoo libretro" platform="generic" builtin_gpu_list="neon peops unai unai_old" +dynarec_list="ari64 lightrec none" builtin_gpu="" sound_driver_list="oss alsa pulseaudio sdl libretro" sound_drivers="" @@ -54,7 +55,7 @@ have_arm_neon_asm="" have_tslib="" have_gles="" have_c64x_dsp="" -enable_dynarec="yes" +dynarec="" need_sdl="no" need_xlib="no" need_libpicofe="yes" @@ -145,7 +146,9 @@ for opt do ;; --disable-neon) have_arm_neon="no" ;; - --disable-dynarec) enable_dynarec="no" + --dynarec=*) dynarec="$optarg" + ;; + --disable-dynarec) dynarec="no" ;; *) echo "ERROR: unknown option $opt"; show_help="yes" ;; @@ -163,8 +166,8 @@ if [ "$show_help" = "yes" ]; then echo " available: $sound_driver_list" echo " --enable-neon" echo " --disable-neon enable/disable ARM NEON optimizations [guessed]" - echo " --disable-dynarec disable dynamic recompiler" - echo " (dynarec is only available and enabled on ARM)" + echo " --dynarec=NAME select dynamic recompiler [guessed]" + echo " available: $dynarec_list" echo "influential environment variables:" echo " CROSS_COMPILE CC CXX AS AR CFLAGS ASFLAGS LDFLAGS LDLIBS" exit 1 @@ -245,6 +248,10 @@ arm*) have_armv5=`check_define HAVE_ARMV5 && echo yes` || true fi + if [ "x$dynarec" = "x" ]; then + dynarec="ari64" + fi + if [ "x$builtin_gpu" = "x" ]; then if [ "$have_arm_neon" = "yes" ]; then builtin_gpu="neon" @@ -295,19 +302,25 @@ arm*) aarch64) have_arm_neon="yes" have_arm_neon_asm="no" + if [ "x$dynarec" = "x" ]; then + dynarec="ari64" + fi if [ "x$builtin_gpu" = "x" ]; then builtin_gpu="neon" fi ;; x86_64) - enable_dynarec="no" + if [ "x$dynarec" = "x" ]; then + dynarec="lightrec" + fi if [ "x$builtin_gpu" = "x" ]; then builtin_gpu="neon" fi ;; *) - # dynarec only available on ARM - enable_dynarec="no" + if [ "x$dynarec" = "x" ]; then + dynarec="lightrec" + fi ;; esac @@ -545,7 +558,7 @@ echo "C compiler $CC" echo "C compiler flags $CFLAGS" echo "libraries $MAIN_LDLIBS" echo "linker flags $LDFLAGS$MAIN_LDFLAGS" -echo "enable dynarec $enable_dynarec" +echo "dynarec $dynarec" if [ "$ARCH" = "arm" -o "$ARCH" = "aarch64" ]; then echo "enable ARM NEON $have_arm_neon" fi @@ -596,9 +609,7 @@ if [ "$have_gles" = "yes" ]; then echo "CFLAGS_GLES = $CFLAGS_GLES" >> $config_mak echo "LDLIBS_GLES = $LDLIBS_GLES" >> $config_mak fi -if [ "$enable_dynarec" = "yes" ]; then - echo "USE_DYNAREC = 1" >> $config_mak -fi +echo "DYNAREC = $dynarec" >> $config_mak if [ "$drc_cache_base" = "yes" ]; then echo "BASE_ADDR_DYNAMIC = 1" >> $config_mak fi diff --git a/deps/libchdr b/deps/libchdr index 86b27207..aaca599e 160000 --- a/deps/libchdr +++ b/deps/libchdr @@ -1 +1 @@ -Subproject commit 86b272076d542287d3f03952e7d4efe283e815bf +Subproject commit aaca599e18e43933fc193bd1b715c368c306208b diff --git a/deps/lightning b/deps/lightning new file mode 160000 index 00000000..de026794 --- /dev/null +++ b/deps/lightning @@ -0,0 +1 @@ +Subproject commit de026794c71386983034461bce2df3c63ccd5827 diff --git a/deps/lightrec b/deps/lightrec new file mode 160000 index 00000000..ea20362c --- /dev/null +++ b/deps/lightrec @@ -0,0 +1 @@ +Subproject commit ea20362c9542f12fb6a0f27aa7df66b2af06b84d -- 2.39.2