brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 7daebae Raw
47 lines · plain
1; RUN: opt -S -dxil-resource-access -mtriple=dxil %s | FileCheck %s2;3; Tests for dynamic indices into arrays in cbuffers.4 5; cbuffer CB : register(b0) {6;   uint s[10]; // offset   0,  size  4 (+12) * 107;   uint t[12]; // offset 160,  size  4 (+12) * 128; }9%__cblayout_CB = type <{ <{ [9 x <{ i32, target("dx.Padding", 12) }>], i32 }>, target("dx.Padding", 12), <{ [11 x <{ i32, target("dx.Padding", 12) }>], i32 }> }>10 11@CB.cb = local_unnamed_addr global target("dx.CBuffer", %__cblayout_CB) poison12 13; CHECK: define void @f14define void @f(ptr %dst, i32 %idx) {15entry:16  %CB.cb_h = tail call target("dx.CBuffer", %__cblayout_CB) @llvm.dx.resource.handlefromimplicitbinding(i32 1, i32 0, i32 1, i32 0, ptr null)17  store target("dx.CBuffer", %__cblayout_CB) %CB.cb_h, ptr @CB.cb, align 418 19  ; CHECK: [[CB:%.*]] = load target("dx.CBuffer", %__cblayout_CB), ptr @CB.cb20  %CB.cb = load target("dx.CBuffer", %__cblayout_CB), ptr @CB.cb, align 421 22  ;; s[idx]23  ;24  ; CHECK: [[LOAD:%.*]] = call { i32, i32, i32, i32 } @llvm.dx.resource.load.cbufferrow.4.{{.*}}(target("dx.CBuffer", %__cblayout_CB) [[CB]], i32 %idx)25  ; CHECK: [[X:%.*]] = extractvalue { i32, i32, i32, i32 } [[LOAD]], 026  ; CHECK: store i32 [[X]], ptr %dst27  %s_ptr = call ptr addrspace(2) @llvm.dx.resource.getpointer(target("dx.CBuffer", %__cblayout_CB) %CB.cb, i32 0)28  %s_gep = getelementptr <{ i32, target("dx.Padding", 12) }>, ptr addrspace(2) %s_ptr, i32 %idx29  %s_load = load i32, ptr addrspace(2) %s_gep, align 430  store i32 %s_load, ptr %dst, align 431 32  ;; t[idx]33  ;34  ; CHECK: [[T_IDX:%.*]] = add i32 10, %idx35  ; CHECK: [[LOAD:%.*]] = call { i32, i32, i32, i32 } @llvm.dx.resource.load.cbufferrow.4.{{.*}}(target("dx.CBuffer", %__cblayout_CB) [[CB]], i32 [[T_IDX]])36  ; CHECK: [[X:%.*]] = extractvalue { i32, i32, i32, i32 } [[LOAD]], 037  ; CHECK: [[PTR:%.*]] = getelementptr inbounds nuw i8, ptr %dst, i32 438  ; CHECK: store i32 [[X]], ptr [[PTR]]39  %t_ptr = call ptr addrspace(2) @llvm.dx.resource.getpointer(target("dx.CBuffer", %__cblayout_CB) %CB.cb, i32 160)40  %t_gep = getelementptr <{ i32, target("dx.Padding", 12) }>, ptr addrspace(2) %t_ptr, i32 %idx41  %t_load = load i32, ptr addrspace(2) %t_gep, align 442  %t.i = getelementptr inbounds nuw i8, ptr %dst, i32 443  store i32 %t_load, ptr %t.i, align 444 45  ret void46}47