[Mlir-commits] [mlir] [mlir] NamedAttribute utility generator (PR #75118)

Krzysztof Drewniak llvmlistbot at llvm.org
Fri Dec 15 12:09:12 PST 2023


krzysz00 wrote:

I think there's an argument for defining a new record type here. To give it a provisional name, something like `DialectScopedAttr`, so that you can generate accessors and the like in `mlir-tblgen`. 

My sense here is that there're two related usecases, which may or may not need the same abstraction:
1. Dialect-specific attributes that need to live on other people's operations. For example, that there `reqd_work_group_size`, which lives on `llvm.func`. Or `gpu.container_module`, which lives on `builtin.module`. It'll be good to have those documented and to have getter/setter functions that check invariants (since we can't inject code into other people's `verify()` methods). This sort of thing could also allow you to specify properties of the operation you put it on - for example, it could be known at tablegen time that `gpu.container_module` is supposed to go on module-like operations only.
2. Dialect-wide attribute grab bags that aren't repeated as properties on every operation. For example, stuff like `llvm.align`, `llvm.invariant_load`, and so on and so forth. In principle, we could go clean all that up and give every LLVM dialect operation a long list of properties matching exactly the kind of metadata or attributes you can put on it in LLVM IR ... or you can just have a cleaner interface to these attributes by routing them through the mechanisms for case (1) above

Making this its own tablegen record type would have the advantage of allowing you to generate documentation automatically as well, for instance, but it is a lot more work.

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


More information about the Mlir-commits mailing list