llvm-project/mlir/lib
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
..
Analysis Move StandardOps/Ops.h to StandardOps/IR/Ops.h 2020-02-21 11:58:47 -08:00
Conversion Move StandardOps/Ops.h to StandardOps/IR/Ops.h 2020-02-21 11:58:47 -08:00
Dialect [mlir][DeclarativeParser] Add basic support for optional groups in the assembly format. 2020-02-21 15:15:31 -08:00
EDSC [mlir][EDSC] Almost NFC - Refactor and untangle EDSC dependencies 2020-02-10 12:10:41 -05:00
ExecutionEngine [mlir] Use LLJIT::getMainJITDylib instead of hardcoding '<main>' 2020-02-20 14:19:34 -08:00
IR [mlir] Silence error: call to constructor of 'llvm::APInt' is ambiguous 2020-02-21 10:06:04 -05:00
Parser [MLIR] Allow Loop dialect IfOp and ForOp to define values 2020-02-21 10:05:32 -08:00
Pass Hide implementation details. NFC> 2020-02-17 17:55:23 +01:00
Quantizer Move StandardOps/Ops.h to StandardOps/IR/Ops.h 2020-02-21 11:58:47 -08:00
Support Remove static registration for dialects, and the "alwayslink" hack for passes 2020-02-12 09:13:02 +00:00
TableGen [mlir] Allow adding extra class declarations to interfaces. 2020-02-15 23:54:42 -08:00
Target [mlir] Add explicit friendship to LLVM::ModuleTranslation to derived 2020-02-05 18:34:44 -08:00
Transforms Move StandardOps/Ops.h to StandardOps/IR/Ops.h 2020-02-21 11:58:47 -08:00
Translation Mass update the MLIR license header to mention "Part of the LLVM project" 2020-01-26 03:58:30 +00:00
CMakeLists.txt NFC: Move AffineOps dialect to the Dialect sub-directory. 2019-08-20 15:36:39 -07:00