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())
1240 if (getResourceAttrs().ResourceClass == llvm::dxil::ResourceClass::UAV)
1247 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1261 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1265 auto AddLoads = [&](StringRef MethodName,
QualType ReturnType) {
1284 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1288 auto AddStore = [&](StringRef MethodName,
QualType ValueType) {
1306 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1308 QualType ReturnType = getHandleElementType();
1310 lookupBuiltinType(SemaRef,
"SamplerState", Record->getDeclContext());
1316 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1320 .addParam(
"Sampler", SamplerStateType)
1321 .addParam(
"Location", Float2Ty)
1322 .accessHandleFieldOnResource(PH::_0)
1323 .callBuiltin(
"__builtin_hlsl_resource_sample", ReturnType, PH::Handle,
1324 PH::LastStmt, PH::_1)
1325 .returnValue(PH::LastStmt)
1330 .addParam(
"Sampler", SamplerStateType)
1331 .addParam(
"Location", Float2Ty)
1332 .addParam(
"Offset", Int2Ty)
1333 .accessHandleFieldOnResource(PH::_0)
1334 .callBuiltin(
"__builtin_hlsl_resource_sample", ReturnType, PH::Handle,
1335 PH::LastStmt, PH::_1, PH::_2)
1336 .returnValue(PH::LastStmt)
1341 .addParam(
"Sampler", SamplerStateType)
1342 .addParam(
"Location", Float2Ty)
1343 .addParam(
"Offset", Int2Ty)
1344 .addParam(
"Clamp", FloatTy)
1345 .accessHandleFieldOnResource(PH::_0)
1346 .callBuiltin(
"__builtin_hlsl_resource_sample", ReturnType, PH::Handle,
1347 PH::LastStmt, PH::_1, PH::_2, PH::_3)
1348 .returnValue(PH::LastStmt)
1354 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1356 QualType ReturnType = getHandleElementType();
1358 lookupBuiltinType(SemaRef,
"SamplerState", Record->getDeclContext());
1364 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1368 .addParam(
"Sampler", SamplerStateType)
1369 .addParam(
"Location", Float2Ty)
1370 .addParam(
"Bias", FloatTy)
1371 .accessHandleFieldOnResource(PH::_0)
1372 .callBuiltin(
"__builtin_hlsl_resource_sample_bias", ReturnType,
1373 PH::Handle, PH::LastStmt, PH::_1, PH::_2)
1374 .returnValue(PH::LastStmt)
1379 .addParam(
"Sampler", SamplerStateType)
1380 .addParam(
"Location", Float2Ty)
1381 .addParam(
"Bias", FloatTy)
1382 .addParam(
"Offset", Int2Ty)
1383 .accessHandleFieldOnResource(PH::_0)
1384 .callBuiltin(
"__builtin_hlsl_resource_sample_bias", ReturnType,
1385 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3)
1386 .returnValue(PH::LastStmt)
1392 .addParam(
"Sampler", SamplerStateType)
1393 .addParam(
"Location", Float2Ty)
1394 .addParam(
"Bias", FloatTy)
1395 .addParam(
"Offset", Int2Ty)
1396 .addParam(
"Clamp", FloatTy)
1397 .accessHandleFieldOnResource(PH::_0)
1398 .callBuiltin(
"__builtin_hlsl_resource_sample_bias", ReturnType,
1399 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3, PH::_4)
1400 .returnValue(PH::LastStmt)
1406 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1408 QualType ReturnType = getHandleElementType();
1410 lookupBuiltinType(SemaRef,
"SamplerState", Record->getDeclContext());
1416 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1420 .addParam(
"Sampler", SamplerStateType)
1421 .addParam(
"Location", Float2Ty)
1422 .addParam(
"DDX", Float2Ty)
1423 .addParam(
"DDY", Float2Ty)
1424 .accessHandleFieldOnResource(PH::_0)
1425 .callBuiltin(
"__builtin_hlsl_resource_sample_grad", 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(
"DDX", Float2Ty)
1436 .addParam(
"DDY", Float2Ty)
1437 .addParam(
"Offset", Int2Ty)
1438 .accessHandleFieldOnResource(PH::_0)
1439 .callBuiltin(
"__builtin_hlsl_resource_sample_grad", ReturnType,
1440 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3, PH::_4)
1441 .returnValue(PH::LastStmt)
1447 .addParam(
"Sampler", SamplerStateType)
1448 .addParam(
"Location", Float2Ty)
1449 .addParam(
"DDX", Float2Ty)
1450 .addParam(
"DDY", Float2Ty)
1451 .addParam(
"Offset", Int2Ty)
1452 .addParam(
"Clamp", FloatTy)
1453 .accessHandleFieldOnResource(PH::_0)
1454 .callBuiltin(
"__builtin_hlsl_resource_sample_grad", ReturnType,
1455 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3, PH::_4,
1457 .returnValue(PH::LastStmt)
1463 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1465 QualType ReturnType = getHandleElementType();
1467 lookupBuiltinType(SemaRef,
"SamplerState", Record->getDeclContext());
1473 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1477 .addParam(
"Sampler", SamplerStateType)
1478 .addParam(
"Location", Float2Ty)
1479 .addParam(
"LOD", FloatTy)
1480 .accessHandleFieldOnResource(PH::_0)
1481 .callBuiltin(
"__builtin_hlsl_resource_sample_level", ReturnType,
1482 PH::Handle, PH::LastStmt, PH::_1, PH::_2)
1483 .returnValue(PH::LastStmt)
1488 .addParam(
"Sampler", SamplerStateType)
1489 .addParam(
"Location", Float2Ty)
1490 .addParam(
"LOD", FloatTy)
1491 .addParam(
"Offset", Int2Ty)
1492 .accessHandleFieldOnResource(PH::_0)
1493 .callBuiltin(
"__builtin_hlsl_resource_sample_level", ReturnType,
1494 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3)
1495 .returnValue(PH::LastStmt)
1501 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1504 QualType SamplerComparisonStateType = lookupBuiltinType(
1505 SemaRef,
"SamplerComparisonState", Record->getDeclContext());
1511 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1515 .addParam(
"Sampler", SamplerComparisonStateType)
1516 .addParam(
"Location", Float2Ty)
1517 .addParam(
"CompareValue", FloatTy)
1518 .accessHandleFieldOnResource(PH::_0)
1519 .callBuiltin(
"__builtin_hlsl_resource_sample_cmp", ReturnType, PH::Handle,
1520 PH::LastStmt, PH::_1, PH::_2)
1521 .returnValue(PH::LastStmt)
1527 .addParam(
"Sampler", SamplerComparisonStateType)
1528 .addParam(
"Location", Float2Ty)
1529 .addParam(
"CompareValue", FloatTy)
1530 .addParam(
"Offset", Int2Ty)
1531 .accessHandleFieldOnResource(PH::_0)
1532 .callBuiltin(
"__builtin_hlsl_resource_sample_cmp", ReturnType, PH::Handle,
1533 PH::LastStmt, PH::_1, PH::_2, PH::_3)
1534 .returnValue(PH::LastStmt)
1540 .addParam(
"Sampler", SamplerComparisonStateType)
1541 .addParam(
"Location", Float2Ty)
1542 .addParam(
"CompareValue", FloatTy)
1543 .addParam(
"Offset", Int2Ty)
1544 .addParam(
"Clamp", FloatTy)
1545 .accessHandleFieldOnResource(PH::_0)
1546 .callBuiltin(
"__builtin_hlsl_resource_sample_cmp", ReturnType, PH::Handle,
1547 PH::LastStmt, PH::_1, PH::_2, PH::_3, PH::_4)
1548 .returnValue(PH::LastStmt)
1554 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1557 QualType SamplerComparisonStateType = lookupBuiltinType(
1558 SemaRef,
"SamplerComparisonState", Record->getDeclContext());
1564 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1569 .addParam(
"Sampler", SamplerComparisonStateType)
1570 .addParam(
"Location", Float2Ty)
1571 .addParam(
"CompareValue", FloatTy)
1572 .accessHandleFieldOnResource(PH::_0)
1573 .callBuiltin(
"__builtin_hlsl_resource_sample_cmp_level_zero", ReturnType,
1574 PH::Handle, PH::LastStmt, PH::_1, PH::_2)
1575 .returnValue(PH::LastStmt)
1581 .addParam(
"Sampler", SamplerComparisonStateType)
1582 .addParam(
"Location", Float2Ty)
1583 .addParam(
"CompareValue", FloatTy)
1584 .addParam(
"Offset", Int2Ty)
1585 .accessHandleFieldOnResource(PH::_0)
1586 .callBuiltin(
"__builtin_hlsl_resource_sample_cmp_level_zero", ReturnType,
1587 PH::Handle, PH::LastStmt, PH::_1, PH::_2, PH::_3)
1588 .returnValue(PH::LastStmt)
1592QualType BuiltinTypeDeclBuilder::getGatherReturnType() {
1594 QualType T = getHandleElementType();
1599 T = VT->getElementType();
1601 T = DT->getElementType();
1608 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1610 QualType ReturnType = getGatherReturnType();
1613 lookupBuiltinType(SemaRef,
"SamplerState", Record->getDeclContext());
1619 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1622 struct GatherVariant {
1626 GatherVariant Variants[] = {{
"Gather", 0},
1630 {
"GatherAlpha", 3}};
1632 for (
const auto &
V : Variants) {
1635 .addParam(
"Sampler", SamplerStateType)
1636 .addParam(
"Location", Float2Ty)
1637 .accessHandleFieldOnResource(PH::_0)
1638 .callBuiltin(
"__builtin_hlsl_resource_gather", ReturnType, PH::Handle,
1639 PH::LastStmt, PH::_1,
1640 getConstantUnsignedIntExpr(
V.Component))
1645 .addParam(
"Sampler", SamplerStateType)
1646 .addParam(
"Location", Float2Ty)
1647 .addParam(
"Offset", OffsetTy)
1648 .accessHandleFieldOnResource(PH::_0)
1649 .callBuiltin(
"__builtin_hlsl_resource_gather", ReturnType, PH::Handle,
1650 PH::LastStmt, PH::_1,
1651 getConstantUnsignedIntExpr(
V.Component), PH::_2)
1660 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1664 QualType SamplerComparisonStateType = lookupBuiltinType(
1665 SemaRef,
"SamplerComparisonState", Record->getDeclContext());
1671 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1675 struct GatherVariant {
1679 GatherVariant Variants[] = {{
"GatherCmp", 0},
1680 {
"GatherCmpRed", 0},
1681 {
"GatherCmpGreen", 1},
1682 {
"GatherCmpBlue", 2},
1683 {
"GatherCmpAlpha", 3}};
1685 for (
const auto &
V : Variants) {
1689 .addParam(
"Sampler", SamplerComparisonStateType)
1690 .addParam(
"Location", Float2Ty)
1691 .addParam(
"CompareValue", FloatTy)
1692 .accessHandleFieldOnResource(PH::_0)
1693 .callBuiltin(
"__builtin_hlsl_resource_gather_cmp", ReturnType,
1694 PH::Handle, PH::LastStmt, PH::_1, PH::_2,
1695 getConstantUnsignedIntExpr(
V.Component))
1701 .addParam(
"Sampler", SamplerComparisonStateType)
1702 .addParam(
"Location", Float2Ty)
1703 .addParam(
"CompareValue", FloatTy)
1704 .addParam(
"Offset", Int2Ty)
1705 .accessHandleFieldOnResource(PH::_0)
1706 .callBuiltin(
"__builtin_hlsl_resource_gather_cmp", ReturnType,
1707 PH::Handle, PH::LastStmt, PH::_1, PH::_2,
1708 getConstantUnsignedIntExpr(
V.Component), PH::_3)
1715FieldDecl *BuiltinTypeDeclBuilder::getResourceHandleField()
const {
1716 auto I = Fields.find(
"__handle");
1717 assert(I != Fields.end() &&
1718 I->second->getType()->isHLSLAttributedResourceType() &&
1719 "record does not have resource handle field");
1723FieldDecl *BuiltinTypeDeclBuilder::getResourceCounterHandleField()
const {
1724 auto I = Fields.find(
"__counter_handle");
1725 if (I == Fields.end() ||
1726 !I->second->getType()->isHLSLAttributedResourceType())
1731QualType BuiltinTypeDeclBuilder::getFirstTemplateTypeParam() {
1732 assert(
Template &&
"record it not a template");
1733 if (
const auto *TTD = dyn_cast<TemplateTypeParmDecl>(
1734 Template->getTemplateParameters()->getParam(0))) {
1735 return QualType(TTD->getTypeForDecl(), 0);
1740QualType BuiltinTypeDeclBuilder::getHandleElementType() {
1742 return getFirstTemplateTypeParam();
1744 if (
auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
1745 const auto &Args = Spec->getTemplateArgs();
1747 return Args[0].getAsType();
1751 return SemaRef.getASTContext().Char8Ty;
1754HLSLAttributedResourceType::Attributes
1755BuiltinTypeDeclBuilder::getResourceAttrs()
const {
1756 QualType HandleType = getResourceHandleField()->getType();
1761 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1762 assert(Record->isBeingDefined() &&
1763 "Definition must be started before completing it.");
1765 Record->completeDefinition();
1769Expr *BuiltinTypeDeclBuilder::getConstantIntExpr(
int value) {
1776Expr *BuiltinTypeDeclBuilder::getConstantUnsignedIntExpr(
unsigned value) {
1793 if (Record->isCompleteDefinition()) {
1794 assert(Template &&
"existing record it not a template");
1795 assert(Template->getTemplateParameters()->size() == Names.size() &&
1796 "template param count mismatch");
1800 assert((DefaultTypes.empty() || DefaultTypes.size() == Names.size()) &&
1801 "template default argument count mismatch");
1804 for (
unsigned i = 0; i < Names.size(); ++i) {
1806 Builder.addTypeParameter(Names[i], DefaultTy);
1808 return Builder.finalizeTemplateArgs(CD);
1812 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1813 QualType UnsignedIntTy = SemaRef.getASTContext().UnsignedIntTy;
1815 .callBuiltin(
"__builtin_hlsl_buffer_update_counter", UnsignedIntTy,
1816 PH::CounterHandle, getConstantIntExpr(1))
1821 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1822 QualType UnsignedIntTy = SemaRef.getASTContext().UnsignedIntTy;
1824 .callBuiltin(
"__builtin_hlsl_buffer_update_counter", UnsignedIntTy,
1825 PH::CounterHandle, getConstantIntExpr(-1))
1831 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1833 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1834 bool NeedsTypedBuiltin = !ReturnTy.
isNull();
1839 if (!NeedsTypedBuiltin)
1840 ReturnTy = getHandleElementType();
1843 MMB.ReturnTy = ReturnTy;
1847 HLSLParamModifierAttr::Keyword_out);
1849 if (NeedsTypedBuiltin)
1850 MMB.
callBuiltin(
"__builtin_hlsl_resource_load_with_status_typed", ReturnTy,
1851 PH::Handle, PH::_0, PH::_1, ReturnTy);
1853 MMB.
callBuiltin(
"__builtin_hlsl_resource_load_with_status", ReturnTy,
1854 PH::Handle, PH::_0, PH::_1);
1861 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1863 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1864 bool NeedsTypedBuiltin = !ElemTy.
isNull();
1869 if (!NeedsTypedBuiltin)
1870 ElemTy = getHandleElementType();
1879 ReturnTy = AddrSpaceElemTy;
1888 MMB.ReturnTy = ReturnTy;
1892 if (NeedsTypedBuiltin)
1893 MMB.
callBuiltin(
"__builtin_hlsl_resource_getpointer_typed", ElemPtrTy,
1894 PH::Handle, PH::_0, ElemTy);
1896 MMB.
callBuiltin(
"__builtin_hlsl_resource_getpointer", ElemPtrTy, PH::Handle,
1905 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1907 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1919 .
callBuiltin(
"__builtin_hlsl_resource_getpointer_typed", ElemPtrTy,
1920 PH::Handle, PH::_0, ValueTy)
1922 .
assign(PH::LastStmt, PH::_1)
1927 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1929 QualType ElemTy = getHandleElementType();
1933 .addParam(
"value", ElemTy)
1934 .callBuiltin(
"__builtin_hlsl_buffer_update_counter", AST.
UnsignedIntTy,
1935 PH::CounterHandle, getConstantIntExpr(1))
1936 .callBuiltin(
"__builtin_hlsl_resource_getpointer",
1939 .dereference(PH::LastStmt)
1940 .assign(PH::LastStmt, PH::_0)
1945 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1947 QualType ElemTy = getHandleElementType();
1951 .callBuiltin(
"__builtin_hlsl_buffer_update_counter", AST.
UnsignedIntTy,
1952 PH::CounterHandle, getConstantIntExpr(-1))
1953 .callBuiltin(
"__builtin_hlsl_resource_getpointer",
1956 .dereference(PH::LastStmt)
1962 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1966 QualType HandleTy = getResourceHandleField()->getType();
1971 if (AttrResTy->getAttrs().RawBuffer &&
1972 AttrResTy->getContainedType() != AST.
Char8Ty) {
1974 .addParam(
"numStructs", UIntTy, HLSLParamModifierAttr::Keyword_out)
1975 .addParam(
"stride", UIntTy, HLSLParamModifierAttr::Keyword_out)
1976 .callBuiltin(
"__builtin_hlsl_resource_getdimensions_x",
QualType(),
1978 .callBuiltin(
"__builtin_hlsl_resource_getstride",
QualType(),
1986 .addParam(
"dim", UIntTy, HLSLParamModifierAttr::Keyword_out)
1987 .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 & addLoadWithStatusFunction(DeclarationName &Name, bool IsConst, QualType ReturnTy=QualType())
BuiltinTypeDeclBuilder & addSampleGradMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addGetDimensionsMethodForBuffer()
BuiltinTypeDeclBuilder & addGatherCmpMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addSamplerHandle()
BuiltinTypeDeclBuilder & addHandleAccessFunction(DeclarationName &Name, bool IsConst, bool IsRef, QualType ElemTy=QualType())
BuiltinTypeDeclBuilder & addArraySubscriptOperators()
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 & 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