[PATCH] D122832: [TableGen] Add a backend to help with target enums
Fraser Cormack via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 31 09:25:12 PDT 2022
frasercrmck created this revision.
frasercrmck added reviewers: RKSimon, craig.topper, Paul-C-Anagnostopoulos.
Herald added subscribers: luke957, StephenFan, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, mgrang, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, arichardson, mgorny.
Herald added a project: All.
frasercrmck requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, MaskRay.
Herald added a project: LLVM.
This patch adds a TableGen backend which aims to help keep enums and
their values in sync between TableGen and C++. Previously enums would be
defined separately, usually with a comment to the effect of "must be
kept in sync with XXX".
Enumerators can be individually defined with or without values. Enums
can be given underling types and be optionally declared as enum classes.
Support is also present for automatically converting enums to/from
string values, using custom string values if desired.
The backend operates on two new basic classes: Enum and EnumMember,
which are fairly self-explanatory.
Although almost every (if not all) backends could likely stand to
benefit from this enum support to some extent, only a handful of RISC-V
enums have been converted to use this new support, both as a proof of
concept and to avoid bloating the patch.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D122832
Files:
llvm/include/llvm/Target/Target.td
llvm/lib/Target/RISCV/CMakeLists.txt
llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
llvm/lib/Target/RISCV/RISCVInstrFormats.td
llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
llvm/test/TableGen/EnumEmitter.td
llvm/test/TableGen/EnumEmitterInvalid.td
llvm/utils/TableGen/CMakeLists.txt
llvm/utils/TableGen/EnumEmitter.cpp
llvm/utils/TableGen/TableGen.cpp
llvm/utils/TableGen/TableGenBackends.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122832.419497.patch
Type: text/x-patch
Size: 21257 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220331/6c3185b2/attachment.bin>
More information about the llvm-commits
mailing list