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