Repository: bytecodealliance/wasmtime
Pull request #7293 (2023-10-19 15:49:19)

Remove some unnecessary world versions
With updates to `wit-parser` and `wit-bindgen` some of these versions are now optional and can be omitted.

<!--
Please make sure you include the following information:

- If this work has been discussed elsewhere, please include a link to that
  conversation. If it was discussed in an issue, just mention "issue #...".

- Explain why this change is needed. If the details are in an issue already,
  this can be brief.

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->



Patch:
diff --git a/cranelift/codegen/src/isa/riscv64/inst.isle b/cranelift/codegen/src/isa/riscv64/inst.isle
index 921e144ae..69413862f 100644
--- a/cranelift/codegen/src/isa/riscv64/inst.isle
+++ b/cranelift/codegen/src/isa/riscv64/inst.isle
@@ -1888,9 +1888,13 @@
 (decl pure partial i8_to_imm5 (i8) Imm5)
 (extern constructor i8_to_imm5 i8_to_imm5)
 
+;; Helper to go directly from a `Value` to an `Imm5`.
+(decl imm5_from_value (Imm5) Value)
+(extractor (imm5_from_value n) (i64_from_iconst (imm5_from_i64 n)))
+
 ;; Constructor that matches a `Value` equivalent to a replicated Imm5 on all lanes.
 (decl pure partial replicated_imm5 (Value) Imm5)
-(rule (replicated_imm5 (splat (i64_from_iconst (imm5_from_i64 n)))) n)
+(rule (replicated_imm5 (splat (imm5_from_value n))) n)
 (rule (replicated_imm5 (vconst (u128_from_constant n128)))
   (if-let (u128_replicated_u64 n64) n128)
   (if-let (u64_replicated_u32 n32) n64)
diff --git a/cranelift/codegen/src/isa/riscv64/lower.isle b/cranelift/codegen/src/isa/riscv64/lower.isle
index c5bebc4c5..9df463969 100644
--- a/cranelift/codegen/src/isa/riscv64/lower.isle
+++ b/cranelift/codegen/src/isa/riscv64/lower.isle
@@ -2700,18 +2700,23 @@
 
 ;;;; Rules for `scalar_to_vector` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
+(rule 0 (lower (has_type (ty_vec_fits_in_register ty) (scalar_to_vector x)))
+  (if (ty_vector_float ty))
+  (let ((zero VReg (rv_vmv_vx (zero_reg) ty))
+        (elem VReg (rv_vfmv_sf x ty))
+        (mask VReg (gen_vec_mask 1)))
+    (rv_vmerge_vvm zero elem mask ty)))
+
 (rule 1 (lower (has_type (ty_vec_fits_in_register ty) (scalar_to_vector x)))
   (if (ty_vector_not_float ty))
   (let ((zero VReg (rv_vmv_vx (zero_reg) ty))
         (mask VReg (gen_vec_mask 1)))
     (rv_vmerge_vxm zero x mask ty)))
 
-(rule 0 (lower (has_type (ty_vec_fits_in_register ty) (scalar_to_vector x)))
-  (if (ty_vector_float ty))
+(rule 2 (lower (has_type (ty_vec_fits_in_register ty) (scalar_to_vector (imm5_from_value x))))
   (let ((zero VReg (rv_vmv_vx (zero_reg) ty))
-        (elem VReg (rv_vfmv_sf x ty))
         (mask VReg (gen_vec_mask 1)))
-    (rv_vmerge_vvm zero elem mask ty)))
+    (rv_vmerge_vim zero x mask ty)))
 
 ;;;; Rules for `sqmul_round_sat` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
