joechrisellis created this revision.
joechrisellis added reviewers: fpetrogalli, peterwaller-arm.
Herald added subscribers: cfe-commits, psnobl, kristof.beyls, tschuett.
Herald added a reviewer: efriedma.
Herald added a project: clang.
joechrisellis requested review of this revision.
Previously, lax conversions were only allowed between SVE vector-length
agnostic types and vector-length specific types. This meant that code
such as the following:
#include <arm_sve.h>
#define N __ARM_FEATURE_SVE_BITS
#define FIXED_ATTR __attribute__ ((vector_size (N/8)))
typedef float fixed_float32_t FIXED_ATTR;
void foo() {
fixed_float32_t fs32;
svfloat64_t s64;
fs32 = s64;
}
was not allowed.
This patch makes a minor change to areLaxCompatibleSveTypes to allow for
lax conversions to be performed between SVE vector-length agnostic types
and GNU vectors.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D91696
Files:
clang/lib/AST/ASTContext.cpp
clang/test/Sema/aarch64-sve-lax-vector-conversions.c
clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
Index: clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
===================================================================
--- clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
+++ clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
@@ -7,32 +7,61 @@
#include <arm_sve.h>
#define N __ARM_FEATURE_SVE_BITS
-#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+#define SVE_FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+#define GNU_FIXED_ATTR __attribute__((vector_size(N / 8)))
-typedef svfloat32_t fixed_float32_t FIXED_ATTR;
-typedef svint32_t fixed_int32_t FIXED_ATTR;
+typedef svfloat32_t sve_fixed_float32_t SVE_FIXED_ATTR;
+typedef svint32_t sve_fixed_int32_t SVE_FIXED_ATTR;
+typedef float gnu_fixed_float32_t GNU_FIXED_ATTR;
+typedef int gnu_fixed_int32_t GNU_FIXED_ATTR;
-void allowed_with_integer_lax_conversions() {
- fixed_int32_t fi32;
+void sve_allowed_with_integer_lax_conversions() {
+ sve_fixed_int32_t fi32;
svint64_t si64;
// The implicit cast here should fail if -flax-vector-conversions=none, but pass if
// -flax-vector-conversions={integer,all}.
fi32 = si64;
- // lax-vector-none-error@-1 {{assigning to 'fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+ // lax-vector-none-error@-1 {{assigning to 'sve_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
si64 = fi32;
// lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
}
-void allowed_with_all_lax_conversions() {
- fixed_float32_t ff32;
+void sve_allowed_with_all_lax_conversions() {
+ sve_fixed_float32_t ff32;
svfloat64_t sf64;
// The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if
// -flax-vector-conversions=all.
ff32 = sf64;
- // lax-vector-none-error@-1 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
- // lax-vector-integer-error@-2 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+ // lax-vector-none-error@-1 {{assigning to 'sve_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+ // lax-vector-integer-error@-2 {{assigning to 'sve_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+ sf64 = ff32;
+ // lax-vector-none-error@-1 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
+ // lax-vector-integer-error@-2 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
+}
+
+void gnu_allowed_with_integer_lax_conversions() {
+ gnu_fixed_int32_t fi32;
+ svint64_t si64;
+
+ // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
+ // -flax-vector-conversions={integer,all}.
+ fi32 = si64;
+ // lax-vector-none-error@-1 {{assigning to 'gnu_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+ si64 = fi32;
+ // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
+}
+
+void gnu_allowed_with_all_lax_conversions() {
+ gnu_fixed_float32_t ff32;
+ svfloat64_t sf64;
+
+ // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if
+ // -flax-vector-conversions=all.
+ ff32 = sf64;
+ // lax-vector-none-error@-1 {{assigning to 'gnu_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+ // lax-vector-integer-error@-2 {{assigning to 'gnu_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
sf64 = ff32;
// lax-vector-none-error@-1 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
// lax-vector-integer-error@-2 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
Index: clang/test/Sema/aarch64-sve-lax-vector-conversions.c
===================================================================
--- clang/test/Sema/aarch64-sve-lax-vector-conversions.c
+++ clang/test/Sema/aarch64-sve-lax-vector-conversions.c
@@ -7,32 +7,61 @@
#include <arm_sve.h>
#define N __ARM_FEATURE_SVE_BITS
-#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+#define SVE_FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+#define GNU_FIXED_ATTR __attribute__((vector_size(N / 8)))
-typedef svfloat32_t fixed_float32_t FIXED_ATTR;
-typedef svint32_t fixed_int32_t FIXED_ATTR;
+typedef svfloat32_t sve_fixed_float32_t SVE_FIXED_ATTR;
+typedef svint32_t sve_fixed_int32_t SVE_FIXED_ATTR;
+typedef float gnu_fixed_float32_t GNU_FIXED_ATTR;
+typedef int gnu_fixed_int32_t GNU_FIXED_ATTR;
-void allowed_with_integer_lax_conversions() {
- fixed_int32_t fi32;
+void sve_allowed_with_integer_lax_conversions() {
+ sve_fixed_int32_t fi32;
svint64_t si64;
// The implicit cast here should fail if -flax-vector-conversions=none, but pass if
// -flax-vector-conversions={integer,all}.
fi32 = si64;
- // lax-vector-none-error@-1 {{assigning to 'fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+ // lax-vector-none-error@-1 {{assigning to 'sve_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
si64 = fi32;
// lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
}
-void allowed_with_all_lax_conversions() {
- fixed_float32_t ff32;
+void sve_allowed_with_all_lax_conversions() {
+ sve_fixed_float32_t ff32;
svfloat64_t sf64;
// The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if
// -flax-vector-conversions=all.
ff32 = sf64;
- // lax-vector-none-error@-1 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
- // lax-vector-integer-error@-2 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+ // lax-vector-none-error@-1 {{assigning to 'sve_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+ // lax-vector-integer-error@-2 {{assigning to 'sve_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+ sf64 = ff32;
+ // lax-vector-none-error@-1 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
+ // lax-vector-integer-error@-2 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
+}
+
+void gnu_allowed_with_integer_lax_conversions() {
+ gnu_fixed_int32_t fi32;
+ svint64_t si64;
+
+ // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
+ // -flax-vector-conversions={integer,all}.
+ fi32 = si64;
+ // lax-vector-none-error@-1 {{assigning to 'gnu_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+ si64 = fi32;
+ // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
+}
+
+void gnu_allowed_with_all_lax_conversions() {
+ gnu_fixed_float32_t ff32;
+ svfloat64_t sf64;
+
+ // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if
+ // -flax-vector-conversions=all.
+ ff32 = sf64;
+ // lax-vector-none-error@-1 {{assigning to 'gnu_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+ // lax-vector-integer-error@-2 {{assigning to 'gnu_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
sf64 = ff32;
// lax-vector-none-error@-1 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
// lax-vector-integer-error@-2 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
Index: clang/lib/AST/ASTContext.cpp
===================================================================
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -8586,7 +8586,8 @@
const auto *VecTy = SecondType->getAs<VectorType>();
if (VecTy &&
- VecTy->getVectorKind() == VectorType::SveFixedLengthDataVector) {
+ (VecTy->getVectorKind() == VectorType::SveFixedLengthDataVector ||
+ VecTy->getVectorKind() == VectorType::GenericVector)) {
const LangOptions::LaxVectorConversionKind LVCKind =
getLangOpts().getLaxVectorConversions();
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits