Commit 2e850875 authored by qinsoon's avatar qinsoon

[wip] new trace scheduling should work for x86_64

parent a1a433f4
Pipeline #739 passed with stages
in 29 minutes and 25 seconds
......@@ -506,6 +506,38 @@ impl Block {
content.body.len()
}
}
/// is this block ends with a conditional branch?
pub fn ends_with_cond_branch(&self) -> bool {
let block : &BlockContent = self.content.as_ref().unwrap();
match block.body.last() {
Some(node) => {
match node.v {
TreeNode_::Instruction(Instruction {v: Instruction_::Branch2{..}, ..}) => {
true
}
_ => false
}
}
None => false
}
}
/// is this block ends with a return?
pub fn ends_with_return(&self) -> bool {
let block : &BlockContent = self.content.as_ref().unwrap();
match block.body.last() {
Some(node) => {
match node.v {
TreeNode_::Instruction(Instruction {v: Instruction_::Return(_), ..}) => {
true
}
_ => false
}
}
None => false
}
}
}
/// TraceHint is a hint for the compiler to generate better trace for this block
......@@ -805,9 +837,13 @@ rodal_struct!(Value{hdr, ty, v});
impl Value {
/// creates an int constant value
pub fn make_int_const(id: MuID, val: u64) -> P<Value> {
Value::make_int_const_ty(id, UINT32_TYPE.clone(), val)
}
pub fn make_int_const_ty(id: MuID, ty: P<MuType>, val: u64) -> P<Value> {
P(Value{
hdr: MuEntityHeader::unnamed(id),
ty: UINT32_TYPE.clone(),
ty: ty,
v: Value_::Constant(Constant::Int(val))
})
}
......
......@@ -81,6 +81,7 @@ impl CompilerPass for RetSink {
// rewrite existing RET instruction to a BRANCH
// use RET values as BRANCH's goto values
let mut has_ret : bool = false;
for (blk_id, mut block) in f_content.blocks.iter_mut() {
trace!("block: {}", blk_id);
......@@ -104,6 +105,7 @@ impl CompilerPass for RetSink {
});
trace!(">> rewrite ret to {}", branch_to_sink);
new_body.push(branch_to_sink);
has_ret = true;
}
_ => new_body.push(node.clone())
}
......@@ -118,7 +120,9 @@ impl CompilerPass for RetSink {
}
// insert return sink
f_content.blocks.insert(return_sink.id(), return_sink);
if has_ret {
f_content.blocks.insert(return_sink.id(), return_sink);
}
// put back the function content
func.content = Some(f_content);
......
This diff is collapsed.
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