|
5 | 5 | target 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"
|
6 | 6 | target triple = "dxil-pc-shadermodel6.6-compute"
|
7 | 7 |
|
8 |
| -%"class.hlsl::Buffer" = type { target("dx.TypedBuffer", <4 x half>, 0, 0, 0) } |
9 |
| -%"class.hlsl::Buffer.1" = type { target("dx.TypedBuffer", <2 x float>, 0, 0, 0) } |
10 |
| -%"class.hlsl::Buffer.2" = type { target("dx.TypedBuffer", double, 0, 0, 0) } |
11 |
| -%"class.hlsl::Buffer.3" = type { target("dx.TypedBuffer", i32, 0, 0, 1) } |
12 |
| -%"class.hlsl::ByteAddressBuffer" = type { target("dx.RawBuffer", i8, 0, 0) } |
13 |
| -%"class.hlsl::StructuredBuffer" = type { target("dx.RawBuffer", i16, 0, 0) } |
14 |
| -%"class.hlsl::Buffer.4" = type { target("dx.TypedBuffer", i64, 0, 0, 0) } |
15 |
| - |
16 |
| -@Zero = internal global %"class.hlsl::Buffer" poison, align 4 |
17 |
| -@One = internal global %"class.hlsl::Buffer.1" poison, align 4 |
18 |
| -@Two = internal global %"class.hlsl::Buffer.2" poison, align 4 |
19 |
| -@Three = internal global %"class.hlsl::Buffer.3" poison, align 4 |
20 |
| -@Four = internal global %"class.hlsl::ByteAddressBuffer" poison, align 4 |
21 |
| -@Five = internal global %"class.hlsl::StructuredBuffer" poison, align 4 |
22 |
| -@Six = internal global %"class.hlsl::Buffer.4" poison, align 4 |
| 8 | +@Zero.str = private unnamed_addr constant [5 x i8] c"Zero\00", align 1 |
| 9 | +@One.str = private unnamed_addr constant [4 x i8] c"One\00", align 1 |
| 10 | +@Two.str = private unnamed_addr constant [4 x i8] c"Two\00", align 1 |
| 11 | +@Three.str = private unnamed_addr constant [6 x i8] c"Three\00", align 1 |
| 12 | +@Four.str = private unnamed_addr constant [5 x i8] c"Four\00", align 1 |
| 13 | +@Five.str = private unnamed_addr constant [5 x i8] c"Five\00", align 1 |
| 14 | +@Six.str = private unnamed_addr constant [4 x i8] c"Six\00", align 1 |
| 15 | +@Seven.str = private unnamed_addr constant [6 x i8] c"Seven\00", align 1 |
| 16 | +@Array.str = private unnamed_addr constant [6 x i8] c"Array\00", align 1 |
23 | 17 |
|
24 | 18 | ; PRINT:; Resource Bindings:
|
25 | 19 | ; PRINT-NEXT:;
|
26 | 20 | ; PRINT-NEXT:; Name Type Format Dim ID HLSL Bind Count
|
27 | 21 | ; PRINT-NEXT:; ------------------------------ ---------- ------- ----------- ------- -------------- ------
|
28 |
| -; PRINT-NEXT:; texture f16 buf T0 t0 1 |
29 |
| -; PRINT-NEXT:; texture f32 buf T1 t1 1 |
30 |
| -; PRINT-NEXT:; texture f64 buf T2 t2 1 |
31 |
| -; PRINT-NEXT:; texture i32 buf T3 t3 1 |
32 |
| -; PRINT-NEXT:; texture byte r/o T4 t5 1 |
33 |
| -; PRINT-NEXT:; texture struct r/o T5 t6 1 |
34 |
| -; PRINT-NEXT:; texture u64 buf T6 t10,space2 1 |
35 |
| -; PRINT-NEXT:; texture f32 buf T7 t4,space3 100 |
| 22 | +; PRINT-NEXT:; Zero texture f16 buf T0 t0 1 |
| 23 | +; PRINT-NEXT:; One texture f32 buf T1 t1 1 |
| 24 | +; PRINT-NEXT:; Two texture f64 buf T2 t2 1 |
| 25 | +; PRINT-NEXT:; Three texture i32 buf T3 t3 1 |
| 26 | +; PRINT-NEXT:; Four texture byte r/o T4 t5 1 |
| 27 | +; PRINT-NEXT:; Five texture struct r/o T5 t6 1 |
| 28 | +; PRINT-NEXT:; Six texture u64 buf T6 t10,space2 1 |
| 29 | +; PRINT-NEXT:; Array texture f32 buf T7 t4,space3 100 |
| 30 | +; PRINT-NEXT:; Seven texture u64 buf T8 t20,space5 1 |
| 31 | +; |
36 | 32 |
|
37 | 33 | define void @test() #0 {
|
38 |
| - ; Buffer<half4> Buf : register(t0) |
| 34 | + ; Buffer<half4> Zero : register(t0) |
39 | 35 | %Zero_h = call target("dx.TypedBuffer", <4 x half>, 0, 0, 0)
|
40 |
| - @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 1, i32 0, i1 false, ptr null) |
41 |
| - store target("dx.TypedBuffer", <4 x half>, 0, 0, 0) %Zero_h, ptr @Zero, align 4 |
| 36 | + @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 1, i32 0, i1 false, ptr @Zero.str) |
42 | 37 |
|
43 |
| - ; Buffer<float4> Buf : register(t1) |
| 38 | + ; Buffer<float4> One : register(t1) |
44 | 39 | %One_h = call target("dx.TypedBuffer", <2 x float>, 0, 0, 0)
|
45 |
| - @llvm.dx.resource.handlefrombinding(i32 0, i32 1, i32 1, i32 0, i1 false, ptr null) |
46 |
| - store target("dx.TypedBuffer", <2 x float>, 0, 0, 0) %One_h, ptr @One, align 4 |
| 40 | + @llvm.dx.resource.handlefrombinding(i32 0, i32 1, i32 1, i32 0, i1 false, ptr @One.str) |
47 | 41 |
|
48 | 42 | ; Buffer<double> Two : register(t2);
|
49 | 43 | %Two_h = call target("dx.TypedBuffer", double, 0, 0, 0)
|
50 |
| - @llvm.dx.resource.handlefrombinding(i32 0, i32 2, i32 1, i32 0, i1 false, ptr null) |
51 |
| - store target("dx.TypedBuffer", double, 0, 0, 0) %Two_h, ptr @Two, align 4 |
| 44 | + @llvm.dx.resource.handlefrombinding(i32 0, i32 2, i32 1, i32 0, i1 false, ptr @Two.str) |
52 | 45 |
|
53 | 46 | ; Buffer<int4> Three : register(t3);
|
54 | 47 | %Three_h = call target("dx.TypedBuffer", <4 x i32>, 0, 0, 1)
|
55 |
| - @llvm.dx.resource.handlefrombinding(i32 0, i32 3, i32 1, i32 0, i1 false, ptr null) |
56 |
| - store target("dx.TypedBuffer", <4 x i32>, 0, 0, 1) %Three_h, ptr @Three, align 4 |
| 48 | + @llvm.dx.resource.handlefrombinding(i32 0, i32 3, i32 1, i32 0, i1 false, ptr @Three.str) |
57 | 49 |
|
58 | 50 | ; ByteAddressBuffer Four : register(t4)
|
59 | 51 | %Four_h = call target("dx.RawBuffer", i8, 0, 0)
|
60 |
| - @llvm.dx.resource.handlefrombinding(i32 0, i32 5, i32 1, i32 0, i1 false, ptr null) |
61 |
| - store target("dx.RawBuffer", i8, 0, 0) %Four_h, ptr @Four, align 4 |
| 52 | + @llvm.dx.resource.handlefrombinding(i32 0, i32 5, i32 1, i32 0, i1 false, ptr @Four.str) |
62 | 53 |
|
63 | 54 | ; StructuredBuffer<int16_t> Five : register(t6);
|
64 | 55 | %Five_h = call target("dx.RawBuffer", i16, 0, 0)
|
65 |
| - @llvm.dx.resource.handlefrombinding(i32 0, i32 6, i32 1, i32 0, i1 false, ptr null) |
66 |
| - store target("dx.RawBuffer", i16, 0, 0) %Five_h, ptr @Five, align 4 |
| 56 | + @llvm.dx.resource.handlefrombinding(i32 0, i32 6, i32 1, i32 0, i1 false, ptr @Five.str) |
67 | 57 |
|
68 | 58 | ; Buffer<double> Six : register(t10, space2);
|
69 | 59 | %Six_h = call target("dx.TypedBuffer", i64, 0, 0, 0)
|
70 |
| - @llvm.dx.resource.handlefrombinding(i32 2, i32 10, i32 1, i32 0, i1 false, ptr null) |
71 |
| - store target("dx.TypedBuffer", i64, 0, 0, 0) %Six_h, ptr @Six, align 4 |
| 60 | + @llvm.dx.resource.handlefrombinding(i32 2, i32 10, i32 1, i32 0, i1 false, ptr @Six.str) |
| 61 | + |
| 62 | + ; Same buffer type as Six - should have the same type in metadata |
| 63 | + ; Buffer<double> Seven : register(t10, space2); |
| 64 | + %Seven_h = call target("dx.TypedBuffer", i64, 0, 0, 0) |
| 65 | + @llvm.dx.resource.handlefrombinding(i32 5, i32 20, i32 1, i32 0, i1 false, ptr @Seven.str) |
72 | 66 |
|
73 | 67 | ; Buffer<float4> Array[100] : register(t4, space3);
|
74 | 68 | ; Buffer<float4> B1 = Array[30];
|
75 | 69 | ; Buffer<float4> B1 = Array[42];
|
76 | 70 | ; resource array accesses should produce one metadata entry
|
77 | 71 | %Array_30_h = call target("dx.TypedBuffer", <4 x float>, 0, 0, 0)
|
78 |
| - @llvm.dx.resource.handlefrombinding(i32 3, i32 4, i32 100, i32 30, i1 false, ptr null) |
| 72 | + @llvm.dx.resource.handlefrombinding(i32 3, i32 4, i32 100, i32 30, i1 false, ptr @Array.str) |
79 | 73 | %Array_42_h = call target("dx.TypedBuffer", <4 x float>, 0, 0, 0)
|
80 |
| - @llvm.dx.resource.handlefrombinding(i32 3, i32 4, i32 100, i32 42, i1 false, ptr null) |
| 74 | + @llvm.dx.resource.handlefrombinding(i32 3, i32 4, i32 100, i32 42, i1 false, ptr @Array.str) |
81 | 75 |
|
82 | 76 | ret void
|
83 | 77 | }
|
84 | 78 |
|
85 | 79 | attributes #0 = { noinline nounwind "hlsl.shader"="compute" }
|
86 | 80 |
|
87 |
| -; CHECK: @0 = external constant %TypedBuffer |
88 |
| -; CHECK: @1 = external constant %TypedBuffer.0 |
89 |
| -; CHECK: @2 = external constant %TypedBuffer.1 |
90 |
| -; CHECK: @3 = external constant %TypedBuffer.2 |
91 |
| -; CHECK: @4 = external constant %ByteAddressBuffer |
92 |
| -; CHECK: @5 = external constant %StructuredBuffer |
93 |
| -; CHECK: @6 = external constant %TypedBuffer.3 |
94 |
| -; CHECK: @7 = external constant %TypedBuffer.4 |
| 81 | +; CHECK: %TypedBuffer = type { <4 x half> } |
| 82 | +; CHECK: %TypedBuffer.0 = type { <2 x float> } |
| 83 | +; CHECK: %TypedBuffer.1 = type { double } |
| 84 | +; CHECK: %TypedBuffer.2 = type { <4 x i32> } |
| 85 | +; CHECK: %ByteAddressBuffer = type { i32 } |
| 86 | +; CHECK: %StructuredBuffer = type { i16 } |
| 87 | +; CHECK: %TypedBuffer.3 = type { i64 } |
| 88 | +; CHECK: %TypedBuffer.4 = type { <4 x float> } |
| 89 | +; CHECK: %TypedBuffer.5 = type { i64 } |
| 90 | + |
| 91 | +; CHECK: @Zero = external constant %TypedBuffer |
| 92 | +; CHECK: @One = external constant %TypedBuffer.0 |
| 93 | +; CHECK: @Two = external constant %TypedBuffer.1 |
| 94 | +; CHECK: @Three = external constant %TypedBuffer.2 |
| 95 | +; CHECK: @Four = external constant %ByteAddressBuffer |
| 96 | +; CHECK: @Five = external constant %StructuredBuffer |
| 97 | +; CHECK: @Six = external constant %TypedBuffer.3 |
| 98 | +; CHECK: @Array = external constant %TypedBuffer.4 |
| 99 | +; CHECK: @Seven = external constant %TypedBuffer.5 |
95 | 100 |
|
96 | 101 | ; CHECK: !dx.resources = !{[[ResList:[!][0-9]+]]}
|
97 | 102 |
|
98 | 103 | ; CHECK: [[ResList]] = !{[[SRVList:[!][0-9]+]], null, null, null}
|
99 | 104 | ; CHECK: [[SRVList]] = !{![[Zero:[0-9]+]], ![[One:[0-9]+]], ![[Two:[0-9]+]],
|
100 | 105 | ; CHECK-SAME: ![[Three:[0-9]+]], ![[Four:[0-9]+]], ![[Five:[0-9]+]],
|
101 |
| -; CHECK-SAME: ![[Six:[0-9]+]], ![[Array:[0-9]+]]} |
| 106 | +; CHECK-SAME: ![[Six:[0-9]+]], ![[Array:[0-9]+]], ![[Seven:[0-9]+]]} |
102 | 107 |
|
103 |
| -; CHECK: ![[Zero]] = !{i32 0, ptr @0, !"", i32 0, i32 0, i32 1, i32 10, i32 0, ![[Half:[0-9]+]]} |
| 108 | +; CHECK: ![[Zero]] = !{i32 0, ptr @Zero, !"Zero", i32 0, i32 0, i32 1, i32 10, i32 0, ![[Half:[0-9]+]]} |
104 | 109 | ; CHECK: ![[Half]] = !{i32 0, i32 8}
|
105 |
| -; CHECK: ![[One]] = !{i32 1, ptr @1, !"", i32 0, i32 1, i32 1, i32 10, i32 0, ![[Float:[0-9]+]]} |
| 110 | +; CHECK: ![[One]] = !{i32 1, ptr @One, !"One", i32 0, i32 1, i32 1, i32 10, i32 0, ![[Float:[0-9]+]]} |
106 | 111 | ; CHECK: ![[Float]] = !{i32 0, i32 9}
|
107 |
| -; CHECK: ![[Two]] = !{i32 2, ptr @2, !"", i32 0, i32 2, i32 1, i32 10, i32 0, ![[Double:[0-9]+]]} |
| 112 | +; CHECK: ![[Two]] = !{i32 2, ptr @Two, !"Two", i32 0, i32 2, i32 1, i32 10, i32 0, ![[Double:[0-9]+]]} |
108 | 113 | ; CHECK: ![[Double]] = !{i32 0, i32 10}
|
109 |
| -; CHECK: ![[Three]] = !{i32 3, ptr @3, !"", i32 0, i32 3, i32 1, i32 10, i32 0, ![[I32:[0-9]+]]} |
| 114 | +; CHECK: ![[Three]] = !{i32 3, ptr @Three, !"Three", i32 0, i32 3, i32 1, i32 10, i32 0, ![[I32:[0-9]+]]} |
110 | 115 | ; CHECK: ![[I32]] = !{i32 0, i32 4}
|
111 |
| -; CHECK: ![[Four]] = !{i32 4, ptr @4, !"", i32 0, i32 5, i32 1, i32 11, i32 0, null} |
112 |
| -; CHECK: ![[Five]] = !{i32 5, ptr @5, !"", i32 0, i32 6, i32 1, i32 12, i32 0, ![[FiveStride:[0-9]+]]} |
| 116 | +; CHECK: ![[Four]] = !{i32 4, ptr @Four, !"Four", i32 0, i32 5, i32 1, i32 11, i32 0, null} |
| 117 | +; CHECK: ![[Five]] = !{i32 5, ptr @Five, !"Five", i32 0, i32 6, i32 1, i32 12, i32 0, ![[FiveStride:[0-9]+]]} |
113 | 118 | ; CHECK: ![[FiveStride]] = !{i32 1, i32 2}
|
114 |
| -; CHECK: ![[Six]] = !{i32 6, ptr @6, !"", i32 2, i32 10, i32 1, i32 10, i32 0, ![[U64:[0-9]+]]} |
| 119 | +; CHECK: ![[Six]] = !{i32 6, ptr @Six, !"Six", i32 2, i32 10, i32 1, i32 10, i32 0, ![[U64:[0-9]+]]} |
115 | 120 | ; CHECK: ![[U64]] = !{i32 0, i32 7}
|
116 |
| -; CHECK: ![[Array]] = !{i32 7, ptr @7, !"", i32 3, i32 4, i32 100, i32 10, i32 0, ![[Float]]} |
| 121 | +; CHECK: ![[Array]] = !{i32 7, ptr @Array, !"Array", i32 3, i32 4, i32 100, i32 10, i32 0, ![[Float]]} |
| 122 | +; CHECK: ![[Seven]] = !{i32 8, ptr @Seven, !"Seven", i32 5, i32 20, i32 1, i32 10, i32 0, ![[U64]]} |
0 commit comments