rustc: Put uniques into addrspace 1

This commit is contained in:
Brian Anderson 2012-06-04 22:56:40 -07:00
parent 1a3b8fc43c
commit d3c641678e
6 changed files with 23 additions and 8 deletions

View File

@ -472,7 +472,9 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef],
if any_uniq_pat(m, col) {
let box = Load(bcx, val);
let unboxed = GEPi(bcx, box, [0u, abi::box_field_body]);
let box_ty = node_id_type(bcx, pat_id);
let box_no_addrspace = non_gc_box_cast(bcx, box, box_ty);
let unboxed = GEPi(bcx, box_no_addrspace, [0u, abi::box_field_body]);
compile_submatch(bcx, enter_uniq(dm, m, col, val),
[unboxed] + vals_left, chk, exits);
ret;

View File

@ -397,7 +397,8 @@ fn malloc_unique_raw(bcx: block, t: ty::t) -> ValueRef {
fn malloc_unique(bcx: block, t: ty::t) -> {box: ValueRef, body: ValueRef} {
let _icx = bcx.insn_ctxt("malloc_unique_box");
let box = malloc_unique_raw(bcx, t);
let body = GEPi(bcx, box, [0u, abi::box_field_body]);
let non_gc_box = non_gc_box_cast(bcx, box, ty::mk_imm_uniq(bcx.tcx(), t));
let body = GEPi(bcx, non_gc_box, [0u, abi::box_field_body]);
ret {box: box, body: body};
}
@ -2681,7 +2682,8 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result {
GEPi(sub.bcx, non_gc_val, [0u, abi::box_field_body])
}
ty::ty_uniq(_) {
GEPi(sub.bcx, sub.val, [0u, abi::box_field_body])
let non_gc_val = non_gc_box_cast(sub.bcx, sub.val, t);
GEPi(sub.bcx, non_gc_val, [0u, abi::box_field_body])
}
ty::ty_res(_, _, _) {
GEPi(sub.bcx, sub.val, [0u, 1u])

View File

@ -691,7 +691,7 @@ fn T_unique(cx: @crate_ctxt, t: TypeRef) -> TypeRef {
}
fn T_unique_ptr(t: TypeRef) -> TypeRef {
const unique_addrspace: uint = 0u;
const unique_addrspace: uint = 1u;
ret llvm::LLVMPointerType(t, unique_addrspace as c_uint);
}

View File

@ -54,6 +54,9 @@ fn type_of_non_gc_box(cx: @crate_ctxt, t: ty::t) -> TypeRef {
ty::ty_box(mt) {
T_ptr(T_box(cx, type_of(cx, mt.ty)))
}
ty::ty_uniq(mt) {
T_ptr(T_unique(cx, type_of(cx, mt.ty)))
}
_ {
cx.sess.bug("non-box in type_of_non_gc_box");
}

View File

@ -0,0 +1,8 @@
fn main() {
alt ~100 {
~x {
#debug("%?", x);
assert x == 100;
}
}
}

View File

@ -3,17 +3,17 @@ fn main() {
let x = ~t1(10);
alt *x {
/*alt *x {
t1(a) {
assert a == 10;
}
_ { fail; }
}
}*/
alt x {
/*alt x {
~t1(a) {
assert a == 10;
}
_ { fail; }
}
}*/
}