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

Method parse

src/debug_utils/generic_reginfo/parse.rs:347–376  ·  view source on GitHub ↗

Parses a textual register description into a [`GenericRegInfo`].

(input: &str)

Source from the content-addressed store, hash-verified

345impl GenericRegInfo {
346 /// Parses a textual register description into a [`GenericRegInfo`].
347 pub fn parse(input: &str) -> Result<Self> {
348 let parse_result = FunctionParser::parse(Rule::reginfo, input)?;
349
350 let mut banks = PrimaryMap::new();
351 let mut classes = PrimaryMap::new();
352 let mut regs = PrimaryMap::new();
353 let mut groups = PrimaryMap::new();
354 let mut superclasses = SecondaryMap::new();
355
356 for pair in parse_result {
357 match pair.as_rule() {
358 Rule::reg_def => parse_reg_def(pair, &mut regs)?,
359 Rule::reg_group_def => parse_reg_group_def(pair, &mut groups)?,
360 Rule::bank_def => {
361 parse_bank_def(pair, &mut banks, &mut classes, &mut regs, &mut superclasses)?;
362 }
363 Rule::EOI => {}
364 _ => unreachable!("{:?}", pair.as_rule()),
365 }
366 }
367
368 resolve_subclasses(&mut classes, &superclasses);
369
370 Ok(Self {
371 banks,
372 classes,
373 regs,
374 groups,
375 })
376 }
377}

Callers 1

parse_numberFunction · 0.45

Calls 4

parse_reg_defFunction · 0.85
parse_reg_group_defFunction · 0.85
parse_bank_defFunction · 0.85
resolve_subclassesFunction · 0.85

Tested by

no test coverage detected