Porting the MLRisc framework to a new architecture requires several steps:
The CELLS structure is trivial to write. The only catch to note, is that the DEC Alpha does not have condition code registers, but implements them using general purpose registers. Therefore:
newCCReg allocates a new general purpose register.
maxCCreg returns the largest allocated general purpose register.
firstPseudoCCreg is identical to firstPseudoReg.
addCCreg adds a condition code register (actually general purpose register) to a cellset.
The instruction set datatype is lifted straight from the architecture reference manual. The main consideration was to factor the instructions making definition/use information easy to compute. The fragment below highlights some of the interesting aspects:
functor Alpha32Instr(Const : CONSTANT) = struct
structure C = Alpha32Cells
structure Constant = Const
datatype operand =
REGop of int
IMMEDop of int
HILABop of LabelExp.labexp
LOLABop of LabelExp.labexp
CONSTop of Const.const
datatype operate = ZAP | ADDL | ADDQ | ...
datatype instruction =
OPERATE of {oper:operate, ra:int, rb:operand, rc:int}
| ...
| COPY of int list * int list * instruction list option ref
| FCOPY of int list * int list * instruction list option ref
end
The first thing to note is that the Alpha instructions are parameterized over the Const module that describes constants used by the front end. These constants are embedded in the operand datatype that characterizes arguments that can be immediate constants.
The fields of OPERATE mimick the names used in the architecture reference manual. The only instruction not found on the Alpha are the parallel copy instructions COPY and FCOPY. These are used to compile the equivalent MLRisc variants. The third field is used to cache an expansion of the parallel copy as a sequence of sequential moves.
Properties of the instruction set are defined by a module matching INSN_PROPERTIES. The header for this module for the Alpha is:
functor Alpha32Props(val exnptrR : int list) : INSN_PROPERTIESIt is parameterized over registers that may be used when a trap occurs. These registers are assumed to be general purpose registers.
Other modules will typically be required and are explained
The module that translates MLRisc like all RISC architectures is trivial to write. There are usually not more than two ways to perform most computations, and so the module is implemented using straight pattern matching. The functor Alpha32 that implements this translation is:
functor Alpha32
(structure Flowgen : FLOWGRAPH_GEN
sharing Flowgen.I = Alpha32Instr
sharing Flowgen.T=Alpha32MLTree
sharing Alpha32MLTree.Constant = Alpha32Instr.Constant) : MLTREECOMP
Submit a comment on this page
Author: Lal George
Last Modified: September 4, 1996
Copyright © 1996 Bell Laboratories