mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-10 01:33:07 +00:00
* Use static `KERNEL` in tests * Print opcode count * Update criterion * Combine all syscalls into one flag (#802) * Combine all syscalls into one flag * Minor: typo * Daniel PR comments * Check that `le_sum` won't overflow * security notes * Test reverse_index_bits Thanks to Least Authority for this * clippy * EVM shift left/right operations (#801) * First parts of shift implementation. * Disable range check errors. * Tidy up ASM. * Update comments; fix some .sum() expressions. * First full draft of shift left/right. * Missed a +1. * Clippy. * Address Jacqui's comments. * Add comment. * Fix missing filter. * Address second round of comments from Jacqui. * Remove signed operation placeholders from arithmetic table. (#812) Co-authored-by: wborgeaud <williamborgeaud@gmail.com> Co-authored-by: Daniel Lubarov <daniel@lubarov.com> Co-authored-by: Jacqueline Nabaglo <jakub@mirprotocol.org> Co-authored-by: Hamish Ivey-Law <426294+unzvfu@users.noreply.github.com>
78 lines
2.5 KiB
Rust
78 lines
2.5 KiB
Rust
use ethereum_types::U256;
|
|
|
|
use crate::generation::prover_input::ProverInputFn;
|
|
|
|
#[derive(Debug)]
|
|
pub(crate) struct File {
|
|
pub(crate) body: Vec<Item>,
|
|
}
|
|
|
|
#[derive(Eq, PartialEq, Clone, Debug)]
|
|
pub(crate) enum Item {
|
|
/// Defines a new macro: name, params, body.
|
|
MacroDef(String, Vec<String>, Vec<Item>),
|
|
/// Calls a macro: name, args.
|
|
MacroCall(String, Vec<PushTarget>),
|
|
/// Repetition, like `%rep` in NASM.
|
|
Repeat(U256, Vec<Item>),
|
|
/// A directive to manipulate the stack according to a specified pattern.
|
|
/// The first list gives names to items on the top of the stack.
|
|
/// The second list specifies replacement items.
|
|
/// Example: `(a, b, c) -> (c, 5, 0x20, @SOME_CONST, a)`.
|
|
StackManipulation(Vec<StackPlaceholder>, Vec<StackReplacement>),
|
|
/// Declares a global label.
|
|
GlobalLabelDeclaration(String),
|
|
/// Declares a label that is local to the current file.
|
|
LocalLabelDeclaration(String),
|
|
/// Declares a label that is local to the macro it's declared in.
|
|
MacroLabelDeclaration(String),
|
|
/// A `PUSH` operation.
|
|
Push(PushTarget),
|
|
/// A `ProverInput` operation.
|
|
ProverInput(ProverInputFn),
|
|
/// Any opcode besides a PUSH opcode.
|
|
StandardOp(String),
|
|
/// Literal hex data; should contain an even number of hex chars.
|
|
Bytes(Vec<u8>),
|
|
/// Creates a table of addresses from a list of labels.
|
|
Jumptable(Vec<String>),
|
|
}
|
|
|
|
/// The left hand side of a %stack stack-manipulation macro.
|
|
#[derive(Eq, PartialEq, Clone, Debug)]
|
|
pub(crate) struct StackPlaceholder(pub String, pub usize);
|
|
|
|
/// The right hand side of a %stack stack-manipulation macro.
|
|
#[derive(Eq, PartialEq, Clone, Debug)]
|
|
pub(crate) enum StackReplacement {
|
|
Literal(U256),
|
|
/// Can be either a named item or a label.
|
|
Identifier(String),
|
|
Label(String),
|
|
MacroLabel(String),
|
|
MacroVar(String),
|
|
Constant(String),
|
|
}
|
|
|
|
impl From<PushTarget> for StackReplacement {
|
|
fn from(target: PushTarget) -> Self {
|
|
match target {
|
|
PushTarget::Literal(x) => Self::Literal(x),
|
|
PushTarget::Label(l) => Self::Label(l),
|
|
PushTarget::MacroLabel(l) => Self::MacroLabel(l),
|
|
PushTarget::MacroVar(v) => Self::MacroVar(v),
|
|
PushTarget::Constant(c) => Self::Constant(c),
|
|
}
|
|
}
|
|
}
|
|
|
|
/// The target of a `PUSH` operation.
|
|
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
|
|
pub(crate) enum PushTarget {
|
|
Literal(U256),
|
|
Label(String),
|
|
MacroLabel(String),
|
|
MacroVar(String),
|
|
Constant(String),
|
|
}
|