winch_codegen/codegen/phase.rs
1//! Type-based states to represent code generation phases.
2//! These states help enforce code generation invariants at compile time.
3//!
4//! Currently two phases are defined for code generation:
5//!
6//! * Prologue: responsible of setting up the function's frame.
7//! * Emission: emission of Wasm code to machine code.
8
9/// A code generation phase.
10pub trait CodeGenPhase {}
11
12/// The prologue phase.
13///
14/// Its main responsibility is to setup the function's frame, by creating the
15/// well known local slots. In this phase, writes to such slots is allowed.
16/// After this phase, the frame is considered immutable.
17pub struct Prologue;
18/// The code emission phase.
19///
20/// Its main responsibility is to emit Wasm code to machine code.
21pub struct Emission;
22
23impl CodeGenPhase for Prologue {}
24impl CodeGenPhase for Emission {}