Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Span block decoding update #212

Merged
merged 1 commit into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --release

clippy:
name: Clippy
Expand Down
208 changes: 108 additions & 100 deletions core/src/operations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ pub enum Operation {
/// Starts processing a new operation batch.
Respan,

/// Indicates the end of the program. This is used primarily to pad the execution trace to
/// the required length. Once HALT operation is executed, no other operations can be executed
/// by the VM (HALT operation itself excepted).
Halt,

// ----- field operations ---------------------------------------------------------------------
/// Pops two elements off the stack, adds them, and pushes the result back onto the stack.
Add,
Expand Down Expand Up @@ -387,105 +392,107 @@ impl Operation {
/// Returns the opcode of this operation.
pub fn op_code(&self) -> Option<u8> {
match self {
Self::Noop => Some(0b0000_0000),
Self::Assert => Some(0b0000_0001),

Self::FmpAdd => Some(0b0011_1101),
Self::FmpUpdate => Some(0b0011_1101),

Self::Push(_) => Some(0b0000_0010),

Self::Eq => Some(0b0000_0011),
Self::Eqz => Some(0b0000_0100),
Self::Eqw => Some(0b0000_0100),

Self::Add => Some(0b0000_0101),
Self::Neg => Some(0b0000_0110),
Self::Mul => Some(0b0000_0111),
Self::Inv => Some(0b0000_1000),
Self::Incr => Some(0b0000_1001),
Self::Pow2 => Some(0b0000_1001),
Self::And => Some(0b0000_1010),
Self::Or => Some(0b0000_1011),
Self::Not => Some(0b0000_1100),

Self::Pad => Some(0b0000_1101),
Self::Drop => Some(0b0000_1110),

Self::Dup0 => Some(0b0001_0000),
Self::Dup1 => Some(0b0001_0001),
Self::Dup2 => Some(0b0001_0010),
Self::Dup3 => Some(0b0001_0011),
Self::Dup4 => Some(0b0001_0100),
Self::Dup5 => Some(0b0001_0101),
Self::Dup6 => Some(0b0001_0110),
Self::Dup7 => Some(0b0001_0111),
Self::Dup9 => Some(0b0001_1000),
Self::Dup11 => Some(0b0001_1001),
Self::Dup13 => Some(0b0001_1011),
Self::Dup15 => Some(0b0001_1100),

Self::Swap => Some(0b0010_0000),
Self::SwapW => Some(0b0010_0001),
Self::SwapW2 => Some(0b0010_0010),
Self::SwapW3 => Some(0b0010_0011),

Self::MovUp2 => Some(0b0010_0001),
Self::MovUp3 => Some(0b0010_0010),
Self::MovUp4 => Some(0b0010_0011),
Self::MovUp5 => Some(0b0010_0100),
Self::MovUp6 => Some(0b0010_0101),
Self::MovUp7 => Some(0b0010_0110),
Self::MovUp9 => Some(0b0010_0111),
Self::MovUp11 => Some(0b0010_1000),
Self::MovUp13 => Some(0b0010_1001),
Self::MovUp15 => Some(0b0010_1011),

Self::MovDn2 => Some(0b0010_0110),
Self::MovDn3 => Some(0b0010_0111),
Self::MovDn4 => Some(0b0010_1000),
Self::MovDn5 => Some(0b0010_1001),
Self::MovDn6 => Some(0b0010_1010),
Self::MovDn7 => Some(0b0010_1010),
Self::MovDn9 => Some(0b0010_1010),
Self::MovDn11 => Some(0b0010_1010),
Self::MovDn13 => Some(0b0010_1010),
Self::MovDn15 => Some(0b0010_1010),

Self::CSwap => Some(0b0010_1010),
Self::CSwapW => Some(0b0010_1010),

Self::U32split => Some(0b0011_0000),
Self::U32add => Some(0b0011_0001),
Self::U32addc => Some(0b0011_0010),
Self::U32sub => Some(0b0011_0011),
Self::U32mul => Some(0b0011_0100),
Self::U32madd => Some(0b0011_0101),
Self::U32div => Some(0b0011_0110),
Self::U32and => Some(0b0011_0111),
Self::U32or => Some(0b0011_1000),
Self::U32xor => Some(0b0011_1001),
Self::U32assert2 => Some(0b0111_1001),

Self::LoadW => Some(0b0011_1010),
Self::StoreW => Some(0b0011_1011),

Self::Read => Some(0b0011_1100),
Self::ReadW => Some(0b0011_1101),

Self::SDepth => Some(0b0011_1101),

Self::RpPerm => Some(0b0011_1111),
Self::MpVerify => Some(0b0011_1110),
Self::MrUpdate(_) => Some(0b0011_1110),

Self::End => Some(0b0111_0000),
Self::Join => Some(0b0111_0001),
Self::Split => Some(0b0111_0010),
Self::Loop => Some(0b0111_0011),
Self::Repeat => Some(0b0111_0100),
Self::Respan => Some(0b0111_1000),
Self::Span => Some(0b0111_1111),
Self::Noop => Some(0),
Self::Assert => Some(1),

Self::FmpAdd => Some(2),
Self::FmpUpdate => Some(3),

Self::Push(_) => Some(4),

Self::Eq => Some(5),
Self::Eqz => Some(6),
Self::Eqw => Some(7),
grjte marked this conversation as resolved.
Show resolved Hide resolved

Self::Add => Some(8),
Self::Neg => Some(9),
Self::Mul => Some(10),
Self::Inv => Some(11),
Self::Incr => Some(12),
Self::Pow2 => Some(13),
Self::And => Some(14),
Self::Or => Some(15),
Self::Not => Some(16),

Self::Pad => Some(17),
Self::Drop => Some(18),

Self::Dup0 => Some(19),
Self::Dup1 => Some(20),
Self::Dup2 => Some(21),
Self::Dup3 => Some(22),
Self::Dup4 => Some(23),
Self::Dup5 => Some(24),
Self::Dup6 => Some(25),
Self::Dup7 => Some(26),
Self::Dup9 => Some(27),
Self::Dup11 => Some(28),
Self::Dup13 => Some(29),
Self::Dup15 => Some(30),

Self::Swap => Some(31),
Self::SwapW => Some(32),
Self::SwapW2 => Some(33),
Self::SwapW3 => Some(34),

Self::MovUp2 => Some(35),
Self::MovUp3 => Some(36),
Self::MovUp4 => Some(37),
Self::MovUp5 => Some(38),
Self::MovUp6 => Some(39),
Self::MovUp7 => Some(40),
Self::MovUp9 => Some(41),
Self::MovUp11 => Some(42),
Self::MovUp13 => Some(43),
Self::MovUp15 => Some(44),

Self::MovDn2 => Some(45),
Self::MovDn3 => Some(46),
Self::MovDn4 => Some(47),
Self::MovDn5 => Some(48),
Self::MovDn6 => Some(49),
Self::MovDn7 => Some(50),
Self::MovDn9 => Some(51),
Self::MovDn11 => Some(52),
Self::MovDn13 => Some(53),
Self::MovDn15 => Some(54),

Self::CSwap => Some(55),
Self::CSwapW => Some(56),

Self::U32assert2 => Some(57),
Self::U32split => Some(58),
Self::U32add => Some(59),
Self::U32addc => Some(60),
Self::U32sub => Some(61),
Self::U32mul => Some(62),
Self::U32madd => Some(63),
Self::U32div => Some(64),

Self::U32and => Some(65),
Self::U32or => Some(66),
Self::U32xor => Some(67),

Self::LoadW => Some(68),
Self::StoreW => Some(69),

Self::Read => Some(70),
Self::ReadW => Some(71),

Self::SDepth => Some(72),

Self::RpPerm => Some(73),
Self::MpVerify => Some(74),
Self::MrUpdate(_) => Some(75),

Self::End => Some(76),
Self::Join => Some(77),
Self::Split => Some(78),
Self::Loop => Some(79),
Self::Repeat => Some(80),
Self::Respan => Some(81),
Self::Span => Some(82),
Self::Halt => Some(83),

Self::Debug(_) => None,
Self::Advice(_) => None,
Expand Down Expand Up @@ -529,6 +536,7 @@ impl fmt::Display for Operation {
Self::Span => write!(f, "span"),
Self::Respan => write!(f, "respan"),
Self::End => write!(f, "end"),
Self::Halt => write!(f, "halt"),

// ----- field operations -------------------------------------------------------------
Self::Add => write!(f, "add"),
Expand All @@ -547,6 +555,7 @@ impl fmt::Display for Operation {
Self::Eqw => write!(f, "eqw"),

// ----- u32 operations ---------------------------------------------------------------
Self::U32assert2 => write!(f, "u32assert2"),
Self::U32split => write!(f, "u32split"),
Self::U32add => write!(f, "u32add"),
Self::U32addc => write!(f, "u32addc"),
Expand All @@ -558,7 +567,6 @@ impl fmt::Display for Operation {
Self::U32and => write!(f, "u32and"),
Self::U32or => write!(f, "u32or"),
Self::U32xor => write!(f, "u32xor"),
Self::U32assert2 => write!(f, "u32assert2"),

// ----- stack manipulation -----------------------------------------------------------
Self::Drop => write!(f, "drop"),
Expand Down
2 changes: 1 addition & 1 deletion core/src/program/blocks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub use call_block::Call;
pub use join_block::Join;
pub use loop_block::Loop;
pub use proxy_block::Proxy;
pub use span_block::{OpBatch, Span};
pub use span_block::{OpBatch, Span, BATCH_SIZE as OP_BATCH_SIZE, GROUP_SIZE as OP_GROUP_SIZE};
pub use split_block::Split;

// PROGRAM BLOCK
Expand Down
Loading