Skip to content

Commit 5709b9b

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:6318dd82732c into amd-gfx:2b566312d5d1
Local branch amd-gfx 2b56631 Revert "[NewPM] Remove CFGPrinterLegacyPass (llvm#73414)" Remote branch main 6318dd8 [mlir] Fix a warning
2 parents 2b56631 + 6318dd8 commit 5709b9b

File tree

230 files changed

+2517
-681
lines changed

Some content is hidden

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

230 files changed

+2517
-681
lines changed

clang/include/clang/AST/OpenMPClause.h

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2513,6 +2513,89 @@ class OMPRelaxedClause final : public OMPClause {
25132513
}
25142514
};
25152515

2516+
/// This represents 'fail' clause in the '#pragma omp atomic'
2517+
/// directive.
2518+
///
2519+
/// \code
2520+
/// #pragma omp atomic compare fail
2521+
/// \endcode
2522+
/// In this example directive '#pragma omp atomic compare' has 'fail' clause.
2523+
class OMPFailClause final : public OMPClause {
2524+
2525+
// FailParameter is a memory-order-clause. Storing the ClauseKind is
2526+
// sufficient for our purpose.
2527+
OpenMPClauseKind FailParameter = llvm::omp::Clause::OMPC_unknown;
2528+
SourceLocation FailParameterLoc;
2529+
SourceLocation LParenLoc;
2530+
2531+
friend class OMPClauseReader;
2532+
2533+
/// Sets the location of '(' in fail clause.
2534+
void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
2535+
2536+
/// Sets the location of memoryOrder clause argument in fail clause.
2537+
void setFailParameterLoc(SourceLocation Loc) { FailParameterLoc = Loc; }
2538+
2539+
/// Sets the mem_order clause for 'atomic compare fail' directive.
2540+
void setFailParameter(OpenMPClauseKind FailParameter) {
2541+
this->FailParameter = FailParameter;
2542+
assert(checkFailClauseParameter(FailParameter) &&
2543+
"Invalid fail clause parameter");
2544+
}
2545+
2546+
public:
2547+
/// Build 'fail' clause.
2548+
///
2549+
/// \param StartLoc Starting location of the clause.
2550+
/// \param EndLoc Ending location of the clause.
2551+
OMPFailClause(SourceLocation StartLoc, SourceLocation EndLoc)
2552+
: OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc) {}
2553+
2554+
OMPFailClause(OpenMPClauseKind FailParameter, SourceLocation FailParameterLoc,
2555+
SourceLocation StartLoc, SourceLocation LParenLoc,
2556+
SourceLocation EndLoc)
2557+
: OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc),
2558+
FailParameterLoc(FailParameterLoc), LParenLoc(LParenLoc) {
2559+
2560+
setFailParameter(FailParameter);
2561+
}
2562+
2563+
/// Build an empty clause.
2564+
OMPFailClause()
2565+
: OMPClause(llvm::omp::OMPC_fail, SourceLocation(), SourceLocation()) {}
2566+
2567+
child_range children() {
2568+
return child_range(child_iterator(), child_iterator());
2569+
}
2570+
2571+
const_child_range children() const {
2572+
return const_child_range(const_child_iterator(), const_child_iterator());
2573+
}
2574+
2575+
child_range used_children() {
2576+
return child_range(child_iterator(), child_iterator());
2577+
}
2578+
const_child_range used_children() const {
2579+
return const_child_range(const_child_iterator(), const_child_iterator());
2580+
}
2581+
2582+
static bool classof(const OMPClause *T) {
2583+
return T->getClauseKind() == llvm::omp::OMPC_fail;
2584+
}
2585+
2586+
/// Gets the location of '(' (for the parameter) in fail clause.
2587+
SourceLocation getLParenLoc() const {
2588+
return LParenLoc;
2589+
}
2590+
2591+
/// Gets the location of Fail Parameter (type memory-order-clause) in
2592+
/// fail clause.
2593+
SourceLocation getFailParameterLoc() const { return FailParameterLoc; }
2594+
2595+
/// Gets the parameter (type memory-order-clause) in Fail clause.
2596+
OpenMPClauseKind getFailParameter() const { return FailParameter; }
2597+
};
2598+
25162599
/// This represents clause 'private' in the '#pragma omp ...' directives.
25172600
///
25182601
/// \code

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3398,6 +3398,11 @@ bool RecursiveASTVisitor<Derived>::VisitOMPCompareClause(OMPCompareClause *) {
33983398
return true;
33993399
}
34003400

