diff options
author | Helena Kotas <hekotas@microsoft.com> | 2024-09-16 19:35:24 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-16 19:35:24 -0700 |
commit | 5df1b79372a89648cdb4ab798f1c74985e00ac6e (patch) | |
tree | 25e77b0902805dc04b136ad3b7ce5dbaa02af078 /clang/lib/Sema/HLSLExternalSemaSource.cpp | |
parent | 8982f9854f1fc6c3ade8c01f992fc49bf41f89b9 (diff) | |
download | llvm-5df1b79372a89648cdb4ab798f1c74985e00ac6e.zip llvm-5df1b79372a89648cdb4ab798f1c74985e00ac6e.tar.gz llvm-5df1b79372a89648cdb4ab798f1c74985e00ac6e.tar.bz2 |
[HLSL] Add `[[hlsl::raw_buffer]]` attribute (#107954)
This PR introduces new HLSL resource type attribute
`[[hlsl::raw_buffer]]`. Presence of this attribute on a resource handle
means that the resource does not require typed element access. The
attribute will be used on resource handles that represent buffers like
`StructuredBuffer` or `ByteAddressBuffer` and in DXIL it will be
translated to target extension type `dx.RawBuffer`.
Fixes #107907
Diffstat (limited to 'clang/lib/Sema/HLSLExternalSemaSource.cpp')
-rw-r--r-- | clang/lib/Sema/HLSLExternalSemaSource.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp b/clang/lib/Sema/HLSLExternalSemaSource.cpp index 444303d..d19f79b 100644 --- a/clang/lib/Sema/HLSLExternalSemaSource.cpp +++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp @@ -112,6 +112,7 @@ struct BuiltinTypeDeclBuilder { BuiltinTypeDeclBuilder & addHandleMember(Sema &S, ResourceClass RC, ResourceKind RK, bool IsROV, + bool RawBuffer, AccessSpecifier Access = AccessSpecifier::AS_private) { if (Record->isCompleteDefinition()) return *this; @@ -135,10 +136,11 @@ struct BuiltinTypeDeclBuilder { SmallVector<const Attr *> Attrs = { HLSLResourceClassAttr::CreateImplicit(Record->getASTContext(), RC), IsROV ? HLSLROVAttr::CreateImplicit(Record->getASTContext()) : nullptr, + RawBuffer ? HLSLRawBufferAttr::CreateImplicit(Record->getASTContext()) + : nullptr, ElementTypeInfo ? HLSLContainedTypeAttr::CreateImplicit( Record->getASTContext(), ElementTypeInfo) - : nullptr, - }; + : nullptr}; Attr *ResourceAttr = HLSLResourceAttr::CreateImplicit(Record->getASTContext(), RK); if (CreateHLSLAttributedResourceType(S, Ty, Attrs, AttributedResTy)) @@ -507,9 +509,9 @@ void HLSLExternalSemaSource::defineTrivialHLSLTypes() { /// Set up common members and attributes for buffer types static BuiltinTypeDeclBuilder setupBufferType(CXXRecordDecl *Decl, Sema &S, ResourceClass RC, ResourceKind RK, - bool IsROV) { + bool IsROV, bool RawBuffer) { return BuiltinTypeDeclBuilder(Decl) - .addHandleMember(S, RC, RK, IsROV) + .addHandleMember(S, RC, RK, IsROV, RawBuffer) .addDefaultHandleConstructor(S, RC); } @@ -522,7 +524,7 @@ void HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() { onCompletion(Decl, [this](CXXRecordDecl *Decl) { setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, ResourceKind::TypedBuffer, - /*IsROV=*/false) + /*IsROV=*/false, /*RawBuffer=*/false) .addArraySubscriptOperators() .completeDefinition(); }); @@ -533,7 +535,8 @@ void HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() { .Record; onCompletion(Decl, [this](CXXRecordDecl *Decl) { setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, - ResourceKind::TypedBuffer, /*IsROV=*/true) + ResourceKind::TypedBuffer, /*IsROV=*/true, + /*RawBuffer=*/false) .addArraySubscriptOperators() .completeDefinition(); }); @@ -543,7 +546,8 @@ void HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() { .Record; onCompletion(Decl, [this](CXXRecordDecl *Decl) { setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, - ResourceKind::TypedBuffer, /*IsROV=*/false) + ResourceKind::TypedBuffer, /*IsROV=*/false, + /*RawBuffer=*/true) .addArraySubscriptOperators() .completeDefinition(); }); |