From 8affc78e8a0e420e1755a34fc7f5e4021c512e9d Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Thu, 3 May 2012 22:31:38 -0700 Subject: [PATCH] Turn constants in back::abi into uints, and propagate types This means GEPi now takes a list of uints. Apologies in advance if this is hard to rebase against, but it gets rid of many a cast :-) Also modernized some for loops here and there. --- src/rustc/back/abi.rs | 89 +++++++++++----------- src/rustc/middle/trans/alt.rs | 16 ++-- src/rustc/middle/trans/base.rs | 118 ++++++++++++++---------------- src/rustc/middle/trans/build.rs | 2 +- src/rustc/middle/trans/closure.rs | 59 ++++++++------- src/rustc/middle/trans/common.rs | 14 ++-- src/rustc/middle/trans/impl.rs | 12 +-- src/rustc/middle/trans/native.rs | 49 ++++++------- src/rustc/middle/trans/tvec.rs | 24 +++--- 9 files changed, 184 insertions(+), 199 deletions(-) diff --git a/src/rustc/back/abi.rs b/src/rustc/back/abi.rs index 4379a35f5f6..70606d9f885 100644 --- a/src/rustc/back/abi.rs +++ b/src/rustc/back/abi.rs @@ -1,55 +1,54 @@ -// FIXME: Most of these should be uints. -const rc_base_field_refcnt: int = 0; +const rc_base_field_refcnt: uint = 0u; -const task_field_refcnt: int = 0; +const task_field_refcnt: uint = 0u; -const task_field_stk: int = 2; +const task_field_stk: uint = 2u; -const task_field_runtime_sp: int = 3; +const task_field_runtime_sp: uint = 3u; -const task_field_rust_sp: int = 4; +const task_field_rust_sp: uint = 4u; -const task_field_gc_alloc_chain: int = 5; +const task_field_gc_alloc_chain: uint = 5u; -const task_field_dom: int = 6; +const task_field_dom: uint = 6u; -const n_visible_task_fields: int = 7; +const n_visible_task_fields: uint = 7u; -const dom_field_interrupt_flag: int = 1; +const dom_field_interrupt_flag: uint = 1u; -const frame_glue_fns_field_mark: int = 0; +const frame_glue_fns_field_mark: uint = 0u; -const frame_glue_fns_field_drop: int = 1; +const frame_glue_fns_field_drop: uint = 1u; -const frame_glue_fns_field_reloc: int = 2; +const frame_glue_fns_field_reloc: uint = 2u; -const box_field_refcnt: int = 0; -const box_field_tydesc: int = 1; -const box_field_prev: int = 2; -const box_field_next: int = 3; -const box_field_body: int = 4; +const box_field_refcnt: uint = 0u; +const box_field_tydesc: uint = 1u; +const box_field_prev: uint = 2u; +const box_field_next: uint = 3u; +const box_field_body: uint = 4u; -const general_code_alignment: int = 16; +const general_code_alignment: uint = 16u; -const tydesc_field_first_param: int = 0; -const tydesc_field_size: int = 1; -const tydesc_field_align: int = 2; -const tydesc_field_take_glue: int = 3; -const tydesc_field_drop_glue: int = 4; -const tydesc_field_free_glue: int = 5; -const tydesc_field_unused: int = 6; -const tydesc_field_sever_glue: int = 7; -const tydesc_field_mark_glue: int = 8; -const tydesc_field_unused2: int = 9; -const tydesc_field_unused_2: int = 10; -const tydesc_field_shape: int = 11; -const tydesc_field_shape_tables: int = 12; -const tydesc_field_n_params: int = 13; -const tydesc_field_obj_params: int = 14; // FIXME unused -const n_tydesc_fields: int = 15; +const tydesc_field_first_param: uint = 0u; +const tydesc_field_size: uint = 1u; +const tydesc_field_align: uint = 2u; +const tydesc_field_take_glue: uint = 3u; +const tydesc_field_drop_glue: uint = 4u; +const tydesc_field_free_glue: uint = 5u; +const tydesc_field_unused: uint = 6u; +const tydesc_field_sever_glue: uint = 7u; +const tydesc_field_mark_glue: uint = 8u; +const tydesc_field_unused2: uint = 9u; +const tydesc_field_unused_2: uint = 10u; +const tydesc_field_shape: uint = 11u; +const tydesc_field_shape_tables: uint = 12u; +const tydesc_field_n_params: uint = 13u; +const tydesc_field_obj_params: uint = 14u; // FIXME unused (#2351) +const n_tydesc_fields: uint = 15u; const cmp_glue_op_eq: uint = 0u; @@ -58,23 +57,23 @@ const cmp_glue_op_lt: uint = 1u; const cmp_glue_op_le: uint = 2u; // The two halves of a closure: code and environment. -const fn_field_code: int = 0; -const fn_field_box: int = 1; +const fn_field_code: uint = 0u; +const fn_field_box: uint = 1u; // closures, see trans_closure.rs -const closure_body_ty_params: int = 0; -const closure_body_bindings: int = 1; +const closure_body_ty_params: uint = 0u; +const closure_body_bindings: uint = 1u; -const vec_elt_fill: int = 0; +const vec_elt_fill: uint = 0u; -const vec_elt_alloc: int = 1; +const vec_elt_alloc: uint = 1u; -const vec_elt_elems: int = 2; +const vec_elt_elems: uint = 2u; -const slice_elt_base: int = 0; -const slice_elt_len: int = 1; +const slice_elt_base: uint = 0u; +const slice_elt_len: uint = 1u; -const worst_case_glue_call_args: int = 7; +const worst_case_glue_call_args: uint = 7u; const abi_version: uint = 1u; diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs index 9219fc8d1ab..3dae38d9496 100644 --- a/src/rustc/middle/trans/alt.rs +++ b/src/rustc/middle/trans/alt.rs @@ -274,7 +274,7 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id, if size > 0u && (*variants).len() != 1u { let enumptr = PointerCast(bcx, val, T_opaque_enum_ptr(ccx)); - blobptr = GEPi(bcx, enumptr, [0, 1]); + blobptr = GEPi(bcx, enumptr, [0u, 1u]); } let vdefs_tg = vdefs.enm; let vdefs_var = vdefs.var; @@ -410,7 +410,7 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef], let mut rec_vals = []; for vec::each(rec_fields) {|field_name| let ix = option::get(ty::field_idx(field_name, fields)); - rec_vals += [GEPi(bcx, val, [0, ix as int])]; + rec_vals += [GEPi(bcx, val, [0u, ix])]; } compile_submatch(bcx, enter_rec(dm, m, col, rec_fields, val), rec_vals + vals_left, chk, exits); @@ -425,7 +425,7 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef], }; let mut tup_vals = [], i = 0u; while i < n_tup_elts { - tup_vals += [GEPi(bcx, val, [0, i as int])]; + tup_vals += [GEPi(bcx, val, [0u, i])]; i += 1u; } compile_submatch(bcx, enter_tup(dm, m, col, val, n_tup_elts), @@ -436,7 +436,7 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef], // Unbox in case of a box field if any_box_pat(m, col) { let box = Load(bcx, val); - let unboxed = GEPi(bcx, box, [0, abi::box_field_body]); + let unboxed = GEPi(bcx, box, [0u, abi::box_field_body]); compile_submatch(bcx, enter_box(dm, m, col, val), [unboxed] + vals_left, chk, exits); ret; @@ -462,7 +462,7 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef], } else { let enumptr = PointerCast(bcx, val, T_opaque_enum_ptr(ccx)); - let discrimptr = GEPi(bcx, enumptr, [0, 0]); + let discrimptr = GEPi(bcx, enumptr, [0u, 0u]); test_val = Load(bcx, discrimptr); kind = switch; } @@ -711,14 +711,14 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef, let rec_fields = ty::get_fields(node_id_type(bcx, pat.id)); for vec::each(fields) {|f| let ix = option::get(ty::field_idx(f.ident, rec_fields)); - let fldptr = GEPi(bcx, val, [0, ix as int]); + let fldptr = GEPi(bcx, val, [0u, ix]); bcx = bind_irrefutable_pat(bcx, f.pat, fldptr, make_copy); } } ast::pat_tup(elems) { let mut i = 0u; for vec::each(elems) {|elem| - let fldptr = GEPi(bcx, val, [0, i as int]); + let fldptr = GEPi(bcx, val, [0u, i]); bcx = bind_irrefutable_pat(bcx, elem, fldptr, make_copy); i += 1u; } @@ -726,7 +726,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef, ast::pat_box(inner) { let box = Load(bcx, val); let unboxed = - GEPi(bcx, box, [0, abi::box_field_body]); + GEPi(bcx, box, [0u, abi::box_field_body]); bcx = bind_irrefutable_pat(bcx, inner, unboxed, true); } ast::pat_uniq(inner) { diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index b3166c8bd26..a06d78c24bb 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -301,7 +301,7 @@ fn GEP_enum(bcx: block, llblobptr: ValueRef, enum_id: ast::def_id, }); let typed_blobptr = PointerCast(bcx, llblobptr, T_ptr(T_struct(arg_lltys))); - GEPi(bcx, typed_blobptr, [0, ix as int]) + GEPi(bcx, typed_blobptr, [0u, ix]) } // trans_shared_malloc: expects a type indicating which pointer type we want @@ -324,7 +324,7 @@ fn opaque_box_body(bcx: block, let _icx = bcx.insn_ctxt("opaque_box_body"); let ccx = bcx.ccx(); let boxptr = PointerCast(bcx, boxptr, T_ptr(T_box_header(ccx))); - let bodyptr = GEPi(bcx, boxptr, [1]); + let bodyptr = GEPi(bcx, boxptr, [1u]); PointerCast(bcx, bodyptr, T_ptr(type_of(ccx, body_t))) } @@ -356,7 +356,7 @@ fn malloc_boxed(bcx: block, t: ty::t) -> {box: ValueRef, body: ValueRef} { let _icx = bcx.insn_ctxt("trans_malloc_boxed"); let mut ti = none; let box = malloc_boxed_raw(bcx, t, ti); - let body = GEPi(bcx, box, [0, abi::box_field_body]); + let body = GEPi(bcx, box, [0u, abi::box_field_body]); ret {box: box, body: body}; } @@ -603,7 +603,7 @@ fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) { closure::make_fn_glue(bcx, v, t, take_ty) } ty::ty_iface(_, _) { - let box = Load(bcx, GEPi(bcx, v, [0, 1])); + let box = Load(bcx, GEPi(bcx, v, [0u, 1u])); incr_refcnt_of_boxed(bcx, box); bcx } @@ -623,7 +623,7 @@ fn incr_refcnt_of_boxed(cx: block, box_ptr: ValueRef) { let _icx = cx.insn_ctxt("incr_refcnt_of_boxed"); let ccx = cx.ccx(); maybe_validate_box(cx, box_ptr); - let rc_ptr = GEPi(cx, box_ptr, [0, abi::box_field_refcnt]); + let rc_ptr = GEPi(cx, box_ptr, [0u, abi::box_field_refcnt]); let rc = Load(cx, rc_ptr); let rc = Add(cx, rc, C_int(ccx, 1)); Store(cx, rc, rc_ptr); @@ -638,7 +638,7 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) { let bcx = alt ty::get(t).struct { ty::ty_box(body_mt) { let v = PointerCast(bcx, v, type_of(ccx, t)); - let body = GEPi(bcx, v, [0, abi::box_field_body]); + let body = GEPi(bcx, v, [0u, abi::box_field_body]); let bcx = drop_ty(bcx, body, body_mt.ty); trans_free(bcx, v) } @@ -650,8 +650,8 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) { ty::ty_opaque_box { let v = PointerCast(bcx, v, type_of(ccx, t)); - let td = Load(bcx, GEPi(bcx, v, [0, abi::box_field_tydesc])); - let valptr = GEPi(bcx, v, [0, abi::box_field_body]); + let td = Load(bcx, GEPi(bcx, v, [0u, abi::box_field_tydesc])); + let valptr = GEPi(bcx, v, [0u, abi::box_field_body]); call_tydesc_glue_full(bcx, valptr, td, abi::tydesc_field_drop_glue, none); trans_free(bcx, v) @@ -698,7 +698,7 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) { closure::make_fn_glue(bcx, v0, t, drop_ty) } ty::ty_iface(_, _) { - let box = Load(bcx, GEPi(bcx, v0, [0, 1])); + let box = Load(bcx, GEPi(bcx, v0, [0u, 1u])); decr_refcnt_maybe_free(bcx, box, ty::mk_opaque_box(ccx.tcx)) } ty::ty_opaque_closure_ptr(ck) { @@ -742,9 +742,9 @@ fn trans_res_drop(bcx: block, rs: ValueRef, did: ast::def_id, let ccx = bcx.ccx(); let inner_t_s = ty::subst_tps(ccx.tcx, tps, inner_t); - let drop_flag = GEPi(bcx, rs, [0, 0]); + let drop_flag = GEPi(bcx, rs, [0u, 0u]); with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag))) {|bcx| - let valptr = GEPi(bcx, rs, [0, 1]); + let valptr = GEPi(bcx, rs, [0u, 1u]); // Find and call the actual destructor. let dtor_addr = get_res_dtor(ccx, did, tps); let args = [bcx.fcx.llretptr, null_env_ptr(bcx)]; @@ -782,7 +782,7 @@ fn decr_refcnt_maybe_free(bcx: block, box_ptr: ValueRef, t: ty::t) -> block { let llbox_ty = T_opaque_box_ptr(ccx); let box_ptr = PointerCast(bcx, box_ptr, llbox_ty); with_cond(bcx, IsNotNull(bcx, box_ptr)) {|bcx| - let rc_ptr = GEPi(bcx, box_ptr, [0, abi::box_field_refcnt]); + let rc_ptr = GEPi(bcx, box_ptr, [0u, abi::box_field_refcnt]); let rc = Sub(bcx, Load(bcx, rc_ptr), C_int(ccx, 1)); Store(bcx, rc, rc_ptr); let zero_test = ICmp(bcx, lib::llvm::IntEQ, C_int(ccx, 0), rc); @@ -888,12 +888,12 @@ fn compare_scalar_values(cx: block, lhs: ValueRef, rhs: ValueRef, type val_pair_fn = fn@(block, ValueRef, ValueRef) -> block; type val_and_ty_fn = fn@(block, ValueRef, ty::t) -> block; -fn load_inbounds(cx: block, p: ValueRef, idxs: [int]) -> ValueRef { +fn load_inbounds(cx: block, p: ValueRef, idxs: [uint]) -> ValueRef { ret Load(cx, GEPi(cx, p, idxs)); } fn store_inbounds(cx: block, v: ValueRef, p: ValueRef, - idxs: [int]) { + idxs: [uint]) { Store(cx, v, GEPi(cx, p, idxs)); } @@ -933,7 +933,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, alt ty::get(t).struct { ty::ty_rec(fields) { for vec::eachi(fields) {|i, fld| - let llfld_a = GEPi(cx, av, [0, i as int]); + let llfld_a = GEPi(cx, av, [0u, i]); cx = f(cx, llfld_a, fld.mt.ty); } } @@ -944,14 +944,14 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, } ty::ty_tup(args) { for vec::eachi(args) {|i, arg| - let llfld_a = GEPi(cx, av, [0, i as int]); + let llfld_a = GEPi(cx, av, [0u, i]); cx = f(cx, llfld_a, arg); } } ty::ty_res(_, inner, substs) { let tcx = cx.tcx(); let inner1 = ty::subst(tcx, substs, inner); - let llfld_a = GEPi(cx, av, [0, 1]); + let llfld_a = GEPi(cx, av, [0u, 1u]); ret f(cx, llfld_a, inner1); } ty::ty_enum(tid, substs) { @@ -967,8 +967,8 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, let ccx = cx.ccx(); let llenumty = T_opaque_enum_ptr(ccx); let av_enum = PointerCast(cx, av, llenumty); - let lldiscrim_a_ptr = GEPi(cx, av_enum, [0, 0]); - let llunion_a_ptr = GEPi(cx, av_enum, [0, 1]); + let lldiscrim_a_ptr = GEPi(cx, av_enum, [0u, 0u]); + let llunion_a_ptr = GEPi(cx, av_enum, [0u, 1u]); let lldiscrim_a = Load(cx, lldiscrim_a_ptr); // NB: we must hit the discriminant first so that structural @@ -993,12 +993,11 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, } ty::ty_class(did, substs) { // a class is like a record type - let mut i: int = 0; - for vec::each(ty::class_items_as_fields(cx.tcx(), did, substs)) {|fld| - let llfld_a = GEPi(cx, av, [0, i]); - cx = f(cx, llfld_a, fld.mt.ty); - i += 1; - } + for vec::eachi(ty::class_items_as_fields(cx.tcx(), did, substs)) + {|i, fld| + let llfld_a = GEPi(cx, av, [0u, i]); + cx = f(cx, llfld_a, fld.mt.ty); + } } _ { cx.sess().unimpl("type in iter_structural_ty"); } } @@ -1012,7 +1011,7 @@ fn lazily_emit_all_tydesc_glue(ccx: @crate_ctxt, lazily_emit_tydesc_glue(ccx, abi::tydesc_field_free_glue, static_ti); } -fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: int, +fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, static_ti: option<@tydesc_info>) { let _icx = ccx.insn_ctxt("lazily_emit_tydesc_glue"); alt static_ti { @@ -1069,7 +1068,7 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: int, } fn call_tydesc_glue_full(cx: block, v: ValueRef, tydesc: ValueRef, - field: int, static_ti: option<@tydesc_info>) { + field: uint, static_ti: option<@tydesc_info>) { let _icx = cx.insn_ctxt("call_tydesc_glue_full"); lazily_emit_tydesc_glue(cx.ccx(), field, static_ti); if cx.unreachable { ret; } @@ -1093,7 +1092,7 @@ fn call_tydesc_glue_full(cx: block, v: ValueRef, tydesc: ValueRef, let llfn = { alt static_glue_fn { none { - let llfnptr = GEPi(cx, tydesc, [0, field]); + let llfnptr = GEPi(cx, tydesc, [0u, field]); Load(cx, llfnptr) } some(sgf) { sgf } @@ -1104,7 +1103,7 @@ fn call_tydesc_glue_full(cx: block, v: ValueRef, tydesc: ValueRef, C_null(T_ptr(T_ptr(cx.ccx().tydesc_type))), llrawptr]); } -fn call_tydesc_glue(cx: block, v: ValueRef, t: ty::t, field: int) -> +fn call_tydesc_glue(cx: block, v: ValueRef, t: ty::t, field: uint) -> block { let _icx = cx.insn_ctxt("call_tydesc_glue"); let mut ti = none; @@ -1126,7 +1125,7 @@ fn call_cmp_glue(bcx: block, lhs: ValueRef, rhs: ValueRef, t: ty::t, let llrawrhsptr = BitCast(bcx, llrhs, T_ptr(T_i8())); let lltydesc = get_tydesc_simple(bcx.ccx(), t); let lltydescs = - Load(bcx, GEPi(bcx, lltydesc, [0, abi::tydesc_field_first_param])); + Load(bcx, GEPi(bcx, lltydesc, [0u, abi::tydesc_field_first_param])); let llfn = bcx.ccx().upcalls.cmp_type; @@ -1605,7 +1604,7 @@ fn autoderef(cx: block, v: ValueRef, t: ty::t) -> result_t { loop { alt ty::get(t1).struct { ty::ty_box(mt) { - let body = GEPi(cx, v1, [0, abi::box_field_body]); + let body = GEPi(cx, v1, [0u, abi::box_field_body]); t1 = mt.ty; // Since we're changing levels of box indirection, we may have @@ -1626,7 +1625,7 @@ fn autoderef(cx: block, v: ValueRef, t: ty::t) -> result_t { } ty::ty_res(did, inner, substs) { t1 = ty::subst(ccx.tcx, substs, inner); - v1 = GEPi(cx, v1, [0, 1]); + v1 = GEPi(cx, v1, [0u, 1u]); } ty::ty_enum(did, substs) { let variants = ty::enum_variants(ccx.tcx, did); @@ -2251,7 +2250,7 @@ fn trans_var(cx: block, def: ast::def, id: ast::node_id)-> lval_maybe_callee { // FIXME: This pointer cast probably isn't necessary let llenumty = type_of(ccx, enum_ty); let llenumptr = PointerCast(cx, llenumblob, T_ptr(llenumty)); - let lldiscrimptr = GEPi(cx, llenumptr, [0, 0]); + let lldiscrimptr = GEPi(cx, llenumptr, [0u, 0u]); let lldiscrim_gv = lookup_discriminant(ccx, vid); let lldiscrim = Load(cx, lldiscrim_gv); Store(cx, lldiscrim, lldiscrimptr); @@ -2293,7 +2292,7 @@ fn trans_rec_field_inner(bcx: block, val: ValueRef, ty: ty::t, base expr has non-record type"); } }; let ix = field_idx_strict(bcx.tcx(), sp, field, fields); - let val = GEPi(bcx, val, [0, ix as int]); + let val = GEPi(bcx, val, [0u, ix]); ret {bcx: bcx, val: val, kind: owned}; } @@ -2400,10 +2399,10 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result { let t = expr_ty(cx, base); let val = alt check ty::get(t).struct { ty::ty_box(_) { - GEPi(sub.bcx, sub.val, [0, abi::box_field_body]) + GEPi(sub.bcx, sub.val, [0u, abi::box_field_body]) } ty::ty_res(_, _, _) { - GEPi(sub.bcx, sub.val, [0, 1]) + GEPi(sub.bcx, sub.val, [0u, 1u]) } ty::ty_enum(_, _) { let ety = expr_ty(cx, e); @@ -2528,7 +2527,7 @@ fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id, let cx = e_res.bcx; let llenumty = T_opaque_enum_ptr(ccx); let av_enum = PointerCast(cx, e_res.val, llenumty); - let lldiscrim_a_ptr = GEPi(cx, av_enum, [0, 0]); + let lldiscrim_a_ptr = GEPi(cx, av_enum, [0u, 0u]); let lldiscrim_a = Load(cx, lldiscrim_a_ptr); alt k_out { cast_integral {int_cast(e_res.bcx, ll_t_out, @@ -2658,7 +2657,7 @@ fn adapt_borrowed_value(lv: lval_result, _arg: ty::arg, owned_imm { lv.val } } }; - let body_ptr = GEPi(bcx, box_ptr, [0, abi::box_field_body]); + let body_ptr = GEPi(bcx, box_ptr, [0u, abi::box_field_body]); ret lval_temp(bcx, body_ptr); } @@ -2685,8 +2684,8 @@ fn adapt_borrowed_value(lv: lval_result, _arg: ty::arg, val_str(bcx.ccx().tn, val), val_str(bcx.ccx().tn, p)); - Store(bcx, base, GEPi(bcx, p, [0, abi::slice_elt_base])); - Store(bcx, len, GEPi(bcx, p, [0, abi::slice_elt_len])); + Store(bcx, base, GEPi(bcx, p, [0u, abi::slice_elt_base])); + Store(bcx, len, GEPi(bcx, p, [0u, abi::slice_elt_len])); ret lval_temp(bcx, p); } @@ -2832,9 +2831,9 @@ fn trans_call_inner(in_cx: block, fn_expr_ty: ty::t, ret_ty: ty::t, faddr = load_if_immediate(bcx, faddr, fn_expr_ty); } let pair = faddr; - faddr = GEPi(bcx, pair, [0, abi::fn_field_code]); + faddr = GEPi(bcx, pair, [0u, abi::fn_field_code]); faddr = Load(bcx, faddr); - let llclosure = GEPi(bcx, pair, [0, abi::fn_field_box]); + let llclosure = GEPi(bcx, pair, [0u, abi::fn_field_box]); Load(bcx, llclosure) } }; @@ -3010,14 +3009,13 @@ fn trans_tup(bcx: block, elts: [@ast::expr], dest: dest) -> block { save_in(pos) { pos } _ { bcx.tcx().sess.bug("trans_tup: weird dest"); } }; - let mut temp_cleanups = [], i = 0; - for vec::each(elts) {|e| - let dst = GEPi(bcx, addr, [0, i]); + let mut temp_cleanups = []; + for vec::eachi(elts) {|i, e| + let dst = GEPi(bcx, addr, [0u, i]); let e_ty = expr_ty(bcx, e); bcx = trans_expr_save_in(bcx, e, dst); add_clean_temp_mem(bcx, dst, e_ty); temp_cleanups += [dst]; - i += 1; } for vec::each(temp_cleanups) {|cleanup| revoke_clean(bcx, cleanup); } ret bcx; @@ -3046,7 +3044,7 @@ fn trans_rec(bcx: block, fields: [ast::field], let ix = option::get(vec::position(ty_fields, {|ft| str::eq(fld.node.ident, ft.ident) })); - let dst = GEPi(bcx, addr, [0, ix as int]); + let dst = GEPi(bcx, addr, [0u, ix]); bcx = trans_expr_save_in(bcx, fld.node.expr, dst); add_clean_temp_mem(bcx, dst, ty_fields[ix].mt.ty); temp_cleanups += [dst]; @@ -3054,17 +3052,15 @@ fn trans_rec(bcx: block, fields: [ast::field], alt base { some(bexp) { let {bcx: cx, val: base_val} = trans_temp_expr(bcx, bexp); - let mut i = 0; bcx = cx; // Copy over inherited fields - for ty_fields.each {|tf| + for ty_fields.eachi {|i, tf| if !vec::any(fields, {|f| str::eq(f.node.ident, tf.ident)}) { - let dst = GEPi(bcx, addr, [0, i]); - let base = GEPi(bcx, base_val, [0, i]); + let dst = GEPi(bcx, addr, [0u, i]); + let base = GEPi(bcx, base_val, [0u, i]); let val = load_if_immediate(bcx, base, tf.mt.ty); bcx = copy_val(bcx, INIT, dst, val, tf.mt.ty); } - i += 1; } } none {} @@ -4199,9 +4195,9 @@ fn trans_res_ctor(ccx: @crate_ctxt, path: path, dtor: ast::fn_decl, }; let llretptr = fcx.llretptr; - let dst = GEPi(bcx, llretptr, [0, 1]); + let dst = GEPi(bcx, llretptr, [0u, 1u]); memmove_ty(bcx, dst, arg, arg_t); - let flag = GEPi(bcx, llretptr, [0, 0]); + let flag = GEPi(bcx, llretptr, [0u, 0u]); let one = C_u8(1u); Store(bcx, one, flag); build_return(bcx); @@ -4238,14 +4234,13 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id, } else { let llenumptr = PointerCast(bcx, fcx.llretptr, T_opaque_enum_ptr(ccx)); - let lldiscrimptr = GEPi(bcx, llenumptr, [0, 0]); + let lldiscrimptr = GEPi(bcx, llenumptr, [0u, 0u]); Store(bcx, C_int(ccx, disr), lldiscrimptr); - GEPi(bcx, llenumptr, [0, 1]) + GEPi(bcx, llenumptr, [0u, 1u]) }; - let mut i = 0u; let t_id = local_def(enum_id); let v_id = local_def(variant.node.id); - for vec::each(variant.node.args) {|va| + for vec::eachi(variant.node.args) {|i, va| let lldestptr = GEP_enum(bcx, llblobptr, t_id, v_id, ty_param_substs, i); // If this argument to this function is a enum, it'll have come in to @@ -4256,7 +4251,6 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id, }; let arg_ty = arg_tys[i].ty; memmove_ty(bcx, lldestptr, llarg, arg_ty); - i += 1u; } build_return(bcx); finish_fn(fcx, lltop); @@ -4433,7 +4427,7 @@ fn trans_class_ctor(ccx: @crate_ctxt, path: path, decl: ast::fn_decl, // drop their LHS for fields.each {|field| let ix = field_idx_strict(bcx.tcx(), sp, field.ident, fields); - bcx = zero_alloca(bcx, GEPi(bcx, selfptr, [0, ix]), + bcx = zero_alloca(bcx, GEPi(bcx, selfptr, [0u, ix]), field.mt.ty); } @@ -4673,9 +4667,9 @@ fn create_real_fn_pair(cx: block, llfnty: TypeRef, llfn: ValueRef, fn fill_fn_pair(bcx: block, pair: ValueRef, llfn: ValueRef, llenvptr: ValueRef) { let ccx = bcx.ccx(); - let code_cell = GEPi(bcx, pair, [0, abi::fn_field_code]); + let code_cell = GEPi(bcx, pair, [0u, abi::fn_field_code]); Store(bcx, llfn, code_cell); - let env_cell = GEPi(bcx, pair, [0, abi::fn_field_box]); + let env_cell = GEPi(bcx, pair, [0u, abi::fn_field_box]); let llenvblobptr = PointerCast(bcx, llenvptr, T_opaque_box_ptr(ccx)); Store(bcx, llenvblobptr, env_cell); } diff --git a/src/rustc/middle/trans/build.rs b/src/rustc/middle/trans/build.rs index c3c816ca4b9..6c2cd8b57de 100644 --- a/src/rustc/middle/trans/build.rs +++ b/src/rustc/middle/trans/build.rs @@ -427,7 +427,7 @@ fn GEP(cx: block, Pointer: ValueRef, Indices: [ValueRef]) -> ValueRef { // Simple wrapper around GEP that takes an array of ints and wraps them // in C_i32() -fn GEPi(cx: block, base: ValueRef, ixs: [int]) -> ValueRef { +fn GEPi(cx: block, base: ValueRef, ixs: [uint]) -> ValueRef { let mut v: [ValueRef] = []; for vec::each(ixs) {|i| v += [C_i32(i as i32)]; } count_insn(cx, "gepi"); diff --git a/src/rustc/middle/trans/closure.rs b/src/rustc/middle/trans/closure.rs index 36dfc3eb19c..706eee8e326 100644 --- a/src/rustc/middle/trans/closure.rs +++ b/src/rustc/middle/trans/closure.rs @@ -154,7 +154,7 @@ fn allocate_cbox(bcx: block, // Initialize ref count to arbitrary value for debugging: let ccx = bcx.ccx(); let box = PointerCast(bcx, box, T_opaque_box_ptr(ccx)); - let ref_cnt = GEPi(bcx, box, [0, abi::box_field_refcnt]); + let ref_cnt = GEPi(bcx, box, [0u, abi::box_field_refcnt]); let rc = C_int(ccx, 0x12345678); Store(bcx, rc, ref_cnt); } @@ -163,7 +163,7 @@ fn allocate_cbox(bcx: block, cdata_ty: ty::t, box: ValueRef, &ti: option<@tydesc_info>) -> block { - let bound_tydesc = GEPi(bcx, box, [0, abi::box_field_tydesc]); + let bound_tydesc = GEPi(bcx, box, [0u, abi::box_field_tydesc]); let td = base::get_tydesc(bcx.ccx(), cdata_ty, ti); Store(bcx, td, bound_tydesc); bcx @@ -243,8 +243,7 @@ fn store_environment(bcx: block, } let bound_data = GEPi(bcx, llbox, - [0, abi::box_field_body, - abi::closure_body_bindings, i as int]); + [0u, abi::box_field_body, abi::closure_body_bindings, i]); alt bv { env_expr(e, _) { bcx = base::trans_expr_save_in(bcx, e, bound_data); @@ -353,28 +352,28 @@ fn load_environment(fcx: fn_ctxt, let llcdata = base::opaque_box_body(bcx, cdata_ty, fcx.llenv); // Populate the upvars from the environment. - let mut i = 0; + let mut i = 0u; vec::iter(cap_vars) { |cap_var| alt cap_var.mode { capture::cap_drop { /* ignore */ } _ { let mut upvarptr = - GEPi(bcx, llcdata, [0, abi::closure_body_bindings, i]); + GEPi(bcx, llcdata, [0u, abi::closure_body_bindings, i]); alt ck { ty::ck_block { upvarptr = Load(bcx, upvarptr); } ty::ck_uniq | ty::ck_box { } } let def_id = ast_util::def_id_of_def(cap_var.def); fcx.llupvars.insert(def_id.node, upvarptr); - i += 1; + i += 1u; } } } if load_ret_handle { let flagptr = Load(bcx, GEPi(bcx, llcdata, - [0, abi::closure_body_bindings, i])); + [0u, abi::closure_body_bindings, i])); let retptr = Load(bcx, GEPi(bcx, llcdata, - [0, abi::closure_body_bindings, i+1])); + [0u, abi::closure_body_bindings, i+1u])); fcx.loop_ret = some({flagptr: flagptr, retptr: retptr}); } } @@ -510,7 +509,7 @@ fn make_fn_glue( let tcx = cx.tcx(); let fn_env = fn@(ck: ty::closure_kind) -> block { - let box_cell_v = GEPi(cx, v, [0, abi::fn_field_box]); + let box_cell_v = GEPi(cx, v, [0u, abi::fn_field_box]); let box_ptr_v = Load(cx, box_cell_v); with_cond(cx, IsNotNull(cx, box_ptr_v)) {|bcx| let closure_ty = ty::mk_opaque_closure_ptr(tcx, ck); @@ -548,10 +547,10 @@ fn make_opaque_cbox_take_glue( with_cond(bcx, IsNotNull(bcx, cbox_in)) {|bcx| // Load the size from the type descr found in the cbox let cbox_in = PointerCast(bcx, cbox_in, llopaquecboxty); - let tydescptr = GEPi(bcx, cbox_in, [0, abi::box_field_tydesc]); + let tydescptr = GEPi(bcx, cbox_in, [0u, abi::box_field_tydesc]); let tydesc = Load(bcx, tydescptr); let tydesc = PointerCast(bcx, tydesc, T_ptr(ccx.tydesc_type)); - let sz = Load(bcx, GEPi(bcx, tydesc, [0, abi::tydesc_field_size])); + let sz = Load(bcx, GEPi(bcx, tydesc, [0u, abi::tydesc_field_size])); // Adjust sz to account for the rust_opaque_box header fields let sz = Add(bcx, sz, shape::llsize_of(ccx, T_box_header(ccx))); @@ -564,12 +563,12 @@ fn make_opaque_cbox_take_glue( Store(bcx, cbox_out, cboxptr); // Take the (deeply cloned) type descriptor - let tydesc_out = GEPi(bcx, cbox_out, [0, abi::box_field_tydesc]); + let tydesc_out = GEPi(bcx, cbox_out, [0u, abi::box_field_tydesc]); let bcx = take_ty(bcx, tydesc_out, ty::mk_type(tcx)); // Take the data in the tuple let ti = none; - let cdata_out = GEPi(bcx, cbox_out, [0, abi::box_field_body]); + let cdata_out = GEPi(bcx, cbox_out, [0u, abi::box_field_body]); call_tydesc_glue_full(bcx, cdata_out, tydesc, abi::tydesc_field_take_glue, ti); bcx @@ -611,13 +610,13 @@ fn make_opaque_cbox_free_glue( // Load the type descr found in the cbox let lltydescty = T_ptr(ccx.tydesc_type); let cbox = PointerCast(bcx, cbox, T_opaque_cbox_ptr(ccx)); - let tydescptr = GEPi(bcx, cbox, [0, abi::box_field_tydesc]); + let tydescptr = GEPi(bcx, cbox, [0u, abi::box_field_tydesc]); let tydesc = Load(bcx, tydescptr); let tydesc = PointerCast(bcx, tydesc, lltydescty); // Drop the tuple data then free the descriptor let ti = none; - let cdata = GEPi(bcx, cbox, [0, abi::box_field_body]); + let cdata = GEPi(bcx, cbox, [0u, abi::box_field_body]); call_tydesc_glue_full(bcx, cdata, tydesc, abi::tydesc_field_drop_glue, ti); @@ -711,26 +710,26 @@ fn trans_bind_thunk(ccx: @crate_ctxt, // target function lives in the first binding spot. let (lltargetfn, lltargetenv, starting_idx) = alt target_info { target_static(fptr) { - (fptr, llvm::LLVMGetUndef(T_opaque_cbox_ptr(ccx)), 0) + (fptr, llvm::LLVMGetUndef(T_opaque_cbox_ptr(ccx)), 0u) } target_closure { - let pair = GEPi(bcx, llcdata, [0, abi::closure_body_bindings, 0]); + let pair = GEPi(bcx, llcdata, [0u, abi::closure_body_bindings, 0u]); let lltargetenv = - Load(bcx, GEPi(bcx, pair, [0, abi::fn_field_box])); + Load(bcx, GEPi(bcx, pair, [0u, abi::fn_field_box])); let lltargetfn = Load - (bcx, GEPi(bcx, pair, [0, abi::fn_field_code])); - (lltargetfn, lltargetenv, 1) + (bcx, GEPi(bcx, pair, [0u, abi::fn_field_code])); + (lltargetfn, lltargetenv, 1u) } target_self { let fptr = Load(bcx, GEPi(bcx, llcdata, - [0, abi::closure_body_bindings, 0])); - let slfbox = GEPi(bcx, llcdata, [0, abi::closure_body_bindings, 1]); - let selfptr = GEPi(bcx, Load(bcx, slfbox), [0, abi::box_field_body]); - (fptr, PointerCast(bcx, selfptr, T_opaque_cbox_ptr(ccx)), 2) + [0u, abi::closure_body_bindings, 0u])); + let slfbox = GEPi(bcx, llcdata, [0u, abi::closure_body_bindings, 1u]); + let selfptr = GEPi(bcx, Load(bcx, slfbox), [0u, abi::box_field_body]); + (fptr, PointerCast(bcx, selfptr, T_opaque_cbox_ptr(ccx)), 2u) } target_static_self(fptr) { - let slfptr = GEPi(bcx, llcdata, [0, abi::closure_body_bindings, 0]); - (fptr, PointerCast(bcx, slfptr, T_opaque_cbox_ptr(ccx)), 1) + let slfptr = GEPi(bcx, llcdata, [0u, abi::closure_body_bindings, 0u]); + (fptr, PointerCast(bcx, slfptr, T_opaque_cbox_ptr(ccx)), 1u) } }; @@ -744,7 +743,7 @@ fn trans_bind_thunk(ccx: @crate_ctxt, let mut llargs: [ValueRef] = [fcx.llretptr, lltargetenv]; let mut a: uint = first_real_arg; // retptr, env come first - let mut b: int = starting_idx; + let mut b: uint = starting_idx; let mut outgoing_arg_index: uint = 0u; for vec::each(args) {|arg| let out_arg = outgoing_args[outgoing_arg_index]; @@ -753,7 +752,7 @@ fn trans_bind_thunk(ccx: @crate_ctxt, // closure. some(e) { let mut val = - GEPi(bcx, llcdata, [0, abi::closure_body_bindings, b]); + GEPi(bcx, llcdata, [0u, abi::closure_body_bindings, b]); alt ty::resolved_mode(tcx, out_arg.mode) { ast::by_val { @@ -768,7 +767,7 @@ fn trans_bind_thunk(ccx: @crate_ctxt, ast::by_ref | ast::by_mutbl_ref | ast::by_move { } } llargs += [val]; - b += 1; + b += 1u; } // Arg will be provided when the thunk is invoked. diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index ac30135f6f2..d71773a138d 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -552,11 +552,11 @@ fn T_task(targ_cfg: @session::config) -> TypeRef { ret t; } -fn T_tydesc_field(cx: @crate_ctxt, field: int) -> TypeRef unsafe { +fn T_tydesc_field(cx: @crate_ctxt, field: uint) -> TypeRef unsafe { // Bit of a kludge: pick the fn typeref out of the tydesc.. let tydesc_elts: [TypeRef] = - vec::from_elem::(abi::n_tydesc_fields as uint, + vec::from_elem::(abi::n_tydesc_fields, T_nil()); llvm::LLVMGetStructElementTypes(cx.tydesc_type, to_ptr::(tydesc_elts)); @@ -902,12 +902,12 @@ fn node_id_type_params(bcx: block, id: ast::node_id) -> [ty::t] { fn field_idx_strict(cx: ty::ctxt, sp: span, ident: ast::ident, fields: [ty::field]) - -> int { + -> uint { alt ty::field_idx(ident, fields) { - none { cx.sess.span_bug(sp, #fmt("base expr doesn't appear to \ - have a field named %s", ident)); } - some(i) { i as int } - } + none { cx.sess.span_bug(sp, #fmt("base expr doesn't appear to \ + have a field named %s", ident)); } + some(i) { i } + } } fn dummy_substs(tps: [ty::t]) -> ty::substs { diff --git a/src/rustc/middle/trans/impl.rs b/src/rustc/middle/trans/impl.rs index b511d653bdf..5f50bb283a1 100644 --- a/src/rustc/middle/trans/impl.rs +++ b/src/rustc/middle/trans/impl.rs @@ -78,7 +78,7 @@ fn trans_vtable_callee(bcx: block, env: callee_env, vtable: ValueRef, let llfty = type_of::type_of_fn_from_ty(ccx, fty); let vtable = PointerCast(bcx, vtable, T_ptr(T_array(T_ptr(llfty), n_method + 1u))); - let mptr = Load(bcx, GEPi(bcx, vtable, [0, n_method as int])); + let mptr = Load(bcx, GEPi(bcx, vtable, [0u, n_method])); {bcx: bcx, val: mptr, kind: owned, env: env} } @@ -153,11 +153,11 @@ fn trans_iface_callee(bcx: block, base: @ast::expr, -> lval_maybe_callee { let _icx = bcx.insn_ctxt("impl::trans_iface_callee"); let {bcx, val} = trans_temp_expr(bcx, base); - let vtable = Load(bcx, PointerCast(bcx, GEPi(bcx, val, [0, 0]), + let vtable = Load(bcx, PointerCast(bcx, GEPi(bcx, val, [0u, 0u]), T_ptr(T_ptr(T_vtable())))); - let box = Load(bcx, GEPi(bcx, val, [0, 1])); + let box = Load(bcx, GEPi(bcx, val, [0u, 1u])); // FIXME[impl] I doubt this is alignment-safe - let self = GEPi(bcx, box, [0, abi::box_field_body]); + let self = GEPi(bcx, box, [0u, abi::box_field_body]); let env = self_env(self, ty::mk_opaque_box(bcx.tcx()), some(box)); trans_vtable_callee(bcx, env, vtable, callee_id, n_method) } @@ -282,12 +282,12 @@ fn trans_cast(bcx: block, val: @ast::expr, id: ast::node_id, dest: dest) let bcx = trans_expr_save_in(bcx, val, body); revoke_clean(bcx, box); let result = get_dest_addr(dest); - Store(bcx, box, PointerCast(bcx, GEPi(bcx, result, [0, 1]), + Store(bcx, box, PointerCast(bcx, GEPi(bcx, result, [0u, 1u]), T_ptr(val_ty(box)))); let orig = ccx.maps.vtable_map.get(id)[0]; let orig = resolve_vtable_in_fn_ctxt(bcx.fcx, orig); let vtable = get_vtable(bcx.ccx(), orig); - Store(bcx, vtable, PointerCast(bcx, GEPi(bcx, result, [0, 0]), + Store(bcx, vtable, PointerCast(bcx, GEPi(bcx, result, [0u, 0u]), T_ptr(val_ty(vtable)))); bcx } diff --git a/src/rustc/middle/trans/native.rs b/src/rustc/middle/trans/native.rs index a6a2d3aed3c..77e3a1f3067 100644 --- a/src/rustc/middle/trans/native.rs +++ b/src/rustc/middle/trans/native.rs @@ -599,7 +599,7 @@ fn trans_native_mod(ccx: @crate_ctxt, let mut atys = x86_64.arg_tys; let mut attrs = x86_64.attrs; if x86_64.sret { - let llretptr = GEPi(bcx, llargbundle, [0, n as int]); + let llretptr = GEPi(bcx, llargbundle, [0u, n]); let llretloc = Load(bcx, llretptr); llargvals = [llretloc]; atys = vec::tail(atys); @@ -608,14 +608,14 @@ fn trans_native_mod(ccx: @crate_ctxt, while i < n { let llargval = if atys[i].cast { let arg_ptr = GEPi(bcx, llargbundle, - [0, i as int]); + [0u, i]); let arg_ptr = BitCast(bcx, arg_ptr, T_ptr(atys[i].ty)); Load(bcx, arg_ptr) } else if option::is_some(attrs[i]) { - GEPi(bcx, llargbundle, [0, i as int]) + GEPi(bcx, llargbundle, [0u, i]) } else { - load_inbounds(bcx, llargbundle, [0, i as int]) + load_inbounds(bcx, llargbundle, [0u, i]) }; llargvals += [llargval]; i += 1u; @@ -624,7 +624,7 @@ fn trans_native_mod(ccx: @crate_ctxt, _ { while i < n { let llargval = load_inbounds(bcx, llargbundle, - [0, i as int]); + [0u, i]); llargvals += [llargval]; i += 1u; } @@ -652,7 +652,7 @@ fn trans_native_mod(ccx: @crate_ctxt, ret; } let n = vec::len(tys.arg_tys); - let llretptr = GEPi(bcx, llargbundle, [0, n as int]); + let llretptr = GEPi(bcx, llargbundle, [0u, n]); let llretloc = Load(bcx, llretptr); if x86_64.ret_ty.cast { let tmp_ptr = BitCast(bcx, llretloc, @@ -666,7 +666,7 @@ fn trans_native_mod(ccx: @crate_ctxt, if tys.ret_def { let n = vec::len(tys.arg_tys); // R** llretptr = &args->r; - let llretptr = GEPi(bcx, llargbundle, [0, n as int]); + let llretptr = GEPi(bcx, llargbundle, [0u, n]); // R* llretloc = *llretptr; /* (args->r) */ let llretloc = Load(bcx, llretptr); // *args->r = r; @@ -736,11 +736,11 @@ fn trans_native_mod(ccx: @crate_ctxt, let implicit_args = first_real_arg; // ret + env while i < n { let llargval = get_param(llwrapfn, i + implicit_args); - store_inbounds(bcx, llargval, llargbundle, [0, i as int]); + store_inbounds(bcx, llargval, llargbundle, [0u, i]); i += 1u; } let llretptr = get_param(llwrapfn, 0u); - store_inbounds(bcx, llretptr, llargbundle, [0, n as int]); + store_inbounds(bcx, llretptr, llargbundle, [0u, n]); } fn build_ret(bcx: block, _tys: @c_stack_tys, @@ -868,12 +868,12 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, let mut llargvals = []; let mut i = 0u; let n = vec::len(tys.arg_tys); - let llretptr = load_inbounds(bcx, llargbundle, [0, n as int]); + let llretptr = load_inbounds(bcx, llargbundle, [0u, n]); llargvals += [llretptr]; let llenvptr = C_null(T_opaque_box_ptr(bcx.ccx())); llargvals += [llenvptr]; while i < n { - let llargval = load_inbounds(bcx, llargbundle, [0, i as int]); + let llargval = load_inbounds(bcx, llargbundle, [0u, i]); llargvals += [llargval]; i += 1u; } @@ -924,33 +924,28 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, let mut argval = get_param(llwrapfn, i + j); if option::is_some(attrs[i]) { argval = Load(bcx, argval); - store_inbounds(bcx, argval, llargbundle, - [0, i as int]); + store_inbounds(bcx, argval, llargbundle, [0u, i]); } else if atys[i].cast { - let argptr = GEPi(bcx, llargbundle, - [0, i as int]); + let argptr = GEPi(bcx, llargbundle, [0u, i]); let argptr = BitCast(bcx, argptr, T_ptr(atys[i].ty)); Store(bcx, argval, argptr); } else { - store_inbounds(bcx, argval, llargbundle, - [0, i as int]); + store_inbounds(bcx, argval, llargbundle, [0u, i]); } i += 1u; } - store_inbounds(bcx, llretptr, llargbundle, [0, n as int]); + store_inbounds(bcx, llretptr, llargbundle, [0u, n]); } _ { let llretptr = alloca(bcx, tys.ret_ty); - let mut i = 0u; let n = vec::len(tys.arg_tys); - while i < n { + uint::range(0u, n) {|i| let llargval = get_param(llwrapfn, i); store_inbounds(bcx, llargval, llargbundle, - [0, i as int]); - i += 1u; - } - store_inbounds(bcx, llretptr, llargbundle, [0, n as int]); + [0u, i]); + }; + store_inbounds(bcx, llretptr, llargbundle, [0u, n]); } } } @@ -965,8 +960,7 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, ret; } let n = vec::len(tys.arg_tys); - let llretval = load_inbounds(bcx, llargbundle, - [0, n as int]); + let llretval = load_inbounds(bcx, llargbundle, [0u, n]); let llretval = if x86_64.ret_ty.cast { let retptr = BitCast(bcx, llretval, T_ptr(x86_64.ret_ty.ty)); @@ -978,8 +972,7 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, } _ { let n = vec::len(tys.arg_tys); - let llretval = load_inbounds(bcx, llargbundle, - [0, n as int]); + let llretval = load_inbounds(bcx, llargbundle, [0u, n]); let llretval = Load(bcx, llretval); Ret(bcx, llretval); } diff --git a/src/rustc/middle/trans/tvec.rs b/src/rustc/middle/trans/tvec.rs index e41e8665cd8..bcc5bbc3fa0 100644 --- a/src/rustc/middle/trans/tvec.rs +++ b/src/rustc/middle/trans/tvec.rs @@ -13,18 +13,18 @@ import common::*; fn get_fill(bcx: block, vptr: ValueRef) -> ValueRef { let _icx = bcx.insn_ctxt("tvec::get_fill"); - Load(bcx, GEPi(bcx, vptr, [0, abi::vec_elt_fill])) + Load(bcx, GEPi(bcx, vptr, [0u, abi::vec_elt_fill])) } fn set_fill(bcx: block, vptr: ValueRef, fill: ValueRef) { - Store(bcx, fill, GEPi(bcx, vptr, [0, abi::vec_elt_fill])); + Store(bcx, fill, GEPi(bcx, vptr, [0u, abi::vec_elt_fill])); } fn get_alloc(bcx: block, vptr: ValueRef) -> ValueRef { - Load(bcx, GEPi(bcx, vptr, [0, abi::vec_elt_alloc])) + Load(bcx, GEPi(bcx, vptr, [0u, abi::vec_elt_alloc])) } fn get_dataptr(bcx: block, vptr: ValueRef, unit_ty: TypeRef) -> ValueRef { let _icx = bcx.insn_ctxt("tvec::get_dataptr"); - let ptr = GEPi(bcx, vptr, [0, abi::vec_elt_elems]); + let ptr = GEPi(bcx, vptr, [0u, abi::vec_elt_elems]); PointerCast(bcx, ptr, T_ptr(unit_ty)) } @@ -41,8 +41,8 @@ fn alloc_uniq_raw(bcx: block, fill: ValueRef, alloc: ValueRef) -> result { let llvecty = ccx.opaque_vec_type; let vecsize = Add(bcx, alloc, llsize_of(ccx, llvecty)); let vecptr = shared_malloc(bcx, T_ptr(llvecty), vecsize); - Store(bcx, fill, GEPi(bcx, vecptr, [0, abi::vec_elt_fill])); - Store(bcx, alloc, GEPi(bcx, vecptr, [0, abi::vec_elt_alloc])); + Store(bcx, fill, GEPi(bcx, vecptr, [0u, abi::vec_elt_fill])); + Store(bcx, alloc, GEPi(bcx, vecptr, [0u, abi::vec_elt_alloc])); ret {bcx: bcx, val: vecptr}; } @@ -69,7 +69,7 @@ fn duplicate_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> result { let newptr = shared_malloc(bcx, val_ty(vptr), size); call_memmove(bcx, newptr, vptr, size); let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty); - Store(bcx, fill, GEPi(bcx, newptr, [0, abi::vec_elt_alloc])); + Store(bcx, fill, GEPi(bcx, newptr, [0u, abi::vec_elt_alloc])); let bcx = if ty::type_needs_drop(bcx.tcx(), unit_ty) { iter_vec(bcx, newptr, vec_ty, base::take_ty) } else { bcx }; @@ -127,8 +127,8 @@ fn trans_evec(bcx: block, args: [@ast::expr], let p = base::alloca(bcx, T_struct([T_ptr(llunitty), ccx.int_type])); - Store(bcx, vp, GEPi(bcx, p, [0, abi::slice_elt_base])); - Store(bcx, len, GEPi(bcx, p, [0, abi::slice_elt_len])); + Store(bcx, vp, GEPi(bcx, p, [0u, abi::slice_elt_base])); + Store(bcx, len, GEPi(bcx, p, [0u, abi::slice_elt_len])); {bcx: bcx, val: p, dataptr: vp} } @@ -205,14 +205,14 @@ fn get_base_and_len(cx: block, v: ValueRef, e_ty: ty::t) alt vstore { ty::vstore_fixed(n) { - let base = GEPi(cx, v, [0, 0]); + let base = GEPi(cx, v, [0u, 0u]); let n = if ty::type_is_str(e_ty) { n + 1u } else { n }; let len = Mul(cx, C_uint(ccx, n), unit_sz); (base, len) } ty::vstore_slice(_) { - let base = Load(cx, GEPi(cx, v, [0, abi::slice_elt_base])); - let len = Load(cx, GEPi(cx, v, [0, abi::slice_elt_len])); + let base = Load(cx, GEPi(cx, v, [0u, abi::slice_elt_base])); + let len = Load(cx, GEPi(cx, v, [0u, abi::slice_elt_len])); (base, len) } ty::vstore_uniq {