[Mlir-commits] [mlir] [mlir] Introduce OpAsmAttrInterface for pretty-print (PR #124721)
River Riddle
llvmlistbot at llvm.org
Tue Feb 18 10:03:37 PST 2025
================
@@ -1159,15 +1160,31 @@ template <typename T>
void AliasInitializer::generateAlias(T symbol, InProgressAliasInfo &alias,
bool canBeDeferred) {
SmallString<32> nameBuffer;
- for (const auto &interface : interfaces) {
- OpAsmDialectInterface::AliasResult result =
- interface.getAlias(symbol, aliasOS);
- if (result == OpAsmDialectInterface::AliasResult::NoAlias)
- continue;
- nameBuffer = std::move(aliasBuffer);
- assert(!nameBuffer.empty() && "expected valid alias name");
- if (result == OpAsmDialectInterface::AliasResult::FinalAlias)
- break;
+
+ OpAsmDialectInterface::AliasResult symbolInterfaceResult =
+ OpAsmDialectInterface::AliasResult::NoAlias;
+ if constexpr (std::is_base_of_v<Attribute, T>) {
+ if (auto symbolInterface = mlir::dyn_cast<OpAsmAttrInterface>(symbol)) {
----------------
River707 wrote:
With the type interface supporting this as well, you should be able to do something like:
```
using InterfaceT = std::conditional_t<std::is_base_of_v<Attribute, T>, OpAsmAttrInterface, OpAsmTypeInterface>;
if (auto symbolInterface = dyn_cast<InterfaceT>(symbol)) {
...
}
```
Note also dropping mlir:: from the dyn_cast, mlir:: shouldn't be necessary in the majority of code upstream.
https://github.com/llvm/llvm-project/pull/124721
More information about the Mlir-commits
mailing list