1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! The optimizer of the in-memory form Koopa IR.
//!
//! This module provides pass traits and the pass manager for optimizing
//! in-memory form Koopa IR programs, including:
//!
//! * The module pass trait ([`ModulePass`]) and the function pass trait
//! ([`FunctionPass`]).
//! * The pass manager ([`PassManager`]) that holds all registered passes,
//! and uses them to optimize the given Koopa IR program.
//!
//! # Example
//!
//! Implement a pass that converts all function names to uppercase:
//!
//! ```
//! use koopa::opt::*;
//! use koopa::ir::Program;
//!
//! struct FunctionNameToUpper;
//!
//! impl ModulePass for FunctionNameToUpper {
//! fn run_on(&mut self, program: &mut Program) {
//! // convert all function names to uppercase
//! for func in program.funcs_mut().values_mut() {
//! let new_name = func.name().to_uppercase();
//! func.set_name(new_name);
//! }
//! }
//! }
//!
//! // register pass
//! let mut passman = PassManager::new();
//! passman.register(Pass::Module(Box::new(FunctionNameToUpper)));
//!
//! // run passes on the Koopa IR program
//! # let mut program = Program::new();
//! passman.run_passes(&mut program);
//! ```
pub use *;
pub use PassManager;