| 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 +avx512f -target-feature +evex512 -verify=both -o - -S |
| 5 |
// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx512f -target-feature -evex512 -verify=avx512-256 -DNOEVEX512 -o - -S |
| 6 |
// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx10.1-512 -verify=both -o - -S |
| 7 |
// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx10.1-256 -verify=avx512-256 -o - -S |
| 8 |
// REQUIRES: x86-registered-target |
| 9 |
|
| 10 |
// both-no-diagnostics |
| 11 |
|
| 12 |
typedef short avx512fType __attribute__((vector_size(64))); |
| 13 |
typedef short avx256Type __attribute__((vector_size(32))); |
| 14 |
|
| 15 |
__attribute__((target("avx"))) void takesAvx256(avx256Type t); |
| 16 |
__attribute__((target("avx512f"))) void takesAvx512(avx512fType t); |
| 17 |
__attribute__((target("avx512f,evex512"))) void takesAvx512_2(avx512fType t); |
| 18 |
void takesAvx256_no_target(avx256Type t); |
| 19 |
void takesAvx512_no_target(avx512fType t); |
| 20 |
|
| 21 |
void variadic(int i, ...); |
| 22 |
__attribute__((target("avx512f"))) void variadic_err(int i, ...); |
| 23 |
|
| 24 |
// If neither side has an attribute, warn. |
| 25 |
void call_warn(void) { |
| 26 |
avx256Type t1; |
| 27 |
takesAvx256_no_target(t1); // no256-warning {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}} |
| 28 |
|
| 29 |
avx512fType t2; |
| 30 |
// avx512-256-error@+1 {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'evex512' enabled changes the ABI}} |
| 31 |
takesAvx512_no_target(t2); // no512-warning {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}} |
| 32 |
|
| 33 |
variadic(1, t1); // no256-warning {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}} |
| 34 |
// avx512-256-error@+1 {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'evex512' enabled changes the ABI}} |
| 35 |
variadic(3, t2); // no512-warning {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}} |
| 36 |
} |
| 37 |
|
| 38 |
// If only 1 side has an attribute, error. |
| 39 |
void call_errors(void) { |
| 40 |
avx256Type t1; |
| 41 |
takesAvx256(t1); // no256-error {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}} |
| 42 |
avx512fType t2; |
| 43 |
// avx512-256-error@+1 {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'evex512' enabled changes the ABI}} |
| 44 |
takesAvx512(t2); // no512-error {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}} |
| 45 |
|
| 46 |
variadic_err(1, t1); // no256-error {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}} |
| 47 |
// avx512-256-error@+1 {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'evex512' enabled changes the ABI}} |
| 48 |
variadic_err(3, t2); // no512-error {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}} |
| 49 |
} |
| 50 |
|
| 51 |
// Check that these errors are treated as non-fatal, so we can report them for |
| 52 |
// all functions, not just the first. |
| 53 |
void call_errors_2(void) { |
| 54 |
avx256Type t1; |
| 55 |
takesAvx256(t1); // no256-error {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}} |
| 56 |
avx512fType t2; |
| 57 |
// avx512-256-error@+1 {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'evex512' enabled changes the ABI}} |
| 58 |
takesAvx512(t2); // no512-error {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}} |
| 59 |
|
| 60 |
variadic_err(1, t1); // no256-error {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}} |
| 61 |
// avx512-256-error@+1 {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'evex512' enabled changes the ABI}} |
| 62 |
variadic_err(3, t2); // no512-error {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}} |
| 63 |
} |
| 64 |
|
| 65 |
__attribute__((target("avx"))) void call_avx256_ok(void) { |
| 66 |
avx256Type t; |
| 67 |
takesAvx256(t); |
| 68 |
} |
| 69 |
|
| 70 |
// Option -mno-evex512 affects target attributes. To retain the 512-bit capability, an explict "evex512" must be added together. |
| 71 |
__attribute__((target("avx512f,evex512"))) void call_avx512_ok1(void) { |
| 72 |
avx512fType t; |
| 73 |
takesAvx512_2(t); |
| 74 |
} |
| 75 |
|
| 76 |
__attribute__((target("avx512f"))) void call_avx512_ok2(void) { |
| 77 |
avx512fType t; |
| 78 |
#if defined(NOEVEX512) |
| 79 |
// avx512-256-error@+2 {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'evex512' enabled changes the ABI}} |
| 80 |
#endif |
| 81 |
takesAvx512(t); |
| 82 |
} |
| 83 |
#if defined(__AVX10_1__) |
| 84 |
// avx512-256-warning@*:* {{invalid feature combination: +avx512f +avx10.1-256; will be promoted to avx10.1-512}} |
| 85 |
// avx512-256-warning@*:* {{invalid feature combination: +avx512f +avx10.1-256; will be promoted to avx10.1-512}} |
| 86 |
// avx512-256-warning@*:* {{invalid feature combination: +avx512f +avx10.1-256; will be promoted to avx10.1-512}} |
| 87 |
// avx512-256-warning@*:* {{invalid feature combination: +avx512f +avx10.1-256; will be promoted to avx10.1-512}} |
| 88 |
// avx512-256-warning@*:* {{invalid feature combination: +avx512f +avx10.1-256; will be promoted to avx10.1-512}} |
| 89 |
// avx512-256-warning@*:* {{invalid feature combination: +avx512f +avx10.1-256; will be promoted to avx10.1-512}} |
| 90 |
// avx512-256-warning@*:* {{invalid feature combination: +avx512f +avx10.1-256; will be promoted to avx10.1-512}} |
| 91 |
// avx512-256-warning@*:* {{invalid feature combination: +avx512f +avx10.1-256; will be promoted to avx10.1-512}} |
| 92 |
// avx512-256-warning@*:* {{invalid feature combination: +avx512f +avx10.1-256; will be promoted to avx10.1-512}} |
| 93 |
// avx512-256-warning@*:* {{invalid feature combination: +avx512f +avx10.1-256; will be promoted to avx10.1-512}} |
| 94 |
// avx512-256-warning@*:* {{invalid feature combination: +avx512f +avx10.1-256; will be promoted to avx10.1-512}} |
| 95 |
// avx512-256-warning@*:* {{invalid feature combination: +avx512f +avx10.1-256; will be promoted to avx10.1-512}} |
| 96 |
// avx512-256-warning@*:* {{invalid feature combination: +avx512f +avx10.1-256; will be promoted to avx10.1-512}} |
| 97 |
// avx512-256-warning@*:* {{invalid feature combination: +avx512f +avx10.1-256; will be promoted to avx10.1-512}} |
| 98 |
// avx512-256-warning@*:* {{invalid feature combination: +avx512f +avx10.1-256; will be promoted to avx10.1-512}} |
| 99 |
// avx512-256-warning@*:* {{invalid feature combination: +avx512f +avx10.1-256; will be promoted to avx10.1-512}} |
| 100 |
// avx512-256-warning@*:* {{invalid feature combination: +avx512f +avx10.1-256; will be promoted to avx10.1-512}} |
| 101 |
#endif |