caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <alain@frisch.fr>
To: "Pierre-Étienne Meunier" <pierreetienne.meunier@gmail.com>,
	"Fabrice Le Fessant" <fabrice.le_fessant@ocamlpro.com>
Cc: Ocaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] OCamlPro Highlights: Dec 2013 & Jan 2014
Date: Fri, 07 Feb 2014 10:15:30 +0100	[thread overview]
Message-ID: <52F4A432.4010209@frisch.fr> (raw)
In-Reply-To: <92F45A7B-CC6A-45B6-86CF-DBC3C87A5D59@gmail.com>

On 02/06/2014 11:53 AM, Pierre-Étienne Meunier wrote:
> However, what is the difference between new backends, and using llvm?

Since this work is done by OCamlPro on behalf of LexiFi, let me answer 
this one. This current project is much less ambitious than switching to 
llvm.

Some context: ocamlopt generates machine code by producing some textual 
assembly code and calling an external assembler (gas or masm) to produce 
object files.  The assembly code is produced directly from an 
higher-level intermediate representation defined in 
asmcomp/linearize.mli (which represents a list of pseudo-instructions). 
  The mapping from this representation to assembly language contains 
some logic such as picking concrete opcodes (including special cases 
such as a simplified jump for a self tail-call), maintaining the current 
stack offset, taking into account various compilation mode (debug mode, 
fast/compact mode, pic mode), expanding complex pseudo-instructions into 
several actual assembly opcodes (e.g. to compile switches using jump 
tables), sharing floating point literals, etc.

Since two concrete syntaxes of assembly languages (gas/masm) have to be 
supported, this mapping has to be implemented twice for each CPU 
(amd64/emit.mlp + amd64/emit_nt.mlp, and same for i386/), which adds 
burden when this code evolves (and it still does quite often).

So the project is to add an extra intermediate language between 
linearize.mli and textual assembly language.  This new representation 
can be seen as a symbolic representation of machine code or an AST of 
the generated assembly language.  This will allow to share most code 
from emit.mlp and emit_nt.mlp.  Two "printers" from this new 
representation to source assembly language will be implemented.  In 
addition to reducing the maintenance overhead and reducing the risk of 
having the Windows port lagging behind, this will bring a few more 
advantages:

  - It will be quite easy to have a third "printer", which generates 
direct binary machine code instead of source assembly language.  LexiFi 
already uses such binary backends for x86 and amd64, which (together 
with a COFF object emitter) make it possible to have a version of 
ocamlopt under Windows that does not require an external assembler. 
(And this allows our end-user application to compile source OCaml code 
and dynlink it on the fly, without forcing our customers to install any 
toolchain.)  The new project will greatly facilitate the maintenance of 
these direct binary backends (and this is actually LexiFi's primary 
reason for funding this project).  The same backends would actually be 
of interest to other projects, such as the native toplevel or MetaOCaml.

  - Some low-level optimizations could be performed on the new 
representation (typically, peep-hole optimizations).

  - The project will probably make it easier to maintain or experiment 
with new variants of the backends (I'm thinking about the ia32 port from 
the sse2 branch, i.e. a variant of x86 using sse2 instructions for 
floating point arithmetic instead of x87 instructions).



Alain

      reply	other threads:[~2014-02-07  9:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-05 17:31 Fabrice Le Fessant
2014-02-06  9:43 ` Romain Bardou
2014-02-06 10:25   ` Malcolm Matalka
2014-02-06 10:57     ` Anil Madhavapeddy
2014-02-06 11:31   ` Benjamin Canou
2014-02-06 13:06     ` Daniel Bünzli
2014-02-06 16:07       ` Benjamin Canou
2014-02-07  1:36         ` Benjamin Canou
2014-02-07 10:48           ` Daniel Bünzli
2014-02-06 10:53 ` Pierre-Étienne Meunier
2014-02-07  9:15   ` Alain Frisch [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52F4A432.4010209@frisch.fr \
    --to=alain@frisch.fr \
    --cc=caml-list@inria.fr \
    --cc=fabrice.le_fessant@ocamlpro.com \
    --cc=pierreetienne.meunier@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).