Drop the domtree argument to legalize_function().
Future legalization patterns will have the ability to mutate the flowgraph, so the domtree's list of RPO blocks is not a good guide for iteration. Use the layout order instead. This will pick up any new EBBs inserted.
This commit is contained in:
@@ -103,7 +103,7 @@ impl Context {
|
|||||||
|
|
||||||
/// Run the legalizer for `isa` on the function.
|
/// Run the legalizer for `isa` on the function.
|
||||||
pub fn legalize(&mut self, isa: &TargetIsa) -> CtonResult {
|
pub fn legalize(&mut self, isa: &TargetIsa) -> CtonResult {
|
||||||
legalize_function(&mut self.func, &mut self.cfg, &self.domtree, isa);
|
legalize_function(&mut self.func, &mut self.cfg, isa);
|
||||||
self.verify_if(isa)
|
self.verify_if(isa)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
//! from the encoding recipes, and solved later by the register allocator.
|
//! from the encoding recipes, and solved later by the register allocator.
|
||||||
|
|
||||||
use cursor::{Cursor, FuncCursor};
|
use cursor::{Cursor, FuncCursor};
|
||||||
use dominator_tree::DominatorTree;
|
|
||||||
use flowgraph::ControlFlowGraph;
|
use flowgraph::ControlFlowGraph;
|
||||||
use ir;
|
use ir;
|
||||||
use isa::TargetIsa;
|
use isa::TargetIsa;
|
||||||
@@ -33,21 +32,16 @@ use self::heap::expand_heap_addr;
|
|||||||
/// - Transform any instructions that don't have a legal representation in `isa`.
|
/// - Transform any instructions that don't have a legal representation in `isa`.
|
||||||
/// - Fill out `func.encodings`.
|
/// - Fill out `func.encodings`.
|
||||||
///
|
///
|
||||||
pub fn legalize_function(func: &mut ir::Function,
|
pub fn legalize_function(func: &mut ir::Function, cfg: &mut ControlFlowGraph, isa: &TargetIsa) {
|
||||||
cfg: &mut ControlFlowGraph,
|
|
||||||
domtree: &DominatorTree,
|
|
||||||
isa: &TargetIsa) {
|
|
||||||
boundary::legalize_signatures(func, isa);
|
boundary::legalize_signatures(func, isa);
|
||||||
|
|
||||||
func.encodings.resize(func.dfg.num_insts());
|
func.encodings.resize(func.dfg.num_insts());
|
||||||
|
|
||||||
let mut pos = FuncCursor::new(func);
|
let mut pos = FuncCursor::new(func);
|
||||||
|
|
||||||
// Process EBBs in a reverse post-order. This minimizes the number of split instructions we
|
// Process EBBs in layout order. Some legalization actions may split the current EBB or append
|
||||||
// need.
|
// new ones to the end. We need to make sure we visit those new EBBs too.
|
||||||
for &ebb in domtree.cfg_postorder().iter().rev() {
|
while let Some(_ebb) = pos.next_ebb() {
|
||||||
pos.goto_top(ebb);
|
|
||||||
|
|
||||||
// Keep track of the cursor position before the instruction being processed, so we can
|
// Keep track of the cursor position before the instruction being processed, so we can
|
||||||
// double back when replacing instructions.
|
// double back when replacing instructions.
|
||||||
let mut prev_pos = pos.position();
|
let mut prev_pos = pos.position();
|
||||||
|
|||||||
Reference in New Issue
Block a user