|
|
Instruction Streams
Overview
An instruction stream
is an abstraction used by MLRISC to describe linearized instructions.
This abstraction turns out to fit the function of
many MLRISC modules. For example,
a phase such as Instruction Selection
can be viewed as taking an stream of
MLTREE statements and return a
stream of instructions. Similarly,
phases such as assembly output and
machine code generation can be seen
as taking a stream of instructions and
returning a stream of characters and a stream of bytes.
The Details
An instruction stream satisfy the following abstract signature:
signature INSTRUCTION_STREAM =
sig
structure P : PSEUDO_OPS
datatype ('a,'b,'c,'d,'e,'f) stream =
STREAM of
{ beginCluster: int -> 'b,
endCluster : 'c -> unit,
emit : 'a,
pseudoOp : P.pseudo_op -> unit,
defineLabel : Label.label -> unit,
entryLabel : Label.label -> unit,
comment : string -> unit,
annotation : Annotations.annotation -> unit,
exitBlock : 'd -> unit,
alias : 'e -> unit,
phi : 'f -> unit
}
end
This type is specialized in other modules as such the
assembler, the machine code emitter,
and the instruction selection modules.
The protocol
All instruction streams, irrespective of their actual types,
follow the following protocol:
- The method beginCluster should be called at the beginning of
the stream to mark the start of a new compilation unit.
The integer passed to this method is the number
of bytes in the stream. This integer is only used for
machine code emitter, which uses it to allocate space for the
code string.
- The method endCluster should be called when the entire
compilation unit has been sent.
- In between these calls, the following methods can be called in any
order:
- emit -- this method emits an instruction. It takes
a regmap as argument.
- pseudoOp -- this method emits a pseudo op.
- defineLabel -- this method defines a local label, i.e.
a label that is only referenced within the same compilation unit.
- entryLabel -- this method defines an enternal label that
marks an procedure entry, and may be referenced from other
compilation units.
- comment -- this emits a comment string
- annotation -- this function attaches an annotation to
the current basic block.
- exitBlock --
this marks the current block as an procedure exit.
|
|
Generated by
mltex2html
|
Last modified: Mon Jun 8 14:18:05 UTC 2009 by buildd@vernadsky
|
|