forked from OSchip/llvm-project
[MLIR][NFC] Fix mix up between dialect attribute values and names
Clear up documentation on dialect attribute values. Fix/improve ModuleOp verifier error message on dialect prefixed attribute names. Additional discussion is here: https://llvm.discourse.group/t/moduleop-attributes/2325 Differential Revision: https://reviews.llvm.org/D92502
This commit is contained in:
parent
2ac5880187
commit
b276bf5a57
|
@ -1369,39 +1369,39 @@ Example:
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -228,9 +228,9 @@ static LogicalResult verify(ModuleOp op) {
|
||||||
ArrayRef<StringRef>{mlir::SymbolTable::getSymbolAttrName(),
|
ArrayRef<StringRef>{mlir::SymbolTable::getSymbolAttrName(),
|
||||||
mlir::SymbolTable::getVisibilityAttrName()},
|
mlir::SymbolTable::getVisibilityAttrName()},
|
||||||
attr.first.strref()))
|
attr.first.strref()))
|
||||||
return op.emitOpError()
|
return op.emitOpError() << "can only contain attributes with "
|
||||||
<< "can only contain dialect-specific attributes, found: '"
|
"dialect-prefixed names, found: '"
|
||||||
<< attr.first << "'";
|
<< attr.first << "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
return success();
|
return success();
|
||||||
|
|
|
@ -44,7 +44,7 @@ func @module_op() {
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
|
|
||||||
// expected-error@+1 {{can only contain dialect-specific attributes}}
|
// expected-error@+1 {{can only contain attributes with dialect-prefixed names}}
|
||||||
module attributes {attr} {
|
module attributes {attr} {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue