forked from OSchip/llvm-project
Add support for 'dynamic_allocators' clause on 'requires' directive. Differential Revision: https://reviews.llvm.org/D53079
llvm-svn: 344249
This commit is contained in:
parent
352a2fa1e7
commit
3fe9e396f4
|
@ -827,6 +827,38 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
/// This represents 'dynamic_allocators' clause in the '#pragma omp requires'
|
||||
/// directive.
|
||||
///
|
||||
/// \code
|
||||
/// #pragma omp requires dynamic_allocators
|
||||
/// \endcode
|
||||
/// In this example directive '#pragma omp requires' has 'dynamic_allocators'
|
||||
/// clause.
|
||||
class OMPDynamicAllocatorsClause final : public OMPClause {
|
||||
public:
|
||||
friend class OMPClauseReader;
|
||||
/// Build 'dynamic_allocators' clause.
|
||||
///
|
||||
/// \param StartLoc Starting location of the clause.
|
||||
/// \param EndLoc Ending location of the clause.
|
||||
OMPDynamicAllocatorsClause(SourceLocation StartLoc, SourceLocation EndLoc)
|
||||
: OMPClause(OMPC_dynamic_allocators, StartLoc, EndLoc) {}
|
||||
|
||||
/// Build an empty clause.
|
||||
OMPDynamicAllocatorsClause()
|
||||
: OMPClause(OMPC_dynamic_allocators, SourceLocation(), SourceLocation()) {
|
||||
}
|
||||
|
||||
child_range children() {
|
||||
return child_range(child_iterator(), child_iterator());
|
||||
}
|
||||
|
||||
static bool classof(const OMPClause *T) {
|
||||
return T->getClauseKind() == OMPC_dynamic_allocators;
|
||||
}
|
||||
};
|
||||
|
||||
/// This represents 'schedule' clause in the '#pragma omp ...' directive.
|
||||
///
|
||||
/// \code
|
||||
|
|
|
@ -2879,6 +2879,12 @@ bool RecursiveASTVisitor<Derived>::VisitOMPReverseOffloadClause(
|
|||
return true;
|
||||
}
|
||||
|
||||
template <typename Derived>
|
||||
bool RecursiveASTVisitor<Derived>::VisitOMPDynamicAllocatorsClause(
|
||||
OMPDynamicAllocatorsClause *) {
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Derived>
|
||||
bool
|
||||
RecursiveASTVisitor<Derived>::VisitOMPScheduleClause(OMPScheduleClause *C) {
|
||||
|
|
|
@ -282,6 +282,7 @@ OPENMP_CLAUSE(in_reduction, OMPInReductionClause)
|
|||
OPENMP_CLAUSE(unified_address, OMPUnifiedAddressClause)
|
||||
OPENMP_CLAUSE(unified_shared_memory, OMPUnifiedSharedMemoryClause)
|
||||
OPENMP_CLAUSE(reverse_offload, OMPReverseOffloadClause)
|
||||
OPENMP_CLAUSE(dynamic_allocators, OMPDynamicAllocatorsClause)
|
||||
|
||||
// Clauses allowed for OpenMP directive 'parallel'.
|
||||
OPENMP_PARALLEL_CLAUSE(if)
|
||||
|
@ -467,6 +468,7 @@ OPENMP_TARGET_CLAUSE(reduction)
|
|||
OPENMP_REQUIRES_CLAUSE(unified_address)
|
||||
OPENMP_REQUIRES_CLAUSE(unified_shared_memory)
|
||||
OPENMP_REQUIRES_CLAUSE(reverse_offload)
|
||||
OPENMP_REQUIRES_CLAUSE(dynamic_allocators)
|
||||
|
||||
// Clauses allowed for OpenMP directive 'target data'.
|
||||
OPENMP_TARGET_DATA_CLAUSE(if)
|
||||
|
|
|
@ -9191,6 +9191,10 @@ public:
|
|||
OMPClause *ActOnOpenMPReverseOffloadClause(SourceLocation StartLoc,
|
||||
SourceLocation EndLoc);
|
||||
|
||||
/// Called on well-formed 'dynamic_allocators' clause.
|
||||
OMPClause *ActOnOpenMPDynamicAllocatorsClause(SourceLocation StartLoc,
|
||||
SourceLocation EndLoc);
|
||||
|
||||
OMPClause *ActOnOpenMPVarListClause(
|
||||
OpenMPClauseKind Kind, ArrayRef<Expr *> Vars, Expr *TailExpr,
|
||||
SourceLocation StartLoc, SourceLocation LParenLoc,
|
||||
|
|
|
@ -109,6 +109,7 @@ const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) {
|
|||
case OMPC_unified_address:
|
||||
case OMPC_unified_shared_memory:
|
||||
case OMPC_reverse_offload:
|
||||
case OMPC_dynamic_allocators:
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -181,6 +182,7 @@ const OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(const OMPClause *C)
|
|||
case OMPC_unified_address:
|
||||
case OMPC_unified_shared_memory:
|
||||
case OMPC_reverse_offload:
|
||||
case OMPC_dynamic_allocators:
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -709,6 +709,11 @@ void OMPClausePrinter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {
|
|||
OS << "reverse_offload";
|
||||
}
|
||||
|
||||
void OMPClausePrinter::VisitOMPDynamicAllocatorsClause(
|
||||
OMPDynamicAllocatorsClause *) {
|
||||
OS << "dynamic_allocators";
|
||||
}
|
||||
|
||||
void OMPClausePrinter::VisitOMPScheduleClause(OMPScheduleClause *Node) {
|
||||
OS << "schedule(";
|
||||
if (Node->getFirstScheduleModifier() != OMPC_SCHEDULE_MODIFIER_unknown) {
|
||||
|
|
|
@ -476,6 +476,9 @@ void OMPClauseProfiler::VisitOMPUnifiedSharedMemoryClause(
|
|||
void OMPClauseProfiler::VisitOMPReverseOffloadClause(
|
||||
const OMPReverseOffloadClause *C) {}
|
||||
|
||||
void OMPClauseProfiler::VisitOMPDynamicAllocatorsClause(
|
||||
const OMPDynamicAllocatorsClause *C) {}
|
||||
|
||||
void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) {
|
||||
VistOMPClauseWithPreInit(C);
|
||||
if (auto *S = C->getChunkSize())
|
||||
|
|
|
@ -171,6 +171,7 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind,
|
|||
case OMPC_unified_address:
|
||||
case OMPC_unified_shared_memory:
|
||||
case OMPC_reverse_offload:
|
||||
case OMPC_dynamic_allocators:
|
||||
break;
|
||||
}
|
||||
llvm_unreachable("Invalid OpenMP simple clause kind");
|
||||
|
@ -315,6 +316,7 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
|
|||
case OMPC_unified_address:
|
||||
case OMPC_unified_shared_memory:
|
||||
case OMPC_reverse_offload:
|
||||
case OMPC_dynamic_allocators:
|
||||
break;
|
||||
}
|
||||
llvm_unreachable("Invalid OpenMP simple clause kind");
|
||||
|
|
|
@ -3901,6 +3901,7 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, OpenMPClauseKind Kind,
|
|||
case OMPC_unified_address:
|
||||
case OMPC_unified_shared_memory:
|
||||
case OMPC_reverse_offload:
|
||||
case OMPC_dynamic_allocators:
|
||||
llvm_unreachable("Clause is not allowed in 'omp atomic'.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1381,6 +1381,7 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
|
|||
case OMPC_unified_address:
|
||||
case OMPC_unified_shared_memory:
|
||||
case OMPC_reverse_offload:
|
||||
case OMPC_dynamic_allocators:
|
||||
// OpenMP [2.7.1, Restrictions, p. 9]
|
||||
// Only one ordered clause can appear on a loop directive.
|
||||
// OpenMP [2.7.1, Restrictions, C/C++, p. 4]
|
||||
|
|
|
@ -8013,6 +8013,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
|
|||
case OMPC_unified_address:
|
||||
case OMPC_unified_shared_memory:
|
||||
case OMPC_reverse_offload:
|
||||
case OMPC_dynamic_allocators:
|
||||
llvm_unreachable("Clause is not allowed.");
|
||||
}
|
||||
return Res;
|
||||
|
@ -8537,6 +8538,7 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause(
|
|||
case OMPC_unified_address:
|
||||
case OMPC_unified_shared_memory:
|
||||
case OMPC_reverse_offload:
|
||||
case OMPC_dynamic_allocators:
|
||||
llvm_unreachable("Unexpected OpenMP clause.");
|
||||
}
|
||||
return CaptureRegion;
|
||||
|
@ -8857,6 +8859,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause(
|
|||
case OMPC_unified_address:
|
||||
case OMPC_unified_shared_memory:
|
||||
case OMPC_reverse_offload:
|
||||
case OMPC_dynamic_allocators:
|
||||
llvm_unreachable("Clause is not allowed.");
|
||||
}
|
||||
return Res;
|
||||
|
@ -9016,6 +9019,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprWithArgClause(
|
|||
case OMPC_unified_address:
|
||||
case OMPC_unified_shared_memory:
|
||||
case OMPC_reverse_offload:
|
||||
case OMPC_dynamic_allocators:
|
||||
llvm_unreachable("Clause is not allowed.");
|
||||
}
|
||||
return Res;
|
||||
|
@ -9180,6 +9184,9 @@ OMPClause *Sema::ActOnOpenMPClause(OpenMPClauseKind Kind,
|
|||
case OMPC_reverse_offload:
|
||||
Res = ActOnOpenMPReverseOffloadClause(StartLoc, EndLoc);
|
||||
break;
|
||||
case OMPC_dynamic_allocators:
|
||||
Res = ActOnOpenMPDynamicAllocatorsClause(StartLoc, EndLoc);
|
||||
break;
|
||||
case OMPC_if:
|
||||
case OMPC_final:
|
||||
case OMPC_num_threads:
|
||||
|
@ -9295,6 +9302,11 @@ OMPClause *Sema::ActOnOpenMPReverseOffloadClause(SourceLocation StartLoc,
|
|||
return new (Context) OMPReverseOffloadClause(StartLoc, EndLoc);
|
||||
}
|
||||
|
||||
OMPClause *Sema::ActOnOpenMPDynamicAllocatorsClause(SourceLocation StartLoc,
|
||||
SourceLocation EndLoc) {
|
||||
return new (Context) OMPDynamicAllocatorsClause(StartLoc, EndLoc);
|
||||
}
|
||||
|
||||
OMPClause *Sema::ActOnOpenMPVarListClause(
|
||||
OpenMPClauseKind Kind, ArrayRef<Expr *> VarList, Expr *TailExpr,
|
||||
SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc,
|
||||
|
@ -9405,6 +9417,7 @@ OMPClause *Sema::ActOnOpenMPVarListClause(
|
|||
case OMPC_unified_address:
|
||||
case OMPC_unified_shared_memory:
|
||||
case OMPC_reverse_offload:
|
||||
case OMPC_dynamic_allocators:
|
||||
llvm_unreachable("Clause is not allowed.");
|
||||
}
|
||||
return Res;
|
||||
|
|
|
@ -8449,6 +8449,13 @@ OMPClause *TreeTransform<Derived>::TransformOMPReverseOffloadClause(
|
|||
llvm_unreachable("reverse_offload clause cannot appear in dependent context");
|
||||
}
|
||||
|
||||
template <typename Derived>
|
||||
OMPClause *TreeTransform<Derived>::TransformOMPDynamicAllocatorsClause(
|
||||
OMPDynamicAllocatorsClause *C) {
|
||||
llvm_unreachable(
|
||||
"dynamic_allocators clause cannot appear in dependent context");
|
||||
}
|
||||
|
||||
template <typename Derived>
|
||||
OMPClause *
|
||||
TreeTransform<Derived>::TransformOMPPrivateClause(OMPPrivateClause *C) {
|
||||
|
|
|
@ -11729,6 +11729,9 @@ OMPClause *OMPClauseReader::readClause() {
|
|||
case OMPC_reverse_offload:
|
||||
C = new (Context) OMPReverseOffloadClause();
|
||||
break;
|
||||
case OMPC_dynamic_allocators:
|
||||
C = new (Context) OMPDynamicAllocatorsClause();
|
||||
break;
|
||||
case OMPC_private:
|
||||
C = OMPPrivateClause::CreateEmpty(Context, Record.readInt());
|
||||
break;
|
||||
|
@ -11964,6 +11967,10 @@ void OMPClauseReader::VisitOMPUnifiedSharedMemoryClause(
|
|||
|
||||
void OMPClauseReader::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {}
|
||||
|
||||
void
|
||||
OMPClauseReader::VisitOMPDynamicAllocatorsClause(OMPDynamicAllocatorsClause *) {
|
||||
}
|
||||
|
||||
void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
|
||||
C->setLParenLoc(Record.readSourceLocation());
|
||||
unsigned NumVars = C->varlist_size();
|
||||
|
|
|
@ -6937,3 +6937,7 @@ void OMPClauseWriter::VisitOMPUnifiedSharedMemoryClause(
|
|||
OMPUnifiedSharedMemoryClause *) {}
|
||||
|
||||
void OMPClauseWriter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {}
|
||||
|
||||
void
|
||||
OMPClauseWriter::VisitOMPDynamicAllocatorsClause(OMPDynamicAllocatorsClause *) {
|
||||
}
|
||||
|
|
|
@ -19,4 +19,7 @@
|
|||
#pragma omp requires reverse_offload
|
||||
// CHECK:#pragma omp requires reverse_offload
|
||||
|
||||
#pragma omp requires dynamic_allocators
|
||||
// CHECK:#pragma omp requires dynamic_allocators
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,11 @@
|
|||
|
||||
#pragma omp requires reverse_offload, reverse_offload // expected-error {{Only one reverse_offload clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'reverse_offload' clause}}
|
||||
|
||||
#pragma omp requires dynamic_allocators // expected-note {{dynamic_allocators clause previously used here}} expected-note {{dynamic_allocators clause previously used here}}
|
||||
|
||||
#pragma omp requires dynamic_allocators, dynamic_allocators // expected-error {{Only one dynamic_allocators clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'dynamic_allocators' clause}}
|
||||
|
||||
|
||||
#pragma omp requires // expected-error {{expected at least one clause on '#pragma omp requires' directive}}
|
||||
|
||||
#pragma omp requires invalid_clause // expected-warning {{extra tokens at the end of '#pragma omp requires' are ignored}} expected-error {{expected at least one clause on '#pragma omp requires' directive}}
|
||||
|
@ -24,7 +29,7 @@
|
|||
|
||||
#pragma omp requires invalid_clause unified_address // expected-warning {{extra tokens at the end of '#pragma omp requires' are ignored}} expected-error {{expected at least one clause on '#pragma omp requires' directive}}
|
||||
|
||||
#pragma omp requires unified_shared_memory, unified_address, reverse_offload // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error{{Only one unified_address clause can appear on a requires directive in a single translation unit}} expected-error{{Only one reverse_offload clause can appear on a requires directive in a single translation unit}}
|
||||
#pragma omp requires unified_shared_memory, unified_address, reverse_offload, dynamic_allocators // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error{{Only one unified_address clause can appear on a requires directive in a single translation unit}} expected-error{{Only one reverse_offload clause can appear on a requires directive in a single translation unit}} expected-error{{Only one dynamic_allocators clause can appear on a requires directive in a single translation unit}}
|
||||
|
||||
namespace A {
|
||||
#pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}}
|
||||
|
|
|
@ -2216,6 +2216,9 @@ void OMPClauseEnqueue::VisitOMPUnifiedSharedMemoryClause(
|
|||
void OMPClauseEnqueue::VisitOMPReverseOffloadClause(
|
||||
const OMPReverseOffloadClause *) {}
|
||||
|
||||
void OMPClauseEnqueue::VisitOMPDynamicAllocatorsClause(
|
||||
const OMPDynamicAllocatorsClause *) {}
|
||||
|
||||
void OMPClauseEnqueue::VisitOMPDeviceClause(const OMPDeviceClause *C) {
|
||||
Visitor->AddStmt(C->getDevice());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue