From 2503ebd2cf9b4d28319551debaacff8b38765698 Mon Sep 17 00:00:00 2001 From: Bob Wilson Date: Mon, 4 Mar 2013 22:37:49 +0000 Subject: [PATCH] Add ARM v6m, v7m, and v7em architectures for Cortex-M series processors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176458 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/ToolChain.cpp | 10 ++++++---- lib/Driver/ToolChains.cpp | 19 ++++++++++++++----- lib/Driver/Tools.cpp | 12 +++++++----- test/Driver/arm-cortex-cpus.c | 8 ++++++++ 4 files changed, 35 insertions(+), 14 deletions(-) create mode 100644 test/Driver/arm-cortex-cpus.c diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp index cf95bec371..21015a6c84 100644 --- a/lib/Driver/ToolChain.cpp +++ b/lib/Driver/ToolChain.cpp @@ -109,16 +109,17 @@ static const char *getARMTargetCPU(const ArgList &Args, .Case("armv6j", "arm1136j-s") .Cases("armv6z", "armv6zk", "arm1176jzf-s") .Case("armv6t2", "arm1156t2-s") + .Cases("armv6m", "armv6-m", "cortex-m0") .Cases("armv7", "armv7a", "armv7-a", "cortex-a8") .Cases("armv7l", "armv7-l", "cortex-a8") .Cases("armv7f", "armv7-f", "cortex-a9-mp") .Cases("armv7s", "armv7-s", "swift") .Cases("armv7r", "armv7-r", "cortex-r4") .Cases("armv7m", "armv7-m", "cortex-m3") + .Cases("armv7em", "armv7e-m", "cortex-m4") .Case("ep9312", "ep9312") .Case("iwmmxt", "iwmmxt") .Case("xscale", "xscale") - .Cases("armv6m", "armv6-m", "cortex-m0") // If all else failed, return the most base CPU LLVM supports. .Default("arm7tdmi"); } @@ -144,9 +145,9 @@ static const char *getLLVMArchSuffixForARM(StringRef CPU) { .Cases("cortex-a5", "cortex-a7", "cortex-a8", "v7") .Cases("cortex-a9", "cortex-a15", "v7") .Case("cortex-r5", "v7r") - .Case("cortex-m3", "v7m") - .Case("cortex-m4", "v7m") .Case("cortex-m0", "v6m") + .Case("cortex-m3", "v7m") + .Case("cortex-m4", "v7em") .Case("cortex-a9-mp", "v7f") .Case("swift", "v7s") .Default(""); @@ -168,7 +169,8 @@ std::string ToolChain::ComputeLLVMTriple(const ArgList &Args, // FIXME: Thumb should just be another -target-feaure, not in the triple. StringRef Suffix = getLLVMArchSuffixForARM(getARMTargetCPU(Args, Triple)); - bool ThumbDefault = (Suffix.startswith("v7") && getTriple().isOSDarwin()); + bool ThumbDefault = Suffix.startswith("v6m") || + (Suffix.startswith("v7") && getTriple().isOSDarwin()); std::string ArchName = "arm"; // Assembly files should start in ARM mode. diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index d1072d5a37..3cd1a34617 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -99,15 +99,17 @@ bool Darwin::hasBlocksRuntime() const { static const char *GetArmArchForMArch(StringRef Value) { return llvm::StringSwitch(Value) .Case("armv6k", "armv6") + .Case("armv6m", "armv6m") .Case("armv5tej", "armv5") .Case("xscale", "xscale") .Case("armv4t", "armv4t") .Case("armv7", "armv7") .Cases("armv7a", "armv7-a", "armv7") .Cases("armv7r", "armv7-r", "armv7") - .Cases("armv7m", "armv7-m", "armv7") + .Cases("armv7em", "armv7e-m", "armv7em") .Cases("armv7f", "armv7-f", "armv7f") .Cases("armv7k", "armv7-k", "armv7k") + .Cases("armv7m", "armv7-m", "armv7m") .Cases("armv7s", "armv7-s", "armv7s") .Default(0); } @@ -118,11 +120,12 @@ static const char *GetArmArchForMCpu(StringRef Value) { .Cases("arm10e", "arm10tdmi", "armv5") .Cases("arm1020t", "arm1020e", "arm1022e", "arm1026ej-s", "armv5") .Case("xscale", "xscale") - .Cases("arm1136j-s", "arm1136jf-s", "arm1176jz-s", - "arm1176jzf-s", "cortex-m0", "armv6") - .Cases("cortex-a8", "cortex-r4", "cortex-m3", "cortex-a9", "cortex-a15", - "armv7") + .Cases("arm1136j-s", "arm1136jf-s", "arm1176jz-s", "arm1176jzf-s", "armv6") + .Case("cortex-m0", "armv6m") + .Cases("cortex-a8", "cortex-r4", "cortex-a9", "cortex-a15", "armv7") .Case("cortex-a9-mp", "armv7f") + .Case("cortex-m3", "armv7m") + .Case("cortex-m4", "armv7em") .Case("swift", "armv7s") .Default(0); } @@ -813,12 +816,18 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args, DAL->AddJoinedArg(0, MArch, "xscale"); else if (Name == "armv6") DAL->AddJoinedArg(0, MArch, "armv6k"); + else if (Name == "armv6m") + DAL->AddJoinedArg(0, MArch, "armv6m"); else if (Name == "armv7") DAL->AddJoinedArg(0, MArch, "armv7a"); + else if (Name == "armv7em") + DAL->AddJoinedArg(0, MArch, "armv7em"); else if (Name == "armv7f") DAL->AddJoinedArg(0, MArch, "armv7f"); else if (Name == "armv7k") DAL->AddJoinedArg(0, MArch, "armv7k"); + else if (Name == "armv7m") + DAL->AddJoinedArg(0, MArch, "armv7m"); else if (Name == "armv7s") DAL->AddJoinedArg(0, MArch, "armv7s"); diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 353a0bbdb9..5dce1ad9e2 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -459,9 +459,9 @@ static const char *getLLVMArchSuffixForARM(StringRef CPU) { .Cases("cortex-a5", "cortex-a7", "cortex-a8", "v7") .Cases("cortex-a9", "cortex-a15", "v7") .Case("cortex-r5", "v7r") - .Case("cortex-m3", "v7m") - .Case("cortex-m4", "v7m") .Case("cortex-m0", "v6m") + .Case("cortex-m3", "v7m") + .Case("cortex-m4", "v7em") .Case("cortex-a9-mp", "v7f") .Case("swift", "v7s") .Default(""); @@ -517,7 +517,9 @@ static std::string getARMTargetCPU(const ArgList &Args, .Case("armv6j", "arm1136j-s") .Cases("armv6z", "armv6zk", "arm1176jzf-s") .Case("armv6t2", "arm1156t2-s") + .Cases("armv6m", "armv6-m", "cortex-m0") .Cases("armv7", "armv7a", "armv7-a", "cortex-a8") + .Cases("armv7em", "armv7e-m", "cortex-m4") .Cases("armv7f", "armv7-f", "cortex-a9-mp") .Cases("armv7s", "armv7-s", "swift") .Cases("armv7r", "armv7-r", "cortex-r4") @@ -525,7 +527,6 @@ static std::string getARMTargetCPU(const ArgList &Args, .Case("ep9312", "ep9312") .Case("iwmmxt", "iwmmxt") .Case("xscale", "xscale") - .Cases("armv6m", "armv6-m", "cortex-m0") // If all else failed, return the most base CPU LLVM supports. .Default("arm7tdmi"); } @@ -4000,8 +4001,9 @@ llvm::Triple::ArchType darwin::getArchTypeForDarwinArchName(StringRef Str) { llvm::Triple::x86) .Case("x86_64", llvm::Triple::x86_64) // This is derived from the driver driver. - .Cases("arm", "armv4t", "armv5", "armv6", llvm::Triple::arm) - .Cases("armv7", "armv7f", "armv7k", "armv7s", "xscale", llvm::Triple::arm) + .Cases("arm", "armv4t", "armv5", "armv6", "armv6m", llvm::Triple::arm) + .Cases("armv7", "armv7em", "armv7f", "armv7k", "armv7m", llvm::Triple::arm) + .Cases("armv7s", "xscale", llvm::Triple::arm) .Case("r600", llvm::Triple::r600) .Case("nvptx", llvm::Triple::nvptx) .Case("nvptx64", llvm::Triple::nvptx64) diff --git a/test/Driver/arm-cortex-cpus.c b/test/Driver/arm-cortex-cpus.c new file mode 100644 index 0000000000..6fa649aa39 --- /dev/null +++ b/test/Driver/arm-cortex-cpus.c @@ -0,0 +1,8 @@ +// RUN: %clang -target armv6m-apple-darwin -arch armv6m -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6M %s +// CHECK-V6M: "-cc1"{{.*}} "-triple" "thumbv6m-{{.*}} "-target-cpu" "cortex-m0" + +// RUN: %clang -target armv7m-apple-darwin -arch armv7m -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V7M %s +// CHECK-V7M: "-cc1"{{.*}} "-triple" "thumbv7m-{{.*}} "-target-cpu" "cortex-m3" + +// RUN: %clang -target armv7em-apple-darwin -arch armv7em -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V7EM %s +// CHECK-V7EM: "-cc1"{{.*}} "-triple" "thumbv7em-{{.*}} "-target-cpu" "cortex-m4" -- 2.40.0