From ce7b4747e8b329ad6bc3362a3e3c245331127d6d Mon Sep 17 00:00:00 2001 From: Mingming Liu Date: Tue, 14 Jun 2022 14:04:49 -0700 Subject: [PATCH] [AArch64] Define __ARM_FEATURE_RCPC This patch implements the definition of __ARM_FEATURE_RCPC when clang command specifies +rcpc. Differential Revision: https://reviews.llvm.org/D127798 --- clang/lib/Basic/Targets/AArch64.cpp | 6 ++++++ clang/lib/Basic/Targets/AArch64.h | 1 + clang/test/Preprocessor/aarch64-target-features.c | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index 85346eb..19e6cca 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -341,6 +341,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts, if (HasCRC) Builder.defineMacro("__ARM_FEATURE_CRC32", "1"); + if (HasRCPC) + Builder.defineMacro("__ARM_FEATURE_RCPC", "1"); + // The __ARM_FEATURE_CRYPTO is deprecated in favor of finer grained feature // macros for AES, SHA2, SHA3 and SM4 if (HasAES && HasSHA2) @@ -551,6 +554,7 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector &Features, HasMatmulFP32 = false; HasLSE = false; HasMOPS = false; + HasRCPC = false; ArchKind = llvm::AArch64::ArchKind::INVALID; @@ -600,6 +604,8 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector &Features, } if (Feature == "+crc") HasCRC = true; + if (Feature == "+rcpc") + HasRCPC = true; if (Feature == "+aes") HasAES = true; if (Feature == "+sha2") diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h index e28a4c5..1930092 100644 --- a/clang/lib/Basic/Targets/AArch64.h +++ b/clang/lib/Basic/Targets/AArch64.h @@ -54,6 +54,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo { bool HasLSE; bool HasFlagM; bool HasMOPS; + bool HasRCPC; llvm::AArch64::ArchKind ArchKind; diff --git a/clang/test/Preprocessor/aarch64-target-features.c b/clang/test/Preprocessor/aarch64-target-features.c index 2d4ec2b..e0004ab 100644 --- a/clang/test/Preprocessor/aarch64-target-features.c +++ b/clang/test/Preprocessor/aarch64-target-features.c @@ -26,6 +26,7 @@ // CHECK: __ARM_FEATURE_IDIV 1 // CHECK: __ARM_FEATURE_LDREX 0xF // CHECK: __ARM_FEATURE_NUMERIC_MAXMIN 1 +// CHECK-NOT: __ARM_FEATURE_RCPC 1 // CHECK-NOT: __ARM_FEATURE_SHA2 1 // CHECK-NOT: __ARM_FEATURE_SHA3 1 // CHECK-NOT: __ARM_FEATURE_SHA512 1 @@ -560,3 +561,6 @@ // CHECK-BEFORE-V83-NOT: __ARM_FEATURE_COMPLEX 1 // CHECK-BEFORE-V83-NOT: __ARM_FEATURE_JCVT 1 // CHECK-BEFORE-V85-NOT: __ARM_FEATURE_FRINT 1 + +// RUN: %clang --target=aarch64 -march=armv8.2-a+rcpc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-RCPC %s +// CHECK-RCPC: __ARM_FEATURE_RCPC 1 -- 2.7.4