From 32f676ea19533dda56cc30302596cc16554fb1f8 Mon Sep 17 00:00:00 2001 From: Bradley Smith Date: Fri, 2 May 2014 15:17:51 +0000 Subject: [PATCH] [ARM64/AArch64] Hook up CRC32 subtarget feature to the driver git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207841 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Basic/Targets.cpp | 14 ++++++++++++++ lib/Driver/Tools.cpp | 9 +++++++++ test/Preprocessor/aarch64-target-features.c | 5 +++++ 3 files changed, 28 insertions(+) diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index a514466328..c9670a41af 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -3399,6 +3399,7 @@ class AArch64TargetInfo : public TargetInfo { }; unsigned FPU; + unsigned CRC; unsigned Crypto; static const Builtin::Info BuiltinInfo[]; @@ -3475,6 +3476,9 @@ public: Builder.defineMacro("__ARM_NEON_FP", "7"); } + if (CRC) + Builder.defineMacro("__ARM_FEATURE_CRC32"); + if (Crypto) { Builder.defineMacro("__ARM_FEATURE_CRYPTO"); } @@ -3498,10 +3502,13 @@ public: bool handleTargetFeatures(std::vector &Features, DiagnosticsEngine &Diags) override { FPU = FPUMode; + CRC = 0; Crypto = 0; for (unsigned i = 0, e = Features.size(); i != e; ++i) { if (Features[i] == "+neon") FPU = NeonMode; + if (Features[i] == "+crc") + CRC = 1; if (Features[i] == "+crypto") Crypto = 1; } @@ -4492,6 +4499,7 @@ class ARM64TargetInfo : public TargetInfo { }; unsigned FPU; + unsigned CRC; unsigned Crypto; static const Builtin::Info BuiltinInfo[]; @@ -4589,6 +4597,9 @@ public: Builder.defineMacro("__ARM_NEON_FP", "7"); } + if (CRC) + Builder.defineMacro("__ARM_FEATURE_CRC32"); + if (Crypto) Builder.defineMacro("__ARM_FEATURE_CRYPTO"); } @@ -4608,10 +4619,13 @@ public: bool handleTargetFeatures(std::vector &Features, DiagnosticsEngine &Diags) override { FPU = FPUMode; + CRC = 0; Crypto = 0; for (unsigned i = 0, e = Features.size(); i != e; ++i) { if (Features[i] == "+neon") FPU = NeonMode; + if (Features[i] == "+crc") + CRC = 1; if (Features[i] == "+crypto") Crypto = 1; } diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index a39b151766..bec557b4cb 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1540,6 +1540,15 @@ static void getAArch64TargetFeatures(const Driver &D, const ArgList &Args, Features.push_back("-crypto"); Features.push_back("-neon"); } + + // En/disable crc + if (Arg *A = Args.getLastArg(options::OPT_mcrc, + options::OPT_mnocrc)) { + if (A->getOption().matches(options::OPT_mcrc)) + Features.push_back("+crc"); + else + Features.push_back("-crc"); + } } static void getTargetFeatures(const Driver &D, const llvm::Triple &Triple, diff --git a/test/Preprocessor/aarch64-target-features.c b/test/Preprocessor/aarch64-target-features.c index b51556f6fa..fb95263901 100644 --- a/test/Preprocessor/aarch64-target-features.c +++ b/test/Preprocessor/aarch64-target-features.c @@ -10,6 +10,7 @@ // CHECK: __ARM_ARCH_PROFILE 'A' // CHECK-NOT: __ARM_FEATURE_BIG_ENDIAN // CHECK: __ARM_FEATURE_CLZ 1 +// CHECK-NOT: __ARM_FEATURE_CRC32 1 // CHECK-NOT: __ARM_FEATURE_CRYPTO 1 // CHECK: __ARM_FEATURE_DIV 1 // CHECK: __ARM_FEATURE_FMA 1 @@ -27,6 +28,10 @@ // RUN: %clang -target aarch64-none-linux-gnu -mfpu=crypto-neon-fp-armv8 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRYPTO %s // CHECK-CRYPTO: __ARM_FEATURE_CRYPTO 1 +// RUN: %clang -target aarch64-none-linux-gnu -mcrc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s +// RUN: %clang -target arm64-none-linux-gnu -mcrc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s +// CHECK-CRC32: __ARM_FEATURE_CRC32 1 + // RUN: %clang -target aarch64-none-linux-gnu -ffast-math -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FASTMATH %s // CHECK-FASTMATH: __ARM_FP_FAST 1 -- 2.40.0