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: liveins: $sgpr30_sgpr31
16 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sgpr_64 = COPY $sgpr30_sgpr31
17 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $scc
18 ; CHECK-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @external_gfx_void_func_void
19 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $sgpr0_sgpr1_sgpr2_sgpr3
20 ; CHECK-NEXT: $sgpr0_sgpr1_sgpr2_sgpr3 = COPY [[COPY1]](<4 x s32>)
21 ; CHECK-NEXT: $sgpr30_sgpr31 = G_SI_CALL [[GV]](p0), @external_gfx_void_func_void, csr_amdgpu_si_gfx, implicit $sgpr0_sgpr1_sgpr2_sgpr3
22 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $scc
23 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gfx_ccr_sgpr_64 = COPY [[COPY]]
24 ; CHECK-NEXT: S_SETPC_B64_return_gfx [[COPY2]]
25 call amdgpu_gfx void @external_gfx_void_func_void()
29 define amdgpu_gfx void @test_gfx_call_external_void_func_i32_imm(i32) #0 {
30 ; CHECK-LABEL: name: test_gfx_call_external_void_func_i32_imm
31 ; CHECK: bb.1 (%ir-block.1):
32 ; CHECK-NEXT: liveins: $vgpr0, $sgpr30_sgpr31
34 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
35 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sgpr_64 = COPY $sgpr30_sgpr31
36 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 42
37 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $scc
38 ; CHECK-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @external_gfx_void_func_i32
39 ; CHECK-NEXT: $vgpr0 = COPY [[C]](s32)
40 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(<4 x s32>) = COPY $sgpr0_sgpr1_sgpr2_sgpr3
41 ; CHECK-NEXT: $sgpr0_sgpr1_sgpr2_sgpr3 = COPY [[COPY2]](<4 x s32>)
42 ; CHECK-NEXT: $sgpr30_sgpr31 = G_SI_CALL [[GV]](p0), @external_gfx_void_func_i32, csr_amdgpu_si_gfx, implicit $vgpr0, implicit $sgpr0_sgpr1_sgpr2_sgpr3
43 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $scc
44 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:gfx_ccr_sgpr_64 = COPY [[COPY1]]
45 ; CHECK-NEXT: S_SETPC_B64_return_gfx [[COPY3]]
46 call amdgpu_gfx void @external_gfx_void_func_i32(i32 42)
50 define amdgpu_gfx void @test_gfx_call_external_void_func_i32_imm_inreg(i32 inreg) #0 {
51 ; CHECK-LABEL: name: test_gfx_call_external_void_func_i32_imm_inreg
52 ; CHECK: bb.1 (%ir-block.1):
53 ; CHECK-NEXT: liveins: $sgpr4, $sgpr30_sgpr31
55 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $sgpr4
56 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sgpr_64 = COPY $sgpr30_sgpr31
57 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 42
58 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $scc
59 ; CHECK-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @external_gfx_void_func_i32_inreg
60 ; CHECK-NEXT: $sgpr4 = COPY [[C]](s32)
61 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(<4 x s32>) = COPY $sgpr0_sgpr1_sgpr2_sgpr3
62 ; CHECK-NEXT: $sgpr0_sgpr1_sgpr2_sgpr3 = COPY [[COPY2]](<4 x s32>)
63 ; CHECK-NEXT: $sgpr30_sgpr31 = G_SI_CALL [[GV]](p0), @external_gfx_void_func_i32_inreg, csr_amdgpu_si_gfx, implicit $sgpr4, implicit $sgpr0_sgpr1_sgpr2_sgpr3
64 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $scc
65 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:gfx_ccr_sgpr_64 = COPY [[COPY1]]
66 ; CHECK-NEXT: S_SETPC_B64_return_gfx [[COPY3]]
67 call amdgpu_gfx void @external_gfx_void_func_i32_inreg(i32 inreg 42)
71 define amdgpu_gfx void @test_gfx_call_external_void_func_struct_i8_i32() #0 {
72 ; CHECK-LABEL: name: test_gfx_call_external_void_func_struct_i8_i32
73 ; CHECK: bb.1 (%ir-block.0):
74 ; CHECK-NEXT: liveins: $sgpr30_sgpr31
76 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sgpr_64 = COPY $sgpr30_sgpr31
77 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(p4) = G_IMPLICIT_DEF
78 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(p1) = G_LOAD [[DEF]](p4) :: (load (p1) from `{ i8, i32 } addrspace(1)* addrspace(4)* undef`, addrspace 4)
79 ; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(s8) = G_LOAD [[LOAD]](p1) :: (load (s8) from %ir.ptr0, align 4, addrspace 1)
80 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 4
81 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p1) = G_PTR_ADD [[LOAD]], [[C]](s64)
82 ; CHECK-NEXT: [[LOAD2:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD]](p1) :: (load (s32) from %ir.ptr0 + 4, addrspace 1)
83 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $scc
84 ; CHECK-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @external_gfx_void_func_struct_i8_i32
85 ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s16) = G_ANYEXT [[LOAD1]](s8)
86 ; CHECK-NEXT: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[ANYEXT]](s16)
87 ; CHECK-NEXT: $vgpr0 = COPY [[ANYEXT1]](s32)
88 ; CHECK-NEXT: $vgpr1 = COPY [[LOAD2]](s32)
89 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $sgpr0_sgpr1_sgpr2_sgpr3
90 ; CHECK-NEXT: $sgpr0_sgpr1_sgpr2_sgpr3 = COPY [[COPY1]](<4 x s32>)
91 ; CHECK-NEXT: $sgpr30_sgpr31 = 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
92 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $scc
93 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gfx_ccr_sgpr_64 = COPY [[COPY]]
94 ; CHECK-NEXT: S_SETPC_B64_return_gfx [[COPY2]]
95 %ptr0 = load { i8, i32 } addrspace(1)*, { i8, i32 } addrspace(1)* addrspace(4)* undef
96 %val = load { i8, i32 }, { i8, i32 } addrspace(1)* %ptr0
97 call amdgpu_gfx void @external_gfx_void_func_struct_i8_i32({ i8, i32 } %val)
101 define amdgpu_gfx void @test_gfx_call_external_void_func_struct_i8_i32_inreg() #0 {
102 ; CHECK-LABEL: name: test_gfx_call_external_void_func_struct_i8_i32_inreg
103 ; CHECK: bb.1 (%ir-block.0):
104 ; CHECK-NEXT: liveins: $sgpr30_sgpr31
106 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sgpr_64 = COPY $sgpr30_sgpr31
107 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(p4) = G_IMPLICIT_DEF
108 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(p1) = G_LOAD [[DEF]](p4) :: (load (p1) from `{ i8, i32 } addrspace(1)* addrspace(4)* undef`, addrspace 4)
109 ; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(s8) = G_LOAD [[LOAD]](p1) :: (load (s8) from %ir.ptr0, align 4, addrspace 1)
110 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 4
111 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p1) = G_PTR_ADD [[LOAD]], [[C]](s64)
112 ; CHECK-NEXT: [[LOAD2:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD]](p1) :: (load (s32) from %ir.ptr0 + 4, addrspace 1)
113 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $scc
114 ; CHECK-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @external_gfx_void_func_struct_i8_i32_inreg
115 ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s16) = G_ANYEXT [[LOAD1]](s8)
116 ; CHECK-NEXT: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[ANYEXT]](s16)
117 ; CHECK-NEXT: $sgpr4 = COPY [[ANYEXT1]](s32)
118 ; CHECK-NEXT: $sgpr5 = COPY [[LOAD2]](s32)
119 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $sgpr0_sgpr1_sgpr2_sgpr3
120 ; CHECK-NEXT: $sgpr0_sgpr1_sgpr2_sgpr3 = COPY [[COPY1]](<4 x s32>)
121 ; CHECK-NEXT: $sgpr30_sgpr31 = 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
122 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $scc
123 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gfx_ccr_sgpr_64 = COPY [[COPY]]
124 ; CHECK-NEXT: S_SETPC_B64_return_gfx [[COPY2]]
125 %ptr0 = load { i8, i32 } addrspace(1)*, { i8, i32 } addrspace(1)* addrspace(4)* undef
126 %val = load { i8, i32 }, { i8, i32 } addrspace(1)* %ptr0
127 call amdgpu_gfx void @external_gfx_void_func_struct_i8_i32_inreg({ i8, i32 } inreg %val)
131 attributes #0 = { nounwind }
132 attributes #1 = { nounwind readnone }
133 attributes #2 = { nounwind noinline }