Changes between Version 1 and Version 2 of Commentary/Compiler/CodeGen/Overview


Ignore:
Timestamp:
Oct 29, 2018 1:52:52 PM (10 months ago)
Author:
terrorjack
Comment:

tryNewCodeGen has been renamed to doCodeGen in c0258176ad255ac42a68df75ac4287630a6c82c0. Updating this page to avoid confusion

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Compiler/CodeGen/Overview

    v1 v2  
    55The goal of the code generator is to convert program from [wiki:Commentary/Compiler/GeneratedCode STG] representation to [wiki:Commentary/Compiler/CmmType Cmm] representation. STG is a functional language with explicit stack. Cmm is a low-level imperative language - something between C and assembly - that is suitable for machine code generation. Note that terminology might be a bit confusing here: the term "code generator" can refer both to STG->Cmm pass and the whole STG->Cmm->assembly pass. The Cmm->assembly conversion is performed by one the backends, eg. NCG (Native Code Generator or LLVM.
    66
    7 The top-most entry point to the codegen is located in [[GhcFile(compiler/main/HscMain.hs)]] in the `tryNewCodegen` function. Code generation is done in two stages:
     7The top-most entry point to the codegen is located in [[GhcFile(compiler/main/HscMain.hs)]] in the `doCodeGen` function. Code generation is done in two stages:
    88  1. Convert STG to Cmm with implicit stack, and native Cmm calls. This whole stage lives in [[GhcFile(compiler/codeGen)]] directory with the entry point being `codeGen` function in [[GhcFile(compiler/codeGen/StgCmm.hs)]] module.
    99  2. Optimise the Cmm, and CPS-convert it to have an explicit stack, and no native calls. This lives in [[GhcFile(compiler/cmm)]] directory with the `cmmPipeline` function from [[GhcFile(compiler/cmm/CmmPipeline.hs)]] module being the entry point.
    1010
    11 The CPS-converted Cmm is fed to one of the backends. This is done by `codeOutput` function ([[GhcFile(compiler/main/CodeOutput.hs)]]) called from `hscGenHardCode` after returning from `tryNewCodegen`.
     11The CPS-converted Cmm is fed to one of the backends. This is done by `codeOutput` function ([[GhcFile(compiler/main/CodeOutput.hs)]]) called from `hscGenHardCode` after returning from `doCodeGen`.
    1212
    1313== First stage: STG to Cmm conversion ==