Skip to content

Commit

Permalink
Merge pull request #1115 from 0xPolygonMiden/andrew-remove-checked-ops
Browse files Browse the repository at this point in the history
Remove `checked` variants of u32 MASM instructions
  • Loading branch information
bobbinth authored Nov 2, 2023
2 parents ab96617 + dfa3ac4 commit 01ee16a
Show file tree
Hide file tree
Showing 40 changed files with 1,315 additions and 3,425 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Introduced the `emit.<event_id>` assembly instruction (#1119).
- Introduced the `procref.<proc_name>` assembly instruction (#1113).
- Added the ability to use constants as counters in `repeat` loops (#1124).
- All `checked` versions of the u32 instructions were removed. All `unchecked` versions were renamed: this mode specification was removed from their titles (#1115).

#### Stdlib
- Introduced `std::utils` module with `is_empty_word` procedure. Refactored `std::collections::smt`
Expand Down
2 changes: 1 addition & 1 deletion assembly/src/assembler/instruction/field_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ pub fn eqw(span: &mut SpanBuilder) -> Result<Option<CodeBlock>, AssemblyError> {
])
}

/// Appends a sequence of operations to to pop the top 2 elements off the stack and do a "less
/// Appends a sequence of operations to pop the top 2 elements off the stack and do a "less
/// than" comparison. The stack is expected to be arranged as [b, a, ...] (from the top). A value
/// of 1 is pushed onto the stack if a < b. Otherwise, 0 is pushed.
///
Expand Down
85 changes: 27 additions & 58 deletions assembly/src/assembler/instruction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,83 +112,52 @@ impl Assembler {
Instruction::U32Cast => span.add_ops([U32split, Drop]),
Instruction::U32Split => span.add_op(U32split),

Instruction::U32CheckedAdd => u32_ops::u32add(span, Checked, None),
Instruction::U32CheckedAddImm(v) => u32_ops::u32add(span, Checked, Some(*v)),
Instruction::U32OverflowingAdd => u32_ops::u32add(span, Overflowing, None),
Instruction::U32OverflowingAddImm(v) => u32_ops::u32add(span, Overflowing, Some(*v)),
Instruction::U32WrappingAdd => u32_ops::u32add(span, Wrapping, None),
Instruction::U32WrappingAddImm(v) => u32_ops::u32add(span, Wrapping, Some(*v)),
Instruction::U32OverflowingAdd3 => span.add_op(U32add3),
Instruction::U32WrappingAdd3 => span.add_ops([U32add3, Drop]),

Instruction::U32CheckedSub => u32_ops::u32sub(span, Checked, None),
Instruction::U32CheckedSubImm(v) => u32_ops::u32sub(span, Checked, Some(*v)),
Instruction::U32OverflowingSub => u32_ops::u32sub(span, Overflowing, None),
Instruction::U32OverflowingSubImm(v) => u32_ops::u32sub(span, Overflowing, Some(*v)),
Instruction::U32WrappingSub => u32_ops::u32sub(span, Wrapping, None),
Instruction::U32WrappingSubImm(v) => u32_ops::u32sub(span, Wrapping, Some(*v)),

Instruction::U32CheckedMul => u32_ops::u32mul(span, Checked, None),
Instruction::U32CheckedMulImm(v) => u32_ops::u32mul(span, Checked, Some(*v)),
Instruction::U32OverflowingMul => u32_ops::u32mul(span, Overflowing, None),
Instruction::U32OverflowingMulImm(v) => u32_ops::u32mul(span, Overflowing, Some(*v)),
Instruction::U32WrappingMul => u32_ops::u32mul(span, Wrapping, None),
Instruction::U32WrappingMulImm(v) => u32_ops::u32mul(span, Wrapping, Some(*v)),
Instruction::U32OverflowingMadd => span.add_op(U32madd),
Instruction::U32WrappingMadd => span.add_ops([U32madd, Drop]),

Instruction::U32CheckedDiv => u32_ops::u32div(span, Checked, None),
Instruction::U32CheckedDivImm(v) => u32_ops::u32div(span, Checked, Some(*v)),
Instruction::U32UncheckedDiv => u32_ops::u32div(span, Unchecked, None),
Instruction::U32UncheckedDivImm(v) => u32_ops::u32div(span, Unchecked, Some(*v)),
Instruction::U32CheckedMod => u32_ops::u32mod(span, Checked, None),
Instruction::U32CheckedModImm(v) => u32_ops::u32mod(span, Checked, Some(*v)),
Instruction::U32UncheckedMod => u32_ops::u32mod(span, Unchecked, None),
Instruction::U32UncheckedModImm(v) => u32_ops::u32mod(span, Unchecked, Some(*v)),
Instruction::U32CheckedDivMod => u32_ops::u32divmod(span, Checked, None),
Instruction::U32CheckedDivModImm(v) => u32_ops::u32divmod(span, Checked, Some(*v)),
Instruction::U32UncheckedDivMod => u32_ops::u32divmod(span, Unchecked, None),
Instruction::U32UncheckedDivModImm(v) => u32_ops::u32divmod(span, Unchecked, Some(*v)),

Instruction::U32CheckedAnd => span.add_op(U32and),
Instruction::U32CheckedOr => span.add_ops([Dup1, Dup1, U32and, Neg, Add, Add]),
Instruction::U32CheckedXor => span.add_op(U32xor),
Instruction::U32CheckedNot => u32_ops::u32not(span),
Instruction::U32CheckedShl => u32_ops::u32shl(span, Checked, None),
Instruction::U32CheckedShlImm(v) => u32_ops::u32shl(span, Checked, Some(*v)),
Instruction::U32UncheckedShl => u32_ops::u32shl(span, Unchecked, None),
Instruction::U32UncheckedShlImm(v) => u32_ops::u32shl(span, Unchecked, Some(*v)),
Instruction::U32CheckedShr => u32_ops::u32shr(span, Checked, None),
Instruction::U32CheckedShrImm(v) => u32_ops::u32shr(span, Checked, Some(*v)),
Instruction::U32UncheckedShr => u32_ops::u32shr(span, Unchecked, None),
Instruction::U32UncheckedShrImm(v) => u32_ops::u32shr(span, Unchecked, Some(*v)),
Instruction::U32CheckedRotl => u32_ops::u32rotl(span, Checked, None),
Instruction::U32CheckedRotlImm(v) => u32_ops::u32rotl(span, Checked, Some(*v)),
Instruction::U32UncheckedRotl => u32_ops::u32rotl(span, Unchecked, None),
Instruction::U32UncheckedRotlImm(v) => u32_ops::u32rotl(span, Unchecked, Some(*v)),
Instruction::U32CheckedRotr => u32_ops::u32rotr(span, Checked, None),
Instruction::U32CheckedRotrImm(v) => u32_ops::u32rotr(span, Checked, Some(*v)),
Instruction::U32UncheckedRotr => u32_ops::u32rotr(span, Unchecked, None),
Instruction::U32UncheckedRotrImm(v) => u32_ops::u32rotr(span, Unchecked, Some(*v)),
Instruction::U32CheckedPopcnt => u32_ops::u32popcnt(span, Checked),
Instruction::U32UncheckedPopcnt => u32_ops::u32popcnt(span, Unchecked),

Instruction::U32CheckedEq => u32_ops::u32eq(span, None),
Instruction::U32CheckedEqImm(v) => u32_ops::u32eq(span, Some(*v)),
Instruction::U32CheckedNeq => u32_ops::u32neq(span, None),
Instruction::U32CheckedNeqImm(v) => u32_ops::u32neq(span, Some(*v)),
Instruction::U32CheckedLt => u32_ops::u32lt(span, Checked),
Instruction::U32UncheckedLt => u32_ops::u32lt(span, Unchecked),
Instruction::U32CheckedLte => u32_ops::u32lte(span, Checked),
Instruction::U32UncheckedLte => u32_ops::u32lte(span, Unchecked),
Instruction::U32CheckedGt => u32_ops::u32gt(span, Checked),
Instruction::U32UncheckedGt => u32_ops::u32gt(span, Unchecked),
Instruction::U32CheckedGte => u32_ops::u32gte(span, Checked),
Instruction::U32UncheckedGte => u32_ops::u32gte(span, Unchecked),
Instruction::U32CheckedMin => u32_ops::u32min(span, Checked),
Instruction::U32UncheckedMin => u32_ops::u32min(span, Unchecked),
Instruction::U32CheckedMax => u32_ops::u32max(span, Checked),
Instruction::U32UncheckedMax => u32_ops::u32max(span, Unchecked),
Instruction::U32Div => u32_ops::u32div(span, None),
Instruction::U32DivImm(v) => u32_ops::u32div(span, Some(*v)),
Instruction::U32Mod => u32_ops::u32mod(span, None),
Instruction::U32ModImm(v) => u32_ops::u32mod(span, Some(*v)),
Instruction::U32DivMod => u32_ops::u32divmod(span, None),
Instruction::U32DivModImm(v) => u32_ops::u32divmod(span, Some(*v)),

Instruction::U32And => span.add_op(U32and),
Instruction::U32Or => span.add_ops([Dup1, Dup1, U32and, Neg, Add, Add]),
Instruction::U32Xor => span.add_op(U32xor),
Instruction::U32Not => u32_ops::u32not(span),
Instruction::U32Shl => u32_ops::u32shl(span, None),
Instruction::U32ShlImm(v) => u32_ops::u32shl(span, Some(*v)),
Instruction::U32Shr => u32_ops::u32shr(span, None),
Instruction::U32ShrImm(v) => u32_ops::u32shr(span, Some(*v)),
Instruction::U32Rotl => u32_ops::u32rotl(span, None),
Instruction::U32RotlImm(v) => u32_ops::u32rotl(span, Some(*v)),
Instruction::U32Rotr => u32_ops::u32rotr(span, None),
Instruction::U32RotrImm(v) => u32_ops::u32rotr(span, Some(*v)),
Instruction::U32Popcnt => u32_ops::u32popcnt(span),

Instruction::U32Lt => u32_ops::u32lt(span),
Instruction::U32Lte => u32_ops::u32lte(span),
Instruction::U32Gt => u32_ops::u32gt(span),
Instruction::U32Gte => u32_ops::u32gte(span),
Instruction::U32Min => u32_ops::u32min(span),
Instruction::U32Max => u32_ops::u32max(span),

// ----- stack manipulation -----------------------------------------------------------
Instruction::Drop => span.add_op(Drop),
Expand Down
Loading

0 comments on commit 01ee16a

Please sign in to comment.