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

Method init

src/internal/allocator/queue.rs:132–154  ·  view source on GitHub ↗

Initializes the allocation queue from the set of existing virtual register and virtual register groups.

(&mut self, virt_regs: &VirtRegs)

Source from the content-addressed store, hash-verified

130 /// Initializes the allocation queue from the set of existing virtual
131 /// register and virtual register groups.
132 pub fn init(&mut self, virt_regs: &VirtRegs) {
133 let mut vec = mem::take(&mut self.queue).into_vec();
134 vec.clear();
135
136 // Add virtual registers that are not part of a group.
137 vec.extend(
138 virt_regs
139 .virt_regs()
140 .filter(|&vreg| virt_regs[vreg].group.is_none())
141 .map(|vreg| Entry::encode(vreg, Stage::Evict, virt_regs)),
142 );
143
144 // Add virtual register groups.
145 vec.extend(
146 virt_regs
147 .groups()
148 .map(|group| Entry::encode_group(group, Stage::Evict, virt_regs)),
149 );
150
151 // O(n) heap construction, which is much faster than inserting entries
152 // one by one.
153 self.queue = vec.into();
154 }
155
156 /// Dequeues the entry with the highest priority from the queue.
157 pub fn dequeue(&mut self) -> Option<(VirtRegOrGroup, Stage)> {

Callers 1

runMethod · 0.80

Calls 6

mapMethod · 0.80
virt_regsMethod · 0.80
is_noneMethod · 0.80
groupsMethod · 0.80
clearMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected