[PATCH] D135335: [HLSL] Add Resource kind for HLSLResourceAttr.
Xiang Li via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 5 17:35:56 PDT 2022
python3kgae created this revision.
python3kgae added reviewers: beanz, pow2clk, bogner.
Herald added a reviewer: aaron.ballman.
Herald added a subscriber: Anastasia.
Herald added a project: All.
python3kgae requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
A new EnumArgument ResourceKind is added for HLSLResourceAttr.
This will be use to get resource kind instead of parse it from the type name.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D135335
Files:
clang/include/clang/Basic/Attr.td
clang/lib/Sema/HLSLExternalSemaSource.cpp
clang/test/AST/HLSL/RWBuffer-AST.hlsl
Index: clang/test/AST/HLSL/RWBuffer-AST.hlsl
===================================================================
--- clang/test/AST/HLSL/RWBuffer-AST.hlsl
+++ clang/test/AST/HLSL/RWBuffer-AST.hlsl
@@ -38,7 +38,7 @@
// CHECK-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit class RWBuffer definition
// CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final
-// CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit UAV
+// CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit UAV TypedBuffer
// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit h 'element_type *'
// CHECK: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> operator[] 'element_type &const (unsigned int) const'
@@ -66,5 +66,5 @@
// CHECK: TemplateArgument type 'float'
// CHECK-NEXT: BuiltinType 0x{{[0-9A-Fa-f]+}} 'float'
// CHECK-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final
-// CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit UAV
+// CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit UAV TypedBuffer
// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit referenced h 'float *'
Index: clang/lib/Sema/HLSLExternalSemaSource.cpp
===================================================================
--- clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -116,11 +116,12 @@
}
BuiltinTypeDeclBuilder &
- annotateResourceClass(HLSLResourceAttr::ResourceClass RC) {
+ annotateResourceClass(HLSLResourceAttr::ResourceClass RC,
+ HLSLResourceAttr::ResourceKind RK) {
if (Record->isCompleteDefinition())
return *this;
Record->addAttr(
- HLSLResourceAttr::CreateImplicit(Record->getASTContext(), RC));
+ HLSLResourceAttr::CreateImplicit(Record->getASTContext(), RC, RK));
return *this;
}
@@ -501,6 +502,7 @@
.addHandleMember()
.addDefaultHandleConstructor(*SemaPtr, ResourceClass::UAV)
.addArraySubscriptOperators()
- .annotateResourceClass(HLSLResourceAttr::UAV)
+ .annotateResourceClass(HLSLResourceAttr::UAV,
+ HLSLResourceAttr::TypedBuffer)
.completeDefinition();
}
Index: clang/include/clang/Basic/Attr.td
===================================================================
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -4037,7 +4037,24 @@
let Args = [EnumArgument<"ResourceType", "ResourceClass",
["SRV", "UAV", "CBuffer", "Sampler"],
["SRV", "UAV", "CBuffer", "Sampler"]
- >];
+ >,
+ EnumArgument<"ResourceShape", "ResourceKind",
+ ["Texture1D", "Texture2D", "Texture2DMS",
+ "Texture3D", "TextureCube", "Texture1DArray",
+ "Texture2DArray", "Texture2DMSArray",
+ "TextureCubeArray", "TypedBuffer", "RawBuffer",
+ "StructuredBuffer", "CBufferKind", "SamplerKind",
+ "TBuffer", "RTAccelerationStructure", "FeedbackTexture2D",
+ "FeedbackTexture2DArray"],
+ ["Texture1D", "Texture2D", "Texture2DMS",
+ "Texture3D", "TextureCube", "Texture1DArray",
+ "Texture2DArray", "Texture2DMSArray",
+ "TextureCubeArray", "TypedBuffer", "RawBuffer",
+ "StructuredBuffer", "CBufferKind", "SamplerKind",
+ "TBuffer", "RTAccelerationStructure", "FeedbackTexture2D",
+ "FeedbackTexture2DArray"]
+ >
+ ];
let Documentation = [InternalOnly];
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135335.465620.patch
Type: text/x-patch
Size: 3996 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221006/92b276cd/attachment.bin>
More information about the cfe-commits
mailing list