1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=mips -relocation-model=static < %s | FileCheck --check-prefixes=ALL,SYM32,O32,O32BE %s 2*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=mipsel -relocation-model=static < %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 -target-abi o32 < %s | FileCheck --check-prefixes=ALL,SYM32,O32 %s 5*9880d681SAndroid Build Coastguard Worker; RUN-TODO: llc -march=mips64el -relocation-model=static -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 -target-abi n32 < %s | FileCheck --check-prefixes=ALL,SYM32,NEW %s 8*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=mips64el -relocation-model=static -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 -target-abi n64 < %s | FileCheck --check-prefixes=ALL,SYM64,NEW %s 11*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=mips64el -relocation-model=static -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 argument is floating point so floating point registers are used. 55*9880d681SAndroid Build Coastguard Worker; The first argument is the same for O32/N32/N64 but the second argument differs 56*9880d681SAndroid Build Coastguard Worker; by register 57*9880d681SAndroid Build Coastguard Worker; ALL-DAG: sdc1 $f12, 8([[R2]]) 58*9880d681SAndroid Build Coastguard Worker; O32-DAG: sdc1 $f14, 16([[R2]]) 59*9880d681SAndroid Build Coastguard Worker; NEW-DAG: sdc1 $f13, 16([[R2]]) 60*9880d681SAndroid Build Coastguard Worker 61*9880d681SAndroid Build Coastguard Worker; O32 has run out of argument registers and starts using the stack 62*9880d681SAndroid Build Coastguard Worker; O32-DAG: ldc1 [[F1:\$f[0-9]+]], 16($sp) 63*9880d681SAndroid Build Coastguard Worker; O32-DAG: sdc1 [[F1]], 24([[R2]]) 64*9880d681SAndroid Build Coastguard Worker; NEW-DAG: sdc1 $f14, 24([[R2]]) 65*9880d681SAndroid Build Coastguard Worker; O32-DAG: ldc1 [[F1:\$f[0-9]+]], 24($sp) 66*9880d681SAndroid Build Coastguard Worker; O32-DAG: sdc1 [[F1]], 32([[R2]]) 67*9880d681SAndroid Build Coastguard Worker; NEW-DAG: sdc1 $f15, 32([[R2]]) 68*9880d681SAndroid Build Coastguard Worker; O32-DAG: ldc1 [[F1:\$f[0-9]+]], 32($sp) 69*9880d681SAndroid Build Coastguard Worker; O32-DAG: sdc1 [[F1]], 40([[R2]]) 70*9880d681SAndroid Build Coastguard Worker; NEW-DAG: sdc1 $f16, 40([[R2]]) 71*9880d681SAndroid Build Coastguard Worker; O32-DAG: ldc1 [[F1:\$f[0-9]+]], 40($sp) 72*9880d681SAndroid Build Coastguard Worker; O32-DAG: sdc1 [[F1]], 48([[R2]]) 73*9880d681SAndroid Build Coastguard Worker; NEW-DAG: sdc1 $f17, 48([[R2]]) 74*9880d681SAndroid Build Coastguard Worker; O32-DAG: ldc1 [[F1:\$f[0-9]+]], 48($sp) 75*9880d681SAndroid Build Coastguard Worker; O32-DAG: sdc1 [[F1]], 56([[R2]]) 76*9880d681SAndroid Build Coastguard Worker; NEW-DAG: sdc1 $f18, 56([[R2]]) 77*9880d681SAndroid Build Coastguard Worker; O32-DAG: ldc1 [[F1:\$f[0-9]+]], 56($sp) 78*9880d681SAndroid Build Coastguard Worker; O32-DAG: sdc1 [[F1]], 64([[R2]]) 79*9880d681SAndroid Build Coastguard Worker; NEW-DAG: sdc1 $f19, 64([[R2]]) 80*9880d681SAndroid Build Coastguard Worker 81*9880d681SAndroid Build Coastguard Worker; N32/N64 have run out of registers and start using the stack too 82*9880d681SAndroid Build Coastguard Worker; O32-DAG: ldc1 [[F1:\$f[0-9]+]], 64($sp) 83*9880d681SAndroid Build Coastguard Worker; O32-DAG: sdc1 [[F1]], 72([[R2]]) 84*9880d681SAndroid Build Coastguard Worker; NEW-DAG: ldc1 [[F1:\$f[0-9]+]], 0($sp) 85*9880d681SAndroid Build Coastguard Worker; NEW-DAG: sdc1 [[F1]], 72([[R2]]) 86*9880d681SAndroid Build Coastguard Worker 87*9880d681SAndroid Build Coastguard Workerdefine void @float_args(float %a, float %b, float %c, float %d, float %e, 88*9880d681SAndroid Build Coastguard Worker float %f, float %g, float %h, float %i) nounwind { 89*9880d681SAndroid Build Coastguard Workerentry: 90*9880d681SAndroid Build Coastguard Worker %0 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 1 91*9880d681SAndroid Build Coastguard Worker store volatile float %a, float* %0 92*9880d681SAndroid Build Coastguard Worker %1 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 2 93*9880d681SAndroid Build Coastguard Worker store volatile float %b, float* %1 94*9880d681SAndroid Build Coastguard Worker %2 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 3 95*9880d681SAndroid Build Coastguard Worker store volatile float %c, float* %2 96*9880d681SAndroid Build Coastguard Worker %3 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 4 97*9880d681SAndroid Build Coastguard Worker store volatile float %d, float* %3 98*9880d681SAndroid Build Coastguard Worker %4 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 5 99*9880d681SAndroid Build Coastguard Worker store volatile float %e, float* %4 100*9880d681SAndroid Build Coastguard Worker %5 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 6 101*9880d681SAndroid Build Coastguard Worker store volatile float %f, float* %5 102*9880d681SAndroid Build Coastguard Worker %6 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 7 103*9880d681SAndroid Build Coastguard Worker store volatile float %g, float* %6 104*9880d681SAndroid Build Coastguard Worker %7 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 8 105*9880d681SAndroid Build Coastguard Worker store volatile float %h, float* %7 106*9880d681SAndroid Build Coastguard Worker %8 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 9 107*9880d681SAndroid Build Coastguard Worker store volatile float %i, float* %8 108*9880d681SAndroid Build Coastguard Worker ret void 109*9880d681SAndroid Build Coastguard Worker} 110*9880d681SAndroid Build Coastguard Worker 111*9880d681SAndroid Build Coastguard Worker; ALL-LABEL: float_args: 112*9880d681SAndroid Build Coastguard Worker; We won't test the way the global address is calculated in this test. This is 113*9880d681SAndroid Build Coastguard Worker; just to get the register number for the other checks. 114*9880d681SAndroid Build Coastguard Worker; SYM32-DAG: addiu [[R1:\$[0-9]+]], ${{[0-9]+}}, %lo(floats) 115*9880d681SAndroid Build Coastguard Worker; SYM64-DAG: ld [[R1:\$[0-9]]], %got_disp(floats)( 116*9880d681SAndroid Build Coastguard Worker 117*9880d681SAndroid Build Coastguard Worker; The first argument is floating point so floating point registers are used. 118*9880d681SAndroid Build Coastguard Worker; The first argument is the same for O32/N32/N64 but the second argument differs 119*9880d681SAndroid Build Coastguard Worker; by register 120*9880d681SAndroid Build Coastguard Worker; ALL-DAG: swc1 $f12, 4([[R1]]) 121*9880d681SAndroid Build Coastguard Worker; O32-DAG: swc1 $f14, 8([[R1]]) 122*9880d681SAndroid Build Coastguard Worker; NEW-DAG: swc1 $f13, 8([[R1]]) 123*9880d681SAndroid Build Coastguard Worker 124*9880d681SAndroid Build Coastguard Worker; O32 has run out of argument registers and (in theory) starts using the stack 125*9880d681SAndroid Build Coastguard Worker; I've yet to find a reference in the documentation about this but GCC uses up 126*9880d681SAndroid Build Coastguard Worker; the remaining two argument slots in the GPR's first. We'll do the same for 127*9880d681SAndroid Build Coastguard Worker; compatibility. 128*9880d681SAndroid Build Coastguard Worker; O32-DAG: sw $6, 12([[R1]]) 129*9880d681SAndroid Build Coastguard Worker; NEW-DAG: swc1 $f14, 12([[R1]]) 130*9880d681SAndroid Build Coastguard Worker; O32-DAG: sw $7, 16([[R1]]) 131*9880d681SAndroid Build Coastguard Worker; NEW-DAG: swc1 $f15, 16([[R1]]) 132*9880d681SAndroid Build Coastguard Worker 133*9880d681SAndroid Build Coastguard Worker; O32 is definitely out of registers now and switches to the stack. 134*9880d681SAndroid Build Coastguard Worker; O32-DAG: lwc1 [[F1:\$f[0-9]+]], 16($sp) 135*9880d681SAndroid Build Coastguard Worker; O32-DAG: swc1 [[F1]], 20([[R1]]) 136*9880d681SAndroid Build Coastguard Worker; NEW-DAG: swc1 $f16, 20([[R1]]) 137*9880d681SAndroid Build Coastguard Worker; O32-DAG: lwc1 [[F1:\$f[0-9]+]], 20($sp) 138*9880d681SAndroid Build Coastguard Worker; O32-DAG: swc1 [[F1]], 24([[R1]]) 139*9880d681SAndroid Build Coastguard Worker; NEW-DAG: swc1 $f17, 24([[R1]]) 140*9880d681SAndroid Build Coastguard Worker; O32-DAG: lwc1 [[F1:\$f[0-9]+]], 24($sp) 141*9880d681SAndroid Build Coastguard Worker; O32-DAG: swc1 [[F1]], 28([[R1]]) 142*9880d681SAndroid Build Coastguard Worker; NEW-DAG: swc1 $f18, 28([[R1]]) 143*9880d681SAndroid Build Coastguard Worker; O32-DAG: lwc1 [[F1:\$f[0-9]+]], 28($sp) 144*9880d681SAndroid Build Coastguard Worker; O32-DAG: swc1 [[F1]], 32([[R1]]) 145*9880d681SAndroid Build Coastguard Worker; NEW-DAG: swc1 $f19, 32([[R1]]) 146*9880d681SAndroid Build Coastguard Worker 147*9880d681SAndroid Build Coastguard Worker; N32/N64 have run out of registers and start using the stack too 148*9880d681SAndroid Build Coastguard Worker; O32-DAG: lwc1 [[F1:\$f[0-9]+]], 32($sp) 149*9880d681SAndroid Build Coastguard Worker; O32-DAG: swc1 [[F1]], 36([[R1]]) 150*9880d681SAndroid Build Coastguard Worker; NEW-DAG: lwc1 [[F1:\$f[0-9]+]], 0($sp) 151*9880d681SAndroid Build Coastguard Worker; NEW-DAG: swc1 [[F1]], 36([[R1]]) 152*9880d681SAndroid Build Coastguard Worker 153*9880d681SAndroid Build Coastguard Worker 154*9880d681SAndroid Build Coastguard Workerdefine void @double_arg2(i8 %a, double %b) nounwind { 155*9880d681SAndroid Build Coastguard Workerentry: 156*9880d681SAndroid Build Coastguard Worker %0 = getelementptr [11 x i8], [11 x i8]* @bytes, i32 0, i32 1 157*9880d681SAndroid Build Coastguard Worker store volatile i8 %a, i8* %0 158*9880d681SAndroid Build Coastguard Worker %1 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 1 159*9880d681SAndroid Build Coastguard Worker store volatile double %b, double* %1 160*9880d681SAndroid Build Coastguard Worker ret void 161*9880d681SAndroid Build Coastguard Worker} 162*9880d681SAndroid Build Coastguard Worker 163*9880d681SAndroid Build Coastguard Worker; ALL-LABEL: double_arg2: 164*9880d681SAndroid Build Coastguard Worker; We won't test the way the global address is calculated in this test. This is 165*9880d681SAndroid Build Coastguard Worker; just to get the register number for the other checks. 166*9880d681SAndroid Build Coastguard Worker; SYM32-DAG: addiu [[R1:\$[0-9]+]], ${{[0-9]+}}, %lo(bytes) 167*9880d681SAndroid Build Coastguard Worker; SYM64-DAG: ld [[R1:\$[0-9]]], %got_disp(bytes)( 168*9880d681SAndroid Build Coastguard Worker; SYM32-DAG: addiu [[R2:\$[0-9]+]], ${{[0-9]+}}, %lo(doubles) 169*9880d681SAndroid Build Coastguard Worker; SYM64-DAG: ld [[R2:\$[0-9]]], %got_disp(doubles)( 170*9880d681SAndroid Build Coastguard Worker 171*9880d681SAndroid Build Coastguard Worker; The first argument is the same in O32/N32/N64. 172*9880d681SAndroid Build Coastguard Worker; ALL-DAG: sb $4, 1([[R1]]) 173*9880d681SAndroid Build Coastguard Worker 174*9880d681SAndroid Build Coastguard Worker; The first argument isn't floating point so floating point registers are not 175*9880d681SAndroid Build Coastguard Worker; used in O32, but N32/N64 will still use them. 176*9880d681SAndroid Build Coastguard Worker; The second slot is insufficiently aligned for double on O32 so it is skipped. 177*9880d681SAndroid Build Coastguard Worker; Also, double occupies two slots on O32 and only one for N32/N64. 178*9880d681SAndroid Build Coastguard Worker; O32LE-DAG: mtc1 $6, [[F1:\$f[0-9]*[02468]+]] 179*9880d681SAndroid Build Coastguard Worker; O32LE-DAG: mtc1 $7, [[F2:\$f[0-9]*[13579]+]] 180*9880d681SAndroid Build Coastguard Worker; O32BE-DAG: mtc1 $6, [[F2:\$f[0-9]*[13579]+]] 181*9880d681SAndroid Build Coastguard Worker; O32BE-DAG: mtc1 $7, [[F1:\$f[0-9]*[02468]+]] 182*9880d681SAndroid Build Coastguard Worker; O32-DAG: sdc1 [[F1]], 8([[R2]]) 183*9880d681SAndroid Build Coastguard Worker; NEW-DAG: sdc1 $f13, 8([[R2]]) 184*9880d681SAndroid Build Coastguard Worker 185*9880d681SAndroid Build Coastguard Workerdefine void @float_arg2(i8 %a, float %b) nounwind { 186*9880d681SAndroid Build Coastguard Workerentry: 187*9880d681SAndroid Build Coastguard Worker %0 = getelementptr [11 x i8], [11 x i8]* @bytes, i32 0, i32 1 188*9880d681SAndroid Build Coastguard Worker store volatile i8 %a, i8* %0 189*9880d681SAndroid Build Coastguard Worker %1 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 1 190*9880d681SAndroid Build Coastguard Worker store volatile float %b, float* %1 191*9880d681SAndroid Build Coastguard Worker ret void 192*9880d681SAndroid Build Coastguard Worker} 193*9880d681SAndroid Build Coastguard Worker 194*9880d681SAndroid Build Coastguard Worker; ALL-LABEL: float_arg2: 195*9880d681SAndroid Build Coastguard Worker; We won't test the way the global address is calculated in this test. This is 196*9880d681SAndroid Build Coastguard Worker; just to get the register number for the other checks. 197*9880d681SAndroid Build Coastguard Worker; SYM32-DAG: addiu [[R1:\$[0-9]+]], ${{[0-9]+}}, %lo(bytes) 198*9880d681SAndroid Build Coastguard Worker; SYM64-DAG: ld [[R1:\$[0-9]]], %got_disp(bytes)( 199*9880d681SAndroid Build Coastguard Worker; SYM32-DAG: addiu [[R2:\$[0-9]+]], ${{[0-9]+}}, %lo(floats) 200*9880d681SAndroid Build Coastguard Worker; SYM64-DAG: ld [[R2:\$[0-9]]], %got_disp(floats)( 201*9880d681SAndroid Build Coastguard Worker 202*9880d681SAndroid Build Coastguard Worker; The first argument is the same in O32/N32/N64. 203*9880d681SAndroid Build Coastguard Worker; ALL-DAG: sb $4, 1([[R1]]) 204*9880d681SAndroid Build Coastguard Worker 205*9880d681SAndroid Build Coastguard Worker; The first argument isn't floating point so floating point registers are not 206*9880d681SAndroid Build Coastguard Worker; used in O32, but N32/N64 will still use them. 207*9880d681SAndroid Build Coastguard Worker; MD00305 and GCC disagree on this one. MD00305 says that floats are treated 208*9880d681SAndroid Build Coastguard Worker; as 8-byte aligned and occupy two slots on O32. GCC is treating them as 4-byte 209*9880d681SAndroid Build Coastguard Worker; aligned and occupying one slot. We'll use GCC's definition. 210*9880d681SAndroid Build Coastguard Worker; O32-DAG: sw $5, 4([[R2]]) 211*9880d681SAndroid Build Coastguard Worker; NEW-DAG: swc1 $f13, 4([[R2]]) 212