1# Generate libmvec.mk for libmvec ABI tests.
2
3# Copyright (C) 2021-2022 Free Software Foundation, Inc.
4# This file is part of the GNU C Library.
5
6# The GNU C Library is free software; you can redistribute it and/or
7# modify it under the terms of the GNU Lesser General Public
8# License as published by the Free Software Foundation; either
9# version 2.1 of the License, or (at your option) any later version.
10
11# The GNU C Library is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14# Lesser General Public License for more details.
15
16# You should have received a copy of the GNU Lesser General Public
17# License along with the GNU C Library; if not, see
18# <https://www.gnu.org/licenses/>.
19
20-include $(common-objpfx)libmvec.mk
21postclean-generated += libmvec.mk
22
23# Define for both math and mathvec directories.
24libmvec-funcs = \
25  acos \
26  acosh \
27  asin \
28  asinh \
29  atan \
30  atan2 \
31  atanh \
32  cbrt \
33  cos \
34  cosh \
35  erf \
36  erfc \
37  exp \
38  exp10 \
39  exp2 \
40  expm1 \
41  hypot \
42  log \
43  log10 \
44  log1p \
45  log2 \
46  pow \
47  sin \
48  sincos \
49  sinh \
50  tan \
51  tanh \
52
53# Define libmvec function for benchtests directory.
54libmvec-bench-funcs = \
55  acos \
56  acosh \
57  asin \
58  asinh \
59  atan \
60  atan2 \
61  atanh \
62  cbrt \
63  cos \
64  cosh \
65  erf \
66  erfc \
67  exp \
68  exp10 \
69  exp2 \
70  expm1 \
71  hypot \
72  log \
73  log10 \
74  log1p \
75  log2 \
76  pow \
77  sin \
78  sinh \
79  tan \
80  tanh \
81
82bench-libmvec-double = \
83  $(addprefix double-vlen1-, $(libmvec-bench-funcs)) \
84  $(addprefix double-vlen2-, $(libmvec-bench-funcs)) \
85  $(addprefix double-vlen4-, $(libmvec-bench-funcs)) \
86  $(addprefix double-vlen4-avx2-, $(libmvec-bench-funcs)) \
87  $(addprefix double-vlen8-, $(libmvec-bench-funcs)) \
88
89bench-libmvec-float = \
90  $(addsuffix f, $(addprefix float-vlen1-, $(libmvec-bench-funcs))) \
91  $(addsuffix f, $(addprefix float-vlen4-, $(libmvec-bench-funcs))) \
92  $(addsuffix f, $(addprefix float-vlen8-, $(libmvec-bench-funcs))) \
93  $(addsuffix f, $(addprefix float-vlen8-avx2-, $(libmvec-bench-funcs))) \
94  $(addsuffix f, $(addprefix float-vlen16-, $(libmvec-bench-funcs))) \
95
96# The base libmvec ABI tests.
97libmvec-abi-func-tests = \
98  $(addprefix test-double-libmvec-,$(libmvec-funcs)) \
99  $(addsuffix f,$(addprefix test-float-libmvec-,$(libmvec-funcs)))
100
101# The AVX libmvec ABI tests.
102libmvec-abi-func-avx-tests = \
103  $(addsuffix -avx,$(libmvec-abi-func-tests))
104#
105# The AVX2 libmvec ABI tests.
106libmvec-abi-func-avx2-tests = \
107  $(addsuffix -avx2,$(libmvec-abi-func-tests))
108#
109# The AVX512F libmvec ABI tests.
110libmvec-abi-func-avx512f-tests = \
111  $(addsuffix -avx512f,$(libmvec-abi-func-tests))
112
113$(common-objpfx)libmvec.mk: $(common-objpfx)config.make
114	(echo "ifeq (\$$(subdir)\$$(build-mathvec),mathyes)"; \
115	 echo; \
116	 echo "extra-test-objs += \\"; \
117	 for i in "" "-avx" "-avx2" "-avx512f"; do \
118	   echo "  test-libmvec$$i.o \\"; \
119	 done; \
120	 echo "# extra-test-objs"; \
121	 echo; \
122	 for i in "" "-avx" "-avx2" "-avx512f"; do \
123	   for t in $(libmvec-abi-func-tests); do \
124	     echo "\$$(objpfx)$$t$$i: \\"; \
125	     echo "  \$$(objpfx)$$t$$i.o \\"; \
126	     echo "  \$$(objpfx)test-libmvec$$i.o \$$(libmvec)"; \
127	     echo; \
128	   done; \
129	 done; \
130	 for t in $(libmvec-funcs); do \
131	   echo "CFLAGS-test-double-libmvec-$$t.c = \\"; \
132	   echo "  \$$(libmvec-abi-test-cflags)"; \
133	   echo "CFLAGS-test-double-libmvec-$$t-avx.c = \\"; \
134	   echo "  \$$(libmvec-abi-test-cflags) \\"; \
135	   echo "  \$$(double-vlen4-arch-ext-cflags)"; \
136	   echo "CFLAGS-test-double-libmvec-$$t-avx2.c = \\"; \
137	   echo "  \$$(libmvec-abi-test-cflags) \\"; \
138	   echo "  \$$(double-vlen4-arch-ext2-cflags)"; \
139	   echo "CFLAGS-test-double-libmvec-$$t-avx512f.c = \\"; \
140	   echo "  \$$(libmvec-abi-test-cflags) \\"; \
141	   echo "  \$$(double-vlen8-arch-ext-cflags)"; \
142	   echo; \
143	   echo "CFLAGS-test-float-libmvec-$${t}f.c = \\"; \
144	   echo "  \$$(libmvec-abi-test-cflags)"; \
145	   echo "CFLAGS-test-float-libmvec-$${t}f-avx.c = \\"; \
146	   echo "  \$$(libmvec-abi-test-cflags) \\"; \
147	   echo "  \$$(float-vlen8-arch-ext-cflags)"; \
148	   echo "CFLAGS-test-float-libmvec-$${t}f-avx2.c = \\"; \
149	   echo "  \$$(libmvec-abi-test-cflags) \\"; \
150	   echo "  \$$(float-vlen8-arch-ext2-cflags)"; \
151	   echo "CFLAGS-test-float-libmvec-$${t}f-avx512f.c = \\"; \
152	   echo "  \$$(libmvec-abi-test-cflags) \\"; \
153	   echo "  \$$(float-vlen16-arch-ext-cflags)"; \
154	   echo; \
155	 done; \
156	 echo "endif"; \
157	 echo "ifeq (\$$(subdir),benchtests)"; \
158	 for t in $(libmvec-bench-funcs); do \
159	   echo "CFLAGS-bench-double-vlen4-$$t.c = \\"; \
160	   echo "  \$$(double-vlen4-arch-ext-cflags)"; \
161	   echo "CFLAGS-bench-double-vlen4-avx2-$$t.c = \\"; \
162	   echo "  \$$(double-vlen4-arch-ext2-cflags)"; \
163	   echo "CFLAGS-bench-double-vlen8-$$t.c = \\"; \
164	   echo "  \$$(double-vlen8-arch-ext-cflags)"; \
165	   echo; \
166	   echo "CFLAGS-bench-float-vlen8-$${t}f.c = \\"; \
167	   echo "  \$$(float-vlen8-arch-ext-cflags)"; \
168	   echo "CFLAGS-bench-float-vlen8-avx2-$${t}f.c = \\"; \
169	   echo "  \$$(float-vlen8-arch-ext2-cflags)"; \
170	   echo "CFLAGS-bench-float-vlen16-$${t}f.c = \\"; \
171	   echo "  \$$(float-vlen16-arch-ext-cflags)"; \
172	   echo; \
173	 done; \
174	 echo "endif") > $@T
175	mv -f $@T $@
176