@@ -337,7 +337,7 @@ fn trans_malloc_boxed_raw(bcx: block, t: ty::t,
337
337
let llty = type_of ( ccx, box_ptr) ;
338
338
339
339
// Get the tydesc for the body:
340
- let { bcx , val : lltydesc } = get_tydesc ( bcx , t, static_ti) ;
340
+ let lltydesc = get_tydesc ( ccx , t, static_ti) ;
341
341
lazily_emit_all_tydesc_glue ( ccx, static_ti) ;
342
342
343
343
// Allocate space:
@@ -358,18 +358,18 @@ fn trans_malloc_boxed(bcx: block, t: ty::t) ->
358
358
359
359
// Type descriptor and type glue stuff
360
360
361
- fn get_tydesc_simple ( bcx : block , t : ty:: t ) -> result {
361
+ fn get_tydesc_simple ( ccx : @ crate_ctxt , t : ty:: t ) -> ValueRef {
362
362
let mut ti = none;
363
- get_tydesc ( bcx , t, ti)
363
+ get_tydesc ( ccx , t, ti)
364
364
}
365
365
366
- fn get_tydesc ( cx : block , t : ty:: t ,
367
- & static_ti: option < @tydesc_info > ) -> result {
366
+ fn get_tydesc ( ccx : @ crate_ctxt , t : ty:: t ,
367
+ & static_ti: option < @tydesc_info > ) -> ValueRef {
368
368
assert !ty:: type_has_params ( t) ;
369
369
// Otherwise, generate a tydesc if necessary, and return it.
370
- let info = get_static_tydesc ( cx . ccx ( ) , t) ;
370
+ let info = get_static_tydesc ( ccx, t) ;
371
371
static_ti = some ( info) ;
372
- ret rslt ( cx , info. tydesc ) ;
372
+ info. tydesc
373
373
}
374
374
375
375
fn get_static_tydesc ( ccx : @crate_ctxt , t : ty:: t ) -> @tydesc_info {
@@ -699,7 +699,7 @@ fn get_res_dtor(ccx: @crate_ctxt, did: ast::def_id, substs: [ty::t])
699
699
maybe_instantiate_inline ( ccx, did)
700
700
} else { did } ;
701
701
assert did. crate == ast:: local_crate;
702
- monomorphic_fn ( ccx, did, substs, none) . val
702
+ monomorphic_fn ( ccx, did, substs, none, none ) . val
703
703
}
704
704
705
705
fn trans_res_drop ( bcx : block , rs : ValueRef , did : ast:: def_id ,
@@ -1074,10 +1074,10 @@ fn call_tydesc_glue_full(cx: block, v: ValueRef, tydesc: ValueRef,
1074
1074
fn call_tydesc_glue ( cx : block , v : ValueRef , t : ty:: t , field : int ) ->
1075
1075
block {
1076
1076
let _icx = cx. insn_ctxt ( "call_tydesc_glue" ) ;
1077
- let mut ti: option < @ tydesc_info > = none;
1078
- let { bcx : bcx , val : td } = get_tydesc ( cx, t, ti) ;
1079
- call_tydesc_glue_full ( bcx , v, td, field, ti) ;
1080
- ret bcx ;
1077
+ let mut ti = none;
1078
+ let td = get_tydesc ( cx. ccx ( ) , t, ti) ;
1079
+ call_tydesc_glue_full ( cx , v, td, field, ti) ;
1080
+ ret cx ;
1081
1081
}
1082
1082
1083
1083
fn call_cmp_glue ( cx : block , lhs : ValueRef , rhs : ValueRef , t : ty:: t ,
@@ -1096,11 +1096,9 @@ fn call_cmp_glue(cx: block, lhs: ValueRef, rhs: ValueRef, t: ty::t,
1096
1096
1097
1097
let llrawlhsptr = BitCast ( bcx, lllhs, T_ptr ( T_i8 ( ) ) ) ;
1098
1098
let llrawrhsptr = BitCast ( bcx, llrhs, T_ptr ( T_i8 ( ) ) ) ;
1099
- let r = get_tydesc_simple ( bcx, t) ;
1100
- let lltydesc = r. val ;
1101
- let bcx = r. bcx ;
1102
- let lltydescs = GEPi ( bcx, lltydesc, [ 0 , abi:: tydesc_field_first_param] ) ;
1103
- let lltydescs = Load ( bcx, lltydescs) ;
1099
+ let lltydesc = get_tydesc_simple ( bcx. ccx ( ) , t) ;
1100
+ let lltydescs =
1101
+ Load ( bcx, GEPi ( bcx, lltydesc, [ 0 , abi:: tydesc_field_first_param] ) ) ;
1104
1102
1105
1103
let llfn = bcx. ccx ( ) . upcalls . cmp_type ;
1106
1104
@@ -1171,9 +1169,7 @@ fn call_memmove(cx: block, dst: ValueRef, src: ValueRef,
1171
1169
session:: arch_x86 | session:: arch_arm { "llvm.memmove.p0i8.p0i8.i32" }
1172
1170
session:: arch_x86_64 { "llvm.memmove.p0i8.p0i8.i64" }
1173
1171
} ;
1174
- let i = ccx. intrinsics ;
1175
- assert ( i. contains_key ( key) ) ;
1176
- let memmove = i. get ( key) ;
1172
+ let memmove = ccx. intrinsics . get ( key) ;
1177
1173
let src_ptr = PointerCast ( cx, src, T_ptr ( T_i8 ( ) ) ) ;
1178
1174
let dst_ptr = PointerCast ( cx, dst, T_ptr ( T_i8 ( ) ) ) ;
1179
1175
let size = IntCast ( cx, n_bytes, ccx. int_type ) ;
@@ -1911,7 +1907,8 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: [ty::t],
1911
1907
}
1912
1908
1913
1909
fn monomorphic_fn ( ccx : @crate_ctxt , fn_id : ast:: def_id , real_substs : [ ty:: t ] ,
1914
- vtables : option < typeck:: vtable_res > )
1910
+ vtables : option < typeck:: vtable_res > ,
1911
+ ref_id : option < ast:: node_id > )
1915
1912
-> { val : ValueRef , must_cast : bool , intrinsic : bool } {
1916
1913
let _icx = ccx. insn_ctxt ( "monomorphic_fn" ) ;
1917
1914
let mut must_cast = false ;
@@ -1952,6 +1949,8 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t],
1952
1949
}
1953
1950
ast_map:: node_variant ( v, _, pt) { ( pt, v. node . name ) }
1954
1951
ast_map:: node_method ( m, _, pt) { ( pt, m. ident ) }
1952
+ ast_map:: node_native_item ( i, ast:: native_abi_rust_builtin, pt)
1953
+ { ( pt, i. ident ) }
1955
1954
ast_map:: node_native_item ( _, abi, _) {
1956
1955
// Natives don't have to be monomorphized.
1957
1956
ret { val : get_item_val ( ccx, fn_id. node ) ,
@@ -1984,6 +1983,10 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t],
1984
1983
ast_map:: node_item ( @{ node: ast:: item_res ( d, _, body, d_id, _) , _} , _) {
1985
1984
trans_fn ( ccx, pt, d, body, lldecl, no_self, psubsts, d_id, none) ;
1986
1985
}
1986
+ ast_map:: node_native_item ( i, _, _) {
1987
+ native:: trans_builtin ( ccx, lldecl, i, pt, option:: get ( psubsts) ,
1988
+ ref_id) ;
1989
+ }
1987
1990
ast_map:: node_variant ( v, enum_item, _) {
1988
1991
let tvs = ty:: enum_variants ( ccx. tcx , local_def ( enum_item. id ) ) ;
1989
1992
let this_tv = option:: get ( vec:: find ( * tvs, { |tv|
@@ -2036,6 +2039,10 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id)
2036
2039
trans_item ( ccx, * item) ;
2037
2040
local_def ( item. id )
2038
2041
}
2042
+ csearch:: found ( ast:: ii_native ( item) ) {
2043
+ ccx. external . insert ( fn_id, some ( item. id ) ) ;
2044
+ local_def ( item. id )
2045
+ }
2039
2046
csearch:: found_parent ( parent_id, ast:: ii_item ( item) ) {
2040
2047
ccx. external . insert ( parent_id, some ( item. id ) ) ;
2041
2048
let mut my_id = 0 ;
@@ -2088,11 +2095,9 @@ fn lval_intrinsic_fn(bcx: block, val: ValueRef, tys: [ty::t],
2088
2095
let mut bcx = bcx;
2089
2096
let ccx = bcx. ccx ( ) ;
2090
2097
let tds = vec:: map ( tys, { |t|
2091
- let mut ti = none;
2092
- let td_res = get_tydesc ( bcx, t, ti) ;
2093
- bcx = td_res. bcx ;
2098
+ let mut ti = none, td = get_tydesc ( bcx. ccx ( ) , t, ti) ;
2094
2099
lazily_emit_all_tydesc_glue ( ccx, ti) ;
2095
- td_res . val
2100
+ td
2096
2101
} ) ;
2097
2102
let llfty = type_of_fn_from_ty ( ccx, node_id_type ( bcx, id) ) ;
2098
2103
let val = PointerCast ( bcx, val, T_ptr ( add_tydesc_params (
@@ -2124,7 +2129,7 @@ fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id,
2124
2129
2125
2130
if fn_id. crate == ast:: local_crate && tys. len ( ) > 0 u {
2126
2131
let mut { val, must_cast, intrinsic} =
2127
- monomorphic_fn ( ccx, fn_id, tys, vtables) ;
2132
+ monomorphic_fn ( ccx, fn_id, tys, vtables, some ( id ) ) ;
2128
2133
if intrinsic { ret lval_intrinsic_fn ( bcx, val, tys, id) ; }
2129
2134
if must_cast {
2130
2135
val = PointerCast ( bcx, val, T_ptr ( type_of_fn_from_ty (
@@ -3318,7 +3323,7 @@ fn trans_log(lvl: @ast::expr, bcx: block, e: @ast::expr) -> block {
3318
3323
with_scope ( bcx, "log" ) { |bcx|
3319
3324
let { bcx, val, _} = trans_temp_expr ( bcx, e) ;
3320
3325
let e_ty = expr_ty ( bcx, e) ;
3321
- let { bcx , val : tydesc } = get_tydesc_simple ( bcx , e_ty) ;
3326
+ let tydesc = get_tydesc_simple ( ccx , e_ty) ;
3322
3327
// Call the polymorphic log function.
3323
3328
let { bcx, val} = spill_if_immediate ( bcx, val, e_ty) ;
3324
3329
let val = PointerCast ( bcx, val, T_ptr ( T_i8 ( ) ) ) ;
0 commit comments