Pipeline
Overview
This page captures the observed compiler pipeline order and the specific foundation stages that already influence frontend and lowering behavior. It is meant to be read alongside the architecture page, but at a narrower operational level.
| Layer | Checked responsibilities |
|---|---|
| Frontend | source normalization, lexer, parser, AST validation |
| Mid-pipeline | symbols, visibility, type DB, HIR validate, sema, typeck |
| Control | control-flow checks, borrow checks |
| Lowering | HIR -> MIR, MIR verify, const-eval |
| Backend | backend lowering, object generation, linking |
Observed order:
- Package/stdlib registry checks
- Module resolution + cycle detection + duplicate module names
- Symbol table checks + shadowing/unknowns
- Visibility enforcement (exports/private)
- Type database build
- HIR validation
- Semantic checks
- Type checks
- Control-flow checks
- Borrow checks
- HIR -> MIR
- MIR verification
- Const eval
- Backend lowering + object + link
Responsibilities
- Preserve the real execution order used by the current compiler.
- Mark which new foundation work already participates in the flow.
- Provide a compact reference for debugging stage-specific failures.
Invariants
- Stage ordering must remain explicit and reviewable.
- Macro, async, coroutine, and concurrency foundations must be documented where
they actually attach to the flow.
- Later roadmap ambitions must not be described as already active pipeline
behavior.
Data Flow
- Input sources are normalized and tokenized.
- Parsing and AST validation create the first structured representation.
- Semantic layers gradually refine meaning and reject invalid contracts.
- MIR lowering and verification prepare backend-safe intermediate state.
- Backend lowering and link produce executable artifacts.
Bootstrap
Bootstrap uses the same pipeline ideas under a narrower accepted subset, so pipeline regressions often surface first in seed or stage rebuild checks.
Driver
Driver mode selection decides which part of the pipeline becomes observable to the user, whether through check, build, dump-hir, or dump-mir.
Frontend Macro Stage (170)
Frontend language pipeline foundation:
- Source normalization
- Lexer pass (pre-expansion token baseline)
- Macro expansion + hygiene pass
- Lexer pass (post-expansion token stream)
- Parse
- AST validation
Current compiler surfaces:
- macro expansion trace string in frontend output
- macro diagnostics mapped to source spans (
line,column,width) - recursion limit protection to keep expansion safe
Example compilation flow
For a simple source file, the pipeline follows these steps:
space app
proc main() -> void {
let x = 1
if x == 1 {
give "ok"
}
}
- Resolution of modules and verification of imports.
- Symbol checking and shadowing.
- Construction of the database type.
- HIR validation and semantic checks.
- Flow control, borrow checks, then MIR generation.
- MIR verification, constants evaluation, and finally backend lowering.
Async/Coroutine Stages (171-172)
- HIR lowering records async/await usage markers.
- HIR emits baseline misuse diagnostics for
awaitoutside async procedures. - HIR->MIR lowering introduces coroutine skeleton control-flow with suspend/resume blocks for await-like statements.
- This is a foundation step; full generator frame layout and drop-order verification are tracked as follow-up work.
Concurrency Memory Model Link (173)
Formal foundation document:
Examples
The following commands are a practical way to observe the pipeline from the outside:
./bin/vitte check src/app.vit
./bin/vitte dump-hir src/app.vit
./bin/vitte dump-mir src/app.vit
These are useful when a contributor needs to determine whether a regression was introduced during parsing, semantic checks, MIR lowering, or backend emission.