[Triple] Use clang-format to normalize the formatting of the ARM target

parsing logic prior to making substantial changes to it.

This parsing logic is incredibly wasteful, so I'm planning to rewrite
it. Just unittesting the triple parsing logic spends well over 80% of
its time in the ARM parsing logic, and others have measured significant
time spent here in real production compiles.

Stay tuned...

llvm-svn: 246369
This commit is contained in:
Chandler Carruth 2015-08-30 02:17:15 +00:00
parent aa0caeb431
commit 4fc3a9862c
2 changed files with 178 additions and 193 deletions

View File

@ -20,7 +20,7 @@
#include <vector>
namespace llvm {
class StringRef;
class StringRef;
// Target specific information into their own namespaces. These should be
// generated from TableGen because the information is already there, and there
@ -29,8 +29,9 @@ namespace llvm {
// even if the back-end is not compiled with LLVM, plus we need to create a new
// back-end to TableGen to create these clean tables.
namespace ARM {
// FPU names.
enum FPUKind {
// FPU names.
enum FPUKind {
FK_INVALID = 0,
FK_NONE,
FK_VFP,
@ -54,34 +55,34 @@ namespace ARM {
FK_CRYPTO_NEON_FP_ARMV8,
FK_SOFTVFP,
FK_LAST
};
};
// FPU Version
enum FPUVersion {
// FPU Version
enum FPUVersion {
FV_NONE = 0,
FV_VFPV2,
FV_VFPV3,
FV_VFPV3_FP16,
FV_VFPV4,
FV_VFPV5
};
};
// An FPU name implies one of three levels of Neon support:
enum NeonSupportLevel {
// An FPU name implies one of three levels of Neon support:
enum NeonSupportLevel {
NS_None = 0, ///< No Neon
NS_Neon, ///< Neon
NS_Crypto ///< Neon with Crypto
};
};
// An FPU name restricts the FPU in one of three ways:
enum FPURestriction {
// An FPU name restricts the FPU in one of three ways:
enum FPURestriction {
FR_None = 0, ///< No restriction
FR_D16, ///< Only 16 D registers
FR_SP_D16 ///< Only single-precision instructions, with 16 D registers
};
};
// Arch names.
enum ArchKind {
// Arch names.
enum ArchKind {
AK_INVALID = 0,
AK_ARMV2,
AK_ARMV2A,
@ -119,10 +120,10 @@ namespace ARM {
AK_ARMV7S,
AK_ARMV7K,
AK_LAST
};
};
// Arch extension modifiers for CPUs.
enum ArchExtKind : unsigned {
// Arch extension modifiers for CPUs.
enum ArchExtKind : unsigned {
AEK_INVALID = 0x0,
AEK_NONE = 0x1,
AEK_CRC = 0x2,
@ -140,62 +141,47 @@ namespace ARM {
AEK_IWMMXT2 = 0x20000000,
AEK_MAVERICK = 0x40000000,
AEK_XSCALE = 0x80000000,
};
};
// ISA kinds.
enum ISAKind {
IK_INVALID = 0,
IK_ARM,
IK_THUMB,
IK_AARCH64
};
// ISA kinds.
enum ISAKind { IK_INVALID = 0, IK_ARM, IK_THUMB, IK_AARCH64 };
// Endianness
// FIXME: BE8 vs. BE32?
enum EndianKind {
EK_INVALID = 0,
EK_LITTLE,
EK_BIG
};
// Endianness
// FIXME: BE8 vs. BE32?
enum EndianKind { EK_INVALID = 0, EK_LITTLE, EK_BIG };
// v6/v7/v8 Profile
enum ProfileKind {
PK_INVALID = 0,
PK_A,
PK_R,
PK_M
};
// v6/v7/v8 Profile
enum ProfileKind { PK_INVALID = 0, PK_A, PK_R, PK_M };
StringRef getCanonicalArchName(StringRef Arch);
StringRef getCanonicalArchName(StringRef Arch);
// Information by ID
const char * getFPUName(unsigned FPUKind);
unsigned getFPUVersion(unsigned FPUKind);
unsigned getFPUNeonSupportLevel(unsigned FPUKind);
unsigned getFPURestriction(unsigned FPUKind);
unsigned getDefaultFPU(StringRef CPU);
// FIXME: This should be moved to TargetTuple once it exists
bool getFPUFeatures(unsigned FPUKind, std::vector<const char *> &Features);
bool getHWDivFeatures(unsigned HWDivKind,
std::vector<const char *> &Features);
const char *getArchName(unsigned ArchKind);
unsigned getArchAttr(unsigned ArchKind);
const char *getCPUAttr(unsigned ArchKind);
const char *getSubArch(unsigned ArchKind);
const char *getArchExtName(unsigned ArchExtKind);
const char *getHWDivName(unsigned HWDivKind);
const char *getDefaultCPU(StringRef Arch);
// Information by ID
const char *getFPUName(unsigned FPUKind);
unsigned getFPUVersion(unsigned FPUKind);
unsigned getFPUNeonSupportLevel(unsigned FPUKind);
unsigned getFPURestriction(unsigned FPUKind);
unsigned getDefaultFPU(StringRef CPU);
// FIXME: This should be moved to TargetTuple once it exists
bool getFPUFeatures(unsigned FPUKind, std::vector<const char *> &Features);
bool getHWDivFeatures(unsigned HWDivKind, std::vector<const char *> &Features);
const char *getArchName(unsigned ArchKind);
unsigned getArchAttr(unsigned ArchKind);
const char *getCPUAttr(unsigned ArchKind);
const char *getSubArch(unsigned ArchKind);
const char *getArchExtName(unsigned ArchExtKind);
const char *getHWDivName(unsigned HWDivKind);
const char *getDefaultCPU(StringRef Arch);
// Parser
unsigned parseHWDiv(StringRef HWDiv);
unsigned parseFPU(StringRef FPU);
unsigned parseArch(StringRef Arch);
unsigned parseArchExt(StringRef ArchExt);
unsigned parseCPUArch(StringRef CPU);
unsigned parseArchISA(StringRef Arch);
unsigned parseArchEndian(StringRef Arch);
unsigned parseArchProfile(StringRef Arch);
unsigned parseArchVersion(StringRef Arch);
// Parser
unsigned parseHWDiv(StringRef HWDiv);
unsigned parseFPU(StringRef FPU);
unsigned parseArch(StringRef Arch);
unsigned parseArchExt(StringRef ArchExt);
unsigned parseCPUArch(StringRef CPU);
unsigned parseArchISA(StringRef Arch);
unsigned parseArchEndian(StringRef Arch);
unsigned parseArchProfile(StringRef Arch);
unsigned parseArchVersion(StringRef Arch);
} // namespace ARM
} // namespace llvm

View File

@ -495,7 +495,7 @@ StringRef llvm::ARM::getCanonicalArchName(StringRef Arch) {
// AArch64 uses "_be", not "eb" suffix.
if (A.find("eb") != StringRef::npos)
return Error;
if (A.substr(offset,3) == "_be")
if (A.substr(offset, 3) == "_be")
offset += 3;
}
@ -584,8 +584,7 @@ unsigned llvm::ARM::parseArchISA(StringRef Arch) {
// Little/Big endian
unsigned llvm::ARM::parseArchEndian(StringRef Arch) {
if (Arch.startswith("armeb") ||
Arch.startswith("thumbeb") ||
if (Arch.startswith("armeb") || Arch.startswith("thumbeb") ||
Arch.startswith("aarch64_be"))
return ARM::EK_BIG;
@ -605,7 +604,7 @@ unsigned llvm::ARM::parseArchEndian(StringRef Arch) {
// Profile A/R/M
unsigned llvm::ARM::parseArchProfile(StringRef Arch) {
Arch = getCanonicalArchName(Arch);
switch(parseArch(Arch)) {
switch (parseArch(Arch)) {
case ARM::AK_ARMV6M:
case ARM::AK_ARMV7M:
case ARM::AK_ARMV6SM:
@ -626,7 +625,7 @@ unsigned llvm::ARM::parseArchProfile(StringRef Arch) {
// Version number (ex. v7 = 7).
unsigned llvm::ARM::parseArchVersion(StringRef Arch) {
Arch = getCanonicalArchName(Arch);
switch(parseArch(Arch)) {
switch (parseArch(Arch)) {
case ARM::AK_ARMV2:
case ARM::AK_ARMV2A:
return 2;