[TableGen] Generating enum definitions and utility functions
authorLei Zhang <antiagainst@google.com>
Sat, 8 Jun 2019 15:39:07 +0000 (08:39 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Sun, 9 Jun 2019 23:24:08 +0000 (16:24 -0700)
commit1be9fc66115de245f469e3b09114a06603258ce0
tree01073dfc7b312c06db890db09fa894007806cf2c
parentb0ee20f9245e9b4abd62149036f6cc961dfaa8ff
[TableGen] Generating enum definitions and utility functions

Enum attributes can be defined using `EnumAttr`, which requires all its cases
to be defined with `EnumAttrCase`. To facilitate the interaction between
`EnumAttr`s and their C++ consumers, add a new EnumsGen TableGen backend
to generate a few common utilities, including an enum class, `llvm::DenseMapInfo`
for the enum class, conversion functions from/to strings.

This is controlled via the `-gen-enum-decls` and `-gen-enum-defs` command-line
options of `mlir-tblgen`.

PiperOrigin-RevId: 252209623
mlir/g3doc/OpDefinitions.md
mlir/include/mlir/IR/OpBase.td
mlir/include/mlir/TableGen/Attribute.h
mlir/lib/TableGen/Attribute.cpp
mlir/tools/mlir-tblgen/CMakeLists.txt
mlir/tools/mlir-tblgen/EnumsGen.cpp [new file with mode: 0644]
mlir/unittests/TableGen/CMakeLists.txt
mlir/unittests/TableGen/EnumsGenTest.cpp [new file with mode: 0644]
mlir/unittests/TableGen/enums.td [new file with mode: 0644]