134 lines · plain
1; RUN: opt -S -dxil-translate-metadata < %s | FileCheck %s2; RUN: opt -S --passes="dxil-pretty-printer" < %s 2>&1 | FileCheck %s --check-prefix=PRINT3; RUN: llc %s --filetype=asm -o - 2>&1 | FileCheck %s --check-prefixes=CHECK,PRINT4 5target 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"6target triple = "dxil-pc-shadermodel6.6-compute"7 8@Zero.str = private unnamed_addr constant [5 x i8] c"Zero\00", align 19@One.str = private unnamed_addr constant [4 x i8] c"One\00", align 110@Two.str = private unnamed_addr constant [4 x i8] c"Two\00", align 111@Three.str = private unnamed_addr constant [6 x i8] c"Three\00", align 112@Four.str = private unnamed_addr constant [5 x i8] c"Four\00", align 113@Five.str = private unnamed_addr constant [5 x i8] c"Five\00", align 114@Six.str = private unnamed_addr constant [4 x i8] c"Six\00", align 115@Seven.str = private unnamed_addr constant [6 x i8] c"Seven\00", align 116@Array.str = private unnamed_addr constant [6 x i8] c"Array\00", align 117@Array2.str = private unnamed_addr constant [7 x i8] c"Array2\00", align 118 19; PRINT:; Resource Bindings:20; PRINT-NEXT:;21; PRINT-NEXT:; Name Type Format Dim ID HLSL Bind Count22; PRINT-NEXT:; ------------------------------ ---------- ------- ----------- ------- -------------- ---------23; PRINT-NEXT:; Zero texture f16 buf T0 t0 124; PRINT-NEXT:; One texture f32 buf T1 t1 125; PRINT-NEXT:; Two texture u32 buf T2 t2 126; PRINT-NEXT:; Three texture i32 buf T3 t3 127; PRINT-NEXT:; Four texture byte r/o T4 t5 128; PRINT-NEXT:; Five texture struct r/o T5 t6 129; PRINT-NEXT:; Six texture u32 buf T6 t10,space2 130; PRINT-NEXT:; Array texture f32 buf T7 t4,space3 10031; PRINT-NEXT:; Array2 texture u32 buf T8 t2,space4 unbounded32; PRINT-NEXT:; Seven texture u32 buf T9 t20,space5 133;34 35define void @test() #0 {36 ; Buffer<half4> Zero : register(t0)37 %Zero_h = call target("dx.TypedBuffer", <4 x half>, 0, 0, 0)38 @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 1, i32 0, ptr @Zero.str)39 40 ; Buffer<float4> One : register(t1)41 %One_h = call target("dx.TypedBuffer", <2 x float>, 0, 0, 0)42 @llvm.dx.resource.handlefrombinding(i32 0, i32 1, i32 1, i32 0, ptr @One.str)43 44 ; Buffer<double> Two : register(t2);45 %Two_h = call target("dx.TypedBuffer", double, 0, 0, 0)46 @llvm.dx.resource.handlefrombinding(i32 0, i32 2, i32 1, i32 0, ptr @Two.str)47 48 ; Buffer<int4> Three : register(t3);49 %Three_h = call target("dx.TypedBuffer", <4 x i32>, 0, 0, 1)50 @llvm.dx.resource.handlefrombinding(i32 0, i32 3, i32 1, i32 0, ptr @Three.str)51 52 ; ByteAddressBuffer Four : register(t4)53 %Four_h = call target("dx.RawBuffer", i8, 0, 0)54 @llvm.dx.resource.handlefrombinding(i32 0, i32 5, i32 1, i32 0, ptr @Four.str)55 56 ; StructuredBuffer<int16_t> Five : register(t6);57 %Five_h = call target("dx.RawBuffer", i16, 0, 0)58 @llvm.dx.resource.handlefrombinding(i32 0, i32 6, i32 1, i32 0, ptr @Five.str)59 60 ; Buffer<double> Six : register(t10, space2);61 %Six_h = call target("dx.TypedBuffer", i64, 0, 0, 0)62 @llvm.dx.resource.handlefrombinding(i32 2, i32 10, i32 1, i32 0, ptr @Six.str)63 64 ; Same buffer type as Six - should have the same type in metadata65 ; Buffer<double> Seven : register(t20, space5);66 %Seven_h = call target("dx.TypedBuffer", i64, 0, 0, 0)67 @llvm.dx.resource.handlefrombinding(i32 5, i32 20, i32 1, i32 0, ptr @Seven.str)68 69 ; Buffer<float4> Array[100] : register(t4, space3);70 ; Buffer<float4> B1 = Array[30];71 ; Buffer<float4> B2 = Array[42];72 ; resource array accesses should produce one metadata entry 73 %Array_30_h = call target("dx.TypedBuffer", <4 x float>, 0, 0, 0)74 @llvm.dx.resource.handlefrombinding(i32 3, i32 4, i32 100, i32 30, ptr @Array.str)75 %Array_42_h = call target("dx.TypedBuffer", <4 x float>, 0, 0, 0)76 @llvm.dx.resource.handlefrombinding(i32 3, i32 4, i32 100, i32 42, ptr @Array.str)77 78 ; test unbounded resource array79 ; Buffer<double> Array2[] : register(t2, space4);80 ; Buffer<double> C1 = Array[10];81 ; Buffer<double> C2 = Array[20];82 %Array2_10_h = call target("dx.TypedBuffer", double, 0, 0, 0)83 @llvm.dx.resource.handlefrombinding(i32 4, i32 2, i32 -1, i32 10, ptr @Array2.str)84 %Array2_20_h = call target("dx.TypedBuffer", double, 0, 0, 0)85 @llvm.dx.resource.handlefrombinding(i32 4, i32 2, i32 -1, i32 20, ptr @Array2.str)86 87 ret void88}89 90attributes #0 = { noinline nounwind "hlsl.shader"="compute" }91 92; CHECK: %"Buffer<half4>" = type { <4 x half> }93; CHECK: %"Buffer<float2>" = type { <2 x float> }94; CHECK: %"Buffer<double>" = type { double }95; CHECK: %"Buffer<int32_t4>" = type { <4 x i32> }96; CHECK: %ByteAddressBuffer = type { i32 }97; CHECK: %"StructuredBuffer<int16_t>" = type { i16 }98; CHECK: %"Buffer<uint32_t>" = type { i64 }99; CHECK: %"Buffer<float4>" = type { <4 x float> }100 101; CHECK: @Zero = external constant %"Buffer<half4>"102; CHECK: @One = external constant %"Buffer<float2>"103; CHECK: @Two = external constant %"Buffer<double>"104; CHECK: @Three = external constant %"Buffer<int32_t4>"105; CHECK: @Four = external constant %ByteAddressBuffer106; CHECK: @Five = external constant %"StructuredBuffer<int16_t>"107; CHECK: @Six = external constant %"Buffer<uint32_t>"108; CHECK: @Array = external constant [100 x %"Buffer<float4>"]109; CHECK: @Array2 = external constant [0 x %"Buffer<double>"]110; CHECK: @Seven = external constant %"Buffer<uint32_t>"111 112; CHECK: !dx.resources = !{[[ResList:[!][0-9]+]]}113 114; CHECK: [[ResList]] = !{[[SRVList:[!][0-9]+]], null, null, null}115; CHECK: [[SRVList]] = !{![[Zero:[0-9]+]], ![[One:[0-9]+]], ![[Two:[0-9]+]],116; CHECK-SAME: ![[Three:[0-9]+]], ![[Four:[0-9]+]], ![[Five:[0-9]+]],117; CHECK-SAME: ![[Six:[0-9]+]], ![[Array:[0-9]+]], ![[Array2:[0-9]+]], ![[Seven:[0-9]+]]}118 119; CHECK: ![[Zero]] = !{i32 0, ptr @Zero, !"Zero", i32 0, i32 0, i32 1, i32 10, i32 0, ![[Half:[0-9]+]]}120; CHECK: ![[Half]] = !{i32 0, i32 8}121; CHECK: ![[One]] = !{i32 1, ptr @One, !"One", i32 0, i32 1, i32 1, i32 10, i32 0, ![[Float:[0-9]+]]}122; CHECK: ![[Float]] = !{i32 0, i32 9}123; CHECK: ![[Two]] = !{i32 2, ptr @Two, !"Two", i32 0, i32 2, i32 1, i32 10, i32 0, ![[U32:[0-9]+]]}124; CHECK: ![[U32]] = !{i32 0, i32 5}125; CHECK: ![[Three]] = !{i32 3, ptr @Three, !"Three", i32 0, i32 3, i32 1, i32 10, i32 0, ![[I32:[0-9]+]]}126; CHECK: ![[I32]] = !{i32 0, i32 4}127; CHECK: ![[Four]] = !{i32 4, ptr @Four, !"Four", i32 0, i32 5, i32 1, i32 11, i32 0, null}128; CHECK: ![[Five]] = !{i32 5, ptr @Five, !"Five", i32 0, i32 6, i32 1, i32 12, i32 0, ![[FiveStride:[0-9]+]]}129; CHECK: ![[FiveStride]] = !{i32 1, i32 2}130; CHECK: ![[Six]] = !{i32 6, ptr @Six, !"Six", i32 2, i32 10, i32 1, i32 10, i32 0, ![[U32:[0-9]+]]}131; CHECK: ![[Array]] = !{i32 7, ptr @Array, !"Array", i32 3, i32 4, i32 100, i32 10, i32 0, ![[Float]]}132; CHECK: ![[Array2]] = !{i32 8, ptr @Array2, !"Array2", i32 4, i32 2, i32 -1, i32 10, i32 0, ![[U32]]}133; CHECK: ![[Seven]] = !{i32 9, ptr @Seven, !"Seven", i32 5, i32 20, i32 1, i32 10, i32 0, ![[U32]]}134