Get Triple::getARMCPUForArch() to use TargetParser

First ARMTargetParser FIXME, conservatively changing the way we parse CPUs
in the back-end. Still not perfect, with a lot of special cases, but moving
towards a more generic solution.

Moving all logic to the target parser made some unwritten assumptions
about architectures in Clang to break. I've added a lot of architectures
required by Clang, and default to CPUs that Clang believes it should
(and I agree).

I've also added a lot of unit tests, with the correct CPU for each
architecture, and Clang seems to be working correctly, too.

It also became clear that using "unsigned ID" as the argument for the get
methods makes it hard to know what ID, so I also changed the argument names
to match the enum type names.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237797 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Renato Golin
2015-05-20 15:05:07 +00:00
parent 5a2d715235
commit 8ca7ac2a38
4 changed files with 367 additions and 115 deletions

View File

@@ -69,8 +69,16 @@ namespace ARM {
AK_ARMV7M,
AK_ARMV8A,
AK_ARMV8_1A,
// Non-standard Arch names.
AK_IWMMXT,
AK_IWMMXT2,
AK_XSCALE,
AK_ARMV5E,
AK_ARMV5TEJ,
AK_ARMV6SM,
AK_ARMV7L,
AK_ARMV7S,
AK_ARMV7EM,
AK_LAST
};
@@ -95,17 +103,21 @@ class ARMTargetParser {
static StringRef getArchSynonym(StringRef Arch);
public:
static StringRef getCanonicalArchName(StringRef Arch);
// Information by ID
static const char * getFPUName(unsigned ID);
static const char * getArchName(unsigned ID);
static unsigned getArchDefaultCPUArch(unsigned ID);
static const char * getArchDefaultCPUName(unsigned ID);
static const char * getArchExtName(unsigned ID);
static const char * getFPUName(unsigned FPUKind);
static const char * getArchName(unsigned ArchKind);
static unsigned getArchDefaultCPUArch(unsigned ArchKind);
static const char * getArchDefaultCPUName(unsigned ArchKind);
static const char * getArchExtName(unsigned ArchExtKind);
static const char * getDefaultCPU(StringRef Arch);
// Parser
static unsigned parseFPU(StringRef FPU);
static unsigned parseArch(StringRef Arch);
static unsigned parseArchExt(StringRef ArchExt);
static unsigned parseCPUArch(StringRef CPU);
};
} // namespace llvm