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

5 6
mod liveness;

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
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) {
26 27 28 29
        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();
30
        
qinsoon's avatar
qinsoon committed
31 32
        let liveness = liveness::build(&mut cf, func);
        liveness.print_with(func);
33 34
    }
}