MCPcopy Create free account
hub / github.com/Amanieu/regalloc3 / units

Method units

src/allocation_unit.rs:108–136  ·  view source on GitHub ↗

Returns an iterator over the units in an allocation.

(self, reginfo: &impl RegInfo)

Source from the content-addressed store, hash-verified

106impl Allocation {
107 /// Returns an iterator over the units in an allocation.
108 pub(crate) fn units(self, reginfo: &impl RegInfo) -> impl Iterator<Item = AllocationUnit> + '_ {
109 enum EitherIter<A, B> {
110 A(A),
111 B(B),
112 }
113 impl<A, B> Iterator for EitherIter<A, B>
114 where
115 A: Iterator,
116 B: Iterator<Item = A::Item>,
117 {
118 type Item = A::Item;
119
120 fn next(&mut self) -> Option<Self::Item> {
121 match self {
122 EitherIter::A(a) => a.next(),
123 EitherIter::B(b) => b.next(),
124 }
125 }
126 }
127
128 match self.kind() {
129 AllocationKind::PhysReg(reg) => {
130 EitherIter::A(reginfo.reg_units(reg).map(AllocationUnit::reg))
131 }
132 AllocationKind::SpillSlot(slot) => {
133 EitherIter::B(iter::once(AllocationUnit::spillslot(slot)))
134 }
135 }
136 }
137}

Callers 6

add_moveMethod · 0.80
resolveMethod · 0.80
indirect_remat_inputsMethod · 0.80
check_instMethod · 0.80
check_remat_inputMethod · 0.80
check_operandMethod · 0.80

Calls 3

mapMethod · 0.80
reg_unitsMethod · 0.80
kindMethod · 0.45

Tested by

no test coverage detected