Skip to content

Commit 91fa249

Browse files
committed
Merge branch 'main' into xegpu-mem-effects
2 parents 1b0bba7 + e4980c6 commit 91fa249

File tree

448 files changed

+14928
-7513
lines changed

Some content is hidden

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

448 files changed

+14928
-7513
lines changed

clang/include/clang-c/Index.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2206,7 +2206,11 @@ enum CXCursorKind {
22062206
*/
22072207
CXCursor_OpenACCUpdateConstruct = 331,
22082208

2209-
CXCursor_LastStmt = CXCursor_OpenACCUpdateConstruct,
2209+
/** OpenACC atomic Construct.
2210+
*/
2211+
CXCursor_OpenACCAtomicConstruct = 332,
2212+
2213+
CXCursor_LastStmt = CXCursor_OpenACCAtomicConstruct,
22102214

22112215
/**
22122216
* Cursor that represents the translation unit itself.

clang/include/clang/AST/DeclBase.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,8 +1257,11 @@ class alignas(8) Decl {
12571257
int64_t getID() const;
12581258

12591259
/// Looks through the Decl's underlying type to extract a FunctionType
1260-
/// when possible. Will return null if the type underlying the Decl does not
1261-
/// have a FunctionType.
1260+
/// when possible. This includes direct FunctionDecls, along with various
1261+
/// function types and typedefs. This includes function pointers/references,
1262+
/// member function pointers, and optionally if \p BlocksToo is set
1263+
/// Objective-C block pointers. Returns nullptr if the type underlying the
1264+
/// Decl does not have a FunctionType.
12621265
const FunctionType *getFunctionType(bool BlocksToo = true) const;
12631266

12641267
// Looks through the Decl's underlying type to determine if it's a

clang/include/clang/AST/ExprCXX.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5040,7 +5040,7 @@ class CXXParenListInitExpr final
50405040
}
50415041

50425042
const FieldDecl *getInitializedFieldInUnion() const {
5043-
return ArrayFillerOrUnionFieldInit.dyn_cast<FieldDecl *>();
5043+
return dyn_cast_if_present<FieldDecl *>(ArrayFillerOrUnionFieldInit);
50445044
}
50455045

50465046
child_range children() {

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4099,6 +4099,8 @@ DEF_TRAVERSE_STMT(OpenACCSetConstruct,
40994099
{ TRY_TO(VisitOpenACCClauseList(S->clauses())); })
41004100
DEF_TRAVERSE_STMT(OpenACCUpdateConstruct,
41014101
{ TRY_TO(VisitOpenACCClauseList(S->clauses())); })
4102+
DEF_TRAVERSE_STMT(OpenACCAtomicConstruct,
4103+
{ TRY_TO(TraverseOpenACCAssociatedStmtConstruct(S)); })
41024104

41034105
// Traverse HLSL: Out argument expression
41044106
DEF_TRAVERSE_STMT(HLSLOutArgExpr, {})

clang/include/clang/AST/StmtOpenACC.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,5 +751,50 @@ class OpenACCUpdateConstruct final
751751
Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
752752
SourceLocation End, ArrayRef<const OpenACCClause *> Clauses);
753753
};
754+
755+
// This class represents the 'atomic' construct, which has an associated
756+
// statement, but no clauses.
757+
class OpenACCAtomicConstruct final : public OpenACCAssociatedStmtConstruct {
758+
759+
friend class ASTStmtReader;
760+
OpenACCAtomicKind AtomicKind = OpenACCAtomicKind::None;
761+
762+
OpenACCAtomicConstruct(EmptyShell)
763+
: OpenACCAssociatedStmtConstruct(
764+
OpenACCAtomicConstructClass, OpenACCDirectiveKind::Atomic,
765+
SourceLocation{}, SourceLocation{}, SourceLocation{},
766+
/*AssociatedStmt=*/nullptr) {}
767+
768+
OpenACCAtomicConstruct(SourceLocation Start, SourceLocation DirectiveLoc,
769+
OpenACCAtomicKind AtKind, SourceLocation End,
770+
Stmt *AssociatedStmt)
771+
: OpenACCAssociatedStmtConstruct(OpenACCAtomicConstructClass,
772+
OpenACCDirectiveKind::Atomic, Start,
773+
DirectiveLoc, End, AssociatedStmt),
774+
AtomicKind(AtKind) {}
775+
776+
void setAssociatedStmt(Stmt *S) {
777+
OpenACCAssociatedStmtConstruct::setAssociatedStmt(S);
778+
}
779+
780+
public:
781+
static bool classof(const Stmt *T) {
782+
return T->getStmtClass() == OpenACCAtomicConstructClass;
783+
}
784+
785+
static OpenACCAtomicConstruct *CreateEmpty(const ASTContext &C);
786+
static OpenACCAtomicConstruct *
787+
Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
788+
OpenACCAtomicKind AtKind, SourceLocation End, Stmt *AssociatedStmt);
789+
790+
OpenACCAtomicKind getAtomicKind() const { return AtomicKind; }
791+
const Stmt *getAssociatedStmt() const {
792+
return OpenACCAssociatedStmtConstruct::getAssociatedStmt();
793+
}
794+
Stmt *getAssociatedStmt() {
795+
return OpenACCAssociatedStmtConstruct::getAssociatedStmt();
796+
}
797+
};
798+
754799
} // namespace clang
755800
#endif // LLVM_CLANG_AST_STMTOPENACC_H

