Skip to content

Commit ecb8434

Browse files
committed
---
yaml --- r: 4512 b: refs/heads/master c: 044b16a h: refs/heads/master v: v3
1 parent b603171 commit ecb8434

File tree

2 files changed

+6
-173
lines changed

2 files changed

+6
-173
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: a5997f2eb21abdc083e0faa3adbfc44116e1014f
2+
refs/heads/master: 044b16ad68984a1c99f88ddf6701f4eaefa15bf8

trunk/src/comp/middle/trans.rs

Lines changed: 5 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,10 +1092,7 @@ fn declare_tydesc(cx: &@local_ctxt, sp: &span, t: &ty::t, ty_params: &[uint])
10921092
ret info;
10931093
}
10941094

1095-
tag make_generic_glue_helper_fn {
1096-
mgghf_single(fn(&@block_ctxt, ValueRef, &ty::t) );
1097-
mgghf_cmp;
1098-
}
1095+
type make_generic_glue_helper_fn = fn(&@block_ctxt, ValueRef, &ty::t);
10991096

11001097
fn declare_generic_glue(cx: &@local_ctxt, t: &ty::t, llfnty: TypeRef,
11011098
name: &str) -> ValueRef {
@@ -1147,15 +1144,7 @@ fn make_generic_glue_inner(cx: &@local_ctxt, sp: &span, t: &ty::t,
11471144
let lltop = bcx.llbb;
11481145
let llrawptr0 = llvm::LLVMGetParam(llfn, 4u);
11491146
let llval0 = bcx.build.BitCast(llrawptr0, llty);
1150-
alt helper {
1151-
mgghf_single(single_fn) { single_fn(bcx, llval0, t); }
1152-
mgghf_cmp. {
1153-
let llrawptr1 = llvm::LLVMGetParam(llfn, 5u);
1154-
let llval1 = bcx.build.BitCast(llrawptr1, llty);
1155-
let llcmpval = llvm::LLVMGetParam(llfn, 6u);
1156-
make_cmp_glue(bcx, llval0, llval1, t, llcmpval);
1157-
}
1158-
}
1147+
helper(bcx, llval0, t);
11591148
finish_fn(fcx, lltop);
11601149
ret llfn;
11611150
}
@@ -1532,147 +1521,6 @@ fn maybe_name_value(cx: &@crate_ctxt, v: ValueRef, s: &str) {
15321521
}
15331522
}
15341523

