Annotations

Overview

A compiler front-end has to be propagate information to
the back-end. An optimization phase may have to leave behind information
at various places of the IR so that other phases can reuse such information.
MLRISC uses the annotations
mechanism for these functions.
Individual instructions, basic blocks, and flow graph edges,
can be attached one or more annotations.

The basic MLRISC system understands many annotations. Some examples are:

COMMENT

these can be used to attach comments. If attached to
an instruction, the assemblers will output
them as part of their assembly output.

BRANCH_PROB

these can be attached to a branch instruction to indicate
the probability in which is it taken.

EXECUTION_FREQ

these can be attached to a basic block to indicate
its expected execution frequency

Details

The primitive annotations datatype is defined
to have this signature.
In addition, MLRISC predefined a few primitive annotations that are
recognized by the core system. This signature is
MLRISC_ANNOTATIONS.
More detailed documentation can be found in this
paper.