2017-11-30 07:27:36 +08:00
|
|
|
//===- OpenMPClause.cpp - Classes for OpenMP clauses ----------------------===//
|
2015-10-02 21:41:04 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the subclesses of Stmt class declared in OpenMPClause.h
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/AST/OpenMPClause.h"
|
|
|
|
#include "clang/AST/ASTContext.h"
|
2017-11-30 07:27:36 +08:00
|
|
|
#include "clang/AST/Decl.h"
|
|
|
|
#include "clang/Basic/LLVM.h"
|
|
|
|
#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;
|
|
|
|
|
|
|
|
OMPClause::child_range OMPClause::children() {
|
|
|
|
switch (getClauseKind()) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
#define OPENMP_CLAUSE(Name, Class) \
|
|
|
|
case OMPC_##Name: \
|
|
|
|
return static_cast<Class *>(this)->children();
|
|
|
|
#include "clang/Basic/OpenMPKinds.def"
|
|
|
|
}
|
|
|
|
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);
|
2016-02-16 19:18:12 +08:00
|
|
|
case OMPC_default:
|
|
|
|
case OMPC_proc_bind:
|
|
|
|
case OMPC_final:
|
|
|
|
case OMPC_safelen:
|
|
|
|
case OMPC_simdlen:
|
|
|
|
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:
|
|
|
|
case OMPC_read:
|
|
|
|
case OMPC_write:
|
|
|
|
case OMPC_update:
|
|
|
|
case OMPC_capture:
|
|
|
|
case OMPC_seq_cst:
|
|
|
|
case OMPC_depend:
|
|
|
|
case OMPC_threads:
|
|
|
|
case OMPC_simd:
|
|
|
|
case OMPC_map:
|
|
|
|
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:
|
2016-07-14 01:16:49 +08:00
|
|
|
case OMPC_is_device_ptr:
|
2016-02-25 13:25:57 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
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:
|
|
|
|
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:
|
|
|
|
case OMPC_read:
|
|
|
|
case OMPC_write:
|
|
|
|
case OMPC_update:
|
|
|
|
case OMPC_capture:
|
|
|
|
case OMPC_seq_cst:
|
|
|
|
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:
|
2016-07-14 01:16:49 +08:00
|
|
|
case OMPC_is_device_ptr:
|
2016-02-16 19:18:12 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
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,
|
2016-02-25 13:25:57 +08:00
|
|
|
ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps, Stmt *PreInit,
|
|
|
|
Expr *PostUpdate) {
|
2016-01-01 08:38:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
|
2015-10-02 21:41:04 +08:00
|
|
|
OMPLastprivateClause *Clause =
|
|
|
|
new (Mem) OMPLastprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2015-10-02 21:41:04 +08:00
|
|
|
// Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
|
|
|
|
// (Step and CalcStep).
|
2016-01-01 08:38:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2));
|
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);
|
|
|
|
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) {
|
|
|
|
// Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
|
|
|
|
// (Step and CalcStep).
|
2016-01-01 08:38:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2));
|
2015-10-02 21:41:04 +08:00
|
|
|
return new (Mem) OMPLinearClause(NumVars);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPReductionClause *OMPReductionClause::Create(
|
|
|
|
const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
|
|
|
|
SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
|
|
|
|
NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
|
2015-10-08 17:10:53 +08:00
|
|
|
ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
|
2016-03-02 12:57:40 +08:00
|
|
|
ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit,
|
|
|
|
Expr *PostUpdate) {
|
2016-01-01 08:38:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
|
2015-10-02 21:41:04 +08:00
|
|
|
OMPReductionClause *Clause = new (Mem) OMPReductionClause(
|
|
|
|
StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
|
|
|
|
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);
|
2015-10-02 21:41:04 +08:00
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPReductionClause *OMPReductionClause::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) OMPReductionClause(N);
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2016-05-25 20:36:08 +08:00
|
|
|
OMPDependClause *OMPDependClause::Create(
|
|
|
|
const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
|
|
|
|
SourceLocation EndLoc, OpenMPDependClauseKind DepKind,
|
|
|
|
SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL) {
|
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
|
2015-10-02 21:41:04 +08:00
|
|
|
OMPDependClause *Clause =
|
|
|
|
new (Mem) OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size());
|
|
|
|
Clause->setVarRefs(VL);
|
|
|
|
Clause->setDependencyKind(DepKind);
|
|
|
|
Clause->setDependencyLoc(DepLoc);
|
|
|
|
Clause->setColonLoc(ColonLoc);
|
2016-05-25 20:36:08 +08:00
|
|
|
Clause->setCounterValue(nullptr);
|
2015-10-02 21:41:04 +08:00
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPDependClause *OMPDependClause::CreateEmpty(const ASTContext &C, unsigned N) {
|
2016-05-25 20:51:24 +08:00
|
|
|
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N + 1));
|
2015-10-02 21:41:04 +08:00
|
|
|
return new (Mem) OMPDependClause(N);
|
|
|
|
}
|
2015-11-23 13:32:03 +08:00
|
|
|
|
2016-05-25 20:36:08 +08:00
|
|
|
void OMPDependClause::setCounterValue(Expr *V) {
|
|
|
|
assert(getDependencyKind() == OMPC_DEPEND_sink ||
|
|
|
|
getDependencyKind() == OMPC_DEPEND_source || V == nullptr);
|
|
|
|
*getVarRefs().end() = V;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Expr *OMPDependClause::getCounterValue() const {
|
|
|
|
auto *V = *getVarRefs().end();
|
|
|
|
assert(getDependencyKind() == OMPC_DEPEND_sink ||
|
|
|
|
getDependencyKind() == OMPC_DEPEND_source || V == nullptr);
|
|
|
|
return V;
|
|
|
|
}
|
|
|
|
|
|
|
|
Expr *OMPDependClause::getCounterValue() {
|
|
|
|
auto *V = *getVarRefs().end();
|
|
|
|
assert(getDependencyKind() == OMPC_DEPEND_sink ||
|
|
|
|
getDependencyKind() == OMPC_DEPEND_source || V == nullptr);
|
|
|
|
return V;
|
|
|
|
}
|
|
|
|
|
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(
|
|
|
|
ArrayRef<ValueDecl *> Declarations) {
|
|
|
|
unsigned TotalNum = 0u;
|
|
|
|
llvm::SmallPtrSet<const ValueDecl *, 8> Cache;
|
|
|
|
for (auto *D : Declarations) {
|
|
|
|
const ValueDecl *VD = D ? cast<ValueDecl>(D->getCanonicalDecl()) : nullptr;
|
|
|
|
if (Cache.count(VD))
|
|
|
|
continue;
|
|
|
|
++TotalNum;
|
|
|
|
Cache.insert(VD);
|
|
|
|
}
|
|
|
|
return TotalNum;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPMapClause *
|
|
|
|
OMPMapClause::Create(const ASTContext &C, SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc, SourceLocation EndLoc,
|
|
|
|
ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
|
|
|
|
MappableExprComponentListsRef ComponentLists,
|
|
|
|
OpenMPMapClauseKind TypeModifier, OpenMPMapClauseKind Type,
|
|
|
|
bool TypeIsImplicit, SourceLocation TypeLoc) {
|
|
|
|
unsigned NumVars = Vars.size();
|
|
|
|
unsigned NumUniqueDeclarations =
|
|
|
|
getUniqueDeclarationsTotalNumber(Declarations);
|
|
|
|
unsigned NumComponentLists = ComponentLists.size();
|
|
|
|
unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
|
|
|
|
|
|
|
|
// 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>(
|
|
|
|
NumVars, NumUniqueDeclarations,
|
|
|
|
NumUniqueDeclarations + NumComponentLists, NumComponents));
|
|
|
|
OMPMapClause *Clause = new (Mem) OMPMapClause(
|
|
|
|
TypeModifier, Type, TypeIsImplicit, TypeLoc, StartLoc, LParenLoc, EndLoc,
|
|
|
|
NumVars, NumUniqueDeclarations, NumComponentLists, NumComponents);
|
|
|
|
|
|
|
|
Clause->setVarRefs(Vars);
|
|
|
|
Clause->setClauseInfo(Declarations, ComponentLists);
|
2015-11-23 13:32:03 +08:00
|
|
|
Clause->setMapTypeModifier(TypeModifier);
|
|
|
|
Clause->setMapType(Type);
|
|
|
|
Clause->setMapLoc(TypeLoc);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
2016-04-26 22:54:23 +08:00
|
|
|
OMPMapClause *OMPMapClause::CreateEmpty(const ASTContext &C, unsigned NumVars,
|
|
|
|
unsigned NumUniqueDeclarations,
|
|
|
|
unsigned NumComponentLists,
|
|
|
|
unsigned NumComponents) {
|
|
|
|
void *Mem = C.Allocate(
|
|
|
|
totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
|
|
|
|
OMPClauseMappableExprCommon::MappableComponent>(
|
|
|
|
NumVars, NumUniqueDeclarations,
|
|
|
|
NumUniqueDeclarations + NumComponentLists, NumComponents));
|
|
|
|
return new (Mem) OMPMapClause(NumVars, NumUniqueDeclarations,
|
|
|
|
NumComponentLists, NumComponents);
|
2015-11-23 13:32:03 +08:00
|
|
|
}
|
2016-05-27 01:39:58 +08:00
|
|
|
|
|
|
|
OMPToClause *OMPToClause::Create(const ASTContext &C, SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation EndLoc, ArrayRef<Expr *> Vars,
|
|
|
|
ArrayRef<ValueDecl *> Declarations,
|
|
|
|
MappableExprComponentListsRef ComponentLists) {
|
|
|
|
unsigned NumVars = Vars.size();
|
|
|
|
unsigned NumUniqueDeclarations =
|
|
|
|
getUniqueDeclarationsTotalNumber(Declarations);
|
|
|
|
unsigned NumComponentLists = ComponentLists.size();
|
|
|
|
unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
|
|
|
|
|
|
|
|
// 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>(
|
|
|
|
NumVars, NumUniqueDeclarations,
|
|
|
|
NumUniqueDeclarations + NumComponentLists, NumComponents));
|
|
|
|
|
|
|
|
OMPToClause *Clause = new (Mem)
|
|
|
|
OMPToClause(StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
|
|
|
|
NumComponentLists, NumComponents);
|
|
|
|
|
|
|
|
Clause->setVarRefs(Vars);
|
|
|
|
Clause->setClauseInfo(Declarations, ComponentLists);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPToClause *OMPToClause::CreateEmpty(const ASTContext &C, unsigned NumVars,
|
|
|
|
unsigned NumUniqueDeclarations,
|
|
|
|
unsigned NumComponentLists,
|
|
|
|
unsigned NumComponents) {
|
|
|
|
void *Mem = C.Allocate(
|
|
|
|
totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
|
|
|
|
OMPClauseMappableExprCommon::MappableComponent>(
|
|
|
|
NumVars, NumUniqueDeclarations,
|
|
|
|
NumUniqueDeclarations + NumComponentLists, NumComponents));
|
|
|
|
return new (Mem) OMPToClause(NumVars, NumUniqueDeclarations,
|
|
|
|
NumComponentLists, NumComponents);
|
|
|
|
}
|
2016-05-27 01:49:04 +08:00
|
|
|
|
|
|
|
OMPFromClause *
|
|
|
|
OMPFromClause::Create(const ASTContext &C, SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc, SourceLocation EndLoc,
|
|
|
|
ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
|
|
|
|
MappableExprComponentListsRef ComponentLists) {
|
|
|
|
unsigned NumVars = Vars.size();
|
|
|
|
unsigned NumUniqueDeclarations =
|
|
|
|
getUniqueDeclarationsTotalNumber(Declarations);
|
|
|
|
unsigned NumComponentLists = ComponentLists.size();
|
|
|
|
unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
|
|
|
|
|
|
|
|
// 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>(
|
|
|
|
NumVars, NumUniqueDeclarations,
|
|
|
|
NumUniqueDeclarations + NumComponentLists, NumComponents));
|
|
|
|
|
|
|
|
OMPFromClause *Clause = new (Mem)
|
|
|
|
OMPFromClause(StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
|
|
|
|
NumComponentLists, NumComponents);
|
|
|
|
|
|
|
|
Clause->setVarRefs(Vars);
|
|
|
|
Clause->setClauseInfo(Declarations, ComponentLists);
|
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
|
|
|
OMPFromClause *OMPFromClause::CreateEmpty(const ASTContext &C, unsigned NumVars,
|
|
|
|
unsigned NumUniqueDeclarations,
|
|
|
|
unsigned NumComponentLists,
|
|
|
|
unsigned NumComponents) {
|
|
|
|
void *Mem = C.Allocate(
|
|
|
|
totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
|
|
|
|
OMPClauseMappableExprCommon::MappableComponent>(
|
|
|
|
NumVars, NumUniqueDeclarations,
|
|
|
|
NumUniqueDeclarations + NumComponentLists, NumComponents));
|
|
|
|
return new (Mem) OMPFromClause(NumVars, NumUniqueDeclarations,
|
|
|
|
NumComponentLists, NumComponents);
|
|
|
|
}
|
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(
|
|
|
|
const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
|
|
|
|
SourceLocation EndLoc, ArrayRef<Expr *> Vars, ArrayRef<Expr *> PrivateVars,
|
|
|
|
ArrayRef<Expr *> Inits, ArrayRef<ValueDecl *> Declarations,
|
|
|
|
MappableExprComponentListsRef ComponentLists) {
|
|
|
|
unsigned NumVars = Vars.size();
|
|
|
|
unsigned NumUniqueDeclarations =
|
|
|
|
getUniqueDeclarationsTotalNumber(Declarations);
|
|
|
|
unsigned NumComponentLists = ComponentLists.size();
|
|
|
|
unsigned 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>(
|
|
|
|
3 * NumVars, NumUniqueDeclarations,
|
|
|
|
NumUniqueDeclarations + NumComponentLists, NumComponents));
|
|
|
|
|
|
|
|
OMPUseDevicePtrClause *Clause = new (Mem) OMPUseDevicePtrClause(
|
|
|
|
StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
|
|
|
|
NumComponentLists, NumComponents);
|
|
|
|
|
|
|
|
Clause->setVarRefs(Vars);
|
|
|
|
Clause->setPrivateCopies(PrivateVars);
|
|
|
|
Clause->setInits(Inits);
|
|
|
|
Clause->setClauseInfo(Declarations, ComponentLists);
|
2016-07-13 23:37:16 +08:00
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
2016-07-28 22:23:26 +08:00
|
|
|
OMPUseDevicePtrClause *OMPUseDevicePtrClause::CreateEmpty(
|
|
|
|
const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations,
|
|
|
|
unsigned NumComponentLists, unsigned NumComponents) {
|
|
|
|
void *Mem = C.Allocate(
|
|
|
|
totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
|
|
|
|
OMPClauseMappableExprCommon::MappableComponent>(
|
|
|
|
3 * NumVars, NumUniqueDeclarations,
|
|
|
|
NumUniqueDeclarations + NumComponentLists, NumComponents));
|
|
|
|
return new (Mem) OMPUseDevicePtrClause(NumVars, NumUniqueDeclarations,
|
|
|
|
NumComponentLists, NumComponents);
|
2016-07-13 23:37:16 +08:00
|
|
|
}
|
2016-07-14 01:16:49 +08:00
|
|
|
|
2016-07-28 22:25:09 +08:00
|
|
|
OMPIsDevicePtrClause *
|
|
|
|
OMPIsDevicePtrClause::Create(const ASTContext &C, SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc, SourceLocation EndLoc,
|
|
|
|
ArrayRef<Expr *> Vars,
|
|
|
|
ArrayRef<ValueDecl *> Declarations,
|
|
|
|
MappableExprComponentListsRef ComponentLists) {
|
|
|
|
unsigned NumVars = Vars.size();
|
|
|
|
unsigned NumUniqueDeclarations =
|
|
|
|
getUniqueDeclarationsTotalNumber(Declarations);
|
|
|
|
unsigned NumComponentLists = ComponentLists.size();
|
|
|
|
unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
|
|
|
|
|
|
|
|
// 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>(
|
|
|
|
NumVars, NumUniqueDeclarations,
|
|
|
|
NumUniqueDeclarations + NumComponentLists, NumComponents));
|
|
|
|
|
|
|
|
OMPIsDevicePtrClause *Clause = new (Mem) OMPIsDevicePtrClause(
|
|
|
|
StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
|
|
|
|
NumComponentLists, NumComponents);
|
|
|
|
|
|
|
|
Clause->setVarRefs(Vars);
|
|
|
|
Clause->setClauseInfo(Declarations, ComponentLists);
|
2016-07-14 01:16:49 +08:00
|
|
|
return Clause;
|
|
|
|
}
|
|
|
|
|
2016-07-28 22:25:09 +08:00
|
|
|
OMPIsDevicePtrClause *OMPIsDevicePtrClause::CreateEmpty(
|
|
|
|
const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations,
|
|
|
|
unsigned NumComponentLists, unsigned NumComponents) {
|
|
|
|
void *Mem = C.Allocate(
|
|
|
|
totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
|
|
|
|
OMPClauseMappableExprCommon::MappableComponent>(
|
|
|
|
NumVars, NumUniqueDeclarations,
|
|
|
|
NumUniqueDeclarations + NumComponentLists, NumComponents));
|
|
|
|
return new (Mem) OMPIsDevicePtrClause(NumVars, NumUniqueDeclarations,
|
|
|
|
NumComponentLists, NumComponents);
|
2016-07-14 01:16:49 +08:00
|
|
|
}
|