clang 20.0.0git
StmtSYCL.h
Go to the documentation of this file.
1//===- StmtSYCL.h - Classes for SYCL kernel calls ---------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8/// \file
9/// This file defines SYCL AST classes used to represent calls to SYCL kernels.
10//===----------------------------------------------------------------------===//
11
12#ifndef LLVM_CLANG_AST_STMTSYCL_H
13#define LLVM_CLANG_AST_STMTSYCL_H
14
16#include "clang/AST/Decl.h"
17#include "clang/AST/Stmt.h"
19
20namespace clang {
21
22//===----------------------------------------------------------------------===//
23// AST classes for SYCL kernel calls.
24//===----------------------------------------------------------------------===//
25
26/// SYCLKernelCallStmt represents the transformation that is applied to the body
27/// of a function declared with the sycl_kernel_entry_point attribute. The body
28/// of such a function specifies the statements to be executed on a SYCL device
29/// to invoke a SYCL kernel with a particular set of kernel arguments. The
30/// SYCLKernelCallStmt associates an original statement (the compound statement
31/// that is the function body) with an OutlinedFunctionDecl that holds the
32/// kernel parameters and the transformed body. During code generation, the
33/// OutlinedFunctionDecl is used to emit an offload kernel entry point suitable
34/// for invocation from a SYCL library implementation. If executed, the
35/// SYCLKernelCallStmt behaves as a no-op; no code generation is performed for
36/// it.
37class SYCLKernelCallStmt : public Stmt {
38 friend class ASTStmtReader;
39 friend class ASTStmtWriter;
40
41private:
42 Stmt *OriginalStmt = nullptr;
43 OutlinedFunctionDecl *OFDecl = nullptr;
44
45public:
46 /// Construct a SYCL kernel call statement.
48 : Stmt(SYCLKernelCallStmtClass), OriginalStmt(CS), OFDecl(OFD) {}
49
50 /// Construct an empty SYCL kernel call statement.
51 SYCLKernelCallStmt(EmptyShell Empty) : Stmt(SYCLKernelCallStmtClass, Empty) {}
52
53 /// Retrieve the model statement.
54 CompoundStmt *getOriginalStmt() { return cast<CompoundStmt>(OriginalStmt); }
56 return cast<CompoundStmt>(OriginalStmt);
57 }
58 void setOriginalStmt(CompoundStmt *CS) { OriginalStmt = CS; }
59
60 /// Retrieve the outlined function declaration.
62 const OutlinedFunctionDecl *getOutlinedFunctionDecl() const { return OFDecl; }
63
64 /// Set the outlined function declaration.
65 void setOutlinedFunctionDecl(OutlinedFunctionDecl *OFD) { OFDecl = OFD; }
66
67 SourceLocation getBeginLoc() const LLVM_READONLY {
68 return getOriginalStmt()->getBeginLoc();
69 }
70
71 SourceLocation getEndLoc() const LLVM_READONLY {
72 return getOriginalStmt()->getEndLoc();
73 }
74
75 SourceRange getSourceRange() const LLVM_READONLY {
77 }
78
79 static bool classof(const Stmt *T) {
80 return T->getStmtClass() == SYCLKernelCallStmtClass;
81 }
82
84 return child_range(&OriginalStmt, &OriginalStmt + 1);
85 }
86
88 return const_child_range(&OriginalStmt, &OriginalStmt + 1);
89 }
90};
91
92} // end namespace clang
93
94#endif // LLVM_CLANG_AST_STMTSYCL_H
Defines the clang::ASTContext interface.
Defines the clang::SourceLocation class and associated facilities.
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1628
SourceLocation getBeginLoc() const
Definition: Stmt.h:1762
SourceLocation getEndLoc() const
Definition: Stmt.h:1763
Represents a partial function definition.
Definition: Decl.h:4703
SYCLKernelCallStmt represents the transformation that is applied to the body of a function declared w...
Definition: StmtSYCL.h:37
CompoundStmt * getOriginalStmt()
Retrieve the model statement.
Definition: StmtSYCL.h:54
void setOriginalStmt(CompoundStmt *CS)
Definition: StmtSYCL.h:58
static bool classof(const Stmt *T)
Definition: StmtSYCL.h:79
SourceRange getSourceRange() const LLVM_READONLY
Definition: StmtSYCL.h:75
SYCLKernelCallStmt(CompoundStmt *CS, OutlinedFunctionDecl *OFD)
Construct a SYCL kernel call statement.
Definition: StmtSYCL.h:47
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: StmtSYCL.h:67
const OutlinedFunctionDecl * getOutlinedFunctionDecl() const
Definition: StmtSYCL.h:62
child_range children()
Definition: StmtSYCL.h:83
const CompoundStmt * getOriginalStmt() const
Definition: StmtSYCL.h:55
SYCLKernelCallStmt(EmptyShell Empty)
Construct an empty SYCL kernel call statement.
Definition: StmtSYCL.h:51
SourceLocation getEndLoc() const LLVM_READONLY
Definition: StmtSYCL.h:71
const_child_range children() const
Definition: StmtSYCL.h:87
OutlinedFunctionDecl * getOutlinedFunctionDecl()
Retrieve the outlined function declaration.
Definition: StmtSYCL.h:61
void setOutlinedFunctionDecl(OutlinedFunctionDecl *OFD)
Set the outlined function declaration.
Definition: StmtSYCL.h:65
Encodes a location in the source.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
Definition: Stmt.h:84
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:334
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:1469
llvm::iterator_range< const_child_iterator > const_child_range
Definition: Stmt.h:1470
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....
Definition: Stmt.h:1320