xref: /llvm-project/llvm/test/CodeGen/DirectX/cbuf.ll (revision 81ee38551f2c9d1677471ab59bdc800e667b9616)
18107810cSJustin Bogner; RUN: opt -S -dxil-translate-metadata < %s | FileCheck %s --check-prefix=DXILMD
2*81ee3855SJustin Bogner; RUN: opt -S --passes="dxil-pretty-printer" < %s 2>&1 | FileCheck %s --check-prefix=PRINT
3944f4b28SXiang Li
4944f4b28SXiang Litarget 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"
5944f4b28SXiang Litarget triple = "dxil-unknown-shadermodel6.7-library"
6944f4b28SXiang Li
7944f4b28SXiang Li; Make sure the size is 24 = 16 + 8 (float,i32,double -> 16 and int2 -> 8)
8944f4b28SXiang Li; DXILMD:!{i32 0, ptr @A.cb., !"", i32 1, i32 2, i32 1, i32 24}
9944f4b28SXiang Li
10944f4b28SXiang Li; Make sure match register(b2, space1) with ID 0.
11944f4b28SXiang Li; PRINT:cbuffer      NA          NA     CB0     cb2,space1     1
12944f4b28SXiang Li
13944f4b28SXiang Li@A.cb. = external constant { float, i32, double, <2 x i32> }
14944f4b28SXiang Li
15944f4b28SXiang Li; Function Attrs: noinline nounwind optnone
16944f4b28SXiang Lidefine noundef float @"?foo@@YAMXZ"() #0 {
17944f4b28SXiang Lientry:
18944f4b28SXiang Li  %0 = load float, ptr @A.cb., align 4
19944f4b28SXiang Li  %conv = fpext float %0 to double
20944f4b28SXiang Li  %1 = load double, ptr getelementptr inbounds ({ float, i32, double, <2 x i32> }, ptr @A.cb., i32 0, i32 2), align 8
21944f4b28SXiang Li  %2 = load <2 x i32>, ptr getelementptr inbounds ({ float, i32, double, <2 x i32> }, ptr @A.cb., i32 0, i32 3), align 8
22944f4b28SXiang Li  %3 = extractelement <2 x i32> %2, i32 1
23944f4b28SXiang Li  %conv1 = sitofp i32 %3 to double
24944f4b28SXiang Li  %4 = call double @llvm.fmuladd.f64(double %1, double %conv1, double %conv)
25944f4b28SXiang Li  %conv2 = fptrunc double %4 to float
26944f4b28SXiang Li  ret float %conv2
27944f4b28SXiang Li}
28944f4b28SXiang Li
29944f4b28SXiang Li; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
30944f4b28SXiang Lideclare double @llvm.fmuladd.f64(double, double, double) #1
31944f4b28SXiang Li
32944f4b28SXiang Liattributes #0 = { noinline nounwind }
33944f4b28SXiang Liattributes #1 = { nocallback nofree nosync nounwind readnone speculatable willreturn }
34944f4b28SXiang Li
35944f4b28SXiang Li!hlsl.cbufs = !{!1}
36944f4b28SXiang Li
377a13e410SJustin Bogner!1 = !{ptr @A.cb., !"A.cb.ty", i32 13, i1 false, i32 2, i32 1}
38