Skip to content

Commit

Permalink
[Clang][AArch64] Implement ACLE feature macro for FEAT_LRCPC3
Browse files Browse the repository at this point in the history
This implements the new value for the `__ARM_FEATURE_RCPC` feature
macro, which was introduced to the ACLE to indicate the availability of
FEAT_LRCPC3.

More details can be found on:
https://github.com/ARM-software/acle/blob/main/main/acle.md#rcpc

Reviewed By: tmatheson

Differential Revision: https://reviews.llvm.org/D153130
  • Loading branch information
pratlucas committed Jul 7, 2023
1 parent 54c7aec commit f1d7a55
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion clang/lib/Basic/Targets/AArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
if (HasCRC)
Builder.defineMacro("__ARM_FEATURE_CRC32", "1");

if (HasRCPC)
if (HasRCPC3)
Builder.defineMacro("__ARM_FEATURE_RCPC", "3");
else if (HasRCPC)
Builder.defineMacro("__ARM_FEATURE_RCPC", "1");

if (HasFMV)
Expand Down Expand Up @@ -671,6 +673,7 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const {
.Case("bti", HasBTI)
.Cases("ls64", "ls64_v", "ls64_accdata", HasLS64)
.Case("wfxt", HasWFxT)
.Case("rcpc3", HasRCPC3)
.Default(false);
}

Expand Down Expand Up @@ -928,6 +931,8 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
HasD128 = true;
if (Feature == "+gcs")
HasGCS = true;
if (Feature == "+rcpc3")
HasRCPC3 = true;
}

// Check features that are manually disabled by command line options.
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Basic/Targets/AArch64.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
bool HasNoSVE = false;
bool HasFMV = true;
bool HasGCS = false;
bool HasRCPC3 = false;

const llvm::AArch64::ArchInfo *ArchInfo = &llvm::AArch64::ARMV8A;

Expand Down
4 changes: 4 additions & 0 deletions clang/test/Preprocessor/aarch64-target-features.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
// CHECK: __ARM_FEATURE_LDREX 0xF
// CHECK: __ARM_FEATURE_NUMERIC_MAXMIN 1
// CHECK-NOT: __ARM_FEATURE_RCPC 1
// CHECK-NOT: __ARM_FEATURE_RCPC 3
// CHECK-NOT: __ARM_FEATURE_SHA2 1
// CHECK-NOT: __ARM_FEATURE_SHA3 1
// CHECK-NOT: __ARM_FEATURE_SHA512 1
Expand Down Expand Up @@ -612,3 +613,6 @@

// 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

// RUN: %clang --target=aarch64 -march=armv8.2-a+rcpc3 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-RCPC3 %s
// CHECK-RCPC3: __ARM_FEATURE_RCPC 3

0 comments on commit f1d7a55

Please sign in to comment.