patchouly_core/lib.rs
1#![no_std]
2
3pub mod relocation;
4pub mod stencils;
5
6/// A trait for a stencil stack
7///
8/// The compiler will generate code that uses stacks
9/// when a variable is determined to be "spilled".
10///
11/// ## Requirements
12///
13/// Note that the functions must be annotated with `#[inline]`
14/// and must not involve further linkage. `patchouly-build` will
15/// report these violations on build-time.
16pub trait StencilStack {
17 fn get(&self, i: usize) -> usize;
18 fn set(&mut self, i: usize, v: usize);
19}
20
21/// A library of stencils
22pub struct StencilLibrary<const MAX_REGS: usize> {
23 /// All the stencil binary code, referred to by stencils
24 pub code: &'static [u8],
25 /// The code for an empty stencil, used to prune consecutive jumps
26 pub empty: &'static [u8],
27 /// Stencils to move values between registers/the stack
28 pub moves: &'static StencilFamily<1, 1, MAX_REGS, 0, 1>,
29}
30
31pub use stencils::Stencil;
32pub use stencils::StencilFamily;