1; RUN: llc -march=mipsel < %s | FileCheck -check-prefix=ALL %s
2; RUN: llc -march=mipsel -mattr=+fp64 < %s | FileCheck -check-prefix=ALL %s
3; RUN: llc -march=mipsel -mcpu=mips32 < %s | FileCheck -check-prefix=ALL -check-prefix=NO-MFHC1 %s
4; RUN: llc -march=mipsel -mcpu=mips32r2              < %s | FileCheck -check-prefix=ALL -check-prefix=HAS-MFHC1 %s
5; RUN: llc -march=mipsel -mcpu=mips32r2 -mattr=+fp64 < %s | FileCheck -check-prefix=ALL -check-prefix=HAS-MFHC1 %s
6
7; $f12, $f14
8; ALL-LABEL: testlowercall0:
9; ALL-DAG:       ldc1 $f12, %lo
10; ALL-DAG:       ldc1 $f14, %lo
11define void @testlowercall0() nounwind {
12entry:
13  tail call void @f0(double 5.000000e+00, double 6.000000e+00) nounwind
14  ret void
15}
16
17declare void @f0(double, double)
18
19; $f12, $f14
20; ALL-LABEL: testlowercall1:
21; ALL-DAG:       lwc1 $f12, %lo
22; ALL-DAG:       lwc1 $f14, %lo
23define void @testlowercall1() nounwind {
24entry:
25  tail call void @f1(float 8.000000e+00, float 9.000000e+00) nounwind
26  ret void
27}
28
29declare void @f1(float, float)
30
31; $f12, $f14
32; ALL-LABEL: testlowercall2:
33; ALL-DAG:       lwc1 $f12, %lo
34; ALL-DAG:       ldc1 $f14, %lo
35define void @testlowercall2() nounwind {
36entry:
37  tail call void @f2(float 8.000000e+00, double 6.000000e+00) nounwind
38  ret void
39}
40
41declare void @f2(float, double)
42
43; $f12, $f14
44; ALL-LABEL: testlowercall3:
45; ALL-DAG:       ldc1 $f12, %lo
46; ALL-DAG:       lwc1 $f14, %lo
47define void @testlowercall3() nounwind {
48entry:
49  tail call void @f3(double 5.000000e+00, float 9.000000e+00) nounwind
50  ret void
51}
52
53declare void @f3(double, float)
54
55; $4, $5, $6, $7
56; ALL-LABEL: testlowercall4:
57; ALL-DAG:       addiu $4, $zero, 12
58; ALL-DAG:       addiu $5, $zero, 13
59; ALL-DAG:       addiu $6, $zero, 14
60; ALL-DAG:       addiu $7, $zero, 15
61define void @testlowercall4() nounwind {
62entry:
63  tail call void @f4(i32 12, i32 13, i32 14, i32 15) nounwind
64  ret void
65}
66
67declare void @f4(i32, i32, i32, i32)
68
69; $f12, $6, stack
70; ALL-LABEL: testlowercall5:
71; ALL-DAG:       ldc1 $f12, %lo
72; ALL-DAG:       addiu $6, $zero, 23
73; ALL-DAG:       sw ${{[a-z0-9]+}}, 16($sp)
74; ALL-DAG:       sw ${{[a-z0-9]+}}, 20($sp)
75define void @testlowercall5() nounwind {
76entry:
77  tail call void @f5(double 1.500000e+01, i32 23, double 1.700000e+01) nounwind
78  ret void
79}
80
81declare void @f5(double, i32, double)
82
83; $f12, $6, $7
84; ALL-LABEL: testlowercall6:
85; ALL-DAG:       ldc1 $f12, %lo
86; ALL-DAG:       addiu $6, $zero, 33
87; ALL-DAG:       addiu $7, $zero, 24
88define void @testlowercall6() nounwind {
89entry:
90  tail call void @f6(double 2.500000e+01, i32 33, i32 24) nounwind
91  ret void
92}
93
94declare void @f6(double, i32, i32)
95
96; $f12, $5, $6
97; ALL-LABEL: testlowercall7:
98; ALL-DAG:       lwc1 $f12, %lo
99; ALL-DAG:       addiu $5, $zero, 43
100; ALL-DAG:       addiu $6, $zero, 34
101define void @testlowercall7() nounwind {
102entry:
103  tail call void @f7(float 1.800000e+01, i32 43, i32 34) nounwind
104  ret void
105}
106
107declare void @f7(float, i32, i32)
108
109; $4, $5, $6, stack
110; ALL-LABEL: testlowercall8:
111; ALL-DAG:       addiu $4, $zero, 22
112; ALL-DAG:       addiu $5, $zero, 53
113; ALL-DAG:       addiu $6, $zero, 44
114; ALL-DAG:       sw ${{[a-z0-9]+}}, 16($sp)
115; ALL-DAG:       sw ${{[a-z0-9]+}}, 20($sp)
116define void @testlowercall8() nounwind {
117entry:
118  tail call void @f8(i32 22, i32 53, i32 44, double 4.000000e+00) nounwind
119  ret void
120}
121
122declare void @f8(i32, i32, i32, double)
123
124; $4, $5, $6, $7
125; ALL-LABEL: testlowercall9:
126; ALL-DAG:       addiu $4, $zero, 32
127; ALL-DAG:       addiu $5, $zero, 63
128; ALL-DAG:       addiu $6, $zero, 54
129; ALL-DAG:       lui $7, 16688
130define void @testlowercall9() nounwind {
131entry:
132  tail call void @f9(i32 32, i32 63, i32 54, float 1.100000e+01) nounwind
133  ret void
134}
135
136declare void @f9(i32, i32, i32, float)
137
138; $4, $5, ($6, $7)
139; ALL-LABEL: testlowercall10:
140
141; ALL-DAG:       addiu $4, $zero, 42
142; ALL-DAG:       addiu $5, $zero, 73
143
144; NO-MFHC1-DAG:  mfc1 $6, $f{{[0-9]+}}
145; NO-MFHC1-DAG:  mfc1 $7, $f{{[0-9]+}}
146
147; HAS-MFHC1-DAG: mfc1 $6, $f{{[0-9]+}}
148; HAS-MFHC1-DAG: mfhc1 $7, $f{{[0-9]+}}
149define void @testlowercall10() nounwind {
150entry:
151  tail call void @f10(i32 42, i32 73, double 2.700000e+01) nounwind
152  ret void
153}
154
155declare void @f10(i32, i32, double)
156
157; $4, ($6, $7)
158; ALL-LABEL: testlowercall11:
159; ALL-DAG:       addiu $4, $zero, 52
160
161; NO-MFHC1-DAG:  mfc1 $6, $f{{[0-9]+}}
162; NO-MFHC1-DAG:  mfc1 $7, $f{{[0-9]+}}
163
164; HAS-MFHC1-DAG: mfc1 $6, $f{{[0-9]+}}
165; HAS-MFHC1-DAG: mfhc1 $7, $f{{[0-9]+}}
166define void @testlowercall11() nounwind {
167entry:
168  tail call void @f11(i32 52, double 1.600000e+01) nounwind
169  ret void
170}
171
172declare void @f11(i32, double)
173
174; $f12, $f14, $6, $7
175; ALL-LABEL: testlowercall12:
176; ALL-DAG:       lwc1 $f12, %lo
177; ALL-DAG:       lwc1 $f14, %lo
178; ALL-DAG:       lui $6, 16672
179; ALL-DAG:       lui $7, 16808
180define void @testlowercall12() nounwind {
181entry:
182  tail call void @f12(float 2.800000e+01, float 1.900000e+01, float 1.000000e+01, float 2.100000e+01) nounwind
183  ret void
184}
185
186declare void @f12(float, float, float, float)
187
188; $f12, $5, $6, $7
189; ALL-LABEL: testlowercall13:
190; ALL-DAG:       lwc1 $f12, %lo
191; ALL-DAG:       addiu $5, $zero, 83
192; ALL-DAG:       lui $6, 16800
193; ALL-DAG:       addiu $7, $zero, 25
194define void @testlowercall13() nounwind {
195entry:
196  tail call void @f13(float 3.800000e+01, i32 83, float 2.000000e+01, i32 25) nounwind
197  ret void
198}
199
200
201declare void @f13(float, i32, float, i32)
202
203; $f12, $f14, $7
204; ALL-LABEL: testlowercall14:
205; ALL-DAG:       ldc1 $f12, %lo
206; ALL-DAG:       lwc1 $f14, %lo
207; ALL-DAG:       lui $7, 16880
208define void @testlowercall14() nounwind {
209entry:
210  tail call void @f14(double 3.500000e+01, float 2.900000e+01, float 3.000000e+01) nounwind
211  ret void
212}
213
214declare void @f14(double, float, float)
215
216; $f12, $f14, ($6, $7)
217; ALL-LABEL: testlowercall15:
218; ALL-DAG:       lwc1 $f12, %lo
219; ALL-DAG:       lwc1 $f14, %lo
220
221; NO-MFHC1-DAG:  mfc1 $6, $f{{[0-9]+}}
222; NO-MFHC1-DAG:  mfc1 $7, $f{{[0-9]+}}
223
224; HAS-MFHC1-DAG: mfc1 $6, $f{{[0-9]+}}
225; HAS-MFHC1-DAG: mfhc1 $7, $f{{[0-9]+}}
226define void @testlowercall15() nounwind {
227entry:
228  tail call void @f15(float 4.800000e+01, float 3.900000e+01, double 3.700000e+01) nounwind
229  ret void
230}
231
232declare void @f15(float, float, double)
233
234; $4, $5, $6, $7
235; ALL-LABEL: testlowercall16:
236; ALL-DAG:       addiu $4, $zero, 62
237; ALL-DAG:       lui $5, 16964
238; ALL-DAG:       addiu $6, $zero, 64
239; ALL-DAG:       lui $7, 16888
240define void @testlowercall16() nounwind {
241entry:
242  tail call void @f16(i32 62, float 4.900000e+01, i32 64, float 3.100000e+01) nounwind
243  ret void
244}
245
246declare void @f16(i32, float, i32, float)
247
248; $4, $5, $6, $7
249; ALL-LABEL: testlowercall17:
250; ALL-DAG:       addiu $4, $zero, 72
251; ALL-DAG:       lui $5, 17004
252; ALL-DAG:       addiu $6, $zero, 74
253; ALL-DAG:       addiu $7, $zero, 35
254define void @testlowercall17() nounwind {
255entry:
256  tail call void @f17(i32 72, float 5.900000e+01, i32 74, i32 35) nounwind
257  ret void
258}
259
260declare void @f17(i32, float, i32, i32)
261
262; $4, $5, $6, $7
263; ALL-LABEL: testlowercall18:
264; ALL-DAG:       addiu $4, $zero, 82
265; ALL-DAG:       addiu $5, $zero, 93
266; ALL-DAG:       lui $6, 16928
267; ALL-DAG:       addiu $7, $zero, 45
268define void @testlowercall18() nounwind {
269entry:
270  tail call void @f18(i32 82, i32 93, float 4.000000e+01, i32 45) nounwind
271  ret void
272}
273
274declare void @f18(i32, i32, float, i32)
275
276
277; $4, ($6, $7), stack
278; ALL-LABEL: testlowercall20:
279; ALL-DAG:       addiu $4, $zero, 92
280; ALL-DAG:       sw ${{[a-z0-9]+}}, 16($sp)
281; ALL-DAG:       sw ${{[a-z0-9]+}}, 20($sp)
282
283; NO-MFHC1-DAG:  mfc1 $6, $f{{[0-9]+}}
284; NO-MFHC1-DAG:  mfc1 $7, $f{{[0-9]+}}
285
286; HAS-MFHC1-DAG: mfc1 $6, $f{{[0-9]+}}
287; HAS-MFHC1-DAG: mfhc1 $7, $f{{[0-9]+}}
288define void @testlowercall20() nounwind {
289entry:
290  tail call void @f20(i32 92, double 2.600000e+01, double 4.700000e+01) nounwind
291  ret void
292}
293
294declare void @f20(i32, double, double)
295
296; $f12, $5
297; ALL-LABEL: testlowercall21:
298; ALL-DAG:       lwc1 $f12, %lo
299; ALL-DAG:       addiu $5, $zero, 103
300define void @testlowercall21() nounwind {
301entry:
302  tail call void @f21(float 5.800000e+01, i32 103) nounwind
303  ret void
304}
305
306declare void @f21(float, i32)
307
308; $f12, $5, ($6, $7)
309; ALL-LABEL: testlowercall22:
310; ALL-DAG:       lwc1 $f12, %lo
311; ALL-DAG:       addiu $5, $zero, 113
312
313; NO-MFHC1-DAG:  mfc1 $6, $f{{[0-9]+}}
314; NO-MFHC1-DAG:  mfc1 $7, $f{{[0-9]+}}
315
316; HAS-MFHC1-DAG: mfc1 $6, $f{{[0-9]+}}
317; HAS-MFHC1-DAG: mfhc1 $7, $f{{[0-9]+}}
318define void @testlowercall22() nounwind {
319entry:
320  tail call void @f22(float 6.800000e+01, i32 113, double 5.700000e+01) nounwind
321  ret void
322}
323
324declare void @f22(float, i32, double)
325
326; $f12, f6
327; ALL-LABEL: testlowercall23:
328; ALL-DAG:       ldc1 $f12, %lo
329; ALL-DAG:       addiu $6, $zero, 123
330define void @testlowercall23() nounwind {
331entry:
332  tail call void @f23(double 4.500000e+01, i32 123) nounwind
333  ret void
334}
335
336declare void @f23(double, i32)
337
338; $f12,$6, stack
339; ALL-LABEL: testlowercall24:
340; ALL-DAG:       ldc1 $f12, %lo
341; ALL-DAG:       addiu $6, $zero, 133
342; ALL-DAG:       sw ${{[a-z0-9]+}}, 16($sp)
343; ALL-DAG:       sw ${{[a-z0-9]+}}, 20($sp)
344define void @testlowercall24() nounwind {
345entry:
346  tail call void @f24(double 5.500000e+01, i32 133, double 6.700000e+01) nounwind
347  ret void
348}
349
350declare void @f24(double, i32, double)
351
352; ALL-LABEL: testlowercall25:
353; ALL-DAG:      lwc1 $f12, %lo
354; ALL-DAG:      lwc1 $f14, %lo
355; ALL-DAG:      lui $6
356; ALL-DAG:      lui $7
357; ALL-DAG:      lwc1 $f12, %lo
358; ALL-DAG:      addiu $5, $zero, 83
359; ALL-DAG:      lui $6
360; ALL-DAG:      addiu $7, $zero, 25
361; ALL-DAG:      addiu $4, $zero, 82
362; ALL-DAG:      addiu $5, $zero, 93
363; ALL-DAG:      lui $6
364; ALL-DAG:      addiu $7, $zero, 45
365define void @testlowercall25() nounwind {
366entry:
367  tail call void @f12(float 2.800000e+01, float 1.900000e+01, float 1.000000e+01, float 2.100000e+01) nounwind
368  tail call void @f13(float 3.800000e+01, i32 83, float 2.000000e+01, i32 25) nounwind
369  tail call void @f18(i32 82, i32 93, float 4.000000e+01, i32 45) nounwind
370  ret void
371}
372