llvm-project/mlir
River Riddle 2d0477a003 [mlir][DeclarativeParser] Add basic support for optional groups in the assembly format.
When operations have optional attributes, or optional operands(i.e. empty variadic operands), the assembly format often has an optional section to represent these arguments. This revision adds basic support for defining an "optional group" in the assembly format to support this. An optional group is defined by wrapping a set of elements in `()` followed by `?` and requires the following:

* The first element of the group must be either a literal or an operand argument.
  - This is because the first element must be optionally parsable.
* There must be exactly one argument variable within the group that is marked as the anchor of the group. The anchor is the element whose presence controls whether the group should be printed/parsed. An element is marked as the anchor by adding a trailing `^`.
* The group must only contain literals, variables, and type directives.
  - Any attribute variables may be used, but only optional attributes can be marked as the anchor.
  - Only variadic, i.e. optional, operand arguments can be used.
  - The elements of a type directive must be defined within the same optional group.

An example of this can be seen with the assembly format for ReturnOp, which has a variadic number of operands.

```
def ReturnOp : ... {
  let arguments = (ins Variadic<AnyType>:$operands);

  // We only print the operands+types if there are a non-zero number
  // of operands.
  let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
}
```

Differential Revision: https://reviews.llvm.org/D74681
2020-02-21 15:15:31 -08:00
..
cmake/modules [MLIR] Fixes for shared library dependencies. 2020-02-04 08:56:37 -08:00
docs [mlir][DeclarativeParser] Add basic support for optional groups in the assembly format. 2020-02-21 15:15:31 -08:00
examples Move StandardOps/Ops.h to StandardOps/IR/Ops.h 2020-02-21 11:58:47 -08:00
include [mlir][DeclarativeParser] Add basic support for optional groups in the assembly format. 2020-02-21 15:15:31 -08:00
lib [mlir][DeclarativeParser] Add basic support for optional groups in the assembly format. 2020-02-21 15:15:31 -08:00
test [mlir][DeclarativeParser] Add basic support for optional groups in the assembly format. 2020-02-21 15:15:31 -08:00
tools [mlir][DeclarativeParser] Add basic support for optional groups in the assembly format. 2020-02-21 15:15:31 -08:00
unittests Support OptionalAttr inside a StructAttr 2020-02-19 12:47:04 +00:00
utils [mlir][spirv] Support implied extensions and capabilities 2020-01-17 08:01:57 -05:00
.clang-format [mlir] add .clang-format 2019-03-29 12:41:43 -07:00
.clang-tidy Add a clang-tidy configuration file for MLIR, it is using camelBack for naming at the moment 2019-12-26 21:42:01 +00:00
CMakeLists.txt [mlir][spirv] Add mlir-vulkan-runner 2020-02-19 11:37:26 -05:00
LICENSE.TXT Add the Apache2 with LLVM exceptions license to MLIR 2019-12-24 00:58:06 -08:00
README.md mlir README.md: Fix the syntax 2019-12-24 13:31:07 +01:00

README.md

Multi-Level Intermediate Representation

See https://mlir.llvm.org/ for more information.