FLANG
matmul-instances.inc
1//===-- include/flang/Runtime/matmul-instances.inc --------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8// Helper macros to instantiate MATMUL/MATMUL_TRANSPOSE definitions
9// for different data types of the input arguments.
10//===----------------------------------------------------------------------===//
11
12#ifndef MATMUL_INSTANCE
13#error "Define MATMUL_INSTANCE before including this file"
14#endif
15
16#ifndef MATMUL_DIRECT_INSTANCE
17#error "Define MATMUL_DIRECT_INSTANCE before including this file"
18#endif
19
20#ifndef MATMUL_FORCE_ALL_TYPES
21#error "Define MATMUL_FORCE_ALL_TYPES to 0 or 1 before including this file"
22#endif
23
24// clang-format off
25
26#define FOREACH_MATMUL_TYPE_PAIR(macro) \
27 macro(Integer, 1, Integer, 1) \
28 macro(Integer, 1, Integer, 2) \
29 macro(Integer, 1, Integer, 4) \
30 macro(Integer, 1, Integer, 8) \
31 macro(Integer, 2, Integer, 1) \
32 macro(Integer, 2, Integer, 2) \
33 macro(Integer, 2, Integer, 4) \
34 macro(Integer, 2, Integer, 8) \
35 macro(Integer, 4, Integer, 1) \
36 macro(Integer, 4, Integer, 2) \
37 macro(Integer, 4, Integer, 4) \
38 macro(Integer, 4, Integer, 8) \
39 macro(Integer, 8, Integer, 1) \
40 macro(Integer, 8, Integer, 2) \
41 macro(Integer, 8, Integer, 4) \
42 macro(Integer, 8, Integer, 8) \
43 macro(Integer, 1, Real, 4) \
44 macro(Integer, 1, Real, 8) \
45 macro(Integer, 2, Real, 4) \
46 macro(Integer, 2, Real, 8) \
47 macro(Integer, 4, Real, 4) \
48 macro(Integer, 4, Real, 8) \
49 macro(Integer, 8, Real, 4) \
50 macro(Integer, 8, Real, 8) \
51 macro(Integer, 1, Complex, 4) \
52 macro(Integer, 1, Complex, 8) \
53 macro(Integer, 2, Complex, 4) \
54 macro(Integer, 2, Complex, 8) \
55 macro(Integer, 4, Complex, 4) \
56 macro(Integer, 4, Complex, 8) \
57 macro(Integer, 8, Complex, 4) \
58 macro(Integer, 8, Complex, 8) \
59 macro(Unsigned, 1, Real, 4) \
60 macro(Unsigned, 1, Real, 8) \
61 macro(Unsigned, 2, Real, 4) \
62 macro(Unsigned, 2, Real, 8) \
63 macro(Unsigned, 4, Real, 4) \
64 macro(Unsigned, 4, Real, 8) \
65 macro(Unsigned, 8, Real, 4) \
66 macro(Unsigned, 8, Real, 8) \
67 macro(Unsigned, 1, Complex, 4) \
68 macro(Unsigned, 1, Complex, 8) \
69 macro(Unsigned, 2, Complex, 4) \
70 macro(Unsigned, 2, Complex, 8) \
71 macro(Unsigned, 4, Complex, 4) \
72 macro(Unsigned, 4, Complex, 8) \
73 macro(Unsigned, 8, Complex, 4) \
74 macro(Unsigned, 8, Complex, 8) \
75 macro(Real, 4, Integer, 1) \
76 macro(Real, 4, Integer, 2) \
77 macro(Real, 4, Integer, 4) \
78 macro(Real, 4, Integer, 8) \
79 macro(Real, 8, Integer, 1) \
80 macro(Real, 8, Integer, 2) \
81 macro(Real, 8, Integer, 4) \
82 macro(Real, 8, Integer, 8) \
83 macro(Real, 4, Unsigned, 1) \
84 macro(Real, 4, Unsigned, 2) \
85 macro(Real, 4, Unsigned, 4) \
86 macro(Real, 4, Unsigned, 8) \
87 macro(Real, 8, Unsigned, 1) \
88 macro(Real, 8, Unsigned, 2) \
89 macro(Real, 8, Unsigned, 4) \
90 macro(Real, 8, Unsigned, 8) \
91 macro(Real, 4, Real, 4) \
92 macro(Real, 4, Real, 8) \
93 macro(Real, 8, Real, 4) \
94 macro(Real, 8, Real, 8) \
95 macro(Real, 4, Complex, 4) \
96 macro(Real, 4, Complex, 8) \
97 macro(Real, 8, Complex, 4) \
98 macro(Real, 8, Complex, 8) \
99 macro(Complex, 4, Integer, 1) \
100 macro(Complex, 4, Integer, 2) \
101 macro(Complex, 4, Integer, 4) \
102 macro(Complex, 4, Integer, 8) \
103 macro(Complex, 8, Integer, 1) \
104 macro(Complex, 8, Integer, 2) \
105 macro(Complex, 8, Integer, 4) \
106 macro(Complex, 8, Integer, 8) \
107 macro(Complex, 4, Unsigned, 1) \
108 macro(Complex, 4, Unsigned, 2) \
109 macro(Complex, 4, Unsigned, 4) \
110 macro(Complex, 4, Unsigned, 8) \
111 macro(Complex, 8, Unsigned, 1) \
112 macro(Complex, 8, Unsigned, 2) \
113 macro(Complex, 8, Unsigned, 4) \
114 macro(Complex, 8, Unsigned, 8) \
115 macro(Complex, 4, Real, 4) \
116 macro(Complex, 4, Real, 8) \
117 macro(Complex, 8, Real, 4) \
118 macro(Complex, 8, Real, 8) \
119 macro(Complex, 4, Complex, 4) \
120 macro(Complex, 4, Complex, 8) \
121 macro(Complex, 8, Complex, 4) \
122 macro(Complex, 8, Complex, 8) \
123
124FOREACH_MATMUL_TYPE_PAIR(MATMUL_INSTANCE)
125FOREACH_MATMUL_TYPE_PAIR(MATMUL_DIRECT_INSTANCE)
126
127#if MATMUL_FORCE_ALL_TYPES || (defined __SIZEOF_INT128__ && !AVOID_NATIVE_UINT128_T)
128#define FOREACH_MATMUL_TYPE_PAIR_WITH_INT16(macro) \
129 macro(Integer, 16, Integer, 1) \
130 macro(Integer, 16, Integer, 2) \
131 macro(Integer, 16, Integer, 4) \
132 macro(Integer, 16, Integer, 8) \
133 macro(Integer, 16, Integer, 16) \
134 macro(Integer, 16, Real, 4) \
135 macro(Integer, 16, Real, 8) \
136 macro(Integer, 16, Complex, 4) \
137 macro(Integer, 16, Complex, 8) \
138 macro(Unsigned, 16, Real, 4) \
139 macro(Unsigned, 16, Real, 8) \
140 macro(Unsigned, 16, Complex, 4) \
141 macro(Unsigned, 16, Complex, 8) \
142 macro(Real, 4, Integer, 16) \
143 macro(Real, 8, Integer, 16) \
144 macro(Complex, 4, Integer, 16) \
145 macro(Complex, 8, Integer, 16) \
146 macro(Real, 4, Unsigned, 16) \
147 macro(Real, 8, Unsigned, 16) \
148 macro(Complex, 4, Unsigned, 16) \
149 macro(Complex, 8, Unsigned, 16) \
150
151FOREACH_MATMUL_TYPE_PAIR_WITH_INT16(MATMUL_INSTANCE)
152FOREACH_MATMUL_TYPE_PAIR_WITH_INT16(MATMUL_DIRECT_INSTANCE)
153
154#if MATMUL_FORCE_ALL_TYPES || HAS_FLOAT80
155MATMUL_INSTANCE(Integer, 16, Real, 10)
156MATMUL_INSTANCE(Integer, 16, Complex, 10)
157MATMUL_INSTANCE(Real, 10, Integer, 16)
158MATMUL_INSTANCE(Complex, 10, Integer, 16)
159MATMUL_INSTANCE(Unsigned, 16, Real, 10)
160MATMUL_INSTANCE(Unsigned, 16, Complex, 10)
161MATMUL_INSTANCE(Real, 10, Unsigned, 16)
162MATMUL_INSTANCE(Complex, 10, Unsigned, 16)
163MATMUL_DIRECT_INSTANCE(Integer, 16, Real, 10)
164MATMUL_DIRECT_INSTANCE(Integer, 16, Complex, 10)
165MATMUL_DIRECT_INSTANCE(Real, 10, Integer, 16)
166MATMUL_DIRECT_INSTANCE(Complex, 10, Integer, 16)
167MATMUL_DIRECT_INSTANCE(Unsigned, 16, Real, 10)
168MATMUL_DIRECT_INSTANCE(Unsigned, 16, Complex, 10)
169MATMUL_DIRECT_INSTANCE(Real, 10, Unsigned, 16)
170MATMUL_DIRECT_INSTANCE(Complex, 10, Unsigned, 16)
171#endif
172#if MATMUL_FORCE_ALL_TYPES || (HAS_LDBL128 || HAS_FLOAT128)
173MATMUL_INSTANCE(Integer, 16, Real, 16)
174MATMUL_INSTANCE(Integer, 16, Complex, 16)
175MATMUL_INSTANCE(Real, 16, Integer, 16)
176MATMUL_INSTANCE(Complex, 16, Integer, 16)
177MATMUL_INSTANCE(Unsigned, 16, Real, 16)
178MATMUL_INSTANCE(Unsigned, 16, Complex, 16)
179MATMUL_INSTANCE(Real, 16, Unsigned, 16)
180MATMUL_INSTANCE(Complex, 16, Unsigned, 16)
181MATMUL_DIRECT_INSTANCE(Integer, 16, Real, 16)
182MATMUL_DIRECT_INSTANCE(Integer, 16, Complex, 16)
183MATMUL_DIRECT_INSTANCE(Real, 16, Integer, 16)
184MATMUL_DIRECT_INSTANCE(Complex, 16, Integer, 16)
185MATMUL_DIRECT_INSTANCE(Unsigned, 16, Real, 16)
186MATMUL_DIRECT_INSTANCE(Unsigned, 16, Complex, 16)
187MATMUL_DIRECT_INSTANCE(Real, 16, Unsigned, 16)
188MATMUL_DIRECT_INSTANCE(Complex, 16, Unsigned, 16)
189#endif
190#endif // MATMUL_FORCE_ALL_TYPES || (defined __SIZEOF_INT128__ && !AVOID_NATIVE_UINT128_T)
191
192#if MATMUL_FORCE_ALL_TYPES || HAS_FLOAT80
193#define FOREACH_MATMUL_TYPE_PAIR_WITH_REAL10(macro) \
194 macro(Integer, 1, Real, 10) \
195 macro(Integer, 1, Complex, 10) \
196 macro(Integer, 2, Real, 10) \
197 macro(Integer, 2, Complex, 10) \
198 macro(Integer, 4, Real, 10) \
199 macro(Integer, 4, Complex, 10) \
200 macro(Integer, 8, Real, 10) \
201 macro(Integer, 8, Complex, 10) \
202 macro(Unsigned, 1, Real, 10) \
203 macro(Unsigned, 1, Complex, 10) \
204 macro(Unsigned, 2, Real, 10) \
205 macro(Unsigned, 2, Complex, 10) \
206 macro(Unsigned, 4, Real, 10) \
207 macro(Unsigned, 4, Complex, 10) \
208 macro(Unsigned, 8, Real, 10) \
209 macro(Unsigned, 8, Complex, 10) \
210 macro(Real, 4, Real, 10) \
211 macro(Real, 4, Complex, 10) \
212 macro(Real, 8, Real, 10) \
213 macro(Real, 8, Complex, 10) \
214 macro(Real, 10, Integer, 1) \
215 macro(Real, 10, Integer, 2) \
216 macro(Real, 10, Integer, 4) \
217 macro(Real, 10, Integer, 8) \
218 macro(Real, 10, Unsigned, 1) \
219 macro(Real, 10, Unsigned, 2) \
220 macro(Real, 10, Unsigned, 4) \
221 macro(Real, 10, Unsigned, 8) \
222 macro(Real, 10, Real, 4) \
223 macro(Real, 10, Real, 8) \
224 macro(Real, 10, Real, 10) \
225 macro(Real, 10, Complex, 4) \
226 macro(Real, 10, Complex, 8) \
227 macro(Real, 10, Complex, 10) \
228 macro(Complex, 4, Real, 10) \
229 macro(Complex, 4, Complex, 10) \
230 macro(Complex, 8, Real, 10) \
231 macro(Complex, 8, Complex, 10) \
232 macro(Complex, 10, Integer, 1) \
233 macro(Complex, 10, Integer, 2) \
234 macro(Complex, 10, Integer, 4) \
235 macro(Complex, 10, Integer, 8) \
236 macro(Complex, 10, Unsigned, 1) \
237 macro(Complex, 10, Unsigned, 2) \
238 macro(Complex, 10, Unsigned, 4) \
239 macro(Complex, 10, Unsigned, 8) \
240 macro(Complex, 10, Real, 4) \
241 macro(Complex, 10, Real, 8) \
242 macro(Complex, 10, Real, 10) \
243 macro(Complex, 10, Complex, 4) \
244 macro(Complex, 10, Complex, 8) \
245 macro(Complex, 10, Complex, 10) \
246
247FOREACH_MATMUL_TYPE_PAIR_WITH_REAL10(MATMUL_INSTANCE)
248FOREACH_MATMUL_TYPE_PAIR_WITH_REAL10(MATMUL_DIRECT_INSTANCE)
249
250#if MATMUL_FORCE_ALL_TYPES || HAS_FLOAT128
251MATMUL_INSTANCE(Real, 10, Real, 16)
252MATMUL_INSTANCE(Real, 10, Complex, 16)
253MATMUL_INSTANCE(Real, 16, Real, 10)
254MATMUL_INSTANCE(Real, 16, Complex, 10)
255MATMUL_INSTANCE(Complex, 10, Real, 16)
256MATMUL_INSTANCE(Complex, 10, Complex, 16)
257MATMUL_INSTANCE(Complex, 16, Real, 10)
258MATMUL_INSTANCE(Complex, 16, Complex, 10)
259MATMUL_DIRECT_INSTANCE(Real, 10, Real, 16)
260MATMUL_DIRECT_INSTANCE(Real, 10, Complex, 16)
261MATMUL_DIRECT_INSTANCE(Real, 16, Real, 10)
262MATMUL_DIRECT_INSTANCE(Real, 16, Complex, 10)
263MATMUL_DIRECT_INSTANCE(Complex, 10, Real, 16)
264MATMUL_DIRECT_INSTANCE(Complex, 10, Complex, 16)
265MATMUL_DIRECT_INSTANCE(Complex, 16, Real, 10)
266MATMUL_DIRECT_INSTANCE(Complex, 16, Complex, 10)
267#endif
268#endif // MATMUL_FORCE_ALL_TYPES || HAS_FLOAT80
269
270#if MATMUL_FORCE_ALL_TYPES || (HAS_LDBL128 || HAS_FLOAT128)
271#define FOREACH_MATMUL_TYPE_PAIR_WITH_REAL16(macro) \
272 macro(Integer, 1, Real, 16) \
273 macro(Integer, 1, Complex, 16) \
274 macro(Integer, 2, Real, 16) \
275 macro(Integer, 2, Complex, 16) \
276 macro(Integer, 4, Real, 16) \
277 macro(Integer, 4, Complex, 16) \
278 macro(Integer, 8, Real, 16) \
279 macro(Integer, 8, Complex, 16) \
280 macro(Real, 4, Real, 16) \
281 macro(Real, 4, Complex, 16) \
282 macro(Real, 8, Real, 16) \
283 macro(Real, 8, Complex, 16) \
284 macro(Real, 16, Integer, 1) \
285 macro(Real, 16, Integer, 2) \
286 macro(Real, 16, Integer, 4) \
287 macro(Real, 16, Integer, 8) \
288 macro(Real, 16, Real, 4) \
289 macro(Real, 16, Real, 8) \
290 macro(Real, 16, Real, 16) \
291 macro(Real, 16, Complex, 4) \
292 macro(Real, 16, Complex, 8) \
293 macro(Real, 16, Complex, 16) \
294 macro(Complex, 4, Real, 16) \
295 macro(Complex, 4, Complex, 16) \
296 macro(Complex, 8, Real, 16) \
297 macro(Complex, 8, Complex, 16) \
298 macro(Complex, 16, Integer, 1) \
299 macro(Complex, 16, Integer, 2) \
300 macro(Complex, 16, Integer, 4) \
301 macro(Complex, 16, Integer, 8) \
302 macro(Complex, 16, Real, 4) \
303 macro(Complex, 16, Real, 8) \
304 macro(Complex, 16, Real, 16) \
305 macro(Complex, 16, Complex, 4) \
306 macro(Complex, 16, Complex, 8) \
307 macro(Complex, 16, Complex, 16) \
308
309FOREACH_MATMUL_TYPE_PAIR_WITH_REAL16(MATMUL_INSTANCE)
310FOREACH_MATMUL_TYPE_PAIR_WITH_REAL16(MATMUL_DIRECT_INSTANCE)
311#endif // MATMUL_FORCE_ALL_TYPES || (HAS_LDBL128 || HAS_FLOAT128)
312
313#define FOREACH_MATMUL_LOGICAL_TYPE_PAIR(macro) \
314 macro(Logical, 1, Logical, 1) \
315 macro(Logical, 1, Logical, 2) \
316 macro(Logical, 1, Logical, 4) \
317 macro(Logical, 1, Logical, 8) \
318 macro(Logical, 2, Logical, 1) \
319 macro(Logical, 2, Logical, 2) \
320 macro(Logical, 2, Logical, 4) \
321 macro(Logical, 2, Logical, 8) \
322 macro(Logical, 4, Logical, 1) \
323 macro(Logical, 4, Logical, 2) \
324 macro(Logical, 4, Logical, 4) \
325 macro(Logical, 4, Logical, 8) \
326 macro(Logical, 8, Logical, 1) \
327 macro(Logical, 8, Logical, 2) \
328 macro(Logical, 8, Logical, 4) \
329 macro(Logical, 8, Logical, 8) \
330
331FOREACH_MATMUL_LOGICAL_TYPE_PAIR(MATMUL_INSTANCE)
332FOREACH_MATMUL_LOGICAL_TYPE_PAIR(MATMUL_DIRECT_INSTANCE)
333
334#undef MATMUL_INSTANCE
335#undef MATMUL_DIRECT_INSTANCE
336#undef MATMUL_FORCE_ALL_TYPES
337
338// clang-format on