Skip to content

Commit 41cdd0b

Browse files
committed
merge main into amd-staging
2 parents a8b8146 + 0e2b890 commit 41cdd0b

File tree

114 files changed

+4492
-2780
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+4492
-2780
lines changed

clang/docs/OpenMPSupport.rst

Lines changed: 662 additions & 662 deletions
Large diffs are not rendered by default.

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,7 @@ OpenMP Support
915915
modifier in the ``adjust_args`` clause.
916916
- Allow array length to be omitted in array section subscript expression.
917917
- Fixed non-contiguous strided update in the ``omp target update`` directive with the ``from`` clause.
918+
- Added support for threadset clause in task and taskloop directives.
918919
- Properly handle array section/assumed-size array privatization in C/C++.
919920
- Added support to handle new syntax of the ``uses_allocators`` clause.
920921
- Added support for ``variable-category`` modifier in ``default clause``.

clang/include/clang/AST/OpenMPClause.h

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,6 +1424,86 @@ class OMPDefaultClause : public OMPClause {
14241424
}
14251425
};
14261426

1427+
/// This represents 'threadset' clause in the '#pragma omp task ...' directive.
1428+
///
1429+
/// \code
1430+
/// #pragma omp task threadset(omp_pool)
1431+
/// \endcode
1432+
/// In this example directive '#pragma omp task' has simple 'threadset'
1433+
/// clause with kind 'omp_pool'.
1434+
class OMPThreadsetClause final : public OMPClause {
1435+
friend class OMPClauseReader;
1436+
1437+
/// Location of '('.
1438+
SourceLocation LParenLoc;
1439+
1440+
/// A kind of the 'threadset' clause.
1441+
OpenMPThreadsetKind Kind = OMPC_THREADSET_unknown;
1442+
1443+
/// Start location of the kind in source code.
1444+
SourceLocation KindLoc;
1445+
1446+
/// Set kind of the clauses.
1447+
///
1448+
/// \param K Argument of clause.
1449+
void setThreadsetKind(OpenMPThreadsetKind K) { Kind = K; }
1450+
1451+
/// Set argument location.
1452+
///
1453+
/// \param KLoc Argument location.
1454+
void setThreadsetKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
1455+
1456+
public:
1457+
/// Build 'threadset' clause with argument \a A ('omp_team' or 'omp_pool').
1458+
///
1459+
/// \param A Argument of the clause ('omp_team' or 'omp_pool').
1460+
/// \param ALoc Starting location of the argument.
1461+
/// \param StartLoc Starting location of the clause.
1462+
/// \param LParenLoc Location of '('.
1463+
/// \param EndLoc Ending location of the clause.
1464+
OMPThreadsetClause(OpenMPThreadsetKind A, SourceLocation ALoc,
1465+
SourceLocation StartLoc, SourceLocation LParenLoc,
1466+
SourceLocation EndLoc)
1467+
: OMPClause(llvm::omp::OMPC_threadset, StartLoc, EndLoc),
1468+
LParenLoc(LParenLoc), Kind(A), KindLoc(ALoc) {}
1469+
1470+
/// Build an empty clause.
1471+
OMPThreadsetClause()
1472+
: OMPClause(llvm::omp::OMPC_threadset, SourceLocation(),
1473+
SourceLocation()) {}
1474+
1475+
/// Sets the location of '('.
1476+
void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
1477+
1478+
/// Returns the location of '('.
1479+
SourceLocation getLParenLoc() const { return LParenLoc; }
1480+
1481+
/// Returns kind of the clause.
1482+
OpenMPThreadsetKind getThreadsetKind() const { return Kind; }
1483+
1484+
/// Returns location of clause kind.
1485+
SourceLocation getThreadsetKindLoc() const { return KindLoc; }
1486+
1487+
child_range children() {
1488+
return child_range(child_iterator(), child_iterator());
1489+
}
1490+
1491+
const_child_range children() const {
1492+
return const_child_range(const_child_iterator(), const_child_iterator());
1493+
}
1494+
1495+
child_range used_children() {
1496+
return child_range(child_iterator(), child_iterator());
1497+
}
1498+
const_child_range used_children() const {
1499+
return const_child_range(const_child_iterator(), const_child_iterator());
1500+
}
1501+
1502+
static bool classof(const OMPClause *T) {
1503+
return T->getClauseKind() == llvm::omp::OMPC_threadset;
1504+
}
1505+
};
1506+
14271507
/// This represents 'proc_bind' clause in the '#pragma omp ...'
14281508
/// directive.
14291509
///

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3523,6 +3523,12 @@ bool RecursiveASTVisitor<Derived>::VisitOMPDefaultClause(OMPDefaultClause *) {
35233523
return true;
35243524
}
35253525

