#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ARMBuildAttributes.h"
+#include "llvm/Support/ARMTargetParserCommon.h"
#include <vector>
namespace llvm {
Crypto ///< Neon with Crypto
};
-// ISA kinds.
-enum class ISAKind { INVALID = 0, ARM, THUMB, AARCH64 };
-
-// Endianness
-// FIXME: BE8 vs. BE32?
-enum class EndianKind { INVALID = 0, LITTLE, BIG };
-
// v6/v7/v8 Profile
enum class ProfileKind { INVALID = 0, A, R, M };
}
};
-static const ArchNames<ArchKind> ARCHNames[] = {
+static const ArchNames<ArchKind> ARMArchNames[] = {
#define ARM_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, \
ARCH_BASE_EXT) \
{NAME, sizeof(NAME) - 1, \
ArchKind parseArch(StringRef Arch);
uint64_t parseArchExt(StringRef ArchExt);
ArchKind parseCPUArch(StringRef CPU);
-ISAKind parseArchISA(StringRef Arch);
-EndianKind parseArchEndian(StringRef Arch);
ProfileKind parseArchProfile(StringRef Arch);
unsigned parseArchVersion(StringRef Arch);
ARM::ArchKind ARM::parseArch(StringRef Arch) {
Arch = getCanonicalArchName(Arch);
StringRef Syn = getArchSynonym(Arch);
- for (const auto &A : ARCHNames) {
+ for (const auto &A : ARMArchNames) {
if (A.getName().endswith(Syn))
return A.ID;
}
return true;
}
-// Little/Big endian
-ARM::EndianKind ARM::parseArchEndian(StringRef Arch) {
- if (Arch.startswith("armeb") || Arch.startswith("thumbeb") ||
- Arch.startswith("aarch64_be"))
- return EndianKind::BIG;
-
- if (Arch.startswith("arm") || Arch.startswith("thumb")) {
- if (Arch.endswith("eb"))
- return EndianKind::BIG;
- else
- return EndianKind::LITTLE;
- }
-
- if (Arch.startswith("aarch64") || Arch.startswith("aarch64_32"))
- return EndianKind::LITTLE;
-
- return EndianKind::INVALID;
-}
-
-// ARM, Thumb, AArch64
-ARM::ISAKind ARM::parseArchISA(StringRef Arch) {
- return StringSwitch<ISAKind>(Arch)
- .StartsWith("aarch64", ISAKind::AARCH64)
- .StartsWith("arm64", ISAKind::AARCH64)
- .StartsWith("thumb", ISAKind::THUMB)
- .StartsWith("arm", ISAKind::ARM)
- .Default(ISAKind::INVALID);
-}
-
unsigned ARM::parseFPU(StringRef FPU) {
StringRef Syn = getFPUSynonym(FPU);
for (const auto &F : FPUNames) {
unsigned ARM::getDefaultFPU(StringRef CPU, ARM::ArchKind AK) {
if (CPU == "generic")
- return ARM::ARCHNames[static_cast<unsigned>(AK)].DefaultFPU;
+ return ARM::ARMArchNames[static_cast<unsigned>(AK)].DefaultFPU;
return StringSwitch<unsigned>(CPU)
#define ARM_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
uint64_t ARM::getDefaultExtensions(StringRef CPU, ARM::ArchKind AK) {
if (CPU == "generic")
- return ARM::ARCHNames[static_cast<unsigned>(AK)].ArchBaseExtensions;
+ return ARM::ARMArchNames[static_cast<unsigned>(AK)].ArchBaseExtensions;
return StringSwitch<uint64_t>(CPU)
#define ARM_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
.Case(NAME, \
- ARCHNames[static_cast<unsigned>(ArchKind::ID)].ArchBaseExtensions | \
+ ARMArchNames[static_cast<unsigned>(ArchKind::ID)].ArchBaseExtensions | \
DEFAULT_EXT)
#include "llvm/Support/ARMTargetParser.def"
.Default(ARM::AEK_INVALID);
}
StringRef ARM::getArchName(ARM::ArchKind AK) {
- return ARCHNames[static_cast<unsigned>(AK)].getName();
+ return ARMArchNames[static_cast<unsigned>(AK)].getName();
}
StringRef ARM::getCPUAttr(ARM::ArchKind AK) {
- return ARCHNames[static_cast<unsigned>(AK)].getCPUAttr();
+ return ARMArchNames[static_cast<unsigned>(AK)].getCPUAttr();
}
StringRef ARM::getSubArch(ARM::ArchKind AK) {
- return ARCHNames[static_cast<unsigned>(AK)].getSubArch();
+ return ARMArchNames[static_cast<unsigned>(AK)].getSubArch();
}
unsigned ARM::getArchAttr(ARM::ArchKind AK) {
- return ARCHNames[static_cast<unsigned>(AK)].ArchAttr;
+ return ARMArchNames[static_cast<unsigned>(AK)].ArchAttr;
}
StringRef ARM::getArchExtName(uint64_t ArchExtKind) {
// Arch will either be a 'v' name (v7a) or a marketing name (xscale).
return A;
}
+
+ARM::ISAKind ARM::parseArchISA(StringRef Arch) {
+ return StringSwitch<ISAKind>(Arch)
+ .StartsWith("aarch64", ISAKind::AARCH64)
+ .StartsWith("arm64", ISAKind::AARCH64)
+ .StartsWith("thumb", ISAKind::THUMB)
+ .StartsWith("arm", ISAKind::ARM)
+ .Default(ISAKind::INVALID);
+}
+
+ARM::EndianKind ARM::parseArchEndian(StringRef Arch) {
+ if (Arch.startswith("armeb") || Arch.startswith("thumbeb") ||
+ Arch.startswith("aarch64_be"))
+ return EndianKind::BIG;
+
+ if (Arch.startswith("arm") || Arch.startswith("thumb")) {
+ if (Arch.endswith("eb"))
+ return EndianKind::BIG;
+ else
+ return EndianKind::LITTLE;
+ }
+
+ if (Arch.startswith("aarch64") || Arch.startswith("aarch64_32"))
+ return EndianKind::LITTLE;
+
+ return EndianKind::INVALID;
+}