[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / metadirective_ast_print.c
blobd9ff7e764521607db7d06b72e24af711f44dd713
1 // RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-linux-gnu -x c -std=c99 -ast-print %s -o - | FileCheck %s
3 // RUN: %clang_cc1 -verify -fopenmp-simd -triple x86_64-unknown-linux-gnu -x c -std=c99 -ast-print %s -o - | FileCheck %s
5 // RUN: %clang_cc1 -verify -fopenmp -triple amdgcn-amd-amdhsa -x c -std=c99 -ast-print %s -o - | FileCheck %s --check-prefix=CHECK-AMDGCN
7 // RUN: %clang_cc1 -verify -fopenmp-simd -triple amdgcn-amd-amdhsa -x c -std=c99 -ast-print %s -o - | FileCheck %s --check-prefix=CHECK-AMDGCN
8 // expected-no-diagnostics
10 #ifndef HEADER
11 #define HEADER
13 void bar(void);
15 #define N 10
16 void foo(void) {
17 #pragma omp metadirective when(device = {kind(cpu)} \
18 : parallel) default()
19 bar();
20 #pragma omp metadirective when(implementation = {vendor(score(0) \
21 : llvm)}, \
22 device = {kind(cpu)} \
23 : parallel) default(target teams)
24 bar();
25 #pragma omp metadirective when(device = {kind(gpu)} \
26 : target teams) when(implementation = {vendor(llvm)} \
27 : parallel) default()
28 bar();
29 #pragma omp metadirective default(target) when(implementation = {vendor(score(5) \
30 : llvm)}, \
31 device = {kind(cpu, host)} \
32 : parallel)
33 bar();
34 #pragma omp metadirective when(user = {condition(N > 10)} \
35 : target) when(user = {condition(N == 10)} \
36 : parallel)
37 bar();
38 #pragma omp metadirective when(device = {kind(host)} \
39 : parallel for)
40 for (int i = 0; i < 100; i++)
42 #pragma omp metadirective when(implementation = {extension(match_all)} \
43 : parallel) default(parallel for)
44 for (int i = 0; i < 100; i++)
46 #pragma omp metadirective when(implementation = {extension(match_any)} \
47 : parallel) default(parallel for)
48 for (int i = 0; i < 100; i++)
50 #pragma omp metadirective when(implementation = {extension(match_none)} \
51 : parallel) default(parallel for)
52 for (int i = 0; i < 100; i++)
55 // Test metadirective with nested OpenMP directive.
56 int array[16];
57 #pragma omp metadirective when(user = {condition(1)} \
58 : parallel for)
59 for (int i = 0; i < 16; i++) {
60 #pragma omp simd
61 for (int j = 0; j < 16; j++)
62 array[i] = i;
65 #pragma omp metadirective when(device={arch("amdgcn")}: \
66 teams distribute parallel for)\
67 default(parallel for)
68 for (int i = 0; i < 100; i++)
71 #pragma omp metadirective when(implementation = {extension(match_all)} \
72 : nothing) default(parallel for)
73 for (int i = 0; i < 16; i++)
76 #pragma omp metadirective when(implementation = {extension(match_any)} \
77 : parallel) default(nothing)
78 for (int i = 0; i < 16; i++)
82 // CHECK: void bar(void);
83 // CHECK: void foo(void)
84 // CHECK-NEXT: #pragma omp parallel
85 // CHECK-NEXT: bar()
86 // CHECK-NEXT: #pragma omp parallel
87 // CHECK-NEXT: bar()
88 // CHECK-NEXT: #pragma omp parallel
89 // CHECK-NEXT: bar()
90 // CHECK-NEXT: #pragma omp parallel
91 // CHECK-NEXT: bar()
92 // CHECK-NEXT: #pragma omp parallel
93 // CHECK-NEXT: bar()
94 // CHECK-NEXT: #pragma omp parallel for
95 // CHECK-NEXT: for (int i = 0; i < 100; i++)
96 // CHECK: #pragma omp parallel
97 // CHECK-NEXT: for (int i = 0; i < 100; i++)
98 // CHECK: #pragma omp parallel for
99 // CHECK-NEXT: for (int i = 0; i < 100; i++)
100 // CHECK: #pragma omp parallel
101 // CHECK-NEXT: for (int i = 0; i < 100; i++)
102 // CHECK: #pragma omp parallel for
103 // CHECK-NEXT: for (int i = 0; i < 16; i++) {
104 // CHECK-NEXT: #pragma omp simd
105 // CHECK-NEXT: for (int j = 0; j < 16; j++)
106 // CHECK-AMDGCN: #pragma omp teams distribute parallel for
107 // CHECK-AMDGCN-NEXT: for (int i = 0; i < 100; i++)
108 // CHECK: for (int i = 0; i < 16; i++)
109 // CHECK: for (int i = 0; i < 16; i++)
111 #endif