1 ; RUN: llc -march=mips -relocation-model=static -mattr=+soft-float < %s | FileCheck --check-prefix=ALL --check-prefix=SYM32 --check-prefix=O32 --check-prefix=O32BE %s 2 ; RUN: llc -march=mipsel -relocation-model=static -mattr=+soft-float < %s | FileCheck --check-prefix=ALL --check-prefix=SYM32 --check-prefix=O32 --check-prefix=O32LE %s 3 4 ; RUN-TODO: llc -march=mips64 -relocation-model=static -mattr=+soft-float -target-abi o32 < %s | FileCheck --check-prefix=ALL --check-prefix=SYM32 --check-prefix=O32 %s 5 ; RUN-TODO: llc -march=mips64el -relocation-model=static -mattr=+soft-float -target-abi o32 < %s | FileCheck --check-prefix=ALL --check-prefix=SYM32 --check-prefix=O32 %s 6 7 ; RUN: llc -march=mips64 -relocation-model=static -mattr=+soft-float -target-abi n32 < %s | FileCheck --check-prefix=ALL --check-prefix=SYM32 --check-prefix=NEW %s 8 ; RUN: llc -march=mips64el -relocation-model=static -mattr=+soft-float -target-abi n32 < %s | FileCheck --check-prefix=ALL --check-prefix=SYM32 --check-prefix=NEW %s 9 10 ; RUN: llc -march=mips64 -relocation-model=static -mattr=+soft-float -target-abi n64 < %s | FileCheck --check-prefix=ALL --check-prefix=SYM64 --check-prefix=NEW %s 11 ; RUN: llc -march=mips64el -relocation-model=static -mattr=+soft-float -target-abi n64 < %s | FileCheck --check-prefix=ALL --check-prefix=SYM64 --check-prefix=NEW %s 12 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 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 { 26 entry: 27 %0 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 1 28 store volatile double %a, double* %0 29 %1 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 2 30 store volatile double %b, double* %1 31 %2 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 3 32 store volatile double %c, double* %2 33 %3 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 4 34 store volatile double %d, double* %3 35 %4 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 5 36 store volatile double %e, double* %4 37 %5 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 6 38 store volatile double %f, double* %5 39 %6 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 7 40 store volatile double %g, double* %6 41 %7 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 8 42 store volatile double %h, double* %7 43 %8 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 9 44 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) 52 ; SYM64-DAG: ld [[R2:\$[0-9]]], %got_disp(doubles)( 53 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]]) 60 61 ; O32-DAG: sw $6, 16([[R2]]) 62 ; O32-DAG: sw $7, 20([[R2]]) 63 ; NEW-DAG: sd $5, 16([[R2]]) 64 65 ; O32 has run out of argument registers and starts using the stack 66 ; O32-DAG: lw [[R3:\$([0-9]+|gp)]], 24($sp) 67 ; O32-DAG: lw [[R4:\$([0-9]+|gp)]], 28($sp) 68 ; O32-DAG: sw [[R3]], 24([[R2]]) 69 ; O32-DAG: sw [[R4]], 28([[R2]]) 70 ; NEW-DAG: sd $6, 24([[R2]]) 71 72 ; O32-DAG: lw [[R3:\$([0-9]+|gp)]], 32($sp) 73 ; O32-DAG: lw [[R4:\$([0-9]+|gp)]], 36($sp) 74 ; O32-DAG: sw [[R3]], 32([[R2]]) 75 ; O32-DAG: sw [[R4]], 36([[R2]]) 76 ; NEW-DAG: sd $7, 32([[R2]]) 77 78 ; O32-DAG: lw [[R3:\$([0-9]+|gp)]], 40($sp) 79 ; O32-DAG: lw [[R4:\$([0-9]+|gp)]], 44($sp) 80 ; O32-DAG: sw [[R3]], 40([[R2]]) 81 ; O32-DAG: sw [[R4]], 44([[R2]]) 82 ; NEW-DAG: sd $8, 40([[R2]]) 83 84 ; O32-DAG: lw [[R3:\$([0-9]+|gp)]], 48($sp) 85 ; O32-DAG: lw [[R4:\$([0-9]+|gp)]], 52($sp) 86 ; O32-DAG: sw [[R3]], 48([[R2]]) 87 ; O32-DAG: sw [[R4]], 52([[R2]]) 88 ; NEW-DAG: sd $9, 48([[R2]]) 89 90 ; O32-DAG: lw [[R3:\$([0-9]+|gp)]], 56($sp) 91 ; O32-DAG: lw [[R4:\$([0-9]+|gp)]], 60($sp) 92 ; O32-DAG: sw [[R3]], 56([[R2]]) 93 ; O32-DAG: sw [[R4]], 60([[R2]]) 94 ; NEW-DAG: sd $10, 56([[R2]]) 95 96 ; N32/N64 have run out of registers and starts using the stack too 97 ; O32-DAG: lw [[R3:\$[0-9]+]], 64($sp) 98 ; O32-DAG: lw [[R4:\$[0-9]+]], 68($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]]) 103 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) 106 nounwind { 107 entry: 108 %0 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 1 109 store volatile float %a, float* %0 110 %1 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 2 111 store volatile float %b, float* %1 112 %2 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 3 113 store volatile float %c, float* %2 114 %3 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 4 115 store volatile float %d, float* %3 116 %4 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 5 117 store volatile float %e, float* %4 118 %5 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 6 119 store volatile float %f, float* %5 120 %6 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 7 121 store volatile float %g, float* %6 122 %7 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 8 123 store volatile float %h, float* %7 124 %8 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 9 125 store volatile float %i, float* %8 126 %9 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 10 127 store volatile float %j, float* %9 128 ret void 129 } 130 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: ld [[R2:\$[0-9]]], %got_disp(floats)( 136 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]]) 147 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]]) 152 153 ; O32-DAG: lw [[R3:\$[0-9]+]], 20($sp) 154 ; O32-DAG: sw [[R3]], 24([[R2]]) 155 ; NEW-DAG: sw $9, 24([[R2]]) 156 157 ; O32-DAG: lw [[R3:\$[0-9]+]], 24($sp) 158 ; O32-DAG: sw [[R3]], 28([[R2]]) 159 ; NEW-DAG: sw $10, 28([[R2]]) 160 161 ; O32-DAG: lw [[R3:\$[0-9]+]], 28($sp) 162 ; O32-DAG: sw [[R3]], 32([[R2]]) 163 ; NEW-DAG: sw $11, 32([[R2]]) 164 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]]) 170 171 define void @double_arg2(i8 %a, double %b) nounwind { 172 entry: 173 %0 = getelementptr [11 x i8], [11 x i8]* @bytes, i32 0, i32 1 174 store volatile i8 %a, i8* %0 175 %1 = getelementptr [11 x double], [11 x double]* @doubles, i32 0, i32 1 176 store volatile double %b, double* %1 177 ret void 178 } 179 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: ld [[R1:\$[0-9]]], %got_disp(bytes)( 185 ; SYM32-DAG: addiu [[R2:\$[0-9]+]], ${{[0-9]+}}, %lo(doubles) 186 ; SYM64-DAG: ld [[R2:\$[0-9]]], %got_disp(doubles)( 187 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 190 ; used. 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]]) 197 198 define void @float_arg2(i8 signext %a, float %b) nounwind { 199 entry: 200 %0 = getelementptr [11 x i8], [11 x i8]* @bytes, i32 0, i32 1 201 store volatile i8 %a, i8* %0 202 %1 = getelementptr [11 x float], [11 x float]* @floats, i32 0, i32 1 203 store volatile float %b, float* %1 204 ret void 205 } 206 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: ld [[R1:\$[0-9]]], %got_disp(bytes)( 212 ; SYM32-DAG: addiu [[R2:\$[0-9]+]], ${{[0-9]+}}, %lo(floats) 213 ; SYM64-DAG: ld [[R2:\$[0-9]]], %got_disp(floats)( 214 215 ; The first four arguments are the same in O32/N32/N64. 216 ; The first argument isn't floating point so floating point registers are not 217 ; used. 218 ; MD00305 and GCC disagree on this one. MD00305 says that floats are treated 219 ; as 8-byte aligned and occupy two slots on O32. GCC is treating them as 4-byte 220 ; aligned and occupying one slot. We'll use GCC's definition. 221 ; ALL-DAG: sb $4, 1([[R1]]) 222 ; ALL-DAG: sw $5, 4([[R2]]) 223