xref: /aosp_15_r20/external/llvm/test/CodeGen/AMDGPU/target-cpu.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Workerdeclare i8 addrspace(2)* @llvm.amdgcn.kernarg.segment.ptr() #1
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Workerdeclare i32 @llvm.amdgcn.workitem.id.x() #1
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker; CI+ intrinsic
8*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.amdgcn.s.dcache.inv.vol() #0
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Worker; VI+ intrinsic
11*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.amdgcn.s.dcache.wb() #0
12*9880d681SAndroid Build Coastguard Worker
13*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: {{^}}target_none:
14*9880d681SAndroid Build Coastguard Worker; CHECK: s_movk_i32 [[OFFSETREG:s[0-9]+]], 0x400
15*9880d681SAndroid Build Coastguard Worker; CHECK: s_load_dwordx2 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, [[OFFSETREG]]
16*9880d681SAndroid Build Coastguard Worker; CHECK: buffer_store_dword v{{[0-9]+}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64
17*9880d681SAndroid Build Coastguard Workerdefine void @target_none() #0 {
18*9880d681SAndroid Build Coastguard Worker  %kernargs = call i8 addrspace(2)* @llvm.amdgcn.kernarg.segment.ptr()
19*9880d681SAndroid Build Coastguard Worker  %kernargs.gep = getelementptr inbounds i8, i8 addrspace(2)* %kernargs, i64 1024
20*9880d681SAndroid Build Coastguard Worker  %kernargs.gep.cast = bitcast i8 addrspace(2)* %kernargs.gep to i32 addrspace(1)* addrspace(2)*
21*9880d681SAndroid Build Coastguard Worker  %ptr = load i32 addrspace(1)*, i32 addrspace(1)* addrspace(2)* %kernargs.gep.cast
22*9880d681SAndroid Build Coastguard Worker  %id = call i32 @llvm.amdgcn.workitem.id.x()
23*9880d681SAndroid Build Coastguard Worker  %id.ext = sext i32 %id to i64
24*9880d681SAndroid Build Coastguard Worker  %gep = getelementptr inbounds i32, i32 addrspace(1)* %ptr, i64 %id.ext
25*9880d681SAndroid Build Coastguard Worker  store i32 0, i32 addrspace(1)* %gep
26*9880d681SAndroid Build Coastguard Worker  ret void
27*9880d681SAndroid Build Coastguard Worker}
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: {{^}}target_tahiti:
30*9880d681SAndroid Build Coastguard Worker; CHECK: s_movk_i32 [[OFFSETREG:s[0-9]+]], 0x400
31*9880d681SAndroid Build Coastguard Worker; CHECK: s_load_dwordx2 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, [[OFFSETREG]]
32*9880d681SAndroid Build Coastguard Worker; CHECK: buffer_store_dword v{{[0-9]+}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64
33*9880d681SAndroid Build Coastguard Workerdefine void @target_tahiti() #1 {
34*9880d681SAndroid Build Coastguard Worker  %kernargs = call i8 addrspace(2)* @llvm.amdgcn.kernarg.segment.ptr()
35*9880d681SAndroid Build Coastguard Worker  %kernargs.gep = getelementptr inbounds i8, i8 addrspace(2)* %kernargs, i64 1024
36*9880d681SAndroid Build Coastguard Worker  %kernargs.gep.cast = bitcast i8 addrspace(2)* %kernargs.gep to i32 addrspace(1)* addrspace(2)*
37*9880d681SAndroid Build Coastguard Worker  %ptr = load i32 addrspace(1)*, i32 addrspace(1)* addrspace(2)* %kernargs.gep.cast
38*9880d681SAndroid Build Coastguard Worker  %id = call i32 @llvm.amdgcn.workitem.id.x()
39*9880d681SAndroid Build Coastguard Worker  %id.ext = sext i32 %id to i64
40*9880d681SAndroid Build Coastguard Worker  %gep = getelementptr inbounds i32, i32 addrspace(1)* %ptr, i64 %id.ext
41*9880d681SAndroid Build Coastguard Worker  store i32 0, i32 addrspace(1)* %gep
42*9880d681SAndroid Build Coastguard Worker  ret void
43*9880d681SAndroid Build Coastguard Worker}
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: {{^}}target_bonaire:
46*9880d681SAndroid Build Coastguard Worker; CHECK: s_load_dwordx2 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0x100
47*9880d681SAndroid Build Coastguard Worker; CHECK: buffer_store_dword v{{[0-9]+}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64
48*9880d681SAndroid Build Coastguard Worker; CHECK: s_dcache_inv_vol
49*9880d681SAndroid Build Coastguard Workerdefine void @target_bonaire() #3 {
50*9880d681SAndroid Build Coastguard Worker  %kernargs = call i8 addrspace(2)* @llvm.amdgcn.kernarg.segment.ptr()
51*9880d681SAndroid Build Coastguard Worker  %kernargs.gep = getelementptr inbounds i8, i8 addrspace(2)* %kernargs, i64 1024
52*9880d681SAndroid Build Coastguard Worker  %kernargs.gep.cast = bitcast i8 addrspace(2)* %kernargs.gep to i32 addrspace(1)* addrspace(2)*
53*9880d681SAndroid Build Coastguard Worker  %ptr = load i32 addrspace(1)*, i32 addrspace(1)* addrspace(2)* %kernargs.gep.cast
54*9880d681SAndroid Build Coastguard Worker  %id = call i32 @llvm.amdgcn.workitem.id.x()
55*9880d681SAndroid Build Coastguard Worker  %id.ext = sext i32 %id to i64
56*9880d681SAndroid Build Coastguard Worker  %gep = getelementptr inbounds i32, i32 addrspace(1)* %ptr, i64 %id.ext
57*9880d681SAndroid Build Coastguard Worker  store i32 0, i32 addrspace(1)* %gep
58*9880d681SAndroid Build Coastguard Worker  call void @llvm.amdgcn.s.dcache.inv.vol()
59*9880d681SAndroid Build Coastguard Worker  ret void
60*9880d681SAndroid Build Coastguard Worker}
61*9880d681SAndroid Build Coastguard Worker
62*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: {{^}}target_fiji:
63*9880d681SAndroid Build Coastguard Worker; CHECK: s_load_dwordx2 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0x400
64*9880d681SAndroid Build Coastguard Worker; CHECK: flat_store_dword
65*9880d681SAndroid Build Coastguard Worker; CHECK: s_dcache_wb{{$}}
66*9880d681SAndroid Build Coastguard Workerdefine void @target_fiji() #4 {
67*9880d681SAndroid Build Coastguard Worker  %kernargs = call i8 addrspace(2)* @llvm.amdgcn.kernarg.segment.ptr()
68*9880d681SAndroid Build Coastguard Worker  %kernargs.gep = getelementptr inbounds i8, i8 addrspace(2)* %kernargs, i64 1024
69*9880d681SAndroid Build Coastguard Worker  %kernargs.gep.cast = bitcast i8 addrspace(2)* %kernargs.gep to i32 addrspace(1)* addrspace(2)*
70*9880d681SAndroid Build Coastguard Worker  %ptr = load i32 addrspace(1)*, i32 addrspace(1)* addrspace(2)* %kernargs.gep.cast
71*9880d681SAndroid Build Coastguard Worker  %id = call i32 @llvm.amdgcn.workitem.id.x()
72*9880d681SAndroid Build Coastguard Worker  %id.ext = sext i32 %id to i64
73*9880d681SAndroid Build Coastguard Worker  %gep = getelementptr inbounds i32, i32 addrspace(1)* %ptr, i64 %id.ext
74*9880d681SAndroid Build Coastguard Worker  store i32 0, i32 addrspace(1)* %gep
75*9880d681SAndroid Build Coastguard Worker  call void @llvm.amdgcn.s.dcache.wb()
76*9880d681SAndroid Build Coastguard Worker  ret void
77*9880d681SAndroid Build Coastguard Worker}
78*9880d681SAndroid Build Coastguard Worker
79*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: {{^}}promote_alloca_enabled:
80*9880d681SAndroid Build Coastguard Worker; CHECK: ds_read_b32
81*9880d681SAndroid Build Coastguard Worker; CHECK: ; LDSByteSize: 5120
82*9880d681SAndroid Build Coastguard Workerdefine void @promote_alloca_enabled(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) #5 {
83*9880d681SAndroid Build Coastguard Workerentry:
84*9880d681SAndroid Build Coastguard Worker  %stack = alloca [5 x i32], align 4
85*9880d681SAndroid Build Coastguard Worker  %tmp = load i32, i32 addrspace(1)* %in, align 4
86*9880d681SAndroid Build Coastguard Worker  %arrayidx1 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %tmp
87*9880d681SAndroid Build Coastguard Worker  %load = load i32, i32* %arrayidx1
88*9880d681SAndroid Build Coastguard Worker  store i32 %load, i32 addrspace(1)* %out
89*9880d681SAndroid Build Coastguard Worker  ret void
90*9880d681SAndroid Build Coastguard Worker}
91*9880d681SAndroid Build Coastguard Worker
92*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: {{^}}promote_alloca_disabled:
93*9880d681SAndroid Build Coastguard Worker; CHECK: SCRATCH_RSRC_DWORD0
94*9880d681SAndroid Build Coastguard Worker; CHECK: SCRATCH_RSRC_DWORD1
95*9880d681SAndroid Build Coastguard Worker; CHECK: ScratchSize: 24
96*9880d681SAndroid Build Coastguard Workerdefine void @promote_alloca_disabled(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) #6 {
97*9880d681SAndroid Build Coastguard Workerentry:
98*9880d681SAndroid Build Coastguard Worker  %stack = alloca [5 x i32], align 4
99*9880d681SAndroid Build Coastguard Worker  %tmp = load i32, i32 addrspace(1)* %in, align 4
100*9880d681SAndroid Build Coastguard Worker  %arrayidx1 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %tmp
101*9880d681SAndroid Build Coastguard Worker  %load = load i32, i32* %arrayidx1
102*9880d681SAndroid Build Coastguard Worker  store i32 %load, i32 addrspace(1)* %out
103*9880d681SAndroid Build Coastguard Worker  ret void
104*9880d681SAndroid Build Coastguard Worker}
105*9880d681SAndroid Build Coastguard Worker
106*9880d681SAndroid Build Coastguard Workerattributes #0 = { nounwind }
107*9880d681SAndroid Build Coastguard Workerattributes #1 = { nounwind readnone }
108*9880d681SAndroid Build Coastguard Workerattributes #2 = { nounwind "target-cpu"="tahiti" }
109*9880d681SAndroid Build Coastguard Workerattributes #3 = { nounwind "target-cpu"="bonaire" }
110*9880d681SAndroid Build Coastguard Workerattributes #4 = { nounwind "target-cpu"="fiji" }
111*9880d681SAndroid Build Coastguard Workerattributes #5 = { nounwind "target-features"="+promote-alloca" "amdgpu-max-waves-per-eu"="3" }
112*9880d681SAndroid Build Coastguard Workerattributes #6 = { nounwind "target-features"="-promote-alloca" "amdgpu-max-waves-per-eu"="3" }
113