[all-commits] [llvm/llvm-project] 8c39e7: [mlir][OpFormatGen] Add support for eliding UnitAt...

River Riddle via All-commits all-commits at lists.llvm.org
Mon Aug 3 14:32:09 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 8c39e70679e93da3af9f881d314940c570d5d822
      https://github.com/llvm/llvm-project/commit/8c39e70679e93da3af9f881d314940c570d5d822
  Author: River Riddle <riddleriver at gmail.com>
  Date:   2020-08-03 (Mon, 03 Aug 2020)

  Changed paths:
    M mlir/docs/OpDefinitions.md
    M mlir/test/lib/Dialect/Test/TestOps.td
    M mlir/test/mlir-tblgen/op-format.mlir
    M mlir/tools/mlir-tblgen/OpFormatGen.cpp

  Log Message:
  -----------
  [mlir][OpFormatGen] Add support for eliding UnitAttr when used to anchor an optional group

Unit attributes are given meaning by their existence, and thus have no meaningful value beyond "is it present". As such, in the format of an operation unit attributes are generally used to guard the printing of other elements and aren't generally printed themselves; as the presence of the group when parsing means that the unit attribute should be added. This revision adds support to the declarative format for eliding unit attributes in situations where they anchor an optional group, but aren't the first element.

For example,
```
let assemblyFormat = "(`is_optional` $unit_attr^)? attr-dict";
```

would print `foo.op is_optional` when $unit_attr is present, instead of the current `foo.op is_optional unit`.

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




More information about the All-commits mailing list