oxilean_codegen/opt_passes/
identityeliminationpass_traits.rs1use crate::lcnf::{LcnfArg, LcnfExpr, LcnfFunDecl, LcnfLetValue, LcnfLit, LcnfVarId};
14
15use super::functions::OptPass;
16use super::types::IdentityEliminationPass;
17use std::fmt;
18
19impl Default for IdentityEliminationPass {
20 fn default() -> Self {
21 Self::new()
22 }
23}
24
25impl fmt::Debug for IdentityEliminationPass {
26 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27 write!(f, "IdentityEliminationPass(elim={})", self.eliminated)
28 }
29}
30
31impl OptPass for IdentityEliminationPass {
32 fn name(&self) -> &str {
33 "identity_elimination"
34 }
35 fn run_pass(&mut self, decls: &mut [LcnfFunDecl]) -> usize {
36 let before = self.eliminated;
37 self.run(decls);
38 (self.eliminated - before) as usize
39 }
40}