30#include "llvm/ADT/SmallVector.h"
32using namespace llvm::hlsl;
40static FunctionDecl *lookupBuiltinFunction(Sema &S, StringRef Name) {
42 S.getASTContext().Idents.get(Name, tok::TokenKind::identifier);
43 DeclarationNameInfo NameInfo =
44 DeclarationNameInfo(DeclarationName(&II), SourceLocation());
48 S.LookupName(R, S.getCurScope());
51 assert(
R.isSingleResult() &&
52 "Since this is a builtin it should always resolve!");
56static QualType lookupBuiltinType(Sema &S, StringRef Name, DeclContext *DC) {
58 S.getASTContext().Idents.get(Name, tok::TokenKind::identifier);
60 S.LookupQualifiedName(
Result, DC);
61 assert(!
Result.empty() &&
"Builtin type not found");
63 S.getASTContext().getTypeDeclType(
Result.getAsSingle<TypeDecl>());
64 S.RequireCompleteType(SourceLocation(), Ty,
65 diag::err_tentative_def_incomplete_type);
69CXXConstructorDecl *lookupCopyConstructor(QualType ResTy) {
70 assert(ResTy->isRecordType() &&
"not a CXXRecord type");
71 for (
auto *CD : ResTy->getAsCXXRecordDecl()->ctors())
72 if (CD->isCopyConstructor())
78convertParamModifierToParamABI(HLSLParamModifierAttr::Spelling Modifier) {
79 assert(Modifier != HLSLParamModifierAttr::Spelling::Keyword_in &&
80 "HLSL 'in' parameters modifier cannot be converted to ParameterABI");
82 case HLSLParamModifierAttr::Spelling::Keyword_out:
84 case HLSLParamModifierAttr::Spelling::Keyword_inout:
87 llvm_unreachable(
"Invalid HLSL parameter modifier");
91QualType getInoutParameterType(ASTContext &AST, QualType Ty) {
92 assert(!Ty->isReferenceType() &&
93 "Pointer and reference types cannot be inout or out parameters");
104void addDerivativeAvailabilityAttrs(ASTContext &AST, FunctionDecl *FD) {
105 struct DerivativeShaderStage {
106 StringRef Environment;
107 VersionTuple Introduced;
109 const DerivativeShaderStage Stages[] = {
110 {
"pixel", VersionTuple(6, 0)},
111 {
"compute", VersionTuple(6, 6)},
112 {
"mesh", VersionTuple(6, 6)},
113 {
"amplification", VersionTuple(6, 6)},
116 const IdentifierInfo *Platform = &AST.
Idents.get(
"shadermodel");
117 for (
const DerivativeShaderStage &Stage : Stages)
118 FD->addAttr(AvailabilityAttr::CreateImplicit(
119 AST, Platform, Stage.Introduced, VersionTuple(),
120 VersionTuple(),
false,
"",
122 &AST.
Idents.get(Stage.Environment),
nullptr));
141 Expr *DefaultValue =
nullptr);
178 HLSLParamModifierAttr::Spelling Modifier;
180 HLSLParamModifierAttr::Spelling Modifier)
181 : NameII(NameII), Ty(Ty), Modifier(Modifier) {}
188 LocalVar(StringRef Name,
QualType Ty) : Name(Name), Ty(Ty),
Decl(
nullptr) {}
212 enum class PlaceHolder {
225 Expr *convertPlaceholder(PlaceHolder PH);
226 Expr *convertPlaceholder(LocalVar &Var);
227 Expr *convertPlaceholder(
Expr *E) {
return E; }
235 QualType ReturnTy,
bool IsConst =
false,
237 : DeclBuilder(DB), Name(Name), ReturnTy(ReturnTy), Method(
nullptr),
238 IsConst(IsConst), IsCtor(IsCtor), SC(SC) {}
241 QualType ReturnTy,
bool IsConst =
false,
251 HLSLParamModifierAttr::Spelling Modifier =
252 HLSLParamModifierAttr::Keyword_in);
255 template <
typename... Ts>
257 QualType ReturnType, Ts &&...ArgSpecs);
258 template <
typename TLHS,
typename TRHS>
261 template <
typename V,
typename S>
264 template <
typename T>
266 template <
typename T>
269 template <
typename ValueT>
272 template <
typename ResourceT,
typename ValueT>
277 template <
typename T>
280 template <
typename ResourceT,
typename ValueT>
298 void ensureCompleteDecl() {
313 assert(!
Builder.Record->isCompleteDefinition() &&
314 "record is already complete");
316 unsigned Position =
static_cast<unsigned>(
Params.size());
320 &AST.
Idents.
get(Name, tok::TokenKind::identifier),
324 if (!DefaultValue.
isNull())
325 Decl->setDefaultArgument(AST,
326 Builder.SemaRef.getTrivialTemplateArgumentLoc(
335 Expr *DefaultValue) {
336 assert(!
Builder.Record->isCompleteDefinition() &&
337 "record is already complete");
339 unsigned Position =
static_cast<unsigned>(
Params.size());
343 &AST.
Idents.
get(Name, tok::TokenKind::identifier), Ty,
346 Decl->setDefaultArgument(
347 AST,
Builder.SemaRef.getTrivialTemplateArgumentLoc(
390 "unexpected concept decl parameter count");
399 Builder.Record->getDeclContext(),
409 T->setDeclContext(DC);
411 QualType ConceptTType = Context.getTypeDeclType(ConceptTTPD);
417 QualType CSETType = Context.getTypeDeclType(
T);
425 Context,
Builder.Record->getDeclContext(), Loc, {CSETA});
465 Builder.Template->setImplicit(
true);
466 Builder.Template->setLexicalDeclContext(
Builder.Record->getDeclContext());
477Expr *BuiltinTypeMethodBuilder::convertPlaceholder(PlaceHolder PH) {
478 if (PH == PlaceHolder::Handle)
480 if (PH == PlaceHolder::CounterHandle)
482 if (PH == PlaceHolder::This)
485 if (PH == PlaceHolder::LastStmt) {
486 assert(!StmtsList.empty() &&
"no statements in the list");
487 Stmt *LastStmt = StmtsList.pop_back_val();
488 assert(
isa<ValueStmt>(LastStmt) &&
"last statement does not have a value");
503Expr *BuiltinTypeMethodBuilder::convertPlaceholder(LocalVar &Var) {
504 VarDecl *VD = Var.Decl;
505 assert(VD &&
"local variable is not declared");
507 VD->getASTContext(), NestedNameSpecifierLoc(), SourceLocation(), VD,
508 false, DeclarationNameInfo(VD->getDeclName(), SourceLocation()),
512Expr *BuiltinTypeMethodBuilder::convertPlaceholder(QualType Ty) {
513 ASTContext &AST = getASTContext();
516 return new (AST) CXXScalarValueInitExpr(
524 bool IsConst,
bool IsCtor,
526 : DeclBuilder(DB), ReturnTy(ReturnTy), Method(
nullptr), IsConst(IsConst),
527 IsCtor(IsCtor), SC(SC) {
529 assert((!NameStr.empty() || IsCtor) &&
"method needs a name");
530 assert(((IsCtor && !IsConst) || !IsCtor) &&
"constructor cannot be const");
538 AST.
Idents.
get(NameStr, tok::TokenKind::identifier);
545 HLSLParamModifierAttr::Spelling Modifier) {
546 assert(Method ==
nullptr &&
"Cannot add param, method already created");
548 getASTContext().Idents.get(Name, tok::TokenKind::identifier);
549 Params.emplace_back(II, Ty, Modifier);
553 assert(Method ==
nullptr &&
554 "Cannot add template param, method already created");
556 unsigned Position =
static_cast<unsigned>(TemplateParamDecls.size());
560 &AST.
Idents.
get(Name, tok::TokenKind::identifier),
564 TemplateParamDecls.push_back(
Decl);
569void BuiltinTypeMethodBuilder::createDecl() {
570 assert(
Method ==
nullptr &&
"Method or constructor is already created");
576 uint32_t ArgIndex = 0;
579 bool UseParamExtInfo =
false;
580 for (Param &MP : Params) {
581 if (MP.Modifier != HLSLParamModifierAttr::Keyword_in) {
582 UseParamExtInfo =
true;
584 ParamExtInfos[ArgIndex] =
585 PI.
withABI(convertParamModifierToParamABI(MP.Modifier));
586 if (!MP.Ty->isDependentType())
587 MP.Ty = getInoutParameterType(AST, MP.Ty);
589 ParamTypes.emplace_back(MP.Ty);
593 FunctionProtoType::ExtProtoInfo ExtInfo;
595 ExtInfo.ExtParameterInfos = ParamExtInfos.data();
597 ExtInfo.TypeQuals.addConst();
603 DeclarationNameInfo NameInfo = DeclarationNameInfo(Name, SourceLocation());
606 AST, DeclBuilder.Record, SourceLocation(), NameInfo, FuncTy, TSInfo,
607 ExplicitSpecifier(),
false,
true,
false,
611 AST, DeclBuilder.Record, SourceLocation(), NameInfo, FuncTy, TSInfo,
612 false,
true, ExplicitSpecifier(),
616 AST, DeclBuilder.Record, SourceLocation(), NameInfo, FuncTy, TSInfo, SC,
623 Method->getTypeSourceInfo()->getTypeLoc().getAs<FunctionProtoTypeLoc>();
624 for (
int I = 0, E = Params.size(); I != E; I++) {
625 Param &MP = Params[I];
627 AST, Method, SourceLocation(), SourceLocation(), &MP.NameII, MP.Ty,
630 if (MP.Modifier != HLSLParamModifierAttr::Keyword_in) {
632 HLSLParamModifierAttr::Create(AST, SourceRange(), MP.Modifier);
635 Parm->setScopeInfo(CurScopeDepth, I);
636 ParmDecls.push_back(Parm);
637 FnProtoLoc.setParam(I, Parm);
639 Method->setParams({ParmDecls});
643 ensureCompleteDecl();
644 FieldDecl *HandleField = DeclBuilder.getResourceHandleField();
649 ensureCompleteDecl();
650 FieldDecl *HandleField = DeclBuilder.getResourceCounterHandleField();
657 ensureCompleteDecl();
658 Expr *BaseExpr = convertPlaceholder(
Base);
666 Method->getFunctionObjectParameterType(),
true);
672 ensureCompleteDecl();
674 assert(Var.Decl ==
nullptr &&
"local variable is already declared");
679 &AST.
Idents.
get(Var.Name, tok::TokenKind::identifier), Var.Ty,
683 StmtsList.push_back(DS);
687template <
typename V,
typename S>
690 assert(ResultTy->
isVectorType() &&
"The result type must be a vector type.");
691 Expr *VecExpr = convertPlaceholder(Vec);
693 Expr *ScalarExpr = convertPlaceholder(Scalar);
697 LocalVar VecVar(
"vec_tmp", VecTy->desugar());
701 QualType EltTy = VecTy->getElementType();
702 unsigned NumElts = VecTy->getNumElements();
706 for (
unsigned I = 0; I < NumElts; ++I) {
708 convertPlaceholder(VecVar), DeclBuilder.getConstantIntExpr(I), EltTy,
711 Elts.push_back(ScalarExpr);
717 ExprResult Cast = DeclBuilder.SemaRef.BuildCStyleCastExpr(
720 assert(!Cast.isInvalid() &&
"Cast cannot fail!");
721 StmtsList.push_back(Cast.get());
731template <
typename... Ts>
734 QualType ReturnType, Ts &&...ArgSpecs) {
735 ensureCompleteDecl();
737 std::array<
Expr *,
sizeof...(ArgSpecs)> Args{
738 convertPlaceholder(std::forward<Ts>(ArgSpecs))...};
741 FunctionDecl *FD = lookupBuiltinFunction(DeclBuilder.SemaRef, BuiltinName);
749 assert(!
Call.isInvalid() &&
"Call to builtin cannot fail!");
752 if (!ReturnType.
isNull() &&
754 ExprResult CastResult = DeclBuilder.SemaRef.BuildCStyleCastExpr(
757 assert(!CastResult.isInvalid() &&
"Cast cannot fail!");
758 E = CastResult.get();
761 StmtsList.push_back(E);
765template <
typename TLHS,
typename TRHS>
767 Expr *LHSExpr = convertPlaceholder(LHS);
768 Expr *RHSExpr = convertPlaceholder(RHS);
770 getASTContext(), LHSExpr, RHSExpr, BO_Assign, LHSExpr->
getType(),
773 StmtsList.push_back(AssignStmt);
779 Expr *PtrExpr = convertPlaceholder(Ptr);
784 StmtsList.push_back(Deref);
791 ensureCompleteDecl();
793 Expr *ResourceExpr = convertPlaceholder(ResourceRecord);
799 if (ResourceTypeDecl == DeclBuilder.Record)
800 HandleField = DeclBuilder.getResourceHandleField();
803 for (
auto *
Decl : ResourceTypeDecl->lookup(&II)) {
804 if ((HandleField = dyn_cast<FieldDecl>(
Decl)))
807 assert(HandleField &&
"Resource handle field not found");
813 StmtsList.push_back(HandleExpr);
821 ensureCompleteDecl();
823 StmtsList.push_back(
Member);
828 FieldDecl *MipsField = DeclBuilder.Fields.lookup(
"mips");
833 const auto *RT = MipsTy->
castAs<RecordType>();
837 assert(MipsRecord->field_begin() != MipsRecord->field_end() &&
838 "mips_type must have at least one field");
839 assert(std::next(MipsRecord->field_begin()) == MipsRecord->field_end() &&
840 "mips_type must have exactly one field");
841 FieldDecl *MipsHandleField = *MipsRecord->field_begin();
843 FieldDecl *HandleField = DeclBuilder.getResourceHandleField();
844 Expr *ResExpr = convertPlaceholder(ResourceRecord);
852 getASTContext(), MipsHandleMemberExpr, HandleMemberExpr, BO_Assign,
856 StmtsList.push_back(AssignStmt);
859template <
typename ValueT>
862 ValueT HandleValue) {
864 DeclBuilder.getResourceHandleField());
869template <
typename ResourceT,
typename ValueT>
872 ResourceT ResourceRecord, ValueT HandleValue) {
874 DeclBuilder.getResourceCounterHandleField());
877template <
typename ResourceT,
typename ValueT>
879 ResourceT ResourceRecord, ValueT HandleValue,
FieldDecl *HandleField) {
880 ensureCompleteDecl();
882 Expr *ResourceExpr = convertPlaceholder(ResourceRecord);
885 "Getting the field from the wrong resource type.");
887 Expr *HandleValueExpr = convertPlaceholder(HandleValue);
891 getASTContext(), HandleMemberExpr, HandleValueExpr, BO_Assign,
894 StmtsList.push_back(AssignStmt);
901 ensureCompleteDecl();
903 Expr *ResourceExpr = convertPlaceholder(ResourceRecord);
905 "Getting the field from the wrong resource type.");
907 FieldDecl *HandleField = DeclBuilder.getResourceCounterHandleField();
909 StmtsList.push_back(HandleExpr);
915 ensureCompleteDecl();
917 Expr *ReturnValueExpr = convertPlaceholder(ReturnValue);
921 if (Ty->
isRecordType() && !Method->getReturnType()->isReferenceType()) {
928 assert(CD &&
"no copy constructor found");
943 assert(!DeclBuilder.Record->isCompleteDefinition() &&
944 "record is already complete");
946 ensureCompleteDecl();
948 if (!Method->hasBody()) {
950 assert((ReturnTy == AST.
VoidTy || !StmtsList.empty()) &&
951 "nothing to return from non-void method");
952 if (ReturnTy != AST.
VoidTy) {
953 if (
Expr *LastExpr = dyn_cast<Expr>(StmtsList.back())) {
955 ReturnTy.getNonReferenceType()) &&
956 "Return type of the last statement must match the return type "
959 StmtsList.pop_back();
968 Method->setLexicalDeclContext(DeclBuilder.Record);
969 Method->setAccess(Access);
970 Method->setImplicitlyInline();
971 Method->addAttr(AlwaysInlineAttr::CreateImplicit(
972 AST,
SourceRange(), AlwaysInlineAttr::CXX11_clang_always_inline));
973 Method->addAttr(ConvergentAttr::CreateImplicit(AST));
974 if (!TemplateParamDecls.empty()) {
981 TemplateParams, Method);
983 FuncTemplate->setLexicalDeclContext(DeclBuilder.Record);
984 FuncTemplate->setImplicit(
true);
985 Method->setDescribedFunctionTemplate(FuncTemplate);
986 DeclBuilder.Record->addDecl(FuncTemplate);
988 DeclBuilder.Record->addDecl(Method);
995 : SemaRef(SemaRef), Record(R) {
996 Record->startDefinition();
997 Template = Record->getDescribedClassTemplate();
1003 : SemaRef(SemaRef), HLSLNamespace(Namespace) {
1009 if (SemaRef.LookupQualifiedName(
Result, HLSLNamespace)) {
1012 if (
auto *TD = dyn_cast<ClassTemplateDecl>(
Found)) {
1013 PrevDecl = TD->getTemplatedDecl();
1016 PrevDecl = dyn_cast<CXXRecordDecl>(
Found);
1017 assert(PrevDecl &&
"Unexpected lookup result type.");
1022 Template = PrevTemplate;
1029 Record->setImplicit(
true);
1030 Record->setLexicalDeclContext(HLSLNamespace);
1031 Record->setHasExternalLexicalStorage();
1035 FinalAttr::CreateImplicit(AST,
SourceRange(), FinalAttr::Keyword_final));
1039 if (HLSLNamespace && !Template && Record->getDeclContext() == HLSLNamespace)
1040 HLSLNamespace->addDecl(Record);
1047 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1048 assert(Record->isBeingDefined() &&
1049 "Definition must be started before adding members!");
1058 Field->setAccess(Access);
1059 Field->setImplicit(
true);
1060 for (
Attr *A : Attrs) {
1065 Record->addDecl(Field);
1066 Fields[Name] = Field;
1072 bool RawBuffer,
bool HasCounter,
1074 QualType ElementTy = getHandleElementType();
1075 addHandleMember(RC, ResourceDimension::Unknown, IsROV, RawBuffer,
1076 false, ElementTy, Access);
1078 addCounterHandleMember(RC, IsROV, RawBuffer, ElementTy, Access);
1083 ResourceClass RC,
bool IsROV,
bool IsArray, ResourceDimension RD,
1085 addResourceMember(
"__handle", RC, RD, IsROV,
false,
1086 false, IsArray, getHandleElementType(),
1087 SampleCountExpr, Access);
1092 addHandleMember(ResourceClass::Sampler, ResourceDimension::Unknown,
1093 false,
false,
false,
1094 getHandleElementType());
1100 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1102 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1104 QualType ElemTy = getHandleElementType();
1114 .callBuiltin(
"__builtin_hlsl_resource_getpointer",
1116 .dereference(PH::LastStmt)
1122 assert(!
Record->isCompleteDefinition() &&
"record is already complete");
1133CXXRecordDecl *BuiltinTypeDeclBuilder::addPrivateNestedRecord(StringRef Name) {
1134 assert(!
Record->isCompleteDefinition() &&
"record is already complete");
1143 Record->addDecl(NestedRecord);
1144 return NestedRecord;
1148 ResourceClass RC, ResourceDimension RD,
bool IsROV,
bool RawBuffer,
1149 bool IsArray, QualType ElementTy, AccessSpecifier Access) {
1150 return addResourceMember(
"__handle", RC, RD, IsROV, RawBuffer,
1151 false, IsArray, ElementTy,
1156 ResourceClass RC,
bool IsROV,
bool RawBuffer, QualType ElementTy,
1158 return addResourceMember(
"__counter_handle", RC, ResourceDimension::Unknown,
1159 IsROV, RawBuffer,
true,
1165 StringRef MemberName,
ResourceClass RC, ResourceDimension RD,
bool IsROV,
1166 bool RawBuffer,
bool IsCounter,
bool IsArray, QualType ElementTy,
1168 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1170 ASTContext &AST = SemaRef.getASTContext();
1172 assert(!ElementTy.isNull() &&
1173 "The caller should always pass in the type for the handle.");
1174 TypeSourceInfo *ElementTypeInfo =
1178 QualType AttributedResTy = QualType();
1179 SmallVector<const Attr *> Attrs = {
1180 HLSLResourceClassAttr::CreateImplicit(AST, RC),
1181 IsROV ? HLSLIsROVAttr::CreateImplicit(AST) :
nullptr,
1182 RawBuffer ? HLSLRawBufferAttr::CreateImplicit(AST) :
nullptr,
1183 RD != ResourceDimension::
Unknown
1184 ? HLSLResourceDimensionAttr::CreateImplicit(AST, RD)
1187 ? HLSLContainedTypeAttr::CreateImplicit(AST, ElementTypeInfo)
1190 Attrs.push_back(HLSLIsCounterAttr::CreateImplicit(AST));
1192 Attrs.push_back(HLSLIsArrayAttr::CreateImplicit(AST));
1193 if (SampleCountExpr)
1194 Attrs.push_back(HLSLIsMultiSampledAttr::CreateImplicit(AST));
1197 AttributedResTy,
nullptr,
1207 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1209 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1210 QualType HandleType = getResourceHandleField()->getType();
1213 .callBuiltin(
"__builtin_hlsl_resource_uninitializedhandle", HandleType,
1215 .assign(PH::Handle, PH::LastStmt)
1222 addCreateFromBindingWithImplicitCounter();
1223 addCreateFromImplicitBindingWithImplicitCounter();
1225 addCreateFromBinding();
1226 addCreateFromImplicitBinding();
1243 assert(!
Record->isCompleteDefinition() &&
"record is already complete");
1245 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1249 BuiltinTypeMethodBuilder::LocalVar TmpVar(
"tmp", RecordType);
1255 .addParam(
"range", AST.
IntTy)
1258 .declareLocalVar(TmpVar)
1259 .accessHandleFieldOnResource(TmpVar)
1260 .callBuiltin(
"__builtin_hlsl_resource_handlefrombinding", HandleType,
1261 PH::LastStmt, PH::_0, PH::_1, PH::_2, PH::_3, PH::_4)
1262 .setHandleFieldOnResource(TmpVar, PH::LastStmt)
1263 .returnValue(TmpVar)
1280 assert(!
Record->isCompleteDefinition() &&
"record is already complete");
1282 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1286 BuiltinTypeMethodBuilder::LocalVar TmpVar(
"tmp", RecordType);
1292 .addParam(
"range", AST.
IntTy)
1295 .declareLocalVar(TmpVar)
1296 .accessHandleFieldOnResource(TmpVar)
1297 .callBuiltin(
"__builtin_hlsl_resource_handlefromimplicitbinding",
1298 HandleType, PH::LastStmt, PH::_0, PH::_1, PH::_2, PH::_3,
1300 .setHandleFieldOnResource(TmpVar, PH::LastStmt)
1301 .returnValue(TmpVar)
1321BuiltinTypeDeclBuilder::addCreateFromBindingWithImplicitCounter() {
1322 assert(!
Record->isCompleteDefinition() &&
"record is already complete");
1324 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1326 QualType HandleType = getResourceHandleField()->
getType();
1327 QualType CounterHandleType = getResourceCounterHandleField()->
getType();
1329 BuiltinTypeMethodBuilder::LocalVar TmpVar(
"tmp", RecordType);
1332 "__createFromBindingWithImplicitCounter",
1336 .addParam(
"range", AST.
IntTy)
1340 .declareLocalVar(TmpVar)
1341 .accessHandleFieldOnResource(TmpVar)
1342 .callBuiltin(
"__builtin_hlsl_resource_handlefrombinding", HandleType,
1343 PH::LastStmt, PH::_0, PH::_1, PH::_2, PH::_3, PH::_4)
1344 .setHandleFieldOnResource(TmpVar, PH::LastStmt)
1345 .accessHandleFieldOnResource(TmpVar)
1346 .callBuiltin(
"__builtin_hlsl_resource_counterhandlefromimplicitbinding",
1347 CounterHandleType, PH::LastStmt, PH::_5, PH::_1)
1348 .setCounterHandleFieldOnResource(TmpVar, PH::LastStmt)
1349 .returnValue(TmpVar)
1370BuiltinTypeDeclBuilder::addCreateFromImplicitBindingWithImplicitCounter() {
1371 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1373 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1374 ASTContext &AST = SemaRef.getASTContext();
1375 QualType HandleType = getResourceHandleField()->getType();
1376 QualType CounterHandleType = getResourceCounterHandleField()->getType();
1378 BuiltinTypeMethodBuilder::LocalVar TmpVar(
"tmp", RecordType);
1381 *
this,
"__createFromImplicitBindingWithImplicitCounter",
1385 .addParam(
"range", AST.
IntTy)
1389 .declareLocalVar(TmpVar)
1390 .accessHandleFieldOnResource(TmpVar)
1391 .callBuiltin(
"__builtin_hlsl_resource_handlefromimplicitbinding",
1392 HandleType, PH::LastStmt, PH::_0, PH::_1, PH::_2, PH::_3,
1394 .setHandleFieldOnResource(TmpVar, PH::LastStmt)
1395 .accessHandleFieldOnResource(TmpVar)
1396 .callBuiltin(
"__builtin_hlsl_resource_counterhandlefromimplicitbinding",
1397 CounterHandleType, PH::LastStmt, PH::_5, PH::_1)
1398 .setCounterHandleFieldOnResource(TmpVar, PH::LastStmt)
1399 .returnValue(TmpVar)
1405 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1412 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1416 MMB.
addParam(
"other", ConstRecordRefType);
1418 for (
auto *Field : Record->fields()) {
1428 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1436 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1439 MMB.
addParam(
"other", ConstRecordRefType);
1441 for (
auto *Field : Record->fields()) {
1452 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1455 uint32_t VecSize = 1;
1456 if (
Dim != ResourceDimension::Unknown)
1467 getResourceAttrs().ResourceClass !=
1468 llvm::dxil::ResourceClass::UAV,
1475 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1489CXXRecordDecl *BuiltinTypeDeclBuilder::addMipsSliceType(ResourceDimension
Dim,
1497 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1502 CXXRecordDecl *MipsSliceRecord = addPrivateNestedRecord(
"mips_slice_type");
1504 MipsSliceBuilder.addFriend(
Record)
1505 .addHandleMember(getResourceAttrs().ResourceClass,
Dim,
1506 getResourceAttrs().IsROV,
false,
1507 getResourceAttrs().IsArray, ReturnType,
1514 FieldDecl *LevelField = MipsSliceBuilder.Fields[
"__level"];
1515 assert(LevelField &&
"Could not find the level field.");
1523 .addParam(
"Coord", IndexTy)
1524 .accessFieldOnResource(PH::This, LevelField)
1525 .concat(PH::_0, PH::LastStmt, CoordLevelTy)
1526 .callBuiltin(
"__builtin_hlsl_resource_load_level", ReturnType, PH::Handle,
1530 MipsSliceBuilder.completeDefinition();
1531 return MipsSliceRecord;
1534CXXRecordDecl *BuiltinTypeDeclBuilder::addMipsType(ResourceDimension Dim,
1535 QualType ReturnType) {
1537 QualType IntTy = AST.
IntTy;
1538 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1541 CXXRecordDecl *MipsSliceRecord = addMipsSliceType(Dim, ReturnType);
1546 CXXRecordDecl *MipsRecord = addPrivateNestedRecord(
"mips_type");
1548 MipsBuilder.addFriend(
Record)
1550 getResourceAttrs().IsROV,
false,
1551 getResourceAttrs().IsArray, ReturnType,
1559 DeclarationName SubscriptName =
1563 auto FieldIt = MipsSliceRecord->field_begin();
1564 FieldDecl *MipsSliceHandleField = *FieldIt;
1566 assert(MipsSliceHandleField->getName() ==
"__handle" &&
1567 LevelField->getName() ==
"__level" &&
1568 "Could not find fields on mips_slice_type");
1571 BuiltinTypeMethodBuilder::LocalVar MipsSliceVar(
"slice", MipsSliceTy);
1574 .addParam(
"Level", IntTy)
1575 .declareLocalVar(MipsSliceVar)
1576 .accessHandleFieldOnResource(PH::This)
1577 .setFieldOnResource(MipsSliceVar, PH::LastStmt, MipsSliceHandleField)
1578 .setFieldOnResource(MipsSliceVar, PH::_0, LevelField)
1579 .returnValue(MipsSliceVar)
1582 MipsBuilder.completeDefinition();
1588 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1590 QualType ReturnType = getHandleElementType();
1604 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1607 uint32_t CoordSize = OffsetSize + (IsArray ? 2 : 1);
1611 QualType ReturnType = getHandleElementType();
1613 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1617 .addParam(
"Location", LocationTy)
1618 .callBuiltin(
"__builtin_hlsl_resource_load_level", ReturnType, PH::Handle,
1624 .addParam(
"Location", LocationTy)
1625 .addParam(
"Offset", OffsetTy)
1626 .callBuiltin(
"__builtin_hlsl_resource_load_level", ReturnType, PH::Handle,
1636 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1642 QualType ReturnType = getHandleElementType();
1644 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1648 .addParam(
"Location", LocationTy)
1649 .callBuiltin(
"__builtin_hlsl_resource_load_level", ReturnType, PH::Handle,
1659 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1663 uint32_t CoordSize = OffsetSize + (IsArray ? 1 : 0);
1667 QualType ReturnType = getHandleElementType();
1669 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1673 .addParam(
"Location", LocationTy)
1674 .addParam(
"SampleIndex", IntTy)
1675 .callBuiltin(
"__builtin_hlsl_resource_load_ms", ReturnType, PH::Handle,
1681 .addParam(
"Location", LocationTy)
1682 .addParam(
"SampleIndex", IntTy)
1683 .addParam(
"Offset", OffsetTy)
1684 .callBuiltin(
"__builtin_hlsl_resource_load_ms", ReturnType, PH::Handle,
1685 PH::_0, PH::_1, PH::_2)
1693 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1697 auto AddLoads = [&](StringRef MethodName,
QualType ReturnType,
1698 bool TransposeResult =
false) {
1721 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1725 auto AddStore = [&](StringRef MethodName,
QualType ValueType,
1726 bool TransposeArg =
false) {
1746 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1752 "__builtin_hlsl_interlocked_add");
1754 "__builtin_hlsl_interlocked_and");
1756 "__builtin_hlsl_interlocked_min");
1758 "__builtin_hlsl_interlocked_min");
1760 "__builtin_hlsl_interlocked_or");
1762 "__builtin_hlsl_interlocked_xor");
1766 bool HasInt64AtomicSupport =
1767 TT.getArch() != llvm::Triple::dxil ||
1769 if (HasInt64AtomicSupport) {
1773 "__builtin_hlsl_interlocked_add");
1776 "__builtin_hlsl_interlocked_and");
1778 "__builtin_hlsl_interlocked_min");
1781 "__builtin_hlsl_interlocked_min");
1783 "__builtin_hlsl_interlocked_or");
1786 "__builtin_hlsl_interlocked_xor");
1793BuiltinTypeDeclBuilder::addDerivativeAvailability(StringRef MethodName) {
1797 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(D))
1798 D = FTD->getTemplatedDecl();
1799 if (
auto *MD = dyn_cast<CXXMethodDecl>(D))
1800 addDerivativeAvailabilityAttrs(AST, MD);
1807 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1809 QualType ReturnType = getHandleElementType();
1811 lookupBuiltinType(SemaRef,
"SamplerState", Record->getDeclContext());
1813 uint32_t CoordSize = OffsetSize + (IsArray ? 1 : 0);
1818 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1822 .addParam(
"Sampler", SamplerStateType)
1823 .addParam(
"Location", CoordTy)
1824 .accessHandleFieldOnResource(PH::_0)
1825 .callBuiltin(
"__builtin_hlsl_resource_sample", ReturnType, PH::Handle,
1826 PH::LastStmt, PH::_1)
1827 .returnValue(PH::LastStmt)
1834 .addParam(
"Sampler", SamplerStateType)
1835 .addParam(
"Location", CoordTy)
1836 .addParam(
"Clamp", FloatTy)
1837 .accessHandleFieldOnResource(PH::_0)
1838 .callBuiltin(
"__builtin_hlsl_resource_sample", ReturnType, PH::Handle,
1839 PH::LastStmt, PH::_1, PH::_2)
1840 .returnValue(PH::LastStmt)
1844 return addDerivativeAvailability(
"Sample");
1849 .addParam(
"Sampler", SamplerStateType)
1850 .addParam(
"Location", CoordTy)
1851 .addParam(
"Offset", OffsetTy)
1852 .accessHandleFieldOnResource(PH::_0)
1853 .callBuiltin(
"__builtin_hlsl_resource_sample", ReturnType, PH::Handle,
1854 PH::LastStmt, PH::_1, PH::_2)
1855 .returnValue(PH::LastStmt)
1860 .addParam(
"Sampler", SamplerStateType)
1861 .addParam(
"Location", CoordTy)
1862 .addParam(
"Offset", OffsetTy)
1863 .addParam(
"Clamp", FloatTy)
1864 .accessHandleFieldOnResource(PH::_0)
1865 .callBuiltin(
"__builtin_hlsl_resource_sample", ReturnType, PH::Handle,
1866 PH::LastStmt, PH::_1, PH::_2, PH::_3)
1867 .returnValue(PH::LastStmt)
1871 return addDerivativeAvailability(
"Sample");
1877 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1879 QualType ReturnType = getHandleElementType();
1881 lookupBuiltinType(SemaRef,
"SamplerState", Record->getDeclContext());
1883 uint32_t CoordSize = OffsetSize + (IsArray ? 1 : 0);
1888 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1892 .addParam(
"Sampler", SamplerStateType)
1893 .addParam(
"Location", CoordTy)
1894 .addParam(
"Bias", FloatTy)
1895 .accessHandleFieldOnResource(PH::_0)
1896 .callBuiltin(
"__builtin_hlsl_resource_sample_bias", ReturnType,
1897 PH::Handle, PH::LastStmt, PH::_1, PH::_2)
1898 .returnValue(PH::LastStmt)
1905 .addParam(
"Sampler", SamplerStateType)
1906 .addParam(
"Location", CoordTy)
1907 .addParam(
"Bias", FloatTy)
1908 .addParam(
"Clamp", FloatTy)
1909 .accessHandleFieldOnResource(PH::_0)
1910 .callBuiltin(
"__builtin_hlsl_resource_sample_bias", ReturnType,
1911 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3)
1912 .returnValue(PH::LastStmt)
1916 return addDerivativeAvailability(
"SampleBias");
1921 .addParam(
"Sampler", SamplerStateType)
1922 .addParam(
"Location", CoordTy)
1923 .addParam(
"Bias", FloatTy)
1924 .addParam(
"Offset", OffsetTy)
1925 .accessHandleFieldOnResource(PH::_0)
1926 .callBuiltin(
"__builtin_hlsl_resource_sample_bias", ReturnType,
1927 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3)
1928 .returnValue(PH::LastStmt)
1934 .addParam(
"Sampler", SamplerStateType)
1935 .addParam(
"Location", CoordTy)
1936 .addParam(
"Bias", FloatTy)
1937 .addParam(
"Offset", OffsetTy)
1938 .addParam(
"Clamp", FloatTy)
1939 .accessHandleFieldOnResource(PH::_0)
1940 .callBuiltin(
"__builtin_hlsl_resource_sample_bias", ReturnType,
1941 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3, PH::_4)
1942 .returnValue(PH::LastStmt)
1946 return addDerivativeAvailability(
"SampleBias");
1952 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1954 QualType ReturnType = getHandleElementType();
1956 lookupBuiltinType(SemaRef,
"SamplerState", Record->getDeclContext());
1958 uint32_t CoordSize = OffsetSize + (IsArray ? 1 : 0);
1964 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1968 .addParam(
"Sampler", SamplerStateType)
1969 .addParam(
"Location", CoordTy)
1970 .addParam(
"DDX", OffsetFloatTy)
1971 .addParam(
"DDY", OffsetFloatTy)
1972 .accessHandleFieldOnResource(PH::_0)
1973 .callBuiltin(
"__builtin_hlsl_resource_sample_grad", ReturnType,
1974 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3)
1975 .returnValue(PH::LastStmt)
1983 .addParam(
"Sampler", SamplerStateType)
1984 .addParam(
"Location", CoordTy)
1985 .addParam(
"DDX", OffsetFloatTy)
1986 .addParam(
"DDY", OffsetFloatTy)
1987 .addParam(
"Clamp", FloatTy)
1988 .accessHandleFieldOnResource(PH::_0)
1989 .callBuiltin(
"__builtin_hlsl_resource_sample_grad", ReturnType,
1990 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3, PH::_4)
1991 .returnValue(PH::LastStmt)
1999 .addParam(
"Sampler", SamplerStateType)
2000 .addParam(
"Location", CoordTy)
2001 .addParam(
"DDX", OffsetFloatTy)
2002 .addParam(
"DDY", OffsetFloatTy)
2003 .addParam(
"Offset", OffsetTy)
2004 .accessHandleFieldOnResource(PH::_0)
2005 .callBuiltin(
"__builtin_hlsl_resource_sample_grad", ReturnType,
2006 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3, PH::_4)
2007 .returnValue(PH::LastStmt)
2013 .addParam(
"Sampler", SamplerStateType)
2014 .addParam(
"Location", CoordTy)
2015 .addParam(
"DDX", OffsetFloatTy)
2016 .addParam(
"DDY", OffsetFloatTy)
2017 .addParam(
"Offset", OffsetTy)
2018 .addParam(
"Clamp", FloatTy)
2019 .accessHandleFieldOnResource(PH::_0)
2020 .callBuiltin(
"__builtin_hlsl_resource_sample_grad", ReturnType,
2021 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3, PH::_4,
2023 .returnValue(PH::LastStmt)
2032 assert(!Record->isCompleteDefinition() &&
"record is already complete");
2034 QualType ReturnType = getHandleElementType();
2036 lookupBuiltinType(SemaRef,
"SamplerState", Record->getDeclContext());
2038 uint32_t CoordSize = OffsetSize + (IsArray ? 1 : 0);
2043 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
2047 .addParam(
"Sampler", SamplerStateType)
2048 .addParam(
"Location", CoordTy)
2049 .addParam(
"LOD", FloatTy)
2050 .accessHandleFieldOnResource(PH::_0)
2051 .callBuiltin(
"__builtin_hlsl_resource_sample_level", ReturnType,
2052 PH::Handle, PH::LastStmt, PH::_1, PH::_2)
2053 .returnValue(PH::LastStmt)
2062 .addParam(
"Sampler", SamplerStateType)
2063 .addParam(
"Location", CoordTy)
2064 .addParam(
"LOD", FloatTy)
2065 .addParam(
"Offset", OffsetTy)
2066 .accessHandleFieldOnResource(PH::_0)
2067 .callBuiltin(
"__builtin_hlsl_resource_sample_level", ReturnType,
2068 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3)
2069 .returnValue(PH::LastStmt)
2078 assert(!Record->isCompleteDefinition() &&
"record is already complete");
2081 QualType SamplerComparisonStateType = lookupBuiltinType(
2082 SemaRef,
"SamplerComparisonState", Record->getDeclContext());
2084 uint32_t CoordSize = OffsetSize + (IsArray ? 1 : 0);
2089 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
2093 .addParam(
"Sampler", SamplerComparisonStateType)
2094 .addParam(
"Location", CoordTy)
2095 .addParam(
"CompareValue", FloatTy)
2096 .accessHandleFieldOnResource(PH::_0)
2097 .callBuiltin(
"__builtin_hlsl_resource_sample_cmp", ReturnType, PH::Handle,
2098 PH::LastStmt, PH::_1, PH::_2)
2099 .returnValue(PH::LastStmt)
2107 .addParam(
"Sampler", SamplerComparisonStateType)
2108 .addParam(
"Location", CoordTy)
2109 .addParam(
"CompareValue", FloatTy)
2110 .addParam(
"Clamp", FloatTy)
2111 .accessHandleFieldOnResource(PH::_0)
2112 .callBuiltin(
"__builtin_hlsl_resource_sample_cmp", ReturnType,
2113 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3)
2114 .returnValue(PH::LastStmt)
2118 return addDerivativeAvailability(
"SampleCmp");
2124 .addParam(
"Sampler", SamplerComparisonStateType)
2125 .addParam(
"Location", CoordTy)
2126 .addParam(
"CompareValue", FloatTy)
2127 .addParam(
"Offset", OffsetTy)
2128 .accessHandleFieldOnResource(PH::_0)
2129 .callBuiltin(
"__builtin_hlsl_resource_sample_cmp", ReturnType, PH::Handle,
2130 PH::LastStmt, PH::_1, PH::_2, PH::_3)
2131 .returnValue(PH::LastStmt)
2137 .addParam(
"Sampler", SamplerComparisonStateType)
2138 .addParam(
"Location", CoordTy)
2139 .addParam(
"CompareValue", FloatTy)
2140 .addParam(
"Offset", OffsetTy)
2141 .addParam(
"Clamp", FloatTy)
2142 .accessHandleFieldOnResource(PH::_0)
2143 .callBuiltin(
"__builtin_hlsl_resource_sample_cmp", ReturnType, PH::Handle,
2144 PH::LastStmt, PH::_1, PH::_2, PH::_3, PH::_4)
2145 .returnValue(PH::LastStmt)
2149 return addDerivativeAvailability(
"SampleCmp");
2155 assert(!Record->isCompleteDefinition() &&
"record is already complete");
2158 QualType SamplerComparisonStateType = lookupBuiltinType(
2159 SemaRef,
"SamplerComparisonState", Record->getDeclContext());
2161 uint32_t CoordSize = OffsetSize + (IsArray ? 1 : 0);
2166 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
2171 .addParam(
"Sampler", SamplerComparisonStateType)
2172 .addParam(
"Location", CoordTy)
2173 .addParam(
"CompareValue", FloatTy)
2174 .accessHandleFieldOnResource(PH::_0)
2175 .callBuiltin(
"__builtin_hlsl_resource_sample_cmp_level_zero", ReturnType,
2176 PH::Handle, PH::LastStmt, PH::_1, PH::_2)
2177 .returnValue(PH::LastStmt)
2187 .addParam(
"Sampler", SamplerComparisonStateType)
2188 .addParam(
"Location", CoordTy)
2189 .addParam(
"CompareValue", FloatTy)
2190 .addParam(
"Offset", OffsetTy)
2191 .accessHandleFieldOnResource(PH::_0)
2192 .callBuiltin(
"__builtin_hlsl_resource_sample_cmp_level_zero", ReturnType,
2193 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3)
2194 .returnValue(PH::LastStmt)
2202 assert(!Record->isCompleteDefinition() &&
"record is already complete");
2203 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
2207 assert(
Dim != ResourceDimension::Unknown);
2211 QualType Params[] = {UIntTy, FloatTy};
2214 if (
Dim == ResourceDimension::Dim2D) {
2215 StringRef XYName =
"__builtin_hlsl_resource_getdimensions_xy";
2216 StringRef LevelsXYName =
2217 "__builtin_hlsl_resource_getdimensions_levels_xy";
2219 if (OutTy == FloatTy) {
2220 XYName =
"__builtin_hlsl_resource_getdimensions_xy_float";
2221 LevelsXYName =
"__builtin_hlsl_resource_getdimensions_levels_xy_float";
2226 .addParam(
"width", OutTy, HLSLParamModifierAttr::Keyword_out)
2227 .addParam(
"height", OutTy, HLSLParamModifierAttr::Keyword_out)
2228 .callBuiltin(XYName,
QualType(), PH::Handle, PH::_0, PH::_1)
2234 .addParam(
"mipLevel", UIntTy)
2235 .addParam(
"width", OutTy, HLSLParamModifierAttr::Keyword_out)
2236 .addParam(
"height", OutTy, HLSLParamModifierAttr::Keyword_out)
2237 .addParam(
"numberOfLevels", OutTy, HLSLParamModifierAttr::Keyword_out)
2238 .callBuiltin(LevelsXYName,
QualType(), PH::Handle, PH::_0, PH::_1,
2249 assert(!Record->isCompleteDefinition() &&
"record is already complete");
2253 lookupBuiltinType(SemaRef,
"SamplerState", Record->getDeclContext());
2257 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
2261 .addParam(
"Sampler", SamplerStateType)
2262 .addParam(
"Location", LocationTy)
2263 .accessHandleFieldOnResource(PH::_0)
2264 .callBuiltin(
"__builtin_hlsl_resource_calculate_lod", ReturnType,
2265 PH::Handle, PH::LastStmt, PH::_1)
2270 .addParam(
"Sampler", SamplerStateType)
2271 .addParam(
"Location", LocationTy)
2272 .accessHandleFieldOnResource(PH::_0)
2273 .callBuiltin(
"__builtin_hlsl_resource_calculate_lod_unclamped",
2274 ReturnType, PH::Handle, PH::LastStmt, PH::_1)
2278 addDerivativeAvailability(
"CalculateLevelOfDetail");
2279 return addDerivativeAvailability(
"CalculateLevelOfDetailUnclamped");
2282QualType BuiltinTypeDeclBuilder::getGatherReturnType() {
2289 T = VT->getElementType();
2291 T = DT->getElementType();
2298 assert(!Record->isCompleteDefinition() &&
"record is already complete");
2300 QualType ReturnType = getGatherReturnType();
2303 lookupBuiltinType(SemaRef,
"SamplerState", Record->getDeclContext());
2305 uint32_t CoordSize = OffsetSize + (IsArray ? 1 : 0);
2310 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
2313 struct GatherVariant {
2317 GatherVariant Variants[] = {{
"Gather", 0},
2321 {
"GatherAlpha", 3}};
2323 for (
const auto &
V : Variants) {
2326 .addParam(
"Sampler", SamplerStateType)
2327 .addParam(
"Location", CoordTy)
2328 .accessHandleFieldOnResource(PH::_0)
2329 .callBuiltin(
"__builtin_hlsl_resource_gather", ReturnType, PH::Handle,
2330 PH::LastStmt, PH::_1,
2331 getConstantUnsignedIntExpr(
V.Component))
2340 .addParam(
"Sampler", SamplerStateType)
2341 .addParam(
"Location", CoordTy)
2342 .addParam(
"Offset", OffsetTy)
2343 .accessHandleFieldOnResource(PH::_0)
2344 .callBuiltin(
"__builtin_hlsl_resource_gather", ReturnType, PH::Handle,
2345 PH::LastStmt, PH::_1,
2346 getConstantUnsignedIntExpr(
V.Component), PH::_2)
2356 assert(!Record->isCompleteDefinition() &&
"record is already complete");
2360 QualType SamplerComparisonStateType = lookupBuiltinType(
2361 SemaRef,
"SamplerComparisonState", Record->getDeclContext());
2363 uint32_t CoordSize = OffsetSize + (IsArray ? 1 : 0);
2368 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
2372 struct GatherVariant {
2376 GatherVariant Variants[] = {{
"GatherCmp", 0},
2377 {
"GatherCmpRed", 0},
2378 {
"GatherCmpGreen", 1},
2379 {
"GatherCmpBlue", 2},
2380 {
"GatherCmpAlpha", 3}};
2382 for (
const auto &
V : Variants) {
2386 .addParam(
"Sampler", SamplerComparisonStateType)
2387 .addParam(
"Location", CoordTy)
2388 .addParam(
"CompareValue", FloatTy)
2389 .accessHandleFieldOnResource(PH::_0)
2390 .callBuiltin(
"__builtin_hlsl_resource_gather_cmp", ReturnType,
2391 PH::Handle, PH::LastStmt, PH::_1, PH::_2,
2392 getConstantUnsignedIntExpr(
V.Component))
2402 .addParam(
"Sampler", SamplerComparisonStateType)
2403 .addParam(
"Location", CoordTy)
2404 .addParam(
"CompareValue", FloatTy)
2405 .addParam(
"Offset", OffsetTy)
2406 .accessHandleFieldOnResource(PH::_0)
2407 .callBuiltin(
"__builtin_hlsl_resource_gather_cmp", ReturnType,
2408 PH::Handle, PH::LastStmt, PH::_1, PH::_2,
2409 getConstantUnsignedIntExpr(
V.Component), PH::_3)
2416FieldDecl *BuiltinTypeDeclBuilder::getResourceHandleField()
const {
2417 auto I = Fields.find(
"__handle");
2418 assert(I != Fields.end() &&
2419 I->second->getType()->isHLSLAttributedResourceType() &&
2420 "record does not have resource handle field");
2424FieldDecl *BuiltinTypeDeclBuilder::getResourceCounterHandleField()
const {
2425 auto I = Fields.find(
"__counter_handle");
2426 if (I == Fields.end() ||
2427 !I->second->getType()->isHLSLAttributedResourceType())
2432QualType BuiltinTypeDeclBuilder::getFirstTemplateTypeParam() {
2433 assert(
Template &&
"record it not a template");
2434 if (
const auto *TTD = dyn_cast<TemplateTypeParmDecl>(
2435 Template->getTemplateParameters()->getParam(0))) {
2436 return QualType(TTD->getTypeForDecl(), 0);
2441QualType BuiltinTypeDeclBuilder::getHandleElementType() {
2443 return getFirstTemplateTypeParam();
2445 if (
auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
2446 const auto &Args = Spec->getTemplateArgs();
2448 return Args[0].getAsType();
2452 return SemaRef.getASTContext().Char8Ty;
2455HLSLAttributedResourceType::Attributes
2456BuiltinTypeDeclBuilder::getResourceAttrs()
const {
2457 QualType HandleType = getResourceHandleField()->getType();
2462 assert(!Record->isCompleteDefinition() &&
"record is already complete");
2463 assert(Record->isBeingDefined() &&
2464 "Definition must be started before completing it.");
2466 Record->completeDefinition();
2467 Record->setIsHLSLBuiltinRecord(
true);
2471Expr *BuiltinTypeDeclBuilder::getConstantIntExpr(
int value) {
2478Expr *BuiltinTypeDeclBuilder::getConstantUnsignedIntExpr(
unsigned value) {
2495 if (Record->isCompleteDefinition()) {
2496 assert(Template &&
"existing record it not a template");
2497 assert(Template->getTemplateParameters()->size() == Names.size() &&
2498 "template param count mismatch");
2502 assert((DefaultTypes.empty() || DefaultTypes.size() == Names.size()) &&
2503 "template default argument count mismatch");
2506 for (
unsigned i = 0; i < Names.size(); ++i) {
2508 Builder.addTypeParameter(Names[i], DefaultTy);
2510 return Builder.finalizeTemplateArgs(CD);
2514 StringRef ElementName, StringRef SampleCountName,
ConceptDecl *CD) {
2515 if (Record->isCompleteDefinition()) {
2516 assert(Template &&
"existing record it not a template");
2517 assert(Template->getTemplateParameters()->size() == 2 &&
2518 "template param count mismatch");
2527 Builder.addTypeParameter(ElementName);
2528 Builder.addNonTypeParameter(SampleCountName, AST.
IntTy,
2529 getConstantIntExpr(0));
2530 return Builder.finalizeTemplateArgs(CD);
2534 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
2535 QualType UnsignedIntTy = SemaRef.getASTContext().UnsignedIntTy;
2537 .callBuiltin(
"__builtin_hlsl_buffer_update_counter", UnsignedIntTy,
2538 PH::CounterHandle, getConstantIntExpr(1))
2543 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
2544 QualType UnsignedIntTy = SemaRef.getASTContext().UnsignedIntTy;
2546 .callBuiltin(
"__builtin_hlsl_buffer_update_counter", UnsignedIntTy,
2547 PH::CounterHandle, getConstantIntExpr(-1))
2554 assert(!Record->isCompleteDefinition() &&
"record is already complete");
2556 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
2557 bool NeedsTypedBuiltin = !ReturnTy.
isNull();
2563 if (!NeedsTypedBuiltin)
2564 ReturnTy = getHandleElementType();
2567 MMB.ReturnTy = ReturnTy;
2571 HLSLParamModifierAttr::Keyword_out);
2573 if (NeedsTypedBuiltin)
2574 MMB.
callBuiltin(
"__builtin_hlsl_resource_load_with_status_typed", ReturnTy,
2575 PH::Handle, PH::_0, PH::_1, ReturnTy);
2577 MMB.
callBuiltin(
"__builtin_hlsl_resource_load_with_status", ReturnTy,
2578 PH::Handle, PH::_0, PH::_1);
2585 QualType ElemTy,
bool TransposeResult) {
2586 assert(!Record->isCompleteDefinition() &&
"record is already complete");
2588 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
2589 bool NeedsTypedBuiltin = !ElemTy.
isNull();
2595 if (!NeedsTypedBuiltin)
2596 ElemTy = getHandleElementType();
2605 ReturnTy = AddrSpaceElemTy;
2610 assert(!IsConstReturn &&
"There shouldn't be any resource methods with a "
2611 "const ref return value");
2614 MMB.ReturnTy = ReturnTy;
2618 if (NeedsTypedBuiltin)
2619 MMB.
callBuiltin(
"__builtin_hlsl_resource_getpointer_typed", ElemPtrTy,
2620 PH::Handle, PH::_0, ElemTy);
2622 MMB.
callBuiltin(
"__builtin_hlsl_resource_getpointer", ElemPtrTy, PH::Handle,
2626 if (TransposeResult)
2627 MMB.
callBuiltin(
"__builtin_hlsl_transpose_if_memory_is_row_major", ElemTy,
2628 PH::LastStmt, getConstantIntExpr(1));
2634 QualType ValueTy,
bool TransposeArg) {
2635 assert(!Record->isCompleteDefinition() &&
"record is already complete");
2637 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
2649 MMB.
callBuiltin(
"__builtin_hlsl_transpose_if_memory_is_row_major", ValueTy,
2650 PH::_1, getConstantIntExpr(0));
2651 MMB.
callBuiltin(
"__builtin_hlsl_resource_getpointer_typed", ElemPtrTy,
2652 PH::Handle, PH::_0, ValueTy)
2654 .
assign(PH::LastStmt, TransposeArg ? PH::LastStmt : PH::_1);
2660 StringRef MethodName,
QualType ValueTy, StringRef BuiltinName) {
2661 assert(!Record->isCompleteDefinition() &&
"record is already complete");
2663 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
2673 auto BuildOverload = [&](
bool WithOriginalValue) {
2676 if (WithOriginalValue)
2677 MMB.
addParam(
"OriginalValue", ValueTy,
2678 HLSLParamModifierAttr::Keyword_out);
2679 MMB.
callBuiltin(
"__builtin_hlsl_resource_getpointer_typed", ElemPtrTy,
2680 PH::Handle, PH::_0, ValueTy)
2682 if (WithOriginalValue)
2689 BuildOverload(
false);
2690 BuildOverload(
true);
2695 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
2697 QualType ElemTy = getHandleElementType();
2701 .addParam(
"value", ElemTy)
2702 .callBuiltin(
"__builtin_hlsl_buffer_update_counter", AST.
UnsignedIntTy,
2703 PH::CounterHandle, getConstantIntExpr(1))
2704 .callBuiltin(
"__builtin_hlsl_resource_getpointer",
2707 .dereference(PH::LastStmt)
2708 .assign(PH::LastStmt, PH::_0)
2713 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
2715 QualType ElemTy = getHandleElementType();
2719 .callBuiltin(
"__builtin_hlsl_buffer_update_counter", AST.
UnsignedIntTy,
2720 PH::CounterHandle, getConstantIntExpr(-1))
2721 .callBuiltin(
"__builtin_hlsl_resource_getpointer",
2724 .dereference(PH::LastStmt)
2730 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
2734 QualType HandleTy = getResourceHandleField()->getType();
2739 if (AttrResTy->getAttrs().RawBuffer &&
2740 AttrResTy->getContainedType() != AST.
Char8Ty) {
2742 .addParam(
"numStructs", UIntTy, HLSLParamModifierAttr::Keyword_out)
2743 .addParam(
"stride", UIntTy, HLSLParamModifierAttr::Keyword_out)
2744 .callBuiltin(
"__builtin_hlsl_resource_getdimensions_x",
QualType(),
2746 .callBuiltin(
"__builtin_hlsl_resource_getstride",
QualType(),
2754 .addParam(
"dim", UIntTy, HLSLParamModifierAttr::Keyword_out)
2755 .callBuiltin(
"__builtin_hlsl_resource_getdimensions_x",
QualType(),
Defines the clang::ASTContext interface.
llvm::dxil::ResourceClass ResourceClass
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
llvm::MachO::Record Record
This file declares semantic analysis for HLSL constructs.
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
DeclarationNameTable DeclarationNames
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType getTypeDeclType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypeDecl *Decl) const
CanQualType UnsignedIntTy
CanQualType getCanonicalTagType(const TagDecl *TD) const
Represents a member of a struct/union/class.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
DeclarationNameTable DeclarationNames
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
CanQualType UnsignedLongTy
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType getTypeDeclType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypeDecl *Decl) const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType UnsignedIntTy
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
const TargetInfo & getTargetInfo() const
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
CanQualType getCanonicalTagType(const TagDecl *TD) const
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Attr - This represents one attribute.
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
static CXXConstructExpr * Create(const ASTContext &Ctx, QualType Ty, SourceLocation Loc, CXXConstructorDecl *Ctor, bool Elidable, ArrayRef< Expr * > Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, CXXConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
Create a C++ construction expression.
Represents a C++ constructor within a class.
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, ExplicitSpecifier ES, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited=InheritedConstructor(), const AssociatedConstraint &TrailingRequiresClause={})
static CXXConversionDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline, ExplicitSpecifier ES, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, const AssociatedConstraint &TrailingRequiresClause={})
Represents a static or instance method of a struct/union/class.
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin, bool isInline, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, const AssociatedConstraint &TrailingRequiresClause={})
Represents a C++ struct/union/class.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr)
Represents the this expression in C++.
static CXXThisExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType Ty, bool IsImplicit)
QualType withConst() const
Retrieves a version of this type with const applied.
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a class template node.
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt * > Stmts, FPOptionsOverride FPFeatures, SourceLocation LB, SourceLocation RB)
Declaration of a C++20 concept.
A reference to a concept and its template args, as it appears in the code.
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, TemplateName NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
Represents the specialization of a concept - evaluates to a prvalue of type bool.
static ConceptSpecializationExpr * Create(const ASTContext &C, ConceptReference *ConceptRef, ImplicitConceptSpecializationDecl *SpecDecl, const ConstraintSatisfaction *Satisfaction)
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
A reference to a declared variable, function, enum, etc.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Decl - This represents one declaration (or definition), e.g.
void setAccess(AccessSpecifier AS)
void setImplicit(bool I=true)
void setLexicalDeclContext(DeclContext *DC)
The name of a declaration.
@ CXXConversionFunctionName
NameKind getNameKind() const
Determine what kind of name this is.
Represents an extended vector type where either the type or size is dependent.
This represents one expression.
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend, SourceLocation FriendL, SourceLocation EllipsisLoc={})
Represents a function declaration or definition.
DeclarationNameInfo getNameInfo() const
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
ExtParameterInfo withABI(ParameterABI kind) const
One of these records is kept for each identifier that is lexed.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
static ImplicitConceptSpecializationDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation SL, ArrayRef< TemplateArgument > ConvertedArgs)
Describes an C or C++ initializer list.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Represents the results of name lookup.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
static MemberExpr * CreateImplicit(const ASTContext &C, Expr *Base, bool IsArrow, ValueDecl *MemberDecl, QualType T, ExprValueKind VK, ExprObjectKind OK)
Create an implicit MemberExpr, with no location, qualifier, template arguments, and so on.
This represents a decl that may have a name.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, int D, int P, const IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
Represents a parameter to a function.
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
A (possibly-)qualified type.
QualType withConst() const
void addConst()
Add the const type qualifier to this QualType.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
static ReturnStmt * Create(const ASTContext &Ctx, SourceLocation RL, Expr *E, const VarDecl *NRVOCandidate)
Create a return statement.
unsigned getDepth() const
Returns the depth of this scope. The translation-unit has scope depth 0.
Sema - This implements semantic analysis and AST building for C.
Scope * getCurScope() const
Retrieve the parser's current scope.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
ASTContext & getASTContext() const
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
@ AP_Explicit
The availability attribute was specified explicitly next to the declaration.
Encodes a location in the source.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
VersionTuple getPlatformMinVersion() const
Retrieve the minimum desired version of the platform, to which the program should be compiled.
A convenient class for passing around template argument information.
void addArgument(const TemplateArgumentLoc &Loc)
Location wrapper for a TemplateArgument.
Represents a template argument.
@ Type
The template argument is a type.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Declaration of a template type parameter.
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, int D, int P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, UnsignedOrNone NumExpanded=std::nullopt)
A container of type source information.
The base class of the type hierarchy.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
const T * castAs() const
Member-template castAs<specific type>.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isVectorType() const
bool isRecordType() const
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
Represents a variable declaration or definition.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
Represents a GCC generic vector type.
BuiltinTypeDeclBuilder & addMSTextureTemplateParams(StringRef ElementName, StringRef SampleCountName, ConceptDecl *CD)
friend struct BuiltinTypeMethodBuilder
BuiltinTypeDeclBuilder & addRWTextureLoadMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addDefaultHandleConstructor(AccessSpecifier Access=AccessSpecifier::AS_public)
BuiltinTypeDeclBuilder(Sema &SemaRef, CXXRecordDecl *R)
BuiltinTypeDeclBuilder & addMemberVariable(StringRef Name, QualType Type, llvm::ArrayRef< Attr * > Attrs, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addConsumeMethod()
BuiltinTypeDeclBuilder & addSampleGradMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addCopyAssignmentOperator(AccessSpecifier Access=AccessSpecifier::AS_public)
~BuiltinTypeDeclBuilder()
BuiltinTypeDeclBuilder & addGatherCmpMethods(ResourceDimension Dim, bool IsArray=false)
friend struct TemplateParameterListBuilder
BuiltinTypeDeclBuilder & addStoreFunction(DeclarationName &Name, bool IsConst, QualType ValueType, bool TransposeArg=false)
BuiltinTypeDeclBuilder & addGetDimensionsMethodForBuffer()
BuiltinTypeDeclBuilder & addTextureLoadMSMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addConstantBufferConversionToType()
BuiltinTypeDeclBuilder & addSamplerHandle()
BuiltinTypeDeclBuilder & addTextureLoadMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & completeDefinition()
BuiltinTypeDeclBuilder & addByteAddressBufferInterlockedMethod(StringRef MethodName, QualType ValueTy, StringRef BuiltinName)
BuiltinTypeDeclBuilder & addSampleBiasMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addBufferHandles(ResourceClass RC, bool IsROV, bool RawBuffer, bool HasCounter, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addByteAddressBufferStoreMethods()
BuiltinTypeDeclBuilder & addSampleMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addArraySubscriptOperators(ResourceDimension Dim=ResourceDimension::Unknown, bool IsArray=false)
BuiltinTypeDeclBuilder & addSampleLevelMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addCopyConstructor(AccessSpecifier Access=AccessSpecifier::AS_public)
BuiltinTypeDeclBuilder & addAppendMethod()
BuiltinTypeDeclBuilder & addHandleAccessFunction(DeclarationName &Name, bool IsConstReturn, bool IsRef, QualType IndexTy, QualType ElemTy=QualType(), bool TransposeResult=false)
BuiltinTypeDeclBuilder & addLoadWithStatusFunction(DeclarationName &Name, QualType ReturnTy=QualType())
BuiltinTypeDeclBuilder & addIncrementCounterMethod()
BuiltinTypeDeclBuilder & addSampleCmpMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addMipsMember(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addByteAddressBufferLoadMethods()
BuiltinTypeDeclBuilder & addStaticInitializationFunctions(bool HasCounter)
BuiltinTypeDeclBuilder & addGatherMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addCalculateLodMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addGetDimensionsMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addByteAddressBufferInterlockedMethods()
BuiltinTypeDeclBuilder & addSimpleTemplateParams(ArrayRef< StringRef > Names, ConceptDecl *CD=nullptr)
BuiltinTypeDeclBuilder & addDecrementCounterMethod()
BuiltinTypeDeclBuilder & addTextureHandle(ResourceClass RC, bool IsROV, bool IsArray, ResourceDimension RD, Expr *SampleCountExpr=nullptr, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addLoadMethods()
BuiltinTypeDeclBuilder & addSampleCmpLevelZeroMethods(ResourceDimension Dim, bool IsArray=false)
uint32_t getResourceDimensions(llvm::dxil::ResourceDimension Dim)
bool hasResourceOffset(llvm::dxil::ResourceDimension Dim)
Top level wrappers for InstallAPI frontend operations.
bool isa(CodeGen::Address addr)
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
@ ICIS_NoInit
No in-class initializer.
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
@ OK_Ordinary
An ordinary object is located at an address in memory.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
StorageClass
Storage classes.
MutableArrayRef< Expr * > MultiExprArg
@ Result
The result type of a method or function.
ParameterABI
Kinds of parameter ABI.
const FunctionProtoType * T
@ Template
We are parsing a template declaration.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
bool CreateHLSLAttributedResourceType(Sema &S, QualType Wrapped, ArrayRef< const Attr * > AttrList, QualType &ResType, HLSLAttributedResourceLocInfo *LocInfo=nullptr, Expr *SampleCountExpr=nullptr)
U cast(CodeGen::Address addr)
ActionResult< Expr * > ExprResult
@ Other
Other implicit parameter.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
BuiltinTypeMethodBuilder & concat(V Vec, S Scalar, QualType ResultTy)
BuiltinTypeMethodBuilder & addParam(StringRef Name, QualType Ty, HLSLParamModifierAttr::Spelling Modifier=HLSLParamModifierAttr::Keyword_in)
BuiltinTypeMethodBuilder & accessFieldOnResource(T ResourceRecord, FieldDecl *Field)
Expr * getResourceHandleExpr()
CXXThisExpr * createThisExpr()
BuiltinTypeDeclBuilder & finalize(AccessSpecifier Access=AccessSpecifier::AS_public)
BuiltinTypeMethodBuilder & callBuiltin(StringRef BuiltinName, QualType ReturnType, Ts &&...ArgSpecs)
BuiltinTypeMethodBuilder & accessHandleFieldOnResource(T ResourceRecord)
Expr * getResourceCounterHandleExpr()
BuiltinTypeMethodBuilder & setHandleFieldOnResource(LocalVar &ResourceRecord, ValueT HandleValue)
BuiltinTypeMethodBuilder & operator=(const BuiltinTypeMethodBuilder &Other)=delete
BuiltinTypeMethodBuilder & returnThis()
BuiltinTypeMethodBuilder & dereference(T Ptr)
~BuiltinTypeMethodBuilder()
BuiltinTypeMethodBuilder & declareLocalVar(LocalVar &Var)
BuiltinTypeMethodBuilder & assign(TLHS LHS, TRHS RHS)
BuiltinTypeMethodBuilder(const BuiltinTypeMethodBuilder &Other)=delete
BuiltinTypeMethodBuilder & accessCounterHandleFieldOnResource(T ResourceRecord)
BuiltinTypeMethodBuilder & setFieldOnResource(ResourceT ResourceRecord, ValueT HandleValue, FieldDecl *HandleField)
MemberExpr * createMemberExpr(T Base, FieldDecl *Field)
BuiltinTypeMethodBuilder & setCounterHandleFieldOnResource(ResourceT ResourceRecord, ValueT HandleValue)
friend BuiltinTypeDeclBuilder
BuiltinTypeMethodBuilder & returnValue(T ReturnValue)
QualType addTemplateTypeParam(StringRef Name)
BuiltinTypeMethodBuilder(BuiltinTypeDeclBuilder &DB, DeclarationName &Name, QualType ReturnTy, bool IsConst=false, bool IsCtor=false, StorageClass SC=SC_None)
void setMipsHandleField(LocalVar &ResourceRecord)
TemplateParameterListBuilder & addNonTypeParameter(StringRef Name, QualType Ty, Expr *DefaultValue=nullptr)
TemplateParameterListBuilder & addTypeParameter(StringRef Name, QualType DefaultValue=QualType())
BuiltinTypeDeclBuilder & finalizeTemplateArgs(ConceptDecl *CD=nullptr)
llvm::SmallVector< NamedDecl * > Params
~TemplateParameterListBuilder()
TemplateParameterListBuilder(BuiltinTypeDeclBuilder &RB)
ConceptSpecializationExpr * constructConceptSpecializationExpr(Sema &S, ConceptDecl *CD)
BuiltinTypeDeclBuilder & Builder