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 @@ -83,6 +83,27 @@ else return false; + // +sme implies +sve, +sve2 and +bf16. + // +sme-f64f64 and +sme-i16i64 both imply +sme. + if (Feature == "sme") { + Features.push_back("+sve"); + Features.push_back("+sve2"); + Features.push_back("+bf16"); + } else if (Feature == "nosme") { + Features.push_back("-sme-f64f64"); + Features.push_back("-sme-i16i64"); + } else if (Feature == "sme-f64f64") { + Features.push_back("+sme"); + Features.push_back("+sve"); + Features.push_back("+sve2"); + Features.push_back("+bf16"); + } else if (Feature == "sme-i16i64") { + Features.push_back("+sme"); + Features.push_back("+sve"); + Features.push_back("+sve2"); + Features.push_back("+bf16"); + } + if (Feature == "sve2") Features.push_back("+sve"); else if (Feature == "sve2-bitperm" || Feature == "sve2-sha3" || @@ -95,11 +116,17 @@ Features.push_back("-sve2-sha3"); Features.push_back("-sve2-aes"); Features.push_back("-sve2-sm4"); + Features.push_back("-sme"); + Features.push_back("-sme-f64f64"); + Features.push_back("-sme-i16i64"); } else if (Feature == "nosve2") { Features.push_back("-sve2-bitperm"); Features.push_back("-sve2-sha3"); Features.push_back("-sve2-aes"); Features.push_back("-sve2-sm4"); + Features.push_back("-sme"); + Features.push_back("-sme-f64f64"); + Features.push_back("-sme-i16i64"); } // +sve implies +f32mm if the base architecture is >= v8.6A (except v9A) diff --git a/clang/test/Driver/aarch64-implied-sme-features.c b/clang/test/Driver/aarch64-implied-sme-features.c new file mode 100644 --- /dev/null +++ b/clang/test/Driver/aarch64-implied-sme-features.c @@ -0,0 +1,55 @@ +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme %s -### 2>&1 | FileCheck %s --check-prefix=SME-IMPLY +// SME-IMPLY: "-target-feature" "+sme" "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+bf16" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+nosme %s -### 2>&1 | FileCheck %s --check-prefix=NOSME +// NOSME: "-target-feature" "-sme" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme+nosme %s -### 2>&1 | FileCheck %s --check-prefix=SME-REVERT +// SME-REVERT-NOT: "-target-feature" "+sme" +// SME-REVERT: "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+bf16" "-target-feature" "-sme" "-target-feature" "-sme-f64f64" "-target-feature" "-sme-i16i64" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme+nosve %s -### 2>&1 | FileCheck %s --check-prefix=SME-CONFLICT +// SME-CONFLICT: "-target-feature" "-sve" "-target-feature" "-sve2" "-target-feature" "-sve2-bitperm" "-target-feature" "-sve2-sha3" "-target-feature" "-sve2-aes" "-target-feature" "-sve2-sm4" "-target-feature" "-sme" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme+sve %s -### 2>&1 | FileCheck %s --check-prefix=SME-SVE +// SME-SVE: "-target-feature" "+sme" "-target-feature" "+sve2" "-target-feature" "+bf16" "-target-feature" "+sve" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme-i16i64 %s -### 2>&1 | FileCheck %s --check-prefix=SME-I16I64 +// SME-I16I64: "-target-feature" "+sme-i16i64" "-target-feature" "+sme" "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+bf16" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+nosme-i16i64 %s -### 2>&1 | FileCheck %s --check-prefix=NOSME-I16I64 +// NOSME-I16I64-NOT: "-target-feature" "+sme-i16i64" +// NOSME-I16I64-NOT: "-target-feature" "+sme" +// NOSME-I16I64-NOT: "-target-feature" "+sve" +// NOSME-I16I64-NOT: "-target-feature" "+sve2" +// NOSME-I16I64-NOT: "-target-feature" "+bf16" +// NOSME-I16I64: "-target-feature" "-sme-i16i64" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme-i16i64+nosme-i16i64 %s -### 2>&1 | FileCheck %s --check-prefix=SME-I16I64-REVERT +// SME-I16I64-REVERT: "-target-feature" "+sme" "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+bf16" "-target-feature" "-sme-i16i64" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+nosme-f64f64 %s -### 2>&1 | FileCheck %s --check-prefix=NOSME-F64F64 +// NOSME-F64F64-NOT: "-target-feature" "+sme-f64f64" +// NOSME-F64F64-NOT: "-target-feature" "+sme" +// NOSME-F64F64-NOT: "-target-feature" "+sve" +// NOSME-F64F64-NOT: "-target-feature" "+sve2" +// NOSME-F64F64-NOT: "-target-feature" "+bf16" +// NOSME-F64F64: "-target-feature" "-sme-f64f64" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme-f64f64+nosme-f64f64 %s -### 2>&1 | FileCheck %s --check-prefix=SME-F64F64-REVERT +// SME-F64F64-REVERT: "-target-feature" "+sme" "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+bf16" "-target-feature" "-sme-f64f64" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme-f64f64+nosme-i16i64 %s -### 2>&1 | FileCheck %s --check-prefix=SME-SUBFEATURE-MIX +// SME-SUBFEATURE-MIX: "-target-feature" "+sme-f64f64" "-target-feature" "+sme" "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+bf16" "-target-feature" "-sme-i16i64" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme-i16i64+nosme %s -### 2>&1 | FileCheck %s --check-prefix=SME-SUBFEATURE-CONFLICT +// SME-SUBFEATURE-CONFLICT: "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+bf16" "-target-feature" "-sme" "-target-feature" "-sme-f64f64" "-target-feature" "-sme-i16i64" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme-f64f64+nosve %s -### 2>&1 | FileCheck %s --check-prefix=SVE-SUBFEATURE-CONFLICT +// SVE-SUBFEATURE-CONFLICT-NOT: "-target-feature" "+sve2" +// SVE-SUBFEATURE-CONFLICT-NOT: "-target-feature" "+sve" +// SVE-SUBFEATURE-CONFLICT-NOT: "-target-feature" "+sme" +// SVE-SUBFEATURE-CONFLICT-NOT: "-target-feature" "+sme-f64f64" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+nosme+sme-i16i64 %s -### 2>&1 | FileCheck %s --check-prefix=SME-SUBFEATURE-CONFLICT-REV +// SME-SUBFEATURE-CONFLICT-REV: "-target-feature" "-sme-f64f64" "-target-feature" "+sme-i16i64" "-target-feature" "+sme" "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+bf16"