Page MenuHomePhabricator

[mlir][spirv] Use symbolize functions in enum attribute predicates
ClosedPublic

Authored by antiagainst on Jan 15 2020, 6:07 AM.

Details

Summary

By default, for an enum attribute, we will generate a list of equality
comparisons for all supported cases inside it's predicate. This list
can be fairly large for certain SPIR-V enum attributes. Instead, we
already have such a list generated by EnumsGen in the symbolize
functions. Leverage that to simplify the generated C++ code.

Diff Detail

Event Timeline

antiagainst created this revision.Jan 15 2020, 6:07 AM

Unit tests: pass. 61884 tests passed, 0 failed and 782 were skipped.

clang-tidy: unknown.

clang-format: pass.

Build artifacts: diff.json, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

benvanik requested changes to this revision.Jan 15 2020, 9:14 AM

sybmolize is a typo in the description :)

mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td
2894

optional: it would make this file more readable if this was instead a class; let predicate = I32EnumAttrIsSymbolizable<"SelectionControl"> etc

This revision now requires changes to proceed.Jan 15 2020, 9:14 AM

Address comment

antiagainst marked an inline comment as done.Jan 16 2020, 6:10 AM
antiagainst added inline comments.
mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td
2894

Good point! This stuff can indeed be deduplicated. I created new wrapper classes to set this there to avoid have each enum to have it.

Unit tests: pass. 61912 tests passed, 0 failed and 783 were skipped.

clang-tidy: unknown.

clang-format: pass.

Build artifacts: diff.json, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Address comment

Unit tests: pass. 61912 tests passed, 0 failed and 783 were skipped.

clang-tidy: unknown.

clang-format: pass.

Build artifacts: diff.json, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

benvanik accepted this revision.Jan 16 2020, 7:28 AM

Awesome! I may use that predicate/class in some of my dialects too :)

This revision is now accepted and ready to land.Jan 16 2020, 7:28 AM
This revision was automatically updated to reflect the committed changes.
mehdi_amini retitled this revision from [mlir][spirv] Use sybmolize functions in enum attribute predicates to [mlir][spirv] Use symbolize functions in enum attribute predicates.Jan 16 2020, 7:35 PM