Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable edition=2018 for core_arch #725

Merged
merged 1 commit into from
Apr 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/core_arch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ keywords = ["core", "simd", "arch", "intrinsics"]
categories = ["hardware-support", "no-std"]
license = "MIT/Apache-2.0"
build = "build.rs"
edition = "2015"
edition = "2018"

[badges]
travis-ci = { repository = "rust-lang-nursery/stdsimd" }
Expand Down
82 changes: 41 additions & 41 deletions crates/core_arch/src/aarch64/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ mod tests {

#[simd_test(enable = "crypto")]
unsafe fn test_vaeseq_u8() {
let data = ::mem::transmute(u8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8));
let key = ::mem::transmute(u8x16::new(0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7));
let r: u8x16 = ::mem::transmute(vaeseq_u8(data, key));
let data = mem::transmute(u8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8));
let key = mem::transmute(u8x16::new(0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7));
let r: u8x16 = mem::transmute(vaeseq_u8(data, key));
assert_eq!(
r,
u8x16::new(
Expand All @@ -182,9 +182,9 @@ mod tests {

#[simd_test(enable = "crypto")]
unsafe fn test_vaesdq_u8() {
let data = ::mem::transmute(u8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8));
let key = ::mem::transmute(u8x16::new(0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7));
let r: u8x16 = ::mem::transmute(vaesdq_u8(data, key));
let data = mem::transmute(u8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8));
let key = mem::transmute(u8x16::new(0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7));
let r: u8x16 = mem::transmute(vaesdq_u8(data, key));
assert_eq!(
r,
u8x16::new(9, 213, 9, 251, 9, 213, 9, 56, 9, 213, 9, 251, 9, 213, 9, 56)
Expand All @@ -193,8 +193,8 @@ mod tests {

#[simd_test(enable = "crypto")]
unsafe fn test_vaesmcq_u8() {
let data = ::mem::transmute(u8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8));
let r: u8x16 = ::mem::transmute(vaesmcq_u8(data));
let data = mem::transmute(u8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8));
let r: u8x16 = mem::transmute(vaesmcq_u8(data));
assert_eq!(
r,
u8x16::new(3, 4, 9, 10, 15, 8, 21, 30, 3, 4, 9, 10, 15, 8, 21, 30)
Expand All @@ -203,8 +203,8 @@ mod tests {

#[simd_test(enable = "crypto")]
unsafe fn test_vaesimcq_u8() {
let data = ::mem::transmute(u8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8));
let r: u8x16 = ::mem::transmute(vaesimcq_u8(data));
let data = mem::transmute(u8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8));
let r: u8x16 = mem::transmute(vaesimcq_u8(data));
assert_eq!(
r,
u8x16::new(43, 60, 33, 50, 103, 80, 125, 70, 43, 60, 33, 50, 103, 80, 125, 70)
Expand All @@ -219,19 +219,19 @@ mod tests {

#[simd_test(enable = "crypto")]
unsafe fn test_vsha1su0q_u32() {
let r: u32x4 = ::mem::transmute(vsha1su0q_u32(
::mem::transmute(u32x4::new(0x1234_u32, 0x5678_u32, 0x9abc_u32, 0xdef0_u32)),
::mem::transmute(u32x4::new(0x1234_u32, 0x5678_u32, 0x9abc_u32, 0xdef0_u32)),
::mem::transmute(u32x4::new(0x1234_u32, 0x5678_u32, 0x9abc_u32, 0xdef0_u32)),
let r: u32x4 = mem::transmute(vsha1su0q_u32(
mem::transmute(u32x4::new(0x1234_u32, 0x5678_u32, 0x9abc_u32, 0xdef0_u32)),
mem::transmute(u32x4::new(0x1234_u32, 0x5678_u32, 0x9abc_u32, 0xdef0_u32)),
mem::transmute(u32x4::new(0x1234_u32, 0x5678_u32, 0x9abc_u32, 0xdef0_u32)),
));
assert_eq!(r, u32x4::new(0x9abc, 0xdef0, 0x1234, 0x5678));
}

#[simd_test(enable = "crypto")]
unsafe fn test_vsha1su1q_u32() {
let r: u32x4 = ::mem::transmute(vsha1su1q_u32(
::mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
::mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
let r: u32x4 = mem::transmute(vsha1su1q_u32(
mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
));
assert_eq!(
r,
Expand All @@ -241,10 +241,10 @@ mod tests {

#[simd_test(enable = "crypto")]
unsafe fn test_vsha1cq_u32() {
let r: u32x4 = ::mem::transmute(vsha1cq_u32(
::mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
let r: u32x4 = mem::transmute(vsha1cq_u32(
mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
0x1234,
::mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
));
assert_eq!(
r,
Expand All @@ -254,10 +254,10 @@ mod tests {

#[simd_test(enable = "crypto")]
unsafe fn test_vsha1pq_u32() {
let r: u32x4 = ::mem::transmute(vsha1pq_u32(
::mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
let r: u32x4 = mem::transmute(vsha1pq_u32(
mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
0x1234,
::mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
));
assert_eq!(
r,
Expand All @@ -267,10 +267,10 @@ mod tests {

#[simd_test(enable = "crypto")]
unsafe fn test_vsha1mq_u32() {
let r: u32x4 = ::mem::transmute(vsha1mq_u32(
::mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
let r: u32x4 = mem::transmute(vsha1mq_u32(
mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
0x1234,
::mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
));
assert_eq!(
r,
Expand All @@ -280,10 +280,10 @@ mod tests {

#[simd_test(enable = "crypto")]
unsafe fn test_vsha256hq_u32() {
let r: u32x4 = ::mem::transmute(vsha256hq_u32(
::mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
::mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
::mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
let r: u32x4 = mem::transmute(vsha256hq_u32(
mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
));
assert_eq!(
r,
Expand All @@ -293,10 +293,10 @@ mod tests {

#[simd_test(enable = "crypto")]
unsafe fn test_vsha256h2q_u32() {
let r: u32x4 = ::mem::transmute(vsha256h2q_u32(
::mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
::mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
::mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
let r: u32x4 = mem::transmute(vsha256h2q_u32(
mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
));
assert_eq!(
r,
Expand All @@ -306,9 +306,9 @@ mod tests {

#[simd_test(enable = "crypto")]
unsafe fn test_vsha256su0q_u32() {
let r: u32x4 = ::mem::transmute(vsha256su0q_u32(
::mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
::mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
let r: u32x4 = mem::transmute(vsha256su0q_u32(
mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
));
assert_eq!(
r,
Expand All @@ -318,10 +318,10 @@ mod tests {

#[simd_test(enable = "crypto")]
unsafe fn test_vsha256su1q_u32() {
let r: u32x4 = ::mem::transmute(vsha256su1q_u32(
::mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
::mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
::mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
let r: u32x4 = mem::transmute(vsha256su1q_u32(
mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
mem::transmute(u32x4::new(0x1234, 0x5678, 0x9abc, 0xdef0)),
));
assert_eq!(
r,
Expand Down
11 changes: 6 additions & 5 deletions crates/core_arch/src/acle/dsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ pub unsafe fn __smlawt(a: i32, b: int16x2_t, c: i32) -> i32 {
mod tests {
use crate::core_arch::arm::*;
use crate::core_arch::simd::{i16x2, i8x4, u8x4};
use std::i32;
use std::mem::transmute;
use stdsimd_test::simd_test;

Expand Down Expand Up @@ -299,24 +300,24 @@ mod tests {
fn qadd() {
unsafe {
assert_eq!(super::__qadd(-10, 60), 50);
assert_eq!(super::__qadd(::std::i32::MAX, 10), ::std::i32::MAX);
assert_eq!(super::__qadd(::std::i32::MIN, -10), ::std::i32::MIN);
assert_eq!(super::__qadd(i32::MAX, 10), i32::MAX);
assert_eq!(super::__qadd(i32::MIN, -10), i32::MIN);
}
}

#[test]
fn qsub() {
unsafe {
assert_eq!(super::__qsub(10, 60), -50);
assert_eq!(super::__qsub(::std::i32::MAX, -10), ::std::i32::MAX);
assert_eq!(super::__qsub(::std::i32::MIN, 10), ::std::i32::MIN);
assert_eq!(super::__qsub(i32::MAX, -10), i32::MAX);
assert_eq!(super::__qsub(i32::MIN, 10), i32::MIN);
}
}

fn qdbl() {
unsafe {
assert_eq!(super::__qdbl(10), 20);
assert_eq!(super::__qdbl(::std::i32::MAX), ::std::i32::MAX);
assert_eq!(super::__qdbl(i32::MAX), i32::MAX);
}
}

Expand Down
32 changes: 17 additions & 15 deletions crates/core_arch/src/acle/simd32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
#[cfg(test)]
use stdsimd_test::assert_instr;

use crate::core_arch::acle::dsp::int16x2_t;
use crate::mem::transmute;
use core_arch::acle::dsp::int16x2_t;

types! {
/// ARM-specific 32-bit wide vector of four packed `i8`.
Expand Down Expand Up @@ -465,15 +465,17 @@ pub unsafe fn __usada8(a: int8x4_t, b: int8x4_t, c: u32) -> u32 {
#[cfg(test)]
mod tests {
use crate::core_arch::simd::{i16x2, i8x4, u8x4};
use std::i16;
use std::i8;
use std::mem::transmute;
use stdsimd_test::simd_test;

#[test]
fn qadd8() {
unsafe {
let a = i8x4::new(1, 2, 3, ::std::i8::MAX);
let a = i8x4::new(1, 2, 3, i8::MAX);
let b = i8x4::new(2, -1, 0, 1);
let c = i8x4::new(3, 1, 3, ::std::i8::MAX);
let c = i8x4::new(3, 1, 3, i8::MAX);
let r: i8x4 = dsp_call!(super::__qadd8, a, b);
assert_eq!(r, c);
}
Expand All @@ -482,9 +484,9 @@ mod tests {
#[test]
fn qsub8() {
unsafe {
let a = i8x4::new(1, 2, 3, ::std::i8::MIN);
let a = i8x4::new(1, 2, 3, i8::MIN);
let b = i8x4::new(2, -1, 0, 1);
let c = i8x4::new(-1, 3, 3, ::std::i8::MIN);
let c = i8x4::new(-1, 3, 3, i8::MIN);
let r: i8x4 = dsp_call!(super::__qsub8, a, b);
assert_eq!(r, c);
}
Expand Down Expand Up @@ -515,9 +517,9 @@ mod tests {
#[test]
fn qasx() {
unsafe {
let a = i16x2::new(1, ::std::i16::MAX);
let a = i16x2::new(1, i16::MAX);
let b = i16x2::new(2, 2);
let c = i16x2::new(-1, ::std::i16::MAX);
let c = i16x2::new(-1, i16::MAX);
let r: i16x2 = dsp_call!(super::__qasx, a, b);
assert_eq!(r, c);
}
Expand All @@ -526,9 +528,9 @@ mod tests {
#[test]
fn qsax() {
unsafe {
let a = i16x2::new(1, ::std::i16::MAX);
let a = i16x2::new(1, i16::MAX);
let b = i16x2::new(2, 2);
let c = i16x2::new(3, ::std::i16::MAX - 2);
let c = i16x2::new(3, i16::MAX - 2);
let r: i16x2 = dsp_call!(super::__qsax, a, b);
assert_eq!(r, c);
}
Expand All @@ -537,9 +539,9 @@ mod tests {
#[test]
fn sadd16() {
unsafe {
let a = i16x2::new(1, ::std::i16::MAX);
let a = i16x2::new(1, i16::MAX);
let b = i16x2::new(2, 2);
let c = i16x2::new(3, -::std::i16::MAX);
let c = i16x2::new(3, -i16::MAX);
let r: i16x2 = dsp_call!(super::__sadd16, a, b);
assert_eq!(r, c);
}
Expand All @@ -548,9 +550,9 @@ mod tests {
#[test]
fn sadd8() {
unsafe {
let a = i8x4::new(1, 2, 3, ::std::i8::MAX);
let a = i8x4::new(1, 2, 3, i8::MAX);
let b = i8x4::new(4, 3, 2, 2);
let c = i8x4::new(5, 5, 5, -::std::i8::MAX);
let c = i8x4::new(5, 5, 5, -i8::MAX);
let r: i8x4 = dsp_call!(super::__sadd8, a, b);
assert_eq!(r, c);
}
Expand Down Expand Up @@ -590,11 +592,11 @@ mod tests {
#[test]
fn sel() {
unsafe {
let a = i8x4::new(1, 2, 3, ::std::i8::MAX);
let a = i8x4::new(1, 2, 3, i8::MAX);
let b = i8x4::new(4, 3, 2, 2);
// call sadd8() to set GE bits
super::__sadd8(transmute(a), transmute(b));
let c = i8x4::new(1, 2, 3, ::std::i8::MAX);
let c = i8x4::new(1, 2, 3, i8::MAX);
let r: i8x4 = dsp_call!(super::__sel, a, b);
assert_eq!(r, c);
}
Expand Down
18 changes: 12 additions & 6 deletions crates/core_arch/src/arm/neon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,13 @@ pub unsafe fn vtbx4_p8(a: poly8x8_t, b: poly8x8x4_t, c: uint8x8_t) -> poly8x8_t
#[cfg(test)]
mod tests {
use crate::core_arch::{arm::*, simd::*};
use std::i16;
use std::i32;
use std::i8;
use std::mem::transmute;
use std::u16;
use std::u32;
use std::u8;
use stdsimd_test::simd_test;

#[simd_test(enable = "neon")]
Expand Down Expand Up @@ -1108,7 +1114,7 @@ mod tests {

#[simd_test(enable = "neon")]
unsafe fn test_vaddl_s8() {
let v = ::std::i8::MAX;
let v = i8::MAX;
let a = i8x8::new(v, v, v, v, v, v, v, v);
let v = 2 * (v as i16);
let e = i16x8::new(v, v, v, v, v, v, v, v);
Expand All @@ -1118,7 +1124,7 @@ mod tests {

#[simd_test(enable = "neon")]
unsafe fn test_vaddl_s16() {
let v = ::std::i16::MAX;
let v = i16::MAX;
let a = i16x4::new(v, v, v, v);
let v = 2 * (v as i32);
let e = i32x4::new(v, v, v, v);
Expand All @@ -1128,7 +1134,7 @@ mod tests {

#[simd_test(enable = "neon")]
unsafe fn test_vaddl_s32() {
let v = ::std::i32::MAX;
let v = i32::MAX;
let a = i32x2::new(v, v);
let v = 2 * (v as i64);
let e = i64x2::new(v, v);
Expand All @@ -1138,7 +1144,7 @@ mod tests {

#[simd_test(enable = "neon")]
unsafe fn test_vaddl_u8() {
let v = ::std::u8::MAX;
let v = u8::MAX;
let a = u8x8::new(v, v, v, v, v, v, v, v);
let v = 2 * (v as u16);
let e = u16x8::new(v, v, v, v, v, v, v, v);
Expand All @@ -1148,7 +1154,7 @@ mod tests {

#[simd_test(enable = "neon")]
unsafe fn test_vaddl_u16() {
let v = ::std::u16::MAX;
let v = u16::MAX;
let a = u16x4::new(v, v, v, v);
let v = 2 * (v as u32);
let e = u32x4::new(v, v, v, v);
Expand All @@ -1158,7 +1164,7 @@ mod tests {

#[simd_test(enable = "neon")]
unsafe fn test_vaddl_u32() {
let v = ::std::u32::MAX;
let v = u32::MAX;
let a = u32x2::new(v, v);
let v = 2 * (v as u64);
let e = u64x2::new(v, v);
Expand Down
Loading