diff options
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/OpenMP/declare_simd_ast_print.c | 12 | ||||
-rw-r--r-- | clang/test/OpenMP/declare_simd_ast_print.cpp | 65 | ||||
-rw-r--r-- | clang/test/OpenMP/declare_simd_messages.cpp | 50 |
3 files changed, 85 insertions, 42 deletions
diff --git a/clang/test/OpenMP/declare_simd_ast_print.c b/clang/test/OpenMP/declare_simd_ast_print.c index fe6bffcf89a..5cb24084e53 100644 --- a/clang/test/OpenMP/declare_simd_ast_print.c +++ b/clang/test/OpenMP/declare_simd_ast_print.c @@ -6,16 +6,16 @@ #ifndef HEADER #define HEADER -#pragma omp declare simd -#pragma omp declare simd simdlen(32) +#pragma omp declare simd aligned(b : 64) +#pragma omp declare simd simdlen(32) aligned(d, s1) #pragma omp declare simd inbranch, uniform(d) #pragma omp declare simd notinbranch simdlen(2), uniform(s1, s2) -void add_1(float *d, float *s1, float *s2) __attribute__((cold)); +void add_1(float *d, float *s1, float *s2, double b[]) __attribute__((cold)); // CHECK: #pragma omp declare simd notinbranch simdlen(2) uniform(s1, s2) // CHECK-NEXT: #pragma omp declare simd inbranch uniform(d) -// CHECK-NEXT: #pragma omp declare simd simdlen(32) -// CHECK-NEXT: #pragma omp declare simd -// CHECK-NEXT: void add_1(float *d, float *s1, float *s2) __attribute__((cold)) +// CHECK-NEXT: #pragma omp declare simd simdlen(32) aligned(d) aligned(s1) +// CHECK-NEXT: #pragma omp declare simd aligned(b: 64) +// CHECK-NEXT: void add_1(float *d, float *s1, float *s2, double b[]) __attribute__((cold)) #endif diff --git a/clang/test/OpenMP/declare_simd_ast_print.cpp b/clang/test/OpenMP/declare_simd_ast_print.cpp index e38ebe9613c..56008b53967 100644 --- a/clang/test/OpenMP/declare_simd_ast_print.cpp +++ b/clang/test/OpenMP/declare_simd_ast_print.cpp @@ -17,27 +17,27 @@ void add_1(float *d) __attribute__((cold)); // CHECK-NEXT: void add_1(float *d) __attribute__((cold)); // -#pragma omp declare simd +#pragma omp declare simd aligned(hp, hp2) template <class C> void h(C *hp, C *hp2, C *hq, C *lin) { } -// CHECK: #pragma omp declare simd +// CHECK: #pragma omp declare simd aligned(hp) aligned(hp2) // CHECK-NEXT: template <class C = int> void h(int *hp, int *hp2, int *hq, int *lin) { // CHECK-NEXT: h((float *)hp, (float *)hp2, (float *)hq, (float *)lin); // CHECK-NEXT: } -// CHECK: #pragma omp declare simd +// CHECK: #pragma omp declare simd aligned(hp) aligned(hp2) // CHECK-NEXT: template <class C = float> void h(float *hp, float *hp2, float *hq, float *lin) { // CHECK-NEXT: } -// CHECK: #pragma omp declare simd +// CHECK: #pragma omp declare simd aligned(hp) aligned(hp2) // CHECK: template <class C> void h(C *hp, C *hp2, C *hq, C *lin) { // CHECK-NEXT: } // // Explicit specialization with <C=int>. // Pragmas need to be same, otherwise standard says that's undefined behavior. -#pragma omp declare simd +#pragma omp declare simd aligned(hp, hp2) template <> void h(int *hp, int *hp2, int *hq, int *lin) { @@ -55,31 +55,31 @@ class VV { #pragma omp declare simd uniform(this, a) int add(int a, int b) __attribute__((cold)) { return a + b; } - // CHECK: #pragma omp declare simd - // CHECK-NEXT: float taddpf(float *a, float *b) { + // CHECK: #pragma omp declare simd aligned(b: 4) aligned(a) + // CHECK-NEXT: float taddpf(float *a, float *&b) { // CHECK-NEXT: return *a + *b; // CHECK-NEXT: } - #pragma omp declare simd - float taddpf(float *a, float *b) { return *a + *b; } + #pragma omp declare simd aligned (b: 4) aligned(a) + float taddpf(float *a, float *&b) { return *a + *b; } -// CHECK: #pragma omp declare simd +// CHECK: #pragma omp declare simd aligned(b: 8) // CHECK-NEXT: #pragma omp declare simd -// CHECK-NEXT: int tadd(int b) { -// CHECK-NEXT: return this->x[b] + b; +// CHECK-NEXT: int tadd(int (&b)[]) { +// CHECK-NEXT: return this->x[b[0]] + b[0]; // CHECK-NEXT: } #pragma omp declare simd - #pragma omp declare simd - int tadd(int b) { return x[b] + b; } + #pragma omp declare simd aligned(b : 8) + int tadd(int (&b)[]) { return x[b[0]] + b[0]; } private: int x[10]; }; -// CHECK: template <int X = 16> class TVV { +// CHECK: template <int X = 16, typename T = float> class TVV { // CHECK: #pragma omp declare simd // CHECK-NEXT: int tadd(int a, int b); -// CHECK: #pragma omp declare simd -// CHECK-NEXT: float taddpf(float *a, float *b) { +// CHECK: #pragma omp declare simd aligned(a: 16 * 2) aligned(b) +// CHECK-NEXT: float taddpf(float *a, float *&b) { // CHECK-NEXT: return *a + *b; // CHECK-NEXT: } // CHECK: #pragma omp declare simd @@ -88,10 +88,10 @@ private: // CHECK-NEXT: return this->x[b] + b; // CHECK-NEXT: } // CHECK: } -template <int X> +template <int X, typename T> class TVV { public: -// CHECK: template <int X> class TVV { +// CHECK: template <int X, typename T> class TVV { #pragma omp declare simd simdlen(X) int tadd(int a, int b) { return a + b; } @@ -100,11 +100,11 @@ public: // CHECK-NEXT: return a + b; // CHECK-NEXT: } - #pragma omp declare simd - float taddpf(float *a, float *b) { return *a + *b; } + #pragma omp declare simd aligned(a : X * 2) aligned(b) + float taddpf(float *a, T *&b) { return *a + *b; } -// CHECK: #pragma omp declare simd -// CHECK-NEXT: float taddpf(float *a, float *b) { +// CHECK: #pragma omp declare simd aligned(a: X * 2) aligned(b) +// CHECK-NEXT: float taddpf(float *a, T *&b) { // CHECK-NEXT: return *a + *b; // CHECK-NEXT: } @@ -123,20 +123,21 @@ private: }; // CHECK: }; -// CHECK: #pragma omp declare simd simdlen(64) -// CHECK: template <int N = 64> void foo(int (&)[64]) -// CHECK: #pragma omp declare simd simdlen(N) -// CHECK: template <int N> void foo(int (&)[N]) -#pragma omp declare simd simdlen(N) +// CHECK: #pragma omp declare simd simdlen(64) aligned(b: 64 * 2) +// CHECK: template <int N = 64> void foo(int (&b)[64]) +// CHECK: #pragma omp declare simd simdlen(N) aligned(b: N * 2) +// CHECK: template <int N> void foo(int (&b)[N]) +#pragma omp declare simd simdlen(N) aligned(b : N * 2) template <int N> -void foo(int (&)[N]); +void foo(int (&b)[N]); -// CHECK: TVV<16> t16; -TVV<16> t16; +// CHECK: TVV<16, float> t16; +TVV<16, float> t16; void f() { float a = 1.0f, b = 2.0f; - float r = t16.taddpf(&a, &b); + float *p = &b; + float r = t16.taddpf(&a, p); int res = t16.tadd(b); int c[64]; foo(c); diff --git a/clang/test/OpenMP/declare_simd_messages.cpp b/clang/test/OpenMP/declare_simd_messages.cpp index 70737ad2685..e1745aaa116 100644 --- a/clang/test/OpenMP/declare_simd_messages.cpp +++ b/clang/test/OpenMP/declare_simd_messages.cpp @@ -75,10 +75,10 @@ void h(int *hp, int *hp2, int *hq, int *lin) { #pragma omp declare simd simdlen() simdlen) void foo(); -// expected-error@+3 2 {{expected reference to one of the parameters of function 'foo'}} +// expected-error@+3 4 {{expected reference to one of the parameters of function 'foo'}} // expected-error@+2 {{invalid use of 'this' outside of a non-static member function}} // expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}} -#pragma omp declare simd simdlen(N) uniform(this, var) +#pragma omp declare simd simdlen(N) uniform(this, var) aligned(var) template<int N> void foo() {} @@ -105,7 +105,46 @@ void test() { #pragma omp declare simd uniform(this,a // expected-error@+1 {{expected expression}} #pragma omp declare simd uniform(,a) -void bar(int a); +// expected-error@+1 {{expected '(' after 'aligned'}} +#pragma omp declare simd aligned +// expected-note@+3 {{to match this '('}} +// expected-error@+2 {{expected ')'}} +// expected-error@+1 {{expected expression}} +#pragma omp declare simd aligned( +// expected-error@+1 {{expected expression}} +#pragma omp declare simd aligned() +// expected-note@+3 {{to match this '('}} +// expected-error@+2 {{expected ')'}} +// expected-error@+1 {{expected expression}} +#pragma omp declare simd aligned(a: +// expected-error@+1 {{expected expression}} +#pragma omp declare simd aligned(a:) +// expected-warning@+2 {{extra tokens at the end of '#pragma omp declare simd' are ignored}} +// expected-error@+1 {{expected '(' after 'aligned'}} +#pragma omp declare simd aligned :) +// expected-note@+3 {{to match this '('}} +// expected-error@+2 {{expected ')'}} +// expected-error@+1 {{invalid use of 'this' outside of a non-static member function}} +#pragma omp declare simd aligned(this +// expected-note@+3 {{to match this '('}} +// expected-error@+2 {{expected ')'}} +// expected-error@+1 {{invalid use of 'this' outside of a non-static member function}} +#pragma omp declare simd aligned(this,b +// expected-error@+1 {{expected expression}} +#pragma omp declare simd aligned(, b) +// expected-note@+4 {{defined as aligned}} +// expected-error@+3 {{a parameter cannot appear in more than one aligned clause}} +// expected-error@+2 {{expected expression}} +// expected-error@+1 {{expected ',' or ')' in 'aligned' clause}} +#pragma omp declare simd aligned(b) aligned(b ; 64) +// expected-note@+2 {{defined as aligned}} +// expected-error@+1 {{a parameter cannot appear in more than one aligned clause}} +#pragma omp declare simd aligned(b) aligned(b: 64) +// expected-error@+1 {{argument to 'aligned' clause must be a strictly positive integer value}} +#pragma omp declare simd aligned(b: -1) +// expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}} +#pragma omp declare simd aligned(b: 3) +void bar(int a, int *b); template <class T> struct St { @@ -113,8 +152,11 @@ struct St { #pragma init_seg(compiler) #pragma omp declare simd #pragma init_seg(compiler) +// expected-note@+4 {{defined as aligned}} +// expected-error@+3 {{argument to 'aligned' clause must be a strictly positive integer value}} +// expected-error@+2 {{'this' cannot appear in more than one aligned clause}} // expected-error@+1 {{use of undeclared identifier 't'}} -#pragma omp declare simd uniform(this, t) +#pragma omp declare simd uniform(this, t) aligned(this: 4) aligned(this: -4) void h(T *hp) { // expected-error@+1 {{unexpected OpenMP directive '#pragma omp declare simd'}} #pragma omp declare simd |