[Apple Arm] introduce sse2neon

This commit is contained in:
SimoneN64
2025-02-07 19:32:13 +01:00
parent 38057b77d5
commit e57edb6a9a
7 changed files with 9484 additions and 7 deletions

21
external/sse2neon/LICENSE vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2015-2025 SSE2NEON Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

9434
external/sse2neon/sse2neon.h vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
#include <Scheduler.hpp> #include <Scheduler.hpp>
namespace n64 { namespace n64 {
Core::Core() : cpu(std::make_unique<JIT>(parallel)) {} Core::Core() : cpu(std::make_unique<Interpreter>(parallel)) {}
void Core::Stop() { void Core::Stop() {
render = false; render = false;

View File

@@ -2,11 +2,16 @@ file(GLOB SOURCES *.cpp)
file(GLOB HEADERS *.hpp) file(GLOB HEADERS *.hpp)
add_subdirectory(interpreter) add_subdirectory(interpreter)
add_subdirectory(jit) if(NOT ARM_APPLE)
add_subdirectory(jit)
endif()
add_subdirectory(mem) add_subdirectory(mem)
add_subdirectory(mmio) add_subdirectory(mmio)
add_subdirectory(registers) add_subdirectory(registers)
add_subdirectory(rsp) add_subdirectory(rsp)
add_library(core ${SOURCES} ${HEADERS}) add_library(core ${SOURCES} ${HEADERS})
target_link_libraries(core PRIVATE jit interpreter mem mmio unarr registers rsp) target_link_libraries(core PRIVATE interpreter mem mmio unarr registers rsp)
if(NOT ARM_APPLE)
target_link_libraries(core PRIVATE jit)
endif()

View File

@@ -1,7 +1,11 @@
#pragma once #pragma once
#include <bitset> #include <bitset>
#include <cstdint> #include <cstdint>
#ifdef __aarch64__
#include <sse2neon.h>
#else
#include <emmintrin.h> #include <emmintrin.h>
#endif
using u8 = uint8_t; using u8 = uint8_t;
using u16 = uint16_t; using u16 = uint16_t;

View File

@@ -9,9 +9,11 @@ find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
if (WIN32) if (WIN32)
add_compile_definitions(NOMINMAX) add_compile_definitions(NOMINMAX)
endif () endif ()
if(APPLE) if(APPLE)
enable_language(OBJC) enable_language(OBJC)
endif() endif()
include_directories( include_directories(
. .
../ ../
@@ -38,6 +40,7 @@ include_directories(
../../external/parallel-rdp/parallel-rdp-standalone/util ../../external/parallel-rdp/parallel-rdp-standalone/util
../../external/unarr ../../external/unarr
../../external/SDL/include ../../external/SDL/include
../../external/sse2neon
../../external/capstone/include ../../external/capstone/include
) )
@@ -48,11 +51,22 @@ option(BUILD_SHARED_LIBS OFF)
include(CheckCCompilerFlag) include(CheckCCompilerFlag)
check_c_compiler_flag(-msse4.1 HAS_SSE4_1) check_c_compiler_flag(-msse4.1 HAS_SIMD)
if(NOT HAS_SIMD)
check_c_compiler_flag(-mfpu=neon HAS_SIMD)
if(APPLE AND HAS_SIMD)
set(ARM_APPLE ON)
message("Compiling on ARM MacOS, very experimental and cool!")
endif()
endif()
if (HAS_SSE4_1) if (HAS_SIMD)
add_compile_definitions(SIMD_SUPPORT) add_compile_definitions(SIMD_SUPPORT)
if(ARM_APPLE)
add_compile_options(-mfpu=neon)
else()
add_compile_options(-msse3 -msse4.1) add_compile_options(-msse3 -msse4.1)
endif()
endif () endif ()
if (${CMAKE_BUILD_TYPE} MATCHES Debug) if (${CMAKE_BUILD_TYPE} MATCHES Debug)

View File

@@ -1,7 +1,6 @@
#pragma once #pragma once
#include <cmath> #include <cmath>
#include <common.hpp> #include <common.hpp>
#include <immintrin.h>
namespace Util { namespace Util {
static FORCE_INLINE auto roundCeil(float f) { static FORCE_INLINE auto roundCeil(float f) {