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:
@@ -17,9 +17,11 @@
|
||||
extern crate cretonne_codegen;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
extern crate raw_cpuid;
|
||||
extern crate target_lexicon;
|
||||
|
||||
use cretonne_codegen::isa;
|
||||
use cretonne_codegen::settings::{self, Configurable};
|
||||
use target_lexicon::Triple;
|
||||
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use raw_cpuid::CpuId;
|
||||
@@ -38,25 +40,8 @@ pub fn builders() -> Result<(settings::Builder, isa::Builder), &'static str> {
|
||||
return Err("unrecognized environment");
|
||||
}
|
||||
|
||||
if cfg!(target_pointer_width = "64") {
|
||||
flag_builder.enable("is_64bit").unwrap();
|
||||
} else if !cfg!(target_pointer_width = "32") {
|
||||
return Err("unrecognized pointer size");
|
||||
}
|
||||
|
||||
// TODO: Add RISC-V support once Rust supports it.
|
||||
let name = if cfg!(any(target_arch = "x86", target_arch = "x86_64")) {
|
||||
"x86"
|
||||
} else if cfg!(target_arch = "arm") {
|
||||
"arm32"
|
||||
} else if cfg!(target_arch = "aarch64") {
|
||||
"arm64"
|
||||
} else {
|
||||
return Err("unrecognized architecture");
|
||||
};
|
||||
|
||||
let mut isa_builder = isa::lookup(name).map_err(|err| match err {
|
||||
isa::LookupError::Unknown => panic!(),
|
||||
let mut isa_builder = isa::lookup(Triple::host()).map_err(|err| match err {
|
||||
isa::LookupError::SupportDisabled => "support for architecture disabled at compile time",
|
||||
isa::LookupError::Unsupported => "unsupported architecture",
|
||||
})?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user