parent
f5024692d4
commit
562afef216
@ -237,8 +237,8 @@ fn native_abi(attrs: [ast::attribute]) -> either<str, ast::native_abi> {
|
||||
option::none {
|
||||
either::right(ast::native_abi_cdecl)
|
||||
}
|
||||
option::some("rust-builtin") {
|
||||
either::right(ast::native_abi_rust_builtin)
|
||||
option::some("rust-builtin") | option::some("rust-intrinsic") {
|
||||
either::right(ast::native_abi_rust_intrinsic)
|
||||
}
|
||||
option::some("cdecl") {
|
||||
either::right(ast::native_abi_cdecl)
|
||||
|
@ -677,7 +677,7 @@ fn encode_info_for_native_item(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
encode_family(ebml_w, purity_fn_family(fn_decl.purity));
|
||||
encode_type_param_bounds(ebml_w, ecx, tps);
|
||||
encode_type(ecx, ebml_w, node_id_to_type(ecx.ccx.tcx, nitem.id));
|
||||
if abi == native_abi_rust_builtin {
|
||||
if abi == native_abi_rust_intrinsic {
|
||||
astencode::encode_inlined_item(ecx, ebml_w, path,
|
||||
ii_native(nitem));
|
||||
} else {
|
||||
|
@ -92,7 +92,7 @@ fn map_decoded_item(sess: session, map: map, path: path, ii: inlined_item) {
|
||||
alt ii {
|
||||
ii_item(i) { /* fallthrough */ }
|
||||
ii_native(i) {
|
||||
cx.map.insert(i.id, node_native_item(i, native_abi_rust_builtin,
|
||||
cx.map.insert(i.id, node_native_item(i, native_abi_rust_intrinsic,
|
||||
@path));
|
||||
}
|
||||
ii_method(impl_did, m) {
|
||||
|
@ -124,7 +124,7 @@ fn check_ctypes(tcx: ty::ctxt, crate: @ast::crate) {
|
||||
fn check_item(tcx: ty::ctxt, it: @ast::item) {
|
||||
alt it.node {
|
||||
ast::item_native_mod(nmod) if attr::native_abi(it.attrs) !=
|
||||
either::right(ast::native_abi_rust_builtin) {
|
||||
either::right(ast::native_abi_rust_intrinsic) {
|
||||
for ni in nmod.items {
|
||||
alt ni.node {
|
||||
ast::native_item_fn(decl, tps) {
|
||||
|
@ -1947,7 +1947,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t],
|
||||
}
|
||||
ast_map::node_variant(v, _, pt) { (pt, v.node.name) }
|
||||
ast_map::node_method(m, _, pt) { (pt, m.ident) }
|
||||
ast_map::node_native_item(i, ast::native_abi_rust_builtin, pt)
|
||||
ast_map::node_native_item(i, ast::native_abi_rust_intrinsic, pt)
|
||||
{ (pt, i.ident) }
|
||||
ast_map::node_native_item(_, abi, _) {
|
||||
// Natives don't have to be monomorphized.
|
||||
@ -1981,8 +1981,8 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t],
|
||||
trans_fn(ccx, pt, d, body, lldecl, no_self, psubsts, d_id, none);
|
||||
}
|
||||
ast_map::node_native_item(i, _, _) {
|
||||
native::trans_builtin(ccx, lldecl, i, pt, option::get(psubsts),
|
||||
ref_id);
|
||||
native::trans_intrinsic(ccx, lldecl, i, pt, option::get(psubsts),
|
||||
ref_id);
|
||||
}
|
||||
ast_map::node_variant(v, enum_item, _) {
|
||||
let tvs = ty::enum_variants(ccx.tcx, local_def(enum_item.id));
|
||||
|
@ -16,7 +16,7 @@ import std::map::hashmap;
|
||||
import util::ppaux::ty_to_str;
|
||||
|
||||
export link_name, trans_native_mod, register_crust_fn, trans_crust_fn,
|
||||
decl_native_fn, trans_builtin;
|
||||
decl_native_fn, trans_intrinsic;
|
||||
|
||||
enum x86_64_reg_class {
|
||||
no_class,
|
||||
@ -730,7 +730,7 @@ fn trans_native_mod(ccx: @crate_ctxt,
|
||||
}
|
||||
|
||||
let mut cc = alt abi {
|
||||
ast::native_abi_rust_builtin { ret; }
|
||||
ast::native_abi_rust_intrinsic { ret; }
|
||||
ast::native_abi_cdecl { lib::llvm::CCallConv }
|
||||
ast::native_abi_stdcall { lib::llvm::X86StdcallCallConv }
|
||||
};
|
||||
@ -752,9 +752,9 @@ fn trans_native_mod(ccx: @crate_ctxt,
|
||||
}
|
||||
}
|
||||
|
||||
fn trans_builtin(ccx: @crate_ctxt, decl: ValueRef, item: @ast::native_item,
|
||||
path: ast_map::path, substs: param_substs,
|
||||
ref_id: option<ast::node_id>) {
|
||||
fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::native_item,
|
||||
path: ast_map::path, substs: param_substs,
|
||||
ref_id: option<ast::node_id>) {
|
||||
let fcx = new_fn_ctxt_w_id(ccx, path, decl, item.id, none,
|
||||
some(substs), some(item.span));
|
||||
let bcx = top_scope_block(fcx, none), lltop = bcx.llbb;
|
||||
|
@ -68,7 +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_builtin {
|
||||
if abi == native_abi_rust_intrinsic {
|
||||
let flags = alt check i.ident {
|
||||
"size_of" | "align_of" | "init" |
|
||||
"reinterpret_cast" { use_repr }
|
||||
|
@ -948,8 +948,8 @@ mod collect {
|
||||
ast::item_mod(_) {}
|
||||
ast::item_native_mod(m) {
|
||||
if front::attr::native_abi(it.attrs) ==
|
||||
either::right(ast::native_abi_rust_builtin) {
|
||||
for item in m.items { check_builtin_type(tcx, item); }
|
||||
either::right(ast::native_abi_rust_intrinsic) {
|
||||
for item in m.items { check_intrinsic_type(tcx, item); }
|
||||
}
|
||||
}
|
||||
ast::item_enum(variants, ty_params) {
|
||||
@ -1414,7 +1414,7 @@ mod writeback {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_builtin_type(tcx: ty::ctxt, it: @ast::native_item) {
|
||||
fn check_intrinsic_type(tcx: ty::ctxt, it: @ast::native_item) {
|
||||
fn param(tcx: ty::ctxt, n: uint) -> ty::t {
|
||||
ty::mk_param(tcx, n, local_def(0))
|
||||
}
|
||||
@ -1432,7 +1432,7 @@ fn check_builtin_type(tcx: ty::ctxt, it: @ast::native_item) {
|
||||
"addr_of" { (1u, [arg(ast::by_ref, param(tcx, 0u))],
|
||||
ty::mk_imm_ptr(tcx, param(tcx, 0u))) }
|
||||
other {
|
||||
tcx.sess.span_err(it.span, "unrecognized builtin function: `" +
|
||||
tcx.sess.span_err(it.span, "unrecognized intrinsic function: `" +
|
||||
other + "`");
|
||||
ret;
|
||||
}
|
||||
@ -1444,11 +1444,11 @@ fn check_builtin_type(tcx: ty::ctxt, it: @ast::native_item) {
|
||||
let i_ty = ty_of_native_item(tcx, m_collect, it);
|
||||
let i_n_tps = (*i_ty.bounds).len();
|
||||
if i_n_tps != n_tps {
|
||||
tcx.sess.span_err(it.span, #fmt("builtin function has wrong number \
|
||||
tcx.sess.span_err(it.span, #fmt("intrinsic has wrong number \
|
||||
of type parameters. found %u, \
|
||||
expected %u", i_n_tps, n_tps));
|
||||
} else if !ty::same_type(tcx, i_ty.ty, fty) {
|
||||
tcx.sess.span_err(it.span, #fmt("builtin function has wrong type. \
|
||||
tcx.sess.span_err(it.span, #fmt("intrinsic has wrong type. \
|
||||
expected %s", ty_to_str(tcx, fty)));
|
||||
}
|
||||
}
|
||||
|
@ -556,7 +556,7 @@ type _mod = {view_items: [@view_item], items: [@item]};
|
||||
|
||||
#[auto_serialize]
|
||||
enum native_abi {
|
||||
native_abi_rust_builtin,
|
||||
native_abi_rust_intrinsic,
|
||||
native_abi_cdecl,
|
||||
native_abi_stdcall,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user