1 ; Test the 'call' instruction and the tailcall variant.
3 ; RUN: llc -march=mips -mcpu=mips32 -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,O32,NOT-R6C
4 ; RUN: llc -march=mips -mcpu=mips32r2 -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,O32,NOT-R6C
5 ; RUN: llc -march=mips -mcpu=mips32r3 -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,O32,NOT-R6C
6 ; RUN: llc -march=mips -mcpu=mips32r5 -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,O32,NOT-R6C
7 ; RUN: llc -march=mips -mcpu=mips32r6 -relocation-model=pic -disable-mips-delay-filler -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,O32,R6C
8 ; RUN: llc -march=mips -mcpu=mips32r6 -relocation-model=pic -mattr=+fp64,+nooddspreg -disable-mips-delay-filler -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,O32,R6C
9 ; RUN: llc -march=mips64 -mcpu=mips4 -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,N64,NOT-R6C
10 ; RUN: llc -march=mips64 -mcpu=mips64 -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,N64,NOT-R6C
11 ; RUN: llc -march=mips64 -mcpu=mips64r2 -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,N64,NOT-R6C
12 ; RUN: llc -march=mips64 -mcpu=mips64r3 -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,N64,NOT-R6C
13 ; RUN: llc -march=mips64 -mcpu=mips64r5 -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,N64,NOT-R6C
14 ; RUN: llc -march=mips64 -mcpu=mips64r6 -relocation-model=pic -disable-mips-delay-filler -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,N64,R6C
15 ; RUN: llc -march=mips -mcpu=mips32 -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck %s -check-prefix=ALL -check-prefix=O32 -check-prefix=NOT-R6C
16 ; RUN: llc -march=mips -mcpu=mips32r2 -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck %s -check-prefix=ALL -check-prefix=O32 -check-prefix=NOT-R6C
17 ; RUN: llc -march=mips -mcpu=mips32r3 -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck %s -check-prefix=ALL -check-prefix=O32 -check-prefix=NOT-R6C
18 ; RUN: llc -march=mips -mcpu=mips32r5 -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck %s -check-prefix=ALL -check-prefix=O32 -check-prefix=NOT-R6C
19 ; RUN: llc -march=mips -mcpu=mips32r6 -relocation-model=pic -disable-mips-delay-filler -mips-tail-calls=1 < %s | FileCheck %s -check-prefix=ALL -check-prefix=O32 -check-prefix=R6C
20 ; RUN: llc -march=mips -mcpu=mips32r6 -relocation-model=pic -mattr=+fp64,+nooddspreg -disable-mips-delay-filler -mips-tail-calls=1 < %s | FileCheck %s -check-prefix=ALL -check-prefix=O32 -check-prefix=R6C
21 ; RUN: llc -march=mips64 -mcpu=mips4 -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck %s -check-prefix=ALL -check-prefix=N64 -check-prefix=NOT-R6C
22 ; RUN: llc -march=mips64 -mcpu=mips64 -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck %s -check-prefix=ALL -check-prefix=N64 -check-prefix=NOT-R6C
23 ; RUN: llc -march=mips64 -mcpu=mips64r2 -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck %s -check-prefix=ALL -check-prefix=N64 -check-prefix=NOT-R6C
24 ; RUN: llc -march=mips64 -mcpu=mips64r3 -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck %s -check-prefix=ALL -check-prefix=N64 -check-prefix=NOT-R6C
25 ; RUN: llc -march=mips64 -mcpu=mips64r5 -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck %s -check-prefix=ALL -check-prefix=N64 -check-prefix=NOT-R6C
26 ; RUN: llc -march=mips64 -mcpu=mips64r6 -relocation-model=pic -disable-mips-delay-filler -mips-tail-calls=1 < %s | FileCheck %s -check-prefix=ALL -check-prefix=N64 -check-prefix=R6C
28 declare void @extern_void_void()
29 declare i32 @extern_i32_void()
30 declare float @extern_float_void()
32 define i32 @call_void_void() {
33 ; ALL-LABEL: call_void_void:
35 ; O32: lw $[[TGT:[0-9]+]], %call16(extern_void_void)($gp)
37 ; N64: ld $[[TGT:[0-9]+]], %call16(extern_void_void)($gp)
39 ; NOT-R6C: jalr $[[TGT]]
42 call void @extern_void_void()
47 define i32 @call_i32_void() {
48 ; ALL-LABEL: call_i32_void:
50 ; O32: lw $[[TGT:[0-9]+]], %call16(extern_i32_void)($gp)
52 ; N64: ld $[[TGT:[0-9]+]], %call16(extern_i32_void)($gp)
54 ; NOT-R6C: jalr $[[TGT]]
57 %1 = call i32 @extern_i32_void()
63 define float @call_float_void() {
64 ; ALL-LABEL: call_float_void:
66 ; FIXME: Not sure why we don't use $gp directly on such a simple test. We should
67 ; look into it at some point.
68 ; O32: addu $[[GP:[0-9]+]], ${{[0-9]+}}, $25
69 ; O32: lw $[[TGT:[0-9]+]], %call16(extern_float_void)($[[GP]])
71 ; N64: ld $[[TGT:[0-9]+]], %call16(extern_float_void)($gp)
73 ; NOT-R6C: jalr $[[TGT]]
77 %1 = call float @extern_float_void()
78 %2 = fadd float %1, 1.0
83 define i32 @indirect_call_void_void(ptr %addr) {
84 ; ALL-LABEL: indirect_call_void_void:
95 define i32 @indirect_call_i32_void(ptr %addr) {
96 ; ALL-LABEL: indirect_call_i32_void:
103 %1 = call i32 %addr()
109 define float @indirect_call_float_void(ptr %addr) {
110 ; ALL-LABEL: indirect_call_float_void:
117 %1 = call float %addr()
118 %2 = fadd float %1, 1.0
123 ; We can't use 'musttail' here because the verifier is too conservative and
124 ; prohibits any prototype difference.
125 define void @tail_indirect_call_void_void(ptr %addr) {
126 ; ALL-LABEL: tail_indirect_call_void_void:
129 ; NOT-R6C: jr $[[TGT]]
132 tail call void %addr()
136 define i32 @tail_indirect_call_i32_void(ptr %addr) {
137 ; ALL-LABEL: tail_indirect_call_i32_void:
140 ; NOT-R6C: jr $[[TGT]]
143 %1 = tail call i32 %addr()
147 define float @tail_indirect_call_float_void(ptr %addr) {
148 ; ALL-LABEL: tail_indirect_call_float_void:
151 ; NOT-R6C: jr $[[TGT]]
154 %1 = tail call float %addr()
158 ; Check that passing undef as a double value doesn't cause machine code errors
160 declare hidden void @undef_double(i32 %this, double %volume) unnamed_addr align 2
162 define hidden void @thunk_undef_double(i32 %this, double %volume) unnamed_addr align 2 {
163 ; ALL-LABEL: thunk_undef_double:
164 ; O32: # implicit-def: $a2
165 ; O32: # implicit-def: $a3
166 ; NOT-R6C: jr $[[TGT]]
169 tail call void @undef_double(i32 undef, double undef) #8
173 ; Check that immediate addresses do not use jal.
174 define i32 @jal_only_allows_symbols() {
175 ; ALL-LABEL: jal_only_allows_symbols:
178 ; ALL: addiu $[[TGT:[0-9]+]], $zero, 1234
180 ; NOT-R6C: jalr $[[TGT]]
181 ; R6C: jalrc $[[TGT]]
184 call void () inttoptr (i32 1234 to ptr)()