xref: /freebsd/sys/contrib/openzfs/config/toolchain-simd.m4 (revision dc318a4ffabcbfa23bb56a33403aad36e6de30af)
1dnl #
2dnl # Checks if host toolchain supports SIMD instructions
3dnl #
4AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_TOOLCHAIN_SIMD], [
5	case "$host_cpu" in
6		amd64 | x86_64 | x86 | i686)
7			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE
8			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE2
9			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE3
10			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSSE3
11			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE4_1
12			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE4_2
13			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX
14			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX2
15			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512F
16			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512CD
17			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512DQ
18			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512BW
19			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512IFMA
20			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512VBMI
21			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512PF
22			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512ER
23			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512VL
24			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AES
25			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_PCLMULQDQ
26			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_MOVBE
27			;;
28	esac
29])
30
31dnl #
32dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE
33dnl #
34AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE], [
35	AC_MSG_CHECKING([whether host toolchain supports SSE])
36
37	AC_LINK_IFELSE([AC_LANG_SOURCE([[
38		void main()
39		{
40			__asm__ __volatile__("xorps %xmm0, %xmm1");
41		}
42	]])], [
43		AC_DEFINE([HAVE_SSE], 1, [Define if host toolchain supports SSE])
44		AC_MSG_RESULT([yes])
45	], [
46		AC_MSG_RESULT([no])
47	])
48])
49
50dnl #
51dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE2
52dnl #
53AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE2], [
54	AC_MSG_CHECKING([whether host toolchain supports SSE2])
55
56	AC_LINK_IFELSE([AC_LANG_SOURCE([[
57		void main()
58		{
59			__asm__ __volatile__("pxor %xmm0, %xmm1");
60		}
61	]])], [
62		AC_DEFINE([HAVE_SSE2], 1, [Define if host toolchain supports SSE2])
63		AC_MSG_RESULT([yes])
64	], [
65		AC_MSG_RESULT([no])
66	])
67])
68
69dnl #
70dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE3
71dnl #
72AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE3], [
73	AC_MSG_CHECKING([whether host toolchain supports SSE3])
74
75	AC_LINK_IFELSE([AC_LANG_SOURCE([[
76		void main()
77		{
78			char v[16];
79			__asm__ __volatile__("lddqu %0,%%xmm0" :: "m"(v[0]));
80		}
81	]])], [
82		AC_DEFINE([HAVE_SSE3], 1, [Define if host toolchain supports SSE3])
83		AC_MSG_RESULT([yes])
84	], [
85		AC_MSG_RESULT([no])
86	])
87])
88
89dnl #
90dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSSE3
91dnl #
92AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSSE3], [
93	AC_MSG_CHECKING([whether host toolchain supports SSSE3])
94
95	AC_LINK_IFELSE([AC_LANG_SOURCE([[
96		void main()
97		{
98			__asm__ __volatile__("pshufb %xmm0,%xmm1");
99		}
100	]])], [
101		AC_DEFINE([HAVE_SSSE3], 1, [Define if host toolchain supports SSSE3])
102		AC_MSG_RESULT([yes])
103	], [
104		AC_MSG_RESULT([no])
105	])
106])
107
108dnl #
109dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE4_1
110dnl #
111AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE4_1], [
112	AC_MSG_CHECKING([whether host toolchain supports SSE4.1])
113
114	AC_LINK_IFELSE([AC_LANG_SOURCE([[
115		void main()
116		{
117			__asm__ __volatile__("pmaxsb %xmm0,%xmm1");
118		}
119	]])], [
120		AC_DEFINE([HAVE_SSE4_1], 1, [Define if host toolchain supports SSE4.1])
121		AC_MSG_RESULT([yes])
122	], [
123		AC_MSG_RESULT([no])
124	])
125])
126
127dnl #
128dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE4_2
129dnl #
130AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE4_2], [
131	AC_MSG_CHECKING([whether host toolchain supports SSE4.2])
132
133	AC_LINK_IFELSE([AC_LANG_SOURCE([[
134		void main()
135		{
136			__asm__ __volatile__("pcmpgtq %xmm0, %xmm1");
137		}
138	]])], [
139		AC_DEFINE([HAVE_SSE4_2], 1, [Define if host toolchain supports SSE4.2])
140		AC_MSG_RESULT([yes])
141	], [
142		AC_MSG_RESULT([no])
143	])
144])
145
146dnl #
147dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX
148dnl #
149AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX], [
150	AC_MSG_CHECKING([whether host toolchain supports AVX])
151
152	AC_LINK_IFELSE([AC_LANG_SOURCE([[
153		void main()
154		{
155			char v[32];
156			__asm__ __volatile__("vmovdqa %0,%%ymm0" :: "m"(v[0]));
157		}
158	]])], [
159		AC_MSG_RESULT([yes])
160		AC_DEFINE([HAVE_AVX], 1, [Define if host toolchain supports AVX])
161	], [
162		AC_MSG_RESULT([no])
163	])
164])
165
166dnl #
167dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX2
168dnl #
169AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX2], [
170	AC_MSG_CHECKING([whether host toolchain supports AVX2])
171
172	AC_LINK_IFELSE([AC_LANG_SOURCE([
173	[
174		void main()
175		{
176			__asm__ __volatile__("vpshufb %ymm0,%ymm1,%ymm2");
177		}
178	]])], [
179		AC_MSG_RESULT([yes])
180		AC_DEFINE([HAVE_AVX2], 1, [Define if host toolchain supports AVX2])
181	], [
182		AC_MSG_RESULT([no])
183	])
184])
185
186dnl #
187dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512F
188dnl #
189AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512F], [
190	AC_MSG_CHECKING([whether host toolchain supports AVX512F])
191
192	AC_LINK_IFELSE([AC_LANG_SOURCE([
193	[
194		void main()
195		{
196			__asm__ __volatile__("vpandd %zmm0,%zmm1,%zmm2");
197		}
198	]])], [
199		AC_MSG_RESULT([yes])
200		AC_DEFINE([HAVE_AVX512F], 1, [Define if host toolchain supports AVX512F])
201	], [
202		AC_MSG_RESULT([no])
203	])
204])
205
206dnl #
207dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512CD
208dnl #
209AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512CD], [
210	AC_MSG_CHECKING([whether host toolchain supports AVX512CD])
211
212	AC_LINK_IFELSE([AC_LANG_SOURCE([
213	[
214		void main()
215		{
216			__asm__ __volatile__("vplzcntd %zmm0,%zmm1");
217		}
218	]])], [
219		AC_MSG_RESULT([yes])
220		AC_DEFINE([HAVE_AVX512CD], 1, [Define if host toolchain supports AVX512CD])
221	], [
222		AC_MSG_RESULT([no])
223	])
224])
225
226dnl #
227dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512DQ
228dnl #
229AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512DQ], [
230	AC_MSG_CHECKING([whether host toolchain supports AVX512DQ])
231
232	AC_LINK_IFELSE([AC_LANG_SOURCE([
233	[
234		void main()
235		{
236			__asm__ __volatile__("vandpd %zmm0,%zmm1,%zmm2");
237		}
238	]])], [
239		AC_MSG_RESULT([yes])
240		AC_DEFINE([HAVE_AVX512DQ], 1, [Define if host toolchain supports AVX512DQ])
241	], [
242		AC_MSG_RESULT([no])
243	])
244])
245
246dnl #
247dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512BW
248dnl #
249AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512BW], [
250	AC_MSG_CHECKING([whether host toolchain supports AVX512BW])
251
252	AC_LINK_IFELSE([AC_LANG_SOURCE([
253	[
254		void main()
255		{
256			__asm__ __volatile__("vpshufb %zmm0,%zmm1,%zmm2");
257		}
258	]])], [
259		AC_MSG_RESULT([yes])
260		AC_DEFINE([HAVE_AVX512BW], 1, [Define if host toolchain supports AVX512BW])
261	], [
262		AC_MSG_RESULT([no])
263	])
264])
265
266dnl #
267dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512IFMA
268dnl #
269AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512IFMA], [
270	AC_MSG_CHECKING([whether host toolchain supports AVX512IFMA])
271
272	AC_LINK_IFELSE([AC_LANG_SOURCE([
273	[
274		void main()
275		{
276			__asm__ __volatile__("vpmadd52luq %zmm0,%zmm1,%zmm2");
277		}
278	]])], [
279		AC_MSG_RESULT([yes])
280		AC_DEFINE([HAVE_AVX512IFMA], 1, [Define if host toolchain supports AVX512IFMA])
281	], [
282		AC_MSG_RESULT([no])
283	])
284])
285
286dnl #
287dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512VBMI
288dnl #
289AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512VBMI], [
290	AC_MSG_CHECKING([whether host toolchain supports AVX512VBMI])
291
292	AC_LINK_IFELSE([AC_LANG_SOURCE([
293	[
294		void main()
295		{
296			__asm__ __volatile__("vpermb %zmm0,%zmm1,%zmm2");
297		}
298	]])], [
299		AC_MSG_RESULT([yes])
300		AC_DEFINE([HAVE_AVX512VBMI], 1, [Define if host toolchain supports AVX512VBMI])
301	], [
302		AC_MSG_RESULT([no])
303	])
304])
305
306dnl #
307dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512PF
308dnl #
309AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512PF], [
310	AC_MSG_CHECKING([whether host toolchain supports AVX512PF])
311
312	AC_LINK_IFELSE([AC_LANG_SOURCE([
313	[
314		void main()
315		{
316			__asm__ __volatile__("vgatherpf0dps (%rsi,%zmm0,4){%k1}");
317		}
318	]])], [
319		AC_MSG_RESULT([yes])
320		AC_DEFINE([HAVE_AVX512PF], 1, [Define if host toolchain supports AVX512PF])
321	], [
322		AC_MSG_RESULT([no])
323	])
324])
325
326dnl #
327dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512ER
328dnl #
329AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512ER], [
330	AC_MSG_CHECKING([whether host toolchain supports AVX512ER])
331
332	AC_LINK_IFELSE([AC_LANG_SOURCE([
333	[
334		void main()
335		{
336			__asm__ __volatile__("vexp2pd %zmm0,%zmm1");
337		}
338	]])], [
339		AC_MSG_RESULT([yes])
340		AC_DEFINE([HAVE_AVX512ER], 1, [Define if host toolchain supports AVX512ER])
341	], [
342		AC_MSG_RESULT([no])
343	])
344])
345
346dnl #
347dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512VL
348dnl #
349AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512VL], [
350	AC_MSG_CHECKING([whether host toolchain supports AVX512VL])
351
352	AC_LINK_IFELSE([AC_LANG_SOURCE([
353	[
354		void main()
355		{
356			__asm__ __volatile__("vpabsq %zmm0,%zmm1");
357		}
358	]])], [
359		AC_MSG_RESULT([yes])
360		AC_DEFINE([HAVE_AVX512VL], 1, [Define if host toolchain supports AVX512VL])
361	], [
362		AC_MSG_RESULT([no])
363	])
364])
365
366dnl #
367dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AES
368dnl #
369AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AES], [
370	AC_MSG_CHECKING([whether host toolchain supports AES])
371
372	AC_LINK_IFELSE([AC_LANG_SOURCE([
373	[
374		void main()
375		{
376			__asm__ __volatile__("aesenc %xmm0, %xmm1");
377		}
378	]])], [
379		AC_MSG_RESULT([yes])
380		AC_DEFINE([HAVE_AES], 1, [Define if host toolchain supports AES])
381	], [
382		AC_MSG_RESULT([no])
383	])
384])
385
386dnl #
387dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_PCLMULQDQ
388dnl #
389AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_PCLMULQDQ], [
390	AC_MSG_CHECKING([whether host toolchain supports PCLMULQDQ])
391
392	AC_LINK_IFELSE([AC_LANG_SOURCE([
393	[
394		void main()
395		{
396			__asm__ __volatile__("pclmulqdq %0, %%xmm0, %%xmm1" :: "i"(0));
397		}
398	]])], [
399		AC_MSG_RESULT([yes])
400		AC_DEFINE([HAVE_PCLMULQDQ], 1, [Define if host toolchain supports PCLMULQDQ])
401	], [
402		AC_MSG_RESULT([no])
403	])
404])
405
406dnl #
407dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_MOVBE
408dnl #
409AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_MOVBE], [
410	AC_MSG_CHECKING([whether host toolchain supports MOVBE])
411
412	AC_LINK_IFELSE([AC_LANG_SOURCE([
413	[
414		void main()
415		{
416			__asm__ __volatile__("movbe 0(%eax), %eax");
417		}
418	]])], [
419		AC_MSG_RESULT([yes])
420		AC_DEFINE([HAVE_MOVBE], 1, [Define if host toolchain supports MOVBE])
421	], [
422		AC_MSG_RESULT([no])
423	])
424])
425