| 1 |
// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon -fopenmp -x c -emit-llvm %s -o - -femit-all-decls | FileCheck %s |
| 2 |
// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon -fopenmp-simd -x c -emit-llvm %s -o - -femit-all-decls | FileCheck %s |
| 3 |
|
| 4 |
// REQUIRES: aarch64-registered-target |
| 5 |
// Note: -fopemp and -fopenmp-simd behavior are expected to be the same. |
| 6 |
|
| 7 |
// This test checks the values of Narrowest Data Size (NDS), as defined in |
| 8 |
// https://github.com/ARM-software/abi-aa/tree/main/vfabia64 |
| 9 |
// |
| 10 |
// NDS is used to compute the <vlen> token in the name of AdvSIMD |
| 11 |
// vector functions when no `simdlen` is specified, with the rule: |
| 12 |
// |
| 13 |
// if NDS(f) = 1, then VLEN = 16, 8; |
| 14 |
// if NDS(f) = 2, then VLEN = 8, 4; |
| 15 |
// if NDS(f) = 4, then VLEN = 4, 2; |
| 16 |
// if NDS(f) = 8 or NDS(f) = 16, then VLEN = 2. |
| 17 |
|
| 18 |
// NDS(NDS_is_sizeof_char) = 1 |
| 19 |
#pragma omp declare simd notinbranch |
| 20 |
char NDS_is_sizeof_char(short in); |
| 21 |
// CHECK-DAG: _ZGVnN16v_NDS_is_sizeof_char |
| 22 |
// CHECK-DAG: _ZGVnN8v_NDS_is_sizeof_char |
| 23 |
// CHECK-NOT: _ZGV{{.*}}_NDS_is_sizeof_char |
| 24 |
|
| 25 |
// NDS(NDS_is_sizeof_short) = 2 |
| 26 |
#pragma omp declare simd notinbranch |
| 27 |
int NDS_is_sizeof_short(short in); |
| 28 |
// CHECK-DAG: _ZGVnN8v_NDS_is_sizeof_short |
| 29 |
// CHECK-DAG: _ZGVnN4v_NDS_is_sizeof_short |
| 30 |
// CHECK-NOT: _ZGV{{.*}}_NDS_is_sizeof_short |
| 31 |
|
| 32 |
// NDS(NDS_is_sizeof_float_with_linear) = 4, and not 2, because the pointers are |
| 33 |
// marked as `linear` and therefore the size of the pointee realizes |
| 34 |
// the NDS. |
| 35 |
#pragma omp declare simd linear(sin) notinbranch |
| 36 |
void NDS_is_sizeof_float_with_linear(double in, float *sin); |
| 37 |
// Neon accepts only power of 2 values as <vlen>. |
| 38 |
// CHECK-DAG: _ZGVnN4vl4_NDS_is_sizeof_float_with_linear |
| 39 |
// CHECK-DAG: _ZGVnN2vl4_NDS_is_sizeof_float_with_linear |
| 40 |
// CHECK-NOT: _ZGV{{.*}}_NDS_is_sizeof_float_with_linear |
| 41 |
|
| 42 |
// NDS(NDS_is_size_of_float) = 4 |
| 43 |
#pragma omp declare simd notinbranch |
| 44 |
double NDS_is_size_of_float(float in); |
| 45 |
// CHECK-DAG: _ZGVnN4v_NDS_is_size_of_float |
| 46 |
// CHECK-DAG: _ZGVnN2v_NDS_is_size_of_float |
| 47 |
// CHECK-NOT: _ZGV{{.*}}_NDS_is_size_of_float |
| 48 |
|
| 49 |
// NDS(NDS_is_sizeof_double) = 8 |
| 50 |
#pragma omp declare simd linear(sin) notinbranch |
| 51 |
void NDS_is_sizeof_double(double in, double *sin); |
| 52 |
// CHECK-DAG: _ZGVnN2vl8_NDS_is_sizeof_double |
| 53 |
// CHECK-NOT: _ZGV{{.*}}_NDS_is_sizeof_double |
| 54 |
|
| 55 |
// NDS(double_complex) = 16 |
| 56 |
#pragma omp declare simd notinbranch |
| 57 |
double _Complex double_complex(double _Complex); |
| 58 |
// CHECK-DAG: _ZGVnN2v_double_complex |
| 59 |
// CHECK-NOT: _ZGV{{.*}}_double_complex |
| 60 |
|
| 61 |
// NDS(double_complex_linear_char) = 1, becasue `x` is marked linear. |
| 62 |
#pragma omp declare simd linear(x) notinbranch |
| 63 |
double _Complex double_complex_linear_char(double _Complex y, char *x); |
| 64 |
// CHECK-DAG: _ZGVnN8vl_double_complex_linear_char |
| 65 |
// CHECK-DAG: _ZGVnN16vl_double_complex_linear_char |
| 66 |
// CHECK-NOT: _ZGV{{.*}}_double_complex_linear_char |
| 67 |
|
| 68 |
static float *F; |
| 69 |
static double *D; |
| 70 |
static short S; |
| 71 |
static int I; |
| 72 |
static char C; |
| 73 |
static double _Complex DC; |
| 74 |
void do_something() { |
| 75 |
C = NDS_is_sizeof_char(S); |
| 76 |
I = NDS_is_sizeof_short(S); |
| 77 |
NDS_is_sizeof_float_with_linear(*D, F); |
| 78 |
*D = NDS_is_size_of_float(*F); |
| 79 |
NDS_is_sizeof_double(*D, D); |
| 80 |
DC = double_complex(DC); |
| 81 |
DC = double_complex_linear_char(DC, &C); |
| 82 |
} |