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