forked from GPUOpen-Drivers/llpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CallLibFromCs-indirect.lgc
63 lines (56 loc) · 4 KB
/
CallLibFromCs-indirect.lgc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
; Call an extern compute library function from a compute shader.
; RUN: lgc -mcpu=gfx1010 -print-after=lgc-patch-entry-point-mutate -o /dev/null 2>&1 - <%s | FileCheck --check-prefixes=CHECK %s
; CHECK: IR Dump After Patch LLVM for entry-point mutation
; CHECK: define dllexport spir_func void @lgc.shader.CS.main(i32 inreg %globalTable, i32 inreg %perShaderTable, <3 x i32> addrspace(4)* inreg %numWorkgroupsPtr, i32 inreg %descTable2, i32 inreg %0, i32 inreg %1, i32 inreg %2, i32 inreg %3, i32 inreg %4, i32 inreg %5, i32 inreg %6, i32 inreg %7, i32 inreg %8, i32 inreg %9, i32 inreg %spillTable, <3 x i32> inreg %WorkgroupId, i32 inreg %MultiDispatchInfo, <3 x i32> %LocalInvocationId) #1 !lgc.shaderstage !7 {
; CHECK: %[[#]] = call amdgpu_gfx i32 %[[#]](i32 inreg %globalTable, i32 inreg %perShaderTable, <3 x i32> addrspace(4)* inreg %numWorkgroupsPtr, i32 inreg %descTable2, i32 inreg %0, i32 inreg %1, i32 inreg %2, i32 inreg %3, i32 inreg %4, i32 inreg %5, i32 inreg %6, i32 inreg %7, i32 inreg %8, i32 inreg %9, i32 inreg %spillTable, <3 x i32> inreg %WorkgroupId, i32 inreg %MultiDispatchInfo, <3 x i32> %LocalInvocationId)
; CHECK: !7 = !{i32 7}
; ModuleID = 'lgcPipeline'
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-ni:7"
target triple = "amdgcn--amdpal"
; Function Attrs: nounwind
define dllexport spir_func void @lgc.shader.CS.main() local_unnamed_addr #0 !lgc.shaderstage !7 {
.entry:
%0 = call i8 addrspace(7)* (...) @lgc.create.load.buffer.desc.p7i8(i32 0, i32 2, i32 0, i32 2)
%1 = call i8 addrspace(7)* (...) @lgc.create.load.buffer.desc.p7i8(i32 0, i32 0, i32 0, i32 2)
%2 = call i8 addrspace(7)* (...) @lgc.create.load.buffer.desc.p7i8(i32 0, i32 1, i32 0, i32 2)
%3 = bitcast i8 addrspace(7)* %2 to <4 x i32> addrspace(7)*
%4 = load <4 x i32>, <4 x i32> addrspace(7)* %3, align 16
%5 = call i8 addrspace(7)* (...) @lgc.create.load.buffer.desc.p7i8(i32 0, i32 1, i32 1, i32 2)
%6 = bitcast i8 addrspace(7)* %5 to <4 x i32> addrspace(7)*
%7 = load <4 x i32>, <4 x i32> addrspace(7)* %6, align 16
%8 = add <4 x i32> %4, %7
%9 = call i8 addrspace(7)* (...) @lgc.create.load.buffer.desc.p7i8(i32 0, i32 1, i32 2, i32 2)
%10 = bitcast i8 addrspace(7)* %9 to <4 x i32> addrspace(7)*
%11 = load <4 x i32>, <4 x i32> addrspace(7)* %10, align 16
%12 = add <4 x i32> %8, %11
%13 = call i8 addrspace(7)* (...) @lgc.create.load.buffer.desc.p7i8(i32 0, i32 1, i32 3, i32 2)
%14 = bitcast i8 addrspace(7)* %13 to <4 x i32> addrspace(7)*
%15 = load <4 x i32>, <4 x i32> addrspace(7)* %14, align 16
%16 = add <4 x i32> %12, %15
%17 = bitcast i8 addrspace(7)* %0 to <4 x i32> addrspace(7)*
%18 = load <4 x i32>, <4 x i32> addrspace(7)* %17, align 16
%19 = add <4 x i32> %16, %18
%20 = bitcast i8 addrspace(7)* %1 to <4 x i32> addrspace(7)*
%func_ptr_ptr = bitcast i8 addrspace(7)* %1 to i32()* addrspace(7)*
%func_ptr = load i32()*, i32()* addrspace(7)* %func_ptr_ptr, align 16
%v = call spir_func i32 %func_ptr()
%v2 = insertelement <4 x i32> %19, i32 %v, i32 0
store <4 x i32> %v2, <4 x i32> addrspace(7)* %20, align 16
ret void
}
; Function Attrs: nounwind readonly
declare i8 addrspace(7)* @lgc.create.load.buffer.desc.p7i8(...) local_unnamed_addr #1
attributes #0 = { nounwind }
attributes #1 = { nounwind readonly }
!llpc.compute.mode = !{!0}
!lgc.options = !{!1}
!lgc.options.CS = !{!2}
!lgc.user.data.nodes = !{!3, !4, !5, !6}
!0 = !{i32 2, i32 3, i32 1}
!1 = !{i32 2113342239, i32 1385488414, i32 -1007072744, i32 -815526592, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 2}
!2 = !{i32 1792639877, i32 1348715323, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 64, i32 0, i32 0, i32 3}
!3 = !{!"DescriptorBuffer", i32 0, i32 4, i32 0, i32 0, i32 4}
!4 = !{!"DescriptorBuffer", i32 4, i32 16, i32 0, i32 1, i32 4}
!5 = !{!"DescriptorTableVaPtr", i32 20, i32 1, i32 1}
!6 = !{!"DescriptorBuffer", i32 0, i32 4, i32 0, i32 2, i32 4}
!7 = !{i32 7}