11; RUN: opt -S -dxil-translate-metadata < %s | FileCheck %s
22; RUN: opt -S --passes="dxil-pretty-printer" < %s 2>&1 | FileCheck %s --check-prefix=PRINT
3- ; RUN: llc %s --filetype=asm -o - < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,PRINT
3+ ; RUN: llc %s --filetype=asm -o - 2>&1 | FileCheck %s --check-prefixes=CHECK,PRINT
44
55target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
66target triple = "dxil-pc-shadermodel6.6-compute"
@@ -17,23 +17,25 @@ target triple = "dxil-pc-shadermodel6.6-compute"
1717@Nine.str = private unnamed_addr constant [5 x i8 ] c "Nine\00 " , align 1
1818@Ten.str = private unnamed_addr constant [4 x i8 ] c "Ten\00 " , align 1
1919@Array.str = private unnamed_addr constant [6 x i8 ] c "Array\00 " , align 1
20+ @Array2.str = private unnamed_addr constant [7 x i8 ] c "Array2\00 " , align 1
2021
2122; PRINT:; Resource Bindings:
2223; PRINT-NEXT:;
23- ; PRINT-NEXT:; Name Type Format Dim ID HLSL Bind Count
24- ; PRINT-NEXT:; ------------------------------ ---------- ------- ----------- ------- -------------- ------
25- ; PRINT-NEXT:; Zero UAV f16 buf U0 u0 1
26- ; PRINT-NEXT:; One UAV f32 buf U1 u1 1
27- ; PRINT-NEXT:; Two UAV f64 buf U2 u2 1
28- ; PRINT-NEXT:; Three UAV i32 buf U3 u3 1
29- ; PRINT-NEXT:; Four UAV byte r/w U4 u5 1
30- ; PRINT-NEXT:; Five UAV struct r/w U5 u6 1
31- ; PRINT-NEXT:; Six UAV i32 buf U6 u7 1
32- ; PRINT-NEXT:; Seven UAV struct r/w U7 u8 1
33- ; PRINT-NEXT:; Eight UAV byte r/w U8 u9 1
34- ; PRINT-NEXT:; Nine UAV u64 buf U9 u10,space2 1
35- ; PRINT-NEXT:; Array UAV f32 buf U10 u4,space3 100
36- ; PRINT-NEXT:; Ten UAV u64 buf U11 u22,space5 1
24+ ; PRINT-NEXT:; Name Type Format Dim ID HLSL Bind Count
25+ ; PRINT-NEXT:; ------------------------------ ---------- ------- ----------- ------- -------------- ---------
26+ ; PRINT-NEXT:; Zero UAV f16 buf U0 u0 1
27+ ; PRINT-NEXT:; One UAV f32 buf U1 u1 1
28+ ; PRINT-NEXT:; Two UAV f64 buf U2 u2 1
29+ ; PRINT-NEXT:; Three UAV i32 buf U3 u3 1
30+ ; PRINT-NEXT:; Four UAV byte r/w U4 u5 1
31+ ; PRINT-NEXT:; Five UAV struct r/w U5 u6 1
32+ ; PRINT-NEXT:; Six UAV i32 buf U6 u7 1
33+ ; PRINT-NEXT:; Seven UAV struct r/w U7 u8 1
34+ ; PRINT-NEXT:; Eight UAV byte r/w U8 u9 1
35+ ; PRINT-NEXT:; Nine UAV u64 buf U9 u10,space2 1
36+ ; PRINT-NEXT:; Array UAV f32 buf U10 u4,space3 100
37+ ; PRINT-NEXT:; Array2 UAV f64 buf U11 u2,space4 unbounded
38+ ; PRINT-NEXT:; Ten UAV u64 buf U12 u22,space5 1
3739
3840define void @test () #0 {
3941 ; RWBuffer<half4> Zero : register(u0)
@@ -78,13 +80,22 @@ define void @test() #0 {
7880
7981 ; RWBuffer<float4> Array[100] : register(u4, space3);
8082 ; RWBuffer<float4> B1 = Array[30];
81- ; RWBuffer<float4> B1 = Array[42];
83+ ; RWBuffer<float4> B2 = Array[42];
8284 ; resource array accesses should produce one metadata entry
8385 %Array_30_h = call target ("dx.TypedBuffer" , <4 x float >, 1 , 0 , 0 )
8486 @llvm.dx.resource.handlefrombinding (i32 3 , i32 4 , i32 100 , i32 30 , i1 false , ptr @Array.str )
8587 %Array_42_h = call target ("dx.TypedBuffer" , <4 x float >, 1 , 0 , 0 )
8688 @llvm.dx.resource.handlefrombinding (i32 3 , i32 4 , i32 100 , i32 42 , i1 false , ptr @Array.str )
8789
90+ ; test unbounded resource array
91+ ; RWBuffer<double> Array2[] : register(u2, space4);
92+ ; RWBuffer<double> C1 = Array[10];
93+ ; RWBuffer<double> C2 = Array[20];
94+ %Array2_10_h = call target ("dx.TypedBuffer" , double , 1 , 0 , 0 )
95+ @llvm.dx.resource.handlefrombinding (i32 4 , i32 2 , i32 -1 , i32 10 , i1 false , ptr @Array2.str )
96+ %Array2_20_h = call target ("dx.TypedBuffer" , double , 1 , 0 , 0 )
97+ @llvm.dx.resource.handlefrombinding (i32 4 , i32 2 , i32 -1 , i32 20 , i1 false , ptr @Array2.str )
98+
8899 ; Same buffer type as Nine - should have the same type in metadata
89100 ; RWBuffer<double> Ten : register(u2);
90101 %Ten_h = call target ("dx.TypedBuffer" , i64 , 1 , 0 , 0 )
@@ -118,6 +129,7 @@ attributes #0 = { noinline nounwind "hlsl.shader"="compute" }
118129; CHECK: @Eight = external constant %RasterizerOrderedByteAddressBuffer
119130; CHECK: @Nine = external constant %"RWBuffer<uint32_t>"
120131; CHECK: @Array = external constant %"RWBuffer<float4>"
132+ ; CHECK: @Array2 = external constant %"RWBuffer<double>"
121133; CHECK: @Ten = external constant %"RWBuffer<uint32_t>"
122134
123135; CHECK: !dx.resources = !{[[ResList:[!][0-9]+]]}
@@ -126,7 +138,7 @@ attributes #0 = { noinline nounwind "hlsl.shader"="compute" }
126138; CHECK: [[UAVList]] = !{![[Zero:[0-9]+]], ![[One:[0-9]+]], ![[Two:[0-9]+]],
127139; CHECK-SAME: ![[Three:[0-9]+]], ![[Four:[0-9]+]], ![[Five:[0-9]+]],
128140; CHECK-SAME: ![[Six:[0-9]+]], ![[Seven:[0-9]+]], ![[Eight:[0-9]+]],
129- ; CHECK-SAME: ![[Nine:[0-9]+]], ![[Array:[0-9]+]], ![[Ten:[0-9]+]]}
141+ ; CHECK-SAME: ![[Nine:[0-9]+]], ![[Array:[0-9]+]], ![[Array2:[0-9]+]], ![[ Ten:[0-9]+]]}
130142
131143; CHECK: ![[Zero]] = !{i32 0, ptr @Zero, !"Zero", i32 0, i32 0, i32 1, i32 10, i1 false, i1 false, i1 false, ![[Half:[0-9]+]]}
132144; CHECK: ![[Half]] = !{i32 0, i32 8}
@@ -146,4 +158,5 @@ attributes #0 = { noinline nounwind "hlsl.shader"="compute" }
146158; CHECK: ![[Nine]] = !{i32 9, ptr @Nine, !"Nine", i32 2, i32 10, i32 1, i32 10, i1 false, i1 false, i1 false, ![[U64:[0-9]+]]}
147159; CHECK: ![[U64]] = !{i32 0, i32 7}
148160; CHECK: ![[Array]] = !{i32 10, ptr @Array, !"Array", i32 3, i32 4, i32 100, i32 10, i1 false, i1 false, i1 false, ![[Float]]}
149- ; CHECK: ![[Ten]] = !{i32 11, ptr @Ten, !"Ten", i32 5, i32 22, i32 1, i32 10, i1 false, i1 false, i1 false, ![[U64:[0-9]+]]}
161+ ; CHECK: ![[Array2]] = !{i32 11, ptr @Array2, !"Array2", i32 4, i32 2, i32 -1, i32 10, i1 false, i1 false, i1 false, ![[Double]]}
162+ ; CHECK: ![[Ten]] = !{i32 12, ptr @Ten, !"Ten", i32 5, i32 22, i32 1, i32 10, i1 false, i1 false, i1 false, ![[U64:[0-9]+]]}
0 commit comments