clang 23.0.0git
HLSLBuiltinTypeDeclBuilder.h
Go to the documentation of this file.
1//===--- HLSLBuiltinTypeDeclBuilder.h - HLSL Builtin Type Decl Builder ---===//
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//
9// Helper classes for creating HLSL builtin class types. Used by external HLSL
10// sema source.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_SEMA_HLSLBUILTINTYPEDECLBUILDER_H
15#define LLVM_CLANG_SEMA_HLSLBUILTINTYPEDECLBUILDER_H
16
17#include "clang/AST/Type.h"
18#include "clang/Sema/Sema.h"
19#include "llvm/ADT/StringMap.h"
20
21using llvm::hlsl::ResourceClass;
22using llvm::hlsl::ResourceDimension;
23
24namespace clang {
25
27class NamespaceDecl;
28class CXXRecordDecl;
29class FieldDecl;
30
31namespace hlsl {
32
33// Builder for builtin HLSL class types such as HLSL resource classes.
34// Allows creating declaration of builtin types using the builder pattern
35// like this:
36//
37// Decl = BuiltinTypeDeclBuilder(Sema, Namespace, "BuiltinClassName")
38// .addSimpleTemplateParams({"T"}, Concept)
39// .finalizeForwardDeclaration();
40//
41// And then completing the type like this:
42//
43// BuiltinTypeDeclBuilder(Sema, Decl)
44// .addDefaultHandleConstructor();
45// .addLoadMethods()
46// .completeDefinition();
47//
49private:
50 Sema &SemaRef;
51 CXXRecordDecl *Record = nullptr;
52 ClassTemplateDecl *Template = nullptr;
53 ClassTemplateDecl *PrevTemplate = nullptr;
54 NamespaceDecl *HLSLNamespace = nullptr;
55 llvm::StringMap<FieldDecl *> Fields;
56
57public:
60
62 BuiltinTypeDeclBuilder(Sema &SemaRef, NamespaceDecl *Namespace,
63 StringRef Name);
65
67 ConceptDecl *CD);
70 ArrayRef<QualType> DefaultTypes, ConceptDecl *CD);
73
77
79 addBufferHandles(ResourceClass RC, bool IsROV, bool RawBuffer,
80 bool HasCounter,
83 addTextureHandle(ResourceClass RC, bool IsROV, ResourceDimension RD,
87
88 // Builtin types constructors
92
93 // Static create methods
95
96 // Builtin types methods
100 BuiltinTypeDeclBuilder &addSampleMethods(ResourceDimension Dim);
106 BuiltinTypeDeclBuilder &addGatherMethods(ResourceDimension Dim);
111 bool IsConst, bool IsRef,
112 QualType ElemTy = QualType());
114 addLoadWithStatusFunction(DeclarationName &Name, bool IsConst,
115 QualType ReturnTy = QualType());
117 QualType ValueType);
120
122
123private:
124 BuiltinTypeDeclBuilder &addCreateFromBinding();
125 BuiltinTypeDeclBuilder &addCreateFromImplicitBinding();
126 BuiltinTypeDeclBuilder &addCreateFromBindingWithImplicitCounter();
127 BuiltinTypeDeclBuilder &addCreateFromImplicitBindingWithImplicitCounter();
128 BuiltinTypeDeclBuilder &addResourceMember(StringRef MemberName,
129 ResourceClass RC,
130 ResourceDimension RD, bool IsROV,
131 bool RawBuffer, bool IsCounter,
132 AccessSpecifier Access);
134 addHandleMember(ResourceClass RC, ResourceDimension RD, bool IsROV,
135 bool RawBuffer,
138 addCounterHandleMember(ResourceClass RC, bool IsROV, bool RawBuffer,
140 QualType getGatherReturnType();
141 FieldDecl *getResourceHandleField() const;
142 FieldDecl *getResourceCounterHandleField() const;
143 QualType getFirstTemplateTypeParam();
144 QualType getHandleElementType();
145 Expr *getConstantIntExpr(int value);
146 Expr *getConstantUnsignedIntExpr(unsigned value);
147 HLSLAttributedResourceType::Attributes getResourceAttrs() const;
148};
149
150} // namespace hlsl
151
152} // namespace clang
153
154#endif // LLVM_CLANG_SEMA_HLSLBUILTINTYPEDECLBUILDER_H
llvm::dxil::ResourceClass ResourceClass
C Language Family Type Representation.
BuiltinTypeDeclBuilder(Sema &SemaRef, CXXRecordDecl *R)
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
Declaration of a class template.
Declaration of a C++20 concept.
The name of a declaration.
This represents one expression.
Definition Expr.h:112
Represents a member of a struct/union/class.
Definition Decl.h:3160
Represent a C++ namespace.
Definition Decl.h:592
A (possibly-)qualified type.
Definition TypeBase.h:937
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:868
The base class of the type hierarchy.
Definition TypeBase.h:1839
BuiltinTypeDeclBuilder & addStoreFunction(DeclarationName &Name, bool IsConst, QualType ValueType)
BuiltinTypeDeclBuilder(Sema &SemaRef, CXXRecordDecl *R)
BuiltinTypeDeclBuilder & addSimpleTemplateParams(ArrayRef< StringRef > Names, ConceptDecl *CD)
BuiltinTypeDeclBuilder & addMemberVariable(StringRef Name, QualType Type, llvm::ArrayRef< Attr * > Attrs, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addLoadWithStatusFunction(DeclarationName &Name, bool IsConst, QualType ReturnTy=QualType())
BuiltinTypeDeclBuilder & addSampleGradMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addGetDimensionsMethodForBuffer()
BuiltinTypeDeclBuilder & addGatherCmpMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addHandleAccessFunction(DeclarationName &Name, bool IsConst, bool IsRef, QualType ElemTy=QualType())
BuiltinTypeDeclBuilder & addSampleBiasMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addBufferHandles(ResourceClass RC, bool IsROV, bool RawBuffer, bool HasCounter, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addByteAddressBufferStoreMethods()
BuiltinTypeDeclBuilder & addTextureHandle(ResourceClass RC, bool IsROV, ResourceDimension RD, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addSampleLevelMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addByteAddressBufferLoadMethods()
BuiltinTypeDeclBuilder & addSampleMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addStaticInitializationFunctions(bool HasCounter)
BuiltinTypeDeclBuilder & addSampleCmpLevelZeroMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addGatherMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addSampleCmpMethods(ResourceDimension Dim)
The JSON file list parser is used to communicate input to InstallAPI.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition Specifiers.h:123
@ AS_private
Definition Specifiers.h:126