From acbface4be3214915148778c0a082ed1fcfa9188 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Thu, 20 Jun 2019 14:51:31 -0700 Subject: [PATCH 01/37] Factor out creating wasmparser::ValidatingParserConfig to its own function. --- lib/runtime-core/src/codegen.rs | 16 +++++++++++++++- lib/runtime-core/src/parse.rs | 15 ++------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/lib/runtime-core/src/codegen.rs b/lib/runtime-core/src/codegen.rs index 25f42612c60..f0fd2c93402 100644 --- a/lib/runtime-core/src/codegen.rs +++ b/lib/runtime-core/src/codegen.rs @@ -137,8 +137,22 @@ impl< } } +pub fn default_validating_parser_config() -> wasmparser::ValidatingParserConfig { + wasmparser::ValidatingParserConfig { + operator_config: wasmparser::OperatorValidatorConfig { + enable_threads: false, + enable_reference_types: false, + enable_simd: false, + enable_bulk_memory: false, + enable_multi_value: false, + }, + mutable_global_imports: false, + } +} + fn validate(bytes: &[u8]) -> CompileResult<()> { - let mut parser = wasmparser::ValidatingParser::new(bytes, None); + let mut parser = + wasmparser::ValidatingParser::new(bytes, Some(default_validating_parser_config())); loop { let state = parser.read(); match *state { diff --git a/lib/runtime-core/src/parse.rs b/lib/runtime-core/src/parse.rs index 93f8d24d419..9f911f036c0 100644 --- a/lib/runtime-core/src/parse.rs +++ b/lib/runtime-core/src/parse.rs @@ -85,19 +85,8 @@ pub fn read_module< custom_sections: HashMap::new(), })); - let mut parser = wasmparser::ValidatingParser::new( - wasm, - Some(wasmparser::ValidatingParserConfig { - operator_config: wasmparser::OperatorValidatorConfig { - enable_threads: false, - enable_reference_types: false, - enable_simd: false, - enable_bulk_memory: false, - enable_multi_value: false, - }, - mutable_global_imports: false, - }), - ); + let mut parser = + wasmparser::ValidatingParser::new(wasm, Some(default_validating_parser_config())); let mut namespace_builder = Some(StringTableBuilder::new()); let mut name_builder = Some(StringTableBuilder::new()); From 9579b07a54ae0b13a6629ec0fff2add479293abf Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 2 Jul 2019 12:00:22 -0700 Subject: [PATCH 02/37] Enable SIMD support in wasmparser. --- lib/runtime-core/src/codegen.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/runtime-core/src/codegen.rs b/lib/runtime-core/src/codegen.rs index f0fd2c93402..47207fafd34 100644 --- a/lib/runtime-core/src/codegen.rs +++ b/lib/runtime-core/src/codegen.rs @@ -142,7 +142,7 @@ pub fn default_validating_parser_config() -> wasmparser::ValidatingParserConfig operator_config: wasmparser::OperatorValidatorConfig { enable_threads: false, enable_reference_types: false, - enable_simd: false, + enable_simd: true, enable_bulk_memory: false, enable_multi_value: false, }, From b8d2aee80f177281d7c1d9f893715efdd5b58086 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Wed, 10 Jul 2019 10:55:10 -0700 Subject: [PATCH 03/37] Update wabt to 0.8 release. --- Cargo.toml | 4 ++-- lib/llvm-backend/Cargo.toml | 2 +- lib/middleware-common/Cargo.toml | 2 +- lib/runtime/Cargo.toml | 2 +- lib/spectests/Cargo.toml | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 921a3c456dd..4f7c8ed6cf0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ include = [ byteorder = "1.3.1" errno = "0.2.4" structopt = "0.2.11" -wabt = "0.7.2" +wabt = "0.8.0" hashbrown = "0.1.8" wasmer-clif-backend = { path = "lib/clif-backend" } wasmer-singlepass-backend = { path = "lib/singlepass-backend", optional = true } @@ -61,7 +61,7 @@ members = [ ] [build-dependencies] -wabt = "0.7.2" +wabt = "0.8.0" glob = "0.2.11" rustc_version = "0.2.3" diff --git a/lib/llvm-backend/Cargo.toml b/lib/llvm-backend/Cargo.toml index 3456daeb8cc..d9aae1ff389 100644 --- a/lib/llvm-backend/Cargo.toml +++ b/lib/llvm-backend/Cargo.toml @@ -23,7 +23,7 @@ semver = "0.9" rustc_version = "0.2.3" [dev-dependencies] -wabt = "0.7.4" +wabt = "0.8.0" [features] debug = ["wasmer-runtime-core/debug"] diff --git a/lib/middleware-common/Cargo.toml b/lib/middleware-common/Cargo.toml index b365e023b8b..9e16c223536 100644 --- a/lib/middleware-common/Cargo.toml +++ b/lib/middleware-common/Cargo.toml @@ -14,7 +14,7 @@ wasmer-llvm-backend = { path = "../llvm-backend", version = "0.5.4", optional = wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.4", optional = true } [dev-dependencies] -wabt = "0.7.4" +wabt = "0.8.0" criterion = "0.2" [features] diff --git a/lib/runtime/Cargo.toml b/lib/runtime/Cargo.toml index 52951437e08..030467e3006 100644 --- a/lib/runtime/Cargo.toml +++ b/lib/runtime/Cargo.toml @@ -25,7 +25,7 @@ optional = true [dev-dependencies] tempfile = "3.0.7" criterion = "0.2" -wabt = "0.7.4" +wabt = "0.8.0" [target.'cfg(not(windows))'.dependencies.wasmer-llvm-backend] path = "../llvm-backend" diff --git a/lib/spectests/Cargo.toml b/lib/spectests/Cargo.toml index ea17aa8a9b8..f89e739d7eb 100644 --- a/lib/spectests/Cargo.toml +++ b/lib/spectests/Cargo.toml @@ -15,10 +15,10 @@ wasmer-llvm-backend = { path = "../llvm-backend", version = "0.5.4", optional = wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.4", optional = true } [build-dependencies] -wabt = "0.7.2" +wabt = "0.8.0" [dev-dependencies] -wabt = "0.7.2" +wabt = "0.8.0" [features] default = ["fast-tests"] From 51556e74da41a8e21901fa9d4e39b30a7e621a3a Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 2 Jul 2019 14:32:41 -0700 Subject: [PATCH 04/37] Turn on parsing of SIMD in .wat files. --- src/bin/wasmer.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index d1e46fbd66c..09de195e06e 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -310,7 +310,9 @@ fn execute_wasm(options: &Run) -> Result<(), String> { }; if !utils::is_wasm_binary(&wasm_binary) { - wasm_binary = wabt::wat2wasm(wasm_binary) + let mut features = wabt::Features::new(); + features.enable_simd(); + wasm_binary = wabt::wat2wasm_with_features(wasm_binary, features) .map_err(|e| format!("Can't convert from wast to wasm: {:?}", e))?; } From ea8392454758e5d757ae524ce560072763acd96c Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Mon, 8 Jul 2019 14:10:37 -0700 Subject: [PATCH 05/37] Update to LLVM 8.0. --- lib/llvm-backend/Cargo.toml | 2 +- lib/llvm-backend/build.rs | 2 +- lib/llvm-backend/cpp/object_loader.cpp | 17 ++++++----------- lib/llvm-backend/src/code.rs | 4 ++-- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/lib/llvm-backend/Cargo.toml b/lib/llvm-backend/Cargo.toml index d9aae1ff389..fbc78c73ed1 100644 --- a/lib/llvm-backend/Cargo.toml +++ b/lib/llvm-backend/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] wasmer-runtime-core = { path = "../runtime-core", version = "0.5.4" } -inkwell = { git = "https://github.com/wasmerio/inkwell", branch = "llvm7-0" } +inkwell = { git = "https://github.com/lumen/inkwell", rev = "64921e418c3e8f4b32f9beed56ebd5aac4e677c7", features = ["llvm8-0"] } wasmparser = "0.32.1" hashbrown = "0.1.8" smallvec = "0.6.8" diff --git a/lib/llvm-backend/build.rs b/lib/llvm-backend/build.rs index ab59748b147..6c8117dd9e3 100644 --- a/lib/llvm-backend/build.rs +++ b/lib/llvm-backend/build.rs @@ -41,7 +41,7 @@ lazy_static! { // Did the user give us a binary path to use? If yes, try // to use that and fail if it doesn't work. - let binary_prefix_var = "LLVM_SYS_70_PREFIX"; + let binary_prefix_var = "LLVM_SYS_80_PREFIX"; let path = if let Some(path) = env::var_os(&binary_prefix_var) { Some(path.to_str().unwrap().to_owned()) diff --git a/lib/llvm-backend/cpp/object_loader.cpp b/lib/llvm-backend/cpp/object_loader.cpp index 28bea635494..3f2078c84f2 100644 --- a/lib/llvm-backend/cpp/object_loader.cpp +++ b/lib/llvm-backend/cpp/object_loader.cpp @@ -139,24 +139,19 @@ struct SymbolLookup : llvm::JITSymbolResolver { public: SymbolLookup(callbacks_t callbacks) : callbacks(callbacks) {} - virtual llvm::Expected lookup(const LookupSet& symbols) override { + void lookup(const LookupSet& symbols, OnResolvedFunction OnResolved) { LookupResult result; for (auto symbol : symbols) { result.emplace(symbol, symbol_lookup(symbol)); } - return result; + OnResolved(result); } - virtual llvm::Expected lookupFlags(const LookupSet& symbols) override { - LookupFlagsResult result; - - for (auto symbol : symbols) { - result.emplace(symbol, symbol_lookup(symbol).getFlags()); - } - - return result; + llvm::Expected getResponsibilitySet(const LookupSet &Symbols) { + const std::set empty; + return empty; } private: @@ -201,4 +196,4 @@ WasmModule::WasmModule( void* WasmModule::get_func(llvm::StringRef name) const { auto symbol = runtime_dyld->getSymbol(name); return (void*)symbol.getAddress(); -} \ No newline at end of file +} diff --git a/lib/llvm-backend/src/code.rs b/lib/llvm-backend/src/code.rs index 0359b3dd8b9..1a1844e4dd5 100644 --- a/lib/llvm-backend/src/code.rs +++ b/lib/llvm-backend/src/code.rs @@ -2603,7 +2603,7 @@ impl ModuleCodeGenerator self.intrinsics.as_ref().unwrap(), ); - let pass_manager = PassManager::create_for_module(); + let pass_manager = PassManager::create(()); if cfg!(test) { pass_manager.add_verifier_pass(); } @@ -2614,7 +2614,7 @@ impl ModuleCodeGenerator pass_manager.add_merged_load_store_motion_pass(); pass_manager.add_new_gvn_pass(); pass_manager.add_aggressive_dce_pass(); - pass_manager.run_on_module(&self.module); + pass_manager.run_on(&self.module); // self.module.print_to_stderr(); From 0a1bdd449ee895e27c7f8bab33309c458e64d716 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 2 Jul 2019 14:40:53 -0700 Subject: [PATCH 06/37] Update to @llvm.minimum/@llvm.maximum which requires LLVM 8. The @llvm.minnum/@llvm.maxnum intrinsics don't produce correct (for wasm) outputs in all cases. --- lib/llvm-backend/src/intrinsics.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/llvm-backend/src/intrinsics.rs b/lib/llvm-backend/src/intrinsics.rs index c3a95f7751a..fa093cb3584 100644 --- a/lib/llvm-backend/src/intrinsics.rs +++ b/lib/llvm-backend/src/intrinsics.rs @@ -267,11 +267,11 @@ impl Intrinsics { sqrt_f32: module.add_function("llvm.sqrt.f32", ret_f32_take_f32, None), sqrt_f64: module.add_function("llvm.sqrt.f64", ret_f64_take_f64, None), - minimum_f32: module.add_function("llvm.minnum.f32", ret_f32_take_f32_f32, None), - minimum_f64: module.add_function("llvm.minnum.f64", ret_f64_take_f64_f64, None), + minimum_f32: module.add_function("llvm.minimum.f32", ret_f32_take_f32_f32, None), + minimum_f64: module.add_function("llvm.minimum.f64", ret_f64_take_f64_f64, None), - maximum_f32: module.add_function("llvm.maxnum.f32", ret_f32_take_f32_f32, None), - maximum_f64: module.add_function("llvm.maxnum.f64", ret_f64_take_f64_f64, None), + maximum_f32: module.add_function("llvm.maximum.f32", ret_f32_take_f32_f32, None), + maximum_f64: module.add_function("llvm.maximum.f64", ret_f64_take_f64_f64, None), ceil_f32: module.add_function("llvm.ceil.f32", ret_f32_take_f32, None), ceil_f64: module.add_function("llvm.ceil.f64", ret_f64_take_f64, None), From df5c12cbe1a83557800178f9d2c9aa90bd23166c Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 2 Jul 2019 14:55:10 -0700 Subject: [PATCH 07/37] Add V128 to wasmer runtime. Unimplemented in clif-backend. Other backends don't build. --- lib/clif-backend/src/module.rs | 3 +++ lib/clif-backend/src/trampoline.rs | 1 + lib/runtime-core/src/global.rs | 3 +++ lib/runtime-core/src/instance.rs | 2 ++ lib/runtime-core/src/parse.rs | 8 ++------ lib/runtime-core/src/types.rs | 12 ++++++++++++ 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/lib/clif-backend/src/module.rs b/lib/clif-backend/src/module.rs index 14adb154700..91e14bf7ced 100644 --- a/lib/clif-backend/src/module.rs +++ b/lib/clif-backend/src/module.rs @@ -107,6 +107,7 @@ impl From> for Type { ir::types::I64 => Type::I64, ir::types::F32 => Type::F32, ir::types::F64 => Type::F64, + ir::types::I32X4 => Type::V128, _ => panic!("unsupported wasm type"), } } @@ -119,6 +120,7 @@ impl From> for ir::Type { Type::I64 => ir::types::I64, Type::F32 => ir::types::F32, Type::F64 => ir::types::F64, + Type::V128 => ir::types::I32X4, } } } @@ -130,6 +132,7 @@ impl From> for ir::AbiParam { Type::I64 => ir::AbiParam::new(ir::types::I64), Type::F32 => ir::AbiParam::new(ir::types::F32), Type::F64 => ir::AbiParam::new(ir::types::F64), + Type::V128 => ir::AbiParam::new(ir::types::I32X4), } } } diff --git a/lib/clif-backend/src/trampoline.rs b/lib/clif-backend/src/trampoline.rs index 09ee4cf74cc..f75ef5ad566 100644 --- a/lib/clif-backend/src/trampoline.rs +++ b/lib/clif-backend/src/trampoline.rs @@ -204,6 +204,7 @@ fn wasm_ty_to_clif(ty: Type) -> ir::types::Type { Type::I64 => ir::types::I64, Type::F32 => ir::types::F32, Type::F64 => ir::types::F64, + Type::V128 => ir::types::I32X4, } } diff --git a/lib/runtime-core/src/global.rs b/lib/runtime-core/src/global.rs index ac485cc4f0c..16a75d6a70a 100644 --- a/lib/runtime-core/src/global.rs +++ b/lib/runtime-core/src/global.rs @@ -50,6 +50,7 @@ impl Global { Value::I64(x) => x as u64, Value::F32(x) => x.to_bits() as u64, Value::F64(x) => x.to_bits(), + Value::V128(_) => unimplemented!(), }, }; @@ -79,6 +80,7 @@ impl Global { Value::I64(x) => x as u64, Value::F32(x) => x.to_bits() as u64, Value::F64(x) => x.to_bits(), + Value::V128(_) => unimplemented!(), }, }; *self.storage.borrow_mut() = local_global; @@ -99,6 +101,7 @@ impl Global { Type::I64 => Value::I64(data as i64), Type::F32 => Value::F32(f32::from_bits(data as u32)), Type::F64 => Value::F64(f64::from_bits(data)), + Type::V128 => unimplemented!(), } } diff --git a/lib/runtime-core/src/instance.rs b/lib/runtime-core/src/instance.rs index cf09b48e75d..d2a6c04e48a 100644 --- a/lib/runtime-core/src/instance.rs +++ b/lib/runtime-core/src/instance.rs @@ -551,6 +551,7 @@ fn call_func_with_index( Value::I64(i) => *i as u64, Value::F32(f) => f.to_bits() as u64, Value::F64(f) => f.to_bits(), + Value::V128(_) => unimplemented!(), }) .collect(); @@ -595,6 +596,7 @@ fn call_func_with_index( Type::I64 => Value::I64(raw as i64), Type::F32 => Value::F32(f32::from_bits(raw as u32)), Type::F64 => Value::F64(f64::from_bits(raw)), + Type::V128 => unimplemented!(), }; match signature.returns() { diff --git a/lib/runtime-core/src/parse.rs b/lib/runtime-core/src/parse.rs index 9f911f036c0..0f365ac2e47 100644 --- a/lib/runtime-core/src/parse.rs +++ b/lib/runtime-core/src/parse.rs @@ -380,12 +380,7 @@ pub fn wp_type_to_type(ty: WpType) -> Result { WpType::I64 => Type::I64, WpType::F32 => Type::F32, WpType::F64 => Type::F64, - WpType::V128 => { - return Err(BinaryReaderError { - message: "the wasmer llvm backend does not yet support the simd extension", - offset: -1isize as usize, - }); - } + WpType::V128 => Type::V128, _ => panic!("broken invariant, invalid type"), }) } @@ -396,6 +391,7 @@ pub fn type_to_wp_type(ty: Type) -> WpType { Type::I64 => WpType::I64, Type::F32 => WpType::F32, Type::F64 => WpType::F64, + Type::V128 => WpType::V128, } } diff --git a/lib/runtime-core/src/types.rs b/lib/runtime-core/src/types.rs index 0c8f08d1a8c..ac3df034322 100644 --- a/lib/runtime-core/src/types.rs +++ b/lib/runtime-core/src/types.rs @@ -12,6 +12,8 @@ pub enum Type { F32, /// The `f64` type. F64, + /// The `v128` type. + V128, } impl std::fmt::Display for Type { @@ -34,6 +36,8 @@ pub enum Value { F32(f32), /// The `f64` type. F64(f64), + /// The `v128` type. + V128(u128), } impl Value { @@ -43,6 +47,7 @@ impl Value { Value::I64(_) => Type::I64, Value::F32(_) => Type::F32, Value::F64(_) => Type::F64, + Value::V128(_) => Type::V128, } } @@ -52,6 +57,7 @@ impl Value { Value::I64(x) => x as u64, Value::F32(x) => f32::to_bits(x) as u64, Value::F64(x) => f64::to_bits(x), + Value::V128(_) => unimplemented!(), } } } @@ -80,6 +86,12 @@ impl From for Value { } } +impl From for Value { + fn from(v: u128) -> Self { + Value::V128(v) + } +} + pub unsafe trait NativeWasmType: Copy + Into where Self: Sized, From 77afcea9dce89e26aa663cc86adf5d82a36f4fb7 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 2 Jul 2019 15:01:50 -0700 Subject: [PATCH 08/37] Add V128 stubs to allow LLVM backend to build again. --- lib/llvm-backend/src/code.rs | 2 ++ lib/llvm-backend/src/intrinsics.rs | 10 ++++++++++ lib/llvm-backend/src/trampolines.rs | 1 + 3 files changed, 13 insertions(+) diff --git a/lib/llvm-backend/src/code.rs b/lib/llvm-backend/src/code.rs index 1a1844e4dd5..31285366dad 100644 --- a/lib/llvm-backend/src/code.rs +++ b/lib/llvm-backend/src/code.rs @@ -57,6 +57,7 @@ fn type_to_llvm(intrinsics: &Intrinsics, ty: Type) -> BasicTypeEnum { Type::I64 => intrinsics.i64_ty.as_basic_type_enum(), Type::F32 => intrinsics.f32_ty.as_basic_type_enum(), Type::F64 => intrinsics.f64_ty.as_basic_type_enum(), + Type::V128 => intrinsics.i128_ty.as_basic_type_enum(), } } @@ -425,6 +426,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { Type::I64 => intrinsics.i64_zero.as_basic_value_enum(), Type::F32 => intrinsics.f32_zero.as_basic_value_enum(), Type::F64 => intrinsics.f64_zero.as_basic_value_enum(), + Type::V128 => intrinsics.i128_zero.as_basic_value_enum(), }; let builder = self.builder.as_ref().unwrap(); diff --git a/lib/llvm-backend/src/intrinsics.rs b/lib/llvm-backend/src/intrinsics.rs index fa093cb3584..c866b8207d5 100644 --- a/lib/llvm-backend/src/intrinsics.rs +++ b/lib/llvm-backend/src/intrinsics.rs @@ -25,6 +25,7 @@ fn type_to_llvm_ptr(intrinsics: &Intrinsics, ty: Type) -> PointerType { Type::I64 => intrinsics.i64_ptr_ty, Type::F32 => intrinsics.f32_ptr_ty, Type::F64 => intrinsics.f64_ptr_ty, + Type::V128 => intrinsics.i128_ptr_ty, } } @@ -74,6 +75,7 @@ pub struct Intrinsics { pub i16_ty: IntType, pub i32_ty: IntType, pub i64_ty: IntType, + pub i128_ty: IntType, pub f32_ty: FloatType, pub f64_ty: FloatType, @@ -81,6 +83,7 @@ pub struct Intrinsics { pub i16_ptr_ty: PointerType, pub i32_ptr_ty: PointerType, pub i64_ptr_ty: PointerType, + pub i128_ptr_ty: PointerType, pub f32_ptr_ty: PointerType, pub f64_ptr_ty: PointerType, @@ -89,6 +92,7 @@ pub struct Intrinsics { pub i1_zero: IntValue, pub i32_zero: IntValue, pub i64_zero: IntValue, + pub i128_zero: IntValue, pub f32_zero: FloatValue, pub f64_zero: FloatValue, @@ -126,6 +130,7 @@ impl Intrinsics { let i16_ty = context.i16_type(); let i32_ty = context.i32_type(); let i64_ty = context.i64_type(); + let i128_ty = context.i128_type(); let f32_ty = context.f32_type(); let f64_ty = context.f64_type(); @@ -133,12 +138,14 @@ impl Intrinsics { let i16_ptr_ty = i16_ty.ptr_type(AddressSpace::Generic); let i32_ptr_ty = i32_ty.ptr_type(AddressSpace::Generic); let i64_ptr_ty = i64_ty.ptr_type(AddressSpace::Generic); + let i128_ptr_ty = i128_ty.ptr_type(AddressSpace::Generic); let f32_ptr_ty = f32_ty.ptr_type(AddressSpace::Generic); let f64_ptr_ty = f64_ty.ptr_type(AddressSpace::Generic); let i1_zero = i1_ty.const_int(0, false); let i32_zero = i32_ty.const_int(0, false); let i64_zero = i64_ty.const_int(0, false); + let i128_zero = i128_ty.const_int(0, false); let f32_zero = f32_ty.const_float(0.0); let f64_zero = f64_ty.const_float(0.0); @@ -300,6 +307,7 @@ impl Intrinsics { i16_ty, i32_ty, i64_ty, + i128_ty, f32_ty, f64_ty, @@ -307,6 +315,7 @@ impl Intrinsics { i16_ptr_ty, i32_ptr_ty, i64_ptr_ty, + i128_ptr_ty, f32_ptr_ty, f64_ptr_ty, @@ -315,6 +324,7 @@ impl Intrinsics { i1_zero, i32_zero, i64_zero, + i128_zero, f32_zero, f64_zero, diff --git a/lib/llvm-backend/src/trampolines.rs b/lib/llvm-backend/src/trampolines.rs index 23677618b41..95a99223c9a 100644 --- a/lib/llvm-backend/src/trampolines.rs +++ b/lib/llvm-backend/src/trampolines.rs @@ -72,6 +72,7 @@ fn generate_trampoline( Type::I64 => intrinsics.i64_ptr_ty, Type::F32 => intrinsics.f32_ptr_ty, Type::F64 => intrinsics.f64_ptr_ty, + Type::V128 => intrinsics.i128_ptr_ty, }; let mut args_vec = Vec::with_capacity(func_sig.params().len() + 1); From 3ba8100e9880278dc468d530e796c3cf2539ca9a Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 2 Jul 2019 15:05:34 -0700 Subject: [PATCH 09/37] Add V128 stubs to allow singlepass backend to build again. --- lib/singlepass-backend/src/codegen_x64.rs | 1 + lib/singlepass-backend/src/emitter_x64.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/singlepass-backend/src/codegen_x64.rs b/lib/singlepass-backend/src/codegen_x64.rs index dde93b57bec..ce6e40a80c0 100644 --- a/lib/singlepass-backend/src/codegen_x64.rs +++ b/lib/singlepass-backend/src/codegen_x64.rs @@ -4885,6 +4885,7 @@ fn type_to_wp_type(ty: Type) -> WpType { Type::I64 => WpType::I64, Type::F32 => WpType::F32, Type::F64 => WpType::F64, + Type::V128 => WpType::V128, } } diff --git a/lib/singlepass-backend/src/emitter_x64.rs b/lib/singlepass-backend/src/emitter_x64.rs index 0fc7795ff20..3476bd289a7 100644 --- a/lib/singlepass-backend/src/emitter_x64.rs +++ b/lib/singlepass-backend/src/emitter_x64.rs @@ -6,6 +6,7 @@ pub enum Location { Imm8(u8), Imm32(u32), Imm64(u64), + Imm128(u128), GPR(GPR), XMM(XMM), Memory(GPR, i32), From fdc13563b825c7bb92dd3d6f4d59e93601b2833d Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 2 Jul 2019 15:50:33 -0700 Subject: [PATCH 10/37] Initial implementation of SIMD in the LLVM backend. --- lib/llvm-backend/src/code.rs | 1956 +++++++++++++++++++++++++++- lib/llvm-backend/src/intrinsics.rs | 133 +- lib/llvm-backend/src/read_info.rs | 7 +- 3 files changed, 2030 insertions(+), 66 deletions(-) diff --git a/lib/llvm-backend/src/code.rs b/lib/llvm-backend/src/code.rs index 31285366dad..ee70850691d 100644 --- a/lib/llvm-backend/src/code.rs +++ b/lib/llvm-backend/src/code.rs @@ -3,8 +3,11 @@ use inkwell::{ context::Context, module::{Linkage, Module}, passes::PassManager, - types::{BasicType, BasicTypeEnum, FunctionType, PointerType}, - values::{BasicValue, FloatValue, FunctionValue, IntValue, PhiValue, PointerValue}, + types::{BasicType, BasicTypeEnum, FunctionType, PointerType, VectorType}, + values::{ + BasicValue, BasicValueEnum, FloatValue, FunctionValue, IntValue, PhiValue, PointerValue, + VectorValue, + }, AddressSpace, FloatPredicate, IntPredicate, }; use smallvec::SmallVec; @@ -61,6 +64,128 @@ fn type_to_llvm(intrinsics: &Intrinsics, ty: Type) -> BasicTypeEnum { } } +// Create a vector where each lane contains the same value. +fn splat_vector( + builder: &Builder, + intrinsics: &Intrinsics, + value: BasicValueEnum, + vec_ty: VectorType, + name: &str, +) -> VectorValue { + // Use insert_element to insert the element into an undef vector, then use + // shuffle vector to copy that lane to all lanes. + builder.build_shuffle_vector( + builder + .build_insert_element(vec_ty.get_undef(), value, intrinsics.i32_zero, ""), + vec_ty.get_undef(), + intrinsics.i32_ty.vec_type(vec_ty.get_size()).const_zero(), + name, + ) +} + +// Convert floating point vector to integer and saturate when out of range. +// TODO: generalize to non-vectors using FloatMathType, IntMathType, etc. for +// https://github.com/WebAssembly/nontrapping-float-to-int-conversions/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md +fn trunc_sat( + builder: &Builder, + intrinsics: &Intrinsics, + fvec_ty: VectorType, + ivec_ty: VectorType, + lower_bound: u64, // Exclusive (lowest representable value) + upper_bound: u64, // Exclusive (greatest representable value) + value: IntValue, + name: &str, +) -> IntValue { + // a) Compare vector with itself to identify NaN lanes. + // b) Compare vector with splat of inttofp(upper_bound) to identify + // lanes that need to saturate to max. + // c) Compare vector with splat of inttofp(lower_bound) to identify + // lanes that need to saturate to min. + // d) Use vector select (not shuffle) to pick from either the + // splat vector or the input vector depending on whether the + // comparison indicates that we have an unrepresentable value. + // e) Now that the value is safe, fpto[su]i it. + + let is_signed = lower_bound != 0; + let lower_bound = if is_signed { + builder.build_signed_int_to_float( + ivec_ty + .get_element_type() + .into_int_type() + .const_int(lower_bound, is_signed), + fvec_ty.get_element_type().into_float_type(), + "", + ) + } else { + builder.build_unsigned_int_to_float( + ivec_ty + .get_element_type() + .into_int_type() + .const_int(lower_bound, is_signed), + fvec_ty.get_element_type().into_float_type(), + "", + ) + }; + let upper_bound = if is_signed { + builder.build_signed_int_to_float( + ivec_ty + .get_element_type() + .into_int_type() + .const_int(upper_bound, is_signed), + fvec_ty.get_element_type().into_float_type(), + "", + ) + } else { + builder.build_unsigned_int_to_float( + ivec_ty + .get_element_type() + .into_int_type() + .const_int(upper_bound, is_signed), + fvec_ty.get_element_type().into_float_type(), + "", + ) + }; + + let value = builder + .build_bitcast(value, fvec_ty, "") + .into_vector_value(); + let zero = fvec_ty.const_zero(); + let lower_bound = splat_vector( + builder, + intrinsics, + lower_bound.as_basic_value_enum(), + fvec_ty, + "", + ); + let upper_bound = splat_vector( + builder, + intrinsics, + upper_bound.as_basic_value_enum(), + fvec_ty, + "", + ); + let nan_cmp = builder.build_float_compare(FloatPredicate::UNE, value, value, ""); + let underflow_cmp = builder.build_float_compare(FloatPredicate::UGT, value, upper_bound, ""); + let overflow_cmp = builder.build_float_compare(FloatPredicate::ULT, value, lower_bound, ""); + let value = builder + .build_select(nan_cmp, zero, value, "") + .into_vector_value(); + let value = builder + .build_select(underflow_cmp, lower_bound, value, "") + .into_vector_value(); + let value = builder + .build_select(overflow_cmp, upper_bound, value, "") + .into_vector_value(); + let res = if is_signed { + builder.build_float_to_signed_int(value, ivec_ty, name) + } else { + builder.build_float_to_unsigned_int(value, ivec_ty, name) + }; + builder + .build_bitcast(res, intrinsics.i128_ty, "") + .into_int_value() +} + fn trap_if_not_representatable_as_int( builder: &Builder, intrinsics: &Intrinsics, @@ -859,6 +984,90 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let f = builder.build_bitcast(bits, intrinsics.f64_ty, "f"); state.push1(f); } + Operator::V128Const { value } => { + let mut hi: [u8; 8] = Default::default(); + let mut lo: [u8; 8] = Default::default(); + hi.copy_from_slice(&value.bytes()[0..8]); + lo.copy_from_slice(&value.bytes()[8..16]); + let packed = [u64::from_le_bytes(hi), u64::from_le_bytes(lo)]; + let i = intrinsics.i128_ty.const_int_arbitrary_precision(&packed); + state.push1(i); + } + + Operator::I8x16Splat => { + let v = state.pop1()?.into_int_value(); + let v = builder.build_int_truncate(v, intrinsics.i8_ty, ""); + let res = splat_vector( + builder, + intrinsics, + v.as_basic_value_enum(), + intrinsics.i8x16_ty, + &state.var_name(), + ); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8Splat => { + let v = state.pop1()?.into_int_value(); + let v = builder.build_int_truncate(v, intrinsics.i16_ty, ""); + let res = splat_vector( + builder, + intrinsics, + v.as_basic_value_enum(), + intrinsics.i16x8_ty, + &state.var_name(), + ); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32x4Splat => { + let v = state.pop1()?; + let res = splat_vector( + builder, + intrinsics, + v, + intrinsics.i32x4_ty, + &state.var_name(), + ); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I64x2Splat => { + let v = state.pop1()?; + let res = splat_vector( + builder, + intrinsics, + v, + intrinsics.i64x2_ty, + &state.var_name(), + ); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F32x4Splat => { + let v = state.pop1()?; + let res = splat_vector( + builder, + intrinsics, + v, + intrinsics.f32x4_ty, + &state.var_name(), + ); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F64x2Splat => { + let v = state.pop1()?; + let res = splat_vector( + builder, + intrinsics, + v, + intrinsics.f64x2_ty, + &state.var_name(), + ); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } // Operate on locals. Operator::GetLocal { local_index } => { @@ -1142,18 +1351,262 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_int_add(v1, v2, &state.var_name()); state.push1(res); } + Operator::I8x16Add => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i8x16_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i8x16_ty, "") + .into_vector_value(); + let res = builder.build_int_add(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8Add => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i16x8_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i16x8_ty, "") + .into_vector_value(); + let res = builder.build_int_add(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32x4Add => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i32x4_ty, "") + .into_vector_value(); + let res = builder.build_int_add(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I64x2Add => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let v1 = builder + .build_bitcast(v1, intrinsics.i64x2_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i64x2_ty, "") + .into_vector_value(); + let res = builder.build_int_add(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I8x16AddSaturateS => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let v1 = builder.build_bitcast(v1, intrinsics.i8x16_ty, ""); + let v2 = builder.build_bitcast(v2, intrinsics.i8x16_ty, ""); + let res = builder + .build_call(intrinsics.sadd_sat_i8x16, &[v1, v2], "") + .try_as_basic_value() + .left() + .unwrap(); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8AddSaturateS => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let v1 = builder.build_bitcast(v1, intrinsics.i16x8_ty, ""); + let v2 = builder.build_bitcast(v2, intrinsics.i16x8_ty, ""); + let res = builder + .build_call(intrinsics.sadd_sat_i16x8, &[v1, v2], "") + .try_as_basic_value() + .left() + .unwrap(); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I8x16AddSaturateU => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let v1 = builder.build_bitcast(v1, intrinsics.i8x16_ty, ""); + let v2 = builder.build_bitcast(v2, intrinsics.i8x16_ty, ""); + let res = builder + .build_call(intrinsics.uadd_sat_i8x16, &[v1, v2], "") + .try_as_basic_value() + .left() + .unwrap(); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8AddSaturateU => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let v1 = builder.build_bitcast(v1, intrinsics.i16x8_ty, ""); + let v2 = builder.build_bitcast(v2, intrinsics.i16x8_ty, ""); + let res = builder + .build_call(intrinsics.uadd_sat_i16x8, &[v1, v2], "") + .try_as_basic_value() + .left() + .unwrap(); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::I32Sub | Operator::I64Sub => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); let res = builder.build_int_sub(v1, v2, &state.var_name()); state.push1(res); } + Operator::I8x16Sub => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let v1 = builder + .build_bitcast(v1, intrinsics.i8x16_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i8x16_ty, "") + .into_vector_value(); + let res = builder.build_int_sub(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8Sub => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let v1 = builder + .build_bitcast(v1, intrinsics.i16x8_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i16x8_ty, "") + .into_vector_value(); + let res = builder.build_int_sub(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32x4Sub => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let v1 = builder + .build_bitcast(v1, intrinsics.i32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i32x4_ty, "") + .into_vector_value(); + let res = builder.build_int_sub(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I64x2Sub => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let v1 = builder + .build_bitcast(v1, intrinsics.i64x2_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i64x2_ty, "") + .into_vector_value(); + let res = builder.build_int_sub(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I8x16SubSaturateS => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let v1 = builder.build_bitcast(v1, intrinsics.i8x16_ty, ""); + let v2 = builder.build_bitcast(v2, intrinsics.i8x16_ty, ""); + let res = builder + .build_call(intrinsics.ssub_sat_i8x16, &[v1, v2], "") + .try_as_basic_value() + .left() + .unwrap(); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8SubSaturateS => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let v1 = builder.build_bitcast(v1, intrinsics.i16x8_ty, ""); + let v2 = builder.build_bitcast(v2, intrinsics.i16x8_ty, ""); + let res = builder + .build_call(intrinsics.ssub_sat_i16x8, &[v1, v2], "") + .try_as_basic_value() + .left() + .unwrap(); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I8x16SubSaturateU => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let v1 = builder.build_bitcast(v1, intrinsics.i8x16_ty, ""); + let v2 = builder.build_bitcast(v2, intrinsics.i8x16_ty, ""); + let res = builder + .build_call(intrinsics.usub_sat_i8x16, &[v1, v2], "") + .try_as_basic_value() + .left() + .unwrap(); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8SubSaturateU => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let v1 = builder.build_bitcast(v1, intrinsics.i16x8_ty, ""); + let v2 = builder.build_bitcast(v2, intrinsics.i16x8_ty, ""); + let res = builder + .build_call(intrinsics.usub_sat_i16x8, &[v1, v2], "") + .try_as_basic_value() + .left() + .unwrap(); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::I32Mul | Operator::I64Mul => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); let res = builder.build_int_mul(v1, v2, &state.var_name()); state.push1(res); } + Operator::I8x16Mul => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let v1 = builder + .build_bitcast(v1, intrinsics.i8x16_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i8x16_ty, "") + .into_vector_value(); + let res = builder.build_int_mul(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8Mul => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let v1 = builder + .build_bitcast(v1, intrinsics.i16x8_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i16x8_ty, "") + .into_vector_value(); + let res = builder.build_int_mul(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32x4Mul => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let v1 = builder + .build_bitcast(v1, intrinsics.i32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i32x4_ty, "") + .into_vector_value(); + let res = builder.build_int_mul(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::I32DivS | Operator::I64DivS => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); @@ -1190,98 +1643,340 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_int_unsigned_rem(v1, v2, &state.var_name()); state.push1(res); } - Operator::I32And | Operator::I64And => { + Operator::I32And | Operator::I64And | Operator::V128And => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); let res = builder.build_and(v1, v2, &state.var_name()); state.push1(res); } - Operator::I32Or | Operator::I64Or => { + Operator::I32Or | Operator::I64Or | Operator::V128Or => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); let res = builder.build_or(v1, v2, &state.var_name()); state.push1(res); } - Operator::I32Xor | Operator::I64Xor => { + Operator::I32Xor | Operator::I64Xor | Operator::V128Xor => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); let res = builder.build_xor(v1, v2, &state.var_name()); state.push1(res); } + Operator::V128Bitselect => { + let (v1, v2, cond) = state.pop3()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i1x128_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i1x128_ty, "") + .into_vector_value(); + let cond = builder + .build_bitcast(cond, intrinsics.i1x128_ty, "") + .into_vector_value(); + let res = builder.build_select(cond, v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::I32Shl | Operator::I64Shl => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + // TODO: missing 'and' of v2? let res = builder.build_left_shift(v1, v2, &state.var_name()); state.push1(res); } - Operator::I32ShrS | Operator::I64ShrS => { + Operator::I8x16Shl => { let (v1, v2) = state.pop2()?; - let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); - let res = builder.build_right_shift(v1, v2, true, &state.var_name()); + let v1 = builder + .build_bitcast(v1, intrinsics.i8x16_ty, "") + .into_vector_value(); + let v2 = v2.into_int_value(); + let v2 = builder.build_and(v2, intrinsics.i32_ty.const_int(7, false), ""); + let v2 = builder.build_int_truncate(v2, intrinsics.i8_ty, ""); + let v2 = splat_vector( + builder, + intrinsics, + v2.as_basic_value_enum(), + intrinsics.i8x16_ty, + "", + ); + let res = builder.build_left_shift(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); state.push1(res); } - Operator::I32ShrU | Operator::I64ShrU => { + Operator::I16x8Shl => { let (v1, v2) = state.pop2()?; - let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); - let res = builder.build_right_shift(v1, v2, false, &state.var_name()); + let v1 = builder + .build_bitcast(v1, intrinsics.i16x8_ty, "") + .into_vector_value(); + let v2 = v2.into_int_value(); + let v2 = builder.build_and(v2, intrinsics.i32_ty.const_int(15, false), ""); + let v2 = builder.build_int_truncate(v2, intrinsics.i16_ty, ""); + let v2 = splat_vector( + builder, + intrinsics, + v2.as_basic_value_enum(), + intrinsics.i16x8_ty, + "", + ); + let res = builder.build_left_shift(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); state.push1(res); } - Operator::I32Rotl => { + Operator::I32x4Shl => { let (v1, v2) = state.pop2()?; - let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); - let lhs = builder.build_left_shift(v1, v2, &state.var_name()); - let rhs = { - let int_width = intrinsics.i32_ty.const_int(32 as u64, false); - let rhs = builder.build_int_sub(int_width, v2, &state.var_name()); - builder.build_right_shift(v1, rhs, false, &state.var_name()) - }; - let res = builder.build_or(lhs, rhs, &state.var_name()); + let v1 = builder + .build_bitcast(v1, intrinsics.i32x4_ty, "") + .into_vector_value(); + let v2 = v2.into_int_value(); + let v2 = builder.build_and(v2, intrinsics.i32_ty.const_int(31, false), ""); + let v2 = splat_vector( + builder, + intrinsics, + v2.as_basic_value_enum(), + intrinsics.i32x4_ty, + "", + ); + let res = builder.build_left_shift(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); state.push1(res); } - Operator::I64Rotl => { + Operator::I64x2Shl => { let (v1, v2) = state.pop2()?; - let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); - let lhs = builder.build_left_shift(v1, v2, &state.var_name()); - let rhs = { - let int_width = intrinsics.i64_ty.const_int(64 as u64, false); - let rhs = builder.build_int_sub(int_width, v2, &state.var_name()); - builder.build_right_shift(v1, rhs, false, &state.var_name()) - }; - let res = builder.build_or(lhs, rhs, &state.var_name()); + let v1 = builder + .build_bitcast(v1, intrinsics.i64x2_ty, "") + .into_vector_value(); + let v2 = v2.into_int_value(); + let v2 = builder.build_and(v2, intrinsics.i32_ty.const_int(63, false), ""); + let v2 = builder.build_int_z_extend(v2, intrinsics.i64_ty, ""); + let v2 = splat_vector( + builder, + intrinsics, + v2.as_basic_value_enum(), + intrinsics.i64x2_ty, + "", + ); + let res = builder.build_left_shift(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); state.push1(res); } - Operator::I32Rotr => { + Operator::I32ShrS | Operator::I64ShrS => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); - let lhs = builder.build_right_shift(v1, v2, false, &state.var_name()); - let rhs = { - let int_width = intrinsics.i32_ty.const_int(32 as u64, false); - let rhs = builder.build_int_sub(int_width, v2, &state.var_name()); - builder.build_left_shift(v1, rhs, &state.var_name()) - }; - let res = builder.build_or(lhs, rhs, &state.var_name()); + // TODO: check wasm spec, is this missing v2 mod LaneBits? + let res = builder.build_right_shift(v1, v2, true, &state.var_name()); state.push1(res); } - Operator::I64Rotr => { + Operator::I8x16ShrS => { let (v1, v2) = state.pop2()?; - let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); - let lhs = builder.build_right_shift(v1, v2, false, &state.var_name()); - let rhs = { - let int_width = intrinsics.i64_ty.const_int(64 as u64, false); - let rhs = builder.build_int_sub(int_width, v2, &state.var_name()); - builder.build_left_shift(v1, rhs, &state.var_name()) - }; - let res = builder.build_or(lhs, rhs, &state.var_name()); + let v1 = builder + .build_bitcast(v1, intrinsics.i8x16_ty, "") + .into_vector_value(); + let v2 = v2.into_int_value(); + let v2 = builder.build_and(v2, intrinsics.i32_ty.const_int(7, false), ""); + let v2 = builder.build_int_truncate(v2, intrinsics.i8_ty, ""); + let v2 = splat_vector( + builder, + intrinsics, + v2.as_basic_value_enum(), + intrinsics.i8x16_ty, + "", + ); + let res = builder.build_right_shift(v1, v2, true, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); state.push1(res); } - Operator::I32Clz => { - let input = state.pop1()?; - let ensure_defined_zero = intrinsics - .i1_ty - .const_int(1 as u64, false) - .as_basic_value_enum(); - let res = builder - .build_call( + Operator::I16x8ShrS => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i16x8_ty, "") + .into_vector_value(); + let v2 = v2.into_int_value(); + let v2 = builder.build_and(v2, intrinsics.i32_ty.const_int(15, false), ""); + let v2 = builder.build_int_truncate(v2, intrinsics.i16_ty, ""); + let v2 = splat_vector( + builder, + intrinsics, + v2.as_basic_value_enum(), + intrinsics.i16x8_ty, + "", + ); + let res = builder.build_right_shift(v1, v2, true, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32x4ShrS => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i32x4_ty, "") + .into_vector_value(); + let v2 = v2.into_int_value(); + let v2 = builder.build_and(v2, intrinsics.i32_ty.const_int(31, false), ""); + let v2 = splat_vector( + builder, + intrinsics, + v2.as_basic_value_enum(), + intrinsics.i32x4_ty, + "", + ); + let res = builder.build_right_shift(v1, v2, true, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I64x2ShrS => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i64x2_ty, "") + .into_vector_value(); + let v2 = v2.into_int_value(); + let v2 = builder.build_and(v2, intrinsics.i32_ty.const_int(63, false), ""); + let v2 = builder.build_int_z_extend(v2, intrinsics.i64_ty, ""); + let v2 = splat_vector( + builder, + intrinsics, + v2.as_basic_value_enum(), + intrinsics.i64x2_ty, + "", + ); + let res = builder.build_right_shift(v1, v2, true, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32ShrU | Operator::I64ShrU => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let res = builder.build_right_shift(v1, v2, false, &state.var_name()); + state.push1(res); + } + Operator::I8x16ShrU => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i8x16_ty, "") + .into_vector_value(); + let v2 = v2.into_int_value(); + let v2 = builder.build_and(v2, intrinsics.i32_ty.const_int(7, false), ""); + let v2 = builder.build_int_truncate(v2, intrinsics.i8_ty, ""); + let v2 = splat_vector( + builder, + intrinsics, + v2.as_basic_value_enum(), + intrinsics.i8x16_ty, + "", + ); + let res = builder.build_right_shift(v1, v2, false, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8ShrU => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i16x8_ty, "") + .into_vector_value(); + let v2 = v2.into_int_value(); + let v2 = builder.build_and(v2, intrinsics.i32_ty.const_int(15, false), ""); + let v2 = builder.build_int_truncate(v2, intrinsics.i16_ty, ""); + let v2 = splat_vector( + builder, + intrinsics, + v2.as_basic_value_enum(), + intrinsics.i16x8_ty, + "", + ); + let res = builder.build_right_shift(v1, v2, false, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32x4ShrU => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i32x4_ty, "") + .into_vector_value(); + let v2 = v2.into_int_value(); + let v2 = builder.build_and(v2, intrinsics.i32_ty.const_int(31, false), ""); + let v2 = splat_vector( + builder, + intrinsics, + v2.as_basic_value_enum(), + intrinsics.i32x4_ty, + "", + ); + let res = builder.build_right_shift(v1, v2, false, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I64x2ShrU => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i64x2_ty, "") + .into_vector_value(); + let v2 = v2.into_int_value(); + let v2 = builder.build_and(v2, intrinsics.i32_ty.const_int(63, false), ""); + let v2 = builder.build_int_z_extend(v2, intrinsics.i64_ty, ""); + let v2 = splat_vector( + builder, + intrinsics, + v2.as_basic_value_enum(), + intrinsics.i64x2_ty, + "", + ); + let res = builder.build_right_shift(v1, v2, false, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32Rotl => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let lhs = builder.build_left_shift(v1, v2, &state.var_name()); + let rhs = { + let int_width = intrinsics.i32_ty.const_int(32 as u64, false); + let rhs = builder.build_int_sub(int_width, v2, &state.var_name()); + builder.build_right_shift(v1, rhs, false, &state.var_name()) + }; + let res = builder.build_or(lhs, rhs, &state.var_name()); + state.push1(res); + } + Operator::I64Rotl => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let lhs = builder.build_left_shift(v1, v2, &state.var_name()); + let rhs = { + let int_width = intrinsics.i64_ty.const_int(64 as u64, false); + let rhs = builder.build_int_sub(int_width, v2, &state.var_name()); + builder.build_right_shift(v1, rhs, false, &state.var_name()) + }; + let res = builder.build_or(lhs, rhs, &state.var_name()); + state.push1(res); + } + Operator::I32Rotr => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let lhs = builder.build_right_shift(v1, v2, false, &state.var_name()); + let rhs = { + let int_width = intrinsics.i32_ty.const_int(32 as u64, false); + let rhs = builder.build_int_sub(int_width, v2, &state.var_name()); + builder.build_left_shift(v1, rhs, &state.var_name()) + }; + let res = builder.build_or(lhs, rhs, &state.var_name()); + state.push1(res); + } + Operator::I64Rotr => { + let (v1, v2) = state.pop2()?; + let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); + let lhs = builder.build_right_shift(v1, v2, false, &state.var_name()); + let rhs = { + let int_width = intrinsics.i64_ty.const_int(64 as u64, false); + let rhs = builder.build_int_sub(int_width, v2, &state.var_name()); + builder.build_left_shift(v1, rhs, &state.var_name()) + }; + let res = builder.build_or(lhs, rhs, &state.var_name()); + state.push1(res); + } + Operator::I32Clz => { + let input = state.pop1()?; + let ensure_defined_zero = intrinsics + .i1_ty + .const_int(1 as u64, false) + .as_basic_value_enum(); + let res = builder + .build_call( intrinsics.ctlz_i32, &[input, ensure_defined_zero], &state.var_name(), @@ -1393,24 +2088,120 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_float_add(v1, v2, &state.var_name()); state.push1(res); } + Operator::F32x4Add => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f32x4_ty, "") + .into_vector_value(); + let res = builder.build_float_add(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F64x2Add => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f64x2_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f64x2_ty, "") + .into_vector_value(); + let res = builder.build_float_add(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::F32Sub | Operator::F64Sub => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_float_value(), v2.into_float_value()); let res = builder.build_float_sub(v1, v2, &state.var_name()); state.push1(res); } + Operator::F32x4Sub => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f32x4_ty, "") + .into_vector_value(); + let res = builder.build_float_sub(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F64x2Sub => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f64x2_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f64x2_ty, "") + .into_vector_value(); + let res = builder.build_float_sub(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::F32Mul | Operator::F64Mul => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_float_value(), v2.into_float_value()); let res = builder.build_float_mul(v1, v2, &state.var_name()); state.push1(res); } + Operator::F32x4Mul => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f32x4_ty, "") + .into_vector_value(); + let res = builder.build_float_mul(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F64x2Mul => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f64x2_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f64x2_ty, "") + .into_vector_value(); + let res = builder.build_float_mul(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::F32Div | Operator::F64Div => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_float_value(), v2.into_float_value()); let res = builder.build_float_div(v1, v2, &state.var_name()); state.push1(res); } + Operator::F32x4Div => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f32x4_ty, "") + .into_vector_value(); + let res = builder.build_float_div(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F64x2Div => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f64x2_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f64x2_ty, "") + .into_vector_value(); + let res = builder.build_float_div(v1, v2, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::F32Sqrt => { let input = state.pop1()?; let res = builder @@ -1429,6 +2220,28 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { .unwrap(); state.push1(res); } + Operator::F32x4Sqrt => { + let input = state.pop1()?.into_int_value(); + let float = builder.build_bitcast(input, intrinsics.f32x4_ty, "float"); + let res = builder + .build_call(intrinsics.sqrt_f32x4, &[float], &state.var_name()) + .try_as_basic_value() + .left() + .unwrap(); + let bits = builder.build_bitcast(res, intrinsics.i128_ty, "bits"); + state.push1(bits); + } + Operator::F64x2Sqrt => { + let input = state.pop1()?.into_int_value(); + let float = builder.build_bitcast(input, intrinsics.f64x2_ty, "float"); + let res = builder + .build_call(intrinsics.sqrt_f64x2, &[float], &state.var_name()) + .try_as_basic_value() + .left() + .unwrap(); + let bits = builder.build_bitcast(res, intrinsics.i128_ty, "bits"); + state.push1(bits); + } Operator::F32Min => { let (v1, v2) = state.pop2()?; let res = builder @@ -1447,6 +2260,30 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { .unwrap(); state.push1(res); } + Operator::F32x4Min => { + let (v1, v2) = state.pop2()?; + let v1 = builder.build_bitcast(v1, intrinsics.f32x4_ty, ""); + let v2 = builder.build_bitcast(v2, intrinsics.f32x4_ty, ""); + let res = builder + .build_call(intrinsics.minimum_f32x4, &[v1, v2], &state.var_name()) + .try_as_basic_value() + .left() + .unwrap(); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F64x2Min => { + let (v1, v2) = state.pop2()?; + let v1 = builder.build_bitcast(v1, intrinsics.f64x2_ty, ""); + let v2 = builder.build_bitcast(v2, intrinsics.f64x2_ty, ""); + let res = builder + .build_call(intrinsics.minimum_f64x2, &[v1, v2], &state.var_name()) + .try_as_basic_value() + .left() + .unwrap(); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::F32Max => { let (v1, v2) = state.pop2()?; let res = builder @@ -1465,6 +2302,30 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { .unwrap(); state.push1(res); } + Operator::F32x4Max => { + let (v1, v2) = state.pop2()?; + let v1 = builder.build_bitcast(v1, intrinsics.f32x4_ty, ""); + let v2 = builder.build_bitcast(v2, intrinsics.f32x4_ty, ""); + let res = builder + .build_call(intrinsics.maximum_f32x4, &[v1, v2], &state.var_name()) + .try_as_basic_value() + .left() + .unwrap(); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F64x2Max => { + let (v1, v2) = state.pop2()?; + let v1 = builder.build_bitcast(v1, intrinsics.f64x2_ty, ""); + let v2 = builder.build_bitcast(v2, intrinsics.f64x2_ty, ""); + let res = builder + .build_call(intrinsics.maximum_f64x2, &[v1, v2], &state.var_name()) + .try_as_basic_value() + .left() + .unwrap(); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::F32Ceil => { let input = state.pop1()?; let res = builder @@ -1555,6 +2416,46 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { .unwrap(); state.push1(res); } + Operator::F32x4Abs => { + let v = state.pop1()?.into_int_value(); + let v = builder.build_bitcast(v, intrinsics.f32x4_ty, ""); + let res = builder + .build_call(intrinsics.fabs_f32x4, &[v], &state.var_name()) + .try_as_basic_value() + .left() + .unwrap(); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F64x2Abs => { + let v = state.pop1()?.into_int_value(); + let v = builder.build_bitcast(v, intrinsics.f64x2_ty, ""); + let res = builder + .build_call(intrinsics.fabs_f64x2, &[v], &state.var_name()) + .try_as_basic_value() + .left() + .unwrap(); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F32x4Neg => { + let v = state.pop1()?.into_int_value(); + let v = builder + .build_bitcast(v, intrinsics.f32x4_ty, "") + .into_vector_value(); + let res = builder.build_float_neg(v, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F64x2Neg => { + let v = state.pop1()?.into_int_value(); + let v = builder + .build_bitcast(v, intrinsics.f64x2_ty, "") + .into_vector_value(); + let res = builder.build_float_neg(v, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::F32Neg | Operator::F64Neg => { let input = state.pop1()?.into_float_value(); let res = builder.build_float_neg(input, &state.var_name()); @@ -1590,6 +2491,45 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_int_z_extend(cond, intrinsics.i32_ty, &state.var_name()); state.push1(res); } + Operator::I8x16Eq => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i8x16_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i8x16_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::EQ, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i8x16_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8Eq => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i16x8_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i16x8_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::EQ, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i16x8_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32x4Eq => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i32x4_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::EQ, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i32x4_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::I32Ne | Operator::I64Ne => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); @@ -1597,6 +2537,45 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_int_z_extend(cond, intrinsics.i32_ty, &state.var_name()); state.push1(res); } + Operator::I8x16Ne => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i8x16_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i8x16_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::NE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i8x16_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8Ne => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i16x8_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i16x8_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::NE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i16x8_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32x4Ne => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i32x4_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::NE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i32x4_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::I32LtS | Operator::I64LtS => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); @@ -1604,6 +2583,45 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_int_z_extend(cond, intrinsics.i32_ty, &state.var_name()); state.push1(res); } + Operator::I8x16LtS => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i8x16_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i8x16_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::SLT, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i8x16_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8LtS => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i16x8_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i16x8_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::SLT, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i16x8_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32x4LtS => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i32x4_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::SLT, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i32x4_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::I32LtU | Operator::I64LtU => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); @@ -1611,6 +2629,45 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_int_z_extend(cond, intrinsics.i32_ty, &state.var_name()); state.push1(res); } + Operator::I8x16LtU => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i8x16_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i8x16_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::ULT, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i8x16_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8LtU => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i16x8_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i16x8_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::ULT, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i16x8_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32x4LtU => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i32x4_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::ULT, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i32x4_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::I32LeS | Operator::I64LeS => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); @@ -1618,6 +2675,45 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_int_z_extend(cond, intrinsics.i32_ty, &state.var_name()); state.push1(res); } + Operator::I8x16LeS => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i8x16_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i8x16_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::SLE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i8x16_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8LeS => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i16x8_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i16x8_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::SLE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i16x8_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32x4LeS => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i32x4_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::SLE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i32x4_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::I32LeU | Operator::I64LeU => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); @@ -1625,6 +2721,45 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_int_z_extend(cond, intrinsics.i32_ty, &state.var_name()); state.push1(res); } + Operator::I8x16LeU => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i8x16_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i8x16_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::ULE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i8x16_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8LeU => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i16x8_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i16x8_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::ULE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i16x8_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32x4LeU => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i32x4_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::ULE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i32x4_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::I32GtS | Operator::I64GtS => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); @@ -1632,6 +2767,45 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_int_z_extend(cond, intrinsics.i32_ty, &state.var_name()); state.push1(res); } + Operator::I8x16GtS => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i8x16_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i8x16_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::SGT, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i8x16_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8GtS => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i16x8_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i16x8_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::SGT, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i16x8_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32x4GtS => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i32x4_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::SGT, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i32x4_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::I32GtU | Operator::I64GtU => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); @@ -1639,6 +2813,45 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_int_z_extend(cond, intrinsics.i32_ty, &state.var_name()); state.push1(res); } + Operator::I8x16GtU => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i8x16_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i8x16_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::UGT, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i8x16_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8GtU => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i16x8_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i16x8_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::UGT, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i16x8_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32x4GtU => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i32x4_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::UGT, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i32x4_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::I32GeS | Operator::I64GeS => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); @@ -1646,6 +2859,45 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_int_z_extend(cond, intrinsics.i32_ty, &state.var_name()); state.push1(res); } + Operator::I8x16GeS => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i8x16_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i8x16_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::SGE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i8x16_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8GeS => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i16x8_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i16x8_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::SGE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i16x8_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32x4GeS => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i32x4_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::SGE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i32x4_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::I32GeU | Operator::I64GeU => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_int_value(), v2.into_int_value()); @@ -1653,6 +2905,45 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_int_z_extend(cond, intrinsics.i32_ty, &state.var_name()); state.push1(res); } + Operator::I8x16GeU => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i8x16_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i8x16_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::UGE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i8x16_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8GeU => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i16x8_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i16x8_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::UGE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i16x8_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32x4GeU => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i32x4_ty, "") + .into_vector_value(); + let res = builder.build_int_compare(IntPredicate::UGE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i32x4_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } /*************************** * Floating-Point Comparison instructions. @@ -1666,6 +2957,32 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_int_z_extend(cond, intrinsics.i32_ty, &state.var_name()); state.push1(res); } + Operator::F32x4Eq => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f32x4_ty, "") + .into_vector_value(); + let res = builder.build_float_compare(FloatPredicate::OEQ, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i32x4_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F64x2Eq => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f64x2_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f64x2_ty, "") + .into_vector_value(); + let res = builder.build_float_compare(FloatPredicate::OEQ, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i64x2_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::F32Ne | Operator::F64Ne => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_float_value(), v2.into_float_value()); @@ -1674,6 +2991,32 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_int_z_extend(cond, intrinsics.i32_ty, &state.var_name()); state.push1(res); } + Operator::F32x4Ne => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f32x4_ty, "") + .into_vector_value(); + let res = builder.build_float_compare(FloatPredicate::UNE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i32x4_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F64x2Ne => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f64x2_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f64x2_ty, "") + .into_vector_value(); + let res = builder.build_float_compare(FloatPredicate::UNE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i64x2_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::F32Lt | Operator::F64Lt => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_float_value(), v2.into_float_value()); @@ -1682,6 +3025,32 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_int_z_extend(cond, intrinsics.i32_ty, &state.var_name()); state.push1(res); } + Operator::F32x4Lt => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f32x4_ty, "") + .into_vector_value(); + let res = builder.build_float_compare(FloatPredicate::OLT, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i32x4_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F64x2Lt => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f64x2_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f64x2_ty, "") + .into_vector_value(); + let res = builder.build_float_compare(FloatPredicate::OLT, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i64x2_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::F32Le | Operator::F64Le => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_float_value(), v2.into_float_value()); @@ -1690,6 +3059,32 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_int_z_extend(cond, intrinsics.i32_ty, &state.var_name()); state.push1(res); } + Operator::F32x4Le => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f32x4_ty, "") + .into_vector_value(); + let res = builder.build_float_compare(FloatPredicate::OLE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i32x4_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F64x2Le => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f64x2_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f64x2_ty, "") + .into_vector_value(); + let res = builder.build_float_compare(FloatPredicate::OLE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i64x2_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::F32Gt | Operator::F64Gt => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_float_value(), v2.into_float_value()); @@ -1698,6 +3093,32 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_int_z_extend(cond, intrinsics.i32_ty, &state.var_name()); state.push1(res); } + Operator::F32x4Gt => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f32x4_ty, "") + .into_vector_value(); + let res = builder.build_float_compare(FloatPredicate::OGT, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i32x4_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F64x2Gt => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f64x2_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f64x2_ty, "") + .into_vector_value(); + let res = builder.build_float_compare(FloatPredicate::OGT, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i64x2_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::F32Ge | Operator::F64Ge => { let (v1, v2) = state.pop2()?; let (v1, v2) = (v1.into_float_value(), v2.into_float_value()); @@ -1706,6 +3127,32 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_int_z_extend(cond, intrinsics.i32_ty, &state.var_name()); state.push1(res); } + Operator::F32x4Ge => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f32x4_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f32x4_ty, "") + .into_vector_value(); + let res = builder.build_float_compare(FloatPredicate::OGE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i32x4_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F64x2Ge => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f64x2_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.f64x2_ty, "") + .into_vector_value(); + let res = builder.build_float_compare(FloatPredicate::OGE, v1, v2, ""); + let res = builder.build_int_s_extend(res, intrinsics.i64x2_ty, ""); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } /*************************** * Conversion instructions. @@ -1726,6 +3173,62 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_int_z_extend(v1, intrinsics.i64_ty, &state.var_name()); state.push1(res); } + Operator::I32x4TruncSF32x4Sat => { + let v = state.pop1()?.into_int_value(); + let res = trunc_sat( + builder, + intrinsics, + intrinsics.f32x4_ty, + intrinsics.i32x4_ty, + std::i32::MIN as u64, + std::i32::MAX as u64, + v, + &state.var_name(), + ); + state.push1(res); + } + Operator::I32x4TruncUF32x4Sat => { + let v = state.pop1()?.into_int_value(); + let res = trunc_sat( + builder, + intrinsics, + intrinsics.f32x4_ty, + intrinsics.i32x4_ty, + std::u32::MIN as u64, + std::u32::MAX as u64, + v, + &state.var_name(), + ); + state.push1(res); + } + Operator::I64x2TruncSF64x2Sat => { + let v = state.pop1()?.into_int_value(); + let res = trunc_sat( + builder, + intrinsics, + intrinsics.f64x2_ty, + intrinsics.i64x2_ty, + std::i64::MIN as u64, + std::i64::MAX as u64, + v, + &state.var_name(), + ); + state.push1(res); + } + Operator::I64x2TruncUF64x2Sat => { + let v = state.pop1()?.into_int_value(); + let res = trunc_sat( + builder, + intrinsics, + intrinsics.f64x2_ty, + intrinsics.i64x2_ty, + std::u64::MIN, + std::u64::MAX, + v, + &state.var_name(), + ); + state.push1(res); + } Operator::I32TruncSF32 => { let v1 = state.pop1()?.into_float_value(); trap_if_not_representatable_as_int( @@ -1904,6 +3407,46 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { builder.build_unsigned_int_to_float(v1, intrinsics.f64_ty, &state.var_name()); state.push1(res); } + Operator::F32x4ConvertSI32x4 => { + let v = state.pop1()?; + let v = builder + .build_bitcast(v, intrinsics.i32x4_ty, "") + .into_vector_value(); + let res = + builder.build_signed_int_to_float(v, intrinsics.f32x4_ty, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F32x4ConvertUI32x4 => { + let v = state.pop1()?; + let v = builder + .build_bitcast(v, intrinsics.i32x4_ty, "") + .into_vector_value(); + let res = + builder.build_unsigned_int_to_float(v, intrinsics.f32x4_ty, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F64x2ConvertSI64x2 => { + let v = state.pop1()?; + let v = builder + .build_bitcast(v, intrinsics.i64x2_ty, "") + .into_vector_value(); + let res = + builder.build_signed_int_to_float(v, intrinsics.f64x2_ty, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F64x2ConvertUI64x2 => { + let v = state.pop1()?; + let v = builder + .build_bitcast(v, intrinsics.i64x2_ty, "") + .into_vector_value(); + let res = + builder.build_unsigned_int_to_float(v, intrinsics.f64x2_ty, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::I32ReinterpretF32 => { let v = state.pop1()?; let space = @@ -2054,6 +3597,21 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let result = builder.build_load(effective_address, &state.var_name()); state.push1(result); } + Operator::V128Load { ref memarg } => { + let effective_address = resolve_memory_ptr( + builder, + intrinsics, + context, + &function, + &mut state, + &mut ctx, + memarg, + intrinsics.i128_ptr_ty, + 16, + )?; + let result = builder.build_load(effective_address, &state.var_name()); + state.push1(result); + } Operator::I32Store { ref memarg } => { let value = state.pop1()?; @@ -2115,6 +3673,21 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { )?; builder.build_store(effective_address, value); } + Operator::V128Store { ref memarg } => { + let value = state.pop1()?; + let effective_address = resolve_memory_ptr( + builder, + intrinsics, + context, + &function, + &mut state, + &mut ctx, + memarg, + intrinsics.i128_ptr_ty, + 16, + )?; + builder.build_store(effective_address, value); + } Operator::I32Load8S { ref memarg } => { let effective_address = resolve_memory_ptr( @@ -2359,6 +3932,281 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { builder.build_int_truncate(value, intrinsics.i32_ty, &state.var_name()); builder.build_store(effective_address, narrow_value); } + Operator::I8x16Neg => { + let v = state.pop1()?.into_int_value(); + let v = builder + .build_bitcast(v, intrinsics.i8x16_ty, "") + .into_vector_value(); + let res = builder.build_int_sub(v.get_type().const_zero(), v, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8Neg => { + let v = state.pop1()?.into_int_value(); + let v = builder + .build_bitcast(v, intrinsics.i16x8_ty, "") + .into_vector_value(); + let res = builder.build_int_sub(v.get_type().const_zero(), v, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32x4Neg => { + let v = state.pop1()?.into_int_value(); + let v = builder + .build_bitcast(v, intrinsics.i32x4_ty, "") + .into_vector_value(); + let res = builder.build_int_sub(v.get_type().const_zero(), v, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I64x2Neg => { + let v = state.pop1()?.into_int_value(); + let v = builder + .build_bitcast(v, intrinsics.i64x2_ty, "") + .into_vector_value(); + let res = builder.build_int_sub(v.get_type().const_zero(), v, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::V128Not => { + let v = state.pop1()?.into_int_value(); + let res = builder.build_not(v, &state.var_name()); + state.push1(res); + } + Operator::I8x16AnyTrue + | Operator::I16x8AnyTrue + | Operator::I32x4AnyTrue + | Operator::I64x2AnyTrue => { + let v = state.pop1()?.into_int_value(); + let res = builder.build_int_compare( + IntPredicate::NE, + v, + v.get_type().const_zero(), + &state.var_name(), + ); + let res = builder.build_int_z_extend(res, intrinsics.i32_ty, ""); + state.push1(res); + } + Operator::I8x16AllTrue + | Operator::I16x8AllTrue + | Operator::I32x4AllTrue + | Operator::I64x2AllTrue => { + let vec_ty = match *op { + Operator::I8x16AllTrue => intrinsics.i8x16_ty, + Operator::I16x8AllTrue => intrinsics.i16x8_ty, + Operator::I32x4AllTrue => intrinsics.i32x4_ty, + Operator::I64x2AllTrue => intrinsics.i64x2_ty, + _ => panic!(), + }; + let v = state.pop1()?.into_int_value(); + let lane_int_ty = context.custom_width_int_type(vec_ty.get_size()); + let vec = builder.build_bitcast(v, vec_ty, "vec").into_vector_value(); + let mask = + builder.build_int_compare(IntPredicate::NE, vec, vec_ty.const_zero(), "mask"); + let cmask = builder + .build_bitcast(mask, lane_int_ty, "cmask") + .into_int_value(); + let res = builder.build_int_compare( + IntPredicate::EQ, + cmask, + lane_int_ty.const_int(std::u64::MAX, true), + &state.var_name(), + ); + let res = builder.build_int_z_extend(res, intrinsics.i32_ty, ""); + state.push1(res); + } + Operator::I8x16ExtractLaneS { lane } => { + let v = state.pop1()?.into_int_value(); + let v = builder + .build_bitcast(v, intrinsics.i8x16_ty, "") + .into_vector_value(); + let idx = intrinsics.i32_ty.const_int(lane.into(), false); + let res = builder + .build_extract_element(v, idx, &state.var_name()) + .into_int_value(); + let res = builder.build_int_s_extend(res, intrinsics.i32_ty, ""); + state.push1(res); + } + Operator::I8x16ExtractLaneU { lane } => { + let v = state.pop1()?.into_int_value(); + let v = builder + .build_bitcast(v, intrinsics.i8x16_ty, "") + .into_vector_value(); + let idx = intrinsics.i32_ty.const_int(lane.into(), false); + let res = builder + .build_extract_element(v, idx, &state.var_name()) + .into_int_value(); + let res = builder.build_int_z_extend(res, intrinsics.i32_ty, ""); + state.push1(res); + } + Operator::I16x8ExtractLaneS { lane } => { + let v = state.pop1()?.into_int_value(); + let v = builder + .build_bitcast(v, intrinsics.i16x8_ty, "") + .into_vector_value(); + let idx = intrinsics.i32_ty.const_int(lane.into(), false); + let res = builder + .build_extract_element(v, idx, &state.var_name()) + .into_int_value(); + let res = builder.build_int_s_extend(res, intrinsics.i32_ty, ""); + state.push1(res); + } + Operator::I16x8ExtractLaneU { lane } => { + let v = state.pop1()?.into_int_value(); + let v = builder + .build_bitcast(v, intrinsics.i16x8_ty, "") + .into_vector_value(); + let idx = intrinsics.i32_ty.const_int(lane.into(), false); + let res = builder + .build_extract_element(v, idx, &state.var_name()) + .into_int_value(); + let res = builder.build_int_z_extend(res, intrinsics.i32_ty, ""); + state.push1(res); + } + Operator::I32x4ExtractLane { lane } => { + let v = state.pop1()?.into_int_value(); + let v = builder + .build_bitcast(v, intrinsics.i32x4_ty, "") + .into_vector_value(); + let idx = intrinsics.i32_ty.const_int(lane.into(), false); + let res = builder.build_extract_element(v, idx, &state.var_name()); + state.push1(res); + } + Operator::I64x2ExtractLane { lane } => { + let v = state.pop1()?.into_int_value(); + let v = builder + .build_bitcast(v, intrinsics.i64x2_ty, "") + .into_vector_value(); + let idx = intrinsics.i32_ty.const_int(lane.into(), false); + let res = builder.build_extract_element(v, idx, &state.var_name()); + state.push1(res); + } + Operator::F32x4ExtractLane { lane } => { + let v = state.pop1()?.into_int_value(); + let v = builder + .build_bitcast(v, intrinsics.f32x4_ty, "") + .into_vector_value(); + let idx = intrinsics.i32_ty.const_int(lane.into(), false); + let res = builder.build_extract_element(v, idx, &state.var_name()); + state.push1(res); + } + Operator::F64x2ExtractLane { lane } => { + let v = state.pop1()?.into_int_value(); + let v = builder + .build_bitcast(v, intrinsics.f64x2_ty, "") + .into_vector_value(); + let idx = intrinsics.i32_ty.const_int(lane.into(), false); + let res = builder.build_extract_element(v, idx, &state.var_name()); + state.push1(res); + } + Operator::I8x16ReplaceLane { lane } => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i8x16_ty, "") + .into_vector_value(); + let v2 = v2.into_int_value(); + let v2 = builder.build_int_cast(v2, intrinsics.i8_ty, ""); + let idx = intrinsics.i32_ty.const_int(lane.into(), false); + let res = builder.build_insert_element(v1, v2, idx, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8ReplaceLane { lane } => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i16x8_ty, "") + .into_vector_value(); + let v2 = v2.into_int_value(); + let v2 = builder.build_int_cast(v2, intrinsics.i16_ty, ""); + let idx = intrinsics.i32_ty.const_int(lane.into(), false); + let res = builder.build_insert_element(v1, v2, idx, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32x4ReplaceLane { lane } => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i32x4_ty, "") + .into_vector_value(); + let v2 = v2.into_int_value(); + let idx = intrinsics.i32_ty.const_int(lane.into(), false); + let res = builder.build_insert_element(v1, v2, idx, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I64x2ReplaceLane { lane } => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i64x2_ty, "") + .into_vector_value(); + let v2 = v2.into_int_value(); + let idx = intrinsics.i32_ty.const_int(lane.into(), false); + let res = builder.build_insert_element(v1, v2, idx, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F32x4ReplaceLane { lane } => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f32x4_ty, "") + .into_vector_value(); + let v2 = v2.into_float_value(); + let idx = intrinsics.i32_ty.const_int(lane.into(), false); + let res = builder.build_insert_element(v1, v2, idx, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::F64x2ReplaceLane { lane } => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.f64x2_ty, "") + .into_vector_value(); + let v2 = v2.into_float_value(); + let idx = intrinsics.i32_ty.const_int(lane.into(), false); + let res = builder.build_insert_element(v1, v2, idx, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::V8x16Shuffle1 => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i8x16_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i8x16_ty, "") + .into_vector_value(); + let mut res = intrinsics.i8x16_ty.get_undef(); + for i in 0..15 { + let idx = builder + .build_extract_element(v2, intrinsics.i32_ty.const_int(i, false), "") + .into_int_value(); + let idx = builder.build_and(idx, intrinsics.i32_ty.const_int(15, false), ""); + let elem = builder.build_extract_element(v1, idx, ""); + res = builder + .build_insert_element(res, elem, intrinsics.i32_ty.const_int(i, false), ""); + } + let res = builder.build_bitcast(res, intrinsics.i128_ty, &state.var_name()); + state.push1(res); + } + Operator::V8x16Shuffle2Imm { lanes } => { + let (v1, v2) = state.pop2()?; + let v1 = builder + .build_bitcast(v1, intrinsics.i8x16_ty, "") + .into_vector_value(); + let v2 = builder + .build_bitcast(v2, intrinsics.i8x16_ty, "") + .into_vector_value(); + let mask = VectorType::const_vector( + lanes + .into_iter() + .map(|l| intrinsics.i32_ty.const_int((*l).into(), false)) + .collect::>() + .as_slice(), + ); + let res = builder.build_shuffle_vector(v1, v2, mask, &state.var_name()); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::MemoryGrow { reserved } => { let memory_index = MemoryIndex::new(reserved as usize); diff --git a/lib/llvm-backend/src/intrinsics.rs b/lib/llvm-backend/src/intrinsics.rs index c866b8207d5..32591ce7054 100644 --- a/lib/llvm-backend/src/intrinsics.rs +++ b/lib/llvm-backend/src/intrinsics.rs @@ -3,7 +3,9 @@ use inkwell::{ builder::Builder, context::Context, module::Module, - types::{BasicType, FloatType, FunctionType, IntType, PointerType, StructType, VoidType}, + types::{ + BasicType, FloatType, FunctionType, IntType, PointerType, StructType, VectorType, VoidType, + }, values::{BasicValue, BasicValueEnum, FloatValue, FunctionValue, IntValue, PointerValue}, AddressSpace, }; @@ -41,12 +43,18 @@ pub struct Intrinsics { pub sqrt_f32: FunctionValue, pub sqrt_f64: FunctionValue, + pub sqrt_f32x4: FunctionValue, + pub sqrt_f64x2: FunctionValue, pub minimum_f32: FunctionValue, pub minimum_f64: FunctionValue, + pub minimum_f32x4: FunctionValue, + pub minimum_f64x2: FunctionValue, pub maximum_f32: FunctionValue, pub maximum_f64: FunctionValue, + pub maximum_f32x4: FunctionValue, + pub maximum_f64x2: FunctionValue, pub ceil_f32: FunctionValue, pub ceil_f64: FunctionValue, @@ -62,10 +70,22 @@ pub struct Intrinsics { pub fabs_f32: FunctionValue, pub fabs_f64: FunctionValue, + pub fabs_f32x4: FunctionValue, + pub fabs_f64x2: FunctionValue, pub copysign_f32: FunctionValue, pub copysign_f64: FunctionValue, + pub sadd_sat_i8x16: FunctionValue, + pub sadd_sat_i16x8: FunctionValue, + pub uadd_sat_i8x16: FunctionValue, + pub uadd_sat_i16x8: FunctionValue, + + pub ssub_sat_i8x16: FunctionValue, + pub ssub_sat_i16x8: FunctionValue, + pub usub_sat_i8x16: FunctionValue, + pub usub_sat_i16x8: FunctionValue, + pub expect_i1: FunctionValue, pub trap: FunctionValue, @@ -79,6 +99,14 @@ pub struct Intrinsics { pub f32_ty: FloatType, pub f64_ty: FloatType, + pub i1x128_ty: VectorType, + pub i8x16_ty: VectorType, + pub i16x8_ty: VectorType, + pub i32x4_ty: VectorType, + pub i64x2_ty: VectorType, + pub f32x4_ty: VectorType, + pub f64x2_ty: VectorType, + pub i8_ptr_ty: PointerType, pub i16_ptr_ty: PointerType, pub i32_ptr_ty: PointerType, @@ -134,6 +162,14 @@ impl Intrinsics { let f32_ty = context.f32_type(); let f64_ty = context.f64_type(); + let i1x128_ty = i1_ty.vec_type(128); + let i8x16_ty = i8_ty.vec_type(16); + let i16x8_ty = i16_ty.vec_type(8); + let i32x4_ty = i32_ty.vec_type(4); + let i64x2_ty = i64_ty.vec_type(2); + let f32x4_ty = f32_ty.vec_type(4); + let f64x2_ty = f64_ty.vec_type(2); + let i8_ptr_ty = i8_ty.ptr_type(AddressSpace::Generic); let i16_ptr_ty = i16_ty.ptr_type(AddressSpace::Generic); let i32_ptr_ty = i32_ty.ptr_type(AddressSpace::Generic); @@ -154,6 +190,10 @@ impl Intrinsics { let i64_ty_basic = i64_ty.as_basic_type_enum(); let f32_ty_basic = f32_ty.as_basic_type_enum(); let f64_ty_basic = f64_ty.as_basic_type_enum(); + let i8x16_ty_basic = i8x16_ty.as_basic_type_enum(); + let i16x8_ty_basic = i16x8_ty.as_basic_type_enum(); + let f32x4_ty_basic = f32x4_ty.as_basic_type_enum(); + let f64x2_ty_basic = f64x2_ty.as_basic_type_enum(); let i8_ptr_ty_basic = i8_ptr_ty.as_basic_type_enum(); let ctx_ty = context.opaque_struct_type("ctx"); @@ -240,6 +280,9 @@ impl Intrinsics { false, ); + let ret_i8x16_take_i8x16_i8x16 = i8x16_ty.fn_type(&[i8x16_ty_basic, i8x16_ty_basic], false); + let ret_i16x8_take_i16x8_i16x8 = i16x8_ty.fn_type(&[i16x8_ty_basic, i16x8_ty_basic], false); + let ret_i32_take_i32_i1 = i32_ty.fn_type(&[i32_ty_basic, i1_ty_basic], false); let ret_i64_take_i64_i1 = i64_ty.fn_type(&[i64_ty_basic, i1_ty_basic], false); @@ -248,9 +291,13 @@ impl Intrinsics { let ret_f32_take_f32 = f32_ty.fn_type(&[f32_ty_basic], false); let ret_f64_take_f64 = f64_ty.fn_type(&[f64_ty_basic], false); + let ret_f32x4_take_f32x4 = f32x4_ty.fn_type(&[f32x4_ty_basic], false); + let ret_f64x2_take_f64x2 = f64x2_ty.fn_type(&[f64x2_ty_basic], false); let ret_f32_take_f32_f32 = f32_ty.fn_type(&[f32_ty_basic, f32_ty_basic], false); let ret_f64_take_f64_f64 = f64_ty.fn_type(&[f64_ty_basic, f64_ty_basic], false); + let ret_f32x4_take_f32x4_f32x4 = f32x4_ty.fn_type(&[f32x4_ty_basic, f32x4_ty_basic], false); + let ret_f64x2_take_f64x2_f64x2 = f64x2_ty.fn_type(&[f64x2_ty_basic, f64x2_ty_basic], false); let ret_i32_take_ctx_i32_i32 = i32_ty.fn_type( &[ctx_ptr_ty.as_basic_type_enum(), i32_ty_basic, i32_ty_basic], @@ -273,12 +320,34 @@ impl Intrinsics { sqrt_f32: module.add_function("llvm.sqrt.f32", ret_f32_take_f32, None), sqrt_f64: module.add_function("llvm.sqrt.f64", ret_f64_take_f64, None), + sqrt_f32x4: module.add_function("llvm.sqrt.v4f32", ret_f32x4_take_f32x4, None), + sqrt_f64x2: module.add_function("llvm.sqrt.v2f64", ret_f64x2_take_f64x2, None), + + minimum_f32: module.add_function("llvm.minnum.f32", ret_f32_take_f32_f32, None), + minimum_f64: module.add_function("llvm.minnum.f64", ret_f64_take_f64_f64, None), + minimum_f32x4: module.add_function( + "llvm.minimum.v4f32", + ret_f32x4_take_f32x4_f32x4, + None, + ), + minimum_f64x2: module.add_function( + "llvm.minimum.v2f64", + ret_f64x2_take_f64x2_f64x2, + None, + ), - minimum_f32: module.add_function("llvm.minimum.f32", ret_f32_take_f32_f32, None), - minimum_f64: module.add_function("llvm.minimum.f64", ret_f64_take_f64_f64, None), - - maximum_f32: module.add_function("llvm.maximum.f32", ret_f32_take_f32_f32, None), - maximum_f64: module.add_function("llvm.maximum.f64", ret_f64_take_f64_f64, None), + maximum_f32: module.add_function("llvm.maxnum.f32", ret_f32_take_f32_f32, None), + maximum_f64: module.add_function("llvm.maxnum.f64", ret_f64_take_f64_f64, None), + maximum_f32x4: module.add_function( + "llvm.maximum.v4f32", + ret_f32x4_take_f32x4_f32x4, + None, + ), + maximum_f64x2: module.add_function( + "llvm.maximum.v2f64", + ret_f64x2_take_f64x2_f64x2, + None, + ), ceil_f32: module.add_function("llvm.ceil.f32", ret_f32_take_f32, None), ceil_f64: module.add_function("llvm.ceil.f64", ret_f64_take_f64, None), @@ -294,10 +363,54 @@ impl Intrinsics { fabs_f32: module.add_function("llvm.fabs.f32", ret_f32_take_f32, None), fabs_f64: module.add_function("llvm.fabs.f64", ret_f64_take_f64, None), + fabs_f32x4: module.add_function("llvm.fabs.v4f32", ret_f32x4_take_f32x4, None), + fabs_f64x2: module.add_function("llvm.fabs.v2f64", ret_f64x2_take_f64x2, None), copysign_f32: module.add_function("llvm.copysign.f32", ret_f32_take_f32_f32, None), copysign_f64: module.add_function("llvm.copysign.f64", ret_f64_take_f64_f64, None), + sadd_sat_i8x16: module.add_function( + "llvm.sadd.sat.v16i8", + ret_i8x16_take_i8x16_i8x16, + None, + ), + sadd_sat_i16x8: module.add_function( + "llvm.sadd.sat.v8i16", + ret_i16x8_take_i16x8_i16x8, + None, + ), + uadd_sat_i8x16: module.add_function( + "llvm.uadd.sat.v16i8", + ret_i8x16_take_i8x16_i8x16, + None, + ), + uadd_sat_i16x8: module.add_function( + "llvm.uadd.sat.v8i16", + ret_i16x8_take_i16x8_i16x8, + None, + ), + + ssub_sat_i8x16: module.add_function( + "llvm.ssub.sat.v16i8", + ret_i8x16_take_i8x16_i8x16, + None, + ), + ssub_sat_i16x8: module.add_function( + "llvm.ssub.sat.v8i16", + ret_i16x8_take_i16x8_i16x8, + None, + ), + usub_sat_i8x16: module.add_function( + "llvm.usub.sat.v16i8", + ret_i8x16_take_i8x16_i8x16, + None, + ), + usub_sat_i16x8: module.add_function( + "llvm.usub.sat.v8i16", + ret_i16x8_take_i16x8_i16x8, + None, + ), + expect_i1: module.add_function("llvm.expect.i1", ret_i1_take_i1_i1, None), trap: module.add_function("llvm.trap", void_ty.fn_type(&[], false), None), @@ -311,6 +424,14 @@ impl Intrinsics { f32_ty, f64_ty, + i1x128_ty, + i8x16_ty, + i16x8_ty, + i32x4_ty, + i64x2_ty, + f32x4_ty, + f64x2_ty, + i8_ptr_ty, i16_ptr_ty, i32_ptr_ty, diff --git a/lib/llvm-backend/src/read_info.rs b/lib/llvm-backend/src/read_info.rs index fa5c017d30f..946c74d5298 100644 --- a/lib/llvm-backend/src/read_info.rs +++ b/lib/llvm-backend/src/read_info.rs @@ -7,12 +7,7 @@ pub fn type_to_type(ty: WpType) -> Result { WpType::I64 => Type::I64, WpType::F32 => Type::F32, WpType::F64 => Type::F64, - WpType::V128 => { - return Err(BinaryReaderError { - message: "the wasmer llvm backend does not yet support the simd extension", - offset: -1isize as usize, - }); - } + WpType::V128 => Type::V128, _ => { return Err(BinaryReaderError { message: "that type is not supported as a wasmer type", From bb30434392dbd3c675df25e8c6b7fdd313c2fbf2 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 2 Jul 2019 16:05:10 -0700 Subject: [PATCH 11/37] This .into_iter() call is equivalent to .iter() and will not move the array. --- lib/llvm-backend/src/code.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/llvm-backend/src/code.rs b/lib/llvm-backend/src/code.rs index ee70850691d..4b9c38f77b9 100644 --- a/lib/llvm-backend/src/code.rs +++ b/lib/llvm-backend/src/code.rs @@ -4198,7 +4198,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { .into_vector_value(); let mask = VectorType::const_vector( lanes - .into_iter() + .iter() .map(|l| intrinsics.i32_ty.const_int((*l).into(), false)) .collect::>() .as_slice(), From f4af4e387d840ffb5fd09230822e28c3f4f2a660 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 2 Jul 2019 17:01:50 -0700 Subject: [PATCH 12/37] Stub out support for V128 in the C API for now. --- lib/runtime-c-api/src/export.rs | 1 + lib/runtime-c-api/src/instance.rs | 1 + lib/runtime-c-api/src/value.rs | 2 ++ 3 files changed, 4 insertions(+) diff --git a/lib/runtime-c-api/src/export.rs b/lib/runtime-c-api/src/export.rs index cdb953e2491..d93f987a4d8 100644 --- a/lib/runtime-c-api/src/export.rs +++ b/lib/runtime-c-api/src/export.rs @@ -402,6 +402,7 @@ pub unsafe extern "C" fn wasmer_export_func_call( tag: wasmer_value_tag::WASM_F64, value: wasmer_value { F64: x }, }, + _ => panic!("not implemented"), }; results[0] = ret; } diff --git a/lib/runtime-c-api/src/instance.rs b/lib/runtime-c-api/src/instance.rs index 79a617be287..4fc76f7665c 100644 --- a/lib/runtime-c-api/src/instance.rs +++ b/lib/runtime-c-api/src/instance.rs @@ -173,6 +173,7 @@ pub unsafe extern "C" fn wasmer_instance_call( tag: wasmer_value_tag::WASM_F64, value: wasmer_value { F64: x }, }, + _ => panic!("not implemented"), }; results[0] = ret; } diff --git a/lib/runtime-c-api/src/value.rs b/lib/runtime-c-api/src/value.rs index d6b7b506aca..62f62c3acdb 100644 --- a/lib/runtime-c-api/src/value.rs +++ b/lib/runtime-c-api/src/value.rs @@ -76,6 +76,7 @@ impl From for wasmer_value_t { tag: wasmer_value_tag::WASM_F64, value: wasmer_value { F64: x }, }, + _ => panic!("not implemented"), } } } @@ -113,6 +114,7 @@ impl From<&wasmer_runtime::wasm::Type> for wasmer_value_tag { Type::I64 => wasmer_value_tag::WASM_I64, Type::F32 => wasmer_value_tag::WASM_F32, Type::F64 => wasmer_value_tag::WASM_F64, + _ => panic!("not implemented"), } } } From 1ac2416c893cbabf84a96a770ed3d776a6bc60af Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 2 Jul 2019 15:51:02 -0700 Subject: [PATCH 13/37] Add changelog entry. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a2add63b5e..ca79b0762d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ Blocks of changes will separated by version increments. ## 0.5.1 - 2019-06-24 - [#508](https://github.com/wasmerio/wasmer/pull/508) Update wapm version, includes bug fixes +- [#?](https://github.com/wasmerio/wasmer/pull/?) Add SIMD support to wasmer and implement it in the LLVM backend only. + ## 0.5.0 - 2019-06-17 - [#471](https://github.com/wasmerio/wasmer/pull/471) Added missing functions to run Python. Improved Emscripten bindings From 53907b0ab2ce41a31567aa2ad3f2064cfc51b4ed Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Wed, 10 Jul 2019 14:23:47 -0700 Subject: [PATCH 14/37] Update inkwell to our own copy until upstream supports LLVM 8. LLVM 8 support from https://github.com/lumen/inkwell/tree/llvm8 . --- lib/llvm-backend/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/llvm-backend/Cargo.toml b/lib/llvm-backend/Cargo.toml index fbc78c73ed1..977347e864e 100644 --- a/lib/llvm-backend/Cargo.toml +++ b/lib/llvm-backend/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] wasmer-runtime-core = { path = "../runtime-core", version = "0.5.4" } -inkwell = { git = "https://github.com/lumen/inkwell", rev = "64921e418c3e8f4b32f9beed56ebd5aac4e677c7", features = ["llvm8-0"] } +inkwell = { git = "https://github.com/wasmerio/inkwell", branch = "llvm8-0", features = ["llvm8-0"] } wasmparser = "0.32.1" hashbrown = "0.1.8" smallvec = "0.6.8" From e4123433a1211b4416a2a187b05ea2af78fe3567 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Wed, 10 Jul 2019 14:28:07 -0700 Subject: [PATCH 15/37] Reformat. --- lib/llvm-backend/src/code.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/llvm-backend/src/code.rs b/lib/llvm-backend/src/code.rs index 4b9c38f77b9..94f860eca64 100644 --- a/lib/llvm-backend/src/code.rs +++ b/lib/llvm-backend/src/code.rs @@ -75,8 +75,7 @@ fn splat_vector( // Use insert_element to insert the element into an undef vector, then use // shuffle vector to copy that lane to all lanes. builder.build_shuffle_vector( - builder - .build_insert_element(vec_ty.get_undef(), value, intrinsics.i32_zero, ""), + builder.build_insert_element(vec_ty.get_undef(), value, intrinsics.i32_zero, ""), vec_ty.get_undef(), intrinsics.i32_ty.vec_type(vec_ty.get_size()).const_zero(), name, @@ -4182,8 +4181,12 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { .into_int_value(); let idx = builder.build_and(idx, intrinsics.i32_ty.const_int(15, false), ""); let elem = builder.build_extract_element(v1, idx, ""); - res = builder - .build_insert_element(res, elem, intrinsics.i32_ty.const_int(i, false), ""); + res = builder.build_insert_element( + res, + elem, + intrinsics.i32_ty.const_int(i, false), + "", + ); } let res = builder.build_bitcast(res, intrinsics.i128_ty, &state.var_name()); state.push1(res); From 702125eef290cae1e456cd857863651ab2e4c9d8 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Wed, 10 Jul 2019 14:31:58 -0700 Subject: [PATCH 16/37] Fill in changelog entry. --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca79b0762d6..86668064fa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All PRs to the Wasmer repository must add to this file. Blocks of changes will separated by version increments. ## **[Unreleased]** +- [#542](https://github.com/wasmerio/wasmer/pull/542) Add SIMD support to wasmer and implement it in the LLVM backend only. - [#541](https://github.com/wasmerio/wasmer/pull/541) Fix dependency graph by making separate test crates; ABI implementations should not depend on compilers. Add Cranelift fork as git submodule of clif-backend - [#537](https://github.com/wasmerio/wasmer/pull/537) Add hidden flag (`--cache-key`) to use prehashed key into the compiled wasm cache and change compiler backend-specific caching to use directories - [#536](https://github.com/wasmerio/wasmer/pull/536) ~Update cache to use compiler backend name in cache key~ @@ -26,8 +27,6 @@ Blocks of changes will separated by version increments. ## 0.5.1 - 2019-06-24 - [#508](https://github.com/wasmerio/wasmer/pull/508) Update wapm version, includes bug fixes -- [#?](https://github.com/wasmerio/wasmer/pull/?) Add SIMD support to wasmer and implement it in the LLVM backend only. - ## 0.5.0 - 2019-06-17 - [#471](https://github.com/wasmerio/wasmer/pull/471) Added missing functions to run Python. Improved Emscripten bindings From a14d2b27b41124f7b4a314640f105e713a320dd3 Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 10 Jul 2019 14:41:02 -0700 Subject: [PATCH 17/37] Added simd tests for llvm --- lib/spectests/build/spectests.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/spectests/build/spectests.rs b/lib/spectests/build/spectests.rs index 10fb4567851..5505f51a3ea 100644 --- a/lib/spectests/build/spectests.rs +++ b/lib/spectests/build/spectests.rs @@ -72,11 +72,13 @@ const TESTS: &[&str] = &[ "spectests/typecheck.wast", "spectests/types.wast", "spectests/unwind.wast", + #[cfg(feature = "llvm")] + "spectests/simd.wast", ]; static COMMON: &'static str = r##" use std::{{f32, f64}}; -use wabt::wat2wasm; +use wabt::{{wat2wasm_with_features, Error as WabtError}}; use wasmer_runtime_core::import::ImportObject; use wasmer_runtime_core::types::Value; use wasmer_runtime_core::{{Instance, module::Module}}; @@ -95,6 +97,14 @@ static IMPORT_MODULE: &str = r#" (global $global_i32 (export "global_i32") i32 (i32.const 666))) "#; +fn wat2wasm>( + source: S, +) -> Result, WabtError> { + let mut features = wabt::Features::new(); + features.enable_simd(); + wabt::wat2wasm_with_features(source, features) +} + #[cfg(feature = "clif")] fn get_compiler() -> impl Compiler { use wasmer_clif_backend::CraneliftCompiler; @@ -291,7 +301,8 @@ impl WastTestGenerator { fn new(path: &PathBuf) -> Self { let filename = path.file_name().unwrap().to_str().unwrap(); let source = fs::read(&path).unwrap(); - let script: ScriptParser = ScriptParser::from_source_and_name(&source, filename).unwrap(); + let script: ScriptParser = ScriptParser::from_source_and_name(&source, filename) + .expect(&format!("Failed to parse script {}", &filename)); let buffer = String::new(); WastTestGenerator { last_module: 0, From e98093132988f25a551db993e29b215236438a8a Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 10 Jul 2019 14:43:54 -0700 Subject: [PATCH 18/37] Added simd spectest file --- lib/spectests/spectests/simd.wast | 680 ++++++++++++++++++++++++++++++ 1 file changed, 680 insertions(+) create mode 100644 lib/spectests/spectests/simd.wast diff --git a/lib/spectests/spectests/simd.wast b/lib/spectests/spectests/simd.wast new file mode 100644 index 00000000000..6ca3f89e615 --- /dev/null +++ b/lib/spectests/spectests/simd.wast @@ -0,0 +1,680 @@ +;; Code tests taken from +;; https://github.com/WAVM/WAVM/blob/2b919c20a02624af9758e9ddd0b9b5726c973e4f/Test/simd.wast + +;; All attributions reserved for WAVM and it's author Andrew +;; https://github.com/WAVM/WAVM + +;; WAVM test spec license: Apache 2.0 +;; https://github.com/WAVM/WAVM/blob/2b919c20a02624af9758e9ddd0b9b5726c973e4f/Test/spec/LICENSE + +;; v128 globals + +(module $M + (global (export "a") v128 (v128.const f32x4 0 1 2 3)) + (global (export "b") (mut v128) (v128.const f32x4 4 5 6 7)) +) +(register "M" $M) + +(module + (global $a (import "M" "a") v128) + (global $b (import "M" "b") (mut v128)) + + (global $c v128 (global.get $a)) + (global $d v128 (v128.const i32x4 8 9 10 11)) + (global $e (mut v128) (global.get $a)) + (global $f (mut v128) (v128.const i32x4 12 13 14 15)) + + (func (export "get-a") (result v128) (global.get $a)) + (func (export "get-b") (result v128) (global.get $b)) + (func (export "get-c") (result v128) (global.get $c)) + (func (export "get-d") (result v128) (global.get $d)) + (func (export "get-e") (result v128) (global.get $e)) + (func (export "get-f") (result v128) (global.get $f)) + + (func (export "set-b") (param $value v128) (global.set $b (local.get $value))) + (func (export "set-e") (param $value v128) (global.set $e (local.get $value))) + (func (export "set-f") (param $value v128) (global.set $f (local.get $value))) +) + +(assert_return (invoke "get-a") (v128.const f32x4 0 1 2 3)) +(assert_return (invoke "get-b") (v128.const f32x4 4 5 6 7)) +(assert_return (invoke "get-c") (v128.const f32x4 0 1 2 3)) +(assert_return (invoke "get-d") (v128.const i32x4 8 9 10 11)) +(assert_return (invoke "get-e") (v128.const f32x4 0 1 2 3)) +(assert_return (invoke "get-f") (v128.const i32x4 12 13 14 15)) + +(invoke "set-b" (v128.const f64x2 nan:0x1 nan:0x2)) +(assert_return (invoke "get-b") (v128.const f64x2 nan:0x1 nan:0x2)) + +(invoke "set-e" (v128.const f64x2 -nan:0x3 +inf)) +(assert_return (invoke "get-e") (v128.const f64x2 -nan:0x3 +inf)) + +(invoke "set-f" (v128.const f32x4 -inf +3.14 10.0e30 +nan:0x42)) +(assert_return (invoke "get-f") (v128.const f32x4 -inf +3.14 10.0e30 +nan:0x42)) + +(assert_invalid (module (global v128 (i32.const 0))) "invalid initializer expression") +(assert_invalid (module (global v128 (i64.const 0))) "invalid initializer expression") +(assert_invalid (module (global v128 (f32.const 0))) "invalid initializer expression") +(assert_invalid (module (global v128 (f64.const 0))) "invalid initializer expression") +(assert_invalid (module (global $i32 i32 (i32.const 0)) (global v128 (global.get $i32))) "invalid initializer expression") + +(module binary + "\00asm" + "\01\00\00\00" ;; 1 section + "\06" ;; global section + "\16" ;; 22 bytes + "\01" ;; 1 global + "\7b" ;; v128 + "\00" ;; immutable + "\fd\02" ;; v128.const + "\00\01\02\03" ;; literal bytes 0-3 + "\04\05\06\07" ;; literal bytes 4-7 + "\08\09\0a\0b" ;; literal bytes 8-11 + "\0c\0d\0e\0f" ;; literal bytes 12-15 + "\0b" ;; end +) + +(assert_invalid + (module binary + "\00asm" + "\01\00\00\00" ;; 1 section + "\06\86\80\80\80\00" ;; global section + "\01" ;; 1 global + "\7b" ;; v128 + "\00" ;; immutable + "\fd\00" ;; v128.load + "\0b" ;; end + ) + "invalid initializer expression" +) + +;; TODO: v128 parameters + +;; TODO: v128 locals + +;; TODO: v128 results + +;; v128.const + +(module + (func (export "v128.const/i8x16") (result v128) (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)) + (func (export "v128.const/i16x8") (result v128) (v128.const i16x8 16 17 18 19 20 21 22 23)) + (func (export "v128.const/i32x4") (result v128) (v128.const i32x4 24 25 26 27)) + (func (export "v128.const/i64x2") (result v128) (v128.const i64x2 28 29)) + (func (export "v128.const/f32x4") (result v128) (v128.const f32x4 30.5 31.5 32.5 33.5)) + (func (export "v128.const/f64x2") (result v128) (v128.const f64x2 34.5 35.5)) +) + +;; v128.load/store + +(module + (memory 1) + (func (export "v128.load") (param $address i32) (result v128) (v128.load align=16 (local.get $address))) + (func (export "v128.store") (param $address i32) (param $value v128) (v128.store align=16 (local.get $address) (local.get $value))) +) + +(assert_invalid (module (memory 1) (func (drop (v128.load align=32 (i32.const 0))))) "invalid alignment") +(assert_invalid (module (memory 1) (func (drop (v128.store align=32 (i32.const 0))))) "invalid alignment") + +;; *.splat + +(module + (func (export "i8x16.splat") (param $a i32) (result v128) (i8x16.splat (local.get $a))) + (func (export "i16x8.splat") (param $a i32) (result v128) (i16x8.splat (local.get $a))) + (func (export "i32x4.splat") (param $a i32) (result v128) (i32x4.splat (local.get $a))) + (func (export "i64x2.splat") (param $a i64) (result v128) (i64x2.splat (local.get $a))) + (func (export "f32x4.splat") (param $a f32) (result v128) (f32x4.splat (local.get $a))) + (func (export "f64x2.splat") (param $a f64) (result v128) (f64x2.splat (local.get $a))) +) + +;; *.extract_lane* + +(module + (func (export "i8x16.extract_lane_s/0") (param $a v128) (result i32) (i8x16.extract_lane_s 0 (local.get $a))) + (func (export "i8x16.extract_lane_s/1") (param $a v128) (result i32) (i8x16.extract_lane_s 1 (local.get $a))) + (func (export "i8x16.extract_lane_s/2") (param $a v128) (result i32) (i8x16.extract_lane_s 2 (local.get $a))) + (func (export "i8x16.extract_lane_s/3") (param $a v128) (result i32) (i8x16.extract_lane_s 3 (local.get $a))) + (func (export "i8x16.extract_lane_s/4") (param $a v128) (result i32) (i8x16.extract_lane_s 4 (local.get $a))) + (func (export "i8x16.extract_lane_s/5") (param $a v128) (result i32) (i8x16.extract_lane_s 5 (local.get $a))) + (func (export "i8x16.extract_lane_s/6") (param $a v128) (result i32) (i8x16.extract_lane_s 6 (local.get $a))) + (func (export "i8x16.extract_lane_s/7") (param $a v128) (result i32) (i8x16.extract_lane_s 7 (local.get $a))) + (func (export "i8x16.extract_lane_s/8") (param $a v128) (result i32) (i8x16.extract_lane_s 8 (local.get $a))) + (func (export "i8x16.extract_lane_s/9") (param $a v128) (result i32) (i8x16.extract_lane_s 9 (local.get $a))) + (func (export "i8x16.extract_lane_s/10") (param $a v128) (result i32) (i8x16.extract_lane_s 10 (local.get $a))) + (func (export "i8x16.extract_lane_s/11") (param $a v128) (result i32) (i8x16.extract_lane_s 11 (local.get $a))) + (func (export "i8x16.extract_lane_s/12") (param $a v128) (result i32) (i8x16.extract_lane_s 12 (local.get $a))) + (func (export "i8x16.extract_lane_s/13") (param $a v128) (result i32) (i8x16.extract_lane_s 13 (local.get $a))) + (func (export "i8x16.extract_lane_s/14") (param $a v128) (result i32) (i8x16.extract_lane_s 14 (local.get $a))) + (func (export "i8x16.extract_lane_s/15") (param $a v128) (result i32) (i8x16.extract_lane_s 15 (local.get $a))) + + (func (export "i8x16.extract_lane_u/0") (param $a v128) (result i32) (i8x16.extract_lane_u 0 (local.get $a))) + (func (export "i8x16.extract_lane_u/1") (param $a v128) (result i32) (i8x16.extract_lane_u 1 (local.get $a))) + (func (export "i8x16.extract_lane_u/2") (param $a v128) (result i32) (i8x16.extract_lane_u 2 (local.get $a))) + (func (export "i8x16.extract_lane_u/3") (param $a v128) (result i32) (i8x16.extract_lane_u 3 (local.get $a))) + (func (export "i8x16.extract_lane_u/4") (param $a v128) (result i32) (i8x16.extract_lane_u 4 (local.get $a))) + (func (export "i8x16.extract_lane_u/5") (param $a v128) (result i32) (i8x16.extract_lane_u 5 (local.get $a))) + (func (export "i8x16.extract_lane_u/6") (param $a v128) (result i32) (i8x16.extract_lane_u 6 (local.get $a))) + (func (export "i8x16.extract_lane_u/7") (param $a v128) (result i32) (i8x16.extract_lane_u 7 (local.get $a))) + (func (export "i8x16.extract_lane_u/8") (param $a v128) (result i32) (i8x16.extract_lane_u 8 (local.get $a))) + (func (export "i8x16.extract_lane_u/9") (param $a v128) (result i32) (i8x16.extract_lane_u 9 (local.get $a))) + (func (export "i8x16.extract_lane_u/10") (param $a v128) (result i32) (i8x16.extract_lane_u 10 (local.get $a))) + (func (export "i8x16.extract_lane_u/11") (param $a v128) (result i32) (i8x16.extract_lane_u 11 (local.get $a))) + (func (export "i8x16.extract_lane_u/12") (param $a v128) (result i32) (i8x16.extract_lane_u 12 (local.get $a))) + (func (export "i8x16.extract_lane_u/13") (param $a v128) (result i32) (i8x16.extract_lane_u 13 (local.get $a))) + (func (export "i8x16.extract_lane_u/14") (param $a v128) (result i32) (i8x16.extract_lane_u 14 (local.get $a))) + (func (export "i8x16.extract_lane_u/15") (param $a v128) (result i32) (i8x16.extract_lane_u 15 (local.get $a))) + + (func (export "i16x8.extract_lane_s/0") (param $a v128) (result i32) (i16x8.extract_lane_s 0 (local.get $a))) + (func (export "i16x8.extract_lane_s/1") (param $a v128) (result i32) (i16x8.extract_lane_s 1 (local.get $a))) + (func (export "i16x8.extract_lane_s/2") (param $a v128) (result i32) (i16x8.extract_lane_s 2 (local.get $a))) + (func (export "i16x8.extract_lane_s/3") (param $a v128) (result i32) (i16x8.extract_lane_s 3 (local.get $a))) + (func (export "i16x8.extract_lane_s/4") (param $a v128) (result i32) (i16x8.extract_lane_s 4 (local.get $a))) + (func (export "i16x8.extract_lane_s/5") (param $a v128) (result i32) (i16x8.extract_lane_s 5 (local.get $a))) + (func (export "i16x8.extract_lane_s/6") (param $a v128) (result i32) (i16x8.extract_lane_s 6 (local.get $a))) + (func (export "i16x8.extract_lane_s/7") (param $a v128) (result i32) (i16x8.extract_lane_s 7 (local.get $a))) + + (func (export "i16x8.extract_lane_u/0") (param $a v128) (result i32) (i16x8.extract_lane_u 0 (local.get $a))) + (func (export "i16x8.extract_lane_u/1") (param $a v128) (result i32) (i16x8.extract_lane_u 1 (local.get $a))) + (func (export "i16x8.extract_lane_u/2") (param $a v128) (result i32) (i16x8.extract_lane_u 2 (local.get $a))) + (func (export "i16x8.extract_lane_u/3") (param $a v128) (result i32) (i16x8.extract_lane_u 3 (local.get $a))) + (func (export "i16x8.extract_lane_u/4") (param $a v128) (result i32) (i16x8.extract_lane_u 4 (local.get $a))) + (func (export "i16x8.extract_lane_u/5") (param $a v128) (result i32) (i16x8.extract_lane_u 5 (local.get $a))) + (func (export "i16x8.extract_lane_u/6") (param $a v128) (result i32) (i16x8.extract_lane_u 6 (local.get $a))) + (func (export "i16x8.extract_lane_u/7") (param $a v128) (result i32) (i16x8.extract_lane_u 7 (local.get $a))) + + (func (export "i32x4.extract_lane/0") (param $a v128) (result i32) (i32x4.extract_lane 0 (local.get $a))) + (func (export "i32x4.extract_lane/1") (param $a v128) (result i32) (i32x4.extract_lane 1 (local.get $a))) + (func (export "i32x4.extract_lane/2") (param $a v128) (result i32) (i32x4.extract_lane 2 (local.get $a))) + (func (export "i32x4.extract_lane/3") (param $a v128) (result i32) (i32x4.extract_lane 3 (local.get $a))) + + (func (export "i64x2.extract_lane/0") (param $a v128) (result i64) (i64x2.extract_lane 0 (local.get $a))) + (func (export "i64x2.extract_lane/1") (param $a v128) (result i64) (i64x2.extract_lane 1 (local.get $a))) + + (func (export "f32x4.extract_lane/0") (param $a v128) (result f32) (f32x4.extract_lane 0 (local.get $a))) + (func (export "f32x4.extract_lane/1") (param $a v128) (result f32) (f32x4.extract_lane 1 (local.get $a))) + (func (export "f32x4.extract_lane/2") (param $a v128) (result f32) (f32x4.extract_lane 2 (local.get $a))) + (func (export "f32x4.extract_lane/3") (param $a v128) (result f32) (f32x4.extract_lane 3 (local.get $a))) + + (func (export "f64x2.extract_lane/0") (param $a v128) (result f64) (f64x2.extract_lane 0 (local.get $a))) + (func (export "f64x2.extract_lane/1") (param $a v128) (result f64) (f64x2.extract_lane 1 (local.get $a))) +) + +;; *.replace_lane + +(module + (func (export "i8x16.replace_lane/0") (param $a v128) (param $b i32) (result v128) (i8x16.replace_lane 0 (local.get $a) (local.get $b))) + (func (export "i8x16.replace_lane/1") (param $a v128) (param $b i32) (result v128) (i8x16.replace_lane 1 (local.get $a) (local.get $b))) + (func (export "i8x16.replace_lane/2") (param $a v128) (param $b i32) (result v128) (i8x16.replace_lane 2 (local.get $a) (local.get $b))) + (func (export "i8x16.replace_lane/3") (param $a v128) (param $b i32) (result v128) (i8x16.replace_lane 3 (local.get $a) (local.get $b))) + (func (export "i8x16.replace_lane/4") (param $a v128) (param $b i32) (result v128) (i8x16.replace_lane 4 (local.get $a) (local.get $b))) + (func (export "i8x16.replace_lane/5") (param $a v128) (param $b i32) (result v128) (i8x16.replace_lane 5 (local.get $a) (local.get $b))) + (func (export "i8x16.replace_lane/6") (param $a v128) (param $b i32) (result v128) (i8x16.replace_lane 6 (local.get $a) (local.get $b))) + (func (export "i8x16.replace_lane/7") (param $a v128) (param $b i32) (result v128) (i8x16.replace_lane 7 (local.get $a) (local.get $b))) + (func (export "i8x16.replace_lane/8") (param $a v128) (param $b i32) (result v128) (i8x16.replace_lane 8 (local.get $a) (local.get $b))) + (func (export "i8x16.replace_lane/9") (param $a v128) (param $b i32) (result v128) (i8x16.replace_lane 9 (local.get $a) (local.get $b))) + (func (export "i8x16.replace_lane/10") (param $a v128) (param $b i32) (result v128) (i8x16.replace_lane 10 (local.get $a) (local.get $b))) + (func (export "i8x16.replace_lane/11") (param $a v128) (param $b i32) (result v128) (i8x16.replace_lane 11 (local.get $a) (local.get $b))) + (func (export "i8x16.replace_lane/12") (param $a v128) (param $b i32) (result v128) (i8x16.replace_lane 12 (local.get $a) (local.get $b))) + (func (export "i8x16.replace_lane/13") (param $a v128) (param $b i32) (result v128) (i8x16.replace_lane 13 (local.get $a) (local.get $b))) + (func (export "i8x16.replace_lane/14") (param $a v128) (param $b i32) (result v128) (i8x16.replace_lane 14 (local.get $a) (local.get $b))) + (func (export "i8x16.replace_lane/15") (param $a v128) (param $b i32) (result v128) (i8x16.replace_lane 15 (local.get $a) (local.get $b))) + + (func (export "i16x8.replace_lane/0") (param $a v128) (param $b i32) (result v128) (i16x8.replace_lane 0 (local.get $a) (local.get $b))) + (func (export "i16x8.replace_lane/1") (param $a v128) (param $b i32) (result v128) (i16x8.replace_lane 1 (local.get $a) (local.get $b))) + (func (export "i16x8.replace_lane/2") (param $a v128) (param $b i32) (result v128) (i16x8.replace_lane 2 (local.get $a) (local.get $b))) + (func (export "i16x8.replace_lane/3") (param $a v128) (param $b i32) (result v128) (i16x8.replace_lane 3 (local.get $a) (local.get $b))) + (func (export "i16x8.replace_lane/4") (param $a v128) (param $b i32) (result v128) (i16x8.replace_lane 4 (local.get $a) (local.get $b))) + (func (export "i16x8.replace_lane/5") (param $a v128) (param $b i32) (result v128) (i16x8.replace_lane 5 (local.get $a) (local.get $b))) + (func (export "i16x8.replace_lane/6") (param $a v128) (param $b i32) (result v128) (i16x8.replace_lane 6 (local.get $a) (local.get $b))) + (func (export "i16x8.replace_lane/7") (param $a v128) (param $b i32) (result v128) (i16x8.replace_lane 7 (local.get $a) (local.get $b))) + + (func (export "i32x4.replace_lane/0") (param $a v128) (param $b i32) (result v128) (i32x4.replace_lane 0 (local.get $a) (local.get $b))) + (func (export "i32x4.replace_lane/1") (param $a v128) (param $b i32) (result v128) (i32x4.replace_lane 1 (local.get $a) (local.get $b))) + (func (export "i32x4.replace_lane/2") (param $a v128) (param $b i32) (result v128) (i32x4.replace_lane 2 (local.get $a) (local.get $b))) + (func (export "i32x4.replace_lane/3") (param $a v128) (param $b i32) (result v128) (i32x4.replace_lane 3 (local.get $a) (local.get $b))) + + (func (export "i64x2.replace_lane/0") (param $a v128) (param $b i64) (result v128) (i64x2.replace_lane 0 (local.get $a) (local.get $b))) + (func (export "i64x2.replace_lane/1") (param $a v128) (param $b i64) (result v128) (i64x2.replace_lane 1 (local.get $a) (local.get $b))) + + (func (export "f32x4.replace_lane/0") (param $a v128) (param $b f32) (result v128) (f32x4.replace_lane 0 (local.get $a) (local.get $b))) + (func (export "f32x4.replace_lane/1") (param $a v128) (param $b f32) (result v128) (f32x4.replace_lane 1 (local.get $a) (local.get $b))) + (func (export "f32x4.replace_lane/2") (param $a v128) (param $b f32) (result v128) (f32x4.replace_lane 2 (local.get $a) (local.get $b))) + (func (export "f32x4.replace_lane/3") (param $a v128) (param $b f32) (result v128) (f32x4.replace_lane 3 (local.get $a) (local.get $b))) + + (func (export "f64x2.replace_lane/0") (param $a v128) (param $b f64) (result v128) (f64x2.replace_lane 0 (local.get $a) (local.get $b))) + (func (export "f64x2.replace_lane/1") (param $a v128) (param $b f64) (result v128) (f64x2.replace_lane 1 (local.get $a) (local.get $b))) +) + +;; v8x16.shuffle1 + +(module + (func (export "v8x16.shuffle1") (param $elements v128) (param $indices v128) (result v128) (v8x16.shuffle1 (get_local $elements) (get_local $indices))) +) + +(assert_return + (invoke "v8x16.shuffle1" + (v128.const i8x16 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115) + (v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) + ) + (v128.const i8x16 115 114 113 112 111 110 109 108 107 106 105 104 103 102 101 100)) + +(assert_return + (invoke "v8x16.shuffle1" + (v128.const i8x16 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115) + (v128.const i8x16 -1 1 -2 2 -3 3 -4 4 -5 5 -6 6 -7 7 -8 8) + ) + (v128.const i8x16 0 101 0 102 0 103 0 104 0 105 0 106 0 107 0 108)) + +(assert_return + (invoke "v8x16.shuffle1" + (v128.const i8x16 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115) + (v128.const i8x16 9 16 10 17 11 18 12 19 13 20 14 21 15 22 16 23) + ) + (v128.const i8x16 109 0 110 0 111 0 112 0 113 0 114 0 115 0 0 0)) + +;; v8x16.shuffle2_imm + +(module + (func (export "v8x16.shuffle2_imm/0123456789abcdef") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 (local.get $a) (local.get $b))) + (func (export "v8x16.shuffle2_imm/ghijklmnopqrstuv") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 (local.get $a) (local.get $b))) + (func (export "v8x16.shuffle2_imm/vutsrqponmlkjihg") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 (local.get $a) (local.get $b))) + (func (export "v8x16.shuffle2_imm/fedcba9876543210") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 (local.get $a) (local.get $b))) + (func (export "v8x16.shuffle2_imm/0000000000000000") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 (local.get $a) (local.get $b))) + (func (export "v8x16.shuffle2_imm/gggggggggggggggg") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 (local.get $a) (local.get $b))) + (func (export "v8x16.shuffle2_imm/00000000gggggggg") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 0 0 0 0 0 0 0 0 16 16 16 16 16 16 16 16 (local.get $a) (local.get $b))) +) + +;; i*.add + +(module + (func (export "i8x16.add") (param $a v128) (param $b v128) (result v128) (i8x16.add (local.get $a) (local.get $b))) + (func (export "i16x8.add") (param $a v128) (param $b v128) (result v128) (i16x8.add (local.get $a) (local.get $b))) + (func (export "i32x4.add") (param $a v128) (param $b v128) (result v128) (i32x4.add (local.get $a) (local.get $b))) + (func (export "i64x2.add") (param $a v128) (param $b v128) (result v128) (i64x2.add (local.get $a) (local.get $b))) +) + +;; i*.sub + +(module + (func (export "i8x16.sub") (param $a v128) (param $b v128) (result v128) (i8x16.sub (local.get $a) (local.get $b))) + (func (export "i16x8.sub") (param $a v128) (param $b v128) (result v128) (i16x8.sub (local.get $a) (local.get $b))) + (func (export "i32x4.sub") (param $a v128) (param $b v128) (result v128) (i32x4.sub (local.get $a) (local.get $b))) + (func (export "i64x2.sub") (param $a v128) (param $b v128) (result v128) (i64x2.sub (local.get $a) (local.get $b))) +) + +;; i*.mul + +(module + (func (export "i8x16.mul") (param $a v128) (param $b v128) (result v128) (i8x16.mul (local.get $a) (local.get $b))) + (func (export "i16x8.mul") (param $a v128) (param $b v128) (result v128) (i16x8.mul (local.get $a) (local.get $b))) + (func (export "i32x4.mul") (param $a v128) (param $b v128) (result v128) (i32x4.mul (local.get $a) (local.get $b))) +) + +;; i*.neg + +(module + (func (export "i8x16.neg") (param $a v128) (result v128) (i8x16.neg (local.get $a))) + (func (export "i16x8.neg") (param $a v128) (result v128) (i16x8.neg (local.get $a))) + (func (export "i32x4.neg") (param $a v128) (result v128) (i32x4.neg (local.get $a))) + (func (export "i64x2.neg") (param $a v128) (result v128) (i64x2.neg (local.get $a))) +) + +;; i*.add_saturate* + +(module + (func (export "i8x16.add_saturate_s") (param $a v128) (param $b v128) (result v128) (i8x16.add_saturate_s (local.get $a) (local.get $b))) + (func (export "i8x16.add_saturate_u") (param $a v128) (param $b v128) (result v128) (i8x16.add_saturate_u (local.get $a) (local.get $b))) + (func (export "i16x8.add_saturate_s") (param $a v128) (param $b v128) (result v128) (i16x8.add_saturate_s (local.get $a) (local.get $b))) + (func (export "i16x8.add_saturate_u") (param $a v128) (param $b v128) (result v128) (i16x8.add_saturate_u (local.get $a) (local.get $b))) +) + +(assert_return + (invoke "i8x16.add_saturate_s" + (v128.const i8x16 127 126 125 124 123 122 121 120 119 120 121 122 123 124 125 126) + (v128.const i8x16 -7 -6 -5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5 +6 +7 +8)) + (v128.const i8x16 120 120 120 120 120 120 120 120 120 122 124 126 127 127 127 127)) + +;; i*.sub_saturate* + +(module + (func (export "i8x16.sub_saturate_s") (param $a v128) (param $b v128) (result v128) (i8x16.sub_saturate_s (local.get $a) (local.get $b))) + (func (export "i8x16.sub_saturate_u") (param $a v128) (param $b v128) (result v128) (i8x16.sub_saturate_u (local.get $a) (local.get $b))) + (func (export "i16x8.sub_saturate_s") (param $a v128) (param $b v128) (result v128) (i16x8.sub_saturate_s (local.get $a) (local.get $b))) + (func (export "i16x8.sub_saturate_u") (param $a v128) (param $b v128) (result v128) (i16x8.sub_saturate_u (local.get $a) (local.get $b))) +) + +;; v128.and/or/xor/not + +(module + (func (export "v128.and") (param $a v128) (param $b v128) (result v128) (v128.and (local.get $a) (local.get $b))) + (func (export "v128.or") (param $a v128) (param $b v128) (result v128) (v128.or (local.get $a) (local.get $b))) + (func (export "v128.xor") (param $a v128) (param $b v128) (result v128) (v128.xor (local.get $a) (local.get $b))) + (func (export "v128.not") (param $a v128) (result v128) (v128.not (local.get $a) )) +) + +(module (func (export "v128.bitselect") (param $a v128) (param $b v128) (param $c v128) (result v128) (v128.bitselect (local.get $a) (local.get $b) (local.get $c)))) + +(module + (func (export "i8x16.any_true") (param $a v128) (result i32) (i8x16.any_true (local.get $a))) + (func (export "i16x8.any_true") (param $a v128) (result i32) (i16x8.any_true (local.get $a))) + (func (export "i32x4.any_true") (param $a v128) (result i32) (i32x4.any_true (local.get $a))) + (func (export "i64x2.any_true") (param $a v128) (result i32) (i64x2.any_true (local.get $a))) +) + +(module + (func (export "i8x16.all_true") (param $a v128) (result i32) (i8x16.all_true (local.get $a))) + (func (export "i16x8.all_true") (param $a v128) (result i32) (i16x8.all_true (local.get $a))) + (func (export "i32x4.all_true") (param $a v128) (result i32) (i32x4.all_true (local.get $a))) + (func (export "i64x2.all_true") (param $a v128) (result i32) (i64x2.all_true (local.get $a))) +) + +(module + (func (export "i8x16.eq") (param $a v128) (param $b v128) (result v128) (i8x16.eq (local.get $a) (local.get $b))) + (func (export "i16x8.eq") (param $a v128) (param $b v128) (result v128) (i16x8.eq (local.get $a) (local.get $b))) + (func (export "i32x4.eq") (param $a v128) (param $b v128) (result v128) (i32x4.eq (local.get $a) (local.get $b))) + (func (export "f32x4.eq") (param $a v128) (param $b v128) (result v128) (f32x4.eq (local.get $a) (local.get $b))) + (func (export "f64x2.eq") (param $a v128) (param $b v128) (result v128) (f64x2.eq (local.get $a) (local.get $b))) +) + +(module + (func (export "i8x16.ne") (param $a v128) (param $b v128) (result v128) (i8x16.ne (local.get $a) (local.get $b))) + (func (export "i16x8.ne") (param $a v128) (param $b v128) (result v128) (i16x8.ne (local.get $a) (local.get $b))) + (func (export "i32x4.ne") (param $a v128) (param $b v128) (result v128) (i32x4.ne (local.get $a) (local.get $b))) + (func (export "f32x4.ne") (param $a v128) (param $b v128) (result v128) (f32x4.ne (local.get $a) (local.get $b))) + (func (export "f64x2.ne") (param $a v128) (param $b v128) (result v128) (f64x2.ne (local.get $a) (local.get $b))) +) + +(module + (func (export "i8x16.lt_s") (param $a v128) (param $b v128) (result v128) (i8x16.lt_s (local.get $a) (local.get $b))) + (func (export "i8x16.lt_u") (param $a v128) (param $b v128) (result v128) (i8x16.lt_u (local.get $a) (local.get $b))) + (func (export "i16x8.lt_s") (param $a v128) (param $b v128) (result v128) (i16x8.lt_s (local.get $a) (local.get $b))) + (func (export "i16x8.lt_u") (param $a v128) (param $b v128) (result v128) (i16x8.lt_u (local.get $a) (local.get $b))) + (func (export "i32x4.lt_s") (param $a v128) (param $b v128) (result v128) (i32x4.lt_s (local.get $a) (local.get $b))) + (func (export "i32x4.lt_u") (param $a v128) (param $b v128) (result v128) (i32x4.lt_u (local.get $a) (local.get $b))) + (func (export "f32x4.lt") (param $a v128) (param $b v128) (result v128) (f32x4.lt (local.get $a) (local.get $b))) + (func (export "f64x2.lt") (param $a v128) (param $b v128) (result v128) (f64x2.lt (local.get $a) (local.get $b))) +) + +(module + (func (export "i8x16.le_s") (param $a v128) (param $b v128) (result v128) (i8x16.le_s (local.get $a) (local.get $b))) + (func (export "i8x16.le_u") (param $a v128) (param $b v128) (result v128) (i8x16.le_u (local.get $a) (local.get $b))) + (func (export "i16x8.le_s") (param $a v128) (param $b v128) (result v128) (i16x8.le_s (local.get $a) (local.get $b))) + (func (export "i16x8.le_u") (param $a v128) (param $b v128) (result v128) (i16x8.le_u (local.get $a) (local.get $b))) + (func (export "i32x4.le_s") (param $a v128) (param $b v128) (result v128) (i32x4.le_s (local.get $a) (local.get $b))) + (func (export "i32x4.le_u") (param $a v128) (param $b v128) (result v128) (i32x4.le_u (local.get $a) (local.get $b))) + (func (export "f32x4.le") (param $a v128) (param $b v128) (result v128) (f32x4.le (local.get $a) (local.get $b))) + (func (export "f64x2.le") (param $a v128) (param $b v128) (result v128) (f64x2.le (local.get $a) (local.get $b))) +) + +(module + (func (export "i8x16.gt_s") (param $a v128) (param $b v128) (result v128) (i8x16.gt_s (local.get $a) (local.get $b))) + (func (export "i8x16.gt_u") (param $a v128) (param $b v128) (result v128) (i8x16.gt_u (local.get $a) (local.get $b))) + (func (export "i16x8.gt_s") (param $a v128) (param $b v128) (result v128) (i16x8.gt_s (local.get $a) (local.get $b))) + (func (export "i16x8.gt_u") (param $a v128) (param $b v128) (result v128) (i16x8.gt_u (local.get $a) (local.get $b))) + (func (export "i32x4.gt_s") (param $a v128) (param $b v128) (result v128) (i32x4.gt_s (local.get $a) (local.get $b))) + (func (export "i32x4.gt_u") (param $a v128) (param $b v128) (result v128) (i32x4.gt_u (local.get $a) (local.get $b))) + (func (export "f32x4.gt") (param $a v128) (param $b v128) (result v128) (f32x4.gt (local.get $a) (local.get $b))) + (func (export "f64x2.gt") (param $a v128) (param $b v128) (result v128) (f64x2.gt (local.get $a) (local.get $b))) +) + +(module + (func (export "i8x16.ge_s") (param $a v128) (param $b v128) (result v128) (i8x16.ge_s (local.get $a) (local.get $b))) + (func (export "i8x16.ge_u") (param $a v128) (param $b v128) (result v128) (i8x16.ge_u (local.get $a) (local.get $b))) + (func (export "i16x8.ge_s") (param $a v128) (param $b v128) (result v128) (i16x8.ge_s (local.get $a) (local.get $b))) + (func (export "i16x8.ge_u") (param $a v128) (param $b v128) (result v128) (i16x8.ge_u (local.get $a) (local.get $b))) + (func (export "i32x4.ge_s") (param $a v128) (param $b v128) (result v128) (i32x4.ge_s (local.get $a) (local.get $b))) + (func (export "i32x4.ge_u") (param $a v128) (param $b v128) (result v128) (i32x4.ge_u (local.get $a) (local.get $b))) + (func (export "f32x4.ge") (param $a v128) (param $b v128) (result v128) (f32x4.ge (local.get $a) (local.get $b))) + (func (export "f64x2.ge") (param $a v128) (param $b v128) (result v128) (f64x2.ge (local.get $a) (local.get $b))) +) + +(module + (func (export "f32x4.min") (param $a v128) (param $b v128) (result v128) (f32x4.min (local.get $a) (local.get $b))) + (func (export "f64x2.min") (param $a v128) (param $b v128) (result v128) (f64x2.min (local.get $a) (local.get $b))) + (func (export "f32x4.max") (param $a v128) (param $b v128) (result v128) (f32x4.max (local.get $a) (local.get $b))) + (func (export "f64x2.max") (param $a v128) (param $b v128) (result v128) (f64x2.max (local.get $a) (local.get $b))) +) + +(module + (func (export "f32x4.add") (param $a v128) (param $b v128) (result v128) (f32x4.add (local.get $a) (local.get $b))) + (func (export "f64x2.add") (param $a v128) (param $b v128) (result v128) (f64x2.add (local.get $a) (local.get $b))) + (func (export "f32x4.sub") (param $a v128) (param $b v128) (result v128) (f32x4.sub (local.get $a) (local.get $b))) + (func (export "f64x2.sub") (param $a v128) (param $b v128) (result v128) (f64x2.sub (local.get $a) (local.get $b))) + (func (export "f32x4.div") (param $a v128) (param $b v128) (result v128) (f32x4.div (local.get $a) (local.get $b))) + (func (export "f64x2.div") (param $a v128) (param $b v128) (result v128) (f64x2.div (local.get $a) (local.get $b))) + (func (export "f32x4.mul") (param $a v128) (param $b v128) (result v128) (f32x4.mul (local.get $a) (local.get $b))) + (func (export "f64x2.mul") (param $a v128) (param $b v128) (result v128) (f64x2.mul (local.get $a) (local.get $b))) +) + +(module + (func (export "f32x4.neg") (param $a v128) (result v128) (f32x4.neg (local.get $a))) + (func (export "f64x2.neg") (param $a v128) (result v128) (f64x2.neg (local.get $a))) + (func (export "f32x4.abs") (param $a v128) (result v128) (f32x4.abs (local.get $a))) + (func (export "f64x2.abs") (param $a v128) (result v128) (f64x2.abs (local.get $a))) + (func (export "f32x4.sqrt") (param $a v128) (result v128) (f32x4.sqrt (local.get $a))) + (func (export "f64x2.sqrt") (param $a v128) (result v128) (f64x2.sqrt (local.get $a))) +) + +(module + (func (export "f32x4.convert_i32x4_s") (param $a v128) (result v128) (f32x4.convert_i32x4_s (local.get $a))) + (func (export "f32x4.convert_i32x4_u") (param $a v128) (result v128) (f32x4.convert_i32x4_u (local.get $a))) + (func (export "f64x2.convert_i64x2_s") (param $a v128) (result v128) (f64x2.convert_i64x2_s (local.get $a))) + (func (export "f64x2.convert_i64x2_u") (param $a v128) (result v128) (f64x2.convert_i64x2_u (local.get $a))) +) + +;; i32x4.trunc_sat_f32x4_s + +(module (func (export "i32x4.trunc_sat_f32x4_s") (param $a f32) (result v128) (i32x4.trunc_sat_f32x4_s (f32x4.splat (local.get $a))))) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_s" (f32.const 0.0)) + (v128.const i32x4 0 0 0 0)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_s" (f32.const 1.0)) + (v128.const i32x4 1 1 1 1)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_s" (f32.const 1.9)) + (v128.const i32x4 1 1 1 1)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_s" (f32.const 2.0)) + (v128.const i32x4 2 2 2 2)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_s" (f32.const -1.0)) + (v128.const i32x4 -1 -1 -1 -1)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_s" (f32.const -1.9)) + (v128.const i32x4 -1 -1 -1 -1)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_s" (f32.const -2)) + (v128.const i32x4 -2 -2 -2 -2)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_s" (f32.const -2147483648.0)) + (v128.const i32x4 -2147483648 -2147483648 -2147483648 -2147483648)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_s" (f32.const -2147483648.0)) + (v128.const i32x4 -2147483648 -2147483648 -2147483648 -2147483648)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_s" (f32.const -3000000000.0)) + (v128.const i32x4 -2147483648 -2147483648 -2147483648 -2147483648)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_s" (f32.const -inf)) + (v128.const i32x4 -2147483648 -2147483648 -2147483648 -2147483648)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_s" (f32.const +inf)) + (v128.const i32x4 2147483647 2147483647 2147483647 2147483647)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_s" (f32.const -nan)) + (v128.const i32x4 0 0 0 0)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_s" (f32.const +nan)) + (v128.const i32x4 0 0 0 0)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_s" (f32.const nan:0x444444)) + (v128.const i32x4 0 0 0 0)) + +;; i32x4.trunc_sat_f32x4_u + +(module (func (export "i32x4.trunc_sat_f32x4_u") (param $a f32) (result v128) (i32x4.trunc_sat_f32x4_u (f32x4.splat (local.get $a))))) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_u" (f32.const 0.0)) + (v128.const i32x4 0 0 0 0)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_u" (f32.const 1.0)) + (v128.const i32x4 1 1 1 1)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_u" (f32.const 1.9)) + (v128.const i32x4 1 1 1 1)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_u" (f32.const 2.0)) + (v128.const i32x4 2 2 2 2)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_u" (f32.const -1.0)) + (v128.const i32x4 0 0 0 0)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_u" (f32.const -2.0)) + (v128.const i32x4 0 0 0 0)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_u" (f32.const -2147483648.0)) + (v128.const i32x4 0 0 0 0)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_u" (f32.const -inf)) + (v128.const i32x4 0 0 0 0)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_u" (f32.const +inf)) + (v128.const i32x4 0xffffffff 0xffffffff 0xffffffff 0xffffffff)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_u" (f32.const -nan)) + (v128.const i32x4 0 0 0 0)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_u" (f32.const +nan)) + (v128.const i32x4 0 0 0 0)) + +(assert_return + (invoke "i32x4.trunc_sat_f32x4_u" (f32.const nan:0x444444)) + (v128.const i32x4 0 0 0 0)) + +;; i64x2.trunc_sat_f64x2_s + +(module (func (export "i64x2.trunc_sat_f64x2_s") (param $a f64) (result v128) (i64x2.trunc_sat_f64x2_s (f64x2.splat (local.get $a))))) + +;; i64x2.trunc_sat_f64x2_u + +(module (func (export "i64x2.trunc_sat_f64x2_u") (param $a f64) (result v128) (i64x2.trunc_sat_f64x2_u (f64x2.splat (local.get $a))))) + +;; Test that LLVM undef isn't introduced by SIMD shifts greater than the scalar width. + +(module + (memory 1 1 shared) + (func (export "test-simd-shift-mask") (param $v v128) (result i32) + (block $0 + (block $1 + (block $2 + (block $3 + (block $default + ;; If the table index is inferred to be undef, LLVM will branch to an + ;; arbitrary successor of the basic block. + (br_table + $0 $1 $2 $3 + $default + (i32x4.extract_lane 0 (i32x4.shr_s (local.get $v) + (i32.const 32))) + ) + ) + (return (i32.const 100)) + ) + (return (i32.const 3)) + ) + (return (i32.const 2)) + ) + (return (i32.const 1)) + ) + (return (i32.const 0)) + ) +) + +(assert_return (invoke "test-simd-shift-mask" (v128.const i32x4 0 0 0 0)) (i32.const 0)) +(assert_return (invoke "test-simd-shift-mask" (v128.const i32x4 1 0 0 0)) (i32.const 1)) +(assert_return (invoke "test-simd-shift-mask" (v128.const i32x4 2 0 0 0)) (i32.const 2)) +(assert_return (invoke "test-simd-shift-mask" (v128.const i32x4 3 0 0 0)) (i32.const 3)) +(assert_return (invoke "test-simd-shift-mask" (v128.const i32x4 4 0 0 0)) (i32.const 100)) + +;; Test that misaligned SIMD loads/stores don't trap + +(module + (memory 1 1) + (func (export "v128.load align=16") (param $address i32) (result v128) + (v128.load align=16 (local.get $address)) + ) + (func (export "v128.store align=16") (param $address i32) (param $value v128) + (v128.store align=16 (local.get $address) (local.get $value)) + ) +) + +(assert_return (invoke "v128.load align=16" (i32.const 0)) (v128.const i64x2 0 0)) +(assert_return (invoke "v128.load align=16" (i32.const 1)) (v128.const i64x2 0 0)) +(assert_return (invoke "v128.store align=16" (i32.const 1) (v128.const i8x16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16))) +(assert_return (invoke "v128.load align=16" (i32.const 0)) (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)) + +;; v128.const format + +(module (func (result v128) (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15))) +(module (func (result v128) (v128.const i16x8 0 1 2 3 4 5 6 7))) +(module (func (result v128) (v128.const i32x4 0 1 2 3))) +(module (func (result v128) (v128.const i64x2 0 1))) +(module (func (result v128) (v128.const i64x2 -1 -2))) + +(module (func (result v128) (v128.const i32x4 0xa 0xb 0xc 0xd))) +(module (func (result v128) (v128.const i32x4 0xa 0xb 0xc 0xd))) + +(module (func (result v128) (v128.const f32x4 0.0 1.0 2.0 3.0))) +(module (func (result v128) (v128.const f64x2 0.0 1.0))) + +(module (func (result v128) (v128.const f32x4 0 1 2 3))) +(module (func (result v128) (v128.const f32x4 0 1 2 -0x1.0p+10))) + +(assert_invalid + (module (func (result v128) (v128.const i32x4 0.0 1.0 2.0 3.0))) + "expected i32 literal" +) + +(assert_invalid + (module (func (result v128) (v128.const i32 0 1 2 3))) + "expected 'i8x6', 'i16x8', 'i32x4', 'i64x2', 'f32x4', or 'f64x2'" +) +(assert_invalid + (module (func (result v128) (v128.const i16x4 0 1 2 3))) + "expected 'i8x6', 'i16x8', 'i32x4', 'i64x2', 'f32x4', or 'f64x2'" +) +(assert_invalid + (module (func (result v128) (v128.const f32 0 1 2 3))) + "expected 'i8x6', 'i16x8', 'i32x4', 'i64x2', 'f32x4', or 'f64x2'" +) +(assert_invalid + (module (func (result v128) (v128.const 0 1 2 3))) + "expected 'i8x6', 'i16x8', 'i32x4', 'i64x2', 'f32x4', or 'f64x2'" +) From 3be6a024aa8e7ca92b14c0536badb91054b91d30 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Thu, 18 Jul 2019 12:52:59 -0700 Subject: [PATCH 19/37] Fix bugs in V128 support based on results from testing against simd spec test. These is one test failure remaining with V128 global variables. * Fix trunc_sat. We need both the largest float that can be converted to an int and the largest int, they are not the same number. * Implement calling of functions that take V128 by passing in two i64's. * Improve support for V128 in spectests. Parse binary modules with the same features as the outer spectest. Fix compilation error involving Result in emitted .rs file. Handle V128 in more cases when producing .rs file. Parse the wast script with SIMD enabled. * Adjust the WAVM spectest so that it parses with WABT and mostly passes with wasmer. Wabt is particular about ints not having decimal places and floats having decimal places. Wasmer does not support mutable globals or shared memory. Tests of shuffles are disabled. Some assert_invalid tests that wabt won't even parse are disabled. --- lib/llvm-backend/src/code.rs | 68 ++++++--- lib/llvm-backend/src/trampolines.rs | 7 +- lib/runtime-core/src/instance.rs | 43 ++++-- lib/runtime-core/src/parse.rs | 3 + lib/spectests/build/spectests.rs | 20 ++- lib/spectests/spectests/simd.wast | 223 ++++++++++++++-------------- 6 files changed, 220 insertions(+), 144 deletions(-) diff --git a/lib/llvm-backend/src/code.rs b/lib/llvm-backend/src/code.rs index 1ce65eba442..8c41e55c9c7 100644 --- a/lib/llvm-backend/src/code.rs +++ b/lib/llvm-backend/src/code.rs @@ -92,6 +92,8 @@ fn trunc_sat( ivec_ty: VectorType, lower_bound: u64, // Exclusive (lowest representable value) upper_bound: u64, // Exclusive (greatest representable value) + int_min_value: u64, + int_max_value: u64, value: IntValue, name: &str, ) -> IntValue { @@ -102,10 +104,27 @@ fn trunc_sat( // lanes that need to saturate to min. // d) Use vector select (not shuffle) to pick from either the // splat vector or the input vector depending on whether the - // comparison indicates that we have an unrepresentable value. + // comparison indicates that we have an unrepresentable value. Replace + // unrepresentable values with zero. // e) Now that the value is safe, fpto[su]i it. + // f) Use our previous comparison results to replace certain zeros with + // int_min or int_max. - let is_signed = lower_bound != 0; + let is_signed = int_min_value != 0; + let int_min_value = splat_vector( + builder, + intrinsics, + ivec_ty.get_element_type().into_int_type().const_int(int_min_value, is_signed).as_basic_value_enum(), + ivec_ty, + "", + ); + let int_max_value = splat_vector( + builder, + intrinsics, + ivec_ty.get_element_type().into_int_type().const_int(int_max_value, is_signed).as_basic_value_enum(), + ivec_ty, + "", + ); let lower_bound = if is_signed { builder.build_signed_int_to_float( ivec_ty @@ -163,23 +182,25 @@ fn trunc_sat( fvec_ty, "", ); - let nan_cmp = builder.build_float_compare(FloatPredicate::UNE, value, value, ""); - let underflow_cmp = builder.build_float_compare(FloatPredicate::UGT, value, upper_bound, ""); - let overflow_cmp = builder.build_float_compare(FloatPredicate::ULT, value, lower_bound, ""); + let nan_cmp = builder.build_float_compare(FloatPredicate::UNO, value, zero, "nan"); + let above_upper_bound_cmp = builder.build_float_compare(FloatPredicate::OGT, value, upper_bound, "above_upper_bound"); + let below_lower_bound_cmp = builder.build_float_compare(FloatPredicate::OLT, value, lower_bound, "below_lower_bound"); + let not_representable = builder + .build_or(builder.build_or(nan_cmp, above_upper_bound_cmp, ""), below_lower_bound_cmp, "not_representable_as_int"); let value = builder - .build_select(nan_cmp, zero, value, "") + .build_select(not_representable, zero, value, "safe_to_convert") .into_vector_value(); + let value = if is_signed { + builder.build_float_to_signed_int(value, ivec_ty, "as_int") + } else { + builder.build_float_to_unsigned_int(value, ivec_ty, "as_int") + }; let value = builder - .build_select(underflow_cmp, lower_bound, value, "") + .build_select(above_upper_bound_cmp, int_max_value, value, "") .into_vector_value(); - let value = builder - .build_select(overflow_cmp, upper_bound, value, "") + let res = builder + .build_select(below_lower_bound_cmp, int_min_value, value, name) .into_vector_value(); - let res = if is_signed { - builder.build_float_to_signed_int(value, ivec_ty, name) - } else { - builder.build_float_to_unsigned_int(value, ivec_ty, name) - }; builder .build_bitcast(res, intrinsics.i128_ty, "") .into_int_value() @@ -3110,6 +3131,8 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { intrinsics, intrinsics.f32x4_ty, intrinsics.i32x4_ty, + -2147480000i32 as u32 as u64, + 2147480000, std::i32::MIN as u64, std::i32::MAX as u64, v, @@ -3124,6 +3147,8 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { intrinsics, intrinsics.f32x4_ty, intrinsics.i32x4_ty, + 0, + 4294960000, std::u32::MIN as u64, std::u32::MAX as u64, v, @@ -3140,6 +3165,8 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { intrinsics.i64x2_ty, std::i64::MIN as u64, std::i64::MAX as u64, + std::i64::MIN as u64, + std::i64::MAX as u64, v, &state.var_name(), ); @@ -3154,6 +3181,8 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { intrinsics.i64x2_ty, std::u64::MIN, std::u64::MAX, + std::u64::MIN, + std::u64::MAX, v, &state.var_name(), ); @@ -4085,16 +4114,19 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let v2 = builder .build_bitcast(v2, intrinsics.i8x16_ty, "") .into_vector_value(); + let lanes = intrinsics.i32_ty.const_int(16, false); let mut res = intrinsics.i8x16_ty.get_undef(); for i in 0..15 { let idx = builder - .build_extract_element(v2, intrinsics.i32_ty.const_int(i, false), "") + .build_extract_element(v2, intrinsics.i32_ty.const_int(i, false), "idx") .into_int_value(); - let idx = builder.build_and(idx, intrinsics.i32_ty.const_int(15, false), ""); - let elem = builder.build_extract_element(v1, idx, ""); + let idx_out_of_range = builder.build_int_compare(IntPredicate::UGE, idx, lanes, "idx_out_of_range"); + let idx_clamped = builder.build_select(idx_out_of_range, intrinsics.i32_zero, idx, "idx_clamped").into_int_value(); + let elem = builder.build_extract_element(v1, idx_clamped, "elem").into_int_value(); + let elem_or_zero = builder.build_select(idx_out_of_range, intrinsics.i32_zero, elem, "elem_or_zero"); res = builder.build_insert_element( res, - elem, + elem_or_zero, intrinsics.i32_ty.const_int(i, false), "", ); diff --git a/lib/llvm-backend/src/trampolines.rs b/lib/llvm-backend/src/trampolines.rs index 95a99223c9a..95fd676b952 100644 --- a/lib/llvm-backend/src/trampolines.rs +++ b/lib/llvm-backend/src/trampolines.rs @@ -78,7 +78,8 @@ fn generate_trampoline( let mut args_vec = Vec::with_capacity(func_sig.params().len() + 1); args_vec.push(vmctx_ptr); - for (i, param_ty) in func_sig.params().iter().enumerate() { + let mut i = 0; + for param_ty in func_sig.params().iter() { let index = intrinsics.i32_ty.const_int(i as _, false); let item_pointer = unsafe { builder.build_in_bounds_gep(args_ptr, &[index], "arg_ptr") }; @@ -89,6 +90,10 @@ fn generate_trampoline( let arg = builder.build_load(typed_item_pointer, "arg"); args_vec.push(arg); + i = i + 1; + if *param_ty == Type::V128 { + i = i + 1; + } } let call_site = builder.build_call(func_ptr, &args_vec, "call"); diff --git a/lib/runtime-core/src/instance.rs b/lib/runtime-core/src/instance.rs index d2a6c04e48a..8627aff340f 100644 --- a/lib/runtime-core/src/instance.rs +++ b/lib/runtime-core/src/instance.rs @@ -519,6 +519,7 @@ fn call_func_with_index( let signature = &info.signatures[sig_index]; let num_results = signature.returns().len(); + let num_results = num_results + signature.returns().iter().filter(|&&ty| ty == Type::V128).count(); rets.reserve(num_results); if !signature.check_param_value_types(args) { @@ -544,16 +545,24 @@ fn call_func_with_index( } }; - let raw_args: SmallVec<[u64; 8]> = args - .iter() - .map(|v| match v { - Value::I32(i) => *i as u64, - Value::I64(i) => *i as u64, - Value::F32(f) => f.to_bits() as u64, - Value::F64(f) => f.to_bits(), - Value::V128(_) => unimplemented!(), - }) - .collect(); + let mut raw_args: SmallVec<[u64; 8]> = SmallVec::new(); + for v in args { + match v { + Value::I32(i) => { raw_args.push(*i as u64); } + Value::I64(i) => { raw_args.push(*i as u64); } + Value::F32(f) => { raw_args.push(f.to_bits() as u64); } + Value::F64(f) => { raw_args.push(f.to_bits() as u64); } + Value::V128(v) => { + let bytes = v.to_le_bytes(); + let mut lo = [0u8; 8]; + lo.clone_from_slice(&bytes[0 .. 8]); + raw_args.push(u64::from_le_bytes(lo)); + let mut hi = [0u8; 8]; + hi.clone_from_slice(&bytes[8 .. 16]); + raw_args.push(u64::from_le_bytes(hi)); + } + } + } let Wasm { trampoline, @@ -596,7 +605,7 @@ fn call_func_with_index( Type::I64 => Value::I64(raw as i64), Type::F32 => Value::F32(f32::from_bits(raw as u32)), Type::F64 => Value::F64(f64::from_bits(raw)), - Type::V128 => unimplemented!(), + _ => unreachable!(), }; match signature.returns() { @@ -604,6 +613,18 @@ fn call_func_with_index( run_wasm(0 as *mut u64)?; Ok(()) } + &[Type::V128] => { + let mut result = [0u64; 2]; + + run_wasm(result.as_mut_ptr())?; + + let mut bytes = [0u8; 16]; + let lo = result[0].to_le_bytes(); + let hi = result[1].to_le_bytes(); + for i in 0..8 { bytes[i] = lo[i]; bytes[i + 8] = hi[i]; } + rets.push(Value::V128(u128::from_le_bytes(bytes))); + Ok(()) + } &[ty] => { let mut result = 0u64; diff --git a/lib/runtime-core/src/parse.rs b/lib/runtime-core/src/parse.rs index 0f365ac2e47..282168d26f2 100644 --- a/lib/runtime-core/src/parse.rs +++ b/lib/runtime-core/src/parse.rs @@ -427,6 +427,9 @@ fn eval_init_expr(op: &Operator) -> Result { Operator::F64Const { value } => { Initializer::Const(Value::F64(f64::from_bits(value.bits()))) } + Operator::V128Const { value } => { + Initializer::Const(Value::V128(u128::from_le_bytes(*value.bytes()))) + } _ => { return Err(BinaryReaderError { message: "init expr evaluation failed: unsupported opcode", diff --git a/lib/spectests/build/spectests.rs b/lib/spectests/build/spectests.rs index 5505f51a3ea..0da6b130e94 100644 --- a/lib/spectests/build/spectests.rs +++ b/lib/spectests/build/spectests.rs @@ -6,7 +6,7 @@ use std::fs::File; use std::path::PathBuf; use std::{env, fs, io::Write}; use wabt::script::{Action, Command, CommandKind, ModuleBinary, ScriptParser, Value}; -use wabt::wasm2wat; +use wabt::{Features, wasm2wat_with_features}; static BANNER: &str = "// Rust test file autogenerated with cargo build (build/spectests.rs). // Please do NOT modify it by hand, as it will be reset on next build.\n"; @@ -99,7 +99,7 @@ static IMPORT_MODULE: &str = r#" fn wat2wasm>( source: S, -) -> Result, WabtError> { +) -> std::result::Result, WabtError> { let mut features = wabt::Features::new(); features.enable_simd(); wabt::wat2wasm_with_features(source, features) @@ -131,7 +131,9 @@ fn get_compiler() -> impl Compiler { } pub fn generate_imports() -> ImportObject { - let wasm_binary = wat2wasm(IMPORT_MODULE.as_bytes()).expect("WAST not valid or malformed"); + let mut features = wabt::Features::new(); + features.enable_simd(); + let wasm_binary = wat2wasm_with_features(IMPORT_MODULE.as_bytes(), features).expect("WAST not valid or malformed"); let module = wasmer_runtime_core::compile_with(&wasm_binary[..], &get_compiler()) .expect("WASM can't be compiled"); let instance = module @@ -199,6 +201,7 @@ fn wabt2rust_type(v: &Value) -> String { Value::I64(_v) => format!("i64"), Value::F32(_v) => format!("f32"), Value::F64(_v) => format!("f64"), + Value::V128(_v) => format!("u128"), } } @@ -208,6 +211,7 @@ fn wabt2rust_type_destructure(v: &Value, placeholder: &str) -> String { Value::I64(_v) => format!("Value::I64({})", placeholder), Value::F32(_v) => format!("Value::F32({})", placeholder), Value::F64(_v) => format!("Value::F64({})", placeholder), + Value::V128(_v) => format!("Value::V128({})", placeholder), } } @@ -251,6 +255,7 @@ fn wabt2rust_value_bare(v: &Value) -> String { format!("{:?}", v) } } + Value::V128(v) => format!("{:?} as u128", v), } } @@ -285,6 +290,7 @@ fn wabt2rust_value(v: &Value) -> String { format!("Value::F64(({:?}f64))", v) } } + Value::V128(v) => format!("Value::V128({:?} as u128)", v), } } @@ -301,7 +307,9 @@ impl WastTestGenerator { fn new(path: &PathBuf) -> Self { let filename = path.file_name().unwrap().to_str().unwrap(); let source = fs::read(&path).unwrap(); - let script: ScriptParser = ScriptParser::from_source_and_name(&source, filename) + let mut features = wabt::Features::new(); + features.enable_simd(); + let script: ScriptParser = ScriptParser::from_source_and_name_with_features(&source, filename, features) .expect(&format!("Failed to parse script {}", &filename)); let buffer = String::new(); WastTestGenerator { @@ -383,7 +391,9 @@ fn test_module_{}() {{ fn visit_module(&mut self, module: &ModuleBinary, _name: &Option) { let wasm_binary: Vec = module.clone().into_vec(); - let wast_string = wasm2wat(wasm_binary).expect("Can't convert back to wasm"); + let mut features = Features::new(); + features.enable_simd(); + let wast_string = wasm2wat_with_features(wasm_binary, features).expect("Can't convert back to wasm"); let last_module = self.last_module; self.flush_module_calls(last_module); self.last_module = self.last_module + 1; diff --git a/lib/spectests/spectests/simd.wast b/lib/spectests/spectests/simd.wast index 6ca3f89e615..65e95a6cbf5 100644 --- a/lib/spectests/spectests/simd.wast +++ b/lib/spectests/spectests/simd.wast @@ -1,56 +1,58 @@ ;; Code tests taken from ;; https://github.com/WAVM/WAVM/blob/2b919c20a02624af9758e9ddd0b9b5726c973e4f/Test/simd.wast - -;; All attributions reserved for WAVM and it's author Andrew -;; https://github.com/WAVM/WAVM - +;; ;; WAVM test spec license: Apache 2.0 ;; https://github.com/WAVM/WAVM/blob/2b919c20a02624af9758e9ddd0b9b5726c973e4f/Test/spec/LICENSE +;; +;; Modified by Wasmer to parse with the wabt spec tests parser and to pass with +;; Wasmer. ;; v128 globals -(module $M - (global (export "a") v128 (v128.const f32x4 0 1 2 3)) - (global (export "b") (mut v128) (v128.const f32x4 4 5 6 7)) -) -(register "M" $M) +;; wasmer silently doesn't implement (register) yet +;;(module $M +;; (global (export "a") v128 (v128.const f32x4 0.0 1.0 2.0 3.0)) +;; Wasmer does not yet support mutable global variables. +;; (global (export "b") (mut v128) (v128.const f32x4 4.0 5.0 6.0 7.0)) +;;) +;;(register "M" $M) (module - (global $a (import "M" "a") v128) - (global $b (import "M" "b") (mut v128)) +;; (global $a (import "M" "a") v128) +;; (global $b (import "M" "b") (mut v128)) - (global $c v128 (global.get $a)) +;; (global $c v128 (global.get $a)) (global $d v128 (v128.const i32x4 8 9 10 11)) - (global $e (mut v128) (global.get $a)) - (global $f (mut v128) (v128.const i32x4 12 13 14 15)) +;; (global $e (mut v128) (global.get $a)) +;; (global $f (mut v128) (v128.const i32x4 12 13 14 15)) - (func (export "get-a") (result v128) (global.get $a)) - (func (export "get-b") (result v128) (global.get $b)) - (func (export "get-c") (result v128) (global.get $c)) +;; (func (export "get-a") (result v128) (global.get $a)) +;; (func (export "get-b") (result v128) (global.get $b)) +;; (func (export "get-c") (result v128) (global.get $c)) (func (export "get-d") (result v128) (global.get $d)) - (func (export "get-e") (result v128) (global.get $e)) - (func (export "get-f") (result v128) (global.get $f)) +;; (func (export "get-e") (result v128) (global.get $e)) +;; (func (export "get-f") (result v128) (global.get $f)) - (func (export "set-b") (param $value v128) (global.set $b (local.get $value))) - (func (export "set-e") (param $value v128) (global.set $e (local.get $value))) - (func (export "set-f") (param $value v128) (global.set $f (local.get $value))) +;; (func (export "set-b") (param $value v128) (global.set $b (local.get $value))) +;; (func (export "set-e") (param $value v128) (global.set $e (local.get $value))) +;; (func (export "set-f") (param $value v128) (global.set $f (local.get $value))) ) -(assert_return (invoke "get-a") (v128.const f32x4 0 1 2 3)) -(assert_return (invoke "get-b") (v128.const f32x4 4 5 6 7)) -(assert_return (invoke "get-c") (v128.const f32x4 0 1 2 3)) +;;(assert_return (invoke "get-a") (v128.const f32x4 0.0 1.0 2.0 3.0)) +;;(assert_return (invoke "get-b") (v128.const f32x4 4.0 5.0 6.0 7.0)) +;;(assert_return (invoke "get-c") (v128.const f32x4 0.0 1.0 2.0 3.0)) (assert_return (invoke "get-d") (v128.const i32x4 8 9 10 11)) -(assert_return (invoke "get-e") (v128.const f32x4 0 1 2 3)) -(assert_return (invoke "get-f") (v128.const i32x4 12 13 14 15)) - -(invoke "set-b" (v128.const f64x2 nan:0x1 nan:0x2)) -(assert_return (invoke "get-b") (v128.const f64x2 nan:0x1 nan:0x2)) - -(invoke "set-e" (v128.const f64x2 -nan:0x3 +inf)) -(assert_return (invoke "get-e") (v128.const f64x2 -nan:0x3 +inf)) - -(invoke "set-f" (v128.const f32x4 -inf +3.14 10.0e30 +nan:0x42)) -(assert_return (invoke "get-f") (v128.const f32x4 -inf +3.14 10.0e30 +nan:0x42)) +;;(assert_return (invoke "get-e") (v128.const f32x4 0.0 1.0 2.0 3.0)) +;;(assert_return (invoke "get-f") (v128.const i32x4 12 13 14 15)) + +;;(invoke "set-b" (v128.const f64x2 nan:0x1 nan:0x2)) +;;(assert_return (invoke "get-b") (v128.const f64x2 nan:0x1 nan:0x2)) +;; +;;(invoke "set-e" (v128.const f64x2 -nan:0x3 +inf)) +;;(assert_return (invoke "get-e") (v128.const f64x2 -nan:0x3 +inf)) +;; +;;(invoke "set-f" (v128.const f32x4 -inf +3.14 10.0e30 +nan:0x42)) +;;(assert_return (invoke "get-f") (v128.const f32x4 -inf +3.14 10.0e30 +nan:0x42)) (assert_invalid (module (global v128 (i32.const 0))) "invalid initializer expression") (assert_invalid (module (global v128 (i64.const 0))) "invalid initializer expression") @@ -246,43 +248,43 @@ ) ;; v8x16.shuffle1 - -(module - (func (export "v8x16.shuffle1") (param $elements v128) (param $indices v128) (result v128) (v8x16.shuffle1 (get_local $elements) (get_local $indices))) -) - -(assert_return - (invoke "v8x16.shuffle1" - (v128.const i8x16 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115) - (v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) - ) - (v128.const i8x16 115 114 113 112 111 110 109 108 107 106 105 104 103 102 101 100)) - -(assert_return - (invoke "v8x16.shuffle1" - (v128.const i8x16 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115) - (v128.const i8x16 -1 1 -2 2 -3 3 -4 4 -5 5 -6 6 -7 7 -8 8) - ) - (v128.const i8x16 0 101 0 102 0 103 0 104 0 105 0 106 0 107 0 108)) - -(assert_return - (invoke "v8x16.shuffle1" - (v128.const i8x16 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115) - (v128.const i8x16 9 16 10 17 11 18 12 19 13 20 14 21 15 22 16 23) - ) - (v128.const i8x16 109 0 110 0 111 0 112 0 113 0 114 0 115 0 0 0)) +;; +;;(module +;; (func (export "v8x16.shuffle1") (param $elements v128) (param $indices v128) (result v128) (v8x16.shuffle1 (get_local $elements) (get_local $indices))) +;;) +;; +;;(assert_return +;; (invoke "v8x16.shuffle1" +;; (v128.const i8x16 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115) +;; (v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) +;; ) +;; (v128.const i8x16 115 114 113 112 111 110 109 108 107 106 105 104 103 102 101 100)) +;; +;;(assert_return +;; (invoke "v8x16.shuffle1" +;; (v128.const i8x16 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115) +;; (v128.const i8x16 -1 1 -2 2 -3 3 -4 4 -5 5 -6 6 -7 7 -8 8) +;; ) +;; (v128.const i8x16 0 101 0 102 0 103 0 104 0 105 0 106 0 107 0 108)) +;; +;;(assert_return +;; (invoke "v8x16.shuffle1" +;; (v128.const i8x16 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115) +;; (v128.const i8x16 9 16 10 17 11 18 12 19 13 20 14 21 15 22 16 23) +;; ) +;; (v128.const i8x16 109 0 110 0 111 0 112 0 113 0 114 0 115 0 0 0)) ;; v8x16.shuffle2_imm - -(module - (func (export "v8x16.shuffle2_imm/0123456789abcdef") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 (local.get $a) (local.get $b))) - (func (export "v8x16.shuffle2_imm/ghijklmnopqrstuv") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 (local.get $a) (local.get $b))) - (func (export "v8x16.shuffle2_imm/vutsrqponmlkjihg") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 (local.get $a) (local.get $b))) - (func (export "v8x16.shuffle2_imm/fedcba9876543210") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 (local.get $a) (local.get $b))) - (func (export "v8x16.shuffle2_imm/0000000000000000") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 (local.get $a) (local.get $b))) - (func (export "v8x16.shuffle2_imm/gggggggggggggggg") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 (local.get $a) (local.get $b))) - (func (export "v8x16.shuffle2_imm/00000000gggggggg") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 0 0 0 0 0 0 0 0 16 16 16 16 16 16 16 16 (local.get $a) (local.get $b))) -) +;; +;;(module +;; (func (export "v8x16.shuffle2_imm/0123456789abcdef") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 (local.get $a) (local.get $b))) +;; (func (export "v8x16.shuffle2_imm/ghijklmnopqrstuv") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 (local.get $a) (local.get $b))) +;; (func (export "v8x16.shuffle2_imm/vutsrqponmlkjihg") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 (local.get $a) (local.get $b))) +;; (func (export "v8x16.shuffle2_imm/fedcba9876543210") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 (local.get $a) (local.get $b))) +;; (func (export "v8x16.shuffle2_imm/0000000000000000") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 (local.get $a) (local.get $b))) +;; (func (export "v8x16.shuffle2_imm/gggggggggggggggg") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 (local.get $a) (local.get $b))) +;; (func (export "v8x16.shuffle2_imm/00000000gggggggg") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 0 0 0 0 0 0 0 0 16 16 16 16 16 16 16 16 (local.get $a) (local.get $b))) +;;) ;; i*.add @@ -481,15 +483,15 @@ (assert_return (invoke "i32x4.trunc_sat_f32x4_s" (f32.const 2.0)) (v128.const i32x4 2 2 2 2)) - + (assert_return (invoke "i32x4.trunc_sat_f32x4_s" (f32.const -1.0)) (v128.const i32x4 -1 -1 -1 -1)) - + (assert_return (invoke "i32x4.trunc_sat_f32x4_s" (f32.const -1.9)) (v128.const i32x4 -1 -1 -1 -1)) - + (assert_return (invoke "i32x4.trunc_sat_f32x4_s" (f32.const -2)) (v128.const i32x4 -2 -2 -2 -2)) @@ -505,11 +507,11 @@ (assert_return (invoke "i32x4.trunc_sat_f32x4_s" (f32.const -3000000000.0)) (v128.const i32x4 -2147483648 -2147483648 -2147483648 -2147483648)) - + (assert_return (invoke "i32x4.trunc_sat_f32x4_s" (f32.const -inf)) (v128.const i32x4 -2147483648 -2147483648 -2147483648 -2147483648)) - + (assert_return (invoke "i32x4.trunc_sat_f32x4_s" (f32.const +inf)) (v128.const i32x4 2147483647 2147483647 2147483647 2147483647)) @@ -517,11 +519,11 @@ (assert_return (invoke "i32x4.trunc_sat_f32x4_s" (f32.const -nan)) (v128.const i32x4 0 0 0 0)) - + (assert_return (invoke "i32x4.trunc_sat_f32x4_s" (f32.const +nan)) (v128.const i32x4 0 0 0 0)) - + (assert_return (invoke "i32x4.trunc_sat_f32x4_s" (f32.const nan:0x444444)) (v128.const i32x4 0 0 0 0)) @@ -545,7 +547,7 @@ (assert_return (invoke "i32x4.trunc_sat_f32x4_u" (f32.const 2.0)) (v128.const i32x4 2 2 2 2)) - + (assert_return (invoke "i32x4.trunc_sat_f32x4_u" (f32.const -1.0)) (v128.const i32x4 0 0 0 0)) @@ -553,15 +555,15 @@ (assert_return (invoke "i32x4.trunc_sat_f32x4_u" (f32.const -2.0)) (v128.const i32x4 0 0 0 0)) - + (assert_return (invoke "i32x4.trunc_sat_f32x4_u" (f32.const -2147483648.0)) (v128.const i32x4 0 0 0 0)) - + (assert_return (invoke "i32x4.trunc_sat_f32x4_u" (f32.const -inf)) (v128.const i32x4 0 0 0 0)) - + (assert_return (invoke "i32x4.trunc_sat_f32x4_u" (f32.const +inf)) (v128.const i32x4 0xffffffff 0xffffffff 0xffffffff 0xffffffff)) @@ -569,11 +571,11 @@ (assert_return (invoke "i32x4.trunc_sat_f32x4_u" (f32.const -nan)) (v128.const i32x4 0 0 0 0)) - + (assert_return (invoke "i32x4.trunc_sat_f32x4_u" (f32.const +nan)) (v128.const i32x4 0 0 0 0)) - + (assert_return (invoke "i32x4.trunc_sat_f32x4_u" (f32.const nan:0x444444)) (v128.const i32x4 0 0 0 0)) @@ -589,7 +591,9 @@ ;; Test that LLVM undef isn't introduced by SIMD shifts greater than the scalar width. (module - (memory 1 1 shared) +;; wabt says "memories may not be shared" +;; (memory 1 1 shared) + (memory 1 1) (func (export "test-simd-shift-mask") (param $v v128) (result i32) (block $0 (block $1 @@ -654,27 +658,28 @@ (module (func (result v128) (v128.const f32x4 0.0 1.0 2.0 3.0))) (module (func (result v128) (v128.const f64x2 0.0 1.0))) -(module (func (result v128) (v128.const f32x4 0 1 2 3))) -(module (func (result v128) (v128.const f32x4 0 1 2 -0x1.0p+10))) - -(assert_invalid - (module (func (result v128) (v128.const i32x4 0.0 1.0 2.0 3.0))) - "expected i32 literal" -) - -(assert_invalid - (module (func (result v128) (v128.const i32 0 1 2 3))) - "expected 'i8x6', 'i16x8', 'i32x4', 'i64x2', 'f32x4', or 'f64x2'" -) -(assert_invalid - (module (func (result v128) (v128.const i16x4 0 1 2 3))) - "expected 'i8x6', 'i16x8', 'i32x4', 'i64x2', 'f32x4', or 'f64x2'" -) -(assert_invalid - (module (func (result v128) (v128.const f32 0 1 2 3))) - "expected 'i8x6', 'i16x8', 'i32x4', 'i64x2', 'f32x4', or 'f64x2'" -) -(assert_invalid - (module (func (result v128) (v128.const 0 1 2 3))) - "expected 'i8x6', 'i16x8', 'i32x4', 'i64x2', 'f32x4', or 'f64x2'" -) +(module (func (result v128) (v128.const f32x4 0.0 1.0 2.0 3.0))) +(module (func (result v128) (v128.const f32x4 0.0 1.0 2.0 -0x1.0p+10))) + +;; wabt rejects this as invalid and won't even build a spectests json out of it. +;;(assert_invalid +;; (module (func (result v128) (v128.const i32x4 0.0 1.0 2.0 3.0))) +;; "expected i32 literal" +;;) +;; +;;(assert_invalid +;; (module (func (result v128) (v128.const i32 0 1 2 3))) +;; "expected 'i8x6', 'i16x8', 'i32x4', 'i64x2', 'f32x4', or 'f64x2'" +;;) +;;(assert_invalid +;; (module (func (result v128) (v128.const i16x4 0 1 2 3))) +;; "expected 'i8x6', 'i16x8', 'i32x4', 'i64x2', 'f32x4', or 'f64x2'" +;;) +;;(assert_invalid +;; (module (func (result v128) (v128.const f32 0 1 2 3))) +;; "expected 'i8x6', 'i16x8', 'i32x4', 'i64x2', 'f32x4', or 'f64x2'" +;;) +;;(assert_invalid +;; (module (func (result v128) (v128.const 0 1 2 3))) +;; "expected 'i8x6', 'i16x8', 'i32x4', 'i64x2', 'f32x4', or 'f64x2'" +;;) From ea93b6816544141bc4a9d00fafa882b40907f693 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Thu, 18 Jul 2019 13:39:41 -0700 Subject: [PATCH 20/37] Bump size of global up to 128 bits. Fixes last spec test failure from the WAVM SIMD spec test. --- lib/runtime-core/src/global.rs | 24 ++++++++-------- lib/runtime-core/src/loader.rs | 51 +++++++++++++++++++++------------- lib/runtime-core/src/state.rs | 6 ++-- lib/runtime-core/src/types.rs | 12 ++++---- lib/runtime-core/src/vm.rs | 2 +- 5 files changed, 54 insertions(+), 41 deletions(-) diff --git a/lib/runtime-core/src/global.rs b/lib/runtime-core/src/global.rs index 16a75d6a70a..8d421253112 100644 --- a/lib/runtime-core/src/global.rs +++ b/lib/runtime-core/src/global.rs @@ -46,11 +46,11 @@ impl Global { let local_global = vm::LocalGlobal { data: match value { - Value::I32(x) => x as u64, - Value::I64(x) => x as u64, - Value::F32(x) => x.to_bits() as u64, - Value::F64(x) => x.to_bits(), - Value::V128(_) => unimplemented!(), + Value::I32(x) => x as u128, + Value::I64(x) => x as u128, + Value::F32(x) => x.to_bits() as u128, + Value::F64(x) => x.to_bits() as u128, + Value::V128(x) => x, }, }; @@ -76,11 +76,11 @@ impl Global { if self.desc.ty == value.ty() { let local_global = vm::LocalGlobal { data: match value { - Value::I32(x) => x as u64, - Value::I64(x) => x as u64, - Value::F32(x) => x.to_bits() as u64, - Value::F64(x) => x.to_bits(), - Value::V128(_) => unimplemented!(), + Value::I32(x) => x as u128, + Value::I64(x) => x as u128, + Value::F32(x) => x.to_bits() as u128, + Value::F64(x) => x.to_bits() as u128, + Value::V128(x) => x, }, }; *self.storage.borrow_mut() = local_global; @@ -100,8 +100,8 @@ impl Global { Type::I32 => Value::I32(data as i32), Type::I64 => Value::I64(data as i64), Type::F32 => Value::F32(f32::from_bits(data as u32)), - Type::F64 => Value::F64(f64::from_bits(data)), - Type::V128 => unimplemented!(), + Type::F64 => Value::F64(f64::from_bits(data as u64)), + Type::V128 => Value::V128(data), } } diff --git a/lib/runtime-core/src/loader.rs b/lib/runtime-core/src/loader.rs index 5ef127ec728..b02e9e8594d 100644 --- a/lib/runtime-core/src/loader.rs +++ b/lib/runtime-core/src/loader.rs @@ -1,4 +1,4 @@ -use crate::{backend::RunnableModule, module::ModuleInfo, types::Value, vm::Ctx}; +use crate::{backend::RunnableModule, module::ModuleInfo, types::Type, types::Value, vm::Ctx}; #[cfg(unix)] use libc::{mmap, mprotect, munmap, MAP_ANON, MAP_PRIVATE, PROT_EXEC, PROT_READ, PROT_WRITE}; use std::{ @@ -62,34 +62,47 @@ pub struct LocalInstance { impl Instance for LocalInstance { type Error = String; fn call(&mut self, id: usize, args: &[Value]) -> Result { + let mut args_u64: Vec = Vec::new(); + for arg in args { + if arg.ty() == Type::V128 { + let bytes = arg.to_u128().to_le_bytes(); + let mut lo = [0u8; 8]; + lo.clone_from_slice(&bytes[0..8]); + args_u64.push(u64::from_le_bytes(lo)); + let mut hi = [0u8; 8]; + hi.clone_from_slice(&bytes[8..16]); + args_u64.push(u64::from_le_bytes(hi)); + } else { + args_u64.push(arg.to_u128() as u64); + } + } let offset = self.offsets[id]; let addr: *const u8 = unsafe { self.code.as_ptr().offset(offset as isize) }; use std::mem::transmute; Ok(unsafe { - match args.len() { + match args_u64.len() { 0 => (transmute::<_, extern "C" fn() -> u64>(addr))(), - 1 => (transmute::<_, extern "C" fn(u64) -> u64>(addr))(args[0].to_u64()), - 2 => (transmute::<_, extern "C" fn(u64, u64) -> u64>(addr))( - args[0].to_u64(), - args[1].to_u64(), - ), + 1 => (transmute::<_, extern "C" fn(u64) -> u64>(addr))(args_u64[0]), + 2 => { + (transmute::<_, extern "C" fn(u64, u64) -> u64>(addr))(args_u64[0], args_u64[1]) + } 3 => (transmute::<_, extern "C" fn(u64, u64, u64) -> u64>(addr))( - args[0].to_u64(), - args[1].to_u64(), - args[2].to_u64(), + args_u64[0], + args_u64[1], + args_u64[2], ), 4 => (transmute::<_, extern "C" fn(u64, u64, u64, u64) -> u64>(addr))( - args[0].to_u64(), - args[1].to_u64(), - args[2].to_u64(), - args[3].to_u64(), + args_u64[0], + args_u64[1], + args_u64[2], + args_u64[3], ), 5 => (transmute::<_, extern "C" fn(u64, u64, u64, u64, u64) -> u64>(addr))( - args[0].to_u64(), - args[1].to_u64(), - args[2].to_u64(), - args[3].to_u64(), - args[4].to_u64(), + args_u64[0], + args_u64[1], + args_u64[2], + args_u64[3], + args_u64[4], ), _ => return Err("too many arguments".into()), } diff --git a/lib/runtime-core/src/state.rs b/lib/runtime-core/src/state.rs index 8650cb4acff..6fd47b204ec 100644 --- a/lib/runtime-core/src/state.rs +++ b/lib/runtime-core/src/state.rs @@ -95,7 +95,7 @@ pub struct ExecutionStateImage { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct InstanceImage { pub memory: Option>, - pub globals: Vec, + pub globals: Vec, pub execution_state: ExecutionStateImage, } @@ -662,11 +662,11 @@ pub mod x64 { // FIXME: Imported globals let globals_len = (*vmctx.module).info.globals.len(); - let globals: Vec = (0..globals_len) + let globals: Vec = (0..globals_len) .map(|i| { (*vmctx.local_backing).globals[LocalGlobalIndex::new(i)] .get() - .to_u64() + .to_u128() }) .collect(); diff --git a/lib/runtime-core/src/types.rs b/lib/runtime-core/src/types.rs index ac3df034322..ad00a1588c0 100644 --- a/lib/runtime-core/src/types.rs +++ b/lib/runtime-core/src/types.rs @@ -51,13 +51,13 @@ impl Value { } } - pub fn to_u64(&self) -> u64 { + pub fn to_u128(&self) -> u128 { match *self { - Value::I32(x) => x as u32 as u64, - Value::I64(x) => x as u64, - Value::F32(x) => f32::to_bits(x) as u64, - Value::F64(x) => f64::to_bits(x), - Value::V128(_) => unimplemented!(), + Value::I32(x) => x as u128, + Value::I64(x) => x as u128, + Value::F32(x) => f32::to_bits(x) as u128, + Value::F64(x) => f64::to_bits(x) as u128, + Value::V128(x) => x, } } } diff --git a/lib/runtime-core/src/vm.rs b/lib/runtime-core/src/vm.rs index 1e0b3773dc8..1a7ed37de38 100644 --- a/lib/runtime-core/src/vm.rs +++ b/lib/runtime-core/src/vm.rs @@ -535,7 +535,7 @@ impl LocalMemory { #[derive(Debug, Clone, Copy)] #[repr(C)] pub struct LocalGlobal { - pub data: u64, + pub data: u128, } impl LocalGlobal { From 3e009c5971b64697333646100d99a19b740449d2 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Thu, 18 Jul 2019 13:40:24 -0700 Subject: [PATCH 21/37] Reformat. --- lib/llvm-backend/src/code.rs | 47 +++++++++++++++++++++++++------- lib/runtime-core/src/instance.rs | 32 ++++++++++++++++------ lib/spectests/build/spectests.rs | 10 ++++--- 3 files changed, 67 insertions(+), 22 deletions(-) diff --git a/lib/llvm-backend/src/code.rs b/lib/llvm-backend/src/code.rs index 8c41e55c9c7..4ce10715897 100644 --- a/lib/llvm-backend/src/code.rs +++ b/lib/llvm-backend/src/code.rs @@ -114,14 +114,22 @@ fn trunc_sat( let int_min_value = splat_vector( builder, intrinsics, - ivec_ty.get_element_type().into_int_type().const_int(int_min_value, is_signed).as_basic_value_enum(), + ivec_ty + .get_element_type() + .into_int_type() + .const_int(int_min_value, is_signed) + .as_basic_value_enum(), ivec_ty, "", ); let int_max_value = splat_vector( builder, intrinsics, - ivec_ty.get_element_type().into_int_type().const_int(int_max_value, is_signed).as_basic_value_enum(), + ivec_ty + .get_element_type() + .into_int_type() + .const_int(int_max_value, is_signed) + .as_basic_value_enum(), ivec_ty, "", ); @@ -183,10 +191,15 @@ fn trunc_sat( "", ); let nan_cmp = builder.build_float_compare(FloatPredicate::UNO, value, zero, "nan"); - let above_upper_bound_cmp = builder.build_float_compare(FloatPredicate::OGT, value, upper_bound, "above_upper_bound"); - let below_lower_bound_cmp = builder.build_float_compare(FloatPredicate::OLT, value, lower_bound, "below_lower_bound"); - let not_representable = builder - .build_or(builder.build_or(nan_cmp, above_upper_bound_cmp, ""), below_lower_bound_cmp, "not_representable_as_int"); + let above_upper_bound_cmp = + builder.build_float_compare(FloatPredicate::OGT, value, upper_bound, "above_upper_bound"); + let below_lower_bound_cmp = + builder.build_float_compare(FloatPredicate::OLT, value, lower_bound, "below_lower_bound"); + let not_representable = builder.build_or( + builder.build_or(nan_cmp, above_upper_bound_cmp, ""), + below_lower_bound_cmp, + "not_representable_as_int", + ); let value = builder .build_select(not_representable, zero, value, "safe_to_convert") .into_vector_value(); @@ -4120,10 +4133,24 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let idx = builder .build_extract_element(v2, intrinsics.i32_ty.const_int(i, false), "idx") .into_int_value(); - let idx_out_of_range = builder.build_int_compare(IntPredicate::UGE, idx, lanes, "idx_out_of_range"); - let idx_clamped = builder.build_select(idx_out_of_range, intrinsics.i32_zero, idx, "idx_clamped").into_int_value(); - let elem = builder.build_extract_element(v1, idx_clamped, "elem").into_int_value(); - let elem_or_zero = builder.build_select(idx_out_of_range, intrinsics.i32_zero, elem, "elem_or_zero"); + let idx_out_of_range = builder.build_int_compare( + IntPredicate::UGE, + idx, + lanes, + "idx_out_of_range", + ); + let idx_clamped = builder + .build_select(idx_out_of_range, intrinsics.i32_zero, idx, "idx_clamped") + .into_int_value(); + let elem = builder + .build_extract_element(v1, idx_clamped, "elem") + .into_int_value(); + let elem_or_zero = builder.build_select( + idx_out_of_range, + intrinsics.i32_zero, + elem, + "elem_or_zero", + ); res = builder.build_insert_element( res, elem_or_zero, diff --git a/lib/runtime-core/src/instance.rs b/lib/runtime-core/src/instance.rs index 8627aff340f..d724e9bd47f 100644 --- a/lib/runtime-core/src/instance.rs +++ b/lib/runtime-core/src/instance.rs @@ -519,7 +519,12 @@ fn call_func_with_index( let signature = &info.signatures[sig_index]; let num_results = signature.returns().len(); - let num_results = num_results + signature.returns().iter().filter(|&&ty| ty == Type::V128).count(); + let num_results = num_results + + signature + .returns() + .iter() + .filter(|&&ty| ty == Type::V128) + .count(); rets.reserve(num_results); if !signature.check_param_value_types(args) { @@ -548,17 +553,25 @@ fn call_func_with_index( let mut raw_args: SmallVec<[u64; 8]> = SmallVec::new(); for v in args { match v { - Value::I32(i) => { raw_args.push(*i as u64); } - Value::I64(i) => { raw_args.push(*i as u64); } - Value::F32(f) => { raw_args.push(f.to_bits() as u64); } - Value::F64(f) => { raw_args.push(f.to_bits() as u64); } + Value::I32(i) => { + raw_args.push(*i as u64); + } + Value::I64(i) => { + raw_args.push(*i as u64); + } + Value::F32(f) => { + raw_args.push(f.to_bits() as u64); + } + Value::F64(f) => { + raw_args.push(f.to_bits() as u64); + } Value::V128(v) => { let bytes = v.to_le_bytes(); let mut lo = [0u8; 8]; - lo.clone_from_slice(&bytes[0 .. 8]); + lo.clone_from_slice(&bytes[0..8]); raw_args.push(u64::from_le_bytes(lo)); let mut hi = [0u8; 8]; - hi.clone_from_slice(&bytes[8 .. 16]); + hi.clone_from_slice(&bytes[8..16]); raw_args.push(u64::from_le_bytes(hi)); } } @@ -621,7 +634,10 @@ fn call_func_with_index( let mut bytes = [0u8; 16]; let lo = result[0].to_le_bytes(); let hi = result[1].to_le_bytes(); - for i in 0..8 { bytes[i] = lo[i]; bytes[i + 8] = hi[i]; } + for i in 0..8 { + bytes[i] = lo[i]; + bytes[i + 8] = hi[i]; + } rets.push(Value::V128(u128::from_le_bytes(bytes))); Ok(()) } diff --git a/lib/spectests/build/spectests.rs b/lib/spectests/build/spectests.rs index 0da6b130e94..35cdd5ffc60 100644 --- a/lib/spectests/build/spectests.rs +++ b/lib/spectests/build/spectests.rs @@ -6,7 +6,7 @@ use std::fs::File; use std::path::PathBuf; use std::{env, fs, io::Write}; use wabt::script::{Action, Command, CommandKind, ModuleBinary, ScriptParser, Value}; -use wabt::{Features, wasm2wat_with_features}; +use wabt::{wasm2wat_with_features, Features}; static BANNER: &str = "// Rust test file autogenerated with cargo build (build/spectests.rs). // Please do NOT modify it by hand, as it will be reset on next build.\n"; @@ -309,8 +309,9 @@ impl WastTestGenerator { let source = fs::read(&path).unwrap(); let mut features = wabt::Features::new(); features.enable_simd(); - let script: ScriptParser = ScriptParser::from_source_and_name_with_features(&source, filename, features) - .expect(&format!("Failed to parse script {}", &filename)); + let script: ScriptParser = + ScriptParser::from_source_and_name_with_features(&source, filename, features) + .expect(&format!("Failed to parse script {}", &filename)); let buffer = String::new(); WastTestGenerator { last_module: 0, @@ -393,7 +394,8 @@ fn test_module_{}() {{ let wasm_binary: Vec = module.clone().into_vec(); let mut features = Features::new(); features.enable_simd(); - let wast_string = wasm2wat_with_features(wasm_binary, features).expect("Can't convert back to wasm"); + let wast_string = + wasm2wat_with_features(wasm_binary, features).expect("Can't convert back to wasm"); let last_module = self.last_module; self.flush_module_calls(last_module); self.last_module = self.last_module + 1; From cd253568584b947a302053ce5504ea25d84c89a6 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Fri, 19 Jul 2019 15:19:58 -0700 Subject: [PATCH 22/37] Fix shuffle and enable tests. Add support for new load_splat instructions. Updates to wasmparser 0.34.0 and picks up a newer wasmerio/wabt. --- Cargo.lock | 173 ++++++++++++++++------------- Cargo.toml | 4 +- lib/clif-backend/Cargo.toml | 12 +- lib/emscripten-tests/Cargo.toml | 2 +- lib/llvm-backend/Cargo.toml | 4 +- lib/llvm-backend/src/code.rs | 143 +++++++++++++++++++++--- lib/llvm-backend/src/intrinsics.rs | 3 + lib/middleware-common/Cargo.toml | 2 +- lib/runtime-abi/Cargo.toml | 2 +- lib/runtime-core/Cargo.toml | 2 +- lib/runtime/Cargo.toml | 2 +- lib/singlepass-backend/Cargo.toml | 2 +- lib/spectests/Cargo.toml | 4 +- lib/spectests/spectests/simd.wast | 76 ++++++------- 14 files changed, 279 insertions(+), 152 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df886045920..4a2acbac4e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -138,6 +138,16 @@ dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "cargo_toml" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cast" version = "0.2.2" @@ -244,20 +254,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift-bforest" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.34.0" +source = "git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc#f05f4044d42c54fc5841753030991afc026695fc" dependencies = [ - "cranelift-entity 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-entity 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", ] [[package]] name = "cranelift-codegen" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.34.0" +source = "git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc#f05f4044d42c54fc5841753030991afc026695fc" dependencies = [ - "cranelift-bforest 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-codegen-meta 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-entity 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-bforest 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", + "cranelift-codegen-meta 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", + "cranelift-entity 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -266,27 +276,51 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.34.0" +source = "git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc#f05f4044d42c54fc5841753030991afc026695fc" dependencies = [ - "cranelift-entity 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-entity 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", ] [[package]] name = "cranelift-entity" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.34.0" +source = "git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc#f05f4044d42c54fc5841753030991afc026695fc" + +[[package]] +name = "cranelift-frontend" +version = "0.34.0" +source = "git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc#f05f4044d42c54fc5841753030991afc026695fc" +dependencies = [ + "cranelift-codegen 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "cranelift-native" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.34.0" +source = "git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc#f05f4044d42c54fc5841753030991afc026695fc" dependencies = [ - "cranelift-codegen 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "cranelift-wasm" +version = "0.34.0" +source = "git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc#f05f4044d42c54fc5841753030991afc026695fc" +dependencies = [ + "cranelift-codegen 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", + "cranelift-entity 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", + "cranelift-frontend 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.34.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "criterion" version = "0.2.11" @@ -555,20 +589,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "inkwell" version = "0.1.0" -source = "git+https://github.com/wasmerio/inkwell?branch=llvm7-0#a14e62977504ef574dc2e933edc559cc79781ca7" +source = "git+https://github.com/wasmerio/inkwell?branch=llvm8-0#f1775622b6d88fd30006b377042726854c9e0193" dependencies = [ "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "enum-methods 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "inkwell_internal_macros 0.1.0 (git+https://github.com/wasmerio/inkwell?branch=llvm7-0)", + "inkwell_internal_macros 0.1.0 (git+https://github.com/wasmerio/inkwell?branch=llvm8-0)", "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", - "llvm-sys 70.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "llvm-sys 80.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "inkwell_internal_macros" version = "0.1.0" -source = "git+https://github.com/wasmerio/inkwell?branch=llvm7-0#a14e62977504ef574dc2e933edc559cc79781ca7" +source = "git+https://github.com/wasmerio/inkwell?branch=llvm8-0#f1775622b6d88fd30006b377042726854c9e0193" dependencies = [ + "cargo_toml 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -620,7 +656,7 @@ dependencies = [ [[package]] name = "llvm-sys" -version = "70.2.0" +version = "80.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1346,19 +1382,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wabt" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.8.0" +source = "git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b#77081af74fe3ecaa300e3517c9f87233ae8cf95b" dependencies = [ "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt-sys 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", + "wabt-sys 0.6.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b)", ] [[package]] name = "wabt-sys" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.6.0" +source = "git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b#77081af74fe3ecaa300e3517c9f87233ae8cf95b" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "cmake 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1385,7 +1421,7 @@ dependencies = [ "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b)", "wasmer-clif-backend 0.5.6", "wasmer-dev-utils 0.5.6", "wasmer-emscripten 0.5.6", @@ -1405,9 +1441,11 @@ name = "wasmer-clif-backend" version = "0.5.6" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-codegen 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-entity 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-native 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", + "cranelift-entity 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", + "cranelift-frontend 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", + "cranelift-native 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", + "cranelift-wasm 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1417,38 +1455,12 @@ dependencies = [ "serde_bytes 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmer-clif-fork-frontend 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmer-clif-fork-wasm 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-runtime-core 0.5.6", "wasmer-win-exception-handler 0.5.6", - "wasmparser 0.32.1 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.34.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "wasmer-clif-fork-frontend" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cranelift-codegen 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasmer-clif-fork-wasm" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cranelift-codegen 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-entity 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmer-clif-fork-frontend 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmparser 0.32.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "wasmer-dev-utils" version = "0.5.6" @@ -1474,7 +1486,7 @@ name = "wasmer-emscripten-tests" version = "0.5.6" dependencies = [ "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b)", "wasmer-clif-backend 0.5.6", "wasmer-dev-utils 0.5.6", "wasmer-emscripten 0.5.6", @@ -1499,7 +1511,7 @@ dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.20 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "inkwell 0.1.0 (git+https://github.com/wasmerio/inkwell?branch=llvm7-0)", + "inkwell 0.1.0 (git+https://github.com/wasmerio/inkwell?branch=llvm8-0)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1507,9 +1519,9 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b)", "wasmer-runtime-core 0.5.6", - "wasmparser 0.32.1 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.34.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1517,7 +1529,7 @@ name = "wasmer-middleware-common" version = "0.5.6" dependencies = [ "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b)", "wasmer-clif-backend 0.5.6", "wasmer-llvm-backend 0.5.6", "wasmer-runtime-core 0.5.6", @@ -1532,7 +1544,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b)", "wasmer-clif-backend 0.5.6", "wasmer-llvm-backend 0.5.6", "wasmer-runtime-core 0.5.6", @@ -1574,7 +1586,7 @@ dependencies = [ "serde_bytes 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmparser 0.32.1 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.34.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1592,14 +1604,14 @@ dependencies = [ "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-runtime-core 0.5.6", - "wasmparser 0.32.1 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.34.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasmer-spectests" version = "0.5.6" dependencies = [ - "wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b)", "wasmer-clif-backend 0.5.6", "wasmer-llvm-backend 0.5.6", "wasmer-runtime-core 0.5.6", @@ -1647,7 +1659,7 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.32.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1733,6 +1745,7 @@ dependencies = [ "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" "checksum capstone 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00be9d203fa0e078b93b24603633fb081851dfe0c1086364431f52587a47157e" "checksum capstone-sys 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2dc8d32bc5c1e6d0fcde10af411c98b07d93498d51654f678757f08fa2acd6a6" +"checksum cargo_toml 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "097f5ce64ba566a83d9d914fd005de1e5937fdd57d8c5d99a7593040955d75a9" "checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427" "checksum cbindgen 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1f861ef68cabbb271d373a7795014052bff37edce22c620d95e395e8719d7dc5" "checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" @@ -1745,11 +1758,13 @@ dependencies = [ "checksum cmake 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "2ca4386c8954b76a8415b63959337d940d724b336cabd3afe189c2b51a7e1ff0" "checksum colored 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6cdb90b60f2927f8d76139c72dbde7e10c3a2bc47c8594c9c7a66529f2687c03" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" -"checksum cranelift-bforest 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)" = "409f92af3dd276e112b72873a3ef02613e3c5f55b81d5d5d04f3157d4f8b8c54" -"checksum cranelift-codegen 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b303542a56fba4cbaeea099fb30ed078b50de0e765fd69f7f5f410adbe31d95b" -"checksum cranelift-codegen-meta 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0fee15ed430092a6d14b7c6d627540bef732509b8097ae31e4e35526edaa129c" -"checksum cranelift-entity 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)" = "739222c3740e4a8d6f0375bd95caba9b6c11afcba9f0e1d4f944d6bd99f84600" -"checksum cranelift-native 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce451162d18b7d82118e23ea7e12f7d8b98557549404bd71215548de79eb0736" +"checksum cranelift-bforest 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)" = "" +"checksum cranelift-codegen 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)" = "" +"checksum cranelift-codegen-meta 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)" = "" +"checksum cranelift-entity 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)" = "" +"checksum cranelift-frontend 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)" = "" +"checksum cranelift-native 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)" = "" +"checksum cranelift-wasm 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)" = "" "checksum criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0363053954f3e679645fc443321ca128b7b950a6fe288cf5f9335cc22ee58394" "checksum criterion-plot 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76f9212ddf2f4a9eb2d401635190600656a1f88a932ef53d06e7fa4c7e02fb8e" "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" @@ -1779,15 +1794,15 @@ dependencies = [ "checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" -"checksum inkwell 0.1.0 (git+https://github.com/wasmerio/inkwell?branch=llvm7-0)" = "" -"checksum inkwell_internal_macros 0.1.0 (git+https://github.com/wasmerio/inkwell?branch=llvm7-0)" = "" +"checksum inkwell 0.1.0 (git+https://github.com/wasmerio/inkwell?branch=llvm8-0)" = "" +"checksum inkwell_internal_macros 0.1.0 (git+https://github.com/wasmerio/inkwell?branch=llvm8-0)" = "" "checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)" = "a844cabbd5a77e60403a58af576f0a1baa83c3dd2670be63e615bd24fc58b82d" "checksum libloading 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a5692f82b51823e27c4118b3e5c0d98aee9be90633ebc71ad12afef380b50219" -"checksum llvm-sys 70.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3a2cb392cf218dbb2d2c4f0fe54b8622871f8897a1d62d24a117dcf540bba124" +"checksum llvm-sys 80.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2110cd4daf9cd8e39dd3b933b1a2a2ac7315e91f7c92b3a20beab526c63b5978" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" @@ -1877,12 +1892,10 @@ dependencies = [ "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "74e463a508e390cc7447e70f640fbf44ad52e1bd095314ace1fdf99516d32add" -"checksum wabt-sys 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a6265b25719e82598d104b3717375e37661d41753e2c84cde3f51050c7ed7e3c" +"checksum wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b)" = "" +"checksum wabt-sys 0.6.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b)" = "" "checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1" -"checksum wasmer-clif-fork-frontend 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)" = "620fd484c3348e4bb565d861cddb0c05170337aaa152b6ba61620d054ab17cd9" -"checksum wasmer-clif-fork-wasm 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b5e42fa4281de137d5a23b8197d29c218212077c6d55d0dfed7bb80c76308ba4" -"checksum wasmparser 0.32.1 (registry+https://github.com/rust-lang/crates.io-index)" = "22d1801de30f112ddaf665291097694ee33a36d1cb414b53a921d05b3519674a" +"checksum wasmparser 0.34.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8030ec5a7c242a91941947fdb752e9a7c0929aced954ea23c54dad1cd2611850" "checksum which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" diff --git a/Cargo.toml b/Cargo.toml index 59893821e38..e4561fd33c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ include = [ byteorder = "1.3.1" errno = "0.2.4" structopt = "0.2.11" -wabt = "0.8.0" +wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "77081af74fe3ecaa300e3517c9f87233ae8cf95b" } hashbrown = "0.1.8" wasmer-clif-backend = { path = "lib/clif-backend" } wasmer-singlepass-backend = { path = "lib/singlepass-backend", optional = true } @@ -61,7 +61,7 @@ members = [ ] [build-dependencies] -wabt = "0.8.0" +wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "77081af74fe3ecaa300e3517c9f87233ae8cf95b" } glob = "0.2.11" rustc_version = "0.2.3" diff --git a/lib/clif-backend/Cargo.toml b/lib/clif-backend/Cargo.toml index 29e7f97227a..8cefab07c28 100644 --- a/lib/clif-backend/Cargo.toml +++ b/lib/clif-backend/Cargo.toml @@ -9,14 +9,14 @@ edition = "2018" [dependencies] wasmer-runtime-core = { path = "../runtime-core", version = "0.5.6" } -cranelift-native = { version = "0.31" } -cranelift-codegen = { version = "0.31" } -cranelift-entity = { version = "0.31" } -cranelift-frontend = { package = "wasmer-clif-fork-frontend", version = "0.31" } -cranelift-wasm = { package = "wasmer-clif-fork-wasm", version = "0.31" } +cranelift-native = { git = "https://github.com/wasmerio/cranelift.git", rev = "f05f4044d42c54fc5841753030991afc026695fc" } +cranelift-codegen = { git = "https://github.com/wasmerio/cranelift.git", rev = "f05f4044d42c54fc5841753030991afc026695fc" } +cranelift-entity = { git = "https://github.com/wasmerio/cranelift.git", rev = "f05f4044d42c54fc5841753030991afc026695fc" } +cranelift-frontend = { git = "https://github.com/wasmerio/cranelift.git", rev = "f05f4044d42c54fc5841753030991afc026695fc" } +cranelift-wasm = { git = "https://github.com/wasmerio/cranelift.git", rev = "f05f4044d42c54fc5841753030991afc026695fc" } hashbrown = "0.1" target-lexicon = "0.4.0" -wasmparser = "0.32.1" +wasmparser = "0.34.0" byteorder = "1" nix = "0.14.0" libc = "0.2.49" diff --git a/lib/emscripten-tests/Cargo.toml b/lib/emscripten-tests/Cargo.toml index e5c21ec69e1..893eb567219 100644 --- a/lib/emscripten-tests/Cargo.toml +++ b/lib/emscripten-tests/Cargo.toml @@ -16,7 +16,7 @@ wasmer-llvm-backend = { path = "../llvm-backend", version = "0.5.6", optional = wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.6", optional = true } [dev-dependencies] -wabt = "0.7.2" +wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "77081af74fe3ecaa300e3517c9f87233ae8cf95b" } wasmer-dev-utils = { path = "../dev-utils", version = "0.5.6"} [build-dependencies] diff --git a/lib/llvm-backend/Cargo.toml b/lib/llvm-backend/Cargo.toml index fe506aad36c..08bc0b1f4d6 100644 --- a/lib/llvm-backend/Cargo.toml +++ b/lib/llvm-backend/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] wasmer-runtime-core = { path = "../runtime-core", version = "0.5.6" } inkwell = { git = "https://github.com/wasmerio/inkwell", branch = "llvm8-0", features = ["llvm8-0"] } -wasmparser = "0.32.1" +wasmparser = "0.34.0" hashbrown = "0.1.8" smallvec = "0.6.8" goblin = "0.0.20" @@ -23,7 +23,7 @@ semver = "0.9" rustc_version = "0.2.3" [dev-dependencies] -wabt = "0.8.0" +wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "77081af74fe3ecaa300e3517c9f87233ae8cf95b" } [features] debug = ["wasmer-runtime-core/debug"] diff --git a/lib/llvm-backend/src/code.rs b/lib/llvm-backend/src/code.rs index 4ce10715897..dd42ae39a73 100644 --- a/lib/llvm-backend/src/code.rs +++ b/lib/llvm-backend/src/code.rs @@ -4119,7 +4119,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); state.push1(res); } - Operator::V8x16Shuffle1 => { + Operator::V8x16Swizzle => { let (v1, v2) = state.pop2()?; let v1 = builder .build_bitcast(v1, intrinsics.i8x16_ty, "") @@ -4127,27 +4127,46 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let v2 = builder .build_bitcast(v2, intrinsics.i8x16_ty, "") .into_vector_value(); - let lanes = intrinsics.i32_ty.const_int(16, false); + let lanes = intrinsics.i8_ty.const_int(16, false); + let lanes = splat_vector( + builder, + intrinsics, + lanes.as_basic_value_enum(), + intrinsics.i8x16_ty, + "", + ); let mut res = intrinsics.i8x16_ty.get_undef(); - for i in 0..15 { + let idx_out_of_range = + builder.build_int_compare(IntPredicate::UGE, v2, lanes, "idx_out_of_range"); + let idx_clamped = builder + .build_select( + idx_out_of_range, + intrinsics.i8x16_ty.const_zero(), + v2, + "idx_clamped", + ) + .into_vector_value(); + for i in 0..16 { let idx = builder - .build_extract_element(v2, intrinsics.i32_ty.const_int(i, false), "idx") + .build_extract_element( + idx_clamped, + intrinsics.i32_ty.const_int(i, false), + "idx", + ) .into_int_value(); - let idx_out_of_range = builder.build_int_compare( - IntPredicate::UGE, - idx, - lanes, - "idx_out_of_range", - ); - let idx_clamped = builder - .build_select(idx_out_of_range, intrinsics.i32_zero, idx, "idx_clamped") + let replace_with_zero = builder + .build_extract_element( + idx_out_of_range, + intrinsics.i32_ty.const_int(i, false), + "replace_with_zero", + ) .into_int_value(); let elem = builder - .build_extract_element(v1, idx_clamped, "elem") + .build_extract_element(v1, idx, "elem") .into_int_value(); let elem_or_zero = builder.build_select( - idx_out_of_range, - intrinsics.i32_zero, + replace_with_zero, + intrinsics.i8_zero, elem, "elem_or_zero", ); @@ -4161,7 +4180,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_bitcast(res, intrinsics.i128_ty, &state.var_name()); state.push1(res); } - Operator::V8x16Shuffle2Imm { lanes } => { + Operator::V8x16Shuffle { lanes } => { let (v1, v2) = state.pop2()?; let v1 = builder .build_bitcast(v1, intrinsics.i8x16_ty, "") @@ -4180,6 +4199,98 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); state.push1(res); } + Operator::I8x16LoadSplat { ref memarg } => { + let effective_address = resolve_memory_ptr( + builder, + intrinsics, + context, + &function, + &mut state, + &mut ctx, + memarg, + intrinsics.i8_ptr_ty, + 1, + )?; + let elem = builder.build_load(effective_address, "").into_int_value(); + let res = splat_vector( + builder, + intrinsics, + elem.as_basic_value_enum(), + intrinsics.i8x16_ty, + &state.var_name(), + ); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I16x8LoadSplat { ref memarg } => { + let effective_address = resolve_memory_ptr( + builder, + intrinsics, + context, + &function, + &mut state, + &mut ctx, + memarg, + intrinsics.i16_ptr_ty, + 2, + )?; + let elem = builder.build_load(effective_address, "").into_int_value(); + let res = splat_vector( + builder, + intrinsics, + elem.as_basic_value_enum(), + intrinsics.i16x8_ty, + &state.var_name(), + ); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I32x4LoadSplat { ref memarg } => { + let effective_address = resolve_memory_ptr( + builder, + intrinsics, + context, + &function, + &mut state, + &mut ctx, + memarg, + intrinsics.i32_ptr_ty, + 4, + )?; + let elem = builder.build_load(effective_address, "").into_int_value(); + let res = splat_vector( + builder, + intrinsics, + elem.as_basic_value_enum(), + intrinsics.i32x4_ty, + &state.var_name(), + ); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } + Operator::I64x2LoadSplat { ref memarg } => { + let effective_address = resolve_memory_ptr( + builder, + intrinsics, + context, + &function, + &mut state, + &mut ctx, + memarg, + intrinsics.i64_ptr_ty, + 8, + )?; + let elem = builder.build_load(effective_address, "").into_int_value(); + let res = splat_vector( + builder, + intrinsics, + elem.as_basic_value_enum(), + intrinsics.i64x2_ty, + &state.var_name(), + ); + let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); + state.push1(res); + } Operator::MemoryGrow { reserved } => { let memory_index = MemoryIndex::new(reserved as usize); diff --git a/lib/llvm-backend/src/intrinsics.rs b/lib/llvm-backend/src/intrinsics.rs index 32591ce7054..7ea57ae082c 100644 --- a/lib/llvm-backend/src/intrinsics.rs +++ b/lib/llvm-backend/src/intrinsics.rs @@ -118,6 +118,7 @@ pub struct Intrinsics { pub anyfunc_ty: StructType, pub i1_zero: IntValue, + pub i8_zero: IntValue, pub i32_zero: IntValue, pub i64_zero: IntValue, pub i128_zero: IntValue, @@ -179,6 +180,7 @@ impl Intrinsics { let f64_ptr_ty = f64_ty.ptr_type(AddressSpace::Generic); let i1_zero = i1_ty.const_int(0, false); + let i8_zero = i8_ty.const_int(0, false); let i32_zero = i32_ty.const_int(0, false); let i64_zero = i64_ty.const_int(0, false); let i128_zero = i128_ty.const_int(0, false); @@ -443,6 +445,7 @@ impl Intrinsics { anyfunc_ty, i1_zero, + i8_zero, i32_zero, i64_zero, i128_zero, diff --git a/lib/middleware-common/Cargo.toml b/lib/middleware-common/Cargo.toml index 01dd50ba2a8..c3e08c956a9 100644 --- a/lib/middleware-common/Cargo.toml +++ b/lib/middleware-common/Cargo.toml @@ -14,7 +14,7 @@ wasmer-llvm-backend = { path = "../llvm-backend", version = "0.5.6", optional = wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.6", optional = true } [dev-dependencies] -wabt = "0.8.0" +wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "77081af74fe3ecaa300e3517c9f87233ae8cf95b" } criterion = "0.2" [features] diff --git a/lib/runtime-abi/Cargo.toml b/lib/runtime-abi/Cargo.toml index 84c6c900067..4a8deb32fe4 100644 --- a/lib/runtime-abi/Cargo.toml +++ b/lib/runtime-abi/Cargo.toml @@ -13,7 +13,7 @@ wasmer-runtime-core = { path = "../runtime-core" } hashbrown = "0.1" failure = "0.1" tar = "0.4" -wasmparser = "0.32.1" +wasmparser = "0.34.0" zstd = "0.4" # [target.'cfg(unix)'.dependencies.zbox] diff --git a/lib/runtime-core/Cargo.toml b/lib/runtime-core/Cargo.toml index 4538cc44227..c40e5d80fe0 100644 --- a/lib/runtime-core/Cargo.toml +++ b/lib/runtime-core/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" [dependencies] nix = "0.14.0" page_size = "0.4.1" -wasmparser = "0.32.1" +wasmparser = "0.34.0" parking_lot = "0.7.1" lazy_static = "1.2.0" indexmap = "1.0.2" diff --git a/lib/runtime/Cargo.toml b/lib/runtime/Cargo.toml index a886a6bebb7..8d65860f361 100644 --- a/lib/runtime/Cargo.toml +++ b/lib/runtime/Cargo.toml @@ -25,7 +25,7 @@ optional = true [dev-dependencies] tempfile = "3.0.7" criterion = "0.2" -wabt = "0.8.0" +wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "77081af74fe3ecaa300e3517c9f87233ae8cf95b" } [target.'cfg(not(windows))'.dependencies.wasmer-llvm-backend] path = "../llvm-backend" diff --git a/lib/singlepass-backend/Cargo.toml b/lib/singlepass-backend/Cargo.toml index f3124221263..56c342c7df0 100644 --- a/lib/singlepass-backend/Cargo.toml +++ b/lib/singlepass-backend/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" [dependencies] wasmer-runtime-core = { path = "../runtime-core", version = "0.5.6" } -wasmparser = "0.32.1" +wasmparser = "0.34.0" dynasm = "0.3.2" dynasmrt = "0.3.1" lazy_static = "1.2.0" diff --git a/lib/spectests/Cargo.toml b/lib/spectests/Cargo.toml index 37d67d18b7a..493be6cc0c9 100644 --- a/lib/spectests/Cargo.toml +++ b/lib/spectests/Cargo.toml @@ -15,10 +15,10 @@ wasmer-llvm-backend = { path = "../llvm-backend", version = "0.5.6", optional = wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.6", optional = true } [build-dependencies] -wabt = "0.8.0" +wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "77081af74fe3ecaa300e3517c9f87233ae8cf95b" } [dev-dependencies] -wabt = "0.8.0" +wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "77081af74fe3ecaa300e3517c9f87233ae8cf95b" } [features] default = ["fast-tests"] diff --git a/lib/spectests/spectests/simd.wast b/lib/spectests/spectests/simd.wast index 65e95a6cbf5..b4de7fc6141 100644 --- a/lib/spectests/spectests/simd.wast +++ b/lib/spectests/spectests/simd.wast @@ -247,44 +247,44 @@ (func (export "f64x2.replace_lane/1") (param $a v128) (param $b f64) (result v128) (f64x2.replace_lane 1 (local.get $a) (local.get $b))) ) -;; v8x16.shuffle1 -;; -;;(module -;; (func (export "v8x16.shuffle1") (param $elements v128) (param $indices v128) (result v128) (v8x16.shuffle1 (get_local $elements) (get_local $indices))) -;;) -;; -;;(assert_return -;; (invoke "v8x16.shuffle1" -;; (v128.const i8x16 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115) -;; (v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) -;; ) -;; (v128.const i8x16 115 114 113 112 111 110 109 108 107 106 105 104 103 102 101 100)) -;; -;;(assert_return -;; (invoke "v8x16.shuffle1" -;; (v128.const i8x16 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115) -;; (v128.const i8x16 -1 1 -2 2 -3 3 -4 4 -5 5 -6 6 -7 7 -8 8) -;; ) -;; (v128.const i8x16 0 101 0 102 0 103 0 104 0 105 0 106 0 107 0 108)) -;; -;;(assert_return -;; (invoke "v8x16.shuffle1" -;; (v128.const i8x16 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115) -;; (v128.const i8x16 9 16 10 17 11 18 12 19 13 20 14 21 15 22 16 23) -;; ) -;; (v128.const i8x16 109 0 110 0 111 0 112 0 113 0 114 0 115 0 0 0)) - -;; v8x16.shuffle2_imm -;; -;;(module -;; (func (export "v8x16.shuffle2_imm/0123456789abcdef") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 (local.get $a) (local.get $b))) -;; (func (export "v8x16.shuffle2_imm/ghijklmnopqrstuv") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 (local.get $a) (local.get $b))) -;; (func (export "v8x16.shuffle2_imm/vutsrqponmlkjihg") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 (local.get $a) (local.get $b))) -;; (func (export "v8x16.shuffle2_imm/fedcba9876543210") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 (local.get $a) (local.get $b))) -;; (func (export "v8x16.shuffle2_imm/0000000000000000") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 (local.get $a) (local.get $b))) -;; (func (export "v8x16.shuffle2_imm/gggggggggggggggg") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 (local.get $a) (local.get $b))) -;; (func (export "v8x16.shuffle2_imm/00000000gggggggg") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle2_imm 0 0 0 0 0 0 0 0 16 16 16 16 16 16 16 16 (local.get $a) (local.get $b))) -;;) +;; v8x16.swizzle + +(module + (func (export "v8x16.swizzle") (param $elements v128) (param $indices v128) (result v128) (v8x16.swizzle (get_local $elements) (get_local $indices))) +) + +(assert_return + (invoke "v8x16.swizzle" + (v128.const i8x16 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115) + (v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) + ) + (v128.const i8x16 115 114 113 112 111 110 109 108 107 106 105 104 103 102 101 100)) + +(assert_return + (invoke "v8x16.swizzle" + (v128.const i8x16 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115) + (v128.const i8x16 -1 1 -2 2 -3 3 -4 4 -5 5 -6 6 -7 7 -8 8) + ) + (v128.const i8x16 0 101 0 102 0 103 0 104 0 105 0 106 0 107 0 108)) + +(assert_return + (invoke "v8x16.swizzle" + (v128.const i8x16 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115) + (v128.const i8x16 9 16 10 17 11 18 12 19 13 20 14 21 15 22 16 23) + ) + (v128.const i8x16 109 0 110 0 111 0 112 0 113 0 114 0 115 0 0 0)) + +;; v8x16.shuffle + +(module + (func (export "v8x16.shuffle/0123456789abcdef") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 (local.get $a) (local.get $b))) + (func (export "v8x16.shuffle/ghijklmnopqrstuv") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 (local.get $a) (local.get $b))) + (func (export "v8x16.shuffle/vutsrqponmlkjihg") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 (local.get $a) (local.get $b))) + (func (export "v8x16.shuffle/fedcba9876543210") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 (local.get $a) (local.get $b))) + (func (export "v8x16.shuffle/0000000000000000") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 (local.get $a) (local.get $b))) + (func (export "v8x16.shuffle/gggggggggggggggg") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 (local.get $a) (local.get $b))) + (func (export "v8x16.shuffle/00000000gggggggg") (param $a v128) (param $b v128) (result v128) (v8x16.shuffle 0 0 0 0 0 0 0 0 16 16 16 16 16 16 16 16 (local.get $a) (local.get $b))) +) ;; i*.add From 775c120b3844790a4a967b3827820d6e879fa35d Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Fri, 19 Jul 2019 15:41:42 -0700 Subject: [PATCH 23/37] Update to newer wasmerio/wabt-rs. --- Cargo.lock | 22 +++++++++++----------- Cargo.toml | 4 ++-- lib/emscripten-tests/Cargo.toml | 2 +- lib/llvm-backend/Cargo.toml | 2 +- lib/middleware-common/Cargo.toml | 2 +- lib/runtime/Cargo.toml | 2 +- lib/spectests/Cargo.toml | 4 ++-- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a2acbac4e3..5f6e521b1e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1383,18 +1383,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wabt" version = "0.8.0" -source = "git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b#77081af74fe3ecaa300e3517c9f87233ae8cf95b" +source = "git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2#17188863021f0ed7721a1969da510efbc17615f2" dependencies = [ "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt-sys 0.6.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b)", + "wabt-sys 0.6.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2)", ] [[package]] name = "wabt-sys" version = "0.6.0" -source = "git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b#77081af74fe3ecaa300e3517c9f87233ae8cf95b" +source = "git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2#17188863021f0ed7721a1969da510efbc17615f2" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "cmake 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1421,7 +1421,7 @@ dependencies = [ "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b)", + "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2)", "wasmer-clif-backend 0.5.6", "wasmer-dev-utils 0.5.6", "wasmer-emscripten 0.5.6", @@ -1486,7 +1486,7 @@ name = "wasmer-emscripten-tests" version = "0.5.6" dependencies = [ "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b)", + "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2)", "wasmer-clif-backend 0.5.6", "wasmer-dev-utils 0.5.6", "wasmer-emscripten 0.5.6", @@ -1519,7 +1519,7 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b)", + "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2)", "wasmer-runtime-core 0.5.6", "wasmparser 0.34.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1529,7 +1529,7 @@ name = "wasmer-middleware-common" version = "0.5.6" dependencies = [ "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b)", + "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2)", "wasmer-clif-backend 0.5.6", "wasmer-llvm-backend 0.5.6", "wasmer-runtime-core 0.5.6", @@ -1544,7 +1544,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b)", + "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2)", "wasmer-clif-backend 0.5.6", "wasmer-llvm-backend 0.5.6", "wasmer-runtime-core 0.5.6", @@ -1611,7 +1611,7 @@ dependencies = [ name = "wasmer-spectests" version = "0.5.6" dependencies = [ - "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b)", + "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2)", "wasmer-clif-backend 0.5.6", "wasmer-llvm-backend 0.5.6", "wasmer-runtime-core 0.5.6", @@ -1892,8 +1892,8 @@ dependencies = [ "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b)" = "" -"checksum wabt-sys 0.6.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=77081af74fe3ecaa300e3517c9f87233ae8cf95b)" = "" +"checksum wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2)" = "" +"checksum wabt-sys 0.6.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2)" = "" "checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1" "checksum wasmparser 0.34.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8030ec5a7c242a91941947fdb752e9a7c0929aced954ea23c54dad1cd2611850" "checksum which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164" diff --git a/Cargo.toml b/Cargo.toml index e4561fd33c7..65617a1d669 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ include = [ byteorder = "1.3.1" errno = "0.2.4" structopt = "0.2.11" -wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "77081af74fe3ecaa300e3517c9f87233ae8cf95b" } +wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "17188863021f0ed7721a1969da510efbc17615f2" } hashbrown = "0.1.8" wasmer-clif-backend = { path = "lib/clif-backend" } wasmer-singlepass-backend = { path = "lib/singlepass-backend", optional = true } @@ -61,7 +61,7 @@ members = [ ] [build-dependencies] -wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "77081af74fe3ecaa300e3517c9f87233ae8cf95b" } +wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "17188863021f0ed7721a1969da510efbc17615f2" } glob = "0.2.11" rustc_version = "0.2.3" diff --git a/lib/emscripten-tests/Cargo.toml b/lib/emscripten-tests/Cargo.toml index 893eb567219..f8d1437cb4b 100644 --- a/lib/emscripten-tests/Cargo.toml +++ b/lib/emscripten-tests/Cargo.toml @@ -16,7 +16,7 @@ wasmer-llvm-backend = { path = "../llvm-backend", version = "0.5.6", optional = wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.6", optional = true } [dev-dependencies] -wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "77081af74fe3ecaa300e3517c9f87233ae8cf95b" } +wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "17188863021f0ed7721a1969da510efbc17615f2" } wasmer-dev-utils = { path = "../dev-utils", version = "0.5.6"} [build-dependencies] diff --git a/lib/llvm-backend/Cargo.toml b/lib/llvm-backend/Cargo.toml index 08bc0b1f4d6..30ede3f1b6b 100644 --- a/lib/llvm-backend/Cargo.toml +++ b/lib/llvm-backend/Cargo.toml @@ -23,7 +23,7 @@ semver = "0.9" rustc_version = "0.2.3" [dev-dependencies] -wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "77081af74fe3ecaa300e3517c9f87233ae8cf95b" } +wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "17188863021f0ed7721a1969da510efbc17615f2" } [features] debug = ["wasmer-runtime-core/debug"] diff --git a/lib/middleware-common/Cargo.toml b/lib/middleware-common/Cargo.toml index c3e08c956a9..bd56ac6958d 100644 --- a/lib/middleware-common/Cargo.toml +++ b/lib/middleware-common/Cargo.toml @@ -14,7 +14,7 @@ wasmer-llvm-backend = { path = "../llvm-backend", version = "0.5.6", optional = wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.6", optional = true } [dev-dependencies] -wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "77081af74fe3ecaa300e3517c9f87233ae8cf95b" } +wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "17188863021f0ed7721a1969da510efbc17615f2" } criterion = "0.2" [features] diff --git a/lib/runtime/Cargo.toml b/lib/runtime/Cargo.toml index 8d65860f361..292c9e0adfa 100644 --- a/lib/runtime/Cargo.toml +++ b/lib/runtime/Cargo.toml @@ -25,7 +25,7 @@ optional = true [dev-dependencies] tempfile = "3.0.7" criterion = "0.2" -wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "77081af74fe3ecaa300e3517c9f87233ae8cf95b" } +wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "17188863021f0ed7721a1969da510efbc17615f2" } [target.'cfg(not(windows))'.dependencies.wasmer-llvm-backend] path = "../llvm-backend" diff --git a/lib/spectests/Cargo.toml b/lib/spectests/Cargo.toml index 493be6cc0c9..9f0fd729ac1 100644 --- a/lib/spectests/Cargo.toml +++ b/lib/spectests/Cargo.toml @@ -15,10 +15,10 @@ wasmer-llvm-backend = { path = "../llvm-backend", version = "0.5.6", optional = wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.6", optional = true } [build-dependencies] -wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "77081af74fe3ecaa300e3517c9f87233ae8cf95b" } +wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "17188863021f0ed7721a1969da510efbc17615f2" } [dev-dependencies] -wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "77081af74fe3ecaa300e3517c9f87233ae8cf95b" } +wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "17188863021f0ed7721a1969da510efbc17615f2" } [features] default = ["fast-tests"] From f8e8b1cdeaed553b03b6dd5a9f03becbb1111ce0 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Mon, 22 Jul 2019 10:57:42 -0700 Subject: [PATCH 24/37] Update to latest wasmer clif branch. --- Cargo.lock | 72 ++++++++++++++++++------------------- lib/clif-backend/Cargo.toml | 10 +++--- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5f6e521b1e0..716d5e7a4e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -254,20 +254,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift-bforest" -version = "0.34.0" -source = "git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc#f05f4044d42c54fc5841753030991afc026695fc" +version = "0.31.0" +source = "git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e#060c5a8e3553540144ca08ca028972c57693fa6e" dependencies = [ - "cranelift-entity 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", + "cranelift-entity 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", ] [[package]] name = "cranelift-codegen" -version = "0.34.0" -source = "git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc#f05f4044d42c54fc5841753030991afc026695fc" +version = "0.31.0" +source = "git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e#060c5a8e3553540144ca08ca028972c57693fa6e" dependencies = [ - "cranelift-bforest 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", - "cranelift-codegen-meta 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", - "cranelift-entity 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", + "cranelift-bforest 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", + "cranelift-codegen-meta 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", + "cranelift-entity 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -276,45 +276,45 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.34.0" -source = "git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc#f05f4044d42c54fc5841753030991afc026695fc" +version = "0.31.0" +source = "git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e#060c5a8e3553540144ca08ca028972c57693fa6e" dependencies = [ - "cranelift-entity 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", + "cranelift-entity 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", ] [[package]] name = "cranelift-entity" -version = "0.34.0" -source = "git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc#f05f4044d42c54fc5841753030991afc026695fc" +version = "0.31.0" +source = "git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e#060c5a8e3553540144ca08ca028972c57693fa6e" [[package]] name = "cranelift-frontend" -version = "0.34.0" -source = "git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc#f05f4044d42c54fc5841753030991afc026695fc" +version = "0.31.0" +source = "git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e#060c5a8e3553540144ca08ca028972c57693fa6e" dependencies = [ - "cranelift-codegen 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", + "cranelift-codegen 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.34.0" -source = "git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc#f05f4044d42c54fc5841753030991afc026695fc" +version = "0.31.0" +source = "git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e#060c5a8e3553540144ca08ca028972c57693fa6e" dependencies = [ - "cranelift-codegen 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", + "cranelift-codegen 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-wasm" -version = "0.34.0" -source = "git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc#f05f4044d42c54fc5841753030991afc026695fc" +version = "0.31.0" +source = "git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e#060c5a8e3553540144ca08ca028972c57693fa6e" dependencies = [ - "cranelift-codegen 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", - "cranelift-entity 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", - "cranelift-frontend 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", + "cranelift-codegen 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", + "cranelift-entity 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", + "cranelift-frontend 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1441,11 +1441,11 @@ name = "wasmer-clif-backend" version = "0.5.6" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-codegen 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", - "cranelift-entity 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", - "cranelift-frontend 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", - "cranelift-native 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", - "cranelift-wasm 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)", + "cranelift-codegen 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", + "cranelift-entity 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", + "cranelift-frontend 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", + "cranelift-native 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", + "cranelift-wasm 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1758,13 +1758,13 @@ dependencies = [ "checksum cmake 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "2ca4386c8954b76a8415b63959337d940d724b336cabd3afe189c2b51a7e1ff0" "checksum colored 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6cdb90b60f2927f8d76139c72dbde7e10c3a2bc47c8594c9c7a66529f2687c03" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" -"checksum cranelift-bforest 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)" = "" -"checksum cranelift-codegen 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)" = "" -"checksum cranelift-codegen-meta 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)" = "" -"checksum cranelift-entity 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)" = "" -"checksum cranelift-frontend 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)" = "" -"checksum cranelift-native 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)" = "" -"checksum cranelift-wasm 0.34.0 (git+https://github.com/wasmerio/cranelift.git?rev=f05f4044d42c54fc5841753030991afc026695fc)" = "" +"checksum cranelift-bforest 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)" = "" +"checksum cranelift-codegen 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)" = "" +"checksum cranelift-codegen-meta 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)" = "" +"checksum cranelift-entity 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)" = "" +"checksum cranelift-frontend 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)" = "" +"checksum cranelift-native 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)" = "" +"checksum cranelift-wasm 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)" = "" "checksum criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0363053954f3e679645fc443321ca128b7b950a6fe288cf5f9335cc22ee58394" "checksum criterion-plot 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76f9212ddf2f4a9eb2d401635190600656a1f88a932ef53d06e7fa4c7e02fb8e" "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" diff --git a/lib/clif-backend/Cargo.toml b/lib/clif-backend/Cargo.toml index 8cefab07c28..7d9c4006bfb 100644 --- a/lib/clif-backend/Cargo.toml +++ b/lib/clif-backend/Cargo.toml @@ -9,11 +9,11 @@ edition = "2018" [dependencies] wasmer-runtime-core = { path = "../runtime-core", version = "0.5.6" } -cranelift-native = { git = "https://github.com/wasmerio/cranelift.git", rev = "f05f4044d42c54fc5841753030991afc026695fc" } -cranelift-codegen = { git = "https://github.com/wasmerio/cranelift.git", rev = "f05f4044d42c54fc5841753030991afc026695fc" } -cranelift-entity = { git = "https://github.com/wasmerio/cranelift.git", rev = "f05f4044d42c54fc5841753030991afc026695fc" } -cranelift-frontend = { git = "https://github.com/wasmerio/cranelift.git", rev = "f05f4044d42c54fc5841753030991afc026695fc" } -cranelift-wasm = { git = "https://github.com/wasmerio/cranelift.git", rev = "f05f4044d42c54fc5841753030991afc026695fc" } +cranelift-native = { git = "https://github.com/wasmerio/cranelift.git", rev = "060c5a8e3553540144ca08ca028972c57693fa6e" } +cranelift-codegen = { git = "https://github.com/wasmerio/cranelift.git", rev = "060c5a8e3553540144ca08ca028972c57693fa6e" } +cranelift-entity = { git = "https://github.com/wasmerio/cranelift.git", rev = "060c5a8e3553540144ca08ca028972c57693fa6e" } +cranelift-frontend = { git = "https://github.com/wasmerio/cranelift.git", rev = "060c5a8e3553540144ca08ca028972c57693fa6e" } +cranelift-wasm = { git = "https://github.com/wasmerio/cranelift.git", rev = "060c5a8e3553540144ca08ca028972c57693fa6e" } hashbrown = "0.1" target-lexicon = "0.4.0" wasmparser = "0.34.0" From 4535274cf36022b992dd67b3fd49913219463825 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Mon, 22 Jul 2019 11:23:41 -0700 Subject: [PATCH 25/37] Update the loader interface for 128 bit types. --- lib/kernel-loader/src/lib.rs | 6 +++--- lib/kernel-loader/src/service.rs | 12 ++++++------ lib/runtime-core/src/loader.rs | 16 ++++++++-------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/kernel-loader/src/lib.rs b/lib/kernel-loader/src/lib.rs index 8abc850af33..51ca6c7da54 100644 --- a/lib/kernel-loader/src/lib.rs +++ b/lib/kernel-loader/src/lib.rs @@ -75,7 +75,7 @@ impl Loader for KernelLoader { if module.imported_globals.len() > 0 { return Err("imported globals are not supported".into()); } - let globals: Vec = unsafe { + let globals: Vec = unsafe { let globals: &[*mut LocalGlobal] = ::std::slice::from_raw_parts(ctx.globals, module.globals.len()); globals.iter().map(|x| (**x).data).collect() @@ -138,11 +138,11 @@ pub struct KernelInstance { impl Instance for KernelInstance { type Error = String; - fn call(&mut self, id: usize, args: &[Value]) -> Result { + fn call(&mut self, id: usize, args: &[Value]) -> Result { if args.len() != self.param_counts[id] { return Err("param count mismatch".into()); } - let args: Vec = args.iter().map(|x| x.to_u64()).collect(); + let args: Vec = args.iter().map(|x| x.to_u128()).collect(); let ret = self .context diff --git a/lib/kernel-loader/src/service.rs b/lib/kernel-loader/src/service.rs index 45ccdd869be..2477cc30f12 100644 --- a/lib/kernel-loader/src/service.rs +++ b/lib/kernel-loader/src/service.rs @@ -54,7 +54,7 @@ struct LoadCodeRequest { memory_max: u32, table: *const TableEntryRequest, table_count: u32, - globals: *const u64, + globals: *const u128, global_count: u32, imported_funcs: *const ImportRequest, @@ -67,7 +67,7 @@ struct LoadCodeRequest { #[repr(C)] struct RunCodeRequest { entry_offset: u32, - params: *const u64, + params: *const u128, param_count: u32, result: *mut RunCodeResult, } @@ -75,7 +75,7 @@ struct RunCodeRequest { #[repr(C)] struct RunCodeResult { success: u32, - retval: u64, + retval: u128, } #[repr(C)] @@ -108,7 +108,7 @@ pub struct LoadProfile<'a> { pub code: &'a [u8], pub memory: Option<&'a [u8]>, pub memory_max: usize, - pub globals: &'a [u64], + pub globals: &'a [u128], pub imports: &'a [ImportInfo], pub dynamic_sigindices: &'a [u32], pub table: Option<&'a [TableEntryRequest]>, @@ -121,7 +121,7 @@ pub struct ImportInfo { pub struct RunProfile<'a> { pub entry_offset: u32, - pub params: &'a [u64], + pub params: &'a [u128], } pub struct ServiceContext { @@ -181,7 +181,7 @@ impl ServiceContext { } } - pub fn run_code(&mut self, run: RunProfile) -> ServiceResult { + pub fn run_code(&mut self, run: RunProfile) -> ServiceResult { let mut result: RunCodeResult = unsafe { ::std::mem::zeroed() }; let mut req = RunCodeRequest { entry_offset: run.entry_offset, diff --git a/lib/runtime-core/src/loader.rs b/lib/runtime-core/src/loader.rs index b02e9e8594d..44be58ce930 100644 --- a/lib/runtime-core/src/loader.rs +++ b/lib/runtime-core/src/loader.rs @@ -20,7 +20,7 @@ pub trait Loader { pub trait Instance { type Error: Debug; - fn call(&mut self, id: usize, args: &[Value]) -> Result; + fn call(&mut self, id: usize, args: &[Value]) -> Result; fn read_memory(&mut self, _offset: u32, _len: u32) -> Result, Self::Error> { unimplemented!() } @@ -61,7 +61,7 @@ pub struct LocalInstance { impl Instance for LocalInstance { type Error = String; - fn call(&mut self, id: usize, args: &[Value]) -> Result { + fn call(&mut self, id: usize, args: &[Value]) -> Result { let mut args_u64: Vec = Vec::new(); for arg in args { if arg.ty() == Type::V128 { @@ -81,23 +81,23 @@ impl Instance for LocalInstance { use std::mem::transmute; Ok(unsafe { match args_u64.len() { - 0 => (transmute::<_, extern "C" fn() -> u64>(addr))(), - 1 => (transmute::<_, extern "C" fn(u64) -> u64>(addr))(args_u64[0]), + 0 => (transmute::<_, extern "C" fn() -> u128>(addr))(), + 1 => (transmute::<_, extern "C" fn(u64) -> u128>(addr))(args_u64[0]), 2 => { - (transmute::<_, extern "C" fn(u64, u64) -> u64>(addr))(args_u64[0], args_u64[1]) + (transmute::<_, extern "C" fn(u64, u64) -> u128>(addr))(args_u64[0], args_u64[1]) } - 3 => (transmute::<_, extern "C" fn(u64, u64, u64) -> u64>(addr))( + 3 => (transmute::<_, extern "C" fn(u64, u64, u64) -> u128>(addr))( args_u64[0], args_u64[1], args_u64[2], ), - 4 => (transmute::<_, extern "C" fn(u64, u64, u64, u64) -> u64>(addr))( + 4 => (transmute::<_, extern "C" fn(u64, u64, u64, u64) -> u128>(addr))( args_u64[0], args_u64[1], args_u64[2], args_u64[3], ), - 5 => (transmute::<_, extern "C" fn(u64, u64, u64, u64, u64) -> u64>(addr))( + 5 => (transmute::<_, extern "C" fn(u64, u64, u64, u64, u64) -> u128>(addr))( args_u64[0], args_u64[1], args_u64[2], From 18307bb79c1ad1a50893b2b1bca1e626dd62f23e Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Mon, 22 Jul 2019 12:15:56 -0700 Subject: [PATCH 26/37] Improve panic/unreachable/unimplemented usage. Refactor a little. --- lib/clif-backend/src/module.rs | 2 +- lib/llvm-backend/src/code.rs | 31 ++++++++----------------------- lib/runtime-c-api/src/export.rs | 2 +- lib/runtime-c-api/src/instance.rs | 2 +- lib/runtime-c-api/src/value.rs | 10 +++++----- lib/runtime-core/src/instance.rs | 2 +- lib/runtime-core/src/loader.rs | 7 ++++--- 7 files changed, 21 insertions(+), 35 deletions(-) diff --git a/lib/clif-backend/src/module.rs b/lib/clif-backend/src/module.rs index 91e14bf7ced..e7f73b9d0fd 100644 --- a/lib/clif-backend/src/module.rs +++ b/lib/clif-backend/src/module.rs @@ -108,7 +108,7 @@ impl From> for Type { ir::types::F32 => Type::F32, ir::types::F64 => Type::F64, ir::types::I32X4 => Type::V128, - _ => panic!("unsupported wasm type"), + _ => unimplemented!("unsupported wasm type"), } } } diff --git a/lib/llvm-backend/src/code.rs b/lib/llvm-backend/src/code.rs index dd42ae39a73..2d2fddcb723 100644 --- a/lib/llvm-backend/src/code.rs +++ b/lib/llvm-backend/src/code.rs @@ -111,12 +111,11 @@ fn trunc_sat( // int_min or int_max. let is_signed = int_min_value != 0; + let ivec_element_ty = ivec_ty.get_element_type().into_int_type(); let int_min_value = splat_vector( builder, intrinsics, - ivec_ty - .get_element_type() - .into_int_type() + ivec_element_ty .const_int(int_min_value, is_signed) .as_basic_value_enum(), ivec_ty, @@ -125,9 +124,7 @@ fn trunc_sat( let int_max_value = splat_vector( builder, intrinsics, - ivec_ty - .get_element_type() - .into_int_type() + ivec_element_ty .const_int(int_max_value, is_signed) .as_basic_value_enum(), ivec_ty, @@ -135,38 +132,26 @@ fn trunc_sat( ); let lower_bound = if is_signed { builder.build_signed_int_to_float( - ivec_ty - .get_element_type() - .into_int_type() - .const_int(lower_bound, is_signed), + ivec_element_ty.const_int(lower_bound, is_signed), fvec_ty.get_element_type().into_float_type(), "", ) } else { builder.build_unsigned_int_to_float( - ivec_ty - .get_element_type() - .into_int_type() - .const_int(lower_bound, is_signed), + ivec_element_ty.const_int(lower_bound, is_signed), fvec_ty.get_element_type().into_float_type(), "", ) }; let upper_bound = if is_signed { builder.build_signed_int_to_float( - ivec_ty - .get_element_type() - .into_int_type() - .const_int(upper_bound, is_signed), + ivec_element_ty.const_int(upper_bound, is_signed), fvec_ty.get_element_type().into_float_type(), "", ) } else { builder.build_unsigned_int_to_float( - ivec_ty - .get_element_type() - .into_int_type() - .const_int(upper_bound, is_signed), + ivec_element_ty.const_int(upper_bound, is_signed), fvec_ty.get_element_type().into_float_type(), "", ) @@ -3948,7 +3933,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { Operator::I16x8AllTrue => intrinsics.i16x8_ty, Operator::I32x4AllTrue => intrinsics.i32x4_ty, Operator::I64x2AllTrue => intrinsics.i64x2_ty, - _ => panic!(), + _ => unreachable!(), }; let v = state.pop1()?.into_int_value(); let lane_int_ty = context.custom_width_int_type(vec_ty.get_size()); diff --git a/lib/runtime-c-api/src/export.rs b/lib/runtime-c-api/src/export.rs index d93f987a4d8..2facfe6c3fe 100644 --- a/lib/runtime-c-api/src/export.rs +++ b/lib/runtime-c-api/src/export.rs @@ -402,7 +402,7 @@ pub unsafe extern "C" fn wasmer_export_func_call( tag: wasmer_value_tag::WASM_F64, value: wasmer_value { F64: x }, }, - _ => panic!("not implemented"), + Value::V128(_) => unimplemented!("returning V128 type"), }; results[0] = ret; } diff --git a/lib/runtime-c-api/src/instance.rs b/lib/runtime-c-api/src/instance.rs index 4fc76f7665c..5a1f8719a92 100644 --- a/lib/runtime-c-api/src/instance.rs +++ b/lib/runtime-c-api/src/instance.rs @@ -173,7 +173,7 @@ pub unsafe extern "C" fn wasmer_instance_call( tag: wasmer_value_tag::WASM_F64, value: wasmer_value { F64: x }, }, - _ => panic!("not implemented"), + Value::V128(_) => unimplemented!("calling function with V128 parameter"), }; results[0] = ret; } diff --git a/lib/runtime-c-api/src/value.rs b/lib/runtime-c-api/src/value.rs index 62f62c3acdb..e8e4019ad1d 100644 --- a/lib/runtime-c-api/src/value.rs +++ b/lib/runtime-c-api/src/value.rs @@ -51,7 +51,7 @@ impl From for Value { tag: wasmer_value_tag::WASM_F64, value: wasmer_value { F64 }, } => Value::F64(F64), - _ => panic!("not implemented"), + _ => unreachable!("unknown WASM type"), } } } @@ -76,7 +76,7 @@ impl From for wasmer_value_t { tag: wasmer_value_tag::WASM_F64, value: wasmer_value { F64: x }, }, - _ => panic!("not implemented"), + Value::V128(_) => unimplemented!("V128 not supported in C API"), } } } @@ -89,7 +89,7 @@ impl From for wasmer_value_tag { Type::I64 => wasmer_value_tag::WASM_I64, Type::F32 => wasmer_value_tag::WASM_F32, Type::F64 => wasmer_value_tag::WASM_F64, - _ => panic!("not implemented"), + Type::V128 => unreachable!("V128 not supported in C API"), } } } @@ -102,7 +102,7 @@ impl From for Type { wasmer_value_tag::WASM_I64 => Type::I64, wasmer_value_tag::WASM_F32 => Type::F32, wasmer_value_tag::WASM_F64 => Type::F64, - _ => panic!("not implemented"), + _ => unreachable!("unknown WASM type"), } } } @@ -114,7 +114,7 @@ impl From<&wasmer_runtime::wasm::Type> for wasmer_value_tag { Type::I64 => wasmer_value_tag::WASM_I64, Type::F32 => wasmer_value_tag::WASM_F32, Type::F64 => wasmer_value_tag::WASM_F64, - _ => panic!("not implemented"), + Type::V128 => unimplemented!("V128 not supported in C API"), } } } diff --git a/lib/runtime-core/src/instance.rs b/lib/runtime-core/src/instance.rs index d724e9bd47f..bc9e27636b9 100644 --- a/lib/runtime-core/src/instance.rs +++ b/lib/runtime-core/src/instance.rs @@ -618,7 +618,7 @@ fn call_func_with_index( Type::I64 => Value::I64(raw as i64), Type::F32 => Value::F32(f32::from_bits(raw as u32)), Type::F64 => Value::F64(f64::from_bits(raw)), - _ => unreachable!(), + Type::V128 => unreachable!("V128 does not map to any single value"), }; match signature.returns() { diff --git a/lib/runtime-core/src/loader.rs b/lib/runtime-core/src/loader.rs index 44be58ce930..9a790c6a40d 100644 --- a/lib/runtime-core/src/loader.rs +++ b/lib/runtime-core/src/loader.rs @@ -83,9 +83,10 @@ impl Instance for LocalInstance { match args_u64.len() { 0 => (transmute::<_, extern "C" fn() -> u128>(addr))(), 1 => (transmute::<_, extern "C" fn(u64) -> u128>(addr))(args_u64[0]), - 2 => { - (transmute::<_, extern "C" fn(u64, u64) -> u128>(addr))(args_u64[0], args_u64[1]) - } + 2 => (transmute::<_, extern "C" fn(u64, u64) -> u128>(addr))( + args_u64[0], + args_u64[1], + ), 3 => (transmute::<_, extern "C" fn(u64, u64, u64) -> u128>(addr))( args_u64[0], args_u64[1], From a301c7abd5be2d3ace87eff690fa96070aed62ae Mon Sep 17 00:00:00 2001 From: Syrus Date: Mon, 22 Jul 2019 14:01:37 -0700 Subject: [PATCH 27/37] Updated LLVM to 8.0 --- .appveyor.yml | 4 ++-- .circleci/config.yml | 30 +++++++++++++++--------------- Dockerfile | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index c057f81d348..65a70559613 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -24,11 +24,11 @@ install: # # Install LLVM # - mkdir C:\projects\deps # - cd C:\projects\deps - # - appveyor DownloadFile http://prereleases.llvm.org/win-snapshots/LLVM-7.0.0-r336178-win64.exe -FileName llvm.exe + # - appveyor DownloadFile https://prereleases.llvm.org/win-snapshots/LLVM-8.0.0-r351033-win64.exe -FileName llvm.exe # - 7z x llvm.exe -oC:\projects\deps\llvm # # - set "PATH=%PATH%;C:\projects\deps\llvm\bin" # - set "LLD_LINK=C:\projects\deps\llvm\bin\lld-link.exe" - # - set "LLVM_SYS_70_PREFIX=C:\projects\deps\llvm" + # - set "LLVM_SYS_80_PREFIX=C:\projects\deps\llvm" # - cd "%APPVEYOR_BUILD_FOLDER%" # Install Rust diff --git a/.circleci/config.yml b/.circleci/config.yml index 40c2772ea7c..41250014ea6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,14 +1,14 @@ run_with_build_env_vars: &run_with_build_env_vars environment: - LLVM_SYS_70_PREFIX: /home/circleci/project/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04/ + LLVM_SYS_80_PREFIX: /home/circleci/project/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/ run_install_dependencies: &run_install_dependencies run: name: install dependencies command: | sudo apt-get install -y cmake - curl -O https://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz - tar xf clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz + curl -O https://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz + tar xf clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz version: 2 jobs: @@ -149,8 +149,8 @@ jobs: tar xf cmake-3.4.1-Darwin-x86_64.tar.gz export PATH="`pwd`/cmake-3.4.1-Darwin-x86_64/CMake.app/Contents/bin:$PATH" # Installing LLVM outside of brew - curl -O https://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-apple-darwin.tar.xz - tar xf clang+llvm-7.0.0-x86_64-apple-darwin.tar.xz + curl -O https://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-apple-darwin.tar.xz + tar xf clang+llvm-8.0.0-x86_64-apple-darwin.tar.xz - run: name: Install Rust command: | @@ -162,7 +162,7 @@ jobs: command: | export PATH="$HOME/.cargo/bin:$PATH" export PATH="`pwd`/cmake-3.4.1-Darwin-x86_64/CMake.app/Contents/bin:$PATH" - export LLVM_SYS_70_PREFIX="`pwd`/clang+llvm-7.0.0-x86_64-apple-darwin/" + export LLVM_SYS_80_PREFIX="`pwd`/clang+llvm-8.0.0-x86_64-apple-darwin/" # We increase the ulimit for fixing cargo unclosed files in mac ulimit -n 8000 sudo sysctl -w kern.maxfiles=655360 kern.maxfilesperproc=327680 @@ -182,7 +182,7 @@ jobs: command: | export PATH="$HOME/.cargo/bin:$PATH" export PATH="`pwd`/cmake-3.4.1-Darwin-x86_64/CMake.app/Contents/bin:$PATH" - export LLVM_SYS_70_PREFIX="`pwd`/clang+llvm-7.0.0-x86_64-apple-darwin/" + export LLVM_SYS_80_PREFIX="`pwd`/clang+llvm-8.0.0-x86_64-apple-darwin/" make integration-tests - save_cache: paths: @@ -213,18 +213,18 @@ jobs: name: Install dependencies command: | sudo apt-get install -y cmake - curl -O https://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz - tar xf clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz + curl -O https://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz + tar xf clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz - run: rustup default nightly-2019-06-10 - run: name: Tests command: | - export LLVM_SYS_70_PREFIX="`pwd`/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04/" + export LLVM_SYS_80_PREFIX="`pwd`/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/" make test - run: name: Release Build command: | - export LLVM_SYS_70_PREFIX="`pwd`/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04/" + export LLVM_SYS_80_PREFIX="`pwd`/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/" make release cargo build --release --manifest-path wapm-cli/Cargo.toml --features telemetry mkdir -p artifacts @@ -275,8 +275,8 @@ jobs: tar xf cmake-3.4.1-Darwin-x86_64.tar.gz export PATH="`pwd`/cmake-3.4.1-Darwin-x86_64/CMake.app/Contents/bin:$PATH" # Installing LLVM outside of brew - curl -O https://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-apple-darwin.tar.xz - tar xf clang+llvm-7.0.0-x86_64-apple-darwin.tar.xz + curl -O https://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-apple-darwin.tar.xz + tar xf clang+llvm-8.0.0-x86_64-apple-darwin.tar.xz - run: name: Install Rust command: | @@ -288,7 +288,7 @@ jobs: command: | export PATH="`pwd`/cmake-3.4.1-Darwin-x86_64/CMake.app/Contents/bin:$PATH" export PATH="$HOME/.cargo/bin:$PATH" - export LLVM_SYS_70_PREFIX="`pwd`/clang+llvm-7.0.0-x86_64-apple-darwin/" + export LLVM_SYS_80_PREFIX="`pwd`/clang+llvm-8.0.0-x86_64-apple-darwin/" # We increase the ulimit for fixing cargo unclosed files in mac ulimit -n 8000 sudo sysctl -w kern.maxfiles=655360 kern.maxfilesperproc=327680 @@ -299,7 +299,7 @@ jobs: command: | export PATH="`pwd`/cmake-3.4.1-Darwin-x86_64/CMake.app/Contents/bin:$PATH" export PATH="$HOME/.cargo/bin:$PATH" - export LLVM_SYS_70_PREFIX="`pwd`/clang+llvm-7.0.0-x86_64-apple-darwin/" + export LLVM_SYS_80_PREFIX="`pwd`/clang+llvm-8.0.0-x86_64-apple-darwin/" make release cargo build --release --manifest-path wapm-cli/Cargo.toml --features telemetry mkdir -p artifacts diff --git a/Dockerfile b/Dockerfile index 02ea6c413a2..43fcda359fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,9 +3,9 @@ RUN sudo apt-get update && \ sudo apt-get install -y --no-install-recommends \ cmake \ && sudo rm -rf /var/lib/apt/lists/* -RUN curl -SL https://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz \ +RUN curl -SL https://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz \ | tar -xJC /home/circleci -ENV LLVM_SYS_70_PREFIX /home/circleci/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04/ +ENV LLVM_SYS_80_PREFIX /home/circleci/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/ FROM wasmer-build-env AS wasmer-debug-env RUN sudo apt-get update && \ From d6546f7ab693fab7526fd4b14c9f7f36df404c31 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Mon, 22 Jul 2019 16:47:09 -0700 Subject: [PATCH 28/37] Write out full 128 bit return value. --- src/bin/kwasmd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/kwasmd.rs b/src/bin/kwasmd.rs index def71d589a1..f3a695920e4 100644 --- a/src/bin/kwasmd.rs +++ b/src/bin/kwasmd.rs @@ -94,7 +94,7 @@ fn handle_client(mut stream: UnixStream) { match ret { Ok(x) => { stream.write_u32::(1).unwrap(); - stream.write_u64::(x).unwrap(); + stream.write_u128::(x).unwrap(); } Err(e) => { println!("Execution error: {:?}", e); From 4b77fae9914cd733b729429c2577bb4190f3f5da Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Mon, 22 Jul 2019 16:49:21 -0700 Subject: [PATCH 29/37] Temporarily disable kernel-loader by adding a panic! to kwasmd. I expect that the V128 changes have broken kernel-loader because I haven't taken care to ensure that the interface was updated the same way on both sides. --- src/bin/kwasmd.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bin/kwasmd.rs b/src/bin/kwasmd.rs index f3a695920e4..bee9984716f 100644 --- a/src/bin/kwasmd.rs +++ b/src/bin/kwasmd.rs @@ -157,6 +157,7 @@ fn run_listen(opts: Listen) { #[cfg(feature = "loader-kernel")] fn main() { + panic!("Kwasm not updated for 128-bit support, yet. Sorry!"); let options = CLIOptions::from_args(); match options { CLIOptions::Listen(listen) => { From fadb975114bedf92e71fa7000280d1431b9569e9 Mon Sep 17 00:00:00 2001 From: Syrus Date: Mon, 22 Jul 2019 17:45:54 -0700 Subject: [PATCH 30/37] Fixed macos check --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 41250014ea6..49a69dd3ad1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -171,6 +171,7 @@ jobs: name: Check command: | export PATH="$HOME/.cargo/bin:$PATH" + export LLVM_SYS_80_PREFIX="`pwd`/clang+llvm-8.0.0-x86_64-apple-darwin/" make check - run: name: Release From 5ef19b76a00aef0413182251f308709ce6675717 Mon Sep 17 00:00:00 2001 From: Syrus Date: Mon, 22 Jul 2019 17:50:10 -0700 Subject: [PATCH 31/37] Updated README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 62f4f9fa700..21c9a0ba3b8 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ nginx and Lua do not work on Windows. See [this issue](https://github.com/wasmer 5. Install [CMake](https://cmake.org/download/). Ensure CMake is in your PATH. -6. Install [LLVM 7.0](https://prereleases.llvm.org/win-snapshots/LLVM-7.0.0-r336178-win64.exe) +6. Install [LLVM 8.0](https://prereleases.llvm.org/win-snapshots/LLVM-8.0.0-r351033-win64.exe) ## Building From fe2bd6ad6c847e32c6dec76f47b816e6091dfa7d Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 23 Jul 2019 10:15:22 -0700 Subject: [PATCH 32/37] Add missing names to LLVM instructions. --- lib/llvm-backend/src/code.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/llvm-backend/src/code.rs b/lib/llvm-backend/src/code.rs index 2d2fddcb723..dde3628c807 100644 --- a/lib/llvm-backend/src/code.rs +++ b/lib/llvm-backend/src/code.rs @@ -1355,7 +1355,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let v1 = builder.build_bitcast(v1, intrinsics.i8x16_ty, ""); let v2 = builder.build_bitcast(v2, intrinsics.i8x16_ty, ""); let res = builder - .build_call(intrinsics.sadd_sat_i8x16, &[v1, v2], "") + .build_call(intrinsics.sadd_sat_i8x16, &[v1, v2], &state.var_name()) .try_as_basic_value() .left() .unwrap(); @@ -1368,7 +1368,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let v1 = builder.build_bitcast(v1, intrinsics.i16x8_ty, ""); let v2 = builder.build_bitcast(v2, intrinsics.i16x8_ty, ""); let res = builder - .build_call(intrinsics.sadd_sat_i16x8, &[v1, v2], "") + .build_call(intrinsics.sadd_sat_i16x8, &[v1, v2], &state.var_name()) .try_as_basic_value() .left() .unwrap(); @@ -1381,7 +1381,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let v1 = builder.build_bitcast(v1, intrinsics.i8x16_ty, ""); let v2 = builder.build_bitcast(v2, intrinsics.i8x16_ty, ""); let res = builder - .build_call(intrinsics.uadd_sat_i8x16, &[v1, v2], "") + .build_call(intrinsics.uadd_sat_i8x16, &[v1, v2], &state.var_name()) .try_as_basic_value() .left() .unwrap(); @@ -1394,7 +1394,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let v1 = builder.build_bitcast(v1, intrinsics.i16x8_ty, ""); let v2 = builder.build_bitcast(v2, intrinsics.i16x8_ty, ""); let res = builder - .build_call(intrinsics.uadd_sat_i16x8, &[v1, v2], "") + .build_call(intrinsics.uadd_sat_i16x8, &[v1, v2], &state.var_name()) .try_as_basic_value() .left() .unwrap(); @@ -1465,7 +1465,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let v1 = builder.build_bitcast(v1, intrinsics.i8x16_ty, ""); let v2 = builder.build_bitcast(v2, intrinsics.i8x16_ty, ""); let res = builder - .build_call(intrinsics.ssub_sat_i8x16, &[v1, v2], "") + .build_call(intrinsics.ssub_sat_i8x16, &[v1, v2], &state.var_name()) .try_as_basic_value() .left() .unwrap(); @@ -1478,7 +1478,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let v1 = builder.build_bitcast(v1, intrinsics.i16x8_ty, ""); let v2 = builder.build_bitcast(v2, intrinsics.i16x8_ty, ""); let res = builder - .build_call(intrinsics.ssub_sat_i16x8, &[v1, v2], "") + .build_call(intrinsics.ssub_sat_i16x8, &[v1, v2], &state.var_name()) .try_as_basic_value() .left() .unwrap(); @@ -1491,7 +1491,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let v1 = builder.build_bitcast(v1, intrinsics.i8x16_ty, ""); let v2 = builder.build_bitcast(v2, intrinsics.i8x16_ty, ""); let res = builder - .build_call(intrinsics.usub_sat_i8x16, &[v1, v2], "") + .build_call(intrinsics.usub_sat_i8x16, &[v1, v2], &state.var_name()) .try_as_basic_value() .left() .unwrap(); @@ -1504,7 +1504,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let v1 = builder.build_bitcast(v1, intrinsics.i16x8_ty, ""); let v2 = builder.build_bitcast(v2, intrinsics.i16x8_ty, ""); let res = builder - .build_call(intrinsics.usub_sat_i16x8, &[v1, v2], "") + .build_call(intrinsics.usub_sat_i16x8, &[v1, v2], &state.var_name()) .try_as_basic_value() .left() .unwrap(); From 0ed104b54357f5aea60e7bc90c55e54101a8990d Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 23 Jul 2019 17:13:02 -0700 Subject: [PATCH 33/37] Remove incorrect comment -- wasmer does support mutable globals. The reason this test needed to be disabled is correctly documented in the comment above. --- lib/spectests/spectests/simd.wast | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/spectests/spectests/simd.wast b/lib/spectests/spectests/simd.wast index b4de7fc6141..351b8230809 100644 --- a/lib/spectests/spectests/simd.wast +++ b/lib/spectests/spectests/simd.wast @@ -12,7 +12,6 @@ ;; wasmer silently doesn't implement (register) yet ;;(module $M ;; (global (export "a") v128 (v128.const f32x4 0.0 1.0 2.0 3.0)) -;; Wasmer does not yet support mutable global variables. ;; (global (export "b") (mut v128) (v128.const f32x4 4.0 5.0 6.0 7.0)) ;;) ;;(register "M" $M) From f763de94ab0dc932ace46bfe32a056f90f41fdca Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Wed, 24 Jul 2019 10:03:08 -0700 Subject: [PATCH 34/37] Update to wabt 0.9.0. --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 4 ++-- lib/emscripten-tests/Cargo.toml | 2 +- lib/llvm-backend/Cargo.toml | 2 +- lib/middleware-common/Cargo.toml | 2 +- lib/runtime/Cargo.toml | 2 +- lib/spectests/Cargo.toml | 4 ++-- lib/spectests/build/spectests.rs | 5 ++++- 8 files changed, 25 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cf8a720e68f..15031ecb7bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1382,19 +1382,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wabt" -version = "0.8.0" -source = "git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2#17188863021f0ed7721a1969da510efbc17615f2" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt-sys 0.6.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2)", + "wabt-sys 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wabt-sys" -version = "0.6.0" -source = "git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2#17188863021f0ed7721a1969da510efbc17615f2" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "cmake 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1421,7 +1421,7 @@ dependencies = [ "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2)", + "wabt 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-clif-backend 0.5.7", "wasmer-dev-utils 0.5.7", "wasmer-emscripten 0.5.7", @@ -1486,7 +1486,7 @@ name = "wasmer-emscripten-tests" version = "0.5.7" dependencies = [ "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2)", + "wabt 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-clif-backend 0.5.7", "wasmer-dev-utils 0.5.7", "wasmer-emscripten 0.5.7", @@ -1519,7 +1519,7 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2)", + "wabt 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-runtime-core 0.5.7", "wasmparser 0.34.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1529,7 +1529,7 @@ name = "wasmer-middleware-common" version = "0.5.7" dependencies = [ "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2)", + "wabt 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-clif-backend 0.5.7", "wasmer-llvm-backend 0.5.7", "wasmer-runtime-core 0.5.7", @@ -1544,7 +1544,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2)", + "wabt 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-clif-backend 0.5.7", "wasmer-llvm-backend 0.5.7", "wasmer-runtime-core 0.5.7", @@ -1611,7 +1611,7 @@ dependencies = [ name = "wasmer-spectests" version = "0.5.7" dependencies = [ - "wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2)", + "wabt 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-clif-backend 0.5.7", "wasmer-llvm-backend 0.5.7", "wasmer-runtime-core 0.5.7", @@ -1892,8 +1892,8 @@ dependencies = [ "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum wabt 0.8.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2)" = "" -"checksum wabt-sys 0.6.0 (git+https://github.com/wasmerio/wabt-rs.git?rev=17188863021f0ed7721a1969da510efbc17615f2)" = "" +"checksum wabt 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d07edd40d190ddcbd0113c2150ccb214f47a02ff36958630ba0e5b8138ece1c1" +"checksum wabt-sys 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b064c81821100adb4b71923cecfc67fef083db21c3bbd454b0162c7ffe63eeaa" "checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1" "checksum wasmparser 0.34.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8030ec5a7c242a91941947fdb752e9a7c0929aced954ea23c54dad1cd2611850" "checksum which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164" diff --git a/Cargo.toml b/Cargo.toml index c95625996c8..1a343280332 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ include = [ byteorder = "1.3.1" errno = "0.2.4" structopt = "0.2.11" -wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "17188863021f0ed7721a1969da510efbc17615f2" } +wabt = "0.9.0" hashbrown = "0.1.8" wasmer-clif-backend = { path = "lib/clif-backend" } wasmer-singlepass-backend = { path = "lib/singlepass-backend", optional = true } @@ -61,7 +61,7 @@ members = [ ] [build-dependencies] -wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "17188863021f0ed7721a1969da510efbc17615f2" } +wabt = "0.9.0" glob = "0.2.11" rustc_version = "0.2.3" diff --git a/lib/emscripten-tests/Cargo.toml b/lib/emscripten-tests/Cargo.toml index e81900f6b8f..3928b7c05e8 100644 --- a/lib/emscripten-tests/Cargo.toml +++ b/lib/emscripten-tests/Cargo.toml @@ -16,7 +16,7 @@ wasmer-llvm-backend = { path = "../llvm-backend", version = "0.5.7", optional = wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.7", optional = true } [dev-dependencies] -wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "17188863021f0ed7721a1969da510efbc17615f2" } +wabt = "0.9.0" wasmer-dev-utils = { path = "../dev-utils", version = "0.5.7"} [build-dependencies] diff --git a/lib/llvm-backend/Cargo.toml b/lib/llvm-backend/Cargo.toml index bcbdcb93fcf..4bc38202cba 100644 --- a/lib/llvm-backend/Cargo.toml +++ b/lib/llvm-backend/Cargo.toml @@ -23,7 +23,7 @@ semver = "0.9" rustc_version = "0.2.3" [dev-dependencies] -wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "17188863021f0ed7721a1969da510efbc17615f2" } +wabt = "0.9.0" [features] debug = ["wasmer-runtime-core/debug"] diff --git a/lib/middleware-common/Cargo.toml b/lib/middleware-common/Cargo.toml index 634680591ef..d7aa7a2efb9 100644 --- a/lib/middleware-common/Cargo.toml +++ b/lib/middleware-common/Cargo.toml @@ -14,7 +14,7 @@ wasmer-llvm-backend = { path = "../llvm-backend", version = "0.5.7", optional = wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.7", optional = true } [dev-dependencies] -wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "17188863021f0ed7721a1969da510efbc17615f2" } +wabt = "0.9.0" criterion = "0.2" [features] diff --git a/lib/runtime/Cargo.toml b/lib/runtime/Cargo.toml index 797044e0178..d613ded7de8 100644 --- a/lib/runtime/Cargo.toml +++ b/lib/runtime/Cargo.toml @@ -25,7 +25,7 @@ optional = true [dev-dependencies] tempfile = "3.0.7" criterion = "0.2" -wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "17188863021f0ed7721a1969da510efbc17615f2" } +wabt = "0.9.0" [target.'cfg(not(windows))'.dependencies.wasmer-llvm-backend] path = "../llvm-backend" diff --git a/lib/spectests/Cargo.toml b/lib/spectests/Cargo.toml index 227ed1fb784..343690e8a5c 100644 --- a/lib/spectests/Cargo.toml +++ b/lib/spectests/Cargo.toml @@ -15,10 +15,10 @@ wasmer-llvm-backend = { path = "../llvm-backend", version = "0.5.7", optional = wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.7", optional = true } [build-dependencies] -wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "17188863021f0ed7721a1969da510efbc17615f2" } +wabt = "0.9.0" [dev-dependencies] -wabt = { git = "https://github.com/wasmerio/wabt-rs.git", rev = "17188863021f0ed7721a1969da510efbc17615f2" } +wabt = "0.9.0" [features] default = ["fast-tests"] diff --git a/lib/spectests/build/spectests.rs b/lib/spectests/build/spectests.rs index 35cdd5ffc60..a19ac14b6fc 100644 --- a/lib/spectests/build/spectests.rs +++ b/lib/spectests/build/spectests.rs @@ -749,7 +749,10 @@ fn {}() {{ } => { // Do nothing for now } - CommandKind::AssertExhaustion { action: _ } => { + CommandKind::AssertExhaustion { + action: _, + message: _, + } => { // Do nothing for now } CommandKind::AssertUnlinkable { From 5c1b7d2e5ba11f4f5c244ba915f511a661d17d27 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Wed, 24 Jul 2019 11:14:44 -0700 Subject: [PATCH 35/37] Adds the SIMD tests from binaryren, updated to work with wasmer. This test is too large and therefore does not run by default, see `fn is_fat_test` in spectests.rs. --- lib/spectests/build/spectests.rs | 2 + lib/spectests/spectests/simd_binaryen.wast | 679 +++++++++++++++++++++ 2 files changed, 681 insertions(+) create mode 100644 lib/spectests/spectests/simd_binaryen.wast diff --git a/lib/spectests/build/spectests.rs b/lib/spectests/build/spectests.rs index a19ac14b6fc..e3fdde530eb 100644 --- a/lib/spectests/build/spectests.rs +++ b/lib/spectests/build/spectests.rs @@ -74,6 +74,8 @@ const TESTS: &[&str] = &[ "spectests/unwind.wast", #[cfg(feature = "llvm")] "spectests/simd.wast", + #[cfg(feature = "llvm")] + "spectests/simd_binaryen.wast", ]; static COMMON: &'static str = r##" diff --git a/lib/spectests/spectests/simd_binaryen.wast b/lib/spectests/spectests/simd_binaryen.wast new file mode 100644 index 00000000000..9747e7ac47f --- /dev/null +++ b/lib/spectests/spectests/simd_binaryen.wast @@ -0,0 +1,679 @@ +;; +;; https://github.com/WebAssembly/binaryen/blob/master/test/spec/simd.wast +;; +;; Distributed under the Apache License +;; https://github.com/WebAssembly/binaryen/blob/master/test/spec/LICENSE +;; +;; Modified by wasmer to work with the wabt parser. + +(module + (memory 1) + (data (i32.const 128) "WASMSIMDGOESFAST") + (func (export "v128.load") (param $0 i32) (result v128)(v128.load (local.get $0))) + (func (export "v128.store") (param $0 i32) (param $1 v128) (result v128) + (v128.store offset=0 align=16 (local.get $0) (local.get $1)) + (v128.load (local.get $0)) + ) + (func (export "v128.const.i8x16") (result v128) (v128.const i8x16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)) + (func (export "v128.const.i16x8") (result v128) (v128.const i16x8 1 2 3 4 5 6 7 8)) + (func (export "v128.const.i32x4") (result v128) (v128.const i32x4 1 2 3 4)) + (func (export "v128.const.i64x2") (result v128) (v128.const i64x2 1 2)) + (func (export "v128.const.f32x4") (result v128) (v128.const f32x4 1.0 2.0 3.0 4.0)) + (func (export "v128.const.f64x2") (result v128) (v128.const f64x2 1.0 2.0)) + (func (export "v128.shuffle_interleave_bytes") (param $0 v128) (param $1 v128) (result v128) + (v8x16.shuffle 0 17 2 19 4 21 6 23 8 25 10 27 12 29 14 31 (local.get $0) (local.get $1)) + ) + (func (export "v128.shuffle_reverse_i32s") (param $0 v128) (result v128) + (v8x16.shuffle 12 13 14 15 8 9 10 11 4 5 6 7 0 1 2 3 (local.get $0) (local.get $0)) + ) + (func (export "i8x16.splat") (param $0 i32) (result v128) (i8x16.splat (local.get $0))) + (func (export "i8x16.extract_lane_s_first") (param $0 v128) (result i32) (i8x16.extract_lane_s 0 (local.get $0))) + (func (export "i8x16.extract_lane_s_last") (param $0 v128) (result i32) (i8x16.extract_lane_s 15 (local.get $0))) + (func (export "i8x16.extract_lane_u_first") (param $0 v128) (result i32) (i8x16.extract_lane_u 0 (local.get $0))) + (func (export "i8x16.extract_lane_u_last") (param $0 v128) (result i32) (i8x16.extract_lane_u 15 (local.get $0))) + (func (export "i8x16.replace_lane_first") (param $0 v128) (param $1 i32) (result v128) (i8x16.replace_lane 0 (local.get $0) (local.get $1))) + (func (export "i8x16.replace_lane_last") (param $0 v128) (param $1 i32) (result v128) (i8x16.replace_lane 15 (local.get $0) (local.get $1))) + (func (export "i16x8.splat") (param $0 i32) (result v128) (i16x8.splat (local.get $0))) + (func (export "i16x8.extract_lane_s_first") (param $0 v128) (result i32) (i16x8.extract_lane_s 0 (local.get $0))) + (func (export "i16x8.extract_lane_s_last") (param $0 v128) (result i32) (i16x8.extract_lane_s 7 (local.get $0))) + (func (export "i16x8.extract_lane_u_first") (param $0 v128) (result i32) (i16x8.extract_lane_u 0 (local.get $0))) + (func (export "i16x8.extract_lane_u_last") (param $0 v128) (result i32) (i16x8.extract_lane_u 7 (local.get $0))) + (func (export "i16x8.replace_lane_first") (param $0 v128) (param $1 i32) (result v128) (i16x8.replace_lane 0 (local.get $0) (local.get $1))) + (func (export "i16x8.replace_lane_last") (param $0 v128) (param $1 i32) (result v128) (i16x8.replace_lane 7 (local.get $0) (local.get $1))) + (func (export "i32x4.splat") (param $0 i32) (result v128) (i32x4.splat (local.get $0))) + (func (export "i32x4.extract_lane_first") (param $0 v128) (result i32) (i32x4.extract_lane 0 (local.get $0))) + (func (export "i32x4.extract_lane_last") (param $0 v128) (result i32) (i32x4.extract_lane 3 (local.get $0))) + (func (export "i32x4.replace_lane_first") (param $0 v128) (param $1 i32) (result v128) (i32x4.replace_lane 0 (local.get $0) (local.get $1))) + (func (export "i32x4.replace_lane_last") (param $0 v128) (param $1 i32) (result v128) (i32x4.replace_lane 3 (local.get $0) (local.get $1))) + (func (export "i64x2.splat") (param $0 i64) (result v128) (i64x2.splat (local.get $0))) + (func (export "i64x2.extract_lane_first") (param $0 v128) (result i64) (i64x2.extract_lane 0 (local.get $0))) + (func (export "i64x2.extract_lane_last") (param $0 v128) (result i64) (i64x2.extract_lane 1 (local.get $0))) + (func (export "i64x2.replace_lane_first") (param $0 v128) (param $1 i64) (result v128) (i64x2.replace_lane 0 (local.get $0) (local.get $1))) + (func (export "i64x2.replace_lane_last") (param $0 v128) (param $1 i64) (result v128) (i64x2.replace_lane 1 (local.get $0) (local.get $1))) + (func (export "f32x4.splat") (param $0 f32) (result v128) (f32x4.splat (local.get $0))) + (func (export "f32x4.extract_lane_first") (param $0 v128) (result f32) (f32x4.extract_lane 0 (local.get $0))) + (func (export "f32x4.extract_lane_last") (param $0 v128) (result f32) (f32x4.extract_lane 3 (local.get $0))) + (func (export "f32x4.replace_lane_first") (param $0 v128) (param $1 f32) (result v128) (f32x4.replace_lane 0 (local.get $0) (local.get $1))) + (func (export "f32x4.replace_lane_last") (param $0 v128) (param $1 f32) (result v128) (f32x4.replace_lane 3 (local.get $0) (local.get $1))) + (func (export "f64x2.splat") (param $0 f64) (result v128) (f64x2.splat (local.get $0))) + (func (export "f64x2.extract_lane_first") (param $0 v128) (result f64) (f64x2.extract_lane 0 (local.get $0))) + (func (export "f64x2.extract_lane_last") (param $0 v128) (result f64) (f64x2.extract_lane 1 (local.get $0))) + (func (export "f64x2.replace_lane_first") (param $0 v128) (param $1 f64) (result v128) (f64x2.replace_lane 0 (local.get $0) (local.get $1))) + (func (export "f64x2.replace_lane_last") (param $0 v128) (param $1 f64) (result v128) (f64x2.replace_lane 1 (local.get $0) (local.get $1))) + (func (export "i8x16.eq") (param $0 v128) (param $1 v128) (result v128) (i8x16.eq (local.get $0) (local.get $1))) + (func (export "i8x16.ne") (param $0 v128) (param $1 v128) (result v128) (i8x16.ne (local.get $0) (local.get $1))) + (func (export "i8x16.lt_s") (param $0 v128) (param $1 v128) (result v128) (i8x16.lt_s (local.get $0) (local.get $1))) + (func (export "i8x16.lt_u") (param $0 v128) (param $1 v128) (result v128) (i8x16.lt_u (local.get $0) (local.get $1))) + (func (export "i8x16.gt_s") (param $0 v128) (param $1 v128) (result v128) (i8x16.gt_s (local.get $0) (local.get $1))) + (func (export "i8x16.gt_u") (param $0 v128) (param $1 v128) (result v128) (i8x16.gt_u (local.get $0) (local.get $1))) + (func (export "i8x16.le_s") (param $0 v128) (param $1 v128) (result v128) (i8x16.le_s (local.get $0) (local.get $1))) + (func (export "i8x16.le_u") (param $0 v128) (param $1 v128) (result v128) (i8x16.le_u (local.get $0) (local.get $1))) + (func (export "i8x16.ge_s") (param $0 v128) (param $1 v128) (result v128) (i8x16.ge_s (local.get $0) (local.get $1))) + (func (export "i8x16.ge_u") (param $0 v128) (param $1 v128) (result v128) (i8x16.ge_u (local.get $0) (local.get $1))) + (func (export "i16x8.eq") (param $0 v128) (param $1 v128) (result v128) (i16x8.eq (local.get $0) (local.get $1))) + (func (export "i16x8.ne") (param $0 v128) (param $1 v128) (result v128) (i16x8.ne (local.get $0) (local.get $1))) + (func (export "i16x8.lt_s") (param $0 v128) (param $1 v128) (result v128) (i16x8.lt_s (local.get $0) (local.get $1))) + (func (export "i16x8.lt_u") (param $0 v128) (param $1 v128) (result v128) (i16x8.lt_u (local.get $0) (local.get $1))) + (func (export "i16x8.gt_s") (param $0 v128) (param $1 v128) (result v128) (i16x8.gt_s (local.get $0) (local.get $1))) + (func (export "i16x8.gt_u") (param $0 v128) (param $1 v128) (result v128) (i16x8.gt_u (local.get $0) (local.get $1))) + (func (export "i16x8.le_s") (param $0 v128) (param $1 v128) (result v128) (i16x8.le_s (local.get $0) (local.get $1))) + (func (export "i16x8.le_u") (param $0 v128) (param $1 v128) (result v128) (i16x8.le_u (local.get $0) (local.get $1))) + (func (export "i16x8.ge_s") (param $0 v128) (param $1 v128) (result v128) (i16x8.ge_s (local.get $0) (local.get $1))) + (func (export "i16x8.ge_u") (param $0 v128) (param $1 v128) (result v128) (i16x8.ge_u (local.get $0) (local.get $1))) + (func (export "i32x4.eq") (param $0 v128) (param $1 v128) (result v128) (i32x4.eq (local.get $0) (local.get $1))) + (func (export "i32x4.ne") (param $0 v128) (param $1 v128) (result v128) (i32x4.ne (local.get $0) (local.get $1))) + (func (export "i32x4.lt_s") (param $0 v128) (param $1 v128) (result v128) (i32x4.lt_s (local.get $0) (local.get $1))) + (func (export "i32x4.lt_u") (param $0 v128) (param $1 v128) (result v128) (i32x4.lt_u (local.get $0) (local.get $1))) + (func (export "i32x4.gt_s") (param $0 v128) (param $1 v128) (result v128) (i32x4.gt_s (local.get $0) (local.get $1))) + (func (export "i32x4.gt_u") (param $0 v128) (param $1 v128) (result v128) (i32x4.gt_u (local.get $0) (local.get $1))) + (func (export "i32x4.le_s") (param $0 v128) (param $1 v128) (result v128) (i32x4.le_s (local.get $0) (local.get $1))) + (func (export "i32x4.le_u") (param $0 v128) (param $1 v128) (result v128) (i32x4.le_u (local.get $0) (local.get $1))) + (func (export "i32x4.ge_s") (param $0 v128) (param $1 v128) (result v128) (i32x4.ge_s (local.get $0) (local.get $1))) + (func (export "i32x4.ge_u") (param $0 v128) (param $1 v128) (result v128) (i32x4.ge_u (local.get $0) (local.get $1))) + (func (export "f32x4.eq") (param $0 v128) (param $1 v128) (result v128) (f32x4.eq (local.get $0) (local.get $1))) + (func (export "f32x4.ne") (param $0 v128) (param $1 v128) (result v128) (f32x4.ne (local.get $0) (local.get $1))) + (func (export "f32x4.lt") (param $0 v128) (param $1 v128) (result v128) (f32x4.lt (local.get $0) (local.get $1))) + (func (export "f32x4.gt") (param $0 v128) (param $1 v128) (result v128) (f32x4.gt (local.get $0) (local.get $1))) + (func (export "f32x4.le") (param $0 v128) (param $1 v128) (result v128) (f32x4.le (local.get $0) (local.get $1))) + (func (export "f32x4.ge") (param $0 v128) (param $1 v128) (result v128) (f32x4.ge (local.get $0) (local.get $1))) + (func (export "f64x2.eq") (param $0 v128) (param $1 v128) (result v128) (f64x2.eq (local.get $0) (local.get $1))) + (func (export "f64x2.ne") (param $0 v128) (param $1 v128) (result v128) (f64x2.ne (local.get $0) (local.get $1))) + (func (export "f64x2.lt") (param $0 v128) (param $1 v128) (result v128) (f64x2.lt (local.get $0) (local.get $1))) + (func (export "f64x2.gt") (param $0 v128) (param $1 v128) (result v128) (f64x2.gt (local.get $0) (local.get $1))) + (func (export "f64x2.le") (param $0 v128) (param $1 v128) (result v128) (f64x2.le (local.get $0) (local.get $1))) + (func (export "f64x2.ge") (param $0 v128) (param $1 v128) (result v128) (f64x2.ge (local.get $0) (local.get $1))) + (func (export "v128.not") (param $0 v128) (result v128) (v128.not (local.get $0))) + (func (export "v128.and") (param $0 v128) (param $1 v128) (result v128) (v128.and (local.get $0) (local.get $1))) + (func (export "v128.or") (param $0 v128) (param $1 v128) (result v128) (v128.or (local.get $0) (local.get $1))) + (func (export "v128.xor") (param $0 v128) (param $1 v128) (result v128) (v128.xor (local.get $0) (local.get $1))) + (func (export "v128.bitselect") (param $0 v128) (param $1 v128) (param $2 v128) (result v128) + (v128.bitselect (local.get $0) (local.get $1) (local.get $2)) + ) + (func (export "i8x16.neg") (param $0 v128) (result v128) (i8x16.neg (local.get $0))) + (func (export "i8x16.any_true") (param $0 v128) (result i32) (i8x16.any_true (local.get $0))) + (func (export "i8x16.all_true") (param $0 v128) (result i32) (i8x16.all_true (local.get $0))) + (func (export "i8x16.shl") (param $0 v128) (param $1 i32) (result v128) (i8x16.shl (local.get $0) (local.get $1))) + (func (export "i8x16.shr_s") (param $0 v128) (param $1 i32) (result v128) (i8x16.shr_s (local.get $0) (local.get $1))) + (func (export "i8x16.shr_u") (param $0 v128) (param $1 i32) (result v128) (i8x16.shr_u (local.get $0) (local.get $1))) + (func (export "i8x16.add") (param $0 v128) (param $1 v128) (result v128) (i8x16.add (local.get $0) (local.get $1))) + (func (export "i8x16.add_saturate_s") (param $0 v128) (param $1 v128) (result v128) (i8x16.add_saturate_s (local.get $0) (local.get $1))) + (func (export "i8x16.add_saturate_u") (param $0 v128) (param $1 v128) (result v128) (i8x16.add_saturate_u (local.get $0) (local.get $1))) + (func (export "i8x16.sub") (param $0 v128) (param $1 v128) (result v128) (i8x16.sub (local.get $0) (local.get $1))) + (func (export "i8x16.sub_saturate_s") (param $0 v128) (param $1 v128) (result v128) (i8x16.sub_saturate_s (local.get $0) (local.get $1))) + (func (export "i8x16.sub_saturate_u") (param $0 v128) (param $1 v128) (result v128) (i8x16.sub_saturate_u (local.get $0) (local.get $1))) + (func (export "i8x16.mul") (param $0 v128) (param $1 v128) (result v128) (i8x16.mul (local.get $0) (local.get $1))) + (func (export "i16x8.neg") (param $0 v128) (result v128) (i16x8.neg (local.get $0))) + (func (export "i16x8.any_true") (param $0 v128) (result i32) (i16x8.any_true (local.get $0))) + (func (export "i16x8.all_true") (param $0 v128) (result i32) (i16x8.all_true (local.get $0))) + (func (export "i16x8.shl") (param $0 v128) (param $1 i32) (result v128) (i16x8.shl (local.get $0) (local.get $1))) + (func (export "i16x8.shr_s") (param $0 v128) (param $1 i32) (result v128) (i16x8.shr_s (local.get $0) (local.get $1))) + (func (export "i16x8.shr_u") (param $0 v128) (param $1 i32) (result v128) (i16x8.shr_u (local.get $0) (local.get $1))) + (func (export "i16x8.add") (param $0 v128) (param $1 v128) (result v128) (i16x8.add (local.get $0) (local.get $1))) + (func (export "i16x8.add_saturate_s") (param $0 v128) (param $1 v128) (result v128) (i16x8.add_saturate_s (local.get $0) (local.get $1))) + (func (export "i16x8.add_saturate_u") (param $0 v128) (param $1 v128) (result v128) (i16x8.add_saturate_u (local.get $0) (local.get $1))) + (func (export "i16x8.sub") (param $0 v128) (param $1 v128) (result v128) (i16x8.sub (local.get $0) (local.get $1))) + (func (export "i16x8.sub_saturate_s") (param $0 v128) (param $1 v128) (result v128) (i16x8.sub_saturate_s (local.get $0) (local.get $1))) + (func (export "i16x8.sub_saturate_u") (param $0 v128) (param $1 v128) (result v128) (i16x8.sub_saturate_u (local.get $0) (local.get $1))) + (func (export "i16x8.mul") (param $0 v128) (param $1 v128) (result v128) (i16x8.mul (local.get $0) (local.get $1))) + (func (export "i32x4.neg") (param $0 v128) (result v128) (i32x4.neg (local.get $0))) + (func (export "i32x4.any_true") (param $0 v128) (result i32) (i32x4.any_true (local.get $0))) + (func (export "i32x4.all_true") (param $0 v128) (result i32) (i32x4.all_true (local.get $0))) + (func (export "i32x4.shl") (param $0 v128) (param $1 i32) (result v128) (i32x4.shl (local.get $0) (local.get $1))) + (func (export "i32x4.shr_s") (param $0 v128) (param $1 i32) (result v128) (i32x4.shr_s (local.get $0) (local.get $1))) + (func (export "i32x4.shr_u") (param $0 v128) (param $1 i32) (result v128) (i32x4.shr_u (local.get $0) (local.get $1))) + (func (export "i32x4.add") (param $0 v128) (param $1 v128) (result v128) (i32x4.add (local.get $0) (local.get $1))) + (func (export "i32x4.sub") (param $0 v128) (param $1 v128) (result v128) (i32x4.sub (local.get $0) (local.get $1))) + (func (export "i32x4.mul") (param $0 v128) (param $1 v128) (result v128) (i32x4.mul (local.get $0) (local.get $1))) + (func (export "i64x2.neg") (param $0 v128) (result v128) (i64x2.neg (local.get $0))) + (func (export "i64x2.any_true") (param $0 v128) (result i32) (i64x2.any_true (local.get $0))) + (func (export "i64x2.all_true") (param $0 v128) (result i32) (i64x2.all_true (local.get $0))) + (func (export "i64x2.shl") (param $0 v128) (param $1 i32) (result v128) (i64x2.shl (local.get $0) (local.get $1))) + (func (export "i64x2.shr_s") (param $0 v128) (param $1 i32) (result v128) (i64x2.shr_s (local.get $0) (local.get $1))) + (func (export "i64x2.shr_u") (param $0 v128) (param $1 i32) (result v128) (i64x2.shr_u (local.get $0) (local.get $1))) + (func (export "i64x2.add") (param $0 v128) (param $1 v128) (result v128) (i64x2.add (local.get $0) (local.get $1))) + (func (export "i64x2.sub") (param $0 v128) (param $1 v128) (result v128) (i64x2.sub (local.get $0) (local.get $1))) + (func (export "f32x4.abs") (param $0 v128) (result v128) (f32x4.abs (local.get $0))) + (func (export "f32x4.neg") (param $0 v128) (result v128) (f32x4.neg (local.get $0))) + (func (export "f32x4.sqrt") (param $0 v128) (result v128) (f32x4.sqrt (local.get $0))) + (func (export "f32x4.add") (param $0 v128) (param $1 v128) (result v128) (f32x4.add (local.get $0) (local.get $1))) + (func (export "f32x4.sub") (param $0 v128) (param $1 v128) (result v128) (f32x4.sub (local.get $0) (local.get $1))) + (func (export "f32x4.mul") (param $0 v128) (param $1 v128) (result v128) (f32x4.mul (local.get $0) (local.get $1))) + (func (export "f32x4.div") (param $0 v128) (param $1 v128) (result v128) (f32x4.div (local.get $0) (local.get $1))) + (func (export "f32x4.min") (param $0 v128) (param $1 v128) (result v128) (f32x4.min (local.get $0) (local.get $1))) + (func (export "f32x4.max") (param $0 v128) (param $1 v128) (result v128) (f32x4.max (local.get $0) (local.get $1))) + (func (export "f64x2.abs") (param $0 v128) (result v128) (f64x2.abs (local.get $0))) + (func (export "f64x2.neg") (param $0 v128) (result v128) (f64x2.neg (local.get $0))) + (func (export "f64x2.sqrt") (param $0 v128) (result v128) (f64x2.sqrt (local.get $0))) + (func (export "f64x2.add") (param $0 v128) (param $1 v128) (result v128) (f64x2.add (local.get $0) (local.get $1))) + (func (export "f64x2.sub") (param $0 v128) (param $1 v128) (result v128) (f64x2.sub (local.get $0) (local.get $1))) + (func (export "f64x2.mul") (param $0 v128) (param $1 v128) (result v128) (f64x2.mul (local.get $0) (local.get $1))) + (func (export "f64x2.div") (param $0 v128) (param $1 v128) (result v128) (f64x2.div (local.get $0) (local.get $1))) + (func (export "f64x2.min") (param $0 v128) (param $1 v128) (result v128) (f64x2.min (local.get $0) (local.get $1))) + (func (export "f64x2.max") (param $0 v128) (param $1 v128) (result v128) (f64x2.max (local.get $0) (local.get $1))) + (func (export "i32x4.trunc_sat_f32x4_s") (param $0 v128) (result v128) (i32x4.trunc_sat_f32x4_s (local.get $0))) + (func (export "i32x4.trunc_sat_f32x4_u") (param $0 v128) (result v128) (i32x4.trunc_sat_f32x4_u (local.get $0))) + (func (export "i64x2.trunc_sat_f64x2_s") (param $0 v128) (result v128) (i64x2.trunc_sat_f64x2_s (local.get $0))) + (func (export "i64x2.trunc_sat_f64x2_u") (param $0 v128) (result v128) (i64x2.trunc_sat_f64x2_u (local.get $0))) + (func (export "f32x4.convert_i32x4_s") (param $0 v128) (result v128) (f32x4.convert_i32x4_s (local.get $0))) + (func (export "f32x4.convert_i32x4_u") (param $0 v128) (result v128) (f32x4.convert_i32x4_u (local.get $0))) + (func (export "f64x2.convert_i64x2_s") (param $0 v128) (result v128) (f64x2.convert_i64x2_s (local.get $0))) + (func (export "f64x2.convert_i64x2_u") (param $0 v128) (result v128) (f64x2.convert_i64x2_u (local.get $0))) +) + +;; Basic v128 manipulation +(assert_return (invoke "v128.load" (i32.const 128)) (v128.const i8x16 87 65 83 77 83 73 77 68 71 79 69 83 70 65 83 84)) +(assert_return (invoke "v128.store" (i32.const 16) (v128.const i32x4 1 2 3 4)) (v128.const i32x4 1 2 3 4)) +(assert_return (invoke "v128.const.i8x16") (v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d)) +(assert_return (invoke "v128.const.i16x8") (v128.const i8x16 01 00 02 00 03 00 04 00 05 00 06 00 07 00 08 00)) +(assert_return (invoke "v128.const.i32x4") (v128.const i8x16 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00)) +(assert_return (invoke "v128.const.i64x2") (v128.const i8x16 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00)) +(assert_return (invoke "v128.const.f32x4") (v128.const f32x4 1.0 2.0 3.0 4.0)) +(assert_return (invoke "v128.const.f64x2") (v128.const f64x2 1.0 2.0)) +(assert_return + (invoke "v128.shuffle_interleave_bytes" + (v128.const i8x16 1 0 3 0 5 0 7 0 9 0 11 0 13 0 15 0) + (v128.const i8x16 0 2 0 4 0 6 0 8 0 10 0 12 0 14 0 16) + ) + (v128.const i8x16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16) +) +(assert_return (invoke "v128.shuffle_reverse_i32s" (v128.const i32x4 1 2 3 4)) (v128.const i32x4 4 3 2 1)) + +;; i8x16 lane accesses +(assert_return (invoke "i8x16.splat" (i32.const 5)) (v128.const i8x16 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5)) +(assert_return (invoke "i8x16.splat" (i32.const 257)) (v128.const i8x16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)) +(assert_return (invoke "i8x16.extract_lane_s_first" (v128.const i8x16 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)) (i32.const -1)) +(assert_return (invoke "i8x16.extract_lane_s_last" (v128.const i8x16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255)) (i32.const -1)) +(assert_return (invoke "i8x16.extract_lane_u_first" (v128.const i8x16 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)) (i32.const 255)) +(assert_return (invoke "i8x16.extract_lane_u_last" (v128.const i8x16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255)) (i32.const 255)) +(assert_return (invoke "i8x16.replace_lane_first" (v128.const i64x2 0 0) (i32.const 7)) (v128.const i8x16 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)) +(assert_return (invoke "i8x16.replace_lane_last" (v128.const i64x2 0 0) (i32.const 7)) (v128.const i8x16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7)) + +;; i16x8 lane accesses +(assert_return (invoke "i16x8.splat" (i32.const 5)) (v128.const i16x8 5 5 5 5 5 5 5 5)) +(assert_return (invoke "i16x8.splat" (i32.const 65537)) (v128.const i16x8 1 1 1 1 1 1 1 1)) +(assert_return (invoke "i16x8.extract_lane_s_first" (v128.const i16x8 65535 0 0 0 0 0 0 0)) (i32.const -1)) +(assert_return (invoke "i16x8.extract_lane_s_last" (v128.const i16x8 0 0 0 0 0 0 0 65535)) (i32.const -1)) +(assert_return (invoke "i16x8.extract_lane_u_first" (v128.const i16x8 65535 0 0 0 0 0 0 0)) (i32.const 65535)) +(assert_return (invoke "i16x8.extract_lane_u_last" (v128.const i16x8 0 0 0 0 0 0 0 65535)) (i32.const 65535)) +(assert_return (invoke "i16x8.replace_lane_first" (v128.const i64x2 0 0) (i32.const 7)) (v128.const i16x8 7 0 0 0 0 0 0 0)) +(assert_return (invoke "i16x8.replace_lane_last" (v128.const i64x2 0 0) (i32.const 7)) (v128.const i16x8 0 0 0 0 0 0 0 7)) + +;; i32x4 lane accesses +(assert_return (invoke "i32x4.splat" (i32.const -5)) (v128.const i32x4 -5 -5 -5 -5)) +(assert_return (invoke "i32x4.extract_lane_first" (v128.const i32x4 -5 0 0 0)) (i32.const -5)) +(assert_return (invoke "i32x4.extract_lane_last" (v128.const i32x4 0 0 0 -5)) (i32.const -5)) +(assert_return (invoke "i32x4.replace_lane_first" (v128.const i64x2 0 0) (i32.const 53)) (v128.const i32x4 53 0 0 0)) +(assert_return (invoke "i32x4.replace_lane_last" (v128.const i64x2 0 0) (i32.const 53)) (v128.const i32x4 0 0 0 53)) + +;; i64x2 lane accesses +(assert_return (invoke "i64x2.splat" (i64.const -5)) (v128.const i64x2 -5 -5)) +(assert_return (invoke "i64x2.extract_lane_first" (v128.const i64x2 -5 0)) (i64.const -5)) +(assert_return (invoke "i64x2.extract_lane_last" (v128.const i64x2 0 -5)) (i64.const -5)) +(assert_return (invoke "i64x2.replace_lane_first" (v128.const i64x2 0 0) (i64.const 53)) (v128.const i64x2 53 0)) +(assert_return (invoke "i64x2.replace_lane_last" (v128.const i64x2 0 0) (i64.const 53)) (v128.const i64x2 0 53)) + +;; f32x4 lane accesses +(assert_return (invoke "f32x4.splat" (f32.const -5)) (v128.const f32x4 -5.0 -5.0 -5.0 -5.0)) +(assert_return (invoke "f32x4.extract_lane_first" (v128.const f32x4 -5.0 0.0 0.0 0.0)) (f32.const -5.0)) +(assert_return (invoke "f32x4.extract_lane_last" (v128.const f32x4 0.0 0.0 0.0 -5.0)) (f32.const -5.0)) +(assert_return (invoke "f32x4.replace_lane_first" (v128.const i64x2 0 0) (f32.const 53)) (v128.const f32x4 53.0 0.0 0.0 0.0)) +(assert_return (invoke "f32x4.replace_lane_last" (v128.const i64x2 0 0) (f32.const 53)) (v128.const f32x4 0.0 0.0 0.0 53.0)) + +;; f64x2 lane accesses +(assert_return (invoke "f64x2.splat" (f64.const -5.0)) (v128.const f64x2 -5.0 -5.0)) +(assert_return (invoke "f64x2.extract_lane_first" (v128.const f64x2 -5.0 0.0)) (f64.const -5.0)) +(assert_return (invoke "f64x2.extract_lane_last" (v128.const f64x2 0.0 -5.0)) (f64.const -5.0)) +(assert_return (invoke "f64x2.replace_lane_first" (v128.const f64x2 0.0 0.0) (f64.const 53.0)) (v128.const f64x2 53.0 0.0)) +(assert_return (invoke "f64x2.replace_lane_last" (v128.const f64x2 0.0 0.0) (f64.const 53.0)) (v128.const f64x2 0.0 53.0)) + +;; i8x16 comparisons +(assert_return + (invoke "i8x16.eq" + (v128.const i8x16 0 127 13 128 1 13 129 42 0 127 255 42 1 13 129 42) + (v128.const i8x16 0 255 13 42 129 127 0 128 0 255 13 42 129 127 0 128) + ) + (v128.const i8x16 -1 0 -1 0 0 0 0 0 -1 0 0 -1 0 0 0 0) +) +(assert_return + (invoke "i8x16.ne" + (v128.const i8x16 0 127 13 128 1 13 129 42 0 127 255 42 1 13 129 42) + (v128.const i8x16 0 255 13 42 129 127 0 128 0 255 13 42 129 127 0 128) + ) + (v128.const i8x16 0 -1 0 -1 -1 -1 -1 -1 0 -1 -1 0 -1 -1 -1 -1) +) +(assert_return + (invoke "i8x16.lt_s" + (v128.const i8x16 0 127 13 128 1 13 129 42 0 127 255 42 1 13 129 42) + (v128.const i8x16 0 255 13 42 129 127 0 128 0 255 13 42 129 127 0 128) + ) + (v128.const i8x16 0 0 0 -1 0 -1 -1 0 0 0 -1 0 0 -1 -1 0) +) +(assert_return + (invoke "i8x16.lt_u" + (v128.const i8x16 0 127 13 128 1 13 129 42 0 127 255 42 1 13 129 42) + (v128.const i8x16 0 255 13 42 129 127 0 128 0 255 13 42 129 127 0 128) + ) + (v128.const i8x16 0 -1 0 0 -1 -1 0 -1 0 -1 0 0 -1 -1 0 -1) +) +(assert_return + (invoke "i8x16.gt_s" + (v128.const i8x16 0 127 13 128 1 13 129 42 0 127 255 42 1 13 129 42) + (v128.const i8x16 0 255 13 42 129 127 0 128 0 255 13 42 129 127 0 128) + ) + (v128.const i8x16 0 -1 0 0 -1 0 0 -1 0 -1 0 0 -1 0 0 -1) +) +(assert_return + (invoke "i8x16.gt_u" + (v128.const i8x16 0 127 13 128 1 13 129 42 0 127 255 42 1 13 129 42) + (v128.const i8x16 0 255 13 42 129 127 0 128 0 255 13 42 129 127 0 128) + ) + (v128.const i8x16 0 0 0 -1 0 0 -1 0 0 0 -1 0 0 0 -1 0) +) +(assert_return + (invoke "i8x16.le_s" + (v128.const i8x16 0 127 13 128 1 13 129 42 0 127 255 42 1 13 129 42) + (v128.const i8x16 0 255 13 42 129 127 0 128 0 255 13 42 129 127 0 128) + ) + (v128.const i8x16 -1 0 -1 -1 0 -1 -1 0 -1 0 -1 -1 0 -1 -1 0) +) +(assert_return + (invoke "i8x16.le_u" + (v128.const i8x16 0 127 13 128 1 13 129 42 0 127 255 42 1 13 129 42) + (v128.const i8x16 0 255 13 42 129 127 0 128 0 255 13 42 129 127 0 128) + ) + (v128.const i8x16 -1 -1 -1 0 -1 -1 0 -1 -1 -1 0 -1 -1 -1 0 -1) +) +(assert_return + (invoke "i8x16.ge_s" + (v128.const i8x16 0 127 13 128 1 13 129 42 0 127 255 42 1 13 129 42) + (v128.const i8x16 0 255 13 42 129 127 0 128 0 255 13 42 129 127 0 128) + ) + (v128.const i8x16 -1 -1 -1 0 -1 0 0 -1 -1 -1 0 -1 -1 0 0 -1) +) +(assert_return + (invoke "i8x16.ge_u" + (v128.const i8x16 0 127 13 128 1 13 129 42 0 127 255 42 1 13 129 42) + (v128.const i8x16 0 255 13 42 129 127 0 128 0 255 13 42 129 127 0 128) + ) + (v128.const i8x16 -1 0 -1 -1 0 0 -1 0 -1 0 -1 -1 0 0 -1 0) +) + +;; i16x8 comparisons +(assert_return (invoke "i16x8.eq" + (v128.const i16x8 0 32767 13 32768 1 32769 42 40000) + (v128.const i16x8 0 13 1 32767 32769 42 40000 32767) + ) + (v128.const i16x8 -1 0 0 0 0 0 0 0) +) +(assert_return + (invoke "i16x8.ne" + (v128.const i16x8 0 32767 13 32768 1 32769 42 40000) + (v128.const i16x8 0 13 1 32767 32769 42 40000 32767) + ) + (v128.const i16x8 0 -1 -1 -1 -1 -1 -1 -1) +) +(assert_return + (invoke "i16x8.lt_s" + (v128.const i16x8 0 32767 13 32768 1 32769 42 40000) + (v128.const i16x8 0 13 1 32767 32769 42 40000 32767) + ) + (v128.const i16x8 0 0 0 -1 0 -1 0 -1) +) +(assert_return + (invoke "i16x8.lt_u" + (v128.const i16x8 0 32767 13 32768 1 32769 42 40000) + (v128.const i16x8 0 13 1 32767 32769 42 40000 32767) + ) + (v128.const i16x8 0 0 0 0 -1 0 -1 0) +) +(assert_return + (invoke "i16x8.gt_s" + (v128.const i16x8 0 32767 13 32768 1 32769 42 40000) + (v128.const i16x8 0 13 1 32767 32769 42 40000 32767) + ) + (v128.const i16x8 0 -1 -1 0 -1 0 -1 0) +) +(assert_return + (invoke "i16x8.gt_u" + (v128.const i16x8 0 32767 13 32768 1 32769 42 40000) + (v128.const i16x8 0 13 1 32767 32769 42 40000 32767) + ) + (v128.const i16x8 0 -1 -1 -1 0 -1 0 -1) +) +(assert_return + (invoke "i16x8.le_s" + (v128.const i16x8 0 32767 13 32768 1 32769 42 40000) + (v128.const i16x8 0 13 1 32767 32769 42 40000 32767) + ) + (v128.const i16x8 -1 0 0 -1 0 -1 0 -1) +) +(assert_return + (invoke "i16x8.le_u" + (v128.const i16x8 0 32767 13 32768 1 32769 42 40000) + (v128.const i16x8 0 13 1 32767 32769 42 40000 32767) + ) + (v128.const i16x8 -1 0 0 0 -1 0 -1 0) +) +(assert_return + (invoke "i16x8.ge_s" + (v128.const i16x8 0 32767 13 32768 1 32769 42 40000) + (v128.const i16x8 0 13 1 32767 32769 42 40000 32767) + ) + (v128.const i16x8 -1 -1 -1 0 -1 0 -1 0) +) +(assert_return + (invoke "i16x8.ge_u" + (v128.const i16x8 0 32767 13 32768 1 32769 42 40000) + (v128.const i16x8 0 13 1 32767 32769 42 40000 32767) + ) + (v128.const i16x8 -1 -1 -1 -1 0 -1 0 -1) +) + +;; i32x4 comparisons +(assert_return (invoke "i32x4.eq" (v128.const i32x4 0 -1 53 -7) (v128.const i32x4 0 53 -7 -1)) (v128.const i32x4 -1 0 0 0)) +(assert_return (invoke "i32x4.ne" (v128.const i32x4 0 -1 53 -7) (v128.const i32x4 0 53 -7 -1)) (v128.const i32x4 0 -1 -1 -1)) +(assert_return (invoke "i32x4.lt_s" (v128.const i32x4 0 -1 53 -7) (v128.const i32x4 0 53 -7 -1)) (v128.const i32x4 0 -1 0 -1)) +(assert_return (invoke "i32x4.lt_u" (v128.const i32x4 0 -1 53 -7) (v128.const i32x4 0 53 -7 -1)) (v128.const i32x4 0 0 -1 -1)) +(assert_return (invoke "i32x4.gt_s" (v128.const i32x4 0 -1 53 -7) (v128.const i32x4 0 53 -7 -1)) (v128.const i32x4 0 0 -1 0)) +(assert_return (invoke "i32x4.gt_u" (v128.const i32x4 0 -1 53 -7) (v128.const i32x4 0 53 -7 -1)) (v128.const i32x4 0 -1 0 0)) +(assert_return (invoke "i32x4.le_s" (v128.const i32x4 0 -1 53 -7) (v128.const i32x4 0 53 -7 -1)) (v128.const i32x4 -1 -1 0 -1)) +(assert_return (invoke "i32x4.le_u" (v128.const i32x4 0 -1 53 -7) (v128.const i32x4 0 53 -7 -1)) (v128.const i32x4 -1 0 -1 -1)) +(assert_return (invoke "i32x4.ge_s" (v128.const i32x4 0 -1 53 -7) (v128.const i32x4 0 53 -7 -1)) (v128.const i32x4 -1 0 -1 0)) +(assert_return (invoke "i32x4.ge_u" (v128.const i32x4 0 -1 53 -7) (v128.const i32x4 0 53 -7 -1)) (v128.const i32x4 -1 -1 0 0)) + +;; f32x4 comparisons +(assert_return (invoke "f32x4.eq" (v128.const f32x4 0.0 -1.0 1.0 0.0) (v128.const f32x4 0.0 0.0 -1.0 1.0)) (v128.const i32x4 -1 0 0 0)) +(assert_return (invoke "f32x4.ne" (v128.const f32x4 0.0 -1.0 1.0 0.0) (v128.const f32x4 0.0 0.0 -1.0 1.0)) (v128.const i32x4 0 -1 -1 -1)) +(assert_return (invoke "f32x4.lt" (v128.const f32x4 0.0 -1.0 1.0 0.0) (v128.const f32x4 0.0 0.0 -1.0 1.0)) (v128.const i32x4 0 -1 0 -1)) +(assert_return (invoke "f32x4.gt" (v128.const f32x4 0.0 -1.0 1.0 0.0) (v128.const f32x4 0.0 0.0 -1.0 1.0)) (v128.const i32x4 0 0 -1 0)) +(assert_return (invoke "f32x4.le" (v128.const f32x4 0.0 -1.0 1.0 0.0) (v128.const f32x4 0.0 0.0 -1.0 1.0)) (v128.const i32x4 -1 -1 0 -1)) +(assert_return (invoke "f32x4.ge" (v128.const f32x4 0.0 -1.0 1.0 0.0) (v128.const f32x4 0.0 0.0 -1.0 1.0)) (v128.const i32x4 -1 0 -1 0)) +(assert_return (invoke "f32x4.eq" (v128.const f32x4 nan 0.0 nan inf) (v128.const f32x4 0.0 nan nan inf)) (v128.const i32x4 0 0 0 -1)) +(assert_return (invoke "f32x4.ne" (v128.const f32x4 nan 0.0 nan inf) (v128.const f32x4 0.0 nan nan inf)) (v128.const i32x4 -1 -1 -1 0)) +(assert_return (invoke "f32x4.lt" (v128.const f32x4 nan 0.0 nan inf) (v128.const f32x4 0.0 nan nan inf)) (v128.const i32x4 0 0 0 0)) +(assert_return (invoke "f32x4.gt" (v128.const f32x4 nan 0.0 nan inf) (v128.const f32x4 0.0 nan nan inf)) (v128.const i32x4 0 0 0 0)) +(assert_return (invoke "f32x4.le" (v128.const f32x4 nan 0.0 nan inf) (v128.const f32x4 0.0 nan nan inf)) (v128.const i32x4 0 0 0 -1)) +(assert_return (invoke "f32x4.ge" (v128.const f32x4 nan 0.0 nan inf) (v128.const f32x4 0.0 nan nan inf)) (v128.const i32x4 0 0 0 -1)) +(assert_return (invoke "f32x4.eq" (v128.const f32x4 -inf 0.0 nan -inf) (v128.const f32x4 0.0 inf inf nan)) (v128.const i32x4 0 0 0 0)) +(assert_return (invoke "f32x4.ne" (v128.const f32x4 -inf 0.0 nan -inf) (v128.const f32x4 0.0 inf inf nan)) (v128.const i32x4 -1 -1 -1 -1)) +(assert_return (invoke "f32x4.lt" (v128.const f32x4 -inf 0.0 nan -inf) (v128.const f32x4 0.0 inf inf nan)) (v128.const i32x4 -1 -1 0 0)) +(assert_return (invoke "f32x4.gt" (v128.const f32x4 -inf 0.0 nan -inf) (v128.const f32x4 0.0 inf inf nan)) (v128.const i32x4 0 0 0 0)) +(assert_return (invoke "f32x4.le" (v128.const f32x4 -inf 0.0 nan -inf) (v128.const f32x4 0.0 inf inf nan)) (v128.const i32x4 -1 -1 0 0)) +(assert_return (invoke "f32x4.ge" (v128.const f32x4 -inf 0.0 nan -inf) (v128.const f32x4 0.0 inf inf nan)) (v128.const i32x4 0 0 0 0)) + +;; f64x2 comparisons +(assert_return (invoke "f64x2.eq" (v128.const f64x2 0.0 1.0) (v128.const f64x2 0.0 0.0)) (v128.const i64x2 -1 0)) +(assert_return (invoke "f64x2.ne" (v128.const f64x2 0.0 1.0) (v128.const f64x2 0.0 0.0)) (v128.const i64x2 0 -1)) +(assert_return (invoke "f64x2.lt" (v128.const f64x2 0.0 1.0) (v128.const f64x2 0.0 0.0)) (v128.const i64x2 0 0)) +(assert_return (invoke "f64x2.gt" (v128.const f64x2 0.0 1.0) (v128.const f64x2 0.0 0.0)) (v128.const i64x2 0 -1)) +(assert_return (invoke "f64x2.le" (v128.const f64x2 0.0 1.0) (v128.const f64x2 0.0 0.0)) (v128.const i64x2 -1 0)) +(assert_return (invoke "f64x2.ge" (v128.const f64x2 0.0 1.0) (v128.const f64x2 0.0 0.0)) (v128.const i64x2 -1 -1)) +(assert_return (invoke "f64x2.eq" (v128.const f64x2 nan 0.0) (v128.const f64x2 inf inf)) (v128.const i64x2 0 0)) +(assert_return (invoke "f64x2.ne" (v128.const f64x2 nan 0.0) (v128.const f64x2 inf inf)) (v128.const i64x2 -1 -1)) +(assert_return (invoke "f64x2.lt" (v128.const f64x2 nan 0.0) (v128.const f64x2 inf inf)) (v128.const i64x2 0 -1)) +(assert_return (invoke "f64x2.gt" (v128.const f64x2 nan 0.0) (v128.const f64x2 inf inf)) (v128.const i64x2 0 0)) +(assert_return (invoke "f64x2.le" (v128.const f64x2 nan 0.0) (v128.const f64x2 inf inf)) (v128.const i64x2 0 -1)) +(assert_return (invoke "f64x2.ge" (v128.const f64x2 nan 0.0) (v128.const f64x2 inf inf)) (v128.const i64x2 0 0)) + +;; bitwise operations +(assert_return (invoke "v128.not" (v128.const i32x4 0 -1 0 -1)) (v128.const i32x4 -1 0 -1 0)) +(assert_return (invoke "v128.and" (v128.const i32x4 0 0 -1 -1) (v128.const i32x4 0 -1 0 -1)) (v128.const i32x4 0 0 0 -1)) +(assert_return (invoke "v128.or" (v128.const i32x4 0 0 -1 -1) (v128.const i32x4 0 -1 0 -1)) (v128.const i32x4 0 -1 -1 -1)) +(assert_return (invoke "v128.xor" (v128.const i32x4 0 0 -1 -1) (v128.const i32x4 0 -1 0 -1)) (v128.const i32x4 0 -1 -1 0)) +(assert_return (invoke "v128.bitselect" + (v128.const i32x4 0xAAAAAAAA 0xAAAAAAAA 0xAAAAAAAA 0xAAAAAAAA) + (v128.const i32x4 0xBBBBBBBB 0xBBBBBBBB 0xBBBBBBBB 0xBBBBBBBB) + (v128.const i32x4 0xF0F0F0F0 0xFFFFFFFF 0x00000000 0xFF00FF00) + ) + (v128.const i32x4 0xABABABAB 0xAAAAAAAA 0xBBBBBBBB 0xAABBAABB) +) + +;; i8x16 arithmetic +(assert_return (invoke "i8x16.neg" (v128.const i8x16 0 1 42 -3 -56 127 -128 -126 0 -1 -42 3 56 -127 -128 126)) + (v128.const i8x16 0 -1 -42 3 56 -127 -128 126 0 1 42 -3 -56 127 -128 -126) +) +(assert_return (invoke "i8x16.any_true" (v128.const i8x16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)) (i32.const 0)) +(assert_return (invoke "i8x16.any_true" (v128.const i8x16 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0)) (i32.const 1)) +(assert_return (invoke "i8x16.any_true" (v128.const i8x16 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1)) (i32.const 1)) +(assert_return (invoke "i8x16.any_true" (v128.const i8x16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)) (i32.const 1)) +(assert_return (invoke "i8x16.all_true" (v128.const i8x16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)) (i32.const 0)) +(assert_return (invoke "i8x16.all_true" (v128.const i8x16 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0)) (i32.const 0)) +(assert_return (invoke "i8x16.all_true" (v128.const i8x16 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1)) (i32.const 0)) +(assert_return (invoke "i8x16.all_true" (v128.const i8x16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)) (i32.const 1)) +(assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 4 8 16 32 64 -128 3 6 12 24 48 96 -64) (i32.const 1)) + (v128.const i8x16 0 2 4 8 16 32 64 -128 0 6 12 24 48 96 -64 -128) +) +(assert_return (invoke "i8x16.shl" (v128.const i8x16 0 1 2 4 8 16 32 64 -128 3 6 12 24 48 96 -64) (i32.const 8)) + (v128.const i8x16 0 1 2 4 8 16 32 64 -128 3 6 12 24 48 96 -64) +) +(assert_return (invoke "i8x16.shr_u" (v128.const i8x16 0 1 2 4 8 16 32 64 -128 3 6 12 24 48 96 -64) (i32.const 1)) + (v128.const i8x16 0 0 1 2 4 8 16 32 64 1 3 6 12 24 48 96) +) +(assert_return (invoke "i8x16.shr_u" (v128.const i8x16 0 1 2 4 8 16 32 64 -128 3 6 12 24 48 96 -64) (i32.const 8)) + (v128.const i8x16 0 1 2 4 8 16 32 64 -128 3 6 12 24 48 96 -64) +) +(assert_return (invoke "i8x16.shr_s" (v128.const i8x16 0 1 2 4 8 16 32 64 -128 3 6 12 24 48 96 -64) (i32.const 1)) + (v128.const i8x16 0 0 1 2 4 8 16 32 -64 1 3 6 12 24 48 -32) +) +(assert_return (invoke "i8x16.shr_s" (v128.const i8x16 0 1 2 4 8 16 32 64 -128 3 6 12 24 48 96 -64) (i32.const 8)) + (v128.const i8x16 0 1 2 4 8 16 32 64 -128 3 6 12 24 48 96 -64) +) +(assert_return + (invoke "i8x16.add" + (v128.const i8x16 0 42 255 128 127 129 6 29 103 196 231 142 17 250 1 73) + (v128.const i8x16 3 231 1 128 129 6 103 17 42 29 73 42 0 255 127 142) + ) + (v128.const i8x16 3 17 0 0 0 135 109 46 145 225 48 184 17 249 128 215) +) +(assert_return + (invoke "i8x16.add_saturate_s" + (v128.const i8x16 0 42 255 128 127 129 6 29 103 196 231 142 17 250 1 73) + (v128.const i8x16 3 231 1 128 129 6 103 17 42 29 73 42 0 255 127 142) + ) + (v128.const i8x16 3 17 0 128 0 135 109 46 127 225 48 184 17 249 127 215) +) +(assert_return + (invoke "i8x16.add_saturate_u" + (v128.const i8x16 0 42 255 128 127 129 6 29 103 196 231 142 17 250 1 73) + (v128.const i8x16 3 231 1 128 129 6 103 17 42 29 73 42 0 255 127 142) + ) + (v128.const i8x16 3 255 255 255 255 135 109 46 145 225 255 184 17 255 128 215) +) +(assert_return + (invoke "i8x16.sub" + (v128.const i8x16 0 42 255 128 127 129 6 29 103 196 231 142 17 250 1 73) + (v128.const i8x16 3 231 1 128 129 6 103 17 42 29 73 42 0 255 127 142) + ) + (v128.const i8x16 253 67 254 0 254 123 159 12 61 167 158 100 17 251 130 187) +) +(assert_return + (invoke "i8x16.sub_saturate_s" + (v128.const i8x16 0 42 255 128 127 129 6 29 103 196 231 142 17 250 1 73) + (v128.const i8x16 3 231 1 128 129 6 103 17 42 29 73 42 0 255 127 142) + ) + (v128.const i8x16 253 67 254 0 127 128 159 12 61 167 158 128 17 251 130 127) +) +(assert_return + (invoke "i8x16.sub_saturate_u" + (v128.const i8x16 0 42 255 128 127 129 6 29 103 196 231 142 17 250 1 73) + (v128.const i8x16 3 231 1 128 129 6 103 17 42 29 73 42 0 255 127 142) + ) + (v128.const i8x16 0 0 254 0 0 123 0 12 61 167 158 100 17 0 0 0) +) +(assert_return + (invoke "i8x16.mul" + (v128.const i8x16 0 42 255 128 127 129 6 29 103 196 231 142 17 250 1 73) + (v128.const i8x16 3 231 1 128 129 6 103 17 42 29 73 42 0 255 127 142) + ) + (v128.const i8x16 0 230 255 0 255 6 106 237 230 52 223 76 0 6 127 126) +) + +;; i16x8 arithmetic +(assert_return (invoke "i16x8.neg" (v128.const i16x8 0 1 42 -3 -56 32767 -32768 32766)) + (v128.const i16x8 0 -1 -42 3 56 -32767 -32768 -32766) +) +(assert_return (invoke "i16x8.any_true" (v128.const i16x8 0 0 0 0 0 0 0 0)) (i32.const 0)) +(assert_return (invoke "i16x8.any_true" (v128.const i16x8 0 0 1 0 0 0 0 0)) (i32.const 1)) +(assert_return (invoke "i16x8.any_true" (v128.const i16x8 1 1 1 1 1 0 1 1)) (i32.const 1)) +(assert_return (invoke "i16x8.any_true" (v128.const i16x8 1 1 1 1 1 1 1 1)) (i32.const 1)) +(assert_return (invoke "i16x8.all_true" (v128.const i16x8 0 0 0 0 0 0 0 0)) (i32.const 0)) +(assert_return (invoke "i16x8.all_true" (v128.const i16x8 0 0 1 0 0 0 0 0)) (i32.const 0)) +(assert_return (invoke "i16x8.all_true" (v128.const i16x8 1 1 1 1 1 0 1 1)) (i32.const 0)) +(assert_return (invoke "i16x8.all_true" (v128.const i16x8 1 1 1 1 1 1 1 1)) (i32.const 1)) +(assert_return (invoke "i16x8.shl" (v128.const i16x8 0 8 16 128 256 2048 4096 -32768) (i32.const 1)) (v128.const i16x8 0 16 32 256 512 4096 8192 0)) +(assert_return (invoke "i16x8.shl" (v128.const i16x8 0 8 16 128 256 2048 4096 -32768) (i32.const 16)) (v128.const i16x8 0 8 16 128 256 2048 4096 -32768)) +(assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 8 16 128 256 2048 4096 -32768) (i32.const 1)) (v128.const i16x8 0 4 8 64 128 1024 2048 16384)) +(assert_return (invoke "i16x8.shr_u" (v128.const i16x8 0 8 16 128 256 2048 4096 -32768) (i32.const 16)) (v128.const i16x8 0 8 16 128 256 2048 4096 -32768)) +(assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 8 16 128 256 2048 4096 -32768) (i32.const 1)) (v128.const i16x8 0 4 8 64 128 1024 2048 -16384)) +(assert_return (invoke "i16x8.shr_s" (v128.const i16x8 0 8 16 128 256 2048 4096 -32768) (i32.const 16)) (v128.const i16x8 0 8 16 128 256 2048 4096 -32768)) +(assert_return + (invoke "i16x8.add" + (v128.const i16x8 0 65280 32768 32512 33024 59136 64000 32766) + (v128.const i16x8 768 1 32768 33024 1536 18688 65280 2) + ) + (v128.const i16x8 768 65281 0 0 34560 12288 63744 32768) +) +(assert_return + (invoke "i16x8.add_saturate_s" + (v128.const i16x8 0 65280 32768 32512 33024 59136 64000 32766) + (v128.const i16x8 768 1 32768 33024 1536 18688 65280 2) + ) + (v128.const i16x8 768 65281 32768 0 34560 12288 63744 32767) +) +(assert_return + (invoke "i16x8.add_saturate_u" + (v128.const i16x8 0 65280 32768 32512 33024 59136 64000 32766) + (v128.const i16x8 768 1 32768 33024 1536 18688 65280 2) + ) + (v128.const i16x8 768 65281 65535 65535 34560 65535 65535 32768) +) +(assert_return + (invoke "i16x8.sub" + (v128.const i16x8 0 65280 32768 32512 33024 59136 64000 32766) + (v128.const i16x8 768 1 32768 33024 1536 18688 65280 2) + ) + (v128.const i16x8 64768 65279 0 65024 31488 40448 64256 32764) +) +(assert_return + (invoke "i16x8.sub_saturate_s" + (v128.const i16x8 0 65280 32768 32512 33024 59136 64000 32766) + (v128.const i16x8 768 1 32768 33024 1536 18688 65280 2) + ) + (v128.const i16x8 64768 65279 0 32767 32768 40448 64256 32764) +) +(assert_return + (invoke "i16x8.sub_saturate_u" + (v128.const i16x8 0 65280 32768 32512 33024 59136 64000 32766) + (v128.const i16x8 768 1 32768 33024 1536 18688 65280 2) + ) + (v128.const i16x8 0 65279 0 0 31488 40448 0 32764) +) +(assert_return + (invoke "i16x8.mul" + (v128.const i16x8 0 65280 32768 32512 33024 59136 64000 32766) + (v128.const i16x8 768 1 32768 33024 1536 18688 65280 2) + ) + (v128.const i16x8 0 65280 0 0 0 0 0 65532) +) + +;; i32x4 arithmetic +(assert_return (invoke "i32x4.neg" (v128.const i32x4 0 1 0x80000000 0x7fffffff)) (v128.const i32x4 0 -1 0x80000000 0x80000001)) +(assert_return (invoke "i32x4.any_true" (v128.const i32x4 0 0 0 0)) (i32.const 0)) +(assert_return (invoke "i32x4.any_true" (v128.const i32x4 0 0 1 0)) (i32.const 1)) +(assert_return (invoke "i32x4.any_true" (v128.const i32x4 1 0 1 1)) (i32.const 1)) +(assert_return (invoke "i32x4.any_true" (v128.const i32x4 1 1 1 1)) (i32.const 1)) +(assert_return (invoke "i32x4.all_true" (v128.const i32x4 0 0 0 0)) (i32.const 0)) +(assert_return (invoke "i32x4.all_true" (v128.const i32x4 0 0 1 0)) (i32.const 0)) +(assert_return (invoke "i32x4.all_true" (v128.const i32x4 1 0 1 1)) (i32.const 0)) +(assert_return (invoke "i32x4.all_true" (v128.const i32x4 1 1 1 1)) (i32.const 1)) +(assert_return (invoke "i32x4.shl" (v128.const i32x4 1 0x40000000 0x80000000 -1) (i32.const 1)) (v128.const i32x4 2 0x80000000 0 -2)) +(assert_return (invoke "i32x4.shl" (v128.const i32x4 1 0x40000000 0x80000000 -1) (i32.const 32)) (v128.const i32x4 1 0x40000000 0x80000000 -1)) +(assert_return (invoke "i32x4.shr_s" (v128.const i32x4 1 0x40000000 0x80000000 -1) (i32.const 1)) (v128.const i32x4 0 0x20000000 0xc0000000 -1)) +(assert_return (invoke "i32x4.shr_s" (v128.const i32x4 1 0x40000000 0x80000000 -1) (i32.const 32)) (v128.const i32x4 1 0x40000000 0x80000000 -1)) +(assert_return (invoke "i32x4.shr_u" (v128.const i32x4 1 0x40000000 0x80000000 -1) (i32.const 1)) (v128.const i32x4 0 0x20000000 0x40000000 0x7fffffff)) +(assert_return (invoke "i32x4.shr_u" (v128.const i32x4 1 0x40000000 0x80000000 -1) (i32.const 32)) (v128.const i32x4 1 0x40000000 0x80000000 -1)) +(assert_return (invoke "i32x4.add" (v128.const i32x4 0 0x80000001 42 5) (v128.const i32x4 0 0x80000001 5 42)) (v128.const i32x4 0 2 47 47)) +(assert_return (invoke "i32x4.sub" (v128.const i32x4 0 2 47 47) (v128.const i32x4 0 0x80000001 42 5)) (v128.const i32x4 0 0x80000001 5 42)) +(assert_return (invoke "i32x4.mul" (v128.const i32x4 0 0x80000001 42 5) (v128.const i32x4 0 0x80000001 42 5)) (v128.const i32x4 0 1 1764 25)) + +;; i64x2 arithmetic +(assert_return (invoke "i64x2.neg" (v128.const i64x2 0x8000000000000000 42)) (v128.const i64x2 0x8000000000000000 -42)) +(assert_return (invoke "i64x2.any_true" (v128.const i64x2 0 0)) (i32.const 0)) +(assert_return (invoke "i64x2.any_true" (v128.const i64x2 1 0)) (i32.const 1)) +(assert_return (invoke "i64x2.any_true" (v128.const i64x2 1 1)) (i32.const 1)) +(assert_return (invoke "i64x2.all_true" (v128.const i64x2 0 0)) (i32.const 0)) +(assert_return (invoke "i64x2.all_true" (v128.const i64x2 1 0)) (i32.const 0)) +(assert_return (invoke "i64x2.all_true" (v128.const i64x2 1 1)) (i32.const 1)) +(assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x8000000000000000) (i32.const 1)) (v128.const i64x2 2 0)) +(assert_return (invoke "i64x2.shl" (v128.const i64x2 1 0x8000000000000000) (i32.const 64)) (v128.const i64x2 1 0x8000000000000000)) +(assert_return (invoke "i64x2.shr_s" (v128.const i64x2 1 0x8000000000000000) (i32.const 1)) (v128.const i64x2 0 0xc000000000000000)) +(assert_return (invoke "i64x2.shr_s" (v128.const i64x2 1 0x8000000000000000) (i32.const 64)) (v128.const i64x2 1 0x8000000000000000)) +(assert_return (invoke "i64x2.shr_u" (v128.const i64x2 1 0x8000000000000000) (i32.const 1)) (v128.const i64x2 0 0x4000000000000000)) +(assert_return (invoke "i64x2.shr_u" (v128.const i64x2 1 0x8000000000000000) (i32.const 64)) (v128.const i64x2 1 0x8000000000000000)) +(assert_return (invoke "i64x2.add" (v128.const i64x2 0x8000000000000001 42) (v128.const i64x2 0x8000000000000001 0)) (v128.const i64x2 2 42)) +(assert_return (invoke "i64x2.sub" (v128.const i64x2 2 42) (v128.const i64x2 0x8000000000000001 0)) (v128.const i64x2 0x8000000000000001 42)) + +;; f32x4 arithmetic +(assert_return (invoke "f32x4.abs" (v128.const f32x4 -0.0 nan -inf 5.0)) (v128.const f32x4 0.0 nan inf 5.0)) +(assert_return (invoke "f32x4.neg" (v128.const f32x4 -0.0 nan -inf 5.0)) (v128.const f32x4 0.0 -nan inf -5.0)) +(assert_return (invoke "f32x4.sqrt" (v128.const f32x4 -0.0 nan inf 4.0)) (v128.const f32x4 -0.0 nan inf 2.0)) +(assert_return (invoke "f32x4.add" (v128.const f32x4 nan -nan inf 42.0) (v128.const f32x4 42.0 inf inf 1.0)) (v128.const f32x4 nan -nan inf 43.0)) +(assert_return (invoke "f32x4.sub" (v128.const f32x4 nan -nan inf 42.0) (v128.const f32x4 42.0 inf -inf 1.0)) (v128.const f32x4 nan -nan inf 41.0)) +(assert_return (invoke "f32x4.mul" (v128.const f32x4 nan -nan inf 42.0) (v128.const f32x4 42.0 inf inf 2.0)) (v128.const f32x4 nan -nan inf 84.0)) +(assert_return (invoke "f32x4.div" (v128.const f32x4 nan -nan inf 42.0) (v128.const f32x4 42.0 inf 2.0 2.0)) (v128.const f32x4 nan -nan inf 21.0)) +(assert_return (invoke "f32x4.min" (v128.const f32x4 -0.0 0.0 nan 5.0) (v128.const f32x4 0.0 -0.0 5.0 nan)) (v128.const f32x4 -0.0 -0.0 nan nan)) +(assert_return (invoke "f32x4.max" (v128.const f32x4 -0.0 0.0 nan 5.0) (v128.const f32x4 0.0 -0.0 5.0 nan)) (v128.const f32x4 0.0 0.0 nan nan)) + +;; f64x2 arithmetic +(assert_return (invoke "f64x2.abs" (v128.const f64x2 -0.0 nan)) (v128.const f64x2 0.0 nan)) +(assert_return (invoke "f64x2.abs" (v128.const f64x2 -inf 5.0)) (v128.const f64x2 inf 5.0)) +(assert_return (invoke "f64x2.neg" (v128.const f64x2 -0.0 nan)) (v128.const f64x2 0.0 -nan)) +(assert_return (invoke "f64x2.neg" (v128.const f64x2 -inf 5.0)) (v128.const f64x2 inf -5.0)) +(assert_return (invoke "f64x2.sqrt" (v128.const f64x2 -0.0 nan)) (v128.const f64x2 -0.0 nan)) +(assert_return (invoke "f64x2.sqrt" (v128.const f64x2 inf 4.0)) (v128.const f64x2 inf 2.0)) +(assert_return (invoke "f64x2.add" (v128.const f64x2 nan -nan) (v128.const f64x2 42.0 inf)) (v128.const f64x2 nan -nan)) +(assert_return (invoke "f64x2.add" (v128.const f64x2 inf 42.0) (v128.const f64x2 inf 1.0)) (v128.const f64x2 inf 43.0)) +(assert_return (invoke "f64x2.sub" (v128.const f64x2 nan -nan) (v128.const f64x2 42.0 inf)) (v128.const f64x2 nan -nan)) +(assert_return (invoke "f64x2.sub" (v128.const f64x2 inf 42.0) (v128.const f64x2 -inf 1.0)) (v128.const f64x2 inf 41.0)) +(assert_return (invoke "f64x2.mul" (v128.const f64x2 nan -nan) (v128.const f64x2 42.0 inf)) (v128.const f64x2 nan -nan)) +(assert_return (invoke "f64x2.mul" (v128.const f64x2 inf 42.0) (v128.const f64x2 inf 2.0)) (v128.const f64x2 inf 84.0)) +(assert_return (invoke "f64x2.div" (v128.const f64x2 nan -nan) (v128.const f64x2 42.0 inf)) (v128.const f64x2 nan -nan)) +(assert_return (invoke "f64x2.div" (v128.const f64x2 inf 42.0) (v128.const f64x2 2.0 2.0)) (v128.const f64x2 inf 21.0)) +(assert_return (invoke "f64x2.min" (v128.const f64x2 -0.0 0.0) (v128.const f64x2 0.0 -0.0)) (v128.const f64x2 -0.0 -0.0)) +(assert_return (invoke "f64x2.min" (v128.const f64x2 nan 5.0) (v128.const f64x2 5.0 nan)) (v128.const f64x2 nan nan)) +(assert_return (invoke "f64x2.max" (v128.const f64x2 -0.0 0.0) (v128.const f64x2 0.0 -0.0)) (v128.const f64x2 0.0 0.0)) +(assert_return (invoke "f64x2.max" (v128.const f64x2 nan 5.0) (v128.const f64x2 5.0 nan)) (v128.const f64x2 nan nan)) + +;; conversions +(assert_return (invoke "i32x4.trunc_sat_f32x4_s" (v128.const f32x4 42.0 nan inf -inf)) (v128.const i32x4 42 0 2147483647 -2147483648)) +(assert_return (invoke "i32x4.trunc_sat_f32x4_u" (v128.const f32x4 42.0 nan inf -inf)) (v128.const i32x4 42 0 4294967295 0)) +(assert_return (invoke "i64x2.trunc_sat_f64x2_s" (v128.const f64x2 42.0 nan)) (v128.const i64x2 42 0)) +(assert_return (invoke "i64x2.trunc_sat_f64x2_s" (v128.const f64x2 inf -inf)) (v128.const i64x2 9223372036854775807 -9223372036854775808)) +(assert_return (invoke "i64x2.trunc_sat_f64x2_u" (v128.const f64x2 42.0 nan)) (v128.const i64x2 42 0)) +(assert_return (invoke "i64x2.trunc_sat_f64x2_u" (v128.const f64x2 inf -inf)) (v128.const i64x2 18446744073709551615 0)) +(assert_return (invoke "f32x4.convert_i32x4_s" (v128.const i32x4 0 -1 2147483647 -2147483648)) (v128.const f32x4 0.0 -1.0 2147483648.0 -2147483648.0)) +(assert_return (invoke "f32x4.convert_i32x4_u" (v128.const i32x4 0 -1 2147483647 -2147483648)) (v128.const f32x4 0.0 4294967296.0 2147483648.0 2147483648.0)) +(assert_return (invoke "f64x2.convert_i64x2_s" (v128.const i64x2 0 -1)) (v128.const f64x2 0.0 -1.0)) +(assert_return (invoke "f64x2.convert_i64x2_s" (v128.const i64x2 9223372036854775807 -9223372036854775808)) (v128.const f64x2 9223372036854775807.0 -9223372036854775808.0)) +(assert_return (invoke "f64x2.convert_i64x2_u" (v128.const i64x2 0 -1)) (v128.const f64x2 0.0 18446744073709551616.0)) +(assert_return (invoke "f64x2.convert_i64x2_u" (v128.const i64x2 9223372036854775807 -9223372036854775808)) (v128.const f64x2 9223372036854775807.0 9223372036854775808.0)) From 4b1bc24a2b66c97145d64f780a5d291f51f881b5 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Wed, 24 Jul 2019 14:06:19 -0700 Subject: [PATCH 36/37] Update cranelift to the version crates.io. This is needed in order for the resulting wasmer to be releasable. --- Cargo.lock | 94 ++++++++++++++++++------------------- lib/clif-backend/Cargo.toml | 10 ++-- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 15031ecb7bf..e973409b106 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -255,19 +255,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift-bforest" version = "0.31.0" -source = "git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e#060c5a8e3553540144ca08ca028972c57693fa6e" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cranelift-entity 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", + "cranelift-entity 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-codegen" version = "0.31.0" -source = "git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e#060c5a8e3553540144ca08ca028972c57693fa6e" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cranelift-bforest 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", - "cranelift-codegen-meta 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", - "cranelift-entity 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", + "cranelift-bforest 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen-meta 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-entity 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -277,50 +277,26 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.31.0" -source = "git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e#060c5a8e3553540144ca08ca028972c57693fa6e" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cranelift-entity 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", + "cranelift-entity 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-entity" version = "0.31.0" -source = "git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e#060c5a8e3553540144ca08ca028972c57693fa6e" - -[[package]] -name = "cranelift-frontend" -version = "0.31.0" -source = "git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e#060c5a8e3553540144ca08ca028972c57693fa6e" -dependencies = [ - "cranelift-codegen 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] +source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift-native" version = "0.31.0" -source = "git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e#060c5a8e3553540144ca08ca028972c57693fa6e" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cranelift-codegen 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", + "cranelift-codegen 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "cranelift-wasm" -version = "0.31.0" -source = "git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e#060c5a8e3553540144ca08ca028972c57693fa6e" -dependencies = [ - "cranelift-codegen 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", - "cranelift-entity 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", - "cranelift-frontend 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmparser 0.34.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "criterion" version = "0.2.11" @@ -1441,11 +1417,9 @@ name = "wasmer-clif-backend" version = "0.5.7" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-codegen 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", - "cranelift-entity 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", - "cranelift-frontend 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", - "cranelift-native 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", - "cranelift-wasm 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)", + "cranelift-codegen 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-entity 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-native 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1455,12 +1429,38 @@ dependencies = [ "serde_bytes 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmer-clif-fork-frontend 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmer-clif-fork-wasm 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-runtime-core 0.5.7", "wasmer-win-exception-handler 0.5.7", "wasmparser 0.34.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "wasmer-clif-fork-frontend" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cranelift-codegen 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasmer-clif-fork-wasm" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cranelift-codegen 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-entity 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmer-clif-fork-frontend 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.34.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "wasmer-dev-utils" version = "0.5.7" @@ -1758,13 +1758,11 @@ dependencies = [ "checksum cmake 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "2ca4386c8954b76a8415b63959337d940d724b336cabd3afe189c2b51a7e1ff0" "checksum colored 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6cdb90b60f2927f8d76139c72dbde7e10c3a2bc47c8594c9c7a66529f2687c03" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" -"checksum cranelift-bforest 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)" = "" -"checksum cranelift-codegen 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)" = "" -"checksum cranelift-codegen-meta 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)" = "" -"checksum cranelift-entity 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)" = "" -"checksum cranelift-frontend 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)" = "" -"checksum cranelift-native 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)" = "" -"checksum cranelift-wasm 0.31.0 (git+https://github.com/wasmerio/cranelift.git?rev=060c5a8e3553540144ca08ca028972c57693fa6e)" = "" +"checksum cranelift-bforest 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)" = "409f92af3dd276e112b72873a3ef02613e3c5f55b81d5d5d04f3157d4f8b8c54" +"checksum cranelift-codegen 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b303542a56fba4cbaeea099fb30ed078b50de0e765fd69f7f5f410adbe31d95b" +"checksum cranelift-codegen-meta 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0fee15ed430092a6d14b7c6d627540bef732509b8097ae31e4e35526edaa129c" +"checksum cranelift-entity 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)" = "739222c3740e4a8d6f0375bd95caba9b6c11afcba9f0e1d4f944d6bd99f84600" +"checksum cranelift-native 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce451162d18b7d82118e23ea7e12f7d8b98557549404bd71215548de79eb0736" "checksum criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0363053954f3e679645fc443321ca128b7b950a6fe288cf5f9335cc22ee58394" "checksum criterion-plot 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76f9212ddf2f4a9eb2d401635190600656a1f88a932ef53d06e7fa4c7e02fb8e" "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" @@ -1895,6 +1893,8 @@ dependencies = [ "checksum wabt 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d07edd40d190ddcbd0113c2150ccb214f47a02ff36958630ba0e5b8138ece1c1" "checksum wabt-sys 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b064c81821100adb4b71923cecfc67fef083db21c3bbd454b0162c7ffe63eeaa" "checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1" +"checksum wasmer-clif-fork-frontend 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fb483d085618e1ee40361a9b7ae815ef002012f9b165e8343cee4770dc28e9dc" +"checksum wasmer-clif-fork-wasm 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)" = "df494fd86c3b8b8f99f1f6d0f4d193efa824dd9221daec56176b36cb15925270" "checksum wasmparser 0.34.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8030ec5a7c242a91941947fdb752e9a7c0929aced954ea23c54dad1cd2611850" "checksum which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" diff --git a/lib/clif-backend/Cargo.toml b/lib/clif-backend/Cargo.toml index fee58f02865..99b5cb2efc7 100644 --- a/lib/clif-backend/Cargo.toml +++ b/lib/clif-backend/Cargo.toml @@ -9,11 +9,11 @@ edition = "2018" [dependencies] wasmer-runtime-core = { path = "../runtime-core", version = "0.5.7" } -cranelift-native = { git = "https://github.com/wasmerio/cranelift.git", rev = "060c5a8e3553540144ca08ca028972c57693fa6e" } -cranelift-codegen = { git = "https://github.com/wasmerio/cranelift.git", rev = "060c5a8e3553540144ca08ca028972c57693fa6e" } -cranelift-entity = { git = "https://github.com/wasmerio/cranelift.git", rev = "060c5a8e3553540144ca08ca028972c57693fa6e" } -cranelift-frontend = { git = "https://github.com/wasmerio/cranelift.git", rev = "060c5a8e3553540144ca08ca028972c57693fa6e" } -cranelift-wasm = { git = "https://github.com/wasmerio/cranelift.git", rev = "060c5a8e3553540144ca08ca028972c57693fa6e" } +cranelift-native = { version = "0.31" } +cranelift-codegen = { version = "0.31" } +cranelift-entity = { version = "0.31" } +cranelift-frontend = { package = "wasmer-clif-fork-frontend", version = "0.31.1" } +cranelift-wasm = { package = "wasmer-clif-fork-wasm", version = "0.31.1" } hashbrown = "0.1" target-lexicon = "0.4.0" wasmparser = "0.34.0" From 361a027ec9a0091a0bf461e6bda77eab9cb5a79c Mon Sep 17 00:00:00 2001 From: nlewycky Date: Wed, 24 Jul 2019 14:10:09 -0700 Subject: [PATCH 37/37] Only enable SIMD when using the LLVM backend. Co-Authored-By: Syrus Akbary --- src/bin/wasmer.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index b1d4140778d..2f24548e3f9 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -317,7 +317,10 @@ fn execute_wasm(options: &Run) -> Result<(), String> { if !utils::is_wasm_binary(&wasm_binary) { let mut features = wabt::Features::new(); - features.enable_simd(); + if options.backend == Backend::LLVM { + // SIMD is only supported in the LLVM backend for now + features.enable_simd(); + } wasm_binary = wabt::wat2wasm_with_features(wasm_binary, features) .map_err(|e| format!("Can't convert from wast to wasm: {:?}", e))?; }