Skip to content

Commit 00daeb4

Browse files
committed
Move type_is_immediate into ty.rs
1 parent a35dbf3 commit 00daeb4

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

src/comp/middle/trans.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3724,7 +3724,7 @@ fn trans_arg_expr(cx: @block_ctxt, arg: ty::arg, lldestty0: TypeRef,
37243724
// to have type lldestty0 (the callee's expected type).
37253725
val = llvm::LLVMGetUndef(lldestty0);
37263726
} else if arg.mode == ast::by_ref || arg.mode == ast::by_val {
3727-
let copied = false, imm = type_is_immediate(ccx, e_ty);
3727+
let copied = false, imm = ty::type_is_immediate(ccx.tcx, e_ty);
37283728
if arg.mode == ast::by_ref && lv.kind != owned && imm {
37293729
val = do_spill_noroot(bcx, val);
37303730
copied = true;
@@ -3741,7 +3741,7 @@ fn trans_arg_expr(cx: @block_ctxt, arg: ty::arg, lldestty0: TypeRef,
37413741
if arg.mode == ast::by_val && (lv.kind == owned || !imm) {
37423742
val = Load(bcx, val);
37433743
}
3744-
} else if type_is_immediate(ccx, e_ty) && lv.kind != owned {
3744+
} else if ty::type_is_immediate(ccx.tcx, e_ty) && lv.kind != owned {
37453745
let r = do_spill(bcx, val, e_ty);
37463746
val = r.val;
37473747
bcx = r.bcx;
@@ -4243,7 +4243,7 @@ fn trans_temp_lval(bcx: @block_ctxt, e: @ast::expr) -> lval_result {
42434243
if ty::type_is_nil(tcx, ty) || ty::type_is_bot(tcx, ty) {
42444244
bcx = trans_expr(bcx, e, ignore);
42454245
ret {bcx: bcx, val: C_nil(), kind: temporary};
4246-
} else if type_is_immediate(bcx_ccx(bcx), ty) {
4246+
} else if ty::type_is_immediate(bcx_tcx(bcx), ty) {
42474247
let cell = empty_dest_cell();
42484248
bcx = trans_expr(bcx, e, by_val(cell));
42494249
add_clean_temp(bcx, *cell, ty);
@@ -4467,16 +4467,6 @@ fn lval_to_dps(bcx: @block_ctxt, e: @ast::expr, dest: dest) -> @block_ctxt {
44674467
ret bcx;
44684468
}
44694469

4470-
// We pass structural values around the compiler "by pointer" and
4471-
// non-structural values (scalars, boxes, pointers) "by value". We call the
4472-
// latter group "immediates" and, in some circumstances when we know we have a
4473-
// pointer (or need one), perform load/store operations based on the
4474-
// immediate-ness of the type.
4475-
// FIXME simply call the version in ty.rs immediately
4476-
fn type_is_immediate(ccx: @crate_ctxt, t: ty::t) -> bool {
4477-
ty::type_is_immediate(ccx.tcx, t)
4478-
}
4479-
44804470
fn do_spill(cx: @block_ctxt, v: ValueRef, t: ty::t) -> result {
44814471
// We have a value but we have to spill it, and root it, to pass by alias.
44824472
let bcx = cx;
@@ -4503,12 +4493,12 @@ fn do_spill_noroot(cx: @block_ctxt, v: ValueRef) -> ValueRef {
45034493
}
45044494

45054495
fn spill_if_immediate(cx: @block_ctxt, v: ValueRef, t: ty::t) -> result {
4506-
if type_is_immediate(bcx_ccx(cx), t) { ret do_spill(cx, v, t); }
4496+
if ty::type_is_immediate(bcx_tcx(cx), t) { ret do_spill(cx, v, t); }
45074497
ret rslt(cx, v);
45084498
}
45094499

45104500
fn load_if_immediate(cx: @block_ctxt, v: ValueRef, t: ty::t) -> ValueRef {
4511-
if type_is_immediate(bcx_ccx(cx), t) { ret Load(cx, v); }
4501+
if ty::type_is_immediate(bcx_tcx(cx), t) { ret Load(cx, v); }
45124502
ret v;
45134503
}
45144504

@@ -5343,7 +5333,7 @@ fn trans_closure(cx: @local_ctxt, sp: span, f: ast::_fn, llfndecl: ValueRef,
53435333
f.proto == ast::proto_iter ||
53445334
option::is_none(f.body.node.expr) {
53455335
bcx = trans_block_dps(bcx, f.body, ignore);
5346-
} else if type_is_immediate(cx.ccx, block_ty) {
5336+
} else if ty::type_is_immediate(cx.ccx.tcx, block_ty) {
53475337
let cell = empty_dest_cell();
53485338
bcx = trans_block_dps(bcx, f.body, by_val(cell));
53495339
Store(bcx, *cell, fcx.llretptr);

0 commit comments

Comments
 (0)