mirror of
https://github.com/rust-lang/rust.git
synced 2025-11-18 19:47:01 +00:00
* fix build after stabilization of cfg_target_feature and target_feature * fix doc tests * fix spurious unused_attributes warning * fix more unused attribute warnings * More unnecessary target features * Remove no longer needed trait imports * Remove fixed upstream workarounds * Fix parsing the #[assert_instr] macro Following upstream proc_macro changes * Fix form and parsing of #[simd_test] * Don't use Cargo features for testing modes Instead use RUSTFLAGS with `--cfg`. This'll help us be compatible with the latest Cargo where a tweak to workspaces and features made the previous invocations we had invalid. * Don't thread RUSTFLAGS through docker * Re-gate on x86 verification Closes #411
56 lines
1.4 KiB
Rust
56 lines
1.4 KiB
Rust
//! MIPS SIMD Architecture intrinsics
|
|
//!
|
|
//! The reference is [MIPS Architecture for Programmers Volume IV-j: The
|
|
//! MIPS32 SIMD Architecture Module Revision 1.12][msa_ref].
|
|
//!
|
|
//! [msa_ref]: http://cdn2.imgtec.com/documentation/MD00866-2B-MSA32-AFP-01.12.pdf
|
|
|
|
use coresimd::simd::*;
|
|
#[cfg(test)]
|
|
use stdsimd_test::assert_instr;
|
|
|
|
#[allow(improper_ctypes)]
|
|
extern "C" {
|
|
#[link_name = "llvm.mips.add.a.b"]
|
|
fn msa_add_a_b(a: i8x16, b: i8x16) -> i8x16;
|
|
}
|
|
|
|
/// Vector Add Absolute Values.
|
|
///
|
|
/// Adds the absolute values of the elements in `a` and `b` into the result
|
|
/// vector.
|
|
#[inline]
|
|
#[target_feature(enable = "msa")]
|
|
#[cfg_attr(test, assert_instr(add_a.b))]
|
|
pub unsafe fn __msa_add_a_b(a: i8x16, b: i8x16) -> i8x16 {
|
|
msa_add_a_b(a, b)
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use coresimd::mips64::msa;
|
|
use simd::*;
|
|
use stdsimd_test::simd_test;
|
|
|
|
#[simd_test(enable = "msa")]
|
|
unsafe fn __msa_add_a_b() {
|
|
#[cfg_attr(rustfmt, rustfmt_skip)]
|
|
let a = i8x16::new(
|
|
1, 2, 3, 4,
|
|
1, 2, 3, 4,
|
|
1, 2, 3, 4,
|
|
1, 2, 3, 4,
|
|
);
|
|
#[cfg_attr(rustfmt, rustfmt_skip)]
|
|
let b = i8x16::new(
|
|
-4, -3, -2, -1,
|
|
-4, -3, -2, -1,
|
|
-4, -3, -2, -1,
|
|
-4, -3, -2, -1,
|
|
);
|
|
let r = i8x16::splat(5);
|
|
|
|
assert_eq!(r, msa::__msa_add_a_b(a, b));
|
|
}
|
|
}
|