Update to target_lexicon 0.2.0.

This commit is contained in:
Dan Gohman
2018-11-07 14:25:03 -08:00
parent 3409af7c07
commit b476f823d4
10 changed files with 16 additions and 30 deletions

View File

@@ -17,7 +17,7 @@ cranelift-bforest = { path = "../bforest", version = "0.22.0", default-features
failure = { version = "0.1.1", default-features = false, features = ["derive"] }
failure_derive = { version = "0.1.1", default-features = false }
hashmap_core = { version = "0.1.9", optional = true }
target-lexicon = { version = "0.0.3", default-features = false }
target-lexicon = { version = "0.2.0", default-features = false }
log = { version = "0.4.4", default-features = false }
# It is a goal of the cranelift-codegen crate to have minimal external dependencies.
# Please don't add any unless they are essential to the task of creating binary

View File

@@ -1,6 +1,6 @@
use std::fmt;
use std::str;
use target_lexicon::{OperatingSystem, Triple};
use target_lexicon::{CallingConvention, Triple};
/// Calling convention identifiers.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
@@ -22,25 +22,11 @@ pub enum CallConv {
impl CallConv {
/// Return the default calling convention for the given target triple.
pub fn default_for_triple(triple: &Triple) -> Self {
match triple.operating_system {
OperatingSystem::Unknown
| OperatingSystem::Bitrig
| OperatingSystem::Cloudabi
| OperatingSystem::Darwin
| OperatingSystem::Dragonfly
| OperatingSystem::Freebsd
| OperatingSystem::Fuchsia
| OperatingSystem::Haiku
| OperatingSystem::Ios
| OperatingSystem::L4re
| OperatingSystem::Linux
| OperatingSystem::Nebulet
| OperatingSystem::Netbsd
| OperatingSystem::Openbsd
| OperatingSystem::Redox
| OperatingSystem::Solaris => CallConv::SystemV,
OperatingSystem::Windows => CallConv::WindowsFastcall,
os => panic!("unsupported operating system: {}", os),
match triple.default_calling_convention() {
// Default to System V for unknown targets because most everything
// uses System V.
Ok(CallingConvention::SystemV) | Err(()) => CallConv::SystemV,
Ok(CallingConvention::WindowsFastcall) => CallConv::WindowsFastcall,
}
}
}