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