13#ifndef LLVM_CLANG_SEMA_SEMAHLSL_H
14#define LLVM_CLANG_SEMA_SEMAHLSL_H
23#include "llvm/ADT/DenseMap.h"
24#include "llvm/ADT/SmallVector.h"
25#include "llvm/ADT/StringSet.h"
26#include "llvm/TargetParser/Triple.h"
27#include <initializer_list>
44 llvm::hlsl::rootsig::RootElement Element)
45 : Loc(Loc), Element(Element) {}
47 const llvm::hlsl::rootsig::RootElement &
getElement()
const {
return Element; }
52 llvm::hlsl::rootsig::RootElement Element;
57using llvm::dxil::ResourceClass;
63 QualType &ResType, HLSLAttributedResourceLocInfo *LocInfo =
nullptr);
72 const HLSLResourceBindingAttr *
Attr;
77 const HLSLResourceBindingAttr *
Attr =
nullptr)
82 "binding attribute already assigned");
106 llvm::DenseMap<const VarDecl *, unsigned> DeclToBindingListIndex;
121 int Min,
int Max,
int Preferred,
122 int SpelledArgsCount);
123 HLSLVkConstantIdAttr *
126 llvm::Triple::EnvironmentType ShaderType);
127 HLSLParamModifierAttr *
129 HLSLParamModifierAttr::Spelling Spelling);
147 std::pair<IdentifierInfo *, bool>
157 RootSigOverrideIdent = DeclIdent;
178 template <
typename T>
180 std::optional<unsigned> Location) {
183 Location.value_or(0));
187 std::optional<unsigned> Index);
225 llvm::DenseMap<
const HLSLAttributedResourceType *,
227 LocsForHLSLAttributedResources;
236 uint32_t ImplicitBindingNextOrderID = 0;
241 struct SemanticInfo {
242 HLSLParsedSemanticAttr *Semantic;
243 std::optional<uint32_t> Index = std::nullopt;
256 struct SemanticContext {
259 std::optional<bool> UsesExplicitVkLocations = std::nullopt;
262 llvm::StringSet<> ActiveSemantics = {};
264 IOType CurrentIOType;
267 struct SemanticStageInfo {
268 llvm::Triple::EnvironmentType Stage;
269 IOType AllowedIOTypesMask;
273 void collectResourceBindingsOnVarDecl(VarDecl *D);
274 void collectResourceBindingsOnUserRecordDecl(
const VarDecl *VD,
275 const RecordType *RT);
277 void checkSemanticAnnotation(FunctionDecl *EntryPoint,
const Decl *Param,
278 const HLSLAppliedSemanticAttr *SemanticAttr,
279 const SemanticContext &SC);
281 bool determineActiveSemanticOnScalar(FunctionDecl *FD,
282 DeclaratorDecl *OutputDecl,
284 SemanticInfo &ActiveSemantic,
285 SemanticContext &SC);
287 bool determineActiveSemantic(FunctionDecl *FD, DeclaratorDecl *OutputDecl,
288 DeclaratorDecl *D, SemanticInfo &ActiveSemantic,
289 SemanticContext &SC);
291 void processExplicitBindingsOnDecl(VarDecl *D);
293 void diagnoseAvailabilityViolations(TranslationUnitDecl *TU);
295 void diagnoseAttrStageMismatch(
296 const Attr *A, llvm::Triple::EnvironmentType Stage,
297 std::initializer_list<llvm::Triple::EnvironmentType> AllowedStages);
299 void diagnoseSemanticStageMismatch(
300 const Attr *A, llvm::Triple::EnvironmentType Stage, IOType CurrentIOType,
301 std::initializer_list<SemanticStageInfo> AllowedStages);
303 uint32_t getNextImplicitBindingOrderID() {
304 return ImplicitBindingNextOrderID++;
307 bool initGlobalResourceDecl(VarDecl *VD);
308 bool initGlobalResourceArrayDecl(VarDecl *VD);
Forward declaration of all AST node types.
llvm::dxil::ResourceClass ResourceClass
llvm::SmallVector< std::pair< const MemRegion *, SVal >, 4 > Bindings
Defines the clang::SourceLocation class and associated facilities.
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
const IdentifierInfo * getAttrName() const
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.
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)
void CheckEntryPoint(FunctionDecl *FD)
void emitLogicalOperatorFixIt(Expr *LHS, Expr *RHS, BinaryOperatorKind Opc)
T * createSemanticAttr(const AttributeCommonInfo &ACI, std::optional< unsigned > Location)
void ActOnEndOfTranslationUnit(TranslationUnitDecl *TU)
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)
bool diagnosePositionType(QualType T, const ParsedAttr &AL)
bool handleInitialization(VarDecl *VDecl, Expr *&Init)
bool diagnoseInputIDType(QualType T, const ParsedAttr &AL)
void handleParamModifierAttr(Decl *D, const ParsedAttr &AL)
bool CheckResourceBinOp(BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr, SourceLocation Loc)
bool CanPerformAggregateSplatCast(Expr *Src, QualType DestType)
bool IsScalarizedLayoutCompatible(QualType T1, QualType T2) const
void diagnoseSystemSemanticAttr(Decl *D, const ParsedAttr &AL, std::optional< unsigned > Index)
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)
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)
void ActOnTopLevelFunction(FunctionDecl *FD)
bool handleResourceTypeAttr(QualType T, const ParsedAttr &AL)
HLSLShaderAttr * mergeShaderAttr(Decl *D, const AttributeCommonInfo &AL, llvm::Triple::EnvironmentType ShaderType)
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)
Decl * ActOnStartBuffer(Scope *BufferScope, bool CBuffer, SourceLocation KwLoc, IdentifierInfo *Ident, SourceLocation IdentLoc, SourceLocation LBrace)
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 top declaration context.
Represents a variable declaration or definition.
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
bool CreateHLSLAttributedResourceType(Sema &S, QualType Wrapped, ArrayRef< const Attr * > AttrList, QualType &ResType, HLSLAttributedResourceLocInfo *LocInfo=nullptr)
ActionResult< Expr * > ExprResult
@ Implicit
An implicit conversion.
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