3526+
template <typename Derived>
3527+
bool RecursiveASTVisitor<Derived>::VisitOMPThreadsetClause(
3528+
OMPThreadsetClause *) {
3529+
return true;
3530+
}
3531+
35263532
template <typename Derived>
35273533
bool RecursiveASTVisitor<Derived>::VisitOMPProcBindClause(OMPProcBindClause *) {
35283534
return true;

clang/include/clang/Basic/OpenMPKinds.def

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@
9898
#ifndef OPENMP_ALLOCATE_MODIFIER
9999
#define OPENMP_ALLOCATE_MODIFIER(Name)
100100
#endif
101+
#ifndef OPENMP_THREADSET_KIND
102+
#define OPENMP_THREADSET_KIND(Name)
103+
#endif
101104

102105
// Static attributes for 'schedule' clause.
103106
OPENMP_SCHEDULE_KIND(static)
@@ -255,6 +258,9 @@ OPENMP_DOACROSS_MODIFIER(sink)
255258
OPENMP_DOACROSS_MODIFIER(sink_omp_cur_iteration)
256259
OPENMP_DOACROSS_MODIFIER(source_omp_cur_iteration)
257260

261+
OPENMP_THREADSET_KIND(omp_pool)
262+
OPENMP_THREADSET_KIND(omp_team)
263+
258264
#undef OPENMP_NUMTASKS_MODIFIER
259265
#undef OPENMP_NUMTHREADS_MODIFIER
260266
#undef OPENMP_GRAINSIZE_MODIFIER
@@ -284,4 +290,4 @@ OPENMP_DOACROSS_MODIFIER(source_omp_cur_iteration)
284290
#undef OPENMP_DEFAULTMAP_MODIFIER
285291
#undef OPENMP_DOACROSS_MODIFIER
286292
#undef OPENMP_ALLOCATE_MODIFIER
287-
293+
#undef OPENMP_THREADSET_KIND

clang/include/clang/Basic/OpenMPKinds.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,13 @@ enum OpenMPAllocateClauseModifier {
250250
OMPC_ALLOCATE_unknown
251251
};
252252

253+
/// OpenMP modifiers for 'threadset' clause.
254+
enum OpenMPThreadsetKind {
255+
#define OPENMP_THREADSET_KIND(Name) OMPC_THREADSET_##Name,
256+
#include "clang/Basic/OpenMPKinds.def"
257+
OMPC_THREADSET_unknown
258+
};
259+
253260
/// Number of allowed allocate-modifiers.
254261
static constexpr unsigned NumberOfOMPAllocateClauseModifiers =
255262
OMPC_ALLOCATE_unknown;

clang/include/clang/Sema/SemaOpenMP.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,12 @@ class SemaOpenMP : public SemaBase {
975975
OpenMPDefaultClauseVariableCategory VCKind,
976976
SourceLocation VCKindLoc, SourceLocation StartLoc,
977977
SourceLocation LParenLoc, SourceLocation EndLoc);
978+
/// Called on well-formed 'threadset' clause.
979+
OMPClause *ActOnOpenMPThreadsetClause(OpenMPThreadsetKind Kind,
980+
SourceLocation KindLoc,
981+
SourceLocation StartLoc,
982+
SourceLocation LParenLoc,
983+
SourceLocation EndLoc);
978984
/// Called on well-formed 'proc_bind' clause.
979985
OMPClause *ActOnOpenMPProcBindClause(llvm::omp::ProcBindKind Kind,
980986
SourceLocation KindLoc,

clang/lib/AST/OpenMPClause.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) {
124124
case OMPC_nowait:
125125
case OMPC_untied:
126126
case OMPC_mergeable:
127+
case OMPC_threadset:
127128
case OMPC_threadprivate:
128129
case OMPC_groupprivate:
129130
case OMPC_flush:
@@ -2035,6 +2036,13 @@ void OMPClausePrinter::VisitOMPDefaultClause(OMPDefaultClause *Node) {
20352036
OS << ")";
20362037
}
20372038

2039+
void OMPClausePrinter::VisitOMPThreadsetClause(OMPThreadsetClause *Node) {
2040+
OS << "threadset("
2041+
<< getOpenMPSimpleClauseTypeName(OMPC_threadset,
2042+
unsigned(Node->getThreadsetKind()))
2043+
<< ")";
2044+
}
2045+
20382046
void OMPClausePrinter::VisitOMPProcBindClause(OMPProcBindClause *Node) {
20392047
OS << "proc_bind("
20402048
<< getOpenMPSimpleClauseTypeName(OMPC_proc_bind,

clang/lib/AST/StmtProfile.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,8 @@ void OMPClauseProfiler::VisitOMPNocontextClause(const OMPNocontextClause *C) {
546546

547547
void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { }
548548

549+
void OMPClauseProfiler::VisitOMPThreadsetClause(const OMPThreadsetClause *C) {}
550+
549551
void OMPClauseProfiler::VisitOMPProcBindClause(const OMPProcBindClause *C) { }
550552

551553
void OMPClauseProfiler::VisitOMPUnifiedAddressClause(

clang/lib/Basic/OpenMPKinds.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,15 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind, StringRef Str,
210210
#define OPENMP_ALLOCATE_MODIFIER(Name) .Case(#Name, OMPC_ALLOCATE_##Name)
211211
#include "clang/Basic/OpenMPKinds.def"
212212
.Default(OMPC_ALLOCATE_unknown);
213+
case OMPC_threadset: {
214+
unsigned Type = llvm::StringSwitch<unsigned>(Str)
215+
#define OPENMP_THREADSET_KIND(Name) .Case(#Name, OMPC_THREADSET_##Name)
216+
#include "clang/Basic/OpenMPKinds.def"
217+
.Default(OMPC_THREADSET_unknown);
218+
if (LangOpts.OpenMP < 60)
219+
return OMPC_THREADSET_unknown;
220+
return Type;
221+
}
213222
case OMPC_num_threads: {
214223
unsigned Type = llvm::StringSwitch<unsigned>(Str)
215224
#define OPENMP_NUMTHREADS_MODIFIER(Name) .Case(#Name, OMPC_NUMTHREADS_##Name)
@@ -565,6 +574,16 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
565574
#include "clang/Basic/OpenMPKinds.def"
566575
}
567576
llvm_unreachable("Invalid OpenMP 'num_threads' clause modifier");
577+
case OMPC_threadset:
578+
switch (Type) {
579+
case OMPC_THREADSET_unknown:
580+
return "unknown";
581+
#define OPENMP_THREADSET_KIND(Name) \
582+
case OMPC_THREADSET_##Name: \
583+
return #Name;
584+
#include "clang/Basic/OpenMPKinds.def"
585+
}
586+
llvm_unreachable("Invalid OpenMP 'threadset' clause modifier");
568587
case OMPC_unknown:
569588
case OMPC_threadprivate:
570589
case OMPC_groupprivate:

0 commit comments

Comments
 (0)