llvm/llvm/test/CodeGen/AMDGPU/gfx-call-non-gfx-func.ll

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=amdgcn--amdpal -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefix=SDAG -enable-var-scope %s
; RUN: llc -global-isel -mtriple=amdgcn--amdpal -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefix=GISEL -enable-var-scope %s

declare void @extern_c_func()

define amdgpu_gfx void @gfx_func() {
; SDAG-LABEL: gfx_func:
; SDAG:       ; %bb.0:
; SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; SDAG-NEXT:    s_mov_b32 s36, s33
; SDAG-NEXT:    s_mov_b32 s33, s32
; SDAG-NEXT:    s_or_saveexec_b64 s[34:35], -1
; SDAG-NEXT:    buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill
; SDAG-NEXT:    s_mov_b64 exec, s[34:35]
; SDAG-NEXT:    v_writelane_b32 v40, s4, 0
; SDAG-NEXT:    v_writelane_b32 v40, s5, 1
; SDAG-NEXT:    v_writelane_b32 v40, s6, 2
; SDAG-NEXT:    v_writelane_b32 v40, s7, 3
; SDAG-NEXT:    v_writelane_b32 v40, s8, 4
; SDAG-NEXT:    v_writelane_b32 v40, s9, 5
; SDAG-NEXT:    v_writelane_b32 v40, s10, 6
; SDAG-NEXT:    v_writelane_b32 v40, s11, 7
; SDAG-NEXT:    v_writelane_b32 v40, s12, 8
; SDAG-NEXT:    v_writelane_b32 v40, s13, 9
; SDAG-NEXT:    v_writelane_b32 v40, s14, 10
; SDAG-NEXT:    v_writelane_b32 v40, s15, 11
; SDAG-NEXT:    v_writelane_b32 v40, s16, 12
; SDAG-NEXT:    v_writelane_b32 v40, s17, 13
; SDAG-NEXT:    v_writelane_b32 v40, s18, 14
; SDAG-NEXT:    v_writelane_b32 v40, s19, 15
; SDAG-NEXT:    v_writelane_b32 v40, s20, 16
; SDAG-NEXT:    v_writelane_b32 v40, s21, 17
; SDAG-NEXT:    v_writelane_b32 v40, s22, 18
; SDAG-NEXT:    v_writelane_b32 v40, s23, 19
; SDAG-NEXT:    v_writelane_b32 v40, s24, 20
; SDAG-NEXT:    v_writelane_b32 v40, s25, 21
; SDAG-NEXT:    v_writelane_b32 v40, s26, 22
; SDAG-NEXT:    v_writelane_b32 v40, s27, 23
; SDAG-NEXT:    v_writelane_b32 v40, s28, 24
; SDAG-NEXT:    v_writelane_b32 v40, s29, 25
; SDAG-NEXT:    v_writelane_b32 v40, s30, 26
; SDAG-NEXT:    s_mov_b32 s35, extern_c_func@abs32@hi
; SDAG-NEXT:    s_mov_b32 s34, extern_c_func@abs32@lo
; SDAG-NEXT:    s_mov_b64 s[8:9], 0
; SDAG-NEXT:    s_addk_i32 s32, 0x400
; SDAG-NEXT:    v_writelane_b32 v40, s31, 27
; SDAG-NEXT:    s_swappc_b64 s[30:31], s[34:35]
; SDAG-NEXT:    v_readlane_b32 s31, v40, 27
; SDAG-NEXT:    v_readlane_b32 s30, v40, 26
; SDAG-NEXT:    v_readlane_b32 s29, v40, 25
; SDAG-NEXT:    v_readlane_b32 s28, v40, 24
; SDAG-NEXT:    v_readlane_b32 s27, v40, 23
; SDAG-NEXT:    v_readlane_b32 s26, v40, 22
; SDAG-NEXT:    v_readlane_b32 s25, v40, 21
; SDAG-NEXT:    v_readlane_b32 s24, v40, 20
; SDAG-NEXT:    v_readlane_b32 s23, v40, 19
; SDAG-NEXT:    v_readlane_b32 s22, v40, 18
; SDAG-NEXT:    v_readlane_b32 s21, v40, 17
; SDAG-NEXT:    v_readlane_b32 s20, v40, 16
; SDAG-NEXT:    v_readlane_b32 s19, v40, 15
; SDAG-NEXT:    v_readlane_b32 s18, v40, 14
; SDAG-NEXT:    v_readlane_b32 s17, v40, 13
; SDAG-NEXT:    v_readlane_b32 s16, v40, 12
; SDAG-NEXT:    v_readlane_b32 s15, v40, 11
; SDAG-NEXT:    v_readlane_b32 s14, v40, 10
; SDAG-NEXT:    v_readlane_b32 s13, v40, 9
; SDAG-NEXT:    v_readlane_b32 s12, v40, 8
; SDAG-NEXT:    v_readlane_b32 s11, v40, 7
; SDAG-NEXT:    v_readlane_b32 s10, v40, 6
; SDAG-NEXT:    v_readlane_b32 s9, v40, 5
; SDAG-NEXT:    v_readlane_b32 s8, v40, 4
; SDAG-NEXT:    v_readlane_b32 s7, v40, 3
; SDAG-NEXT:    v_readlane_b32 s6, v40, 2
; SDAG-NEXT:    v_readlane_b32 s5, v40, 1
; SDAG-NEXT:    v_readlane_b32 s4, v40, 0
; SDAG-NEXT:    s_or_saveexec_b64 s[34:35], -1
; SDAG-NEXT:    buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload
; SDAG-NEXT:    s_mov_b64 exec, s[34:35]
; SDAG-NEXT:    s_addk_i32 s32, 0xfc00
; SDAG-NEXT:    s_mov_b32 s33, s36
; SDAG-NEXT:    s_waitcnt vmcnt(0)
; SDAG-NEXT:    s_setpc_b64 s[30:31]
;
; GISEL-LABEL: gfx_func:
; GISEL:       ; %bb.0:
; GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GISEL-NEXT:    s_mov_b32 s36, s33
; GISEL-NEXT:    s_mov_b32 s33, s32
; GISEL-NEXT:    s_or_saveexec_b64 s[34:35], -1
; GISEL-NEXT:    buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill
; GISEL-NEXT:    s_mov_b64 exec, s[34:35]
; GISEL-NEXT:    v_writelane_b32 v40, s4, 0
; GISEL-NEXT:    v_writelane_b32 v40, s5, 1
; GISEL-NEXT:    v_writelane_b32 v40, s6, 2
; GISEL-NEXT:    v_writelane_b32 v40, s7, 3
; GISEL-NEXT:    v_writelane_b32 v40, s8, 4
; GISEL-NEXT:    v_writelane_b32 v40, s9, 5
; GISEL-NEXT:    v_writelane_b32 v40, s10, 6
; GISEL-NEXT:    v_writelane_b32 v40, s11, 7
; GISEL-NEXT:    v_writelane_b32 v40, s12, 8
; GISEL-NEXT:    v_writelane_b32 v40, s13, 9
; GISEL-NEXT:    v_writelane_b32 v40, s14, 10
; GISEL-NEXT:    v_writelane_b32 v40, s15, 11
; GISEL-NEXT:    v_writelane_b32 v40, s16, 12
; GISEL-NEXT:    v_writelane_b32 v40, s17, 13
; GISEL-NEXT:    v_writelane_b32 v40, s18, 14
; GISEL-NEXT:    v_writelane_b32 v40, s19, 15
; GISEL-NEXT:    v_writelane_b32 v40, s20, 16
; GISEL-NEXT:    v_writelane_b32 v40, s21, 17
; GISEL-NEXT:    v_writelane_b32 v40, s22, 18
; GISEL-NEXT:    v_writelane_b32 v40, s23, 19
; GISEL-NEXT:    v_writelane_b32 v40, s24, 20
; GISEL-NEXT:    v_writelane_b32 v40, s25, 21
; GISEL-NEXT:    v_writelane_b32 v40, s26, 22
; GISEL-NEXT:    v_writelane_b32 v40, s27, 23
; GISEL-NEXT:    v_writelane_b32 v40, s28, 24
; GISEL-NEXT:    v_writelane_b32 v40, s29, 25
; GISEL-NEXT:    v_writelane_b32 v40, s30, 26
; GISEL-NEXT:    s_mov_b32 s34, extern_c_func@abs32@lo
; GISEL-NEXT:    s_mov_b32 s35, extern_c_func@abs32@hi
; GISEL-NEXT:    s_mov_b64 s[8:9], 0
; GISEL-NEXT:    s_addk_i32 s32, 0x400
; GISEL-NEXT:    v_writelane_b32 v40, s31, 27
; GISEL-NEXT:    s_swappc_b64 s[30:31], s[34:35]
; GISEL-NEXT:    v_readlane_b32 s31, v40, 27
; GISEL-NEXT:    v_readlane_b32 s30, v40, 26
; GISEL-NEXT:    v_readlane_b32 s29, v40, 25
; GISEL-NEXT:    v_readlane_b32 s28, v40, 24
; GISEL-NEXT:    v_readlane_b32 s27, v40, 23
; GISEL-NEXT:    v_readlane_b32 s26, v40, 22
; GISEL-NEXT:    v_readlane_b32 s25, v40, 21
; GISEL-NEXT:    v_readlane_b32 s24, v40, 20
; GISEL-NEXT:    v_readlane_b32 s23, v40, 19
; GISEL-NEXT:    v_readlane_b32 s22, v40, 18
; GISEL-NEXT:    v_readlane_b32 s21, v40, 17
; GISEL-NEXT:    v_readlane_b32 s20, v40, 16
; GISEL-NEXT:    v_readlane_b32 s19, v40, 15
; GISEL-NEXT:    v_readlane_b32 s18, v40, 14
; GISEL-NEXT:    v_readlane_b32 s17, v40, 13
; GISEL-NEXT:    v_readlane_b32 s16, v40, 12
; GISEL-NEXT:    v_readlane_b32 s15, v40, 11
; GISEL-NEXT:    v_readlane_b32 s14, v40, 10
; GISEL-NEXT:    v_readlane_b32 s13, v40, 9
; GISEL-NEXT:    v_readlane_b32 s12, v40, 8
; GISEL-NEXT:    v_readlane_b32 s11, v40, 7
; GISEL-NEXT:    v_readlane_b32 s10, v40, 6
; GISEL-NEXT:    v_readlane_b32 s9, v40, 5
; GISEL-NEXT:    v_readlane_b32 s8, v40, 4
; GISEL-NEXT:    v_readlane_b32 s7, v40, 3
; GISEL-NEXT:    v_readlane_b32 s6, v40, 2
; GISEL-NEXT:    v_readlane_b32 s5, v40, 1
; GISEL-NEXT:    v_readlane_b32 s4, v40, 0
; GISEL-NEXT:    s_or_saveexec_b64 s[34:35], -1
; GISEL-NEXT:    buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload
; GISEL-NEXT:    s_mov_b64 exec, s[34:35]
; GISEL-NEXT:    s_addk_i32 s32, 0xfc00
; GISEL-NEXT:    s_mov_b32 s33, s36
; GISEL-NEXT:    s_waitcnt vmcnt(0)
; GISEL-NEXT:    s_setpc_b64 s[30:31]
  call void @extern_c_func()
  ret void
}