mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
rustc: Trim down and rename trans_compare. Now only eq shape glue remains.
This commit is contained in:
parent
10aa849d28
commit
bea6fe0ec1
@ -428,32 +428,18 @@ impl branch_kind : cmp::Eq {
|
||||
}
|
||||
|
||||
// Compiles a comparison between two things.
|
||||
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");
|
||||
fn compare_values(cx: block, lhs: ValueRef, rhs: ValueRef, rhs_t: ty::t) ->
|
||||
Result {
|
||||
let _icx = cx.insn_ctxt("compare_values");
|
||||
if ty::type_is_scalar(rhs_t) {
|
||||
let rs = compare_scalar_types(cx, lhs, rhs, rhs_t, op);
|
||||
let rs = compare_scalar_types(cx, lhs, rhs, rhs_t, ast::eq);
|
||||
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 llop = C_u8(abi::cmp_glue_op_eq);
|
||||
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")
|
||||
}
|
||||
rslt(cx, cmpval)
|
||||
}
|
||||
|
||||
fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
|
||||
@ -663,15 +649,12 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
|
||||
do with_scope_result(bcx, None, ~"compare_scope") |bcx| {
|
||||
match trans_opt(bcx, opt) {
|
||||
single_result(
|
||||
Result {bcx, val}) =>
|
||||
{
|
||||
trans_compare(bcx, ast::eq, test_val,
|
||||
t, val, t)
|
||||
Result {bcx, val}) => {
|
||||
compare_values(bcx, test_val, val, t)
|
||||
}
|
||||
range_result(
|
||||
Result {val: vbegin, _},
|
||||
Result {bcx, val: vend}) =>
|
||||
{
|
||||
Result {bcx, val: vend}) => {
|
||||
let Result {bcx, val: llge} =
|
||||
compare_scalar_types(bcx, test_val,
|
||||
vbegin, t, ast::ge);
|
||||
|
Loading…
Reference in New Issue
Block a user