(
pair: Pair<'_, Rule>,
blocks: &mut PrimaryMap<Block, BlockData>,
insts: &mut PrimaryMap<Inst, InstData>,
groups: &mut PrimaryMap<ValueGroup, Vec<Value>>,
)
| 319 | } |
| 320 | |
| 321 | fn 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 | |
| 360 | fn compute_preds_and_dominators(func: &mut GenericFunction) { |
| 361 | let mut preds = SecondaryMap::<Block, Vec<Block>>::with_max_index(func.num_blocks()); |
no test coverage detected