Added f64 spectest

This commit is contained in:
Syrus Akbary
2018-10-24 01:22:16 +02:00
parent e8e7111e3f
commit f6a5bfaeee
5 changed files with 25116 additions and 3 deletions

2518
spectests/f64_.wast Normal file

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@ static ENV_VAR: &str = "WASM_GENERATE_SPECTESTS";
static BANNER: &str = "// Rust test file autogenerated with cargo build (src/build_spectests.rs). static BANNER: &str = "// Rust test file autogenerated with cargo build (src/build_spectests.rs).
// Please do NOT modify it by hand, as it will be reseted on next build.\n"; // Please do NOT modify it by hand, as it will be reseted on next build.\n";
const TESTS: [&str; 18] = [ const TESTS: [&str; 19] = [
"spectests/block.wast", "spectests/block.wast",
"spectests/br.wast", "spectests/br.wast",
"spectests/br_if.wast", "spectests/br_if.wast",
@ -27,6 +27,7 @@ const TESTS: [&str; 18] = [
"spectests/data.wast", "spectests/data.wast",
"spectests/exports.wast", "spectests/exports.wast",
"spectests/f32_.wast", "spectests/f32_.wast",
"spectests/f64_.wast",
"spectests/func_ptrs.wast", "spectests/func_ptrs.wast",
"spectests/i32_.wast", "spectests/i32_.wast",
"spectests/i64_.wast", "spectests/i64_.wast",
@ -57,7 +58,14 @@ fn wabt2rust_value(v: &Value) -> String {
_ => format!("{:?} as f32", v), _ => format!("{:?} as f32", v),
} }
}, },
Value::F64(v) => format!("{:?} as f64", v), Value::F64(v) => {
match *v {
std::f64::INFINITY => "std::f64::INFINITY".to_string(),
std::f64::NEG_INFINITY => "std::f64::NEG_INFINITY".to_string(),
std::f64::NAN => "std::f64::NAN".to_string(),
_ => format!("{:?} as f64", v),
}
}
} }
} }

22556
src/spectests/f64_.rs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -14,6 +14,7 @@ mod const_;
mod data; mod data;
mod exports; mod exports;
mod f32_; mod f32_;
mod f64_;
mod func_ptrs; mod func_ptrs;
mod i32_; mod i32_;
mod i64_; mod i64_;

View File

@ -242,6 +242,18 @@ impl Instance {
RelocationType::LibCall(LibCall::NearestF32) => { RelocationType::LibCall(LibCall::NearestF32) => {
_nearbyintf32 as isize _nearbyintf32 as isize
}, },
RelocationType::LibCall(LibCall::CeilF64) => {
_ceilf64 as isize
},
RelocationType::LibCall(LibCall::FloorF64) => {
_floorf64 as isize
},
RelocationType::LibCall(LibCall::TruncF64) => {
_truncf64 as isize
},
RelocationType::LibCall(LibCall::NearestF64) => {
_nearbyintf64 as isize
},
_ => unimplemented!() _ => unimplemented!()
// RelocationType::Intrinsic(name) => { // RelocationType::Intrinsic(name) => {
// get_abi_intrinsic(name)? // get_abi_intrinsic(name)?
@ -649,8 +661,9 @@ extern "C" fn current_memory(memory_index: u32, vmctx: &VmCtx) -> u32 {
// Because of this bug https://github.com/rust-lang/rust/issues/34123 // Because of this bug https://github.com/rust-lang/rust/issues/34123
// We create internal functions for it // We create internal functions for it
use std::intrinsics::{ceilf32, floorf32, truncf32, nearbyintf32}; use std::intrinsics::{ceilf32, floorf32, truncf32, nearbyintf32, ceilf64, floorf64, truncf64, nearbyintf64};
// F32
unsafe extern fn _ceilf32(x: f32) -> f32 { unsafe extern fn _ceilf32(x: f32) -> f32 {
ceilf32(x) ceilf32(x)
} }
@ -666,3 +679,20 @@ unsafe extern fn _truncf32(x: f32) -> f32 {
unsafe extern fn _nearbyintf32(x: f32) -> f32 { unsafe extern fn _nearbyintf32(x: f32) -> f32 {
nearbyintf32(x) nearbyintf32(x)
} }
// F64
unsafe extern fn _ceilf64(x: f64) -> f64 {
ceilf64(x)
}
unsafe extern fn _floorf64(x: f64) -> f64 {
floorf64(x)
}
unsafe extern fn _truncf64(x: f64) -> f64 {
truncf64(x)
}
unsafe extern fn _nearbyintf64(x: f64) -> f64 {
nearbyintf64(x)
}