Commit 66a09287 authored by qinsoon's avatar qinsoon

[wip] started a bit on inst selection. will work on GC for a while

parent 9ea79e21
use ast::ir::*;
use ast::ptr::*;
use ast::inst::Instruction_::*;
use vm::context::VMContext;
......@@ -21,6 +22,49 @@ impl CompilerPass for InstructionSelection {
#[allow(unused_variables)]
fn start_function(&mut self, vm_context: &VMContext, func: &mut MuFunction) {
println!("{}", self.name());
debug!("{}", self.name());
}
}
\ No newline at end of file
fn visit_function(&mut self, vm_context: &VMContext, func: &mut MuFunction) {
for block_label in func.block_trace.as_ref().unwrap() {
let block = func.content.as_mut().unwrap().get_block_mut(block_label);
let block_content = block.content.as_mut().unwrap();
for inst in block_content.body.iter_mut() {
instruction_select(inst);
}
}
}
}
fn instruction_select(inst: &mut P<TreeNode>) {
match inst.v {
TreeNode_::Instruction(ref inst) => {
match inst.v {
Branch2{cond, ref true_dest, ref false_dest, true_prob} => {
let ref cond = inst.ops.borrow()[cond];
match cond.v {
TreeNode_::Instruction(ref inst) => {
match inst.v {
CmpOp(op, op1, op2) => {
},
_ => panic!("unexpected inst as child node of branch2: {}", cond)
}
},
TreeNode_::Value(ref pv) => {
}
}
},
_ => unimplemented!()
}
},
_ => panic!("expected instruction")
}
}
\ 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