pub(crate) type TypeIdx = u32;
pub(crate) type FuncIdx = u32;
pub(crate) type TableIdx = u32;
pub(crate) type GlobalIdx = u32;
pub(crate) type LocalIdx = u32;
pub(crate) type DataIdx = u32;
pub(crate) type ElemIdx = u32;
pub(crate) type Slot = u32;
#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub(crate) struct LoadArg {
pub dst: Slot,
pub addr: Slot,
pub offset: u32,
}
#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub(crate) struct StoreArg {
pub addr: Slot,
pub val: Slot,
pub offset: u32,
}
pub(crate) const BIG_MEMARG: u32 = u32::MAX;
#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub(crate) struct BigMemArg {
pub memory: u32,
pub offset: u64,
}
#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub(crate) struct BranchTarget {
pub ip: u32,
pub keep: u16,
pub pop: u16,
}
#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub(crate) struct BrTableRange {
pub base: u32,
pub len: u32,
}
pub(crate) const NULLABLE_BIT: u32 = 1 << 31;
#[derive(Copy, Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[rustfmt::skip]
pub(crate) enum CmpKind { Eq, Ne, LtS, LtU, GtS, GtU, LeS, LeU, GeS, GeU }
impl CmpKind {
pub(crate) fn mirror(self) -> Self {
use CmpKind::{Eq, GeS, GeU, GtS, GtU, LeS, LeU, LtS, LtU, Ne};
match self {
Eq => Eq,
Ne => Ne,
LtS => GtS,
GtS => LtS,
LtU => GtU,
GtU => LtU,
LeS => GeS,
GeS => LeS,
LeU => GeU,
GeU => LeU,
}
}
}