#include #include #include ">

clang: lib/Sema/SemaHLSL.cpp File Reference (original) (raw)

#include "[clang/Sema/SemaHLSL.h](SemaHLSL%5F8h%5Fsource.html)"
#include "[clang/AST/ASTConsumer.h](ASTConsumer%5F8h%5Fsource.html)"
#include "[clang/AST/ASTContext.h](ASTContext%5F8h%5Fsource.html)"
#include "[clang/AST/Attr.h](AST%5F2Attr%5F8h%5Fsource.html)"
#include "clang/AST/Attrs.inc"
#include "[clang/AST/Decl.h](Decl%5F8h%5Fsource.html)"
#include "[clang/AST/DeclBase.h](DeclBase%5F8h%5Fsource.html)"
#include "[clang/AST/DeclCXX.h](DeclCXX%5F8h%5Fsource.html)"
#include "[clang/AST/DeclarationName.h](DeclarationName%5F8h%5Fsource.html)"
#include "[clang/AST/DynamicRecursiveASTVisitor.h](DynamicRecursiveASTVisitor%5F8h%5Fsource.html)"
#include "[clang/AST/Expr.h](Expr%5F8h%5Fsource.html)"
#include "[clang/AST/HLSLResource.h](HLSLResource%5F8h%5Fsource.html)"
#include "[clang/AST/Type.h](Type%5F8h%5Fsource.html)"
#include "[clang/AST/TypeBase.h](TypeBase%5F8h%5Fsource.html)"
#include "[clang/AST/TypeLoc.h](TypeLoc%5F8h%5Fsource.html)"
#include "[clang/Basic/Builtins.h](Builtins%5F8h%5Fsource.html)"
#include "[clang/Basic/DiagnosticSema.h](DiagnosticSema%5F8h%5Fsource.html)"
#include "[clang/Basic/IdentifierTable.h](IdentifierTable%5F8h%5Fsource.html)"
#include "[clang/Basic/LLVM.h](LLVM%5F8h%5Fsource.html)"
#include "[clang/Basic/SourceLocation.h](SourceLocation%5F8h%5Fsource.html)"
#include "[clang/Basic/Specifiers.h](Specifiers%5F8h%5Fsource.html)"
#include "[clang/Basic/TargetInfo.h](include%5F2clang%5F2Basic%5F2TargetInfo%5F8h%5Fsource.html)"
#include "[clang/Sema/Initialization.h](Initialization%5F8h%5Fsource.html)"
#include "[clang/Sema/Lookup.h](Sema%5F2Lookup%5F8h%5Fsource.html)"
#include "[clang/Sema/ParsedAttr.h](ParsedAttr%5F8h%5Fsource.html)"
#include "[clang/Sema/Sema.h](Sema%5F8h%5Fsource.html)"
#include "[clang/Sema/Template.h](Template%5F8h%5Fsource.html)"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Frontend/HLSL/HLSLBinding.h"
#include "llvm/Frontend/HLSL/RootSignatureValidations.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/DXILABI.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/TargetParser/Triple.h"
#include <cmath>
#include <cstddef>
#include <iterator>
#include <utility>

Go to the source code of this file.

