Skip to content

Commit 3d379f9

Browse files
committed
Move supported builtin functions out of unsupported_math test
Signed-off-by: gejin <[email protected]>
1 parent 01ebd61 commit 3d379f9

File tree

2 files changed

+64
-51
lines changed

2 files changed

+64
-51
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsyntax-only -Wno-sycl-strict -verify %s
2+
extern "C" float sinf(float);
3+
extern "C" float cosf(float);
4+
extern "C" float floorf(float);
5+
extern "C" float logf(float);
6+
extern "C" float nearbyintf(float);
7+
extern "C" float rintf(float);
8+
extern "C" float roundf(float);
9+
extern "C" float truncf(float);
10+
extern "C" float copysignf(float, float);
11+
extern "C" double sin(double);
12+
extern "C" double cos(double);
13+
extern "C" double floor(double);
14+
extern "C" double log(double);
15+
extern "C" double nearbyint(double);
16+
extern "C" double rint(double);
17+
extern "C" double round(double);
18+
extern "C" double trunc(double);
19+
extern "C" double copysign(double, double);
20+
template <typename name, typename Func>
21+
__attribute__((sycl_kernel)) void kernel(const Func &kernelFunc) {
22+
kernelFunc();
23+
}
24+
25+
int main() {
26+
kernel<class kernel_function>([=]() {
27+
int acc[1] = {5};
28+
acc[0] *= 2;
29+
acc[0] += (int)truncf(1.0f); // expected-no-diagnostics
30+
acc[0] += (int)trunc(1.0); // expected-no-diagnostics
31+
acc[0] += (int)roundf(1.0f); // expected-no-diagnostics
32+
acc[0] += (int)round(1.0); // expected-no-diagnostics
33+
acc[0] += (int)rintf(1.0f); // expected-no-diagnostics
34+
acc[0] += (int)rint(1.0); // expected-no-diagnostics
35+
acc[0] += (int)nearbyintf(0.5f); // expected-no-diagnostics
36+
acc[0] += (int)nearbyint(0.5); // expected-no-diagnostics
37+
acc[0] += (int)floorf(0.5f); // expected-no-diagnostics
38+
acc[0] += (int)floor(0.5); // expected-no-diagnostics
39+
acc[0] += (int)copysignf(1.0f, -0.5f); // expected-no-diagnostics
40+
acc[0] += (int)copysign(1.0, -0.5); // expected-no-diagnostics
41+
acc[0] += (int)sinf(1.0f); // expected-no-diagnostics
42+
acc[0] += (int)sin(1.0); // expected-no-diagnostics
43+
acc[0] += (int)__builtin_sinf(1.0f); // expected-no-diagnostics
44+
acc[0] += (int)__builtin_sin(1.0); // expected-no-diagnostics
45+
acc[0] += (int)cosf(1.0f); // expected-no-diagnostics
46+
acc[0] += (int)cos(1.0); // expected-no-diagnostics
47+
acc[0] += (int)__builtin_cosf(1.0f); // expected-no-diagnostics
48+
acc[0] += (int)__builtin_cos(1.0); // expected-no-diagnostics
49+
acc[0] += (int)logf(1.0f); // expected-no-diagnostics
50+
acc[0] += (int)log(1.0); // expected-no-diagnostics
51+
acc[0] += (int)__builtin_truncf(1.0f); // expected-no-diagnostics
52+
acc[0] += (int)__builtin_trunc(1.0); // expected-no-diagnostics
53+
acc[0] += (int)__builtin_rintf(1.0f); // expected-no-diagnostics
54+
acc[0] += (int)__builtin_rint(1.0); // expected-no-diagnostics
55+
acc[0] += (int)__builtin_nearbyintf(0.5f); // expected-no-diagnostics
56+
acc[0] += (int)__builtin_nearbyint(0.5); // expected-no-diagnostics
57+
acc[0] += (int)__builtin_floorf(0.5f); // expected-no-diagnostics
58+
acc[0] += (int)__builtin_floor(0.5); // expected-no-diagnostics
59+
acc[0] += (int)__builtin_copysignf(1.0f, -0.5f); // expected-no-diagnostics
60+
acc[0] += (int)__builtin_logf(1.0f); // expected-no-diagnostics
61+
acc[0] += (int)__builtin_log(1.0); // expected-no-diagnostics
62+
});
63+
return 0;
64+
}

