52 lines · c
1// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -verify=no256,no512 -o - -S2// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx -verify=no512 -o - -S3// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx512f -verify=both -o - -S4// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx10.1 -verify=both -o - -S5// REQUIRES: x86-registered-target6 7// both-no-diagnostics8 9typedef short avx512fType __attribute__((vector_size(64)));10typedef short avx256Type __attribute__((vector_size(32)));11 12__attribute__((target("avx"))) void takesAvx256(avx256Type t);13__attribute__((target("avx512f"))) void takesAvx512(avx512fType t);14void takesAvx256_no_target(avx256Type t);15void takesAvx512_no_target(avx512fType t);16 17void variadic(int i, ...);18__attribute__((target("avx512f"))) void variadic_err(int i, ...);19 20// If neither side has an attribute, warn.21void 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.33void 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}52