Skip to content

Commit

Permalink
Remove remainders from when booleans were i8
Browse files Browse the repository at this point in the history
  • Loading branch information
dotdash committed Jul 6, 2014
1 parent b8ef5cf commit d2a22f5
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/adt.rs
Expand Up @@ -618,7 +618,7 @@ pub fn trans_case<'a>(bcx: &'a Block<'a>, r: &Repr, discr: Disr)
RawNullablePointer { .. } |
StructWrappedNullablePointer { .. } => {
assert!(discr == 0 || discr == 1);
_match::single_result(Result::new(bcx, C_i1(bcx.ccx(), discr != 0)))
_match::single_result(Result::new(bcx, C_bool(bcx.ccx(), discr != 0)))
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/middle/trans/base.rs
Expand Up @@ -539,8 +539,8 @@ pub fn compare_scalar_values<'a>(
// We don't need to do actual comparisons for nil.
// () == () holds but () < () does not.
match op {
ast::BiEq | ast::BiLe | ast::BiGe => return C_i1(cx.ccx(), true),
ast::BiNe | ast::BiLt | ast::BiGt => return C_i1(cx.ccx(), false),
ast::BiEq | ast::BiLe | ast::BiGe => return C_bool(cx.ccx(), true),
ast::BiNe | ast::BiLt | ast::BiGt => return C_bool(cx.ccx(), false),
// refinements would be nice
_ => die(cx)
}
Expand Down Expand Up @@ -1014,7 +1014,7 @@ pub fn call_memcpy(cx: &Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef,
let dst_ptr = PointerCast(cx, dst, Type::i8p(ccx));
let size = IntCast(cx, n_bytes, ccx.int_type);
let align = C_i32(ccx, align as i32);
let volatile = C_i1(ccx, false);
let volatile = C_bool(ccx, false);
Call(cx, memcpy, [dst_ptr, src_ptr, size, align, volatile], []);
}

Expand Down Expand Up @@ -1059,7 +1059,7 @@ fn memzero(b: &Builder, llptr: ValueRef, ty: Type) {
let llzeroval = C_u8(ccx, 0);
let size = machine::llsize_of(ccx, ty);
let align = C_i32(ccx, llalign_of_min(ccx, ty) as i32);
let volatile = C_i1(ccx, false);
let volatile = C_bool(ccx, false);
b.call(llintrinsicfn, [llptr, llzeroval, size, align, volatile], []);
}

Expand Down
4 changes: 0 additions & 4 deletions src/librustc/middle/trans/common.rs
Expand Up @@ -526,10 +526,6 @@ pub fn C_nil(ccx: &CrateContext) -> ValueRef {
}

pub fn C_bool(ccx: &CrateContext, val: bool) -> ValueRef {
C_integral(Type::bool(ccx), val as u64, false)
}

pub fn C_i1(ccx: &CrateContext, val: bool) -> ValueRef {
C_integral(Type::i1(ccx), val as u64, false)
}

Expand Down
10 changes: 2 additions & 8 deletions src/librustc/middle/trans/expr.rs
Expand Up @@ -505,7 +505,7 @@ fn trans_index<'a>(bcx: &'a Block<'a>,

let bounds_check = ICmp(bcx, lib::llvm::IntUGE, ix_val, len);
let expect = ccx.get_intrinsic(&("llvm.expect.i1"));
let expected = Call(bcx, expect, [bounds_check, C_i1(ccx, false)], []);
let expected = Call(bcx, expect, [bounds_check, C_bool(ccx, false)], []);
let bcx = with_cond(bcx, expected, |bcx| {
controlflow::trans_fail_bounds_check(bcx, index_expr.span, ix_val, len)
});
Expand Down Expand Up @@ -1149,13 +1149,7 @@ fn trans_unary<'a>(bcx: &'a Block<'a>,
match op {
ast::UnNot => {
let datum = unpack_datum!(bcx, trans(bcx, sub_expr));
let llresult = if ty::type_is_bool(un_ty) {
let val = datum.to_llscalarish(bcx);
Xor(bcx, val, C_bool(ccx, true))
} else {
// Note: `Not` is bitwise, not suitable for logical not.
Not(bcx, datum.to_llscalarish(bcx))
};
let llresult = Not(bcx, datum.to_llscalarish(bcx));
immediate_rvalue_bcx(bcx, llresult, un_ty).to_expr_datumblock()
}
ast::UnNeg => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/glue.rs
Expand Up @@ -234,7 +234,7 @@ fn trans_struct_drop_flag<'a>(bcx: &'a Block<'a>,
-> &'a Block<'a> {
let repr = adt::represent_type(bcx.ccx(), t);
let drop_flag = adt::trans_drop_flag_ptr(bcx, &*repr, v0);
with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag)), |cx| {
with_cond(bcx, Load(bcx, drop_flag), |cx| {
trans_struct_drop(cx, t, v0, dtor_did, class_did, substs)
})
}
Expand Down
7 changes: 4 additions & 3 deletions src/librustc/middle/trans/intrinsic.rs
Expand Up @@ -150,7 +150,8 @@ pub fn trans_intrinsic(ccx: &CrateContext,
let src_ptr = PointerCast(bcx, get_param(decl, first_real_arg + 1), Type::i8p(ccx));
let count = get_param(decl, first_real_arg + 2);
let llfn = ccx.get_intrinsic(&name);
Call(bcx, llfn, [dst_ptr, src_ptr, Mul(bcx, size, count), align, C_i1(ccx, volatile)], []);
Call(bcx, llfn,
[dst_ptr, src_ptr, Mul(bcx, size, count), align, C_bool(ccx, volatile)], []);
RetVoid(bcx);
}

Expand All @@ -171,13 +172,13 @@ pub fn trans_intrinsic(ccx: &CrateContext,
let val = get_param(decl, first_real_arg + 1);
let count = get_param(decl, first_real_arg + 2);
let llfn = ccx.get_intrinsic(&name);
Call(bcx, llfn, [dst_ptr, val, Mul(bcx, size, count), align, C_i1(ccx, volatile)], []);
Call(bcx, llfn, [dst_ptr, val, Mul(bcx, size, count), align, C_bool(ccx, volatile)], []);
RetVoid(bcx);
}

fn count_zeros_intrinsic(bcx: &Block, name: &'static str) {
let x = get_param(bcx.fcx.llfn, bcx.fcx.arg_pos(0u));
let y = C_i1(bcx.ccx(), false);
let y = C_bool(bcx.ccx(), false);
let llfn = bcx.ccx().get_intrinsic(&name);
let llcall = Call(bcx, llfn, [x, y], []);
Ret(bcx, llcall);
Expand Down

0 comments on commit d2a22f5

Please sign in to comment.