diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2012-03-23 11:51:06 +0100 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2012-03-23 12:21:55 +0100 |
| commit | f5024692d49be49b2efff452059f83efaebfd0ee (patch) | |
| tree | 23da664fb1bf1c374081550309731cf206341b57 /src/rustc | |
| parent | 0303396f4cc292b54a0b097364581c88b8631696 (diff) | |
| download | rust-f5024692d49be49b2efff452059f83efaebfd0ee.tar.gz rust-f5024692d49be49b2efff452059f83efaebfd0ee.zip | |
Remove support for the old-style intrinsics
Closes #2042 Closes #1981
Diffstat (limited to 'src/rustc')
| -rw-r--r-- | src/rustc/back/link.rs | 64 | ||||
| -rw-r--r-- | src/rustc/back/upcall.rs | 6 | ||||
| -rw-r--r-- | src/rustc/front/attr.rs | 3 | ||||
| -rw-r--r-- | src/rustc/metadata/common.rs | 1 | ||||
| -rw-r--r-- | src/rustc/metadata/csearch.rs | 6 | ||||
| -rw-r--r-- | src/rustc/metadata/decoder.rs | 8 | ||||
| -rw-r--r-- | src/rustc/metadata/encoder.rs | 4 | ||||
| -rw-r--r-- | src/rustc/middle/trans/base.rs | 65 | ||||
| -rw-r--r-- | src/rustc/middle/trans/closure.rs | 1 | ||||
| -rw-r--r-- | src/rustc/middle/trans/impl.rs | 2 | ||||
| -rw-r--r-- | src/rustc/middle/trans/native.rs | 29 | ||||
| -rw-r--r-- | src/rustc/middle/trans/type_use.rs | 8 | ||||
| -rw-r--r-- | src/rustc/syntax/ast.rs | 1 |
13 files changed, 15 insertions, 183 deletions
diff --git a/src/rustc/back/link.rs b/src/rustc/back/link.rs index 7b0e14b1da6..cf01d9507f2 100644 --- a/src/rustc/back/link.rs +++ b/src/rustc/back/link.rs @@ -30,69 +30,6 @@ fn llvm_err(sess: session, msg: str) -> ! unsafe { } else { sess.fatal(msg + ": " + str::unsafe::from_c_str(cstr)); } } -fn load_intrinsics_bc(sess: session) -> option<ModuleRef> { - let path = alt filesearch::search( - sess.filesearch, - bind filesearch::pick_file("intrinsics.bc", _)) { - option::some(path) { path } - option::none { - sess.warn("couldn't find intrinsics.bc"); - ret option::none; - } - }; - let membuf = str::as_c_str(path, {|buf| - llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf) - }); - if membuf as uint == 0u { - llvm_err(sess, "installation problem: couldn't open " + path); - } - let llintrinsicsmod = llvm::LLVMRustParseBitcode(membuf); - llvm::LLVMDisposeMemoryBuffer(membuf); - if llintrinsicsmod as uint == 0u { - sess.warn("couldn't parse intrinsics.bc"); - ret option::none; - } - - ret option::some(llintrinsicsmod); -} - -fn load_intrinsics_ll(sess: session) -> ModuleRef { - let path = alt filesearch::search( - sess.filesearch, - bind filesearch::pick_file("intrinsics.ll", _)) { - option::some(path) { path } - option::none { sess.fatal("couldn't find intrinsics.ll") } - }; - let llintrinsicsmod = str::as_c_str(path, { |buf| - llvm::LLVMRustParseAssemblyFile(buf) - }); - if llintrinsicsmod as uint == 0u { - llvm_err(sess, "couldn't parse intrinsics.ll"); - } - ret llintrinsicsmod; -} - -fn link_intrinsics(sess: session, llmod: ModuleRef) { - let llintrinsicsmod = { - alt load_intrinsics_bc(sess) { - option::some(m) { m } - option::none { - // When the bitcode format changes we can't parse a .bc - // file produced with a newer LLVM (as happens when stage0 - // is trying to build against a new LLVM revision), in - // that case we'll try to parse the assembly. - sess.warn("couldn't parse intrinsics.bc, trying intrinsics.ll"); - load_intrinsics_ll(sess) - } - } - }; - let linkres = llvm::LLVMLinkModules(llmod, llintrinsicsmod); - llvm::LLVMDisposeModule(llintrinsicsmod); - if linkres == False { - llvm_err(sess, "couldn't link the module with the intrinsics"); - } -} - mod write { fn is_object_or_assembly_or_exe(ot: output_type) -> bool { if ot == output_type_assembly || ot == output_type_object || @@ -115,7 +52,6 @@ mod write { fn run_passes(sess: session, llmod: ModuleRef, output: str) { let opts = sess.opts; if opts.time_llvm_passes { llvm::LLVMRustEnableTimePasses(); } - link_intrinsics(sess, llmod); let mut pm = mk_pass_manager(); let td = mk_target_data( sess.targ_cfg.target_strs.data_layout); diff --git a/src/rustc/back/upcall.rs b/src/rustc/back/upcall.rs index 3d8b051638b..43c924b9595 100644 --- a/src/rustc/back/upcall.rs +++ b/src/rustc/back/upcall.rs @@ -17,7 +17,6 @@ type upcalls = shared_realloc: ValueRef, mark: ValueRef, vec_grow: ValueRef, - vec_push: ValueRef, str_concat: ValueRef, cmp_type: ValueRef, log_type: ValueRef, @@ -41,7 +40,6 @@ fn declare_upcalls(targ_cfg: @session::config, } let d = bind decl(llmod, "upcall_", _, _, _); let dv = bind decl(llmod, "upcall_", _, _, T_void()); - let dvi = bind decl(llmod, "upcall_intrinsic_", _, _, T_void()); let int_t = T_int(targ_cfg); let size_t = T_size_t(targ_cfg); @@ -66,10 +64,6 @@ fn declare_upcalls(targ_cfg: @session::config, d("mark", [T_ptr(T_i8())], int_t), vec_grow: dv("vec_grow", [T_ptr(T_ptr(opaque_vec_t)), int_t]), - vec_push: - dvi("vec_push", - [T_ptr(T_ptr(opaque_vec_t)), T_ptr(tydesc_type), - T_ptr(T_i8())]), str_concat: d("str_concat", [T_ptr(opaque_vec_t), T_ptr(opaque_vec_t)], T_ptr(opaque_vec_t)), diff --git a/src/rustc/front/attr.rs b/src/rustc/front/attr.rs index 8c991517d88..4fdb3e2fe7e 100644 --- a/src/rustc/front/attr.rs +++ b/src/rustc/front/attr.rs @@ -237,9 +237,6 @@ fn native_abi(attrs: [ast::attribute]) -> either<str, ast::native_abi> { option::none { either::right(ast::native_abi_cdecl) } - option::some("rust-intrinsic") { - either::right(ast::native_abi_rust_intrinsic) - } option::some("rust-builtin") { either::right(ast::native_abi_rust_builtin) } diff --git a/src/rustc/metadata/common.rs b/src/rustc/metadata/common.rs index 00aa26969d7..8a6b0eb30b2 100644 --- a/src/rustc/metadata/common.rs +++ b/src/rustc/metadata/common.rs @@ -68,7 +68,6 @@ const tag_mod_impl: uint = 0x30u; const tag_item_method: uint = 0x31u; const tag_impl_iface: uint = 0x32u; -const tag_item_is_intrinsic: uint = 0x33u; // discriminator value for variants const tag_disr_val: uint = 0x34u; diff --git a/src/rustc/metadata/csearch.rs b/src/rustc/metadata/csearch.rs index 02b506f7070..e43b7aa7ff3 100644 --- a/src/rustc/metadata/csearch.rs +++ b/src/rustc/metadata/csearch.rs @@ -26,7 +26,6 @@ export get_type; export get_impl_iface; export get_impl_method; export get_item_path; -export item_is_intrinsic; export maybe_get_item_ast, found_ast, found, found_parent, not_found; fn get_symbol(cstore: cstore::cstore, def: ast::def_id) -> str { @@ -190,11 +189,6 @@ fn get_class_method(cstore: cstore::cstore, def: ast::def_id, mname: str) decoder::get_class_method(cdata, def.node, mname) } -fn item_is_intrinsic(cstore: cstore::cstore, def: ast::def_id) -> bool { - let cdata = cstore::get_crate_data(cstore, def.crate); - decoder::item_is_intrinsic(cdata, def.node) -} - // Local Variables: // mode: rust // fill-column: 78; diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs index cf1947a96dc..97a77dd71d3 100644 --- a/src/rustc/metadata/decoder.rs +++ b/src/rustc/metadata/decoder.rs @@ -41,7 +41,6 @@ export get_item_path; export maybe_find_item; // sketchy export item_type; // sketchy export maybe_get_item_ast; -export item_is_intrinsic; // Used internally by astencode: export translate_def_id; @@ -309,13 +308,6 @@ fn get_class_method(cdata: cmd, id: ast::node_id, name: str) -> ast::def_id { } } -fn item_is_intrinsic(cdata: cmd, id: ast::node_id) -> bool { - let mut intrinsic = false; - ebml::tagged_docs(lookup_item(id, cdata.data), tag_item_is_intrinsic, - {|_i| intrinsic = true;}); - intrinsic -} - fn get_symbol(data: @[u8], id: ast::node_id) -> str { ret item_symbol(lookup_item(id, data)); } diff --git a/src/rustc/metadata/encoder.rs b/src/rustc/metadata/encoder.rs index 69086d4698b..2533d125457 100644 --- a/src/rustc/metadata/encoder.rs +++ b/src/rustc/metadata/encoder.rs @@ -676,10 +676,6 @@ fn encode_info_for_native_item(ecx: @encode_ctxt, ebml_w: ebml::writer, encode_def_id(ebml_w, local_def(nitem.id)); encode_family(ebml_w, purity_fn_family(fn_decl.purity)); encode_type_param_bounds(ebml_w, ecx, tps); - if abi == native_abi_rust_intrinsic { - ebml_w.start_tag(tag_item_is_intrinsic); - ebml_w.end_tag(); - } encode_type(ecx, ebml_w, node_id_to_type(ecx.ccx.tcx, nitem.id)); if abi == native_abi_rust_builtin { astencode::encode_inlined_item(ecx, ebml_w, path, diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index 0252802d6a7..7faf81bdcdc 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -1801,9 +1801,7 @@ enum callee_env { type lval_maybe_callee = {bcx: block, val: ValueRef, kind: lval_kind, - env: callee_env, - // Tydescs to pass. Only used to call intrinsics - tds: option<[ValueRef]>}; + env: callee_env}; fn null_env_ptr(bcx: block) -> ValueRef { C_null(T_opaque_box_ptr(bcx.ccx())) @@ -1822,7 +1820,7 @@ fn lval_temp(bcx: block, val: ValueRef) -> lval_result { fn lval_no_env(bcx: block, val: ValueRef, kind: lval_kind) -> lval_maybe_callee { - ret {bcx: bcx, val: val, kind: kind, env: is_closure, tds: none}; + ret {bcx: bcx, val: val, kind: kind, env: is_closure}; } fn trans_external_path(ccx: @crate_ctxt, did: ast::def_id, t: ty::t) @@ -1909,7 +1907,7 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: [ty::t], fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t], vtables: option<typeck::vtable_res>, ref_id: option<ast::node_id>) - -> {val: ValueRef, must_cast: bool, intrinsic: bool} { + -> {val: ValueRef, must_cast: bool} { let _icx = ccx.insn_ctxt("monomorphic_fn"); let mut must_cast = false; let substs = vec::map(real_substs, {|t| @@ -1927,7 +1925,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t], } alt ccx.monomorphized.find(hash_id) { some(val) { - ret {val: val, must_cast: must_cast, intrinsic: false}; + ret {val: val, must_cast: must_cast}; } none {} } @@ -1954,8 +1952,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t], ast_map::node_native_item(_, abi, _) { // Natives don't have to be monomorphized. ret {val: get_item_val(ccx, fn_id.node), - must_cast: true, - intrinsic: abi == ast::native_abi_rust_intrinsic}; + must_cast: true}; } ast_map::node_ctor(i, _) { alt check ccx.tcx.items.get(i.id) { @@ -2014,7 +2011,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t], } } } - {val: lldecl, must_cast: must_cast, intrinsic: false} + {val: lldecl, must_cast: must_cast} } fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id) @@ -2078,33 +2075,6 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id) } } -fn lval_intrinsic_fn(bcx: block, val: ValueRef, tys: [ty::t], - id: ast::node_id) -> lval_maybe_callee { - let _icx = bcx.insn_ctxt("lval_intrinsic_fn"); - fn add_tydesc_params(ccx: @crate_ctxt, llfty: TypeRef, n: uint) - -> TypeRef { - let out_ty = llvm::LLVMGetReturnType(llfty); - let n_args = llvm::LLVMCountParamTypes(llfty); - let args = vec::from_elem(n_args as uint, 0 as TypeRef); - unsafe { llvm::LLVMGetParamTypes(llfty, vec::unsafe::to_ptr(args)); } - T_fn(vec::slice(args, 0u, first_real_arg) + - vec::from_elem(n, T_ptr(ccx.tydesc_type)) + - vec::tailn(args, first_real_arg), out_ty) - } - - let mut bcx = bcx; - let ccx = bcx.ccx(); - let tds = vec::map(tys, {|t| - let mut ti = none, td = get_tydesc(bcx.ccx(), t, ti); - lazily_emit_all_tydesc_glue(ccx, ti); - td - }); - let llfty = type_of_fn_from_ty(ccx, node_id_type(bcx, id)); - let val = PointerCast(bcx, val, T_ptr(add_tydesc_params( - ccx, llfty, tys.len()))); - {bcx: bcx, val: val, kind: owned, env: null_env, tds: some(tds)} -} - fn lval_static_fn(bcx: block, fn_id: ast::def_id, id: ast::node_id) -> lval_maybe_callee { let _icx = bcx.insn_ctxt("lval_static_fn"); @@ -2128,14 +2098,13 @@ fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id, } else { fn_id }; if fn_id.crate == ast::local_crate && tys.len() > 0u { - let mut {val, must_cast, intrinsic} = + let mut {val, must_cast} = monomorphic_fn(ccx, fn_id, tys, vtables, some(id)); - if intrinsic { ret lval_intrinsic_fn(bcx, val, tys, id); } if must_cast { val = PointerCast(bcx, val, T_ptr(type_of_fn_from_ty( ccx, node_id_type(bcx, id)))); } - ret {bcx: bcx, val: val, kind: owned, env: null_env, tds: none}; + ret {bcx: bcx, val: val, kind: owned, env: null_env}; } let mut val = if fn_id.crate == ast::local_crate { @@ -2146,11 +2115,6 @@ fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id, trans_external_path(ccx, fn_id, tpt.ty) }; if tys.len() > 0u { - // This is supposed to be an external native function. - // Unfortunately, I found no easy/cheap way to assert that. - if csearch::item_is_intrinsic(ccx.sess.cstore, fn_id) { - ret lval_intrinsic_fn(bcx, val, tys, id); - } val = PointerCast(bcx, val, T_ptr(type_of_fn_from_ty( ccx, node_id_type(bcx, id)))); } @@ -2167,7 +2131,7 @@ fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id, } } - ret {bcx: bcx, val: val, kind: owned, env: null_env, tds: none}; + ret {bcx: bcx, val: val, kind: owned, env: null_env}; } fn lookup_discriminant(ccx: @crate_ctxt, vid: ast::def_id) -> ValueRef { @@ -2625,7 +2589,7 @@ enum call_args { // - new_fn_ctxt // - trans_args fn trans_args(cx: block, llenv: ValueRef, args: call_args, fn_ty: ty::t, - dest: dest, always_valid_retptr: bool) + dest: dest) -> {bcx: block, args: [ValueRef], retslot: ValueRef} { let _icx = cx.insn_ctxt("trans_args"); let mut temp_cleanups = []; @@ -2639,7 +2603,7 @@ fn trans_args(cx: block, llenv: ValueRef, args: call_args, fn_ty: ty::t, // Arg 0: Output pointer. let llretslot = alt dest { ignore { - if ty::type_is_nil(retty) && !always_valid_retptr { + if ty::type_is_nil(retty) { llvm::LLVMGetUndef(T_ptr(T_nil())) } else { let {bcx: cx, val} = alloc_ty(bcx, retty); @@ -2733,15 +2697,10 @@ fn trans_call_inner(in_cx: block, fn_expr_ty: ty::t, ret_ty: ty::t, }; let args_res = { - trans_args(bcx, llenv, args, fn_expr_ty, dest, - option::is_some(f_res.tds)) + trans_args(bcx, llenv, args, fn_expr_ty, dest) }; bcx = args_res.bcx; let mut llargs = args_res.args; - option::may(f_res.tds) {|vals| - llargs = vec::slice(llargs, 0u, first_real_arg) + vals + - vec::tailn(llargs, first_real_arg); - } let llretslot = args_res.retslot; diff --git a/src/rustc/middle/trans/closure.rs b/src/rustc/middle/trans/closure.rs index 153cc079d6b..a10eda9932a 100644 --- a/src/rustc/middle/trans/closure.rs +++ b/src/rustc/middle/trans/closure.rs @@ -416,7 +416,6 @@ fn trans_bind_1(cx: block, outgoing_fty: ty::t, args: [option<@ast::expr>], pair_ty: ty::t, dest: dest) -> block { let _icx = cx.insn_ctxt("closure::trans_bind1"); - assert option::is_none(f_res.tds); let ccx = cx.ccx(); let mut bound: [@ast::expr] = []; for argopt: option<@ast::expr> in args { diff --git a/src/rustc/middle/trans/impl.rs b/src/rustc/middle/trans/impl.rs index 3fa4dfc80b0..0f9c5cf4759 100644 --- a/src/rustc/middle/trans/impl.rs +++ b/src/rustc/middle/trans/impl.rs @@ -79,7 +79,7 @@ fn trans_vtable_callee(bcx: block, env: callee_env, vtable: ValueRef, let vtable = PointerCast(bcx, vtable, T_ptr(T_array(T_ptr(llfty), n_method + 1u))); let mptr = Load(bcx, GEPi(bcx, vtable, [0, n_method as int])); - {bcx: bcx, val: mptr, kind: owned, env: env, tds: none} + {bcx: bcx, val: mptr, kind: owned, env: env} } fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id, diff --git a/src/rustc/middle/trans/native.rs b/src/rustc/middle/trans/native.rs index be10c8d0e78..dbbf918f896 100644 --- a/src/rustc/middle/trans/native.rs +++ b/src/rustc/middle/trans/native.rs @@ -730,10 +730,6 @@ fn trans_native_mod(ccx: @crate_ctxt, } let mut cc = alt abi { - ast::native_abi_rust_intrinsic { - for item in native_mod.items { get_item_val(ccx, item.id); } - ret; - } ast::native_abi_rust_builtin { ret; } ast::native_abi_cdecl { lib::llvm::CCallConv } ast::native_abi_stdcall { lib::llvm::X86StdcallCallConv } @@ -1009,28 +1005,5 @@ fn abi_of_native_fn(ccx: @crate_ctxt, i: @ast::native_item) fn decl_native_fn(ccx: @crate_ctxt, i: @ast::native_item, pth: ast_map::path) -> ValueRef { - let _icx = ccx.insn_ctxt("native::decl_native_fn"); - alt i.node { - ast::native_item_fn(_, _) { - let node_type = ty::node_id_to_type(ccx.tcx, i.id); - alt abi_of_native_fn(ccx, i) { - ast::native_abi_rust_intrinsic { - // For intrinsics: link the function directly to the intrinsic - // function itself. - let fn_type = type_of_fn_from_ty(ccx, node_type); - let ri_name = "rust_intrinsic_" + native::link_name(i); - ccx.item_symbols.insert(i.id, ri_name); - get_extern_fn(ccx.externs, ccx.llmod, ri_name, - lib::llvm::CCallConv, fn_type) - } - ast::native_abi_cdecl | ast::native_abi_stdcall | - ast::native_abi_rust_builtin { - // For true external functions: create a rust wrapper - // and link to that. The rust wrapper will handle - // switching to the C stack. - register_fn(ccx, i.span, pth, i.id) - } - } - } - } + register_fn(ccx, i.span, pth, i.id) } diff --git a/src/rustc/middle/trans/type_use.rs b/src/rustc/middle/trans/type_use.rs index 24b6f9cf572..5b381b79c4d 100644 --- a/src/rustc/middle/trans/type_use.rs +++ b/src/rustc/middle/trans/type_use.rs @@ -52,11 +52,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) _ {} } - // FIXME handle external native functions in a more efficient way if fn_id_loc.crate != local_crate { - if csearch::item_is_intrinsic(ccx.sess.cstore, fn_id) { - uint::range(0u, n_tps) {|n| cx.uses[n] |= use_tydesc;} - } let uses = vec::from_mut(cx.uses); ccx.type_use_cache.insert(fn_id, uses); ret uses; @@ -72,9 +68,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) uint::range(0u, n_tps) {|n| cx.uses[n] |= use_repr;} } ast_map::node_native_item(i@@{node: native_item_fn(_, _), _}, abi, _) { - if abi == native_abi_rust_intrinsic { - uint::range(0u, n_tps) {|n| cx.uses[n] |= use_tydesc;} - } else if abi == native_abi_rust_builtin { + if abi == native_abi_rust_builtin { let flags = alt check i.ident { "size_of" | "align_of" | "init" | "reinterpret_cast" { use_repr } diff --git a/src/rustc/syntax/ast.rs b/src/rustc/syntax/ast.rs index 0776ec3dfbd..e3881eec203 100644 --- a/src/rustc/syntax/ast.rs +++ b/src/rustc/syntax/ast.rs @@ -556,7 +556,6 @@ type _mod = {view_items: [@view_item], items: [@item]}; #[auto_serialize] enum native_abi { - native_abi_rust_intrinsic, native_abi_rust_builtin, native_abi_cdecl, native_abi_stdcall, |
