Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4882,63 +4882,57 @@ break; } - const char *result = llvm::StringSwitch(MArch) - .Cases("armv2", "armv2a","arm2") - .Case("armv3", "arm6") - .Case("armv3m", "arm7m") - .Case("armv4", "strongarm") - .Case("armv4t", "arm7tdmi") - .Case("thumbv4t", "arm7tdmi") - .Cases("armv5", "armv5t", "arm10tdmi") - .Cases("thumbv5", "thumbv5t", "arm10tdmi") - .Cases("armv5e", "armv5te", "arm1022e") - .Cases("thumbv5e", "thumbv5te", "arm1022e") - .Case("armv5tej", "arm926ej-s") - .Case("thumbv5tej", "arm926ej-s") - .Cases("armv6", "armv6k", "arm1136jf-s") - .Cases("thumbv6", "thumbv6k", "arm1136jf-s") - .Case("armv6j", "arm1136j-s") - .Case("thumbv6j", "arm1136j-s") - .Cases("armv6z", "armv6zk", "arm1176jzf-s") - .Cases("thumbv6z", "thumbv6zk", "arm1176jzf-s") - .Case("armv6t2", "arm1156t2-s") - .Case("thumbv6t2", "arm1156t2-s") - .Cases("armv6m", "armv6-m", "cortex-m0") - .Case("thumbv6m", "cortex-m0") - .Cases("armv7", "armv7a", "armv7-a", "cortex-a8") - .Cases("armebv7", "armebv7a", "armebv7-a", "cortex-a8") - .Cases("thumbv7", "thumbv7a", "cortex-a8") - .Cases("thumbebv7", "thumbebv7a", "cortex-a8") - .Cases("armv7l", "armv7-l", "cortex-a8") - .Cases("armebv7l", "armebv7-l", "cortex-a8") - .Cases("armv7s", "armv7-s", "swift") - .Cases("armebv7s", "armebv7-s", "swift") - .Cases("armv7r", "armv7-r", "cortex-r4") - .Cases("armebv7r", "armebv7-r", "cortex-r4") - .Case("thumbv7r", "cortex-r4") - .Case("thumbebv7r", "cortex-r4") - .Cases("armv7m", "armv7-m", "cortex-m3") - .Cases("armebv7m", "armebv7-m", "cortex-m3") - .Case("thumbv7m", "cortex-m3") - .Case("thumbebv7m", "cortex-m3") - .Cases("armv7em", "armv7e-m", "cortex-m4") - .Cases("armebv7em", "armebv7e-m", "cortex-m4") - .Cases("thumbv7em", "thumbv7e-m", "cortex-m4") - .Cases("thumbebv7em", "thumbebv7e-m", "cortex-m4") - .Cases("armv8", "armv8a", "armv8-a", "cortex-a53") - .Cases("armebv8", "armebv8a", "armebv8-a", "cortex-a53") - .Cases("thumbv8", "thumbv8a", "cortex-a53") - .Cases("thumbebv8", "thumbebv8a", "cortex-a53") - .Case("ep9312", "ep9312") - .Case("iwmmxt", "iwmmxt") - .Case("xscale", "xscale") - // If all else failed, return the most base CPU with thumb interworking - // supported by LLVM. - .Default(0); + const char *result = nullptr; + if (MArch.startswith("arm") || MArch.startswith("thumb")) + result = llvm::StringSwitch(MArch) + .EndsWith("v2", "arm2") + .EndsWith("v2a", "arm2") + .EndsWith("v3", "arm6") + .EndsWith("v3m", "arm7m") + .EndsWith("v4", "strongarm") + .EndsWith("v4t", "arm7tdmi") + .EndsWith("v5", "arm10tdmi") + .EndsWith("v5t", "arm10tdmi") + .EndsWith("v5e", "arm1022e") + .EndsWith("v5te", "arm1022e") + .EndsWith("v5tej", "arm926ej-s") + .EndsWith("v6", "arm1136jf-s") + .EndsWith("v6k", "arm1136jf-s") + .EndsWith("v6j", "arm1136j-s") + .EndsWith("v6z", "arm1176jzf-s") + .EndsWith("v6zk", "arm1176jzf-s") + .EndsWith("v6t2", "arm1156t2-s") + .EndsWith("v6m", "cortex-m0") + .EndsWith("v6-m", "cortex-m0") + .EndsWith("v7", "cortex-a8") + .EndsWith("v7a", "cortex-a8") + .EndsWith("v7-a", "cortex-a8") + .EndsWith("v7l", "cortex-a8") + .EndsWith("v7-l", "cortex-a8") + .EndsWith("v7s", "swift") + .EndsWith("v7-s", "swift") + .EndsWith("v7r", "cortex-r4") + .EndsWith("v7-r", "cortex-r4") + .EndsWith("v7m", "cortex-m3") + .EndsWith("v7-m", "cortex-m3") + .EndsWith("v7em", "cortex-m4") + .EndsWith("v7e-m", "cortex-m4") + .EndsWith("v8", "cortex-a53") + .EndsWith("v8a", "cortex-a53") + .EndsWith("v8-a", "cortex-a53") + .Default(nullptr); + else + result = llvm::StringSwitch(MArch) + .Case("ep9312", "ep9312") + .Case("iwmmxt", "iwmmxt") + .Case("xscale", "xscale") + .Default(nullptr); if (result) return result; + // If all else failed, return the most base CPU with thumb interworking + // supported by LLVM. switch (Triple.getOS()) { case llvm::Triple::NetBSD: switch (Triple.getEnvironment()) { Index: test/Driver/arm-cortex-cpus.c =================================================================== --- test/Driver/arm-cortex-cpus.c +++ test/Driver/arm-cortex-cpus.c @@ -71,6 +71,10 @@ // RUN: %clang -target arm -march=armv6m -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6M %s // CHECK-V6M: "-cc1"{{.*}} "-triple" "thumbv6m-{{.*}} "-target-cpu" "cortex-m0" +// RUN: %clang -target armv6m -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6M-BIG %s +// RUN: %clang -target arm -march=armv6m -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6M-BIG %s +// CHECK-V6M-BIG: "-cc1"{{.*}} "-triple" "thumbebv6m-{{.*}} "-target-cpu" "cortex-m0" + // RUN: %clang -target armv7m -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V7M %s // RUN: %clang -target arm -march=armv7-m -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V7M %s // CHECK-V7M: "-cc1"{{.*}} "-triple" "thumbv7m-{{.*}} "-target-cpu" "cortex-m3" @@ -79,6 +83,10 @@ // RUN: %clang -target arm -march=armv7e-m -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V7EM %s // CHECK-V7EM: "-cc1"{{.*}} "-triple" "thumbv7em-{{.*}} "-target-cpu" "cortex-m4" +// RUN: %clang -target armv7em -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V7EM-BIG %s +// RUN: %clang -target arm -march=armv7e-m -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V7EM-BIG %s +// CHECK-V7EM-BIG: "-cc1"{{.*}} "-triple" "thumbebv7em-{{.*}} "-target-cpu" "cortex-m4" + // RUN: %clang -target armv6m-apple-darwin -arch armv6m -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6M-DARWIN %s // CHECK-V6M-DARWIN: "-cc1"{{.*}} "-triple" "thumbv6m-{{.*}} "-target-cpu" "cortex-m0"