Coverage Report

Created: 2021-09-21 08:58

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Basic/OpenMPKinds.cpp
Line
Count
Source (jump to first uncovered line)
1
//===--- OpenMPKinds.cpp - Token Kinds Support ----------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
/// \file
9
/// This file implements the OpenMP enum and support functions.
10
///
11
//===----------------------------------------------------------------------===//
12
13
#include "clang/Basic/OpenMPKinds.h"
14
#include "clang/Basic/IdentifierTable.h"
15
#include "llvm/ADT/StringRef.h"
16
#include "llvm/ADT/StringSwitch.h"
17
#include "llvm/Support/ErrorHandling.h"
18
#include <cassert>
19
20
using namespace clang;
21
using namespace llvm::omp;
22
23
unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind, StringRef Str,
24
38.8k
                                          const LangOptions &LangOpts) {
25
38.8k
  switch (Kind) {
26
1.69k
  case OMPC_default:
27
1.69k
    return llvm::StringSwitch<unsigned>(Str)
28
6.78k
#define OMP_DEFAULT_KIND(Enum, Name) .Case(Name, unsigned(Enum))
29
1.69k
#include "llvm/Frontend/OpenMP/OMPKinds.def"
30
1.69k
        .Default(unsigned(llvm::omp::OMP_DEFAULT_unknown));
31
661
  case OMPC_proc_bind:
32
661
    return llvm::StringSwitch<unsigned>(Str)
33
3.96k
#define OMP_PROC_BIND_KIND(Enum, Name, Value) .Case(Name, Value)
34
661
#include "llvm/Frontend/OpenMP/OMPKinds.def"
35
661
        .Default(unsigned(llvm::omp::OMP_PROC_BIND_unknown));
36
3.03k
  case OMPC_schedule:
37
3.03k
    return llvm::StringSwitch<unsigned>(Str)
38
3.03k
#define OPENMP_SCHEDULE_KIND(Name)                                             \
39
15.1k
  .Case(#Name, static_cast<unsigned>(OMPC_SCHEDULE_##Name))
40
3.03k
#define OPENMP_SCHEDULE_MODIFIER(Name)                                         \
41
9.09k
  .Case(#Name, static_cast<unsigned>(OMPC_SCHEDULE_MODIFIER_##Name))
42
3.03k
#include "clang/Basic/OpenMPKinds.def"
43
3.03k
        .Default(OMPC_SCHEDULE_unknown);
44
4.24k
  case OMPC_depend:
45
4.24k
    return llvm::StringSwitch<OpenMPDependClauseKind>(Str)
46
29.7k
#define OPENMP_DEPEND_KIND(Name) .Case(#Name, OMPC_DEPEND_##Name)
47
4.24k
#include "clang/Basic/OpenMPKinds.def"
48
4.24k
        .Default(OMPC_DEPEND_unknown);
49
298
  case OMPC_linear:
50
298
    return llvm::StringSwitch<OpenMPLinearClauseKind>(Str)
51
894
#define OPENMP_LINEAR_KIND(Name) .Case(#Name, OMPC_LINEAR_##Name)
52
298
#include "clang/Basic/OpenMPKinds.def"
53
298
        .Default(OMPC_LINEAR_unknown);
54
20.1k
  case OMPC_map: {
55
20.1k
    unsigned Type = llvm::StringSwitch<unsigned>(Str)
56
20.1k
#define OPENMP_MAP_KIND(Name)                                                  \
57
120k
  .Case(#Name, static_cast<unsigned>(OMPC_MAP_##Name))
58
20.1k
#define OPENMP_MAP_MODIFIER_KIND(Name)                                         \
59
100k
  .Case(#Name, static_cast<unsigned>(OMPC_MAP_MODIFIER_##Name))
60
20.1k
#include "clang/Basic/OpenMPKinds.def"
61
20.1k
        .Default(OMPC_MAP_unknown);
62
20.1k
    if (LangOpts.OpenMP < 51 && 
Type == OMPC_MAP_MODIFIER_present17.5k
)
63
320
      return OMPC_MAP_MODIFIER_unknown;
64
19.7k
    if (!LangOpts.OpenMPExtensions && 
Type == OMPC_MAP_MODIFIER_ompx_hold4.50k
)
65
114
      return OMPC_MAP_MODIFIER_unknown;
66
19.6k
    return Type;
67
19.7k
  }
68
1.91k
  case OMPC_to:
69
2.77k
  case OMPC_from: {
70
2.77k
    unsigned Type = llvm::StringSwitch<unsigned>(Str)
71
2.77k
#define OPENMP_MOTION_MODIFIER_KIND(Name)                                      \
72
5.55k
  .Case(#Name, static_cast<unsigned>(OMPC_MOTION_MODIFIER_##Name))
73
2.77k
#include "clang/Basic/OpenMPKinds.def"
74
2.77k
        .Default(OMPC_MOTION_MODIFIER_unknown);
75
2.77k
    if (LangOpts.OpenMP < 51 && 
Type == OMPC_MOTION_MODIFIER_present2.42k
)
76
36
      return OMPC_MOTION_MODIFIER_unknown;
77
2.74k
    return Type;
78
2.77k
  }
79
1.49k
  case OMPC_dist_schedule:
80
1.49k
    return llvm::StringSwitch<OpenMPDistScheduleClauseKind>(Str)
81
1.49k
#define OPENMP_DIST_SCHEDULE_KIND(Name) .Case(#Name, OMPC_DIST_SCHEDULE_##Name)
82
1.49k
#include "clang/Basic/OpenMPKinds.def"
83
1.49k
        .Default(OMPC_DIST_SCHEDULE_unknown);
84
3.39k
  case OMPC_defaultmap:
85
3.39k
    return llvm::StringSwitch<unsigned>(Str)
86
3.39k
#define OPENMP_DEFAULTMAP_KIND(Name)                                           \
87
10.1k
  .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_##Name))
88
3.39k
#define OPENMP_DEFAULTMAP_MODIFIER(Name)                                       \
89
27.1k
  .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_MODIFIER_##Name))
90
3.39k
#include "clang/Basic/OpenMPKinds.def"
91
3.39k
        .Default(OMPC_DEFAULTMAP_unknown);
92
39
  case OMPC_atomic_default_mem_order:
93
39
     return llvm::StringSwitch<OpenMPAtomicDefaultMemOrderClauseKind>(Str)
94
39
#define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name)       \
95
117
  .Case(#Name, OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name)
96
39
#include "clang/Basic/OpenMPKinds.def"
97
39
        .Default(OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown);
98
122
  case OMPC_device_type:
99
122
    return llvm::StringSwitch<OpenMPDeviceType>(Str)
100
366
#define OPENMP_DEVICE_TYPE_KIND(Name) .Case(#Name, OMPC_DEVICE_TYPE_##Name)
101
122
#include "clang/Basic/OpenMPKinds.def"
102
122
        .Default(OMPC_DEVICE_TYPE_unknown);
103
92
  case OMPC_lastprivate:
104
92
    return llvm::StringSwitch<OpenMPLastprivateModifier>(Str)
105
92
#define OPENMP_LASTPRIVATE_KIND(Name) .Case(#Name, OMPC_LASTPRIVATE_##Name)
106
92
#include "clang/Basic/OpenMPKinds.def"
107
92
        .Default(OMPC_LASTPRIVATE_unknown);
108
387
  case OMPC_order:
109
387
    return llvm::StringSwitch<OpenMPOrderClauseKind>(Str)
110
387
#define OPENMP_ORDER_KIND(Name) .Case(#Name, OMPC_ORDER_##Name)
111
387
#include "clang/Basic/OpenMPKinds.def"
112
387
        .Default(OMPC_ORDER_unknown);
113
32
  case OMPC_update:
114
32
    return llvm::StringSwitch<OpenMPDependClauseKind>(Str)
115
224
#define OPENMP_DEPEND_KIND(Name) .Case(#Name, OMPC_DEPEND_##Name)
116
32
#include "clang/Basic/OpenMPKinds.def"
117
32
        .Default(OMPC_DEPEND_unknown);
118
22
  case OMPC_device:
119
22
    return llvm::StringSwitch<OpenMPDeviceClauseModifier>(Str)
120
44
#define OPENMP_DEVICE_MODIFIER(Name) .Case(#Name, OMPC_DEVICE_##Name)
121
22
#include "clang/Basic/OpenMPKinds.def"
122
22
        .Default(OMPC_DEVICE_unknown);
123
463
  case OMPC_reduction:
124
463
    return llvm::StringSwitch<OpenMPReductionClauseModifier>(Str)
125
1.38k
#define OPENMP_REDUCTION_MODIFIER(Name) .Case(#Name, OMPC_REDUCTION_##Name)
126
463
#include "clang/Basic/OpenMPKinds.def"
127
463
        .Default(OMPC_REDUCTION_unknown);
128
0
  case OMPC_unknown:
129
0
  case OMPC_threadprivate:
130
0
  case OMPC_if:
131
0
  case OMPC_final:
132
0
  case OMPC_num_threads:
133
0
  case OMPC_safelen:
134
0
  case OMPC_simdlen:
135
0
  case OMPC_sizes:
136
0
  case OMPC_allocator:
137
0
  case OMPC_allocate:
138
0
  case OMPC_collapse:
139
0
  case OMPC_private:
140
0
  case OMPC_firstprivate:
141
0
  case OMPC_shared:
142
0
  case OMPC_task_reduction:
143
0
  case OMPC_in_reduction:
144
0
  case OMPC_aligned:
145
0
  case OMPC_copyin:
146
0
  case OMPC_copyprivate:
147
0
  case OMPC_ordered:
148
0
  case OMPC_nowait:
149
0
  case OMPC_untied:
150
0
  case OMPC_mergeable:
151
0
  case OMPC_flush:
152
0
  case OMPC_depobj:
153
0
  case OMPC_read:
154
0
  case OMPC_write:
155
0
  case OMPC_capture:
156
0
  case OMPC_seq_cst:
157
0
  case OMPC_acq_rel:
158
0
  case OMPC_acquire:
159
0
  case OMPC_release:
160
0
  case OMPC_relaxed:
161
0
  case OMPC_threads:
162
0
  case OMPC_simd:
163
0
  case OMPC_num_teams:
164
0
  case OMPC_thread_limit:
165
0
  case OMPC_priority:
166
0
  case OMPC_grainsize:
167
0
  case OMPC_nogroup:
168
0
  case OMPC_num_tasks:
169
0
  case OMPC_hint:
170
0
  case OMPC_uniform:
171
0
  case OMPC_use_device_ptr:
172
0
  case OMPC_use_device_addr:
173
0
  case OMPC_is_device_ptr:
174
0
  case OMPC_unified_address:
175
0
  case OMPC_unified_shared_memory:
176
0
  case OMPC_reverse_offload:
177
0
  case OMPC_dynamic_allocators:
178
0
  case OMPC_match:
179
0
  case OMPC_nontemporal:
180
0
  case OMPC_destroy:
181
0
  case OMPC_novariants:
182
0
  case OMPC_nocontext:
183
0
  case OMPC_detach:
184
0
  case OMPC_inclusive:
185
0
  case OMPC_exclusive:
186
0
  case OMPC_uses_allocators:
187
0
  case OMPC_affinity:
188
0
  case OMPC_when:
189
0
    break;
190
0
  default:
191
0
    break;
192
38.8k
  }
193
0
  llvm_unreachable("Invalid OpenMP simple clause kind");
194
0
}
195
196
const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
197
13.8k
                                                 unsigned Type) {
198
13.8k
  switch (Kind) {
199
1.52k
  case OMPC_default:
200
1.52k
    switch (llvm::omp::DefaultKind(Type)) {
201
0
#define OMP_DEFAULT_KIND(Enum, Name)                                           \
202
1.52k
  case Enum:                                                                   \
203
1.52k
    return Name;
204
1.52k
#include 
"llvm/Frontend/OpenMP/OMPKinds.def"0
205
1.52k
    }
206
0
    llvm_unreachable("Invalid OpenMP 'default' clause type");
207
654
  case OMPC_proc_bind:
208
654
    switch (Type) {
209
0
#define OMP_PROC_BIND_KIND(Enum, Name, Value)                                  \
210
654
  case Value:                                                                  \
211
654
    return Name;
212
654
#include 
"llvm/Frontend/OpenMP/OMPKinds.def"0
213
654
    }
214
0
    llvm_unreachable("Invalid OpenMP 'proc_bind' clause type");
215
1.77k
  case OMPC_schedule:
216
1.77k
    switch (Type) {
217
0
    case OMPC_SCHEDULE_unknown:
218
0
    case OMPC_SCHEDULE_MODIFIER_last:
219
0
      return "unknown";
220
0
#define OPENMP_SCHEDULE_KIND(Name)                                             \
221
1.17k
    case OMPC_SCHEDULE_##Name:                                                 \
222
1.17k
      return #Name;
223
0
#define OPENMP_SCHEDULE_MODIFIER(Name)                                         \
224
600
    case OMPC_SCHEDULE_MODIFIER_##Name:                                        \
225
600
      return #Name;
226
1.77k
#include 
"clang/Basic/OpenMPKinds.def"0
227
1.77k
    }
228
0
    llvm_unreachable("Invalid OpenMP 'schedule' clause type");
229
2.51k
  case OMPC_depend:
230
2.51k
    switch (Type) {
231
0
    case OMPC_DEPEND_unknown:
232
0
      return "unknown";
233
0
#define OPENMP_DEPEND_KIND(Name)                                             \
234
2.51k
  case OMPC_DEPEND_##Name:                                                   \
235
2.51k
    return #Name;
236
2.51k
#include 
"clang/Basic/OpenMPKinds.def"0
237
2.51k
    }
238
0
    llvm_unreachable("Invalid OpenMP 'depend' clause type");
239
128
  case OMPC_linear:
240
128
    switch (Type) {
241
0
    case OMPC_LINEAR_unknown:
242
0
      return "unknown";
243
0
#define OPENMP_LINEAR_KIND(Name)                                             \
244
128
  case OMPC_LINEAR_##Name:                                                   \
245
128
    return #Name;
246
128
#include 
"clang/Basic/OpenMPKinds.def"0
247
128
    }
248
0
    llvm_unreachable("Invalid OpenMP 'linear' clause type");
249
4.38k
  case OMPC_map:
250
4.38k
    switch (Type) {
251
0
    case OMPC_MAP_unknown:
252
0
    case OMPC_MAP_MODIFIER_last:
253
0
      return "unknown";
254
0
#define OPENMP_MAP_KIND(Name)                                                \
255
3.65k
  case OMPC_MAP_##Name:                                                      \
256
3.65k
    return #Name;
257
0
#define OPENMP_MAP_MODIFIER_KIND(Name)                                       \
258
724
  case OMPC_MAP_MODIFIER_##Name:                                             \
259
724
    return #Name;
260
0
#include "clang/Basic/OpenMPKinds.def"
261
0
    default:
262
0
      break;
263
4.38k
    }
264
0
    llvm_unreachable("Invalid OpenMP 'map' clause type");
265
64
  case OMPC_to:
266
124
  case OMPC_from:
267
124
    switch (Type) {
268
0
    case OMPC_MOTION_MODIFIER_unknown:
269
0
      return "unknown";
270
0
#define OPENMP_MOTION_MODIFIER_KIND(Name)                                      \
271
124
  case OMPC_MOTION_MODIFIER_##Name:                                            \
272
124
    return #Name;
273
0
#include "clang/Basic/OpenMPKinds.def"
274
0
    default:
275
0
      break;
276
124
    }
277
0
    llvm_unreachable("Invalid OpenMP 'to' or 'from' clause type");
278
416
  case OMPC_dist_schedule:
279
416
    switch (Type) {
280
0
    case OMPC_DIST_SCHEDULE_unknown:
281
0
      return "unknown";
282
0
#define OPENMP_DIST_SCHEDULE_KIND(Name)                                      \
283
416
  case OMPC_DIST_SCHEDULE_##Name:                                            \
284
416
    return #Name;
285
416
#include 
"clang/Basic/OpenMPKinds.def"0
286
416
    }
287
0
    llvm_unreachable("Invalid OpenMP 'dist_schedule' clause type");
288
1.86k
  case OMPC_defaultmap:
289
1.86k
    switch (Type) {
290
0
    case OMPC_DEFAULTMAP_unknown:
291
0
    case OMPC_DEFAULTMAP_MODIFIER_last:
292
0
      return "unknown";
293
0
#define OPENMP_DEFAULTMAP_KIND(Name)                                         \
294
968
    case OMPC_DEFAULTMAP_##Name:                                             \
295
968
      return #Name;
296
0
#define OPENMP_DEFAULTMAP_MODIFIER(Name)                                     \
297
892
    case OMPC_DEFAULTMAP_MODIFIER_##Name:                                    \
298
892
      return #Name;
299
1.86k
#include 
"clang/Basic/OpenMPKinds.def"0
300
1.86k
    }
301
0
    llvm_unreachable("Invalid OpenMP 'schedule' clause type");
302
24
  case OMPC_atomic_default_mem_order:
303
24
    switch (Type) {
304
0
    case OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown:
305
0
      return "unknown";
306
0
#define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name)                           \
307
24
    case OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name:                               \
308
24
      return #Name;
309
24
#include 
"clang/Basic/OpenMPKinds.def"0
310
24
}
311
0
    llvm_unreachable("Invalid OpenMP 'atomic_default_mem_order' clause type");
312
29
  case OMPC_device_type:
313
29
    switch (Type) {
314
0
    case OMPC_DEVICE_TYPE_unknown:
315
0
      return "unknown";
316
0
#define OPENMP_DEVICE_TYPE_KIND(Name)                                          \
317
29
    case OMPC_DEVICE_TYPE_##Name:                                              \
318
29
      return #Name;
319
29
#include 
"clang/Basic/OpenMPKinds.def"0
320
29
    }
321
0
    llvm_unreachable("Invalid OpenMP 'device_type' clause type");
322
44
  case OMPC_lastprivate:
323
44
    switch (Type) {
324
0
    case OMPC_LASTPRIVATE_unknown:
325
0
      return "unknown";
326
0
#define OPENMP_LASTPRIVATE_KIND(Name)                                          \
327
44
    case OMPC_LASTPRIVATE_##Name:                                              \
328
44
      return #Name;
329
44
#include 
"clang/Basic/OpenMPKinds.def"0
330
44
    }
331
0
    llvm_unreachable("Invalid OpenMP 'lastprivate' clause type");
332
186
  case OMPC_order:
333
186
    switch (Type) {
334
0
    case OMPC_ORDER_unknown:
335
0
      return "unknown";
336
0
#define OPENMP_ORDER_KIND(Name)                                                \
337
186
    case OMPC_ORDER_##Name:                                                    \
338
186
      return #Name;
339
186
#include 
"clang/Basic/OpenMPKinds.def"0
340
186
    }
341
0
    llvm_unreachable("Invalid OpenMP 'order' clause type");
342
12
  case OMPC_update:
343
12
    switch (Type) {
344
0
    case OMPC_DEPEND_unknown:
345
0
      return "unknown";
346
0
#define OPENMP_DEPEND_KIND(Name)                                               \
347
12
  case OMPC_DEPEND_##Name:                                                     \
348
12
    return #Name;
349
12
#include 
"clang/Basic/OpenMPKinds.def"0
350
12
    }
351
0
    llvm_unreachable("Invalid OpenMP 'depend' clause type");
352
28
  case OMPC_device:
353
28
    switch (Type) {
354
0
    case OMPC_DEVICE_unknown:
355
0
      return "unknown";
356
0
#define OPENMP_DEVICE_MODIFIER(Name)                                           \
357
28
  case OMPC_DEVICE_##Name:                                                     \
358
28
    return #Name;
359
28
#include 
"clang/Basic/OpenMPKinds.def"0
360
28
    }
361
0
    llvm_unreachable("Invalid OpenMP 'device' clause modifier");
362
143
  case OMPC_reduction:
363
143
    switch (Type) {
364
0
    case OMPC_REDUCTION_unknown:
365
0
      return "unknown";
366
0
#define OPENMP_REDUCTION_MODIFIER(Name)                                        \
367
143
  case OMPC_REDUCTION_##Name:                                                  \
368
143
    return #Name;
369
143
#include 
"clang/Basic/OpenMPKinds.def"0
370
143
    }
371
0
    llvm_unreachable("Invalid OpenMP 'reduction' clause modifier");
372
0
  case OMPC_unknown:
373
0
  case OMPC_threadprivate:
374
0
  case OMPC_if:
375
0
  case OMPC_final:
376
0
  case OMPC_num_threads:
377
0
  case OMPC_safelen:
378
0
  case OMPC_simdlen:
379
0
  case OMPC_sizes:
380
0
  case OMPC_allocator:
381
0
  case OMPC_allocate:
382
0
  case OMPC_collapse:
383
0
  case OMPC_private:
384
0
  case OMPC_firstprivate:
385
0
  case OMPC_shared:
386
0
  case OMPC_task_reduction:
387
0
  case OMPC_in_reduction:
388
0
  case OMPC_aligned:
389
0
  case OMPC_copyin:
390
0
  case OMPC_copyprivate:
391
0
  case OMPC_ordered:
392
0
  case OMPC_nowait:
393
0
  case OMPC_untied:
394
0
  case OMPC_mergeable:
395
0
  case OMPC_flush:
396
0
  case OMPC_depobj:
397
0
  case OMPC_read:
398
0
  case OMPC_write:
399
0
  case OMPC_capture:
400
0
  case OMPC_seq_cst:
401
0
  case OMPC_acq_rel:
402
0
  case OMPC_acquire:
403
0
  case OMPC_release:
404
0
  case OMPC_relaxed:
405
0
  case OMPC_threads:
406
0
  case OMPC_simd:
407
0
  case OMPC_num_teams:
408
0
  case OMPC_thread_limit:
409
0
  case OMPC_priority:
410
0
  case OMPC_grainsize:
411
0
  case OMPC_nogroup:
412
0
  case OMPC_num_tasks:
413
0
  case OMPC_hint:
414
0
  case OMPC_uniform:
415
0
  case OMPC_use_device_ptr:
416
0
  case OMPC_use_device_addr:
417
0
  case OMPC_is_device_ptr:
418
0
  case OMPC_unified_address:
419
0
  case OMPC_unified_shared_memory:
420
0
  case OMPC_reverse_offload:
421
0
  case OMPC_dynamic_allocators:
422
0
  case OMPC_match:
423
0
  case OMPC_nontemporal:
424
0
  case OMPC_destroy:
425
0
  case OMPC_detach:
426
0
  case OMPC_novariants:
427
0
  case OMPC_nocontext:
428
0
  case OMPC_inclusive:
429
0
  case OMPC_exclusive:
430
0
  case OMPC_uses_allocators:
431
0
  case OMPC_affinity:
432
0
  case OMPC_when:
433
0
    break;
434
0
  default:
435
0
    break;
436
13.8k
  }
437
0
  llvm_unreachable("Invalid OpenMP simple clause kind");
438
0
}
439
440
5.30M
bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) {
441
5.30M
  return DKind == OMPD_simd || 
DKind == OMPD_for5.20M
||
DKind == OMPD_for_simd5.06M
||
442
5.30M
         
DKind == OMPD_parallel_for4.95M
||
DKind == OMPD_parallel_for_simd4.86M
||
443
5.30M
         
DKind == OMPD_taskloop4.76M
||
DKind == OMPD_taskloop_simd4.68M
||
444
5.30M
         
DKind == OMPD_master_taskloop4.59M
||
DKind == OMPD_master_taskloop_simd4.52M
||
445
5.30M
         
DKind == OMPD_parallel_master_taskloop4.43M
||
446
5.30M
         
DKind == OMPD_parallel_master_taskloop_simd4.36M
||
447
5.30M
         
DKind == OMPD_distribute4.26M
||
DKind == OMPD_target_parallel_for4.20M
||
448
5.30M
         
DKind == OMPD_distribute_parallel_for3.97M
||
449
5.30M
         
DKind == OMPD_distribute_parallel_for_simd3.73M
||
450
5.30M
         
DKind == OMPD_distribute_simd3.39M
||
451
5.30M
         
DKind == OMPD_target_parallel_for_simd3.11M
||
DKind == OMPD_target_simd2.81M
||
452
5.30M
         
DKind == OMPD_teams_distribute2.59M
||
453
5.30M
         
DKind == OMPD_teams_distribute_simd2.46M
||
454
5.30M
         
DKind == OMPD_teams_distribute_parallel_for_simd2.27M
||
455
5.30M
         
DKind == OMPD_teams_distribute_parallel_for2.01M
||
456
5.30M
         
DKind == OMPD_target_teams_distribute1.83M
||
457
5.30M
         
DKind == OMPD_target_teams_distribute_parallel_for1.62M
||
458
5.30M
         
DKind == OMPD_target_teams_distribute_parallel_for_simd1.39M
||
459
5.30M
         
DKind == OMPD_target_teams_distribute_simd1.00M
||
DKind == OMPD_tile697k
||
460
5.30M
         
DKind == OMPD_unroll696k
;
461
5.30M
}
462
463
5.43M
bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
464
5.43M
  return DKind == OMPD_for || 
DKind == OMPD_for_simd5.20M
||
465
5.43M
         
DKind == OMPD_sections5.03M
||
DKind == OMPD_section5.01M
||
466
5.43M
         
DKind == OMPD_single5.01M
||
DKind == OMPD_parallel_for4.99M
||
467
5.43M
         
DKind == OMPD_parallel_for_simd4.87M
||
DKind == OMPD_parallel_sections4.72M
||
468
5.43M
         
DKind == OMPD_target_parallel_for4.71M
||
469
5.43M
         
DKind == OMPD_distribute_parallel_for4.50M
||
470
5.43M
         
DKind == OMPD_distribute_parallel_for_simd4.41M
||
471
5.43M
         
DKind == OMPD_target_parallel_for_simd4.30M
||
472
5.43M
         
DKind == OMPD_teams_distribute_parallel_for_simd4.10M
||
473
5.43M
         
DKind == OMPD_teams_distribute_parallel_for4.00M
||
474
5.43M
         
DKind == OMPD_target_teams_distribute_parallel_for3.91M
||
475
5.43M
         
DKind == OMPD_target_teams_distribute_parallel_for_simd3.78M
;
476
5.43M
}
477
478
11.9M
bool clang::isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind) {
479
11.9M
  return DKind == OMPD_taskloop || 
DKind == OMPD_taskloop_simd11.5M
||
480
11.9M
         
DKind == OMPD_master_taskloop11.3M
||
DKind == OMPD_master_taskloop_simd11.1M
||
481
11.9M
         
DKind == OMPD_parallel_master_taskloop10.9M
||
482
11.9M
         
DKind == OMPD_parallel_master_taskloop_simd10.8M
;
483
11.9M
}
484
485
14.7M
bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
486
14.7M
  return DKind == OMPD_parallel || 
DKind == OMPD_parallel_for13.9M
||
487
14.7M
         
DKind == OMPD_parallel_for_simd13.8M
||
DKind == OMPD_parallel_sections13.8M
||
488
14.7M
         
DKind == OMPD_target_parallel13.7M
||
DKind == OMPD_target_parallel_for13.6M
||
489
14.7M
         
DKind == OMPD_distribute_parallel_for13.4M
||
490
14.7M
         
DKind == OMPD_distribute_parallel_for_simd13.3M
||
491
14.7M
         
DKind == OMPD_target_parallel_for_simd13.2M
||
492
14.7M
         
DKind == OMPD_teams_distribute_parallel_for12.9M
||
493
14.7M
         
DKind == OMPD_teams_distribute_parallel_for_simd12.8M
||
494
14.7M
         
DKind == OMPD_target_teams_distribute_parallel_for12.7M
||
495
14.7M
         
DKind == OMPD_target_teams_distribute_parallel_for_simd12.5M
||
496
14.7M
         
DKind == OMPD_parallel_master12.1M
||
497
14.7M
         
DKind == OMPD_parallel_master_taskloop12.1M
||
498
14.7M
         
DKind == OMPD_parallel_master_taskloop_simd12.0M
;
499
14.7M
}
500
501
12.7M
bool clang::isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind) {
502
12.7M
  return DKind == OMPD_target || 
DKind == OMPD_target_parallel10.9M
||
503
12.7M
         
DKind == OMPD_target_parallel_for10.7M
||
504
12.7M
         
DKind == OMPD_target_parallel_for_simd10.4M
||
DKind == OMPD_target_simd10.0M
||
505
12.7M
         
DKind == OMPD_target_teams9.75M
||
DKind == OMPD_target_teams_distribute9.58M
||
506
12.7M
         
DKind == OMPD_target_teams_distribute_parallel_for9.31M
||
507
12.7M
         
DKind == OMPD_target_teams_distribute_parallel_for_simd9.02M
||
508
12.7M
         
DKind == OMPD_target_teams_distribute_simd8.52M
;
509
12.7M
}
510
511
1.06M
bool clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) {
512
1.06M
  return DKind == OMPD_target_data || 
DKind == OMPD_target_enter_data1.03M
||
513
1.06M
         
DKind == OMPD_target_exit_data1.03M
||
DKind == OMPD_target_update1.02M
;
514
1.06M
}
515
516
10.9M
bool clang::isOpenMPNestingTeamsDirective(OpenMPDirectiveKind DKind) {
517
10.9M
  return DKind == OMPD_teams || 
DKind == OMPD_teams_distribute10.5M
||
518
10.9M
         
DKind == OMPD_teams_distribute_simd10.4M
||
519
10.9M
         
DKind == OMPD_teams_distribute_parallel_for_simd10.4M
||
520
10.9M
         
DKind == OMPD_teams_distribute_parallel_for10.3M
;
521
10.9M
}
522
523
10.7M
bool clang::isOpenMPTeamsDirective(OpenMPDirectiveKind DKind) {
524
10.7M
  return isOpenMPNestingTeamsDirective(DKind) ||
525
10.7M
         
DKind == OMPD_target_teams10.1M
||
DKind == OMPD_target_teams_distribute10.1M
||
526
10.7M
         
DKind == OMPD_target_teams_distribute_parallel_for10.0M
||
527
10.7M
         
DKind == OMPD_target_teams_distribute_parallel_for_simd10.0M
||
528
10.7M
         
DKind == OMPD_target_teams_distribute_simd10.0M
;
529
10.7M
}
530
531
3.45M
bool clang::isOpenMPSimdDirective(OpenMPDirectiveKind DKind) {
532
3.45M
  return DKind == OMPD_simd || 
DKind == OMPD_for_simd3.40M
||
533
3.45M
         
DKind == OMPD_parallel_for_simd3.32M
||
DKind == OMPD_taskloop_simd3.24M
||
534
3.45M
         
DKind == OMPD_master_taskloop_simd3.21M
||
535
3.45M
         
DKind == OMPD_parallel_master_taskloop_simd3.18M
||
536
3.45M
         
DKind == OMPD_distribute_parallel_for_simd3.11M
||
537
3.45M
         
DKind == OMPD_distribute_simd2.99M
||
DKind == OMPD_target_simd2.93M
||
538
3.45M
         
DKind == OMPD_teams_distribute_simd2.86M
||
539
3.45M
         
DKind == OMPD_teams_distribute_parallel_for_simd2.81M
||
540
3.45M
         
DKind == OMPD_target_teams_distribute_parallel_for_simd2.69M
||
541
3.45M
         
DKind == OMPD_target_teams_distribute_simd2.33M
||
542
3.45M
         
DKind == OMPD_target_parallel_for_simd2.22M
;
543
3.45M
}
544
545
1.03M
bool clang::isOpenMPNestingDistributeDirective(OpenMPDirectiveKind Kind) {
546
1.03M
  return Kind == OMPD_distribute || 
Kind == OMPD_distribute_parallel_for989k
||
547
1.03M
         
Kind == OMPD_distribute_parallel_for_simd984k
||
548
1.03M
         
Kind == OMPD_distribute_simd977k
;
549
  // TODO add next directives.
550
1.03M
}
551
552
959k
bool clang::isOpenMPDistributeDirective(OpenMPDirectiveKind Kind) {
553
959k
  return isOpenMPNestingDistributeDirective(Kind) ||
554
959k
         
Kind == OMPD_teams_distribute808k
||
Kind == OMPD_teams_distribute_simd720k
||
555
959k
         
Kind == OMPD_teams_distribute_parallel_for_simd616k
||
556
959k
         
Kind == OMPD_teams_distribute_parallel_for614k
||
557
959k
         
Kind == OMPD_target_teams_distribute612k
||
558
959k
         
Kind == OMPD_target_teams_distribute_parallel_for457k
||
559
959k
         
Kind == OMPD_target_teams_distribute_parallel_for_simd454k
||
560
959k
         
Kind == OMPD_target_teams_distribute_simd450k
;
561
959k
}
562
563
647k
bool clang::isOpenMPPrivate(OpenMPClauseKind Kind) {
564
647k
  return Kind == OMPC_private || 
Kind == OMPC_firstprivate617k
||
565
647k
         
Kind == OMPC_lastprivate537k
||
Kind == OMPC_linear509k
||
566
647k
         
Kind == OMPC_reduction464k
||
Kind == OMPC_task_reduction378k
||
567
647k
         
Kind == OMPC_in_reduction375k
; // TODO add next clauses like 'reduction'.
568
647k
}
569
570
2.99M
bool clang::isOpenMPThreadPrivate(OpenMPClauseKind Kind) {
571
2.99M
  return Kind == OMPC_threadprivate || 
Kind == OMPC_copyin2.97M
;
572
2.99M
}
573
574
12.5M
bool clang::isOpenMPTaskingDirective(OpenMPDirectiveKind Kind) {
575
12.5M
  return Kind == OMPD_task || 
isOpenMPTaskLoopDirective(Kind)10.1M
;
576
12.5M
}
577
578
2.56M
bool clang::isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind) {
579
2.56M
  return Kind == OMPD_distribute_parallel_for ||
580
2.56M
         
Kind == OMPD_distribute_parallel_for_simd2.41M
||
581
2.56M
         
Kind == OMPD_teams_distribute_parallel_for_simd2.24M
||
582
2.56M
         
Kind == OMPD_teams_distribute_parallel_for2.09M
||
583
2.56M
         
Kind == OMPD_target_teams_distribute_parallel_for1.95M
||
584
2.56M
         
Kind == OMPD_target_teams_distribute_parallel_for_simd1.74M
;
585
2.56M
}
586
587
813k
bool clang::isOpenMPLoopTransformationDirective(OpenMPDirectiveKind DKind) {
588
813k
  return DKind == OMPD_tile || 
DKind == OMPD_unroll812k
;
589
813k
}
590
591
void clang::getOpenMPCaptureRegions(
592
    SmallVectorImpl<OpenMPDirectiveKind> &CaptureRegions,
593
2.92M
    OpenMPDirectiveKind DKind) {
594
2.92M
  assert(unsigned(DKind) < llvm::omp::Directive_enumSize);
595
0
  switch (DKind) {
596
0
  case OMPD_metadirective:
597
0
    CaptureRegions.push_back(OMPD_metadirective);
598
0
    break;
599
165k
  case OMPD_parallel:
600
191k
  case OMPD_parallel_for:
601
224k
  case OMPD_parallel_for_simd:
602
233k
  case OMPD_parallel_master:
603
244k
  case OMPD_parallel_sections:
604
280k
  case OMPD_distribute_parallel_for:
605
329k
  case OMPD_distribute_parallel_for_simd:
606
329k
    CaptureRegions.push_back(OMPD_parallel);
607
329k
    break;
608
68.8k
  case OMPD_target_teams:
609
152k
  case OMPD_target_teams_distribute:
610
275k
  case OMPD_target_teams_distribute_simd:
611
275k
    CaptureRegions.push_back(OMPD_task);
612
275k
    CaptureRegions.push_back(OMPD_target);
613
275k
    CaptureRegions.push_back(OMPD_teams);
614
275k
    break;
615
177k
  case OMPD_teams:
616
206k
  case OMPD_teams_distribute:
617
243k
  case OMPD_teams_distribute_simd:
618
243k
    CaptureRegions.push_back(OMPD_teams);
619
243k
    break;
620
639k
  case OMPD_target:
621
726k
  case OMPD_target_simd:
622
726k
    CaptureRegions.push_back(OMPD_task);
623
726k
    CaptureRegions.push_back(OMPD_target);
624
726k
    break;
625
46.0k
  case OMPD_teams_distribute_parallel_for:
626
107k
  case OMPD_teams_distribute_parallel_for_simd:
627
107k
    CaptureRegions.push_back(OMPD_teams);
628
107k
    CaptureRegions.push_back(OMPD_parallel);
629
107k
    break;
630
69.9k
  case OMPD_target_parallel:
631
167k
  case OMPD_target_parallel_for:
632
276k
  case OMPD_target_parallel_for_simd:
633
276k
    CaptureRegions.push_back(OMPD_task);
634
276k
    CaptureRegions.push_back(OMPD_target);
635
276k
    CaptureRegions.push_back(OMPD_parallel);
636
276k
    break;
637
99.4k
  case OMPD_task:
638
105k
  case OMPD_target_enter_data:
639
111k
  case OMPD_target_exit_data:
640
124k
  case OMPD_target_update:
641
124k
    CaptureRegions.push_back(OMPD_task);
642
124k
    break;
643
46.4k
  case OMPD_taskloop:
644
104k
  case OMPD_taskloop_simd:
645
141k
  case OMPD_master_taskloop:
646
199k
  case OMPD_master_taskloop_simd:
647
199k
    CaptureRegions.push_back(OMPD_taskloop);
648
199k
    break;
649
57.5k
  case OMPD_parallel_master_taskloop:
650
150k
  case OMPD_parallel_master_taskloop_simd:
651
150k
    CaptureRegions.push_back(OMPD_parallel);
652
150k
    CaptureRegions.push_back(OMPD_taskloop);
653
150k
    break;
654
93.5k
  case OMPD_target_teams_distribute_parallel_for:
655
250k
  case OMPD_target_teams_distribute_parallel_for_simd:
656
250k
    CaptureRegions.push_back(OMPD_task);
657
250k
    CaptureRegions.push_back(OMPD_target);
658
250k
    CaptureRegions.push_back(OMPD_teams);
659
250k
    CaptureRegions.push_back(OMPD_parallel);
660
250k
    break;
661
33.7k
  case OMPD_simd:
662
73.3k
  case OMPD_for:
663
105k
  case OMPD_for_simd:
664
119k
  case OMPD_sections:
665
119k
  case OMPD_section:
666
126k
  case OMPD_single:
667
126k
  case OMPD_master:
668
126k
  case OMPD_critical:
669
141k
  case OMPD_taskgroup:
670
151k
  case OMPD_distribute:
671
155k
  case OMPD_ordered:
672
155k
  case OMPD_atomic:
673
204k
  case OMPD_target_data:
674
240k
  case OMPD_distribute_simd:
675
241k
  case OMPD_dispatch:
676
241k
    CaptureRegions.push_back(OMPD_unknown);
677
241k
    break;
678
81
  case OMPD_tile:
679
176
  case OMPD_unroll:
680
    // loop transformations do not introduce captures.
681
176
    break;
682
0
  case OMPD_threadprivate:
683
0
  case OMPD_allocate:
684
0
  case OMPD_taskyield:
685
0
  case OMPD_barrier:
686
0
  case OMPD_taskwait:
687
0
  case OMPD_cancellation_point:
688
0
  case OMPD_cancel:
689
0
  case OMPD_flush:
690
0
  case OMPD_depobj:
691
0
  case OMPD_scan:
692
0
  case OMPD_declare_reduction:
693
0
  case OMPD_declare_mapper:
694
0
  case OMPD_declare_simd:
695
0
  case OMPD_declare_target:
696
0
  case OMPD_end_declare_target:
697
0
  case OMPD_requires:
698
0
  case OMPD_declare_variant:
699
0
  case OMPD_begin_declare_variant:
700
0
  case OMPD_end_declare_variant:
701
0
    llvm_unreachable("OpenMP Directive is not allowed");
702
0
  case OMPD_unknown:
703
0
  default:
704
0
    llvm_unreachable("Unknown OpenMP directive");
705
2.92M
  }
706
2.92M
}