machinst: bump regalloc to 0.0.23 and return a slice on the successor indexes, in block_succs;
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -1525,9 +1525,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regalloc"
|
name = "regalloc"
|
||||||
version = "0.0.22"
|
version = "0.0.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9993953f6481fe355c490a0bdc2d488e354cd28728da36cd4156e2cfb74fd6de"
|
checksum = "b36727ea09f6e363ddebb29b2d2620052267cc1fc6e0da7da63317938eb4104c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ gimli = { version = "0.20.0", default-features = false, features = ["write"], op
|
|||||||
smallvec = { version = "1.0.0" }
|
smallvec = { version = "1.0.0" }
|
||||||
thiserror = "1.0.4"
|
thiserror = "1.0.4"
|
||||||
byteorder = { version = "1.3.2", default-features = false }
|
byteorder = { version = "1.3.2", default-features = false }
|
||||||
regalloc = "0.0.22"
|
regalloc = "0.0.23"
|
||||||
# It is a goal of the cranelift-codegen crate to have minimal external dependencies.
|
# It is a goal of the cranelift-codegen crate to have minimal external dependencies.
|
||||||
# Please don't add any unless they are essential to the task of creating binary
|
# Please don't add any unless they are essential to the task of creating binary
|
||||||
# machine code. Integration tests that need external dependencies can be
|
# machine code. Integration tests that need external dependencies can be
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ impl BlockRPO {
|
|||||||
fn visit<I: VCodeInst>(&mut self, vcode: &VCode<I>, block: BlockIndex) {
|
fn visit<I: VCodeInst>(&mut self, vcode: &VCode<I>, block: BlockIndex) {
|
||||||
self.visited[block as usize] = true;
|
self.visited[block as usize] = true;
|
||||||
for succ in vcode.succs(block) {
|
for succ in vcode.succs(block) {
|
||||||
if !self.visited[*succ as usize] {
|
if !self.visited[succ.get() as usize] {
|
||||||
self.visit(vcode, *succ);
|
self.visit(vcode, succ.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if Some(block) != vcode.fallthrough_return_block {
|
if Some(block) != vcode.fallthrough_return_block {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ use regalloc::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
use alloc::vec::Vec;
|
use alloc::{borrow::Cow, vec::Vec};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
@@ -78,7 +78,7 @@ pub struct VCode<I: VCodeInst> {
|
|||||||
/// Block successor lists, concatenated into one Vec. The `block_succ_range`
|
/// Block successor lists, concatenated into one Vec. The `block_succ_range`
|
||||||
/// list of tuples above gives (start, end) ranges within this list that
|
/// list of tuples above gives (start, end) ranges within this list that
|
||||||
/// correspond to each basic block's successors.
|
/// correspond to each basic block's successors.
|
||||||
block_succs: Vec<BlockIndex>,
|
block_succs: Vec<BlockIx>,
|
||||||
|
|
||||||
/// Block indices by IR block.
|
/// Block indices by IR block.
|
||||||
block_by_bb: SecondaryMap<ir::Block, BlockIndex>,
|
block_by_bb: SecondaryMap<ir::Block, BlockIndex>,
|
||||||
@@ -237,15 +237,15 @@ impl<I: VCodeInst> VCodeBuilder<I> {
|
|||||||
match insn.is_term() {
|
match insn.is_term() {
|
||||||
MachTerminator::None | MachTerminator::Ret => {}
|
MachTerminator::None | MachTerminator::Ret => {}
|
||||||
MachTerminator::Uncond(target) => {
|
MachTerminator::Uncond(target) => {
|
||||||
self.vcode.block_succs.push(target);
|
self.vcode.block_succs.push(BlockIx::new(target));
|
||||||
}
|
}
|
||||||
MachTerminator::Cond(true_branch, false_branch) => {
|
MachTerminator::Cond(true_branch, false_branch) => {
|
||||||
self.vcode.block_succs.push(true_branch);
|
self.vcode.block_succs.push(BlockIx::new(true_branch));
|
||||||
self.vcode.block_succs.push(false_branch);
|
self.vcode.block_succs.push(BlockIx::new(false_branch));
|
||||||
}
|
}
|
||||||
MachTerminator::Indirect(targets) => {
|
MachTerminator::Indirect(targets) => {
|
||||||
for target in targets {
|
for target in targets {
|
||||||
self.vcode.block_succs.push(*target);
|
self.vcode.block_succs.push(BlockIx::new(*target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -358,7 +358,7 @@ impl<I: VCodeInst> VCode<I> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the successors for a block.
|
/// Get the successors for a block.
|
||||||
pub fn succs(&self, block: BlockIndex) -> &[BlockIndex] {
|
pub fn succs(&self, block: BlockIndex) -> &[BlockIx] {
|
||||||
let (start, end) = self.block_succ_range[block as usize];
|
let (start, end) = self.block_succ_range[block as usize];
|
||||||
&self.block_succs[start..end]
|
&self.block_succs[start..end]
|
||||||
}
|
}
|
||||||
@@ -489,8 +489,8 @@ impl<I: VCodeInst> VCode<I> {
|
|||||||
|
|
||||||
// Rewrite successor information based on the block-rewrite map.
|
// Rewrite successor information based on the block-rewrite map.
|
||||||
for succ in &mut self.block_succs {
|
for succ in &mut self.block_succs {
|
||||||
let new_succ = block_rewrites[*succ as usize];
|
let new_succ = block_rewrites[succ.get() as usize];
|
||||||
*succ = new_succ;
|
*succ = BlockIx::new(new_succ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -643,13 +643,9 @@ impl<I: VCodeInst> RegallocFunction for VCode<I> {
|
|||||||
Range::new(InstIx::new(start), (end - start) as usize)
|
Range::new(InstIx::new(start), (end - start) as usize)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn block_succs(&self, block: BlockIx) -> Vec<BlockIx> {
|
fn block_succs(&self, block: BlockIx) -> Cow<[BlockIx]> {
|
||||||
let (start, end) = self.block_succ_range[block.get() as usize];
|
let (start, end) = self.block_succ_range[block.get() as usize];
|
||||||
self.block_succs[start..end]
|
Cow::Borrowed(&self.block_succs[start..end])
|
||||||
.iter()
|
|
||||||
.cloned()
|
|
||||||
.map(BlockIx::new)
|
|
||||||
.collect()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_ret(&self, insn: InstIx) -> bool {
|
fn is_ret(&self, insn: InstIx) -> bool {
|
||||||
@@ -721,7 +717,7 @@ impl<I: VCodeInst> fmt::Debug for VCode<I> {
|
|||||||
for block in 0..self.num_blocks() {
|
for block in 0..self.num_blocks() {
|
||||||
writeln!(f, "Block {}:", block,)?;
|
writeln!(f, "Block {}:", block,)?;
|
||||||
for succ in self.succs(block as BlockIndex) {
|
for succ in self.succs(block as BlockIndex) {
|
||||||
writeln!(f, " (successor: Block {})", succ)?;
|
writeln!(f, " (successor: Block {})", succ.get())?;
|
||||||
}
|
}
|
||||||
let (start, end) = self.block_ranges[block];
|
let (start, end) = self.block_ranges[block];
|
||||||
writeln!(f, " (instruction range: {} .. {})", start, end)?;
|
writeln!(f, " (instruction range: {} .. {})", start, end)?;
|
||||||
@@ -783,7 +779,7 @@ impl<I: VCodeInst + ShowWithRRU> ShowWithRRU for VCode<I> {
|
|||||||
write!(&mut s, " (original IR block: {})\n", bb).unwrap();
|
write!(&mut s, " (original IR block: {})\n", bb).unwrap();
|
||||||
}
|
}
|
||||||
for succ in self.succs(block as BlockIndex) {
|
for succ in self.succs(block as BlockIndex) {
|
||||||
write!(&mut s, " (successor: Block {})\n", succ).unwrap();
|
write!(&mut s, " (successor: Block {})\n", succ.get()).unwrap();
|
||||||
}
|
}
|
||||||
let (start, end) = self.block_ranges[block];
|
let (start, end) = self.block_ranges[block];
|
||||||
write!(&mut s, " (instruction range: {} .. {})\n", start, end).unwrap();
|
write!(&mut s, " (instruction range: {} .. {})\n", start, end).unwrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user