mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-07 15:37:39 +00:00
Fix LLVM translation of modules.
This commit is contained in:
parent
80a1cd3d1e
commit
fdb842f9e6
@ -418,7 +418,6 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
|
|||||||
alt-tag.rs \
|
alt-tag.rs \
|
||||||
arithmetic-interference.rs \
|
arithmetic-interference.rs \
|
||||||
argv.rs \
|
argv.rs \
|
||||||
auto-deref.rs \
|
|
||||||
autoderef-full-lval.rs \
|
autoderef-full-lval.rs \
|
||||||
autoderef-objfn.rs \
|
autoderef-objfn.rs \
|
||||||
basic.rs \
|
basic.rs \
|
||||||
@ -452,7 +451,6 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
|
|||||||
generic-drop-glue.rs \
|
generic-drop-glue.rs \
|
||||||
generic-exterior-box.rs \
|
generic-exterior-box.rs \
|
||||||
generic-fn-infer.rs \
|
generic-fn-infer.rs \
|
||||||
generic-fn-twice.rs \
|
|
||||||
generic-fn.rs \
|
generic-fn.rs \
|
||||||
generic-obj-with-derived-type.rs \
|
generic-obj-with-derived-type.rs \
|
||||||
generic-obj.rs \
|
generic-obj.rs \
|
||||||
@ -482,8 +480,6 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
|
|||||||
mutable-alias-vec.rs \
|
mutable-alias-vec.rs \
|
||||||
mutable-vec-drop.rs \
|
mutable-vec-drop.rs \
|
||||||
mutual-recursion-group.rs \
|
mutual-recursion-group.rs \
|
||||||
native-mod.rc \
|
|
||||||
native.rc \
|
|
||||||
obj-as.rs \
|
obj-as.rs \
|
||||||
obj-drop.rs \
|
obj-drop.rs \
|
||||||
obj-dtor.rs \
|
obj-dtor.rs \
|
||||||
|
@ -588,7 +588,7 @@ let trans_crate
|
|||||||
(* Maps a fn's or block's id to an LLVM metadata node (subprogram or
|
(* Maps a fn's or block's id to an LLVM metadata node (subprogram or
|
||||||
lexical block) representing it. *)
|
lexical block) representing it. *)
|
||||||
let (dbg_llscopes:(node_id, Llvm.llvalue) Hashtbl.t) = Hashtbl.create 0 in
|
let (dbg_llscopes:(node_id, Llvm.llvalue) Hashtbl.t) = Hashtbl.create 0 in
|
||||||
let declare_mod_item
|
let rec declare_mod_item
|
||||||
(name:Ast.ident)
|
(name:Ast.ident)
|
||||||
mod_item
|
mod_item
|
||||||
: unit =
|
: unit =
|
||||||
@ -616,9 +616,8 @@ let trans_crate
|
|||||||
| Ast.MOD_ITEM_type _ ->
|
| Ast.MOD_ITEM_type _ ->
|
||||||
() (* Types get translated with their terms. *)
|
() (* Types get translated with their terms. *)
|
||||||
|
|
||||||
| Ast.MOD_ITEM_mod _ ->
|
| Ast.MOD_ITEM_mod (_, items) ->
|
||||||
() (* Modules simply contain other items that are translated
|
Hashtbl.iter declare_mod_item items
|
||||||
on their own. *)
|
|
||||||
|
|
||||||
| _ ->
|
| _ ->
|
||||||
Common.unimpl (Some id)
|
Common.unimpl (Some id)
|
||||||
@ -807,6 +806,17 @@ let trans_crate
|
|||||||
Ast.sprintf_lval lval)
|
Ast.sprintf_lval lval)
|
||||||
in
|
in
|
||||||
|
|
||||||
|
let trans_callee (fn:Ast.lval) : (Llvm.llvalue * Ast.ty) =
|
||||||
|
let fty = Hashtbl.find sem_cx.ctxt_all_lval_types (lval_base_id fn) in
|
||||||
|
if lval_base_is_item sem_cx fn then
|
||||||
|
let fn_item = lval_item sem_cx fn in
|
||||||
|
let llfn = Hashtbl.find llitems (fn_item.id) in
|
||||||
|
(llfn, fty)
|
||||||
|
else
|
||||||
|
(* indirect call to computed slot *)
|
||||||
|
trans_lval fn
|
||||||
|
in
|
||||||
|
|
||||||
let trans_atom (atom:Ast.atom) : Llvm.llvalue =
|
let trans_atom (atom:Ast.atom) : Llvm.llvalue =
|
||||||
iflog (fun _ -> log sem_cx "trans_atom: %a" Ast.sprintf_atom atom);
|
iflog (fun _ -> log sem_cx "trans_atom: %a" Ast.sprintf_atom atom);
|
||||||
match atom with
|
match atom with
|
||||||
@ -959,7 +969,7 @@ let trans_crate
|
|||||||
| Ast.STMT_call (dest, fn, args) ->
|
| Ast.STMT_call (dest, fn, args) ->
|
||||||
let llargs = Array.map trans_atom args in
|
let llargs = Array.map trans_atom args in
|
||||||
let (lldest, _) = trans_lval dest in
|
let (lldest, _) = trans_lval dest in
|
||||||
let (llfn, _) = trans_lval fn in
|
let (llfn, _) = trans_callee fn in
|
||||||
let llallargs = Array.append [| lldest; lltask |] llargs in
|
let llallargs = Array.append [| lldest; lltask |] llargs in
|
||||||
let llrv = build_call llfn llallargs "" llbuilder in
|
let llrv = build_call llfn llallargs "" llbuilder in
|
||||||
Llvm.set_instruction_call_conv Llvm.CallConv.c llrv;
|
Llvm.set_instruction_call_conv Llvm.CallConv.c llrv;
|
||||||
@ -1072,13 +1082,22 @@ let trans_crate
|
|||||||
ignore (Llvm.build_br llbodyblock llinitbuilder)
|
ignore (Llvm.build_br llbodyblock llinitbuilder)
|
||||||
in
|
in
|
||||||
|
|
||||||
let trans_mod_item
|
let rec trans_mod_item
|
||||||
(_:Ast.ident)
|
(name:Ast.ident)
|
||||||
{ node = { Ast.decl_item = (item:Ast.mod_item') }; id = id }
|
mod_item
|
||||||
: unit =
|
: unit =
|
||||||
|
let { node = { Ast.decl_item = (item:Ast.mod_item') }; id = id } =
|
||||||
|
mod_item in
|
||||||
match item with
|
match item with
|
||||||
Ast.MOD_ITEM_fn fn -> trans_fn fn id
|
Ast.MOD_ITEM_type _ ->
|
||||||
| _ -> ()
|
() (* Types get translated with their terms. *)
|
||||||
|
| Ast.MOD_ITEM_mod (_, items) ->
|
||||||
|
Hashtbl.iter trans_mod_item items
|
||||||
|
| Ast.MOD_ITEM_fn fn -> trans_fn fn id
|
||||||
|
| _ -> Common.unimpl (Some id)
|
||||||
|
"LLVM module declaration for: %a"
|
||||||
|
Ast.sprintf_mod_item (name, mod_item)
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
let exit_task_glue =
|
let exit_task_glue =
|
||||||
|
Loading…
Reference in New Issue
Block a user