Typedefs
using RegisterType = HLSLResourceBindingAttr::RegisterType
Functions
static CXXRecordDecl * createHostLayoutStruct (Sema &S, CXXRecordDecl *StructDecl)
static RegisterType getRegisterType (ResourceClass RC)
static RegisterType getRegisterType (const HLSLAttributedResourceType *ResTy)
static bool convertToRegisterType (StringRef Slot, RegisterType *RT)
static ResourceClass getResourceClass (RegisterType RT)
static Builtin::ID getSpecConstBuiltinId (const Type *Type)
static unsigned calculateLegacyCbufferFieldAlign (const ASTContext &Context, QualType T)
static unsigned calculateLegacyCbufferSize (const ASTContext &Context, QualType T)
static void validatePackoffset (Sema &S, HLSLBufferDecl *BufDecl)
static bool isZeroSizedArray (const ConstantArrayType *CAT)
static bool isResourceRecordTypeOrArrayOf (VarDecl *VD)
static const HLSLAttributedResourceType * getResourceArrayHandleType (VarDecl *VD)
static bool isInvalidConstantBufferLeafElementType (const Type *Ty)
static bool requiresImplicitBufferLayoutStructure (const CXXRecordDecl *RD)
static CXXRecordDecl * findRecordDeclInContext (IdentifierInfo *II, DeclContext *DC)
static IdentifierInfo * getHostLayoutStructName (Sema &S, NamedDecl *BaseDecl, bool MustBeUnique)
static FieldDecl * createFieldForHostLayoutStruct (Sema &S, const Type *Ty, IdentifierInfo *II, CXXRecordDecl *LayoutStruct)
void createHostLayoutStructForBuffer (Sema &S, HLSLBufferDecl *BufDecl)
static void addImplicitBindingAttrToDecl (Sema &S, Decl *D, RegisterType RT, uint32_t ImplicitBindingOrderID)
static bool isVkPipelineBuiltin (const ASTContext &AstContext, FunctionDecl *FD, HLSLAppliedSemanticAttr *Semantic, bool IsInput)
template<CastKind Kind>
static void castVector (Sema &S, ExprResult &E, QualType &Ty, unsigned Sz)
template<CastKind Kind>
static QualType castElement (Sema &S, ExprResult &E, QualType Ty)
static QualType handleFloatVectorBinOpConversion (Sema &SemaRef, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, QualType LElTy, QualType RElTy, bool IsCompAssign)
static QualType handleIntegerVectorBinOpConversion (Sema &SemaRef, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, QualType LElTy, QualType RElTy, bool IsCompAssign)
static CastKind getScalarCastKind (ASTContext &Ctx, QualType DestTy, QualType SrcTy)
static bool hasCounterHandle (const CXXRecordDecl *RD)
static bool isValidWaveSizeValue (unsigned Value)
static bool DiagnoseLocalRegisterBinding (Sema &S, SourceLocation &ArgLoc, Decl *D, RegisterType RegType, bool SpecifiedSpace)
static bool ValidateMultipleRegisterAnnotations (Sema &S, Decl *TheDecl, RegisterType regType)
static bool DiagnoseHLSLRegisterAttribute (Sema &S, SourceLocation &ArgLoc, Decl *D, RegisterType RegType, bool SpecifiedSpace)
static bool CheckAllArgsHaveSameType (Sema *S, CallExpr *TheCall)
static bool CheckArgTypeMatches (Sema *S, Expr *Arg, QualType ExpectedType)
static bool CheckAllArgTypesAreCorrect (Sema *S, CallExpr *TheCall, llvm::function_ref< bool(Sema *S, SourceLocation Loc, int ArgOrdinal, clang::QualType PassedType)> Check)
static bool CheckFloatOrHalfRepresentation (Sema *S, SourceLocation Loc, int ArgOrdinal, clang::QualType PassedType)
static bool CheckModifiableLValue (Sema *S, CallExpr *TheCall, unsigned ArgIndex)
static bool CheckNoDoubleVectors (Sema *S, SourceLocation Loc, int ArgOrdinal, clang::QualType PassedType)
static bool CheckFloatingOrIntRepresentation (Sema *S, SourceLocation Loc, int ArgOrdinal, clang::QualType PassedType)
static bool CheckUnsignedIntVecRepresentation (Sema *S, SourceLocation Loc, int ArgOrdinal, clang::QualType PassedType)
static bool CheckUnsignedIntRepresentation (Sema *S, SourceLocation Loc, int ArgOrdinal, clang::QualType PassedType)
static bool CheckExpectedBitWidth (Sema *S, CallExpr *TheCall, unsigned ArgOrdinal, unsigned Width)
static void SetElementTypeAsReturnType (Sema *S, CallExpr *TheCall, QualType ReturnType)
static bool CheckScalarOrVector (Sema *S, CallExpr *TheCall, QualType Scalar, unsigned ArgIndex)
static bool CheckAnyScalarOrVector (Sema *S, CallExpr *TheCall, unsigned ArgIndex)
static bool CheckWaveActive (Sema *S, CallExpr *TheCall)
static bool CheckBoolSelect (Sema *S, CallExpr *TheCall)
static bool CheckVectorSelect (Sema *S, CallExpr *TheCall)
static bool CheckResourceHandle (Sema *S, CallExpr *TheCall, unsigned ArgIndex, llvm::function_ref< bool(const HLSLAttributedResourceType *ResType)> Check=nullptr)
static void BuildFlattenedTypeList (QualType BaseTy, llvm::SmallVectorImpl< QualType > &List)
static bool IsDefaultBufferConstantDecl (VarDecl *VD)

