Skip to content

Commit b7060d0

Browse files
committed
[DirectX] Fix printing of DXIL cbuffer info (#128698)
Make sure we're able to print cbuffer comments in a way that's compatible with DXC. Fixes #128562 Note: This is a re-commit because I somehow managed to get a completely empty commit the first time.
1 parent 1b39328 commit b7060d0

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ struct FormatResourceDimension
164164
case dxil::ResourceKind::TypedBuffer:
165165
OS << "buf";
166166
break;
167+
case dxil::ResourceKind::CBuffer:
168+
OS << "NA";
169+
break;
167170
case dxil::ResourceKind::RTAccelerationStructure:
168171
// TODO: dxc would print "ras" here. Can/should this happen?
169172
llvm_unreachable("RTAccelerationStructure printing is not implemented");

llvm/test/CodeGen/DirectX/CreateHandleFromBinding.ll

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
; CHECK-PRETTY: SRV u32 buf T3 t3,space5 24
1010
; CHECK-PRETTY: UAV i32 buf U0 u7,space2 1
1111
; CHECK-PRETTY: UAV f32 buf U1 u5,space3 1
12+
; CHECK-PRETTY: cbuffer NA NA CB0 cb0 1
1213

1314
target triple = "dxil-pc-shadermodel6.6-compute"
1415

@@ -63,6 +64,12 @@ define void @test_bindings() {
6364
; CHECK: [[BUF5:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 7, i32 -1, i32 0, i8 0 }, i32 %[[IX]], i1 false) #[[#ATTR]]
6465
; CHECK: call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BUF5]], %dx.types.ResourceProperties { i32 10, i32 1033 }) #[[#ATTR]]
6566

67+
; cbuffer cb0 : register(b0) { int4 i; float4 f; }
68+
%cb0 = call target("dx.CBuffer", target("dx.Layout", {<4 x i32>, <4 x float>}, 32, 0, 16))
69+
@llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 1, i32 0, i1 false)
70+
; CHECK: [[BUF6:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 0, i32 0, i32 0, i8 2 }, i32 0, i1 false) #[[#ATTR]]
71+
; CHECK: call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BUF6]], %dx.types.ResourceProperties { i32 13, i32 32 }) #[[#ATTR]]
72+
6673
ret void
6774
}
6875

@@ -72,8 +79,9 @@ define void @test_bindings() {
7279
; contents of the metadata are tested elsewhere.
7380
;
7481
; CHECK: !dx.resources = !{[[RESMD:![0-9]+]]}
75-
; CHECK: [[RESMD]] = !{[[SRVMD:![0-9]+]], [[UAVMD:![0-9]+]], null, null}
82+
; CHECK: [[RESMD]] = !{[[SRVMD:![0-9]+]], [[UAVMD:![0-9]+]], [[CBUFMD:![0-9]+]], null}
7683
; CHECK-DAG: [[SRVMD]] = !{!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}}
7784
; CHECK-DAG: [[UAVMD]] = !{!{{[0-9]+}}, !{{[0-9]+}}}
85+
; CHECK-DAG: [[CBUFMD]] = !{!{{[0-9]+}}}
7886

7987
attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }

0 commit comments

Comments
 (0)