diff options
author | River Riddle <riddleriver@gmail.com> | 2021-03-22 18:07:09 -0700 |
---|---|---|
committer | River Riddle <riddleriver@gmail.com> | 2021-03-22 18:19:23 -0700 |
commit | 6d6fe9ccc43d23286b764016bc8b5a4a3ab8f675 (patch) | |
tree | 1bb9a5320f871e37164186a43142ad8ae69ee092 /clang/lib/Basic/Module.cpp | |
parent | 0524a09cc7e1a0797982feacf505825231efbee7 (diff) | |
download | llvm-6d6fe9ccc43d23286b764016bc8b5a4a3ab8f675.zip llvm-6d6fe9ccc43d23286b764016bc8b5a4a3ab8f675.tar.gz llvm-6d6fe9ccc43d23286b764016bc8b5a4a3ab8f675.tar.bz2 |
[mlir][OpAsmFormat] Add support for an "else" group on optional elements
The "else" group of an optional element is a collection of elements that get parsed/printed when the anchor of the main element group is *not* present. This is useful when there is a special syntax when an element is not present. The new syntax for an optional element is shown below:
```
optional-group: `(` elements `)` (`:` `(` else-elements `)`)? `?`
```
An example of how this might be used is shown below:
```tablegen
def FooOp : ... {
let arguments = (ins UnitAttr:$foo);
let assemblyFormat = "attr-dict (`foo_is_present` $foo^):(`foo_is_absent`)?";
}
```
would be formatted as such:
```mlir
// When the `foo` attribute is present:
foo.op foo_is_present
// When the `foo` attribute is not present:
foo.op foo_is_absent
```
Differential Revision: https://reviews.llvm.org/D99129
Diffstat (limited to 'clang/lib/Basic/Module.cpp')
0 files changed, 0 insertions, 0 deletions