Alpha32 Code Generator

DEC Alpha Code Generator

Porting the MLRisc framework to a new architecture requires several steps:

All of these are quite trivial to write and an outline for the DEC Alpha is described.

Alpha Cells

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:

Instruction Set

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.

Instruction Set Properties

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_PROPERTIES
It 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

Alpha MLTREECOMP

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  

[ INDEX | TOP | Parent | Root ]

Author: Lal George
Last Modified: September 4, 1996
Copyright © 1996 Bell Laboratories