RegisterType

using RegisterType = HLSLResourceBindingAttr::RegisterType

addImplicitBindingAttrToDecl()

void addImplicitBindingAttrToDecl ( Sema & S, Decl * D, RegisterType RT, uint32_t ImplicitBindingOrderID ) static

BuildFlattenedTypeList()

calculateLegacyCbufferFieldAlign()

calculateLegacyCbufferSize()

castElement()

castVector()

CheckAllArgsHaveSameType()

CheckAllArgTypesAreCorrect()

CheckAnyScalarOrVector()

CheckArgTypeMatches()

CheckBoolSelect()

CheckExpectedBitWidth()

CheckFloatingOrIntRepresentation()

CheckFloatOrHalfRepresentation()

CheckModifiableLValue()

CheckNoDoubleVectors()

CheckResourceHandle()

bool CheckResourceHandle ( Sema * S, CallExpr * TheCall, unsigned ArgIndex, llvm::function_ref< bool(const HLSLAttributedResourceType *ResType)> Check = nullptr ) static

CheckScalarOrVector()

CheckUnsignedIntRepresentation()

CheckUnsignedIntVecRepresentation()

CheckVectorSelect()

Definition at line 3045 of file SemaHLSL.cpp.

References clang::Sema::Context, clang::SemaBase::Diag(), clang::CallExpr::getArg(), clang::Type::getAs(), clang::Sema::getASTContext(), clang::CallExpr::getBeginLoc(), clang::Stmt::getBeginLoc(), clang::CallExpr::getCallee(), clang::ASTContext::getExtVectorType(), clang::CallExpr::getNumArgs(), clang::Stmt::getSourceRange(), clang::Expr::getType(), clang::ASTContext::hasSameUnqualifiedType(), clang::Type::isVectorType(), and clang::Expr::setType().

Referenced by clang::SemaHLSL::CheckBuiltinFunctionCall().

CheckWaveActive()

convertToRegisterType()

bool convertToRegisterType ( StringRef Slot, RegisterType * RT ) static

createFieldForHostLayoutStruct()

Definition at line 458 of file SemaHLSL.cpp.

References clang::AS_public, clang::Sema::Context, clang::FieldDecl::Create(), createHostLayoutStruct(), clang::Type::getAsCXXRecordDecl(), clang::Sema::getASTContext(), clang::ASTContext::getCanonicalTagType(), clang::ASTContext::getTrivialTypeSourceInfo(), clang::CanQual< T >::getTypePtr(), clang::ICIS_NoInit, isInvalidConstantBufferLeafElementType(), and requiresImplicitBufferLayoutStructure().

Referenced by createHostLayoutStruct(), and createHostLayoutStructForBuffer().

createHostLayoutStruct()

Definition at line 490 of file SemaHLSL.cpp.

References clang::Decl::addAttr(), clang::DeclContext::addDecl(), clang::AS_none, clang::CXXRecordDecl::bases_begin(), clang::CXXRecordDecl::completeDefinition(), clang::CXXRecordDecl::Create(), createFieldForHostLayoutStruct(), createHostLayoutStruct(), clang::RecordDecl::field_empty(), clang::RecordDecl::fields(), findRecordDeclInContext(), clang::Sema::getASTContext(), clang::ASTContext::getCanonicalTagType(), clang::Decl::getDeclContext(), getHostLayoutStructName(), clang::CXXRecordDecl::getNumBases(), clang::ASTContext::getTrivialTypeSourceInfo(), clang::Type::getUnqualifiedDesugaredType(), clang::TagDecl::isClass(), requiresImplicitBufferLayoutStructure(), clang::CXXRecordDecl::setBases(), clang::Decl::setImplicit(), and clang::TagDecl::startDefinition().

