1 | //===-- mlir-c/BuiltinTypes.h - C API for MLIR Builtin types ------*- C -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM |
4 | // Exceptions. |
5 | // See https://llvm.org/LICENSE.txt for license information. |
6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
7 | // |
8 | //===----------------------------------------------------------------------===// |
9 | |
10 | #ifndef MLIR_C_BUILTINTYPES_H |
11 | #define MLIR_C_BUILTINTYPES_H |
12 | |
13 | #include "mlir-c/AffineMap.h" |
14 | #include "mlir-c/IR.h" |
15 | #include <stdint.h> |
16 | |
17 | #ifdef __cplusplus |
18 | extern "C" { |
19 | #endif |
20 | |
21 | //===----------------------------------------------------------------------===// |
22 | // Integer types. |
23 | //===----------------------------------------------------------------------===// |
24 | |
25 | /// Returns the typeID of an Integer type. |
26 | MLIR_CAPI_EXPORTED MlirTypeID mlirIntegerTypeGetTypeID(void); |
27 | |
28 | /// Checks whether the given type is an integer type. |
29 | MLIR_CAPI_EXPORTED bool mlirTypeIsAInteger(MlirType type); |
30 | |
31 | /// Creates a signless integer type of the given bitwidth in the context. The |
32 | /// type is owned by the context. |
33 | MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeGet(MlirContext ctx, |
34 | unsigned bitwidth); |
35 | |
36 | /// Creates a signed integer type of the given bitwidth in the context. The type |
37 | /// is owned by the context. |
38 | MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeSignedGet(MlirContext ctx, |
39 | unsigned bitwidth); |
40 | |
41 | /// Creates an unsigned integer type of the given bitwidth in the context. The |
42 | /// type is owned by the context. |
43 | MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeUnsignedGet(MlirContext ctx, |
44 | unsigned bitwidth); |
45 | |
46 | /// Returns the bitwidth of an integer type. |
47 | MLIR_CAPI_EXPORTED unsigned mlirIntegerTypeGetWidth(MlirType type); |
48 | |
49 | /// Checks whether the given integer type is signless. |
50 | MLIR_CAPI_EXPORTED bool mlirIntegerTypeIsSignless(MlirType type); |
51 | |
52 | /// Checks whether the given integer type is signed. |
53 | MLIR_CAPI_EXPORTED bool mlirIntegerTypeIsSigned(MlirType type); |
54 | |
55 | /// Checks whether the given integer type is unsigned. |
56 | MLIR_CAPI_EXPORTED bool mlirIntegerTypeIsUnsigned(MlirType type); |
57 | |
58 | //===----------------------------------------------------------------------===// |
59 | // Index type. |
60 | //===----------------------------------------------------------------------===// |
61 | |
62 | /// Returns the typeID of an Index type. |
63 | MLIR_CAPI_EXPORTED MlirTypeID mlirIndexTypeGetTypeID(void); |
64 | |
65 | /// Checks whether the given type is an index type. |
66 | MLIR_CAPI_EXPORTED bool mlirTypeIsAIndex(MlirType type); |
67 | |
68 | /// Creates an index type in the given context. The type is owned by the |
69 | /// context. |
70 | MLIR_CAPI_EXPORTED MlirType mlirIndexTypeGet(MlirContext ctx); |
71 | |
72 | //===----------------------------------------------------------------------===// |
73 | // Floating-point types. |
74 | //===----------------------------------------------------------------------===// |
75 | |
76 | /// Checks whether the given type is a floating-point type. |
77 | MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat(MlirType type); |
78 | |
79 | /// Returns the bitwidth of a floating-point type. |
80 | MLIR_CAPI_EXPORTED unsigned mlirFloatTypeGetWidth(MlirType type); |
81 | |
82 | /// Returns the typeID of an Float8E5M2 type. |
83 | MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E5M2TypeGetTypeID(void); |
84 | |
85 | /// Checks whether the given type is an f8E5M2 type. |
86 | MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E5M2(MlirType type); |
87 | |
88 | /// Creates an f8E5M2 type in the given context. The type is owned by the |
89 | /// context. |
90 | MLIR_CAPI_EXPORTED MlirType mlirFloat8E5M2TypeGet(MlirContext ctx); |
91 | |
92 | /// Returns the typeID of an Float8E4M3FN type. |
93 | MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E4M3FNTypeGetTypeID(void); |
94 | |
95 | /// Checks whether the given type is an f8E4M3FN type. |
96 | MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E4M3FN(MlirType type); |
97 | |
98 | /// Creates an f8E4M3FN type in the given context. The type is owned by the |
99 | /// context. |
100 | MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3FNTypeGet(MlirContext ctx); |
101 | |
102 | /// Returns the typeID of an Float8E5M2FNUZ type. |
103 | MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E5M2FNUZTypeGetTypeID(void); |
104 | |
105 | /// Checks whether the given type is an f8E5M2FNUZ type. |
106 | MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E5M2FNUZ(MlirType type); |
107 | |
108 | /// Creates an f8E5M2FNUZ type in the given context. The type is owned by the |
109 | /// context. |
110 | MLIR_CAPI_EXPORTED MlirType mlirFloat8E5M2FNUZTypeGet(MlirContext ctx); |
111 | |
112 | /// Returns the typeID of an Float8E4M3FNUZ type. |
113 | MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E4M3FNUZTypeGetTypeID(void); |
114 | |
115 | /// Checks whether the given type is an f8E4M3FNUZ type. |
116 | MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E4M3FNUZ(MlirType type); |
117 | |
118 | /// Creates an f8E4M3FNUZ type in the given context. The type is owned by the |
119 | /// context. |
120 | MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3FNUZTypeGet(MlirContext ctx); |
121 | |
122 | /// Returns the typeID of an Float8E4M3B11FNUZ type. |
123 | MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E4M3B11FNUZTypeGetTypeID(void); |
124 | |
125 | /// Checks whether the given type is an f8E4M3B11FNUZ type. |
126 | MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E4M3B11FNUZ(MlirType type); |
127 | |
128 | /// Creates an f8E4M3B11FNUZ type in the given context. The type is owned by the |
129 | /// context. |
130 | MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3B11FNUZTypeGet(MlirContext ctx); |
131 | |
132 | /// Returns the typeID of an BFloat16 type. |
133 | MLIR_CAPI_EXPORTED MlirTypeID mlirBFloat16TypeGetTypeID(void); |
134 | |
135 | /// Checks whether the given type is a bf16 type. |
136 | MLIR_CAPI_EXPORTED bool mlirTypeIsABF16(MlirType type); |
137 | |
138 | /// Creates a bf16 type in the given context. The type is owned by the |
139 | /// context. |
140 | MLIR_CAPI_EXPORTED MlirType mlirBF16TypeGet(MlirContext ctx); |
141 | |
142 | /// Returns the typeID of an Float16 type. |
143 | MLIR_CAPI_EXPORTED MlirTypeID mlirFloat16TypeGetTypeID(void); |
144 | |
145 | /// Checks whether the given type is an f16 type. |
146 | MLIR_CAPI_EXPORTED bool mlirTypeIsAF16(MlirType type); |
147 | |
148 | /// Creates an f16 type in the given context. The type is owned by the |
149 | /// context. |
150 | MLIR_CAPI_EXPORTED MlirType mlirF16TypeGet(MlirContext ctx); |
151 | |
152 | /// Returns the typeID of an Float32 type. |
153 | MLIR_CAPI_EXPORTED MlirTypeID mlirFloat32TypeGetTypeID(void); |
154 | |
155 | /// Checks whether the given type is an f32 type. |
156 | MLIR_CAPI_EXPORTED bool mlirTypeIsAF32(MlirType type); |
157 | |
158 | /// Creates an f32 type in the given context. The type is owned by the |
159 | /// context. |
160 | MLIR_CAPI_EXPORTED MlirType mlirF32TypeGet(MlirContext ctx); |
161 | |
162 | /// Returns the typeID of an Float64 type. |
163 | MLIR_CAPI_EXPORTED MlirTypeID mlirFloat64TypeGetTypeID(void); |
164 | |
165 | /// Checks whether the given type is an f64 type. |
166 | MLIR_CAPI_EXPORTED bool mlirTypeIsAF64(MlirType type); |
167 | |
168 | /// Creates a f64 type in the given context. The type is owned by the |
169 | /// context. |
170 | MLIR_CAPI_EXPORTED MlirType mlirF64TypeGet(MlirContext ctx); |
171 | |
172 | /// Returns the typeID of a TF32 type. |
173 | MLIR_CAPI_EXPORTED MlirTypeID mlirFloatTF32TypeGetTypeID(void); |
174 | |
175 | /// Checks whether the given type is an TF32 type. |
176 | MLIR_CAPI_EXPORTED bool mlirTypeIsATF32(MlirType type); |
177 | |
178 | /// Creates a TF32 type in the given context. The type is owned by the |
179 | /// context. |
180 | MLIR_CAPI_EXPORTED MlirType mlirTF32TypeGet(MlirContext ctx); |
181 | |
182 | //===----------------------------------------------------------------------===// |
183 | // None type. |
184 | //===----------------------------------------------------------------------===// |
185 | |
186 | /// Returns the typeID of an None type. |
187 | MLIR_CAPI_EXPORTED MlirTypeID mlirNoneTypeGetTypeID(void); |
188 | |
189 | /// Checks whether the given type is a None type. |
190 | MLIR_CAPI_EXPORTED bool mlirTypeIsANone(MlirType type); |
191 | |
192 | /// Creates a None type in the given context. The type is owned by the |
193 | /// context. |
194 | MLIR_CAPI_EXPORTED MlirType mlirNoneTypeGet(MlirContext ctx); |
195 | |
196 | //===----------------------------------------------------------------------===// |
197 | // Complex type. |
198 | //===----------------------------------------------------------------------===// |
199 | |
200 | /// Returns the typeID of an Complex type. |
201 | MLIR_CAPI_EXPORTED MlirTypeID mlirComplexTypeGetTypeID(void); |
202 | |
203 | /// Checks whether the given type is a Complex type. |
204 | MLIR_CAPI_EXPORTED bool mlirTypeIsAComplex(MlirType type); |
205 | |
206 | /// Creates a complex type with the given element type in the same context as |
207 | /// the element type. The type is owned by the context. |
208 | MLIR_CAPI_EXPORTED MlirType mlirComplexTypeGet(MlirType elementType); |
209 | |
210 | /// Returns the element type of the given complex type. |
211 | MLIR_CAPI_EXPORTED MlirType mlirComplexTypeGetElementType(MlirType type); |
212 | |
213 | //===----------------------------------------------------------------------===// |
214 | // Shaped type. |
215 | //===----------------------------------------------------------------------===// |
216 | |
217 | /// Checks whether the given type is a Shaped type. |
218 | MLIR_CAPI_EXPORTED bool mlirTypeIsAShaped(MlirType type); |
219 | |
220 | /// Returns the element type of the shaped type. |
221 | MLIR_CAPI_EXPORTED MlirType mlirShapedTypeGetElementType(MlirType type); |
222 | |
223 | /// Checks whether the given shaped type is ranked. |
224 | MLIR_CAPI_EXPORTED bool mlirShapedTypeHasRank(MlirType type); |
225 | |
226 | /// Returns the rank of the given ranked shaped type. |
227 | MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetRank(MlirType type); |
228 | |
229 | /// Checks whether the given shaped type has a static shape. |
230 | MLIR_CAPI_EXPORTED bool mlirShapedTypeHasStaticShape(MlirType type); |
231 | |
232 | /// Checks wither the dim-th dimension of the given shaped type is dynamic. |
233 | MLIR_CAPI_EXPORTED bool mlirShapedTypeIsDynamicDim(MlirType type, intptr_t dim); |
234 | |
235 | /// Returns the dim-th dimension of the given ranked shaped type. |
236 | MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDimSize(MlirType type, |
237 | intptr_t dim); |
238 | |
239 | /// Checks whether the given value is used as a placeholder for dynamic sizes |
240 | /// in shaped types. |
241 | MLIR_CAPI_EXPORTED bool mlirShapedTypeIsDynamicSize(int64_t size); |
242 | |
243 | /// Returns the value indicating a dynamic size in a shaped type. Prefer |
244 | /// mlirShapedTypeIsDynamicSize to direct comparisons with this value. |
245 | MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDynamicSize(void); |
246 | |
247 | /// Checks whether the given value is used as a placeholder for dynamic strides |
248 | /// and offsets in shaped types. |
249 | MLIR_CAPI_EXPORTED bool mlirShapedTypeIsDynamicStrideOrOffset(int64_t val); |
250 | |
251 | /// Returns the value indicating a dynamic stride or offset in a shaped type. |
252 | /// Prefer mlirShapedTypeGetDynamicStrideOrOffset to direct comparisons with |
253 | /// this value. |
254 | MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDynamicStrideOrOffset(void); |
255 | |
256 | //===----------------------------------------------------------------------===// |
257 | // Vector type. |
258 | //===----------------------------------------------------------------------===// |
259 | |
260 | /// Returns the typeID of an Vector type. |
261 | MLIR_CAPI_EXPORTED MlirTypeID mlirVectorTypeGetTypeID(void); |
262 | |
263 | /// Checks whether the given type is a Vector type. |
264 | MLIR_CAPI_EXPORTED bool mlirTypeIsAVector(MlirType type); |
265 | |
266 | /// Creates a vector type of the shape identified by its rank and dimensions, |
267 | /// with the given element type in the same context as the element type. The |
268 | /// type is owned by the context. |
269 | MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGet(intptr_t rank, |
270 | const int64_t *shape, |
271 | MlirType elementType); |
272 | |
273 | /// Same as "mlirVectorTypeGet" but returns a nullptr wrapping MlirType on |
274 | /// illegal arguments, emitting appropriate diagnostics. |
275 | MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGetChecked(MlirLocation loc, |
276 | intptr_t rank, |
277 | const int64_t *shape, |
278 | MlirType elementType); |
279 | |
280 | /// Creates a scalable vector type with the shape identified by its rank and |
281 | /// dimensions. A subset of dimensions may be marked as scalable via the |
282 | /// corresponding flag list, which is expected to have as many entries as the |
283 | /// rank of the vector. The vector is created in the same context as the element |
284 | /// type. |
285 | MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGetScalable(intptr_t rank, |
286 | const int64_t *shape, |
287 | const bool *scalable, |
288 | MlirType elementType); |
289 | |
290 | /// Same as "mlirVectorTypeGetScalable" but returns a nullptr wrapping MlirType |
291 | /// on illegal arguments, emitting appropriate diagnostics. |
292 | MLIR_CAPI_EXPORTED |
293 | MlirType mlirVectorTypeGetScalableChecked(MlirLocation loc, intptr_t rank, |
294 | const int64_t *shape, |
295 | const bool *scalable, |
296 | MlirType elementType); |
297 | |
298 | /// Checks whether the given vector type is scalable, i.e., has at least one |
299 | /// scalable dimension. |
300 | MLIR_CAPI_EXPORTED bool mlirVectorTypeIsScalable(MlirType type); |
301 | |
302 | /// Checks whether the "dim"-th dimension of the given vector is scalable. |
303 | MLIR_CAPI_EXPORTED bool mlirVectorTypeIsDimScalable(MlirType type, |
304 | intptr_t dim); |
305 | |
306 | //===----------------------------------------------------------------------===// |
307 | // Ranked / Unranked Tensor type. |
308 | //===----------------------------------------------------------------------===// |
309 | |
310 | /// Checks whether the given type is a Tensor type. |
311 | MLIR_CAPI_EXPORTED bool mlirTypeIsATensor(MlirType type); |
312 | |
313 | /// Returns the typeID of an RankedTensor type. |
314 | MLIR_CAPI_EXPORTED MlirTypeID mlirRankedTensorTypeGetTypeID(void); |
315 | |
316 | /// Checks whether the given type is a ranked tensor type. |
317 | MLIR_CAPI_EXPORTED bool mlirTypeIsARankedTensor(MlirType type); |
318 | |
319 | /// Returns the typeID of an UnrankedTensor type. |
320 | MLIR_CAPI_EXPORTED MlirTypeID mlirUnrankedTensorTypeGetTypeID(void); |
321 | |
322 | /// Checks whether the given type is an unranked tensor type. |
323 | MLIR_CAPI_EXPORTED bool mlirTypeIsAUnrankedTensor(MlirType type); |
324 | |
325 | /// Creates a tensor type of a fixed rank with the given shape, element type, |
326 | /// and optional encoding in the same context as the element type. The type is |
327 | /// owned by the context. Tensor types without any specific encoding field |
328 | /// should assign mlirAttributeGetNull() to this parameter. |
329 | MLIR_CAPI_EXPORTED MlirType mlirRankedTensorTypeGet(intptr_t rank, |
330 | const int64_t *shape, |
331 | MlirType elementType, |
332 | MlirAttribute encoding); |
333 | |
334 | /// Same as "mlirRankedTensorTypeGet" but returns a nullptr wrapping MlirType on |
335 | /// illegal arguments, emitting appropriate diagnostics. |
336 | MLIR_CAPI_EXPORTED MlirType mlirRankedTensorTypeGetChecked( |
337 | MlirLocation loc, intptr_t rank, const int64_t *shape, MlirType elementType, |
338 | MlirAttribute encoding); |
339 | |
340 | /// Gets the 'encoding' attribute from the ranked tensor type, returning a null |
341 | /// attribute if none. |
342 | MLIR_CAPI_EXPORTED MlirAttribute mlirRankedTensorTypeGetEncoding(MlirType type); |
343 | |
344 | /// Creates an unranked tensor type with the given element type in the same |
345 | /// context as the element type. The type is owned by the context. |
346 | MLIR_CAPI_EXPORTED MlirType mlirUnrankedTensorTypeGet(MlirType elementType); |
347 | |
348 | /// Same as "mlirUnrankedTensorTypeGet" but returns a nullptr wrapping MlirType |
349 | /// on illegal arguments, emitting appropriate diagnostics. |
350 | MLIR_CAPI_EXPORTED MlirType |
351 | mlirUnrankedTensorTypeGetChecked(MlirLocation loc, MlirType elementType); |
352 | |
353 | //===----------------------------------------------------------------------===// |
354 | // Ranked / Unranked MemRef type. |
355 | //===----------------------------------------------------------------------===// |
356 | |
357 | /// Returns the typeID of an MemRef type. |
358 | MLIR_CAPI_EXPORTED MlirTypeID mlirMemRefTypeGetTypeID(void); |
359 | |
360 | /// Checks whether the given type is a MemRef type. |
361 | MLIR_CAPI_EXPORTED bool mlirTypeIsAMemRef(MlirType type); |
362 | |
363 | /// Returns the typeID of an UnrankedMemRef type. |
364 | MLIR_CAPI_EXPORTED MlirTypeID mlirUnrankedMemRefTypeGetTypeID(void); |
365 | |
366 | /// Checks whether the given type is an UnrankedMemRef type. |
367 | MLIR_CAPI_EXPORTED bool mlirTypeIsAUnrankedMemRef(MlirType type); |
368 | |
369 | /// Creates a MemRef type with the given rank and shape, a potentially empty |
370 | /// list of affine layout maps, the given memory space and element type, in the |
371 | /// same context as element type. The type is owned by the context. |
372 | MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGet(MlirType elementType, |
373 | intptr_t rank, |
374 | const int64_t *shape, |
375 | MlirAttribute layout, |
376 | MlirAttribute memorySpace); |
377 | |
378 | /// Same as "mlirMemRefTypeGet" but returns a nullptr-wrapping MlirType o |
379 | /// illegal arguments, emitting appropriate diagnostics. |
380 | MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGetChecked( |
381 | MlirLocation loc, MlirType elementType, intptr_t rank, const int64_t *shape, |
382 | MlirAttribute layout, MlirAttribute memorySpace); |
383 | |
384 | /// Creates a MemRef type with the given rank, shape, memory space and element |
385 | /// type in the same context as the element type. The type has no affine maps, |
386 | /// i.e. represents a default row-major contiguous memref. The type is owned by |
387 | /// the context. |
388 | MLIR_CAPI_EXPORTED MlirType |
389 | mlirMemRefTypeContiguousGet(MlirType elementType, intptr_t rank, |
390 | const int64_t *shape, MlirAttribute memorySpace); |
391 | |
392 | /// Same as "mlirMemRefTypeContiguousGet" but returns a nullptr wrapping |
393 | /// MlirType on illegal arguments, emitting appropriate diagnostics. |
394 | MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeContiguousGetChecked( |
395 | MlirLocation loc, MlirType elementType, intptr_t rank, const int64_t *shape, |
396 | MlirAttribute memorySpace); |
397 | |
398 | /// Creates an Unranked MemRef type with the given element type and in the given |
399 | /// memory space. The type is owned by the context of element type. |
400 | MLIR_CAPI_EXPORTED MlirType |
401 | mlirUnrankedMemRefTypeGet(MlirType elementType, MlirAttribute memorySpace); |
402 | |
403 | /// Same as "mlirUnrankedMemRefTypeGet" but returns a nullptr wrapping |
404 | /// MlirType on illegal arguments, emitting appropriate diagnostics. |
405 | MLIR_CAPI_EXPORTED MlirType mlirUnrankedMemRefTypeGetChecked( |
406 | MlirLocation loc, MlirType elementType, MlirAttribute memorySpace); |
407 | |
408 | /// Returns the layout of the given MemRef type. |
409 | MLIR_CAPI_EXPORTED MlirAttribute mlirMemRefTypeGetLayout(MlirType type); |
410 | |
411 | /// Returns the affine map of the given MemRef type. |
412 | MLIR_CAPI_EXPORTED MlirAffineMap mlirMemRefTypeGetAffineMap(MlirType type); |
413 | |
414 | /// Returns the memory space of the given MemRef type. |
415 | MLIR_CAPI_EXPORTED MlirAttribute mlirMemRefTypeGetMemorySpace(MlirType type); |
416 | |
417 | /// Returns the strides of the MemRef if the layout map is in strided form. |
418 | /// Both strides and offset are out params. strides must point to pre-allocated |
419 | /// memory of length equal to the rank of the memref. |
420 | MLIR_CAPI_EXPORTED MlirLogicalResult mlirMemRefTypeGetStridesAndOffset( |
421 | MlirType type, int64_t *strides, int64_t *offset); |
422 | |
423 | /// Returns the memory spcae of the given Unranked MemRef type. |
424 | MLIR_CAPI_EXPORTED MlirAttribute |
425 | mlirUnrankedMemrefGetMemorySpace(MlirType type); |
426 | |
427 | //===----------------------------------------------------------------------===// |
428 | // Tuple type. |
429 | //===----------------------------------------------------------------------===// |
430 | |
431 | /// Returns the typeID of an Tuple type. |
432 | MLIR_CAPI_EXPORTED MlirTypeID mlirTupleTypeGetTypeID(void); |
433 | |
434 | /// Checks whether the given type is a tuple type. |
435 | MLIR_CAPI_EXPORTED bool mlirTypeIsATuple(MlirType type); |
436 | |
437 | /// Creates a tuple type that consists of the given list of elemental types. The |
438 | /// type is owned by the context. |
439 | MLIR_CAPI_EXPORTED MlirType mlirTupleTypeGet(MlirContext ctx, |
440 | intptr_t numElements, |
441 | MlirType const *elements); |
442 | |
443 | /// Returns the number of types contained in a tuple. |
444 | MLIR_CAPI_EXPORTED intptr_t mlirTupleTypeGetNumTypes(MlirType type); |
445 | |
446 | /// Returns the pos-th type in the tuple type. |
447 | MLIR_CAPI_EXPORTED MlirType mlirTupleTypeGetType(MlirType type, intptr_t pos); |
448 | |
449 | //===----------------------------------------------------------------------===// |
450 | // Function type. |
451 | //===----------------------------------------------------------------------===// |
452 | |
453 | /// Returns the typeID of an Function type. |
454 | MLIR_CAPI_EXPORTED MlirTypeID mlirFunctionTypeGetTypeID(void); |
455 | |
456 | /// Checks whether the given type is a function type. |
457 | MLIR_CAPI_EXPORTED bool mlirTypeIsAFunction(MlirType type); |
458 | |
459 | /// Creates a function type, mapping a list of input types to result types. |
460 | MLIR_CAPI_EXPORTED MlirType mlirFunctionTypeGet(MlirContext ctx, |
461 | intptr_t numInputs, |
462 | MlirType const *inputs, |
463 | intptr_t numResults, |
464 | MlirType const *results); |
465 | |
466 | /// Returns the number of input types. |
467 | MLIR_CAPI_EXPORTED intptr_t mlirFunctionTypeGetNumInputs(MlirType type); |
468 | |
469 | /// Returns the number of result types. |
470 | MLIR_CAPI_EXPORTED intptr_t mlirFunctionTypeGetNumResults(MlirType type); |
471 | |
472 | /// Returns the pos-th input type. |
473 | MLIR_CAPI_EXPORTED MlirType mlirFunctionTypeGetInput(MlirType type, |
474 | intptr_t pos); |
475 | |
476 | /// Returns the pos-th result type. |
477 | MLIR_CAPI_EXPORTED MlirType mlirFunctionTypeGetResult(MlirType type, |
478 | intptr_t pos); |
479 | |
480 | //===----------------------------------------------------------------------===// |
481 | // Opaque type. |
482 | //===----------------------------------------------------------------------===// |
483 | |
484 | /// Returns the typeID of an Opaque type. |
485 | MLIR_CAPI_EXPORTED MlirTypeID mlirOpaqueTypeGetTypeID(void); |
486 | |
487 | /// Checks whether the given type is an opaque type. |
488 | MLIR_CAPI_EXPORTED bool mlirTypeIsAOpaque(MlirType type); |
489 | |
490 | /// Creates an opaque type in the given context associated with the dialect |
491 | /// identified by its namespace. The type contains opaque byte data of the |
492 | /// specified length (data need not be null-terminated). |
493 | MLIR_CAPI_EXPORTED MlirType mlirOpaqueTypeGet(MlirContext ctx, |
494 | MlirStringRef dialectNamespace, |
495 | MlirStringRef typeData); |
496 | |
497 | /// Returns the namespace of the dialect with which the given opaque type |
498 | /// is associated. The namespace string is owned by the context. |
499 | MLIR_CAPI_EXPORTED MlirStringRef |
500 | mlirOpaqueTypeGetDialectNamespace(MlirType type); |
501 | |
502 | /// Returns the raw data as a string reference. The data remains live as long as |
503 | /// the context in which the type lives. |
504 | MLIR_CAPI_EXPORTED MlirStringRef mlirOpaqueTypeGetData(MlirType type); |
505 | |
506 | #ifdef __cplusplus |
507 | } |
508 | #endif |
509 | |
510 | #endif // MLIR_C_BUILTINTYPES_H |
511 | |