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 %s |
2 | |
3 | #pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : enable |
4 | |
5 | // All intel_sub_group_avc_* types can only be used as argument or return value |
6 | // of built-in functions defined in the extension. |
7 | // But there are also additional initialization rules: |
8 | // * All types except intel_sub_group_avc_mce_* types can be initialized with |
9 | // the corresponding initializer macro defined in opencl-c.h |
10 | // Currently all these macroses are defined as 0x0 |
11 | // * In previous versions of the extension these macroses was defined as {0}, |
12 | // so initialization with initializer list containing one integer equal to |
13 | // zero should also work |
14 | |
15 | struct st{}; |
16 | // negative test cases for initializers |
17 | void foo(char c, float f, void* v, struct st ss) { |
18 | intel_sub_group_avc_mce_payload_t payload_mce = 0; // No zero initializer for mce types |
19 | // expected-error@-1 {{initializing 'intel_sub_group_avc_mce_payload_t' with an expression of incompatible type 'int'}} |
20 | intel_sub_group_avc_ime_payload_t payload_ime = 1; // No literal initializer for *payload_t types |
21 | // expected-error@-1 {{initializing 'intel_sub_group_avc_ime_payload_t' with an expression of incompatible type 'int'}} |
22 | intel_sub_group_avc_ref_payload_t payload_ref = f; |
23 | // expected-error@-1 {{initializing 'intel_sub_group_avc_ref_payload_t' with an expression of incompatible type 'float'}} |
24 | intel_sub_group_avc_sic_payload_t payload_sic = ss; |
25 | // expected-error@-1 {{initializing 'intel_sub_group_avc_sic_payload_t' with an expression of incompatible type 'struct st'}} |
26 | |
27 | intel_sub_group_avc_mce_result_t result_mce = 0; // No zero initializer for mce types |
28 | // expected-error@-1 {{initializing 'intel_sub_group_avc_mce_result_t' with an expression of incompatible type 'int'}} |
29 | intel_sub_group_avc_ime_result_t result_ime = 1; // No literal initializer for *result_t types |
30 | // expected-error@-1 {{initializing 'intel_sub_group_avc_ime_result_t' with an expression of incompatible type 'int'}} |
31 | intel_sub_group_avc_ref_result_t result_ref = f; |
32 | // expected-error@-1 {{initializing 'intel_sub_group_avc_ref_result_t' with an expression of incompatible type 'float'}} |
33 | intel_sub_group_avc_sic_result_t result_sic = ss; |
34 | // expected-error@-1 {{initializing 'intel_sub_group_avc_sic_result_t' with an expression of incompatible type 'struct st'}} |
35 | |
36 | intel_sub_group_avc_ime_result_single_reference_streamout_t sstreamout = v; |
37 | // expected-error@-1 {{initializing 'intel_sub_group_avc_ime_result_single_reference_streamout_t' with an expression of incompatible type 'void *'}} |
38 | |
39 | intel_sub_group_avc_ime_result_dual_reference_streamout_t dstreamin_list = {0x0, 0x1}; |
40 | // expected-warning@-1 {{excess elements in struct initializer}} |
41 | intel_sub_group_avc_ime_dual_reference_streamin_t dstreamin_list2 = {}; |
42 | // expected-error@-1 {{scalar initializer cannot be empty}} |
43 | intel_sub_group_avc_ime_single_reference_streamin_t dstreamin_list3 = {c}; |
44 | // expected-error@-1 {{initializing 'intel_sub_group_avc_ime_single_reference_streamin_t' with an expression of incompatible type 'char'}} |
45 | intel_sub_group_avc_ime_dual_reference_streamin_t dstreamin_list4 = {1}; |
46 | // expected-error@-1 {{initializing 'intel_sub_group_avc_ime_dual_reference_streamin_t' with an expression of incompatible type 'int'}} |
47 | } |
48 | |
49 | // negative tests for initializers and assignment |
50 | void far() { |
51 | intel_sub_group_avc_mce_payload_t payload_mce; |
52 | intel_sub_group_avc_mce_payload_t payload_mce2 = payload_mce; |
53 | |
54 | intel_sub_group_avc_ime_payload_t payload_ime; |
55 | intel_sub_group_avc_ref_payload_t payload_ref = payload_ime; |
56 | // expected-error@-1 {{initializing 'intel_sub_group_avc_ref_payload_t' with an expression of incompatible type 'intel_sub_group_avc_ime_payload_t'}} |
57 | |
58 | intel_sub_group_avc_sic_result_t result_sic; |
59 | intel_sub_group_avc_ime_result_t result_ime; |
60 | result_sic = result_ime; |
61 | // expected-error@-1 {{assigning to 'intel_sub_group_avc_sic_result_t' from incompatible type 'intel_sub_group_avc_ime_result_t'}} |
62 | } |
63 | |
64 | // Using 0x0 directly allows us not to include opencl-c.h header and not to |
65 | // redefine all of these CLK_AVC_*_INTITIALIZE_INTEL macro. '0x0' value must |
66 | // be in sync with ones defined in opencl-c.h |
67 | |
68 | // positive test cases |
69 | void bar() { |
70 | const sampler_t vme_sampler = 0x0; |
71 | |
72 | intel_sub_group_avc_mce_payload_t payload_mce; // No literal initializer for mce types |
73 | intel_sub_group_avc_ime_payload_t payload_ime = 0x0; |
74 | intel_sub_group_avc_ref_payload_t payload_ref = 0x0; |
75 | intel_sub_group_avc_sic_payload_t payload_sic = 0x0; |
76 | |
77 | intel_sub_group_avc_mce_result_t result_mce; // No literal initializer for mce types |
78 | intel_sub_group_avc_ime_result_t result_ime = 0x0; |
79 | intel_sub_group_avc_ref_result_t result_ref = 0x0; |
80 | intel_sub_group_avc_sic_result_t result_sic = 0x0; |
81 | |
82 | intel_sub_group_avc_ime_result_single_reference_streamout_t sstreamout = 0x0; |
83 | intel_sub_group_avc_ime_result_dual_reference_streamout_t dstreamout = 0x0; |
84 | intel_sub_group_avc_ime_single_reference_streamin_t sstreamin = 0x0; |
85 | intel_sub_group_avc_ime_dual_reference_streamin_t dstreamin = 0x0; |
86 | |
87 | // It is allowed to assign variables of the same types |
88 | intel_sub_group_avc_mce_payload_t pauload_mce2 = payload_mce; |
89 | |
90 | // Initialization with initializer list was supported in the first version |
91 | // of the extension. So we check for backward compatibility here. |
92 | intel_sub_group_avc_ime_payload_t payload_ime_list = {0}; |
93 | intel_sub_group_avc_ref_payload_t payload_ref_list = {0}; |
94 | intel_sub_group_avc_sic_payload_t payload_sic_list = {0}; |
95 | |
96 | intel_sub_group_avc_ime_result_t result_ime_list = {0}; |
97 | intel_sub_group_avc_ref_result_t result_ref_list = {0}; |
98 | intel_sub_group_avc_sic_result_t result_sic_list = {0}; |
99 | |
100 | intel_sub_group_avc_ime_result_single_reference_streamout_t sstreamout_list = {0}; |
101 | intel_sub_group_avc_ime_result_dual_reference_streamout_t dstreamout_list = {0}; |
102 | intel_sub_group_avc_ime_single_reference_streamin_t sstreamin_list = {0}; |
103 | intel_sub_group_avc_ime_dual_reference_streamin_t dstreamin_list = {0}; |
104 | } |
105 | |
106 | |