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 <marian.lu...@arm.com> Date: Wed, 12 Jun 2024 11:13:48 +0000 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..0000000000000 --- 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 neon enabled (no errors expected). -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -x c++ -fsyntax-only -verify=quiet %s - -// Regular C++ compilation on ARM with neon disabled. -// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -x c++ -fsyntax-only -verify %s - -// quiet-no-diagnostics -typedef __attribute__((neon_vector_type(4))) float float32x4_t; -// expected-error@-1 {{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'}} -// expect -typedef unsigned char poly8_t; -typedef __attribute__((neon_polyvector_type(8))) poly8_t poly8x8_t; -// expected-error@-1 {{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'}} diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp index 56f1fdf9ef574..626031d38cf00 100644 --- a/clang/utils/TableGen/NeonEmitter.cpp +++ b/clang/utils/TableGen/NeonEmitter.cpp @@ -2370,10 +2370,6 @@ void NeonEmitter::run(raw_ostream &OS) { "Please use -mfloat-abi=softfp or -mfloat-abi=hard\"\n"; OS << "#else\n\n"; - OS << "#if !defined(__ARM_NEON)\n"; - OS << "#error \"NEON support not enabled\"\n"; - OS << "#else\n\n"; - OS << "#include <stdint.h>\n\n"; OS << "#include <arm_bf16.h>\n"; @@ -2450,7 +2446,6 @@ void NeonEmitter::run(raw_ostream &OS) { OS << "#undef __ai\n\n"; OS << "#endif /* if !defined(__ARM_NEON) */\n"; OS << "#endif /* ifndef __ARM_FP */\n"; - OS << "#endif /* __ARM_NEON_H */\n"; } /// run - Read the records in arm_fp16.td and output arm_fp16.h. arm_fp16.h >From a7ffcc53d3969dc9e412d2cdd545f06aaedb4fbc Mon Sep 17 00:00:00 2001 From: Marian Lukac <marian.lu...@arm.com> Date: Wed, 12 Jun 2024 11:33:03 +0000 Subject: [PATCH 2/3] fix formatting --- clang/lib/Sema/SemaType.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 9c0d043725dde..c49c59f2b715b 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; } >From 77a3e1456aac4828e24d449532da337d82696708 Mon Sep 17 00:00:00 2001 From: Marian Lukac <marian.lu...@arm.com> Date: Mon, 17 Jun 2024 09:42:15 +0000 Subject: [PATCH 3/3] change error message --- clang/include/clang/Basic/DiagnosticSemaKinds.td | 3 +++ clang/lib/Sema/SemaType.cpp | 4 ++-- clang/test/Sema/arm-vector-types-support.c | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 193eae3bc41d6..9aecd0c565678 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -3240,6 +3240,9 @@ def warn_unsupported_target_attribute def err_attribute_unsupported : Error<"%0 attribute is not supported on targets missing %1;" " specify an appropriate -march= or -mcpu=">; +def err_attribute_unsupported_m_profile + : Error<"on M-profile architectures %0 attribute is not supported on targets missing %1;" + " specify an appropriate -march= or -mcpu=">; def err_duplicate_target_attribute : Error<"%select{unsupported|duplicate|unknown}0%select{| CPU|" " tune CPU}1 '%2' in the '%select{target|target_clones|target_version}3' " diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index c49c59f2b715b..bbc7ac31550b2 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -8090,7 +8090,7 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, IsTargetCUDAAndHostARM) && 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_m_profile) << Attr << "'mve'"; Attr.setInvalid(); return; } @@ -8098,7 +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_m_profile) << 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 e648d791a2687..8b8c9634631d0 100644 --- a/clang/test/Sema/arm-vector-types-support.c +++ b/clang/test/Sema/arm-vector-types-support.c @@ -2,7 +2,7 @@ // 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 '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__((neon_vector_type(2))) int int32x2_t; // expected-error{{on M-profile architectures '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{{on M-profile architectures '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=}} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits