[mlir] EnumsGen: dissociate string form of integer enum from C++ symbol name
authorAlex Zinenko <zinenko@google.com>
Fri, 24 Jan 2020 16:51:10 +0000 (17:51 +0100)
committerAlex Zinenko <zinenko@google.com>
Thu, 30 Jan 2020 16:04:00 +0000 (17:04 +0100)
commitfdc496a3d30d2d82814965a6aa987b7ef0b136ef
treef9f228b24cdd2ae73812da7e4f23309af4ceeea5
parent3bbe7a681e0f98182daf268a314d1372073ea019
[mlir] EnumsGen: dissociate string form of integer enum from C++ symbol name

Summary:
In some cases, one may want to use different names for C++ symbol of an
enumerand from its string representation. In particular, in the LLVM dialect
for, e.g., Linkage, we would like to preserve the same enumerand names as LLVM
API and the same textual IR form as LLVM IR, yet the two are different
(CamelCase vs snake_case with additional limitations on not being a C++
keyword).

Modify EnumAttrCaseInfo in OpBase.td to include both the integer value and its
string representation. By default, this representation is the same as C++
symbol name. Introduce new IntStrAttrCaseBase that allows one to use different
names. Exercise it for LLVM Dialect Linkage attribute. Other attributes will
follow as separate changes.

Differential Revision: https://reviews.llvm.org/D73362
mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/include/mlir/IR/OpBase.td
mlir/include/mlir/TableGen/Attribute.h
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/TableGen/Attribute.cpp
mlir/tools/mlir-tblgen/EnumsGen.cpp
mlir/unittests/TableGen/EnumsGenTest.cpp
mlir/unittests/TableGen/enums.td