From 37430f22c5234cb09f2325575806b830f947bf8a Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Fri, 7 May 2021 20:41:54 +0200 Subject: Small optimization (~2-4%) and whitespace cleanup! Cleans up a ton of whitespace in cpu.c (like 100KB!) and improves readability of some massive decode statements. Added an optimization for PC-relative loads (pool load) in ROM (since it's read only and cannot possibily change) that directly emits an immediate load. This is way faster, specially in MIPS/x86, ARM can be even faster if we rewrite the immediate load macros to also use a pool. --- Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 5d28045..f4c758f 100644 --- a/Makefile +++ b/Makefile @@ -376,6 +376,7 @@ else ifeq ($(platform), mips32) SHARED := -shared -nostdlib -Wl,--version-script=link.T fpic := -fPIC -DPIC CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float + CFLAGS += -fno-caller-saves HAVE_DYNAREC := 1 CPU_ARCH := mips -- cgit v1.2.3 From 261b2db9bb65b63d4968f89deecdf92f1975011f Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Wed, 19 May 2021 20:09:44 +0200 Subject: Cleanup Makefiles a bit --- Makefile | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index f4c758f..6edf65c 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,4 @@ DEBUG=0 -HAVE_GRIFFIN=0 FRONTEND_SUPPORTS_RGB565=1 FORCE_32BIT_ARCH=0 HAVE_MMAP=0 @@ -74,7 +73,7 @@ ifeq ($(platform), unix) LIBM := endif CFLAGS += $(FORCE_32BIT) - LDFLAGS := -Wl,--no-undefined + LDFLAGS += -Wl,--no-undefined ifeq ($(HAVE_DYNAREC),1) HAVE_MMAP = 1 endif @@ -368,7 +367,7 @@ else ifneq (,$(findstring armv,$(platform))) ifeq (,$(findstring no-dynarec,$(platform))) HAVE_DYNAREC := 1 endif - LDFLAGS := -Wl,--no-undefined + LDFLAGS += -Wl,--no-undefined # MIPS else ifeq ($(platform), mips32) @@ -444,11 +443,6 @@ else OPTIMIZE := -O3 -DNDEBUG endif - -include Makefile.common - -OBJECTS := $(SOURCES_C:.c=.o) $(SOURCES_ASM:.S=.o) - DEFINES := -DHAVE_STRINGS_H -DHAVE_STDINT_H -DHAVE_INTTYPES_H -D__LIBRETRO__ -DINLINE=inline -Wall ifeq ($(HAVE_DYNAREC), 1) @@ -463,6 +457,9 @@ else ifeq ($(CPU_ARCH), x86_32) DEFINES += -DX86_ARCH endif +include Makefile.common + +OBJECTS := $(SOURCES_C:.c=.o) $(SOURCES_ASM:.S=.o) WARNINGS_DEFINES = CODE_DEFINES = -- cgit v1.2.3 From e0a31952dbffd15cd2878ed20142ec41cbd937bb Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Fri, 18 Jun 2021 18:03:47 +0200 Subject: Add preliminary support for non mips32r2 devices This is required in PS2 but could also make older dingux devices run gpsp on retroarch --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 6edf65c..4d75fdd 100644 --- a/Makefile +++ b/Makefile @@ -200,7 +200,7 @@ else ifeq ($(platform), psp1) TARGET := $(TARGET_NAME)_libretro_$(platform).a CC = psp-gcc$(EXE_EXT) AR = psp-ar$(EXE_EXT) - CFLAGS += -DPSP -G0 -DUSE_BGR_FORMAT + CFLAGS += -DPSP -G0 -DUSE_BGR_FORMAT -DMIPS_HAS_R2_INSTS CFLAGS += -I$(shell psp-config --pspsdk-path)/include CFLAGS += -march=allegrex -mfp32 -mgp32 -mlong32 -mabi=eabi CFLAGS += -fomit-frame-pointer -ffast-math @@ -375,7 +375,7 @@ else ifeq ($(platform), mips32) SHARED := -shared -nostdlib -Wl,--version-script=link.T fpic := -fPIC -DPIC CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float - CFLAGS += -fno-caller-saves + CFLAGS += -fno-caller-saves -DMIPS_HAS_R2_INSTS HAVE_DYNAREC := 1 CPU_ARCH := mips @@ -393,6 +393,7 @@ else ifeq ($(platform), gcw0) SHARED := -shared -nostdlib -Wl,--version-script=link.T fpic := -fPIC -DPIC CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float + CFLAGS += -DMIPS_HAS_R2_INSTS HAVE_DYNAREC := 1 CPU_ARCH := mips @@ -408,7 +409,7 @@ else ifeq ($(platform), gcw0-odbeta) # The ASM code and/or MIPS dynarec of GPSP does not respect # MIPS calling conventions, so we must use '-fno-caller-saves' # for the OpenDingux Beta build - CFLAGS += -fno-caller-saves + CFLAGS += -fno-caller-saves -DMIPS_HAS_R2_INSTS HAVE_DYNAREC := 1 CPU_ARCH := mips -- cgit v1.2.3 From f8d4276e12165a2610c87e998a343c02c2904855 Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Mon, 21 Jun 2021 19:17:19 +0200 Subject: Add support for mips64n32 This only needs some support to save/load state with 64 bit registers. Since pointers remain 32 bit, no extra changes are needed in the dynarec. Verified with qemu (qemu-mipsn32el) and miniretro. --- Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 4d75fdd..d127e92 100644 --- a/Makefile +++ b/Makefile @@ -379,6 +379,16 @@ else ifeq ($(platform), mips32) HAVE_DYNAREC := 1 CPU_ARCH := mips +# MIPS64 +else ifeq ($(platform), mips64n32) + TARGET := $(TARGET_NAME)_libretro.so + SHARED := -shared -nostdlib -Wl,--version-script=link.T + fpic := -fPIC -DPIC + CFLAGS += -fomit-frame-pointer -ffast-math -march=mips64 -mabi=n32 -mhard-float + CFLAGS += -fno-caller-saves + HAVE_DYNAREC := 1 + CPU_ARCH := mips + # emscripten else ifeq ($(platform), emscripten) TARGET := $(TARGET_NAME)_libretro_$(platform).bc -- cgit v1.2.3 From dbf72e95efd507d5a6255c25aee055a0a3c1350e Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Tue, 22 Jun 2021 00:09:44 +0200 Subject: Fix the no-caller-saves bug for MIPS Seems that ABI mandates that we allocate space for arg0..4 even if we do pass them as registers. For some reason write_io_register<> functions write in that stack area (1 word) corrupting the s0 saved register. This seems to be a new gcc behaviour? --- Makefile | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index d127e92..cf0bfd1 100644 --- a/Makefile +++ b/Makefile @@ -375,7 +375,7 @@ else ifeq ($(platform), mips32) SHARED := -shared -nostdlib -Wl,--version-script=link.T fpic := -fPIC -DPIC CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float - CFLAGS += -fno-caller-saves -DMIPS_HAS_R2_INSTS + CFLAGS += -DMIPS_HAS_R2_INSTS HAVE_DYNAREC := 1 CPU_ARCH := mips @@ -385,7 +385,6 @@ else ifeq ($(platform), mips64n32) SHARED := -shared -nostdlib -Wl,--version-script=link.T fpic := -fPIC -DPIC CFLAGS += -fomit-frame-pointer -ffast-math -march=mips64 -mabi=n32 -mhard-float - CFLAGS += -fno-caller-saves HAVE_DYNAREC := 1 CPU_ARCH := mips @@ -394,7 +393,7 @@ else ifeq ($(platform), emscripten) TARGET := $(TARGET_NAME)_libretro_$(platform).bc STATIC_LINKING = 1 -# GCW0 +# GCW0 (OD and OD Beta) else ifeq ($(platform), gcw0) TARGET := $(TARGET_NAME)_libretro.so CC = /opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc @@ -407,22 +406,6 @@ else ifeq ($(platform), gcw0) HAVE_DYNAREC := 1 CPU_ARCH := mips -# GCW0 (OpenDingux Beta) -else ifeq ($(platform), gcw0-odbeta) - TARGET := $(TARGET_NAME)_libretro.so - CC = /opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc - CXX = /opt/gcw0-toolchain/usr/bin/mipsel-linux-g++ - AR = /opt/gcw0-toolchain/usr/bin/mipsel-linux-ar - SHARED := -shared -nostdlib -Wl,--version-script=link.T - fpic := -fPIC -DPIC - CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float - # The ASM code and/or MIPS dynarec of GPSP does not respect - # MIPS calling conventions, so we must use '-fno-caller-saves' - # for the OpenDingux Beta build - CFLAGS += -fno-caller-saves -DMIPS_HAS_R2_INSTS - HAVE_DYNAREC := 1 - CPU_ARCH := mips - # Windows else TARGET := $(TARGET_NAME)_libretro.dll -- cgit v1.2.3 From 8dbf5f6c17e3d217877119620e5bbfeba05abd7a Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Sun, 27 Jun 2021 01:16:28 +0200 Subject: Enable big-endian devices: gc/wii This patch adds big-endian compatibility in gpsp (in general but only for the interpreter). There's no performance hit for little-endian platforms (should be a no-op) and only add a small overhead in memory accesses for big-endian platforms. Most memory accesses are wrapped with a byteswap instruction and I/O reg accesses are also rewired for proper access (using macros). Video rendering has been fixed to also do byteswaps but there's a couple of games and rendering modes that still seem broken (but they amount to less than 20 games in my tests with 1K ROMs). This also adds build rules and CI for NGC/WII/WIIU (untested) --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index cf0bfd1..5f7afff 100644 --- a/Makefile +++ b/Makefile @@ -195,6 +195,14 @@ else ifeq ($(platform), switch) include $(LIBTRANSISTOR_HOME)/libtransistor.mk STATIC_LINKING=1 +# Nintendo Game Cube / Wii / WiiU +else ifneq (,$(filter $(platform), ngc wii wiiu)) + TARGET := $(TARGET_NAME)_libretro_$(platform).a + CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT) + AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) + CFLAGS += -DGEKKO -mcpu=750 -meabi -mhard-float -DHAVE_STRTOF_L + STATIC_LINKING = 1 + # PSP else ifeq ($(platform), psp1) TARGET := $(TARGET_NAME)_libretro_$(platform).a -- cgit v1.2.3