Man page for mgen.1
Table of Contents


mgen - MIPS code generator


mgen [ options ] infile ...
mgen -ddebug


The mgen program is a code generator from old-SUIF to MIPS assembly. The input files must have already been processed by mexp. There can be multiple input files. You cannot specify the names of the output files. Instead, the suffix of each input file is replaced by .s to determine the name of the corresponding output file. Each input file must have a suffix, but it doesn't matter what it is.

There are three passes in the code generator. The first pass:

does major translation of SUIF instructions into MIPS assembly

gathers information on all types of registers

gathers information on the size of the stack frame, etc.

and performs some peephole optimizations (e.g. replaces "ldc
" instructions with immediate operands and generates pc-relative branches).

The second pass:

determines stack home and/or register home of every pseudo regis

spills node registers to memory if there are not enough temporar
y registers;

expands ao_cg_*rec pseudo operations

performs other minor translations, not done in the first pass

expands built-in functions

and performs some peephole optimizations

The third pass:

determines the true size of the stack frame

finishes creation of the header

expands ao_cg_restore ops with the trailer instructions

completes machine register allocation by allocating temporar

registers to the node registers;

and performs the final peephole optimizations


Describe the actions of each debug level.

Set the debug level to N, where N is between 0 and 9, inclusive. The default debug level is 0.

Generate MIPS assembly with infinite temporary registers.

Generate MIPS assembly with infinite saved registers.

Assume that all pseudo registers live on the stack.

-oput X
If X is "binary", the output is to a binary file instead of an ASCII file. This is used when the output file is passed to an instruction scheduler.

Stop translation after the first pass.

Stop translation after the second pass.


The input files must be processed by mexp before running mgen. Moreover, mgen cannot handle "mod" instructions; they must have already been expanded. The counts for the various shift instructions cannot be negative. The target addresses for "btrue" and "bfalse" instructions must be in node registers.


Mike Smith



Table of Contents