Debian Codegraph @

clang/test/CodeGen/target-avx-abi-diag.c

raw
1 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -verify=no256,no512 -o - -S
2 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx -verify=no512 -o - -S
3 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx512f -verify=both -o - -S
4 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx10.1 -verify=both -o - -S
5 // REQUIRES: x86-registered-target
6
7 // both-no-diagnostics
8
9 typedef short avx512fType __attribute__((vector_size(64)));
10 typedef short avx256Type __attribute__((vector_size(32)));
11
12 __attribute__((target("avx"))) void takesAvx256(avx256Type t);
13 __attribute__((target("avx512f"))) void takesAvx512(avx512fType t);
14 void takesAvx256_no_target(avx256Type t);
15 void takesAvx512_no_target(avx512fType t);
16
17 void variadic(int i, ...);
18 __attribute__((target("avx512f"))) void variadic_err(int i, ...);
19
20 // If neither side has an attribute, warn.
21 void call_warn(void) {
22 avx256Type t1;
23 takesAvx256_no_target(t1); // no256-warning {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}}
24
25 avx512fType t2;
26 takesAvx512_no_target(t2); // no512-warning {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}}
27
28 variadic(1, t1); // no256-warning {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}}
29 variadic(3, t2); // no512-warning {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}}
30 }
31
32 // If only 1 side has an attribute, error.
33 void call_errors(void) {
34 avx256Type t1;
35 takesAvx256(t1); // no256-error {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}}
36 avx512fType t2;
37 takesAvx512(t2); // no512-error {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}}
38
39 variadic_err(1, t1); // no256-error {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}}
40 variadic_err(3, t2); // no512-error {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}}
41 }
42
43 __attribute__((target("avx"))) void call_avx256_ok(void) {
44 avx256Type t;
45 takesAvx256(t);
46 }
47
48 __attribute__((target("avx512f"))) void call_avx512_ok2(void) {
49 avx512fType t;
50 takesAvx512(t);
51 }