@@ -226,13 +226,13 @@ fn type_of_tag(cx: @crate_ctxt, sp: span, did: ast::def_id, t: ty::t)
226
226
let degen = std:: vec:: len ( ty:: tag_variants ( cx. tcx , did) ) == 1 u;
227
227
if check type_has_static_size ( cx, t) {
228
228
let size = static_size_of_tag ( cx, sp, t) ;
229
- if !degen { T_tag ( cx. tn , size) }
230
- else if size == 0 u { T_struct ( [ T_int ( ) ] ) }
229
+ if !degen { T_tag ( cx, size) }
230
+ else if size == 0 u { T_struct ( [ cx . int_type ] ) }
231
231
else { T_array ( T_i8 ( ) , size) }
232
232
}
233
233
else {
234
- if degen { T_struct ( [ T_int ( ) ] ) }
235
- else { T_opaque_tag ( cx. tn ) }
234
+ if degen { T_struct ( [ cx . int_type ] ) }
235
+ else { T_opaque_tag ( cx) }
236
236
}
237
237
}
238
238
@@ -3031,12 +3031,13 @@ fn trans_var(cx: @block_ctxt, sp: span, def: ast::def, id: ast::node_id)
3031
3031
let lltagty = type_of_tag ( ccx, sp, tid, tag_ty) ;
3032
3032
let bcx = alloc_result. bcx ;
3033
3033
let lltagptr = PointerCast ( bcx, lltagblob, T_ptr ( lltagty) ) ;
3034
- let lldiscrimptr = GEP ( bcx, lltagptr, [ C_int ( 0 ) , C_int ( 0 ) ] ) ;
3034
+ let lldiscrimptr = GEP ( bcx, lltagptr, [ C_int ( ccx, 0 ) ,
3035
+ C_int ( ccx, 0 ) ] ) ;
3035
3036
let d = if std:: vec:: len ( ty:: tag_variants ( ccx. tcx , tid) ) != 1 u {
3036
3037
let lldiscrim_gv = lookup_discriminant ( bcx. fcx . lcx , vid) ;
3037
3038
let lldiscrim = Load ( bcx, lldiscrim_gv) ;
3038
3039
lldiscrim
3039
- } else { C_int ( 0 ) } ;
3040
+ } else { C_int ( ccx , 0 ) } ;
3040
3041
Store ( bcx, d, lldiscrimptr) ;
3041
3042
ret lval_no_env ( bcx, lltagptr, temporary) ;
3042
3043
}
@@ -3914,7 +3915,8 @@ fn trans_c_stack_native_call(bcx: @block_ctxt, f: @ast::expr,
3914
3915
let i = 0 u, n = vec:: len ( llargs) ;
3915
3916
while i < n {
3916
3917
let llarg = llargs[ i] . llval ;
3917
- store_inbounds ( bcx, llarg, llargbundle, [ C_int ( 0 ) , C_uint ( i) ] ) ;
3918
+ store_inbounds ( bcx, llarg, llargbundle, [ C_int ( ccx, 0 ) ,
3919
+ C_uint ( ccx, i) ] ) ;
3918
3920
i += 1 u;
3919
3921
}
3920
3922
@@ -4449,8 +4451,8 @@ fn trans_log(lvl: int, cx: @block_ctxt, e: @ast::expr) -> @block_ctxt {
4449
4451
let llvalptr = r. val ;
4450
4452
let llval_i8 = PointerCast ( log_bcx, llvalptr, T_ptr ( T_i8 ( ) ) ) ;
4451
4453
4452
- Call ( log_bcx, bcx_ccx ( log_bcx ) . upcalls . log_type ,
4453
- [ lltydesc, llval_i8, C_int ( lvl) ] ) ;
4454
+ Call ( log_bcx, ccx . upcalls . log_type ,
4455
+ [ lltydesc, llval_i8, C_int ( ccx , lvl) ] ) ;
4454
4456
4455
4457
log_bcx = trans_block_cleanups ( log_bcx, log_cx) ;
4456
4458
Br ( log_bcx, after_cx. llbb ) ;
@@ -4514,7 +4516,7 @@ fn trans_fail_value(bcx: @block_ctxt, sp_opt: option::t<span>,
4514
4516
}
4515
4517
let V_str = PointerCast ( bcx, V_fail_str , T_ptr ( T_i8 ( ) ) ) ;
4516
4518
V_filename = PointerCast ( bcx, V_filename , T_ptr ( T_i8 ( ) ) ) ;
4517
- let args = [ V_str , V_filename , C_int ( V_line ) ] ;
4519
+ let args = [ V_str , V_filename , C_int ( ccx , V_line ) ] ;
4518
4520
let bcx = invoke ( bcx, bcx_ccx ( bcx) . upcalls . _fail , args) ;
4519
4521
Unreachable ( bcx) ;
4520
4522
ret bcx;
@@ -5518,16 +5520,16 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
5518
5520
fn main_name ( ) -> str { ret "main" ; }
5519
5521
#[ cfg( target_os = "linux" ) ]
5520
5522
fn main_name ( ) -> str { ret "main" ; }
5521
- let llfty = T_fn ( [ T_int ( ) , T_int ( ) ] , T_int ( ) ) ;
5523
+ let llfty = T_fn ( [ ccx . int_type , ccx . int_type ] , ccx . int_type ) ;
5522
5524
let llfn = decl_cdecl_fn ( ccx. llmod , main_name ( ) , llfty) ;
5523
5525
let llbb = str:: as_buf ( "top" , { |buf|
5524
5526
llvm:: LLVMAppendBasicBlock ( llfn, buf)
5525
5527
} ) ;
5526
5528
let bld = * ccx. builder ;
5527
5529
llvm:: LLVMPositionBuilderAtEnd ( bld, llbb) ;
5528
5530
let crate_map = ccx. crate_map ;
5529
- let start_ty = T_fn ( [ val_ty ( rust_main) , T_int ( ) , T_int ( ) ,
5530
- val_ty ( crate_map) ] , T_int ( ) ) ;
5531
+ let start_ty = T_fn ( [ val_ty ( rust_main) , ccx . int_type , ccx . int_type ,
5532
+ val_ty ( crate_map) ] , ccx . int_type ) ;
5531
5533
let start = str:: as_buf ( "rust_start" , { |buf|
5532
5534
llvm:: LLVMAddGlobal ( ccx. llmod , start_ty, buf)
5533
5535
} ) ;
@@ -6018,10 +6020,11 @@ fn create_module_map(ccx: @crate_ctxt) -> ValueRef {
6018
6020
lib:: llvm:: LLVMInternalLinkage as llvm:: Linkage ) ;
6019
6021
let elts: [ ValueRef ] = [ ] ;
6020
6022
ccx. module_data . items { |key, val|
6021
- let elt = C_struct ( [ p2i ( C_cstr ( ccx, key) ) , p2i ( val) ] ) ;
6023
+ let elt = C_struct ( [ p2i ( ccx, C_cstr ( ccx, key) ) ,
6024
+ p2i ( ccx, val) ] ) ;
6022
6025
elts += [ elt] ;
6023
6026
} ;
6024
- let term = C_struct ( [ C_int ( 0 ) , C_int ( 0 ) ] ) ;
6027
+ let term = C_struct ( [ C_int ( ccx , 0 ) , C_int ( ccx , 0 ) ] ) ;
6025
6028
elts += [ term] ;
6026
6029
llvm:: LLVMSetInitializer ( map, C_array ( elttype, elts) ) ;
6027
6030
ret map;
@@ -6030,13 +6033,15 @@ fn create_module_map(ccx: @crate_ctxt) -> ValueRef {
6030
6033
6031
6034
fn decl_crate_map ( sess : session:: session , mapname : str ,
6032
6035
llmod : ModuleRef ) -> ValueRef {
6036
+ let targ_cfg = sess. get_targ_cfg ( ) ;
6037
+ let int_type = T_int ( targ_cfg) ;
6033
6038
let n_subcrates = 1 ;
6034
6039
let cstore = sess. get_cstore ( ) ;
6035
6040
while cstore:: have_crate_data ( cstore, n_subcrates) { n_subcrates += 1 ; }
6036
6041
if !sess. get_opts ( ) . library { mapname = "toplevel" ; }
6037
6042
let sym_name = "_rust_crate_map_" + mapname;
6038
- let arrtype = T_array ( T_int ( ) , n_subcrates as uint ) ;
6039
- let maptype = T_struct ( [ T_int ( ) , arrtype] ) ;
6043
+ let arrtype = T_array ( int_type , n_subcrates as uint ) ;
6044
+ let maptype = T_struct ( [ int_type , arrtype] ) ;
6040
6045
let map = str:: as_buf ( sym_name, { |buf|
6041
6046
llvm:: LLVMAddGlobal ( llmod, maptype, buf)
6042
6047
} ) ;
@@ -6053,32 +6058,15 @@ fn fill_crate_map(ccx: @crate_ctxt, map: ValueRef) {
6053
6058
while cstore:: have_crate_data ( cstore, i) {
6054
6059
let nm = "_rust_crate_map_" + cstore:: get_crate_data ( cstore, i) . name ;
6055
6060
let cr = str:: as_buf ( nm, { |buf|
6056
- llvm:: LLVMAddGlobal ( ccx. llmod , T_int ( ) , buf)
6061
+ llvm:: LLVMAddGlobal ( ccx. llmod , ccx . int_type , buf)
6057
6062
} ) ;
6058
- subcrates += [ p2i ( cr) ] ;
6063
+ subcrates += [ p2i ( ccx , cr) ] ;
6059
6064
i += 1 ;
6060
6065
}
6061
- subcrates += [ C_int ( 0 ) ] ;
6062
- llvm:: LLVMSetInitializer ( map, C_struct ( [ p2i ( create_module_map ( ccx) ) ,
6063
- C_array ( T_int ( ) , subcrates) ] ) ) ;
6064
6066
subcrates += [ C_int ( ccx, 0 ) ] ;
6065
- let mapname;
6066
- if ccx. sess . get_opts ( ) . library {
6067
- mapname = ccx. link_meta . name ;
6068
- } else { mapname = "toplevel" ; }
6069
- let sym_name = "_rust_crate_map_" + mapname;
6070
- let arrtype = T_array ( ccx. int_type , std:: vec:: len :: < ValueRef > ( subcrates) ) ;
6071
- let maptype = T_struct ( [ ccx. int_type , arrtype] ) ;
6072
- let map =
6073
- str:: as_buf ( sym_name,
6074
- { |buf| llvm:: LLVMAddGlobal ( ccx. llmod , maptype, buf) } ) ;
6075
- llvm:: LLVMSetLinkage ( map,
6076
- lib:: llvm:: LLVMExternalLinkage as llvm:: Linkage ) ;
6077
- llvm:: LLVMSetInitializer ( map,
6078
- C_struct ( [ p2i ( ccx, create_module_map ( ccx) ) ,
6079
- C_array ( ccx. int_type , subcrates) ] ) ) ;
6080
- ret map;
6081
- >>>>>>> work on making the size of ints depend on the target arch
6067
+ llvm:: LLVMSetInitializer ( map, C_struct (
6068
+ [ p2i ( ccx, create_module_map ( ccx) ) ,
6069
+ C_array ( ccx. int_type , subcrates) ] ) ) ;
6082
6070
}
6083
6071
6084
6072
fn write_metadata ( cx : @crate_ctxt , crate : @ast:: crate ) {
@@ -6138,7 +6126,7 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
6138
6126
let task_type = T_task ( targ_cfg) ;
6139
6127
let taskptr_type = T_ptr ( task_type) ;
6140
6128
tn. associate ( "taskptr" , taskptr_type) ;
6141
- let tydesc_type = T_tydesc ( targ_cfg, taskptr_type ) ;
6129
+ let tydesc_type = T_tydesc ( targ_cfg) ;
6142
6130
tn. associate ( "tydesc" , tydesc_type) ;
6143
6131
let hasher = ty:: hash_ty;
6144
6132
let eqer = ty:: eq_ty;
0 commit comments