Compare commits
2 Commits
75fdc9d3a4
...
f5f984c81a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5f984c81a | ||
|
|
74873feb96 |
@@ -144,8 +144,8 @@ struct FastAllocState<'a, F: Function> {
|
||||
pub vregs: Vec<VRegData>,
|
||||
pub pregs: Vec<PRegData>,
|
||||
pub blocks: Vec<BlockData>,
|
||||
pub liveins: Vec<VRegBitmap>,
|
||||
pub liveouts: Vec<VRegBitmap>,
|
||||
pub liveins: Vec<IndexSet>,
|
||||
pub liveouts: Vec<IndexSet>,
|
||||
|
||||
pub cur_stack_slot_idx: u32,
|
||||
pub reftype_vregs_in_pregs_count: u32,
|
||||
@@ -1093,7 +1093,6 @@ fn calc_use_positions_and_live_bitmaps<'a, F: Function>(
|
||||
calc_live_bitmaps(state, const_state)
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct BlockBitmap {
|
||||
storage: SmallVec<[u64; 2]>,
|
||||
}
|
||||
@@ -1123,82 +1122,6 @@ impl BlockBitmap {
|
||||
let bit = 1u64 << (idx % 64);
|
||||
(self.storage[idx] & bit) != 0
|
||||
}
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
for &b in self.storage.iter() {
|
||||
if b != 0 {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
pub fn union_with(&mut self, other: &Self) -> bool {
|
||||
let mut changed = 0;
|
||||
for (word_idx, &bits) in other.storage.iter().enumerate() {
|
||||
if bits == 0 {
|
||||
continue;
|
||||
}
|
||||
let self_word = &mut self.storage[word_idx];
|
||||
changed |= bits & !*self_word;
|
||||
*self_word |= bits;
|
||||
}
|
||||
changed != 0
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct VRegBitmap {
|
||||
storage: SmallVec<[u64; 8]>,
|
||||
}
|
||||
|
||||
impl VRegBitmap {
|
||||
fn init(vreg_count: usize) -> Self {
|
||||
let u64_count = (vreg_count + 63) / 64;
|
||||
let mut storage = SmallVec::<[u64; 8]>::with_capacity(u64_count);
|
||||
storage.resize(u64_count, 0);
|
||||
Self { storage }
|
||||
}
|
||||
|
||||
fn set(&mut self, idx: usize) {
|
||||
let idx = idx / 64;
|
||||
let bit = 1u64 << (idx % 64);
|
||||
self.storage[idx] |= bit;
|
||||
}
|
||||
|
||||
fn un_set(&mut self, idx: usize) {
|
||||
let idx = idx / 64;
|
||||
let bit = 1u64 << (idx % 64);
|
||||
self.storage[idx] &= !bit;
|
||||
}
|
||||
|
||||
fn is_set(&mut self, idx: usize) -> bool {
|
||||
let idx = idx / 64;
|
||||
let bit = 1u64 << (idx % 64);
|
||||
(self.storage[idx] & bit) != 0
|
||||
}
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
for &b in self.storage.iter() {
|
||||
if b != 0 {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
pub fn union_with(&mut self, other: &Self) -> bool {
|
||||
let mut changed = 0;
|
||||
for (word_idx, &bits) in other.storage.iter().enumerate() {
|
||||
if bits == 0 {
|
||||
continue;
|
||||
}
|
||||
let self_word = &mut self.storage[word_idx];
|
||||
changed |= bits & !*self_word;
|
||||
*self_word |= bits;
|
||||
}
|
||||
changed != 0
|
||||
}
|
||||
}
|
||||
|
||||
// currently, copy from liveranges.rs
|
||||
@@ -1208,12 +1131,8 @@ fn calc_live_bitmaps<'a, F: Function>(
|
||||
state: &mut FastAllocState<'a, F>,
|
||||
const_state: &ReadOnlyData,
|
||||
) -> Result<(), RegAllocError> {
|
||||
state
|
||||
.liveins
|
||||
.resize(state.blocks.len(), VRegBitmap::init(state.vregs.len()));
|
||||
state
|
||||
.liveouts
|
||||
.resize(state.blocks.len(), VRegBitmap::init(state.vregs.len()));
|
||||
state.liveins.resize(state.blocks.len(), IndexSet::new());
|
||||
state.liveouts.resize(state.blocks.len(), IndexSet::new());
|
||||
|
||||
// Run a worklist algorithm to precisely compute liveins and
|
||||
// liveouts.
|
||||
@@ -1240,7 +1159,7 @@ fn calc_live_bitmaps<'a, F: Function>(
|
||||
if state.func.is_branch(insns.last()) {
|
||||
for i in 0..state.func.block_succs(block).len() {
|
||||
for ¶m in state.func.branch_blockparams(block, insns.last(), i) {
|
||||
live.set(param.vreg());
|
||||
live.set(param.vreg(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1252,14 +1171,14 @@ fn calc_live_bitmaps<'a, F: Function>(
|
||||
continue;
|
||||
}
|
||||
if op.pos() == *pos {
|
||||
let was_live = live.is_set(op.vreg().vreg());
|
||||
let was_live = live.get(op.vreg().vreg());
|
||||
trace!("op {:?} was_live = {}", op, was_live);
|
||||
match op.kind() {
|
||||
OperandKind::Use => {
|
||||
live.set(op.vreg().vreg());
|
||||
live.set(op.vreg().vreg(), true);
|
||||
}
|
||||
OperandKind::Def => {
|
||||
live.un_set(op.vreg().vreg());
|
||||
live.set(op.vreg().vreg(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1267,7 +1186,7 @@ fn calc_live_bitmaps<'a, F: Function>(
|
||||
}
|
||||
}
|
||||
for &blockparam in state.func.block_params(block) {
|
||||
live.un_set(blockparam.vreg());
|
||||
live.set(blockparam.vreg(), false);
|
||||
}
|
||||
|
||||
for &pred in state.func.block_preds(block) {
|
||||
|
||||
Reference in New Issue
Block a user