From: Ana Pazos Date: Fri, 6 Dec 2013 22:43:17 +0000 (+0000) Subject: Added support for mcpu krait X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=69a9e166e083131c91409207a5ee07479c1cc14d;p=clang Added support for mcpu krait - krait processor currently modeled with the same features as A9. - Krait processor additionally has VFP4 (fused multiply add/sub) and hardware division features enabled. - krait has currently the same Schedule model as A9 - krait cpu flag is not recognized by the GNU assembler yet, it is replaced with march=armv7-a to avoid a lower march from being used. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196618 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 3b6cfb2790..8950fa0ab7 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -3820,7 +3820,9 @@ public: else if (CPU == "cortex-a5") { Features["vfp4"] = true; Features["neon"] = true; - } else if (CPU == "swift" || CPU == "cortex-a7" || CPU == "cortex-a12" || CPU == "cortex-a15") { + } else if (CPU == "swift" || CPU == "cortex-a7" || + CPU == "cortex-a12" || CPU == "cortex-a15" || + CPU == "krait") { Features["vfp4"] = true; Features["neon"] = true; Features["hwdiv"] = true; @@ -3920,7 +3922,7 @@ public: .Cases("arm1136jf-s", "mpcorenovfp", "mpcore", "6K") .Cases("arm1156t2-s", "arm1156t2f-s", "6T2") .Cases("cortex-a5", "cortex-a7", "cortex-a8", "7A") - .Cases("cortex-a9", "cortex-a12", "cortex-a15", "7A") + .Cases("cortex-a9", "cortex-a12", "cortex-a15", "krait", "7A") .Cases("cortex-r4", "cortex-r5", "7R") .Case("cortex-a9-mp", "7F") .Case("swift", "7S") @@ -3932,7 +3934,7 @@ public: static const char *getCPUProfile(StringRef Name) { return llvm::StringSwitch(Name) .Cases("cortex-a5", "cortex-a7", "cortex-a8", "A") - .Cases("cortex-a9", "cortex-a12", "cortex-a15", "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-r4", "cortex-r5", "R") diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp index efd3945b3d..da9b2cb09d 100644 --- a/lib/Driver/ToolChain.cpp +++ b/lib/Driver/ToolChain.cpp @@ -246,7 +246,7 @@ static const char *getLLVMArchSuffixForARM(StringRef CPU) { .Cases("arm1176jzf-s", "mpcorenovfp", "mpcore", "v6") .Cases("arm1156t2-s", "arm1156t2f-s", "v6t2") .Cases("cortex-a5", "cortex-a7", "cortex-a8", "v7") - .Cases("cortex-a9", "cortex-a12", "cortex-a15", "v7") + .Cases("cortex-a9", "cortex-a12", "cortex-a15", "krait", "v7") .Cases("cortex-r4", "cortex-r5", "v7r") .Case("cortex-m0", "v6m") .Case("cortex-m3", "v7m") diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index aa8cc56629..63584882cd 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -125,7 +125,7 @@ static const char *GetArmArchForMCpu(StringRef Value) { .Cases("arm1136j-s", "arm1136jf-s", "arm1176jz-s", "arm1176jzf-s", "armv6") .Case("cortex-m0", "armv6m") .Cases("cortex-a5", "cortex-a7", "cortex-a8", "armv7") - .Cases("cortex-a9", "cortex-a12", "cortex-a15", "armv7") + .Cases("cortex-a9", "cortex-a12", "cortex-a15", "krait", "armv7") .Cases("cortex-r4", "cortex-r5", "armv7r") .Case("cortex-a9-mp", "armv7f") .Case("cortex-m3", "armv7m") diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 16ec73302a..10dd69a8b8 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -462,7 +462,7 @@ static const char *getLLVMArchSuffixForARM(StringRef CPU) { .Cases("arm1176jzf-s", "mpcorenovfp", "mpcore", "v6") .Cases("arm1156t2-s", "arm1156t2f-s", "v6t2") .Cases("cortex-a5", "cortex-a7", "cortex-a8", "v7") - .Cases("cortex-a9", "cortex-a12", "cortex-a15", "v7") + .Cases("cortex-a9", "cortex-a12", "cortex-a15", "krait", "v7") .Cases("cortex-r4", "cortex-r5", "v7r") .Case("cortex-m0", "v6m") .Case("cortex-m3", "v7m") @@ -6166,7 +6166,16 @@ void gnutools::Assemble::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(Args.MakeArgString("-mfloat-abi=" + ARMFloatABI)); Args.AddLastArg(CmdArgs, options::OPT_march_EQ); - Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ); + + // FIXME: remove krait check when GNU tools support krait cpu + // for now replace it with -march=armv7-a to avoid a lower + // march from being picked in the absence of a cpu flag. + Arg *A; + if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) && + StringRef(A->getValue()) == "krait") + CmdArgs.push_back("-march=armv7-a"); + else + Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ); Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ); } else if (getToolChain().getArch() == llvm::Triple::mips || getToolChain().getArch() == llvm::Triple::mipsel || diff --git a/test/Driver/krait-cpu.c b/test/Driver/krait-cpu.c new file mode 100644 index 0000000000..ee324b6a54 --- /dev/null +++ b/test/Driver/krait-cpu.c @@ -0,0 +1,3 @@ +// ================== Check default Architecture on krait CPU +// RUN: %clang -target arm-linux-gnueabi -mcpu=krait -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A %s +// CHECK-CPUV7A: "-cc1"{{.*}} "-triple" "armv7-{{.*}} diff --git a/test/Preprocessor/arm-target-features.c b/test/Preprocessor/arm-target-features.c index ee84269b88..4d40bcb3c6 100644 --- a/test/Preprocessor/arm-target-features.c +++ b/test/Preprocessor/arm-target-features.c @@ -222,3 +222,13 @@ // Test whether predefines are as expected when targeting cortex-m4. // 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 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 +// KRAIT-ARM:#define __ARM_VFPV4__ 1 + +// RUN: %clang -target armv7 -mthumb -mcpu=krait -x c -E -dM %s -o - | FileCheck --check-prefix=KRAIT-THUMB %s +// KRAIT-THUMB:#define __ARM_ARCH_EXT_IDIV__ 1 +// KRAIT-THUMB:#define __ARM_VFPV4__ 1 +