1 ; Test the 'call' instruction and the tailcall variant.
3 ; FIXME: We should remove the need for -enable-mips-tail-calls
4 ; RUN: llc -march=mips -mcpu=mips32 -enable-mips-tail-calls < %s | FileCheck %s -check-prefix=ALL -check-prefix=O32
5 ; RUN: llc -march=mips -mcpu=mips32r2 -enable-mips-tail-calls < %s | FileCheck %s -check-prefix=ALL -check-prefix=O32
6 ; RUN: llc -march=mips64 -mcpu=mips4 -enable-mips-tail-calls < %s | FileCheck %s -check-prefix=ALL -check-prefix=N64
7 ; RUN: llc -march=mips64 -mcpu=mips64 -enable-mips-tail-calls < %s | FileCheck %s -check-prefix=ALL -check-prefix=N64
9 declare void @extern_void_void()
10 declare i32 @extern_i32_void()
11 declare float @extern_float_void()
13 define i32 @call_void_void() {
14 ; ALL-LABEL: call_void_void:
16 ; O32: lw $[[TGT:[0-9]+]], %call16(extern_void_void)($gp)
18 ; N64: ld $[[TGT:[0-9]+]], %call16(extern_void_void)($gp)
22 call void @extern_void_void()
26 define i32 @call_i32_void() {
27 ; ALL-LABEL: call_i32_void:
29 ; O32: lw $[[TGT:[0-9]+]], %call16(extern_i32_void)($gp)
31 ; N64: ld $[[TGT:[0-9]+]], %call16(extern_i32_void)($gp)
35 %1 = call i32 @extern_i32_void()
40 define float @call_float_void() {
41 ; ALL-LABEL: call_float_void:
43 ; FIXME: Not sure why we don't use $gp directly on such a simple test. We should
44 ; look into it at some point.
45 ; O32: addu $[[GP:[0-9]+]], ${{[0-9]+}}, $25
46 ; O32: lw $[[TGT:[0-9]+]], %call16(extern_float_void)($[[GP]])
48 ; N64: ld $[[TGT:[0-9]+]], %call16(extern_float_void)($gp)
52 ; O32: move $gp, $[[GP]]
54 %1 = call float @extern_float_void()
55 %2 = fadd float %1, 1.0
59 define void @musttail_call_void_void() {
60 ; ALL-LABEL: musttail_call_void_void:
62 ; O32: lw $[[TGT:[0-9]+]], %call16(extern_void_void)($gp)
64 ; N64: ld $[[TGT:[0-9]+]], %call16(extern_void_void)($gp)
68 musttail call void @extern_void_void()
72 define i32 @musttail_call_i32_void() {
73 ; ALL-LABEL: musttail_call_i32_void:
75 ; O32: lw $[[TGT:[0-9]+]], %call16(extern_i32_void)($gp)
77 ; N64: ld $[[TGT:[0-9]+]], %call16(extern_i32_void)($gp)
81 %1 = musttail call i32 @extern_i32_void()
85 define float @musttail_call_float_void() {
86 ; ALL-LABEL: musttail_call_float_void:
88 ; O32: lw $[[TGT:[0-9]+]], %call16(extern_float_void)($gp)
90 ; N64: ld $[[TGT:[0-9]+]], %call16(extern_float_void)($gp)
94 %1 = musttail call float @extern_float_void()
98 define i32 @indirect_call_void_void(void ()* %addr) {
99 ; ALL-LABEL: indirect_call_void_void:
108 define i32 @indirect_call_i32_void(i32 ()* %addr) {
109 ; ALL-LABEL: indirect_call_i32_void:
114 %1 = call i32 %addr()
119 define float @indirect_call_float_void(float ()* %addr) {
120 ; ALL-LABEL: indirect_call_float_void:
125 %1 = call float %addr()
126 %2 = fadd float %1, 1.0
130 ; We can't use 'musttail' here because the verifier is too conservative and
131 ; prohibits any prototype difference.
132 define void @tail_indirect_call_void_void(void ()* %addr) {
133 ; ALL-LABEL: tail_indirect_call_void_void:
138 tail call void %addr()
142 define i32 @tail_indirect_call_i32_void(i32 ()* %addr) {
143 ; ALL-LABEL: tail_indirect_call_i32_void:
148 %1 = tail call i32 %addr()
152 define float @tail_indirect_call_float_void(float ()* %addr) {
153 ; ALL-LABEL: tail_indirect_call_float_void:
158 %1 = tail call float %addr()