diff options
| author | Graydon Hoare <[email protected]> | 2010-06-23 21:03:09 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2010-06-23 21:03:09 -0700 |
| commit | d6b7c96c3eb29b9244ece0c046d3f372ff432d04 (patch) | |
| tree | b425187e232966063ffc2f0d14c04a55d8f004ef /src/boot/llvm/llemit.ml | |
| parent | Initial git commit. (diff) | |
| download | rust-d6b7c96c3eb29b9244ece0c046d3f372ff432d04.tar.xz rust-d6b7c96c3eb29b9244ece0c046d3f372ff432d04.zip | |
Populate tree.
Diffstat (limited to 'src/boot/llvm/llemit.ml')
| -rw-r--r-- | src/boot/llvm/llemit.ml | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/boot/llvm/llemit.ml b/src/boot/llvm/llemit.ml new file mode 100644 index 00000000..2b229fde --- /dev/null +++ b/src/boot/llvm/llemit.ml @@ -0,0 +1,36 @@ +(* + * LLVM emitter. + *) + +(* The top-level interface to the LLVM translation subsystem. *) +let trans_and_process_crate + (sess:Session.sess) + (sem_cx:Semant.ctxt) + (crate:Ast.crate) + : unit = + let llcontext = Llvm.create_context () in + let emit_file (llmod:Llvm.llmodule) : unit = + let filename = Session.filename_of sess.Session.sess_out in + if not (Llvm_bitwriter.write_bitcode_file llmod filename) + then raise (Failure ("failed to write the LLVM bitcode '" ^ filename + ^ "'")) + in + let llmod = Lltrans.trans_crate sem_cx llcontext sess crate in + begin + try + emit_file llmod + with e -> Llvm.dispose_module llmod; raise e + end; + Llvm.dispose_module llmod; + Llvm.dispose_context llcontext +;; + +(* + * 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: + *) + |