1 ; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 ; RUN: llc -global-isel -stop-after=irtranslator -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 -verify-machineinstrs -o - %s | FileCheck -enable-var-scope %s
4 ; amdgpu_gfx calling convention
5 declare hidden amdgpu_gfx void @external_gfx_void_func_void() #0
6 declare hidden amdgpu_gfx void @external_gfx_void_func_i32(i32) #0
7 declare hidden amdgpu_gfx void @external_gfx_void_func_i32_inreg(i32 inreg) #0
8 declare hidden amdgpu_gfx void @external_gfx_void_func_struct_i8_i32({ i8, i32 }) #0
9 declare hidden amdgpu_gfx void @external_gfx_void_func_struct_i8_i32_inreg({ i8, i32 } inreg) #0
11 define amdgpu_gfx void @test_gfx_call_external_void_func_void() #0 {
12 ; CHECK-LABEL: name: test_gfx_call_external_void_func_void
13 ; CHECK: bb.1 (%ir-block.0):
14 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $scc
15 ; CHECK-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @external_gfx_void_func_void
16 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $sgpr0_sgpr1_sgpr2_sgpr3
17 ; CHECK-NEXT: $sgpr0_sgpr1_sgpr2_sgpr3 = COPY [[COPY]](<4 x s32>)
18 ; CHECK-NEXT: $sgpr30_sgpr31 = noconvergent G_SI_CALL [[GV]](p0), @external_gfx_void_func_void, csr_amdgpu_si_gfx, implicit $sgpr0_sgpr1_sgpr2_sgpr3
19 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $scc
20 ; CHECK-NEXT: SI_RETURN
21 call amdgpu_gfx void @external_gfx_void_func_void()
25 define amdgpu_gfx void @test_gfx_call_external_void_func_i32_imm(i32) #0 {
26 ; CHECK-LABEL: name: test_gfx_call_external_void_func_i32_imm
27 ; CHECK: bb.1 (%ir-block.1):
28 ; CHECK-NEXT: liveins: $vgpr0
30 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
31 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 42
32 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $scc
33 ; CHECK-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @external_gfx_void_func_i32
34 ; CHECK-NEXT: $vgpr0 = COPY [[C]](s32)
35 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $sgpr0_sgpr1_sgpr2_sgpr3
36 ; CHECK-NEXT: $sgpr0_sgpr1_sgpr2_sgpr3 = COPY [[COPY1]](<4 x s32>)
37 ; CHECK-NEXT: $sgpr30_sgpr31 = noconvergent G_SI_CALL [[GV]](p0), @external_gfx_void_func_i32, csr_amdgpu_si_gfx, implicit $vgpr0, implicit $sgpr0_sgpr1_sgpr2_sgpr3
38 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $scc
39 ; CHECK-NEXT: SI_RETURN
40 call amdgpu_gfx void @external_gfx_void_func_i32(i32 42)
44 define amdgpu_gfx void @test_gfx_call_external_void_func_i32_imm_inreg(i32 inreg) #0 {
45 ; CHECK-LABEL: name: test_gfx_call_external_void_func_i32_imm_inreg
46 ; CHECK: bb.1 (%ir-block.1):
47 ; CHECK-NEXT: liveins: $sgpr4
49 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $sgpr4
50 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 42
51 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $scc
52 ; CHECK-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @external_gfx_void_func_i32_inreg
53 ; CHECK-NEXT: $sgpr4 = COPY [[C]](s32)
54 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $sgpr0_sgpr1_sgpr2_sgpr3
55 ; CHECK-NEXT: $sgpr0_sgpr1_sgpr2_sgpr3 = COPY [[COPY1]](<4 x s32>)
56 ; CHECK-NEXT: $sgpr30_sgpr31 = noconvergent G_SI_CALL [[GV]](p0), @external_gfx_void_func_i32_inreg, csr_amdgpu_si_gfx, implicit $sgpr4, implicit $sgpr0_sgpr1_sgpr2_sgpr3
57 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $scc
58 ; CHECK-NEXT: SI_RETURN
59 call amdgpu_gfx void @external_gfx_void_func_i32_inreg(i32 inreg 42)
63 define amdgpu_gfx void @test_gfx_call_external_void_func_struct_i8_i32() #0 {
64 ; CHECK-LABEL: name: test_gfx_call_external_void_func_struct_i8_i32
65 ; CHECK: bb.1 (%ir-block.0):
66 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(p4) = G_IMPLICIT_DEF
67 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(p1) = G_LOAD [[DEF]](p4) :: (invariant load (p1) from `ptr addrspace(4) undef`, addrspace 4)
68 ; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(s8) = G_LOAD [[LOAD]](p1) :: (load (s8) from %ir.ptr0, align 4, addrspace 1)
69 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 4
70 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p1) = G_PTR_ADD [[LOAD]], [[C]](s64)
71 ; CHECK-NEXT: [[LOAD2:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD]](p1) :: (load (s32) from %ir.ptr0 + 4, addrspace 1)
72 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $scc
73 ; CHECK-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @external_gfx_void_func_struct_i8_i32
74 ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s16) = G_ANYEXT [[LOAD1]](s8)
75 ; CHECK-NEXT: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[ANYEXT]](s16)
76 ; CHECK-NEXT: $vgpr0 = COPY [[ANYEXT1]](s32)
77 ; CHECK-NEXT: $vgpr1 = COPY [[LOAD2]](s32)
78 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $sgpr0_sgpr1_sgpr2_sgpr3
79 ; CHECK-NEXT: $sgpr0_sgpr1_sgpr2_sgpr3 = COPY [[COPY]](<4 x s32>)
80 ; CHECK-NEXT: $sgpr30_sgpr31 = noconvergent G_SI_CALL [[GV]](p0), @external_gfx_void_func_struct_i8_i32, csr_amdgpu_si_gfx, implicit $vgpr0, implicit $vgpr1, implicit $sgpr0_sgpr1_sgpr2_sgpr3
81 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $scc
82 ; CHECK-NEXT: SI_RETURN
83 %ptr0 = load ptr addrspace(1), ptr addrspace(4) undef
84 %val = load { i8, i32 }, ptr addrspace(1) %ptr0
85 call amdgpu_gfx void @external_gfx_void_func_struct_i8_i32({ i8, i32 } %val)
89 define amdgpu_gfx void @test_gfx_call_external_void_func_struct_i8_i32_inreg() #0 {
90 ; CHECK-LABEL: name: test_gfx_call_external_void_func_struct_i8_i32_inreg
91 ; CHECK: bb.1 (%ir-block.0):
92 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(p4) = G_IMPLICIT_DEF
93 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(p1) = G_LOAD [[DEF]](p4) :: (invariant load (p1) from `ptr addrspace(4) undef`, addrspace 4)
94 ; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(s8) = G_LOAD [[LOAD]](p1) :: (load (s8) from %ir.ptr0, align 4, addrspace 1)
95 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 4
96 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p1) = G_PTR_ADD [[LOAD]], [[C]](s64)
97 ; CHECK-NEXT: [[LOAD2:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD]](p1) :: (load (s32) from %ir.ptr0 + 4, addrspace 1)
98 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $scc
99 ; CHECK-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @external_gfx_void_func_struct_i8_i32_inreg
100 ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s16) = G_ANYEXT [[LOAD1]](s8)
101 ; CHECK-NEXT: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[ANYEXT]](s16)
102 ; CHECK-NEXT: $sgpr4 = COPY [[ANYEXT1]](s32)
103 ; CHECK-NEXT: $sgpr5 = COPY [[LOAD2]](s32)
104 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $sgpr0_sgpr1_sgpr2_sgpr3
105 ; CHECK-NEXT: $sgpr0_sgpr1_sgpr2_sgpr3 = COPY [[COPY]](<4 x s32>)
106 ; CHECK-NEXT: $sgpr30_sgpr31 = noconvergent G_SI_CALL [[GV]](p0), @external_gfx_void_func_struct_i8_i32_inreg, csr_amdgpu_si_gfx, implicit $sgpr4, implicit $sgpr5, implicit $sgpr0_sgpr1_sgpr2_sgpr3
107 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $scc
108 ; CHECK-NEXT: SI_RETURN
109 %ptr0 = load ptr addrspace(1), ptr addrspace(4) undef
110 %val = load { i8, i32 }, ptr addrspace(1) %ptr0
111 call amdgpu_gfx void @external_gfx_void_func_struct_i8_i32_inreg({ i8, i32 } inreg %val)
115 attributes #0 = { nounwind }
116 attributes #1 = { nounwind readnone }
117 attributes #2 = { nounwind noinline }