From 72c6c60d80cdfe63af5046a1a98549f0515734f2 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 24 Jun 2010 19:21:40 -0700 Subject: [PATCH] Add intrinsic calling convention. --- src/boot/me/trans.ml | 12 ++++++++++-- src/boot/me/transutil.ml | 22 ++++++++++++++++++++++ src/boot/util/common.ml | 2 ++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/boot/me/trans.ml b/src/boot/me/trans.ml index b43ffb82c4b..3d23a94569a 100644 --- a/src/boot/me/trans.ml +++ b/src/boot/me/trans.ml @@ -4525,10 +4525,12 @@ let trans_visitor [| Asm.WORD (word_ty_mach, Asm.IMM 0L) |])) in - let trans_required_fn (fnid:node_id) (blockid:node_id) : unit = + let trans_real_required_fn + (fnid:node_id) + (blockid:node_id) : unit = + let (ilib, conv) = Hashtbl.find cx.ctxt_required_items fnid in trans_frame_entry fnid; emit (Il.Enter (Hashtbl.find cx.ctxt_block_fixups blockid)); - let (ilib, conv) = Hashtbl.find cx.ctxt_required_items fnid in let lib_num = htab_search_or_add cx.ctxt_required_lib_num ilib (fun _ -> Hashtbl.length cx.ctxt_required_lib_num) @@ -4655,6 +4657,12 @@ let trans_visitor "Trans.required_rust_fn on unexpected form of require library" in + let trans_required_fn (fnid:node_id) (blockid:node_id) : unit = + if fn_is_intrinsic cx fnid + then () + else trans_real_required_fn fnid blockid + in + let trans_tag (n:Ast.ident) (tagid:node_id) diff --git a/src/boot/me/transutil.ml b/src/boot/me/transutil.ml index c430e034ca9..7a6f9b8e85a 100644 --- a/src/boot/me/transutil.ml +++ b/src/boot/me/transutil.ml @@ -225,6 +225,28 @@ let iter_rec_slots (Array.map snd entries) f curr_iso ;; +let intrinsic_name (cx:ctxt) (fnid:node_id) : string = + match Hashtbl.find cx.ctxt_all_item_names fnid with + Ast.NAME_base (Ast.BASE_ident id) -> id + | Ast.NAME_base (Ast.BASE_app (id, _)) -> id + | Ast.NAME_ext (_, Ast.COMP_ident id) -> id + | Ast.NAME_ext (_, Ast.COMP_app (id, _)) -> id + | _ -> err (Some fnid) "unexpected name for intrinsic fn" +;; + +let fn_is_intrinsic (cx:ctxt) (fnid:node_id) : bool = + let (_, conv) = Hashtbl.find cx.ctxt_required_items fnid in + conv = CONV_intrinsic +;; + +let lval_is_intrinsic (cx:ctxt) (lval:Ast.lval) : bool = + let item = lval_item cx lval in + match item.node.Ast.decl_item with + Ast.MOD_ITEM_fn _ + when Hashtbl.mem cx.ctxt_required_items item.id -> + fn_is_intrinsic cx item.id + | _ -> false +;; diff --git a/src/boot/util/common.ml b/src/boot/util/common.ml index f33a6ea1649..ad784877398 100644 --- a/src/boot/util/common.ml +++ b/src/boot/util/common.ml @@ -105,6 +105,7 @@ type ty_param_idx = int type nabi_conv = CONV_rust | CONV_cdecl + | CONV_intrinsic ;; type nabi = { nabi_indirect: bool; @@ -115,6 +116,7 @@ let string_to_conv (a:string) : nabi_conv option = match a with "cdecl" -> Some CONV_cdecl | "rust" -> Some CONV_rust + | "intrinsic" -> Some CONV_intrinsic | _ -> None (* FIXME: remove this when native items go away. *)