[Mlir-commits] [mlir] [mlir] Add the ability to override attribute parsing/printing in attr-dicts (PR #103304)

Benjamin Maxwell llvmlistbot at llvm.org
Wed Aug 14 14:53:03 PDT 2024


MacDue wrote:

> I don't think this PR is needed to implement it in custom C++: you can print `{` then iterate the dictionary and custom print anything there.
> 
> >

I don't think this PR is needed to implement it in custom C++: you can print { then iterate the dictionary and custom print anything there.

I know it's not _needed_ you could manually implement both the printing and parsing of the `attr-dict`, but I think it's easier to use what's already there, as there are some complications particularly in generally parsing the `attr-dict` (which you can see in the implementation of `parseAttributeDict()`). 

> Second point was that instead of having to do let hasCustomAssemblyFormat = 1;, one may want to continue using declarative assembly with custom directive just for the attr-dict :   let assemblyFormat = "custom<MyPrintParse>(attr-dict)".

I think having a declarative away to do something like this would be nice :slightly_smiling_face:, though note that the first use case (the vector transfer ops), already has a custom printer/parser for other reasons. So, simply providing these callbacks is an easy change. 


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


More information about the Mlir-commits mailing list