[llvm-branch-commits] [mlir] b276bf5 - [MLIR][NFC] Fix mix up between dialect attribute values and names

Uday Bondhugula via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Dec 2 13:10:04 PST 2020


Author: Uday Bondhugula
Date: 2020-12-03T02:34:15+05:30
New Revision: b276bf5a572b64a02bd4b067125d4f2c9cf6fb6b

URL: https://github.com/llvm/llvm-project/commit/b276bf5a572b64a02bd4b067125d4f2c9cf6fb6b
DIFF: https://github.com/llvm/llvm-project/commit/b276bf5a572b64a02bd4b067125d4f2c9cf6fb6b.diff

LOG: [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

Added: 
    

Modified: 
    mlir/docs/LangRef.md
    mlir/lib/IR/BuiltinDialect.cpp
    mlir/test/IR/invalid-module-op.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/docs/LangRef.md b/mlir/docs/LangRef.md
index 82272d1b729f..fd78d51afd6d 100644
--- a/mlir/docs/LangRef.md
+++ b/mlir/docs/LangRef.md
@@ -1369,39 +1369,39 @@ Example:
 
 Similarly to operations, dialects may define custom attribute values. The
 syntactic structure of these values is identical to custom dialect type values,
-except that dialect attributes values are distinguished with a leading '#',
-while dialect types are distinguished with a leading '!'.
+except that dialect attribute values are distinguished with a leading '#', while
+dialect types are distinguished with a leading '!'.
 
 ```
-dialect-attribute ::= '#' opaque-dialect-item
-dialect-attribute ::= '#' pretty-dialect-item
+dialect-attribute-value ::= '#' opaque-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
-// Complex attribute
+// Complex attribute value.
 #foo<"something<abcd>">
 
-// Even more complex attribute
+// Even more complex attribute value.
 #foo<"something<a%%123^^^>>>">
 ```
 
-Dialect attributes that are simple enough can use the pretty format, which is a
-lighter weight syntax that is equivalent to the above forms:
+Dialect attribute values that are simple enough can use the pretty format, which
+is a lighter weight syntax that is equivalent to the above forms:
 
 ```mlir
 // Complex attribute
 #foo.something<abcd>
 ```
 
-Sufficiently complex dialect attributes are required to use the verbose form for
-generality. For example, the more complex type shown above wouldn't be valid in
-the lighter syntax: `#foo.something<a%%123^^^>>>` because it contains characters
-that are not allowed in the lighter syntax, as well as unbalanced `<>`
-characters.
+Sufficiently complex dialect attribute values are required to use the verbose
+form for generality. For example, the more complex type shown above would not be
+valid in the lighter syntax: `#foo.something<a%%123^^^>>>` because it contains
+characters that are not allowed in the lighter syntax, as well as unbalanced
+`<>` characters.
 
-See [here](Tutorials/DefiningAttributesAndTypes.md) to learn how to define dialect
+See [here](Tutorials/DefiningAttributesAndTypes.md) on how to define dialect
 attribute values.
 
 ### Standard Attribute Values

diff  --git a/mlir/lib/IR/BuiltinDialect.cpp b/mlir/lib/IR/BuiltinDialect.cpp
index 5c0a0380f9af..8f872ac7c9ab 100644
--- a/mlir/lib/IR/BuiltinDialect.cpp
+++ b/mlir/lib/IR/BuiltinDialect.cpp
@@ -228,9 +228,9 @@ static LogicalResult verify(ModuleOp op) {
             ArrayRef<StringRef>{mlir::SymbolTable::getSymbolAttrName(),
                                 mlir::SymbolTable::getVisibilityAttrName()},
             attr.first.strref()))
-      return op.emitOpError()
-             << "can only contain dialect-specific attributes, found: '"
-             << attr.first << "'";
+      return op.emitOpError() << "can only contain attributes with "
+                                 "dialect-prefixed names, found: '"
+                              << attr.first << "'";
   }
 
   return success();

diff  --git a/mlir/test/IR/invalid-module-op.mlir b/mlir/test/IR/invalid-module-op.mlir
index 73fe188209d1..520821a7b0b4 100644
--- a/mlir/test/IR/invalid-module-op.mlir
+++ b/mlir/test/IR/invalid-module-op.mlir
@@ -44,7 +44,7 @@ func @module_op() {
 
 // -----
 
-// expected-error at +1 {{can only contain dialect-specific attributes}}
+// expected-error at +1 {{can only contain attributes with dialect-prefixed names}}
 module attributes {attr} {
 }
 


        


More information about the llvm-branch-commits mailing list