Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaOpenCL / intel-subgroup-avc-ext-types.cl
blobadddead3eb412264803ff84d55aca2e6ee35be44
1 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL1.2 -cl-ext=+cl_intel_device_side_avc_motion_estimation -fsyntax-only -verify -DEXT %s
2 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL1.2 -cl-ext=-cl_intel_device_side_avc_motion_estimation -fsyntax-only -verify %s
4 #ifdef cl_intel_device_side_avc_motion_estimation
5 #pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : enable
6 #endif
8 // All intel_sub_group_avc_* types can only be used as argument or return value
9 // of built-in functions defined in the extension.
10 // But there are also additional initialization rules:
11 // * All types except intel_sub_group_avc_mce_* types can be initialized with
12 // the corresponding initializer macro defined in opencl-c.h
13 // Currently all these macroses are defined as 0x0
14 // * In previous versions of the extension these macroses was defined as {0},
15 // so initialization with initializer list containing one integer equal to
16 // zero should also work
18 struct st{};
19 // negative test cases for initializers
20 void foo(char c, float f, void* v, struct st ss) {
21 intel_sub_group_avc_mce_payload_t payload_mce = 0; // No zero initializer for mce types
22 intel_sub_group_avc_ime_payload_t payload_ime = 1; // No literal initializer for *payload_t types
23 intel_sub_group_avc_ref_payload_t payload_ref = f;
24 intel_sub_group_avc_sic_payload_t payload_sic = ss;
25 intel_sub_group_avc_mce_result_t result_mce = 0; // No zero initializer for mce types
26 intel_sub_group_avc_ime_result_t result_ime = 1; // No literal initializer for *result_t types
27 intel_sub_group_avc_ref_result_t result_ref = f;
28 intel_sub_group_avc_sic_result_t result_sic = ss;
29 intel_sub_group_avc_ime_result_single_reference_streamout_t sstreamout = v;
30 intel_sub_group_avc_ime_result_dual_reference_streamout_t dstreamin_list = {0x0, 0x1};
31 intel_sub_group_avc_ime_single_reference_streamin_t dstreamin_list3 = {c};
32 intel_sub_group_avc_ime_dual_reference_streamin_t dstreamin_list4 = {1};
33 #ifdef EXT
34 // expected-error@-13 {{initializing '__private intel_sub_group_avc_mce_payload_t' with an expression of incompatible type 'int'}}
35 // expected-error@-13 {{initializing '__private intel_sub_group_avc_ime_payload_t' with an expression of incompatible type 'int'}}
36 // expected-error@-13 {{initializing '__private intel_sub_group_avc_ref_payload_t' with an expression of incompatible type '__private float'}}
37 // expected-error@-13 {{initializing '__private intel_sub_group_avc_sic_payload_t' with an expression of incompatible type '__private struct st'}}
38 // expected-error@-13 {{initializing '__private intel_sub_group_avc_mce_result_t' with an expression of incompatible type 'int'}}
39 // expected-error@-13 {{initializing '__private intel_sub_group_avc_ime_result_t' with an expression of incompatible type 'int'}}
40 // expected-error@-13 {{initializing '__private intel_sub_group_avc_ref_result_t' with an expression of incompatible type '__private float'}}
41 // expected-error@-13 {{initializing '__private intel_sub_group_avc_sic_result_t' with an expression of incompatible type '__private struct st'}}
42 // expected-error@-13 {{initializing '__private intel_sub_group_avc_ime_result_single_reference_streamout_t' with an expression of incompatible type '__private void *__private'}}
43 // expected-warning@-13 {{excess elements in struct initializer}}
44 // expected-error@-13 {{initializing '__private intel_sub_group_avc_ime_single_reference_streamin_t' with an expression of incompatible type '__private char'}}
45 // expected-error@-13 {{initializing '__private intel_sub_group_avc_ime_dual_reference_streamin_t' with an expression of incompatible type 'int'}}
46 #else
47 // expected-error@-26 {{use of undeclared identifier 'intel_sub_group_avc_mce_payload_t'}}
48 // expected-error@-26 {{use of undeclared identifier 'intel_sub_group_avc_ime_payload_t'}}
49 // expected-error@-26 {{use of undeclared identifier 'intel_sub_group_avc_ref_payload_t'}}
50 // expected-error@-26 {{use of undeclared identifier 'intel_sub_group_avc_sic_payload_t'}}
51 // expected-error@-26 {{use of undeclared identifier 'intel_sub_group_avc_mce_result_t'}}
52 // expected-error@-26 {{use of undeclared identifier 'intel_sub_group_avc_ime_result_t'}}
53 // expected-error@-26 {{use of undeclared identifier 'intel_sub_group_avc_ref_result_t'}}
54 // expected-error@-26 {{use of undeclared identifier 'intel_sub_group_avc_sic_result_t'}}
55 // expected-error@-26 {{use of undeclared identifier 'intel_sub_group_avc_ime_result_single_reference_streamout_t'}}
56 // expected-error@-26 {{use of undeclared identifier 'intel_sub_group_avc_ime_result_dual_reference_streamout_t'}}
57 // expected-error@-26 {{use of undeclared identifier 'intel_sub_group_avc_ime_single_reference_streamin_t'}}
58 // expected-error@-26 {{use of undeclared identifier 'intel_sub_group_avc_ime_dual_reference_streamin_t'}}
59 #endif
62 // negative tests for initializers and assignment
63 void far() {
64 intel_sub_group_avc_mce_payload_t payload_mce;
65 intel_sub_group_avc_mce_payload_t payload_mce2 = payload_mce;
66 intel_sub_group_avc_ime_payload_t payload_ime;
67 intel_sub_group_avc_ref_payload_t payload_ref = payload_ime;
68 intel_sub_group_avc_sic_result_t result_sic;
69 intel_sub_group_avc_ime_result_t result_ime;
70 result_sic = result_ime;
71 #ifdef EXT
72 // expected-error@-5 {{initializing '__private intel_sub_group_avc_ref_payload_t' with an expression of incompatible type '__private intel_sub_group_avc_ime_payload_t'}}
73 // expected-error@-3 {{assigning to '__private intel_sub_group_avc_sic_result_t' from incompatible type '__private intel_sub_group_avc_ime_result_t'}}
74 #else
75 // expected-error@-11 {{use of undeclared identifier 'intel_sub_group_avc_mce_payload_t'}}
76 // expected-error@-11 {{use of undeclared identifier 'intel_sub_group_avc_mce_payload_t'}}
77 // expected-error@-11 {{use of undeclared identifier 'intel_sub_group_avc_ime_payload_t'}}
78 // expected-error@-11 {{use of undeclared identifier 'intel_sub_group_avc_ref_payload_t'}}
79 // expected-error@-11 {{use of undeclared identifier 'intel_sub_group_avc_sic_result_t'}}
80 // expected-error@-11 {{use of undeclared identifier 'intel_sub_group_avc_ime_result_t'}}
81 // expected-error@-11 {{use of undeclared identifier 'result_sic'}} expected-error@-11 {{use of undeclared identifier 'result_ime'}}
82 #endif
85 // Using 0x0 directly allows us not to include opencl-c.h header and not to
86 // redefine all of these CLK_AVC_*_INTITIALIZE_INTEL macro. '0x0' value must
87 // be in sync with ones defined in opencl-c.h
89 #ifdef EXT
90 // positive test cases
91 void bar() {
92 const sampler_t vme_sampler = 0x0;
94 intel_sub_group_avc_mce_payload_t payload_mce; // No literal initializer for mce types
95 intel_sub_group_avc_ime_payload_t payload_ime = 0x0;
96 intel_sub_group_avc_ref_payload_t payload_ref = 0x0;
97 intel_sub_group_avc_sic_payload_t payload_sic = 0x0;
99 intel_sub_group_avc_mce_result_t result_mce; // No literal initializer for mce types
100 intel_sub_group_avc_ime_result_t result_ime = 0x0;
101 intel_sub_group_avc_ref_result_t result_ref = 0x0;
102 intel_sub_group_avc_sic_result_t result_sic = 0x0;
104 intel_sub_group_avc_ime_result_single_reference_streamout_t sstreamout = 0x0;
105 intel_sub_group_avc_ime_result_dual_reference_streamout_t dstreamout = 0x0;
106 intel_sub_group_avc_ime_single_reference_streamin_t sstreamin = 0x0;
107 intel_sub_group_avc_ime_dual_reference_streamin_t dstreamin = 0x0;
109 // It is allowed to assign variables of the same types
110 intel_sub_group_avc_mce_payload_t pauload_mce2 = payload_mce;
112 // Initialization with initializer list was supported in the first version
113 // of the extension. So we check for backward compatibility here.
114 intel_sub_group_avc_ime_payload_t payload_ime_list = {0};
115 intel_sub_group_avc_ref_payload_t payload_ref_list = {0};
116 intel_sub_group_avc_sic_payload_t payload_sic_list = {0};
118 intel_sub_group_avc_ime_result_t result_ime_list = {0};
119 intel_sub_group_avc_ref_result_t result_ref_list = {0};
120 intel_sub_group_avc_sic_result_t result_sic_list = {0};
122 intel_sub_group_avc_ime_result_single_reference_streamout_t sstreamout_list = {0};
123 intel_sub_group_avc_ime_result_dual_reference_streamout_t dstreamout_list = {0};
124 intel_sub_group_avc_ime_single_reference_streamin_t sstreamin_list = {0};
125 intel_sub_group_avc_ime_dual_reference_streamin_t dstreamin_list = {0};
127 #endif //EXT