From fbbc259e379d6a5f7401ab2d686157728c63ed78 Mon Sep 17 00:00:00 2001 From: Bradley Smith Date: Wed, 18 Nov 2015 16:32:12 +0000 Subject: [PATCH] [ARM] Add +feature names to TargetParser extensions table git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253470 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/ARMTargetParser.def | 33 ++++++++++++------------ include/llvm/Support/TargetParser.h | 1 + lib/Support/TargetParser.cpp | 18 ++++++++++++- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/include/llvm/Support/ARMTargetParser.def b/include/llvm/Support/ARMTargetParser.def index 27cfb0d9e5e..3a72842145b 100644 --- a/include/llvm/Support/ARMTargetParser.def +++ b/include/llvm/Support/ARMTargetParser.def @@ -104,23 +104,24 @@ ARM_ARCH("armv7k", AK_ARMV7K, "7-K", "v7k", ARMBuildAttrs::CPUArch::v7, #undef ARM_ARCH #ifndef ARM_ARCH_EXT_NAME -#define ARM_ARCH_EXT_NAME(NAME, ID) +#define ARM_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE) #endif -ARM_ARCH_EXT_NAME("invalid", AEK_INVALID) -ARM_ARCH_EXT_NAME("none", AEK_NONE) -ARM_ARCH_EXT_NAME("crc", AEK_CRC) -ARM_ARCH_EXT_NAME("crypto", AEK_CRYPTO) -ARM_ARCH_EXT_NAME("fp", AEK_FP) -ARM_ARCH_EXT_NAME("idiv", (AEK_HWDIVARM | AEK_HWDIV)) -ARM_ARCH_EXT_NAME("mp", AEK_MP) -ARM_ARCH_EXT_NAME("simd", AEK_SIMD) -ARM_ARCH_EXT_NAME("sec", AEK_SEC) -ARM_ARCH_EXT_NAME("virt", AEK_VIRT) -ARM_ARCH_EXT_NAME("os", AEK_OS) -ARM_ARCH_EXT_NAME("iwmmxt", AEK_IWMMXT) -ARM_ARCH_EXT_NAME("iwmmxt2", AEK_IWMMXT2) -ARM_ARCH_EXT_NAME("maverick", AEK_MAVERICK) -ARM_ARCH_EXT_NAME("xscale", AEK_XSCALE) +// FIXME: This would be nicer were it tablegen +ARM_ARCH_EXT_NAME("invalid", AEK_INVALID, nullptr, nullptr) +ARM_ARCH_EXT_NAME("none", AEK_NONE, nullptr, nullptr) +ARM_ARCH_EXT_NAME("crc", AEK_CRC, "+crc", "-crc") +ARM_ARCH_EXT_NAME("crypto", AEK_CRYPTO, "+crypto","-crypto") +ARM_ARCH_EXT_NAME("fp", AEK_FP, nullptr, nullptr) +ARM_ARCH_EXT_NAME("idiv", (AEK_HWDIVARM | AEK_HWDIV), nullptr, nullptr) +ARM_ARCH_EXT_NAME("mp", AEK_MP, nullptr, nullptr) +ARM_ARCH_EXT_NAME("simd", AEK_SIMD, nullptr, nullptr) +ARM_ARCH_EXT_NAME("sec", AEK_SEC, nullptr, nullptr) +ARM_ARCH_EXT_NAME("virt", AEK_VIRT, nullptr, nullptr) +ARM_ARCH_EXT_NAME("os", AEK_OS, nullptr, nullptr) +ARM_ARCH_EXT_NAME("iwmmxt", AEK_IWMMXT, nullptr, nullptr) +ARM_ARCH_EXT_NAME("iwmmxt2", AEK_IWMMXT2, nullptr, nullptr) +ARM_ARCH_EXT_NAME("maverick", AEK_MAVERICK, nullptr, nullptr) +ARM_ARCH_EXT_NAME("xscale", AEK_XSCALE, nullptr, nullptr) #undef ARM_ARCH_EXT_NAME #ifndef ARM_HW_DIV_NAME diff --git a/include/llvm/Support/TargetParser.h b/include/llvm/Support/TargetParser.h index 216b4e8f32c..6ca0281515e 100644 --- a/include/llvm/Support/TargetParser.h +++ b/include/llvm/Support/TargetParser.h @@ -119,6 +119,7 @@ unsigned getArchAttr(unsigned ArchKind); StringRef getCPUAttr(unsigned ArchKind); StringRef getSubArch(unsigned ArchKind); StringRef getArchExtName(unsigned ArchExtKind); +const char *getArchExtFeature(StringRef ArchExt); StringRef getHWDivName(unsigned HWDivKind); // Information by Name diff --git a/lib/Support/TargetParser.cpp b/lib/Support/TargetParser.cpp index a57b48f8a4e..213275ab009 100644 --- a/lib/Support/TargetParser.cpp +++ b/lib/Support/TargetParser.cpp @@ -16,6 +16,7 @@ #include "llvm/Support/TargetParser.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" +#include "llvm/ADT/Twine.h" #include using namespace llvm; @@ -82,10 +83,14 @@ static const struct { const char *NameCStr; size_t NameLength; unsigned ID; + const char *Feature; + const char *NegFeature; StringRef getName() const { return StringRef(NameCStr, NameLength); } + StringRef getNegName() const { return (Twine("no") + getName()).str(); } } ARCHExtNames[] = { -#define ARM_ARCH_EXT_NAME(NAME, ID) { NAME, sizeof(NAME) - 1, ID }, +#define ARM_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE) \ + { NAME, sizeof(NAME) - 1, ID, FEATURE, NEGFEATURE }, #include "llvm/Support/ARMTargetParser.def" }; @@ -326,6 +331,17 @@ StringRef llvm::ARM::getArchExtName(unsigned ArchExtKind) { return StringRef(); } +const char *llvm::ARM::getArchExtFeature(StringRef ArchExt) { + for (const auto AE : ARCHExtNames) { + if (AE.Feature && ArchExt == AE.getName()) + return AE.Feature; + else if (AE.NegFeature && ArchExt == AE.getNegName()) + return AE.NegFeature; + } + + return nullptr; +} + StringRef llvm::ARM::getHWDivName(unsigned HWDivKind) { for (const auto D : HWDivNames) { if (HWDivKind == D.ID) -- 2.34.1