Skip to content

Commit 4d97a09

Browse files
lucabtamird
authored andcommitted
---
yaml --- r: 212278 b: refs/heads/master c: ce32f64 h: refs/heads/master v: v3
1 parent c778d10 commit 4d97a09

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 1be9e6f055fbcd6bfcf0a1f9e9ef0e86abe54f02
2+
refs/heads/master: ce32f6412e1937c0844aa48e5b4e876b96dcd66d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
55
refs/heads/try: 1864973ae17213c5a58c4dd3f9af6d1b6c7d2e05

trunk/src/librustc_llvm/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,6 +1772,8 @@ extern {
17721772
-> ValueRef;
17731773

17741774
pub fn LLVMRustDebugMetadataVersion() -> u32;
1775+
pub fn LLVMVersionMajor() -> u32;
1776+
pub fn LLVMVersionMinor() -> u32;
17751777

17761778
pub fn LLVMRustAddModuleFlag(M: ModuleRef,
17771779
name: *const c_char,

trunk/src/librustc_trans/trans/context.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,11 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
870870
ifn!("llvm.trunc.f32", fn(t_f32) -> t_f32);
871871
ifn!("llvm.trunc.f64", fn(t_f64) -> t_f64);
872872

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+
873878
ifn!("llvm.rint.f32", fn(t_f32) -> t_f32);
874879
ifn!("llvm.rint.f64", fn(t_f64) -> t_f64);
875880
ifn!("llvm.nearbyint.f32", fn(t_f32) -> t_f32);
@@ -931,20 +936,22 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
931936
ifn!("llvm.assume", fn(i1) -> void);
932937

933938
// 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.
936940
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+
}
939952
)
940953
}
941954

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-
948955
if ccx.sess().opts.debuginfo != NoDebugInfo {
949956
ifn!("llvm.dbg.declare", fn(Type::metadata(ccx), Type::metadata(ccx)) -> void);
950957
ifn!("llvm.dbg.value", fn(Type::metadata(ccx), t_i64, Type::metadata(ccx)) -> void);

trunk/src/rustllvm/RustWrapper.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ extern "C" uint32_t LLVMRustDebugMetadataVersion() {
237237
return DEBUG_METADATA_VERSION;
238238
}
239239

240+
extern "C" uint32_t LLVMVersionMinor() {
241+
return LLVM_VERSION_MINOR;
242+
}
243+
244+
extern "C" uint32_t LLVMVersionMajor() {
245+
return LLVM_VERSION_MAJOR;
246+
}
247+
240248
extern "C" void LLVMRustAddModuleFlag(LLVMModuleRef M,
241249
const char *name,
242250
uint32_t value) {

0 commit comments

Comments
 (0)