xref: /llvm-project/mlir/include/mlir-c/BuiltinTypes.h (revision 3f9cabae0029bcbe88835aaa4c417ce41e584fb1)
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 Float4E2M1FN type.
83 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat4E2M1FNTypeGetTypeID(void);
84 
85 /// Checks whether the given type is an f4E2M1FN type.
86 MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat4E2M1FN(MlirType type);
87 
88 /// Creates an f4E2M1FN type in the given context. The type is owned by the
89 /// context.
90 MLIR_CAPI_EXPORTED MlirType mlirFloat4E2M1FNTypeGet(MlirContext ctx);
91 
92 /// Returns the typeID of an Float6E2M3FN type.
93 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat6E2M3FNTypeGetTypeID(void);
94 
95 /// Checks whether the given type is an f6E2M3FN type.
96 MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat6E2M3FN(MlirType type);
97 
98 /// Creates an f6E2M3FN type in the given context. The type is owned by the
99 /// context.
100 MLIR_CAPI_EXPORTED MlirType mlirFloat6E2M3FNTypeGet(MlirContext ctx);
101 
102 /// Returns the typeID of an Float6E3M2FN type.
103 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat6E3M2FNTypeGetTypeID(void);
104 
105 /// Checks whether the given type is an f6E3M2FN type.
106 MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat6E3M2FN(MlirType type);
107 
108 /// Creates an f6E3M2FN type in the given context. The type is owned by the
109 /// context.
110 MLIR_CAPI_EXPORTED MlirType mlirFloat6E3M2FNTypeGet(MlirContext ctx);
111 
112 /// Returns the typeID of an Float8E5M2 type.
113 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E5M2TypeGetTypeID(void);
114 
115 /// Checks whether the given type is an f8E5M2 type.
116 MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E5M2(MlirType type);
117 
118 /// Creates an f8E5M2 type in the given context. The type is owned by the
119 /// context.
120 MLIR_CAPI_EXPORTED MlirType mlirFloat8E5M2TypeGet(MlirContext ctx);
121 
122 /// Returns the typeID of an Float8E4M3 type.
123 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E4M3TypeGetTypeID(void);
124 
125 /// Checks whether the given type is an f8E4M3 type.
126 MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E4M3(MlirType type);
127 
128 /// Creates an f8E4M3 type in the given context. The type is owned by the
129 /// context.
130 MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3TypeGet(MlirContext ctx);
131 
132 /// Returns the typeID of an Float8E4M3FN type.
133 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E4M3FNTypeGetTypeID(void);
134 
135 /// Checks whether the given type is an f8E4M3FN type.
136 MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E4M3FN(MlirType type);
137 
138 /// Creates an f8E4M3FN type in the given context. The type is owned by the
139 /// context.
140 MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3FNTypeGet(MlirContext ctx);
141 
142 /// Returns the typeID of an Float8E5M2FNUZ type.
143 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E5M2FNUZTypeGetTypeID(void);
144 
145 /// Checks whether the given type is an f8E5M2FNUZ type.
146 MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E5M2FNUZ(MlirType type);
147 
148 /// Creates an f8E5M2FNUZ type in the given context. The type is owned by the
149 /// context.
150 MLIR_CAPI_EXPORTED MlirType mlirFloat8E5M2FNUZTypeGet(MlirContext ctx);
151 
152 /// Returns the typeID of an Float8E4M3FNUZ type.
153 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E4M3FNUZTypeGetTypeID(void);
154 
155 /// Checks whether the given type is an f8E4M3FNUZ type.
156 MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E4M3FNUZ(MlirType type);
157 
158 /// Creates an f8E4M3FNUZ type in the given context. The type is owned by the
159 /// context.
160 MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3FNUZTypeGet(MlirContext ctx);
161 
162 /// Returns the typeID of an Float8E4M3B11FNUZ type.
163 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E4M3B11FNUZTypeGetTypeID(void);
164 
165 /// Checks whether the given type is an f8E4M3B11FNUZ type.
166 MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E4M3B11FNUZ(MlirType type);
167 
168 /// Creates an f8E4M3B11FNUZ type in the given context. The type is owned by the
169 /// context.
170 MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3B11FNUZTypeGet(MlirContext ctx);
171 
172 /// Returns the typeID of an Float8E3M4 type.
173 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E3M4TypeGetTypeID(void);
174 
175 /// Checks whether the given type is an f8E3M4 type.
176 MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E3M4(MlirType type);
177 
178 /// Creates an f8E3M4 type in the given context. The type is owned by the
179 /// context.
180 MLIR_CAPI_EXPORTED MlirType mlirFloat8E3M4TypeGet(MlirContext ctx);
181 
182 /// Returns the typeID of an Float8E8M0FNU type.
183 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E8M0FNUTypeGetTypeID(void);
184 
185 /// Checks whether the given type is an f8E8M0FNU type.
186 MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E8M0FNU(MlirType type);
187 
188 /// Creates an f8E8M0FNU type in the given context. The type is owned by the
189 /// context.
190 MLIR_CAPI_EXPORTED MlirType mlirFloat8E8M0FNUTypeGet(MlirContext ctx);
191 
192 /// Returns the typeID of an BFloat16 type.
193 MLIR_CAPI_EXPORTED MlirTypeID mlirBFloat16TypeGetTypeID(void);
194 
195 /// Checks whether the given type is a bf16 type.
196 MLIR_CAPI_EXPORTED bool mlirTypeIsABF16(MlirType type);
197 
198 /// Creates a bf16 type in the given context. The type is owned by the
199 /// context.
200 MLIR_CAPI_EXPORTED MlirType mlirBF16TypeGet(MlirContext ctx);
201 
202 /// Returns the typeID of an Float16 type.
203 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat16TypeGetTypeID(void);
204 
205 /// Checks whether the given type is an f16 type.
206 MLIR_CAPI_EXPORTED bool mlirTypeIsAF16(MlirType type);
207 
208 /// Creates an f16 type in the given context. The type is owned by the
209 /// context.
210 MLIR_CAPI_EXPORTED MlirType mlirF16TypeGet(MlirContext ctx);
211 
212 /// Returns the typeID of an Float32 type.
213 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat32TypeGetTypeID(void);
214 
215 /// Checks whether the given type is an f32 type.
216 MLIR_CAPI_EXPORTED bool mlirTypeIsAF32(MlirType type);
217 
218 /// Creates an f32 type in the given context. The type is owned by the
219 /// context.
220 MLIR_CAPI_EXPORTED MlirType mlirF32TypeGet(MlirContext ctx);
221 
222 /// Returns the typeID of an Float64 type.
223 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat64TypeGetTypeID(void);
224 
225 /// Checks whether the given type is an f64 type.
226 MLIR_CAPI_EXPORTED bool mlirTypeIsAF64(MlirType type);
227 
228 /// Creates a f64 type in the given context. The type is owned by the
229 /// context.
230 MLIR_CAPI_EXPORTED MlirType mlirF64TypeGet(MlirContext ctx);
231 
232 /// Returns the typeID of a TF32 type.
233 MLIR_CAPI_EXPORTED MlirTypeID mlirFloatTF32TypeGetTypeID(void);
234 
235 /// Checks whether the given type is an TF32 type.
236 MLIR_CAPI_EXPORTED bool mlirTypeIsATF32(MlirType type);
237 
238 /// Creates a TF32 type in the given context. The type is owned by the
239 /// context.
240 MLIR_CAPI_EXPORTED MlirType mlirTF32TypeGet(MlirContext ctx);
241 
242 //===----------------------------------------------------------------------===//
243 // None type.
244 //===----------------------------------------------------------------------===//
245 
246 /// Returns the typeID of an None type.
247 MLIR_CAPI_EXPORTED MlirTypeID mlirNoneTypeGetTypeID(void);
248 
249 /// Checks whether the given type is a None type.
250 MLIR_CAPI_EXPORTED bool mlirTypeIsANone(MlirType type);
251 
252 /// Creates a None type in the given context. The type is owned by the
253 /// context.
254 MLIR_CAPI_EXPORTED MlirType mlirNoneTypeGet(MlirContext ctx);
255 
256 //===----------------------------------------------------------------------===//
257 // Complex type.
258 //===----------------------------------------------------------------------===//
259 
260 /// Returns the typeID of an Complex type.
261 MLIR_CAPI_EXPORTED MlirTypeID mlirComplexTypeGetTypeID(void);
262 
263 /// Checks whether the given type is a Complex type.
264 MLIR_CAPI_EXPORTED bool mlirTypeIsAComplex(MlirType type);
265 
266 /// Creates a complex type with the given element type in the same context as
267 /// the element type. The type is owned by the context.
268 MLIR_CAPI_EXPORTED MlirType mlirComplexTypeGet(MlirType elementType);
269 
270 /// Returns the element type of the given complex type.
271 MLIR_CAPI_EXPORTED MlirType mlirComplexTypeGetElementType(MlirType type);
272 
273 //===----------------------------------------------------------------------===//
274 // Shaped type.
275 //===----------------------------------------------------------------------===//
276 
277 /// Checks whether the given type is a Shaped type.
278 MLIR_CAPI_EXPORTED bool mlirTypeIsAShaped(MlirType type);
279 
280 /// Returns the element type of the shaped type.
281 MLIR_CAPI_EXPORTED MlirType mlirShapedTypeGetElementType(MlirType type);
282 
283 /// Checks whether the given shaped type is ranked.
284 MLIR_CAPI_EXPORTED bool mlirShapedTypeHasRank(MlirType type);
285 
286 /// Returns the rank of the given ranked shaped type.
287 MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetRank(MlirType type);
288 
289 /// Checks whether the given shaped type has a static shape.
290 MLIR_CAPI_EXPORTED bool mlirShapedTypeHasStaticShape(MlirType type);
291 
292 /// Checks wither the dim-th dimension of the given shaped type is dynamic.
293 MLIR_CAPI_EXPORTED bool mlirShapedTypeIsDynamicDim(MlirType type, intptr_t dim);
294 
295 /// Returns the dim-th dimension of the given ranked shaped type.
296 MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDimSize(MlirType type,
297                                                     intptr_t dim);
298 
299 /// Checks whether the given value is used as a placeholder for dynamic sizes
300 /// in shaped types.
301 MLIR_CAPI_EXPORTED bool mlirShapedTypeIsDynamicSize(int64_t size);
302 
303 /// Returns the value indicating a dynamic size in a shaped type. Prefer
304 /// mlirShapedTypeIsDynamicSize to direct comparisons with this value.
305 MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDynamicSize(void);
306 
307 /// Checks whether the given value is used as a placeholder for dynamic strides
308 /// and offsets in shaped types.
309 MLIR_CAPI_EXPORTED bool mlirShapedTypeIsDynamicStrideOrOffset(int64_t val);
310 
311 /// Returns the value indicating a dynamic stride or offset in a shaped type.
312 /// Prefer mlirShapedTypeGetDynamicStrideOrOffset to direct comparisons with
313 /// this value.
314 MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDynamicStrideOrOffset(void);
315 
316 //===----------------------------------------------------------------------===//
317 // Vector type.
318 //===----------------------------------------------------------------------===//
319 
320 /// Returns the typeID of an Vector type.
321 MLIR_CAPI_EXPORTED MlirTypeID mlirVectorTypeGetTypeID(void);
322 
323 /// Checks whether the given type is a Vector type.
324 MLIR_CAPI_EXPORTED bool mlirTypeIsAVector(MlirType type);
325 
326 /// Creates a vector type of the shape identified by its rank and dimensions,
327 /// with the given element type in the same context as the element type. The
328 /// type is owned by the context.
329 MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGet(intptr_t rank,
330                                               const int64_t *shape,
331                                               MlirType elementType);
332 
333 /// Same as "mlirVectorTypeGet" but returns a nullptr wrapping MlirType on
334 /// illegal arguments, emitting appropriate diagnostics.
335 MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGetChecked(MlirLocation loc,
336                                                      intptr_t rank,
337                                                      const int64_t *shape,
338                                                      MlirType elementType);
339 
340 /// Creates a scalable vector type with the shape identified by its rank and
341 /// dimensions. A subset of dimensions may be marked as scalable via the
342 /// corresponding flag list, which is expected to have as many entries as the
343 /// rank of the vector. The vector is created in the same context as the element
344 /// type.
345 MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGetScalable(intptr_t rank,
346                                                       const int64_t *shape,
347                                                       const bool *scalable,
348                                                       MlirType elementType);
349 
350 /// Same as "mlirVectorTypeGetScalable" but returns a nullptr wrapping MlirType
351 /// on illegal arguments, emitting appropriate diagnostics.
352 MLIR_CAPI_EXPORTED
353 MlirType mlirVectorTypeGetScalableChecked(MlirLocation loc, intptr_t rank,
354                                           const int64_t *shape,
355                                           const bool *scalable,
356                                           MlirType elementType);
357 
358 /// Checks whether the given vector type is scalable, i.e., has at least one
359 /// scalable dimension.
360 MLIR_CAPI_EXPORTED bool mlirVectorTypeIsScalable(MlirType type);
361 
362 /// Checks whether the "dim"-th dimension of the given vector is scalable.
363 MLIR_CAPI_EXPORTED bool mlirVectorTypeIsDimScalable(MlirType type,
364                                                     intptr_t dim);
365 
366 //===----------------------------------------------------------------------===//
367 // Ranked / Unranked Tensor type.
368 //===----------------------------------------------------------------------===//
369 
370 /// Checks whether the given type is a Tensor type.
371 MLIR_CAPI_EXPORTED bool mlirTypeIsATensor(MlirType type);
372 
373 /// Returns the typeID of an RankedTensor type.
374 MLIR_CAPI_EXPORTED MlirTypeID mlirRankedTensorTypeGetTypeID(void);
375 
376 /// Checks whether the given type is a ranked tensor type.
377 MLIR_CAPI_EXPORTED bool mlirTypeIsARankedTensor(MlirType type);
378 
379 /// Returns the typeID of an UnrankedTensor type.
380 MLIR_CAPI_EXPORTED MlirTypeID mlirUnrankedTensorTypeGetTypeID(void);
381 
382 /// Checks whether the given type is an unranked tensor type.
383 MLIR_CAPI_EXPORTED bool mlirTypeIsAUnrankedTensor(MlirType type);
384 
385 /// Creates a tensor type of a fixed rank with the given shape, element type,
386 /// and optional encoding in the same context as the element type. The type is
387 /// owned by the context. Tensor types without any specific encoding field
388 /// should assign mlirAttributeGetNull() to this parameter.
389 MLIR_CAPI_EXPORTED MlirType mlirRankedTensorTypeGet(intptr_t rank,
390                                                     const int64_t *shape,
391                                                     MlirType elementType,
392                                                     MlirAttribute encoding);
393 
394 /// Same as "mlirRankedTensorTypeGet" but returns a nullptr wrapping MlirType on
395 /// illegal arguments, emitting appropriate diagnostics.
396 MLIR_CAPI_EXPORTED MlirType mlirRankedTensorTypeGetChecked(
397     MlirLocation loc, intptr_t rank, const int64_t *shape, MlirType elementType,
398     MlirAttribute encoding);
399 
400 /// Gets the 'encoding' attribute from the ranked tensor type, returning a null
401 /// attribute if none.
402 MLIR_CAPI_EXPORTED MlirAttribute mlirRankedTensorTypeGetEncoding(MlirType type);
403 
404 /// Creates an unranked tensor type with the given element type in the same
405 /// context as the element type. The type is owned by the context.
406 MLIR_CAPI_EXPORTED MlirType mlirUnrankedTensorTypeGet(MlirType elementType);
407 
408 /// Same as "mlirUnrankedTensorTypeGet" but returns a nullptr wrapping MlirType
409 /// on illegal arguments, emitting appropriate diagnostics.
410 MLIR_CAPI_EXPORTED MlirType
411 mlirUnrankedTensorTypeGetChecked(MlirLocation loc, MlirType elementType);
412 
413 //===----------------------------------------------------------------------===//
414 // Ranked / Unranked MemRef type.
415 //===----------------------------------------------------------------------===//
416 
417 /// Returns the typeID of an MemRef type.
418 MLIR_CAPI_EXPORTED MlirTypeID mlirMemRefTypeGetTypeID(void);
419 
420 /// Checks whether the given type is a MemRef type.
421 MLIR_CAPI_EXPORTED bool mlirTypeIsAMemRef(MlirType type);
422 
423 /// Returns the typeID of an UnrankedMemRef type.
424 MLIR_CAPI_EXPORTED MlirTypeID mlirUnrankedMemRefTypeGetTypeID(void);
425 
426 /// Checks whether the given type is an UnrankedMemRef type.
427 MLIR_CAPI_EXPORTED bool mlirTypeIsAUnrankedMemRef(MlirType type);
428 
429 /// Creates a MemRef type with the given rank and shape, a potentially empty
430 /// list of affine layout maps, the given memory space and element type, in the
431 /// same context as element type. The type is owned by the context.
432 MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGet(MlirType elementType,
433                                               intptr_t rank,
434                                               const int64_t *shape,
435                                               MlirAttribute layout,
436                                               MlirAttribute memorySpace);
437 
438 /// Same as "mlirMemRefTypeGet" but returns a nullptr-wrapping MlirType o
439 /// illegal arguments, emitting appropriate diagnostics.
440 MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGetChecked(
441     MlirLocation loc, MlirType elementType, intptr_t rank, const int64_t *shape,
442     MlirAttribute layout, MlirAttribute memorySpace);
443 
444 /// Creates a MemRef type with the given rank, shape, memory space and element
445 /// type in the same context as the element type. The type has no affine maps,
446 /// i.e. represents a default row-major contiguous memref. The type is owned by
447 /// the context.
448 MLIR_CAPI_EXPORTED MlirType
449 mlirMemRefTypeContiguousGet(MlirType elementType, intptr_t rank,
450                             const int64_t *shape, MlirAttribute memorySpace);
451 
452 /// Same as "mlirMemRefTypeContiguousGet" but returns a nullptr wrapping
453 /// MlirType on illegal arguments, emitting appropriate diagnostics.
454 MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeContiguousGetChecked(
455     MlirLocation loc, MlirType elementType, intptr_t rank, const int64_t *shape,
456     MlirAttribute memorySpace);
457 
458 /// Creates an Unranked MemRef type with the given element type and in the given
459 /// memory space. The type is owned by the context of element type.
460 MLIR_CAPI_EXPORTED MlirType
461 mlirUnrankedMemRefTypeGet(MlirType elementType, MlirAttribute memorySpace);
462 
463 /// Same as "mlirUnrankedMemRefTypeGet" but returns a nullptr wrapping
464 /// MlirType on illegal arguments, emitting appropriate diagnostics.
465 MLIR_CAPI_EXPORTED MlirType mlirUnrankedMemRefTypeGetChecked(
466     MlirLocation loc, MlirType elementType, MlirAttribute memorySpace);
467 
468 /// Returns the layout of the given MemRef type.
469 MLIR_CAPI_EXPORTED MlirAttribute mlirMemRefTypeGetLayout(MlirType type);
470 
471 /// Returns the affine map of the given MemRef type.
472 MLIR_CAPI_EXPORTED MlirAffineMap mlirMemRefTypeGetAffineMap(MlirType type);
473 
474 /// Returns the memory space of the given MemRef type.
475 MLIR_CAPI_EXPORTED MlirAttribute mlirMemRefTypeGetMemorySpace(MlirType type);
476 
477 /// Returns the strides of the MemRef if the layout map is in strided form.
478 /// Both strides and offset are out params. strides must point to pre-allocated
479 /// memory of length equal to the rank of the memref.
480 MLIR_CAPI_EXPORTED MlirLogicalResult mlirMemRefTypeGetStridesAndOffset(
481     MlirType type, int64_t *strides, int64_t *offset);
482 
483 /// Returns the memory spcae of the given Unranked MemRef type.
484 MLIR_CAPI_EXPORTED MlirAttribute
485 mlirUnrankedMemrefGetMemorySpace(MlirType type);
486 
487 //===----------------------------------------------------------------------===//
488 // Tuple type.
489 //===----------------------------------------------------------------------===//
490 
491 /// Returns the typeID of an Tuple type.
492 MLIR_CAPI_EXPORTED MlirTypeID mlirTupleTypeGetTypeID(void);
493 
494 /// Checks whether the given type is a tuple type.
495 MLIR_CAPI_EXPORTED bool mlirTypeIsATuple(MlirType type);
496 
497 /// Creates a tuple type that consists of the given list of elemental types. The
498 /// type is owned by the context.
499 MLIR_CAPI_EXPORTED MlirType mlirTupleTypeGet(MlirContext ctx,
500                                              intptr_t numElements,
501                                              MlirType const *elements);
502 
503 /// Returns the number of types contained in a tuple.
504 MLIR_CAPI_EXPORTED intptr_t mlirTupleTypeGetNumTypes(MlirType type);
505 
506 /// Returns the pos-th type in the tuple type.
507 MLIR_CAPI_EXPORTED MlirType mlirTupleTypeGetType(MlirType type, intptr_t pos);
508 
509 //===----------------------------------------------------------------------===//
510 // Function type.
511 //===----------------------------------------------------------------------===//
512 
513 /// Returns the typeID of an Function type.
514 MLIR_CAPI_EXPORTED MlirTypeID mlirFunctionTypeGetTypeID(void);
515 
516 /// Checks whether the given type is a function type.
517 MLIR_CAPI_EXPORTED bool mlirTypeIsAFunction(MlirType type);
518 
519 /// Creates a function type, mapping a list of input types to result types.
520 MLIR_CAPI_EXPORTED MlirType mlirFunctionTypeGet(MlirContext ctx,
521                                                 intptr_t numInputs,
522                                                 MlirType const *inputs,
523                                                 intptr_t numResults,
524                                                 MlirType const *results);
525 
526 /// Returns the number of input types.
527 MLIR_CAPI_EXPORTED intptr_t mlirFunctionTypeGetNumInputs(MlirType type);
528 
529 /// Returns the number of result types.
530 MLIR_CAPI_EXPORTED intptr_t mlirFunctionTypeGetNumResults(MlirType type);
531 
532 /// Returns the pos-th input type.
533 MLIR_CAPI_EXPORTED MlirType mlirFunctionTypeGetInput(MlirType type,
534                                                      intptr_t pos);
535 
536 /// Returns the pos-th result type.
537 MLIR_CAPI_EXPORTED MlirType mlirFunctionTypeGetResult(MlirType type,
538                                                       intptr_t pos);
539 
540 //===----------------------------------------------------------------------===//
541 // Opaque type.
542 //===----------------------------------------------------------------------===//
543 
544 /// Returns the typeID of an Opaque type.
545 MLIR_CAPI_EXPORTED MlirTypeID mlirOpaqueTypeGetTypeID(void);
546 
547 /// Checks whether the given type is an opaque type.
548 MLIR_CAPI_EXPORTED bool mlirTypeIsAOpaque(MlirType type);
549 
550 /// Creates an opaque type in the given context associated with the dialect
551 /// identified by its namespace. The type contains opaque byte data of the
552 /// specified length (data need not be null-terminated).
553 MLIR_CAPI_EXPORTED MlirType mlirOpaqueTypeGet(MlirContext ctx,
554                                               MlirStringRef dialectNamespace,
555                                               MlirStringRef typeData);
556 
557 /// Returns the namespace of the dialect with which the given opaque type
558 /// is associated. The namespace string is owned by the context.
559 MLIR_CAPI_EXPORTED MlirStringRef
560 mlirOpaqueTypeGetDialectNamespace(MlirType type);
561 
562 /// Returns the raw data as a string reference. The data remains live as long as
563 /// the context in which the type lives.
564 MLIR_CAPI_EXPORTED MlirStringRef mlirOpaqueTypeGetData(MlirType type);
565 
566 #ifdef __cplusplus
567 }
568 #endif
569 
570 #endif // MLIR_C_BUILTINTYPES_H
571