brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.0 KiB · 6cca501 Raw
82 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 13target triple = "dxil-pc-shadermodel6.0-compute"14 15@BufA.str = private unnamed_addr constant [5 x i8] c"BufA\00", align 116@BufB.str = private unnamed_addr constant [5 x i8] c"BufB\00", align 117 18; make sure the string constants are removed from the module19; CHECK-NOT: private unnamed_addr constant [5 x i8] c"BufA\00", align 120; CHECK-NOT: private unnamed_addr constant [5 x i8] c"BufB\00", align 121 22declare i32 @some_val();23 24define void @test_buffers() {25  ; RWBuffer<float4> Buf : register(u5, space3)26  %typed0 = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0)27              @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v4f32_1_0_0(28                  i32 3, i32 5, i32 1, i32 0, ptr @BufA.str)29  ; CHECK: call %dx.types.Handle @dx.op.createHandle(i32 57, i8 1, i32 1, i32 5, i1 false) #[[#ATTR:]]30  ; CHECK-NOT: @llvm.dx.cast.handle31 32  ; RWBuffer<int> Buf : register(u7, space2)33  %typed1 = call target("dx.TypedBuffer", i32, 1, 0, 1)34      @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_i32_1_0_1t(35          i32 2, i32 7, i32 1, i32 0, ptr null)36  ; CHECK: call %dx.types.Handle @dx.op.createHandle(i32 57, i8 1, i32 0, i32 7, i1 false) #[[#ATTR]]37 38  ; Buffer<uint4> Buf[24] : register(t3, space5)39  ; Buffer<uint4> typed2 = Buf[4]40  ; Note that the index below is 3 + 4 = 741  %typed2 = call target("dx.TypedBuffer", <4 x i32>, 0, 0, 0)42      @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_i32_0_0_0t(43          i32 5, i32 3, i32 24, i32 4, ptr @BufB.str)44  ; CHECK: call %dx.types.Handle @dx.op.createHandle(i32 57, i8 0, i32 3, i32 7, i1 false) #[[#ATTR]]45 46  ; struct S { float4 a; uint4 b; };47  ; StructuredBuffer<S> Buf : register(t2, space4)48  %struct0 = call target("dx.RawBuffer", {<4 x float>, <4 x i32>}, 0, 0)49      @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_sl_v4f32v4i32s_0_0t(50          i32 4, i32 2, i32 1, i32 0, ptr null)51  ; CHECK: call %dx.types.Handle @dx.op.createHandle(i32 57, i8 0, i32 2, i32 2, i1 false) #[[#ATTR]]52 53  ; ByteAddressBuffer Buf : register(t8, space1)54  %byteaddr0 = call target("dx.RawBuffer", i8, 0, 0)55      @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i8_0_0t(56          i32 1, i32 8, i32 1, i32 0, ptr null)57  ; CHECK: call %dx.types.Handle @dx.op.createHandle(i32 57, i8 0, i32 1, i32 8, i1 false) #[[#ATTR]]58 59  ; Buffer<float4> Buf[] : register(t7)60  ; Buffer<float4> typed3 = Buf[ix]61  %typed3_ix = call i32 @some_val()62  %typed3 = call target("dx.TypedBuffer", <4 x float>, 0, 0, 0)63      @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v4f32_0_0_0t(64          i32 0, i32 7, i32 -1, i32 %typed3_ix, ptr null)65  ; CHECK: %[[IX:.*]] = add i32 %typed3_ix, 766  ; CHECK: call %dx.types.Handle @dx.op.createHandle(i32 57, i8 0, i32 0, i32 %[[IX]], i1 false) #[[#ATTR]]67 68  ret void69}70 71; CHECK: attributes #[[#ATTR]] = {{{.*}} memory(read) {{.*}}}72 73; Just check that we have the right types and number of metadata nodes, the74; contents of the metadata are tested elsewhere.75;76; CHECK: !dx.resources = !{[[RESMD:![0-9]+]]}77; CHECK: [[RESMD]] = !{[[SRVMD:![0-9]+]], [[UAVMD:![0-9]+]], null, null}78; CHECK-DAG: [[SRVMD]] = !{!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}}79; CHECK-DAG: [[UAVMD]] = !{!{{[0-9]+}}, !{{[0-9]+}}}80 81attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }82