aboutsummaryrefslogtreecommitdiff
path: root/src/boot/llvm/llfinal.ml
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-12-29 16:27:13 -0800
committerGraydon Hoare <[email protected]>2010-12-29 16:27:19 -0800
commit454bf428efa6f581f94f817d9f044d6934af1a0f (patch)
treee8726997e920a608d80526ea06fa7db9bd599594 /src/boot/llvm/llfinal.ml
parentrustc: Make parametric return types go through an out pointer (diff)
downloadrust-454bf428efa6f581f94f817d9f044d6934af1a0f.tar.xz
rust-454bf428efa6f581f94f817d9f044d6934af1a0f.zip
Remove LLVM rustboot backend.
Diffstat (limited to 'src/boot/llvm/llfinal.ml')
-rw-r--r--src/boot/llvm/llfinal.ml105
1 files changed, 0 insertions, 105 deletions
diff --git a/src/boot/llvm/llfinal.ml b/src/boot/llvm/llfinal.ml
deleted file mode 100644
index a7e190cd..00000000
--- a/src/boot/llvm/llfinal.ml
+++ /dev/null
@@ -1,105 +0,0 @@
-(*
- * LLVM ABI-level stuff that needs to happen after modules have been
- * translated.
- *)
-
-let finalize_module
- (sess:Session.sess)
- (llctx:Llvm.llcontext)
- (llmod:Llvm.llmodule)
- (abi:Llabi.abi)
- (asm_glue:Llasm.asm_glue)
- (exit_task_glue:Llvm.llvalue)
- (crate_ptr:Llvm.llvalue)
- : unit =
- let i32 = Llvm.i32_type llctx in
-
- (*
- * Count the number of Rust functions and the number of C functions by
- * simply (and crudely) testing whether each function in the module begins
- * with "_rust_".
- *)
-
- let (rust_fn_count, c_fn_count) =
- let count (rust_fn_count, c_fn_count) fn =
- let begins_with prefix str =
- let (str_len, prefix_len) =
- (String.length str, String.length prefix)
- in
- prefix_len <= str_len && (String.sub str 0 prefix_len) = prefix
- in
- if begins_with "_rust_" (Llvm.value_name fn) then
- (rust_fn_count + 1, c_fn_count)
- else
- (rust_fn_count, c_fn_count + 1)
- in
- Llvm.fold_left_functions count (0, 0) llmod
- in
-
- let crate_val =
- let crate_addr = Llvm.const_ptrtoint crate_ptr i32 in
- let glue_off glue =
- let addr = Llvm.const_ptrtoint glue i32 in
- Llvm.const_sub addr crate_addr
- in
- let activate_glue_off = glue_off asm_glue.Llasm.asm_activate_glue in
- let yield_glue_off = glue_off asm_glue.Llasm.asm_yield_glue in
- let exit_task_glue_off = glue_off exit_task_glue in
-
- Llvm.const_struct llctx [|
- Llvm.const_int i32 0; (* ptrdiff_t image_base_off *)
- crate_ptr; (* uintptr_t self_addr *)
- Llvm.const_int i32 0; (* ptrdiff_t debug_abbrev_off *)
- Llvm.const_int i32 0; (* size_t debug_abbrev_sz *)
- Llvm.const_int i32 0; (* ptrdiff_t debug_info_off *)
- Llvm.const_int i32 0; (* size_t debug_info_sz *)
- activate_glue_off; (* size_t activate_glue_off *)
- yield_glue_off; (* size_t yield_glue_off *)
- Llvm.const_int i32 0; (* size_t unwind_glue_off *)
- Llvm.const_int i32 0; (* size_t gc_glue_off *)
- exit_task_glue_off; (* size_t main_exit_task_glue_off *)
- Llvm.const_int i32 rust_fn_count; (* int n_rust_syms *)
- Llvm.const_int i32 c_fn_count; (* int n_c_syms *)
- Llvm.const_int i32 0 (* int n_libs *)
- |]
- in
-
- Llvm.set_initializer crate_val crate_ptr;
-
- (* Define the main function for crt0 to call. *)
- let main_fn =
- let main_ty = Llvm.function_type i32 [| i32; i32 |] in
- let main_name =
- match sess.Session.sess_targ with
- Common.Win32_x86_pe -> "WinMain@16"
- | Common.Linux_x86_elf
- | Common.MacOS_x86_macho -> "main"
- in
- Llvm.define_function main_name main_ty llmod
- in
- let argc = Llvm.param main_fn 0 in
- let argv = Llvm.param main_fn 1 in
- let main_builder = Llvm.builder_at_end llctx (Llvm.entry_block main_fn) in
- let rust_main_fn =
- match Llvm.lookup_function "_rust_main" llmod with
- None -> raise (Failure "no main function found")
- | Some fn -> fn
- in
- let rust_start = abi.Llabi.rust_start in
- let rust_start_args = [| Llvm.const_ptrtoint rust_main_fn abi.Llabi.word_ty;
- crate_ptr; argc; argv |] in
- ignore (Llvm.build_call
- rust_start rust_start_args "start_rust" main_builder);
- ignore (Llvm.build_ret (Llvm.const_int i32 0) main_builder)
-;;
-
-
-(*
- * Local Variables:
- * fill-column: 78;
- * indent-tabs-mode: nil
- * buffer-file-coding-system: utf-8-unix
- * compile-command: "make -k -C ../.. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
- * End:
- *)
-