test_regalloc.rs 964 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
extern crate mu;
extern crate log;
extern crate simple_logger;

use test_ir::test_ir::factorial;
use self::mu::compiler::*;

use std::sync::Arc;

#[test]
fn test_regalloc_fac() {
    simple_logger::init_with_level(log::LogLevel::Trace).ok();
    
    let vm_context = Arc::new(factorial());
    
    let compiler = Compiler::new(CompilerPolicy::new(vec![
            Box::new(passes::DefUse::new()),
            Box::new(passes::TreeGen::new()),
            Box::new(passes::ControlFlowAnalysis::new()),
            Box::new(passes::TraceGen::new()),
            Box::new(backend::inst_sel::InstructionSelection::new()),
22 23
            Box::new(backend::reg_alloc::RegisterAllocation::new()),
            Box::new(backend::code_emission::CodeEmission::new())
24 25 26 27 28 29 30
    ]), vm_context.clone());
    
    let funcs = vm_context.funcs().read().unwrap();
    let mut factorial_func = funcs.get("fac").unwrap().borrow_mut();
    
    compiler.compile(&mut factorial_func);    
}