1; We used to mark some of these as noinline, with the claim that 2; "otherwise llvm sneakily peephole optimizes things like (float)(ceil((double)f)) -> ceilf(f), 3; even though ceilf doesn't exist."" 4; 5; However, this causes another problem; since this module is always inlined into 6; generated code by LLVM_Runtime_Linker, anything that is marked 'noinline' gets 7; duplicated in each AOT section, making it impossible to link multiple AOT outputs 8; into a single binary without using the /FORCE:MULTIPLE flag, which is suboptimal. 9; 10; Since posix_math.ll seems to be avoiding the peepholing issue mentioned above, 11; we're marking everything in this file as alwaysinline (as expected by LLVM_Runtime_Linker) 12; for now, and will re-examine the peephole issues if/when they appear. 13 14declare double @llvm.sqrt.f64(double) nounwind readnone 15 16define weak_odr double @sqrt_f64(double %x) nounwind uwtable readnone alwaysinline { 17 %y = tail call double @llvm.sqrt.f64(double %x) nounwind readnone 18 ret double %y 19} 20 21define weak_odr float @sqrt_f32(float %x) nounwind uwtable readnone alwaysinline { 22 %xd = fpext float %x to double 23 %yd = tail call double @sqrt_f64(double %xd) nounwind readnone 24 %y = fptrunc double %yd to float 25 ret float %y 26} 27 28declare double @llvm.sin.f64(double) nounwind readnone 29 30define weak_odr double @sin_f64(double %x) nounwind uwtable readnone alwaysinline { 31 %y = tail call double @llvm.sin.f64(double %x) nounwind readnone 32 ret double %y 33} 34 35define weak_odr float @sin_f32(float %x) nounwind uwtable readnone alwaysinline { 36 %xd = fpext float %x to double 37 %yd = tail call double @sin_f64(double %xd) nounwind readnone 38 %y = fptrunc double %yd to float 39 ret float %y 40} 41 42declare double @llvm.cos.f64(double) nounwind readnone 43 44define weak_odr double @cos_f64(double %x) nounwind uwtable readnone alwaysinline { 45 %y = tail call double @llvm.cos.f64(double %x) nounwind readnone 46 ret double %y 47} 48 49define weak_odr float @cos_f32(float %x) nounwind uwtable readnone alwaysinline { 50 %xd = fpext float %x to double 51 %yd = tail call double @cos_f64(double %xd) nounwind readnone 52 %y = fptrunc double %yd to float 53 ret float %y 54} 55 56declare double @llvm.exp.f64(double) nounwind readnone 57 58define weak_odr double @exp_f64(double %x) nounwind uwtable readnone alwaysinline { 59 %y = tail call double @llvm.exp.f64(double %x) nounwind readnone 60 ret double %y 61} 62 63define weak_odr float @exp_f32(float %x) nounwind uwtable readnone alwaysinline { 64 %xd = fpext float %x to double 65 %yd = tail call double @exp_f64(double %xd) nounwind readnone 66 %y = fptrunc double %yd to float 67 ret float %y 68} 69 70declare double @llvm.log.f64(double) nounwind readnone 71 72define weak_odr double @log_f64(double %x) nounwind uwtable readnone alwaysinline { 73 %y = tail call double @llvm.log.f64(double %x) nounwind readnone 74 ret double %y 75} 76 77define weak_odr float @log_f32(float %x) nounwind uwtable readnone alwaysinline { 78 %xd = fpext float %x to double 79 %yd = tail call double @log_f64(double %xd) nounwind readnone 80 %y = fptrunc double %yd to float 81 ret float %y 82} 83 84declare float @llvm.fabs.f32(float) nounwind readnone 85declare double @llvm.fabs.f64(double) nounwind readnone 86 87define weak_odr double @abs_f64(double %x) nounwind uwtable readnone alwaysinline { 88 %y = tail call double @llvm.fabs.f64(double %x) nounwind readnone 89 ret double %y 90} 91 92define weak_odr float @abs_f32(float %x) nounwind uwtable readnone alwaysinline { 93 %xd = fpext float %x to double 94 %yd = tail call double @abs_f64(double %xd) nounwind readnone 95 %y = fptrunc double %yd to float 96 ret float %y 97} 98 99declare double @llvm.floor.f64(double) nounwind readnone 100 101define weak_odr double @floor_f64(double %x) nounwind uwtable readnone alwaysinline { 102 %y = tail call double @llvm.floor.f64(double %x) nounwind readnone 103 ret double %y 104} 105 106define weak_odr float @floor_f32(float %x) nounwind uwtable readnone alwaysinline { 107 %xd = fpext float %x to double 108 %yd = tail call double @floor_f64(double %xd) nounwind readnone 109 %y = fptrunc double %yd to float 110 ret float %y 111} 112 113declare double @ceil(double) nounwind readnone 114 115define weak_odr double @ceil_f64(double %x) nounwind uwtable readnone alwaysinline { 116 %y = tail call double @ceil(double %x) nounwind readnone 117 ret double %y 118} 119 120define weak_odr float @ceil_f32(float %x) nounwind uwtable readnone alwaysinline { 121 %xd = fpext float %x to double 122 %yd = tail call double @ceil_f64(double %xd) nounwind readnone 123 %y = fptrunc double %yd to float 124 ret float %y 125} 126 127declare float @llvm.nearbyint.f32(float) nounwind readnone 128declare double @llvm.nearbyint.f64(double) nounwind readnone 129 130define weak_odr float @round_f32(float %x) nounwind uwtable readnone alwaysinline { 131 %y = tail call float @llvm.nearbyint.f32(float %x) nounwind readnone 132 ret float %y 133} 134 135define weak_odr double @round_f64(double %x) nounwind uwtable readnone alwaysinline { 136 %y = tail call double @llvm.nearbyint.f64(double %x) nounwind readnone 137 ret double %y 138} 139 140declare float @llvm.trunc.f32(float) nounwind readnone 141declare double @llvm.trunc.f64(double) nounwind readnone 142 143define weak_odr float @trunc_f32(float %x) nounwind uwtable readnone alwaysinline { 144 %y = tail call float @llvm.trunc.f32(float %x) nounwind readnone 145 ret float %y 146} 147 148define weak_odr double @trunc_f64(double %x) nounwind uwtable readnone alwaysinline { 149 %y = tail call double @llvm.trunc.f64(double %x) nounwind readnone 150 ret double %y 151} 152 153declare double @llvm.pow.f64(double, double) nounwind readnone 154 155define weak_odr double @pow_f64(double %x, double %y) nounwind uwtable readnone alwaysinline { 156 %z = tail call double @llvm.pow.f64(double %x, double %y) nounwind readnone 157 ret double %z 158} 159 160define weak_odr float @pow_f32(float %x1, float %x2) nounwind uwtable readnone alwaysinline { 161 %x1d = fpext float %x1 to double 162 %x2d = fpext float %x2 to double 163 %yd = tail call double @pow_f64(double %x1d, double %x2d) nounwind readnone 164 %y = fptrunc double %yd to float 165 ret float %y 166} 167 168declare double @asin(double) nounwind readnone 169 170define weak_odr double @asin_f64(double %x) nounwind uwtable readnone alwaysinline { 171 %y = tail call double @asin(double %x) nounwind readnone 172 ret double %y 173} 174 175define weak_odr float @asin_f32(float %x) nounwind uwtable readnone alwaysinline { 176 %xd = fpext float %x to double 177 %yd = tail call double @asin_f64(double %xd) nounwind readnone 178 %y = fptrunc double %yd to float 179 ret float %y 180} 181 182declare double @acos(double) nounwind readnone 183 184define weak_odr double @acos_f64(double %x) nounwind uwtable readnone alwaysinline { 185 %y = tail call double @acos(double %x) nounwind readnone 186 ret double %y 187} 188 189define weak_odr float @acos_f32(float %x) nounwind uwtable readnone alwaysinline { 190 %xd = fpext float %x to double 191 %yd = tail call double @acos_f64(double %xd) nounwind readnone 192 %y = fptrunc double %yd to float 193 ret float %y 194} 195 196declare double @tan(double) nounwind readnone 197 198define weak_odr double @tan_f64(double %x) nounwind uwtable readnone alwaysinline { 199 %y = tail call double @tan(double %x) nounwind readnone 200 ret double %y 201} 202 203define weak_odr float @tan_f32(float %x) nounwind uwtable readnone alwaysinline { 204 %xd = fpext float %x to double 205 %yd = tail call double @tan_f64(double %xd) nounwind readnone 206 %y = fptrunc double %yd to float 207 ret float %y 208} 209 210declare double @atan(double) nounwind readnone 211 212define weak_odr double @atan_f64(double %x) nounwind uwtable readnone alwaysinline { 213 %y = tail call double @atan(double %x) nounwind readnone 214 ret double %y 215} 216 217define weak_odr float @atan_f32(float %x) nounwind uwtable readnone alwaysinline { 218 %xd = fpext float %x to double 219 %yd = tail call double @atan_f64(double %xd) nounwind readnone 220 %y = fptrunc double %yd to float 221 ret float %y 222} 223 224declare double @atan2(double, double) nounwind readnone 225 226define weak_odr double @atan2_f64(double %y, double %x) nounwind uwtable readnone alwaysinline { 227 %z = tail call double @atan2(double %y, double %x) nounwind readnone 228 ret double %z 229} 230 231define weak_odr float @atan2_f32(float %x1, float %x2) nounwind uwtable readnone alwaysinline { 232 %x1d = fpext float %x1 to double 233 %x2d = fpext float %x2 to double 234 %yd = tail call double @atan2_f64(double %x1d, double %x2d) nounwind readnone 235 %y = fptrunc double %yd to float 236 ret float %y 237} 238 239declare double @sinh(double) nounwind readnone 240 241define weak_odr double @sinh_f64(double %x) nounwind uwtable readnone alwaysinline { 242 %y = tail call double @sinh(double %x) nounwind readnone 243 ret double %y 244} 245 246define weak_odr float @sinh_f32(float %x) nounwind uwtable readnone alwaysinline { 247 %xd = fpext float %x to double 248 %yd = tail call double @sinh_f64(double %xd) nounwind readnone 249 %y = fptrunc double %yd to float 250 ret float %y 251} 252 253declare double @asinh(double) nounwind readnone 254 255define weak_odr double @asinh_f64(double %x) nounwind uwtable readnone alwaysinline { 256 %y = tail call double @asinh(double %x) nounwind readnone 257 ret double %y 258} 259 260define weak_odr float @asinh_f32(float %x) nounwind uwtable readnone alwaysinline { 261 %xd = fpext float %x to double 262 %yd = tail call double @asinh_f64(double %xd) nounwind readnone 263 %y = fptrunc double %yd to float 264 ret float %y 265} 266 267declare double @cosh(double) nounwind readnone 268 269define weak_odr double @cosh_f64(double %x) nounwind uwtable readnone alwaysinline { 270 %y = tail call double @cosh(double %x) nounwind readnone 271 ret double %y 272} 273 274define weak_odr float @cosh_f32(float %x) nounwind uwtable readnone alwaysinline { 275 %xd = fpext float %x to double 276 %yd = tail call double @cosh_f64(double %xd) nounwind readnone 277 %y = fptrunc double %yd to float 278 ret float %y 279} 280 281declare double @acosh(double) nounwind readnone 282 283define weak_odr double @acosh_f64(double %x) nounwind uwtable readnone alwaysinline { 284 %y = tail call double @acosh(double %x) nounwind readnone 285 ret double %y 286} 287 288define weak_odr float @acosh_f32(float %x) nounwind uwtable readnone alwaysinline { 289 %xd = fpext float %x to double 290 %yd = tail call double @acosh_f64(double %xd) nounwind readnone 291 %y = fptrunc double %yd to float 292 ret float %y 293} 294 295declare double @tanh(double) nounwind readnone 296 297define weak_odr double @tanh_f64(double %x) nounwind uwtable readnone alwaysinline { 298 %y = tail call double @tanh(double %x) nounwind readnone 299 ret double %y 300} 301 302define weak_odr float @tanh_f32(float %x) nounwind uwtable readnone alwaysinline { 303 %xd = fpext float %x to double 304 %yd = tail call double @tanh_f64(double %xd) nounwind readnone 305 %y = fptrunc double %yd to float 306 ret float %y 307} 308 309declare double @atanh(double) nounwind readnone 310 311define weak_odr double @atanh_f64(double %x) nounwind uwtable readnone alwaysinline { 312 %y = tail call double @atanh(double %x) nounwind readnone 313 ret double %y 314} 315 316define weak_odr float @atanh_f32(float %x) nounwind uwtable readnone alwaysinline { 317 %xd = fpext float %x to double 318 %yd = tail call double @atanh_f64(double %xd) nounwind readnone 319 %y = fptrunc double %yd to float 320 ret float %y 321} 322 323 324define weak_odr float @inf_f32() nounwind uwtable readnone alwaysinline { 325 ret float 0x7FF0000000000000 326} 327 328define weak_odr float @neg_inf_f32() nounwind uwtable readnone alwaysinline { 329 ret float 0xFFF0000000000000 330} 331 332define weak_odr float @nan_f32() nounwind uwtable readnone alwaysinline { 333 ret float 0x7FF8000000000000 334} 335 336 337define weak_odr double @inf_f64() nounwind uwtable readnone alwaysinline { 338 ret double 0x7FF0000000000000 339} 340 341define weak_odr double @neg_inf_f64() nounwind uwtable readnone alwaysinline { 342 ret double 0xFFF0000000000000 343} 344 345define weak_odr double @nan_f64() nounwind uwtable readnone alwaysinline { 346 ret double 0x7FF8000000000000 347}