i128 test: transmute intrinsic output before comparing

on Windows, these intrinsics return a U64x2 type because of ABI requirements
This commit is contained in:
Jorge Aparicio 2017-04-11 14:47:23 -05:00
parent aa553fe113
commit 46085a2313
1 changed files with 71 additions and 15 deletions

View File

@ -189,6 +189,7 @@ use core::mem;
target_os = "linux", target_os = "linux",
test)))] test)))]
use std::mem; use std::mem;
use compiler_builtins::float::add::__adddf3; use compiler_builtins::float::add::__adddf3;
fn mk_f64(x: u64) -> f64 { fn mk_f64(x: u64) -> f64 {
@ -828,11 +829,22 @@ fn divsi3() {
} }
fn prologue() -> &'static str { fn prologue() -> &'static str {
" r#"
#[cfg(all(target_arch = "arm",
not(any(target_env = "gnu", target_env = "musl")),
target_os = "linux",
test))]
use core::mem;
#[cfg(not(all(target_arch = "arm",
not(any(target_env = "gnu", target_env = "musl")),
target_os = "linux",
test)))]
use std::mem;
use compiler_builtins::int::sdiv::__divti3; use compiler_builtins::int::sdiv::__divti3;
static TEST_CASES: &[((i128, i128), i128)] = &[ static TEST_CASES: &[((i128, i128), i128)] = &[
" "#
} }
fn epilogue() -> &'static str { fn epilogue() -> &'static str {
@ -842,7 +854,7 @@ static TEST_CASES: &[((i128, i128), i128)] = &[
#[test] #[test]
fn divti3() { fn divti3() {
for &((a, b), c) in TEST_CASES { for &((a, b), c) in TEST_CASES {
let c_ = __divti3(a, b); let c_: i128 = unsafe { mem::transmute(__divti3(a, b)) };
assert_eq!(((a, b), c), ((a, b), c_)); assert_eq!(((a, b), c), ((a, b), c_));
} }
} }
@ -1895,11 +1907,22 @@ fn modsi3() {
} }
fn prologue() -> &'static str { fn prologue() -> &'static str {
" r#"
#[cfg(all(target_arch = "arm",
not(any(target_env = "gnu", target_env = "musl")),
target_os = "linux",
test))]
use core::mem;
#[cfg(not(all(target_arch = "arm",
not(any(target_env = "gnu", target_env = "musl")),
target_os = "linux",
test)))]
use std::mem;
use compiler_builtins::int::sdiv::__modti3; use compiler_builtins::int::sdiv::__modti3;
static TEST_CASES: &[((i128, i128), i128)] = &[ static TEST_CASES: &[((i128, i128), i128)] = &[
" "#
} }
fn epilogue() -> &'static str { fn epilogue() -> &'static str {
@ -1909,7 +1932,7 @@ static TEST_CASES: &[((i128, i128), i128)] = &[
#[test] #[test]
fn modti3() { fn modti3() {
for &((a, b), c) in TEST_CASES { for &((a, b), c) in TEST_CASES {
let c_ = __modti3(a, b); let c_: i128 = unsafe { mem::transmute(__modti3(a, b)) };
assert_eq!(((a, b), c), ((a, b), c_)); assert_eq!(((a, b), c), ((a, b), c_));
} }
} }
@ -2913,11 +2936,22 @@ fn udivmodsi4() {
} }
fn prologue() -> &'static str { fn prologue() -> &'static str {
" r#"
#[cfg(all(target_arch = "arm",
not(any(target_env = "gnu", target_env = "musl")),
target_os = "linux",
test))]
use core::mem;
#[cfg(not(all(target_arch = "arm",
not(any(target_env = "gnu", target_env = "musl")),
target_os = "linux",
test)))]
use std::mem;
use compiler_builtins::int::udiv::__udivmodti4; use compiler_builtins::int::udiv::__udivmodti4;
static TEST_CASES: &[((u128, u128), (u128, u128))] = &[ static TEST_CASES: &[((u128, u128), (u128, u128))] = &[
" "#
} }
fn epilogue() -> &'static str { fn epilogue() -> &'static str {
@ -2928,7 +2962,7 @@ static TEST_CASES: &[((u128, u128), (u128, u128))] = &[
fn udivmodti4() { fn udivmodti4() {
for &((a, b), (c, rem)) in TEST_CASES { for &((a, b), (c, rem)) in TEST_CASES {
let mut rem_ = 0; let mut rem_ = 0;
let c_ = __udivmodti4(a, b, Some(&mut rem_)); let c_: u128 = unsafe { mem::transmute(__udivmodti4(a, b, Some(&mut rem_))) };
assert_eq!(((a, b), (c, rem)), ((a, b), (c_, rem_))); assert_eq!(((a, b), (c, rem)), ((a, b), (c_, rem_)));
} }
} }
@ -3036,11 +3070,22 @@ fn udivsi3() {
} }
fn prologue() -> &'static str { fn prologue() -> &'static str {
" r#"
#[cfg(all(target_arch = "arm",
not(any(target_env = "gnu", target_env = "musl")),
target_os = "linux",
test))]
use core::mem;
#[cfg(not(all(target_arch = "arm",
not(any(target_env = "gnu", target_env = "musl")),
target_os = "linux",
test)))]
use std::mem;
use compiler_builtins::int::udiv::__udivti3; use compiler_builtins::int::udiv::__udivti3;
static TEST_CASES: &[((u128, u128), u128)] = &[ static TEST_CASES: &[((u128, u128), u128)] = &[
" "#
} }
fn epilogue() -> &'static str { fn epilogue() -> &'static str {
@ -3050,7 +3095,7 @@ static TEST_CASES: &[((u128, u128), u128)] = &[
#[test] #[test]
fn udivti3() { fn udivti3() {
for &((a, b), c) in TEST_CASES { for &((a, b), c) in TEST_CASES {
let c_ = __udivti3(a, b); let c_: u128 = unsafe { mem::transmute(__udivti3(a, b)) };
assert_eq!(((a, b), c), ((a, b), c_)); assert_eq!(((a, b), c), ((a, b), c_));
} }
} }
@ -3219,11 +3264,22 @@ fn umodsi3() {
} }
fn prologue() -> &'static str { fn prologue() -> &'static str {
" r#"
#[cfg(all(target_arch = "arm",
not(any(target_env = "gnu", target_env = "musl")),
target_os = "linux",
test))]
use core::mem;
#[cfg(not(all(target_arch = "arm",
not(any(target_env = "gnu", target_env = "musl")),
target_os = "linux",
test)))]
use std::mem;
use compiler_builtins::int::udiv::__umodti3; use compiler_builtins::int::udiv::__umodti3;
static TEST_CASES: &[((u128, u128), u128)] = &[ static TEST_CASES: &[((u128, u128), u128)] = &[
" "#
} }
fn epilogue() -> &'static str { fn epilogue() -> &'static str {
@ -3233,7 +3289,7 @@ static TEST_CASES: &[((u128, u128), u128)] = &[
#[test] #[test]
fn umodti3() { fn umodti3() {
for &((a, b), c) in TEST_CASES { for &((a, b), c) in TEST_CASES {
let c_ = __umodti3(a, b); let c_: u128 = unsafe { mem::transmute(__umodti3(a, b)) };
assert_eq!(((a, b), c), ((a, b), c_)); assert_eq!(((a, b), c), ((a, b), c_));
} }
} }