[Mlir-commits] [mlir] Reimplementing target description concept using DLTI attribute (PR #92138)
Mehdi Amini
llvmlistbot at llvm.org
Mon Jun 17 06:05:26 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.
----------------
joker-eph wrote:
What is the logic behind this verifier? The comment says "we may allow keys unknown to us", but we don't right now?
(also we should avoid string comparisons)
https://github.com/llvm/llvm-project/pull/92138
More information about the Mlir-commits
mailing list