[Mlir-commits] [mlir] [mlir][AsmPrinter] Print op properties directly in generic form (PR #106996)

Andrei Golubev llvmlistbot at llvm.org
Mon Sep 2 07:27:04 PDT 2024


================
@@ -1809,14 +1809,13 @@ class Op : public OpState, public Traits<ConcreteType>... {
 
   /// Trait to check if printProperties(OpAsmPrinter, T, ArrayRef<StringRef>)
   /// exist
-  template <typename T, typename... Args>
-  using has_print_properties =
-      decltype(printProperties(std::declval<OpAsmPrinter &>(),
-                               std::declval<T>(),
-                               std::declval<ArrayRef<StringRef>>()));
-  template <typename T>
+  template <typename ConcreteOp, typename Props>
+  using has_print_properties = decltype(ConcreteOp::printProperties(
----------------
andrey-golubev wrote:

note: this changed from free-standing printProperties to ConcreteOp::printProperties. motivation:
I've tried to have a custom "hook" using a free-standing function and failed (I think because the declaration order was messed up). At which point I figured that the last thing the user wants is a no-error-whatsoever (thanks SFINAE) mechanism to allow custom behavior.

Since properties type is strongly coupled to the operation, i think it makes sense to make printProperties a static member function also. This would at least avoid the declaration-issue as one would have method declaration in the body of the Op (e.g. when generating tablegen inside extraClassDeclarations).

https://github.com/llvm/llvm-project/pull/106996


More information about the Mlir-commits mailing list