29#include "llvm/ADT/SmallVector.h"
31using namespace llvm::hlsl;
39static FunctionDecl *lookupBuiltinFunction(Sema &S, StringRef Name) {
41 S.getASTContext().Idents.get(Name, tok::TokenKind::identifier);
42 DeclarationNameInfo NameInfo =
43 DeclarationNameInfo(DeclarationName(&II), SourceLocation());
47 S.LookupName(R, S.getCurScope());
50 assert(
R.isSingleResult() &&
51 "Since this is a builtin it should always resolve!");
55static QualType lookupBuiltinType(Sema &S, StringRef Name, DeclContext *DC) {
57 S.getASTContext().Idents.get(Name, tok::TokenKind::identifier);
59 S.LookupQualifiedName(
Result, DC);
60 assert(!
Result.empty() &&
"Builtin type not found");
62 S.getASTContext().getTypeDeclType(
Result.getAsSingle<TypeDecl>());
63 S.RequireCompleteType(SourceLocation(), Ty,
64 diag::err_tentative_def_incomplete_type);
68CXXConstructorDecl *lookupCopyConstructor(QualType ResTy) {
69 assert(ResTy->isRecordType() &&
"not a CXXRecord type");
70 for (
auto *CD : ResTy->getAsCXXRecordDecl()->ctors())
71 if (CD->isCopyConstructor())
77convertParamModifierToParamABI(HLSLParamModifierAttr::Spelling Modifier) {
78 assert(Modifier != HLSLParamModifierAttr::Spelling::Keyword_in &&
79 "HLSL 'in' parameters modifier cannot be converted to ParameterABI");
81 case HLSLParamModifierAttr::Spelling::Keyword_out:
83 case HLSLParamModifierAttr::Spelling::Keyword_inout:
86 llvm_unreachable(
"Invalid HLSL parameter modifier");
90QualType getInoutParameterType(ASTContext &AST, QualType Ty) {
91 assert(!Ty->isReferenceType() &&
92 "Pointer and reference types cannot be inout or out parameters");
147 HLSLParamModifierAttr::Spelling Modifier;
149 HLSLParamModifierAttr::Spelling Modifier)
150 : NameII(NameII), Ty(Ty), Modifier(Modifier) {}
157 LocalVar(StringRef Name,
QualType Ty) : Name(Name), Ty(Ty),
Decl(
nullptr) {}
181 enum class PlaceHolder {
193 Expr *convertPlaceholder(PlaceHolder PH);
194 Expr *convertPlaceholder(LocalVar &Var);
195 Expr *convertPlaceholder(
Expr *E) {
return E; }
203 QualType ReturnTy,
bool IsConst =
false,
205 : DeclBuilder(DB), Name(Name), ReturnTy(ReturnTy), Method(
nullptr),
206 IsConst(IsConst), IsCtor(IsCtor), SC(SC) {}
209 QualType ReturnTy,
bool IsConst =
false,
219 HLSLParamModifierAttr::Spelling Modifier =
220 HLSLParamModifierAttr::Keyword_in);
223 template <
typename... Ts>
225 QualType ReturnType, Ts &&...ArgSpecs);
226 template <
typename TLHS,
typename TRHS>
230 template <
typename T>
232 template <
typename ResourceT,
typename ValueT>
235 template <
typename T>
238 template <
typename ResourceT,
typename ValueT>
252 void ensureCompleteDecl() {
257 template <
typename ResourceT,
typename ValueT>
270 assert(!
Builder.Record->isCompleteDefinition() &&
271 "record is already complete");
273 unsigned Position =
static_cast<unsigned>(
Params.size());
277 &AST.
Idents.
get(Name, tok::TokenKind::identifier),
281 if (!DefaultValue.
isNull())
282 Decl->setDefaultArgument(AST,
283 Builder.SemaRef.getTrivialTemplateArgumentLoc(
325 "unexpected concept decl parameter count");
334 Builder.Record->getDeclContext(),
344 T->setDeclContext(DC);
346 QualType ConceptTType = Context.getTypeDeclType(ConceptTTPD);
352 QualType CSETType = Context.getTypeDeclType(T);
360 Context,
Builder.Record->getDeclContext(), Loc, {CSETA});
400 Builder.Template->setImplicit(
true);
401 Builder.Template->setLexicalDeclContext(
Builder.Record->getDeclContext());
412Expr *BuiltinTypeMethodBuilder::convertPlaceholder(PlaceHolder PH) {
413 if (PH == PlaceHolder::Handle)
415 if (PH == PlaceHolder::CounterHandle)
418 if (PH == PlaceHolder::LastStmt) {
419 assert(!StmtsList.empty() &&
"no statements in the list");
420 Stmt *LastStmt = StmtsList.pop_back_val();
421 assert(
isa<ValueStmt>(LastStmt) &&
"last statement does not have a value");
437Expr *BuiltinTypeMethodBuilder::convertPlaceholder(LocalVar &Var) {
438 VarDecl *VD = Var.Decl;
439 assert(VD &&
"local variable is not declared");
441 VD->getASTContext(), NestedNameSpecifierLoc(), SourceLocation(), VD,
442 false, DeclarationNameInfo(VD->getDeclName(), SourceLocation()),
446Expr *BuiltinTypeMethodBuilder::convertPlaceholder(QualType Ty) {
447 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
450 return new (AST) CXXScalarValueInitExpr(
458 bool IsConst,
bool IsCtor,
460 : DeclBuilder(DB), ReturnTy(ReturnTy), Method(
nullptr), IsConst(IsConst),
461 IsCtor(IsCtor), SC(SC) {
463 assert((!NameStr.empty() || IsCtor) &&
"method needs a name");
464 assert(((IsCtor && !IsConst) || !IsCtor) &&
"constructor cannot be const");
472 AST.
Idents.
get(NameStr, tok::TokenKind::identifier);
479 HLSLParamModifierAttr::Spelling Modifier) {
480 assert(Method ==
nullptr &&
"Cannot add param, method already created");
481 const IdentifierInfo &II = DeclBuilder.SemaRef.getASTContext().Idents.get(
482 Name, tok::TokenKind::identifier);
483 Params.emplace_back(II, Ty, Modifier);
487 assert(Method ==
nullptr &&
488 "Cannot add template param, method already created");
489 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
490 unsigned Position =
static_cast<unsigned>(TemplateParamDecls.size());
494 &AST.
Idents.
get(Name, tok::TokenKind::identifier),
498 TemplateParamDecls.push_back(
Decl);
503void BuiltinTypeMethodBuilder::createDecl() {
504 assert(
Method ==
nullptr &&
"Method or constructor is already created");
510 uint32_t ArgIndex = 0;
513 bool UseParamExtInfo =
false;
514 for (Param &MP : Params) {
515 if (MP.Modifier != HLSLParamModifierAttr::Keyword_in) {
516 UseParamExtInfo =
true;
518 ParamExtInfos[ArgIndex] =
519 PI.
withABI(convertParamModifierToParamABI(MP.Modifier));
520 if (!MP.Ty->isDependentType())
521 MP.Ty = getInoutParameterType(AST, MP.Ty);
523 ParamTypes.emplace_back(MP.Ty);
527 FunctionProtoType::ExtProtoInfo ExtInfo;
529 ExtInfo.ExtParameterInfos = ParamExtInfos.data();
531 ExtInfo.TypeQuals.addConst();
537 DeclarationNameInfo NameInfo = DeclarationNameInfo(Name, SourceLocation());
540 AST, DeclBuilder.Record, SourceLocation(), NameInfo, FuncTy, TSInfo,
541 ExplicitSpecifier(),
false,
true,
false,
545 AST, DeclBuilder.Record, SourceLocation(), NameInfo, FuncTy, TSInfo, SC,
552 Method->getTypeSourceInfo()->getTypeLoc().getAs<FunctionProtoTypeLoc>();
553 for (
int I = 0, E = Params.size(); I != E; I++) {
554 Param &MP = Params[I];
556 AST, Method, SourceLocation(), SourceLocation(), &MP.NameII, MP.Ty,
559 if (MP.Modifier != HLSLParamModifierAttr::Keyword_in) {
561 HLSLParamModifierAttr::Create(AST, SourceRange(), MP.Modifier);
564 Parm->setScopeInfo(CurScopeDepth, I);
565 ParmDecls.push_back(Parm);
566 FnProtoLoc.setParam(I, Parm);
568 Method->setParams({ParmDecls});
572 ensureCompleteDecl();
574 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
576 AST,
SourceLocation(), Method->getFunctionObjectParameterType(),
true);
577 FieldDecl *HandleField = DeclBuilder.getResourceHandleField();
584 ensureCompleteDecl();
586 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
588 AST,
SourceLocation(), Method->getFunctionObjectParameterType(),
true);
589 FieldDecl *HandleField = DeclBuilder.getResourceCounterHandleField();
597 ensureCompleteDecl();
599 assert(Var.Decl ==
nullptr &&
"local variable is already declared");
601 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
604 &AST.
Idents.
get(Var.Name, tok::TokenKind::identifier), Var.Ty,
608 StmtsList.push_back(DS);
613 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
617 StmtsList.push_back(ThisExpr);
621template <
typename... Ts>
624 QualType ReturnType, Ts &&...ArgSpecs) {
625 ensureCompleteDecl();
627 std::array<
Expr *,
sizeof...(ArgSpecs)> Args{
628 convertPlaceholder(std::forward<Ts>(ArgSpecs))...};
630 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
631 FunctionDecl *FD = lookupBuiltinFunction(DeclBuilder.SemaRef, BuiltinName);
639 assert(!
Call.isInvalid() &&
"Call to builtin cannot fail!");
642 if (!ReturnType.
isNull() &&
644 ExprResult CastResult = DeclBuilder.SemaRef.BuildCStyleCastExpr(
647 assert(!CastResult.isInvalid() &&
"Cast cannot fail!");
648 E = CastResult.get();
651 StmtsList.push_back(E);
655template <
typename TLHS,
typename TRHS>
657 Expr *LHSExpr = convertPlaceholder(LHS);
658 Expr *RHSExpr = convertPlaceholder(RHS);
660 DeclBuilder.SemaRef.getASTContext(), LHSExpr, RHSExpr, BO_Assign,
663 StmtsList.push_back(AssignStmt);
669 Expr *PtrExpr = convertPlaceholder(Ptr);
675 StmtsList.push_back(Deref);
682 ensureCompleteDecl();
684 Expr *ResourceExpr = convertPlaceholder(ResourceRecord);
687 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
690 if (ResourceTypeDecl == DeclBuilder.Record)
691 HandleField = DeclBuilder.getResourceHandleField();
694 for (
auto *
Decl : ResourceTypeDecl->lookup(&II)) {
695 if ((HandleField = dyn_cast<FieldDecl>(
Decl)))
698 assert(HandleField &&
"Resource handle field not found");
704 StmtsList.push_back(HandleExpr);
708template <
typename ResourceT,
typename ValueT>
711 ValueT HandleValue) {
712 return setFieldOnResource(ResourceRecord, HandleValue,
713 DeclBuilder.getResourceHandleField());
716template <
typename ResourceT,
typename ValueT>
719 ResourceT ResourceRecord, ValueT HandleValue) {
720 return setFieldOnResource(ResourceRecord, HandleValue,
721 DeclBuilder.getResourceCounterHandleField());
724template <
typename ResourceT,
typename ValueT>
726 ResourceT ResourceRecord, ValueT HandleValue,
FieldDecl *HandleField) {
727 ensureCompleteDecl();
729 Expr *ResourceExpr = convertPlaceholder(ResourceRecord);
732 "Getting the field from the wrong resource type.");
734 Expr *HandleValueExpr = convertPlaceholder(HandleValue);
741 DeclBuilder.SemaRef.
getASTContext(), HandleMemberExpr, HandleValueExpr,
744 StmtsList.push_back(AssignStmt);
749BuiltinTypeMethodBuilder &
751 ensureCompleteDecl();
753 Expr *ResourceExpr = convertPlaceholder(ResourceRecord);
755 "Getting the field from the wrong resource type.");
757 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
758 FieldDecl *HandleField = DeclBuilder.getResourceCounterHandleField();
762 StmtsList.push_back(HandleExpr);
768 ensureCompleteDecl();
770 Expr *ReturnValueExpr = convertPlaceholder(ReturnValue);
771 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
781 assert(CD &&
"no copy constructor found");
795 assert(!DeclBuilder.Record->isCompleteDefinition() &&
796 "record is already complete");
798 ensureCompleteDecl();
800 if (!Method->hasBody()) {
801 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
802 assert((ReturnTy == AST.
VoidTy || !StmtsList.empty()) &&
803 "nothing to return from non-void method");
804 if (ReturnTy != AST.
VoidTy) {
805 if (
Expr *LastExpr = dyn_cast<Expr>(StmtsList.back())) {
807 ReturnTy.getNonReferenceType()) &&
808 "Return type of the last statement must match the return type "
811 StmtsList.pop_back();
820 Method->setLexicalDeclContext(DeclBuilder.Record);
822 Method->addAttr(AlwaysInlineAttr::CreateImplicit(
823 AST,
SourceRange(), AlwaysInlineAttr::CXX11_clang_always_inline));
824 if (!TemplateParamDecls.empty()) {
831 TemplateParams, Method);
833 FuncTemplate->setLexicalDeclContext(DeclBuilder.Record);
834 FuncTemplate->setImplicit(
true);
835 Method->setDescribedFunctionTemplate(FuncTemplate);
836 DeclBuilder.Record->addDecl(FuncTemplate);
838 DeclBuilder.Record->addDecl(Method);
845 : SemaRef(SemaRef), Record(R) {
846 Record->startDefinition();
847 Template = Record->getDescribedClassTemplate();
853 : SemaRef(SemaRef), HLSLNamespace(Namespace) {
859 if (SemaRef.LookupQualifiedName(
Result, HLSLNamespace)) {
862 if (
auto *TD = dyn_cast<ClassTemplateDecl>(
Found)) {
863 PrevDecl = TD->getTemplatedDecl();
866 PrevDecl = dyn_cast<CXXRecordDecl>(
Found);
867 assert(PrevDecl &&
"Unexpected lookup result type.");
872 Template = PrevTemplate;
879 Record->setImplicit(
true);
880 Record->setLexicalDeclContext(HLSLNamespace);
881 Record->setHasExternalLexicalStorage();
885 FinalAttr::CreateImplicit(AST,
SourceRange(), FinalAttr::Keyword_final));
889 if (HLSLNamespace && !Template && Record->getDeclContext() == HLSLNamespace)
890 HLSLNamespace->addDecl(Record);
897 assert(!Record->isCompleteDefinition() &&
"record is already complete");
898 assert(Record->isBeingDefined() &&
899 "Definition must be started before adding members!");
908 Field->setAccess(Access);
909 Field->setImplicit(
true);
910 for (
Attr *A : Attrs) {
915 Record->addDecl(Field);
916 Fields[Name] = Field;
922 bool RawBuffer,
bool HasCounter,
924 addHandleMember(RC, ResourceDimension::Unknown, IsROV, RawBuffer, Access);
926 addCounterHandleMember(RC, IsROV, RawBuffer, Access);
932 ResourceDimension RD,
934 addHandleMember(RC, RD, IsROV,
false, Access);
939 addHandleMember(ResourceClass::Sampler, ResourceDimension::Unknown,
945BuiltinTypeDeclBuilder::addHandleMember(ResourceClass RC, ResourceDimension RD,
946 bool IsROV,
bool RawBuffer,
948 return addResourceMember(
"__handle", RC, RD, IsROV, RawBuffer,
953 ResourceClass RC,
bool IsROV,
bool RawBuffer,
AccessSpecifier Access) {
954 return addResourceMember(
"__counter_handle", RC, ResourceDimension::Unknown,
960 StringRef MemberName,
ResourceClass RC, ResourceDimension RD,
bool IsROV,
961 bool RawBuffer,
bool IsCounter, AccessSpecifier Access) {
962 assert(!
Record->isCompleteDefinition() &&
"record is already complete");
965 TypeSourceInfo *ElementTypeInfo =
969 QualType AttributedResTy = QualType();
971 HLSLResourceClassAttr::CreateImplicit(Ctx, RC),
972 IsROV ? HLSLROVAttr::CreateImplicit(Ctx) :
nullptr,
973 RawBuffer ? HLSLRawBufferAttr::CreateImplicit(Ctx) :
nullptr,
974 RD != ResourceDimension::
Unknown
975 ? HLSLResourceDimensionAttr::CreateImplicit(Ctx, RD)
978 ? HLSLContainedTypeAttr::CreateImplicit(Ctx, ElementTypeInfo)
981 Attrs.push_back(HLSLIsCounterAttr::CreateImplicit(Ctx));
992 assert(!Record->isCompleteDefinition() &&
"record is already complete");
994 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
995 QualType HandleType = getResourceHandleField()->getType();
998 .callBuiltin(
"__builtin_hlsl_resource_uninitializedhandle", HandleType,
1000 .assign(PH::Handle, PH::LastStmt)
1007 addCreateFromBindingWithImplicitCounter();
1008 addCreateFromImplicitBindingWithImplicitCounter();
1010 addCreateFromBinding();
1011 addCreateFromImplicitBinding();
1028 assert(!
Record->isCompleteDefinition() &&
"record is already complete");
1030 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1034 BuiltinTypeMethodBuilder::LocalVar TmpVar(
"tmp", RecordType);
1040 .addParam(
"range", AST.
IntTy)
1043 .declareLocalVar(TmpVar)
1044 .accessHandleFieldOnResource(TmpVar)
1045 .callBuiltin(
"__builtin_hlsl_resource_handlefrombinding", HandleType,
1046 PH::LastStmt, PH::_0, PH::_1, PH::_2, PH::_3, PH::_4)
1047 .setHandleFieldOnResource(TmpVar, PH::LastStmt)
1048 .returnValue(TmpVar)
1065 assert(!
Record->isCompleteDefinition() &&
"record is already complete");
1067 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1071 BuiltinTypeMethodBuilder::LocalVar TmpVar(
"tmp", RecordType);
1077 .addParam(
"range", AST.
IntTy)
1080 .declareLocalVar(TmpVar)
1081 .accessHandleFieldOnResource(TmpVar)
1082 .callBuiltin(
"__builtin_hlsl_resource_handlefromimplicitbinding",
1083 HandleType, PH::LastStmt, PH::_0, PH::_1, PH::_2, PH::_3,
1085 .setHandleFieldOnResource(TmpVar, PH::LastStmt)
1086 .returnValue(TmpVar)
1106BuiltinTypeDeclBuilder::addCreateFromBindingWithImplicitCounter() {
1107 assert(!
Record->isCompleteDefinition() &&
"record is already complete");
1109 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1111 QualType HandleType = getResourceHandleField()->
getType();
1112 QualType CounterHandleType = getResourceCounterHandleField()->
getType();
1114 BuiltinTypeMethodBuilder::LocalVar TmpVar(
"tmp", RecordType);
1117 "__createFromBindingWithImplicitCounter",
1121 .addParam(
"range", AST.
IntTy)
1125 .declareLocalVar(TmpVar)
1126 .accessHandleFieldOnResource(TmpVar)
1127 .callBuiltin(
"__builtin_hlsl_resource_handlefrombinding", HandleType,
1128 PH::LastStmt, PH::_0, PH::_1, PH::_2, PH::_3, PH::_4)
1129 .setHandleFieldOnResource(TmpVar, PH::LastStmt)
1130 .accessHandleFieldOnResource(TmpVar)
1131 .callBuiltin(
"__builtin_hlsl_resource_counterhandlefromimplicitbinding",
1132 CounterHandleType, PH::LastStmt, PH::_5, PH::_1)
1133 .setCounterHandleFieldOnResource(TmpVar, PH::LastStmt)
1134 .returnValue(TmpVar)
1155BuiltinTypeDeclBuilder::addCreateFromImplicitBindingWithImplicitCounter() {
1156 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1158 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1159 ASTContext &AST = SemaRef.getASTContext();
1160 QualType HandleType = getResourceHandleField()->getType();
1161 QualType CounterHandleType = getResourceCounterHandleField()->getType();
1163 BuiltinTypeMethodBuilder::LocalVar TmpVar(
"tmp", RecordType);
1166 *
this,
"__createFromImplicitBindingWithImplicitCounter",
1170 .addParam(
"range", AST.
IntTy)
1174 .declareLocalVar(TmpVar)
1175 .accessHandleFieldOnResource(TmpVar)
1176 .callBuiltin(
"__builtin_hlsl_resource_handlefromimplicitbinding",
1177 HandleType, PH::LastStmt, PH::_0, PH::_1, PH::_2, PH::_3,
1179 .setHandleFieldOnResource(TmpVar, PH::LastStmt)
1180 .accessHandleFieldOnResource(TmpVar)
1181 .callBuiltin(
"__builtin_hlsl_resource_counterhandlefromimplicitbinding",
1182 CounterHandleType, PH::LastStmt, PH::_5, PH::_1)
1183 .setCounterHandleFieldOnResource(TmpVar, PH::LastStmt)
1184 .returnValue(TmpVar)
1189 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1196 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1200 MMB.
addParam(
"other", ConstRecordRefType)
1202 .
assign(PH::Handle, PH::LastStmt);
1204 if (getResourceCounterHandleField())
1212 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1220 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1223 MMB.
addParam(
"other", ConstRecordRefType)
1225 .
assign(PH::Handle, PH::LastStmt);
1227 if (getResourceCounterHandleField())
1236 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1239 uint32_t VecSize = 1;
1240 if (
Dim != ResourceDimension::Unknown)
1251 if (getResourceAttrs().ResourceClass == llvm::dxil::ResourceClass::UAV)
1259 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1274 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1280 QualType ReturnType = getHandleElementType();
1282 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1286 .addParam(
"Location", LocationTy)
1287 .callBuiltin(
"__builtin_hlsl_resource_load_level", ReturnType, PH::Handle,
1293 .addParam(
"Location", LocationTy)
1294 .addParam(
"Offset", OffsetTy)
1295 .callBuiltin(
"__builtin_hlsl_resource_load_level", ReturnType, PH::Handle,
1302 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1306 auto AddLoads = [&](StringRef MethodName,
QualType ReturnType) {
1325 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1329 auto AddStore = [&](StringRef MethodName,
QualType ValueType) {
1347 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1349 QualType ReturnType = getHandleElementType();
1351 lookupBuiltinType(SemaRef,
"SamplerState", Record->getDeclContext());
1357 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1361 .addParam(
"Sampler", SamplerStateType)
1362 .addParam(
"Location", Float2Ty)
1363 .accessHandleFieldOnResource(PH::_0)
1364 .callBuiltin(
"__builtin_hlsl_resource_sample", ReturnType, PH::Handle,
1365 PH::LastStmt, PH::_1)
1366 .returnValue(PH::LastStmt)
1371 .addParam(
"Sampler", SamplerStateType)
1372 .addParam(
"Location", Float2Ty)
1373 .addParam(
"Offset", Int2Ty)
1374 .accessHandleFieldOnResource(PH::_0)
1375 .callBuiltin(
"__builtin_hlsl_resource_sample", ReturnType, PH::Handle,
1376 PH::LastStmt, PH::_1, PH::_2)
1377 .returnValue(PH::LastStmt)
1382 .addParam(
"Sampler", SamplerStateType)
1383 .addParam(
"Location", Float2Ty)
1384 .addParam(
"Offset", Int2Ty)
1385 .addParam(
"Clamp", FloatTy)
1386 .accessHandleFieldOnResource(PH::_0)
1387 .callBuiltin(
"__builtin_hlsl_resource_sample", ReturnType, PH::Handle,
1388 PH::LastStmt, PH::_1, PH::_2, PH::_3)
1389 .returnValue(PH::LastStmt)
1395 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1397 QualType ReturnType = getHandleElementType();
1399 lookupBuiltinType(SemaRef,
"SamplerState", Record->getDeclContext());
1405 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1409 .addParam(
"Sampler", SamplerStateType)
1410 .addParam(
"Location", Float2Ty)
1411 .addParam(
"Bias", FloatTy)
1412 .accessHandleFieldOnResource(PH::_0)
1413 .callBuiltin(
"__builtin_hlsl_resource_sample_bias", ReturnType,
1414 PH::Handle, PH::LastStmt, PH::_1, PH::_2)
1415 .returnValue(PH::LastStmt)
1420 .addParam(
"Sampler", SamplerStateType)
1421 .addParam(
"Location", Float2Ty)
1422 .addParam(
"Bias", FloatTy)
1423 .addParam(
"Offset", Int2Ty)
1424 .accessHandleFieldOnResource(PH::_0)
1425 .callBuiltin(
"__builtin_hlsl_resource_sample_bias", ReturnType,
1426 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3)
1427 .returnValue(PH::LastStmt)
1433 .addParam(
"Sampler", SamplerStateType)
1434 .addParam(
"Location", Float2Ty)
1435 .addParam(
"Bias", FloatTy)
1436 .addParam(
"Offset", Int2Ty)
1437 .addParam(
"Clamp", FloatTy)
1438 .accessHandleFieldOnResource(PH::_0)
1439 .callBuiltin(
"__builtin_hlsl_resource_sample_bias", ReturnType,
1440 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3, PH::_4)
1441 .returnValue(PH::LastStmt)
1447 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1449 QualType ReturnType = getHandleElementType();
1451 lookupBuiltinType(SemaRef,
"SamplerState", Record->getDeclContext());
1457 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1461 .addParam(
"Sampler", SamplerStateType)
1462 .addParam(
"Location", Float2Ty)
1463 .addParam(
"DDX", Float2Ty)
1464 .addParam(
"DDY", Float2Ty)
1465 .accessHandleFieldOnResource(PH::_0)
1466 .callBuiltin(
"__builtin_hlsl_resource_sample_grad", ReturnType,
1467 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3)
1468 .returnValue(PH::LastStmt)
1474 .addParam(
"Sampler", SamplerStateType)
1475 .addParam(
"Location", Float2Ty)
1476 .addParam(
"DDX", Float2Ty)
1477 .addParam(
"DDY", Float2Ty)
1478 .addParam(
"Offset", Int2Ty)
1479 .accessHandleFieldOnResource(PH::_0)
1480 .callBuiltin(
"__builtin_hlsl_resource_sample_grad", ReturnType,
1481 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3, PH::_4)
1482 .returnValue(PH::LastStmt)
1488 .addParam(
"Sampler", SamplerStateType)
1489 .addParam(
"Location", Float2Ty)
1490 .addParam(
"DDX", Float2Ty)
1491 .addParam(
"DDY", Float2Ty)
1492 .addParam(
"Offset", Int2Ty)
1493 .addParam(
"Clamp", FloatTy)
1494 .accessHandleFieldOnResource(PH::_0)
1495 .callBuiltin(
"__builtin_hlsl_resource_sample_grad", ReturnType,
1496 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3, PH::_4,
1498 .returnValue(PH::LastStmt)
1504 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1506 QualType ReturnType = getHandleElementType();
1508 lookupBuiltinType(SemaRef,
"SamplerState", Record->getDeclContext());
1514 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1518 .addParam(
"Sampler", SamplerStateType)
1519 .addParam(
"Location", Float2Ty)
1520 .addParam(
"LOD", FloatTy)
1521 .accessHandleFieldOnResource(PH::_0)
1522 .callBuiltin(
"__builtin_hlsl_resource_sample_level", ReturnType,
1523 PH::Handle, PH::LastStmt, PH::_1, PH::_2)
1524 .returnValue(PH::LastStmt)
1529 .addParam(
"Sampler", SamplerStateType)
1530 .addParam(
"Location", Float2Ty)
1531 .addParam(
"LOD", FloatTy)
1532 .addParam(
"Offset", Int2Ty)
1533 .accessHandleFieldOnResource(PH::_0)
1534 .callBuiltin(
"__builtin_hlsl_resource_sample_level", ReturnType,
1535 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3)
1536 .returnValue(PH::LastStmt)
1542 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1545 QualType SamplerComparisonStateType = lookupBuiltinType(
1546 SemaRef,
"SamplerComparisonState", Record->getDeclContext());
1552 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1556 .addParam(
"Sampler", SamplerComparisonStateType)
1557 .addParam(
"Location", Float2Ty)
1558 .addParam(
"CompareValue", FloatTy)
1559 .accessHandleFieldOnResource(PH::_0)
1560 .callBuiltin(
"__builtin_hlsl_resource_sample_cmp", ReturnType, PH::Handle,
1561 PH::LastStmt, PH::_1, PH::_2)
1562 .returnValue(PH::LastStmt)
1568 .addParam(
"Sampler", SamplerComparisonStateType)
1569 .addParam(
"Location", Float2Ty)
1570 .addParam(
"CompareValue", FloatTy)
1571 .addParam(
"Offset", Int2Ty)
1572 .accessHandleFieldOnResource(PH::_0)
1573 .callBuiltin(
"__builtin_hlsl_resource_sample_cmp", ReturnType, PH::Handle,
1574 PH::LastStmt, PH::_1, PH::_2, PH::_3)
1575 .returnValue(PH::LastStmt)
1581 .addParam(
"Sampler", SamplerComparisonStateType)
1582 .addParam(
"Location", Float2Ty)
1583 .addParam(
"CompareValue", FloatTy)
1584 .addParam(
"Offset", Int2Ty)
1585 .addParam(
"Clamp", FloatTy)
1586 .accessHandleFieldOnResource(PH::_0)
1587 .callBuiltin(
"__builtin_hlsl_resource_sample_cmp", ReturnType, PH::Handle,
1588 PH::LastStmt, PH::_1, PH::_2, PH::_3, PH::_4)
1589 .returnValue(PH::LastStmt)
1595 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1598 QualType SamplerComparisonStateType = lookupBuiltinType(
1599 SemaRef,
"SamplerComparisonState", Record->getDeclContext());
1605 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1610 .addParam(
"Sampler", SamplerComparisonStateType)
1611 .addParam(
"Location", Float2Ty)
1612 .addParam(
"CompareValue", FloatTy)
1613 .accessHandleFieldOnResource(PH::_0)
1614 .callBuiltin(
"__builtin_hlsl_resource_sample_cmp_level_zero", ReturnType,
1615 PH::Handle, PH::LastStmt, PH::_1, PH::_2)
1616 .returnValue(PH::LastStmt)
1622 .addParam(
"Sampler", SamplerComparisonStateType)
1623 .addParam(
"Location", Float2Ty)
1624 .addParam(
"CompareValue", FloatTy)
1625 .addParam(
"Offset", Int2Ty)
1626 .accessHandleFieldOnResource(PH::_0)
1627 .callBuiltin(
"__builtin_hlsl_resource_sample_cmp_level_zero", ReturnType,
1628 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3)
1629 .returnValue(PH::LastStmt)
1633QualType BuiltinTypeDeclBuilder::getGatherReturnType() {
1635 QualType T = getHandleElementType();
1640 T = VT->getElementType();
1642 T = DT->getElementType();
1649 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1651 QualType ReturnType = getGatherReturnType();
1654 lookupBuiltinType(SemaRef,
"SamplerState", Record->getDeclContext());
1660 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1663 struct GatherVariant {
1667 GatherVariant Variants[] = {{
"Gather", 0},
1671 {
"GatherAlpha", 3}};
1673 for (
const auto &
V : Variants) {
1676 .addParam(
"Sampler", SamplerStateType)
1677 .addParam(
"Location", Float2Ty)
1678 .accessHandleFieldOnResource(PH::_0)
1679 .callBuiltin(
"__builtin_hlsl_resource_gather", ReturnType, PH::Handle,
1680 PH::LastStmt, PH::_1,
1681 getConstantUnsignedIntExpr(
V.Component))
1686 .addParam(
"Sampler", SamplerStateType)
1687 .addParam(
"Location", Float2Ty)
1688 .addParam(
"Offset", OffsetTy)
1689 .accessHandleFieldOnResource(PH::_0)
1690 .callBuiltin(
"__builtin_hlsl_resource_gather", ReturnType, PH::Handle,
1691 PH::LastStmt, PH::_1,
1692 getConstantUnsignedIntExpr(
V.Component), PH::_2)
1701 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1705 QualType SamplerComparisonStateType = lookupBuiltinType(
1706 SemaRef,
"SamplerComparisonState", Record->getDeclContext());
1712 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1716 struct GatherVariant {
1720 GatherVariant Variants[] = {{
"GatherCmp", 0},
1721 {
"GatherCmpRed", 0},
1722 {
"GatherCmpGreen", 1},
1723 {
"GatherCmpBlue", 2},
1724 {
"GatherCmpAlpha", 3}};
1726 for (
const auto &
V : Variants) {
1730 .addParam(
"Sampler", SamplerComparisonStateType)
1731 .addParam(
"Location", Float2Ty)
1732 .addParam(
"CompareValue", FloatTy)
1733 .accessHandleFieldOnResource(PH::_0)
1734 .callBuiltin(
"__builtin_hlsl_resource_gather_cmp", ReturnType,
1735 PH::Handle, PH::LastStmt, PH::_1, PH::_2,
1736 getConstantUnsignedIntExpr(
V.Component))
1742 .addParam(
"Sampler", SamplerComparisonStateType)
1743 .addParam(
"Location", Float2Ty)
1744 .addParam(
"CompareValue", FloatTy)
1745 .addParam(
"Offset", Int2Ty)
1746 .accessHandleFieldOnResource(PH::_0)
1747 .callBuiltin(
"__builtin_hlsl_resource_gather_cmp", ReturnType,
1748 PH::Handle, PH::LastStmt, PH::_1, PH::_2,
1749 getConstantUnsignedIntExpr(
V.Component), PH::_3)
1756FieldDecl *BuiltinTypeDeclBuilder::getResourceHandleField()
const {
1757 auto I = Fields.find(
"__handle");
1758 assert(I != Fields.end() &&
1759 I->second->getType()->isHLSLAttributedResourceType() &&
1760 "record does not have resource handle field");
1764FieldDecl *BuiltinTypeDeclBuilder::getResourceCounterHandleField()
const {
1765 auto I = Fields.find(
"__counter_handle");
1766 if (I == Fields.end() ||
1767 !I->second->getType()->isHLSLAttributedResourceType())
1772QualType BuiltinTypeDeclBuilder::getFirstTemplateTypeParam() {
1773 assert(
Template &&
"record it not a template");
1774 if (
const auto *TTD = dyn_cast<TemplateTypeParmDecl>(
1775 Template->getTemplateParameters()->getParam(0))) {
1776 return QualType(TTD->getTypeForDecl(), 0);
1781QualType BuiltinTypeDeclBuilder::getHandleElementType() {
1783 return getFirstTemplateTypeParam();
1785 if (
auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
1786 const auto &Args = Spec->getTemplateArgs();
1788 return Args[0].getAsType();
1792 return SemaRef.getASTContext().Char8Ty;
1795HLSLAttributedResourceType::Attributes
1796BuiltinTypeDeclBuilder::getResourceAttrs()
const {
1797 QualType HandleType = getResourceHandleField()->getType();
1802 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1803 assert(Record->isBeingDefined() &&
1804 "Definition must be started before completing it.");
1806 Record->completeDefinition();
1810Expr *BuiltinTypeDeclBuilder::getConstantIntExpr(
int value) {
1817Expr *BuiltinTypeDeclBuilder::getConstantUnsignedIntExpr(
unsigned value) {
1834 if (Record->isCompleteDefinition()) {
1835 assert(Template &&
"existing record it not a template");
1836 assert(Template->getTemplateParameters()->size() == Names.size() &&
1837 "template param count mismatch");
1841 assert((DefaultTypes.empty() || DefaultTypes.size() == Names.size()) &&
1842 "template default argument count mismatch");
1845 for (
unsigned i = 0; i < Names.size(); ++i) {
1847 Builder.addTypeParameter(Names[i], DefaultTy);
1849 return Builder.finalizeTemplateArgs(CD);
1853 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1854 QualType UnsignedIntTy = SemaRef.getASTContext().UnsignedIntTy;
1856 .callBuiltin(
"__builtin_hlsl_buffer_update_counter", UnsignedIntTy,
1857 PH::CounterHandle, getConstantIntExpr(1))
1862 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1863 QualType UnsignedIntTy = SemaRef.getASTContext().UnsignedIntTy;
1865 .callBuiltin(
"__builtin_hlsl_buffer_update_counter", UnsignedIntTy,
1866 PH::CounterHandle, getConstantIntExpr(-1))
1872 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1874 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1875 bool NeedsTypedBuiltin = !ReturnTy.
isNull();
1880 if (!NeedsTypedBuiltin)
1881 ReturnTy = getHandleElementType();
1884 MMB.ReturnTy = ReturnTy;
1888 HLSLParamModifierAttr::Keyword_out);
1890 if (NeedsTypedBuiltin)
1891 MMB.
callBuiltin(
"__builtin_hlsl_resource_load_with_status_typed", ReturnTy,
1892 PH::Handle, PH::_0, PH::_1, ReturnTy);
1894 MMB.
callBuiltin(
"__builtin_hlsl_resource_load_with_status", ReturnTy,
1895 PH::Handle, PH::_0, PH::_1);
1903 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1905 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1906 bool NeedsTypedBuiltin = !ElemTy.
isNull();
1911 if (!NeedsTypedBuiltin)
1912 ElemTy = getHandleElementType();
1921 ReturnTy = AddrSpaceElemTy;
1930 MMB.ReturnTy = ReturnTy;
1934 if (NeedsTypedBuiltin)
1935 MMB.
callBuiltin(
"__builtin_hlsl_resource_getpointer_typed", ElemPtrTy,
1936 PH::Handle, PH::_0, ElemTy);
1938 MMB.
callBuiltin(
"__builtin_hlsl_resource_getpointer", ElemPtrTy, PH::Handle,
1947 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1949 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1961 .
callBuiltin(
"__builtin_hlsl_resource_getpointer_typed", ElemPtrTy,
1962 PH::Handle, PH::_0, ValueTy)
1964 .
assign(PH::LastStmt, PH::_1)
1969 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1971 QualType ElemTy = getHandleElementType();
1975 .addParam(
"value", ElemTy)
1976 .callBuiltin(
"__builtin_hlsl_buffer_update_counter", AST.
UnsignedIntTy,
1977 PH::CounterHandle, getConstantIntExpr(1))
1978 .callBuiltin(
"__builtin_hlsl_resource_getpointer",
1981 .dereference(PH::LastStmt)
1982 .assign(PH::LastStmt, PH::_0)
1987 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1989 QualType ElemTy = getHandleElementType();
1993 .callBuiltin(
"__builtin_hlsl_buffer_update_counter", AST.
UnsignedIntTy,
1994 PH::CounterHandle, getConstantIntExpr(-1))
1995 .callBuiltin(
"__builtin_hlsl_resource_getpointer",
1998 .dereference(PH::LastStmt)
2004 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
2008 QualType HandleTy = getResourceHandleField()->getType();
2013 if (AttrResTy->getAttrs().RawBuffer &&
2014 AttrResTy->getContainedType() != AST.
Char8Ty) {
2016 .addParam(
"numStructs", UIntTy, HLSLParamModifierAttr::Keyword_out)
2017 .addParam(
"stride", UIntTy, HLSLParamModifierAttr::Keyword_out)
2018 .callBuiltin(
"__builtin_hlsl_resource_getdimensions_x",
QualType(),
2020 .callBuiltin(
"__builtin_hlsl_resource_getstride",
QualType(),
2028 .addParam(
"dim", UIntTy, HLSLParamModifierAttr::Keyword_out)
2029 .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 ...
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
a trap message and trap category.
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
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.
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.
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={})
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, TemplateDecl *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.
The name of a declaration.
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)
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)
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.
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.
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
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
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.
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, unsigned D, unsigned 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...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
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 & addStoreFunction(DeclarationName &Name, bool IsConst, QualType ValueType)
friend struct BuiltinTypeMethodBuilder
BuiltinTypeDeclBuilder(Sema &SemaRef, CXXRecordDecl *R)
BuiltinTypeDeclBuilder & addSimpleTemplateParams(ArrayRef< StringRef > Names, ConceptDecl *CD)
BuiltinTypeDeclBuilder & addMemberVariable(StringRef Name, QualType Type, llvm::ArrayRef< Attr * > Attrs, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addConsumeMethod()
~BuiltinTypeDeclBuilder()
friend struct TemplateParameterListBuilder
BuiltinTypeDeclBuilder & addArraySubscriptOperators(ResourceDimension Dim=ResourceDimension::Unknown)
BuiltinTypeDeclBuilder & addLoadWithStatusFunction(DeclarationName &Name, bool IsConst, QualType ReturnTy=QualType())
BuiltinTypeDeclBuilder & addSampleGradMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addHandleAccessFunction(DeclarationName &Name, bool IsConst, bool IsRef, QualType IndexTy, QualType ElemTy=QualType())
BuiltinTypeDeclBuilder & addGetDimensionsMethodForBuffer()
BuiltinTypeDeclBuilder & addGatherCmpMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addSamplerHandle()
BuiltinTypeDeclBuilder & addSampleBiasMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & completeDefinition()
BuiltinTypeDeclBuilder & addBufferHandles(ResourceClass RC, bool IsROV, bool RawBuffer, bool HasCounter, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addByteAddressBufferStoreMethods()
BuiltinTypeDeclBuilder & addTextureHandle(ResourceClass RC, bool IsROV, ResourceDimension RD, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addAppendMethod()
BuiltinTypeDeclBuilder & addTextureLoadMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addIncrementCounterMethod()
BuiltinTypeDeclBuilder & addSampleLevelMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addCopyAssignmentOperator()
BuiltinTypeDeclBuilder & addCopyConstructor()
BuiltinTypeDeclBuilder & addByteAddressBufferLoadMethods()
BuiltinTypeDeclBuilder & addSampleMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addStaticInitializationFunctions(bool HasCounter)
BuiltinTypeDeclBuilder & addDefaultHandleConstructor()
BuiltinTypeDeclBuilder & addSampleCmpLevelZeroMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addGatherMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addDecrementCounterMethod()
BuiltinTypeDeclBuilder & addSampleCmpMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addLoadMethods()
uint32_t getResourceDimensions(llvm::dxil::ResourceDimension Dim)
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
@ ICIS_NoInit
No in-class initializer.
@ 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.
@ Template
We are parsing a template declaration.
bool CreateHLSLAttributedResourceType(Sema &S, QualType Wrapped, ArrayRef< const Attr * > AttrList, QualType &ResType, HLSLAttributedResourceLocInfo *LocInfo=nullptr)
@ 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.
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 & addParam(StringRef Name, QualType Ty, HLSLParamModifierAttr::Spelling Modifier=HLSLParamModifierAttr::Keyword_in)
Expr * getResourceHandleExpr()
BuiltinTypeMethodBuilder & callBuiltin(StringRef BuiltinName, QualType ReturnType, Ts &&...ArgSpecs)
BuiltinTypeMethodBuilder & accessHandleFieldOnResource(T ResourceRecord)
BuiltinTypeDeclBuilder & finalize()
Expr * getResourceCounterHandleExpr()
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 & setCounterHandleFieldOnResource(ResourceT ResourceRecord, ValueT HandleValue)
BuiltinTypeMethodBuilder & setHandleFieldOnResource(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)
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