Move entry_block() into Layout.
The single entry block in a function is simply the first block in the layout. Remove the 'entry' keyword from the textual IL, the lexer and parser.
This commit is contained in:
@@ -104,11 +104,8 @@ impl ControlFlowGraph {
|
||||
&self.data[ebb].successors
|
||||
}
|
||||
|
||||
pub fn postorder_ebbs(&self) -> Vec<Ebb> {
|
||||
if self.len() < 1 {
|
||||
return Vec::new();
|
||||
}
|
||||
let mut stack_a = vec![Ebb::with_number(0).unwrap()];
|
||||
pub fn postorder_ebbs(&self, entry: Ebb) -> Vec<Ebb> {
|
||||
let mut stack_a = vec![entry];
|
||||
let mut stack_b = Vec::new();
|
||||
while stack_a.len() > 0 {
|
||||
let cur = stack_a.pop().unwrap();
|
||||
@@ -282,7 +279,7 @@ mod tests {
|
||||
func.layout.append_inst(jmp_ebb2_ebb5, ebb2);
|
||||
|
||||
let cfg = ControlFlowGraph::new(&func);
|
||||
assert_eq!(cfg.postorder_ebbs(),
|
||||
assert_eq!(cfg.postorder_ebbs(func.layout.entry_block().unwrap()),
|
||||
vec![ebb0, ebb2, ebb5, ebb4, ebb1, ebb3]);
|
||||
}
|
||||
|
||||
@@ -309,6 +306,7 @@ mod tests {
|
||||
func.layout.append_inst(jmp_ebb2_ebb3, ebb2);
|
||||
|
||||
let cfg = ControlFlowGraph::new(&func);
|
||||
assert_eq!(cfg.postorder_ebbs(), vec![ebb0, ebb1, ebb2, ebb3]);
|
||||
assert_eq!(cfg.postorder_ebbs(func.layout.entry_block().unwrap()),
|
||||
vec![ebb0, ebb1, ebb2, ebb3]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,6 +108,12 @@ impl Layout {
|
||||
next: self.first_ebb,
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the function's entry block.
|
||||
/// This is simply the first EBB in the layout order.
|
||||
pub fn entry_block(&self) -> Option<Ebb> {
|
||||
self.first_ebb
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
@@ -414,8 +420,11 @@ mod tests {
|
||||
let e0 = Ebb::new(0);
|
||||
let e1 = Ebb::new(1);
|
||||
|
||||
assert_eq!(layout.entry_block(), None);
|
||||
layout.append_ebb(e0);
|
||||
assert_eq!(layout.entry_block(), Some(e0));
|
||||
layout.append_ebb(e1);
|
||||
assert_eq!(layout.entry_block(), Some(e0));
|
||||
|
||||
let i0 = Inst::new(0);
|
||||
let i1 = Inst::new(1);
|
||||
|
||||
@@ -10,7 +10,7 @@ pub mod layout;
|
||||
|
||||
use ir::types::{FunctionName, Signature};
|
||||
use entity_map::EntityRef;
|
||||
use ir::entities::{Ebb, NO_EBB, StackSlot};
|
||||
use ir::entities::StackSlot;
|
||||
use ir::dfg::DataFlowGraph;
|
||||
use ir::layout::Layout;
|
||||
use std::fmt::{self, Debug, Display, Formatter};
|
||||
@@ -24,9 +24,6 @@ pub struct Function {
|
||||
/// Signature of this function.
|
||||
signature: Signature,
|
||||
|
||||
/// The entry block.
|
||||
pub entry_block: Ebb,
|
||||
|
||||
/// Stack slots allocated in this function.
|
||||
stack_slots: Vec<StackSlotData>,
|
||||
|
||||
@@ -43,7 +40,6 @@ impl Function {
|
||||
Function {
|
||||
name: name,
|
||||
signature: sig,
|
||||
entry_block: NO_EBB,
|
||||
stack_slots: Vec::new(),
|
||||
dfg: DataFlowGraph::new(),
|
||||
layout: Layout::new(),
|
||||
|
||||
Reference in New Issue
Block a user