[Mlir-commits] [mlir] [NFC] Improve readability of AttrHelper usage (PR #135873)

River Riddle llvmlistbot at llvm.org
Tue Apr 15 15:47:08 PDT 2025


================
@@ -341,7 +349,17 @@ static const char *const dialectDestructorStr = R"(
 {0}::~{0}() = default;
 
 )";
+  
+/// The code block to generate a member funcs.
+///
+/// {0}: The name of the dialect class.
+static const char *const dialectStaticMemberDefs = R"(
+const {0} *{0}::getLoaded(::mlir::Operation *operation) {{
----------------
River707 wrote:

I'm not convinced of the utility of this method over just casting from the operations dialect. This method is going to be significantly slower than calling getDialect on the operation itself. If we wanted to make this easier, we should rather consider auto-generating a templated version of `getDialect` for Ops/Attrs/Types that does the casting for you.

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


More information about the Mlir-commits mailing list