Skip to content

Commit 08b2fcd

Browse files
lucabtamird
authored andcommitted
---
yaml --- r: 212299 b: refs/heads/auto c: ce32f64 h: refs/heads/master i: 212297: 20f62c0 212295: 67b6348 v: v3
1 parent a121aa9 commit 08b2fcd

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
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 1be9e6f055fbcd6bfcf0a1f9e9ef0e86abe54f02
13+
refs/heads/auto: ce32f6412e1937c0844aa48e5b4e876b96dcd66d
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/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,

branches/auto/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);

branches/auto/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)