13
13
// but many TypeRefs correspond to one ty::t; for instance, tup(int, int,
14
14
// int) and rec(x=int, y=int, z=int) will have the same TypeRef.
15
15
16
+ import core:: ctypes:: c_uint;
16
17
import std:: { map, time} ;
17
18
import std:: map:: hashmap;
18
19
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,
292
293
}
293
294
294
295
295
- fn decl_fn ( llmod : ModuleRef , name : str , cc : uint , llty : TypeRef ) -> ValueRef {
296
+ fn decl_fn ( llmod : ModuleRef , name : str , cc : uint , llty : TypeRef ) ->
297
+ ValueRef {
296
298
let llfn: ValueRef =
297
299
str:: as_buf ( name, { |buf|
298
300
llvm:: LLVMGetOrInsertFunction ( llmod, buf, llty) } ) ;
299
- llvm:: LLVMSetFunctionCallConv ( llfn, cc) ;
301
+ llvm:: LLVMSetFunctionCallConv ( llfn, cc as c_uint ) ;
300
302
ret llfn;
301
303
}
302
304
@@ -339,7 +341,8 @@ fn get_simple_extern_fn(cx: @block_ctxt,
339
341
let inputs = vec:: init_elt :: < TypeRef > ( ccx. int_type , n_args as uint ) ;
340
342
let output = ccx. int_type ;
341
343
let t = T_fn ( inputs, output) ;
342
- ret get_extern_fn ( externs, llmod, name, lib:: llvm:: LLVMCCallConv , t) ;
344
+ ret get_extern_fn ( externs, llmod, name,
345
+ lib:: llvm:: LLVMCCallConv , t) ;
343
346
}
344
347
345
348
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 {
390
393
391
394
// Returns the real size of the given type for the current target.
392
395
fn llsize_of_real ( cx : @crate_ctxt , t : TypeRef ) -> uint {
393
- ret llvm:: LLVMStoreSizeOfType ( cx. td . lltd , t) ;
396
+ ret llvm:: LLVMStoreSizeOfType ( cx. td . lltd , t) as uint ;
394
397
}
395
398
396
399
// Returns the real alignment of the given type for the current target.
397
400
fn llalign_of_real ( cx : @crate_ctxt , t : TypeRef ) -> uint {
398
- ret llvm:: LLVMPreferredAlignmentOfType ( cx. td . lltd , t) ;
401
+ ret llvm:: LLVMPreferredAlignmentOfType ( cx. td . lltd , t) as uint ;
399
402
}
400
403
401
404
fn llsize_of ( cx : @crate_ctxt , t : TypeRef ) -> ValueRef {
@@ -1070,7 +1073,7 @@ fn set_no_inline(f: ValueRef) {
1070
1073
llvm:: LLVMAddFunctionAttr ( f,
1071
1074
lib:: llvm:: LLVMNoInlineAttribute as
1072
1075
lib:: llvm:: llvm:: Attribute ,
1073
- 0 u ) ;
1076
+ 0u32 ) ;
1074
1077
}
1075
1078
1076
1079
// Tell LLVM to emit the information necessary to unwind the stack for the
@@ -1079,19 +1082,19 @@ fn set_uwtable(f: ValueRef) {
1079
1082
llvm:: LLVMAddFunctionAttr ( f,
1080
1083
lib:: llvm:: LLVMUWTableAttribute as
1081
1084
lib:: llvm:: llvm:: Attribute ,
1082
- 0 u ) ;
1085
+ 0u32 ) ;
1083
1086
}
1084
1087
1085
1088
fn set_always_inline ( f : ValueRef ) {
1086
1089
llvm:: LLVMAddFunctionAttr ( f,
1087
1090
lib:: llvm:: LLVMAlwaysInlineAttribute as
1088
1091
lib:: llvm:: llvm:: Attribute ,
1089
- 0 u ) ;
1092
+ 0u32 ) ;
1090
1093
}
1091
1094
1092
1095
fn set_custom_stack_growth_fn ( f : ValueRef ) {
1093
1096
// TODO: Remove this hack to work around the lack of u64 in the FFI.
1094
- llvm:: LLVMAddFunctionAttr ( f, 0 as lib:: llvm:: llvm:: Attribute , 1 u ) ;
1097
+ llvm:: LLVMAddFunctionAttr ( f, 0 as lib:: llvm:: llvm:: Attribute , 1u32 ) ;
1095
1098
}
1096
1099
1097
1100
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,
1178
1181
} else { T_ptr ( T_i8 ( ) ) } ;
1179
1182
1180
1183
let ty_param_count = vec:: len :: < uint > ( ty_params) ;
1181
- let lltyparams = llvm:: LLVMGetParam ( llfn, 2 u ) ;
1184
+ let lltyparams = llvm:: LLVMGetParam ( llfn, 2u32 ) ;
1182
1185
let load_env_bcx = new_raw_block_ctxt ( fcx, fcx. llloadenv ) ;
1183
1186
let lltydescs = [ mutable] ;
1184
1187
let p = 0 u;
@@ -1193,7 +1196,7 @@ fn make_generic_glue_inner(cx: @local_ctxt, sp: span, t: ty::t,
1193
1196
1194
1197
let bcx = new_top_block_ctxt ( fcx) ;
1195
1198
let lltop = bcx. llbb ;
1196
- let llrawptr0 = llvm:: LLVMGetParam ( llfn, 3 u ) ;
1199
+ let llrawptr0 = llvm:: LLVMGetParam ( llfn, 3u32 ) ;
1197
1200
let llval0 = BitCast ( bcx, llrawptr0, llty) ;
1198
1201
helper ( bcx, llval0, t) ;
1199
1202
finish_fn ( fcx, lltop) ;
@@ -4300,8 +4303,8 @@ fn new_fn_ctxt_w_id(cx: @local_ctxt, sp: span, llfndecl: ValueRef,
4300
4303
-> @fn_ctxt {
4301
4304
let llbbs = mk_standard_basic_blocks ( llfndecl) ;
4302
4305
ret @{ llfn : llfndecl,
4303
- llenv : llvm:: LLVMGetParam ( llfndecl, 1 u ) ,
4304
- llretptr : llvm:: LLVMGetParam ( llfndecl, 0 u ) ,
4306
+ llenv : llvm:: LLVMGetParam ( llfndecl, 1u32 ) ,
4307
+ llretptr : llvm:: LLVMGetParam ( llfndecl, 0u32 ) ,
4305
4308
mutable llstaticallocas : llbbs. sa ,
4306
4309
mutable llloadenv : llbbs. ca ,
4307
4310
mutable llderivedtydescs_first : llbbs. dt ,
@@ -4344,7 +4347,7 @@ fn create_llargs_for_fn_args(cx: @fn_ctxt, ty_self: self_arg,
4344
4347
// Skip the implicit arguments 0, and 1. TODO: Pull out 2u and define
4345
4348
// it as a constant, since we're using it in several places in trans this
4346
4349
// way.
4347
- let arg_n = 2 u ;
4350
+ let arg_n = 2u32 ;
4348
4351
alt ty_self {
4349
4352
impl_self( tt) {
4350
4353
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,
4353
4356
}
4354
4357
for tp in ty_params {
4355
4358
let lltydesc = llvm:: LLVMGetParam ( cx. llfn , arg_n) , dicts = none;
4356
- arg_n += 1 u ;
4359
+ arg_n += 1u32 ;
4357
4360
for bound in * fcx_tcx ( cx) . ty_param_bounds . get ( tp. id ) {
4358
4361
alt bound {
4359
4362
ty : : bound_iface ( _) {
4360
4363
let dict = llvm:: LLVMGetParam ( cx. llfn , arg_n) ;
4361
- arg_n += 1 u ;
4364
+ arg_n += 1u32 ;
4362
4365
dicts = some ( alt dicts {
4363
4366
none. { [ dict] }
4364
4367
some ( ds) { ds + [ dict] }
@@ -4379,7 +4382,7 @@ fn create_llargs_for_fn_args(cx: @fn_ctxt, ty_self: self_arg,
4379
4382
// copy_args_to_allocas will overwrite the table entry with local_imm
4380
4383
// before it's actually used.
4381
4384
cx. llargs . insert ( arg. id , local_mem ( llarg) ) ;
4382
- arg_n += 1 u ;
4385
+ arg_n += 1u32 ;
4383
4386
}
4384
4387
}
4385
4388
@@ -4798,7 +4801,7 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod,
4798
4801
let fcx = new_fn_ctxt ( lcx, span, llshimfn) ;
4799
4802
let bcx = new_top_block_ctxt ( fcx) ;
4800
4803
let lltop = bcx. llbb ;
4801
- let llargbundle = llvm:: LLVMGetParam ( llshimfn, 0 u ) ;
4804
+ let llargbundle = llvm:: LLVMGetParam ( llshimfn, 0u32 ) ;
4802
4805
let i = 0 u, n = vec:: len ( tys. arg_tys ) ;
4803
4806
let llargvals = [ ] ;
4804
4807
while i < n {
@@ -4808,7 +4811,8 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod,
4808
4811
}
4809
4812
4810
4813
// Create the call itself and store the return value:
4811
- let llretval = CallWithConv ( bcx, llbasefn, llargvals, cc) ; // r
4814
+ let llretval = CallWithConv ( bcx, llbasefn,
4815
+ llargvals, cc as c_uint ) ; // r
4812
4816
if tys. ret_def {
4813
4817
// R** llretptr = &args->r;
4814
4818
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,
4842
4846
let i = 0 u, n = vec:: len ( tys. arg_tys ) ;
4843
4847
let implicit_args = 2 u + num_tps; // ret + env
4844
4848
while i < n {
4845
- let llargval = llvm:: LLVMGetParam ( llwrapfn, i + implicit_args) ;
4849
+ let llargval = llvm:: LLVMGetParam ( llwrapfn,
4850
+ ( i + implicit_args) as c_uint ) ;
4846
4851
store_inbounds ( bcx, llargval, llargbundle, [ 0 , i as int ] ) ;
4847
4852
i += 1 u;
4848
4853
}
4849
- let llretptr = llvm:: LLVMGetParam ( llwrapfn, 0 u ) ;
4854
+ let llretptr = llvm:: LLVMGetParam ( llwrapfn, 0u32 ) ;
4850
4855
store_inbounds ( bcx, llretptr, llargbundle, [ 0 , n as int ] ) ;
4851
4856
4852
4857
// Create call itself.
@@ -4859,7 +4864,7 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod,
4859
4864
}
4860
4865
4861
4866
let ccx = lcx_ccx ( lcx) ;
4862
- let cc: uint = lib:: llvm:: LLVMCCallConv ;
4867
+ let cc = lib:: llvm:: LLVMCCallConv ;
4863
4868
alt abi {
4864
4869
ast : : native_abi_rust_intrinsic. { ret; }
4865
4870
ast:: native_abi_cdecl. { cc = lib:: llvm:: LLVMCCallConv ; }
@@ -5031,10 +5036,10 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
5031
5036
let bcx = new_top_block_ctxt ( fcx) ;
5032
5037
let lltop = bcx. llbb ;
5033
5038
5034
- let lloutputarg = llvm:: LLVMGetParam ( llfdecl, 0 u ) ;
5035
- let llenvarg = llvm:: LLVMGetParam ( llfdecl, 1 u ) ;
5039
+ let lloutputarg = llvm:: LLVMGetParam ( llfdecl, 0u32 ) ;
5040
+ let llenvarg = llvm:: LLVMGetParam ( llfdecl, 1u32 ) ;
5036
5041
let args = [ lloutputarg, llenvarg] ;
5037
- if takes_argv { args += [ llvm:: LLVMGetParam ( llfdecl, 2 u ) ] ; }
5042
+ if takes_argv { args += [ llvm:: LLVMGetParam ( llfdecl, 2u32 ) ] ; }
5038
5043
Call ( bcx, main_llfn, args) ;
5039
5044
build_return ( bcx) ;
5040
5045
@@ -5065,11 +5070,11 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
5065
5070
let start = str:: as_buf ( "rust_start" , { |buf|
5066
5071
llvm:: LLVMAddGlobal ( ccx. llmod , start_ty, buf)
5067
5072
} ) ;
5068
- let args = [ rust_main, llvm:: LLVMGetParam ( llfn, 0 u ) ,
5069
- llvm:: LLVMGetParam ( llfn, 1 u ) , crate_map] ;
5073
+ let args = [ rust_main, llvm:: LLVMGetParam ( llfn, 0u32 ) ,
5074
+ llvm:: LLVMGetParam ( llfn, 1u32 ) , crate_map] ;
5070
5075
let result = unsafe {
5071
5076
llvm:: LLVMBuildCall ( bld, start, vec:: to_ptr ( args) ,
5072
- vec:: len ( args) , noname ( ) )
5077
+ vec:: len ( args) as c_uint , noname ( ) )
5073
5078
} ;
5074
5079
llvm:: LLVMBuildRet ( bld, result) ;
5075
5080
}
0 commit comments