3401+
template <typename Derived>
3402+
bool RecursiveASTVisitor<Derived>::VisitOMPFailClause(OMPFailClause *) {
3403+
return true;
3404+
}
3405+
34013406
template <typename Derived>
34023407
bool RecursiveASTVisitor<Derived>::VisitOMPSeqCstClause(OMPSeqCstClause *) {
34033408
return true;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10971,6 +10971,8 @@ def note_omp_atomic_compare: Note<
1097110971
"expect binary operator in conditional expression|expect '<', '>' or '==' as order operator|expect comparison in a form of 'x == e', 'e == x', 'x ordop expr', or 'expr ordop x'|"
1097210972
"expect lvalue for result value|expect scalar value|expect integer value|unexpected 'else' statement|expect '==' operator|expect an assignment statement 'v = x'|"
1097310973
"expect a 'if' statement|expect no more than two statements|expect a compound statement|expect 'else' statement|expect a form 'r = x == e; if (r) ...'}0">;
10974+
def err_omp_atomic_fail_wrong_or_no_clauses : Error<"expected a memory order clause">;
10975+
def err_omp_atomic_fail_no_compare : Error<"expected 'compare' clause with the 'fail' modifier">;
1097410976
def err_omp_atomic_several_clauses : Error<
1097510977
"directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause">;
1097610978
def err_omp_several_mem_order_clauses : Error<

clang/include/clang/Basic/OpenMPKinds.def

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
#ifndef OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND
4242
#define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name)
4343
#endif
44+
#ifndef OPENMP_ATOMIC_FAIL_MODIFIER
45+
#define OPENMP_ATOMIC_FAIL_MODIFIER(Name)
46+
#endif
4447
#ifndef OPENMP_AT_KIND
4548
#define OPENMP_AT_KIND(Name)
4649
#endif
@@ -138,6 +141,11 @@ OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(seq_cst)
138141
OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(acq_rel)
139142
OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(relaxed)
140143

144+
// Modifiers for atomic 'fail' clause.
145+
OPENMP_ATOMIC_FAIL_MODIFIER(seq_cst)
146+
OPENMP_ATOMIC_FAIL_MODIFIER(acquire)
147+
OPENMP_ATOMIC_FAIL_MODIFIER(relaxed)
148+
141149
// Modifiers for 'at' clause.
142150
OPENMP_AT_KIND(compilation)
143151
OPENMP_AT_KIND(execution)
@@ -226,6 +234,7 @@ OPENMP_DOACROSS_MODIFIER(source_omp_cur_iteration)
226234
#undef OPENMP_SCHEDULE_MODIFIER
227235
#undef OPENMP_SCHEDULE_KIND
228236
#undef OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND
237+
#undef OPENMP_ATOMIC_FAIL_MODIFIER
229238
#undef OPENMP_AT_KIND
230239
#undef OPENMP_SEVERITY_KIND
231240
#undef OPENMP_MAP_KIND

clang/include/clang/Basic/OpenMPKinds.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,11 @@ bool isOpenMPCombinedParallelADirective(OpenMPDirectiveKind DKind);
363363
/// \return true - if the above condition is met for this directive
364364
/// otherwise - false.
365365
bool needsTaskBasedThreadLimit(OpenMPDirectiveKind DKind);
366+
367+
/// Checks if the parameter to the fail clause in "#pragma atomic compare fail"
368+
/// is restricted only to memory order clauses of "OMPC_acquire",
369+
/// "OMPC_relaxed" and "OMPC_seq_cst".
370+
bool checkFailClauseParameter(OpenMPClauseKind FailClauseParameter);
366371
}
367372

