caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Using OCaml's run-time from LLVM-generated native code
@ 2008-02-01 21:24 Jon Harrop
  2008-02-03 21:24 ` [Caml-list] " Alain Frisch
  0 siblings, 1 reply; 9+ messages in thread
From: Jon Harrop @ 2008-02-01 21:24 UTC (permalink / raw)
  To: caml-list


I would like to use OCaml's run-time in code that is run-time generated by 
LLVM as simply as possible (i.e. with no regard for efficiency yet). There 
are two main motivations for this:

1. Write a native-code compiler for MiniML as an educational exercise but 
without having to implement a GC.

2. Write a tool that autogenerates bindings to native-code libraries that are 
immediately usable from OCaml without having to go via C or use external 
tools (just LLVM).

I believe the easiest solution is to autogenerate equivalents of the CAML* 
macros from OCaml's C FFI. For example, the LLVM backend can then generate 
native code equivalent to (from [1]):

CAMLprim value
create_tuple( value a, value b, value c )
{
    CAMLparam3( a, b, c );
    CAMLlocal1( abc );

    abc = caml_alloc(3, 0);

    Store_field( abc, 0, a );
    Store_field( abc, 1, b );
    Store_field( abc, 2, c );

    CAMLreturn( abc );
}

This raises several questions for me:

. Is this even possible?

. Has anyone written any self-contained toy C programs that use OCaml's 
run-time for garbage collection?

. Do I need to worry about what the C program puts on the stack or will this 
take care of itself?

. Has anyone already done this?

For anyone who hasn't already used LLVM and its excellent OCaml bindings, I 
cannot recommend it highly enough: it is a tremendous achievement.

[1] - http://www.linux-nantes.org/~fmonnier/OCaml/ocaml-wrapping-c.php

Many thanks,
-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/?e


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-02-05 23:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-01 21:24 Using OCaml's run-time from LLVM-generated native code Jon Harrop
2008-02-03 21:24 ` [Caml-list] " Alain Frisch
2008-02-03 23:19   ` Jon Harrop
2008-02-04  7:03     ` Alain Frisch
2008-02-04 10:32       ` Jon Harrop
2008-02-04 11:11         ` Alain Frisch
2008-02-04 13:36           ` Jon Harrop
2008-02-04 15:20             ` Alain Frisch
2008-02-05 23:08             ` Florent Monnier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).