Referenced by createFieldForHostLayoutStruct(), and createHostLayoutStruct().

createHostLayoutStructForBuffer()

Definition at line 555 of file SemaHLSL.cpp.

References clang::Decl::addAttr(), clang::DeclContext::addDecl(), clang::HLSLBufferDecl::addLayoutStruct(), clang::HLSLBufferDecl::buffer_decls(), clang::CXXRecordDecl::completeDefinition(), clang::CXXRecordDecl::Create(), createFieldForHostLayoutStruct(), clang::QualType::getAddressSpace(), clang::ASTContext::getAddrSpaceQualType(), clang::Sema::getASTContext(), getHostLayoutStructName(), clang::NamedDecl::getIdentifier(), clang::VarDecl::getStorageClass(), clang::ValueDecl::getType(), clang::Type::getUnqualifiedDesugaredType(), clang::hlsl_constant, clang::hlsl_groupshared, clang::SC_Static, clang::Decl::setImplicit(), clang::ValueDecl::setType(), and clang::TagDecl::startDefinition().

Referenced by clang::SemaHLSL::ActOnEndOfTranslationUnit(), and clang::SemaHLSL::ActOnFinishBuffer().

DiagnoseHLSLRegisterAttribute()

DiagnoseLocalRegisterBinding()

Definition at line 2239 of file SemaHLSL.cpp.

References clang::cast(), clang::SemaBase::Diag(), clang::Type::getArrayElementTypeNoTypeQual(), clang::Sema::getASTContext(), clang::Decl::getDeclContext(), clang::Decl::getLocation(), getRegisterType(), clang::ValueDecl::getType(), clang::QualType::getTypePtr(), clang::Decl::hasAttr(), clang::isa(), clang::Type::isArithmeticType(), clang::Type::isArrayType(), clang::Type::isFloatingType(), clang::Type::isIntegralType(), clang::Type::isRecordType(), and clang::Type::isVectorType().

Referenced by DiagnoseHLSLRegisterAttribute().

findRecordDeclInContext()

getHostLayoutStructName()

getRegisterType() [1/2]

RegisterType getRegisterType ( const HLSLAttributedResourceType * ResTy) static

getRegisterType() [2/2]

getResourceArrayHandleType()

const HLSLAttributedResourceType * getResourceArrayHandleType ( VarDecl * VD) static

getResourceClass()

getScalarCastKind()

getSpecConstBuiltinId()

handleFloatVectorBinOpConversion()

handleIntegerVectorBinOpConversion()

hasCounterHandle()

IsDefaultBufferConstantDecl()

bool IsDefaultBufferConstantDecl ( VarDecl * VD) static

isInvalidConstantBufferLeafElementType()

bool isInvalidConstantBufferLeafElementType ( const Type * Ty) static

Definition at line 365 of file SemaHLSL.cpp.

References clang::cast(), clang::Type::getAsCXXRecordDecl(), clang::Type::getUnqualifiedDesugaredType(), clang::Type::isConstantArrayType(), clang::Type::isHLSLAttributedResourceType(), clang::Type::isHLSLBuiltinIntangibleType(), clang::Type::isHLSLResourceRecord(), clang::Type::isHLSLResourceRecordArray(), and isZeroSizedArray().

Referenced by createFieldForHostLayoutStruct(), IsDefaultBufferConstantDecl(), and requiresImplicitBufferLayoutStructure().

isResourceRecordTypeOrArrayOf()

bool isResourceRecordTypeOrArrayOf ( VarDecl * VD) static

isValidWaveSizeValue()

isVkPipelineBuiltin()

isZeroSizedArray()

requiresImplicitBufferLayoutStructure()

SetElementTypeAsReturnType()

ValidateMultipleRegisterAnnotations()

bool ValidateMultipleRegisterAnnotations ( Sema & S, Decl * TheDecl, RegisterType regType ) static

validatePackoffset()