@@ -870,6 +870,11 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
870
870
ifn ! ( "llvm.trunc.f32" , fn ( t_f32) -> t_f32) ;
871
871
ifn ! ( "llvm.trunc.f64" , fn ( t_f64) -> t_f64) ;
872
872
873
+ ifn ! ( "llvm.copysign.f32" , fn ( t_f32, t_f32) -> t_f32) ;
874
+ ifn ! ( "llvm.copysign.f64" , fn ( t_f64, t_f64) -> t_f64) ;
875
+ ifn ! ( "llvm.round.f32" , fn ( t_f32) -> t_f32) ;
876
+ ifn ! ( "llvm.round.f64" , fn ( t_f64) -> t_f64) ;
877
+
873
878
ifn ! ( "llvm.rint.f32" , fn ( t_f32) -> t_f32) ;
874
879
ifn ! ( "llvm.rint.f64" , fn ( t_f64) -> t_f64) ;
875
880
ifn ! ( "llvm.nearbyint.f32" , fn ( t_f32) -> t_f32) ;
@@ -931,20 +936,22 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
931
936
ifn ! ( "llvm.assume" , fn ( i1) -> void) ;
932
937
933
938
// Some intrinsics were introduced in later versions of LLVM, but they have
934
- // fallbacks in libc or libm and such. Currently, all of these intrinsics
935
- // were introduced in LLVM 3.4, so we case on that.
939
+ // fallbacks in libc or libm and such.
936
940
macro_rules! compatible_ifn {
937
- ( $name: expr, $cname: ident ( $( $arg: expr) ,* ) -> $ret: expr) => (
938
- ifn!( $name, fn ( $( $arg) ,* ) -> $ret) ;
941
+ ( $name: expr, $cname: ident ( $( $arg: expr) ,* ) -> $ret: expr, $llvm_version: expr) => (
942
+ if unsafe { llvm:: LLVMVersionMinor ( ) >= $llvm_version } {
943
+ // The `if key == $name` is already in ifn!
944
+ ifn!( $name, fn ( $( $arg) ,* ) -> $ret) ;
945
+ } else if * key == $name {
946
+ let f = declare:: declare_cfn( ccx, stringify!( $cname) ,
947
+ Type :: func( & [ $( $arg) ,* ] , & $ret) ,
948
+ ty:: mk_nil( ccx. tcx( ) ) ) ;
949
+ ccx. intrinsics( ) . borrow_mut( ) . insert( $name, f. clone( ) ) ;
950
+ return Some ( f) ;
951
+ }
939
952
)
940
953
}
941
954
942
- compatible_ifn ! ( "llvm.copysign.f32" , copysignf( t_f32, t_f32) -> t_f32) ;
943
- compatible_ifn ! ( "llvm.copysign.f64" , copysign( t_f64, t_f64) -> t_f64) ;
944
- compatible_ifn ! ( "llvm.round.f32" , roundf( t_f32) -> t_f32) ;
945
- compatible_ifn ! ( "llvm.round.f64" , round( t_f64) -> t_f64) ;
946
-
947
-
948
955
if ccx. sess ( ) . opts . debuginfo != NoDebugInfo {
949
956
ifn ! ( "llvm.dbg.declare" , fn ( Type :: metadata( ccx) , Type :: metadata( ccx) ) -> void) ;
950
957
ifn ! ( "llvm.dbg.value" , fn ( Type :: metadata( ccx) , t_i64, Type :: metadata( ccx) ) -> void) ;
0 commit comments