blob: e98a11a8064c8fca3e07baf74921851ab32b3562 [file] [log] [blame]
Daniel Sanders0d972702016-06-24 12:23:17 +00001; RUN: llc -march=mips -relocation-model=static < %s | FileCheck --check-prefixes=ALL,SYM32,O32,O32BE %s
2; RUN: llc -march=mipsel -relocation-model=static < %s | FileCheck --check-prefixes=ALL,SYM32,O32,O32LE %s
Daniel Sanders9fe0ad02014-04-16 09:59:46 +00003
Daniel Sanders0d972702016-06-24 12:23:17 +00004; RUN-TODO: llc -march=mips64 -relocation-model=static -target-abi o32 < %s | FileCheck --check-prefixes=ALL,SYM32,O32 %s
5; RUN-TODO: llc -march=mips64el -relocation-model=static -target-abi o32 < %s | FileCheck --check-prefixes=ALL,SYM32,O32 %s
Daniel Sanders9fe0ad02014-04-16 09:59:46 +00006
Daniel Sanders0d972702016-06-24 12:23:17 +00007; RUN: llc -march=mips64 -relocation-model=static -target-abi n32 < %s | FileCheck --check-prefixes=ALL,SYM32,NEW %s
8; RUN: llc -march=mips64el -relocation-model=static -target-abi n32 < %s | FileCheck --check-prefixes=ALL,SYM32,NEW %s
Daniel Sanders9fe0ad02014-04-16 09:59:46 +00009
Daniel Sanders0d972702016-06-24 12:23:17 +000010; RUN: llc -march=mips64 -relocation-model=static -target-abi n64 < %s | FileCheck --check-prefixes=ALL,SYM64,NEW %s
11; RUN: llc -march=mips64el -relocation-model=static -target-abi n64 < %s | FileCheck --check-prefixes=ALL,SYM64,NEW %s
Daniel Sanders9fe0ad02014-04-16 09:59:46 +000012
13; Test the floating point arguments for all ABI's and byte orders as specified
14; by section 5 of MD00305 (MIPS ABIs Described).
15;
16; N32/N64 are identical in this area so their checks have been combined into
17; the 'NEW' prefix (the N stands for New).
18
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
23
24define void @double_args(double %a, double %b, double %c, double %d, double %e,
25 double %f, double %g, double %h, double %i) nounwind {
26entry:
David Blaikie79e6c742015-02-27 19:29:02 +000027 %0 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 1
Daniel Sanders9fe0ad02014-04-16 09:59:46 +000028 store volatile double %a, double* %0
David Blaikie79e6c742015-02-27 19:29:02 +000029 %1 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 2
Daniel Sanders9fe0ad02014-04-16 09:59:46 +000030 store volatile double %b, double* %1
David Blaikie79e6c742015-02-27 19:29:02 +000031 %2 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 3
Daniel Sanders9fe0ad02014-04-16 09:59:46 +000032 store volatile double %c, double* %2
David Blaikie79e6c742015-02-27 19:29:02 +000033 %3 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 4
Daniel Sanders9fe0ad02014-04-16 09:59:46 +000034 store volatile double %d, double* %3
David Blaikie79e6c742015-02-27 19:29:02 +000035 %4 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 5
Daniel Sanders9fe0ad02014-04-16 09:59:46 +000036 store volatile double %e, double* %4
David Blaikie79e6c742015-02-27 19:29:02 +000037 %5 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 6
Daniel Sanders9fe0ad02014-04-16 09:59:46 +000038 store volatile double %f, double* %5
David Blaikie79e6c742015-02-27 19:29:02 +000039 %6 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 7
Daniel Sanders9fe0ad02014-04-16 09:59:46 +000040 store volatile double %g, double* %6
David Blaikie79e6c742015-02-27 19:29:02 +000041 %7 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 8
Daniel Sanders9fe0ad02014-04-16 09:59:46 +000042 store volatile double %h, double* %7
David Blaikie79e6c742015-02-27 19:29:02 +000043 %8 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 9
Daniel Sanders9fe0ad02014-04-16 09:59:46 +000044 store volatile double %i, double* %8
45 ret void
46}
47
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)
Simon Dardisca74dd72017-01-27 11:36:52 +000052; SYM64-DAG: daddiu [[R2:\$[0-9]]], ${{[0-9]+}}, %lo(doubles)
Daniel Sanders9fe0ad02014-04-16 09:59:46 +000053
54; The first argument is floating point so floating point registers are used.
55; The first argument is the same for O32/N32/N64 but the second argument differs
56; by register
57; ALL-DAG: sdc1 $f12, 8([[R2]])
58; O32-DAG: sdc1 $f14, 16([[R2]])
59; NEW-DAG: sdc1 $f13, 16([[R2]])
60
61; O32 has run out of argument registers and starts using the stack
62; O32-DAG: ldc1 [[F1:\$f[0-9]+]], 16($sp)
63; O32-DAG: sdc1 [[F1]], 24([[R2]])
64; NEW-DAG: sdc1 $f14, 24([[R2]])
65; O32-DAG: ldc1 [[F1:\$f[0-9]+]], 24($sp)
66; O32-DAG: sdc1 [[F1]], 32([[R2]])
67; NEW-DAG: sdc1 $f15, 32([[R2]])
68; O32-DAG: ldc1 [[F1:\$f[0-9]+]], 32($sp)
69; O32-DAG: sdc1 [[F1]], 40([[R2]])
70; NEW-DAG: sdc1 $f16, 40([[R2]])
71; O32-DAG: ldc1 [[F1:\$f[0-9]+]], 40($sp)
72; O32-DAG: sdc1 [[F1]], 48([[R2]])
73; NEW-DAG: sdc1 $f17, 48([[R2]])
74; O32-DAG: ldc1 [[F1:\$f[0-9]+]], 48($sp)
75; O32-DAG: sdc1 [[F1]], 56([[R2]])
76; NEW-DAG: sdc1 $f18, 56([[R2]])
77; O32-DAG: ldc1 [[F1:\$f[0-9]+]], 56($sp)
78; O32-DAG: sdc1 [[F1]], 64([[R2]])
79; NEW-DAG: sdc1 $f19, 64([[R2]])
80
81; N32/N64 have run out of registers and start using the stack too
82; O32-DAG: ldc1 [[F1:\$f[0-9]+]], 64($sp)
83; O32-DAG: sdc1 [[F1]], 72([[R2]])
84; NEW-DAG: ldc1 [[F1:\$f[0-9]+]], 0($sp)
85; NEW-DAG: sdc1 [[F1]], 72([[R2]])
86
87define void @float_args(float %a, float %b, float %c, float %d, float %e,
88 float %f, float %g, float %h, float %i) nounwind {
89entry:
David Blaikie79e6c742015-02-27 19:29:02 +000090 %0 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 1
Daniel Sanders9fe0ad02014-04-16 09:59:46 +000091 store volatile float %a, float* %0
David Blaikie79e6c742015-02-27 19:29:02 +000092 %1 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 2
Daniel Sanders9fe0ad02014-04-16 09:59:46 +000093 store volatile float %b, float* %1
David Blaikie79e6c742015-02-27 19:29:02 +000094 %2 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 3
Daniel Sanders9fe0ad02014-04-16 09:59:46 +000095 store volatile float %c, float* %2
David Blaikie79e6c742015-02-27 19:29:02 +000096 %3 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 4
Daniel Sanders9fe0ad02014-04-16 09:59:46 +000097 store volatile float %d, float* %3
David Blaikie79e6c742015-02-27 19:29:02 +000098 %4 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 5
Daniel Sanders9fe0ad02014-04-16 09:59:46 +000099 store volatile float %e, float* %4
David Blaikie79e6c742015-02-27 19:29:02 +0000100 %5 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 6
Daniel Sanders9fe0ad02014-04-16 09:59:46 +0000101 store volatile float %f, float* %5
David Blaikie79e6c742015-02-27 19:29:02 +0000102 %6 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 7
Daniel Sanders9fe0ad02014-04-16 09:59:46 +0000103 store volatile float %g, float* %6
David Blaikie79e6c742015-02-27 19:29:02 +0000104 %7 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 8
Daniel Sanders9fe0ad02014-04-16 09:59:46 +0000105 store volatile float %h, float* %7
David Blaikie79e6c742015-02-27 19:29:02 +0000106 %8 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 9
Daniel Sanders9fe0ad02014-04-16 09:59:46 +0000107 store volatile float %i, float* %8
108 ret void
109}
110
111; ALL-LABEL: float_args:
112; We won't test the way the global address is calculated in this test. This is
113; just to get the register number for the other checks.
Simon Dardisca74dd72017-01-27 11:36:52 +0000114; SYM32-DAG: addiu [[R1:\$[0-9]+]], ${{[0-9]+}}, %lo(floats)
115; SYM64-DAG: daddiu [[R1:\$[0-9]]], ${{[0-9]+}}, %lo(floats)
Daniel Sanders9fe0ad02014-04-16 09:59:46 +0000116
117; The first argument is floating point so floating point registers are used.
118; The first argument is the same for O32/N32/N64 but the second argument differs
119; by register
120; ALL-DAG: swc1 $f12, 4([[R1]])
121; O32-DAG: swc1 $f14, 8([[R1]])
122; NEW-DAG: swc1 $f13, 8([[R1]])
123
124; O32 has run out of argument registers and (in theory) starts using the stack
125; I've yet to find a reference in the documentation about this but GCC uses up
126; the remaining two argument slots in the GPR's first. We'll do the same for
127; compatibility.
Craig Topperd8e91c32018-08-24 17:48:25 +0000128; O32-DAG: mtc1 $6, $f0
129; O32-DAG: swc1 $f0, 12([[R1]])
Daniel Sanders9fe0ad02014-04-16 09:59:46 +0000130; NEW-DAG: swc1 $f14, 12([[R1]])
Craig Topperd8e91c32018-08-24 17:48:25 +0000131; O32-DAG: mtc1 $7, $f0
132; O32-DAG: swc1 $f0, 16([[R1]])
Daniel Sanders9fe0ad02014-04-16 09:59:46 +0000133; NEW-DAG: swc1 $f15, 16([[R1]])
134
135; O32 is definitely out of registers now and switches to the stack.
136; O32-DAG: lwc1 [[F1:\$f[0-9]+]], 16($sp)
137; O32-DAG: swc1 [[F1]], 20([[R1]])
138; NEW-DAG: swc1 $f16, 20([[R1]])
139; O32-DAG: lwc1 [[F1:\$f[0-9]+]], 20($sp)
140; O32-DAG: swc1 [[F1]], 24([[R1]])
141; NEW-DAG: swc1 $f17, 24([[R1]])
142; O32-DAG: lwc1 [[F1:\$f[0-9]+]], 24($sp)
143; O32-DAG: swc1 [[F1]], 28([[R1]])
144; NEW-DAG: swc1 $f18, 28([[R1]])
145; O32-DAG: lwc1 [[F1:\$f[0-9]+]], 28($sp)
146; O32-DAG: swc1 [[F1]], 32([[R1]])
147; NEW-DAG: swc1 $f19, 32([[R1]])
148
149; N32/N64 have run out of registers and start using the stack too
150; O32-DAG: lwc1 [[F1:\$f[0-9]+]], 32($sp)
151; O32-DAG: swc1 [[F1]], 36([[R1]])
152; NEW-DAG: lwc1 [[F1:\$f[0-9]+]], 0($sp)
153; NEW-DAG: swc1 [[F1]], 36([[R1]])
154
155
156define void @double_arg2(i8 %a, double %b) nounwind {
157entry:
David Blaikie79e6c742015-02-27 19:29:02 +0000158 %0 = getelementptr [11 x i8], [11 x i8]* @bytes, i32 0, i32 1
Daniel Sanders9fe0ad02014-04-16 09:59:46 +0000159 store volatile i8 %a, i8* %0
David Blaikie79e6c742015-02-27 19:29:02 +0000160 %1 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 1
Daniel Sanders9fe0ad02014-04-16 09:59:46 +0000161 store volatile double %b, double* %1
162 ret void
163}
164
165; ALL-LABEL: double_arg2:
166; We won't test the way the global address is calculated in this test. This is
167; just to get the register number for the other checks.
168; SYM32-DAG: addiu [[R1:\$[0-9]+]], ${{[0-9]+}}, %lo(bytes)
Simon Dardisca74dd72017-01-27 11:36:52 +0000169; SYM64-DAG: daddiu [[R1:\$[0-9]]], ${{[0-9]+}}, %lo(bytes)
Daniel Sanders9fe0ad02014-04-16 09:59:46 +0000170; SYM32-DAG: addiu [[R2:\$[0-9]+]], ${{[0-9]+}}, %lo(doubles)
Simon Dardisca74dd72017-01-27 11:36:52 +0000171; SYM64-DAG: daddiu [[R2:\$[0-9]]], ${{[0-9]+}}, %lo(doubles)
Daniel Sanders9fe0ad02014-04-16 09:59:46 +0000172
173; The first argument is the same in O32/N32/N64.
174; ALL-DAG: sb $4, 1([[R1]])
175
176; The first argument isn't floating point so floating point registers are not
177; used in O32, but N32/N64 will still use them.
178; The second slot is insufficiently aligned for double on O32 so it is skipped.
179; Also, double occupies two slots on O32 and only one for N32/N64.
180; O32LE-DAG: mtc1 $6, [[F1:\$f[0-9]*[02468]+]]
181; O32LE-DAG: mtc1 $7, [[F2:\$f[0-9]*[13579]+]]
182; O32BE-DAG: mtc1 $6, [[F2:\$f[0-9]*[13579]+]]
183; O32BE-DAG: mtc1 $7, [[F1:\$f[0-9]*[02468]+]]
184; O32-DAG: sdc1 [[F1]], 8([[R2]])
185; NEW-DAG: sdc1 $f13, 8([[R2]])
186
187define void @float_arg2(i8 %a, float %b) nounwind {
188entry:
David Blaikie79e6c742015-02-27 19:29:02 +0000189 %0 = getelementptr [11 x i8], [11 x i8]* @bytes, i32 0, i32 1
Daniel Sanders9fe0ad02014-04-16 09:59:46 +0000190 store volatile i8 %a, i8* %0
David Blaikie79e6c742015-02-27 19:29:02 +0000191 %1 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 1
Daniel Sanders9fe0ad02014-04-16 09:59:46 +0000192 store volatile float %b, float* %1
193 ret void
194}
195
196; ALL-LABEL: float_arg2:
197; We won't test the way the global address is calculated in this test. This is
198; just to get the register number for the other checks.
199; SYM32-DAG: addiu [[R1:\$[0-9]+]], ${{[0-9]+}}, %lo(bytes)
Simon Dardisca74dd72017-01-27 11:36:52 +0000200; SYM64-DAG: daddiu [[R1:\$[0-9]]], ${{[0-9]+}}, %lo(bytes)
Daniel Sanders9fe0ad02014-04-16 09:59:46 +0000201; SYM32-DAG: addiu [[R2:\$[0-9]+]], ${{[0-9]+}}, %lo(floats)
Simon Dardisca74dd72017-01-27 11:36:52 +0000202; SYM64-DAG: daddiu [[R2:\$[0-9]]], ${{[0-9]+}}, %lo(floats)
Daniel Sanders9fe0ad02014-04-16 09:59:46 +0000203
204; The first argument is the same in O32/N32/N64.
205; ALL-DAG: sb $4, 1([[R1]])
206
207; The first argument isn't floating point so floating point registers are not
208; used in O32, but N32/N64 will still use them.
209; MD00305 and GCC disagree on this one. MD00305 says that floats are treated
210; as 8-byte aligned and occupy two slots on O32. GCC is treating them as 4-byte
211; aligned and occupying one slot. We'll use GCC's definition.
Craig Topperd8e91c32018-08-24 17:48:25 +0000212; O32-DAG: mtc1 $5, $f0
213; O32-DAG: swc1 $f0, 4([[R2]])
Daniel Sanders9fe0ad02014-04-16 09:59:46 +0000214; NEW-DAG: swc1 $f13, 4([[R2]])