librustc: Attempt to put out burning tree by fixing translation of unary negation in boolean constants. rs=burningtree
This commit is contained in:
parent
b34f871dda
commit
cf6c3d96fb
2 changed files with 31 additions and 15 deletions
|
@ -445,14 +445,19 @@ pub extern mod llvm {
|
||||||
Count: c_uint,
|
Count: c_uint,
|
||||||
Packed: Bool) -> ValueRef;
|
Packed: Bool) -> ValueRef;
|
||||||
|
|
||||||
pub unsafe fn LLVMConstString(Str: *c_char, Length: c_uint,
|
pub unsafe fn LLVMConstString(Str: *c_char,
|
||||||
DontNullTerminate: Bool) -> ValueRef;
|
Length: c_uint,
|
||||||
pub unsafe fn LLVMConstArray(ElementTy: TypeRef, ConstantVals: *ValueRef,
|
DontNullTerminate: Bool)
|
||||||
Length: c_uint) -> ValueRef;
|
-> ValueRef;
|
||||||
|
pub unsafe fn LLVMConstArray(ElementTy: TypeRef,
|
||||||
|
ConstantVals: *ValueRef,
|
||||||
|
Length: c_uint)
|
||||||
|
-> ValueRef;
|
||||||
pub unsafe fn LLVMConstStruct(ConstantVals: *ValueRef,
|
pub unsafe fn LLVMConstStruct(ConstantVals: *ValueRef,
|
||||||
Count: c_uint, Packed: Bool) -> ValueRef;
|
Count: c_uint,
|
||||||
|
Packed: Bool) -> ValueRef;
|
||||||
pub unsafe fn LLVMConstVector(ScalarConstantVals: *ValueRef,
|
pub unsafe fn LLVMConstVector(ScalarConstantVals: *ValueRef,
|
||||||
Size: c_uint) -> ValueRef;
|
Size: c_uint) -> ValueRef;
|
||||||
|
|
||||||
/* Constant expressions */
|
/* Constant expressions */
|
||||||
pub unsafe fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
|
pub unsafe fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
|
||||||
|
@ -463,8 +468,8 @@ pub extern mod llvm {
|
||||||
pub unsafe fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
|
pub unsafe fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
|
||||||
pub unsafe fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
|
pub unsafe fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
|
||||||
pub unsafe fn LLVMConstAdd(LHSConstant: ValueRef,
|
pub unsafe fn LLVMConstAdd(LHSConstant: ValueRef,
|
||||||
RHSConstant: ValueRef)
|
RHSConstant: ValueRef)
|
||||||
-> ValueRef;
|
-> ValueRef;
|
||||||
pub unsafe fn LLVMConstNSWAdd(LHSConstant: ValueRef,
|
pub unsafe fn LLVMConstNSWAdd(LHSConstant: ValueRef,
|
||||||
RHSConstant: ValueRef)
|
RHSConstant: ValueRef)
|
||||||
-> ValueRef;
|
-> ValueRef;
|
||||||
|
@ -475,14 +480,14 @@ pub extern mod llvm {
|
||||||
RHSConstant: ValueRef)
|
RHSConstant: ValueRef)
|
||||||
-> ValueRef;
|
-> ValueRef;
|
||||||
pub unsafe fn LLVMConstSub(LHSConstant: ValueRef,
|
pub unsafe fn LLVMConstSub(LHSConstant: ValueRef,
|
||||||
RHSConstant: ValueRef)
|
RHSConstant: ValueRef)
|
||||||
-> ValueRef;
|
-> ValueRef;
|
||||||
pub unsafe fn LLVMConstNSWSub(LHSConstant: ValueRef,
|
pub unsafe fn LLVMConstNSWSub(LHSConstant: ValueRef,
|
||||||
RHSConstant: ValueRef)
|
RHSConstant: ValueRef)
|
||||||
-> ValueRef;
|
-> ValueRef;
|
||||||
pub unsafe fn LLVMConstNUWSub(LHSConstant: ValueRef,
|
pub unsafe fn LLVMConstNUWSub(LHSConstant: ValueRef,
|
||||||
RHSConstant: ValueRef)
|
RHSConstant: ValueRef)
|
||||||
-> ValueRef;
|
-> ValueRef;
|
||||||
pub unsafe fn LLVMConstFSub(LHSConstant: ValueRef,
|
pub unsafe fn LLVMConstFSub(LHSConstant: ValueRef,
|
||||||
RHSConstant: ValueRef)
|
RHSConstant: ValueRef)
|
||||||
-> ValueRef;
|
-> ValueRef;
|
||||||
|
|
|
@ -204,7 +204,18 @@ pub fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
|
||||||
ast::box(_) |
|
ast::box(_) |
|
||||||
ast::uniq(_) |
|
ast::uniq(_) |
|
||||||
ast::deref => const_deref(cx, te),
|
ast::deref => const_deref(cx, te),
|
||||||
ast::not => llvm::LLVMConstNot(te),
|
ast::not => {
|
||||||
|
match ty::get(ty).sty {
|
||||||
|
ty::ty_bool => {
|
||||||
|
// Somewhat questionable, but I believe this is
|
||||||
|
// correct.
|
||||||
|
let te = llvm::LLVMConstTrunc(te, T_i1());
|
||||||
|
let te = llvm::LLVMConstNot(te);
|
||||||
|
llvm::LLVMConstZExt(te, T_bool())
|
||||||
|
}
|
||||||
|
_ => llvm::LLVMConstNot(te),
|
||||||
|
}
|
||||||
|
}
|
||||||
ast::neg => {
|
ast::neg => {
|
||||||
if is_float { llvm::LLVMConstFNeg(te) }
|
if is_float { llvm::LLVMConstFNeg(te) }
|
||||||
else { llvm::LLVMConstNeg(te) }
|
else { llvm::LLVMConstNeg(te) }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue