From 3a8811e15fbf1f7493387bfe24fb8f1a110955fa Mon Sep 17 00:00:00 2001 From: Oliver Stannard Date: Wed, 1 Oct 2014 09:03:02 +0000 Subject: [PATCH] [ARM] Add support for Cortex-M7, FPv5-SP and FPv5-DP The Cortex-M7 has 3 options for its FPU: none, FPv5-SP-D16 and FPv5-DP-D16. FPv5 has the same instructions as FP-ARMv8, so it can be modeled using the same target feature, and all double-precision operations are already disabled by the fp-only-sp target features. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218748 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Basic/Targets.cpp | 6 +++--- lib/Driver/ToolChains.cpp | 2 +- lib/Driver/Tools.cpp | 14 +++++++++++++- test/Driver/arm-cortex-cpus.c | 4 ++++ test/Driver/arm-mfpu.c | 19 +++++++++++++++++++ test/Preprocessor/arm-target-features.c | 4 ++++ 6 files changed, 44 insertions(+), 5 deletions(-) diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index d0af13e3d5..251fa88755 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -3917,7 +3917,7 @@ public: ArchName == "thumbebv8a" || ArchName == "thumbebv8") { Features["hwdiv"] = true; Features["hwdiv-arm"] = true; - } else if (CPU == "cortex-m3" || CPU == "cortex-m4") { + } else if (CPU == "cortex-m3" || CPU == "cortex-m4" || CPU == "cortex-m7") { Features["hwdiv"] = true; } } @@ -4017,7 +4017,7 @@ public: .Case("swift", "7S") .Case("cyclone", "8A") .Case("cortex-m3", "7M") - .Case("cortex-m4", "7EM") + .Cases("cortex-m4", "cortex-m7", "7EM") .Case("cortex-m0", "6M") .Cases("cortex-a53", "cortex-a57", "8A") .Default(nullptr); @@ -4027,7 +4027,7 @@ public: .Cases("cortex-a5", "cortex-a7", "cortex-a8", "A") .Cases("cortex-a9", "cortex-a12", "cortex-a15", "krait", "A") .Cases("cortex-a53", "cortex-a57", "A") - .Cases("cortex-m3", "cortex-m4", "cortex-m0", "M") + .Cases("cortex-m3", "cortex-m4", "cortex-m0", "cortex-m7", "M") .Cases("cortex-r4", "cortex-r5", "R") .Default(""); } diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 2b888170c4..d85a67d656 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -137,7 +137,7 @@ static const char *GetArmArchForMCpu(StringRef Value) { .Cases("cortex-a9", "cortex-a12", "cortex-a15", "krait", "armv7") .Cases("cortex-r4", "cortex-r5", "armv7r") .Case("cortex-m3", "armv7m") - .Case("cortex-m4", "armv7em") + .Cases("cortex-m4", "cortex-m7", "armv7em") .Case("swift", "armv7s") .Default(nullptr); } diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 50c101fa6d..99e34e4be0 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -544,6 +544,18 @@ static void getARMFPUFeatures(const Driver &D, const Arg *A, Features.push_back("+d16"); Features.push_back("+fp-only-sp"); Features.push_back("-neon"); + } else if (FPU == "fp5-sp-d16" || FPU == "fpv5-sp-d16") { + Features.push_back("+fp-armv8"); + Features.push_back("+fp-only-sp"); + Features.push_back("+d16"); + Features.push_back("-neon"); + Features.push_back("-crypto"); + } else if (FPU == "fp5-dp-d16" || FPU == "fpv5-dp-d16" || + FPU == "fp5-d16" || FPU == "fpv5-d16") { + Features.push_back("+fp-armv8"); + Features.push_back("+d16"); + Features.push_back("-neon"); + Features.push_back("-crypto"); } else if (FPU == "fp-armv8") { Features.push_back("+fp-armv8"); Features.push_back("-neon"); @@ -5340,7 +5352,7 @@ const char *arm::getLLVMArchSuffixForARM(StringRef CPU) { .Cases("cortex-r4", "cortex-r5", "v7r") .Case("cortex-m0", "v6m") .Case("cortex-m3", "v7m") - .Case("cortex-m4", "v7em") + .Cases("cortex-m4", "cortex-m7", "v7em") .Case("swift", "v7s") .Case("cyclone", "v8") .Cases("cortex-a53", "cortex-a57", "v8") diff --git a/test/Driver/arm-cortex-cpus.c b/test/Driver/arm-cortex-cpus.c index 224ba575dd..52d3ec3278 100644 --- a/test/Driver/arm-cortex-cpus.c +++ b/test/Driver/arm-cortex-cpus.c @@ -231,11 +231,15 @@ // CHECK-BE-CPUV7M: "-cc1"{{.*}} "-triple" "thumbebv7m-{{.*}} // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-m4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7EM %s +// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-m7 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7EM %s // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-m4 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7EM %s +// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-m7 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7EM %s // CHECK-CPUV7EM: "-cc1"{{.*}} "-triple" "thumbv7em-{{.*}} // RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-m4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7EM %s +// RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-m7 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7EM %s // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-m4 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7EM %s +// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-m7 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7EM %s // CHECK-BE-CPUV7EM: "-cc1"{{.*}} "-triple" "thumbebv7em-{{.*}} // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R %s diff --git a/test/Driver/arm-mfpu.c b/test/Driver/arm-mfpu.c index 89c2035422..e76247852d 100644 --- a/test/Driver/arm-mfpu.c +++ b/test/Driver/arm-mfpu.c @@ -63,6 +63,25 @@ // CHECK-FP4-SP-D16: "-target-feature" "+fp-only-sp" // CHECK-FP4-SP-D16: "-target-feature" "-neon" +// RUN: %clang -target arm-linux-eabi -mfpu=fp5-sp-d16 %s -### -o %t.o 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-FP5-SP-D16 %s +// RUN: %clang -target arm-linux-eabi -mfpu=fpv5-sp-d16 %s -### -o %t.o 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-FP5-SP-D16 %s +// CHECK-FP5-SP-D16: "-target-feature" "+fp-armv8" +// CHECK-FP5-SP-D16: "-target-feature" "+fp-only-sp" +// CHECK-FP5-SP-D16: "-target-feature" "+d16" +// CHECK-FP5-SP-D16: "-target-feature" "-neon" +// CHECK-FP5-SP-D16: "-target-feature" "-crypto" + +// RUN: %clang -target arm-linux-eabi -mfpu=fp5-dp-d16 %s -### -o %t.o 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-FP5-DP-D16 %s +// RUN: %clang -target arm-linux-eabi -mfpu=fpv5-dp-d16 %s -### -o %t.o 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-FP5-DP-D16 %s +// CHECK-FP5-DP-D16: "-target-feature" "+fp-armv8" +// CHECK-FP5-DP-D16: "-target-feature" "+d16" +// CHECK-FP5-DP-D16: "-target-feature" "-neon" +// CHECK-FP5-DP-D16: "-target-feature" "-crypto" + // RUN: %clang -target arm-linux-eabi -mfpu=neon %s -### -o %t.o 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NEON %s // CHECK-NEON: "-target-feature" "+neon" diff --git a/test/Preprocessor/arm-target-features.c b/test/Preprocessor/arm-target-features.c index e3bee55fc9..b56eb7ccc9 100644 --- a/test/Preprocessor/arm-target-features.c +++ b/test/Preprocessor/arm-target-features.c @@ -240,6 +240,10 @@ // RUN: %clang -target armv7 -mthumb -mcpu=cortex-m4 -x c -E -dM %s -o - | FileCheck --check-prefix=M4-THUMB %s // M4-THUMB:#define __ARM_ARCH_EXT_IDIV__ 1 +// Test whether predefines are as expected when targeting cortex-m7. +// RUN: %clang -target armv7 -mthumb -mcpu=cortex-m7 -x c -E -dM %s -o - | FileCheck --check-prefix=M7-THUMB %s +// M7-THUMB:#define __ARM_ARCH_EXT_IDIV__ 1 + // Test whether predefines are as expected when targeting krait. // RUN: %clang -target armv7 -mcpu=krait -x c -E -dM %s -o - | FileCheck --check-prefix=KRAIT-ARM %s // KRAIT-ARM:#define __ARM_ARCH_EXT_IDIV__ 1 -- 2.40.0