The Mercury Project
Back-ends

[Mercury Logo]
Home

News

Information

Documentation

Mailing Lists

Back-ends
  Low-level C
  High-level C
  Java
  Erlang
  Microsoft .NET
  Native code
  Mercury Bytecode

Download

Related

Contact

Search

Bug Database

Back-ends

The Mercury implementation compiles to a wide variety of target languages on a wide variety of platforms.

Several of these back-ends are quite mature, other have been released but are still immature, while others are under development.

  • Mature:

    Low level C.
    Our original back-end. This one compiles Mercury source to low-level C code. It works by converting Mercury source into code for an abstract machine, and then converting the abstract machine instructions into C code with macros for the abstract machine registers and instructions. We use C's conditional compilation (#ifdef) to define these macros as either standard ANSI/ISO C code, or as GNU C code that makes uses of GNU C extensions such as global register variables, computed gotos, and inline assembler.

    For more information on the low-level C back-end, see the papers section of the web site, in particular the papers titled "The execution algorithm of Mercury: an efficient purely declarative logic programming language", "Code generation for Mercury", and "Compiling logic programs to C using GNU C as a portable assembler".

    High level C.
    This back-end compiles Mercury code to fairly high-level C code, more like the kind that a C programmer might write.

    For details, see the announcement of Mercury release 0.10.

  • Beta-release quality:

    Java.
    This back-end compiles Mercury to Java.

    The compiler support is complete, includes good support for interfacing with Java (see the language reference manual for details), and the standard library is fairly reasonable. There is no support for Mercury-level debugging or profiling.

    For a guide to installing and using the Java grade, refer to README.Java and the User's Guide. You will need a release-of-the-day.

    Erlang.
    This back-end compiles Mercury to Erlang.

    The compiler support is in good shape, includes good support for interfacing with Erlang (see the language reference manual for details), and the standard library is fairly reasonable. There is no support for Mercury-level debugging or profiling.

    For a guide to installing and using the Erlang grade, refer to README.Erlang and the User's Guide. You will need a release-of-the-day.

  • Dormant, not currently under development:

    Microsoft's .NET
    This back-end generates IL, the Intermediate Language used by Microsoft's .NET Common Language Runtime.

    Native code
    This back-end compiles to assembler, using the GCC back-end.

    Mercury byte-code.
    We have our own bytecode format, a back-end which generates it, and an interpreter which runs it. This is designed to interoperate with our low-level C back-end. The main aim here is to get better turn-around time for debugging.

    This one still needs quite a bit of work to integrate it with the rest of the Mercury implementation. Read the source.