[ARM] Proper generic cpus handling

"generic" cpu was wrongly handled as exact real CPU name of ARMv8.1A architecture.

This has been fixed, now it is abstract name, suitable for any arch.

Reviewers: rengolin

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D11640

llvm-svn: 245445
This commit is contained in:
Vladimir Sukharev 2015-08-19 14:50:18 +00:00
parent d966fb6fef
commit 457d34193e
3 changed files with 32 additions and 15 deletions

View File

@ -4257,21 +4257,18 @@ class ARMTargetInfo : public TargetInfo {
ArchISA = llvm::ARMTargetParser::parseArchISA(ArchName);
DefaultCPU = getDefaultCPU(ArchName);
// SubArch is specified by the target triple
if (!DefaultCPU.empty())
setArchInfo(DefaultCPU);
else
// FIXME ArchInfo should be based on ArchName from triple, not on
// a hard-coded CPU name. Doing so currently causes regressions:
// test/Preprocessor/init.c: __ARM_ARCH_6J__ not defined
setArchInfo(CPU);
unsigned ArchKind = llvm::ARMTargetParser::parseArch(ArchName);
if (ArchKind == llvm::ARM::AK_INVALID)
// set arch of the CPU, either provided explicitly or hardcoded default
ArchKind = llvm::ARMTargetParser::parseCPUArch(CPU);
setArchInfo(ArchKind);
}
void setArchInfo(StringRef CPU) {
void setArchInfo(unsigned Kind) {
StringRef SubArch;
// cache TargetParser info
ArchKind = llvm::ARMTargetParser::parseCPUArch(CPU);
ArchKind = Kind;
SubArch = llvm::ARMTargetParser::getSubArch(ArchKind);
ArchProfile = llvm::ARMTargetParser::parseArchProfile(SubArch);
ArchVersion = llvm::ARMTargetParser::parseArchVersion(SubArch);
@ -4570,10 +4567,11 @@ public:
}
bool setCPU(const std::string &Name) override {
unsigned ArchKind = llvm::ARMTargetParser::parseCPUArch(Name);
if (Name != "generic")
setArchInfo(llvm::ARMTargetParser::parseCPUArch(Name));
if (ArchKind == llvm::ARM::AK_INVALID)
return false;
setArchInfo(Name);
setAtomic();
CPU = Name;
return true;

View File

@ -6002,9 +6002,9 @@ std::string arm::getARMTargetCPU(StringRef CPU, StringRef Arch,
/// CPU (or Arch, if CPU is generic).
// FIXME: This is redundant with -mcpu, why does LLVM use this.
const char *arm::getLLVMArchSuffixForARM(StringRef CPU, StringRef Arch) {
if (CPU == "generic" &&
llvm::ARMTargetParser::parseArch(Arch) == llvm::ARM::AK_ARMV8_1A)
return "v8.1a";
if (CPU == "generic")
return llvm::ARMTargetParser::getSubArch(
llvm::ARMTargetParser::parseArch(Arch));
unsigned ArchKind = llvm::ARMTargetParser::parseCPUArch(CPU);
if (ArchKind == llvm::ARM::AK_INVALID)

View File

@ -134,6 +134,18 @@
// RUN: %clang -target arm -mlittle-endian -march=armv8-a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A %s
// CHECK-V8A: "-cc1"{{.*}} "-triple" "armv8-{{.*}}" "-target-cpu" "cortex-a53"
// RUN: %clang -mcpu=generic -target armv8 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-GENERIC %s
// RUN: %clang -mcpu=generic -target arm -march=armv8 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-GENERIC %s
// RUN: %clang -mcpu=generic -target armv8a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-GENERIC %s
// RUN: %clang -mcpu=generic -target arm -march=armv8a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-GENERIC %s
// RUN: %clang -mcpu=generic -target arm -march=armv8-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-GENERIC %s
// RUN: %clang -mcpu=generic -target armv8 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-GENERIC %s
// RUN: %clang -mcpu=generic -target arm -march=armv8 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-GENERIC %s
// RUN: %clang -mcpu=generic -target armv8a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-GENERIC %s
// RUN: %clang -mcpu=generic -target arm -march=armv8a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-GENERIC %s
// RUN: %clang -mcpu=generic -target arm -mlittle-endian -march=armv8-a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-GENERIC %s
// CHECK-V8A-GENERIC: "-cc1"{{.*}} "-triple" "armv8-{{.*}}" "-target-cpu" "generic"
// RUN: %clang -target armebv8 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V8A %s
// RUN: %clang -target armeb -march=armebv8 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V8A %s
// RUN: %clang -target armebv8a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V8A %s
@ -173,6 +185,13 @@
// RUN: %clang -target armv8.1a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A %s
// RUN: %clang -target arm -march=armv8.1a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A %s
// RUN: %clang -target arm -mlittle-endian -march=armv8.1-a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A %s
// RUN: %clang -mcpu=generic -target arm -march=armv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A %s
// RUN: %clang -mcpu=generic -target armv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A %s
// RUN: %clang -mcpu=generic -target arm -march=armv8.1-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A %s
// RUN: %clang -mcpu=generic -target arm -march=armv8.1a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A %s
// RUN: %clang -mcpu=generic -target armv8.1a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A %s
// RUN: %clang -mcpu=generic -target arm -march=armv8.1a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A %s
// RUN: %clang -mcpu=generic -target arm -mlittle-endian -march=armv8.1-a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A %s
// CHECK-V81A: "-cc1"{{.*}} "-triple" "armv8.1a-{{.*}}" "-target-cpu" "generic" "-target-feature" "+v8.1a"
// RUN: %clang -target armebv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V81A %s