xref: /freebsd/contrib/llvm-project/clang/include/clang/Sema/SemaSYCL.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
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/Decl.h"
17 #include "clang/AST/Type.h"
18 #include "clang/Basic/SourceLocation.h"
19 #include "clang/Sema/Ownership.h"
20 #include "clang/Sema/SemaBase.h"
21 #include "llvm/ADT/DenseSet.h"
22 
23 namespace clang {
24 class Decl;
25 class ParsedAttr;
26 
27 class SemaSYCL : public SemaBase {
28 public:
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";
49   SemaDiagnosticBuilder DiagIfDeviceCode(SourceLocation Loc, unsigned DiagID);
50 
51   void deepTypeCheckForDevice(SourceLocation UsedAt,
52                               llvm::DenseSet<QualType> Visited,
53                               ValueDecl *DeclToCheck);
54 
55   ExprResult BuildUniqueStableNameExpr(SourceLocation OpLoc,
56                                        SourceLocation LParen,
57                                        SourceLocation RParen,
58                                        TypeSourceInfo *TSI);
59   ExprResult ActOnUniqueStableNameExpr(SourceLocation OpLoc,
60                                        SourceLocation LParen,
61                                        SourceLocation RParen,
62                                        ParsedType ParsedTy);
63 
64   void handleKernelAttr(Decl *D, const ParsedAttr &AL);
65 };
66 
67 } // namespace clang
68 
69 #endif // LLVM_CLANG_SEMA_SEMASYCL_H
70