Commit 9ea79e21 authored by qinsoon's avatar qinsoon

stubs for arch specific instruction selection

parent 8dfa2bff
use ast::ir::*;
use ast::inst::Instruction_::*;
use vm::context::VMContext;
use compiler::CompilerPass;
pub struct InstructionSelection {
name: &'static str
}
impl InstructionSelection {
pub fn new() -> InstructionSelection {
InstructionSelection{name: "Instruction Selection (ARM)"}
}
}
impl CompilerPass for InstructionSelection {
fn name(&self) -> &'static str {
self.name
}
#[allow(unused_variables)]
fn start_function(&mut self, vm_context: &VMContext, func: &mut MuFunction) {
println!("{}", self.name());
}
}
\ No newline at end of file
pub use self::arch_specific::*;
#[cfg(target_arch = "x86_64")]
#[path="x86_64/inst_sel.rs"]
mod arch_specific;
#[cfg(target_arch = "arm")]
#[path="arm/inst_sel.rs"]
mod arch_specific;
\ No newline at end of file
pub mod inst_sel;
\ No newline at end of file
use ast::ir::*;
use ast::inst::Instruction_::*;
use vm::context::VMContext;
use compiler::CompilerPass;
pub struct InstructionSelection {
name: &'static str
}
impl InstructionSelection {
pub fn new() -> InstructionSelection {
InstructionSelection{name: "Instruction Selection (x64)"}
}
}
impl CompilerPass for InstructionSelection {
fn name(&self) -> &'static str {
self.name
}
#[allow(unused_variables)]
fn start_function(&mut self, vm_context: &VMContext, func: &mut MuFunction) {
println!("{}", self.name());
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ use vm::context::VMContext;
use std::cell::RefCell;
pub mod passes;
pub mod backend;
pub struct Compiler {
policy: RefCell<CompilerPolicy>
......@@ -31,6 +32,7 @@ impl CompilerPolicy {
passes.push(Box::new(passes::DefUse::new()));
passes.push(Box::new(passes::TreeGen::new()));
passes.push(Box::new(passes::ControlFlowAnalysis::new()));
passes.push(Box::new(backend::inst_sel::InstructionSelection::new()));
CompilerPolicy{passes: passes}
}
......
......@@ -17,6 +17,7 @@ impl CompilerPass for TraceGen {
self.name
}
#[allow(unused_variables)]
fn visit_function(&mut self, vm_context: &VMContext, func: &mut MuFunction) {
// we put the high probability edge into a hot trace, and others into cold paths
// and traverse cold_path later
......@@ -67,6 +68,7 @@ impl CompilerPass for TraceGen {
func.block_trace = Some(trace);
}
#[allow(unused_variables)]
fn finish_function(&mut self, vm_context: &VMContext, func: &mut MuFunction) {
debug!("trace for {}", func.fn_name);
debug!("{:?}", func.block_trace.as_ref().unwrap());
......
mod test_pre_instsel;
\ No newline at end of file
mod test_pre_instsel;
mod test_instsel;
\ No newline at end of file
extern crate mu;
extern crate log;
extern crate simple_logger;
use test_ir::test_ir::factorial;
use self::mu::compiler::*;
use self::mu::vm::context::VMContext;
#[test]
fn test_instsel_fac() {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
let vm_context : VMContext = 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())
]));
let mut factorial_func = {
vm_context.get_func("fac").unwrap().borrow_mut()
};
compiler.compile(&vm_context, &mut factorial_func);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment