Coverage Report

Created: 2020-07-11 14:00

/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,
24
27.2k
                                          StringRef Str) {
25
27.2k
  switch (Kind) {
26
1.09k
  case OMPC_default:
27
1.09k
    return llvm::StringSwitch<unsigned>(Str)
28
3.27k
#define OMP_DEFAULT_KIND(Enum, Name) .Case(Name, unsigned(Enum))
29
1.09k
#include "llvm/Frontend/OpenMP/OMPKinds.def"
30
1.09k
        .Default(unsigned(llvm::omp::OMP_DEFAULT_unknown));
31
589
  case OMPC_proc_bind:
32
589
    return llvm::StringSwitch<unsigned>(Str)
33
2.94k
#define OMP_PROC_BIND_KIND(Enum, Name, Value) .Case(Name, Value)
34
589
#include "llvm/Frontend/OpenMP/OMPKinds.def"
35
589
        .Default(unsigned(llvm::omp::OMP_PROC_BIND_unknown));
36
2.97k
  case OMPC_schedule:
37
2.97k
    return llvm::StringSwitch<unsigned>(Str)
38
2.97k
#define OPENMP_SCHEDULE_KIND(Name)                                             \
39
14.8k
  .Case(#Name, static_cast<unsigned>(OMPC_SCHEDULE_##Name))
40
2.97k
#define OPENMP_SCHEDULE_MODIFIER(Name)                                         \
41
8.92k
  .Case(#Name, static_cast<unsigned>(OMPC_SCHEDULE_MODIFIER_##Name))
42
2.97k
#include "clang/Basic/OpenMPKinds.def"
43
2.97k
        .Default(OMPC_SCHEDULE_unknown);
44
4.04k
  case OMPC_depend:
45
4.04k
    return llvm::StringSwitch<OpenMPDependClauseKind>(Str)
46
28.3k
#define OPENMP_DEPEND_KIND(Name) .Case(#Name, OMPC_DEPEND_##Name)
47
4.04k
#include "clang/Basic/OpenMPKinds.def"
48
4.04k
        .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
10.8k
  case OMPC_map:
55
10.8k
    return llvm::StringSwitch<unsigned>(Str)
56
10.8k
#define OPENMP_MAP_KIND(Name)                                                  \
57
65.0k
  .Case(#Name, static_cast<unsigned>(OMPC_MAP_##Name))
58
10.8k
#define OPENMP_MAP_MODIFIER_KIND(Name)                                         \
59
32.5k
  .Case(#Name, static_cast<unsigned>(OMPC_MAP_MODIFIER_##Name))
60
10.8k
#include "clang/Basic/OpenMPKinds.def"
61
10.8k
        .Default(OMPC_MAP_unknown);
62
1.44k
  case OMPC_to:
63
1.44k
    return llvm::StringSwitch<unsigned>(Str)
64
1.44k
#define OPENMP_TO_MODIFIER_KIND(Name)                                          \
65
1.44k
  .Case(#Name, static_cast<unsigned>(OMPC_TO_MODIFIER_##Name))
66
1.44k
#include "clang/Basic/OpenMPKinds.def"
67
1.44k
        .Default(OMPC_TO_MODIFIER_unknown);
68
585
  case OMPC_from:
69
585
    return llvm::StringSwitch<unsigned>(Str)
70
585
#define OPENMP_FROM_MODIFIER_KIND(Name)                                     \
71
585
  .Case(#Name, static_cast<unsigned>(OMPC_FROM_MODIFIER_##Name))
72
585
#include "clang/Basic/OpenMPKinds.def"
73
585
        .Default(OMPC_FROM_MODIFIER_unknown);
74
1.47k
  case OMPC_dist_schedule:
75
1.47k
    return llvm::StringSwitch<OpenMPDistScheduleClauseKind>(Str)
76
1.47k
#define OPENMP_DIST_SCHEDULE_KIND(Name) .Case(#Name, OMPC_DIST_SCHEDULE_##Name)
77
1.47k
#include "clang/Basic/OpenMPKinds.def"
78
1.47k
        .Default(OMPC_DIST_SCHEDULE_unknown);
79
2.81k
  case OMPC_defaultmap:
80
2.81k
    return llvm::StringSwitch<unsigned>(Str)
81
2.81k
#define OPENMP_DEFAULTMAP_KIND(Name)                                           \
82
8.45k
  .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_##Name))
83
2.81k
#define OPENMP_DEFAULTMAP_MODIFIER(Name)                                       \
84
19.7k
  .Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_MODIFIER_##Name))
85
2.81k
#include "clang/Basic/OpenMPKinds.def"
86
2.81k
        .Default(OMPC_DEFAULTMAP_unknown);
87
39
  case OMPC_atomic_default_mem_order:
88
39
     return llvm::StringSwitch<OpenMPAtomicDefaultMemOrderClauseKind>(Str)
89
39
#define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name)       \
90
117
  .Case(#Name, OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name)
91
39
#include "clang/Basic/OpenMPKinds.def"
92
39
        .Default(OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown);
93
68
  case OMPC_device_type:
94
68
    return llvm::StringSwitch<OpenMPDeviceType>(Str)
95
204
#define OPENMP_DEVICE_TYPE_KIND(Name) .Case(#Name, OMPC_DEVICE_TYPE_##Name)
96
68
#include "clang/Basic/OpenMPKinds.def"
97
68
        .Default(OMPC_DEVICE_TYPE_unknown);
98
92
  case OMPC_lastprivate:
99
92
    return llvm::StringSwitch<OpenMPLastprivateModifier>(Str)
100
92
#define OPENMP_LASTPRIVATE_KIND(Name) .Case(#Name, OMPC_LASTPRIVATE_##Name)
101
92
#include "clang/Basic/OpenMPKinds.def"
102
92
        .Default(OMPC_LASTPRIVATE_unknown);
103
375
  case OMPC_order:
104
375
    return llvm::StringSwitch<OpenMPOrderClauseKind>(Str)
105
375
#define OPENMP_ORDER_KIND(Name) .Case(#Name, OMPC_ORDER_##Name)
106
375
#include "clang/Basic/OpenMPKinds.def"
107
375
        .Default(OMPC_ORDER_unknown);
108
32
  case OMPC_update:
109
32
    return llvm::StringSwitch<OpenMPDependClauseKind>(Str)
110
224
#define OPENMP_DEPEND_KIND(Name) .Case(#Name, OMPC_DEPEND_##Name)
111
32
#include "clang/Basic/OpenMPKinds.def"
112
32
        .Default(OMPC_DEPEND_unknown);
113
22
  case OMPC_device:
114
22
    return llvm::StringSwitch<OpenMPDeviceClauseModifier>(Str)
115
44
#define OPENMP_DEVICE_MODIFIER(Name) .Case(#Name, OMPC_DEVICE_##Name)
116
22
#include "clang/Basic/OpenMPKinds.def"
117
22
        .Default(OMPC_DEVICE_unknown);
118
443
  case OMPC_reduction:
119
443
    return llvm::StringSwitch<OpenMPReductionClauseModifier>(Str)
120
1.32k
#define OPENMP_REDUCTION_MODIFIER(Name) .Case(#Name, OMPC_REDUCTION_##Name)
121
443
#include "clang/Basic/OpenMPKinds.def"
122
443
        .Default(OMPC_REDUCTION_unknown);
123
0
  case OMPC_unknown:
124
0
  case OMPC_threadprivate:
125
0
  case OMPC_if:
126
0
  case OMPC_final:
127
0
  case OMPC_num_threads:
128
0
  case OMPC_safelen:
129
0
  case OMPC_simdlen:
130
0
  case OMPC_allocator:
131
0
  case OMPC_allocate:
132
0
  case OMPC_collapse:
133
0
  case OMPC_private:
134
0
  case OMPC_firstprivate:
135
0
  case OMPC_shared:
136
0
  case OMPC_task_reduction:
137
0
  case OMPC_in_reduction:
138
0
  case OMPC_aligned:
139
0
  case OMPC_copyin:
140
0
  case OMPC_copyprivate:
141
0
  case OMPC_ordered:
142
0
  case OMPC_nowait:
143
0
  case OMPC_untied:
144
0
  case OMPC_mergeable:
145
0
  case OMPC_flush:
146
0
  case OMPC_depobj:
147
0
  case OMPC_read:
148
0
  case OMPC_write:
149
0
  case OMPC_capture:
150
0
  case OMPC_seq_cst:
151
0
  case OMPC_acq_rel:
152
0
  case OMPC_acquire:
153
0
  case OMPC_release:
154
0
  case OMPC_relaxed:
155
0
  case OMPC_threads:
156
0
  case OMPC_simd:
157
0
  case OMPC_num_teams:
158
0
  case OMPC_thread_limit:
159
0
  case OMPC_priority:
160
0
  case OMPC_grainsize:
161
0
  case OMPC_nogroup:
162
0
  case OMPC_num_tasks:
163
0
  case OMPC_hint:
164
0
  case OMPC_uniform:
165
0
  case OMPC_use_device_ptr:
166
0
  case OMPC_use_device_addr:
167
0
  case OMPC_is_device_ptr:
168
0
  case OMPC_unified_address:
169
0
  case OMPC_unified_shared_memory:
170
0
  case OMPC_reverse_offload:
171
0
  case OMPC_dynamic_allocators:
172
0
  case OMPC_match:
173
0
  case OMPC_nontemporal:
174
0
  case OMPC_destroy:
175
0
  case OMPC_detach:
176
0
  case OMPC_inclusive:
177
0
  case OMPC_exclusive:
178
0
  case OMPC_uses_allocators:
179
0
  case OMPC_affinity:
180
0
    break;
181
0
  default:
182
0
    break;
183
0
  }
184
0
  llvm_unreachable("Invalid OpenMP simple clause kind");
185
0
}
186
187
const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
188
10.9k
                                                 unsigned Type) {
189
10.9k
  switch (Kind) {
190
988
  case OMPC_default:
191
988
    switch (llvm::omp::DefaultKind(Type)) {
192
0
#define OMP_DEFAULT_KIND(Enum, Name)                                           \
193
988
  case Enum:                                                                   \
194
988
    return Name;
195
0
#include "llvm/Frontend/OpenMP/OMPKinds.def"
196
988
    }
197
988
    
llvm_unreachable0
("Invalid OpenMP 'default' clause type");
198
988
  case OMPC_proc_bind:
199
556
    switch (Type) {
200
0
#define OMP_PROC_BIND_KIND(Enum, Name, Value)                                  \
201
556
  case Value:                                                                  \
202
556
    return Name;
203
0
#include "llvm/Frontend/OpenMP/OMPKinds.def"
204
556
    }
205
556
    
llvm_unreachable0
("Invalid OpenMP 'proc_bind' clause type");
206
1.77k
  case OMPC_schedule:
207
1.77k
    switch (Type) {
208
0
    case OMPC_SCHEDULE_unknown:
209
0
    case OMPC_SCHEDULE_MODIFIER_last:
210
0
      return "unknown";
211
0
#define OPENMP_SCHEDULE_KIND(Name)                                             \
212
1.17k
    case OMPC_SCHEDULE_##Name:                                                 \
213
1.17k
      return #Name;
214
0
#define OPENMP_SCHEDULE_MODIFIER(Name)                                         \
215
600
    case OMPC_SCHEDULE_MODIFIER_##Name:                                        \
216
600
      return #Name;
217
0
#include "clang/Basic/OpenMPKinds.def"
218
1.77k
    }
219
1.77k
    
llvm_unreachable0
("Invalid OpenMP 'schedule' clause type");
220
2.21k
  case OMPC_depend:
221
2.21k
    switch (Type) {
222
0
    case OMPC_DEPEND_unknown:
223
0
      return "unknown";
224
0
#define OPENMP_DEPEND_KIND(Name)                                             \
225
2.21k
  case OMPC_DEPEND_##Name:                                                   \
226
2.21k
    return #Name;
227
0
#include "clang/Basic/OpenMPKinds.def"
228
2.21k
    }
229
2.21k
    
llvm_unreachable0
("Invalid OpenMP 'depend' clause type");
230
2.21k
  case OMPC_linear:
231
128
    switch (Type) {
232
0
    case OMPC_LINEAR_unknown:
233
0
      return "unknown";
234
0
#define OPENMP_LINEAR_KIND(Name)                                             \
235
128
  case OMPC_LINEAR_##Name:                                                   \
236
128
    return #Name;
237
0
#include "clang/Basic/OpenMPKinds.def"
238
128
    }
239
128
    
llvm_unreachable0
("Invalid OpenMP 'linear' clause type");
240
2.72k
  case OMPC_map:
241
2.72k
    switch (Type) {
242
0
    case OMPC_MAP_unknown:
243
0
    case OMPC_MAP_MODIFIER_last:
244
0
      return "unknown";
245
0
#define OPENMP_MAP_KIND(Name)                                                \
246
2.29k
  case OMPC_MAP_##Name:                                                      \
247
2.29k
    return #Name;
248
0
#define OPENMP_MAP_MODIFIER_KIND(Name)                                       \
249
424
  case OMPC_MAP_MODIFIER_##Name:                                             \
250
424
    return #Name;
251
0
#include "clang/Basic/OpenMPKinds.def"
252
0
    default:
253
0
      break;
254
0
    }
255
0
    llvm_unreachable("Invalid OpenMP 'map' clause type");
256
0
  case OMPC_to:
257
0
    switch (Type) {
258
0
    case OMPC_TO_MODIFIER_unknown:
259
0
      return "unknown";
260
0
#define OPENMP_TO_MODIFIER_KIND(Name)                                          \
261
0
  case OMPC_TO_MODIFIER_##Name:                                                \
262
0
    return #Name;
263
0
#include "clang/Basic/OpenMPKinds.def"
264
0
    default:
265
0
      break;
266
0
    }
267
0
    llvm_unreachable("Invalid OpenMP 'to' clause type");
268
0
  case OMPC_from:
269
0
    switch (Type) {
270
0
    case OMPC_FROM_MODIFIER_unknown:
271
0
      return "unknown";
272
0
#define OPENMP_FROM_MODIFIER_KIND(Name)                                        \
273
0
  case OMPC_FROM_MODIFIER_##Name:                                              \
274
0
    return #Name;
275
0
#include "clang/Basic/OpenMPKinds.def"
276
0
    default:
277
0
      break;
278
0
    }
279
0
    llvm_unreachable("Invalid OpenMP 'from' clause type");
280
416
  case OMPC_dist_schedule:
281
416
    switch (Type) {
282
0
    case OMPC_DIST_SCHEDULE_unknown:
283
0
      return "unknown";
284
0
#define OPENMP_DIST_SCHEDULE_KIND(Name)                                      \
285
416
  case OMPC_DIST_SCHEDULE_##Name:                                            \
286
416
    return #Name;
287
0
#include "clang/Basic/OpenMPKinds.def"
288
416
    }
289
416
    
llvm_unreachable0
("Invalid OpenMP 'dist_schedule' clause type");
290
1.76k
  case OMPC_defaultmap:
291
1.76k
    switch (Type) {
292
0
    case OMPC_DEFAULTMAP_unknown:
293
0
    case OMPC_DEFAULTMAP_MODIFIER_last:
294
0
      return "unknown";
295
0
#define OPENMP_DEFAULTMAP_KIND(Name)                                         \
296
920
    case OMPC_DEFAULTMAP_##Name:                                             \
297
920
      return #Name;
298
0
#define OPENMP_DEFAULTMAP_MODIFIER(Name)                                     \
299
844
    case OMPC_DEFAULTMAP_MODIFIER_##Name:                                    \
300
844
      return #Name;
301
0
#include "clang/Basic/OpenMPKinds.def"
302
1.76k
    }
303
1.76k
    
llvm_unreachable0
("Invalid OpenMP 'schedule' clause type");
304
1.76k
  case OMPC_atomic_default_mem_order:
305
24
    switch (Type) {
306
0
    case OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown:
307
0
      return "unknown";
308
0
#define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name)                           \
309
24
    case OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name:                               \
310
24
      return #Name;
311
0
#include "clang/Basic/OpenMPKinds.def"
312
24
}
313
24
    
llvm_unreachable0
("Invalid OpenMP 'atomic_default_mem_order' clause type");
314
29
  case OMPC_device_type:
315
29
    switch (Type) {
316
0
    case OMPC_DEVICE_TYPE_unknown:
317
0
      return "unknown";
318
0
#define OPENMP_DEVICE_TYPE_KIND(Name)                                          \
319
29
    case OMPC_DEVICE_TYPE_##Name:                                              \
320
29
      return #Name;
321
0
#include "clang/Basic/OpenMPKinds.def"
322
29
    }
323
29
    
llvm_unreachable0
("Invalid OpenMP 'device_type' clause type");
324
44
  case OMPC_lastprivate:
325
44
    switch (Type) {
326
0
    case OMPC_LASTPRIVATE_unknown:
327
0
      return "unknown";
328
0
#define OPENMP_LASTPRIVATE_KIND(Name)                                          \
329
44
    case OMPC_LASTPRIVATE_##Name:                                              \
330
44
      return #Name;
331
0
#include "clang/Basic/OpenMPKinds.def"
332
44
    }
333
44
    
llvm_unreachable0
("Invalid OpenMP 'lastprivate' clause type");
334
174
  case OMPC_order:
335
174
    switch (Type) {
336
0
    case OMPC_ORDER_unknown:
337
0
      return "unknown";
338
0
#define OPENMP_ORDER_KIND(Name)                                                \
339
174
    case OMPC_ORDER_##Name:                                                    \
340
174
      return #Name;
341
0
#include "clang/Basic/OpenMPKinds.def"
342
174
    }
343
174
    
llvm_unreachable0
("Invalid OpenMP 'order' clause type");
344
174
  case OMPC_update:
345
12
    switch (Type) {
346
0
    case OMPC_DEPEND_unknown:
347
0
      return "unknown";
348
0
#define OPENMP_DEPEND_KIND(Name)                                               \
349
12
  case OMPC_DEPEND_##Name:                                                     \
350
12
    return #Name;
351
0
#include "clang/Basic/OpenMPKinds.def"
352
12
    }
353
12
    
llvm_unreachable0
("Invalid OpenMP 'depend' clause type");
354
28
  case OMPC_device:
355
28
    switch (Type) {
356
0
    case OMPC_DEVICE_unknown:
357
0
      return "unknown";
358
0
#define OPENMP_DEVICE_MODIFIER(Name)                                           \
359
28
  case OMPC_DEVICE_##Name:                                                     \
360
28
    return #Name;
361
0
#include "clang/Basic/OpenMPKinds.def"
362
28
    }
363
28
    
llvm_unreachable0
("Invalid OpenMP 'device' clause modifier");
364
115
  case OMPC_reduction:
365
115
    switch (Type) {
366
0
    case OMPC_REDUCTION_unknown:
367
0
      return "unknown";
368
0
#define OPENMP_REDUCTION_MODIFIER(Name)                                        \
369
115
  case OMPC_REDUCTION_##Name:                                                  \
370
115
    return #Name;
371
0
#include "clang/Basic/OpenMPKinds.def"
372
115
    }
373
115
    
llvm_unreachable0
("Invalid OpenMP 'reduction' clause modifier");
374
115
  case OMPC_unknown:
375
0
  case OMPC_threadprivate:
376
0
  case OMPC_if:
377
0
  case OMPC_final:
378
0
  case OMPC_num_threads:
379
0
  case OMPC_safelen:
380
0
  case OMPC_simdlen:
381
0
  case OMPC_allocator:
382
0
  case OMPC_allocate:
383
0
  case OMPC_collapse:
384
0
  case OMPC_private:
385
0
  case OMPC_firstprivate:
386
0
  case OMPC_shared:
387
0
  case OMPC_task_reduction:
388
0
  case OMPC_in_reduction:
389
0
  case OMPC_aligned:
390
0
  case OMPC_copyin:
391
0
  case OMPC_copyprivate:
392
0
  case OMPC_ordered:
393
0
  case OMPC_nowait:
394
0
  case OMPC_untied:
395
0
  case OMPC_mergeable:
396
0
  case OMPC_flush:
397
0
  case OMPC_depobj:
398
0
  case OMPC_read:
399
0
  case OMPC_write:
400
0
  case OMPC_capture:
401
0
  case OMPC_seq_cst:
402
0
  case OMPC_acq_rel:
403
0
  case OMPC_acquire:
404
0
  case OMPC_release:
405
0
  case OMPC_relaxed:
406
0
  case OMPC_threads:
407
0
  case OMPC_simd:
408
0
  case OMPC_num_teams:
409
0
  case OMPC_thread_limit:
410
0
  case OMPC_priority:
411
0
  case OMPC_grainsize:
412
0
  case OMPC_nogroup:
413
0
  case OMPC_num_tasks:
414
0
  case OMPC_hint:
415
0
  case OMPC_uniform:
416
0
  case OMPC_use_device_ptr:
417
0
  case OMPC_use_device_addr:
418
0
  case OMPC_is_device_ptr:
419
0
  case OMPC_unified_address:
420
0
  case OMPC_unified_shared_memory:
421
0
  case OMPC_reverse_offload:
422
0
  case OMPC_dynamic_allocators:
423
0
  case OMPC_match:
424
0
  case OMPC_nontemporal:
425
0
  case OMPC_destroy:
426
0
  case OMPC_detach:
427
0
  case OMPC_inclusive:
428
0
  case OMPC_exclusive:
429
0
  case OMPC_uses_allocators:
430
0
  case OMPC_affinity:
431
0
    break;
432
0
  default:
433
0
    break;
434
0
  }
435
0
  llvm_unreachable("Invalid OpenMP simple clause kind");
436
0
}
437
438
4.58M
bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) {
439
4.58M
  return DKind == OMPD_simd || 
DKind == OMPD_for4.49M
||
DKind == OMPD_for_simd4.35M
||
440
4.58M
         
DKind == OMPD_parallel_for4.25M
||
DKind == OMPD_parallel_for_simd4.18M
||
441
4.58M
         
DKind == OMPD_taskloop4.08M
||
DKind == OMPD_taskloop_simd4.01M
||
442
4.58M
         
DKind == OMPD_master_taskloop3.93M
||
DKind == OMPD_master_taskloop_simd3.86M
||
443
4.58M
         
DKind == OMPD_parallel_master_taskloop3.78M
||
444
4.58M
         
DKind == OMPD_parallel_master_taskloop_simd3.71M
||
445
4.58M
         
DKind == OMPD_distribute3.61M
||
DKind == OMPD_target_parallel_for3.56M
||
446
4.58M
         
DKind == OMPD_distribute_parallel_for3.38M
||
447
4.58M
         
DKind == OMPD_distribute_parallel_for_simd3.16M
||
448
4.58M
         
DKind == OMPD_distribute_simd2.83M
||
449
4.58M
         
DKind == OMPD_target_parallel_for_simd2.56M
||
DKind == OMPD_target_simd2.31M
||
450
4.58M
         
DKind == OMPD_teams_distribute2.13M
||
451
4.58M
         
DKind == OMPD_teams_distribute_simd2.00M
||
452
4.58M
         
DKind == OMPD_teams_distribute_parallel_for_simd1.82M
||
453
4.58M
         
DKind == OMPD_teams_distribute_parallel_for1.57M
||
454
4.58M
         
DKind == OMPD_target_teams_distribute1.40M
||
455
4.58M
         
DKind == OMPD_target_teams_distribute_parallel_for1.24M
||
456
4.58M
         
DKind == OMPD_target_teams_distribute_parallel_for_simd1.04M
||
457
4.58M
         
DKind == OMPD_target_teams_distribute_simd716k
;
458
4.58M
}
459
460
4.66M
bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
461
4.66M
  return DKind == OMPD_for || 
DKind == OMPD_for_simd4.45M
||
462
4.66M
         
DKind == OMPD_sections4.28M
||
DKind == OMPD_section4.27M
||
463
4.66M
         
DKind == OMPD_single4.27M
||
DKind == OMPD_parallel_for4.26M
||
464
4.66M
         
DKind == OMPD_parallel_for_simd4.15M
||
DKind == OMPD_parallel_sections4.01M
||
465
4.66M
         
DKind == OMPD_target_parallel_for4.00M
||
466
4.66M
         
DKind == OMPD_distribute_parallel_for3.83M
||
467
4.66M
         
DKind == OMPD_distribute_parallel_for_simd3.76M
||
468
4.66M
         
DKind == OMPD_target_parallel_for_simd3.66M
||
469
4.66M
         
DKind == OMPD_teams_distribute_parallel_for_simd3.47M
||
470
4.66M
         
DKind == OMPD_teams_distribute_parallel_for3.38M
||
471
4.66M
         
DKind == OMPD_target_teams_distribute_parallel_for3.31M
||
472
4.66M
         
DKind == OMPD_target_teams_distribute_parallel_for_simd3.20M
;
473
4.66M
}
474
475
8.96M
bool clang::isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind) {
476
8.96M
  return DKind == OMPD_taskloop || 
DKind == OMPD_taskloop_simd8.57M
||
477
8.96M
         
DKind == OMPD_master_taskloop8.36M
||
DKind == OMPD_master_taskloop_simd8.20M
||
478
8.96M
         
DKind == OMPD_parallel_master_taskloop7.99M
||
479
8.96M
         
DKind == OMPD_parallel_master_taskloop_simd7.85M
;
480
8.96M
}
481
482
10.9M
bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
483
10.9M
  return DKind == OMPD_parallel || 
DKind == OMPD_parallel_for10.2M
||
484
10.9M
         
DKind == OMPD_parallel_for_simd10.1M
||
DKind == OMPD_parallel_sections10.1M
||
485
10.9M
         
DKind == OMPD_target_parallel10.1M
||
DKind == OMPD_target_parallel_for10.0M
||
486
10.9M
         
DKind == OMPD_distribute_parallel_for9.91M
||
487
10.9M
         
DKind == OMPD_distribute_parallel_for_simd9.82M
||
488
10.9M
         
DKind == OMPD_target_parallel_for_simd9.68M
||
489
10.9M
         
DKind == OMPD_teams_distribute_parallel_for9.47M
||
490
10.9M
         
DKind == OMPD_teams_distribute_parallel_for_simd9.38M
||
491
10.9M
         
DKind == OMPD_target_teams_distribute_parallel_for9.24M
||
492
10.9M
         
DKind == OMPD_target_teams_distribute_parallel_for_simd9.08M
||
493
10.9M
         
DKind == OMPD_parallel_master8.79M
||
494
10.9M
         
DKind == OMPD_parallel_master_taskloop8.78M
||
495
10.9M
         
DKind == OMPD_parallel_master_taskloop_simd8.71M
;
496
10.9M
}
497
498
9.02M
bool clang::isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind) {
499
9.02M
  return DKind == OMPD_target || 
DKind == OMPD_target_parallel7.45M
||
500
9.02M
         
DKind == OMPD_target_parallel_for7.33M
||
501
9.02M
         
DKind == OMPD_target_parallel_for_simd7.13M
||
DKind == OMPD_target_simd6.81M
||
502
9.02M
         
DKind == OMPD_target_teams6.55M
||
DKind == OMPD_target_teams_distribute6.45M
||
503
9.02M
         
DKind == OMPD_target_teams_distribute_parallel_for6.26M
||
504
9.02M
         
DKind == OMPD_target_teams_distribute_parallel_for_simd6.00M
||
505
9.02M
         
DKind == OMPD_target_teams_distribute_simd5.59M
;
506
9.02M
}
507
508
974k
bool clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) {
509
974k
  return DKind == OMPD_target_data || 
DKind == OMPD_target_enter_data962k
||
510
974k
         
DKind == OMPD_target_exit_data957k
||
DKind == OMPD_target_update953k
;
511
974k
}
512
513
7.49M
bool clang::isOpenMPNestingTeamsDirective(OpenMPDirectiveKind DKind) {
514
7.49M
  return DKind == OMPD_teams || 
DKind == OMPD_teams_distribute7.06M
||
515
7.49M
         
DKind == OMPD_teams_distribute_simd7.02M
||
516
7.49M
         
DKind == OMPD_teams_distribute_parallel_for_simd6.96M
||
517
7.49M
         
DKind == OMPD_teams_distribute_parallel_for6.95M
;
518
7.49M
}
519
520
7.30M
bool clang::isOpenMPTeamsDirective(OpenMPDirectiveKind DKind) {
521
7.30M
  return isOpenMPNestingTeamsDirective(DKind) ||
522
7.30M
         
DKind == OMPD_target_teams6.78M
||
DKind == OMPD_target_teams_distribute6.76M
||
523
7.30M
         
DKind == OMPD_target_teams_distribute_parallel_for6.71M
||
524
7.30M
         
DKind == OMPD_target_teams_distribute_parallel_for_simd6.71M
||
525
7.30M
         
DKind == OMPD_target_teams_distribute_simd6.71M
;
526
7.30M
}
527
528
2.51M
bool clang::isOpenMPSimdDirective(OpenMPDirectiveKind DKind) {
529
2.51M
  return DKind == OMPD_simd || 
DKind == OMPD_for_simd2.49M
||
530
2.51M
         
DKind == OMPD_parallel_for_simd2.42M
||
DKind == OMPD_taskloop_simd2.35M
||
531
2.51M
         
DKind == OMPD_master_taskloop_simd2.33M
||
532
2.51M
         
DKind == OMPD_parallel_master_taskloop_simd2.31M
||
533
2.51M
         
DKind == OMPD_distribute_parallel_for_simd2.25M
||
534
2.51M
         
DKind == OMPD_distribute_simd2.15M
||
DKind == OMPD_target_simd2.10M
||
535
2.51M
         
DKind == OMPD_teams_distribute_simd2.05M
||
536
2.51M
         
DKind == OMPD_teams_distribute_parallel_for_simd2.02M
||
537
2.51M
         
DKind == OMPD_target_teams_distribute_parallel_for_simd1.91M
||
538
2.51M
         
DKind == OMPD_target_teams_distribute_simd1.61M
||
539
2.51M
         
DKind == OMPD_target_parallel_for_simd1.54M
;
540
2.51M
}
541
542
1.04M
bool clang::isOpenMPNestingDistributeDirective(OpenMPDirectiveKind Kind) {
543
1.04M
  return Kind == OMPD_distribute || 
Kind == OMPD_distribute_parallel_for1.00M
||
544
1.04M
         
Kind == OMPD_distribute_parallel_for_simd997k
||
545
1.04M
         
Kind == OMPD_distribute_simd991k
;
546
1.04M
  // TODO add next directives.
547
1.04M
}
548
549
982k
bool clang::isOpenMPDistributeDirective(OpenMPDirectiveKind Kind) {
550
982k
  return isOpenMPNestingDistributeDirective(Kind) ||
551
982k
         
Kind == OMPD_teams_distribute814k
||
Kind == OMPD_teams_distribute_simd717k
||
552
982k
         
Kind == OMPD_teams_distribute_parallel_for_simd602k
||
553
982k
         
Kind == OMPD_teams_distribute_parallel_for600k
||
554
982k
         
Kind == OMPD_target_teams_distribute599k
||
555
982k
         
Kind == OMPD_target_teams_distribute_parallel_for457k
||
556
982k
         
Kind == OMPD_target_teams_distribute_parallel_for_simd455k
||
557
982k
         
Kind == OMPD_target_teams_distribute_simd451k
;
558
982k
}
559
560
598k
bool clang::isOpenMPPrivate(OpenMPClauseKind Kind) {
561
598k
  return Kind == OMPC_private || 
Kind == OMPC_firstprivate569k
||
562
598k
         
Kind == OMPC_lastprivate494k
||
Kind == OMPC_linear465k
||
563
598k
         
Kind == OMPC_reduction424k
||
Kind == OMPC_task_reduction337k
||
564
598k
         
Kind == OMPC_in_reduction334k
; // TODO add next clauses like 'reduction'.
565
598k
}
566
567
2.73M
bool clang::isOpenMPThreadPrivate(OpenMPClauseKind Kind) {
568
2.73M
  return Kind == OMPC_threadprivate || 
Kind == OMPC_copyin2.71M
;
569
2.73M
}
570
571
9.51M
bool clang::isOpenMPTaskingDirective(OpenMPDirectiveKind Kind) {
572
9.51M
  return Kind == OMPD_task || 
isOpenMPTaskLoopDirective(Kind)7.16M
;
573
9.51M
}
574
575
2.62M
bool clang::isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind) {
576
2.62M
  return Kind == OMPD_distribute_parallel_for ||
577
2.62M
         
Kind == OMPD_distribute_parallel_for_simd2.48M
||
578
2.62M
         
Kind == OMPD_teams_distribute_parallel_for_simd2.30M
||
579
2.62M
         
Kind == OMPD_teams_distribute_parallel_for2.13M
||
580
2.62M
         
Kind == OMPD_target_teams_distribute_parallel_for1.99M
||
581
2.62M
         
Kind == OMPD_target_teams_distribute_parallel_for_simd1.78M
;
582
2.62M
}
583
584
void clang::getOpenMPCaptureRegions(
585
    SmallVectorImpl<OpenMPDirectiveKind> &CaptureRegions,
586
2.93M
    OpenMPDirectiveKind DKind) {
587
2.93M
  assert(unsigned(DKind) < llvm::omp::Directive_enumSize);
588
2.93M
  switch (DKind) {
589
346k
  case OMPD_parallel:
590
346k
  case OMPD_parallel_for:
591
346k
  case OMPD_parallel_for_simd:
592
346k
  case OMPD_parallel_master:
593
346k
  case OMPD_parallel_sections:
594
346k
  case OMPD_distribute_parallel_for:
595
346k
  case OMPD_distribute_parallel_for_simd:
596
346k
    CaptureRegions.push_back(OMPD_parallel);
597
346k
    break;
598
346k
  case OMPD_target_teams:
599
240k
  case OMPD_target_teams_distribute:
600
240k
  case OMPD_target_teams_distribute_simd:
601
240k
    CaptureRegions.push_back(OMPD_task);
602
240k
    CaptureRegions.push_back(OMPD_target);
603
240k
    CaptureRegions.push_back(OMPD_teams);
604
240k
    break;
605
271k
  case OMPD_teams:
606
271k
  case OMPD_teams_distribute:
607
271k
  case OMPD_teams_distribute_simd:
608
271k
    CaptureRegions.push_back(OMPD_teams);
609
271k
    break;
610
723k
  case OMPD_target:
611
723k
  case OMPD_target_simd:
612
723k
    CaptureRegions.push_back(OMPD_task);
613
723k
    CaptureRegions.push_back(OMPD_target);
614
723k
    break;
615
723k
  case OMPD_teams_distribute_parallel_for:
616
116k
  case OMPD_teams_distribute_parallel_for_simd:
617
116k
    CaptureRegions.push_back(OMPD_teams);
618
116k
    CaptureRegions.push_back(OMPD_parallel);
619
116k
    break;
620
241k
  case OMPD_target_parallel:
621
241k
  case OMPD_target_parallel_for:
622
241k
  case OMPD_target_parallel_for_simd:
623
241k
    CaptureRegions.push_back(OMPD_task);
624
241k
    CaptureRegions.push_back(OMPD_target);
625
241k
    CaptureRegions.push_back(OMPD_parallel);
626
241k
    break;
627
241k
  case OMPD_task:
628
112k
  case OMPD_target_enter_data:
629
112k
  case OMPD_target_exit_data:
630
112k
  case OMPD_target_update:
631
112k
    CaptureRegions.push_back(OMPD_task);
632
112k
    break;
633
206k
  case OMPD_taskloop:
634
206k
  case OMPD_taskloop_simd:
635
206k
  case OMPD_master_taskloop:
636
206k
  case OMPD_master_taskloop_simd:
637
206k
    CaptureRegions.push_back(OMPD_taskloop);
638
206k
    break;
639
206k
  case OMPD_parallel_master_taskloop:
640
153k
  case OMPD_parallel_master_taskloop_simd:
641
153k
    CaptureRegions.push_back(OMPD_parallel);
642
153k
    CaptureRegions.push_back(OMPD_taskloop);
643
153k
    break;
644
247k
  case OMPD_target_teams_distribute_parallel_for:
645
247k
  case OMPD_target_teams_distribute_parallel_for_simd:
646
247k
    CaptureRegions.push_back(OMPD_task);
647
247k
    CaptureRegions.push_back(OMPD_target);
648
247k
    CaptureRegions.push_back(OMPD_teams);
649
247k
    CaptureRegions.push_back(OMPD_parallel);
650
247k
    break;
651
279k
  case OMPD_simd:
652
279k
  case OMPD_for:
653
279k
  case OMPD_for_simd:
654
279k
  case OMPD_sections:
655
279k
  case OMPD_section:
656
279k
  case OMPD_single:
657
279k
  case OMPD_master:
658
279k
  case OMPD_critical:
659
279k
  case OMPD_taskgroup:
660
279k
  case OMPD_distribute:
661
279k
  case OMPD_ordered:
662
279k
  case OMPD_atomic:
663
279k
  case OMPD_target_data:
664
279k
  case OMPD_distribute_simd:
665
279k
    CaptureRegions.push_back(OMPD_unknown);
666
279k
    break;
667
279k
  case OMPD_threadprivate:
668
0
  case OMPD_allocate:
669
0
  case OMPD_taskyield:
670
0
  case OMPD_barrier:
671
0
  case OMPD_taskwait:
672
0
  case OMPD_cancellation_point:
673
0
  case OMPD_cancel:
674
0
  case OMPD_flush:
675
0
  case OMPD_depobj:
676
0
  case OMPD_scan:
677
0
  case OMPD_declare_reduction:
678
0
  case OMPD_declare_mapper:
679
0
  case OMPD_declare_simd:
680
0
  case OMPD_declare_target:
681
0
  case OMPD_end_declare_target:
682
0
  case OMPD_requires:
683
0
  case OMPD_declare_variant:
684
0
  case OMPD_begin_declare_variant:
685
0
  case OMPD_end_declare_variant:
686
0
    llvm_unreachable("OpenMP Directive is not allowed");
687
0
  case OMPD_unknown:
688
0
  default:
689
0
    llvm_unreachable("Unknown OpenMP directive");
690
2.93M
  }
691
2.93M
}