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

Method new

src/debug_utils/generic_function/arbitrary.rs:161–215  ·  view source on GitHub ↗

Initializes the `FunctionBuilder`.

(u: &'a mut Unstructured<'b>, reginfo: &'a R, config: ArbitraryFunctionConfig)

Source from the content-addressed store, hash-verified

159impl<'a, 'b, R: RegInfo> FunctionBuilder<'a, 'b, R> {
160 /// Initializes the `FunctionBuilder`.
161 fn new(u: &'a mut Unstructured<'b>, reginfo: &'a R, config: ArbitraryFunctionConfig) -> Self {
162 let func = GenericFunction {
163 entry_points: vec![],
164 blocks: PrimaryMap::new(),
165 insts: PrimaryMap::new(),
166 values: PrimaryMap::new(),
167 value_groups: PrimaryMap::new(),
168 };
169
170 let mut class_per_bank: SecondaryMap<RegBank, Vec<RegClass>> =
171 SecondaryMap::with_max_index(reginfo.num_banks());
172 let mut remat_class_per_bank: SecondaryMap<RegBank, Vec<RegClass>> =
173 SecondaryMap::with_max_index(reginfo.num_banks());
174 let mut reg_per_bank: SecondaryMap<RegBank, Vec<PhysReg>> =
175 SecondaryMap::with_max_index(reginfo.num_banks());
176 let mut non_allocatable_regs = vec![];
177 for class in reginfo.classes() {
178 class_per_bank[reginfo.bank_for_class(class)].push(class);
179 if reginfo.class_group_size(class) == 1
180 && !reginfo.allocation_order(class).is_empty()
181 && (reginfo.class_includes_spillslots(class)
182 || reginfo
183 .class_members(class)
184 .into_iter()
185 .all(|reg| !reginfo.is_memory(reg)))
186 {
187 remat_class_per_bank[reginfo.bank_for_class(class)].push(class);
188 }
189 }
190 for reg in reginfo.regs() {
191 if let Some(bank) = reginfo.bank_for_reg(reg) {
192 reg_per_bank[bank].push(reg);
193 } else {
194 non_allocatable_regs.push(reg);
195 }
196 }
197
198 Self {
199 u,
200 reginfo,
201 func,
202 config,
203 domtree: DominatorTree::new(),
204 block_insts: SecondaryMap::new(),
205 class_per_bank,
206 remat_class_per_bank,
207 reg_per_bank,
208 non_allocatable_regs,
209 defs_by_blocks: SecondaryMap::new(),
210 use_candidates: vec![],
211 early_fixed: RegUnitSet::new(),
212 late_fixed: RegUnitSet::new(),
213 reuse_operands: vec![],
214 }
215 }
216
217 /// Generates a reasonable block frequency.
218 fn block_frequency(&mut self) -> Result<f32> {

Callers

nothing calls this directly

Calls 13

num_banksMethod · 0.80
classesMethod · 0.80
pushMethod · 0.80
bank_for_classMethod · 0.80
class_group_sizeMethod · 0.80
class_membersMethod · 0.80
regsMethod · 0.80
bank_for_regMethod · 0.80
is_emptyMethod · 0.45
allocation_orderMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected