Rename ivecs to vecs in the compiler
This commit is contained in:
parent
a0e2809f54
commit
785c26f7f4
src/comp
@ -36,16 +36,6 @@ const box_rc_field_body: int = 1;
|
||||
|
||||
const general_code_alignment: int = 16;
|
||||
|
||||
const vec_elt_rc: int = 0;
|
||||
|
||||
const vec_elt_alloc: int = 1;
|
||||
|
||||
const vec_elt_fill: int = 2;
|
||||
|
||||
const vec_elt_pad: int = 3;
|
||||
|
||||
const vec_elt_data: int = 4;
|
||||
|
||||
const tydesc_field_first_param: int = 0;
|
||||
const tydesc_field_size: int = 1;
|
||||
const tydesc_field_align: int = 2;
|
||||
@ -92,11 +82,11 @@ const closure_elt_bindings: int = 1;
|
||||
|
||||
const closure_elt_ty_params: int = 2;
|
||||
|
||||
const ivec_elt_fill: uint = 0u;
|
||||
const vec_elt_fill: uint = 0u;
|
||||
|
||||
const ivec_elt_alloc: uint = 1u;
|
||||
const vec_elt_alloc: uint = 1u;
|
||||
|
||||
const ivec_elt_elems: uint = 2u;
|
||||
const vec_elt_elems: uint = 2u;
|
||||
|
||||
const worst_case_glue_call_args: int = 7;
|
||||
|
||||
|
@ -10,10 +10,10 @@ import middle::trans_common::T_i1;
|
||||
import middle::trans_common::T_i8;
|
||||
import middle::trans_common::T_i32;
|
||||
import middle::trans_common::T_int;
|
||||
import middle::trans_common::T_ivec;
|
||||
import middle::trans_common::T_vec;
|
||||
import middle::trans_common::T_nil;
|
||||
import middle::trans_common::T_opaque_chan_ptr;
|
||||
import middle::trans_common::T_opaque_ivec;
|
||||
import middle::trans_common::T_opaque_vec;
|
||||
import middle::trans_common::T_opaque_port_ptr;
|
||||
import middle::trans_common::T_ptr;
|
||||
import middle::trans_common::T_size_t;
|
||||
@ -36,8 +36,8 @@ type upcalls =
|
||||
shared_free: ValueRef,
|
||||
mark: ValueRef,
|
||||
get_type_desc: ValueRef,
|
||||
ivec_grow: ValueRef,
|
||||
ivec_push: ValueRef,
|
||||
vec_grow: ValueRef,
|
||||
vec_push: ValueRef,
|
||||
cmp_type: ValueRef,
|
||||
log_type: ValueRef,
|
||||
dynastack_mark: ValueRef,
|
||||
@ -82,12 +82,12 @@ fn declare_upcalls(_tn: type_names, tydesc_type: TypeRef,
|
||||
d(~"get_type_desc",
|
||||
[T_ptr(T_nil()), T_size_t(), T_size_t(), T_size_t(),
|
||||
T_ptr(T_ptr(tydesc_type)), T_int()], T_ptr(tydesc_type)),
|
||||
ivec_grow:
|
||||
d(~"vec_grow", [T_ptr(T_ptr(T_opaque_ivec())), T_int()],
|
||||
vec_grow:
|
||||
d(~"vec_grow", [T_ptr(T_ptr(T_opaque_vec())), T_int()],
|
||||
T_void()),
|
||||
ivec_push:
|
||||
vec_push:
|
||||
d(~"vec_push",
|
||||
[T_ptr(T_ptr(T_opaque_ivec())), T_ptr(tydesc_type),
|
||||
[T_ptr(T_ptr(T_opaque_vec())), T_ptr(tydesc_type),
|
||||
T_ptr(T_i8())], T_void()),
|
||||
cmp_type:
|
||||
dr(~"cmp_type",
|
||||
|
@ -56,7 +56,7 @@ const shape_i64: u8 = 7u8;
|
||||
const shape_f32: u8 = 8u8;
|
||||
const shape_f64: u8 = 9u8;
|
||||
// (10 is currently unused, was evec)
|
||||
const shape_ivec: u8 = 11u8;
|
||||
const shape_vec: u8 = 11u8;
|
||||
const shape_tag: u8 = 12u8;
|
||||
const shape_box: u8 = 13u8;
|
||||
const shape_struct: u8 = 17u8;
|
||||
@ -306,7 +306,7 @@ fn shape_of(ccx: &@crate_ctxt, t: ty::t) -> [u8] {
|
||||
|
||||
|
||||
ty::ty_istr. {
|
||||
s += [shape_ivec];
|
||||
s += [shape_vec];
|
||||
add_bool(s, true); // type is POD
|
||||
let unit_ty = ty::mk_mach(ccx.tcx, ast::ty_u8);
|
||||
add_substr(s, shape_of(ccx, unit_ty));
|
||||
@ -358,7 +358,7 @@ fn shape_of(ccx: &@crate_ctxt, t: ty::t) -> [u8] {
|
||||
add_substr(s, shape_of(ccx, subt));
|
||||
}
|
||||
ty::ty_vec(mt) {
|
||||
s += [shape_ivec];
|
||||
s += [shape_vec];
|
||||
add_bool(s, ty::type_is_pod(ccx.tcx, mt.ty));
|
||||
add_substr(s, shape_of(ccx, mt.ty));
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ import trans_build::*;
|
||||
|
||||
import trans_objects::trans_anon_obj;
|
||||
import trans_objects::trans_obj;
|
||||
import ivec = trans_ivec;
|
||||
import tvec = trans_vec;
|
||||
|
||||
// This function now fails if called on a type with dynamic size (as its
|
||||
// return value was always meaningless in that case anyhow). Beware!
|
||||
@ -202,14 +202,14 @@ fn type_of_inner(cx: &@crate_ctxt, sp: &span, t: ty::t) -> TypeRef {
|
||||
}
|
||||
}
|
||||
ty::ty_char. { llty = T_char(); }
|
||||
ty::ty_istr. { llty = T_ptr(T_ivec(T_i8())); }
|
||||
ty::ty_istr. { llty = T_ptr(T_vec(T_i8())); }
|
||||
ty::ty_tag(did, _) { llty = type_of_tag(cx, sp, did, t); }
|
||||
ty::ty_box(mt) { llty = T_ptr(T_box(type_of_inner(cx, sp, mt.ty))); }
|
||||
ty::ty_uniq(t) { llty = T_ptr(type_of_inner(cx, sp, t)); }
|
||||
ty::ty_vec(mt) {
|
||||
if ty::type_has_dynamic_size(cx.tcx, mt.ty) {
|
||||
llty = T_ptr(T_opaque_ivec());
|
||||
} else { llty = T_ptr(T_ivec(type_of_inner(cx, sp, mt.ty))); }
|
||||
llty = T_ptr(T_opaque_vec());
|
||||
} else { llty = T_ptr(T_vec(type_of_inner(cx, sp, mt.ty))); }
|
||||
}
|
||||
ty::ty_ptr(mt) { llty = T_ptr(type_of_inner(cx, sp, mt.ty)); }
|
||||
ty::ty_rec(fields) {
|
||||
@ -1306,9 +1306,9 @@ fn make_take_glue(cx: &@block_ctxt, v: ValueRef, t: ty::t) {
|
||||
bcx = incr_refcnt_of_boxed(bcx, Load(bcx, v));
|
||||
} else if ty::type_is_structural(bcx_tcx(bcx), t) {
|
||||
bcx = iter_structural_ty(bcx, v, t, take_ty);
|
||||
} else if ty::type_is_ivec(bcx_tcx(bcx), t) {
|
||||
bcx = ivec::duplicate(bcx, v);
|
||||
bcx = ivec::iter_ivec(bcx, v, t, take_ty);
|
||||
} else if ty::type_is_vec(bcx_tcx(bcx), t) {
|
||||
bcx = tvec::duplicate(bcx, v);
|
||||
bcx = tvec::iter_vec(bcx, v, t, take_ty);
|
||||
}
|
||||
|
||||
build_return(bcx);
|
||||
@ -1390,8 +1390,8 @@ fn make_drop_glue(bcx: &@block_ctxt, v0: ValueRef, t: ty::t) {
|
||||
// NB: v0 is an *alias* of type t here, not a direct value.
|
||||
let ccx = bcx_ccx(bcx);
|
||||
let bcx = alt ty::struct(ccx.tcx, t) {
|
||||
ty::ty_vec(_) { ivec::make_drop_glue(bcx, v0, t) }
|
||||
ty::ty_istr. { ivec::make_drop_glue(bcx, v0, t) }
|
||||
ty::ty_vec(_) { tvec::make_drop_glue(bcx, v0, t) }
|
||||
ty::ty_istr. { tvec::make_drop_glue(bcx, v0, t) }
|
||||
ty::ty_box(_) { decr_refcnt_maybe_free(bcx, v0, v0, t) }
|
||||
ty::ty_uniq(_) { trans_shared_free(bcx, Load(bcx, v0)) }
|
||||
ty::ty_obj(_) {
|
||||
@ -1809,19 +1809,11 @@ fn iter_sequence_inner(cx: &@block_ctxt, src: ValueRef,
|
||||
fn iter_sequence(cx: @block_ctxt, v: ValueRef, t: ty::t, f: &val_and_ty_fn)
|
||||
-> @block_ctxt {
|
||||
fn iter_sequence_body(bcx: @block_ctxt, v: ValueRef, elt_ty: ty::t,
|
||||
f: &val_and_ty_fn, trailing_null: bool,
|
||||
interior: bool) -> @block_ctxt {
|
||||
let p0;
|
||||
let len;
|
||||
f: &val_and_ty_fn, trailing_null: bool)
|
||||
-> @block_ctxt {
|
||||
let llunit_ty = type_of_or_i8(bcx, elt_ty);
|
||||
if !interior {
|
||||
p0 = GEP(bcx, v, [C_int(0), C_int(abi::vec_elt_data)]);
|
||||
let lp = GEP(bcx, v, [C_int(0), C_int(abi::vec_elt_fill)]);
|
||||
len = Load(bcx, lp);
|
||||
} else {
|
||||
len = ivec::get_fill(bcx, v);
|
||||
p0 = ivec::get_dataptr(bcx, v, llunit_ty);
|
||||
}
|
||||
let p0 = tvec::get_dataptr(bcx, v, llunit_ty);
|
||||
let len = tvec::get_fill(bcx, v);
|
||||
|
||||
if trailing_null {
|
||||
let unit_sz = size_of(bcx, elt_ty);
|
||||
@ -1836,11 +1828,11 @@ fn iter_sequence(cx: @block_ctxt, v: ValueRef, t: ty::t, f: &val_and_ty_fn)
|
||||
|
||||
alt ty::struct(bcx_tcx(cx), t) {
|
||||
ty::ty_vec(elt) {
|
||||
ret iter_sequence_body(cx, v, elt.ty, f, false, true);
|
||||
ret iter_sequence_body(cx, v, elt.ty, f, false);
|
||||
}
|
||||
ty::ty_istr. {
|
||||
let et = ty::mk_mach(bcx_tcx(cx), ast::ty_u8);
|
||||
ret iter_sequence_body(cx, v, et, f, true, true);
|
||||
ret iter_sequence_body(cx, v, et, f, true);
|
||||
}
|
||||
_ {
|
||||
bcx_ccx(cx).sess.bug(
|
||||
@ -2147,7 +2139,7 @@ fn copy_val_no_check(cx: &@block_ctxt, action: copy_action, dst: ValueRef,
|
||||
} else if ty::type_is_nil(ccx.tcx, t) || ty::type_is_bot(ccx.tcx, t) {
|
||||
ret cx;
|
||||
} else if ty::type_is_boxed(ccx.tcx, t) ||
|
||||
ty::type_is_ivec(ccx.tcx, t) {
|
||||
ty::type_is_vec(ccx.tcx, t) {
|
||||
let bcx = if action == DROP_EXISTING {
|
||||
drop_ty(cx, dst, t)
|
||||
} else { cx };
|
||||
@ -2259,7 +2251,7 @@ fn trans_crate_lit(cx: &@crate_ctxt, lit: &ast::lit) -> ValueRef {
|
||||
|
||||
fn trans_lit(cx: &@block_ctxt, lit: &ast::lit) -> result {
|
||||
alt lit.node {
|
||||
ast::lit_str(s) { ret ivec::trans_istr(cx, s); }
|
||||
ast::lit_str(s) { ret tvec::trans_istr(cx, s); }
|
||||
_ { ret rslt(cx, trans_crate_lit(bcx_ccx(cx), lit)); }
|
||||
}
|
||||
}
|
||||
@ -2357,7 +2349,7 @@ fn trans_eager_binop(cx: &@block_ctxt, op: ast::binop, lhs: ValueRef,
|
||||
alt op {
|
||||
ast::add. {
|
||||
if ty::type_is_sequence(bcx_tcx(cx), intype) {
|
||||
ret ivec::trans_add(cx, intype, lhs, rhs);
|
||||
ret tvec::trans_add(cx, intype, lhs, rhs);
|
||||
}
|
||||
if is_float {
|
||||
ret rslt(cx, FAdd(cx, lhs, rhs));
|
||||
@ -3168,8 +3160,8 @@ fn trans_index(cx: &@block_ctxt, sp: &span, base: &@ast::expr,
|
||||
maybe_name_value(bcx_ccx(cx), unit_sz.val, ~"unit_sz");
|
||||
let scaled_ix = Mul(bcx, ix_val, unit_sz.val);
|
||||
maybe_name_value(bcx_ccx(cx), scaled_ix, ~"scaled_ix");
|
||||
let lim = ivec::get_fill(bcx, v);
|
||||
let body = ivec::get_dataptr(bcx, v, type_of_or_i8(bcx, unit_ty));
|
||||
let lim = tvec::get_fill(bcx, v);
|
||||
let body = tvec::get_dataptr(bcx, v, type_of_or_i8(bcx, unit_ty));
|
||||
let bounds_check = ICmp(bcx, lib::llvm::LLVMIntULT, scaled_ix, lim);
|
||||
let fail_cx = new_sub_block_ctxt(bcx, ~"fail");
|
||||
let next_cx = new_sub_block_ctxt(bcx, ~"next");
|
||||
@ -3632,7 +3624,7 @@ fn trans_arg_expr(cx: &@block_ctxt, arg: &ty::arg, lldestty0: TypeRef,
|
||||
val = dst.val;
|
||||
add_clean_temp(bcx, val, e_ty);
|
||||
} else {
|
||||
if ty::type_is_ivec(ccx.tcx, e_ty) {
|
||||
if ty::type_is_vec(ccx.tcx, e_ty) {
|
||||
let arg_copy = do_spill(bcx, Load(bcx, val));
|
||||
bcx = take_ty(bcx, arg_copy, e_ty);
|
||||
val = Load(bcx, arg_copy);
|
||||
@ -4056,7 +4048,7 @@ fn trans_expr_out(cx: &@block_ctxt, e: &@ast::expr, output: out_method) ->
|
||||
ty::ty_vec(_) {
|
||||
alt src.node {
|
||||
ast::expr_vec(args, _) {
|
||||
let bcx = ivec::trans_append_literal
|
||||
let bcx = tvec::trans_append_literal
|
||||
(lhs_res.res.bcx, lhs_res.res.val, t, args);
|
||||
ret rslt(bcx, C_nil());
|
||||
}
|
||||
@ -4071,7 +4063,7 @@ fn trans_expr_out(cx: &@block_ctxt, e: &@ast::expr, output: out_method) ->
|
||||
if ty::type_is_sequence(tcx, t) {
|
||||
alt op {
|
||||
ast::add. {
|
||||
ret ivec::trans_append(rhs_res.bcx, t, lhs_res.res.val,
|
||||
ret tvec::trans_append(rhs_res.bcx, t, lhs_res.res.val,
|
||||
rhs_res.val);
|
||||
}
|
||||
_ { }
|
||||
@ -4091,7 +4083,7 @@ fn trans_expr_out(cx: &@block_ctxt, e: &@ast::expr, output: out_method) ->
|
||||
ret trans_call(cx, f, none::<ValueRef>, args, e.id);
|
||||
}
|
||||
ast::expr_cast(val, _) { ret trans_cast(cx, val, e.id); }
|
||||
ast::expr_vec(args, _) { ret ivec::trans_ivec(cx, args, e.id); }
|
||||
ast::expr_vec(args, _) { ret tvec::trans_vec(cx, args, e.id); }
|
||||
ast::expr_rec(args, base) { ret trans_rec(cx, args, base, e.id); }
|
||||
ast::expr_tup(args) { ret trans_tup(cx, args, e.id); }
|
||||
ast::expr_mac(_) { ret bcx_ccx(cx).sess.bug(~"unexpanded macro"); }
|
||||
@ -4177,7 +4169,7 @@ fn with_out_method(work: fn(&out_method) -> result, cx: @block_ctxt,
|
||||
// immediate-ness of the type.
|
||||
fn type_is_immediate(ccx: &@crate_ctxt, t: ty::t) -> bool {
|
||||
ret ty::type_is_scalar(ccx.tcx, t) || ty::type_is_boxed(ccx.tcx, t) ||
|
||||
ty::type_is_native(ccx.tcx, t) || ty::type_is_ivec(ccx.tcx, t);
|
||||
ty::type_is_native(ccx.tcx, t) || ty::type_is_vec(ccx.tcx, t);
|
||||
}
|
||||
|
||||
fn do_spill(cx: &@block_ctxt, v: ValueRef) -> ValueRef {
|
||||
@ -4264,21 +4256,10 @@ fn trans_fail_expr(cx: &@block_ctxt, sp_opt: &option::t<span>,
|
||||
bcx = expr_res.bcx;
|
||||
|
||||
if ty::type_is_str(tcx, e_ty) {
|
||||
let is_istr = alt ty::struct(tcx, e_ty) {
|
||||
ty::ty_istr. { true }
|
||||
_ { false }
|
||||
};
|
||||
if !is_istr {
|
||||
let elt =
|
||||
GEP(bcx, expr_res.val,
|
||||
[C_int(0), C_int(abi::vec_elt_data)]);
|
||||
ret trans_fail_value(bcx, sp_opt, elt);
|
||||
} else {
|
||||
let data = ivec::get_dataptr(
|
||||
bcx, expr_res.val,
|
||||
type_of_or_i8(bcx, ty::mk_mach(tcx, ast::ty_u8)));
|
||||
ret trans_fail_value(bcx, sp_opt, data);
|
||||
}
|
||||
let data = tvec::get_dataptr(
|
||||
bcx, expr_res.val,
|
||||
type_of_or_i8(bcx, ty::mk_mach(tcx, ast::ty_u8)));
|
||||
ret trans_fail_value(bcx, sp_opt, data);
|
||||
} else {
|
||||
bcx_ccx(cx).sess.span_bug(expr.span,
|
||||
~"fail called with unsupported type "
|
||||
@ -5449,13 +5430,13 @@ fn create_main_wrapper(ccx: &@crate_ctxt, sp: &span, main_llfn: ValueRef,
|
||||
fn create_main(ccx: &@crate_ctxt, sp: &span, main_llfn: ValueRef,
|
||||
takes_argv: bool) -> ValueRef {
|
||||
let unit_ty = ty::mk_istr(ccx.tcx);
|
||||
let ivecarg_ty: ty::arg =
|
||||
let vecarg_ty: ty::arg =
|
||||
{mode: ty::mo_val,
|
||||
ty:
|
||||
ty::mk_vec(ccx.tcx,
|
||||
{ty: unit_ty, mut: ast::imm})};
|
||||
let llfty =
|
||||
type_of_fn(ccx, sp, ast::proto_fn, [ivecarg_ty],
|
||||
type_of_fn(ccx, sp, ast::proto_fn, [vecarg_ty],
|
||||
ty::mk_nil(ccx.tcx), 0u);
|
||||
let llfdecl = decl_fastcall_fn(ccx.llmod, ~"_rust_main", llfty);
|
||||
|
||||
@ -5942,16 +5923,6 @@ fn decl_no_op_type_glue(llmod: ModuleRef, taskptr_type: TypeRef) -> ValueRef {
|
||||
abi::no_op_type_glue_name(), ty);
|
||||
}
|
||||
|
||||
fn vec_fill(bcx: &@block_ctxt, v: ValueRef) -> ValueRef {
|
||||
ret Load(bcx, GEP(bcx, v,
|
||||
[C_int(0), C_int(abi::vec_elt_fill)]));
|
||||
}
|
||||
|
||||
fn vec_p0(bcx: &@block_ctxt, v: ValueRef) -> ValueRef {
|
||||
let p = GEP(bcx, v, [C_int(0), C_int(abi::vec_elt_data)]);
|
||||
ret PointerCast(bcx, p, T_ptr(T_i8()));
|
||||
}
|
||||
|
||||
fn make_glues(llmod: ModuleRef, taskptr_type: TypeRef) -> @glue_fns {
|
||||
ret @{no_op_type_glue: decl_no_op_type_glue(llmod, taskptr_type)};
|
||||
}
|
||||
|
@ -643,15 +643,15 @@ fn T_array(t: TypeRef, n: uint) -> TypeRef { ret llvm::LLVMArrayType(t, n); }
|
||||
// Interior vector.
|
||||
//
|
||||
// TODO: Support user-defined vector sizes.
|
||||
fn T_ivec(t: TypeRef) -> TypeRef {
|
||||
fn T_vec(t: TypeRef) -> TypeRef {
|
||||
ret T_struct([T_int(), // fill
|
||||
T_int(), // alloc
|
||||
T_array(t, 0u)]); // elements
|
||||
}
|
||||
|
||||
// Note that the size of this one is in bytes.
|
||||
fn T_opaque_ivec() -> TypeRef {
|
||||
ret T_ivec(T_i8());
|
||||
fn T_opaque_vec() -> TypeRef {
|
||||
ret T_vec(T_i8());
|
||||
}
|
||||
|
||||
fn T_box(t: TypeRef) -> TypeRef { ret T_struct([T_int(), t]); }
|
||||
|
@ -13,14 +13,14 @@ import trans_build::*;
|
||||
import trans_common::*;
|
||||
|
||||
fn get_fill(bcx: &@block_ctxt, vptr: ValueRef) -> ValueRef {
|
||||
Load(bcx, InBoundsGEP(bcx, vptr, [C_int(0), C_uint(abi::ivec_elt_fill)]))
|
||||
Load(bcx, InBoundsGEP(bcx, vptr, [C_int(0), C_uint(abi::vec_elt_fill)]))
|
||||
}
|
||||
fn get_alloc(bcx: &@block_ctxt, vptr: ValueRef) -> ValueRef {
|
||||
Load(bcx, InBoundsGEP(bcx, vptr, [C_int(0), C_uint(abi::ivec_elt_alloc)]))
|
||||
Load(bcx, InBoundsGEP(bcx, vptr, [C_int(0), C_uint(abi::vec_elt_alloc)]))
|
||||
}
|
||||
fn get_dataptr(bcx: &@block_ctxt, vpt: ValueRef,
|
||||
unit_ty: TypeRef) -> ValueRef {
|
||||
let ptr = InBoundsGEP(bcx, vpt, [C_int(0), C_uint(abi::ivec_elt_elems)]);
|
||||
let ptr = InBoundsGEP(bcx, vpt, [C_int(0), C_uint(abi::vec_elt_elems)]);
|
||||
PointerCast(bcx, ptr, T_ptr(unit_ty))
|
||||
}
|
||||
|
||||
@ -32,14 +32,14 @@ fn pointer_add(bcx: &@block_ctxt, ptr: ValueRef, bytes: ValueRef)
|
||||
}
|
||||
|
||||
fn alloc_raw(bcx: &@block_ctxt, fill: ValueRef, alloc: ValueRef) -> result {
|
||||
let llvecty = T_opaque_ivec();
|
||||
let llvecty = T_opaque_vec();
|
||||
let vecsize = Add(bcx, alloc, llsize_of(llvecty));
|
||||
let {bcx, val: vecptr} =
|
||||
trans_shared_malloc(bcx, T_ptr(llvecty), vecsize);
|
||||
Store(bcx, fill, InBoundsGEP
|
||||
(bcx, vecptr, [C_int(0), C_uint(abi::ivec_elt_fill)]));
|
||||
(bcx, vecptr, [C_int(0), C_uint(abi::vec_elt_fill)]));
|
||||
Store(bcx, alloc, InBoundsGEP
|
||||
(bcx, vecptr, [C_int(0), C_uint(abi::ivec_elt_alloc)]));
|
||||
(bcx, vecptr, [C_int(0), C_uint(abi::vec_elt_alloc)]));
|
||||
ret {bcx: bcx, val: vecptr};
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ type alloc_result = {bcx: @block_ctxt,
|
||||
fn alloc(bcx: &@block_ctxt, vec_ty: &ty::t, elts: uint) -> alloc_result {
|
||||
let unit_ty = ty::sequence_element_type(bcx_tcx(bcx), vec_ty);
|
||||
let llunitty = type_of_or_i8(bcx, unit_ty);
|
||||
let llvecty = T_ivec(llunitty);
|
||||
let llvecty = T_vec(llunitty);
|
||||
let {bcx, val: unit_sz} = size_of(bcx, unit_ty);
|
||||
|
||||
let fill = Mul(bcx, C_uint(elts), unit_sz);
|
||||
@ -67,11 +67,11 @@ fn alloc(bcx: &@block_ctxt, vec_ty: &ty::t, elts: uint) -> alloc_result {
|
||||
fn duplicate(bcx: &@block_ctxt, vptrptr: ValueRef) -> @block_ctxt {
|
||||
let vptr = Load(bcx, vptrptr);
|
||||
let fill = get_fill(bcx, vptr);
|
||||
let size = Add(bcx, fill, llsize_of(T_opaque_ivec()));
|
||||
let size = Add(bcx, fill, llsize_of(T_opaque_vec()));
|
||||
let {bcx, val: newptr} = trans_shared_malloc(bcx, val_ty(vptr), size);
|
||||
let bcx = call_memmove(bcx, newptr, vptr, size).bcx;
|
||||
Store(bcx, fill,
|
||||
InBoundsGEP(bcx, newptr, [C_int(0), C_uint(abi::ivec_elt_alloc)]));
|
||||
InBoundsGEP(bcx, newptr, [C_int(0), C_uint(abi::vec_elt_alloc)]));
|
||||
Store(bcx, newptr, vptrptr);
|
||||
ret bcx;
|
||||
}
|
||||
@ -84,14 +84,14 @@ fn make_drop_glue(bcx: &@block_ctxt, vptrptr: ValueRef, vec_ty: ty::t)
|
||||
let null_test = IsNull(bcx, vptr);
|
||||
CondBr(bcx, null_test, next_cx.llbb, drop_cx.llbb);
|
||||
if ty::type_needs_drop(bcx_tcx(bcx), unit_ty) {
|
||||
drop_cx = iter_ivec(drop_cx, vptrptr, vec_ty, trans::drop_ty);
|
||||
drop_cx = iter_vec(drop_cx, vptrptr, vec_ty, trans::drop_ty);
|
||||
}
|
||||
drop_cx = trans::trans_shared_free(drop_cx, vptr);
|
||||
Br(drop_cx, next_cx.llbb);
|
||||
ret next_cx;
|
||||
}
|
||||
|
||||
fn trans_ivec(bcx: &@block_ctxt, args: &[@ast::expr],
|
||||
fn trans_vec(bcx: &@block_ctxt, args: &[@ast::expr],
|
||||
id: ast::node_id) -> result {
|
||||
let vec_ty = node_id_type(bcx_ccx(bcx), id);
|
||||
let {bcx, val: vptr, llunitsz, unit_ty, llunitty} =
|
||||
@ -131,8 +131,8 @@ fn trans_append(cx: &@block_ctxt, vec_ty: ty::t, lhsptr: ValueRef,
|
||||
let unit_ty = ty::sequence_element_type(bcx_tcx(cx), vec_ty);
|
||||
let dynamic = ty::type_has_dynamic_size(bcx_tcx(cx), unit_ty);
|
||||
if dynamic {
|
||||
lhsptr = PointerCast(cx, lhsptr, T_ptr(T_ptr(T_opaque_ivec())));
|
||||
rhs = PointerCast(cx, rhs, T_ptr(T_opaque_ivec()));
|
||||
lhsptr = PointerCast(cx, lhsptr, T_ptr(T_ptr(T_opaque_vec())));
|
||||
rhs = PointerCast(cx, rhs, T_ptr(T_opaque_vec()));
|
||||
}
|
||||
let strings = alt ty::struct(bcx_tcx(cx), vec_ty) {
|
||||
ty::ty_istr. { true }
|
||||
@ -148,8 +148,8 @@ fn trans_append(cx: &@block_ctxt, vec_ty: ty::t, lhsptr: ValueRef,
|
||||
let rfill = get_fill(bcx, rhs);
|
||||
let new_fill = Add(bcx, lfill, rfill);
|
||||
if strings { new_fill = Sub(bcx, new_fill, C_int(1)); }
|
||||
let opaque_lhs = PointerCast(bcx, lhsptr, T_ptr(T_ptr(T_opaque_ivec())));
|
||||
Call(bcx, bcx_ccx(cx).upcalls.ivec_grow,
|
||||
let opaque_lhs = PointerCast(bcx, lhsptr, T_ptr(T_ptr(T_opaque_vec())));
|
||||
Call(bcx, bcx_ccx(cx).upcalls.vec_grow,
|
||||
[cx.fcx.lltaskptr, opaque_lhs, new_fill]);
|
||||
// Was overwritten if we resized
|
||||
let lhs = Load(bcx, lhsptr);
|
||||
@ -160,7 +160,7 @@ fn trans_append(cx: &@block_ctxt, vec_ty: ty::t, lhsptr: ValueRef,
|
||||
if strings { lhs_off = Sub(bcx, lhs_off, C_int(1)); }
|
||||
let write_ptr = pointer_add(bcx, lhs_data, lhs_off);
|
||||
let write_ptr_ptr = do_spill(bcx, write_ptr);
|
||||
let bcx = iter_ivec_raw(bcx, rhs, vec_ty, rfill, { | &bcx, addr, _ty |
|
||||
let bcx = iter_vec_raw(bcx, rhs, vec_ty, rfill, { | &bcx, addr, _ty |
|
||||
let write_ptr = Load(bcx, write_ptr_ptr);
|
||||
let bcx = copy_val(bcx, INIT, write_ptr,
|
||||
load_if_immediate(bcx, addr, unit_ty), unit_ty);
|
||||
@ -182,12 +182,12 @@ fn trans_append_literal(bcx: &@block_ctxt, vptrptr: ValueRef, vec_ty: ty::t,
|
||||
let {bcx, val: td} =
|
||||
get_tydesc(bcx, elt_ty, false, tps_normal, ti).result;
|
||||
trans::lazily_emit_tydesc_glue(bcx, abi::tydesc_field_take_glue, ti);
|
||||
let opaque_v = PointerCast(bcx, vptrptr, T_ptr(T_ptr(T_opaque_ivec())));
|
||||
let opaque_v = PointerCast(bcx, vptrptr, T_ptr(T_ptr(T_opaque_vec())));
|
||||
for val in vals {
|
||||
let {bcx: e_bcx, val: elt} = trans::trans_expr(bcx, val);
|
||||
bcx = e_bcx;
|
||||
let spilled = trans::spill_if_immediate(bcx, elt, elt_ty);
|
||||
Call(bcx, bcx_ccx(bcx).upcalls.ivec_push,
|
||||
Call(bcx, bcx_ccx(bcx).upcalls.vec_push,
|
||||
[bcx.fcx.lltaskptr, opaque_v, td,
|
||||
PointerCast(bcx, spilled, T_ptr(T_i8()))]);
|
||||
}
|
||||
@ -209,7 +209,7 @@ fn trans_add(bcx: &@block_ctxt, vec_ty: ty::t, lhs: ValueRef,
|
||||
let rhs_fill = get_fill(bcx, rhs);
|
||||
let new_fill = Add(bcx, lhs_fill, rhs_fill);
|
||||
let {bcx, val: new_vec} = alloc_raw(bcx, new_fill, new_fill);
|
||||
let new_vec = PointerCast(bcx, new_vec, T_ptr(T_ivec(llunitty)));
|
||||
let new_vec = PointerCast(bcx, new_vec, T_ptr(T_vec(llunitty)));
|
||||
add_clean_temp(bcx, new_vec, vec_ty);
|
||||
|
||||
let write_ptr_ptr = do_spill(bcx, get_dataptr(bcx, new_vec, llunitty));
|
||||
@ -228,21 +228,21 @@ fn trans_add(bcx: &@block_ctxt, vec_ty: ty::t, lhs: ValueRef,
|
||||
ret bcx;
|
||||
} (_, _, _, write_ptr_ptr, unit_ty, llunitsz);
|
||||
|
||||
let bcx = iter_ivec_raw(bcx, lhs, vec_ty, lhs_fill, copy_fn);
|
||||
let bcx = iter_ivec_raw(bcx, rhs, vec_ty, rhs_fill, copy_fn);
|
||||
let bcx = iter_vec_raw(bcx, lhs, vec_ty, lhs_fill, copy_fn);
|
||||
let bcx = iter_vec_raw(bcx, rhs, vec_ty, rhs_fill, copy_fn);
|
||||
ret rslt(bcx, new_vec);
|
||||
}
|
||||
|
||||
type val_and_ty_fn = fn(&@block_ctxt, ValueRef, ty::t) -> result;
|
||||
|
||||
type iter_ivec_block = block(&@block_ctxt, ValueRef, ty::t) -> @block_ctxt;
|
||||
type iter_vec_block = block(&@block_ctxt, ValueRef, ty::t) -> @block_ctxt;
|
||||
|
||||
fn iter_ivec_raw(bcx: &@block_ctxt, vptr: ValueRef, vec_ty: ty::t,
|
||||
fill: ValueRef, f: &iter_ivec_block) -> @block_ctxt {
|
||||
fn iter_vec_raw(bcx: &@block_ctxt, vptr: ValueRef, vec_ty: ty::t,
|
||||
fill: ValueRef, f: &iter_vec_block) -> @block_ctxt {
|
||||
let unit_ty = ty::sequence_element_type(bcx_tcx(bcx), vec_ty);
|
||||
let llunitty = type_of_or_i8(bcx, unit_ty);
|
||||
let {bcx, val: unit_sz} = size_of(bcx, unit_ty);
|
||||
let vptr = PointerCast(bcx, vptr, T_ptr(T_ivec(llunitty)));
|
||||
let vptr = PointerCast(bcx, vptr, T_ptr(T_vec(llunitty)));
|
||||
let data_ptr = get_dataptr(bcx, vptr, llunitty);
|
||||
|
||||
// Calculate the last pointer address we want to handle.
|
||||
@ -252,13 +252,13 @@ fn iter_ivec_raw(bcx: &@block_ctxt, vptr: ValueRef, vec_ty: ty::t,
|
||||
let data_ptr_ptr = do_spill(bcx, data_ptr);
|
||||
|
||||
// Now perform the iteration.
|
||||
let header_cx = new_sub_block_ctxt(bcx, ~"iter_ivec_loop_header");
|
||||
let header_cx = new_sub_block_ctxt(bcx, ~"iter_vec_loop_header");
|
||||
Br(bcx, header_cx.llbb);
|
||||
let data_ptr = Load(header_cx, data_ptr_ptr);
|
||||
let not_yet_at_end = ICmp(header_cx, lib::llvm::LLVMIntULT,
|
||||
data_ptr, data_end_ptr);
|
||||
let body_cx = new_sub_block_ctxt(bcx, ~"iter_ivec_loop_body");
|
||||
let next_cx = new_sub_block_ctxt(bcx, ~"iter_ivec_next");
|
||||
let body_cx = new_sub_block_ctxt(bcx, ~"iter_vec_loop_body");
|
||||
let next_cx = new_sub_block_ctxt(bcx, ~"iter_vec_next");
|
||||
CondBr(header_cx, not_yet_at_end, body_cx.llbb, next_cx.llbb);
|
||||
body_cx = f(body_cx, data_ptr, unit_ty);
|
||||
let increment = if ty::type_has_dynamic_size(bcx_tcx(bcx), unit_ty) {
|
||||
@ -270,11 +270,11 @@ fn iter_ivec_raw(bcx: &@block_ctxt, vptr: ValueRef, vec_ty: ty::t,
|
||||
ret next_cx;
|
||||
}
|
||||
|
||||
fn iter_ivec(bcx: &@block_ctxt, vptrptr: ValueRef, vec_ty: ty::t,
|
||||
f: &iter_ivec_block) -> @block_ctxt {
|
||||
fn iter_vec(bcx: &@block_ctxt, vptrptr: ValueRef, vec_ty: ty::t,
|
||||
f: &iter_vec_block) -> @block_ctxt {
|
||||
let vptr = Load(bcx, PointerCast(bcx, vptrptr,
|
||||
T_ptr(T_ptr(T_opaque_ivec()))));
|
||||
ret iter_ivec_raw(bcx, vptr, vec_ty, get_fill(bcx, vptr), f);
|
||||
T_ptr(T_ptr(T_opaque_vec()))));
|
||||
ret iter_vec_raw(bcx, vptr, vec_ty, get_fill(bcx, vptr), f);
|
||||
}
|
||||
|
||||
//
|
@ -153,7 +153,7 @@ export type_is_bool;
|
||||
export type_is_bot;
|
||||
export type_is_box;
|
||||
export type_is_boxed;
|
||||
export type_is_ivec;
|
||||
export type_is_vec;
|
||||
export type_is_fp;
|
||||
export type_is_integral;
|
||||
export type_is_native;
|
||||
@ -877,7 +877,7 @@ fn type_is_boxed(cx: &ctxt, ty: t) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
fn type_is_ivec(cx: &ctxt, ty: t) -> bool {
|
||||
fn type_is_vec(cx: &ctxt, ty: t) -> bool {
|
||||
ret alt struct(cx, ty) {
|
||||
ty_vec(_) { true }
|
||||
ty_istr. { true }
|
||||
|
@ -19,7 +19,7 @@ mod middle {
|
||||
mod trans;
|
||||
mod trans_alt;
|
||||
mod trans_objects;
|
||||
mod trans_ivec;
|
||||
mod trans_vec;
|
||||
mod ty;
|
||||
mod ast_map;
|
||||
mod resolve;
|
||||
|
@ -301,9 +301,9 @@ tag ty_ {
|
||||
ty_float;
|
||||
ty_machine(ty_mach);
|
||||
ty_char;
|
||||
ty_istr; // interior string
|
||||
ty_istr;
|
||||
ty_box(mt);
|
||||
ty_vec(mt); // interior vector
|
||||
ty_vec(mt);
|
||||
ty_ptr(mt);
|
||||
ty_task;
|
||||
ty_port(@ty);
|
||||
|
Loading…
x
Reference in New Issue
Block a user