Skip to content

Commit 699fa9a

Browse files
committed
Sync from rust b6d7ff3aa71e48e2901b0900f8b5d98126b537ed
2 parents a842469 + d1c33c3 commit 699fa9a

File tree

4 files changed

+15
-26
lines changed

4 files changed

+15
-26
lines changed

src/abi/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,8 @@ pub(crate) fn codegen_call_with_unwind_action(
916916
pub(crate) fn lib_call_arg_param(tcx: TyCtxt<'_>, ty: Type, is_signed: bool) -> AbiParam {
917917
let param = AbiParam::new(ty);
918918
if ty.is_int() && u64::from(ty.bits()) < tcx.data_layout.pointer_size().bits() {
919-
match (&tcx.sess.target.arch, tcx.sess.target.vendor.as_ref()) {
920-
(Arch::X86_64, _) | (Arch::AArch64, "apple") => match (ty, is_signed) {
919+
match (&tcx.sess.target.arch, tcx.sess.target.is_like_darwin) {
920+
(Arch::X86_64, _) | (Arch::AArch64, true) => match (ty, is_signed) {
921921
(types::I8 | types::I16, true) => param.sext(),
922922
(types::I8 | types::I16, false) => param.uext(),
923923
_ => param,

src/base.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -865,17 +865,8 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
865865
fields.iter(),
866866
)
867867
.bytes(),
868-
NullOp::UbChecks => {
869-
let val = fx.tcx.sess.ub_checks();
870-
let val = CValue::by_val(
871-
fx.bcx.ins().iconst(types::I8, i64::from(val)),
872-
fx.layout_of(fx.tcx.types.bool),
873-
);
874-
lval.write_cvalue(fx, val);
875-
return;
876-
}
877-
NullOp::ContractChecks => {
878-
let val = fx.tcx.sess.contract_checks();
868+
NullOp::RuntimeChecks(kind) => {
869+
let val = kind.value(fx.tcx.sess);
879870
let val = CValue::by_val(
880871
fx.bcx.ins().iconst(types::I8, i64::from(val)),
881872
fx.layout_of(fx.tcx.types.bool),

src/codegen_f16_f128.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::prelude::*;
55

66
pub(crate) fn f16_to_f32(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value {
77
let (value, arg_ty) =
8-
if fx.tcx.sess.target.vendor == "apple" && fx.tcx.sess.target.arch == Arch::X86_64 {
8+
if fx.tcx.sess.target.is_like_darwin && fx.tcx.sess.target.arch == Arch::X86_64 {
99
(
1010
fx.bcx.ins().bitcast(types::I16, MemFlags::new(), value),
1111
lib_call_arg_param(fx.tcx, types::I16, false),
@@ -22,8 +22,7 @@ fn f16_to_f64(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value {
2222
}
2323

2424
pub(crate) fn f32_to_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value {
25-
let ret_ty = if fx.tcx.sess.target.vendor == "apple" && fx.tcx.sess.target.arch == Arch::X86_64
26-
{
25+
let ret_ty = if fx.tcx.sess.target.is_like_darwin && fx.tcx.sess.target.arch == Arch::X86_64 {
2726
types::I16
2827
} else {
2928
types::F16
@@ -38,8 +37,7 @@ pub(crate) fn f32_to_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value
3837
}
3938

4039
fn f64_to_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value {
41-
let ret_ty = if fx.tcx.sess.target.vendor == "apple" && fx.tcx.sess.target.arch == Arch::X86_64
42-
{
40+
let ret_ty = if fx.tcx.sess.target.is_like_darwin && fx.tcx.sess.target.arch == Arch::X86_64 {
4341
types::I16
4442
} else {
4543
types::F16

src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
4949
use rustc_session::Session;
5050
use rustc_session::config::OutputFilenames;
5151
use rustc_span::{Symbol, sym};
52-
use rustc_target::spec::Arch;
52+
use rustc_target::spec::{Abi, Arch, Env, Os};
5353

5454
pub use crate::config::*;
5555
use crate::prelude::*;
@@ -163,15 +163,15 @@ impl CodegenBackend for CraneliftCodegenBackend {
163163
fn target_config(&self, sess: &Session) -> TargetConfig {
164164
// FIXME return the actually used target features. this is necessary for #[cfg(target_feature)]
165165
let target_features = match sess.target.arch {
166-
Arch::X86_64 if sess.target.os != "none" => {
166+
Arch::X86_64 if sess.target.os != Os::None => {
167167
// x86_64 mandates SSE2 support and rustc requires the x87 feature to be enabled
168168
vec![sym::fxsr, sym::sse, sym::sse2, Symbol::intern("x87")]
169169
}
170-
Arch::AArch64 => match &*sess.target.os {
171-
"none" => vec![],
170+
Arch::AArch64 => match &sess.target.os {
171+
Os::None => vec![],
172172
// On macOS the aes, sha2 and sha3 features are enabled by default and ring
173173
// fails to compile on macOS when they are not present.
174-
"macos" => vec![sym::neon, sym::aes, sym::sha2, sym::sha3],
174+
Os::MacOs => vec![sym::neon, sym::aes, sym::sha2, sym::sha3],
175175
// AArch64 mandates Neon support
176176
_ => vec![sym::neon],
177177
},
@@ -184,9 +184,9 @@ impl CodegenBackend for CraneliftCodegenBackend {
184184
// targets due to GCC using a different ABI than LLVM. Therefore `f16` and `f128`
185185
// won't be available when using a LLVM-built sysroot.
186186
let has_reliable_f16_f128 = !(sess.target.arch == Arch::X86_64
187-
&& sess.target.os == "windows"
188-
&& sess.target.env == "gnu"
189-
&& sess.target.abi != "llvm");
187+
&& sess.target.os == Os::Windows
188+
&& sess.target.env == Env::Gnu
189+
&& sess.target.abi != Abi::Llvm);
190190

191191
TargetConfig {
192192
target_features,

0 commit comments

Comments
 (0)