Skip to content

Commit bea6fe0

Browse files
committed
rustc: Trim down and rename trans_compare. Now only eq shape glue remains.
1 parent 10aa849 commit bea6fe0

File tree

1 file changed

+9
-26
lines changed

1 file changed

+9
-26
lines changed

src/rustc/middle/trans/alt.rs

+9-26
Original file line numberDiff line numberDiff line change
@@ -428,32 +428,18 @@ impl branch_kind : cmp::Eq {
428428
}
429429

430430
// Compiles a comparison between two things.
431-
fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef,
432-
_lhs_t: ty::t, rhs: ValueRef, rhs_t: ty::t) -> Result {
433-
let _icx = cx.insn_ctxt("trans_compare");
431+
fn compare_values(cx: block, lhs: ValueRef, rhs: ValueRef, rhs_t: ty::t) ->
432+
Result {
433+
let _icx = cx.insn_ctxt("compare_values");
434434
if ty::type_is_scalar(rhs_t) {
435-
let rs = compare_scalar_types(cx, lhs, rhs, rhs_t, op);
435+
let rs = compare_scalar_types(cx, lhs, rhs, rhs_t, ast::eq);
436436
return rslt(rs.bcx, rs.val);
437437
}
438438

439439
// Determine the operation we need.
440-
let llop = {
441-
match op {
442-
ast::eq | ast::ne => C_u8(abi::cmp_glue_op_eq),
443-
ast::lt | ast::ge => C_u8(abi::cmp_glue_op_lt),
444-
ast::le | ast::gt => C_u8(abi::cmp_glue_op_le),
445-
_ => cx.tcx().sess.bug(~"trans_compare got non-comparison-op")
446-
}
447-
};
448-
440+
let llop = C_u8(abi::cmp_glue_op_eq);
449441
let cmpval = glue::call_cmp_glue(cx, lhs, rhs, rhs_t, llop);
450-
451-
// Invert the result if necessary.
452-
match op {
453-
ast::eq | ast::lt | ast::le => rslt(cx, cmpval),
454-
ast::ne | ast::ge | ast::gt => rslt(cx, Not(cx, cmpval)),
455-
_ => cx.tcx().sess.bug(~"trans_compare got non-comparison-op")
456-
}
442+
rslt(cx, cmpval)
457443
}
458444

459445
fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
@@ -663,15 +649,12 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
663649
do with_scope_result(bcx, None, ~"compare_scope") |bcx| {
664650
match trans_opt(bcx, opt) {
665651
single_result(
666-
Result {bcx, val}) =>
667-
{
668-
trans_compare(bcx, ast::eq, test_val,
669-
t, val, t)
652+
Result {bcx, val}) => {
653+
compare_values(bcx, test_val, val, t)
670654
}
671655
range_result(
672656
Result {val: vbegin, _},
673-
Result {bcx, val: vend}) =>
674-
{
657+
Result {bcx, val: vend}) => {
675658
let Result {bcx, val: llge} =
676659
compare_scalar_types(bcx, test_val,
677660
vbegin, t, ast::ge);

0 commit comments

Comments
 (0)