diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index cdc128c6eeb6..bf3d09d848da 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -220,7 +220,6 @@ pub mod llvm { use super::{ObjectFileRef, Opcode, PassManagerRef, PassManagerBuilderRef}; use super::{SectionIteratorRef, TargetDataRef, TypeKind, TypeRef, UseRef}; use super::{ValueRef}; - use super::{IntPredicate, RealPredicate}; use core::libc::{c_char, c_int, c_longlong, c_uint, c_ulonglong}; @@ -453,9 +452,9 @@ pub mod llvm { #[fast_ffi] pub unsafe fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef; #[fast_ffi] - pub unsafe fn LLVMConstICmp(Pred: IntPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef; + pub unsafe fn LLVMConstICmp(Pred: c_uint, V1: ValueRef, V2: ValueRef) -> ValueRef; #[fast_ffi] - pub unsafe fn LLVMConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef; + pub unsafe fn LLVMConstFCmp(Pred: c_uint, V1: ValueRef, V2: ValueRef) -> ValueRef; /* only for int/vector */ #[fast_ffi] pub unsafe fn LLVMGetUndef(Ty: TypeRef) -> ValueRef; @@ -1919,6 +1918,16 @@ pub fn SetLinkage(Global: ValueRef, Link: Linkage) { } } +pub fn ConstICmp(Pred: IntPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef { + unsafe { + llvm::LLVMConstICmp(Pred as c_uint, V1, V2) + } +} +pub fn ConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef { + unsafe { + llvm::LLVMConstICmp(Pred as c_uint, V1, V2) + } +} /* Memory-managed object interface to type handles. */ pub struct TypeNames { diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 6df523976f2b..22014fa33041 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -9,7 +9,8 @@ // except according to those terms. use back::abi; -use lib::llvm::{llvm, SetLinkage, PrivateLinkage, ValueRef, TypeRef, Bool, True, False}; +use lib::llvm::{llvm, ConstFCmp, ConstICmp, SetLinkage, PrivateLinkage, ValueRef, TypeRef, Bool, + True, False}; use lib::llvm::{IntEQ, IntNE, IntUGT, IntUGE, IntULT, IntULE, IntSGT, IntSGE, IntSLT, IntSLE, RealOEQ, RealOGT, RealOGE, RealOLT, RealOLE, RealONE}; @@ -293,39 +294,39 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef { else { llvm::LLVMConstLShr(te1, te2) } } ast::eq => { - if is_float { llvm::LLVMConstFCmp(RealOEQ, te1, te2) } - else { llvm::LLVMConstICmp(IntEQ, te1, te2) } + if is_float { ConstFCmp(RealOEQ, te1, te2) } + else { ConstICmp(IntEQ, te1, te2) } }, ast::lt => { - if is_float { llvm::LLVMConstFCmp(RealOLT, te1, te2) } + if is_float { ConstFCmp(RealOLT, te1, te2) } else { - if signed { llvm::LLVMConstICmp(IntSLT, te1, te2) } - else { llvm::LLVMConstICmp(IntULT, te1, te2) } + if signed { ConstICmp(IntSLT, te1, te2) } + else { ConstICmp(IntULT, te1, te2) } } }, ast::le => { - if is_float { llvm::LLVMConstFCmp(RealOLE, te1, te2) } + if is_float { ConstFCmp(RealOLE, te1, te2) } else { - if signed { llvm::LLVMConstICmp(IntSLE, te1, te2) } - else { llvm::LLVMConstICmp(IntULE, te1, te2) } + if signed { ConstICmp(IntSLE, te1, te2) } + else { ConstICmp(IntULE, te1, te2) } } }, ast::ne => { - if is_float { llvm::LLVMConstFCmp(RealONE, te1, te2) } - else { llvm::LLVMConstICmp(IntNE, te1, te2) } + if is_float { ConstFCmp(RealONE, te1, te2) } + else { ConstICmp(IntNE, te1, te2) } }, ast::ge => { - if is_float { llvm::LLVMConstFCmp(RealOGE, te1, te2) } + if is_float { ConstFCmp(RealOGE, te1, te2) } else { - if signed { llvm::LLVMConstICmp(IntSGE, te1, te2) } - else { llvm::LLVMConstICmp(IntUGE, te1, te2) } + if signed { ConstICmp(IntSGE, te1, te2) } + else { ConstICmp(IntUGE, te1, te2) } } }, ast::gt => { - if is_float { llvm::LLVMConstFCmp(RealOGT, te1, te2) } + if is_float { ConstFCmp(RealOGT, te1, te2) } else { - if signed { llvm::LLVMConstICmp(IntSGT, te1, te2) } - else { llvm::LLVMConstICmp(IntUGT, te1, te2) } + if signed { ConstICmp(IntSGT, te1, te2) } + else { ConstICmp(IntUGT, te1, te2) } } }, };