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