[Mlir-commits] [mlir] [MLIR] Add ODS support for generating helpers for dialect (discardable) attributes (PR #77024)

Jeff Niu llvmlistbot at llvm.org
Sat Jan 6 04:12:38 PST 2024


================
@@ -181,6 +196,37 @@ static const char *const operationInterfaceFallbackDecl = R"(
                                       mlir::OperationName opName) override;
 )";
 
+/// The code block for the discardable attribute helper.
+static const char *const discardableAttrHelperDecl = R"(
+    /// Helper to manage the discardable attribute `{1}`.
+    class {0}AttrHelper {{
+      mlir::StringAttr name;
+    public:
+      static constexpr llvm::StringLiteral getNameStr() {{
----------------
Mogball wrote:

I guess my only complaint is that the helper pattern is a bit verbose, but it's efficient because it enables one to avoid deferencing the dialect pointer more than once. Seems fine to me.

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


More information about the Mlir-commits mailing list