1 ; RUN: llc -mtriple=mips -relocation-model=static -mattr=+soft-float < %s | FileCheck --check-prefixes=ALL,SYM32,O32 %s
2 ; RUN: llc -mtriple=mipsel -relocation-model=static -mattr=+soft-float < %s | FileCheck --check-prefixes=ALL,SYM32,O32 %s
4 ; RUN-TODO: llc -mtriple=mips64 -relocation-model=static -mattr=+soft-float -target-abi o32 < %s | FileCheck --check-prefixes=ALL,SYM32,O32 %s
5 ; RUN-TODO: llc -mtriple=mips64el -relocation-model=static -mattr=+soft-float -target-abi o32 < %s | FileCheck --check-prefixes=ALL,SYM32,O32 %s
7 ; RUN: llc -mtriple=mips64 -relocation-model=static -mattr=+soft-float -target-abi n32 < %s | FileCheck --check-prefixes=ALL,SYM32,NEW %s
8 ; RUN: llc -mtriple=mips64el -relocation-model=static -mattr=+soft-float -target-abi n32 < %s | FileCheck --check-prefixes=ALL,SYM32,NEW %s
10 ; RUN: llc -mtriple=mips64 -relocation-model=static -mattr=+soft-float -target-abi n64 < %s | FileCheck --check-prefixes=ALL,SYM64,NEW %s
11 ; RUN: llc -mtriple=mips64el -relocation-model=static -mattr=+soft-float -target-abi n64 < %s | FileCheck --check-prefixes=ALL,SYM64,NEW %s
13 ; Test the floating point arguments for all ABI's and byte orders as specified
14 ; by section 5 of MD00305 (MIPS ABIs Described).
16 ; N32/N64 are identical in this area so their checks have been combined into
17 ; the 'NEW' prefix (the N stands for New).
19 @bytes = global [11 x i8] zeroinitializer
20 @dwords = global [11 x i64] zeroinitializer
21 @floats = global [11 x float] zeroinitializer
22 @doubles = global [11 x double] zeroinitializer
24 define void @double_args(double %a, double %b, double %c, double %d, double %e,
25 double %f, double %g, double %h, double %i) nounwind {
27 %0 = getelementptr [11 x double], ptr @doubles, i32 0, i32 1
28 store volatile double %a, ptr %0
29 %1 = getelementptr [11 x double], ptr @doubles, i32 0, i32 2
30 store volatile double %b, ptr %1
31 %2 = getelementptr [11 x double], ptr @doubles, i32 0, i32 3
32 store volatile double %c, ptr %2
33 %3 = getelementptr [11 x double], ptr @doubles, i32 0, i32 4
34 store volatile double %d, ptr %3
35 %4 = getelementptr [11 x double], ptr @doubles, i32 0, i32 5
36 store volatile double %e, ptr %4
37 %5 = getelementptr [11 x double], ptr @doubles, i32 0, i32 6
38 store volatile double %f, ptr %5
39 %6 = getelementptr [11 x double], ptr @doubles, i32 0, i32 7
40 store volatile double %g, ptr %6
41 %7 = getelementptr [11 x double], ptr @doubles, i32 0, i32 8
42 store volatile double %h, ptr %7
43 %8 = getelementptr [11 x double], ptr @doubles, i32 0, i32 9
44 store volatile double %i, ptr %8
48 ; ALL-LABEL: double_args:
49 ; We won't test the way the global address is calculated in this test. This is
50 ; just to get the register number for the other checks.
51 ; SYM32-DAG: addiu [[R2:\$[0-9]+]], ${{[0-9]+}}, %lo(doubles)
52 ; SYM64-DAG: daddiu [[R2:\$[0-9]]], ${{[0-9]+}}, %lo(doubles)
54 ; The first four arguments are the same in O32/N32/N64.
55 ; The first argument is floating point but soft-float is enabled so floating
56 ; point registers are not used.
57 ; O32-DAG: sw $4, 8([[R2]])
58 ; O32-DAG: sw $5, 12([[R2]])
59 ; NEW-DAG: sd $4, 8([[R2]])
61 ; O32-DAG: sw $6, 16([[R2]])
62 ; O32-DAG: sw $7, 20([[R2]])
63 ; NEW-DAG: sd $5, 16([[R2]])
65 ; O32 has run out of argument registers and starts using the stack
66 ; O32-DAG: lw [[R3:\$([0-9]+|gp)]], 16($sp)
67 ; O32-DAG: lw [[R4:\$([0-9]+|gp)]], 20($sp)
68 ; O32-DAG: sw [[R3]], 24([[R2]])
69 ; O32-DAG: sw [[R4]], 28([[R2]])
70 ; NEW-DAG: sd $6, 24([[R2]])
72 ; O32-DAG: lw [[R3:\$([0-9]+|gp)]], 24($sp)
73 ; O32-DAG: lw [[R4:\$([0-9]+|gp)]], 28($sp)
74 ; O32-DAG: sw [[R3]], 32([[R2]])
75 ; O32-DAG: sw [[R4]], 36([[R2]])
76 ; NEW-DAG: sd $7, 32([[R2]])
78 ; O32-DAG: lw [[R3:\$([0-9]+|gp)]], 32($sp)
79 ; O32-DAG: lw [[R4:\$([0-9]+|gp)]], 36($sp)
80 ; O32-DAG: sw [[R3]], 40([[R2]])
81 ; O32-DAG: sw [[R4]], 44([[R2]])
82 ; NEW-DAG: sd $8, 40([[R2]])
84 ; O32-DAG: lw [[R3:\$([0-9]+|gp)]], 40($sp)
85 ; O32-DAG: lw [[R4:\$([0-9]+|gp)]], 44($sp)
86 ; O32-DAG: sw [[R3]], 48([[R2]])
87 ; O32-DAG: sw [[R4]], 52([[R2]])
88 ; NEW-DAG: sd $9, 48([[R2]])
90 ; O32-DAG: lw [[R3:\$([0-9]+|gp)]], 48($sp)
91 ; O32-DAG: lw [[R4:\$([0-9]+|gp)]], 52($sp)
92 ; O32-DAG: sw [[R3]], 56([[R2]])
93 ; O32-DAG: sw [[R4]], 60([[R2]])
94 ; NEW-DAG: sd $10, 56([[R2]])
96 ; N32/N64 have run out of registers and starts using the stack too
97 ; O32-DAG: lw [[R3:\$[0-9]+]], 56($sp)
98 ; O32-DAG: lw [[R4:\$[0-9]+]], 60($sp)
99 ; O32-DAG: sw [[R3]], 64([[R2]])
100 ; O32-DAG: sw [[R4]], 68([[R2]])
101 ; NEW-DAG: ld [[R3:\$[0-9]+]], 0($sp)
102 ; NEW-DAG: sd $11, 64([[R2]])
104 define void @float_args(float %a, float %b, float %c, float %d, float %e,
105 float %f, float %g, float %h, float %i, float %j)
108 %0 = getelementptr [11 x float], ptr @floats, i32 0, i32 1
109 store volatile float %a, ptr %0
110 %1 = getelementptr [11 x float], ptr @floats, i32 0, i32 2
111 store volatile float %b, ptr %1
112 %2 = getelementptr [11 x float], ptr @floats, i32 0, i32 3
113 store volatile float %c, ptr %2
114 %3 = getelementptr [11 x float], ptr @floats, i32 0, i32 4
115 store volatile float %d, ptr %3
116 %4 = getelementptr [11 x float], ptr @floats, i32 0, i32 5
117 store volatile float %e, ptr %4
118 %5 = getelementptr [11 x float], ptr @floats, i32 0, i32 6
119 store volatile float %f, ptr %5
120 %6 = getelementptr [11 x float], ptr @floats, i32 0, i32 7
121 store volatile float %g, ptr %6
122 %7 = getelementptr [11 x float], ptr @floats, i32 0, i32 8
123 store volatile float %h, ptr %7
124 %8 = getelementptr [11 x float], ptr @floats, i32 0, i32 9
125 store volatile float %i, ptr %8
126 %9 = getelementptr [11 x float], ptr @floats, i32 0, i32 10
127 store volatile float %j, ptr %9
131 ; ALL-LABEL: float_args:
132 ; We won't test the way the global address is calculated in this test. This is
133 ; just to get the register number for the other checks.
134 ; SYM32-DAG: addiu [[R2:\$[0-9]+]], ${{[0-9]+}}, %lo(floats)
135 ; SYM64-DAG: daddiu [[R2:\$[0-9]]], ${{[0-9]+}}, %lo(floats)
137 ; The first four arguments are the same in O32/N32/N64.
138 ; The first argument is floating point but soft-float is enabled so floating
139 ; point registers are not used.
140 ; MD00305 and GCC disagree on this one. MD00305 says that floats are treated
141 ; as 8-byte aligned and occupy two slots on O32. GCC is treating them as 4-byte
142 ; aligned and occupying one slot. We'll use GCC's definition.
143 ; ALL-DAG: sw $4, 4([[R2]])
144 ; ALL-DAG: sw $5, 8([[R2]])
145 ; ALL-DAG: sw $6, 12([[R2]])
146 ; ALL-DAG: sw $7, 16([[R2]])
148 ; O32 has run out of argument registers and starts using the stack
149 ; O32-DAG: lw [[R3:\$[0-9]+]], 16($sp)
150 ; O32-DAG: sw [[R3]], 20([[R2]])
151 ; NEW-DAG: sw $8, 20([[R2]])
153 ; O32-DAG: lw [[R3:\$[0-9]+]], 20($sp)
154 ; O32-DAG: sw [[R3]], 24([[R2]])
155 ; NEW-DAG: sw $9, 24([[R2]])
157 ; O32-DAG: lw [[R3:\$[0-9]+]], 24($sp)
158 ; O32-DAG: sw [[R3]], 28([[R2]])
159 ; NEW-DAG: sw $10, 28([[R2]])
161 ; O32-DAG: lw [[R3:\$[0-9]+]], 28($sp)
162 ; O32-DAG: sw [[R3]], 32([[R2]])
163 ; NEW-DAG: sw $11, 32([[R2]])
165 ; N32/N64 have run out of registers and start using the stack too
166 ; O32-DAG: lw [[R3:\$[0-9]+]], 32($sp)
167 ; O32-DAG: sw [[R3]], 36([[R2]])
168 ; NEW-DAG: lw [[R3:\$[0-9]+]], 0($sp)
169 ; NEW-DAG: sw [[R3]], 36([[R2]])
171 define void @double_arg2(i8 %a, double %b) nounwind {
173 %0 = getelementptr [11 x i8], ptr @bytes, i32 0, i32 1
174 store volatile i8 %a, ptr %0
175 %1 = getelementptr [11 x double], ptr @doubles, i32 0, i32 1
176 store volatile double %b, ptr %1
180 ; ALL-LABEL: double_arg2:
181 ; We won't test the way the global address is calculated in this test. This is
182 ; just to get the register number for the other checks.
183 ; SYM32-DAG: addiu [[R1:\$[0-9]+]], ${{[0-9]+}}, %lo(bytes)
184 ; SYM64-DAG: daddiu [[R1:\$[0-9]]], ${{[0-9]+}}, %lo(bytes)
185 ; SYM32-DAG: addiu [[R2:\$[0-9]+]], ${{[0-9]+}}, %lo(doubles)
186 ; SYM64-DAG: daddiu [[R2:\$[0-9]]], ${{[0-9]+}}, %lo(doubles)
188 ; The first four arguments are the same in O32/N32/N64.
189 ; The first argument isn't floating point so floating point registers are not
191 ; The second slot is insufficiently aligned for double on O32 so it is skipped.
192 ; Also, double occupies two slots on O32 and only one for N32/N64.
193 ; ALL-DAG: sb $4, 1([[R1]])
194 ; O32-DAG: sw $6, 8([[R2]])
195 ; O32-DAG: sw $7, 12([[R2]])
196 ; NEW-DAG: sd $5, 8([[R2]])
198 define void @float_arg2(i8 signext %a, float %b) nounwind {
200 %0 = getelementptr [11 x i8], ptr @bytes, i32 0, i32 1
201 store volatile i8 %a, ptr %0
202 %1 = getelementptr [11 x float], ptr @floats, i32 0, i32 1
203 store volatile float %b, ptr %1
207 ; ALL-LABEL: float_arg2:
208 ; We won't test the way the global address is calculated in this test. This is
209 ; just to get the register number for the other checks.
210 ; SYM32-DAG: addiu [[R1:\$[0-9]+]], ${{[0-9]+}}, %lo(bytes)
211 ; SYM64-DAG: daddiu [[R1:\$[0-9]]], ${{[0-9]+}}, %lo(bytes)
212 ; SYM32-DAG: addiu [[R2:\$[0-9]+]], ${{[0-9]+}}, %lo(floats)
213 ; SYM64-DAG: daddiu [[R2:\$[0-9]]], ${{[0-9]+}}, %lo(floats)
216 ; The first four arguments are the same in O32/N32/N64.
217 ; The first argument isn't floating point so floating point registers are not
219 ; MD00305 and GCC disagree on this one. MD00305 says that floats are treated
220 ; as 8-byte aligned and occupy two slots on O32. GCC is treating them as 4-byte
221 ; aligned and occupying one slot. We'll use GCC's definition.
222 ; ALL-DAG: sb $4, 1([[R1]])
223 ; ALL-DAG: sw $5, 4([[R2]])