Eugene Zelenko | d1b2d22 | 2017-11-29 23:27:36 +0000 | [diff] [blame] | 1 | //===- OpenMPClause.cpp - Classes for OpenMP clauses ----------------------===// |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file implements the subclesses of Stmt class declared in OpenMPClause.h |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "clang/AST/OpenMPClause.h" |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 14 | #include "clang/AST/ASTContext.h" |
Eugene Zelenko | d1b2d22 | 2017-11-29 23:27:36 +0000 | [diff] [blame] | 15 | #include "clang/AST/Decl.h" |
Patrick Lyster | 074c3ae2 | 2018-10-18 14:28:23 +0000 | [diff] [blame] | 16 | #include "clang/AST/DeclOpenMP.h" |
Eugene Zelenko | d1b2d22 | 2017-11-29 23:27:36 +0000 | [diff] [blame] | 17 | #include "clang/Basic/LLVM.h" |
Alexey Bataev | 93dc40d | 2019-12-20 11:04:57 -0500 | [diff] [blame] | 18 | #include "clang/Basic/OpenMPKinds.h" |
Eugene Zelenko | d1b2d22 | 2017-11-29 23:27:36 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/SmallPtrSet.h" |
| 20 | #include "llvm/Support/Casting.h" |
| 21 | #include "llvm/Support/ErrorHandling.h" |
| 22 | #include <algorithm> |
| 23 | #include <cassert> |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 24 | |
| 25 | using namespace clang; |
| 26 | |
| 27 | OMPClause::child_range OMPClause::children() { |
| 28 | switch (getClauseKind()) { |
| 29 | default: |
| 30 | break; |
| 31 | #define OPENMP_CLAUSE(Name, Class) \ |
| 32 | case OMPC_##Name: \ |
| 33 | return static_cast<Class *>(this)->children(); |
| 34 | #include "clang/Basic/OpenMPKinds.def" |
| 35 | } |
| 36 | llvm_unreachable("unknown OMPClause"); |
| 37 | } |
| 38 | |
Alexey Bataev | c2c21ef | 2019-07-11 14:54:17 +0000 | [diff] [blame] | 39 | OMPClause::child_range OMPClause::used_children() { |
| 40 | switch (getClauseKind()) { |
| 41 | #define OPENMP_CLAUSE(Name, Class) \ |
| 42 | case OMPC_##Name: \ |
| 43 | return static_cast<Class *>(this)->used_children(); |
| 44 | #include "clang/Basic/OpenMPKinds.def" |
| 45 | case OMPC_threadprivate: |
| 46 | case OMPC_uniform: |
Alexey Bataev | 729e242 | 2019-08-23 16:11:14 +0000 | [diff] [blame] | 47 | case OMPC_device_type: |
Alexey Bataev | dba792c | 2019-09-23 18:13:31 +0000 | [diff] [blame] | 48 | case OMPC_match: |
Alexey Bataev | c2c21ef | 2019-07-11 14:54:17 +0000 | [diff] [blame] | 49 | case OMPC_unknown: |
| 50 | break; |
| 51 | } |
| 52 | llvm_unreachable("unknown OMPClause"); |
| 53 | } |
| 54 | |
Alexey Bataev | 3392d76 | 2016-02-16 11:18:12 +0000 | [diff] [blame] | 55 | OMPClauseWithPreInit *OMPClauseWithPreInit::get(OMPClause *C) { |
| 56 | auto *Res = OMPClauseWithPreInit::get(const_cast<const OMPClause *>(C)); |
| 57 | return Res ? const_cast<OMPClauseWithPreInit *>(Res) : nullptr; |
| 58 | } |
| 59 | |
| 60 | const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) { |
| 61 | switch (C->getClauseKind()) { |
| 62 | case OMPC_schedule: |
| 63 | return static_cast<const OMPScheduleClause *>(C); |
| 64 | case OMPC_dist_schedule: |
| 65 | return static_cast<const OMPDistScheduleClause *>(C); |
Alexey Bataev | 417089f | 2016-02-17 13:19:37 +0000 | [diff] [blame] | 66 | case OMPC_firstprivate: |
| 67 | return static_cast<const OMPFirstprivateClause *>(C); |
Alexey Bataev | 005248a | 2016-02-25 05:25:57 +0000 | [diff] [blame] | 68 | case OMPC_lastprivate: |
| 69 | return static_cast<const OMPLastprivateClause *>(C); |
Alexey Bataev | 6120507 | 2016-03-02 04:57:40 +0000 | [diff] [blame] | 70 | case OMPC_reduction: |
| 71 | return static_cast<const OMPReductionClause *>(C); |
Alexey Bataev | 169d96a | 2017-07-18 20:17:46 +0000 | [diff] [blame] | 72 | case OMPC_task_reduction: |
| 73 | return static_cast<const OMPTaskReductionClause *>(C); |
Alexey Bataev | fa312f3 | 2017-07-21 18:48:21 +0000 | [diff] [blame] | 74 | case OMPC_in_reduction: |
| 75 | return static_cast<const OMPInReductionClause *>(C); |
Alexey Bataev | 78849fb | 2016-03-09 09:49:00 +0000 | [diff] [blame] | 76 | case OMPC_linear: |
| 77 | return static_cast<const OMPLinearClause *>(C); |
Arpith Chacko Jacob | fe4890a | 2017-01-18 20:40:48 +0000 | [diff] [blame] | 78 | case OMPC_if: |
| 79 | return static_cast<const OMPIfClause *>(C); |
Arpith Chacko Jacob | 33c849a | 2017-01-25 00:57:16 +0000 | [diff] [blame] | 80 | case OMPC_num_threads: |
| 81 | return static_cast<const OMPNumThreadsClause *>(C); |
Arpith Chacko Jacob | bc12634 | 2017-01-25 11:28:18 +0000 | [diff] [blame] | 82 | case OMPC_num_teams: |
| 83 | return static_cast<const OMPNumTeamsClause *>(C); |
Arpith Chacko Jacob | 7ecc0b7 | 2017-01-25 11:44:35 +0000 | [diff] [blame] | 84 | case OMPC_thread_limit: |
| 85 | return static_cast<const OMPThreadLimitClause *>(C); |
Alexey Bataev | 931e19b | 2017-10-02 16:32:39 +0000 | [diff] [blame] | 86 | case OMPC_device: |
| 87 | return static_cast<const OMPDeviceClause *>(C); |
Alexey Bataev | b9c55e2 | 2019-10-14 19:29:52 +0000 | [diff] [blame] | 88 | case OMPC_grainsize: |
| 89 | return static_cast<const OMPGrainsizeClause *>(C); |
Alexey Bataev | d88c7de | 2019-10-14 20:44:34 +0000 | [diff] [blame] | 90 | case OMPC_num_tasks: |
| 91 | return static_cast<const OMPNumTasksClause *>(C); |
Alexey Bataev | 3a842ec | 2019-10-15 19:37:05 +0000 | [diff] [blame] | 92 | case OMPC_final: |
| 93 | return static_cast<const OMPFinalClause *>(C); |
Alexey Bataev | 31ba476 | 2019-10-16 18:09:37 +0000 | [diff] [blame] | 94 | case OMPC_priority: |
| 95 | return static_cast<const OMPPriorityClause *>(C); |
Alexey Bataev | 3392d76 | 2016-02-16 11:18:12 +0000 | [diff] [blame] | 96 | case OMPC_default: |
| 97 | case OMPC_proc_bind: |
Alexey Bataev | 3392d76 | 2016-02-16 11:18:12 +0000 | [diff] [blame] | 98 | case OMPC_safelen: |
| 99 | case OMPC_simdlen: |
Alexey Bataev | 9cc10fc | 2019-03-12 18:52:33 +0000 | [diff] [blame] | 100 | case OMPC_allocator: |
Alexey Bataev | e04483e | 2019-03-27 14:14:31 +0000 | [diff] [blame] | 101 | case OMPC_allocate: |
Alexey Bataev | 3392d76 | 2016-02-16 11:18:12 +0000 | [diff] [blame] | 102 | case OMPC_collapse: |
| 103 | case OMPC_private: |
Alexey Bataev | 005248a | 2016-02-25 05:25:57 +0000 | [diff] [blame] | 104 | case OMPC_shared: |
Alexey Bataev | 005248a | 2016-02-25 05:25:57 +0000 | [diff] [blame] | 105 | case OMPC_aligned: |
| 106 | case OMPC_copyin: |
| 107 | case OMPC_copyprivate: |
| 108 | case OMPC_ordered: |
| 109 | case OMPC_nowait: |
| 110 | case OMPC_untied: |
| 111 | case OMPC_mergeable: |
| 112 | case OMPC_threadprivate: |
| 113 | case OMPC_flush: |
| 114 | case OMPC_read: |
| 115 | case OMPC_write: |
| 116 | case OMPC_update: |
| 117 | case OMPC_capture: |
| 118 | case OMPC_seq_cst: |
| 119 | case OMPC_depend: |
Alexey Bataev | 005248a | 2016-02-25 05:25:57 +0000 | [diff] [blame] | 120 | case OMPC_threads: |
| 121 | case OMPC_simd: |
| 122 | case OMPC_map: |
Alexey Bataev | 005248a | 2016-02-25 05:25:57 +0000 | [diff] [blame] | 123 | case OMPC_nogroup: |
Alexey Bataev | 005248a | 2016-02-25 05:25:57 +0000 | [diff] [blame] | 124 | case OMPC_hint: |
| 125 | case OMPC_defaultmap: |
| 126 | case OMPC_unknown: |
Alexey Bataev | e48a5fc | 2016-04-12 05:28:34 +0000 | [diff] [blame] | 127 | case OMPC_uniform: |
Samuel Antao | 661c090 | 2016-05-26 17:39:58 +0000 | [diff] [blame] | 128 | case OMPC_to: |
Samuel Antao | ec172c6 | 2016-05-26 17:49:04 +0000 | [diff] [blame] | 129 | case OMPC_from: |
Carlo Bertolli | 2404b17 | 2016-07-13 15:37:16 +0000 | [diff] [blame] | 130 | case OMPC_use_device_ptr: |
Carlo Bertolli | 70594e9 | 2016-07-13 17:16:49 +0000 | [diff] [blame] | 131 | case OMPC_is_device_ptr: |
Kelvin Li | 1408f91 | 2018-09-26 04:28:39 +0000 | [diff] [blame] | 132 | case OMPC_unified_address: |
Patrick Lyster | 4a370b9 | 2018-10-01 13:47:43 +0000 | [diff] [blame] | 133 | case OMPC_unified_shared_memory: |
Patrick Lyster | 6bdf63b | 2018-10-03 20:07:58 +0000 | [diff] [blame] | 134 | case OMPC_reverse_offload: |
Patrick Lyster | 3fe9e39 | 2018-10-11 14:41:10 +0000 | [diff] [blame] | 135 | case OMPC_dynamic_allocators: |
Patrick Lyster | 7a2a27c | 2018-11-02 12:18:11 +0000 | [diff] [blame] | 136 | case OMPC_atomic_default_mem_order: |
Alexey Bataev | 729e242 | 2019-08-23 16:11:14 +0000 | [diff] [blame] | 137 | case OMPC_device_type: |
Alexey Bataev | dba792c | 2019-09-23 18:13:31 +0000 | [diff] [blame] | 138 | case OMPC_match: |
Alexey Bataev | b6e7084 | 2019-12-16 15:54:17 -0500 | [diff] [blame] | 139 | case OMPC_nontemporal: |
Alexey Bataev | cb8e691 | 2020-01-31 16:09:26 -0500 | [diff] [blame^] | 140 | case OMPC_order: |
Alexey Bataev | 005248a | 2016-02-25 05:25:57 +0000 | [diff] [blame] | 141 | break; |
| 142 | } |
| 143 | |
| 144 | return nullptr; |
| 145 | } |
| 146 | |
| 147 | OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(OMPClause *C) { |
| 148 | auto *Res = OMPClauseWithPostUpdate::get(const_cast<const OMPClause *>(C)); |
| 149 | return Res ? const_cast<OMPClauseWithPostUpdate *>(Res) : nullptr; |
| 150 | } |
| 151 | |
| 152 | const OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(const OMPClause *C) { |
| 153 | switch (C->getClauseKind()) { |
Alexey Bataev | 3392d76 | 2016-02-16 11:18:12 +0000 | [diff] [blame] | 154 | case OMPC_lastprivate: |
Alexey Bataev | 005248a | 2016-02-25 05:25:57 +0000 | [diff] [blame] | 155 | return static_cast<const OMPLastprivateClause *>(C); |
Alexey Bataev | 6120507 | 2016-03-02 04:57:40 +0000 | [diff] [blame] | 156 | case OMPC_reduction: |
| 157 | return static_cast<const OMPReductionClause *>(C); |
Alexey Bataev | 169d96a | 2017-07-18 20:17:46 +0000 | [diff] [blame] | 158 | case OMPC_task_reduction: |
| 159 | return static_cast<const OMPTaskReductionClause *>(C); |
Alexey Bataev | fa312f3 | 2017-07-21 18:48:21 +0000 | [diff] [blame] | 160 | case OMPC_in_reduction: |
| 161 | return static_cast<const OMPInReductionClause *>(C); |
Alexey Bataev | 78849fb | 2016-03-09 09:49:00 +0000 | [diff] [blame] | 162 | case OMPC_linear: |
| 163 | return static_cast<const OMPLinearClause *>(C); |
Alexey Bataev | 005248a | 2016-02-25 05:25:57 +0000 | [diff] [blame] | 164 | case OMPC_schedule: |
| 165 | case OMPC_dist_schedule: |
| 166 | case OMPC_firstprivate: |
| 167 | case OMPC_default: |
| 168 | case OMPC_proc_bind: |
| 169 | case OMPC_if: |
| 170 | case OMPC_final: |
| 171 | case OMPC_num_threads: |
| 172 | case OMPC_safelen: |
| 173 | case OMPC_simdlen: |
Alexey Bataev | 9cc10fc | 2019-03-12 18:52:33 +0000 | [diff] [blame] | 174 | case OMPC_allocator: |
Alexey Bataev | e04483e | 2019-03-27 14:14:31 +0000 | [diff] [blame] | 175 | case OMPC_allocate: |
Alexey Bataev | 005248a | 2016-02-25 05:25:57 +0000 | [diff] [blame] | 176 | case OMPC_collapse: |
| 177 | case OMPC_private: |
Alexey Bataev | 3392d76 | 2016-02-16 11:18:12 +0000 | [diff] [blame] | 178 | case OMPC_shared: |
Alexey Bataev | 3392d76 | 2016-02-16 11:18:12 +0000 | [diff] [blame] | 179 | case OMPC_aligned: |
| 180 | case OMPC_copyin: |
| 181 | case OMPC_copyprivate: |
| 182 | case OMPC_ordered: |
| 183 | case OMPC_nowait: |
| 184 | case OMPC_untied: |
| 185 | case OMPC_mergeable: |
| 186 | case OMPC_threadprivate: |
| 187 | case OMPC_flush: |
| 188 | case OMPC_read: |
| 189 | case OMPC_write: |
| 190 | case OMPC_update: |
| 191 | case OMPC_capture: |
| 192 | case OMPC_seq_cst: |
| 193 | case OMPC_depend: |
| 194 | case OMPC_device: |
| 195 | case OMPC_threads: |
| 196 | case OMPC_simd: |
| 197 | case OMPC_map: |
| 198 | case OMPC_num_teams: |
| 199 | case OMPC_thread_limit: |
| 200 | case OMPC_priority: |
| 201 | case OMPC_grainsize: |
| 202 | case OMPC_nogroup: |
| 203 | case OMPC_num_tasks: |
| 204 | case OMPC_hint: |
| 205 | case OMPC_defaultmap: |
| 206 | case OMPC_unknown: |
Alexey Bataev | e48a5fc | 2016-04-12 05:28:34 +0000 | [diff] [blame] | 207 | case OMPC_uniform: |
Samuel Antao | 661c090 | 2016-05-26 17:39:58 +0000 | [diff] [blame] | 208 | case OMPC_to: |
Samuel Antao | ec172c6 | 2016-05-26 17:49:04 +0000 | [diff] [blame] | 209 | case OMPC_from: |
Carlo Bertolli | 2404b17 | 2016-07-13 15:37:16 +0000 | [diff] [blame] | 210 | case OMPC_use_device_ptr: |
Carlo Bertolli | 70594e9 | 2016-07-13 17:16:49 +0000 | [diff] [blame] | 211 | case OMPC_is_device_ptr: |
Kelvin Li | 1408f91 | 2018-09-26 04:28:39 +0000 | [diff] [blame] | 212 | case OMPC_unified_address: |
Patrick Lyster | 4a370b9 | 2018-10-01 13:47:43 +0000 | [diff] [blame] | 213 | case OMPC_unified_shared_memory: |
Patrick Lyster | 6bdf63b | 2018-10-03 20:07:58 +0000 | [diff] [blame] | 214 | case OMPC_reverse_offload: |
Patrick Lyster | 3fe9e39 | 2018-10-11 14:41:10 +0000 | [diff] [blame] | 215 | case OMPC_dynamic_allocators: |
Patrick Lyster | 7a2a27c | 2018-11-02 12:18:11 +0000 | [diff] [blame] | 216 | case OMPC_atomic_default_mem_order: |
Alexey Bataev | 729e242 | 2019-08-23 16:11:14 +0000 | [diff] [blame] | 217 | case OMPC_device_type: |
Alexey Bataev | dba792c | 2019-09-23 18:13:31 +0000 | [diff] [blame] | 218 | case OMPC_match: |
Alexey Bataev | b6e7084 | 2019-12-16 15:54:17 -0500 | [diff] [blame] | 219 | case OMPC_nontemporal: |
Alexey Bataev | cb8e691 | 2020-01-31 16:09:26 -0500 | [diff] [blame^] | 220 | case OMPC_order: |
Alexey Bataev | 3392d76 | 2016-02-16 11:18:12 +0000 | [diff] [blame] | 221 | break; |
| 222 | } |
| 223 | |
| 224 | return nullptr; |
| 225 | } |
| 226 | |
Alexey Bataev | 655cb4a | 2019-07-16 14:51:46 +0000 | [diff] [blame] | 227 | /// Gets the address of the original, non-captured, expression used in the |
| 228 | /// clause as the preinitializer. |
| 229 | static Stmt **getAddrOfExprAsWritten(Stmt *S) { |
| 230 | if (!S) |
| 231 | return nullptr; |
| 232 | if (auto *DS = dyn_cast<DeclStmt>(S)) { |
| 233 | assert(DS->isSingleDecl() && "Only single expression must be captured."); |
| 234 | if (auto *OED = dyn_cast<OMPCapturedExprDecl>(DS->getSingleDecl())) |
| 235 | return OED->getInitAddress(); |
| 236 | } |
| 237 | return nullptr; |
| 238 | } |
| 239 | |
| 240 | OMPClause::child_range OMPIfClause::used_children() { |
| 241 | if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt())) |
| 242 | return child_range(C, C + 1); |
| 243 | return child_range(&Condition, &Condition + 1); |
| 244 | } |
| 245 | |
Alexey Bataev | b9c55e2 | 2019-10-14 19:29:52 +0000 | [diff] [blame] | 246 | OMPClause::child_range OMPGrainsizeClause::used_children() { |
| 247 | if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt())) |
| 248 | return child_range(C, C + 1); |
| 249 | return child_range(&Grainsize, &Grainsize + 1); |
| 250 | } |
| 251 | |
Alexey Bataev | d88c7de | 2019-10-14 20:44:34 +0000 | [diff] [blame] | 252 | OMPClause::child_range OMPNumTasksClause::used_children() { |
| 253 | if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt())) |
| 254 | return child_range(C, C + 1); |
| 255 | return child_range(&NumTasks, &NumTasks + 1); |
| 256 | } |
| 257 | |
Alexey Bataev | 3a842ec | 2019-10-15 19:37:05 +0000 | [diff] [blame] | 258 | OMPClause::child_range OMPFinalClause::used_children() { |
| 259 | if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt())) |
| 260 | return child_range(C, C + 1); |
| 261 | return child_range(&Condition, &Condition + 1); |
| 262 | } |
| 263 | |
Alexey Bataev | 31ba476 | 2019-10-16 18:09:37 +0000 | [diff] [blame] | 264 | OMPClause::child_range OMPPriorityClause::used_children() { |
| 265 | if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt())) |
| 266 | return child_range(C, C + 1); |
| 267 | return child_range(&Priority, &Priority + 1); |
| 268 | } |
| 269 | |
Alexey Bataev | f138fda | 2018-08-13 19:04:24 +0000 | [diff] [blame] | 270 | OMPOrderedClause *OMPOrderedClause::Create(const ASTContext &C, Expr *Num, |
| 271 | unsigned NumLoops, |
| 272 | SourceLocation StartLoc, |
| 273 | SourceLocation LParenLoc, |
| 274 | SourceLocation EndLoc) { |
| 275 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops)); |
| 276 | auto *Clause = |
| 277 | new (Mem) OMPOrderedClause(Num, NumLoops, StartLoc, LParenLoc, EndLoc); |
| 278 | for (unsigned I = 0; I < NumLoops; ++I) { |
| 279 | Clause->setLoopNumIterations(I, nullptr); |
| 280 | Clause->setLoopCounter(I, nullptr); |
| 281 | } |
| 282 | return Clause; |
| 283 | } |
| 284 | |
| 285 | OMPOrderedClause *OMPOrderedClause::CreateEmpty(const ASTContext &C, |
| 286 | unsigned NumLoops) { |
| 287 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops)); |
| 288 | auto *Clause = new (Mem) OMPOrderedClause(NumLoops); |
| 289 | for (unsigned I = 0; I < NumLoops; ++I) { |
| 290 | Clause->setLoopNumIterations(I, nullptr); |
| 291 | Clause->setLoopCounter(I, nullptr); |
| 292 | } |
| 293 | return Clause; |
| 294 | } |
| 295 | |
| 296 | void OMPOrderedClause::setLoopNumIterations(unsigned NumLoop, |
| 297 | Expr *NumIterations) { |
| 298 | assert(NumLoop < NumberOfLoops && "out of loops number."); |
| 299 | getTrailingObjects<Expr *>()[NumLoop] = NumIterations; |
| 300 | } |
| 301 | |
| 302 | ArrayRef<Expr *> OMPOrderedClause::getLoopNumIterations() const { |
| 303 | return llvm::makeArrayRef(getTrailingObjects<Expr *>(), NumberOfLoops); |
| 304 | } |
| 305 | |
| 306 | void OMPOrderedClause::setLoopCounter(unsigned NumLoop, Expr *Counter) { |
| 307 | assert(NumLoop < NumberOfLoops && "out of loops number."); |
| 308 | getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop] = Counter; |
| 309 | } |
| 310 | |
Mike Rice | 0ed4666 | 2018-09-20 17:19:41 +0000 | [diff] [blame] | 311 | Expr *OMPOrderedClause::getLoopCounter(unsigned NumLoop) { |
Alexey Bataev | f138fda | 2018-08-13 19:04:24 +0000 | [diff] [blame] | 312 | assert(NumLoop < NumberOfLoops && "out of loops number."); |
| 313 | return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop]; |
| 314 | } |
| 315 | |
Mike Rice | 0ed4666 | 2018-09-20 17:19:41 +0000 | [diff] [blame] | 316 | const Expr *OMPOrderedClause::getLoopCounter(unsigned NumLoop) const { |
Alexey Bataev | f138fda | 2018-08-13 19:04:24 +0000 | [diff] [blame] | 317 | assert(NumLoop < NumberOfLoops && "out of loops number."); |
| 318 | return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop]; |
| 319 | } |
| 320 | |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 321 | void OMPPrivateClause::setPrivateCopies(ArrayRef<Expr *> VL) { |
| 322 | assert(VL.size() == varlist_size() && |
| 323 | "Number of private copies is not the same as the preallocated buffer"); |
| 324 | std::copy(VL.begin(), VL.end(), varlist_end()); |
| 325 | } |
| 326 | |
| 327 | OMPPrivateClause * |
| 328 | OMPPrivateClause::Create(const ASTContext &C, SourceLocation StartLoc, |
| 329 | SourceLocation LParenLoc, SourceLocation EndLoc, |
| 330 | ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL) { |
| 331 | // Allocate space for private variables and initializer expressions. |
James Y Knight | 374fd20 | 2016-01-01 00:38:24 +0000 | [diff] [blame] | 332 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size())); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 333 | OMPPrivateClause *Clause = |
| 334 | new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size()); |
| 335 | Clause->setVarRefs(VL); |
| 336 | Clause->setPrivateCopies(PrivateVL); |
| 337 | return Clause; |
| 338 | } |
| 339 | |
| 340 | OMPPrivateClause *OMPPrivateClause::CreateEmpty(const ASTContext &C, |
| 341 | unsigned N) { |
James Y Knight | 374fd20 | 2016-01-01 00:38:24 +0000 | [diff] [blame] | 342 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N)); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 343 | return new (Mem) OMPPrivateClause(N); |
| 344 | } |
| 345 | |
| 346 | void OMPFirstprivateClause::setPrivateCopies(ArrayRef<Expr *> VL) { |
| 347 | assert(VL.size() == varlist_size() && |
| 348 | "Number of private copies is not the same as the preallocated buffer"); |
| 349 | std::copy(VL.begin(), VL.end(), varlist_end()); |
| 350 | } |
| 351 | |
| 352 | void OMPFirstprivateClause::setInits(ArrayRef<Expr *> VL) { |
| 353 | assert(VL.size() == varlist_size() && |
| 354 | "Number of inits is not the same as the preallocated buffer"); |
| 355 | std::copy(VL.begin(), VL.end(), getPrivateCopies().end()); |
| 356 | } |
| 357 | |
| 358 | OMPFirstprivateClause * |
| 359 | OMPFirstprivateClause::Create(const ASTContext &C, SourceLocation StartLoc, |
| 360 | SourceLocation LParenLoc, SourceLocation EndLoc, |
| 361 | ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL, |
Alexey Bataev | 417089f | 2016-02-17 13:19:37 +0000 | [diff] [blame] | 362 | ArrayRef<Expr *> InitVL, Stmt *PreInit) { |
James Y Knight | 374fd20 | 2016-01-01 00:38:24 +0000 | [diff] [blame] | 363 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size())); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 364 | OMPFirstprivateClause *Clause = |
| 365 | new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size()); |
| 366 | Clause->setVarRefs(VL); |
| 367 | Clause->setPrivateCopies(PrivateVL); |
| 368 | Clause->setInits(InitVL); |
Alexey Bataev | 417089f | 2016-02-17 13:19:37 +0000 | [diff] [blame] | 369 | Clause->setPreInitStmt(PreInit); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 370 | return Clause; |
| 371 | } |
| 372 | |
| 373 | OMPFirstprivateClause *OMPFirstprivateClause::CreateEmpty(const ASTContext &C, |
| 374 | unsigned N) { |
James Y Knight | 374fd20 | 2016-01-01 00:38:24 +0000 | [diff] [blame] | 375 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * N)); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 376 | return new (Mem) OMPFirstprivateClause(N); |
| 377 | } |
| 378 | |
| 379 | void OMPLastprivateClause::setPrivateCopies(ArrayRef<Expr *> PrivateCopies) { |
| 380 | assert(PrivateCopies.size() == varlist_size() && |
| 381 | "Number of private copies is not the same as the preallocated buffer"); |
| 382 | std::copy(PrivateCopies.begin(), PrivateCopies.end(), varlist_end()); |
| 383 | } |
| 384 | |
| 385 | void OMPLastprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) { |
| 386 | assert(SrcExprs.size() == varlist_size() && "Number of source expressions is " |
| 387 | "not the same as the " |
| 388 | "preallocated buffer"); |
| 389 | std::copy(SrcExprs.begin(), SrcExprs.end(), getPrivateCopies().end()); |
| 390 | } |
| 391 | |
| 392 | void OMPLastprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) { |
| 393 | assert(DstExprs.size() == varlist_size() && "Number of destination " |
| 394 | "expressions is not the same as " |
| 395 | "the preallocated buffer"); |
| 396 | std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end()); |
| 397 | } |
| 398 | |
| 399 | void OMPLastprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) { |
| 400 | assert(AssignmentOps.size() == varlist_size() && |
| 401 | "Number of assignment expressions is not the same as the preallocated " |
| 402 | "buffer"); |
| 403 | std::copy(AssignmentOps.begin(), AssignmentOps.end(), |
| 404 | getDestinationExprs().end()); |
| 405 | } |
| 406 | |
| 407 | OMPLastprivateClause *OMPLastprivateClause::Create( |
| 408 | const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
| 409 | SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs, |
Alexey Bataev | 93dc40d | 2019-12-20 11:04:57 -0500 | [diff] [blame] | 410 | ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps, |
| 411 | OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, |
| 412 | SourceLocation ColonLoc, Stmt *PreInit, Expr *PostUpdate) { |
James Y Knight | 374fd20 | 2016-01-01 00:38:24 +0000 | [diff] [blame] | 413 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size())); |
Alexey Bataev | 93dc40d | 2019-12-20 11:04:57 -0500 | [diff] [blame] | 414 | OMPLastprivateClause *Clause = new (Mem) OMPLastprivateClause( |
| 415 | StartLoc, LParenLoc, EndLoc, LPKind, LPKindLoc, ColonLoc, VL.size()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 416 | Clause->setVarRefs(VL); |
| 417 | Clause->setSourceExprs(SrcExprs); |
| 418 | Clause->setDestinationExprs(DstExprs); |
| 419 | Clause->setAssignmentOps(AssignmentOps); |
Alexey Bataev | 005248a | 2016-02-25 05:25:57 +0000 | [diff] [blame] | 420 | Clause->setPreInitStmt(PreInit); |
| 421 | Clause->setPostUpdateExpr(PostUpdate); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 422 | return Clause; |
| 423 | } |
| 424 | |
| 425 | OMPLastprivateClause *OMPLastprivateClause::CreateEmpty(const ASTContext &C, |
| 426 | unsigned N) { |
James Y Knight | 374fd20 | 2016-01-01 00:38:24 +0000 | [diff] [blame] | 427 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N)); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 428 | return new (Mem) OMPLastprivateClause(N); |
| 429 | } |
| 430 | |
| 431 | OMPSharedClause *OMPSharedClause::Create(const ASTContext &C, |
| 432 | SourceLocation StartLoc, |
| 433 | SourceLocation LParenLoc, |
| 434 | SourceLocation EndLoc, |
| 435 | ArrayRef<Expr *> VL) { |
James Y Knight | 374fd20 | 2016-01-01 00:38:24 +0000 | [diff] [blame] | 436 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size())); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 437 | OMPSharedClause *Clause = |
| 438 | new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size()); |
| 439 | Clause->setVarRefs(VL); |
| 440 | return Clause; |
| 441 | } |
| 442 | |
| 443 | OMPSharedClause *OMPSharedClause::CreateEmpty(const ASTContext &C, unsigned N) { |
James Y Knight | 374fd20 | 2016-01-01 00:38:24 +0000 | [diff] [blame] | 444 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N)); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 445 | return new (Mem) OMPSharedClause(N); |
| 446 | } |
| 447 | |
| 448 | void OMPLinearClause::setPrivates(ArrayRef<Expr *> PL) { |
| 449 | assert(PL.size() == varlist_size() && |
| 450 | "Number of privates is not the same as the preallocated buffer"); |
| 451 | std::copy(PL.begin(), PL.end(), varlist_end()); |
| 452 | } |
| 453 | |
| 454 | void OMPLinearClause::setInits(ArrayRef<Expr *> IL) { |
| 455 | assert(IL.size() == varlist_size() && |
| 456 | "Number of inits is not the same as the preallocated buffer"); |
| 457 | std::copy(IL.begin(), IL.end(), getPrivates().end()); |
| 458 | } |
| 459 | |
| 460 | void OMPLinearClause::setUpdates(ArrayRef<Expr *> UL) { |
| 461 | assert(UL.size() == varlist_size() && |
| 462 | "Number of updates is not the same as the preallocated buffer"); |
| 463 | std::copy(UL.begin(), UL.end(), getInits().end()); |
| 464 | } |
| 465 | |
| 466 | void OMPLinearClause::setFinals(ArrayRef<Expr *> FL) { |
| 467 | assert(FL.size() == varlist_size() && |
| 468 | "Number of final updates is not the same as the preallocated buffer"); |
| 469 | std::copy(FL.begin(), FL.end(), getUpdates().end()); |
| 470 | } |
| 471 | |
Alexey Bataev | 195ae90 | 2019-08-08 13:42:45 +0000 | [diff] [blame] | 472 | void OMPLinearClause::setUsedExprs(ArrayRef<Expr *> UE) { |
| 473 | assert( |
| 474 | UE.size() == varlist_size() + 1 && |
| 475 | "Number of used expressions is not the same as the preallocated buffer"); |
| 476 | std::copy(UE.begin(), UE.end(), getFinals().end() + 2); |
| 477 | } |
| 478 | |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 479 | OMPLinearClause *OMPLinearClause::Create( |
| 480 | const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
| 481 | OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, |
| 482 | SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL, |
Alexey Bataev | 78849fb | 2016-03-09 09:49:00 +0000 | [diff] [blame] | 483 | ArrayRef<Expr *> PL, ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep, |
| 484 | Stmt *PreInit, Expr *PostUpdate) { |
Alexey Bataev | 195ae90 | 2019-08-08 13:42:45 +0000 | [diff] [blame] | 485 | // Allocate space for 5 lists (Vars, Inits, Updates, Finals), 2 expressions |
| 486 | // (Step and CalcStep), list of used expression + step. |
| 487 | void *Mem = |
| 488 | C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2 + VL.size() + 1)); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 489 | OMPLinearClause *Clause = new (Mem) OMPLinearClause( |
| 490 | StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc, EndLoc, VL.size()); |
| 491 | Clause->setVarRefs(VL); |
| 492 | Clause->setPrivates(PL); |
| 493 | Clause->setInits(IL); |
| 494 | // Fill update and final expressions with zeroes, they are provided later, |
| 495 | // after the directive construction. |
| 496 | std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(), |
| 497 | nullptr); |
| 498 | std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(), |
| 499 | nullptr); |
Alexey Bataev | 195ae90 | 2019-08-08 13:42:45 +0000 | [diff] [blame] | 500 | std::fill(Clause->getUsedExprs().begin(), Clause->getUsedExprs().end(), |
| 501 | nullptr); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 502 | Clause->setStep(Step); |
| 503 | Clause->setCalcStep(CalcStep); |
Alexey Bataev | 78849fb | 2016-03-09 09:49:00 +0000 | [diff] [blame] | 504 | Clause->setPreInitStmt(PreInit); |
| 505 | Clause->setPostUpdateExpr(PostUpdate); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 506 | return Clause; |
| 507 | } |
| 508 | |
| 509 | OMPLinearClause *OMPLinearClause::CreateEmpty(const ASTContext &C, |
| 510 | unsigned NumVars) { |
Alexey Bataev | 195ae90 | 2019-08-08 13:42:45 +0000 | [diff] [blame] | 511 | // Allocate space for 5 lists (Vars, Inits, Updates, Finals), 2 expressions |
| 512 | // (Step and CalcStep), list of used expression + step. |
| 513 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2 + NumVars +1)); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 514 | return new (Mem) OMPLinearClause(NumVars); |
| 515 | } |
| 516 | |
Alexey Bataev | 195ae90 | 2019-08-08 13:42:45 +0000 | [diff] [blame] | 517 | OMPClause::child_range OMPLinearClause::used_children() { |
| 518 | // Range includes only non-nullptr elements. |
| 519 | return child_range( |
| 520 | reinterpret_cast<Stmt **>(getUsedExprs().begin()), |
| 521 | reinterpret_cast<Stmt **>(llvm::find(getUsedExprs(), nullptr))); |
| 522 | } |
| 523 | |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 524 | OMPAlignedClause * |
| 525 | OMPAlignedClause::Create(const ASTContext &C, SourceLocation StartLoc, |
| 526 | SourceLocation LParenLoc, SourceLocation ColonLoc, |
| 527 | SourceLocation EndLoc, ArrayRef<Expr *> VL, Expr *A) { |
James Y Knight | 374fd20 | 2016-01-01 00:38:24 +0000 | [diff] [blame] | 528 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1)); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 529 | OMPAlignedClause *Clause = new (Mem) |
| 530 | OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size()); |
| 531 | Clause->setVarRefs(VL); |
| 532 | Clause->setAlignment(A); |
| 533 | return Clause; |
| 534 | } |
| 535 | |
| 536 | OMPAlignedClause *OMPAlignedClause::CreateEmpty(const ASTContext &C, |
| 537 | unsigned NumVars) { |
James Y Knight | 374fd20 | 2016-01-01 00:38:24 +0000 | [diff] [blame] | 538 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1)); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 539 | return new (Mem) OMPAlignedClause(NumVars); |
| 540 | } |
| 541 | |
| 542 | void OMPCopyinClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) { |
| 543 | assert(SrcExprs.size() == varlist_size() && "Number of source expressions is " |
| 544 | "not the same as the " |
| 545 | "preallocated buffer"); |
| 546 | std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end()); |
| 547 | } |
| 548 | |
| 549 | void OMPCopyinClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) { |
| 550 | assert(DstExprs.size() == varlist_size() && "Number of destination " |
| 551 | "expressions is not the same as " |
| 552 | "the preallocated buffer"); |
| 553 | std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end()); |
| 554 | } |
| 555 | |
| 556 | void OMPCopyinClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) { |
| 557 | assert(AssignmentOps.size() == varlist_size() && |
| 558 | "Number of assignment expressions is not the same as the preallocated " |
| 559 | "buffer"); |
| 560 | std::copy(AssignmentOps.begin(), AssignmentOps.end(), |
| 561 | getDestinationExprs().end()); |
| 562 | } |
| 563 | |
| 564 | OMPCopyinClause *OMPCopyinClause::Create( |
| 565 | const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
| 566 | SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs, |
| 567 | ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) { |
James Y Knight | 374fd20 | 2016-01-01 00:38:24 +0000 | [diff] [blame] | 568 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size())); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 569 | OMPCopyinClause *Clause = |
| 570 | new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size()); |
| 571 | Clause->setVarRefs(VL); |
| 572 | Clause->setSourceExprs(SrcExprs); |
| 573 | Clause->setDestinationExprs(DstExprs); |
| 574 | Clause->setAssignmentOps(AssignmentOps); |
| 575 | return Clause; |
| 576 | } |
| 577 | |
| 578 | OMPCopyinClause *OMPCopyinClause::CreateEmpty(const ASTContext &C, unsigned N) { |
James Y Knight | 374fd20 | 2016-01-01 00:38:24 +0000 | [diff] [blame] | 579 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N)); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 580 | return new (Mem) OMPCopyinClause(N); |
| 581 | } |
| 582 | |
| 583 | void OMPCopyprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) { |
| 584 | assert(SrcExprs.size() == varlist_size() && "Number of source expressions is " |
| 585 | "not the same as the " |
| 586 | "preallocated buffer"); |
| 587 | std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end()); |
| 588 | } |
| 589 | |
| 590 | void OMPCopyprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) { |
| 591 | assert(DstExprs.size() == varlist_size() && "Number of destination " |
| 592 | "expressions is not the same as " |
| 593 | "the preallocated buffer"); |
| 594 | std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end()); |
| 595 | } |
| 596 | |
| 597 | void OMPCopyprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) { |
| 598 | assert(AssignmentOps.size() == varlist_size() && |
| 599 | "Number of assignment expressions is not the same as the preallocated " |
| 600 | "buffer"); |
| 601 | std::copy(AssignmentOps.begin(), AssignmentOps.end(), |
| 602 | getDestinationExprs().end()); |
| 603 | } |
| 604 | |
| 605 | OMPCopyprivateClause *OMPCopyprivateClause::Create( |
| 606 | const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
| 607 | SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs, |
| 608 | ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) { |
James Y Knight | 374fd20 | 2016-01-01 00:38:24 +0000 | [diff] [blame] | 609 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size())); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 610 | OMPCopyprivateClause *Clause = |
| 611 | new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size()); |
| 612 | Clause->setVarRefs(VL); |
| 613 | Clause->setSourceExprs(SrcExprs); |
| 614 | Clause->setDestinationExprs(DstExprs); |
| 615 | Clause->setAssignmentOps(AssignmentOps); |
| 616 | return Clause; |
| 617 | } |
| 618 | |
| 619 | OMPCopyprivateClause *OMPCopyprivateClause::CreateEmpty(const ASTContext &C, |
| 620 | unsigned N) { |
James Y Knight | 374fd20 | 2016-01-01 00:38:24 +0000 | [diff] [blame] | 621 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N)); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 622 | return new (Mem) OMPCopyprivateClause(N); |
| 623 | } |
| 624 | |
Alexey Bataev | f24e7b1 | 2015-10-08 09:10:53 +0000 | [diff] [blame] | 625 | void OMPReductionClause::setPrivates(ArrayRef<Expr *> Privates) { |
| 626 | assert(Privates.size() == varlist_size() && |
| 627 | "Number of private copies is not the same as the preallocated buffer"); |
| 628 | std::copy(Privates.begin(), Privates.end(), varlist_end()); |
| 629 | } |
| 630 | |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 631 | void OMPReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) { |
| 632 | assert( |
| 633 | LHSExprs.size() == varlist_size() && |
| 634 | "Number of LHS expressions is not the same as the preallocated buffer"); |
Alexey Bataev | f24e7b1 | 2015-10-08 09:10:53 +0000 | [diff] [blame] | 635 | std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end()); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 636 | } |
| 637 | |
| 638 | void OMPReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) { |
| 639 | assert( |
| 640 | RHSExprs.size() == varlist_size() && |
| 641 | "Number of RHS expressions is not the same as the preallocated buffer"); |
| 642 | std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end()); |
| 643 | } |
| 644 | |
| 645 | void OMPReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) { |
| 646 | assert(ReductionOps.size() == varlist_size() && "Number of reduction " |
| 647 | "expressions is not the same " |
| 648 | "as the preallocated buffer"); |
| 649 | std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end()); |
| 650 | } |
| 651 | |
| 652 | OMPReductionClause *OMPReductionClause::Create( |
| 653 | const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
| 654 | SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL, |
| 655 | NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, |
Alexey Bataev | f24e7b1 | 2015-10-08 09:10:53 +0000 | [diff] [blame] | 656 | ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs, |
Alexey Bataev | 6120507 | 2016-03-02 04:57:40 +0000 | [diff] [blame] | 657 | ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit, |
| 658 | Expr *PostUpdate) { |
James Y Knight | 374fd20 | 2016-01-01 00:38:24 +0000 | [diff] [blame] | 659 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size())); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 660 | OMPReductionClause *Clause = new (Mem) OMPReductionClause( |
| 661 | StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo); |
| 662 | Clause->setVarRefs(VL); |
Alexey Bataev | f24e7b1 | 2015-10-08 09:10:53 +0000 | [diff] [blame] | 663 | Clause->setPrivates(Privates); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 664 | Clause->setLHSExprs(LHSExprs); |
| 665 | Clause->setRHSExprs(RHSExprs); |
| 666 | Clause->setReductionOps(ReductionOps); |
Alexey Bataev | 6120507 | 2016-03-02 04:57:40 +0000 | [diff] [blame] | 667 | Clause->setPreInitStmt(PreInit); |
| 668 | Clause->setPostUpdateExpr(PostUpdate); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 669 | return Clause; |
| 670 | } |
| 671 | |
| 672 | OMPReductionClause *OMPReductionClause::CreateEmpty(const ASTContext &C, |
| 673 | unsigned N) { |
James Y Knight | 374fd20 | 2016-01-01 00:38:24 +0000 | [diff] [blame] | 674 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N)); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 675 | return new (Mem) OMPReductionClause(N); |
| 676 | } |
| 677 | |
Alexey Bataev | 169d96a | 2017-07-18 20:17:46 +0000 | [diff] [blame] | 678 | void OMPTaskReductionClause::setPrivates(ArrayRef<Expr *> Privates) { |
| 679 | assert(Privates.size() == varlist_size() && |
| 680 | "Number of private copies is not the same as the preallocated buffer"); |
| 681 | std::copy(Privates.begin(), Privates.end(), varlist_end()); |
| 682 | } |
| 683 | |
| 684 | void OMPTaskReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) { |
| 685 | assert( |
| 686 | LHSExprs.size() == varlist_size() && |
| 687 | "Number of LHS expressions is not the same as the preallocated buffer"); |
| 688 | std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end()); |
| 689 | } |
| 690 | |
| 691 | void OMPTaskReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) { |
| 692 | assert( |
| 693 | RHSExprs.size() == varlist_size() && |
| 694 | "Number of RHS expressions is not the same as the preallocated buffer"); |
| 695 | std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end()); |
| 696 | } |
| 697 | |
| 698 | void OMPTaskReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) { |
| 699 | assert(ReductionOps.size() == varlist_size() && "Number of task reduction " |
| 700 | "expressions is not the same " |
| 701 | "as the preallocated buffer"); |
| 702 | std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end()); |
| 703 | } |
| 704 | |
| 705 | OMPTaskReductionClause *OMPTaskReductionClause::Create( |
| 706 | const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
| 707 | SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL, |
| 708 | NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, |
| 709 | ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs, |
| 710 | ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit, |
| 711 | Expr *PostUpdate) { |
| 712 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size())); |
| 713 | OMPTaskReductionClause *Clause = new (Mem) OMPTaskReductionClause( |
| 714 | StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo); |
| 715 | Clause->setVarRefs(VL); |
| 716 | Clause->setPrivates(Privates); |
| 717 | Clause->setLHSExprs(LHSExprs); |
| 718 | Clause->setRHSExprs(RHSExprs); |
| 719 | Clause->setReductionOps(ReductionOps); |
| 720 | Clause->setPreInitStmt(PreInit); |
| 721 | Clause->setPostUpdateExpr(PostUpdate); |
| 722 | return Clause; |
| 723 | } |
| 724 | |
| 725 | OMPTaskReductionClause *OMPTaskReductionClause::CreateEmpty(const ASTContext &C, |
| 726 | unsigned N) { |
| 727 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N)); |
| 728 | return new (Mem) OMPTaskReductionClause(N); |
| 729 | } |
| 730 | |
Alexey Bataev | fa312f3 | 2017-07-21 18:48:21 +0000 | [diff] [blame] | 731 | void OMPInReductionClause::setPrivates(ArrayRef<Expr *> Privates) { |
| 732 | assert(Privates.size() == varlist_size() && |
| 733 | "Number of private copies is not the same as the preallocated buffer"); |
| 734 | std::copy(Privates.begin(), Privates.end(), varlist_end()); |
| 735 | } |
| 736 | |
| 737 | void OMPInReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) { |
| 738 | assert( |
| 739 | LHSExprs.size() == varlist_size() && |
| 740 | "Number of LHS expressions is not the same as the preallocated buffer"); |
| 741 | std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end()); |
| 742 | } |
| 743 | |
| 744 | void OMPInReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) { |
| 745 | assert( |
| 746 | RHSExprs.size() == varlist_size() && |
| 747 | "Number of RHS expressions is not the same as the preallocated buffer"); |
| 748 | std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end()); |
| 749 | } |
| 750 | |
| 751 | void OMPInReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) { |
| 752 | assert(ReductionOps.size() == varlist_size() && "Number of in reduction " |
| 753 | "expressions is not the same " |
| 754 | "as the preallocated buffer"); |
| 755 | std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end()); |
| 756 | } |
| 757 | |
Alexey Bataev | 88202be | 2017-07-27 13:20:36 +0000 | [diff] [blame] | 758 | void OMPInReductionClause::setTaskgroupDescriptors( |
| 759 | ArrayRef<Expr *> TaskgroupDescriptors) { |
| 760 | assert(TaskgroupDescriptors.size() == varlist_size() && |
| 761 | "Number of in reduction descriptors is not the same as the " |
| 762 | "preallocated buffer"); |
| 763 | std::copy(TaskgroupDescriptors.begin(), TaskgroupDescriptors.end(), |
| 764 | getReductionOps().end()); |
| 765 | } |
| 766 | |
Alexey Bataev | fa312f3 | 2017-07-21 18:48:21 +0000 | [diff] [blame] | 767 | OMPInReductionClause *OMPInReductionClause::Create( |
| 768 | const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
| 769 | SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL, |
| 770 | NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, |
| 771 | ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs, |
Alexey Bataev | 88202be | 2017-07-27 13:20:36 +0000 | [diff] [blame] | 772 | ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, |
| 773 | ArrayRef<Expr *> TaskgroupDescriptors, Stmt *PreInit, Expr *PostUpdate) { |
| 774 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * VL.size())); |
Alexey Bataev | fa312f3 | 2017-07-21 18:48:21 +0000 | [diff] [blame] | 775 | OMPInReductionClause *Clause = new (Mem) OMPInReductionClause( |
| 776 | StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo); |
| 777 | Clause->setVarRefs(VL); |
| 778 | Clause->setPrivates(Privates); |
| 779 | Clause->setLHSExprs(LHSExprs); |
| 780 | Clause->setRHSExprs(RHSExprs); |
| 781 | Clause->setReductionOps(ReductionOps); |
Alexey Bataev | 88202be | 2017-07-27 13:20:36 +0000 | [diff] [blame] | 782 | Clause->setTaskgroupDescriptors(TaskgroupDescriptors); |
Alexey Bataev | fa312f3 | 2017-07-21 18:48:21 +0000 | [diff] [blame] | 783 | Clause->setPreInitStmt(PreInit); |
| 784 | Clause->setPostUpdateExpr(PostUpdate); |
| 785 | return Clause; |
| 786 | } |
| 787 | |
| 788 | OMPInReductionClause *OMPInReductionClause::CreateEmpty(const ASTContext &C, |
| 789 | unsigned N) { |
Alexey Bataev | 88202be | 2017-07-27 13:20:36 +0000 | [diff] [blame] | 790 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * N)); |
Alexey Bataev | fa312f3 | 2017-07-21 18:48:21 +0000 | [diff] [blame] | 791 | return new (Mem) OMPInReductionClause(N); |
| 792 | } |
| 793 | |
Alexey Bataev | e04483e | 2019-03-27 14:14:31 +0000 | [diff] [blame] | 794 | OMPAllocateClause * |
| 795 | OMPAllocateClause::Create(const ASTContext &C, SourceLocation StartLoc, |
| 796 | SourceLocation LParenLoc, Expr *Allocator, |
| 797 | SourceLocation ColonLoc, SourceLocation EndLoc, |
| 798 | ArrayRef<Expr *> VL) { |
| 799 | // Allocate space for private variables and initializer expressions. |
| 800 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size())); |
| 801 | auto *Clause = new (Mem) OMPAllocateClause(StartLoc, LParenLoc, Allocator, |
| 802 | ColonLoc, EndLoc, VL.size()); |
| 803 | Clause->setVarRefs(VL); |
| 804 | return Clause; |
| 805 | } |
| 806 | |
| 807 | OMPAllocateClause *OMPAllocateClause::CreateEmpty(const ASTContext &C, |
| 808 | unsigned N) { |
| 809 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N)); |
| 810 | return new (Mem) OMPAllocateClause(N); |
| 811 | } |
| 812 | |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 813 | OMPFlushClause *OMPFlushClause::Create(const ASTContext &C, |
| 814 | SourceLocation StartLoc, |
| 815 | SourceLocation LParenLoc, |
| 816 | SourceLocation EndLoc, |
| 817 | ArrayRef<Expr *> VL) { |
Alexey Bataev | 8b42706 | 2016-05-25 12:36:08 +0000 | [diff] [blame] | 818 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1)); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 819 | OMPFlushClause *Clause = |
| 820 | new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size()); |
| 821 | Clause->setVarRefs(VL); |
| 822 | return Clause; |
| 823 | } |
| 824 | |
| 825 | OMPFlushClause *OMPFlushClause::CreateEmpty(const ASTContext &C, unsigned N) { |
James Y Knight | 374fd20 | 2016-01-01 00:38:24 +0000 | [diff] [blame] | 826 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N)); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 827 | return new (Mem) OMPFlushClause(N); |
| 828 | } |
| 829 | |
Alexey Bataev | f138fda | 2018-08-13 19:04:24 +0000 | [diff] [blame] | 830 | OMPDependClause * |
| 831 | OMPDependClause::Create(const ASTContext &C, SourceLocation StartLoc, |
| 832 | SourceLocation LParenLoc, SourceLocation EndLoc, |
| 833 | OpenMPDependClauseKind DepKind, SourceLocation DepLoc, |
| 834 | SourceLocation ColonLoc, ArrayRef<Expr *> VL, |
| 835 | unsigned NumLoops) { |
| 836 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + NumLoops)); |
| 837 | OMPDependClause *Clause = new (Mem) |
| 838 | OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size(), NumLoops); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 839 | Clause->setVarRefs(VL); |
| 840 | Clause->setDependencyKind(DepKind); |
| 841 | Clause->setDependencyLoc(DepLoc); |
| 842 | Clause->setColonLoc(ColonLoc); |
Alexey Bataev | f138fda | 2018-08-13 19:04:24 +0000 | [diff] [blame] | 843 | for (unsigned I = 0 ; I < NumLoops; ++I) |
| 844 | Clause->setLoopData(I, nullptr); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 845 | return Clause; |
| 846 | } |
| 847 | |
Alexey Bataev | f138fda | 2018-08-13 19:04:24 +0000 | [diff] [blame] | 848 | OMPDependClause *OMPDependClause::CreateEmpty(const ASTContext &C, unsigned N, |
| 849 | unsigned NumLoops) { |
| 850 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N + NumLoops)); |
| 851 | return new (Mem) OMPDependClause(N, NumLoops); |
James Y Knight | b8bfd96 | 2015-10-02 13:41:04 +0000 | [diff] [blame] | 852 | } |
Kelvin Li | 0bff7af | 2015-11-23 05:32:03 +0000 | [diff] [blame] | 853 | |
Alexey Bataev | f138fda | 2018-08-13 19:04:24 +0000 | [diff] [blame] | 854 | void OMPDependClause::setLoopData(unsigned NumLoop, Expr *Cnt) { |
| 855 | assert((getDependencyKind() == OMPC_DEPEND_sink || |
| 856 | getDependencyKind() == OMPC_DEPEND_source) && |
| 857 | NumLoop < NumLoops && |
| 858 | "Expected sink or source depend + loop index must be less number of " |
| 859 | "loops."); |
| 860 | auto It = std::next(getVarRefs().end(), NumLoop); |
| 861 | *It = Cnt; |
Alexey Bataev | 8b42706 | 2016-05-25 12:36:08 +0000 | [diff] [blame] | 862 | } |
| 863 | |
Alexey Bataev | f138fda | 2018-08-13 19:04:24 +0000 | [diff] [blame] | 864 | Expr *OMPDependClause::getLoopData(unsigned NumLoop) { |
| 865 | assert((getDependencyKind() == OMPC_DEPEND_sink || |
| 866 | getDependencyKind() == OMPC_DEPEND_source) && |
| 867 | NumLoop < NumLoops && |
| 868 | "Expected sink or source depend + loop index must be less number of " |
| 869 | "loops."); |
| 870 | auto It = std::next(getVarRefs().end(), NumLoop); |
| 871 | return *It; |
Alexey Bataev | 8b42706 | 2016-05-25 12:36:08 +0000 | [diff] [blame] | 872 | } |
| 873 | |
Alexey Bataev | f138fda | 2018-08-13 19:04:24 +0000 | [diff] [blame] | 874 | const Expr *OMPDependClause::getLoopData(unsigned NumLoop) const { |
| 875 | assert((getDependencyKind() == OMPC_DEPEND_sink || |
| 876 | getDependencyKind() == OMPC_DEPEND_source) && |
| 877 | NumLoop < NumLoops && |
| 878 | "Expected sink or source depend + loop index must be less number of " |
| 879 | "loops."); |
| 880 | auto It = std::next(getVarRefs().end(), NumLoop); |
| 881 | return *It; |
Alexey Bataev | 8b42706 | 2016-05-25 12:36:08 +0000 | [diff] [blame] | 882 | } |
| 883 | |
Samuel Antao | 9092700 | 2016-04-26 14:54:23 +0000 | [diff] [blame] | 884 | unsigned OMPClauseMappableExprCommon::getComponentsTotalNumber( |
| 885 | MappableExprComponentListsRef ComponentLists) { |
| 886 | unsigned TotalNum = 0u; |
| 887 | for (auto &C : ComponentLists) |
| 888 | TotalNum += C.size(); |
| 889 | return TotalNum; |
| 890 | } |
| 891 | |
| 892 | unsigned OMPClauseMappableExprCommon::getUniqueDeclarationsTotalNumber( |
Alexey Bataev | e372710 | 2018-04-18 15:57:46 +0000 | [diff] [blame] | 893 | ArrayRef<const ValueDecl *> Declarations) { |
Samuel Antao | 9092700 | 2016-04-26 14:54:23 +0000 | [diff] [blame] | 894 | unsigned TotalNum = 0u; |
| 895 | llvm::SmallPtrSet<const ValueDecl *, 8> Cache; |
Alexey Bataev | e372710 | 2018-04-18 15:57:46 +0000 | [diff] [blame] | 896 | for (const ValueDecl *D : Declarations) { |
Samuel Antao | 9092700 | 2016-04-26 14:54:23 +0000 | [diff] [blame] | 897 | const ValueDecl *VD = D ? cast<ValueDecl>(D->getCanonicalDecl()) : nullptr; |
| 898 | if (Cache.count(VD)) |
| 899 | continue; |
| 900 | ++TotalNum; |
| 901 | Cache.insert(VD); |
| 902 | } |
| 903 | return TotalNum; |
| 904 | } |
| 905 | |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 906 | OMPMapClause *OMPMapClause::Create( |
| 907 | const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars, |
| 908 | ArrayRef<ValueDecl *> Declarations, |
| 909 | MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs, |
| 910 | ArrayRef<OpenMPMapModifierKind> MapModifiers, |
| 911 | ArrayRef<SourceLocation> MapModifiersLoc, |
| 912 | NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId, |
| 913 | OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc) { |
| 914 | OMPMappableExprListSizeTy Sizes; |
| 915 | Sizes.NumVars = Vars.size(); |
| 916 | Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations); |
| 917 | Sizes.NumComponentLists = ComponentLists.size(); |
| 918 | Sizes.NumComponents = getComponentsTotalNumber(ComponentLists); |
Samuel Antao | 9092700 | 2016-04-26 14:54:23 +0000 | [diff] [blame] | 919 | |
| 920 | // We need to allocate: |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 921 | // 2 x NumVars x Expr* - we have an original list expression and an associated |
| 922 | // user-defined mapper for each clause list entry. |
Samuel Antao | 9092700 | 2016-04-26 14:54:23 +0000 | [diff] [blame] | 923 | // NumUniqueDeclarations x ValueDecl* - unique base declarations associated |
| 924 | // with each component list. |
| 925 | // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the |
| 926 | // number of lists for each unique declaration and the size of each component |
| 927 | // list. |
| 928 | // NumComponents x MappableComponent - the total of all the components in all |
| 929 | // the lists. |
| 930 | void *Mem = C.Allocate( |
| 931 | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
| 932 | OMPClauseMappableExprCommon::MappableComponent>( |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 933 | 2 * Sizes.NumVars, Sizes.NumUniqueDeclarations, |
| 934 | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
| 935 | Sizes.NumComponents)); |
| 936 | OMPMapClause *Clause = new (Mem) |
| 937 | OMPMapClause(MapModifiers, MapModifiersLoc, UDMQualifierLoc, MapperId, |
| 938 | Type, TypeIsImplicit, TypeLoc, Locs, Sizes); |
Samuel Antao | 9092700 | 2016-04-26 14:54:23 +0000 | [diff] [blame] | 939 | |
| 940 | Clause->setVarRefs(Vars); |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 941 | Clause->setUDMapperRefs(UDMapperRefs); |
Samuel Antao | 9092700 | 2016-04-26 14:54:23 +0000 | [diff] [blame] | 942 | Clause->setClauseInfo(Declarations, ComponentLists); |
Kelvin Li | 0bff7af | 2015-11-23 05:32:03 +0000 | [diff] [blame] | 943 | Clause->setMapType(Type); |
| 944 | Clause->setMapLoc(TypeLoc); |
| 945 | return Clause; |
| 946 | } |
| 947 | |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 948 | OMPMapClause * |
| 949 | OMPMapClause::CreateEmpty(const ASTContext &C, |
| 950 | const OMPMappableExprListSizeTy &Sizes) { |
Samuel Antao | 9092700 | 2016-04-26 14:54:23 +0000 | [diff] [blame] | 951 | void *Mem = C.Allocate( |
| 952 | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
| 953 | OMPClauseMappableExprCommon::MappableComponent>( |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 954 | 2 * Sizes.NumVars, Sizes.NumUniqueDeclarations, |
| 955 | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
| 956 | Sizes.NumComponents)); |
| 957 | return new (Mem) OMPMapClause(Sizes); |
Kelvin Li | 0bff7af | 2015-11-23 05:32:03 +0000 | [diff] [blame] | 958 | } |
Samuel Antao | 661c090 | 2016-05-26 17:39:58 +0000 | [diff] [blame] | 959 | |
Michael Kruse | 01f670d | 2019-02-22 22:29:42 +0000 | [diff] [blame] | 960 | OMPToClause *OMPToClause::Create( |
| 961 | const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars, |
| 962 | ArrayRef<ValueDecl *> Declarations, |
| 963 | MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs, |
| 964 | NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId) { |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 965 | OMPMappableExprListSizeTy Sizes; |
| 966 | Sizes.NumVars = Vars.size(); |
| 967 | Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations); |
| 968 | Sizes.NumComponentLists = ComponentLists.size(); |
| 969 | Sizes.NumComponents = getComponentsTotalNumber(ComponentLists); |
Samuel Antao | 661c090 | 2016-05-26 17:39:58 +0000 | [diff] [blame] | 970 | |
| 971 | // We need to allocate: |
Michael Kruse | 01f670d | 2019-02-22 22:29:42 +0000 | [diff] [blame] | 972 | // 2 x NumVars x Expr* - we have an original list expression and an associated |
| 973 | // user-defined mapper for each clause list entry. |
Samuel Antao | 661c090 | 2016-05-26 17:39:58 +0000 | [diff] [blame] | 974 | // NumUniqueDeclarations x ValueDecl* - unique base declarations associated |
| 975 | // with each component list. |
| 976 | // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the |
| 977 | // number of lists for each unique declaration and the size of each component |
| 978 | // list. |
| 979 | // NumComponents x MappableComponent - the total of all the components in all |
| 980 | // the lists. |
| 981 | void *Mem = C.Allocate( |
| 982 | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
| 983 | OMPClauseMappableExprCommon::MappableComponent>( |
Michael Kruse | 01f670d | 2019-02-22 22:29:42 +0000 | [diff] [blame] | 984 | 2 * Sizes.NumVars, Sizes.NumUniqueDeclarations, |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 985 | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
| 986 | Sizes.NumComponents)); |
Samuel Antao | 661c090 | 2016-05-26 17:39:58 +0000 | [diff] [blame] | 987 | |
Michael Kruse | 01f670d | 2019-02-22 22:29:42 +0000 | [diff] [blame] | 988 | auto *Clause = new (Mem) OMPToClause(UDMQualifierLoc, MapperId, Locs, Sizes); |
Samuel Antao | 661c090 | 2016-05-26 17:39:58 +0000 | [diff] [blame] | 989 | |
| 990 | Clause->setVarRefs(Vars); |
Michael Kruse | 01f670d | 2019-02-22 22:29:42 +0000 | [diff] [blame] | 991 | Clause->setUDMapperRefs(UDMapperRefs); |
Samuel Antao | 661c090 | 2016-05-26 17:39:58 +0000 | [diff] [blame] | 992 | Clause->setClauseInfo(Declarations, ComponentLists); |
| 993 | return Clause; |
| 994 | } |
| 995 | |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 996 | OMPToClause *OMPToClause::CreateEmpty(const ASTContext &C, |
| 997 | const OMPMappableExprListSizeTy &Sizes) { |
Samuel Antao | 661c090 | 2016-05-26 17:39:58 +0000 | [diff] [blame] | 998 | void *Mem = C.Allocate( |
| 999 | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
| 1000 | OMPClauseMappableExprCommon::MappableComponent>( |
Michael Kruse | 01f670d | 2019-02-22 22:29:42 +0000 | [diff] [blame] | 1001 | 2 * Sizes.NumVars, Sizes.NumUniqueDeclarations, |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 1002 | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
| 1003 | Sizes.NumComponents)); |
| 1004 | return new (Mem) OMPToClause(Sizes); |
Samuel Antao | 661c090 | 2016-05-26 17:39:58 +0000 | [diff] [blame] | 1005 | } |
Samuel Antao | ec172c6 | 2016-05-26 17:49:04 +0000 | [diff] [blame] | 1006 | |
Michael Kruse | 0336c75 | 2019-02-25 20:34:15 +0000 | [diff] [blame] | 1007 | OMPFromClause *OMPFromClause::Create( |
| 1008 | const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars, |
| 1009 | ArrayRef<ValueDecl *> Declarations, |
| 1010 | MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs, |
| 1011 | NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId) { |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 1012 | OMPMappableExprListSizeTy Sizes; |
| 1013 | Sizes.NumVars = Vars.size(); |
| 1014 | Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations); |
| 1015 | Sizes.NumComponentLists = ComponentLists.size(); |
| 1016 | Sizes.NumComponents = getComponentsTotalNumber(ComponentLists); |
Samuel Antao | ec172c6 | 2016-05-26 17:49:04 +0000 | [diff] [blame] | 1017 | |
| 1018 | // We need to allocate: |
Michael Kruse | 0336c75 | 2019-02-25 20:34:15 +0000 | [diff] [blame] | 1019 | // 2 x NumVars x Expr* - we have an original list expression and an associated |
| 1020 | // user-defined mapper for each clause list entry. |
Samuel Antao | ec172c6 | 2016-05-26 17:49:04 +0000 | [diff] [blame] | 1021 | // NumUniqueDeclarations x ValueDecl* - unique base declarations associated |
| 1022 | // with each component list. |
| 1023 | // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the |
| 1024 | // number of lists for each unique declaration and the size of each component |
| 1025 | // list. |
| 1026 | // NumComponents x MappableComponent - the total of all the components in all |
| 1027 | // the lists. |
| 1028 | void *Mem = C.Allocate( |
| 1029 | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
| 1030 | OMPClauseMappableExprCommon::MappableComponent>( |
Michael Kruse | 0336c75 | 2019-02-25 20:34:15 +0000 | [diff] [blame] | 1031 | 2 * Sizes.NumVars, Sizes.NumUniqueDeclarations, |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 1032 | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
| 1033 | Sizes.NumComponents)); |
Samuel Antao | ec172c6 | 2016-05-26 17:49:04 +0000 | [diff] [blame] | 1034 | |
Michael Kruse | 0336c75 | 2019-02-25 20:34:15 +0000 | [diff] [blame] | 1035 | auto *Clause = |
| 1036 | new (Mem) OMPFromClause(UDMQualifierLoc, MapperId, Locs, Sizes); |
Samuel Antao | ec172c6 | 2016-05-26 17:49:04 +0000 | [diff] [blame] | 1037 | |
| 1038 | Clause->setVarRefs(Vars); |
Michael Kruse | 0336c75 | 2019-02-25 20:34:15 +0000 | [diff] [blame] | 1039 | Clause->setUDMapperRefs(UDMapperRefs); |
Samuel Antao | ec172c6 | 2016-05-26 17:49:04 +0000 | [diff] [blame] | 1040 | Clause->setClauseInfo(Declarations, ComponentLists); |
| 1041 | return Clause; |
| 1042 | } |
| 1043 | |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 1044 | OMPFromClause * |
| 1045 | OMPFromClause::CreateEmpty(const ASTContext &C, |
| 1046 | const OMPMappableExprListSizeTy &Sizes) { |
Samuel Antao | ec172c6 | 2016-05-26 17:49:04 +0000 | [diff] [blame] | 1047 | void *Mem = C.Allocate( |
| 1048 | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
| 1049 | OMPClauseMappableExprCommon::MappableComponent>( |
Michael Kruse | 0336c75 | 2019-02-25 20:34:15 +0000 | [diff] [blame] | 1050 | 2 * Sizes.NumVars, Sizes.NumUniqueDeclarations, |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 1051 | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
| 1052 | Sizes.NumComponents)); |
| 1053 | return new (Mem) OMPFromClause(Sizes); |
Samuel Antao | ec172c6 | 2016-05-26 17:49:04 +0000 | [diff] [blame] | 1054 | } |
Carlo Bertolli | 2404b17 | 2016-07-13 15:37:16 +0000 | [diff] [blame] | 1055 | |
Samuel Antao | cc10b85 | 2016-07-28 14:23:26 +0000 | [diff] [blame] | 1056 | void OMPUseDevicePtrClause::setPrivateCopies(ArrayRef<Expr *> VL) { |
| 1057 | assert(VL.size() == varlist_size() && |
| 1058 | "Number of private copies is not the same as the preallocated buffer"); |
| 1059 | std::copy(VL.begin(), VL.end(), varlist_end()); |
| 1060 | } |
| 1061 | |
| 1062 | void OMPUseDevicePtrClause::setInits(ArrayRef<Expr *> VL) { |
| 1063 | assert(VL.size() == varlist_size() && |
| 1064 | "Number of inits is not the same as the preallocated buffer"); |
| 1065 | std::copy(VL.begin(), VL.end(), getPrivateCopies().end()); |
| 1066 | } |
| 1067 | |
| 1068 | OMPUseDevicePtrClause *OMPUseDevicePtrClause::Create( |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 1069 | const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars, |
| 1070 | ArrayRef<Expr *> PrivateVars, ArrayRef<Expr *> Inits, |
| 1071 | ArrayRef<ValueDecl *> Declarations, |
Samuel Antao | cc10b85 | 2016-07-28 14:23:26 +0000 | [diff] [blame] | 1072 | MappableExprComponentListsRef ComponentLists) { |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 1073 | OMPMappableExprListSizeTy Sizes; |
| 1074 | Sizes.NumVars = Vars.size(); |
| 1075 | Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations); |
| 1076 | Sizes.NumComponentLists = ComponentLists.size(); |
| 1077 | Sizes.NumComponents = getComponentsTotalNumber(ComponentLists); |
Samuel Antao | cc10b85 | 2016-07-28 14:23:26 +0000 | [diff] [blame] | 1078 | |
| 1079 | // We need to allocate: |
| 1080 | // 3 x NumVars x Expr* - we have an original list expression for each clause |
| 1081 | // list entry and an equal number of private copies and inits. |
| 1082 | // NumUniqueDeclarations x ValueDecl* - unique base declarations associated |
| 1083 | // with each component list. |
| 1084 | // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the |
| 1085 | // number of lists for each unique declaration and the size of each component |
| 1086 | // list. |
| 1087 | // NumComponents x MappableComponent - the total of all the components in all |
| 1088 | // the lists. |
| 1089 | void *Mem = C.Allocate( |
| 1090 | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
| 1091 | OMPClauseMappableExprCommon::MappableComponent>( |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 1092 | 3 * Sizes.NumVars, Sizes.NumUniqueDeclarations, |
| 1093 | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
| 1094 | Sizes.NumComponents)); |
Samuel Antao | cc10b85 | 2016-07-28 14:23:26 +0000 | [diff] [blame] | 1095 | |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 1096 | OMPUseDevicePtrClause *Clause = new (Mem) OMPUseDevicePtrClause(Locs, Sizes); |
Samuel Antao | cc10b85 | 2016-07-28 14:23:26 +0000 | [diff] [blame] | 1097 | |
| 1098 | Clause->setVarRefs(Vars); |
| 1099 | Clause->setPrivateCopies(PrivateVars); |
| 1100 | Clause->setInits(Inits); |
| 1101 | Clause->setClauseInfo(Declarations, ComponentLists); |
Carlo Bertolli | 2404b17 | 2016-07-13 15:37:16 +0000 | [diff] [blame] | 1102 | return Clause; |
| 1103 | } |
| 1104 | |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 1105 | OMPUseDevicePtrClause * |
| 1106 | OMPUseDevicePtrClause::CreateEmpty(const ASTContext &C, |
| 1107 | const OMPMappableExprListSizeTy &Sizes) { |
Samuel Antao | cc10b85 | 2016-07-28 14:23:26 +0000 | [diff] [blame] | 1108 | void *Mem = C.Allocate( |
| 1109 | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
| 1110 | OMPClauseMappableExprCommon::MappableComponent>( |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 1111 | 3 * Sizes.NumVars, Sizes.NumUniqueDeclarations, |
| 1112 | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
| 1113 | Sizes.NumComponents)); |
| 1114 | return new (Mem) OMPUseDevicePtrClause(Sizes); |
Carlo Bertolli | 2404b17 | 2016-07-13 15:37:16 +0000 | [diff] [blame] | 1115 | } |
Carlo Bertolli | 70594e9 | 2016-07-13 17:16:49 +0000 | [diff] [blame] | 1116 | |
Samuel Antao | 6890b09 | 2016-07-28 14:25:09 +0000 | [diff] [blame] | 1117 | OMPIsDevicePtrClause * |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 1118 | OMPIsDevicePtrClause::Create(const ASTContext &C, const OMPVarListLocTy &Locs, |
Samuel Antao | 6890b09 | 2016-07-28 14:25:09 +0000 | [diff] [blame] | 1119 | ArrayRef<Expr *> Vars, |
| 1120 | ArrayRef<ValueDecl *> Declarations, |
| 1121 | MappableExprComponentListsRef ComponentLists) { |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 1122 | OMPMappableExprListSizeTy Sizes; |
| 1123 | Sizes.NumVars = Vars.size(); |
| 1124 | Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations); |
| 1125 | Sizes.NumComponentLists = ComponentLists.size(); |
| 1126 | Sizes.NumComponents = getComponentsTotalNumber(ComponentLists); |
Samuel Antao | 6890b09 | 2016-07-28 14:25:09 +0000 | [diff] [blame] | 1127 | |
| 1128 | // We need to allocate: |
| 1129 | // NumVars x Expr* - we have an original list expression for each clause list |
| 1130 | // entry. |
| 1131 | // NumUniqueDeclarations x ValueDecl* - unique base declarations associated |
| 1132 | // with each component list. |
| 1133 | // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the |
| 1134 | // number of lists for each unique declaration and the size of each component |
| 1135 | // list. |
| 1136 | // NumComponents x MappableComponent - the total of all the components in all |
| 1137 | // the lists. |
| 1138 | void *Mem = C.Allocate( |
| 1139 | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
| 1140 | OMPClauseMappableExprCommon::MappableComponent>( |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 1141 | Sizes.NumVars, Sizes.NumUniqueDeclarations, |
| 1142 | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
| 1143 | Sizes.NumComponents)); |
Samuel Antao | 6890b09 | 2016-07-28 14:25:09 +0000 | [diff] [blame] | 1144 | |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 1145 | OMPIsDevicePtrClause *Clause = new (Mem) OMPIsDevicePtrClause(Locs, Sizes); |
Samuel Antao | 6890b09 | 2016-07-28 14:25:09 +0000 | [diff] [blame] | 1146 | |
| 1147 | Clause->setVarRefs(Vars); |
| 1148 | Clause->setClauseInfo(Declarations, ComponentLists); |
Carlo Bertolli | 70594e9 | 2016-07-13 17:16:49 +0000 | [diff] [blame] | 1149 | return Clause; |
| 1150 | } |
| 1151 | |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 1152 | OMPIsDevicePtrClause * |
| 1153 | OMPIsDevicePtrClause::CreateEmpty(const ASTContext &C, |
| 1154 | const OMPMappableExprListSizeTy &Sizes) { |
Samuel Antao | 6890b09 | 2016-07-28 14:25:09 +0000 | [diff] [blame] | 1155 | void *Mem = C.Allocate( |
| 1156 | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
| 1157 | OMPClauseMappableExprCommon::MappableComponent>( |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 1158 | Sizes.NumVars, Sizes.NumUniqueDeclarations, |
| 1159 | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
| 1160 | Sizes.NumComponents)); |
| 1161 | return new (Mem) OMPIsDevicePtrClause(Sizes); |
Carlo Bertolli | 70594e9 | 2016-07-13 17:16:49 +0000 | [diff] [blame] | 1162 | } |
Patrick Lyster | 074c3ae2 | 2018-10-18 14:28:23 +0000 | [diff] [blame] | 1163 | |
Alexey Bataev | b6e7084 | 2019-12-16 15:54:17 -0500 | [diff] [blame] | 1164 | OMPNontemporalClause *OMPNontemporalClause::Create(const ASTContext &C, |
| 1165 | SourceLocation StartLoc, |
| 1166 | SourceLocation LParenLoc, |
| 1167 | SourceLocation EndLoc, |
| 1168 | ArrayRef<Expr *> VL) { |
Alexey Bataev | 0860db9 | 2019-12-19 10:01:10 -0500 | [diff] [blame] | 1169 | // Allocate space for nontemporal variables + private references. |
| 1170 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size())); |
Alexey Bataev | b6e7084 | 2019-12-16 15:54:17 -0500 | [diff] [blame] | 1171 | auto *Clause = |
| 1172 | new (Mem) OMPNontemporalClause(StartLoc, LParenLoc, EndLoc, VL.size()); |
| 1173 | Clause->setVarRefs(VL); |
| 1174 | return Clause; |
| 1175 | } |
| 1176 | |
| 1177 | OMPNontemporalClause *OMPNontemporalClause::CreateEmpty(const ASTContext &C, |
| 1178 | unsigned N) { |
Alexey Bataev | 0860db9 | 2019-12-19 10:01:10 -0500 | [diff] [blame] | 1179 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N)); |
Alexey Bataev | b6e7084 | 2019-12-16 15:54:17 -0500 | [diff] [blame] | 1180 | return new (Mem) OMPNontemporalClause(N); |
| 1181 | } |
| 1182 | |
Alexey Bataev | 0860db9 | 2019-12-19 10:01:10 -0500 | [diff] [blame] | 1183 | void OMPNontemporalClause::setPrivateRefs(ArrayRef<Expr *> VL) { |
| 1184 | assert(VL.size() == varlist_size() && "Number of private references is not " |
| 1185 | "the same as the preallocated buffer"); |
| 1186 | std::copy(VL.begin(), VL.end(), varlist_end()); |
| 1187 | } |
| 1188 | |
Patrick Lyster | 074c3ae2 | 2018-10-18 14:28:23 +0000 | [diff] [blame] | 1189 | //===----------------------------------------------------------------------===// |
| 1190 | // OpenMP clauses printing methods |
| 1191 | //===----------------------------------------------------------------------===// |
| 1192 | |
| 1193 | void OMPClausePrinter::VisitOMPIfClause(OMPIfClause *Node) { |
| 1194 | OS << "if("; |
Johannes Doerfert | eb3e81f | 2019-11-04 22:00:49 -0600 | [diff] [blame] | 1195 | if (Node->getNameModifier() != llvm::omp::OMPD_unknown) |
Patrick Lyster | 074c3ae2 | 2018-10-18 14:28:23 +0000 | [diff] [blame] | 1196 | OS << getOpenMPDirectiveName(Node->getNameModifier()) << ": "; |
| 1197 | Node->getCondition()->printPretty(OS, nullptr, Policy, 0); |
| 1198 | OS << ")"; |
| 1199 | } |
| 1200 | |
| 1201 | void OMPClausePrinter::VisitOMPFinalClause(OMPFinalClause *Node) { |
| 1202 | OS << "final("; |
| 1203 | Node->getCondition()->printPretty(OS, nullptr, Policy, 0); |
| 1204 | OS << ")"; |
| 1205 | } |
| 1206 | |
| 1207 | void OMPClausePrinter::VisitOMPNumThreadsClause(OMPNumThreadsClause *Node) { |
| 1208 | OS << "num_threads("; |
| 1209 | Node->getNumThreads()->printPretty(OS, nullptr, Policy, 0); |
| 1210 | OS << ")"; |
| 1211 | } |
| 1212 | |
| 1213 | void OMPClausePrinter::VisitOMPSafelenClause(OMPSafelenClause *Node) { |
| 1214 | OS << "safelen("; |
| 1215 | Node->getSafelen()->printPretty(OS, nullptr, Policy, 0); |
| 1216 | OS << ")"; |
| 1217 | } |
| 1218 | |
| 1219 | void OMPClausePrinter::VisitOMPSimdlenClause(OMPSimdlenClause *Node) { |
| 1220 | OS << "simdlen("; |
| 1221 | Node->getSimdlen()->printPretty(OS, nullptr, Policy, 0); |
| 1222 | OS << ")"; |
| 1223 | } |
| 1224 | |
Alexey Bataev | 9cc10fc | 2019-03-12 18:52:33 +0000 | [diff] [blame] | 1225 | void OMPClausePrinter::VisitOMPAllocatorClause(OMPAllocatorClause *Node) { |
| 1226 | OS << "allocator("; |
| 1227 | Node->getAllocator()->printPretty(OS, nullptr, Policy, 0); |
| 1228 | OS << ")"; |
| 1229 | } |
| 1230 | |
Patrick Lyster | 074c3ae2 | 2018-10-18 14:28:23 +0000 | [diff] [blame] | 1231 | void OMPClausePrinter::VisitOMPCollapseClause(OMPCollapseClause *Node) { |
| 1232 | OS << "collapse("; |
| 1233 | Node->getNumForLoops()->printPretty(OS, nullptr, Policy, 0); |
| 1234 | OS << ")"; |
| 1235 | } |
| 1236 | |
| 1237 | void OMPClausePrinter::VisitOMPDefaultClause(OMPDefaultClause *Node) { |
| 1238 | OS << "default(" |
| 1239 | << getOpenMPSimpleClauseTypeName(OMPC_default, Node->getDefaultKind()) |
| 1240 | << ")"; |
| 1241 | } |
| 1242 | |
| 1243 | void OMPClausePrinter::VisitOMPProcBindClause(OMPProcBindClause *Node) { |
| 1244 | OS << "proc_bind(" |
Johannes Doerfert | 6c5d1f40 | 2019-12-25 18:15:36 -0600 | [diff] [blame] | 1245 | << getOpenMPSimpleClauseTypeName(OMPC_proc_bind, |
| 1246 | unsigned(Node->getProcBindKind())) |
Patrick Lyster | 074c3ae2 | 2018-10-18 14:28:23 +0000 | [diff] [blame] | 1247 | << ")"; |
| 1248 | } |
| 1249 | |
| 1250 | void OMPClausePrinter::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) { |
| 1251 | OS << "unified_address"; |
| 1252 | } |
| 1253 | |
| 1254 | void OMPClausePrinter::VisitOMPUnifiedSharedMemoryClause( |
| 1255 | OMPUnifiedSharedMemoryClause *) { |
| 1256 | OS << "unified_shared_memory"; |
| 1257 | } |
| 1258 | |
| 1259 | void OMPClausePrinter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) { |
| 1260 | OS << "reverse_offload"; |
| 1261 | } |
| 1262 | |
| 1263 | void OMPClausePrinter::VisitOMPDynamicAllocatorsClause( |
| 1264 | OMPDynamicAllocatorsClause *) { |
| 1265 | OS << "dynamic_allocators"; |
| 1266 | } |
| 1267 | |
Patrick Lyster | 7a2a27c | 2018-11-02 12:18:11 +0000 | [diff] [blame] | 1268 | void OMPClausePrinter::VisitOMPAtomicDefaultMemOrderClause( |
| 1269 | OMPAtomicDefaultMemOrderClause *Node) { |
| 1270 | OS << "atomic_default_mem_order(" |
| 1271 | << getOpenMPSimpleClauseTypeName(OMPC_atomic_default_mem_order, |
| 1272 | Node->getAtomicDefaultMemOrderKind()) |
| 1273 | << ")"; |
| 1274 | } |
| 1275 | |
Patrick Lyster | 074c3ae2 | 2018-10-18 14:28:23 +0000 | [diff] [blame] | 1276 | void OMPClausePrinter::VisitOMPScheduleClause(OMPScheduleClause *Node) { |
| 1277 | OS << "schedule("; |
| 1278 | if (Node->getFirstScheduleModifier() != OMPC_SCHEDULE_MODIFIER_unknown) { |
| 1279 | OS << getOpenMPSimpleClauseTypeName(OMPC_schedule, |
| 1280 | Node->getFirstScheduleModifier()); |
| 1281 | if (Node->getSecondScheduleModifier() != OMPC_SCHEDULE_MODIFIER_unknown) { |
| 1282 | OS << ", "; |
| 1283 | OS << getOpenMPSimpleClauseTypeName(OMPC_schedule, |
| 1284 | Node->getSecondScheduleModifier()); |
| 1285 | } |
| 1286 | OS << ": "; |
| 1287 | } |
| 1288 | OS << getOpenMPSimpleClauseTypeName(OMPC_schedule, Node->getScheduleKind()); |
| 1289 | if (auto *E = Node->getChunkSize()) { |
| 1290 | OS << ", "; |
| 1291 | E->printPretty(OS, nullptr, Policy); |
| 1292 | } |
| 1293 | OS << ")"; |
| 1294 | } |
| 1295 | |
| 1296 | void OMPClausePrinter::VisitOMPOrderedClause(OMPOrderedClause *Node) { |
| 1297 | OS << "ordered"; |
| 1298 | if (auto *Num = Node->getNumForLoops()) { |
| 1299 | OS << "("; |
| 1300 | Num->printPretty(OS, nullptr, Policy, 0); |
| 1301 | OS << ")"; |
| 1302 | } |
| 1303 | } |
| 1304 | |
| 1305 | void OMPClausePrinter::VisitOMPNowaitClause(OMPNowaitClause *) { |
| 1306 | OS << "nowait"; |
| 1307 | } |
| 1308 | |
| 1309 | void OMPClausePrinter::VisitOMPUntiedClause(OMPUntiedClause *) { |
| 1310 | OS << "untied"; |
| 1311 | } |
| 1312 | |
| 1313 | void OMPClausePrinter::VisitOMPNogroupClause(OMPNogroupClause *) { |
| 1314 | OS << "nogroup"; |
| 1315 | } |
| 1316 | |
| 1317 | void OMPClausePrinter::VisitOMPMergeableClause(OMPMergeableClause *) { |
| 1318 | OS << "mergeable"; |
| 1319 | } |
| 1320 | |
| 1321 | void OMPClausePrinter::VisitOMPReadClause(OMPReadClause *) { OS << "read"; } |
| 1322 | |
| 1323 | void OMPClausePrinter::VisitOMPWriteClause(OMPWriteClause *) { OS << "write"; } |
| 1324 | |
| 1325 | void OMPClausePrinter::VisitOMPUpdateClause(OMPUpdateClause *) { |
| 1326 | OS << "update"; |
| 1327 | } |
| 1328 | |
| 1329 | void OMPClausePrinter::VisitOMPCaptureClause(OMPCaptureClause *) { |
| 1330 | OS << "capture"; |
| 1331 | } |
| 1332 | |
| 1333 | void OMPClausePrinter::VisitOMPSeqCstClause(OMPSeqCstClause *) { |
| 1334 | OS << "seq_cst"; |
| 1335 | } |
| 1336 | |
| 1337 | void OMPClausePrinter::VisitOMPThreadsClause(OMPThreadsClause *) { |
| 1338 | OS << "threads"; |
| 1339 | } |
| 1340 | |
| 1341 | void OMPClausePrinter::VisitOMPSIMDClause(OMPSIMDClause *) { OS << "simd"; } |
| 1342 | |
| 1343 | void OMPClausePrinter::VisitOMPDeviceClause(OMPDeviceClause *Node) { |
| 1344 | OS << "device("; |
| 1345 | Node->getDevice()->printPretty(OS, nullptr, Policy, 0); |
| 1346 | OS << ")"; |
| 1347 | } |
| 1348 | |
| 1349 | void OMPClausePrinter::VisitOMPNumTeamsClause(OMPNumTeamsClause *Node) { |
| 1350 | OS << "num_teams("; |
| 1351 | Node->getNumTeams()->printPretty(OS, nullptr, Policy, 0); |
| 1352 | OS << ")"; |
| 1353 | } |
| 1354 | |
| 1355 | void OMPClausePrinter::VisitOMPThreadLimitClause(OMPThreadLimitClause *Node) { |
| 1356 | OS << "thread_limit("; |
| 1357 | Node->getThreadLimit()->printPretty(OS, nullptr, Policy, 0); |
| 1358 | OS << ")"; |
| 1359 | } |
| 1360 | |
| 1361 | void OMPClausePrinter::VisitOMPPriorityClause(OMPPriorityClause *Node) { |
| 1362 | OS << "priority("; |
| 1363 | Node->getPriority()->printPretty(OS, nullptr, Policy, 0); |
| 1364 | OS << ")"; |
| 1365 | } |
| 1366 | |
| 1367 | void OMPClausePrinter::VisitOMPGrainsizeClause(OMPGrainsizeClause *Node) { |
| 1368 | OS << "grainsize("; |
| 1369 | Node->getGrainsize()->printPretty(OS, nullptr, Policy, 0); |
| 1370 | OS << ")"; |
| 1371 | } |
| 1372 | |
| 1373 | void OMPClausePrinter::VisitOMPNumTasksClause(OMPNumTasksClause *Node) { |
| 1374 | OS << "num_tasks("; |
| 1375 | Node->getNumTasks()->printPretty(OS, nullptr, Policy, 0); |
| 1376 | OS << ")"; |
| 1377 | } |
| 1378 | |
| 1379 | void OMPClausePrinter::VisitOMPHintClause(OMPHintClause *Node) { |
| 1380 | OS << "hint("; |
| 1381 | Node->getHint()->printPretty(OS, nullptr, Policy, 0); |
| 1382 | OS << ")"; |
| 1383 | } |
| 1384 | |
| 1385 | template<typename T> |
| 1386 | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { |
| 1387 | for (typename T::varlist_iterator I = Node->varlist_begin(), |
| 1388 | E = Node->varlist_end(); |
| 1389 | I != E; ++I) { |
| 1390 | assert(*I && "Expected non-null Stmt"); |
| 1391 | OS << (I == Node->varlist_begin() ? StartSym : ','); |
| 1392 | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { |
| 1393 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) |
| 1394 | DRE->printPretty(OS, nullptr, Policy, 0); |
| 1395 | else |
| 1396 | DRE->getDecl()->printQualifiedName(OS); |
| 1397 | } else |
| 1398 | (*I)->printPretty(OS, nullptr, Policy, 0); |
| 1399 | } |
| 1400 | } |
| 1401 | |
Alexey Bataev | e04483e | 2019-03-27 14:14:31 +0000 | [diff] [blame] | 1402 | void OMPClausePrinter::VisitOMPAllocateClause(OMPAllocateClause *Node) { |
| 1403 | if (Node->varlist_empty()) |
| 1404 | return; |
| 1405 | OS << "allocate"; |
| 1406 | if (Expr *Allocator = Node->getAllocator()) { |
| 1407 | OS << "("; |
| 1408 | Allocator->printPretty(OS, nullptr, Policy, 0); |
| 1409 | OS << ":"; |
| 1410 | VisitOMPClauseList(Node, ' '); |
| 1411 | } else { |
| 1412 | VisitOMPClauseList(Node, '('); |
| 1413 | } |
| 1414 | OS << ")"; |
| 1415 | } |
| 1416 | |
Patrick Lyster | 074c3ae2 | 2018-10-18 14:28:23 +0000 | [diff] [blame] | 1417 | void OMPClausePrinter::VisitOMPPrivateClause(OMPPrivateClause *Node) { |
| 1418 | if (!Node->varlist_empty()) { |
| 1419 | OS << "private"; |
| 1420 | VisitOMPClauseList(Node, '('); |
| 1421 | OS << ")"; |
| 1422 | } |
| 1423 | } |
| 1424 | |
| 1425 | void OMPClausePrinter::VisitOMPFirstprivateClause(OMPFirstprivateClause *Node) { |
| 1426 | if (!Node->varlist_empty()) { |
| 1427 | OS << "firstprivate"; |
| 1428 | VisitOMPClauseList(Node, '('); |
| 1429 | OS << ")"; |
| 1430 | } |
| 1431 | } |
| 1432 | |
| 1433 | void OMPClausePrinter::VisitOMPLastprivateClause(OMPLastprivateClause *Node) { |
| 1434 | if (!Node->varlist_empty()) { |
| 1435 | OS << "lastprivate"; |
Alexey Bataev | 93dc40d | 2019-12-20 11:04:57 -0500 | [diff] [blame] | 1436 | OpenMPLastprivateModifier LPKind = Node->getKind(); |
| 1437 | if (LPKind != OMPC_LASTPRIVATE_unknown) { |
| 1438 | OS << "(" |
| 1439 | << getOpenMPSimpleClauseTypeName(OMPC_lastprivate, Node->getKind()) |
| 1440 | << ":"; |
| 1441 | } |
| 1442 | VisitOMPClauseList(Node, LPKind == OMPC_LASTPRIVATE_unknown ? '(' : ' '); |
Patrick Lyster | 074c3ae2 | 2018-10-18 14:28:23 +0000 | [diff] [blame] | 1443 | OS << ")"; |
| 1444 | } |
| 1445 | } |
| 1446 | |
| 1447 | void OMPClausePrinter::VisitOMPSharedClause(OMPSharedClause *Node) { |
| 1448 | if (!Node->varlist_empty()) { |
| 1449 | OS << "shared"; |
| 1450 | VisitOMPClauseList(Node, '('); |
| 1451 | OS << ")"; |
| 1452 | } |
| 1453 | } |
| 1454 | |
| 1455 | void OMPClausePrinter::VisitOMPReductionClause(OMPReductionClause *Node) { |
| 1456 | if (!Node->varlist_empty()) { |
| 1457 | OS << "reduction("; |
| 1458 | NestedNameSpecifier *QualifierLoc = |
| 1459 | Node->getQualifierLoc().getNestedNameSpecifier(); |
| 1460 | OverloadedOperatorKind OOK = |
| 1461 | Node->getNameInfo().getName().getCXXOverloadedOperator(); |
| 1462 | if (QualifierLoc == nullptr && OOK != OO_None) { |
| 1463 | // Print reduction identifier in C format |
| 1464 | OS << getOperatorSpelling(OOK); |
| 1465 | } else { |
| 1466 | // Use C++ format |
| 1467 | if (QualifierLoc != nullptr) |
| 1468 | QualifierLoc->print(OS, Policy); |
| 1469 | OS << Node->getNameInfo(); |
| 1470 | } |
| 1471 | OS << ":"; |
| 1472 | VisitOMPClauseList(Node, ' '); |
| 1473 | OS << ")"; |
| 1474 | } |
| 1475 | } |
| 1476 | |
| 1477 | void OMPClausePrinter::VisitOMPTaskReductionClause( |
| 1478 | OMPTaskReductionClause *Node) { |
| 1479 | if (!Node->varlist_empty()) { |
| 1480 | OS << "task_reduction("; |
| 1481 | NestedNameSpecifier *QualifierLoc = |
| 1482 | Node->getQualifierLoc().getNestedNameSpecifier(); |
| 1483 | OverloadedOperatorKind OOK = |
| 1484 | Node->getNameInfo().getName().getCXXOverloadedOperator(); |
| 1485 | if (QualifierLoc == nullptr && OOK != OO_None) { |
| 1486 | // Print reduction identifier in C format |
| 1487 | OS << getOperatorSpelling(OOK); |
| 1488 | } else { |
| 1489 | // Use C++ format |
| 1490 | if (QualifierLoc != nullptr) |
| 1491 | QualifierLoc->print(OS, Policy); |
| 1492 | OS << Node->getNameInfo(); |
| 1493 | } |
| 1494 | OS << ":"; |
| 1495 | VisitOMPClauseList(Node, ' '); |
| 1496 | OS << ")"; |
| 1497 | } |
| 1498 | } |
| 1499 | |
| 1500 | void OMPClausePrinter::VisitOMPInReductionClause(OMPInReductionClause *Node) { |
| 1501 | if (!Node->varlist_empty()) { |
| 1502 | OS << "in_reduction("; |
| 1503 | NestedNameSpecifier *QualifierLoc = |
| 1504 | Node->getQualifierLoc().getNestedNameSpecifier(); |
| 1505 | OverloadedOperatorKind OOK = |
| 1506 | Node->getNameInfo().getName().getCXXOverloadedOperator(); |
| 1507 | if (QualifierLoc == nullptr && OOK != OO_None) { |
| 1508 | // Print reduction identifier in C format |
| 1509 | OS << getOperatorSpelling(OOK); |
| 1510 | } else { |
| 1511 | // Use C++ format |
| 1512 | if (QualifierLoc != nullptr) |
| 1513 | QualifierLoc->print(OS, Policy); |
| 1514 | OS << Node->getNameInfo(); |
| 1515 | } |
| 1516 | OS << ":"; |
| 1517 | VisitOMPClauseList(Node, ' '); |
| 1518 | OS << ")"; |
| 1519 | } |
| 1520 | } |
| 1521 | |
| 1522 | void OMPClausePrinter::VisitOMPLinearClause(OMPLinearClause *Node) { |
| 1523 | if (!Node->varlist_empty()) { |
| 1524 | OS << "linear"; |
| 1525 | if (Node->getModifierLoc().isValid()) { |
| 1526 | OS << '(' |
| 1527 | << getOpenMPSimpleClauseTypeName(OMPC_linear, Node->getModifier()); |
| 1528 | } |
| 1529 | VisitOMPClauseList(Node, '('); |
| 1530 | if (Node->getModifierLoc().isValid()) |
| 1531 | OS << ')'; |
| 1532 | if (Node->getStep() != nullptr) { |
| 1533 | OS << ": "; |
| 1534 | Node->getStep()->printPretty(OS, nullptr, Policy, 0); |
| 1535 | } |
| 1536 | OS << ")"; |
| 1537 | } |
| 1538 | } |
| 1539 | |
| 1540 | void OMPClausePrinter::VisitOMPAlignedClause(OMPAlignedClause *Node) { |
| 1541 | if (!Node->varlist_empty()) { |
| 1542 | OS << "aligned"; |
| 1543 | VisitOMPClauseList(Node, '('); |
| 1544 | if (Node->getAlignment() != nullptr) { |
| 1545 | OS << ": "; |
| 1546 | Node->getAlignment()->printPretty(OS, nullptr, Policy, 0); |
| 1547 | } |
| 1548 | OS << ")"; |
| 1549 | } |
| 1550 | } |
| 1551 | |
| 1552 | void OMPClausePrinter::VisitOMPCopyinClause(OMPCopyinClause *Node) { |
| 1553 | if (!Node->varlist_empty()) { |
| 1554 | OS << "copyin"; |
| 1555 | VisitOMPClauseList(Node, '('); |
| 1556 | OS << ")"; |
| 1557 | } |
| 1558 | } |
| 1559 | |
| 1560 | void OMPClausePrinter::VisitOMPCopyprivateClause(OMPCopyprivateClause *Node) { |
| 1561 | if (!Node->varlist_empty()) { |
| 1562 | OS << "copyprivate"; |
| 1563 | VisitOMPClauseList(Node, '('); |
| 1564 | OS << ")"; |
| 1565 | } |
| 1566 | } |
| 1567 | |
| 1568 | void OMPClausePrinter::VisitOMPFlushClause(OMPFlushClause *Node) { |
| 1569 | if (!Node->varlist_empty()) { |
| 1570 | VisitOMPClauseList(Node, '('); |
| 1571 | OS << ")"; |
| 1572 | } |
| 1573 | } |
| 1574 | |
| 1575 | void OMPClausePrinter::VisitOMPDependClause(OMPDependClause *Node) { |
| 1576 | OS << "depend("; |
| 1577 | OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(), |
| 1578 | Node->getDependencyKind()); |
| 1579 | if (!Node->varlist_empty()) { |
| 1580 | OS << " :"; |
| 1581 | VisitOMPClauseList(Node, ' '); |
| 1582 | } |
| 1583 | OS << ")"; |
| 1584 | } |
| 1585 | |
| 1586 | void OMPClausePrinter::VisitOMPMapClause(OMPMapClause *Node) { |
| 1587 | if (!Node->varlist_empty()) { |
| 1588 | OS << "map("; |
| 1589 | if (Node->getMapType() != OMPC_MAP_unknown) { |
Kelvin Li | ef57943 | 2018-12-18 22:18:41 +0000 | [diff] [blame] | 1590 | for (unsigned I = 0; I < OMPMapClause::NumberOfModifiers; ++I) { |
| 1591 | if (Node->getMapTypeModifier(I) != OMPC_MAP_MODIFIER_unknown) { |
| 1592 | OS << getOpenMPSimpleClauseTypeName(OMPC_map, |
| 1593 | Node->getMapTypeModifier(I)); |
Michael Kruse | 4304e9d | 2019-02-19 16:38:20 +0000 | [diff] [blame] | 1594 | if (Node->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_mapper) { |
| 1595 | OS << '('; |
| 1596 | NestedNameSpecifier *MapperNNS = |
| 1597 | Node->getMapperQualifierLoc().getNestedNameSpecifier(); |
| 1598 | if (MapperNNS) |
| 1599 | MapperNNS->print(OS, Policy); |
| 1600 | OS << Node->getMapperIdInfo() << ')'; |
| 1601 | } |
Kelvin Li | ef57943 | 2018-12-18 22:18:41 +0000 | [diff] [blame] | 1602 | OS << ','; |
| 1603 | } |
Patrick Lyster | 074c3ae2 | 2018-10-18 14:28:23 +0000 | [diff] [blame] | 1604 | } |
| 1605 | OS << getOpenMPSimpleClauseTypeName(OMPC_map, Node->getMapType()); |
| 1606 | OS << ':'; |
| 1607 | } |
| 1608 | VisitOMPClauseList(Node, ' '); |
| 1609 | OS << ")"; |
| 1610 | } |
| 1611 | } |
| 1612 | |
| 1613 | void OMPClausePrinter::VisitOMPToClause(OMPToClause *Node) { |
| 1614 | if (!Node->varlist_empty()) { |
| 1615 | OS << "to"; |
Michael Kruse | 01f670d | 2019-02-22 22:29:42 +0000 | [diff] [blame] | 1616 | DeclarationNameInfo MapperId = Node->getMapperIdInfo(); |
| 1617 | if (MapperId.getName() && !MapperId.getName().isEmpty()) { |
| 1618 | OS << '('; |
| 1619 | OS << "mapper("; |
| 1620 | NestedNameSpecifier *MapperNNS = |
| 1621 | Node->getMapperQualifierLoc().getNestedNameSpecifier(); |
| 1622 | if (MapperNNS) |
| 1623 | MapperNNS->print(OS, Policy); |
| 1624 | OS << MapperId << "):"; |
| 1625 | VisitOMPClauseList(Node, ' '); |
| 1626 | } else { |
| 1627 | VisitOMPClauseList(Node, '('); |
| 1628 | } |
Patrick Lyster | 074c3ae2 | 2018-10-18 14:28:23 +0000 | [diff] [blame] | 1629 | OS << ")"; |
| 1630 | } |
| 1631 | } |
| 1632 | |
| 1633 | void OMPClausePrinter::VisitOMPFromClause(OMPFromClause *Node) { |
| 1634 | if (!Node->varlist_empty()) { |
| 1635 | OS << "from"; |
Michael Kruse | 0336c75 | 2019-02-25 20:34:15 +0000 | [diff] [blame] | 1636 | DeclarationNameInfo MapperId = Node->getMapperIdInfo(); |
| 1637 | if (MapperId.getName() && !MapperId.getName().isEmpty()) { |
| 1638 | OS << '('; |
| 1639 | OS << "mapper("; |
| 1640 | NestedNameSpecifier *MapperNNS = |
| 1641 | Node->getMapperQualifierLoc().getNestedNameSpecifier(); |
| 1642 | if (MapperNNS) |
| 1643 | MapperNNS->print(OS, Policy); |
| 1644 | OS << MapperId << "):"; |
| 1645 | VisitOMPClauseList(Node, ' '); |
| 1646 | } else { |
| 1647 | VisitOMPClauseList(Node, '('); |
| 1648 | } |
Patrick Lyster | 074c3ae2 | 2018-10-18 14:28:23 +0000 | [diff] [blame] | 1649 | OS << ")"; |
| 1650 | } |
| 1651 | } |
| 1652 | |
| 1653 | void OMPClausePrinter::VisitOMPDistScheduleClause(OMPDistScheduleClause *Node) { |
| 1654 | OS << "dist_schedule(" << getOpenMPSimpleClauseTypeName( |
| 1655 | OMPC_dist_schedule, Node->getDistScheduleKind()); |
| 1656 | if (auto *E = Node->getChunkSize()) { |
| 1657 | OS << ", "; |
| 1658 | E->printPretty(OS, nullptr, Policy); |
| 1659 | } |
| 1660 | OS << ")"; |
| 1661 | } |
| 1662 | |
| 1663 | void OMPClausePrinter::VisitOMPDefaultmapClause(OMPDefaultmapClause *Node) { |
| 1664 | OS << "defaultmap("; |
| 1665 | OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap, |
| 1666 | Node->getDefaultmapModifier()); |
| 1667 | OS << ": "; |
| 1668 | OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap, |
| 1669 | Node->getDefaultmapKind()); |
| 1670 | OS << ")"; |
| 1671 | } |
| 1672 | |
| 1673 | void OMPClausePrinter::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *Node) { |
| 1674 | if (!Node->varlist_empty()) { |
| 1675 | OS << "use_device_ptr"; |
| 1676 | VisitOMPClauseList(Node, '('); |
| 1677 | OS << ")"; |
| 1678 | } |
| 1679 | } |
| 1680 | |
| 1681 | void OMPClausePrinter::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *Node) { |
| 1682 | if (!Node->varlist_empty()) { |
| 1683 | OS << "is_device_ptr"; |
| 1684 | VisitOMPClauseList(Node, '('); |
| 1685 | OS << ")"; |
| 1686 | } |
| 1687 | } |
| 1688 | |
Alexey Bataev | b6e7084 | 2019-12-16 15:54:17 -0500 | [diff] [blame] | 1689 | void OMPClausePrinter::VisitOMPNontemporalClause(OMPNontemporalClause *Node) { |
| 1690 | if (!Node->varlist_empty()) { |
| 1691 | OS << "nontemporal"; |
| 1692 | VisitOMPClauseList(Node, '('); |
| 1693 | OS << ")"; |
| 1694 | } |
| 1695 | } |
Alexey Bataev | cb8e691 | 2020-01-31 16:09:26 -0500 | [diff] [blame^] | 1696 | |
| 1697 | void OMPClausePrinter::VisitOMPOrderClause(OMPOrderClause *Node) { |
| 1698 | OS << "order(" << getOpenMPSimpleClauseTypeName(OMPC_order, Node->getKind()) |
| 1699 | << ")"; |
| 1700 | } |