brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.9 KiB · 671fcef Raw
95 lines · plain
1; RUN: opt -S -passes=dxil-translate-metadata,dxil-op-lower %s | FileCheck %s2; RUN: opt -S -passes=dxil-pretty-printer %s 2>&1 >/dev/null | FileCheck --check-prefix=CHECK-PRETTY %s3 4; CHECK-PRETTY:       Type  Format         Dim      ID      HLSL Bind     Count5; CHECK-PRETTY: ---------- ------- ----------- ------- -------------- ---------6; CHECK-PRETTY:    texture     f32         buf      T0      t7        unbounded7; CHECK-PRETTY:    texture    byte         r/o      T1      t8,space1         18; CHECK-PRETTY:    texture  struct         r/o      T2      t2,space4         19; CHECK-PRETTY:    texture     u32         buf      T3      t3,space5        2410; CHECK-PRETTY:        UAV     i32         buf      U0      u7,space2         111; CHECK-PRETTY:        UAV     f32         buf      U1      u5,space3         112; CHECK-PRETTY:    cbuffer      NA          NA     CB0            cb0         113 14target triple = "dxil-pc-shadermodel6.6-compute"15 16@BufA.str = private unnamed_addr constant [5 x i8] c"BufA\00", align 117@BufB.str = private unnamed_addr constant [5 x i8] c"BufB\00", align 118 19; make sure the string constants are removed from the module20; CHECK-NOT: private unnamed_addr constant [5 x i8] c"BufA\00", align 121; CHECK-NOT: private unnamed_addr constant [5 x i8] c"BufB\00", align 122 23declare i32 @some_val();24 25define void @test_bindings() {26  ; RWBuffer<float4> Buf : register(u5, space3)27  %typed0 = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0)28              @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v4f32_1_0_0(29                  i32 3, i32 5, i32 1, i32 0, ptr @BufA.str)30  ; CHECK: [[BUF0:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 5, i32 5, i32 3, i8 1 }, i32 5, i1 false) #[[#ATTR:]]31  ; CHECK: call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BUF0]], %dx.types.ResourceProperties { i32 4106, i32 1033 }) #[[#ATTR]]32 33  ; RWBuffer<int> Buf : register(u7, space2)34  %typed1 = call target("dx.TypedBuffer", i32, 1, 0, 1)35      @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_i32_1_0_0t(36          i32 2, i32 7, i32 1, i32 0, ptr null)37  ; CHECK: [[BUF1:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 7, i32 7, i32 2, i8 1 }, i32 7, i1 false) #[[#ATTR]]38  ; CHECK: call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BUF1]], %dx.types.ResourceProperties { i32 4106, i32 260 }) #[[#ATTR]]39 40  ; Buffer<uint4> Buf[24] : register(t3, space5)41  ; Buffer<uint4> typed2 = Buf[4]42  ; Note that the index below is 3 + 4 = 743  %typed2 = call target("dx.TypedBuffer", <4 x i32>, 0, 0, 0)44      @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_i32_0_0_0t(45          i32 5, i32 3, i32 24, i32 4, ptr @BufB.str)46  ; 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) #[[#ATTR]]47  ; CHECK: call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BUF2]], %dx.types.ResourceProperties { i32 10, i32 1029 }) #[[#ATTR]]48 49  ; struct S { float4 a; uint4 b; };50  ; StructuredBuffer<S> Buf : register(t2, space4)51  %struct0 = call target("dx.RawBuffer", {<4 x float>, <4 x i32>}, 0, 0)52      @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_sl_v4f32v4i32s_0_0t(53          i32 4, i32 2, i32 1, i32 0, ptr null)54  ; CHECK: [[BUF3:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 2, i32 2, i32 4, i8 0 }, i32 2, i1 false) #[[#ATTR]]55  ; CHECK: = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BUF3]], %dx.types.ResourceProperties { i32 1036, i32 32 }) #[[#ATTR]]56 57  ; ByteAddressBuffer Buf : register(t8, space1)58  %byteaddr0 = call target("dx.RawBuffer", i8, 0, 0)59      @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i8_0_0t(60          i32 1, i32 8, i32 1, i32 0, ptr null)61  ; CHECK: [[BUF4:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 8, i32 8, i32 1, i8 0 }, i32 8, i1 false) #[[#ATTR]]62  ; CHECK: call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BUF4]], %dx.types.ResourceProperties { i32 11, i32 0 }) #[[#ATTR]]63 64  ; Buffer<float4> Buf[] : register(t7)65  ; Buffer<float4> typed3 = Buf[ix]66  %typed3_ix = call i32 @some_val()67  %typed3 = call target("dx.TypedBuffer", <4 x float>, 0, 0, 0)68      @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v4f32_0_0_0t(69          i32 0, i32 7, i32 -1, i32 %typed3_ix, ptr null)70  ; CHECK: %[[IX:.*]] = add i32 %typed3_ix, 771  ; 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]]72  ; CHECK: call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BUF5]], %dx.types.ResourceProperties { i32 10, i32 1033 }) #[[#ATTR]]73 74  ; cbuffer cb0 : register(b0) { int4 i; float4 f; }75  %cb0 = call target("dx.CBuffer", <{ <4 x i32>, <4 x float> }>)76      @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 1, i32 0, ptr null)77  ; 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]]78  ; CHECK: call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[BUF6]], %dx.types.ResourceProperties { i32 13, i32 32 }) #[[#ATTR]]79 80  ret void81}82 83; CHECK: attributes #[[#ATTR]] = {{{.*}} memory(none) {{.*}}}84 85; Just check that we have the right types and number of metadata nodes, the86; contents of the metadata are tested elsewhere.87;88; CHECK: !dx.resources = !{[[RESMD:![0-9]+]]}89; CHECK: [[RESMD]] = !{[[SRVMD:![0-9]+]], [[UAVMD:![0-9]+]], [[CBUFMD:![0-9]+]], null}90; CHECK-DAG: [[SRVMD]] = !{!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}}91; CHECK-DAG: [[UAVMD]] = !{!{{[0-9]+}}, !{{[0-9]+}}}92; CHECK-DAG: [[CBUFMD]] = !{!{{[0-9]+}}}93 94attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }95