diff options
Diffstat (limited to 'src/comp/middle')
| -rw-r--r-- | src/comp/middle/debuginfo.rs | 4 | ||||
| -rw-r--r-- | src/comp/middle/trans.rs | 61 | ||||
| -rw-r--r-- | src/comp/middle/trans_build.rs | 59 | ||||
| -rw-r--r-- | src/comp/middle/trans_closure.rs | 4 | ||||
| -rw-r--r-- | src/comp/middle/trans_common.rs | 48 | ||||
| -rw-r--r-- | src/comp/middle/trans_impl.rs | 19 |
6 files changed, 106 insertions, 89 deletions
diff --git a/src/comp/middle/debuginfo.rs b/src/comp/middle/debuginfo.rs index 938fcac52d3..821858465c3 100644 --- a/src/comp/middle/debuginfo.rs +++ b/src/comp/middle/debuginfo.rs @@ -46,7 +46,7 @@ const DW_ATE_unsigned_char: int = 0x08; fn llstr(s: str) -> ValueRef { str::as_buf(s, {|sbuf| - llvm::LLVMMDString(sbuf, str::byte_len(s)) + llvm::LLVMMDString(sbuf, str::byte_len(s) as u32) }) } fn lltag(lltag: int) -> ValueRef { @@ -63,7 +63,7 @@ fn lli1(bval: bool) -> ValueRef { } fn llmdnode(elems: [ValueRef]) -> ValueRef unsafe { llvm::LLVMMDNode(vec::unsafe::to_ptr(elems), - vec::len(elems)) + vec::len(elems) as u32) } fn llunused() -> ValueRef { lli32(0x0) diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index f709ddb56bd..b6a34a6177b 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -13,6 +13,7 @@ // but many TypeRefs correspond to one ty::t; for instance, tup(int, int, // int) and rec(x=int, y=int, z=int) will have the same TypeRef. +import core::ctypes::c_uint; import std::{map, time}; import std::map::hashmap; import std::map::{new_int_hash, new_str_hash}; @@ -292,11 +293,12 @@ fn log_fn_time(ccx: @crate_ctxt, name: str, start: time::timeval, } -fn decl_fn(llmod: ModuleRef, name: str, cc: uint, llty: TypeRef) -> ValueRef { +fn decl_fn(llmod: ModuleRef, name: str, cc: uint, llty: TypeRef) -> + ValueRef { let llfn: ValueRef = str::as_buf(name, {|buf| llvm::LLVMGetOrInsertFunction(llmod, buf, llty) }); - llvm::LLVMSetFunctionCallConv(llfn, cc); + llvm::LLVMSetFunctionCallConv(llfn, cc as c_uint); ret llfn; } @@ -339,7 +341,8 @@ fn get_simple_extern_fn(cx: @block_ctxt, let inputs = vec::init_elt::<TypeRef>(ccx.int_type, n_args as uint); let output = ccx.int_type; let t = T_fn(inputs, output); - ret get_extern_fn(externs, llmod, name, lib::llvm::LLVMCCallConv, t); + ret get_extern_fn(externs, llmod, name, + lib::llvm::LLVMCCallConv, t); } fn trans_native_call(cx: @block_ctxt, externs: hashmap<str, ValueRef>, @@ -390,12 +393,12 @@ fn align_to(cx: @block_ctxt, off: ValueRef, align: ValueRef) -> ValueRef { // Returns the real size of the given type for the current target. fn llsize_of_real(cx: @crate_ctxt, t: TypeRef) -> uint { - ret llvm::LLVMStoreSizeOfType(cx.td.lltd, t); + ret llvm::LLVMStoreSizeOfType(cx.td.lltd, t) as uint; } // Returns the real alignment of the given type for the current target. fn llalign_of_real(cx: @crate_ctxt, t: TypeRef) -> uint { - ret llvm::LLVMPreferredAlignmentOfType(cx.td.lltd, t); + ret llvm::LLVMPreferredAlignmentOfType(cx.td.lltd, t) as uint; } fn llsize_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef { @@ -1070,7 +1073,7 @@ fn set_no_inline(f: ValueRef) { llvm::LLVMAddFunctionAttr(f, lib::llvm::LLVMNoInlineAttribute as lib::llvm::llvm::Attribute, - 0u); + 0u32); } // Tell LLVM to emit the information necessary to unwind the stack for the @@ -1079,19 +1082,19 @@ fn set_uwtable(f: ValueRef) { llvm::LLVMAddFunctionAttr(f, lib::llvm::LLVMUWTableAttribute as lib::llvm::llvm::Attribute, - 0u); + 0u32); } fn set_always_inline(f: ValueRef) { llvm::LLVMAddFunctionAttr(f, lib::llvm::LLVMAlwaysInlineAttribute as lib::llvm::llvm::Attribute, - 0u); + 0u32); } fn set_custom_stack_growth_fn(f: ValueRef) { // TODO: Remove this hack to work around the lack of u64 in the FFI. - llvm::LLVMAddFunctionAttr(f, 0 as lib::llvm::llvm::Attribute, 1u); + llvm::LLVMAddFunctionAttr(f, 0 as lib::llvm::llvm::Attribute, 1u32); } fn set_glue_inlining(cx: @local_ctxt, f: ValueRef, t: ty::t) { @@ -1178,7 +1181,7 @@ fn make_generic_glue_inner(cx: @local_ctxt, sp: span, t: ty::t, } else { T_ptr(T_i8()) }; let ty_param_count = vec::len::<uint>(ty_params); - let lltyparams = llvm::LLVMGetParam(llfn, 2u); + let lltyparams = llvm::LLVMGetParam(llfn, 2u32); let load_env_bcx = new_raw_block_ctxt(fcx, fcx.llloadenv); let lltydescs = [mutable]; let p = 0u; @@ -1193,7 +1196,7 @@ fn make_generic_glue_inner(cx: @local_ctxt, sp: span, t: ty::t, let bcx = new_top_block_ctxt(fcx); let lltop = bcx.llbb; - let llrawptr0 = llvm::LLVMGetParam(llfn, 3u); + let llrawptr0 = llvm::LLVMGetParam(llfn, 3u32); let llval0 = BitCast(bcx, llrawptr0, llty); helper(bcx, llval0, t); finish_fn(fcx, lltop); @@ -4300,8 +4303,8 @@ fn new_fn_ctxt_w_id(cx: @local_ctxt, sp: span, llfndecl: ValueRef, -> @fn_ctxt { let llbbs = mk_standard_basic_blocks(llfndecl); ret @{llfn: llfndecl, - llenv: llvm::LLVMGetParam(llfndecl, 1u), - llretptr: llvm::LLVMGetParam(llfndecl, 0u), + llenv: llvm::LLVMGetParam(llfndecl, 1u32), + llretptr: llvm::LLVMGetParam(llfndecl, 0u32), mutable llstaticallocas: llbbs.sa, mutable llloadenv: llbbs.ca, mutable llderivedtydescs_first: llbbs.dt, @@ -4344,7 +4347,7 @@ fn create_llargs_for_fn_args(cx: @fn_ctxt, ty_self: self_arg, // Skip the implicit arguments 0, and 1. TODO: Pull out 2u and define // it as a constant, since we're using it in several places in trans this // way. - let arg_n = 2u; + let arg_n = 2u32; alt ty_self { impl_self(tt) { cx.llself = some({v: cx.llenv, t: tt}); @@ -4353,12 +4356,12 @@ fn create_llargs_for_fn_args(cx: @fn_ctxt, ty_self: self_arg, } for tp in ty_params { let lltydesc = llvm::LLVMGetParam(cx.llfn, arg_n), dicts = none; - arg_n += 1u; + arg_n += 1u32; for bound in *fcx_tcx(cx).ty_param_bounds.get(tp.id) { alt bound { ty::bound_iface(_) { let dict = llvm::LLVMGetParam(cx.llfn, arg_n); - arg_n += 1u; + arg_n += 1u32; dicts = some(alt dicts { none. { [dict] } some(ds) { ds + [dict] } @@ -4379,7 +4382,7 @@ fn create_llargs_for_fn_args(cx: @fn_ctxt, ty_self: self_arg, // copy_args_to_allocas will overwrite the table entry with local_imm // before it's actually used. cx.llargs.insert(arg.id, local_mem(llarg)); - arg_n += 1u; + arg_n += 1u32; } } @@ -4798,7 +4801,7 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod, let fcx = new_fn_ctxt(lcx, span, llshimfn); let bcx = new_top_block_ctxt(fcx); let lltop = bcx.llbb; - let llargbundle = llvm::LLVMGetParam(llshimfn, 0u); + let llargbundle = llvm::LLVMGetParam(llshimfn, 0u32); let i = 0u, n = vec::len(tys.arg_tys); let llargvals = []; while i < n { @@ -4808,7 +4811,8 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod, } // Create the call itself and store the return value: - let llretval = CallWithConv(bcx, llbasefn, llargvals, cc); // r + let llretval = CallWithConv(bcx, llbasefn, + llargvals, cc as c_uint); // r if tys.ret_def { // R** llretptr = &args->r; let llretptr = GEPi(bcx, llargbundle, [0, n as int]); @@ -4842,11 +4846,12 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod, let i = 0u, n = vec::len(tys.arg_tys); let implicit_args = 2u + num_tps; // ret + env while i < n { - let llargval = llvm::LLVMGetParam(llwrapfn, i + implicit_args); + let llargval = llvm::LLVMGetParam(llwrapfn, + (i + implicit_args) as c_uint); store_inbounds(bcx, llargval, llargbundle, [0, i as int]); i += 1u; } - let llretptr = llvm::LLVMGetParam(llwrapfn, 0u); + let llretptr = llvm::LLVMGetParam(llwrapfn, 0u32); store_inbounds(bcx, llretptr, llargbundle, [0, n as int]); // Create call itself. @@ -4859,7 +4864,7 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod, } let ccx = lcx_ccx(lcx); - let cc: uint = lib::llvm::LLVMCCallConv; + let cc = lib::llvm::LLVMCCallConv; alt abi { ast::native_abi_rust_intrinsic. { ret; } ast::native_abi_cdecl. { cc = lib::llvm::LLVMCCallConv; } @@ -5031,10 +5036,10 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef, let bcx = new_top_block_ctxt(fcx); let lltop = bcx.llbb; - let lloutputarg = llvm::LLVMGetParam(llfdecl, 0u); - let llenvarg = llvm::LLVMGetParam(llfdecl, 1u); + let lloutputarg = llvm::LLVMGetParam(llfdecl, 0u32); + let llenvarg = llvm::LLVMGetParam(llfdecl, 1u32); let args = [lloutputarg, llenvarg]; - if takes_argv { args += [llvm::LLVMGetParam(llfdecl, 2u)]; } + if takes_argv { args += [llvm::LLVMGetParam(llfdecl, 2u32)]; } Call(bcx, main_llfn, args); build_return(bcx); @@ -5065,11 +5070,11 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef, let start = str::as_buf("rust_start", {|buf| llvm::LLVMAddGlobal(ccx.llmod, start_ty, buf) }); - let args = [rust_main, llvm::LLVMGetParam(llfn, 0u), - llvm::LLVMGetParam(llfn, 1u), crate_map]; + let args = [rust_main, llvm::LLVMGetParam(llfn, 0u32), + llvm::LLVMGetParam(llfn, 1u32), crate_map]; let result = unsafe { llvm::LLVMBuildCall(bld, start, vec::to_ptr(args), - vec::len(args), noname()) + vec::len(args) as c_uint, noname()) }; llvm::LLVMBuildRet(bld, result); } diff --git a/src/comp/middle/trans_build.rs b/src/comp/middle/trans_build.rs index a9d18fbd55a..8fa703c8f88 100644 --- a/src/comp/middle/trans_build.rs +++ b/src/comp/middle/trans_build.rs @@ -1,4 +1,5 @@ import core::{vec, str}; +import core::ctypes::c_uint; import str::sbuf; import lib::llvm::llvm; import syntax::codemap; @@ -42,7 +43,7 @@ fn AggregateRet(cx: @block_ctxt, RetVals: [ValueRef]) { cx.terminated = true; unsafe { llvm::LLVMBuildAggregateRet(B(cx), vec::to_ptr(RetVals), - vec::len(RetVals)); + vec::len(RetVals) as c_uint); } } @@ -66,7 +67,7 @@ fn Switch(cx: @block_ctxt, V: ValueRef, Else: BasicBlockRef, NumCases: uint) if cx.unreachable { ret _Undef(V); } assert !cx.terminated; cx.terminated = true; - ret llvm::LLVMBuildSwitch(B(cx), V, Else, NumCases); + ret llvm::LLVMBuildSwitch(B(cx), V, Else, NumCases as c_uint); } fn AddCase(S: ValueRef, OnVal: ValueRef, Dest: BasicBlockRef) { @@ -78,7 +79,7 @@ fn IndirectBr(cx: @block_ctxt, Addr: ValueRef, NumDests: uint) { if cx.unreachable { ret; } assert (!cx.terminated); cx.terminated = true; - llvm::LLVMBuildIndirectBr(B(cx), Addr, NumDests); + llvm::LLVMBuildIndirectBr(B(cx), Addr, NumDests as c_uint); } // This is a really awful way to get a zero-length c-string, but better (and a @@ -95,7 +96,7 @@ fn Invoke(cx: @block_ctxt, Fn: ValueRef, Args: [ValueRef], cx.terminated = true; unsafe { llvm::LLVMBuildInvoke(B(cx), Fn, vec::to_ptr(Args), - vec::len(Args), Then, Catch, + vec::len(Args) as c_uint, Then, Catch, noname()); } } @@ -107,8 +108,10 @@ fn FastInvoke(cx: @block_ctxt, Fn: ValueRef, Args: [ValueRef], cx.terminated = true; unsafe { let v = llvm::LLVMBuildInvoke(B(cx), Fn, vec::to_ptr(Args), - vec::len(Args), Then, Catch, noname()); - llvm::LLVMSetInstructionCallConv(v, lib::llvm::LLVMFastCallConv); + vec::len(Args) as c_uint, + Then, Catch, noname()); + llvm::LLVMSetInstructionCallConv( + v, lib::llvm::LLVMFastCallConv as c_uint); } } @@ -308,7 +311,7 @@ fn Load(cx: @block_ctxt, PointerVal: ValueRef) -> ValueRef { let ccx = cx.fcx.lcx.ccx; if cx.unreachable { let ty = val_ty(PointerVal); - let eltty = if llvm::LLVMGetTypeKind(ty) == 11 { + let eltty = if llvm::LLVMGetTypeKind(ty) == 11i32 { llvm::LLVMGetElementType(ty) } else { ccx.int_type }; ret llvm::LLVMGetUndef(eltty); } @@ -324,7 +327,7 @@ fn GEP(cx: @block_ctxt, Pointer: ValueRef, Indices: [ValueRef]) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); } unsafe { ret llvm::LLVMBuildGEP(B(cx), Pointer, vec::to_ptr(Indices), - vec::len(Indices), noname()); + vec::len(Indices) as c_uint, noname()); } } @@ -342,13 +345,14 @@ fn InBoundsGEP(cx: @block_ctxt, Pointer: ValueRef, Indices: [ValueRef]) -> unsafe { ret llvm::LLVMBuildInBoundsGEP(B(cx), Pointer, vec::to_ptr(Indices), - vec::len(Indices), noname()); + vec::len(Indices) as c_uint, + noname()); } } fn StructGEP(cx: @block_ctxt, Pointer: ValueRef, Idx: uint) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); } - ret llvm::LLVMBuildStructGEP(B(cx), Pointer, Idx, noname()); + ret llvm::LLVMBuildStructGEP(B(cx), Pointer, Idx as c_uint, noname()); } fn GlobalString(cx: @block_ctxt, _Str: sbuf) -> ValueRef { @@ -465,12 +469,12 @@ fn FPCast(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef { /* Comparisons */ fn ICmp(cx: @block_ctxt, Op: uint, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); } - ret llvm::LLVMBuildICmp(B(cx), Op, LHS, RHS, noname()); + ret llvm::LLVMBuildICmp(B(cx), Op as c_uint, LHS, RHS, noname()); } fn FCmp(cx: @block_ctxt, Op: uint, LHS: ValueRef, RHS: ValueRef) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); } - ret llvm::LLVMBuildFCmp(B(cx), Op, LHS, RHS, noname()); + ret llvm::LLVMBuildFCmp(B(cx), Op as c_uint, LHS, RHS, noname()); } /* Miscellaneous instructions */ @@ -486,7 +490,7 @@ fn Phi(cx: @block_ctxt, Ty: TypeRef, vals: [ValueRef], bbs: [BasicBlockRef]) let phi = EmptyPhi(cx, Ty); unsafe { llvm::LLVMAddIncoming(phi, vec::to_ptr(vals), vec::to_ptr(bbs), - vec::len(vals)); + vec::len(vals) as c_uint); ret phi; } } @@ -496,14 +500,14 @@ fn AddIncomingToPhi(phi: ValueRef, val: ValueRef, bb: BasicBlockRef) { unsafe { let valptr = unsafe::reinterpret_cast(ptr::addr_of(val)); let bbptr = unsafe::reinterpret_cast(ptr::addr_of(bb)); - llvm::LLVMAddIncoming(phi, valptr, bbptr, 1u); + llvm::LLVMAddIncoming(phi, valptr, bbptr, 1u32); } } fn _UndefReturn(cx: @block_ctxt, Fn: ValueRef) -> ValueRef { let ccx = cx.fcx.lcx.ccx; let ty = val_ty(Fn); - let retty = if llvm::LLVMGetTypeKind(ty) == 8 { + let retty = if llvm::LLVMGetTypeKind(ty) == 8i32 { llvm::LLVMGetReturnType(ty) } else { ccx.int_type }; ret llvm::LLVMGetUndef(retty); } @@ -535,7 +539,7 @@ fn Call(cx: @block_ctxt, Fn: ValueRef, Args: [ValueRef]) -> ValueRef { if cx.unreachable { ret _UndefReturn(cx, Fn); } unsafe { ret llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args), - vec::len(Args), noname()); + vec::len(Args) as c_uint, noname()); } } @@ -543,18 +547,19 @@ fn FastCall(cx: @block_ctxt, Fn: ValueRef, Args: [ValueRef]) -> ValueRef { if cx.unreachable { ret _UndefReturn(cx, Fn); } unsafe { let v = llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args), - vec::len(Args), noname()); - llvm::LLVMSetInstructionCallConv(v, lib::llvm::LLVMFastCallConv); + vec::len(Args) as c_uint, noname()); + llvm::LLVMSetInstructionCallConv( + v, lib::llvm::LLVMFastCallConv as c_uint); ret v; } } -fn CallWithConv(cx: @block_ctxt, Fn: ValueRef, Args: [ValueRef], Conv: uint) - -> ValueRef { +fn CallWithConv(cx: @block_ctxt, Fn: ValueRef, Args: [ValueRef], + Conv: c_uint) -> ValueRef { if cx.unreachable { ret _UndefReturn(cx, Fn); } unsafe { let v = llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args), - vec::len(Args), noname()); + vec::len(Args) as c_uint, noname()); llvm::LLVMSetInstructionCallConv(v, Conv); ret v; } @@ -591,13 +596,14 @@ fn ShuffleVector(cx: @block_ctxt, V1: ValueRef, V2: ValueRef, fn ExtractValue(cx: @block_ctxt, AggVal: ValueRef, Index: uint) -> ValueRef { if cx.unreachable { ret llvm::LLVMGetUndef(T_nil()); } - ret llvm::LLVMBuildExtractValue(B(cx), AggVal, Index, noname()); + ret llvm::LLVMBuildExtractValue(B(cx), AggVal, Index as c_uint, noname()); } fn InsertValue(cx: @block_ctxt, AggVal: ValueRef, EltVal: ValueRef, Index: uint) { if cx.unreachable { ret; } - llvm::LLVMBuildInsertValue(B(cx), AggVal, EltVal, Index, noname()); + llvm::LLVMBuildInsertValue(B(cx), AggVal, EltVal, Index as c_uint, + noname()); } fn IsNull(cx: @block_ctxt, Val: ValueRef) -> ValueRef { @@ -628,15 +634,16 @@ fn Trap(cx: @block_ctxt) { assert (T as int != 0); let Args: [ValueRef] = []; unsafe { - llvm::LLVMBuildCall(b, T, vec::to_ptr(Args), vec::len(Args), - noname()); + llvm::LLVMBuildCall(b, T, vec::to_ptr(Args), + vec::len(Args) as c_uint, noname()); } } fn LandingPad(cx: @block_ctxt, Ty: TypeRef, PersFn: ValueRef, NumClauses: uint) -> ValueRef { assert !cx.terminated && !cx.unreachable; - ret llvm::LLVMBuildLandingPad(B(cx), Ty, PersFn, NumClauses, noname()); + ret llvm::LLVMBuildLandingPad(B(cx), Ty, PersFn, + NumClauses as c_uint, noname()); } fn SetCleanup(_cx: @block_ctxt, LandingPad: ValueRef) { diff --git a/src/comp/middle/trans_closure.rs b/src/comp/middle/trans_closure.rs index 21e9a876866..61f7aec9997 100644 --- a/src/comp/middle/trans_closure.rs +++ b/src/comp/middle/trans_closure.rs @@ -918,7 +918,7 @@ fn trans_bind_thunk(cx: @local_ctxt, fcx.lltyparams += [{desc: dsc, dicts: dicts}]; } - let a: uint = 2u; // retptr, env come first + let a: u32 = 2u32; // retptr, env come first let b: int = starting_idx; let outgoing_arg_index: uint = 0u; let llout_arg_tys: [TypeRef] = @@ -960,7 +960,7 @@ fn trans_bind_thunk(cx: @local_ctxt, arg = PointerCast(bcx, arg, llout_arg_ty); } llargs += [arg]; - a += 1u; + a += 1u32; } } outgoing_arg_index += 1u; diff --git a/src/comp/middle/trans_common.rs b/src/comp/middle/trans_common.rs index 0368a4c7cdf..835f8cc5c5e 100644 --- a/src/comp/middle/trans_common.rs +++ b/src/comp/middle/trans_common.rs @@ -4,6 +4,7 @@ */ import core::{int, vec, str, uint, option, unsafe}; +import core::ctypes::unsigned; import vec::to_ptr; import std::map::hashmap; import option::some; @@ -410,7 +411,7 @@ fn val_str(tn: type_names, v: ValueRef) -> str { ret ty_str(tn, val_ty(v)); } // Returns the nth element of the given LLVM structure type. fn struct_elt(llstructty: TypeRef, n: uint) -> TypeRef unsafe { - let elt_count = llvm::LLVMCountStructElementTypes(llstructty); + let elt_count = llvm::LLVMCountStructElementTypes(llstructty) as uint; assert (n < elt_count); let elt_tys = vec::init_elt(T_nil(), elt_count); llvm::LLVMGetStructElementTypes(llstructty, to_ptr(elt_tys)); @@ -533,17 +534,20 @@ fn T_size_t(targ_cfg: @session::config) -> TypeRef { fn T_fn(inputs: [TypeRef], output: TypeRef) -> TypeRef unsafe { ret llvm::LLVMFunctionType(output, to_ptr(inputs), - vec::len::<TypeRef>(inputs), False); + vec::len::<TypeRef>(inputs) as unsigned, + False); } fn T_fn_pair(cx: @crate_ctxt, tfn: TypeRef) -> TypeRef { ret T_struct([T_ptr(tfn), T_opaque_cbox_ptr(cx)]); } -fn T_ptr(t: TypeRef) -> TypeRef { ret llvm::LLVMPointerType(t, 0u); } +fn T_ptr(t: TypeRef) -> TypeRef { + ret llvm::LLVMPointerType(t, 0u as unsigned); +} fn T_struct(elts: [TypeRef]) -> TypeRef unsafe { - ret llvm::LLVMStructType(to_ptr(elts), vec::len(elts), False); + ret llvm::LLVMStructType(to_ptr(elts), vec::len(elts) as unsigned, False); } fn T_named_struct(name: str) -> TypeRef { @@ -552,7 +556,8 @@ fn T_named_struct(name: str) -> TypeRef { } fn set_struct_body(t: TypeRef, elts: [TypeRef]) unsafe { - llvm::LLVMStructSetBody(t, to_ptr(elts), vec::len(elts), False); + llvm::LLVMStructSetBody(t, to_ptr(elts), + vec::len(elts) as unsigned, False); } fn T_empty_struct() -> TypeRef { ret T_struct([]); } @@ -634,7 +639,9 @@ fn T_tydesc(targ_cfg: @session::config) -> TypeRef { ret tydesc; } -fn T_array(t: TypeRef, n: uint) -> TypeRef { ret llvm::LLVMArrayType(t, n); } +fn T_array(t: TypeRef, n: uint) -> TypeRef { + ret llvm::LLVMArrayType(t, n as unsigned); +} // Interior vector. // @@ -739,8 +746,8 @@ fn T_opaque_chan_ptr() -> TypeRef { ret T_ptr(T_i8()); } fn C_null(t: TypeRef) -> ValueRef { ret llvm::LLVMConstNull(t); } fn C_integral(t: TypeRef, u: u64, sign_extend: Bool) -> ValueRef { - let u_hi = (u >> 32u64) as uint; - let u_lo = u as uint; + let u_hi = (u >> 32u64) as unsigned; + let u_lo = u as unsigned; ret llvm::LLVMRustConstInt(t, u_hi, u_lo, sign_extend); } @@ -782,11 +789,9 @@ fn C_u8(i: uint) -> ValueRef { ret C_integral(T_i8(), i as u64, False); } // This is a 'c-like' raw string, which differs from // our boxed-and-length-annotated strings. fn C_cstr(cx: @crate_ctxt, s: str) -> ValueRef { - let sc = - str::as_buf(s, - {|buf| - llvm::LLVMConstString(buf, str::byte_len(s), False) - }); + let sc = str::as_buf(s) {|buf| + llvm::LLVMConstString(buf, str::byte_len(s) as unsigned, False) + }; let g = str::as_buf(cx.names("str"), {|buf| llvm::LLVMAddGlobal(cx.llmod, val_ty(sc), buf) }); @@ -798,10 +803,9 @@ fn C_cstr(cx: @crate_ctxt, s: str) -> ValueRef { // Returns a Plain Old LLVM String: fn C_postr(s: str) -> ValueRef { - ret str::as_buf(s, - {|buf| - llvm::LLVMConstString(buf, str::byte_len(s), False) - }); + ret str::as_buf(s) {|buf| + llvm::LLVMConstString(buf, str::byte_len(s) as unsigned, False) + }; } fn C_zero_byte_arr(size: uint) -> ValueRef unsafe { @@ -809,28 +813,28 @@ fn C_zero_byte_arr(size: uint) -> ValueRef unsafe { let elts: [ValueRef] = []; while i < size { elts += [C_u8(0u)]; i += 1u; } ret llvm::LLVMConstArray(T_i8(), vec::to_ptr(elts), - vec::len(elts)); + vec::len(elts) as unsigned); } fn C_struct(elts: [ValueRef]) -> ValueRef unsafe { - ret llvm::LLVMConstStruct(vec::to_ptr(elts), vec::len(elts), + ret llvm::LLVMConstStruct(vec::to_ptr(elts), vec::len(elts) as unsigned, False); } fn C_named_struct(T: TypeRef, elts: [ValueRef]) -> ValueRef unsafe { ret llvm::LLVMConstNamedStruct(T, vec::to_ptr(elts), - vec::len(elts)); + vec::len(elts) as unsigned); } fn C_array(ty: TypeRef, elts: [ValueRef]) -> ValueRef unsafe { ret llvm::LLVMConstArray(ty, vec::to_ptr(elts), - vec::len(elts)); + vec::len(elts) as unsigned); } fn C_bytes(bytes: [u8]) -> ValueRef unsafe { ret llvm::LLVMConstString( unsafe::reinterpret_cast(vec::to_ptr(bytes)), - vec::len(bytes), False); + vec::len(bytes) as unsigned, False); } fn C_shape(ccx: @crate_ctxt, bytes: [u8]) -> ValueRef { diff --git a/src/comp/middle/trans_impl.rs b/src/comp/middle/trans_impl.rs index 634b5842839..f23f4a47353 100644 --- a/src/comp/middle/trans_impl.rs +++ b/src/comp/middle/trans_impl.rs @@ -138,7 +138,7 @@ fn trans_iface_callee(bcx: @block_ctxt, fld_expr: @ast::expr, fn llfn_arg_tys(ft: TypeRef) -> {inputs: [TypeRef], output: TypeRef} { let out_ty = llvm::LLVMGetReturnType(ft); let n_args = llvm::LLVMCountParamTypes(ft); - let args = vec::init_elt(0 as TypeRef, n_args); + let args = vec::init_elt(0 as TypeRef, n_args as uint); unsafe { llvm::LLVMGetParamTypes(ft, vec::to_ptr(args)); } {inputs: args, output: out_ty} } @@ -191,19 +191,20 @@ fn trans_impl_wrapper(ccx: @crate_ctxt, pt: [ast::ident], vec::slice(real_args, 2u + vec::len(extra_ptrs), vec::len(real_args)); let llfn_ty = T_fn(wrap_args, real_ret); trans_wrapper(ccx, pt, llfn_ty, {|llfn, bcx| - let dict = PointerCast(bcx, LLVMGetParam(llfn, 0u), env_ty); + let dict = PointerCast(bcx, LLVMGetParam(llfn, 0u32), env_ty); // retptr, self - let args = [LLVMGetParam(llfn, 1u), LLVMGetParam(llfn, 2u)], i = 0u; + let args = [LLVMGetParam(llfn, 1u32), LLVMGetParam(llfn, 2u32)]; + let i = 0u; // saved tydescs/dicts while i < n_extra_ptrs { i += 1u; args += [load_inbounds(bcx, dict, [0, i as int])]; } // the rest of the parameters - let i = 3u, params_total = llvm::LLVMCountParamTypes(llfn_ty); + let i = 3u32, params_total = llvm::LLVMCountParamTypes(llfn_ty); while i < params_total { args += [LLVMGetParam(llfn, i)]; - i += 1u; + i += 1u32; } Call(bcx, real_fn, args); bcx @@ -231,7 +232,7 @@ fn trans_iface_wrapper(ccx: @crate_ctxt, pt: [ast::ident], m: ty::method, n: uint) -> ValueRef { let {llty: llfty, _} = wrapper_fn_ty(ccx, T_ptr(T_i8()), m); trans_wrapper(ccx, pt, llfty, {|llfn, bcx| - let self = Load(bcx, PointerCast(bcx, LLVMGetParam(llfn, 2u), + let self = Load(bcx, PointerCast(bcx, LLVMGetParam(llfn, 2u32), T_ptr(T_opaque_iface_ptr(ccx)))); let boxed = GEPi(bcx, self, [0, abi::box_rc_field_body]); let dict = Load(bcx, PointerCast(bcx, GEPi(bcx, boxed, [0, 1]), @@ -242,12 +243,12 @@ fn trans_iface_wrapper(ccx: @crate_ctxt, pt: [ast::ident], m: ty::method, // FIXME[impl] This doesn't account for more-than-ptr-sized alignment let inner_self = GEPi(bcx, boxed, [0, 2]); let args = [PointerCast(bcx, dict, T_ptr(T_i8())), - LLVMGetParam(llfn, 1u), + LLVMGetParam(llfn, 1u32), PointerCast(bcx, inner_self, T_opaque_cbox_ptr(ccx))]; - let i = 3u, total = llvm::LLVMCountParamTypes(llfty); + let i = 3u32, total = llvm::LLVMCountParamTypes(llfty); while i < total { args += [LLVMGetParam(llfn, i)]; - i += 1u; + i += 1u32; } Call(bcx, mptr, args); bcx |
