xref: /llvm-project/clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c (revision 123064dc397d478a636ba1c5960d41ad381036a0)
1 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=1 -mvscale-max=1 -flax-vector-conversions=none -ffreestanding -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=2 -mvscale-max=2 -flax-vector-conversions=none -ffreestanding -fsyntax-only -verify %s
3 // 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 %s
4 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=8 -mvscale-max=8 -flax-vector-conversions=none -ffreestanding -fsyntax-only -verify %s
5 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=16 -mvscale-max=16 -flax-vector-conversions=none -ffreestanding -fsyntax-only -verify %s
6 
7 // expected-no-diagnostics
8 
9 // REQUIRES: aarch64-registered-target || arm-registered-target
10 
11 #include <arm_sve.h>
12 
13 #define N __ARM_FEATURE_SVE_BITS
14 #define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
15 
16 typedef svfloat32_t fixed_float32_t FIXED_ATTR;
17 typedef svfloat64_t fixed_float64_t FIXED_ATTR;
18 typedef svint32_t fixed_int32_t FIXED_ATTR;
19 typedef svint64_t fixed_int64_t FIXED_ATTR;
20 
21 // SVE VLSTs can be cast to SVE VLATs, regardless of lane size.
22 // NOTE: the list below is NOT exhaustive for all SVE types.
23 
24 #define CAST(from, to) \
25     void from##_to_##to(from a, to b) { \
26         b = (to) a; \
27     }
28 
29 #define TESTCASE(ty1, ty2) \
30     CAST(ty1, ty2) \
31     CAST(ty2, ty1)
32 
33 TESTCASE(fixed_float32_t, svfloat32_t)
34 TESTCASE(fixed_float32_t, svfloat64_t)
35 TESTCASE(fixed_float32_t, svint32_t)
36 TESTCASE(fixed_float32_t, svint64_t)
37 
38 TESTCASE(fixed_float64_t, svfloat32_t)
39 TESTCASE(fixed_float64_t, svfloat64_t)
40 TESTCASE(fixed_float64_t, svint32_t)
41 TESTCASE(fixed_float64_t, svint64_t)
42 
43 TESTCASE(fixed_int32_t, svfloat32_t)
44 TESTCASE(fixed_int32_t, svfloat64_t)
45 TESTCASE(fixed_int32_t, svint32_t)
46 TESTCASE(fixed_int32_t, svint64_t)
47 
48 TESTCASE(fixed_int64_t, svfloat32_t)
49 TESTCASE(fixed_int64_t, svfloat64_t)
50 TESTCASE(fixed_int64_t, svint32_t)
51 TESTCASE(fixed_int64_t, svint64_t)
52