compiler/rust,nak: Rename BitSet::get() to contains()

Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34994>
This commit is contained in:
Faith Ekstrand 2025-05-15 03:33:37 -04:00
parent 20d247d754
commit 323769d3bb
6 changed files with 23 additions and 21 deletions

View file

@ -52,7 +52,7 @@ impl BitSet {
}
}
pub fn get(&self, idx: usize) -> bool {
pub fn contains(&self, idx: usize) -> bool {
let w = idx / 32;
let b = idx % 32;
if w < self.words.len() {
@ -406,8 +406,8 @@ mod tests {
assert_eq!(to_vec(&set), &[0, 1, 73]);
assert!(!set.is_empty());
assert!(set.get(73));
assert!(!set.get(197));
assert!(set.contains(73));
assert!(!set.contains(197));
assert!(set.remove(1));
assert!(!set.remove(7));

View file

@ -39,7 +39,7 @@ fn graph_post_dfs<N>(
post_idx: &mut Vec<usize>,
count: &mut usize,
) {
if seen.get(id) {
if seen.contains(id) {
return;
}
seen.insert(id);
@ -184,8 +184,8 @@ fn loop_detect_dfs<N>(
post: &mut BitSet,
loops: &mut BitSet,
) {
if pre.get(id) {
if !post.get(id) {
if pre.contains(id) {
if !post.contains(id) {
loops.insert(id);
}
return;
@ -209,7 +209,7 @@ fn detect_loops<N>(nodes: &mut Vec<CFGNode<N>>) -> bool {
let mut has_loop = false;
nodes[0].lph = usize::MAX;
for i in 1..nodes.len() {
if loops.get(i) {
if loops.contains(i) {
// This is a loop header
nodes[i].lph = i;
has_loop = true;

View file

@ -287,11 +287,11 @@ impl RegAllocator {
}
pub fn reg_is_used(&self, reg: u32) -> bool {
self.used.get(reg.try_into().unwrap())
self.used.contains(reg.try_into().unwrap())
}
pub fn reg_is_pinned(&self, reg: u32) -> bool {
self.pinned.get(reg.try_into().unwrap())
self.pinned.contains(reg.try_into().unwrap())
}
pub fn try_get_reg(&self, ssa: SSAValue) -> Option<u32> {
@ -356,7 +356,7 @@ impl RegAllocator {
fn reg_range_is_unset(set: &BitSet, reg: u32, comps: u8) -> bool {
for c in 0..u32::from(comps) {
if set.get((reg + c).try_into().unwrap()) {
if set.contains((reg + c).try_into().unwrap()) {
return false;
}
}
@ -515,7 +515,7 @@ impl<'a> VecRegAllocator<'a> {
}
fn reg_is_pinned(&self, reg: u32) -> bool {
self.pinned.get(reg.try_into().unwrap())
self.pinned.contains(reg.try_into().unwrap())
}
fn reg_range_is_unpinned(&self, reg: u32, comps: u8) -> bool {

View file

@ -253,7 +253,7 @@ impl SimpleBlockLiveness {
impl BlockLiveness for SimpleBlockLiveness {
fn is_live_after_ip(&self, val: &SSAValue, ip: usize) -> bool {
if self.live_out.get(val.idx().try_into().unwrap()) {
if self.live_out.contains(val.idx().try_into().unwrap()) {
true
} else if let Some(last_use_ip) = self.last_use.get(&val.idx()) {
*last_use_ip > ip
@ -263,11 +263,11 @@ impl BlockLiveness for SimpleBlockLiveness {
}
fn is_live_in(&self, val: &SSAValue) -> bool {
self.live_in.get(val.idx().try_into().unwrap())
self.live_in.contains(val.idx().try_into().unwrap())
}
fn is_live_out(&self, val: &SSAValue) -> bool {
self.live_out.get(val.idx().try_into().unwrap())
self.live_out.contains(val.idx().try_into().unwrap())
}
}

View file

@ -92,11 +92,11 @@ impl BarPropPass {
seen: &mut BitSet,
phi: u32,
) -> bool {
if self.phi_is_not_bar.get(phi.try_into().unwrap()) {
if self.phi_is_not_bar.contains(phi.try_into().unwrap()) {
return false;
}
if seen.get(phi.try_into().unwrap()) {
if seen.contains(phi.try_into().unwrap()) {
// If we've hit a cycle, that's not a fail
return true;
}
@ -129,7 +129,7 @@ impl BarPropPass {
phi: u32,
ssa: SSAValue,
) {
if !needs_bar.get(phi.try_into().unwrap()) {
if !needs_bar.contains(phi.try_into().unwrap()) {
return;
}
@ -154,7 +154,7 @@ impl BarPropPass {
phi: u32,
ssa: SSAValue,
) {
if self.phi_is_bar.get(phi.try_into().unwrap()) {
if self.phi_is_bar.contains(phi.try_into().unwrap()) {
return;
}
@ -203,7 +203,8 @@ impl BarPropPass {
match &mut instr.op {
Op::PhiSrcs(op) => {
for (idx, src) in op.srcs.iter_mut() {
if self.phi_is_bar.get((*idx).try_into().unwrap()) {
if self.phi_is_bar.contains((*idx).try_into().unwrap())
{
// Barrier immediates don't exist
let ssa = src.as_ssa().unwrap();
let bar = *self.map_bar(&ssa[0]).unwrap();
@ -215,7 +216,8 @@ impl BarPropPass {
Op::PhiDsts(op) => {
let mut bmovs = Vec::new();
for (idx, dst) in op.dsts.iter_mut() {
if self.phi_is_bar.get((*idx).try_into().unwrap()) {
if self.phi_is_bar.contains((*idx).try_into().unwrap())
{
let ssa = dst.as_ssa().unwrap().clone();
let bar = *self.ssa_map.get(&ssa[0]).unwrap();
*dst = bar.into();

View file

@ -984,7 +984,7 @@ fn spill_values<S: Spill>(
continue;
}
if spilled_phis.get((*idx).try_into().unwrap()) {
if spilled_phis.contains((*idx).try_into().unwrap()) {
if !p_out.s.contains(ssa) {
spills.push(*ssa);
}