1 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=128 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=256 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
3 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
4 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=1024 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
5 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=2048 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
6 
7 // expected-no-diagnostics
8 
9 #include <arm_sve.h>
10 
11 #define N __ARM_FEATURE_SVE_BITS
12 #define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
13 
14 typedef svfloat32_t fixed_float32_t FIXED_ATTR;
15 typedef svfloat64_t fixed_float64_t FIXED_ATTR;
16 typedef svint32_t fixed_int32_t FIXED_ATTR;
17 typedef svint64_t fixed_int64_t FIXED_ATTR;
18 typedef svbool_t fixed_bool_t FIXED_ATTR;
19 
20 // SVE VLSTs can be cast to SVE VLATs, regardless of lane size.
21 // NOTE: the list below is NOT exhaustive for all SVE types.
22 
23 #define CAST(from, to) \
24     void from##_to_##to(from a, to b) { \
25         b = (to) a; \
26     }
27 
28 #define TESTCASE(ty1, ty2) \
29     CAST(ty1, ty2) \
30     CAST(ty2, ty1)
31 
32 TESTCASE(fixed_float32_t, svfloat32_t)
33 TESTCASE(fixed_float32_t, svfloat64_t)
34 TESTCASE(fixed_float32_t, svint32_t)
35 TESTCASE(fixed_float32_t, svint64_t)
36 
37 TESTCASE(fixed_float64_t, svfloat32_t)
38 TESTCASE(fixed_float64_t, svfloat64_t)
39 TESTCASE(fixed_float64_t, svint32_t)
40 TESTCASE(fixed_float64_t, svint64_t)
41 
42 TESTCASE(fixed_int32_t, svfloat32_t)
43 TESTCASE(fixed_int32_t, svfloat64_t)
44 TESTCASE(fixed_int32_t, svint32_t)
45 TESTCASE(fixed_int32_t, svint64_t)
46 
47 TESTCASE(fixed_int64_t, svfloat32_t)
48 TESTCASE(fixed_int64_t, svfloat64_t)
49 TESTCASE(fixed_int64_t, svint32_t)
50 TESTCASE(fixed_int64_t, svint64_t)
51 
52 TESTCASE(fixed_bool_t, svbool_t)
53