[llvm] [DirectX] Add support for heap resources to `DXILResourceMap` (PR #216454)

Helena Kotas via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 18 12:57:56 PDT 2026


================
@@ -0,0 +1,175 @@
+; RUN: opt -S -disable-output -passes="print<dxil-resources>" < %s 2>&1 | FileCheck %s
+
+%struct.S = type { <4 x float>, <4 x i32> }
+%P = type <{ float }>
+%Q = type <{ <{ [2 x <{ float, target("dx.Padding", 12) }>], float }> }>
+
+; The resources in this test are created in the same order as they appear after
+; sorting in the ResourceInfo list because FileCheck cannot match multiline sections
+; of text in arbitrary order.
+
+define void @test_typedbuffer() {
+
+  %idx = tail call i32 @llvm.dx.thread.id.in.group(i32 0)
+
+  ; Buffer<uint4> Buf2 = ResourceDescriptorHeap[ID.x + 1];
+  %add0 = add i32 %idx, 1
+  %srv0 = tail call target("dx.TypedBuffer", <4 x i32>, 0, 0, 0)
+      @llvm.dx.resource.handlefromheap.tdx.TypedBuffer_v4i32_0_0_0t(i32 %add0, i1 false)
+; CHECK: Resource [[SRV0:0]]:
+; CHECK-NEXT:   HeapIndexID: {{[0-9]+}}
+; CHECK-NEXT:   Globally Coherent: 0
+; CHECK-NEXT:   Has Atomic64 Use: 0
+; CHECK-NEXT:   Counter Direction: Unknown
+; CHECK-NEXT:   Class: SRV
+; CHECK-NEXT:   Kind: Buffer
+; CHECK-NEXT:   Element Type: u32
+; CHECK-NEXT:   Element Count: 4
+
+  ; ByteAddressBuffer Buf0 = ResourceDescriptorHeap[5];
+  %srv1 = tail call target("dx.RawBuffer", i8, 0, 0)
+      @llvm.dx.resource.handlefromheap.tdx.RawBuffer_i8_0_0t(i32 5, i1 false)
+; CHECK: Resource [[SRV1:1]]:
+; CHECK-NEXT:   HeapIndexID: {{[0-9]+}}
+; CHECK-NEXT:   Globally Coherent: 0
+; CHECK-NEXT:   Has Atomic64 Use: 0
+; CHECK-NEXT:   Counter Direction: Unknown
+; CHECK-NEXT:   Class: SRV
+; CHECK-NEXT:   Kind: RawBuffer
+
+  ; struct S { float4 a; uint4 b; };
+  ; StructuredBuffer<S> Buf1 = ResourceDescriptorHeap[ID.x];
+  %srv2 = tail call target("dx.RawBuffer", %struct.S, 0, 0)
+      @llvm.dx.resource.handlefromheap.tdx.RawBuffer_s_struct.Ss_0_0t(i32 %idx, i1 false)
+; CHECK-DAG: Resource [[SRV2:2]]:
+; CHECK: HeapIndexID: {{[0-9]+}}
+; CHECK-NEXT:   Globally Coherent: 0
+; CHECK-NEXT:   Has Atomic64 Use: 0
+; CHECK-NEXT:   Counter Direction: Unknown
+; CHECK-NEXT:   Class: SRV
+; CHECK-NEXT:   Kind: StructuredBuffer
+; CHECK-NEXT:   Buffer Stride: 32
+; CHECK-NEXT:   Alignment: 4
+
+; Make sure this was the last SRV resource in the list.
+; CHECK-NOT: Class: SRV
+
+  ; RWBuffer<int> Buf3 = ResourceDescriptorHeap[ID.x + 2];
+  %add2 = add i32 %idx, 2
+  %uav0 = tail call target("dx.TypedBuffer", i32, 1, 0, 1)
+      @llvm.dx.resource.handlefromheap.tdx.TypedBuffer_i32_1_0_1t(i32 %add2, i1 false)
+; CHECK: Resource [[UAV0:3]]:
+; CHECK-NEXT:   HeapIndexID: 7
----------------
hekota wrote:

No, these should all be regexes.

https://github.com/llvm/llvm-project/pull/216454


More information about the llvm-commits mailing list