diff options
| author | Ben Blum <bblum@andrew.cmu.edu> | 2012-08-21 15:05:57 -0400 |
|---|---|---|
| committer | Ben Blum <bblum@andrew.cmu.edu> | 2012-08-21 15:30:53 -0400 |
| commit | f5332769d58c5e8d9fee36a7e1f8faa4f5c1b861 (patch) | |
| tree | cd96f3ade46c9ecba55ba9ab1cb1783f6589596b /src | |
| parent | 9423302c82b0974315c7f2637f72c00ab3c26a18 (diff) | |
Convert atomic intrinsics away from old argument modes (partial #3200)
Diffstat (limited to 'src')
| -rw-r--r-- | src/rustc/middle/trans/foreign.rs | 25 | ||||
| -rw-r--r-- | src/rustc/middle/trans/type_use.rs | 12 | ||||
| -rw-r--r-- | src/rustc/middle/ty.rs | 9 | ||||
| -rw-r--r-- | src/rustc/middle/typeck/check.rs | 12 |
4 files changed, 44 insertions, 14 deletions
diff --git a/src/rustc/middle/trans/foreign.rs b/src/rustc/middle/trans/foreign.rs index 77afcc6fc93..50c86ddd86a 100644 --- a/src/rustc/middle/trans/foreign.rs +++ b/src/rustc/middle/trans/foreign.rs @@ -799,64 +799,66 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item, let fcx = new_fn_ctxt_w_id(ccx, path, decl, item.id, some(substs), some(item.span)); let mut bcx = top_scope_block(fcx, none), lltop = bcx.llbb; - match check *item.ident { - ~"atomic_xchng" => { + match *item.ident { + // NB: Transitionary, de-mode-ing. Remove the first string of each + // pattern when the old intrinsics are gone. + ~"atomic_xchng" | ~"atomic_xchg" => { let old = AtomicRMW(bcx, Xchg, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), SequentiallyConsistent); Store(bcx, old, fcx.llretptr); } - ~"atomic_xchng_acq" => { + ~"atomic_xchng_acq" | ~"atomic_xchg_acq" => { let old = AtomicRMW(bcx, Xchg, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), Acquire); Store(bcx, old, fcx.llretptr); } - ~"atomic_xchng_rel" => { + ~"atomic_xchng_rel" | ~"atomic_xchg_rel" => { let old = AtomicRMW(bcx, Xchg, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), Release); Store(bcx, old, fcx.llretptr); } - ~"atomic_add" => { + ~"atomic_add" | ~"atomic_xadd" => { let old = AtomicRMW(bcx, lib::llvm::Add, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), SequentiallyConsistent); Store(bcx, old, fcx.llretptr); } - ~"atomic_add_acq" => { + ~"atomic_add_acq" | ~"atomic_xadd_acq" => { let old = AtomicRMW(bcx, lib::llvm::Add, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), Acquire); Store(bcx, old, fcx.llretptr); } - ~"atomic_add_rel" => { + ~"atomic_add_rel" | ~"atomic_xadd_rel" => { let old = AtomicRMW(bcx, lib::llvm::Add, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), Release); Store(bcx, old, fcx.llretptr); } - ~"atomic_sub" => { + ~"atomic_sub" | ~"atomic_xsub" => { let old = AtomicRMW(bcx, lib::llvm::Sub, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), SequentiallyConsistent); Store(bcx, old, fcx.llretptr); } - ~"atomic_sub_acq" => { + ~"atomic_sub_acq" | ~"atomic_xsub_acq" => { let old = AtomicRMW(bcx, lib::llvm::Sub, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), Acquire); Store(bcx, old, fcx.llretptr); } - ~"atomic_sub_rel" => { + ~"atomic_sub_rel" | ~"atomic_xsub_rel" => { let old = AtomicRMW(bcx, lib::llvm::Sub, get_param(decl, first_real_arg), get_param(decl, first_real_arg + 1u), @@ -980,6 +982,9 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item, lv_temporary), arg_vals(~[frameaddress_val]), ignore); } + _ => { + ccx.sess.span_bug(item.span, ~"unknown intrinsic"); + } } build_return(bcx); finish_fn(fcx, lltop); diff --git a/src/rustc/middle/trans/type_use.rs b/src/rustc/middle/trans/type_use.rs index a53d9b3a3ba..93f5d4e996f 100644 --- a/src/rustc/middle/trans/type_use.rs +++ b/src/rustc/middle/trans/type_use.rs @@ -64,7 +64,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) none => ccx.sess.bug(fmt!{"type_uses_for: unbound item ID %?", fn_id_loc}) }; - match check map_node { + match map_node { ast_map::node_item(@{node: item_fn(_, _, body), _}, _) | ast_map::node_method(@{body, _}, _, _) => { handle_body(cx, body); @@ -81,7 +81,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) ast_map::node_foreign_item(i@@{node: foreign_item_fn(_, _), _}, abi, _) => { if abi == foreign_abi_rust_intrinsic { - let flags = match check *i.ident { + let flags = match *i.ident { ~"size_of" | ~"pref_align_of" | ~"min_align_of" | ~"init" | ~"reinterpret_cast" | ~"move_val" | ~"move_val_init" => { @@ -90,6 +90,11 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) ~"get_tydesc" | ~"needs_drop" => { use_tydesc } + // NB: new intrinsics + ~"atomic_xchg" | ~"atomic_xadd" | ~"atomic_xsub" | + ~"atomic_xchg_acq" | ~"atomic_xadd_acq" | ~"atomic_xsub_acq" | + ~"atomic_xchg_rel" | ~"atomic_xadd_rel" | ~"atomic_xsub_rel" | + // old intrinsics ~"atomic_xchng" | ~"atomic_add" | ~"atomic_sub" | ~"atomic_xchng_acq" | ~"atomic_add_acq" | ~"atomic_sub_acq" | ~"atomic_xchng_rel" | ~"atomic_add_rel" | ~"atomic_sub_rel" => { @@ -98,6 +103,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) ~"visit_tydesc" | ~"forget" | ~"addr_of" => { 0u } + _ => fail ~"unknown intrinsic in type_use" }; for uint::range(0u, n_tps) |n| { cx.uses[n] |= flags;} } @@ -108,7 +114,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) ast_map::node_dtor(_, dtor, _, _) => { handle_body(cx, dtor.node.body); } - + _ => fail ~"unknown node type in type_use" } let uses = vec::from_mut(copy cx.uses); ccx.type_use_cache.insert(fn_id, uses); diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index 70473f52d69..e59a29cfec2 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -88,7 +88,7 @@ export ty_nil, mk_nil, type_is_nil; export ty_trait, mk_trait; export ty_param, mk_param, ty_params_to_tys; export ty_ptr, mk_ptr, mk_mut_ptr, mk_imm_ptr, mk_nil_ptr, type_is_unsafe_ptr; -export ty_rptr, mk_rptr; +export ty_rptr, mk_rptr, mk_mut_rptr, mk_imm_rptr; export ty_rec, mk_rec; export ty_enum, mk_enum, type_is_enum; export ty_tup, mk_tup; @@ -764,6 +764,13 @@ fn mk_ptr(cx: ctxt, tm: mt) -> t { mk_t(cx, ty_ptr(tm)) } fn mk_rptr(cx: ctxt, r: region, tm: mt) -> t { mk_t(cx, ty_rptr(r, tm)) } +fn mk_mut_rptr(cx: ctxt, r: region, ty: t) -> t { + mk_rptr(cx, r, {ty: ty, mutbl: ast::m_mutbl}) +} +fn mk_imm_rptr(cx: ctxt, r: region, ty: t) -> t { + mk_rptr(cx, r, {ty: ty, mutbl: ast::m_imm}) +} + fn mk_mut_ptr(cx: ctxt, ty: t) -> t { mk_ptr(cx, {ty: ty, mutbl: ast::m_mutbl}) } diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index e1e8af26546..7947bc6ee18 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -2487,6 +2487,7 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) { } ~"needs_drop" => (1u, ~[], ty::mk_bool(tcx)), + // NB: Old intrinsics. ~"atomic_xchng" | ~"atomic_add" | ~"atomic_sub" | ~"atomic_xchng_acq" | ~"atomic_add_acq" | ~"atomic_sub_acq" | ~"atomic_xchng_rel" | ~"atomic_add_rel" | ~"atomic_sub_rel" => { @@ -2495,6 +2496,17 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) { ty::mk_int(tcx)) } + // NB: Transitionary, de-mode-ing. + ~"atomic_xchg" | ~"atomic_xadd" | ~"atomic_xsub" | + ~"atomic_xchg_acq" | ~"atomic_xadd_acq" | ~"atomic_xsub_acq" | + ~"atomic_xchg_rel" | ~"atomic_xadd_rel" | ~"atomic_xsub_rel" => { + (0u, ~[arg(ast::by_val, + ty::mk_mut_rptr(tcx, ty::re_bound(ty::br_anon(0)), + ty::mk_int(tcx))), + arg(ast::by_val, ty::mk_int(tcx))], + ty::mk_int(tcx)) + } + ~"get_tydesc" => { // FIXME (#2712): return *intrinsic::tydesc, not *() (1u, ~[], ty::mk_nil_ptr(tcx)) |
