Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:43

0001 //===- StmtSYCL.h - Classes for SYCL kernel calls ---------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 /// \file
0009 /// This file defines SYCL AST classes used to represent calls to SYCL kernels.
0010 //===----------------------------------------------------------------------===//
0011 
0012 #ifndef LLVM_CLANG_AST_STMTSYCL_H
0013 #define LLVM_CLANG_AST_STMTSYCL_H
0014 
0015 #include "clang/AST/ASTContext.h"
0016 #include "clang/AST/Decl.h"
0017 #include "clang/AST/Stmt.h"
0018 #include "clang/Basic/SourceLocation.h"
0019 
0020 namespace clang {
0021 
0022 //===----------------------------------------------------------------------===//
0023 // AST classes for SYCL kernel calls.
0024 //===----------------------------------------------------------------------===//
0025 
0026 /// SYCLKernelCallStmt represents the transformation that is applied to the body
0027 /// of a function declared with the sycl_kernel_entry_point attribute. The body
0028 /// of such a function specifies the statements to be executed on a SYCL device
0029 /// to invoke a SYCL kernel with a particular set of kernel arguments. The
0030 /// SYCLKernelCallStmt associates an original statement (the compound statement
0031 /// that is the function body) with an OutlinedFunctionDecl that holds the
0032 /// kernel parameters and the transformed body. During code generation, the
0033 /// OutlinedFunctionDecl is used to emit an offload kernel entry point suitable
0034 /// for invocation from a SYCL library implementation. If executed, the
0035 /// SYCLKernelCallStmt behaves as a no-op; no code generation is performed for
0036 /// it.
0037 class SYCLKernelCallStmt : public Stmt {
0038   friend class ASTStmtReader;
0039   friend class ASTStmtWriter;
0040 
0041 private:
0042   Stmt *OriginalStmt = nullptr;
0043   OutlinedFunctionDecl *OFDecl = nullptr;
0044 
0045 public:
0046   /// Construct a SYCL kernel call statement.
0047   SYCLKernelCallStmt(CompoundStmt *CS, OutlinedFunctionDecl *OFD)
0048       : Stmt(SYCLKernelCallStmtClass), OriginalStmt(CS), OFDecl(OFD) {}
0049 
0050   /// Construct an empty SYCL kernel call statement.
0051   SYCLKernelCallStmt(EmptyShell Empty) : Stmt(SYCLKernelCallStmtClass, Empty) {}
0052 
0053   /// Retrieve the model statement.
0054   CompoundStmt *getOriginalStmt() { return cast<CompoundStmt>(OriginalStmt); }
0055   const CompoundStmt *getOriginalStmt() const {
0056     return cast<CompoundStmt>(OriginalStmt);
0057   }
0058   void setOriginalStmt(CompoundStmt *CS) { OriginalStmt = CS; }
0059 
0060   /// Retrieve the outlined function declaration.
0061   OutlinedFunctionDecl *getOutlinedFunctionDecl() { return OFDecl; }
0062   const OutlinedFunctionDecl *getOutlinedFunctionDecl() const { return OFDecl; }
0063 
0064   /// Set the outlined function declaration.
0065   void setOutlinedFunctionDecl(OutlinedFunctionDecl *OFD) { OFDecl = OFD; }
0066 
0067   SourceLocation getBeginLoc() const LLVM_READONLY {
0068     return getOriginalStmt()->getBeginLoc();
0069   }
0070 
0071   SourceLocation getEndLoc() const LLVM_READONLY {
0072     return getOriginalStmt()->getEndLoc();
0073   }
0074 
0075   SourceRange getSourceRange() const LLVM_READONLY {
0076     return getOriginalStmt()->getSourceRange();
0077   }
0078 
0079   static bool classof(const Stmt *T) {
0080     return T->getStmtClass() == SYCLKernelCallStmtClass;
0081   }
0082 
0083   child_range children() {
0084     return child_range(&OriginalStmt, &OriginalStmt + 1);
0085   }
0086 
0087   const_child_range children() const {
0088     return const_child_range(&OriginalStmt, &OriginalStmt + 1);
0089   }
0090 };
0091 
0092 } // end namespace clang
0093 
0094 #endif // LLVM_CLANG_AST_STMTSYCL_H