Coverage Report

Created: 2025-12-04 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/regalloc2/src/fastalloc/iter.rs
Line
Count
Source
1
use crate::{Operand, OperandConstraint, OperandKind, OperandPos};
2
3
pub struct Operands<'a>(pub &'a [Operand]);
4
5
impl<'a> Operands<'a> {
6
0
    pub fn new(operands: &'a [Operand]) -> Self {
7
0
        Self(operands)
8
0
    }
9
10
0
    pub fn matches<F: Fn(Operand) -> bool + 'a>(
11
0
        &self,
12
0
        predicate: F,
13
0
    ) -> impl Iterator<Item = (usize, Operand)> + 'a {
14
0
        self.0
15
0
            .iter()
16
0
            .cloned()
17
0
            .enumerate()
18
0
            .filter(move |(_, op)| predicate(*op))
Unexecuted instantiation: <regalloc2::fastalloc::iter::Operands>::matches::<<regalloc2::fastalloc::iter::Operands>::late::{closure#0}>::{closure#0}
Unexecuted instantiation: <regalloc2::fastalloc::iter::Operands>::matches::<<regalloc2::fastalloc::iter::Operands>::early::{closure#0}>::{closure#0}
Unexecuted instantiation: <regalloc2::fastalloc::iter::Operands>::matches::<<regalloc2::fastalloc::iter::Operands>::fixed::{closure#0}>::{closure#0}
Unexecuted instantiation: <regalloc2::fastalloc::iter::Operands>::matches::<<regalloc2::fastalloc::iter::Operands>::use_ops::{closure#0}>::{closure#0}
19
0
    }
Unexecuted instantiation: <regalloc2::fastalloc::iter::Operands>::matches::<<regalloc2::fastalloc::iter::Operands>::late::{closure#0}>
Unexecuted instantiation: <regalloc2::fastalloc::iter::Operands>::matches::<<regalloc2::fastalloc::iter::Operands>::early::{closure#0}>
Unexecuted instantiation: <regalloc2::fastalloc::iter::Operands>::matches::<<regalloc2::fastalloc::iter::Operands>::fixed::{closure#0}>
Unexecuted instantiation: <regalloc2::fastalloc::iter::Operands>::matches::<<regalloc2::fastalloc::iter::Operands>::use_ops::{closure#0}>
20
21
    pub fn def_ops(&self) -> impl Iterator<Item = (usize, Operand)> + 'a {
22
        self.matches(|op| op.kind() == OperandKind::Def)
23
    }
24
25
0
    pub fn use_ops(&self) -> impl Iterator<Item = (usize, Operand)> + 'a {
26
0
        self.matches(|op| op.kind() == OperandKind::Use)
27
0
    }
28
29
    pub fn reuse(&self) -> impl Iterator<Item = (usize, Operand)> + 'a {
30
        self.matches(|op| matches!(op.constraint(), OperandConstraint::Reuse(_)))
31
    }
32
33
0
    pub fn fixed(&self) -> impl Iterator<Item = (usize, Operand)> + 'a {
34
0
        self.matches(|op| matches!(op.constraint(), OperandConstraint::FixedReg(_)))
35
0
    }
36
37
    pub fn any_reg(&self) -> impl Iterator<Item = (usize, Operand)> + 'a {
38
        self.matches(|op| matches!(op.constraint(), OperandConstraint::Reg))
39
    }
40
41
0
    pub fn late(&self) -> impl Iterator<Item = (usize, Operand)> + 'a {
42
0
        self.matches(|op| op.pos() == OperandPos::Late)
43
0
    }
44
45
0
    pub fn early(&self) -> impl Iterator<Item = (usize, Operand)> + 'a {
46
0
        self.matches(|op| op.pos() == OperandPos::Early)
47
0
    }
48
}
49
50
impl<'a> core::ops::Index<usize> for Operands<'a> {
51
    type Output = Operand;
52
53
0
    fn index(&self, index: usize) -> &Self::Output {
54
0
        &self.0[index]
55
0
    }
56
}