r319077 - Switch CPU names not recognized by GNU assembler
Pirama Arumuga Nainar via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 27 11:18:39 PST 2017
Author: pirama
Date: Mon Nov 27 11:18:39 2017
New Revision: 319077
URL: http://llvm.org/viewvc/llvm-project?rev=319077&view=rev
Log:
Switch CPU names not recognized by GNU assembler
Summary:
Switch CPU names not recognized by GNU assembler to a close CPU that it
does recognize. In this patch, kryo, falkor and saphira all get
replaced by cortex-a57 when invoking the assembler. In addition, krait
was already being replaced by cortex-a15.
Reviewers: weimingz
Subscribers: srhines, cfe-commits
Differential Revision: https://reviews.llvm.org/D40476
Added:
cfe/trunk/test/Driver/as-mcpu.c
Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=319077&r1=319076&r2=319077&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Mon Nov 27 11:18:39 2017
@@ -42,6 +42,24 @@ static bool forwardToGCC(const Option &O
!O.hasFlag(options::DriverOption) && !O.hasFlag(options::LinkerInput);
}
+// Switch CPU names not recognized by GNU assembler to a close CPU that it does
+// recognize, instead of a lower march from being picked in the absence of a cpu
+// flag.
+static void normalizeCPUNamesForAssembler(const ArgList &Args,
+ ArgStringList &CmdArgs) {
+ if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
+ StringRef CPUArg(A->getValue());
+ if (CPUArg.equals_lower("krait"))
+ CmdArgs.push_back("-mcpu=cortex-a15");
+ else if(CPUArg.equals_lower("kryo") ||
+ CPUArg.equals_lower("falkor") ||
+ CPUArg.equals_lower("saphira"))
+ CmdArgs.push_back("-mcpu=cortex-a57");
+ else
+ Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+ }
+}
+
void tools::gcc::Common::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
@@ -652,23 +670,16 @@ void tools::gnutools::Assembler::Constru
}
Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
+ normalizeCPUNamesForAssembler(Args, CmdArgs);
- // FIXME: remove krait check when GNU tools support krait cpu
- // for now replace it with -mcpu=cortex-a15 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()).equals_lower("krait"))
- CmdArgs.push_back("-mcpu=cortex-a15");
- else
- Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
break;
}
case llvm::Triple::aarch64:
case llvm::Triple::aarch64_be: {
Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
- Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+ normalizeCPUNamesForAssembler(Args, CmdArgs);
+
break;
}
case llvm::Triple::mips:
Added: cfe/trunk/test/Driver/as-mcpu.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/as-mcpu.c?rev=319077&view=auto
==============================================================================
--- cfe/trunk/test/Driver/as-mcpu.c (added)
+++ cfe/trunk/test/Driver/as-mcpu.c Mon Nov 27 11:18:39 2017
@@ -0,0 +1,17 @@
+// ================== Check that krait is substituted by cortex-a15 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// ================== Check that kryo is substituted by cortex-a57 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// RUN: %clang -target arm-linux -mcpu=falkor -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=falkor -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// RUN: %clang -target arm-linux -mcpu=saphira -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=saphira -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// CHECK-CORTEX-A57: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a57
More information about the cfe-commits
mailing list