[all-commits] [llvm/llvm-project] 607f14: [mlir][ods] Add ArrayOfAttr for creating custom ar...

Jeff Niu via All-commits all-commits at lists.llvm.org
Fri Sep 2 11:13:16 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 607f14d9605da801034e7119c297c3f58ebce603
      https://github.com/llvm/llvm-project/commit/607f14d9605da801034e7119c297c3f58ebce603
  Author: Jeff Niu <jeff at modular.com>
  Date:   2022-09-02 (Fri, 02 Sep 2022)

  Changed paths:
    M mlir/include/mlir/IR/AttrTypeBase.td
    A mlir/test/IR/array-of-attr.mlir
    M mlir/test/lib/Dialect/Test/TestAttrDefs.td
    M mlir/test/lib/Dialect/Test/TestOps.td

  Log Message:
  -----------
  [mlir][ods] Add ArrayOfAttr for creating custom array attributes

`ArrayOfAttr` can be used to easily create an attribute that just
contains an array of something. The elements can be other attributes,
in which case the custom parsers and printers are invoked directly for
nice syntax, or any C++ type that supports parsing and printing, either
though custom `printer` and `parser` methods or `FieldParser`.

An array of integers:

```
def ArrayOfInts : ArrayOfAttr<Test_Dialect, "ArrayOfInts", "array_of_ints",
                              "int32_t">;
```

When embedded in an op's assembly format, it will look like

```
foo.ints value = [1, 2, 3]
```

An array of enums, when embedded in an op's assembly format, will look
like:

```
foo.enums value = [first, second, last]
```

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D133131




More information about the All-commits mailing list