| 1 | | -------------------------------------- |
| | 1 | = Design of the new code generator = |
| | 2 | |
| | 3 | This page contains notes about the design of the new code generator |
| | 4 | |
| | 5 | == The new Cmm data type == |
| | 6 | |
| | 7 | There is a new Cmm data type: |
| | 8 | |
| | 9 | * [[GhcFile(compiler/cmm/ZipCfg.hs)]] contains a generic zipper-based control-flow graph data type. It is generic in the sense that it's polymorphic in the type of '''middle nodes''' and '''last nodes''' of a block. (Middle nodes don't do control transfers; last nodes only do control transfers.) There are extensive notes at the start of the module.[[BR]][[BR]] |
| | 10 | The key types it defines are: |
| | 11 | * Block identifiers: `BlockId`, `BlockEnv`, `BlockSet` |
| | 12 | * Control-flow blocks: `Block` |
| | 13 | * Control-flow graphs: `Graph`[[BR]][[BR]] |
| | 14 | * '''`ZipDataFlow`''' contains a generic framework for solving dataflow problems over `ZipCfg`.[[BR]][[BR]] |
| | 15 | * '''[[GhcFile(compiler/cmm/ZipCfgCmmRep.hs)]]''' instantiates `ZipCfg` for Cmm, by defining types `Middle` and `Last` and using these to instantiate the polymorphic fields of `ZipCfg`. It also defines a bunch of smart constructor (`mkJump`, `mkAssign`, `mkCmmIfThenElse` etc) which make it easy to build `CmmGraph`.[[BR]][[BR]] |
| | 16 | * '''`CmmExpr`''' contains the data types for Cmm expressions, registers, and the like. It does not depend on the dataflow framework at all. |
| | 17 | |