clang/include/clang/AST/TextNodeDumper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ class TextNodeDumper
420420
void VisitOpenACCSetConstruct(const OpenACCSetConstruct *S);
421421
void VisitOpenACCShutdownConstruct(const OpenACCShutdownConstruct *S);
422422
void VisitOpenACCUpdateConstruct(const OpenACCUpdateConstruct *S);
423+
void VisitOpenACCAtomicConstruct(const OpenACCAtomicConstruct *S);
423424
void VisitOpenACCAsteriskSizeExpr(const OpenACCAsteriskSizeExpr *S);
424425
void VisitEmbedExpr(const EmbedExpr *S);
425426
void VisitAtomicExpr(const AtomicExpr *AE);

clang/include/clang/Basic/Attr.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def OpenCLKernelFunction
198198
// inclusive nature of subject testing).
199199
def HasFunctionProto : SubsetSubject<DeclBase,
200200
[{(S->getFunctionType(true) != nullptr &&
201-
isa<FunctionProtoType>(S->getFunctionType())) ||
201+
isa<FunctionProtoType>(S->getFunctionType())) ||
202202
isa<ObjCMethodDecl>(S) ||
203203
isa<BlockDecl>(S)}],
204204
"non-K&R-style functions">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12903,6 +12903,48 @@ def err_acc_update_as_body
1290312903
: Error<"OpenACC 'update' construct may not appear in place of the "
1290412904
"statement following a%select{n if statement| while statement| do "
1290512905
"statement| switch statement| label statement}0">;
12906+
def err_acc_invalid_atomic
12907+
: Error<"statement associated with OpenACC 'atomic%select{| "
12908+
"%1}0' directive is invalid">;
12909+
def note_acc_atomic_expr_must_be
12910+
: Note<"expected "
12911+
"%enum_select<OACCAtomicExpr>{%Assign{assignment}|%UnaryCompAssign{"
12912+
"assignment, compound assignment, increment, or decrement}}0 "
12913+
"expression">;
12914+
def note_acc_atomic_unsupported_unary_operator
12915+
: Note<"unary operator not supported, only increment and decrement "
12916+
"operations permitted">;
12917+
def note_acc_atomic_unsupported_binary_operator
12918+
: Note<"binary operator not supported, only +, *, -, /, &, ^, |, <<, or >> "
12919+
"are permitted">;
12920+
def note_acc_atomic_unsupported_compound_binary_operator
12921+
: Note<"compound binary operator not supported, only +=, *=, -=, /=, &=, "
12922+
"^=, |=, <<=, or >>= are permitted">;
12923+
12924+
def note_acc_atomic_operand_lvalue_scalar
12925+
: Note<"%select{left |right |}0operand to "
12926+
"%enum_select<OACCAtomicOpKind>{%Assign{assignment}|%CompoundAssign{"
12927+
"compound assignment}|%Inc{increment}|"
12928+
"%Dec{decrement}}1 "
12929+
"expression must be "
12930+
"%enum_select<OACCLValScalar>{%LVal{an l-value}|%Scalar{of scalar "
12931+
"type (was %3)}}2">;
12932+
def note_acc_atomic_too_many_stmts
12933+
: Note<"'atomic capture' with a compound statement only supports two "
12934+
"statements">;
12935+
def note_acc_atomic_expected_binop : Note<"expected binary operation on right "
12936+
"hand side of assignment operator">;
12937+
def note_acc_atomic_mismatch_operand
12938+
: Note<"left hand side of assignment operation('%0') must match one side "
12939+
"of the sub-operation on the right hand side('%1' and '%2')">;
12940+
def note_acc_atomic_mismatch_compound_operand
12941+
: Note<"variable %select{|in unary expression|on right hand side of "
12942+
"assignment|on left hand side of assignment|on left hand side of "
12943+
"compound assignment|on left hand side of assignment}2('%3') must "
12944+
"match variable used %select{|in unary expression|on right hand "
12945+
"side of assignment|<not possible>|on left hand side of compound "
12946+
"assignment|on left hand side of assignment}0('%1') from the first "
12947+
"statement">;
1290612948

