Skip to content

Commit 9f1c621

Browse files
committed
rustc_trans: don't hardcode llvm version for conditional intrinsics
This commit introduce a third parameter for compatible_ifn!, as new intrinsics are being added in recent LLVM releases and there is no need to hardcode a specific case. Signed-off-by: Luca Bruno <[email protected]>
1 parent 796d009 commit 9f1c621

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/librustc_trans/trans/context.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -876,11 +876,10 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
876876
ifn!("llvm.assume", fn(i1) -> void);
877877

878878
// Some intrinsics were introduced in later versions of LLVM, but they have
879-
// fallbacks in libc or libm and such. Currently, all of these intrinsics
880-
// were introduced in LLVM 3.4, so we case on that.
879+
// fallbacks in libc or libm and such.
881880
macro_rules! compatible_ifn {
882-
($name:expr, $cname:ident ($($arg:expr),*) -> $ret:expr) => (
883-
if unsafe { llvm::LLVMVersionMinor() >= 4 } {
881+
($name:expr, $cname:ident ($($arg:expr),*) -> $ret:expr, $llvm_version:expr) => (
882+
if unsafe { llvm::LLVMVersionMinor() >= $llvm_version } {
884883
// The `if key == $name` is already in ifn!
885884
ifn!($name, fn($($arg),*) -> $ret);
886885
} else if *key == $name {
@@ -893,10 +892,10 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
893892
)
894893
}
895894

896-
compatible_ifn!("llvm.copysign.f32", copysignf(t_f32, t_f32) -> t_f32);
897-
compatible_ifn!("llvm.copysign.f64", copysign(t_f64, t_f64) -> t_f64);
898-
compatible_ifn!("llvm.round.f32", roundf(t_f32) -> t_f32);
899-
compatible_ifn!("llvm.round.f64", round(t_f64) -> t_f64);
895+
compatible_ifn!("llvm.copysign.f32", copysignf(t_f32, t_f32) -> t_f32, 4);
896+
compatible_ifn!("llvm.copysign.f64", copysign(t_f64, t_f64) -> t_f64, 4);
897+
compatible_ifn!("llvm.round.f32", roundf(t_f32) -> t_f32, 4);
898+
compatible_ifn!("llvm.round.f64", round(t_f64) -> t_f64, 4);
900899

901900

902901
if ccx.sess().opts.debuginfo != NoDebugInfo {

0 commit comments

Comments
 (0)