summaryrefslogtreecommitdiff
path: root/mlir/lib/IR/ExtensibleDialect.cpp
diff options
context:
space:
mode:
authorRiver Riddle <riddleriver@gmail.com>2023-01-20 21:39:13 -0800
committerRiver Riddle <riddleriver@gmail.com>2023-01-27 15:28:03 -0800
commit03d136cf5f3f10b618b7e17f897ebf6019518dcc (patch)
tree77296a1eb9bdc726ea3b1f3b81012210694a37c1 /mlir/lib/IR/ExtensibleDialect.cpp
parentf58de2125caf75ec0d40bc3e094a93c0b314a66a (diff)
downloadllvm-03d136cf5f3f10b618b7e17f897ebf6019518dcc.tar.gz
[mlir] Promote the SubElementInterfaces to a core Attribute/Type construct
This commit restructures the sub element infrastructure to be a core part of attributes and types, instead of being relegated to an interface. This establishes sub element walking/replacement as something "always there", which makes it easier to rely on for correctness/etc (which various bits of infrastructure want, such as Symbols). Attribute/Type now have `walk` and `replace` methods directly accessible, which provide power API for interacting with sub elements. As part of this, a new AttrTypeWalker class is introduced that supports caching walked attributes/types, and a friendlier API (see the simplification of symbol walking in SymbolTable.cpp). Differential Revision: https://reviews.llvm.org/D142272
Diffstat (limited to 'mlir/lib/IR/ExtensibleDialect.cpp')
-rw-r--r--mlir/lib/IR/ExtensibleDialect.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/mlir/lib/IR/ExtensibleDialect.cpp b/mlir/lib/IR/ExtensibleDialect.cpp
index 701683fdcb5c..00849857b51d 100644
--- a/mlir/lib/IR/ExtensibleDialect.cpp
+++ b/mlir/lib/IR/ExtensibleDialect.cpp
@@ -407,9 +407,10 @@ void ExtensibleDialect::registerDynamicType(
assert(registered &&
"Trying to create a new dynamic type with an existing name");
- auto abstractType =
- AbstractType::get(*dialect, DynamicAttr::getInterfaceMap(),
- DynamicType::getHasTraitFn(), typeID);
+ auto abstractType = AbstractType::get(
+ *dialect, DynamicAttr::getInterfaceMap(), DynamicType::getHasTraitFn(),
+ DynamicType::getWalkImmediateSubElementsFn(),
+ DynamicType::getReplaceImmediateSubElementsFn(), typeID);
/// Add the type to the dialect and the type uniquer.
addType(typeID, std::move(abstractType));
@@ -436,9 +437,10 @@ void ExtensibleDialect::registerDynamicAttr(
assert(registered &&
"Trying to create a new dynamic attribute with an existing name");
- auto abstractAttr =
- AbstractAttribute::get(*dialect, DynamicAttr::getInterfaceMap(),
- DynamicAttr::getHasTraitFn(), typeID);
+ auto abstractAttr = AbstractAttribute::get(
+ *dialect, DynamicAttr::getInterfaceMap(), DynamicAttr::getHasTraitFn(),
+ DynamicAttr::getWalkImmediateSubElementsFn(),
+ DynamicAttr::getReplaceImmediateSubElementsFn(), typeID);
/// Add the type to the dialect and the type uniquer.
addAttribute(typeID, std::move(abstractAttr));