brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.0 KiB · 6f6166e Raw
146 lines · plain
1; RUN: opt -S -dxil-resource-access -mtriple=dxil %s | FileCheck %s2 3; cbuffer CB : register(b0) {4;   float a1[3];        // offset   0,  size 4  (+12) * 35;   double3 a2[2];      // offset   48, size 24  (+8) * 26;   float16_t a3[2][2]; // offset  112, size  2 (+14) * 47;   uint64_t a4[3];     // offset  176, size  8  (+8) * 38;   int4 a5[2][3][4];   // offset  224, size 16       * 249;   uint16_t a6[1];     // offset  608, size  2 (+14) * 110;   int64_t a7[2];      // offset  624, size  8  (+8) * 211;   bool a8[4];         // offset  656, size  4 (+12) * 412; }13%__cblayout_CB = type <{14  <{ [2 x <{ float, target("dx.Padding", 12) }>], float }>, target("dx.Padding", 12),15  <{ [1 x <{ <3 x double>, target("dx.Padding", 8) }>], <3 x double> }>, target("dx.Padding", 8),16  <{ [3 x <{ half, target("dx.Padding", 14) }>], half }>, target("dx.Padding", 14),17  <{ [2 x <{ i64, target("dx.Padding", 8) }>], i64 }>, target("dx.Padding", 8),18  [24 x <4 x i32>],19  [1 x i16], target("dx.Padding", 14),20  <{ [1 x <{ i64, target("dx.Padding", 8) }>], i64 }>, target("dx.Padding", 8),21  <{ [3 x <{ i32, target("dx.Padding", 12) }>], i32 }>22}>23 24@CB.cb = local_unnamed_addr global target("dx.CBuffer", %__cblayout_CB) poison25 26; CHECK: define void @f27define void @f(ptr %dst) {28entry:29  %CB.cb_h.i.i = tail call target("dx.CBuffer", %__cblayout_CB) @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 1, i32 0, ptr null)30  store target("dx.CBuffer", %__cblayout_CB) %CB.cb_h.i.i, ptr @CB.cb, align 431 32  ; CHECK: [[CB:%.*]] = load target("dx.CBuffer", %__cblayout_CB), ptr @CB.cb33  %CB.cb = load target("dx.CBuffer", %__cblayout_CB), ptr @CB.cb, align 434 35  ;; a1[1]36  ;37  ; CHECK: [[LOAD:%.*]] = call { float, float, float, float } @llvm.dx.resource.load.cbufferrow.4.{{.*}}(target("dx.CBuffer", %__cblayout_CB) [[CB]], i32 1)38  ; CHECK: [[X:%.*]] = extractvalue { float, float, float, float } [[LOAD]], 039  ; CHECK: store float [[X]], ptr %dst40  %a1_ptr = call ptr addrspace(2) @llvm.dx.resource.getpointer(target("dx.CBuffer", %__cblayout_CB) %CB.cb, i32 0)41  %a1_gep = getelementptr inbounds nuw i8, ptr addrspace(2) %a1_ptr, i32 1642  %a1 = load float, ptr addrspace(2) %a1_gep, align 443  store float %a1, ptr %dst, align 3244 45  ;; a2[1]46  ;47  ; CHECK: [[LOAD:%.*]] = call { double, double } @llvm.dx.resource.load.cbufferrow.2.{{.*}}(target("dx.CBuffer", %__cblayout_CB) [[CB]], i32 5)48  ; CHECK: [[X:%.*]] = extractvalue { double, double } [[LOAD]], 049  ; CHECK: [[Y:%.*]] = extractvalue { double, double } [[LOAD]], 150  ; CHECK: [[LOAD:%.*]] = call { double, double } @llvm.dx.resource.load.cbufferrow.2.{{.*}}(target("dx.CBuffer", %__cblayout_CB) [[CB]], i32 6)51  ; CHECK: [[Z:%.*]] = extractvalue { double, double } [[LOAD]], 052  ; CHECK: [[VEC0:%.*]] = insertelement <3 x double> poison, double [[X]], i32 053  ; CHECK: [[VEC1:%.*]] = insertelement <3 x double> [[VEC0]], double [[Y]], i32 154  ; CHECK: [[VEC2:%.*]] = insertelement <3 x double> [[VEC1]], double [[Z]], i32 255  ; CHECK: [[PTR:%.*]] = getelementptr inbounds nuw i8, ptr %dst, i32 856  ; CHECK: store <3 x double> [[VEC2]], ptr [[PTR]]57  %a2_ptr = call ptr addrspace(2) @llvm.dx.resource.getpointer(target("dx.CBuffer", %__cblayout_CB) %CB.cb, i32 48)58  %a2_gep = getelementptr inbounds nuw i8, ptr addrspace(2) %a2_ptr, i32 3259  %a2 = load <3 x double>, ptr addrspace(2) %a2_gep, align 860  %a2.i = getelementptr inbounds nuw i8, ptr %dst, i32 861  store <3 x double> %a2, ptr %a2.i, align 3262 63  ;; a3[0][1]64  ;65  ; CHECK: [[LOAD:%.*]] = call { half, half, half, half, half, half, half, half } @llvm.dx.resource.load.cbufferrow.8.{{.*}}(target("dx.CBuffer", %__cblayout_CB) [[CB]], i32 8)66  ; CHECK: [[X:%.*]] = extractvalue { half, half, half, half, half, half, half, half } [[LOAD]], 067  ; CHECK: [[PTR:%.*]] = getelementptr inbounds nuw i8, ptr %dst, i32 3268  ; CHECK: store half [[X]], ptr [[PTR]]69  %a3_ptr = call ptr addrspace(2) @llvm.dx.resource.getpointer(target("dx.CBuffer", %__cblayout_CB) %CB.cb, i32 112)70  %a3_gep = getelementptr inbounds nuw i8, ptr addrspace(2) %a3_ptr, i32 1671  %a3 = load half, ptr addrspace(2) %a3_gep, align 272  %a3.i = getelementptr inbounds nuw i8, ptr %dst, i32 3273  store half %a3, ptr %a3.i, align 274 75  ;; a4[1]76  ;77  ; CHECK: [[LOAD:%.*]] = call { i64, i64 } @llvm.dx.resource.load.cbufferrow.2.{{.*}}(target("dx.CBuffer", %__cblayout_CB) [[CB]], i32 12)78  ; CHECK: [[X:%.*]] = extractvalue { i64, i64 } [[LOAD]], 079  ; CHECK: [[PTR:%.*]] = getelementptr inbounds nuw i8, ptr %dst, i32 4080  ; CHECK: store i64 [[X]], ptr [[PTR]]81  %a4_ptr = call ptr addrspace(2) @llvm.dx.resource.getpointer(target("dx.CBuffer", %__cblayout_CB) %CB.cb, i32 176)82  %a4_gep = getelementptr inbounds nuw i8, ptr addrspace(2) %a4_ptr, i32 1683  %a4 = load i64, ptr addrspace(2) %a4_gep, align 884  %a4.i = getelementptr inbounds nuw i8, ptr %dst, i32 4085  store i64 %a4, ptr %a4.i, align 886 87  ;; a5[1][0][0]88  ;89  ; CHECK: [[LOAD:%.*]] = call { i32, i32, i32, i32 } @llvm.dx.resource.load.cbufferrow.4.{{.*}}(target("dx.CBuffer", %__cblayout_CB) [[CB]], i32 26)90  ; CHECK: [[X:%.*]] = extractvalue { i32, i32, i32, i32 } [[LOAD]], 091  ; CHECK: [[Y:%.*]] = extractvalue { i32, i32, i32, i32 } [[LOAD]], 192  ; CHECK: [[Z:%.*]] = extractvalue { i32, i32, i32, i32 } [[LOAD]], 293  ; CHECK: [[A:%.*]] = extractvalue { i32, i32, i32, i32 } [[LOAD]], 394  ; CHECK: [[VEC0:%.*]] = insertelement <4 x i32> poison, i32 [[X]], i32 095  ; CHECK: [[VEC1:%.*]] = insertelement <4 x i32> [[VEC0]], i32 [[Y]], i32 196  ; CHECK: [[VEC2:%.*]] = insertelement <4 x i32> [[VEC1]], i32 [[Z]], i32 297  ; CHECK: [[VEC3:%.*]] = insertelement <4 x i32> [[VEC2]], i32 [[A]], i32 398  ; CHECK: [[PTR:%.*]] = getelementptr inbounds nuw i8, ptr %dst, i32 4899  ; CHECK: store <4 x i32> [[VEC3]], ptr [[PTR]]100  %a5_ptr = call ptr addrspace(2) @llvm.dx.resource.getpointer(target("dx.CBuffer", %__cblayout_CB) %CB.cb, i32 224)101  %a5_gep = getelementptr inbounds nuw i8, ptr addrspace(2) %a5_ptr, i32 192102  %a5 = load <4 x i32>, ptr addrspace(2) %a5_gep, align 4103  %a5.i = getelementptr inbounds nuw i8, ptr %dst, i32 48104  store <4 x i32> %a5, ptr %a5.i, align 4105 106  ;; a6[0]107  ;108  ; CHECK: [[LOAD:%.*]] = call { i16, i16, i16, i16, i16, i16, i16, i16 } @llvm.dx.resource.load.cbufferrow.8.{{.*}}(target("dx.CBuffer", %__cblayout_CB) [[CB]], i32 38)109  ; CHECK: [[X:%.*]] = extractvalue { i16, i16, i16, i16, i16, i16, i16, i16 } [[LOAD]], 0110  ; CHECK: [[PTR:%.*]] = getelementptr inbounds nuw i8, ptr %dst, i32 64111  ; CHECK: store i16 [[X]], ptr [[PTR]]112  %a6_ptr = call ptr addrspace(2) @llvm.dx.resource.getpointer(target("dx.CBuffer", %__cblayout_CB) %CB.cb, i32 608)113  %a6 = load i16, ptr addrspace(2) %a6_ptr, align 2114  %a6.i = getelementptr inbounds nuw i8, ptr %dst, i32 64115  store i16 %a6, ptr %a6.i, align 2116 117  ;; a7[1]118  ;119  ; CHECK: [[LOAD:%.*]] = call { i64, i64 } @llvm.dx.resource.load.cbufferrow.2.{{.*}}(target("dx.CBuffer", %__cblayout_CB) [[CB]], i32 40)120  ; CHECK: [[X:%.*]] = extractvalue { i64, i64 } [[LOAD]], 0121  ; CHECK: [[PTR:%.*]] = getelementptr inbounds nuw i8, ptr %dst, i32 72122  ; CHECK: store i64 [[X]], ptr [[PTR]]123  %a7_ptr = call ptr addrspace(2) @llvm.dx.resource.getpointer(target("dx.CBuffer", %__cblayout_CB) %CB.cb, i32 624)124  %a7_gep = getelementptr inbounds nuw i8, ptr addrspace(2) %a7_ptr, i32 16125  %a7 = load i64, ptr addrspace(2) %a7_gep, align 8126  %a7.i = getelementptr inbounds nuw i8, ptr %dst, i32 72127  store i64 %a7, ptr %a7.i, align 8128 129  ;; a8[1]130  ;131  ; CHECK: [[LOAD:%.*]] = call { i32, i32, i32, i32 } @llvm.dx.resource.load.cbufferrow.4.{{.*}}(target("dx.CBuffer", %__cblayout_CB) [[CB]], i32 42)132  ; CHECK: [[X:%.*]] = extractvalue { i32, i32, i32, i32 } [[LOAD]], 0133  ; CHECK: [[PTR:%.*]] = getelementptr inbounds nuw i8, ptr %dst, i32 80134  ; CHECK: store i32 [[X]], ptr [[PTR]]135  %a8_ptr = call ptr addrspace(2) @llvm.dx.resource.getpointer(target("dx.CBuffer", %__cblayout_CB) %CB.cb, i32 656)136  %a8_gep = getelementptr inbounds nuw i8, ptr addrspace(2) %a8_ptr, i32 16137  %a8 = load i32, ptr addrspace(2) %a8_gep, align 4, !range !0, !noundef !1138  %a8.i = getelementptr inbounds nuw i8, ptr %dst, i32 80139  store i32 %a8, ptr %a8.i, align 4140 141  ret void142}143 144!0 = !{i32 0, i32 2}145!1 = !{}146