Skip to content

Commit

Permalink
[AArch64] Add default features for CPUs on AArch64 target.
Browse files Browse the repository at this point in the history
For ARM target, we can use CRYPTO and CRC features if we select
cortex-a57 by '-mcpu', but for AArch64 target, it doesn't work
unless adding with '-mfpu=crypto-neon-fp-armv8'. To keep consistency
between front-end and back-end and get end-users more easier to use,
we'd better add default feature for CPUs on AArch64 target as well.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210625 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Kevin Qin authored and Kevin Qin committed Jun 11, 2014
1 parent ba63908 commit 1441ef5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/Basic/Targets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4243,6 +4243,7 @@ class AArch64TargetInfo : public TargetInfo {
NeonMode
};

std::string CPU;
unsigned FPU;
unsigned CRC;
unsigned Crypto;
Expand Down Expand Up @@ -4302,6 +4303,8 @@ class AArch64TargetInfo : public TargetInfo {
.Cases("cortex-a53", "cortex-a57", true)
.Case("cyclone", true)
.Default(false);
if (CPUKnown)
CPU = Name;
return CPUKnown;
}

Expand Down Expand Up @@ -4373,6 +4376,23 @@ class AArch64TargetInfo : public TargetInfo {
(Feature == "neon" && FPU == NeonMode);
}

void getDefaultFeatures(llvm::StringMap<bool> &Features) const override {

if (CPU == "cyclone") {
Features["fp-armv8"] = true;
Features["neon"] = true;
Features["crypto"] = true;
Features["crc"] = true;
Features["zcm"] = true;
Features["zcz"] = true;
} else if (CPU == "cortex-a53" || CPU == "cortex-a57") {
Features["fp-armv8"] = true;
Features["neon"] = true;
Features["crypto"] = true;
Features["crc"] = true;
}
}

bool handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) override {
FPU = FPUMode;
Expand Down
10 changes: 10 additions & 0 deletions test/Preprocessor/aarch64-target-features.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,13 @@
// RUN: %clang -target arm64-none-linux-gnu -mfpu=neon -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NEON %s
// CHECK-NEON: __ARM_NEON 1
// CHECK-NEON: __ARM_NEON_FP 0xe

// RUN: %clang -target aarch64-none-linux-gnu -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FEATURE %s
// RUN: %clang -target aarch64-none-linux-gnu -mcpu=cortex-a57 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FEATURE %s
// RUN: %clang -target aarch64-none-linux-gnu -mcpu=cyclone -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FEATURE %s
// CHECK-FEATURE: __ARM_FEATURE_CRC32 1
// CHECK-FEATURE: __ARM_FEATURE_CRYPTO 1
// CHECK-FEATURE: __ARM_NEON 1
// CHECK-FEATURE: __ARM_NEON_FP 0xe


0 comments on commit 1441ef5

Please sign in to comment.