Skip to content

Commit 82836a5

Browse files
authored
wasmi_ir: add support for the Wasm simd proposal (#1409)
* add simd crate feature to wasmi_ir * make wasmi_ir::Instruction non_exhaustive * adjust Wasmi executor for non-exhaustive Instruction * make it possible to feature guard instruction definitions * add simd splat instruction variants * add extract_lane SIMD ops * make wasmi_ir compile without simd feature * add result and docs for extract_lanes ops * import V128 for docs * add replace_lane SIMD ops * add i8x16.{swizzle,shuffle} ops * add lanewise binary int arithmetic ops * add i32x4.dot_i16x8_s op * add missing comma * add integer lanewise neg ops * add extmul SIMD ops * add extadd pairwise SIMD ops * add {add,sub}_sat SIMD ops * add Wasm i16x8.q15mulr_sat_s op * add integer min, max SIMD ops * add avgr_u SIMD ops * add integer abs SIMD ops * add shift SIMD ops * add bitwise SIMD ops * fix spelling of new ops * add missing comma * add v128.bitselect SIMD op * add all_true, any_true, bitmask and popcnt SIMD ops * add SIMD comparison ops * add f{32,64} neg and abs SIMD ops * add f{32,64} binary math SIMD ops * add f{32,64} unary math SIMD ops * add conversion SIMD ops * add narrowing conversion SIMD ops * add extend_{low,high} SIMD ops * add v128.store SIMD op * fix inconsistencies in V128Store instructions * add missing `value: Reg` to V128StoreOffset16 op * add Offset8 utility type * add Wasm v128.storeN_lane SIMD ops * add most v128 load SIMD ops * add v128.loadN_lane SIMD ops
1 parent dbcd4ba commit 82836a5

File tree

8 files changed

+3238
-1
lines changed

8 files changed

+3238
-1
lines changed

crates/ir/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ default = ["std"]
2626
std = [
2727
"wasmi_core/std",
2828
]
29+
simd = ["wasmi_core/simd"]

crates/ir/src/enum.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
#[cfg(all(feature = "simd", doc))]
2+
use crate::core::simd::V128;
3+
#[cfg(feature = "simd")]
4+
use crate::core::simd::{ImmLaneIdx16, ImmLaneIdx2, ImmLaneIdx4, ImmLaneIdx8};
15
use crate::{core::TrapCode, for_each_op, index::*, primitive::Offset64Hi, *};
26
use ::core::num::{NonZeroI32, NonZeroI64, NonZeroU32, NonZeroU64};
37

48
macro_rules! define_enum {
59
(
610
$(
711
$( #[doc = $doc:literal] )*
12+
$( #[cfg(feature = $feature_name:literal)] )?
813
#[snake_name($snake_name:ident)]
914
$name:ident
1015
$(
@@ -37,10 +42,12 @@ macro_rules! define_enum {
3742
/// `#Encoding` section of its documentation if it requires more than a single
3843
/// instruction for its encoding.
3944
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
45+
#[non_exhaustive]
4046
#[repr(u16)]
4147
pub enum Instruction {
4248
$(
4349
$( #[doc = $doc] )*
50+
$( #[cfg(feature = $feature_name)] )?
4451
$name
4552
$(
4653
{
@@ -60,6 +67,7 @@ macro_rules! define_enum {
6067
impl Instruction {
6168
$(
6269
#[doc = concat!("Creates a new [`Instruction::", stringify!($name), "`].")]
70+
$( #[cfg(feature = $feature_name)] )?
6371
pub fn $snake_name(
6472
$(
6573
$( $result_name: impl Into<$result_ty>, )?
@@ -101,6 +109,7 @@ macro_rules! define_result {
101109
(
102110
$(
103111
$( #[doc = $doc:literal] )*
112+
$( #[cfg(feature = $feature_name:literal)] )?
104113
#[snake_name($snake_name:ident)]
105114
$name:ident
106115
$(
@@ -124,6 +133,7 @@ macro_rules! define_result {
124133
pub fn result(&self) -> Option<$crate::Reg> {
125134
match *self {
126135
$(
136+
$( #[cfg(feature = $feature_name)] )?
127137
Self::$name { $( $( $result_name, )? )* .. } => {
128138
IntoReg::into_reg((
129139
$( $( $result_name )? )*

0 commit comments

Comments
 (0)