@@ -2286,8 +2286,6 @@ pub fn declare_intrinsics(llmod: ModuleRef) -> HashMap<&'static str, ValueRef> {
22862286
22872287 ifn!( intrinsics, "llvm.fabs.f32" , [ Type :: f32 ( ) ] , Type :: f32 ( ) ) ;
22882288 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 ( ) ) ;
22912289
22922290 ifn!( intrinsics, "llvm.floor.f32" , [ Type :: f32 ( ) ] , Type :: f32 ( ) ) ;
22932291 ifn!( intrinsics, "llvm.floor.f64" , [ Type :: f64 ( ) ] , Type :: f64 ( ) ) ;
@@ -2300,8 +2298,6 @@ pub fn declare_intrinsics(llmod: ModuleRef) -> HashMap<&'static str, ValueRef> {
23002298 ifn!( intrinsics, "llvm.rint.f64" , [ Type :: f64 ( ) ] , Type :: f64 ( ) ) ;
23012299 ifn!( intrinsics, "llvm.nearbyint.f32" , [ Type :: f32 ( ) ] , Type :: f32 ( ) ) ;
23022300 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 ( ) ) ;
23052301
23062302 ifn!( intrinsics, "llvm.ctpop.i8" , [ Type :: i8 ( ) ] , Type :: i8 ( ) ) ;
23072303 ifn!( intrinsics, "llvm.ctpop.i16" , [ Type :: i16 ( ) ] , Type :: i16 ( ) ) ;
@@ -2378,6 +2374,32 @@ pub fn declare_intrinsics(llmod: ModuleRef) -> HashMap<&'static str, ValueRef> {
23782374
23792375 ifn!( intrinsics, "llvm.expect.i1" , [ Type :: i1( ) , Type :: i1( ) ] , Type :: i1( ) ) ;
23802376
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+
23812403 return intrinsics;
23822404}
23832405
0 commit comments