-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[SYCL] AST support for SYCL kernel entry point functions. #122379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a634261
[SYCL] AST support for SYCL kernel entry point functions.
tahonermann 51951a7
Squash; address the non-dumb clang-format complaints.
tahonermann cef6177
Addressed the first round of code review comments from Erich Keane.
tahonermann 7077a87
Disallow applying the sycl_kernel_entry_point attribute to functions …
tahonermann dc93ffa
Addressed the second round of code review comments from Erich Keane.
tahonermann 48b62dc
clang-format is a harsh mistress.
tahonermann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
//===- StmtSYCL.h - Classes for SYCL kernel calls ---------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// \file | ||
/// This file defines SYCL AST classes used to represent calls to SYCL kernels. | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_CLANG_AST_STMTSYCL_H | ||
#define LLVM_CLANG_AST_STMTSYCL_H | ||
|
||
#include "clang/AST/ASTContext.h" | ||
#include "clang/AST/Decl.h" | ||
#include "clang/AST/Stmt.h" | ||
#include "clang/Basic/SourceLocation.h" | ||
|
||
namespace clang { | ||
|
||
//===----------------------------------------------------------------------===// | ||
// AST classes for SYCL kernel calls. | ||
//===----------------------------------------------------------------------===// | ||
|
||
/// SYCLKernelCallStmt represents the transformation that is applied to the body | ||
/// of a function declared with the sycl_kernel_entry_point attribute. The body | ||
/// 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. | ||
class SYCLKernelCallStmt : public Stmt { | ||
friend class ASTStmtReader; | ||
friend class ASTStmtWriter; | ||
|
||
private: | ||
Stmt *OriginalStmt = nullptr; | ||
OutlinedFunctionDecl *OFDecl = nullptr; | ||
|
||
public: | ||
/// Construct a SYCL kernel call statement. | ||
SYCLKernelCallStmt(CompoundStmt *CS, OutlinedFunctionDecl *OFD) | ||
: Stmt(SYCLKernelCallStmtClass), OriginalStmt(CS), OFDecl(OFD) {} | ||
|
||
/// Construct an empty SYCL kernel call statement. | ||
SYCLKernelCallStmt(EmptyShell Empty) : Stmt(SYCLKernelCallStmtClass, Empty) {} | ||
|
||
/// Retrieve the model statement. | ||
CompoundStmt *getOriginalStmt() { return cast<CompoundStmt>(OriginalStmt); } | ||
const CompoundStmt *getOriginalStmt() const { | ||
return cast<CompoundStmt>(OriginalStmt); | ||
} | ||
void setOriginalStmt(CompoundStmt *CS) { OriginalStmt = CS; } | ||
|
||
/// Retrieve the outlined function declaration. | ||
OutlinedFunctionDecl *getOutlinedFunctionDecl() { return OFDecl; } | ||
const OutlinedFunctionDecl *getOutlinedFunctionDecl() const { return OFDecl; } | ||
|
||
/// Set the outlined function declaration. | ||
void setOutlinedFunctionDecl(OutlinedFunctionDecl *OFD) { OFDecl = OFD; } | ||
|
||
SourceLocation getBeginLoc() const LLVM_READONLY { | ||
return getOriginalStmt()->getBeginLoc(); | ||
} | ||
|
||
SourceLocation getEndLoc() const LLVM_READONLY { | ||
return getOriginalStmt()->getEndLoc(); | ||
} | ||
|
||
SourceRange getSourceRange() const LLVM_READONLY { | ||
return getOriginalStmt()->getSourceRange(); | ||
} | ||
|
||
static bool classof(const Stmt *T) { | ||
return T->getStmtClass() == SYCLKernelCallStmtClass; | ||
} | ||
|
||
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.