#[allow(dead_code)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PeepInstr {
Const(i64),
Add,
Sub,
Mul,
Div,
Neg,
Load(String),
Store(String),
Branch(String),
Jump(String),
Ret,
Dup,
Pop,
Swap,
Nop,
}
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct PeepPattern {
pub instrs: Vec<PeepInstr>,
pub name: String,
}
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct PeepReplacement {
pub instrs: Vec<PeepInstr>,
pub name: String,
}
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct PeepRule {
pub pattern: PeepPattern,
pub replacement: PeepReplacement,
pub priority: i32,
}
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct PeepResult {
pub instructions: Vec<PeepInstr>,
pub rules_applied: Vec<String>,
pub reduction: usize,
}