368373
#endif

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ def extract_api_ignores_EQ: CommaJoined<["--"], "extract-api-ignores=">,
14521452
Visibility<[ClangOption, CC1Option]>,
14531453
HelpText<"Comma separated list of files containing a new line separated list of API symbols to ignore when extracting API information.">,
14541454
MarshallingInfoStringVector<FrontendOpts<"ExtractAPIIgnoresFileList">>;
1455-
def e : JoinedOrSeparate<["-"], "e">, Flags<[LinkerInput]>, Group<Link_Group>;
1455+
def e : Separate<["-"], "e">, Flags<[LinkerInput]>, Group<Link_Group>;
14561456
def fmax_tokens_EQ : Joined<["-"], "fmax-tokens=">, Group<f_Group>,
14571457
Visibility<[ClangOption, CC1Option]>,
14581458
HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">,

clang/include/clang/Sema/Sema.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12198,6 +12198,13 @@ class Sema final {
1219812198
/// Called on well-formed 'compare' clause.
1219912199
OMPClause *ActOnOpenMPCompareClause(SourceLocation StartLoc,
1220012200
SourceLocation EndLoc);
12201+
/// Called on well-formed 'fail' clause.
12202+
OMPClause *ActOnOpenMPFailClause(SourceLocation StartLoc,
12203+
SourceLocation EndLoc);
12204+
OMPClause *ActOnOpenMPFailClause(
12205+
OpenMPClauseKind Kind, SourceLocation KindLoc,
12206+
SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc);
12207+
1220112208
/// Called on well-formed 'seq_cst' clause.
1220212209
OMPClause *ActOnOpenMPSeqCstClause(SourceLocation StartLoc,
1220312210
SourceLocation EndLoc);

clang/lib/AST/OpenMPClause.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) {
130130
case OMPC_update:
131131
case OMPC_capture:
132132
case OMPC_compare:
133+
case OMPC_fail:
133134
case OMPC_seq_cst:
134135
case OMPC_acq_rel:
135136
case OMPC_acquire:
@@ -227,6 +228,7 @@ const OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(const OMPClause *C)
227228
case OMPC_update:
228229
case OMPC_capture:
229230
case OMPC_compare:
231+
case OMPC_fail:
230232
case OMPC_seq_cst:
231233
case OMPC_acq_rel:
232234
case OMPC_acquire:
@@ -1925,6 +1927,16 @@ void OMPClausePrinter::VisitOMPCompareClause(OMPCompareClause *) {
19251927
OS << "compare";
19261928
}
19271929

1930+
void OMPClausePrinter::VisitOMPFailClause(OMPFailClause *Node) {
1931+
OS << "fail";
1932+
if (Node) {
1933+
OS << "(";
1934+
OS << getOpenMPSimpleClauseTypeName(
1935+
Node->getClauseKind(), static_cast<int>(Node->getFailParameter()));
1936+
OS << ")";
1937+
}
1938+
}
1939+
19281940
void OMPClausePrinter::VisitOMPSeqCstClause(OMPSeqCstClause *) {
19291941
OS << "seq_cst";
19301942
}

clang/lib/AST/StmtProfile.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,8 @@ void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {}
582582

583583
void OMPClauseProfiler::VisitOMPCompareClause(const OMPCompareClause *) {}
584584

585+
void OMPClauseProfiler::VisitOMPFailClause(const OMPFailClause *) {}
586+
585587
void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
586588

587589
void OMPClauseProfiler::VisitOMPAcqRelClause(const OMPAcqRelClause *) {}

clang/lib/Basic/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
set(LLVM_LINK_COMPONENTS
22
Support
33
TargetParser
4+
FrontendOpenMP
45
)
56

67
find_first_existing_vc_file("${LLVM_MAIN_SRC_DIR}" llvm_vc)

0 commit comments

Comments
 (0)