Changeset View
Changeset View
Standalone View
Standalone View
mlir/docs/LangRef.md
Show First 20 Lines • Show All 1,363 Lines • ▼ Show 20 Lines | |||||
// Using the attribute alias. | // Using the attribute alias. | ||||
%b = affine.apply #map(%a) | %b = affine.apply #map(%a) | ||||
``` | ``` | ||||
### Dialect Attribute Values | ### Dialect Attribute Values | ||||
Similarly to operations, dialects may define custom attribute values. The | Similarly to operations, dialects may define custom attribute values. The | ||||
syntactic structure of these values is identical to custom dialect type values, | syntactic structure of these values is identical to custom dialect type values, | ||||
except that dialect attributes values are distinguished with a leading '#', | except that dialect attribute values are distinguished with a leading '#', while | ||||
while dialect types are distinguished with a leading '!'. | dialect types are distinguished with a leading '!'. | ||||
``` | ``` | ||||
dialect-attribute ::= '#' opaque-dialect-item | dialect-attribute-value ::= '#' opaque-dialect-item | ||||
dialect-attribute ::= '#' pretty-dialect-item | dialect-attribute-value ::= '#' pretty-dialect-item | ||||
``` | ``` | ||||
Dialect attributes can be specified in a verbose form, e.g. like this: | Dialect attribute values can be specified in a verbose form, e.g. like this: | ||||
```mlir | ```mlir | ||||
// Complex attribute | // Complex attribute value. | ||||
#foo<"something<abcd>"> | #foo<"something<abcd>"> | ||||
// Even more complex attribute | // Even more complex attribute value. | ||||
#foo<"something<a%%123^^^>>>"> | #foo<"something<a%%123^^^>>>"> | ||||
``` | ``` | ||||
Dialect attributes that are simple enough can use the pretty format, which is a | Dialect attribute values that are simple enough can use the pretty format, which | ||||
lighter weight syntax that is equivalent to the above forms: | is a lighter weight syntax that is equivalent to the above forms: | ||||
```mlir | ```mlir | ||||
// Complex attribute | // Complex attribute | ||||
#foo.something<abcd> | #foo.something<abcd> | ||||
``` | ``` | ||||
Sufficiently complex dialect attributes are required to use the verbose form for | Sufficiently complex dialect attribute values are required to use the verbose | ||||
generality. For example, the more complex type shown above wouldn't be valid in | form for generality. For example, the more complex type shown above would not be | ||||
the lighter syntax: `#foo.something<a%%123^^^>>>` because it contains characters | valid in the lighter syntax: `#foo.something<a%%123^^^>>>` because it contains | ||||
that are not allowed in the lighter syntax, as well as unbalanced `<>` | characters that are not allowed in the lighter syntax, as well as unbalanced | ||||
characters. | `<>` characters. | ||||
See [here](Tutorials/DefiningAttributesAndTypes.md) to learn how to define dialect | See [here](Tutorials/DefiningAttributesAndTypes.md) on how to define dialect | ||||
attribute values. | attribute values. | ||||
### Standard Attribute Values | ### Standard Attribute Values | ||||
Standard attributes are a core set of | Standard attributes are a core set of | ||||
[dialect attributes](#dialect-attribute-values) that are defined in a builtin | [dialect attributes](#dialect-attribute-values) that are defined in a builtin | ||||
dialect and thus available to all users of MLIR. | dialect and thus available to all users of MLIR. | ||||
▲ Show 20 Lines • Show All 256 Lines • Show Last 20 Lines |