From ca6449626fce3db8ee403b86c84d4d34e47cde79 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 8 Aug 2019 11:33:05 -0700 Subject: [PATCH] Verify that cranelift-wasm can translate SIMD instructions To do so we must use a new version of wabt-rs that allows us to enable features (e.g. SIMD) when translating the wasmtests --- cranelift/wasm/tests/wasm_testsuite.rs | 6 ++++-- cranelift/wasmtests/simd.wat | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 cranelift/wasmtests/simd.wat diff --git a/cranelift/wasm/tests/wasm_testsuite.rs b/cranelift/wasm/tests/wasm_testsuite.rs index f521828282..6b16f69791 100644 --- a/cranelift/wasm/tests/wasm_testsuite.rs +++ b/cranelift/wasm/tests/wasm_testsuite.rs @@ -10,7 +10,7 @@ use std::io::prelude::*; use std::path::Path; use std::str::FromStr; use target_lexicon::triple; -use wabt::wat2wasm; +use wabt::{wat2wasm_with_features, Features}; #[test] fn testsuite() { @@ -61,7 +61,9 @@ fn handle_module(path: &Path, flags: &Flags, return_mode: ReturnMode) { Some("wasm") => read_file(path).expect("error reading wasm file"), Some("wat") => { let wat = read_file(path).expect("error reading wat file"); - match wat2wasm(&wat) { + let mut features = Features::new(); + features.enable_all(); + match wat2wasm_with_features(&wat, features) { Ok(wasm) => wasm, Err(e) => { panic!("error converting wat to wasm: {:?}", e); diff --git a/cranelift/wasmtests/simd.wat b/cranelift/wasmtests/simd.wat new file mode 100644 index 0000000000..99b7d5c10d --- /dev/null +++ b/cranelift/wasmtests/simd.wat @@ -0,0 +1,23 @@ +(module + (func $test_splat (result i32) + i32.const 42 + i32x4.splat + i32x4.extract_lane 0 + ) + + (func $test_insert_lane (result i32) + v128.const i64x2 0 0 + i32.const 99 + i32x4.replace_lane 1 + i32x4.extract_lane 1 + ) + + (func $test_const (result i32) + v128.const i32x4 1 2 3 4 + i32x4.extract_lane 3 + ) + + (export "test_splat" (func $test_splat)) + (export "test_insert_lane" (func $test_insert_lane)) + (export "test_const" (func $test_const)) +)