Skip to content

Commit

Permalink
Use named field for Wasmi store instructions (#1164)
Browse files Browse the repository at this point in the history
use named field for Wasmi store instructions
  • Loading branch information
Robbepop committed Sep 4, 2024
1 parent 82d7fae commit 01b17c4
Show file tree
Hide file tree
Showing 7 changed files with 520 additions and 376 deletions.
17 changes: 7 additions & 10 deletions crates/wasmi/src/engine/bytecode/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ use super::{
RegSpan,
RegSpanIter,
SignatureIdx,
StoreAtInstr,
StoreInstr,
StoreOffset16Instr,
TableIdx,
UnaryInstr,
};
Expand Down Expand Up @@ -1621,43 +1618,43 @@ macro_rules! constructor_for_store_instrs {
( @impl fn $fn_name:ident() -> Self::$op_code:ident ) => {
#[doc = concat!("Creates a new [`Instruction::", stringify!($op_code), "`].")]
pub fn $fn_name(ptr: Reg, offset: Const32<u32>) -> Self {
Self::$op_code(StoreInstr::new(ptr, offset))
Self::$op_code { ptr, offset: u32::from(offset) }
}
};
( @impl fn $fn_name:ident(at) -> Self::$op_code:ident ) => {
#[doc = concat!("Creates a new [`Instruction::", stringify!($op_code), "`].")]
pub fn $fn_name(address: Const32<u32>, value: Reg) -> Self {
Self::$op_code(StoreAtInstr::new(address, value))
Self::$op_code { address: u32::from(address), value }
}
};
( @impl fn $fn_name:ident(offset16) -> Self::$op_code:ident ) => {
#[doc = concat!("Creates a new [`Instruction::", stringify!($op_code), "`].")]
pub fn $fn_name(ptr: Reg, offset: u16, value: Reg) -> Self {
Self::$op_code(StoreOffset16Instr::new(ptr, offset.into(), value))
Self::$op_code { ptr, offset: offset.into(), value }
}
};
( @impl fn $fn_name:ident({offset16_imm<i8>}) -> Self::$op_code:ident ) => {
#[doc = concat!("Creates a new [`Instruction::", stringify!($op_code), "`].")]
pub fn $fn_name(ptr: Reg, offset: u16, value: i8) -> Self {
Self::$op_code(StoreOffset16Instr::new(ptr, offset.into(), value.into()))
Self::$op_code { ptr, offset: offset.into(), value: value.into() }
}
};
( @impl fn $fn_name:ident({offset16_imm<i16>}) -> Self::$op_code:ident ) => {
#[doc = concat!("Creates a new [`Instruction::", stringify!($op_code), "`].")]
pub fn $fn_name(ptr: Reg, offset: u16, value: i16) -> Self {
Self::$op_code(StoreOffset16Instr::new(ptr, offset.into(), value.into()))
Self::$op_code { ptr, offset: offset.into(), value: value.into() }
}
};
( @impl fn $fn_name:ident({at_imm<i8>}) -> Self::$op_code:ident ) => {
#[doc = concat!("Creates a new [`Instruction::", stringify!($op_code), "`].")]
pub fn $fn_name(address: Const32<u32>, value: i8) -> Self {
Self::$op_code(StoreAtInstr::new(address, value.into()))
Self::$op_code { address: u32::from(address), value: value.into() }
}
};
( @impl fn $fn_name:ident({at_imm<i16>}) -> Self::$op_code:ident ) => {
#[doc = concat!("Creates a new [`Instruction::", stringify!($op_code), "`].")]
pub fn $fn_name(address: Const32<u32>, value: i16) -> Self {
Self::$op_code(StoreAtInstr::new(address, value.into()))
Self::$op_code { address: u32::from(address), value: value.into() }
}
};
}
Expand Down
Loading

0 comments on commit 01b17c4

Please sign in to comment.