next up previous
Next: AST input Up: The C-Breeze Compiler Infrastructure Previous: Invoking a Changer


The MIR Level

The goal of the MIR level is to provide a well-defined internal representation that is simpler than the AST representation while still remaining machine-independent. At the MIR level, the tree structure of the AST has been flattened so that each basic block is a list of instructions, and each instruction is considerably simpler, allowing only a single assignment operator and only goto's as control flow. In addition to the canonical MIR format, there is also an intermediate MIR format that simplifies control flow without simplifying expressions.

The dismantler is responsible for converting an AST into MIR format. The dismantler can be invoked from the command line by specifying the -dismantle flag; to dismantle control flow only, use the -dismantle-control flag.

The dismantler can also be invoked programmatically, which can be useful for restoring the MIR format after a transformation. Note that the dismantler has been designed to be idempotent, so that dismantling a portion of code multiple times has the same effect as dismantling it once.1 To use the new dismantler programmatically, use one of the static methods defined on the Dismantle class. You must include the file dismantle.h in order to see this class. The method Dismantle
::dismantle_control()
will dismantle control flow only. To completely dismantle the code, use the method Dismantle::dismantle(). Note that although the Dismantle class is a Changer, it is not intended to be used in a call to Node::change(); using the class directly in this way can lead to subtle bugs.

Finally, as mentioned in Section 2, the -cfg flag instructs C-Breeze to both convert to MIR and create a CFG.

The MIR format is not well-suited for loop transformations on multi-dimensional arrays, such as loop interchange or unroll and jam. The difficulty arises because in our MIR format each operandNode has an optional array subscript at the end. Since it only has a single subscript, multi-dimensional arrays cannot be represented directly but instead require the use of a temporary variable.



Subsections
next up previous
Next: AST input Up: The C-Breeze Compiler Infrastructure Previous: Invoking a Changer
Adam C. Brown 2006-01-26