Skip to content

Commit 90fb25a

Browse files
committed
Auto merge of rust-lang#3556 - RalfJung:intrinsics, r=RalfJung
move intrinsics tests into dedicated folder And separate them from "shims" (which are for extern functions we link against).
2 parents d90acac + c484fd2 commit 90fb25a

26 files changed

+32
-32
lines changed

src/tools/miri/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ mod concurrency;
7979
mod diagnostics;
8080
mod eval;
8181
mod helpers;
82+
mod intrinsics;
8283
mod machine;
8384
mod mono_hash_map;
8485
mod operator;
@@ -95,9 +96,9 @@ pub use rustc_const_eval::interpret::*;
9596
#[doc(no_inline)]
9697
pub use rustc_const_eval::interpret::{self, AllocMap, PlaceTy, Provenance as _};
9798

99+
pub use crate::intrinsics::EvalContextExt as _;
98100
pub use crate::shims::env::{EnvVars, EvalContextExt as _};
99101
pub use crate::shims::foreign_items::{DynSym, EvalContextExt as _};
100-
pub use crate::shims::intrinsics::EvalContextExt as _;
101102
pub use crate::shims::os_str::EvalContextExt as _;
102103
pub use crate::shims::panic::{CatchUnwindData, EvalContextExt as _};
103104
pub use crate::shims::time::EvalContextExt as _;

src/tools/miri/src/shims/foreign_items.rs

+30-30
Original file line numberDiff line numberDiff line change
@@ -893,36 +893,6 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
893893
throw_unsup_format!("unsupported `llvm.prefetch` type argument: {}", ty);
894894
}
895895
}
896-
// FIXME: Move these to an `arm` submodule.
897-
"llvm.aarch64.isb" if this.tcx.sess.target.arch == "aarch64" => {
898-
let [arg] = this.check_shim(abi, Abi::Unadjusted, link_name, args)?;
899-
let arg = this.read_scalar(arg)?.to_i32()?;
900-
match arg {
901-
// SY ("full system scope")
902-
15 => {
903-
this.yield_active_thread();
904-
}
905-
_ => {
906-
throw_unsup_format!("unsupported llvm.aarch64.isb argument {}", arg);
907-
}
908-
}
909-
}
910-
"llvm.arm.hint" if this.tcx.sess.target.arch == "arm" => {
911-
let [arg] = this.check_shim(abi, Abi::Unadjusted, link_name, args)?;
912-
let arg = this.read_scalar(arg)?.to_i32()?;
913-
// Note that different arguments might have different target feature requirements.
914-
match arg {
915-
// YIELD
916-
1 => {
917-
this.expect_target_feature_for_intrinsic(link_name, "v6")?;
918-
this.yield_active_thread();
919-
}
920-
_ => {
921-
throw_unsup_format!("unsupported llvm.arm.hint argument {}", arg);
922-
}
923-
}
924-
}
925-
926896
// Used to implement the x86 `_mm{,256,512}_popcnt_epi{8,16,32,64}` and wasm
927897
// `{i,u}8x16_popcnt` functions.
928898
name if name.starts_with("llvm.ctpop.v") => {
@@ -946,6 +916,7 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
946916
}
947917
}
948918

919+
// Target-specific shims
949920
name if name.starts_with("llvm.x86.")
950921
&& (this.tcx.sess.target.arch == "x86"
951922
|| this.tcx.sess.target.arch == "x86_64") =>
@@ -954,6 +925,35 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
954925
this, link_name, abi, args, dest,
955926
);
956927
}
928+
// FIXME: Move these to an `arm` submodule.
929+
"llvm.aarch64.isb" if this.tcx.sess.target.arch == "aarch64" => {
930+
let [arg] = this.check_shim(abi, Abi::Unadjusted, link_name, args)?;
931+
let arg = this.read_scalar(arg)?.to_i32()?;
932+
match arg {
933+
// SY ("full system scope")
934+
15 => {
935+
this.yield_active_thread();
936+
}
937+
_ => {
938+
throw_unsup_format!("unsupported llvm.aarch64.isb argument {}", arg);
939+
}
940+
}
941+
}
942+
"llvm.arm.hint" if this.tcx.sess.target.arch == "arm" => {
943+
let [arg] = this.check_shim(abi, Abi::Unadjusted, link_name, args)?;
944+
let arg = this.read_scalar(arg)?.to_i32()?;
945+
// Note that different arguments might have different target feature requirements.
946+
match arg {
947+
// YIELD
948+
1 => {
949+
this.expect_target_feature_for_intrinsic(link_name, "v6")?;
950+
this.yield_active_thread();
951+
}
952+
_ => {
953+
throw_unsup_format!("unsupported llvm.arm.hint argument {}", arg);
954+
}
955+
}
956+
}
957957

958958
// Platform-specific shims
959959
_ =>

src/tools/miri/src/shims/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ mod backtrace;
55
#[cfg(target_os = "linux")]
66
pub mod ffi_support;
77
pub mod foreign_items;
8-
pub mod intrinsics;
98
pub mod unix;
109
pub mod windows;
1110
mod x86;
File renamed without changes.

0 commit comments

Comments
 (0)