// 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): " #
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;
}
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()) {
}
StringRef StructAttr::getCppNamespace() const {
- Dialect dialect(def->getValueAsDef("structDialect"));
+ Dialect dialect(def->getValueAsDef("dialect"));
return dialect.getCppNamespace();
}