|
CONVERSION ERROR
|
|
# GHC Commentary: The Compiler
|
|
|
|
|
|
Error: HttpError (HttpExceptionRequest Request {
|
|
|
|
host = "ghc.haskell.org"
|
|
The compiler itself is written entirely in Haskell, and lives in the many sub-directories of the [compiler](/trac/ghc/browser/ghc/compiler) directory.
|
|
port = 443
|
|
|
|
secure = True
|
|
- [Compiler Module Dependencies](module-dependencies) (deals with the arcane mutual recursions among GHC's many data types)
|
|
requestHeaders = []
|
|
- [Coding guidelines](commentary/coding-style)
|
|
path = "/trac/ghc/wiki/Commentary/Compiler"
|
|
|
|
queryString = "?version=11"
|
|
- [Key data types](commentary/compiler/key-data-types)
|
|
method = "GET"
|
|
|
|
proxy = Nothing
|
|
- [The source language: HsSyn](commentary/compiler/hs-syn-type)
|
|
rawBody = False
|
|
- [RdrNames, Modules, and OccNames](commentary/compiler/rdr-name-type)
|
|
redirectCount = 10
|
|
- [Names](commentary/compiler/name-type)
|
|
responseTimeout = ResponseTimeoutDefault
|
|
- [Entities](commentary/compiler/entity-types): variables, type constructors, data constructors, and classes.
|
|
requestVersion = HTTP/1.1
|
|
- Types: [Type and Kind](commentary/compiler/type-type), [equality types and coercions](commentary/compiler/fc)
|
|
}
|
|
- [The core language](commentary/compiler/core-syn-type)
|
|
(StatusCodeException (Response {responseStatus = Status {statusCode = 403, statusMessage = "Forbidden"}, responseVersion = HTTP/1.1, responseHeaders = [("Date","Sun, 10 Mar 2019 07:03:59 GMT"),("Server","Apache/2.2.22 (Debian)"),("Strict-Transport-Security","max-age=63072000; includeSubDomains"),("Vary","Accept-Encoding"),("Content-Encoding","gzip"),("Content-Length","256"),("Content-Type","text/html; charset=iso-8859-1")], responseBody = (), responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}) "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>403 Forbidden</title>\n</head><body>\n<h1>Forbidden</h1>\n<p>You don't have permission to access /trac/ghc/wiki/Commentary/Compiler\non this server.</p>\n<hr>\n<address>Apache/2.2.22 (Debian) Server at ghc.haskell.org Port 443</address>\n</body></html>\n"))
|
|
- [The STG language](commentary/compiler/stg-syn-type)
|
|
|
|
- [The Cmm language](commentary/compiler/cmm-type)
|
|
Original source:
|
|
- [Compiling one module: HscMain](commentary/compiler/hsc-main)
|
|
|
|
|
|
```trac
|
|
- [Renamer](commentary/compiler/renamer)
|
|
|
|
- Typechecker
|
|
|
|
- Desugarer
|
|
= GHC Commentary: The Compiler =
|
|
- Core-\>core
|
|
|
|
|
|
The compiler itself is written entirely in Haskell, and lives in the many sub-directories of the [[GhcFile(compiler)]] directory.
|
|
- [Demand analysis](commentary/compiler/strictness-analysis) (i.e., strictness analysis)
|
|
|
|
- Core-\>CorePrep
|
|
* [wiki:ModuleDependencies Compiler Module Dependencies] (deals with the arcane mutual recursions among GHC's many data types)
|
|
- CorePrep-\>Stg?
|
|
* [wiki:Commentary/CodingStyle Coding guidelines]
|
|
- [The code generator](commentary/compiler/code-gen): Stg-\>Cmm
|
|
|
|
- [CPSer](commentary/compiler/cps): Cmm-\>Cmm (not in HEAD yet)
|
|
* [wiki:Commentary/Compiler/KeyDataTypes Key data types]
|
|
|
|
* [wiki:Commentary/Compiler/HsSynType The source language: HsSyn]
|
|
- [The GHC API](commentary/compiler/api)
|
|
* [wiki:Commentary/Compiler/RdrNameType RdrNames, Modules, and OccNames]
|
|
- [Symbol names and the Z-encoding](commentary/compiler/symbol-names)
|
|
* [wiki:Commentary/Compiler/NameType Names]
|
|
- Template Haskell?
|
|
* [wiki:Commentary/Compiler/EntityTypes Entities]: variables, type constructors, data constructors, and classes.
|
|
- [Wired-in and known-key things](commentary/compiler/wired-in)
|
|
* Types: [wiki:Commentary/Compiler/TypeType Type and Kind], [wiki:Commentary/Compiler/FC equality types and coercions]
|
|
- [Packages](commentary/compiler/packages)
|
|
* [wiki:Commentary/Compiler/CoreSynType The core language]
|
|
- The Finder?
|
|
* [wiki:Commentary/Compiler/StgSynType The STG language]
|
|
- [Backends](commentary/compiler/backends):
|
|
* [wiki:Commentary/Compiler/CmmType The Cmm language]
|
|
|
|
* [wiki:Commentary/Compiler/HscMain Compiling one module: HscMain]
|
|
- [C code generator](commentary/compiler/backends/ppr-c)
|
|
* [wiki:Commentary/Compiler/Renamer Renamer]
|
|
- [Native code generator](commentary/compiler/backends/ncg)
|
|
* Typechecker
|
|
|
|
* Desugarer
|
|
## Overall Structure
|
|
* Core->core
|
|
|
|
* [wiki:Commentary/Compiler/StrictnessAnalysis Demand analysis] (i.e., strictness analysis)
|
|
|
|
* Core->CorePrep
|
|
Here is a block diagram of its top-level structure:
|
|
* [wiki:Commentary/Compiler/Core2Stg CorePrep->Stg]
|
|
|
|
* [wiki:Commentary/Compiler/CodeGen The code generator]: Stg->Cmm
|
|
[](/trac/ghc/attachment/wiki/Commentary/Compiler/ghc-top.png)
|
|
* [wiki:Commentary/Compiler/CPS CPSer]: Cmm->Cmm (not in HEAD yet)
|
|
|
|
|
|
|
|
* [wiki:Commentary/Compiler/API The GHC API]
|
|
The part called **HscMain** deals with compiling a single module. On top of this is built the **compilation manager** (in blue) that manages the compilation of multiple modules. It exports an interface called the **GHC API**. On top of this API are four small front ends:
|
|
* [wiki:Commentary/Compiler/SymbolNames Symbol names and the Z-encoding]
|
|
|
|
* [wiki:Commentary/Compiler/TemplateHaskell Template Haskell]
|
|
- GHCi, the interactive environment, is implemented in [compiler/ghci/InteractiveUI.hs](/trac/ghc/browser/ghc/compiler/ghci/InteractiveUI.hs) and sits squarely on top of the GHC
|
|
* [wiki:Commentary/Compiler/WiredIn Wired-in and known-key things]
|
|
API.
|
|
* [wiki:Commentary/Compiler/Packages Packages]
|
|
|
|
* [wiki:Commentary/Compiler/Finder The Finder]
|
|
- `--make` is almost a trivial client of the GHC API, and is implemented in [compiler/main/Main.hs](/trac/ghc/browser/ghc/compiler/main/Main.hs).
|
|
* [wiki:Commentary/Compiler/Backends Backends]:
|
|
|
|
* [wiki:Commentary/Compiler/Backends/PprC C code generator]
|
|
- `-M`, the Makefile dependency generator, is also a client of the GHC API and is implemented in
|
|
* [wiki:Commentary/Compiler/Backends/NCG Native code generator]
|
|
[compiler/main/DriverMkDepend.hs](/trac/ghc/browser/ghc/compiler/main/DriverMkDepend.hs).
|
|
|
|
|
|
== Overall Structure ==
|
|
- The "one-shot" mode, where GHC compiles each file on the command line separately (eg. `ghc -c Foo.hs`). This mode bypasses the GHC API, and is implemented
|
|
|
|
directly on top of [HscMain](commentary/compiler/hsc-main), since it compiles only one file at a time. In fact, this is all that
|
|
Here is a block diagram of its top-level structure:
|
|
GHC consisted of prior to version 5.00 when GHCi and `--make` were introduced.
|
|
|
|
|
|
[[Image(ghc-top.png)]]
|
|
|
|
|
|
GHC is packaged as a single binary in which all of these front-ends are present, selected by the command-line flags indicated above. There is a single command-line interface implemented in [compiler/main/Main.hs](/trac/ghc/browser/ghc/compiler/main/Main.hs).
|
|
The part called '''HscMain''' deals with compiling a single module. On top of this is built the '''compilation manager''' (in blue) that manages the compilation of multiple modules. It exports an interface called the '''GHC API'''. On top of this API are four small front ends:
|
|
|
|
|
|
|
|
* GHCi, the interactive environment, is implemented in [[GhcFile(compiler/ghci/InteractiveUI.hs)]] and sits squarely on top of the GHC
|
|
In adition, GHC is compiled, without its front ends, as a *library* which can be imported by any Haskell program; see [the GHC API](commentary/compiler/api). |
|
API.
|
|
|
|
|
|
|
|
* {{{--make}}} is almost a trivial client of the GHC API, and is implemented in [[GhcFile(compiler/main/Main.hs)]].
|
|
|
|
|
|
|
|
* {{{-M}}}, the Makefile dependency generator, is also a client of the GHC API and is implemented in
|
|
|
|
[[GhcFile(compiler/main/DriverMkDepend.hs)]].
|
|
|
|
|
|
|
|
* The "one-shot" mode, where GHC compiles each file on the command line separately (eg. {{{ghc -c Foo.hs}}}). This mode bypasses teh GHC API, and is implemented
|
|
|
|
directly on top of [wiki:Commentary/Compiler/HscMain HscMain], since it compiles only one file at a time. In fact, this is all that
|
|
|
|
GHC consisted of prior to version 5.00 when GHCi and `--make` were introduced.
|
|
|
|
|
|
|
|
GHC is packaged as a single binary in which all of these front-ends are present, selected by the command-line flags indicated above. There is a single command-line interface implemented in [[GhcFile(compiler/main/Main.hs)]].
|
|
|
|
|
|
|
|
In adition, GHC is compiled, without its front ends, as a ''library'' which can be imported by any Haskell program; see [wiki:Commentary/Compiler/API the GHC API].
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
``` |
|
|