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

Function parse_operand

src/debug_utils/generic_function/parse.rs:267–305  ·  view source on GitHub ↗
(
    pair: Pair<'_, Rule>,
    groups: &mut PrimaryMap<ValueGroup, Vec<Value>>,
)

Source from the content-addressed store, hash-verified

265}
266
267fn 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
307fn parse_constraint(pair: Pair<'_, Rule>) -> Result<OperandConstraint> {
308 let constraint_pair = pair.into_inner().next().unwrap();

Callers 2

parse_value_declarationFunction · 0.85
parse_instructionFunction · 0.85

Calls 8

UseClass · 0.85
parse_constraintFunction · 0.85
unwrapMethod · 0.80
pushMethod · 0.80
extractFunction · 0.70
parse_entityFunction · 0.70
parse_entity_listFunction · 0.70
nextMethod · 0.45

Tested by

no test coverage detected