mod.rs 883 Bytes
Newer Older
1 2 3 4
use compiler::CompilerPass;
use ast::ir::*;
use vm::context::VMContext;

5
mod liveness;
qinsoon's avatar
qinsoon committed
6
mod coloring;
7

8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
pub struct RegisterAllocation {
    name: &'static str
}

impl RegisterAllocation {
    pub fn new() -> RegisterAllocation {
        RegisterAllocation {
            name: "Register Allcoation"
        }
    }
}

impl CompilerPass for RegisterAllocation {
    fn name(&self) -> &'static str {
        self.name
    }
    
    #[allow(unused_variables)]
    fn visit_function(&mut self, vm_context: &VMContext, func: &mut MuFunction) {
27 28 29 30
        let mut compiled_funcs = vm_context.compiled_funcs().read().unwrap();
        let mut cf = compiled_funcs.get(func.fn_name).unwrap().borrow_mut();
        
        cf.mc.print();
31
        
32 33
        let liveness = liveness::build(&mut cf);
        liveness.print();
qinsoon's avatar
qinsoon committed
34 35
        
        coloring::GraphColoring::start(&mut cf, liveness);
36 37
    }
}