Added f32 spectest

This commit is contained in:
Syrus Akbary
2018-10-24 01:15:20 +02:00
parent bb3e5dcfbe
commit e8e7111e3f
6 changed files with 25121 additions and 7 deletions

2518
spectests/f32_.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).
// Please do NOT modify it by hand, as it will be reseted on next build.\n";
const TESTS: [&str; 17] = [
const TESTS: [&str; 18] = [
"spectests/block.wast",
"spectests/br.wast",
"spectests/br_if.wast",
@ -26,6 +26,7 @@ const TESTS: [&str; 17] = [
"spectests/const_.wast",
"spectests/data.wast",
"spectests/exports.wast",
"spectests/f32_.wast",
"spectests/func_ptrs.wast",
"spectests/i32_.wast",
"spectests/i64_.wast",
@ -48,7 +49,14 @@ fn wabt2rust_value(v: &Value) -> String {
match v {
Value::I32(v) => format!("{:?} as i32", v),
Value::I64(v) => format!("{:?} as i64", v),
Value::F32(v) => format!("{:?} as f32", v),
Value::F32(v) => {
match *v {
std::f32::INFINITY => "std::f32::INFINITY".to_string(),
std::f32::NEG_INFINITY => "std::f32::NEG_INFINITY".to_string(),
std::f32::NAN => "std::f32::NAN".to_string(),
_ => format!("{:?} as f32", v),
}
},
Value::F64(v) => format!("{:?} as f64", v),
}
}

View File

@ -1,4 +1,4 @@
#![feature(test, libc)]
#![feature(test, libc, core_intrinsics)]
extern crate test;
#[macro_use]

22556
src/spectests/f32_.rs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,7 @@ mod call_indirect;
mod const_;
mod data;
mod exports;
mod f32_;
mod func_ptrs;
mod i32_;
mod i64_;

View File

@ -9,6 +9,7 @@
use cranelift_codegen::{binemit, isa, Context};
use cranelift_entity::EntityRef;
use cranelift_wasm::{FuncIndex, GlobalInit};
use cranelift_codegen::ir::LibCall;
use memmap::MmapMut;
use region;
use spin::RwLock;
@ -225,13 +226,21 @@ impl Instance {
},
RelocationType::CurrentMemory => {
current_memory as isize
// panic!("current memory not yet implemented");
// unimplemented!()
},
RelocationType::GrowMemory => {
grow_memory as isize
// panic!("Grow memory not yet implemented");
// unimplemented!()
},
RelocationType::LibCall(LibCall::CeilF32) => {
_ceilf32 as isize
},
RelocationType::LibCall(LibCall::FloorF32) => {
_floorf32 as isize
},
RelocationType::LibCall(LibCall::TruncF32) => {
_truncf32 as isize
},
RelocationType::LibCall(LibCall::NearestF32) => {
_nearbyintf32 as isize
},
_ => unimplemented!()
// RelocationType::Intrinsic(name) => {
@ -635,3 +644,25 @@ extern "C" fn current_memory(memory_index: u32, vmctx: &VmCtx) -> u32 {
// .current_size()
// }
}
// Because of this bug https://github.com/rust-lang/rust/issues/34123
// We create internal functions for it
use std::intrinsics::{ceilf32, floorf32, truncf32, nearbyintf32};
unsafe extern fn _ceilf32(x: f32) -> f32 {
ceilf32(x)
}
unsafe extern fn _floorf32(x: f32) -> f32 {
floorf32(x)
}
unsafe extern fn _truncf32(x: f32) -> f32 {
truncf32(x)
}
unsafe extern fn _nearbyintf32(x: f32) -> f32 {
nearbyintf32(x)
}