Skip to content

Commit 836e0ba

Browse files
committed
move msa to mips
1 parent 71411d9 commit 836e0ba

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

coresimd/mips/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//! MIPS
2+
3+
mod msa;
4+
pub use self::msa::*;

coresimd/mips/msa.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//! MIPS SIMD Architecture intrinsics
2+
//!
3+
//! The reference is [MIPS Architecture for Programmers Volume IV-j: The MIPS32 SIMD
4+
//! Architecture Module Revision 1.12][msa_ref].
5+
//!
6+
//! [msa_ref]: http://cdn2.imgtec.com/documentation/MD00866-2B-MSA32-AFP-01.12.pdf
7+
8+
#[cfg(test)]
9+
use stdsimd_test::assert_instr;
10+
use ::coresimd::simd::*;
11+
12+
#[allow(improper_ctypes)]
13+
extern "C" {
14+
#[link_name = "llvm.mips.add.a.b"]
15+
fn msa_add_a_b(a: i8x16, b: i8x16) -> i8x16;
16+
}
17+
18+
/// Vector Add Absolute Values.
19+
///
20+
/// Adds the absolute values of the elements in `a` and `b` into the result vector.
21+
#[inline]
22+
#[target_feature(enable = "msa")]
23+
#[cfg_attr(test, assert_instr(add_a.b))]
24+
pub unsafe fn __msa_add_a_b(a: i8x16, b: i8x16) -> i8x16 {
25+
msa_add_a_b(a, b)
26+
}
27+
28+
#[cfg(test)]
29+
mod tests {
30+
use simd::*;
31+
use stdsimd_test::simd_test;
32+
use coresimd::mips64::msa;
33+
34+
#[simd_test = "msa"]
35+
unsafe fn __msa_add_a_b() {
36+
#[cfg_attr(rustfmt, rustfmt_skip)]
37+
let a = i8x16::new(
38+
1, 2, 3, 4,
39+
1, 2, 3, 4,
40+
1, 2, 3, 4,
41+
1, 2, 3, 4,
42+
);
43+
#[cfg_attr(rustfmt, rustfmt_skip)]
44+
let b = i8x16::new(
45+
-4, -3, -2, -1,
46+
-4, -3, -2, -1,
47+
-4, -3, -2, -1,
48+
-4, -3, -2, -1,
49+
);
50+
let r = i8x16::splat(5);
51+
52+
assert_eq!(r, msa::__msa_add_a_b(a, b));
53+
}
54+
}

0 commit comments

Comments
 (0)