xref: /freebsd/contrib/llvm-project/clang/include/clang/Sema/SemaHLSL.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1 //===----- SemaHLSL.h ----- Semantic Analysis for HLSL 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 HLSL constructs.
10 ///
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_SEMA_SEMAHLSL_H
14 #define LLVM_CLANG_SEMA_SEMAHLSL_H
15 
16 #include "clang/AST/Attr.h"
17 #include "clang/AST/Decl.h"
18 #include "clang/AST/DeclBase.h"
19 #include "clang/AST/Expr.h"
20 #include "clang/Basic/AttributeCommonInfo.h"
21 #include "clang/Basic/IdentifierTable.h"
22 #include "clang/Basic/SourceLocation.h"
23 #include "clang/Sema/Scope.h"
24 #include "clang/Sema/SemaBase.h"
25 #include <initializer_list>
26 
27 namespace clang {
28 class ParsedAttr;
29 
30 class SemaHLSL : public SemaBase {
31 public:
32   SemaHLSL(Sema &S);
33 
34   Decl *ActOnStartBuffer(Scope *BufferScope, bool CBuffer, SourceLocation KwLoc,
35                          IdentifierInfo *Ident, SourceLocation IdentLoc,
36                          SourceLocation LBrace);
37   void ActOnFinishBuffer(Decl *Dcl, SourceLocation RBrace);
38   HLSLNumThreadsAttr *mergeNumThreadsAttr(Decl *D,
39                                           const AttributeCommonInfo &AL, int X,
40                                           int Y, int Z);
41   HLSLShaderAttr *mergeShaderAttr(Decl *D, const AttributeCommonInfo &AL,
42                                   llvm::Triple::EnvironmentType ShaderType);
43   HLSLParamModifierAttr *
44   mergeParamModifierAttr(Decl *D, const AttributeCommonInfo &AL,
45                          HLSLParamModifierAttr::Spelling Spelling);
46   void ActOnTopLevelFunction(FunctionDecl *FD);
47   void CheckEntryPoint(FunctionDecl *FD);
48   void CheckSemanticAnnotation(FunctionDecl *EntryPoint, const Decl *Param,
49                                const HLSLAnnotationAttr *AnnotationAttr);
50   void DiagnoseAttrStageMismatch(
51       const Attr *A, llvm::Triple::EnvironmentType Stage,
52       std::initializer_list<llvm::Triple::EnvironmentType> AllowedStages);
53   void DiagnoseAvailabilityViolations(TranslationUnitDecl *TU);
54 
55   void handleNumThreadsAttr(Decl *D, const ParsedAttr &AL);
56   void handleSV_DispatchThreadIDAttr(Decl *D, const ParsedAttr &AL);
57   void handlePackOffsetAttr(Decl *D, const ParsedAttr &AL);
58   void handleShaderAttr(Decl *D, const ParsedAttr &AL);
59   void handleResourceClassAttr(Decl *D, const ParsedAttr &AL);
60   void handleResourceBindingAttr(Decl *D, const ParsedAttr &AL);
61   void handleParamModifierAttr(Decl *D, const ParsedAttr &AL);
62 
63   bool CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
64 };
65 
66 } // namespace clang
67 
68 #endif // LLVM_CLANG_SEMA_SEMAHLSL_H
69