|
1 |
| -// RUN: %clang_cc1 %s -fsyntax-only -ast-dump -fsycl-is-device -triple spir64 -Wno-sycl-2017-compat -verify | FileCheck %s |
| 1 | +// RUN: %clang_cc1 -fsycl-is-device -verify %s |
2 | 2 |
|
3 |
| -#include "Inputs/sycl.hpp" |
| 3 | +// Test that checks scheduler_target_fmax_mhz attribute support on Function. |
| 4 | + |
| 5 | +// Test for deprecated spelling of scheduler_target_fmax_mhz attribute. |
4 | 6 | // expected-warning@+2 {{attribute 'intelfpga::scheduler_target_fmax_mhz' is deprecated}}
|
5 | 7 | // expected-note@+1 {{did you mean to use 'intel::scheduler_target_fmax_mhz' instead?}}
|
6 |
| -[[intelfpga::scheduler_target_fmax_mhz(2)]] void |
7 |
| -func() {} |
| 8 | +[[intelfpga::scheduler_target_fmax_mhz(2)]] void deprecate() {} |
| 9 | + |
| 10 | +// Tests for incorrect argument values for Intel FPGA scheduler_target_fmax_mhz function attribute. |
| 11 | +[[intel::scheduler_target_fmax_mhz(0)]] int Var = 0; // expected-error{{'scheduler_target_fmax_mhz' attribute only applies to functions}} |
| 12 | + |
| 13 | +[[intel::scheduler_target_fmax_mhz(1048577)]] void correct() {} // OK |
| 14 | + |
| 15 | +[[intel::scheduler_target_fmax_mhz("foo")]] void func() {} // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'const char [4]'}} |
| 16 | + |
| 17 | +[[intel::scheduler_target_fmax_mhz(-1)]] void func1() {} // expected-error{{'scheduler_target_fmax_mhz' attribute requires a non-negative integral compile time constant expression}} |
| 18 | + |
| 19 | +[[intel::scheduler_target_fmax_mhz(0, 1)]] void func2() {} // expected-error{{'scheduler_target_fmax_mhz' attribute takes one argument}} |
| 20 | + |
| 21 | +// Tests for Intel FPGA scheduler_target_fmax_mhz function attribute duplication. |
| 22 | +// No diagnostic is emitted because the arguments match. Duplicate attribute is silently ignored. |
| 23 | +[[intel::scheduler_target_fmax_mhz(2)]] |
| 24 | +[[intel::scheduler_target_fmax_mhz(2)]] void |
| 25 | +func3() {} |
8 | 26 |
|
9 | 27 | // No diagnostic is emitted because the arguments match.
|
10 |
| -[[intel::scheduler_target_fmax_mhz(12)]] void bar(); |
11 |
| -[[intel::scheduler_target_fmax_mhz(12)]] void bar() {} // OK |
| 28 | +[[intel::scheduler_target_fmax_mhz(4)]] void func4(); |
| 29 | +[[intel::scheduler_target_fmax_mhz(4)]] void func4(); // OK |
12 | 30 |
|
13 | 31 | // Diagnostic is emitted because the arguments mismatch.
|
14 |
| -[[intel::scheduler_target_fmax_mhz(12)]] void baz(); // expected-note {{previous attribute is here}} |
15 |
| -[[intel::scheduler_target_fmax_mhz(100)]] void baz(); // expected-warning {{attribute 'scheduler_target_fmax_mhz' is already applied with different arguments}} |
| 32 | +[[intel::scheduler_target_fmax_mhz(2)]] // expected-note {{previous attribute is here}} |
| 33 | +[[intel::scheduler_target_fmax_mhz(4)]] void |
| 34 | +func5() {} // expected-warning@-1 {{attribute 'scheduler_target_fmax_mhz' is already applied with different arguments}} |
| 35 | + |
| 36 | +[[intel::scheduler_target_fmax_mhz(1)]] void func6(); // expected-note {{previous attribute is here}} |
| 37 | +[[intel::scheduler_target_fmax_mhz(3)]] void func6(); // expected-warning {{attribute 'scheduler_target_fmax_mhz' is already applied with different arguments}} |
16 | 38 |
|
| 39 | +// Tests that check template parameter support for Intel FPGA scheduler_target_fmax_mhz function attributes. |
17 | 40 | template <int N>
|
18 |
| -[[intel::scheduler_target_fmax_mhz(N)]] void zoo() {} |
19 |
| - |
20 |
| -int main() { |
21 |
| - // CHECK-LABEL: FunctionDecl {{.*}}test_kernel1 'void ()' |
22 |
| - // CHECK: SYCLIntelSchedulerTargetFmaxMhzAttr {{.*}} |
23 |
| - // CHECK-NEXT: ConstantExpr {{.*}} 'int' |
24 |
| - // CHECK-NEXT: value: Int 5 |
25 |
| - // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 5 |
26 |
| - // expected-warning@+3 {{attribute 'intelfpga::scheduler_target_fmax_mhz' is deprecated}} |
27 |
| - // expected-note@+2 {{did you mean to use 'intel::scheduler_target_fmax_mhz' instead?}} |
28 |
| - cl::sycl::kernel_single_task<class test_kernel1>( |
29 |
| - []() [[intelfpga::scheduler_target_fmax_mhz(5)]]{}); |
30 |
| - |
31 |
| - // CHECK-LABEL: FunctionDecl {{.*}}test_kernel2 'void ()' |
32 |
| - // CHECK: SYCLIntelSchedulerTargetFmaxMhzAttr {{.*}} |
33 |
| - // CHECK-NEXT: ConstantExpr {{.*}} 'int' |
34 |
| - // CHECK-NEXT: value: Int 2 |
35 |
| - // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 2 |
36 |
| - cl::sycl::kernel_single_task<class test_kernel2>( |
37 |
| - []() { func(); }); |
38 |
| - |
39 |
| - // CHECK-LABEL: FunctionDecl {{.*}}test_kernel3 'void ()' |
40 |
| - // CHECK: SYCLIntelSchedulerTargetFmaxMhzAttr {{.*}} |
41 |
| - // CHECK-NEXT: ConstantExpr {{.*}} 'int' |
42 |
| - // CHECK-NEXT: value: Int 75 |
43 |
| - // CHECK-NEXT: SubstNonTypeTemplateParmExpr {{.*}} 'int' |
44 |
| - // CHECK-NEXT: NonTypeTemplateParmDecl {{.*}} referenced 'int' depth 0 index 0 N |
45 |
| - // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 75 |
46 |
| - cl::sycl::kernel_single_task<class test_kernel3>( |
47 |
| - []() { zoo<75>(); }); |
48 |
| - |
49 |
| - [[intel::scheduler_target_fmax_mhz(0)]] int Var = 0; // expected-error{{'scheduler_target_fmax_mhz' attribute only applies to functions}} |
50 |
| - |
51 |
| - cl::sycl::kernel_single_task<class test_kernel4>( |
52 |
| - []() [[intel::scheduler_target_fmax_mhz(1048577)]]{}); // OK |
53 |
| - |
54 |
| - cl::sycl::kernel_single_task<class test_kernel5>( |
55 |
| - []() [[intel::scheduler_target_fmax_mhz(-4)]]{}); // expected-error{{'scheduler_target_fmax_mhz' attribute requires a non-negative integral compile time constant expression}} |
56 |
| - |
57 |
| - cl::sycl::kernel_single_task<class test_kernel6>( |
58 |
| - []() [[intel::scheduler_target_fmax_mhz(1), // expected-note {{previous attribute is here}} |
59 |
| - intel::scheduler_target_fmax_mhz(2)]]{}); // expected-warning{{attribute 'scheduler_target_fmax_mhz' is already applied with different arguments}} |
| 41 | +[[intel::scheduler_target_fmax_mhz(N)]] void func7(); // expected-error {{'scheduler_target_fmax_mhz' attribute requires a non-negative integral compile time constant expression}} |
| 42 | + |
| 43 | +template <int size> |
| 44 | +[[intel::scheduler_target_fmax_mhz(10)]] void func8(); // expected-note {{previous attribute is here}} |
| 45 | +template <int size> |
| 46 | +[[intel::scheduler_target_fmax_mhz(size)]] void func8() {} // expected-warning {{attribute 'scheduler_target_fmax_mhz' is already applied with different arguments}} |
| 47 | + |
| 48 | +void checkTemplates() { |
| 49 | + func7<4>(); // OK |
| 50 | + func7<-1>(); // expected-note {{in instantiation of function template specialization 'func7<-1>' requested here}} |
| 51 | + func7<0>(); // OK |
| 52 | + func8<20>(); // expected-note {{in instantiation of function template specialization 'func8<20>' requested here}} |
| 53 | +} |
| 54 | + |
| 55 | +// Test that checks expression is not a constant expression. |
| 56 | +// expected-note@+1{{declared here}} |
| 57 | +int baz(); |
| 58 | +// expected-error@+2{{expression is not an integral constant expression}} |
| 59 | +// expected-note@+1{{non-constexpr function 'baz' cannot be used in a constant expression}} |
| 60 | +[[intel::scheduler_target_fmax_mhz(baz() + 1)]] void func9(); |
| 61 | + |
| 62 | +// Test that checks expression is a constant expression. |
| 63 | +constexpr int bar() { return 0; } |
| 64 | +[[intel::scheduler_target_fmax_mhz(bar() + 2)]] void func10(); // OK |
| 65 | + |
| 66 | +// Test that checks wrong function template instantiation and ensures that the type |
| 67 | +// is checked properly when instantiating from the template definition. |
| 68 | +template <typename Ty> |
| 69 | +// expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'S'}} |
| 70 | +// expected-error@+1 {{integral constant expression must have integral or unscoped enumeration type, not 'float'}} |
| 71 | +[[intel::scheduler_target_fmax_mhz(Ty{})]] void func11() {} |
| 72 | + |
| 73 | +struct S {}; |
| 74 | +void test() { |
| 75 | + //expected-note@+1{{in instantiation of function template specialization 'func11<S>' requested here}} |
| 76 | + func11<S>(); |
| 77 | + //expected-note@+1{{in instantiation of function template specialization 'func11<float>' requested here}} |
| 78 | + func11<float>(); |
60 | 79 | }
|
0 commit comments