Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Inline assembly?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: [Caml-list] Inline assembly?
> Is it possible to use inline assembly in ocaml?

Currently, no.  A gcc-style inline asm facility could be useful to
express some canned instruction sequences that are currently hardcoded
into each native-code generator, but that's also quite a lot of work
to implement properly.

> If not, what is the lowest overhead way to approximate
> it? Using a C function which includes the asm?

Yes.  Since the C function will not heap-allocate nor raise
exceptions, you can tell the compiler about it using the "noalloc"
annotation:

        external myfunction : ... = "myfunction" "noalloc"

and this will select a faster calling convention from Caml to C for
this function.  If the function operates over floats, there are other
performance tricks one can play; write me if this is the case.

Regards,

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr