clang 24.0.0git
HLSLExternalSemaSource.cpp
Go to the documentation of this file.
1//===--- HLSLExternalSemaSource.cpp - HLSL Sema Source --------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9//
10//===----------------------------------------------------------------------===//
11
15#include "clang/AST/Attr.h"
16#include "clang/AST/Decl.h"
17#include "clang/AST/DeclCXX.h"
19#include "clang/AST/Expr.h"
20#include "clang/AST/Type.h"
24#include "clang/Sema/Lookup.h"
25#include "clang/Sema/Sema.h"
26#include "clang/Sema/SemaHLSL.h"
27#include "llvm/ADT/BitmaskEnum.h"
28#include "llvm/ADT/STLExtras.h"
29#include "llvm/ADT/SmallVector.h"
30
31using namespace clang;
32using namespace llvm::hlsl;
33
35
37 SemaPtr = &S;
38 ASTContext &AST = SemaPtr->getASTContext();
39 // If the translation unit has external storage force external decls to load.
42
43 IdentifierInfo &HLSL = AST.Idents.get("hlsl", tok::TokenKind::identifier);
45 NamespaceDecl *PrevDecl = nullptr;
47 PrevDecl = Result.getAsSingle<NamespaceDecl>();
48 HLSLNamespace = NamespaceDecl::Create(
49 AST, AST.getTranslationUnitDecl(), /*Inline=*/false, SourceLocation(),
50 SourceLocation(), &HLSL, PrevDecl, /*Nested=*/false);
51 HLSLNamespace->setImplicit(true);
52 HLSLNamespace->setHasExternalLexicalStorage();
53 AST.getTranslationUnitDecl()->addDecl(HLSLNamespace);
54
55 // Force external decls in the HLSL namespace to load from the PCH.
56 (void)HLSLNamespace->getCanonicalDecl()->decls_begin();
57 defineTrivialHLSLTypes();
58 defineHLSLTypesWithForwardDeclarations();
59 defineHLSLAtomicIntrinsics();
60
61 // This adds a `using namespace hlsl` directive. In DXC, we don't put HLSL's
62 // built in types inside a namespace, but we are planning to change that in
63 // the near future. In order to be source compatible older versions of HLSL
64 // will need to implicitly use the hlsl namespace. For now in clang everything
65 // will get added to the namespace, and we can remove the using directive for
66 // future language versions to match HLSL's evolution.
69 NestedNameSpecifierLoc(), SourceLocation(), HLSLNamespace,
71
73}
74
75void HLSLExternalSemaSource::defineHLSLVectorAlias() {
76 ASTContext &AST = SemaPtr->getASTContext();
77
78 llvm::SmallVector<NamedDecl *> TemplateParams;
79
80 auto *TypeParam = TemplateTypeParmDecl::Create(
81 AST, HLSLNamespace, SourceLocation(), SourceLocation(), 0, 0,
82 &AST.Idents.get("element", tok::TokenKind::identifier), false, false);
83 TypeParam->setDefaultArgument(
86
87 TemplateParams.emplace_back(TypeParam);
88
89 auto *SizeParam = NonTypeTemplateParmDecl::Create(
90 AST, HLSLNamespace, SourceLocation(), SourceLocation(), 0, 1,
91 &AST.Idents.get("element_count", tok::TokenKind::identifier), AST.IntTy,
92 false, AST.getTrivialTypeSourceInfo(AST.IntTy));
93 llvm::APInt Val(AST.getIntWidth(AST.IntTy), 4);
94 TemplateArgument Default(AST, llvm::APSInt(std::move(Val)), AST.IntTy,
95 /*IsDefaulted=*/true);
96 SizeParam->setDefaultArgument(AST, SemaPtr->getTrivialTemplateArgumentLoc(
98 TemplateParams.emplace_back(SizeParam);
99
100 auto *ParamList =
102 TemplateParams, SourceLocation(), nullptr);
103
104 IdentifierInfo &II = AST.Idents.get("vector", tok::TokenKind::identifier);
105
107 AST.getTemplateTypeParmType(0, 0, false, TypeParam),
109 AST, NestedNameSpecifierLoc(), SourceLocation(), SizeParam, false,
110 DeclarationNameInfo(SizeParam->getDeclName(), SourceLocation()),
111 AST.IntTy, VK_LValue),
113
114 auto *Record = TypeAliasDecl::Create(AST, HLSLNamespace, SourceLocation(),
115 SourceLocation(), &II,
116 AST.getTrivialTypeSourceInfo(AliasType));
117 Record->setImplicit(true);
118
119 auto *Template =
120 TypeAliasTemplateDecl::Create(AST, HLSLNamespace, SourceLocation(),
121 Record->getIdentifier(), ParamList, Record);
122
123 Record->setDescribedAliasTemplate(Template);
124 Template->setImplicit(true);
125 Template->setLexicalDeclContext(Record->getDeclContext());
126 HLSLNamespace->addDecl(Template);
127}
128
129void HLSLExternalSemaSource::defineHLSLMatrixAlias() {
130 ASTContext &AST = SemaPtr->getASTContext();
131 llvm::SmallVector<NamedDecl *> TemplateParams;
132
133 auto *TypeParam = TemplateTypeParmDecl::Create(
134 AST, HLSLNamespace, SourceLocation(), SourceLocation(), 0, 0,
135 &AST.Idents.get("element", tok::TokenKind::identifier), false, false);
136 TypeParam->setDefaultArgument(
137 AST, SemaPtr->getTrivialTemplateArgumentLoc(
139
140 TemplateParams.emplace_back(TypeParam);
141
142 // these should be 64 bit to be consistent with other clang matrices.
143 auto *RowsParam = NonTypeTemplateParmDecl::Create(
144 AST, HLSLNamespace, SourceLocation(), SourceLocation(), 0, 1,
145 &AST.Idents.get("rows_count", tok::TokenKind::identifier), AST.IntTy,
146 false, AST.getTrivialTypeSourceInfo(AST.IntTy));
147 llvm::APInt RVal(AST.getIntWidth(AST.IntTy), 4);
148 TemplateArgument RDefault(AST, llvm::APSInt(std::move(RVal)), AST.IntTy,
149 /*IsDefaulted=*/true);
150 RowsParam->setDefaultArgument(
151 AST, SemaPtr->getTrivialTemplateArgumentLoc(RDefault, AST.IntTy,
152 SourceLocation()));
153 TemplateParams.emplace_back(RowsParam);
154
155 auto *ColsParam = NonTypeTemplateParmDecl::Create(
156 AST, HLSLNamespace, SourceLocation(), SourceLocation(), 0, 2,
157 &AST.Idents.get("cols_count", tok::TokenKind::identifier), AST.IntTy,
158 false, AST.getTrivialTypeSourceInfo(AST.IntTy));
159 llvm::APInt CVal(AST.getIntWidth(AST.IntTy), 4);
160 TemplateArgument CDefault(AST, llvm::APSInt(std::move(CVal)), AST.IntTy,
161 /*IsDefaulted=*/true);
162 ColsParam->setDefaultArgument(
163 AST, SemaPtr->getTrivialTemplateArgumentLoc(CDefault, AST.IntTy,
164 SourceLocation()));
165 TemplateParams.emplace_back(ColsParam);
166
167 const unsigned MaxMatDim = SemaPtr->getLangOpts().MaxMatrixDimension;
168
169 auto *MaxRow = IntegerLiteral::Create(
170 AST, llvm::APInt(AST.getIntWidth(AST.IntTy), MaxMatDim), AST.IntTy,
172 auto *MaxCol = IntegerLiteral::Create(
173 AST, llvm::APInt(AST.getIntWidth(AST.IntTy), MaxMatDim), AST.IntTy,
175
176 auto *RowsRef = DeclRefExpr::Create(
177 AST, NestedNameSpecifierLoc(), SourceLocation(), RowsParam,
178 /*RefersToEnclosingVariableOrCapture*/ false,
179 DeclarationNameInfo(RowsParam->getDeclName(), SourceLocation()),
180 AST.IntTy, VK_LValue);
181 auto *ColsRef = DeclRefExpr::Create(
182 AST, NestedNameSpecifierLoc(), SourceLocation(), ColsParam,
183 /*RefersToEnclosingVariableOrCapture*/ false,
184 DeclarationNameInfo(ColsParam->getDeclName(), SourceLocation()),
185 AST.IntTy, VK_LValue);
186
187 auto *RowsLE = BinaryOperator::Create(AST, RowsRef, MaxRow, BO_LE, AST.BoolTy,
190 auto *ColsLE = BinaryOperator::Create(AST, ColsRef, MaxCol, BO_LE, AST.BoolTy,
193
195 AST, RowsLE, ColsLE, BO_LAnd, AST.BoolTy, VK_PRValue, OK_Ordinary,
197
198 auto *ParamList = TemplateParameterList::Create(
199 AST, SourceLocation(), SourceLocation(), TemplateParams, SourceLocation(),
201
202 IdentifierInfo &II = AST.Idents.get("matrix", tok::TokenKind::identifier);
203
205 AST.getTemplateTypeParmType(0, 0, false, TypeParam),
207 AST, NestedNameSpecifierLoc(), SourceLocation(), RowsParam, false,
208 DeclarationNameInfo(RowsParam->getDeclName(), SourceLocation()),
209 AST.IntTy, VK_LValue),
211 AST, NestedNameSpecifierLoc(), SourceLocation(), ColsParam, false,
212 DeclarationNameInfo(ColsParam->getDeclName(), SourceLocation()),
213 AST.IntTy, VK_LValue),
215
216 auto *Record = TypeAliasDecl::Create(AST, HLSLNamespace, SourceLocation(),
217 SourceLocation(), &II,
218 AST.getTrivialTypeSourceInfo(AliasType));
219 Record->setImplicit(true);
220
221 auto *Template =
222 TypeAliasTemplateDecl::Create(AST, HLSLNamespace, SourceLocation(),
223 Record->getIdentifier(), ParamList, Record);
224
225 Record->setDescribedAliasTemplate(Template);
226 Template->setImplicit(true);
227 Template->setLexicalDeclContext(Record->getDeclContext());
228 HLSLNamespace->addDecl(Template);
229}
230
231void HLSLExternalSemaSource::defineTrivialHLSLTypes() {
232 defineHLSLVectorAlias();
233 defineHLSLMatrixAlias();
234}
235
236/// Set up common members and attributes for buffer types
238 ResourceClass RC, bool IsROV,
239 bool RawBuffer, bool HasCounter) {
241 .addBufferHandles(RC, IsROV, RawBuffer, HasCounter)
246}
247
248/// Set up common members and attributes for sampler types
257
258namespace {
260
261/// Which members a texture type has. Overloads within a member family
262/// (e.g., offset overloads for samplers) follow from ResourceDimension.
263enum class TexCap : uint32_t {
264 Load = 1u << 0, // Load(int<N+1>) taking a mip level
265 LoadMS = 1u << 1, // Load(int<N>, int sampleIndex) on a multisampled type
266 LoadRW = 1u << 2, // Load(int<N>) on a writable texture
267 Subscript = 1u << 3, // operator[]
268 Mips = 1u << 4, // mips[]
269 Sample = 1u << 5, // Sample, SampleBias, SampleGrad, SampleLevel
270 SampleCmp = 1u << 6, // SampleCmp, SampleCmpLevelZero
271 Gather = 1u << 7, // Gather*, GatherCmp*
272 CalcLOD = 1u << 8, // CalculateLevelOfDetail, ...Unclamped
273 GetDims = 1u << 9, // GetDimensions
274
275 // TODO: multisampled types need an MS-specific GetDimensions
276 // https://github.com/llvm/wg-hlsl/issues/347
277
278 LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/GetDims)
279};
280
281/// How a type's template parameters are spelled. Independent of its
282/// capabilities; also decides which types get a vector partial specialization.
283enum class TemplateShape {
284 ElementType, // template<typename T = float4>
285 ElementTypeAndSampleCount, // template<typename T, uint N>
286};
287
288struct TextureTypeInfo {
289 const char *Name;
290 ResourceClass RC;
291 ResourceDimension Dim;
292 bool IsArray;
293 bool IsROV;
294 TemplateShape Shape;
295 TexCap Caps;
296
297 bool has(TexCap C) const { return (Caps & C) != TexCap{}; }
298 bool hasSampleCount() const {
299 return Shape == TemplateShape::ElementTypeAndSampleCount;
300 }
301};
302} // namespace
303
304static const TextureTypeInfo TextureTypes[] = {
305 {"Texture2D", ResourceClass::SRV, ResourceDimension::Dim2D,
306 /*IsArray=*/false, /*IsROV=*/false, TemplateShape::ElementType,
307 TexCap::Load | TexCap::Subscript | TexCap::Mips | TexCap::Sample |
308 TexCap::SampleCmp | TexCap::CalcLOD | TexCap::Gather |
309 TexCap::GetDims},
310 {"RWTexture2D", ResourceClass::UAV, ResourceDimension::Dim2D,
311 /*IsArray=*/false, /*IsROV=*/false, TemplateShape::ElementType,
312 TexCap::LoadRW | TexCap::Subscript | TexCap::GetDims},
313 {"Texture2DArray", ResourceClass::SRV, ResourceDimension::Dim2D,
314 /*IsArray=*/true, /*IsROV=*/false, TemplateShape::ElementType,
315 TexCap::Load | TexCap::Subscript | TexCap::Mips | TexCap::Sample |
316 TexCap::SampleCmp | TexCap::CalcLOD | TexCap::Gather |
317 TexCap::GetDims},
318 {"RWTexture2DArray", ResourceClass::UAV, ResourceDimension::Dim2D,
319 /*IsArray=*/true, /*IsROV=*/false, TemplateShape::ElementType,
320 TexCap::LoadRW | TexCap::Subscript | TexCap::GetDims},
321 {"Texture2DMS", ResourceClass::SRV, ResourceDimension::Dim2D,
322 /*IsArray=*/false, /*IsROV=*/false,
323 TemplateShape::ElementTypeAndSampleCount,
324 TexCap::LoadMS | TexCap::Subscript},
325 {"TextureCube", ResourceClass::SRV, ResourceDimension::Cube,
326 /*IsArray=*/false, /*IsROV=*/false, TemplateShape::ElementType,
327 TexCap::Sample | TexCap::SampleCmp | TexCap::CalcLOD | TexCap::Gather |
328 TexCap::GetDims},
329 {"TextureCubeArray", ResourceClass::SRV, ResourceDimension::Cube,
330 /*IsArray=*/true, /*IsROV=*/false, TemplateShape::ElementType,
331 TexCap::Sample | TexCap::SampleCmp | TexCap::CalcLOD | TexCap::Gather |
332 TexCap::GetDims},
333};
334
336 const TextureTypeInfo &T) {
337 const ResourceDimension Dim = T.Dim;
338 const bool IsArray = T.IsArray;
339
340 Expr *SampleCountExpr = nullptr;
341 if (T.hasSampleCount()) {
342 ClassTemplateDecl *CTD = Decl->getDescribedClassTemplate();
343 assert(CTD && "multisampled texture must be a class template");
344 // Parameter 1 is the N in Texture2DMS<T, N>.
347 SampleCountExpr =
348 S.BuildDeclRefExpr(NTTP, NTTP->getType(), VK_PRValue, SourceLocation());
349 }
350
352 B.addTextureHandle(T.RC, T.IsROV, IsArray, Dim, SampleCountExpr);
353
354 // The `mips` member holds a second copy of the resource handle.
355 // addCopyConstructor, addCopyAssignmentOperator and
356 // addStaticInitializationFunctions are what initialize that copy, and they
357 // look the member up by name, so it has to exist before they run.
358 if (T.has(TexCap::Mips))
360
365
366 if (T.has(TexCap::Load))
367 B.addTextureLoadMethods(Dim, IsArray);
368 if (T.has(TexCap::LoadMS))
369 B.addTextureLoadMSMethods(Dim, IsArray);
370 if (T.has(TexCap::LoadRW))
371 B.addRWTextureLoadMethods(Dim, IsArray);
372 if (T.has(TexCap::Subscript))
374
375 if (T.has(TexCap::Sample))
376 B.addSampleMethods(Dim, IsArray)
377 .addSampleBiasMethods(Dim, IsArray)
378 .addSampleGradMethods(Dim, IsArray)
379 .addSampleLevelMethods(Dim, IsArray);
380 if (T.has(TexCap::SampleCmp))
381 B.addSampleCmpMethods(Dim, IsArray)
383 if (T.has(TexCap::CalcLOD))
385 if (T.has(TexCap::GetDims))
387 if (T.has(TexCap::Gather))
388 B.addGatherMethods(Dim, IsArray).addGatherCmpMethods(Dim, IsArray);
389
390 return B;
391}
392
393// Add a partial specialization for a template. The `TextureTemplate` is
394// `Texture<element_type>`, and it will be specialized for vectors:
395// `Texture<vector<element_type, element_count>>`.
398 ClassTemplateDecl *TextureTemplate) {
399 ASTContext &AST = S.getASTContext();
400
401 // Create the template parameters: element_type and element_count.
402 auto *ElementType = TemplateTypeParmDecl::Create(
403 AST, HLSLNamespace, SourceLocation(), SourceLocation(), 0, 0,
404 &AST.Idents.get("element_type"), false, false);
405 auto *ElementCount = NonTypeTemplateParmDecl::Create(
406 AST, HLSLNamespace, SourceLocation(), SourceLocation(), 0, 1,
407 &AST.Idents.get("element_count"), AST.IntTy, false,
409
410 auto *TemplateParams = TemplateParameterList::Create(
411 AST, SourceLocation(), SourceLocation(), {ElementType, ElementCount},
412 SourceLocation(), nullptr);
413
414 // Create the dependent vector type: vector<element_type, element_count>.
416 AST.getTemplateTypeParmType(0, 0, false, ElementType),
418 AST, NestedNameSpecifierLoc(), SourceLocation(), ElementCount, false,
419 DeclarationNameInfo(ElementCount->getDeclName(), SourceLocation()),
420 AST.IntTy, VK_LValue),
422
423 // Create the partial specialization declaration.
424 QualType CanonInjectedTST =
428
430 AST, TagDecl::TagKind::Class, HLSLNamespace, SourceLocation(),
431 SourceLocation(), TemplateParams, TextureTemplate,
433 CanQualType::CreateUnsafe(CanonInjectedTST), nullptr);
434
435 // Set the template arguments as written.
437 TemplateArgumentLoc ArgLoc =
439 TemplateArgumentListInfo ArgsInfo =
441 ArgsInfo.addArgument(ArgLoc);
442 PartialSpec->setTemplateArgsAsWritten(
444
445 PartialSpec->setImplicit(true);
446 PartialSpec->setLexicalDeclContext(HLSLNamespace);
447 PartialSpec->setHasExternalLexicalStorage();
448
449 // Add the partial specialization to the namespace and the class template.
450 HLSLNamespace->addDecl(PartialSpec);
451 TextureTemplate->AddPartialSpecialization(PartialSpec, {});
452
453 return PartialSpec;
454}
455
456// This function is responsible for constructing the constraint expression for
457// this concept:
458// template<typename T> concept is_typed_resource_element_compatible =
459// __is_typed_resource_element_compatible<T>;
462 ASTContext &Context = S.getASTContext();
463
464 // Obtain the QualType for 'bool'
465 QualType BoolTy = Context.BoolTy;
466
467 // Create a QualType that points to this TemplateTypeParmDecl
468 QualType TType = Context.getTypeDeclType(T);
469
470 // Create a TypeSourceInfo for the template type parameter 'T'
471 TypeSourceInfo *TTypeSourceInfo =
472 Context.getTrivialTypeSourceInfo(TType, NameLoc);
473
474 TypeTraitExpr *TypedResExpr = TypeTraitExpr::Create(
475 Context, BoolTy, NameLoc, UTT_IsTypedResourceElementCompatible,
476 {TTypeSourceInfo}, NameLoc, true);
477
478 return TypedResExpr;
479}
480
481// This function is responsible for constructing the constraint expression for
482// this concept:
483// template<typename T> concept is_constant_buffer_element_compatible =
484// std::is_class_v<T> && !__is_intangible(T);
486 SourceLocation NameLoc,
488 ASTContext &Context = S.getASTContext();
489
490 // Obtain the QualType for 'bool'
491 QualType BoolTy = Context.BoolTy;
492
493 // Create a QualType that points to this TemplateTypeParmDecl
494 QualType TType = Context.getTypeDeclType(T);
495
496 // Create a TypeSourceInfo for the template type parameter 'T'
497 TypeSourceInfo *TTypeSourceInfo =
498 Context.getTrivialTypeSourceInfo(TType, NameLoc);
499
501 Context, BoolTy, NameLoc, UTT_IsConstantBufferElementCompatible,
502 {TTypeSourceInfo}, NameLoc, true);
503
504 return ResExpr;
505}
506
507// This function is responsible for constructing the constraint expression for
508// this concept:
509// template<typename T> concept is_structured_resource_element_compatible =
510// !__is_intangible<T> && sizeof(T) >= 1;
512 SourceLocation NameLoc,
514 ASTContext &Context = S.getASTContext();
515
516 // Obtain the QualType for 'bool'
517 QualType BoolTy = Context.BoolTy;
518
519 // Create a QualType that points to this TemplateTypeParmDecl
520 QualType TType = Context.getTypeDeclType(T);
521
522 // Create a TypeSourceInfo for the template type parameter 'T'
523 TypeSourceInfo *TTypeSourceInfo =
524 Context.getTrivialTypeSourceInfo(TType, NameLoc);
525
526 TypeTraitExpr *IsIntangibleExpr =
527 TypeTraitExpr::Create(Context, BoolTy, NameLoc, UTT_IsIntangibleType,
528 {TTypeSourceInfo}, NameLoc, true);
529
530 // negate IsIntangibleExpr
531 UnaryOperator *NotIntangibleExpr = UnaryOperator::Create(
532 Context, IsIntangibleExpr, UO_LNot, BoolTy, VK_LValue, OK_Ordinary,
533 NameLoc, false, FPOptionsOverride());
534
535 // element types also may not be of 0 size
536 UnaryExprOrTypeTraitExpr *SizeOfExpr = new (Context) UnaryExprOrTypeTraitExpr(
537 UETT_SizeOf, TTypeSourceInfo, BoolTy, NameLoc, NameLoc);
538
539 // Create a BinaryOperator that checks if the size of the type is not equal to
540 // 1 Empty structs have a size of 1 in HLSL, so we need to check for that
542 Context, llvm::APInt(Context.getTypeSize(Context.getSizeType()), 1, true),
543 Context.getSizeType(), NameLoc);
544
545 BinaryOperator *SizeGEQOneExpr =
546 BinaryOperator::Create(Context, SizeOfExpr, rhs, BO_GE, BoolTy, VK_LValue,
547 OK_Ordinary, NameLoc, FPOptionsOverride());
548
549 // Combine the two constraints
551 Context, NotIntangibleExpr, SizeGEQOneExpr, BO_LAnd, BoolTy, VK_LValue,
552 OK_Ordinary, NameLoc, FPOptionsOverride());
553
554 return CombinedExpr;
555}
556
558
560 HLSLBufferType BT) {
561 ASTContext &Context = S.getASTContext();
562 DeclContext *DC = NSD->getDeclContext();
563 SourceLocation DeclLoc = SourceLocation();
564
565 IdentifierInfo &ElementTypeII = Context.Idents.get("element_type");
567 Context, NSD->getDeclContext(), DeclLoc, DeclLoc,
568 /*D=*/0,
569 /*P=*/0,
570 /*Id=*/&ElementTypeII,
571 /*Typename=*/true,
572 /*ParameterPack=*/false);
573
574 T->setDeclContext(DC);
575 T->setReferenced();
576
577 // Create and Attach Template Parameter List to ConceptDecl
579 Context, DeclLoc, DeclLoc, {T}, DeclLoc, nullptr);
580
581 DeclarationName DeclName;
582 Expr *ConstraintExpr = nullptr;
583
584 switch (BT) {
586 DeclName = DeclarationName(
587 &Context.Idents.get("__is_typed_resource_element_compatible"));
588 ConstraintExpr = constructTypedBufferConstraintExpr(S, DeclLoc, T);
589 break;
591 DeclName = DeclarationName(
592 &Context.Idents.get("__is_structured_resource_element_compatible"));
593 ConstraintExpr = constructStructuredBufferConstraintExpr(S, DeclLoc, T);
594 break;
596 DeclName = DeclarationName(
597 &Context.Idents.get("__is_constant_buffer_element_compatible"));
598 ConstraintExpr = constructConstantBufferConstraintExpr(S, DeclLoc, T);
599 break;
600 }
601
602 // Create a ConceptDecl
603 ConceptDecl *CD =
604 ConceptDecl::Create(Context, NSD->getDeclContext(), DeclLoc, DeclName,
605 ConceptParams, ConstraintExpr);
606
607 // Attach the template parameter list to the ConceptDecl
608 CD->setTemplateParameters(ConceptParams);
609
610 // Add the concept declaration to the Translation Unit Decl
611 NSD->getDeclContext()->addDecl(CD);
612
613 return CD;
614}
615
616void HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() {
617 ASTContext &AST = SemaPtr->getASTContext();
618 CXXRecordDecl *Decl;
619 ConceptDecl *TypedBufferConcept = constructBufferConceptDecl(
620 *SemaPtr, HLSLNamespace, HLSLBufferType::Typed);
621 ConceptDecl *StructuredBufferConcept = constructBufferConceptDecl(
622 *SemaPtr, HLSLNamespace, HLSLBufferType::Structured);
623 ConceptDecl *ConstantBufferConcept = constructBufferConceptDecl(
624 *SemaPtr, HLSLNamespace, HLSLBufferType::Constant);
625
626 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "ConstantBuffer")
627 .addSimpleTemplateParams({"element_type"}, ConstantBufferConcept)
628 .finalizeForwardDeclaration();
629
630 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
631 setupBufferType(Decl, *SemaPtr, ResourceClass::CBuffer, /*IsROV=*/false,
632 /*RawBuffer=*/false, /*HasCounter=*/false)
635 });
636
637 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "Buffer")
638 .addSimpleTemplateParams({"element_type"}, TypedBufferConcept)
639 .finalizeForwardDeclaration();
640
641 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
642 setupBufferType(Decl, *SemaPtr, ResourceClass::SRV, /*IsROV=*/false,
643 /*RawBuffer=*/false, /*HasCounter=*/false)
648 });
649
650 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "RWBuffer")
651 .addSimpleTemplateParams({"element_type"}, TypedBufferConcept)
652 .finalizeForwardDeclaration();
653
654 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
655 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/false,
656 /*RawBuffer=*/false, /*HasCounter=*/false)
661 });
662
663 Decl =
664 BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "RasterizerOrderedBuffer")
665 .addSimpleTemplateParams({"element_type"}, StructuredBufferConcept)
666 .finalizeForwardDeclaration();
667 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
668 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/true,
669 /*RawBuffer=*/false, /*HasCounter=*/false)
674 });
675
676 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "StructuredBuffer")
677 .addSimpleTemplateParams({"element_type"}, StructuredBufferConcept)
678 .finalizeForwardDeclaration();
679 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
680 setupBufferType(Decl, *SemaPtr, ResourceClass::SRV, /*IsROV=*/false,
681 /*RawBuffer=*/true, /*HasCounter=*/false)
686 });
687
688 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "RWStructuredBuffer")
689 .addSimpleTemplateParams({"element_type"}, StructuredBufferConcept)
690 .finalizeForwardDeclaration();
691 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
692 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/false,
693 /*RawBuffer=*/true, /*HasCounter=*/true)
700 });
701
702 Decl =
703 BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "AppendStructuredBuffer")
704 .addSimpleTemplateParams({"element_type"}, StructuredBufferConcept)
705 .finalizeForwardDeclaration();
706 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
707 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/false,
708 /*RawBuffer=*/true, /*HasCounter=*/true)
712 });
713
714 Decl =
715 BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "ConsumeStructuredBuffer")
716 .addSimpleTemplateParams({"element_type"}, StructuredBufferConcept)
717 .finalizeForwardDeclaration();
718 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
719 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/false,
720 /*RawBuffer=*/true, /*HasCounter=*/true)
724 });
725
726 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace,
727 "RasterizerOrderedStructuredBuffer")
728 .addSimpleTemplateParams({"element_type"}, StructuredBufferConcept)
729 .finalizeForwardDeclaration();
730 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
731 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/true,
732 /*RawBuffer=*/true, /*HasCounter=*/true)
739 });
740
741 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "ByteAddressBuffer")
742 .finalizeForwardDeclaration();
743 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
744 setupBufferType(Decl, *SemaPtr, ResourceClass::SRV, /*IsROV=*/false,
745 /*RawBuffer=*/true, /*HasCounter=*/false)
749 });
750 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "RWByteAddressBuffer")
751 .finalizeForwardDeclaration();
752 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
753 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/false,
754 /*RawBuffer=*/true, /*HasCounter=*/false)
760 });
761 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace,
762 "RasterizerOrderedByteAddressBuffer")
763 .finalizeForwardDeclaration();
764 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
765 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/true,
766 /*RawBuffer=*/true, /*HasCounter=*/false)
770 });
771
772 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "SamplerState")
773 .finalizeForwardDeclaration();
774 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
775 setupSamplerType(Decl, *SemaPtr).completeDefinition();
776 });
777
778 Decl =
779 BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "SamplerComparisonState")
780 .finalizeForwardDeclaration();
781 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
782 setupSamplerType(Decl, *SemaPtr).completeDefinition();
783 });
784
785 QualType Float4Ty = AST.getExtVectorType(AST.FloatTy, 4);
786 for (const TextureTypeInfo &T : TextureTypes) {
787 BuiltinTypeDeclBuilder TexBuilder(*SemaPtr, HLSLNamespace, T.Name);
788 switch (T.Shape) {
789 case TemplateShape::ElementType:
790 TexBuilder.addSimpleTemplateParams({"element_type"}, {Float4Ty},
791 TypedBufferConcept);
792 break;
793 case TemplateShape::ElementTypeAndSampleCount:
794 TexBuilder.addMSTextureTemplateParams("element_type", "sample_count",
795 TypedBufferConcept);
796 break;
797 }
798 Decl = TexBuilder.finalizeForwardDeclaration();
799
800 onCompletion(Decl, [this, &T](CXXRecordDecl *Decl) {
801 setupTextureType(Decl, *SemaPtr, T).completeDefinition();
802 });
803
804 if (T.Shape != TemplateShape::ElementType)
805 continue;
806
807 CXXRecordDecl *PartialSpec = addVectorTexturePartialSpecialization(
808 *SemaPtr, HLSLNamespace, Decl->getDescribedClassTemplate());
809 onCompletion(PartialSpec, [this, &T](CXXRecordDecl *Decl) {
810 setupTextureType(Decl, *SemaPtr, T).completeDefinition();
811 });
812 }
813}
814
815// Build a single overload of an HLSL atomic intrinsic in the hlsl namespace.
816// `dest` is an address-space-qualified reference; `original_value` (when
817// present) is a plain reference. The synthesized FunctionDecl aliases the
818// underlying clang builtin via BuiltinAliasAttr.
819static void buildAtomicOverload(Sema &S, NamespaceDecl *NS, StringRef FuncName,
820 StringRef BuiltinName, QualType ElemTy,
821 LangAS DestAS, bool ThreeArg) {
822 ASTContext &AST = S.getASTContext();
823
824 QualType DestTy =
825 AST.getLValueReferenceType(AST.getAddrSpaceQualType(ElemTy, DestAS));
826 QualType OrigRefTy = AST.getLValueReferenceType(ElemTy);
827
828 SmallVector<QualType, 3> ParamTypes;
829 ParamTypes.push_back(DestTy);
830 ParamTypes.push_back(ElemTy);
831 if (ThreeArg)
832 ParamTypes.push_back(OrigRefTy);
833
835 QualType FuncTy = AST.getFunctionType(AST.VoidTy, ParamTypes, EPI);
836 auto *TSInfo = AST.getTrivialTypeSourceInfo(FuncTy, SourceLocation());
837
838 IdentifierInfo &FuncII = AST.Idents.get(FuncName, tok::TokenKind::identifier);
839 DeclarationName FuncDeclName(&FuncII);
840
842 AST, NS, SourceLocation(), SourceLocation(), FuncDeclName, FuncTy, TSInfo,
843 SC_Extern, /*UsesFPIntrin=*/false, /*isInlineSpecified=*/false,
844 /*hasWrittenPrototype=*/true);
845
846 constexpr const char *ParamNames[] = {"dest", "value", "original_value"};
848 unsigned I = 0;
849 for (auto [ParamType, ParamName] : llvm::zip(ParamTypes, ParamNames)) {
850 IdentifierInfo &PII = AST.Idents.get(ParamName, tok::TokenKind::identifier);
852 AST, FD, SourceLocation(), SourceLocation(), &PII, ParamType,
854 nullptr);
855 Parm->setScopeInfo(0, I++);
856 ParmDecls.push_back(Parm);
857 }
858 FD->setParams(ParmDecls);
859
860 IdentifierInfo &BuiltinII =
861 S.getPreprocessor().getIdentifierTable().get(BuiltinName);
862 FD->addAttr(BuiltinAliasAttr::CreateImplicit(AST, &BuiltinII));
863 FD->setImplicit();
864 NS->addDecl(FD);
865}
866
867// Synthesize the InterlockedFunc overload set: {int, uint, int64_t, uint64_t}
868// x {groupshared, device} x {2-arg, 3-arg}.
870 StringRef FuncName,
871 StringRef BuiltinName) {
872 ASTContext &AST = S.getASTContext();
873 // HLSL: int64_t == long, uint64_t == unsigned long (see hlsl_basic_types.h).
874 QualType Elems[] = {AST.IntTy, AST.UnsignedIntTy, AST.LongTy,
875 AST.UnsignedLongTy};
877
878 for (QualType ElemTy : Elems)
879 for (LangAS AS : AddrSpaces)
880 for (bool ThreeArg : {false, true})
881 buildAtomicOverload(S, NS, FuncName, BuiltinName, ElemTy, AS, ThreeArg);
882}
883
884void HLSLExternalSemaSource::defineHLSLAtomicIntrinsics() {
885 defineHLSLInterlockedFunc(*SemaPtr, HLSLNamespace, "InterlockedAdd",
886 "__builtin_hlsl_interlocked_add");
887 defineHLSLInterlockedFunc(*SemaPtr, HLSLNamespace, "InterlockedAnd",
888 "__builtin_hlsl_interlocked_and");
889 defineHLSLInterlockedFunc(*SemaPtr, HLSLNamespace, "InterlockedMin",
890 "__builtin_hlsl_interlocked_min");
891 defineHLSLInterlockedFunc(*SemaPtr, HLSLNamespace, "InterlockedOr",
892 "__builtin_hlsl_interlocked_or");
893 defineHLSLInterlockedFunc(*SemaPtr, HLSLNamespace, "InterlockedXor",
894 "__builtin_hlsl_interlocked_xor");
895}
896
897void HLSLExternalSemaSource::onCompletion(CXXRecordDecl *Record,
898 CompletionFunction Fn) {
899 if (!Record->isCompleteDefinition())
900 Completions.insert(std::make_pair(Record->getCanonicalDecl(), Fn));
901}
902
904 if (!isa<CXXRecordDecl>(Tag))
905 return;
906 auto *Record = cast<CXXRecordDecl>(Tag);
907 Record = Record->getCanonicalDecl();
908 auto It = Completions.find(Record);
909 if (It == Completions.end())
910 return;
911 // Move out the callback and erase before invoking it: the callback can
912 // re-enter CompleteType and mutate Completions, which invalidates It under
913 // backward-shift deletion.
914 CompletionFunction Fn = std::move(It->second);
915 Completions.erase(It);
916 Fn(Record);
917}
Defines the clang::ASTContext interface.
Provides definitions for the various language-specific address spaces.
llvm::dxil::ResourceClass ResourceClass
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
static BuiltinTypeDeclBuilder setupBufferType(CXXRecordDecl *Decl, Sema &S, ResourceClass RC, bool IsROV, bool RawBuffer, bool HasCounter)
Set up common members and attributes for buffer types.
static BuiltinTypeDeclBuilder setupTextureType(CXXRecordDecl *Decl, Sema &S, const TextureTypeInfo &T)
static void defineHLSLInterlockedFunc(Sema &S, NamespaceDecl *NS, StringRef FuncName, StringRef BuiltinName)
static BuiltinTypeDeclBuilder setupSamplerType(CXXRecordDecl *Decl, Sema &S)
Set up common members and attributes for sampler types.
static void buildAtomicOverload(Sema &S, NamespaceDecl *NS, StringRef FuncName, StringRef BuiltinName, QualType ElemTy, LangAS DestAS, bool ThreeArg)
static Expr * constructTypedBufferConstraintExpr(Sema &S, SourceLocation NameLoc, TemplateTypeParmDecl *T)
static ConceptDecl * constructBufferConceptDecl(Sema &S, NamespaceDecl *NSD, HLSLBufferType BT)
static const TextureTypeInfo TextureTypes[]
static Expr * constructConstantBufferConstraintExpr(Sema &S, SourceLocation NameLoc, TemplateTypeParmDecl *T)
static ClassTemplatePartialSpecializationDecl * addVectorTexturePartialSpecialization(Sema &S, NamespaceDecl *HLSLNamespace, ClassTemplateDecl *TextureTemplate)
static Expr * constructStructuredBufferConstraintExpr(Sema &S, SourceLocation NameLoc, TemplateTypeParmDecl *T)
llvm::MachO::Record Record
Definition MachO.h:31
Defines the clang::Preprocessor interface.
This file declares semantic analysis for HLSL constructs.
Defines the clang::SourceLocation class and associated facilities.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:223
TranslationUnitDecl * getTranslationUnitDecl() const
QualType getDependentSizedMatrixType(QualType ElementType, Expr *RowExpr, Expr *ColumnExpr, SourceLocation AttrLoc) const
Return the unique reference to the matrix type of the specified element type and size.
CanQualType LongTy
unsigned getIntWidth(QualType T) const
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
CanQualType FloatTy
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
IdentifierTable & Idents
Definition ASTContext.h:828
CanQualType BoolTy
CanQualType UnsignedLongTy
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
CanQualType IntTy
CanQualType VoidTy
CanQualType UnsignedIntTy
QualType getTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName T, ArrayRef< TemplateArgument > SpecifiedArgs, ArrayRef< TemplateArgument > CanonicalArgs, QualType Underlying=QualType()) const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getTemplateTypeParmType(int Depth, int Index, bool ParameterPack, TemplateTypeParmDecl *ParmDecl=nullptr) const
Retrieve the template type parameter type for a template parameter or parameter pack with the given d...
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 ...
QualType getDependentSizedExtVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc) const
A builtin binary operation expression such as "x + y" or "x <= y".
Definition Expr.h:4082
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
Definition Expr.cpp:5131
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
static CanQual< Type > CreateUnsafe(QualType Other)
Declaration of a class template.
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, llvm::FoldingSetInsertToken InsertToken)
Insert the specified partial specialization knowing that it is not already in.
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, CanQualType CanonInjectedTST, ClassTemplatePartialSpecializationDecl *PrevDecl)
Declaration of a C++20 concept.
static ConceptDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, Expr *ConstraintExpr=nullptr)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1466
void addDecl(Decl *D)
Add the declaration D into this context.
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
Definition DeclBase.h:2718
decl_iterator decls_begin() const
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)
Definition Expr.cpp:494
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
void addAttr(Attr *A)
void setImplicit(bool I=true)
Definition DeclBase.h:602
DeclContext * getDeclContext()
Definition DeclBase.h:456
The name of a declaration.
This represents one expression.
Definition Expr.h:113
Represents difference between two FPOptions values.
Represents a function declaration or definition.
Definition Decl.h:2059
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin=false, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=ConstexprSpecKind::Unspecified, const AssociatedConstraint &TrailingRequiresClause={})
Definition Decl.h:2303
void CompleteType(TagDecl *Tag) override
Complete an incomplete HLSL builtin type.
void InitializeSema(Sema &S) override
Initialize the semantic source with the Sema instance being used to perform semantic analysis on the ...
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 IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Definition Expr.cpp:981
Represents the results of name lookup.
Definition Lookup.h:147
Represent a C++ namespace.
Definition Decl.h:593
static NamespaceDecl * Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl, bool Nested)
Definition DeclCXX.cpp:3374
A C++ nested-name-specifier augmented with source location information.
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, int D, int P, const IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
Represents a parameter to a function.
Definition Decl.h:1820
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition Decl.h:1853
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Definition Decl.cpp:2945
IdentifierTable & getIdentifierTable()
A (possibly-)qualified type.
Definition TypeBase.h:938
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:863
@ LookupNamespaceName
Look up a namespace name within a C++ using directive or namespace alias definition,...
Definition Sema.h:9393
Preprocessor & getPreprocessor() const
Definition Sema.h:934
ASTContext & getASTContext() const
Definition Sema.h:935
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
const LangOptions & getLangOpts() const
Definition Sema.h:928
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
Encodes a location in the source.
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3852
A convenient class for passing around template argument information.
void addArgument(const TemplateArgumentLoc &Loc)
Location wrapper for a TemplateArgument.
Represents a template argument.
void setTemplateParameters(TemplateParameterList *TParams)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Declaration of a template type parameter.
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, int D, int P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, UnsignedOrNone NumExpanded=std::nullopt)
static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, TypeSourceInfo *TInfo)
Definition Decl.cpp:5881
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
A container of type source information.
Definition TypeBase.h:8472
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition ExprCXX.h:2900
static TypeTraitExpr * Create(const ASTContext &C, QualType T, SourceLocation Loc, TypeTrait Kind, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc, bool Value)
Create a new type trait expression.
Definition ExprCXX.cpp:1939
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
Definition Expr.h:2669
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2288
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
Definition Expr.cpp:5188
Represents a C++ using-declaration.
Definition DeclCXX.h:3620
static UsingDirectiveDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespaceLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor)
Definition DeclCXX.cpp:3330
Represents a GCC generic vector type.
Definition TypeBase.h:4289
BuiltinTypeDeclBuilder & addRWTextureLoadMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addDefaultHandleConstructor(AccessSpecifier Access=AccessSpecifier::AS_public)
BuiltinTypeDeclBuilder & addSampleGradMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addCopyAssignmentOperator(AccessSpecifier Access=AccessSpecifier::AS_public)
BuiltinTypeDeclBuilder & addGatherCmpMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addGetDimensionsMethodForBuffer()
BuiltinTypeDeclBuilder & addTextureLoadMSMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addConstantBufferConversionToType()
BuiltinTypeDeclBuilder & addTextureLoadMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addSampleBiasMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addBufferHandles(ResourceClass RC, bool IsROV, bool RawBuffer, bool HasCounter, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addByteAddressBufferStoreMethods()
BuiltinTypeDeclBuilder & addSampleMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addArraySubscriptOperators(ResourceDimension Dim=ResourceDimension::Unknown, bool IsArray=false)
BuiltinTypeDeclBuilder & addSampleLevelMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addCopyConstructor(AccessSpecifier Access=AccessSpecifier::AS_public)
BuiltinTypeDeclBuilder & addSampleCmpMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addMipsMember(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addByteAddressBufferLoadMethods()
BuiltinTypeDeclBuilder & addStaticInitializationFunctions(bool HasCounter)
BuiltinTypeDeclBuilder & addGatherMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addCalculateLodMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addGetDimensionsMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addByteAddressBufferInterlockedMethods()
BuiltinTypeDeclBuilder & addTextureHandle(ResourceClass RC, bool IsROV, bool IsArray, ResourceDimension RD, Expr *SampleCountExpr=nullptr, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addSampleCmpLevelZeroMethods(ResourceDimension Dim, bool IsArray=false)
MIPS builtins.
const internal::ArgumentAdaptingMatcherFunc< internal::HasMatcher > has
Matches AST nodes that have child AST nodes that match the provided matcher.
bool Load(InterpState &S, CodePtr OpPC)
Definition Interp.h:2203
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
Top level wrappers for InstallAPI frontend operations.
bool isa(CodeGen::Address addr)
Definition Address.h:330
@ OK_Ordinary
An ordinary object is located at an address in memory.
Definition Specifiers.h:152
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()
@ SC_Extern
Definition Specifiers.h:252
@ SC_None
Definition Specifiers.h:251
@ Default
Set to the current date and time.
@ Result
The result type of a method or function.
Definition TypeBase.h:906
const FunctionProtoType * T
@ Template
We are parsing a template declaration.
Definition Parser.h:81
LangAS
Defines the address space values used by the address space qualifier of QualType.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition Specifiers.h:136
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition Specifiers.h:140
U cast(CodeGen::Address addr)
Definition Address.h:327
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:6030
__packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 uint32_t
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
Extra information about a function prototype.
Definition TypeBase.h:5506