[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
https://github.com/Lukacma closed https://github.com/llvm/llvm-project/pull/95224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
https://github.com/Lukacma created https://github.com/llvm/llvm-project/pull/95224 To enable function multi-versioning (FMV), current checks which rely on cmd line options or global macros to see if target feature is present need to be removed. This patch removes those for NEON and also implements changes to NEON header file as proposed in [ACLE](https://github.com/ARM-software/acle/pull/321). >From d5caa1a22c90c7d3b1fd995c3ae980f02e4c14c9 Mon Sep 17 00:00:00 2001 From: Marian Lukac Date: Wed, 12 Jun 2024 11:13:48 + Subject: [PATCH] fix for mve --- clang/lib/Sema/SemaType.cpp| 18 -- clang/test/Sema/arm-vector-types-support.c | 11 ++- clang/test/SemaCUDA/neon-attrs.cu | 22 -- clang/utils/TableGen/NeonEmitter.cpp | 5 - 4 files changed, 14 insertions(+), 42 deletions(-) delete mode 100644 clang/test/SemaCUDA/neon-attrs.cu diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 441fdcca0758f..9c0d043725dde 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -8086,23 +8086,21 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, // Target must have NEON (or MVE, whose vectors are similar enough // not to need a separate attribute) - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -S.Context.getTargetInfo().hasFeature("sve") || -S.Context.getTargetInfo().hasFeature("sme") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && - VecKind == VectorKind::Neon) { + VecKind == VectorKind::Neon && + S.Context.getTargetInfo().getTriple().isArmMClass()) { S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon', 'mve', 'sve' or 'sme'"; +<< Attr << "'mve'"; Attr.setInvalid(); return; } - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && - VecKind == VectorKind::NeonPoly) { + VecKind == VectorKind::NeonPoly && + S.Context.getTargetInfo().getTriple().isArmMClass()) { S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon' or 'mve'"; +<< Attr << "'mve'"; Attr.setInvalid(); return; } diff --git a/clang/test/Sema/arm-vector-types-support.c b/clang/test/Sema/arm-vector-types-support.c index ed5f5ba175a94..e648d791a2687 100644 --- a/clang/test/Sema/arm-vector-types-support.c +++ b/clang/test/Sema/arm-vector-types-support.c @@ -1,7 +1,8 @@ -// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple armv8.1m.main -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type +// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify=sve-type -typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or -mcpu=}} -typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_polyvector_type(16))) unsigned char poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} typedef __attribute__((arm_sve_vector_bits(256))) void nosveflag; // expected-error{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}} + // sve-type-error@-1{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}} diff --git a/clang/test/SemaCUDA/neon-attrs.cu b/clang/test/SemaCUDA/neon-attrs.cu deleted file mode 100644 index 129056741ac9a..0 --- a/clang/test/SemaCUDA/neon-attrs.cu +++ /dev/null @@ -1,22 +0,0 @@ -// CPU-side compilation on ARM with neon enabled (no errors expected). -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify=quiet %s - -// CPU-side compilation on ARM with neon disabled. -// RUN: %clang_cc1 -tr
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (Lukacma) Changes To enable function multi-versioning (FMV), current checks which rely on cmd line options or global macros to see if target feature is present need to be removed. This patch removes those for NEON and also implements changes to NEON header file as proposed in [ACLE](https://github.com/ARM-software/acle/pull/321). --- Full diff: https://github.com/llvm/llvm-project/pull/95224.diff 4 Files Affected: - (modified) clang/lib/Sema/SemaType.cpp (+8-10) - (modified) clang/test/Sema/arm-vector-types-support.c (+6-5) - (removed) clang/test/SemaCUDA/neon-attrs.cu (-22) - (modified) clang/utils/TableGen/NeonEmitter.cpp (-5) ``diff diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 441fdcca0758f..9c0d043725dde 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -8086,23 +8086,21 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, // Target must have NEON (or MVE, whose vectors are similar enough // not to need a separate attribute) - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -S.Context.getTargetInfo().hasFeature("sve") || -S.Context.getTargetInfo().hasFeature("sme") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && - VecKind == VectorKind::Neon) { + VecKind == VectorKind::Neon && + S.Context.getTargetInfo().getTriple().isArmMClass()) { S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon', 'mve', 'sve' or 'sme'"; +<< Attr << "'mve'"; Attr.setInvalid(); return; } - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && - VecKind == VectorKind::NeonPoly) { + VecKind == VectorKind::NeonPoly && + S.Context.getTargetInfo().getTriple().isArmMClass()) { S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon' or 'mve'"; +<< Attr << "'mve'"; Attr.setInvalid(); return; } diff --git a/clang/test/Sema/arm-vector-types-support.c b/clang/test/Sema/arm-vector-types-support.c index ed5f5ba175a94..e648d791a2687 100644 --- a/clang/test/Sema/arm-vector-types-support.c +++ b/clang/test/Sema/arm-vector-types-support.c @@ -1,7 +1,8 @@ -// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple armv8.1m.main -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type +// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify=sve-type -typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or -mcpu=}} -typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_polyvector_type(16))) unsigned char poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} typedef __attribute__((arm_sve_vector_bits(256))) void nosveflag; // expected-error{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}} + // sve-type-error@-1{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}} diff --git a/clang/test/SemaCUDA/neon-attrs.cu b/clang/test/SemaCUDA/neon-attrs.cu deleted file mode 100644 index 129056741ac9a..0 --- a/clang/test/SemaCUDA/neon-attrs.cu +++ /dev/null @@ -1,22 +0,0 @@ -// CPU-side compilation on ARM with neon enabled (no errors expected). -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify=quiet %s - -// CPU-side compilation on ARM with neon disabled. -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify %s - -// GPU-side compilation on ARM (no errors expected). -// RUN: %clang_cc1 -triple nvptx64 -aux-triple a
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff a45080f09181517c9c5eb5099a6b6ac67a48424a d5caa1a22c90c7d3b1fd995c3ae980f02e4c14c9 -- clang/lib/Sema/SemaType.cpp clang/test/Sema/arm-vector-types-support.c clang/utils/TableGen/NeonEmitter.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 9c0d043725..c49c59f2b7 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -8088,10 +8088,9 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, // not to need a separate attribute) if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && - VecKind == VectorKind::Neon && + VecKind == VectorKind::Neon && S.Context.getTargetInfo().getTriple().isArmMClass()) { -S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'mve'"; +S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) << Attr << "'mve'"; Attr.setInvalid(); return; } @@ -8099,8 +8098,7 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, IsTargetCUDAAndHostARM) && VecKind == VectorKind::NeonPoly && S.Context.getTargetInfo().getTriple().isArmMClass()) { -S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'mve'"; +S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) << Attr << "'mve'"; Attr.setInvalid(); return; } `` https://github.com/llvm/llvm-project/pull/95224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
https://github.com/Lukacma updated https://github.com/llvm/llvm-project/pull/95224 >From d5caa1a22c90c7d3b1fd995c3ae980f02e4c14c9 Mon Sep 17 00:00:00 2001 From: Marian Lukac Date: Wed, 12 Jun 2024 11:13:48 + Subject: [PATCH 1/2] fix for mve --- clang/lib/Sema/SemaType.cpp| 18 -- clang/test/Sema/arm-vector-types-support.c | 11 ++- clang/test/SemaCUDA/neon-attrs.cu | 22 -- clang/utils/TableGen/NeonEmitter.cpp | 5 - 4 files changed, 14 insertions(+), 42 deletions(-) delete mode 100644 clang/test/SemaCUDA/neon-attrs.cu diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 441fdcca0758f..9c0d043725dde 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -8086,23 +8086,21 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, // Target must have NEON (or MVE, whose vectors are similar enough // not to need a separate attribute) - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -S.Context.getTargetInfo().hasFeature("sve") || -S.Context.getTargetInfo().hasFeature("sme") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && - VecKind == VectorKind::Neon) { + VecKind == VectorKind::Neon && + S.Context.getTargetInfo().getTriple().isArmMClass()) { S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon', 'mve', 'sve' or 'sme'"; +<< Attr << "'mve'"; Attr.setInvalid(); return; } - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && - VecKind == VectorKind::NeonPoly) { + VecKind == VectorKind::NeonPoly && + S.Context.getTargetInfo().getTriple().isArmMClass()) { S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon' or 'mve'"; +<< Attr << "'mve'"; Attr.setInvalid(); return; } diff --git a/clang/test/Sema/arm-vector-types-support.c b/clang/test/Sema/arm-vector-types-support.c index ed5f5ba175a94..e648d791a2687 100644 --- a/clang/test/Sema/arm-vector-types-support.c +++ b/clang/test/Sema/arm-vector-types-support.c @@ -1,7 +1,8 @@ -// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple armv8.1m.main -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type +// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify=sve-type -typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or -mcpu=}} -typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_polyvector_type(16))) unsigned char poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} typedef __attribute__((arm_sve_vector_bits(256))) void nosveflag; // expected-error{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}} + // sve-type-error@-1{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}} diff --git a/clang/test/SemaCUDA/neon-attrs.cu b/clang/test/SemaCUDA/neon-attrs.cu deleted file mode 100644 index 129056741ac9a..0 --- a/clang/test/SemaCUDA/neon-attrs.cu +++ /dev/null @@ -1,22 +0,0 @@ -// CPU-side compilation on ARM with neon enabled (no errors expected). -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify=quiet %s - -// CPU-side compilation on ARM with neon disabled. -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify %s - -// GPU-side compilation on ARM (no errors expected). -// RUN: %clang_cc1 -triple nvptx64 -aux-triple arm64-linux-gnu -fcuda-is-device -x cuda -fsyntax-only -verify=quiet %s - -// Regular C++ compilation on ARM with
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
Lukacma wrote: Due to me screwing up on git rebase I recreated the PR. This PR has fix for MVE https://github.com/llvm/llvm-project/pull/95224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
@@ -1,7 +1,8 @@ -// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple armv8.1m.main -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type +// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify=sve-type -typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or -mcpu=}} -typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} mgabka wrote: this error message does not sound like the one we are expecting to see as that suggests that "neon_vector_type'' is only supported when target supports mve. What I believe is not true. >From the changes to SemaType.cpp it looks like you want to emit this error >only when the requested target is an m class architecture, this should be >reflected in the error message. But I am surprised that the run line: RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type still generates this error. https://github.com/llvm/llvm-project/pull/95224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
@@ -1,7 +1,8 @@ -// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple armv8.1m.main -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type +// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify=sve-type -typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or -mcpu=}} -typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} Lukacma wrote: The original idea behind this error message was to preserve original behaviour of the code for MVE, as this patch is only changing NEON. I am thinking that rather than changing the error message to add note about m class architecture, I should revert it to its original form. What do you think ? RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type This run line doesn't generate any error message for neon attributes but only for sve attribute, if that's what you are asking about. https://github.com/llvm/llvm-project/pull/95224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
@@ -1,7 +1,8 @@ -// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple armv8.1m.main -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type +// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify=sve-type -typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or -mcpu=}} -typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} mgabka wrote: sorry, it was some time since I was working on sema, i didn't realise that "-verify=sve-type" make it only apply to the errors tagged with "sve-type-error@". Is the error message used anywhere else? if not I personally am not against changing the error message, to be specific to M class processors. https://github.com/llvm/llvm-project/pull/95224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
https://github.com/Lukacma updated https://github.com/llvm/llvm-project/pull/95224 >From d5caa1a22c90c7d3b1fd995c3ae980f02e4c14c9 Mon Sep 17 00:00:00 2001 From: Marian Lukac Date: Wed, 12 Jun 2024 11:13:48 + Subject: [PATCH 1/3] fix for mve --- clang/lib/Sema/SemaType.cpp| 18 -- clang/test/Sema/arm-vector-types-support.c | 11 ++- clang/test/SemaCUDA/neon-attrs.cu | 22 -- clang/utils/TableGen/NeonEmitter.cpp | 5 - 4 files changed, 14 insertions(+), 42 deletions(-) delete mode 100644 clang/test/SemaCUDA/neon-attrs.cu diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 441fdcca0758f..9c0d043725dde 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -8086,23 +8086,21 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, // Target must have NEON (or MVE, whose vectors are similar enough // not to need a separate attribute) - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -S.Context.getTargetInfo().hasFeature("sve") || -S.Context.getTargetInfo().hasFeature("sme") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && - VecKind == VectorKind::Neon) { + VecKind == VectorKind::Neon && + S.Context.getTargetInfo().getTriple().isArmMClass()) { S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon', 'mve', 'sve' or 'sme'"; +<< Attr << "'mve'"; Attr.setInvalid(); return; } - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && - VecKind == VectorKind::NeonPoly) { + VecKind == VectorKind::NeonPoly && + S.Context.getTargetInfo().getTriple().isArmMClass()) { S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon' or 'mve'"; +<< Attr << "'mve'"; Attr.setInvalid(); return; } diff --git a/clang/test/Sema/arm-vector-types-support.c b/clang/test/Sema/arm-vector-types-support.c index ed5f5ba175a94..e648d791a2687 100644 --- a/clang/test/Sema/arm-vector-types-support.c +++ b/clang/test/Sema/arm-vector-types-support.c @@ -1,7 +1,8 @@ -// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple armv8.1m.main -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type +// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify=sve-type -typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or -mcpu=}} -typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_polyvector_type(16))) unsigned char poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} typedef __attribute__((arm_sve_vector_bits(256))) void nosveflag; // expected-error{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}} + // sve-type-error@-1{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}} diff --git a/clang/test/SemaCUDA/neon-attrs.cu b/clang/test/SemaCUDA/neon-attrs.cu deleted file mode 100644 index 129056741ac9a..0 --- a/clang/test/SemaCUDA/neon-attrs.cu +++ /dev/null @@ -1,22 +0,0 @@ -// CPU-side compilation on ARM with neon enabled (no errors expected). -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify=quiet %s - -// CPU-side compilation on ARM with neon disabled. -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify %s - -// GPU-side compilation on ARM (no errors expected). -// RUN: %clang_cc1 -triple nvptx64 -aux-triple arm64-linux-gnu -fcuda-is-device -x cuda -fsyntax-only -verify=quiet %s - -// Regular C++ compilation on ARM with
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
@@ -1,7 +1,8 @@ -// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple armv8.1m.main -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type +// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify=sve-type -typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or -mcpu=}} -typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} Lukacma wrote: M-profile specific message added. The original error message was used elsewhere so couldn't be changed so I just created new one https://github.com/llvm/llvm-project/pull/95224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
https://github.com/Lukacma updated https://github.com/llvm/llvm-project/pull/95224 >From d5caa1a22c90c7d3b1fd995c3ae980f02e4c14c9 Mon Sep 17 00:00:00 2001 From: Marian Lukac Date: Wed, 12 Jun 2024 11:13:48 + Subject: [PATCH 1/4] fix for mve --- clang/lib/Sema/SemaType.cpp| 18 -- clang/test/Sema/arm-vector-types-support.c | 11 ++- clang/test/SemaCUDA/neon-attrs.cu | 22 -- clang/utils/TableGen/NeonEmitter.cpp | 5 - 4 files changed, 14 insertions(+), 42 deletions(-) delete mode 100644 clang/test/SemaCUDA/neon-attrs.cu diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 441fdcca0758f..9c0d043725dde 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -8086,23 +8086,21 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, // Target must have NEON (or MVE, whose vectors are similar enough // not to need a separate attribute) - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -S.Context.getTargetInfo().hasFeature("sve") || -S.Context.getTargetInfo().hasFeature("sme") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && - VecKind == VectorKind::Neon) { + VecKind == VectorKind::Neon && + S.Context.getTargetInfo().getTriple().isArmMClass()) { S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon', 'mve', 'sve' or 'sme'"; +<< Attr << "'mve'"; Attr.setInvalid(); return; } - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && - VecKind == VectorKind::NeonPoly) { + VecKind == VectorKind::NeonPoly && + S.Context.getTargetInfo().getTriple().isArmMClass()) { S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon' or 'mve'"; +<< Attr << "'mve'"; Attr.setInvalid(); return; } diff --git a/clang/test/Sema/arm-vector-types-support.c b/clang/test/Sema/arm-vector-types-support.c index ed5f5ba175a94..e648d791a2687 100644 --- a/clang/test/Sema/arm-vector-types-support.c +++ b/clang/test/Sema/arm-vector-types-support.c @@ -1,7 +1,8 @@ -// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple armv8.1m.main -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type +// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify=sve-type -typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or -mcpu=}} -typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_polyvector_type(16))) unsigned char poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} typedef __attribute__((arm_sve_vector_bits(256))) void nosveflag; // expected-error{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}} + // sve-type-error@-1{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}} diff --git a/clang/test/SemaCUDA/neon-attrs.cu b/clang/test/SemaCUDA/neon-attrs.cu deleted file mode 100644 index 129056741ac9a..0 --- a/clang/test/SemaCUDA/neon-attrs.cu +++ /dev/null @@ -1,22 +0,0 @@ -// CPU-side compilation on ARM with neon enabled (no errors expected). -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify=quiet %s - -// CPU-side compilation on ARM with neon disabled. -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify %s - -// GPU-side compilation on ARM (no errors expected). -// RUN: %clang_cc1 -triple nvptx64 -aux-triple arm64-linux-gnu -fcuda-is-device -x cuda -fsyntax-only -verify=quiet %s - -// Regular C++ compilation on ARM with
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
@@ -8086,23 +8086,21 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, // Target must have NEON (or MVE, whose vectors are similar enough // not to need a separate attribute) - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -S.Context.getTargetInfo().hasFeature("sve") || -S.Context.getTargetInfo().hasFeature("sme") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && mgabka wrote: it looks to me like the logic here can be simplified and use of this variable can be removed entirely. After reading https://github.com/llvm/llvm-project/commit/8b0ea48740935d819618d8254fc45d98179b672c It looks to me like somebody already disabled these errors when targeting GPUs, so we could just simplify the logic and emit the errors only when user targets M class CPUs, what do you think? https://github.com/llvm/llvm-project/pull/95224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
@@ -8086,23 +8086,21 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, // Target must have NEON (or MVE, whose vectors are similar enough // not to need a separate attribute) - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -S.Context.getTargetInfo().hasFeature("sve") || -S.Context.getTargetInfo().hasFeature("sme") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && Lukacma wrote: I am not sure I follow. The commit you pointed me to adds this variable to the check ? https://github.com/llvm/llvm-project/pull/95224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
@@ -8086,23 +8086,21 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, // Target must have NEON (or MVE, whose vectors are similar enough // not to need a separate attribute) - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -S.Context.getTargetInfo().hasFeature("sve") || -S.Context.getTargetInfo().hasFeature("sme") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && mgabka wrote: I am suggesting that in that patch we removed error emission when targeting GPU, since now we are restricting error emission to M class processors, I think the extra handling for GPUS can be removed. https://github.com/llvm/llvm-project/pull/95224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
https://github.com/Lukacma updated https://github.com/llvm/llvm-project/pull/95224 >From d5caa1a22c90c7d3b1fd995c3ae980f02e4c14c9 Mon Sep 17 00:00:00 2001 From: Marian Lukac Date: Wed, 12 Jun 2024 11:13:48 + Subject: [PATCH 1/5] fix for mve --- clang/lib/Sema/SemaType.cpp| 18 -- clang/test/Sema/arm-vector-types-support.c | 11 ++- clang/test/SemaCUDA/neon-attrs.cu | 22 -- clang/utils/TableGen/NeonEmitter.cpp | 5 - 4 files changed, 14 insertions(+), 42 deletions(-) delete mode 100644 clang/test/SemaCUDA/neon-attrs.cu diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 441fdcca0758f..9c0d043725dde 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -8086,23 +8086,21 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, // Target must have NEON (or MVE, whose vectors are similar enough // not to need a separate attribute) - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -S.Context.getTargetInfo().hasFeature("sve") || -S.Context.getTargetInfo().hasFeature("sme") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && - VecKind == VectorKind::Neon) { + VecKind == VectorKind::Neon && + S.Context.getTargetInfo().getTriple().isArmMClass()) { S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon', 'mve', 'sve' or 'sme'"; +<< Attr << "'mve'"; Attr.setInvalid(); return; } - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && - VecKind == VectorKind::NeonPoly) { + VecKind == VectorKind::NeonPoly && + S.Context.getTargetInfo().getTriple().isArmMClass()) { S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon' or 'mve'"; +<< Attr << "'mve'"; Attr.setInvalid(); return; } diff --git a/clang/test/Sema/arm-vector-types-support.c b/clang/test/Sema/arm-vector-types-support.c index ed5f5ba175a94..e648d791a2687 100644 --- a/clang/test/Sema/arm-vector-types-support.c +++ b/clang/test/Sema/arm-vector-types-support.c @@ -1,7 +1,8 @@ -// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple armv8.1m.main -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type +// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify=sve-type -typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or -mcpu=}} -typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_polyvector_type(16))) unsigned char poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} typedef __attribute__((arm_sve_vector_bits(256))) void nosveflag; // expected-error{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}} + // sve-type-error@-1{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}} diff --git a/clang/test/SemaCUDA/neon-attrs.cu b/clang/test/SemaCUDA/neon-attrs.cu deleted file mode 100644 index 129056741ac9a..0 --- a/clang/test/SemaCUDA/neon-attrs.cu +++ /dev/null @@ -1,22 +0,0 @@ -// CPU-side compilation on ARM with neon enabled (no errors expected). -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify=quiet %s - -// CPU-side compilation on ARM with neon disabled. -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify %s - -// GPU-side compilation on ARM (no errors expected). -// RUN: %clang_cc1 -triple nvptx64 -aux-triple arm64-linux-gnu -fcuda-is-device -x cuda -fsyntax-only -verify=quiet %s - -// Regular C++ compilation on ARM with
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
@@ -8086,23 +8086,21 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, // Target must have NEON (or MVE, whose vectors are similar enough // not to need a separate attribute) - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -S.Context.getTargetInfo().hasFeature("sve") || -S.Context.getTargetInfo().hasFeature("sme") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && Lukacma wrote: Ah now I understand. What you are trying to see that for mve there is no reason to check for GPUs as they will never be target for this extension? https://github.com/llvm/llvm-project/pull/95224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
@@ -8077,32 +8077,21 @@ static bool verifyValidIntegerConstantExpr(Sema &S, const ParsedAttr &Attr, /// match one of the standard Neon vector types. static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, Sema &S, VectorKind VecKind) { - bool IsTargetCUDAAndHostARM = false; - if (S.getLangOpts().CUDAIsDevice) { -const TargetInfo *AuxTI = S.getASTContext().getAuxTargetInfo(); -IsTargetCUDAAndHostARM = -AuxTI && (AuxTI->getTriple().isAArch64() || AuxTI->getTriple().isARM()); - } - // Target must have NEON (or MVE, whose vectors are similar enough // not to need a separate attribute) - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -S.Context.getTargetInfo().hasFeature("sve") || -S.Context.getTargetInfo().hasFeature("sme") || -IsTargetCUDAAndHostARM) && - VecKind == VectorKind::Neon) { -S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon', 'mve', 'sve' or 'sme'"; + if (!S.Context.getTargetInfo().hasFeature("mve") && + VecKind == VectorKind::Neon && + S.Context.getTargetInfo().getTriple().isArmMClass()) { +S.Diag(Attr.getLoc(), diag::err_attribute_unsupported_m_profile) +<< Attr << "'mve'"; Attr.setInvalid(); return; } - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -IsTargetCUDAAndHostARM) && - VecKind == VectorKind::NeonPoly) { -S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon' or 'mve'"; + if (!S.Context.getTargetInfo().hasFeature("mve") && + VecKind == VectorKind::NeonPoly && CarolineConcatto wrote: Wha happens if we have the original test(git show ed2d497291f0de330), but without the neon check: if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM)){ https://github.com/llvm/llvm-project/pull/95224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
@@ -8077,32 +8077,21 @@ static bool verifyValidIntegerConstantExpr(Sema &S, const ParsedAttr &Attr, /// match one of the standard Neon vector types. static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, Sema &S, VectorKind VecKind) { - bool IsTargetCUDAAndHostARM = false; - if (S.getLangOpts().CUDAIsDevice) { -const TargetInfo *AuxTI = S.getASTContext().getAuxTargetInfo(); -IsTargetCUDAAndHostARM = -AuxTI && (AuxTI->getTriple().isAArch64() || AuxTI->getTriple().isARM()); - } - // Target must have NEON (or MVE, whose vectors are similar enough // not to need a separate attribute) - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -S.Context.getTargetInfo().hasFeature("sve") || -S.Context.getTargetInfo().hasFeature("sme") || -IsTargetCUDAAndHostARM) && - VecKind == VectorKind::Neon) { -S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon', 'mve', 'sve' or 'sme'"; + if (!S.Context.getTargetInfo().hasFeature("mve") && + VecKind == VectorKind::Neon && + S.Context.getTargetInfo().getTriple().isArmMClass()) { +S.Diag(Attr.getLoc(), diag::err_attribute_unsupported_m_profile) +<< Attr << "'mve'"; Attr.setInvalid(); return; } - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -IsTargetCUDAAndHostARM) && - VecKind == VectorKind::NeonPoly) { -S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon' or 'mve'"; + if (!S.Context.getTargetInfo().hasFeature("mve") && + VecKind == VectorKind::NeonPoly && Lukacma wrote: No that wouldn't work as we would still get missing attribute error on aarch64 targets, as they don't have mve enabled. https://github.com/llvm/llvm-project/pull/95224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
https://github.com/Lukacma updated https://github.com/llvm/llvm-project/pull/95224 >From d5caa1a22c90c7d3b1fd995c3ae980f02e4c14c9 Mon Sep 17 00:00:00 2001 From: Marian Lukac Date: Wed, 12 Jun 2024 11:13:48 + Subject: [PATCH 1/6] fix for mve --- clang/lib/Sema/SemaType.cpp| 18 -- clang/test/Sema/arm-vector-types-support.c | 11 ++- clang/test/SemaCUDA/neon-attrs.cu | 22 -- clang/utils/TableGen/NeonEmitter.cpp | 5 - 4 files changed, 14 insertions(+), 42 deletions(-) delete mode 100644 clang/test/SemaCUDA/neon-attrs.cu diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 441fdcca0758f..9c0d043725dde 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -8086,23 +8086,21 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, // Target must have NEON (or MVE, whose vectors are similar enough // not to need a separate attribute) - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -S.Context.getTargetInfo().hasFeature("sve") || -S.Context.getTargetInfo().hasFeature("sme") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && - VecKind == VectorKind::Neon) { + VecKind == VectorKind::Neon && + S.Context.getTargetInfo().getTriple().isArmMClass()) { S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon', 'mve', 'sve' or 'sme'"; +<< Attr << "'mve'"; Attr.setInvalid(); return; } - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && - VecKind == VectorKind::NeonPoly) { + VecKind == VectorKind::NeonPoly && + S.Context.getTargetInfo().getTriple().isArmMClass()) { S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon' or 'mve'"; +<< Attr << "'mve'"; Attr.setInvalid(); return; } diff --git a/clang/test/Sema/arm-vector-types-support.c b/clang/test/Sema/arm-vector-types-support.c index ed5f5ba175a94..e648d791a2687 100644 --- a/clang/test/Sema/arm-vector-types-support.c +++ b/clang/test/Sema/arm-vector-types-support.c @@ -1,7 +1,8 @@ -// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple armv8.1m.main -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type +// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify=sve-type -typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or -mcpu=}} -typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_polyvector_type(16))) unsigned char poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} typedef __attribute__((arm_sve_vector_bits(256))) void nosveflag; // expected-error{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}} + // sve-type-error@-1{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}} diff --git a/clang/test/SemaCUDA/neon-attrs.cu b/clang/test/SemaCUDA/neon-attrs.cu deleted file mode 100644 index 129056741ac9a..0 --- a/clang/test/SemaCUDA/neon-attrs.cu +++ /dev/null @@ -1,22 +0,0 @@ -// CPU-side compilation on ARM with neon enabled (no errors expected). -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify=quiet %s - -// CPU-side compilation on ARM with neon disabled. -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify %s - -// GPU-side compilation on ARM (no errors expected). -// RUN: %clang_cc1 -triple nvptx64 -aux-triple arm64-linux-gnu -fcuda-is-device -x cuda -fsyntax-only -verify=quiet %s - -// Regular C++ compilation on ARM with
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
https://github.com/mgabka approved this pull request. https://github.com/llvm/llvm-project/pull/95224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
https://github.com/Lukacma updated https://github.com/llvm/llvm-project/pull/95224 >From d5caa1a22c90c7d3b1fd995c3ae980f02e4c14c9 Mon Sep 17 00:00:00 2001 From: Marian Lukac Date: Wed, 12 Jun 2024 11:13:48 + Subject: [PATCH 1/6] fix for mve --- clang/lib/Sema/SemaType.cpp| 18 -- clang/test/Sema/arm-vector-types-support.c | 11 ++- clang/test/SemaCUDA/neon-attrs.cu | 22 -- clang/utils/TableGen/NeonEmitter.cpp | 5 - 4 files changed, 14 insertions(+), 42 deletions(-) delete mode 100644 clang/test/SemaCUDA/neon-attrs.cu diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 441fdcca0758f..9c0d043725dde 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -8086,23 +8086,21 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, // Target must have NEON (or MVE, whose vectors are similar enough // not to need a separate attribute) - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || -S.Context.getTargetInfo().hasFeature("sve") || -S.Context.getTargetInfo().hasFeature("sme") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && - VecKind == VectorKind::Neon) { + VecKind == VectorKind::Neon && + S.Context.getTargetInfo().getTriple().isArmMClass()) { S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon', 'mve', 'sve' or 'sme'"; +<< Attr << "'mve'"; Attr.setInvalid(); return; } - if (!(S.Context.getTargetInfo().hasFeature("neon") || -S.Context.getTargetInfo().hasFeature("mve") || + if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM) && - VecKind == VectorKind::NeonPoly) { + VecKind == VectorKind::NeonPoly && + S.Context.getTargetInfo().getTriple().isArmMClass()) { S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) -<< Attr << "'neon' or 'mve'"; +<< Attr << "'mve'"; Attr.setInvalid(); return; } diff --git a/clang/test/Sema/arm-vector-types-support.c b/clang/test/Sema/arm-vector-types-support.c index ed5f5ba175a94..e648d791a2687 100644 --- a/clang/test/Sema/arm-vector-types-support.c +++ b/clang/test/Sema/arm-vector-types-support.c @@ -1,7 +1,8 @@ -// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple armv8.1m.main -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type +// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify=sve-type -typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or -mcpu=}} -typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_polyvector_type(16))) unsigned char poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} typedef __attribute__((arm_sve_vector_bits(256))) void nosveflag; // expected-error{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}} + // sve-type-error@-1{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}} diff --git a/clang/test/SemaCUDA/neon-attrs.cu b/clang/test/SemaCUDA/neon-attrs.cu deleted file mode 100644 index 129056741ac9a..0 --- a/clang/test/SemaCUDA/neon-attrs.cu +++ /dev/null @@ -1,22 +0,0 @@ -// CPU-side compilation on ARM with neon enabled (no errors expected). -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify=quiet %s - -// CPU-side compilation on ARM with neon disabled. -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify %s - -// GPU-side compilation on ARM (no errors expected). -// RUN: %clang_cc1 -triple nvptx64 -aux-triple arm64-linux-gnu -fcuda-is-device -x cuda -fsyntax-only -verify=quiet %s - -// Regular C++ compilation on ARM with