1290712949
// AMDGCN builtins diagnostics
1290812950
def err_amdgcn_global_load_lds_size_invalid_value : Error<"invalid size value">;

clang/include/clang/Basic/OpenACCKinds.h

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,33 @@ enum class OpenACCAtomicKind : uint8_t {
171171
Write,
172172
Update,
173173
Capture,
174-
Invalid,
174+
None,
175175
};
176176

177+
template <typename StreamTy>
178+
inline StreamTy &printOpenACCAtomicKind(StreamTy &Out, OpenACCAtomicKind AK) {
179+
switch (AK) {
180+
case OpenACCAtomicKind::Read:
181+
return Out << "read";
182+
case OpenACCAtomicKind::Write:
183+
return Out << "write";
184+
case OpenACCAtomicKind::Update:
185+
return Out << "update";
186+
case OpenACCAtomicKind::Capture:
187+
return Out << "capture";
188+
case OpenACCAtomicKind::None:
189+
return Out << "<none>";
190+
}
191+
}
192+
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &Out,
193+
OpenACCAtomicKind AK) {
194+
return printOpenACCAtomicKind(Out, AK);
195+
}
196+
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out,
197+
OpenACCAtomicKind AK) {
198+
return printOpenACCAtomicKind(Out, AK);
199+
}
200+
177201
/// Represents the kind of an OpenACC clause.
178202
enum class OpenACCClauseKind : uint8_t {
179203
/// 'finalize' clause, allowed on 'exit data' directive.

clang/include/clang/Basic/StmtNodes.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ def OpenACCInitConstruct : StmtNode<OpenACCConstructStmt>;
319319
def OpenACCShutdownConstruct : StmtNode<OpenACCConstructStmt>;
320320
def OpenACCSetConstruct : StmtNode<OpenACCConstructStmt>;
321321
def OpenACCUpdateConstruct : StmtNode<OpenACCConstructStmt>;
322+
def OpenACCAtomicConstruct : StmtNode<OpenACCAssociatedStmtConstruct>;
322323

323324
// OpenACC Additional Expressions.
324325
def OpenACCAsteriskSizeExpr : StmtNode<Expr>;

0 commit comments

Comments
 (0)