[Mlir-commits] [mlir] Reimplementing target description concept using DLTI attribute (PR #92138)
Niranjan Hasabnis
llvmlistbot at llvm.org
Mon Jun 17 10:42:45 PDT 2024
================
@@ -375,32 +457,34 @@ class TargetDataLayoutInterface : public DataLayoutDialectInterface {
};
} // namespace
-void DLTIDialect::initialize() {
- addAttributes<DataLayoutEntryAttr, DataLayoutSpecAttr>();
- addInterfaces<TargetDataLayoutInterface>();
-}
-
-Attribute DLTIDialect::parseAttribute(DialectAsmParser &parser,
- Type type) const {
- StringRef attrKind;
- if (parser.parseKeyword(&attrKind))
- return {};
+namespace {
+/// An interface to check entries of a target device spec.
+class SystemDescSpecInterface : public DataLayoutDialectInterface {
+public:
+ using DataLayoutDialectInterface::DataLayoutDialectInterface;
- if (attrKind == DataLayoutEntryAttr::kAttrKeyword)
- return DataLayoutEntryAttr::parse(parser);
- if (attrKind == DataLayoutSpecAttr::kAttrKeyword)
- return DataLayoutSpecAttr::parse(parser);
+ LogicalResult verifyEntry(TargetDeviceSpecInterface entry,
+ Location loc) const final {
- parser.emitError(parser.getNameLoc(), "unknown attrribute type: ")
- << attrKind;
- return {};
-}
+ for (DataLayoutEntryInterface dl_entry : entry.getEntries()) {
+ StringRef entryName = dl_entry.getKey().get<StringAttr>().strref();
+ // Check that the key name is known to us. Although, we may allow keys
+ // unknown to us.
----------------
nhasabni wrote:
Clarifying the comment - we don't allow unknown keys currently.
https://github.com/llvm/llvm-project/pull/92138
More information about the Mlir-commits
mailing list