xref: /llvm-project/mlir/docs/Dialects/Builtin.md (revision 728a8d5a81f35f24492fcd31928ef95e597a66af)
1# Builtin Dialect
2
3The builtin dialect contains a core set of Attributes, Operations, and Types
4that have wide applicability across a very large number of domains and
5abstractions. Many of the components of this dialect are also instrumental in
6the implementation of the core IR. As such, this dialect is implicitly loaded in
7every `MLIRContext`, and available directly to all users of MLIR.
8
9Given the far-reaching nature of this dialect and the fact that MLIR is
10extensible by design, any potential additions are heavily scrutinized.
11
12[TOC]
13
14## Attributes
15
16[include "Dialects/BuiltinAttributes.md"]
17
18## Location Attributes
19
20A subset of the builtin attribute values correspond to
21[source locations](../Diagnostics.md/#source-locations), that may be attached to
22Operations.
23
24[include "Dialects/BuiltinLocationAttributes.md"]
25
26## DistinctAttribute
27
28A DistinctAttribute associates an attribute with a unique identifier.
29As a result, multiple DistinctAttribute instances may point to the same
30attribute. Every call to the `create` function allocates a new
31DistinctAttribute instance. The address of the attribute instance serves as a
32temporary unique identifier. Similar to the names of SSA values, the final
33unique identifiers are generated during pretty printing. This delayed
34numbering ensures the printed identifiers are deterministic even if
35multiple DistinctAttribute instances are created in-parallel.
36
37Syntax:
38
39```
40distinct-id ::= integer-literal
41distinct-attribute ::= `distinct` `[` distinct-id `]<` attribute `>`
42```
43
44Examples:
45
46```mlir
47#distinct = distinct[0]<42.0 : f32>
48#distinct1 = distinct[1]<42.0 : f32>
49#distinct2 = distinct[2]<array<i32: 10, 42>>
50```
51
52This mechanism is meant to generate attributes with a unique
53identifier, which can be used to mark groups of operations that share a
54common property. For example, groups of aliasing memory operations may be
55marked using one DistinctAttribute instance per alias group.
56
57## Operations
58
59[include "Dialects/BuiltinOps.md"]
60
61## Types
62
63[include "Dialects/BuiltinTypes.md"]
64
65## Type Interfaces
66
67[include "Dialects/BuiltinTypeInterfaces.md"]
68