[PATCH] D14648: NFC refactorings in lib/Support/TargetParser.cpp
A. Skrobov via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 13 03:50:02 PST 2015
tyomitch created this revision.
tyomitch added a reviewer: rengolin.
tyomitch added a subscriber: llvm-commits.
* declare FPUNames, ARCHNames, ARCHExtNames, HWDivNames, CPUNames
as static const
* implement getDefaultExtensions with a StringSwitch, in the same
way getDefaultFPU is implemented
http://reviews.llvm.org/D14648
Files:
lib/Support/TargetParser.cpp
Index: lib/Support/TargetParser.cpp
===================================================================
--- lib/Support/TargetParser.cpp
+++ lib/Support/TargetParser.cpp
@@ -27,7 +27,7 @@
// features they correspond to (use getFPUFeatures).
// FIXME: TableGen this.
// The entries must appear in the order listed in ARM::FPUKind for correct indexing
-struct {
+static const struct {
const char *NameCStr;
size_t NameLength;
ARM::FPUKind ID;
@@ -50,7 +50,7 @@
// of the triples and are not conforming with their official names.
// Check to see if the expectation should be changed.
// FIXME: TableGen this.
-struct {
+static const struct {
const char *NameCStr;
size_t NameLength;
ARM::ArchKind ID;
@@ -77,7 +77,7 @@
// List of Arch Extension names.
// FIXME: TableGen this.
-struct {
+static const struct {
const char *NameCStr;
size_t NameLength;
unsigned ID;
@@ -91,7 +91,7 @@
// List of HWDiv names (use getHWDivSynonym) and which architectural
// features they correspond to (use getHWDivFeatures).
// FIXME: TableGen this.
-struct {
+static const struct {
const char *NameCStr;
size_t NameLength;
unsigned ID;
@@ -107,7 +107,7 @@
// When finding the Arch for a CPU, first-found prevails. Sort them accordingly.
// When this becomes table-generated, we'd probably need two tables.
// FIXME: TableGen this.
-struct {
+static const struct {
const char *NameCStr;
size_t NameLength;
ARM::ArchKind ArchID;
@@ -159,6 +159,14 @@
.Default(ARM::FK_INVALID);
}
+unsigned llvm::ARM::getDefaultExtensions(StringRef CPU) {
+ return StringSwitch<unsigned>(CPU)
+#define ARM_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
+ .Case(NAME, ARCHNames[ID].ArchBaseExtensions | DEFAULT_EXT)
+#include "llvm/Support/ARMTargetParser.def"
+ .Default(ARM::AEK_INVALID);
+}
+
bool llvm::ARM::getHWDivFeatures(unsigned HWDivKind,
std::vector<const char *> &Features) {
@@ -319,14 +327,6 @@
return StringRef();
}
-unsigned llvm::ARM::getDefaultExtensions(StringRef CPU) {
- for (const auto C : CPUNames) {
- if (CPU == C.getName())
- return (ARCHNames[C.ArchID].ArchBaseExtensions | C.DefaultExtensions);
- }
- return ARM::AEK_INVALID;
-}
-
StringRef llvm::ARM::getDefaultCPU(StringRef Arch) {
unsigned AK = parseArch(Arch);
if (AK == ARM::AK_INVALID)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14648.40134.patch
Type: text/x-patch
Size: 2377 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151113/189e5332/attachment.bin>
More information about the llvm-commits
mailing list