[Mlir-commits] [mlir] a394230 - Make struct dialects have the same field name as everything else, 'dialect'.
Mehdi Amini
llvmlistbot at llvm.org
Thu Sep 10 12:13:50 PDT 2020
Author: Federico Lebrón
Date: 2020-09-10T19:13:42Z
New Revision: a39423084cbbeb59e81002e741190dccf08b5c82
URL: https://github.com/llvm/llvm-project/commit/a39423084cbbeb59e81002e741190dccf08b5c82
DIFF: https://github.com/llvm/llvm-project/commit/a39423084cbbeb59e81002e741190dccf08b5c82.diff
LOG: Make struct dialects have the same field name as everything else, 'dialect'.
Also make the behavior of getting a dialect more forgiving, in the case where
there isn't a dialect associated with an attribute.
Depends On D86807
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D86809
Added:
Modified:
mlir/include/mlir/IR/OpBase.td
mlir/lib/TableGen/Attribute.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td
index b0f08e93666a..29f139f25069 100644
--- a/mlir/include/mlir/IR/OpBase.td
+++ b/mlir/include/mlir/IR/OpBase.td
@@ -1443,7 +1443,7 @@ class StructFieldAttr<string thisName, Attr thisType> {
// Structured attribute that wraps a DictionaryAttr and provides both a
// validation method and set of accessors for a fixed set of fields. This is
// useful when representing data that would normally be in a structure.
-class StructAttr<string name, Dialect dialect,
+class StructAttr<string name, Dialect d,
list<StructFieldAttr> attributes> :
DictionaryAttrBase<CPred<"$_self.isa<" # name # ">()">,
"DictionaryAttr with field(s): " #
@@ -1459,7 +1459,7 @@ class StructAttr<string name, Dialect dialect,
let storageType = name;
// The dialect this StructAttr belongs to.
- Dialect structDialect = dialect;
+ Dialect dialect = d;
// List of fields that the StructAttr contains.
list<StructFieldAttr> fields = attributes;
diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp
index e489174a38d9..f34d9c00b438 100644
--- a/mlir/lib/TableGen/Attribute.cpp
+++ b/mlir/lib/TableGen/Attribute.cpp
@@ -126,7 +126,12 @@ StringRef Attribute::getDerivedCodeBody() const {
}
Dialect Attribute::getDialect() const {
- return Dialect(def->getValueAsDef("dialect"));
+ const llvm::RecordVal *record = def->getValue("dialect");
+ if (record && record->getValue()) {
+ if (DefInit *init = dyn_cast<DefInit>(record->getValue()))
+ return Dialect(init->getDef());
+ }
+ return Dialect(nullptr);
}
ConstantAttr::ConstantAttr(const DefInit *init) : def(init->getDef()) {
@@ -255,7 +260,7 @@ StringRef StructAttr::getStructClassName() const {
}
StringRef StructAttr::getCppNamespace() const {
- Dialect dialect(def->getValueAsDef("structDialect"));
+ Dialect dialect(def->getValueAsDef("dialect"));
return dialect.getCppNamespace();
}
More information about the Mlir-commits
mailing list