Skip to content

Commit 19ad7dd

Browse files
authored
[DirectX] Update DXIL op codes for annotateHandle and createHandleFromBinding to match the spec and DXC (#114473)
DXIL spec for reference: [DXIL.rst](https://github.com/microsoft/DirectXShaderCompiler/blob/5704c4744e8752adf5c1bacbf94638f30ff330fd/docs/DXIL.rst?plain=1#L2330).
1 parent 8f8e2b7 commit 19ad7dd

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed

llvm/lib/Target/DirectX/DXIL.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,14 +788,14 @@ def SplitDouble : DXILOp<102, splitDouble> {
788788
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
789789
}
790790

791-
def AnnotateHandle : DXILOp<217, annotateHandle> {
791+
def AnnotateHandle : DXILOp<216, annotateHandle> {
792792
let Doc = "annotate handle with resource properties";
793793
let arguments = [HandleTy, ResPropsTy];
794794
let result = HandleTy;
795795
let stages = [Stages<DXIL1_6, [all_stages]>];
796796
}
797797

798-
def CreateHandleFromBinding : DXILOp<218, createHandleFromBinding> {
798+
def CreateHandleFromBinding : DXILOp<217, createHandleFromBinding> {
799799
let Doc = "create resource handle from binding";
800800
let arguments = [ResBindTy, Int32Ty, Int1Ty];
801801
let result = HandleTy;

llvm/test/CodeGen/DirectX/BufferLoad.ll

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ declare void @vector_user(<4 x float>)
77
declare void @check_user(i1)
88

99
define void @loadv4f32() {
10-
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding
11-
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 217, %dx.types.Handle [[BIND]]
10+
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217,
11+
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BIND]]
1212
%buffer = call target("dx.TypedBuffer", <4 x float>, 0, 0, 0)
1313
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_v4f32_0_0_0(
1414
i32 0, i32 0, i32 1, i32 0, i1 false)
@@ -63,8 +63,8 @@ define void @loadv4f32() {
6363
}
6464

6565
define void @index_dynamic(i32 %bufindex, i32 %elemindex) {
66-
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding
67-
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 217, %dx.types.Handle [[BIND]]
66+
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217,
67+
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BIND]]
6868
%buffer = call target("dx.TypedBuffer", <4 x float>, 0, 0, 0)
6969
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_v4f32_0_0_0(
7070
i32 0, i32 0, i32 1, i32 0, i1 false)
@@ -98,8 +98,8 @@ define void @index_dynamic(i32 %bufindex, i32 %elemindex) {
9898
}
9999

100100
define void @loadf32() {
101-
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding
102-
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 217, %dx.types.Handle [[BIND]]
101+
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217,
102+
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BIND]]
103103
%buffer = call target("dx.TypedBuffer", float, 0, 0, 0)
104104
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_f32_0_0_0(
105105
i32 0, i32 0, i32 1, i32 0, i1 false)
@@ -116,8 +116,8 @@ define void @loadf32() {
116116
}
117117

118118
define void @loadv2f32() {
119-
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding
120-
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 217, %dx.types.Handle [[BIND]]
119+
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217,
120+
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BIND]]
121121
%buffer = call target("dx.TypedBuffer", <2 x float>, 0, 0, 0)
122122
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_v2f32_0_0_0(
123123
i32 0, i32 0, i32 1, i32 0, i1 false)
@@ -130,8 +130,8 @@ define void @loadv2f32() {
130130
}
131131

132132
define void @loadv4f32_checkbit() {
133-
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding
134-
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 217, %dx.types.Handle [[BIND]]
133+
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217,
134+
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BIND]]
135135
%buffer = call target("dx.TypedBuffer", <4 x float>, 0, 0, 0)
136136
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_v4f32_0_0_0(
137137
i32 0, i32 0, i32 1, i32 0, i1 false)
@@ -151,8 +151,8 @@ define void @loadv4f32_checkbit() {
151151
}
152152

153153
define void @loadv4i32() {
154-
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding
155-
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 217, %dx.types.Handle [[BIND]]
154+
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217,
155+
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BIND]]
156156
%buffer = call target("dx.TypedBuffer", <4 x i32>, 0, 0, 0)
157157
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_v4i32_0_0_0(
158158
i32 0, i32 0, i32 1, i32 0, i1 false)
@@ -165,8 +165,8 @@ define void @loadv4i32() {
165165
}
166166

