IRVM: A Virtual Machine for Andrew W. Appel's Tree Intermediate Representation
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

IRVM 0.0.3

IRVM is a virtual machine designed to execute simple register based high level intermediate code. It interprets the intermediate representations defined by Andrew Appel in his "Modern Compiler Implementation". For more information about the Andrew Appel's Modern Compiler Implementation book series please visit Andrew Appel's home page.

IRVM features are:

  • accepts HIR tree-like source language (two way conditional jumps, arbitrarily nested subroutines calls)

  • accepts LIR threaded source language (one way conditional jumps, no nested subroutines calls)

  • a runtime library comparable to SPIM's

IRVM is inspired by the HAVM Tree virtual machine developped by Robert Anisko at EPITA. For more information about HAVM, please visit its project page.

HAVM is a robust Tree Virtual Machine, but it does not support Tree programs that change the control flow by jumping outside of an expression evaluation (see HAVM documentation section 3 Known Problems). For example, HAVM is unable to interpret the Tree IR generated from the following Tiger source program.

print_int (if 0 | 0 then 0 else 1)

In contrast, IRVM fully supports these programs. In IRVM, Jump and CJump breaking out of expressions nodes are properly handled.


For full instructions please read the INSTALL procedure. In most of the cases, typing the following commands should suffice,

make && make install

For those commands to work, you should ensure that the GNU autotools are installed on your system.


IRVM is invoked with the following parameters


where FILE is the input IR Tree file and OPTIONS may be chosen among the following:

  • -h / --help : Displays a help message and exits

  • -V / --version: Displays the version number and exits

  • -t / --trace: Produces detailed execution traces on stderr. This option is very useful when debugging a Tree program.

  • -l / --low: Checks that the input is a valid LIR program before execution.

For more information please refer to the documentation in doc/.


IRVM is released under the GNU General Public License Version 3 or later. The Licence terms are available in the COPYING file.