]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Handle ARM64EC as ARM64.
authorDavid Korth <gerbilsoft@gerbilsoft.com>
Sat, 15 Jul 2023 14:13:20 +0000 (10:13 -0400)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Sun, 16 Jul 2023 10:42:38 +0000 (12:42 +0200)
ARM64EC is a new ARM64 variant introduced in Windows 11 that uses an
ABI similar to AMD64, which allows for better interoperability with
emulated AMD64 applications. When enabled in MSVC, it defines _M_AMD64
and _M_ARM64EC, but not _M_ARM64, so we need to check for _M_ARM64EC.

arch/arm/arm_features.c
arch/arm/chunkset_neon.c
arch/arm/crc32_acle.c
arch/arm/neon_intrins.h
cmake/detect-arch.c
cmake/detect-arch.cmake
cmake/detect-intrinsics.cmake
configure
fallback_builtins.h
zbuild.h
zendian.h

index 7394351fa1adae002ea1dfe9f7c31fd10ce49139..8ef82000998a76d53551be01a52b1ef045d53e13 100644 (file)
@@ -45,7 +45,7 @@ static int arm_has_crc32() {
 }
 
 /* AArch64 has neon. */
-#if !defined(__aarch64__) && !defined(_M_ARM64)
+#if !defined(__aarch64__) && !defined(_M_ARM64) && !defined(_M_ARM64EC)
 static inline int arm_has_neon() {
 #if defined(__linux__) && defined(ARM_AUXV_HAS_NEON)
 #  ifdef HWCAP_ARM_NEON
@@ -73,7 +73,7 @@ static inline int arm_has_neon() {
 #endif
 
 void Z_INTERNAL arm_check_features(struct arm_cpu_features *features) {
-#if defined(__aarch64__) || defined(_M_ARM64)
+#if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
     features->has_neon = 1; /* always available */
 #else
     features->has_neon = arm_has_neon();
index 7891eabd2a7584d906465a1c9f9a6e11a93cac30..f9a444b0681fc02a832fd3399a6cc1be37c77533 100644 (file)
@@ -72,7 +72,7 @@ static inline chunk_t GET_CHUNK_MAG(uint8_t *buf, uint32_t *chunk_rem, uint32_t
     __msan_unpoison(buf + dist, 16 - dist);
 
     /* This version of table is only available on aarch64 */
-#if defined(_M_ARM64) || defined(__aarch64__)
+#if defined(_M_ARM64) || defined(_M_ARM64EC) || defined(__aarch64__)
     uint8x16_t ret_vec = vld1q_u8(buf);
 
     uint8x16_t perm_vec = vld1q_u8(permute_table + lut_rem.idx);
index a4e54d7182719740ba56899e849885af3c05302c..0c9b9b6596f210e51fbe513fbe2bda75aac721db 100644 (file)
@@ -33,7 +33,7 @@ Z_INTERNAL uint32_t crc32_acle(uint32_t crc, const uint8_t *buf, size_t len) {
         buf4 = (const uint32_t *) buf;
     }
 
-#if defined(__aarch64__) || defined(_M_ARM64)
+#if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
     if ((len >= sizeof(uint32_t)) && ((ptrdiff_t)buf & sizeof(uint32_t))) {
         c = __crc32w(c, *buf4++);
         len -= sizeof(uint32_t);
index d6b57f6414c402af02e8ebfd43feddbd84837534..478697a6de9f21c6575b65eea6a622cf1feb3dca 100644 (file)
@@ -1,13 +1,13 @@
 #ifndef ARM_NEON_INTRINS_H
 #define ARM_NEON_INTRINS_H
 
-#ifdef _M_ARM64
+#if defined(_M_ARM64) || defined(_M_ARM64EC)
 #  include <arm64_neon.h>
 #else
 #  include <arm_neon.h>
 #endif
 
-#if defined(ARM_NEON) && !defined(__aarch64__) && !defined(_M_ARM64)
+#if defined(ARM_NEON) && !defined(__aarch64__) && !defined(_M_ARM64) && !defined(_M_ARM64EC)
 /* Compatibility shim for the _high family of functions */
 #define vmull_high_u8(a, b) vmull_u8(vget_high_u8(a), vget_high_u8(b))
 #define vmlal_high_u8(a, b, c) vmlal_u8(a, vget_high_u8(b), vget_high_u8(c))
index 903ae5f29ff4614a99478b9d378bf239eb603868..92590182c2dd0d4d1e20b70c21fe12d3c8597bfe 100644 (file)
@@ -12,7 +12,7 @@
     #error archfound i686
 
 // ARM
-#elif defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64)
+#elif defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
     #error archfound aarch64
 #elif defined(__arm__) || defined(__arm) || defined(_M_ARM) || defined(__TARGET_ARCH_ARM)
     #if defined(__ARM64_ARCH_8__) || defined(__ARMv8__) || defined(__ARMv8_A__)
index 706d13f8779dd596a4379dc3d165f846a4a9a981..dfdc6013cea78b88ede50273ff0ae153b41dbe0f 100644 (file)
@@ -13,7 +13,7 @@ elseif(MSVC)
         set(ARCH "x86_64")
     elseif("${MSVC_C_ARCHITECTURE_ID}" STREQUAL "ARM" OR "${MSVC_C_ARCHITECTURE_ID}" STREQUAL "ARMV7")
         set(ARCH "arm")
-    elseif ("${MSVC_C_ARCHITECTURE_ID}" STREQUAL "ARM64")
+    elseif ("${MSVC_C_ARCHITECTURE_ID}" STREQUAL "ARM64" OR "${MSVC_C_ARCHITECTURE_ID}" STREQUAL "ARM64EC")
         set(ARCH "aarch64")
     endif()
 elseif(EMSCRIPTEN)
index 9cbc5908987ff91bc697ea29c15ed519b1d396a0..b0b0516e379f385866785f466849263c0c5a49b3 100644 (file)
@@ -176,7 +176,7 @@ macro(check_neon_compiler_flag)
     # Check whether compiler supports NEON flag
     set(CMAKE_REQUIRED_FLAGS "${NEONFLAG} ${NATIVEFLAG}")
     check_c_source_compiles(
-        "#ifdef _M_ARM64
+        "#if defined(_M_ARM64) || defined(_M_ARM64EC)
         #  include <arm64_neon.h>
         #else
         #  include <arm_neon.h>
@@ -199,7 +199,7 @@ macro(check_neon_ld4_intrinsics)
     # Check whether compiler supports loading 4 neon vecs into a register range
     set(CMAKE_REQUIRED_FLAGS "${NEONFLAG}")
     check_c_source_compiles(
-        "#ifdef _M_ARM64
+        "#if defined(_M_ARM64) || defined(_M_ARM64EC)
         #  include <arm64_neon.h>
         #else
         #  include <arm_neon.h>
index 8714590e526ddb955ec2015b0966a842967f17e2..29a64badfdba14ddb5afe6e1f54f63ba672223d2 100755 (executable)
--- a/configure
+++ b/configure
@@ -1200,7 +1200,7 @@ EOF
 check_neon_compiler_flag() {
     # Check whether -mfpu=neon is available on ARM processors.
     cat > $test.c << EOF
-#ifdef _M_ARM64
+#if defined(_M_ARM64) || defined(_M_ARM64EC)
  #  include <arm64_neon.h>
  #else
  #  include <arm_neon.h>
@@ -1225,7 +1225,7 @@ check_neon_ld4_intrinsics() {
         fi
     fi
     cat > $test.c << EOF
-#ifdef _M_ARM64
+#if defined(_M_ARM64) || defined(_M_ARM64EC)
 #  include <arm64_neon.h>
 #else
 #  include <arm_neon.h>
index 447f9ac1930fe0b43982265ce710316c6d3b2555..6e8ed9f400500b8f79dd59ce62819c703523f2af 100644 (file)
@@ -2,7 +2,7 @@
 #define FALLBACK_BUILTINS_H
 
 #if defined(_MSC_VER) && !defined(__clang__)
-#if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) ||  defined(_M_ARM) || defined(_M_ARM64)
+#if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) ||  defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC)
 
 #include <intrin.h>
 #ifdef X86_FEATURES
index d9559591b4cd071ab171e077967194b6ee204b81..2f9dd6b1c0c9b1df59a3c0010997b1d9682f7172 100644 (file)
--- a/zbuild.h
+++ b/zbuild.h
 #  elif defined(__i386__) || defined(__i486__) || defined(__i586__) || \
         defined(__i686__) || defined(_X86_) || defined(_M_IX86)
 #    define UNALIGNED_OK
-#  elif defined(__aarch64__) || defined(_M_ARM64)
+#  elif defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
 #    if (defined(__GNUC__) && defined(__ARM_FEATURE_UNALIGNED)) || !defined(__GNUC__)
 #      define UNALIGNED_OK
 #      define UNALIGNED64_OK
index 3fdb13041a05a1609e2873793b067db20ddde9ac..28177a609ff177db5d44ba593e500fe82e8c76e5 100644 (file)
--- a/zendian.h
+++ b/zendian.h
@@ -27,7 +27,7 @@
 #elif defined(_WIN32)
 #  define LITTLE_ENDIAN 1234
 #  define BIG_ENDIAN 4321
-#  if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) || defined (_M_ARM) || defined (_M_ARM64)
+#  if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) || defined (_M_ARM) || defined (_M_ARM64) || defined (_M_ARM64EC)
 #    define BYTE_ORDER LITTLE_ENDIAN
 #  else
 #    error Unknown endianness!