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=mips -mcpu=mips32r6 -enable-mips-tail-calls < %s | FileCheck %s -check-prefix=ALL -check-prefix=O32
7 ; RUN: llc -march=mips64 -mcpu=mips4 -enable-mips-tail-calls < %s | FileCheck %s -check-prefix=ALL -check-prefix=N64
8 ; RUN: llc -march=mips64 -mcpu=mips64 -enable-mips-tail-calls < %s | FileCheck %s -check-prefix=ALL -check-prefix=N64
9 ; RUN: llc -march=mips64 -mcpu=mips64r2 -enable-mips-tail-calls < %s | FileCheck %s -check-prefix=ALL -check-prefix=N64
10 ; RUN: llc -march=mips64 -mcpu=mips64r6 -enable-mips-tail-calls < %s | FileCheck %s -check-prefix=ALL -check-prefix=N64
12 declare void @extern_void_void()
13 declare i32 @extern_i32_void()
14 declare float @extern_float_void()
16 define i32 @call_void_void() {
17 ; ALL-LABEL: call_void_void:
19 ; O32: lw $[[TGT:[0-9]+]], %call16(extern_void_void)($gp)
21 ; N64: ld $[[TGT:[0-9]+]], %call16(extern_void_void)($gp)
25 call void @extern_void_void()
29 define i32 @call_i32_void() {
30 ; ALL-LABEL: call_i32_void:
32 ; O32: lw $[[TGT:[0-9]+]], %call16(extern_i32_void)($gp)
34 ; N64: ld $[[TGT:[0-9]+]], %call16(extern_i32_void)($gp)
38 %1 = call i32 @extern_i32_void()
43 define float @call_float_void() {
44 ; ALL-LABEL: call_float_void:
46 ; FIXME: Not sure why we don't use $gp directly on such a simple test. We should
47 ; look into it at some point.
48 ; O32: addu $[[GP:[0-9]+]], ${{[0-9]+}}, $25
49 ; O32: lw $[[TGT:[0-9]+]], %call16(extern_float_void)($[[GP]])
51 ; N64: ld $[[TGT:[0-9]+]], %call16(extern_float_void)($gp)
55 ; O32: move $gp, $[[GP]]
57 %1 = call float @extern_float_void()
58 %2 = fadd float %1, 1.0
62 define void @musttail_call_void_void() {
63 ; ALL-LABEL: musttail_call_void_void:
65 ; O32: lw $[[TGT:[0-9]+]], %call16(extern_void_void)($gp)
67 ; N64: ld $[[TGT:[0-9]+]], %call16(extern_void_void)($gp)
72 musttail call void @extern_void_void()
76 define i32 @musttail_call_i32_void() {
77 ; ALL-LABEL: musttail_call_i32_void:
79 ; O32: lw $[[TGT:[0-9]+]], %call16(extern_i32_void)($gp)
81 ; N64: ld $[[TGT:[0-9]+]], %call16(extern_i32_void)($gp)
86 %1 = musttail call i32 @extern_i32_void()
90 define float @musttail_call_float_void() {
91 ; ALL-LABEL: musttail_call_float_void:
93 ; O32: lw $[[TGT:[0-9]+]], %call16(extern_float_void)($gp)
95 ; N64: ld $[[TGT:[0-9]+]], %call16(extern_float_void)($gp)
100 %1 = musttail call float @extern_float_void()
104 define i32 @indirect_call_void_void(void ()* %addr) {
105 ; ALL-LABEL: indirect_call_void_void:
114 define i32 @indirect_call_i32_void(i32 ()* %addr) {
115 ; ALL-LABEL: indirect_call_i32_void:
120 %1 = call i32 %addr()
125 define float @indirect_call_float_void(float ()* %addr) {
126 ; ALL-LABEL: indirect_call_float_void:
131 %1 = call float %addr()
132 %2 = fadd float %1, 1.0
136 ; We can't use 'musttail' here because the verifier is too conservative and
137 ; prohibits any prototype difference.
138 define void @tail_indirect_call_void_void(void ()* %addr) {
139 ; ALL-LABEL: tail_indirect_call_void_void:
144 tail call void %addr()
148 define i32 @tail_indirect_call_i32_void(i32 ()* %addr) {
149 ; ALL-LABEL: tail_indirect_call_i32_void:
154 %1 = tail call i32 %addr()
158 define float @tail_indirect_call_float_void(float ()* %addr) {
159 ; ALL-LABEL: tail_indirect_call_float_void:
164 %1 = tail call float %addr()