The \-RTL Translator Source Distribution
This implementation of the \-RTL
translator is distributed ``as is,'' for experimental
purposes only.
If you can make it do something useful, we're both happy.
The translator is written in a combination of Icon and Standard ML.
(Actually, the translator does not run any Icon code, but Icon is used to
generate some of the ML code that makes up the translator.)
To make things even more interesting, the source code is written in
noweb.
Finally, the translator uses special
Standard ML
of New Jersey features, especially the Compilation Manager.
A final note --- this distribution includes (and subsumes) the experimental ML version of the New Jersey Machine-Code Toolkit.
Preliminaries
First, get and install the software tools you will need.
- Get and install Icon from the
Icon Project (FAQ
here) at the
University of Arizona.
You can get binaries for
386 DOS,
Linux,
SPARC SunOS,
SPARC Solaris,
32-bit Windows,
and other targets.
- Get and install the
noweb
literate-programming tool.
- Get and install
Standard ML
of New Jersey, version 110 or later.
Naturally, you will need the binaries for these things on your
execution path.
The final preliminary is to download the \-RTL
source package.
Building the tools and the \-RTL translator
Untar the translator source package, which will create an lrtl
directory.
Edit the shell script
lrtl/install, setting the variables in the script according to the
comments.
Then run cd lrtl; ./install, which should
- Compile and install the tools needed to build the translator.
- Build sml-nw, a version of Standard ML of New Jersey that
understands how to use these tools build the translator.
If an error occurs during this step, see below.
- Compile the translator itself (the big step).
The installation script runs in about 6 minutes on a Pentium 200 with
128M of memory.
Once it completes, you should have an executable lrtl on your
path.
Potential errors building sml-nw
An error may occur when building sml-nw, because not all
SML/NJ versions beyond 110 treat CM tools in the same way.
If you are using an older version like 110.0.3, you will have to
change tools/export.sml to conform.
As distributed, the file contains the following binding:
val runlex =
Tools.stdShellProcessor
( { command = command, tool = "ML-Lex+" } (* old style *)
; { mkCommand = fn () => command, tool = "ML-Lex+" } (* new style *)
)
If the compiler complains, you can simply remove the line marked `new style'.
Using the translator
The installation process should put an executable lrtl in
with the other SML executables.
The translator has a plethora of options, but most can be ignored.
- lrtl -help produces a usage message, as well as telling what
modules have been precompiled into the translator.
- lrtl -tex file runs the translator and emits part of a
processor supplement into file.tex.
Turning this file into a full processor supplement is nontrivial, but
it is probably the easiest way to begin to see if what you specified
was what you intended.
- lrtl -cln file runs the translator and emits fully
decorated typed lambda-calculus into file.cln.
This calculus is a bit difficult to read (because it does not use
infix notation), but it shows the explicit specialization of all the
RTL operators to the appropriate sizes, which is useful for debugging.
- If I ever get the ASDL installation problems fixed,
lrtl -pkl file will run the translator and emit an ASDL
pickle into file.pkl.
Such pickle contain the attributes in the \-RTL specification, and
they can easily be read by C programs, etc.
The \-RTL translator uses an experimental type-inference algorithm
that can usually insert fetches automatically and decide how large a
fetched value will be.
The easiest way to control this feature is with explicit typecasts,
e.g., $m[addr] : #16 bits
.
It may sometimes be more convenient to define a function to perform
the cast; i.e., if function hword
is \x.x:#16 bits
, then
hword $m[addr]
is equivalent to $m[addr] : #16 bits
.
Correspondence
Send all correspondence to
nr@cs.tufts.edu.