1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32
3 ; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -relocation-model=pic -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32_PIC
5 declare i32 @f(i32 %a, i32 %b);
7 define i32 @call_global(i32 %a0, i32 %a1, i32 %x, i32 %y) {
8 ; MIPS32-LABEL: call_global:
9 ; MIPS32: # %bb.0: # %entry
10 ; MIPS32-NEXT: addiu $sp, $sp, -24
11 ; MIPS32-NEXT: .cfi_def_cfa_offset 24
12 ; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill
13 ; MIPS32-NEXT: .cfi_offset 31, -4
14 ; MIPS32-NEXT: move $4, $6
15 ; MIPS32-NEXT: move $5, $7
18 ; MIPS32-NEXT: addu $2, $2, $2
19 ; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
20 ; MIPS32-NEXT: addiu $sp, $sp, 24
24 ; MIPS32_PIC-LABEL: call_global:
25 ; MIPS32_PIC: # %bb.0: # %entry
26 ; MIPS32_PIC-NEXT: lui $2, %hi(_gp_disp)
27 ; MIPS32_PIC-NEXT: addiu $2, $2, %lo(_gp_disp)
28 ; MIPS32_PIC-NEXT: addiu $sp, $sp, -24
29 ; MIPS32_PIC-NEXT: .cfi_def_cfa_offset 24
30 ; MIPS32_PIC-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill
31 ; MIPS32_PIC-NEXT: .cfi_offset 31, -4
32 ; MIPS32_PIC-NEXT: addu $1, $2, $25
33 ; MIPS32_PIC-NEXT: lw $25, %call16(f)($1)
34 ; MIPS32_PIC-NEXT: move $4, $6
35 ; MIPS32_PIC-NEXT: move $5, $7
36 ; MIPS32_PIC-NEXT: move $gp, $1
37 ; MIPS32_PIC-NEXT: jalr $25
38 ; MIPS32_PIC-NEXT: nop
39 ; MIPS32_PIC-NEXT: addu $2, $2, $2
40 ; MIPS32_PIC-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
41 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 24
42 ; MIPS32_PIC-NEXT: jr $ra
43 ; MIPS32_PIC-NEXT: nop
45 %z = call i32 @f(i32 %x, i32 %y)
46 %doublez = add i32 %z, %z
50 define internal i32 @f_with_local_linkage(i32 %x, i32 %y) {
51 ; MIPS32-LABEL: f_with_local_linkage:
52 ; MIPS32: # %bb.0: # %entry
53 ; MIPS32-NEXT: addu $2, $5, $4
57 ; MIPS32_PIC-LABEL: f_with_local_linkage:
58 ; MIPS32_PIC: # %bb.0: # %entry
59 ; MIPS32_PIC-NEXT: addu $2, $5, $4
60 ; MIPS32_PIC-NEXT: jr $ra
61 ; MIPS32_PIC-NEXT: nop
67 define i32 @call_global_with_local_linkage(i32 %a0, i32 %a1, i32 %x, i32 %y) {
68 ; MIPS32-LABEL: call_global_with_local_linkage:
69 ; MIPS32: # %bb.0: # %entry
70 ; MIPS32-NEXT: addiu $sp, $sp, -24
71 ; MIPS32-NEXT: .cfi_def_cfa_offset 24
72 ; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill
73 ; MIPS32-NEXT: .cfi_offset 31, -4
74 ; MIPS32-NEXT: move $4, $6
75 ; MIPS32-NEXT: move $5, $7
76 ; MIPS32-NEXT: jal f_with_local_linkage
78 ; MIPS32-NEXT: addu $2, $2, $2
79 ; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
80 ; MIPS32-NEXT: addiu $sp, $sp, 24
84 ; MIPS32_PIC-LABEL: call_global_with_local_linkage:
85 ; MIPS32_PIC: # %bb.0: # %entry
86 ; MIPS32_PIC-NEXT: lui $2, %hi(_gp_disp)
87 ; MIPS32_PIC-NEXT: addiu $2, $2, %lo(_gp_disp)
88 ; MIPS32_PIC-NEXT: addiu $sp, $sp, -24
89 ; MIPS32_PIC-NEXT: .cfi_def_cfa_offset 24
90 ; MIPS32_PIC-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill
91 ; MIPS32_PIC-NEXT: .cfi_offset 31, -4
92 ; MIPS32_PIC-NEXT: addu $1, $2, $25
93 ; MIPS32_PIC-NEXT: lw $2, %got(f_with_local_linkage)($1)
94 ; MIPS32_PIC-NEXT: addiu $25, $2, %lo(f_with_local_linkage)
95 ; MIPS32_PIC-NEXT: move $4, $6
96 ; MIPS32_PIC-NEXT: move $5, $7
97 ; MIPS32_PIC-NEXT: move $gp, $1
98 ; MIPS32_PIC-NEXT: jalr $25
99 ; MIPS32_PIC-NEXT: nop
100 ; MIPS32_PIC-NEXT: addu $2, $2, $2
101 ; MIPS32_PIC-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
102 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 24
103 ; MIPS32_PIC-NEXT: jr $ra
104 ; MIPS32_PIC-NEXT: nop
106 %z = call i32 @f_with_local_linkage(i32 %x, i32 %y)
107 %doublez = add i32 %z, %z
111 define i32 @call_reg(i32 (i32, i32)* %f_ptr, i32 %x, i32 %y) {
112 ; MIPS32-LABEL: call_reg:
113 ; MIPS32: # %bb.0: # %entry
114 ; MIPS32-NEXT: addiu $sp, $sp, -24
115 ; MIPS32-NEXT: .cfi_def_cfa_offset 24
116 ; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill
117 ; MIPS32-NEXT: .cfi_offset 31, -4
118 ; MIPS32-NEXT: sw $4, 16($sp) # 4-byte Folded Spill
119 ; MIPS32-NEXT: move $4, $5
120 ; MIPS32-NEXT: move $5, $6
121 ; MIPS32-NEXT: lw $25, 16($sp) # 4-byte Folded Reload
122 ; MIPS32-NEXT: jalr $25
124 ; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
125 ; MIPS32-NEXT: addiu $sp, $sp, 24
126 ; MIPS32-NEXT: jr $ra
129 ; MIPS32_PIC-LABEL: call_reg:
130 ; MIPS32_PIC: # %bb.0: # %entry
131 ; MIPS32_PIC-NEXT: addiu $sp, $sp, -24
132 ; MIPS32_PIC-NEXT: .cfi_def_cfa_offset 24
133 ; MIPS32_PIC-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill
134 ; MIPS32_PIC-NEXT: .cfi_offset 31, -4
135 ; MIPS32_PIC-NEXT: sw $4, 16($sp) # 4-byte Folded Spill
136 ; MIPS32_PIC-NEXT: move $4, $5
137 ; MIPS32_PIC-NEXT: move $5, $6
138 ; MIPS32_PIC-NEXT: lw $25, 16($sp) # 4-byte Folded Reload
139 ; MIPS32_PIC-NEXT: jalr $25
140 ; MIPS32_PIC-NEXT: nop
141 ; MIPS32_PIC-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
142 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 24
143 ; MIPS32_PIC-NEXT: jr $ra
144 ; MIPS32_PIC-NEXT: nop
146 %call = call i32 %f_ptr(i32 %x, i32 %y)
150 declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i1 immarg)
152 define void @call_symbol(i8* nocapture readonly %src, i8* nocapture %dest, i32 signext %length) {
153 ; MIPS32-LABEL: call_symbol:
154 ; MIPS32: # %bb.0: # %entry
155 ; MIPS32-NEXT: addiu $sp, $sp, -24
156 ; MIPS32-NEXT: .cfi_def_cfa_offset 24
157 ; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill
158 ; MIPS32-NEXT: .cfi_offset 31, -4
159 ; MIPS32-NEXT: sw $4, 16($sp) # 4-byte Folded Spill
160 ; MIPS32-NEXT: move $4, $5
161 ; MIPS32-NEXT: lw $5, 16($sp) # 4-byte Folded Reload
162 ; MIPS32-NEXT: jal memcpy
164 ; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
165 ; MIPS32-NEXT: addiu $sp, $sp, 24
166 ; MIPS32-NEXT: jr $ra
169 ; MIPS32_PIC-LABEL: call_symbol:
170 ; MIPS32_PIC: # %bb.0: # %entry
171 ; MIPS32_PIC-NEXT: addiu $sp, $sp, -24
172 ; MIPS32_PIC-NEXT: .cfi_def_cfa_offset 24
173 ; MIPS32_PIC-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill
174 ; MIPS32_PIC-NEXT: .cfi_offset 31, -4
175 ; MIPS32_PIC-NEXT: sw $4, 16($sp) # 4-byte Folded Spill
176 ; MIPS32_PIC-NEXT: move $4, $5
177 ; MIPS32_PIC-NEXT: lw $5, 16($sp) # 4-byte Folded Reload
178 ; MIPS32_PIC-NEXT: jal memcpy
179 ; MIPS32_PIC-NEXT: nop
180 ; MIPS32_PIC-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
181 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 24
182 ; MIPS32_PIC-NEXT: jr $ra
183 ; MIPS32_PIC-NEXT: nop
185 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %dest, i8* align 1 %src, i32 %length, i1 false)