1 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.4-library -finclude-default-header -verify -fnative-half-type %s
2 // RUN: %clang_cc1 -triple spirv-linux-vulkan-library -finclude-default-header -verify -fnative-half-type %s
4 // expected-no-diagnostics
5 #define SizeCheck(Ty, SizeInBits) \
6 _Static_assert(sizeof(Ty) == SizeInBits / 8, #Ty " is " #SizeInBits "-bit"); \
7 _Static_assert(sizeof(Ty##1) == (SizeInBits * 1) / 8, #Ty "1 is 1x" #SizeInBits "-bit"); \
8 _Static_assert(__builtin_vectorelements(Ty##1) == 1, #Ty "1 is has 1 " #SizeInBits "-bit element"); \
9 _Static_assert(sizeof(Ty##2) == (SizeInBits * 2) / 8, #Ty "2 is 2x" #SizeInBits "-bit"); \
10 _Static_assert(__builtin_vectorelements(Ty##2) == 2, #Ty "2 is has 2 " #SizeInBits "-bit element"); \
11 _Static_assert(__builtin_vectorelements(Ty##3) == 3, #Ty "3 is has 3 " #SizeInBits "-bit element"); \
12 _Static_assert(sizeof(Ty##4) == (SizeInBits * 4) / 8, #Ty "4 is 4x" #SizeInBits "-bit"); \
13 _Static_assert(__builtin_vectorelements(Ty##4) == 4, #Ty "4 is has 4 " #SizeInBits "-bit element");
15 // FIXME: https://github.com/llvm/llvm-project/issues/104503 - 3 element vectors
16 // should be the size of 3 elements not padded to 4.
17 // _Static_assert(sizeof(Ty##3) == (SizeInBits * 3) / 8, #Ty "3 is 3x" #SizeInBits "-bit");
19 SizeCheck(int16_t, 16);
20 SizeCheck(uint16_t, 16);
22 SizeCheck(float16_t, 16);
26 SizeCheck(int32_t, 32);
27 SizeCheck(uint32_t, 32);
29 SizeCheck(float32_t, 32);
31 SizeCheck(int64_t, 64);
32 SizeCheck(uint64_t, 64);
33 SizeCheck(double, 64);
34 SizeCheck(float64_t, 64);