[Mlir-commits] [mlir] [MLIR][ODS] Make dialect attribute helper member functions const (NFC) (PR #181111)

Christian Ulmann llvmlistbot at llvm.org
Thu Feb 12 05:36:26 PST 2026


Dinistro wrote:

> > these helpers can be used as members of rewrite patterns
> 
> What does that mean? Can you post a small example of what does not compile?

Sure, sorry for not adding it right away. Something like this does not work:

```
struct ExamplePattern : public OpConversionPattern<MyDialect::MyOp> {
  using Base::OpConversionPattern;

  ExamplePattern(MLIRContext *context) : Base(context), helper(context) {}

  LogicalResult
  matchAndRewrite(MyDialect::MyOpop, OpAdaptor adaptor,
                  ConversionPatternRewriter &rewriter) const override {
    // Does not compile, because `setAttr` is not const.              
    helper.setAttr(op, rewriter.getUnitAttr());
    return success();
  }
  
  MyDialect::MyAttrHelper helper;
};
```

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


More information about the Mlir-commits mailing list