Parses an ISA string and returns an iterator over the extensions.
(isa: &str)
| 85 | |
| 86 | /// Parses an ISA string and returns an iterator over the extensions. |
| 87 | fn isa_string_extensions(isa: &str) -> Vec<&str> { |
| 88 | let mut parts = isa.split('_'); |
| 89 | let mut extensions = Vec::new(); |
| 90 | // The first entry has the form `rv64imafdcvh`, we need to skip the architecture ("rv64"). |
| 91 | // Each of the letters after the cpu architecture is an extension, so return them |
| 92 | // individually. |
| 93 | if let Some(letters) = parts.next().unwrap().strip_prefix("rv64") { |
| 94 | extensions.extend(letters.matches(|_| true)); |
| 95 | extensions.extend(parts); |
| 96 | } |
| 97 | extensions |
| 98 | } |
| 99 | |
| 100 | #[cfg(test)] |
| 101 | mod tests { |