clang 23.0.0git
SemaSYCL.h
Go to the documentation of this file.
1//===----- SemaSYCL.h ------- Semantic Analysis for SYCL constructs -------===//
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 declares semantic analysis for SYCL constructs.
10///
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_SEMA_SEMASYCL_H
14#define LLVM_CLANG_SEMA_SEMASYCL_H
15
16#include "clang/AST/ASTFwd.h"
17#include "clang/AST/Type.h"
20#include "clang/Sema/SemaBase.h"
21#include "llvm/ADT/DenseSet.h"
22
23namespace clang {
24class Decl;
25class ParsedAttr;
26
27class SemaSYCL : public SemaBase {
28public:
29 SemaSYCL(Sema &S);
30
31 /// Creates a SemaDiagnosticBuilder that emits the diagnostic if the current
32 /// context is "used as device code".
33 ///
34 /// - If CurLexicalContext is a kernel function or it is known that the
35 /// function will be emitted for the device, emits the diagnostics
36 /// immediately.
37 /// - If CurLexicalContext is a function and we are compiling
38 /// for the device, but we don't know yet that this function will be
39 /// codegen'ed for the devive, creates a diagnostic which is emitted if and
40 /// when we realize that the function will be codegen'ed.
41 ///
42 /// Example usage:
43 ///
44 /// Diagnose __float128 type usage only from SYCL device code if the current
45 /// target doesn't support it
46 /// if (!S.Context.getTargetInfo().hasFloat128Type() &&
47 /// S.getLangOpts().SYCLIsDevice)
48 /// DiagIfDeviceCode(Loc, diag::err_type_unsupported) << "__float128";
50
52 llvm::DenseSet<QualType> Visited,
53 ValueDecl *DeclToCheck);
54
56 SourceLocation LParen,
57 SourceLocation RParen,
58 TypeSourceInfo *TSI);
60 SourceLocation LParen,
61 SourceLocation RParen,
62 ParsedType ParsedTy);
63
64 void handleKernelAttr(Decl *D, const ParsedAttr &AL);
65 void handleKernelEntryPointAttr(Decl *D, const ParsedAttr &AL);
66
67 /// Issues a deferred diagnostic if use of the declaration designated
68 /// by 'ND' is invalid in a device context.
70
73
74 /// Builds an expression for the lookup of a 'sycl_kernel_launch' template
75 /// with 'KernelName' as an explicit template argument. Lookup is performed
76 /// as if from the first statement of the body of 'FD' and thus requires
77 /// searching the scopes that exist at parse time. This function therefore
78 /// requires the current semantic context to be the definition of 'FD'. In a
79 /// dependent context, the returned expression will be an UnresolvedLookupExpr
80 /// or an UnresolvedMemberExpr. In a non-dependent context, the returned
81 /// expression will be a DeclRefExpr or MemberExpr. If lookup fails, a null
82 /// error result is returned. The resulting expression is intended to be
83 /// passed as the 'LaunchIdExpr' argument in a call to either
84 /// BuildSYCLKernelCallStmt() or BuildUnresolvedSYCLKernelCallStmt() after
85 /// the function body has been parsed.
87
88 /// Builds a SYCLKernelCallStmt to wrap 'Body' and to be used as the body of
89 /// 'FD'. 'LaunchIdExpr' specifies the lookup result returned by a previous
90 /// call to BuildSYCLKernelLaunchIdExpr().
92 Expr *LaunchIdExpr);
93
94 /// Builds an UnresolvedSYCLKernelCallStmt to wrap 'Body'. 'LaunchIdExpr'
95 /// specifies the lookup result returned by a previous call to
96 /// BuildSYCLKernelLaunchIdExpr().
98 Expr *LaunchIdExpr);
99};
100
101} // namespace clang
102
103#endif // LLVM_CLANG_SEMA_SEMASYCL_H
Forward declaration of all AST node types.
Defines the clang::SourceLocation class and associated facilities.
C Language Family Type Representation.
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition Stmt.h:1732
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
This represents one expression.
Definition Expr.h:112
Represents a function declaration or definition.
Definition Decl.h:2000
This represents a decl that may have a name.
Definition Decl.h:274
ParsedAttr - Represents a syntactic attribute.
Definition ParsedAttr.h:119
A (possibly-)qualified type.
Definition TypeBase.h:937
A generic diagnostic builder for errors which may or may not be deferred.
Definition SemaBase.h:111
SemaBase(Sema &S)
Definition SemaBase.cpp:7
StmtResult BuildUnresolvedSYCLKernelCallStmt(CompoundStmt *Body, Expr *LaunchIdExpr)
Builds an UnresolvedSYCLKernelCallStmt to wrap 'Body'.
Definition SemaSYCL.cpp:713
StmtResult BuildSYCLKernelCallStmt(FunctionDecl *FD, CompoundStmt *Body, Expr *LaunchIdExpr)
Builds a SYCLKernelCallStmt to wrap 'Body' and to be used as the body of 'FD'.
Definition SemaSYCL.cpp:670
SemaDiagnosticBuilder DiagIfDeviceCode(SourceLocation Loc, unsigned DiagID)
Creates a SemaDiagnosticBuilder that emits the diagnostic if the current context is "used as device c...
Definition SemaSYCL.cpp:30
void CheckSYCLExternalFunctionDecl(FunctionDecl *FD)
Definition SemaSYCL.cpp:280
ExprResult BuildUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
Definition SemaSYCL.cpp:153
void handleKernelEntryPointAttr(Decl *D, const ParsedAttr &AL)
Definition SemaSYCL.cpp:215
void deepTypeCheckForDevice(SourceLocation UsedAt, llvm::DenseSet< QualType > Visited, ValueDecl *DeclToCheck)
Definition SemaSYCL.cpp:61
void handleKernelAttr(Decl *D, const ParsedAttr &AL)
Definition SemaSYCL.cpp:176
SemaSYCL(Sema &S)
Definition SemaSYCL.cpp:28
void CheckSYCLEntryPointFunctionDecl(FunctionDecl *FD)
Definition SemaSYCL.cpp:297
void CheckDeviceUseOfDecl(NamedDecl *ND, SourceLocation Loc)
Issues a deferred diagnostic if use of the declaration designated by 'ND' is invalid in a device cont...
Definition SemaSYCL.cpp:224
ExprResult BuildSYCLKernelLaunchIdExpr(FunctionDecl *FD, QualType KernelName)
Builds an expression for the lookup of a 'sycl_kernel_launch' template with 'KernelName' as an explic...
Definition SemaSYCL.cpp:427
ExprResult ActOnUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, ParsedType ParsedTy)
Definition SemaSYCL.cpp:161
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:868
Encodes a location in the source.
A container of type source information.
Definition TypeBase.h:8359
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:712
The JSON file list parser is used to communicate input to InstallAPI.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
Definition Ownership.h:230
ActionResult< Expr * > ExprResult
Definition Ownership.h:249
ActionResult< Stmt * > StmtResult
Definition Ownership.h:250