167167
define void @loadv4f16() {
168-
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding
169-
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 217, %dx.types.Handle [[BIND]]
168+
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217,
169+
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BIND]]
170170
%buffer = call target("dx.TypedBuffer", <4 x half>, 0, 0, 0)
171171
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_v4f16_0_0_0(
172172
i32 0, i32 0, i32 1, i32 0, i1 false)
@@ -179,8 +179,8 @@ define void @loadv4f16() {
179179
}
180180

181181
define void @loadv4i16() {
182-
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding
183-
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 217, %dx.types.Handle [[BIND]]
182+
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217,
183+
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BIND]]
184184
%buffer = call target("dx.TypedBuffer", <4 x i16>, 0, 0, 0)
185185
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_v4i16_0_0_0(
186186
i32 0, i32 0, i32 1, i32 0, i1 false)

llvm/test/CodeGen/DirectX/BufferStore.ll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ target triple = "dxil-pc-shadermodel6.6-compute"
44

55
define void @storefloat(<4 x float> %data, i32 %index) {
66

7-
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding
8-
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 217, %dx.types.Handle [[BIND]]
7+
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217,
8+
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BIND]]
99
%buffer = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0)
1010
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_v4f32_1_0_0(
1111
i32 0, i32 0, i32 1, i32 0, i1 false)
@@ -27,8 +27,8 @@ define void @storefloat(<4 x float> %data, i32 %index) {
2727

2828
define void @storeint(<4 x i32> %data, i32 %index) {
2929

30-
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding
31-
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 217, %dx.types.Handle [[BIND]]
30+
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217,
31+
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BIND]]
3232
%buffer = call target("dx.TypedBuffer", <4 x i32>, 1, 0, 0)
3333
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_v4i32_1_0_0(
3434
i32 0, i32 0, i32 1, i32 0, i1 false)
@@ -47,8 +47,8 @@ define void @storeint(<4 x i32> %data, i32 %index) {
4747

4848
define void @storehalf(<4 x half> %data, i32 %index) {
4949

50-
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding
51-
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 217, %dx.types.Handle [[BIND]]
50+
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217,
51+
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BIND]]
5252
%buffer = call target("dx.TypedBuffer", <4 x half>, 1, 0, 0)
5353
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_v4f16_1_0_0(
5454
i32 0, i32 0, i32 1, i32 0, i1 false)
@@ -70,8 +70,8 @@ define void @storehalf(<4 x half> %data, i32 %index) {
7070

7171
define void @storei16(<4 x i16> %data, i32 %index) {
7272

73-
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding
74-
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 217, %dx.types.Handle [[BIND]]
73+
; CHECK: [[BIND:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217,
74+
; CHECK: [[HANDLE:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BIND]]
7575
%buffer = call target("dx.TypedBuffer", <4 x i16>, 1, 0, 0)
7676
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_v4i16_1_0_0(
7777
i32 0, i32 0, i32 1, i32 0, i1 false)

llvm/test/CodeGen/DirectX/CreateHandleFromBinding.ll

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,48 +19,48 @@ define void @test_bindings() {
1919
%typed0 = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0)
2020
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_v4f32_1_0_0(
2121
i32 3, i32 5, i32 1, i32 4, i1 false)
22-
; CHECK: [[BUF0:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 218, %dx.types.ResBind { i32 5, i32 5, i32 3, i8 1 }, i32 4, i1 false)
23-
; CHECK: call %dx.types.Handle @dx.op.annotateHandle(i32 217, %dx.types.Handle [[BUF0]], %dx.types.ResourceProperties { i32 4106, i32 1033 })
22+
; CHECK: [[BUF0:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 5, i32 5, i32 3, i8 1 }, i32 4, i1 false)
23+
; CHECK: call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BUF0]], %dx.types.ResourceProperties { i32 4106, i32 1033 })
2424

2525
; RWBuffer<int> Buf : register(u7, space2)
2626
%typed1 = call target("dx.TypedBuffer", i32, 1, 0, 1)
2727
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_i32_1_0_0t(
2828
i32 2, i32 7, i32 1, i32 6, i1 false)
29-
; CHECK: [[BUF1:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 218, %dx.types.ResBind { i32 7, i32 7, i32 2, i8 1 }, i32 6, i1 false)
30-
; CHECK: call %dx.types.Handle @dx.op.annotateHandle(i32 217, %dx.types.Handle [[BUF1]], %dx.types.ResourceProperties { i32 4106, i32 260 })
29+
; CHECK: [[BUF1:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 7, i32 7, i32 2, i8 1 }, i32 6, i1 false)
30+
; CHECK: call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BUF1]], %dx.types.ResourceProperties { i32 4106, i32 260 })
3131

