From efc7d46188c6696ae873b2b71ead7e34fc4501ab Mon Sep 17 00:00:00 2001 From: John Kåre Alsaker Date: Sun, 10 Sep 2017 22:34:56 +0200 Subject: Analyse storage liveness and preserve it during generator transformation --- src/librustc_data_structures/bitslice.rs | 5 +++++ src/librustc_data_structures/indexed_set.rs | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/librustc_data_structures') diff --git a/src/librustc_data_structures/bitslice.rs b/src/librustc_data_structures/bitslice.rs index f74af6ee163..7665bfd5b11 100644 --- a/src/librustc_data_structures/bitslice.rs +++ b/src/librustc_data_structures/bitslice.rs @@ -132,6 +132,11 @@ pub trait BitwiseOperator { fn join(&self, pred1: usize, pred2: usize) -> usize; } +pub struct Intersect; +impl BitwiseOperator for Intersect { + #[inline] + fn join(&self, a: usize, b: usize) -> usize { a & b } +} pub struct Union; impl BitwiseOperator for Union { #[inline] diff --git a/src/librustc_data_structures/indexed_set.rs b/src/librustc_data_structures/indexed_set.rs index 47fa21e3bf0..c790463e47a 100644 --- a/src/librustc_data_structures/indexed_set.rs +++ b/src/librustc_data_structures/indexed_set.rs @@ -15,7 +15,7 @@ use std::mem; use std::ops::{Deref, DerefMut, Range}; use std::slice; use bitslice::{BitSlice, Word}; -use bitslice::{bitwise, Union, Subtract}; +use bitslice::{bitwise, Union, Subtract, Intersect}; use indexed_vec::Idx; /// Represents a set (or packed family of sets), of some element type @@ -164,6 +164,10 @@ impl IdxSet { bitwise(self.words_mut(), other.words(), &Subtract) } + pub fn intersect(&mut self, other: &IdxSet) -> bool { + bitwise(self.words_mut(), other.words(), &Intersect) + } + pub fn iter(&self) -> Iter { Iter { cur: None, -- cgit 1.4.1-3-g733a5