Index: clang/lib/Basic/Targets/AArch64.h =================================================================== --- clang/lib/Basic/Targets/AArch64.h +++ clang/lib/Basic/Targets/AArch64.h @@ -44,6 +44,7 @@ bool HasSVE2BitPerm; bool HasMatmulFP64; bool HasMatmulFP32; + bool HasLSE; llvm::AArch64::ArchKind ArchKind; Index: clang/lib/Basic/Targets/AArch64.cpp =================================================================== --- clang/lib/Basic/Targets/AArch64.cpp +++ clang/lib/Basic/Targets/AArch64.cpp @@ -155,8 +155,9 @@ void AArch64TargetInfo::getTargetDefinesARMV81A(const LangOptions &Opts, MacroBuilder &Builder) const { - // FIXME: Armv8.1 makes __ARM_FEATURE_CRC32 mandatory. Handle it here. Builder.defineMacro("__ARM_FEATURE_QRDMX", "1"); + Builder.defineMacro("__ARM_FEATURE_ATOMICS", "1"); + Builder.defineMacro("__ARM_FEATURE_CRC32", "1"); } void AArch64TargetInfo::getTargetDefinesARMV82A(const LangOptions &Opts, @@ -176,8 +177,6 @@ void AArch64TargetInfo::getTargetDefinesARMV84A(const LangOptions &Opts, MacroBuilder &Builder) const { // Also include the Armv8.3 defines - // FIXME: Armv8.4 makes __ARM_FEATURE_ATOMICS, defined in GCC, mandatory. - // Add and handle it here. getTargetDefinesARMV83A(Opts, Builder); } @@ -304,6 +303,9 @@ if (HasMatMul) Builder.defineMacro("__ARM_FEATURE_MATMUL_INT8", "1"); + if (HasLSE) + Builder.defineMacro("__ARM_FEATURE_ATOMICS", "1"); + if (HasBFloat16) { Builder.defineMacro("__ARM_FEATURE_BF16", "1"); Builder.defineMacro("__ARM_FEATURE_BF16_VECTOR_ARITHMETIC", "1"); @@ -416,6 +418,7 @@ HasSVE2BitPerm = false; HasMatmulFP64 = false; HasMatmulFP32 = false; + HasLSE = false; ArchKind = llvm::AArch64::ArchKind::ARMV8A; @@ -497,6 +500,8 @@ HasMatMul = true; if (Feature == "+bf16") HasBFloat16 = true; + if (Feature == "+lse") + HasLSE = true; } setDataLayout(); Index: clang/test/Preprocessor/aarch64-target-features.c =================================================================== --- clang/test/Preprocessor/aarch64-target-features.c +++ clang/test/Preprocessor/aarch64-target-features.c @@ -62,6 +62,8 @@ // RUN: %clang -target arm64-none-linux-gnu -mcrc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+crc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+crc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s +// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s +// RUN: %clang -target arm64-none-linux-gnu -march=armv8.1-a -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 -fno-math-errno -fno-signed-zeros\ @@ -451,3 +453,10 @@ // CHECK-SVE-VECTOR-BITS-512: __ARM_FEATURE_SVE_BITS 512 // CHECK-SVE-VECTOR-BITS-1024: __ARM_FEATURE_SVE_BITS 1024 // CHECK-SVE-VECTOR-BITS-2048: __ARM_FEATURE_SVE_BITS 2048 + +// ================== Check Largse System Extensions (LSE) +// RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+lse -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s +// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+lse -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s +// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s +// RUN: %clang -target arm64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s +// CHECK-LSE: __ARM_FEATURE_ATOMICS 1