[PATCH] D35882: [TargetParser] Use enum classes for various ARM kind enums.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 26 02:29:17 PDT 2017


fhahn created this revision.
Herald added subscribers: kristof.beyls, aemerson.

Using c++11 enum classes ensures that only valid enum values are used
for ArchKind, ProfileKind, VersionKind and ISAKind. This removes the
need for checks that the provided values map to a proper enum value,
allows us to get rid of AK_LAST and prevents comparing values from
different enums. It also removes a bunch of static_cast
from unsigned to enum values and vice versa, at the cost of introducing
static casts to access AArch64ARCHNames and ARMARCHNames by ArchKind.

FPUKind and ArchExtKind are the only remaining old-style enum in
TargetParser.h. I think it's beneficial to keep ArchExtKind as old-style
enum, but FPUKind can be converted too, but this patch is quite big, so
could do this in a follow-up patch. I could also split this patch up a
bit, if people would prefer that.


https://reviews.llvm.org/D35882

Files:
  include/llvm/MC/MCStreamer.h
  include/llvm/Support/AArch64TargetParser.def
  include/llvm/Support/ARMTargetParser.def
  include/llvm/Support/TargetParser.h
  lib/Support/TargetParser.cpp
  lib/Support/Triple.cpp
  lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  lib/Target/ARM/ARMSubtarget.cpp
  lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
  lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
  lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
  lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp
  unittests/Support/TargetParserTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35882.108238.patch
Type: text/x-patch
Size: 94239 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170726/ec3bc271/attachment.bin>


More information about the llvm-commits mailing list