Index: lib/Basic/Targets.cpp =================================================================== --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -4066,9 +4066,21 @@ Features["hwdiv-arm"] = true; Features["crc"] = true; Features["crypto"] = true; + } else if (CPU == "generic-armv8.1-a" ) { + Features["v8.1a"] = true; + Features["fp-armv8"] = true; + Features["neon"] = true; + Features["hwdiv"] = true; + Features["hwdiv-arm"] = true; + Features["crc"] = true; + Features["crypto"] = true; } else if (CPU == "cortex-r5" || CPU == "cortex-r7" || // Enable the hwdiv extension for all v8a AArch32 cores by // default. + ArchName == "armv8.1a" || + ArchName == "armebv8.1a" || ArchName == "armebv8.1a" || + ArchName == "thumbv8.1a" || ArchName == "thumbv8.1a" || + ArchName == "thumbebv8.1a" || ArchName == "thumbebv8.1" || ArchName == "armv8a" || ArchName == "armv8" || ArchName == "armebv8a" || ArchName == "armebv8" || ArchName == "thumbv8a" || ArchName == "thumbv8" || @@ -4182,6 +4194,7 @@ .Cases("cortex-m4", "cortex-m7", "7EM") .Cases("sc000", "cortex-m0", "cortex-m0plus", "cortex-m1", "6M") .Cases("cortex-a53", "cortex-a57", "cortex-a72", "8A") + .Case("generic-armv8.1-a","8_1A") .Default(nullptr); } static const char *getCPUProfile(StringRef Name) { @@ -4193,6 +4206,7 @@ .Cases("cortex-m3", "cortex-m4", "cortex-m0", "cortex-m0plus", "M") .Cases("cortex-m1", "cortex-m7", "sc000", "sc300", "M") .Cases("cortex-r4", "cortex-r5", "cortex-r7", "R") + .Case("generic-armv8.1-a", "A") .Default(""); } bool setCPU(const std::string &Name) override { @@ -4220,6 +4234,7 @@ // We check both CPUArchVer and ArchName because when only triple is // specified, the default CPU is arm1136j-s. return ArchName.endswith("v6t2") || ArchName.endswith("v7") || + ArchName.endswith("v8.1a") || ArchName.endswith("v8") || CPUArch == "6T2" || CPUArchVer >= 7; } void getTargetDefines(const LangOptions &Opts, @@ -4732,6 +4747,7 @@ bool setCPU(const std::string &Name) override { bool CPUKnown = llvm::StringSwitch(Name) .Case("generic", true) + .Case("generic-armv8.1-a", true) .Cases("cortex-a53", "cortex-a57", "cortex-a72", true) .Case("cyclone", true) .Default(false); Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -908,6 +908,14 @@ if (Args.getLastArg(options::OPT_arch)) return "cyclone"; + if (Arg *A = Args.getLastArg(options::OPT_march_EQ)) { + std::string MArch = A->getValue(); + std::string v8_1a = "armv8.1a"; + std::string v8_1_a = "armv8.1-a"; + if(MArch.substr(0, v8_1a.size()) == v8_1a || + MArch.substr(0, v8_1_a.size()) == v8_1_a) + return "generic-armv8.1-a"; + } return "generic"; } @@ -1750,7 +1758,7 @@ Features.push_back("+neon"); Features.push_back("+crc"); Features.push_back("+crypto"); - } else if (CPU == "generic") { + } else if (CPU.find("generic") == 0) { // CPU starts with "generic" Features.push_back("+neon"); } else { return false; @@ -1767,7 +1775,11 @@ const ArgList &Args, std::vector &Features) { std::pair Split = March.split("+"); - if (Split.first != "armv8-a") + + if (Split.first != "armv8-a" && + Split.first != "armv8a" && + Split.first != "armv8.1-a" && + Split.first != "armv8.1a" ) return false; if (Split.second.size() && !DecodeAArch64Features(D, Split.second, Features)) @@ -5532,7 +5544,7 @@ // Handle -march=native. if (MArch == "native") { std::string CPU = llvm::sys::getHostCPUName(); - if (CPU != "generic") { + if (CPU.find("generic") == 0) { // CPU starts with "generic" // Translate the native cpu into the architecture. The switch below will // then chose the minimum cpu for that arch. MArch = std::string("arm") + arm::getLLVMArchSuffixForARM(CPU); @@ -5588,6 +5600,7 @@ .Case("swift", "v7s") .Case("cyclone", "v8") .Cases("cortex-a53", "cortex-a57", "cortex-a72", "v8") + .Case("generic-armv8.1-a", "v8.1a") .Default(""); } @@ -7309,6 +7322,7 @@ CmdArgs.push_back("-mfpu=neon"); break; case llvm::Triple::ARMSubArch_v8: + case llvm::Triple::ARMSubArch_v8_1a: CmdArgs.push_back("-mfpu=crypto-neon-fp-armv8"); break; default: Index: test/Driver/aarch64-cpus.c =================================================================== --- test/Driver/aarch64-cpus.c +++ test/Driver/aarch64-cpus.c @@ -88,3 +88,26 @@ // RUN: %clang -target aarch64 -mcpu=cortex-a72 -mtune=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=MCPU-MTUNE %s // RUN: %clang -target aarch64 -mtune=cortex-a53 -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck -check-prefix=MCPU-MTUNE %s // MCPU-MTUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a53" + +// RUN: %clang -target aarch64 -march=armv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV81A %s +// RUN: %clang -target aarch64 -march=armv8.1-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV81A %s +// RUN: %clang -target aarch64 -mlittle-endian -march=armv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV81A %s +// RUN: %clang -target aarch64 -mlittle-endian -march=armv8.1-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV81A %s +// RUN: %clang -target aarch64_be -mlittle-endian -march=armv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV81A %s +// RUN: %clang -target aarch64_be -mlittle-endian -march=armv8.1-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV81A %s +// GENERICV81A: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic-armv8.1-a" + +// RUN: %clang -target arm64 -march=armv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERICV81A %s +// RUN: %clang -target arm64 -march=armv8.1-a -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERICV81A %s +// RUN: %clang -target arm64 -mlittle-endian -march=armv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERICV81A %s +// RUN: %clang -target arm64 -mlittle-endian -march=armv8.1-a -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERICV81A %s +// ARM64-GENERICV81A: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "generic-armv8.1-a" + +// RUN: %clang -target aarch64_be -march=armv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV81A-BE %s +// RUN: %clang -target aarch64_be -march=armv8.1-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV81A-BE %s +// RUN: %clang -target aarch64 -mbig-endian -march=armv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV81A-BE %s +// RUN: %clang -target aarch64 -mbig-endian -march=armv8.1-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV81A-BE %s +// RUN: %clang -target aarch64_be -mbig-endian -march=armv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV81A-BE %s +// RUN: %clang -target aarch64_be -mbig-endian -march=armv8.1-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV81A-BE %s +// GENERICV81A-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" "generic-armv8.1-a" + Index: test/Driver/arm-cortex-cpus.c =================================================================== --- test/Driver/arm-cortex-cpus.c +++ test/Driver/arm-cortex-cpus.c @@ -166,6 +166,50 @@ // RUN: %clang -target arm -march=armebv8a -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V8A-THUMB %s // CHECK-BE-V8A-THUMB: "-cc1"{{.*}} "-triple" "thumbebv8-{{.*}}" "-target-cpu" "cortex-a53" +// RUN: %clang -target armv8.1 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A %s +// RUN: %clang -target arm -march=armv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A %s +// RUN: %clang -target armv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A %s +// RUN: %clang -target arm -march=armv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A %s +// RUN: %clang -target arm -march=armv8.1-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A %s +// RUN: %clang -target armv8.1 -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 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 +// CHECK-V81A: "-cc1"{{.*}} "-triple" "armv8.1a-{{.*}}" "-target-cpu" "generic-armv8.1-a" + +// RUN: %clang -target armebv8.1 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V81A %s +// RUN: %clang -target armeb -march=armebv8.1 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V81A %s +// RUN: %clang -target armebv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V81A %s +// RUN: %clang -target armeb -march=armebv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V81A %s +// RUN: %clang -target armeb -march=armebv8.1-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V81A %s +// RUN: %clang -target armv8.1 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V81A %s +// RUN: %clang -target arm -march=armebv8.1 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V81A %s +// RUN: %clang -target armv8.1a -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V81A %s +// RUN: %clang -target arm -march=armebv8.1a -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V81A %s +// RUN: %clang -target arm -march=armebv8.1-a -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V81A %s +// CHECK-BE-V81A: "-cc1"{{.*}} "-triple" "armebv8.1a-{{.*}}" "-target-cpu" "generic-armv8.1-a" + +// RUN: %clang -target armv8.1 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A-THUMB %s +// RUN: %clang -target arm -march=armv8.1 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A-THUMB %s +// RUN: %clang -target armv8.1a -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A-THUMB %s +// RUN: %clang -target arm -march=armv8.1a -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A-THUMB %s +// RUN: %clang -target armv8.1 -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A-THUMB %s +// RUN: %clang -target arm -march=armv8.1 -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A-THUMB %s +// RUN: %clang -target armv8.1a -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A-THUMB %s +// RUN: %clang -target arm -march=armv8.1a -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A-THUMB %s +// CHECK-V81A-THUMB: "-cc1"{{.*}} "-triple" "thumbv8.1a-{{.*}}" "-target-cpu" "generic-armv8.1-a" + +// RUN: %clang -target armebv8.1 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V81A-THUMB %s +// RUN: %clang -target armeb -march=armebv8.1 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V81A-THUMB %s +// RUN: %clang -target armebv8.1a -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V81A-THUMB %s +// RUN: %clang -target armeb -march=armebv8.1a -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V81A-THUMB %s +// RUN: %clang -target armv8.1 -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V81A-THUMB %s +// RUN: %clang -target arm -march=armebv8.1 -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V81A-THUMB %s +// RUN: %clang -target armv8.1a -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V81A-THUMB %s +// RUN: %clang -target arm -march=armebv8.1a -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V81A-THUMB %s +// CHECK-BE-V81A-THUMB: "-cc1"{{.*}} "-triple" "thumbebv8.1a-{{.*}}" "-target-cpu" "generic-armv8.1-a" + // ================== Check default CPU on bogus architecture // RUN: %clang -target arm -march=armbogusv6 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BOGUS %s // CHECK-BOGUS: "-cc1"{{.*}} "-triple" "armv4t-{{.*}} "-target-cpu" "arm7tdmi" @@ -343,3 +387,20 @@ // RUN: %clang -target arm -mcpu=cortex-a57 -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A-THUMB %s // RUN: %clang -target arm -mcpu=cortex-a72 -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A-THUMB %s // CHECK-BE-CPUV8A-THUMB: "-cc1"{{.*}} "-triple" "thumbebv8-{{.*}} + +// RUN: %clang -target arm -mcpu=generic-armv8.1-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV81A %s +// RUN: %clang -target arm -mcpu=generic-armv8.1-a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV81A %s +// CHECK-CPUV81A: "-cc1"{{.*}} "-triple" "armv8.1a-{{.*}} + +// RUN: %clang -target armeb -mcpu=generic-armv8.1-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV81A %s +// RUN: %clang -target arm -mcpu=generic-armv8.1-a -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV81A %s +// CHECK-BE-CPUV81A: "-cc1"{{.*}} "-triple" "armebv8.1a-{{.*}} + +// RUN: %clang -target arm -mcpu=generic-armv8.1-a -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV81A-THUMB %s +// RUN: %clang -target arm -mcpu=generic-armv8.1-a -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV81A-THUMB %s +// CHECK-CPUV81A-THUMB: "-cc1"{{.*}} "-triple" "thumbv8.1a-{{.*}} + +// RUN: %clang -target armeb -mcpu=generic-armv8.1-a -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV81A-THUMB %s +// RUN: %clang -target arm -mcpu=generic-armv8.1-a -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV81A-THUMB %s +// CHECK-BE-CPUV81A-THUMB: "-cc1"{{.*}} "-triple" "thumbebv8.1a-{{.*}} + Index: test/Preprocessor/aarch64-target-features.c =================================================================== --- test/Preprocessor/aarch64-target-features.c +++ test/Preprocessor/aarch64-target-features.c @@ -109,3 +109,11 @@ // RUN: %clang -target aarch64 -march=armv8-a+neon -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR-NEON %s // RUN: %clang -target aarch64 -march=armv8-a+noneon -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR-NEON %s // CHECK-ERROR-NEON: error: [no]neon is not accepted as modifier, please use [no]simd instead + +// RUN: %clang -target aarch64 -mcpu=generic-armv8.1-a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A-FEATURE-1 %s +// RUN: %clang -target aarch64 -mcpu=generic-armv8.1-a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A-FEATURE-2 %s +// RUN: %clang -target aarch64 -mcpu=generic-armv8.1-a+nosimd -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V81A-FEATURE-3 %s +// CHECK-V81A-FEATURE-1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crypto" +// CHECK-V81A-FEATURE-2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "-crypto" +// CHECK-V81A-FEATURE-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "-neon" + Index: test/Preprocessor/arm-target-features.c =================================================================== --- test/Preprocessor/arm-target-features.c +++ test/Preprocessor/arm-target-features.c @@ -316,3 +316,9 @@ // KRAIT-THUMB:#define __ARM_ARCH_EXT_IDIV__ 1 // KRAIT-THUMB:#define __ARM_FEATURE_DSP // KRAIT-THUMB:#define __ARM_VFPV4__ 1 + +// RUN: %clang -target armv8.1a-none-none-eabi -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-V81A %s +// CHECK-V81A: __ARM_ARCH 8 +// CHECK-V81A: __ARM_ARCH_8_1A__ 1 +// CHECK-V81A: #define __ARM_ARCH_PROFILE 'A' +