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

Function parse_block_label

src/debug_utils/generic_function/parse.rs:161–225  ·  view source on GitHub ↗
(
    pair: Pair<'_, Rule>,
    entry_points: &mut Vec<Block>,
    blocks: &mut PrimaryMap<Block, BlockData>,
    insts: &mut PrimaryMap<Inst, InstData>,
)

Source from the content-addressed store, hash-verified

159}
160
161fn parse_block_label(
162 pair: Pair<'_, Rule>,
163 entry_points: &mut Vec<Block>,
164 blocks: &mut PrimaryMap<Block, BlockData>,
165 insts: &mut PrimaryMap<Inst, InstData>,
166) -> Result<()> {
167 let span = pair.as_span();
168 let expected_block = blocks.next_key();
169 let mut block = None;
170 let mut block_params_in = vec![];
171 let mut frequency = None;
172 let mut is_entry_point = false;
173 let mut is_critical_edge = false;
174
175 for pair in pair.into_inner() {
176 match pair.as_rule() {
177 Rule::block => {
178 parse_expected_entity(pair, expected_block)?;
179 block = Some(expected_block);
180 }
181 Rule::value_list => block_params_in = parse_entity_list(pair)?,
182 Rule::frequency => {
183 let [float] = extract(pair, [Rule::float]);
184 frequency = Some(parse_number(float)?);
185 }
186 Rule::block_attribute => match pair.as_str() {
187 "entry_point" => {
188 if is_entry_point {
189 Err(custom_error(pair.as_span(), "duplicate attribute"))?;
190 }
191 is_entry_point = true;
192 }
193 "critical_edge" => {
194 if is_critical_edge {
195 Err(custom_error(pair.as_span(), "duplicate attribute"))?;
196 }
197 is_critical_edge = true;
198 }
199 _ => unreachable!(),
200 },
201 _ => unreachable!(),
202 }
203 }
204
205 let Some(block) = block else {
206 Err(custom_error(span, "missing block"))?
207 };
208 let Some(frequency) = frequency else {
209 Err(custom_error(span, "missing frequency"))?
210 };
211 if is_entry_point {
212 entry_points.push(block);
213 }
214 blocks.push(BlockData {
215 insts: InstRange::new(insts.next_key(), insts.next_key()),
216 preds: vec![],
217 succs: vec![],
218 block_params_in,

Callers 1

parseMethod · 0.85

Calls 7

next_keyMethod · 0.80
pushMethod · 0.80
parse_expected_entityFunction · 0.70
parse_entity_listFunction · 0.70
extractFunction · 0.70
parse_numberFunction · 0.70
custom_errorFunction · 0.70

Tested by

no test coverage detected