(
pair: Pair<'_, Rule>,
groups: &mut PrimaryMap<ValueGroup, Vec<Value>>,
)
| 265 | } |
| 266 | |
| 267 | fn parse_operand( |
| 268 | pair: Pair<'_, Rule>, |
| 269 | groups: &mut PrimaryMap<ValueGroup, Vec<Value>>, |
| 270 | ) -> Result<Operand> { |
| 271 | assert_eq!(pair.as_rule(), Rule::operand); |
| 272 | let mut inner = pair.into_inner(); |
| 273 | let pair = inner.next().unwrap(); |
| 274 | assert!(inner.next().is_none()); |
| 275 | |
| 276 | if pair.as_rule() == Rule::nonallocatable_operand { |
| 277 | let [physreg] = extract(pair, [Rule::physreg]); |
| 278 | return Ok(Operand::fixed_nonallocatable(parse_entity(physreg)?)); |
| 279 | } |
| 280 | |
| 281 | assert_eq!(pair.as_rule(), Rule::normal_operand); |
| 282 | let [operand_kind, value_list, constraint] = extract( |
| 283 | pair, |
| 284 | [Rule::operand_kind, Rule::value_list, Rule::constraint], |
| 285 | ); |
| 286 | let values = parse_entity_list(value_list)?; |
| 287 | let kind = if let [value] = values[..] { |
| 288 | match operand_kind.as_str() { |
| 289 | "Use" => OperandKind::Use(value), |
| 290 | "Def" => OperandKind::Def(value), |
| 291 | "EarlyDef" => OperandKind::EarlyDef(value), |
| 292 | _ => unreachable!(), |
| 293 | } |
| 294 | } else { |
| 295 | let group = groups.push(values); |
| 296 | match operand_kind.as_str() { |
| 297 | "Use" => OperandKind::UseGroup(group), |
| 298 | "Def" => OperandKind::DefGroup(group), |
| 299 | "EarlyDef" => OperandKind::EarlyDefGroup(group), |
| 300 | _ => unreachable!(), |
| 301 | } |
| 302 | }; |
| 303 | let constraint = parse_constraint(constraint)?; |
| 304 | Ok(Operand::new(kind, constraint)) |
| 305 | } |
| 306 | |
| 307 | fn parse_constraint(pair: Pair<'_, Rule>) -> Result<OperandConstraint> { |
| 308 | let constraint_pair = pair.into_inner().next().unwrap(); |
no test coverage detected