@@ -2286,8 +2286,6 @@ pub fn declare_intrinsics(llmod: ModuleRef) -> HashMap<&'static str, ValueRef> {
2286
2286
2287
2287
ifn!( intrinsics, "llvm.fabs.f32" , [ Type :: f32 ( ) ] , Type :: f32 ( ) ) ;
2288
2288
ifn!( intrinsics, "llvm.fabs.f64" , [ Type :: f64 ( ) ] , Type :: f64 ( ) ) ;
2289
- ifn!( intrinsics, "llvm.copysign.f32" , [ Type :: f32 ( ) , Type :: f32 ( ) ] , Type :: f32 ( ) ) ;
2290
- ifn!( intrinsics, "llvm.copysign.f64" , [ Type :: f64 ( ) , Type :: f64 ( ) ] , Type :: f64 ( ) ) ;
2291
2289
2292
2290
ifn!( intrinsics, "llvm.floor.f32" , [ Type :: f32 ( ) ] , Type :: f32 ( ) ) ;
2293
2291
ifn!( intrinsics, "llvm.floor.f64" , [ Type :: f64 ( ) ] , Type :: f64 ( ) ) ;
@@ -2300,8 +2298,6 @@ pub fn declare_intrinsics(llmod: ModuleRef) -> HashMap<&'static str, ValueRef> {
2300
2298
ifn!( intrinsics, "llvm.rint.f64" , [ Type :: f64 ( ) ] , Type :: f64 ( ) ) ;
2301
2299
ifn!( intrinsics, "llvm.nearbyint.f32" , [ Type :: f32 ( ) ] , Type :: f32 ( ) ) ;
2302
2300
ifn!( intrinsics, "llvm.nearbyint.f64" , [ Type :: f64 ( ) ] , Type :: f64 ( ) ) ;
2303
- ifn!( intrinsics, "llvm.round.f32" , [ Type :: f32 ( ) ] , Type :: f32 ( ) ) ;
2304
- ifn!( intrinsics, "llvm.round.f64" , [ Type :: f64 ( ) ] , Type :: f64 ( ) ) ;
2305
2301
2306
2302
ifn!( intrinsics, "llvm.ctpop.i8" , [ Type :: i8 ( ) ] , Type :: i8 ( ) ) ;
2307
2303
ifn!( intrinsics, "llvm.ctpop.i16" , [ Type :: i16 ( ) ] , Type :: i16 ( ) ) ;
@@ -2378,6 +2374,32 @@ pub fn declare_intrinsics(llmod: ModuleRef) -> HashMap<&'static str, ValueRef> {
2378
2374
2379
2375
ifn!( intrinsics, "llvm.expect.i1" , [ Type :: i1( ) , Type :: i1( ) ] , Type :: i1( ) ) ;
2380
2376
2377
+ // Some intrinsics were introduced in later versions of LLVM, but they have
2378
+ // fallbacks in libc or libm and such. Currently, all of these intrinsics
2379
+ // were introduced in LLVM 3.4, so we case on that.
2380
+ macro_rules! compatible_ifn (
2381
+ ( $intrinsics: ident, $name: expr, $cname: expr, $args: expr, $ret: expr) => ( {
2382
+ let name = $name;
2383
+ if unsafe { llvm:: LLVMVersionMinor ( ) >= 4 } {
2384
+ ifn!( $intrinsics, $name, $args, $ret) ;
2385
+ } else {
2386
+ let f = decl_cdecl_fn( llmod, $cname,
2387
+ Type :: func( $args, & $ret) ,
2388
+ ty:: mk_nil( ) ) ;
2389
+ $intrinsics. insert( name, f) ;
2390
+ }
2391
+ } )
2392
+ )
2393
+
2394
+ compatible_ifn!( intrinsics, "llvm.copysign.f32" , "copysignf" ,
2395
+ [ Type :: f32 ( ) , Type :: f32 ( ) ] , Type :: f32 ( ) ) ;
2396
+ compatible_ifn!( intrinsics, "llvm.copysign.f64" , "copysign" ,
2397
+ [ Type :: f64 ( ) , Type :: f64 ( ) ] , Type :: f64 ( ) ) ;
2398
+ compatible_ifn!( intrinsics, "llvm.round.f32" , "roundf" ,
2399
+ [ Type :: f32 ( ) ] , Type :: f32 ( ) ) ;
2400
+ compatible_ifn!( intrinsics, "llvm.round.f64" , "round" ,
2401
+ [ Type :: f64 ( ) ] , Type :: f64 ( ) ) ;
2402
+
2381
2403
return intrinsics;
2382
2404
}
2383
2405
0 commit comments