diff options
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CodeGenCXX/pragma-pipeline.cpp | 47 | ||||
-rw-r--r-- | clang/test/Parser/pragma-loop.cpp | 2 | ||||
-rw-r--r-- | clang/test/Parser/pragma-pipeline.cpp | 33 | ||||
-rw-r--r-- | clang/test/Parser/pragma-unroll-and-jam.cpp | 2 | ||||
-rw-r--r-- | clang/test/Sema/pragma-pipeline.cpp | 34 |
5 files changed, 116 insertions, 2 deletions
diff --git a/clang/test/CodeGenCXX/pragma-pipeline.cpp b/clang/test/CodeGenCXX/pragma-pipeline.cpp new file mode 100644 index 00000000000..6846f154436 --- /dev/null +++ b/clang/test/CodeGenCXX/pragma-pipeline.cpp @@ -0,0 +1,47 @@ +// RUN: %clang_cc1 -triple hexagon -std=c++11 -emit-llvm -o - %s | FileCheck %s + +void pipeline_disabled(int *List, int Length, int Value) { +// CHECK-LABEL: define {{.*}} @_Z17pipeline_disabled +#pragma clang loop pipeline(disable) + for (int i = 0; i < Length; i++) { + // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_1:.*]] + List[i] = Value; + } +} + +void pipeline_not_disabled(int *List, int Length, int Value) { + // CHECK-LABEL: define {{.*}} @_Z21pipeline_not_disabled + for (int i = 0; i < Length; i++) { + List[i] = Value; + } +} + +void pipeline_initiation_interval(int *List, int Length, int Value) { +// CHECK-LABEL: define {{.*}} @_Z28pipeline_initiation_interval +#pragma clang loop pipeline_initiation_interval(10) + for (int i = 0; i < Length; i++) { + // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_3:.*]] + List[i] = Value; + } +} + +void pipeline_disabled_on_nested_loop(int *List, int Length, int Value) { + // CHECK-LABEL: define {{.*}} @_Z32pipeline_disabled_on_nested_loop + for (int i = 0; i < Length; i++) { +#pragma clang loop pipeline(disable) + for (int j = 0; j < Length; j++) { + // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_4:.*]] + List[i * Length + j] = Value; + } + } +} + +// CHECK: ![[LOOP_1]] = distinct !{![[LOOP_1]], ![[PIPELINE_DISABLE:.*]]} +// CHECK: ![[PIPELINE_DISABLE]] = !{!"llvm.loop.pipeline.disable", i1 true} + +// CHECK-NOT:llvm.loop.pipeline + +// CHECK: ![[LOOP_3]] = distinct !{![[LOOP_3]], ![[PIPELINE_II_10:.*]]} +// CHECK: ![[PIPELINE_II_10]] = !{!"llvm.loop.pipeline.initiationinterval", i32 10} + +// CHECK: ![[LOOP_4]] = distinct !{![[LOOP_4]], ![[PIPELINE_DISABLE]]} diff --git a/clang/test/Parser/pragma-loop.cpp b/clang/test/Parser/pragma-loop.cpp index 3db0fc45968..be765170f85 100644 --- a/clang/test/Parser/pragma-loop.cpp +++ b/clang/test/Parser/pragma-loop.cpp @@ -147,7 +147,7 @@ void test(int *List, int Length) { /* expected-error {{missing argument; expected 'enable', 'full' or 'disable'}} */ #pragma clang loop unroll() /* expected-error {{missing argument; expected 'enable' or 'disable'}} */ #pragma clang loop distribute() -/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, or distribute}} */ #pragma clang loop +/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, or distribute}} */ #pragma clang loop /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword(enable) /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop vectorize(enable) badkeyword(4) diff --git a/clang/test/Parser/pragma-pipeline.cpp b/clang/test/Parser/pragma-pipeline.cpp new file mode 100644 index 00000000000..e500d4d2d5f --- /dev/null +++ b/clang/test/Parser/pragma-pipeline.cpp @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -std=c++11 -verify %s + +// Note that this puts the expected lines before the directives to work around +// limitations in the -verify mode. + +void test(int *List, int Length, int Value) { + int i = 0; + +#pragma clang loop pipeline(disable) + for (int i = 0; i < Length; i++) { + List[i] = Value; + } + +#pragma clang loop pipeline_initiation_interval(10) + for (int i = 0; i < Length; i++) { + List[i] = Value; + } + +/* expected-error {{expected ')'}} */ #pragma clang loop pipeline(disable +/* expected-error {{invalid argument; expected 'disable'}} */ #pragma clang loop pipeline(enable) +/* expected-error {{invalid argument; expected 'disable'}} */ #pragma clang loop pipeline(error) +/* expected-error {{expected '('}} */ #pragma clang loop pipeline disable +/* expected-error {{missing argument; expected an integer value}} */ #pragma clang loop pipeline_initiation_interval() +/* expected-error {{use of undeclared identifier 'error'}} */ #pragma clang loop pipeline_initiation_interval(error) +/* expected-error {{expected '('}} */ #pragma clang loop pipeline_initiation_interval 1 2 +/* expected-error {{expected ')'}} */ #pragma clang loop pipeline_initiation_interval(1 + for (int i = 0; i < Length; i++) { + for (int j = 0; j < Length; j++) { + List[i * Length + j] = Value; + } + } + +} diff --git a/clang/test/Parser/pragma-unroll-and-jam.cpp b/clang/test/Parser/pragma-unroll-and-jam.cpp index 8452156f69c..ef1867aa195 100644 --- a/clang/test/Parser/pragma-unroll-and-jam.cpp +++ b/clang/test/Parser/pragma-unroll-and-jam.cpp @@ -67,7 +67,7 @@ void test(int *List, int Length, int Value) { } // pragma clang unroll_and_jam is disabled for the moment -/* expected-error {{invalid option 'unroll_and_jam'; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, or distribute}} */ #pragma clang loop unroll_and_jam(4) +/* expected-error {{invalid option 'unroll_and_jam'; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, or distribute}} */ #pragma clang loop unroll_and_jam(4) for (int i = 0; i < Length; i++) { for (int j = 0; j < Length; j++) { List[i * Length + j] = Value; diff --git a/clang/test/Sema/pragma-pipeline.cpp b/clang/test/Sema/pragma-pipeline.cpp new file mode 100644 index 00000000000..7b277601d06 --- /dev/null +++ b/clang/test/Sema/pragma-pipeline.cpp @@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +#pragma clang loop pipeline(disable) /* expected-error {{expected unqualified-id}} */ +int main() { + for (int i = 0; i < 10; ++i) + ; +} + +void test(int *List, int Length, int Value) { + int i = 0; + +/* expected-error {{invalid argument of type 'double'; expected an integer type}} */ #pragma clang loop pipeline_initiation_interval(1.0) +/* expected-error {{invalid value '0'; must be positive}} */ #pragma clang loop pipeline_initiation_interval(0) +/* expected-error {{invalid value '-1'; must be positive}} */ #pragma clang loop pipeline_initiation_interval(-1) + for (int i = 0; i < Length; i++) { + for (int j = 0; j < Length; j++) { + List[i * Length + j] = Value; + } + } + +#pragma clang loop pipeline(disable) +/* expected-error {{expected a for, while, or do-while loop to follow '#pragma clang loop'}} */ int j = Length; +#pragma clang loop pipeline_initiation_interval(4) +/* expected-error {{expected a for, while, or do-while loop to follow '#pragma clang loop'}} */ int k = Length; + +#pragma clang loop pipeline(disable) +#pragma clang loop pipeline_initiation_interval(4) /* expected-error {{incompatible directives 'pipeline(disable)' and 'pipeline_initiation_interval(4)'}} */ + for (int i = 0; i < Length; i++) { + List[i] = Value; + } + +#pragma clang loop pipeline(disable) +/* expected-error {{expected statement}} */ } + |