| 1 |
// RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +f -target-feature +d -target-feature +zve64d -mvscale-min=8 -mvscale-max=8 -flax-vector-conversions=none -ffreestanding -fsyntax-only -verify=lax-vector-none %s |
| 2 |
// RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +f -target-feature +d -target-feature +zve64d -mvscale-min=8 -mvscale-max=8 -flax-vector-conversions=integer -ffreestanding -fsyntax-only -verify=lax-vector-integer %s |
| 3 |
// RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +f -target-feature +d -target-feature +zve64d -mvscale-min=8 -mvscale-max=8 -flax-vector-conversions=all -ffreestanding -fsyntax-only -verify=lax-vector-all %s |
| 4 |
|
| 5 |
// REQUIRES: riscv-registered-target |
| 6 |
|
| 7 |
#define RVV_FIXED_ATTR __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))) |
| 8 |
#define GNU_FIXED_ATTR __attribute__((vector_size(__riscv_v_fixed_vlen / 8))) |
| 9 |
|
| 10 |
typedef __rvv_int8m1_t vint8m1_t; |
| 11 |
typedef __rvv_uint8m1_t vuint8m1_t; |
| 12 |
typedef __rvv_int16m1_t vint16m1_t; |
| 13 |
typedef __rvv_uint16m1_t vuint16m1_t; |
| 14 |
typedef __rvv_int32m1_t vint32m1_t; |
| 15 |
typedef __rvv_uint32m1_t vuint32m1_t; |
| 16 |
typedef __rvv_int64m1_t vint64m1_t; |
| 17 |
typedef __rvv_uint64m1_t vuint64m1_t; |
| 18 |
typedef __rvv_float32m1_t vfloat32m1_t; |
| 19 |
typedef __rvv_float64m1_t vfloat64m1_t; |
| 20 |
|
| 21 |
typedef vfloat32m1_t rvv_fixed_float32m1_t RVV_FIXED_ATTR; |
| 22 |
typedef vint32m1_t rvv_fixed_int32m1_t RVV_FIXED_ATTR; |
| 23 |
typedef float gnu_fixed_float32m1_t GNU_FIXED_ATTR; |
| 24 |
typedef int gnu_fixed_int32m1_t GNU_FIXED_ATTR; |
| 25 |
|
| 26 |
void rvv_allowed_with_integer_lax_conversions() { |
| 27 |
rvv_fixed_int32m1_t fi32; |
| 28 |
vint64m1_t si64; |
| 29 |
|
| 30 |
// The implicit cast here should fail if -flax-vector-conversions=none, but pass if |
| 31 |
// -flax-vector-conversions={integer,all}. |
| 32 |
fi32 = si64; |
| 33 |
// lax-vector-none-error@-1 {{assigning to 'rvv_fixed_int32m1_t' (vector of 16 'int' values) from incompatible type}} |
| 34 |
// lax-vector-integer-error@-2 {{assigning to 'rvv_fixed_int32m1_t' (vector of 16 'int' values) from incompatible type}} |
| 35 |
// lax-vector-all-error@-3 {{assigning to 'rvv_fixed_int32m1_t' (vector of 16 'int' values) from incompatible type}} |
| 36 |
si64 = fi32; |
| 37 |
// lax-vector-none-error@-1 {{assigning to 'vint64m1_t' (aka '__rvv_int64m1_t') from incompatible type}} |
| 38 |
// lax-vector-integer-error@-2 {{assigning to 'vint64m1_t' (aka '__rvv_int64m1_t') from incompatible type}} |
| 39 |
// lax-vector-all-error@-3 {{assigning to 'vint64m1_t' (aka '__rvv_int64m1_t') from incompatible type}} |
| 40 |
} |
| 41 |
|
| 42 |
void rvv_allowed_with_all_lax_conversions() { |
| 43 |
rvv_fixed_float32m1_t ff32; |
| 44 |
vfloat64m1_t sf64; |
| 45 |
|
| 46 |
// The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if |
| 47 |
// -flax-vector-conversions=all. |
| 48 |
ff32 = sf64; |
| 49 |
// lax-vector-none-error@-1 {{assigning to 'rvv_fixed_float32m1_t' (vector of 16 'float' values) from incompatible type}} |
| 50 |
// lax-vector-integer-error@-2 {{assigning to 'rvv_fixed_float32m1_t' (vector of 16 'float' values) from incompatible type}} |
| 51 |
// lax-vector-all-error@-3 {{assigning to 'rvv_fixed_float32m1_t' (vector of 16 'float' values) from incompatible type}} |
| 52 |
sf64 = ff32; |
| 53 |
// lax-vector-none-error@-1 {{assigning to 'vfloat64m1_t' (aka '__rvv_float64m1_t') from incompatible type}} |
| 54 |
// lax-vector-integer-error@-2 {{assigning to 'vfloat64m1_t' (aka '__rvv_float64m1_t') from incompatible type}} |
| 55 |
// lax-vector-all-error@-3 {{assigning to 'vfloat64m1_t' (aka '__rvv_float64m1_t') from incompatible type}} |
| 56 |
} |
| 57 |
|
| 58 |
void gnu_allowed_with_integer_lax_conversions() { |
| 59 |
gnu_fixed_int32m1_t fi32; |
| 60 |
vint64m1_t si64; |
| 61 |
|
| 62 |
// The implicit cast here should fail if -flax-vector-conversions=none, but pass if |
| 63 |
// -flax-vector-conversions={integer,all}. |
| 64 |
fi32 = si64; |
| 65 |
// lax-vector-none-error@-1 {{assigning to 'gnu_fixed_int32m1_t' (vector of 16 'int' values) from incompatible type}} |
| 66 |
si64 = fi32; |
| 67 |
// lax-vector-none-error@-1 {{assigning to 'vint64m1_t' (aka '__rvv_int64m1_t') from incompatible type}} |
| 68 |
} |
| 69 |
|
| 70 |
void gnu_allowed_with_all_lax_conversions() { |
| 71 |
gnu_fixed_float32m1_t ff32; |
| 72 |
vfloat64m1_t sf64; |
| 73 |
|
| 74 |
// The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if |
| 75 |
// -flax-vector-conversions=all. |
| 76 |
ff32 = sf64; |
| 77 |
// lax-vector-none-error@-1 {{assigning to 'gnu_fixed_float32m1_t' (vector of 16 'float' values) from incompatible type}} |
| 78 |
// lax-vector-integer-error@-2 {{assigning to 'gnu_fixed_float32m1_t' (vector of 16 'float' values) from incompatible type}} |
| 79 |
sf64 = ff32; |
| 80 |
// lax-vector-none-error@-1 {{assigning to 'vfloat64m1_t' (aka '__rvv_float64m1_t') from incompatible type}} |
| 81 |
// lax-vector-integer-error@-2 {{assigning to 'vfloat64m1_t' (aka '__rvv_float64m1_t') from incompatible type}} |
| 82 |
} |