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} ;
@@ -291,11 +292,12 @@ fn log_fn_time(ccx: @crate_ctxt, name: str, start: time::timeval,
291
292
}
292
293
293
294
294
- fn decl_fn ( llmod : ModuleRef , name : str , cc : uint , llty : TypeRef ) -> ValueRef {
295
+ fn decl_fn ( llmod : ModuleRef , name : str , cc : uint , llty : TypeRef ) ->
296
+ ValueRef {
295
297
let llfn: ValueRef =
296
298
str:: as_buf ( name, { |buf|
297
299
llvm:: LLVMGetOrInsertFunction ( llmod, buf, llty) } ) ;
298
- llvm:: LLVMSetFunctionCallConv ( llfn, cc) ;
300
+ llvm:: LLVMSetFunctionCallConv ( llfn, cc as c_uint ) ;
299
301
ret llfn;
300
302
}
301
303
@@ -338,7 +340,8 @@ fn get_simple_extern_fn(cx: @block_ctxt,
338
340
let inputs = vec:: init_elt :: < TypeRef > ( ccx. int_type , n_args as uint ) ;
339
341
let output = ccx. int_type ;
340
342
let t = T_fn ( inputs, output) ;
341
- ret get_extern_fn ( externs, llmod, name, lib:: llvm:: LLVMCCallConv , t) ;
343
+ ret get_extern_fn ( externs, llmod, name,
344
+ lib:: llvm:: LLVMCCallConv , t) ;
342
345
}
343
346
344
347
fn trans_native_call ( cx : @block_ctxt , externs : hashmap < str , ValueRef > ,
@@ -389,12 +392,12 @@ fn align_to(cx: @block_ctxt, off: ValueRef, align: ValueRef) -> ValueRef {
389
392
390
393
// Returns the real size of the given type for the current target.
391
394
fn llsize_of_real ( cx : @crate_ctxt , t : TypeRef ) -> uint {
392
- ret llvm:: LLVMStoreSizeOfType ( cx. td . lltd , t) ;
395
+ ret llvm:: LLVMStoreSizeOfType ( cx. td . lltd , t) as uint ;
393
396
}
394
397
395
398
// Returns the real alignment of the given type for the current target.
396
399
fn llalign_of_real ( cx : @crate_ctxt , t : TypeRef ) -> uint {
397
- ret llvm:: LLVMPreferredAlignmentOfType ( cx. td . lltd , t) ;
400
+ ret llvm:: LLVMPreferredAlignmentOfType ( cx. td . lltd , t) as uint ;
398
401
}
399
402
400
403
fn llsize_of ( cx : @crate_ctxt , t : TypeRef ) -> ValueRef {
@@ -1067,7 +1070,7 @@ fn set_no_inline(f: ValueRef) {
1067
1070
llvm:: LLVMAddFunctionAttr ( f,
1068
1071
lib:: llvm:: LLVMNoInlineAttribute as
1069
1072
lib:: llvm:: llvm:: Attribute ,
1070
- 0 u ) ;
1073
+ 0u32 ) ;
1071
1074
}
1072
1075
1073
1076
// Tell LLVM to emit the information necessary to unwind the stack for the
@@ -1076,19 +1079,19 @@ fn set_uwtable(f: ValueRef) {
1076
1079
llvm:: LLVMAddFunctionAttr ( f,
1077
1080
lib:: llvm:: LLVMUWTableAttribute as
1078
1081
lib:: llvm:: llvm:: Attribute ,
1079
- 0 u ) ;
1082
+ 0u32 ) ;
1080
1083
}
1081
1084
1082
1085
fn set_always_inline ( f : ValueRef ) {
1083
1086
llvm:: LLVMAddFunctionAttr ( f,
1084
1087
lib:: llvm:: LLVMAlwaysInlineAttribute as
1085
1088
lib:: llvm:: llvm:: Attribute ,
1086
- 0 u ) ;
1089
+ 0u32 ) ;
1087
1090
}
1088
1091
1089
1092
fn set_custom_stack_growth_fn ( f : ValueRef ) {
1090
1093
// TODO: Remove this hack to work around the lack of u64 in the FFI.
1091
- llvm:: LLVMAddFunctionAttr ( f, 0 as lib:: llvm:: llvm:: Attribute , 1 u ) ;
1094
+ llvm:: LLVMAddFunctionAttr ( f, 0 as lib:: llvm:: llvm:: Attribute , 1u32 ) ;
1092
1095
}
1093
1096
1094
1097
fn set_glue_inlining ( cx : @local_ctxt , f : ValueRef , t : ty:: t ) {
@@ -1175,7 +1178,7 @@ fn make_generic_glue_inner(cx: @local_ctxt, sp: span, t: ty::t,
1175
1178
} else { T_ptr ( T_i8 ( ) ) } ;
1176
1179
1177
1180
let ty_param_count = vec:: len :: < uint > ( ty_params) ;
1178
- let lltyparams = llvm:: LLVMGetParam ( llfn, 2 u ) ;
1181
+ let lltyparams = llvm:: LLVMGetParam ( llfn, 2u32 ) ;
1179
1182
let load_env_bcx = new_raw_block_ctxt ( fcx, fcx. llloadenv ) ;
1180
1183
let lltydescs = [ mutable] ;
1181
1184
let p = 0 u;
@@ -1190,7 +1193,7 @@ fn make_generic_glue_inner(cx: @local_ctxt, sp: span, t: ty::t,
1190
1193
1191
1194
let bcx = new_top_block_ctxt ( fcx) ;
1192
1195
let lltop = bcx. llbb ;
1193
- let llrawptr0 = llvm:: LLVMGetParam ( llfn, 3 u ) ;
1196
+ let llrawptr0 = llvm:: LLVMGetParam ( llfn, 3u32 ) ;
1194
1197
let llval0 = BitCast ( bcx, llrawptr0, llty) ;
1195
1198
helper ( bcx, llval0, t) ;
1196
1199
finish_fn ( fcx, lltop) ;
@@ -4302,8 +4305,8 @@ fn new_fn_ctxt_w_id(cx: @local_ctxt, sp: span, llfndecl: ValueRef,
4302
4305
-> @fn_ctxt {
4303
4306
let llbbs = mk_standard_basic_blocks ( llfndecl) ;
4304
4307
ret @{ llfn : llfndecl,
4305
- llenv : llvm:: LLVMGetParam ( llfndecl, 1 u ) ,
4306
- llretptr : llvm:: LLVMGetParam ( llfndecl, 0 u ) ,
4308
+ llenv : llvm:: LLVMGetParam ( llfndecl, 1u32 ) ,
4309
+ llretptr : llvm:: LLVMGetParam ( llfndecl, 0u32 ) ,
4307
4310
mutable llstaticallocas : llbbs. sa ,
4308
4311
mutable llloadenv : llbbs. ca ,
4309
4312
mutable llderivedtydescs_first : llbbs. dt ,
@@ -4346,7 +4349,7 @@ fn create_llargs_for_fn_args(cx: @fn_ctxt, ty_self: self_arg,
4346
4349
// Skip the implicit arguments 0, and 1. TODO: Pull out 2u and define
4347
4350
// it as a constant, since we're using it in several places in trans this
4348
4351
// way.
4349
- let arg_n = 2 u ;
4352
+ let arg_n = 2u32 ;
4350
4353
alt ty_self {
4351
4354
impl_self( tt) {
4352
4355
cx. llself = some ( { v: cx. llenv , t: tt} ) ;
@@ -4355,12 +4358,12 @@ fn create_llargs_for_fn_args(cx: @fn_ctxt, ty_self: self_arg,
4355
4358
}
4356
4359
for tp in ty_params {
4357
4360
let lltydesc = llvm:: LLVMGetParam ( cx. llfn , arg_n) , dicts = none;
4358
- arg_n += 1 u ;
4361
+ arg_n += 1u32 ;
4359
4362
for bound in * fcx_tcx ( cx) . ty_param_bounds . get ( tp. id ) {
4360
4363
alt bound {
4361
4364
ty : : bound_iface ( _) {
4362
4365
let dict = llvm:: LLVMGetParam ( cx. llfn , arg_n) ;
4363
- arg_n += 1 u ;
4366
+ arg_n += 1u32 ;
4364
4367
dicts = some ( alt dicts {
4365
4368
none. { [ dict] }
4366
4369
some ( ds) { ds + [ dict] }
@@ -4381,7 +4384,7 @@ fn create_llargs_for_fn_args(cx: @fn_ctxt, ty_self: self_arg,
4381
4384
// copy_args_to_allocas will overwrite the table entry with local_imm
4382
4385
// before it's actually used.
4383
4386
cx. llargs . insert ( arg. id , local_mem ( llarg) ) ;
4384
- arg_n += 1 u ;
4387
+ arg_n += 1u32 ;
4385
4388
}
4386
4389
}
4387
4390
@@ -4804,7 +4807,7 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod,
4804
4807
let fcx = new_fn_ctxt ( lcx, span, llshimfn) ;
4805
4808
let bcx = new_top_block_ctxt ( fcx) ;
4806
4809
let lltop = bcx. llbb ;
4807
- let llargbundle = llvm:: LLVMGetParam ( llshimfn, 0 u ) ;
4810
+ let llargbundle = llvm:: LLVMGetParam ( llshimfn, 0u32 ) ;
4808
4811
let i = 0 u, n = vec:: len ( tys. arg_tys ) ;
4809
4812
let llargvals = [ ] ;
4810
4813
while i < n {
@@ -4814,7 +4817,8 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod,
4814
4817
}
4815
4818
4816
4819
// Create the call itself and store the return value:
4817
- let llretval = CallWithConv ( bcx, llbasefn, llargvals, cc) ; // r
4820
+ let llretval = CallWithConv ( bcx, llbasefn,
4821
+ llargvals, cc as c_uint ) ; // r
4818
4822
if tys. ret_def {
4819
4823
// R** llretptr = &args->r;
4820
4824
let llretptr = GEPi ( bcx, llargbundle, [ 0 , n as int ] ) ;
@@ -4848,11 +4852,12 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod,
4848
4852
let i = 0 u, n = vec:: len ( tys. arg_tys ) ;
4849
4853
let implicit_args = 2 u + num_tps; // ret + env
4850
4854
while i < n {
4851
- let llargval = llvm:: LLVMGetParam ( llwrapfn, i + implicit_args) ;
4855
+ let llargval = llvm:: LLVMGetParam ( llwrapfn,
4856
+ ( i + implicit_args) as c_uint ) ;
4852
4857
store_inbounds ( bcx, llargval, llargbundle, [ 0 , i as int ] ) ;
4853
4858
i += 1 u;
4854
4859
}
4855
- let llretptr = llvm:: LLVMGetParam ( llwrapfn, 0 u ) ;
4860
+ let llretptr = llvm:: LLVMGetParam ( llwrapfn, 0u32 ) ;
4856
4861
store_inbounds ( bcx, llretptr, llargbundle, [ 0 , n as int ] ) ;
4857
4862
4858
4863
// Create call itself.
@@ -4865,7 +4870,7 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod,
4865
4870
}
4866
4871
4867
4872
let ccx = lcx_ccx ( lcx) ;
4868
- let cc: uint = lib:: llvm:: LLVMCCallConv ;
4873
+ let cc = lib:: llvm:: LLVMCCallConv ;
4869
4874
alt abi {
4870
4875
ast : : native_abi_rust_intrinsic. { ret; }
4871
4876
ast:: native_abi_cdecl. { cc = lib:: llvm:: LLVMCCallConv ; }
@@ -5037,10 +5042,10 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
5037
5042
let bcx = new_top_block_ctxt ( fcx) ;
5038
5043
let lltop = bcx. llbb ;
5039
5044
5040
- let lloutputarg = llvm:: LLVMGetParam ( llfdecl, 0 u ) ;
5041
- let llenvarg = llvm:: LLVMGetParam ( llfdecl, 1 u ) ;
5045
+ let lloutputarg = llvm:: LLVMGetParam ( llfdecl, 0u32 ) ;
5046
+ let llenvarg = llvm:: LLVMGetParam ( llfdecl, 1u32 ) ;
5042
5047
let args = [ lloutputarg, llenvarg] ;
5043
- if takes_argv { args += [ llvm:: LLVMGetParam ( llfdecl, 2 u ) ] ; }
5048
+ if takes_argv { args += [ llvm:: LLVMGetParam ( llfdecl, 2u32 ) ] ; }
5044
5049
Call ( bcx, main_llfn, args) ;
5045
5050
build_return ( bcx) ;
5046
5051
@@ -5071,11 +5076,11 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
5071
5076
let start = str:: as_buf ( "rust_start" , { |buf|
5072
5077
llvm:: LLVMAddGlobal ( ccx. llmod , start_ty, buf)
5073
5078
} ) ;
5074
- let args = [ rust_main, llvm:: LLVMGetParam ( llfn, 0 u ) ,
5075
- llvm:: LLVMGetParam ( llfn, 1 u ) , crate_map] ;
5079
+ let args = [ rust_main, llvm:: LLVMGetParam ( llfn, 0u32 ) ,
5080
+ llvm:: LLVMGetParam ( llfn, 1u32 ) , crate_map] ;
5076
5081
let result = unsafe {
5077
5082
llvm:: LLVMBuildCall ( bld, start, vec:: to_ptr ( args) ,
5078
- vec:: len ( args) , noname ( ) )
5083
+ vec:: len ( args) as c_uint , noname ( ) )
5079
5084
} ;
5080
5085
llvm:: LLVMBuildRet ( bld, result) ;
5081
5086
}
0 commit comments