r193740 - [AArch64] Add some CPU targets for "generic", A-53 and A-57.
Bernie Ogden
bogden at arm.com
Fri Nov 8 02:01:54 PST 2013
Hi Eric,
To me it would be odd if the AArch64 CLI behaved differently to AArch32,
except where absolutely necessary.
So I think the most important thing is for the two CLIs to be consistent.
That doesn't necessarily mean that the AArch32 CLI couldn't change or be
extended in the ways you suggest.
Could you elaborate on those 'reasons'? What are the disadvantages of the
present approach and/or advantages of your approach?
Thanks,
Bernie
From: cfe-commits-bounces at cs.uiuc.edu
[mailto:cfe-commits-bounces at cs.uiuc.edu] On Behalf Of Eric Christopher
Sent: 07 November 2013 22:09
To: Amara Emerson; Nigel Stephens
Cc: cfe-commits at cs.uiuc.edu
Subject: Re: r193740 - [AArch64] Add some CPU targets for "generic", A-53
and A-57.
On Thu, Nov 7, 2013 at 6:47 AM, Amara Emerson <amara.emerson at arm.com> wrote:
Hi Eric,
Some of the main reasons (there may be more I'm overlooking) for using this
scheme is consistency with the existing ARM backend for end users. From our
perspective, -march should be restricted to actual architectures, and not
one specific implementation. A pragmatic addition is that accepting
-march=cortex-a53 would be ambiguous, as cortex-a53 will exist in both the
ARM and AArch64 backends. Specifying the CPU name alone is not enough to
determine the architecture we're compiling for. We've also never used
-mtune, and to begin doing so would not bring us any significant benefits.
Hope that answers your questions.
It seems odd to saddle the ARM64 port with the mistakes of the previous ARM
port. That there's going to be a cortex-a53 for arm64 and arm seems
irrelevant since, for the general -arch or -target case, you'll be
specifying the triple that you're compiling for so whether you're compiling
for 64 or 32-bit will be clear on the command line. Unless you have a plan
for cpu families ala the old ARM I really don't see a reason to have this
and a lot of reasons not to.
As far as -mtune, the ARM port was actually the only port in gcc that didn't
use -mtune and it caused a lot of odd bugs and complaints. I don't see a
reason to limit tuning for a particular processor while targeting the
architecture of something else.
Nigel: Can you elaborate here a bit more with the uses you see here?
-eric
Amara
From: Eric Christopher [mailto:echristo at gmail.com]
Sent: 06 November 2013 16:34
To: Amara Emerson
Cc: cfe-commits at cs.uiuc.edu
Subject: Re: r193740 - [AArch64] Add some CPU targets for "generic", A-53
and A-57.
Ping? Can you answer this?
On Nov 1, 2013 3:04 PM, "Eric Christopher" <echristo at gmail.com> wrote:
Out of curiosity this seems to be enshrining for AArch64 the -march/-mcpu
stuff from the old 32-bit arm gcc port. Why is this necessary? Why not just
-march=cortex-a53 to generate code for a particular architecture and
-mtune=cortex-a53 to tune, but not use any cpu specific instructions for a
particular architecture? Can you explain what your thoughts are here?
-eric
On Thu, Oct 31, 2013 at 2:32 AM, Amara Emerson <amara.emerson at arm.com>
wrote:
Author: aemerson
Date: Thu Oct 31 04:32:33 2013
New Revision: 193740
URL: http://llvm.org/viewvc/llvm-project?rev=193740
<http://llvm.org/viewvc/llvm-project?rev=193740&view=rev> &view=rev
Log:
[AArch64] Add some CPU targets for "generic", A-53 and A-57.
Enables the clang driver to begin targeting specific CPUs. Introduced a
"generic" CPU which will ensure that the optional FP feature is enabled
by default when it gets to LLVM, without needing any extra arguments.
Cortex-A53 and A-57 are also introduced with tests, although backend
handling of them does not yet exist.
Added:
cfe/trunk/test/Driver/aarch64-cpus.c
cfe/trunk/test/Driver/aarch64-mfpu.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=1937
40
<http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=193
740&r1=193739&r2=193740&view=diff> &r1=193739&r2=193740&view=diff
============================================================================
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Oct 31 04:32:33 2013
@@ -3472,6 +3472,13 @@ public:
return Feature == "aarch64" || (Feature == "neon" && FPU == NeonMode);
}
+ virtual bool setCPU(const std::string &Name) {
+ return llvm::StringSwitch<bool>(Name)
+ .Case("generic", true)
+ .Cases("cortex-a53", "cortex-a57", true)
+ .Default(false);
+ }
+
virtual bool handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) {
FPU = FPUMode;
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=19374
0
<http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=1937
40&r1=193739&r2=193740&view=diff> &r1=193739&r2=193740&view=diff
============================================================================
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Oct 31 04:32:33 2013
@@ -539,6 +539,26 @@ static std::string getARMTargetCPU(const
.Default("arm7tdmi");
}
+/// getAArch64TargetCPU - Get the (LLVM) name of the AArch64 cpu we are
targeting.
+//
+// FIXME: tblgen this.
+static std::string getAArch64TargetCPU(const ArgList &Args,
+ const llvm::Triple &Triple) {
+ // FIXME: Warn on inconsistent use of -mcpu and -march.
+
+ // If we have -mcpu=, use that.
+ if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
+ StringRef MCPU = A->getValue();
+ // Handle -mcpu=native.
+ if (MCPU == "native")
+ return llvm::sys::getHostCPUName();
+ else
+ return MCPU;
+ }
+
+ return "generic";
+}
+
// FIXME: Move to target hook.
static bool isSignedCharDefault(const llvm::Triple &Triple) {
switch (Triple.getArch()) {
@@ -1304,6 +1324,9 @@ static std::string getCPUName(const ArgL
default:
return "";
+ case llvm::Triple::aarch64:
+ return getAArch64TargetCPU(Args, T);
+
case llvm::Triple::arm:
case llvm::Triple::thumb:
return getARMTargetCPU(Args, T);
Modified: cfe/trunk/lib/Driver/Tools.h
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=193740
<http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=193740
&r1=193739&r2=193740&view=diff> &r1=193739&r2=193740&view=diff
============================================================================
==
--- cfe/trunk/lib/Driver/Tools.h (original)
+++ cfe/trunk/lib/Driver/Tools.h Thu Oct 31 04:32:33 2013
@@ -49,6 +49,8 @@ using llvm::opt::ArgStringList;
const InputInfo &Output,
const InputInfoList &Inputs) const;
+ void AddAArch64TargetArgs(const llvm::opt::ArgList &Args,
+ llvm::opt::ArgStringList &CmdArgs) const;
void AddARMTargetArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs,
bool KernelOrKext) const;
Added: cfe/trunk/test/Driver/aarch64-cpus.c
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-cpus.c?rev
=193740
<http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-cpus.c?re
v=193740&view=auto> &view=auto
============================================================================
==
--- cfe/trunk/test/Driver/aarch64-cpus.c (added)
+++ cfe/trunk/test/Driver/aarch64-cpus.c Thu Oct 31 04:32:33 2013
@@ -0,0 +1,10 @@
+// Check target CPUs are correctly passed.
+
+// RUN: %clang -target aarch64 -### -c %s 2>&1 | FileCheck
-check-prefix=GENERIC %s
+// GENERIC: "-cc1"{{.*}} "-triple" "aarch64" {{.*}} "-target-cpu" "generic"
+
+// RUN: %clang -target aarch64 -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck
-check-prefix=CA53 %s
+// CA53: "-cc1"{{.*}} "-triple" "aarch64" {{.*}} "-target-cpu" "cortex-a53"
+
+// RUN: %clang -target aarch64 -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck
-check-prefix=CA57 %s
+// CA57: "-cc1"{{.*}} "-triple" "aarch64" {{.*}} "-target-cpu" "cortex-a57"
Added: cfe/trunk/test/Driver/aarch64-mfpu.c
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-mfpu.c?rev
=193740
<http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-mfpu.c?re
v=193740&view=auto> &view=auto
============================================================================
==
--- cfe/trunk/test/Driver/aarch64-mfpu.c (added)
+++ cfe/trunk/test/Driver/aarch64-mfpu.c Thu Oct 31 04:32:33 2013
@@ -0,0 +1,26 @@
+// Test that different values of -mfpu pick correct AArch64 FPU
target-feature(s).
+
+// RUN: %clang -target aarch64-linux-eabi -mfpu=neon %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NEON %s
+// CHECK-NEON: "-target-feature" "+neon"
+
+// RUN: %clang -target aarch64-linux-eabi -mfpu=fp-armv8 %s -### -o %t.o
2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-FP-ARMV8 %s
+// CHECK-FP-ARMV8: "-target-feature" "+fp-armv8"
+
+// RUN: %clang -target aarch64-linux-eabi -mfpu=neon-fp-armv8 %s -### 2>&1
\
+// RUN: | FileCheck --check-prefix=CHECK-NEON-FP-ARMV8 %s
+// CHECK-NEON-FP-ARMV8: "-target-feature" "+fp-armv8"
+// CHECK-NEON-FP-ARMV8: "-target-feature" "+neon"
+
+// RUN: %clang -target aarch64-linux-eabi -mfpu=crypto-neon-fp-armv8 %s
-### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-CRYPTO-NEON-FP-ARMV8 %s
+// CHECK-CRYPTO-NEON-FP-ARMV8: "-target-feature" "+fp-armv8"
+// CHECK-CRYPTO-NEON-FP-ARMV8: "-target-feature" "+neon"
+// CHECK-CRYPTO-NEON-FP-ARMV8: "-target-feature" "+crypto"
+
+// RUN: %clang -target aarch64-linux-eabi -mfpu=none %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-FP %s
+// CHECK-NO-FP: "-target-feature" "-fp-armv8"
+// CHECK-NO-FP: "-target-feature" "-crypto"
+// CHECK-NO-FP: "-target-feature" "-neon"
_______________________________________________
cfe-commits mailing list
cfe-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131108/864f710f/attachment.html>
More information about the cfe-commits
mailing list