13#ifndef LLVM_CLANG_SEMA_SEMAHLSL_H
14#define LLVM_CLANG_SEMA_SEMAHLSL_H
23#include "llvm/ADT/ArrayRef.h"
24#include "llvm/ADT/DenseMap.h"
25#include "llvm/ADT/SmallVector.h"
26#include "llvm/ADT/StringSet.h"
27#include "llvm/Frontend/HLSL/SemanticSignatures.h"
28#include "llvm/TargetParser/Triple.h"
29#include <initializer_list>
46 llvm::hlsl::rootsig::RootElement Element)
47 : Loc(Loc), Element(Element) {}
49 const llvm::hlsl::rootsig::RootElement &
getElement()
const {
return Element; }
54 llvm::hlsl::rootsig::RootElement Element;
59using llvm::dxil::ResourceClass;
65 QualType &ResType, HLSLAttributedResourceLocInfo *LocInfo =
nullptr,
66 Expr *SampleCountExpr =
nullptr);
75 const HLSLResourceBindingAttr *
Attr;
80 const HLSLResourceBindingAttr *
Attr =
nullptr)
85 "binding attribute already assigned");
109 llvm::DenseMap<const VarDecl *, unsigned> DeclToBindingListIndex;
124 int Min,
int Max,
int Preferred,
125 int SpelledArgsCount);
126 HLSLVkConstantIdAttr *
129 llvm::Triple::EnvironmentType ShaderType);
130 HLSLParamModifierAttr *
132 HLSLParamModifierAttr::Spelling Spelling);
165 std::pair<IdentifierInfo *, bool>
175 RootSigOverrideIdent = DeclIdent;
202 template <
typename T>
204 std::optional<unsigned> Location) {
207 Location.value_or(0));
212 std::optional<unsigned> Index);
255 return ImplicitBindingNextOrderID++;
268 llvm::DenseMap<
const HLSLAttributedResourceType *,
270 LocsForHLSLAttributedResources;
279 llvm::DenseMap<const VarDecl *, const DeclBindingInfo *> Assigns;
285 uint32_t ImplicitBindingNextOrderID = 0;
289 bool HasDeclaredAPushConstant =
false;
292 struct SemanticInfo {
293 HLSLParsedSemanticAttr *Semantic;
294 std::optional<uint32_t> Index = std::nullopt;
299 struct SemanticContext {
302 std::optional<bool> UsesExplicitVkLocations = std::nullopt;
305 llvm::StringSet<> ActiveSemantics = {};
307 llvm::hlsl::IOType CurrentIOType;
311 void collectResourceBindingsOnVarDecl(VarDecl *D);
312 void collectResourceBindingsOnUserRecordDecl(
const VarDecl *VD,
313 const RecordType *RT);
315 void checkSemanticAnnotation(FunctionDecl *EntryPoint,
const Decl *Param,
316 const HLSLAppliedSemanticAttr *SemanticAttr,
317 const SemanticContext &SC);
319 bool determineActiveSemanticOnScalar(FunctionDecl *FD,
320 DeclaratorDecl *OutputDecl,
322 SemanticInfo &ActiveSemantic,
323 SemanticContext &SC);
325 bool determineActiveSemantic(FunctionDecl *FD, DeclaratorDecl *OutputDecl,
326 DeclaratorDecl *D, SemanticInfo &ActiveSemantic,
327 SemanticContext &SC);
329 void processExplicitBindingsOnDecl(VarDecl *D);
331 void diagnoseAvailabilityViolations(TranslationUnitDecl *TU);
333 void diagnoseAttrStageMismatch(
334 const Attr *A, llvm::Triple::EnvironmentType Stage,
335 std::initializer_list<llvm::Triple::EnvironmentType> AllowedStages);
338 diagnoseSemanticStageMismatch(
const Attr *A,
339 llvm::Triple::EnvironmentType Stage,
340 llvm::hlsl::IOType CurrentIOType,
343 void handleGlobalStructOrArrayOfWithResources(VarDecl *VD);
350 std::optional<const DeclBindingInfo *> inferGlobalBinding(Expr *E);
352 void trackLocalResource(VarDecl *VDecl, Expr *E);
Forward declaration of all AST node types.
llvm::dxil::ResourceClass ResourceClass
llvm::SmallVector< std::pair< const MemRegion *, SVal >, 4 > Bindings
llvm::dxbc::PSV::SemanticKind SemanticKind
Defines the clang::SourceLocation class and associated facilities.
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
Attr - This represents one attribute.
const IdentifierInfo * getAttrName() const
Represents a C++ struct/union/class.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
Represents a function declaration or definition.
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
Describes an C or C++ initializer list.
Describes the kind of initialization being performed, along with location information for tokens rela...
Describes an entity that is being initialized.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
This represents a decl that may have a name.
Represents a parameter to a function.
ParsedAttr - Represents a syntactic attribute.
A (possibly-)qualified type.
bool hasBindingInfoForDecl(const VarDecl *VD) const
DeclBindingInfo * getDeclBindingInfo(const VarDecl *VD, ResourceClass ResClass)
DeclBindingInfo * addDeclBindingInfo(const VarDecl *VD, ResourceClass ResClass)
Scope - A scope is a transient data structure that is used while parsing the program.
ASTContext & getASTContext() const
ExprResult ActOnOutParamExpr(ParmVarDecl *Param, Expr *Arg)
HLSLRootSignatureDecl * lookupRootSignatureOverrideDecl(DeclContext *DC) const
bool CanPerformElementwiseCast(Expr *Src, QualType DestType)
void handleWaveSizeAttr(Decl *D, const ParsedAttr &AL)
void handleVkLocationAttr(Decl *D, const ParsedAttr &AL)
HLSLAttributedResourceLocInfo TakeLocForHLSLAttribute(const HLSLAttributedResourceType *RT)
void handleSemanticAttr(Decl *D, const ParsedAttr &AL)
bool CanPerformScalarCast(QualType SrcTy, QualType DestTy)
QualType ProcessResourceTypeAttributes(QualType Wrapped)
void handleShaderAttr(Decl *D, const ParsedAttr &AL)
uint32_t getNextImplicitBindingOrderID()
void CheckEntryPoint(FunctionDecl *FD)
void handleVkExtBuiltinOutputAttr(Decl *D, const ParsedAttr &AL)
void emitLogicalOperatorFixIt(Expr *LHS, Expr *RHS, BinaryOperatorKind Opc)
void propagateContextualMatrixLayout(Expr *E, QualType DestType)
T * createSemanticAttr(const AttributeCommonInfo &ACI, std::optional< unsigned > Location)
bool initGlobalResourceDecl(VarDecl *VD)
void ActOnEndOfTranslationUnit(TranslationUnitDecl *TU)
bool initGlobalResourceArrayDecl(VarDecl *VD)
HLSLVkConstantIdAttr * mergeVkConstantIdAttr(Decl *D, const AttributeCommonInfo &AL, int Id)
HLSLNumThreadsAttr * mergeNumThreadsAttr(Decl *D, const AttributeCommonInfo &AL, int X, int Y, int Z)
void deduceAddressSpace(VarDecl *Decl)
std::pair< IdentifierInfo *, bool > ActOnStartRootSignatureDecl(StringRef Signature)
Computes the unique Root Signature identifier from the given signature, then lookup if there is a pre...
void handlePackOffsetAttr(Decl *D, const ParsedAttr &AL)
Attr * buildMatrixLayoutTypeAttr(QualType T, const ParsedAttr &AL)
bool handleInitialization(VarDecl *VDecl, Expr *&Init)
void handleParamModifierAttr(Decl *D, const ParsedAttr &AL)
bool CheckResourceBinOp(BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr, SourceLocation Loc)
bool diagnoseIndexType(QualType T, const ParsedAttr &AL)
bool CanPerformAggregateSplatCast(Expr *Src, QualType DestType)
bool ActOnResourceMemberAccessExpr(MemberExpr *ME)
bool IsScalarizedLayoutCompatible(QualType T1, QualType T2) const
QualType ActOnTemplateShorthand(TemplateDecl *Template, SourceLocation NameLoc)
void handleRootSignatureAttr(Decl *D, const ParsedAttr &AL)
bool CheckCompatibleParameterABI(FunctionDecl *New, FunctionDecl *Old)
QualType handleVectorBinOpConversion(ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
QualType checkMatrixComponent(Sema &S, QualType baseType, ExprValueKind &VK, SourceLocation OpLoc, const IdentifierInfo *CompName, SourceLocation CompLoc)
bool IsConstantBufferElementCompatible(QualType T1)
void handleResourceBindingAttr(Decl *D, const ParsedAttr &AL)
bool IsTypedResourceElementCompatible(QualType T1)
void SetRootSignatureOverride(IdentifierInfo *DeclIdent)
bool transformInitList(const InitializedEntity &Entity, InitListExpr *Init)
void handleNumThreadsAttr(Decl *D, const ParsedAttr &AL)
bool ActOnUninitializedVarDecl(VarDecl *D)
void handleVkExtBuiltinInputAttr(Decl *D, const ParsedAttr &AL)
bool canHaveOverloadedBinOp(QualType Ty, BinaryOperatorKind Opc)
void ActOnTopLevelFunction(FunctionDecl *FD)
bool handleResourceTypeAttr(QualType T, const ParsedAttr &AL)
void handleVkPushConstantAttr(Decl *D, const ParsedAttr &AL)
HLSLShaderAttr * mergeShaderAttr(Decl *D, const AttributeCommonInfo &AL, llvm::Triple::EnvironmentType ShaderType)
NamedDecl * getConstantBufferConversionFunction(QualType Type, CXXRecordDecl *RD)
void ActOnFinishBuffer(Decl *Dcl, SourceLocation RBrace)
void handleVkBindingAttr(Decl *D, const ParsedAttr &AL)
HLSLParamModifierAttr * mergeParamModifierAttr(Decl *D, const AttributeCommonInfo &AL, HLSLParamModifierAttr::Spelling Spelling)
void diagnoseSystemSemanticAttr(Decl *D, const ParsedAttr &AL, llvm::dxbc::PSV::SemanticKind SemanticKind, std::optional< unsigned > Index)
QualType getInoutParameterType(QualType Ty)
bool diagnoseFloatType(QualType T, const ParsedAttr &AL)
void handleVkConstantIdAttr(Decl *D, const ParsedAttr &AL)
std::optional< ExprResult > tryPerformConstantBufferConversion(Expr *BaseExpr)
Decl * ActOnStartBuffer(Scope *BufferScope, bool CBuffer, SourceLocation KwLoc, IdentifierInfo *Ident, SourceLocation IdentLoc, SourceLocation LBrace)
bool diagnoseMatrixLayoutInstantiation(attr::Kind K, QualType T, SourceLocation Loc)
HLSLWaveSizeAttr * mergeWaveSizeAttr(Decl *D, const AttributeCommonInfo &AL, int Min, int Max, int Preferred, int SpelledArgsCount)
bool handleRootSignatureElements(ArrayRef< hlsl::RootSignatureElement > Elements)
void ActOnFinishRootSignatureDecl(SourceLocation Loc, IdentifierInfo *DeclIdent, ArrayRef< hlsl::RootSignatureElement > Elements)
Creates the Root Signature decl of the parsed Root Signature elements onto the AST and push it onto c...
void ActOnVariableDeclarator(VarDecl *VD)
bool CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall)
Sema - This implements semantic analysis and AST building for C.
Encodes a location in the source.
The base class of all kinds of template declarations (e.g., class, function, etc.).
The top declaration context.
The base class of the type hierarchy.
Represents a variable declaration or definition.
Top level wrappers for InstallAPI frontend operations.
const FunctionProtoType * T
@ Template
We are parsing a template declaration.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
bool CreateHLSLAttributedResourceType(Sema &S, QualType Wrapped, ArrayRef< const Attr * > AttrList, QualType &ResType, HLSLAttributedResourceLocInfo *LocInfo=nullptr, Expr *SampleCountExpr=nullptr)
ActionResult< Expr * > ExprResult
@ Implicit
An implicit conversion.
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 uint8_t
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 uint32_t
const HLSLResourceBindingAttr * Attr
DeclBindingInfo(const VarDecl *Decl, ResourceClass ResClass, BindingType BindType=BindingType::NotAssigned, const HLSLResourceBindingAttr *Attr=nullptr)
void setBindingAttribute(HLSLResourceBindingAttr *A, BindingType BT)
const SourceLocation & getLocation() const
RootSignatureElement(SourceLocation Loc, llvm::hlsl::rootsig::RootElement Element)
const llvm::hlsl::rootsig::RootElement & getElement() const