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

Function parse_instruction

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

Source from the content-addressed store, hash-verified

319}
320
321fn parse_instruction(
322 pair: Pair<'_, Rule>,
323 blocks: &mut PrimaryMap<Block, BlockData>,
324 insts: &mut PrimaryMap<Inst, InstData>,
325 groups: &mut PrimaryMap<ValueGroup, Vec<Value>>,
326) -> Result<()> {
327 let Some((block, block_data)) = blocks.last_mut() else {
328 Err(custom_error(
329 pair.as_span(),
330 "instruction is not inside a block",
331 ))?
332 };
333 let mut data = InstData {
334 operands: vec![],
335 clobbers: vec![],
336 block,
337 terminator_kind: None,
338 is_pure: false,
339 };
340 for pair in pair.into_inner() {
341 match pair.as_rule() {
342 Rule::inst_label => {
343 // We specifically ignore instruction labels to make it easier to edit code.
344 }
345 Rule::opcode => parse_opcode(pair, &mut data, block_data)?,
346 Rule::attribute => parse_attribute(pair, &mut data.is_pure)?,
347 Rule::operand => data.operands.push(parse_operand(pair, groups)?),
348 Rule::clobber => {
349 let [unit] = extract(pair, [Rule::unit]);
350 data.clobbers.push(parse_entity(unit)?);
351 }
352 _ => unreachable!(),
353 }
354 }
355 insts.push(data);
356 block_data.insts.to = insts.next_key();
357 Ok(())
358}
359
360fn compute_preds_and_dominators(func: &mut GenericFunction) {
361 let mut preds = SecondaryMap::<Block, Vec<Block>>::with_max_index(func.num_blocks());

Callers 1

parseMethod · 0.85

Calls 9

parse_opcodeFunction · 0.85
parse_attributeFunction · 0.85
parse_operandFunction · 0.85
last_mutMethod · 0.80
pushMethod · 0.80
next_keyMethod · 0.80
custom_errorFunction · 0.70
extractFunction · 0.70
parse_entityFunction · 0.70

Tested by

no test coverage detected