[PATCH] D136307: [DirectX backend] support unbound resource.
Xiang Li via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 21 15:44:11 PDT 2022
python3kgae updated this revision to Diff 469806.
python3kgae added a comment.
Rebase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136307/new/
https://reviews.llvm.org/D136307
Files:
llvm/lib/Target/DirectX/DXILResource.cpp
llvm/test/CodeGen/DirectX/UAVMetadata.ll
Index: llvm/test/CodeGen/DirectX/UAVMetadata.ll
===================================================================
--- llvm/test/CodeGen/DirectX/UAVMetadata.ll
+++ llvm/test/CodeGen/DirectX/UAVMetadata.ll
@@ -12,16 +12,17 @@
; PRINT-NEXT:;
; PRINT-NEXT:; Name Type Format Dim ID HLSL Bind Count
; PRINT-NEXT:; ------------------------------ ---------- ------- ----------- ------- -------------- ------
-; PRINT-NEXT:; UAV f16 buf U0 u0 1
-; PRINT-NEXT:; UAV f32 buf U1 u1 1
-; PRINT-NEXT:; UAV f64 buf U2 u2 1
-; PRINT-NEXT:; UAV i1 buf U3 u3 2
-; PRINT-NEXT:; UAV byte r/w U4 u5 1
-; PRINT-NEXT:; UAV struct r/w U5 u6 1
-; PRINT-NEXT:; UAV i32 buf U6 u7 1
-; PRINT-NEXT:; UAV struct r/w U7 u8 1
-; PRINT-NEXT:; UAV byte r/w U8 u9 1
-; PRINT-NEXT:; UAV u64 buf U9 u10,space2 1
+; PRINT-NEXT:; UAV f16 buf U0 u0 1
+; PRINT-NEXT:; UAV f32 buf U1 u1 1
+; PRINT-NEXT:; UAV f64 buf U2 u2 1
+; PRINT-NEXT:; UAV i1 buf U3 u3 2
+; PRINT-NEXT:; UAV byte r/w U4 u5 1
+; PRINT-NEXT:; UAV struct r/w U5 u6 1
+; PRINT-NEXT:; UAV i32 buf U6 u7 1
+; PRINT-NEXT:; UAV struct r/w U7 u8 1
+; PRINT-NEXT:; UAV byte r/w U8 u9 1
+; PRINT-NEXT:; UAV u64 buf U9 u10,space2 1
+; PRINT-NEXT:; UAV u64 buf U10 u11 unbounded
@Zero = local_unnamed_addr global %"class.hlsl::RWBuffer" zeroinitializer, align 4
@One = local_unnamed_addr global %"class.hlsl::RWBuffer" zeroinitializer, align 4
@@ -33,9 +34,10 @@
@Seven = local_unnamed_addr global %"class.hlsl::RWBuffer" zeroinitializer, align 4
@Eight = local_unnamed_addr global %"class.hlsl::RWBuffer" zeroinitializer, align 4
@Nine = local_unnamed_addr global %"class.hlsl::RWBuffer" zeroinitializer, align 4
+ at Ten = local_unnamed_addr global [0 x %"class.hlsl::RWBuffer"] zeroinitializer, align 4
-!hlsl.uavs = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9}
+!hlsl.uavs = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10}
!0 = !{ptr @Zero, !"RWBuffer<half>", i32 10, i32 0, i32 0}
!1 = !{ptr @One, !"Buffer<vector<float,4>>", i32 10, i32 1, i32 0}
@@ -47,6 +49,7 @@
!7 = !{ptr @Seven, !"RasterizerOrderedStructuredBuffer<uint32_t>", i32 12, i32 8, i32 0}
!8 = !{ptr @Eight, !"RasterizerOrderedByteAddressBuffer<int64_t>", i32 11, i32 9, i32 0}
!9 = !{ptr @Nine, !"RWBuffer<uint64_t>", i32 10, i32 10, i32 2}
+!10 = !{ptr @Ten, !"RWBuffer<uint64_t>", i32 10, i32 11, i32 0}
; CHECK: !dx.resources = !{[[ResList:[!][0-9]+]]}
@@ -54,7 +57,7 @@
; CHECK: [[UAVList]] = !{[[Zero:[!][0-9]+]], [[One:[!][0-9]+]],
; CHECK-SAME: [[Two:[!][0-9]+]], [[Three:[!][0-9]+]], [[Four:[!][0-9]+]],
; CHECK-SAME: [[Five:[!][0-9]+]], [[Six:[!][0-9]+]], [[Seven:[!][0-9]+]],
-; CHECK-SAME: [[Eight:[!][0-9]+]], [[Nine:[!][0-9]+]]}
+; CHECK-SAME: [[Eight:[!][0-9]+]], [[Nine:[!][0-9]+]], [[Ten:[!][0-9]+]]}
; CHECK: [[Zero]] = !{i32 0, ptr @Zero, !"", i32 0, i32 0, i32 1, i32 10, i1 false, i1 false, i1 false, [[Half:[!][0-9]+]]}
; CHECK: [[Half]] = !{i32 0, i32 8}
; CHECK: [[One]] = !{i32 1, ptr @One, !"", i32 0, i32 1, i32 1, i32 10, i1 false, i1 false, i1 false, [[Float:[!][0-9]+]]}
@@ -75,3 +78,4 @@
; CHECK: [[I64]] = !{i32 0, i32 6}
; CHECK: [[Nine]] = !{i32 9, ptr @Nine, !"", i32 2, i32 10, i32 1, i32 10, i1 false, i1 false, i1 false, [[U64:[!][0-9]+]]}
; CHECK: [[U64]] = !{i32 0, i32 7}
+; CHECK: [[Ten]] = !{i32 10, ptr @Ten, !"", i32 0, i32 11, i32 -1, i32 10, i1 false, i1 false, i1 false, [[U64]]}
Index: llvm/lib/Target/DirectX/DXILResource.cpp
===================================================================
--- llvm/lib/Target/DirectX/DXILResource.cpp
+++ llvm/lib/Target/DirectX/DXILResource.cpp
@@ -39,7 +39,7 @@
: ID(I), GV(R.getGlobalVariable()), Name(""), Space(R.getSpace()),
LowerBound(R.getResourceIndex()), RangeSize(1) {
if (auto *ArrTy = dyn_cast<ArrayType>(GV->getInitializer()->getType()))
- RangeSize = ArrTy->getNumElements();
+ RangeSize = ArrTy->getNumElements() ? ArrTy->getNumElements() : -1;
}
StringRef ResourceBase::getComponentTypeName(ComponentType CompType) {
@@ -204,9 +204,9 @@
OS << right_justify(Bind, 15);
if (RangeSize != UINT_MAX)
- OS << right_justify(std::to_string(RangeSize), 6) << "\n";
+ OS << right_justify(std::to_string(RangeSize), 10) << "\n";
else
- OS << right_justify("unbounded", 6) << "\n";
+ OS << right_justify("unbounded", 10) << "\n";
}
UAVResource::UAVResource(uint32_t I, FrontendResource R)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136307.469806.patch
Type: text/x-patch
Size: 5891 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221021/ee822fb6/attachment.bin>
More information about the llvm-commits
mailing list