3232
; Buffer<uint4> Buf[24] : register(t3, space5)
3333
; Buffer<uint4> typed2 = Buf[4]
3434
; Note that the index below is 3 + 4 = 7
3535
%typed2 = call target("dx.TypedBuffer", <4 x i32>, 0, 0, 0)
3636
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_i32_0_0_0t(
3737
i32 5, i32 3, i32 24, i32 7, i1 false)
38-
; CHECK: [[BUF2:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 218, %dx.types.ResBind { i32 3, i32 26, i32 5, i8 0 }, i32 7, i1 false)
39-
; CHECK: call %dx.types.Handle @dx.op.annotateHandle(i32 217, %dx.types.Handle [[BUF2]], %dx.types.ResourceProperties { i32 10, i32 1029 })
38+
; CHECK: [[BUF2:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 3, i32 26, i32 5, i8 0 }, i32 7, i1 false)
39+
; CHECK: call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BUF2]], %dx.types.ResourceProperties { i32 10, i32 1029 })
4040

4141
; struct S { float4 a; uint4 b; };
4242
; StructuredBuffer<S> Buf : register(t2, space4)
4343
%struct0 = call target("dx.RawBuffer", {<4 x float>, <4 x i32>}, 0, 0)
4444
@llvm.dx.handle.fromBinding.tdx.RawBuffer_sl_v4f32v4i32s_0_0t(
4545
i32 4, i32 2, i32 1, i32 10, i1 true)
46-
; CHECK: [[BUF3:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 218, %dx.types.ResBind { i32 2, i32 2, i32 4, i8 0 }, i32 10, i1 true)
47-
; CHECK: = call %dx.types.Handle @dx.op.annotateHandle(i32 217, %dx.types.Handle [[BUF3]], %dx.types.ResourceProperties { i32 1036, i32 32 })
46+
; CHECK: [[BUF3:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 2, i32 2, i32 4, i8 0 }, i32 10, i1 true)
47+
; CHECK: = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BUF3]], %dx.types.ResourceProperties { i32 1036, i32 32 })
4848

4949
; ByteAddressBuffer Buf : register(t8, space1)
5050
%byteaddr0 = call target("dx.RawBuffer", i8, 0, 0)
5151
@llvm.dx.handle.fromBinding.tdx.RawBuffer_i8_0_0t(
5252
i32 1, i32 8, i32 1, i32 12, i1 false)
53-
; CHECK: [[BUF4:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 218, %dx.types.ResBind { i32 8, i32 8, i32 1, i8 0 }, i32 12, i1 false)
54-
; CHECK: call %dx.types.Handle @dx.op.annotateHandle(i32 217, %dx.types.Handle [[BUF4]], %dx.types.ResourceProperties { i32 11, i32 0 })
53+
; CHECK: [[BUF4:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 8, i32 8, i32 1, i8 0 }, i32 12, i1 false)
54+
; CHECK: call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BUF4]], %dx.types.ResourceProperties { i32 11, i32 0 })
5555

5656
; Buffer<float4> Buf[] : register(t0)
5757
; Buffer<float4> typed3 = Buf[ix]
5858
%typed3_ix = call i32 @some_val()
5959
%typed3 = call target("dx.TypedBuffer", <4 x float>, 0, 0, 0)
6060
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_v4f32_0_0_0t(
6161
i32 0, i32 0, i32 -1, i32 %typed3_ix, i1 false)
62-
; CHECK: [[BUF5:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 218, %dx.types.ResBind { i32 0, i32 -1, i32 0, i8 0 }, i32 %typed3_ix, i1 false)
63-
; CHECK: call %dx.types.Handle @dx.op.annotateHandle(i32 217, %dx.types.Handle [[BUF5]], %dx.types.ResourceProperties { i32 10, i32 1033 })
62+
; CHECK: [[BUF5:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 0, i32 -1, i32 0, i8 0 }, i32 %typed3_ix, i1 false)
63+
; CHECK: call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BUF5]], %dx.types.ResourceProperties { i32 10, i32 1033 })
6464

6565
ret void
6666
}

0 commit comments

Comments
 (0)