1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx900 -mattr=+architected-sgprs --verify-machineinstrs < %s | FileCheck -check-prefix=GFX9-SDAG %s
3 ; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx900 -mattr=+architected-sgprs -global-isel --verify-machineinstrs < %s | FileCheck -check-prefix=GFX9-GISEL %s
5 define amdgpu_cs void @_amdgpu_cs_main() {
6 ; GFX9-SDAG-LABEL: _amdgpu_cs_main:
7 ; GFX9-SDAG: ; %bb.0: ; %.entry
8 ; GFX9-SDAG-NEXT: s_lshr_b32 s2, ttmp7, 16
9 ; GFX9-SDAG-NEXT: s_and_b32 s1, ttmp7, 0xffff
10 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v0, ttmp9
11 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v1, s1
12 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v2, s2
13 ; GFX9-SDAG-NEXT: buffer_store_dwordx3 v[0:2], off, s[0:3], 0
14 ; GFX9-SDAG-NEXT: s_endpgm
16 ; GFX9-GISEL-LABEL: _amdgpu_cs_main:
17 ; GFX9-GISEL: ; %bb.0: ; %.entry
18 ; GFX9-GISEL-NEXT: s_mov_b32 s0, ttmp9
19 ; GFX9-GISEL-NEXT: s_and_b32 s1, ttmp7, 0xffff
20 ; GFX9-GISEL-NEXT: s_lshr_b32 s2, ttmp7, 16
21 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v0, s0
22 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v1, s1
23 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v2, s2
24 ; GFX9-GISEL-NEXT: buffer_store_dwordx3 v[0:2], off, s[0:3], 0
25 ; GFX9-GISEL-NEXT: s_endpgm
27 %idx = call i32 @llvm.amdgcn.workgroup.id.x()
28 %idy = call i32 @llvm.amdgcn.workgroup.id.y()
29 %idz = call i32 @llvm.amdgcn.workgroup.id.z()
30 %ielemx = insertelement <3 x i32> undef, i32 %idx, i64 0
31 %ielemy = insertelement <3 x i32> %ielemx, i32 %idy, i64 1
32 %ielemz = insertelement <3 x i32> %ielemy, i32 %idz, i64 2
33 call void @llvm.amdgcn.raw.ptr.buffer.store.v3i32(<3 x i32> %ielemz, ptr addrspace(8) undef, i32 0, i32 0, i32 0)
37 define amdgpu_cs void @caller() {
38 ; GFX9-SDAG-LABEL: caller:
40 ; GFX9-SDAG-NEXT: s_getpc_b64 s[8:9]
41 ; GFX9-SDAG-NEXT: s_mov_b32 s8, s0
42 ; GFX9-SDAG-NEXT: s_load_dwordx4 s[8:11], s[8:9], 0x10
43 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v0, ttmp9
44 ; GFX9-SDAG-NEXT: s_mov_b32 s32, 0
45 ; GFX9-SDAG-NEXT: s_waitcnt lgkmcnt(0)
46 ; GFX9-SDAG-NEXT: s_add_u32 s8, s8, s0
47 ; GFX9-SDAG-NEXT: s_addc_u32 s9, s9, 0
48 ; GFX9-SDAG-NEXT: s_getpc_b64 s[0:1]
49 ; GFX9-SDAG-NEXT: s_add_u32 s0, s0, callee@gotpcrel32@lo+4
50 ; GFX9-SDAG-NEXT: s_addc_u32 s1, s1, callee@gotpcrel32@hi+12
51 ; GFX9-SDAG-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
52 ; GFX9-SDAG-NEXT: s_mov_b64 s[0:1], s[8:9]
53 ; GFX9-SDAG-NEXT: s_mov_b64 s[2:3], s[10:11]
54 ; GFX9-SDAG-NEXT: s_waitcnt lgkmcnt(0)
55 ; GFX9-SDAG-NEXT: s_swappc_b64 s[30:31], s[4:5]
56 ; GFX9-SDAG-NEXT: s_endpgm
58 ; GFX9-GISEL-LABEL: caller:
59 ; GFX9-GISEL: ; %bb.0:
60 ; GFX9-GISEL-NEXT: s_getpc_b64 s[8:9]
61 ; GFX9-GISEL-NEXT: s_mov_b32 s8, s0
62 ; GFX9-GISEL-NEXT: s_load_dwordx4 s[8:11], s[8:9], 0x10
63 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v0, ttmp9
64 ; GFX9-GISEL-NEXT: s_mov_b32 s32, 0
65 ; GFX9-GISEL-NEXT: s_waitcnt lgkmcnt(0)
66 ; GFX9-GISEL-NEXT: s_add_u32 s8, s8, s0
67 ; GFX9-GISEL-NEXT: s_addc_u32 s9, s9, 0
68 ; GFX9-GISEL-NEXT: s_getpc_b64 s[0:1]
69 ; GFX9-GISEL-NEXT: s_add_u32 s0, s0, callee@gotpcrel32@lo+4
70 ; GFX9-GISEL-NEXT: s_addc_u32 s1, s1, callee@gotpcrel32@hi+12
71 ; GFX9-GISEL-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
72 ; GFX9-GISEL-NEXT: s_mov_b64 s[0:1], s[8:9]
73 ; GFX9-GISEL-NEXT: s_mov_b64 s[2:3], s[10:11]
74 ; GFX9-GISEL-NEXT: s_waitcnt lgkmcnt(0)
75 ; GFX9-GISEL-NEXT: s_swappc_b64 s[30:31], s[4:5]
76 ; GFX9-GISEL-NEXT: s_endpgm
77 %idx = call i32 @llvm.amdgcn.workgroup.id.x()
78 call amdgpu_gfx void @callee(i32 %idx)
82 declare amdgpu_gfx void @callee(i32)
84 declare i32 @llvm.amdgcn.workgroup.id.x()
85 declare i32 @llvm.amdgcn.workgroup.id.y()
86 declare i32 @llvm.amdgcn.workgroup.id.z()
87 declare void @llvm.amdgcn.raw.ptr.buffer.store.v3i32(<3 x i32>, ptr addrspace(8), i32, i32, i32 immarg)