This revision adds support for assembly formats with optional attributes. It elides optional attributes that are part of the syntax from the attribute dictionary.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
LGTM after fixing the use of curly braces.
mlir/tools/mlir-tblgen/OpFormatGen.cpp | ||
---|---|---|
893 | nit: It could be advisable to use some curly braces for such nested statements. |
mlir/tools/mlir-tblgen/OpFormatGen.cpp | ||
---|---|---|
893 | MLIR is actually quite adamant on the opposite |
mlir/tools/mlir-tblgen/OpFormatGen.cpp | ||
---|---|---|
893 | Interesting. Is there a mention of this in the LLVM coding standards? If not I guess it is mostly up to preference. |
mlir/tools/mlir-tblgen/OpFormatGen.cpp | ||
---|---|---|
893 | It's not in LLVM standards or MLIR fixups to them. In practice, MLIR is aggressive on eliding the braces for single-line one-statement bodies. |
mlir/tools/mlir-tblgen/OpFormatGen.cpp | ||
---|---|---|
893 | Sure, for single-line bodies I totally agree that avoiding the braces can make things more readable. What I was pointing out in the first comment was if (...) for (...) if (...) // ... which I find less readable and potentially more error-prone than if (...) { for (...) { if (...) // ... } } |
mlir/tools/mlir-tblgen/OpFormatGen.cpp | ||
---|---|---|
893 | If there is a single statement body inside the if, we'll go without braces in MLIR in general I believe |
mlir/tools/mlir-tblgen/OpFormatGen.cpp | ||
---|---|---|
893 | This is the style we follow. I generally err on the side of removing "trivial" braces(i.e. 1-2 lines). When they start to span multiple lines it becomes unreadable IMO. @Kayjukh I think your example highlights the style nicely, though in many situations i would also elide the braces around the for. for (...) if (...) // ... |
nit: It could be advisable to use some curly braces for such nested statements.