[mlir][irdl] Add `irdl.attributes` operation for defining named attributes
authorDaniil Dudkin <unterumarmung@yandex.ru>
Tue, 20 Jun 2023 17:58:26 +0000 (20:58 +0300)
committerDaniil Dudkin <unterumarmung@yandex.ru>
Tue, 20 Jun 2023 19:30:09 +0000 (22:30 +0300)
commitf1a040298381cdfc0657d5ecba231ebe6bbef61a
treef0af1ad44a54b35c152b9ba344ea104bc0502725
parent0ce2ce2a47c7f71dbbcae3c8bb5604395926c85c
[mlir][irdl] Add `irdl.attributes` operation for defining named attributes

This commit introduces the `irdl.attributes` operation, which allows defining named attributes for the parent operation. Each attribute is defined with a name and a type constraint.

Example usage:
```
irdl.dialect @example {
  irdl.operation @attr_op {
    %0 = irdl.any
    %1 = irdl.is i64
    irdl.attributes {
      "attr1" = %0,
      "attr2" = %1
    }
  }
}
```
In this example the operation will expect an arbitrary attribute "attr1"
and an attribute "attr2" with value `i64`.

Reviewed By: math-fehr, Mogball

Differential Revision: https://reviews.llvm.org/D152618
mlir/include/mlir/Dialect/IRDL/IR/IRDLOps.td
mlir/lib/Dialect/IRDL/IR/IRDL.cpp
mlir/lib/Dialect/IRDL/IRDLLoading.cpp
mlir/test/Dialect/IRDL/attributes-op.irdl.mlir [new file with mode: 0644]
mlir/test/Dialect/IRDL/testd.irdl.mlir
mlir/test/Dialect/IRDL/testd.mlir