1535-
fn make_cmp_glue(cx: &@block_ctxt, lhs0: ValueRef, rhs0: ValueRef, t: &ty::t,
1536-
llop: ValueRef) {
1537-
let lhs = load_if_immediate(cx, lhs0, t);
1538-
let rhs = load_if_immediate(cx, rhs0, t);
1539-
if ty::type_is_scalar(bcx_tcx(cx), t) {
1540-
make_scalar_cmp_glue(cx, lhs, rhs, t, llop);
1541-
} else if (ty::type_is_box(bcx_tcx(cx), t)) {
1542-
lhs = cx.build.GEP(lhs, ~[C_int(0), C_int(abi::box_rc_field_body)]);
1543-
rhs = cx.build.GEP(rhs, ~[C_int(0), C_int(abi::box_rc_field_body)]);
1544-
let t_inner =
1545-
alt ty::struct(bcx_tcx(cx), t) { ty::ty_box(ti) { ti.ty } };
1546-
let rslt = compare(cx, lhs, rhs, t_inner, llop);
1547-
rslt.bcx.build.Store(rslt.val, cx.fcx.llretptr);
1548-
rslt.bcx.build.RetVoid();
1549-
} else if (ty::type_is_structural(bcx_tcx(cx), t) ||
1550-
ty::type_is_sequence(bcx_tcx(cx), t)) {
1551-
let scx = new_sub_block_ctxt(cx, "structural compare start");
1552-
let next = new_sub_block_ctxt(cx, "structural compare end");
1553-
cx.build.Br(scx.llbb);
1554-
/*
1555-
* We're doing lexicographic comparison here. We start with the
1556-
* assumption that the two input elements are equal. Depending on
1557-
* operator, this means that the result is either true or false;
1558-
* equality produces 'true' for ==, <= and >=. It produces 'false' for
1559-
* !=, < and >.
1560-
*
1561-
* We then move one element at a time through the structure checking
1562-
* for pairwise element equality: If we have equality, our assumption
1563-
* about overall sequence equality is not modified, so we have to move
1564-
* to the next element.
1565-
*
1566-
* If we do not have pairwise element equality, we have reached an
1567-
* element that 'decides' the lexicographic comparison. So we exit the
1568-
* loop with a flag that indicates the true/false sense of that
1569-
* decision, by testing the element again with the operator we're
1570-
* interested in.
1571-
*
1572-
* When we're lucky, LLVM should be able to fold some of these two
1573-
* tests together (as they're applied to the same operands and in some
1574-
* cases are sometimes redundant). But we don't bother trying to
1575-
* optimize combinations like that, at this level.
1576-
*/
1577-
1578-
let flag = alloca(scx, T_i1());
1579-
maybe_name_value(bcx_ccx(cx), flag, "flag");
1580-
let r;
1581-
if ty::type_is_sequence(bcx_tcx(cx), t) {
1582-
// If we hit == all the way through the minimum-shared-length
1583-
// section, default to judging the relative sequence lengths.
1584-
1585-
let lhs_fill;
1586-
let rhs_fill;
1587-
let bcx;
1588-
if ty::sequence_is_interior(bcx_tcx(cx), t) {
1589-
let st = ty::sequence_element_type(bcx_tcx(cx), t);
1590-
let lad = ivec::get_len_and_data(scx, lhs, st);
1591-
bcx = lad.bcx;
1592-
lhs_fill = lad.len;
1593-
lad = ivec::get_len_and_data(bcx, rhs, st);
1594-
bcx = lad.bcx;
1595-
rhs_fill = lad.len;
1596-
} else {
1597-
lhs_fill = vec_fill(scx, lhs);
1598-
rhs_fill = vec_fill(scx, rhs);
1599-
bcx = scx;
1600-
}
1601-
r =
1602-
compare_scalar_values(bcx, lhs_fill, rhs_fill, unsigned_int,
1603-
llop);
1604-
r.bcx.build.Store(r.val, flag);
1605-
} else {
1606-
// == and <= default to true if they find == all the way. <
1607-
// defaults to false if it finds == all the way.
1608-
1609-
let result_if_equal =
1610-
scx.build.ICmp(lib::llvm::LLVMIntNE, llop,
1611-
C_u8(abi::cmp_glue_op_lt));
1612-
scx.build.Store(result_if_equal, flag);
1613-
r = rslt(scx, C_nil());
1614-
}
1615-
fn inner(last_cx: @block_ctxt, load_inner: bool, flag: ValueRef,
1616-
llop: ValueRef, cx: &@block_ctxt, av0: ValueRef,
1617-
bv0: ValueRef, t: ty::t) -> result {
1618-
let cnt_cx = new_sub_block_ctxt(cx, "continue_comparison");
1619-
let stop_cx = new_sub_block_ctxt(cx, "stop_comparison");
1620-
let av = av0;
1621-
let bv = bv0;
1622-
if load_inner {
1623-
// If `load_inner` is true, then the pointer type will always
1624-
// be i8, because the data part of a vector always has type
1625-
// [i8]. So we need to cast it to the proper type.
1626-
1627-
if !ty::type_has_dynamic_size(bcx_tcx(last_cx), t) {
1628-
let llelemty =
1629-
T_ptr(type_of(bcx_ccx(last_cx), last_cx.sp, t));
1630-
av = cx.build.PointerCast(av, llelemty);
1631-
bv = cx.build.PointerCast(bv, llelemty);
1632-
}
1633-
av = load_if_immediate(cx, av, t);
1634-
bv = load_if_immediate(cx, bv, t);
1635-
}
1636-
1637-
// First 'eq' comparison: if so, continue to next elts.
1638-
let eq_r = compare(cx, av, bv, t, C_u8(abi::cmp_glue_op_eq));
1639-
eq_r.bcx.build.CondBr(eq_r.val, cnt_cx.llbb, stop_cx.llbb);
1640-
1641-
// Second 'op' comparison: find out how this elt-pair decides.
1642-
let stop_r = compare(stop_cx, av, bv, t, llop);
1643-
stop_r.bcx.build.Store(stop_r.val, flag);
1644-
stop_r.bcx.build.Br(last_cx.llbb);
1645-
ret rslt(cnt_cx, C_nil());
1646-
}
1647-
if ty::type_is_structural(bcx_tcx(cx), t) {
1648-
r = iter_structural_ty_full(r.bcx, lhs, rhs, t,
1649-
bind inner(next, false, flag, llop, _,
1650-
_, _, _));
1651-
} else {
1652-
let lhs_p0 = vec_p0(r.bcx, lhs);
1653-
let rhs_p0 = vec_p0(r.bcx, rhs);
1654-
let min_len =
1655-
umin(r.bcx, vec_fill(r.bcx, lhs), vec_fill(r.bcx, rhs));
1656-
let rhs_lim = r.bcx.build.GEP(rhs_p0, ~[min_len]);
1657-
let elt_ty = ty::sequence_element_type(bcx_tcx(cx), t);
1658-
r = size_of(r.bcx, elt_ty);
1659-
r = iter_sequence_raw(r.bcx, lhs_p0, rhs_p0, rhs_lim, r.val,
1660-
bind inner(next, true, flag, llop, _, _, _,
1661-
elt_ty));
1662-
}
1663-
r.bcx.build.Br(next.llbb);
1664-
let v = next.build.Load(flag);
1665-
next.build.Store(v, cx.fcx.llretptr);
1666-
next.build.RetVoid();
1667-
} else {
1668-
// FIXME: compare obj, fn by pointer?
1669-
1670-
trans_fail(cx, none[span],
1671-
"attempt to compare values of type " +
1672-
ty_to_str(bcx_tcx(cx), t));
1673-
}
1674-
}
1675-
16761524

