mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 02:03:53 +00:00
Fix simple generic type parameters in LLVM.
This commit is contained in:
parent
09885b5b87
commit
2c24f70cf4
@ -427,8 +427,6 @@ TEST_XFAILS_LLVM := $(addprefix test/run-pass/, \
|
|||||||
generic-recursive-tag.rs \
|
generic-recursive-tag.rs \
|
||||||
generic-tag-alt.rs \
|
generic-tag-alt.rs \
|
||||||
generic-tag.rs \
|
generic-tag.rs \
|
||||||
generic-type-synonym.rs \
|
|
||||||
generic-type.rs \
|
|
||||||
import.rs \
|
import.rs \
|
||||||
inner-module.rs \
|
inner-module.rs \
|
||||||
large-records.rs \
|
large-records.rs \
|
||||||
|
@ -6,6 +6,7 @@ type abi = {
|
|||||||
crate_ty: Llvm.lltype;
|
crate_ty: Llvm.lltype;
|
||||||
task_ty: Llvm.lltype;
|
task_ty: Llvm.lltype;
|
||||||
word_ty: Llvm.lltype;
|
word_ty: Llvm.lltype;
|
||||||
|
tydesc_ty: Llvm.lltype;
|
||||||
rust_start: Llvm.llvalue;
|
rust_start: Llvm.llvalue;
|
||||||
};;
|
};;
|
||||||
|
|
||||||
@ -13,6 +14,7 @@ let declare_abi (llctx:Llvm.llcontext) (llmod:Llvm.llmodule) : abi =
|
|||||||
let i32 = Llvm.i32_type llctx in
|
let i32 = Llvm.i32_type llctx in
|
||||||
(* FIXME: Use Llvm_target.intptr_type for more platform support. *)
|
(* FIXME: Use Llvm_target.intptr_type for more platform support. *)
|
||||||
let word_ty = i32 in
|
let word_ty = i32 in
|
||||||
|
let p ty = Llvm.pointer_type ty in
|
||||||
|
|
||||||
let crate_ty =
|
let crate_ty =
|
||||||
(* TODO: other architectures besides x86 *)
|
(* TODO: other architectures besides x86 *)
|
||||||
@ -53,6 +55,27 @@ let declare_abi (llctx:Llvm.llcontext) (llmod:Llvm.llmodule) : abi =
|
|||||||
in
|
in
|
||||||
ignore (Llvm.define_type_name "rust_task" task_ty llmod);
|
ignore (Llvm.define_type_name "rust_task" task_ty llmod);
|
||||||
|
|
||||||
|
(* This is the type_desc struct in rust_internal.h *)
|
||||||
|
let tydesc_ty =
|
||||||
|
(* TODO: other architectures besides x86 *)
|
||||||
|
let tydesc_opaque_ty = Llvm.opaque_type llctx in
|
||||||
|
let tydesc_tyhandle = Llvm.handle_to_type (Llvm.struct_type llctx [|
|
||||||
|
p (p tydesc_opaque_ty); (* const type_desc **first_param *)
|
||||||
|
word_ty; (* size_t size *)
|
||||||
|
word_ty; (* size_t align *)
|
||||||
|
word_ty; (* uintptr_t copy_glue_off *)
|
||||||
|
word_ty; (* uintptr_t drop_glue_off *)
|
||||||
|
word_ty; (* uintptr_t free_glue_off *)
|
||||||
|
word_ty; (* uintptr_t sever_glue_off *)
|
||||||
|
word_ty; (* uintptr_t mark_glue_off *)
|
||||||
|
word_ty; (* uintptr_t obj_drop_glue_off *)
|
||||||
|
|])
|
||||||
|
in
|
||||||
|
Llvm.refine_type tydesc_opaque_ty (Llvm.type_of_handle tydesc_tyhandle);
|
||||||
|
Llvm.type_of_handle tydesc_tyhandle
|
||||||
|
in
|
||||||
|
ignore (Llvm.define_type_name "type_desc" tydesc_ty llmod);
|
||||||
|
|
||||||
let rust_start_ty =
|
let rust_start_ty =
|
||||||
(* Rust's main function can have several types, so we cast them
|
(* Rust's main function can have several types, so we cast them
|
||||||
all to uintptr_t. *)
|
all to uintptr_t. *)
|
||||||
@ -64,6 +87,7 @@ let declare_abi (llctx:Llvm.llcontext) (llmod:Llvm.llmodule) : abi =
|
|||||||
crate_ty = crate_ty;
|
crate_ty = crate_ty;
|
||||||
task_ty = task_ty;
|
task_ty = task_ty;
|
||||||
word_ty = word_ty;
|
word_ty = word_ty;
|
||||||
|
tydesc_ty = tydesc_ty;
|
||||||
rust_start = Llvm.declare_function "rust_start" rust_start_ty llmod
|
rust_start = Llvm.declare_function "rust_start" rust_start_ty llmod
|
||||||
}
|
}
|
||||||
;;
|
;;
|
||||||
|
@ -346,12 +346,13 @@ let trans_crate
|
|||||||
| Ast.TY_native _ ->
|
| Ast.TY_native _ ->
|
||||||
word_ty
|
word_ty
|
||||||
|
|
||||||
|
| Ast.TY_param _ ->
|
||||||
|
abi.Llabi.tydesc_ty
|
||||||
|
|
||||||
| Ast.TY_tag _ | Ast.TY_iso _ | Ast.TY_idx _
|
| Ast.TY_tag _ | Ast.TY_iso _ | Ast.TY_idx _
|
||||||
| Ast.TY_obj _ | Ast.TY_type ->
|
| Ast.TY_obj _ | Ast.TY_type | Ast.TY_named _ ->
|
||||||
Common.unimpl None "LLVM type translation for: %a" Ast.sprintf_ty ty
|
Common.unimpl None "LLVM type translation for: %a" Ast.sprintf_ty ty
|
||||||
|
|
||||||
| Ast.TY_param _ | Ast.TY_named _ ->
|
|
||||||
bug () "unresolved type in lltrans"
|
|
||||||
|
|
||||||
and trans_ty t =
|
and trans_ty t =
|
||||||
htab_search_or_add lltys t (fun _ -> trans_ty_full t)
|
htab_search_or_add lltys t (fun _ -> trans_ty_full t)
|
||||||
|
Loading…
Reference in New Issue
Block a user