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.
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 (
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 more information on the high-level C back-end see the papers section of the web site, in particular the paper titled "Compiling Mercury to high-level C code".
Dormant, not currently under development
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.
We formerly had a back-end that compiled to assembler, using the GCC back-end. It had not been maintained for many years, so has been removed.
This back-end generates IL, the Intermediate Language used by Microsoft's .NET Common Language Runtime.
Click here for more