113 lines · cpp
1// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=4 -mvscale-max=4 -flax-vector-conversions=none -ffreestanding -fsyntax-only -verify=lax-vector-none %s2// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=4 -mvscale-max=4 -flax-vector-conversions=integer -ffreestanding -fsyntax-only -verify=lax-vector-integer %s3// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=4 -mvscale-max=4 -flax-vector-conversions=all -ffreestanding -fsyntax-only -verify=lax-vector-all %s4 5// REQUIRES: aarch64-registered-target || arm-registered-target6 7#include <arm_sve.h>8 9#define N __ARM_FEATURE_SVE_BITS10#define SVE_FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))11#define GNU_FIXED_ATTR __attribute__((vector_size(N / 8)))12#define GNU_BOOL_FIXED_ATTR __attribute__((vector_size(N / 64)))13 14typedef svfloat32_t sve_fixed_float32_t SVE_FIXED_ATTR;15typedef svint32_t sve_fixed_int32_t SVE_FIXED_ATTR;16typedef svbool_t sve_fixed_bool_t SVE_FIXED_ATTR;17typedef float gnu_fixed_float32_t GNU_FIXED_ATTR;18typedef int gnu_fixed_int32_t GNU_FIXED_ATTR;19typedef int8_t gnu_fixed_bool_t GNU_BOOL_FIXED_ATTR;20 21void sve_allowed_with_integer_lax_conversions() {22 sve_fixed_int32_t fi32;23 svint64_t si64;24 svbool_t sb8;25 sve_fixed_bool_t fb8;26 27 // The implicit cast here should fail if -flax-vector-conversions=none, but pass if28 // -flax-vector-conversions={integer,all}.29 fi32 = si64;30 // lax-vector-none-error@-1 {{assigning to 'sve_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}31 si64 = fi32;32 // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}33 34 fi32 = sb8;35 // lax-vector-none-error@-1 {{assigning to 'sve_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}36 // lax-vector-integer-error@-2 {{assigning to 'sve_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}37 // lax-vector-all-error@-3 {{assigning to 'sve_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}38 sb8 = fi32;39 // lax-vector-none-error@-1 {{assigning to 'svbool_t' (aka '__SVBool_t') from incompatible type}}40 // lax-vector-integer-error@-2 {{assigning to 'svbool_t' (aka '__SVBool_t') from incompatible type}}41 // lax-vector-all-error@-3 {{assigning to 'svbool_t' (aka '__SVBool_t') from incompatible type}}42 43 si64 = fb8;44 // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}45 // lax-vector-integer-error@-2 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}46 // lax-vector-all-error@-3 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}47 48 fb8 = si64;49 // lax-vector-none-error@-1 {{assigning to 'sve_fixed_bool_t' (vector of 8 'unsigned char' values) from incompatible type}}50 // lax-vector-integer-error@-2 {{assigning to 'sve_fixed_bool_t' (vector of 8 'unsigned char' values) from incompatible type}}51 // lax-vector-all-error@-3 {{assigning to 'sve_fixed_bool_t' (vector of 8 'unsigned char' values) from incompatible type}}52}53 54void sve_allowed_with_all_lax_conversions() {55 sve_fixed_float32_t ff32;56 svfloat64_t sf64;57 58 // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if59 // -flax-vector-conversions=all.60 ff32 = sf64;61 // lax-vector-none-error@-1 {{assigning to 'sve_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}62 // lax-vector-integer-error@-2 {{assigning to 'sve_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}63 sf64 = ff32;64 // lax-vector-none-error@-1 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}65 // lax-vector-integer-error@-2 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}66}67 68void gnu_allowed_with_integer_lax_conversions() {69 gnu_fixed_int32_t fi32;70 svint64_t si64;71 svbool_t sb8;72 gnu_fixed_bool_t fb8;73 74 // The implicit cast here should fail if -flax-vector-conversions=none, but pass if75 // -flax-vector-conversions={integer,all}.76 fi32 = si64;77 // lax-vector-none-error@-1 {{assigning to 'gnu_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}78 si64 = fi32;79 // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}80 81 fi32 = sb8;82 // lax-vector-none-error@-1 {{assigning to 'gnu_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}83 // lax-vector-integer-error@-2 {{assigning to 'gnu_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}84 // lax-vector-all-error@-3 {{assigning to 'gnu_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}85 sb8 = fi32;86 // lax-vector-none-error@-1 {{assigning to 'svbool_t' (aka '__SVBool_t') from incompatible type}}87 // lax-vector-integer-error@-2 {{assigning to 'svbool_t' (aka '__SVBool_t') from incompatible type}}88 // lax-vector-all-error@-3 {{assigning to 'svbool_t' (aka '__SVBool_t') from incompatible type}}89 90 fb8 = si64;91 // lax-vector-none-error@-1 {{assigning to 'gnu_fixed_bool_t' (vector of 8 'int8_t' values) from incompatible type}}92 // lax-vector-integer-error@-2 {{assigning to 'gnu_fixed_bool_t' (vector of 8 'int8_t' values) from incompatible type}}93 // lax-vector-all-error@-3 {{assigning to 'gnu_fixed_bool_t' (vector of 8 'int8_t' values) from incompatible type}}94 si64 = fb8;95 // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}96 // lax-vector-integer-error@-2 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}97 // lax-vector-all-error@-3 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}98}99 100void gnu_allowed_with_all_lax_conversions() {101 gnu_fixed_float32_t ff32;102 svfloat64_t sf64;103 104 // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if105 // -flax-vector-conversions=all.106 ff32 = sf64;107 // lax-vector-none-error@-1 {{assigning to 'gnu_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}108 // lax-vector-integer-error@-2 {{assigning to 'gnu_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}109 sf64 = ff32;110 // lax-vector-none-error@-1 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}111 // lax-vector-integer-error@-2 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}112}113