forked from ilyakurdyukov/e2k-ports
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zlib-ng-2.1.4-e2k.patch
122 lines (117 loc) · 4.42 KB
/
zlib-ng-2.1.4-e2k.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
From c134cd6275ab3c2813e5b1e3730600108166f809 Mon Sep 17 00:00:00 2001
From: Ilya Kurdyukov <[email protected]>
Date: Sun, 22 Oct 2023 09:29:44 +0700
Subject: [PATCH] zlib-ng-2.1.4 e2k support
---
CMakeLists.txt | 14 +++++++++++++-
arch/x86/x86_features.c | 14 ++++++++++++++
arch/x86/x86_intrins.h | 7 ++++++-
cmake/detect-arch.cmake | 2 ++
cmake/detect-intrinsics.cmake | 3 +++
5 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 974af49..15ab3f7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -113,6 +113,18 @@ elseif(BASEARCH_S360_FOUND)
option(WITH_DFLTCC_DEFLATE "Build with DFLTCC intrinsics for compression on IBM Z" OFF)
option(WITH_DFLTCC_INFLATE "Build with DFLTCC intrinsics for decompression on IBM Z" OFF)
option(WITH_CRC32_VX "Build with vectorized CRC32 on IBM Z" ON)
+elseif(BASEARCH_X86_FOUND AND ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "e2k")
+ option(WITH_AVX2 "Build with AVX2" OFF)
+ option(WITH_AVX512 "Build with AVX512" OFF)
+ option(WITH_AVX512VNNI "Build with AVX512 VNNI extensions" OFF)
+ option(WITH_SSE2 "Build with SSE2" ON)
+ option(WITH_SSSE3 "Build with SSSE3" ON)
+ option(WITH_SSE42 "Build with SSE42" OFF)
+ option(WITH_PCLMULQDQ "Build with PCLMULQDQ" ON)
+ option(WITH_VPCLMULQDQ "Build with VPCLMULQDQ" OFF)
+ if(NOT WITH_AVX2)
+ add_compile_options(-mno-avx)
+ endif()
elseif(BASEARCH_X86_FOUND)
option(WITH_AVX2 "Build with AVX2" ON)
option(WITH_AVX512 "Build with AVX512" ON)
@@ -873,7 +885,7 @@ if(WITH_OPTIM)
set(WITH_SSSE3 OFF)
endif()
endif()
- if(WITH_PCLMULQDQ AND WITH_SSSE3 AND WITH_SSE42)
+ if(WITH_PCLMULQDQ AND WITH_SSSE3 AND (WITH_SSE42 OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "e2k"))
check_pclmulqdq_intrinsics()
if(HAVE_PCLMULQDQ_INTRIN AND HAVE_SSSE3_INTRIN)
add_definitions(-DX86_PCLMULQDQ_CRC)
diff --git a/arch/x86/x86_features.c b/arch/x86/x86_features.c
index 8d11564..12ded76 100644
--- a/arch/x86/x86_features.c
+++ b/arch/x86/x86_features.c
@@ -10,6 +10,19 @@
#include "../../zbuild.h"
#include "x86_features.h"
+#ifdef __e2k__
+void Z_INTERNAL x86_check_features(struct x86_cpu_features *features) {
+ features->has_sse2 = 1;
+ features->has_ssse3 = 1;
+#if __iset__ >= 6
+ features->has_pclmulqdq = 1;
+#endif
+#ifdef __AVX2__
+ features->has_os_save_ymm = 1;
+ features->has_avx2 = 1;
+#endif
+}
+#else
#ifdef _MSC_VER
# include <intrin.h>
#else
@@ -95,3 +108,4 @@ void Z_INTERNAL x86_check_features(struct x86_cpu_features *features) {
}
}
}
+#endif
diff --git a/arch/x86/x86_intrins.h b/arch/x86/x86_intrins.h
index 52e1085..126ab68 100644
--- a/arch/x86/x86_intrins.h
+++ b/arch/x86/x86_intrins.h
@@ -7,7 +7,12 @@
#ifdef __AVX2__
#include <immintrin.h>
-#if (!defined(__clang__) && defined(__GNUC__) && __GNUC__ < 10) \
+#ifdef __e2k__
+#define _mm256_zextsi128_si256 _mm256_zextsi128_si256_redef
+static inline __m256i _mm256_zextsi128_si256(__m128i a) {
+ return _mm256_set_m128i(_mm_setzero_si128(), a);
+}
+#elif (!defined(__clang__) && defined(__GNUC__) && __GNUC__ < 10) \
|| (defined(__apple_build_version__) && __apple_build_version__ < 9020039)
static inline __m256i _mm256_zextsi128_si256(__m128i a) {
__m128i r;
diff --git a/cmake/detect-arch.cmake b/cmake/detect-arch.cmake
index dfdc601..41a78cb 100644
--- a/cmake/detect-arch.cmake
+++ b/cmake/detect-arch.cmake
@@ -16,6 +16,8 @@ elseif(MSVC)
elseif ("${MSVC_C_ARCHITECTURE_ID}" STREQUAL "ARM64" OR "${MSVC_C_ARCHITECTURE_ID}" STREQUAL "ARM64EC")
set(ARCH "aarch64")
endif()
+elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "e2k")
+ set(ARCH "x86_64")
elseif(EMSCRIPTEN)
set(ARCH "wasm32")
elseif(CMAKE_CROSSCOMPILING)
diff --git a/cmake/detect-intrinsics.cmake b/cmake/detect-intrinsics.cmake
index 250ee44..f4a6ad9 100644
--- a/cmake/detect-intrinsics.cmake
+++ b/cmake/detect-intrinsics.cmake
@@ -245,6 +245,9 @@ macro(check_pclmulqdq_intrinsics)
set(CMAKE_REQUIRED_FLAGS "${PCLMULFLAG} ${NATIVEFLAG}")
check_c_source_compiles(
"#include <immintrin.h>
+ #if defined(__e2k__) && __iset__ < 6
+ #error
+ #endif
#include <wmmintrin.h>
__m128i f(__m128i a, __m128i b) { return _mm_clmulepi64_si128(a, b, 0x10); }
int main(void) { return 0; }"
--
2.34.1