rustc: Make range literals use compare_scalar_types instead of trans_compare

This commit is contained in:
Patrick Walton 2012-09-10 15:26:15 -07:00
parent 5eccf84919
commit 7e9f98a8c9
2 changed files with 6 additions and 32 deletions

View File

@ -672,10 +672,12 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
Result {val: vbegin, _},
Result {bcx, val: vend}) =>
{
let Result {bcx, val: llge} = trans_compare(
bcx, ast::ge, test_val, t, vbegin, t);
let Result {bcx, val: llle} = trans_compare(
bcx, ast::le, test_val, t, vend, t);
let Result {bcx, val: llge} =
compare_scalar_types(bcx, test_val,
vbegin, t, ast::ge);
let Result {bcx, val: llle} =
compare_scalar_types(bcx, test_val, vend,
t, ast::le);
rslt(bcx, And(bcx, llge, llle))
}
}

View File

@ -610,34 +610,6 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
return cx;
}
fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef,
_lhs_t: ty::t, rhs: ValueRef, rhs_t: ty::t) -> Result {
let _icx = cx.insn_ctxt("trans_compare");
if ty::type_is_scalar(rhs_t) {
let rs = compare_scalar_types(cx, lhs, rhs, rhs_t, op);
return rslt(rs.bcx, rs.val);
}
// Determine the operation we need.
let llop = {
match op {
ast::eq | ast::ne => C_u8(abi::cmp_glue_op_eq),
ast::lt | ast::ge => C_u8(abi::cmp_glue_op_lt),
ast::le | ast::gt => C_u8(abi::cmp_glue_op_le),
_ => cx.tcx().sess.bug(~"trans_compare got non-comparison-op")
}
};
let cmpval = glue::call_cmp_glue(cx, lhs, rhs, rhs_t, llop);
// Invert the result if necessary.
match op {
ast::eq | ast::lt | ast::le => rslt(cx, cmpval),
ast::ne | ast::ge | ast::gt => rslt(cx, Not(cx, cmpval)),
_ => cx.tcx().sess.bug(~"trans_compare got non-comparison-op")
}
}
fn cast_shift_expr_rhs(cx: block, op: ast::binop,
lhs: ValueRef, rhs: ValueRef) -> ValueRef {
cast_shift_rhs(op, lhs, rhs,