2017-11-30 07:27:36 +08:00
|
|
|
//===- OpenMPClause.cpp - Classes for OpenMP clauses ----------------------===//
|
2015-10-02 21:41:04 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-10-02 21:41:04 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the subclesses of Stmt class declared in OpenMPClause.h
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/AST/OpenMPClause.h"
|
|
|
|
#include "clang/AST/ASTContext.h"
|
2020-03-12 11:22:14 +08:00
|
|
|
#include "clang/AST/Attr.h"
|
2017-11-30 07:27:36 +08:00
|
|
|
#include "clang/AST/Decl.h"
|
2018-10-18 22:28:23 +08:00
|
|
|
#include "clang/AST/DeclOpenMP.h"
|
2017-11-30 07:27:36 +08:00
|
|
|
#include "clang/Basic/LLVM.h"
|
2019-12-21 00:04:57 +08:00
|
|
|
#include "clang/Basic/OpenMPKinds.h"
|
2020-07-07 14:08:03 +08:00
|
|
|
#include "clang/Basic/TargetInfo.h"
|
2017-11-30 07:27:36 +08:00
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
|
|
|
#include "llvm/Support/Casting.h"
|
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
#include <algorithm>
|
|
|
|
#include <cassert>
|
2015-10-02 21:41:04 +08:00
|
|
|
|
|
|
|
using namespace clang;
|
2020-03-26 08:33:48 +08:00
|
|
|
using namespace llvm;
|
|
|
|
using namespace omp;
|
2015-10-02 21:41:04 +08:00
|
|
|
|
|
|
|
OMPClause::child_range OMPClause::children() {
|
|
|
|
switch (getClauseKind()) {
|
|
|
|
default:
|
|
|
|
break;
|
2020-12-18 03:07:29 +08:00
|
|
|
#define GEN_CLANG_CLAUSE_CLASS
|
|
|
|
#define CLAUSE_CLASS(Enum, Str, Class) \
|
2020-03-31 08:58:40 +08:00
|
|
|
case Enum: \
|
2015-10-02 21:41:04 +08:00
|
|
|
return static_cast<Class *>(this)->children();
|
2020-12-18 03:07:29 +08:00
|
|
|
#include "llvm/Frontend/OpenMP/OMP.inc"
|
2015-10-02 21:41:04 +08:00
|
|
|
}
|
|
|
|
llvm_unreachable("unknown OMPClause");
|
|
|
|
}
|
|
|
|
|
[OPENMP]Initial fix PR42392: Improve -Wuninitialized warnings for OpenMP programs.
Summary:
Some OpenMP clauses rely on the values of the variables. If the variable
is not initialized and used in OpenMP clauses that depend on the
variables values, it should be reported that the uninitialized variable
is used in the OpenMP clause expression.
This patch adds initial processing for uninitialized variables in OpenMP
constructs. Currently, it checks for use of the uninitialized variables
in the structured blocks.
Reviewers: NoQ, Szelethus, dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet
Subscribers: rnkovacs, guansong, jfb, jdoerfert, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64356
llvm-svn: 365786
2019-07-11 22:54:17 +08:00
|
|
|
OMPClause::child_range OMPClause::used_children() {
|
|
|
|
switch (getClauseKind()) {
|
2020-12-18 03:07:29 +08:00
|
|
|
#define GEN_CLANG_CLAUSE_CLASS
|
|
|
|
#define CLAUSE_CLASS(Enum, Str, Class) \
|
2020-03-31 08:58:40 +08:00
|
|
|
case Enum: \
|
[OPENMP]Initial fix PR42392: Improve -Wuninitialized warnings for OpenMP programs.
Summary:
Some OpenMP clauses rely on the values of the variables. If the variable
is not initialized and used in OpenMP clauses that depend on the
variables values, it should be reported that the uninitialized variable
is used in the OpenMP clause expression.
This patch adds initial processing for uninitialized variables in OpenMP
constructs. Currently, it checks for use of the uninitialized variables
in the structured blocks.
Reviewers: NoQ, Szelethus, dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet
Subscribers: rnkovacs, guansong, jfb, jdoerfert, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64356
llvm-svn: 365786
2019-07-11 22:54:17 +08:00
|
|
|
return static_cast<Class *>(this)->used_children();
|
2020-12-18 03:07:29 +08:00
|
|
|
#define CLAUSE_NO_CLASS(Enum, Str) \
|
|
|
|
case Enum: \
|
[flang][openmp] Use common Directive and Clause enum from llvm/Frontend
Summary:
This patch is removing the custom enumeration for OpenMP Directives and Clauses and replace them
with the newly tablegen generated one from llvm/Frontend. This is a first patch and some will follow to share the same
infrastructure where possible. The next patch should use the clauses allowance defined in the tablegen file.
Reviewers: jdoerfert, DavidTruby, sscalpone, kiranchandramohan, ichoyjx
Reviewed By: DavidTruby, ichoyjx
Subscribers: jholewinski, cfe-commits, dblaikie, MaskRay, ymandel, ichoyjx, mgorny, yaxunl, guansong, jfb, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm, #flang, #clang
Differential Revision: https://reviews.llvm.org/D82906
2020-07-02 08:57:11 +08:00
|
|
|
break;
|
2020-12-18 03:07:29 +08:00
|
|
|
#include "llvm/Frontend/OpenMP/OMP.inc"
|
[OPENMP]Initial fix PR42392: Improve -Wuninitialized warnings for OpenMP programs.
Summary:
Some OpenMP clauses rely on the values of the variables. If the variable
is not initialized and used in OpenMP clauses that depend on the
variables values, it should be reported that the uninitialized variable
is used in the OpenMP clause expression.
This patch adds initial processing for uninitialized variables in OpenMP
constructs. Currently, it checks for use of the uninitialized variables
in the structured blocks.
Reviewers: NoQ, Szelethus, dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet
Subscribers: rnkovacs, guansong, jfb, jdoerfert, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64356
llvm-svn: 365786
2019-07-11 22:54:17 +08:00
|
|
|
}
|
|
|
|
llvm_unreachable("unknown OMPClause");
|
|
|
|
}
|
|
|
|
|
2016-02-16 19:18:12 +08:00
|
|
|
OMPClauseWithPreInit *OMPClauseWithPreInit::get(OMPClause *C) {
|
|
|
|
auto *Res = OMPClauseWithPreInit::get(const_cast<const OMPClause *>(C));
|
|
|
|
return Res ? const_cast<OMPClauseWithPreInit *>(Res) : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) {
|
|
|
|
switch (C->getClauseKind()) {
|
|
|
|
case OMPC_schedule:
|
|
|
|
return static_cast<const OMPScheduleClause *>(C);
|
|
|
|
case OMPC_dist_schedule:
|
|
|
|
return static_cast<const OMPDistScheduleClause *>(C);
|
2016-02-17 21:19:37 +08:00
|
|
|
case OMPC_firstprivate:
|
|
|
|
return static_cast<const OMPFirstprivateClause *>(C);
|
2016-02-25 13:25:57 +08:00
|
|
|
case OMPC_lastprivate:
|
|
|
|
return static_cast<const OMPLastprivateClause *>(C);
|
2016-03-02 12:57:40 +08:00
|
|
|
case OMPC_reduction:
|
|
|
|
return static_cast<const OMPReductionClause *>(C);
|
2017-07-19 04:17:46 +08:00
|
|
|
case OMPC_task_reduction:
|
|
|
|
return static_cast<const OMPTaskReductionClause *>(C);
|
2017-07-22 02:48:21 +08:00
|
|
|
case OMPC_in_reduction:
|
|
|
|
return static_cast<const OMPInReductionClause *>(C);
|
2016-03-09 17:49:00 +08:00
|
|
|
case OMPC_linear:
|
|
|
|
return static_cast<const OMPLinearClause *>(C);
|
2017-01-19 04:40:48 +08:00
|
|
|
case OMPC_if:
|
|
|
|
return static_cast<const OMPIfClause *>(C);
|
2017-01-25 08:57:16 +08:00
|
|
|
case OMPC_num_threads:
|
|
|
|
return static_cast<const OMPNumThreadsClause *>(C);
|
2017-01-25 19:28:18 +08:00
|
|
|
case OMPC_num_teams:
|
|
|
|
return static_cast<const OMPNumTeamsClause *>(C);
|
2017-01-25 19:44:35 +08:00
|
|
|
case OMPC_thread_limit:
|
|
|
|
return static_cast<const OMPThreadLimitClause *>(C);
|
2017-10-03 00:32:39 +08:00
|
|
|
case OMPC_device:
|
|
|
|
return static_cast<const OMPDeviceClause *>(C);
|
2019-10-15 03:29:52 +08:00
|
|
|
case OMPC_grainsize:
|
|
|
|
return static_cast<const OMPGrainsizeClause *>(C);
|
2019-10-15 04:44:34 +08:00
|
|
|
case OMPC_num_tasks:
|
|
|
|
return static_cast<const OMPNumTasksClause *>(C);
|
2019-10-16 03:37:05 +08:00
|
|
|
case OMPC_final:
|
|
|
|
return static_cast<const OMPFinalClause *>(C);
|
2019-10-17 02:09:37 +08:00
|
|
|
case OMPC_priority:
|
|
|
|
return static_cast<const OMPPriorityClause *>(C);
|
2021-04-01 03:26:47 +08:00
|
|
|
case OMPC_novariants:
|
|
|
|
return static_cast<const OMPNovariantsClause *>(C);
|
2021-04-04 02:09:25 +08:00
|
|
|
case OMPC_nocontext:
|
|
|
|
return static_cast<const OMPNocontextClause *>(C);
|
2021-04-10 03:00:36 +08:00
|
|
|
case OMPC_filter:
|
|
|
|
return static_cast<const OMPFilterClause *>(C);
|
2016-02-16 19:18:12 +08:00
|
|
|
case OMPC_default:
|
|
|
|
case OMPC_proc_bind:
|
|
|
|
case OMPC_safelen:
|
|
|
|
case OMPC_simdlen:
|
2021-02-13 03:26:59 +08:00
|
|
|
case OMPC_sizes:
|
2019-03-13 02:52:33 +08:00
|
|
|
case OMPC_allocator:
|
2019-03-27 22:14:31 +08:00
|
|
|
case OMPC_allocate:
|
2016-02-16 19:18:12 +08:00
|
|
|
case OMPC_collapse:
|
|
|
|
case OMPC_private:
|
2016-02-25 13:25:57 +08:00
|
|
|
case OMPC_shared:
|
|
|
|
case OMPC_aligned:
|
|
|
|
case OMPC_copyin:
|
|
|
|
case OMPC_copyprivate:
|
|
|
|
case OMPC_ordered:
|
|
|
|
case OMPC_nowait:
|
|
|
|
case OMPC_untied:
|
|
|
|
case OMPC_mergeable:
|
|
|
|
case OMPC_threadprivate:
|
|
|
|
case OMPC_flush:
|
2020-02-28 22:52:15 +08:00
|
|
|
case OMPC_depobj:
|
2016-02-25 13:25:57 +08:00
|
|
|
case OMPC_read:
|
|
|
|
case OMPC_write:
|
|
|
|
case OMPC_update:
|
|
|
|
case OMPC_capture:
|
2021-12-24 21:16:33 +08:00
|
|
|
case OMPC_compare:
|
2016-02-25 13:25:57 +08:00
|
|
|
case OMPC_seq_cst:
|
2020-02-07 05:30:23 +08:00
|
|
|
case OMPC_acq_rel:
|
2020-02-11 03:30:39 +08:00
|
|
|
case OMPC_acquire:
|
2020-02-11 04:49:05 +08:00
|
|
|
case OMPC_release:
|
2020-02-12 00:10:43 +08:00
|
|
|
case OMPC_relaxed:
|
2016-02-25 13:25:57 +08:00
|
|
|
case OMPC_depend:
|
|
|
|
case OMPC_threads:
|
|
|
|
case OMPC_simd:
|
|
|
|
case OMPC_map:
|
|
|
|
case OMPC_nogroup:
|
|
|
|
case OMPC_hint:
|
|
|
|
case OMPC_defaultmap:
|
|
|
|
case OMPC_unknown:
|
2016-04-12 13:28:34 +08:00
|
|
|
case OMPC_uniform:
|
2016-05-27 01:39:58 +08:00
|
|
|
case OMPC_to:
|
2016-05-27 01:49:04 +08:00
|
|
|
case OMPC_from:
|
2016-07-13 23:37:16 +08:00
|
|
|
case OMPC_use_device_ptr:
|
2020-05-21 20:30:23 +08:00
|
|
|
case OMPC_use_device_addr:
|
2016-07-14 01:16:49 +08:00
|
|
|
case OMPC_is_device_ptr:
|
2018-09-26 12:28:39 +08:00
|
|
|
case OMPC_unified_address:
|
2018-10-01 21:47:43 +08:00
|
|
|
case OMPC_unified_shared_memory:
|
2018-10-04 04:07:58 +08:00
|
|
|
case OMPC_reverse_offload:
|
2018-10-11 22:41:10 +08:00
|
|
|
case OMPC_dynamic_allocators:
|
2018-11-02 20:18:11 +08:00
|
|
|
case OMPC_atomic_default_mem_order:
|
2019-08-24 00:11:14 +08:00
|
|
|
case OMPC_device_type:
|
2019-09-24 02:13:31 +08:00
|
|
|
case OMPC_match:
|
2019-12-17 04:54:17 +08:00
|
|
|
case OMPC_nontemporal:
|
2020-02-01 05:09:26 +08:00
|
|
|
case OMPC_order:
|
2020-03-03 03:21:20 +08:00
|
|
|
case OMPC_destroy:
|
2020-03-17 21:17:42 +08:00
|
|
|
case OMPC_detach:
|
2020-03-20 21:41:22 +08:00
|
|
|
case OMPC_inclusive:
|
2020-03-23 22:41:08 +08:00
|
|
|
case OMPC_exclusive:
|
2020-04-22 01:21:00 +08:00
|
|
|
case OMPC_uses_allocators:
|
2020-05-19 01:37:53 +08:00
|
|
|
case OMPC_affinity:
|
2021-09-18 05:03:01 +08:00
|
|
|
case OMPC_when:
|
2021-11-04 05:57:01 +08:00
|
|
|
case OMPC_bind:
|
2016-02-25 13:25:57 +08:00
|
|
|
break;
|
[flang][openmp] Use common Directive and Clause enum from llvm/Frontend
Summary:
This patch is removing the custom enumeration for OpenMP Directives and Clauses and replace them
with the newly tablegen generated one from llvm/Frontend. This is a first patch and some will follow to share the same
infrastructure where possible. The next patch should use the clauses allowance defined in the tablegen file.
Reviewers: jdoerfert, DavidTruby, sscalpone, kiranchandramohan, ichoyjx
Reviewed By: DavidTruby, ichoyjx
Subscribers: jholewinski, cfe-commits, dblaikie, MaskRay, ymandel, ichoyjx, mgorny, yaxunl, guansong, jfb, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm, #flang, #clang
Differential Revision: https://reviews.llvm.org/D82906
2020-07-02 08:57:11 +08:00
|
|
|
default:
|
|
|
|
break;
|
2016-02-25 13:25:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(OMPClause *C) {
|
|
|
|
auto *Res = OMPClauseWithPostUpdate::get(const_cast<const OMPClause *>(C));
|
|
|
|
return Res ? const_cast<OMPClauseWithPostUpdate *>(Res) : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(const OMPClause *C) {
|
|
|
|
switch (C->getClauseKind()) {
|
2016-02-16 19:18:12 +08:00
|
|
|
case OMPC_lastprivate:
|
2016-02-25 13:25:57 +08:00
|
|
|
return static_cast<const OMPLastprivateClause *>(C);
|
2016-03-02 12:57:40 +08:00
|
|
|
case OMPC_reduction:
|
|
|
|
return static_cast<const OMPReductionClause *>(C);
|
2017-07-19 04:17:46 +08:00
|
|
|
case OMPC_task_reduction:
|
|
|
|
return static_cast<const OMPTaskReductionClause *>(C);
|
2017-07-22 02:48:21 +08:00
|
|
|
case OMPC_in_reduction:
|
|
|
|
return static_cast<const OMPInReductionClause *>(C);
|
2016-03-09 17:49:00 +08:00
|
|
|
case OMPC_linear:
|
|
|
|
return static_cast<const OMPLinearClause *>(C);
|
2016-02-25 13:25:57 +08:00
|
|
|
case OMPC_schedule:
|
|
|
|
case OMPC_dist_schedule:
|
|
|
|
case OMPC_firstprivate:
|
|
|
|
case OMPC_default:
|
|
|
|
case OMPC_proc_bind:
|
|
|
|
case OMPC_if:
|
|
|
|
case OMPC_final:
|
|
|
|
case OMPC_num_threads:
|
|
|
|
case OMPC_safelen:
|
|
|
|
case OMPC_simdlen:
|
2021-02-13 03:26:59 +08:00
|
|
|
case OMPC_sizes:
|
2019-03-13 02:52:33 +08:00
|
|
|
case OMPC_allocator:
|
2019-03-27 22:14:31 +08:00
|
|
|
case OMPC_allocate:
|
2016-02-25 13:25:57 +08:00
|
|
|
case OMPC_collapse:
|
|
|
|
case OMPC_private:
|
2016-02-16 19:18:12 +08:00
|
|
|
case OMPC_shared:
|
|
|
|
case OMPC_aligned:
|
|
|
|
case OMPC_copyin:
|
|
|
|
case OMPC_copyprivate:
|
|
|
|
case OMPC_ordered:
|
|
|
|
case OMPC_nowait:
|
|
|
|
case OMPC_untied:
|
|
|
|
case OMPC_mergeable:
|
|
|
|
case OMPC_threadprivate:
|
|
|
|
case OMPC_flush:
|
2020-02-28 22:52:15 +08:00
|
|
|
case OMPC_depobj:
|
2016-02-16 19:18:12 +08:00
|
|
|
case OMPC_read:
|
|
|
|
case OMPC_write:
|
|
|
|
case OMPC_update:
|
|
|
|
case OMPC_capture:
|
2021-12-24 21:16:33 +08:00
|
|
|
case OMPC_compare:
|
2016-02-16 19:18:12 +08:00
|
|
|
case OMPC_seq_cst:
|
2020-02-07 05:30:23 +08:00
|
|
|
case OMPC_acq_rel:
|
2020-02-11 03:30:39 +08:00
|
|
|
case OMPC_acquire:
|
2020-02-11 04:49:05 +08:00
|
|
|
case OMPC_release:
|
2020-02-12 00:10:43 +08:00
|
|
|
case OMPC_relaxed:
|
2016-02-16 19:18:12 +08:00
|
|
|
case OMPC_depend:
|
|
|
|
case OMPC_device:
|
|
|
|
case OMPC_threads:
|
|
|
|
case OMPC_simd:
|
|
|
|
case OMPC_map:
|
|
|
|
case OMPC_num_teams:
|
|
|
|
case OMPC_thread_limit:
|
|
|
|
case OMPC_priority:
|
|
|
|
case OMPC_grainsize:
|
|
|
|
case OMPC_nogroup:
|
|
|
|
case OMPC_num_tasks:
|
|
|
|
case OMPC_hint:
|
|
|
|
case OMPC_defaultmap:
|
|
|
|
case OMPC_unknown:
|
2016-04-12 13:28:34 +08:00
|
|
|
case OMPC_uniform:
|
2016-05-27 01:39:58 +08:00
|
|
|
case OMPC_to:
|
2016-05-27 01:49:04 +08:00
|
|
|
case OMPC_from:
|
2016-07-13 23:37:16 +08:00
|
|
|
case OMPC_use_device_ptr:
|
2020-05-21 20:30:23 +08:00
|
|
|
case OMPC_use_device_addr:
|
2016-07-14 01:16:49 +08:00
|
|
|
case OMPC_is_device_ptr:
|
2018-09-26 12:28:39 +08:00
|
|
|
case OMPC_unified_address:
|
2018-10-01 21:47:43 +08:00
|
|
|
case OMPC_unified_shared_memory:
|
2018-10-04 04:07:58 +08:00
|
|
|
case OMPC_reverse_offload:
|
2018-10-11 22:41:10 +08:00
|
|
|
case OMPC_dynamic_allocators:
|
2018-11-02 20:18:11 +08:00
|
|
|
case OMPC_atomic_default_mem_order:
|
2019-08-24 00:11:14 +08:00
|
|
|
case OMPC_device_type:
|
2019-09-24 02:13:31 +08:00
|
|
|
case OMPC_match:
|
2019-12-17 04:54:17 +08:00
|
|
|
case OMPC_nontemporal:
|
2020-02-01 05:09:26 +08:00
|
|
|
case OMPC_order:
|
2020-03-03 03:21:20 +08:00
|
|
|
case OMPC_destroy:
|
2021-04-01 03:26:47 +08:00
|
|
|
case OMPC_novariants:
|
2021-04-04 02:09:25 +08:00
|
|
|
case OMPC_nocontext:
|
2020-03-17 21:17:42 +08:00
|
|
|
case OMPC_detach:
|
2020-03-20 21:41:22 +08:00
|
|
|
case OMPC_inclusive:
|
2020-03-23 22:41:08 +08:00
|
|
|
case OMPC_exclusive:
|
2020-04-22 01:21:00 +08:00
|
|
|
case OMPC_uses_allocators:
|
2020-05-19 01:37:53 +08:00
|
|
|
case OMPC_affinity:
|
2021-09-18 05:03:01 +08:00
|
|
|
case OMPC_when:
|
2021-11-04 05:57:01 +08:00
|
|
|
case OMPC_bind:
|
2016-02-16 19:18:12 +08:00
|
|
|
break;
|
[flang][openmp] Use common Directive and Clause enum from llvm/Frontend
Summary:
This patch is removing the custom enumeration for OpenMP Directives and Clauses and replace them
with the newly tablegen generated one from llvm/Frontend. This is a first patch and some will follow to share the same
infrastructure where possible. The next patch should use the clauses allowance defined in the tablegen file.
Reviewers: jdoerfert, DavidTruby, sscalpone, kiranchandramohan, ichoyjx
Reviewed By: DavidTruby, ichoyjx
Subscribers: jholewinski, cfe-commits, dblaikie, MaskRay, ymandel, ichoyjx, mgorny, yaxunl, guansong, jfb, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm, #flang, #clang
Differential Revision: https://reviews.llvm.org/D82906
2020-07-02 08:57:11 +08:00
|
|
|
default:
|
|
|
|
break;
|
2016-02-16 19:18:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-07-16 22:51:46 +08:00
|
|
|
/// Gets the address of the original, non-captured, expression used in the
|
|
|
|
/// clause as the preinitializer.
|
|
|
|
static Stmt **getAddrOfExprAsWritten(Stmt *S) {
|
|
|
|
if (!S)
|
|
|
|
return nullptr;
|
|
|
|
if (auto *DS = dyn_cast<DeclStmt>(S)) {
|
|
|
|
assert(DS->isSingleDecl() && "Only single expression must be captured.");
|
|
|
|
if (auto *OED = dyn_cast<OMPCapturedExprDecl>(DS->getSingleDecl()))
|
|
|
|
return OED->getInitAddress();
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPClause::child_range OMPIfClause::used_children() {
|
|
|
|
if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
|
|
|
|
return child_range(C, C + 1);
|
|
|
|
return child_range(&Condition, &Condition + 1);
|
|
|
|
}
|
|
|
|
|
2019-10-15 03:29:52 +08:00
|
|
|
OMPClause::child_range OMPGrainsizeClause::used_children() {
|
|
|
|
if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
|
|
|
|
return child_range(C, C + 1);
|
|
|
|
return child_range(&Grainsize, &Grainsize + 1);
|
|
|
|
}
|
|
|
|
|
2019-10-15 04:44:34 +08:00
|
|
|
OMPClause::child_range OMPNumTasksClause::used_children() {
|
|
|
|
if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
|
|
|
|
return child_range(C, C + 1);
|
|
|
|
return child_range(&NumTasks, &NumTasks + 1);
|
|
|
|
}
|
|
|
|
|
2019-10-16 03:37:05 +08:00
|
|
|
OMPClause::child_range OMPFinalClause::used_children() {
|
|
|
|
if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
|
|
|
|
return child_range(C, C + 1);
|
|
|
|
return child_range(&Condition, &Condition + 1);
|
|
|
|
}
|
|
|
|
|
2019-10-17 02:09:37 +08:00
|
|
|
OMPClause::child_range OMPPriorityClause::used_children() {
|
|
|
|
if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
|
|
|
|
return child_range(C, C + 1);
|
|
|
|
return child_range(&Priority, &Priority + 1);
|
|
|
|
}
|
|
|
|
|
2021-04-01 03:26:47 +08:00
|
|
|
OMPClause::child_range OMPNovariantsClause::used_children() {
|
|
|
|
if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
|
|
|
|
return child_range(C, C + 1);
|
|
|
|
return child_range(&Condition, &Condition + 1);
|
|
|
|
}
|
|
|
|
|
2021-04-04 02:09:25 +08:00
|
|
|
OMPClause::child_range OMPNocontextClause::used_children() {
|
|
|
|
if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
|
|
|
|
return child_range(C, C + 1);
|
|
|
|
return child_range(&Condition, &Condition + 1);
|
|
|
|
}
|
|
|
|
|
2018-08-14 03:04:24 +08:00
|
|
|
OMPOrderedClause *OMPOrderedClause::Create(const ASTContext &C, Expr *Num,
|
|
|
|
unsigned NumLoops,
|
|
|
|
SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation EndLoc) {
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
|
|
|
|
auto *Clause =
|
|
|
|
new (Mem) OMPOrderedClause(Num, NumLoops, StartLoc, LParenLoc, EndLoc);
|
|
|
|
for (unsigned I = 0; I < NumLoops; ++I) {
|
|
|
|
Clause->setLoopNumIterations(I, nullptr);
|
|
|
|
Clause->setLoopCounter(I, nullptr);
|
|
|
|
}
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPOrderedClause *OMPOrderedClause::CreateEmpty(const ASTContext &C,
|
|
|
|
unsigned NumLoops) {
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
|
|
|
|
auto *Clause = new (Mem) OMPOrderedClause(NumLoops);
|
|
|
|
for (unsigned I = 0; I < NumLoops; ++I) {
|
|
|
|
Clause->setLoopNumIterations(I, nullptr);
|
|
|
|
Clause->setLoopCounter(I, nullptr);
|
|
|
|
}
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPOrderedClause::setLoopNumIterations(unsigned NumLoop,
|
|
|
|
Expr *NumIterations) {
|
|
|
|
assert(NumLoop < NumberOfLoops && "out of loops number.");
|
|
|
|
getTrailingObjects<Expr *>()[NumLoop] = NumIterations;
|
|
|
|
}
|
|
|
|
|
|
|
|
ArrayRef<Expr *> OMPOrderedClause::getLoopNumIterations() const {
|
|
|
|
return llvm::makeArrayRef(getTrailingObjects<Expr *>(), NumberOfLoops);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPOrderedClause::setLoopCounter(unsigned NumLoop, Expr *Counter) {
|
|
|
|
assert(NumLoop < NumberOfLoops && "out of loops number.");
|
|
|
|
getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop] = Counter;
|
|
|
|
}
|
|
|
|
|
2018-09-21 01:19:41 +08:00
|
|
|
Expr *OMPOrderedClause::getLoopCounter(unsigned NumLoop) {
|
2018-08-14 03:04:24 +08:00
|
|
|
assert(NumLoop < NumberOfLoops && "out of loops number.");
|
|
|
|
return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop];
|
|
|
|
}
|
|
|
|
|
2018-09-21 01:19:41 +08:00
|
|
|
const Expr *OMPOrderedClause::getLoopCounter(unsigned NumLoop) const {
|
2018-08-14 03:04:24 +08:00
|
|
|
assert(NumLoop < NumberOfLoops && "out of loops number.");
|
|
|
|
return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop];
|
|
|
|
}
|
|
|
|
|
2020-03-04 02:22:35 +08:00
|
|
|
OMPUpdateClause *OMPUpdateClause::Create(const ASTContext &C,
|
|
|
|
SourceLocation StartLoc,
|
|
|
|
SourceLocation EndLoc) {
|
|
|
|
return new (C) OMPUpdateClause(StartLoc, EndLoc, /*IsExtended=*/false);
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPUpdateClause *
|
|
|
|
OMPUpdateClause::Create(const ASTContext &C, SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc, SourceLocation ArgumentLoc,
|
|
|
|
OpenMPDependClauseKind DK, SourceLocation EndLoc) {
|
|
|
|
void *Mem =
|
|
|
|
C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1),
|
|
|
|
alignof(OMPUpdateClause));
|
|
|
|
auto *Clause =
|
|
|
|
new (Mem) OMPUpdateClause(StartLoc, EndLoc, /*IsExtended=*/true);
|
|
|
|
Clause->setLParenLoc(LParenLoc);
|
|
|
|
Clause->setArgumentLoc(ArgumentLoc);
|
|
|
|
Clause->setDependencyKind(DK);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPUpdateClause *OMPUpdateClause::CreateEmpty(const ASTContext &C,
|
|
|
|
bool IsExtended) {
|
|
|
|
if (!IsExtended)
|
|
|
|
return new (C) OMPUpdateClause(/*IsExtended=*/false);
|
|
|
|
void *Mem =
|
|
|
|
C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1),
|
|
|
|
alignof(OMPUpdateClause));
|
|
|
|
auto *Clause = new (Mem) OMPUpdateClause(/*IsExtended=*/true);
|
|
|
|
Clause->IsExtended = true;
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
2015-10-02 21:41:04 +08:00
|
|
|
void OMPPrivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
|
|
|
|
assert(VL.size() == varlist_size() &&
|
|
|
|
"Number of private copies is not the same as the preallocated buffer");
|
|
|
|
std::copy(VL.begin(), VL.end(), varlist_end());
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPPrivateClause *
|
|
|
|
OMPPrivateClause::Create(const ASTContext &C, SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc, SourceLocation EndLoc,
|
|
|
|
ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL) {
|
|
|
|
// Allocate space for private variables and initializer expressions.
|
2016-01-01 08:38:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
|
2015-10-02 21:41:04 +08:00
|
|
|
OMPPrivateClause *Clause =
|
|
|
|
new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
|
|
|
|
Clause->setVarRefs(VL);
|
|
|
|
Clause->setPrivateCopies(PrivateVL);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPPrivateClause *OMPPrivateClause::CreateEmpty(const ASTContext &C,
|
|
|
|
unsigned N) {
|
2016-01-01 08:38:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
|
2015-10-02 21:41:04 +08:00
|
|
|
return new (Mem) OMPPrivateClause(N);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPFirstprivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
|
|
|
|
assert(VL.size() == varlist_size() &&
|
|
|
|
"Number of private copies is not the same as the preallocated buffer");
|
|
|
|
std::copy(VL.begin(), VL.end(), varlist_end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPFirstprivateClause::setInits(ArrayRef<Expr *> VL) {
|
|
|
|
assert(VL.size() == varlist_size() &&
|
|
|
|
"Number of inits is not the same as the preallocated buffer");
|
|
|
|
std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPFirstprivateClause *
|
|
|
|
OMPFirstprivateClause::Create(const ASTContext &C, SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc, SourceLocation EndLoc,
|
|
|
|
ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
|
2016-02-17 21:19:37 +08:00
|
|
|
ArrayRef<Expr *> InitVL, Stmt *PreInit) {
|
2016-01-01 08:38:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
|
2015-10-02 21:41:04 +08:00
|
|
|
OMPFirstprivateClause *Clause =
|
|
|
|
new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
|
|
|
|
Clause->setVarRefs(VL);
|
|
|
|
Clause->setPrivateCopies(PrivateVL);
|
|
|
|
Clause->setInits(InitVL);
|
2016-02-17 21:19:37 +08:00
|
|
|
Clause->setPreInitStmt(PreInit);
|
2015-10-02 21:41:04 +08:00
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPFirstprivateClause *OMPFirstprivateClause::CreateEmpty(const ASTContext &C,
|
|
|
|
unsigned N) {
|
2016-01-01 08:38:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * N));
|
2015-10-02 21:41:04 +08:00
|
|
|
return new (Mem) OMPFirstprivateClause(N);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPLastprivateClause::setPrivateCopies(ArrayRef<Expr *> PrivateCopies) {
|
|
|
|
assert(PrivateCopies.size() == varlist_size() &&
|
|
|
|
"Number of private copies is not the same as the preallocated buffer");
|
|
|
|
std::copy(PrivateCopies.begin(), PrivateCopies.end(), varlist_end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPLastprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
|
|
|
|
assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
|
|
|
|
"not the same as the "
|
|
|
|
"preallocated buffer");
|
|
|
|
std::copy(SrcExprs.begin(), SrcExprs.end(), getPrivateCopies().end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPLastprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
|
|
|
|
assert(DstExprs.size() == varlist_size() && "Number of destination "
|
|
|
|
"expressions is not the same as "
|
|
|
|
"the preallocated buffer");
|
|
|
|
std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPLastprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
|
|
|
|
assert(AssignmentOps.size() == varlist_size() &&
|
|
|
|
"Number of assignment expressions is not the same as the preallocated "
|
|
|
|
"buffer");
|
|
|
|
std::copy(AssignmentOps.begin(), AssignmentOps.end(),
|
|
|
|
getDestinationExprs().end());
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPLastprivateClause *OMPLastprivateClause::Create(
|
|
|
|
const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
|
|
|
|
SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
|
2019-12-21 00:04:57 +08:00
|
|
|
ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps,
|
|
|
|
OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc,
|
|
|
|
SourceLocation ColonLoc, Stmt *PreInit, Expr *PostUpdate) {
|
2016-01-01 08:38:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
|
2019-12-21 00:04:57 +08:00
|
|
|
OMPLastprivateClause *Clause = new (Mem) OMPLastprivateClause(
|
|
|
|
StartLoc, LParenLoc, EndLoc, LPKind, LPKindLoc, ColonLoc, VL.size());
|
2015-10-02 21:41:04 +08:00
|
|
|
Clause->setVarRefs(VL);
|
|
|
|
Clause->setSourceExprs(SrcExprs);
|
|
|
|
Clause->setDestinationExprs(DstExprs);
|
|
|
|
Clause->setAssignmentOps(AssignmentOps);
|
2016-02-25 13:25:57 +08:00
|
|
|
Clause->setPreInitStmt(PreInit);
|
|
|
|
Clause->setPostUpdateExpr(PostUpdate);
|
2015-10-02 21:41:04 +08:00
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPLastprivateClause *OMPLastprivateClause::CreateEmpty(const ASTContext &C,
|
|
|
|
unsigned N) {
|
2016-01-01 08:38:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
|
2015-10-02 21:41:04 +08:00
|
|
|
return new (Mem) OMPLastprivateClause(N);
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPSharedClause *OMPSharedClause::Create(const ASTContext &C,
|
|
|
|
SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation EndLoc,
|
|
|
|
ArrayRef<Expr *> VL) {
|
2016-01-01 08:38:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
|
2015-10-02 21:41:04 +08:00
|
|
|
OMPSharedClause *Clause =
|
|
|
|
new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size());
|
|
|
|
Clause->setVarRefs(VL);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPSharedClause *OMPSharedClause::CreateEmpty(const ASTContext &C, unsigned N) {
|
2016-01-01 08:38:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
|
2015-10-02 21:41:04 +08:00
|
|
|
return new (Mem) OMPSharedClause(N);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPLinearClause::setPrivates(ArrayRef<Expr *> PL) {
|
|
|
|
assert(PL.size() == varlist_size() &&
|
|
|
|
"Number of privates is not the same as the preallocated buffer");
|
|
|
|
std::copy(PL.begin(), PL.end(), varlist_end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPLinearClause::setInits(ArrayRef<Expr *> IL) {
|
|
|
|
assert(IL.size() == varlist_size() &&
|
|
|
|
"Number of inits is not the same as the preallocated buffer");
|
|
|
|
std::copy(IL.begin(), IL.end(), getPrivates().end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPLinearClause::setUpdates(ArrayRef<Expr *> UL) {
|
|
|
|
assert(UL.size() == varlist_size() &&
|
|
|
|
"Number of updates is not the same as the preallocated buffer");
|
|
|
|
std::copy(UL.begin(), UL.end(), getInits().end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPLinearClause::setFinals(ArrayRef<Expr *> FL) {
|
|
|
|
assert(FL.size() == varlist_size() &&
|
|
|
|
"Number of final updates is not the same as the preallocated buffer");
|
|
|
|
std::copy(FL.begin(), FL.end(), getUpdates().end());
|
|
|
|
}
|
|
|
|
|
2019-08-08 21:42:45 +08:00
|
|
|
void OMPLinearClause::setUsedExprs(ArrayRef<Expr *> UE) {
|
|
|
|
assert(
|
|
|
|
UE.size() == varlist_size() + 1 &&
|
|
|
|
"Number of used expressions is not the same as the preallocated buffer");
|
|
|
|
std::copy(UE.begin(), UE.end(), getFinals().end() + 2);
|
|
|
|
}
|
|
|
|
|
2015-10-02 21:41:04 +08:00
|
|
|
OMPLinearClause *OMPLinearClause::Create(
|
|
|
|
const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
|
|
|
|
OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
|
|
|
|
SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
|
2016-03-09 17:49:00 +08:00
|
|
|
ArrayRef<Expr *> PL, ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep,
|
|
|
|
Stmt *PreInit, Expr *PostUpdate) {
|
2019-08-08 21:42:45 +08:00
|
|
|
// Allocate space for 5 lists (Vars, Inits, Updates, Finals), 2 expressions
|
|
|
|
// (Step and CalcStep), list of used expression + step.
|
|
|
|
void *Mem =
|
|
|
|
C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2 + VL.size() + 1));
|
2015-10-02 21:41:04 +08:00
|
|
|
OMPLinearClause *Clause = new (Mem) OMPLinearClause(
|
|
|
|
StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc, EndLoc, VL.size());
|
|
|
|
Clause->setVarRefs(VL);
|
|
|
|
Clause->setPrivates(PL);
|
|
|
|
Clause->setInits(IL);
|
|
|
|
// Fill update and final expressions with zeroes, they are provided later,
|
|
|
|
// after the directive construction.
|
|
|
|
std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(),
|
|
|
|
nullptr);
|
|
|
|
std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(),
|
|
|
|
nullptr);
|
2019-08-08 21:42:45 +08:00
|
|
|
std::fill(Clause->getUsedExprs().begin(), Clause->getUsedExprs().end(),
|
|
|
|
nullptr);
|
2015-10-02 21:41:04 +08:00
|
|
|
Clause->setStep(Step);
|
|
|
|
Clause->setCalcStep(CalcStep);
|
2016-03-09 17:49:00 +08:00
|
|
|
Clause->setPreInitStmt(PreInit);
|
|
|
|
Clause->setPostUpdateExpr(PostUpdate);
|
2015-10-02 21:41:04 +08:00
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPLinearClause *OMPLinearClause::CreateEmpty(const ASTContext &C,
|
|
|
|
unsigned NumVars) {
|
2019-08-08 21:42:45 +08:00
|
|
|
// Allocate space for 5 lists (Vars, Inits, Updates, Finals), 2 expressions
|
|
|
|
// (Step and CalcStep), list of used expression + step.
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2 + NumVars +1));
|
2015-10-02 21:41:04 +08:00
|
|
|
return new (Mem) OMPLinearClause(NumVars);
|
|
|
|
}
|
|
|
|
|
2019-08-08 21:42:45 +08:00
|
|
|
OMPClause::child_range OMPLinearClause::used_children() {
|
|
|
|
// Range includes only non-nullptr elements.
|
|
|
|
return child_range(
|
|
|
|
reinterpret_cast<Stmt **>(getUsedExprs().begin()),
|
|
|
|
reinterpret_cast<Stmt **>(llvm::find(getUsedExprs(), nullptr)));
|
|
|
|
}
|
|
|
|
|
2015-10-02 21:41:04 +08:00
|
|
|
OMPAlignedClause *
|
|
|
|
OMPAlignedClause::Create(const ASTContext &C, SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc, SourceLocation ColonLoc,
|
|
|
|
SourceLocation EndLoc, ArrayRef<Expr *> VL, Expr *A) {
|
2016-01-01 08:38:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
|
2015-10-02 21:41:04 +08:00
|
|
|
OMPAlignedClause *Clause = new (Mem)
|
|
|
|
OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size());
|
|
|
|
Clause->setVarRefs(VL);
|
|
|
|
Clause->setAlignment(A);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPAlignedClause *OMPAlignedClause::CreateEmpty(const ASTContext &C,
|
|
|
|
unsigned NumVars) {
|
2016-01-01 08:38:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1));
|
2015-10-02 21:41:04 +08:00
|
|
|
return new (Mem) OMPAlignedClause(NumVars);
|
|
|
|
}
|
|
|
|
|
2021-11-09 20:33:39 +08:00
|
|
|
OMPAlignClause *OMPAlignClause::Create(const ASTContext &C, Expr *A,
|
|
|
|
SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation EndLoc) {
|
|
|
|
return new (C) OMPAlignClause(A, StartLoc, LParenLoc, EndLoc);
|
|
|
|
}
|
|
|
|
|
2015-10-02 21:41:04 +08:00
|
|
|
void OMPCopyinClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
|
|
|
|
assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
|
|
|
|
"not the same as the "
|
|
|
|
"preallocated buffer");
|
|
|
|
std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPCopyinClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
|
|
|
|
assert(DstExprs.size() == varlist_size() && "Number of destination "
|
|
|
|
"expressions is not the same as "
|
|
|
|
"the preallocated buffer");
|
|
|
|
std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPCopyinClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
|
|
|
|
assert(AssignmentOps.size() == varlist_size() &&
|
|
|
|
"Number of assignment expressions is not the same as the preallocated "
|
|
|
|
"buffer");
|
|
|
|
std::copy(AssignmentOps.begin(), AssignmentOps.end(),
|
|
|
|
getDestinationExprs().end());
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPCopyinClause *OMPCopyinClause::Create(
|
|
|
|
const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
|
|
|
|
SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
|
|
|
|
ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
|
2016-01-01 08:38:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
|
2015-10-02 21:41:04 +08:00
|
|
|
OMPCopyinClause *Clause =
|
|
|
|
new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size());
|
|
|
|
Clause->setVarRefs(VL);
|
|
|
|
Clause->setSourceExprs(SrcExprs);
|
|
|
|
Clause->setDestinationExprs(DstExprs);
|
|
|
|
Clause->setAssignmentOps(AssignmentOps);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPCopyinClause *OMPCopyinClause::CreateEmpty(const ASTContext &C, unsigned N) {
|
2016-01-01 08:38:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
|
2015-10-02 21:41:04 +08:00
|
|
|
return new (Mem) OMPCopyinClause(N);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPCopyprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
|
|
|
|
assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
|
|
|
|
"not the same as the "
|
|
|
|
"preallocated buffer");
|
|
|
|
std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPCopyprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
|
|
|
|
assert(DstExprs.size() == varlist_size() && "Number of destination "
|
|
|
|
"expressions is not the same as "
|
|
|
|
"the preallocated buffer");
|
|
|
|
std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPCopyprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
|
|
|
|
assert(AssignmentOps.size() == varlist_size() &&
|
|
|
|
"Number of assignment expressions is not the same as the preallocated "
|
|
|
|
"buffer");
|
|
|
|
std::copy(AssignmentOps.begin(), AssignmentOps.end(),
|
|
|
|
getDestinationExprs().end());
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPCopyprivateClause *OMPCopyprivateClause::Create(
|
|
|
|
const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
|
|
|
|
SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
|
|
|
|
ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
|
2016-01-01 08:38:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
|
2015-10-02 21:41:04 +08:00
|
|
|
OMPCopyprivateClause *Clause =
|
|
|
|
new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
|
|
|
|
Clause->setVarRefs(VL);
|
|
|
|
Clause->setSourceExprs(SrcExprs);
|
|
|
|
Clause->setDestinationExprs(DstExprs);
|
|
|
|
Clause->setAssignmentOps(AssignmentOps);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPCopyprivateClause *OMPCopyprivateClause::CreateEmpty(const ASTContext &C,
|
|
|
|
unsigned N) {
|
2016-01-01 08:38:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
|
2015-10-02 21:41:04 +08:00
|
|
|
return new (Mem) OMPCopyprivateClause(N);
|
|
|
|
}
|
|
|
|
|
2015-10-08 17:10:53 +08:00
|
|
|
void OMPReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
|
|
|
|
assert(Privates.size() == varlist_size() &&
|
|
|
|
"Number of private copies is not the same as the preallocated buffer");
|
|
|
|
std::copy(Privates.begin(), Privates.end(), varlist_end());
|
|
|
|
}
|
|
|
|
|
2015-10-02 21:41:04 +08:00
|
|
|
void OMPReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
|
|
|
|
assert(
|
|
|
|
LHSExprs.size() == varlist_size() &&
|
|
|
|
"Number of LHS expressions is not the same as the preallocated buffer");
|
2015-10-08 17:10:53 +08:00
|
|
|
std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
|
2015-10-02 21:41:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OMPReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
|
|
|
|
assert(
|
|
|
|
RHSExprs.size() == varlist_size() &&
|
|
|
|
"Number of RHS expressions is not the same as the preallocated buffer");
|
|
|
|
std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
|
|
|
|
assert(ReductionOps.size() == varlist_size() && "Number of reduction "
|
|
|
|
"expressions is not the same "
|
|
|
|
"as the preallocated buffer");
|
|
|
|
std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
|
|
|
|
}
|
|
|
|
|
2020-05-05 04:19:31 +08:00
|
|
|
void OMPReductionClause::setInscanCopyOps(ArrayRef<Expr *> Ops) {
|
|
|
|
assert(Modifier == OMPC_REDUCTION_inscan && "Expected inscan reduction.");
|
|
|
|
assert(Ops.size() == varlist_size() && "Number of copy "
|
|
|
|
"expressions is not the same "
|
|
|
|
"as the preallocated buffer");
|
|
|
|
llvm::copy(Ops, getReductionOps().end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPReductionClause::setInscanCopyArrayTemps(
|
|
|
|
ArrayRef<Expr *> CopyArrayTemps) {
|
|
|
|
assert(Modifier == OMPC_REDUCTION_inscan && "Expected inscan reduction.");
|
|
|
|
assert(CopyArrayTemps.size() == varlist_size() &&
|
|
|
|
"Number of copy temp expressions is not the same as the preallocated "
|
|
|
|
"buffer");
|
|
|
|
llvm::copy(CopyArrayTemps, getInscanCopyOps().end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPReductionClause::setInscanCopyArrayElems(
|
|
|
|
ArrayRef<Expr *> CopyArrayElems) {
|
|
|
|
assert(Modifier == OMPC_REDUCTION_inscan && "Expected inscan reduction.");
|
|
|
|
assert(CopyArrayElems.size() == varlist_size() &&
|
|
|
|
"Number of copy temp expressions is not the same as the preallocated "
|
|
|
|
"buffer");
|
|
|
|
llvm::copy(CopyArrayElems, getInscanCopyArrayTemps().end());
|
|
|
|
}
|
|
|
|
|
2015-10-02 21:41:04 +08:00
|
|
|
OMPReductionClause *OMPReductionClause::Create(
|
|
|
|
const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
|
2020-03-24 05:30:38 +08:00
|
|
|
SourceLocation ModifierLoc, SourceLocation EndLoc, SourceLocation ColonLoc,
|
|
|
|
OpenMPReductionClauseModifier Modifier, ArrayRef<Expr *> VL,
|
2015-10-02 21:41:04 +08:00
|
|
|
NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
|
2015-10-08 17:10:53 +08:00
|
|
|
ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
|
2020-05-05 04:19:31 +08:00
|
|
|
ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps,
|
|
|
|
ArrayRef<Expr *> CopyOps, ArrayRef<Expr *> CopyArrayTemps,
|
|
|
|
ArrayRef<Expr *> CopyArrayElems, Stmt *PreInit, Expr *PostUpdate) {
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(
|
|
|
|
(Modifier == OMPC_REDUCTION_inscan ? 8 : 5) * VL.size()));
|
2020-03-24 05:30:38 +08:00
|
|
|
auto *Clause = new (Mem)
|
|
|
|
OMPReductionClause(StartLoc, LParenLoc, ModifierLoc, EndLoc, ColonLoc,
|
|
|
|
Modifier, VL.size(), QualifierLoc, NameInfo);
|
2015-10-02 21:41:04 +08:00
|
|
|
Clause->setVarRefs(VL);
|
2015-10-08 17:10:53 +08:00
|
|
|
Clause->setPrivates(Privates);
|
2015-10-02 21:41:04 +08:00
|
|
|
Clause->setLHSExprs(LHSExprs);
|
|
|
|
Clause->setRHSExprs(RHSExprs);
|
|
|
|
Clause->setReductionOps(ReductionOps);
|
2016-03-02 12:57:40 +08:00
|
|
|
Clause->setPreInitStmt(PreInit);
|
|
|
|
Clause->setPostUpdateExpr(PostUpdate);
|
2020-05-05 04:19:31 +08:00
|
|
|
if (Modifier == OMPC_REDUCTION_inscan) {
|
|
|
|
Clause->setInscanCopyOps(CopyOps);
|
|
|
|
Clause->setInscanCopyArrayTemps(CopyArrayTemps);
|
|
|
|
Clause->setInscanCopyArrayElems(CopyArrayElems);
|
|
|
|
} else {
|
|
|
|
assert(CopyOps.empty() &&
|
|
|
|
"copy operations are expected in inscan reductions only.");
|
|
|
|
assert(CopyArrayTemps.empty() &&
|
|
|
|
"copy array temps are expected in inscan reductions only.");
|
|
|
|
assert(CopyArrayElems.empty() &&
|
|
|
|
"copy array temps are expected in inscan reductions only.");
|
|
|
|
}
|
2015-10-02 21:41:04 +08:00
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
2020-05-05 04:19:31 +08:00
|
|
|
OMPReductionClause *
|
|
|
|
OMPReductionClause::CreateEmpty(const ASTContext &C, unsigned N,
|
|
|
|
OpenMPReductionClauseModifier Modifier) {
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(
|
|
|
|
(Modifier == OMPC_REDUCTION_inscan ? 8 : 5) * N));
|
|
|
|
auto *Clause = new (Mem) OMPReductionClause(N);
|
|
|
|
Clause->setModifier(Modifier);
|
|
|
|
return Clause;
|
2015-10-02 21:41:04 +08:00
|
|
|
}
|
|
|
|
|
2017-07-19 04:17:46 +08:00
|
|
|
void OMPTaskReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
|
|
|
|
assert(Privates.size() == varlist_size() &&
|
|
|
|
"Number of private copies is not the same as the preallocated buffer");
|
|
|
|
std::copy(Privates.begin(), Privates.end(), varlist_end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPTaskReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
|
|
|
|
assert(
|
|
|
|
LHSExprs.size() == varlist_size() &&
|
|
|
|
"Number of LHS expressions is not the same as the preallocated buffer");
|
|
|
|
std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPTaskReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
|
|
|
|
assert(
|
|
|
|
RHSExprs.size() == varlist_size() &&
|
|
|
|
"Number of RHS expressions is not the same as the preallocated buffer");
|
|
|
|
std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPTaskReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
|
|
|
|
assert(ReductionOps.size() == varlist_size() && "Number of task reduction "
|
|
|
|
"expressions is not the same "
|
|
|
|
"as the preallocated buffer");
|
|
|
|
std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPTaskReductionClause *OMPTaskReductionClause::Create(
|
|
|
|
const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
|
|
|
|
SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
|
|
|
|
NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
|
|
|
|
ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
|
|
|
|
ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit,
|
|
|
|
Expr *PostUpdate) {
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
|
|
|
|
OMPTaskReductionClause *Clause = new (Mem) OMPTaskReductionClause(
|
|
|
|
StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
|
|
|
|
Clause->setVarRefs(VL);
|
|
|
|
Clause->setPrivates(Privates);
|
|
|
|
Clause->setLHSExprs(LHSExprs);
|
|
|
|
Clause->setRHSExprs(RHSExprs);
|
|
|
|
Clause->setReductionOps(ReductionOps);
|
|
|
|
Clause->setPreInitStmt(PreInit);
|
|
|
|
Clause->setPostUpdateExpr(PostUpdate);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPTaskReductionClause *OMPTaskReductionClause::CreateEmpty(const ASTContext &C,
|
|
|
|
unsigned N) {
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
|
|
|
|
return new (Mem) OMPTaskReductionClause(N);
|
|
|
|
}
|
|
|
|
|
2017-07-22 02:48:21 +08:00
|
|
|
void OMPInReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
|
|
|
|
assert(Privates.size() == varlist_size() &&
|
|
|
|
"Number of private copies is not the same as the preallocated buffer");
|
|
|
|
std::copy(Privates.begin(), Privates.end(), varlist_end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPInReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
|
|
|
|
assert(
|
|
|
|
LHSExprs.size() == varlist_size() &&
|
|
|
|
"Number of LHS expressions is not the same as the preallocated buffer");
|
|
|
|
std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPInReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
|
|
|
|
assert(
|
|
|
|
RHSExprs.size() == varlist_size() &&
|
|
|
|
"Number of RHS expressions is not the same as the preallocated buffer");
|
|
|
|
std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPInReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
|
|
|
|
assert(ReductionOps.size() == varlist_size() && "Number of in reduction "
|
|
|
|
"expressions is not the same "
|
|
|
|
"as the preallocated buffer");
|
|
|
|
std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
|
|
|
|
}
|
|
|
|
|
2017-07-27 21:20:36 +08:00
|
|
|
void OMPInReductionClause::setTaskgroupDescriptors(
|
|
|
|
ArrayRef<Expr *> TaskgroupDescriptors) {
|
|
|
|
assert(TaskgroupDescriptors.size() == varlist_size() &&
|
|
|
|
"Number of in reduction descriptors is not the same as the "
|
|
|
|
"preallocated buffer");
|
|
|
|
std::copy(TaskgroupDescriptors.begin(), TaskgroupDescriptors.end(),
|
|
|
|
getReductionOps().end());
|
|
|
|
}
|
|
|
|
|
2017-07-22 02:48:21 +08:00
|
|
|
OMPInReductionClause *OMPInReductionClause::Create(
|
|
|
|
const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
|
|
|
|
SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
|
|
|
|
NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
|
|
|
|
ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
|
2017-07-27 21:20:36 +08:00
|
|
|
ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps,
|
|
|
|
ArrayRef<Expr *> TaskgroupDescriptors, Stmt *PreInit, Expr *PostUpdate) {
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * VL.size()));
|
2017-07-22 02:48:21 +08:00
|
|
|
OMPInReductionClause *Clause = new (Mem) OMPInReductionClause(
|
|
|
|
StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
|
|
|
|
Clause->setVarRefs(VL);
|
|
|
|
Clause->setPrivates(Privates);
|
|
|
|
Clause->setLHSExprs(LHSExprs);
|
|
|
|
Clause->setRHSExprs(RHSExprs);
|
|
|
|
Clause->setReductionOps(ReductionOps);
|
2017-07-27 21:20:36 +08:00
|
|
|
Clause->setTaskgroupDescriptors(TaskgroupDescriptors);
|
2017-07-22 02:48:21 +08:00
|
|
|
Clause->setPreInitStmt(PreInit);
|
|
|
|
Clause->setPostUpdateExpr(PostUpdate);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPInReductionClause *OMPInReductionClause::CreateEmpty(const ASTContext &C,
|
|
|
|
unsigned N) {
|
2017-07-27 21:20:36 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * N));
|
2017-07-22 02:48:21 +08:00
|
|
|
return new (Mem) OMPInReductionClause(N);
|
|
|
|
}
|
|
|
|
|
2021-02-13 03:26:59 +08:00
|
|
|
OMPSizesClause *OMPSizesClause::Create(const ASTContext &C,
|
|
|
|
SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation EndLoc,
|
|
|
|
ArrayRef<Expr *> Sizes) {
|
|
|
|
OMPSizesClause *Clause = CreateEmpty(C, Sizes.size());
|
|
|
|
Clause->setLocStart(StartLoc);
|
|
|
|
Clause->setLParenLoc(LParenLoc);
|
|
|
|
Clause->setLocEnd(EndLoc);
|
|
|
|
Clause->setSizesRefs(Sizes);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPSizesClause *OMPSizesClause::CreateEmpty(const ASTContext &C,
|
|
|
|
unsigned NumSizes) {
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumSizes));
|
|
|
|
return new (Mem) OMPSizesClause(NumSizes);
|
|
|
|
}
|
|
|
|
|
2021-06-11 03:24:17 +08:00
|
|
|
OMPFullClause *OMPFullClause::Create(const ASTContext &C,
|
|
|
|
SourceLocation StartLoc,
|
|
|
|
SourceLocation EndLoc) {
|
|
|
|
OMPFullClause *Clause = CreateEmpty(C);
|
|
|
|
Clause->setLocStart(StartLoc);
|
|
|
|
Clause->setLocEnd(EndLoc);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPFullClause *OMPFullClause::CreateEmpty(const ASTContext &C) {
|
|
|
|
return new (C) OMPFullClause();
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPPartialClause *OMPPartialClause::Create(const ASTContext &C,
|
|
|
|
SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation EndLoc,
|
|
|
|
Expr *Factor) {
|
|
|
|
OMPPartialClause *Clause = CreateEmpty(C);
|
|
|
|
Clause->setLocStart(StartLoc);
|
|
|
|
Clause->setLParenLoc(LParenLoc);
|
|
|
|
Clause->setLocEnd(EndLoc);
|
|
|
|
Clause->setFactor(Factor);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPPartialClause *OMPPartialClause::CreateEmpty(const ASTContext &C) {
|
|
|
|
return new (C) OMPPartialClause();
|
|
|
|
}
|
|
|
|
|
2019-03-27 22:14:31 +08:00
|
|
|
OMPAllocateClause *
|
|
|
|
OMPAllocateClause::Create(const ASTContext &C, SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc, Expr *Allocator,
|
|
|
|
SourceLocation ColonLoc, SourceLocation EndLoc,
|
|
|
|
ArrayRef<Expr *> VL) {
|
|
|
|
// Allocate space for private variables and initializer expressions.
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
|
|
|
|
auto *Clause = new (Mem) OMPAllocateClause(StartLoc, LParenLoc, Allocator,
|
|
|
|
ColonLoc, EndLoc, VL.size());
|
|
|
|
Clause->setVarRefs(VL);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPAllocateClause *OMPAllocateClause::CreateEmpty(const ASTContext &C,
|
|
|
|
unsigned N) {
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
|
|
|
|
return new (Mem) OMPAllocateClause(N);
|
|
|
|
}
|
|
|
|
|
2015-10-02 21:41:04 +08:00
|
|
|
OMPFlushClause *OMPFlushClause::Create(const ASTContext &C,
|
|
|
|
SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation EndLoc,
|
|
|
|
ArrayRef<Expr *> VL) {
|
2016-05-25 20:36:08 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
|
2015-10-02 21:41:04 +08:00
|
|
|
OMPFlushClause *Clause =
|
|
|
|
new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size());
|
|
|
|
Clause->setVarRefs(VL);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPFlushClause *OMPFlushClause::CreateEmpty(const ASTContext &C, unsigned N) {
|
2016-01-01 08:38:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
|
2015-10-02 21:41:04 +08:00
|
|
|
return new (Mem) OMPFlushClause(N);
|
|
|
|
}
|
|
|
|
|
2020-02-28 22:52:15 +08:00
|
|
|
OMPDepobjClause *OMPDepobjClause::Create(const ASTContext &C,
|
|
|
|
SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation RParenLoc,
|
|
|
|
Expr *Depobj) {
|
|
|
|
auto *Clause = new (C) OMPDepobjClause(StartLoc, LParenLoc, RParenLoc);
|
|
|
|
Clause->setDepobj(Depobj);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPDepobjClause *OMPDepobjClause::CreateEmpty(const ASTContext &C) {
|
|
|
|
return new (C) OMPDepobjClause();
|
|
|
|
}
|
|
|
|
|
2018-08-14 03:04:24 +08:00
|
|
|
OMPDependClause *
|
|
|
|
OMPDependClause::Create(const ASTContext &C, SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc, SourceLocation EndLoc,
|
2020-04-02 03:06:38 +08:00
|
|
|
Expr *DepModifier, OpenMPDependClauseKind DepKind,
|
|
|
|
SourceLocation DepLoc, SourceLocation ColonLoc,
|
|
|
|
ArrayRef<Expr *> VL, unsigned NumLoops) {
|
|
|
|
void *Mem = C.Allocate(
|
|
|
|
totalSizeToAlloc<Expr *>(VL.size() + /*depend-modifier*/ 1 + NumLoops),
|
|
|
|
alignof(OMPDependClause));
|
2018-08-14 03:04:24 +08:00
|
|
|
OMPDependClause *Clause = new (Mem)
|
|
|
|
OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size(), NumLoops);
|
2015-10-02 21:41:04 +08:00
|
|
|
Clause->setVarRefs(VL);
|
|
|
|
Clause->setDependencyKind(DepKind);
|
|
|
|
Clause->setDependencyLoc(DepLoc);
|
|
|
|
Clause->setColonLoc(ColonLoc);
|
2020-04-02 03:06:38 +08:00
|
|
|
Clause->setModifier(DepModifier);
|
2018-08-14 03:04:24 +08:00
|
|
|
for (unsigned I = 0 ; I < NumLoops; ++I)
|
|
|
|
Clause->setLoopData(I, nullptr);
|
2015-10-02 21:41:04 +08:00
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
2018-08-14 03:04:24 +08:00
|
|
|
OMPDependClause *OMPDependClause::CreateEmpty(const ASTContext &C, unsigned N,
|
|
|
|
unsigned NumLoops) {
|
2020-04-02 03:06:38 +08:00
|
|
|
void *Mem =
|
|
|
|
C.Allocate(totalSizeToAlloc<Expr *>(N + /*depend-modifier*/ 1 + NumLoops),
|
|
|
|
alignof(OMPDependClause));
|
2018-08-14 03:04:24 +08:00
|
|
|
return new (Mem) OMPDependClause(N, NumLoops);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPDependClause::setLoopData(unsigned NumLoop, Expr *Cnt) {
|
|
|
|
assert((getDependencyKind() == OMPC_DEPEND_sink ||
|
|
|
|
getDependencyKind() == OMPC_DEPEND_source) &&
|
|
|
|
NumLoop < NumLoops &&
|
|
|
|
"Expected sink or source depend + loop index must be less number of "
|
|
|
|
"loops.");
|
2020-04-02 03:06:38 +08:00
|
|
|
auto *It = std::next(getVarRefs().end(), NumLoop + 1);
|
2018-08-14 03:04:24 +08:00
|
|
|
*It = Cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
Expr *OMPDependClause::getLoopData(unsigned NumLoop) {
|
|
|
|
assert((getDependencyKind() == OMPC_DEPEND_sink ||
|
|
|
|
getDependencyKind() == OMPC_DEPEND_source) &&
|
|
|
|
NumLoop < NumLoops &&
|
|
|
|
"Expected sink or source depend + loop index must be less number of "
|
|
|
|
"loops.");
|
2020-04-02 03:06:38 +08:00
|
|
|
auto *It = std::next(getVarRefs().end(), NumLoop + 1);
|
2018-08-14 03:04:24 +08:00
|
|
|
return *It;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Expr *OMPDependClause::getLoopData(unsigned NumLoop) const {
|
|
|
|
assert((getDependencyKind() == OMPC_DEPEND_sink ||
|
|
|
|
getDependencyKind() == OMPC_DEPEND_source) &&
|
|
|
|
NumLoop < NumLoops &&
|
|
|
|
"Expected sink or source depend + loop index must be less number of "
|
|
|
|
"loops.");
|
2020-04-02 03:06:38 +08:00
|
|
|
const auto *It = std::next(getVarRefs().end(), NumLoop + 1);
|
2018-08-14 03:04:24 +08:00
|
|
|
return *It;
|
2016-05-25 20:36:08 +08:00
|
|
|
}
|
|
|
|
|
2020-04-02 03:06:38 +08:00
|
|
|
void OMPDependClause::setModifier(Expr *DepModifier) {
|
|
|
|
*getVarRefs().end() = DepModifier;
|
|
|
|
}
|
|
|
|
Expr *OMPDependClause::getModifier() { return *getVarRefs().end(); }
|
|
|
|
|
2016-04-26 22:54:23 +08:00
|
|
|
unsigned OMPClauseMappableExprCommon::getComponentsTotalNumber(
|
|
|
|
MappableExprComponentListsRef ComponentLists) {
|
|
|
|
unsigned TotalNum = 0u;
|
|
|
|
for (auto &C : ComponentLists)
|
|
|
|
TotalNum += C.size();
|
|
|
|
return TotalNum;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned OMPClauseMappableExprCommon::getUniqueDeclarationsTotalNumber(
|
2018-04-18 23:57:46 +08:00
|
|
|
ArrayRef<const ValueDecl *> Declarations) {
|
2016-04-26 22:54:23 +08:00
|
|
|
unsigned TotalNum = 0u;
|
|
|
|
llvm::SmallPtrSet<const ValueDecl *, 8> Cache;
|
2018-04-18 23:57:46 +08:00
|
|
|
for (const ValueDecl *D : Declarations) {
|
2016-04-26 22:54:23 +08:00
|
|
|
const ValueDecl *VD = D ? cast<ValueDecl>(D->getCanonicalDecl()) : nullptr;
|
|
|
|
if (Cache.count(VD))
|
|
|
|
continue;
|
|
|
|
++TotalNum;
|
|
|
|
Cache.insert(VD);
|
|
|
|
}
|
|
|
|
return TotalNum;
|
|
|
|
}
|
|
|
|
|
2019-02-20 00:38:20 +08:00
|
|
|
OMPMapClause *OMPMapClause::Create(
|
|
|
|
const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
|
|
|
|
ArrayRef<ValueDecl *> Declarations,
|
|
|
|
MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs,
|
|
|
|
ArrayRef<OpenMPMapModifierKind> MapModifiers,
|
|
|
|
ArrayRef<SourceLocation> MapModifiersLoc,
|
|
|
|
NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId,
|
|
|
|
OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc) {
|
|
|
|
OMPMappableExprListSizeTy Sizes;
|
|
|
|
Sizes.NumVars = Vars.size();
|
|
|
|
Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
|
|
|
|
Sizes.NumComponentLists = ComponentLists.size();
|
|
|
|
Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
|
2016-04-26 22:54:23 +08:00
|
|
|
|
|
|
|
// We need to allocate:
|
2019-02-20 00:38:20 +08:00
|
|
|
// 2 x NumVars x Expr* - we have an original list expression and an associated
|
|
|
|
// user-defined mapper for each clause list entry.
|
2016-04-26 22:54:23 +08:00
|
|
|
// NumUniqueDeclarations x ValueDecl* - unique base declarations associated
|
|
|
|
// with each component list.
|
|
|
|
// (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
|
|
|
|
// number of lists for each unique declaration and the size of each component
|
|
|
|
// list.
|
|
|
|
// NumComponents x MappableComponent - the total of all the components in all
|
|
|
|
// the lists.
|
|
|
|
void *Mem = C.Allocate(
|
|
|
|
totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
|
|
|
|
OMPClauseMappableExprCommon::MappableComponent>(
|
2019-02-20 00:38:20 +08:00
|
|
|
2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
|
|
|
|
Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
|
|
|
|
Sizes.NumComponents));
|
|
|
|
OMPMapClause *Clause = new (Mem)
|
|
|
|
OMPMapClause(MapModifiers, MapModifiersLoc, UDMQualifierLoc, MapperId,
|
|
|
|
Type, TypeIsImplicit, TypeLoc, Locs, Sizes);
|
2016-04-26 22:54:23 +08:00
|
|
|
|
|
|
|
Clause->setVarRefs(Vars);
|
2019-02-20 00:38:20 +08:00
|
|
|
Clause->setUDMapperRefs(UDMapperRefs);
|
2016-04-26 22:54:23 +08:00
|
|
|
Clause->setClauseInfo(Declarations, ComponentLists);
|
2015-11-23 13:32:03 +08:00
|
|
|
Clause->setMapType(Type);
|
|
|
|
Clause->setMapLoc(TypeLoc);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
2019-02-20 00:38:20 +08:00
|
|
|
OMPMapClause *
|
|
|
|
OMPMapClause::CreateEmpty(const ASTContext &C,
|
|
|
|
const OMPMappableExprListSizeTy &Sizes) {
|
2016-04-26 22:54:23 +08:00
|
|
|
void *Mem = C.Allocate(
|
|
|
|
totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
|
|
|
|
OMPClauseMappableExprCommon::MappableComponent>(
|
2019-02-20 00:38:20 +08:00
|
|
|
2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
|
|
|
|
Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
|
|
|
|
Sizes.NumComponents));
|
|
|
|
return new (Mem) OMPMapClause(Sizes);
|
2015-11-23 13:32:03 +08:00
|
|
|
}
|
2016-05-27 01:39:58 +08:00
|
|
|
|
2019-02-23 06:29:42 +08:00
|
|
|
OMPToClause *OMPToClause::Create(
|
|
|
|
const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
|
|
|
|
ArrayRef<ValueDecl *> Declarations,
|
|
|
|
MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs,
|
2020-07-30 00:18:45 +08:00
|
|
|
ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
|
|
|
|
ArrayRef<SourceLocation> MotionModifiersLoc,
|
2019-02-23 06:29:42 +08:00
|
|
|
NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId) {
|
2019-02-20 00:38:20 +08:00
|
|
|
OMPMappableExprListSizeTy Sizes;
|
|
|
|
Sizes.NumVars = Vars.size();
|
|
|
|
Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
|
|
|
|
Sizes.NumComponentLists = ComponentLists.size();
|
|
|
|
Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
|
2016-05-27 01:39:58 +08:00
|
|
|
|
|
|
|
// We need to allocate:
|
2019-02-23 06:29:42 +08:00
|
|
|
// 2 x NumVars x Expr* - we have an original list expression and an associated
|
|
|
|
// user-defined mapper for each clause list entry.
|
2016-05-27 01:39:58 +08:00
|
|
|
// NumUniqueDeclarations x ValueDecl* - unique base declarations associated
|
|
|
|
// with each component list.
|
|
|
|
// (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
|
|
|
|
// number of lists for each unique declaration and the size of each component
|
|
|
|
// list.
|
|
|
|
// NumComponents x MappableComponent - the total of all the components in all
|
|
|
|
// the lists.
|
|
|
|
void *Mem = C.Allocate(
|
|
|
|
totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
|
|
|
|
OMPClauseMappableExprCommon::MappableComponent>(
|
2019-02-23 06:29:42 +08:00
|
|
|
2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
|
2019-02-20 00:38:20 +08:00
|
|
|
Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
|
|
|
|
Sizes.NumComponents));
|
2016-05-27 01:39:58 +08:00
|
|
|
|
2020-07-30 00:18:45 +08:00
|
|
|
auto *Clause = new (Mem) OMPToClause(MotionModifiers, MotionModifiersLoc,
|
|
|
|
UDMQualifierLoc, MapperId, Locs, Sizes);
|
2016-05-27 01:39:58 +08:00
|
|
|
|
|
|
|
Clause->setVarRefs(Vars);
|
2019-02-23 06:29:42 +08:00
|
|
|
Clause->setUDMapperRefs(UDMapperRefs);
|
2016-05-27 01:39:58 +08:00
|
|
|
Clause->setClauseInfo(Declarations, ComponentLists);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
2019-02-20 00:38:20 +08:00
|
|
|
OMPToClause *OMPToClause::CreateEmpty(const ASTContext &C,
|
|
|
|
const OMPMappableExprListSizeTy &Sizes) {
|
2016-05-27 01:39:58 +08:00
|
|
|
void *Mem = C.Allocate(
|
|
|
|
totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
|
|
|
|
OMPClauseMappableExprCommon::MappableComponent>(
|
2019-02-23 06:29:42 +08:00
|
|
|
2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
|
2019-02-20 00:38:20 +08:00
|
|
|
Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
|
|
|
|
Sizes.NumComponents));
|
|
|
|
return new (Mem) OMPToClause(Sizes);
|
2016-05-27 01:39:58 +08:00
|
|
|
}
|
2016-05-27 01:49:04 +08:00
|
|
|
|
2019-02-26 04:34:15 +08:00
|
|
|
OMPFromClause *OMPFromClause::Create(
|
|
|
|
const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
|
|
|
|
ArrayRef<ValueDecl *> Declarations,
|
|
|
|
MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs,
|
2020-07-30 00:18:45 +08:00
|
|
|
ArrayRef<OpenMPMotionModifierKind> MotionModifiers,
|
|
|
|
ArrayRef<SourceLocation> MotionModifiersLoc,
|
2019-02-26 04:34:15 +08:00
|
|
|
NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId) {
|
2019-02-20 00:38:20 +08:00
|
|
|
OMPMappableExprListSizeTy Sizes;
|
|
|
|
Sizes.NumVars = Vars.size();
|
|
|
|
Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
|
|
|
|
Sizes.NumComponentLists = ComponentLists.size();
|
|
|
|
Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
|
2016-05-27 01:49:04 +08:00
|
|
|
|
|
|
|
// We need to allocate:
|
2019-02-26 04:34:15 +08:00
|
|
|
// 2 x NumVars x Expr* - we have an original list expression and an associated
|
|
|
|
// user-defined mapper for each clause list entry.
|
2016-05-27 01:49:04 +08:00
|
|
|
// NumUniqueDeclarations x ValueDecl* - unique base declarations associated
|
|
|
|
// with each component list.
|
|
|
|
// (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
|
|
|
|
// number of lists for each unique declaration and the size of each component
|
|
|
|
// list.
|
|
|
|
// NumComponents x MappableComponent - the total of all the components in all
|
|
|
|
// the lists.
|
|
|
|
void *Mem = C.Allocate(
|
|
|
|
totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
|
|
|
|
OMPClauseMappableExprCommon::MappableComponent>(
|
2019-02-26 04:34:15 +08:00
|
|
|
2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
|
2019-02-20 00:38:20 +08:00
|
|
|
Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
|
|
|
|
Sizes.NumComponents));
|
2016-05-27 01:49:04 +08:00
|
|
|
|
2019-02-26 04:34:15 +08:00
|
|
|
auto *Clause =
|
2020-07-30 00:18:45 +08:00
|
|
|
new (Mem) OMPFromClause(MotionModifiers, MotionModifiersLoc,
|
|
|
|
UDMQualifierLoc, MapperId, Locs, Sizes);
|
2016-05-27 01:49:04 +08:00
|
|
|
|
|
|
|
Clause->setVarRefs(Vars);
|
2019-02-26 04:34:15 +08:00
|
|
|
Clause->setUDMapperRefs(UDMapperRefs);
|
2016-05-27 01:49:04 +08:00
|
|
|
Clause->setClauseInfo(Declarations, ComponentLists);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
2019-02-20 00:38:20 +08:00
|
|
|
OMPFromClause *
|
|
|
|
OMPFromClause::CreateEmpty(const ASTContext &C,
|
|
|
|
const OMPMappableExprListSizeTy &Sizes) {
|
2016-05-27 01:49:04 +08:00
|
|
|
void *Mem = C.Allocate(
|
|
|
|
totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
|
|
|
|
OMPClauseMappableExprCommon::MappableComponent>(
|
2019-02-26 04:34:15 +08:00
|
|
|
2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
|
2019-02-20 00:38:20 +08:00
|
|
|
Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
|
|
|
|
Sizes.NumComponents));
|
|
|
|
return new (Mem) OMPFromClause(Sizes);
|
2016-05-27 01:49:04 +08:00
|
|
|
}
|
2016-07-13 23:37:16 +08:00
|
|
|
|
2016-07-28 22:23:26 +08:00
|
|
|
void OMPUseDevicePtrClause::setPrivateCopies(ArrayRef<Expr *> VL) {
|
|
|
|
assert(VL.size() == varlist_size() &&
|
|
|
|
"Number of private copies is not the same as the preallocated buffer");
|
|
|
|
std::copy(VL.begin(), VL.end(), varlist_end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPUseDevicePtrClause::setInits(ArrayRef<Expr *> VL) {
|
|
|
|
assert(VL.size() == varlist_size() &&
|
|
|
|
"Number of inits is not the same as the preallocated buffer");
|
|
|
|
std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPUseDevicePtrClause *OMPUseDevicePtrClause::Create(
|
2019-02-20 00:38:20 +08:00
|
|
|
const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
|
|
|
|
ArrayRef<Expr *> PrivateVars, ArrayRef<Expr *> Inits,
|
|
|
|
ArrayRef<ValueDecl *> Declarations,
|
2016-07-28 22:23:26 +08:00
|
|
|
MappableExprComponentListsRef ComponentLists) {
|
2019-02-20 00:38:20 +08:00
|
|
|
OMPMappableExprListSizeTy Sizes;
|
|
|
|
Sizes.NumVars = Vars.size();
|
|
|
|
Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
|
|
|
|
Sizes.NumComponentLists = ComponentLists.size();
|
|
|
|
Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
|
2016-07-28 22:23:26 +08:00
|
|
|
|
|
|
|
// We need to allocate:
|
2020-05-26 04:06:31 +08:00
|
|
|
// NumVars x Expr* - we have an original list expression for each clause
|
|
|
|
// list entry.
|
2016-07-28 22:23:26 +08:00
|
|
|
// NumUniqueDeclarations x ValueDecl* - unique base declarations associated
|
|
|
|
// with each component list.
|
|
|
|
// (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
|
|
|
|
// number of lists for each unique declaration and the size of each component
|
|
|
|
// list.
|
|
|
|
// NumComponents x MappableComponent - the total of all the components in all
|
|
|
|
// the lists.
|
|
|
|
void *Mem = C.Allocate(
|
|
|
|
totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
|
|
|
|
OMPClauseMappableExprCommon::MappableComponent>(
|
2019-02-20 00:38:20 +08:00
|
|
|
3 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
|
|
|
|
Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
|
|
|
|
Sizes.NumComponents));
|
2016-07-28 22:23:26 +08:00
|
|
|
|
2019-02-20 00:38:20 +08:00
|
|
|
OMPUseDevicePtrClause *Clause = new (Mem) OMPUseDevicePtrClause(Locs, Sizes);
|
2016-07-28 22:23:26 +08:00
|
|
|
|
|
|
|
Clause->setVarRefs(Vars);
|
|
|
|
Clause->setPrivateCopies(PrivateVars);
|
|
|
|
Clause->setInits(Inits);
|
|
|
|
Clause->setClauseInfo(Declarations, ComponentLists);
|
2016-07-13 23:37:16 +08:00
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
2019-02-20 00:38:20 +08:00
|
|
|
OMPUseDevicePtrClause *
|
|
|
|
OMPUseDevicePtrClause::CreateEmpty(const ASTContext &C,
|
|
|
|
const OMPMappableExprListSizeTy &Sizes) {
|
2016-07-28 22:23:26 +08:00
|
|
|
void *Mem = C.Allocate(
|
|
|
|
totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
|
|
|
|
OMPClauseMappableExprCommon::MappableComponent>(
|
2019-02-20 00:38:20 +08:00
|
|
|
3 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
|
|
|
|
Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
|
|
|
|
Sizes.NumComponents));
|
|
|
|
return new (Mem) OMPUseDevicePtrClause(Sizes);
|
2016-07-13 23:37:16 +08:00
|
|
|
}
|
2016-07-14 01:16:49 +08:00
|
|
|
|
2020-05-21 20:30:23 +08:00
|
|
|
OMPUseDeviceAddrClause *
|
|
|
|
OMPUseDeviceAddrClause::Create(const ASTContext &C, const OMPVarListLocTy &Locs,
|
|
|
|
ArrayRef<Expr *> Vars,
|
|
|
|
ArrayRef<ValueDecl *> Declarations,
|
|
|
|
MappableExprComponentListsRef ComponentLists) {
|
|
|
|
OMPMappableExprListSizeTy Sizes;
|
|
|
|
Sizes.NumVars = Vars.size();
|
|
|
|
Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
|
|
|
|
Sizes.NumComponentLists = ComponentLists.size();
|
|
|
|
Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
|
|
|
|
|
|
|
|
// We need to allocate:
|
|
|
|
// 3 x NumVars x Expr* - we have an original list expression for each clause
|
|
|
|
// list entry and an equal number of private copies and inits.
|
|
|
|
// NumUniqueDeclarations x ValueDecl* - unique base declarations associated
|
|
|
|
// with each component list.
|
|
|
|
// (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
|
|
|
|
// number of lists for each unique declaration and the size of each component
|
|
|
|
// list.
|
|
|
|
// NumComponents x MappableComponent - the total of all the components in all
|
|
|
|
// the lists.
|
|
|
|
void *Mem = C.Allocate(
|
|
|
|
totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
|
|
|
|
OMPClauseMappableExprCommon::MappableComponent>(
|
|
|
|
Sizes.NumVars, Sizes.NumUniqueDeclarations,
|
|
|
|
Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
|
|
|
|
Sizes.NumComponents));
|
|
|
|
|
|
|
|
auto *Clause = new (Mem) OMPUseDeviceAddrClause(Locs, Sizes);
|
|
|
|
|
|
|
|
Clause->setVarRefs(Vars);
|
|
|
|
Clause->setClauseInfo(Declarations, ComponentLists);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPUseDeviceAddrClause *
|
|
|
|
OMPUseDeviceAddrClause::CreateEmpty(const ASTContext &C,
|
|
|
|
const OMPMappableExprListSizeTy &Sizes) {
|
|
|
|
void *Mem = C.Allocate(
|
|
|
|
totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
|
|
|
|
OMPClauseMappableExprCommon::MappableComponent>(
|
|
|
|
Sizes.NumVars, Sizes.NumUniqueDeclarations,
|
|
|
|
Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
|
|
|
|
Sizes.NumComponents));
|
|
|
|
return new (Mem) OMPUseDeviceAddrClause(Sizes);
|
|
|
|
}
|
|
|
|
|
2016-07-28 22:25:09 +08:00
|
|
|
OMPIsDevicePtrClause *
|
2019-02-20 00:38:20 +08:00
|
|
|
OMPIsDevicePtrClause::Create(const ASTContext &C, const OMPVarListLocTy &Locs,
|
2016-07-28 22:25:09 +08:00
|
|
|
ArrayRef<Expr *> Vars,
|
|
|
|
ArrayRef<ValueDecl *> Declarations,
|
|
|
|
MappableExprComponentListsRef ComponentLists) {
|
2019-02-20 00:38:20 +08:00
|
|
|
OMPMappableExprListSizeTy Sizes;
|
|
|
|
Sizes.NumVars = Vars.size();
|
|
|
|
Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
|
|
|
|
Sizes.NumComponentLists = ComponentLists.size();
|
|
|
|
Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
|
2016-07-28 22:25:09 +08:00
|
|
|
|
|
|
|
// We need to allocate:
|
|
|
|
// NumVars x Expr* - we have an original list expression for each clause list
|
|
|
|
// entry.
|
|
|
|
// NumUniqueDeclarations x ValueDecl* - unique base declarations associated
|
|
|
|
// with each component list.
|
|
|
|
// (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
|
|
|
|
// number of lists for each unique declaration and the size of each component
|
|
|
|
// list.
|
|
|
|
// NumComponents x MappableComponent - the total of all the components in all
|
|
|
|
// the lists.
|
|
|
|
void *Mem = C.Allocate(
|
|
|
|
totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
|
|
|
|
OMPClauseMappableExprCommon::MappableComponent>(
|
2019-02-20 00:38:20 +08:00
|
|
|
Sizes.NumVars, Sizes.NumUniqueDeclarations,
|
|
|
|
Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
|
|
|
|
Sizes.NumComponents));
|
2016-07-28 22:25:09 +08:00
|
|
|
|
2019-02-20 00:38:20 +08:00
|
|
|
OMPIsDevicePtrClause *Clause = new (Mem) OMPIsDevicePtrClause(Locs, Sizes);
|
2016-07-28 22:25:09 +08:00
|
|
|
|
|
|
|
Clause->setVarRefs(Vars);
|
|
|
|
Clause->setClauseInfo(Declarations, ComponentLists);
|
2016-07-14 01:16:49 +08:00
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
2019-02-20 00:38:20 +08:00
|
|
|
OMPIsDevicePtrClause *
|
|
|
|
OMPIsDevicePtrClause::CreateEmpty(const ASTContext &C,
|
|
|
|
const OMPMappableExprListSizeTy &Sizes) {
|
2016-07-28 22:25:09 +08:00
|
|
|
void *Mem = C.Allocate(
|
|
|
|
totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
|
|
|
|
OMPClauseMappableExprCommon::MappableComponent>(
|
2019-02-20 00:38:20 +08:00
|
|
|
Sizes.NumVars, Sizes.NumUniqueDeclarations,
|
|
|
|
Sizes.NumUniqueDeclarations + Sizes.NumComponentLists,
|
|
|
|
Sizes.NumComponents));
|
|
|
|
return new (Mem) OMPIsDevicePtrClause(Sizes);
|
2016-07-14 01:16:49 +08:00
|
|
|
}
|
2018-10-18 22:28:23 +08:00
|
|
|
|
2019-12-17 04:54:17 +08:00
|
|
|
OMPNontemporalClause *OMPNontemporalClause::Create(const ASTContext &C,
|
|
|
|
SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation EndLoc,
|
|
|
|
ArrayRef<Expr *> VL) {
|
2019-12-19 23:01:10 +08:00
|
|
|
// Allocate space for nontemporal variables + private references.
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
|
2019-12-17 04:54:17 +08:00
|
|
|
auto *Clause =
|
|
|
|
new (Mem) OMPNontemporalClause(StartLoc, LParenLoc, EndLoc, VL.size());
|
|
|
|
Clause->setVarRefs(VL);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPNontemporalClause *OMPNontemporalClause::CreateEmpty(const ASTContext &C,
|
|
|
|
unsigned N) {
|
2019-12-19 23:01:10 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
|
2019-12-17 04:54:17 +08:00
|
|
|
return new (Mem) OMPNontemporalClause(N);
|
|
|
|
}
|
|
|
|
|
2019-12-19 23:01:10 +08:00
|
|
|
void OMPNontemporalClause::setPrivateRefs(ArrayRef<Expr *> VL) {
|
|
|
|
assert(VL.size() == varlist_size() && "Number of private references is not "
|
|
|
|
"the same as the preallocated buffer");
|
|
|
|
std::copy(VL.begin(), VL.end(), varlist_end());
|
|
|
|
}
|
|
|
|
|
2020-03-20 21:41:22 +08:00
|
|
|
OMPInclusiveClause *OMPInclusiveClause::Create(const ASTContext &C,
|
|
|
|
SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation EndLoc,
|
|
|
|
ArrayRef<Expr *> VL) {
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
|
|
|
|
auto *Clause =
|
|
|
|
new (Mem) OMPInclusiveClause(StartLoc, LParenLoc, EndLoc, VL.size());
|
|
|
|
Clause->setVarRefs(VL);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPInclusiveClause *OMPInclusiveClause::CreateEmpty(const ASTContext &C,
|
|
|
|
unsigned N) {
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
|
|
|
|
return new (Mem) OMPInclusiveClause(N);
|
|
|
|
}
|
|
|
|
|
2020-03-23 22:41:08 +08:00
|
|
|
OMPExclusiveClause *OMPExclusiveClause::Create(const ASTContext &C,
|
|
|
|
SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation EndLoc,
|
|
|
|
ArrayRef<Expr *> VL) {
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
|
|
|
|
auto *Clause =
|
|
|
|
new (Mem) OMPExclusiveClause(StartLoc, LParenLoc, EndLoc, VL.size());
|
|
|
|
Clause->setVarRefs(VL);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPExclusiveClause *OMPExclusiveClause::CreateEmpty(const ASTContext &C,
|
|
|
|
unsigned N) {
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
|
|
|
|
return new (Mem) OMPExclusiveClause(N);
|
|
|
|
}
|
|
|
|
|
2020-04-22 01:21:00 +08:00
|
|
|
void OMPUsesAllocatorsClause::setAllocatorsData(
|
|
|
|
ArrayRef<OMPUsesAllocatorsClause::Data> Data) {
|
|
|
|
assert(Data.size() == NumOfAllocators &&
|
|
|
|
"Size of allocators data is not the same as the preallocated buffer.");
|
|
|
|
for (unsigned I = 0, E = Data.size(); I < E; ++I) {
|
|
|
|
const OMPUsesAllocatorsClause::Data &D = Data[I];
|
|
|
|
getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) +
|
|
|
|
static_cast<int>(ExprOffsets::Allocator)] =
|
|
|
|
D.Allocator;
|
|
|
|
getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) +
|
|
|
|
static_cast<int>(
|
|
|
|
ExprOffsets::AllocatorTraits)] =
|
|
|
|
D.AllocatorTraits;
|
|
|
|
getTrailingObjects<
|
|
|
|
SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) +
|
|
|
|
static_cast<int>(ParenLocsOffsets::LParen)] =
|
|
|
|
D.LParenLoc;
|
|
|
|
getTrailingObjects<
|
|
|
|
SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) +
|
|
|
|
static_cast<int>(ParenLocsOffsets::RParen)] =
|
|
|
|
D.RParenLoc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPUsesAllocatorsClause::Data
|
|
|
|
OMPUsesAllocatorsClause::getAllocatorData(unsigned I) const {
|
|
|
|
OMPUsesAllocatorsClause::Data Data;
|
|
|
|
Data.Allocator =
|
|
|
|
getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) +
|
|
|
|
static_cast<int>(ExprOffsets::Allocator)];
|
|
|
|
Data.AllocatorTraits =
|
|
|
|
getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) +
|
|
|
|
static_cast<int>(
|
|
|
|
ExprOffsets::AllocatorTraits)];
|
|
|
|
Data.LParenLoc = getTrailingObjects<
|
|
|
|
SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) +
|
|
|
|
static_cast<int>(ParenLocsOffsets::LParen)];
|
|
|
|
Data.RParenLoc = getTrailingObjects<
|
|
|
|
SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) +
|
|
|
|
static_cast<int>(ParenLocsOffsets::RParen)];
|
|
|
|
return Data;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPUsesAllocatorsClause *
|
|
|
|
OMPUsesAllocatorsClause::Create(const ASTContext &C, SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc, SourceLocation EndLoc,
|
|
|
|
ArrayRef<OMPUsesAllocatorsClause::Data> Data) {
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>(
|
|
|
|
static_cast<int>(ExprOffsets::Total) * Data.size(),
|
|
|
|
static_cast<int>(ParenLocsOffsets::Total) * Data.size()));
|
|
|
|
auto *Clause = new (Mem)
|
|
|
|
OMPUsesAllocatorsClause(StartLoc, LParenLoc, EndLoc, Data.size());
|
|
|
|
Clause->setAllocatorsData(Data);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPUsesAllocatorsClause *
|
|
|
|
OMPUsesAllocatorsClause::CreateEmpty(const ASTContext &C, unsigned N) {
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>(
|
|
|
|
static_cast<int>(ExprOffsets::Total) * N,
|
|
|
|
static_cast<int>(ParenLocsOffsets::Total) * N));
|
|
|
|
return new (Mem) OMPUsesAllocatorsClause(N);
|
|
|
|
}
|
|
|
|
|
2020-05-19 01:37:53 +08:00
|
|
|
OMPAffinityClause *
|
|
|
|
OMPAffinityClause::Create(const ASTContext &C, SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc, SourceLocation ColonLoc,
|
|
|
|
SourceLocation EndLoc, Expr *Modifier,
|
|
|
|
ArrayRef<Expr *> Locators) {
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(Locators.size() + 1));
|
|
|
|
auto *Clause = new (Mem)
|
|
|
|
OMPAffinityClause(StartLoc, LParenLoc, ColonLoc, EndLoc, Locators.size());
|
|
|
|
Clause->setModifier(Modifier);
|
|
|
|
Clause->setVarRefs(Locators);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPAffinityClause *OMPAffinityClause::CreateEmpty(const ASTContext &C,
|
|
|
|
unsigned N) {
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N + 1));
|
|
|
|
return new (Mem) OMPAffinityClause(N);
|
|
|
|
}
|
|
|
|
|
2021-03-16 04:09:46 +08:00
|
|
|
OMPInitClause *OMPInitClause::Create(const ASTContext &C, Expr *InteropVar,
|
|
|
|
ArrayRef<Expr *> PrefExprs, bool IsTarget,
|
|
|
|
bool IsTargetSync, SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation VarLoc,
|
|
|
|
SourceLocation EndLoc) {
|
|
|
|
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(PrefExprs.size() + 1));
|
|
|
|
auto *Clause =
|
|
|
|
new (Mem) OMPInitClause(IsTarget, IsTargetSync, StartLoc, LParenLoc,
|
|
|
|
VarLoc, EndLoc, PrefExprs.size() + 1);
|
|
|
|
Clause->setInteropVar(InteropVar);
|
|
|
|
llvm::copy(PrefExprs, Clause->getTrailingObjects<Expr *>() + 1);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPInitClause *OMPInitClause::CreateEmpty(const ASTContext &C, unsigned N) {
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
|
|
|
|
return new (Mem) OMPInitClause(N);
|
|
|
|
}
|
|
|
|
|
2021-11-04 05:57:01 +08:00
|
|
|
OMPBindClause *
|
|
|
|
OMPBindClause::Create(const ASTContext &C, OpenMPBindClauseKind K,
|
|
|
|
SourceLocation KLoc, SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc, SourceLocation EndLoc) {
|
|
|
|
return new (C) OMPBindClause(K, KLoc, StartLoc, LParenLoc, EndLoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPBindClause *OMPBindClause::CreateEmpty(const ASTContext &C) {
|
|
|
|
return new (C) OMPBindClause();
|
|
|
|
}
|
2018-10-18 22:28:23 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// OpenMP clauses printing methods
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPIfClause(OMPIfClause *Node) {
|
|
|
|
OS << "if(";
|
2020-03-26 08:33:48 +08:00
|
|
|
if (Node->getNameModifier() != OMPD_unknown)
|
2018-10-18 22:28:23 +08:00
|
|
|
OS << getOpenMPDirectiveName(Node->getNameModifier()) << ": ";
|
|
|
|
Node->getCondition()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPFinalClause(OMPFinalClause *Node) {
|
|
|
|
OS << "final(";
|
|
|
|
Node->getCondition()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPNumThreadsClause(OMPNumThreadsClause *Node) {
|
|
|
|
OS << "num_threads(";
|
|
|
|
Node->getNumThreads()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2021-11-09 20:33:39 +08:00
|
|
|
void OMPClausePrinter::VisitOMPAlignClause(OMPAlignClause *Node) {
|
|
|
|
OS << "align(";
|
|
|
|
Node->getAlignment()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2018-10-18 22:28:23 +08:00
|
|
|
void OMPClausePrinter::VisitOMPSafelenClause(OMPSafelenClause *Node) {
|
|
|
|
OS << "safelen(";
|
|
|
|
Node->getSafelen()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPSimdlenClause(OMPSimdlenClause *Node) {
|
|
|
|
OS << "simdlen(";
|
|
|
|
Node->getSimdlen()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2021-02-13 03:26:59 +08:00
|
|
|
void OMPClausePrinter::VisitOMPSizesClause(OMPSizesClause *Node) {
|
|
|
|
OS << "sizes(";
|
|
|
|
bool First = true;
|
|
|
|
for (auto Size : Node->getSizesRefs()) {
|
|
|
|
if (!First)
|
|
|
|
OS << ", ";
|
|
|
|
Size->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
First = false;
|
|
|
|
}
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2021-06-11 03:24:17 +08:00
|
|
|
void OMPClausePrinter::VisitOMPFullClause(OMPFullClause *Node) { OS << "full"; }
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPPartialClause(OMPPartialClause *Node) {
|
|
|
|
OS << "partial";
|
|
|
|
|
|
|
|
if (Expr *Factor = Node->getFactor()) {
|
|
|
|
OS << '(';
|
|
|
|
Factor->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ')';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-13 02:52:33 +08:00
|
|
|
void OMPClausePrinter::VisitOMPAllocatorClause(OMPAllocatorClause *Node) {
|
|
|
|
OS << "allocator(";
|
|
|
|
Node->getAllocator()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2018-10-18 22:28:23 +08:00
|
|
|
void OMPClausePrinter::VisitOMPCollapseClause(OMPCollapseClause *Node) {
|
|
|
|
OS << "collapse(";
|
|
|
|
Node->getNumForLoops()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2020-03-17 21:17:42 +08:00
|
|
|
void OMPClausePrinter::VisitOMPDetachClause(OMPDetachClause *Node) {
|
|
|
|
OS << "detach(";
|
|
|
|
Node->getEventHandler()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2018-10-18 22:28:23 +08:00
|
|
|
void OMPClausePrinter::VisitOMPDefaultClause(OMPDefaultClause *Node) {
|
|
|
|
OS << "default("
|
2020-02-15 11:45:49 +08:00
|
|
|
<< getOpenMPSimpleClauseTypeName(OMPC_default,
|
|
|
|
unsigned(Node->getDefaultKind()))
|
2018-10-18 22:28:23 +08:00
|
|
|
<< ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPProcBindClause(OMPProcBindClause *Node) {
|
|
|
|
OS << "proc_bind("
|
2019-12-26 08:15:36 +08:00
|
|
|
<< getOpenMPSimpleClauseTypeName(OMPC_proc_bind,
|
|
|
|
unsigned(Node->getProcBindKind()))
|
2018-10-18 22:28:23 +08:00
|
|
|
<< ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) {
|
|
|
|
OS << "unified_address";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPUnifiedSharedMemoryClause(
|
|
|
|
OMPUnifiedSharedMemoryClause *) {
|
|
|
|
OS << "unified_shared_memory";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {
|
|
|
|
OS << "reverse_offload";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPDynamicAllocatorsClause(
|
|
|
|
OMPDynamicAllocatorsClause *) {
|
|
|
|
OS << "dynamic_allocators";
|
|
|
|
}
|
|
|
|
|
2018-11-02 20:18:11 +08:00
|
|
|
void OMPClausePrinter::VisitOMPAtomicDefaultMemOrderClause(
|
|
|
|
OMPAtomicDefaultMemOrderClause *Node) {
|
|
|
|
OS << "atomic_default_mem_order("
|
|
|
|
<< getOpenMPSimpleClauseTypeName(OMPC_atomic_default_mem_order,
|
|
|
|
Node->getAtomicDefaultMemOrderKind())
|
|
|
|
<< ")";
|
|
|
|
}
|
|
|
|
|
2018-10-18 22:28:23 +08:00
|
|
|
void OMPClausePrinter::VisitOMPScheduleClause(OMPScheduleClause *Node) {
|
|
|
|
OS << "schedule(";
|
|
|
|
if (Node->getFirstScheduleModifier() != OMPC_SCHEDULE_MODIFIER_unknown) {
|
|
|
|
OS << getOpenMPSimpleClauseTypeName(OMPC_schedule,
|
|
|
|
Node->getFirstScheduleModifier());
|
|
|
|
if (Node->getSecondScheduleModifier() != OMPC_SCHEDULE_MODIFIER_unknown) {
|
|
|
|
OS << ", ";
|
|
|
|
OS << getOpenMPSimpleClauseTypeName(OMPC_schedule,
|
|
|
|
Node->getSecondScheduleModifier());
|
|
|
|
}
|
|
|
|
OS << ": ";
|
|
|
|
}
|
|
|
|
OS << getOpenMPSimpleClauseTypeName(OMPC_schedule, Node->getScheduleKind());
|
|
|
|
if (auto *E = Node->getChunkSize()) {
|
|
|
|
OS << ", ";
|
|
|
|
E->printPretty(OS, nullptr, Policy);
|
|
|
|
}
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPOrderedClause(OMPOrderedClause *Node) {
|
|
|
|
OS << "ordered";
|
|
|
|
if (auto *Num = Node->getNumForLoops()) {
|
|
|
|
OS << "(";
|
|
|
|
Num->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPNowaitClause(OMPNowaitClause *) {
|
|
|
|
OS << "nowait";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPUntiedClause(OMPUntiedClause *) {
|
|
|
|
OS << "untied";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPNogroupClause(OMPNogroupClause *) {
|
|
|
|
OS << "nogroup";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPMergeableClause(OMPMergeableClause *) {
|
|
|
|
OS << "mergeable";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPReadClause(OMPReadClause *) { OS << "read"; }
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPWriteClause(OMPWriteClause *) { OS << "write"; }
|
|
|
|
|
2020-03-04 02:22:35 +08:00
|
|
|
void OMPClausePrinter::VisitOMPUpdateClause(OMPUpdateClause *Node) {
|
2018-10-18 22:28:23 +08:00
|
|
|
OS << "update";
|
2020-03-04 02:22:35 +08:00
|
|
|
if (Node->isExtended()) {
|
|
|
|
OS << "(";
|
|
|
|
OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(),
|
|
|
|
Node->getDependencyKind());
|
|
|
|
OS << ")";
|
|
|
|
}
|
2018-10-18 22:28:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPCaptureClause(OMPCaptureClause *) {
|
|
|
|
OS << "capture";
|
|
|
|
}
|
|
|
|
|
2021-12-24 21:16:33 +08:00
|
|
|
void OMPClausePrinter::VisitOMPCompareClause(OMPCompareClause *) {
|
|
|
|
OS << "compare";
|
|
|
|
}
|
|
|
|
|
2018-10-18 22:28:23 +08:00
|
|
|
void OMPClausePrinter::VisitOMPSeqCstClause(OMPSeqCstClause *) {
|
|
|
|
OS << "seq_cst";
|
|
|
|
}
|
|
|
|
|
2020-02-07 05:30:23 +08:00
|
|
|
void OMPClausePrinter::VisitOMPAcqRelClause(OMPAcqRelClause *) {
|
|
|
|
OS << "acq_rel";
|
|
|
|
}
|
|
|
|
|
2020-02-11 03:30:39 +08:00
|
|
|
void OMPClausePrinter::VisitOMPAcquireClause(OMPAcquireClause *) {
|
|
|
|
OS << "acquire";
|
|
|
|
}
|
|
|
|
|
2020-02-11 04:49:05 +08:00
|
|
|
void OMPClausePrinter::VisitOMPReleaseClause(OMPReleaseClause *) {
|
|
|
|
OS << "release";
|
|
|
|
}
|
|
|
|
|
2020-02-12 00:10:43 +08:00
|
|
|
void OMPClausePrinter::VisitOMPRelaxedClause(OMPRelaxedClause *) {
|
|
|
|
OS << "relaxed";
|
|
|
|
}
|
|
|
|
|
2018-10-18 22:28:23 +08:00
|
|
|
void OMPClausePrinter::VisitOMPThreadsClause(OMPThreadsClause *) {
|
|
|
|
OS << "threads";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPSIMDClause(OMPSIMDClause *) { OS << "simd"; }
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPDeviceClause(OMPDeviceClause *Node) {
|
|
|
|
OS << "device(";
|
2020-03-19 03:01:15 +08:00
|
|
|
OpenMPDeviceClauseModifier Modifier = Node->getModifier();
|
|
|
|
if (Modifier != OMPC_DEVICE_unknown) {
|
|
|
|
OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(), Modifier)
|
|
|
|
<< ": ";
|
|
|
|
}
|
2018-10-18 22:28:23 +08:00
|
|
|
Node->getDevice()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPNumTeamsClause(OMPNumTeamsClause *Node) {
|
|
|
|
OS << "num_teams(";
|
|
|
|
Node->getNumTeams()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPThreadLimitClause(OMPThreadLimitClause *Node) {
|
|
|
|
OS << "thread_limit(";
|
|
|
|
Node->getThreadLimit()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPPriorityClause(OMPPriorityClause *Node) {
|
|
|
|
OS << "priority(";
|
|
|
|
Node->getPriority()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPGrainsizeClause(OMPGrainsizeClause *Node) {
|
|
|
|
OS << "grainsize(";
|
|
|
|
Node->getGrainsize()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPNumTasksClause(OMPNumTasksClause *Node) {
|
|
|
|
OS << "num_tasks(";
|
|
|
|
Node->getNumTasks()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPHintClause(OMPHintClause *Node) {
|
|
|
|
OS << "hint(";
|
|
|
|
Node->getHint()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2021-03-16 04:09:46 +08:00
|
|
|
void OMPClausePrinter::VisitOMPInitClause(OMPInitClause *Node) {
|
|
|
|
OS << "init(";
|
|
|
|
bool First = true;
|
|
|
|
for (const Expr *E : Node->prefs()) {
|
|
|
|
if (First)
|
|
|
|
OS << "prefer_type(";
|
|
|
|
else
|
|
|
|
OS << ",";
|
|
|
|
E->printPretty(OS, nullptr, Policy);
|
|
|
|
First = false;
|
|
|
|
}
|
|
|
|
if (!First)
|
|
|
|
OS << "), ";
|
|
|
|
if (Node->getIsTarget())
|
|
|
|
OS << "target";
|
|
|
|
if (Node->getIsTargetSync()) {
|
|
|
|
if (Node->getIsTarget())
|
|
|
|
OS << ", ";
|
|
|
|
OS << "targetsync";
|
|
|
|
}
|
|
|
|
OS << " : ";
|
2021-03-18 04:04:08 +08:00
|
|
|
Node->getInteropVar()->printPretty(OS, nullptr, Policy);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPUseClause(OMPUseClause *Node) {
|
|
|
|
OS << "use(";
|
2021-03-16 04:09:46 +08:00
|
|
|
Node->getInteropVar()->printPretty(OS, nullptr, Policy);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2021-03-18 07:43:47 +08:00
|
|
|
void OMPClausePrinter::VisitOMPDestroyClause(OMPDestroyClause *Node) {
|
2020-03-03 03:21:20 +08:00
|
|
|
OS << "destroy";
|
2021-03-18 07:43:47 +08:00
|
|
|
if (Expr *E = Node->getInteropVar()) {
|
|
|
|
OS << "(";
|
|
|
|
E->printPretty(OS, nullptr, Policy);
|
|
|
|
OS << ")";
|
|
|
|
}
|
2020-03-03 03:21:20 +08:00
|
|
|
}
|
|
|
|
|
2021-04-01 03:26:47 +08:00
|
|
|
void OMPClausePrinter::VisitOMPNovariantsClause(OMPNovariantsClause *Node) {
|
|
|
|
OS << "novariants";
|
|
|
|
if (Expr *E = Node->getCondition()) {
|
|
|
|
OS << "(";
|
|
|
|
E->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-04 02:09:25 +08:00
|
|
|
void OMPClausePrinter::VisitOMPNocontextClause(OMPNocontextClause *Node) {
|
|
|
|
OS << "nocontext";
|
|
|
|
if (Expr *E = Node->getCondition()) {
|
|
|
|
OS << "(";
|
|
|
|
E->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-18 22:28:23 +08:00
|
|
|
template<typename T>
|
|
|
|
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
|
|
|
|
for (typename T::varlist_iterator I = Node->varlist_begin(),
|
|
|
|
E = Node->varlist_end();
|
|
|
|
I != E; ++I) {
|
|
|
|
assert(*I && "Expected non-null Stmt");
|
|
|
|
OS << (I == Node->varlist_begin() ? StartSym : ',');
|
|
|
|
if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
|
|
|
|
if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
|
|
|
|
DRE->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
else
|
|
|
|
DRE->getDecl()->printQualifiedName(OS);
|
|
|
|
} else
|
|
|
|
(*I)->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-27 22:14:31 +08:00
|
|
|
void OMPClausePrinter::VisitOMPAllocateClause(OMPAllocateClause *Node) {
|
|
|
|
if (Node->varlist_empty())
|
|
|
|
return;
|
|
|
|
OS << "allocate";
|
|
|
|
if (Expr *Allocator = Node->getAllocator()) {
|
|
|
|
OS << "(";
|
|
|
|
Allocator->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ":";
|
|
|
|
VisitOMPClauseList(Node, ' ');
|
|
|
|
} else {
|
|
|
|
VisitOMPClauseList(Node, '(');
|
|
|
|
}
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2018-10-18 22:28:23 +08:00
|
|
|
void OMPClausePrinter::VisitOMPPrivateClause(OMPPrivateClause *Node) {
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
OS << "private";
|
|
|
|
VisitOMPClauseList(Node, '(');
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPFirstprivateClause(OMPFirstprivateClause *Node) {
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
OS << "firstprivate";
|
|
|
|
VisitOMPClauseList(Node, '(');
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPLastprivateClause(OMPLastprivateClause *Node) {
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
OS << "lastprivate";
|
2019-12-21 00:04:57 +08:00
|
|
|
OpenMPLastprivateModifier LPKind = Node->getKind();
|
|
|
|
if (LPKind != OMPC_LASTPRIVATE_unknown) {
|
|
|
|
OS << "("
|
|
|
|
<< getOpenMPSimpleClauseTypeName(OMPC_lastprivate, Node->getKind())
|
|
|
|
<< ":";
|
|
|
|
}
|
|
|
|
VisitOMPClauseList(Node, LPKind == OMPC_LASTPRIVATE_unknown ? '(' : ' ');
|
2018-10-18 22:28:23 +08:00
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPSharedClause(OMPSharedClause *Node) {
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
OS << "shared";
|
|
|
|
VisitOMPClauseList(Node, '(');
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPReductionClause(OMPReductionClause *Node) {
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
OS << "reduction(";
|
2020-03-24 05:30:38 +08:00
|
|
|
if (Node->getModifierLoc().isValid())
|
|
|
|
OS << getOpenMPSimpleClauseTypeName(OMPC_reduction, Node->getModifier())
|
|
|
|
<< ", ";
|
2018-10-18 22:28:23 +08:00
|
|
|
NestedNameSpecifier *QualifierLoc =
|
|
|
|
Node->getQualifierLoc().getNestedNameSpecifier();
|
|
|
|
OverloadedOperatorKind OOK =
|
|
|
|
Node->getNameInfo().getName().getCXXOverloadedOperator();
|
|
|
|
if (QualifierLoc == nullptr && OOK != OO_None) {
|
|
|
|
// Print reduction identifier in C format
|
|
|
|
OS << getOperatorSpelling(OOK);
|
|
|
|
} else {
|
|
|
|
// Use C++ format
|
|
|
|
if (QualifierLoc != nullptr)
|
|
|
|
QualifierLoc->print(OS, Policy);
|
|
|
|
OS << Node->getNameInfo();
|
|
|
|
}
|
|
|
|
OS << ":";
|
|
|
|
VisitOMPClauseList(Node, ' ');
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPTaskReductionClause(
|
|
|
|
OMPTaskReductionClause *Node) {
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
OS << "task_reduction(";
|
|
|
|
NestedNameSpecifier *QualifierLoc =
|
|
|
|
Node->getQualifierLoc().getNestedNameSpecifier();
|
|
|
|
OverloadedOperatorKind OOK =
|
|
|
|
Node->getNameInfo().getName().getCXXOverloadedOperator();
|
|
|
|
if (QualifierLoc == nullptr && OOK != OO_None) {
|
|
|
|
// Print reduction identifier in C format
|
|
|
|
OS << getOperatorSpelling(OOK);
|
|
|
|
} else {
|
|
|
|
// Use C++ format
|
|
|
|
if (QualifierLoc != nullptr)
|
|
|
|
QualifierLoc->print(OS, Policy);
|
|
|
|
OS << Node->getNameInfo();
|
|
|
|
}
|
|
|
|
OS << ":";
|
|
|
|
VisitOMPClauseList(Node, ' ');
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPInReductionClause(OMPInReductionClause *Node) {
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
OS << "in_reduction(";
|
|
|
|
NestedNameSpecifier *QualifierLoc =
|
|
|
|
Node->getQualifierLoc().getNestedNameSpecifier();
|
|
|
|
OverloadedOperatorKind OOK =
|
|
|
|
Node->getNameInfo().getName().getCXXOverloadedOperator();
|
|
|
|
if (QualifierLoc == nullptr && OOK != OO_None) {
|
|
|
|
// Print reduction identifier in C format
|
|
|
|
OS << getOperatorSpelling(OOK);
|
|
|
|
} else {
|
|
|
|
// Use C++ format
|
|
|
|
if (QualifierLoc != nullptr)
|
|
|
|
QualifierLoc->print(OS, Policy);
|
|
|
|
OS << Node->getNameInfo();
|
|
|
|
}
|
|
|
|
OS << ":";
|
|
|
|
VisitOMPClauseList(Node, ' ');
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPLinearClause(OMPLinearClause *Node) {
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
OS << "linear";
|
|
|
|
if (Node->getModifierLoc().isValid()) {
|
|
|
|
OS << '('
|
|
|
|
<< getOpenMPSimpleClauseTypeName(OMPC_linear, Node->getModifier());
|
|
|
|
}
|
|
|
|
VisitOMPClauseList(Node, '(');
|
|
|
|
if (Node->getModifierLoc().isValid())
|
|
|
|
OS << ')';
|
|
|
|
if (Node->getStep() != nullptr) {
|
|
|
|
OS << ": ";
|
|
|
|
Node->getStep()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
}
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPAlignedClause(OMPAlignedClause *Node) {
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
OS << "aligned";
|
|
|
|
VisitOMPClauseList(Node, '(');
|
|
|
|
if (Node->getAlignment() != nullptr) {
|
|
|
|
OS << ": ";
|
|
|
|
Node->getAlignment()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
}
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPCopyinClause(OMPCopyinClause *Node) {
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
OS << "copyin";
|
|
|
|
VisitOMPClauseList(Node, '(');
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPCopyprivateClause(OMPCopyprivateClause *Node) {
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
OS << "copyprivate";
|
|
|
|
VisitOMPClauseList(Node, '(');
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPFlushClause(OMPFlushClause *Node) {
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
VisitOMPClauseList(Node, '(');
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-28 22:52:15 +08:00
|
|
|
void OMPClausePrinter::VisitOMPDepobjClause(OMPDepobjClause *Node) {
|
|
|
|
OS << "(";
|
|
|
|
Node->getDepobj()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2018-10-18 22:28:23 +08:00
|
|
|
void OMPClausePrinter::VisitOMPDependClause(OMPDependClause *Node) {
|
|
|
|
OS << "depend(";
|
2020-04-02 03:06:38 +08:00
|
|
|
if (Expr *DepModifier = Node->getModifier()) {
|
|
|
|
DepModifier->printPretty(OS, nullptr, Policy);
|
|
|
|
OS << ", ";
|
|
|
|
}
|
2018-10-18 22:28:23 +08:00
|
|
|
OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(),
|
|
|
|
Node->getDependencyKind());
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
OS << " :";
|
|
|
|
VisitOMPClauseList(Node, ' ');
|
|
|
|
}
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2020-07-30 00:18:45 +08:00
|
|
|
template <typename T>
|
|
|
|
static void PrintMapper(raw_ostream &OS, T *Node,
|
|
|
|
const PrintingPolicy &Policy) {
|
|
|
|
OS << '(';
|
|
|
|
NestedNameSpecifier *MapperNNS =
|
|
|
|
Node->getMapperQualifierLoc().getNestedNameSpecifier();
|
|
|
|
if (MapperNNS)
|
|
|
|
MapperNNS->print(OS, Policy);
|
|
|
|
OS << Node->getMapperIdInfo() << ')';
|
|
|
|
}
|
|
|
|
|
2018-10-18 22:28:23 +08:00
|
|
|
void OMPClausePrinter::VisitOMPMapClause(OMPMapClause *Node) {
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
OS << "map(";
|
|
|
|
if (Node->getMapType() != OMPC_MAP_unknown) {
|
2020-04-04 03:35:30 +08:00
|
|
|
for (unsigned I = 0; I < NumberOfOMPMapClauseModifiers; ++I) {
|
2018-12-19 06:18:41 +08:00
|
|
|
if (Node->getMapTypeModifier(I) != OMPC_MAP_MODIFIER_unknown) {
|
|
|
|
OS << getOpenMPSimpleClauseTypeName(OMPC_map,
|
|
|
|
Node->getMapTypeModifier(I));
|
2020-07-30 00:18:45 +08:00
|
|
|
if (Node->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_mapper)
|
|
|
|
PrintMapper(OS, Node, Policy);
|
2018-12-19 06:18:41 +08:00
|
|
|
OS << ',';
|
|
|
|
}
|
2018-10-18 22:28:23 +08:00
|
|
|
}
|
|
|
|
OS << getOpenMPSimpleClauseTypeName(OMPC_map, Node->getMapType());
|
|
|
|
OS << ':';
|
|
|
|
}
|
|
|
|
VisitOMPClauseList(Node, ' ');
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-30 00:18:45 +08:00
|
|
|
template <typename T> void OMPClausePrinter::VisitOMPMotionClause(T *Node) {
|
|
|
|
if (Node->varlist_empty())
|
|
|
|
return;
|
|
|
|
OS << getOpenMPClauseName(Node->getClauseKind());
|
|
|
|
unsigned ModifierCount = 0;
|
|
|
|
for (unsigned I = 0; I < NumberOfOMPMotionModifiers; ++I) {
|
|
|
|
if (Node->getMotionModifier(I) != OMPC_MOTION_MODIFIER_unknown)
|
|
|
|
++ModifierCount;
|
|
|
|
}
|
|
|
|
if (ModifierCount) {
|
|
|
|
OS << '(';
|
|
|
|
for (unsigned I = 0; I < NumberOfOMPMotionModifiers; ++I) {
|
|
|
|
if (Node->getMotionModifier(I) != OMPC_MOTION_MODIFIER_unknown) {
|
|
|
|
OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(),
|
|
|
|
Node->getMotionModifier(I));
|
|
|
|
if (Node->getMotionModifier(I) == OMPC_MOTION_MODIFIER_mapper)
|
|
|
|
PrintMapper(OS, Node, Policy);
|
|
|
|
if (I < ModifierCount - 1)
|
|
|
|
OS << ", ";
|
|
|
|
}
|
2019-02-23 06:29:42 +08:00
|
|
|
}
|
2020-07-30 00:18:45 +08:00
|
|
|
OS << ':';
|
|
|
|
VisitOMPClauseList(Node, ' ');
|
|
|
|
} else {
|
|
|
|
VisitOMPClauseList(Node, '(');
|
2018-10-18 22:28:23 +08:00
|
|
|
}
|
2020-07-30 00:18:45 +08:00
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPToClause(OMPToClause *Node) {
|
|
|
|
VisitOMPMotionClause(Node);
|
2018-10-18 22:28:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPFromClause(OMPFromClause *Node) {
|
2020-07-30 00:18:45 +08:00
|
|
|
VisitOMPMotionClause(Node);
|
2018-10-18 22:28:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPDistScheduleClause(OMPDistScheduleClause *Node) {
|
|
|
|
OS << "dist_schedule(" << getOpenMPSimpleClauseTypeName(
|
|
|
|
OMPC_dist_schedule, Node->getDistScheduleKind());
|
|
|
|
if (auto *E = Node->getChunkSize()) {
|
|
|
|
OS << ", ";
|
|
|
|
E->printPretty(OS, nullptr, Policy);
|
|
|
|
}
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPDefaultmapClause(OMPDefaultmapClause *Node) {
|
|
|
|
OS << "defaultmap(";
|
|
|
|
OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap,
|
|
|
|
Node->getDefaultmapModifier());
|
2020-04-09 03:19:54 +08:00
|
|
|
if (Node->getDefaultmapKind() != OMPC_DEFAULTMAP_unknown) {
|
|
|
|
OS << ": ";
|
|
|
|
OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap,
|
|
|
|
Node->getDefaultmapKind());
|
|
|
|
}
|
2018-10-18 22:28:23 +08:00
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *Node) {
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
OS << "use_device_ptr";
|
|
|
|
VisitOMPClauseList(Node, '(');
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-21 20:30:23 +08:00
|
|
|
void OMPClausePrinter::VisitOMPUseDeviceAddrClause(
|
|
|
|
OMPUseDeviceAddrClause *Node) {
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
OS << "use_device_addr";
|
|
|
|
VisitOMPClauseList(Node, '(');
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-18 22:28:23 +08:00
|
|
|
void OMPClausePrinter::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *Node) {
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
OS << "is_device_ptr";
|
|
|
|
VisitOMPClauseList(Node, '(');
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-17 04:54:17 +08:00
|
|
|
void OMPClausePrinter::VisitOMPNontemporalClause(OMPNontemporalClause *Node) {
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
OS << "nontemporal";
|
|
|
|
VisitOMPClauseList(Node, '(');
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
2020-02-01 05:09:26 +08:00
|
|
|
|
|
|
|
void OMPClausePrinter::VisitOMPOrderClause(OMPOrderClause *Node) {
|
|
|
|
OS << "order(" << getOpenMPSimpleClauseTypeName(OMPC_order, Node->getKind())
|
|
|
|
<< ")";
|
|
|
|
}
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
|
2020-03-20 21:41:22 +08:00
|
|
|
void OMPClausePrinter::VisitOMPInclusiveClause(OMPInclusiveClause *Node) {
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
OS << "inclusive";
|
|
|
|
VisitOMPClauseList(Node, '(');
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-23 22:41:08 +08:00
|
|
|
void OMPClausePrinter::VisitOMPExclusiveClause(OMPExclusiveClause *Node) {
|
|
|
|
if (!Node->varlist_empty()) {
|
|
|
|
OS << "exclusive";
|
|
|
|
VisitOMPClauseList(Node, '(');
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-22 01:21:00 +08:00
|
|
|
void OMPClausePrinter::VisitOMPUsesAllocatorsClause(
|
|
|
|
OMPUsesAllocatorsClause *Node) {
|
|
|
|
if (Node->getNumberOfAllocators() == 0)
|
|
|
|
return;
|
|
|
|
OS << "uses_allocators(";
|
|
|
|
for (unsigned I = 0, E = Node->getNumberOfAllocators(); I < E; ++I) {
|
|
|
|
OMPUsesAllocatorsClause::Data Data = Node->getAllocatorData(I);
|
|
|
|
Data.Allocator->printPretty(OS, nullptr, Policy);
|
|
|
|
if (Data.AllocatorTraits) {
|
|
|
|
OS << "(";
|
|
|
|
Data.AllocatorTraits->printPretty(OS, nullptr, Policy);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
if (I < E - 1)
|
|
|
|
OS << ",";
|
|
|
|
}
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2020-05-19 01:37:53 +08:00
|
|
|
void OMPClausePrinter::VisitOMPAffinityClause(OMPAffinityClause *Node) {
|
|
|
|
if (Node->varlist_empty())
|
|
|
|
return;
|
|
|
|
OS << "affinity";
|
|
|
|
char StartSym = '(';
|
|
|
|
if (Expr *Modifier = Node->getModifier()) {
|
|
|
|
OS << "(";
|
|
|
|
Modifier->printPretty(OS, nullptr, Policy);
|
|
|
|
OS << " :";
|
|
|
|
StartSym = ' ';
|
|
|
|
}
|
|
|
|
VisitOMPClauseList(Node, StartSym);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2021-04-10 03:00:36 +08:00
|
|
|
void OMPClausePrinter::VisitOMPFilterClause(OMPFilterClause *Node) {
|
|
|
|
OS << "filter(";
|
|
|
|
Node->getThreadID()->printPretty(OS, nullptr, Policy, 0);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2021-11-04 05:57:01 +08:00
|
|
|
void OMPClausePrinter::VisitOMPBindClause(OMPBindClause *Node) {
|
|
|
|
OS << "bind("
|
|
|
|
<< getOpenMPSimpleClauseTypeName(OMPC_bind, unsigned(Node->getBindKind()))
|
|
|
|
<< ")";
|
|
|
|
}
|
|
|
|
|
2020-02-21 09:50:47 +08:00
|
|
|
void OMPTraitInfo::getAsVariantMatchInfo(ASTContext &ASTCtx,
|
2020-04-04 00:29:53 +08:00
|
|
|
VariantMatchInfo &VMI) const {
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
for (const OMPTraitSet &Set : Sets) {
|
|
|
|
for (const OMPTraitSelector &Selector : Set.Selectors) {
|
|
|
|
|
|
|
|
// User conditions are special as we evaluate the condition here.
|
2020-03-26 08:33:48 +08:00
|
|
|
if (Selector.Kind == TraitSelector::user_condition) {
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
assert(Selector.ScoreOrCondition &&
|
|
|
|
"Ill-formed user condition, expected condition expression!");
|
|
|
|
assert(Selector.Properties.size() == 1 &&
|
|
|
|
Selector.Properties.front().Kind ==
|
2020-03-26 08:33:48 +08:00
|
|
|
TraitProperty::user_condition_unknown &&
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
"Ill-formed user condition, expected unknown trait property!");
|
|
|
|
|
2020-07-13 11:31:08 +08:00
|
|
|
if (Optional<APSInt> CondVal =
|
|
|
|
Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx))
|
2021-09-30 17:50:04 +08:00
|
|
|
VMI.addTrait(CondVal->isZero() ? TraitProperty::user_condition_false
|
|
|
|
: TraitProperty::user_condition_true,
|
2020-07-07 14:08:03 +08:00
|
|
|
"<condition>");
|
2020-04-04 00:29:53 +08:00
|
|
|
else
|
2020-07-07 14:08:03 +08:00
|
|
|
VMI.addTrait(TraitProperty::user_condition_false, "<condition>");
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-07-13 11:31:08 +08:00
|
|
|
Optional<llvm::APSInt> Score;
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
llvm::APInt *ScorePtr = nullptr;
|
|
|
|
if (Selector.ScoreOrCondition) {
|
2020-07-13 11:31:08 +08:00
|
|
|
if ((Score = Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx)))
|
|
|
|
ScorePtr = &*Score;
|
2020-04-04 00:29:53 +08:00
|
|
|
else
|
2020-07-07 14:08:03 +08:00
|
|
|
VMI.addTrait(TraitProperty::user_condition_false,
|
|
|
|
"<non-constant-score>");
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
}
|
2020-04-04 00:29:53 +08:00
|
|
|
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
for (const OMPTraitProperty &Property : Selector.Properties)
|
2020-07-07 14:08:03 +08:00
|
|
|
VMI.addTrait(Set.Kind, Property.Kind, Property.RawString, ScorePtr);
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
|
2020-03-26 08:33:48 +08:00
|
|
|
if (Set.Kind != TraitSet::construct)
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// TODO: This might not hold once we implement SIMD properly.
|
|
|
|
assert(Selector.Properties.size() == 1 &&
|
|
|
|
Selector.Properties.front().Kind ==
|
2020-03-26 08:33:48 +08:00
|
|
|
getOpenMPContextTraitPropertyForSelector(
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
Selector.Kind) &&
|
|
|
|
"Ill-formed construct selector!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OMPTraitInfo::print(llvm::raw_ostream &OS,
|
|
|
|
const PrintingPolicy &Policy) const {
|
|
|
|
bool FirstSet = true;
|
2020-04-04 03:35:30 +08:00
|
|
|
for (const OMPTraitSet &Set : Sets) {
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
if (!FirstSet)
|
|
|
|
OS << ", ";
|
|
|
|
FirstSet = false;
|
2020-03-26 08:33:48 +08:00
|
|
|
OS << getOpenMPContextTraitSetName(Set.Kind) << "={";
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
|
|
|
|
bool FirstSelector = true;
|
2020-04-04 03:35:30 +08:00
|
|
|
for (const OMPTraitSelector &Selector : Set.Selectors) {
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
if (!FirstSelector)
|
|
|
|
OS << ", ";
|
|
|
|
FirstSelector = false;
|
2020-03-26 08:33:48 +08:00
|
|
|
OS << getOpenMPContextTraitSelectorName(Selector.Kind);
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
|
|
|
|
bool AllowsTraitScore = false;
|
|
|
|
bool RequiresProperty = false;
|
2020-03-26 08:33:48 +08:00
|
|
|
isValidTraitSelectorForTraitSet(
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
Selector.Kind, Set.Kind, AllowsTraitScore, RequiresProperty);
|
|
|
|
|
|
|
|
if (!RequiresProperty)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
OS << "(";
|
2020-03-26 08:33:48 +08:00
|
|
|
if (Selector.Kind == TraitSelector::user_condition) {
|
2020-08-13 08:44:25 +08:00
|
|
|
if (Selector.ScoreOrCondition)
|
|
|
|
Selector.ScoreOrCondition->printPretty(OS, nullptr, Policy);
|
|
|
|
else
|
|
|
|
OS << "...";
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
} else {
|
|
|
|
|
|
|
|
if (Selector.ScoreOrCondition) {
|
|
|
|
OS << "score(";
|
|
|
|
Selector.ScoreOrCondition->printPretty(OS, nullptr, Policy);
|
|
|
|
OS << "): ";
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FirstProperty = true;
|
2020-04-04 03:35:30 +08:00
|
|
|
for (const OMPTraitProperty &Property : Selector.Properties) {
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
if (!FirstProperty)
|
|
|
|
OS << ", ";
|
|
|
|
FirstProperty = false;
|
2020-07-07 14:08:03 +08:00
|
|
|
OS << getOpenMPContextTraitPropertyName(Property.Kind,
|
|
|
|
Property.RawString);
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
OS << "}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[OpenMP] `omp begin/end declare variant` - part 2, sema ("+CG")
This is the second part loosely extracted from D71179 and cleaned up.
This patch provides semantic analysis support for `omp begin/end declare
variant`, mostly as defined in OpenMP technical report 8 (TR8) [0].
The sema handling makes code generation obsolete as we generate "the
right" calls that can just be handled as usual. This handling also
applies to the existing, albeit problematic, `omp declare variant
support`. As a consequence a lot of unneeded code generation and
complexity is removed.
A major purpose of this patch is to provide proper `math.h`/`cmath`
support for OpenMP target offloading. See PR42061, PR42798, PR42799. The
current code was developed with this feature in mind, see [1].
The logic is as follows:
If we have seen a `#pragma omp begin declare variant match(<SELECTOR>)`
but not the corresponding `end declare variant`, and we find a function
definition we will:
1) Create a function declaration for the definition we were about to generate.
2) Create a function definition but with a mangled name (according to
`<SELECTOR>`).
3) Annotate the declaration with the `OMPDeclareVariantAttr`, the same
one used already for `omp declare variant`, using and the mangled
function definition as specialization for the context defined by
`<SELECTOR>`.
When a call is created we inspect it. If the target has an
`OMPDeclareVariantAttr` attribute we try to specialize the call. To this
end, all variants are checked, the best applicable one is picked and a
new call to the specialization is created. The new call is used instead
of the original one to the base function. To keep the AST printing and
tooling possible we utilize the PseudoObjectExpr. The original call is
the syntactic expression, the specialized call is the semantic
expression.
[0] https://www.openmp.org/wp-content/uploads/openmp-TR8.pdf
[1] https://reviews.llvm.org/D61399#change-496lQkg0mhRN
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim, aaron.ballman
Subscribers: bollu, guansong, openmp-commits, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D75779
2020-02-26 06:04:06 +08:00
|
|
|
std::string OMPTraitInfo::getMangledName() const {
|
|
|
|
std::string MangledName;
|
|
|
|
llvm::raw_string_ostream OS(MangledName);
|
2020-04-04 03:35:30 +08:00
|
|
|
for (const OMPTraitSet &Set : Sets) {
|
2020-06-04 04:32:49 +08:00
|
|
|
OS << '$' << 'S' << unsigned(Set.Kind);
|
2020-04-04 03:35:30 +08:00
|
|
|
for (const OMPTraitSelector &Selector : Set.Selectors) {
|
[OpenMP] `omp begin/end declare variant` - part 2, sema ("+CG")
This is the second part loosely extracted from D71179 and cleaned up.
This patch provides semantic analysis support for `omp begin/end declare
variant`, mostly as defined in OpenMP technical report 8 (TR8) [0].
The sema handling makes code generation obsolete as we generate "the
right" calls that can just be handled as usual. This handling also
applies to the existing, albeit problematic, `omp declare variant
support`. As a consequence a lot of unneeded code generation and
complexity is removed.
A major purpose of this patch is to provide proper `math.h`/`cmath`
support for OpenMP target offloading. See PR42061, PR42798, PR42799. The
current code was developed with this feature in mind, see [1].
The logic is as follows:
If we have seen a `#pragma omp begin declare variant match(<SELECTOR>)`
but not the corresponding `end declare variant`, and we find a function
definition we will:
1) Create a function declaration for the definition we were about to generate.
2) Create a function definition but with a mangled name (according to
`<SELECTOR>`).
3) Annotate the declaration with the `OMPDeclareVariantAttr`, the same
one used already for `omp declare variant`, using and the mangled
function definition as specialization for the context defined by
`<SELECTOR>`.
When a call is created we inspect it. If the target has an
`OMPDeclareVariantAttr` attribute we try to specialize the call. To this
end, all variants are checked, the best applicable one is picked and a
new call to the specialization is created. The new call is used instead
of the original one to the base function. To keep the AST printing and
tooling possible we utilize the PseudoObjectExpr. The original call is
the syntactic expression, the specialized call is the semantic
expression.
[0] https://www.openmp.org/wp-content/uploads/openmp-TR8.pdf
[1] https://reviews.llvm.org/D61399#change-496lQkg0mhRN
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim, aaron.ballman
Subscribers: bollu, guansong, openmp-commits, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D75779
2020-02-26 06:04:06 +08:00
|
|
|
|
|
|
|
bool AllowsTraitScore = false;
|
|
|
|
bool RequiresProperty = false;
|
|
|
|
isValidTraitSelectorForTraitSet(
|
|
|
|
Selector.Kind, Set.Kind, AllowsTraitScore, RequiresProperty);
|
2020-06-04 04:32:49 +08:00
|
|
|
OS << '$' << 's' << unsigned(Selector.Kind);
|
[OpenMP] `omp begin/end declare variant` - part 2, sema ("+CG")
This is the second part loosely extracted from D71179 and cleaned up.
This patch provides semantic analysis support for `omp begin/end declare
variant`, mostly as defined in OpenMP technical report 8 (TR8) [0].
The sema handling makes code generation obsolete as we generate "the
right" calls that can just be handled as usual. This handling also
applies to the existing, albeit problematic, `omp declare variant
support`. As a consequence a lot of unneeded code generation and
complexity is removed.
A major purpose of this patch is to provide proper `math.h`/`cmath`
support for OpenMP target offloading. See PR42061, PR42798, PR42799. The
current code was developed with this feature in mind, see [1].
The logic is as follows:
If we have seen a `#pragma omp begin declare variant match(<SELECTOR>)`
but not the corresponding `end declare variant`, and we find a function
definition we will:
1) Create a function declaration for the definition we were about to generate.
2) Create a function definition but with a mangled name (according to
`<SELECTOR>`).
3) Annotate the declaration with the `OMPDeclareVariantAttr`, the same
one used already for `omp declare variant`, using and the mangled
function definition as specialization for the context defined by
`<SELECTOR>`.
When a call is created we inspect it. If the target has an
`OMPDeclareVariantAttr` attribute we try to specialize the call. To this
end, all variants are checked, the best applicable one is picked and a
new call to the specialization is created. The new call is used instead
of the original one to the base function. To keep the AST printing and
tooling possible we utilize the PseudoObjectExpr. The original call is
the syntactic expression, the specialized call is the semantic
expression.
[0] https://www.openmp.org/wp-content/uploads/openmp-TR8.pdf
[1] https://reviews.llvm.org/D61399#change-496lQkg0mhRN
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim, aaron.ballman
Subscribers: bollu, guansong, openmp-commits, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D75779
2020-02-26 06:04:06 +08:00
|
|
|
|
|
|
|
if (!RequiresProperty ||
|
|
|
|
Selector.Kind == TraitSelector::user_condition)
|
|
|
|
continue;
|
|
|
|
|
2020-04-04 03:35:30 +08:00
|
|
|
for (const OMPTraitProperty &Property : Selector.Properties)
|
2020-07-07 14:08:03 +08:00
|
|
|
OS << '$' << 'P'
|
|
|
|
<< getOpenMPContextTraitPropertyName(Property.Kind,
|
|
|
|
Property.RawString);
|
[OpenMP] `omp begin/end declare variant` - part 2, sema ("+CG")
This is the second part loosely extracted from D71179 and cleaned up.
This patch provides semantic analysis support for `omp begin/end declare
variant`, mostly as defined in OpenMP technical report 8 (TR8) [0].
The sema handling makes code generation obsolete as we generate "the
right" calls that can just be handled as usual. This handling also
applies to the existing, albeit problematic, `omp declare variant
support`. As a consequence a lot of unneeded code generation and
complexity is removed.
A major purpose of this patch is to provide proper `math.h`/`cmath`
support for OpenMP target offloading. See PR42061, PR42798, PR42799. The
current code was developed with this feature in mind, see [1].
The logic is as follows:
If we have seen a `#pragma omp begin declare variant match(<SELECTOR>)`
but not the corresponding `end declare variant`, and we find a function
definition we will:
1) Create a function declaration for the definition we were about to generate.
2) Create a function definition but with a mangled name (according to
`<SELECTOR>`).
3) Annotate the declaration with the `OMPDeclareVariantAttr`, the same
one used already for `omp declare variant`, using and the mangled
function definition as specialization for the context defined by
`<SELECTOR>`.
When a call is created we inspect it. If the target has an
`OMPDeclareVariantAttr` attribute we try to specialize the call. To this
end, all variants are checked, the best applicable one is picked and a
new call to the specialization is created. The new call is used instead
of the original one to the base function. To keep the AST printing and
tooling possible we utilize the PseudoObjectExpr. The original call is
the syntactic expression, the specialized call is the semantic
expression.
[0] https://www.openmp.org/wp-content/uploads/openmp-TR8.pdf
[1] https://reviews.llvm.org/D61399#change-496lQkg0mhRN
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim, aaron.ballman
Subscribers: bollu, guansong, openmp-commits, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D75779
2020-02-26 06:04:06 +08:00
|
|
|
}
|
|
|
|
}
|
2021-12-10 06:52:30 +08:00
|
|
|
return MangledName;
|
[OpenMP] `omp begin/end declare variant` - part 2, sema ("+CG")
This is the second part loosely extracted from D71179 and cleaned up.
This patch provides semantic analysis support for `omp begin/end declare
variant`, mostly as defined in OpenMP technical report 8 (TR8) [0].
The sema handling makes code generation obsolete as we generate "the
right" calls that can just be handled as usual. This handling also
applies to the existing, albeit problematic, `omp declare variant
support`. As a consequence a lot of unneeded code generation and
complexity is removed.
A major purpose of this patch is to provide proper `math.h`/`cmath`
support for OpenMP target offloading. See PR42061, PR42798, PR42799. The
current code was developed with this feature in mind, see [1].
The logic is as follows:
If we have seen a `#pragma omp begin declare variant match(<SELECTOR>)`
but not the corresponding `end declare variant`, and we find a function
definition we will:
1) Create a function declaration for the definition we were about to generate.
2) Create a function definition but with a mangled name (according to
`<SELECTOR>`).
3) Annotate the declaration with the `OMPDeclareVariantAttr`, the same
one used already for `omp declare variant`, using and the mangled
function definition as specialization for the context defined by
`<SELECTOR>`.
When a call is created we inspect it. If the target has an
`OMPDeclareVariantAttr` attribute we try to specialize the call. To this
end, all variants are checked, the best applicable one is picked and a
new call to the specialization is created. The new call is used instead
of the original one to the base function. To keep the AST printing and
tooling possible we utilize the PseudoObjectExpr. The original call is
the syntactic expression, the specialized call is the semantic
expression.
[0] https://www.openmp.org/wp-content/uploads/openmp-TR8.pdf
[1] https://reviews.llvm.org/D61399#change-496lQkg0mhRN
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim, aaron.ballman
Subscribers: bollu, guansong, openmp-commits, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D75779
2020-02-26 06:04:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
OMPTraitInfo::OMPTraitInfo(StringRef MangledName) {
|
|
|
|
unsigned long U;
|
|
|
|
do {
|
2020-06-04 04:32:49 +08:00
|
|
|
if (!MangledName.consume_front("$S"))
|
[OpenMP] `omp begin/end declare variant` - part 2, sema ("+CG")
This is the second part loosely extracted from D71179 and cleaned up.
This patch provides semantic analysis support for `omp begin/end declare
variant`, mostly as defined in OpenMP technical report 8 (TR8) [0].
The sema handling makes code generation obsolete as we generate "the
right" calls that can just be handled as usual. This handling also
applies to the existing, albeit problematic, `omp declare variant
support`. As a consequence a lot of unneeded code generation and
complexity is removed.
A major purpose of this patch is to provide proper `math.h`/`cmath`
support for OpenMP target offloading. See PR42061, PR42798, PR42799. The
current code was developed with this feature in mind, see [1].
The logic is as follows:
If we have seen a `#pragma omp begin declare variant match(<SELECTOR>)`
but not the corresponding `end declare variant`, and we find a function
definition we will:
1) Create a function declaration for the definition we were about to generate.
2) Create a function definition but with a mangled name (according to
`<SELECTOR>`).
3) Annotate the declaration with the `OMPDeclareVariantAttr`, the same
one used already for `omp declare variant`, using and the mangled
function definition as specialization for the context defined by
`<SELECTOR>`.
When a call is created we inspect it. If the target has an
`OMPDeclareVariantAttr` attribute we try to specialize the call. To this
end, all variants are checked, the best applicable one is picked and a
new call to the specialization is created. The new call is used instead
of the original one to the base function. To keep the AST printing and
tooling possible we utilize the PseudoObjectExpr. The original call is
the syntactic expression, the specialized call is the semantic
expression.
[0] https://www.openmp.org/wp-content/uploads/openmp-TR8.pdf
[1] https://reviews.llvm.org/D61399#change-496lQkg0mhRN
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim, aaron.ballman
Subscribers: bollu, guansong, openmp-commits, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D75779
2020-02-26 06:04:06 +08:00
|
|
|
break;
|
|
|
|
if (MangledName.consumeInteger(10, U))
|
|
|
|
break;
|
|
|
|
Sets.push_back(OMPTraitSet());
|
|
|
|
OMPTraitSet &Set = Sets.back();
|
|
|
|
Set.Kind = TraitSet(U);
|
|
|
|
do {
|
2020-06-04 04:32:49 +08:00
|
|
|
if (!MangledName.consume_front("$s"))
|
[OpenMP] `omp begin/end declare variant` - part 2, sema ("+CG")
This is the second part loosely extracted from D71179 and cleaned up.
This patch provides semantic analysis support for `omp begin/end declare
variant`, mostly as defined in OpenMP technical report 8 (TR8) [0].
The sema handling makes code generation obsolete as we generate "the
right" calls that can just be handled as usual. This handling also
applies to the existing, albeit problematic, `omp declare variant
support`. As a consequence a lot of unneeded code generation and
complexity is removed.
A major purpose of this patch is to provide proper `math.h`/`cmath`
support for OpenMP target offloading. See PR42061, PR42798, PR42799. The
current code was developed with this feature in mind, see [1].
The logic is as follows:
If we have seen a `#pragma omp begin declare variant match(<SELECTOR>)`
but not the corresponding `end declare variant`, and we find a function
definition we will:
1) Create a function declaration for the definition we were about to generate.
2) Create a function definition but with a mangled name (according to
`<SELECTOR>`).
3) Annotate the declaration with the `OMPDeclareVariantAttr`, the same
one used already for `omp declare variant`, using and the mangled
function definition as specialization for the context defined by
`<SELECTOR>`.
When a call is created we inspect it. If the target has an
`OMPDeclareVariantAttr` attribute we try to specialize the call. To this
end, all variants are checked, the best applicable one is picked and a
new call to the specialization is created. The new call is used instead
of the original one to the base function. To keep the AST printing and
tooling possible we utilize the PseudoObjectExpr. The original call is
the syntactic expression, the specialized call is the semantic
expression.
[0] https://www.openmp.org/wp-content/uploads/openmp-TR8.pdf
[1] https://reviews.llvm.org/D61399#change-496lQkg0mhRN
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim, aaron.ballman
Subscribers: bollu, guansong, openmp-commits, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D75779
2020-02-26 06:04:06 +08:00
|
|
|
break;
|
|
|
|
if (MangledName.consumeInteger(10, U))
|
|
|
|
break;
|
|
|
|
Set.Selectors.push_back(OMPTraitSelector());
|
|
|
|
OMPTraitSelector &Selector = Set.Selectors.back();
|
|
|
|
Selector.Kind = TraitSelector(U);
|
|
|
|
do {
|
2020-06-04 04:32:49 +08:00
|
|
|
if (!MangledName.consume_front("$P"))
|
[OpenMP] `omp begin/end declare variant` - part 2, sema ("+CG")
This is the second part loosely extracted from D71179 and cleaned up.
This patch provides semantic analysis support for `omp begin/end declare
variant`, mostly as defined in OpenMP technical report 8 (TR8) [0].
The sema handling makes code generation obsolete as we generate "the
right" calls that can just be handled as usual. This handling also
applies to the existing, albeit problematic, `omp declare variant
support`. As a consequence a lot of unneeded code generation and
complexity is removed.
A major purpose of this patch is to provide proper `math.h`/`cmath`
support for OpenMP target offloading. See PR42061, PR42798, PR42799. The
current code was developed with this feature in mind, see [1].
The logic is as follows:
If we have seen a `#pragma omp begin declare variant match(<SELECTOR>)`
but not the corresponding `end declare variant`, and we find a function
definition we will:
1) Create a function declaration for the definition we were about to generate.
2) Create a function definition but with a mangled name (according to
`<SELECTOR>`).
3) Annotate the declaration with the `OMPDeclareVariantAttr`, the same
one used already for `omp declare variant`, using and the mangled
function definition as specialization for the context defined by
`<SELECTOR>`.
When a call is created we inspect it. If the target has an
`OMPDeclareVariantAttr` attribute we try to specialize the call. To this
end, all variants are checked, the best applicable one is picked and a
new call to the specialization is created. The new call is used instead
of the original one to the base function. To keep the AST printing and
tooling possible we utilize the PseudoObjectExpr. The original call is
the syntactic expression, the specialized call is the semantic
expression.
[0] https://www.openmp.org/wp-content/uploads/openmp-TR8.pdf
[1] https://reviews.llvm.org/D61399#change-496lQkg0mhRN
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim, aaron.ballman
Subscribers: bollu, guansong, openmp-commits, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D75779
2020-02-26 06:04:06 +08:00
|
|
|
break;
|
|
|
|
Selector.Properties.push_back(OMPTraitProperty());
|
|
|
|
OMPTraitProperty &Property = Selector.Properties.back();
|
2020-06-04 04:32:49 +08:00
|
|
|
std::pair<StringRef, StringRef> PropRestPair = MangledName.split('$');
|
2020-07-07 14:08:03 +08:00
|
|
|
Property.RawString = PropRestPair.first;
|
|
|
|
Property.Kind = getOpenMPContextTraitPropertyKind(
|
|
|
|
Set.Kind, Selector.Kind, PropRestPair.first);
|
2020-08-13 14:12:31 +08:00
|
|
|
MangledName = MangledName.drop_front(PropRestPair.first.size());
|
[OpenMP] `omp begin/end declare variant` - part 2, sema ("+CG")
This is the second part loosely extracted from D71179 and cleaned up.
This patch provides semantic analysis support for `omp begin/end declare
variant`, mostly as defined in OpenMP technical report 8 (TR8) [0].
The sema handling makes code generation obsolete as we generate "the
right" calls that can just be handled as usual. This handling also
applies to the existing, albeit problematic, `omp declare variant
support`. As a consequence a lot of unneeded code generation and
complexity is removed.
A major purpose of this patch is to provide proper `math.h`/`cmath`
support for OpenMP target offloading. See PR42061, PR42798, PR42799. The
current code was developed with this feature in mind, see [1].
The logic is as follows:
If we have seen a `#pragma omp begin declare variant match(<SELECTOR>)`
but not the corresponding `end declare variant`, and we find a function
definition we will:
1) Create a function declaration for the definition we were about to generate.
2) Create a function definition but with a mangled name (according to
`<SELECTOR>`).
3) Annotate the declaration with the `OMPDeclareVariantAttr`, the same
one used already for `omp declare variant`, using and the mangled
function definition as specialization for the context defined by
`<SELECTOR>`.
When a call is created we inspect it. If the target has an
`OMPDeclareVariantAttr` attribute we try to specialize the call. To this
end, all variants are checked, the best applicable one is picked and a
new call to the specialization is created. The new call is used instead
of the original one to the base function. To keep the AST printing and
tooling possible we utilize the PseudoObjectExpr. The original call is
the syntactic expression, the specialized call is the semantic
expression.
[0] https://www.openmp.org/wp-content/uploads/openmp-TR8.pdf
[1] https://reviews.llvm.org/D61399#change-496lQkg0mhRN
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim, aaron.ballman
Subscribers: bollu, guansong, openmp-commits, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D75779
2020-02-26 06:04:06 +08:00
|
|
|
} while (true);
|
|
|
|
} while (true);
|
|
|
|
} while (true);
|
|
|
|
}
|
|
|
|
|
[OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.
All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.
The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).
The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.
The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.
The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.
---
Test changes:
The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim
Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D71830
2019-12-20 10:42:12 +08:00
|
|
|
llvm::raw_ostream &clang::operator<<(llvm::raw_ostream &OS,
|
|
|
|
const OMPTraitInfo &TI) {
|
|
|
|
LangOptions LO;
|
|
|
|
PrintingPolicy Policy(LO);
|
|
|
|
TI.print(OS, Policy);
|
|
|
|
return OS;
|
|
|
|
}
|
2020-03-14 12:42:05 +08:00
|
|
|
llvm::raw_ostream &clang::operator<<(llvm::raw_ostream &OS,
|
|
|
|
const OMPTraitInfo *TI) {
|
|
|
|
return TI ? OS << *TI : OS;
|
|
|
|
}
|
2020-07-07 14:08:03 +08:00
|
|
|
|
|
|
|
TargetOMPContext::TargetOMPContext(
|
|
|
|
ASTContext &ASTCtx, std::function<void(StringRef)> &&DiagUnknownTrait,
|
2021-09-17 00:28:31 +08:00
|
|
|
const FunctionDecl *CurrentFunctionDecl,
|
|
|
|
ArrayRef<llvm::omp::TraitProperty> ConstructTraits)
|
2020-07-07 14:08:03 +08:00
|
|
|
: OMPContext(ASTCtx.getLangOpts().OpenMPIsDevice,
|
|
|
|
ASTCtx.getTargetInfo().getTriple()),
|
|
|
|
FeatureValidityCheck([&](StringRef FeatureName) {
|
|
|
|
return ASTCtx.getTargetInfo().isValidFeatureName(FeatureName);
|
|
|
|
}),
|
|
|
|
DiagUnknownTrait(std::move(DiagUnknownTrait)) {
|
|
|
|
ASTCtx.getFunctionFeatureMap(FeatureMap, CurrentFunctionDecl);
|
2021-09-17 00:28:31 +08:00
|
|
|
|
|
|
|
for (llvm::omp::TraitProperty Property : ConstructTraits)
|
|
|
|
addTrait(Property);
|
2020-07-07 14:08:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TargetOMPContext::matchesISATrait(StringRef RawString) const {
|
|
|
|
auto It = FeatureMap.find(RawString);
|
|
|
|
if (It != FeatureMap.end())
|
|
|
|
return It->second;
|
|
|
|
if (!FeatureValidityCheck(RawString))
|
|
|
|
DiagUnknownTrait(RawString);
|
|
|
|
return false;
|
|
|
|
}
|