-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
75 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
use std::cmp; | ||
|
||
use rustc_middle::ty::Ty; | ||
use rustc_span::Symbol; | ||
use rustc_target::callconv::{Conv, FnAbi}; | ||
|
||
use self::helpers::bool_to_simd_element; | ||
use crate::*; | ||
|
||
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {} | ||
pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | ||
fn emulate_aarch64_intrinsic( | ||
&mut self, | ||
link_name: Symbol, | ||
abi: &FnAbi<'tcx, Ty<'tcx>>, | ||
args: &[OpTy<'tcx>], | ||
dest: &MPlaceTy<'tcx>, | ||
) -> InterpResult<'tcx, EmulateItemResult> { | ||
let this = self.eval_context_mut(); | ||
// Prefix should have already been checked. | ||
let unprefixed_name = link_name.as_str().strip_prefix("llvm.aarch64.").unwrap(); | ||
match unprefixed_name { | ||
"isb" => { | ||
let [arg] = this.check_shim(abi, Conv::C, link_name, args)?; | ||
let arg = this.read_scalar(arg)?.to_i32()?; | ||
match arg { | ||
// SY ("full system scope") | ||
15 => { | ||
this.yield_active_thread(); | ||
} | ||
_ => { | ||
throw_unsup_format!("unsupported llvm.aarch64.isb argument {}", arg); | ||
} | ||
} | ||
} | ||
|
||
"neon.umaxp.v16i8" => { | ||
let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; | ||
|
||
let (left, left_len) = this.project_to_simd(left)?; | ||
let (right, right_len) = this.project_to_simd(right)?; | ||
let (dest, lane_count) = this.project_to_simd(dest)?; | ||
assert_eq!(left_len, right_len); | ||
assert_eq!(lane_count, left_len); | ||
|
||
for lane_idx in 0..lane_count { | ||
let src = if lane_idx < (lane_count / 2) { &left } else { &right }; | ||
let src_idx = lane_idx % (lane_count / 2); | ||
|
||
let lhs_lane = this.read_scalar(&this.project_index(src, src_idx * 2)?)?; | ||
let rhs_lane = this.read_scalar(&this.project_index(src, src_idx * 2 + 1)?)?; | ||
|
||
let res_lane = match unprefixed_name { | ||
"neon.umaxp.v16i8" => { | ||
Scalar::from_i8(cmp::max(lhs_lane.to_i8()?, rhs_lane.to_i8()?)) | ||
} | ||
_ => unreachable!(), | ||
}; | ||
|
||
let dest = this.project_index(&dest, lane_idx)?; | ||
this.write_scalar(res_lane, &dest)?; | ||
} | ||
} | ||
|
||
_ => return interp_ok(EmulateItemResult::NotSupported), | ||
} | ||
interp_ok(EmulateItemResult::NeedsReturn) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#![warn(clippy::arithmetic_side_effects)] | ||
|
||
mod aarch64; | ||
mod alloc; | ||
mod backtrace; | ||
mod files; | ||
|