summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/eina/eina_cpu.c17
-rw-r--r--src/lib/eina/eina_cpu.h19
-rw-r--r--src/lib/evas/common/evas_cpu.c38
-rw-r--r--src/lib/evas/include/evas_common_private.h3
4 files changed, 61 insertions, 16 deletions
diff --git a/src/lib/eina/eina_cpu.c b/src/lib/eina/eina_cpu.c
index f12bec0fa8..45b3b9295d 100644
--- a/src/lib/eina/eina_cpu.c
+++ b/src/lib/eina/eina_cpu.c
@@ -49,7 +49,7 @@
49#include "eina_log.h" 49#include "eina_log.h"
50#include "eina_cpu.h" 50#include "eina_cpu.h"
51 51
52#if defined(HAVE_SYS_AUXV_H) && defined(HAVE_ASM_HWCAP_H) && defined(__arm__) && defined(__linux__) 52#if defined(HAVE_SYS_AUXV_H) && defined(HAVE_ASM_HWCAP_H) && (defined(__arm__) || defined(__aarch64__)) && defined(__linux__)
53# include <sys/auxv.h> 53# include <sys/auxv.h>
54# include <asm/hwcap.h> 54# include <asm/hwcap.h>
55#endif 55#endif
@@ -126,7 +126,7 @@ void _x86_simd(Eina_Cpu_Features *features)
126} 126}
127#endif 127#endif
128 128
129#if defined(HAVE_SYS_AUXV_H) && defined(HAVE_ASM_HWCAP_H) && defined(__arm__) && defined(__linux__) 129#if defined(HAVE_SYS_AUXV_H) && defined(HAVE_ASM_HWCAP_H) && (defined(__arm__) || defined(__aarch64__)) && defined(__linux__)
130static void 130static void
131_arm_cpu_features(Eina_Cpu_Features *features) 131_arm_cpu_features(Eina_Cpu_Features *features)
132{ 132{
@@ -134,8 +134,15 @@ _arm_cpu_features(Eina_Cpu_Features *features)
134 134
135 aux = getauxval(AT_HWCAP); 135 aux = getauxval(AT_HWCAP);
136 136
137 if (aux & HWCAP_NEON) 137# if defined(__aarch64__)
138 *features |= EINA_CPU_NEON; 138 *features |= EINA_CPU_NEON;
139# endif
140# ifdef HWCAP_NEON
141 if (aux & HWCAP_NEON) *features |= EINA_CPU_NEON;
142# endif
143# ifdef HWCAP_SVE
144 if (aux & HWCAP_SVE) *features |= EINA_CPU_SVE;
145# endif
139} 146}
140#endif 147#endif
141 148
@@ -157,7 +164,7 @@ eina_cpu_init(void)
157{ 164{
158#if defined(__i386__) || defined(__x86_64__) 165#if defined(__i386__) || defined(__x86_64__)
159 _x86_simd(&eina_cpu_features); 166 _x86_simd(&eina_cpu_features);
160#elif defined(HAVE_SYS_AUXV_H) && defined(HAVE_ASM_HWCAP_H) && defined(__arm__) && defined(__linux__) 167#elif defined(HAVE_SYS_AUXV_H) && defined(HAVE_ASM_HWCAP_H) && (defined(__arm__) || defined(__aarch64__)) && defined(__linux__)
161 _arm_cpu_features(&eina_cpu_features); 168 _arm_cpu_features(&eina_cpu_features);
162#endif 169#endif
163 170
diff --git a/src/lib/eina/eina_cpu.h b/src/lib/eina/eina_cpu.h
index 6235b7b939..6426017be6 100644
--- a/src/lib/eina/eina_cpu.h
+++ b/src/lib/eina/eina_cpu.h
@@ -45,17 +45,18 @@
45 */ 45 */
46typedef enum _Eina_Cpu_Features 46typedef enum _Eina_Cpu_Features
47{ 47{
48 EINA_CPU_MMX = 0x00000001, 48 EINA_CPU_MMX = 0x00000001,
49 EINA_CPU_SSE = 0x00000002, 49 EINA_CPU_SSE = 0x00000002,
50 EINA_CPU_SSE2 = 0x00000004, 50 EINA_CPU_SSE2 = 0x00000004,
51 EINA_CPU_SSE3 = 0x00000008, 51 EINA_CPU_SSE3 = 0x00000008,
52 /* TODO 3DNow! */ 52 /* TODO 3DNow! */
53 EINA_CPU_ALTIVEC = 0x00000010, 53 EINA_CPU_ALTIVEC = 0x00000010,
54 EINA_CPU_VIS = 0x00000020, 54 EINA_CPU_VIS = 0x00000020,
55 EINA_CPU_NEON = 0x00000040, 55 EINA_CPU_NEON = 0x00000040,
56 EINA_CPU_SSSE3 = 0x00000080, 56 EINA_CPU_SSSE3 = 0x00000080,
57 EINA_CPU_SSE41 = 0x00000100, 57 EINA_CPU_SSE41 = 0x00000100,
58 EINA_CPU_SSE42 = 0x00000200 58 EINA_CPU_SSE42 = 0x00000200,
59 EINA_CPU_SVE = 0x00000400
59} Eina_Cpu_Features; 60} Eina_Cpu_Features;
60 61
61/** 62/**
diff --git a/src/lib/evas/common/evas_cpu.c b/src/lib/evas/common/evas_cpu.c
index 5551775733..d9215e1140 100644
--- a/src/lib/evas/common/evas_cpu.c
+++ b/src/lib/evas/common/evas_cpu.c
@@ -7,7 +7,6 @@
7 7
8static int cpu_feature_mask = 0; 8static int cpu_feature_mask = 0;
9 9
10
11#ifdef BUILD_ALTIVEC 10#ifdef BUILD_ALTIVEC
12# ifdef __POWERPC__ 11# ifdef __POWERPC__
13# ifdef __VEC__ 12# ifdef __VEC__
@@ -26,6 +25,12 @@ static int cpu_feature_mask = 0;
26# endif 25# endif
27#endif 26#endif
28 27
28#if defined(__aarch64__)
29# ifdef BUILD_NEON
30# define NEED_FEATURE_TEST
31# endif
32#endif
33
29#ifdef NEED_FEATURE_TEST 34#ifdef NEED_FEATURE_TEST
30# ifdef HAVE_SIGLONGJMP 35# ifdef HAVE_SIGLONGJMP
31# include <signal.h> 36# include <signal.h>
@@ -70,6 +75,7 @@ evas_common_cpu_neon_test(void)
70# ifdef BUILD_NEON 75# ifdef BUILD_NEON
71# ifdef BUILD_NEON_INTRINSICS 76# ifdef BUILD_NEON_INTRINSICS
72 volatile uint32x4_t temp = vdupq_n_u32(0x1); 77 volatile uint32x4_t temp = vdupq_n_u32(0x1);
78 vaddq_u32(temp, temp);
73# else 79# else
74 asm volatile ( 80 asm volatile (
75 ".fpu neon \n\t" 81 ".fpu neon \n\t"
@@ -85,6 +91,15 @@ evas_common_cpu_neon_test(void)
85} 91}
86 92
87void 93void
94evas_common_cpu_sve_test(void)
95{
96#if defined(__aarch64__)
97 volatile int result = 123;
98 asm("movz %w[res], #10" : [res] "=r" (result));
99#endif
100}
101
102void
88evas_common_cpu_vis_test(void) 103evas_common_cpu_vis_test(void)
89{ 104{
90# ifdef __SPARC__ 105# ifdef __SPARC__
@@ -165,6 +180,10 @@ evas_common_cpu_feature_test(void (*feature)(void))
165 if (feature == evas_common_cpu_neon_test) 180 if (feature == evas_common_cpu_neon_test)
166 return _cpu_check(EINA_CPU_NEON); 181 return _cpu_check(EINA_CPU_NEON);
167# endif 182# endif
183# if defined(__aarch64__)
184 if (feature == evas_common_cpu_sve_test)
185 return _cpu_check(EINA_CPU_SVE);
186# endif
168 return 0; 187 return 0;
169# endif 188# endif
170} 189}
@@ -249,6 +268,23 @@ evas_common_cpu_init(void)
249 else 268 else
250 cpu_feature_mask |= CPU_FEATURE_NEON; 269 cpu_feature_mask |= CPU_FEATURE_NEON;
251#endif 270#endif
271
272#if defined(__aarch64__)
273 if (getenv("EVAS_CPU_NO_SVE"))
274 cpu_feature_mask &= ~CPU_FEATURE_SVE;
275 else
276 {
277# if defined(HAVE_SYS_AUXV_H) && defined(HAVE_ASM_HWCAP_H) && defined(__arm__) && defined(__linux__)
278#error "xx"
279 cpu_feature_mask |= CPU_FEATURE_SVE *
280 !!(eina_cpu_features_get() & EINA_CPU_SVE);
281# else
282 cpu_feature_mask |= CPU_FEATURE_SVE *
283 evas_common_cpu_feature_test(evas_common_cpu_sve_test);
284 evas_common_cpu_end_opt();
285# endif
286 }
287#endif
252} 288}
253 289
254int 290int
diff --git a/src/lib/evas/include/evas_common_private.h b/src/lib/evas/include/evas_common_private.h
index d0354347fc..7fe19b7b9a 100644
--- a/src/lib/evas/include/evas_common_private.h
+++ b/src/lib/evas/include/evas_common_private.h
@@ -503,7 +503,8 @@ typedef enum _CPU_Features
503 CPU_FEATURE_VIS = (1 << 4), 503 CPU_FEATURE_VIS = (1 << 4),
504 CPU_FEATURE_VIS2 = (1 << 5), 504 CPU_FEATURE_VIS2 = (1 << 5),
505 CPU_FEATURE_NEON = (1 << 6), 505 CPU_FEATURE_NEON = (1 << 6),
506 CPU_FEATURE_SSE3 = (1 << 7) 506 CPU_FEATURE_SSE3 = (1 << 7),
507 CPU_FEATURE_SVE = (1 << 8)
507} CPU_Features; 508} CPU_Features;
508 509
509/*****************************************************************************/ 510/*****************************************************************************/