diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -226,8 +226,6 @@ void AArch64TargetInfo::getTargetDefinesARMV88A(const LangOptions &Opts, MacroBuilder &Builder) const { - // FIXME: this does not handle the case where MOPS is disabled using +nomops - Builder.defineMacro("__ARM_FEATURE_MOPS", "1"); // Also include the Armv8.7 defines getTargetDefinesARMV87A(Opts, Builder); } diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp --- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp +++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp @@ -459,13 +459,23 @@ } } - const char *Archs[] = {"+v8.6a", "+v8.7a", "+v8.8a", - "+v9.1a", "+v9.2a", "+v9.3a"}; + // FIXME: these insertions should ideally be automated using default + // extensions support from the target parser. + const char *v8691OrLater[] = {"+v8.6a", "+v8.7a", "+v8.8a", + "+v9.1a", "+v9.2a", "+v9.3a"}; auto Pos = std::find_first_of(Features.begin(), Features.end(), - std::begin(Archs), std::end(Archs)); + std::begin(v8691OrLater), std::end(v8691OrLater)); if (Pos != std::end(Features)) Pos = Features.insert(std::next(Pos), {"+i8mm", "+bf16"}); + // For Armv8.8-a/Armv9.3-a or later, FEAT_HBC and FEAT_MOPS are enabled by + // default. + const char *v8893OrLater[] = {"+v8.8a", "+v9.3a"}; + Pos = std::find_first_of(Features.begin(), Features.end(), + std::begin(v8893OrLater), std::end(v8893OrLater)); + if (Pos != std::end(Features)) + Pos = Features.insert(std::next(Pos), {"+hbc", "+mops"}); + if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access, options::OPT_munaligned_access)) { if (A->getOption().matches(options::OPT_mno_unaligned_access)) diff --git a/clang/test/Driver/aarch64-hbc.c b/clang/test/Driver/aarch64-hbc.c --- a/clang/test/Driver/aarch64-hbc.c +++ b/clang/test/Driver/aarch64-hbc.c @@ -1,6 +1,12 @@ // Test that target feature hbc is implemented and available correctly -// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+hbc %s 2>&1 | FileCheck %s -// CHECK: "-target-feature" "+hbc" - +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.7-a+hbc %s 2>&1 | FileCheck %s +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a %s 2>&1 | FileCheck %s +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+hbc %s 2>&1 | FileCheck %s // RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+nohbc %s 2>&1 | FileCheck %s --check-prefix=NO_HBC +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.2-a+hbc %s 2>&1 | FileCheck %s +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a %s 2>&1 | FileCheck %s +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a+hbc %s 2>&1 | FileCheck %s +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a+nohbc %s 2>&1 | FileCheck %s --check-prefix=NO_HBC + +// CHECK: "-target-feature" "+hbc" // NO_HBC: "-target-feature" "-hbc" diff --git a/clang/test/Driver/aarch64-mops.c b/clang/test/Driver/aarch64-mops.c --- a/clang/test/Driver/aarch64-mops.c +++ b/clang/test/Driver/aarch64-mops.c @@ -1,6 +1,12 @@ // Test that target feature mops is implemented and available correctly -// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+mops %s 2>&1 | FileCheck %s -// CHECK: "-target-feature" "+mops" - +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.7-a+mops %s 2>&1 | FileCheck %s +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a %s 2>&1 | FileCheck %s +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+mops %s 2>&1 | FileCheck %s // RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+nomops %s 2>&1 | FileCheck %s --check-prefix=NO_MOPS +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.2-a+mops %s 2>&1 | FileCheck %s +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a %s 2>&1 | FileCheck %s +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a+mops %s 2>&1 | FileCheck %s +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a+nomops %s 2>&1 | FileCheck %s --check-prefix=NO_MOPS + +// CHECK: "-target-feature" "+mops" // NO_MOPS: "-target-feature" "-mops" diff --git a/clang/test/Preprocessor/aarch64-target-features.c b/clang/test/Preprocessor/aarch64-target-features.c --- a/clang/test/Preprocessor/aarch64-target-features.c +++ b/clang/test/Preprocessor/aarch64-target-features.c @@ -521,13 +521,17 @@ // CHECK-LSE: __ARM_FEATURE_ATOMICS 1 // ================== Check Armv8.8-A/Armv9.3-A memcpy and memset acceleration instructions (MOPS) -// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s -// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s -// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s -// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s -// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s -// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s -// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s -// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s +// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s +// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s +// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s +// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a+nomops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s +// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a+nomops+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s +// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s +// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a+mops+nomops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s +// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s +// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s +// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s +// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a+nomops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s +// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s // CHECK-MOPS: __ARM_FEATURE_MOPS 1 // CHECK-NOMOPS-NOT: __ARM_FEATURE_MOPS 1