diff --git a/desmume/src/Makefile.am b/desmume/src/Makefile.am index 971611eea..36cee224e 100644 --- a/desmume/src/Makefile.am +++ b/desmume/src/Makefile.am @@ -141,24 +141,13 @@ libdesmume_a_SOURCES = \ libretro-common/rthreads/rsemaphore.c \ libretro-common/rthreads/rthreads.c -if SUPPORT_SSE2 -libdesmume_a_SOURCES += \ - utils/colorspacehandler/colorspacehandler_SSE2.cpp -endif - -if SUPPORT_AVX2 -libdesmume_a_SOURCES += \ - utils/colorspacehandler/colorspacehandler_AVX2.cpp -endif - -if SUPPORT_ALTIVEC -libdesmume_a_SOURCES += \ - utils/colorspacehandler/colorspacehandler_AltiVec.cpp -endif - if HAVE_JIT libdesmume_a_SOURCES += \ - arm_jit.cpp arm_jit.h instruction_attributes.h \ + arm_jit.h instruction_attributes.h + +if HOST_CPU_KIND_X86 +libdesmume_a_SOURCES += \ + arm_jit.cpp \ utils/AsmJit/AsmJit.h \ utils/AsmJit/Config.h \ utils/AsmJit/core.h \ @@ -227,6 +216,13 @@ libdesmume_a_SOURCES += \ utils/AsmJit/x86/x86operand.h \ utils/AsmJit/x86/x86util.cpp \ utils/AsmJit/x86/x86util.h +else +if HOST_CPU_KIND_ARM +libdesmume_a_SOURCES += \ + utils/arm_jit/arm_jit_arm.cpp +endif +endif + endif if ENABLE_OPENGL_ES diff --git a/desmume/src/frontend/posix/Makefile.am b/desmume/src/frontend/posix/Makefile.am index 7da01eb2f..7330369bc 100644 --- a/desmume/src/frontend/posix/Makefile.am +++ b/desmume/src/frontend/posix/Makefile.am @@ -120,24 +120,13 @@ libdesmume_a_SOURCES = \ ../../libretro-common/rthreads/rthreads.c \ ../../libretro-common/encodings/encoding_utf.c -if SUPPORT_SSE2 -libdesmume_a_SOURCES += \ - ../../utils/colorspacehandler/colorspacehandler_SSE2.cpp ../../utils/colorspacehandler/colorspacehandler_SSE2.h -endif - -if SUPPORT_AVX2 -libdesmume_a_SOURCES += \ - ../../utils/colorspacehandler/colorspacehandler_AVX2.cpp ../../utils/colorspacehandler/colorspacehandler_AVX2.h -endif - -if SUPPORT_ALTIVEC -libdesmume_a_SOURCES += \ - ../../utils/colorspacehandler/colorspacehandler_AltiVec.cpp ../../utils/colorspacehandler/colorspacehandler_AltiVec.h -endif - if HAVE_JIT libdesmume_a_SOURCES += \ - ../../arm_jit.cpp ../../arm_jit.h ../../instruction_attributes.h \ + ../../arm_jit.h ../../instruction_attributes.h + +if HOST_CPU_KIND_X86 +libdesmume_a_SOURCES += \ + ../../arm_jit.cpp \ ../../utils/AsmJit/AsmJit.h \ ../../utils/AsmJit/Config.h \ ../../utils/AsmJit/core.h \ @@ -206,6 +195,13 @@ libdesmume_a_SOURCES += \ ../../utils/AsmJit/x86/x86operand.h \ ../../utils/AsmJit/x86/x86util.cpp \ ../../utils/AsmJit/x86/x86util.h +else +if HOST_CPU_KIND_ARM +libdesmume_a_SOURCES += \ + ../../utils/arm_jit/arm_jit_arm.cpp +endif +endif + endif libdesmume_a_SOURCES += shared/desmume_config.cpp shared/desmume_config.h diff --git a/desmume/src/frontend/posix/configure.ac b/desmume/src/frontend/posix/configure.ac index d4d201014..1aaf0e763 100644 --- a/desmume/src/frontend/posix/configure.ac +++ b/desmume/src/frontend/posix/configure.ac @@ -338,7 +338,7 @@ fi dnl - jit support case $host_cpu in - x86|x86_64|i386|i486|i586|i686) + x86|x86_64|i386|i486|i586|i686|arm|arm64|aarch64) HAVE_JIT=yes AC_DEFINE(HAVE_JIT) ;; @@ -382,19 +382,37 @@ AS_CASE([$host], ) AS_CASE([$host_cpu], - [x86_64], [AC_DEFINE(HOST_64)], - [amd64], [AC_DEFINE(HOST_64)], + [x86_64], [AC_DEFINE(HOST_64)], + [amd64], [AC_DEFINE(HOST_64)], + [aarch64], [AC_DEFINE(HOST_64)], + [arm64], [AC_DEFINE(HOST_64)], + [ppc64], [AC_DEFINE(HOST_64)], [AC_DEFINE(HOST_32)] ) -AC_CHECK_DECL([__SSE2__]) -AM_CONDITIONAL([SUPPORT_SSE2], [test "x$ac_cv_have_decl___SSE2__" = xyes]) +host_cpu_kind_x86=no +host_cpu_kind_arm=no +host_cpu_kind_powerpc=no +host_cpu_kind_unknown=no +AS_CASE([$host_cpu], + [x86_64], [host_cpu_kind_x86=yes], + [amd64], [host_cpu_kind_x86=yes], + [x86], [host_cpu_kind_x86=yes], + [i686], [host_cpu_kind_x86=yes], + [i586], [host_cpu_kind_x86=yes], + [i486], [host_cpu_kind_x86=yes], + [i386], [host_cpu_kind_x86=yes], + [aarch64], [host_cpu_kind_arm=yes], + [arm64], [host_cpu_kind_arm=yes], + [arm], [host_cpu_kind_arm=yes], + [ppc64], [host_cpu_kind_powerpc=yes], + [powerpc], [host_cpu_kind_powerpc=yes], + [host_cpu_kind_unknown=yes] +) -AC_CHECK_DECL([__AVX2__]) -AM_CONDITIONAL([SUPPORT_AVX2], [test "x$ac_cv_have_decl___AVX2__" = xyes]) - -AC_CHECK_DECL([__ALTIVEC__]) -AM_CONDITIONAL([SUPPORT_ALTIVEC], [test "x$ac_cv_have_decl___ALTIVEC__" = xyes]) +AM_CONDITIONAL([HOST_CPU_KIND_X86], [test x$host_cpu_kind_x86 = xyes]) +AM_CONDITIONAL([HOST_CPU_KIND_ARM], [test x$host_cpu_kind_arm = xyes]) +AM_CONDITIONAL([HOST_CPU_KIND_PPC], [test x$host_cpu_kind_powerpc = xyes]) AC_SUBST(UI_DIR) AC_SUBST(PO_DIR) diff --git a/desmume/src/frontend/posix/meson.build b/desmume/src/frontend/posix/meson.build index 77e6f62c2..a17c22617 100644 --- a/desmume/src/frontend/posix/meson.build +++ b/desmume/src/frontend/posix/meson.build @@ -34,14 +34,48 @@ endif dependencies = [dep_glib2, dep_sdl, dep_pcap, dep_zlib, dep_threads] -if target_machine.cpu() == 'x86_64' - add_global_arguments('-DHAVE_JIT', language: ['c', 'cpp']) +# Determine the CPU architecture of the target. +target_cpu_64bit = false +target_cpu_kind_x86 = false +target_cpu_kind_arm = false +target_cpu_kind_powerpc = false +target_cpu_kind_unknown = false + +if target_machine.cpu() == 'x86_64' or \ + target_machine.cpu() == 'amd64' + target_cpu_kind_x86 = true + target_cpu_64bit = true +elif target_machine.cpu() == 'x86' or \ + target_machine.cpu() == 'i686' or \ + target_machine.cpu() == 'i586' or \ + target_machine.cpu() == 'i486' or \ + target_machine.cpu() == 'i386' + target_cpu_kind_x86 = true +elif target_machine.cpu() == 'aarch64' or \ + target_machine.cpu() == 'arm64' + target_cpu_kind_arm = true + target_cpu_64bit = true +elif target_machine.cpu() == 'arm' + target_cpu_kind_arm = true +elif target_machine.cpu() == 'ppc64' + target_cpu_kind_powerpc = true + target_cpu_64bit = true +elif target_machine.cpu() == 'powerpc' + target_cpu_kind_powerpc = true +else + target_cpu_kind_unknown = true +endif + +if target_cpu_64bit add_global_arguments('-DHOST_64', language: ['c', 'cpp']) - have_jit = true -elif target_machine.cpu() == 'i686' - add_global_arguments('-DHAVE_JIT', language: ['c', 'cpp']) +else add_global_arguments('-DHOST_32', language: ['c', 'cpp']) +endif + +# Enable JIT for supported architectures. +if target_cpu_kind_x86 or target_cpu_kind_arm have_jit = true + add_global_arguments('-DHAVE_JIT', language: ['c', 'cpp']) else have_jit = false endif @@ -133,38 +167,44 @@ libdesmume_src = [ ] if have_jit - libdesmume_src += [ - '../../arm_jit.cpp', - '../../utils/AsmJit/core/assembler.cpp', - '../../utils/AsmJit/core/assert.cpp', - '../../utils/AsmJit/core/buffer.cpp', - '../../utils/AsmJit/core/compiler.cpp', - '../../utils/AsmJit/core/compilercontext.cpp', - '../../utils/AsmJit/core/compilerfunc.cpp', - '../../utils/AsmJit/core/compileritem.cpp', - '../../utils/AsmJit/core/context.cpp', - '../../utils/AsmJit/core/cpuinfo.cpp', - '../../utils/AsmJit/core/defs.cpp', - '../../utils/AsmJit/core/func.cpp', - '../../utils/AsmJit/core/logger.cpp', - '../../utils/AsmJit/core/memorymanager.cpp', - '../../utils/AsmJit/core/memorymarker.cpp', - '../../utils/AsmJit/core/operand.cpp', - '../../utils/AsmJit/core/stringbuilder.cpp', - '../../utils/AsmJit/core/stringutil.cpp', - '../../utils/AsmJit/core/virtualmemory.cpp', - '../../utils/AsmJit/core/zonememory.cpp', - '../../utils/AsmJit/x86/x86assembler.cpp', - '../../utils/AsmJit/x86/x86compiler.cpp', - '../../utils/AsmJit/x86/x86compilercontext.cpp', - '../../utils/AsmJit/x86/x86compilerfunc.cpp', - '../../utils/AsmJit/x86/x86compileritem.cpp', - '../../utils/AsmJit/x86/x86cpuinfo.cpp', - '../../utils/AsmJit/x86/x86defs.cpp', - '../../utils/AsmJit/x86/x86func.cpp', - '../../utils/AsmJit/x86/x86operand.cpp', - '../../utils/AsmJit/x86/x86util.cpp', - ] + if target_cpu_kind_x86 + libdesmume_src += [ + '../../arm_jit.cpp', + '../../utils/AsmJit/core/assembler.cpp', + '../../utils/AsmJit/core/assert.cpp', + '../../utils/AsmJit/core/buffer.cpp', + '../../utils/AsmJit/core/compiler.cpp', + '../../utils/AsmJit/core/compilercontext.cpp', + '../../utils/AsmJit/core/compilerfunc.cpp', + '../../utils/AsmJit/core/compileritem.cpp', + '../../utils/AsmJit/core/context.cpp', + '../../utils/AsmJit/core/cpuinfo.cpp', + '../../utils/AsmJit/core/defs.cpp', + '../../utils/AsmJit/core/func.cpp', + '../../utils/AsmJit/core/logger.cpp', + '../../utils/AsmJit/core/memorymanager.cpp', + '../../utils/AsmJit/core/memorymarker.cpp', + '../../utils/AsmJit/core/operand.cpp', + '../../utils/AsmJit/core/stringbuilder.cpp', + '../../utils/AsmJit/core/stringutil.cpp', + '../../utils/AsmJit/core/virtualmemory.cpp', + '../../utils/AsmJit/core/zonememory.cpp', + '../../utils/AsmJit/x86/x86assembler.cpp', + '../../utils/AsmJit/x86/x86compiler.cpp', + '../../utils/AsmJit/x86/x86compilercontext.cpp', + '../../utils/AsmJit/x86/x86compilerfunc.cpp', + '../../utils/AsmJit/x86/x86compileritem.cpp', + '../../utils/AsmJit/x86/x86cpuinfo.cpp', + '../../utils/AsmJit/x86/x86defs.cpp', + '../../utils/AsmJit/x86/x86func.cpp', + '../../utils/AsmJit/x86/x86operand.cpp', + '../../utils/AsmJit/x86/x86util.cpp', + ] + elif target_cpu_kind_arm + libdesmume_src += [ + '../../utils/arm_jit/arm_jit_arm.cpp', + ] + endif endif libdesmume_src += [ @@ -285,25 +325,10 @@ if get_option('gdb-stub') ] endif -simd = import('unstable-simd') -cxx = meson.get_compiler('cpp') -rval = simd.check('colorspacehandler', - sse2: '../../utils/colorspacehandler/colorspacehandler_SSE2.cpp', - # TODO: add these two even in generic builds. - #avx2: '../../utils/colorspacehandler/colorspacehandler_AVX2.cpp', - #avx512: '../../utils/colorspacehandler/colorspacehandler_AVX512.cpp', - # TODO: add support for this in meson. - #altivec: '../../utils/colorspacehandler/colorspacehandler_AltiVec.cpp', - compiler: cxx, - include_directories: includes, -) -colorspacehandler_simd = rval[0] - libdesmume = static_library('desmume', libdesmume_src, dependencies: dependencies, include_directories: includes, - link_with: colorspacehandler_simd, ) if get_option('frontend-cli')