next up previous
Next: Compiler Internals Up: MIT REVERSIBLE COMPUTING PROJECT Previous: Example Program sch.r

R Compiler User's Manual

Currently the R compiler does not have a very convenient user interface. But this section describes the interface, such as it is.

The R compiler resides in the files mpf/lang/compiler/*.lisp. To use it, start a Common Lisp such as Lucid ( e.g., by typing M-x lucid in Emacs), and type (load "loader"). This will load up the system.

Write your R program in a file such as program.r. Then type at Lisp, (rcompile-file "program.r"). First, the source will be printed with comments stripped out, and then, after a delay, the entire Pendulum assembly code for the compiled program will be printed. The example program sch.r takes about 15 seconds to compile on a Sparc 20.

Alternatively, one can type (rcompile-file "program.r" :debug t), and the full program will be printed out after every tiny little step in the compilation process. The output from this is voluminous, but by doing an incremental search ( '136S/ '136R) in Emacs for the characters `` ==>'' in this output, one can easily scroll through it to see what is going on at each compilation step. However, it is not recommended to try this with large programs.

When there are compilation problems, it is helpful to try compiling individual subroutines and statements in isolation, using the calls (rc source) and (rcd source), where source is a Lisp expression that evaluates to the list representing the fragment of source code to be compiled. Rc prints out the compiled assembly code, and rcd prints out the complete state of the program after each compilation step. For example, (rc '(a += b)) outputs the single Pendulum assembly language instruction `` ADD $2 $3.''



Michael Frank
Mon Nov 3 16:33:38 EST 1997