clang/test/SemaSYCL/unsupported_math.cpp

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,4 @@
11
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsyntax-only -Wno-sycl-2017-compat -verify %s
2-
extern "C" float sinf(float);
3-
extern "C" float cosf(float);
4-
extern "C" float floorf(float);
5-
extern "C" float logf(float);
6-
extern "C" float nearbyintf(float);
7-
extern "C" float rintf(float);
8-
extern "C" float roundf(float);
9-
extern "C" float truncf(float);
10-
extern "C" float copysignf(float, float);
11-
extern "C" double sin(double);
12-
extern "C" double cos(double);
13-
extern "C" double floor(double);
14-
extern "C" double log(double);
15-
extern "C" double nearbyint(double);
16-
extern "C" double rint(double);
17-
extern "C" double round(double);
18-
extern "C" double trunc(double);
19-
extern "C" double copysign(double, double);
202
template <typename name, typename Func>
213
__attribute__((sycl_kernel)) void kernel(const Func &kernelFunc) {
224
kernelFunc();
@@ -26,39 +8,6 @@ int main() {
268
kernel<class kernel_function>([=]() {
279
int acc[1] = {5};
2810
acc[0] *= 2;
29-
acc[0] += (int)truncf(1.0f); // expected-no-error
30-
acc[0] += (int)trunc(1.0); // expected-no-error
31-
acc[0] += (int)roundf(1.0f); // expected-no-error
32-
acc[0] += (int)round(1.0); // expected-no-error
33-
acc[0] += (int)rintf(1.0f); // expected-no-error
34-
acc[0] += (int)rint(1.0); // expected-no-error
35-
acc[0] += (int)nearbyintf(0.5f); // expected-no-error
36-
acc[0] += (int)nearbyint(0.5); // expected-no-error
37-
acc[0] += (int)floorf(0.5f); // expected-no-error
38-
acc[0] += (int)floor(0.5); // expected-no-error
39-
acc[0] += (int)copysignf(1.0f, -0.5f); // expected-no-error
40-
acc[0] += (int)copysign(1.0, -0.5); // expected-no-error
41-
acc[0] += (int)sinf(1.0f); // expected-no-error
42-
acc[0] += (int)sin(1.0); // expected-no-error
43-
acc[0] += (int)__builtin_sinf(1.0f); // expected-no-error
44-
acc[0] += (int)__builtin_sin(1.0); // expected-no-error
45-
acc[0] += (int)cosf(1.0f); // expected-no-error
46-
acc[0] += (int)cos(1.0); // expected-no-error
47-
acc[0] += (int)__builtin_cosf(1.0f); // expected-no-error
48-
acc[0] += (int)__builtin_cos(1.0); // expected-no-error
49-
acc[0] += (int)logf(1.0f); // expected-no-error
50-
acc[0] += (int)log(1.0); // expected-no-error
51-
acc[0] += (int)__builtin_truncf(1.0f); // expected-no-error
52-
acc[0] += (int)__builtin_trunc(1.0); // expected-no-error
53-
acc[0] += (int)__builtin_rintf(1.0f); // expected-no-error
54-
acc[0] += (int)__builtin_rint(1.0); // expected-no-error
55-
acc[0] += (int)__builtin_nearbyintf(0.5f); // expected-no-error
56-
acc[0] += (int)__builtin_nearbyint(0.5); // expected-no-error
57-
acc[0] += (int)__builtin_floorf(0.5f); // expected-no-error
58-
acc[0] += (int)__builtin_floor(0.5); // expected-no-error
59-
acc[0] += (int)__builtin_copysignf(1.0f, -0.5f); // expected-no-error
60-
acc[0] += (int)__builtin_logf(1.0f); // expected-no-error
61-
acc[0] += (int)__builtin_log(1.0); // expected-no-error
6211
acc[0] += (int)__builtin_fabsl(-1.0); // expected-error{{builtin is not supported on this target}}
6312
acc[0] += (int)__builtin_cosl(-1.0); // expected-error{{builtin is not supported on this target}}
6413
acc[0] += (int)__builtin_powl(-1.0, 10.0); // expected-error{{builtin is not supported on this target}}

0 commit comments

Comments
 (0)