Debian Codegraph @

clang/test/OpenMP/interchange_ast_print.cpp

raw
1 // Check no warnings/errors
2 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++20 -fopenmp -fopenmp-version=60 -fsyntax-only -verify %s
3 // expected-no-diagnostics
4
5 // Check AST and unparsing
6 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++20 -fopenmp -fopenmp-version=60 -ast-dump %s | FileCheck %s --check-prefix=DUMP
7 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++20 -fopenmp -fopenmp-version=60 -ast-print %s | FileCheck %s --check-prefix=PRINT
8
9 // Check same results after serialization round-trip
10 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++20 -fopenmp -fopenmp-version=60 -emit-pch -o %t %s
11 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++20 -fopenmp -fopenmp-version=60 -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP
12 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++20 -fopenmp -fopenmp-version=60 -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT
13
14 #ifndef HEADER
15 #define HEADER
16
17 // placeholder for loop body code.
18 extern "C" void body(...);
19
20 // PRINT-LABEL: void foo1(
21 // DUMP-LABEL: FunctionDecl {{.*}} foo1
22 void foo1() {
23 // PRINT: #pragma omp interchange
24 // DUMP: OMPInterchangeDirective
25 #pragma omp interchange
26 // PRINT: for (int i = 7; i < 17; i += 3)
27 // DUMP-NEXT: ForStmt
28 for (int i = 7; i < 17; i += 3)
29 // PRINT: for (int j = 7; j < 17; j += 3)
30 // DUMP: ForStmt
31 for (int j = 7; j < 17; j += 3)
32 // PRINT: body(i, j);
33 // DUMP: CallExpr
34 body(i, j);
35 }
36
37
38
39
40 // PRINT-LABEL: void foo3(
41 // DUMP-LABEL: FunctionDecl {{.*}} foo3
42 void foo3() {
43 // PRINT: #pragma omp for collapse(3)
44 // DUMP: OMPForDirective
45 // DUMP-NEXT: OMPCollapseClause
46 // DUMP-NEXT: ConstantExpr
47 // DUMP-NEXT: value: Int 3
48 // DUMP-NEXT: IntegerLiteral {{.*}} 3
49 // DUMP-NEXT: CapturedStmt
50 // DUMP-NEXT: CapturedDecl
51 #pragma omp for collapse(3)
52 // PRINT: #pragma omp interchange
53 // DUMP: OMPInterchangeDirective
54 #pragma omp interchange
55 // PRINT: for (int i = 7; i < 17; i += 1)
56 // DUMP-NEXT: ForStmt
57 for (int i = 7; i < 17; i += 1)
58 // PRINT: for (int j = 7; j < 17; j += 1)
59 // DUMP: ForStmt
60 for (int j = 7; j < 17; j += 1)
61 // PRINT: for (int k = 7; k < 17; k += 1)
62 // DUMP: ForStmt
63 for (int k = 7; k < 17; k += 1)
64 // PRINT: body(i, j, k);
65 // DUMP: CallExpr
66 body(i, j, k);
67 }
68
69
70 // PRINT-LABEL: void foo6(
71 // DUMP-LABEL: FunctionTemplateDecl {{.*}} foo6
72 template<int Tile>
73 void foo6() {
74 // PRINT: #pragma omp interchange
75 // DUMP: OMPInterchangeDirective
76 #pragma omp interchange
77 // PRINT-NEXT: for (int i = 0; i < 11; i += 2)
78 // DUMP-NEXT: ForStmt
79 for (int i = 0; i < 11; i += 2)
80 // PRINT-NEXT: #pragma omp tile sizes(Tile)
81 // DUMP: OMPTileDirective
82 #pragma omp tile sizes(Tile)
83 // PRINT-NEXT: for (int j = 0; j < 13; j += 2)
84 // DUMP: ForStmt
85 for (int j = 0; j < 13; j += 2)
86 // PRINT-NEXT: body(i, j);
87 // DUMP: CallExpr
88 body(i, j);
89 }
90
91 // Also test instantiating the template.
92 void tfoo6() {
93 foo6<32>();
94 }
95
96
97 // PRINT-LABEL: void foo7(
98 // DUMP-LABEL: FunctionDecl {{.*}} foo7
99 void foo7() {
100 double arr[128];
101 // PRINT: #pragma omp interchange
102 // DUMP: OMPInterchangeDirective
103 #pragma omp interchange
104 // PRINT-NEXT: for (double c = 42; auto &&v : arr)
105 // DUMP-NEXT: CXXForRangeStmt
106 for (double c = 42; auto &&v : arr)
107 // PRINT-NEXT: for (int i = 0; i < 42; i += 2)
108 // DUMP: ForStmt
109 for (int i = 0; i < 42; i += 2)
110 // PRINT-NEXT: body(c, v, i);
111 // DUMP: CallExpr
112 body(c, v, i);
113 }
114
115
116 // PRINT-LABEL: void foo8(
117 // DUMP-LABEL: FunctionDecl {{.*}} foo8
118 void foo8() {
119 double arr[128];
120 // PRINT: #pragma omp interchange
121 // DUMP: OMPInterchangeDirective
122 #pragma omp interchange
123 // PRINT-NEXT: for (int i = 0; i < 42; i += 2)
124 // DUMP-NEXT: ForStmt
125 for (int i = 0; i < 42; i += 2)
126 // PRINT-NEXT: for (double c = 42; auto &&v : arr)
127 // DUMP: CXXForRangeStmt
128 for (double c = 42; auto &&v : arr)
129 // PRINT-NEXT: body(i, c, v);
130 // DUMP: CallExpr
131 body(i, c, v);
132 }
133
134 #endif
135