16771525
// Used only for creating scalar comparison glue.
16781526
tag scalar_type { nil_type; signed_int; unsigned_int; floating_point; }
@@ -1721,21 +1569,6 @@ fn compare_scalar_types(cx: @block_ctxt, lhs: ValueRef, rhs: ValueRef,
17211569
}
17221570
}
17231571

1724-
// A helper function to create scalar comparison glue.
1725-
fn make_scalar_cmp_glue(cx: &@block_ctxt, lhs: ValueRef, rhs: ValueRef,
1726-
t: &ty::t, llop: ValueRef) {
1727-
assert (ty::type_is_scalar(bcx_tcx(cx), t));
1728-
1729-
// In most cases, we need to know whether to do signed, unsigned, or float
1730-
// comparison.
1731-
1732-
let rslt = compare_scalar_types(cx, lhs, rhs, t, llop);
1733-
let bcx = rslt.bcx;
1734-
let compare_result = rslt.val;
1735-
bcx.build.Store(compare_result, cx.fcx.llretptr);
1736-
bcx.build.RetVoid();
1737-
}
1738-
17391572

17401573
// A helper function to do the actual comparison of scalar values.
17411574
fn compare_scalar_values(cx: &@block_ctxt, lhs: ValueRef, rhs: ValueRef,
@@ -2192,7 +2025,7 @@ fn lazily_emit_tydesc_glue(cx: &@block_ctxt, field: int,
21922025
"copy");
21932026
ti.copy_glue = some[ValueRef](glue_fn);
21942027
make_generic_glue(lcx, cx.sp, ti.ty, glue_fn,
2195-
mgghf_single(make_copy_glue), ti.ty_params,
2028+
make_copy_glue, ti.ty_params,
21962029
"take");
21972030
log #fmt("--- lazily_emit_tydesc_glue TAKE %s",
21982031
ty_to_str(bcx_tcx(cx), ti.ty));
@@ -2210,7 +2043,7 @@ fn lazily_emit_tydesc_glue(cx: &@block_ctxt, field: int,
22102043
"drop");
22112044
ti.drop_glue = some[ValueRef](glue_fn);
22122045
make_generic_glue(lcx, cx.sp, ti.ty, glue_fn,
2213-
mgghf_single(make_drop_glue), ti.ty_params,
2046+
make_drop_glue, ti.ty_params,
22142047
"drop");
22152048
log #fmt("--- lazily_emit_tydesc_glue DROP %s",
22162049
ty_to_str(bcx_tcx(cx), ti.ty));
@@ -2228,7 +2061,7 @@ fn lazily_emit_tydesc_glue(cx: &@block_ctxt, field: int,
22282061
"free");
22292062
ti.free_glue = some[ValueRef](glue_fn);
22302063
make_generic_glue(lcx, cx.sp, ti.ty, glue_fn,
2231-
mgghf_single(make_free_glue), ti.ty_params,
2064+
make_free_glue, ti.ty_params,
22322065
"free");
22332066
log #fmt("--- lazily_emit_tydesc_glue FREE %s",
22342067
ty_to_str(bcx_tcx(cx), ti.ty));

0 commit comments

Comments
 (0)