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/StringMap.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;
240 return ImplicitBindingNextOrderID++;
253 llvm::DenseMap<
const HLSLAttributedResourceType *,
255 LocsForHLSLAttributedResources;
264 llvm::DenseMap<const VarDecl *, const DeclBindingInfo *> Assigns;
270 uint32_t ImplicitBindingNextOrderID = 0;
274 bool HasDeclaredAPushConstant =
false;
277 struct SemanticInfo {
278 HLSLParsedSemanticAttr *Semantic;
279 std::optional<uint32_t> Index = std::nullopt;
284 struct SemanticContext {
287 std::optional<bool> UsesExplicitVkLocations = std::nullopt;
290 llvm::StringMap<SourceLocation> ActiveSemantics = {};
292 llvm::hlsl::IOType CurrentIOType;
297 checkInterpolationModifiers(
const DeclaratorDecl *D,
298 const HLSLInterpolationModifierAttr *Inherited,
299 const HLSLParsedSemanticAttr *Semantic);
301 void collectResourceBindingsOnVarDecl(VarDecl *D);
302 void collectResourceBindingsOnUserRecordDecl(
const VarDecl *VD,
303 const RecordType *RT);
305 void checkSemanticAnnotation(FunctionDecl *EntryPoint,
const Decl *Param,
306 const HLSLAppliedSemanticAttr *SemanticAttr,
307 const SemanticContext &SC,
308 unsigned ElementCount);
310 bool determineActiveSemanticOnScalar(FunctionDecl *FD,
311 DeclaratorDecl *OutputDecl,
313 SemanticInfo &ActiveSemantic,
314 SemanticContext &SC);
316 bool determineActiveSemantic(FunctionDecl *FD, DeclaratorDecl *OutputDecl,
317 DeclaratorDecl *D, SemanticInfo &ActiveSemantic,
318 SemanticContext &SC);
320 void processExplicitBindingsOnDecl(VarDecl *D);
322 void diagnoseAvailabilityViolations(TranslationUnitDecl *TU);
324 void diagnoseAttrStageMismatch(
325 const Attr *A, llvm::Triple::EnvironmentType Stage,
326 std::initializer_list<llvm::Triple::EnvironmentType> AllowedStages);
329 diagnoseSemanticStageMismatch(
const Attr *A,
330 llvm::Triple::EnvironmentType Stage,
331 llvm::hlsl::IOType CurrentIOType,
335 void diagnoseSystemSemanticIndex(
const HLSLAppliedSemanticAttr *A,
337 unsigned ElementCount);
339 void diagnoseSemanticType(
const Decl *D,
const HLSLAppliedSemanticAttr *A,
342 void handleGlobalStructOrArrayOfWithResources(VarDecl *VD);
349 std::optional<const DeclBindingInfo *> inferGlobalBinding(Expr *E);
351 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.
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.
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.
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 handleInterpolationModifierAttr(Decl *D, const ParsedAttr &AL)
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)
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 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)
QualType getInoutParameterType(QualType Ty)
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)
bool CanPerformPackedTypeCast(Expr *Src, QualType DestTy)
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_bitreverse32 uint32_t __builtin_riscv_aaddu_u32 __builtin_riscv_asubu_u32 __builtin_elementwise_add_sat __builtin_elementwise_sub_sat int32_t uint32_t uint32_t __builtin_riscv_mhacc_i32 __builtin_riscv_mhaccu_u32 __builtin_riscv_mhaccsu_i32 __builtin_riscv_mulq_i32 uint8_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