Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
919cd88
[SYCL] SYCL host kernel launch support for the sycl_kernel_entry_poin…
tahonermann Aug 7, 2025
350a476
Add diagnostics for use of 'this' in a potentially evaluated expression.
tahonermann Aug 16, 2025
1f1b8b7
Remove stale FIXME comment regarding diagnostics for 'this'.
tahonermann Aug 16, 2025
2a1c23d
Add tests for kernel name character encoding concerns.
tahonermann Aug 18, 2025
c1ffcf8
[SYCL-Upstreaming] Add support for host kernel launch stmt generation…
Fznamznon Sep 29, 2025
59baed4
[SYCL-Upstreaming] Fix a crash (#52)
Fznamznon Oct 1, 2025
4abaf06
[SYCL-Upstreaming] Fix a crash an argument of skep function is not tr…
Fznamznon Oct 1, 2025
9779525
Correct expected AST output for a test following a rebase.
tahonermann Nov 10, 2025
07c9c1c
Misc cleanup.
tahonermann Nov 14, 2025
5b18f99
Address clang-format complaints.
tahonermann Nov 14, 2025
8a4fc3f
Added support for passing arguments to sycl_kernel_launch as xvalues.
tahonermann Nov 15, 2025
69740b2
Prohibited use of the sycl_kernel_entry_point attribute with a non-st…
tahonermann Nov 15, 2025
1aee751
Diagnostic improvements, additional tests.
tahonermann Nov 18, 2025
fa42860
Make clang-format happy again.
tahonermann Nov 18, 2025
f89a6af
Reworded much of the sycl_kernel_entry_point attribute documentation.
tahonermann Nov 21, 2025
ee8ba91
Added an additional test case to sycl-kernel-launch-ms-compat.cpp.
tahonermann Nov 21, 2025
ac92913
Fix a style nit noted in code review.
tahonermann Nov 21, 2025
1035a57
Addressed code review comments from Mariya and corrected a grammar is…
tahonermann Dec 5, 2025
6da9cc9
Added coge generation tests for exception handling.
tahonermann Dec 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion clang/include/clang/AST/ASTNodeTraverser.h
Original file line number Diff line number Diff line change
Expand Up @@ -836,8 +836,10 @@ class ASTNodeTraverser

void VisitSYCLKernelCallStmt(const SYCLKernelCallStmt *Node) {
Visit(Node->getOriginalStmt());
if (Traversal != TK_IgnoreUnlessSpelledInSource)
if (Traversal != TK_IgnoreUnlessSpelledInSource) {
Visit(Node->getKernelLaunchStmt());
Visit(Node->getOutlinedFunctionDecl());
}
}

void VisitOMPExecutableDirective(const OMPExecutableDirective *Node) {
Expand Down
8 changes: 8 additions & 0 deletions clang/include/clang/AST/RecursiveASTVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2990,6 +2990,13 @@ DEF_TRAVERSE_STMT(ParenListExpr, {})
DEF_TRAVERSE_STMT(SYCLUniqueStableNameExpr, {
TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
})
DEF_TRAVERSE_STMT(UnresolvedSYCLKernelCallStmt, {
if (getDerived().shouldVisitImplicitCode()) {
TRY_TO(TraverseStmt(S->getOriginalStmt()));
TRY_TO(TraverseStmt(S->getKernelLaunchIdExpr()));
ShouldVisitChildren = false;
}
})
DEF_TRAVERSE_STMT(OpenACCAsteriskSizeExpr, {})
DEF_TRAVERSE_STMT(PredefinedExpr, {})
DEF_TRAVERSE_STMT(ShuffleVectorExpr, {})
Expand Down Expand Up @@ -3027,6 +3034,7 @@ DEF_TRAVERSE_STMT(CapturedStmt, { TRY_TO(TraverseDecl(S->getCapturedDecl())); })
DEF_TRAVERSE_STMT(SYCLKernelCallStmt, {
if (getDerived().shouldVisitImplicitCode()) {
TRY_TO(TraverseStmt(S->getOriginalStmt()));
TRY_TO(TraverseStmt(S->getKernelLaunchStmt()));
TRY_TO(TraverseDecl(S->getOutlinedFunctionDecl()));
ShouldVisitChildren = false;
}
Expand Down
92 changes: 83 additions & 9 deletions clang/include/clang/AST/StmtSYCL.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,45 @@ namespace clang {
/// of such a function specifies the statements to be executed on a SYCL device
/// to invoke a SYCL kernel with a particular set of kernel arguments. The
/// SYCLKernelCallStmt associates an original statement (the compound statement
/// that is the function body) with an OutlinedFunctionDecl that holds the
/// kernel parameters and the transformed body. During code generation, the
/// OutlinedFunctionDecl is used to emit an offload kernel entry point suitable
/// for invocation from a SYCL library implementation. If executed, the
/// SYCLKernelCallStmt behaves as a no-op; no code generation is performed for
/// it.
/// that is the function body) with a kernel launch statement to execute on a
/// SYCL host and an OutlinedFunctionDecl that holds the kernel parameters and
/// the transformed body to execute on a SYCL device. During code generation,
/// the OutlinedFunctionDecl is used to emit an offload kernel entry point
/// suitable for invocation from a SYCL library implementation.
class SYCLKernelCallStmt : public Stmt {
friend class ASTStmtReader;
friend class ASTStmtWriter;

private:
Stmt *OriginalStmt = nullptr;
Stmt *KernelLaunchStmt = nullptr;
OutlinedFunctionDecl *OFDecl = nullptr;

public:
/// Construct a SYCL kernel call statement.
SYCLKernelCallStmt(CompoundStmt *CS, OutlinedFunctionDecl *OFD)
: Stmt(SYCLKernelCallStmtClass), OriginalStmt(CS), OFDecl(OFD) {}
SYCLKernelCallStmt(CompoundStmt *CS, Stmt *S, OutlinedFunctionDecl *OFD)
: Stmt(SYCLKernelCallStmtClass), OriginalStmt(CS), KernelLaunchStmt(S),
OFDecl(OFD) {}

/// Construct an empty SYCL kernel call statement.
SYCLKernelCallStmt(EmptyShell Empty) : Stmt(SYCLKernelCallStmtClass, Empty) {}

/// Retrieve the model statement.
/// Retrieve the original statement.
CompoundStmt *getOriginalStmt() { return cast<CompoundStmt>(OriginalStmt); }
const CompoundStmt *getOriginalStmt() const {
return cast<CompoundStmt>(OriginalStmt);
}

/// Set the original statement.
void setOriginalStmt(CompoundStmt *CS) { OriginalStmt = CS; }

/// Retrieve the kernel launch statement.
Stmt *getKernelLaunchStmt() { return KernelLaunchStmt; }
const Stmt *getKernelLaunchStmt() const { return KernelLaunchStmt; }

/// Set the kernel launch statement.
void setKernelLaunchStmt(Stmt *S) { KernelLaunchStmt = S; }

/// Retrieve the outlined function declaration.
OutlinedFunctionDecl *getOutlinedFunctionDecl() { return OFDecl; }
const OutlinedFunctionDecl *getOutlinedFunctionDecl() const { return OFDecl; }
Expand Down Expand Up @@ -89,6 +99,70 @@ class SYCLKernelCallStmt : public Stmt {
}
};

// UnresolvedSYCLKernelCallStmt represents an invocation of a SYCL kernel in
// a dependent context for which lookup of the sycl_kernel_launch identifier
// cannot be performed. These statements are transformed to SYCLKernelCallStmt
// during template instantiation.
class UnresolvedSYCLKernelCallStmt : public Stmt {
friend class ASTStmtReader;
friend class ASTStmtWriter;

private:
Stmt *OriginalStmt = nullptr;
// KernelLaunchIdExpr stores an UnresolvedLookupExpr or UnresolvedMemberExpr
// corresponding to the SYCL kernel launch function for which a call
// will be synthesized during template instantiation.
Expr *KernelLaunchIdExpr = nullptr;

UnresolvedSYCLKernelCallStmt(CompoundStmt *CS, Expr *IdExpr)
: Stmt(UnresolvedSYCLKernelCallStmtClass), OriginalStmt(CS),
KernelLaunchIdExpr(IdExpr) {}

/// Set the original statement.
void setOriginalStmt(CompoundStmt *CS) { OriginalStmt = CS; }

/// Set the kernel launch ID expression.
void setKernelLaunchIdExpr(Expr *IdExpr) { KernelLaunchIdExpr = IdExpr; }

public:
static UnresolvedSYCLKernelCallStmt *Create(const ASTContext &C,
CompoundStmt *CS, Expr *IdExpr) {
return new (C) UnresolvedSYCLKernelCallStmt(CS, IdExpr);
}

static UnresolvedSYCLKernelCallStmt *CreateEmpty(const ASTContext &C) {
return new (C) UnresolvedSYCLKernelCallStmt(nullptr, nullptr);
}

/// Retrieve the original statement.
CompoundStmt *getOriginalStmt() { return cast<CompoundStmt>(OriginalStmt); }
const CompoundStmt *getOriginalStmt() const {
return cast<CompoundStmt>(OriginalStmt);
}

/// Retrieve the kernel launch ID expression.
Expr *getKernelLaunchIdExpr() { return KernelLaunchIdExpr; }
const Expr *getKernelLaunchIdExpr() const { return KernelLaunchIdExpr; }

SourceLocation getBeginLoc() const LLVM_READONLY {
return getOriginalStmt()->getBeginLoc();
}

SourceLocation getEndLoc() const LLVM_READONLY {
return getOriginalStmt()->getEndLoc();
}
static bool classof(const Stmt *T) {
return T->getStmtClass() == UnresolvedSYCLKernelCallStmtClass;
}
child_range children() {
return child_range(&OriginalStmt, &OriginalStmt + 1);
}

const_child_range children() const {
return const_child_range(&OriginalStmt, &OriginalStmt + 1);
}
};

} // end namespace clang

#endif // LLVM_CLANG_AST_STMTSYCL_H
Loading
Loading