Use the target-lexicon crate.

This switches from a custom list of architectures to use the
target-lexicon crate.

 - "set is_64bit=1; isa x86" is replaced with "target x86_64", and
   similar for other architectures, and the `is_64bit` flag is removed
   entirely.

 - The `is_compressed` flag is removed too; it's no longer being used to
   control REX prefixes on x86-64, ARM and Thumb are separate
   architectures in target-lexicon, and we can figure out how to
   select RISC-V compressed encodings when we're ready.
This commit is contained in:
Dan Gohman
2018-05-25 11:41:14 -07:00
parent 2f3008aa40
commit 4e67e08efd
131 changed files with 487 additions and 499 deletions

View File

@@ -7,6 +7,8 @@ use cretonne_reader::{parse_options, Location};
use std::fs::File;
use std::io::{self, Read};
use std::path::Path;
use std::str::FromStr;
use target_lexicon::Triple;
/// Read an entire file into a string.
pub fn read_to_string<P: AsRef<Path>>(path: P) -> io::Result<String> {
@@ -40,8 +42,11 @@ impl OwnedFlagsOrIsa {
}
}
/// Parse "set" and "isa" commands.
pub fn parse_sets_and_isa(flag_set: &[String], flag_isa: &str) -> Result<OwnedFlagsOrIsa, String> {
/// Parse "set" and "triple" commands.
pub fn parse_sets_and_triple(
flag_set: &[String],
flag_triple: &str,
) -> Result<OwnedFlagsOrIsa, String> {
let mut flag_builder = settings::builder();
parse_options(
flag_set.iter().map(|x| x.as_str()),
@@ -49,12 +54,21 @@ pub fn parse_sets_and_isa(flag_set: &[String], flag_isa: &str) -> Result<OwnedFl
&Location { line_number: 0 },
).map_err(|err| err.to_string())?;
let mut words = flag_isa.trim().split_whitespace();
// Look for `isa foo`.
if let Some(isa_name) = words.next() {
let mut isa_builder = isa::lookup(isa_name).map_err(|err| match err {
isa::LookupError::Unknown => format!("unknown ISA '{}'", isa_name),
isa::LookupError::Unsupported => format!("support for ISA '{}' not enabled", isa_name),
let mut words = flag_triple.trim().split_whitespace();
// Look for `target foo`.
if let Some(triple_name) = words.next() {
let triple = match Triple::from_str(triple_name) {
Ok(triple) => triple,
Err(parse_error) => return Err(format!("{}", parse_error)),
};
let mut isa_builder = isa::lookup(triple).map_err(|err| match err {
isa::LookupError::SupportDisabled => {
format!("support for triple '{}' is disabled", triple_name)
}
isa::LookupError::Unsupported => format!(
"support for triple '{}' is not implemented yet",
triple_name
),
})?;
// Apply the ISA-specific settings to `isa_builder`.
parse_options(words, &mut isa_builder, &Location { line_number: 0 })