aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/HLSLExternalSemaSource.cpp
diff options
context:
space:
mode:
authorJoshua Batista <jbatista@microsoft.com>2024-07-12 13:10:34 -0700
committerGitHub <noreply@github.com>2024-07-12 13:10:34 -0700
commit5dc371e289584928345f74f560a18a805226b5f8 (patch)
tree7640d9ee590a268b941573d8ca6a93a51f911b08 /clang/lib/Sema/HLSLExternalSemaSource.cpp
parenteb27256850ad792a287a8547c88410b7cf1bcb42 (diff)
downloadllvm-5dc371e289584928345f74f560a18a805226b5f8.zip
llvm-5dc371e289584928345f74f560a18a805226b5f8.tar.gz
llvm-5dc371e289584928345f74f560a18a805226b5f8.tar.bz2
[HLSL] Split out resource class data from resource attribute (#98419)
The ability to spell out and specify the resource class is necessary for testing various resource binding behaviors. Though it is not intended for users to use this in customized HLSL source code, the ability to specify the resource class via an attribute is immensely helpful for writing thorough tests. This PR introduces a new attribute, hlsl::resource_attribute, that can only be applied on structs. This attribute only has 1 required argument, and must be one of: ``` SRV UAV CBuffer Sampler ``` By applying this attribute to a struct, the struct will have the `HLSLResourceClassAttr` attribute attached to it in the AST representation, which provides information on the type of resource class the struct is meant to be. The resource class data that was originally contained within the `HLSLResourceAttr` attribute has been removed in favor of this new attribute, and so certain ast-dump tests need to be modified so that the same information can be represented via 2 attributes instead of one. Fixes #98193 --------- Co-authored-by: Damyan Pepper <damyanp@microsoft.com>
Diffstat (limited to 'clang/lib/Sema/HLSLExternalSemaSource.cpp')
-rw-r--r--clang/lib/Sema/HLSLExternalSemaSource.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp b/clang/lib/Sema/HLSLExternalSemaSource.cpp
index a2b29a7..7fcf575 100644
--- a/clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -115,12 +115,14 @@ struct BuiltinTypeDeclBuilder {
return addMemberVariable("h", Ty, Access);
}
- BuiltinTypeDeclBuilder &annotateResourceClass(ResourceClass RC,
- ResourceKind RK, bool IsROV) {
+ BuiltinTypeDeclBuilder &annotateHLSLResource(ResourceClass RC,
+ ResourceKind RK, bool IsROV) {
if (Record->isCompleteDefinition())
return *this;
- Record->addAttr(HLSLResourceAttr::CreateImplicit(Record->getASTContext(),
- RC, RK, IsROV));
+ Record->addAttr(
+ HLSLResourceClassAttr::CreateImplicit(Record->getASTContext(), RC));
+ Record->addAttr(
+ HLSLResourceAttr::CreateImplicit(Record->getASTContext(), RK, IsROV));
return *this;
}
@@ -171,7 +173,6 @@ struct BuiltinTypeDeclBuilder {
DeclRefExpr *Fn =
lookupBuiltinFunction(AST, S, "__builtin_hlsl_create_handle");
-
Expr *RCExpr = emitResourceClassExpr(AST, RC);
Expr *Call = CallExpr::Create(AST, Fn, {RCExpr}, AST.VoidPtrTy, VK_PRValue,
SourceLocation(), FPOptionsOverride());
@@ -496,7 +497,7 @@ static BuiltinTypeDeclBuilder setupBufferType(CXXRecordDecl *Decl, Sema &S,
return BuiltinTypeDeclBuilder(Decl)
.addHandleMember()
.addDefaultHandleConstructor(S, RC)
- .annotateResourceClass(RC, RK, IsROV);
+ .annotateHLSLResource(RC, RK, IsROV);
}
void HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() {