[OpenMP][NFCI] Move OpenMP clause information to `lib/Frontend/OpenMP`

This is a cleanup and normalization patch that also enables reuse with
Flang later on. A follow up will clean up and move the directive ->
clauses mapping.

Differential Revision: https://reviews.llvm.org/D77112
This commit is contained in:
Johannes Doerfert 2020-03-30 19:58:40 -05:00
parent b0b5f0416b
commit c18d55998b
29 changed files with 621 additions and 544 deletions

View File

@ -27,8 +27,8 @@ class Type;
#include "clang/AST/TypeNodes.inc"
class CXXCtorInitializer;
class OMPClause;
#define OPENMP_CLAUSE(KIND, CLASSNAME) class CLASSNAME;
#include "clang/Basic/OpenMPKinds.def"
#define OMP_CLAUSE_CLASS(Enum, Str, Class) class Class;
#include "llvm/Frontend/OpenMP/OMPKinds.def"
} // end namespace clang

View File

@ -148,8 +148,8 @@ private:
#define TYPE(DERIVED, BASE) NKI_##DERIVED##Type,
#include "clang/AST/TypeNodes.inc"
NKI_OMPClause,
#define OPENMP_CLAUSE(TextualSpelling, Class) NKI_##Class,
#include "clang/Basic/OpenMPKinds.def"
#define OMP_CLAUSE_CLASS(Enum, Str, Class) NKI_##Class,
#include "llvm/Frontend/OpenMP/OMPKinds.def"
NKI_NumberOfKinds
};
@ -204,8 +204,8 @@ KIND_TO_KIND_ID(OMPClause)
#include "clang/AST/StmtNodes.inc"
#define TYPE(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Type)
#include "clang/AST/TypeNodes.inc"
#define OPENMP_CLAUSE(TextualSpelling, Class) KIND_TO_KIND_ID(Class)
#include "clang/Basic/OpenMPKinds.def"
#define OMP_CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class)
#include "llvm/Frontend/OpenMP/OMPKinds.def"
#undef KIND_TO_KIND_ID
inline raw_ostream &operator<<(raw_ostream &OS, ASTNodeKind K) {

File diff suppressed because it is too large Load Diff

View File

@ -534,8 +534,8 @@ private:
bool TraverseOMPExecutableDirective(OMPExecutableDirective *S);
bool TraverseOMPLoopDirective(OMPLoopDirective *S);
bool TraverseOMPClause(OMPClause *C);
#define OPENMP_CLAUSE(Name, Class) bool Visit##Class(Class *C);
#include "clang/Basic/OpenMPKinds.def"
#define OMP_CLAUSE_CLASS(Enum, Str, Class) bool Visit##Class(Class *C);
#include "llvm/Frontend/OpenMP/OMPKinds.def"
/// Process clauses with list of variables.
template <typename T> bool VisitOMPClauseList(T *Node);
/// Process clauses with pre-initis.
@ -2956,17 +2956,14 @@ bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
if (!C)
return true;
switch (C->getClauseKind()) {
#define OPENMP_CLAUSE(Name, Class) \
case OMPC_##Name: \
#define OMP_CLAUSE_CLASS(Enum, Str, Class) \
case llvm::omp::Clause::Enum: \
TRY_TO(Visit##Class(static_cast<Class *>(C))); \
break;
#include "clang/Basic/OpenMPKinds.def"
case OMPC_threadprivate:
case OMPC_uniform:
case OMPC_device_type:
case OMPC_match:
case OMPC_unknown:
#define OMP_CLAUSE_NO_CLASS(Enum, Str) \
case llvm::omp::Clause::Enum: \
break;
#include "llvm/Frontend/OpenMP/OMPKinds.def"
}
return true;
}

View File

@ -3242,8 +3242,13 @@ def OMPCaptureKind : Attr {
// This attribute has no spellings as it is only ever created implicitly.
let Spellings = [];
let SemaHandler = 0;
let Args = [UnsignedArgument<"CaptureKind">];
let Args = [UnsignedArgument<"CaptureKindVal">];
let Documentation = [Undocumented];
let AdditionalMembers = [{
llvm::omp::Clause getCaptureKind() const {
return static_cast<llvm::omp::Clause>(getCaptureKindVal());
}
}];
}
def OMPReferencedVar : Attr {

View File

@ -222,74 +222,6 @@
#define OPENMP_REDUCTION_MODIFIER(Name)
#endif
// OpenMP clauses.
OPENMP_CLAUSE(allocator, OMPAllocatorClause)
OPENMP_CLAUSE(if, OMPIfClause)
OPENMP_CLAUSE(final, OMPFinalClause)
OPENMP_CLAUSE(num_threads, OMPNumThreadsClause)
OPENMP_CLAUSE(safelen, OMPSafelenClause)
OPENMP_CLAUSE(simdlen, OMPSimdlenClause)
OPENMP_CLAUSE(collapse, OMPCollapseClause)
OPENMP_CLAUSE(default, OMPDefaultClause)
OPENMP_CLAUSE(private, OMPPrivateClause)
OPENMP_CLAUSE(firstprivate, OMPFirstprivateClause)
OPENMP_CLAUSE(lastprivate, OMPLastprivateClause)
OPENMP_CLAUSE(shared, OMPSharedClause)
OPENMP_CLAUSE(reduction, OMPReductionClause)
OPENMP_CLAUSE(linear, OMPLinearClause)
OPENMP_CLAUSE(aligned, OMPAlignedClause)
OPENMP_CLAUSE(copyin, OMPCopyinClause)
OPENMP_CLAUSE(copyprivate, OMPCopyprivateClause)
OPENMP_CLAUSE(proc_bind, OMPProcBindClause)
OPENMP_CLAUSE(schedule, OMPScheduleClause)
OPENMP_CLAUSE(ordered, OMPOrderedClause)
OPENMP_CLAUSE(nowait, OMPNowaitClause)
OPENMP_CLAUSE(untied, OMPUntiedClause)
OPENMP_CLAUSE(mergeable, OMPMergeableClause)
OPENMP_CLAUSE(flush, OMPFlushClause)
OPENMP_CLAUSE(read, OMPReadClause)
OPENMP_CLAUSE(write, OMPWriteClause)
OPENMP_CLAUSE(update, OMPUpdateClause)
OPENMP_CLAUSE(capture, OMPCaptureClause)
OPENMP_CLAUSE(seq_cst, OMPSeqCstClause)
OPENMP_CLAUSE(acq_rel, OMPAcqRelClause)
OPENMP_CLAUSE(acquire, OMPAcquireClause)
OPENMP_CLAUSE(release, OMPReleaseClause)
OPENMP_CLAUSE(relaxed, OMPRelaxedClause)
OPENMP_CLAUSE(depend, OMPDependClause)
OPENMP_CLAUSE(device, OMPDeviceClause)
OPENMP_CLAUSE(threads, OMPThreadsClause)
OPENMP_CLAUSE(simd, OMPSIMDClause)
OPENMP_CLAUSE(map, OMPMapClause)
OPENMP_CLAUSE(num_teams, OMPNumTeamsClause)
OPENMP_CLAUSE(thread_limit, OMPThreadLimitClause)
OPENMP_CLAUSE(priority, OMPPriorityClause)
OPENMP_CLAUSE(grainsize, OMPGrainsizeClause)
OPENMP_CLAUSE(nogroup, OMPNogroupClause)
OPENMP_CLAUSE(num_tasks, OMPNumTasksClause)
OPENMP_CLAUSE(hint, OMPHintClause)
OPENMP_CLAUSE(dist_schedule, OMPDistScheduleClause)
OPENMP_CLAUSE(defaultmap, OMPDefaultmapClause)
OPENMP_CLAUSE(to, OMPToClause)
OPENMP_CLAUSE(from, OMPFromClause)
OPENMP_CLAUSE(use_device_ptr, OMPUseDevicePtrClause)
OPENMP_CLAUSE(is_device_ptr, OMPIsDevicePtrClause)
OPENMP_CLAUSE(task_reduction, OMPTaskReductionClause)
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)
OPENMP_CLAUSE(atomic_default_mem_order, OMPAtomicDefaultMemOrderClause)
OPENMP_CLAUSE(allocate, OMPAllocateClause)
OPENMP_CLAUSE(nontemporal, OMPNontemporalClause)
OPENMP_CLAUSE(order, OMPOrderClause)
OPENMP_CLAUSE(depobj, OMPDepobjClause)
OPENMP_CLAUSE(destroy, OMPDestroyClause)
OPENMP_CLAUSE(detach, OMPDetachClause)
OPENMP_CLAUSE(inclusive, OMPInclusiveClause)
OPENMP_CLAUSE(exclusive, OMPExclusiveClause)
// Clauses allowed for OpenMP directive 'scan'.
OPENMP_SCAN_CLAUSE(inclusive)
OPENMP_SCAN_CLAUSE(exclusive)

View File

@ -23,16 +23,7 @@ namespace clang {
using OpenMPDirectiveKind = llvm::omp::Directive;
/// OpenMP clauses.
enum OpenMPClauseKind {
#define OPENMP_CLAUSE(Name, Class) \
OMPC_##Name,
#include "clang/Basic/OpenMPKinds.def"
OMPC_threadprivate,
OMPC_uniform,
OMPC_device_type,
OMPC_match,
OMPC_unknown
};
using OpenMPClauseKind = llvm::omp::Clause;
/// OpenMP attributes for 'schedule' clause.
enum OpenMPScheduleClauseKind {
@ -175,9 +166,6 @@ enum OpenMPReductionClauseModifier {
OMPC_REDUCTION_unknown,
};
OpenMPClauseKind getOpenMPClauseKind(llvm::StringRef Str);
const char *getOpenMPClauseName(OpenMPClauseKind Kind);
unsigned getOpenMPSimpleClauseType(OpenMPClauseKind Kind, llvm::StringRef Str);
const char *getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type);

View File

@ -39,8 +39,8 @@ const ASTNodeKind::KindInfo ASTNodeKind::AllKindInfo[] = {
#define TYPE(DERIVED, BASE) { NKI_##BASE, #DERIVED "Type" },
#include "clang/AST/TypeNodes.inc"
{ NKI_None, "OMPClause" },
#define OPENMP_CLAUSE(TextualSpelling, Class) {NKI_OMPClause, #Class},
#include "clang/Basic/OpenMPKinds.def"
#define OMP_CLAUSE_CLASS(Enum, Str, Class) {NKI_OMPClause, #Class},
#include "llvm/Frontend/OpenMP/OMPKinds.def"
};
bool ASTNodeKind::isBaseOf(ASTNodeKind Other, unsigned *Distance) const {
@ -111,15 +111,13 @@ ASTNodeKind ASTNodeKind::getFromNode(const Type &T) {
ASTNodeKind ASTNodeKind::getFromNode(const OMPClause &C) {
switch (C.getClauseKind()) {
#define OPENMP_CLAUSE(Name, Class) \
case OMPC_##Name: return ASTNodeKind(NKI_##Class);
#include "clang/Basic/OpenMPKinds.def"
case OMPC_threadprivate:
case OMPC_uniform:
case OMPC_device_type:
case OMPC_match:
case OMPC_unknown:
#define OMP_CLAUSE_CLASS(Enum, Str, Class) \
case llvm::omp::Clause::Enum: \
return ASTNodeKind(NKI_##Class);
#define OMP_CLAUSE_NO_CLASS(Enum, Str) \
case llvm::omp::Clause::Enum: \
llvm_unreachable("unexpected OpenMP clause kind");
#include "llvm/Frontend/OpenMP/OMPKinds.def"
}
llvm_unreachable("invalid stmt kind");
}

View File

@ -108,7 +108,8 @@ void OMPDeclareSimdDeclAttr::printPrettyPragma(
for (auto *E : linears()) {
OS << " linear(";
if (*MI != OMPC_LINEAR_unknown)
OS << getOpenMPSimpleClauseTypeName(OMPC_linear, *MI) << "(";
OS << getOpenMPSimpleClauseTypeName(llvm::omp::Clause::OMPC_linear, *MI)
<< "(";
E->printPretty(OS, nullptr, Policy);
if (*MI != OMPC_LINEAR_unknown)
OS << ")";

View File

@ -31,20 +31,20 @@ OMPClause::child_range OMPClause::children() {
switch (getClauseKind()) {
default:
break;
#define OPENMP_CLAUSE(Name, Class) \
case OMPC_##Name: \
#define OMP_CLAUSE_CLASS(Enum, Str, Class) \
case Enum: \
return static_cast<Class *>(this)->children();
#include "clang/Basic/OpenMPKinds.def"
#include "llvm/Frontend/OpenMP/OMPKinds.def"
}
llvm_unreachable("unknown OMPClause");
}
OMPClause::child_range OMPClause::used_children() {
switch (getClauseKind()) {
#define OPENMP_CLAUSE(Name, Class) \
case OMPC_##Name: \
#define OMP_CLAUSE_CLASS(Enum, Str, Class) \
case Enum: \
return static_cast<Class *>(this)->used_children();
#include "clang/Basic/OpenMPKinds.def"
#include "llvm/Frontend/OpenMP/OMPKinds.def"
case OMPC_threadprivate:
case OMPC_uniform:
case OMPC_device_type:

View File

@ -414,9 +414,8 @@ class OMPClauseProfiler : public ConstOMPClauseVisitor<OMPClauseProfiler> {
public:
OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { }
#define OPENMP_CLAUSE(Name, Class) \
void Visit##Class(const Class *C);
#include "clang/Basic/OpenMPKinds.def"
#define OMP_CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(const Class *C);
#include "llvm/Frontend/OpenMP/OMPKinds.def"
void VistOMPClauseWithPreInit(const OMPClauseWithPreInit *C);
void VistOMPClauseWithPostUpdate(const OMPClauseWithPostUpdate *C);
};

View File

@ -314,7 +314,7 @@ void TextNodeDumper::Visit(const OMPClause *C) {
}
{
ColorScope Color(OS, ShowColors, AttrColor);
StringRef ClauseName(getOpenMPClauseName(C->getClauseKind()));
StringRef ClauseName(llvm::omp::getOpenMPClauseName(C->getClauseKind()));
OS << "OMP" << ClauseName.substr(/*Start=*/0, /*N=*/1).upper()
<< ClauseName.drop_front() << "Clause";
}
@ -1517,7 +1517,8 @@ void TextNodeDumper::VisitOMPRequiresDecl(const OMPRequiresDecl *D) {
}
{
ColorScope Color(OS, ShowColors, AttrColor);
StringRef ClauseName(getOpenMPClauseName(C->getClauseKind()));
StringRef ClauseName(
llvm::omp::getOpenMPClauseName(C->getClauseKind()));
OS << "OMP" << ClauseName.substr(/*Start=*/0, /*N=*/1).upper()
<< ClauseName.drop_front() << "Clause";
}

View File

@ -1,6 +1,9 @@
add_subdirectory(Dynamic)
set(LLVM_LINK_COMPONENTS support)
set(LLVM_LINK_COMPONENTS
FrontendOpenMP
Support
)
add_clang_library(clangASTMatchers
ASTMatchFinder.cpp

View File

@ -170,9 +170,8 @@ template <> struct ArgTypeTraits<OpenMPClauseKind> {
private:
static Optional<OpenMPClauseKind> getClauseKind(llvm::StringRef ClauseKind) {
return llvm::StringSwitch<Optional<OpenMPClauseKind>>(ClauseKind)
#define OPENMP_CLAUSE(TextualSpelling, Class) \
.Case("OMPC_" #TextualSpelling, OMPC_##TextualSpelling)
#include "clang/Basic/OpenMPKinds.def"
#define OMP_CLAUSE_CLASS(Enum, Str, Class) .Case(#Enum, llvm::omp::Clause::Enum)
#include "llvm/Frontend/OpenMP/OMPKinds.def"
.Default(llvm::None);
}

View File

@ -1,4 +1,5 @@
set(LLVM_LINK_COMPONENTS
FrontendOpenMP
Support
)

View File

@ -20,50 +20,6 @@
using namespace clang;
using namespace llvm::omp;
OpenMPClauseKind clang::getOpenMPClauseKind(StringRef Str) {
// 'flush' clause cannot be specified explicitly, because this is an implicit
// clause for 'flush' directive. If the 'flush' clause is explicitly specified
// the Parser should generate a warning about extra tokens at the end of the
// directive.
// 'depobj' clause cannot be specified explicitly, because this is an implicit
// clause for 'depobj' directive. If the 'depobj' clause is explicitly
// specified the Parser should generate a warning about extra tokens at the
// end of the directive.
if (llvm::StringSwitch<bool>(Str)
.Case("flush", true)
.Case("depobj", true)
.Default(false))
return OMPC_unknown;
return llvm::StringSwitch<OpenMPClauseKind>(Str)
#define OPENMP_CLAUSE(Name, Class) .Case(#Name, OMPC_##Name)
#include "clang/Basic/OpenMPKinds.def"
.Case("uniform", OMPC_uniform)
.Case("device_type", OMPC_device_type)
.Case("match", OMPC_match)
.Default(OMPC_unknown);
}
const char *clang::getOpenMPClauseName(OpenMPClauseKind Kind) {
assert(Kind <= OMPC_unknown);
switch (Kind) {
case OMPC_unknown:
return "unknown";
#define OPENMP_CLAUSE(Name, Class) \
case OMPC_##Name: \
return #Name;
#include "clang/Basic/OpenMPKinds.def"
case OMPC_uniform:
return "uniform";
case OMPC_threadprivate:
return "threadprivate or thread local";
case OMPC_device_type:
return "device_type";
case OMPC_match:
return "match";
}
llvm_unreachable("Invalid OpenMP clause kind");
}
unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind,
StringRef Str) {
switch (Kind) {

View File

@ -341,8 +341,7 @@ class CheckVarsEscapingDeclContext final
if (!Attr)
return;
if (((Attr->getCaptureKind() != OMPC_map) &&
!isOpenMPPrivate(
static_cast<OpenMPClauseKind>(Attr->getCaptureKind()))) ||
!isOpenMPPrivate(Attr->getCaptureKind())) ||
((Attr->getCaptureKind() == OMPC_map) &&
!FD->getType()->isAnyPointerType()))
return;

View File

@ -1387,7 +1387,7 @@ bool Parser::parseOMPDeclareVariantMatchClause(SourceLocation Loc,
// Parse '('.
BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end);
if (T.expectAndConsume(diag::err_expected_lparen_after,
getOpenMPClauseName(OMPC_match))) {
getOpenMPClauseName(OMPC_match).data())) {
while (!SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch))
;
// Skip the last annot_pragma_openmp_end.
@ -1434,7 +1434,7 @@ parseOpenMPSimpleClause(Parser &P, OpenMPClauseKind Kind) {
// Parse '('.
BalancedDelimiterTracker T(P, tok::l_paren, tok::annot_pragma_openmp_end);
if (T.expectAndConsume(diag::err_expected_lparen_after,
getOpenMPClauseName(Kind)))
getOpenMPClauseName(Kind).data()))
return llvm::None;
unsigned Type = getOpenMPSimpleClauseType(
@ -1673,18 +1673,18 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
SmallVector<OMPClause *, 1> Clauses;
if (Tok.isNot(tok::annot_pragma_openmp_end)) {
SmallVector<llvm::PointerIntPair<OMPClause *, 1, bool>,
OMPC_unknown + 1>
FirstClauses(OMPC_unknown + 1);
unsigned(OMPC_unknown) + 1>
FirstClauses(unsigned(OMPC_unknown) + 1);
while (Tok.isNot(tok::annot_pragma_openmp_end)) {
OpenMPClauseKind CKind =
Tok.isAnnotation() ? OMPC_unknown
: getOpenMPClauseKind(PP.getSpelling(Tok));
Actions.StartOpenMPClause(CKind);
OMPClause *Clause = ParseOpenMPClause(OMPD_allocate, CKind,
!FirstClauses[CKind].getInt());
OMPClause *Clause = ParseOpenMPClause(
OMPD_allocate, CKind, !FirstClauses[unsigned(CKind)].getInt());
SkipUntil(tok::comma, tok::identifier, tok::annot_pragma_openmp_end,
StopBeforeMatch);
FirstClauses[CKind].setInt(true);
FirstClauses[unsigned(CKind)].setInt(true);
if (Clause != nullptr)
Clauses.push_back(Clause);
if (Tok.is(tok::annot_pragma_openmp_end)) {
@ -1708,8 +1708,9 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
case OMPD_requires: {
SourceLocation StartLoc = ConsumeToken();
SmallVector<OMPClause *, 5> Clauses;
SmallVector<llvm::PointerIntPair<OMPClause *, 1, bool>, OMPC_unknown + 1>
FirstClauses(OMPC_unknown + 1);
SmallVector<llvm::PointerIntPair<OMPClause *, 1, bool>,
unsigned(OMPC_unknown) + 1>
FirstClauses(unsigned(OMPC_unknown) + 1);
if (Tok.is(tok::annot_pragma_openmp_end)) {
Diag(Tok, diag::err_omp_expected_clause)
<< getOpenMPDirectiveName(OMPD_requires);
@ -1720,11 +1721,11 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
? OMPC_unknown
: getOpenMPClauseKind(PP.getSpelling(Tok));
Actions.StartOpenMPClause(CKind);
OMPClause *Clause = ParseOpenMPClause(OMPD_requires, CKind,
!FirstClauses[CKind].getInt());
OMPClause *Clause = ParseOpenMPClause(
OMPD_requires, CKind, !FirstClauses[unsigned(CKind)].getInt());
SkipUntil(tok::comma, tok::identifier, tok::annot_pragma_openmp_end,
StopBeforeMatch);
FirstClauses[CKind].setInt(true);
FirstClauses[unsigned(CKind)].setInt(true);
if (Clause != nullptr)
Clauses.push_back(Clause);
if (Tok.is(tok::annot_pragma_openmp_end)) {
@ -2023,8 +2024,9 @@ Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
ParsingOpenMPDirectiveRAII DirScope(*this);
ParenBraceBracketBalancer BalancerRAIIObj(*this);
SmallVector<OMPClause *, 5> Clauses;
SmallVector<llvm::PointerIntPair<OMPClause *, 1, bool>, OMPC_unknown + 1>
FirstClauses(OMPC_unknown + 1);
SmallVector<llvm::PointerIntPair<OMPClause *, 1, bool>,
unsigned(OMPC_unknown) + 1>
FirstClauses(unsigned(OMPC_unknown) + 1);
unsigned ScopeFlags = Scope::FnScope | Scope::DeclScope |
Scope::CompoundStmtScope | Scope::OpenMPDirectiveScope;
SourceLocation Loc = ConsumeAnnotationToken(), EndLoc;
@ -2069,18 +2071,18 @@ Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
SmallVector<OMPClause *, 1> Clauses;
if (Tok.isNot(tok::annot_pragma_openmp_end)) {
SmallVector<llvm::PointerIntPair<OMPClause *, 1, bool>,
OMPC_unknown + 1>
FirstClauses(OMPC_unknown + 1);
unsigned(OMPC_unknown) + 1>
FirstClauses(unsigned(OMPC_unknown) + 1);
while (Tok.isNot(tok::annot_pragma_openmp_end)) {
OpenMPClauseKind CKind =
Tok.isAnnotation() ? OMPC_unknown
: getOpenMPClauseKind(PP.getSpelling(Tok));
Actions.StartOpenMPClause(CKind);
OMPClause *Clause = ParseOpenMPClause(OMPD_allocate, CKind,
!FirstClauses[CKind].getInt());
OMPClause *Clause = ParseOpenMPClause(
OMPD_allocate, CKind, !FirstClauses[unsigned(CKind)].getInt());
SkipUntil(tok::comma, tok::identifier, tok::annot_pragma_openmp_end,
StopBeforeMatch);
FirstClauses[CKind].setInt(true);
FirstClauses[unsigned(CKind)].setInt(true);
if (Clause != nullptr)
Clauses.push_back(Clause);
if (Tok.is(tok::annot_pragma_openmp_end)) {
@ -2248,11 +2250,11 @@ Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
ImplicitClauseAllowed = false;
Actions.StartOpenMPClause(CKind);
HasImplicitClause = false;
OMPClause *Clause =
ParseOpenMPClause(DKind, CKind, !FirstClauses[CKind].getInt());
FirstClauses[CKind].setInt(true);
OMPClause *Clause = ParseOpenMPClause(
DKind, CKind, !FirstClauses[unsigned(CKind)].getInt());
FirstClauses[unsigned(CKind)].setInt(true);
if (Clause) {
FirstClauses[CKind].setPointer(Clause);
FirstClauses[unsigned(CKind)].setPointer(Clause);
Clauses.push_back(Clause);
}
@ -2269,7 +2271,7 @@ Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
// OpenMP [2.13.8, ordered Construct, Syntax]
// If the depend clause is specified, the ordered construct is a stand-alone
// directive.
if (DKind == OMPD_ordered && FirstClauses[OMPC_depend].getInt()) {
if (DKind == OMPD_ordered && FirstClauses[unsigned(OMPC_depend)].getInt()) {
if ((StmtCtx & ParsedStmtContext::AllowStandaloneOpenMPDirectives) ==
ParsedStmtContext()) {
Diag(Loc, diag::err_omp_immediate_directive)
@ -2754,7 +2756,7 @@ OMPClause *Parser::ParseOpenMPSingleExprWithArgClause(OpenMPDirectiveKind DKind,
// Parse '('.
BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end);
if (T.expectAndConsume(diag::err_expected_lparen_after,
getOpenMPClauseName(Kind)))
getOpenMPClauseName(Kind).data()))
return nullptr;
ExprResult Val;
@ -3066,7 +3068,7 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
// Parse '('.
BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end);
if (T.expectAndConsume(diag::err_expected_lparen_after,
getOpenMPClauseName(Kind)))
getOpenMPClauseName(Kind).data()))
return true;
bool NeedRParenForLinear = false;

View File

@ -2231,7 +2231,7 @@ void Sema::setOpenMPCaptureKind(FieldDecl *FD, const ValueDecl *D,
}
}
if (OMPC != OMPC_unknown)
FD->addAttr(OMPCaptureKindAttr::CreateImplicit(Context, OMPC));
FD->addAttr(OMPCaptureKindAttr::CreateImplicit(Context, unsigned(OMPC)));
}
bool Sema::isOpenMPTargetCapturedDecl(const ValueDecl *D, unsigned Level,

View File

@ -730,10 +730,10 @@ public:
#define ABSTRACT_STMT(Stmt)
#include "clang/AST/StmtNodes.inc"
#define OPENMP_CLAUSE(Name, Class) \
#define OMP_CLAUSE_CLASS(Enum, Str, Class) \
LLVM_ATTRIBUTE_NOINLINE \
OMPClause *Transform ## Class(Class *S);
#include "clang/Basic/OpenMPKinds.def"
#include "llvm/Frontend/OpenMP/OMPKinds.def"
/// Build a new qualified type given its unqualified type and type location.
///
@ -3585,10 +3585,10 @@ OMPClause *TreeTransform<Derived>::TransformOMPClause(OMPClause *S) {
switch (S->getClauseKind()) {
default: break;
// Transform individual clause nodes
#define OPENMP_CLAUSE(Name, Class) \
case OMPC_ ## Name : \
#define OMP_CLAUSE_CLASS(Enum, Str, Class) \
case Enum: \
return getDerived().Transform ## Class(cast<Class>(S));
#include "clang/Basic/OpenMPKinds.def"
#include "llvm/Frontend/OpenMP/OMPKinds.def"
}
return S;

View File

@ -11613,8 +11613,8 @@ public:
OMPClauseReader(ASTRecordReader &Record)
: Record(Record), Context(Record.getContext()) {}
#define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *C);
#include "clang/Basic/OpenMPKinds.def"
#define OMP_CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *C);
#include "llvm/Frontend/OpenMP/OMPKinds.def"
OMPClause *readClause();
void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C);
void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C);
@ -11628,149 +11628,149 @@ OMPClause *ASTRecordReader::readOMPClause() {
OMPClause *OMPClauseReader::readClause() {
OMPClause *C = nullptr;
switch (Record.readInt()) {
case OMPC_if:
switch (llvm::omp::Clause(Record.readInt())) {
case llvm::omp::OMPC_if:
C = new (Context) OMPIfClause();
break;
case OMPC_final:
case llvm::omp::OMPC_final:
C = new (Context) OMPFinalClause();
break;
case OMPC_num_threads:
case llvm::omp::OMPC_num_threads:
C = new (Context) OMPNumThreadsClause();
break;
case OMPC_safelen:
case llvm::omp::OMPC_safelen:
C = new (Context) OMPSafelenClause();
break;
case OMPC_simdlen:
case llvm::omp::OMPC_simdlen:
C = new (Context) OMPSimdlenClause();
break;
case OMPC_allocator:
case llvm::omp::OMPC_allocator:
C = new (Context) OMPAllocatorClause();
break;
case OMPC_collapse:
case llvm::omp::OMPC_collapse:
C = new (Context) OMPCollapseClause();
break;
case OMPC_default:
case llvm::omp::OMPC_default:
C = new (Context) OMPDefaultClause();
break;
case OMPC_proc_bind:
case llvm::omp::OMPC_proc_bind:
C = new (Context) OMPProcBindClause();
break;
case OMPC_schedule:
case llvm::omp::OMPC_schedule:
C = new (Context) OMPScheduleClause();
break;
case OMPC_ordered:
case llvm::omp::OMPC_ordered:
C = OMPOrderedClause::CreateEmpty(Context, Record.readInt());
break;
case OMPC_nowait:
case llvm::omp::OMPC_nowait:
C = new (Context) OMPNowaitClause();
break;
case OMPC_untied:
case llvm::omp::OMPC_untied:
C = new (Context) OMPUntiedClause();
break;
case OMPC_mergeable:
case llvm::omp::OMPC_mergeable:
C = new (Context) OMPMergeableClause();
break;
case OMPC_read:
case llvm::omp::OMPC_read:
C = new (Context) OMPReadClause();
break;
case OMPC_write:
case llvm::omp::OMPC_write:
C = new (Context) OMPWriteClause();
break;
case OMPC_update:
case llvm::omp::OMPC_update:
C = OMPUpdateClause::CreateEmpty(Context, Record.readInt());
break;
case OMPC_capture:
case llvm::omp::OMPC_capture:
C = new (Context) OMPCaptureClause();
break;
case OMPC_seq_cst:
case llvm::omp::OMPC_seq_cst:
C = new (Context) OMPSeqCstClause();
break;
case OMPC_acq_rel:
case llvm::omp::OMPC_acq_rel:
C = new (Context) OMPAcqRelClause();
break;
case OMPC_acquire:
case llvm::omp::OMPC_acquire:
C = new (Context) OMPAcquireClause();
break;
case OMPC_release:
case llvm::omp::OMPC_release:
C = new (Context) OMPReleaseClause();
break;
case OMPC_relaxed:
case llvm::omp::OMPC_relaxed:
C = new (Context) OMPRelaxedClause();
break;
case OMPC_threads:
case llvm::omp::OMPC_threads:
C = new (Context) OMPThreadsClause();
break;
case OMPC_simd:
case llvm::omp::OMPC_simd:
C = new (Context) OMPSIMDClause();
break;
case OMPC_nogroup:
case llvm::omp::OMPC_nogroup:
C = new (Context) OMPNogroupClause();
break;
case OMPC_unified_address:
case llvm::omp::OMPC_unified_address:
C = new (Context) OMPUnifiedAddressClause();
break;
case OMPC_unified_shared_memory:
case llvm::omp::OMPC_unified_shared_memory:
C = new (Context) OMPUnifiedSharedMemoryClause();
break;
case OMPC_reverse_offload:
case llvm::omp::OMPC_reverse_offload:
C = new (Context) OMPReverseOffloadClause();
break;
case OMPC_dynamic_allocators:
case llvm::omp::OMPC_dynamic_allocators:
C = new (Context) OMPDynamicAllocatorsClause();
break;
case OMPC_atomic_default_mem_order:
case llvm::omp::OMPC_atomic_default_mem_order:
C = new (Context) OMPAtomicDefaultMemOrderClause();
break;
case OMPC_private:
case llvm::omp::OMPC_private:
C = OMPPrivateClause::CreateEmpty(Context, Record.readInt());
break;
case OMPC_firstprivate:
case llvm::omp::OMPC_firstprivate:
C = OMPFirstprivateClause::CreateEmpty(Context, Record.readInt());
break;
case OMPC_lastprivate:
case llvm::omp::OMPC_lastprivate:
C = OMPLastprivateClause::CreateEmpty(Context, Record.readInt());
break;
case OMPC_shared:
case llvm::omp::OMPC_shared:
C = OMPSharedClause::CreateEmpty(Context, Record.readInt());
break;
case OMPC_reduction:
case llvm::omp::OMPC_reduction:
C = OMPReductionClause::CreateEmpty(Context, Record.readInt());
break;
case OMPC_task_reduction:
case llvm::omp::OMPC_task_reduction:
C = OMPTaskReductionClause::CreateEmpty(Context, Record.readInt());
break;
case OMPC_in_reduction:
case llvm::omp::OMPC_in_reduction:
C = OMPInReductionClause::CreateEmpty(Context, Record.readInt());
break;
case OMPC_linear:
case llvm::omp::OMPC_linear:
C = OMPLinearClause::CreateEmpty(Context, Record.readInt());
break;
case OMPC_aligned:
case llvm::omp::OMPC_aligned:
C = OMPAlignedClause::CreateEmpty(Context, Record.readInt());
break;
case OMPC_copyin:
case llvm::omp::OMPC_copyin:
C = OMPCopyinClause::CreateEmpty(Context, Record.readInt());
break;
case OMPC_copyprivate:
case llvm::omp::OMPC_copyprivate:
C = OMPCopyprivateClause::CreateEmpty(Context, Record.readInt());
break;
case OMPC_flush:
case llvm::omp::OMPC_flush:
C = OMPFlushClause::CreateEmpty(Context, Record.readInt());
break;
case OMPC_depobj:
case llvm::omp::OMPC_depobj:
C = OMPDepobjClause::CreateEmpty(Context);
break;
case OMPC_depend: {
case llvm::omp::OMPC_depend: {
unsigned NumVars = Record.readInt();
unsigned NumLoops = Record.readInt();
C = OMPDependClause::CreateEmpty(Context, NumVars, NumLoops);
break;
}
case OMPC_device:
case llvm::omp::OMPC_device:
C = new (Context) OMPDeviceClause();
break;
case OMPC_map: {
case llvm::omp::OMPC_map: {
OMPMappableExprListSizeTy Sizes;
Sizes.NumVars = Record.readInt();
Sizes.NumUniqueDeclarations = Record.readInt();
@ -11779,31 +11779,31 @@ OMPClause *OMPClauseReader::readClause() {
C = OMPMapClause::CreateEmpty(Context, Sizes);
break;
}
case OMPC_num_teams:
case llvm::omp::OMPC_num_teams:
C = new (Context) OMPNumTeamsClause();
break;
case OMPC_thread_limit:
case llvm::omp::OMPC_thread_limit:
C = new (Context) OMPThreadLimitClause();
break;
case OMPC_priority:
case llvm::omp::OMPC_priority:
C = new (Context) OMPPriorityClause();
break;
case OMPC_grainsize:
case llvm::omp::OMPC_grainsize:
C = new (Context) OMPGrainsizeClause();
break;
case OMPC_num_tasks:
case llvm::omp::OMPC_num_tasks:
C = new (Context) OMPNumTasksClause();
break;
case OMPC_hint:
case llvm::omp::OMPC_hint:
C = new (Context) OMPHintClause();
break;
case OMPC_dist_schedule:
case llvm::omp::OMPC_dist_schedule:
C = new (Context) OMPDistScheduleClause();
break;
case OMPC_defaultmap:
case llvm::omp::OMPC_defaultmap:
C = new (Context) OMPDefaultmapClause();
break;
case OMPC_to: {
case llvm::omp::OMPC_to: {
OMPMappableExprListSizeTy Sizes;
Sizes.NumVars = Record.readInt();
Sizes.NumUniqueDeclarations = Record.readInt();
@ -11812,7 +11812,7 @@ OMPClause *OMPClauseReader::readClause() {
C = OMPToClause::CreateEmpty(Context, Sizes);
break;
}
case OMPC_from: {
case llvm::omp::OMPC_from: {
OMPMappableExprListSizeTy Sizes;
Sizes.NumVars = Record.readInt();
Sizes.NumUniqueDeclarations = Record.readInt();
@ -11821,7 +11821,7 @@ OMPClause *OMPClauseReader::readClause() {
C = OMPFromClause::CreateEmpty(Context, Sizes);
break;
}
case OMPC_use_device_ptr: {
case llvm::omp::OMPC_use_device_ptr: {
OMPMappableExprListSizeTy Sizes;
Sizes.NumVars = Record.readInt();
Sizes.NumUniqueDeclarations = Record.readInt();
@ -11830,7 +11830,7 @@ OMPClause *OMPClauseReader::readClause() {
C = OMPUseDevicePtrClause::CreateEmpty(Context, Sizes);
break;
}
case OMPC_is_device_ptr: {
case llvm::omp::OMPC_is_device_ptr: {
OMPMappableExprListSizeTy Sizes;
Sizes.NumVars = Record.readInt();
Sizes.NumUniqueDeclarations = Record.readInt();
@ -11839,27 +11839,31 @@ OMPClause *OMPClauseReader::readClause() {
C = OMPIsDevicePtrClause::CreateEmpty(Context, Sizes);
break;
}
case OMPC_allocate:
case llvm::omp::OMPC_allocate:
C = OMPAllocateClause::CreateEmpty(Context, Record.readInt());
break;
case OMPC_nontemporal:
case llvm::omp::OMPC_nontemporal:
C = OMPNontemporalClause::CreateEmpty(Context, Record.readInt());
break;
case OMPC_inclusive:
case llvm::omp::OMPC_inclusive:
C = OMPInclusiveClause::CreateEmpty(Context, Record.readInt());
break;
case OMPC_exclusive:
case llvm::omp::OMPC_exclusive:
C = OMPExclusiveClause::CreateEmpty(Context, Record.readInt());
break;
case OMPC_order:
case llvm::omp::OMPC_order:
C = new (Context) OMPOrderClause();
break;
case OMPC_destroy:
case llvm::omp::OMPC_destroy:
C = new (Context) OMPDestroyClause();
break;
case OMPC_detach:
case llvm::omp::OMPC_detach:
C = new (Context) OMPDetachClause();
break;
#define OMP_CLAUSE_NO_CLASS(Enum, Str) \
case llvm::omp::Enum: \
break;
#include "llvm/Frontend/OpenMP/OMPKinds.def"
}
assert(C && "Unknown OMPClause type");

View File

@ -6037,8 +6037,8 @@ class OMPClauseWriter : public OMPClauseVisitor<OMPClauseWriter> {
public:
OMPClauseWriter(ASTRecordWriter &Record) : Record(Record) {}
#define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *S);
#include "clang/Basic/OpenMPKinds.def"
#define OMP_CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);
#include "llvm/Frontend/OpenMP/OMPKinds.def"
void writeClause(OMPClause *C);
void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C);
void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C);
@ -6051,7 +6051,7 @@ void ASTRecordWriter::writeOMPClause(OMPClause *C) {
}
void OMPClauseWriter::writeClause(OMPClause *C) {
Record.push_back(C->getClauseKind());
Record.push_back(unsigned(C->getClauseKind()));
Visit(C);
Record.AddSourceLocation(C->getBeginLoc());
Record.AddSourceLocation(C->getEndLoc());

View File

@ -1,4 +1,5 @@
set(LLVM_LINK_COMPONENTS
FrontendOpenMP
Support
)

View File

@ -1,4 +1,7 @@
set(LLVM_LINK_COMPONENTS support)
set(LLVM_LINK_COMPONENTS
FrontendOpenMP
Support
)
add_clang_library(clangStaticAnalyzerCore
APSIntType.cpp

View File

@ -2153,8 +2153,8 @@ class OMPClauseEnqueue : public ConstOMPClauseVisitor<OMPClauseEnqueue> {
public:
OMPClauseEnqueue(EnqueueVisitor *Visitor) : Visitor(Visitor) {}
#define OPENMP_CLAUSE(Name, Class) void Visit##Class(const Class *C);
#include "clang/Basic/OpenMPKinds.def"
#define OMP_CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(const Class *C);
#include "llvm/Frontend/OpenMP/OMPKinds.def"
void VisitOMPClauseWithPreInit(const OMPClauseWithPreInit *C);
void VisitOMPClauseWithPostUpdate(const OMPClauseWithPostUpdate *C);
};

View File

@ -2612,7 +2612,7 @@ TEST(HasExternalFormalLinkage, Basic) {
}
TEST(HasDefaultArgument, Basic) {
EXPECT_TRUE(matches("void x(int val = 0) {}",
EXPECT_TRUE(matches("void x(int val = 0) {}",
parmVarDecl(hasDefaultArgument())));
EXPECT_TRUE(notMatches("void x(int val) {}",
parmVarDecl(hasDefaultArgument())));
@ -2665,7 +2665,7 @@ TEST(HasTrailingReturn, MatchesTrailingReturn) {
EXPECT_TRUE(matches("auto Y() -> int { return 0; }",
functionDecl(hasTrailingReturn())));
EXPECT_TRUE(matches("auto X() -> int;", functionDecl(hasTrailingReturn())));
EXPECT_TRUE(notMatches("int X() { return 0; }",
EXPECT_TRUE(notMatches("int X() { return 0; }",
functionDecl(hasTrailingReturn())));
EXPECT_TRUE(notMatches("int X();", functionDecl(hasTrailingReturn())));
EXPECT_TRUE(notMatchesC("void X();", functionDecl(hasTrailingReturn())));
@ -2891,8 +2891,8 @@ void x(int x) {
}
TEST(OMPExecutableDirective, isAllowedToContainClauseKind) {
auto Matcher =
ompExecutableDirective(isAllowedToContainClauseKind(OMPC_default));
auto Matcher = ompExecutableDirective(
isAllowedToContainClauseKind(llvm::omp::OMPC_default));
const std::string Source0 = R"(
void x() {

View File

@ -34,11 +34,18 @@ enum class Directive {
#include "llvm/Frontend/OpenMP/OMPKinds.def"
};
/// IDs for all OpenMP clauses.
enum class Clause {
#define OMP_CLAUSE(Enum, ...) Enum,
#include "llvm/Frontend/OpenMP/OMPKinds.def"
};
/// Make the enum values available in the llvm::omp namespace. This allows us to
/// write something like OMPD_parallel if we have a `using namespace omp`. At
/// the same time we do not loose the strong type guarantees of the enum class,
/// that is we cannot pass an unsigned as Directive without an explicit cast.
#define OMP_DIRECTIVE(Enum, ...) constexpr auto Enum = omp::Directive::Enum;
#define OMP_CLAUSE(Enum, ...) constexpr auto Enum = omp::Clause::Enum;
#include "llvm/Frontend/OpenMP/OMPKinds.def"
/// IDs for all omp runtime library (RTL) functions.
@ -87,6 +94,12 @@ Directive getOpenMPDirectiveKind(StringRef Str);
/// Return a textual representation of the directive \p D.
StringRef getOpenMPDirectiveName(Directive D);
/// Parse \p Str and return the clause it matches or OMPC_unknown if none.
Clause getOpenMPClauseKind(StringRef Str);
/// Return a textual representation of the clause \p C.
StringRef getOpenMPClauseName(Clause C);
/// Forward declarations for LLVM-IR types (simple, function and structure) are
/// generated below. Their names are defined and used in OpenMP/OMPKinds.def.
/// Here we provide the forward declarations, the initializeTypes function will

View File

@ -105,6 +105,117 @@ __OMP_DIRECTIVE(unknown)
///}
/// OpenMP Clauses
///
///{
#ifndef OMP_CLAUSE
#define OMP_CLAUSE(Enum, Str, Implicit)
#endif
#ifndef OMP_CLAUSE_CLASS
#define OMP_CLAUSE_CLASS(Enum, Str, Class)
#endif
#ifndef OMP_CLAUSE_NO_CLASS
#define OMP_CLAUSE_NO_CLASS(Enum, Str)
#endif
#define __OMP_CLAUSE(Name, Class) \
OMP_CLAUSE(OMPC_##Name, #Name, /* Implicit */ false) \
OMP_CLAUSE_CLASS(OMPC_##Name, #Name, Class)
#define __OMP_CLAUSE_NO_CLASS(Name) \
OMP_CLAUSE(OMPC_##Name, #Name, /* Implicit */ false) \
OMP_CLAUSE_NO_CLASS(OMPC_##Name, #Name)
#define __OMP_IMPLICIT_CLAUSE_CLASS(Name, Str, Class) \
OMP_CLAUSE(OMPC_##Name, Str, /* Implicit */ true) \
OMP_CLAUSE_CLASS(OMPC_##Name, Str, Class)
#define __OMP_IMPLICIT_CLAUSE_NO_CLASS(Name, Str) \
OMP_CLAUSE(OMPC_##Name, Str, /* Implicit */ true) \
OMP_CLAUSE_NO_CLASS(OMPC_##Name, Str)
__OMP_CLAUSE(allocator, OMPAllocatorClause)
__OMP_CLAUSE(if, OMPIfClause)
__OMP_CLAUSE(final, OMPFinalClause)
__OMP_CLAUSE(num_threads, OMPNumThreadsClause)
__OMP_CLAUSE(safelen, OMPSafelenClause)
__OMP_CLAUSE(simdlen, OMPSimdlenClause)
__OMP_CLAUSE(collapse, OMPCollapseClause)
__OMP_CLAUSE(default, OMPDefaultClause)
__OMP_CLAUSE(private, OMPPrivateClause)
__OMP_CLAUSE(firstprivate, OMPFirstprivateClause)
__OMP_CLAUSE(lastprivate, OMPLastprivateClause)
__OMP_CLAUSE(shared, OMPSharedClause)
__OMP_CLAUSE(reduction, OMPReductionClause)
__OMP_CLAUSE(linear, OMPLinearClause)
__OMP_CLAUSE(aligned, OMPAlignedClause)
__OMP_CLAUSE(copyin, OMPCopyinClause)
__OMP_CLAUSE(copyprivate, OMPCopyprivateClause)
__OMP_CLAUSE(proc_bind, OMPProcBindClause)
__OMP_CLAUSE(schedule, OMPScheduleClause)
__OMP_CLAUSE(ordered, OMPOrderedClause)
__OMP_CLAUSE(nowait, OMPNowaitClause)
__OMP_CLAUSE(untied, OMPUntiedClause)
__OMP_CLAUSE(mergeable, OMPMergeableClause)
__OMP_CLAUSE(read, OMPReadClause)
__OMP_CLAUSE(write, OMPWriteClause)
__OMP_CLAUSE(update, OMPUpdateClause)
__OMP_CLAUSE(capture, OMPCaptureClause)
__OMP_CLAUSE(seq_cst, OMPSeqCstClause)
__OMP_CLAUSE(acq_rel, OMPAcqRelClause)
__OMP_CLAUSE(acquire, OMPAcquireClause)
__OMP_CLAUSE(release, OMPReleaseClause)
__OMP_CLAUSE(relaxed, OMPRelaxedClause)
__OMP_CLAUSE(depend, OMPDependClause)
__OMP_CLAUSE(device, OMPDeviceClause)
__OMP_CLAUSE(threads, OMPThreadsClause)
__OMP_CLAUSE(simd, OMPSIMDClause)
__OMP_CLAUSE(map, OMPMapClause)
__OMP_CLAUSE(num_teams, OMPNumTeamsClause)
__OMP_CLAUSE(thread_limit, OMPThreadLimitClause)
__OMP_CLAUSE(priority, OMPPriorityClause)
__OMP_CLAUSE(grainsize, OMPGrainsizeClause)
__OMP_CLAUSE(nogroup, OMPNogroupClause)
__OMP_CLAUSE(num_tasks, OMPNumTasksClause)
__OMP_CLAUSE(hint, OMPHintClause)
__OMP_CLAUSE(dist_schedule, OMPDistScheduleClause)
__OMP_CLAUSE(defaultmap, OMPDefaultmapClause)
__OMP_CLAUSE(to, OMPToClause)
__OMP_CLAUSE(from, OMPFromClause)
__OMP_CLAUSE(use_device_ptr, OMPUseDevicePtrClause)
__OMP_CLAUSE(is_device_ptr, OMPIsDevicePtrClause)
__OMP_CLAUSE(task_reduction, OMPTaskReductionClause)
__OMP_CLAUSE(in_reduction, OMPInReductionClause)
__OMP_CLAUSE(unified_address, OMPUnifiedAddressClause)
__OMP_CLAUSE(unified_shared_memory, OMPUnifiedSharedMemoryClause)
__OMP_CLAUSE(reverse_offload, OMPReverseOffloadClause)
__OMP_CLAUSE(dynamic_allocators, OMPDynamicAllocatorsClause)
__OMP_CLAUSE(atomic_default_mem_order, OMPAtomicDefaultMemOrderClause)
__OMP_CLAUSE(allocate, OMPAllocateClause)
__OMP_CLAUSE(nontemporal, OMPNontemporalClause)
__OMP_CLAUSE(order, OMPOrderClause)
__OMP_CLAUSE(destroy, OMPDestroyClause)
__OMP_CLAUSE(detach, OMPDetachClause)
__OMP_CLAUSE(inclusive, OMPInclusiveClause)
__OMP_CLAUSE(exclusive, OMPExclusiveClause)
__OMP_CLAUSE_NO_CLASS(uniform)
__OMP_CLAUSE_NO_CLASS(device_type)
__OMP_CLAUSE_NO_CLASS(match)
__OMP_IMPLICIT_CLAUSE_CLASS(depobj, "depobj", OMPDepobjClause)
__OMP_IMPLICIT_CLAUSE_CLASS(flush, "flush", OMPFlushClause)
__OMP_IMPLICIT_CLAUSE_NO_CLASS(threadprivate, "threadprivate or thread local")
__OMP_IMPLICIT_CLAUSE_NO_CLASS(unknown, "unknown")
#undef __OMP_IMPLICIT_CLAUSE_NO_CLASS
#undef __OMP_IMPLICIT_CLAUSE_CLASS
#undef __OMP_CLAUSE
#undef OMP_CLAUSE_NO_CLASS
#undef OMP_CLAUSE_CLASS
#undef OMP_CLAUSE
///}
/// Types used in runtime structs or runtime functions
///
///{
@ -232,8 +343,10 @@ __OMP_RTL(omp_set_max_active_levels, false, Void, Int32)
__OMP_RTL(__kmpc_master, false, Int32, IdentPtr, Int32)
__OMP_RTL(__kmpc_end_master, false, Void, IdentPtr, Int32)
__OMP_RTL(__kmpc_critical, false, Void, IdentPtr, Int32, KmpCriticalNamePtrTy)
__OMP_RTL(__kmpc_critical_with_hint, false, Void, IdentPtr, Int32, KmpCriticalNamePtrTy, Int32)
__OMP_RTL(__kmpc_end_critical, false, Void, IdentPtr, Int32, KmpCriticalNamePtrTy)
__OMP_RTL(__kmpc_critical_with_hint, false, Void, IdentPtr, Int32,
KmpCriticalNamePtrTy, Int32)
__OMP_RTL(__kmpc_end_critical, false, Void, IdentPtr, Int32,
KmpCriticalNamePtrTy)
__OMP_RTL(__last, false, Void, )

View File

@ -36,6 +36,24 @@ StringRef llvm::omp::getOpenMPDirectiveName(Directive Kind) {
llvm_unreachable("Invalid OpenMP directive kind");
}
Clause llvm::omp::getOpenMPClauseKind(StringRef Str) {
return llvm::StringSwitch<Clause>(Str)
#define OMP_CLAUSE(Enum, Str, Implicit) \
.Case(Str, Implicit ? OMPC_unknown : Enum)
#include "llvm/Frontend/OpenMP/OMPKinds.def"
.Default(OMPC_unknown);
}
StringRef llvm::omp::getOpenMPClauseName(Clause C) {
switch (C) {
#define OMP_CLAUSE(Enum, Str, ...) \
case Enum: \
return Str;
#include "llvm/Frontend/OpenMP/OMPKinds.def"
}
llvm_unreachable("Invalid OpenMP clause kind");
}
/// Declarations for LLVM-IR types (simple, array, function and structure) are
/// generated below. Their names are defined and used in OpenMPKinds.def. Here
/// we provide the declarations, the initializeTypes function will provide the