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 $gp, $2, $25
33 ; MIPS32_PIC-NEXT: move $4, $6
34 ; MIPS32_PIC-NEXT: move $5, $7
35 ; MIPS32_PIC-NEXT: lw $25, %call16(f)($gp)
36 ; MIPS32_PIC-NEXT: jalr $25
37 ; MIPS32_PIC-NEXT: nop
38 ; MIPS32_PIC-NEXT: addu $2, $2, $2
39 ; MIPS32_PIC-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
40 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 24
41 ; MIPS32_PIC-NEXT: jr $ra
42 ; MIPS32_PIC-NEXT: nop
44 %z = call i32 @f(i32 %x, i32 %y)
45 %doublez = add i32 %z, %z
49 define internal i32 @f_with_local_linkage(i32 %x, i32 %y) {
50 ; MIPS32-LABEL: f_with_local_linkage:
51 ; MIPS32: # %bb.0: # %entry
52 ; MIPS32-NEXT: addu $2, $5, $4
56 ; MIPS32_PIC-LABEL: f_with_local_linkage:
57 ; MIPS32_PIC: # %bb.0: # %entry
58 ; MIPS32_PIC-NEXT: addu $2, $5, $4
59 ; MIPS32_PIC-NEXT: jr $ra
60 ; MIPS32_PIC-NEXT: nop
66 define i32 @call_global_with_local_linkage(i32 %a0, i32 %a1, i32 %x, i32 %y) {
67 ; MIPS32-LABEL: call_global_with_local_linkage:
68 ; MIPS32: # %bb.0: # %entry
69 ; MIPS32-NEXT: addiu $sp, $sp, -24
70 ; MIPS32-NEXT: .cfi_def_cfa_offset 24
71 ; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill
72 ; MIPS32-NEXT: .cfi_offset 31, -4
73 ; MIPS32-NEXT: move $4, $6
74 ; MIPS32-NEXT: move $5, $7
75 ; MIPS32-NEXT: jal f_with_local_linkage
77 ; MIPS32-NEXT: addu $2, $2, $2
78 ; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
79 ; MIPS32-NEXT: addiu $sp, $sp, 24
83 ; MIPS32_PIC-LABEL: call_global_with_local_linkage:
84 ; MIPS32_PIC: # %bb.0: # %entry
85 ; MIPS32_PIC-NEXT: lui $2, %hi(_gp_disp)
86 ; MIPS32_PIC-NEXT: addiu $2, $2, %lo(_gp_disp)
87 ; MIPS32_PIC-NEXT: addiu $sp, $sp, -24
88 ; MIPS32_PIC-NEXT: .cfi_def_cfa_offset 24
89 ; MIPS32_PIC-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill
90 ; MIPS32_PIC-NEXT: .cfi_offset 31, -4
91 ; MIPS32_PIC-NEXT: addu $gp, $2, $25
92 ; MIPS32_PIC-NEXT: move $4, $6
93 ; MIPS32_PIC-NEXT: move $5, $7
94 ; MIPS32_PIC-NEXT: lw $1, %got(f_with_local_linkage)($gp)
95 ; MIPS32_PIC-NEXT: addiu $25, $1, %lo(f_with_local_linkage)
96 ; MIPS32_PIC-NEXT: jalr $25
97 ; MIPS32_PIC-NEXT: nop
98 ; MIPS32_PIC-NEXT: addu $2, $2, $2
99 ; MIPS32_PIC-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
100 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 24
101 ; MIPS32_PIC-NEXT: jr $ra
102 ; MIPS32_PIC-NEXT: nop
104 %z = call i32 @f_with_local_linkage(i32 %x, i32 %y)
105 %doublez = add i32 %z, %z
109 define i32 @call_reg(ptr %f_ptr, i32 %x, i32 %y) {
110 ; MIPS32-LABEL: call_reg:
111 ; MIPS32: # %bb.0: # %entry
112 ; MIPS32-NEXT: addiu $sp, $sp, -24
113 ; MIPS32-NEXT: .cfi_def_cfa_offset 24
114 ; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill
115 ; MIPS32-NEXT: .cfi_offset 31, -4
116 ; MIPS32-NEXT: move $25, $4
117 ; MIPS32-NEXT: move $4, $5
118 ; MIPS32-NEXT: move $5, $6
119 ; MIPS32-NEXT: jalr $25
121 ; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
122 ; MIPS32-NEXT: addiu $sp, $sp, 24
123 ; MIPS32-NEXT: jr $ra
126 ; MIPS32_PIC-LABEL: call_reg:
127 ; MIPS32_PIC: # %bb.0: # %entry
128 ; MIPS32_PIC-NEXT: addiu $sp, $sp, -24
129 ; MIPS32_PIC-NEXT: .cfi_def_cfa_offset 24
130 ; MIPS32_PIC-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill
131 ; MIPS32_PIC-NEXT: .cfi_offset 31, -4
132 ; MIPS32_PIC-NEXT: move $25, $4
133 ; MIPS32_PIC-NEXT: move $4, $5
134 ; MIPS32_PIC-NEXT: move $5, $6
135 ; MIPS32_PIC-NEXT: jalr $25
136 ; MIPS32_PIC-NEXT: nop
137 ; MIPS32_PIC-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
138 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 24
139 ; MIPS32_PIC-NEXT: jr $ra
140 ; MIPS32_PIC-NEXT: nop
142 %call = call i32 %f_ptr(i32 %x, i32 %y)
146 declare void @llvm.memcpy.p0.p0.i32(ptr nocapture writeonly, ptr nocapture readonly, i32, i1 immarg)
148 define void @call_symbol(ptr nocapture readonly %src, ptr nocapture %dest, i32 signext %length) {
149 ; MIPS32-LABEL: call_symbol:
150 ; MIPS32: # %bb.0: # %entry
151 ; MIPS32-NEXT: addiu $sp, $sp, -24
152 ; MIPS32-NEXT: .cfi_def_cfa_offset 24
153 ; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill
154 ; MIPS32-NEXT: .cfi_offset 31, -4
155 ; MIPS32-NEXT: sw $4, 16($sp) # 4-byte Folded Spill
156 ; MIPS32-NEXT: move $4, $5
157 ; MIPS32-NEXT: lw $5, 16($sp) # 4-byte Folded Reload
158 ; MIPS32-NEXT: jal memcpy
160 ; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
161 ; MIPS32-NEXT: addiu $sp, $sp, 24
162 ; MIPS32-NEXT: jr $ra
165 ; MIPS32_PIC-LABEL: call_symbol:
166 ; MIPS32_PIC: # %bb.0: # %entry
167 ; MIPS32_PIC-NEXT: addiu $sp, $sp, -24
168 ; MIPS32_PIC-NEXT: .cfi_def_cfa_offset 24
169 ; MIPS32_PIC-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill
170 ; MIPS32_PIC-NEXT: .cfi_offset 31, -4
171 ; MIPS32_PIC-NEXT: sw $4, 16($sp) # 4-byte Folded Spill
172 ; MIPS32_PIC-NEXT: move $4, $5
173 ; MIPS32_PIC-NEXT: lw $5, 16($sp) # 4-byte Folded Reload
174 ; MIPS32_PIC-NEXT: jal memcpy
175 ; MIPS32_PIC-NEXT: nop
176 ; MIPS32_PIC-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
177 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 24
178 ; MIPS32_PIC-NEXT: jr $ra
179 ; MIPS32_PIC-NEXT: nop
181 call void @llvm.memcpy.p0.p0.i32(ptr align 1 %dest, ptr align 1 %src, i32 %length, i1 false)