diff --git a/crates/fuzzing/src/generators/config.rs b/crates/fuzzing/src/generators/config.rs
index 5a29e689f..74b0bfb72 100644
--- a/crates/fuzzing/src/generators/config.rs
+++ b/crates/fuzzing/src/generators/config.rs
@@ -171,6 +171,10 @@ impl Config {
             .allocation_strategy(self.wasmtime.strategy.to_wasmtime())
             .generate_address_map(self.wasmtime.generate_address_map);
 
+        if !self.module_config.config.simd_enabled {
+            cfg.wasm_relaxed_simd(false);
+        }
+
         let compiler_strategy = &self.wasmtime.compiler_strategy;
         let cranelift_strategy = *compiler_strategy == CompilerStrategy::Cranelift;
         cfg.strategy(self.wasmtime.compiler_strategy.to_wasmtime());
diff --git a/crates/wasi-http/src/proxy.rs b/crates/wasi-http/src/proxy.rs
index 0f8d55221..155a55fd1 100644
--- a/crates/wasi-http/src/proxy.rs
+++ b/crates/wasi-http/src/proxy.rs
@@ -2,7 +2,7 @@ use crate::{bindings, WasiHttpView};
 use wasmtime_wasi::preview2;
 
 wasmtime::component::bindgen!({
-    world: "wasi:http/proxy@0.2.0-rc-2023-10-18",
+    world: "wasi:http/proxy",
     tracing: true,
     async: true,
     with: {
@@ -40,7 +40,7 @@ pub mod sync {
     use wasmtime_wasi::preview2;
 
     wasmtime::component::bindgen!({
-        world: "wasi:http/proxy@0.2.0-rc-2023-10-18",
+        world: "wasi:http/proxy",
         tracing: true,
         async: false,
         with: {
diff --git a/crates/wasi-preview1-component-adapter/src/lib.rs b/crates/wasi-preview1-component-adapter/src/lib.rs
index f83dfd2ed..ff09003d1 100644
--- a/crates/wasi-preview1-component-adapter/src/lib.rs
+++ b/crates/wasi-preview1-component-adapter/src/lib.rs
@@ -30,7 +30,7 @@ pub mod bindings {
     #[cfg(feature = "command")]
     wit_bindgen::generate!({
         path: "../wasi/wit",
-        world: "wasi:cli/command@0.2.0-rc-2023-10-18",
+        world: "wasi:cli/command",
         std_feature,
         raw_strings,
         // Automatically generated bindings for these functions will allocate
diff --git a/crates/wasi/src/preview2/command.rs b/crates/wasi/src/preview2/command.rs
index 299b31c67..898311157 100644
--- a/crates/wasi/src/preview2/command.rs
+++ b/crates/wasi/src/preview2/command.rs
@@ -1,7 +1,7 @@
 use crate::preview2::WasiView;
 
 wasmtime::component::bindgen!({
-    world: "wasi:cli/command@0.2.0-rc-2023-10-18",
+    world: "wasi:cli/command",
     tracing: true,
     async: true,
     with: {
@@ -60,7 +60,7 @@ pub mod sync {
     use crate::preview2::WasiView;
 
     wasmtime::component::bindgen!({
-        world: "wasi:cli/command@0.2.0-rc-2023-10-18",
+        world: "wasi:cli/command",
         tracing: true,
         async: false,
         with: {
diff --git a/crates/wasi/src/preview2/mod.rs b/crates/wasi/src/preview2/mod.rs
index 902657f48..6208cb112 100644
--- a/crates/wasi/src/preview2/mod.rs
+++ b/crates/wasi/src/preview2/mod.rs
@@ -93,7 +93,7 @@ pub mod bindings {
 
     wasmtime::component::bindgen!({
         path: "wit",
-        interfaces: "include wasi:cli/reactor@0.2.0-rc-2023-10-18;",
+        world: "wasi:cli/reactor",
         tracing: true,
         async: {
             // Only these functions are `async` and everything else is sync


Test patch:
diff --git a/cranelift/filetests/filetests/isa/riscv64/simd-scalartovector.clif b/cranelift/filetests/filetests/isa/riscv64/simd-scalartovector.clif
index e9be3c845..d706a5708 100644
--- a/cranelift/filetests/filetests/isa/riscv64/simd-scalartovector.clif
+++ b/cranelift/filetests/filetests/isa/riscv64/simd-scalartovector.clif
@@ -157,3 +157,108 @@ block0(v0: f64):
 ;   .byte 0xa7, 0x04, 0x05, 0x02
 ;   ret
 
+function %scalartovector_i8_imm(i8) -> i8x16 {
+block0(v0: i8):
+    v1 = iconst.i8 7
+    v2 = scalar_to_vector.i8x16 v1
+    return v2
+}
+
+; VCode:
+; block0:
+;   vmv.v.x v11,zero #avl=16, #vtype=(e8, m1, ta, ma)
+;   vmv.v.i v0,1 #avl=2, #vtype=(e64, m1, ta, ma)
+;   vmerge.vim v15,v11,7,v0.t #avl=16, #vtype=(e8, m1, ta, ma)
+;   vse8.v v15,0(a1) #avl=16, #vtype=(e8, m1, ta, ma)
+;   ret
+;
+; Disassembled:
+; block0: ; offset 0x0
+;   .byte 0x57, 0x70, 0x08, 0xcc
+;   .byte 0xd7, 0x45, 0x00, 0x5e
+;   .byte 0x57, 0x70, 0x81, 0xcd
+;   .byte 0x57, 0xb0, 0x00, 0x5e
+;   .byte 0x57, 0x70, 0x08, 0xcc
+;   .byte 0xd7, 0xb7, 0xb3, 0x5c
+;   .byte 0xa7, 0x87, 0x05, 0x02
+;   ret
+
+function %scalartovector_i16_imm(i16) -> i16x8 {
+block0(v0: i16):
+    v1 = iconst.i16 7
+    v2 = scalar_to_vector.i16x8 v1
+    return v2
+}
+
+; VCode:
+; block0:
+;   vmv.v.x v11,zero #avl=8, #vtype=(e16, m1, ta, ma)
+;   vmv.v.i v0,1 #avl=2, #vtype=(e64, m1, ta, ma)
+;   vmerge.vim v15,v11,7,v0.t #avl=8, #vtype=(e16, m1, ta, ma)
+;   vse8.v v15,0(a1) #avl=16, #vtype=(e8, m1, ta, ma)
+;   ret
+;
+; Disassembled:
+; block0: ; offset 0x0
+;   .byte 0x57, 0x70, 0x84, 0xcc
+;   .byte 0xd7, 0x45, 0x00, 0x5e
+;   .byte 0x57, 0x70, 0x81, 0xcd
+;   .byte 0x57, 0xb0, 0x00, 0x5e
+;   .byte 0x57, 0x70, 0x84, 0xcc
+;   .byte 0xd7, 0xb7, 0xb3, 0x5c
+;   .byte 0x57, 0x70, 0x08, 0xcc
+;   .byte 0xa7, 0x87, 0x05, 0x02
+;   ret
+
+function %scalartovector_i32_imm(i32) -> i32x4 {
+block0(v0: i32):
+    v1 = iconst.i32 7
+    v2 = scalar_to_vector.i32x4 v1
+    return v2
+}
+
+; VCode:
+; block0:
+;   vmv.v.x v11,zero #avl=4, #vtype=(e32, m1, ta, ma)
+;   vmv.v.i v0,1 #avl=2, #vtype=(e64, m1, ta, ma)
+;   vmerge.vim v15,v11,7,v0.t #avl=4, #vtype=(e32, m1, ta, ma)
+;   vse8.v v15,0(a1) #avl=16, #vtype=(e8, m1, ta, ma)
+;   ret
+;
+; Disassembled:
+; block0: ; offset 0x0
+;   .byte 0x57, 0x70, 0x02, 0xcd
+;   .byte 0xd7, 0x45, 0x00, 0x5e
+;   .byte 0x57, 0x70, 0x81, 0xcd
+;   .byte 0x57, 0xb0, 0x00, 0x5e
+;   .byte 0x57, 0x70, 0x02, 0xcd
+;   .byte 0xd7, 0xb7, 0xb3, 0x5c
+;   .byte 0x57, 0x70, 0x08, 0xcc
+;   .byte 0xa7, 0x87, 0x05, 0x02
+;   ret
+
+function %scalartovector_i64_imm(i64) -> i64x2 {
+block0(v0: i64):
+    v1 = iconst.i64 7
+    v2 = scalar_to_vector.i64x2 v1
+    return v2
+}
+
+; VCode:
+; block0:
+;   vmv.v.x v11,zero #avl=2, #vtype=(e64, m1, ta, ma)
+;   vmv.v.i v0,1 #avl=2, #vtype=(e64, m1, ta, ma)
+;   vmerge.vim v15,v11,7,v0.t #avl=2, #vtype=(e64, m1, ta, ma)
+;   vse8.v v15,0(a1) #avl=16, #vtype=(e8, m1, ta, ma)
+;   ret
+;
+; Disassembled:
+; block0: ; offset 0x0
+;   .byte 0x57, 0x70, 0x81, 0xcd
+;   .byte 0xd7, 0x45, 0x00, 0x5e
+;   .byte 0x57, 0xb0, 0x00, 0x5e
+;   .byte 0xd7, 0xb7, 0xb3, 0x5c
+;   .byte 0x57, 0x70, 0x08, 0xcc
+;   .byte 0xa7, 0x87, 0x05, 0x02
+;   ret
+
diff --git a/cranelift/filetests/filetests/runtests/simd-scalartovector.clif b/cranelift/filetests/filetests/runtests/simd-scalartovector.clif
index 5ec07bc47..5a92405b6 100644
--- a/cranelift/filetests/filetests/runtests/simd-scalartovector.clif
+++ b/cranelift/filetests/filetests/runtests/simd-scalartovector.clif
@@ -15,6 +15,14 @@ block0(v0: i32):
 ; run: %scalartovector_i32(1) == [1 0 0 0]
 ; run: %scalartovector_i32(4294967295) == [4294967295 0 0 0]
 
+function %scalartovector_i32_imm(i32) -> i32x4 {
+block0(v0: i32):
+    v1 = iconst.i32 7
+    v2 = scalar_to_vector.i32x4 v1
+    return v2
+}
+; run: %scalartovector_i32_imm(1) == [7 0 0 0]
+
 function %scalartovector_i64(i64) -> i64x2 {
 block0(v0: i64):
     v1 = scalar_to_vector.i64x2 v0
@@ -24,6 +32,14 @@ block0(v0: i64):
 ; run: %scalartovector_i64(1) == [1 0]
 ; run: %scalartovector_i64(18446744073709551615) == [18446744073709551615 0]
 
+function %scalartovector_i64_imm(i64) -> i64x2 {
+block0(v0: i64):
+    v1 = iconst.i64 7
+    v2 = scalar_to_vector.i64x2 v1
+    return v2
+}
+; run: %scalartovector_i64_imm(1) == [7 0]
+
 function %scalartovector_f32(f32) -> f32x4 {
 block0(v0: f32):
     v1 = scalar_to_vector.f32x4 v0
diff --git a/crates/test-programs/src/bin/api_proxy.rs b/crates/test-programs/src/bin/api_proxy.rs
index b81e81508..6798d4e30 100644
--- a/crates/test-programs/src/bin/api_proxy.rs
+++ b/crates/test-programs/src/bin/api_proxy.rs
@@ -3,7 +3,7 @@ pub mod bindings {
 
     wit_bindgen::generate!({
         path: "../wasi-http/wit",
-        world: "wasi:http/proxy@0.2.0-rc-2023-10-18",
+        world: "wasi:http/proxy",
         exports: {
             "wasi:http/incoming-handler": T,
         },